… | |
… | |
14 | use SDL::OpenGL::Constants; |
14 | use SDL::OpenGL::Constants; |
15 | |
15 | |
16 | use Crossfire; |
16 | use Crossfire; |
17 | use Crossfire::Protocol; |
17 | use Crossfire::Protocol; |
18 | |
18 | |
19 | use Crossfire::Client; |
19 | use CFClient; |
20 | use Crossfire::Client::Widget; |
20 | use CFClient::UI; |
21 | |
21 | |
22 | our $VERSION = '0.1'; |
22 | our $VERSION = '0.1'; |
23 | |
23 | |
24 | my $MAX_FPS = 30; |
24 | my $MAX_FPS = 60; |
25 | my $TICKS_PER_FRAME = int 1000 / $MAX_FPS - 1; # min ticks per frame |
25 | my $TICKS_PER_FRAME = int 1000 / $MAX_FPS - 1; # min ticks per frame |
26 | |
26 | |
27 | our $FACECACHE; |
27 | our $FACECACHE; |
28 | |
28 | |
29 | our $CFG; |
29 | our $CFG; |
30 | our $CONN; |
30 | our $CONN; |
31 | |
31 | |
|
|
32 | our @SDL_MODES; |
32 | our $WIDTH; |
33 | our $WIDTH; |
33 | our $HEIGHT; |
34 | our $HEIGHT; |
34 | our $FULLSCREEN; |
35 | our $FULLSCREEN; |
35 | |
36 | |
|
|
37 | our $NOW; |
|
|
38 | |
|
|
39 | our $MAPWIDGET; |
36 | our $FONTSIZE; |
40 | our $FONTSIZE; |
37 | |
41 | |
38 | our $SDL_TIMER; |
42 | our $SDL_TIMER; |
39 | our $SDL_APP; |
43 | our $SDL_APP; |
40 | our $SDL_EV; |
44 | our $SDL_EV; |
… | |
… | |
66 | -resizeable => 0; |
70 | -resizeable => 0; |
67 | |
71 | |
68 | $SDL_EV = new SDL::Event; |
72 | $SDL_EV = new SDL::Event; |
69 | $SDL_EV->set_unicode (1); |
73 | $SDL_EV->set_unicode (1); |
70 | |
74 | |
71 | $SDL_TIMER = add Glib::Timeout 1000/50, sub { |
75 | $SDL_TIMER = add Glib::Timeout 1000 / $MAX_FPS, sub { |
72 | ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->() |
76 | ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->() |
73 | while $SDL_EV->poll; |
77 | while $SDL_EV->poll; |
74 | |
78 | |
75 | 1 |
79 | 1 |
76 | }; |
80 | }; |
77 | |
81 | |
78 | $last_refresh = SDL::GetTicks; |
82 | $last_refresh = SDL::GetTicks; |
79 | |
83 | |
80 | Crossfire::Client::gl_init; |
84 | CFClient::gl_init; |
81 | |
85 | |
82 | $FONTSIZE = int $HEIGHT / 50; |
86 | $FONTSIZE = int $HEIGHT / 40; |
83 | |
87 | |
84 | ############################################################################# |
88 | ############################################################################# |
85 | |
89 | |
86 | glClearColor 0.45, 0.45, 0.45, 1; |
90 | glClearColor 0.45, 0.45, 0.45, 1; |
87 | |
91 | |
… | |
… | |
91 | glDisable GL_DEPTH_TEST; |
95 | glDisable GL_DEPTH_TEST; |
92 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
96 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
93 | |
97 | |
94 | ############################################################################# |
98 | ############################################################################# |
95 | |
99 | |
96 | $DEBUG_STATUS = new Crossfire::Client::Widget::Label 0, 0, 1, $FONTSIZE, ""; |
100 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0; |
97 | $Crossfire::Client::Widget::TOPLEVEL->add ($DEBUG_STATUS); |
101 | $CFClient::UI::TOPLEVEL->add ($DEBUG_STATUS); |
98 | |
102 | |
99 | $STATUS_LINE = new Crossfire::Client::Widget::Label |
103 | $STATUS_LINE = new CFClient::UI::Label |
100 | 0, $HEIGHT * 59 / 60 - $FONTSIZE, 1, $FONTSIZE, |
104 | padding => 0, |
101 | ""; |
105 | y => $HEIGHT * 49 / 50 - $FONTSIZE; |
102 | $Crossfire::Client::Widget::TOPLEVEL->add ($STATUS_LINE); |
106 | $CFClient::UI::TOPLEVEL->add ($STATUS_LINE); |
103 | |
107 | |
104 | $ALT_ENTER_MESSAGE = new Crossfire::Client::Widget::Label |
108 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
105 | 0, $HEIGHT * 59 / 60, 1, $HEIGHT / 60, |
109 | padding => 0, |
|
|
110 | y => $HEIGHT * 49 / 50, |
|
|
111 | height => $HEIGHT / 50, |
106 | "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
112 | text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
107 | $Crossfire::Client::Widget::TOPLEVEL->add ($ALT_ENTER_MESSAGE); |
113 | $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE); |
108 | |
114 | |
109 | # Test code #d# |
115 | $MAPWIDGET = new CFClient::UI::MapWidget; |
110 | unless ($tw) { # haha... |
116 | $CFClient::UI::TOPLEVEL->add ($MAPWIDGET); |
111 | $te = new Crossfire::Client::Widget::FancyFrame; |
117 | $MAPWIDGET->focus_in; |
112 | $te->add (new Crossfire::Client::Widget::Entry); |
|
|
113 | $te->move (300, 0, 2); |
|
|
114 | $Crossfire::Client::Widget::TOPLEVEL->add ($te); |
|
|
115 | |
|
|
116 | $tw = new Crossfire::Client::Widget::Animator; |
|
|
117 | my $lbl1 = new Crossfire::Client::Widget::Label |
|
|
118 | 0, 0, 10, $FONTSIZE, "<i>This</i> is a\n<u>TEST</u>!\nOf a themed\nFrame!"; |
|
|
119 | my $lbl2 = new Crossfire::Client::Widget::Label |
|
|
120 | 0, 0, 10, $FONTSIZE, "LBL2"; |
|
|
121 | |
|
|
122 | my $vb = new Crossfire::Client::Widget::VBox; |
|
|
123 | my $f = new Crossfire::Client::Widget::FancyFrame; |
|
|
124 | my $f2 = new Crossfire::Client::Widget::FancyFrame; |
|
|
125 | $f->add ($lbl1); |
|
|
126 | $f2->add ($lbl2); |
|
|
127 | $vb->add ($f); |
|
|
128 | $vb->add ($f2, 1); |
|
|
129 | |
|
|
130 | $tw->add ($vb); |
|
|
131 | $tw->w (400); |
|
|
132 | $tw->h (300); |
|
|
133 | $tw->move ($WIDTH - 200, 0); |
|
|
134 | $tw->moveto (0, 0); |
|
|
135 | $Crossfire::Client::Widget::TOPLEVEL->add ($tw); |
|
|
136 | |
|
|
137 | # $f->move ($WIDTH - 200, 0); |
|
|
138 | # $Crossfire::Client::Widget::TOPLEVEL->add ($f); |
|
|
139 | } |
|
|
140 | } |
118 | } |
141 | |
119 | |
142 | sub destroy_screen { |
120 | sub destroy_screen { |
143 | remove Glib::Source $SDL_TIMER; |
121 | remove Glib::Source $SDL_TIMER; |
144 | undef $SDL_APP; |
122 | undef $SDL_APP; |
145 | undef $SDL_EV; |
123 | undef $SDL_EV; |
146 | SDL::Quit; |
124 | SDL::Quit; |
147 | } |
125 | } |
148 | |
126 | |
|
|
127 | sub config_dialog { |
|
|
128 | my $dialog = new CFClient::UI::FancyFrame x => 300, y => 100, |
|
|
129 | child => (my $vbox = new CFClient::UI::VBox); |
|
|
130 | $vbox->add (new CFClient::UI::Label align => 0, text => "Setup"); |
|
|
131 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
|
|
132 | |
|
|
133 | $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode"); |
|
|
134 | $table->add (1, 0, my $hbox = new CFClient::UI::HBox); |
|
|
135 | |
|
|
136 | $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]); |
|
|
137 | $hbox->add (my $mode_label = new CFClient::UI::Label height => $FONTSIZE * 0.8); |
|
|
138 | |
|
|
139 | $mode_slider->connect (changed => sub { |
|
|
140 | my ($self, $value) = @_; |
|
|
141 | |
|
|
142 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
|
|
143 | $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); |
|
|
144 | }); |
|
|
145 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
|
|
146 | |
|
|
147 | $table->add (0, 1, new CFClient::UI::Label align => 1, text => "Host"); |
|
|
148 | $table->add (1, 1, my $host = new CFClient::UI::Entry text => $CFG->{host}); |
|
|
149 | |
|
|
150 | $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Port"); |
|
|
151 | $table->add (1, 2, my $port = new CFClient::UI::Entry text => $CFG->{port}); |
|
|
152 | |
|
|
153 | $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Username"); |
|
|
154 | $table->add (1, 3, my $user = new CFClient::UI::Entry text => $CFG->{user}); |
|
|
155 | |
|
|
156 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Password"); |
|
|
157 | $table->add (1, 4, my $pass = new CFClient::UI::Entry text => $CFG->{password}, hidden => 1); |
|
|
158 | |
|
|
159 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Map Size"); |
|
|
160 | $table->add (1, 5, new CFClient::UI::Slider |
|
|
161 | req_w => 100, |
|
|
162 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
|
|
163 | connect_changed => sub { |
|
|
164 | my ($self, $value) = @_; |
|
|
165 | |
|
|
166 | $CFG->{mapsize} = $self->{range}[0] = $value = int $value; |
|
|
167 | }, |
|
|
168 | ); |
|
|
169 | |
|
|
170 | $vbox->add (my $hbox = new CFClient::UI::HBox); |
|
|
171 | $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub { |
|
|
172 | warn "save\n"; |
|
|
173 | }); |
|
|
174 | $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub { |
|
|
175 | warn "login\n"; |
|
|
176 | }); |
|
|
177 | $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
|
|
178 | warn "apply\n"; |
|
|
179 | }); |
|
|
180 | |
|
|
181 | $CFClient::UI::TOPLEVEL->add ($dialog); |
|
|
182 | } |
|
|
183 | |
149 | sub start_game { |
184 | sub start_game { |
150 | $WIDTH = $CFG->{width}; |
185 | $WIDTH = $CFG->{width}; |
151 | $HEIGHT = $CFG->{height}; |
186 | $HEIGHT = $CFG->{height}; |
152 | $FULLSCREEN = 0; |
187 | $FULLSCREEN = 0; |
153 | |
188 | |
154 | init_screen; |
189 | init_screen; |
|
|
190 | |
|
|
191 | config_dialog; |
155 | |
192 | |
156 | my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
193 | my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
157 | |
194 | |
158 | $CONN = new conn |
195 | $CONN = new conn |
159 | host => $CFG->{host}, |
196 | host => $CFG->{host}, |
… | |
… | |
162 | pass => $CFG->{password}, |
199 | pass => $CFG->{password}, |
163 | mapw => $mapsize, |
200 | mapw => $mapsize, |
164 | maph => $mapsize, |
201 | maph => $mapsize, |
165 | ; |
202 | ; |
166 | |
203 | |
167 | Crossfire::Client::lowdelay fileno $CONN->{fh}; |
204 | CFClient::lowdelay fileno $CONN->{fh}; |
168 | } |
205 | } |
169 | |
206 | |
170 | sub stop_game { |
207 | sub stop_game { |
171 | remove Glib::Source $refresh_handler if $refresh_handler; |
208 | remove Glib::Source $refresh_handler if $refresh_handler; |
172 | undef $refresh_handler; |
209 | undef $refresh_handler; |
… | |
… | |
180 | |
217 | |
181 | glMatrixMode GL_PROJECTION; |
218 | glMatrixMode GL_PROJECTION; |
182 | glLoadIdentity; |
219 | glLoadIdentity; |
183 | glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000; |
220 | glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000; |
184 | glMatrixMode GL_MODELVIEW; |
221 | glMatrixMode GL_MODELVIEW; |
|
|
222 | glLoadIdentity; |
185 | |
223 | |
186 | glClear GL_COLOR_BUFFER_BIT; |
224 | glClear GL_COLOR_BUFFER_BIT; |
187 | |
225 | |
188 | $Crossfire::Client::Widget::TOPLEVEL->draw; |
226 | $CFClient::UI::TOPLEVEL->draw; |
189 | |
227 | |
190 | SDL::GLSwapBuffers; |
228 | SDL::GLSwapBuffers; |
191 | } |
229 | } |
192 | |
230 | |
193 | sub debug { |
231 | sub debug { |
194 | $DEBUG_STATUS->set_text ($_[0]); |
232 | $DEBUG_STATUS->set_text ($_[0]); |
195 | $DEBUG_STATUS->size_allocate ($DEBUG_STATUS->size_request); |
233 | my ($w, $h) = $DEBUG_STATUS->size_request; |
196 | $DEBUG_STATUS->move ($WIDTH - $DEBUG_STATUS->{w}, 0); |
234 | $DEBUG_STATUS->size_allocate ($WIDTH - $w, 0, $w, $h); |
197 | } |
235 | } |
198 | |
236 | |
199 | my $FPS; |
237 | my $FPS; |
200 | |
238 | |
201 | sub refresh { |
239 | sub refresh { |
202 | $refresh_handler ||= add Glib::Idle sub { |
240 | $refresh_handler ||= add Glib::Idle sub { |
203 | if ($SDL_APP) { |
241 | if ($SDL_APP) { |
204 | my $next_refresh = SDL::GetTicks; |
242 | $NOW = SDL::GetTicks; |
205 | |
243 | |
206 | if ($next_refresh - $last_refresh < $TICKS_PER_FRAME) { |
244 | if ($NOW - $last_refresh < $TICKS_PER_FRAME) { |
207 | SDL::Delay $TICKS_PER_FRAME - ($next_refresh - $last_refresh); |
245 | SDL::Delay $TICKS_PER_FRAME - ($NOW - $last_refresh); |
208 | $next_refresh = SDL::GetTicks; |
246 | $NOW = SDL::GetTicks; |
209 | } |
247 | } |
210 | |
248 | |
211 | my $interval = ($next_refresh - $last_refresh) * 0.001; |
249 | my $interval = ($NOW - $last_refresh) * 0.001; |
212 | $last_refresh = $next_refresh; |
250 | $last_refresh = $NOW; |
213 | |
251 | |
214 | if ($interval) { |
252 | if ($interval) { |
215 | $FPS ||= 1 / $interval; |
253 | $FPS ||= 1 / $interval; |
216 | $FPS = $FPS * 0.96 + (1 / $interval) * 0.04; |
254 | $FPS = $FPS * 0.9 + (1 / $interval) * 0.1; |
217 | debug sprintf "%5.02f\n", $FPS; |
255 | debug sprintf "%5.02f", $FPS; |
218 | } |
256 | } |
219 | |
257 | |
220 | force_refresh; |
258 | force_refresh; |
221 | $_->animate ($interval) for grep $_, values %ANIMATE; |
259 | $_->animate ($interval) for grep $_, values %ANIMATE; |
222 | |
260 | |
… | |
… | |
259 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
297 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
260 | # alt-enter |
298 | # alt-enter |
261 | $FULLSCREEN = !$FULLSCREEN; |
299 | $FULLSCREEN = !$FULLSCREEN; |
262 | init_screen; |
300 | init_screen; |
263 | } else { |
301 | } else { |
264 | Crossfire::Client::Widget::feed_sdl_key_down_event ($SDL_EV); |
302 | CFClient::UI::feed_sdl_key_down_event ($SDL_EV); |
265 | } |
303 | } |
266 | }, |
304 | }, |
267 | SDL_KEYUP() => sub { |
305 | SDL_KEYUP() => sub { |
268 | Crossfire::Client::Widget::feed_sdl_key_up_event ($SDL_EV); |
306 | CFClient::UI::feed_sdl_key_up_event ($SDL_EV); |
269 | }, |
307 | }, |
270 | SDL_MOUSEMOTION() => sub { |
308 | SDL_MOUSEMOTION() => sub { |
271 | Crossfire::Client::Widget::feed_sdl_motion_event ($SDL_EV); |
309 | CFClient::UI::feed_sdl_motion_event ($SDL_EV); |
272 | }, |
310 | }, |
273 | SDL_MOUSEBUTTONDOWN() => sub { |
311 | SDL_MOUSEBUTTONDOWN() => sub { |
274 | Crossfire::Client::Widget::feed_sdl_button_down_event ($SDL_EV); |
312 | CFClient::UI::feed_sdl_button_down_event ($SDL_EV); |
275 | }, |
313 | }, |
276 | SDL_MOUSEBUTTONUP() => sub { |
314 | SDL_MOUSEBUTTONUP() => sub { |
277 | Crossfire::Client::Widget::feed_sdl_button_up_event ($SDL_EV); |
315 | CFClient::UI::feed_sdl_button_up_event ($SDL_EV); |
278 | }, |
316 | }, |
279 | SDL_ACTIVEEVENT() => sub { |
317 | SDL_ACTIVEEVENT() => sub { |
280 | printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
318 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
281 | }, |
319 | }, |
282 | ); |
320 | ); |
283 | |
321 | |
284 | @conn::ISA = Crossfire::Protocol::; |
322 | @conn::ISA = Crossfire::Protocol::; |
285 | |
323 | |
286 | sub conn::map_update { |
324 | sub conn::map_update { |
287 | my ($self, $dirty) = @_; |
325 | my ($self, $dirty) = @_; |
288 | |
326 | |
289 | refresh; |
327 | $MAPWIDGET->update; |
290 | } |
328 | } |
291 | |
329 | |
292 | sub conn::map_scroll { |
330 | sub conn::map_scroll { |
293 | my ($self, $dx, $dy) = @_; |
331 | my ($self, $dx, $dy) = @_; |
294 | |
332 | |
… | |
… | |
310 | sub conn::face_update { |
348 | sub conn::face_update { |
311 | my ($self, $face) = @_; |
349 | my ($self, $face) = @_; |
312 | |
350 | |
313 | $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; |
351 | $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; |
314 | |
352 | |
315 | $face->{texture} = new_from_image Crossfire::Client::Texture delete $face->{image}; |
353 | $face->{texture} = new_from_image CFClient::Texture delete $face->{image}; |
316 | } |
354 | } |
317 | |
355 | |
318 | sub conn::query { |
356 | sub conn::query { |
319 | my ($self, $flags, $prompt) = @_; |
357 | my ($self, $flags, $prompt) = @_; |
320 | |
358 | |
… | |
… | |
356 | [qw/Password password/], |
394 | [qw/Password password/], |
357 | ); |
395 | ); |
358 | |
396 | |
359 | my $cfg = {}; |
397 | my $cfg = {}; |
360 | |
398 | |
361 | my $a = SDL::ListModes (0, SDL_FULLSCREEN|SDL_HWSURFACE); |
|
|
362 | my @modes = map { [SDL::RectW ($_), SDL::RectH ($_)] } @$a; |
|
|
363 | |
|
|
364 | $w->add (my $vb = Gtk2::VBox->new); |
399 | $w->add (my $vb = Gtk2::VBox->new); |
365 | $vb->pack_start (my $t = Gtk2::Table->new (2, scalar @cfg), 0, 0, 0); |
400 | $vb->pack_start (my $t = Gtk2::Table->new (2, scalar @cfg), 0, 0, 0); |
366 | my $selmode = $::CFG->{width} . 'x' . $::CFG->{height}; |
401 | my $selmode = $::CFG->{width} . 'x' . $::CFG->{height}; |
367 | $t->attach_defaults (Gtk2::Label->new ("Modes"), 0, 1, 0, 1); |
402 | $t->attach_defaults (Gtk2::Label->new ("Modes"), 0, 1, 0, 1); |
368 | $t->attach_defaults (my $cb = Gtk2::ComboBox->new_text, 1, 2, 0, 1); |
403 | $t->attach_defaults (my $cb = Gtk2::ComboBox->new_text, 1, 2, 0, 1); |
369 | my $i = 0; |
404 | my $i = 0; |
370 | my $act = 0; |
405 | my $act = 0; |
371 | for (map { "$_->[0]x$_->[1]" } reverse @modes) { |
406 | for (map { "$_->[0]x$_->[1]" } @SDL_MODES) { |
372 | if ($_ eq $selmode) { $act = $i } |
407 | if ($_ eq $selmode) { $act = $i } |
373 | $cb->append_text ($_); |
408 | $cb->append_text ($_); |
374 | $i++; |
409 | $i++; |
375 | } |
410 | } |
376 | $cb->set_active ($act); |
411 | $cb->set_active ($act); |
… | |
… | |
393 | $cb->signal_connect (clicked => sub { |
428 | $cb->signal_connect (clicked => sub { |
394 | for (keys %$cfg) { |
429 | for (keys %$cfg) { |
395 | $::CFG->{$_} = $cfg->{$_} |
430 | $::CFG->{$_} = $cfg->{$_} |
396 | if $_ ne '_i'; |
431 | if $_ ne '_i'; |
397 | } |
432 | } |
398 | Crossfire::Client::write_cfg "$Crossfire::VARDIR/pclientrc"; |
433 | CFClient::write_cfg "$CFrossfire::VARDIR/pclientrc"; |
399 | }); |
434 | }); |
400 | $hb->pack_start (my $cb = Gtk2::Button->new ("login"), 1, 1, 5); |
435 | $hb->pack_start (my $cb = Gtk2::Button->new ("login"), 1, 1, 5); |
401 | $cb->signal_connect (clicked => sub { |
436 | $cb->signal_connect (clicked => sub { |
402 | for (keys %$cfg) { |
437 | for (keys %$cfg) { |
403 | $::CFG->{$_} = $cfg->{$_} |
438 | $::CFG->{$_} = $cfg->{$_} |
… | |
… | |
422 | |
457 | |
423 | ############################################################################# |
458 | ############################################################################# |
424 | |
459 | |
425 | SDL::Init SDL_INIT_EVERYTHING; |
460 | SDL::Init SDL_INIT_EVERYTHING; |
426 | |
461 | |
427 | my $mapwidget = Crossfire::Client::Widget::MapWidget->new; |
462 | @SDL_MODES = reverse map [SDL::RectW ($_), SDL::RectH ($_)], |
|
|
463 | @{ SDL::ListModes 0, SDL_FULLSCREEN|SDL_HWSURFACE }; |
428 | |
464 | |
429 | $Crossfire::Client::Widget::TOPLEVEL->add ($mapwidget); |
|
|
430 | $mapwidget->focus_in; |
|
|
431 | |
|
|
432 | Crossfire::Client::read_cfg "$Crossfire::VARDIR/pclientrc"; |
465 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
433 | |
466 | |
434 | $CFG ||= { |
467 | $CFG ||= { |
435 | width => 640, |
468 | width => 640, |
436 | height => 480, |
469 | height => 480, |
437 | mapsize => 100, |
470 | mapsize => 100, |
… | |
… | |
439 | host => "crossfire.schmorp.de", |
472 | host => "crossfire.schmorp.de", |
440 | port => 13327, |
473 | port => 13327, |
441 | }; |
474 | }; |
442 | |
475 | |
443 | { |
476 | { |
444 | my @fonts = map Crossfire::Client::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); |
477 | my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); |
445 | |
478 | |
446 | Crossfire::Client::add_font $_ for @fonts; |
479 | CFClient::add_font $_ for @fonts; |
447 | Crossfire::Client::set_font $fonts[0]; |
480 | CFClient::set_font $fonts[0]; |
448 | } |
481 | } |
449 | |
482 | |
450 | $FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; |
483 | $FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; |
451 | |
484 | |
452 | run_config_dialog |
485 | run_config_dialog |