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.109 by root, Sat Apr 15 01:45:32 2006 UTC vs.
Revision 1.145 by root, Wed Apr 19 20:46:45 2006 UTC

4use utf8; 4use utf8;
5 5
6use Time::HiRes 'time'; 6use Time::HiRes 'time';
7use Event; 7use Event;
8 8
9use SDL;
10use SDL::App;
11use SDL::Event; 9use SDL::Event;
10
11use SDL::Mixer;
12use SDL::Surface; 12use SDL::Sound;
13use SDL::Music;
14
13use SDL::OpenGL; 15use SDL::OpenGL;
14 16
15use Crossfire; 17use Crossfire;
16use Crossfire::Protocol; 18use Crossfire::Protocol;
17 19
20use Compress::LZF;
21
18use CFClient; 22use CFClient;
19use CFClient::UI; 23use CFClient::UI;
24use CFClient::MapWidget;
20 25
21our $VERSION = '0.1'; 26our $VERSION = '0.1';
22 27
23my $MAX_FPS = 60; 28my $MAX_FPS = 60;
24my $MIN_FPS = 5; # unused as of yet 29my $MIN_FPS = 5; # unused as of yet
25 30
31our $META_SERVER = "crossfire.real-time.com:13326";
32
33our $FACEMAP;
34our $TILECACHE;
26our $FACECACHE; 35our $MAPCACHE;
27 36
28our $LAST_REFRESH; 37our $LAST_REFRESH;
29our $NOW; 38our $NOW;
30 39
31our $CFG; 40our $CFG;
38our $FULLSCREEN; 47our $FULLSCREEN;
39our $FONTSIZE; 48our $FONTSIZE;
40 49
41our $MAP; 50our $MAP;
42our $MAPWIDGET; 51our $MAPWIDGET;
52our $BUTTONBAR;
53our $LOGVIEW;
54our $CONSOLE;
55our $METASERVER;
56
57our $GAUGES;
43 58
44our $SDL_ACTIVE; 59our $SDL_ACTIVE;
45our $SDL_EV; 60our $SDL_EV;
46our %SDL_CB; 61our %SDL_CB;
47 62
63our $SDL_MIXER;
64our @SOUNDS; # event => file mapping
65our %AUDIO_CHUNKS; # audio files
66
48our $ALT_ENTER_MESSAGE; 67our $ALT_ENTER_MESSAGE;
49our $STATUS_LINE; 68our $STATUS_LINE;
50our $DEBUG_STATUS; 69our $DEBUG_STATUS;
51our $BUTTONBAR;
52our $LOGVIEW;
53our $CONSOLE;
54 70
55sub status { 71sub status {
56 $STATUS_LINE->set_text ($_[0]); 72 $STATUS_LINE->set_text ($_[0]);
57 my ($w, $h) = $STATUS_LINE->size_request;
58 $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); 73 $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h});
59} 74}
60 75
61sub debug { 76sub debug {
62 $DEBUG_STATUS->set_text ($_[0]); 77 $DEBUG_STATUS->set_text ($_[0]);
63 my ($w, $h) = $DEBUG_STATUS->size_request; 78 $DEBUG_STATUS->move ($WIDTH - $DEBUG_STATUS->{w}, 0, $DEBUG_STATUS->{w}, $DEBUG_STATUS->{h});
64 $DEBUG_STATUS->size_allocate ($WIDTH - $w, 0, $w, $h);
65} 79}
66 80
67sub start_game { 81sub start_game {
68 status "logging in..."; 82 status "logging in...";
69 83
70 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 84 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
71 85
86 $MAPCACHE = CFClient::db_table "mapcache_$CFG->{host}";
87
72 $MAP = new CFClient::Map $mapsize, $mapsize; 88 $MAP = new CFClient::Map $mapsize, $mapsize;
89
90 my ($host, $port) = split /:/, $CFG->{host};
73 91
74 $CONN = new conn 92 $CONN = new conn
75 host => $CFG->{host}, 93 host => $host,
76 port => $CFG->{port}, 94 port => $port || 13327,
77 user => $CFG->{user}, 95 user => $CFG->{user},
78 pass => $CFG->{password}, 96 pass => $CFG->{password},
79 mapw => $mapsize, 97 mapw => $mapsize,
80 maph => $mapsize, 98 maph => $mapsize,
81 ; 99 ;
87 105
88sub stop_game { 106sub stop_game {
89 undef $CONN; 107 undef $CONN;
90} 108}
91 109
92sub config_dialog { 110sub client_setup {
93 my $dialog = new CFClient::UI::FancyFrame 111 my $dialog = new CFClient::UI::FancyFrame
94 child => (my $vbox = new CFClient::UI::VBox); 112 child => (my $vbox = new CFClient::UI::VBox);
95 $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); 113 $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Client Setup");
96 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 114 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
97 115
98 $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode"); 116 $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode");
99 $table->add (1, 0, my $hbox = new CFClient::UI::HBox); 117 $table->add (1, 0, my $hbox = new CFClient::UI::HBox);
100 118
101 $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]); 119 $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]);
102 $hbox->add (my $mode_label = new CFClient::UI::Label height => $FONTSIZE * 0.8); 120 $hbox->add (my $mode_label = new CFClient::UI::Label valign => 0, height => 0.8);
103 121
104 $mode_slider->connect (changed => sub { 122 $mode_slider->connect (changed => sub {
105 my ($self, $value) = @_; 123 my ($self, $value) = @_;
106 124
107 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; 125 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value;
108 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); 126 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]});
109 }); 127 });
110 $mode_slider->emit (changed => $mode_slider->{range}[0]); 128 $mode_slider->emit (changed => $mode_slider->{range}[0]);
111 129
112 $table->add (0, 1, new CFClient::UI::Label align => 1, text => "Fullscreen"); 130 $table->add (0, 1, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen");
113 $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub { 131 $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub {
114 my ($self, $value) = @_; 132 my ($self, $value) = @_;
115 $CFG->{fullscreen} = $value; 133 $CFG->{fullscreen} = $value;
116 }); 134 });
117 135
118 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Fast & Ugly"); 136 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Fast & Ugly");
119 $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub { 137 $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub {
120 my ($self, $value) = @_; 138 my ($self, $value) = @_;
121 $CFG->{fast} = $value; 139 $CFG->{fast} = $value;
122 }); 140 });
123 141
124 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Fog of War"); 142 $table->add (0, 3, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War");
125 $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub { 143 $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub {
126 my ($self, $value) = @_; 144 my ($self, $value) = @_;
127 $CFG->{fow_enable} = $value; 145 $CFG->{fow_enable} = $value;
128 }); 146 });
129 147
130 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "FoW Intensity"); 148 $table->add (0, 4, new CFClient::UI::Label valign => 0, 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 { 149 $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) = @_; 150 my ($self, $value) = @_;
133 $CFG->{fow_intensity} = $value; 151 $CFG->{fow_intensity} = $value;
134 }); 152 });
135 153
136 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth"); 154 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Smooth");
137 $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { 155 $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub {
138 my ($self, $value) = @_; 156 my ($self, $value) = @_;
139 $CFG->{fow_smooth} = $value; 157 $CFG->{fow_smooth} = $value;
158 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2;
140 }); 159 });
141 160
142 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Log Fontsize"); 161 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize");
162 $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{gui_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub {
163 $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10;
164# $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
165 });
166
167 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize");
143 $table->add (1, 5, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 8, 30, 1], connect_changed => sub { 168 $table->add (1, 7, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub {
144 my ($self, $value) = @_;
145 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = int $value); 169 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10);
146 }); 170 });
147 171
148 $table->add (1, 6, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 172 $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
149 destroy_screen (); 173 video_shutdown ();
150 init_screen (); 174 video_init ();
175 });
176
177 $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable");
178 $table->add (1, 9, new CFClient::UI::CheckBox state => $CFG->{audio_enable}, connect_changed => sub {
179 $CFG->{audio_enable} = $_[1];
180 });
181# $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume");
182# $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], connect_changed => sub {
183# $CFG->{effects_volume} = $_[1];
151 }); 184# });
185 $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music");
186 $table->add (1, 10, my $hbox = new CFClient::UI::HBox);
187 $hbox->add (new CFClient::UI::CheckBox expand => 1, state => $CFG->{bgm_enable}, connect_changed => sub {
188 $CFG->{bgm_enable} = $_[1];
189 });
190 $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 128, 1], connect_changed => sub {
191 $CFG->{bgm_volume} = $_[1];
192 $SDL_MIXER->music_volume ($_[1]);
193 });
194
195 $table->add (1, 11, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
196 audio_shutdown ();
197 audio_init ();
198 });
199
200 $dialog
201}
202
203sub metaserver_dialog {
204 my $dialog = new CFClient::UI::FancyFrame
205 child => (my $vbox = new CFClient::UI::VBox);
206
207 $vbox->add ($dialog->{table} = new CFClient::UI::Table);
208
209 $dialog
210}
211
212sub update_metaserver {
213 my ($HOST) = @_;
214
215 status "fetching metaserver list...";
216
217 my $buf;
218
219 my $fh = new IO::Socket::INET PeerHost => $META_SERVER, Blocking => 0;
220
221 Event->io (fd => $fh, poll => 'r', cb => sub {
222 my $res = sysread $fh, $buf, 8192, length $buf;
223
224 if (!defined $res) {
225 $_[0]->w->cancel;
226 status "metaserver: $!";
227 } elsif ($res == 0) {
228 $_[0]->w->cancel;
229 status "server list retrieved";
230
231 my $table = $METASERVER->{table};
232
233 $table->clear;
234
235 my @col = qw(Use #Users Host Uptime Version Description);
236 $table->add ($_, 0, new CFClient::UI::Label align => 0, fg => [1, 1, 0], text => $col[$_])
237 for 0 .. $#col;
238
239 my @align = qw(1 0 1 1 -1);
240
241 my $y = 0;
242 for my $m (sort { $b->[3] <=> $a->[3] } map [split /\|/], split /\015?\012/, $buf) {
243 my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime) = @$m;
244
245 for ($desc) {
246 s/<br>/\n/gi;
247 s/<li>/\n· /gi;
248 s/<.*?>//sgi;
249 s/&/&amp;/g;
250 s/</&lt;/g;
251 s/>/&gt;/g;
252 }
253
254 $uptime = sprintf "%dd %02d:%02d:%02d",
255 (int $m->[8] / 86400),
256 (int $m->[8] / 3600) % 24,
257 (int $m->[8] / 60) % 60,
258 $m->[8] % 60;
259
260 $m = [$users, $host, $uptime, $version, $desc];
261
262 $y++;
263
264 $table->add (0, $y, new CFClient::UI::VBox children => [
265 (new CFClient::UI::Button text => " ", connect_activate => sub {
266 $HOST->set_text ($CFG->{host} = $host);
267 }),
268 (new CFClient::UI::Empty expand => 1),
269 ]);
270
271 $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => 0.8)
272 for 0 .. $#$m;
273 }
274 }
275 });
276}
277
278sub server_setup {
279 my $dialog = new CFClient::UI::FancyFrame
280 child => (my $vbox = new CFClient::UI::VBox);
152 281
153 $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); 282 $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Server Setup");
154 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 283 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
155 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host"); 284 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port");
285
286 {
287 $table->add (1, 2, my $vbox = new CFClient::UI::VBox);
288
156 $table->add (1, 2, my $host = new CFClient::UI::Entry text => $CFG->{host}, connect_changed => sub { 289 $vbox->add (my $HOST = new CFClient::UI::Entry expand => 1, text => $CFG->{host}, connect_changed => sub {
157 my ($self, $value) = @_; 290 my ($self, $value) = @_;
158 $CFG->{host} = $value; 291 $CFG->{host} = $value;
159 }); 292 });
160 293
161 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Port"); 294 $METASERVER = metaserver_dialog;
162 $table->add (1, 3, my $port = new CFClient::UI::Entry text => $CFG->{port}, connect_changed => sub { 295
163 my ($self, $value) = @_; 296 $vbox->add (new CFClient::UI::Flopper expand => 1, text => "Metaserver", other => $METASERVER, connect_open => sub {
164 $CFG->{port} = $value; 297 update_metaserver $HOST;
165 }); 298 });
299 }
166 300
167 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username"); 301 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
168 $table->add (1, 4, my $user = new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { 302 $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub {
169 my ($self, $value) = @_; 303 my ($self, $value) = @_;
170 $CFG->{user} = $value; 304 $CFG->{user} = $value;
171 }); 305 });
172 306
173 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password"); 307 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password");
174 $table->add (1, 5, my $pass = new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { 308 $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub {
175 my ($self, $value) = @_; 309 my ($self, $value) = @_;
176 $CFG->{password} = $value; 310 $CFG->{password} = $value;
177 }); 311 });
178 312
179 $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Def. say cmd"); 313 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd");
180 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { 314 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub {
181 my ($self, $value) = @_; 315 my ($self, $value) = @_;
182 $CFG->{say_command} = $value; 316 $CFG->{say_command} = $value;
183 }); 317 });
184 318
185 $table->add (0, 7, new CFClient::UI::Label align => 1, text => "Map Size"); 319 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
186 $table->add (1, 7, new CFClient::UI::Slider 320 $table->add (1, 7, new CFClient::UI::Slider
187 req_w => 100, 321 req_w => 100,
188 range => [$CFG->{mapsize}, 10, 100 + 1, 1], 322 range => [$CFG->{mapsize}, 10, 100 + 1, 1],
189 connect_changed => sub { 323 connect_changed => sub {
190 my ($self, $value) = @_; 324 my ($self, $value) = @_;
195 329
196 $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub { 330 $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub {
197 start_game; 331 start_game;
198 }); 332 });
199 333
200 $vbox->add (my $hbox = new CFClient::UI::HBox);
201
202 $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub {
203 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
204 status "Configuration Saved";
205 });
206
207 $dialog 334 $dialog
208} 335}
209 336
210sub console_window { 337sub message_window {
211 my $window = new CFClient::UI::FancyFrame 338 my $window = new CFClient::UI::FancyFrame
212 border_bg => [1, 1, 1, 0.5], 339 border_bg => [1, 1, 1, 0.5],
213 bg => [0.3, 0.3, 0.3, 0.8], 340 bg => [0.3, 0.3, 0.3, 0.8],
214 user_w => $::WIDTH/4, 341 user_w => int $::WIDTH / 3,
215 user_h => $::HEIGHT, 342 user_h => int $::HEIGHT / 5,
216 child => (my $vbox = new CFClient::UI::VBox); 343 child => (my $vbox = new CFClient::UI::VBox);
217 344
218 $vbox->add ($LOGVIEW = new CFClient::UI::TextView 345 $vbox->add ($LOGVIEW = new CFClient::UI::TextView
219 expand => 1, 346 expand => 1,
220 fontsize => $::CFG->{log_fontsize}, 347 fontsize => $::CFG->{log_fontsize},
221 ); 348 );
222 349
223 $vbox->add (my $input = new CFClient::UI::LineEntry); 350 $vbox->add (my $input = new CFClient::UI::Entry
351 connect_focus_in => sub {
352 my ($input, $prev_focus) = @_;
353
354 delete $input->{refocus_map};
355
356 if ($prev_focus == $MAPWIDGET && $input->{auto_activated}) {
357 $input->{refocus_map} = 1;
358 }
359 delete $input->{auto_activated};
360 },
224 $input->connect (activate => sub { 361 connect_activate => sub {
225 my ($input, $text) = @_; 362 my ($input, $text) = @_;
226 $input->set_text (''); 363 $input->set_text ('');
227 364
228 if ($text =~ /^\/(.*)/) { 365 if ($text =~ /^\/(.*)/) {
229 $::CONN->user_send ("command $1"); 366 $::CONN->user_send ($1);
230 } else { 367 } else {
231 my $say_cmd = $::CFG->{say_command} || 'say'; 368 my $say_cmd = $::CFG->{say_command} || 'say';
232 $::CONN->user_send ("command $say_cmd $text"); 369 $::CONN->user_send ("$say_cmd $text");
233 } 370 }
371 if ($input->{refocus_map}) {
372 delete $input->{refocus_map};
373 $MAPWIDGET->focus_in
234 1 374 }
235 }); 375 },
236 $input->connect (escape => sub { 376 connect_escape => sub {
237 $MAPWIDGET->focus_in 377 $MAPWIDGET->focus_in
238 }); 378 },
239 $input->focus_in; 379 );
240 380
241 $CONSOLE = { 381 $CONSOLE = {
242 window => $window, 382 window => $window,
243 input => $input 383 input => $input
244 }; 384 };
245 385
246 $window 386 $window
247} 387}
248 388
249sub sdl_init { 389sub sdl_init {
250 #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE 390 CFClient::SDL_Init
251 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO
252 and die "SDL::Init failed!\n"; 391 and die "SDL::Init failed!\n";
253} 392}
254 393
255sub init_screen { 394sub video_init {
256 sdl_init; 395 sdl_init;
257 396
258 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; 397 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
259 $FULLSCREEN = $CFG->{fullscreen}; 398 $FULLSCREEN = $CFG->{fullscreen};
260 $FAST = $CFG->{fast}; 399 $FAST = $CFG->{fast};
261 400
262 SDL::GLSetAttribute SDL_GL_RED_SIZE, 5; 401 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN
263 SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5;
264 SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5;
265 SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 0;
266
267 SDL::GLSetAttribute SDL_GL_ACCUM_RED_SIZE, 0;
268 SDL::GLSetAttribute SDL_GL_ACCUM_GREEN_SIZE, 0;
269 SDL::GLSetAttribute SDL_GL_ACCUM_BLUE_SIZE, 0;
270 SDL::GLSetAttribute SDL_GL_ACCUM_ALPHA_SIZE, 0;
271
272 SDL::GLSetAttribute SDL_GL_DOUBLEBUFFER, 1;
273 SDL::GLSetAttribute SDL_GL_BUFFER_SIZE, 15;
274 SDL::GLSetAttribute SDL_GL_DEPTH_SIZE, 0;
275
276 SDL::SetVideoMode $WIDTH, $HEIGHT, 0,
277 SDL_HWSURFACE | SDL_ANYFORMAT | SDL_OPENGL | SDL_DOUBLEBUF
278 | ($FULLSCREEN ? SDL_FULLSCREEN : 0)
279 or die "SDL::SetVideoMode failed!\n"; 402 or die "SDL_SetVideoMode failed!\n";
280
281 SDL::WMSetCaption "Crossfire+ Client", "Crossfire+";
282 403
283 $SDL_EV = new SDL::Event; 404 $SDL_EV = new SDL::Event;
284 $SDL_EV->set_unicode (1); 405 $SDL_EV->set_unicode (1);
285 406
286 $SDL_ACTIVE = 1; 407 $SDL_ACTIVE = 1;
287 408
288 $LAST_REFRESH = time - 0.01; 409 $LAST_REFRESH = time - 0.01;
289 410
290 CFClient::gl_init; 411 CFClient::gl_init;
291 412
292 $FONTSIZE = int $HEIGHT / 40; 413 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
293 414
294 ############################################################################# 415 #############################################################################
295 416
296 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; 417 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100;
297 $CFClient::UI::TOPLEVEL->add ($DEBUG_STATUS); 418 $DEBUG_STATUS->show;
298 419
299 $STATUS_LINE = new CFClient::UI::Label 420 $STATUS_LINE = new CFClient::UI::Label
300 padding => 0, 421 padding => 0,
301 y => $HEIGHT * 44 / 45 - $FONTSIZE; 422 y => $HEIGHT - $FONTSIZE * 1.8;
302 $CFClient::UI::TOPLEVEL->add ($STATUS_LINE); 423 $STATUS_LINE->show;
303 424
304 $ALT_ENTER_MESSAGE = new CFClient::UI::Label 425 $ALT_ENTER_MESSAGE = new CFClient::UI::Label
305 padding => 0, 426 padding => 0,
306 y => $HEIGHT * 44 / 45, 427 fontsize => 0.8,
307 height => $HEIGHT / 45,
308 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 428 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
309 $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE); 429 $ALT_ENTER_MESSAGE->show;
430 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h});
310 431
311 $CFClient::UI::TOPLEVEL->add ($MAPWIDGET = new CFClient::UI::MapWidget); 432 $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::MapWidget);
312 $MAPWIDGET->focus_in; 433 $MAPWIDGET->focus_in;
313 $MAPWIDGET->connect (activate_console => sub { 434 $MAPWIDGET->connect (activate_console => sub {
314 my ($mapwidget, $preset) = @_; 435 my ($mapwidget, $preset) = @_;
315 436
316 if ($CONSOLE) { 437 if ($CONSOLE) {
438 $CONSOLE->{input}->{auto_activated} = 1;
317 $CONSOLE->{input}->focus_in; 439 $CONSOLE->{input}->focus_in;
318 440
319 if ($preset && $CONSOLE->{input}->get_text eq '') { 441 if ($preset && $CONSOLE->{input}->get_text eq '') {
320 $CONSOLE->{input}->set_text ($preset); 442 $CONSOLE->{input}->set_text ($preset);
321 } 443 }
322 } 444 }
323 }); 445 });
324 446
325 $CFClient::UI::TOPLEVEL->add ($BUTTONBAR = new CFClient::UI::HBox); 447 $CFClient::UI::ROOT->add ($BUTTONBAR = new CFClient::UI::HBox);
326 448
327 $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Setup", other => config_dialog, state => 1); 449 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup);
328 $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Console", other => console_window); 450 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup);
329} 451 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window);
330 452
331sub destroy_screen { 453 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub {
454 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
455 status "Configuration Saved";
456 });
457
458 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
459
460 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 300, y => 0);
461 $tgw->add (my $hbox = new CFClient::UI::HBox ());
462
463 $hbox->add (my $hg = new CFClient::UI::VGauge (gauge => 'hp'));
464 $hbox->add (my $mg = new CFClient::UI::VGauge (gauge => 'mana'));
465 $hbox->add (my $gg = new CFClient::UI::VGauge (gauge => 'grace'));
466 $hbox->add (my $fg = new CFClient::UI::VGauge (gauge => 'food'));
467
468 $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg };
469 $CFClient::UI::ROOT->add ($tgw);
470}
471
472sub video_shutdown {
332 $CFClient::UI::TOPLEVEL->{children} = []; 473 $CFClient::UI::ROOT->{children} = [];
333 undef $SDL_ACTIVE; 474 undef $SDL_ACTIVE;
334 undef $SDL_EV; 475 undef $SDL_EV;
335 SDL::Quit; 476}
477
478my $bgmusic;#TODO#hack#d#
479
480sub audio_init {
481 if ($CFG->{audio_enable}) {
482 if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") {
483
484 $SDL_MIXER = new SDL::Mixer
485 -rate => 22050,
486 -channels => 1, # mono
487 -size => 512;
488
489 $SDL_MIXER->allocate_channels (8);
490
491 # TODO: hack, do play loop and mood music
492 if ($CFG->{bgm_enable}) {
493 $bgmusic = new SDL::Music CFClient::find_rcfile "music/game3.ogg";
494 $SDL_MIXER->play_music ($bgmusic, -1);
495 $SDL_MIXER->music_volume ($CFG->{bgm_volume});
496 }
497
498 while (<$fh>) {
499 next if /^\s*#/;
500 next if /^\s*$/;
501
502 my ($file, $volume, $event) = split /\s+/, $_, 3;
503
504 push @SOUNDS, "$volume,$file";
505
506 $AUDIO_CHUNKS{"$volume,$file"} ||= do {
507 my $chunk = new SDL::Sound CFClient::find_rcfile "sounds/$file";
508 $chunk->volume ($volume * 128 / 100);
509 $chunk
510 };
511 }
512 } else {
513 status "unable to open sound config: $!";
514 }
515 }
516}
517
518sub audio_shutdown {
519 undef $SDL_MIXER;
520 @SOUNDS = ();
521 %AUDIO_CHUNKS = ();
336} 522}
337 523
338my %animate_object; 524my %animate_object;
339my $animate_timer; 525my $animate_timer;
340 526
348 debug sprintf "%3.2f", $fps; 534 debug sprintf "%3.2f", $fps;
349 535
350 $want_refresh = 0; 536 $want_refresh = 0;
351 $can_refresh = 0; 537 $can_refresh = 0;
352 538
353 $CFClient::UI::TOPLEVEL->draw; 539 $CFClient::UI::ROOT->draw;
354 540
355 SDL::GLSwapBuffers; 541 SDL::GLSwapBuffers;
356 542
357 $LAST_REFRESH = $NOW; 543 $LAST_REFRESH = $NOW;
358} 544}
389 delete $animate_object{$widget}; 575 delete $animate_object{$widget};
390} 576}
391 577
392@conn::ISA = Crossfire::Protocol::; 578@conn::ISA = Crossfire::Protocol::;
393 579
580sub conn::stats_update {
581 my ($self, $stats) = @_;
582
583 # i love text protocols!!!
584 # FIXME: the stats are somehow weird
585 my $hp = $stats->{1};
586 my $hp_m = $stats->{2};
587 my $sp = $stats->{3};
588 my $sp_m = $stats->{4};
589 my $fo = $stats->{18};
590 my $fo_m = 1000;
591 my $gr = $stats->{23};
592 my $gr_m = $stats->{24};
593
594 #d# warn "DATA $hp $hp_m $sp $sp_m $fo $fo_m $gr $gr_m\n";
595 $GAUGES->{hp}->set_value ($hp, $hp_m);
596 $GAUGES->{mana}->set_value ($sp, $sp_m);
597 $GAUGES->{food}->set_value ($fo, $fo_m);
598 $GAUGES->{grace}->set_value ($gr, $gr_m);
599}
600
394sub conn::user_send { 601sub conn::user_send {
395 my ($self, $command) = @_; 602 my ($self, $command) = @_;
396 603
397 $self->send ($command); 604 $self->send_command ($command);
398 status $command; 605 status $command;
606}
607
608sub conn::map_scroll {
609 my ($self, $dx, $dy) = @_;
610
611 $MAP->scroll ($dx, $dy);
399} 612}
400 613
401sub conn::feed_map1a { 614sub conn::feed_map1a {
402 my ($self, $data) = @_; 615 my ($self, $data) = @_;
403 616
404# $self->Crossfire::Protocol::feed_map1a ($data); 617# $self->Crossfire::Protocol::feed_map1a ($data);
405 618
406 $MAP->scroll (delete $self->{delayed_scroll_x}, delete $self->{delayed_scroll_y});
407 $MAP->map1a_update ($data); 619 $MAP->map1a_update ($data);
408 $MAPWIDGET->update; 620 $MAPWIDGET->update;
409} 621}
410 622
411#sub conn::map_update { 623sub conn::flush_map {
412# my ($self, $dirty) = @_; 624 my ($self) = @_;
413# 625
414# $MAPWIDGET->update; 626 my $map_info = delete $self->{map_info}
415#} 627 or return;
628
629 my ($hash, $x, $y, $w, $h) = @$map_info;
630
631 my $data = $MAP->get_rect ($x, $y, $w, $h);
632 $MAPCACHE->put ($hash => Compress::LZF::compress $data);
633
634 warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d#
635
636}
416 637
417sub conn::map_clear { 638sub conn::map_clear {
418 my ($self) = @_; 639 my ($self) = @_;
419 640
641 $self->flush_map;
642 delete $self->{neigh};
643
420 $MAP->clear; 644 $MAP->clear;
645}
421 646
422# refresh; 647
648sub conn::load_map($$$) {
649 my ($self, $hash, $x, $y) = @_;
650
651 if (defined (my $data = $MAPCACHE->get ($hash))) {
652 $data = Compress::LZF::decompress $data;
653 warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d#
654 for my $id ($MAP->set_rect ($x, $y, $data)) {
655 my $data = $TILECACHE->get ($id)
656 or next;
657
658 $self->set_texture ($id => $data);
659 }
660 }
661}
662
663sub conn::flood_fill {
664 my ($self, $path, $hash, $flags, $x0, $y0, $x1, $y1) = @_;
665
666 # the server does not allow map paths > 6
667 return if 6 <= length $path;
668
669 for my $tile (1..4) {
670 next if $self->{neigh}{$hash}[$tile];
671 next unless $flags & (1 << ($tile - 1));
672
673 my $neigh = $self->{neigh}{$hash} ||= [];
674
675 $self->send_mapinfo ("spatial $path$tile", sub {
676 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_;
677
678 #warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d#
679 return if $mode ne "spatial";
680
681 $x += $MAP->ox;
682 $y += $MAP->oy;
683
684 $self->load_map ($hash, $x, $y)
685 unless $self->{neigh}{$hash}[5]++;#d#
686
687 $neigh->[$tile] = [$x, $y, $w, $h];
688
689 $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1)
690 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1;
691 });
692 }
693}
694
695sub conn::map_change {
696 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
697
698 $self->flush_map;
699
700 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
701
702 my $mapmapw = 250;
703 my $mapmaph = 250;
704
705 $self->flood_fill ("", $hash, $flags,
706 $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5,
707 $ox + $mapmapw * 0.5, $oy + $mapmapw * 0.5);
708
709 $x += $ox;
710 $y += $oy;
711
712 $self->{map_info} = [$hash, $x, $y, $w, $h];
713
714 $self->load_map ($hash, $x, $y);
423} 715}
424 716
425sub conn::face_find { 717sub conn::face_find {
426 my ($self, $face) = @_; 718 my ($self, $facenum, $face) = @_;
427 719
428 $FACECACHE->{"$face->{chksum},$face->{name}"} 720 my $hash = "$face->{chksum},$face->{name}";
721
722 my $id = $FACEMAP->get ($hash);
723
724 unless ($id) {
725 # create new id for face
726 # i love transactions
727 for (1..100) {
728 my $txn = $CFClient::DB_ENV->txn_begin;
729 my $status = $FACEMAP->db_get (id => $id, BerkeleyDB::DB_RMW);
730 if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) {
731 $id++;
732 if ($FACEMAP->put (id => $id) == 0
733 && $FACEMAP->put ($hash => $id) == 0) {
734 $txn->txn_commit;
735
736 goto gotid;
737 }
738 }
739 $txn->abort;
740 }
741
742 CFClient::fatal "maximum number of transaction retries reached - database problems?";
743 }
744
745gotid:
746 $face->{id} = $id;
747 $MAP->set_face ($facenum => $id);
748 $TILECACHE->get ($id)
429} 749}
430 750
431sub conn::face_update { 751sub conn::face_update {
432 my ($self, $facenum, $face) = @_; 752 my ($self, $facenum, $face) = @_;
433 753
434 $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; 754 $TILECACHE->put ($face->{id} => $face->{image}); #TODO: try to avoid duplicate writes
435 755
436 my $tex = $face->{texture} = 756 $self->set_texture ($face->{id} => delete $face->{image});
757}
758
759sub conn::set_texture {
760 my ($self, $id, $data) = @_;
761
762 $self->{texture}[$id] ||= do {
763 my $tex =
437 new_from_image CFClient::Texture 764 new_from_image CFClient::Texture
438 delete $face->{image}, minify => 1; 765 $data, minify => 1;
439 766
440 $MAP->set_texture ($facenum, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 767 $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}});
441 $MAPWIDGET->update; 768 $MAPWIDGET->update;
769
770 $tex
771 };
772}
773
774sub conn::sound_play {
775 my ($self, $x, $y, $soundnum, $type) = @_;
776
777 $SDL_MIXER
778 or return;
779
780 my $chunk = $AUDIO_CHUNKS{$SOUNDS[$soundnum]}
781 or return;
782
783 $SDL_MIXER->play_channel (-1, $chunk);
784# warn "sound $x,$y,$soundnum,$type\n";#d#
442} 785}
443 786
444sub conn::query { 787sub conn::query {
445 my ($self, $flags, $prompt) = @_; 788 my ($self, $flags, $prompt) = @_;
446 789
447 #TODO 790 #TODO, display dialog with relevant information
448 warn "<<<<QUERY:$flags:$prompt>>>\n";#d# 791 warn "<<<<QUERY:$flags:$prompt>>>\n";#d#
449} 792}
450 793
451sub conn::drawinfo { 794sub conn::drawinfo {
452 my ($self, $color, $text) = @_; 795 my ($self, $color, $text) = @_;
453 796
454 my @color = ( 797 my @color = (
455 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], 798 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00],
456 [1.00, 1.00, 1.00], 799 [1.00, 1.00, 1.00],
457 [0.00, 0.00, 0.55], 800 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55]
458 [1.00, 0.00, 0.00], 801 [1.00, 0.00, 0.00],
459 [1.00, 0.54, 0.00], 802 [1.00, 0.54, 0.00],
460 [0.11, 0.56, 1.00], 803 [0.11, 0.56, 1.00],
461 [0.93, 0.46, 0.00], 804 [0.93, 0.46, 0.00],
462 [0.18, 0.54, 0.34], 805 [0.18, 0.54, 0.34],
468 ); 811 );
469 812
470 $LOGVIEW->add_paragraph ($color[$color], $text); 813 $LOGVIEW->add_paragraph ($color[$color], $text);
471} 814}
472 815
816sub conn::spell_add {
817 my ($self, $spell) = @_;
818
819 $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}, sub {
820 });
821 $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}, sub {
822 });
823}
824
825sub conn::spell_delete {
826 my ($self, $spell) = @_;
827}
828
829sub conn::addme_success {
830 my ($self) = @_;
831
832 for my $skill (values %{$self->{skill_info}}) {
833 $MAPWIDGET->add_command ("ready_skill $skill", "", sub {
834 });
835 $MAPWIDGET->add_command ("use_skill $skill", "", sub {
836 });
837 }
838}
839
473%SDL_CB = ( 840%SDL_CB = (
474 SDL_QUIT() => sub { 841 CFClient::SDL_QUIT => sub {
475 Event::unloop -1; 842 Event::unloop -1;
476 }, 843 },
477 SDL_VIDEORESIZE() => sub { 844 CFClient::SDL_VIDEORESIZE => sub {
478 }, 845 },
479 SDL_VIDEOEXPOSE() => sub { 846 CFClient::SDL_VIDEOEXPOSE => sub {
480 refresh; 847 refresh;
481 }, 848 },
482 SDL_KEYDOWN() => sub { 849 CFClient::SDL_KEYDOWN => sub {
483 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { 850 if ($SDL_EV->key_mod & CFClient::KMOD_ALT && $SDL_EV->key_sym == 13) {
484 # alt-enter 851 # alt-enter
485 destroy_screen; 852 video_shutdown;
486 $CFG->{fullscreen} = !$CFG->{fullscreen}; 853 $CFG->{fullscreen} = !$CFG->{fullscreen};
487 init_screen; 854 video_init;
488 } else { 855 } else {
489 CFClient::UI::feed_sdl_key_down_event ($SDL_EV); 856 CFClient::UI::feed_sdl_key_down_event ($SDL_EV);
490 } 857 }
491 }, 858 },
492 SDL_KEYUP() => sub { 859 CFClient::SDL_KEYUP => sub {
493 CFClient::UI::feed_sdl_key_up_event ($SDL_EV); 860 CFClient::UI::feed_sdl_key_up_event ($SDL_EV);
494 }, 861 },
495 SDL_MOUSEMOTION() => sub { 862 CFClient::SDL_MOUSEMOTION => sub {
496 CFClient::UI::feed_sdl_motion_event ($SDL_EV); 863 CFClient::UI::feed_sdl_motion_event ($SDL_EV);
497 }, 864 },
498 SDL_MOUSEBUTTONDOWN() => sub { 865 CFClient::SDL_MOUSEBUTTONDOWN => sub {
499 CFClient::UI::feed_sdl_button_down_event ($SDL_EV); 866 CFClient::UI::feed_sdl_button_down_event ($SDL_EV);
500 }, 867 },
501 SDL_MOUSEBUTTONUP() => sub { 868 CFClient::SDL_MOUSEBUTTONUP => sub {
502 CFClient::UI::feed_sdl_button_up_event ($SDL_EV); 869 CFClient::UI::feed_sdl_button_up_event ($SDL_EV);
503 }, 870 },
504 SDL_ACTIVEEVENT() => sub { 871 CFClient::SDL_ACTIVEEVENT => sub {
505# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# 872# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d#
506 }, 873 },
507); 874);
508 875
509############################################################################# 876#############################################################################
877
878$SIG{INT} = $SIG{TERM} = sub { exit };
879
880$TILECACHE = CFClient::db_table "tilecache";
881$FACEMAP = CFClient::db_table "facemap";
510 882
511CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; 883CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
512 884
513my %DEF_CFG = ( 885my %DEF_CFG = (
514 sdl_mode => 0, 886 sdl_mode => 0,
517 fullscreen => 0, 889 fullscreen => 0,
518 fast => 0, 890 fast => 0,
519 fow_enable => 1, 891 fow_enable => 1,
520 fow_intensity => 0.45, 892 fow_intensity => 0.45,
521 fow_smooth => 0, 893 fow_smooth => 0,
894 gui_fontsize => 1,
522 log_fontsize => 14, 895 log_fontsize => 14,
523 mapsize => 100, 896 mapsize => 100,
524 host => "crossfire.schmorp.de", 897 host => "crossfire.schmorp.de",
525 port => 13327,
526 say_command => 'say', 898 say_command => 'say',
899 audio_enable => 1,
900 bgm_enable => 1,
901 bgm_volume => 64,
527); 902);
528 903
529while (my ($k, $v) = each %DEF_CFG) { 904while (my ($k, $v) = each %DEF_CFG) {
530 $CFG->{$k} = $v unless exists $CFG->{$k}; 905 $CFG->{$k} = $v unless exists $CFG->{$k};
531} 906}
532 907
533sdl_init; 908sdl_init;
534 909
535@SDL_MODES = reverse 910@SDL_MODES = reverse
536 grep $_->[0] >= 640 && $_->[1] >= 480, 911 grep $_->[0] >= 640 && $_->[1] >= 480,
537 map [SDL::RectW ($_), SDL::RectH ($_)], 912 CFClient::SDL_ListModes;
538 @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL };
539 913
540@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; 914@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
541 915
542$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; 916$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
543
544init_screen;
545 917
546{ 918{
547 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); 919 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf);
548 920
549 CFClient::add_font $_ for @fonts; 921 CFClient::add_font $_ for @fonts;
550 CFClient::set_font $fonts[0]; 922 CFClient::set_font $fonts[0];
551} 923}
552 924
553$FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; 925video_init;
926audio_init;
554 927
555Event::loop; 928Event::loop;
556 929
557Crossfire::save_ref $FACECACHE, "$Crossfire::VARDIR/pclient.faces"; 930END { SDL::Quit }
558 931
932

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines