--- deliantra/Deliantra-Client/bin/cfplus 2006/08/13 03:20:56 1.107
+++ deliantra/Deliantra-Client/bin/cfplus 2006/11/18 22:36:00 1.127
@@ -1,5 +1,26 @@
#!/opt/bin/perl
+my $startup_done = sub { };
+
+# do splash-screen thingy on win32
+BEGIN {
+ if (%PAR::LibCache && $^O eq "MSWin32") {
+ while (my ($filename, $zip) = each %PAR::LibCache) {
+ $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp");
+ }
+
+ require Win32::GUI::SplashScreen;
+
+ Win32::GUI::SplashScreen::Show (
+ -file => "$ENV{PAR_TEMP}/SPLASH.bmp",
+ );
+
+ $startup_done = sub {
+ Win32::GUI::SplashScreen::Done (1);
+ };
+ }
+}
+
use strict;
use utf8;
@@ -10,7 +31,7 @@
while (my ($filename, $zip) = each %PAR::LibCache) {
for ($zip->memberNames) {
- next unless /^\/root\/(.*)/;
+ next unless /^root\/(.*)/;
$zip->extractMember ($_, "$ENV{PAR_TEMP}/$1")
unless -e "$ENV{PAR_TEMP}/$1";
}
@@ -49,30 +70,21 @@
$Event::DIED = sub {
# TODO: display dialog box or so
Carp::cluck $_[1];#d#TODO: remove when stable
- CFPlus::error $_[1];
-};
-
-$SIG{__DIE__} = sub {
- return if CFPlus::in_destruct;
- Carp::cluck $_[0];
- CFPlus::error $_[0];
return;#d#
- #return unless defined $^S && !$^S;
- $Event::DIED->(undef, $_[0]);
+ CFPlus::fatal ($_[1]);
};
-our $VERSION = '0.1';
-
my $MAX_FPS = 60;
my $MIN_FPS = 5; # unused as of yet
-our $META_SERVER = "crossfire.real-time.com:13326";
+our $META_SERVER = "http://metaserver.schmorp.de/current.json";
our $LAST_REFRESH;
our $NOW;
our $CFG;
our $CONN;
+our $PROFILE; # current profile
our $FAST; # fast, low-quality mode, possibly useful for software-rendering
our $WANT_REFRESH;
@@ -148,6 +160,17 @@
$DEBUG_STATUS->set_text ($_[0]);
}
+sub message {
+ my ($para) = @_;
+
+ my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0];
+
+ $para->{markup} = "$time $para->{markup}";
+
+ $LOGVIEW->add_paragraph ($para);
+ $LOGVIEW->scroll_to_bottom;
+}
+
sub destroy_query_dialog {
(delete $_[0]{query_dialog})->destroy
if $_[0]{query_dialog};
@@ -157,7 +180,7 @@
sub server_query {
my ($conn, $flags, $prompt) = @_;
- $conn->{query_dialog} = my $dialog = new CFPlus::UI::FancyFrame
+ $conn->{query_dialog} = my $dialog = new CFPlus::UI::Toplevel
x => "center",
y => "center",
title => "Server Query",
@@ -192,7 +215,7 @@
$dialog->grab_focus;
} elsif ($flags & CS_QUERY_SINGLECHAR) {
- $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)";
+ $dialog->{tooltip} = "#charcreation_focus";
if ($prompt =~ /Now choose a character|Press any key for the next race/i) {
$MESSAGE_WINDOW->show;
@@ -224,14 +247,7 @@
unshift @dialog, new CFPlus::UI::Label
max_w => $::WIDTH * 0.4,
ellipsise => 0,
- markup =>
- "Character Creation: Race\n\n"
- . "Look at the Messages window to see a description of this race "
- . "and the center of the screen to see how this race looks like "
- . "(below this dialog window: you may need to move the dialog away and "
- . "click into the display area to make it visible).\n\n"
- . "You can look at another race, or accept this race (you will cycle back to "
- . "this race eventually, so you can take your time making this important choice."
+ markup => (CFPlus::Pod::section_label ui => "chargen_race"),
;
} elsif ($prompt =~ /roll new stats/) {
@@ -322,12 +338,7 @@
unshift @dialog, new CFPlus::UI::Label
max_w => $::WIDTH * 0.4,
ellipsise => 0,
- markup =>
- "Character Creation: Stats\n\n"
- . "Stats are a very important aspect of your character. You can use the tooltips to learn what each Stat governs.\n\n"
- . "The stats generated by the server are always sorted from Str (highest) to Cha (lowest). "
- . "They will be modified later by both the race and the class you choose.\n\n"
- . "You can create another set of stats, swap two stat values with each other or accept the stats as shown below and continue.\n"
+ markup => (CFPlus::Pod::section_label ui => "chargen_stats"),
;
}
@@ -366,21 +377,25 @@
$LOGIN_BUTTON->set_text ("Logout");
$SETUP_DIALOG->hide;
+ $PROFILE = $CFG->{profile}{default};
+
my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
- my ($host, $port) = split /:/, $CFG->{profile}{default}{host};
+ my ($host, $port) = split /:/, $PROFILE->{host};
- $MAP = new CFPlus::Map $mapsize, $mapsize;
+ $MAP = new CFPlus::Map;
$CONN = eval {
new CFPlus::Protocol
host => $host,
port => $port || 13327,
- user => $CFG->{profile}{default}{user},
- pass => $CFG->{profile}{default}{password},
+ user => $PROFILE->{user},
+ pass => $PROFILE->{password},
mapw => $mapsize,
maph => $mapsize,
+ client => "cfplus $CFPlus::VERSION $] $^O",
+
map_widget => $MAPWIDGET,
logview => $LOGVIEW,
statusbox => $STATUSBOX,
@@ -624,19 +639,13 @@
],
);
- $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp',
- tooltip => "Health points. Measures of how much damage you can take before dying. Hit points are determined from your level and are influenced by the value of your Con. Hp value may range between 1 to beyond 500 and higher values indicate a greater ability to withstand punishment.");
- $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana',
- tooltip => "Spell points. Measures of how much \"fuel\" you have for casting spells and incantations. Mana is calculated from your level and your Pow. Mana values can range between 1 to beyond 500 (glowing crystals can increase the current spell points beyond your normal maximum). Higher values indicate greater amounts of mana.");
- $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace',
- tooltip => "Grace points - how favored you are by your god. In game terms, how much divine magic you can cast. Your level, Wis and Pow effect what the value of grace is. Prayong on an altar of your god can increase this value beyond your normal maximum. Grace can take on large positive and negative values. Positive values indicate favor by the gods.");
- $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food',
- tooltip => "Food. Ranges between 0 (starving) and 999 (satiated). At a value of 0 the character begins to die. Some magic can speed up or slow down the character digestion. Healing wounds will speed up digestion too.");
-
- $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1,
- tooltip => "Experience points and overall level - experience is increased as a reward for appropriate action (such as killing monsters) and may decrease as a result of a magical attack or dying. Level is directly derived from the experience value. As the level of the character increases, the character becomes able to succeed at more difficult tasks. A character's level starts at a value of 0 and may range up beyond 100.");
- $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1,
- tooltip => "Ranged attack - how you attack when you press shift-cursor (spell, skill, weapon etc.)");
+ $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health");
+ $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana");
+ $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace");
+ $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food");
+
+ $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp");
+ $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged");
$GAUGES = {
exp => $exp, win => $win, range => $rng,
@@ -683,14 +692,19 @@
);
$r->add (my $vb = new CFPlus::UI::VBox);
- $vb->add ($STATWIDS->{title} = new CFPlus::UI::Label valign => 0, align => -1, text => "Title:", expand => 1,
+ $vb->add (new CFPlus::UI::FancyFrame
+ label => "Player",
+ child => (my $pi = new CFPlus::UI::VBox),
+ );
+
+ $pi->add ($STATWIDS->{title} = new CFPlus::UI::Label valign => 0, align => -1, text => "Title:", expand => 1,
can_hover => 1, can_events => 1,
tooltip => "Your name and title. You can change your title by using the title command, if supported by the server.");
- $vb->add ($STATWIDS->{map} = new CFPlus::UI::Label valign => 0, align => -1, text => "Map:", expand => 1,
+ $pi->add ($STATWIDS->{map} = new CFPlus::UI::Label valign => 0, align => -1, text => "Map:", expand => 1,
can_hover => 1, can_events => 1,
tooltip => "The map you are currently on (if supported by the server).");
- $vb->add (my $hb0 = new CFPlus::UI::HBox);
+ $pi->add (my $hb0 = new CFPlus::UI::HBox);
$hb0->add ($STATWIDS->{weight} = new CFPlus::UI::Label valign => 0, align => -1, text => "Weight:", expand => 1,
can_hover => 1, can_events => 1,
tooltip => "The weight of the player including all inventory items.");
@@ -698,7 +712,10 @@
can_hover => 1, can_events => 1,
tooltip => "The weight limit: you cannot carry more than this.");
- $vb->add (my $hb = new CFPlus::UI::HBox expand => 1);
+ $vb->add (new CFPlus::UI::FancyFrame
+ label => "Primary/Secondary Statistics",
+ child => (my $hb = new CFPlus::UI::HBox expand => 1),
+ );
$hb->add (my $tbl = new CFPlus::UI::Table expand => 1);
my $color2 = [1, 1, 0];
@@ -729,7 +746,10 @@
align => -1, text => $label, tooltip => "#stat_$label");
}
- $vb->add (my $tbl2 = new CFPlus::UI::Table expand => 1);
+ $vb->add (new CFPlus::UI::FancyFrame
+ label => "Resistancies",
+ child => (my $tbl2 = new CFPlus::UI::Table expand => 1),
+ );
my $row = 0;
my $col = 0;
@@ -839,27 +859,15 @@
$table->clear;
$table->add (0, 0, my $label = new CFPlus::UI::Label max_w => $WIDTH * 0.8, text => "fetching server list...");
- my $buf;
+ my $ok = 0;
- my $fh = new IO::Socket::INET PeerHost => $META_SERVER, Blocking => 0;
-
- unless ($fh) {
- $label->set_text ("unable to contact metaserver: $!");
- return;
- }
-
- Event->io (fd => $fh, poll => 'r', cb => sub {
- my $res = sysread $fh, $buf, 8192, length $buf;
-
- if (!defined $res) {
- $_[0]->w->cancel;
- $label->set_text ("error while retrieving server list: $!");
- } elsif ($res == 0) {
- $_[0]->w->cancel;
- status "server list retrieved";
-
- utf8::decode $buf if utf8::valid $buf;
+ CFPlus::background {
+ my $ua = CFPlus::lwp_useragent;
+ CFPlus::background_msg CFPlus::from_json +(CFPlus::lwp_check $ua->get ($META_SERVER))->decoded_content;
+ } sub {
+ my ($msg) = @_;
+ if ($msg) {
$table->clear;
my @tip = (
@@ -879,23 +887,30 @@
my @align = qw(1 0 1 1 -1);
my $y = 0;
- for my $m (sort { $b->[3] <=> $a->[3] } map [split /\|/], split /\015?\012/, $buf) {
- my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime) = @$m;
+ for my $m (
+ sort {
+ $b->{version} <=> $a->{version}
+ or $b->{users} <=> $a->{users}
+ }
+ @{ $msg->{servers} }
+ ) {
+ my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime) =
+ @$m{qw(ip age hostname users version description ibytes obytes uptime)};
for ($desc) {
s/
/\n/gi;
s/