--- deliantra/Deliantra-Client/bin/cfplus 2006/11/19 20:31:29 1.131 +++ deliantra/Deliantra-Client/bin/cfplus 2006/12/08 14:59:54 1.136 @@ -24,6 +24,8 @@ use strict; use utf8; +use Carp 'verbose'; + # do things only needed for single-binary version (par) BEGIN { if (%PAR::LibCache) { @@ -68,10 +70,7 @@ $Event::Eval = 0; $Event::DIED = sub { - # TODO: display dialog box or so - Carp::cluck $_[1];#d#TODO: remove when stable - return;#d# - CFPlus::fatal ($_[1]); + CFPlus::fatal Carp::longmess $_[1] }; my $MAX_FPS = 60; @@ -153,6 +152,9 @@ our $PICKUP_CFG; +our $IN_BUILD_MODE; +our $BUILD_BUTTON; + sub status { $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); } @@ -432,7 +434,7 @@ $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); $SETUP_DIALOG->show; $PL_WINDOW->hide; - $SPELL_PAGE->clear_spells; + $SPELL_LIST->clear_spells; return unless $CONN; @@ -669,6 +671,7 @@ $table->add (1, 2, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 }); $table->add (0, 3, new CFPlus::UI::Label text => "Suppress Tooltips"); $table->add (1, 3, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 }); + $table->add (0, 4, new CFPlus::UI::Button text => "die on click(tm)", on_activate => sub { die "violator" } ); my @default_smooth = (0.05, 0.13, 0.05, 0.13, 0.30, 0.13, 0.05, 0.13, 0.05); @@ -682,6 +685,7 @@ } } + $table->add (0, 5, new CFPlus::UI::TextEdit text => "line1\0152\0153");#d# $table } @@ -1192,12 +1196,12 @@ ["Cloaks" => PICKUP_CLOAK], ], - ["Readables", 2, 2, + ["Readables", 2, 0, ["Spellbooks" => PICKUP_SPELLBOOK], ["Skillscrolls" => PICKUP_SKILLSCROLL], ["Normal Books/Scrolls" => PICKUP_READABLES], ], - ["Misc", 2, 7, + ["Misc", 2, 5, ["Food" => PICKUP_FOOD], ["Drinks" => PICKUP_DRINK], ["Valuables (Money, Gems)" => PICKUP_VALUABLES], @@ -1207,6 +1211,7 @@ ["Magic Devices" => PICKUP_MAGIC_DEVICE], ["Ignore cursed" => PICKUP_NOT_CURSED], ["Jewelery" => PICKUP_JEWELS], + ["Flesh" => PICKUP_FLESH], ], ["Weight/Value ratio", 2, 17] ) @@ -1863,6 +1868,7 @@ $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, tooltip => "View Documentation"); + $BUTTONBAR->add (new CFPlus::UI::Button text => "Quit", tooltip => "Terminates the program", @@ -1883,6 +1889,124 @@ $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); } +sub setup_build_button { + my ($enabled) = @_; + if ($enabled) { + $BUILD_BUTTON ||= new CFPlus::UI::Button + text => "Build", + tooltip => "Opens the ingame builder", + on_activate => sub { + if ($CONN) { + $CONN->send_ext_req (builder_player_items => sub { + open_ingame_editor ($_[0]) if exists $_[0]->{items}; + }); + } + 0 + }; + $BUTTONBAR->add ($BUILD_BUTTON); + } else { + $BUILD_BUTTON->hide if $BUILD_BUTTON; + } +} + +sub open_ingame_editor { + my ($msg) = @_; + + my $win = new CFPlus::UI::Toplevel + x => 0, + y => 'center', + z => 4, + name => 'builder_window', + force_w => int $WIDTH * 1/4, + force_h => int $HEIGHT * 3/4, + title => "In game builder", + has_close_button => 1; + + my $r = new CFPlus::UI::ScrolledWindow ( + expand => 1, + scroll_y => 1 + ); + $r->add (my $vb = new CFPlus::UI::VBox); + $win->add ($r); + + + $vb->add ( + new CFPlus::UI::Button + text => "Disable build mode", + on_activate => sub { $::IN_BUILD_MODE = undef } + ); + $vb->add ( + new CFPlus::UI::Button + text => "ERASE", + on_activate => sub { $::IN_BUILD_MODE = { do_erase => 1 } } + ); + + for my $itemarchname ( + sort { + $msg->{items}->{$a}->{build_arch_name} + cmp $msg->{items}->{$b}->{build_arch_name} + } keys %{$msg->{items}} + ) { + my $info = $msg->{items}->{$itemarchname}; + $vb->add ( + new CFPlus::UI::Button text => $info->{build_arch_name}, + on_activate => sub { + $::IN_BUILD_MODE = { item => $itemarchname, info => $info }; + + if (grep { $msg->{items}->{$itemarchname}->{$_} } qw/has_connection has_name has_text/) { + build_mode_query_arch_info (); + } + } + ); + } + + $win->show; +} + +sub build_mode_query_arch_info { + my ($iteminfo) = $::IN_BUILD_MODE; + my $itemarchname = $iteminfo->{item}; + my $info = $iteminfo->{info}; + + my $dialog = new CFPlus::UI::Toplevel + x => "center", + y => "center", + z => 50, + force_w => int $WIDTH * 1/2, + title => "Enter information for placement of '$itemarchname'", + has_close_button => 1; + + $dialog->add (my $vb = new CFPlus::UI::VBox expand => 1); + + $vb->add (my $table = new CFPlus::UI::Table expand => 1); + my $row = 0; + if ($info->{has_name}) { + $table->add (0, $row, new CFPlus::UI::Label text => "Name:"); + $table->add (1, $row++, new CFPlus::UI::Entry expand => 1, on_changed => sub { $::IN_BUILD_MODE->{name} = $_[1]; 0 }); + } + if ($info->{has_text}) { + $table->add (0, $row, new CFPlus::UI::Label text => "Text:"); + $table->add (1, $row++, new CFPlus::UI::Entry expand => 1, on_changed => sub { $::IN_BUILD_MODE->{text} = $_[1]; 0 }); + } + if ($info->{has_connection}) { + $table->add (0, $row, new CFPlus::UI::Label text => "Connection ID:"); + $table->add (1, $row++, + new CFPlus::UI::Entry + expand => 1, + on_changed => sub { $::IN_BUILD_MODE->{connection} = $_[1]; 0 }, + tooltip => "Enter the connection ID here. The connection ID connects actors like a lever to a gate or a magic ear to a gate" + ); + } + + $vb->add (my $hb = new CFPlus::UI::HBox expand => 1); + $hb->add (new CFPlus::UI::Button + text => "Close", + expand => 1, + on_activate => sub { $dialog->hide; 0 }, + ); + $dialog->show; +} + sub video_shutdown { CFPlus::OpenGL::shutdown;