1 | #!/opt/bin/perl |
1 | #!/opt/bin/perl |
2 | |
2 | |
3 | use strict; |
3 | use strict; |
|
|
4 | use utf8; |
4 | |
5 | |
5 | use Glib; |
6 | use Glib; |
6 | use Gtk2 -init; |
7 | use Gtk2 -init; |
7 | |
8 | |
8 | use SDL; |
9 | use SDL; |
… | |
… | |
14 | |
15 | |
15 | use Crossfire; |
16 | use Crossfire; |
16 | use Crossfire::Client; |
17 | use Crossfire::Client; |
17 | use Crossfire::Protocol; |
18 | use Crossfire::Protocol; |
18 | |
19 | |
19 | use Client::Util; |
|
|
20 | use Client::Widget; |
20 | use Crossfire::Client::Widget; |
|
|
21 | |
|
|
22 | our $FACECACHE; |
21 | |
23 | |
22 | our $VERSION = '0.1'; |
24 | our $VERSION = '0.1'; |
|
|
25 | |
|
|
26 | our %GL_EXT; |
23 | |
27 | |
24 | our $CFG; |
28 | our $CFG; |
25 | our $CONN; |
29 | our $CONN; |
|
|
30 | |
|
|
31 | our $WIDTH; |
|
|
32 | our $HEIGHT; |
|
|
33 | our $FULLSCREEN; |
|
|
34 | |
|
|
35 | our $FONTSIZE; |
26 | |
36 | |
27 | our $SDL_TIMER; |
37 | our $SDL_TIMER; |
28 | our $SDL_APP; |
38 | our $SDL_APP; |
29 | our $SDL_EV = new SDL::Event; |
39 | our $SDL_EV = new SDL::Event; |
30 | our %SDL_CB; |
40 | our %SDL_CB; |
31 | |
41 | |
|
|
42 | our @GL_INIT; # hooks called on every gl init |
|
|
43 | |
|
|
44 | our $ALT_ENTER_MESSAGE; |
|
|
45 | |
|
|
46 | our $TOPLEVEL; |
|
|
47 | |
|
|
48 | our $tw; # Test widget #d# |
|
|
49 | |
|
|
50 | my $last_refresh; |
|
|
51 | my %ANIMATE; |
|
|
52 | my $refresh_handler; |
|
|
53 | |
32 | sub init_screen { |
54 | sub init_screen { |
33 | # nuke all gl context data |
|
|
34 | |
|
|
35 | $SDL_APP = new SDL::App |
55 | $SDL_APP = new SDL::App |
36 | -flags => SDL_ANYFORMAT | SDL_HWSURFACE, |
56 | -flags => SDL_ANYFORMAT | SDL_HWSURFACE, |
37 | -title => "Crossfire+ Client", |
57 | -title => "Crossfire+ Client", |
38 | -width => $CFG->{width}, |
58 | -width => $WIDTH, |
39 | -height => $CFG->{height}, |
59 | -height => $HEIGHT, |
40 | -opengl => 1, |
60 | -opengl => 1, |
41 | -red_size => 8, |
61 | -red_size => 8, |
42 | -green_size => 8, |
62 | -green_size => 8, |
43 | -blue_size => 8, |
63 | -blue_size => 8, |
44 | -double_buffer => 1, |
64 | -double_buffer => 1, |
45 | -fullscreen => $CFG->{fullscreen}, |
65 | -fullscreen => $FULLSCREEN, |
46 | -resizeable => 0; |
66 | -resizeable => 0; |
47 | |
67 | |
|
|
68 | $last_refresh = SDL::GetTicks; |
|
|
69 | |
|
|
70 | %GL_EXT = map +($_ => 1), split /\s+/, Crossfire::Client::gl_extensions; |
|
|
71 | |
|
|
72 | $GL_EXT{GL_ARB_texture_non_power_of_two} |
|
|
73 | or warn "WARNING: non-power-of-two opengl extension required"; |
|
|
74 | |
|
|
75 | $FONTSIZE = int $HEIGHT / 50; |
|
|
76 | |
|
|
77 | $ALT_ENTER_MESSAGE = new Crossfire::Client::Widget::Label |
|
|
78 | 0, $FONTSIZE, $HEIGHT - $FONTSIZE, $FONTSIZE, |
|
|
79 | "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
|
|
80 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - ($ALT_ENTER_MESSAGE->size_request)[1]); |
|
|
81 | $TOPLEVEL->add ($ALT_ENTER_MESSAGE); |
|
|
82 | |
|
|
83 | # Test code #d# |
|
|
84 | unless ($tw) { # haha... |
|
|
85 | $tw = new Crossfire::Client::Widget::Animator; |
|
|
86 | my $lbl1 = new Crossfire::Client::Widget::Label |
|
|
87 | 0, 0, 10, $FONTSIZE, "<i>This</i> is a\n<u>TEST</u>!\nOf a themed\nFrame!"; |
|
|
88 | my $lbl2 = new Crossfire::Client::Widget::Label |
|
|
89 | 0, 0, 10, $FONTSIZE, "LBL2"; |
|
|
90 | |
|
|
91 | my $vb = new Crossfire::Client::Widget::VBox; |
|
|
92 | my $f = new Crossfire::Client::Widget::FancyFrame; |
|
|
93 | my $f2 = new Crossfire::Client::Widget::FancyFrame; |
|
|
94 | $f->add ($lbl1); |
|
|
95 | $f2->add ($lbl2); |
|
|
96 | $vb->add ($f); |
|
|
97 | $vb->add ($f2, 1); |
|
|
98 | |
|
|
99 | $tw->add ($vb); |
|
|
100 | $tw->w (400); |
|
|
101 | $tw->h (300); |
|
|
102 | $tw->move ($WIDTH - 200, 0); |
|
|
103 | $tw->moveto (0, 0); |
|
|
104 | $TOPLEVEL->add ($tw); |
|
|
105 | |
|
|
106 | # $f->move ($WIDTH - 200, 0); |
|
|
107 | # $TOPLEVEL->add ($f); |
|
|
108 | } |
|
|
109 | |
|
|
110 | glClearColor 0, 0, 0, 0; |
|
|
111 | |
48 | glEnable GL_TEXTURE_2D; |
112 | glEnable GL_TEXTURE_2D; |
49 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
113 | glEnable GL_COLOR_MATERIAL; |
50 | glShadeModel GL_FLAT; |
114 | glShadeModel GL_FLAT; |
51 | glDisable GL_DEPTH_TEST; |
115 | glDisable GL_DEPTH_TEST; |
52 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
116 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
53 | glEnable GL_BLEND; |
117 | |
|
|
118 | $_->() for @GL_INIT; |
|
|
119 | } |
|
|
120 | |
|
|
121 | sub start_game { |
|
|
122 | $SDL_TIMER = add Glib::Timeout 1000/50, sub { |
|
|
123 | ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->() |
|
|
124 | while $SDL_EV->poll; |
|
|
125 | |
|
|
126 | 1 |
|
|
127 | }; |
|
|
128 | |
|
|
129 | $WIDTH = $CFG->{width}; |
|
|
130 | $HEIGHT = $CFG->{height}; |
|
|
131 | $FULLSCREEN = 0; |
|
|
132 | |
|
|
133 | init_screen; |
|
|
134 | |
|
|
135 | my $mapsize = List::Util::min 64, List::Util::max 11, int $HEIGHT * $CFG->{mapsize} * 0.01 / 32; |
|
|
136 | |
|
|
137 | $CONN = new conn |
|
|
138 | host => $CFG->{host}, |
|
|
139 | port => $CFG->{port}, |
|
|
140 | user => $CFG->{user}, |
|
|
141 | pass => $CFG->{password}, |
|
|
142 | mapw => $mapsize, |
|
|
143 | maph => $mapsize, |
|
|
144 | ; |
|
|
145 | |
|
|
146 | Crossfire::Client::lowdelay fileno $CONN->{fh}; |
|
|
147 | } |
|
|
148 | |
|
|
149 | sub stop_game { |
|
|
150 | remove Glib::Source $SDL_TIMER; |
|
|
151 | remove Glib::Source $refresh_handler; |
|
|
152 | undef $refresh_handler; |
|
|
153 | |
|
|
154 | undef $SDL_APP; |
|
|
155 | undef $CONN; |
|
|
156 | SDL::Quit; |
|
|
157 | } |
|
|
158 | |
|
|
159 | |
|
|
160 | sub force_refresh { |
|
|
161 | glViewport 0, 0, $WIDTH, $HEIGHT; |
54 | |
162 | |
55 | glMatrixMode GL_PROJECTION; |
163 | glMatrixMode GL_PROJECTION; |
56 | glLoadIdentity; |
164 | glLoadIdentity; |
57 | glOrtho 0, $CFG->{width} / 32, $CFG->{height} / 32, 0, -1 , 1; |
165 | glOrtho 0, $WIDTH, $HEIGHT, 0, -6000 , 6000; |
|
|
166 | glMatrixMode GL_MODELVIEW; |
58 | |
167 | |
59 | # re-bind all textures |
168 | glClear GL_COLOR_BUFFER_BIT; |
60 | } |
|
|
61 | |
169 | |
62 | sub start_game { |
170 | $TOPLEVEL->draw; |
63 | $SDL_TIMER = add Glib::Timeout 1000/20, sub { |
171 | |
64 | while ($SDL_EV->poll) { |
172 | SDL::GLSwapBuffers; |
65 | ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->(); |
173 | } |
|
|
174 | |
|
|
175 | sub refresh { |
|
|
176 | $refresh_handler ||= add Glib::Idle sub { |
|
|
177 | return unless $SDL_APP; |
|
|
178 | |
|
|
179 | my $next_refresh = SDL::GetTicks; |
|
|
180 | my $interval = ($next_refresh - $last_refresh) * 0.001; |
|
|
181 | $last_refresh = $next_refresh; |
|
|
182 | |
|
|
183 | force_refresh; |
|
|
184 | $_->animate ($interval) for grep $_, values %ANIMATE; |
|
|
185 | |
|
|
186 | if (%ANIMATE) { |
|
|
187 | 1 |
|
|
188 | } else { |
|
|
189 | undef $refresh_handler; |
|
|
190 | 0 |
66 | } |
191 | } |
67 | |
|
|
68 | 1 |
|
|
69 | }; |
192 | }; |
70 | |
|
|
71 | init_screen; |
|
|
72 | |
|
|
73 | $CONN = new conn |
|
|
74 | host => $CFG->{host}, |
|
|
75 | port => $CFG->{port}; |
|
|
76 | } |
193 | } |
77 | |
194 | |
78 | sub stop_game { |
195 | sub animation_start { |
79 | remove Glib::Source $SDL_TIMER; |
196 | my ($widget) = @_; |
|
|
197 | $ANIMATE{$widget} = $widget; |
|
|
198 | Scalar::Util::weaken $ANIMATE{$widget}; |
80 | |
199 | |
81 | undef $SDL_APP; |
200 | refresh; |
82 | SDL::Quit; |
|
|
83 | } |
201 | } |
84 | |
202 | |
85 | sub refresh { |
203 | sub animation_stop { |
86 | glClearColor 0, 0, 0, 0; |
204 | my ($widget) = @_; |
87 | glClear GL_COLOR_BUFFER_BIT; |
205 | delete $ANIMATE{$widget}; |
88 | |
|
|
89 | my $map = $CONN->{map}; |
|
|
90 | |
|
|
91 | for my $x (0 .. $CONN->{mapw} - 1) { |
|
|
92 | for my $y (0 .. $CONN->{maph} - 1) { |
|
|
93 | |
|
|
94 | my $cell = $map->[$x][$y] |
|
|
95 | or next; |
|
|
96 | |
|
|
97 | my $darkness = $cell->[3] * (1 / 255); |
|
|
98 | glColor $darkness, $darkness, $darkness; |
|
|
99 | |
|
|
100 | for my $num (grep $_, $cell->[0], $cell->[1], $cell->[2]) { |
|
|
101 | my $tex = $CONN->{face}[$num]{texture} || 0; |
|
|
102 | |
|
|
103 | glBindTexture GL_TEXTURE_2D, $tex; |
|
|
104 | |
|
|
105 | glBegin GL_QUADS; |
|
|
106 | glTexCoord 0, 0; glVertex $x, $y; |
|
|
107 | glTexCoord 0, 1; glVertex $x, $y + 1; |
|
|
108 | glTexCoord 1, 1; glVertex $x + 1, $y + 1; |
|
|
109 | glTexCoord 1, 0; glVertex $x + 1, $y; |
|
|
110 | glEnd; |
|
|
111 | } |
|
|
112 | } |
|
|
113 | } |
|
|
114 | |
|
|
115 | SDL::GLSwapBuffers; |
|
|
116 | } |
206 | } |
117 | |
207 | |
118 | %SDL_CB = ( |
208 | %SDL_CB = ( |
119 | SDL_QUIT() => sub { |
209 | SDL_QUIT() => sub { |
120 | warn "sdl quit\n";#d# |
210 | main_quit Gtk2; |
121 | exit; |
|
|
122 | }, |
211 | }, |
123 | SDL_VIDEORESIZE() => sub { |
212 | SDL_VIDEORESIZE() => sub { |
124 | }, |
213 | }, |
125 | SDL_VIDEOEXPOSE() => sub { |
214 | SDL_VIDEOEXPOSE() => sub { |
126 | refresh; |
215 | refresh; |
127 | }, |
216 | }, |
128 | SDL_KEYDOWN() => sub { |
217 | SDL_KEYDOWN() => sub { |
|
|
218 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
|
|
219 | # alt-enter |
|
|
220 | $FULLSCREEN = !$FULLSCREEN; |
|
|
221 | init_screen; |
|
|
222 | } else { |
129 | # Client::Widget::feed_sdl_key_down_event ($SDL_EV); |
223 | Crossfire::Client::Widget::feed_sdl_key_down_event ($SDL_EV); |
|
|
224 | } |
130 | }, |
225 | }, |
131 | SDL_KEYUP() => sub { |
226 | SDL_KEYUP() => sub { |
132 | # Client::Widget::feed_sdl_key_up_event ($SDL_EV); |
227 | Crossfire::Client::Widget::feed_sdl_key_up_event ($SDL_EV); |
133 | }, |
228 | }, |
134 | SDL_MOUSEMOTION() => sub { |
229 | SDL_MOUSEMOTION() => sub { |
135 | warn "sdl motion\n";#d# |
230 | warn "sdl motion\n";#d# |
136 | }, |
231 | }, |
137 | SDL_MOUSEBUTTONDOWN() => sub { |
232 | SDL_MOUSEBUTTONDOWN() => sub { |
138 | # Client::Widget::feed_sdl_button_down_event ($SDL_EV); |
233 | Crossfire::Client::Widget::feed_sdl_button_down_event ($SDL_EV); |
139 | }, |
234 | }, |
140 | SDL_MOUSEBUTTONUP() => sub { |
235 | SDL_MOUSEBUTTONUP() => sub { |
141 | # Client::Widget::feed_sdl_button_up_event ($SDL_EV); |
236 | Crossfire::Client::Widget::feed_sdl_button_up_event ($SDL_EV); |
142 | }, |
237 | }, |
143 | SDL_ACTIVEEVENT() => sub { |
238 | SDL_ACTIVEEVENT() => sub { |
144 | warn "active\n";#d# |
239 | warn "active\n";#d# |
145 | }, |
240 | }, |
146 | ); |
241 | ); |
… | |
… | |
154 | } |
249 | } |
155 | |
250 | |
156 | sub conn::map_scroll { |
251 | sub conn::map_scroll { |
157 | my ($self, $dx, $dy) = @_; |
252 | my ($self, $dx, $dy) = @_; |
158 | |
253 | |
159 | refresh; |
254 | # refresh; |
160 | } |
255 | } |
161 | |
256 | |
162 | sub conn::map_clear { |
257 | sub conn::map_clear { |
163 | my ($self) = @_; |
258 | my ($self) = @_; |
164 | |
259 | |
165 | refresh; |
260 | # refresh; |
|
|
261 | } |
|
|
262 | |
|
|
263 | sub conn::face_find { |
|
|
264 | my ($self, $face) = @_; |
|
|
265 | |
|
|
266 | $FACECACHE->{"$face->{chksum},$face->{name}"} |
166 | } |
267 | } |
167 | |
268 | |
168 | sub conn::face_update { |
269 | sub conn::face_update { |
169 | my ($self, $num, $face) = @_; |
270 | my ($self, $face) = @_; |
170 | |
271 | |
171 | my $pb = new Gtk2::Gdk::PixbufLoader; |
272 | $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; |
172 | $pb->write ($face->{image}); |
|
|
173 | $pb->close; |
|
|
174 | |
273 | |
175 | $pb = $pb->get_pixbuf; |
274 | $face->{texture} = new_from_image Crossfire::Client::Texture delete $face->{image}; |
176 | $pb = $pb->add_alpha (0, 0, 0, 0); |
275 | } |
177 | |
276 | |
178 | glGetError(); |
277 | sub conn::query { |
179 | my ($tex) = @{glGenTextures 1}; |
278 | my ($self, $flags, $prompt) = @_; |
180 | |
279 | |
181 | $face->{texture} = $tex; |
280 | warn "<<<<QUERY:$flags:$prompt>>>\n";#d# |
|
|
281 | } |
|
|
282 | |
|
|
283 | sub gtk_add_cfg_field { |
|
|
284 | my ($tbl, $cfg, $klbl, $key, $value) = @_; |
|
|
285 | my $i = $cfg->{_i}++; |
|
|
286 | $tbl->attach_defaults (my $lbl = Gtk2::Label->new ($klbl), 0, 1, $i, $i + 1); |
|
|
287 | $tbl->attach_defaults (my $ent = Gtk2::Entry->new, 1, 2, $i, $i + 1); |
|
|
288 | if ($key eq 'password') { |
|
|
289 | $ent->set_invisible_char ("*"); |
|
|
290 | $ent->set (visibility => 0) |
|
|
291 | } |
|
|
292 | $ent->set_text ($value); |
|
|
293 | $ent->signal_connect (changed => sub { |
|
|
294 | my ($ent) = @_; |
|
|
295 | $cfg->{$key} = $ent->get_text; |
|
|
296 | # TODO: Mapsize should be a slider in the game gui |
|
|
297 | if ($key eq 'mapsize' and $cfg->{$key} > 100) { |
|
|
298 | $cfg->{$key} = 100; |
|
|
299 | } elsif ($key eq 'mapsize' and $cfg->{$key} < 50) { |
|
|
300 | $cfg->{$key} = 50; |
|
|
301 | } |
|
|
302 | }); |
|
|
303 | } |
|
|
304 | |
|
|
305 | sub run_config_dialog { |
|
|
306 | my (%events) = @_; |
|
|
307 | |
|
|
308 | my $w = Gtk2::Window->new; |
|
|
309 | |
|
|
310 | my @cfg = ( |
|
|
311 | [qw/Host host/], |
|
|
312 | [qw/Port port/], |
|
|
313 | [qw/Mapsize% mapsize/], |
|
|
314 | [qw/Username user/], |
|
|
315 | [qw/Password password/], |
182 | |
316 | ); |
183 | glBindTexture GL_TEXTURE_2D, $tex; |
317 | |
184 | my $glerr=glGetError(); die "a: ".gluErrorString($glerr)."\n" if $glerr; |
318 | my $cfg = {}; |
|
|
319 | |
|
|
320 | my $a = SDL::ListModes (0, SDL_FULLSCREEN|SDL_HWSURFACE); |
|
|
321 | my @modes = map { [SDL::RectW ($_), SDL::RectH ($_)] } @$a; |
|
|
322 | |
|
|
323 | $w->add (my $vb = Gtk2::VBox->new); |
|
|
324 | $vb->pack_start (my $t = Gtk2::Table->new (2, scalar @cfg), 0, 0, 0); |
|
|
325 | my $selmode = $::CFG->{width} . 'x' . $::CFG->{height}; |
|
|
326 | $t->attach_defaults (Gtk2::Label->new ("Modes"), 0, 1, 0, 1); |
|
|
327 | $t->attach_defaults (my $cb = Gtk2::ComboBox->new_text, 1, 2, 0, 1); |
|
|
328 | my $i = 0; |
|
|
329 | my $act = 0; |
|
|
330 | for (map { "$_->[0]x$_->[1]" } reverse @modes) { |
|
|
331 | if ($_ eq $selmode) { $act = $i } |
|
|
332 | $cb->append_text ($_); |
|
|
333 | $i++; |
|
|
334 | } |
|
|
335 | $cb->set_active ($act); |
|
|
336 | $cb->signal_connect (changed => sub { |
|
|
337 | my ($cb) = @_; |
|
|
338 | my $txt = $cb->get_active_text; |
|
|
339 | if ($txt =~ m/(\d+)x(\d+)/) { |
|
|
340 | $::CFG->{width} = $1; |
|
|
341 | $::CFG->{height} = $2; |
185 | |
342 | } |
186 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR; |
343 | }); |
187 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR;#_MIPMAP_LINEAR; |
344 | |
188 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP; |
345 | $cfg->{_i} = 1; |
189 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP; |
346 | for (@cfg) { |
190 | |
347 | gtk_add_cfg_field ($t, $cfg, $_->[0], $_->[1], $::CFG->{$_->[1]}); |
191 | glTexImage2D GL_TEXTURE_2D, 0, |
348 | } |
192 | GL_RGBA8, |
349 | |
193 | $pb->get_width, $pb->get_height, |
350 | $vb->pack_start (my $hb = Gtk2::HBox->new, 0, 0, 0); |
|
|
351 | $hb->pack_start (my $cb = Gtk2::Button->new ("save"), 1, 1, 5); |
|
|
352 | $cb->signal_connect (clicked => sub { |
|
|
353 | for (keys %$cfg) { |
|
|
354 | $::CFG->{$_} = $cfg->{$_} |
|
|
355 | if $_ ne '_i'; |
194 | 0, |
356 | } |
|
|
357 | Crossfire::Client::write_cfg "$Crossfire::VARDIR/pclientrc"; |
|
|
358 | }); |
|
|
359 | $hb->pack_start (my $cb = Gtk2::Button->new ("login"), 1, 1, 5); |
|
|
360 | $cb->signal_connect (clicked => sub { |
|
|
361 | for (keys %$cfg) { |
|
|
362 | $::CFG->{$_} = $cfg->{$_} |
|
|
363 | if $_ ne '_i'; |
195 | GL_RGBA, |
364 | } |
196 | GL_UNSIGNED_BYTE, |
365 | my $cb = $events{login} || sub {}; |
197 | $pb->get_pixels; |
366 | $cb->($::CFG->{user}, $::CFG->{password}); |
198 | my $glerr=glGetError(); die "Problem setting up 2d Texture (dimensions not a power of 2?)):".gluErrorString($glerr)."\n" if $glerr; |
367 | }); |
|
|
368 | $hb->pack_start (my $cb = Gtk2::Button->new ("logout"), 1, 1, 5); |
|
|
369 | $cb->signal_connect (clicked => sub { |
|
|
370 | my $cb = $events{logout} || sub {}; |
|
|
371 | $cb->(); |
|
|
372 | }); |
|
|
373 | $hb->pack_start (my $cb = Gtk2::Button->new ("quit"), 1, 1, 5); |
|
|
374 | $cb->signal_connect (clicked => sub { $w->destroy }); |
|
|
375 | |
|
|
376 | $w->show_all; |
|
|
377 | |
|
|
378 | $w->signal_connect (destroy => sub { Gtk2->main_quit }); |
199 | } |
379 | } |
|
|
380 | |
200 | |
381 | |
201 | ############################################################################# |
382 | ############################################################################# |
202 | |
383 | |
|
|
384 | SDL::Init SDL_INIT_EVERYTHING; |
|
|
385 | |
|
|
386 | $TOPLEVEL = Crossfire::Client::Widget::Toplevel->new; |
|
|
387 | |
|
|
388 | my $mapwidget = Crossfire::Client::Widget::MapWidget->new; |
|
|
389 | |
|
|
390 | $TOPLEVEL->add ($mapwidget); |
|
|
391 | $mapwidget->focus_in; |
|
|
392 | |
203 | Client::Util::read_cfg "$Crossfire::VARDIR/pclientrc"; |
393 | Crossfire::Client::read_cfg "$Crossfire::VARDIR/pclientrc"; |
204 | |
394 | |
205 | $CFG ||= { |
395 | $CFG ||= { |
206 | width => 640, |
396 | width => 640, |
207 | height => 480, |
397 | height => 480, |
|
|
398 | mapsize => 100, |
208 | fullscreen => 0, |
399 | fullscreen => 0, |
209 | host => "crossfire.schmorp.de", |
400 | host => "crossfire.schmorp.de", |
210 | port => 13327, |
401 | port => 13327, |
211 | }; |
402 | }; |
212 | |
403 | |
213 | Client::Util::run_config_dialog |
404 | Crossfire::Client::set_font Crossfire::Client::find_rcfile "uifont.ttf"; |
|
|
405 | |
|
|
406 | $FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; |
|
|
407 | |
|
|
408 | run_config_dialog |
214 | login => sub { start_game }, |
409 | login => sub { start_game }, |
215 | logout => sub { stop_game }, |
410 | logout => sub { stop_game }; |
216 | |
411 | |
217 | main Gtk2; |
412 | main Gtk2; |
|
|
413 | |
|
|
414 | Crossfire::save_ref $FACECACHE, "$Crossfire::VARDIR/pclient.faces"; |