ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/deliantra
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/deliantra (file contents):
Revision 1.83 by root, Sun Jan 4 10:22:19 2009 UTC vs.
Revision 1.89 by root, Mon Jan 12 03:11:05 2009 UTC

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
87use Deliantra; 92use Deliantra;
88use Deliantra::Protocol::Constants; 93use Deliantra::Protocol::Constants;
89 94
90use AnyEvent::Util (); 95use AnyEvent::Util ();
91use AnyEvent::DNS;
92use AnyEvent::Socket (); 96use AnyEvent::Socket ();
93use AnyEvent::DNS (); 97use AnyEvent::DNS ();
94 98
95use Compress::LZF; 99use Compress::LZF;
96use JSON::XS; 100use JSON::XS;
162 166
163our $MAP; 167our $MAP;
164our $MAPMAP; 168our $MAPMAP;
165our $MAPWIDGET; 169our $MAPWIDGET;
166our $COMPLETER; 170our $COMPLETER;
167our $BUTTONBAR; 171our $MENUFRAME; # the rectangle at the top
172our $MENUBAR; # the hbox at the top
173our $MENUPOPUP;
174our $BUTTONBAR; # the menu buttons
168our $METASERVER; 175our $METASERVER;
169our $LOGIN_BUTTON; 176our $LOGIN_BUTTON;
170our $QUIT_DIALOG; 177our $QUIT_DIALOG;
171our $HOST_ENTRY; 178our $HOST_ENTRY;
172our $FULLSCREEN_ENABLE; 179our $FULLSCREEN_ENABLE;
339 or return; 346 or return;
340 347
341 $meta->{data} 348 $meta->{data}
342 or return; 349 or return;
343 350
344 # if its a jingle, play it as ambient music 351 # if it's a jingle, play it as ambient music
345 if ($meta->{data}{jingle}) { 352 if ($meta->{data}{jingle}) {
346 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
347 push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue 354 push @MUSIC_JINGLE, $meta; # push it unto the music/jingle queue
348 &audio_music_push ($face); 355 &audio_music_push ($face);
349 } 356 }
350 } else { 357 } else {
351 # fetch from database 358 # fetch from database
352 DC::DB::get res_data => $meta->{name}, sub { 359 DC::DB::get res_data => $meta->{name}, sub {
353 my $rwops = new DC::RW $_[0]; 360 my $rwops = new DC::RW $_[0];
354 my $chunk = new DC::MixChunk $rwops 361 my $chunk = new DC::MixChunk $rwops
355 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;
356 $chunk->volume (($meta->{data}{volume} || 1) * 128); 363 $chunk->volume (($meta->{data}{volume} || 1) * 128);
357 $AUDIO_CHUNK{$face} = $chunk; 364 $AUDIO_CHUNK{$face} = $chunk;
358 365
359 audio_sound_push ($face); 366 audio_sound_push ($face);
360 }; 367 };
407 414
408 audio_music_update_volume; 415 audio_music_update_volume;
409 416
410 $MUSIC_PLAYING_DATA = \$_[0]; 417 $MUSIC_PLAYING_DATA = \$_[0];
411 418
419 $meta->{path} or length $_[0]
420 or return clienterror "empty music face from res_data ($meta->{face})";#d#
421
412 my $rwops = $meta->{path} 422 my $rwops = $meta->{path}
413 ? 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
414 : new DC::RW $$MUSIC_PLAYING_DATA; 424 : new DC::RW $$MUSIC_PLAYING_DATA;
415 425
416 $MUSIC_PLAYER = new DC::MixMusic $rwops 426 $MUSIC_PLAYER = new DC::MixMusic $rwops
417 or return clienterror "music face $meta->{face} unloadable: " . DC::Mix_GetError => 1; 427 or return clienterror "music face $meta->{face} unloadable: " . DC::Mix_GetError => 1;
418 428
911 921
912 $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");
913 $table->add_at (1, $row++, my $hbox = new DC::UI::HBox); 923 $table->add_at (1, $row++, my $hbox = new DC::UI::HBox);
914 924
915 $hbox->add ($MODE_SLIDER = new DC::UI::Slider 925 $hbox->add ($MODE_SLIDER = new DC::UI::Slider
926 c_rescale => 1,
916 force_w => $WIDTH * 0.1, expand => 1, 927 force_w => $WIDTH * 0.1, expand => 1,
917 range => [ ($CFG->{sdl_mode}) x 3 ], 928 range => [ ($CFG->{sdl_mode}) x 3 ],
918 tooltip => $vidmode_tooltip); 929 tooltip => $vidmode_tooltip);
919 $hbox->add (my $mode_label = new DC::UI::Label 930 $hbox->add (my $mode_label = new DC::UI::Label
920 height => 0.8, template => "9999x9999@9+9", 931 height => 0.8, template => "9999x9999@9+9",
1244} 1255}
1245 1256
1246sub make_gauge_window { 1257sub make_gauge_window {
1247 my $gh = int $HEIGHT * $CFG->{gauge_size}; 1258 my $gh = int $HEIGHT * $CFG->{gauge_size};
1248 1259
1249 my $win = new DC::UI::Frame ( 1260 $GAUGES->{win} = my $win = new DC::UI::Frame (
1250 force_x => 0, 1261 force_x => 0,
1251 force_y => "max", 1262 force_y => "max",
1252 force_w => $WIDTH, 1263 force_w => $WIDTH,
1253 force_h => $gh, 1264 force_h => $gh,
1254 ); 1265 );
1270 (new DC::UI::Empty expand => 1), 1281 (new DC::UI::Empty expand => 1),
1271 (my $hb = new DC::UI::HBox), 1282 (my $hb = new DC::UI::HBox),
1272 ], 1283 ],
1273 ); 1284 );
1274 1285
1275 $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");
1276 $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");
1277 $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");
1278 $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");
1279
1280 $vbox->add (my $exp = new DC::UI::Label align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp");
1281 $vbox->add (my $prg = new DC::UI::ExperienceProgress);
1282 $vbox->add (my $sklprg = new DC::UI::ExperienceProgress);
1283 $vbox->add (my $rng = new DC::UI::Label align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged");
1284
1285 $GAUGES = {
1286 exp => $exp, prg => $prg, sklprg => $sklprg,
1287 win => $win, range => $rng,
1288 hp => $hg, mana => $mg, grace => $gg, food => $fg,
1289 };
1290 1290
1291 &set_gauge_window_fontsize; 1291 &set_gauge_window_fontsize;
1292 1292
1293 $win 1293 $win
1294} 1294}
1636 ); 1636 );
1637 1637
1638 $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username"); 1638 $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username");
1639 $table->add_at (1, 4, new DC::UI::Entry 1639 $table->add_at (1, 4, new DC::UI::Entry
1640 text => $CFG->{profile}{default}{user}, 1640 text => $CFG->{profile}{default}{user},
1641 tooltip => "The name of your character on the server.", 1641 tooltip => "The name of your character on the server. The name is case-sensitive!",
1642 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 } 1642 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 }
1643 ); 1643 );
1644 1644
1645 $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password"); 1645 $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password");
1646 $table->add_at (1, 5, new DC::UI::Entry 1646 $table->add_at (1, 5, new DC::UI::Entry
1748 1748
1749 my $row = 0; 1749 my $row = 0;
1750 1750
1751 $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");
1752 $table->add_at (1, $row++, new DC::UI::CheckBox 1752 $table->add_at (1, $row++, new DC::UI::CheckBox
1753 c_colspan => 2,
1753 state => $CFG->{show_tips}, 1754 state => $CFG->{show_tips},
1754 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?",
1755 on_changed => sub { 1756 on_changed => sub {
1756 my ($self, $value) = @_; 1757 my ($self, $value) = @_;
1757 $CFG->{show_tips} = $value; 1758 $CFG->{show_tips} = $value;
1759 } 1760 }
1760 ); 1761 );
1761 1762
1762 $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");
1763 $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,
1764 text => $CFG->{logview_max_par}, 1766 text => $CFG->{logview_max_par},
1765 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 "
1766 . "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 "
1767 . "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.",
1768 on_changed => sub { 1770 on_changed => sub {
1770 $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); 1772 $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1);
1771 0 1773 0
1772 }, 1774 },
1773 ); 1775 );
1774 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 }
1797 );
1798
1775 $table 1799 $table
1776} 1800}
1777 1801
1778sub autopickup_setup { 1802sub autopickup_setup {
1779 my $r = new DC::UI::ScrolledWindow ( 1803 my $r = new DC::UI::ScrolledWindow (
1785 col_expand => [0, 1, 0, 1], 1809 col_expand => [0, 1, 0, 1],
1786 ); 1810 );
1787 1811
1788 for ( 1812 for (
1789 ["General", 0, 0, 1813 ["General", 0, 0,
1790 ["Enable autopickup" => PICKUP_NEWMODE, \$PICKUP_ENABLE],
1791 ["Inhibit autopickup" => PICKUP_INHIBIT], 1814# ["Inhibit autopickup" => PICKUP_INHIBIT],
1792 ["Stop before pickup" => PICKUP_STOP], 1815 ["Stop before pickup" => PICKUP_STOP],
1793 ["Debug autopickup" => PICKUP_DEBUG], 1816 ["Debug autopickup" => PICKUP_DEBUG],
1794 ], 1817 ],
1795 ["Weapons", 0, 6, 1818 ["Weapons", 0, 6,
1796 ["All weapons" => PICKUP_ALLWEAPON], 1819 ["All weapons" => PICKUP_ALLWEAPON],
1844 $::CFG->{pickup} |= $mask; 1867 $::CFG->{pickup} |= $mask;
1845 } else { 1868 } else {
1846 $::CFG->{pickup} &= ~$mask; 1869 $::CFG->{pickup} &= ~$mask;
1847 } 1870 }
1848 1871
1849 $::CONN->send_command ("pickup $::CFG->{pickup}") 1872 $::CONN->send_pickup ($::CFG->{pickup})
1850 if defined $::CONN; 1873 if defined $::CONN;
1851 1874
1852 0 1875 0
1853 }); 1876 });
1854 1877
1871 }); 1894 });
1872 1895
1873 $table->add_at (3, 18, new DC::UI::Button 1896 $table->add_at (3, 18, new DC::UI::Button
1874 text => "set", 1897 text => "set",
1875 on_activate => sub { 1898 on_activate => sub {
1876 $::CONN->send_command ("pickup $::CFG->{pickup}") 1899 $::CONN->send_pickup ($::CFG->{pickup})
1877 if defined $::CONN; 1900 if defined $::CONN;
1878 0 1901 0
1879 }); 1902 });
1880 1903
1881 $r 1904 $r
1994 $PL_NOTEBOOK->set_current_page ($widget); 2017 $PL_NOTEBOOK->set_current_page ($widget);
1995 $PL_WINDOW->show; 2018 $PL_WINDOW->show;
1996 } 2019 }
1997} 2020}
1998 2021
1999sub player_window { 2022sub make_playerbook {
2000 my $plwin = $PL_WINDOW = new DC::UI::Toplevel 2023 my $plwin = $PL_WINDOW = new DC::UI::Toplevel
2001 x => "center", 2024 x => "center",
2002 y => "center", 2025 y => "center",
2003 force_w => $WIDTH * 9/10, 2026 force_w => $WIDTH * 9/10,
2004 force_h => $HEIGHT * 9/10, 2027 force_h => $HEIGHT * 9/10,
2038 "License, Author and Source info for media sent by the server."); 2061 "License, Author and Source info for media sent by the server.");
2039 2062
2040 $ntb->set_current_page ($INVENTORY_PAGE); 2063 $ntb->set_current_page ($INVENTORY_PAGE);
2041 2064
2042 $plwin->add ($ntb); 2065 $plwin->add ($ntb);
2043 $plwin
2044} 2066}
2045 2067
2046sub keyboard_setup { 2068sub keyboard_setup {
2047 DC::Macro::keyboard_setup 2069 DC::Macro::keyboard_setup
2048} 2070}
2049 2071
2050sub help_window { 2072sub make_help_window {
2051 my $win = new DC::UI::Toplevel 2073 my $win = new DC::UI::Toplevel
2052 x => 'center', 2074 x => 'center',
2053 y => 'center', 2075 y => 'center',
2054 z => 4, 2076 z => 4,
2055 name => 'doc_browser', 2077 name => 'doc_browser',
2144 2166
2145 $load_node->((DC::Pod::find @path)[0]); 2167 $load_node->((DC::Pod::find @path)[0]);
2146 $win->show; 2168 $win->show;
2147 }; 2169 };
2148 2170
2149 $win 2171 $HELP_WINDOW = $win;
2150}
2151
2152sub open_string_query {
2153 my ($title, $cb, $txt, $tooltip) = @_;
2154 my $dialog = new DC::UI::Toplevel
2155 x => "center",
2156 y => "center",
2157 z => 50,
2158 force_w => $WIDTH * 4/5,
2159 title => $title;
2160
2161 $dialog->add (
2162 my $e = new DC::UI::Entry
2163 on_activate => sub { $cb->(@_); $dialog->hide; 0 },
2164 on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 },
2165 tooltip => $tooltip
2166 );
2167
2168 $e->grab_focus;
2169 $e->set_text ($txt) if $txt;
2170 $dialog->show;
2171} 2172}
2172 2173
2173sub open_quit_dialog { 2174sub open_quit_dialog {
2174 unless ($QUIT_DIALOG) { 2175 unless ($QUIT_DIALOG) {
2175 $QUIT_DIALOG = new DC::UI::Toplevel 2176 $QUIT_DIALOG = new DC::UI::Toplevel
2208 2209
2209 $QUIT_DIALOG->show; 2210 $QUIT_DIALOG->show;
2210 $QUIT_DIALOG->grab_focus; 2211 $QUIT_DIALOG->grab_focus;
2211} 2212}
2212 2213
2214sub make_menubar {
2215 $MENUFRAME = new DC::UI::Toplevel
2216 border => 0,
2217 force_x => 0,
2218 force_y => 0,
2219 force_w => $::WIDTH,
2220 child => ($MENUBAR = new DC::UI::HBox),
2221 ;
2222
2223 $MENUBAR->add ($BUTTONBAR = new DC::UI::Buttonbar);
2224
2225 # 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
2226 make_gauge_window->show;
2227
2228# $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW,
2229# tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server.");
2230
2231 make_playerbook;
2232
2233 $MENUPOPUP = DC::UI::Menu->new (items => [
2234 ["Setup…\tF9" , sub { $SETUP_DIALOG->toggle_visibility }],
2235 ["Playerbook…\tTab" , sub { $PL_WINDOW ->toggle_visibility }],
2236 ["…Statistics\tF2" , sub { toggle_player_page ($::STATS_PAGE) }],
2237 ["…Skills\tF3" , sub { toggle_player_page ($::SKILL_PAGE) }],
2238 ["…Spells\tF4" , sub { toggle_player_page ($::SPELL_PAGE) }],
2239 ["…Inventory\tF5" , sub { toggle_player_page ($::INVENTORY_PAGE) }],
2240 ["Help Browser…\tF1" , sub { $HELP_WINDOW ->toggle_visibility }],
2241 ["Quit…" , sub {
2242 if ($CONN) {
2243 open_quit_dialog;
2244 } else {
2245 EV::unloop EV::UNLOOP_ALL;
2246 }
2247 }],
2248 ]);
2249
2250 $BUTTONBAR->add (new DC::UI::Button text => "Menu…",
2251 tooltip => "Shows the main menu",
2252 on_button_down => sub {
2253 my ($self, $ev) = @_;
2254 local $ev->{x} = 0;
2255 local $ev->{y} = 0;
2256 $MENUPOPUP->popup ($ev);
2257 },
2258 );
2259
2260 $MENUBAR->add ($GAUGES->{exp} = new DC::UI::ExperienceProgress
2261 padding_x => 6,
2262 padding_y => 3,
2263 tooltip => "This progress bar shows your progress towards the next character level.",
2264 template => " Exp: 888,888,888,888 (lvl 188) ",
2265 );
2266
2267 $MENUBAR->add ($PICKUP_ENABLE = new DC::UI::CheckBox # checkbox bad, button better?
2268 tooltip => "Automatic Pickup Enable - when this checkbox is enabled, then your character "
2269 . "will automatically pick up items as defined by your item pickup settings "
2270 . "in the playerbook. Often (e.g. in apartments) you want to temporarily "
2271 . "disable autopickup by disabling this checkbox.",
2272 state => $CFG->{pickup} & PICKUP_INHIBIT ? 0 : 1,
2273 on_changed => sub {
2274 my ($self, $value) = @_;
2275 $CFG->{pickup} &= ~PICKUP_INHIBIT;
2276 $CFG->{pickup} |= PICKUP_INHIBIT unless $_[1];
2277 $CONN->send_pickup ($CFG->{pickup})
2278 if $CONN;
2279 },
2280 );
2281
2282 $MENUBAR->add ($GAUGES->{skillexp} = new DC::UI::ExperienceProgress
2283 c_rescale => 1,
2284 padding_x => 6,
2285 padding_y => 3,
2286 force_w => $::WIDTH * 0.2,
2287 tooltip => "This progress bar shows the currently used skill and your progress towards the next skill level of that skill.",
2288 template => "two handed weapons 99%",
2289 );
2290
2291 $MENUBAR->add ($GAUGES->{range} = new DC::UI::Label
2292 expand => 1,
2293 align => 1, can_hover => 1, can_events => 1,
2294 text => "Range and Combat Slots",
2295 tooltip => "#stat_ranged",
2296 );
2297
2298 $MENUFRAME->show;
2299}
2300
2301sub open_string_query {
2302 my ($title, $cb, $txt, $tooltip) = @_;
2303 my $dialog = new DC::UI::Toplevel
2304 x => "center",
2305 y => "center",
2306 z => 50,
2307 force_w => $WIDTH * 4/5,
2308 title => $title;
2309
2310 $dialog->add (
2311 my $e = new DC::UI::Entry
2312 on_activate => sub { $cb->(@_); $dialog->hide; 0 },
2313 on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 },
2314 tooltip => $tooltip
2315 );
2316
2317 $e->grab_focus;
2318 $e->set_text ($txt) if $txt;
2319 $dialog->show;
2320}
2321
2213sub show_tip_of_the_day { 2322sub show_tip_of_the_day {
2214 # find all tips 2323 # find all tips
2215 my @tod = DC::Pod::find tip_of_the_day => "*"; 2324 my @tod = DC::Pod::find tip_of_the_day => "*";
2216 2325
2217 DC::DB::get state => "tip_of_the_day", sub { 2326 DC::DB::get state => "tip_of_the_day", sub {
2356 2465
2357 (new DC::UI::Frame 2466 (new DC::UI::Frame
2358 bg => [0, 0, 0, 0.4], 2467 bg => [0, 0, 0, 0.4],
2359 force_x => 0, 2468 force_x => 0,
2360 force_y => "max", 2469 force_y => "max",
2361 child => (my $LR = new DC::UI::VBox), 2470 child => (my $LL = new DC::UI::VBox),
2362 )->show; 2471 )->show;
2363 2472
2364 $LR->add ($STATUSBOX); 2473 $LL->add ($STATUSBOX);
2365 $LR->add ($MODBOX); 2474 $LL->add ($MODBOX);
2366 $LR->add (new DC::UI::Label 2475 $LL->add (new DC::UI::Label
2367 align => 0, 2476 align => 0,
2368 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode", 2477 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode",
2369 fontsize => 0.5, 2478 fontsize => 0.5,
2370 fg => [1, 1, 0, 0.7], 2479 fg => [1, 1, 0, 0.7],
2371 ); 2480 );
2440 . "After pressing the combo the binding will be saved automatically and the " 2549 . "After pressing the combo the binding will be saved automatically and the "
2441 . "binding editor closes"); 2550 . "binding editor closes");
2442 $SETUP_NOTEBOOK->add_tab (Debug => debug_setup, 2551 $SETUP_NOTEBOOK->add_tab (Debug => debug_setup,
2443 "Some debuggin' options. Do not ask."); 2552 "Some debuggin' options. Do not ask.");
2444 2553
2445 $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top 2554 make_help_window;
2555 make_menubar;
2446 2556
2447 $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG,
2448 tooltip => "Toggles a dialog where you can configure all aspects of this client.");
2449
2450# $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW,
2451# tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server.");
2452
2453 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
2454
2455 $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window,
2456 tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats.");
2457
2458 $BUTTONBAR->add (new DC::UI::Button
2459 text => "Save Config",
2460 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.",
2461 on_activate => sub {
2462 $::CFG->{layout} = DC::UI::get_layout;
2463 DC::write_cfg;
2464 status "Configuration Saved";
2465 0
2466 },
2467 );
2468
2469 $BUTTONBAR->add (new DC::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window,
2470 tooltip => "View Documentation");
2471
2472 $BUTTONBAR->add (new DC::UI::Button
2473 text => "Quit",
2474 tooltip => "Terminates the program",
2475 on_activate => sub {
2476 if ($CONN) {
2477 open_quit_dialog;
2478 } else {
2479 EV::unloop EV::UNLOOP_ALL;
2480 }
2481 0
2482 },
2483 );
2484
2485 $BUTTONBAR->show;
2486 $SETUP_DIALOG->show; 2557 $SETUP_DIALOG->show;
2487 $MESSAGE_WINDOW->show; 2558 $MESSAGE_WINDOW->show;
2488 } 2559 }
2489 2560
2490 $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]); 2561 $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]);
2600$SIG{INT} = $SIG{TERM} = sub { 2671$SIG{INT} = $SIG{TERM} = sub {
2601 EV::unloop; 2672 EV::unloop;
2602 #d# TODO calling exit here hangs the process in some futex 2673 #d# TODO calling exit here hangs the process in some futex
2603}; 2674};
2604 2675
2605# initialise the resolver now, as vista forces us back to the desktop
2606# when doing this.
2607AnyEvent::DNS::resolver;
2608
2609# due to mac os x + sdl combined braindamage, we need this contortion 2676# due to mac os x + sdl combined braindamage, we need this contortion
2610sub main { 2677sub main {
2611 { 2678 {
2612 DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; 2679 DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst";
2613 2680
2631 DC::DB::open_db; 2698 DC::DB::open_db;
2632 2699
2633 DC::UI::set_layout ($::CFG->{layout}); 2700 DC::UI::set_layout ($::CFG->{layout});
2634 2701
2635 my %DEF_CFG = ( 2702 my %DEF_CFG = (
2703 config_autosave => 1,
2636 sdl_mode => undef, 2704 sdl_mode => undef,
2637 fullscreen => 1, 2705 fullscreen => 1,
2638 fast => 0, 2706 fast => 0,
2639 force_opengl11 => undef, 2707 force_opengl11 => undef,
2640 disable_alpha => 0, 2708 disable_alpha => 0,
2658 effects_enable => 1, 2726 effects_enable => 1,
2659 effects_volume => 1, 2727 effects_volume => 1,
2660 bgm_enable => 1, 2728 bgm_enable => 1,
2661 bgm_volume => 0.5, 2729 bgm_volume => 0.5,
2662 output_rate => "", 2730 output_rate => "",
2663 pickup => 0, 2731 pickup => PICKUP_SPELLBOOK | PICKUP_SKILLSCROLL | PICKUP_VALUABLES,
2664 inv_sort => "mtime", 2732 inv_sort => "mtime",
2665 default => "profile", # default profile 2733 default => "profile", # default profile
2666 show_tips => 1, 2734 show_tips => 1,
2667 logview_max_par => 1000, 2735 logview_max_par => 1000,
2668 shift_fire_stop => 0, 2736 shift_fire_stop => 0,
2737 }; 2805 };
2738 2806
2739 delete $SIG{__DIE__}; 2807 delete $SIG{__DIE__};
2740 EV::loop; 2808 EV::loop;
2741 2809
2810 DC::write_cfg if $CFG->{config_autosave};
2811
2742#video_shutdown; 2812 #video_shutdown;
2743#audio_shutdown; 2813 #audio_shutdown;
2814
2744 DC::OpenGL::quit; 2815 DC::OpenGL::quit;
2745 DC::SDL_Quit; 2816 DC::SDL_Quit;
2746 DC::DB::Server::stop; 2817 DC::DB::Server::stop;
2747} 2818}
2748 2819

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines