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.71 by root, Tue Apr 11 17:02:36 2006 UTC vs.
Revision 1.72 by root, Tue Apr 11 18:06:53 2006 UTC

15 15
16use Crossfire; 16use Crossfire;
17use Crossfire::Protocol; 17use Crossfire::Protocol;
18 18
19use CFClient; 19use CFClient;
20use CFClient::Widget; 20use CFClient::UI;
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
94 glDisable GL_DEPTH_TEST; 94 glDisable GL_DEPTH_TEST;
95 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 95 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
96 96
97 ############################################################################# 97 #############################################################################
98 98
99 $DEBUG_STATUS = new CFClient::Widget::Label; 99 $DEBUG_STATUS = new CFClient::UI::Label;
100 $CFClient::Widget::TOPLEVEL->add ($DEBUG_STATUS); 100 $CFClient::UI::TOPLEVEL->add ($DEBUG_STATUS);
101 101
102 $STATUS_LINE = new CFClient::Widget::Label 102 $STATUS_LINE = new CFClient::UI::Label
103 y => $HEIGHT * 59 / 60 - $FONTSIZE; 103 y => $HEIGHT * 59 / 60 - $FONTSIZE;
104 $CFClient::Widget::TOPLEVEL->add ($STATUS_LINE); 104 $CFClient::UI::TOPLEVEL->add ($STATUS_LINE);
105 105
106 $ALT_ENTER_MESSAGE = new CFClient::Widget::Label 106 $ALT_ENTER_MESSAGE = new CFClient::UI::Label
107 y => $HEIGHT * 59 / 60, 107 y => $HEIGHT * 59 / 60,
108 height => $HEIGHT / 60, 108 height => $HEIGHT / 60,
109 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 109 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
110 $CFClient::Widget::TOPLEVEL->add ($ALT_ENTER_MESSAGE); 110 $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE);
111 111
112 $MAPWIDGET = new CFClient::Widget::MapWidget; 112 $MAPWIDGET = new CFClient::UI::MapWidget;
113 $CFClient::Widget::TOPLEVEL->add ($MAPWIDGET); 113 $CFClient::UI::TOPLEVEL->add ($MAPWIDGET);
114 $MAPWIDGET->focus_in; 114 $MAPWIDGET->focus_in;
115 115
116 # Test code #d# 116 # Test code #d#
117 unless ($tw) { # haha... 117 unless ($tw) { # haha...
118 my $w = new CFClient::Widget::Window 118 my $w = new CFClient::UI::Window
119 w => 300, h => 300, 119 w => 300, h => 300,
120 child => (my $frame = new CFClient::Widget::FancyFrame); 120 child => (my $frame = new CFClient::UI::FancyFrame);
121 $CFClient::Widget::TOPLEVEL->add ($w); 121 $CFClient::UI::TOPLEVEL->add ($w);
122 122
123 $frame->add (my $vbox = new CFClient::Widget::VBox); 123 $frame->add (my $vbox = new CFClient::UI::VBox);
124 124
125 $vbox->add (new CFClient::Widget::Entry text => "hallo"); 125 $vbox->add (new CFClient::UI::Entry text => "hallo");
126 $vbox->add (new CFClient::Widget::Slider); 126 $vbox->add (new CFClient::UI::Slider);
127 127
128 $tw = new CFClient::Widget::Animator x => $WIDTH - 200, w => 600, h => 300; 128 $tw = new CFClient::UI::Animator x => $WIDTH - 200, w => 600, h => 300;
129 my $lbl1 = new CFClient::Widget::Label text => "<i>This</i> is a\n<u>TEST</u>!\nOf a themed\nFrame!"; 129 my $lbl1 = new CFClient::UI::Label text => "<i>This</i> is a\n<u>TEST</u>!\nOf a themed\nFrame!";
130 my $lbl2 = new CFClient::Widget::Label text => "LBL2"; 130 my $lbl2 = new CFClient::UI::Label text => "LBL2";
131 my $vb = new CFClient::Widget::VBox; 131 my $vb = new CFClient::UI::VBox;
132 my $f = new CFClient::Widget::FancyFrame; 132 my $f = new CFClient::UI::FancyFrame;
133 my $f2 = new CFClient::Widget::FancyFrame; 133 my $f2 = new CFClient::UI::FancyFrame;
134 $f->add ($lbl1); 134 $f->add ($lbl1);
135 $f2->add ($lbl2); 135 $f2->add ($lbl2);
136 $vb->add ($f); 136 $vb->add ($f);
137 $vb->add ($f2, 1); 137 $vb->add ($f2, 1);
138 138
139 $tw->add ($vb); 139 $tw->add ($vb);
140 $tw->moveto (0, 0); 140 $tw->moveto (0, 0);
141 $CFClient::Widget::TOPLEVEL->add ($tw); 141 $CFClient::UI::TOPLEVEL->add ($tw);
142 142
143# $f->move ($WIDTH - 200, 0); 143# $f->move ($WIDTH - 200, 0);
144# $CFClient::Widget::TOPLEVEL->add ($f); 144# $CFClient::UI::TOPLEVEL->add ($f);
145 } 145 }
146} 146}
147 147
148sub destroy_screen { 148sub destroy_screen {
149 remove Glib::Source $SDL_TIMER; 149 remove Glib::Source $SDL_TIMER;
150 undef $SDL_APP; 150 undef $SDL_APP;
151 undef $SDL_EV; 151 undef $SDL_EV;
152 SDL::Quit; 152 SDL::Quit;
153} 153}
154 154
155sub config_dialog {
156 my $dialog = new CFClient::UI::FancyFrame x => 300, y => 100,
157 child => (my $vbox = new CFClient::UI::VBox);
158 $vbox->add (new CFClient::UI::Label align => 0, text => "Setup");
159
160 $CFClient::UI::TOPLEVEL->add ($dialog);
161}
162
155sub start_game { 163sub start_game {
156 $WIDTH = $CFG->{width}; 164 $WIDTH = $CFG->{width};
157 $HEIGHT = $CFG->{height}; 165 $HEIGHT = $CFG->{height};
158 $FULLSCREEN = 0; 166 $FULLSCREEN = 0;
159 167
160 init_screen; 168 init_screen;
169
170 config_dialog;
161 171
162 my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 172 my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
163 173
164 $CONN = new conn 174 $CONN = new conn
165 host => $CFG->{host}, 175 host => $CFG->{host},
189 glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000; 199 glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000;
190 glMatrixMode GL_MODELVIEW; 200 glMatrixMode GL_MODELVIEW;
191 201
192 glClear GL_COLOR_BUFFER_BIT; 202 glClear GL_COLOR_BUFFER_BIT;
193 203
194 $CFClient::Widget::TOPLEVEL->draw; 204 $CFClient::UI::TOPLEVEL->draw;
195 205
196 SDL::GLSwapBuffers; 206 SDL::GLSwapBuffers;
197} 207}
198 208
199sub debug { 209sub debug {
265 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { 275 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) {
266 # alt-enter 276 # alt-enter
267 $FULLSCREEN = !$FULLSCREEN; 277 $FULLSCREEN = !$FULLSCREEN;
268 init_screen; 278 init_screen;
269 } else { 279 } else {
270 CFClient::Widget::feed_sdl_key_down_event ($SDL_EV); 280 CFClient::UI::feed_sdl_key_down_event ($SDL_EV);
271 } 281 }
272 }, 282 },
273 SDL_KEYUP() => sub { 283 SDL_KEYUP() => sub {
274 CFClient::Widget::feed_sdl_key_up_event ($SDL_EV); 284 CFClient::UI::feed_sdl_key_up_event ($SDL_EV);
275 }, 285 },
276 SDL_MOUSEMOTION() => sub { 286 SDL_MOUSEMOTION() => sub {
277 CFClient::Widget::feed_sdl_motion_event ($SDL_EV); 287 CFClient::UI::feed_sdl_motion_event ($SDL_EV);
278 }, 288 },
279 SDL_MOUSEBUTTONDOWN() => sub { 289 SDL_MOUSEBUTTONDOWN() => sub {
280 CFClient::Widget::feed_sdl_button_down_event ($SDL_EV); 290 CFClient::UI::feed_sdl_button_down_event ($SDL_EV);
281 }, 291 },
282 SDL_MOUSEBUTTONUP() => sub { 292 SDL_MOUSEBUTTONUP() => sub {
283 CFClient::Widget::feed_sdl_button_up_event ($SDL_EV); 293 CFClient::UI::feed_sdl_button_up_event ($SDL_EV);
284 }, 294 },
285 SDL_ACTIVEEVENT() => sub { 295 SDL_ACTIVEEVENT() => sub {
286# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# 296# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d#
287 }, 297 },
288); 298);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines