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.131 by root, Sun Nov 19 20:31:29 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
150 149
151our $BIND_EDITOR; 150our $BIND_EDITOR;
152our $BIND_UPD_CB; 151our $BIND_UPD_CB;
153 152
154our $PICKUP_CFG; 153our $PICKUP_CFG;
154
155our $IN_BUILD_MODE;
156our $BUILD_BUTTON;
155 157
156sub status { 158sub status {
157 $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]);
158} 160}
159 161
430sub stop_game { 432sub stop_game {
431 $LOGIN_BUTTON->set_text ("Login"); 433 $LOGIN_BUTTON->set_text ("Login");
432 $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); 434 $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER);
433 $SETUP_DIALOG->show; 435 $SETUP_DIALOG->show;
434 $PL_WINDOW->hide; 436 $PL_WINDOW->hide;
435 $SPELL_PAGE->clear_spells; 437 $SPELL_LIST->clear_spells;
436 438
437 return unless $CONN; 439 return unless $CONN;
438 440
439 status "connection closed"; 441 status "connection closed";
440 442
667 $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 });
668 $table->add (0, 2, new CFPlus::UI::Label text => "Show FPS"); 670 $table->add (0, 2, new CFPlus::UI::Label text => "Show FPS");
669 $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 });
670 $table->add (0, 3, new CFPlus::UI::Label text => "Suppress Tooltips"); 672 $table->add (0, 3, new CFPlus::UI::Label text => "Suppress Tooltips");
671 $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" } );
672 675
673 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);
674 677
675 for my $x (0..2) { 678 for my $x (0..2) {
676 for my $y (0 .. 2) { 679 for my $y (0 .. 2) {
680 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 },
681 ); 684 );
682 } 685 }
683 } 686 }
684 687
688 $table->add (0, 5, new CFPlus::UI::TextEdit text => "line1\0152\0153");#d#
685 689
686 $table 690 $table
687} 691}
688 692
689sub stats_window { 693sub stats_window {
1190 ["Boots" => PICKUP_BOOTS], 1194 ["Boots" => PICKUP_BOOTS],
1191 ["Gloves" => PICKUP_GLOVES], 1195 ["Gloves" => PICKUP_GLOVES],
1192 ["Cloaks" => PICKUP_CLOAK], 1196 ["Cloaks" => PICKUP_CLOAK],
1193 ], 1197 ],
1194 1198
1195 ["Readables", 2, 2, 1199 ["Readables", 2, 0,
1196 ["Spellbooks" => PICKUP_SPELLBOOK], 1200 ["Spellbooks" => PICKUP_SPELLBOOK],
1197 ["Skillscrolls" => PICKUP_SKILLSCROLL], 1201 ["Skillscrolls" => PICKUP_SKILLSCROLL],
1198 ["Normal Books/Scrolls" => PICKUP_READABLES], 1202 ["Normal Books/Scrolls" => PICKUP_READABLES],
1199 ], 1203 ],
1200 ["Misc", 2, 7, 1204 ["Misc", 2, 5,
1201 ["Food" => PICKUP_FOOD], 1205 ["Food" => PICKUP_FOOD],
1202 ["Drinks" => PICKUP_DRINK], 1206 ["Drinks" => PICKUP_DRINK],
1203 ["Valuables (Money, Gems)" => PICKUP_VALUABLES], 1207 ["Valuables (Money, Gems)" => PICKUP_VALUABLES],
1204 ["Keys" => PICKUP_KEY], 1208 ["Keys" => PICKUP_KEY],
1205 ["Magical Items" => PICKUP_MAGICAL], 1209 ["Magical Items" => PICKUP_MAGICAL],
1206 ["Potions" => PICKUP_POTION], 1210 ["Potions" => PICKUP_POTION],
1207 ["Magic Devices" => PICKUP_MAGIC_DEVICE], 1211 ["Magic Devices" => PICKUP_MAGIC_DEVICE],
1208 ["Ignore cursed" => PICKUP_NOT_CURSED], 1212 ["Ignore cursed" => PICKUP_NOT_CURSED],
1209 ["Jewelery" => PICKUP_JEWELS], 1213 ["Jewelery" => PICKUP_JEWELS],
1214 ["Flesh" => PICKUP_FLESH],
1210 ], 1215 ],
1211 ["Weight/Value ratio", 2, 17] 1216 ["Weight/Value ratio", 2, 17]
1212 ) 1217 )
1213 { 1218 {
1214 my ($title, $x, $y, @bits) = @$_; 1219 my ($title, $x, $y, @bits) = @$_;
1861 ); 1866 );
1862 1867
1863 $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,
1864 tooltip => "View Documentation"); 1869 tooltip => "View Documentation");
1865 1870
1871
1866 $BUTTONBAR->add (new CFPlus::UI::Button 1872 $BUTTONBAR->add (new CFPlus::UI::Button
1867 text => "Quit", 1873 text => "Quit",
1868 tooltip => "Terminates the program", 1874 tooltip => "Terminates the program",
1869 on_activate => sub { 1875 on_activate => sub {
1870 if ($CONN) { 1876 if ($CONN) {
1879 $BUTTONBAR->show; 1885 $BUTTONBAR->show;
1880 $SETUP_DIALOG->show; 1886 $SETUP_DIALOG->show;
1881 } 1887 }
1882 1888
1883 $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]);
1890}
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;
1884} 2008}
1885 2009
1886sub video_shutdown { 2010sub video_shutdown {
1887 CFPlus::OpenGL::shutdown; 2011 CFPlus::OpenGL::shutdown;
1888 2012

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines