… | |
… | |
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 | |
20 | use Crossfire::Client::Widget; |
19 | use CFClient; |
|
|
20 | use CFClient::UI; |
|
|
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 $UIFONT; |
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; |
|
|
47 | our $STATUS_LINE; |
|
|
48 | our $DEBUG_STATUS; |
45 | |
49 | |
46 | our $tw; |
50 | my $last_refresh; |
|
|
51 | my %ANIMATE; |
|
|
52 | my $refresh_handler; |
|
|
53 | |
|
|
54 | our ($tw, $te); # Test widget #d# |
47 | |
55 | |
48 | sub init_screen { |
56 | sub init_screen { |
49 | $SDL_APP = new SDL::App |
57 | $SDL_APP = new SDL::App |
50 | -flags => SDL_ANYFORMAT | SDL_HWSURFACE, |
58 | -flags => SDL_ANYFORMAT | SDL_HWSURFACE, |
51 | -title => "Crossfire+ Client", |
59 | -title => "Crossfire+ Client", |
52 | -width => $WIDTH, |
60 | -width => $WIDTH, |
53 | -height => $HEIGHT, |
61 | -height => $HEIGHT, |
54 | -opengl => 1, |
62 | -opengl => 1, |
55 | -red_size => 8, |
63 | -red_size => 5, |
56 | -green_size => 8, |
64 | -green_size => 5, |
57 | -blue_size => 8, |
65 | -blue_size => 5, |
|
|
66 | -alpha_size => 0, |
58 | -double_buffer => 1, |
67 | -double_buffer => 1, |
59 | -fullscreen => $FULLSCREEN, |
68 | -fullscreen => $FULLSCREEN, |
60 | -resizeable => 0; |
69 | -resizeable => 0; |
61 | |
70 | |
62 | %GL_EXT = map +($_ => 1), split /\s+/, Crossfire::Client::gl_extensions; |
71 | $SDL_EV = new SDL::Event; |
|
|
72 | $SDL_EV->set_unicode (1); |
63 | |
73 | |
64 | $GL_EXT{GL_ARB_texture_non_power_of_two} |
74 | $SDL_TIMER = add Glib::Timeout 1000/50, sub { |
65 | or warn "WARNING: non-power-of-two opengl extension required"; |
75 | ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->() |
|
|
76 | while $SDL_EV->poll; |
66 | |
77 | |
67 | $UIFONT = SDL::TTFOpenFont Crossfire::Client::find_rcfile "uifont.ttf", $HEIGHT / 40 |
78 | 1 |
68 | or die "TTFOpenFont: $!"; |
79 | }; |
69 | |
80 | |
70 | $ALT_ENTER_MESSAGE = new Crossfire::Client::Widget::Label 0, $HEIGHT - $HEIGHT / 40, 10, $UIFONT, "Alt-Enter toggles fullscreen mode"; |
81 | $last_refresh = SDL::GetTicks; |
71 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - ($ALT_ENTER_MESSAGE->size_request)[1]); |
|
|
72 | $ALT_ENTER_MESSAGE->activate; |
|
|
73 | |
82 | |
74 | $tw = new Crossfire::Client::Widget::Window; |
83 | CFClient::gl_init; |
75 | $tw->add (my $lbl = new Crossfire::Client::Widget::Label 0, $HEIGHT - $HEIGHT / 40, 10, $UIFONT, "Foo in the garden!"); |
|
|
76 | # $tw = new Crossfire::Client::Widget::Label 0, $HEIGHT - $HEIGHT / 40, 10, $UIFONT, "Foo in the garden!"; |
|
|
77 | |
84 | |
78 | $tw->move (0, $HEIGHT - 50); |
85 | $FONTSIZE = int $HEIGHT / 50; |
79 | $tw->activate; |
|
|
80 | |
86 | |
|
|
87 | ############################################################################# |
|
|
88 | |
81 | glClearColor 0, 0, 0, 0; |
89 | glClearColor 0.45, 0.45, 0.45, 1; |
82 | |
90 | |
83 | glEnable GL_TEXTURE_2D; |
91 | glEnable GL_TEXTURE_2D; |
|
|
92 | glEnable GL_COLOR_MATERIAL; |
84 | glShadeModel GL_FLAT; |
93 | glShadeModel GL_FLAT; |
85 | glDisable GL_DEPTH_TEST; |
94 | glDisable GL_DEPTH_TEST; |
86 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
95 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
87 | |
96 | |
88 | glMatrixMode GL_PROJECTION; |
97 | ############################################################################# |
89 | glLoadIdentity; |
|
|
90 | glOrtho 0, $WIDTH, $HEIGHT, 0, -100 , 100; |
|
|
91 | |
98 | |
92 | glMatrixMode GL_MODELVIEW; |
99 | $DEBUG_STATUS = new CFClient::UI::Label; |
|
|
100 | $CFClient::UI::TOPLEVEL->add ($DEBUG_STATUS); |
|
|
101 | |
|
|
102 | $STATUS_LINE = new CFClient::UI::Label |
|
|
103 | y => $HEIGHT * 59 / 60 - $FONTSIZE; |
|
|
104 | $CFClient::UI::TOPLEVEL->add ($STATUS_LINE); |
93 | |
105 | |
94 | $_->() for @GL_INIT; |
106 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
|
|
107 | y => $HEIGHT * 59 / 60, |
|
|
108 | height => $HEIGHT / 60, |
|
|
109 | text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
|
|
110 | $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE); |
|
|
111 | |
|
|
112 | $MAPWIDGET = new CFClient::UI::MapWidget; |
|
|
113 | $CFClient::UI::TOPLEVEL->add ($MAPWIDGET); |
|
|
114 | $MAPWIDGET->focus_in; |
|
|
115 | } |
|
|
116 | |
|
|
117 | sub destroy_screen { |
|
|
118 | remove Glib::Source $SDL_TIMER; |
|
|
119 | undef $SDL_APP; |
|
|
120 | undef $SDL_EV; |
|
|
121 | SDL::Quit; |
|
|
122 | } |
|
|
123 | |
|
|
124 | sub config_dialog { |
|
|
125 | my $dialog = new CFClient::UI::FancyFrame x => 300, y => 100, |
|
|
126 | child => (my $vbox = new CFClient::UI::VBox); |
|
|
127 | $vbox->add (new CFClient::UI::Label align => 0, text => "Setup"); |
|
|
128 | $vbox->add (my $table = new CFClient::UI::Table); |
|
|
129 | |
|
|
130 | $table->add (0, 0, new CFClient::UI::Label text => "Video Mode"); |
|
|
131 | $table->add (0, 1, new CFClient::UI::Label text => "Host"); |
|
|
132 | $table->add (0, 2, new CFClient::UI::Label text => "Port"); |
|
|
133 | $table->add (0, 3, new CFClient::UI::Label text => "Username"); |
|
|
134 | $table->add (0, 4, new CFClient::UI::Label text => "Password", hidden => 1); |
|
|
135 | $table->add (0, 5, new CFClient::UI::Label text => "Server Map Size"); |
|
|
136 | |
|
|
137 | $CFClient::UI::TOPLEVEL->add ($dialog); |
95 | } |
138 | } |
96 | |
139 | |
97 | sub start_game { |
140 | sub start_game { |
98 | $SDL_TIMER = add Glib::Timeout 1000/100, sub { |
|
|
99 | ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->() |
|
|
100 | while $SDL_EV->poll; |
|
|
101 | |
|
|
102 | 1 |
|
|
103 | }; |
|
|
104 | |
|
|
105 | $WIDTH = $CFG->{width}; |
141 | $WIDTH = $CFG->{width}; |
106 | $HEIGHT = $CFG->{height}; |
142 | $HEIGHT = $CFG->{height}; |
107 | $FULLSCREEN = 0; |
143 | $FULLSCREEN = 0; |
108 | |
144 | |
109 | init_screen; |
145 | init_screen; |
|
|
146 | |
|
|
147 | config_dialog; |
|
|
148 | |
|
|
149 | my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
110 | |
150 | |
111 | $CONN = new conn |
151 | $CONN = new conn |
112 | host => $CFG->{host}, |
152 | host => $CFG->{host}, |
113 | port => $CFG->{port}, |
153 | port => $CFG->{port}, |
114 | user => $CFG->{user}, |
154 | user => $CFG->{user}, |
115 | pass => $CFG->{password}; |
155 | pass => $CFG->{password}, |
|
|
156 | mapw => $mapsize, |
|
|
157 | maph => $mapsize, |
|
|
158 | ; |
|
|
159 | |
|
|
160 | CFClient::lowdelay fileno $CONN->{fh}; |
116 | } |
161 | } |
117 | |
162 | |
118 | sub stop_game { |
163 | sub stop_game { |
119 | remove Glib::Source $SDL_TIMER; |
164 | remove Glib::Source $refresh_handler if $refresh_handler; |
|
|
165 | undef $refresh_handler; |
120 | |
166 | |
121 | undef $SDL_APP; |
167 | undef $CONN; |
122 | SDL::Quit; |
168 | destroy_screen; |
123 | } |
169 | } |
124 | |
|
|
125 | |
170 | |
126 | sub force_refresh { |
171 | sub force_refresh { |
127 | glViewport 0, 0, $WIDTH, $HEIGHT; |
172 | glViewport 0, 0, $WIDTH, $HEIGHT; |
|
|
173 | |
|
|
174 | glMatrixMode GL_PROJECTION; |
|
|
175 | glLoadIdentity; |
|
|
176 | glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000; |
|
|
177 | glMatrixMode GL_MODELVIEW; |
|
|
178 | glLoadIdentity; |
|
|
179 | |
128 | glClear GL_COLOR_BUFFER_BIT; |
180 | glClear GL_COLOR_BUFFER_BIT; |
129 | |
181 | |
130 | $_->draw for @Crossfire::Client::Widget::ACTIVE_WIDGETS; |
182 | $CFClient::UI::TOPLEVEL->draw; |
131 | |
183 | |
132 | SDL::GLSwapBuffers; |
184 | SDL::GLSwapBuffers; |
133 | } |
185 | } |
134 | |
186 | |
135 | my $refresh_handler; |
187 | sub debug { |
|
|
188 | $DEBUG_STATUS->set_text ($_[0]); |
|
|
189 | $DEBUG_STATUS->size_allocate ($DEBUG_STATUS->size_request); |
|
|
190 | $DEBUG_STATUS->move ($WIDTH - $DEBUG_STATUS->{w}, 0); |
|
|
191 | } |
|
|
192 | |
|
|
193 | my $FPS; |
136 | |
194 | |
137 | sub refresh { |
195 | sub refresh { |
138 | $refresh_handler ||= add Glib::Idle sub { |
196 | $refresh_handler ||= add Glib::Idle sub { |
|
|
197 | if ($SDL_APP) { |
|
|
198 | $NOW = SDL::GetTicks; |
|
|
199 | |
|
|
200 | if ($NOW - $last_refresh < $TICKS_PER_FRAME) { |
|
|
201 | SDL::Delay $TICKS_PER_FRAME - ($NOW - $last_refresh); |
|
|
202 | $NOW = SDL::GetTicks; |
|
|
203 | } |
|
|
204 | |
|
|
205 | my $interval = ($NOW - $last_refresh) * 0.001; |
|
|
206 | $last_refresh = $NOW; |
|
|
207 | |
|
|
208 | if ($interval) { |
|
|
209 | $FPS ||= 1 / $interval; |
|
|
210 | $FPS = $FPS * 0.96 + (1 / $interval) * 0.04; |
|
|
211 | debug sprintf "%5.02f", $FPS; |
|
|
212 | } |
|
|
213 | |
139 | force_refresh; |
214 | force_refresh; |
|
|
215 | $_->animate ($interval) for grep $_, values %ANIMATE; |
|
|
216 | |
|
|
217 | if (%ANIMATE) { |
|
|
218 | 1 |
|
|
219 | } else { |
|
|
220 | undef $refresh_handler; |
|
|
221 | 0 |
|
|
222 | } |
|
|
223 | } else { |
140 | undef $refresh_handler; |
224 | undef $refresh_handler; |
|
|
225 | 0 |
141 | 0 |
226 | } |
142 | }; |
227 | }; |
|
|
228 | } |
|
|
229 | |
|
|
230 | sub animation_start { |
|
|
231 | my ($widget) = @_; |
|
|
232 | $ANIMATE{$widget} = $widget; |
|
|
233 | Scalar::Util::weaken $ANIMATE{$widget}; |
|
|
234 | |
|
|
235 | refresh; |
|
|
236 | } |
|
|
237 | |
|
|
238 | sub animation_stop { |
|
|
239 | my ($widget) = @_; |
|
|
240 | delete $ANIMATE{$widget}; |
143 | } |
241 | } |
144 | |
242 | |
145 | %SDL_CB = ( |
243 | %SDL_CB = ( |
146 | SDL_QUIT() => sub { |
244 | SDL_QUIT() => sub { |
147 | main_quit Gtk2; |
245 | main_quit Gtk2; |
… | |
… | |
155 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
253 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
156 | # alt-enter |
254 | # alt-enter |
157 | $FULLSCREEN = !$FULLSCREEN; |
255 | $FULLSCREEN = !$FULLSCREEN; |
158 | init_screen; |
256 | init_screen; |
159 | } else { |
257 | } else { |
160 | Crossfire::Client::Widget::feed_sdl_key_down_event ($SDL_EV); |
258 | CFClient::UI::feed_sdl_key_down_event ($SDL_EV); |
161 | } |
259 | } |
162 | }, |
260 | }, |
163 | SDL_KEYUP() => sub { |
261 | SDL_KEYUP() => sub { |
164 | Crossfire::Client::Widget::feed_sdl_key_up_event ($SDL_EV); |
262 | CFClient::UI::feed_sdl_key_up_event ($SDL_EV); |
165 | }, |
263 | }, |
166 | SDL_MOUSEMOTION() => sub { |
264 | SDL_MOUSEMOTION() => sub { |
167 | warn "sdl motion\n";#d# |
265 | CFClient::UI::feed_sdl_motion_event ($SDL_EV); |
168 | }, |
266 | }, |
169 | SDL_MOUSEBUTTONDOWN() => sub { |
267 | SDL_MOUSEBUTTONDOWN() => sub { |
170 | Crossfire::Client::Widget::feed_sdl_button_down_event ($SDL_EV); |
268 | CFClient::UI::feed_sdl_button_down_event ($SDL_EV); |
171 | }, |
269 | }, |
172 | SDL_MOUSEBUTTONUP() => sub { |
270 | SDL_MOUSEBUTTONUP() => sub { |
173 | Crossfire::Client::Widget::feed_sdl_button_up_event ($SDL_EV); |
271 | CFClient::UI::feed_sdl_button_up_event ($SDL_EV); |
174 | }, |
272 | }, |
175 | SDL_ACTIVEEVENT() => sub { |
273 | SDL_ACTIVEEVENT() => sub { |
176 | warn "active\n";#d# |
274 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
177 | }, |
275 | }, |
178 | ); |
276 | ); |
179 | |
277 | |
180 | @conn::ISA = Crossfire::Protocol::; |
278 | @conn::ISA = Crossfire::Protocol::; |
181 | |
279 | |
182 | sub conn::map_update { |
280 | sub conn::map_update { |
183 | my ($self, $dirty) = @_; |
281 | my ($self, $dirty) = @_; |
184 | |
282 | |
185 | refresh; |
283 | $MAPWIDGET->update; |
186 | } |
284 | } |
187 | |
285 | |
188 | sub conn::map_scroll { |
286 | sub conn::map_scroll { |
189 | my ($self, $dx, $dy) = @_; |
287 | my ($self, $dx, $dy) = @_; |
190 | |
288 | |
191 | refresh; |
289 | # refresh; |
192 | } |
290 | } |
193 | |
291 | |
194 | sub conn::map_clear { |
292 | sub conn::map_clear { |
195 | my ($self) = @_; |
293 | my ($self) = @_; |
196 | |
294 | |
197 | refresh; |
295 | # refresh; |
198 | } |
296 | } |
199 | |
297 | |
200 | sub conn::face_find { |
298 | sub conn::face_find { |
201 | my ($self, $face) = @_; |
299 | my ($self, $face) = @_; |
202 | |
300 | |
… | |
… | |
206 | sub conn::face_update { |
304 | sub conn::face_update { |
207 | my ($self, $face) = @_; |
305 | my ($self, $face) = @_; |
208 | |
306 | |
209 | $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; |
307 | $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; |
210 | |
308 | |
211 | $face->{texture} = new_from_image Crossfire::Client::Texture delete $face->{image}; |
309 | $face->{texture} = new_from_image CFClient::Texture delete $face->{image}; |
|
|
310 | } |
|
|
311 | |
|
|
312 | sub conn::query { |
|
|
313 | my ($self, $flags, $prompt) = @_; |
|
|
314 | |
|
|
315 | warn "<<<<QUERY:$flags:$prompt>>>\n";#d# |
212 | } |
316 | } |
213 | |
317 | |
214 | sub gtk_add_cfg_field { |
318 | sub gtk_add_cfg_field { |
215 | my ($tbl, $cfg, $klbl, $key, $value) = @_; |
319 | my ($tbl, $cfg, $klbl, $key, $value) = @_; |
216 | my $i = $cfg->{_i}++; |
320 | my $i = $cfg->{_i}++; |
… | |
… | |
222 | } |
326 | } |
223 | $ent->set_text ($value); |
327 | $ent->set_text ($value); |
224 | $ent->signal_connect (changed => sub { |
328 | $ent->signal_connect (changed => sub { |
225 | my ($ent) = @_; |
329 | my ($ent) = @_; |
226 | $cfg->{$key} = $ent->get_text; |
330 | $cfg->{$key} = $ent->get_text; |
|
|
331 | # TODO: Mapsize should be a slider in the game gui |
|
|
332 | if ($key eq 'mapsize' and $cfg->{$key} > 100) { |
|
|
333 | $cfg->{$key} = 100; |
|
|
334 | } elsif ($key eq 'mapsize' and $cfg->{$key} < 50) { |
|
|
335 | $cfg->{$key} = 50; |
|
|
336 | } |
227 | }); |
337 | }); |
228 | } |
338 | } |
229 | |
339 | |
230 | sub run_config_dialog { |
340 | sub run_config_dialog { |
231 | my (%events) = @_; |
341 | my (%events) = @_; |
… | |
… | |
233 | my $w = Gtk2::Window->new; |
343 | my $w = Gtk2::Window->new; |
234 | |
344 | |
235 | my @cfg = ( |
345 | my @cfg = ( |
236 | [qw/Host host/], |
346 | [qw/Host host/], |
237 | [qw/Port port/], |
347 | [qw/Port port/], |
|
|
348 | [qw/Mapsize% mapsize/], |
238 | [qw/Username user/], |
349 | [qw/Username user/], |
239 | [qw/Password password/], |
350 | [qw/Password password/], |
240 | ); |
351 | ); |
241 | |
352 | |
242 | my $cfg = {}; |
353 | my $cfg = {}; |
… | |
… | |
276 | $cb->signal_connect (clicked => sub { |
387 | $cb->signal_connect (clicked => sub { |
277 | for (keys %$cfg) { |
388 | for (keys %$cfg) { |
278 | $::CFG->{$_} = $cfg->{$_} |
389 | $::CFG->{$_} = $cfg->{$_} |
279 | if $_ ne '_i'; |
390 | if $_ ne '_i'; |
280 | } |
391 | } |
281 | Crossfire::Client::write_cfg "$Crossfire::VARDIR/pclientrc"; |
392 | CFClient::write_cfg "$CFrossfire::VARDIR/pclientrc"; |
282 | }); |
393 | }); |
283 | $hb->pack_start (my $cb = Gtk2::Button->new ("login"), 1, 1, 5); |
394 | $hb->pack_start (my $cb = Gtk2::Button->new ("login"), 1, 1, 5); |
284 | $cb->signal_connect (clicked => sub { |
395 | $cb->signal_connect (clicked => sub { |
285 | for (keys %$cfg) { |
396 | for (keys %$cfg) { |
286 | $::CFG->{$_} = $cfg->{$_} |
397 | $::CFG->{$_} = $cfg->{$_} |
… | |
… | |
289 | my $cb = $events{login} || sub {}; |
400 | my $cb = $events{login} || sub {}; |
290 | $cb->($::CFG->{user}, $::CFG->{password}); |
401 | $cb->($::CFG->{user}, $::CFG->{password}); |
291 | }); |
402 | }); |
292 | $hb->pack_start (my $cb = Gtk2::Button->new ("logout"), 1, 1, 5); |
403 | $hb->pack_start (my $cb = Gtk2::Button->new ("logout"), 1, 1, 5); |
293 | $cb->signal_connect (clicked => sub { |
404 | $cb->signal_connect (clicked => sub { |
294 | my $cb = $events{login} || sub {}; |
405 | my $cb = $events{logout} || sub {}; |
295 | $cb->(); |
406 | $cb->(); |
296 | }); |
407 | }); |
297 | $hb->pack_start (my $cb = Gtk2::Button->new ("quit"), 1, 1, 5); |
408 | $hb->pack_start (my $cb = Gtk2::Button->new ("quit"), 1, 1, 5); |
298 | $cb->signal_connect (clicked => sub { $w->destroy }); |
409 | $cb->signal_connect (clicked => sub { $w->destroy }); |
299 | |
410 | |
… | |
… | |
304 | |
415 | |
305 | |
416 | |
306 | ############################################################################# |
417 | ############################################################################# |
307 | |
418 | |
308 | SDL::Init SDL_INIT_EVERYTHING; |
419 | SDL::Init SDL_INIT_EVERYTHING; |
309 | SDL::TTFInit; |
|
|
310 | |
420 | |
311 | my $mapwidget = Crossfire::Client::Widget::MapWidget->new; |
|
|
312 | |
|
|
313 | $mapwidget->activate; |
|
|
314 | $mapwidget->focus_in; |
|
|
315 | |
|
|
316 | Crossfire::Client::read_cfg "$Crossfire::VARDIR/pclientrc"; |
421 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
317 | |
422 | |
318 | $CFG ||= { |
423 | $CFG ||= { |
319 | width => 640, |
424 | width => 640, |
320 | height => 480, |
425 | height => 480, |
|
|
426 | mapsize => 100, |
321 | fullscreen => 0, |
427 | fullscreen => 0, |
322 | host => "crossfire.schmorp.de", |
428 | host => "crossfire.schmorp.de", |
323 | port => 13327, |
429 | port => 13327, |
324 | }; |
430 | }; |
325 | |
431 | |
|
|
432 | { |
|
|
433 | my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); |
|
|
434 | |
|
|
435 | CFClient::add_font $_ for @fonts; |
|
|
436 | CFClient::set_font $fonts[0]; |
|
|
437 | } |
|
|
438 | |
326 | $FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; |
439 | $FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; |
327 | |
440 | |
328 | run_config_dialog |
441 | run_config_dialog |
329 | login => sub { start_game }, |
442 | login => sub { start_game }, |
330 | logout => sub { stop_game }; |
443 | logout => sub { stop_game }; |