… | |
… | |
16 | while (my ($filename, $zip) = each %PAR::LibCache) { |
16 | while (my ($filename, $zip) = each %PAR::LibCache) { |
17 | $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp"); |
17 | $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp"); |
18 | } |
18 | } |
19 | |
19 | |
20 | require Win32::GUI::SplashScreen; |
20 | require Win32::GUI::SplashScreen; |
|
|
21 | |
|
|
22 | # initialise the resolver now, as vista forces us back to the desktop |
|
|
23 | # when doing this. |
|
|
24 | use AnyEvent::DNS (); |
|
|
25 | AnyEvent::DNS::resolver; |
21 | |
26 | |
22 | Win32::GUI::SplashScreen::Show ( |
27 | Win32::GUI::SplashScreen::Show ( |
23 | -file => "$ENV{PAR_TEMP}/SPLASH.bmp", |
28 | -file => "$ENV{PAR_TEMP}/SPLASH.bmp", |
24 | ); |
29 | ); |
25 | |
30 | |
… | |
… | |
86 | |
91 | |
87 | use Deliantra; |
92 | use Deliantra; |
88 | use Deliantra::Protocol::Constants; |
93 | use Deliantra::Protocol::Constants; |
89 | |
94 | |
90 | use AnyEvent::Util (); |
95 | use AnyEvent::Util (); |
91 | use AnyEvent::DNS; |
|
|
92 | use AnyEvent::Socket (); |
96 | use AnyEvent::Socket (); |
|
|
97 | use AnyEvent::DNS (); |
93 | |
98 | |
94 | use Compress::LZF; |
99 | use Compress::LZF; |
95 | use JSON::XS; |
100 | use JSON::XS; |
96 | |
101 | |
97 | use DC; |
102 | use DC; |
… | |
… | |
125 | |
130 | |
126 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
131 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
127 | $SIG{PIPE} = 'IGNORE'; |
132 | $SIG{PIPE} = 'IGNORE'; |
128 | |
133 | |
129 | $EV::DIED = sub { |
134 | $EV::DIED = sub { |
130 | crash "CRASH/EV::DIED: $@" => 1; |
135 | crash "CRASH/EV::DIED: $@" => 0; |
131 | DC::fatal Carp::longmess $@; |
136 | DC::fatal Carp::longmess $@; |
132 | }; |
137 | }; |
133 | |
138 | |
134 | my $MAX_FPS = 60; |
139 | my $MAX_FPS = 60; |
135 | |
140 | |
… | |
… | |
161 | |
166 | |
162 | our $MAP; |
167 | our $MAP; |
163 | our $MAPMAP; |
168 | our $MAPMAP; |
164 | our $MAPWIDGET; |
169 | our $MAPWIDGET; |
165 | our $COMPLETER; |
170 | our $COMPLETER; |
166 | our $BUTTONBAR; |
171 | our $MENUFRAME; # the rectangle at the top |
|
|
172 | our $MENUBAR; # the hbox at the top |
|
|
173 | our $MENUPOPUP; |
|
|
174 | our $BUTTONBAR; # the menu buttons |
167 | our $METASERVER; |
175 | our $METASERVER; |
168 | our $LOGIN_BUTTON; |
176 | our $LOGIN_BUTTON; |
169 | our $QUIT_DIALOG; |
177 | our $QUIT_DIALOG; |
170 | our $HOST_ENTRY; |
178 | our $HOST_ENTRY; |
171 | our $FULLSCREEN_ENABLE; |
179 | our $FULLSCREEN_ENABLE; |
… | |
… | |
215 | # write a crash message blockingly to the socket, if possible |
223 | # write a crash message blockingly to the socket, if possible |
216 | # this is a bit too complicated for my tastes, but it was easy. |
224 | # this is a bit too complicated for my tastes, but it was easy. |
217 | *crash = sub($;$) { |
225 | *crash = sub($;$) { |
218 | my ($msg, $backtrace) = @_; |
226 | my ($msg, $backtrace) = @_; |
219 | |
227 | |
|
|
228 | warn $msg; |
|
|
229 | |
220 | return unless $CONN; |
230 | return unless $CONN; |
221 | |
231 | |
222 | my $fh = $CONN->{fh} |
232 | my $fh = $CONN->{fh} |
223 | or return; |
233 | or return; |
224 | |
234 | |
… | |
… | |
234 | |
244 | |
235 | # backtrace as second step, in case it crashes, too |
245 | # backtrace as second step, in case it crashes, too |
236 | crash Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated" |
246 | crash Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated" |
237 | if $backtrace; |
247 | if $backtrace; |
238 | }; |
248 | }; |
|
|
249 | |
|
|
250 | sub clienterror($;$) { |
|
|
251 | my ($msg, $backtrace) = @_; |
|
|
252 | |
|
|
253 | warn $msg; |
|
|
254 | |
|
|
255 | return unless $CONN; |
|
|
256 | |
|
|
257 | $CONN->send_exti_msg (clientlog => $msg); |
|
|
258 | $CONN->send_exti_msg (clientlog => Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated") if $backtrace; |
|
|
259 | } |
239 | |
260 | |
240 | ############################################################################# |
261 | ############################################################################# |
241 | |
262 | |
242 | sub status { |
263 | sub status { |
243 | $STATUSBOX->add (DC::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
264 | $STATUSBOX->add (DC::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
… | |
… | |
325 | or return; |
346 | or return; |
326 | |
347 | |
327 | $meta->{data} |
348 | $meta->{data} |
328 | or return; |
349 | or return; |
329 | |
350 | |
330 | # if its a jingle, play it as ambient music |
351 | # if it's a jingle, play it as ambient music |
331 | if ($meta->{data}{jingle}) { |
352 | if ($meta->{data}{jingle}) { |
332 | if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue |
353 | if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue |
333 | push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue |
354 | push @MUSIC_JINGLE, $meta; # push it unto the music/jingle queue |
334 | &audio_music_push ($face); |
355 | &audio_music_push ($face); |
335 | } |
356 | } |
336 | } else { |
357 | } else { |
337 | # fetch from database |
358 | # fetch from database |
338 | DC::DB::get res_data => $meta->{name}, sub { |
359 | DC::DB::get res_data => $meta->{name}, sub { |
339 | my $rwops = new DC::RW $_[0]; |
360 | my $rwops = new DC::RW $_[0]; |
340 | my $chunk = new DC::MixChunk $rwops |
361 | my $chunk = new DC::MixChunk $rwops |
341 | or Carp::confess "sound face " . (JSON::XS::encode_json $meta) . " unloadable: " . DC::Mix_GetError; |
362 | or Carp::confess "sound face " . (JSON::XS::encode_json $meta) . " (" . (unpack "H64", $_[0]) . ") unloadable: " . DC::Mix_GetError; |
342 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
363 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
343 | $AUDIO_CHUNK{$face} = $chunk; |
364 | $AUDIO_CHUNK{$face} = $chunk; |
344 | |
365 | |
345 | audio_sound_push ($face); |
366 | audio_sound_push ($face); |
346 | }; |
367 | }; |
… | |
… | |
393 | |
414 | |
394 | audio_music_update_volume; |
415 | audio_music_update_volume; |
395 | |
416 | |
396 | $MUSIC_PLAYING_DATA = \$_[0]; |
417 | $MUSIC_PLAYING_DATA = \$_[0]; |
397 | |
418 | |
|
|
419 | $meta->{path} or length $_[0] |
|
|
420 | or return clienterror "empty music face from res_data ($meta->{face})";#d# |
|
|
421 | |
398 | my $rwops = $meta->{path} |
422 | my $rwops = $meta->{path} |
399 | ? new_from_file DC::RW $meta->{path} |
423 | ? (new_from_file DC::RW $meta->{path} or return clienterror "unable to load music face $meta->{path}: $!")#d#clienterror |
400 | : new DC::RW $$MUSIC_PLAYING_DATA; |
424 | : new DC::RW $$MUSIC_PLAYING_DATA; |
401 | |
425 | |
402 | $MUSIC_PLAYER = new DC::MixMusic $rwops |
426 | $MUSIC_PLAYER = new DC::MixMusic $rwops |
403 | or Carp::confess "music face $meta->{face} unloadable: " . DC::Mix_GetError; |
427 | or return clienterror "music face $meta->{face} unloadable: " . DC::Mix_GetError => 1; |
404 | |
428 | |
405 | my $NOW = time; |
429 | my $NOW = time; |
406 | |
430 | |
407 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
431 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
408 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
432 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
… | |
… | |
897 | |
921 | |
898 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Video Mode"); |
922 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Video Mode"); |
899 | $table->add_at (1, $row++, my $hbox = new DC::UI::HBox); |
923 | $table->add_at (1, $row++, my $hbox = new DC::UI::HBox); |
900 | |
924 | |
901 | $hbox->add ($MODE_SLIDER = new DC::UI::Slider |
925 | $hbox->add ($MODE_SLIDER = new DC::UI::Slider |
|
|
926 | c_rescale => 1, |
902 | force_w => $WIDTH * 0.1, expand => 1, |
927 | force_w => $WIDTH * 0.1, expand => 1, |
903 | range => [ ($CFG->{sdl_mode}) x 3 ], |
928 | range => [ ($CFG->{sdl_mode}) x 3 ], |
904 | tooltip => $vidmode_tooltip); |
929 | tooltip => $vidmode_tooltip); |
905 | $hbox->add (my $mode_label = new DC::UI::Label |
930 | $hbox->add (my $mode_label = new DC::UI::Label |
906 | height => 0.8, template => "9999x9999@9+9", |
931 | height => 0.8, template => "9999x9999@9+9", |
… | |
… | |
1230 | } |
1255 | } |
1231 | |
1256 | |
1232 | sub make_gauge_window { |
1257 | sub make_gauge_window { |
1233 | my $gh = int $HEIGHT * $CFG->{gauge_size}; |
1258 | my $gh = int $HEIGHT * $CFG->{gauge_size}; |
1234 | |
1259 | |
1235 | my $win = new DC::UI::Frame ( |
1260 | $GAUGES->{win} = my $win = new DC::UI::Frame ( |
1236 | force_x => 0, |
1261 | force_x => 0, |
1237 | force_y => "max", |
1262 | force_y => "max", |
1238 | force_w => $WIDTH, |
1263 | force_w => $WIDTH, |
1239 | force_h => $gh, |
1264 | force_h => $gh, |
1240 | ); |
1265 | ); |
… | |
… | |
1256 | (new DC::UI::Empty expand => 1), |
1281 | (new DC::UI::Empty expand => 1), |
1257 | (my $hb = new DC::UI::HBox), |
1282 | (my $hb = new DC::UI::HBox), |
1258 | ], |
1283 | ], |
1259 | ); |
1284 | ); |
1260 | |
1285 | |
1261 | $hb->add (my $hg = new DC::UI::Gauge type => 'hp', tooltip => "#stat_health"); |
1286 | $hb->add ($GAUGES->{hp} = new DC::UI::Gauge type => 'hp', tooltip => "#stat_health"); |
1262 | $hb->add (my $mg = new DC::UI::Gauge type => 'mana', tooltip => "#stat_mana"); |
1287 | $hb->add ($GAUGES->{mana} = new DC::UI::Gauge type => 'mana', tooltip => "#stat_mana"); |
1263 | $hb->add (my $gg = new DC::UI::Gauge type => 'grace', tooltip => "#stat_grace"); |
1288 | $hb->add ($GAUGES->{grace} = new DC::UI::Gauge type => 'grace', tooltip => "#stat_grace"); |
1264 | $hb->add (my $fg = new DC::UI::Gauge type => 'food', tooltip => "#stat_food"); |
1289 | $hb->add ($GAUGES->{food} = new DC::UI::Gauge type => 'food', tooltip => "#stat_food"); |
1265 | |
|
|
1266 | $vbox->add (my $exp = new DC::UI::Label align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); |
|
|
1267 | $vbox->add (my $prg = new DC::UI::ExperienceProgress); |
|
|
1268 | $vbox->add (my $sklprg = new DC::UI::ExperienceProgress); |
|
|
1269 | $vbox->add (my $rng = new DC::UI::Label align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); |
|
|
1270 | |
|
|
1271 | $GAUGES = { |
|
|
1272 | exp => $exp, prg => $prg, sklprg => $sklprg, |
|
|
1273 | win => $win, range => $rng, |
|
|
1274 | hp => $hg, mana => $mg, grace => $gg, food => $fg, |
|
|
1275 | }; |
|
|
1276 | |
1290 | |
1277 | &set_gauge_window_fontsize; |
1291 | &set_gauge_window_fontsize; |
1278 | |
1292 | |
1279 | $win |
1293 | $win |
1280 | } |
1294 | } |
… | |
… | |
1734 | |
1748 | |
1735 | my $row = 0; |
1749 | my $row = 0; |
1736 | |
1750 | |
1737 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Tip of the day"); |
1751 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Tip of the day"); |
1738 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1752 | $table->add_at (1, $row++, new DC::UI::CheckBox |
|
|
1753 | c_colspan => 2, |
1739 | state => $CFG->{show_tips}, |
1754 | state => $CFG->{show_tips}, |
1740 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1755 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1741 | on_changed => sub { |
1756 | on_changed => sub { |
1742 | my ($self, $value) = @_; |
1757 | my ($self, $value) = @_; |
1743 | $CFG->{show_tips} = $value; |
1758 | $CFG->{show_tips} = $value; |
… | |
… | |
1745 | } |
1760 | } |
1746 | ); |
1761 | ); |
1747 | |
1762 | |
1748 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Window Size"); |
1763 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Window Size"); |
1749 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
1764 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
|
|
1765 | c_colspan => 2, |
1750 | text => $CFG->{logview_max_par}, |
1766 | text => $CFG->{logview_max_par}, |
1751 | tooltip => "This is maximum number of messages remembered in the <b>Message</b> window. If the server " |
1767 | tooltip => "This is maximum number of messages remembered in the <b>Message</b> window. If the server " |
1752 | . "sends more messages than this number, older messages get removed to save memory and " |
1768 | . "sends more messages than this number, older messages get removed to save memory and " |
1753 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1769 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1754 | on_changed => sub { |
1770 | on_changed => sub { |
1755 | my ($self, $value) = @_; |
1771 | my ($self, $value) = @_; |
1756 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
1772 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
1757 | 0 |
1773 | 0 |
1758 | }, |
1774 | }, |
|
|
1775 | ); |
|
|
1776 | |
|
|
1777 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Config Autosave"); |
|
|
1778 | $table->add_at (1, $row, new DC::UI::CheckBox |
|
|
1779 | state => $CFG->{config_autosave}, |
|
|
1780 | tooltip => "Normally, configuration settings and the user interface layout " |
|
|
1781 | . "are saved on client exit. You can disable this behaviour by " |
|
|
1782 | . "unchecking this checkbox.", |
|
|
1783 | on_changed => sub { |
|
|
1784 | my ($self, $value) = @_; |
|
|
1785 | $CFG->{config_autosave} = $value; |
|
|
1786 | 0 |
|
|
1787 | } |
|
|
1788 | ); |
|
|
1789 | $table->add_at (2, $row++, new DC::UI::Button |
|
|
1790 | text => "Save Now", |
|
|
1791 | tooltip => "Use this to manually save configuration and UI layout when " |
|
|
1792 | . "autosave is disabled.", |
|
|
1793 | on_activate => sub { |
|
|
1794 | DC::write_cfg; |
|
|
1795 | 0 |
|
|
1796 | } |
1759 | ); |
1797 | ); |
1760 | |
1798 | |
1761 | $table |
1799 | $table |
1762 | } |
1800 | } |
1763 | |
1801 | |
… | |
… | |
1980 | $PL_NOTEBOOK->set_current_page ($widget); |
2018 | $PL_NOTEBOOK->set_current_page ($widget); |
1981 | $PL_WINDOW->show; |
2019 | $PL_WINDOW->show; |
1982 | } |
2020 | } |
1983 | } |
2021 | } |
1984 | |
2022 | |
1985 | sub player_window { |
2023 | sub make_playerbook { |
1986 | my $plwin = $PL_WINDOW = new DC::UI::Toplevel |
2024 | my $plwin = $PL_WINDOW = new DC::UI::Toplevel |
1987 | x => "center", |
2025 | x => "center", |
1988 | y => "center", |
2026 | y => "center", |
1989 | force_w => $WIDTH * 9/10, |
2027 | force_w => $WIDTH * 9/10, |
1990 | force_h => $HEIGHT * 9/10, |
2028 | force_h => $HEIGHT * 9/10, |
… | |
… | |
2024 | "License, Author and Source info for media sent by the server."); |
2062 | "License, Author and Source info for media sent by the server."); |
2025 | |
2063 | |
2026 | $ntb->set_current_page ($INVENTORY_PAGE); |
2064 | $ntb->set_current_page ($INVENTORY_PAGE); |
2027 | |
2065 | |
2028 | $plwin->add ($ntb); |
2066 | $plwin->add ($ntb); |
2029 | $plwin |
|
|
2030 | } |
2067 | } |
2031 | |
2068 | |
2032 | sub keyboard_setup { |
2069 | sub keyboard_setup { |
2033 | DC::Macro::keyboard_setup |
2070 | DC::Macro::keyboard_setup |
2034 | } |
2071 | } |
… | |
… | |
2131 | $load_node->((DC::Pod::find @path)[0]); |
2168 | $load_node->((DC::Pod::find @path)[0]); |
2132 | $win->show; |
2169 | $win->show; |
2133 | }; |
2170 | }; |
2134 | |
2171 | |
2135 | $win |
2172 | $win |
2136 | } |
|
|
2137 | |
|
|
2138 | sub open_string_query { |
|
|
2139 | my ($title, $cb, $txt, $tooltip) = @_; |
|
|
2140 | my $dialog = new DC::UI::Toplevel |
|
|
2141 | x => "center", |
|
|
2142 | y => "center", |
|
|
2143 | z => 50, |
|
|
2144 | force_w => $WIDTH * 4/5, |
|
|
2145 | title => $title; |
|
|
2146 | |
|
|
2147 | $dialog->add ( |
|
|
2148 | my $e = new DC::UI::Entry |
|
|
2149 | on_activate => sub { $cb->(@_); $dialog->hide; 0 }, |
|
|
2150 | on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 }, |
|
|
2151 | tooltip => $tooltip |
|
|
2152 | ); |
|
|
2153 | |
|
|
2154 | $e->grab_focus; |
|
|
2155 | $e->set_text ($txt) if $txt; |
|
|
2156 | $dialog->show; |
|
|
2157 | } |
2173 | } |
2158 | |
2174 | |
2159 | sub open_quit_dialog { |
2175 | sub open_quit_dialog { |
2160 | unless ($QUIT_DIALOG) { |
2176 | unless ($QUIT_DIALOG) { |
2161 | $QUIT_DIALOG = new DC::UI::Toplevel |
2177 | $QUIT_DIALOG = new DC::UI::Toplevel |
… | |
… | |
2194 | |
2210 | |
2195 | $QUIT_DIALOG->show; |
2211 | $QUIT_DIALOG->show; |
2196 | $QUIT_DIALOG->grab_focus; |
2212 | $QUIT_DIALOG->grab_focus; |
2197 | } |
2213 | } |
2198 | |
2214 | |
|
|
2215 | sub make_menuframe { |
|
|
2216 | $MENUFRAME = new DC::UI::Toplevel |
|
|
2217 | border => 0, |
|
|
2218 | force_x => 0, |
|
|
2219 | force_y => 0, |
|
|
2220 | force_w => $::WIDTH, |
|
|
2221 | child => ($MENUBAR = new DC::UI::HBox), |
|
|
2222 | ; |
|
|
2223 | |
|
|
2224 | $MENUBAR->add ($BUTTONBAR = new DC::UI::Buttonbar); |
|
|
2225 | |
|
|
2226 | # 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 |
|
|
2227 | make_gauge_window->show; |
|
|
2228 | |
|
|
2229 | # $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
|
|
2230 | # tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
|
|
2231 | |
|
|
2232 | make_playerbook; |
|
|
2233 | |
|
|
2234 | $MENUPOPUP = DC::UI::Menu->new (items => [ |
|
|
2235 | ["Setup…" , sub { $SETUP_DIALOG->toggle_visibility}], |
|
|
2236 | ["Playerbook…\tTab", sub { $PL_WINDOW ->toggle_visibility}], |
|
|
2237 | ["Help Browser…" , sub { $HELP_WINDOW ->toggle_visibility}], |
|
|
2238 | ["Quit…" , sub { |
|
|
2239 | if ($CONN) { |
|
|
2240 | open_quit_dialog; |
|
|
2241 | } else { |
|
|
2242 | EV::unloop EV::UNLOOP_ALL; |
|
|
2243 | } |
|
|
2244 | }], |
|
|
2245 | ]); |
|
|
2246 | |
|
|
2247 | $BUTTONBAR->add (new DC::UI::Button text => "Menu…", |
|
|
2248 | tooltip => "Shows the main menu", |
|
|
2249 | on_button_down => sub { $MENUPOPUP->popup ($_[1]) }, |
|
|
2250 | ); |
|
|
2251 | |
|
|
2252 | $MENUBAR->add ($GAUGES->{prg} = new DC::UI::ExperienceProgress |
|
|
2253 | c_rescale => 1, |
|
|
2254 | padding_x => 6, |
|
|
2255 | padding_y => 3, |
|
|
2256 | force_w => $::WIDTH * 0.1, |
|
|
2257 | tooltip => "This progress bar shows your progress towards the next character level.", |
|
|
2258 | ); |
|
|
2259 | $MENUBAR->add ($GAUGES->{exp} = new DC::UI::Label |
|
|
2260 | align => 1, can_hover => 1, can_events => 1, |
|
|
2261 | text => "Total Experience", |
|
|
2262 | tooltip => "#stat_exp", |
|
|
2263 | fontsize => 0.8, |
|
|
2264 | ); |
|
|
2265 | $MENUBAR->add ($GAUGES->{sklprg} = new DC::UI::ExperienceProgress |
|
|
2266 | c_rescale => 1, |
|
|
2267 | padding_x => 6, |
|
|
2268 | padding_y => 3, |
|
|
2269 | force_w => $::WIDTH * 0.2, |
|
|
2270 | tooltip => "This progress bar shows the currently used skill and your progress towards the next skill level of that skill.", |
|
|
2271 | ); |
|
|
2272 | $MENUBAR->add ($GAUGES->{range} = new DC::UI::Label |
|
|
2273 | expand => 1, |
|
|
2274 | align => 1, can_hover => 1, can_events => 1, |
|
|
2275 | text => "Range and Combat Slots", |
|
|
2276 | tooltip => "#stat_ranged", |
|
|
2277 | ); |
|
|
2278 | |
|
|
2279 | $MENUFRAME->show; |
|
|
2280 | } |
|
|
2281 | |
|
|
2282 | sub open_string_query { |
|
|
2283 | my ($title, $cb, $txt, $tooltip) = @_; |
|
|
2284 | my $dialog = new DC::UI::Toplevel |
|
|
2285 | x => "center", |
|
|
2286 | y => "center", |
|
|
2287 | z => 50, |
|
|
2288 | force_w => $WIDTH * 4/5, |
|
|
2289 | title => $title; |
|
|
2290 | |
|
|
2291 | $dialog->add ( |
|
|
2292 | my $e = new DC::UI::Entry |
|
|
2293 | on_activate => sub { $cb->(@_); $dialog->hide; 0 }, |
|
|
2294 | on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 }, |
|
|
2295 | tooltip => $tooltip |
|
|
2296 | ); |
|
|
2297 | |
|
|
2298 | $e->grab_focus; |
|
|
2299 | $e->set_text ($txt) if $txt; |
|
|
2300 | $dialog->show; |
|
|
2301 | } |
|
|
2302 | |
2199 | sub show_tip_of_the_day { |
2303 | sub show_tip_of_the_day { |
2200 | # find all tips |
2304 | # find all tips |
2201 | my @tod = DC::Pod::find tip_of_the_day => "*"; |
2305 | my @tod = DC::Pod::find tip_of_the_day => "*"; |
2202 | |
2306 | |
2203 | DC::DB::get state => "tip_of_the_day", sub { |
2307 | DC::DB::get state => "tip_of_the_day", sub { |
… | |
… | |
2342 | |
2446 | |
2343 | (new DC::UI::Frame |
2447 | (new DC::UI::Frame |
2344 | bg => [0, 0, 0, 0.4], |
2448 | bg => [0, 0, 0, 0.4], |
2345 | force_x => 0, |
2449 | force_x => 0, |
2346 | force_y => "max", |
2450 | force_y => "max", |
2347 | child => (my $LR = new DC::UI::VBox), |
2451 | child => (my $LL = new DC::UI::VBox), |
2348 | )->show; |
2452 | )->show; |
2349 | |
2453 | |
2350 | $LR->add ($STATUSBOX); |
2454 | $LL->add ($STATUSBOX); |
2351 | $LR->add ($MODBOX); |
2455 | $LL->add ($MODBOX); |
2352 | $LR->add (new DC::UI::Label |
2456 | $LL->add (new DC::UI::Label |
2353 | align => 0, |
2457 | align => 0, |
2354 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode", |
2458 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode", |
2355 | fontsize => 0.5, |
2459 | fontsize => 0.5, |
2356 | fg => [1, 1, 0, 0.7], |
2460 | fg => [1, 1, 0, 0.7], |
2357 | ); |
2461 | ); |
… | |
… | |
2426 | . "After pressing the combo the binding will be saved automatically and the " |
2530 | . "After pressing the combo the binding will be saved automatically and the " |
2427 | . "binding editor closes"); |
2531 | . "binding editor closes"); |
2428 | $SETUP_NOTEBOOK->add_tab (Debug => debug_setup, |
2532 | $SETUP_NOTEBOOK->add_tab (Debug => debug_setup, |
2429 | "Some debuggin' options. Do not ask."); |
2533 | "Some debuggin' options. Do not ask."); |
2430 | |
2534 | |
2431 | $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
2535 | make_menuframe; |
2432 | |
2536 | |
2433 | $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
|
|
2434 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
|
|
2435 | |
|
|
2436 | # $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
|
|
2437 | # tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
|
|
2438 | |
|
|
2439 | 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 |
|
|
2440 | |
|
|
2441 | $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window, |
|
|
2442 | tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); |
|
|
2443 | |
|
|
2444 | $BUTTONBAR->add (new DC::UI::Button |
|
|
2445 | text => "Save Config", |
|
|
2446 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
|
|
2447 | on_activate => sub { |
|
|
2448 | $::CFG->{layout} = DC::UI::get_layout; |
|
|
2449 | DC::write_cfg; |
|
|
2450 | status "Configuration Saved"; |
|
|
2451 | 0 |
|
|
2452 | }, |
|
|
2453 | ); |
|
|
2454 | |
|
|
2455 | $BUTTONBAR->add (new DC::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, |
|
|
2456 | tooltip => "View Documentation"); |
|
|
2457 | |
|
|
2458 | $BUTTONBAR->add (new DC::UI::Button |
|
|
2459 | text => "Quit", |
|
|
2460 | tooltip => "Terminates the program", |
|
|
2461 | on_activate => sub { |
|
|
2462 | if ($CONN) { |
|
|
2463 | open_quit_dialog; |
|
|
2464 | } else { |
|
|
2465 | EV::unloop EV::UNLOOP_ALL; |
|
|
2466 | } |
|
|
2467 | 0 |
|
|
2468 | }, |
|
|
2469 | ); |
|
|
2470 | |
|
|
2471 | $BUTTONBAR->show; |
|
|
2472 | $SETUP_DIALOG->show; |
2537 | $SETUP_DIALOG->show; |
2473 | $MESSAGE_WINDOW->show; |
2538 | $MESSAGE_WINDOW->show; |
2474 | } |
2539 | } |
2475 | |
2540 | |
2476 | $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]); |
2541 | $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]); |
… | |
… | |
2586 | $SIG{INT} = $SIG{TERM} = sub { |
2651 | $SIG{INT} = $SIG{TERM} = sub { |
2587 | EV::unloop; |
2652 | EV::unloop; |
2588 | #d# TODO calling exit here hangs the process in some futex |
2653 | #d# TODO calling exit here hangs the process in some futex |
2589 | }; |
2654 | }; |
2590 | |
2655 | |
2591 | # due to mac os x + sdl combined briandamage, we need this contortion |
2656 | # due to mac os x + sdl combined braindamage, we need this contortion |
2592 | sub main { |
2657 | sub main { |
2593 | { |
2658 | { |
2594 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2659 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2595 | |
2660 | |
2596 | if (-e "$Deliantra::VARDIR/client.cf") { |
2661 | if (-e "$Deliantra::VARDIR/client.cf") { |
… | |
… | |
2613 | DC::DB::open_db; |
2678 | DC::DB::open_db; |
2614 | |
2679 | |
2615 | DC::UI::set_layout ($::CFG->{layout}); |
2680 | DC::UI::set_layout ($::CFG->{layout}); |
2616 | |
2681 | |
2617 | my %DEF_CFG = ( |
2682 | my %DEF_CFG = ( |
|
|
2683 | config_autosave => 1, |
2618 | sdl_mode => undef, |
2684 | sdl_mode => undef, |
2619 | fullscreen => 1, |
2685 | fullscreen => 1, |
2620 | fast => 0, |
2686 | fast => 0, |
2621 | force_opengl11 => undef, |
2687 | force_opengl11 => undef, |
2622 | disable_alpha => 0, |
2688 | disable_alpha => 0, |
… | |
… | |
2719 | }; |
2785 | }; |
2720 | |
2786 | |
2721 | delete $SIG{__DIE__}; |
2787 | delete $SIG{__DIE__}; |
2722 | EV::loop; |
2788 | EV::loop; |
2723 | |
2789 | |
|
|
2790 | DC::write_cfg if $CFG->{config_autosave}; |
|
|
2791 | |
2724 | #video_shutdown; |
2792 | #video_shutdown; |
2725 | #audio_shutdown; |
2793 | #audio_shutdown; |
|
|
2794 | |
2726 | DC::OpenGL::quit; |
2795 | DC::OpenGL::quit; |
2727 | DC::SDL_Quit; |
2796 | DC::SDL_Quit; |
2728 | DC::DB::Server::stop; |
2797 | DC::DB::Server::stop; |
2729 | } |
2798 | } |
2730 | |
2799 | |