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.173 by root, Mon Apr 24 06:05:36 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;
120 $mode_slider->emit (changed => $mode_slider->{range}[0]); 124 $mode_slider->emit (changed => $mode_slider->{range}[0]);
121 125
122 my $row = 1; 126 my $row = 1;
123 127
124 $table->add (0, $row, 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");
125 $table->add (1, $row++, 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 {
126 my ($self, $value) = @_; 133 my ($self, $value) = @_;
127 $CFG->{fullscreen} = $value; 134 $CFG->{fullscreen} = $value;
135 }
128 }); 136 );
129 137
130 $table->add (0, $row, 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");
131 $table->add (1, $row++, 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 {
132 my ($self, $value) = @_; 143 my ($self, $value) = @_;
133 $CFG->{fast} = $value; 144 $CFG->{fast} = $value;
145 }
134 }); 146 );
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 );
135 157
136 $table->add (0, $row, 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");
137 $table->add (1, $row++, 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 {
138 my ($self, $value) = @_; 163 my ($self, $value) = @_;
139 $CFG->{fow_enable} = $value; 164 $CFG->{fow_enable} = $value;
165 }
140 }); 166 );
141 167
142 $table->add (0, $row, 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");
143 $table->add (1, $row++, 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 {
144 my ($self, $value) = @_; 173 my ($self, $value) = @_;
145 $CFG->{fow_intensity} = $value; 174 $CFG->{fow_intensity} = $value;
175 }
146 }); 176 );
147 177
148 $table->add (0, $row, 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");
149 $table->add (1, $row++, 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 {
150 my ($self, $value) = @_; 183 my ($self, $value) = @_;
151 $CFG->{fow_smooth} = $value; 184 $CFG->{fow_smooth} = $value;
152 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 }
153 }); 187 );
154 188
155 $table->add (0, $row, 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");
156 $table->add (1, $row++, 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 {
157 $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10; 194 $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10;
158# $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; 195# $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
196 }
159 }); 197 );
160 198
161 $table->add (0, $row, 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");
162 $table->add (1, $row++, 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 {
163 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10); 204 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10);
205 }
164 }); 206 );
165 207
166 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize"); 208 $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 { 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 {
168 $CFG->{stat_fontsize} = 0.1 * int $_[1] * 10; 214 $CFG->{stat_fontsize} = 0.1 * int $_[1] * 10;
169 &set_stats_window_fontsize; 215 &set_stats_window_fontsize;
216 }
170 }); 217 );
171 218
172 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge height"); 219 $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 { 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 {
174 $CFG->{gauge_size} = $_[1]; 224 $CFG->{gauge_size} = $_[1];
175 my $h = int ($HEIGHT * $CFG->{gauge_size}); 225 my $h = int $HEIGHT * $CFG->{gauge_size};
176 $GAUGES->{win}->set_size ($WIDTH, $h); 226 $GAUGES->{win}->set_size ($WIDTH, $h);
177 $GAUGES->{win}->{y} = $HEIGHT - $h; 227 $GAUGES->{win}->move (0, $HEIGHT - $h);
178 $GAUGES->{win}->{x} = 0; 228 }
179 $GAUGES->{win}->update;
180 }); 229 );
181
182 230
183 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); 231 $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 { 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 {
185 $CFG->{gauge_fontsize} = 0.1 * int $_[1] * 10; 236 $CFG->{gauge_fontsize} = 0.1 * int $_[1] * 10;
186 &set_gauge_window_fontsize; 237 &set_gauge_window_fontsize;
187 $GAUGES->{win}->check_size; 238 }
188 $GAUGES->{win}->update;
189 }); 239 );
190 240
191 241 $table->add (1, $row++, new CFClient::UI::Button
192 242 expand => 1, align => 0, text => "Apply",
193 $table->add (1, $row++, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 243 tooltip => "Apply the video settings",
244 connect_activate => sub {
194 video_shutdown (); 245 video_shutdown ();
195 video_init (); 246 video_init ();
247 }
196 }); 248 );
197 249
198 $table->add (0, $row, 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");
199 $table->add (1, $row++, 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 {
200 $CFG->{audio_enable} = $_[1]; 255 $CFG->{audio_enable} = $_[1];
256 }
201 }); 257 );
202# $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");
203# $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 {
204# $CFG->{effects_volume} = $_[1]; 260# $CFG->{effects_volume} = $_[1];
205# }); 261# });
206 $table->add (0, $row, 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");
207 $table->add (1, $row++, my $hbox = new CFClient::UI::HBox); 263 $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 { 264 $hbox->add (new CFClient::UI::CheckBox
265 expand => 1, state => $CFG->{bgm_enable},
266 tooltip => "Enable background music playing",
267 connect_changed => sub {
209 $CFG->{bgm_enable} = $_[1]; 268 $CFG->{bgm_enable} = $_[1];
269 }
210 }); 270 );
211 $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 {
212 $CFG->{bgm_volume} = $_[1]; 275 $CFG->{bgm_volume} = $_[1];
213 CFClient::MixMusic::volume $_[1] * 128; 276 CFClient::MixMusic::volume $_[1] * 128;
277 }
214 }); 278 );
215 279
216 $table->add (1, $row++, 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 {
217 audio_shutdown (); 284 audio_shutdown ();
218 audio_init (); 285 audio_init ();
286 }
219 }); 287 );
220 288
221 $dialog 289 $dialog
222} 290}
223 291
224sub set_stats_window_fontsize { 292sub set_stats_window_fontsize {
229 297
230sub set_gauge_window_fontsize { 298sub set_gauge_window_fontsize {
231 for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) { 299 for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) {
232 $_->set_fontsize ($::CFG->{gauge_fontsize}); 300 $_->set_fontsize ($::CFG->{gauge_fontsize});
233 } 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;
234} 305}
235 306
236sub make_gauge_window { 307sub make_gauge_window {
237 my $gh = int ($HEIGHT * $CFG->{gauge_size}); 308 my $gh = int ($HEIGHT * $CFG->{gauge_size});
238# my $gw = int ($WIDTH * $CFG->{gauge_w_size}); 309# my $gw = int ($WIDTH * $CFG->{gauge_w_size});
239 310
240 my $win = new CFClient::UI::Frame ( 311 my $win = new CFClient::UI::Frame (
241 y => $HEIGHT - $gh, x => 0, req_w => $WIDTH, req_h => $gh 312 y => $HEIGHT - $gh, x => 0, user_w => $WIDTH, user_h => $gh
242 ); 313 );
243 $win->add (my $vb = new CFClient::UI::VBox); 314 $win->add (my $hbox = new CFClient::UI::HBox
244 315 children => [
245 $vb->add (my $hbg = new CFClient::UI::HBox expand => 1); 316 (new CFClient::UI::HBox expand => 1),
317 ($FLOORBOX = new CFClient::UI::VBox),
318 (my $vbox = new CFClient::UI::VBox),
319 ],
320 );
246 321
247 322 $vbox->add (new CFClient::UI::HBox
323 expand => 1,
324 children => [
248 $hbg->add (new CFClient::UI::Empty expand => 1); 325 (new CFClient::UI::Empty expand => 1),
249 $hbg->add (my $hb = new CFClient::UI::HBox); 326 (my $hb = new CFClient::UI::HBox),
327 ],
328 );
329
250 $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp'); 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");
251 $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana'); 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");
252 $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace'); 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");
253 $hb->add (my $fg = new CFClient::UI::Gauge type => 'food'); 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");
254 338
255 $vb->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, text => "XP:"); 339 $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:"); 340 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:"); 341 $vbox->add (my $rng = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1,
258 342 tooltip => "Ranged attack - how you attack when you press shift-cursor (spell, skill, weapon etc.)");
259 343
260 $GAUGES = { 344 $GAUGES = {
261 exp => $exp,# lvl => $lvl,
262 win => $win, range => $rng, 345 exp => $exp, win => $win, range => $rng,
263 food => $fg, mana => $mg, hp => $hg, grace => $gg 346 food => $fg, mana => $mg, hp => $hg, grace => $gg
264 }; 347 };
348
349 &set_gauge_window_fontsize;
350
265 $win 351 $win
266} 352}
267 353
268sub make_stats_window { 354sub make_stats_window {
269 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");
270 356
271 $tgw->add (my $vb = new CFClient::UI::VBox); 357 $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); 358 $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); 359 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1);
275 360
276 $vb->add (my $hb = new CFClient::UI::HBox expand => 1); 361 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
277 362
278 $hb->add (my $tbl = new CFClient::UI::Table expand => 1); 363 $hb->add (my $tbl = new CFClient::UI::Table expand => 1);
279 364
365 $tbl->add (0, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
366 $tbl->add (0, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
367 $tbl->add (0, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
368 $tbl->add (0, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
369 $tbl->add (0, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
370 $tbl->add (0, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
371 $tbl->add (0, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
372
280 $tbl->add (0, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Str"); 373 $tbl->add (1, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Str");
281 $tbl->add (0, 1, $STATWIDS->{st_dex_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Dex"); 374 $tbl->add (1, 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"); 375 $tbl->add (1, 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"); 376 $tbl->add (1, 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"); 377 $tbl->add (1, 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"); 378 $tbl->add (1, 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"); 379 $tbl->add (1, 6, $STATWIDS->{st_cha_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Cha");
287 380
288 $tbl->add (1, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => +1, text => ""); 381 $tbl->add (2, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => +1, template => "-120");
382 $tbl->add (2, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => +1, template => "-120");
289 $tbl->add (1, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => +1, text => ""); 383 $tbl->add (2, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => +1, template => "120");
290 $tbl->add (1, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => +1, text => "");
291 $tbl->add (1, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => +1, text => ""); 384 $tbl->add (2, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => +1, template => "120");
385 $tbl->add (2, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => +1, template => "10.54");
292 $tbl->add (1, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => +1, text => ""); 386 $tbl->add (2, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => +1, template => "9");
293 $tbl->add (1, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => +1, text => "");
294 $tbl->add (1, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => +1, text => "");
295 387
296 $tbl->add (2, 0, $STATWIDS->{st_wc_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Wc"); 388 $tbl->add (3, 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"); 389 $tbl->add (3, 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"); 390 $tbl->add (3, 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"); 391 $tbl->add (3, 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"); 392 $tbl->add (3, 4, $STATWIDS->{st_spd_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Sp");
301 $tbl->add (2, 5, $STATWIDS->{st_wspd_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "WSp"); 393 $tbl->add (3, 5, $STATWIDS->{st_wspd_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "WSp");
302
303 $tbl->add (3, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => +1, text => "");
304 $tbl->add (3, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => +1, text => "");
305 $tbl->add (3, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => +1, text => "");
306 $tbl->add (3, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => +1, text => "");
307 $tbl->add (3, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => +1, text => "");
308 $tbl->add (3, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => +1, text => "");
309 394
310 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); 395 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1);
311 396
312 my $row = 0; 397 my $row = 0;
313 my $col = 0; 398 my $col = 0;
314 399
400 my %resist_names = (
401 slow => "Slow",
402 holyw => "Holy Word",
403 conf => "Confusion",
404 fire => "Fire",
405 depl => "Depletion",
406 magic => "Magic",
407 drain => "Draining",
408 acid => "Acid",
409 pois => "Poison",
410 para => "Paralysation",
411 deat => "Death",
412 phys => "Physical",
413 blind => "Blind",
414 fear => "Fear",
415 tund => "Turn undead",
416 elec => "Electricity",
417 cold => "Cold",
418 ghit => "Ghost hit",
419 );
315 for (qw/slow holyw conf fire depl magic 420 for (qw/slow holyw conf fire depl magic
316 drain acid pois para deat phys 421 drain acid pois para deat phys
317 blind fear tund elec cold ghit/) 422 blind fear tund elec cold ghit/)
318 { 423 {
319 $tbl2->add ($col , $row, 424 $tbl2->add ($col, $row,
320 $STATWIDS->{"res_$_"} = 425 $STATWIDS->{"res_$_"} =
321 new CFClient::UI::Label text => "0", align => +1, valign => 0 426 new CFClient::UI::Label
427 template => "-100%",
428 align => +1,
429 valign => 0,
430 tooltip => $resist_names{$_}
322 ); 431 );
323 $tbl2->add ($col + 1, $row, new CFClient::UI::Image image => "ui/resist/resist_$_.png"); 432 $tbl2->add ($col + 1, $row, new CFClient::UI::Image
433 can_hover => 1,
434 can_events => 1,
435 image => "ui/resist/resist_$_.png",
436 tooltip => $resist_names{$_}
437 );
324 438
325 $row++; 439 $row++;
326 if ($row % 6 == 0) { 440 if ($row % 6 == 0) {
327 $col += 2; 441 $col += 2;
328 $row = 0; 442 $row = 0;
333 update_stats_window ({}); 447 update_stats_window ({});
334 448
335 $tgw 449 $tgw
336} 450}
337 451
452sub formsep {
453 reverse join ",", grep length, split /(...)/, reverse $_[0] * 1
454}
455
338sub update_stats_window { 456sub update_stats_window {
339 my ($stats) = @_; 457 my ($stats) = @_;
340 458
341 # i love text protocols!!! 459 # i love text protocols!!!
342 my $hp = $stats->{1} * 1; 460 my $hp = $stats->{Crossfire::Protocol::CS_STAT_HP} * 1;
343 my $hp_m = $stats->{2} * 1; 461 my $hp_m = $stats->{Crossfire::Protocol::CS_STAT_MAXHP} * 1;
344 my $sp = $stats->{3} * 1; 462 my $sp = $stats->{Crossfire::Protocol::CS_STAT_SP} * 1;
345 my $sp_m = $stats->{4} * 1; 463 my $sp_m = $stats->{Crossfire::Protocol::CS_STAT_MAXSP} * 1;
346 my $fo = $stats->{18} * 1; 464 my $fo = $stats->{Crossfire::Protocol::CS_STAT_FOOD} * 1;
347 my $fo_m = 999; 465 my $fo_m = 999;
348 my $gr = $stats->{23} * 1; 466 my $gr = $stats->{Crossfire::Protocol::CS_STAT_GRACE} * 1;
349 my $gr_m = $stats->{24} * 1; 467 my $gr_m = $stats->{Crossfire::Protocol::CS_STAT_MAXGRACE} * 1;
350 468
351 $GAUGES->{hp} ->set_value ($hp, $hp_m); 469 $GAUGES->{hp} ->set_value ($hp, $hp_m);
352 $GAUGES->{mana} ->set_value ($sp, $sp_m); 470 $GAUGES->{mana} ->set_value ($sp, $sp_m);
353 $GAUGES->{food} ->set_value ($fo, $fo_m); 471 $GAUGES->{food} ->set_value ($fo, $fo_m);
354 $GAUGES->{grace} ->set_value ($gr, $gr_m); 472 $GAUGES->{grace} ->set_value ($gr, $gr_m);
355 $GAUGES->{exp} ->set_text ("XP: " . ($stats->{11} || $stats->{28}) * 1 473 $GAUGES->{exp} ->set_text ("Exp: " . (formsep $stats->{Crossfire::Protocol::CS_STAT_EXP64})
356 ." LVL: " . $stats->{12} * 1); 474 . " (lvl " . ($stats->{Crossfire::Protocol::CS_STAT_LEVEL} * 1) . ")");
357 my $rng = $stats->{20}; 475 my $rng = $stats->{Crossfire::Protocol::CS_STAT_RANGE};
358 $rng =~ s/^Range: //; # thank you so much dear server 476 $rng =~ s/^Range: //; # thank you so much dear server
359 $GAUGES->{range} ->set_text ("Rng: " . $rng); 477 $GAUGES->{range} ->set_text ("Rng: " . $rng);
360# $GAUGES->{lvl} ->set_text ("LVL: " . $stats->{12}); 478 my $title = $stats->{Crossfire::Protocol::CS_STAT_TITLE};
479 $title =~ s/^Player: //;
361 $STATWIDS->{title} ->set_text ("Title: " . $stats->{21}); 480 $STATWIDS->{title} ->set_text ("Title: " . $title);
362 481
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}); 482 $STATWIDS->{st_str} ->set_text (sprintf "%d", $stats->{5});
379 $STATWIDS->{st_dex} ->set_text (sprintf "%d", $stats->{8}); 483 $STATWIDS->{st_dex} ->set_text (sprintf "%d", $stats->{8});
380 $STATWIDS->{st_con} ->set_text (sprintf "%d", $stats->{9}); 484 $STATWIDS->{st_con} ->set_text (sprintf "%d", $stats->{9});
381 $STATWIDS->{st_int} ->set_text (sprintf "%d", $stats->{6}); 485 $STATWIDS->{st_int} ->set_text (sprintf "%d", $stats->{6});
382 $STATWIDS->{st_wis} ->set_text (sprintf "%d", $stats->{7}); 486 $STATWIDS->{st_wis} ->set_text (sprintf "%d", $stats->{7});
383 $STATWIDS->{st_pow} ->set_text (sprintf "%d", $stats->{22}); 487 $STATWIDS->{st_pow} ->set_text (sprintf "%d", $stats->{22});
384 $STATWIDS->{st_cha} ->set_text (sprintf "%d", $stats->{10}); 488 $STATWIDS->{st_cha} ->set_text (sprintf "%d", $stats->{10});
385 $STATWIDS->{st_wc} ->set_text (sprintf "%d", $stats->{13}); 489 $STATWIDS->{st_wc} ->set_text (sprintf "%d", $stats->{13});
386 $STATWIDS->{st_ac} ->set_text (sprintf "%d", $stats->{14}); 490 $STATWIDS->{st_ac} ->set_text (sprintf "%d", $stats->{14});
387 $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15}); 491 $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15});
388 $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16}); 492 $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16});
389 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{17}); 493 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::CS_STAT_SPEED});
390 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{19}); 494 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::CS_STAT_WEAP_SP});
391 }
392 495
393 my %tbl = ( 496 my %tbl = (
394 phys => 100, 497 phys => 100,
395 magic => 101, 498 magic => 101,
396 fire => 102, 499 fire => 102,
403 pois => 109, 506 pois => 109,
404 slow => 110, 507 slow => 110,
405 para => 111, 508 para => 111,
406 tund => 112, 509 tund => 112,
407 fear => 113, 510 fear => 113,
511 depl => 113,
408 deat => 115, 512 deat => 115,
409 holyw => 116, 513 holyw => 116,
410 blind => 117 514 blind => 117
411 ); 515 );
412 516
501 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); 605 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port");
502 606
503 { 607 {
504 $table->add (1, 2, my $vbox = new CFClient::UI::VBox); 608 $table->add (1, 2, my $vbox = new CFClient::UI::VBox);
505 609
506 $vbox->add (my $HOST = new CFClient::UI::Entry expand => 1, text => $CFG->{host}, connect_changed => sub { 610 $vbox->add (
611 my $HOST = new CFClient::UI::Entry
612 expand => 1,
613 text => $CFG->{host},
614 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to",
615 connect_changed => sub {
616 my ($self, $value) = @_;
617 $CFG->{host} = $value;
618 }
619 );
620
621 $METASERVER = metaserver_dialog;
622
623 $vbox->add (new CFClient::UI::Flopper
624 expand => 1,
625 text => "Metaserver",
626 other => $METASERVER,
627 tooltip => "Show a list of avaible crossfire servers",
628 connect_open => sub {
629 update_metaserver $HOST;
630 }
631 );
632 }
633
634 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
635 $table->add (1, 4, new CFClient::UI::Entry
636 text => $CFG->{user},
637 tooltip => "The name of your character on the server",
638 connect_changed => sub {
507 my ($self, $value) = @_; 639 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; 640 $CFG->{user} = $value;
641 }
522 }); 642 );
523 643
524 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password"); 644 $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 { 645 $table->add (1, 5, new CFClient::UI::Entry
646 text => $CFG->{password},
647 hidden => 1,
648 tooltip => "The password for your character",
649 connect_changed => sub {
526 my ($self, $value) = @_; 650 my ($self, $value) = @_;
527 $CFG->{password} = $value; 651 $CFG->{password} = $value;
652 }
528 }); 653 );
529 654
530 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); 655 $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 { 656 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry
657 text => $CFG->{say_command},
658 tooltip => "This is the command that will be used if you write a line in the message window entry. "
659 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
660 ."But you could also set it to 'tell &lt;playername&gt;' to only chat with that user.",
661 connect_changed => sub {
532 my ($self, $value) = @_; 662 my ($self, $value) = @_;
533 $CFG->{say_command} = $value; 663 $CFG->{say_command} = $value;
664 }
534 }); 665 );
535 666
536 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); 667 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
537 $table->add (1, 7, new CFClient::UI::Slider 668 $table->add (1, 7, new CFClient::UI::Slider
538 req_w => 100, 669 req_w => 100,
539 range => [$CFG->{mapsize}, 10, 100 + 1, 1], 670 range => [$CFG->{mapsize}, 10, 100 + 1, 1],
671 tooltip => "This is the size of the portion of the map update the server sends you. "
672 ."If you set this to a high value you will be able to see further for example.",
540 connect_changed => sub { 673 connect_changed => sub {
541 my ($self, $value) = @_; 674 my ($self, $value) = @_;
542 675
543 $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 676 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
544 }, 677 },
560 user_h => int $::HEIGHT / 5, 693 user_h => int $::HEIGHT / 5,
561 child => (my $vbox = new CFClient::UI::VBox); 694 child => (my $vbox = new CFClient::UI::VBox);
562 695
563 $vbox->add ($LOGVIEW = new CFClient::UI::TextView 696 $vbox->add ($LOGVIEW = new CFClient::UI::TextView
564 expand => 1, 697 expand => 1,
698 font => $FONT_FIXED,
565 fontsize => $::CFG->{log_fontsize}, 699 fontsize => $::CFG->{log_fontsize},
566 ); 700 );
567 701
568 $vbox->add (my $input = new CFClient::UI::Entry 702 $vbox->add (my $input = new CFClient::UI::Entry
569 connect_focus_in => sub { 703 connect_focus_in => sub {
663 797
664 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); 798 $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); 799 $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); 800 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window);
667 801
802 $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
803 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window);
804
668 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { 805 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub {
669 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 806 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
670 status "Configuration Saved"; 807 status "Configuration Saved";
671 }); 808 });
672 809
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 810 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
677
678
679} 811}
680 812
681sub video_shutdown { 813sub video_shutdown {
682 $CFClient::UI::ROOT->{children} = []; 814 $CFClient::UI::ROOT->{children} = [];
683 undef $SDL_ACTIVE; 815 undef $SDL_ACTIVE;
968 } 1100 }
969 1101
970gotid: 1102gotid:
971 $face->{id} = $id; 1103 $face->{id} = $id;
972 $MAP->set_face ($facenum => $id); 1104 $MAP->set_face ($facenum => $id);
1105 $self->{faceid}[$facenum] = $id;#d#
973 $TILECACHE->get ($id) 1106 $TILECACHE->get ($id)
974} 1107}
975 1108
976sub conn::face_update { 1109sub conn::face_update {
977 my ($self, $facenum, $face) = @_; 1110 my ($self, $facenum, $face) = @_;
985 my ($self, $id, $data) = @_; 1118 my ($self, $id, $data) = @_;
986 1119
987 $self->{texture}[$id] ||= do { 1120 $self->{texture}[$id] ||= do {
988 my $tex = 1121 my $tex =
989 new_from_image CFClient::Texture 1122 new_from_image CFClient::Texture
990 $data, minify => 1; 1123 $data, minify => 1, mipmap => 1;
991 1124
992 $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 1125 $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}});
993 $MAPWIDGET->update; 1126 $MAPWIDGET->update;
994 1127
995 $tex 1128 $tex
1007 1140
1008 $chunk->play; 1141 $chunk->play;
1009# warn "sound $x,$y,$soundnum,$type\n";#d# 1142# warn "sound $x,$y,$soundnum,$type\n";#d#
1010} 1143}
1011 1144
1145my $LAST_QUERY; # server is stupid, stupid, stupid
1146
1012sub conn::query { 1147sub conn::query {
1013 my ($self, $flags, $prompt) = @_; 1148 my ($self, $flags, $prompt) = @_;
1014 1149
1015 #TODO, display dialog with relevant information 1150 $prompt = $LAST_QUERY unless length $prompt;
1016 warn "<<<<QUERY:$flags:$prompt>>>\n";#d# 1151 $LAST_QUERY = $prompt;
1152
1153 my $dialog = new CFClient::UI::FancyFrame
1154 title => "Query",
1155 child => my $vbox = new CFClient::UI::VBox;
1156
1157 $vbox->add (new CFClient::UI::Label
1158 max_w => $::WIDTH * 0.4,
1159 text => $prompt);
1160
1161 if ($flags & Crossfire::Protocol::CS_QUERY_YESNO) {
1162 $vbox->add (my $hbox = new CFClient::HBox);
1163 $hbox->add (new CFClient::Button
1164 text => "No",
1165 connect_activate => sub {
1166 $self->send ("reply n");
1167 $dialog->destroy;
1168 $MAPWIDGET->focus_in;
1169 }
1170 );
1171 $hbox->add (new CFClient::Button
1172 text => "Yes",
1173 connect_activate => sub {
1174 $self->send ("reply y");
1175 $dialog->destroy;
1176 $MAPWIDGET->focus_in;
1177 },
1178 );
1179
1180 $dialog->focus_in;
1181
1182 } elsif ($flags & Crossfire::Protocol::CS_QUERY_SINGLECHAR) {
1183 $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)";
1184 $vbox->add (my $entry = new CFClient::UI::Entry
1185 connect_changed => sub {
1186 $self->send ("reply $_[1]");
1187 $dialog->destroy;
1188 $MAPWIDGET->focus_in;
1189 },
1190 );
1191
1192 $entry->focus_in;
1193
1194 } else {
1195 $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)";
1196
1197 $vbox->add (my $entry = new CFClient::UI::Entry
1198 $flags & Crossfire::Protocol::CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (),
1199 connect_activate => sub {
1200 $self->send ("reply $_[1]");
1201 $dialog->destroy;
1202 $MAPWIDGET->focus_in;
1203 },
1204 );
1205
1206 $entry->focus_in;
1207 }
1208
1209 $dialog->show;
1017} 1210}
1018 1211
1019sub conn::drawinfo { 1212sub conn::drawinfo {
1020 my ($self, $color, $text) = @_; 1213 my ($self, $color, $text) = @_;
1021 1214
1039} 1232}
1040 1233
1041sub conn::spell_add { 1234sub conn::spell_add {
1042 my ($self, $spell) = @_; 1235 my ($self, $spell) = @_;
1043 1236
1237 # TODO
1238 # create a widget dynamically, using spell face (CF::Protocol downloads them)
1044 $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}, sub { 1239 $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message});
1045 });
1046 $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}, sub { 1240 $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message});
1047 });
1048} 1241}
1049 1242
1050sub conn::spell_delete { 1243sub conn::spell_delete {
1051 my ($self, $spell) = @_; 1244 my ($self, $spell) = @_;
1052} 1245}
1053 1246
1054sub conn::addme_success { 1247sub conn::addme_success {
1055 my ($self) = @_; 1248 my ($self) = @_;
1056 1249
1057 for my $skill (values %{$self->{skill_info}}) { 1250 for my $skill (values %{$self->{skill_info}}) {
1058 $MAPWIDGET->add_command ("ready_skill $skill", "", sub { 1251 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'");
1059 }); 1252 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'");
1060 $MAPWIDGET->add_command ("use_skill $skill", "", sub {
1061 });
1062 } 1253 }
1254}
1255
1256sub update_floorbox {
1257 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub {
1258 $FLOORBOX->clear;
1259 $FLOORBOX->add (new CFClient::UI::Empty expand => 1);
1260
1261 my @items = values %{ $CONN->{container}{0} };
1262
1263 # we basically have to use the same sorting as everybody else
1264 @items = sort { $a->{type} <=> $b->{type} } @items;
1265
1266 for my $item (reverse @items) {
1267 my $desc = $item->{nrof} < 2
1268 ? $item->{name}
1269 : "$item->{nrof} $item->{name_pl}";
1270 # todo: animation widget, face widget, weight(?) etc.
1271 $FLOORBOX->add (my $hbox = new CFClient::UI::HBox
1272 tooltip => (CFClient::UI::Label->escape ($desc)
1273 . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"),
1274 can_hover => 1,
1275 can_events => 1,
1276 );
1277
1278 $hbox->add (new CFClient::UI::Face
1279 face => $item->{face},
1280 anim => $item->{anim},
1281 animspeed => $item->{animspeed},
1282 );
1283
1284 $hbox->add (new CFClient::UI::Label
1285 text => $desc,
1286 );
1287 }
1288 });
1289 refresh;
1290}
1291
1292sub conn::container_add {
1293 my ($self, $id, $items) = @_;
1294
1295 update_floorbox if $id == 0;
1296 # $self-<{player}{tag} => player inv
1297 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}};
1298}
1299
1300sub conn::container_clear {
1301 my ($self, $id) = @_;
1302
1303 update_floorbox if $id == 0;
1304# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
1305}
1306
1307sub conn::item_delete {
1308 my ($self, @items) = @_;
1309
1310 for (@items) {
1311 update_floorbox if $_->{container} == 0;
1312 }
1313}
1314
1315sub conn::item_update {
1316 my ($self, $item) = @_;
1317
1318 update_floorbox if $item->{container} == 0;
1063} 1319}
1064 1320
1065%SDL_CB = ( 1321%SDL_CB = (
1066 CFClient::SDL_QUIT => sub { 1322 CFClient::SDL_QUIT => sub {
1067 Event::unloop -1; 1323 Event::unloop -1;
1102 sdl_mode => 0, 1358 sdl_mode => 0,
1103 width => 640, 1359 width => 640,
1104 height => 480, 1360 height => 480,
1105 fullscreen => 0, 1361 fullscreen => 0,
1106 fast => 0, 1362 fast => 0,
1363 map_scale => 0.5,
1107 fow_enable => 1, 1364 fow_enable => 1,
1108 fow_intensity => 0.45, 1365 fow_intensity => 0.45,
1109 fow_smooth => 0, 1366 fow_smooth => 0,
1110 gui_fontsize => 1, 1367 gui_fontsize => 1,
1111 log_fontsize => 1, 1368 log_fontsize => 1,
1133@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; 1390@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
1134 1391
1135$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; 1392$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
1136 1393
1137{ 1394{
1138 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); 1395 my @fonts = map CFClient::find_rcfile "fonts/$_", qw(
1396 DejaVuSans.ttf
1397 DejaVuSansMono.ttf
1398 DejaVuSans-Bold.ttf
1399 DejaVuSansMono-Bold.ttf
1400 DejaVuSans-Oblique.ttf
1401 DejaVuSansMono-Oblique.ttf
1402 DejaVuSans-BoldOblique.ttf
1403 DejaVuSansMono-BoldOblique.ttf
1404 );
1139 1405
1140 CFClient::add_font $_ for @fonts; 1406 CFClient::add_font $_ for @fonts;
1141 CFClient::set_font $fonts[0]; 1407
1408 $FONT_PROP = new_from_file CFClient::Font $fonts[0];
1409 $FONT_FIXED = new_from_file CFClient::Font $fonts[1];
1410
1411 $FONT_PROP->make_default;
1142} 1412}
1143 1413
1144video_init; 1414video_init;
1145audio_init; 1415audio_init;
1146 1416

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines