1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Admin\View\ShowSignatures; |
6
|
|
|
|
7
|
|
|
use Stu\Lib\Map\VisualPanel\AbstractVisualPanel; |
8
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Shipcount\ShipcountLayerTypeEnum; |
9
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Subspace\SubspaceLayerTypeEnum; |
10
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\PanelLayerCreationInterface; |
11
|
|
|
use Stu\Lib\Map\VisualPanel\PanelBoundaries; |
12
|
|
|
use Stu\Lib\Map\VisualPanel\SignaturePanelEntry; |
13
|
|
|
use Stu\Module\Logging\LoggerUtilInterface; |
14
|
|
|
use Stu\Orm\Entity\LayerInterface; |
15
|
|
|
|
16
|
|
|
class SignaturePanel extends AbstractVisualPanel |
17
|
|
|
{ |
18
|
|
|
private int $userId; |
19
|
|
|
private int $allyId; |
20
|
|
|
|
21
|
|
|
/** @var array{minx: int, maxx: int, miny: int, maxy: int} */ |
22
|
|
|
private array $data; |
23
|
|
|
|
24
|
|
|
private LayerInterface $layer; |
25
|
|
|
|
26
|
|
|
/** @param array{minx: int, maxx: int, miny: int, maxy: int} $data */ |
27
|
|
|
public function __construct( |
28
|
|
|
array $data, |
29
|
|
|
PanelLayerCreationInterface $panelLayerCreation, |
30
|
|
|
LayerInterface $layer, |
31
|
|
|
int $userId, |
32
|
|
|
int $allyId, |
33
|
|
|
LoggerUtilInterface $loggerUtil |
34
|
|
|
) { |
35
|
|
|
parent::__construct($panelLayerCreation, $loggerUtil); |
36
|
|
|
|
37
|
|
|
$this->data = $data; |
38
|
|
|
$this->layer = $layer; |
39
|
|
|
$this->userId = $userId; |
40
|
|
|
$this->allyId = $allyId; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
protected function createBoundaries(): PanelBoundaries |
44
|
|
|
{ |
45
|
|
|
return PanelBoundaries::fromArray($this->data, $this->layer); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
protected function loadLayers(): void |
49
|
|
|
{ |
50
|
|
|
|
51
|
|
|
$panelLayerCreation = $this->panelLayerCreation |
52
|
|
|
->addBorderLayer(null, null); |
53
|
|
|
|
54
|
|
|
$panelLayerCreation->addMapLayer($this->layer); |
55
|
|
|
|
56
|
|
|
if ($this->userId !== 0) { |
57
|
|
|
$panelLayerCreation->addShipCountLayer(true, null, ShipcountLayerTypeEnum::USER_ONLY, $this->userId); |
58
|
|
|
$panelLayerCreation->addSubspaceLayer($this->userId, SubspaceLayerTypeEnum::USER_ONLY); |
59
|
|
|
} elseif ($this->allyId !== 0) { |
60
|
|
|
$panelLayerCreation->addShipCountLayer(true, null, ShipcountLayerTypeEnum::ALLIANCE_ONLY, $this->allyId); |
61
|
|
|
$panelLayerCreation->addSubspaceLayer($this->allyId, SubspaceLayerTypeEnum::ALLIANCE_ONLY); |
62
|
|
|
} else { |
63
|
|
|
$panelLayerCreation->addShipCountLayer(true, null, ShipcountLayerTypeEnum::ALL, 0); |
64
|
|
|
$panelLayerCreation->addSubspaceLayer(0, SubspaceLayerTypeEnum::ALL); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
$this->layers = $panelLayerCreation->build($this); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
protected function getEntryCallable(): callable |
71
|
|
|
{ |
72
|
|
|
return fn (int $x, int $y) => new SignaturePanelEntry( |
73
|
|
|
$x, |
74
|
|
|
$y, |
75
|
|
|
$this->layers |
76
|
|
|
); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
protected function getPanelViewportPercentage(): int |
80
|
|
|
{ |
81
|
|
|
return 100; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|