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.156 by elmex, Fri Apr 21 12:27:20 2006 UTC vs.
Revision 1.174 by root, Mon Apr 24 06:40:30 2006 UTC

36our @SDL_MODES; 36our @SDL_MODES;
37our $WIDTH; 37our $WIDTH;
38our $HEIGHT; 38our $HEIGHT;
39our $FULLSCREEN; 39our $FULLSCREEN;
40our $FONTSIZE; 40our $FONTSIZE;
41
42our $FONT_PROP;
43our $FONT_FIXED;
41 44
42our $MAP; 45our $MAP;
43our $MAPWIDGET; 46our $MAPWIDGET;
44our $BUTTONBAR; 47our $BUTTONBAR;
45our $LOGVIEW; 48our $LOGVIEW;
46our $CONSOLE; 49our $CONSOLE;
47our $METASERVER; 50our $METASERVER;
48 51
52our $FLOORBOX;
49our $GAUGES; 53our $GAUGES;
50our $STATWIDS; 54our $STATWIDS;
51 55
52our $SDL_ACTIVE; 56our $SDL_ACTIVE;
53our %SDL_CB; 57our %SDL_CB;
117 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; 121 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value;
118 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); 122 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]});
119 }); 123 });
120 $mode_slider->emit (changed => $mode_slider->{range}[0]); 124 $mode_slider->emit (changed => $mode_slider->{range}[0]);
121 125
126 my $row = 1;
127
122 $table->add (0, 1, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen"); 128 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen");
123 $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub { 129 $table->add (1, $row++, new CFClient::UI::CheckBox
130 state => $CFG->{fullscreen},
131 tooltip => "Bring the client into fullscreen mode",
132 connect_changed => sub {
124 my ($self, $value) = @_; 133 my ($self, $value) = @_;
125 $CFG->{fullscreen} = $value; 134 $CFG->{fullscreen} = $value;
135 }
126 }); 136 );
127 137
128 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); 138 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fast & Ugly");
129 $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub { 139 $table->add (1, $row++, new CFClient::UI::CheckBox
140 state => $CFG->{fast},
141 tooltip => "Lower the visual quality considerably to speed up rendering.",
142 connect_changed => sub {
130 my ($self, $value) = @_; 143 my ($self, $value) = @_;
131 $CFG->{fast} = $value; 144 $CFG->{fast} = $value;
145 }
132 }); 146 );
133 147
148 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Map Scale");
149 $table->add (1, $row++, new CFClient::UI::Slider
150 range => [$CFG->{map_scale}, 0.25, 2, 0.05],
151 tooltip => "Enlarge or shrink the displayed map",
152 connect_changed => sub {
153 my ($self, $value) = @_;
154 $CFG->{map_scale} = 0.05 * int $value / 0.05;
155 }
156 );
157
134 $table->add (0, 3, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War"); 158 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War");
135 $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub { 159 $table->add (1, $row++, new CFClient::UI::CheckBox
160 state => $CFG->{fow_enable},
161 tooltip => "Fog-of-War marks areas that cannot be seen by the player",
162 connect_changed => sub {
136 my ($self, $value) = @_; 163 my ($self, $value) = @_;
137 $CFG->{fow_enable} = $value; 164 $CFG->{fow_enable} = $value;
165 }
138 }); 166 );
139 167
140 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity"); 168 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity");
141 $table->add (1, 4, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub { 169 $table->add (1, $row++, new CFClient::UI::Slider
170 range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001],
171 tooltip => "The higher the intensity, the lighter the Fog-of-War color",
172 connect_changed => sub {
142 my ($self, $value) = @_; 173 my ($self, $value) = @_;
143 $CFG->{fow_intensity} = $value; 174 $CFG->{fow_intensity} = $value;
175 }
144 }); 176 );
145 177
146 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Smooth"); 178 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Smooth");
147 $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { 179 $table->add (1, $row++, new CFClient::UI::CheckBox
180 state => $CFG->{fow_smooth},
181 tooltip => "Smooth the Fog-of-War a bit to make it more realistic",
182 connect_changed => sub {
148 my ($self, $value) = @_; 183 my ($self, $value) = @_;
149 $CFG->{fow_smooth} = $value; 184 $CFG->{fow_smooth} = $value;
150 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; 185 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2;
186 }
151 }); 187 );
152 188
153 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); 189 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize");
154 $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{gui_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub { 190 $table->add (1, $row++, new CFClient::UI::Slider
191 range => [$CFG->{gui_fontsize}, 0.5, 2, 0.1],
192 tooltip => "The font size used by most GUI elements",
193 connect_changed => sub {
155 $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10; 194 $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10;
156# $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; 195# $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
196 }
157 }); 197 );
158 198
159 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize"); 199 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize");
160 $table->add (1, 7, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub { 200 $table->add (1, $row++, new CFClient::UI::Slider
201 range => [$CFG->{log_fontsize}, 0.5, 2, 0.1],
202 tooltip => "The font size used by the server log window only",
203 connect_changed => sub {
161 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10); 204 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10);
205 }
162 }); 206 );
163 207
164 $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 208 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize");
209
210 $table->add (1, $row++, new CFClient::UI::Slider
211 range => [$CFG->{stat_fontsize}, 0.5, 2, 0.1],
212 tooltip => "The font size used by the statistics window only",
213 connect_changed => sub {
214 $CFG->{stat_fontsize} = 0.1 * int $_[1] * 10;
215 &set_stats_window_fontsize;
216 }
217 );
218
219 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge size");
220 $table->add (1, $row++, new CFClient::UI::Slider
221 range => [$CFG->{gauge_size}, 0.2, 0.8, 0.02],
222 tooltip => "Adjust the size of the stats gauges at the bottom right",
223 connect_changed => sub {
224 $CFG->{gauge_size} = $_[1];
225 my $h = int $HEIGHT * $CFG->{gauge_size};
226 $GAUGES->{win}->set_size ($WIDTH, $h);
227 $GAUGES->{win}->move (0, $HEIGHT - $h);
228 }
229 );
230
231 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize");
232 $table->add (1, $row++, new CFClient::UI::Slider
233 range => [$CFG->{gauge_fontsize}, 0.5, 2.0, 0.1],
234 tooltip => "Adjusts the fontsize of the gauges at the bottom right",
235 connect_changed => sub {
236 $CFG->{gauge_fontsize} = 0.1 * int $_[1] * 10;
237 &set_gauge_window_fontsize;
238 }
239 );
240
241 $table->add (1, $row++, new CFClient::UI::Button
242 expand => 1, align => 0, text => "Apply",
243 tooltip => "Apply the video settings",
244 connect_activate => sub {
165 video_shutdown (); 245 video_shutdown ();
166 video_init (); 246 video_init ();
247 }
167 }); 248 );
168 249
169 $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable"); 250 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable");
170 $table->add (1, 9, new CFClient::UI::CheckBox state => $CFG->{audio_enable}, connect_changed => sub { 251 $table->add (1, $row++, new CFClient::UI::CheckBox
252 state => $CFG->{audio_enable},
253 tooltip => "If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.",
254 connect_changed => sub {
171 $CFG->{audio_enable} = $_[1]; 255 $CFG->{audio_enable} = $_[1];
256 }
172 }); 257 );
173# $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume"); 258# $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume");
174# $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], connect_changed => sub { 259# $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], connect_changed => sub {
175# $CFG->{effects_volume} = $_[1]; 260# $CFG->{effects_volume} = $_[1];
176# }); 261# });
177 $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music"); 262 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music");
178 $table->add (1, 10, my $hbox = new CFClient::UI::HBox); 263 $table->add (1, $row++, my $hbox = new CFClient::UI::HBox);
179 $hbox->add (new CFClient::UI::CheckBox expand => 1, state => $CFG->{bgm_enable}, connect_changed => sub { 264 $hbox->add (new CFClient::UI::CheckBox
265 expand => 1, state => $CFG->{bgm_enable},
266 tooltip => "Enable background music playing",
267 connect_changed => sub {
180 $CFG->{bgm_enable} = $_[1]; 268 $CFG->{bgm_enable} = $_[1];
269 }
181 }); 270 );
182 $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0.1], connect_changed => sub { 271 $hbox->add (new CFClient::UI::Slider
272 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0.1],
273 tooltip => "The volume of the background music",
274 connect_changed => sub {
183 $CFG->{bgm_volume} = $_[1]; 275 $CFG->{bgm_volume} = $_[1];
184 CFClient::MixMusic::volume $_[1] * 128; 276 CFClient::MixMusic::volume $_[1] * 128;
277 }
185 }); 278 );
186 279
187 $table->add (1, 11, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 280 $table->add (1, $row++, new CFClient::UI::Button
281 expand => 1, align => 0, text => "Apply",
282 tooltip => "Apply the audio settings",
283 connect_activate => sub {
188 audio_shutdown (); 284 audio_shutdown ();
189 audio_init (); 285 audio_init ();
286 }
190 }); 287 );
191 288
192 $dialog 289 $dialog
290}
291
292sub set_stats_window_fontsize {
293 for (values %{$STATWIDS}) {
294 $_->set_fontsize ($::CFG->{stat_fontsize});
295 }
296}
297
298sub set_gauge_window_fontsize {
299 for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) {
300 $_->set_fontsize ($::CFG->{gauge_fontsize});
301 }
302
303# local $GAUGES->{win}{parent};#d#
304# use PApp::Util; open D, ">:utf8", "d"; print D PApp::Util::dumpval $GAUGES->{win}; close D;
305}
306
307sub make_gauge_window {
308 my $gh = int ($HEIGHT * $CFG->{gauge_size});
309# my $gw = int ($WIDTH * $CFG->{gauge_w_size});
310
311 my $win = new CFClient::UI::Frame (
312 y => $HEIGHT - $gh, x => 0, user_w => $WIDTH, user_h => $gh
313 );
314 $win->add (my $hbox = new CFClient::UI::HBox
315 children => [
316 (new CFClient::UI::HBox expand => 1),
317 ($FLOORBOX = new CFClient::UI::VBox),
318 (my $vbox = new CFClient::UI::VBox),
319 ],
320 );
321
322 $vbox->add (new CFClient::UI::HBox
323 expand => 1,
324 children => [
325 (new CFClient::UI::Empty expand => 1),
326 (my $hb = new CFClient::UI::HBox),
327 ],
328 );
329
330 $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp',
331 tooltip => "Health points - depletes when you get wounded, refills when you heal or idle");
332 $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana',
333 tooltip => "Spell points - deplete when you cast wizard spells, refills when you idle");
334 $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace',
335 tooltip => "Grace points - deplete when you cast priest spells, refills when you pray");
336 $hb->add (my $fg = new CFClient::UI::Gauge type => 'food',
337 tooltip => "Food - depletes with time, faster when you heal or build mana, refills when you eat healthy food");
338
339 $vbox->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1,
340 tooltip => "Experience points and level - increases when you kill monsters or successfully use skills");
341 $vbox->add (my $rng = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1,
342 tooltip => "Ranged attack - how you attack when you press shift-cursor (spell, skill, weapon etc.)");
343
344 $GAUGES = {
345 exp => $exp, win => $win, range => $rng,
346 food => $fg, mana => $mg, hp => $hg, grace => $gg
347 };
348
349 &set_gauge_window_fontsize;
350
351 $win
193} 352}
194 353
195sub make_stats_window { 354sub make_stats_window {
196 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH * 2/5, y => 0, title => "Stats"); 355 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH * 2/5, y => 0, title => "Stats");
197 356
198 $tgw->add (my $vb = new CFClient::UI::VBox); 357 $tgw->add (my $vb = new CFClient::UI::VBox);
199 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:"); 358 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1);
200 $vb->add (my $lhb = new CFClient::UI::HBox);
201 $lhb->add ($STATWIDS->{exp} = new CFClient::UI::Label valign => 0, align => -1, text => "Exp:", expand => 1); 359 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1);
202 $lhb->add ($STATWIDS->{lvl} = new CFClient::UI::Label valign => 0, align => -1, text => "Level:", expand => 1);
203 360
204 $vb->add (my $hb = new CFClient::UI::HBox expand => 1); 361 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
205 $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp', expand => 1);
206 $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana', expand => 1);
207 $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace', expand => 1);
208 $hb->add (my $fg = new CFClient::UI::Gauge type => 'food', expand => 1);
209 $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg };
210 362
211 $hb->add (my $tbl = new CFClient::UI::Table expand => 1); 363 $hb->add (my $tbl = new CFClient::UI::Table expand => 1);
212 364
213 if (0) { # this code can vanish, just wanted to preserver it for a checkin 365 my $black = [0, 0, 0];
366
214 $tbl->add (0, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => -1, text => "S"); 367 $tbl->add (0, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
215 $tbl->add (0, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => -1, text => "D"); 368 $tbl->add (0, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
216 $tbl->add (0, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => -1, text => "Co"); 369 $tbl->add (0, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
217 $tbl->add (0, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => -1, text => "I"); 370 $tbl->add (0, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
218 $tbl->add (0, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => -1, text => "W"); 371 $tbl->add (0, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
219 $tbl->add (0, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => -1, text => "P"); 372 $tbl->add (0, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
220 $tbl->add (0, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => -1, text => "Ch"); 373 $tbl->add (0, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
221 374
375 $tbl->add (1, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Str");
376 $tbl->add (1, 1, $STATWIDS->{st_dex_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Dex");
377 $tbl->add (1, 2, $STATWIDS->{st_con_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Con");
378 $tbl->add (1, 3, $STATWIDS->{st_int_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Int");
222 $tbl->add (1, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => -1, text => "Wc"); 379 $tbl->add (1, 4, $STATWIDS->{st_wis_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Wis");
380 $tbl->add (1, 5, $STATWIDS->{st_pow_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Pow");
223 $tbl->add (1, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => -1, text => "Ac"); 381 $tbl->add (1, 6, $STATWIDS->{st_cha_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Cha");
382
383 $tbl->add (2, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => +1, template => "-120");
384 $tbl->add (2, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => +1, template => "-120");
224 $tbl->add (1, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => -1, text => "Dam"); 385 $tbl->add (2, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => +1, template => "120");
225 $tbl->add (1, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => -1, text => "Arm"); 386 $tbl->add (2, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => +1, template => "120");
226 $tbl->add (1, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => -1, text => "Sp");
227 $tbl->add (1, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => -1, text => "WSp");
228 } else {
229 $tbl->add (0, 0, new CFClient::UI::Label valign => 0, align => +1, text => "S");
230 $tbl->add (0, 1, new CFClient::UI::Label valign => 0, align => +1, text => "D");
231 $tbl->add (0, 2, new CFClient::UI::Label valign => 0, align => +1, text => "Co");
232 $tbl->add (0, 3, new CFClient::UI::Label valign => 0, align => +1, text => "I");
233 $tbl->add (0, 4, new CFClient::UI::Label valign => 0, align => +1, text => "W");
234 $tbl->add (0, 5, new CFClient::UI::Label valign => 0, align => +1, text => "P");
235 $tbl->add (0, 6, new CFClient::UI::Label valign => 0, align => +1, text => "Ch");
236
237 $tbl->add (1, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => -1, text => "");
238 $tbl->add (1, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => -1, text => "");
239 $tbl->add (1, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => -1, text => "");
240 $tbl->add (1, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => -1, text => "");
241 $tbl->add (1, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => -1, text => "");
242 $tbl->add (1, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => -1, text => "");
243 $tbl->add (1, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => -1, text => "");
244
245 $tbl->add (2, 0, new CFClient::UI::Label valign => 0, align => +1, text => "Wc");
246 $tbl->add (2, 1, new CFClient::UI::Label valign => 0, align => +1, text => "Ac");
247 $tbl->add (2, 2, new CFClient::UI::Label valign => 0, align => +1, text => "Dam");
248 $tbl->add (2, 3, new CFClient::UI::Label valign => 0, align => +1, text => "Arm");
249 $tbl->add (2, 4, new CFClient::UI::Label valign => 0, align => +1, text => "Sp");
250 $tbl->add (2, 5, new CFClient::UI::Label valign => 0, align => +1, text => "WSp");
251
252 $tbl->add (3, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => -1, text => "");
253 $tbl->add (3, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => -1, text => "");
254 $tbl->add (3, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => -1, text => "");
255 $tbl->add (3, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => -1, text => "");
256 $tbl->add (3, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => -1, text => ""); 387 $tbl->add (2, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => +1, template => "10.54");
257 $tbl->add (3, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => -1, text => ""); 388 $tbl->add (2, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => +1, template => "9");
258 }
259 389
390 $tbl->add (3, 0, $STATWIDS->{st_wc_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Wc");
391 $tbl->add (3, 1, $STATWIDS->{st_ac_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Ac");
392 $tbl->add (3, 2, $STATWIDS->{st_dam_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Dam");
393 $tbl->add (3, 3, $STATWIDS->{st_arm_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Arm");
394 $tbl->add (3, 4, $STATWIDS->{st_spd_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Sp");
395 $tbl->add (3, 5, $STATWIDS->{st_wspd_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "WSp");
396
260 $hb->add (my $tbl2 = new CFClient::UI::Table); 397 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1);
261 398
262 my $row = 0; 399 my $row = 0;
263 my $col = 0; 400 my $col = 0;
264 401
402 my %resist_names = (
403 slow => "Slow",
404 holyw => "Holy Word",
405 conf => "Confusion",
406 fire => "Fire",
407 depl => "Depletion",
408 magic => "Magic",
409 drain => "Draining",
410 acid => "Acid",
411 pois => "Poison",
412 para => "Paralysation",
413 deat => "Death",
414 phys => "Physical",
415 blind => "Blind",
416 fear => "Fear",
417 tund => "Turn undead",
418 elec => "Electricity",
419 cold => "Cold",
420 ghit => "Ghost hit",
421 );
265 for (qw/slow holyw conf fire depl magic 422 for (qw/slow holyw conf fire depl magic
266 drain acid pois para deat phys 423 drain acid pois para deat phys
267 blind fear tund elec cold ghit/) 424 blind fear tund elec cold ghit/)
268 { 425 {
269 $tbl2->add ($col, $row, new CFClient::UI::Image image => "ui/resist/resist_$_.png");
270 $tbl2->add ($col + 1, $row, 426 $tbl2->add ($col, $row,
271 $STATWIDS->{"res_$_"} = 427 $STATWIDS->{"res_$_"} =
272 new CFClient::UI::Label text => "0", align => -1, valign => 0 428 new CFClient::UI::Label
429 template => "-100%",
430 align => +1,
431 valign => 0,
432 tooltip => $resist_names{$_}
433 );
434 $tbl2->add ($col + 1, $row, new CFClient::UI::Image
435 can_hover => 1,
436 can_events => 1,
437 image => "ui/resist/resist_$_.png",
438 tooltip => $resist_names{$_}
273 ); 439 );
274 440
275 $row++; 441 $row++;
276 if ($row % 6 == 0) { 442 if ($row % 6 == 0) {
277 $col += 2; 443 $col += 2;
278 $row = 0; 444 $row = 0;
279 } 445 }
280 } 446 }
281 447
448 &set_stats_window_fontsize;
282 update_stats_window ({}); 449 update_stats_window ({});
283 450
284 $tgw 451 $tgw
452}
453
454sub formsep {
455 reverse join ",", grep length, split /(...)/, reverse $_[0] * 1
285} 456}
286 457
287sub update_stats_window { 458sub update_stats_window {
288 my ($stats) = @_; 459 my ($stats) = @_;
289 460
290 # i love text protocols!!! 461 # i love text protocols!!!
291 my $hp = $stats->{1}; 462 my $hp = $stats->{Crossfire::Protocol::CS_STAT_HP} * 1;
292 my $hp_m = $stats->{2}; 463 my $hp_m = $stats->{Crossfire::Protocol::CS_STAT_MAXHP} * 1;
293 my $sp = $stats->{3}; 464 my $sp = $stats->{Crossfire::Protocol::CS_STAT_SP} * 1;
294 my $sp_m = $stats->{4}; 465 my $sp_m = $stats->{Crossfire::Protocol::CS_STAT_MAXSP} * 1;
295 my $fo = $stats->{18}; 466 my $fo = $stats->{Crossfire::Protocol::CS_STAT_FOOD} * 1;
296 my $fo_m = 999; 467 my $fo_m = 999;
297 my $gr = $stats->{23}; 468 my $gr = $stats->{Crossfire::Protocol::CS_STAT_GRACE} * 1;
298 my $gr_m = $stats->{24}; 469 my $gr_m = $stats->{Crossfire::Protocol::CS_STAT_MAXGRACE} * 1;
299 470
300 $GAUGES->{hp} ->set_value ($hp, $hp_m); 471 $GAUGES->{hp} ->set_value ($hp, $hp_m);
301 $GAUGES->{mana} ->set_value ($sp, $sp_m); 472 $GAUGES->{mana} ->set_value ($sp, $sp_m);
302 $GAUGES->{food} ->set_value ($fo, $fo_m); 473 $GAUGES->{food} ->set_value ($fo, $fo_m);
303 $GAUGES->{grace} ->set_value ($gr, $gr_m); 474 $GAUGES->{grace} ->set_value ($gr, $gr_m);
475 $GAUGES->{exp} ->set_text ("Exp: " . (formsep $stats->{Crossfire::Protocol::CS_STAT_EXP64})
476 . " (lvl " . ($stats->{Crossfire::Protocol::CS_STAT_LEVEL} * 1) . ")");
477 my $rng = $stats->{Crossfire::Protocol::CS_STAT_RANGE};
478 $rng =~ s/^Range: //; # thank you so much dear server
479 $GAUGES->{range} ->set_text ("Rng: " . $rng);
480 my $title = $stats->{Crossfire::Protocol::CS_STAT_TITLE};
481 $title =~ s/^Player: //;
304 $STATWIDS->{title} ->set_text ("Title: " . $stats->{21}); 482 $STATWIDS->{title} ->set_text ("Title: " . $title);
305 $STATWIDS->{exp} ->set_text ("Exp.: " . ($stats->{11} || $stats->{28}));
306 $STATWIDS->{lvl} ->set_text ("Level: " . $stats->{12});
307 483
308 if (0) { # this code can vanish, just wanted to preserver it for a checkin
309 $STATWIDS->{st_str} ->set_text (sprintf "S%d", $stats->{5});
310 $STATWIDS->{st_dex} ->set_text (sprintf "D%d", $stats->{8});
311 $STATWIDS->{st_con} ->set_text (sprintf "Co%d", $stats->{9});
312 $STATWIDS->{st_int} ->set_text (sprintf "I%d", $stats->{6});
313 $STATWIDS->{st_wis} ->set_text (sprintf "W%d", $stats->{7});
314 $STATWIDS->{st_pow} ->set_text (sprintf "P%d", $stats->{22});
315 $STATWIDS->{st_cha} ->set_text (sprintf "Ch%d", $stats->{10});
316 $STATWIDS->{st_wc} ->set_text (sprintf "Wc%d", $stats->{13});
317 $STATWIDS->{st_ac} ->set_text (sprintf "Ac%d", $stats->{14});
318 $STATWIDS->{st_dam} ->set_text (sprintf "Dam%d", $stats->{15});
319 $STATWIDS->{st_arm} ->set_text (sprintf "Arm%d", $stats->{16});
320 $STATWIDS->{st_spd} ->set_text (sprintf "Sp%.1f", $stats->{17});
321 $STATWIDS->{st_wspd}->set_text (sprintf "WSp%.1f", $stats->{19});
322 } else {
323 $STATWIDS->{st_str} ->set_text (sprintf "%d", $stats->{5}); 484 $STATWIDS->{st_str} ->set_text (sprintf "%d", $stats->{5});
324 $STATWIDS->{st_dex} ->set_text (sprintf "%d", $stats->{8}); 485 $STATWIDS->{st_dex} ->set_text (sprintf "%d", $stats->{8});
325 $STATWIDS->{st_con} ->set_text (sprintf "%d", $stats->{9}); 486 $STATWIDS->{st_con} ->set_text (sprintf "%d", $stats->{9});
326 $STATWIDS->{st_int} ->set_text (sprintf "%d", $stats->{6}); 487 $STATWIDS->{st_int} ->set_text (sprintf "%d", $stats->{6});
327 $STATWIDS->{st_wis} ->set_text (sprintf "%d", $stats->{7}); 488 $STATWIDS->{st_wis} ->set_text (sprintf "%d", $stats->{7});
328 $STATWIDS->{st_pow} ->set_text (sprintf "%d", $stats->{22}); 489 $STATWIDS->{st_pow} ->set_text (sprintf "%d", $stats->{22});
329 $STATWIDS->{st_cha} ->set_text (sprintf "%d", $stats->{10}); 490 $STATWIDS->{st_cha} ->set_text (sprintf "%d", $stats->{10});
330 $STATWIDS->{st_wc} ->set_text (sprintf "%d", $stats->{13}); 491 $STATWIDS->{st_wc} ->set_text (sprintf "%d", $stats->{13});
331 $STATWIDS->{st_ac} ->set_text (sprintf "%d", $stats->{14}); 492 $STATWIDS->{st_ac} ->set_text (sprintf "%d", $stats->{14});
332 $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15}); 493 $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15});
333 $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16}); 494 $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16});
334 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{17}); 495 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::CS_STAT_SPEED});
335 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{19}); 496 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::CS_STAT_WEAP_SP});
336 }
337 497
338 my %tbl = ( 498 my %tbl = (
339 phys => 100, 499 phys => 100,
340 magic => 101, 500 magic => 101,
341 fire => 102, 501 fire => 102,
348 pois => 109, 508 pois => 109,
349 slow => 110, 509 slow => 110,
350 para => 111, 510 para => 111,
351 tund => 112, 511 tund => 112,
352 fear => 113, 512 fear => 113,
513 depl => 113,
353 deat => 115, 514 deat => 115,
354 holyw => 116, 515 holyw => 116,
355 blind => 117 516 blind => 117
356 ); 517 );
357 518
446 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); 607 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port");
447 608
448 { 609 {
449 $table->add (1, 2, my $vbox = new CFClient::UI::VBox); 610 $table->add (1, 2, my $vbox = new CFClient::UI::VBox);
450 611
451 $vbox->add (my $HOST = new CFClient::UI::Entry expand => 1, text => $CFG->{host}, connect_changed => sub { 612 $vbox->add (
613 my $HOST = new CFClient::UI::Entry
614 expand => 1,
615 text => $CFG->{host},
616 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to",
617 connect_changed => sub {
618 my ($self, $value) = @_;
619 $CFG->{host} = $value;
620 }
621 );
622
623 $METASERVER = metaserver_dialog;
624
625 $vbox->add (new CFClient::UI::Flopper
626 expand => 1,
627 text => "Metaserver",
628 other => $METASERVER,
629 tooltip => "Show a list of avaible crossfire servers",
630 connect_open => sub {
631 update_metaserver $HOST;
632 }
633 );
634 }
635
636 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
637 $table->add (1, 4, new CFClient::UI::Entry
638 text => $CFG->{user},
639 tooltip => "The name of your character on the server",
640 connect_changed => sub {
452 my ($self, $value) = @_; 641 my ($self, $value) = @_;
453 $CFG->{host} = $value;
454 });
455
456 $METASERVER = metaserver_dialog;
457
458 $vbox->add (new CFClient::UI::Flopper expand => 1, text => "Metaserver", other => $METASERVER, connect_open => sub {
459 update_metaserver $HOST;
460 });
461 }
462
463 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
464 $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub {
465 my ($self, $value) = @_;
466 $CFG->{user} = $value; 642 $CFG->{user} = $value;
643 }
467 }); 644 );
468 645
469 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password"); 646 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password");
470 $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { 647 $table->add (1, 5, new CFClient::UI::Entry
648 text => $CFG->{password},
649 hidden => 1,
650 tooltip => "The password for your character",
651 connect_changed => sub {
471 my ($self, $value) = @_; 652 my ($self, $value) = @_;
472 $CFG->{password} = $value; 653 $CFG->{password} = $value;
654 }
473 }); 655 );
474 656
475 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); 657 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd");
476 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { 658 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry
659 text => $CFG->{say_command},
660 tooltip => "This is the command that will be used if you write a line in the message window entry. "
661 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
662 ."But you could also set it to 'tell &lt;playername&gt;' to only chat with that user.",
663 connect_changed => sub {
477 my ($self, $value) = @_; 664 my ($self, $value) = @_;
478 $CFG->{say_command} = $value; 665 $CFG->{say_command} = $value;
666 }
479 }); 667 );
480 668
481 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); 669 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
482 $table->add (1, 7, new CFClient::UI::Slider 670 $table->add (1, 7, new CFClient::UI::Slider
483 req_w => 100, 671 req_w => 100,
484 range => [$CFG->{mapsize}, 10, 100 + 1, 1], 672 range => [$CFG->{mapsize}, 10, 100 + 1, 1],
673 tooltip => "This is the size of the portion of the map update the server sends you. "
674 ."If you set this to a high value you will be able to see further for example.",
485 connect_changed => sub { 675 connect_changed => sub {
486 my ($self, $value) = @_; 676 my ($self, $value) = @_;
487 677
488 $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 678 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
489 }, 679 },
505 user_h => int $::HEIGHT / 5, 695 user_h => int $::HEIGHT / 5,
506 child => (my $vbox = new CFClient::UI::VBox); 696 child => (my $vbox = new CFClient::UI::VBox);
507 697
508 $vbox->add ($LOGVIEW = new CFClient::UI::TextView 698 $vbox->add ($LOGVIEW = new CFClient::UI::TextView
509 expand => 1, 699 expand => 1,
700 font => $FONT_FIXED,
510 fontsize => $::CFG->{log_fontsize}, 701 fontsize => $::CFG->{log_fontsize},
511 ); 702 );
512 703
513 $vbox->add (my $input = new CFClient::UI::Entry 704 $vbox->add (my $input = new CFClient::UI::Entry
514 connect_focus_in => sub { 705 connect_focus_in => sub {
608 799
609 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); 800 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup);
610 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); 801 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup);
611 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); 802 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window);
612 803
804 $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
805 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window);
806
613 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { 807 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub {
614 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 808 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
615 status "Configuration Saved"; 809 status "Configuration Saved";
616 }); 810 });
617 811
618 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup 812 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
619
620
621 $CFClient::UI::ROOT->add (make_stats_window);
622} 813}
623 814
624sub video_shutdown { 815sub video_shutdown {
625 $CFClient::UI::ROOT->{children} = []; 816 $CFClient::UI::ROOT->{children} = [];
626 undef $SDL_ACTIVE; 817 undef $SDL_ACTIVE;
872 1063
873 $x += $ox; 1064 $x += $ox;
874 $y += $oy; 1065 $y += $oy;
875 1066
876 $self->{map_info} = [$hash, $x, $y, $w, $h]; 1067 $self->{map_info} = [$hash, $x, $y, $w, $h];
1068
1069 my $map = $self->{map_info}[0];
1070 $map =~ s/^.*?\/([^\/]+)$/\1/;
1071 $STATWIDS->{map}->set_text ("Map: " . $map);
877 1072
878 $self->load_map ($hash, $x, $y); 1073 $self->load_map ($hash, $x, $y);
879} 1074}
880 1075
881sub conn::face_find { 1076sub conn::face_find {
907 } 1102 }
908 1103
909gotid: 1104gotid:
910 $face->{id} = $id; 1105 $face->{id} = $id;
911 $MAP->set_face ($facenum => $id); 1106 $MAP->set_face ($facenum => $id);
1107 $self->{faceid}[$facenum] = $id;#d#
912 $TILECACHE->get ($id) 1108 $TILECACHE->get ($id)
913} 1109}
914 1110
915sub conn::face_update { 1111sub conn::face_update {
916 my ($self, $facenum, $face) = @_; 1112 my ($self, $facenum, $face) = @_;
924 my ($self, $id, $data) = @_; 1120 my ($self, $id, $data) = @_;
925 1121
926 $self->{texture}[$id] ||= do { 1122 $self->{texture}[$id] ||= do {
927 my $tex = 1123 my $tex =
928 new_from_image CFClient::Texture 1124 new_from_image CFClient::Texture
929 $data, minify => 1; 1125 $data, minify => 1, mipmap => 1;
930 1126
931 $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 1127 $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}});
932 $MAPWIDGET->update; 1128 $MAPWIDGET->update;
933 1129
934 $tex 1130 $tex
946 1142
947 $chunk->play; 1143 $chunk->play;
948# warn "sound $x,$y,$soundnum,$type\n";#d# 1144# warn "sound $x,$y,$soundnum,$type\n";#d#
949} 1145}
950 1146
1147my $LAST_QUERY; # server is stupid, stupid, stupid
1148
951sub conn::query { 1149sub conn::query {
952 my ($self, $flags, $prompt) = @_; 1150 my ($self, $flags, $prompt) = @_;
953 1151
954 #TODO, display dialog with relevant information 1152 $prompt = $LAST_QUERY unless length $prompt;
955 warn "<<<<QUERY:$flags:$prompt>>>\n";#d# 1153 $LAST_QUERY = $prompt;
1154
1155 my $dialog = new CFClient::UI::FancyFrame
1156 title => "Query",
1157 child => my $vbox = new CFClient::UI::VBox;
1158
1159 $vbox->add (new CFClient::UI::Label
1160 max_w => $::WIDTH * 0.4,
1161 text => $prompt);
1162
1163 if ($flags & Crossfire::Protocol::CS_QUERY_YESNO) {
1164 $vbox->add (my $hbox = new CFClient::HBox);
1165 $hbox->add (new CFClient::Button
1166 text => "No",
1167 connect_activate => sub {
1168 $self->send ("reply n");
1169 $dialog->destroy;
1170 $MAPWIDGET->focus_in;
1171 }
1172 );
1173 $hbox->add (new CFClient::Button
1174 text => "Yes",
1175 connect_activate => sub {
1176 $self->send ("reply y");
1177 $dialog->destroy;
1178 $MAPWIDGET->focus_in;
1179 },
1180 );
1181
1182 $dialog->focus_in;
1183
1184 } elsif ($flags & Crossfire::Protocol::CS_QUERY_SINGLECHAR) {
1185 $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)";
1186 $vbox->add (my $entry = new CFClient::UI::Entry
1187 connect_changed => sub {
1188 $self->send ("reply $_[1]");
1189 $dialog->destroy;
1190 $MAPWIDGET->focus_in;
1191 },
1192 );
1193
1194 $entry->focus_in;
1195
1196 } else {
1197 $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)";
1198
1199 $vbox->add (my $entry = new CFClient::UI::Entry
1200 $flags & Crossfire::Protocol::CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (),
1201 connect_activate => sub {
1202 $self->send ("reply $_[1]");
1203 $dialog->destroy;
1204 $MAPWIDGET->focus_in;
1205 },
1206 );
1207
1208 $entry->focus_in;
1209 }
1210
1211 $dialog->show;
956} 1212}
957 1213
958sub conn::drawinfo { 1214sub conn::drawinfo {
959 my ($self, $color, $text) = @_; 1215 my ($self, $color, $text) = @_;
960 1216
978} 1234}
979 1235
980sub conn::spell_add { 1236sub conn::spell_add {
981 my ($self, $spell) = @_; 1237 my ($self, $spell) = @_;
982 1238
1239 # TODO
1240 # create a widget dynamically, using spell face (CF::Protocol downloads them)
983 $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}, sub { 1241 $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message});
984 });
985 $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}, sub { 1242 $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message});
986 });
987} 1243}
988 1244
989sub conn::spell_delete { 1245sub conn::spell_delete {
990 my ($self, $spell) = @_; 1246 my ($self, $spell) = @_;
991} 1247}
992 1248
993sub conn::addme_success { 1249sub conn::addme_success {
994 my ($self) = @_; 1250 my ($self) = @_;
995 1251
996 for my $skill (values %{$self->{skill_info}}) { 1252 for my $skill (values %{$self->{skill_info}}) {
997 $MAPWIDGET->add_command ("ready_skill $skill", "", sub { 1253 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'");
998 }); 1254 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'");
999 $MAPWIDGET->add_command ("use_skill $skill", "", sub {
1000 });
1001 } 1255 }
1256}
1257
1258sub update_floorbox {
1259 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub {
1260 $FLOORBOX->clear;
1261 $FLOORBOX->add (new CFClient::UI::Empty expand => 1);
1262
1263 my @items = values %{ $CONN->{container}{0} };
1264
1265 # we basically have to use the same sorting as everybody else
1266 @items = sort { $a->{type} <=> $b->{type} } @items;
1267
1268 for my $item (reverse @items) {
1269 my $desc = $item->{nrof} < 2
1270 ? $item->{name}
1271 : "$item->{nrof} $item->{name_pl}";
1272 # todo: animation widget, face widget, weight(?) etc.
1273 $FLOORBOX->add (my $hbox = new CFClient::UI::HBox
1274 tooltip => (CFClient::UI::Label->escape ($desc)
1275 . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"),
1276 can_hover => 1,
1277 can_events => 1,
1278 connect_button_down => sub {
1279 my ($self, $ev, $x, $y) = @_;
1280
1281 # todo: maybe put examine on 1? but should just be a tooltip :(
1282 if ($ev->{button} == 1) {
1283 $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0");
1284 } elsif ($ev->{button} == 2) {
1285 $CONN->send ("apply $item->{tag}");
1286 } elsif ($ev->{button} == 3) {
1287 # examine, lock, mark, maybe other things
1288 warn "MENU not implemented yet\n";
1289 }
1290
1291 1
1292 },
1293 );
1294
1295 $hbox->add (new CFClient::UI::Face
1296 face => $item->{face},
1297 anim => $item->{anim},
1298 animspeed => $item->{animspeed},
1299 );
1300
1301 $hbox->add (new CFClient::UI::Label
1302 text => $desc,
1303 );
1304 }
1305 });
1306 refresh;
1307}
1308
1309sub conn::container_add {
1310 my ($self, $id, $items) = @_;
1311
1312 update_floorbox if $id == 0;
1313 # $self-<{player}{tag} => player inv
1314 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}};
1315}
1316
1317sub conn::container_clear {
1318 my ($self, $id) = @_;
1319
1320 update_floorbox if $id == 0;
1321# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
1322}
1323
1324sub conn::item_delete {
1325 my ($self, @items) = @_;
1326
1327 for (@items) {
1328 update_floorbox if $_->{container} == 0;
1329 }
1330}
1331
1332sub conn::item_update {
1333 my ($self, $item) = @_;
1334
1335 update_floorbox if $item->{container} == 0;
1002} 1336}
1003 1337
1004%SDL_CB = ( 1338%SDL_CB = (
1005 CFClient::SDL_QUIT => sub { 1339 CFClient::SDL_QUIT => sub {
1006 Event::unloop -1; 1340 Event::unloop -1;
1041 sdl_mode => 0, 1375 sdl_mode => 0,
1042 width => 640, 1376 width => 640,
1043 height => 480, 1377 height => 480,
1044 fullscreen => 0, 1378 fullscreen => 0,
1045 fast => 0, 1379 fast => 0,
1380 map_scale => 0.5,
1046 fow_enable => 1, 1381 fow_enable => 1,
1047 fow_intensity => 0.45, 1382 fow_intensity => 0.45,
1048 fow_smooth => 0, 1383 fow_smooth => 0,
1049 gui_fontsize => 1, 1384 gui_fontsize => 1,
1050 log_fontsize => 14, 1385 log_fontsize => 1,
1386 gauge_fontsize => 1,
1387 gauge_size => 0.35,
1388 stat_fontsize => 1,
1051 mapsize => 100, 1389 mapsize => 100,
1052 host => "crossfire.schmorp.de", 1390 host => "crossfire.schmorp.de",
1053 say_command => 'say', 1391 say_command => 'say',
1054 audio_enable => 1, 1392 audio_enable => 1,
1055 bgm_enable => 1, 1393 bgm_enable => 1,
1069@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; 1407@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
1070 1408
1071$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; 1409$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
1072 1410
1073{ 1411{
1074 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); 1412 my @fonts = map CFClient::find_rcfile "fonts/$_", qw(
1413 DejaVuSans.ttf
1414 DejaVuSansMono.ttf
1415 DejaVuSans-Bold.ttf
1416 DejaVuSansMono-Bold.ttf
1417 DejaVuSans-Oblique.ttf
1418 DejaVuSansMono-Oblique.ttf
1419 DejaVuSans-BoldOblique.ttf
1420 DejaVuSansMono-BoldOblique.ttf
1421 );
1075 1422
1076 CFClient::add_font $_ for @fonts; 1423 CFClient::add_font $_ for @fonts;
1077 CFClient::set_font $fonts[0]; 1424
1425 $FONT_PROP = new_from_file CFClient::Font $fonts[0];
1426 $FONT_FIXED = new_from_file CFClient::Font $fonts[1];
1427
1428 $FONT_PROP->make_default;
1078} 1429}
1079 1430
1080video_init; 1431video_init;
1081audio_init; 1432audio_init;
1082 1433

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines