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.30 by root, Mon Mar 24 01:15:22 2008 UTC vs.
Revision 1.42 by elmex, Thu May 8 18:25:25 2008 UTC

99use Deliantra; 99use Deliantra;
100use Deliantra::Protocol::Constants; 100use Deliantra::Protocol::Constants;
101 101
102use Compress::LZF; 102use Compress::LZF;
103 103
104use DC; 104use DC; BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } }
105use DC::OpenGL (); 105use DC::OpenGL ();
106use DC::Protocol; 106use DC::Protocol;
107use DC::DB; 107use DC::DB;
108use DC::UI; 108use DC::UI;
109use DC::UI::Canvas; 109use DC::UI::Canvas;
664 # right: accept 664 # right: accept
665 $table->add_at (4, 0, new DC::UI::Button 665 $table->add_at (4, 0, new DC::UI::Button
666 text => "Accept", 666 text => "Accept",
667 on_activate => sub { 667 on_activate => sub {
668 $conn->send ("reply n"); 668 $conn->send ("reply n");
669 $STATS_PAGE->hide;
670 destroy_query_dialog $conn; 669 destroy_query_dialog $conn;
671 0 670 0
672 }, 671 },
673 ); 672 );
674 673
765 if ($CONN) { 764 if ($CONN) {
766 DC::lowdelay fileno $CONN->{fh}; 765 DC::lowdelay fileno $CONN->{fh};
767 766
768 status "login successful"; 767 status "login successful";
769 } else { 768 } else {
769 warn $@;
770 status "unable to connect"; 770 status "unable to connect";
771 stop_game(); 771 stop_game();
772 } 772 }
773} 773}
774 774
1620 $CFG->{show_tips} = $value; 1620 $CFG->{show_tips} = $value;
1621 0 1621 0
1622 } 1622 }
1623 ); 1623 );
1624 1624
1625 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Messages Window Size"); 1625 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Window Size");
1626 $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry 1626 $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry
1627 text => $CFG->{logview_max_par}, 1627 text => $CFG->{logview_max_par},
1628 tooltip => "This is maximum number of messages remembered in the <b>Messages</b> window. If the server " 1628 tooltip => "This is maximum number of messages remembered in the <b>Message</b> window. If the server "
1629 . "sends more messages than this number, older messages get removed to save memory and " 1629 . "sends more messages than this number, older messages get removed to save memory and "
1630 . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", 1630 . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.",
1631 on_changed => sub { 1631 on_changed => sub {
1632 my ($self, $value) = @_; 1632 my ($self, $value) = @_;
1633 $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); 1633 $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1);
1742 1742
1743 $r 1743 $r
1744} 1744}
1745 1745
1746my %SORT_ORDER = ( 1746my %SORT_ORDER = (
1747 type => undef, 1747 type => sub {
1748 sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_
1749 },
1748 mtime => sub { 1750 mtime => sub {
1749 my $NOW = time; 1751 my $NOW = time;
1750 sort { 1752 sort {
1751 my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; 1753 my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6;
1752 my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; 1754 my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6;
1974 my @path = DC::Pod::full_path_of $node; 1976 my @path = DC::Pod::full_path_of $node;
1975 pop @path; # drop current node 1977 pop @path; # drop current node
1976 1978
1977 for my $node (@path) { 1979 for my $node (@path) {
1978 $buttons->add (new DC::UI::Button 1980 $buttons->add (new DC::UI::Button
1979 text => $node->{kw}[0], 1981 text => $node->[DC::Pod::N_KW][0],
1980 tooltip => "go to <i>" . (DC::asxml DC::Pod::full_path $node) . "</i>", 1982 tooltip => "go to <i>" . (DC::asxml DC::Pod::full_path $node) . "</i>",
1981 on_activate => sub { 1983 on_activate => sub {
1982 push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); 1984 push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = ();
1983 $load_node->($node); 1985 $load_node->($node);
1984 }, 1986 },
1985 ); 1987 );
1986 $buttons->add (new DC::UI::Label text => "/"); 1988 $buttons->add (new DC::UI::Label text => "/");
1987 } 1989 }
1988 1990
1989 $buttons->add (new DC::UI::Label text => $node->{kw}[0], padding_x => 4, padding_y => 4); 1991 $buttons->add (new DC::UI::Label text => $node->[DC::Pod::N_KW][0], padding_x => 4, padding_y => 4);
1990 1992
1991 $curnode = $node; 1993 $curnode = $node;
1992 1994
1993 $viewer->clear; 1995 $viewer->clear;
1994 $viewer->add_paragraph (DC::Pod::as_paragraphs DC::Pod::section_of $curnode); 1996 $viewer->add_paragraph (DC::Pod::as_paragraphs DC::Pod::section_of $curnode);
2241 force_h => $::HEIGHT * 0.6, 2243 force_h => $::HEIGHT * 0.6,
2242 has_close_button => 1, 2244 has_close_button => 1,
2243 ; 2245 ;
2244 2246
2245 $METASERVER = metaserver_dialog; 2247 $METASERVER = metaserver_dialog;
2246 $MESSAGE_WINDOW = new DC::UI::Dockbar (name => 'message_window', title => 'Messages'); 2248 # the name is changed to not conflict with the older name as users could have hidden it
2249 $MESSAGE_WINDOW = new DC::UI::Dockbar
2250 name => "message_window2",
2251 title => 'Messages',
2252 force_w => $::WIDTH * 0.6,
2253 force_h => $::HEIGHT * 0.25,
2254 ;
2255
2247 $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; 2256 $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW;
2248 2257
2249 $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new DC::UI::Notebook expand => 1, debug => 1, 2258 $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new DC::UI::Notebook expand => 1,
2250 filter => new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); 2259 filter => new DC::UI::ScrolledWindow expand => 1, scroll_y => 1);
2251 2260
2252 $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup, 2261 $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup,
2253 "Configure the server to play on, your username and password."); 2262 "Configure the server to play on, your username and password.");
2254 $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup, 2263 $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup,
2272 $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top 2281 $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top
2273 2282
2274 $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG, 2283 $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG,
2275 tooltip => "Toggles a dialog where you can configure all aspects of this client."); 2284 tooltip => "Toggles a dialog where you can configure all aspects of this client.");
2276 2285
2277 $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, 2286# $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW,
2278 tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); 2287# tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server.");
2279 2288
2280 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 2289 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
2281 2290
2282 $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window, 2291 $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window,
2283 tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); 2292 tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats.");
2285 $BUTTONBAR->add (new DC::UI::Button 2294 $BUTTONBAR->add (new DC::UI::Button
2286 text => "Save Config", 2295 text => "Save Config",
2287 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", 2296 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.",
2288 on_activate => sub { 2297 on_activate => sub {
2289 $::CFG->{layout} = DC::UI::get_layout; 2298 $::CFG->{layout} = DC::UI::get_layout;
2290 DC::write_cfg "$Deliantra::VARDIR/client.cf"; 2299 DC::write_cfg;
2291 status "Configuration Saved"; 2300 status "Configuration Saved";
2292 0 2301 0
2293 }, 2302 },
2294 ); 2303 );
2295 2304
2296 $BUTTONBAR->add (new DC::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, 2305 $BUTTONBAR->add (new DC::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window,
2297 tooltip => "View Documentation"); 2306 tooltip => "View Documentation");
2298
2299 2307
2300 $BUTTONBAR->add (new DC::UI::Button 2308 $BUTTONBAR->add (new DC::UI::Button
2301 text => "Quit", 2309 text => "Quit",
2302 tooltip => "Terminates the program", 2310 tooltip => "Terminates the program",
2303 on_activate => sub { 2311 on_activate => sub {
2420 EV::unloop; 2428 EV::unloop;
2421 #d# TODO calling exit here hangs the process in some futex 2429 #d# TODO calling exit here hangs the process in some futex
2422}; 2430};
2423 2431
2424{ 2432{
2433 DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst";
2434
2425 if (-e "$Deliantra::VARDIR/client.cf") { 2435 if (-e "$Deliantra::VARDIR/client.cf") {
2426 DC::read_cfg "$Deliantra::VARDIR/client.cf"; 2436 DC::read_cfg "$Deliantra::VARDIR/client.cf";
2427 } else { 2437 } else {
2428 #TODO: compatibility cruft 2438 #TODO: compatibility cruft
2429 DC::read_cfg "$Deliantra::OLDDIR/cfplusrc"; 2439 DC::read_cfg "$Deliantra::OLDDIR/cfplusrc";
2430 print STDERR "INFO: used old configuration file\n"; 2440 print STDERR "INFO: used old configuration file\n";
2431 } 2441 }
2432 2442
2433 DC::DB::Server::run; 2443 DC::DB::Server::run;
2444
2445 if ($CFG->{db_schema} < 1) {
2446 warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n";
2447 DC::DB::nuke_db;
2448 $CFG->{db_schema} = 1;
2449 DC::write_cfg;
2450 }
2451
2452 DC::DB::open_db;
2434 2453
2435 DC::UI::set_layout ($::CFG->{layout}); 2454 DC::UI::set_layout ($::CFG->{layout});
2436 2455
2437 my %DEF_CFG = ( 2456 my %DEF_CFG = (
2438 sdl_mode => 0, 2457 sdl_mode => 0,
2463 pickup => 0, 2482 pickup => 0,
2464 inv_sort => "mtime", 2483 inv_sort => "mtime",
2465 default => "profile", # default profile 2484 default => "profile", # default profile
2466 show_tips => 1, 2485 show_tips => 1,
2467 logview_max_par => 1000, 2486 logview_max_par => 1000,
2487 shift_fire_stop => 0,
2468 ); 2488 );
2469 2489
2470 while (my ($k, $v) = each %DEF_CFG) { 2490 while (my ($k, $v) = each %DEF_CFG) {
2471 $CFG->{$k} = $v unless exists $CFG->{$k}; 2491 $CFG->{$k} = $v unless exists $CFG->{$k};
2472 } 2492 }
2540our $STARTUP_CANCEL = EV::idle sub { 2560our $STARTUP_CANCEL = EV::idle sub {
2541 undef $::STARTUP_CANCEL; 2561 undef $::STARTUP_CANCEL;
2542 $startup_done->(); 2562 $startup_done->();
2543}; 2563};
2544 2564
2565delete $SIG{__DIE__};
2545EV::loop; 2566EV::loop;
2546 2567
2547#video_shutdown; 2568#video_shutdown;
2548#audio_shutdown; 2569#audio_shutdown;
2549DC::OpenGL::quit; 2570DC::OpenGL::quit;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines