ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/pclient
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/pclient (file contents):
Revision 1.67 by root, Tue Apr 11 13:14:36 2006 UTC vs.
Revision 1.71 by root, Tue Apr 11 17:02:36 2006 UTC

31 31
32our $WIDTH; 32our $WIDTH;
33our $HEIGHT; 33our $HEIGHT;
34our $FULLSCREEN; 34our $FULLSCREEN;
35 35
36our $NOW;
37
38our $MAPWIDGET;
36our $FONTSIZE; 39our $FONTSIZE;
37 40
38our $SDL_TIMER; 41our $SDL_TIMER;
39our $SDL_APP; 42our $SDL_APP;
40our $SDL_EV; 43our $SDL_EV;
91 glDisable GL_DEPTH_TEST; 94 glDisable GL_DEPTH_TEST;
92 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 95 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
93 96
94 ############################################################################# 97 #############################################################################
95 98
96 $DEBUG_STATUS = new CFClient::Widget::Label 0, 0, 1, $FONTSIZE, ""; 99 $DEBUG_STATUS = new CFClient::Widget::Label;
97 $CFClient::Widget::TOPLEVEL->add ($DEBUG_STATUS); 100 $CFClient::Widget::TOPLEVEL->add ($DEBUG_STATUS);
98 101
99 $STATUS_LINE = new CFClient::Widget::Label 102 $STATUS_LINE = new CFClient::Widget::Label
100 0, $HEIGHT * 59 / 60 - $FONTSIZE, 1, $FONTSIZE, 103 y => $HEIGHT * 59 / 60 - $FONTSIZE;
101 "";
102 $CFClient::Widget::TOPLEVEL->add ($STATUS_LINE); 104 $CFClient::Widget::TOPLEVEL->add ($STATUS_LINE);
103 105
104 $ALT_ENTER_MESSAGE = new CFClient::Widget::Label 106 $ALT_ENTER_MESSAGE = new CFClient::Widget::Label
105 0, $HEIGHT * 59 / 60, 1, $HEIGHT / 60, 107 y => $HEIGHT * 59 / 60,
108 height => $HEIGHT / 60,
106 "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 109 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
107 $CFClient::Widget::TOPLEVEL->add ($ALT_ENTER_MESSAGE); 110 $CFClient::Widget::TOPLEVEL->add ($ALT_ENTER_MESSAGE);
111
112 $MAPWIDGET = new CFClient::Widget::MapWidget;
113 $CFClient::Widget::TOPLEVEL->add ($MAPWIDGET);
114 $MAPWIDGET->focus_in;
108 115
109 # Test code #d# 116 # Test code #d#
110 unless ($tw) { # haha... 117 unless ($tw) { # haha...
118 my $w = new CFClient::Widget::Window
119 w => 300, h => 300,
111 $te = new CFClient::Widget::FancyFrame; 120 child => (my $frame = new CFClient::Widget::FancyFrame);
112 $te->add (new CFClient::Widget::Entry);
113 $te->move (300, 0, 2);
114 $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);
115 127
116 $tw = new CFClient::Widget::Animator; 128 $tw = new CFClient::Widget::Animator x => $WIDTH - 200, w => 600, h => 300;
117 my $lbl1 = new CFClient::Widget::Label 129 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 130 my $lbl2 = new CFClient::Widget::Label text => "LBL2";
120 0, 0, 10, $FONTSIZE, "LBL2";
121
122 my $vb = new CFClient::Widget::VBox; 131 my $vb = new CFClient::Widget::VBox;
123 my $f = new CFClient::Widget::FancyFrame; 132 my $f = new CFClient::Widget::FancyFrame;
124 my $f2 = new CFClient::Widget::FancyFrame; 133 my $f2 = new CFClient::Widget::FancyFrame;
125 $f->add ($lbl1); 134 $f->add ($lbl1);
126 $f2->add ($lbl2); 135 $f2->add ($lbl2);
127 $vb->add ($f); 136 $vb->add ($f);
128 $vb->add ($f2, 1); 137 $vb->add ($f2, 1);
129 138
130 $tw->add ($vb); 139 $tw->add ($vb);
131 $tw->w (400);
132 $tw->h (300);
133 $tw->move ($WIDTH - 200, 0);
134 $tw->moveto (0, 0); 140 $tw->moveto (0, 0);
135 $CFClient::Widget::TOPLEVEL->add ($tw); 141 $CFClient::Widget::TOPLEVEL->add ($tw);
136 142
137# $f->move ($WIDTH - 200, 0); 143# $f->move ($WIDTH - 200, 0);
138# $CFClient::Widget::TOPLEVEL->add ($f); 144# $CFClient::Widget::TOPLEVEL->add ($f);
199my $FPS; 205my $FPS;
200 206
201sub refresh { 207sub refresh {
202 $refresh_handler ||= add Glib::Idle sub { 208 $refresh_handler ||= add Glib::Idle sub {
203 if ($SDL_APP) { 209 if ($SDL_APP) {
204 my $next_refresh = SDL::GetTicks; 210 $NOW = SDL::GetTicks;
205 211
206 if ($next_refresh - $last_refresh < $TICKS_PER_FRAME) { 212 if ($NOW - $last_refresh < $TICKS_PER_FRAME) {
207 SDL::Delay $TICKS_PER_FRAME - ($next_refresh - $last_refresh); 213 SDL::Delay $TICKS_PER_FRAME - ($NOW - $last_refresh);
208 $next_refresh = SDL::GetTicks; 214 $NOW = SDL::GetTicks;
209 } 215 }
210 216
211 my $interval = ($next_refresh - $last_refresh) * 0.001; 217 my $interval = ($NOW - $last_refresh) * 0.001;
212 $last_refresh = $next_refresh; 218 $last_refresh = $NOW;
213 219
214 if ($interval) { 220 if ($interval) {
215 $FPS ||= 1 / $interval; 221 $FPS ||= 1 / $interval;
216 $FPS = $FPS * 0.96 + (1 / $interval) * 0.04; 222 $FPS = $FPS * 0.96 + (1 / $interval) * 0.04;
217 debug sprintf "%5.02f", $FPS; 223 debug sprintf "%5.02f", $FPS;
275 }, 281 },
276 SDL_MOUSEBUTTONUP() => sub { 282 SDL_MOUSEBUTTONUP() => sub {
277 CFClient::Widget::feed_sdl_button_up_event ($SDL_EV); 283 CFClient::Widget::feed_sdl_button_up_event ($SDL_EV);
278 }, 284 },
279 SDL_ACTIVEEVENT() => sub { 285 SDL_ACTIVEEVENT() => sub {
280 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#
281 }, 287 },
282); 288);
283 289
284@conn::ISA = Crossfire::Protocol::; 290@conn::ISA = Crossfire::Protocol::;
285 291
286sub conn::map_update { 292sub conn::map_update {
287 my ($self, $dirty) = @_; 293 my ($self, $dirty) = @_;
288 294
289 refresh; 295 $MAPWIDGET->update;
290} 296}
291 297
292sub conn::map_scroll { 298sub conn::map_scroll {
293 my ($self, $dx, $dy) = @_; 299 my ($self, $dx, $dy) = @_;
294 300
422 428
423############################################################################# 429#############################################################################
424 430
425SDL::Init SDL_INIT_EVERYTHING; 431SDL::Init SDL_INIT_EVERYTHING;
426 432
427my $mapwidget = CFClient::Widget::MapWidget->new;
428
429$CFClient::Widget::TOPLEVEL->add ($mapwidget);
430$mapwidget->focus_in;
431
432CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; 433CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
433 434
434$CFG ||= { 435$CFG ||= {
435 width => 640, 436 width => 640,
436 height => 480, 437 height => 480,
453 login => sub { start_game }, 454 login => sub { start_game },
454 logout => sub { stop_game }; 455 logout => sub { stop_game };
455 456
456main Gtk2; 457main Gtk2;
457 458
458CFsave_ref $FACECACHE, "$Crossfire::VARDIR/pclient.faces"; 459Crossfire::save_ref $FACECACHE, "$Crossfire::VARDIR/pclient.faces";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines