… | |
… | |
99 | use Deliantra; |
99 | use Deliantra; |
100 | use Deliantra::Protocol::Constants; |
100 | use Deliantra::Protocol::Constants; |
101 | |
101 | |
102 | use Compress::LZF; |
102 | use Compress::LZF; |
103 | |
103 | |
104 | use DC; |
104 | use DC; BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } } |
105 | use DC::OpenGL (); |
105 | use DC::OpenGL (); |
106 | use DC::Protocol; |
106 | use DC::Protocol; |
107 | use DC::DB; |
107 | use DC::DB; |
108 | use DC::UI; |
108 | use DC::UI; |
109 | use DC::UI::Canvas; |
109 | use DC::UI::Canvas; |
… | |
… | |
232 | |
232 | |
233 | $markup .= $mod & DC::KMOD_NUM |
233 | $markup .= $mod & DC::KMOD_NUM |
234 | ? "[NUM]" |
234 | ? "[NUM]" |
235 | : "[<span foreground='#888'>num</span>]"; |
235 | : "[<span foreground='#888'>num</span>]"; |
236 | |
236 | |
|
|
237 | # <tt> around next statement works around some bug that keeps the |
|
|
238 | # "font =>" from being used on windows |
237 | $MODBOX->set_markup ($markup); |
239 | $MODBOX->set_markup ("<tt>$markup</tt>"); |
238 | } |
240 | } |
239 | |
241 | |
240 | ############################################################################# |
242 | ############################################################################# |
241 | #TODO: maybe move into own audio module... |
243 | #TODO: maybe move into own audio module... |
242 | |
244 | |
… | |
… | |
662 | # right: accept |
664 | # right: accept |
663 | $table->add_at (4, 0, new DC::UI::Button |
665 | $table->add_at (4, 0, new DC::UI::Button |
664 | text => "Accept", |
666 | text => "Accept", |
665 | on_activate => sub { |
667 | on_activate => sub { |
666 | $conn->send ("reply n"); |
668 | $conn->send ("reply n"); |
667 | $STATS_PAGE->hide; |
|
|
668 | destroy_query_dialog $conn; |
669 | destroy_query_dialog $conn; |
669 | 0 |
670 | 0 |
670 | }, |
671 | }, |
671 | ); |
672 | ); |
672 | |
673 | |
… | |
… | |
763 | if ($CONN) { |
764 | if ($CONN) { |
764 | DC::lowdelay fileno $CONN->{fh}; |
765 | DC::lowdelay fileno $CONN->{fh}; |
765 | |
766 | |
766 | status "login successful"; |
767 | status "login successful"; |
767 | } else { |
768 | } else { |
|
|
769 | warn $@; |
768 | status "unable to connect"; |
770 | status "unable to connect"; |
769 | stop_game(); |
771 | stop_game(); |
770 | } |
772 | } |
771 | } |
773 | } |
772 | |
774 | |
… | |
… | |
1618 | $CFG->{show_tips} = $value; |
1620 | $CFG->{show_tips} = $value; |
1619 | 0 |
1621 | 0 |
1620 | } |
1622 | } |
1621 | ); |
1623 | ); |
1622 | |
1624 | |
1623 | $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"); |
1624 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
1626 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
1625 | text => $CFG->{logview_max_par}, |
1627 | text => $CFG->{logview_max_par}, |
1626 | 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 " |
1627 | . "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 " |
1628 | . "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.", |
1629 | on_changed => sub { |
1631 | on_changed => sub { |
1630 | my ($self, $value) = @_; |
1632 | my ($self, $value) = @_; |
1631 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
1633 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
… | |
… | |
1740 | |
1742 | |
1741 | $r |
1743 | $r |
1742 | } |
1744 | } |
1743 | |
1745 | |
1744 | my %SORT_ORDER = ( |
1746 | my %SORT_ORDER = ( |
1745 | type => undef, |
1747 | type => sub { |
|
|
1748 | sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ |
|
|
1749 | }, |
1746 | mtime => sub { |
1750 | mtime => sub { |
1747 | my $NOW = time; |
1751 | my $NOW = time; |
1748 | sort { |
1752 | sort { |
1749 | 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; |
1750 | 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; |
… | |
… | |
1972 | my @path = DC::Pod::full_path_of $node; |
1976 | my @path = DC::Pod::full_path_of $node; |
1973 | pop @path; # drop current node |
1977 | pop @path; # drop current node |
1974 | |
1978 | |
1975 | for my $node (@path) { |
1979 | for my $node (@path) { |
1976 | $buttons->add (new DC::UI::Button |
1980 | $buttons->add (new DC::UI::Button |
1977 | text => $node->{kw}[0], |
1981 | text => $node->[DC::Pod::N_KW][0], |
1978 | 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>", |
1979 | on_activate => sub { |
1983 | on_activate => sub { |
1980 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
1984 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
1981 | $load_node->($node); |
1985 | $load_node->($node); |
1982 | }, |
1986 | }, |
1983 | ); |
1987 | ); |
1984 | $buttons->add (new DC::UI::Label text => "/"); |
1988 | $buttons->add (new DC::UI::Label text => "/"); |
1985 | } |
1989 | } |
1986 | |
1990 | |
1987 | $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); |
1988 | |
1992 | |
1989 | $curnode = $node; |
1993 | $curnode = $node; |
1990 | |
1994 | |
1991 | $viewer->clear; |
1995 | $viewer->clear; |
1992 | $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); |
… | |
… | |
2178 | can_events => 1, |
2182 | can_events => 1, |
2179 | can_hover => 1, |
2183 | can_hover => 1, |
2180 | markup => "", |
2184 | markup => "", |
2181 | align => 0, |
2185 | align => 0, |
2182 | font => $FONT_FIXED, |
2186 | font => $FONT_FIXED, |
2183 | tooltip => "#modifier_box"; |
2187 | tooltip => "#modifier_box", |
|
|
2188 | tooltip_width => 0.67, |
|
|
2189 | ; |
2184 | |
2190 | |
2185 | update_modbox; |
2191 | update_modbox; |
2186 | |
2192 | |
2187 | (new DC::UI::Frame |
2193 | (new DC::UI::Frame |
2188 | bg => [0, 0, 0, 0.4], |
2194 | bg => [0, 0, 0, 0.4], |
… | |
… | |
2237 | force_h => $::HEIGHT * 0.6, |
2243 | force_h => $::HEIGHT * 0.6, |
2238 | has_close_button => 1, |
2244 | has_close_button => 1, |
2239 | ; |
2245 | ; |
2240 | |
2246 | |
2241 | $METASERVER = metaserver_dialog; |
2247 | $METASERVER = metaserver_dialog; |
2242 | $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 | |
2243 | $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; |
2256 | $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; |
2244 | |
2257 | |
2245 | $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, |
2246 | filter => new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); |
2259 | filter => new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); |
2247 | |
2260 | |
2248 | $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup, |
2261 | $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup, |
2249 | "Configure the server to play on, your username and password."); |
2262 | "Configure the server to play on, your username and password."); |
2250 | $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup, |
2263 | $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup, |
… | |
… | |
2268 | $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 |
2269 | |
2282 | |
2270 | $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
2283 | $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
2271 | 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."); |
2272 | |
2285 | |
2273 | $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, |
2274 | 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."); |
2275 | |
2288 | |
2276 | 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 |
2277 | |
2290 | |
2278 | $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window, |
2291 | $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window, |
2279 | 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."); |
… | |
… | |
2281 | $BUTTONBAR->add (new DC::UI::Button |
2294 | $BUTTONBAR->add (new DC::UI::Button |
2282 | text => "Save Config", |
2295 | text => "Save Config", |
2283 | 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.", |
2284 | on_activate => sub { |
2297 | on_activate => sub { |
2285 | $::CFG->{layout} = DC::UI::get_layout; |
2298 | $::CFG->{layout} = DC::UI::get_layout; |
2286 | DC::write_cfg "$Deliantra::VARDIR/client.cf"; |
2299 | DC::write_cfg; |
2287 | status "Configuration Saved"; |
2300 | status "Configuration Saved"; |
2288 | 0 |
2301 | 0 |
2289 | }, |
2302 | }, |
2290 | ); |
2303 | ); |
2291 | |
2304 | |
2292 | $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, |
2293 | tooltip => "View Documentation"); |
2306 | tooltip => "View Documentation"); |
2294 | |
|
|
2295 | |
2307 | |
2296 | $BUTTONBAR->add (new DC::UI::Button |
2308 | $BUTTONBAR->add (new DC::UI::Button |
2297 | text => "Quit", |
2309 | text => "Quit", |
2298 | tooltip => "Terminates the program", |
2310 | tooltip => "Terminates the program", |
2299 | on_activate => sub { |
2311 | on_activate => sub { |
… | |
… | |
2416 | EV::unloop; |
2428 | EV::unloop; |
2417 | #d# TODO calling exit here hangs the process in some futex |
2429 | #d# TODO calling exit here hangs the process in some futex |
2418 | }; |
2430 | }; |
2419 | |
2431 | |
2420 | { |
2432 | { |
|
|
2433 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
|
|
2434 | |
2421 | if (-e "$Deliantra::VARDIR/client.cf") { |
2435 | if (-e "$Deliantra::VARDIR/client.cf") { |
2422 | DC::read_cfg "$Deliantra::VARDIR/client.cf"; |
2436 | DC::read_cfg "$Deliantra::VARDIR/client.cf"; |
2423 | } else { |
2437 | } else { |
2424 | #TODO: compatibility cruft |
2438 | #TODO: compatibility cruft |
2425 | DC::read_cfg "$Deliantra::OLDDIR/cfplusrc"; |
2439 | DC::read_cfg "$Deliantra::OLDDIR/cfplusrc"; |
2426 | print STDERR "INFO: used old configuration file\n"; |
2440 | print STDERR "INFO: used old configuration file\n"; |
2427 | } |
2441 | } |
2428 | |
2442 | |
2429 | 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; |
2430 | |
2453 | |
2431 | DC::UI::set_layout ($::CFG->{layout}); |
2454 | DC::UI::set_layout ($::CFG->{layout}); |
2432 | |
2455 | |
2433 | my %DEF_CFG = ( |
2456 | my %DEF_CFG = ( |
2434 | sdl_mode => 0, |
2457 | sdl_mode => 0, |
… | |
… | |
2459 | pickup => 0, |
2482 | pickup => 0, |
2460 | inv_sort => "mtime", |
2483 | inv_sort => "mtime", |
2461 | default => "profile", # default profile |
2484 | default => "profile", # default profile |
2462 | show_tips => 1, |
2485 | show_tips => 1, |
2463 | logview_max_par => 1000, |
2486 | logview_max_par => 1000, |
|
|
2487 | shift_fire_stop => 0, |
2464 | ); |
2488 | ); |
2465 | |
2489 | |
2466 | while (my ($k, $v) = each %DEF_CFG) { |
2490 | while (my ($k, $v) = each %DEF_CFG) { |
2467 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2491 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2468 | } |
2492 | } |
… | |
… | |
2504 | DejaVuSansMono-BoldOblique.ttf |
2528 | DejaVuSansMono-BoldOblique.ttf |
2505 | ); |
2529 | ); |
2506 | |
2530 | |
2507 | DC::add_font $_ for @fonts; |
2531 | DC::add_font $_ for @fonts; |
2508 | |
2532 | |
2509 | DC::pango_init; |
|
|
2510 | |
|
|
2511 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2533 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2512 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2534 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2513 | |
2535 | |
2514 | $FONT_PROP->make_default; |
2536 | $FONT_PROP->make_default; |
|
|
2537 | |
|
|
2538 | DC::pango_init; |
2515 | } |
2539 | } |
2516 | |
2540 | |
2517 | # compare mono (ft) vs. rgba (cairo) |
2541 | # compare mono (ft) vs. rgba (cairo) |
2518 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
2542 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
2519 | # for my $rgba (0..1) { |
2543 | # for my $rgba (0..1) { |
… | |
… | |
2536 | our $STARTUP_CANCEL = EV::idle sub { |
2560 | our $STARTUP_CANCEL = EV::idle sub { |
2537 | undef $::STARTUP_CANCEL; |
2561 | undef $::STARTUP_CANCEL; |
2538 | $startup_done->(); |
2562 | $startup_done->(); |
2539 | }; |
2563 | }; |
2540 | |
2564 | |
|
|
2565 | delete $SIG{__DIE__}; |
2541 | EV::loop; |
2566 | EV::loop; |
2542 | |
2567 | |
2543 | #video_shutdown; |
2568 | #video_shutdown; |
2544 | #audio_shutdown; |
2569 | #audio_shutdown; |
2545 | DC::OpenGL::quit; |
2570 | DC::OpenGL::quit; |