--- deliantra/Deliantra-Client/bin/pclient 2006/05/12 01:47:04 1.210
+++ deliantra/Deliantra-Client/bin/pclient 2006/05/17 14:55:15 1.223
@@ -96,17 +96,17 @@
our %AUDIO_CHUNKS; # audio files
our $ALT_ENTER_MESSAGE;
-our $STATUS_LINE;
+our $STATUSBOX;
our $DEBUG_STATUS;
our $INVWIN;
our $INV;
+our $INVR;
+our $INVR_LBL;
+our $OPENCONT;
sub status {
- $STATUS_LINE->add ($_[0], pri => -10, group => "status", timeout => 20, color => [1, 1, 0, 1]);
- $CFClient::UI::ROOT->on_refresh ($STATUS_LINE => sub {
- $STATUS_LINE->move (0, $HEIGHT - $STATUS_LINE->{h});#d# to in toplevel
- });
+ $STATUSBOX->add ($_[0], pri => -10, group => "status", timeout => 20, fg => [1, 1, 0, 1]);
}
sub debug {
@@ -169,7 +169,7 @@
$table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode");
$table->add (1, 0, my $hbox = new CFClient::UI::HBox);
- $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]);
+ $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 1, 1]);
$hbox->add (my $mode_label = new CFClient::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999");
$mode_slider->connect (changed => sub {
@@ -204,11 +204,11 @@
$table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Map Scale");
$table->add (1, $row++, new CFClient::UI::Slider
- range => [$CFG->{map_scale}, 0.25, 2, 0.05],
+ range => [$CFG->{map_scale}, 0.25, 2, 0.05, 0.05],
tooltip => "Enlarge or shrink the displayed map",
connect_changed => sub {
my ($self, $value) = @_;
- $CFG->{map_scale} = 0.05 * int $value / 0.05;
+ $CFG->{map_scale} = $value;
}
);
@@ -245,30 +245,25 @@
$table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize");
$table->add (1, $row++, new CFClient::UI::Slider
- range => [$CFG->{gui_fontsize}, 0.5, 2, 0.1],
+ range => [$CFG->{gui_fontsize}, 0.5, 2, 0.1, 0.1],
tooltip => "The font size used by most GUI elements",
- connect_changed => sub {
- $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10;
-# $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
- }
+ connect_changed => sub { $CFG->{gui_fontsize} = $_[1] },
);
$table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize");
$table->add (1, $row++, new CFClient::UI::Slider
- range => [$CFG->{log_fontsize}, 0.5, 2, 0.1],
+ range => [$CFG->{log_fontsize}, 0.5, 2, 0.1, 0.1],
tooltip => "The font size used by the server log window only",
- connect_changed => sub {
- $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10);
- }
+ connect_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]) },
);
$table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize");
$table->add (1, $row++, new CFClient::UI::Slider
- range => [$CFG->{stat_fontsize}, 0.5, 2, 0.1],
+ range => [$CFG->{stat_fontsize}, 0.5, 2, 0.1, 0.1],
tooltip => "The font size used by the statistics window only",
connect_changed => sub {
- $CFG->{stat_fontsize} = 0.1 * int $_[1] * 10;
+ $CFG->{stat_fontsize} = $_[1];
&set_stats_window_fontsize;
}
);
@@ -279,18 +274,16 @@
tooltip => "Adjust the size of the stats gauges at the bottom right",
connect_changed => sub {
$CFG->{gauge_size} = $_[1];
- my $h = int $HEIGHT * $CFG->{gauge_size};
- $GAUGES->{win}->set_size ($WIDTH, $h);
- $GAUGES->{win}->move (0, $HEIGHT - $h);
+ $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size});
}
);
$table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize");
$table->add (1, $row++, new CFClient::UI::Slider
- range => [$CFG->{gauge_fontsize}, 0.5, 2.0, 0.1],
+ range => [$CFG->{gauge_fontsize}, 0.5, 2.0, 0.1, 0.1],
tooltip => "Adjusts the fontsize of the gauges at the bottom right",
connect_changed => sub {
- $CFG->{gauge_fontsize} = 0.1 * int $_[1] * 10;
+ $CFG->{gauge_fontsize} = $_[1];
&set_gauge_window_fontsize;
}
);
@@ -374,16 +367,21 @@
}
sub make_gauge_window {
- my $gh = int ($HEIGHT * $CFG->{gauge_size});
-# my $gw = int ($WIDTH * $CFG->{gauge_w_size});
+ my $gh = int $HEIGHT * $CFG->{gauge_size};
my $win = new CFClient::UI::Frame (
- y => $HEIGHT - $gh, x => 0, user_w => $WIDTH, user_h => $gh
+ req_y => -1,
+ user_w => $WIDTH,
+ user_h => $gh,
);
+
$win->add (my $hbox = new CFClient::UI::HBox
children => [
(new CFClient::UI::HBox expand => 1),
- ($FLOORBOX = new CFClient::UI::VBox),
+ (new CFClient::UI::VBox children => [
+ (new CFClient::UI::Empty expand => 1),
+ (new CFClient::UI::Frame bg => [0, 0, 0, 0.4], child => ($FLOORBOX = new CFClient::UI::VBox)),
+ ]),
(my $vbox = new CFClient::UI::VBox),
],
);
@@ -736,7 +734,7 @@
$table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
$table->add (1, 7, new CFClient::UI::Slider
req_w => 100,
- range => [$CFG->{mapsize}, 10, 100 + 1, 1],
+ range => [$CFG->{mapsize}, 10, 100 + 1, 1, 1],
tooltip => "This is the size of the portion of the map update the server sends you. "
."If you set this to a high value you will be able to see further for example.",
connect_changed => sub {
@@ -814,8 +812,21 @@
}
sub make_inventory_window {
- my $invwin = new CFClient::UI::FancyFrame user_w => 300, user_h => 300, title => "Inventory";
- $invwin->add ($INV = new CFClient::UI::Inventory expand => 1);
+ my $invwin = new CFClient::UI::FancyFrame
+ user_w => $WIDTH * (4/5), user_h => $HEIGHT * (4/5), title => "Inventory";
+
+ $invwin->add (my $hb = new CFClient::UI::HBox);
+
+ $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1);
+ $vb1->add (my $lbl = new CFClient::UI::Label);
+ $lbl->set_text ("Player");
+ $vb1->add ($INV = new CFClient::UI::Inventory expand => 1);
+
+ $hb->add (my $vb2 = new CFClient::UI::VBox expand => 1);
+ $vb2->add ($INVR_LBL = new CFClient::UI::Label);
+ $INVR_LBL->set_text ("Floor");
+ $vb2->add ($INVR = new CFClient::UI::Inventory expand => 1);
+
$invwin
}
@@ -847,19 +858,20 @@
#############################################################################
- if ($DEBUG_STATUS) {
- # reconfigure all widgets
- $CFClient::UI::ROOT->reconfigure;
-
- } else {
+ unless ($DEBUG_STATUS) {
# create the widgets
- $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100, text => "hulla", x => 100;#d#
+ $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100, req_x => -1;
$DEBUG_STATUS->show;
- $STATUS_LINE = new CFClient::UI::Statusbox;
- $STATUS_LINE->add ("Use Alt-Enter to toggle fullscreen mode", pri => -100, size => 0.8, color => [1, 1, 1, 0.8]);
- $STATUS_LINE->show;
+ $STATUSBOX = new CFClient::UI::Statusbox;
+ $STATUSBOX->add ("Use Alt-Enter to toggle fullscreen mode", pri => -100, color => [1, 1, 1, 0.8]);
+
+ (new CFClient::UI::Frame
+ bg => [0, 0, 0, 0.4],
+ req_y => -1,
+ child => $STATUSBOX,
+ )->show;
CFClient::UI::FancyFrame->new (
border_bg => [1, 1, 1, 192/255],
@@ -901,9 +913,13 @@
$BUTTONBAR->show;
+ $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
+
# delay till geometry is constant
- $CFClient::UI::ROOT->on_refresh (startup => sub {
+ $CFClient::UI::ROOT->on_post_alloc (startup => sub {
$BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
+ my $widget = $GAUGES->{win};
+ $widget->move (0, $HEIGHT - $widget->{h});#d# to in toplevel
});
force_refresh ();
}
@@ -974,7 +990,7 @@
my $fps = 9;
sub force_refresh {
- $fps = $fps * 0.95 + 1 / ($NOW - $LAST_REFRESH) * 0.05;
+ $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05;
debug sprintf "%3.2f", $fps;
$CFClient::UI::ROOT->draw;
@@ -1325,13 +1341,19 @@
my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0];
- $text =~ s/&/&/g; $text =~ s/</g;
+ $text = CFClient::UI::Label::escape $text;
$text =~ s/\[b\](.*?)\[\/b\]/\1<\/b>/g;
$text =~ s/\[color=(.*?)\](.*?)\[\/color\]/\2<\/span>/g;
$LOGVIEW->add_paragraph ($color[$color],
join "\n", map "$time $_", split /\n/, $text);
- $STATUS_LINE->add ($text, color => $color[$color], timeout => 60);
+
+ $STATUSBOX->add ($text,
+ group => $text,
+ fg => $color[$color],
+ timeout => 60,
+ tooltip_font => $::FONT_FIXED,
+ );
}
sub conn::drawextinfo {
@@ -1356,18 +1378,88 @@
sub conn::addme_success {
my ($self) = @_;
+ $MAPWIDGET->clr_commands;
+
for my $skill (values %{$self->{skill_info}}) {
$MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'");
$MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'");
}
- $MAPWIDGET->add_command ("pet\\_mode defend", "Tell pets to stay close to you and defend you");
- $MAPWIDGET->add_command ("pet\\_mode arena", "Same as petmode attack, but also attack other players");
- $MAPWIDGET->add_command ("pet\\_mode sad", "Search & Destroy - tell pets to roam about and attack enemies");
- $MAPWIDGET->add_command ("kill\\_pets", "kill your pets");
+ $MAPWIDGET->add_command ("petmode defend", "Tell pets to stay close to you and defend you");
+ $MAPWIDGET->add_command ("petmode arena", "Same as petmode sad, but also attack other players");
+ $MAPWIDGET->add_command ("petmode sad", "Search & Destroy - tell pets to roam about and attack enemies");
+ $MAPWIDGET->add_command ("killpets", "Kill your pets");
+ $MAPWIDGET->add_command ("chat", "chat TEXT\nChat with all other players");
+ $MAPWIDGET->add_command ("shout", "shout TEXT\nShout loudly, used for emergencies");
+ $MAPWIDGET->add_command ("tell", "tell USERNAME TEXT\nPrivately tell a specific player");
+
+ # TODO: add documentation on these
+ for (qw(
+ afk
+ apply
+ body
+ bowmode
+ brace
+ build
+ disarm
+ dm
+ dmhide
+ drop
+ dropall
+ examine
+ get
+ gsay
+ help
+ hiscore
+ inventory
+ invoke
+ killpets
+ listen
+ logs
+ mapinfo
+ maps
+ mark
+ motd
+ output-count
+ output-sync
+ party
+ peaceful
+ petmode
+ pickup
+ players
+ prepare
+ quests
+ rename
+ resistances
+ rotateshoottype
+ save
+ say
+ search
+ search-items
+ showpets
+ skills
+ sound
+ take
+ throw
+ time
+ title
+ usekeys
+ version
+ weather
+ whereabouts
+ whereami
+ who
+ wimpy
+ )) {
+ $MAPWIDGET->add_command ($_, "$_: no help available (yet)");
+ }
+
+ #TODO: add " and ' "aliases" etc.
}
sub conn::eof {
+ $MAPWIDGET->clr_commands;
+
stop_game;
}
@@ -1395,10 +1487,21 @@
sub conn::container_add {
my ($self, $tag, $items) = @_;
- update_floorbox if $tag == 0;
+ #d# print "container_add: container $tag ($self->{player}{tag})\n";
- $INV->set_items ($self->{container}{$self->{player}{tag}})
- if $tag == $self->{player}{tag};
+ if ($tag == 0) {
+ update_floorbox;
+ $OPENCONT = 0;
+ $INVR_LBL->set_text ("Floor");
+ $INVR->set_items ($self->{container}{0});
+ } elsif ($tag == $self->{player}{tag}) {
+ $INVR_LBL->set_text ("Player");
+ $INV->set_items ($self->{container}{$self->{player}{tag}})
+ } else {
+ $OPENCONT = $tag;
+ $INVR_LBL->set_text (CFClient::UI::InventoryItem::_item_to_desc ($self->{item}->{$OPENCONT}));
+ $INVR->set_items ($self->{container}{$tag});
+ }
# $self-<{player}{tag} => player inv
#use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}};
@@ -1407,10 +1510,21 @@
sub conn::container_clear {
my ($self, $tag) = @_;
- update_floorbox if $tag == 0;
+ #d# print "container_clear: container $tag ($self->{player}{tag})\n";
- $INV->set_items ($self->{container}{$tag})
- if $tag == $self->{player}{tag};
+ if ($tag == 0) {
+ update_floorbox;
+ $OPENCONT = 0;
+ $INVR_LBL->set_text ("Floor");
+ $INVR->set_items ($self->{container}{0});
+ } elsif ($tag == $self->{player}{tag}) {
+ $INVR_LBL->set_text ("Player");
+ $INV->set_items ($self->{container}{$tag})
+ } else {
+ $OPENCONT = $tag;
+ $INVR_LBL->set_text (CFClient::UI::InventoryItem::_item_to_desc ($self->{item}->{$OPENCONT}));
+ $INVR->set_items ($self->{container}{$tag});
+ }
# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
}
@@ -1419,20 +1533,46 @@
my ($self, @items) = @_;
for (@items) {
- update_floorbox if $_->{container} == 0;
+ #d# print "item_delete: $_->{tag} from $_->{container} ($self->{player}{tag})\n";
- $INV->set_items ($self->{container}{$_->{container}})
- if $_->{container} == $self->{player}{tag};
+ if ($_->{container} == 0) {
+ update_floorbox;
+ $OPENCONT = 0;
+ $INVR_LBL->set_text ("Floor");
+ $INVR->set_items ($self->{container}{0});
+ } elsif ($_->{container} == $self->{player}{tag}) {
+ $INVR_LBL->set_text ("Player");
+ $INV->set_items ($self->{container}{$self->{player}{tag}})
+ } else {
+ $OPENCONT = $_->{container};
+ $INVR_LBL->set_text (CFClient::UI::InventoryItem::_item_to_desc ($self->{item}->{$OPENCONT}));
+ $INVR->set_items ($self->{container}{$_->{container}});
+ }
}
}
sub conn::item_update {
my ($self, $item) = @_;
- update_floorbox if $item->{container} == 0;
+ #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($OPENCONT)\n";
- $INV->set_items ($self->{container}{$item->{container}})
- if $item->{container} == $self->{player}{tag};
+ if ($item->{tag} == $OPENCONT && not ($item->{flags} & Crossfire::Protocol::F_OPEN)) {
+ $OPENCONT = 0;
+ $INVR_LBL->set_text ("Floor");
+ $INVR->set_items ($self->{container}{0});
+
+ $item->{widget}->update_item
+ if $item->{widget};
+ } else {
+ if ($item->{container} == 0) {
+ update_floorbox;
+ $OPENCONT = 0;
+ $INVR_LBL->set_text ("Floor");
+ $INVR->set_items ($self->{container}{0});
+ } elsif ($item->{container} == $self->{player}{tag}) {
+ $INV->set_items ($self->{container}{$item->{container}})
+ }
+ }
}
%SDL_CB = (
@@ -1533,12 +1673,27 @@
CFClient::add_font $_ for @fonts;
+ CFClient::pango_init;
+
$FONT_PROP = new_from_file CFClient::Font $fonts[0];
$FONT_FIXED = new_from_file CFClient::Font $fonts[1];
$FONT_PROP->make_default;
}
+# compare mono (ft) vs. rgba (cairo)
+# ft - 1.8s, cairo 3s, even in alpha-only mode
+# for my $rgba (0..1) {
+# my $t1 = Time::HiRes::time;
+# for (1..1000) {
+# my $layout = CFClient::Layout->new ($rgba);
+# $layout->set_text ("hallo" x 100);
+# $layout->render;
+# }
+# my $t2 = Time::HiRes::time;
+# warn $t2-$t1;
+# }
+
video_init;
audio_init;
}