Суббота, 04 Мая 2024, 13:35

Приветствую Вас Гость

[ Новые сообщения · Игроделы · Правила · Поиск ]
  • Страница 1 из 1
  • 1
Форум игроделов » Движки для разработки игр и сложные системы разработки » Движки для браузерных игр » Переделать шаблон (Шаблон c использованием Smarty)
Переделать шаблон
NosorogДата: Суббота, 03 Сентября 2011, 20:44 | Сообщение # 1
участник
Сейчас нет на сайте
Есть шаблон, в который выводится список зданий (каждое здание в новой строке), мне нужно сделать чтобы выводилось по три здания в одной строке!
Вот собственно сам шаблон:

Code
<table align="top" width="530">    
     {foreach item=BuildInfoRow from=$BuildInfoList}
     <tr>
      <td rowspan="2" style="background-image:url({$dpath}img/invisible.png);border:none;">
       <a href="#" onclick="return Dialog.info({$BuildInfoRow.id})">
        <img src="{$dpath}gebaeude/{$BuildInfoRow.id}.png" alt="{$BuildInfoRow.name}" width="120" height="120">
       </a>
      </td>
      <th>
       <a href="#" onclick="return Dialog.info({$BuildInfoRow.id})">{$BuildInfoRow.name}</a>{if $BuildInfoRow.level > 0} ({$bd_lvl} {$BuildInfoRow.level}){/if}
      </th>
     </tr>
     <tr>
      <td>
       <table style="width:100%">
        <tr>
         <td class="transparent left" style="width:90%;padding:10px;">{$BuildInfoRow.descriptions}<br>{$BuildInfoRow.price}</td>

        </tr>
                     <td class="transparent" style="vertical-align:middle;background-image:url({$dpath}img/invisible.png);border:none;">
         {$BuildInfoRow.BuildLink}   ||     
          <a class="tooltip_sticky" name="<table style=\'width:100%;margin:0;padding:0\'><tr><th colspan=\'2\'>{$bd_price_for_destroy} {$BuildInfoRow.name} {$BuildInfoRow.level}</th></tr><tr><td class=\'transparent\'>{$Metal}</td><td class=\'transparent\'>{$BuildInfoRow.destroyress.metal}</td></tr><tr><td class=\'transparent\'>{$Crystal}</td><td class=\'transparent\'>{$BuildInfoRow.destroyress.crystal}</td></tr><tr><td class=\'transparent\'>{$Deuterium}</td><td class=\'transparent\'>{$BuildInfoRow.destroyress.deuterium}</td></tr><tr><td class=\'transparent\'>{$Norio}</td><td class=\'transparent\'>{$BuildInfoRow.destroyress.norio}</td></tr><tr><td class=\'transparent\'>{$bd_destroy_time}</td><td class=\'transparent\'>{$BuildInfoRow.destroytime}</td></tr><tr><td colspan=\'2\' class=\'transparent\'><a href=game.php?page=buildings&cmd=destroy&building={$BuildInfoRow.id}>{$bd_dismantle}</a></td></tr></table>">{$bd_dismantle}</a>
         </td>
       </table>
      </td>
     </tr>
     <tr>
       <td colspan="2" style="margin-bottom:5px;">     
       <table style="width:100%">
        <tr>
         <td class="transparent left">
          <font color="#0871a2"><b>{$bd_remaining}:</b></font>   
          {foreach key=ResName item=ResCount from=$BuildInfoRow.restprice}
          {$ResName}: <span style="font-weight:700">{$ResCount}</span>   
          {/foreach}
          <br>
         </td>
         <td class="transparent">
          <font color="orange"><b>{$fgf_time}</b></font><br>{$BuildInfoRow.time}
         </td>
        </tr>
        <tr>     
         <td class="transparent left" style="width:68%">
          {if $BuildInfoRow.EnergyNeed}
          <font color="#0871a2"><b>{$bd_next_level}</b></font>   
          {$BuildInfoRow.EnergyNeed}
          {/if}
          {if $BuildInfoRow.level > 0 && $BuildInfoRow.id != 33}
          <br>{if $BuildInfoRow.id == 43}<a href="javascript:OpenPopup('game.php?page=infos&gid=43', '', 720, 300);">{$bd_jump_gate_action}</a>{/if}
          {/if}
             
         </td>
        </tr>    
       </table>
      </td>
     </tr>
     {/foreach}
       </table>


А это функция обработчик:

Code
{
global $ProdGrid, $LNG, $resource, $reslist, $CONF, $db, $PLANET, $USER;

     include_once(ROOT_PATH . 'includes/functions/IsTechnologieAccessible.php');
     include_once(ROOT_PATH . 'includes/functions/GetElementPrice.php');
        
     $TheCommand   = request_var('cmd','');
           $Element      = request_var('building',0);
           $ListID       = request_var('listid',0);

     $PlanetRess  = new ResourceUpdate();
     $PlanetRess->CalcResource();
        
     if(!empty($Element) && $USER['urlaubs_modus'] == 0 && (IsTechnologieAccessible($USER, $PLANET, $Element) && in_array($Element, $reslist['allow'][$PLANET['planet_type']])) || $TheCommand == "cancel" || $TheCommand == "remove")
     {
      if(($Element == 31 && $USER["b_tech_planet"] != 0) || (($Element == 15 || $Element == 21) && !empty($PLANET['b_hangar_id'])))
       $TheCommand    = '';
          
      switch($TheCommand)
      {
       case 'cancel':
        $this->CancelBuildingFromQueue($PlanetRess);
       break;
       case 'remove':
        $this->RemoveBuildingFromQueue($ListID, $PlanetRess);
       break;
       case 'insert':
        $this->AddBuildingToQueue($Element, true);
       break;
       case 'destroy':
        $this->AddBuildingToQueue($Element, false);
       break;
      }
     }
     $PlanetRess->SavePlanetToDB();
     if($_SERVER['REQUEST_METHOD'] === 'POST') {
      header('HTTP/1.0 204 No Content');
      exit;
     }
        
     $Queue     = $this->ShowBuildingQueue();
        
     $CanBuildElement  = (count($Queue) < MAX_BUILDING_QUEUE_SIZE) ? true : false;
     $CurrentMaxFields   = CalculateMaxPlanetFields($PLANET);
     $RoomIsOk    = ($PLANET["field_current"] < ($CurrentMaxFields - count($Queue))) ? true : false;
          
     $BuildEnergy  = $USER[$resource[113]];
     $BuildLevelFactor   = 10;
     $BuildTemp          = $PLANET['temp_max'];
     foreach($reslist['allow'][$PLANET['planet_type']] as $ID => $Element)
     {
      if (!IsTechnologieAccessible($USER, $PLANET, $Element))
       continue;

      $HaveRessources         = IsElementBuyable ($USER, $PLANET, $Element, true, false);
      if(in_array($Element, $reslist['prod']))
      {
       $BuildLevel          = $PLANET[$resource[$Element]];
       $Need                  = floor(eval($ProdGrid[$Element]['formule']['energy']) * $CONF['resource_multiplier']);
       $BuildLevel      += 1;
       $Prod                  = floor(eval($ProdGrid[$Element]['formule']['energy']) * $CONF['resource_multiplier']);
       $EnergyNeed          = $Prod - $Need;
      } else
       unset($EnergyNeed);
          
      $BulidLink         = '';
      $NextBuildLevel         = $PLANET[$resource[$Element]] + 1;

      if ($RoomIsOk && $CanBuildElement)
      $BulidLink = ($HaveRessources == true) ? '<a href="game.php?page=buildings&cmd=insert&building='.$Element.'" class="post" style="color:lime">'.(($PLANET['b_building'] != 0) ? $LNG['bd_add_to_list'] : (($NextBuildLevel == 1) ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel)).'</a>' : '<span style="color:red">'.(($NextBuildLevel == 1) ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel).'</span>';
      elseif ($RoomIsOk && !$CanBuildElement)
       $BulidLink = '<span style="color:red">'.(($NextBuildLevel == 1) ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel) .'</span>';
      else
       $BulidLink = '<span style="color:red">'.$LNG['bd_no_more_fields'].'</span>';

      if (($Element == 6 || $Element == 31) && $USER['b_tech'] > TIMESTAMP)
       $BulidLink = '<span style="color:red">'.$LNG['bd_working'].'</span>';
      elseif (($Element == 15 || $Element == 21) && !empty($PLANET['b_hangar_id']))
       $BulidLink = '<span style="color:red">'.$LNG['bd_working'].'</span>';
         
      $BuildInfoList[]    = array(
       'id'   => $Element,
       'name'   => $LNG['tech'][$Element],
       'descriptions'    => $LNG['res']['descriptions'][$Element],
       'level'   => $PLANET[$resource[$Element]],
       'destroyress'    => array_map('pretty_number', GetBuildingPrice ($USER, $PLANET, $Element, true, true)),
       'destroytime'    => pretty_time(GetBuildingTime($USER, $PLANET, $Element, true)),
       'price'   => GetElementPrice($USER, $PLANET, $Element, true),
       'time'         => pretty_time(GetBuildingTime($USER, $PLANET, $Element)),
       'EnergyNeed'    => (isset($EnergyNeed)) ? sprintf(($EnergyNeed < 0) ? $LNG['bd_need_engine'] : $LNG['bd_more_engine'] , pretty_number(abs($EnergyNeed)), $LNG['Energy']) : "",
       'BuildLink'  => $BulidLink,
       'restprice'  => $this->GetRestPrice($Element),
      );
     }
        
     $template   = new template();

     if ($PLANET['b_building'] != 0)
     {
      $template->execscript('ReBuildView();Buildlist();');
      $template->loadscript('buildlist.js');
      $template->assign_vars(array(
       'data'    => json_encode(array('bd_cancel' => $LNG['bd_cancel'], 'bd_continue' => $LNG['bd_continue'], 'bd_finished' => $LNG['bd_finished'], 'build' => $Queue)),
      ));
     }

     $template->assign_vars(array(
      'BuildInfoList'   => $BuildInfoList,
      'bd_lvl'    => $LNG['bd_lvl'],
      'bd_next_level'   => $LNG['bd_next_level'],
      'Metal'     => $LNG['Metal'],
      'Crystal'    => $LNG['Crystal'],
      'Deuterium'    => $LNG['Deuterium'],
      'Norio'    => $LNG['Norio'],
      'Darkmatter'         => $LNG['Darkmatter'],
      'bd_dismantle'   => $LNG['bd_dismantle'],
      'fgf_time'    => $LNG['fgf_time'],
      'bd_remaining'   => $LNG['bd_remaining'],
      'bd_jump_gate_action'    => $LNG['bd_jump_gate_action'],
      'bd_price_for_destroy'    => $LNG['bd_price_for_destroy'],
      'bd_destroy_time'  => $LNG['bd_destroy_time'],
     ));
         
     $template->show("buildings_overview.tpl");
    }


Есть задумка - как это сделать, но не могу реализовать!
Я представляю себе это как-то так:
Code
for ($x=1; $x<4; $x++) { if ($x==1) $tr="<tr>"; if ($x==3) $tr1="</tr>";}


Спасибо всем кто, хотя бы заморочился...
Проблема решена!


Классическая ошибка, которую совершают проектировщики абсолютно надёжных систем, - недооценка изобретательности клинических идиотов.

Сообщение отредактировал Nosorog - Вторник, 06 Сентября 2011, 18:56
Форум игроделов » Движки для разработки игр и сложные системы разработки » Движки для браузерных игр » Переделать шаблон (Шаблон c использованием Smarty)
  • Страница 1 из 1
  • 1
Поиск:

Все права сохранены. GcUp.ru © 2008-2024 Рейтинг