… | |
… | |
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 | BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } } |
105 | use DC::OpenGL (); |
106 | use DC::OpenGL (); |
106 | use DC::Protocol; |
107 | use DC::Protocol; |
107 | use DC::DB; |
108 | use DC::DB; |
108 | use DC::UI; |
109 | use DC::UI; |
109 | use DC::UI::Canvas; |
110 | use DC::UI::Canvas; |
… | |
… | |
664 | # right: accept |
665 | # right: accept |
665 | $table->add_at (4, 0, new DC::UI::Button |
666 | $table->add_at (4, 0, new DC::UI::Button |
666 | text => "Accept", |
667 | text => "Accept", |
667 | on_activate => sub { |
668 | on_activate => sub { |
668 | $conn->send ("reply n"); |
669 | $conn->send ("reply n"); |
669 | $STATS_PAGE->hide; |
|
|
670 | destroy_query_dialog $conn; |
670 | destroy_query_dialog $conn; |
671 | 0 |
671 | 0 |
672 | }, |
672 | }, |
673 | ); |
673 | ); |
674 | |
674 | |
… | |
… | |
738 | |
738 | |
739 | my ($host, $port) = split /:/, $PROFILE->{host}; |
739 | my ($host, $port) = split /:/, $PROFILE->{host}; |
740 | |
740 | |
741 | $MAP = new DC::Map; |
741 | $MAP = new DC::Map; |
742 | |
742 | |
743 | $CONN = eval { |
743 | $CONN = |
744 | new DC::Protocol |
744 | new DC::Protocol |
745 | host => $host, |
745 | host => $host, |
746 | port => $port || 13327, |
746 | port => $port || 13327, |
747 | user => $PROFILE->{user}, |
747 | user => $PROFILE->{user}, |
748 | pass => $PROFILE->{password}, |
748 | pass => $PROFILE->{password}, |
… | |
… | |
758 | query => \&server_query, |
758 | query => \&server_query, |
759 | |
759 | |
760 | setup_req => { |
760 | setup_req => { |
761 | smoothing => $CFG->{map_smoothing}*1, |
761 | smoothing => $CFG->{map_smoothing}*1, |
762 | }, |
762 | }, |
763 | }; |
|
|
764 | |
763 | |
765 | if ($CONN) { |
764 | on_connect => sub { |
|
|
765 | if ($_[0]) { |
766 | DC::lowdelay fileno $CONN->{fh}; |
766 | DC::lowdelay fileno $CONN->{fh}; |
767 | |
767 | |
768 | status "login successful"; |
768 | status "login successful"; |
769 | } else { |
769 | } else { |
770 | warn $@; |
770 | undef $CONN; |
771 | status "unable to connect"; |
771 | status "unable to connect: $!"; |
772 | stop_game(); |
772 | stop_game(); |
|
|
773 | } |
|
|
774 | }, |
773 | } |
775 | ; |
774 | } |
776 | } |
775 | |
777 | |
776 | sub stop_game { |
778 | sub stop_game { |
777 | $LOGIN_BUTTON->set_text ("Login / Register"); |
779 | $LOGIN_BUTTON->set_text ("Login / Register"); |
778 | $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN); |
780 | $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN); |
… | |
… | |
1621 | $CFG->{show_tips} = $value; |
1623 | $CFG->{show_tips} = $value; |
1622 | 0 |
1624 | 0 |
1623 | } |
1625 | } |
1624 | ); |
1626 | ); |
1625 | |
1627 | |
1626 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Messages Window Size"); |
1628 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Window Size"); |
1627 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
1629 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
1628 | text => $CFG->{logview_max_par}, |
1630 | text => $CFG->{logview_max_par}, |
1629 | tooltip => "This is maximum number of messages remembered in the <b>Messages</b> window. If the server " |
1631 | tooltip => "This is maximum number of messages remembered in the <b>Message</b> window. If the server " |
1630 | . "sends more messages than this number, older messages get removed to save memory and " |
1632 | . "sends more messages than this number, older messages get removed to save memory and " |
1631 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1633 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1632 | on_changed => sub { |
1634 | on_changed => sub { |
1633 | my ($self, $value) = @_; |
1635 | my ($self, $value) = @_; |
1634 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
1636 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
… | |
… | |
1743 | |
1745 | |
1744 | $r |
1746 | $r |
1745 | } |
1747 | } |
1746 | |
1748 | |
1747 | my %SORT_ORDER = ( |
1749 | my %SORT_ORDER = ( |
1748 | type => undef, |
1750 | type => sub { |
|
|
1751 | sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ |
|
|
1752 | }, |
1749 | mtime => sub { |
1753 | mtime => sub { |
1750 | my $NOW = time; |
1754 | my $NOW = time; |
1751 | sort { |
1755 | sort { |
1752 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
1756 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
1753 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
1757 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
… | |
… | |
2242 | force_h => $::HEIGHT * 0.6, |
2246 | force_h => $::HEIGHT * 0.6, |
2243 | has_close_button => 1, |
2247 | has_close_button => 1, |
2244 | ; |
2248 | ; |
2245 | |
2249 | |
2246 | $METASERVER = metaserver_dialog; |
2250 | $METASERVER = metaserver_dialog; |
2247 | $MESSAGE_WINDOW = new DC::UI::Dockbar (name => 'message_window', title => 'Messages'); |
2251 | # the name is changed to not conflict with the older name as users could have hidden it |
|
|
2252 | $MESSAGE_WINDOW = new DC::UI::Dockbar |
|
|
2253 | name => "message_window2", |
|
|
2254 | title => 'Messages', |
|
|
2255 | force_w => $::WIDTH * 0.6, |
|
|
2256 | force_h => $::HEIGHT * 0.25, |
|
|
2257 | ; |
|
|
2258 | |
2248 | $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; |
2259 | $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; |
2249 | |
2260 | |
2250 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new DC::UI::Notebook expand => 1, debug => 1, |
2261 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new DC::UI::Notebook expand => 1, |
2251 | filter => new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); |
2262 | filter => new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); |
2252 | |
2263 | |
2253 | $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup, |
2264 | $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup, |
2254 | "Configure the server to play on, your username and password."); |
2265 | "Configure the server to play on, your username and password."); |
2255 | $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup, |
2266 | $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup, |
… | |
… | |
2273 | $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
2284 | $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
2274 | |
2285 | |
2275 | $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
2286 | $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
2276 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
2287 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
2277 | |
2288 | |
2278 | $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
2289 | # $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
2279 | tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
2290 | # tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
2280 | |
2291 | |
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 |
2292 | 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 |
2282 | |
2293 | |
2283 | $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window, |
2294 | $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window, |
2284 | tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); |
2295 | tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); |
… | |
… | |
2294 | }, |
2305 | }, |
2295 | ); |
2306 | ); |
2296 | |
2307 | |
2297 | $BUTTONBAR->add (new DC::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, |
2308 | $BUTTONBAR->add (new DC::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, |
2298 | tooltip => "View Documentation"); |
2309 | tooltip => "View Documentation"); |
2299 | |
|
|
2300 | |
2310 | |
2301 | $BUTTONBAR->add (new DC::UI::Button |
2311 | $BUTTONBAR->add (new DC::UI::Button |
2302 | text => "Quit", |
2312 | text => "Quit", |
2303 | tooltip => "Terminates the program", |
2313 | tooltip => "Terminates the program", |
2304 | on_activate => sub { |
2314 | on_activate => sub { |
… | |
… | |
2475 | pickup => 0, |
2485 | pickup => 0, |
2476 | inv_sort => "mtime", |
2486 | inv_sort => "mtime", |
2477 | default => "profile", # default profile |
2487 | default => "profile", # default profile |
2478 | show_tips => 1, |
2488 | show_tips => 1, |
2479 | logview_max_par => 1000, |
2489 | logview_max_par => 1000, |
|
|
2490 | shift_fire_stop => 0, |
2480 | ); |
2491 | ); |
2481 | |
2492 | |
2482 | while (my ($k, $v) = each %DEF_CFG) { |
2493 | while (my ($k, $v) = each %DEF_CFG) { |
2483 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2494 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2484 | } |
2495 | } |