Completed
Pull Request — master (#104)
by
unknown
04:57 queued 02:15
created

CustomUi   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 173
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 13
c 2
b 0
f 0
lcom 1
cbo 3
dl 0
loc 173
ccs 0
cts 98
cp 0
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setCustomUi() 0 11 3
B sendCustomUi() 0 76 1
A setStatus() 0 4 1
A onApplicationInit() 0 4 1
A onApplicationReady() 0 4 1
A onApplicationStop() 0 4 1
A onPlayerConnect() 0 4 1
A onPlayerDisconnect() 0 4 1
A onPlayerInfoChanged() 0 4 1
A onPlayerAlliesChanged() 0 4 1
1
<?php
2
3
namespace eXpansion\Bundle\CustomUi\Plugins;
4
5
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups;
6
use eXpansion\Framework\Core\DataProviders\Listener\ListenerInterfaceExpApplication;
7
use eXpansion\Framework\Core\DataProviders\Listener\ListenerInterfaceMpLegacyChat;
8
use eXpansion\Framework\Core\DataProviders\Listener\ListenerInterfaceMpLegacyPlayer;
9
use eXpansion\Framework\Core\Plugins\StatusAwarePluginInterface;
10
use eXpansion\Framework\Core\Services\Console;
11
use eXpansion\Framework\Core\Storage\Data\Player;
12
use eXpansion\Framework\Core\Storage\PlayerStorage;
13
use Maniaplanet\DedicatedServer\Connection;
14
15
16
class CustomUi implements ListenerInterfaceExpApplication, StatusAwarePluginInterface, ListenerInterfaceMpLegacyPlayer
17
{
18
    /** @var Connection */
19
    protected $connection;
20
    /**
21
     * @var PlayerStorage
22
     */
23
    private $playerStorage;
24
25
    /**
26
     * CustomUi constructor.
27
     * @param Connection $connection
28
     * @param PlayerStorage $playerStorage
29
     */
30
    public function __construct(Connection $connection, PlayerStorage $playerStorage)
31
    {
32
        $this->connection = $connection;
33
        $this->playerStorage = $playerStorage;
34
    }
35
36
37
    public function setCustomUi($login)
38
    {
39
        if ($login == null) {
40
            foreach ($this->playerStorage->getOnline() as $player) {
41
                $this->sendCustomUi($player->getLogin(), true);
42
            }
43
            $this->connection->executeMulticall();
44
        } else {
45
            $this->sendCustomUi($login, false);
46
        }
47
    }
48
49
50
    public function sendCustomUi($login, $multicall)
0 ignored issues
show
Unused Code introduced by
The parameter $login is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
51
    {
52
        $properties = /** @lang XML */
53
            <<<EOL
54
    <ui_properties>
55
 		<!-- The map name and author displayed in the top right of the screen when viewing the scores table -->
56
 		<map_info visible="false" pos="-160. 80. 150." />
57
 
58
 		<!-- Information about live envent displayed in the top right of the screen -->
59
 		<live_info visible="false" pos="-159. 84. 5." />
60
 
61
 		<!-- Information about the spectated player displayed in the bottom of the screen -->
62
 		<spectator_info visible="true" pos="0. -68. 5." />
63
 
64
 		<!-- Only visible in solo modes, it hides the medal/ghost selection UI -->
65
 		<opponents_info visible="true" />
66
 		<!--
67
 			The server chat displayed on the bottom left of the screen
68
 			The offset values range from 0. to -3.2 for x and from 0. to 1.8 for y
69
 			The linecount property must be between 0 and 40
70
 			use offset 0 1.55 for upper corner 
71
 		-->
72
 		<chat visible="true" offset="0. 0." linecount="7" />
73
 		
74
 		<!-- Time of the players at the current checkpoint displayed at the bottom of the screen -->
75
 		<checkpoint_list visible="true" pos="48. -52. 5." />
76
 		
77
 		<!-- Small scores table displayed at the end of race of the round based modes (Rounds, Cup, ...) on the right of the screen -->
78
 		<round_scores visible="true" pos="-158.5 40. 5." />
79
 		
80
 		<!-- Race time left displayed at the bottom right of the screen -->
81
 		<countdown visible="true" pos="153. -40. 5." />
82
 		
83
 		<!-- 3, 2, 1, Go! message displayed on the middle of the screen when spawning --> 		
84
 		<go visible="true" />
85
 		
86
 		<!-- Current race chrono displayed at the bottom center of the screen -->
87
 		<chrono visible="true" pos="0. 84. -5." />
88
 		
89
 		<!-- Speed and distance raced displayed in the bottom right of the screen -->
90
 		<speed_and_distance visible="true" pos="137. -69. 5." />
91
 		
92
 		<!-- Previous and best times displayed at the bottom right of the screen -->
93
 		<personal_best_and_rank visible="false" pos="157. -24. 5." />
94
 		
95
 		<!-- Current position in the map ranking displayed at the bottom right of the screen -->
96
 		<position visible="true" pos="0 81. 5." />
97
 		
98
 		<!-- Checkpoint time information displayed in the middle of the screen when crossing a checkpoint -->
99
 		<checkpoint_time visible="true" pos="0. 3. -10." />
100
 		
101
 		<!-- The avatar of the last player speaking in the chat displayed above the chat -->
102
 		<chat_avatar visible="false" />
103
 		
104
 		<!-- Warm-up progression displayed on the right of the screen during warm-up -->
105
  		<warmup visible="true" pos="153. 13. 0." /> 		
106
 		
107
 		<!-- Ladder progression box displayed on the top of the screen at the end of the map --> 		
108
 		<endmap_ladder_recap visible="false" /> 		
109
 		
110
 		<!-- Laps count displayed on the right of the screen on multilaps map --> 		
111
 		<multilap_info visible="true" pos="140. 84. 5." />
112
 		
113
 		<!-- Player's ranking at the latest checkpoint --> 		
114
 		<checkpoint_ranking visible="false" pos="0. 84. 5." />
115
 		
116
 		<!-- Scores table displayed in the middle of the screen --> 		
117
 		<scorestable alt_visible="false" />
118
 		
119
 		<!-- Number of players spectating us displayed at the bottom right of the screen --> 		
120
 		<viewers_count visible="true" pos="157. -40. 5." /> 	
121
 	</ui_properties>
122
EOL;
123
124
        $this->connection->triggerModeScriptEvent('Trackmania.UI.SetProperties', [$properties], $multicall);
125
    }
126
127
    /**
128
     * Set the status of the plugin
129
     *
130
     * @param boolean $status
131
     *
132
     * @return null
133
     */
134
    public function setStatus($status)
135
    {
136
137
    }
138
139
    /**
140
     * called at eXpansion init
141
     *
142
     * @return void
143
     */
144
    public function onApplicationInit()
145
    {
146
        // TODO: Implement onApplicationInit() method.
147
    }
148
149
    /**
150
     * called when init is done and callbacks are enabled
151
     *
152
     * @return void
153
     */
154
    public function onApplicationReady()
155
    {
156
        $this->setCustomUi(null);
157
    }
158
159
    /**
160
     * called when requesting application stop
161
     *
162
     * @return void
163
     */
164
    public function onApplicationStop()
165
    {
166
        // TODO: Implement onApplicationStop() method.
167
    }
168
169
    public function onPlayerConnect(Player $player)
170
    {
171
        $this->setCustomUi($player->getLogin());
172
    }
173
174
    public function onPlayerDisconnect(Player $player, $disconnectionReason)
175
    {
176
        // TODO: Implement onPlayerDisconnect() method.
177
    }
178
179
    public function onPlayerInfoChanged(Player $oldPlayer, Player $player)
180
    {
181
        // TODO: Implement onPlayerInfoChanged() method.
182
    }
183
184
    public function onPlayerAlliesChanged(Player $oldPlayer, Player $player)
185
    {
186
        // TODO: Implement onPlayerAlliesChanged() method.
187
    }
188
}
189