Skip to content

Commit

Permalink
fix starsystem database
Browse files Browse the repository at this point in the history
  • Loading branch information
g5bot committed Sep 9, 2023
1 parent 52d0f1c commit f95ecee
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 41 deletions.
9 changes: 5 additions & 4 deletions src/Lib/Map/VisualPanel/SignaturePanelEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ class SignaturePanelEntry implements VisualPanelElementInterface

private ?LayerInterface $layer;

private EncodedMapInterface $encodedMap;
private ?EncodedMapInterface $encodedMap;

private string $cssClass = 'lss';

public function __construct(
VisualPanelEntryData $data,
?LayerInterface $layer,
EncodedMapInterface $encodedMap
?EncodedMapInterface $encodedMap
) {
$this->data = $data;
$this->layer = $layer;
Expand Down Expand Up @@ -72,9 +72,10 @@ private function getMapGraphicPath(): ?string
return null;
}

if ($layer->isEncoded()) {
$encodedMap = $this->encodedMap;
if ($layer->isEncoded() && $encodedMap !== null) {

return $this->encodedMap->getEncodedMapPath(
return $encodedMap->getEncodedMapPath(
$this->data->getMapfieldType(),
$layer
);
Expand Down
4 changes: 1 addition & 3 deletions src/Lib/Map/VisualPanel/SystemScanPanelEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Stu\Lib\Map\VisualPanel;

use Stu\Component\Map\EncodedMapInterface;
use Stu\Orm\Entity\StarSystemInterface;

class SystemScanPanelEntry extends SignaturePanelEntry
Expand All @@ -13,10 +12,9 @@ class SystemScanPanelEntry extends SignaturePanelEntry

public function __construct(
VisualPanelEntryData $data,
EncodedMapInterface $encodedMap,
StarSystemInterface $system
) {
parent::__construct($data, null, $encodedMap);
parent::__construct($data, null, null);

$this->system = $system;
}
Expand Down
14 changes: 14 additions & 0 deletions src/Lib/Map/VisualPanel/VisualPanelEntryData.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,25 @@ public function getSystemId(): ?int
return $this->sysid;
}

public function setSystemId(int $systemId): VisualPanelEntryData
{
$this->sysid = $systemId;

return $this;
}

public function getMapfieldType(): int
{
return $this->type;
}

public function setMapfieldType(int $type): VisualPanelEntryData
{
$this->type = $type;

return $this;
}

public function getShipCount(): int
{
return $this->shipcount;
Expand Down
14 changes: 13 additions & 1 deletion src/Module/Database/View/DatabaseEntry/DatabaseEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Stu\Component\Database\DatabaseEntryTypeEnum;
use Stu\Component\Ship\Crew\ShipCrewCalculatorInterface;
use Stu\Exception\AccessViolation;
use Stu\Lib\Map\VisualPanel\SignaturePanelEntry;
use Stu\Lib\Map\VisualPanel\VisualPanelEntryData;
use Stu\Module\Control\GameControllerInterface;
use Stu\Module\Control\ViewControllerInterface;
use Stu\Module\Database\View\Category\Category;
Expand Down Expand Up @@ -149,7 +151,8 @@ protected function addSpecialVars(GameControllerInterface $game, DatabaseEntryIn
$userHasColonyInSystem = $this->hasUserColonyInSystem($game->getUser(), $entry_object_id);
foreach ($starSystem->getFields() as $obj) {
$fields['fields'][$obj->getSY()][] = [
'map' => $obj,
'entry' => $this->createSignaturePanelEntry($obj),
'colony' => $obj->getColony(),
'showPm' => $userHasColonyInSystem && $this->showPmHref($obj, $game->getUser())
];
}
Expand All @@ -161,6 +164,15 @@ protected function addSpecialVars(GameControllerInterface $game, DatabaseEntryIn
}
}

private function createSignaturePanelEntry(StarSystemMapInterface $systemMap): SignaturePanelEntry
{
$data = new VisualPanelEntryData();
$data->setMapfieldType($systemMap->getFieldId())
->setSystemId($systemMap->getSystemId());

return new SignaturePanelEntry($data, null, null);
}

private function hasUserColonyInSystem(UserInterface $user, int $systemId): bool
{
foreach ($user->getColonies() as $colony) {
Expand Down
8 changes: 1 addition & 7 deletions src/Module/Station/Lib/StationUiFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Stu\Module\Station\Lib;

use Stu\Component\Map\EncodedMapInterface;
use Stu\Lib\Map\VisualPanel\SystemScanPanelEntry;
use Stu\Lib\Map\VisualPanel\VisualPanelEntryData;
use Stu\Module\Logging\LoggerUtilInterface;
Expand All @@ -30,20 +29,16 @@ final class StationUiFactory implements StationUiFactoryInterface

private ShipRepositoryInterface $shipRepository;

private EncodedMapInterface $encodedMap;

public function __construct(
UserRepositoryInterface $userRepository,
AllianceRepositoryInterface $allianceRepository,
FactionRepositoryInterface $factionRepository,
ShipRepositoryInterface $shipRepository,
EncodedMapInterface $encodedMap
ShipRepositoryInterface $shipRepository
) {
$this->userRepository = $userRepository;
$this->allianceRepository = $allianceRepository;
$this->factionRepository = $factionRepository;
$this->shipRepository = $shipRepository;
$this->encodedMap = $encodedMap;
}

public function createSystemScanPanel(
Expand All @@ -68,7 +63,6 @@ public function createSystemScanPanelEntry(
): SystemScanPanelEntry {
return new SystemScanPanelEntry(
$data,
$this->encodedMap,
$system
);
}
Expand Down
18 changes: 0 additions & 18 deletions src/Orm/Entity/StarSystemMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,24 +189,6 @@ public function setFieldType(MapFieldTypeInterface $mapFieldType): StarSystemMap
return $this;
}

public function getBackgroundId(): string
{

$x = (string)$this->getSx();
$y = (string)$this->getSy();


$x = str_pad($x, 2, '0', STR_PAD_LEFT);
$y = str_pad($y, 2, '0', STR_PAD_LEFT);


$backgroundId = $y . $x;

return $backgroundId;
}



public function getColony(): ?ColonyInterface
{
return $this->colony;
Expand Down
2 changes: 0 additions & 2 deletions src/Orm/Entity/StarSystemMapInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public function getFieldId(): int;

public function getFieldType(): MapFieldTypeInterface;

public function getBackgroundId(): string;

public function setFieldType(MapFieldTypeInterface $mapFieldType): StarSystemMapInterface;

public function getColony(): ?ColonyInterface;
Expand Down
12 changes: 6 additions & 6 deletions src/html/databasemacros.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@
<tr tal:repeat="yaxis map/fields">
<th tal:content="repeat/yaxis/key">CY</th>
<td tal:repeat="xaxis yaxis" class="lss" style="background-size: cover;">
<div class="lssobj imgOverlayText"
<div class="lssobj imgOverlayText" tal:define="lssCellData xaxis/entry/getLssCellData"
style=" position: relative !important; top: 0px; height: 30px; width: 30px">
<img src="assets/map/starmap/${xaxis/map/getBackgroundId}.png" style="z-index: 1;" />
<img tal:condition="xaxis/map/getFieldGraphicID" class="lssColoShield"
src="assets/map/${xaxis/map/getFieldGraphicID}.png" style="z-index: 2;" />
<img src="assets/map/starmap/${lssCellData/getSystemBackgroundId}.png" style="z-index: 1;" />
<img tal:condition="lssCellData/getFieldGraphicID" class="lssColoShield"
src="assets/map/${lssCellData/getFieldGraphicID}.png" style="z-index: 2;" />
<div class="lssobj imgOverlayText" style=" position: relative !important; top: 0px;"
tal:condition="xaxis/showPm" href="javascript:void(0);"
onclick="openPmWindow(${THIS/getUser/getId},${xaxis/map/getColony/getId},1,5)"
title="Nachricht an ${bbcode2txt:xaxis/map/getColony/getUser/getName} verfassen">
onclick="openPmWindow(${THIS/getUser/getId},${xaxis/colony/getId},1,5)"
title="Nachricht an ${bbcode2txt:xaxis/colony/getUser/getName} verfassen">
<img class="lssColoShield" src="assets/map/pm.png" style="z-index: 3;" />
</div>
</div>
Expand Down

0 comments on commit f95ecee

Please sign in to comment.