forked from UltimaPHP/UltimaPHP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgumps.class.php
239 lines (183 loc) · 6.47 KB
/
gumps.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<?php
/**
* Ultima PHP - OpenSource Ultima Online Server written in PHP
* Version: 0.1 - Pre Alpha
*/
class Gumps {
public $id;
private $client;
private $pages = [];
private $text = [];
private $x, $y, $noMove, $noClose, $noDispose, $type;
public $layout, $textLayout, $gumpId;
/**
* Dialog basic methods
*/
public function __construct($client = false) {
if (!$client) {
return false;
}
$this->setType(1);
$this->setNoClose(false);
$this->setNoDispose(false);
$this->setNoMove(false);
$this->setX(50);
$this->setY(50);
$this->client = $client;
if ($this->getGumpId() === null) {
$id = $this->retriveNewGumpId();
$this->setGumpId($id);
Map::$gumpsIds[$id] = &$this;
}
}
public function getClient() {
return $this->client;
}
private function retriveNewGumpId() {
$tmpId = rand(1000000000, 4294967295);
if (isset(Map::$gumpsIds[$tmpId])) {
$tmpId = $this->retriveNewGumpId();
}
return $tmpId;
}
public function setGumpId($gumpId) {
$this->gumpId = $gumpId;
}
public function getGumpId() {
return $this->gumpId;
}
public function setX($x) {
$this->x = $x;
}
public function getX() {
return $this->x;
}
public function setY($y) {
$this->y = $y;
}
public function getY() {
return $this->y;
}
public function setNoClose($noClose) {
$this->noClose = $noClose;
}
public function getNoClose() {
return $this->noClose;
}
public function setNoMove($noMove) {
$this->noMove = $noMove;
}
public function getNoMove() {
return $this->noMove;
}
public function setNoDispose($noDispose) {
$this->noDispose = $noDispose;
}
public function getNoDispose() {
return $this->noDispose;
}
public function getLayout() {
return ($this->getNoClose() ? "{noclose}" : "") . ($this->getNoDispose() ? "{nodispose}" : "") . ($this->getNoMove() ? "{nomove}" : "") . $this->layout;
}
public function getText() {
return $this->text;
}
public function getTextParsed() {
$textStr = "";
foreach ($this->getText() as $id => $text) {
$length = str_pad(dechex(strlen($text)), 4, "0", STR_PAD_LEFT);
$text = Functions::strToHex($text, true);
$textStr .= $length . $text;
}
return $textStr;
}
public function setType($type) {
$this->type = $type;
}
public function getType() {
return $this->type;
}
/**
* Send the compressed packet 0xDD to the client
*/
public function show() {
$this->build();
$packet = new packet_0xDD($this->client, $this);
$packet->send();
}
/**
* Dialog building methods
*/
public function addBackground($x, $y, $size_x, $size_y, $gump) {
$this->layout .= "{resizepic $x $y $gump $size_x $size_y}";
}
public function addText($x, $y, $color, $text) {
$this->text[] = $text;
$textId = count($this->text) - 1;
$this->layout .= "{text $x $y $color $textId}";
}
public function addLabelCropped($x, $y, $width, $height, $color, $text) {
$this->text[] = $text;
$textId = count($this->text) - 1;
$this->layout .= "{croppedtext $x $y $width $height $color $textId}";
}
public function addGumpPic($x, $y, $gump, $color = false) {
if (!$color) {
$this->layout .= "{gumppic $x $y $gump}";
} else {
$this->layout .= "{gumppic $x $y $gump hue=$color}";
}
}
public function addGumpPicTiled($x, $y, $to_x, $to_y, $gump) {
$this->layout .= "{gumppictiled $x $y $to_x $to_y $gump}";
}
public function addTransparency($x, $y, $to_x, $to_y) {
$this->layout .= "{checkertrans $x $y $to_x $to_y}";
}
public function addCheckbox($x, $y, $gump, $gump_pressed, $info_1, $info_2) {
$this->layout .= "{checkbox $x $y $gump $gump_pressed $info_1 $info_2}";
}
public function addGroup($group_id) {
$this->layout .= "{Group $group_id}";
}
public function addRadio($x, $y, $gump, $gump_pressed, $info_1, $info_2) {
$this->layout .= "{radio $x $y $gump $gump_pressed $info_1 $info_2}";
}
public function addTilePicHue($x, $y, $item_id, $color) {
$this->layout .= "{tilepichue $x $y $item_id $color}";
}
public function addTilePic($x, $y, $item_id) {
$this->layout .= "{tilepic $x $y $item_id}";
}
public function addTextEntry($x, $y, $to_x, $to_y, $color, $id, $text) {
$this->text[] = $text;
$textId = count($this->text) - 1;
$this->layout .= "{textentry $x $y $to_x $to_y $color $id $textId}";
}
public function addButton($x, $y, $gump, $gump_pressed, $info_1, $info_2, $info_3) {
$this->layout .= "{button $x $y $gump $gump_pressed $info_1 $info_2 $info_3}";
}
public function addHtmlGump($x, $y, $info_1, $info_2, $info_4, $info_5, $text) {
$this->text[] = $text;
$textId = count($this->text) - 1;
$this->layout .= "{htmlgump $x $y $info_1 $info_2 $textId $info_4 $info_5}";
}
public function addXmfHtmlGump($x, $y, $width, $height, $number, $background, $scrollbar) {
$this->layout .= "{xmfhtmlgump $x $y $width $height $number $background $scrollbar}";
}
public function addXmfHtmlGumpColor($x, $y, $width, $height, $number, $color, $background, $scrollbar) {
$this->layout .= "{xmfhtmlgumpcolor $x $y $width $height $number $background $scrollbar $color}";
}
public function addXmfHtmlTok($x, $y, $width, $height, $args, $number, $color, $background, $scrollbar) {
$this->layout .= "{xmfhtmltok $x $y $width $height $background $scrollbar $color $number $args}";
}
public function addPage($page_id = 0) {
if ($page_id == 0) {
return true;
}
$this->layout .= "{page $page_id}";
}
public function addECHandleInput() {
$this->layout .= "{ echandleinput }";
}
}