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.178 by root, Fri Jul 20 16:32:04 2007 UTC vs.
Revision 1.183 by root, Sun Jul 22 17:17:17 2007 UTC

82use CFPlus; 82use CFPlus;
83use CFPlus::OpenGL (); 83use CFPlus::OpenGL ();
84use CFPlus::Protocol; 84use CFPlus::Protocol;
85use CFPlus::DB; 85use CFPlus::DB;
86use CFPlus::UI; 86use CFPlus::UI;
87use CFPlus::UI::Canvas;
87use CFPlus::UI::Inventory; 88use CFPlus::UI::Inventory;
88use CFPlus::UI::SpellList; 89use CFPlus::UI::SpellList;
90use CFPlus::UI::MessageWindow;
89use CFPlus::Pod; 91use CFPlus::Pod;
90use CFPlus::MapWidget; 92use CFPlus::MapWidget;
91use CFPlus::Macro; 93use CFPlus::Macro;
92 94
93$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 95$SIG{QUIT} = sub { Carp::cluck "QUIT" };
125 127
126our $MAP; 128our $MAP;
127our $MAPMAP; 129our $MAPMAP;
128our $MAPWIDGET; 130our $MAPWIDGET;
129our $BUTTONBAR; 131our $BUTTONBAR;
130our $LOGVIEW;
131our $CONSOLE;
132our $METASERVER; 132our $METASERVER;
133our $LOGIN_BUTTON; 133our $LOGIN_BUTTON;
134our $QUIT_DIALOG; 134our $QUIT_DIALOG;
135our $HOST_ENTRY; 135our $HOST_ENTRY;
136our $FULLSCREEN_ENABLE; 136our $FULLSCREEN_ENABLE;
191 $DEBUG_STATUS->set_text ($_[0]); 191 $DEBUG_STATUS->set_text ($_[0]);
192} 192}
193 193
194sub message { 194sub message {
195 my ($para) = @_; 195 my ($para) = @_;
196 196 $MESSAGE_WINDOW->message ($para);
197 my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0];
198
199 $para->{markup} = "<span foreground='#ffffff'>$time</span> $para->{markup}";
200
201 $LOGVIEW->add_paragraph ($para);
202 $LOGVIEW->scroll_to_bottom;
203} 197}
204 198
205sub destroy_query_dialog { 199sub destroy_query_dialog {
206 (delete $_[0]{query_dialog})->destroy 200 (delete $_[0]{query_dialog})->destroy
207 if $_[0]{query_dialog}; 201 if $_[0]{query_dialog};
460 maph => $mapsize, 454 maph => $mapsize,
461 455
462 client => "cfplus $CFPlus::VERSION $] $^O", 456 client => "cfplus $CFPlus::VERSION $] $^O",
463 457
464 map_widget => $MAPWIDGET, 458 map_widget => $MAPWIDGET,
465 logview => $LOGVIEW,
466 statusbox => $STATUSBOX, 459 statusbox => $STATUSBOX,
467 map => $MAP, 460 map => $MAP,
468 mapmap => $MAPMAP, 461 mapmap => $MAPMAP,
469 query => \&server_query, 462 query => \&server_query,
470 463
613 606
614 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); 607 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize");
615 $table->add_at (1, $row++, new CFPlus::UI::Slider 608 $table->add_at (1, $row++, new CFPlus::UI::Slider
616 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], 609 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1],
617 tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.", 610 tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.",
618 on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, 611 on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 },
619 ); 612 );
620 613
621 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); 614 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge fontsize");
622 $table->add_at (1, $row++, new CFPlus::UI::Slider 615 $table->add_at (1, $row++, new CFPlus::UI::Slider
623 range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], 616 range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1],
751 $table->add_at (0, 3, new CFPlus::UI::Label text => "Suppress Tooltips"); 744 $table->add_at (0, 3, new CFPlus::UI::Label text => "Suppress Tooltips");
752 $table->add_at (1, 3, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 }); 745 $table->add_at (1, 3, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 });
753 $table->add_at (0, 4, new CFPlus::UI::Button text => "die on click(tm)", on_activate => sub { &CFPlus::debug() } ); 746 $table->add_at (0, 4, new CFPlus::UI::Button text => "die on click(tm)", on_activate => sub { &CFPlus::debug() } );
754 747
755 $table->add_at (0, 5, new CFPlus::UI::TextEdit text => "line1\0152\0153");#d# 748 $table->add_at (0, 5, new CFPlus::UI::TextEdit text => "line1\0152\0153");#d#
749
750 $table->add_at (7,7, my $t = new CFPlus::UI::Table expand => 0);
751 $t->add_at (0,0, new CFPlus::UI::Label text => "a a a a", rowspan => 1, colspan => 2);
752 $t->add_at (2,0, new CFPlus::UI::Label text => "b\nb", rowspan => 2, colspan => 1);
753 $t->add_at (1,2, new CFPlus::UI::Label text => "c c c c", rowspan => 1, colspan => 2);
754 $t->add_at (0,1, new CFPlus::UI::Label text => "d\nd", rowspan => 2, colspan => 1);
755 $t->add_at (1,1, new CFPlus::UI::Label text => "e");
756
757 $table->add_at (7, 6, my $c = new CFPlus::UI::Canvas);
758
759 $c->add_items ({
760 type => "line_loop",
761 color => [0, 1, 0],
762 width => 9,
763 coord_mode => "abs",
764 coord => [[10, 5], [5, 50], [20, 5], [5, 60]],
765 });
766
767 $c->add_items ({
768 type => "lines",
769 color => [1, 1, 0],
770 width => 2,
771 coord_mode => "rel",
772 coord => [[0,0], [1,1], [1,0], [0,1]],
773 });
774
775 $c->add_items ({
776 type => "polygon",
777 color => [0, 0.43, 0],
778 width => 2,
779 coord_mode => "rel",
780 coord => [[0,0.2], [1,.4], [1,.6], [0,.8]],
781 });
756 782
757 $table 783 $table
758} 784}
759 785
760sub stats_window { 786sub stats_window {
1190 tooltip => "This is maximum number of messages remembered in the <b>Messages</b> window. If the server " 1216 tooltip => "This is maximum number of messages remembered in the <b>Messages</b> window. If the server "
1191 . "sends more messages than this number, older messages get removed to save memory and " 1217 . "sends more messages than this number, older messages get removed to save memory and "
1192 . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", 1218 . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.",
1193 on_changed => sub { 1219 on_changed => sub {
1194 my ($self, $value) = @_; 1220 my ($self, $value) = @_;
1195 $LOGVIEW->{max_par} = $CFG->{logview_max_par} = $value*1; 1221 $MESSAGE_WINDOW->set_max_para ($CFG->{logview_max_par} = $value*1);
1196 0 1222 0
1197 }, 1223 },
1198 ); 1224 );
1199 1225
1200 $table 1226 $table
1201}
1202
1203sub message_window {
1204 my $window = new CFPlus::UI::Toplevel
1205 name => "message_window",
1206 title => "Messages",
1207 border_bg => [1, 1, 1, 1],
1208 x => "max",
1209 y => 0,
1210 force_w => $::WIDTH * 0.4,
1211 force_h => $::HEIGHT * 0.5,
1212 child => (my $vbox = new CFPlus::UI::VBox),
1213 has_close_button => 1;
1214
1215 $vbox->add ($LOGVIEW);
1216
1217 $vbox->add (my $input = new CFPlus::UI::Entry
1218 tooltip => "<b>Chat Box</b>. If you enter a text and press return/enter here, the current <i>communication command</i> "
1219 . "from the client setup will be prepended (e.g. <b>shout</b>, <b>chat</b>...). "
1220 . "If you prepend a slash (/), you will submit a command instead (similar to IRC). "
1221 . "A better way to submit commands (and the occasional chat command) is often the map command completer.",
1222 on_focus_in => sub {
1223 my ($input, $prev_focus) = @_;
1224
1225 delete $input->{refocus_map};
1226
1227 if ($prev_focus == $MAPWIDGET && $input->{auto_activated}) {
1228 $input->{refocus_map} = 1;
1229 }
1230 delete $input->{auto_activated};
1231
1232 0
1233 },
1234 on_activate => sub {
1235 my ($input, $text) = @_;
1236 $input->set_text ('');
1237
1238 if ($text =~ /^\/(.*)/) {
1239 $::CONN->user_send ($1);
1240 } else {
1241 my $say_cmd = $::CFG->{say_command} || 'say';
1242 $::CONN->user_send ("$say_cmd $text");
1243 }
1244 if ($input->{refocus_map}) {
1245 delete $input->{refocus_map};
1246 $MAPWIDGET->focus_in
1247 }
1248
1249 0
1250 },
1251 on_escape => sub {
1252 $MAPWIDGET->grab_focus;
1253
1254 0
1255 },
1256 );
1257
1258 $CONSOLE = {
1259 window => $window,
1260 input => $input,
1261 };
1262
1263 $window
1264} 1227}
1265 1228
1266sub autopickup_setup { 1229sub autopickup_setup {
1267 my $r = new CFPlus::UI::ScrolledWindow ( 1230 my $r = new CFPlus::UI::ScrolledWindow (
1268 expand => 1, 1231 expand => 1,
1767 1730
1768 $MAPWIDGET = new CFPlus::MapWidget; 1731 $MAPWIDGET = new CFPlus::MapWidget;
1769 $MAPWIDGET->connect (activate_console => sub { 1732 $MAPWIDGET->connect (activate_console => sub {
1770 my ($mapwidget, $preset) = @_; 1733 my ($mapwidget, $preset) = @_;
1771 1734
1772 if ($CONSOLE) { 1735 $MESSAGE_WINDOW->activate_console ($preset)
1773 $CONSOLE->{input}->{auto_activated} = 1; 1736 if $MESSAGE_WINDOW;
1774 $CONSOLE->{input}->grab_focus;
1775
1776 if ($preset && $CONSOLE->{input}->get_text eq '') {
1777 $CONSOLE->{input}->set_text ($preset);
1778 }
1779 }
1780 }); 1737 });
1781 $MAPWIDGET->show; 1738 $MAPWIDGET->show;
1782 $MAPWIDGET->grab_focus; 1739 $MAPWIDGET->grab_focus;
1783
1784 $LOGVIEW = new CFPlus::UI::TextScroller
1785 expand => 1,
1786 font => $FONT_FIXED,
1787 fontsize => $::CFG->{log_fontsize},
1788 indent => -4,
1789 can_hover => 1,
1790 can_events => 1,
1791 max_par => $CFG->{logview_max_par},
1792 tooltip => "<b>Server Log</b>. This text viewer contains all recent messages sent by the server.",
1793 ;
1794 1740
1795 $SETUP_DIALOG = new CFPlus::UI::Toplevel 1741 $SETUP_DIALOG = new CFPlus::UI::Toplevel
1796 title => "Setup", 1742 title => "Setup",
1797 name => "setup_dialog", 1743 name => "setup_dialog",
1798 x => 'center', 1744 x => 'center',
1802 force_h => $::HEIGHT * 0.6, 1748 force_h => $::HEIGHT * 0.6,
1803 has_close_button => 1, 1749 has_close_button => 1,
1804 ; 1750 ;
1805 1751
1806 $METASERVER = metaserver_dialog; 1752 $METASERVER = metaserver_dialog;
1753 $MESSAGE_WINDOW = new CFPlus::UI::MessageWindow;
1807 1754
1808 $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFPlus::UI::Notebook expand => 1, debug => 1, 1755 $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFPlus::UI::Notebook expand => 1, debug => 1,
1809 filter => new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); 1756 filter => new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1);
1810 1757
1811 $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, 1758 $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup,
1829 $BUTTONBAR = new CFPlus::UI::Buttonbar x => 0, y => 0, z => 200; # put on top 1776 $BUTTONBAR = new CFPlus::UI::Buttonbar x => 0, y => 0, z => 200; # put on top
1830 1777
1831 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Setup", other => $SETUP_DIALOG, 1778 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Setup", other => $SETUP_DIALOG,
1832 tooltip => "Toggles a dialog where you can configure all aspects of this client."); 1779 tooltip => "Toggles a dialog where you can configure all aspects of this client.");
1833 1780
1834 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW = message_window, 1781 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW,
1835 tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); 1782 tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server.");
1836 1783
1837 make_gauge_window->show; # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D 1784 make_gauge_window->show; # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D
1838 1785
1839 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Playerbook", other => player_window, 1786 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Playerbook", other => player_window,
2022sub audio_music_start { 1969sub audio_music_start {
2023 my $path = $MUSIC_PLAYING->{path} 1970 my $path = $MUSIC_PLAYING->{path}
2024 or return; 1971 or return;
2025 1972
2026 CFPlus::DB::prefetch_file $path, 1024_000, sub { 1973 CFPlus::DB::prefetch_file $path, 1024_000, sub {
1974 return unless $SDL_MIXER;
1975
2027 # music might have changed... 1976 # music might have changed...
2028 $path eq $MUSIC_PLAYING->{path} 1977 $path eq $MUSIC_PLAYING->{path}
2029 or return &audio_music_start (); 1978 or return &audio_music_start ();
2030 1979
2031 $MUSIC_PLAYER = new_from_file CFPlus::MixMusic $path; 1980 $MUSIC_PLAYER = new_from_file CFPlus::MixMusic $path;
2046 } 1995 }
2047} 1996}
2048 1997
2049sub audio_music_changed { 1998sub audio_music_changed {
2050 return unless $CFG->{bgm_enable}; 1999 return unless $CFG->{bgm_enable};
2000 return unless $SDL_MIXER;
2051 2001
2052 # default MUSIC_WANT == MUSIC_DEFAULT 2002 # default MUSIC_WANT == MUSIC_DEFAULT
2053 @MUSIC_WANT = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_WANT; 2003 @MUSIC_WANT = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_WANT;
2054 2004
2055 # if the currently playing song is acceptable, let it continue 2005 # if the currently playing song is acceptable, let it continue
2115 }; 2065 };
2116 } 2066 }
2117 } else { 2067 } else {
2118 status "unable to open sound config: $!"; 2068 status "unable to open sound config: $!";
2119 } 2069 }
2070 } else {
2071 undef $SDL_MIXER;
2120 } 2072 }
2121} 2073}
2122 2074
2123sub audio_shutdown { 2075sub audio_shutdown {
2124 CFPlus::Mix_CloseAudio if $SDL_MIXER; 2076 CFPlus::Mix_CloseAudio if $SDL_MIXER;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines