|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Bundle\ImmersiveWindows\Model\Gui\Factory; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Bundle\ImmersiveWindows\Plugins\WindowsGuiHandler; |
|
6
|
|
|
use eXpansion\Bundle\Menu\DataProviders\MenuItemProvider; |
|
7
|
|
|
use eXpansion\Bundle\Menu\Gui\MenuTabsFactory; |
|
8
|
|
|
use eXpansion\Bundle\Menu\Model\Menu\ItemInterface; |
|
9
|
|
|
use eXpansion\Bundle\Menu\Plugins\Gui\MenuContentFactory; |
|
10
|
|
|
use eXpansion\Framework\Core\Model\Gui\Factory\WindowFrameFactory as OriginalWindowFrameFactory; |
|
11
|
|
|
use eXpansion\Framework\Core\Model\Gui\ManialinkInterface; |
|
12
|
|
|
use eXpansion\Framework\Core\Model\Gui\ManiaScriptFactory; |
|
13
|
|
|
use eXpansion\Framework\Core\Model\Gui\WindowFrameFactoryInterface; |
|
14
|
|
|
use eXpansion\Framework\Gui\Components\uiButton; |
|
15
|
|
|
use eXpansion\Framework\Gui\Ui\Factory; |
|
16
|
|
|
use FML\Controls\Frame; |
|
17
|
|
|
use FML\Controls\Label; |
|
18
|
|
|
use FML\Controls\Quad; |
|
19
|
|
|
use FML\ManiaLink; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Class WindowFrameFactory |
|
23
|
|
|
* |
|
24
|
|
|
* @author de Cramer Oliver<[email protected]> |
|
25
|
|
|
* @copyright 2017 Smile |
|
26
|
|
|
* @package eXpansion\Bundle\ImmersiveWindows\Model\Gui\Factory |
|
27
|
|
|
*/ |
|
28
|
|
|
class WindowFrameFactory extends OriginalWindowFrameFactory implements WindowFrameFactoryInterface |
|
29
|
|
|
{ |
|
30
|
|
|
/** @var MenuTabsFactory */ |
|
31
|
|
|
protected $menuTabsFactory; |
|
32
|
|
|
|
|
33
|
|
|
/** @var MenuItemProvider */ |
|
34
|
|
|
protected $menuItemProvider; |
|
35
|
|
|
|
|
36
|
|
|
/** @var MenuContentFactory */ |
|
37
|
|
|
protected $menuContentFactory; |
|
38
|
|
|
|
|
39
|
|
|
/** @var WindowsGuiHandler */ |
|
40
|
|
|
protected $windowsGuiHandler; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var ManiaScriptFactory |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $maniaScriptFactory; |
|
46
|
|
|
/** |
|
47
|
|
|
* @var ManialinkInterface |
|
48
|
|
|
*/ |
|
49
|
|
|
protected $manialinkInterface; |
|
50
|
|
|
/** |
|
51
|
|
|
* @var Factory |
|
52
|
|
|
*/ |
|
53
|
|
|
protected $uiFactory; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* WindowFrameFactory constructor. |
|
57
|
|
|
* |
|
58
|
|
|
* @param ManiaScriptFactory $maniaScriptFactory |
|
59
|
|
|
* @param MenuTabsFactory $menuTabsFactory |
|
60
|
|
|
* @param MenuItemProvider $menuItemProvider |
|
61
|
|
|
* @param Factory $uiFactory |
|
62
|
|
|
*/ |
|
63
|
|
|
public function __construct( |
|
64
|
|
|
ManiaScriptFactory $maniaScriptFactory, |
|
65
|
|
|
MenuTabsFactory $menuTabsFactory, |
|
66
|
|
|
MenuItemProvider $menuItemProvider, |
|
67
|
|
|
Factory $uiFactory, |
|
68
|
|
|
MenuContentFactory $menuContentFactory, |
|
69
|
|
|
WindowsGuiHandler $windowsGuiHandler |
|
70
|
|
|
) { |
|
71
|
|
|
parent::__construct($maniaScriptFactory); |
|
72
|
|
|
$this->maniaScriptFactory = $maniaScriptFactory; |
|
73
|
|
|
$this->menuTabsFactory = $menuTabsFactory; |
|
74
|
|
|
$this->menuItemProvider = $menuItemProvider; |
|
75
|
|
|
$this->uiFactory = $uiFactory; |
|
76
|
|
|
$this->menuContentFactory = $menuContentFactory; |
|
77
|
|
|
$this->windowsGuiHandler = $windowsGuiHandler; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @inheritdoc |
|
82
|
|
|
*/ |
|
83
|
|
|
public function build( |
|
84
|
|
|
ManiaLink $manialink, |
|
85
|
|
|
Frame $mainFrame, |
|
86
|
|
|
$name, |
|
87
|
|
|
$sizeX, |
|
88
|
|
|
$sizeY |
|
89
|
|
|
) { |
|
90
|
|
|
// Creating sub frame to keep all the pieces together. Position needs to be top left corner. |
|
91
|
|
|
$frame = new Frame(); |
|
92
|
|
|
$frame->setPosition(-160 - $mainFrame->getX(), 90 - $mainFrame->getY()); |
|
93
|
|
|
|
|
94
|
|
|
$tabsFrame = new Frame(); |
|
95
|
|
|
$tabsFrame->setPosition(-144 - $mainFrame->getX(), 82- $mainFrame->getY()); |
|
96
|
|
|
|
|
97
|
|
|
// Creating the tabs. |
|
98
|
|
|
$mainFrame->addChild( |
|
99
|
|
|
$this->menuTabsFactory->createTabsMenu( |
|
|
|
|
|
|
100
|
|
|
$this->manialinkInterface, |
|
101
|
|
|
$tabsFrame, |
|
102
|
|
|
$this->menuItemProvider->getRootItem(), |
|
|
|
|
|
|
103
|
|
|
[$this, 'callbackItemClick'], |
|
104
|
|
|
'admin/admin' |
|
105
|
|
|
) |
|
106
|
|
|
); |
|
107
|
|
|
$mainFrame->addChild($tabsFrame); |
|
108
|
|
|
$mainFrame->addChild($frame); |
|
109
|
|
|
|
|
110
|
|
|
$closeButton = $this->uiFactory->createButton('Close', uiButton::TYPE_DECORATED); |
|
111
|
|
|
$closeButton->setBorderColor(uiButton::COLOR_WARNING)->setFocusColor(uiButton::COLOR_WARNING); |
|
112
|
|
|
$closeButton->setPosition(300, -20); |
|
113
|
|
|
$frame->addChild($closeButton); |
|
114
|
|
|
|
|
115
|
|
|
|
|
116
|
|
|
/* |
|
117
|
|
|
* Adding background frame |
|
118
|
|
|
*/ |
|
119
|
|
|
$bgFrame = Frame::create("background"); |
|
120
|
|
|
$quad = new Quad(); |
|
121
|
|
|
$quad->addClass("bg") |
|
122
|
|
|
->setId("mainBg") |
|
123
|
|
|
->setPosition(0, 0) |
|
124
|
|
|
->setSize(322, 182); |
|
125
|
|
|
$quad->setAlign("left", "top") |
|
126
|
|
|
->setStyles("Bgs1", "BgDialogBlur"); |
|
127
|
|
|
$bgFrame->addChild($quad); |
|
128
|
|
|
|
|
129
|
|
|
$frame->addChild($bgFrame); |
|
130
|
|
|
|
|
131
|
|
|
|
|
132
|
|
|
$manialink->addChild($this->maniaScriptFactory->createScript([''])); |
|
133
|
|
|
|
|
134
|
|
|
return $closeButton; |
|
|
|
|
|
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* @param ManialinkInterface $manialinkInterface |
|
139
|
|
|
*/ |
|
140
|
|
|
public function setManialinkInterface(ManialinkInterface $manialinkInterface) |
|
141
|
|
|
{ |
|
142
|
|
|
$this->manialinkInterface = $manialinkInterface; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* Callback when an item of the menu is clicked on. |
|
147
|
|
|
* |
|
148
|
|
|
* @param ManialinkInterface $manialink |
|
149
|
|
|
* @param $login |
|
150
|
|
|
* @param $params |
|
151
|
|
|
* @param $args |
|
152
|
|
|
*/ |
|
153
|
|
|
public function callbackItemClick(ManialinkInterface $manialink, $login, $params, $args) |
|
154
|
|
|
{ |
|
155
|
|
|
$this->windowsGuiHandler->addToHide($manialink); |
|
156
|
|
|
$this->menuContentFactory->create($login); |
|
157
|
|
|
|
|
158
|
|
|
/** @var ItemInterface $item */ |
|
159
|
|
|
$item = $args['item']; |
|
160
|
|
|
$item->execute($this->menuContentFactory, $manialink, $login, $params, $args); |
|
161
|
|
|
} |
|
162
|
|
|
} |
|
163
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: