|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Bundle\Menu\Plugins\Gui; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups; |
|
6
|
|
|
use eXpansion\Framework\Core\Model\Gui\ManialinkInterface; |
|
7
|
|
|
use eXpansion\Framework\Core\Model\Gui\ManiaScriptFactory; |
|
8
|
|
|
use eXpansion\Framework\Core\Model\Gui\Widget; |
|
9
|
|
|
use eXpansion\Framework\Core\Plugins\Gui\WidgetFactory; |
|
10
|
|
|
use FML\Controls\Frame; |
|
11
|
|
|
use FML\Controls\Label; |
|
12
|
|
|
use FML\Controls\Quad; |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class MenuFactory |
|
17
|
|
|
* |
|
18
|
|
|
* @package eXpansion\Bundle\Menu\Plugins\Gui; |
|
19
|
|
|
* @author oliver de Cramer <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class MenuFactory extends WidgetFactory |
|
22
|
|
|
{ |
|
23
|
|
|
/** @var ManiaScriptFactory */ |
|
24
|
|
|
protected $menuScriptFactory; |
|
25
|
|
|
|
|
26
|
|
|
/** @var AdminGroups */ |
|
27
|
|
|
protected $adminGroupsHelper; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param ManiaScriptFactory $menuScriptFactory |
|
31
|
|
|
*/ |
|
32
|
|
|
public function setMenuScriptFactory($menuScriptFactory) |
|
33
|
|
|
{ |
|
34
|
|
|
$this->menuScriptFactory = $menuScriptFactory; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param AdminGroups $adminGroupsHelper |
|
39
|
|
|
*/ |
|
40
|
|
|
public function setAdminGroupsHelper($adminGroupsHelper) |
|
41
|
|
|
{ |
|
42
|
|
|
$this->adminGroupsHelper = $adminGroupsHelper; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param Widget $manialink |
|
47
|
|
|
*/ |
|
48
|
|
|
protected function createContent(ManialinkInterface $manialink) |
|
49
|
|
|
{ |
|
50
|
|
|
/* Button frame first */ |
|
51
|
|
|
|
|
52
|
|
|
$label = Label::create("open"); |
|
53
|
|
|
$label->setText("Open") |
|
54
|
|
|
->setAreaFocusColor("5ff") |
|
55
|
|
|
->setAreaColor("3af") |
|
56
|
|
|
->setPosition(100, 60) |
|
57
|
|
|
->setScriptEvents(true); |
|
58
|
|
|
// $manialink->addChild($label); |
|
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
$btnFrame = Frame::create("buttons"); |
|
61
|
|
|
$btnFrame->setZ(101)->setPosition(0, 30); |
|
62
|
|
|
|
|
63
|
|
|
$y = 0; |
|
64
|
|
|
$baseLabel = Label::create(); |
|
65
|
|
|
$baseLabel->setAreaColor("0000") |
|
66
|
|
|
->setAreaFocusColor("0000") |
|
67
|
|
|
->setTextColor("FFF") |
|
68
|
|
|
->setAlign("center", "center2") |
|
69
|
|
|
->addClass("button") |
|
70
|
|
|
->setScriptEvents(true); |
|
71
|
|
|
|
|
72
|
|
|
$label = clone $baseLabel; |
|
73
|
|
|
$label->setPosition(0, $y -= 8) |
|
74
|
|
|
->setText("Help") |
|
75
|
|
|
->setTextPrefix(" ") |
|
76
|
|
|
->setDataAttributes(["action" => "!help"]); |
|
77
|
|
|
$btnFrame->addChild($label); |
|
78
|
|
|
|
|
79
|
|
|
$label = clone $baseLabel; |
|
80
|
|
|
$label->setPosition(0, $y -= 10) |
|
81
|
|
|
->setText("Show Profile") |
|
82
|
|
|
->setTextPrefix(" ") |
|
83
|
|
|
->setDataAttributes(["action" => "!profile"]); |
|
84
|
|
|
$btnFrame->addChild($label); |
|
85
|
|
|
|
|
86
|
|
|
$label = clone $baseLabel; |
|
87
|
|
|
$label->setPosition(0, $y -= 8) |
|
88
|
|
|
->setText("Spectate") |
|
89
|
|
|
->setTextPrefix("") |
|
90
|
|
|
->setDataAttributes(["action" => "!spec"]); |
|
91
|
|
|
$btnFrame->addChild($label); |
|
92
|
|
|
|
|
93
|
|
|
$label = clone $baseLabel; |
|
94
|
|
|
$label->setPosition(0, $y -= 8) |
|
95
|
|
|
->setText("Return to game") |
|
96
|
|
|
->setTextPrefix(" ") |
|
97
|
|
|
->setDataAttributes(["action" => "!close"]); |
|
98
|
|
|
$btnFrame->addChild($label); |
|
99
|
|
|
|
|
100
|
|
|
|
|
101
|
|
|
$label = clone $baseLabel; |
|
102
|
|
|
$label->setPosition(0, $y -= 12) |
|
103
|
|
|
->setText("Return to main menu") |
|
104
|
|
|
->setTextPrefix("🏁 ") |
|
105
|
|
|
->setDataAttributes(["action" => "!quit"]); |
|
106
|
|
|
$btnFrame->addChild($label); |
|
107
|
|
|
|
|
108
|
|
|
|
|
109
|
|
|
|
|
110
|
|
|
$bgFrame = Frame::create("background"); |
|
111
|
|
|
$bgFrame->setZ(100); |
|
112
|
|
|
|
|
113
|
|
|
$baseLabel = Label::create(); |
|
114
|
|
|
$baseLabel->setAreaColor("0000") |
|
115
|
|
|
->setAreaFocusColor("0000") |
|
116
|
|
|
->setTextColor("FFF") |
|
117
|
|
|
->setAlign("center", "center2") |
|
118
|
|
|
->addClass("bg"); |
|
119
|
|
|
|
|
120
|
|
|
|
|
121
|
|
|
$label = clone $baseLabel; |
|
122
|
|
|
$label->setText("") |
|
123
|
|
|
->setTextSize(16) |
|
124
|
|
|
->setPosition(0, 50) |
|
125
|
|
|
->setSize(32, 32); |
|
126
|
|
|
$bgFrame->addChild($label); |
|
127
|
|
|
|
|
128
|
|
|
$label = clone $baseLabel; |
|
129
|
|
|
$label->setText("Server Menu") |
|
130
|
|
|
->setTextSize(8) |
|
131
|
|
|
->setPosition(0, 35) |
|
132
|
|
|
->setTextFont('Oswald'); |
|
133
|
|
|
$bgFrame->addChild($label); |
|
134
|
|
|
|
|
135
|
|
|
|
|
136
|
|
|
$quad = Quad::create(); |
|
137
|
|
|
$quad->addClass("bg") |
|
138
|
|
|
->setPosition(0, 28) |
|
139
|
|
|
->setSize(100, 0.5) |
|
140
|
|
|
->setAlign("center", "center") |
|
141
|
|
|
->setBackgroundColor("fff"); |
|
142
|
|
|
$bgFrame->addChild($quad); |
|
143
|
|
|
|
|
144
|
|
|
$quad = Quad::create(); |
|
145
|
|
|
$quad->addClass("bg") |
|
146
|
|
|
->setPosition(0, 0) |
|
147
|
|
|
->setSize(322, 182) |
|
148
|
|
|
->setAlign("center", "center") |
|
149
|
|
|
->setStyles("Bgs1", "BgDialogBlur"); |
|
150
|
|
|
$bgFrame->addChild($quad); |
|
151
|
|
|
|
|
152
|
|
|
|
|
153
|
|
|
|
|
154
|
|
|
$manialink->addChild($btnFrame); |
|
|
|
|
|
|
155
|
|
|
$manialink->addChild($bgFrame); |
|
|
|
|
|
|
156
|
|
|
|
|
157
|
|
|
$manialink->addChild($this->menuScriptFactory->createScript([])); |
|
|
|
|
|
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
/** |
|
161
|
|
|
* @param Widget $manialink |
|
162
|
|
|
*/ |
|
163
|
|
|
protected function updateContent(ManialinkInterface $manialink) |
|
164
|
|
|
{ |
|
165
|
|
|
// Do stuff Here. |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
} |
|
169
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.