ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/pclient
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/pclient (file contents):
Revision 1.161 by elmex, Sun Apr 23 00:08:31 2006 UTC vs.
Revision 1.177 by root, Mon Apr 24 11:45:17 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines