… | |
… | |
97 | use List::Util qw(max min); |
97 | use List::Util qw(max min); |
98 | |
98 | |
99 | use Deliantra; |
99 | use Deliantra; |
100 | use Deliantra::Protocol::Constants; |
100 | use Deliantra::Protocol::Constants; |
101 | |
101 | |
|
|
102 | use AnyEvent::DNS; |
|
|
103 | use AnyEvent::Socket (); |
|
|
104 | |
102 | use Compress::LZF; |
105 | use Compress::LZF; |
103 | |
106 | |
104 | use DC; |
107 | use DC; |
|
|
108 | BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } } |
105 | use DC::OpenGL (); |
109 | use DC::OpenGL (); |
106 | use DC::Protocol; |
110 | use DC::Protocol; |
107 | use DC::DB; |
111 | use DC::DB; |
108 | use DC::UI; |
112 | use DC::UI; |
109 | use DC::UI::Canvas; |
113 | use DC::UI::Canvas; |
… | |
… | |
190 | our $SDL_ACTIVE; |
194 | our $SDL_ACTIVE; |
191 | our %SDL_CB; |
195 | our %SDL_CB; |
192 | |
196 | |
193 | our $ALT_ENTER_MESSAGE; |
197 | our $ALT_ENTER_MESSAGE; |
194 | our $STATUSBOX; |
198 | our $STATUSBOX; |
|
|
199 | our $MODBOX; |
195 | our $DEBUG_STATUS; |
200 | our $DEBUG_STATUS; |
196 | |
201 | |
197 | our $INV; |
202 | our $INV; |
198 | our $INVR; |
203 | our $INVR; |
199 | our $INVR_HB; |
204 | our $INVR_HB; |
… | |
… | |
208 | $DEBUG_STATUS->set_text ($_[0]); |
213 | $DEBUG_STATUS->set_text ($_[0]); |
209 | } |
214 | } |
210 | |
215 | |
211 | sub message { |
216 | sub message { |
212 | $MESSAGE_DIST->message (@_); |
217 | $MESSAGE_DIST->message (@_); |
|
|
218 | } |
|
|
219 | |
|
|
220 | sub update_modbox { |
|
|
221 | my $mod = DC::SDL_GetModState; |
|
|
222 | |
|
|
223 | my $markup; |
|
|
224 | |
|
|
225 | $markup .= $mod & DC::KMOD_CTRL |
|
|
226 | ? ($MAPWIDGET->{ctrl} ? "[REPEAT]" : "[<span foreground='#888'>REPEAT</span>]") |
|
|
227 | : "[<span foreground='#888'> once </span>]"; |
|
|
228 | |
|
|
229 | $markup .= $mod & DC::KMOD_SHIFT |
|
|
230 | ? ($MAPWIDGET->{shft} ? "[FIRE]" : "[<span foreground='#888'>FIRE</span>]") |
|
|
231 | : "[<span foreground='#888'>move</span>]"; |
|
|
232 | |
|
|
233 | $markup .= $mod & (DC::KMOD_ALT | DC::KMOD_META) |
|
|
234 | ? "[ALT]" |
|
|
235 | : "[<span foreground='#888'>alt</span>]"; |
|
|
236 | |
|
|
237 | $markup .= $mod & DC::KMOD_NUM |
|
|
238 | ? "[NUM]" |
|
|
239 | : "[<span foreground='#888'>num</span>]"; |
|
|
240 | |
|
|
241 | # <tt> around next statement works around some bug that keeps the |
|
|
242 | # "font =>" from being used on windows |
|
|
243 | $MODBOX->set_markup ("<tt>$markup</tt>"); |
213 | } |
244 | } |
214 | |
245 | |
215 | ############################################################################# |
246 | ############################################################################# |
216 | #TODO: maybe move into own audio module... |
247 | #TODO: maybe move into own audio module... |
217 | |
248 | |
… | |
… | |
637 | # right: accept |
668 | # right: accept |
638 | $table->add_at (4, 0, new DC::UI::Button |
669 | $table->add_at (4, 0, new DC::UI::Button |
639 | text => "Accept", |
670 | text => "Accept", |
640 | on_activate => sub { |
671 | on_activate => sub { |
641 | $conn->send ("reply n"); |
672 | $conn->send ("reply n"); |
642 | $STATS_PAGE->hide; |
|
|
643 | destroy_query_dialog $conn; |
673 | destroy_query_dialog $conn; |
644 | 0 |
674 | 0 |
645 | }, |
675 | }, |
646 | ); |
676 | ); |
647 | |
677 | |
… | |
… | |
699 | |
729 | |
700 | $vbox->add (@dialog); |
730 | $vbox->add (@dialog); |
701 | $dialog->show; |
731 | $dialog->show; |
702 | } |
732 | } |
703 | |
733 | |
704 | sub start_game { |
734 | sub dc_connect { |
705 | status "logging in..."; |
735 | my ($host, $port) = @_; |
706 | |
|
|
707 | $LOGIN_BUTTON->set_text ("Logout"); |
|
|
708 | $SETUP_DIALOG->hide; |
|
|
709 | |
736 | |
710 | my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
737 | my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
711 | |
738 | |
712 | my ($host, $port) = split /:/, $PROFILE->{host}; |
|
|
713 | |
|
|
714 | $MAP = new DC::Map; |
|
|
715 | |
|
|
716 | $CONN = eval { |
739 | $CONN = |
717 | new DC::Protocol |
740 | new DC::Protocol |
718 | host => $host, |
741 | host => $host, |
719 | port => $port || 13327, |
742 | port => $port, |
720 | user => $PROFILE->{user}, |
743 | user => $PROFILE->{user}, |
721 | pass => $PROFILE->{password}, |
744 | pass => $PROFILE->{password}, |
722 | mapw => $mapsize, |
745 | mapw => $mapsize, |
723 | maph => $mapsize, |
746 | maph => $mapsize, |
724 | |
747 | |
… | |
… | |
731 | query => \&server_query, |
754 | query => \&server_query, |
732 | |
755 | |
733 | setup_req => { |
756 | setup_req => { |
734 | smoothing => $CFG->{map_smoothing}*1, |
757 | smoothing => $CFG->{map_smoothing}*1, |
735 | }, |
758 | }, |
736 | }; |
|
|
737 | |
759 | |
738 | if ($CONN) { |
760 | on_connect => sub { |
|
|
761 | if ($_[0]) { |
739 | DC::lowdelay fileno $CONN->{fh}; |
762 | DC::lowdelay fileno $CONN->{fh}; |
740 | |
763 | |
741 | status "login successful"; |
764 | status "login successful"; |
|
|
765 | } else { |
|
|
766 | undef $CONN; |
|
|
767 | status "unable to connect: $!"; |
|
|
768 | stop_game(); |
|
|
769 | } |
|
|
770 | }, |
|
|
771 | ; |
|
|
772 | } |
|
|
773 | |
|
|
774 | sub start_game { |
|
|
775 | status "logging in..."; |
|
|
776 | |
|
|
777 | $LOGIN_BUTTON->set_text ("Logout"); |
|
|
778 | $SETUP_DIALOG->hide; |
|
|
779 | |
|
|
780 | my ($host, $port) = AnyEvent::Socket::parse_hostport $PROFILE->{host}, "deliantra=13327"; |
|
|
781 | |
|
|
782 | $MAP = new DC::Map; |
|
|
783 | |
|
|
784 | # hack to make SURE we find the IP address all right |
|
|
785 | # can be removed once AnyEvent::DNS is proven stable. |
|
|
786 | if ($host eq "gameserver.deliantra.net") { |
|
|
787 | AnyEvent::DNS::a "dnstest.deliantra.net", sub { |
|
|
788 | if ($_[0] ne "80.101.114.108") { # Perl |
|
|
789 | status "dns failure, using hardcoded address"; |
|
|
790 | $host = "129.13.162.95"; |
|
|
791 | } |
|
|
792 | |
|
|
793 | dc_connect $host, $port; |
|
|
794 | }; |
742 | } else { |
795 | } else { |
743 | status "unable to connect"; |
796 | dc_connect $host, $port; |
744 | stop_game(); |
|
|
745 | } |
797 | } |
746 | } |
798 | } |
747 | |
799 | |
748 | sub stop_game { |
800 | sub stop_game { |
749 | $LOGIN_BUTTON->set_text ("Login / Register"); |
801 | $LOGIN_BUTTON->set_text ("Login / Register"); |
… | |
… | |
1528 | |
1580 | |
1529 | $vbox->add ( |
1581 | $vbox->add ( |
1530 | $HOST_ENTRY = new DC::UI::Entry |
1582 | $HOST_ENTRY = new DC::UI::Entry |
1531 | expand => 1, |
1583 | expand => 1, |
1532 | text => $CFG->{profile}{default}{host}, |
1584 | text => $CFG->{profile}{default}{host}, |
1533 | tooltip => "The hostname or ip address of the Deliantra server to connect to", |
1585 | tooltip => "The hostname or ip address of the Deliantra server to connect to (e.g. <b>gameserver.deliantra.net</b>)", |
1534 | on_changed => sub { |
1586 | on_changed => sub { |
1535 | my ($self, $value) = @_; |
1587 | my ($self, $value) = @_; |
1536 | $CFG->{profile}{default}{host} = $value; |
1588 | $CFG->{profile}{default}{host} = $value; |
1537 | 1 |
1589 | 1 |
1538 | } |
1590 | } |
… | |
… | |
1541 | if (0) { #d# disabled |
1593 | if (0) { #d# disabled |
1542 | $vbox->add (new DC::UI::Button |
1594 | $vbox->add (new DC::UI::Button |
1543 | expand => 1, |
1595 | expand => 1, |
1544 | text => "Server List", |
1596 | text => "Server List", |
1545 | other => $METASERVER, |
1597 | other => $METASERVER, |
1546 | tooltip => "Show a list of available crossfire servers", |
1598 | tooltip => "Show a list of available Deliantra servers", |
1547 | on_activate => sub { $METASERVER->toggle_visibility; 0 }, |
1599 | on_activate => sub { $METASERVER->toggle_visibility; 0 }, |
1548 | on_visibility_change => sub { $METASERVER->hide unless $_[1]; 1 }, |
1600 | on_visibility_change => sub { $METASERVER->hide unless $_[1]; 1 }, |
1549 | ); |
1601 | ); |
1550 | }#d# |
1602 | }#d# |
1551 | } |
1603 | } |
… | |
… | |
1593 | $CFG->{show_tips} = $value; |
1645 | $CFG->{show_tips} = $value; |
1594 | 0 |
1646 | 0 |
1595 | } |
1647 | } |
1596 | ); |
1648 | ); |
1597 | |
1649 | |
1598 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Messages Window Size"); |
1650 | $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 |
1651 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
1600 | text => $CFG->{logview_max_par}, |
1652 | text => $CFG->{logview_max_par}, |
1601 | tooltip => "This is maximum number of messages remembered in the <b>Messages</b> window. If the server " |
1653 | 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 " |
1654 | . "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.", |
1655 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1604 | on_changed => sub { |
1656 | on_changed => sub { |
1605 | my ($self, $value) = @_; |
1657 | my ($self, $value) = @_; |
1606 | $MESSAGE_DIST->set_max_para ($CFG->{logview_max_par} = $value*1); |
1658 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
1607 | 0 |
1659 | 0 |
1608 | }, |
1660 | }, |
1609 | ); |
1661 | ); |
1610 | |
1662 | |
1611 | $table |
1663 | $table |
… | |
… | |
1715 | |
1767 | |
1716 | $r |
1768 | $r |
1717 | } |
1769 | } |
1718 | |
1770 | |
1719 | my %SORT_ORDER = ( |
1771 | my %SORT_ORDER = ( |
1720 | type => undef, |
1772 | type => sub { |
|
|
1773 | sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ |
|
|
1774 | }, |
1721 | mtime => sub { |
1775 | mtime => sub { |
1722 | my $NOW = time; |
1776 | my $NOW = time; |
1723 | sort { |
1777 | sort { |
1724 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
1778 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
1725 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
1779 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
… | |
… | |
1947 | my @path = DC::Pod::full_path_of $node; |
2001 | my @path = DC::Pod::full_path_of $node; |
1948 | pop @path; # drop current node |
2002 | pop @path; # drop current node |
1949 | |
2003 | |
1950 | for my $node (@path) { |
2004 | for my $node (@path) { |
1951 | $buttons->add (new DC::UI::Button |
2005 | $buttons->add (new DC::UI::Button |
1952 | text => $node->{kw}[0], |
2006 | text => $node->[DC::Pod::N_KW][0], |
1953 | tooltip => "go to <i>" . (DC::asxml DC::Pod::full_path $node) . "</i>", |
2007 | tooltip => "go to <i>" . (DC::asxml DC::Pod::full_path $node) . "</i>", |
1954 | on_activate => sub { |
2008 | on_activate => sub { |
1955 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
2009 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
1956 | $load_node->($node); |
2010 | $load_node->($node); |
1957 | }, |
2011 | }, |
1958 | ); |
2012 | ); |
1959 | $buttons->add (new DC::UI::Label text => "/"); |
2013 | $buttons->add (new DC::UI::Label text => "/"); |
1960 | } |
2014 | } |
1961 | |
2015 | |
1962 | $buttons->add (new DC::UI::Label text => $node->{kw}[0], padding_x => 4, padding_y => 4); |
2016 | $buttons->add (new DC::UI::Label text => $node->[DC::Pod::N_KW][0], padding_x => 4, padding_y => 4); |
1963 | |
2017 | |
1964 | $curnode = $node; |
2018 | $curnode = $node; |
1965 | |
2019 | |
1966 | $viewer->clear; |
2020 | $viewer->clear; |
1967 | $viewer->add_paragraph (DC::Pod::as_paragraphs DC::Pod::section_of $curnode); |
2021 | $viewer->add_paragraph (DC::Pod::as_paragraphs DC::Pod::section_of $curnode); |
… | |
… | |
2146 | force_x => "max", |
2200 | force_x => "max", |
2147 | force_y => 0; |
2201 | force_y => 0; |
2148 | $DEBUG_STATUS->show; |
2202 | $DEBUG_STATUS->show; |
2149 | |
2203 | |
2150 | $STATUSBOX = new DC::UI::Statusbox; |
2204 | $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]); |
2205 | |
|
|
2206 | $MODBOX = new DC::UI::Label |
|
|
2207 | can_events => 1, |
|
|
2208 | can_hover => 1, |
|
|
2209 | markup => "", |
|
|
2210 | align => 0, |
|
|
2211 | font => $FONT_FIXED, |
|
|
2212 | tooltip => "#modifier_box", |
|
|
2213 | tooltip_width => 0.67, |
|
|
2214 | ; |
|
|
2215 | |
|
|
2216 | update_modbox; |
2152 | |
2217 | |
2153 | (new DC::UI::Frame |
2218 | (new DC::UI::Frame |
2154 | bg => [0, 0, 0, 0.4], |
2219 | bg => [0, 0, 0, 0.4], |
2155 | force_x => 0, |
2220 | force_x => 0, |
2156 | force_y => "max", |
2221 | force_y => "max", |
2157 | child => $STATUSBOX, |
2222 | child => (my $LR = new DC::UI::VBox), |
2158 | )->show; |
2223 | )->show; |
|
|
2224 | |
|
|
2225 | $LR->add ($STATUSBOX); |
|
|
2226 | $LR->add ($MODBOX); |
|
|
2227 | $LR->add (new DC::UI::Label |
|
|
2228 | align => 0, |
|
|
2229 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode", |
|
|
2230 | fontsize => 0.5, |
|
|
2231 | fg => [1, 1, 0, 0.7], |
|
|
2232 | ); |
2159 | |
2233 | |
2160 | DC::UI::Toplevel->new ( |
2234 | DC::UI::Toplevel->new ( |
2161 | title => "Minimap", |
2235 | title => "Minimap", |
2162 | name => "mapmap", |
2236 | name => "mapmap", |
2163 | x => 0, |
2237 | x => 0, |
… | |
… | |
2194 | force_h => $::HEIGHT * 0.6, |
2268 | force_h => $::HEIGHT * 0.6, |
2195 | has_close_button => 1, |
2269 | has_close_button => 1, |
2196 | ; |
2270 | ; |
2197 | |
2271 | |
2198 | $METASERVER = metaserver_dialog; |
2272 | $METASERVER = metaserver_dialog; |
2199 | $MESSAGE_WINDOW = new DC::UI::Dockbar (name => 'message_window', title => 'Messages'); |
2273 | # the name is changed to not conflict with the older name as users could have hidden it |
|
|
2274 | $MESSAGE_WINDOW = new DC::UI::Dockbar |
|
|
2275 | name => "message_window2", |
|
|
2276 | title => 'Messages', |
|
|
2277 | force_w => $::WIDTH * 0.6, |
|
|
2278 | force_h => $::HEIGHT * 0.25, |
|
|
2279 | ; |
|
|
2280 | |
2200 | $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; |
2281 | $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; |
2201 | |
2282 | |
2202 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new DC::UI::Notebook expand => 1, debug => 1, |
2283 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new DC::UI::Notebook expand => 1, |
2203 | filter => new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); |
2284 | filter => new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); |
2204 | |
2285 | |
2205 | $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup, |
2286 | $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup, |
2206 | "Configure the server to play on, your username and password."); |
2287 | "Configure the server to play on, your username and password."); |
2207 | $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup, |
2288 | $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup, |
… | |
… | |
2225 | $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
2306 | $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
2226 | |
2307 | |
2227 | $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
2308 | $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."); |
2309 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
2229 | |
2310 | |
2230 | $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
2311 | # $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."); |
2312 | # tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
2232 | |
2313 | |
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 |
2314 | 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 | |
2315 | |
2235 | $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window, |
2316 | $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."); |
2317 | tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); |
… | |
… | |
2238 | $BUTTONBAR->add (new DC::UI::Button |
2319 | $BUTTONBAR->add (new DC::UI::Button |
2239 | text => "Save Config", |
2320 | 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.", |
2321 | 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 { |
2322 | on_activate => sub { |
2242 | $::CFG->{layout} = DC::UI::get_layout; |
2323 | $::CFG->{layout} = DC::UI::get_layout; |
2243 | DC::write_cfg "$Deliantra::VARDIR/client.cf"; |
2324 | DC::write_cfg; |
2244 | status "Configuration Saved"; |
2325 | status "Configuration Saved"; |
2245 | 0 |
2326 | 0 |
2246 | }, |
2327 | }, |
2247 | ); |
2328 | ); |
2248 | |
2329 | |
2249 | $BUTTONBAR->add (new DC::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, |
2330 | $BUTTONBAR->add (new DC::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, |
2250 | tooltip => "View Documentation"); |
2331 | tooltip => "View Documentation"); |
2251 | |
|
|
2252 | |
2332 | |
2253 | $BUTTONBAR->add (new DC::UI::Button |
2333 | $BUTTONBAR->add (new DC::UI::Button |
2254 | text => "Quit", |
2334 | text => "Quit", |
2255 | tooltip => "Terminates the program", |
2335 | tooltip => "Terminates the program", |
2256 | on_activate => sub { |
2336 | on_activate => sub { |
… | |
… | |
2345 | # alt-enter |
2425 | # alt-enter |
2346 | $FULLSCREEN_ENABLE->toggle; |
2426 | $FULLSCREEN_ENABLE->toggle; |
2347 | video_shutdown; |
2427 | video_shutdown; |
2348 | video_init; |
2428 | video_init; |
2349 | } else { |
2429 | } else { |
2350 | DC::UI::feed_sdl_key_down_event ($_[0]); |
2430 | &DC::UI::feed_sdl_key_down_event; |
2351 | } |
2431 | } |
|
|
2432 | update_modbox; |
2352 | }, |
2433 | }, |
2353 | DC::SDL_KEYUP => \&DC::UI::feed_sdl_key_up_event, |
2434 | DC::SDL_KEYUP => sub { |
|
|
2435 | &DC::UI::feed_sdl_key_up_event; |
|
|
2436 | update_modbox; |
|
|
2437 | }, |
2354 | DC::SDL_MOUSEMOTION => \&DC::UI::feed_sdl_motion_event, |
2438 | DC::SDL_MOUSEMOTION => \&DC::UI::feed_sdl_motion_event, |
2355 | DC::SDL_MOUSEBUTTONDOWN => \&DC::UI::feed_sdl_button_down_event, |
2439 | DC::SDL_MOUSEBUTTONDOWN => \&DC::UI::feed_sdl_button_down_event, |
2356 | DC::SDL_MOUSEBUTTONUP => \&DC::UI::feed_sdl_button_up_event, |
2440 | DC::SDL_MOUSEBUTTONUP => \&DC::UI::feed_sdl_button_up_event, |
2357 | DC::SDL_USEREVENT => sub { |
2441 | DC::SDL_USEREVENT => sub { |
2358 | if ($_[0]{code} == 1) { |
2442 | if ($_[0]{code} == 1) { |
… | |
… | |
2369 | EV::unloop; |
2453 | EV::unloop; |
2370 | #d# TODO calling exit here hangs the process in some futex |
2454 | #d# TODO calling exit here hangs the process in some futex |
2371 | }; |
2455 | }; |
2372 | |
2456 | |
2373 | { |
2457 | { |
|
|
2458 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
|
|
2459 | |
2374 | if (-e "$Deliantra::VARDIR/client.cf") { |
2460 | if (-e "$Deliantra::VARDIR/client.cf") { |
2375 | DC::read_cfg "$Deliantra::VARDIR/client.cf"; |
2461 | DC::read_cfg "$Deliantra::VARDIR/client.cf"; |
2376 | } else { |
2462 | } else { |
2377 | #TODO: compatibility cruft |
2463 | #TODO: compatibility cruft |
2378 | DC::read_cfg "$Deliantra::OLDDIR/cfplusrc"; |
2464 | DC::read_cfg "$Deliantra::OLDDIR/cfplusrc"; |
2379 | print STDERR "INFO: used old configuration file\n"; |
2465 | print STDERR "INFO: used old configuration file\n"; |
2380 | } |
2466 | } |
2381 | |
2467 | |
2382 | DC::DB::Server::run; |
2468 | DC::DB::Server::run; |
|
|
2469 | |
|
|
2470 | if ($CFG->{db_schema} < 1) { |
|
|
2471 | warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; |
|
|
2472 | DC::DB::nuke_db; |
|
|
2473 | $CFG->{db_schema} = 1; |
|
|
2474 | DC::write_cfg; |
|
|
2475 | } |
|
|
2476 | |
|
|
2477 | DC::DB::open_db; |
2383 | |
2478 | |
2384 | DC::UI::set_layout ($::CFG->{layout}); |
2479 | DC::UI::set_layout ($::CFG->{layout}); |
2385 | |
2480 | |
2386 | my %DEF_CFG = ( |
2481 | my %DEF_CFG = ( |
2387 | sdl_mode => 0, |
2482 | sdl_mode => 0, |
… | |
… | |
2412 | pickup => 0, |
2507 | pickup => 0, |
2413 | inv_sort => "mtime", |
2508 | inv_sort => "mtime", |
2414 | default => "profile", # default profile |
2509 | default => "profile", # default profile |
2415 | show_tips => 1, |
2510 | show_tips => 1, |
2416 | logview_max_par => 1000, |
2511 | logview_max_par => 1000, |
|
|
2512 | shift_fire_stop => 0, |
2417 | ); |
2513 | ); |
2418 | |
2514 | |
2419 | while (my ($k, $v) = each %DEF_CFG) { |
2515 | while (my ($k, $v) = each %DEF_CFG) { |
2420 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2516 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2421 | } |
2517 | } |
… | |
… | |
2457 | DejaVuSansMono-BoldOblique.ttf |
2553 | DejaVuSansMono-BoldOblique.ttf |
2458 | ); |
2554 | ); |
2459 | |
2555 | |
2460 | DC::add_font $_ for @fonts; |
2556 | DC::add_font $_ for @fonts; |
2461 | |
2557 | |
2462 | DC::pango_init; |
|
|
2463 | |
|
|
2464 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2558 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2465 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2559 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2466 | |
2560 | |
2467 | $FONT_PROP->make_default; |
2561 | $FONT_PROP->make_default; |
|
|
2562 | |
|
|
2563 | DC::pango_init; |
2468 | } |
2564 | } |
2469 | |
2565 | |
2470 | # compare mono (ft) vs. rgba (cairo) |
2566 | # compare mono (ft) vs. rgba (cairo) |
2471 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
2567 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
2472 | # for my $rgba (0..1) { |
2568 | # for my $rgba (0..1) { |
… | |
… | |
2489 | our $STARTUP_CANCEL = EV::idle sub { |
2585 | our $STARTUP_CANCEL = EV::idle sub { |
2490 | undef $::STARTUP_CANCEL; |
2586 | undef $::STARTUP_CANCEL; |
2491 | $startup_done->(); |
2587 | $startup_done->(); |
2492 | }; |
2588 | }; |
2493 | |
2589 | |
|
|
2590 | delete $SIG{__DIE__}; |
2494 | EV::loop; |
2591 | EV::loop; |
2495 | |
2592 | |
2496 | #video_shutdown; |
2593 | #video_shutdown; |
2497 | #audio_shutdown; |
2594 | #audio_shutdown; |
2498 | DC::OpenGL::quit; |
2595 | DC::OpenGL::quit; |