… | |
… | |
31 | |
31 | |
32 | our $WIDTH; |
32 | our $WIDTH; |
33 | our $HEIGHT; |
33 | our $HEIGHT; |
34 | our $FULLSCREEN; |
34 | our $FULLSCREEN; |
35 | |
35 | |
|
|
36 | our $MAPWIDGET; |
36 | our $FONTSIZE; |
37 | our $FONTSIZE; |
37 | |
38 | |
38 | our $SDL_TIMER; |
39 | our $SDL_TIMER; |
39 | our $SDL_APP; |
40 | our $SDL_APP; |
40 | our $SDL_EV; |
41 | our $SDL_EV; |
… | |
… | |
91 | glDisable GL_DEPTH_TEST; |
92 | glDisable GL_DEPTH_TEST; |
92 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
93 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
93 | |
94 | |
94 | ############################################################################# |
95 | ############################################################################# |
95 | |
96 | |
96 | $DEBUG_STATUS = new CFClient::Widget::Label 0, 0, 1, $FONTSIZE, ""; |
97 | $DEBUG_STATUS = new CFClient::Widget::Label; |
97 | $CFClient::Widget::TOPLEVEL->add ($DEBUG_STATUS); |
98 | $CFClient::Widget::TOPLEVEL->add ($DEBUG_STATUS); |
98 | |
99 | |
99 | $STATUS_LINE = new CFClient::Widget::Label |
100 | $STATUS_LINE = new CFClient::Widget::Label |
100 | 0, $HEIGHT * 59 / 60 - $FONTSIZE, 1, $FONTSIZE, |
101 | y => $HEIGHT * 59 / 60 - $FONTSIZE; |
101 | ""; |
|
|
102 | $CFClient::Widget::TOPLEVEL->add ($STATUS_LINE); |
102 | $CFClient::Widget::TOPLEVEL->add ($STATUS_LINE); |
103 | |
103 | |
104 | $ALT_ENTER_MESSAGE = new CFClient::Widget::Label |
104 | $ALT_ENTER_MESSAGE = new CFClient::Widget::Label |
105 | 0, $HEIGHT * 59 / 60, 1, $HEIGHT / 60, |
105 | y => $HEIGHT * 59 / 60, |
|
|
106 | height => $HEIGHT / 60, |
106 | "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
107 | text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
107 | $CFClient::Widget::TOPLEVEL->add ($ALT_ENTER_MESSAGE); |
108 | $CFClient::Widget::TOPLEVEL->add ($ALT_ENTER_MESSAGE); |
|
|
109 | |
|
|
110 | $MAPWIDGET = new CFClient::Widget::MapWidget; |
|
|
111 | $CFClient::Widget::TOPLEVEL->add ($MAPWIDGET); |
|
|
112 | $MAPWIDGET->focus_in; |
108 | |
113 | |
109 | # Test code #d# |
114 | # Test code #d# |
110 | unless ($tw) { # haha... |
115 | unless ($tw) { # haha... |
111 | $te = new CFClient::Widget::FancyFrame; |
116 | $te = new CFClient::Widget::FancyFrame x => 300, z => 1; |
112 | $te->add (new CFClient::Widget::Entry); |
117 | $te->add (new CFClient::Widget::Entry); |
113 | $te->move (300, 0, 2); |
|
|
114 | $CFClient::Widget::TOPLEVEL->add ($te); |
118 | $CFClient::Widget::TOPLEVEL->add ($te); |
115 | |
119 | |
116 | $tw = new CFClient::Widget::Animator; |
120 | $tw = new CFClient::Widget::Animator x => $WIDTH - 200, w => 600, h => 300; |
117 | my $lbl1 = new CFClient::Widget::Label |
121 | my $lbl1 = new CFClient::Widget::Label text => "<i>This</i> is a\n<u>TEST</u>!\nOf a themed\nFrame!"; |
118 | 0, 0, 10, $FONTSIZE, "<i>This</i> is a\n<u>TEST</u>!\nOf a themed\nFrame!"; |
|
|
119 | my $lbl2 = new CFClient::Widget::Label |
122 | my $lbl2 = new CFClient::Widget::Label text => "LBL2"; |
120 | 0, 0, 10, $FONTSIZE, "LBL2"; |
|
|
121 | |
|
|
122 | my $vb = new CFClient::Widget::VBox; |
123 | my $vb = new CFClient::Widget::VBox; |
123 | my $f = new CFClient::Widget::FancyFrame; |
124 | my $f = new CFClient::Widget::FancyFrame; |
124 | my $f2 = new CFClient::Widget::FancyFrame; |
125 | my $f2 = new CFClient::Widget::FancyFrame; |
125 | $f->add ($lbl1); |
126 | $f->add ($lbl1); |
126 | $f2->add ($lbl2); |
127 | $f2->add ($lbl2); |
127 | $vb->add ($f); |
128 | $vb->add ($f); |
128 | $vb->add ($f2, 1); |
129 | $vb->add ($f2, 1); |
129 | |
130 | |
130 | $tw->add ($vb); |
131 | $tw->add ($vb); |
131 | $tw->w (400); |
|
|
132 | $tw->h (300); |
|
|
133 | $tw->move ($WIDTH - 200, 0); |
|
|
134 | $tw->moveto (0, 0); |
132 | $tw->moveto (0, 0); |
135 | $CFClient::Widget::TOPLEVEL->add ($tw); |
133 | $CFClient::Widget::TOPLEVEL->add ($tw); |
136 | |
134 | |
137 | # $f->move ($WIDTH - 200, 0); |
135 | # $f->move ($WIDTH - 200, 0); |
138 | # $CFClient::Widget::TOPLEVEL->add ($f); |
136 | # $CFClient::Widget::TOPLEVEL->add ($f); |
… | |
… | |
284 | @conn::ISA = Crossfire::Protocol::; |
282 | @conn::ISA = Crossfire::Protocol::; |
285 | |
283 | |
286 | sub conn::map_update { |
284 | sub conn::map_update { |
287 | my ($self, $dirty) = @_; |
285 | my ($self, $dirty) = @_; |
288 | |
286 | |
289 | refresh; |
287 | $MAPWIDGET->update; |
290 | } |
288 | } |
291 | |
289 | |
292 | sub conn::map_scroll { |
290 | sub conn::map_scroll { |
293 | my ($self, $dx, $dy) = @_; |
291 | my ($self, $dx, $dy) = @_; |
294 | |
292 | |
… | |
… | |
422 | |
420 | |
423 | ############################################################################# |
421 | ############################################################################# |
424 | |
422 | |
425 | SDL::Init SDL_INIT_EVERYTHING; |
423 | SDL::Init SDL_INIT_EVERYTHING; |
426 | |
424 | |
427 | my $mapwidget = CFClient::Widget::MapWidget->new; |
|
|
428 | |
|
|
429 | $CFClient::Widget::TOPLEVEL->add ($mapwidget); |
|
|
430 | $mapwidget->focus_in; |
|
|
431 | |
|
|
432 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
425 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
433 | |
426 | |
434 | $CFG ||= { |
427 | $CFG ||= { |
435 | width => 640, |
428 | width => 640, |
436 | height => 480, |
429 | height => 480, |
… | |
… | |
453 | login => sub { start_game }, |
446 | login => sub { start_game }, |
454 | logout => sub { stop_game }; |
447 | logout => sub { stop_game }; |
455 | |
448 | |
456 | main Gtk2; |
449 | main Gtk2; |
457 | |
450 | |
458 | CFsave_ref $FACECACHE, "$Crossfire::VARDIR/pclient.faces"; |
451 | Crossfire::save_ref $FACECACHE, "$Crossfire::VARDIR/pclient.faces"; |