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.136 by root, Fri Dec 8 14:59:54 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) {
679 on_changed => sub { $MAP->{smooth_matrix}[$x * 3 + $y] = $_[1] if $MAP; 0 }, 683 on_changed => sub { $MAP->{smooth_matrix}[$x * 3 + $y] = $_[1] if $MAP; 0 },
680 ); 684 );
681 } 685 }
682 } 686 }
683 687
688 $table->add (0, 5, new CFPlus::UI::TextEdit text => "line1\0152\0153");#d#
684 689
685 $table 690 $table
686} 691}
687 692
688sub stats_window { 693sub stats_window {
1189 ["Boots" => PICKUP_BOOTS], 1194 ["Boots" => PICKUP_BOOTS],
1190 ["Gloves" => PICKUP_GLOVES], 1195 ["Gloves" => PICKUP_GLOVES],
1191 ["Cloaks" => PICKUP_CLOAK], 1196 ["Cloaks" => PICKUP_CLOAK],
1192 ], 1197 ],
1193 1198
1194 ["Readables", 2, 2, 1199 ["Readables", 2, 0,
1195 ["Spellbooks" => PICKUP_SPELLBOOK], 1200 ["Spellbooks" => PICKUP_SPELLBOOK],
1196 ["Skillscrolls" => PICKUP_SKILLSCROLL], 1201 ["Skillscrolls" => PICKUP_SKILLSCROLL],
1197 ["Normal Books/Scrolls" => PICKUP_READABLES], 1202 ["Normal Books/Scrolls" => PICKUP_READABLES],
1198 ], 1203 ],
1199 ["Misc", 2, 7, 1204 ["Misc", 2, 5,
1200 ["Food" => PICKUP_FOOD], 1205 ["Food" => PICKUP_FOOD],
1201 ["Drinks" => PICKUP_DRINK], 1206 ["Drinks" => PICKUP_DRINK],
1202 ["Valuables (Money, Gems)" => PICKUP_VALUABLES], 1207 ["Valuables (Money, Gems)" => PICKUP_VALUABLES],
1203 ["Keys" => PICKUP_KEY], 1208 ["Keys" => PICKUP_KEY],
1204 ["Magical Items" => PICKUP_MAGICAL], 1209 ["Magical Items" => PICKUP_MAGICAL],
1205 ["Potions" => PICKUP_POTION], 1210 ["Potions" => PICKUP_POTION],
1206 ["Magic Devices" => PICKUP_MAGIC_DEVICE], 1211 ["Magic Devices" => PICKUP_MAGIC_DEVICE],
1207 ["Ignore cursed" => PICKUP_NOT_CURSED], 1212 ["Ignore cursed" => PICKUP_NOT_CURSED],
1208 ["Jewelery" => PICKUP_JEWELS], 1213 ["Jewelery" => PICKUP_JEWELS],
1214 ["Flesh" => PICKUP_FLESH],
1209 ], 1215 ],
1210 ["Weight/Value ratio", 2, 17] 1216 ["Weight/Value ratio", 2, 17]
1211 ) 1217 )
1212 { 1218 {
1213 my ($title, $x, $y, @bits) = @$_; 1219 my ($title, $x, $y, @bits) = @$_;
1263 $table 1269 $table
1264} 1270}
1265 1271
1266my %SORT_ORDER = ( 1272my %SORT_ORDER = (
1267 type => undef, 1273 type => undef,
1268 mtime => sub { sort { 1274 mtime => sub {
1275 my $NOW = time;
1276 sort {
1277 my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6;
1278 my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6;
1279
1269 ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) 1280 ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED)
1270 or $b->{mtime} <=> $a->{mtime} 1281 or $btime <=> $atime
1271 or $a->{type} <=> $b->{type} 1282 or $a->{type} <=> $b->{type}
1283 } @_
1272 } @_ }, 1284 },
1273 weight => sub { sort { 1285 weight => sub { sort {
1274 $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) 1286 $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1)
1275 or $a->{type} <=> $b->{type} 1287 or $a->{type} <=> $b->{type}
1276 } @_ }, 1288 } @_ },
1277); 1289);
1352 $ntb->add ( 1364 $ntb->add (
1353 "Skills (F3)" => $SKILL_PAGE = skill_window, 1365 "Skills (F3)" => $SKILL_PAGE = skill_window,
1354 "Shows all your Skills." 1366 "Shows all your Skills."
1355 ); 1367 );
1356 1368
1357 my $spellsw = new CFPlus::UI::ScrolledWindow (expand => 1, scroll_y => 1); 1369 my $spellsw = $SPELL_PAGE = new CFPlus::UI::ScrolledWindow (expand => 1, scroll_y => 1);
1358 $spellsw->add ($SPELL_PAGE = new CFPlus::UI::SpellList); 1370 $spellsw->add ($SPELL_LIST = new CFPlus::UI::SpellList);
1359 $ntb->add ( 1371 $ntb->add (
1360 "Spellbook (F4)" => $spellsw, 1372 "Spellbook (F4)" => $spellsw,
1361 "Displays all spells you have and lets you edit keyboard shortcuts for them." 1373 "Displays all spells you have and lets you edit keyboard shortcuts for them."
1362 ); 1374 );
1363 $ntb->add ( 1375 $ntb->add (
1854 ); 1866 );
1855 1867
1856 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, 1868 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window,
1857 tooltip => "View Documentation"); 1869 tooltip => "View Documentation");
1858 1870
1871
1859 $BUTTONBAR->add (new CFPlus::UI::Button 1872 $BUTTONBAR->add (new CFPlus::UI::Button
1860 text => "Quit", 1873 text => "Quit",
1861 tooltip => "Terminates the program", 1874 tooltip => "Terminates the program",
1862 on_activate => sub { 1875 on_activate => sub {
1863 if ($CONN) { 1876 if ($CONN) {
1874 } 1887 }
1875 1888
1876 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); 1889 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
1877} 1890}
1878 1891
1892sub setup_build_button {
1893 my ($enabled) = @_;
1894 if ($enabled) {
1895 $BUILD_BUTTON ||= new CFPlus::UI::Button
1896 text => "Build",
1897 tooltip => "Opens the ingame builder",
1898 on_activate => sub {
1899 if ($CONN) {
1900 $CONN->send_ext_req (builder_player_items => sub {
1901 open_ingame_editor ($_[0]) if exists $_[0]->{items};
1902 });
1903 }
1904 0
1905 };
1906 $BUTTONBAR->add ($BUILD_BUTTON);
1907 } else {
1908 $BUILD_BUTTON->hide if $BUILD_BUTTON;
1909 }
1910}
1911
1912sub open_ingame_editor {
1913 my ($msg) = @_;
1914
1915 my $win = new CFPlus::UI::Toplevel
1916 x => 0,
1917 y => 'center',
1918 z => 4,
1919 name => 'builder_window',
1920 force_w => int $WIDTH * 1/4,
1921 force_h => int $HEIGHT * 3/4,
1922 title => "In game builder",
1923 has_close_button => 1;
1924
1925 my $r = new CFPlus::UI::ScrolledWindow (
1926 expand => 1,
1927 scroll_y => 1
1928 );
1929 $r->add (my $vb = new CFPlus::UI::VBox);
1930 $win->add ($r);
1931
1932
1933 $vb->add (
1934 new CFPlus::UI::Button
1935 text => "Disable build mode",
1936 on_activate => sub { $::IN_BUILD_MODE = undef }
1937 );
1938 $vb->add (
1939 new CFPlus::UI::Button
1940 text => "ERASE",
1941 on_activate => sub { $::IN_BUILD_MODE = { do_erase => 1 } }
1942 );
1943
1944 for my $itemarchname (
1945 sort {
1946 $msg->{items}->{$a}->{build_arch_name}
1947 cmp $msg->{items}->{$b}->{build_arch_name}
1948 } keys %{$msg->{items}}
1949 ) {
1950 my $info = $msg->{items}->{$itemarchname};
1951 $vb->add (
1952 new CFPlus::UI::Button text => $info->{build_arch_name},
1953 on_activate => sub {
1954 $::IN_BUILD_MODE = { item => $itemarchname, info => $info };
1955
1956 if (grep { $msg->{items}->{$itemarchname}->{$_} } qw/has_connection has_name has_text/) {
1957 build_mode_query_arch_info ();
1958 }
1959 }
1960 );
1961 }
1962
1963 $win->show;
1964}
1965
1966sub build_mode_query_arch_info {
1967 my ($iteminfo) = $::IN_BUILD_MODE;
1968 my $itemarchname = $iteminfo->{item};
1969 my $info = $iteminfo->{info};
1970
1971 my $dialog = new CFPlus::UI::Toplevel
1972 x => "center",
1973 y => "center",
1974 z => 50,
1975 force_w => int $WIDTH * 1/2,
1976 title => "Enter information for placement of '$itemarchname'",
1977 has_close_button => 1;
1978
1979 $dialog->add (my $vb = new CFPlus::UI::VBox expand => 1);
1980
1981 $vb->add (my $table = new CFPlus::UI::Table expand => 1);
1982 my $row = 0;
1983 if ($info->{has_name}) {
1984 $table->add (0, $row, new CFPlus::UI::Label text => "Name:");
1985 $table->add (1, $row++, new CFPlus::UI::Entry expand => 1, on_changed => sub { $::IN_BUILD_MODE->{name} = $_[1]; 0 });
1986 }
1987 if ($info->{has_text}) {
1988 $table->add (0, $row, new CFPlus::UI::Label text => "Text:");
1989 $table->add (1, $row++, new CFPlus::UI::Entry expand => 1, on_changed => sub { $::IN_BUILD_MODE->{text} = $_[1]; 0 });
1990 }
1991 if ($info->{has_connection}) {
1992 $table->add (0, $row, new CFPlus::UI::Label text => "Connection ID:");
1993 $table->add (1, $row++,
1994 new CFPlus::UI::Entry
1995 expand => 1,
1996 on_changed => sub { $::IN_BUILD_MODE->{connection} = $_[1]; 0 },
1997 tooltip => "Enter the connection ID here. The connection ID connects actors like a lever to a gate or a magic ear to a gate"
1998 );
1999 }
2000
2001 $vb->add (my $hb = new CFPlus::UI::HBox expand => 1);
2002 $hb->add (new CFPlus::UI::Button
2003 text => "Close",
2004 expand => 1,
2005 on_activate => sub { $dialog->hide; 0 },
2006 );
2007 $dialog->show;
2008}
2009
1879sub video_shutdown { 2010sub video_shutdown {
1880 CFPlus::OpenGL::shutdown; 2011 CFPlus::OpenGL::shutdown;
1881 2012
1882 undef $SDL_ACTIVE; 2013 undef $SDL_ACTIVE;
1883} 2014}
1916 2047
1917 audio_music_finished; 2048 audio_music_finished;
1918 2049
1919 local $_; 2050 local $_;
1920 while (<$fh>) { 2051 while (<$fh>) {
1921 last;
1922 next if /^\s*#/; 2052 next if /^\s*#/;
1923 next if /^\s*$/; 2053 next if /^\s*$/;
1924 2054
1925 my ($file, $volume, $event) = split /\s+/, $_, 3; 2055 my ($file, $volume, $event) = split /\s+/, $_, 3;
1926 2056

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines