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