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.66 by root, Tue Apr 11 13:05:12 2006 UTC vs.
Revision 1.69 by root, Tue Apr 11 14:04:27 2006 UTC

14use SDL::OpenGL::Constants; 14use SDL::OpenGL::Constants;
15 15
16use Crossfire; 16use Crossfire;
17use Crossfire::Protocol; 17use Crossfire::Protocol;
18 18
19use Crossfire::Client; 19use CFClient;
20use Crossfire::Client::Widget; 20use CFClient::Widget;
21 21
22our $VERSION = '0.1'; 22our $VERSION = '0.1';
23 23
24my $MAX_FPS = 30; 24my $MAX_FPS = 30;
25my $TICKS_PER_FRAME = int 1000 / $MAX_FPS - 1; # min ticks per frame 25my $TICKS_PER_FRAME = int 1000 / $MAX_FPS - 1; # min ticks per frame
31 31
32our $WIDTH; 32our $WIDTH;
33our $HEIGHT; 33our $HEIGHT;
34our $FULLSCREEN; 34our $FULLSCREEN;
35 35
36our $MAPWIDGET;
36our $FONTSIZE; 37our $FONTSIZE;
37 38
38our $SDL_TIMER; 39our $SDL_TIMER;
39our $SDL_APP; 40our $SDL_APP;
40our $SDL_EV; 41our $SDL_EV;
75 1 76 1
76 }; 77 };
77 78
78 $last_refresh = SDL::GetTicks; 79 $last_refresh = SDL::GetTicks;
79 80
80 Crossfire::Client::gl_init; 81 CFClient::gl_init;
81 82
82 $FONTSIZE = int $HEIGHT / 50; 83 $FONTSIZE = int $HEIGHT / 50;
83 84
84 ############################################################################# 85 #############################################################################
85 86
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 Crossfire::Client::Widget::Label 0, 0, 1, $FONTSIZE, ""; 97 $DEBUG_STATUS = new CFClient::Widget::Label;
97 $Crossfire::Client::Widget::TOPLEVEL->add ($DEBUG_STATUS); 98 $CFClient::Widget::TOPLEVEL->add ($DEBUG_STATUS);
98 99
99 $STATUS_LINE = new Crossfire::Client::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 $Crossfire::Client::Widget::TOPLEVEL->add ($STATUS_LINE); 102 $CFClient::Widget::TOPLEVEL->add ($STATUS_LINE);
103 103
104 $ALT_ENTER_MESSAGE = new Crossfire::Client::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 $Crossfire::Client::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 Crossfire::Client::Widget::FancyFrame; 116 $te = new CFClient::Widget::FancyFrame x => 300, z => 1;
112 $te->add (new Crossfire::Client::Widget::Entry); 117 $te->add (new CFClient::Widget::Entry);
113 $te->move (300, 0, 2);
114 $Crossfire::Client::Widget::TOPLEVEL->add ($te); 118 $CFClient::Widget::TOPLEVEL->add ($te);
115 119
116 $tw = new Crossfire::Client::Widget::Animator; 120 $tw = new CFClient::Widget::Animator x => $WIDTH - 200, w => 600, h => 300;
117 my $lbl1 = new Crossfire::Client::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 Crossfire::Client::Widget::Label 122 my $lbl2 = new CFClient::Widget::Label text => "LBL2";
120 0, 0, 10, $FONTSIZE, "LBL2";
121
122 my $vb = new Crossfire::Client::Widget::VBox; 123 my $vb = new CFClient::Widget::VBox;
123 my $f = new Crossfire::Client::Widget::FancyFrame; 124 my $f = new CFClient::Widget::FancyFrame;
124 my $f2 = new Crossfire::Client::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 $Crossfire::Client::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# $Crossfire::Client::Widget::TOPLEVEL->add ($f); 136# $CFClient::Widget::TOPLEVEL->add ($f);
139 } 137 }
140} 138}
141 139
142sub destroy_screen { 140sub destroy_screen {
143 remove Glib::Source $SDL_TIMER; 141 remove Glib::Source $SDL_TIMER;
162 pass => $CFG->{password}, 160 pass => $CFG->{password},
163 mapw => $mapsize, 161 mapw => $mapsize,
164 maph => $mapsize, 162 maph => $mapsize,
165 ; 163 ;
166 164
167 Crossfire::Client::lowdelay fileno $CONN->{fh}; 165 CFClient::lowdelay fileno $CONN->{fh};
168} 166}
169 167
170sub stop_game { 168sub stop_game {
171 remove Glib::Source $refresh_handler if $refresh_handler; 169 remove Glib::Source $refresh_handler if $refresh_handler;
172 undef $refresh_handler; 170 undef $refresh_handler;
183 glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000; 181 glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000;
184 glMatrixMode GL_MODELVIEW; 182 glMatrixMode GL_MODELVIEW;
185 183
186 glClear GL_COLOR_BUFFER_BIT; 184 glClear GL_COLOR_BUFFER_BIT;
187 185
188 $Crossfire::Client::Widget::TOPLEVEL->draw; 186 $CFClient::Widget::TOPLEVEL->draw;
189 187
190 SDL::GLSwapBuffers; 188 SDL::GLSwapBuffers;
191} 189}
192 190
193sub debug { 191sub debug {
259 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { 257 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) {
260 # alt-enter 258 # alt-enter
261 $FULLSCREEN = !$FULLSCREEN; 259 $FULLSCREEN = !$FULLSCREEN;
262 init_screen; 260 init_screen;
263 } else { 261 } else {
264 Crossfire::Client::Widget::feed_sdl_key_down_event ($SDL_EV); 262 CFClient::Widget::feed_sdl_key_down_event ($SDL_EV);
265 } 263 }
266 }, 264 },
267 SDL_KEYUP() => sub { 265 SDL_KEYUP() => sub {
268 Crossfire::Client::Widget::feed_sdl_key_up_event ($SDL_EV); 266 CFClient::Widget::feed_sdl_key_up_event ($SDL_EV);
269 }, 267 },
270 SDL_MOUSEMOTION() => sub { 268 SDL_MOUSEMOTION() => sub {
271 Crossfire::Client::Widget::feed_sdl_motion_event ($SDL_EV); 269 CFClient::Widget::feed_sdl_motion_event ($SDL_EV);
272 }, 270 },
273 SDL_MOUSEBUTTONDOWN() => sub { 271 SDL_MOUSEBUTTONDOWN() => sub {
274 Crossfire::Client::Widget::feed_sdl_button_down_event ($SDL_EV); 272 CFClient::Widget::feed_sdl_button_down_event ($SDL_EV);
275 }, 273 },
276 SDL_MOUSEBUTTONUP() => sub { 274 SDL_MOUSEBUTTONUP() => sub {
277 Crossfire::Client::Widget::feed_sdl_button_up_event ($SDL_EV); 275 CFClient::Widget::feed_sdl_button_up_event ($SDL_EV);
278 }, 276 },
279 SDL_ACTIVEEVENT() => sub { 277 SDL_ACTIVEEVENT() => sub {
280 printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# 278 printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d#
281 }, 279 },
282); 280);
284@conn::ISA = Crossfire::Protocol::; 282@conn::ISA = Crossfire::Protocol::;
285 283
286sub conn::map_update { 284sub conn::map_update {
287 my ($self, $dirty) = @_; 285 my ($self, $dirty) = @_;
288 286
289 refresh; 287 $MAPWIDGET->update;
290} 288}
291 289
292sub conn::map_scroll { 290sub conn::map_scroll {
293 my ($self, $dx, $dy) = @_; 291 my ($self, $dx, $dy) = @_;
294 292
310sub conn::face_update { 308sub conn::face_update {
311 my ($self, $face) = @_; 309 my ($self, $face) = @_;
312 310
313 $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; 311 $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image};
314 312
315 $face->{texture} = new_from_image Crossfire::Client::Texture delete $face->{image}; 313 $face->{texture} = new_from_image CFClient::Texture delete $face->{image};
316} 314}
317 315
318sub conn::query { 316sub conn::query {
319 my ($self, $flags, $prompt) = @_; 317 my ($self, $flags, $prompt) = @_;
320 318
393 $cb->signal_connect (clicked => sub { 391 $cb->signal_connect (clicked => sub {
394 for (keys %$cfg) { 392 for (keys %$cfg) {
395 $::CFG->{$_} = $cfg->{$_} 393 $::CFG->{$_} = $cfg->{$_}
396 if $_ ne '_i'; 394 if $_ ne '_i';
397 } 395 }
398 Crossfire::Client::write_cfg "$Crossfire::VARDIR/pclientrc"; 396 CFClient::write_cfg "$CFrossfire::VARDIR/pclientrc";
399 }); 397 });
400 $hb->pack_start (my $cb = Gtk2::Button->new ("login"), 1, 1, 5); 398 $hb->pack_start (my $cb = Gtk2::Button->new ("login"), 1, 1, 5);
401 $cb->signal_connect (clicked => sub { 399 $cb->signal_connect (clicked => sub {
402 for (keys %$cfg) { 400 for (keys %$cfg) {
403 $::CFG->{$_} = $cfg->{$_} 401 $::CFG->{$_} = $cfg->{$_}
422 420
423############################################################################# 421#############################################################################
424 422
425SDL::Init SDL_INIT_EVERYTHING; 423SDL::Init SDL_INIT_EVERYTHING;
426 424
427my $mapwidget = Crossfire::Client::Widget::MapWidget->new;
428
429$Crossfire::Client::Widget::TOPLEVEL->add ($mapwidget);
430$mapwidget->focus_in;
431
432Crossfire::Client::read_cfg "$Crossfire::VARDIR/pclientrc"; 425CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
433 426
434$CFG ||= { 427$CFG ||= {
435 width => 640, 428 width => 640,
436 height => 480, 429 height => 480,
437 mapsize => 100, 430 mapsize => 100,
439 host => "crossfire.schmorp.de", 432 host => "crossfire.schmorp.de",
440 port => 13327, 433 port => 13327,
441}; 434};
442 435
443{ 436{
444 my @fonts = map Crossfire::Client::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); 437 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf);
445 438
446 Crossfire::Client::add_font $_ for @fonts; 439 CFClient::add_font $_ for @fonts;
447 Crossfire::Client::set_font $fonts[0]; 440 CFClient::set_font $fonts[0];
448} 441}
449 442
450$FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; 443$FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {};
451 444
452run_config_dialog 445run_config_dialog

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines