Deliantra-Client
view release on metacpan or search on metacpan
bin/deliantra view on Meta::CPAN
sub open_quit_dialog {
unless ($QUIT_DIALOG) {
$QUIT_DIALOG = new DC::UI::Toplevel
x => "center",
y => "center",
z => 50,
title => "Really Quit?",
on_key_down => sub {
my ($dialog, $ev) = @_;
$ev->{sym} == 27 and $dialog->hide;
}
;
$QUIT_DIALOG->add (my $vb = new DC::UI::VBox expand => 1);
$vb->add (new DC::UI::Label
text => "You should find a savebed and apply it first!",
max_w => $WIDTH * 0.25,
ellipsize => 0,
);
$vb->add (my $hb = new DC::UI::HBox expand => 1);
$hb->add (new DC::UI::Button
text => "Ok",
expand => 1,
on_activate => sub { $QUIT_DIALOG->hide; 0 },
);
$hb->add (new DC::UI::Button
text => "Quit anyway",
expand => 1,
on_activate => sub {
crash "Quit anyway";
EV::unloop EV::UNLOOP_ALL;
},
);
}
$QUIT_DIALOG->show;
$QUIT_DIALOG->grab_focus;
}
sub make_menubar {
$MENUFRAME = new DC::UI::Toplevel
border => 0,
force_x => 0,
force_y => 0,
force_w => $::WIDTH,
child => ($MENUBAR = new DC::UI::HBox),
;
$MENUBAR->add ($BUTTONBAR = new DC::UI::Buttonbar);
# XXX: this has to be done before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D
make_gauge_window->show;
# $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW,
# tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server.");
make_playerbook;
$MENUPOPUP = DC::UI::Menu->new (items => [
["Setupâ¦\tF9" , sub { $SETUP_DIALOG->toggle_visibility }],
["Playerbookâ¦\tTab" , sub { $PL_WINDOW ->toggle_visibility }],
["â¦Statistics\tF2" , sub { toggle_player_page ($::STATS_PAGE) }],
["â¦Skills\tF3" , sub { toggle_player_page ($::SKILL_PAGE) }],
["â¦Spells\tF4" , sub { toggle_player_page ($::SPELL_PAGE) }],
["â¦Inventory\tF5" , sub { toggle_player_page ($::INVENTORY_PAGE) }],
["Help Browserâ¦\tF1" , sub { $HELP_WINDOW ->toggle_visibility }],
["Quitâ¦" , sub {
if ($CONN) {
open_quit_dialog;
} else {
EV::unloop EV::UNLOOP_ALL;
}
}],
]);
$BUTTONBAR->add (new DC::UI::Button text => "Menuâ¦",
tooltip => "Shows the main menu",
on_button_down => sub {
my ($self, $ev) = @_;
local $ev->{x} = 0;
local $ev->{y} = 0;
$MENUPOPUP->popup ($ev);
},
);
$MENUBAR->add ($GAUGES->{exp} = new DC::UI::ExperienceProgress
padding_x => 6,
padding_y => 3,
tooltip => "This progress bar shows your overall experience and your progress towards the next character level.",
template => " Exp: 888,888,888,888 (lvl 188) ",
);
$MENUBAR->add ($PICKUP_ENABLE = new DC::UI::CheckBox # checkbox bad, button better?
tooltip => "Automatic Pickup Enable - when this checkbox is enabled, then your character "
. "will automatically pick up items as defined by your item pickup settings "
. "in the playerbook. Often (e.g. in apartments) you want to temporarily "
. "disable autopickup by disabling this checkbox.",
state => $CFG->{pickup} & PICKUP_INHIBIT ? 0 : 1,
on_changed => sub {
my ($self, $value) = @_;
$CFG->{pickup} &= ~PICKUP_INHIBIT;
$CFG->{pickup} |= PICKUP_INHIBIT unless $_[1];
$CONN->send_pickup ($CFG->{pickup})
if $CONN;
},
);
$MENUBAR->add ($GAUGES->{skillexp} = new DC::UI::ExperienceProgress
c_rescale => 1,
padding_x => 6,
padding_y => 3,
force_w => $::WIDTH * 0.2,
tooltip => "This progress bar shows the currently used skill and your progress towards the next skill level of that skill.",
template => "two handed weapons 99%",
);
$MENUBAR->add ($GAUGES->{range} = new DC::UI::Label
expand => 1,
align => 1, can_hover => 1, can_events => 1,
text => "Range and Combat Slots",
tooltip => "#stat_ranged",
);
$MENUFRAME->show;
}
sub open_string_query {
my ($title, $cb, $txt, $tooltip) = @_;
my $dialog = new DC::UI::Toplevel
x => "center",
y => "center",
z => 50,
force_w => $WIDTH * 4/5,
title => $title;
$dialog->add (
( run in 0.807 second using v1.01-cache-2.11-cpan-39bf76dae61 )