… | |
… | |
22 | |
22 | |
23 | our $VERSION = '0.1'; |
23 | our $VERSION = '0.1'; |
24 | |
24 | |
25 | our $CFG; |
25 | our $CFG; |
26 | our $CONN; |
26 | our $CONN; |
|
|
27 | |
|
|
28 | our $GUIFONT; |
27 | |
29 | |
28 | our $SDL_TIMER; |
30 | our $SDL_TIMER; |
29 | our $SDL_APP; |
31 | our $SDL_APP; |
30 | our $SDL_EV = new SDL::Event; |
32 | our $SDL_EV = new SDL::Event; |
31 | our %SDL_CB; |
33 | our %SDL_CB; |
… | |
… | |
55 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
57 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
56 | glEnable GL_BLEND; |
58 | glEnable GL_BLEND; |
57 | |
59 | |
58 | glMatrixMode GL_PROJECTION; |
60 | glMatrixMode GL_PROJECTION; |
59 | glLoadIdentity; |
61 | glLoadIdentity; |
60 | glOrtho 0, $CFG->{width} / 32, $CFG->{height} / 32, 0, -100 , 100; |
62 | glOrtho 0, $CFG->{width}, $CFG->{height}, 0, -100 , 100; |
61 | |
63 | |
62 | glMatrixMode GL_MODELVIEW; |
64 | glMatrixMode GL_MODELVIEW; |
63 | |
65 | |
64 | $_->() for @GL_INIT; |
66 | $_->() for @GL_INIT; |
65 | } |
67 | } |
|
|
68 | |
|
|
69 | my $label;#d# |
66 | |
70 | |
67 | sub start_game { |
71 | sub start_game { |
68 | $SDL_TIMER = add Glib::Timeout 1000/20, sub { |
72 | $SDL_TIMER = add Glib::Timeout 1000/20, sub { |
69 | while ($SDL_EV->poll) { |
73 | while ($SDL_EV->poll) { |
70 | ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->(); |
74 | ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->(); |
… | |
… | |
72 | |
76 | |
73 | 1 |
77 | 1 |
74 | }; |
78 | }; |
75 | |
79 | |
76 | init_screen; |
80 | init_screen; |
|
|
81 | |
|
|
82 | # $label = new Crossfire::Client::Widget::Label "Testü[]"; |
|
|
83 | # $label->activate; |
77 | |
84 | |
78 | $CONN = new conn |
85 | $CONN = new conn |
79 | host => $CFG->{host}, |
86 | host => $CFG->{host}, |
80 | port => $CFG->{port}; |
87 | port => $CFG->{port}; |
81 | } |
88 | } |
… | |
… | |
256 | } |
263 | } |
257 | |
264 | |
258 | |
265 | |
259 | ############################################################################# |
266 | ############################################################################# |
260 | |
267 | |
261 | SDL::Init(SDL_INIT_EVERYTHING()); |
268 | SDL::Init SDL_INIT_EVERYTHING; |
262 | |
269 | |
263 | my $mapwidget = Crossfire::Client::Widget::MapWidget->new; |
270 | my $mapwidget = Crossfire::Client::Widget::MapWidget->new; |
264 | |
|
|
265 | find_rcfile "uifont.ttf"; |
|
|
266 | |
271 | |
267 | $mapwidget->activate; |
272 | $mapwidget->activate; |
268 | $mapwidget->focus_in; |
273 | $mapwidget->focus_in; |
269 | |
274 | |
270 | Crossfire::Client::read_cfg "$Crossfire::VARDIR/pclientrc"; |
275 | Crossfire::Client::read_cfg "$Crossfire::VARDIR/pclientrc"; |
271 | |
|
|
272 | $FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; |
|
|
273 | |
276 | |
274 | $CFG ||= { |
277 | $CFG ||= { |
275 | width => 640, |
278 | width => 640, |
276 | height => 480, |
279 | height => 480, |
277 | fullscreen => 0, |
280 | fullscreen => 0, |
278 | host => "crossfire.schmorp.de", |
281 | host => "crossfire.schmorp.de", |
279 | port => 13327, |
282 | port => 13327, |
280 | }; |
283 | }; |
281 | |
284 | |
|
|
285 | $FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; |
|
|
286 | |
|
|
287 | SDL::TTFInit; |
|
|
288 | |
|
|
289 | $GUIFONT = SDL::TTFOpenFont Crossfire::Client::find_rcfile "uifont.ttf", 12 |
|
|
290 | or die "TTFOpenFont: $!"; |
|
|
291 | |
282 | run_config_dialog |
292 | run_config_dialog |
283 | login => sub { start_game }, |
293 | login => sub { start_game }, |
284 | logout => sub { stop_game }; |
294 | logout => sub { stop_game }; |
285 | |
295 | |
286 | main Gtk2; |
296 | main Gtk2; |