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.32 by elmex, Sat Apr 8 17:21:01 2006 UTC vs.
Revision 1.41 by elmex, Sun Apr 9 01:21:11 2006 UTC

30 30
31our $WIDTH; 31our $WIDTH;
32our $HEIGHT; 32our $HEIGHT;
33our $FULLSCREEN; 33our $FULLSCREEN;
34 34
35our $UIFONT; 35our $FONTSIZE;
36 36
37our $SDL_TIMER; 37our $SDL_TIMER;
38our $SDL_APP; 38our $SDL_APP;
39our $SDL_EV = new SDL::Event; 39our $SDL_EV = new SDL::Event;
40our %SDL_CB; 40our %SDL_CB;
41 41
42our @GL_INIT; # hooks called on every gl init 42our @GL_INIT; # hooks called on every gl init
43 43
44our $ALT_ENTER_MESSAGE; 44our $ALT_ENTER_MESSAGE;
45 45
46our $tw; 46our $TOPLEVEL;
47
48our $tw; # Test widget #d#
47 49
48sub init_screen { 50sub init_screen {
49 $SDL_APP = new SDL::App 51 $SDL_APP = new SDL::App
50 -flags => SDL_ANYFORMAT | SDL_HWSURFACE, 52 -flags => SDL_ANYFORMAT | SDL_HWSURFACE,
51 -title => "Crossfire+ Client", 53 -title => "Crossfire+ Client",
62 %GL_EXT = map +($_ => 1), split /\s+/, Crossfire::Client::gl_extensions; 64 %GL_EXT = map +($_ => 1), split /\s+/, Crossfire::Client::gl_extensions;
63 65
64 $GL_EXT{GL_ARB_texture_non_power_of_two} 66 $GL_EXT{GL_ARB_texture_non_power_of_two}
65 or warn "WARNING: non-power-of-two opengl extension required"; 67 or warn "WARNING: non-power-of-two opengl extension required";
66 68
67 $UIFONT = SDL::TTFOpenFont Crossfire::Client::find_rcfile "uifont.ttf", $HEIGHT / 40 69 $FONTSIZE = int $HEIGHT / 50;
68 or die "TTFOpenFont: $!";
69 70
70 $ALT_ENTER_MESSAGE = new Crossfire::Client::Widget::Label 0, $HEIGHT - $HEIGHT / 40, 10, $UIFONT, "Alt-Enter toggles fullscreen mode"; 71 $ALT_ENTER_MESSAGE = new Crossfire::Client::Widget::Label
72 0, $FONTSIZE, $HEIGHT - $FONTSIZE, $FONTSIZE,
73 "Use <b>Alt-Enter</b> to toggle fullscreen mode";
71 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - ($ALT_ENTER_MESSAGE->size_request)[1]); 74 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - ($ALT_ENTER_MESSAGE->size_request)[1]);
72 $ALT_ENTER_MESSAGE->activate; 75 $TOPLEVEL->add ($ALT_ENTER_MESSAGE);
73 76
77 # Test code #d#
78 {
79 my $frm = new Crossfire::Client::Widget::Frame;
74 $tw = new Crossfire::Client::Widget::Window; 80 $tw = new Crossfire::Client::Widget::Window;
75 $tw->add (my $lbl = new Crossfire::Client::Widget::Label 0, $HEIGHT - $HEIGHT / 40, 10, $UIFONT, "Foo in the garden!"); 81 $frm->add (my $te = new Crossfire::Client::Widget::TextEntry 0, 0, 10, $FONTSIZE, "Foo in the garden!");
76# $tw = new Crossfire::Client::Widget::Label 0, $HEIGHT - $HEIGHT / 40, 10, $UIFONT, "Foo in the garden!"; 82 $tw->add ($frm);
77 83
78 $tw->move (0, $HEIGHT - 50); 84 $tw->move (0, $HEIGHT - 120);
79 $tw->activate; 85 $TOPLEVEL->add ($tw);
86# $te->focus_in;
87 }
80 88
81 glClearColor 0, 0, 0, 0; 89 glClearColor 0, 0, 0, 0;
82 90
83 glEnable GL_TEXTURE_2D; 91 glEnable GL_TEXTURE_2D;
92 glEnable GL_COLOR_MATERIAL;
84 glShadeModel GL_FLAT; 93 glShadeModel GL_FLAT;
85 glDisable GL_DEPTH_TEST; 94 glDisable GL_DEPTH_TEST;
86 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 95 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
87
88 glMatrixMode GL_PROJECTION;
89 glLoadIdentity;
90 glOrtho 0, $WIDTH, $HEIGHT, 0, -100 , 100;
91
92 glMatrixMode GL_MODELVIEW;
93 96
94 $_->() for @GL_INIT; 97 $_->() for @GL_INIT;
95} 98}
96 99
97sub start_game { 100sub start_game {
110 113
111 $CONN = new conn 114 $CONN = new conn
112 host => $CFG->{host}, 115 host => $CFG->{host},
113 port => $CFG->{port}, 116 port => $CFG->{port},
114 user => $CFG->{user}, 117 user => $CFG->{user},
115 pass => $CFG->{password}; 118 pass => $CFG->{password},
119 mapw => 50,
120 maph => 37,
121 ;
116} 122}
117 123
118sub stop_game { 124sub stop_game {
119 remove Glib::Source $SDL_TIMER; 125 remove Glib::Source $SDL_TIMER;
120 126
123} 129}
124 130
125 131
126sub force_refresh { 132sub force_refresh {
127 glViewport 0, 0, $WIDTH, $HEIGHT; 133 glViewport 0, 0, $WIDTH, $HEIGHT;
134
135 glMatrixMode GL_PROJECTION;
136 glLoadIdentity;
137 glOrtho 0, $WIDTH, $HEIGHT, 0, -100 , 100;
138 glMatrixMode GL_MODELVIEW;
139
128 glClear GL_COLOR_BUFFER_BIT; 140 glClear GL_COLOR_BUFFER_BIT;
129 141
130 $_->draw for @Crossfire::Client::Widget::ACTIVE_WIDGETS; 142 $TOPLEVEL->draw;
131 143
132 SDL::GLSwapBuffers; 144 SDL::GLSwapBuffers;
133} 145}
134 146
135my $refresh_handler; 147my $refresh_handler;
207 my ($self, $face) = @_; 219 my ($self, $face) = @_;
208 220
209 $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; 221 $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image};
210 222
211 $face->{texture} = new_from_image Crossfire::Client::Texture delete $face->{image}; 223 $face->{texture} = new_from_image Crossfire::Client::Texture delete $face->{image};
224}
225
226sub conn::query {
227 my ($self, $flags, $prompt) = @_;
228
229 warn "<<<<QUERY:$flags:$prompt>>>\n";#d#
212} 230}
213 231
214sub gtk_add_cfg_field { 232sub gtk_add_cfg_field {
215 my ($tbl, $cfg, $klbl, $key, $value) = @_; 233 my ($tbl, $cfg, $klbl, $key, $value) = @_;
216 my $i = $cfg->{_i}++; 234 my $i = $cfg->{_i}++;
304 322
305 323
306############################################################################# 324#############################################################################
307 325
308SDL::Init SDL_INIT_EVERYTHING; 326SDL::Init SDL_INIT_EVERYTHING;
309SDL::TTFInit; 327
328$TOPLEVEL = Crossfire::Client::Widget::Toplevel->new;
310 329
311my $mapwidget = Crossfire::Client::Widget::MapWidget->new; 330my $mapwidget = Crossfire::Client::Widget::MapWidget->new;
312 331
313$mapwidget->activate; 332$TOPLEVEL->add ($mapwidget);
314$mapwidget->focus_in; 333$mapwidget->focus_in;
315 334
316Crossfire::Client::read_cfg "$Crossfire::VARDIR/pclientrc"; 335Crossfire::Client::read_cfg "$Crossfire::VARDIR/pclientrc";
317 336
318$CFG ||= { 337$CFG ||= {
321 fullscreen => 0, 340 fullscreen => 0,
322 host => "crossfire.schmorp.de", 341 host => "crossfire.schmorp.de",
323 port => 13327, 342 port => 13327,
324}; 343};
325 344
345Crossfire::Client::add_font Crossfire::Client::find_rcfile "uifont.ttf";
346Crossfire::Client::set_font "[Bitstream Vera Sans Mono]";
347
326$FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; 348$FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {};
327 349
328run_config_dialog 350run_config_dialog
329 login => sub { start_game }, 351 login => sub { start_game },
330 logout => sub { stop_game }; 352 logout => sub { stop_game };

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines