… | |
… | |
19 | use CFClient::UI; |
19 | use CFClient::UI; |
20 | |
20 | |
21 | our $VERSION = '0.1'; |
21 | our $VERSION = '0.1'; |
22 | |
22 | |
23 | my $MAX_FPS = 60; |
23 | my $MAX_FPS = 60; |
24 | my $MIN_FPS = 5; # unused |
24 | my $MIN_FPS = 5; # unused as of yet |
25 | |
25 | |
26 | our $FACECACHE; |
26 | our $FACECACHE; |
27 | |
27 | |
28 | our $LAST_REFRESH; |
28 | our $LAST_REFRESH; |
29 | our $NOW; |
29 | our $NOW; |
… | |
… | |
34 | |
34 | |
35 | our @SDL_MODES; |
35 | our @SDL_MODES; |
36 | our $WIDTH; |
36 | our $WIDTH; |
37 | our $HEIGHT; |
37 | our $HEIGHT; |
38 | our $FULLSCREEN; |
38 | our $FULLSCREEN; |
|
|
39 | our $FONTSIZE; |
39 | |
40 | |
|
|
41 | our $MAP; |
40 | our $MAPWIDGET; |
42 | our $MAPWIDGET; |
41 | our $FONTSIZE; |
|
|
42 | |
43 | |
43 | our $SDL_ACTIVE; |
44 | our $SDL_ACTIVE; |
44 | our $SDL_EV; |
45 | our $SDL_EV; |
45 | our %SDL_CB; |
46 | our %SDL_CB; |
46 | |
47 | |
47 | our $ALT_ENTER_MESSAGE; |
48 | our $ALT_ENTER_MESSAGE; |
48 | our $STATUS_LINE; |
49 | our $STATUS_LINE; |
49 | our $DEBUG_STATUS; |
50 | our $DEBUG_STATUS; |
|
|
51 | our $BUTTONBAR; |
|
|
52 | our $LOGVIEW; |
|
|
53 | our $CONSOLE; |
50 | |
54 | |
51 | sub status { |
55 | sub status { |
52 | $STATUS_LINE->set_text ($_[0]); |
56 | $STATUS_LINE->set_text ($_[0]); |
53 | my ($w, $h) = $STATUS_LINE->size_request; |
57 | my ($w, $h) = $STATUS_LINE->size_request; |
54 | $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); |
58 | $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); |
… | |
… | |
63 | sub start_game { |
67 | sub start_game { |
64 | status "logging in..."; |
68 | status "logging in..."; |
65 | |
69 | |
66 | my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
70 | my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
67 | |
71 | |
|
|
72 | $MAP = new CFClient::Map $mapsize, $mapsize; |
|
|
73 | |
68 | $CONN = new conn |
74 | $CONN = new conn |
69 | host => $CFG->{host}, |
75 | host => $CFG->{host}, |
70 | port => $CFG->{port}, |
76 | port => $CFG->{port}, |
71 | user => $CFG->{user}, |
77 | user => $CFG->{user}, |
72 | pass => $CFG->{password}, |
78 | pass => $CFG->{password}, |
… | |
… | |
82 | sub stop_game { |
88 | sub stop_game { |
83 | undef $CONN; |
89 | undef $CONN; |
84 | } |
90 | } |
85 | |
91 | |
86 | sub config_dialog { |
92 | sub config_dialog { |
87 | my $dialog = new CFClient::UI::FancyFrame x => 300, y => 100, |
93 | my $dialog = new CFClient::UI::FancyFrame |
88 | child => (my $vbox = new CFClient::UI::VBox); |
94 | child => (my $vbox = new CFClient::UI::VBox); |
89 | $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); |
95 | $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); |
90 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
96 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
91 | |
97 | |
92 | $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode"); |
98 | $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode"); |
… | |
… | |
107 | $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub { |
113 | $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub { |
108 | my ($self, $value) = @_; |
114 | my ($self, $value) = @_; |
109 | $CFG->{fullscreen} = $value; |
115 | $CFG->{fullscreen} = $value; |
110 | }); |
116 | }); |
111 | |
117 | |
|
|
118 | $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Fast & Ugly"); |
|
|
119 | $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub { |
|
|
120 | my ($self, $value) = @_; |
|
|
121 | $CFG->{fast} = $value; |
|
|
122 | }); |
|
|
123 | |
|
|
124 | $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Fog of War"); |
|
|
125 | $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub { |
|
|
126 | my ($self, $value) = @_; |
|
|
127 | $CFG->{fow_enable} = $value; |
|
|
128 | }); |
|
|
129 | |
|
|
130 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "FoW Intensity"); |
|
|
131 | $table->add (1, 4, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub { |
|
|
132 | my ($self, $value) = @_; |
|
|
133 | $CFG->{fow_intensity} = $value; |
|
|
134 | }); |
|
|
135 | |
|
|
136 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth"); |
|
|
137 | $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
|
|
138 | my ($self, $value) = @_; |
|
|
139 | $CFG->{fow_smooth} = $value; |
|
|
140 | }); |
|
|
141 | |
112 | $table->add (1, 2, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
142 | $table->add (1, 6, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
113 | destroy_screen (); |
143 | destroy_screen (); |
114 | init_screen (); |
144 | init_screen (); |
115 | }); |
145 | }); |
116 | |
146 | |
117 | $vbox->add (new CFClient::UI::Label align => 0, text => "Server"); |
147 | $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); |
118 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
148 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
119 | $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host"); |
149 | $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host"); |
120 | $table->add (1, 2, my $host = new CFClient::UI::Entry text => $CFG->{host}); |
150 | $table->add (1, 2, my $host = new CFClient::UI::Entry text => $CFG->{host}, connect_changed => sub { |
121 | |
151 | my ($self, $value) = @_; |
|
|
152 | $CFG->{host} = $value; |
|
|
153 | }); |
|
|
154 | |
122 | $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Port"); |
155 | $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Port"); |
123 | $table->add (1, 3, my $port = new CFClient::UI::Entry text => $CFG->{port}); |
156 | $table->add (1, 3, my $port = new CFClient::UI::Entry text => $CFG->{port}, connect_changed => sub { |
|
|
157 | my ($self, $value) = @_; |
|
|
158 | $CFG->{port} = $value; |
|
|
159 | }); |
124 | |
160 | |
125 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username"); |
161 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username"); |
126 | $table->add (1, 4, my $user = new CFClient::UI::Entry text => $CFG->{user}); |
162 | $table->add (1, 4, my $user = new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { |
|
|
163 | my ($self, $value) = @_; |
|
|
164 | $CFG->{user} = $value; |
|
|
165 | }); |
127 | |
166 | |
128 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password"); |
167 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password"); |
129 | $table->add (1, 5, my $pass = new CFClient::UI::Entry text => $CFG->{password}, hidden => 1); |
168 | $table->add (1, 5, my $pass = new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { |
|
|
169 | my ($self, $value) = @_; |
|
|
170 | $CFG->{password} = $value; |
|
|
171 | }); |
130 | |
172 | |
|
|
173 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Def. say cmd"); |
|
|
174 | $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { |
|
|
175 | my ($self, $value) = @_; |
|
|
176 | $CFG->{say_command} = $value; |
|
|
177 | }); |
|
|
178 | |
131 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Map Size"); |
179 | $table->add (0, 7, new CFClient::UI::Label align => 1, text => "Map Size"); |
132 | $table->add (1, 6, new CFClient::UI::Slider |
180 | $table->add (1, 7, new CFClient::UI::Slider |
133 | req_w => 100, |
181 | req_w => 100, |
134 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
182 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
135 | connect_changed => sub { |
183 | connect_changed => sub { |
136 | my ($self, $value) = @_; |
184 | my ($self, $value) = @_; |
137 | |
185 | |
138 | $CFG->{mapsize} = $self->{range}[0] = $value = int $value; |
186 | $CFG->{mapsize} = $self->{range}[0] = $value = int $value; |
139 | }, |
187 | }, |
140 | ); |
188 | ); |
141 | |
189 | |
142 | $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub { |
190 | $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub { |
143 | start_game; |
191 | start_game; |
144 | }); |
192 | }); |
145 | |
193 | |
146 | $vbox->add (my $hbox = new CFClient::UI::HBox); |
194 | $vbox->add (my $hbox = new CFClient::UI::HBox); |
147 | |
195 | |
148 | $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub { |
196 | $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub { |
149 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
197 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
150 | status "Configuration Saved"; |
198 | status "Configuration Saved"; |
151 | }); |
199 | }); |
152 | $CFClient::UI::TOPLEVEL->add ($dialog); |
200 | |
|
|
201 | $dialog |
|
|
202 | } |
|
|
203 | |
|
|
204 | sub console_window { |
|
|
205 | my $window = new CFClient::UI::FancyFrame |
|
|
206 | border_bg => [1, 1, 1, 0.5], |
|
|
207 | bg => [0.3, 0.3, 0.3, 0.8], |
|
|
208 | child => (my $vbox = new CFClient::UI::VBox); |
|
|
209 | |
|
|
210 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView expand => 1); |
|
|
211 | $vbox->add (my $input = new CFClient::UI::LineEntry); |
|
|
212 | $input->connect (activate => sub { |
|
|
213 | my ($input, $text) = @_; |
|
|
214 | $input->set_text (''); |
|
|
215 | |
|
|
216 | if ($text =~ /^\/(.*)/) { |
|
|
217 | $::CONN->user_send ("command $1"); |
|
|
218 | } else { |
|
|
219 | my $say_cmd = $::CFG->{say_command} || 'say'; |
|
|
220 | $::CONN->user_send ("command $say_cmd $text"); |
|
|
221 | } |
|
|
222 | 1 |
|
|
223 | }); |
|
|
224 | $input->connect (escape => sub { |
|
|
225 | $MAPWIDGET->focus_in |
|
|
226 | }); |
|
|
227 | $input->focus_in; |
|
|
228 | |
|
|
229 | $CONSOLE = { |
|
|
230 | window => $window, |
|
|
231 | input => $input |
|
|
232 | }; |
|
|
233 | |
|
|
234 | $window |
|
|
235 | } |
|
|
236 | |
|
|
237 | sub sdl_init { |
|
|
238 | SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO |
|
|
239 | and die "SDL::Init failed!\n"; |
153 | } |
240 | } |
154 | |
241 | |
155 | sub init_screen { |
242 | sub init_screen { |
|
|
243 | sdl_init; |
|
|
244 | |
156 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
245 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
157 | $FULLSCREEN = $CFG->{fullscreen}; |
246 | $FULLSCREEN = $CFG->{fullscreen}; |
|
|
247 | $FAST = $CFG->{fast}; |
158 | |
248 | |
159 | SDL::GLSetAttribute SDL_GL_RED_SIZE, 5; |
249 | SDL::GLSetAttribute SDL_GL_RED_SIZE, 5; |
160 | SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5; |
250 | SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5; |
161 | SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5; |
251 | SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5; |
162 | SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 0; |
252 | SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 0; |
… | |
… | |
188 | |
278 | |
189 | $FONTSIZE = int $HEIGHT / 40; |
279 | $FONTSIZE = int $HEIGHT / 40; |
190 | |
280 | |
191 | ############################################################################# |
281 | ############################################################################# |
192 | |
282 | |
193 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0; |
283 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; |
194 | $CFClient::UI::TOPLEVEL->add ($DEBUG_STATUS); |
284 | $CFClient::UI::TOPLEVEL->add ($DEBUG_STATUS); |
195 | |
285 | |
196 | $STATUS_LINE = new CFClient::UI::Label |
286 | $STATUS_LINE = new CFClient::UI::Label |
197 | padding => 0, |
287 | padding => 0, |
198 | y => $HEIGHT * 49 / 50 - $FONTSIZE; |
288 | y => $HEIGHT * 44 / 45 - $FONTSIZE; |
199 | $CFClient::UI::TOPLEVEL->add ($STATUS_LINE); |
289 | $CFClient::UI::TOPLEVEL->add ($STATUS_LINE); |
200 | |
290 | |
201 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
291 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
202 | padding => 0, |
292 | padding => 0, |
203 | y => $HEIGHT * 49 / 50, |
293 | y => $HEIGHT * 44 / 45, |
204 | height => $HEIGHT / 50, |
294 | height => $HEIGHT / 45, |
205 | text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
295 | text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
206 | $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE); |
296 | $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE); |
207 | |
297 | |
208 | $MAPWIDGET = new CFClient::UI::MapWidget; |
|
|
209 | $CFClient::UI::TOPLEVEL->add ($MAPWIDGET); |
298 | $CFClient::UI::TOPLEVEL->add ($MAPWIDGET = new CFClient::UI::MapWidget); |
210 | $MAPWIDGET->focus_in; |
299 | $MAPWIDGET->focus_in; |
|
|
300 | $MAPWIDGET->connect (activate_console => sub { |
|
|
301 | my ($mapwidget, $preset) = @_; |
211 | |
302 | |
212 | config_dialog; |
303 | if ($CONSOLE) { |
|
|
304 | $CONSOLE->{input}->focus_in; |
|
|
305 | |
|
|
306 | if ($preset && $CONSOLE->{input}->get_text eq '') { |
|
|
307 | $CONSOLE->{input}->set_text ($preset); |
|
|
308 | } |
|
|
309 | } |
|
|
310 | }); |
|
|
311 | |
|
|
312 | $CFClient::UI::TOPLEVEL->add ($BUTTONBAR = new CFClient::UI::HBox); |
|
|
313 | |
|
|
314 | $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Setup", other => config_dialog, state => 1); |
|
|
315 | $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Console", other => console_window); |
213 | } |
316 | } |
214 | |
317 | |
215 | sub destroy_screen { |
318 | sub destroy_screen { |
216 | $CFClient::UI::TOPLEVEL->{children} = []; |
319 | $CFClient::UI::TOPLEVEL->{children} = []; |
217 | undef $SDL_ACTIVE; |
320 | undef $SDL_ACTIVE; |
… | |
… | |
240 | glLoadIdentity; |
343 | glLoadIdentity; |
241 | glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000; |
344 | glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000; |
242 | glMatrixMode GL_MODELVIEW; |
345 | glMatrixMode GL_MODELVIEW; |
243 | glLoadIdentity; |
346 | glLoadIdentity; |
244 | |
347 | |
|
|
348 | glClearColor +($CFG->{fow_intensity}) x 3, 1; |
245 | glClear GL_COLOR_BUFFER_BIT; |
349 | glClear GL_COLOR_BUFFER_BIT; |
246 | |
350 | |
247 | $CFClient::UI::TOPLEVEL->draw; |
351 | $CFClient::UI::TOPLEVEL->draw; |
248 | |
352 | |
249 | SDL::GLSwapBuffers; |
353 | SDL::GLSwapBuffers; |
… | |
… | |
283 | delete $animate_object{$widget}; |
387 | delete $animate_object{$widget}; |
284 | } |
388 | } |
285 | |
389 | |
286 | @conn::ISA = Crossfire::Protocol::; |
390 | @conn::ISA = Crossfire::Protocol::; |
287 | |
391 | |
288 | sub conn::map_update { |
392 | sub conn::user_send { |
|
|
393 | my ($self, $command) = @_; |
|
|
394 | |
|
|
395 | $self->send ($command); |
|
|
396 | status $command; |
|
|
397 | } |
|
|
398 | |
|
|
399 | sub conn::feed_map1a { |
289 | my ($self, $dirty) = @_; |
400 | my ($self, $data) = @_; |
290 | |
401 | |
|
|
402 | # $self->Crossfire::Protocol::feed_map1a ($data); |
|
|
403 | |
|
|
404 | $MAP->scroll (delete $self->{delayed_scroll_x}, delete $self->{delayed_scroll_y}); |
|
|
405 | $MAP->map1a_update ($data); |
291 | $MAPWIDGET->update; |
406 | $MAPWIDGET->update; |
292 | } |
407 | } |
293 | |
408 | |
294 | sub conn::map_scroll { |
409 | #sub conn::map_update { |
295 | my ($self, $dx, $dy) = @_; |
410 | # my ($self, $dirty) = @_; |
296 | |
411 | # |
297 | # refresh; |
412 | # $MAPWIDGET->update; |
298 | } |
413 | #} |
299 | |
414 | |
300 | sub conn::map_clear { |
415 | sub conn::map_clear { |
301 | my ($self) = @_; |
416 | my ($self) = @_; |
302 | |
417 | |
|
|
418 | $MAP->clear; |
|
|
419 | |
303 | # refresh; |
420 | # refresh; |
304 | } |
421 | } |
305 | |
422 | |
306 | sub conn::face_find { |
423 | sub conn::face_find { |
307 | my ($self, $face) = @_; |
424 | my ($self, $face) = @_; |
308 | |
425 | |
309 | $FACECACHE->{"$face->{chksum},$face->{name}"} |
426 | $FACECACHE->{"$face->{chksum},$face->{name}"} |
310 | } |
427 | } |
311 | |
428 | |
312 | sub conn::face_update { |
429 | sub conn::face_update { |
313 | my ($self, $face) = @_; |
430 | my ($self, $facenum, $face) = @_; |
314 | |
431 | |
315 | $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; |
432 | $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; |
316 | |
433 | |
317 | $face->{texture} = new_from_image CFClient::Texture delete $face->{image}; |
434 | my $tex = $face->{texture} = new_from_image CFClient::Texture delete $face->{image}; |
|
|
435 | |
|
|
436 | $MAP->set_texture ($facenum, @$tex{qw(name w h s t)}); |
|
|
437 | $MAPWIDGET->update; |
318 | } |
438 | } |
319 | |
439 | |
320 | sub conn::query { |
440 | sub conn::query { |
321 | my ($self, $flags, $prompt) = @_; |
441 | my ($self, $flags, $prompt) = @_; |
322 | |
442 | |
|
|
443 | #TODO |
323 | warn "<<<<QUERY:$flags:$prompt>>>\n";#d# |
444 | warn "<<<<QUERY:$flags:$prompt>>>\n";#d# |
|
|
445 | } |
|
|
446 | |
|
|
447 | sub conn::drawinfo { |
|
|
448 | my ($self, $color, $text) = @_; |
|
|
449 | |
|
|
450 | my @color = ( |
|
|
451 | [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], |
|
|
452 | [1.00, 1.00, 1.00], |
|
|
453 | [0.00, 0.00, 0.55], |
|
|
454 | [1.00, 0.00, 0.00], |
|
|
455 | [1.00, 0.54, 0.00], |
|
|
456 | [0.11, 0.56, 1.00], |
|
|
457 | [0.93, 0.46, 0.00], |
|
|
458 | [0.18, 0.54, 0.34], |
|
|
459 | [0.56, 0.73, 0.56], |
|
|
460 | [0.80, 0.80, 0.80], |
|
|
461 | [0.55, 0.41, 0.13], |
|
|
462 | [0.99, 0.77, 0.26], |
|
|
463 | [0.74, 0.65, 0.41], |
|
|
464 | ); |
|
|
465 | |
|
|
466 | $LOGVIEW->add_paragraph ($color[$color], $text); |
324 | } |
467 | } |
325 | |
468 | |
326 | %SDL_CB = ( |
469 | %SDL_CB = ( |
327 | SDL_QUIT() => sub { |
470 | SDL_QUIT() => sub { |
328 | Event::unloop -1; |
471 | Event::unloop -1; |
… | |
… | |
333 | refresh; |
476 | refresh; |
334 | }, |
477 | }, |
335 | SDL_KEYDOWN() => sub { |
478 | SDL_KEYDOWN() => sub { |
336 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
479 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
337 | # alt-enter |
480 | # alt-enter |
338 | $FULLSCREEN = !$FULLSCREEN; |
|
|
339 | destroy_screen; |
481 | destroy_screen; |
|
|
482 | $CFG->{fullscreen} = !$CFG->{fullscreen}; |
340 | init_screen; |
483 | init_screen; |
341 | } else { |
484 | } else { |
342 | CFClient::UI::feed_sdl_key_down_event ($SDL_EV); |
485 | CFClient::UI::feed_sdl_key_down_event ($SDL_EV); |
343 | } |
486 | } |
344 | }, |
487 | }, |
… | |
… | |
361 | |
504 | |
362 | ############################################################################# |
505 | ############################################################################# |
363 | |
506 | |
364 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
507 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
365 | |
508 | |
366 | $CFG ||= { |
509 | my %DEF_CFG = ( |
367 | width => 640, |
510 | width => 640, |
368 | height => 480, |
511 | height => 480, |
|
|
512 | fast => 0, |
|
|
513 | fow_enable => 1, |
|
|
514 | fow_intensity => 0.45, |
|
|
515 | fow_smooth => 0, |
369 | fullscreen => 0, |
516 | fullscreen => 0, |
370 | sdl_mode => 0, |
517 | sdl_mode => 0, |
371 | mapsize => 100, |
518 | mapsize => 100, |
372 | host => "crossfire.schmorp.de", |
519 | host => "crossfire.schmorp.de", |
373 | port => 13327, |
520 | port => 13327, |
374 | }; |
521 | say_command => 'say', |
|
|
522 | ); |
375 | |
523 | |
376 | SDL::Init SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO |
524 | while (my ($k, $v) = each %DEF_CFG) { |
377 | and die "SDL::Init failed!\n"; |
525 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
|
|
526 | } |
378 | |
527 | |
379 | @SDL_MODES = reverse map [SDL::RectW ($_), SDL::RectH ($_)], |
528 | sdl_init; |
|
|
529 | |
|
|
530 | @SDL_MODES = reverse |
|
|
531 | grep $_->[0] >= 640 && $_->[1] >= 480, |
|
|
532 | map [SDL::RectW ($_), SDL::RectH ($_)], |
380 | @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL }; |
533 | @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL }; |
|
|
534 | |
|
|
535 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
|
|
536 | |
|
|
537 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
381 | |
538 | |
382 | init_screen; |
539 | init_screen; |
383 | |
540 | |
384 | { |
541 | { |
385 | my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); |
542 | my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); |