… | |
… | |
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; |
… | |
… | |
190 | our $SDL_ACTIVE; |
190 | our $SDL_ACTIVE; |
191 | our %SDL_CB; |
191 | our %SDL_CB; |
192 | |
192 | |
193 | our $ALT_ENTER_MESSAGE; |
193 | our $ALT_ENTER_MESSAGE; |
194 | our $STATUSBOX; |
194 | our $STATUSBOX; |
|
|
195 | our $MODBOX; |
195 | our $DEBUG_STATUS; |
196 | our $DEBUG_STATUS; |
196 | |
197 | |
197 | our $INV; |
198 | our $INV; |
198 | our $INVR; |
199 | our $INVR; |
199 | our $INVR_HB; |
200 | our $INVR_HB; |
… | |
… | |
208 | $DEBUG_STATUS->set_text ($_[0]); |
209 | $DEBUG_STATUS->set_text ($_[0]); |
209 | } |
210 | } |
210 | |
211 | |
211 | sub message { |
212 | sub message { |
212 | $MESSAGE_DIST->message (@_); |
213 | $MESSAGE_DIST->message (@_); |
|
|
214 | } |
|
|
215 | |
|
|
216 | sub update_modbox { |
|
|
217 | my $mod = DC::SDL_GetModState; |
|
|
218 | |
|
|
219 | my $markup; |
|
|
220 | |
|
|
221 | $markup .= $mod & DC::KMOD_CTRL |
|
|
222 | ? ($MAPWIDGET->{ctrl} ? "[REPEAT]" : "[<span foreground='#888'>REPEAT</span>]") |
|
|
223 | : "[<span foreground='#888'> once </span>]"; |
|
|
224 | |
|
|
225 | $markup .= $mod & DC::KMOD_SHIFT |
|
|
226 | ? ($MAPWIDGET->{shft} ? "[FIRE]" : "[<span foreground='#888'>FIRE</span>]") |
|
|
227 | : "[<span foreground='#888'>move</span>]"; |
|
|
228 | |
|
|
229 | $markup .= $mod & (DC::KMOD_ALT | DC::KMOD_META) |
|
|
230 | ? "[ALT]" |
|
|
231 | : "[<span foreground='#888'>alt</span>]"; |
|
|
232 | |
|
|
233 | $markup .= $mod & DC::KMOD_NUM |
|
|
234 | ? "[NUM]" |
|
|
235 | : "[<span foreground='#888'>num</span>]"; |
|
|
236 | |
|
|
237 | # <tt> around next statement works around some bug that keeps the |
|
|
238 | # "font =>" from being used on windows |
|
|
239 | $MODBOX->set_markup ("<tt>$markup</tt>"); |
213 | } |
240 | } |
214 | |
241 | |
215 | ############################################################################# |
242 | ############################################################################# |
216 | #TODO: maybe move into own audio module... |
243 | #TODO: maybe move into own audio module... |
217 | |
244 | |
… | |
… | |
720 | user => $PROFILE->{user}, |
747 | user => $PROFILE->{user}, |
721 | pass => $PROFILE->{password}, |
748 | pass => $PROFILE->{password}, |
722 | mapw => $mapsize, |
749 | mapw => $mapsize, |
723 | maph => $mapsize, |
750 | maph => $mapsize, |
724 | |
751 | |
725 | client => "cfplus $DC::VERSION $] $^O", |
752 | client => "$DC::VERSION $] $^O", |
726 | |
753 | |
727 | map_widget => $MAPWIDGET, |
754 | map_widget => $MAPWIDGET, |
728 | statusbox => $STATUSBOX, |
755 | statusbox => $STATUSBOX, |
729 | map => $MAP, |
756 | map => $MAP, |
730 | mapmap => $MAPMAP, |
757 | mapmap => $MAPMAP, |
… | |
… | |
738 | if ($CONN) { |
765 | if ($CONN) { |
739 | DC::lowdelay fileno $CONN->{fh}; |
766 | DC::lowdelay fileno $CONN->{fh}; |
740 | |
767 | |
741 | status "login successful"; |
768 | status "login successful"; |
742 | } else { |
769 | } else { |
|
|
770 | warn $@; |
743 | status "unable to connect"; |
771 | status "unable to connect"; |
744 | stop_game(); |
772 | stop_game(); |
745 | } |
773 | } |
746 | } |
774 | } |
747 | |
775 | |
… | |
… | |
1528 | |
1556 | |
1529 | $vbox->add ( |
1557 | $vbox->add ( |
1530 | $HOST_ENTRY = new DC::UI::Entry |
1558 | $HOST_ENTRY = new DC::UI::Entry |
1531 | expand => 1, |
1559 | expand => 1, |
1532 | text => $CFG->{profile}{default}{host}, |
1560 | text => $CFG->{profile}{default}{host}, |
1533 | tooltip => "The hostname or ip address of the Deliantra server to connect to", |
1561 | tooltip => "The hostname or ip address of the Deliantra server to connect to (e.g. <b>gameserver.deliantra.net</b>)", |
1534 | on_changed => sub { |
1562 | on_changed => sub { |
1535 | my ($self, $value) = @_; |
1563 | my ($self, $value) = @_; |
1536 | $CFG->{profile}{default}{host} = $value; |
1564 | $CFG->{profile}{default}{host} = $value; |
1537 | 1 |
1565 | 1 |
1538 | } |
1566 | } |
… | |
… | |
1541 | if (0) { #d# disabled |
1569 | if (0) { #d# disabled |
1542 | $vbox->add (new DC::UI::Button |
1570 | $vbox->add (new DC::UI::Button |
1543 | expand => 1, |
1571 | expand => 1, |
1544 | text => "Server List", |
1572 | text => "Server List", |
1545 | other => $METASERVER, |
1573 | other => $METASERVER, |
1546 | tooltip => "Show a list of available crossfire servers", |
1574 | tooltip => "Show a list of available Deliantra servers", |
1547 | on_activate => sub { $METASERVER->toggle_visibility; 0 }, |
1575 | on_activate => sub { $METASERVER->toggle_visibility; 0 }, |
1548 | on_visibility_change => sub { $METASERVER->hide unless $_[1]; 1 }, |
1576 | on_visibility_change => sub { $METASERVER->hide unless $_[1]; 1 }, |
1549 | ); |
1577 | ); |
1550 | }#d# |
1578 | }#d# |
1551 | } |
1579 | } |
… | |
… | |
1593 | $CFG->{show_tips} = $value; |
1621 | $CFG->{show_tips} = $value; |
1594 | 0 |
1622 | 0 |
1595 | } |
1623 | } |
1596 | ); |
1624 | ); |
1597 | |
1625 | |
1598 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Messages Window Size"); |
1626 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Window Size"); |
1599 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
1627 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
1600 | text => $CFG->{logview_max_par}, |
1628 | text => $CFG->{logview_max_par}, |
1601 | tooltip => "This is maximum number of messages remembered in the <b>Messages</b> window. If the server " |
1629 | tooltip => "This is maximum number of messages remembered in the <b>Message</b> window. If the server " |
1602 | . "sends more messages than this number, older messages get removed to save memory and " |
1630 | . "sends more messages than this number, older messages get removed to save memory and " |
1603 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1631 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1604 | on_changed => sub { |
1632 | on_changed => sub { |
1605 | my ($self, $value) = @_; |
1633 | my ($self, $value) = @_; |
1606 | $MESSAGE_DIST->set_max_para ($CFG->{logview_max_par} = $value*1); |
1634 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
1607 | 0 |
1635 | 0 |
1608 | }, |
1636 | }, |
1609 | ); |
1637 | ); |
1610 | |
1638 | |
1611 | $table |
1639 | $table |
… | |
… | |
1947 | my @path = DC::Pod::full_path_of $node; |
1975 | my @path = DC::Pod::full_path_of $node; |
1948 | pop @path; # drop current node |
1976 | pop @path; # drop current node |
1949 | |
1977 | |
1950 | for my $node (@path) { |
1978 | for my $node (@path) { |
1951 | $buttons->add (new DC::UI::Button |
1979 | $buttons->add (new DC::UI::Button |
1952 | text => $node->{kw}[0], |
1980 | text => $node->[DC::Pod::N_KW][0], |
1953 | tooltip => "go to <i>" . (DC::asxml DC::Pod::full_path $node) . "</i>", |
1981 | tooltip => "go to <i>" . (DC::asxml DC::Pod::full_path $node) . "</i>", |
1954 | on_activate => sub { |
1982 | on_activate => sub { |
1955 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
1983 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
1956 | $load_node->($node); |
1984 | $load_node->($node); |
1957 | }, |
1985 | }, |
1958 | ); |
1986 | ); |
1959 | $buttons->add (new DC::UI::Label text => "/"); |
1987 | $buttons->add (new DC::UI::Label text => "/"); |
1960 | } |
1988 | } |
1961 | |
1989 | |
1962 | $buttons->add (new DC::UI::Label text => $node->{kw}[0], padding_x => 4, padding_y => 4); |
1990 | $buttons->add (new DC::UI::Label text => $node->[DC::Pod::N_KW][0], padding_x => 4, padding_y => 4); |
1963 | |
1991 | |
1964 | $curnode = $node; |
1992 | $curnode = $node; |
1965 | |
1993 | |
1966 | $viewer->clear; |
1994 | $viewer->clear; |
1967 | $viewer->add_paragraph (DC::Pod::as_paragraphs DC::Pod::section_of $curnode); |
1995 | $viewer->add_paragraph (DC::Pod::as_paragraphs DC::Pod::section_of $curnode); |
… | |
… | |
2146 | force_x => "max", |
2174 | force_x => "max", |
2147 | force_y => 0; |
2175 | force_y => 0; |
2148 | $DEBUG_STATUS->show; |
2176 | $DEBUG_STATUS->show; |
2149 | |
2177 | |
2150 | $STATUSBOX = new DC::UI::Statusbox; |
2178 | $STATUSBOX = new DC::UI::Statusbox; |
2151 | $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", timeout => 864000, pri => -100, color => [1, 1, 1, 0.8]); |
2179 | |
|
|
2180 | $MODBOX = new DC::UI::Label |
|
|
2181 | can_events => 1, |
|
|
2182 | can_hover => 1, |
|
|
2183 | markup => "", |
|
|
2184 | align => 0, |
|
|
2185 | font => $FONT_FIXED, |
|
|
2186 | tooltip => "#modifier_box", |
|
|
2187 | tooltip_width => 0.67, |
|
|
2188 | ; |
|
|
2189 | |
|
|
2190 | update_modbox; |
2152 | |
2191 | |
2153 | (new DC::UI::Frame |
2192 | (new DC::UI::Frame |
2154 | bg => [0, 0, 0, 0.4], |
2193 | bg => [0, 0, 0, 0.4], |
2155 | force_x => 0, |
2194 | force_x => 0, |
2156 | force_y => "max", |
2195 | force_y => "max", |
2157 | child => $STATUSBOX, |
2196 | child => (my $LR = new DC::UI::VBox), |
2158 | )->show; |
2197 | )->show; |
|
|
2198 | |
|
|
2199 | $LR->add ($STATUSBOX); |
|
|
2200 | $LR->add ($MODBOX); |
|
|
2201 | $LR->add (new DC::UI::Label |
|
|
2202 | align => 0, |
|
|
2203 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode", |
|
|
2204 | fontsize => 0.5, |
|
|
2205 | fg => [1, 1, 0, 0.7], |
|
|
2206 | ); |
2159 | |
2207 | |
2160 | DC::UI::Toplevel->new ( |
2208 | DC::UI::Toplevel->new ( |
2161 | title => "Minimap", |
2209 | title => "Minimap", |
2162 | name => "mapmap", |
2210 | name => "mapmap", |
2163 | x => 0, |
2211 | x => 0, |
… | |
… | |
2194 | force_h => $::HEIGHT * 0.6, |
2242 | force_h => $::HEIGHT * 0.6, |
2195 | has_close_button => 1, |
2243 | has_close_button => 1, |
2196 | ; |
2244 | ; |
2197 | |
2245 | |
2198 | $METASERVER = metaserver_dialog; |
2246 | $METASERVER = metaserver_dialog; |
2199 | $MESSAGE_WINDOW = new DC::UI::Dockbar; |
2247 | $MESSAGE_WINDOW = new DC::UI::Dockbar (title => 'Messages'); |
2200 | $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; |
2248 | $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; |
2201 | |
2249 | |
2202 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new DC::UI::Notebook expand => 1, debug => 1, |
2250 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new DC::UI::Notebook expand => 1, debug => 1, |
2203 | filter => new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); |
2251 | filter => new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); |
2204 | |
2252 | |
… | |
… | |
2225 | $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
2273 | $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
2226 | |
2274 | |
2227 | $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
2275 | $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
2228 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
2276 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
2229 | |
2277 | |
2230 | $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
2278 | # $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
2231 | tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
2279 | # tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
2232 | |
2280 | |
2233 | 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 | 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 |
2234 | |
2282 | |
2235 | $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window, |
2283 | $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window, |
2236 | tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); |
2284 | tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); |
… | |
… | |
2238 | $BUTTONBAR->add (new DC::UI::Button |
2286 | $BUTTONBAR->add (new DC::UI::Button |
2239 | text => "Save Config", |
2287 | text => "Save Config", |
2240 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
2288 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
2241 | on_activate => sub { |
2289 | on_activate => sub { |
2242 | $::CFG->{layout} = DC::UI::get_layout; |
2290 | $::CFG->{layout} = DC::UI::get_layout; |
2243 | DC::write_cfg "$Deliantra::VARDIR/client.cf"; |
2291 | DC::write_cfg; |
2244 | status "Configuration Saved"; |
2292 | status "Configuration Saved"; |
2245 | 0 |
2293 | 0 |
2246 | }, |
2294 | }, |
2247 | ); |
2295 | ); |
2248 | |
2296 | |
… | |
… | |
2345 | # alt-enter |
2393 | # alt-enter |
2346 | $FULLSCREEN_ENABLE->toggle; |
2394 | $FULLSCREEN_ENABLE->toggle; |
2347 | video_shutdown; |
2395 | video_shutdown; |
2348 | video_init; |
2396 | video_init; |
2349 | } else { |
2397 | } else { |
2350 | DC::UI::feed_sdl_key_down_event ($_[0]); |
2398 | &DC::UI::feed_sdl_key_down_event; |
2351 | } |
2399 | } |
|
|
2400 | update_modbox; |
2352 | }, |
2401 | }, |
2353 | DC::SDL_KEYUP => \&DC::UI::feed_sdl_key_up_event, |
2402 | DC::SDL_KEYUP => sub { |
|
|
2403 | &DC::UI::feed_sdl_key_up_event; |
|
|
2404 | update_modbox; |
|
|
2405 | }, |
2354 | DC::SDL_MOUSEMOTION => \&DC::UI::feed_sdl_motion_event, |
2406 | DC::SDL_MOUSEMOTION => \&DC::UI::feed_sdl_motion_event, |
2355 | DC::SDL_MOUSEBUTTONDOWN => \&DC::UI::feed_sdl_button_down_event, |
2407 | DC::SDL_MOUSEBUTTONDOWN => \&DC::UI::feed_sdl_button_down_event, |
2356 | DC::SDL_MOUSEBUTTONUP => \&DC::UI::feed_sdl_button_up_event, |
2408 | DC::SDL_MOUSEBUTTONUP => \&DC::UI::feed_sdl_button_up_event, |
2357 | DC::SDL_USEREVENT => sub { |
2409 | DC::SDL_USEREVENT => sub { |
2358 | if ($_[0]{code} == 1) { |
2410 | if ($_[0]{code} == 1) { |
… | |
… | |
2369 | EV::unloop; |
2421 | EV::unloop; |
2370 | #d# TODO calling exit here hangs the process in some futex |
2422 | #d# TODO calling exit here hangs the process in some futex |
2371 | }; |
2423 | }; |
2372 | |
2424 | |
2373 | { |
2425 | { |
|
|
2426 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
|
|
2427 | |
2374 | if (-e "$Deliantra::VARDIR/client.cf") { |
2428 | if (-e "$Deliantra::VARDIR/client.cf") { |
2375 | DC::read_cfg "$Deliantra::VARDIR/client.cf"; |
2429 | DC::read_cfg "$Deliantra::VARDIR/client.cf"; |
2376 | } else { |
2430 | } else { |
2377 | #TODO: compatibility cruft |
2431 | #TODO: compatibility cruft |
2378 | DC::read_cfg "$Deliantra::OLDDIR/cfplusrc"; |
2432 | DC::read_cfg "$Deliantra::OLDDIR/cfplusrc"; |
2379 | print STDERR "INFO: used old configuratrion file\n"; |
2433 | print STDERR "INFO: used old configuration file\n"; |
2380 | } |
2434 | } |
2381 | |
2435 | |
2382 | DC::DB::Server::run; |
2436 | DC::DB::Server::run; |
|
|
2437 | |
|
|
2438 | if ($CFG->{db_schema} < 1) { |
|
|
2439 | warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; |
|
|
2440 | DC::DB::nuke_db; |
|
|
2441 | $CFG->{db_schema} = 1; |
|
|
2442 | DC::write_cfg; |
|
|
2443 | } |
|
|
2444 | |
|
|
2445 | DC::DB::open_db; |
2383 | |
2446 | |
2384 | DC::UI::set_layout ($::CFG->{layout}); |
2447 | DC::UI::set_layout ($::CFG->{layout}); |
2385 | |
2448 | |
2386 | my %DEF_CFG = ( |
2449 | my %DEF_CFG = ( |
2387 | sdl_mode => 0, |
2450 | sdl_mode => 0, |
… | |
… | |
2457 | DejaVuSansMono-BoldOblique.ttf |
2520 | DejaVuSansMono-BoldOblique.ttf |
2458 | ); |
2521 | ); |
2459 | |
2522 | |
2460 | DC::add_font $_ for @fonts; |
2523 | DC::add_font $_ for @fonts; |
2461 | |
2524 | |
2462 | DC::pango_init; |
|
|
2463 | |
|
|
2464 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2525 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2465 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2526 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2466 | |
2527 | |
2467 | $FONT_PROP->make_default; |
2528 | $FONT_PROP->make_default; |
|
|
2529 | |
|
|
2530 | DC::pango_init; |
2468 | } |
2531 | } |
2469 | |
2532 | |
2470 | # compare mono (ft) vs. rgba (cairo) |
2533 | # compare mono (ft) vs. rgba (cairo) |
2471 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
2534 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
2472 | # for my $rgba (0..1) { |
2535 | # for my $rgba (0..1) { |
… | |
… | |
2489 | our $STARTUP_CANCEL = EV::idle sub { |
2552 | our $STARTUP_CANCEL = EV::idle sub { |
2490 | undef $::STARTUP_CANCEL; |
2553 | undef $::STARTUP_CANCEL; |
2491 | $startup_done->(); |
2554 | $startup_done->(); |
2492 | }; |
2555 | }; |
2493 | |
2556 | |
|
|
2557 | delete $SIG{__DIE__}; |
2494 | EV::loop; |
2558 | EV::loop; |
2495 | |
2559 | |
2496 | #video_shutdown; |
2560 | #video_shutdown; |
2497 | #audio_shutdown; |
2561 | #audio_shutdown; |
2498 | DC::OpenGL::quit; |
2562 | DC::OpenGL::quit; |