|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Framework\Core\Plugins\Gui; |
|
4
|
|
|
use eXpansion\Framework\Core\Model\Gui\Manialink; |
|
5
|
|
|
use eXpansion\Framework\Core\Model\Gui\ManiaScriptFactory; |
|
6
|
|
|
use eXpansion\Framework\Core\Model\Gui\Window; |
|
7
|
|
|
use eXpansion\Framework\Core\Model\UserGroups\Group; |
|
8
|
|
|
use eXpansion\Framework\Core\Plugins\GuiHandler; |
|
9
|
|
|
use eXpansion\Framework\Core\Plugins\UserGroups\Factory; |
|
10
|
|
|
use FML\Controls\Control; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class ManialiveFactory allow the creation of manialinks. |
|
14
|
|
|
* |
|
15
|
|
|
* @package eXpansion\Framework\Core\Plugins\Gui |
|
16
|
|
|
* @author Oliver de Cramer |
|
17
|
|
|
*/ |
|
18
|
|
|
class WindowFactory extends ManialinkFactory { |
|
19
|
|
|
|
|
20
|
|
|
protected $windowManiaScriptFactory; |
|
21
|
|
|
|
|
22
|
|
|
public function __construct( |
|
23
|
|
|
GuiHandler $guiHandler, |
|
24
|
|
|
Factory $groupFactory, |
|
25
|
|
|
ActionFactory $actionFactory, |
|
26
|
|
|
ManiaScriptFactory $windowManiaScriptFactory, |
|
27
|
|
|
$className = Window::class, |
|
28
|
|
|
$name, |
|
29
|
|
|
$sizeX, |
|
30
|
|
|
$sizeY, |
|
31
|
|
|
$posX = null, |
|
32
|
|
|
$posY = null |
|
33
|
|
|
) { |
|
34
|
|
|
// Hack for FML to use default MP alignements. |
|
35
|
|
|
Control::clearDefaultAlign(); |
|
36
|
|
|
|
|
37
|
|
|
parent::__construct($guiHandler, $groupFactory, $actionFactory, $name, $sizeX, $sizeY, $posX, $posY, $className); |
|
38
|
|
|
|
|
39
|
|
|
$this->windowManiaScriptFactory = $windowManiaScriptFactory; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
protected function createManialink(Group $group) |
|
43
|
|
|
{ |
|
44
|
|
|
$className = $this->className; |
|
45
|
|
|
$manialink = new $className( |
|
46
|
|
|
$group, |
|
47
|
|
|
$this->windowManiaScriptFactory, |
|
48
|
|
|
$this->name, |
|
49
|
|
|
$this->sizeX, |
|
50
|
|
|
$this->sizeY, |
|
51
|
|
|
$this->posX, |
|
52
|
|
|
$this->posY |
|
53
|
|
|
); |
|
54
|
|
|
|
|
55
|
|
|
$actionId = $this->actionFactory->createManialinkAction( |
|
56
|
|
|
$manialink, |
|
57
|
|
|
[$this, 'closeManialink'], |
|
58
|
|
|
['manialink' => $manialink] |
|
59
|
|
|
); |
|
60
|
|
|
|
|
61
|
|
|
$manialink->setCloseAction($actionId); |
|
62
|
|
|
|
|
63
|
|
|
return $manialink; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function closeManialink($login, $answerValues, $arguments) |
|
67
|
|
|
{ |
|
68
|
|
|
/** @var Manialink $manialink */ |
|
69
|
|
|
$manialink = $arguments['manialink']; |
|
70
|
|
|
$this->destroy($manialink->getUserGroup()); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|