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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines