--- deliantra/Deliantra-Client/bin/pclient 2006/04/11 13:14:36 1.67 +++ deliantra/Deliantra-Client/bin/pclient 2006/04/11 17:02:36 1.71 @@ -33,6 +33,9 @@ our $HEIGHT; our $FULLSCREEN; +our $NOW; + +our $MAPWIDGET; our $FONTSIZE; our $SDL_TIMER; @@ -93,32 +96,38 @@ ############################################################################# - $DEBUG_STATUS = new CFClient::Widget::Label 0, 0, 1, $FONTSIZE, ""; + $DEBUG_STATUS = new CFClient::Widget::Label; $CFClient::Widget::TOPLEVEL->add ($DEBUG_STATUS); $STATUS_LINE = new CFClient::Widget::Label - 0, $HEIGHT * 59 / 60 - $FONTSIZE, 1, $FONTSIZE, - ""; + y => $HEIGHT * 59 / 60 - $FONTSIZE; $CFClient::Widget::TOPLEVEL->add ($STATUS_LINE); $ALT_ENTER_MESSAGE = new CFClient::Widget::Label - 0, $HEIGHT * 59 / 60, 1, $HEIGHT / 60, - "Use Alt-Enter to toggle fullscreen mode"; + y => $HEIGHT * 59 / 60, + height => $HEIGHT / 60, + text => "Use Alt-Enter to toggle fullscreen mode"; $CFClient::Widget::TOPLEVEL->add ($ALT_ENTER_MESSAGE); + $MAPWIDGET = new CFClient::Widget::MapWidget; + $CFClient::Widget::TOPLEVEL->add ($MAPWIDGET); + $MAPWIDGET->focus_in; + # Test code #d# unless ($tw) { # haha... - $te = new CFClient::Widget::FancyFrame; - $te->add (new CFClient::Widget::Entry); - $te->move (300, 0, 2); - $CFClient::Widget::TOPLEVEL->add ($te); - - $tw = new CFClient::Widget::Animator; - my $lbl1 = new CFClient::Widget::Label - 0, 0, 10, $FONTSIZE, "This is a\nTEST!\nOf a themed\nFrame!"; - my $lbl2 = new CFClient::Widget::Label - 0, 0, 10, $FONTSIZE, "LBL2"; + my $w = new CFClient::Widget::Window + w => 300, h => 300, + child => (my $frame = new CFClient::Widget::FancyFrame); + $CFClient::Widget::TOPLEVEL->add ($w); + + $frame->add (my $vbox = new CFClient::Widget::VBox); + $vbox->add (new CFClient::Widget::Entry text => "hallo"); + $vbox->add (new CFClient::Widget::Slider); + + $tw = new CFClient::Widget::Animator x => $WIDTH - 200, w => 600, h => 300; + my $lbl1 = new CFClient::Widget::Label text => "This is a\nTEST!\nOf a themed\nFrame!"; + my $lbl2 = new CFClient::Widget::Label text => "LBL2"; my $vb = new CFClient::Widget::VBox; my $f = new CFClient::Widget::FancyFrame; my $f2 = new CFClient::Widget::FancyFrame; @@ -128,9 +137,6 @@ $vb->add ($f2, 1); $tw->add ($vb); - $tw->w (400); - $tw->h (300); - $tw->move ($WIDTH - 200, 0); $tw->moveto (0, 0); $CFClient::Widget::TOPLEVEL->add ($tw); @@ -201,15 +207,15 @@ sub refresh { $refresh_handler ||= add Glib::Idle sub { if ($SDL_APP) { - my $next_refresh = SDL::GetTicks; + $NOW = SDL::GetTicks; - if ($next_refresh - $last_refresh < $TICKS_PER_FRAME) { - SDL::Delay $TICKS_PER_FRAME - ($next_refresh - $last_refresh); - $next_refresh = SDL::GetTicks; + if ($NOW - $last_refresh < $TICKS_PER_FRAME) { + SDL::Delay $TICKS_PER_FRAME - ($NOW - $last_refresh); + $NOW = SDL::GetTicks; } - my $interval = ($next_refresh - $last_refresh) * 0.001; - $last_refresh = $next_refresh; + my $interval = ($NOW - $last_refresh) * 0.001; + $last_refresh = $NOW; if ($interval) { $FPS ||= 1 / $interval; @@ -277,7 +283,7 @@ CFClient::Widget::feed_sdl_button_up_event ($SDL_EV); }, SDL_ACTIVEEVENT() => sub { - printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# +# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# }, ); @@ -286,7 +292,7 @@ sub conn::map_update { my ($self, $dirty) = @_; - refresh; + $MAPWIDGET->update; } sub conn::map_scroll { @@ -424,11 +430,6 @@ SDL::Init SDL_INIT_EVERYTHING; -my $mapwidget = CFClient::Widget::MapWidget->new; - -$CFClient::Widget::TOPLEVEL->add ($mapwidget); -$mapwidget->focus_in; - CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; $CFG ||= { @@ -455,4 +456,4 @@ main Gtk2; -CFsave_ref $FACECACHE, "$Crossfire::VARDIR/pclient.faces"; +Crossfire::save_ref $FACECACHE, "$Crossfire::VARDIR/pclient.faces";