|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Framework\Core\Plugins\Gui; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Framework\Core\DataProviders\ChatCommandDataProvider; |
|
6
|
|
|
use eXpansion\Framework\Core\Model\Gui\Grid\DataCollectionFactory; |
|
7
|
|
|
use eXpansion\Framework\Core\Model\Gui\Grid\GridBuilder; |
|
8
|
|
|
use eXpansion\Framework\Core\Model\Gui\Grid\GridBuilderFactory; |
|
9
|
|
|
use eXpansion\Framework\Core\Model\Gui\ManialinkInterface; |
|
10
|
|
|
use eXpansion\Framework\Core\Services\ChatCommands; |
|
11
|
|
|
use FML\Controls\Frame; |
|
12
|
|
|
use FML\Controls\Label; |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class HelpFactory |
|
17
|
|
|
* |
|
18
|
|
|
* @package eXpansion\Framework\AdminGroups\Plugins\Window; |
|
19
|
|
|
* @author oliver de Cramer <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class WindowHelpFactory extends WindowFactory |
|
22
|
|
|
{ |
|
23
|
|
|
/** @var GridBuilderFactory */ |
|
24
|
|
|
protected $gridBuilderFactory; |
|
25
|
|
|
|
|
26
|
|
|
/** @var DataCollectionFactory */ |
|
27
|
|
|
protected $dataCollectionFactory; |
|
28
|
|
|
|
|
29
|
|
|
/** @var ChatCommands */ |
|
30
|
|
|
protected $chatCommands; |
|
31
|
|
|
|
|
32
|
|
|
/** @var ChatCommandDataProvider */ |
|
33
|
|
|
protected $chatCommandDataPovider; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param GridBuilderFactory $gridBuilderFactory |
|
37
|
|
|
*/ |
|
38
|
|
|
public function setGridBuilderFactory($gridBuilderFactory) |
|
39
|
|
|
{ |
|
40
|
|
|
$this->gridBuilderFactory = $gridBuilderFactory; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @param DataCollectionFactory $dataCollectionFactory |
|
45
|
|
|
*/ |
|
46
|
|
|
public function setDataCollectionFactory($dataCollectionFactory) |
|
47
|
|
|
{ |
|
48
|
|
|
$this->dataCollectionFactory = $dataCollectionFactory; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @param ChatCommands $chatCommands |
|
53
|
|
|
*/ |
|
54
|
|
|
public function setChatCommands($chatCommands) |
|
55
|
|
|
{ |
|
56
|
|
|
$this->chatCommands = $chatCommands; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function setChatCommandDataProvide($chatCommandDataPovider) |
|
60
|
|
|
{ |
|
61
|
|
|
$this->chatCommandDataPovider = $chatCommandDataPovider; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @inheritdoc |
|
66
|
|
|
*/ |
|
67
|
|
|
protected function createContent(ManialinkInterface $manialink) |
|
68
|
|
|
{ |
|
69
|
|
|
$collection = $this->dataCollectionFactory->create($this->chatCommands->getChatCommands()); |
|
70
|
|
|
$collection->setPageSize(2); |
|
71
|
|
|
|
|
72
|
|
|
$helpButton = new Label(); |
|
73
|
|
|
$helpButton->setText('') |
|
74
|
|
|
->setSize(6, 6) |
|
75
|
|
|
->setAreaColor("0000") |
|
76
|
|
|
->setAreaFocusColor("0000"); |
|
77
|
|
|
|
|
78
|
|
|
$gridBuilder = $this->gridBuilderFactory->create(); |
|
79
|
|
|
$gridBuilder->setManialink($manialink) |
|
80
|
|
|
->setDataCollection($collection) |
|
81
|
|
|
->setManialinkFactory($this) |
|
82
|
|
|
->addTextColumn( |
|
83
|
|
|
'command', |
|
84
|
|
|
"expansion_core.windows.chat_commands.column_command", |
|
85
|
|
|
25 |
|
86
|
|
|
) |
|
87
|
|
|
->addTextColumn( |
|
88
|
|
|
'description', |
|
89
|
|
|
'expansion_core.windows.chat_commands.column_description', |
|
90
|
|
|
70, |
|
91
|
|
|
false, |
|
92
|
|
|
true |
|
93
|
|
|
) |
|
94
|
|
|
->addActionColumn('help', '', 5, array($this, 'callbackHelp'), $helpButton); |
|
|
|
|
|
|
95
|
|
|
|
|
96
|
|
|
$manialink->setData('grid', $gridBuilder); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @inheritdoc |
|
101
|
|
|
*/ |
|
102
|
|
|
protected function updateContent(ManialinkInterface $manialink) |
|
103
|
|
|
{ |
|
104
|
|
|
/** @var Frame $contentFrame */ |
|
105
|
|
|
$contentFrame = $manialink->getContentFrame(); |
|
|
|
|
|
|
106
|
|
|
$contentFrame->removeAllChildren(); |
|
107
|
|
|
|
|
108
|
|
|
$collection = $this->dataCollectionFactory->create($this->chatCommands->getChatCommands()); |
|
109
|
|
|
$collection->setPageSize(20); |
|
110
|
|
|
|
|
111
|
|
|
/** @var GridBuilder $gridBuilder */ |
|
112
|
|
|
$gridBuilder = $manialink->getData('grid'); |
|
113
|
|
|
$contentFrame->addChild($gridBuilder->build($contentFrame->getWidth(), $contentFrame->getHeight())); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Callbacked called when help button is pressed. |
|
118
|
|
|
* |
|
119
|
|
|
* @param $login |
|
120
|
|
|
* @param $params |
|
121
|
|
|
* @param $arguments |
|
122
|
|
|
*/ |
|
123
|
|
|
public function callbackHelp($login, $params, $arguments) |
|
124
|
|
|
{ |
|
125
|
|
|
$this->chatCommandDataPovider->onPlayerChat(0, $login, '/'.$arguments['command'].' -h', true); |
|
126
|
|
|
} |
|
127
|
|
|
} |
|
128
|
|
|
|
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: