… | |
… | |
30 | our $CONN; |
30 | our $CONN; |
31 | |
31 | |
32 | our $WIDTH; |
32 | our $WIDTH; |
33 | our $HEIGHT; |
33 | our $HEIGHT; |
34 | our $FULLSCREEN; |
34 | our $FULLSCREEN; |
|
|
35 | |
|
|
36 | our $NOW; |
35 | |
37 | |
36 | our $MAPWIDGET; |
38 | our $MAPWIDGET; |
37 | our $FONTSIZE; |
39 | our $FONTSIZE; |
38 | |
40 | |
39 | our $SDL_TIMER; |
41 | our $SDL_TIMER; |
… | |
… | |
111 | $CFClient::Widget::TOPLEVEL->add ($MAPWIDGET); |
113 | $CFClient::Widget::TOPLEVEL->add ($MAPWIDGET); |
112 | $MAPWIDGET->focus_in; |
114 | $MAPWIDGET->focus_in; |
113 | |
115 | |
114 | # Test code #d# |
116 | # Test code #d# |
115 | unless ($tw) { # haha... |
117 | unless ($tw) { # haha... |
116 | $te = new CFClient::Widget::FancyFrame x => 300, z => 1; |
118 | my $w = new CFClient::Widget::Window |
117 | $te->add (new CFClient::Widget::Entry); |
119 | w => 300, h => 300, |
|
|
120 | child => (my $frame = new CFClient::Widget::FancyFrame); |
118 | $CFClient::Widget::TOPLEVEL->add ($te); |
121 | $CFClient::Widget::TOPLEVEL->add ($w); |
|
|
122 | |
|
|
123 | $frame->add (my $vbox = new CFClient::Widget::VBox); |
|
|
124 | |
|
|
125 | $vbox->add (new CFClient::Widget::Entry text => "hallo"); |
|
|
126 | $vbox->add (new CFClient::Widget::Slider); |
119 | |
127 | |
120 | $tw = new CFClient::Widget::Animator x => $WIDTH - 200, w => 600, h => 300; |
128 | $tw = new CFClient::Widget::Animator x => $WIDTH - 200, w => 600, h => 300; |
121 | my $lbl1 = new CFClient::Widget::Label text => "<i>This</i> is a\n<u>TEST</u>!\nOf a themed\nFrame!"; |
129 | my $lbl1 = new CFClient::Widget::Label text => "<i>This</i> is a\n<u>TEST</u>!\nOf a themed\nFrame!"; |
122 | my $lbl2 = new CFClient::Widget::Label text => "LBL2"; |
130 | my $lbl2 = new CFClient::Widget::Label text => "LBL2"; |
123 | my $vb = new CFClient::Widget::VBox; |
131 | my $vb = new CFClient::Widget::VBox; |
… | |
… | |
197 | my $FPS; |
205 | my $FPS; |
198 | |
206 | |
199 | sub refresh { |
207 | sub refresh { |
200 | $refresh_handler ||= add Glib::Idle sub { |
208 | $refresh_handler ||= add Glib::Idle sub { |
201 | if ($SDL_APP) { |
209 | if ($SDL_APP) { |
202 | my $next_refresh = SDL::GetTicks; |
210 | $NOW = SDL::GetTicks; |
203 | |
211 | |
204 | if ($next_refresh - $last_refresh < $TICKS_PER_FRAME) { |
212 | if ($NOW - $last_refresh < $TICKS_PER_FRAME) { |
205 | SDL::Delay $TICKS_PER_FRAME - ($next_refresh - $last_refresh); |
213 | SDL::Delay $TICKS_PER_FRAME - ($NOW - $last_refresh); |
206 | $next_refresh = SDL::GetTicks; |
214 | $NOW = SDL::GetTicks; |
207 | } |
215 | } |
208 | |
216 | |
209 | my $interval = ($next_refresh - $last_refresh) * 0.001; |
217 | my $interval = ($NOW - $last_refresh) * 0.001; |
210 | $last_refresh = $next_refresh; |
218 | $last_refresh = $NOW; |
211 | |
219 | |
212 | if ($interval) { |
220 | if ($interval) { |
213 | $FPS ||= 1 / $interval; |
221 | $FPS ||= 1 / $interval; |
214 | $FPS = $FPS * 0.96 + (1 / $interval) * 0.04; |
222 | $FPS = $FPS * 0.96 + (1 / $interval) * 0.04; |
215 | debug sprintf "%5.02f", $FPS; |
223 | debug sprintf "%5.02f", $FPS; |
… | |
… | |
273 | }, |
281 | }, |
274 | SDL_MOUSEBUTTONUP() => sub { |
282 | SDL_MOUSEBUTTONUP() => sub { |
275 | CFClient::Widget::feed_sdl_button_up_event ($SDL_EV); |
283 | CFClient::Widget::feed_sdl_button_up_event ($SDL_EV); |
276 | }, |
284 | }, |
277 | SDL_ACTIVEEVENT() => sub { |
285 | SDL_ACTIVEEVENT() => sub { |
278 | printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
286 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
279 | }, |
287 | }, |
280 | ); |
288 | ); |
281 | |
289 | |
282 | @conn::ISA = Crossfire::Protocol::; |
290 | @conn::ISA = Crossfire::Protocol::; |
283 | |
291 | |