Deliantra-Client
view release on metacpan or search on metacpan
bin/deliantra view on Meta::CPAN
}
}
# prepend private library directory and prepare env
BEGIN {
for (grep !ref, @INC) {
my $path = "$_/Deliantra/Client/private";
if (-d $path) {
unshift @INC, $path;
last;
}
}
}
# need to do it again because that pile of garbage called PAR nukes it before main
unshift @INC, $ENV{PAR_TEMP}
if %PAR::LibCache;
use EV;
BEGIN { *time = \&EV::time }
use List::Util qw(max min);
use Deliantra;
use Deliantra::Protocol::Constants;
use AnyEvent::Util ();
use AnyEvent::Socket ();
use AnyEvent::DNS ();
use Compress::LZF;
use JSON::XS;
use DC;
sub crash($;$) {
# nop during compiletime
}
BEGIN {
$SIG{__DIE__} = sub {
return if $^S;
crash "CRASH/DIE: $_[0]" => 1;
DC::fatal Carp::longmess "$_[0]";
}
}
use DC::OpenGL ();
use DC::Protocol;
use DC::DB;
use DC::UI;
use DC::UI::Canvas;
use DC::UI::Inventory;
use DC::UI::SpellList;
use DC::UI::Dockable;
use DC::UI::Dockbar;
use DC::UI::ChatView;
use DC::MessageDistributor;
use DC::Pod;
use DC::MapWidget;
use DC::Macro;
$SIG{QUIT} = sub { Carp::cluck "QUIT" };
$SIG{PIPE} = 'IGNORE';
$EV::DIED = sub {
crash "CRASH/EV::DIED: $@" => 0;
DC::fatal Carp::longmess $@;
};
my $MAX_FPS = 60;
our $DEFAULT_SERVER = "gameserver.deliantra.net";
our $META_SERVER = "http://metaserver.schmorp.de/current.json";
our $LAST_REFRESH;
our $NOW;
our $CFG;
our $PROFILE; # current profile
our $FAST; # fast, low-quality mode, possibly useful for software-rendering
our $DELIANTRA_DEBUG = $ENV{DELIANTRA_DEBUG} * 1;
our $WANT_REFRESH;
our $MODE_SLIDER;
our $CAVEAT_LABEL;
our @SDL_MODES;
our $SDL_REINIT = 1;
our $WIDTH;
our $HEIGHT;
our $FULLSCREEN;
our $FONTSIZE;
our $FONT_PROP;
our $FONT_FIXED;
our $CONN;
our $MAP;
our $MAPMAP;
our $MAPWIDGET;
our $COMPLETER;
our $MENUFRAME; # the rectangle at the top
our $MENUBAR; # the hbox at the top
our $MENUPOPUP;
our $BUTTONBAR; # the menu buttons
our $METASERVER;
our $LOGIN_BUTTON;
our $QUIT_DIALOG;
our $HOST_ENTRY;
our $FULLSCREEN_ENABLE;
our $PICKUP_ENABLE;
our $SERVER_INFO;
our $SETUP_DIALOG;
our $SETUP_NOTEBOOK;
our $SETUP_SERVER;
our $SETUP_LOGIN;
bin/deliantra view on Meta::CPAN
}
sub toggle_player_page {
my ($widget) = @_;
if ($PL_WINDOW->{visible} && $PL_NOTEBOOK->get_current_page == $widget) {
$PL_WINDOW->hide;
} else {
$PL_NOTEBOOK->set_current_page ($widget);
$PL_WINDOW->show;
}
}
sub make_playerbook {
my $plwin = $PL_WINDOW = new DC::UI::Toplevel
x => "center",
y => "center",
force_w => $WIDTH * 9/10,
force_h => $HEIGHT * 9/10,
title => "Player",
name => "playerbook",
has_close_button => 1
;
my $ntb =
$PL_NOTEBOOK =
new DC::UI::Notebook expand => 1;
$ntb->add_tab (
"Statistics (F2)" => $STATS_PAGE = stats_window,
"Shows statistics, where all your Stats and Resistances are shown."
);
$ntb->add_tab (
"Skills (F3)" => $SKILL_PAGE = skill_window,
"Shows all your Skills."
);
my $spellsw = $SPELL_PAGE = new DC::UI::ScrolledWindow (expand => 1, scroll_y => 1);
$spellsw->add ($SPELL_LIST = new DC::UI::SpellList);
$ntb->add_tab (
"Spellbook (F4)" => $spellsw,
"Displays all spells you have and lets you edit keyboard shortcuts for them."
);
$ntb->add_tab (
"Inventory (F5)" => $INVENTORY_PAGE = inventory_widget,
"Toggles the inventory window, where you can manage your loot (or treasures :). "
. "You can also hit the <b>Tab</b>-key to show/hide the Inventory."
);
$ntb->add_tab (Pickup => $PICKUP_PAGE = autopickup_setup,
"Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them.");
$ntb->add_tab (Media => media_window,
"License, Author and Source info for media sent by the server.");
$ntb->set_current_page ($INVENTORY_PAGE);
$plwin->add ($ntb);
}
sub keyboard_setup {
DC::Macro::keyboard_setup
}
sub make_help_window {
my $win = new DC::UI::Toplevel
x => 'center',
y => 'center',
z => 4,
name => 'doc_browser',
force_w => int $WIDTH * 7/8,
force_h => int $HEIGHT * 7/8,
title => "Help Browser",
has_close_button => 1;
$win->add (my $vbox = new DC::UI::VBox);
$vbox->add (new DC::UI::FancyFrame
label => "Navigation",
child => (my $buttons = new DC::UI::HBox),
);
$vbox->add (my $viewer = new DC::UI::TextScroller
expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4);
my @history;
my @future;
my $curnode;
my $load_node; $load_node = sub {
my ($node, $para) = @_;
$buttons->clear;
$buttons->add (new DC::UI::Button
text => "â¤",
tooltip => "back to the starting page",
on_activate => sub {
unshift @future, [$curnode, $viewer->current_paragraph] if $curnode;
unshift @future, @history;
@history = ();
$load_node->(@{shift @future});
},
);
if (@history) {
$buttons->add (new DC::UI::Button
text => "â",
tooltip => "back to <i>" . (DC::asxml DC::Pod::full_path $history[-1][0]) . "</i>",
on_activate => sub {
unshift @future, [$curnode, $viewer->current_paragraph] if $curnode;
$load_node->(@{pop @history});
},
);
}
if (@future) {
$buttons->add (new DC::UI::Button
text => "â",
tooltip => "forward to <i>" . (DC::asxml DC::Pod::full_path $future[0][0]) . "</i>",
on_activate => sub {
push @history, [$curnode, $viewer->current_paragraph];
$load_node->(@{shift @future});
bin/deliantra view on Meta::CPAN
$vbox->add (my $table = new DC::UI::Table col_expand => [0, 1]);
$table->add_at (0, 0, new DC::UI::Button
text => "Close",
tooltip => "Close the tip of the day window. To never see it again, disable the tip of the day in the <b>Server Setup</b>.",
on_activate => $close,
);
$table->add_at (2, 0, new DC::UI::Button
text => "Next",
tooltip => "Show the next <b>Tip of the day</b>.",
on_activate => sub {
$close->();
&show_tip_of_the_day;
},
);
$dialog->show;
};
}
sub video_init {
DC::set_theme $CFG->{uitheme};
DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT;
$SDL_REINIT = 0;
@SDL_MODES = DC::SDL_ListModes 8, $CFG->{disable_alpha} ? 0 : 8;
@SDL_MODES = DC::SDL_ListModes 8, 8 unless @SDL_MODES;
@SDL_MODES = DC::SDL_ListModes 5, 0 unless @SDL_MODES;
@SDL_MODES or DC::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
@SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES;
if (!defined $CFG->{sdl_mode} or $CFG->{sdl_mode} > $#SDL_MODES) {
$CFG->{sdl_mode} = 0; # lowest resolution by default
# now choose biggest mode <= 1024x768
for (0 .. $#SDL_MODES) {
if ($SDL_MODES[$_][0] * $SDL_MODES[$_][1] <= 1024 * 768) {
$CFG->{sdl_mode} = $_;
}
}
}
my ($old_w, $old_h) = ($WIDTH, $HEIGHT);
($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
$FULLSCREEN = $CFG->{fullscreen};
$FAST = $CFG->{fast};
# due to mac os x braindamage, we simply retry with !fullscreen in case of an error
DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, $FULLSCREEN
or DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, !$FULLSCREEN
or die "SDL_SetVideoMode failed: " . (DC::SDL_GetError) . "\n";
$SDL_ACTIVE = 1;
$LAST_REFRESH = time - 0.01;
DC::OpenGL::init;
DC::Macro::init;
$FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
$DC::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d#
#############################################################################
if ($DEBUG_STATUS) {
DC::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h;
} else {
# create/configure the widgets
$DC::UI::ROOT->connect (key_down => sub {
my (undef, $ev) = @_;
if (my @macros = DC::Macro::find $ev) {
DC::Macro::execute $_ for @macros;
return 1;
}
0
});
$DEBUG_STATUS = new DC::UI::Label
padding => 0,
z => 100,
force_x => "max",
force_y => 20;
$DEBUG_STATUS->show;
$STATUSBOX = new DC::UI::Statusbox;
$MODBOX = new DC::UI::Label
can_events => 1,
can_hover => 1,
markup => "",
align => 0,
font => $FONT_FIXED,
tooltip => "#modifier_box",
tooltip_width => 0.67,
;
update_modbox;
(new DC::UI::Frame
bg => [0, 0, 0, 0.4],
force_x => 0,
force_y => "max",
child => (my $LL = new DC::UI::VBox),
)->show;
$LL->add ($STATUSBOX);
$LL->add ($MODBOX);
$LL->add (new DC::UI::Label
align => 0,
markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode",
fontsize => 0.5,
fg => [1, 1, 0, 0.7],
);
DC::UI::Toplevel->new (
title => "Minimap",
name => "mapmap",
x => 0,
y => $::FONTSIZE + 8,#d# hack to move messages window below the menubar
border_bg => [1, 1, 1, 192/255],
bg => [1, 1, 1, 0],
child => ($MAPMAP = new DC::MapWidget::MapMap
tooltip => "<b>Minimap</b>. This will display an overview of the surrounding areas.",
),
)->show;
$MAPWIDGET = new DC::MapWidget;
$MAPWIDGET->connect (activate_console => sub {
my ($mapwidget, $preset) = @_;
( run in 1.204 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )