1 | #!/opt/bin/perl |
1 | #!/opt/bin/perl |
|
|
2 | |
|
|
3 | if ($ENV{DELIANTRA_CORO_DEBUG}) { |
|
|
4 | eval ' |
|
|
5 | use Coro; |
|
|
6 | use Coro::EV; |
|
|
7 | use Coro::Debug; |
|
|
8 | our $debug = new_unix_server Coro::Debug "/tmp/dc"; |
|
|
9 | '; |
|
|
10 | die if $@; |
|
|
11 | } |
2 | |
12 | |
3 | # do splash-screen thingy on win32 |
13 | # do splash-screen thingy on win32 |
4 | my $startup_done = sub { }; |
14 | my $startup_done = sub { }; |
5 | BEGIN { |
15 | BEGIN { |
6 | if (%PAR::LibCache && $^O eq "MSWin32") { |
16 | if (%PAR::LibCache && $^O eq "MSWin32") { |
… | |
… | |
12 | |
22 | |
13 | Win32::GUI::SplashScreen::Show ( |
23 | Win32::GUI::SplashScreen::Show ( |
14 | -file => "$ENV{PAR_TEMP}/SPLASH.bmp", |
24 | -file => "$ENV{PAR_TEMP}/SPLASH.bmp", |
15 | ); |
25 | ); |
16 | |
26 | |
|
|
27 | # initialise the resolver now, as vista forces us back to the desktop |
|
|
28 | # when doing this later. |
|
|
29 | require AnyEvent::DNS; |
|
|
30 | AnyEvent::DNS::resolver (); |
|
|
31 | |
17 | $startup_done = sub { |
32 | $startup_done = sub { |
18 | Win32::GUI::SplashScreen::Done (1); |
33 | Win32::GUI::SplashScreen::Done (1); |
19 | }; |
34 | }; |
20 | } |
35 | } |
21 | } |
36 | } |
22 | |
37 | |
23 | use strict; |
38 | use common::sense; |
24 | use utf8; |
|
|
25 | |
39 | |
26 | use Carp 'verbose'; |
40 | use Carp 'verbose'; |
27 | |
41 | |
28 | # do things only needed for single-binary version (par) |
42 | # do things only needed for single-binary version (par) |
29 | BEGIN { |
43 | BEGIN { |
… | |
… | |
41 | } |
55 | } |
42 | |
56 | |
43 | if ($^O eq "MSWin32") { |
57 | if ($^O eq "MSWin32") { |
44 | # pango is relocatable on win32 |
58 | # pango is relocatable on win32 |
45 | } else { |
59 | } else { |
46 | open my $fh, "<:perlio", "$root/pangoversion" |
60 | # OS X |
47 | or die "pangoversion: $!"; |
|
|
48 | my $PANGO = <$fh>; |
|
|
49 | # unix, need to patch pango rc file |
|
|
50 | open my $fh, "<:perlio", "$root/usr/lib/pango/$PANGO/module-files.d/libpango1.0-0.modules" |
|
|
51 | or die "$root/usr/lib/$PANGO/module-files.d/libpango1.0-0.modules: $!"; |
|
|
52 | local $/; |
|
|
53 | my $rc = <$fh>; |
|
|
54 | $rc =~ s/^\//$root\//gm; # replace abs paths by relative ones |
|
|
55 | |
|
|
56 | mkdir "$root/pango-modules"; |
|
|
57 | open my $fh, ">:perlio", "$root/pango-modules/pango.modules" |
|
|
58 | or die "$root/pango-modules/pango.modules: $!"; |
|
|
59 | print $fh $rc; |
|
|
60 | |
|
|
61 | $ENV{PANGO_RC_FILE} = "$root/pango.rc"; |
61 | $ENV{PANGO_RC_FILE} = "$root/pango.rc"; |
62 | open my $fh, ">:perlio", $ENV{PANGO_RC_FILE} |
62 | $ENV{DYLD_LIBRARY_PATH} = $root; |
63 | or die "$ENV{PANGO_RC_FILE}: $!"; |
63 | chdir $root; # for pango modules, maybe other things |
64 | print $fh "[Pango]\nModuleFiles = $root/pango-modules\n"; |
|
|
65 | } |
64 | } |
66 | |
65 | |
67 | unshift @INC, $root; |
66 | unshift @INC, $root; |
|
|
67 | } |
|
|
68 | } |
|
|
69 | |
|
|
70 | # prepend private library directory and prepare env |
|
|
71 | BEGIN { |
|
|
72 | for (grep !ref, @INC) { |
|
|
73 | my $path = "$_/Deliantra/Client/private"; |
|
|
74 | if (-d $path) { |
|
|
75 | unshift @INC, $path; |
|
|
76 | last; |
|
|
77 | } |
68 | } |
78 | } |
69 | } |
79 | } |
70 | |
80 | |
71 | # need to do it again because that pile of garbage called PAR nukes it before main |
81 | # need to do it again because that pile of garbage called PAR nukes it before main |
72 | unshift @INC, $ENV{PAR_TEMP} |
82 | unshift @INC, $ENV{PAR_TEMP} |
73 | if %PAR::LibCache; |
83 | if %PAR::LibCache; |
74 | |
84 | |
75 | use Time::HiRes 'time'; |
85 | use EV; |
76 | use Event; |
86 | BEGIN { *time = \&EV::time } |
|
|
87 | |
77 | use List::Util qw(max min); |
88 | use List::Util qw(max min); |
78 | |
89 | |
79 | use Crossfire; |
90 | use Deliantra; |
80 | use Crossfire::Protocol::Constants; |
91 | use Deliantra::Protocol::Constants; |
|
|
92 | |
|
|
93 | use AnyEvent::Util (); |
|
|
94 | use AnyEvent::Socket (); |
|
|
95 | use AnyEvent::DNS (); |
81 | |
96 | |
82 | use Compress::LZF; |
97 | use Compress::LZF; |
|
|
98 | use JSON::XS; |
83 | |
99 | |
84 | use CFPlus; |
100 | use DC; |
|
|
101 | |
|
|
102 | sub crash($;$) { |
|
|
103 | # nop during compiletime |
|
|
104 | } |
|
|
105 | |
|
|
106 | BEGIN { |
|
|
107 | $SIG{__DIE__} = sub { |
|
|
108 | return if $^S; |
|
|
109 | crash "CRASH/DIE: $_[0]" => 1; |
|
|
110 | DC::fatal Carp::longmess "$_[0]"; |
|
|
111 | } |
|
|
112 | } |
|
|
113 | |
85 | use CFPlus::OpenGL (); |
114 | use DC::OpenGL (); |
86 | use CFPlus::Protocol; |
115 | use DC::Protocol; |
87 | use CFPlus::DB; |
116 | use DC::DB; |
88 | use CFPlus::UI; |
117 | use DC::UI; |
89 | use CFPlus::UI::Canvas; |
118 | use DC::UI::Canvas; |
90 | use CFPlus::UI::Inventory; |
119 | use DC::UI::Inventory; |
91 | use CFPlus::UI::SpellList; |
120 | use DC::UI::SpellList; |
92 | use CFPlus::UI::Dockable; |
121 | use DC::UI::Dockable; |
93 | use CFPlus::UI::MessageWindow; |
122 | use DC::UI::Dockbar; |
94 | use CFPlus::UI::ChatView; |
123 | use DC::UI::ChatView; |
|
|
124 | use DC::MessageDistributor; |
95 | use CFPlus::Pod; |
125 | use DC::Pod; |
96 | use CFPlus::MapWidget; |
126 | use DC::MapWidget; |
97 | use CFPlus::Macro; |
127 | use DC::Macro; |
98 | |
128 | |
99 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
129 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
100 | $SIG{PIPE} = 'IGNORE'; |
130 | $SIG{PIPE} = 'IGNORE'; |
101 | |
131 | |
102 | $Event::Eval = 1; |
|
|
103 | $Event::DIED = sub { |
132 | $EV::DIED = sub { |
|
|
133 | crash "CRASH/EV::DIED: $@" => 0; |
104 | CFPlus::fatal Carp::longmess $_[1] |
134 | DC::fatal Carp::longmess $@; |
105 | }; |
135 | }; |
106 | |
136 | |
107 | my $MAX_FPS = 60; |
137 | my $MAX_FPS = 60; |
108 | my $MIN_FPS = 5; # unused as of yet |
138 | |
|
|
139 | our $DEFAULT_SERVER = "gameserver.deliantra.net"; |
109 | |
140 | |
110 | our $META_SERVER = "http://metaserver.schmorp.de/current.json"; |
141 | our $META_SERVER = "http://metaserver.schmorp.de/current.json"; |
111 | |
142 | |
112 | our $LAST_REFRESH; |
143 | our $LAST_REFRESH; |
113 | our $NOW; |
144 | our $NOW; |
114 | |
145 | |
115 | our $CFG; |
146 | our $CFG; |
116 | our $CONN; |
|
|
117 | our $PROFILE; # current profile |
147 | our $PROFILE; # current profile |
118 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
148 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
|
|
149 | our $DELIANTRA_DEBUG = $ENV{DELIANTRA_DEBUG} * 1; |
119 | |
150 | |
120 | our $WANT_REFRESH; |
151 | our $WANT_REFRESH; |
121 | |
152 | |
|
|
153 | our $MODE_SLIDER; |
|
|
154 | our $CAVEAT_LABEL; |
|
|
155 | |
122 | our @SDL_MODES; |
156 | our @SDL_MODES; |
|
|
157 | our $SDL_REINIT = 1; |
123 | our $WIDTH; |
158 | our $WIDTH; |
124 | our $HEIGHT; |
159 | our $HEIGHT; |
125 | our $FULLSCREEN; |
160 | our $FULLSCREEN; |
126 | our $FONTSIZE; |
161 | our $FONTSIZE; |
127 | |
162 | |
128 | our $FONT_PROP; |
163 | our $FONT_PROP; |
129 | our $FONT_FIXED; |
164 | our $FONT_FIXED; |
130 | |
165 | |
|
|
166 | our $CONN; |
|
|
167 | |
131 | our $MAP; |
168 | our $MAP; |
132 | our $MAPMAP; |
169 | our $MAPMAP; |
133 | our $MAPWIDGET; |
170 | our $MAPWIDGET; |
134 | our $COMPLETER; |
171 | our $COMPLETER; |
135 | our $BUTTONBAR; |
172 | our $MENUFRAME; # the rectangle at the top |
|
|
173 | our $MENUBAR; # the hbox at the top |
|
|
174 | our $MENUPOPUP; |
|
|
175 | our $BUTTONBAR; # the menu buttons |
136 | our $METASERVER; |
176 | our $METASERVER; |
137 | our $LOGIN_BUTTON; |
177 | our $LOGIN_BUTTON; |
138 | our $QUIT_DIALOG; |
178 | our $QUIT_DIALOG; |
139 | our $HOST_ENTRY; |
179 | our $HOST_ENTRY; |
140 | our $FULLSCREEN_ENABLE; |
180 | our $FULLSCREEN_ENABLE; |
… | |
… | |
160 | our $SPELL_PAGE; |
200 | our $SPELL_PAGE; |
161 | our $SPELL_LIST; |
201 | our $SPELL_LIST; |
162 | |
202 | |
163 | our $HELP_WINDOW; |
203 | our $HELP_WINDOW; |
164 | our $MESSAGE_WINDOW; |
204 | our $MESSAGE_WINDOW; |
|
|
205 | our $MESSAGE_DIST; |
165 | our $FLOORBOX; |
206 | our $FLOORBOX; |
166 | our $GAUGES; |
207 | our $GAUGES; |
167 | our $STATWIDS; |
208 | our $STATWIDS; |
168 | |
209 | |
169 | our $SDL_ACTIVE; |
210 | our $SDL_ACTIVE; |
170 | our %SDL_CB; |
211 | our @SDL_CB; |
171 | |
212 | |
172 | our $ALT_ENTER_MESSAGE; |
213 | our $ALT_ENTER_MESSAGE; |
173 | our $STATUSBOX; |
214 | our $STATUSBOX; |
|
|
215 | our $MODBOX; |
174 | our $DEBUG_STATUS; |
216 | our $DEBUG_STATUS; |
175 | |
217 | |
176 | our $INV; |
218 | our $INV; |
177 | our $INVR; |
219 | our $INVR; |
178 | our $INVR_HB; |
220 | our $INVR_HB; |
179 | |
221 | |
180 | ############################################################################# |
222 | ############################################################################# |
181 | |
223 | |
|
|
224 | # write a crash message blockingly to the socket, if possible |
|
|
225 | # this is a bit too complicated for my tastes, but it was easy. |
|
|
226 | *crash = sub($;$) { |
|
|
227 | my ($msg, $backtrace) = @_; |
|
|
228 | |
|
|
229 | warn $msg; |
|
|
230 | |
|
|
231 | return unless $CONN; |
|
|
232 | |
|
|
233 | my $fh = $CONN->{fh} |
|
|
234 | or return; |
|
|
235 | |
|
|
236 | my $buf = delete $CONN->{wbuf}; |
|
|
237 | |
|
|
238 | $buf .= pack "n/a*", "exti " . JSON::XS::encode_json [clientlog => undef, substr $msg, 0, 8000]; |
|
|
239 | |
|
|
240 | AnyEvent::Util::fh_nonblocking $fh, 0; |
|
|
241 | syswrite $fh, $buf; |
|
|
242 | AnyEvent::Util::fh_nonblocking $fh, 1; |
|
|
243 | |
|
|
244 | $msg =~ s/\s+$//; |
|
|
245 | |
|
|
246 | # backtrace as second step, in case it crashes, too |
|
|
247 | crash Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated" |
|
|
248 | if $backtrace; |
|
|
249 | }; |
|
|
250 | |
|
|
251 | sub clienterror($;$) { |
|
|
252 | my ($msg, $backtrace) = @_; |
|
|
253 | |
|
|
254 | warn $msg; |
|
|
255 | |
|
|
256 | return unless $CONN; |
|
|
257 | |
|
|
258 | $CONN->send_exti_msg (clientlog => $msg); |
|
|
259 | $CONN->send_exti_msg (clientlog => Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated") if $backtrace; |
|
|
260 | } |
|
|
261 | |
|
|
262 | ############################################################################# |
|
|
263 | |
182 | sub status { |
264 | sub status { |
183 | $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
265 | $STATUSBOX->add (DC::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
184 | } |
266 | } |
185 | |
267 | |
186 | sub debug { |
268 | sub debug { |
187 | $DEBUG_STATUS->set_text ($_[0]); |
269 | $DEBUG_STATUS->set_text ($_[0]); |
188 | } |
270 | } |
189 | |
271 | |
190 | sub message { |
272 | sub message { |
191 | $MESSAGE_WINDOW->message (@_); |
273 | $MESSAGE_DIST->message (@_); |
|
|
274 | } |
|
|
275 | |
|
|
276 | sub update_modbox { |
|
|
277 | my $mod = DC::SDL_GetModState; |
|
|
278 | |
|
|
279 | my $markup; |
|
|
280 | |
|
|
281 | $markup .= $mod & DC::KMOD_CTRL |
|
|
282 | ? ($MAPWIDGET->{ctrl} ? "[REPEAT]" : "[<span foreground='#888'>REPEAT</span>]") |
|
|
283 | : "[<span foreground='#888'> once </span>]"; |
|
|
284 | |
|
|
285 | $markup .= $mod & DC::KMOD_SHIFT |
|
|
286 | ? ($MAPWIDGET->{shft} ? "[FIRE]" : "[<span foreground='#888'>FIRE</span>]") |
|
|
287 | : "[<span foreground='#888'>move</span>]"; |
|
|
288 | |
|
|
289 | $markup .= $mod & (DC::KMOD_ALT | DC::KMOD_META) |
|
|
290 | ? "[ALT]" |
|
|
291 | : "[<span foreground='#888'>alt</span>]"; |
|
|
292 | |
|
|
293 | $markup .= $mod & DC::KMOD_NUM |
|
|
294 | ? "[NUM]" |
|
|
295 | : "[<span foreground='#888'>num</span>]"; |
|
|
296 | |
|
|
297 | # <tt> around next statement works around some bug that keeps the |
|
|
298 | # "font =>" from being used on windows |
|
|
299 | $MODBOX->set_markup ("<tt>$markup</tt>"); |
192 | } |
300 | } |
193 | |
301 | |
194 | ############################################################################# |
302 | ############################################################################# |
195 | #TODO: maybe move into own audio module... |
303 | #TODO: maybe move into own audio module... |
196 | |
304 | |
… | |
… | |
223 | |
331 | |
224 | $AUDIO_PLAY{$face} |
332 | $AUDIO_PLAY{$face} |
225 | or return; |
333 | or return; |
226 | |
334 | |
227 | if (my $chunk = $AUDIO_CHUNK{$face}) { |
335 | if (my $chunk = $AUDIO_CHUNK{$face}) { |
228 | for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) { |
336 | for (grep $_->[0] >= EV::now, @{(delete $AUDIO_PLAY{$face}) || []}) { |
229 | my (undef, $dx, $dy, $vol) = @$_; |
337 | my (undef, $dx, $dy, $vol) = @$_; |
230 | |
338 | |
231 | my $channel = CFPlus::Channel::find; |
339 | my $channel = DC::Channel::find; |
232 | $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255); |
340 | $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255); |
233 | $channel->set_position_r ($dx, $dy, 20); |
341 | $channel->set_position_r ($dx, $dy, 20); |
234 | $chunk->play ($channel); |
342 | $chunk->play ($channel); |
235 | } |
343 | } |
236 | } else { |
344 | } else { |
… | |
… | |
239 | or return; |
347 | or return; |
240 | |
348 | |
241 | $meta->{data} |
349 | $meta->{data} |
242 | or return; |
350 | or return; |
243 | |
351 | |
244 | # if its a jingle, play it as ambient music |
352 | # if it's a jingle, play it as ambient music |
245 | if ($meta->{data}{jingle}) { |
353 | if ($meta->{data}{jingle}) { |
246 | if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue |
354 | if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue |
247 | push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue |
355 | push @MUSIC_JINGLE, $meta; # push it unto the music/jingle queue |
248 | &audio_music_push ($face); |
356 | &audio_music_push ($face); |
249 | } |
357 | } |
250 | } else { |
358 | } else { |
251 | # fetch from database |
359 | # fetch from database |
252 | CFPlus::DB::get res_data => $meta->{name}, sub { |
360 | DC::DB::get res_data => $meta->{name}, sub { |
253 | my $rwops = new CFPlus::RW $_[0]; |
361 | my $rwops = new DC::RW $_[0]; |
254 | my $chunk = new CFPlus::MixChunk $rwops |
362 | my $chunk = new DC::MixChunk $rwops |
255 | or Carp::confess "sound face " . (JSON::XS::to_json $meta) . " unloadable: " . CFPlus::Mix_GetError; |
363 | or Carp::confess "sound face " . (JSON::XS::encode_json $meta) . " (" . (unpack "H64", $_[0]) . ") unloadable: " . DC::Mix_GetError; |
256 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
364 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
257 | $AUDIO_CHUNK{$face} = $chunk; |
365 | $AUDIO_CHUNK{$face} = $chunk; |
258 | |
366 | |
259 | audio_sound_push ($face); |
367 | audio_sound_push ($face); |
260 | }; |
368 | }; |
… | |
… | |
269 | or return; |
377 | or return; |
270 | $CFG->{effects_enable} |
378 | $CFG->{effects_enable} |
271 | or return; |
379 | or return; |
272 | |
380 | |
273 | my $queue = $AUDIO_PLAY{$face} ||= []; |
381 | my $queue = $AUDIO_PLAY{$face} ||= []; |
274 | push @$queue, [Event::time + 0.6, $dx, $dy, $vol]; # do not play sound for outdated events |
382 | push @$queue, [EV::now + 0.6, $dx, $dy, $vol]; # do not play sound for outdated events |
275 | audio_sound_push $face |
383 | audio_sound_push $face |
276 | unless @$queue > 1; |
384 | unless @$queue > 1; |
277 | } |
385 | } |
278 | |
386 | |
279 | sub audio_music_set_meta { |
387 | sub audio_music_set_meta { |
280 | my ($meta) = @_; |
388 | my ($meta) = @_; |
281 | |
389 | |
282 | $MUSIC_PLAYING_META = $meta; |
390 | $MUSIC_PLAYING_META = $meta; |
283 | $MUSIC_PLAYING_WIDGET->set_markup ( |
391 | $MUSIC_PLAYING_WIDGET->set_markup ( |
284 | "<b>Name</b>: " . (CFPlus::asxml $meta->{data}{name}) . "\n" |
392 | "<b>Name</b>: " . (DC::asxml $meta->{data}{name}) . "\n" |
285 | . "<b>Author</b>: " . (CFPlus::asxml $meta->{data}{author}) . "\n" |
393 | . "<b>Author</b>: " . (DC::asxml $meta->{data}{author}) . "\n" |
286 | . "<b>Source</b>: " . (CFPlus::asxml $meta->{data}{source}) . "\n" |
394 | . "<b>Source</b>: " . (DC::asxml $meta->{data}{source}) . "\n" |
287 | . "<b>License</b>: " . (CFPlus::asxml $meta->{data}{license}) |
395 | . "<b>License</b>: " . (DC::asxml $meta->{data}{license}) |
288 | ); |
396 | ); |
289 | } |
397 | } |
290 | |
398 | |
291 | sub audio_music_update_volume { |
399 | sub audio_music_update_volume { |
292 | return unless $MUSIC_PLAYING_META; |
400 | return unless $MUSIC_PLAYING_META; |
293 | my $volume = $MUSIC_PLAYING_META->{data}{volume} || 1; |
401 | my $volume = $MUSIC_PLAYING_META->{data}{volume} || 1; |
294 | my $base = $MUSIC_PLAYING_META->{data}{jingle} ? 1 : $CFG->{bgm_volume}; |
402 | my $base = $MUSIC_PLAYING_META->{data}{jingle} ? 1 : $CFG->{bgm_volume}; |
295 | CFPlus::MixMusic::volume $base * $volume * 128; |
403 | DC::MixMusic::volume $base * $volume * 128; |
296 | } |
404 | } |
297 | |
405 | |
298 | sub audio_music_start { |
406 | sub audio_music_start { |
299 | my $meta = $MUSIC_PLAYING_META; |
407 | my $meta = $MUSIC_PLAYING_META; |
300 | |
408 | |
301 | CFPlus::DB::get res_data => $meta->{name}, sub { |
409 | DC::DB::get res_data => $meta->{name}, sub { |
302 | return unless $SDL_MIXER; |
410 | return unless $SDL_MIXER; |
303 | |
411 | |
304 | # music might have changed... |
412 | # music might have changed... |
305 | $meta eq $MUSIC_PLAYING_META |
413 | $meta eq $MUSIC_PLAYING_META |
306 | or return &audio_music_start (); |
414 | or return &audio_music_start (); |
307 | |
415 | |
308 | audio_music_update_volume; |
416 | audio_music_update_volume; |
309 | |
417 | |
310 | $MUSIC_PLAYING_DATA = \$_[0]; |
418 | $MUSIC_PLAYING_DATA = \$_[0]; |
311 | |
419 | |
|
|
420 | $meta->{path} or length $_[0] |
|
|
421 | or return clienterror "empty music face from res_data ($meta->{face})";#d# |
|
|
422 | |
312 | my $rwops = $meta->{path} |
423 | my $rwops = $meta->{path} |
313 | ? new_from_file CFPlus::RW $meta->{path} |
424 | ? (new_from_file DC::RW $meta->{path} or return clienterror "unable to load music face $meta->{path}: $!")#d#clienterror |
314 | : new CFPlus::RW $$MUSIC_PLAYING_DATA; |
425 | : new DC::RW $$MUSIC_PLAYING_DATA; |
315 | |
426 | |
316 | $MUSIC_PLAYER = new CFPlus::MixMusic $rwops |
427 | $MUSIC_PLAYER = new DC::MixMusic $rwops |
317 | or Carp::confess "music face $meta->{face} unloadable: " . CFPlus::Mix_GetError; |
428 | or return clienterror "music face $meta->{face} unloadable: " . DC::Mix_GetError => 1; |
318 | |
429 | |
319 | my $NOW = time; |
430 | my $NOW = time; |
320 | |
431 | |
321 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
432 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
322 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
433 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
… | |
… | |
336 | return unless $SDL_MIXER; |
447 | return unless $SDL_MIXER; |
337 | |
448 | |
338 | my $fade_out; |
449 | my $fade_out; |
339 | |
450 | |
340 | if (@MUSIC_JINGLE) { |
451 | if (@MUSIC_JINGLE) { |
|
|
452 | $fade_out = 333; |
341 | @MUSIC_HAVE = $MUSIC_JINGLE[0]; |
453 | @MUSIC_HAVE = $MUSIC_JINGLE[0]; |
342 | $fade_out = 333; |
454 | |
343 | } else { |
455 | } else { |
344 | return unless $CFG->{bgm_enable}; |
456 | return unless $CFG->{bgm_enable}; |
345 | |
457 | |
346 | my @have = |
458 | $fade_out = 700; |
|
|
459 | |
|
|
460 | @MUSIC_HAVE = |
347 | grep $_ && $_->{data}, |
461 | grep $_ && $_->{data}, |
348 | map $CONN->{face}[$_], |
462 | map $CONN->{face}[$_], |
349 | @$MUSIC_WANT; |
463 | @$MUSIC_WANT; |
350 | |
464 | |
351 | # randomize music a bit so that the order is not always the same |
465 | # randomize music a bit so that the order is not always the same |
352 | $_->{stop_time} ||= rand for @have; |
466 | $_->{stop_time} ||= rand for @MUSIC_HAVE; |
353 | |
|
|
354 | @MUSIC_HAVE = @have |
|
|
355 | if @have; |
|
|
356 | |
467 | |
357 | # default MUSIC_HAVE == MUSIC_DEFAULT |
468 | # default MUSIC_HAVE == MUSIC_DEFAULT |
358 | @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_HAVE; |
469 | @MUSIC_HAVE = { path => DC::find_rcfile "music/$MUSIC_DEFAULT" } |
359 | $fade_out = 700; |
470 | unless @MUSIC_HAVE; |
360 | } |
471 | } |
361 | |
472 | |
362 | # if the currently playing song is acceptable, let it continue |
473 | # if the currently playing song is acceptable, let it continue |
363 | return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; |
474 | return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; |
364 | |
475 | |
365 | my $NOW = time; |
476 | my $NOW = time; |
366 | |
477 | |
367 | if ($MUSIC_PLAYING_META) { |
478 | if ($MUSIC_PLAYING_META) { |
368 | $MUSIC_PLAYING_META->{stop_time} = $NOW; |
479 | $MUSIC_PLAYING_META->{stop_time} = $NOW; |
369 | $MUSIC_PLAYING_META->{stop_pos} = $NOW - $MUSIC_START; |
480 | $MUSIC_PLAYING_META->{stop_pos} = $NOW - $MUSIC_START; |
370 | CFPlus::MixMusic::fade_out $fade_out; |
481 | DC::MixMusic::fade_out $fade_out; |
371 | } else { |
482 | } else { |
372 | # sort by stop time, oldest first |
483 | # sort by stop time, oldest first |
373 | @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE; |
484 | @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE; |
374 | |
485 | |
375 | # if the most recently-played piece played very recently, |
486 | # if the most recently-played piece played very recently, |
… | |
… | |
408 | audio_music_push; |
519 | audio_music_push; |
409 | } |
520 | } |
410 | |
521 | |
411 | sub audio_init { |
522 | sub audio_init { |
412 | if ($CFG->{audio_enable}) { |
523 | if ($CFG->{audio_enable}) { |
|
|
524 | if (length $CFG->{audio_driver}) { |
|
|
525 | local $ENV{SDL_AUDIODRIVER} = $CFG->{audio_driver}; |
|
|
526 | DC::SDL_Init DC::SDL_INIT_AUDIO |
|
|
527 | and die "SDL::Init failed!\n"; |
|
|
528 | } else { |
|
|
529 | DC::SDL_Init DC::SDL_INIT_AUDIO |
|
|
530 | and die "SDL::Init failed!\n"; |
|
|
531 | } |
|
|
532 | |
413 | $ENV{MIX_EFFECTSMAXSPEED} = 1; |
533 | $ENV{MIX_EFFECTSMAXSPEED} = 1; |
414 | $SDL_MIXER = !CFPlus::Mix_OpenAudio |
534 | $SDL_MIXER = !DC::Mix_OpenAudio |
415 | $CFG->{audio_hw_frequency}, |
535 | $CFG->{audio_hw_frequency}, |
416 | CFPlus::MIX_DEFAULT_FORMAT, |
536 | DC::MIX_DEFAULT_FORMAT, |
417 | $CFG->{audio_hw_channels}, |
537 | $CFG->{audio_hw_channels}, |
418 | $CFG->{audio_hw_chunksize}; |
538 | $CFG->{audio_hw_chunksize}; |
419 | |
539 | |
420 | if ($SDL_MIXER) { |
540 | if ($SDL_MIXER) { |
421 | CFPlus::Mix_AllocateChannels $CFG->{audio_mix_channels}; |
541 | DC::Mix_AllocateChannels $CFG->{audio_mix_channels}; |
422 | |
542 | |
423 | audio_music_finished; |
543 | audio_music_finished; |
424 | } else { |
544 | } else { |
425 | status "Unable to open sound device: there will be no sound"; |
545 | status "Unable to open sound device: there will be no sound"; |
426 | } |
546 | } |
… | |
… | |
431 | sub audio_tab_update; |
551 | sub audio_tab_update; |
432 | audio_tab_update; |
552 | audio_tab_update; |
433 | } |
553 | } |
434 | |
554 | |
435 | sub audio_shutdown { |
555 | sub audio_shutdown { |
|
|
556 | if ($SDL_MIXER) { |
|
|
557 | DC::MixMusic::halt; |
|
|
558 | DC::Mix_AllocateChannels 0; |
|
|
559 | } |
|
|
560 | |
436 | undef $MUSIC_PLAYER; |
561 | undef $MUSIC_PLAYER; |
437 | undef $MUSIC_PLAYING_META; |
562 | undef $MUSIC_PLAYING_META; |
438 | undef $MUSIC_PLAYING_DATA; |
563 | undef $MUSIC_PLAYING_DATA; |
439 | |
564 | |
440 | $MUSIC_WANT = []; |
565 | $MUSIC_WANT = []; |
441 | @MUSIC_JINGLE = (); |
566 | @MUSIC_JINGLE = (); |
442 | %AUDIO_PLAY = (); |
567 | %AUDIO_PLAY = (); |
443 | %AUDIO_CHUNK = (); |
568 | %AUDIO_CHUNK = (); |
444 | |
569 | |
445 | CFPlus::Mix_CloseAudio if $SDL_MIXER; |
570 | DC::Mix_CloseAudio if $SDL_MIXER; |
446 | undef $SDL_MIXER; |
571 | undef $SDL_MIXER; |
|
|
572 | |
|
|
573 | DC::SDL_QuitSubSystem DC::SDL_INIT_AUDIO; |
447 | } |
574 | } |
448 | |
575 | |
449 | ############################################################################# |
576 | ############################################################################# |
450 | |
577 | |
451 | sub destroy_query_dialog { |
578 | sub destroy_query_dialog { |
… | |
… | |
461 | my ($conn, $flags, $prompt) = @_; |
588 | my ($conn, $flags, $prompt) = @_; |
462 | |
589 | |
463 | # FIXME: a very ugly hack to wait for stat update #d# |
590 | # FIXME: a very ugly hack to wait for stat update #d# |
464 | if ($prompt =~ /roll new stats/ and not $conn->{stat_change_with}) { |
591 | if ($prompt =~ /roll new stats/ and not $conn->{stat_change_with}) { |
465 | unless ($QUERY_TIMER) { |
592 | unless ($QUERY_TIMER) { |
466 | $QUERY_TIMER = |
593 | $QUERY_TIMER = EV::timer 1, 0, sub { |
467 | Event->timer ( |
|
|
468 | after => 1, |
|
|
469 | cb => sub { |
|
|
470 | server_query ($conn, $flags, $prompt, 1); |
594 | server_query ($conn, $flags, $prompt, 1); |
471 | $QUERY_TIMER = undef |
595 | $QUERY_TIMER = undef |
472 | } |
|
|
473 | ); |
596 | }; |
|
|
597 | |
474 | return; |
598 | return; |
475 | } |
599 | } |
476 | } |
600 | } |
477 | |
601 | |
478 | $conn->{query_dialog} = my $dialog = new CFPlus::UI::Toplevel |
602 | $conn->{query_dialog} = my $dialog = new DC::UI::Toplevel |
479 | x => "center", |
603 | x => "center", |
480 | y => "center", |
604 | y => "center", |
481 | title => "Server Query", |
605 | title => "Server Query", |
482 | child => my $vbox = new CFPlus::UI::VBox, |
606 | child => my $vbox = new DC::UI::VBox, |
483 | ; |
607 | ; |
484 | |
608 | |
485 | my @dialog = my $label = new CFPlus::UI::Label |
609 | my @dialog = my $label = new DC::UI::Label |
486 | max_w => $::WIDTH * 0.8, |
610 | max_w => $::WIDTH * 0.8, |
487 | ellipsise => 0, |
611 | ellipsise => 0, |
488 | text => $prompt; |
612 | text => $prompt; |
489 | |
613 | |
490 | if ($flags & CS_QUERY_YESNO) { |
614 | if ($flags & CS_QUERY_YESNO) { |
491 | push @dialog, my $hbox = new CFPlus::UI::HBox; |
615 | push @dialog, my $hbox = new DC::UI::HBox; |
492 | |
616 | |
493 | $hbox->add (new CFPlus::UI::Button |
617 | $hbox->add (new DC::UI::Button |
494 | text => "No", |
618 | text => "No", |
495 | on_activate => sub { |
619 | on_activate => sub { |
496 | $conn->send ("reply n"); |
620 | $conn->send ("reply n"); |
497 | $dialog->destroy; |
621 | $dialog->destroy; |
498 | 0 |
622 | 0 |
499 | } |
623 | } |
500 | ); |
624 | ); |
501 | $hbox->add (new CFPlus::UI::Button |
625 | $hbox->add (new DC::UI::Button |
502 | text => "Yes", |
626 | text => "Yes", |
503 | on_activate => sub { |
627 | on_activate => sub { |
504 | $conn->send ("reply y"); |
628 | $conn->send ("reply y"); |
505 | destroy_query_dialog $conn; |
629 | destroy_query_dialog $conn; |
506 | 0 |
630 | 0 |
… | |
… | |
511 | |
635 | |
512 | } elsif ($flags & CS_QUERY_SINGLECHAR) { |
636 | } elsif ($flags & CS_QUERY_SINGLECHAR) { |
513 | if ($prompt =~ /Now choose a character|Press any key for the next race/i) { |
637 | if ($prompt =~ /Now choose a character|Press any key for the next race/i) { |
514 | $dialog->{tooltip} = "#charcreation_focus"; |
638 | $dialog->{tooltip} = "#charcreation_focus"; |
515 | |
639 | |
516 | unshift @dialog, new CFPlus::UI::Label |
640 | unshift @dialog, new DC::UI::Label |
517 | max_w => $::WIDTH * 0.8, |
641 | max_w => $::WIDTH * 0.8, |
518 | ellipsise => 0, |
642 | ellipsise => 0, |
519 | markup => "\nOr use your keyboard and the text entry below:\n"; |
643 | markup => "\nOr use your keyboard and the text entry below:\n"; |
520 | |
644 | |
521 | unshift @dialog, my $table = new CFPlus::UI::Table; |
645 | unshift @dialog, my $table = new DC::UI::Table; |
522 | |
646 | |
523 | $table->add_at (0, 0, new CFPlus::UI::Button |
647 | $table->add_at (0, 0, new DC::UI::Button |
524 | text => "Next Race", |
648 | text => "Next Race", |
525 | on_activate => sub { |
649 | on_activate => sub { |
526 | $conn->send ("reply n"); |
650 | $conn->send ("reply n"); |
527 | destroy_query_dialog $conn; |
651 | destroy_query_dialog $conn; |
528 | 0 |
652 | 0 |
529 | }, |
653 | }, |
530 | ); |
654 | ); |
531 | $table->add_at (2, 0, new CFPlus::UI::Button |
655 | $table->add_at (2, 0, new DC::UI::Button |
532 | text => "Accept", |
656 | text => "Accept", |
533 | on_activate => sub { |
657 | on_activate => sub { |
534 | $conn->send ("reply d"); |
658 | $conn->send ("reply d"); |
535 | destroy_query_dialog $conn; |
659 | destroy_query_dialog $conn; |
536 | 0 |
660 | 0 |
537 | }, |
661 | }, |
538 | ); |
662 | ); |
539 | |
663 | |
540 | if ($conn->{chargen_race_description}) { |
664 | if ($conn->{chargen_race_description}) { |
541 | unshift @dialog, new CFPlus::UI::Label |
665 | unshift @dialog, new DC::UI::Label |
542 | max_w => $::WIDTH * 0.8, |
666 | max_w => $::WIDTH * 0.8, |
543 | ellipsise => 0, |
667 | ellipsise => 0, |
544 | markup => "<span foreground='#ccccff'>$conn->{chargen_race_description}</span>", |
668 | markup => "<span foreground='#ccccff'>$conn->{chargen_race_description}</span>", |
545 | ; |
669 | ; |
546 | } |
670 | } |
547 | |
671 | |
548 | unshift @dialog, new CFPlus::UI::Face |
672 | unshift @dialog, new DC::UI::Face |
549 | face => $conn->{player}{face}, |
673 | face => $conn->{player}{face}, |
550 | bg => [.2, .2, .2, 1], |
674 | bg => [.2, .2, .2, 1], |
551 | min_w => 64, |
675 | min_w => 64, |
552 | min_h => 64, |
676 | min_h => 64, |
553 | ; |
677 | ; |
554 | |
678 | |
555 | if ($conn->{chargen_race_title}) { |
679 | if ($conn->{chargen_race_title}) { |
556 | unshift @dialog, new CFPlus::UI::Label |
680 | unshift @dialog, new DC::UI::Label |
557 | allign => 1, |
681 | allign => 1, |
558 | ellipsise => 0, |
682 | ellipsise => 0, |
559 | markup => "<span foreground='#ccccff' size='large'>Race: $conn->{chargen_race_title}</span>", |
683 | markup => "<span foreground='#ccccff' size='large'>Race: $conn->{chargen_race_title}</span>", |
560 | ; |
684 | ; |
561 | } |
685 | } |
562 | |
686 | |
563 | unshift @dialog, new CFPlus::UI::Label |
687 | unshift @dialog, new DC::UI::Label |
564 | max_w => $::WIDTH * 0.4, |
688 | max_w => $::WIDTH * 0.4, |
565 | ellipsise => 0, |
689 | ellipsise => 0, |
566 | markup => (CFPlus::Pod::section_label ui => "chargen_race"), |
690 | markup => (DC::Pod::section_label ui => "chargen_race"), |
567 | ; |
691 | ; |
568 | |
692 | |
569 | } elsif ($prompt =~ /roll new stats/) { |
693 | } elsif ($prompt =~ /roll new stats/) { |
570 | if (my $stat = delete $conn->{stat_change_with}) { |
694 | if (my $stat = delete $conn->{stat_change_with}) { |
571 | $conn->send ("reply $stat"); |
695 | $conn->send ("reply $stat"); |
572 | destroy_query_dialog $conn; |
696 | destroy_query_dialog $conn; |
573 | return; |
697 | return; |
574 | } |
698 | } |
575 | |
699 | |
576 | unshift @dialog, new CFPlus::UI::Label |
700 | unshift @dialog, new DC::UI::Label |
577 | max_w => $::WIDTH * 0.4, |
701 | max_w => $::WIDTH * 0.4, |
578 | ellipsise => 0, |
702 | ellipsise => 0, |
579 | markup => "\nOr use your keyboard and the text entry below:\n"; |
703 | markup => "\nOr use your keyboard and the text entry below:\n"; |
580 | |
704 | |
581 | unshift @dialog, my $table = new CFPlus::UI::Table; |
705 | unshift @dialog, my $table = new DC::UI::Table; |
582 | |
706 | |
583 | # left: re-roll |
707 | # left: re-roll |
584 | $table->add_at (0, 0, new CFPlus::UI::Button |
708 | $table->add_at (0, 0, new DC::UI::Button |
585 | text => "Roll Again", |
709 | text => "Roll Again", |
586 | on_activate => sub { |
710 | on_activate => sub { |
587 | $conn->send ("reply y"); |
711 | $conn->send ("reply y"); |
588 | destroy_query_dialog $conn; |
712 | destroy_query_dialog $conn; |
589 | 0 |
713 | 0 |
590 | }, |
714 | }, |
591 | ); |
715 | ); |
592 | |
716 | |
593 | # center: swap stats |
717 | # center: swap stats |
594 | my ($sw1, $sw2) = map +(new CFPlus::UI::Selector |
718 | my ($sw1, $sw2) = map +(new DC::UI::Selector |
595 | expand => 1, |
719 | expand => 1, |
596 | value => $_, |
720 | value => $_, |
597 | options => [ |
721 | options => [ |
598 | [1 => "Str", "Strength ($conn->{stat}{+CS_STAT_STR})"], |
722 | [1 => "Str", "Strength ($conn->{stat}{+CS_STAT_STR})"], |
599 | [2 => "Dex", "Dexterity ($conn->{stat}{+CS_STAT_DEX})"], |
723 | [2 => "Dex", "Dexterity ($conn->{stat}{+CS_STAT_DEX})"], |
… | |
… | |
603 | [6 => "Pow", "Power ($conn->{stat}{+CS_STAT_POW})"], |
727 | [6 => "Pow", "Power ($conn->{stat}{+CS_STAT_POW})"], |
604 | [7 => "Cha", "Charisma ($conn->{stat}{+CS_STAT_CHA})"], |
728 | [7 => "Cha", "Charisma ($conn->{stat}{+CS_STAT_CHA})"], |
605 | ], |
729 | ], |
606 | ), 1 .. 2; |
730 | ), 1 .. 2; |
607 | |
731 | |
608 | $table->add_at (2, 0, new CFPlus::UI::Button |
732 | $table->add_at (2, 0, new DC::UI::Button |
609 | text => "Swap Stats", |
733 | text => "Swap Stats", |
610 | on_activate => sub { |
734 | on_activate => sub { |
611 | $conn->{stat_change_with} = $sw2->{value}; |
735 | $conn->{stat_change_with} = $sw2->{value}; |
612 | $conn->send ("reply $sw1->{value}"); |
736 | $conn->send ("reply $sw1->{value}"); |
613 | destroy_query_dialog $conn; |
737 | destroy_query_dialog $conn; |
614 | 0 |
738 | 0 |
615 | }, |
739 | }, |
616 | ); |
740 | ); |
617 | $table->add_at (2, 1, new CFPlus::UI::HBox children => [$sw1, $sw2]); |
741 | $table->add_at (2, 1, new DC::UI::HBox children => [$sw1, $sw2]); |
618 | |
742 | |
619 | # right: accept |
743 | # right: accept |
620 | $table->add_at (4, 0, new CFPlus::UI::Button |
744 | $table->add_at (4, 0, new DC::UI::Button |
621 | text => "Accept", |
745 | text => "Accept", |
622 | on_activate => sub { |
746 | on_activate => sub { |
623 | $conn->send ("reply n"); |
747 | $conn->send ("reply n"); |
624 | $STATS_PAGE->hide; |
|
|
625 | destroy_query_dialog $conn; |
748 | destroy_query_dialog $conn; |
626 | 0 |
749 | 0 |
627 | }, |
750 | }, |
628 | ); |
751 | ); |
629 | |
752 | |
630 | unshift @dialog, my $hbox = new CFPlus::UI::HBox; |
753 | unshift @dialog, my $hbox = new DC::UI::HBox; |
631 | for ( |
754 | for ( |
632 | [Str => CS_STAT_STR], |
755 | [Str => CS_STAT_STR], |
633 | [Dex => CS_STAT_DEX], |
756 | [Dex => CS_STAT_DEX], |
634 | [Con => CS_STAT_CON], |
757 | [Con => CS_STAT_CON], |
635 | [Int => CS_STAT_INT], |
758 | [Int => CS_STAT_INT], |
636 | [Wis => CS_STAT_WIS], |
759 | [Wis => CS_STAT_WIS], |
637 | [Pow => CS_STAT_POW], |
760 | [Pow => CS_STAT_POW], |
638 | [Cha => CS_STAT_CHA], |
761 | [Cha => CS_STAT_CHA], |
639 | ) { |
762 | ) { |
640 | my ($name, $id) = @$_; |
763 | my ($name, $id) = @$_; |
641 | $hbox->add (new CFPlus::UI::Label |
764 | $hbox->add (new DC::UI::Label |
642 | markup => "$conn->{stat}{$id} <span foreground='yellow'>$name</span>", |
765 | markup => "$conn->{stat}{$id} <span foreground='yellow'>$name</span>", |
643 | align => 0, |
|
|
644 | expand => 1, |
766 | expand => 1, |
645 | can_events => 1, |
767 | can_events => 1, |
646 | can_hover => 1, |
768 | can_hover => 1, |
647 | tooltip => "#stat_$name", |
769 | tooltip => "#stat_$name", |
648 | ); |
770 | ); |
649 | } |
771 | } |
650 | |
772 | |
651 | unshift @dialog, new CFPlus::UI::Label |
773 | unshift @dialog, new DC::UI::Label |
652 | max_w => $::WIDTH * 0.4, |
774 | max_w => $::WIDTH * 0.4, |
653 | ellipsise => 0, |
775 | ellipsise => 0, |
654 | markup => (CFPlus::Pod::section_label ui => "chargen_stats"), |
776 | markup => (DC::Pod::section_label ui => "chargen_stats"), |
655 | ; |
777 | ; |
656 | } |
778 | } |
657 | |
779 | |
658 | push @dialog, my $entry = new CFPlus::UI::Entry |
780 | push @dialog, my $entry = new DC::UI::Entry |
659 | on_changed => sub { |
781 | on_changed => sub { |
660 | $conn->send ("reply $_[1]"); |
782 | $conn->send ("reply $_[1]"); |
661 | destroy_query_dialog $conn; |
783 | destroy_query_dialog $conn; |
662 | 0 |
784 | 0 |
663 | }, |
785 | }, |
… | |
… | |
666 | $entry->grab_focus; |
788 | $entry->grab_focus; |
667 | |
789 | |
668 | } else { |
790 | } else { |
669 | $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; |
791 | $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; |
670 | |
792 | |
671 | push @dialog, my $entry = new CFPlus::UI::Entry |
793 | push @dialog, my $entry = new DC::UI::Entry |
672 | $flags & CS_QUERY_HIDEINPUT ? (hidden => "*") : (), |
794 | $flags & CS_QUERY_HIDEINPUT ? (hidden => "*") : (), |
673 | on_activate => sub { |
795 | on_activate => sub { |
674 | $conn->send ("reply $_[1]"); |
796 | $conn->send ("reply $_[1]"); |
675 | destroy_query_dialog $conn; |
797 | destroy_query_dialog $conn; |
676 | 0 |
798 | 0 |
… | |
… | |
682 | |
804 | |
683 | $vbox->add (@dialog); |
805 | $vbox->add (@dialog); |
684 | $dialog->show; |
806 | $dialog->show; |
685 | } |
807 | } |
686 | |
808 | |
687 | sub start_game { |
809 | sub dc_connect { |
688 | status "logging in..."; |
810 | my ($host, $port) = @_; |
689 | |
811 | |
690 | $LOGIN_BUTTON->set_text ("Logout"); |
|
|
691 | $SETUP_DIALOG->hide; |
|
|
692 | |
|
|
693 | my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
812 | my $mapw = List::Util::min 48, List::Util::max 11, int 1.5 + $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
|
|
813 | my $maph = List::Util::min 48, List::Util::max 11, int 1.5 + $HEIGHT * $CFG->{mapsize} * 0.01 / 32; |
694 | |
814 | |
695 | my ($host, $port) = split /:/, $PROFILE->{host}; |
|
|
696 | |
|
|
697 | $MAP = new CFPlus::Map; |
|
|
698 | |
|
|
699 | $CONN = eval { |
815 | $CONN = |
700 | new CFPlus::Protocol |
816 | new DC::Protocol |
701 | host => $host, |
817 | host => $host, |
702 | port => $port || 13327, |
818 | port => $port, |
703 | user => $PROFILE->{user}, |
819 | user => $PROFILE->{user}, |
704 | pass => $PROFILE->{password}, |
820 | pass => $PROFILE->{password}, |
705 | mapw => $mapsize, |
821 | mapw => $mapw, |
706 | maph => $mapsize, |
822 | maph => $maph, |
707 | |
823 | |
708 | client => "cfplus $CFPlus::VERSION $] $^O", |
824 | c_version => { |
|
|
825 | client => "deliantra", |
|
|
826 | clientver => $DC::VERSION, |
|
|
827 | gl_vendor => DC::OpenGL::gl_vendor, |
|
|
828 | gl_version => DC::OpenGL::gl_version, |
|
|
829 | }, |
709 | |
830 | |
710 | map_widget => $MAPWIDGET, |
831 | map_widget => $MAPWIDGET, |
711 | statusbox => $STATUSBOX, |
832 | statusbox => $STATUSBOX, |
712 | map => $MAP, |
833 | map => $MAP, |
713 | mapmap => $MAPMAP, |
834 | mapmap => $MAPMAP, |
714 | query => \&server_query, |
835 | query => \&server_query, |
715 | |
836 | |
716 | setup_req => { |
837 | setup_req => { |
717 | smoothing => $CFG->{map_smoothing}*1, |
838 | smoothing => $CFG->{map_smoothing}*1, |
718 | }, |
839 | }, |
|
|
840 | |
|
|
841 | on_connect => sub { |
|
|
842 | if ($_[0]) { |
|
|
843 | DC::lowdelay fileno $CONN->{fh}; |
|
|
844 | |
|
|
845 | status "successfully connected to the server"; |
|
|
846 | } else { |
|
|
847 | undef $CONN; |
|
|
848 | status "unable to connect: $!"; |
|
|
849 | stop_game(); |
|
|
850 | } |
|
|
851 | }, |
719 | }; |
852 | ; |
|
|
853 | } |
720 | |
854 | |
721 | if ($CONN) { |
855 | sub start_game { |
722 | CFPlus::lowdelay fileno $CONN->{fh}; |
856 | status "logging in..."; |
|
|
857 | |
|
|
858 | my $server = $PROFILE->{host} || $DEFAULT_SERVER; |
|
|
859 | my ($host, $port) = AnyEvent::Socket::parse_hostport $server, "deliantra=13327" |
|
|
860 | or return status "$server: unable to parse server address, try an empty field."; |
723 | |
861 | |
724 | status "login successful"; |
862 | $LOGIN_BUTTON->set_text ("Logout"); |
|
|
863 | $SETUP_DIALOG->hide; |
|
|
864 | |
|
|
865 | $MAP = new DC::Map; |
|
|
866 | |
|
|
867 | # hack to make SURE we find the IP address all right |
|
|
868 | # can be removed once AnyEvent::DNS is proven stable. |
|
|
869 | if ($host eq "gameserver.deliantra.net") { |
|
|
870 | AnyEvent::DNS::a "dnstest.deliantra.net", sub { |
|
|
871 | if ($_[0] ne "80.101.114.108") { # P-e-r-l |
|
|
872 | status "dns failure, trying differently"; |
|
|
873 | $host = eval { Socket::inet_ntoa Socket::inet_aton "gameserver.deliantra.net" }; |
|
|
874 | unless (defined $host) { |
|
|
875 | status "dns failure, using hardcoded address"; |
|
|
876 | $host = "194.126.175.154"; |
|
|
877 | } |
|
|
878 | } |
|
|
879 | |
|
|
880 | dc_connect $host, $port; |
|
|
881 | }; |
725 | } else { |
882 | } else { |
726 | status "unable to connect"; |
883 | dc_connect $host, $port; |
727 | stop_game(); |
|
|
728 | } |
884 | } |
729 | } |
885 | } |
730 | |
886 | |
731 | sub stop_game { |
887 | sub stop_game { |
|
|
888 | crash "stop_game"; |
|
|
889 | |
732 | $LOGIN_BUTTON->set_text ("Login / Register"); |
890 | $LOGIN_BUTTON->set_text ("Login / Register"); |
733 | $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN); |
891 | $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN); |
734 | $SETUP_DIALOG->show; |
892 | $SETUP_DIALOG->show; |
735 | $PL_WINDOW->hide; |
893 | $PL_WINDOW->hide; |
736 | $SPELL_LIST->clear_spells; |
894 | $SPELL_LIST->clear_spells; |
737 | $CFPlus::UI::ROOT->emit (stop_game => ! ! $CONN); |
895 | $DC::UI::ROOT->emit (stop_game => ! ! $CONN); |
738 | |
896 | |
739 | &audio_music_set_ambient ([]); |
897 | &audio_music_set_ambient ([]); |
740 | |
898 | |
741 | return unless $CONN; |
899 | return unless $CONN; |
742 | |
900 | |
… | |
… | |
748 | |
906 | |
749 | undef $MAP; |
907 | undef $MAP; |
750 | } |
908 | } |
751 | |
909 | |
752 | sub graphics_setup { |
910 | sub graphics_setup { |
753 | my $vbox = new CFPlus::UI::VBox; |
911 | my $vbox = new DC::UI::VBox; |
754 | |
912 | |
|
|
913 | { |
|
|
914 | $vbox->add (my $frame = new DC::UI::FancyFrame expand => 1, label => "Video Mode"); |
|
|
915 | |
755 | $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]); |
916 | $frame->add (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]); |
756 | |
917 | |
757 | my $row = 0; |
918 | my $row = 0; |
758 | |
919 | |
759 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "OpenGL Info"); |
920 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "OpenGL Info"); |
760 | $table->add_at (1, $row++, new CFPlus::UI::Label valign => 0, fontsize => 0.8, text => CFPlus::OpenGL::gl_vendor . ", " . CFPlus::OpenGL::gl_version, |
921 | $table->add_at (1, $row++, new DC::UI::Label fontsize => 0.8, text => DC::OpenGL::gl_vendor . ", " . DC::OpenGL::gl_version, |
761 | can_events => 1, |
922 | can_events => 1, |
762 | tooltip => "<tt><span size='8192'>" . (CFPlus::OpenGL::gl_extensions) . "</span></tt>"); |
923 | tooltip => "<tt><span size='8192'>" . (DC::OpenGL::gl_extensions) . "</span></tt>"); |
763 | |
924 | |
|
|
925 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Caveats"); |
|
|
926 | $table->add_at (1, $row++, $CAVEAT_LABEL = new DC::UI::Label fontsize => 0.8, |
|
|
927 | can_events => 1, |
|
|
928 | tooltip => "This field shows any known issues with your config or driver, such as " |
|
|
929 | . "a non-accelerated display format. You can try to work around these issues " |
|
|
930 | . "by selecting a different video mode, changing the settings below or " |
|
|
931 | . "by installing the right driver for your graphics card."); |
|
|
932 | |
|
|
933 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "UI Theme"); |
|
|
934 | $table->add_at (1, $row++, $FULLSCREEN_ENABLE = new DC::UI::Selector |
|
|
935 | value => $CFG->{uitheme}, |
|
|
936 | options => [ |
|
|
937 | [wood => "Wood (the default)"], |
|
|
938 | [plain => "Plain (very)"], |
|
|
939 | [blue => "Blue (dark)"], |
|
|
940 | [metal => "Metal (light)"], |
|
|
941 | ], |
|
|
942 | tooltip => "Choose the User Interface theme that you like most :)", |
|
|
943 | on_changed => sub { my ($self, $value) = @_; $CFG->{uitheme} = $value; 0 } |
|
|
944 | ); |
|
|
945 | |
764 | my $vidmode_tooltip = |
946 | my $vidmode_tooltip = |
765 | "<b>Video Mode.</b> The video mode to use for fullscreen (and the window size for windowed operation). " |
947 | "<b>Video Mode.</b> The video mode to use for fullscreen (and the window size for windowed operation). " |
766 | . "The format is <i>width</i> x <i>height</i> \@ <i>depth-per-channel</i> + <i>alpha-channel</i>."; |
948 | . "The format is <i>width</i> x <i>height</i> \@ <i>depth-per-channel</i> + <i>alpha-channel</i>."; |
767 | |
949 | |
768 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Video Mode"); |
950 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Video Mode"); |
769 | $table->add_at (1, $row++, my $hbox = new CFPlus::UI::HBox); |
951 | $table->add_at (1, $row++, my $hbox = new DC::UI::HBox); |
770 | |
952 | |
771 | $hbox->add (my $mode_slider = new CFPlus::UI::Slider |
953 | $hbox->add ($MODE_SLIDER = new DC::UI::Slider |
772 | force_w => $WIDTH * 0.1, expand => 1, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 0, 1], |
954 | c_rescale => 1, |
|
|
955 | force_w => $WIDTH * 0.1, expand => 1, |
|
|
956 | range => [ ($CFG->{sdl_mode}) x 3 ], |
773 | tooltip => $vidmode_tooltip); |
957 | tooltip => $vidmode_tooltip); |
774 | $hbox->add (my $mode_label = new CFPlus::UI::Label |
958 | $hbox->add (my $mode_label = new DC::UI::Label |
775 | align => 0, valign => 0, height => 0.8, template => "9999x9999@9+9", |
959 | height => 0.8, template => "9999x9999@9+9", |
776 | can_events => 1, tooltip => $vidmode_tooltip); |
960 | can_events => 1, tooltip => $vidmode_tooltip); |
777 | |
961 | |
778 | $mode_slider->connect (changed => sub { |
962 | $MODE_SLIDER->connect (changed => sub { |
779 | my ($self, $value) = @_; |
963 | my ($self, $value) = @_; |
780 | |
964 | |
781 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
965 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
782 | $mode_label->set_text (sprintf '%dx%d@%d+%d', @{$SDL_MODES[$value]}); |
966 | $mode_label->set_text (sprintf '%dx%d@%d+%d', @{$SDL_MODES[$value]}); |
783 | }); |
967 | }); |
784 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
968 | $MODE_SLIDER->emit (changed => $MODE_SLIDER->{range}[0]); |
785 | |
969 | |
786 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fullscreen"); |
970 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fullscreen"); |
787 | $table->add_at (1, $row++, $FULLSCREEN_ENABLE = new CFPlus::UI::CheckBox |
971 | $table->add_at (1, $row++, $FULLSCREEN_ENABLE = new DC::UI::CheckBox |
788 | state => $CFG->{fullscreen}, |
972 | state => $CFG->{fullscreen}, |
789 | tooltip => "Bring the client into fullscreen mode.", |
973 | tooltip => "Bring the client into fullscreen mode.", |
790 | on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } |
974 | on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } |
791 | ); |
975 | ); |
792 | |
976 | |
793 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Force OpenGL 1.1"); |
977 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Force OpenGL 1.1"); |
794 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
978 | $table->add_at (1, $row++, new DC::UI::CheckBox |
795 | state => $CFG->{force_opengl11}, |
979 | state => $CFG->{force_opengl11}, |
796 | tooltip => "Limit CFPlus to use OpenGL 1.1 features only. This will normally result in " |
980 | tooltip => "Limit Deliantra to use OpenGL 1.1 features only. This will normally result in " |
797 | . "higher memory usage and slower performance. It will, however, help tremendously on " |
981 | . "higher memory usage and slower performance. It will, however, help tremendously on " |
798 | . "cards that claim to support a feature but fall back to software rendering. " |
982 | . "cards that claim to support a feature but fall back to software rendering. " |
799 | . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, " |
983 | . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, " |
800 | . "but cards and drivers from other vendors (ATI) are often just as bad. <b>If you " |
984 | . "but cards and drivers from other vendors (ATI) are often just as bad. " |
801 | . "experience extremely low framerates and your card should do better, try this option.</b>", |
985 | . "<b>If you experience extremely low framerates and your card should do better, try this option.</b>", |
802 | on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 } |
986 | on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 } |
803 | ); |
987 | ); |
804 | |
988 | |
805 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Compress Textures"); |
989 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Forbid Alpha"); |
806 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
990 | $table->add_at (1, $row++, new DC::UI::CheckBox |
|
|
991 | state => $CFG->{disable_alpha}, |
|
|
992 | tooltip => "Forbid the use of the alpha channel. This makes Deliantra look a lot worse " |
|
|
993 | . "by disabling a number of textures and transparency effects. Normally, these " |
|
|
994 | . "effects do not cost a lot of resources, but some graphics cards might fall " |
|
|
995 | . "back to extremely slow rendering if this is enabled. If disabling this option " |
|
|
996 | . "noticably improves the framerate of the client please report this! " |
|
|
997 | . "<b>If you experience extremely low framerates and your card should do better, try this option.</b>", |
|
|
998 | on_changed => sub { |
|
|
999 | my ($self, $value) = @_; |
|
|
1000 | $CFG->{disable_alpha} = $value; |
|
|
1001 | $SDL_REINIT = 1; # SDL_SetVideoMode ignores GL attr changes |
|
|
1002 | 0 |
|
|
1003 | } |
|
|
1004 | ); |
|
|
1005 | |
|
|
1006 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures"); |
|
|
1007 | $table->add_at (1, $row++, new DC::UI::CheckBox |
807 | state => $CFG->{texture_compression}, |
1008 | state => $CFG->{texture_compression}, |
808 | tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " |
1009 | tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " |
809 | . "will save a lot of memory and increase performance. The compression algorithm " |
1010 | . "will save a lot of memory and increase performance (and also fall prey to the ever-buggy Mac OS X software renderer). " |
810 | . "can differ form card to card, so your mileage may vary. This setting is ignored in " |
1011 | . "The compression algorithm can differ form card to card, so your mileage may vary. This setting is ignored in " |
811 | . "forced OpenGL 1.1 mode.", |
1012 | . "forced OpenGL 1.1 mode and when using the Apple renderer.", |
812 | on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } |
1013 | on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } |
813 | ); |
1014 | ); |
814 | |
1015 | |
815 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); |
1016 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fast & Ugly"); |
816 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
1017 | $table->add_at (1, $row++, new DC::UI::CheckBox |
817 | state => $CFG->{fast}, |
1018 | state => $CFG->{fast}, |
818 | tooltip => "Lower the visual quality considerably to speed up rendering.", |
1019 | tooltip => "Lower the visual quality considerably to speed up rendering.", |
819 | on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } |
1020 | on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } |
820 | ); |
1021 | ); |
821 | |
1022 | |
822 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); |
1023 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "GUI Fontsize"); |
823 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
1024 | $table->add_at (1, $row++, new DC::UI::Slider |
824 | range => [$CFG->{gui_fontsize}, 0.5, 2, 0, 0.1], |
1025 | range => [$CFG->{gui_fontsize}, 0.5, 2, 0, 0.1], |
825 | tooltip => "The base font size used by most GUI elements that do not have their own setting.", |
1026 | tooltip => "The base font size used by most GUI elements that do not have their own setting.", |
826 | on_changed => sub { $CFG->{gui_fontsize} = $_[1]; 0 }, |
1027 | on_changed => sub { $CFG->{gui_fontsize} = $_[1]; 0 }, |
827 | ); |
1028 | ); |
828 | |
1029 | |
829 | $table->add_at (1, $row++, new CFPlus::UI::Button |
1030 | $table->add_at (1, $row++, new DC::UI::Button |
830 | expand => 1, align => 0, text => "Apply", |
1031 | expand => 1, text => "Apply", |
831 | tooltip => "Apply the video settings above.", |
1032 | tooltip => "Apply the video settings above.", |
832 | on_activate => sub { |
1033 | on_activate => sub { |
833 | video_shutdown (); |
1034 | video_shutdown (); |
834 | video_init (); |
1035 | video_init (); |
|
|
1036 | 0 |
835 | 0 |
1037 | } |
836 | } |
1038 | ); |
|
|
1039 | } |
|
|
1040 | |
|
|
1041 | { |
|
|
1042 | $vbox->add (my $frame = new DC::UI::FancyFrame expand => 1, label => "Other Settings"); |
|
|
1043 | |
|
|
1044 | $frame->add (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]); |
|
|
1045 | |
|
|
1046 | my $row = 0; |
|
|
1047 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Smooth Movement"); |
|
|
1048 | $table->add_at (1, $row++, new DC::UI::CheckBox |
|
|
1049 | state => $CFG->{smooth_movement}, |
|
|
1050 | tooltip => "<b>Smooth Movement</b> tries to make movement, well, smoother, but also increases the framerate. " |
|
|
1051 | . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, " |
|
|
1052 | . "then disable this option. Changes take effect immdiately.", |
|
|
1053 | on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_movement} = $value; 0 } |
837 | ); |
1054 | ); |
838 | |
1055 | |
|
|
1056 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Smooth Transitions"); |
|
|
1057 | $table->add_at (1, $row++, new DC::UI::CheckBox |
|
|
1058 | state => $CFG->{smooth_transitions}, |
|
|
1059 | tooltip => "<b>Smooth Transitions</b> tries to blend the fog of war and lighting smoothly between updates. " |
|
|
1060 | . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, " |
|
|
1061 | . "then disable this option. Requires Smooth Movement and OpenGL Multitexturing. Changes take effect immdiately.", |
|
|
1062 | on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_transitions} = $value; 0 } |
|
|
1063 | ); |
|
|
1064 | |
|
|
1065 | |
839 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Scale"); |
1066 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Scale"); |
840 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
1067 | $table->add_at (1, $row++, new DC::UI::Slider |
841 | range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], |
1068 | range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], |
842 | tooltip => "Enlarge or shrink the displayed map. Changes are instant.", |
1069 | tooltip => "Enlarge or shrink the displayed map. Changes are instant.", |
843 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 } |
1070 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 } |
844 | ); |
1071 | ); |
845 | |
1072 | |
846 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Smoothing"); |
1073 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Smoothing"); |
847 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
1074 | $table->add_at (1, $row++, new DC::UI::CheckBox |
848 | state => $CFG->{map_smoothing}, |
1075 | state => $CFG->{map_smoothing}, |
849 | tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. " |
1076 | tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. " |
850 | . "This increases load on the graphics subsystem and works only with TRT servers. " |
1077 | . "This increases load on the graphics subsystem and works only with TRT servers. " |
851 | . "Changes take effect at next login only.", |
1078 | . "Changes take effect at next login only.", |
852 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } |
1079 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } |
853 | ); |
1080 | ); |
854 | |
1081 | |
855 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War"); |
1082 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fog of War"); |
856 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
1083 | $table->add_at (1, $row++, new DC::UI::CheckBox |
857 | state => $CFG->{fow_enable}, |
1084 | state => $CFG->{fow_enable}, |
858 | tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.", |
1085 | tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.", |
859 | on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 } |
1086 | on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 } |
860 | ); |
1087 | ); |
861 | |
1088 | |
|
|
1089 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Pattern"); |
|
|
1090 | $table->add_at (1, $row++, new DC::UI::ImageButton |
|
|
1091 | tex => $DC::MapWidget::TEX_HIDDEN[$CFG->{fow_texture}], |
|
|
1092 | bg => [0.3, 0.3, 0.2], |
|
|
1093 | force_w => 64, |
|
|
1094 | force_h => 64, |
|
|
1095 | tooltip => "<b>Fog of War Pattern.</b> The pattern that is overlaid over areas hidden from view. Click to cycle through various alternatives. Changes are instant.", |
|
|
1096 | on_activate => sub { |
|
|
1097 | my ($self) = @_; |
|
|
1098 | $CFG->{fow_texture} = ($CFG->{fow_texture} + 1) % @DC::MapWidget::TEX_HIDDEN; |
|
|
1099 | $self->set_texture ($DC::MapWidget::TEX_HIDDEN[$CFG->{fow_texture}]); |
|
|
1100 | $MAPWIDGET->update; |
|
|
1101 | } |
|
|
1102 | ); |
|
|
1103 | |
862 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "FoW Intensity"); |
1104 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Intensity"); |
863 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
1105 | $table->add_at (1, $row++, new DC::UI::Slider |
864 | range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256], |
1106 | range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256], |
865 | tooltip => "<b>Fog of War Lightness.</b> The higher the intensity, the lighter the Fog-of-War color. Changes are instant.", |
1107 | tooltip => "<b>Fog of War Lightness.</b> The higher the intensity, the lighter the Fog-of-War color. Changes are instant.", |
866 | on_changed => sub { my ($self, $value) = @_; $CFG->{fow_intensity} = $value; 0 } |
1108 | on_changed => sub { my ($self, $value) = @_; $CFG->{fow_intensity} = $value; 0 } |
867 | ); |
1109 | ); |
868 | |
1110 | |
869 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); |
1111 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Fontsize"); |
870 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
1112 | $table->add_at (1, $row++, new DC::UI::Slider |
871 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
1113 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
872 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant, " |
1114 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant, " |
873 | . "but you still need to press apply to correctly re-layout the widget.", |
1115 | . "but you still need to press apply to correctly re-layout the widget.", |
874 | on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
1116 | on_changed => sub { $MESSAGE_DIST->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
875 | ); |
1117 | ); |
876 | |
1118 | |
877 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
1119 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Gauge fontsize"); |
878 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
1120 | $table->add_at (1, $row++, new DC::UI::Slider |
879 | range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], |
1121 | range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], |
880 | tooltip => "Adjusts the fontsize of the gauges at the bottom right. Changes are instant.", |
1122 | tooltip => "Adjusts the fontsize of the gauges at the bottom right. Changes are instant.", |
881 | on_changed => sub { |
1123 | on_changed => sub { |
882 | $CFG->{gauge_fontsize} = $_[1]; |
1124 | $CFG->{gauge_fontsize} = $_[1]; |
883 | &set_gauge_window_fontsize; |
1125 | &set_gauge_window_fontsize; |
|
|
1126 | 0 |
884 | 0 |
1127 | } |
885 | } |
1128 | ); |
886 | ); |
|
|
887 | |
1129 | |
888 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge size"); |
1130 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Gauge size"); |
889 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
1131 | $table->add_at (1, $row++, new DC::UI::Slider |
890 | range => [$CFG->{gauge_size}, 0.2, 0.8], |
1132 | range => [$CFG->{gauge_size}, 0.2, 0.8], |
891 | tooltip => "Adjust the size of the stats gauges at the bottom right. Changes are instant.", |
1133 | tooltip => "Adjust the size of the stats gauges at the bottom right. Changes are instant.", |
892 | on_changed => sub { |
1134 | on_changed => sub { |
893 | $CFG->{gauge_size} = $_[1]; |
1135 | $CFG->{gauge_size} = $_[1]; |
894 | $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size}); |
1136 | $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size}); |
|
|
1137 | 0 |
895 | 0 |
1138 | } |
896 | } |
1139 | ); |
897 | ); |
1140 | } |
898 | |
1141 | |
899 | $vbox |
1142 | $vbox |
900 | } |
1143 | } |
901 | |
1144 | |
902 | our $AUDIO_HW_CHUNKSIZE; |
1145 | our $AUDIO_HW_CHUNKSIZE; |
903 | our $AUDIO_INFO; |
1146 | our $AUDIO_INFO; |
904 | |
1147 | |
905 | sub audio_tab_update { |
1148 | sub audio_tab_update { |
906 | my ($freq, $format, $chans) = CFPlus::Mix_QuerySpec; |
1149 | my ($freq, $format, $chans) = DC::Mix_QuerySpec; |
907 | |
1150 | |
908 | $AUDIO_HW_CHUNKSIZE->set_options ([ |
1151 | $AUDIO_HW_CHUNKSIZE->set_options ([ |
909 | [0, "default", "Use System Default"], |
1152 | [0, "default", "Use System Default"], |
910 | map { |
1153 | map { |
911 | my $ms = sprintf "%dms", 1000 * $_ / ($CFG->{audio_hw_frequency} || 22050); |
1154 | my $ms = sprintf "%dms", 1000 * $_ / ($CFG->{audio_hw_frequency} || 22050); |
… | |
… | |
914 | ]); |
1157 | ]); |
915 | |
1158 | |
916 | my $text = !$freq |
1159 | my $text = !$freq |
917 | ? "audio is off" |
1160 | ? "audio is off" |
918 | : "audio is enabled\n" |
1161 | : "audio is enabled\n" |
|
|
1162 | . "driver: " . DC::SDL_AudioDriverName . "\n" |
919 | . "frequency (Hz): $freq\n" |
1163 | . "frequency (Hz): $freq\n" |
920 | . "channels: $chans"; |
1164 | . "channels: $chans\n" |
|
|
1165 | . "chunk decoders available: " . (join ", ", DC::MixChunk::decoders) . "\n" |
|
|
1166 | . "music decoders available: " . (join ", ", DC::MixMusic::decoders); |
921 | |
1167 | |
922 | $AUDIO_INFO->set_text ($text); |
1168 | $AUDIO_INFO->set_text ($text); |
923 | } |
1169 | } |
924 | |
1170 | |
925 | sub audio_setup { |
1171 | sub audio_setup { |
926 | my $vbox = new CFPlus::UI::VBox; |
1172 | my $vbox = new DC::UI::VBox; |
927 | |
1173 | |
928 | $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1]); |
1174 | $vbox->add (my $table = new DC::UI::Table expand => 1, col_expand => [0, 0, 1]); |
929 | |
1175 | |
930 | my $row = 0; |
1176 | my $row = 0; |
931 | |
1177 | |
932 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Audio Enable"); |
1178 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Audio Enable"); |
933 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
1179 | $table->add_at (1, $row, new DC::UI::CheckBox |
934 | state => $CFG->{audio_enable}, |
1180 | state => $CFG->{audio_enable}, |
935 | tooltip => "<b>Master Audio Enable.</b> If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.", |
1181 | tooltip => "<b>Master Audio Enable.</b> If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.", |
936 | on_changed => sub { $CFG->{audio_enable} = $_[1]; 1 } |
1182 | on_changed => sub { $CFG->{audio_enable} = $_[1]; 1 } |
937 | ); |
1183 | ); |
|
|
1184 | $table->add_at (2, $row++, my $driver = new DC::UI::HBox expand => 1); |
|
|
1185 | |
|
|
1186 | $driver->add (new DC::UI::Label align => 1, text => " Audio driver override"); |
|
|
1187 | $driver->add (new DC::UI::Entry |
|
|
1188 | text => $CFG->{audio_driver}, |
|
|
1189 | template => "dsound1234", |
|
|
1190 | tooltip => "You can override the audio driver to use here. Leaving it empty will result " |
|
|
1191 | . "in Deliantra picking one automatically. GNU/Linux users often prefer specific " |
|
|
1192 | . "drivers though, and can experiment with <b>alsa</b>, <b>dsp</b>, <b>esd</b>, <b>pulse</b>, <b>arts</b>, <b>nas</b> " |
|
|
1193 | . "or other system-specific drivers. Selecting the wrong driver here will simply result" |
|
|
1194 | . "in no sound.", |
|
|
1195 | on_changed => sub { my ($self, $value) = @_; $CFG->{audio_driver} = $value; 1 } |
|
|
1196 | ); |
938 | |
1197 | |
939 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Sound Effects"); |
1198 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Sound Effects"); |
940 | $table->add_at (1, $row, new CFPlus::UI::CheckBox |
1199 | $table->add_at (1, $row, new DC::UI::CheckBox |
941 | expand => 1, state => $CFG->{effects_enable}, |
1200 | expand => 1, state => $CFG->{effects_enable}, |
942 | tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.", |
1201 | tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.", |
943 | on_changed => sub { |
1202 | on_changed => sub { |
944 | $CFG->{effects_enable} = $_[1]; |
1203 | $CFG->{effects_enable} = $_[1]; |
945 | $CONN->update_fx_want if $CONN; |
1204 | $CONN->update_fx_want if $CONN; |
946 | 1 |
1205 | 1 |
947 | } |
1206 | } |
948 | ); |
1207 | ); |
949 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
1208 | $table->add_at (2, $row++, new DC::UI::Slider |
950 | expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128], |
1209 | expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128], |
951 | tooltip => "The relative volume of sound effects. Best audio quality is achieved if this " |
1210 | tooltip => "The relative volume of sound effects. Best audio quality is achieved if this " |
952 | . "is set highest (rightmost) and you use your operating system volume setting. Changes are instant.", |
1211 | . "is set highest (rightmost) and you use your operating system volume setting. Changes are instant.", |
953 | on_changed => sub { $CFG->{effects_volume} = $_[1]; 1 } |
1212 | on_changed => sub { $CFG->{effects_volume} = $_[1]; 1 } |
954 | ); |
1213 | ); |
955 | |
1214 | |
956 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Background Music"); |
1215 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Background Music"); |
957 | $table->add_at (1, $row, new CFPlus::UI::CheckBox |
1216 | $table->add_at (1, $row, new DC::UI::CheckBox |
958 | expand => 1, state => $CFG->{bgm_enable}, |
1217 | expand => 1, state => $CFG->{bgm_enable}, |
959 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
1218 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played. Needs server reconnect to take effect.", |
960 | on_changed => sub { |
1219 | on_changed => sub { |
961 | $CFG->{bgm_enable} = $_[1]; |
1220 | $CFG->{bgm_enable} = $_[1]; |
962 | $CONN->update_fx_want if $CONN; |
1221 | $CONN->update_fx_want if $CONN; |
963 | audio_music_push; |
1222 | audio_music_push; |
964 | 1 |
1223 | 1 |
965 | } |
1224 | } |
966 | ); |
1225 | ); |
967 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
1226 | $table->add_at (2, $row++, new DC::UI::Slider |
968 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
1227 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
969 | tooltip => "The volume of the background music. Changes are instant.", |
1228 | tooltip => "The volume of the background music. Changes are instant.", |
970 | on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 } |
1229 | on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 } |
971 | ); |
1230 | ); |
972 | |
1231 | |
973 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Frequency"); |
1232 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Frequency"); |
974 | $table->add_at (1, $row++, new CFPlus::UI::Selector |
1233 | $table->add_at (1, $row++, new DC::UI::Selector |
975 | c_colspan => 2, expand => 1, |
1234 | c_colspan => 2, expand => 1, |
976 | value => $CFG->{audio_hw_frequency}, |
1235 | value => $CFG->{audio_hw_frequency}, |
977 | options => [ |
1236 | options => [ |
978 | [ 0, "default" , "Use System Default"], |
1237 | [ 0, "default" , "Use System Default"], |
979 | [11025, "11 kHz" , "11kHz (low quality)"], |
1238 | [11025, "11 kHz" , "11kHz (low quality)"], |
980 | [22050, "22 kHz" , "22kHz (reduced quality)"], |
1239 | [22050, "22 kHz" , "22kHz (reduced quality, recommended)"], |
981 | [44100, "44.1 kHz", "44.1kHz (cd quality)"], |
1240 | [44100, "44.1 kHz", "44.1kHz (cd quality)"], |
982 | [48000, "48 kHz" , "48kHz (studio quality)"], |
1241 | [48000, "48 kHz" , "48kHz (studio quality, not recommended)"], |
983 | ], |
1242 | ], |
984 | tooltip => "The sampling frequency to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.", |
1243 | tooltip => "The sampling frequency to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.", |
985 | on_changed => sub { |
1244 | on_changed => sub { |
986 | $CFG->{audio_hw_frequency} = $_[1]; |
1245 | $CFG->{audio_hw_frequency} = $_[1]; |
987 | audio_tab_update; |
1246 | audio_tab_update; |
988 | 1 |
1247 | 1 |
989 | } |
1248 | } |
990 | ); |
1249 | ); |
991 | |
1250 | |
992 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Channels"); |
1251 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Channels"); |
993 | $table->add_at (1, $row++, new CFPlus::UI::Selector |
1252 | $table->add_at (1, $row++, new DC::UI::Selector |
994 | c_colspan => 2, expand => 1, |
1253 | c_colspan => 2, expand => 1, |
995 | value => $CFG->{audio_hw_channels}, |
1254 | value => $CFG->{audio_hw_channels}, |
996 | options => [ |
1255 | options => [ |
997 | [0, "default" , "Use System Default"], |
1256 | [0, "default" , "Use System Default"], |
998 | [1, "Mono" , "Mono (single channel, low quality)"], |
1257 | [1, "Mono" , "Mono (single channel, low quality)"], |
999 | [2, "Stereo" , "Stereo (dual channe, standard quality)"], |
1258 | [2, "Stereo" , "Stereo (dual channel, standard quality)"], |
1000 | [4, "4 Ch Surround", "4 Channel Surround Sound (3d sound, high quality)"], |
1259 | [4, "4 Ch Surround", "4 Channel Surround Sound (3d sound, high quality)"], |
1001 | [6, "6 Ch Surround", "6 Channel Surround Sound (3d sound + center + lfe)"], |
1260 | [6, "6 Ch Surround", "6 Channel Surround Sound (3d sound + center + lfe)"], |
1002 | ], |
1261 | ], |
1003 | tooltip => "The number of independent sound channels to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.", |
1262 | tooltip => "The number of independent sound channels to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.", |
1004 | on_changed => sub { |
1263 | on_changed => sub { |
… | |
… | |
1006 | audio_tab_update; |
1265 | audio_tab_update; |
1007 | 1 |
1266 | 1 |
1008 | } |
1267 | } |
1009 | ); |
1268 | ); |
1010 | |
1269 | |
1011 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Latency"); |
1270 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Latency"); |
1012 | $table->add_at (1, $row++, $AUDIO_HW_CHUNKSIZE = new CFPlus::UI::Selector |
1271 | $table->add_at (1, $row++, $AUDIO_HW_CHUNKSIZE = new DC::UI::Selector |
1013 | c_colspan => 2, expand => 1, |
1272 | c_colspan => 2, expand => 1, |
1014 | value => $CFG->{audio_hw_chunksize}, |
1273 | value => $CFG->{audio_hw_chunksize}, |
1015 | tooltip => "The guarenteed latency. Lower is better, but also more cpu-intensive and might cause stuttering. If music playback " |
1274 | tooltip => "The guarenteed latency. Lower is better, but also more cpu-intensive and might cause stuttering. If music playback " |
1016 | . "is stuttering, increase this value. Values of 50-100ms are optimal.", |
1275 | . "is stuttering, increase this value. Values of 50-150ms are optimal.", |
1017 | on_changed => sub { |
1276 | on_changed => sub { |
1018 | $CFG->{audio_hw_chunksize} = $_[1]; |
1277 | $CFG->{audio_hw_chunksize} = $_[1]; |
1019 | audio_tab_update; |
1278 | audio_tab_update; |
1020 | 1 |
1279 | 1 |
1021 | } |
1280 | } |
1022 | ); |
1281 | ); |
1023 | |
1282 | |
1024 | # should really be a slider |
1283 | # should really be a slider |
1025 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Mixer Voices"); |
1284 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Mixer Voices"); |
1026 | $table->add_at (1, $row++, new CFPlus::UI::ValSlider |
1285 | $table->add_at (1, $row++, new DC::UI::ValSlider |
1027 | c_colspan => 2, expand => 1, |
1286 | c_colspan => 2, expand => 1, |
1028 | tooltip => "The number of simultaneous sound effects possible. Higher is better, but also more cpu-intensive and might cause stuttering.", |
1287 | tooltip => "The number of simultaneous sound effects possible. Higher is better, but also more cpu-intensive and might cause stuttering.", |
1029 | range => [$::CFG->{audio_mix_channels}, 4, 32, 0, 1], |
1288 | range => [$::CFG->{audio_mix_channels}, 4, 32, 0, 1], |
1030 | template => ">= 99", |
1289 | template => ">= 99", |
1031 | on_changed => sub { |
1290 | on_changed => sub { |
… | |
… | |
1035 | if $value; |
1294 | if $value; |
1036 | 1; |
1295 | 1; |
1037 | } |
1296 | } |
1038 | ); |
1297 | ); |
1039 | |
1298 | |
1040 | $table->add_at (1, $row++, new CFPlus::UI::Button |
1299 | $table->add_at (1, $row++, new DC::UI::Button |
1041 | c_colspan => 2, expand => 1, align => 0, text => "Apply", |
1300 | c_colspan => 2, expand => 1, text => "Apply", |
1042 | tooltip => "Apply the audio settings", |
1301 | tooltip => "Apply the audio settings", |
1043 | on_activate => sub { |
1302 | on_activate => sub { |
1044 | audio_shutdown (); |
1303 | audio_shutdown (); |
1045 | audio_init (); |
1304 | audio_init (); |
1046 | 0 |
1305 | 0 |
1047 | } |
1306 | } |
1048 | ); |
1307 | ); |
1049 | |
1308 | |
1050 | $vbox->add (new CFPlus::UI::FancyFrame |
1309 | $vbox->add (new DC::UI::FancyFrame |
1051 | expand => 1, |
1310 | expand => 1, |
1052 | label => "Audio Info", |
1311 | label => "Audio Info", |
1053 | child => ($AUDIO_INFO = new CFPlus::UI::Label ellipsise => 0), |
1312 | child => ($AUDIO_INFO = new DC::UI::Label ellipsise => 0), |
1054 | ); |
1313 | ); |
1055 | |
1314 | |
1056 | audio_tab_update; |
1315 | audio_tab_update; |
1057 | |
1316 | |
1058 | $vbox |
1317 | $vbox |
… | |
… | |
1065 | } |
1324 | } |
1066 | |
1325 | |
1067 | sub make_gauge_window { |
1326 | sub make_gauge_window { |
1068 | my $gh = int $HEIGHT * $CFG->{gauge_size}; |
1327 | my $gh = int $HEIGHT * $CFG->{gauge_size}; |
1069 | |
1328 | |
1070 | my $win = new CFPlus::UI::Frame ( |
1329 | $GAUGES->{win} = my $win = new DC::UI::Frame ( |
1071 | force_x => 0, |
1330 | force_x => 0, |
1072 | force_y => "max", |
1331 | force_y => "max", |
1073 | force_w => $WIDTH, |
1332 | force_w => $WIDTH, |
1074 | force_h => $gh, |
1333 | force_h => $gh, |
1075 | ); |
1334 | ); |
1076 | |
1335 | |
1077 | $win->add (my $hbox = new CFPlus::UI::HBox |
1336 | $win->add (my $hbox = new DC::UI::HBox |
1078 | children => [ |
1337 | children => [ |
1079 | (new CFPlus::UI::HBox expand => 1), |
1338 | (new DC::UI::HBox expand => 1), |
1080 | (new CFPlus::UI::VBox children => [ |
1339 | (new DC::UI::VBox children => [ |
1081 | (new CFPlus::UI::Empty expand => 1), |
1340 | (new DC::UI::Empty expand => 1), |
1082 | (new CFPlus::UI::Frame bg => [0, 0, 0, 0.4], child => ($FLOORBOX = new CFPlus::UI::Table)), |
1341 | (new DC::UI::Frame bg => [0, 0, 0, 0.4], child => ($FLOORBOX = new DC::UI::Table)), |
1083 | ]), |
1342 | ]), |
1084 | (my $vbox = new CFPlus::UI::VBox), |
1343 | (my $vbox = new DC::UI::VBox), |
1085 | ], |
1344 | ], |
1086 | ); |
1345 | ); |
1087 | |
1346 | |
1088 | $vbox->add (new CFPlus::UI::HBox |
1347 | $vbox->add (new DC::UI::HBox |
1089 | expand => 1, |
1348 | expand => 1, |
1090 | children => [ |
1349 | children => [ |
1091 | (new CFPlus::UI::Empty expand => 1), |
1350 | (new DC::UI::Empty expand => 1), |
1092 | (my $hb = new CFPlus::UI::HBox), |
1351 | (my $hb = new DC::UI::HBox), |
1093 | ], |
1352 | ], |
1094 | ); |
1353 | ); |
1095 | |
1354 | |
1096 | $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health"); |
1355 | $hb->add ($GAUGES->{hp} = new DC::UI::Gauge type => 'hp', tooltip => "#stat_health"); |
1097 | $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana"); |
1356 | $hb->add ($GAUGES->{mana} = new DC::UI::Gauge type => 'mana', tooltip => "#stat_mana"); |
1098 | $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace"); |
1357 | $hb->add ($GAUGES->{grace} = new DC::UI::Gauge type => 'grace', tooltip => "#stat_grace"); |
1099 | $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food"); |
1358 | $hb->add ($GAUGES->{food} = new DC::UI::Gauge type => 'food', tooltip => "#stat_food"); |
1100 | |
|
|
1101 | $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); |
|
|
1102 | $vbox->add (my $prg = new CFPlus::UI::ExperienceProgress); |
|
|
1103 | $vbox->add (my $sklprg = new CFPlus::UI::ExperienceProgress); |
|
|
1104 | $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); |
|
|
1105 | |
|
|
1106 | $GAUGES = { |
|
|
1107 | exp => $exp, prg => $prg, sklprg => $sklprg, |
|
|
1108 | win => $win, range => $rng, |
|
|
1109 | hp => $hg, mana => $mg, grace => $gg, food => $fg, |
|
|
1110 | }; |
|
|
1111 | |
1359 | |
1112 | &set_gauge_window_fontsize; |
1360 | &set_gauge_window_fontsize; |
1113 | |
1361 | |
1114 | $win |
1362 | $win |
1115 | } |
1363 | } |
1116 | |
1364 | |
|
|
1365 | our $BW_WATCHER; |
|
|
1366 | |
|
|
1367 | sub debug_toggle($) { |
|
|
1368 | $DELIANTRA_DEBUG ^= $_[0]; |
|
|
1369 | |
|
|
1370 | if ($DELIANTRA_DEBUG & 16) { |
|
|
1371 | $BW_WATCHER = EV::periodic 0, 1, 0, sub { |
|
|
1372 | return unless $CONN; |
|
|
1373 | debug sprintf "%8.2gKB/s", $CONN->{octets_in} / 1e3; |
|
|
1374 | $CONN->{octets_in} = 0; |
|
|
1375 | }; |
|
|
1376 | } else { |
|
|
1377 | undef $BW_WATCHER; |
|
|
1378 | } |
|
|
1379 | |
|
|
1380 | } |
|
|
1381 | |
1117 | sub debug_setup { |
1382 | sub debug_setup { |
1118 | my $table = new CFPlus::UI::Table; |
1383 | my $table = new DC::UI::Table; |
1119 | |
1384 | |
1120 | $table->add_at (0, 0, new CFPlus::UI::Label text => "Widget Borders"); |
1385 | $table->add_at (0, 0, new DC::UI::Label text => "Widget Borders"); |
1121 | $table->add_at (1, 0, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 1; 0 }); |
1386 | $table->add_at (1, 0, new DC::UI::CheckBox on_changed => sub { debug_toggle 1; 0 }); |
1122 | $table->add_at (0, 1, new CFPlus::UI::Label text => "Tooltip Widget Info"); |
1387 | $table->add_at (0, 1, new DC::UI::Label text => "Tooltip Widget Info"); |
1123 | $table->add_at (1, 1, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 }); |
1388 | $table->add_at (1, 1, new DC::UI::CheckBox on_changed => sub { debug_toggle 2; 0 }); |
1124 | $table->add_at (0, 2, new CFPlus::UI::Label text => "Show FPS"); |
1389 | $table->add_at (0, 2, new DC::UI::Label text => "Show FPS"); |
1125 | $table->add_at (1, 2, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 }); |
1390 | $table->add_at (1, 2, new DC::UI::CheckBox on_changed => sub { debug_toggle 4; 0 }); |
1126 | $table->add_at (0, 3, new CFPlus::UI::Label text => "Suppress Tooltips"); |
1391 | $table->add_at (0, 3, new DC::UI::Label text => "Suppress Tooltips"); |
1127 | $table->add_at (1, 3, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 }); |
1392 | $table->add_at (1, 3, new DC::UI::CheckBox on_changed => sub { debug_toggle 8; 0 }); |
|
|
1393 | $table->add_at (0, 4, new DC::UI::Label text => "Show Bandwidth"); |
|
|
1394 | $table->add_at (1, 4, new DC::UI::CheckBox on_changed => sub { debug_toggle 16; 0 }); |
|
|
1395 | |
1128 | $table->add_at (0, 4, new CFPlus::UI::Button text => "die on click(tm)", on_activate => sub { &CFPlus::debug() } ); |
1396 | $table->add_at (0, 6, new DC::UI::Button text => "die on click(tm)", on_activate => sub { &DC::debug() } ); |
1129 | |
|
|
1130 | $table->add_at (0, 5, new CFPlus::UI::TextEdit text => "line1\0152\0153");#d# |
1397 | $table->add_at (0, 7, new DC::UI::TextEdit text => "line1\0152\0153\nµikachu\nづx゙つ゛");#d# |
1131 | |
1398 | |
1132 | $table->add_at (7,7, my $t = new CFPlus::UI::Table expand => 0); |
1399 | $table->add_at (7,7, my $t = new DC::UI::Table expand => 0); |
1133 | $t->add_at (0,0, new CFPlus::UI::Label text => "a a a a", c_rowspan => 1, c_colspan => 2); |
1400 | $t->add_at (0,0, new DC::UI::Label text => "a a", c_rowspan => 1, c_colspan => 2); |
1134 | $t->add_at (2,0, new CFPlus::UI::Label text => "b\nb", c_rowspan => 2, c_colspan => 1); |
1401 | $t->add_at (2,0, new DC::UI::Label text => "b\nb", c_rowspan => 2, c_colspan => 1, ellipsise => 0 ); |
1135 | $t->add_at (1,2, new CFPlus::UI::Label text => "c c c c", c_rowspan => 1, c_colspan => 2); |
1402 | $t->add_at (1,2, new DC::UI::Label text => "c c", c_rowspan => 1, c_colspan => 2); |
1136 | $t->add_at (0,1, new CFPlus::UI::Label text => "d\nd", c_rowspan => 2, c_colspan => 1); |
1403 | $t->add_at (0,1, new DC::UI::Label text => "d\nd", c_rowspan => 2, c_colspan => 1, ellipsise => 0 ); |
1137 | $t->add_at (1,1, new CFPlus::UI::Label text => "e"); |
1404 | $t->add_at (1,1, new DC::UI::Label text => "e"); |
1138 | |
1405 | |
1139 | $table->add_at (7, 6, my $c = new CFPlus::UI::Canvas); |
1406 | $table->add_at (7, 6, my $c = new DC::UI::Canvas); |
1140 | |
1407 | |
1141 | $c->add_items ({ |
1408 | $c->add_items ({ |
1142 | type => "line_loop", |
1409 | type => "line_loop", |
1143 | color => [0, 1, 0], |
1410 | color => [0, 1, 0], |
1144 | width => 9, |
1411 | width => 9, |
… | |
… | |
1164 | |
1431 | |
1165 | $table |
1432 | $table |
1166 | } |
1433 | } |
1167 | |
1434 | |
1168 | sub stats_window { |
1435 | sub stats_window { |
1169 | my $r = new CFPlus::UI::ScrolledWindow ( |
1436 | my $r = new DC::UI::ScrolledWindow ( |
1170 | expand => 1, |
1437 | expand => 1, |
1171 | scroll_y => 1 |
1438 | scroll_y => 1 |
1172 | ); |
1439 | ); |
1173 | $r->add (my $vb = new CFPlus::UI::VBox); |
1440 | $r->add (my $vb = new DC::UI::VBox); |
1174 | |
1441 | |
1175 | $vb->add (new CFPlus::UI::FancyFrame |
1442 | $vb->add (new DC::UI::FancyFrame |
1176 | label => "Player", |
1443 | label => "Player", |
1177 | child => (my $pi = new CFPlus::UI::VBox), |
1444 | child => (my $pi = new DC::UI::VBox), |
1178 | ); |
1445 | ); |
1179 | |
1446 | |
1180 | $pi->add ($STATWIDS->{title} = new CFPlus::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, |
1447 | $pi->add ($STATWIDS->{title} = new DC::UI::Label text => "Title:", expand => 1, align => 0, |
1181 | can_hover => 1, can_events => 1, |
1448 | can_hover => 1, can_events => 1, |
1182 | tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); |
1449 | tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); |
1183 | $pi->add ($STATWIDS->{map} = new CFPlus::UI::Label valign => 0, align => -1, text => "Map:", expand => 1, |
1450 | $pi->add ($STATWIDS->{map} = new DC::UI::Label align => 0, text => "Map:", expand => 1, |
1184 | can_hover => 1, can_events => 1, |
1451 | can_hover => 1, can_events => 1, |
1185 | tooltip => "The map you are currently on (if supported by the server)."); |
1452 | tooltip => "The map you are currently on (if supported by the server)."); |
1186 | |
1453 | |
1187 | $pi->add (my $hb0 = new CFPlus::UI::HBox); |
1454 | $pi->add (my $hb0 = new DC::UI::HBox); |
1188 | $hb0->add ($STATWIDS->{weight} = new CFPlus::UI::Label valign => 0, align => -1, text => "Weight:", expand => 1, |
1455 | $hb0->add ($STATWIDS->{weight} = new DC::UI::Label text => "Weight:", expand => 1, align => 0, |
1189 | can_hover => 1, can_events => 1, |
1456 | can_hover => 1, can_events => 1, |
1190 | tooltip => "The weight of the player including all inventory items."); |
1457 | tooltip => "The weight of the player including all inventory items."); |
1191 | $hb0->add ($STATWIDS->{m_weight} = new CFPlus::UI::Label valign => 0, align => -1, text => "Max weight:", expand => 1, |
1458 | $hb0->add ($STATWIDS->{m_weight} = new DC::UI::Label align => 0, text => "Max weight:", expand => 1, |
1192 | can_hover => 1, can_events => 1, |
1459 | can_hover => 1, can_events => 1, |
1193 | tooltip => "The weight limit: you cannot carry more than this."); |
1460 | tooltip => "The weight limit: you cannot carry more than this."); |
1194 | |
1461 | |
1195 | $vb->add (new CFPlus::UI::FancyFrame |
1462 | $vb->add (new DC::UI::FancyFrame |
1196 | label => "Primary/Secondary Statistics", |
1463 | label => "Primary/Secondary Statistics", |
1197 | child => (my $hb = new CFPlus::UI::HBox expand => 1), |
1464 | child => (my $hb = new DC::UI::HBox expand => 1), |
1198 | ); |
1465 | ); |
1199 | $hb->add (my $tbl = new CFPlus::UI::Table expand => 1); |
1466 | $hb->add (my $tbl = new DC::UI::Table expand => 1); |
1200 | |
1467 | |
1201 | my $color2 = [1, 1, 0]; |
1468 | my $color2 = [1, 1, 0]; |
1202 | |
1469 | |
1203 | for ( |
1470 | for ( |
1204 | [0, 0, st_str => "Str", 30], |
1471 | [0, 0, st_str => "Str", 30], |
… | |
… | |
1216 | [2, 4, st_spd => "Spd", 10.54], |
1483 | [2, 4, st_spd => "Spd", 10.54], |
1217 | [2, 5, st_wspd => "WSp", 10.54], |
1484 | [2, 5, st_wspd => "WSp", 10.54], |
1218 | ) { |
1485 | ) { |
1219 | my ($col, $row, $id, $label, $template) = @$_; |
1486 | my ($col, $row, $id, $label, $template) = @$_; |
1220 | |
1487 | |
1221 | $tbl->add_at ($col , $row, $STATWIDS->{$id} = new CFPlus::UI::Label |
1488 | $tbl->add_at ($col , $row, $STATWIDS->{$id} = new DC::UI::Label |
1222 | font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, |
1489 | font => $FONT_FIXED, can_hover => 1, can_events => 1, |
1223 | align => +1, template => $template, tooltip => "#stat_$label"); |
1490 | align => 1, template => $template, tooltip => "#stat_$label"); |
1224 | $tbl->add_at ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFPlus::UI::Label |
1491 | $tbl->add_at ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new DC::UI::Label |
1225 | font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0, |
1492 | font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, |
1226 | align => -1, text => $label, tooltip => "#stat_$label"); |
1493 | align => 0, text => $label, tooltip => "#stat_$label"); |
1227 | } |
1494 | } |
1228 | |
1495 | |
1229 | $vb->add (new CFPlus::UI::FancyFrame |
1496 | $vb->add (new DC::UI::FancyFrame |
1230 | label => "Resistancies", |
1497 | label => "Resistancies", |
1231 | child => (my $tbl2 = new CFPlus::UI::Table expand => 1), |
1498 | child => (my $tbl2 = new DC::UI::Table expand => 1, col_expand => [1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0]), |
1232 | ); |
1499 | ); |
1233 | |
1500 | |
1234 | my $row = 0; |
1501 | my $row = 0; |
1235 | my $col = 0; |
1502 | my $col = 0; |
1236 | |
1503 | |
… | |
… | |
1256 | para => ["Paralysation", |
1523 | para => ["Paralysation", |
1257 | "<b>Paralysation</b> (this resistance affects the chance you get paralysed)"], |
1524 | "<b>Paralysation</b> (this resistance affects the chance you get paralysed)"], |
1258 | deat => ["Death", |
1525 | deat => ["Death", |
1259 | "<b>Death</b> (resistance against death spells)"], |
1526 | "<b>Death</b> (resistance against death spells)"], |
1260 | phys => ["Physical", |
1527 | phys => ["Physical", |
1261 | "<b>Physical</b> (this is the resistance against physical attacks, like when a monster hit you in melee combat. The value displayed here is also displayed in the 'Arm' field on the left.)"], |
1528 | "<b>Physical</b> (this is the resistance against physical attacks, like when a monster hit you in melee combat. The value displayed here is also displayed as the 'Arm' secondary stat.)"], |
1262 | blind => ["Blind", |
1529 | blind => ["Blind", |
1263 | "<b>Blind</b> (blind resistance affects the chance of a successful blinding attack)"], |
1530 | "<b>Blind</b> (blind resistance affects the chance of a successful blinding attack)"], |
1264 | fear => ["Fear", |
1531 | fear => ["Fear", |
1265 | "<b>Fear</b> (this attack will drive you away from monsters who cast this and hit you successfully, being resistant to this helps a lot when fighting those monsters)"], |
1532 | "<b>Fear</b> (this attack will drive you away from monsters who cast this and hit you successfully, being resistant to this helps a lot when fighting those monsters)"], |
1266 | tund => ["Turn undead", |
1533 | tund => ["Turn undead", |
… | |
… | |
1275 | |
1542 | |
1276 | for (qw/slow holyw conf fire depl magic |
1543 | for (qw/slow holyw conf fire depl magic |
1277 | drain acid pois para deat phys |
1544 | drain acid pois para deat phys |
1278 | blind fear tund elec cold ghit/) |
1545 | blind fear tund elec cold ghit/) |
1279 | { |
1546 | { |
1280 | $tbl2->add_at ($col, $row, |
1547 | $tbl2->add_at ($col + 2, $row, |
1281 | $STATWIDS->{"res_$_"} = |
1548 | $STATWIDS->{"res_$_"} = |
1282 | new CFPlus::UI::Label |
1549 | new DC::UI::Label |
1283 | font => $FONT_FIXED, |
1550 | font => $FONT_FIXED, |
1284 | template => "-100%", |
1551 | template => "-100%", |
1285 | align => +1, |
1552 | align => 1, |
1286 | valign => 0, |
|
|
1287 | can_events => 1, |
1553 | can_events => 1, |
1288 | can_hover => 1, |
1554 | can_hover => 1, |
1289 | tooltip => $resist_names{$_}->[1], |
1555 | tooltip => $resist_names{$_}->[1], |
1290 | ); |
1556 | ); |
1291 | $tbl2->add_at ($col + 1, $row, new CFPlus::UI::Image |
1557 | $tbl2->add_at ($col + 1, $row, new DC::UI::Image |
1292 | font => $FONT_FIXED, |
1558 | font => $FONT_FIXED, |
1293 | can_hover => 1, |
1559 | can_hover => 1, |
1294 | can_events => 1, |
1560 | can_events => 1, |
1295 | path => "ui/resist/resist_$_.png", |
1561 | path => "ui/resist/resist_$_.png", |
1296 | tooltip => $resist_names{$_}->[1], |
1562 | tooltip => $resist_names{$_}->[1], |
1297 | ); |
1563 | ); |
1298 | $tbl2->add_at ($col + 2, $row, new CFPlus::UI::Label |
1564 | $tbl2->add_at ($col + 0, $row, new DC::UI::Label |
1299 | text => $resist_names{$_}->[0], |
1565 | text => $resist_names{$_}->[0], |
1300 | font => $FONT_FIXED, |
1566 | font => $FONT_FIXED, |
|
|
1567 | align => 1, |
1301 | can_hover => 1, |
1568 | can_hover => 1, |
1302 | can_events => 1, |
1569 | can_events => 1, |
1303 | tooltip => $resist_names{$_}->[1], |
1570 | tooltip => $resist_names{$_}->[1], |
1304 | ); |
1571 | ); |
1305 | |
1572 | |
1306 | $row++; |
1573 | $row++; |
1307 | if ($row % 6 == 0) { |
1574 | if ($row % 6 == 0) { |
1308 | $col += 3; |
1575 | $col += 4; |
1309 | $row = 0; |
1576 | $row = 0; |
1310 | } |
1577 | } |
1311 | } |
1578 | } |
1312 | |
1579 | |
1313 | #update_stats_window ({}); |
1580 | #update_stats_window ({}); |
1314 | |
1581 | |
1315 | $r |
1582 | $r |
1316 | } |
1583 | } |
1317 | |
1584 | |
1318 | sub skill_window { |
1585 | sub skill_window { |
1319 | my $sw = new CFPlus::UI::ScrolledWindow (expand => 1); |
1586 | my $sw = new DC::UI::ScrolledWindow (expand => 1); |
1320 | |
1587 | |
1321 | $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, .1, 0, 0, 1, .1]); |
1588 | $sw->add ($STATWIDS->{skill_tbl} = new DC::UI::Table expand => 1, col_expand => [0, 0, 1, .1, 0, 0, 1, .1]); |
1322 | |
1589 | |
1323 | $sw |
1590 | $sw |
1324 | } |
1591 | } |
1325 | |
1592 | |
1326 | sub formsep($) { |
1593 | sub formsep($) { |
… | |
… | |
1338 | return if $METASERVER_ATIME > time; |
1605 | return if $METASERVER_ATIME > time; |
1339 | $METASERVER_ATIME = time + 60; |
1606 | $METASERVER_ATIME = time + 60; |
1340 | |
1607 | |
1341 | my $table = $METASERVER->{table}; |
1608 | my $table = $METASERVER->{table}; |
1342 | $table->clear; |
1609 | $table->clear; |
1343 | $table->add_at (0, 0, my $label = new CFPlus::UI::Label max_w => $WIDTH * 0.8, text => "fetching server list..."); |
1610 | $table->add_at (0, 0, my $label = new DC::UI::Label max_w => $WIDTH * 0.8, text => "fetching server list..."); |
1344 | |
1611 | |
1345 | my $ok = 0; |
1612 | my $ok = 0; |
1346 | |
1613 | |
1347 | CFPlus::background { |
1614 | DC::background { |
1348 | my $ua = CFPlus::lwp_useragent; |
1615 | my $ua = DC::lwp_useragent; |
1349 | |
1616 | |
1350 | CFPlus::background_msg CFPlus::from_json +(CFPlus::lwp_check $ua->get ($META_SERVER))->decoded_content; |
1617 | DC::background_msg DC::decode_json +(DC::lwp_check $ua->get ($META_SERVER))->decoded_content; |
1351 | } sub { |
1618 | } sub { |
1352 | my ($msg) = @_; |
1619 | my ($msg) = @_; |
1353 | if ($msg) { |
1620 | if ($msg) { |
1354 | $table->clear; |
1621 | $table->clear; |
1355 | |
1622 | |
… | |
… | |
1358 | "The hostname of the server.", |
1625 | "The hostname of the server.", |
1359 | "The time this server has been running without being restarted.", |
1626 | "The time this server has been running without being restarted.", |
1360 | "Short information about this server provided by its admins.", |
1627 | "Short information about this server provided by its admins.", |
1361 | ); |
1628 | ); |
1362 | my @col = qw(#Users Host Uptime Version Description); |
1629 | my @col = qw(#Users Host Uptime Version Description); |
1363 | $table->add_at ($_, 0, new CFPlus::UI::Label |
1630 | $table->add_at ($_, 0, new DC::UI::Label |
1364 | can_hover => 1, can_events => 1, |
1631 | can_hover => 1, can_events => 1, fg => [1, 1, 0], |
1365 | align => 0, fg => [1, 1, 0], |
|
|
1366 | text => $col[$_], tooltip => $tip[$_]) |
1632 | text => $col[$_], tooltip => $tip[$_]) |
1367 | for 0 .. $#col; |
1633 | for 0 .. $#col; |
1368 | |
1634 | |
1369 | my @align = qw(1 0 1 1 -1); |
1635 | my @align = qw(1 0.5 1 1 0); |
1370 | |
1636 | |
1371 | my $y = 0; |
1637 | my $y = 0; |
1372 | for my $m (@{ $msg->{servers} }) { |
1638 | for my $m (@{ $msg->{servers} }) { |
1373 | my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime, $highlight) = |
1639 | my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime, $highlight) = |
1374 | @$m{qw(ip age hostname users version description ibytes obytes uptime highlight)}; |
1640 | @$m{qw(ip age hostname users version description ibytes obytes uptime highlight)}; |
… | |
… | |
1390 | |
1656 | |
1391 | $m = [$users, $host, $uptime, $version, $desc]; |
1657 | $m = [$users, $host, $uptime, $version, $desc]; |
1392 | |
1658 | |
1393 | $y++; |
1659 | $y++; |
1394 | |
1660 | |
1395 | $table->add_at (scalar @$m, $y, new CFPlus::UI::VBox children => [ |
1661 | $table->add_at (scalar @$m, $y, new DC::UI::VBox children => [ |
1396 | (new CFPlus::UI::Button |
1662 | (new DC::UI::Button |
1397 | text => "Use", |
1663 | text => "Use", |
1398 | tooltip => "Put this server into the <b>Host:Port</b> field", |
1664 | tooltip => "Put this server into the <b>Host:Port</b> field", |
1399 | on_activate => sub { |
1665 | on_activate => sub { |
1400 | $HOST_ENTRY->set_text ($CFG->{profile}{default}{host} = $host); |
1666 | $HOST_ENTRY->set_text ($CFG->{profile}{default}{host} = $host); |
1401 | $METASERVER->hide; |
1667 | $METASERVER->hide; |
1402 | 0 |
1668 | 0 |
1403 | }, |
1669 | }, |
1404 | ), |
1670 | ), |
1405 | (new CFPlus::UI::Empty expand => 1), |
1671 | (new DC::UI::Empty expand => 1), |
1406 | ]); |
1672 | ]); |
1407 | |
1673 | |
1408 | $table->add_at ($_, $y, new CFPlus::UI::Label |
1674 | $table->add_at ($_, $y, new DC::UI::Label |
1409 | max_w => $::WIDTH * 0.4, |
1675 | max_w => $::WIDTH * 0.4, |
1410 | ellipsise => 0, |
1676 | ellipsise => 0, |
1411 | align => $align[$_], |
1677 | align => $align[$_], |
1412 | text => $m->[$_], |
1678 | text => $m->[$_], |
1413 | tooltip => $tip[$_], |
1679 | tooltip => $tip[$_], |
… | |
… | |
1423 | }; |
1689 | }; |
1424 | |
1690 | |
1425 | } |
1691 | } |
1426 | |
1692 | |
1427 | sub metaserver_dialog { |
1693 | sub metaserver_dialog { |
1428 | my $vbox = new CFPlus::UI::VBox; |
1694 | my $vbox = new DC::UI::VBox; |
1429 | my $table = new CFPlus::UI::Table; |
1695 | my $table = new DC::UI::Table; |
1430 | $vbox->add (new CFPlus::UI::ScrolledWindow expand => 1, child => $table); |
1696 | $vbox->add (new DC::UI::ScrolledWindow expand => 1, child => $table); |
1431 | |
1697 | |
1432 | my $dialog = new CFPlus::UI::Toplevel |
1698 | my $dialog = new DC::UI::Toplevel |
1433 | title => "Server List", |
1699 | title => "Server List", |
1434 | name => 'metaserver_dialog', |
1700 | name => 'metaserver_dialog', |
1435 | x => 'center', |
1701 | x => 'center', |
1436 | y => 'center', |
1702 | y => 'center', |
1437 | z => 3, |
1703 | z => 3, |
… | |
… | |
1448 | |
1714 | |
1449 | $dialog |
1715 | $dialog |
1450 | } |
1716 | } |
1451 | |
1717 | |
1452 | sub login_setup { |
1718 | sub login_setup { |
1453 | my $vbox = new CFPlus::UI::VBox; |
1719 | my $vbox = new DC::UI::VBox; |
1454 | |
1720 | |
1455 | $vbox->add (new CFPlus::UI::FancyFrame |
1721 | $vbox->add (new DC::UI::FancyFrame |
1456 | label => "Login Settings", |
1722 | label => "Login Settings", |
1457 | child => (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]), |
1723 | child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]), |
1458 | ); |
1724 | ); |
1459 | |
1725 | |
1460 | $table->add_at (0, 4, new CFPlus::UI::Label valign => 0, align => 1, text => "Username"); |
1726 | $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username"); |
1461 | $table->add_at (1, 4, new CFPlus::UI::Entry |
1727 | $table->add_at (1, 4, new DC::UI::Entry |
1462 | text => $CFG->{profile}{default}{user}, |
1728 | text => $PROFILE->{user}, |
1463 | tooltip => "The name of your character on the server.", |
1729 | tooltip => "The name of your character on the server. The name is case-sensitive!", |
1464 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 } |
1730 | on_changed => sub { my ($self, $value) = @_; $PROFILE->{user} = $value; 1 } |
1465 | ); |
1731 | ); |
1466 | |
1732 | |
1467 | $table->add_at (0, 5, new CFPlus::UI::Label valign => 0, align => 1, text => "Password"); |
1733 | $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password"); |
1468 | $table->add_at (1, 5, new CFPlus::UI::Entry |
1734 | $table->add_at (1, 5, new DC::UI::Entry |
1469 | text => $CFG->{profile}{default}{password}, |
1735 | text => $PROFILE->{password}, |
1470 | hidden => 1, |
1736 | hidden => 1, |
1471 | tooltip => "The password for your character.", |
1737 | tooltip => "The password for your character.", |
1472 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value; 1 } |
1738 | on_changed => sub { my ($self, $value) = @_; $PROFILE->{password} = $value; 1 } |
1473 | ); |
1739 | ); |
1474 | |
1740 | |
1475 | $table->add_at (1, 11, $LOGIN_BUTTON = new CFPlus::UI::Button |
1741 | $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button |
1476 | expand => 1, |
1742 | expand => 1, |
1477 | align => 0, |
|
|
1478 | text => "Login / Register", |
1743 | text => "Login / Register", |
1479 | tooltip => "This button will either login to the account configured above or register a new account.", |
1744 | tooltip => "This button will either login to the account configured above or register a new account.", |
1480 | on_activate => sub { |
1745 | on_activate => sub { |
1481 | $CONN ? stop_game |
1746 | $CONN ? stop_game |
1482 | : start_game; |
1747 | : start_game; |
1483 | 1 |
1748 | 1 |
1484 | }, |
1749 | }, |
1485 | ); |
1750 | ); |
1486 | |
1751 | |
1487 | $vbox->add (new CFPlus::UI::FancyFrame |
1752 | $vbox->add (new DC::UI::FancyFrame |
1488 | label => "Registering", |
1753 | label => "How to Play", |
1489 | min_h => 200, |
1754 | min_h => 240, |
1490 | child => (new CFPlus::UI::Label valign => -1, ellipsise => 0, |
1755 | child => (new DC::UI::Label valign => 0, ellipsise => 0, |
1491 | markup => |
1756 | markup => |
|
|
1757 | "First select a suitable video resolution in the <b>Graphics</b> tab, above.\n\n" |
|
|
1758 | . "Then register a new account (or use an existing one if you have one). " |
1492 | "To register a new account, choose a username that hasn't been taken yet and " |
1759 | . "To register an account, choose a username that hasn't been taken yet (just guess) and " |
1493 | . "try to log-in. Follow the instructions in the Log tab in the message window.", |
1760 | . "try to log-in. Follow the instructions in the Log tab in the message window.", |
1494 | ), |
1761 | ), |
1495 | ); |
1762 | ); |
1496 | |
1763 | |
1497 | $vbox |
1764 | $vbox |
1498 | } |
1765 | } |
1499 | |
1766 | |
1500 | sub server_setup { |
1767 | sub server_setup { |
1501 | my $vbox = new CFPlus::UI::VBox; |
1768 | my $vbox = new DC::UI::VBox; |
1502 | |
1769 | |
1503 | $vbox->add (new CFPlus::UI::FancyFrame |
1770 | $vbox->add (new DC::UI::FancyFrame |
1504 | label => "Connection Settings", |
1771 | label => "Connection Settings", |
1505 | child => (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]), |
1772 | child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]), |
1506 | ); |
1773 | ); |
1507 | |
1774 | |
1508 | my $row = 0; |
1775 | my $row = 0; |
1509 | |
1776 | |
1510 | $table->add_at (0, ++$row, new CFPlus::UI::Label valign => 0, align => 1, text => "Host:Port"); |
1777 | $table->add_at (0, ++$row, new DC::UI::Label align => 1, text => "Host:Port"); |
1511 | { |
1778 | { |
1512 | $table->add_at (1, $row, my $vbox = new CFPlus::UI::VBox); |
1779 | $table->add_at (1, $row, my $vbox = new DC::UI::VBox); |
1513 | |
1780 | |
1514 | $vbox->add ( |
1781 | $vbox->add ( |
1515 | $HOST_ENTRY = new CFPlus::UI::Entry |
1782 | $HOST_ENTRY = new DC::UI::Entry |
1516 | expand => 1, |
1783 | expand => 1, |
1517 | text => $CFG->{profile}{default}{host}, |
1784 | text => $PROFILE->{host}, |
1518 | tooltip => "The hostname or ip address of the Deliantra server to connect to", |
1785 | tooltip => "The hostname or ip address of the Deliantra server to connect to (e.g. <b>gameserver.deliantra.net</b>)", |
1519 | on_changed => sub { |
1786 | on_changed => sub { |
1520 | my ($self, $value) = @_; |
1787 | my ($self, $value) = @_; |
1521 | $CFG->{profile}{default}{host} = $value; |
1788 | $PROFILE->{host} = $value; |
1522 | 1 |
1789 | 1 |
1523 | } |
1790 | } |
1524 | ); |
1791 | ); |
1525 | |
1792 | |
|
|
1793 | if (0) { #d# disabled |
1526 | $vbox->add (new CFPlus::UI::Button |
1794 | $vbox->add (new DC::UI::Button |
1527 | expand => 1, |
1795 | expand => 1, |
1528 | text => "Server List", |
1796 | text => "Server List", |
1529 | other => $METASERVER, |
1797 | other => $METASERVER, |
1530 | tooltip => "Show a list of available crossfire servers", |
1798 | tooltip => "Show a list of available Deliantra servers", |
1531 | on_activate => sub { $METASERVER->toggle_visibility; 0 }, |
1799 | on_activate => sub { $METASERVER->toggle_visibility; 0 }, |
1532 | on_visibility_change => sub { $METASERVER->hide unless $_[1]; 1 }, |
1800 | on_visibility_change => sub { $METASERVER->hide unless $_[1]; 1 }, |
1533 | ); |
1801 | ); |
|
|
1802 | }#d# |
1534 | } |
1803 | } |
1535 | |
1804 | |
1536 | $table->add_at (0, ++$row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Size"); |
1805 | $table->add_at (0, ++$row, new DC::UI::Label align => 1, text => "Map Size"); |
1537 | $table->add_at (1, $row, new CFPlus::UI::Slider |
1806 | $table->add_at (1, $row, new DC::UI::Slider |
1538 | force_w => 100, |
1807 | force_w => 100, |
1539 | range => [$CFG->{mapsize}, 10, 100, 0, 1], |
1808 | range => [$CFG->{mapsize}, 10, 100, 0, 1], |
1540 | tooltip => "This is the size of the portion of the map update the server sends you. " |
1809 | tooltip => "This is the size of the portion of the map update the server sends you. " |
1541 | . "If you set this to a high value you will be able to see further, " |
1810 | . "If you set this to a high value you will be able to see further, " |
1542 | . "but you also increase bandwidth requirements and latency. " |
1811 | . "but you also increase bandwidth requirements and latency. " |
1543 | . "This option is only used once at log-in.", |
1812 | . "This option is only used once at log-in.", |
1544 | on_changed => sub { my ($self, $value) = @_; $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 1 }, |
1813 | on_changed => sub { my ($self, $value) = @_; $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 1 }, |
1545 | ); |
1814 | ); |
1546 | |
1815 | |
1547 | $table->add_at (0, ++$row, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Rate"); |
1816 | $table->add_at (0, ++$row, new DC::UI::Label align => 1, text => "Output-Rate"); |
1548 | $table->add_at (1, $row, new CFPlus::UI::Entry |
1817 | $table->add_at (1, $row, new DC::UI::Entry |
1549 | text => $CFG->{output_rate}, |
1818 | text => $CFG->{output_rate}, |
1550 | tooltip => "The maximum bandwidth in bytes per second that the server should not exceed " |
1819 | tooltip => "The maximum bandwidth in bytes per second that the server should not exceed " |
1551 | . "when sending data. When 0 or unset, the server " |
1820 | . "when sending data. When 0 or unset, the server " |
1552 | . "default will be used, which is usually around 100kb/s. Most servers will " |
1821 | . "default will be used, which is usually around 100kb/s. Most servers will " |
1553 | . "dynamically find an optimal rate, so adjust this only when necessary.", |
1822 | . "dynamically find an optimal rate, so adjust this only when necessary.", |
1554 | on_changed => sub { $CFG->{output_rate} = $_[1]; 1 }, |
1823 | on_changed => sub { $CFG->{output_rate} = $_[1]; 1 }, |
1555 | ); |
1824 | ); |
1556 | |
1825 | |
1557 | $vbox->add (new CFPlus::UI::FancyFrame |
1826 | $vbox->add (new DC::UI::FancyFrame |
1558 | label => "Server Info", |
1827 | label => "Server Info", |
1559 | child => ($SERVER_INFO = new CFPlus::UI::Label ellipsise => 0), |
1828 | child => ($SERVER_INFO = new DC::UI::Label ellipsise => 0), |
1560 | ); |
1829 | ); |
1561 | |
1830 | |
1562 | $vbox |
1831 | $vbox |
1563 | } |
1832 | } |
1564 | |
1833 | |
1565 | sub client_setup { |
1834 | sub client_setup { |
1566 | my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]; |
1835 | my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]; |
1567 | |
1836 | |
1568 | my $row = 0; |
1837 | my $row = 0; |
1569 | |
1838 | |
1570 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day"); |
1839 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Tip of the day"); |
1571 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
1840 | $table->add_at (1, $row++, new DC::UI::CheckBox |
|
|
1841 | c_colspan => 2, |
1572 | state => $CFG->{show_tips}, |
1842 | state => $CFG->{show_tips}, |
1573 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1843 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1574 | on_changed => sub { |
1844 | on_changed => sub { |
1575 | my ($self, $value) = @_; |
1845 | my ($self, $value) = @_; |
1576 | $CFG->{show_tips} = $value; |
1846 | $CFG->{show_tips} = $value; |
1577 | 0 |
1847 | 0 |
1578 | } |
1848 | } |
1579 | ); |
1849 | ); |
1580 | |
1850 | |
1581 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Messages Window Size"); |
1851 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Window Size"); |
1582 | $table->add_at (1, $row++, my $saycmd = new CFPlus::UI::Entry |
1852 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
|
|
1853 | c_colspan => 2, |
1583 | text => $CFG->{logview_max_par}, |
1854 | text => $CFG->{logview_max_par}, |
1584 | tooltip => "This is maximum number of messages remembered in the <b>Messages</b> window. If the server " |
1855 | tooltip => "This is maximum number of messages remembered in the <b>Message</b> window. If the server " |
1585 | . "sends more messages than this number, older messages get removed to save memory and " |
1856 | . "sends more messages than this number, older messages get removed to save memory and " |
1586 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1857 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1587 | on_changed => sub { |
1858 | on_changed => sub { |
1588 | my ($self, $value) = @_; |
1859 | my ($self, $value) = @_; |
1589 | $MESSAGE_WINDOW->set_max_para ($CFG->{logview_max_par} = $value*1); |
1860 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
1590 | 0 |
1861 | 0 |
1591 | }, |
1862 | }, |
1592 | ); |
1863 | ); |
1593 | |
1864 | |
|
|
1865 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Config Autosave"); |
|
|
1866 | $table->add_at (1, $row, new DC::UI::CheckBox |
|
|
1867 | state => $CFG->{config_autosave}, |
|
|
1868 | tooltip => "Normally, configuration settings and the user interface layout " |
|
|
1869 | . "are saved on client exit. You can disable this behaviour by " |
|
|
1870 | . "unchecking this checkbox.", |
|
|
1871 | on_changed => sub { |
|
|
1872 | my ($self, $value) = @_; |
|
|
1873 | $CFG->{config_autosave} = $value; |
|
|
1874 | 0 |
|
|
1875 | } |
|
|
1876 | ); |
|
|
1877 | $table->add_at (2, $row++, new DC::UI::Button |
|
|
1878 | text => "Save Now", |
|
|
1879 | tooltip => "Use this to manually save configuration and UI layout when " |
|
|
1880 | . "autosave is disabled.", |
|
|
1881 | on_activate => sub { |
|
|
1882 | DC::write_cfg; |
|
|
1883 | 0 |
|
|
1884 | } |
|
|
1885 | ); |
|
|
1886 | |
1594 | $table |
1887 | $table |
1595 | } |
1888 | } |
1596 | |
1889 | |
1597 | sub autopickup_setup { |
1890 | sub autopickup_setup { |
1598 | my $r = new CFPlus::UI::ScrolledWindow ( |
1891 | my $r = new DC::UI::ScrolledWindow ( |
1599 | expand => 1, |
1892 | expand => 1, |
1600 | scroll_y => 1 |
1893 | scroll_y => 1 |
1601 | ); |
1894 | ); |
1602 | $r->add (my $table = new CFPlus::UI::Table |
1895 | $r->add (my $table = new DC::UI::Table |
1603 | row_expand => [0], |
1896 | row_expand => [0], |
1604 | col_expand => [0, 1, 0, 1], |
1897 | col_expand => [0, 1, 0, 1], |
1605 | ); |
1898 | ); |
1606 | |
1899 | |
1607 | for ( |
1900 | for ( |
1608 | ["General", 0, 0, |
1901 | ["General", 0, 0, |
1609 | ["Enable autopickup" => PICKUP_NEWMODE, \$PICKUP_ENABLE], |
|
|
1610 | ["Inhibit autopickup" => PICKUP_INHIBIT], |
1902 | # ["Inhibit autopickup" => PICKUP_INHIBIT], |
1611 | ["Stop before pickup" => PICKUP_STOP], |
1903 | ["Stop before pickup" => PICKUP_STOP], |
1612 | ["Debug autopickup" => PICKUP_DEBUG], |
1904 | ["Debug autopickup" => PICKUP_DEBUG], |
1613 | ], |
1905 | ], |
1614 | ["Weapons", 0, 6, |
1906 | ["Weapons", 0, 6, |
1615 | ["All weapons" => PICKUP_ALLWEAPON], |
1907 | ["All weapons" => PICKUP_ALLWEAPON], |
… | |
… | |
1641 | ["Magic Devices" => PICKUP_MAGIC_DEVICE], |
1933 | ["Magic Devices" => PICKUP_MAGIC_DEVICE], |
1642 | ["Ignore cursed" => PICKUP_NOT_CURSED], |
1934 | ["Ignore cursed" => PICKUP_NOT_CURSED], |
1643 | ["Jewelery" => PICKUP_JEWELS], |
1935 | ["Jewelery" => PICKUP_JEWELS], |
1644 | ["Flesh" => PICKUP_FLESH], |
1936 | ["Flesh" => PICKUP_FLESH], |
1645 | ], |
1937 | ], |
1646 | ["Weight/Value ratio", 2, 17] |
1938 | ["Value/Weight ratio", 2, 17] |
1647 | ) |
1939 | ) |
1648 | { |
1940 | { |
1649 | my ($title, $x, $y, @bits) = @$_; |
1941 | my ($title, $x, $y, @bits) = @$_; |
1650 | $table->add_at ($x, $y, new CFPlus::UI::Label text => $title, align => 1, fg => [1, 1, 0]); |
1942 | $table->add_at ($x, $y, new DC::UI::Label text => $title, align => 1, fg => [1, 1, 0]); |
1651 | |
1943 | |
1652 | for (@bits) { |
1944 | for (@bits) { |
1653 | ++$y; |
1945 | ++$y; |
1654 | |
1946 | |
1655 | my $mask = $_->[1]; |
1947 | my $mask = $_->[1]; |
1656 | $table->add_at ($x , $y, new CFPlus::UI::Label text => $_->[0], align => 1, expand => 1); |
1948 | $table->add_at ($x , $y, new DC::UI::Label text => $_->[0], align => 1, expand => 1); |
1657 | $table->add_at ($x+1, $y, my $checkbox = new CFPlus::UI::CheckBox |
1949 | $table->add_at ($x+1, $y, my $checkbox = new DC::UI::CheckBox |
1658 | state => $::CFG->{pickup} & $mask, |
1950 | state => $::CFG->{pickup} & $mask, |
1659 | on_changed => sub { |
1951 | on_changed => sub { |
1660 | my ($box, $value) = @_; |
1952 | my ($box, $value) = @_; |
1661 | |
1953 | |
1662 | if ($value) { |
1954 | if ($value) { |
1663 | $::CFG->{pickup} |= $mask; |
1955 | $::CFG->{pickup} |= $mask; |
1664 | } else { |
1956 | } else { |
1665 | $::CFG->{pickup} &= ~$mask; |
1957 | $::CFG->{pickup} &= ~$mask; |
1666 | } |
1958 | } |
1667 | |
1959 | |
1668 | $::CONN->send_command ("pickup $::CFG->{pickup}") |
1960 | $::CONN->send_pickup ($::CFG->{pickup}) |
1669 | if defined $::CONN; |
1961 | if defined $::CONN; |
1670 | |
1962 | |
1671 | 0 |
1963 | 0 |
1672 | }); |
1964 | }); |
1673 | |
1965 | |
1674 | ${$_->[2]} = $checkbox if $_->[2]; |
1966 | ${$_->[2]} = $checkbox if $_->[2]; |
1675 | } |
1967 | } |
1676 | } |
1968 | } |
1677 | |
1969 | |
1678 | $table->add_at (2, 18, new CFPlus::UI::ValSlider |
1970 | $table->add_at (2, 18, new DC::UI::ValSlider |
1679 | range => [$::CFG->{pickup} & 0xF, 0, 16, 1, 1], |
1971 | range => [$::CFG->{pickup} & 0xF, 0, 16, 1, 1], |
1680 | template => ">= 99", |
1972 | template => ">= 99", |
|
|
1973 | tooltip => "Pick up items whose value/weight (silver/kg) ratio is equal or higher than this setting (which is specified in gold coins).", |
1681 | to_value => sub { ">= " . 5 * $_[0] }, |
1974 | to_value => sub { ">= " . 5 * $_[0] }, |
1682 | on_changed => sub { |
1975 | on_changed => sub { |
1683 | my ($slider, $value) = @_; |
1976 | my ($slider, $value) = @_; |
1684 | |
1977 | |
1685 | $::CFG->{pickup} &= ~0xF; |
1978 | $::CFG->{pickup} &= ~0xF; |
1686 | $::CFG->{pickup} |= int $value |
1979 | $::CFG->{pickup} |= int $value |
1687 | if $value; |
1980 | if $value; |
1688 | 1; |
1981 | 1; |
1689 | }); |
1982 | }); |
1690 | |
1983 | |
1691 | $table->add_at (3, 18, new CFPlus::UI::Button |
1984 | $table->add_at (3, 18, new DC::UI::Button |
1692 | text => "set", |
1985 | text => "set", |
1693 | on_activate => sub { |
1986 | on_activate => sub { |
1694 | $::CONN->send_command ("pickup $::CFG->{pickup}") |
1987 | $::CONN->send_pickup ($::CFG->{pickup}) |
1695 | if defined $::CONN; |
1988 | if defined $::CONN; |
1696 | 0 |
1989 | 0 |
1697 | }); |
1990 | }); |
1698 | |
1991 | |
1699 | $r |
1992 | $r |
1700 | } |
1993 | } |
1701 | |
1994 | |
1702 | my %SORT_ORDER = ( |
1995 | my %SORT_ORDER = ( |
1703 | type => undef, |
1996 | type => sub { |
|
|
1997 | use sort 'stable'; |
|
|
1998 | sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ |
|
|
1999 | }, |
1704 | mtime => sub { |
2000 | mtime => sub { |
|
|
2001 | use sort 'stable'; |
1705 | my $NOW = time; |
2002 | my $NOW = time; |
1706 | sort { |
2003 | sort { |
1707 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
2004 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
1708 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
2005 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
1709 | |
2006 | |
1710 | ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) |
2007 | ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) |
1711 | or $btime <=> $atime |
2008 | or $btime <=> $atime |
1712 | or $a->{type} <=> $b->{type} |
2009 | or $a->{type} <=> $b->{type} |
1713 | } @_ |
2010 | } @_ |
1714 | }, |
2011 | }, |
1715 | weight => sub { sort { |
2012 | weight => sub { |
|
|
2013 | use sort 'stable'; |
|
|
2014 | sort { |
1716 | $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) |
2015 | $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) |
1717 | or $a->{type} <=> $b->{type} |
2016 | or $a->{type} <=> $b->{type} |
1718 | } @_ }, |
2017 | } @_ |
|
|
2018 | }, |
1719 | ); |
2019 | ); |
1720 | |
2020 | |
1721 | sub inventory_widget { |
2021 | sub inventory_widget { |
1722 | my $hb = new CFPlus::UI::HBox homogeneous => 1; |
2022 | my $hb = new DC::UI::HBox homogeneous => 1; |
1723 | |
2023 | |
1724 | $hb->add (my $vb1 = new CFPlus::UI::VBox); |
2024 | $hb->add (my $vb1 = new DC::UI::VBox); |
1725 | $vb1->add (new CFPlus::UI::Label align => 0, text => "Player"); |
2025 | $vb1->add (new DC::UI::Label text => "Player"); |
1726 | |
2026 | |
1727 | $vb1->add (my $hb1 = new CFPlus::UI::HBox); |
2027 | $vb1->add (my $hb1 = new DC::UI::HBox); |
1728 | |
2028 | |
1729 | use sort 'stable'; |
2029 | use sort 'stable'; |
1730 | |
2030 | |
1731 | $hb1->add (new CFPlus::UI::Selector |
2031 | $hb1->add (new DC::UI::Selector |
1732 | value => $::CFG->{inv_sort}, |
2032 | value => $::CFG->{inv_sort}, |
1733 | options => [ |
2033 | options => [ |
1734 | [type => "Type/Name"], |
2034 | [type => "Type/Name"], |
1735 | [mtime => "Recent/Normal/Locked"], |
2035 | [mtime => "Recent/Normal/Locked"], |
1736 | [weight => "Weight/Type"], |
2036 | [weight => "Weight/Type"], |
… | |
… | |
1738 | on_changed => sub { |
2038 | on_changed => sub { |
1739 | $::CFG->{inv_sort} = $_[1]; |
2039 | $::CFG->{inv_sort} = $_[1]; |
1740 | $INV->set_sort_order ($SORT_ORDER{$_[1]}); |
2040 | $INV->set_sort_order ($SORT_ORDER{$_[1]}); |
1741 | }, |
2041 | }, |
1742 | ); |
2042 | ); |
1743 | $hb1->add (new CFPlus::UI::Label text => "Weight: ", align => 1, expand => 1); |
2043 | $hb1->add (new DC::UI::Label text => "Weight: ", align => 1, expand => 1); |
1744 | #TODO# update to weigh/maxweight |
2044 | #TODO# update to weight/maxweight |
1745 | $hb1->add ($STATWIDS->{i_weight} = new CFPlus::UI::Label align => -1); |
2045 | $hb1->add ($STATWIDS->{i_weight} = new DC::UI::Label align => 0); |
1746 | |
2046 | |
1747 | $vb1->add (my $sw1 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); |
2047 | $vb1->add (my $sw1 = new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1748 | $sw1->add ($INV = new CFPlus::UI::Inventory); |
2048 | $sw1->add ($INV = new DC::UI::Inventory); |
1749 | $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}}); |
2049 | $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}}); |
1750 | |
2050 | |
1751 | $hb->add (my $vb2 = new CFPlus::UI::VBox); |
2051 | $hb->add (my $vb2 = new DC::UI::VBox); |
1752 | |
2052 | |
1753 | $vb2->add ($INVR_HB = new CFPlus::UI::HBox); |
2053 | $vb2->add ($INVR_HB = new DC::UI::HBox); |
1754 | |
2054 | |
1755 | $vb2->add (my $sw2 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); |
2055 | $vb2->add (my $sw2 = new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1756 | $sw2->add ($INVR = new CFPlus::UI::Inventory); |
2056 | $sw2->add ($INVR = new DC::UI::Inventory); |
1757 | |
2057 | |
1758 | # XXX: Call after $INVR = ... because set_opencont sets the items |
2058 | # XXX: Call after $INVR = ... because set_opencont sets the items |
1759 | CFPlus::Protocol::set_opencont ($::CONN, 0, "Floor"); |
2059 | DC::Protocol::set_opencont ($::CONN, 0, "Floor"); |
1760 | |
2060 | |
1761 | $hb |
2061 | $hb |
1762 | } |
2062 | } |
1763 | |
2063 | |
1764 | sub media_window { |
2064 | sub media_window { |
1765 | my $vb = new CFPlus::UI::VBox; |
2065 | my $vb = new DC::UI::VBox; |
1766 | |
2066 | |
1767 | $vb->add (new CFPlus::UI::FancyFrame |
2067 | $vb->add (new DC::UI::FancyFrame |
1768 | label => "Currently playing music", |
2068 | label => "Currently playing music", |
1769 | child => new CFPlus::UI::ScrolledWindow scroll_x => 1, scroll_y => 0, |
2069 | child => new DC::UI::ScrolledWindow scroll_x => 1, scroll_y => 0, |
1770 | child => ($MUSIC_PLAYING_WIDGET = new CFPlus::UI::Label ellipsise => 0, fontsize => 0.8), |
2070 | child => ($MUSIC_PLAYING_WIDGET = new DC::UI::Label ellipsise => 0, fontsize => 0.8), |
1771 | ); |
2071 | ); |
1772 | |
2072 | |
1773 | $vb->add (new CFPlus::UI::FancyFrame |
2073 | $vb->add (new DC::UI::FancyFrame |
1774 | label => "Other media used in this session", |
2074 | label => "Other media used in this session", |
1775 | expand => 1, |
2075 | expand => 1, |
1776 | child => ($LICENSE_WIDGET = new CFPlus::UI::TextScroller |
2076 | child => ($LICENSE_WIDGET = new DC::UI::TextScroller |
1777 | expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4), |
2077 | expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4), |
1778 | ); |
2078 | ); |
1779 | |
2079 | |
1780 | $vb |
2080 | $vb |
1781 | } |
2081 | } |
… | |
… | |
1790 | or return; |
2090 | or return; |
1791 | |
2091 | |
1792 | $LICENSE_WIDGET->add_paragraph ({ |
2092 | $LICENSE_WIDGET->add_paragraph ({ |
1793 | fg => [1, 1, 1, 1], |
2093 | fg => [1, 1, 1, 1], |
1794 | markup => "<small>" |
2094 | markup => "<small>" |
1795 | . "<b>Name:</b> " . (CFPlus::asxml $meta->{name}) . "\n" |
2095 | . "<b>Name:</b> " . (DC::asxml $meta->{name}) . "\n" |
1796 | . "<b>Author:</b> " . (CFPlus::asxml $meta->{author}) . "\n" |
2096 | . "<b>Author:</b> " . (DC::asxml $meta->{author}) . "\n" |
1797 | . "<b>Source:</b> " . (CFPlus::asxml $meta->{source}) . "\n" |
2097 | . "<b>Source:</b> " . (DC::asxml $meta->{source}) . "\n" |
1798 | . "<b>License:</b> " . (CFPlus::asxml $meta->{license}) . "\n" |
2098 | . "<b>License:</b> " . (DC::asxml $meta->{license}) . "\n" |
1799 | . "</small>", |
2099 | . "</small>", |
1800 | }); |
2100 | }); |
1801 | $LICENSE_WIDGET->scroll_to_bottom; |
2101 | $LICENSE_WIDGET->scroll_to_bottom; |
1802 | } |
2102 | } |
1803 | |
2103 | |
… | |
… | |
1810 | $PL_NOTEBOOK->set_current_page ($widget); |
2110 | $PL_NOTEBOOK->set_current_page ($widget); |
1811 | $PL_WINDOW->show; |
2111 | $PL_WINDOW->show; |
1812 | } |
2112 | } |
1813 | } |
2113 | } |
1814 | |
2114 | |
1815 | sub player_window { |
2115 | sub make_playerbook { |
1816 | my $plwin = $PL_WINDOW = new CFPlus::UI::Toplevel |
2116 | my $plwin = $PL_WINDOW = new DC::UI::Toplevel |
1817 | x => "center", |
2117 | x => "center", |
1818 | y => "center", |
2118 | y => "center", |
1819 | force_w => $WIDTH * 9/10, |
2119 | force_w => $WIDTH * 9/10, |
1820 | force_h => $HEIGHT * 9/10, |
2120 | force_h => $HEIGHT * 9/10, |
1821 | title => "Player", |
2121 | title => "Player", |
… | |
… | |
1823 | has_close_button => 1 |
2123 | has_close_button => 1 |
1824 | ; |
2124 | ; |
1825 | |
2125 | |
1826 | my $ntb = |
2126 | my $ntb = |
1827 | $PL_NOTEBOOK = |
2127 | $PL_NOTEBOOK = |
1828 | new CFPlus::UI::Notebook expand => 1; |
2128 | new DC::UI::Notebook expand => 1; |
1829 | |
2129 | |
1830 | $ntb->add_tab ( |
2130 | $ntb->add_tab ( |
1831 | "Statistics (F2)" => $STATS_PAGE = stats_window, |
2131 | "Statistics (F2)" => $STATS_PAGE = stats_window, |
1832 | "Shows statistics, where all your Stats and Resistances are shown." |
2132 | "Shows statistics, where all your Stats and Resistances are shown." |
1833 | ); |
2133 | ); |
1834 | $ntb->add_tab ( |
2134 | $ntb->add_tab ( |
1835 | "Skills (F3)" => $SKILL_PAGE = skill_window, |
2135 | "Skills (F3)" => $SKILL_PAGE = skill_window, |
1836 | "Shows all your Skills." |
2136 | "Shows all your Skills." |
1837 | ); |
2137 | ); |
1838 | |
2138 | |
1839 | my $spellsw = $SPELL_PAGE = new CFPlus::UI::ScrolledWindow (expand => 1, scroll_y => 1); |
2139 | my $spellsw = $SPELL_PAGE = new DC::UI::ScrolledWindow (expand => 1, scroll_y => 1); |
1840 | $spellsw->add ($SPELL_LIST = new CFPlus::UI::SpellList); |
2140 | $spellsw->add ($SPELL_LIST = new DC::UI::SpellList); |
1841 | $ntb->add_tab ( |
2141 | $ntb->add_tab ( |
1842 | "Spellbook (F4)" => $spellsw, |
2142 | "Spellbook (F4)" => $spellsw, |
1843 | "Displays all spells you have and lets you edit keyboard shortcuts for them." |
2143 | "Displays all spells you have and lets you edit keyboard shortcuts for them." |
1844 | ); |
2144 | ); |
1845 | $ntb->add_tab ( |
2145 | $ntb->add_tab ( |
… | |
… | |
1854 | "License, Author and Source info for media sent by the server."); |
2154 | "License, Author and Source info for media sent by the server."); |
1855 | |
2155 | |
1856 | $ntb->set_current_page ($INVENTORY_PAGE); |
2156 | $ntb->set_current_page ($INVENTORY_PAGE); |
1857 | |
2157 | |
1858 | $plwin->add ($ntb); |
2158 | $plwin->add ($ntb); |
1859 | $plwin |
|
|
1860 | } |
2159 | } |
1861 | |
2160 | |
1862 | sub keyboard_setup { |
2161 | sub keyboard_setup { |
1863 | CFPlus::Macro::keyboard_setup |
2162 | DC::Macro::keyboard_setup |
1864 | } |
2163 | } |
1865 | |
2164 | |
1866 | sub help_window { |
2165 | sub make_help_window { |
1867 | my $win = new CFPlus::UI::Toplevel |
2166 | my $win = new DC::UI::Toplevel |
1868 | x => 'center', |
2167 | x => 'center', |
1869 | y => 'center', |
2168 | y => 'center', |
1870 | z => 4, |
2169 | z => 4, |
1871 | name => 'doc_browser', |
2170 | name => 'doc_browser', |
1872 | force_w => int $WIDTH * 7/8, |
2171 | force_w => int $WIDTH * 7/8, |
1873 | force_h => int $HEIGHT * 7/8, |
2172 | force_h => int $HEIGHT * 7/8, |
1874 | title => "Help Browser", |
2173 | title => "Help Browser", |
1875 | has_close_button => 1; |
2174 | has_close_button => 1; |
1876 | |
2175 | |
1877 | $win->add (my $vbox = new CFPlus::UI::VBox); |
2176 | $win->add (my $vbox = new DC::UI::VBox); |
1878 | |
2177 | |
1879 | $vbox->add (new CFPlus::UI::FancyFrame |
2178 | $vbox->add (new DC::UI::FancyFrame |
1880 | label => "Navigation", |
2179 | label => "Navigation", |
1881 | child => (my $buttons = new CFPlus::UI::HBox), |
2180 | child => (my $buttons = new DC::UI::HBox), |
1882 | ); |
2181 | ); |
1883 | $vbox->add (my $viewer = new CFPlus::UI::TextScroller |
2182 | $vbox->add (my $viewer = new DC::UI::TextScroller |
1884 | expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4); |
2183 | expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4); |
1885 | |
2184 | |
1886 | my @history; |
2185 | my @history; |
1887 | my @future; |
2186 | my @future; |
1888 | my $curnode; |
2187 | my $curnode; |
… | |
… | |
1890 | my $load_node; $load_node = sub { |
2189 | my $load_node; $load_node = sub { |
1891 | my ($node, $para) = @_; |
2190 | my ($node, $para) = @_; |
1892 | |
2191 | |
1893 | $buttons->clear; |
2192 | $buttons->clear; |
1894 | |
2193 | |
1895 | $buttons->add (new CFPlus::UI::Button |
2194 | $buttons->add (new DC::UI::Button |
1896 | text => "⇤", |
2195 | text => "⇤", |
1897 | tooltip => "back to the starting page", |
2196 | tooltip => "back to the starting page", |
1898 | on_activate => sub { |
2197 | on_activate => sub { |
1899 | unshift @future, [$curnode, $viewer->current_paragraph] if $curnode; |
2198 | unshift @future, [$curnode, $viewer->current_paragraph] if $curnode; |
1900 | unshift @future, @history; |
2199 | unshift @future, @history; |
… | |
… | |
1902 | $load_node->(@{shift @future}); |
2201 | $load_node->(@{shift @future}); |
1903 | }, |
2202 | }, |
1904 | ); |
2203 | ); |
1905 | |
2204 | |
1906 | if (@history) { |
2205 | if (@history) { |
1907 | $buttons->add (new CFPlus::UI::Button |
2206 | $buttons->add (new DC::UI::Button |
1908 | text => "⋘", |
2207 | text => "⋘", |
1909 | tooltip => "back to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $history[-1][0]) . "</i>", |
2208 | tooltip => "back to <i>" . (DC::asxml DC::Pod::full_path $history[-1][0]) . "</i>", |
1910 | on_activate => sub { |
2209 | on_activate => sub { |
1911 | unshift @future, [$curnode, $viewer->current_paragraph] if $curnode; |
2210 | unshift @future, [$curnode, $viewer->current_paragraph] if $curnode; |
1912 | $load_node->(@{pop @history}); |
2211 | $load_node->(@{pop @history}); |
1913 | }, |
2212 | }, |
1914 | ); |
2213 | ); |
1915 | } |
2214 | } |
1916 | |
2215 | |
1917 | if (@future) { |
2216 | if (@future) { |
1918 | $buttons->add (new CFPlus::UI::Button |
2217 | $buttons->add (new DC::UI::Button |
1919 | text => "⋙", |
2218 | text => "⋙", |
1920 | tooltip => "forward to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $future[0][0]) . "</i>", |
2219 | tooltip => "forward to <i>" . (DC::asxml DC::Pod::full_path $future[0][0]) . "</i>", |
1921 | on_activate => sub { |
2220 | on_activate => sub { |
1922 | push @history, [$curnode, $viewer->current_paragraph]; |
2221 | push @history, [$curnode, $viewer->current_paragraph]; |
1923 | $load_node->(@{shift @future}); |
2222 | $load_node->(@{shift @future}); |
1924 | }, |
2223 | }, |
1925 | ); |
2224 | ); |
1926 | } |
2225 | } |
1927 | |
2226 | |
1928 | $buttons->add (new CFPlus::UI::Label text => " "); |
2227 | $buttons->add (new DC::UI::Label text => " "); |
1929 | |
2228 | |
1930 | my @path = CFPlus::Pod::full_path_of $node; |
2229 | my @path = DC::Pod::full_path_of $node; |
1931 | pop @path; # drop current node |
2230 | pop @path; # drop current node |
1932 | |
2231 | |
1933 | for my $node (@path) { |
2232 | for my $node (@path) { |
1934 | $buttons->add (new CFPlus::UI::Button |
2233 | $buttons->add (new DC::UI::Button |
1935 | text => $node->{kw}[0], |
2234 | text => $node->[DC::Pod::N_KW][0], |
1936 | tooltip => "go to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $node) . "</i>", |
2235 | tooltip => "go to <i>" . (DC::asxml DC::Pod::full_path $node) . "</i>", |
1937 | on_activate => sub { |
2236 | on_activate => sub { |
1938 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
2237 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
1939 | $load_node->($node); |
2238 | $load_node->($node); |
1940 | }, |
2239 | }, |
1941 | ); |
2240 | ); |
1942 | $buttons->add (new CFPlus::UI::Label text => "/"); |
2241 | $buttons->add (new DC::UI::Label text => "/"); |
1943 | } |
2242 | } |
1944 | |
2243 | |
1945 | $buttons->add (new CFPlus::UI::Label text => $node->{kw}[0], padding_x => 4, padding_y => 4); |
2244 | $buttons->add (new DC::UI::Label text => $node->[DC::Pod::N_KW][0], padding_x => 4, padding_y => 4); |
1946 | |
2245 | |
1947 | $curnode = $node; |
2246 | $curnode = $node; |
1948 | |
2247 | |
1949 | $viewer->clear; |
2248 | $viewer->clear; |
1950 | $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $curnode); |
2249 | $viewer->add_paragraph (DC::Pod::as_paragraphs DC::Pod::section_of $curnode); |
1951 | $viewer->scroll_to ($para); |
2250 | $viewer->scroll_to ($para); |
1952 | }; |
2251 | }; |
1953 | |
2252 | |
1954 | $load_node->(CFPlus::Pod::find pod => "mainpage"); |
2253 | $load_node->(DC::Pod::find pod => "mainpage"); |
1955 | |
2254 | |
1956 | $CFPlus::Pod::goto_document = sub { |
2255 | $DC::Pod::goto_document = sub { |
1957 | my (@path) = @_; |
2256 | my (@path) = @_; |
1958 | |
2257 | |
1959 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
2258 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
1960 | |
2259 | |
1961 | $load_node->((CFPlus::Pod::find @path)[0]); |
2260 | $load_node->((DC::Pod::find @path)[0]); |
1962 | $win->show; |
2261 | $win->show; |
1963 | }; |
2262 | }; |
1964 | |
2263 | |
1965 | $win |
2264 | $HELP_WINDOW = $win; |
1966 | } |
|
|
1967 | |
|
|
1968 | sub open_string_query { |
|
|
1969 | my ($title, $cb, $txt, $tooltip) = @_; |
|
|
1970 | my $dialog = new CFPlus::UI::Toplevel |
|
|
1971 | x => "center", |
|
|
1972 | y => "center", |
|
|
1973 | z => 50, |
|
|
1974 | force_w => $WIDTH * 4/5, |
|
|
1975 | title => $title; |
|
|
1976 | |
|
|
1977 | $dialog->add ( |
|
|
1978 | my $e = new CFPlus::UI::Entry |
|
|
1979 | on_activate => sub { $cb->(@_); $dialog->hide; 0 }, |
|
|
1980 | on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 }, |
|
|
1981 | tooltip => $tooltip |
|
|
1982 | ); |
|
|
1983 | |
|
|
1984 | $e->grab_focus; |
|
|
1985 | $e->set_text ($txt) if $txt; |
|
|
1986 | $dialog->show; |
|
|
1987 | } |
2265 | } |
1988 | |
2266 | |
1989 | sub open_quit_dialog { |
2267 | sub open_quit_dialog { |
1990 | unless ($QUIT_DIALOG) { |
2268 | unless ($QUIT_DIALOG) { |
1991 | $QUIT_DIALOG = new CFPlus::UI::Toplevel |
2269 | $QUIT_DIALOG = new DC::UI::Toplevel |
1992 | x => "center", |
2270 | x => "center", |
1993 | y => "center", |
2271 | y => "center", |
1994 | z => 50, |
2272 | z => 50, |
1995 | title => "Really Quit?", |
2273 | title => "Really Quit?", |
1996 | on_key_down => sub { |
2274 | on_key_down => sub { |
1997 | my ($dialog, $ev) = @_; |
2275 | my ($dialog, $ev) = @_; |
1998 | $ev->{sym} == 27 and $dialog->hide; |
2276 | $ev->{sym} == 27 and $dialog->hide; |
1999 | } |
2277 | } |
2000 | ; |
2278 | ; |
2001 | |
2279 | |
2002 | $QUIT_DIALOG->add (my $vb = new CFPlus::UI::VBox expand => 1); |
2280 | $QUIT_DIALOG->add (my $vb = new DC::UI::VBox expand => 1); |
2003 | |
2281 | |
2004 | $vb->add (new CFPlus::UI::Label |
2282 | $vb->add (new DC::UI::Label |
2005 | text => "You should find a savebed and apply it first!", |
2283 | text => "You should find a savebed and apply it first!", |
2006 | max_w => $WIDTH * 0.25, |
2284 | max_w => $WIDTH * 0.25, |
2007 | ellipsize => 0, |
2285 | ellipsize => 0, |
2008 | ); |
2286 | ); |
2009 | $vb->add (my $hb = new CFPlus::UI::HBox expand => 1); |
2287 | $vb->add (my $hb = new DC::UI::HBox expand => 1); |
2010 | $hb->add (new CFPlus::UI::Button |
2288 | $hb->add (new DC::UI::Button |
2011 | text => "Ok", |
2289 | text => "Ok", |
2012 | expand => 1, |
2290 | expand => 1, |
2013 | on_activate => sub { $QUIT_DIALOG->hide; 0 }, |
2291 | on_activate => sub { $QUIT_DIALOG->hide; 0 }, |
2014 | ); |
2292 | ); |
2015 | $hb->add (new CFPlus::UI::Button |
2293 | $hb->add (new DC::UI::Button |
2016 | text => "Quit anyway", |
2294 | text => "Quit anyway", |
2017 | expand => 1, |
2295 | expand => 1, |
2018 | on_activate => sub { Event::unloop_all }, |
2296 | on_activate => sub { |
|
|
2297 | crash "Quit anyway"; |
|
|
2298 | EV::unloop EV::UNLOOP_ALL; |
|
|
2299 | }, |
2019 | ); |
2300 | ); |
2020 | } |
2301 | } |
2021 | |
2302 | |
2022 | $QUIT_DIALOG->show; |
2303 | $QUIT_DIALOG->show; |
2023 | $QUIT_DIALOG->grab_focus; |
2304 | $QUIT_DIALOG->grab_focus; |
2024 | } |
2305 | } |
2025 | |
2306 | |
|
|
2307 | sub make_menubar { |
|
|
2308 | $MENUFRAME = new DC::UI::Toplevel |
|
|
2309 | border => 0, |
|
|
2310 | force_x => 0, |
|
|
2311 | force_y => 0, |
|
|
2312 | force_w => $::WIDTH, |
|
|
2313 | child => ($MENUBAR = new DC::UI::HBox), |
|
|
2314 | ; |
|
|
2315 | |
|
|
2316 | $MENUBAR->add ($BUTTONBAR = new DC::UI::Buttonbar); |
|
|
2317 | |
|
|
2318 | # XXX: this has to be done before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D |
|
|
2319 | make_gauge_window->show; |
|
|
2320 | |
|
|
2321 | # $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
|
|
2322 | # tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
|
|
2323 | |
|
|
2324 | make_playerbook; |
|
|
2325 | |
|
|
2326 | $MENUPOPUP = DC::UI::Menu->new (items => [ |
|
|
2327 | ["Setup…\tF9" , sub { $SETUP_DIALOG->toggle_visibility }], |
|
|
2328 | ["Playerbook…\tTab" , sub { $PL_WINDOW ->toggle_visibility }], |
|
|
2329 | ["…Statistics\tF2" , sub { toggle_player_page ($::STATS_PAGE) }], |
|
|
2330 | ["…Skills\tF3" , sub { toggle_player_page ($::SKILL_PAGE) }], |
|
|
2331 | ["…Spells\tF4" , sub { toggle_player_page ($::SPELL_PAGE) }], |
|
|
2332 | ["…Inventory\tF5" , sub { toggle_player_page ($::INVENTORY_PAGE) }], |
|
|
2333 | ["Help Browser…\tF1" , sub { $HELP_WINDOW ->toggle_visibility }], |
|
|
2334 | ["Quit…" , sub { |
|
|
2335 | if ($CONN) { |
|
|
2336 | open_quit_dialog; |
|
|
2337 | } else { |
|
|
2338 | EV::unloop EV::UNLOOP_ALL; |
|
|
2339 | } |
|
|
2340 | }], |
|
|
2341 | ]); |
|
|
2342 | |
|
|
2343 | $BUTTONBAR->add (new DC::UI::Button text => "Menu…", |
|
|
2344 | tooltip => "Shows the main menu", |
|
|
2345 | on_button_down => sub { |
|
|
2346 | my ($self, $ev) = @_; |
|
|
2347 | local $ev->{x} = 0; |
|
|
2348 | local $ev->{y} = 0; |
|
|
2349 | $MENUPOPUP->popup ($ev); |
|
|
2350 | }, |
|
|
2351 | ); |
|
|
2352 | |
|
|
2353 | $MENUBAR->add ($GAUGES->{exp} = new DC::UI::ExperienceProgress |
|
|
2354 | padding_x => 6, |
|
|
2355 | padding_y => 3, |
|
|
2356 | tooltip => "This progress bar shows your overall experience and your progress towards the next character level.", |
|
|
2357 | template => " Exp: 888,888,888,888 (lvl 188) ", |
|
|
2358 | ); |
|
|
2359 | |
|
|
2360 | $MENUBAR->add ($PICKUP_ENABLE = new DC::UI::CheckBox # checkbox bad, button better? |
|
|
2361 | tooltip => "Automatic Pickup Enable - when this checkbox is enabled, then your character " |
|
|
2362 | . "will automatically pick up items as defined by your item pickup settings " |
|
|
2363 | . "in the playerbook. Often (e.g. in apartments) you want to temporarily " |
|
|
2364 | . "disable autopickup by disabling this checkbox.", |
|
|
2365 | state => $CFG->{pickup} & PICKUP_INHIBIT ? 0 : 1, |
|
|
2366 | on_changed => sub { |
|
|
2367 | my ($self, $value) = @_; |
|
|
2368 | $CFG->{pickup} &= ~PICKUP_INHIBIT; |
|
|
2369 | $CFG->{pickup} |= PICKUP_INHIBIT unless $_[1]; |
|
|
2370 | $CONN->send_pickup ($CFG->{pickup}) |
|
|
2371 | if $CONN; |
|
|
2372 | }, |
|
|
2373 | ); |
|
|
2374 | |
|
|
2375 | $MENUBAR->add ($GAUGES->{skillexp} = new DC::UI::ExperienceProgress |
|
|
2376 | c_rescale => 1, |
|
|
2377 | padding_x => 6, |
|
|
2378 | padding_y => 3, |
|
|
2379 | force_w => $::WIDTH * 0.2, |
|
|
2380 | tooltip => "This progress bar shows the currently used skill and your progress towards the next skill level of that skill.", |
|
|
2381 | template => "two handed weapons 99%", |
|
|
2382 | ); |
|
|
2383 | |
|
|
2384 | $MENUBAR->add ($GAUGES->{range} = new DC::UI::Label |
|
|
2385 | expand => 1, |
|
|
2386 | align => 1, can_hover => 1, can_events => 1, |
|
|
2387 | text => "Range and Combat Slots", |
|
|
2388 | tooltip => "#stat_ranged", |
|
|
2389 | ); |
|
|
2390 | |
|
|
2391 | $MENUFRAME->show; |
|
|
2392 | } |
|
|
2393 | |
|
|
2394 | sub open_string_query { |
|
|
2395 | my ($title, $cb, $txt, $tooltip) = @_; |
|
|
2396 | my $dialog = new DC::UI::Toplevel |
|
|
2397 | x => "center", |
|
|
2398 | y => "center", |
|
|
2399 | z => 50, |
|
|
2400 | force_w => $WIDTH * 4/5, |
|
|
2401 | title => $title; |
|
|
2402 | |
|
|
2403 | $dialog->add ( |
|
|
2404 | my $e = new DC::UI::Entry |
|
|
2405 | on_activate => sub { $cb->(@_); $dialog->hide; 0 }, |
|
|
2406 | on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 }, |
|
|
2407 | tooltip => $tooltip |
|
|
2408 | ); |
|
|
2409 | |
|
|
2410 | $e->grab_focus; |
|
|
2411 | $e->set_text ($txt) if $txt; |
|
|
2412 | $dialog->show; |
|
|
2413 | } |
|
|
2414 | |
2026 | sub show_tip_of_the_day { |
2415 | sub show_tip_of_the_day { |
2027 | # find all tips |
2416 | # find all tips |
2028 | my @tod = CFPlus::Pod::find tip_of_the_day => "*"; |
2417 | my @tod = DC::Pod::find tip_of_the_day => "*"; |
2029 | |
2418 | |
2030 | CFPlus::DB::get state => "tip_of_the_day", sub { |
2419 | DC::DB::get state => "tip_of_the_day", sub { |
2031 | my ($todindex) = @_; |
2420 | my ($todindex) = @_; |
2032 | $todindex = 0 if $todindex >= @tod; |
2421 | $todindex = 0 if $todindex >= @tod; |
2033 | CFPlus::DB::put state => tip_of_the_day => $todindex + 1, sub { }; |
2422 | DC::DB::put state => tip_of_the_day => $todindex + 1, sub { }; |
2034 | |
2423 | |
2035 | # create dialog |
2424 | # create dialog |
2036 | my $dialog; |
2425 | my $dialog; |
2037 | |
2426 | |
2038 | my $close = sub { |
2427 | my $close = sub { |
2039 | $dialog->destroy; |
2428 | $dialog->destroy; |
2040 | }; |
2429 | }; |
2041 | |
2430 | |
2042 | $dialog = new CFPlus::UI::Toplevel |
2431 | $dialog = new DC::UI::Toplevel |
2043 | x => "center", |
2432 | x => "center", |
2044 | y => "center", |
2433 | y => "center", |
2045 | z => 3, |
2434 | z => 3, |
2046 | name => 'tip_of_the_day', |
2435 | name => 'tip_of_the_day', |
2047 | force_w => int $WIDTH * 4/9, |
2436 | force_w => int $WIDTH * 4/9, |
2048 | force_h => int $WIDTH * 2/9, |
2437 | force_h => int $WIDTH * 2/9, |
2049 | title => "Tip of the day #" . (1 + $todindex), |
2438 | title => "Tip of the day #" . (1 + $todindex), |
2050 | child => my $vbox = new CFPlus::UI::VBox, |
2439 | child => my $vbox = new DC::UI::VBox, |
2051 | has_close_button => 1, |
2440 | has_close_button => 1, |
2052 | on_delete => $close, |
2441 | on_delete => $close, |
2053 | ; |
2442 | ; |
2054 | |
2443 | |
2055 | $vbox->add (my $viewer = new CFPlus::UI::TextScroller |
2444 | $vbox->add (my $viewer = new DC::UI::TextScroller |
2056 | expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4); |
2445 | expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4); |
2057 | $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $tod[$todindex]); |
2446 | $viewer->add_paragraph (DC::Pod::as_paragraphs DC::Pod::section_of $tod[$todindex]); |
2058 | |
2447 | |
2059 | $vbox->add (my $table = new CFPlus::UI::Table col_expand => [0, 1]); |
2448 | $vbox->add (my $table = new DC::UI::Table col_expand => [0, 1]); |
2060 | |
2449 | |
2061 | $table->add_at (0, 0, new CFPlus::UI::Button |
2450 | $table->add_at (0, 0, new DC::UI::Button |
2062 | text => "Close", |
2451 | text => "Close", |
2063 | tooltip => "Close the tip of the day window. To never see it again, disable the tip of the day in the <b>Server Setup</b>.", |
2452 | tooltip => "Close the tip of the day window. To never see it again, disable the tip of the day in the <b>Server Setup</b>.", |
2064 | on_activate => $close, |
2453 | on_activate => $close, |
2065 | ); |
2454 | ); |
2066 | |
2455 | |
2067 | $table->add_at (2, 0, new CFPlus::UI::Button |
2456 | $table->add_at (2, 0, new DC::UI::Button |
2068 | text => "Next", |
2457 | text => "Next", |
2069 | tooltip => "Show the next <b>Tip of the day</b>.", |
2458 | tooltip => "Show the next <b>Tip of the day</b>.", |
2070 | on_activate => sub { |
2459 | on_activate => sub { |
2071 | $close->(); |
2460 | $close->(); |
2072 | &show_tip_of_the_day; |
2461 | &show_tip_of_the_day; |
… | |
… | |
2075 | |
2464 | |
2076 | $dialog->show; |
2465 | $dialog->show; |
2077 | }; |
2466 | }; |
2078 | } |
2467 | } |
2079 | |
2468 | |
2080 | sub sdl_init { |
|
|
2081 | CFPlus::SDL_Init |
|
|
2082 | and die "SDL::Init failed!\n"; |
|
|
2083 | } |
|
|
2084 | |
|
|
2085 | sub video_init { |
2469 | sub video_init { |
|
|
2470 | DC::set_theme $CFG->{uitheme}; |
|
|
2471 | |
|
|
2472 | DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT; |
|
|
2473 | $SDL_REINIT = 0; |
|
|
2474 | |
|
|
2475 | @SDL_MODES = DC::SDL_ListModes 8, $CFG->{disable_alpha} ? 0 : 8; |
|
|
2476 | @SDL_MODES = DC::SDL_ListModes 8, 8 unless @SDL_MODES; |
|
|
2477 | @SDL_MODES = DC::SDL_ListModes 5, 0 unless @SDL_MODES; |
|
|
2478 | @SDL_MODES or DC::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
|
|
2479 | |
|
|
2480 | @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES; |
|
|
2481 | |
2086 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES; |
2482 | if (!defined $CFG->{sdl_mode} or $CFG->{sdl_mode} > $#SDL_MODES) { |
|
|
2483 | $CFG->{sdl_mode} = 0; # lowest resolution by default |
|
|
2484 | |
|
|
2485 | # now choose biggest mode <= 1024x768 |
|
|
2486 | for (0 .. $#SDL_MODES) { |
|
|
2487 | if ($SDL_MODES[$_][0] * $SDL_MODES[$_][1] <= 1024 * 768) { |
|
|
2488 | $CFG->{sdl_mode} = $_; |
|
|
2489 | } |
|
|
2490 | } |
|
|
2491 | } |
2087 | |
2492 | |
2088 | my ($old_w, $old_h) = ($WIDTH, $HEIGHT); |
2493 | my ($old_w, $old_h) = ($WIDTH, $HEIGHT); |
2089 | |
2494 | |
2090 | ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
2495 | ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
2091 | $FULLSCREEN = $CFG->{fullscreen}; |
2496 | $FULLSCREEN = $CFG->{fullscreen}; |
2092 | $FAST = $CFG->{fast}; |
2497 | $FAST = $CFG->{fast}; |
2093 | |
2498 | |
|
|
2499 | # due to mac os x braindamage, we simply retry with !fullscreen in case of an error |
2094 | CFPlus::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, $FULLSCREEN |
2500 | DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, $FULLSCREEN |
|
|
2501 | or DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, !$FULLSCREEN |
2095 | or die "SDL_SetVideoMode failed: " . (CFPlus::SDL_GetError) . "\n"; |
2502 | or die "SDL_SetVideoMode failed: " . (DC::SDL_GetError) . "\n"; |
2096 | |
2503 | |
2097 | $SDL_ACTIVE = 1; |
2504 | $SDL_ACTIVE = 1; |
2098 | $LAST_REFRESH = time - 0.01; |
2505 | $LAST_REFRESH = time - 0.01; |
2099 | |
2506 | |
2100 | CFPlus::OpenGL::init; |
2507 | DC::OpenGL::init; |
2101 | CFPlus::Macro::init; |
2508 | DC::Macro::init; |
2102 | |
2509 | |
2103 | $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
2510 | $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
2104 | |
2511 | |
2105 | $CFPlus::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# |
2512 | $DC::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# |
2106 | |
2513 | |
2107 | ############################################################################# |
2514 | ############################################################################# |
2108 | |
2515 | |
2109 | if ($DEBUG_STATUS) { |
2516 | if ($DEBUG_STATUS) { |
2110 | CFPlus::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h; |
2517 | DC::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h; |
2111 | } else { |
2518 | } else { |
2112 | # create/configure the widgets |
2519 | # create/configure the widgets |
2113 | |
2520 | |
2114 | $CFPlus::UI::ROOT->connect (key_down => sub { |
2521 | $DC::UI::ROOT->connect (key_down => sub { |
2115 | my (undef, $ev) = @_; |
2522 | my (undef, $ev) = @_; |
2116 | |
2523 | |
2117 | if (my @macros = CFPlus::Macro::find $ev) { |
2524 | if (my @macros = DC::Macro::find $ev) { |
2118 | CFPlus::Macro::execute $_ for @macros; |
2525 | DC::Macro::execute $_ for @macros; |
2119 | |
2526 | |
2120 | return 1; |
2527 | return 1; |
2121 | } |
2528 | } |
2122 | |
2529 | |
2123 | 0 |
2530 | 0 |
2124 | }); |
2531 | }); |
2125 | |
2532 | |
2126 | $DEBUG_STATUS = new CFPlus::UI::Label |
2533 | $DEBUG_STATUS = new DC::UI::Label |
2127 | padding => 0, |
2534 | padding => 0, |
2128 | z => 100, |
2535 | z => 100, |
2129 | force_x => "max", |
2536 | force_x => "max", |
2130 | force_y => 0; |
2537 | force_y => 20; |
2131 | $DEBUG_STATUS->show; |
2538 | $DEBUG_STATUS->show; |
2132 | |
2539 | |
2133 | $STATUSBOX = new CFPlus::UI::Statusbox; |
2540 | $STATUSBOX = new DC::UI::Statusbox; |
2134 | $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", timeout => 864000, pri => -100, color => [1, 1, 1, 0.8]); |
|
|
2135 | |
2541 | |
|
|
2542 | $MODBOX = new DC::UI::Label |
|
|
2543 | can_events => 1, |
|
|
2544 | can_hover => 1, |
|
|
2545 | markup => "", |
|
|
2546 | align => 0, |
|
|
2547 | font => $FONT_FIXED, |
|
|
2548 | tooltip => "#modifier_box", |
|
|
2549 | tooltip_width => 0.67, |
|
|
2550 | ; |
|
|
2551 | |
|
|
2552 | update_modbox; |
|
|
2553 | |
2136 | (new CFPlus::UI::Frame |
2554 | (new DC::UI::Frame |
2137 | bg => [0, 0, 0, 0.4], |
2555 | bg => [0, 0, 0, 0.4], |
2138 | force_x => 0, |
2556 | force_x => 0, |
2139 | force_y => "max", |
2557 | force_y => "max", |
2140 | child => $STATUSBOX, |
2558 | child => (my $LL = new DC::UI::VBox), |
2141 | )->show; |
2559 | )->show; |
2142 | |
2560 | |
|
|
2561 | $LL->add ($STATUSBOX); |
|
|
2562 | $LL->add ($MODBOX); |
|
|
2563 | $LL->add (new DC::UI::Label |
|
|
2564 | align => 0, |
|
|
2565 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode", |
|
|
2566 | fontsize => 0.5, |
|
|
2567 | fg => [1, 1, 0, 0.7], |
|
|
2568 | ); |
|
|
2569 | |
2143 | CFPlus::UI::Toplevel->new ( |
2570 | DC::UI::Toplevel->new ( |
2144 | title => "Map", |
2571 | title => "Minimap", |
2145 | name => "mapmap", |
2572 | name => "mapmap", |
2146 | x => 0, |
2573 | x => 0, |
2147 | y => $FONTSIZE + 8, |
2574 | y => $::FONTSIZE + 8,#d# hack to move messages window below the menubar |
2148 | border_bg => [1, 1, 1, 192/255], |
2575 | border_bg => [1, 1, 1, 192/255], |
2149 | bg => [1, 1, 1, 0], |
2576 | bg => [1, 1, 1, 0], |
2150 | child => ($MAPMAP = new CFPlus::MapWidget::MapMap |
2577 | child => ($MAPMAP = new DC::MapWidget::MapMap |
2151 | tooltip => "<b>Map</b>. On servers that support this feature, this will display an overview of the surrounding areas.", |
2578 | tooltip => "<b>Minimap</b>. This will display an overview of the surrounding areas.", |
2152 | ), |
2579 | ), |
2153 | )->show; |
2580 | )->show; |
2154 | |
2581 | |
2155 | $MAPWIDGET = new CFPlus::MapWidget; |
2582 | $MAPWIDGET = new DC::MapWidget; |
2156 | $MAPWIDGET->connect (activate_console => sub { |
2583 | $MAPWIDGET->connect (activate_console => sub { |
2157 | my ($mapwidget, $preset) = @_; |
2584 | my ($mapwidget, $preset) = @_; |
2158 | |
2585 | |
2159 | $MESSAGE_WINDOW->activate_console ($preset) |
2586 | $MESSAGE_DIST->activate_console ($preset) |
2160 | if $MESSAGE_WINDOW; |
2587 | if $MESSAGE_DIST; |
2161 | }); |
2588 | }); |
2162 | $MAPWIDGET->show; |
2589 | $MAPWIDGET->show; |
2163 | $MAPWIDGET->grab_focus; |
2590 | $MAPWIDGET->grab_focus; |
2164 | |
2591 | |
2165 | $COMPLETER = new CFPlus::MapWidget::Command:: |
2592 | $COMPLETER = new DC::MapWidget::Command:: |
2166 | command => { }, |
2593 | command => { }, |
2167 | tooltip => "#completer_help", |
2594 | tooltip => "#completer_help", |
2168 | ; |
2595 | ; |
2169 | |
2596 | |
2170 | $SETUP_DIALOG = new CFPlus::UI::Toplevel |
2597 | $SETUP_DIALOG = new DC::UI::Toplevel |
2171 | title => "Setup", |
2598 | title => "Setup", |
2172 | name => "setup_dialog", |
2599 | name => "setup_dialog", |
2173 | x => 'center', |
2600 | x => 'center', |
2174 | y => 'center', |
2601 | y => 'center', |
2175 | z => 2, |
2602 | z => 2, |
… | |
… | |
2177 | force_h => $::HEIGHT * 0.6, |
2604 | force_h => $::HEIGHT * 0.6, |
2178 | has_close_button => 1, |
2605 | has_close_button => 1, |
2179 | ; |
2606 | ; |
2180 | |
2607 | |
2181 | $METASERVER = metaserver_dialog; |
2608 | $METASERVER = metaserver_dialog; |
2182 | $MESSAGE_WINDOW = new CFPlus::UI::MessageWindow; |
2609 | # the name is changed to not conflict with the older name as users could have hidden it |
|
|
2610 | $MESSAGE_WINDOW = new DC::UI::Dockbar |
|
|
2611 | name => "message_window2", |
|
|
2612 | title => 'Messages', |
|
|
2613 | y => $::FONTSIZE + 8,#d# hack to move messages window below the menubar |
|
|
2614 | force_w => $::WIDTH * 0.6, |
|
|
2615 | force_h => $::HEIGHT * 0.25, |
|
|
2616 | ; |
2183 | |
2617 | |
|
|
2618 | $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; |
|
|
2619 | |
2184 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFPlus::UI::Notebook expand => 1, debug => 1, |
2620 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new DC::UI::Notebook expand => 1, |
2185 | filter => new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); |
2621 | filter => new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); |
2186 | |
2622 | |
2187 | $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup, |
2623 | $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup, |
2188 | "Configure the server to play on, your username and password."); |
2624 | "Configure the server to play on, your username and password."); |
2189 | $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup, |
2625 | $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup, |
2190 | "Configure other server related options."); |
2626 | "Configure other server related options."); |
… | |
… | |
2202 | . "After pressing the combo the binding will be saved automatically and the " |
2638 | . "After pressing the combo the binding will be saved automatically and the " |
2203 | . "binding editor closes"); |
2639 | . "binding editor closes"); |
2204 | $SETUP_NOTEBOOK->add_tab (Debug => debug_setup, |
2640 | $SETUP_NOTEBOOK->add_tab (Debug => debug_setup, |
2205 | "Some debuggin' options. Do not ask."); |
2641 | "Some debuggin' options. Do not ask."); |
2206 | |
2642 | |
2207 | $BUTTONBAR = new CFPlus::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
2643 | make_help_window; |
|
|
2644 | make_menubar; |
2208 | |
2645 | |
2209 | $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
|
|
2210 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
|
|
2211 | |
|
|
2212 | $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
|
|
2213 | tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
|
|
2214 | |
|
|
2215 | make_gauge_window->show; # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D |
|
|
2216 | |
|
|
2217 | $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Playerbook", other => player_window, |
|
|
2218 | tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); |
|
|
2219 | |
|
|
2220 | $BUTTONBAR->add (new CFPlus::UI::Button |
|
|
2221 | text => "Save Config", |
|
|
2222 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
|
|
2223 | on_activate => sub { |
|
|
2224 | $::CFG->{layout} = CFPlus::UI::get_layout; |
|
|
2225 | CFPlus::write_cfg "$Crossfire::VARDIR/cfplusrc"; |
|
|
2226 | status "Configuration Saved"; |
|
|
2227 | 0 |
|
|
2228 | }, |
|
|
2229 | ); |
|
|
2230 | |
|
|
2231 | $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, |
|
|
2232 | tooltip => "View Documentation"); |
|
|
2233 | |
|
|
2234 | |
|
|
2235 | $BUTTONBAR->add (new CFPlus::UI::Button |
|
|
2236 | text => "Quit", |
|
|
2237 | tooltip => "Terminates the program", |
|
|
2238 | on_activate => sub { |
|
|
2239 | if ($CONN) { |
|
|
2240 | open_quit_dialog; |
|
|
2241 | } else { |
|
|
2242 | Event::unloop_all; |
|
|
2243 | } |
|
|
2244 | 0 |
|
|
2245 | }, |
|
|
2246 | ); |
|
|
2247 | |
|
|
2248 | $BUTTONBAR->show; |
|
|
2249 | $SETUP_DIALOG->show; |
2646 | $SETUP_DIALOG->show; |
2250 | $MESSAGE_WINDOW->show; |
2647 | $MESSAGE_WINDOW->show; |
2251 | } |
2648 | } |
2252 | |
2649 | |
|
|
2650 | $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]); |
|
|
2651 | $MODE_SLIDER->emit (changed => $CFG->{sdl_mode}); |
|
|
2652 | |
|
|
2653 | $CAVEAT_LABEL->set_text ("None :)"); |
|
|
2654 | $CAVEAT_LABEL->set_text ("Apple/NVIDIA Texture bug (slow)") |
|
|
2655 | if $DC::OpenGL::APPLE_NVIDIA_BUG; |
|
|
2656 | $CAVEAT_LABEL->set_text ("Software Rendering (very slow)") |
|
|
2657 | unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL; |
|
|
2658 | |
2253 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2659 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2254 | } |
2660 | } |
2255 | |
2661 | |
2256 | sub video_shutdown { |
2662 | sub video_shutdown { |
2257 | CFPlus::OpenGL::shutdown; |
2663 | DC::OpenGL::shutdown; |
|
|
2664 | DC::SDL_QuitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT; |
2258 | |
2665 | |
2259 | undef $SDL_ACTIVE; |
2666 | undef $SDL_ACTIVE; |
2260 | } |
2667 | } |
2261 | |
2668 | |
2262 | my %animate_object; |
2669 | my %animate_object; |
2263 | my $animate_timer; |
2670 | my $animate_timer; |
2264 | |
2671 | |
2265 | my $fps = 9; |
2672 | my $fps = 9; |
2266 | |
2673 | |
2267 | sub force_refresh { |
2674 | sub force_refresh { |
2268 | if ($ENV{CFPLUS_DEBUG} & 4) { |
2675 | if ($DELIANTRA_DEBUG & 4) { |
2269 | $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; |
2676 | $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; |
2270 | debug sprintf "%3.2f", $fps; |
2677 | debug sprintf "%3.2f", $fps; |
2271 | } |
2678 | } |
2272 | |
2679 | |
|
|
2680 | undef $WANT_REFRESH; |
|
|
2681 | $_[0]->stop; |
|
|
2682 | |
2273 | $CFPlus::UI::ROOT->draw; |
2683 | $DC::UI::ROOT->draw; |
2274 | CFPlus::SDL_GL_SwapBuffers; |
2684 | DC::SDL_GL_SwapBuffers; |
2275 | $LAST_REFRESH = $NOW; |
2685 | $LAST_REFRESH = $NOW; |
2276 | $WANT_REFRESH->stop; |
|
|
2277 | } |
2686 | } |
2278 | |
2687 | |
2279 | $WANT_REFRESH = Event->idle (min => 0.001, max => 0.06, parked => 1, cb => \&force_refresh); |
2688 | my $want_refresh = EV::prepare_ns \&force_refresh; |
2280 | |
2689 | |
2281 | my $input = Event->timer (after => 0, hard => 0, interval => 1 / 50, cb => sub { |
2690 | my $input = EV::periodic 0, 1 / $MAX_FPS, undef, sub { |
2282 | $NOW = time; |
2691 | $NOW = EV::now; |
2283 | |
2692 | |
2284 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
2693 | ($SDL_CB[$_->{type}] || sub { warn "unhandled event $_->{type}" })->($_) |
2285 | for CFPlus::poll_events; |
2694 | for DC::poll_events; |
2286 | |
2695 | |
2287 | if (%animate_object) { |
2696 | if (%animate_object) { |
2288 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2697 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
|
|
2698 | $WANT_REFRESH = 1; |
|
|
2699 | } |
|
|
2700 | |
|
|
2701 | $want_refresh->start |
2289 | $WANT_REFRESH->start; |
2702 | if $WANT_REFRESH; |
2290 | } |
|
|
2291 | }); |
2703 | }; |
2292 | |
2704 | |
2293 | sub animation_start { |
2705 | sub animation_start { |
2294 | my ($widget) = @_; |
2706 | my ($widget) = @_; |
2295 | $animate_object{$widget} = $widget; |
2707 | $animate_object{$widget} = $widget; |
2296 | } |
2708 | } |
… | |
… | |
2298 | sub animation_stop { |
2710 | sub animation_stop { |
2299 | my ($widget) = @_; |
2711 | my ($widget) = @_; |
2300 | delete $animate_object{$widget}; |
2712 | delete $animate_object{$widget}; |
2301 | } |
2713 | } |
2302 | |
2714 | |
2303 | %SDL_CB = ( |
2715 | $SDL_CB[DC::SDL_QUIT] = sub { |
2304 | CFPlus::SDL_QUIT => sub { |
2716 | crash "SDL_QUIT"; |
2305 | Event::unloop_all; |
2717 | EV::unloop EV::UNLOOP_ALL; |
2306 | }, |
2718 | }; |
2307 | CFPlus::SDL_VIDEORESIZE => sub { |
2719 | $SDL_CB[DC::SDL_VIDEORESIZE] = sub { }; |
2308 | }, |
2720 | $SDL_CB[DC::SDL_VIDEOEXPOSE] = sub { |
2309 | CFPlus::SDL_VIDEOEXPOSE => sub { |
|
|
2310 | CFPlus::UI::full_refresh; |
2721 | DC::UI::full_refresh; |
2311 | }, |
2722 | }; |
2312 | CFPlus::SDL_ACTIVEEVENT => sub { |
2723 | $SDL_CB[DC::SDL_ACTIVEEVENT] = sub { |
2313 | # not useful, as APPACTIVE include sonly iconified state, not unmapped |
2724 | # not useful, as APPACTIVE includes only iconified state, not unmapped |
2314 | # printf "active %x %x %x\n", $_[0]{gain}, $_[0]{state}, CFPlus::SDL_GetAppState;#d# |
2725 | # printf "active %x %x %x\n", $_[0]{gain}, $_[0]{state}, DC::SDL_GetAppState;#d# |
2315 | # printf "a %x\n", CFPlus::SDL_GetAppState & CFPlus::SDL_APPACTIVE;#d# |
2726 | # printf "a %x\n", DC::SDL_GetAppState & DC::SDL_APPACTIVE;#d# |
2316 | # printf "A\n" if $_[0]{state} & CFPlus::SDL_APPACTIVE; |
2727 | # printf "A\n" if $_[0]{state} & DC::SDL_APPACTIVE; |
2317 | # printf "K\n" if $_[0]{state} & CFPlus::SDL_APPINPUTFOCUS; |
2728 | # printf "K\n" if $_[0]{state} & DC::SDL_APPINPUTFOCUS; |
2318 | # printf "M\n" if $_[0]{state} & CFPlus::SDL_APPMOUSEFOCUS; |
2729 | # printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS; |
2319 | }, |
2730 | }; |
2320 | CFPlus::SDL_KEYDOWN => sub { |
2731 | $SDL_CB[DC::SDL_KEYDOWN] = sub { |
2321 | if ($_[0]{mod} & CFPlus::KMOD_ALT && $_[0]{sym} == 13) { |
2732 | if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) { |
2322 | # alt-enter |
2733 | # alt-enter |
|
|
2734 | video_shutdown; |
2323 | $FULLSCREEN_ENABLE->toggle; |
2735 | $FULLSCREEN_ENABLE->toggle; |
2324 | video_shutdown; |
|
|
2325 | video_init; |
2736 | video_init; |
|
|
2737 | } else { |
|
|
2738 | &DC::UI::feed_sdl_key_down_event; |
|
|
2739 | } |
|
|
2740 | update_modbox; |
|
|
2741 | }; |
|
|
2742 | $SDL_CB[DC::SDL_KEYUP] = sub { |
|
|
2743 | &DC::UI::feed_sdl_key_up_event; |
|
|
2744 | update_modbox; |
|
|
2745 | }; |
|
|
2746 | $SDL_CB[DC::SDL_MOUSEMOTION] = \&DC::UI::feed_sdl_motion_event, |
|
|
2747 | $SDL_CB[DC::SDL_MOUSEBUTTONDOWN] = \&DC::UI::feed_sdl_button_down_event, |
|
|
2748 | $SDL_CB[DC::SDL_MOUSEBUTTONUP] = \&DC::UI::feed_sdl_button_up_event, |
|
|
2749 | $SDL_CB[DC::SDL_USEREVENT] = sub { |
|
|
2750 | if ($_[0]{code} == 1) { |
|
|
2751 | audio_channel_finished $_[0]{data1}; |
|
|
2752 | } elsif ($_[0]{code} == 0) { |
|
|
2753 | audio_music_finished; |
|
|
2754 | } |
|
|
2755 | }; |
|
|
2756 | |
|
|
2757 | ############################################################################# |
|
|
2758 | |
|
|
2759 | $SIG{INT} = $SIG{TERM} = sub { |
|
|
2760 | EV::unloop; |
|
|
2761 | #d# TODO calling exit here hangs the process in some futex |
|
|
2762 | }; |
|
|
2763 | |
|
|
2764 | # due to mac os x + sdl combined braindamage, we need this contortion |
|
|
2765 | sub main { |
|
|
2766 | { |
|
|
2767 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
|
|
2768 | |
|
|
2769 | if (-e "$Deliantra::VARDIR/client.cf") { |
|
|
2770 | DC::read_cfg "$Deliantra::VARDIR/client.cf"; |
2326 | } else { |
2771 | } else { |
2327 | CFPlus::UI::feed_sdl_key_down_event ($_[0]); |
2772 | #TODO: compatibility cruft |
|
|
2773 | DC::read_cfg "$Deliantra::OLDDIR/cfplusrc"; |
|
|
2774 | print STDERR "INFO: used old configuration file\n"; |
2328 | } |
2775 | } |
2329 | }, |
|
|
2330 | CFPlus::SDL_KEYUP => \&CFPlus::UI::feed_sdl_key_up_event, |
|
|
2331 | CFPlus::SDL_MOUSEMOTION => \&CFPlus::UI::feed_sdl_motion_event, |
|
|
2332 | CFPlus::SDL_MOUSEBUTTONDOWN => \&CFPlus::UI::feed_sdl_button_down_event, |
|
|
2333 | CFPlus::SDL_MOUSEBUTTONUP => \&CFPlus::UI::feed_sdl_button_up_event, |
|
|
2334 | CFPlus::SDL_USEREVENT => sub { |
|
|
2335 | if ($_[0]{code} == 1) { |
|
|
2336 | audio_channel_finished $_[0]{data1}; |
|
|
2337 | } elsif ($_[0]{code} == 0) { |
|
|
2338 | audio_music_finished; |
|
|
2339 | } |
|
|
2340 | }, |
|
|
2341 | ); |
|
|
2342 | |
2776 | |
2343 | ############################################################################# |
|
|
2344 | |
|
|
2345 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
|
|
2346 | |
|
|
2347 | { |
|
|
2348 | CFPlus::read_cfg "$Crossfire::VARDIR/cfplusrc"; |
|
|
2349 | CFPlus::DB::Server::run; |
2777 | DC::DB::Server::run; |
2350 | |
2778 | |
|
|
2779 | if ($CFG->{db_schema} < 1) { |
|
|
2780 | warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; |
|
|
2781 | DC::DB::nuke_db; |
|
|
2782 | $CFG->{db_schema} = 1; |
|
|
2783 | DC::write_cfg; |
|
|
2784 | } |
|
|
2785 | |
|
|
2786 | DC::DB::open_db; |
|
|
2787 | |
2351 | CFPlus::UI::set_layout ($::CFG->{layout}); |
2788 | DC::UI::set_layout ($::CFG->{layout}); |
2352 | |
2789 | |
2353 | my %DEF_CFG = ( |
2790 | my %DEF_CFG = ( |
|
|
2791 | config_autosave => 1, |
2354 | sdl_mode => 0, |
2792 | sdl_mode => undef, |
2355 | fullscreen => 0, |
2793 | fullscreen => 1, |
2356 | fast => 0, |
2794 | fast => 0, |
2357 | force_opengl11 => undef, |
2795 | force_opengl11 => undef, |
|
|
2796 | disable_alpha => 0, |
|
|
2797 | smooth_movement => 1, |
|
|
2798 | smooth_transitions => 1, |
2358 | texture_compression => 1, |
2799 | texture_compression => 1, |
2359 | map_scale => 1, |
2800 | map_scale => 1, |
2360 | fow_enable => 1, |
2801 | fow_enable => 1, |
2361 | fow_intensity => 0, |
2802 | fow_intensity => 0, |
|
|
2803 | fow_texture => 0, |
2362 | map_smoothing => 1, |
2804 | map_smoothing => 1, |
2363 | gui_fontsize => 1, |
2805 | gui_fontsize => 1, |
2364 | log_fontsize => 0.7, |
2806 | log_fontsize => 0.7, |
2365 | gauge_fontsize => 1, |
2807 | gauge_fontsize => 1, |
2366 | gauge_size => 0.35, |
2808 | gauge_size => 0.35, |
2367 | stat_fontsize => 0.7, |
2809 | stat_fontsize => 0.7, |
2368 | mapsize => 100, |
2810 | mapsize => 100, |
2369 | audio_enable => 1, |
2811 | audio_enable => 1, |
2370 | audio_hw_channels => 0, |
2812 | audio_hw_channels => 0, |
2371 | audio_hw_frequency => 0, |
2813 | audio_hw_frequency => 0, |
2372 | audio_hw_chunksize => 0, |
2814 | audio_hw_chunksize => 0, |
2373 | audio_mix_channels => 8, |
2815 | audio_mix_channels => 8, |
2374 | effects_enable => 1, |
2816 | effects_enable => 1, |
2375 | effects_volume => 1, |
2817 | effects_volume => 1, |
2376 | bgm_enable => 1, |
2818 | bgm_enable => 1, |
2377 | bgm_volume => 0.5, |
2819 | bgm_volume => 0.5, |
2378 | output_rate => "", |
2820 | output_rate => "", |
2379 | pickup => 0, |
2821 | pickup => PICKUP_SPELLBOOK | PICKUP_SKILLSCROLL | PICKUP_VALUABLES, |
2380 | inv_sort => "mtime", |
2822 | inv_sort => "mtime", |
2381 | default => "profile", # default profile |
2823 | default => "profile", # default profile |
2382 | show_tips => 1, |
2824 | show_tips => 1, |
2383 | logview_max_par => 1000, |
2825 | logview_max_par => 1000, |
|
|
2826 | shift_fire_stop => 0, |
|
|
2827 | uitheme => "wood", |
|
|
2828 | map_shift_x => -24, # arbitrary |
|
|
2829 | map_shift_y => +24, # arbitrary |
2384 | ); |
2830 | ); |
2385 | |
2831 | |
2386 | while (my ($k, $v) = each %DEF_CFG) { |
2832 | while (my ($k, $v) = each %DEF_CFG) { |
2387 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2833 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2388 | } |
2834 | } |
2389 | |
2835 | |
2390 | $CFG->{profile}{default}{host} ||= "gameserver.deliantra.net"; |
2836 | my @args = @ARGV; |
2391 | $PROFILE = $CFG->{profile}{default}; |
|
|
2392 | |
2837 | |
2393 | # convert old bindings (only default profile matters) |
2838 | # OS X passes some process serial number of other shit. they |
2394 | if (my $bindings = delete $PROFILE->{bindings}) { |
2839 | # could have used an env var or any other sane mechanism. but |
2395 | while (my ($mod, $syms) = each %$bindings) { |
2840 | # would it be os x then? no... |
2396 | while (my ($sym, $cmds) = each %$syms) { |
2841 | shift @args if $args[0] =~ /^-psn_/; |
2397 | push @{ $PROFILE->{macro} }, { |
2842 | |
2398 | accelkey => [$mod*1, $sym*1], |
2843 | my $profile = 'default'; |
2399 | action => $cmds, |
2844 | |
|
|
2845 | for (my $i = 0; $i < @args; $i++) { |
|
|
2846 | if ($args[$i] =~ /^--?profile$/) { |
|
|
2847 | $profile = $args[$i + 1]; |
|
|
2848 | splice @args, $i, 2, (); |
2400 | }; |
2849 | $i = 0; |
|
|
2850 | } elsif ($args[$i] =~ /^--?h/) { |
|
|
2851 | print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n"; |
|
|
2852 | exit 0; |
2401 | } |
2853 | } |
2402 | } |
2854 | } |
2403 | } |
|
|
2404 | |
2855 | |
2405 | sdl_init; |
2856 | $CFG->{profile}{$profile} ||= {}; |
|
|
2857 | $PROFILE = $CFG->{profile}{$profile}; |
|
|
2858 | $PROFILE->{host} ||= "gameserver.deliantra.net"; |
2406 | |
2859 | |
2407 | @SDL_MODES = CFPlus::SDL_ListModes 8, 8; |
2860 | $PROFILE->{host} = $args[0] if @args > 0; |
2408 | @SDL_MODES = CFPlus::SDL_ListModes 5, 0 unless @SDL_MODES; |
2861 | $PROFILE->{user} = $args[1] if @args > 1; |
2409 | @SDL_MODES or CFPlus::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
2862 | $PROFILE->{password} = $args[2] if @args > 2; |
2410 | |
2863 | |
2411 | @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES; |
2864 | # convert old bindings (only default profile matters) |
|
|
2865 | if (my $bindings = delete $PROFILE->{bindings}) { |
|
|
2866 | while (my ($mod, $syms) = each %$bindings) { |
|
|
2867 | while (my ($sym, $cmds) = each %$syms) { |
|
|
2868 | push @{ $PROFILE->{macro} }, { |
|
|
2869 | accelkey => [$mod*1, $sym*1], |
|
|
2870 | action => $cmds, |
|
|
2871 | }; |
|
|
2872 | } |
|
|
2873 | } |
|
|
2874 | } |
2412 | |
2875 | |
2413 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
2876 | $ENV{FONTCONFIG_FILE} = DC::find_rcfile "fonts/fonts.conf"; |
|
|
2877 | $ENV{FONTCONFIG_DIR} = DC::find_rcfile "fonts"; |
2414 | |
2878 | |
2415 | { |
2879 | { |
2416 | my @fonts = map CFPlus::find_rcfile "fonts/$_", qw( |
2880 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
2417 | DejaVuSans.ttf |
2881 | DejaVuSans.ttf |
2418 | DejaVuSansMono.ttf |
2882 | DejaVuSansMono.ttf |
2419 | DejaVuSans-Bold.ttf |
2883 | DejaVuSans-Bold.ttf |
2420 | DejaVuSansMono-Bold.ttf |
2884 | DejaVuSansMono-Bold.ttf |
2421 | DejaVuSans-Oblique.ttf |
2885 | DejaVuSans-Oblique.ttf |
2422 | DejaVuSansMono-Oblique.ttf |
2886 | DejaVuSansMono-Oblique.ttf |
2423 | DejaVuSans-BoldOblique.ttf |
2887 | DejaVuSans-BoldOblique.ttf |
2424 | DejaVuSansMono-BoldOblique.ttf |
2888 | DejaVuSansMono-BoldOblique.ttf |
|
|
2889 | mona.ttf |
2425 | ); |
2890 | ); |
2426 | |
2891 | |
2427 | CFPlus::add_font $_ for @fonts; |
2892 | DC::add_font $_ for @fonts; |
2428 | |
|
|
2429 | CFPlus::pango_init; |
|
|
2430 | |
2893 | |
2431 | $FONT_PROP = new_from_file CFPlus::Font $fonts[0]; |
2894 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2432 | $FONT_FIXED = new_from_file CFPlus::Font $fonts[1]; |
2895 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2433 | |
2896 | |
2434 | $FONT_PROP->make_default; |
2897 | $FONT_PROP->make_default; |
2435 | } |
2898 | |
|
|
2899 | DC::pango_init; |
|
|
2900 | } |
2436 | |
2901 | |
2437 | # compare mono (ft) vs. rgba (cairo) |
2902 | # compare mono (ft) vs. rgba (cairo) |
2438 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
2903 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
2439 | # for my $rgba (0..1) { |
2904 | # for my $rgba (0..1) { |
2440 | # my $t1 = Time::HiRes::time; |
2905 | # my $t1 = Time::HiRes::time; |
2441 | # for (1..1000) { |
2906 | # for (1..1000) { |
2442 | # my $layout = CFPlus::Layout->new ($rgba); |
2907 | # my $layout = DC::Layout->new ($rgba); |
2443 | # $layout->set_text ("hallo" x 100); |
2908 | # $layout->set_text ("hallo" x 100); |
2444 | # $layout->render; |
2909 | # $layout->render; |
2445 | # } |
2910 | # } |
2446 | # my $t2 = Time::HiRes::time; |
2911 | # my $t2 = Time::HiRes::time; |
2447 | # warn $t2-$t1; |
2912 | # warn $t2-$t1; |
2448 | # } |
2913 | # } |
2449 | |
2914 | |
2450 | video_init; |
2915 | DC::IMG_Init; video_init; |
2451 | audio_init; |
2916 | DC::Mix_Init; audio_init; |
2452 | } |
2917 | } |
2453 | |
2918 | |
2454 | show_tip_of_the_day if $CFG->{show_tips}; |
2919 | show_tip_of_the_day if $CFG->{show_tips}; |
2455 | |
2920 | |
2456 | Event->idle (cb => sub { |
2921 | our $STARTUP_CANCEL = EV::idle sub { |
2457 | $_[0]->w->cancel; |
2922 | undef $::STARTUP_CANCEL; |
2458 | $startup_done->(); |
2923 | $startup_done->(); |
2459 | }); |
2924 | }; |
2460 | |
2925 | |
2461 | Event::loop; |
2926 | debug_toggle 0; |
2462 | |
2927 | |
|
|
2928 | delete $SIG{__DIE__}; |
|
|
2929 | EV::loop; |
|
|
2930 | |
|
|
2931 | DC::write_cfg if $CFG->{config_autosave}; |
|
|
2932 | |
2463 | #video_shutdown; |
2933 | #video_shutdown; |
2464 | #audio_shutdown; |
2934 | #audio_shutdown; |
2465 | CFPlus::SDL_Quit; |
2935 | |
|
|
2936 | DC::OpenGL::quit; |
|
|
2937 | DC::SDL_Quit; |
2466 | CFPlus::DB::Server::stop; |
2938 | DC::DB::Server::stop; |
|
|
2939 | } |
|
|
2940 | |
|
|
2941 | DC::SDL_braino; # see sub above |
2467 | |
2942 | |
2468 | =head1 NAME |
2943 | =head1 NAME |
2469 | |
2944 | |
2470 | deliantra - A Deliantra MORPG game client |
2945 | deliantra - A Deliantra MORPG game client |
2471 | |
2946 | |
2472 | =head1 SYNOPSIS |
2947 | =head1 SYNOPSIS |
2473 | |
2948 | |
2474 | Just run it - no commandline arguments are supported. |
2949 | deliantra [--profile name] [host [user [password]]] |
|
|
2950 | deliantra --help |
2475 | |
2951 | |
2476 | =head1 USAGE |
2952 | =head1 USAGE |
2477 | |
2953 | |
2478 | deliantra utilises OpenGL for all UI elements and the game. It is supposed to |
2954 | The deliantra client utilises OpenGL for all UI elements and the game. It |
2479 | be used in fullscreen mode and interactively. |
2955 | is supposed to be used in fullscreen mode and interactively. |
2480 | |
2956 | |
2481 | =head1 DEBUGGING |
2957 | =head1 DEBUGGING |
2482 | |
2958 | |
2483 | |
|
|
2484 | CFPLUS_DEBUG - environment variable |
2959 | DELIANTRA_DEBUG - environment variable |
2485 | |
2960 | |
2486 | 1 draw borders around widgets |
2961 | 1 draw borders around widgets |
2487 | 2 add low-level widget info to tooltips |
2962 | 2 add low-level widget info to tooltips |
2488 | 4 show fps |
2963 | 4 show fps |
2489 | 8 suppress tooltips |
2964 | 8 suppress tooltips |
|
|
2965 | 16 show bandwidth downstream |
2490 | |
2966 | |
2491 | =head1 AUTHOR |
2967 | =head1 AUTHOR |
2492 | |
2968 | |
2493 | Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org> |
2969 | Marc Lehmann <deliantra@schmorp.de>, Robin Redeker <elmex@ta-sa.org> |
2494 | |
2970 | |
2495 | |
2971 | |
2496 | |
2972 | |