ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/cfplus
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/cfplus (file contents):
Revision 1.98 by root, Sat Jul 22 13:20:33 2006 UTC vs.
Revision 1.102 by root, Mon Jul 24 04:24:43 2006 UTC

36 36
37use CFClient; 37use CFClient;
38use CFClient::OpenGL (); 38use CFClient::OpenGL ();
39use CFClient::Protocol; 39use CFClient::Protocol;
40use CFClient::UI; 40use CFClient::UI;
41use CFClient::Pod;
41use CFClient::BindingEditor; 42use CFClient::BindingEditor;
42use CFClient::MapWidget; 43use CFClient::MapWidget;
43 44
44$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 45$SIG{QUIT} = sub { Carp::cluck "QUIT" };
45$SIG{PIPE} = 'IGNORE'; 46$SIG{PIPE} = 'IGNORE';
130our $BIND_UPD_CB; 131our $BIND_UPD_CB;
131 132
132our $PICKUP_CFG; 133our $PICKUP_CFG;
133 134
134sub status { 135sub status {
135 $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); 136 $STATUSBOX->add (CFClient::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
136} 137}
137 138
138sub debug { 139sub debug {
139 $DEBUG_STATUS->set_text ($_[0]); 140 $DEBUG_STATUS->set_text ($_[0]);
140} 141}
251 0 252 0
252 }, 253 },
253 ); 254 );
254 255
255 # center: swap stats 256 # center: swap stats
256 my ($sw1, $sw2) = map +(new CFClient::UI::Combobox 257 my ($sw1, $sw2) = map +(new CFClient::UI::Selector
257 expand => 1, 258 expand => 1,
258 value => $_, 259 value => $_,
259 options => [ 260 options => [
260 [1 => "Str", "Strength ($conn->{stat}{+CS_STAT_STR})"], 261 [1 => "Str", "Strength ($conn->{stat}{+CS_STAT_STR})"],
261 [2 => "Dex", "Dexterity ($conn->{stat}{+CS_STAT_DEX})"], 262 [2 => "Dex", "Dexterity ($conn->{stat}{+CS_STAT_DEX})"],
686 can_hover => 1, can_events => 1, 687 can_hover => 1, can_events => 1,
687 tooltip => "The weight of the player including all inventory items."); 688 tooltip => "The weight of the player including all inventory items.");
688 $hb0->add ($STATWIDS->{m_weight} = new CFClient::UI::Label valign => 0, align => -1, text => "Max weight:", expand => 1, 689 $hb0->add ($STATWIDS->{m_weight} = new CFClient::UI::Label valign => 0, align => -1, text => "Max weight:", expand => 1,
689 can_hover => 1, can_events => 1, 690 can_hover => 1, can_events => 1,
690 tooltip => "The weight limit: you cannot carry more than this."); 691 tooltip => "The weight limit: you cannot carry more than this.");
691
692 692
693 $vb->add (my $hb = new CFClient::UI::HBox expand => 1); 693 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
694 $hb->add (my $tbl = new CFClient::UI::Table expand => 1); 694 $hb->add (my $tbl = new CFClient::UI::Table expand => 1);
695 695
696 my $color2 = [1, 1, 0]; 696 my $color2 = [1, 1, 0];
1132 $QUIT_DIALOG = new CFClient::UI::FancyFrame 1132 $QUIT_DIALOG = new CFClient::UI::FancyFrame
1133 x => "center", 1133 x => "center",
1134 y => "center", 1134 y => "center",
1135 z => 50, 1135 z => 50,
1136 title => "Really Quit?", 1136 title => "Really Quit?",
1137 on_key_down => sub {
1138 my ($dialog, $ev) = @_;
1139 $ev->{sym} == 27 and $dialog->hide;
1140 }
1137 ; 1141 ;
1138 1142
1139 $QUIT_DIALOG->add (my $vb = new CFClient::UI::VBox expand => 1); 1143 $QUIT_DIALOG->add (my $vb = new CFClient::UI::VBox expand => 1);
1140 1144
1141 $vb->add (new CFClient::UI::Label 1145 $vb->add (new CFClient::UI::Label
1155 on_activate => sub { exit }, 1159 on_activate => sub { exit },
1156 ); 1160 );
1157 } 1161 }
1158 1162
1159 $QUIT_DIALOG->show; 1163 $QUIT_DIALOG->show;
1164 $QUIT_DIALOG->grab_focus;
1160} 1165}
1161 1166
1162sub autopickup_setup { 1167sub autopickup_setup {
1163 my $table = new CFClient::UI::Table; 1168 my $table = new CFClient::UI::Table;
1164 1169
1254 }); 1259 });
1255 1260
1256 $table 1261 $table
1257} 1262}
1258 1263
1264my %SORT_ORDER = (
1265 type => undef,
1266 mtime => sub { sort {
1267 ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED)
1268 or $b->{mtime} <=> $a->{mtime}
1269 or $a->{type} <=> $b->{type}
1270 } @_ },
1271 weight => sub { sort {
1272 $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1)
1273 or $a->{type} <=> $b->{type}
1274 } @_ },
1275);
1276
1259sub inventory_widget { 1277sub inventory_widget {
1260 my $hb = new CFClient::UI::HBox homogeneous => 1; 1278 my $hb = new CFClient::UI::HBox homogeneous => 1;
1261 1279
1262 $hb->add (my $vb1 = new CFClient::UI::VBox); 1280 $hb->add (my $vb1 = new CFClient::UI::VBox);
1263 $vb1->add (new CFClient::UI::Label align => 0, text => "Player"); 1281 $vb1->add (new CFClient::UI::Label align => 0, text => "Player");
1282
1283 $vb1->add (my $hb1 = new CFClient::UI::HBox);
1284
1285 use sort 'stable';
1286
1287 $hb1->add (new CFClient::UI::Selector
1288 value => $::CFG->{inv_sort},
1289 options => [
1290 [type => "Type/Name"],
1291 [mtime => "Recent/Normal/Locked"],
1292 [weight => "Weight/Type"],
1293 ],
1294 on_changed => sub {
1295 $::CFG->{inv_sort} = $_[1];
1296 $INV->set_sort_order ($SORT_ORDER{$_[1]});
1297 },
1298 );
1299 $hb1->add (new CFClient::UI::Label text => "Weight: ", align => 1, expand => 1);
1300 #TODO# update to weigh/maxweight
1301 $hb1->add ($STATWIDS->{i_weight} = new CFClient::UI::Label align => -1);
1302
1264 $vb1->add (my $sw1 = new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1); 1303 $vb1->add (my $sw1 = new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1);
1265 $sw1->add ($INV = new CFClient::UI::Inventory); 1304 $sw1->add ($INV = new CFClient::UI::Inventory);
1266 1305
1267 $hb->add (my $vb2 = new CFClient::UI::VBox); 1306 $hb->add (my $vb2 = new CFClient::UI::VBox);
1268 1307
1460 1499
1461 my $parser = HTML::Parser->new ( 1500 my $parser = HTML::Parser->new (
1462 text_h => [sub { 1501 text_h => [sub {
1463 my ($text) = @_; 1502 my ($text) = @_;
1464 $text =~ s/\s+/ /g; 1503 $text =~ s/\s+/ /g;
1465 $s[-1]{text} .= CFClient::UI::Label::escape $text; 1504 $s[-1]{text} .= CFClient::asxml $text;
1466 }, "dtext"], 1505 }, "dtext"],
1467 start_h => [sub { 1506 start_h => [sub {
1468 my ($tag, $attr) = @_; 1507 my ($tag, $attr) = @_;
1469 if ($passthrough{$tag}) { 1508 if ($passthrough{$tag}) {
1470 $s[-1]{text} .= "<$tag>"; 1509 $s[-1]{text} .= "<$tag>";
1535 $vbox->add (my $buttons = new CFClient::UI::HBox); 1574 $vbox->add (my $buttons = new CFClient::UI::HBox);
1536 $vbox->add (my $viewer = new CFClient::UI::TextScroller 1575 $vbox->add (my $viewer = new CFClient::UI::TextScroller
1537 expand => 1, fontsize => 0.8, padding_x => 4); 1576 expand => 1, fontsize => 0.8, padding_x => 4);
1538 1577
1539 $buttons->add (new CFClient::UI::Label text => "Choose a document to display: "); 1578 $buttons->add (new CFClient::UI::Label text => "Choose a document to display: ");
1540 $buttons->add (my $combo = new CFClient::UI::Combobox 1579 $buttons->add (my $combo = new CFClient::UI::Selector
1541 value => undef, 1580 value => undef,
1542 options => [ 1581 options => [
1543 [intro => "Introduction"], 1582 [intro => "Introduction"],
1544 [manual => "Main Manual"], 1583 [manual => "Main Manual"],
1545 [skill_help => "Skill Reference"], 1584 [skill_help => "Skill Reference"],
1557 }; 1596 };
1558 warn "$@" if $@; 1597 warn "$@" if $@;
1559 return; 1598 return;
1560 } 1599 }
1561 1600
1562 my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", 1601 my $pom = CFClient::Pod::load CFClient::find_rcfile "pod/$pod.pod",
1563 doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; 1602 doc_viewer => 1, sub { CFClient::Pod::as_paragraphs $_[0] };
1603
1604 #use Data::Dumper; warn Dumper $pom;#d#
1564 1605
1565 $viewer->clear; 1606 $viewer->clear;
1566 1607
1567# $viewer->add_paragraph ([1, 1, 1, 1], ["<big>Test</big>\n\n \x{fffc} \x{fffc}\n", 1608# $viewer->add_paragraph ([1, 1, 1, 1], ["<big>Test</big>\n\n \x{fffc} \x{fffc}\n",
1568# (new CFClient::UI::Image path => "x.png", can_hover => 1, can_events => 1), 1609# (new CFClient::UI::Image path => "x.png", can_hover => 1, can_events => 1),
1569# (new CFClient::UI::Label text => "üüüü", can_hover => 1, can_events => 1, tooltip => "??"), 1610# (new CFClient::UI::Label text => "üüüü", can_hover => 1, can_events => 1, tooltip => "??"),
1570# ]);#d# 1611# ]);#d#
1571 1612
1572 $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) 1613 $viewer->add_paragraph ([1, 1, 1, 1], [$_->{text}, @{ $_->{obj} || [] }], $_->{indent})
1573 for @$pom; 1614 for @$pom;
1574 1615
1575 $viewer->set_offset (0); 1616 $viewer->set_offset (0);
1576 1617
1577 0 1618 0
1843 1884
1844 $WANT_REFRESH = 0; 1885 $WANT_REFRESH = 0;
1845 $CAN_REFRESH = 0; 1886 $CAN_REFRESH = 0;
1846 $LAST_REFRESH = $NOW; 1887 $LAST_REFRESH = $NOW;
1847 1888
18480 && do {
1849 # some weird model-drawing code, just a joke right now
1850 use CFClient::OpenGL;
1851
1852 $demo{t}{eye_auv} ||= new_from_file CFClient::Texture "eye2.png" or die;
1853 $demo{t}{body_auv} ||= new_from_file CFClient::Texture "body_auv3.png" or die;
1854 $demo{r} ||= do {
1855 my $mod = Compress::LZF::sthaw do { local $/; open my $fh, "<:raw:perlio", "dread.lz3"; <$fh> };
1856 $mod->{v} = pack "f*", @{$mod->{v}};
1857 $_ = [scalar @$_, pack "S!*", @$_]
1858 for values %{$mod->{g}};
1859 $mod
1860 };
1861
1862 my $r = $demo{r} or die;
1863
1864 glDepthMask 1;
1865 glClear GL_DEPTH_BUFFER_BIT;
1866 glEnable GL_TEXTURE_2D;
1867 glEnable GL_DEPTH_TEST;
1868 glEnable GL_CULL_FACE;
1869 glShadeModel $::FAST ? GL_FLAT : GL_SMOOTH;
1870
1871 glMatrixMode GL_PROJECTION;
1872 glLoadIdentity;
1873 glFrustum -1 * ($::WIDTH / $::HEIGHT), 1 * ($::WIDTH / $::HEIGHT), 1, -1, 1, 10000;
1874 #glOrtho 0, $::WIDTH, 0, $::HEIGHT, -10000, 10000;
1875 glMatrixMode GL_MODELVIEW;
1876 glLoadIdentity;
1877
1878 glPushMatrix;
1879 glTranslate 0, 0, -800;
1880 glScale 1, -1, 1;
1881 glRotate $NOW * 1000 % 36000 / 5, 0, 1, 0;
1882 glRotate $NOW * 1000 % 36000 / 6, 1, 0, 0;
1883 glRotate $NOW * 1000 % 36000 / 7, 0, 0, 1;
1884 glScale 50, 50, 50;
1885
1886 glInterleavedArrays GL_T2F_N3F_V3F, 0, $r->{v};
1887 while (my ($k, $v) = each %{$r->{g}}) {
1888 glBindTexture GL_TEXTURE_2D, ($demo{t}{$k}{name} or die);
1889 glDrawElements GL_TRIANGLES, $v->[0], GL_UNSIGNED_SHORT, $v->[1];
1890 }
1891
1892 glPopMatrix;
1893
1894 glShadeModel GL_FLAT;
1895 glDisable GL_DEPTH_TEST;
1896 glDisable GL_TEXTURE_2D;
1897 glDepthMask 0;
1898
1899 $WANT_REFRESH++;
1900};
1901
1902 CFClient::SDL_GL_SwapBuffers; 1889 CFClient::SDL_GL_SwapBuffers;
1903} 1890}
1904 1891
1905my $refresh_watcher = Event->timer (after => 0, hard => 0, interval => 1 / $MAX_FPS, cb => sub { 1892my $refresh_watcher = Event->timer (after => 0, hard => 0, interval => 1 / $MAX_FPS, cb => sub {
1906 $NOW = time; 1893 $NOW = time;
2010 bgm_volume => 0.25, 1997 bgm_volume => 0.25,
2011 face_prefetch => 0, 1998 face_prefetch => 0,
2012 output_sync => 1, 1999 output_sync => 1,
2013 output_count => 1, 2000 output_count => 1,
2014 pickup => 0, 2001 pickup => 0,
2002 inv_sort => "mtime",
2015 default => "profile", # default profile 2003 default => "profile", # default profile
2016 ); 2004 );
2017 2005
2018 while (my ($k, $v) = each %DEF_CFG) { 2006 while (my ($k, $v) = each %DEF_CFG) {
2019 $CFG->{$k} = $v unless exists $CFG->{$k}; 2007 $CFG->{$k} = $v unless exists $CFG->{$k};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines