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.67 by root, Tue Apr 11 13:14:36 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
75 1 75 1
76 }; 76 };
77 77
78 $last_refresh = SDL::GetTicks; 78 $last_refresh = SDL::GetTicks;
79 79
80 Crossfire::Client::gl_init; 80 CFClient::gl_init;
81 81
82 $FONTSIZE = int $HEIGHT / 50; 82 $FONTSIZE = int $HEIGHT / 50;
83 83
84 ############################################################################# 84 #############################################################################
85 85
91 glDisable GL_DEPTH_TEST; 91 glDisable GL_DEPTH_TEST;
92 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 92 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
93 93
94 ############################################################################# 94 #############################################################################
95 95
96 $DEBUG_STATUS = new Crossfire::Client::Widget::Label 0, 0, 1, $FONTSIZE, ""; 96 $DEBUG_STATUS = new CFClient::Widget::Label 0, 0, 1, $FONTSIZE, "";
97 $Crossfire::Client::Widget::TOPLEVEL->add ($DEBUG_STATUS); 97 $CFClient::Widget::TOPLEVEL->add ($DEBUG_STATUS);
98 98
99 $STATUS_LINE = new Crossfire::Client::Widget::Label 99 $STATUS_LINE = new CFClient::Widget::Label
100 0, $HEIGHT * 59 / 60 - $FONTSIZE, 1, $FONTSIZE, 100 0, $HEIGHT * 59 / 60 - $FONTSIZE, 1, $FONTSIZE,
101 ""; 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 0, $HEIGHT * 59 / 60, 1, $HEIGHT / 60,
106 "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 106 "Use <b>Alt-Enter</b> to toggle fullscreen mode";
107 $Crossfire::Client::Widget::TOPLEVEL->add ($ALT_ENTER_MESSAGE); 107 $CFClient::Widget::TOPLEVEL->add ($ALT_ENTER_MESSAGE);
108 108
109 # Test code #d# 109 # Test code #d#
110 unless ($tw) { # haha... 110 unless ($tw) { # haha...
111 $te = new Crossfire::Client::Widget::FancyFrame; 111 $te = new CFClient::Widget::FancyFrame;
112 $te->add (new Crossfire::Client::Widget::Entry); 112 $te->add (new CFClient::Widget::Entry);
113 $te->move (300, 0, 2); 113 $te->move (300, 0, 2);
114 $Crossfire::Client::Widget::TOPLEVEL->add ($te); 114 $CFClient::Widget::TOPLEVEL->add ($te);
115 115
116 $tw = new Crossfire::Client::Widget::Animator; 116 $tw = new CFClient::Widget::Animator;
117 my $lbl1 = new Crossfire::Client::Widget::Label 117 my $lbl1 = new CFClient::Widget::Label
118 0, 0, 10, $FONTSIZE, "<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 119 my $lbl2 = new CFClient::Widget::Label
120 0, 0, 10, $FONTSIZE, "LBL2"; 120 0, 0, 10, $FONTSIZE, "LBL2";
121 121
122 my $vb = new Crossfire::Client::Widget::VBox; 122 my $vb = new CFClient::Widget::VBox;
123 my $f = new Crossfire::Client::Widget::FancyFrame; 123 my $f = new CFClient::Widget::FancyFrame;
124 my $f2 = new Crossfire::Client::Widget::FancyFrame; 124 my $f2 = new CFClient::Widget::FancyFrame;
125 $f->add ($lbl1); 125 $f->add ($lbl1);
126 $f2->add ($lbl2); 126 $f2->add ($lbl2);
127 $vb->add ($f); 127 $vb->add ($f);
128 $vb->add ($f2, 1); 128 $vb->add ($f2, 1);
129 129
130 $tw->add ($vb); 130 $tw->add ($vb);
131 $tw->w (400); 131 $tw->w (400);
132 $tw->h (300); 132 $tw->h (300);
133 $tw->move ($WIDTH - 200, 0); 133 $tw->move ($WIDTH - 200, 0);
134 $tw->moveto (0, 0); 134 $tw->moveto (0, 0);
135 $Crossfire::Client::Widget::TOPLEVEL->add ($tw); 135 $CFClient::Widget::TOPLEVEL->add ($tw);
136 136
137# $f->move ($WIDTH - 200, 0); 137# $f->move ($WIDTH - 200, 0);
138# $Crossfire::Client::Widget::TOPLEVEL->add ($f); 138# $CFClient::Widget::TOPLEVEL->add ($f);
139 } 139 }
140} 140}
141 141
142sub destroy_screen { 142sub destroy_screen {
143 remove Glib::Source $SDL_TIMER; 143 remove Glib::Source $SDL_TIMER;
162 pass => $CFG->{password}, 162 pass => $CFG->{password},
163 mapw => $mapsize, 163 mapw => $mapsize,
164 maph => $mapsize, 164 maph => $mapsize,
165 ; 165 ;
166 166
167 Crossfire::Client::lowdelay fileno $CONN->{fh}; 167 CFClient::lowdelay fileno $CONN->{fh};
168} 168}
169 169
170sub stop_game { 170sub stop_game {
171 remove Glib::Source $refresh_handler if $refresh_handler; 171 remove Glib::Source $refresh_handler if $refresh_handler;
172 undef $refresh_handler; 172 undef $refresh_handler;
183 glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000; 183 glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000;
184 glMatrixMode GL_MODELVIEW; 184 glMatrixMode GL_MODELVIEW;
185 185
186 glClear GL_COLOR_BUFFER_BIT; 186 glClear GL_COLOR_BUFFER_BIT;
187 187
188 $Crossfire::Client::Widget::TOPLEVEL->draw; 188 $CFClient::Widget::TOPLEVEL->draw;
189 189
190 SDL::GLSwapBuffers; 190 SDL::GLSwapBuffers;
191} 191}
192 192
193sub debug { 193sub debug {
259 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { 259 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) {
260 # alt-enter 260 # alt-enter
261 $FULLSCREEN = !$FULLSCREEN; 261 $FULLSCREEN = !$FULLSCREEN;
262 init_screen; 262 init_screen;
263 } else { 263 } else {
264 Crossfire::Client::Widget::feed_sdl_key_down_event ($SDL_EV); 264 CFClient::Widget::feed_sdl_key_down_event ($SDL_EV);
265 } 265 }
266 }, 266 },
267 SDL_KEYUP() => sub { 267 SDL_KEYUP() => sub {
268 Crossfire::Client::Widget::feed_sdl_key_up_event ($SDL_EV); 268 CFClient::Widget::feed_sdl_key_up_event ($SDL_EV);
269 }, 269 },
270 SDL_MOUSEMOTION() => sub { 270 SDL_MOUSEMOTION() => sub {
271 Crossfire::Client::Widget::feed_sdl_motion_event ($SDL_EV); 271 CFClient::Widget::feed_sdl_motion_event ($SDL_EV);
272 }, 272 },
273 SDL_MOUSEBUTTONDOWN() => sub { 273 SDL_MOUSEBUTTONDOWN() => sub {
274 Crossfire::Client::Widget::feed_sdl_button_down_event ($SDL_EV); 274 CFClient::Widget::feed_sdl_button_down_event ($SDL_EV);
275 }, 275 },
276 SDL_MOUSEBUTTONUP() => sub { 276 SDL_MOUSEBUTTONUP() => sub {
277 Crossfire::Client::Widget::feed_sdl_button_up_event ($SDL_EV); 277 CFClient::Widget::feed_sdl_button_up_event ($SDL_EV);
278 }, 278 },
279 SDL_ACTIVEEVENT() => sub { 279 SDL_ACTIVEEVENT() => sub {
280 printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# 280 printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d#
281 }, 281 },
282); 282);
310sub conn::face_update { 310sub conn::face_update {
311 my ($self, $face) = @_; 311 my ($self, $face) = @_;
312 312
313 $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; 313 $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image};
314 314
315 $face->{texture} = new_from_image Crossfire::Client::Texture delete $face->{image}; 315 $face->{texture} = new_from_image CFClient::Texture delete $face->{image};
316} 316}
317 317
318sub conn::query { 318sub conn::query {
319 my ($self, $flags, $prompt) = @_; 319 my ($self, $flags, $prompt) = @_;
320 320
393 $cb->signal_connect (clicked => sub { 393 $cb->signal_connect (clicked => sub {
394 for (keys %$cfg) { 394 for (keys %$cfg) {
395 $::CFG->{$_} = $cfg->{$_} 395 $::CFG->{$_} = $cfg->{$_}
396 if $_ ne '_i'; 396 if $_ ne '_i';
397 } 397 }
398 Crossfire::Client::write_cfg "$Crossfire::VARDIR/pclientrc"; 398 CFClient::write_cfg "$CFrossfire::VARDIR/pclientrc";
399 }); 399 });
400 $hb->pack_start (my $cb = Gtk2::Button->new ("login"), 1, 1, 5); 400 $hb->pack_start (my $cb = Gtk2::Button->new ("login"), 1, 1, 5);
401 $cb->signal_connect (clicked => sub { 401 $cb->signal_connect (clicked => sub {
402 for (keys %$cfg) { 402 for (keys %$cfg) {
403 $::CFG->{$_} = $cfg->{$_} 403 $::CFG->{$_} = $cfg->{$_}
422 422
423############################################################################# 423#############################################################################
424 424
425SDL::Init SDL_INIT_EVERYTHING; 425SDL::Init SDL_INIT_EVERYTHING;
426 426
427my $mapwidget = Crossfire::Client::Widget::MapWidget->new; 427my $mapwidget = CFClient::Widget::MapWidget->new;
428 428
429$Crossfire::Client::Widget::TOPLEVEL->add ($mapwidget); 429$CFClient::Widget::TOPLEVEL->add ($mapwidget);
430$mapwidget->focus_in; 430$mapwidget->focus_in;
431 431
432Crossfire::Client::read_cfg "$Crossfire::VARDIR/pclientrc"; 432CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
433 433
434$CFG ||= { 434$CFG ||= {
435 width => 640, 435 width => 640,
436 height => 480, 436 height => 480,
437 mapsize => 100, 437 mapsize => 100,
439 host => "crossfire.schmorp.de", 439 host => "crossfire.schmorp.de",
440 port => 13327, 440 port => 13327,
441}; 441};
442 442
443{ 443{
444 my @fonts = map Crossfire::Client::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); 444 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf);
445 445
446 Crossfire::Client::add_font $_ for @fonts; 446 CFClient::add_font $_ for @fonts;
447 Crossfire::Client::set_font $fonts[0]; 447 CFClient::set_font $fonts[0];
448} 448}
449 449
450$FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; 450$FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {};
451 451
452run_config_dialog 452run_config_dialog
453 login => sub { start_game }, 453 login => sub { start_game },
454 logout => sub { stop_game }; 454 logout => sub { stop_game };
455 455
456main Gtk2; 456main Gtk2;
457 457
458Crossfire::save_ref $FACECACHE, "$Crossfire::VARDIR/pclient.faces"; 458CFsave_ref $FACECACHE, "$Crossfire::VARDIR/pclient.faces";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines