1 | #!/opt/bin/perl |
1 | #!/opt/bin/perl |
2 | |
2 | |
3 | use strict; |
3 | use strict; |
4 | use utf8; |
4 | use utf8; |
|
|
5 | |
|
|
6 | BEGIN { |
|
|
7 | if (%PAR::LibCache) { |
|
|
8 | @INC = grep ref, @INC; # weed out all paths except pars loader refs |
|
|
9 | |
|
|
10 | while (my ($filename, $zip) = each %PAR::LibCache) { |
|
|
11 | for ($zip->memberNames) { |
|
|
12 | next unless /^\/root\/(.*)/; |
|
|
13 | $zip->extractMember ($_, "$ENV{PAR_TEMP}/$1") |
|
|
14 | unless -e "$ENV{PAR_TEMP}/$1"; |
|
|
15 | } |
|
|
16 | } |
|
|
17 | |
|
|
18 | unshift @INC, $ENV{PAR_TEMP}; |
|
|
19 | |
|
|
20 | if ($^O eq "MSWin32") { |
|
|
21 | $ENV{GTK_RC_FILES} = "$ENV{PAR_TEMP}/share/themes/MS-Windows/gtk-2.0/gtkrc"; |
|
|
22 | } |
|
|
23 | } |
|
|
24 | } |
|
|
25 | |
|
|
26 | # need to do it again because that pile of garbage called PAR nukes it before main |
|
|
27 | unshift @INC, $ENV{PAR_TEMP}; |
5 | |
28 | |
6 | use Time::HiRes 'time'; |
29 | use Time::HiRes 'time'; |
7 | use Event; |
30 | use Event; |
8 | |
31 | |
9 | use Crossfire; |
32 | use Crossfire; |
… | |
… | |
12 | use Compress::LZF; |
35 | use Compress::LZF; |
13 | |
36 | |
14 | use CFClient; |
37 | use CFClient; |
15 | use CFClient::UI; |
38 | use CFClient::UI; |
16 | use CFClient::MapWidget; |
39 | use CFClient::MapWidget; |
|
|
40 | |
|
|
41 | $SIG{__DIE__} = sub { CFClient::fatal "$_[0]"; exit 1 }; |
17 | |
42 | |
18 | our $VERSION = '0.1'; |
43 | our $VERSION = '0.1'; |
19 | |
44 | |
20 | my $MAX_FPS = 60; |
45 | my $MAX_FPS = 60; |
21 | my $MIN_FPS = 5; # unused as of yet |
46 | my $MIN_FPS = 5; # unused as of yet |
… | |
… | |
36 | our @SDL_MODES; |
61 | our @SDL_MODES; |
37 | our $WIDTH; |
62 | our $WIDTH; |
38 | our $HEIGHT; |
63 | our $HEIGHT; |
39 | our $FULLSCREEN; |
64 | our $FULLSCREEN; |
40 | our $FONTSIZE; |
65 | our $FONTSIZE; |
|
|
66 | |
|
|
67 | our $FONT_PROP; |
|
|
68 | our $FONT_FIXED; |
41 | |
69 | |
42 | our $MAP; |
70 | our $MAP; |
43 | our $MAPWIDGET; |
71 | our $MAPWIDGET; |
44 | our $BUTTONBAR; |
72 | our $BUTTONBAR; |
45 | our $LOGVIEW; |
73 | our $LOGVIEW; |
46 | our $CONSOLE; |
74 | our $CONSOLE; |
47 | our $METASERVER; |
75 | our $METASERVER; |
48 | |
76 | |
|
|
77 | our $FLOORBOX; |
49 | our $GAUGES; |
78 | our $GAUGES; |
50 | our $STATWIDS; |
79 | our $STATWIDS; |
51 | |
80 | |
52 | our $SDL_ACTIVE; |
81 | our $SDL_ACTIVE; |
53 | our %SDL_CB; |
82 | our %SDL_CB; |
… | |
… | |
120 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
149 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
121 | |
150 | |
122 | my $row = 1; |
151 | my $row = 1; |
123 | |
152 | |
124 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen"); |
153 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen"); |
125 | $table->add (1, $row++, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub { |
154 | $table->add (1, $row++, new CFClient::UI::CheckBox |
|
|
155 | state => $CFG->{fullscreen}, |
|
|
156 | tooltip => "Bring the client into fullscreen mode", |
|
|
157 | connect_changed => sub { |
126 | my ($self, $value) = @_; |
158 | my ($self, $value) = @_; |
127 | $CFG->{fullscreen} = $value; |
159 | $CFG->{fullscreen} = $value; |
|
|
160 | } |
128 | }); |
161 | ); |
129 | |
162 | |
130 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); |
163 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); |
131 | $table->add (1, $row++, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub { |
164 | $table->add (1, $row++, new CFClient::UI::CheckBox |
|
|
165 | state => $CFG->{fast}, |
|
|
166 | tooltip => "Lower the visual quality considerably to speed up rendering.", |
|
|
167 | connect_changed => sub { |
132 | my ($self, $value) = @_; |
168 | my ($self, $value) = @_; |
133 | $CFG->{fast} = $value; |
169 | $CFG->{fast} = $value; |
|
|
170 | } |
134 | }); |
171 | ); |
|
|
172 | |
|
|
173 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Map Scale"); |
|
|
174 | $table->add (1, $row++, new CFClient::UI::Slider |
|
|
175 | range => [$CFG->{map_scale}, 0.25, 2, 0.05], |
|
|
176 | tooltip => "Enlarge or shrink the displayed map", |
|
|
177 | connect_changed => sub { |
|
|
178 | my ($self, $value) = @_; |
|
|
179 | $CFG->{map_scale} = 0.05 * int $value / 0.05; |
|
|
180 | } |
|
|
181 | ); |
135 | |
182 | |
136 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War"); |
183 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War"); |
137 | $table->add (1, $row++, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub { |
184 | $table->add (1, $row++, new CFClient::UI::CheckBox |
|
|
185 | state => $CFG->{fow_enable}, |
|
|
186 | tooltip => "Fog-of-War marks areas that cannot be seen by the player", |
|
|
187 | connect_changed => sub { |
138 | my ($self, $value) = @_; |
188 | my ($self, $value) = @_; |
139 | $CFG->{fow_enable} = $value; |
189 | $CFG->{fow_enable} = $value; |
|
|
190 | } |
140 | }); |
191 | ); |
141 | |
192 | |
142 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity"); |
193 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity"); |
143 | $table->add (1, $row++, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub { |
194 | $table->add (1, $row++, new CFClient::UI::Slider |
|
|
195 | range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], |
|
|
196 | tooltip => "The higher the intensity, the lighter the Fog-of-War color", |
|
|
197 | connect_changed => sub { |
144 | my ($self, $value) = @_; |
198 | my ($self, $value) = @_; |
145 | $CFG->{fow_intensity} = $value; |
199 | $CFG->{fow_intensity} = $value; |
|
|
200 | } |
146 | }); |
201 | ); |
147 | |
202 | |
148 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Smooth"); |
203 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Smooth"); |
149 | $table->add (1, $row++, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
204 | $table->add (1, $row++, new CFClient::UI::CheckBox |
|
|
205 | state => $CFG->{fow_smooth}, |
|
|
206 | tooltip => "Smooth the Fog-of-War a bit to make it more realistic", |
|
|
207 | connect_changed => sub { |
150 | my ($self, $value) = @_; |
208 | my ($self, $value) = @_; |
151 | $CFG->{fow_smooth} = $value; |
209 | $CFG->{fow_smooth} = $value; |
152 | status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; |
210 | status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; |
|
|
211 | } |
153 | }); |
212 | ); |
154 | |
213 | |
155 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); |
214 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); |
156 | $table->add (1, $row++, new CFClient::UI::Slider range => [$CFG->{gui_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub { |
215 | $table->add (1, $row++, new CFClient::UI::Slider |
|
|
216 | range => [$CFG->{gui_fontsize}, 0.5, 2, 0.1], |
|
|
217 | tooltip => "The font size used by most GUI elements", |
|
|
218 | connect_changed => sub { |
157 | $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10; |
219 | $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10; |
158 | # $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
220 | # $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
|
|
221 | } |
159 | }); |
222 | ); |
160 | |
223 | |
161 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize"); |
224 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize"); |
162 | $table->add (1, $row++, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub { |
225 | $table->add (1, $row++, new CFClient::UI::Slider |
|
|
226 | range => [$CFG->{log_fontsize}, 0.5, 2, 0.1], |
|
|
227 | tooltip => "The font size used by the server log window only", |
|
|
228 | connect_changed => sub { |
163 | $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10); |
229 | $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10); |
|
|
230 | } |
164 | }); |
231 | ); |
165 | |
232 | |
166 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize"); |
233 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize"); |
167 | $table->add (1, $row++, new CFClient::UI::Slider range => [$CFG->{stat_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub { |
234 | |
|
|
235 | $table->add (1, $row++, new CFClient::UI::Slider |
|
|
236 | range => [$CFG->{stat_fontsize}, 0.5, 2, 0.1], |
|
|
237 | tooltip => "The font size used by the statistics window only", |
|
|
238 | connect_changed => sub { |
168 | $CFG->{stat_fontsize} = 0.1 * int $_[1] * 10; |
239 | $CFG->{stat_fontsize} = 0.1 * int $_[1] * 10; |
169 | &set_stats_window_fontsize; |
240 | &set_stats_window_fontsize; |
|
|
241 | } |
170 | }); |
242 | ); |
171 | |
243 | |
172 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge width"); |
244 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge size"); |
173 | $table->add (1, $row++, new CFClient::UI::Slider range => [$CFG->{gauge_w_size}, 0.1, 0.5, 0.02], connect_changed => sub { |
245 | $table->add (1, $row++, new CFClient::UI::Slider |
174 | $CFG->{gauge_w_size} = $_[1]; |
246 | range => [$CFG->{gauge_size}, 0.2, 0.8, 0.02], |
175 | my $h = int ($HEIGHT * $CFG->{gauge_size}); |
247 | tooltip => "Adjust the size of the stats gauges at the bottom right", |
176 | my $w = int ($WIDTH * $CFG->{gauge_w_size}); |
248 | connect_changed => sub { |
177 | $GAUGES->{win}->set_size ($w, $h); |
|
|
178 | $GAUGES->{win}->{y} = $HEIGHT - $h; |
|
|
179 | $GAUGES->{win}->{x} = $WIDTH - $w; |
|
|
180 | $GAUGES->{win}->update; |
|
|
181 | }); |
|
|
182 | |
|
|
183 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge height"); |
|
|
184 | $table->add (1, $row++, new CFClient::UI::Slider range => [$CFG->{gauge_size}, 0.2, 0.8, 0.02], connect_changed => sub { |
|
|
185 | $CFG->{gauge_size} = $_[1]; |
249 | $CFG->{gauge_size} = $_[1]; |
186 | my $h = int ($HEIGHT * $CFG->{gauge_size}); |
250 | my $h = int $HEIGHT * $CFG->{gauge_size}; |
187 | my $w = int ($WIDTH * $CFG->{gauge_w_size}); |
|
|
188 | $GAUGES->{win}->set_size ($w, $h); |
251 | $GAUGES->{win}->set_size ($WIDTH, $h); |
189 | $GAUGES->{win}->{y} = $HEIGHT - $h; |
252 | $GAUGES->{win}->move (0, $HEIGHT - $h); |
190 | $GAUGES->{win}->{x} = $WIDTH - $w; |
253 | } |
191 | $GAUGES->{win}->update; |
|
|
192 | }); |
254 | ); |
193 | |
|
|
194 | |
255 | |
195 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
256 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
196 | $table->add (1, $row++, new CFClient::UI::Slider range => [$CFG->{gauge_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub { |
257 | $table->add (1, $row++, new CFClient::UI::Slider |
|
|
258 | range => [$CFG->{gauge_fontsize}, 0.5, 2.0, 0.1], |
|
|
259 | tooltip => "Adjusts the fontsize of the gauges at the bottom right", |
|
|
260 | connect_changed => sub { |
197 | $CFG->{gauge_fontsize} = 0.1 * int $_[1] * 10; |
261 | $CFG->{gauge_fontsize} = 0.1 * int $_[1] * 10; |
198 | &set_gauge_window_fontsize; |
262 | &set_gauge_window_fontsize; |
199 | $GAUGES->{win}->check_size; |
263 | } |
200 | $GAUGES->{win}->update; |
|
|
201 | }); |
264 | ); |
202 | |
265 | |
203 | |
266 | $table->add (1, $row++, new CFClient::UI::Button |
204 | |
267 | expand => 1, align => 0, text => "Apply", |
205 | $table->add (1, $row++, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
268 | tooltip => "Apply the video settings", |
|
|
269 | connect_activate => sub { |
206 | video_shutdown (); |
270 | video_shutdown (); |
207 | video_init (); |
271 | video_init (); |
|
|
272 | } |
208 | }); |
273 | ); |
209 | |
274 | |
210 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable"); |
275 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable"); |
211 | $table->add (1, $row++, new CFClient::UI::CheckBox state => $CFG->{audio_enable}, connect_changed => sub { |
276 | $table->add (1, $row++, new CFClient::UI::CheckBox |
|
|
277 | state => $CFG->{audio_enable}, |
|
|
278 | tooltip => "If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.", |
|
|
279 | connect_changed => sub { |
212 | $CFG->{audio_enable} = $_[1]; |
280 | $CFG->{audio_enable} = $_[1]; |
|
|
281 | } |
213 | }); |
282 | ); |
214 | # $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume"); |
283 | # $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume"); |
215 | # $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], connect_changed => sub { |
284 | # $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], connect_changed => sub { |
216 | # $CFG->{effects_volume} = $_[1]; |
285 | # $CFG->{effects_volume} = $_[1]; |
217 | # }); |
286 | # }); |
218 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music"); |
287 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music"); |
219 | $table->add (1, $row++, my $hbox = new CFClient::UI::HBox); |
288 | $table->add (1, $row++, my $hbox = new CFClient::UI::HBox); |
220 | $hbox->add (new CFClient::UI::CheckBox expand => 1, state => $CFG->{bgm_enable}, connect_changed => sub { |
289 | $hbox->add (new CFClient::UI::CheckBox |
|
|
290 | expand => 1, state => $CFG->{bgm_enable}, |
|
|
291 | tooltip => "Enable background music playing", |
|
|
292 | connect_changed => sub { |
221 | $CFG->{bgm_enable} = $_[1]; |
293 | $CFG->{bgm_enable} = $_[1]; |
|
|
294 | } |
222 | }); |
295 | ); |
223 | $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0.1], connect_changed => sub { |
296 | $hbox->add (new CFClient::UI::Slider |
|
|
297 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0.1], |
|
|
298 | tooltip => "The volume of the background music", |
|
|
299 | connect_changed => sub { |
224 | $CFG->{bgm_volume} = $_[1]; |
300 | $CFG->{bgm_volume} = $_[1]; |
225 | CFClient::MixMusic::volume $_[1] * 128; |
301 | CFClient::MixMusic::volume $_[1] * 128; |
|
|
302 | } |
226 | }); |
303 | ); |
227 | |
304 | |
228 | $table->add (1, $row++, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
305 | $table->add (1, $row++, new CFClient::UI::Button |
|
|
306 | expand => 1, align => 0, text => "Apply", |
|
|
307 | tooltip => "Apply the audio settings", |
|
|
308 | connect_activate => sub { |
229 | audio_shutdown (); |
309 | audio_shutdown (); |
230 | audio_init (); |
310 | audio_init (); |
|
|
311 | } |
231 | }); |
312 | ); |
232 | |
313 | |
233 | $dialog |
314 | $dialog |
234 | } |
315 | } |
235 | |
316 | |
236 | sub set_stats_window_fontsize { |
317 | sub set_stats_window_fontsize { |
… | |
… | |
241 | |
322 | |
242 | sub set_gauge_window_fontsize { |
323 | sub set_gauge_window_fontsize { |
243 | for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) { |
324 | for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) { |
244 | $_->set_fontsize ($::CFG->{gauge_fontsize}); |
325 | $_->set_fontsize ($::CFG->{gauge_fontsize}); |
245 | } |
326 | } |
|
|
327 | |
|
|
328 | # local $GAUGES->{win}{parent};#d# |
|
|
329 | # use PApp::Util; open D, ">:utf8", "d"; print D PApp::Util::dumpval $GAUGES->{win}; close D; |
246 | } |
330 | } |
247 | |
331 | |
248 | sub make_gauge_window { |
332 | sub make_gauge_window { |
249 | my $gh = int ($HEIGHT * $CFG->{gauge_size}); |
333 | my $gh = int ($HEIGHT * $CFG->{gauge_size}); |
250 | my $gw = int ($WIDTH * $CFG->{gauge_w_size}); |
334 | # my $gw = int ($WIDTH * $CFG->{gauge_w_size}); |
251 | |
335 | |
252 | my $win = new CFClient::UI::Frame ( |
336 | my $win = new CFClient::UI::Frame ( |
253 | y => $HEIGHT - $gh, x => $WIDTH - $gw, req_w => $gw, req_h => $gh |
337 | y => $HEIGHT - $gh, x => 0, user_w => $WIDTH, user_h => $gh |
254 | ); |
338 | ); |
255 | $win->add (my $vb = new CFClient::UI::VBox); |
339 | $win->add (my $hbox = new CFClient::UI::HBox |
256 | |
340 | children => [ |
257 | $vb->add (my $hb = new CFClient::UI::HBox expand => 1); |
341 | (new CFClient::UI::HBox expand => 1), |
|
|
342 | ($FLOORBOX = new CFClient::UI::VBox), |
|
|
343 | (my $vbox = new CFClient::UI::VBox), |
|
|
344 | ], |
|
|
345 | ); |
|
|
346 | |
|
|
347 | $vbox->add (new CFClient::UI::HBox |
|
|
348 | expand => 1, |
|
|
349 | children => [ |
|
|
350 | (new CFClient::UI::Empty expand => 1), |
|
|
351 | (my $hb = new CFClient::UI::HBox), |
|
|
352 | ], |
|
|
353 | ); |
|
|
354 | |
258 | $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp', expand => 1); |
355 | $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp', |
|
|
356 | tooltip => "Health points - depletes when you get wounded, refills when you heal or idle"); |
259 | $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana', expand => 1); |
357 | $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana', |
|
|
358 | tooltip => "Spell points - deplete when you cast wizard spells, refills when you idle"); |
260 | $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace', expand => 1); |
359 | $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace', |
|
|
360 | tooltip => "Grace points - deplete when you cast priest spells, refills when you pray"); |
261 | $hb->add (my $fg = new CFClient::UI::Gauge type => 'food', expand => 1); |
361 | $hb->add (my $fg = new CFClient::UI::Gauge type => 'food', |
|
|
362 | tooltip => "Food - depletes with time, faster when you heal or build mana, refills when you eat healthy food"); |
|
|
363 | |
262 | $vb->add (my $exp = new CFClient::UI::Label valign => 0, align => -1, text => "XP:"); |
364 | $vbox->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, |
263 | $vb->add (my $lvl = new CFClient::UI::Label valign => 0, align => -1, text => "Lvl:"); |
365 | tooltip => "Experience points and level - increases when you kill monsters or successfully use skills"); |
264 | $vb->add (my $rng = new CFClient::UI::Label valign => 0, align => -1, text => "Rng:"); |
366 | $vbox->add (my $rng = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, |
265 | |
367 | tooltip => "Ranged attack - how you attack when you press shift-cursor (spell, skill, weapon etc.)"); |
266 | |
368 | |
267 | $GAUGES = { |
369 | $GAUGES = { |
268 | exp => $exp, lvl => $lvl, win => $win, range => $rng, |
370 | exp => $exp, win => $win, range => $rng, |
269 | food => $fg, mana => $mg, hp => $hg, grace => $gg |
371 | food => $fg, mana => $mg, hp => $hg, grace => $gg |
270 | }; |
372 | }; |
|
|
373 | |
|
|
374 | &set_gauge_window_fontsize; |
|
|
375 | |
271 | $win |
376 | $win |
272 | } |
377 | } |
273 | |
378 | |
274 | sub make_stats_window { |
379 | sub make_stats_window { |
275 | my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH * 2/5, y => 0, title => "Stats"); |
380 | my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH * 2/5, y => 0, title => "Stats"); |
276 | |
381 | |
277 | $tgw->add (my $vb = new CFClient::UI::VBox); |
382 | $tgw->add (my $vb = new CFClient::UI::VBox); |
278 | $vb->add (my $uhb = new CFClient::UI::HBox); |
|
|
279 | $uhb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1); |
383 | $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1); |
280 | $uhb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1); |
384 | $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1); |
281 | |
385 | |
282 | $vb->add (my $hb = new CFClient::UI::HBox expand => 1); |
386 | $vb->add (my $hb = new CFClient::UI::HBox expand => 1); |
283 | |
387 | |
284 | $hb->add (my $tbl = new CFClient::UI::Table expand => 1); |
388 | $hb->add (my $tbl = new CFClient::UI::Table expand => 1); |
285 | |
389 | |
286 | $tbl->add (0, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Str"); |
390 | my $black = [0, 0, 0]; |
287 | $tbl->add (0, 1, $STATWIDS->{st_dex_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Dex"); |
|
|
288 | $tbl->add (0, 2, $STATWIDS->{st_con_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Con"); |
|
|
289 | $tbl->add (0, 3, $STATWIDS->{st_int_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Int"); |
|
|
290 | $tbl->add (0, 4, $STATWIDS->{st_wis_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Wis"); |
|
|
291 | $tbl->add (0, 5, $STATWIDS->{st_pow_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Pow"); |
|
|
292 | $tbl->add (0, 6, $STATWIDS->{st_cha_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Cha"); |
|
|
293 | |
391 | |
294 | $tbl->add (1, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => +1, text => ""); |
392 | $tbl->add (0, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); |
295 | $tbl->add (1, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => +1, text => ""); |
393 | $tbl->add (0, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); |
296 | $tbl->add (1, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => +1, text => ""); |
394 | $tbl->add (0, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); |
297 | $tbl->add (1, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => +1, text => ""); |
395 | $tbl->add (0, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); |
298 | $tbl->add (1, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => +1, text => ""); |
396 | $tbl->add (0, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); |
299 | $tbl->add (1, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => +1, text => ""); |
397 | $tbl->add (0, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); |
300 | $tbl->add (1, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => +1, text => ""); |
398 | $tbl->add (0, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); |
301 | |
399 | |
302 | $tbl->add (2, 0, $STATWIDS->{st_wc_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Wc"); |
|
|
303 | $tbl->add (2, 1, $STATWIDS->{st_ac_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Ac"); |
|
|
304 | $tbl->add (2, 2, $STATWIDS->{st_dam_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Dam"); |
|
|
305 | $tbl->add (2, 3, $STATWIDS->{st_arm_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Arm"); |
|
|
306 | $tbl->add (2, 4, $STATWIDS->{st_spd_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Sp"); |
400 | $tbl->add (1, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Str"); |
|
|
401 | $tbl->add (1, 1, $STATWIDS->{st_dex_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Dex"); |
|
|
402 | $tbl->add (1, 2, $STATWIDS->{st_con_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Con"); |
|
|
403 | $tbl->add (1, 3, $STATWIDS->{st_int_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Int"); |
307 | $tbl->add (2, 5, $STATWIDS->{st_wspd_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "WSp"); |
404 | $tbl->add (1, 4, $STATWIDS->{st_wis_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Wis"); |
|
|
405 | $tbl->add (1, 5, $STATWIDS->{st_pow_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Pow"); |
|
|
406 | $tbl->add (1, 6, $STATWIDS->{st_cha_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Cha"); |
308 | |
407 | |
309 | $tbl->add (3, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => +1, text => ""); |
408 | $tbl->add (2, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => +1, template => "-120"); |
310 | $tbl->add (3, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => +1, text => ""); |
409 | $tbl->add (2, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => +1, template => "-120"); |
311 | $tbl->add (3, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => +1, text => ""); |
410 | $tbl->add (2, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => +1, template => "120"); |
312 | $tbl->add (3, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => +1, text => ""); |
411 | $tbl->add (2, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => +1, template => "120"); |
313 | $tbl->add (3, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => +1, text => ""); |
412 | $tbl->add (2, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => +1, template => "10.54"); |
314 | $tbl->add (3, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => +1, text => ""); |
413 | $tbl->add (2, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => +1, template => "9"); |
|
|
414 | |
|
|
415 | $tbl->add (3, 0, $STATWIDS->{st_wc_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Wc"); |
|
|
416 | $tbl->add (3, 1, $STATWIDS->{st_ac_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Ac"); |
|
|
417 | $tbl->add (3, 2, $STATWIDS->{st_dam_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Dam"); |
|
|
418 | $tbl->add (3, 3, $STATWIDS->{st_arm_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Arm"); |
|
|
419 | $tbl->add (3, 4, $STATWIDS->{st_spd_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Sp"); |
|
|
420 | $tbl->add (3, 5, $STATWIDS->{st_wspd_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "WSp"); |
315 | |
421 | |
316 | $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); |
422 | $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); |
317 | |
423 | |
318 | my $row = 0; |
424 | my $row = 0; |
319 | my $col = 0; |
425 | my $col = 0; |
320 | |
426 | |
|
|
427 | my %resist_names = ( |
|
|
428 | slow => "Slow", |
|
|
429 | holyw => "Holy Word", |
|
|
430 | conf => "Confusion", |
|
|
431 | fire => "Fire", |
|
|
432 | depl => "Depletion", |
|
|
433 | magic => "Magic", |
|
|
434 | drain => "Draining", |
|
|
435 | acid => "Acid", |
|
|
436 | pois => "Poison", |
|
|
437 | para => "Paralysation", |
|
|
438 | deat => "Death", |
|
|
439 | phys => "Physical", |
|
|
440 | blind => "Blind", |
|
|
441 | fear => "Fear", |
|
|
442 | tund => "Turn undead", |
|
|
443 | elec => "Electricity", |
|
|
444 | cold => "Cold", |
|
|
445 | ghit => "Ghost hit", |
|
|
446 | ); |
321 | for (qw/slow holyw conf fire depl magic |
447 | for (qw/slow holyw conf fire depl magic |
322 | drain acid pois para deat phys |
448 | drain acid pois para deat phys |
323 | blind fear tund elec cold ghit/) |
449 | blind fear tund elec cold ghit/) |
324 | { |
450 | { |
325 | $tbl2->add ($col , $row, |
451 | $tbl2->add ($col, $row, |
326 | $STATWIDS->{"res_$_"} = |
452 | $STATWIDS->{"res_$_"} = |
327 | new CFClient::UI::Label text => "0", align => +1, valign => 0 |
453 | new CFClient::UI::Label |
|
|
454 | template => "-100%", |
|
|
455 | align => +1, |
|
|
456 | valign => 0, |
|
|
457 | tooltip => $resist_names{$_} |
328 | ); |
458 | ); |
329 | $tbl2->add ($col + 1, $row, new CFClient::UI::Image image => "ui/resist/resist_$_.png"); |
459 | $tbl2->add ($col + 1, $row, new CFClient::UI::Image |
|
|
460 | can_hover => 1, |
|
|
461 | can_events => 1, |
|
|
462 | image => "ui/resist/resist_$_.png", |
|
|
463 | tooltip => $resist_names{$_} |
|
|
464 | ); |
330 | |
465 | |
331 | $row++; |
466 | $row++; |
332 | if ($row % 6 == 0) { |
467 | if ($row % 6 == 0) { |
333 | $col += 2; |
468 | $col += 2; |
334 | $row = 0; |
469 | $row = 0; |
… | |
… | |
339 | update_stats_window ({}); |
474 | update_stats_window ({}); |
340 | |
475 | |
341 | $tgw |
476 | $tgw |
342 | } |
477 | } |
343 | |
478 | |
|
|
479 | sub formsep { |
|
|
480 | reverse join ",", grep length, split /(...)/, reverse $_[0] * 1 |
|
|
481 | } |
|
|
482 | |
344 | sub update_stats_window { |
483 | sub update_stats_window { |
345 | my ($stats) = @_; |
484 | my ($stats) = @_; |
346 | |
485 | |
347 | # i love text protocols!!! |
486 | # i love text protocols!!! |
348 | my $hp = $stats->{1} * 1; |
487 | my $hp = $stats->{Crossfire::Protocol::CS_STAT_HP} * 1; |
349 | my $hp_m = $stats->{2} * 1; |
488 | my $hp_m = $stats->{Crossfire::Protocol::CS_STAT_MAXHP} * 1; |
350 | my $sp = $stats->{3} * 1; |
489 | my $sp = $stats->{Crossfire::Protocol::CS_STAT_SP} * 1; |
351 | my $sp_m = $stats->{4} * 1; |
490 | my $sp_m = $stats->{Crossfire::Protocol::CS_STAT_MAXSP} * 1; |
352 | my $fo = $stats->{18} * 1; |
491 | my $fo = $stats->{Crossfire::Protocol::CS_STAT_FOOD} * 1; |
353 | my $fo_m = 999; |
492 | my $fo_m = 999; |
354 | my $gr = $stats->{23} * 1; |
493 | my $gr = $stats->{Crossfire::Protocol::CS_STAT_GRACE} * 1; |
355 | my $gr_m = $stats->{24} * 1; |
494 | my $gr_m = $stats->{Crossfire::Protocol::CS_STAT_MAXGRACE} * 1; |
356 | |
495 | |
357 | $GAUGES->{hp} ->set_value ($hp, $hp_m); |
496 | $GAUGES->{hp} ->set_value ($hp, $hp_m); |
358 | $GAUGES->{mana} ->set_value ($sp, $sp_m); |
497 | $GAUGES->{mana} ->set_value ($sp, $sp_m); |
359 | $GAUGES->{food} ->set_value ($fo, $fo_m); |
498 | $GAUGES->{food} ->set_value ($fo, $fo_m); |
360 | $GAUGES->{grace} ->set_value ($gr, $gr_m); |
499 | $GAUGES->{grace} ->set_value ($gr, $gr_m); |
361 | $GAUGES->{exp} ->set_text ("XP: " . ($stats->{11} || $stats->{28})); |
500 | $GAUGES->{exp} ->set_text ("Exp: " . (formsep $stats->{Crossfire::Protocol::CS_STAT_EXP64}) |
362 | my $rng = $stats->{20}; |
501 | . " (lvl " . ($stats->{Crossfire::Protocol::CS_STAT_LEVEL} * 1) . ")"); |
|
|
502 | my $rng = $stats->{Crossfire::Protocol::CS_STAT_RANGE}; |
363 | $rng =~ s/^Range: //; # thank you so much dear server |
503 | $rng =~ s/^Range: //; # thank you so much dear server |
364 | $GAUGES->{range} ->set_text ("Rng: " . $rng); |
504 | $GAUGES->{range} ->set_text ("Rng: " . $rng); |
365 | $GAUGES->{lvl} ->set_text ("LVL: " . $stats->{12}); |
505 | my $title = $stats->{Crossfire::Protocol::CS_STAT_TITLE}; |
|
|
506 | $title =~ s/^Player: //; |
366 | $STATWIDS->{title} ->set_text ("Title: " . $stats->{21}); |
507 | $STATWIDS->{title} ->set_text ("Title: " . $title); |
367 | |
508 | |
368 | if (0) { # this code can vanish, just wanted to preserver it for a checkin |
|
|
369 | $STATWIDS->{st_str} ->set_text (sprintf "S%d", $stats->{5}); |
|
|
370 | $STATWIDS->{st_dex} ->set_text (sprintf "D%d", $stats->{8}); |
|
|
371 | $STATWIDS->{st_con} ->set_text (sprintf "Co%d", $stats->{9}); |
|
|
372 | $STATWIDS->{st_int} ->set_text (sprintf "I%d", $stats->{6}); |
|
|
373 | $STATWIDS->{st_wis} ->set_text (sprintf "W%d", $stats->{7}); |
|
|
374 | $STATWIDS->{st_pow} ->set_text (sprintf "P%d", $stats->{22}); |
|
|
375 | $STATWIDS->{st_cha} ->set_text (sprintf "Ch%d", $stats->{10}); |
|
|
376 | $STATWIDS->{st_wc} ->set_text (sprintf "Wc%d", $stats->{13}); |
|
|
377 | $STATWIDS->{st_ac} ->set_text (sprintf "Ac%d", $stats->{14}); |
|
|
378 | $STATWIDS->{st_dam} ->set_text (sprintf "Dam%d", $stats->{15}); |
|
|
379 | $STATWIDS->{st_arm} ->set_text (sprintf "Arm%d", $stats->{16}); |
|
|
380 | $STATWIDS->{st_spd} ->set_text (sprintf "Sp%.1f", $stats->{17}); |
|
|
381 | $STATWIDS->{st_wspd}->set_text (sprintf "WSp%.1f", $stats->{19}); |
|
|
382 | } else { |
|
|
383 | $STATWIDS->{st_str} ->set_text (sprintf "%d", $stats->{5}); |
509 | $STATWIDS->{st_str} ->set_text (sprintf "%d", $stats->{5}); |
384 | $STATWIDS->{st_dex} ->set_text (sprintf "%d", $stats->{8}); |
510 | $STATWIDS->{st_dex} ->set_text (sprintf "%d", $stats->{8}); |
385 | $STATWIDS->{st_con} ->set_text (sprintf "%d", $stats->{9}); |
511 | $STATWIDS->{st_con} ->set_text (sprintf "%d", $stats->{9}); |
386 | $STATWIDS->{st_int} ->set_text (sprintf "%d", $stats->{6}); |
512 | $STATWIDS->{st_int} ->set_text (sprintf "%d", $stats->{6}); |
387 | $STATWIDS->{st_wis} ->set_text (sprintf "%d", $stats->{7}); |
513 | $STATWIDS->{st_wis} ->set_text (sprintf "%d", $stats->{7}); |
388 | $STATWIDS->{st_pow} ->set_text (sprintf "%d", $stats->{22}); |
514 | $STATWIDS->{st_pow} ->set_text (sprintf "%d", $stats->{22}); |
389 | $STATWIDS->{st_cha} ->set_text (sprintf "%d", $stats->{10}); |
515 | $STATWIDS->{st_cha} ->set_text (sprintf "%d", $stats->{10}); |
390 | $STATWIDS->{st_wc} ->set_text (sprintf "%d", $stats->{13}); |
516 | $STATWIDS->{st_wc} ->set_text (sprintf "%d", $stats->{13}); |
391 | $STATWIDS->{st_ac} ->set_text (sprintf "%d", $stats->{14}); |
517 | $STATWIDS->{st_ac} ->set_text (sprintf "%d", $stats->{14}); |
392 | $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15}); |
518 | $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15}); |
393 | $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16}); |
519 | $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16}); |
394 | $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{17}); |
520 | $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::CS_STAT_SPEED}); |
395 | $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{19}); |
521 | $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::CS_STAT_WEAP_SP}); |
396 | } |
|
|
397 | |
522 | |
398 | my %tbl = ( |
523 | my %tbl = ( |
399 | phys => 100, |
524 | phys => 100, |
400 | magic => 101, |
525 | magic => 101, |
401 | fire => 102, |
526 | fire => 102, |
… | |
… | |
408 | pois => 109, |
533 | pois => 109, |
409 | slow => 110, |
534 | slow => 110, |
410 | para => 111, |
535 | para => 111, |
411 | tund => 112, |
536 | tund => 112, |
412 | fear => 113, |
537 | fear => 113, |
|
|
538 | depl => 113, |
413 | deat => 115, |
539 | deat => 115, |
414 | holyw => 116, |
540 | holyw => 116, |
415 | blind => 117 |
541 | blind => 117 |
416 | ); |
542 | ); |
417 | |
543 | |
… | |
… | |
506 | $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); |
632 | $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); |
507 | |
633 | |
508 | { |
634 | { |
509 | $table->add (1, 2, my $vbox = new CFClient::UI::VBox); |
635 | $table->add (1, 2, my $vbox = new CFClient::UI::VBox); |
510 | |
636 | |
511 | $vbox->add (my $HOST = new CFClient::UI::Entry expand => 1, text => $CFG->{host}, connect_changed => sub { |
637 | $vbox->add ( |
|
|
638 | my $HOST = new CFClient::UI::Entry |
|
|
639 | expand => 1, |
|
|
640 | text => $CFG->{host}, |
|
|
641 | tooltip => "The hostname or ip address of the Crossfire(+) server to connect to", |
|
|
642 | connect_changed => sub { |
|
|
643 | my ($self, $value) = @_; |
|
|
644 | $CFG->{host} = $value; |
|
|
645 | } |
|
|
646 | ); |
|
|
647 | |
|
|
648 | $METASERVER = metaserver_dialog; |
|
|
649 | |
|
|
650 | $vbox->add (new CFClient::UI::Flopper |
|
|
651 | expand => 1, |
|
|
652 | text => "Metaserver", |
|
|
653 | other => $METASERVER, |
|
|
654 | tooltip => "Show a list of avaible crossfire servers", |
|
|
655 | connect_open => sub { |
|
|
656 | update_metaserver $HOST; |
|
|
657 | } |
|
|
658 | ); |
|
|
659 | } |
|
|
660 | |
|
|
661 | $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username"); |
|
|
662 | $table->add (1, 4, new CFClient::UI::Entry |
|
|
663 | text => $CFG->{user}, |
|
|
664 | tooltip => "The name of your character on the server", |
|
|
665 | connect_changed => sub { |
512 | my ($self, $value) = @_; |
666 | my ($self, $value) = @_; |
513 | $CFG->{host} = $value; |
|
|
514 | }); |
|
|
515 | |
|
|
516 | $METASERVER = metaserver_dialog; |
|
|
517 | |
|
|
518 | $vbox->add (new CFClient::UI::Flopper expand => 1, text => "Metaserver", other => $METASERVER, connect_open => sub { |
|
|
519 | update_metaserver $HOST; |
|
|
520 | }); |
|
|
521 | } |
|
|
522 | |
|
|
523 | $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username"); |
|
|
524 | $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { |
|
|
525 | my ($self, $value) = @_; |
|
|
526 | $CFG->{user} = $value; |
667 | $CFG->{user} = $value; |
|
|
668 | } |
527 | }); |
669 | ); |
528 | |
670 | |
529 | $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password"); |
671 | $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password"); |
530 | $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { |
672 | $table->add (1, 5, new CFClient::UI::Entry |
|
|
673 | text => $CFG->{password}, |
|
|
674 | hidden => 1, |
|
|
675 | tooltip => "The password for your character", |
|
|
676 | connect_changed => sub { |
531 | my ($self, $value) = @_; |
677 | my ($self, $value) = @_; |
532 | $CFG->{password} = $value; |
678 | $CFG->{password} = $value; |
|
|
679 | } |
533 | }); |
680 | ); |
534 | |
681 | |
535 | $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); |
682 | $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); |
536 | $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { |
683 | $table->add (1, 6, my $saycmd = new CFClient::UI::Entry |
|
|
684 | text => $CFG->{say_command}, |
|
|
685 | tooltip => "This is the command that will be used if you write a line in the message window entry. " |
|
|
686 | ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " |
|
|
687 | ."But you could also set it to 'tell <playername>' to only chat with that user.", |
|
|
688 | connect_changed => sub { |
537 | my ($self, $value) = @_; |
689 | my ($self, $value) = @_; |
538 | $CFG->{say_command} = $value; |
690 | $CFG->{say_command} = $value; |
|
|
691 | } |
539 | }); |
692 | ); |
540 | |
693 | |
541 | $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); |
694 | $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); |
542 | $table->add (1, 7, new CFClient::UI::Slider |
695 | $table->add (1, 7, new CFClient::UI::Slider |
543 | req_w => 100, |
696 | req_w => 100, |
544 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
697 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
|
|
698 | tooltip => "This is the size of the portion of the map update the server sends you. " |
|
|
699 | ."If you set this to a high value you will be able to see further for example.", |
545 | connect_changed => sub { |
700 | connect_changed => sub { |
546 | my ($self, $value) = @_; |
701 | my ($self, $value) = @_; |
547 | |
702 | |
548 | $CFG->{mapsize} = $self->{range}[0] = $value = int $value; |
703 | $CFG->{mapsize} = $self->{range}[0] = $value = int $value; |
549 | }, |
704 | }, |
… | |
… | |
565 | user_h => int $::HEIGHT / 5, |
720 | user_h => int $::HEIGHT / 5, |
566 | child => (my $vbox = new CFClient::UI::VBox); |
721 | child => (my $vbox = new CFClient::UI::VBox); |
567 | |
722 | |
568 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView |
723 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView |
569 | expand => 1, |
724 | expand => 1, |
|
|
725 | font => $FONT_FIXED, |
570 | fontsize => $::CFG->{log_fontsize}, |
726 | fontsize => $::CFG->{log_fontsize}, |
571 | ); |
727 | ); |
572 | |
728 | |
573 | $vbox->add (my $input = new CFClient::UI::Entry |
729 | $vbox->add (my $input = new CFClient::UI::Entry |
574 | connect_focus_in => sub { |
730 | connect_focus_in => sub { |
… | |
… | |
668 | |
824 | |
669 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); |
825 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); |
670 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); |
826 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); |
671 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); |
827 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); |
672 | |
828 | |
|
|
829 | $CFClient::UI::ROOT->add (make_gauge_window); # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D |
|
|
830 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); |
|
|
831 | |
673 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
832 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
674 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
833 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
675 | status "Configuration Saved"; |
834 | status "Configuration Saved"; |
676 | }); |
835 | }); |
677 | |
836 | |
678 | $CFClient::UI::ROOT->add (make_gauge_window); # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D |
|
|
679 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); |
|
|
680 | |
|
|
681 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
837 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
682 | |
|
|
683 | |
|
|
684 | } |
838 | } |
685 | |
839 | |
686 | sub video_shutdown { |
840 | sub video_shutdown { |
687 | $CFClient::UI::ROOT->{children} = []; |
841 | $CFClient::UI::ROOT->{children} = []; |
688 | undef $SDL_ACTIVE; |
842 | undef $SDL_ACTIVE; |
… | |
… | |
973 | } |
1127 | } |
974 | |
1128 | |
975 | gotid: |
1129 | gotid: |
976 | $face->{id} = $id; |
1130 | $face->{id} = $id; |
977 | $MAP->set_face ($facenum => $id); |
1131 | $MAP->set_face ($facenum => $id); |
|
|
1132 | $self->{faceid}[$facenum] = $id;#d# |
978 | $TILECACHE->get ($id) |
1133 | $TILECACHE->get ($id) |
979 | } |
1134 | } |
980 | |
1135 | |
981 | sub conn::face_update { |
1136 | sub conn::face_update { |
982 | my ($self, $facenum, $face) = @_; |
1137 | my ($self, $facenum, $face) = @_; |
… | |
… | |
990 | my ($self, $id, $data) = @_; |
1145 | my ($self, $id, $data) = @_; |
991 | |
1146 | |
992 | $self->{texture}[$id] ||= do { |
1147 | $self->{texture}[$id] ||= do { |
993 | my $tex = |
1148 | my $tex = |
994 | new_from_image CFClient::Texture |
1149 | new_from_image CFClient::Texture |
995 | $data, minify => 1; |
1150 | $data, minify => 1, mipmap => 1; |
996 | |
1151 | |
997 | $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
1152 | $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
998 | $MAPWIDGET->update; |
1153 | $MAPWIDGET->update; |
999 | |
1154 | |
1000 | $tex |
1155 | $tex |
… | |
… | |
1012 | |
1167 | |
1013 | $chunk->play; |
1168 | $chunk->play; |
1014 | # warn "sound $x,$y,$soundnum,$type\n";#d# |
1169 | # warn "sound $x,$y,$soundnum,$type\n";#d# |
1015 | } |
1170 | } |
1016 | |
1171 | |
|
|
1172 | my $LAST_QUERY; # server is stupid, stupid, stupid |
|
|
1173 | |
1017 | sub conn::query { |
1174 | sub conn::query { |
1018 | my ($self, $flags, $prompt) = @_; |
1175 | my ($self, $flags, $prompt) = @_; |
1019 | |
1176 | |
1020 | #TODO, display dialog with relevant information |
1177 | $prompt = $LAST_QUERY unless length $prompt; |
1021 | warn "<<<<QUERY:$flags:$prompt>>>\n";#d# |
1178 | $LAST_QUERY = $prompt; |
|
|
1179 | |
|
|
1180 | my $dialog = new CFClient::UI::FancyFrame |
|
|
1181 | title => "Query", |
|
|
1182 | child => my $vbox = new CFClient::UI::VBox; |
|
|
1183 | |
|
|
1184 | $vbox->add (new CFClient::UI::Label |
|
|
1185 | max_w => $::WIDTH * 0.4, |
|
|
1186 | text => $prompt); |
|
|
1187 | |
|
|
1188 | if ($flags & Crossfire::Protocol::CS_QUERY_YESNO) { |
|
|
1189 | $vbox->add (my $hbox = new CFClient::HBox); |
|
|
1190 | $hbox->add (new CFClient::Button |
|
|
1191 | text => "No", |
|
|
1192 | connect_activate => sub { |
|
|
1193 | $self->send ("reply n"); |
|
|
1194 | $dialog->destroy; |
|
|
1195 | $MAPWIDGET->focus_in; |
|
|
1196 | } |
|
|
1197 | ); |
|
|
1198 | $hbox->add (new CFClient::Button |
|
|
1199 | text => "Yes", |
|
|
1200 | connect_activate => sub { |
|
|
1201 | $self->send ("reply y"); |
|
|
1202 | $dialog->destroy; |
|
|
1203 | $MAPWIDGET->focus_in; |
|
|
1204 | }, |
|
|
1205 | ); |
|
|
1206 | |
|
|
1207 | $dialog->focus_in; |
|
|
1208 | |
|
|
1209 | } elsif ($flags & Crossfire::Protocol::CS_QUERY_SINGLECHAR) { |
|
|
1210 | $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; |
|
|
1211 | $vbox->add (my $entry = new CFClient::UI::Entry |
|
|
1212 | connect_changed => sub { |
|
|
1213 | $self->send ("reply $_[1]"); |
|
|
1214 | $dialog->destroy; |
|
|
1215 | $MAPWIDGET->focus_in; |
|
|
1216 | }, |
|
|
1217 | ); |
|
|
1218 | |
|
|
1219 | $entry->focus_in; |
|
|
1220 | |
|
|
1221 | } else { |
|
|
1222 | $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; |
|
|
1223 | |
|
|
1224 | $vbox->add (my $entry = new CFClient::UI::Entry |
|
|
1225 | $flags & Crossfire::Protocol::CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (), |
|
|
1226 | connect_activate => sub { |
|
|
1227 | $self->send ("reply $_[1]"); |
|
|
1228 | $dialog->destroy; |
|
|
1229 | $MAPWIDGET->focus_in; |
|
|
1230 | }, |
|
|
1231 | ); |
|
|
1232 | |
|
|
1233 | $entry->focus_in; |
|
|
1234 | } |
|
|
1235 | |
|
|
1236 | $dialog->show; |
1022 | } |
1237 | } |
1023 | |
1238 | |
1024 | sub conn::drawinfo { |
1239 | sub conn::drawinfo { |
1025 | my ($self, $color, $text) = @_; |
1240 | my ($self, $color, $text) = @_; |
1026 | |
1241 | |
… | |
… | |
1044 | } |
1259 | } |
1045 | |
1260 | |
1046 | sub conn::spell_add { |
1261 | sub conn::spell_add { |
1047 | my ($self, $spell) = @_; |
1262 | my ($self, $spell) = @_; |
1048 | |
1263 | |
|
|
1264 | # TODO |
|
|
1265 | # create a widget dynamically, using spell face (CF::Protocol downloads them) |
1049 | $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}, sub { |
1266 | $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}); |
1050 | }); |
|
|
1051 | $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}, sub { |
1267 | $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}); |
1052 | }); |
|
|
1053 | } |
1268 | } |
1054 | |
1269 | |
1055 | sub conn::spell_delete { |
1270 | sub conn::spell_delete { |
1056 | my ($self, $spell) = @_; |
1271 | my ($self, $spell) = @_; |
1057 | } |
1272 | } |
1058 | |
1273 | |
1059 | sub conn::addme_success { |
1274 | sub conn::addme_success { |
1060 | my ($self) = @_; |
1275 | my ($self) = @_; |
1061 | |
1276 | |
1062 | for my $skill (values %{$self->{skill_info}}) { |
1277 | for my $skill (values %{$self->{skill_info}}) { |
1063 | $MAPWIDGET->add_command ("ready_skill $skill", "", sub { |
1278 | $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'"); |
1064 | }); |
1279 | $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'"); |
1065 | $MAPWIDGET->add_command ("use_skill $skill", "", sub { |
|
|
1066 | }); |
|
|
1067 | } |
1280 | } |
|
|
1281 | } |
|
|
1282 | |
|
|
1283 | sub update_floorbox { |
|
|
1284 | $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { |
|
|
1285 | $FLOORBOX->clear; |
|
|
1286 | $FLOORBOX->add (new CFClient::UI::Empty expand => 1); |
|
|
1287 | |
|
|
1288 | my @items = values %{ $CONN->{container}{0} }; |
|
|
1289 | |
|
|
1290 | # we basically have to use the same sorting as everybody else |
|
|
1291 | @items = sort { $a->{type} <=> $b->{type} } @items; |
|
|
1292 | |
|
|
1293 | for my $item (reverse @items) { |
|
|
1294 | my $desc = $item->{nrof} < 2 |
|
|
1295 | ? $item->{name} |
|
|
1296 | : "$item->{nrof} $item->{name_pl}"; |
|
|
1297 | # todo: animation widget, face widget, weight(?) etc. |
|
|
1298 | $FLOORBOX->add (my $hbox = new CFClient::UI::HBox |
|
|
1299 | tooltip => (CFClient::UI::Label->escape ($desc) |
|
|
1300 | . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"), |
|
|
1301 | can_hover => 1, |
|
|
1302 | can_events => 1, |
|
|
1303 | connect_button_down => sub { |
|
|
1304 | my ($self, $ev, $x, $y) = @_; |
|
|
1305 | |
|
|
1306 | # todo: maybe put examine on 1? but should just be a tooltip :( |
|
|
1307 | if ($ev->{button} == 1) { |
|
|
1308 | $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0"); |
|
|
1309 | } elsif ($ev->{button} == 2) { |
|
|
1310 | $CONN->send ("apply $item->{tag}"); |
|
|
1311 | } elsif ($ev->{button} == 3) { |
|
|
1312 | # examine, lock, mark, maybe other things |
|
|
1313 | warn "MENU not implemented yet\n"; |
|
|
1314 | } |
|
|
1315 | |
|
|
1316 | 1 |
|
|
1317 | }, |
|
|
1318 | ); |
|
|
1319 | |
|
|
1320 | $hbox->add (new CFClient::UI::Face |
|
|
1321 | can_events => 0, |
|
|
1322 | face => $item->{face}, |
|
|
1323 | anim => $item->{anim}, |
|
|
1324 | animspeed => $item->{animspeed}, |
|
|
1325 | ); |
|
|
1326 | |
|
|
1327 | $hbox->add (new CFClient::UI::Label |
|
|
1328 | can_events => 0, |
|
|
1329 | text => $desc, |
|
|
1330 | ); |
|
|
1331 | } |
|
|
1332 | }); |
|
|
1333 | refresh; |
|
|
1334 | } |
|
|
1335 | |
|
|
1336 | sub conn::container_add { |
|
|
1337 | my ($self, $id, $items) = @_; |
|
|
1338 | |
|
|
1339 | update_floorbox if $id == 0; |
|
|
1340 | # $self-<{player}{tag} => player inv |
|
|
1341 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
|
|
1342 | } |
|
|
1343 | |
|
|
1344 | sub conn::container_clear { |
|
|
1345 | my ($self, $id) = @_; |
|
|
1346 | |
|
|
1347 | update_floorbox if $id == 0; |
|
|
1348 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
|
|
1349 | } |
|
|
1350 | |
|
|
1351 | sub conn::item_delete { |
|
|
1352 | my ($self, @items) = @_; |
|
|
1353 | |
|
|
1354 | for (@items) { |
|
|
1355 | update_floorbox if $_->{container} == 0; |
|
|
1356 | } |
|
|
1357 | } |
|
|
1358 | |
|
|
1359 | sub conn::item_update { |
|
|
1360 | my ($self, $item) = @_; |
|
|
1361 | |
|
|
1362 | update_floorbox if $item->{container} == 0; |
1068 | } |
1363 | } |
1069 | |
1364 | |
1070 | %SDL_CB = ( |
1365 | %SDL_CB = ( |
1071 | CFClient::SDL_QUIT => sub { |
1366 | CFClient::SDL_QUIT => sub { |
1072 | Event::unloop -1; |
1367 | Event::unloop -1; |
… | |
… | |
1107 | sdl_mode => 0, |
1402 | sdl_mode => 0, |
1108 | width => 640, |
1403 | width => 640, |
1109 | height => 480, |
1404 | height => 480, |
1110 | fullscreen => 0, |
1405 | fullscreen => 0, |
1111 | fast => 0, |
1406 | fast => 0, |
|
|
1407 | map_scale => 0.5, |
1112 | fow_enable => 1, |
1408 | fow_enable => 1, |
1113 | fow_intensity => 0.45, |
1409 | fow_intensity => 0.45, |
1114 | fow_smooth => 0, |
1410 | fow_smooth => 0, |
1115 | gui_fontsize => 1, |
1411 | gui_fontsize => 1, |
1116 | log_fontsize => 1, |
1412 | log_fontsize => 1, |
1117 | gauge_fontsize => 1, |
1413 | gauge_fontsize => 1, |
1118 | gauge_size => 0.35, |
1414 | gauge_size => 0.35, |
1119 | gauge_w_size => 0.14, |
|
|
1120 | stat_fontsize => 1, |
1415 | stat_fontsize => 1, |
1121 | mapsize => 100, |
1416 | mapsize => 100, |
1122 | host => "crossfire.schmorp.de", |
1417 | host => "crossfire.schmorp.de", |
1123 | say_command => 'say', |
1418 | say_command => 'say', |
1124 | audio_enable => 1, |
1419 | audio_enable => 1, |
… | |
… | |
1139 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
1434 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
1140 | |
1435 | |
1141 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
1436 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
1142 | |
1437 | |
1143 | { |
1438 | { |
1144 | my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); |
1439 | my @fonts = map CFClient::find_rcfile "fonts/$_", qw( |
|
|
1440 | DejaVuSans.ttf |
|
|
1441 | DejaVuSansMono.ttf |
|
|
1442 | DejaVuSans-Bold.ttf |
|
|
1443 | DejaVuSansMono-Bold.ttf |
|
|
1444 | DejaVuSans-Oblique.ttf |
|
|
1445 | DejaVuSansMono-Oblique.ttf |
|
|
1446 | DejaVuSans-BoldOblique.ttf |
|
|
1447 | DejaVuSansMono-BoldOblique.ttf |
|
|
1448 | ); |
1145 | |
1449 | |
1146 | CFClient::add_font $_ for @fonts; |
1450 | CFClient::add_font $_ for @fonts; |
1147 | CFClient::set_font $fonts[0]; |
1451 | |
|
|
1452 | $FONT_PROP = new_from_file CFClient::Font $fonts[0]; |
|
|
1453 | $FONT_FIXED = new_from_file CFClient::Font $fonts[1]; |
|
|
1454 | |
|
|
1455 | $FONT_PROP->make_default; |
1148 | } |
1456 | } |
1149 | |
1457 | |
1150 | video_init; |
1458 | video_init; |
1151 | audio_init; |
1459 | audio_init; |
1152 | |
1460 | |