… | |
… | |
12 | use SDL::Surface; |
12 | use SDL::Surface; |
13 | use SDL::OpenGL; |
13 | use SDL::OpenGL; |
14 | use SDL::OpenGL::Constants; |
14 | use SDL::OpenGL::Constants; |
15 | |
15 | |
16 | use Crossfire; |
16 | use Crossfire; |
17 | use Crossfire::Client; |
|
|
18 | use Crossfire::Protocol; |
17 | use Crossfire::Protocol; |
19 | |
18 | |
|
|
19 | use CFClient; |
20 | use Crossfire::Client::Widget; |
20 | use CFClient::Widget; |
|
|
21 | |
|
|
22 | our $VERSION = '0.1'; |
|
|
23 | |
|
|
24 | my $MAX_FPS = 30; |
|
|
25 | my $TICKS_PER_FRAME = int 1000 / $MAX_FPS - 1; # min ticks per frame |
21 | |
26 | |
22 | our $FACECACHE; |
27 | our $FACECACHE; |
23 | |
|
|
24 | our $VERSION = '0.1'; |
|
|
25 | |
|
|
26 | our %GL_EXT; |
|
|
27 | |
28 | |
28 | our $CFG; |
29 | our $CFG; |
29 | our $CONN; |
30 | our $CONN; |
30 | |
31 | |
31 | our $WIDTH; |
32 | our $WIDTH; |
32 | our $HEIGHT; |
33 | our $HEIGHT; |
33 | our $FULLSCREEN; |
34 | our $FULLSCREEN; |
34 | |
35 | |
|
|
36 | our $MAPWIDGET; |
35 | our $FONTSIZE; |
37 | our $FONTSIZE; |
36 | |
38 | |
37 | our $SDL_TIMER; |
39 | our $SDL_TIMER; |
38 | our $SDL_APP; |
40 | our $SDL_APP; |
39 | our $SDL_EV = new SDL::Event; |
41 | our $SDL_EV; |
40 | our %SDL_CB; |
42 | our %SDL_CB; |
41 | |
43 | |
42 | our @GL_INIT; # hooks called on every gl init |
|
|
43 | |
|
|
44 | our $ALT_ENTER_MESSAGE; |
44 | our $ALT_ENTER_MESSAGE; |
45 | |
45 | our $STATUS_LINE; |
46 | our $TOPLEVEL; |
46 | our $DEBUG_STATUS; |
47 | |
|
|
48 | our $tw; # Test widget #d# |
|
|
49 | |
47 | |
50 | my $last_refresh; |
48 | my $last_refresh; |
|
|
49 | my %ANIMATE; |
|
|
50 | my $refresh_handler; |
|
|
51 | |
|
|
52 | our ($tw, $te); # Test widget #d# |
51 | |
53 | |
52 | sub init_screen { |
54 | sub init_screen { |
53 | $SDL_APP = new SDL::App |
55 | $SDL_APP = new SDL::App |
54 | -flags => SDL_ANYFORMAT | SDL_HWSURFACE, |
56 | -flags => SDL_ANYFORMAT | SDL_HWSURFACE, |
55 | -title => "Crossfire+ Client", |
57 | -title => "Crossfire+ Client", |
56 | -width => $WIDTH, |
58 | -width => $WIDTH, |
57 | -height => $HEIGHT, |
59 | -height => $HEIGHT, |
58 | -opengl => 1, |
60 | -opengl => 1, |
59 | -red_size => 8, |
61 | -red_size => 5, |
60 | -green_size => 8, |
62 | -green_size => 5, |
61 | -blue_size => 8, |
63 | -blue_size => 5, |
|
|
64 | -alpha_size => 0, |
62 | -double_buffer => 1, |
65 | -double_buffer => 1, |
63 | -fullscreen => $FULLSCREEN, |
66 | -fullscreen => $FULLSCREEN, |
64 | -resizeable => 0; |
67 | -resizeable => 0; |
65 | |
68 | |
|
|
69 | $SDL_EV = new SDL::Event; |
|
|
70 | $SDL_EV->set_unicode (1); |
|
|
71 | |
|
|
72 | $SDL_TIMER = add Glib::Timeout 1000/50, sub { |
|
|
73 | ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->() |
|
|
74 | while $SDL_EV->poll; |
|
|
75 | |
|
|
76 | 1 |
|
|
77 | }; |
|
|
78 | |
66 | $last_refresh = SDL::GetTicks; |
79 | $last_refresh = SDL::GetTicks; |
67 | |
80 | |
68 | %GL_EXT = map +($_ => 1), split /\s+/, Crossfire::Client::gl_extensions; |
81 | CFClient::gl_init; |
69 | |
|
|
70 | $GL_EXT{GL_ARB_texture_non_power_of_two} |
|
|
71 | or warn "WARNING: non-power-of-two opengl extension required"; |
|
|
72 | |
82 | |
73 | $FONTSIZE = int $HEIGHT / 50; |
83 | $FONTSIZE = int $HEIGHT / 50; |
74 | |
84 | |
75 | $ALT_ENTER_MESSAGE = new Crossfire::Client::Widget::Label |
85 | ############################################################################# |
76 | 0, $FONTSIZE, $HEIGHT - $FONTSIZE, $FONTSIZE, |
|
|
77 | "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
|
|
78 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - ($ALT_ENTER_MESSAGE->size_request)[1]); |
|
|
79 | $TOPLEVEL->add ($ALT_ENTER_MESSAGE); |
|
|
80 | |
86 | |
81 | # Test code #d# |
|
|
82 | unless ($tw) { # haha... |
|
|
83 | $tw = new Crossfire::Client::Widget::Animator; |
|
|
84 | my $lbl1 = new Crossfire::Client::Widget::Label |
|
|
85 | 0, 0, 10, $FONTSIZE, "<i>This</i> is a\n<u>TEST</u>!\nOf a themed\nFrame!"; |
|
|
86 | my $lbl2 = new Crossfire::Client::Widget::Label |
|
|
87 | 0, 0, 10, $FONTSIZE, "LBL2"; |
|
|
88 | |
|
|
89 | my $vb = new Crossfire::Client::Widget::VBox; |
|
|
90 | my $f = new Crossfire::Client::Widget::FancyFrame; |
|
|
91 | my $f2 = new Crossfire::Client::Widget::FancyFrame; |
|
|
92 | $f->add ($lbl1); |
|
|
93 | $f2->add ($lbl2); |
|
|
94 | $vb->add ($f); |
|
|
95 | $vb->add ($f2, 1); |
|
|
96 | |
|
|
97 | $tw->add ($vb); |
|
|
98 | $tw->w (400); |
|
|
99 | $tw->h (300); |
|
|
100 | $tw->move ($WIDTH - 200, 0); |
|
|
101 | $tw->moveto (0, 0); |
|
|
102 | $TOPLEVEL->add ($tw); |
|
|
103 | |
|
|
104 | # $f->move ($WIDTH - 200, 0); |
|
|
105 | # $TOPLEVEL->add ($f); |
|
|
106 | } |
|
|
107 | |
|
|
108 | glClearColor 0, 0, 0, 0; |
87 | glClearColor 0.45, 0.45, 0.45, 1; |
109 | |
88 | |
110 | glEnable GL_TEXTURE_2D; |
89 | glEnable GL_TEXTURE_2D; |
111 | glEnable GL_COLOR_MATERIAL; |
90 | glEnable GL_COLOR_MATERIAL; |
112 | glShadeModel GL_FLAT; |
91 | glShadeModel GL_FLAT; |
113 | glDisable GL_DEPTH_TEST; |
92 | glDisable GL_DEPTH_TEST; |
114 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
93 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
115 | |
94 | |
116 | $_->() for @GL_INIT; |
95 | ############################################################################# |
|
|
96 | |
|
|
97 | $DEBUG_STATUS = new CFClient::Widget::Label; |
|
|
98 | $CFClient::Widget::TOPLEVEL->add ($DEBUG_STATUS); |
|
|
99 | |
|
|
100 | $STATUS_LINE = new CFClient::Widget::Label |
|
|
101 | y => $HEIGHT * 59 / 60 - $FONTSIZE; |
|
|
102 | $CFClient::Widget::TOPLEVEL->add ($STATUS_LINE); |
|
|
103 | |
|
|
104 | $ALT_ENTER_MESSAGE = new CFClient::Widget::Label |
|
|
105 | y => $HEIGHT * 59 / 60, |
|
|
106 | height => $HEIGHT / 60, |
|
|
107 | text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
|
|
108 | $CFClient::Widget::TOPLEVEL->add ($ALT_ENTER_MESSAGE); |
|
|
109 | |
|
|
110 | $MAPWIDGET = new CFClient::Widget::MapWidget; |
|
|
111 | $CFClient::Widget::TOPLEVEL->add ($MAPWIDGET); |
|
|
112 | $MAPWIDGET->focus_in; |
|
|
113 | |
|
|
114 | # Test code #d# |
|
|
115 | unless ($tw) { # haha... |
|
|
116 | $te = new CFClient::Widget::FancyFrame x => 300, z => 1; |
|
|
117 | $te->add (new CFClient::Widget::Entry); |
|
|
118 | $CFClient::Widget::TOPLEVEL->add ($te); |
|
|
119 | |
|
|
120 | $tw = new CFClient::Widget::Animator x => $WIDTH - 200, w => 600, h => 300; |
|
|
121 | my $lbl1 = new CFClient::Widget::Label text => "<i>This</i> is a\n<u>TEST</u>!\nOf a themed\nFrame!"; |
|
|
122 | my $lbl2 = new CFClient::Widget::Label text => "LBL2"; |
|
|
123 | my $vb = new CFClient::Widget::VBox; |
|
|
124 | my $f = new CFClient::Widget::FancyFrame; |
|
|
125 | my $f2 = new CFClient::Widget::FancyFrame; |
|
|
126 | $f->add ($lbl1); |
|
|
127 | $f2->add ($lbl2); |
|
|
128 | $vb->add ($f); |
|
|
129 | $vb->add ($f2, 1); |
|
|
130 | |
|
|
131 | $tw->add ($vb); |
|
|
132 | $tw->moveto (0, 0); |
|
|
133 | $CFClient::Widget::TOPLEVEL->add ($tw); |
|
|
134 | |
|
|
135 | # $f->move ($WIDTH - 200, 0); |
|
|
136 | # $CFClient::Widget::TOPLEVEL->add ($f); |
|
|
137 | } |
|
|
138 | } |
|
|
139 | |
|
|
140 | sub destroy_screen { |
|
|
141 | remove Glib::Source $SDL_TIMER; |
|
|
142 | undef $SDL_APP; |
|
|
143 | undef $SDL_EV; |
|
|
144 | SDL::Quit; |
117 | } |
145 | } |
118 | |
146 | |
119 | sub start_game { |
147 | sub start_game { |
120 | $SDL_TIMER = add Glib::Timeout 1000/100, sub { |
|
|
121 | ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->() |
|
|
122 | while $SDL_EV->poll; |
|
|
123 | |
|
|
124 | 1 |
|
|
125 | }; |
|
|
126 | |
|
|
127 | $WIDTH = $CFG->{width}; |
148 | $WIDTH = $CFG->{width}; |
128 | $HEIGHT = $CFG->{height}; |
149 | $HEIGHT = $CFG->{height}; |
129 | $FULLSCREEN = 0; |
150 | $FULLSCREEN = 0; |
130 | |
151 | |
131 | init_screen; |
152 | init_screen; |
|
|
153 | |
|
|
154 | my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
132 | |
155 | |
133 | $CONN = new conn |
156 | $CONN = new conn |
134 | host => $CFG->{host}, |
157 | host => $CFG->{host}, |
135 | port => $CFG->{port}, |
158 | port => $CFG->{port}, |
136 | user => $CFG->{user}, |
159 | user => $CFG->{user}, |
137 | pass => $CFG->{password}, |
160 | pass => $CFG->{password}, |
138 | mapw => 50, |
161 | mapw => $mapsize, |
139 | maph => 37, |
162 | maph => $mapsize, |
140 | ; |
163 | ; |
141 | |
164 | |
142 | Crossfire::Client::lowdelay fileno $CONN->{fh}; |
165 | CFClient::lowdelay fileno $CONN->{fh}; |
143 | } |
166 | } |
144 | |
167 | |
145 | sub stop_game { |
168 | sub stop_game { |
146 | remove Glib::Source $SDL_TIMER; |
169 | remove Glib::Source $refresh_handler if $refresh_handler; |
|
|
170 | undef $refresh_handler; |
147 | |
171 | |
148 | undef $SDL_APP; |
172 | undef $CONN; |
149 | SDL::Quit; |
173 | destroy_screen; |
150 | } |
174 | } |
151 | |
|
|
152 | |
175 | |
153 | sub force_refresh { |
176 | sub force_refresh { |
154 | glViewport 0, 0, $WIDTH, $HEIGHT; |
177 | glViewport 0, 0, $WIDTH, $HEIGHT; |
155 | |
178 | |
156 | glMatrixMode GL_PROJECTION; |
179 | glMatrixMode GL_PROJECTION; |
157 | glLoadIdentity; |
180 | glLoadIdentity; |
158 | glOrtho 0, $WIDTH, $HEIGHT, 0, -6000 , 6000; |
181 | glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000; |
159 | glMatrixMode GL_MODELVIEW; |
182 | glMatrixMode GL_MODELVIEW; |
160 | |
183 | |
161 | glClear GL_COLOR_BUFFER_BIT; |
184 | glClear GL_COLOR_BUFFER_BIT; |
162 | |
185 | |
163 | $TOPLEVEL->draw; |
186 | $CFClient::Widget::TOPLEVEL->draw; |
164 | |
187 | |
165 | SDL::GLSwapBuffers; |
188 | SDL::GLSwapBuffers; |
166 | } |
189 | } |
167 | |
190 | |
168 | my %ANIMATE; |
191 | sub debug { |
|
|
192 | $DEBUG_STATUS->set_text ($_[0]); |
|
|
193 | $DEBUG_STATUS->size_allocate ($DEBUG_STATUS->size_request); |
|
|
194 | $DEBUG_STATUS->move ($WIDTH - $DEBUG_STATUS->{w}, 0); |
|
|
195 | } |
169 | |
196 | |
170 | my $refresh_handler; |
197 | my $FPS; |
171 | |
198 | |
172 | sub refresh { |
199 | sub refresh { |
173 | $refresh_handler ||= add Glib::Idle sub { |
200 | $refresh_handler ||= add Glib::Idle sub { |
|
|
201 | if ($SDL_APP) { |
174 | my $next_refresh = SDL::GetTicks; |
202 | my $next_refresh = SDL::GetTicks; |
|
|
203 | |
|
|
204 | if ($next_refresh - $last_refresh < $TICKS_PER_FRAME) { |
|
|
205 | SDL::Delay $TICKS_PER_FRAME - ($next_refresh - $last_refresh); |
|
|
206 | $next_refresh = SDL::GetTicks; |
|
|
207 | } |
|
|
208 | |
175 | my $interval = ($next_refresh - $last_refresh) * 0.001; |
209 | my $interval = ($next_refresh - $last_refresh) * 0.001; |
176 | $last_refresh = $next_refresh; |
210 | $last_refresh = $next_refresh; |
177 | |
211 | |
|
|
212 | if ($interval) { |
|
|
213 | $FPS ||= 1 / $interval; |
|
|
214 | $FPS = $FPS * 0.96 + (1 / $interval) * 0.04; |
|
|
215 | debug sprintf "%5.02f", $FPS; |
|
|
216 | } |
|
|
217 | |
178 | force_refresh; |
218 | force_refresh; |
179 | $_->animate ($interval) for grep $_, values %ANIMATE; |
219 | $_->animate ($interval) for grep $_, values %ANIMATE; |
180 | |
220 | |
181 | if (%ANIMATE) { |
221 | if (%ANIMATE) { |
|
|
222 | 1 |
|
|
223 | } else { |
|
|
224 | undef $refresh_handler; |
|
|
225 | 0 |
182 | 1 |
226 | } |
183 | } else { |
227 | } else { |
184 | undef $refresh_handler; |
228 | undef $refresh_handler; |
185 | 0 |
229 | 0 |
186 | } |
230 | } |
187 | }; |
231 | }; |
… | |
… | |
213 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
257 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
214 | # alt-enter |
258 | # alt-enter |
215 | $FULLSCREEN = !$FULLSCREEN; |
259 | $FULLSCREEN = !$FULLSCREEN; |
216 | init_screen; |
260 | init_screen; |
217 | } else { |
261 | } else { |
218 | Crossfire::Client::Widget::feed_sdl_key_down_event ($SDL_EV); |
262 | CFClient::Widget::feed_sdl_key_down_event ($SDL_EV); |
219 | } |
263 | } |
220 | }, |
264 | }, |
221 | SDL_KEYUP() => sub { |
265 | SDL_KEYUP() => sub { |
222 | Crossfire::Client::Widget::feed_sdl_key_up_event ($SDL_EV); |
266 | CFClient::Widget::feed_sdl_key_up_event ($SDL_EV); |
223 | }, |
267 | }, |
224 | SDL_MOUSEMOTION() => sub { |
268 | SDL_MOUSEMOTION() => sub { |
225 | warn "sdl motion\n";#d# |
269 | CFClient::Widget::feed_sdl_motion_event ($SDL_EV); |
226 | }, |
270 | }, |
227 | SDL_MOUSEBUTTONDOWN() => sub { |
271 | SDL_MOUSEBUTTONDOWN() => sub { |
228 | Crossfire::Client::Widget::feed_sdl_button_down_event ($SDL_EV); |
272 | CFClient::Widget::feed_sdl_button_down_event ($SDL_EV); |
229 | }, |
273 | }, |
230 | SDL_MOUSEBUTTONUP() => sub { |
274 | SDL_MOUSEBUTTONUP() => sub { |
231 | Crossfire::Client::Widget::feed_sdl_button_up_event ($SDL_EV); |
275 | CFClient::Widget::feed_sdl_button_up_event ($SDL_EV); |
232 | }, |
276 | }, |
233 | SDL_ACTIVEEVENT() => sub { |
277 | SDL_ACTIVEEVENT() => sub { |
234 | warn "active\n";#d# |
278 | printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
235 | }, |
279 | }, |
236 | ); |
280 | ); |
237 | |
281 | |
238 | @conn::ISA = Crossfire::Protocol::; |
282 | @conn::ISA = Crossfire::Protocol::; |
239 | |
283 | |
240 | sub conn::map_update { |
284 | sub conn::map_update { |
241 | my ($self, $dirty) = @_; |
285 | my ($self, $dirty) = @_; |
242 | |
286 | |
243 | refresh; |
287 | $MAPWIDGET->update; |
244 | } |
288 | } |
245 | |
289 | |
246 | sub conn::map_scroll { |
290 | sub conn::map_scroll { |
247 | my ($self, $dx, $dy) = @_; |
291 | my ($self, $dx, $dy) = @_; |
248 | |
292 | |
… | |
… | |
264 | sub conn::face_update { |
308 | sub conn::face_update { |
265 | my ($self, $face) = @_; |
309 | my ($self, $face) = @_; |
266 | |
310 | |
267 | $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; |
311 | $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; |
268 | |
312 | |
269 | $face->{texture} = new_from_image Crossfire::Client::Texture delete $face->{image}; |
313 | $face->{texture} = new_from_image CFClient::Texture delete $face->{image}; |
270 | } |
314 | } |
271 | |
315 | |
272 | sub conn::query { |
316 | sub conn::query { |
273 | my ($self, $flags, $prompt) = @_; |
317 | my ($self, $flags, $prompt) = @_; |
274 | |
318 | |
… | |
… | |
286 | } |
330 | } |
287 | $ent->set_text ($value); |
331 | $ent->set_text ($value); |
288 | $ent->signal_connect (changed => sub { |
332 | $ent->signal_connect (changed => sub { |
289 | my ($ent) = @_; |
333 | my ($ent) = @_; |
290 | $cfg->{$key} = $ent->get_text; |
334 | $cfg->{$key} = $ent->get_text; |
|
|
335 | # TODO: Mapsize should be a slider in the game gui |
291 | if ($key eq 'mapsize' and $cfg->{$key} > 100) { |
336 | if ($key eq 'mapsize' and $cfg->{$key} > 100) { |
292 | $cfg->{$key} = 100; |
337 | $cfg->{$key} = 100; |
293 | $ent->set_text ('100'); |
|
|
294 | } elsif ($key eq 'mapsize' and $cfg->{$key} < 0) { |
338 | } elsif ($key eq 'mapsize' and $cfg->{$key} < 50) { |
295 | $cfg->{$key} = 0; |
339 | $cfg->{$key} = 50; |
296 | $ent->set_text ('0'); |
|
|
297 | } |
340 | } |
298 | }); |
341 | }); |
299 | } |
342 | } |
300 | |
343 | |
301 | sub run_config_dialog { |
344 | sub run_config_dialog { |
… | |
… | |
348 | $cb->signal_connect (clicked => sub { |
391 | $cb->signal_connect (clicked => sub { |
349 | for (keys %$cfg) { |
392 | for (keys %$cfg) { |
350 | $::CFG->{$_} = $cfg->{$_} |
393 | $::CFG->{$_} = $cfg->{$_} |
351 | if $_ ne '_i'; |
394 | if $_ ne '_i'; |
352 | } |
395 | } |
353 | Crossfire::Client::write_cfg "$Crossfire::VARDIR/pclientrc"; |
396 | CFClient::write_cfg "$CFrossfire::VARDIR/pclientrc"; |
354 | }); |
397 | }); |
355 | $hb->pack_start (my $cb = Gtk2::Button->new ("login"), 1, 1, 5); |
398 | $hb->pack_start (my $cb = Gtk2::Button->new ("login"), 1, 1, 5); |
356 | $cb->signal_connect (clicked => sub { |
399 | $cb->signal_connect (clicked => sub { |
357 | for (keys %$cfg) { |
400 | for (keys %$cfg) { |
358 | $::CFG->{$_} = $cfg->{$_} |
401 | $::CFG->{$_} = $cfg->{$_} |
… | |
… | |
361 | my $cb = $events{login} || sub {}; |
404 | my $cb = $events{login} || sub {}; |
362 | $cb->($::CFG->{user}, $::CFG->{password}); |
405 | $cb->($::CFG->{user}, $::CFG->{password}); |
363 | }); |
406 | }); |
364 | $hb->pack_start (my $cb = Gtk2::Button->new ("logout"), 1, 1, 5); |
407 | $hb->pack_start (my $cb = Gtk2::Button->new ("logout"), 1, 1, 5); |
365 | $cb->signal_connect (clicked => sub { |
408 | $cb->signal_connect (clicked => sub { |
366 | my $cb = $events{login} || sub {}; |
409 | my $cb = $events{logout} || sub {}; |
367 | $cb->(); |
410 | $cb->(); |
368 | }); |
411 | }); |
369 | $hb->pack_start (my $cb = Gtk2::Button->new ("quit"), 1, 1, 5); |
412 | $hb->pack_start (my $cb = Gtk2::Button->new ("quit"), 1, 1, 5); |
370 | $cb->signal_connect (clicked => sub { $w->destroy }); |
413 | $cb->signal_connect (clicked => sub { $w->destroy }); |
371 | |
414 | |
… | |
… | |
377 | |
420 | |
378 | ############################################################################# |
421 | ############################################################################# |
379 | |
422 | |
380 | SDL::Init SDL_INIT_EVERYTHING; |
423 | SDL::Init SDL_INIT_EVERYTHING; |
381 | |
424 | |
382 | $TOPLEVEL = Crossfire::Client::Widget::Toplevel->new; |
|
|
383 | |
|
|
384 | my $mapwidget = Crossfire::Client::Widget::MapWidget->new; |
|
|
385 | |
|
|
386 | $TOPLEVEL->add ($mapwidget); |
|
|
387 | $mapwidget->focus_in; |
|
|
388 | |
|
|
389 | Crossfire::Client::read_cfg "$Crossfire::VARDIR/pclientrc"; |
425 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
390 | |
426 | |
391 | $CFG ||= { |
427 | $CFG ||= { |
392 | width => 640, |
428 | width => 640, |
393 | height => 480, |
429 | height => 480, |
394 | mapsize => 100, |
430 | mapsize => 100, |
395 | fullscreen => 0, |
431 | fullscreen => 0, |
396 | host => "crossfire.schmorp.de", |
432 | host => "crossfire.schmorp.de", |
397 | port => 13327, |
433 | port => 13327, |
398 | }; |
434 | }; |
399 | |
435 | |
400 | Crossfire::Client::set_font Crossfire::Client::find_rcfile "uifont.ttf"; |
436 | { |
|
|
437 | my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); |
|
|
438 | |
|
|
439 | CFClient::add_font $_ for @fonts; |
|
|
440 | CFClient::set_font $fonts[0]; |
|
|
441 | } |
401 | |
442 | |
402 | $FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; |
443 | $FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; |
403 | |
444 | |
404 | run_config_dialog |
445 | run_config_dialog |
405 | login => sub { start_game }, |
446 | login => sub { start_game }, |