-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #409 from hemberger/warp-creation
Improve warp creator in Universe Generator
- Loading branch information
Showing
3 changed files
with
137 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,61 @@ | ||
<?php | ||
require_once(get_file_loc('SmrGalaxy.class.inc')); | ||
|
||
if (isset($var['gal_on'])) $gal_on = $var['gal_on']; | ||
else $PHP_OUTPUT.= 'Gal_on not found!!'; | ||
if (isset($var['message'])) { | ||
$template->assign('Message', $var['message']); | ||
SmrSession::updateVar('message', null); // Only show message once | ||
} | ||
|
||
$galaxies =& SmrGalaxy::getGameGalaxies($var['game_id']); | ||
$galaxy =& SmrGalaxy::getGalaxy($var['game_id'],$var['gal_on']); | ||
$galSectors =& $galaxy->getSectors(); | ||
|
||
$template->assign('PageTopic', 'Warps for Galaxy : '.$galaxy->getName().' ('.$galaxy->getGalaxyID().')'); | ||
|
||
|
||
// Initialize warps array | ||
$warps = array(); | ||
foreach ($galaxies as $gal1) { | ||
$warps[$gal1->getGalaxyID()] = array(); | ||
foreach ($galaxies as $gal2) { | ||
$warps[$gal1->getGalaxyID()][$gal2->getGalaxyID()] = 0; | ||
} | ||
} | ||
|
||
//get totals | ||
foreach ($galSectors as &$galSector) { | ||
if($galSector->hasWarp()) { | ||
$otherGalaxyID = $galSector->getWarpSector()->getGalaxyID(); | ||
if($otherGalaxyID==$galaxy->getGalaxyID()) | ||
$warps[$otherGalaxyID]+=0.5; | ||
else | ||
$warps[$otherGalaxyID]++; | ||
$db->query('SELECT * FROM warp WHERE game_id='.$db->escapeNumber($var['game_id'])); | ||
while ($db->nextRecord()) { | ||
$warp1 = SmrSector::getSector($db->getInt('game_id'), $db->getInt('sector_id_1')); | ||
$warp2 = SmrSector::getSector($db->getInt('game_id'), $db->getInt('sector_id_2')); | ||
if ($warp1->getGalaxyID() == $warp2->getGalaxyID()) { | ||
$warps[$warp1->getGalaxyID()][$warp2->getGalaxyID()]++; | ||
} else { | ||
$warps[$warp1->getGalaxyID()][$warp2->getGalaxyID()]++; | ||
$warps[$warp2->getGalaxyID()][$warp1->getGalaxyID()]++; | ||
} | ||
} | ||
|
||
//universe_create_warps.php | ||
// Get links to other pages | ||
$container = create_container('skeleton.php', '1.6/universe_create_warps.php'); | ||
$container['game_id'] = $var['game_id']; | ||
$galLinks = array(); | ||
foreach ($galaxies as $gal) { | ||
$container['gal_on'] = $gal->getGalaxyID(); | ||
$galLinks[$gal->getGalaxyID()] = SmrSession::getNewHREF($container); | ||
} | ||
$template->assign('GalLinks', $galLinks); | ||
|
||
$container = $var; | ||
$container['url'] = '1.6/universe_create_save_processing.php'; | ||
$container['body'] = '1.6/universe_create_sectors.php'; | ||
$PHP_OUTPUT.= create_echo_form($container); | ||
$PHP_OUTPUT.= 'Working on Galaxy : ' . $galaxy->getName() . ' (' . $galaxy->getGalaxyID() . ')<br />'; | ||
$PHP_OUTPUT.= '<table class="standard">'; | ||
foreach ($galaxies as &$eachGalaxy) { | ||
$PHP_OUTPUT.= '<tr><td class="right">' . $eachGalaxy->getName() . '</td><td>'; | ||
$PHP_OUTPUT.= '<input type="number" value="'; | ||
if (isset($warps[$eachGalaxy->getGalaxyID()])) $PHP_OUTPUT.= $warps[$eachGalaxy->getGalaxyID()]; | ||
else $PHP_OUTPUT.= '0'; | ||
$PHP_OUTPUT.= '" size="5" name="warp' . $eachGalaxy->getGalaxyID() . '"></td></tr>'; | ||
} | ||
$PHP_OUTPUT.= '<tr><td colspan="2" class="center"><input type="submit" name="submit" value="Create Warps">'; | ||
$container['body'] = '1.6/universe_create_warps.php'; | ||
$template->assign('SubmitHREF', SmrSession::getNewHREF($container)); | ||
|
||
$container = $var; | ||
$container['body'] = '1.6/universe_create_sectors.php'; | ||
$PHP_OUTPUT.= '<br /><br /><a href="'.SmrSession::getNewHREF($container).'" class="submitStyle">Cancel</a>'; | ||
$PHP_OUTPUT.= '</td></tr></table></form>'; | ||
$template->assign('CancelHREF', SmrSession::getNewHREF($container)); | ||
|
||
$PHP_OUTPUT.= '<span class="small">Note: When you press "Create Warps" this will rearrange all current warps.<br />'; | ||
$PHP_OUTPUT.= 'To add new warps without rearranging everything use the edit sector feature.'; | ||
$PHP_OUTPUT.= 'Keep in mind this removes both sides of the warp, so 2 gals are changed for each warp.</span>'; | ||
$template->assign('Galaxy', $galaxy); | ||
$template->assign('Galaxies', $galaxies); | ||
$template->assign('Warps', $warps); | ||
|
||
?> | ||
?> |
81 changes: 81 additions & 0 deletions
81
templates/Default/admin/Default/1.6/universe_create_warps.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
if (isset($Message)) { | ||
echo $Message; ?><br /><br /><?php | ||
} ?> | ||
|
||
<table> | ||
<tr> | ||
<td class="shrink" style="white-space:nowrap"> | ||
<form method="POST" action="<?php echo $SubmitHREF; ?>"> | ||
<table class="standard"> | ||
<tr> | ||
<th>Galaxy</th> | ||
<th>Number of Warps</th> | ||
</tr><?php | ||
foreach ($Galaxies as $eachGalaxy) { ?> | ||
<tr> | ||
<td class="right"><?php echo $eachGalaxy->getName(); ?></td> | ||
<td><input class="center" type="number" value="<?php echo $Warps[$Galaxy->getGalaxyID()][$eachGalaxy->getGalaxyID()]; ?>" name="warp<?php echo $eachGalaxy->getGalaxyID(); ?>"></td> | ||
</tr><?php | ||
} ?> | ||
<tr> | ||
<td colspan="2" class="center"> | ||
<input type="submit" name="submit" value="Create Warps"> | ||
<br /><br /> | ||
<a href="<?php echo $CancelHREF; ?>" class="submitStyle"><< Back to Map</a> | ||
</td> | ||
</tr> | ||
</table> | ||
</form> | ||
</td> | ||
|
||
<td style="vertical-align:top"> | ||
<div style="margin-left:10px"> | ||
Warps will be placed randomly in the galaxies, with these exceptions: | ||
<ul> | ||
<li>Only one warp per sector</li> | ||
<li>No warps in sectors with Federal Beacons</li> | ||
</ul> | ||
<span class="bold">Note:</span> When you press "Create Warps" this will rearrange all current warps. | ||
To add new warps without rearranging everything use the edit sector feature. | ||
Keep in mind this removes both sides of the warp, so 2 galaxies are changed for each warp. | ||
</div> | ||
</td> | ||
</tr> | ||
</table> | ||
<br /> | ||
|
||
<style type="text/css"> | ||
p.vert { | ||
writing-mode: tb-rl; | ||
padding: 1px; | ||
margin: 1px; | ||
} | ||
</style> | ||
|
||
<h2>Warp Summary</h2> | ||
<p>Click on a galaxy name to edit warps for that galaxy.</p> | ||
<table class="standard"> | ||
<tr> | ||
<td></td><?php | ||
foreach ($Galaxies as $gal) { ?> | ||
<th> | ||
<p class="vert"> | ||
<a href="<?php echo $GalLinks[$gal->getGalaxyID()]; ?>"><?php echo $gal->getName(); ?></a> | ||
</p> | ||
</th><?php | ||
} ?> | ||
<th><p class="vert">Total</p></th> | ||
</tr><?php | ||
foreach ($Galaxies as $galRow) { ?> | ||
<tr> | ||
<th><a href="<?php echo $GalLinks[$galRow->getGalaxyID()]; ?>"><?php echo $galRow->getName(); ?></a></th><?php | ||
foreach ($Galaxies as $galCol) { | ||
$count = $Warps[$galRow->getGalaxyID()][$galCol->getGalaxyID()]; | ||
$display = $count == 0 ? '' : $count; ?> | ||
<td class="center"><?php echo $display; ?></td><?php | ||
} ?> | ||
<th><?php echo array_sum($Warps[$galRow->getGalaxyID()]); ?></th> | ||
</tr><?php | ||
} ?> | ||
</table> |