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.129 by root, Sun Nov 19 00:07:51 2006 UTC vs.
Revision 1.135 by elmex, Tue Dec 5 16:53:29 2006 UTC

21 } 21 }
22} 22}
23 23
24use strict; 24use strict;
25use utf8; 25use utf8;
26
27use Carp 'verbose';
26 28
27# do things only needed for single-binary version (par) 29# do things only needed for single-binary version (par)
28BEGIN { 30BEGIN {
29 if (%PAR::LibCache) { 31 if (%PAR::LibCache) {
30 @INC = grep ref, @INC; # weed out all paths except pars loader refs 32 @INC = grep ref, @INC; # weed out all paths except pars loader refs
66$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 68$SIG{QUIT} = sub { Carp::cluck "QUIT" };
67$SIG{PIPE} = 'IGNORE'; 69$SIG{PIPE} = 'IGNORE';
68 70
69$Event::Eval = 0; 71$Event::Eval = 0;
70$Event::DIED = sub { 72$Event::DIED = sub {
71 # TODO: display dialog box or so 73 CFPlus::fatal Carp::longmess $_[1]
72 Carp::cluck $_[1];#d#TODO: remove when stable
73 return;#d#
74 CFPlus::fatal ($_[1]);
75}; 74};
76 75
77my $MAX_FPS = 60; 76my $MAX_FPS = 60;
78my $MIN_FPS = 5; # unused as of yet 77my $MIN_FPS = 5; # unused as of yet
79 78
123 122
124our $INVENTORY_PAGE; 123our $INVENTORY_PAGE;
125our $STATS_PAGE; 124our $STATS_PAGE;
126our $SKILL_PAGE; 125our $SKILL_PAGE;
127our $SPELL_PAGE; 126our $SPELL_PAGE;
127our $SPELL_LIST;
128 128
129our $HELP_WINDOW; 129our $HELP_WINDOW;
130our $MESSAGE_WINDOW; 130our $MESSAGE_WINDOW;
131our $FLOORBOX; 131our $FLOORBOX;
132our $GAUGES; 132our $GAUGES;
149 149
150our $BIND_EDITOR; 150our $BIND_EDITOR;
151our $BIND_UPD_CB; 151our $BIND_UPD_CB;
152 152
153our $PICKUP_CFG; 153our $PICKUP_CFG;
154
155our $IN_BUILD_MODE;
156our $BUILD_BUTTON;
154 157
155sub status { 158sub status {
156 $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); 159 $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
157} 160}
158 161
429sub stop_game { 432sub stop_game {
430 $LOGIN_BUTTON->set_text ("Login"); 433 $LOGIN_BUTTON->set_text ("Login");
431 $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); 434 $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER);
432 $SETUP_DIALOG->show; 435 $SETUP_DIALOG->show;
433 $PL_WINDOW->hide; 436 $PL_WINDOW->hide;
434 $SPELL_PAGE->clear_spells; 437 $SPELL_LIST->clear_spells;
435 438
436 return unless $CONN; 439 return unless $CONN;
437 440
438 status "connection closed"; 441 status "connection closed";
439 442
666 $table->add (1, 1, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 }); 669 $table->add (1, 1, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 });
667 $table->add (0, 2, new CFPlus::UI::Label text => "Show FPS"); 670 $table->add (0, 2, new CFPlus::UI::Label text => "Show FPS");
668 $table->add (1, 2, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 }); 671 $table->add (1, 2, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 });
669 $table->add (0, 3, new CFPlus::UI::Label text => "Suppress Tooltips"); 672 $table->add (0, 3, new CFPlus::UI::Label text => "Suppress Tooltips");
670 $table->add (1, 3, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 }); 673 $table->add (1, 3, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 });
674 $table->add (0, 4, new CFPlus::UI::Button text => "die on click(tm)", on_activate => sub { die "violator" } );
671 675
672 my @default_smooth = (0.05, 0.13, 0.05, 0.13, 0.30, 0.13, 0.05, 0.13, 0.05); 676 my @default_smooth = (0.05, 0.13, 0.05, 0.13, 0.30, 0.13, 0.05, 0.13, 0.05);
673 677
674 for my $x (0..2) { 678 for my $x (0..2) {
675 for my $y (0 .. 2) { 679 for my $y (0 .. 2) {
1189 ["Boots" => PICKUP_BOOTS], 1193 ["Boots" => PICKUP_BOOTS],
1190 ["Gloves" => PICKUP_GLOVES], 1194 ["Gloves" => PICKUP_GLOVES],
1191 ["Cloaks" => PICKUP_CLOAK], 1195 ["Cloaks" => PICKUP_CLOAK],
1192 ], 1196 ],
1193 1197
1194 ["Readables", 2, 2, 1198 ["Readables", 2, 0,
1195 ["Spellbooks" => PICKUP_SPELLBOOK], 1199 ["Spellbooks" => PICKUP_SPELLBOOK],
1196 ["Skillscrolls" => PICKUP_SKILLSCROLL], 1200 ["Skillscrolls" => PICKUP_SKILLSCROLL],
1197 ["Normal Books/Scrolls" => PICKUP_READABLES], 1201 ["Normal Books/Scrolls" => PICKUP_READABLES],
1198 ], 1202 ],
1199 ["Misc", 2, 7, 1203 ["Misc", 2, 5,
1200 ["Food" => PICKUP_FOOD], 1204 ["Food" => PICKUP_FOOD],
1201 ["Drinks" => PICKUP_DRINK], 1205 ["Drinks" => PICKUP_DRINK],
1202 ["Valuables (Money, Gems)" => PICKUP_VALUABLES], 1206 ["Valuables (Money, Gems)" => PICKUP_VALUABLES],
1203 ["Keys" => PICKUP_KEY], 1207 ["Keys" => PICKUP_KEY],
1204 ["Magical Items" => PICKUP_MAGICAL], 1208 ["Magical Items" => PICKUP_MAGICAL],
1205 ["Potions" => PICKUP_POTION], 1209 ["Potions" => PICKUP_POTION],
1206 ["Magic Devices" => PICKUP_MAGIC_DEVICE], 1210 ["Magic Devices" => PICKUP_MAGIC_DEVICE],
1207 ["Ignore cursed" => PICKUP_NOT_CURSED], 1211 ["Ignore cursed" => PICKUP_NOT_CURSED],
1208 ["Jewelery" => PICKUP_JEWELS], 1212 ["Jewelery" => PICKUP_JEWELS],
1213 ["Flesh" => PICKUP_FLESH],
1209 ], 1214 ],
1210 ["Weight/Value ratio", 2, 17] 1215 ["Weight/Value ratio", 2, 17]
1211 ) 1216 )
1212 { 1217 {
1213 my ($title, $x, $y, @bits) = @$_; 1218 my ($title, $x, $y, @bits) = @$_;
1263 $table 1268 $table
1264} 1269}
1265 1270
1266my %SORT_ORDER = ( 1271my %SORT_ORDER = (
1267 type => undef, 1272 type => undef,
1268 mtime => sub { sort { 1273 mtime => sub {
1274 my $NOW = time;
1275 sort {
1276 my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6;
1277 my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6;
1278
1269 ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) 1279 ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED)
1270 or $b->{mtime} <=> $a->{mtime} 1280 or $btime <=> $atime
1271 or $a->{type} <=> $b->{type} 1281 or $a->{type} <=> $b->{type}
1282 } @_
1272 } @_ }, 1283 },
1273 weight => sub { sort { 1284 weight => sub { sort {
1274 $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) 1285 $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1)
1275 or $a->{type} <=> $b->{type} 1286 or $a->{type} <=> $b->{type}
1276 } @_ }, 1287 } @_ },
1277); 1288);
1352 $ntb->add ( 1363 $ntb->add (
1353 "Skills (F3)" => $SKILL_PAGE = skill_window, 1364 "Skills (F3)" => $SKILL_PAGE = skill_window,
1354 "Shows all your Skills." 1365 "Shows all your Skills."
1355 ); 1366 );
1356 1367
1357 my $spellsw = new CFPlus::UI::ScrolledWindow (expand => 1, scroll_y => 1); 1368 my $spellsw = $SPELL_PAGE = new CFPlus::UI::ScrolledWindow (expand => 1, scroll_y => 1);
1358 $spellsw->add ($SPELL_PAGE = new CFPlus::UI::SpellList); 1369 $spellsw->add ($SPELL_LIST = new CFPlus::UI::SpellList);
1359 $ntb->add ( 1370 $ntb->add (
1360 "Spellbook (F4)" => $spellsw, 1371 "Spellbook (F4)" => $spellsw,
1361 "Displays all spells you have and lets you edit keyboard shortcuts for them." 1372 "Displays all spells you have and lets you edit keyboard shortcuts for them."
1362 ); 1373 );
1363 $ntb->add ( 1374 $ntb->add (
1854 ); 1865 );
1855 1866
1856 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, 1867 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window,
1857 tooltip => "View Documentation"); 1868 tooltip => "View Documentation");
1858 1869
1870
1859 $BUTTONBAR->add (new CFPlus::UI::Button 1871 $BUTTONBAR->add (new CFPlus::UI::Button
1860 text => "Quit", 1872 text => "Quit",
1861 tooltip => "Terminates the program", 1873 tooltip => "Terminates the program",
1862 on_activate => sub { 1874 on_activate => sub {
1863 if ($CONN) { 1875 if ($CONN) {
1874 } 1886 }
1875 1887
1876 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); 1888 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
1877} 1889}
1878 1890
1891sub setup_build_button {
1892 my ($enabled) = @_;
1893 if ($enabled) {
1894 $BUILD_BUTTON ||= new CFPlus::UI::Button
1895 text => "Build",
1896 tooltip => "Opens the ingame builder",
1897 on_activate => sub {
1898 if ($CONN) {
1899 $CONN->send_ext_req (builder_player_items => sub {
1900 open_ingame_editor ($_[0]) if exists $_[0]->{items};
1901 });
1902 }
1903 0
1904 };
1905 $BUTTONBAR->add ($BUILD_BUTTON);
1906 } else {
1907 $BUILD_BUTTON->hide if $BUILD_BUTTON;
1908 }
1909}
1910
1911sub open_ingame_editor {
1912 my ($msg) = @_;
1913
1914 my $win = new CFPlus::UI::Toplevel
1915 x => 0,
1916 y => 'center',
1917 z => 4,
1918 name => 'builder_window',
1919 force_w => int $WIDTH * 1/4,
1920 force_h => int $HEIGHT * 3/4,
1921 title => "In game builder",
1922 has_close_button => 1;
1923
1924 my $r = new CFPlus::UI::ScrolledWindow (
1925 expand => 1,
1926 scroll_y => 1
1927 );
1928 $r->add (my $vb = new CFPlus::UI::VBox);
1929 $win->add ($r);
1930
1931
1932 $vb->add (
1933 new CFPlus::UI::Button
1934 text => "Disable build mode",
1935 on_activate => sub { $::IN_BUILD_MODE = undef }
1936 );
1937 $vb->add (
1938 new CFPlus::UI::Button
1939 text => "ERASE",
1940 on_activate => sub { $::IN_BUILD_MODE = { do_erase => 1 } }
1941 );
1942
1943 for my $itemarchname (
1944 sort {
1945 $msg->{items}->{$a}->{build_arch_name}
1946 cmp $msg->{items}->{$b}->{build_arch_name}
1947 } keys %{$msg->{items}}
1948 ) {
1949 my $info = $msg->{items}->{$itemarchname};
1950 $vb->add (
1951 new CFPlus::UI::Button text => $info->{build_arch_name},
1952 on_activate => sub {
1953 $::IN_BUILD_MODE = { item => $itemarchname, info => $info };
1954
1955 if (grep { $msg->{items}->{$itemarchname}->{$_} } qw/has_connection has_name has_text/) {
1956 build_mode_query_arch_info ();
1957 }
1958 }
1959 );
1960 }
1961
1962 $win->show;
1963}
1964
1965sub build_mode_query_arch_info {
1966 my ($iteminfo) = $::IN_BUILD_MODE;
1967 my $itemarchname = $iteminfo->{item};
1968 my $info = $iteminfo->{info};
1969
1970 my $dialog = new CFPlus::UI::Toplevel
1971 x => "center",
1972 y => "center",
1973 z => 50,
1974 force_w => int $WIDTH * 1/2,
1975 title => "Enter information for placement of '$itemarchname'",
1976 has_close_button => 1;
1977
1978 $dialog->add (my $vb = new CFPlus::UI::VBox expand => 1);
1979
1980 $vb->add (my $table = new CFPlus::UI::Table expand => 1);
1981 my $row = 0;
1982 if ($info->{has_name}) {
1983 $table->add (0, $row, new CFPlus::UI::Label text => "Name:");
1984 $table->add (1, $row++, new CFPlus::UI::Entry expand => 1, on_changed => sub { $::IN_BUILD_MODE->{name} = $_[1]; 0 });
1985 }
1986 if ($info->{has_text}) {
1987 $table->add (0, $row, new CFPlus::UI::Label text => "Text:");
1988 $table->add (1, $row++, new CFPlus::UI::Entry expand => 1, on_changed => sub { $::IN_BUILD_MODE->{text} = $_[1]; 0 });
1989 }
1990 if ($info->{has_connection}) {
1991 $table->add (0, $row, new CFPlus::UI::Label text => "Connection ID:");
1992 $table->add (1, $row++,
1993 new CFPlus::UI::Entry
1994 expand => 1,
1995 on_changed => sub { $::IN_BUILD_MODE->{connection} = $_[1]; 0 },
1996 tooltip => "Enter the connection ID here. The connection ID connects actors like a lever to a gate or a magic ear to a gate"
1997 );
1998 }
1999
2000 $vb->add (my $hb = new CFPlus::UI::HBox expand => 1);
2001 $hb->add (new CFPlus::UI::Button
2002 text => "Close",
2003 expand => 1,
2004 on_activate => sub { $dialog->hide; 0 },
2005 );
2006 $dialog->show;
2007}
2008
1879sub video_shutdown { 2009sub video_shutdown {
1880 CFPlus::OpenGL::shutdown; 2010 CFPlus::OpenGL::shutdown;
1881 2011
1882 undef $SDL_ACTIVE; 2012 undef $SDL_ACTIVE;
1883} 2013}
1916 2046
1917 audio_music_finished; 2047 audio_music_finished;
1918 2048
1919 local $_; 2049 local $_;
1920 while (<$fh>) { 2050 while (<$fh>) {
1921 last;
1922 next if /^\s*#/; 2051 next if /^\s*#/;
1923 next if /^\s*$/; 2052 next if /^\s*$/;
1924 2053
1925 my ($file, $volume, $event) = split /\s+/, $_, 3; 2054 my ($file, $volume, $event) = split /\s+/, $_, 3;
1926 2055

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines