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.99 by root, Sun Jul 23 08:58:44 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");
1264 1282
1265 $vb1->add (my $hb1 = new CFClient::UI::HBox); 1283 $vb1->add (my $hb1 = new CFClient::UI::HBox);
1266 1284
1267 use sort 'stable'; 1285 use sort 'stable';
1268 1286
1269 $hb1->add (new CFClient::UI::Combobox 1287 $hb1->add (new CFClient::UI::Selector
1270 value => undef, 1288 value => $::CFG->{inv_sort},
1271 options => [ 1289 options => [
1272 [undef, "Type/Name"], 1290 [type => "Type/Name"],
1273 [ 1291 [mtime => "Recent/Normal/Locked"],
1274 sub { sort {
1275 $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1)
1276 or $a->{type} <=> $b->{type}
1277 } @_ },
1278 "Weight/Type", 1292 [weight => "Weight/Type"],
1279 ],
1280 [sub { } => "#TODO#"],
1281 ], 1293 ],
1282 on_changed => sub { 1294 on_changed => sub {
1295 $::CFG->{inv_sort} = $_[1];
1283 $INV->set_sort_order ($_[1]); 1296 $INV->set_sort_order ($SORT_ORDER{$_[1]});
1284 }, 1297 },
1285 ); 1298 );
1286 $hb1->add (new CFClient::UI::Label text => "Weight: ", align => 1, expand => 1); 1299 $hb1->add (new CFClient::UI::Label text => "Weight: ", align => 1, expand => 1);
1287 #TODO# update to weigh/maxweight 1300 #TODO# update to weigh/maxweight
1288 $hb1->add ($STATWIDS->{i_weight} = new CFClient::UI::Label align => -1); 1301 $hb1->add ($STATWIDS->{i_weight} = new CFClient::UI::Label align => -1);
1486 1499
1487 my $parser = HTML::Parser->new ( 1500 my $parser = HTML::Parser->new (
1488 text_h => [sub { 1501 text_h => [sub {
1489 my ($text) = @_; 1502 my ($text) = @_;
1490 $text =~ s/\s+/ /g; 1503 $text =~ s/\s+/ /g;
1491 $s[-1]{text} .= CFClient::UI::Label::escape $text; 1504 $s[-1]{text} .= CFClient::asxml $text;
1492 }, "dtext"], 1505 }, "dtext"],
1493 start_h => [sub { 1506 start_h => [sub {
1494 my ($tag, $attr) = @_; 1507 my ($tag, $attr) = @_;
1495 if ($passthrough{$tag}) { 1508 if ($passthrough{$tag}) {
1496 $s[-1]{text} .= "<$tag>"; 1509 $s[-1]{text} .= "<$tag>";
1561 $vbox->add (my $buttons = new CFClient::UI::HBox); 1574 $vbox->add (my $buttons = new CFClient::UI::HBox);
1562 $vbox->add (my $viewer = new CFClient::UI::TextScroller 1575 $vbox->add (my $viewer = new CFClient::UI::TextScroller
1563 expand => 1, fontsize => 0.8, padding_x => 4); 1576 expand => 1, fontsize => 0.8, padding_x => 4);
1564 1577
1565 $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: ");
1566 $buttons->add (my $combo = new CFClient::UI::Combobox 1579 $buttons->add (my $combo = new CFClient::UI::Selector
1567 value => undef, 1580 value => undef,
1568 options => [ 1581 options => [
1569 [intro => "Introduction"], 1582 [intro => "Introduction"],
1570 [manual => "Main Manual"], 1583 [manual => "Main Manual"],
1571 [skill_help => "Skill Reference"], 1584 [skill_help => "Skill Reference"],
1583 }; 1596 };
1584 warn "$@" if $@; 1597 warn "$@" if $@;
1585 return; 1598 return;
1586 } 1599 }
1587 1600
1588 my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", 1601 my $pom = CFClient::Pod::load CFClient::find_rcfile "pod/$pod.pod",
1589 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#
1590 1605
1591 $viewer->clear; 1606 $viewer->clear;
1592 1607
1593# $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",
1594# (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),
1595# (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 => "??"),
1596# ]);#d# 1611# ]);#d#
1597 1612
1598 $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) 1613 $viewer->add_paragraph ([1, 1, 1, 1], [$_->{text}, @{ $_->{obj} || [] }], $_->{indent})
1599 for @$pom; 1614 for @$pom;
1600 1615
1601 $viewer->set_offset (0); 1616 $viewer->set_offset (0);
1602 1617
1603 0 1618 0
1869 1884
1870 $WANT_REFRESH = 0; 1885 $WANT_REFRESH = 0;
1871 $CAN_REFRESH = 0; 1886 $CAN_REFRESH = 0;
1872 $LAST_REFRESH = $NOW; 1887 $LAST_REFRESH = $NOW;
1873 1888
18740 && do {
1875 # some weird model-drawing code, just a joke right now
1876 use CFClient::OpenGL;
1877
1878 $demo{t}{eye_auv} ||= new_from_file CFClient::Texture "eye2.png" or die;
1879 $demo{t}{body_auv} ||= new_from_file CFClient::Texture "body_auv3.png" or die;
1880 $demo{r} ||= do {
1881 my $mod = Compress::LZF::sthaw do { local $/; open my $fh, "<:raw:perlio", "dread.lz3"; <$fh> };
1882 $mod->{v} = pack "f*", @{$mod->{v}};
1883 $_ = [scalar @$_, pack "S!*", @$_]
1884 for values %{$mod->{g}};
1885 $mod
1886 };
1887
1888 my $r = $demo{r} or die;
1889
1890 glDepthMask 1;
1891 glClear GL_DEPTH_BUFFER_BIT;
1892 glEnable GL_TEXTURE_2D;
1893 glEnable GL_DEPTH_TEST;
1894 glEnable GL_CULL_FACE;
1895 glShadeModel $::FAST ? GL_FLAT : GL_SMOOTH;
1896
1897 glMatrixMode GL_PROJECTION;
1898 glLoadIdentity;
1899 glFrustum -1 * ($::WIDTH / $::HEIGHT), 1 * ($::WIDTH / $::HEIGHT), 1, -1, 1, 10000;
1900 #glOrtho 0, $::WIDTH, 0, $::HEIGHT, -10000, 10000;
1901 glMatrixMode GL_MODELVIEW;
1902 glLoadIdentity;
1903
1904 glPushMatrix;
1905 glTranslate 0, 0, -800;
1906 glScale 1, -1, 1;
1907 glRotate $NOW * 1000 % 36000 / 5, 0, 1, 0;
1908 glRotate $NOW * 1000 % 36000 / 6, 1, 0, 0;
1909 glRotate $NOW * 1000 % 36000 / 7, 0, 0, 1;
1910 glScale 50, 50, 50;
1911
1912 glInterleavedArrays GL_T2F_N3F_V3F, 0, $r->{v};
1913 while (my ($k, $v) = each %{$r->{g}}) {
1914 glBindTexture GL_TEXTURE_2D, ($demo{t}{$k}{name} or die);
1915 glDrawElements GL_TRIANGLES, $v->[0], GL_UNSIGNED_SHORT, $v->[1];
1916 }
1917
1918 glPopMatrix;
1919
1920 glShadeModel GL_FLAT;
1921 glDisable GL_DEPTH_TEST;
1922 glDisable GL_TEXTURE_2D;
1923 glDepthMask 0;
1924
1925 $WANT_REFRESH++;
1926};
1927
1928 CFClient::SDL_GL_SwapBuffers; 1889 CFClient::SDL_GL_SwapBuffers;
1929} 1890}
1930 1891
1931my $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 {
1932 $NOW = time; 1893 $NOW = time;
2036 bgm_volume => 0.25, 1997 bgm_volume => 0.25,
2037 face_prefetch => 0, 1998 face_prefetch => 0,
2038 output_sync => 1, 1999 output_sync => 1,
2039 output_count => 1, 2000 output_count => 1,
2040 pickup => 0, 2001 pickup => 0,
2002 inv_sort => "mtime",
2041 default => "profile", # default profile 2003 default => "profile", # default profile
2042 ); 2004 );
2043 2005
2044 while (my ($k, $v) = each %DEF_CFG) { 2006 while (my ($k, $v) = each %DEF_CFG) {
2045 $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