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.181 by root, Sat Jul 21 16:07:53 2007 UTC vs.
Revision 1.182 by elmex, Sat Jul 21 20:30:41 2007 UTC

85use CFPlus::DB; 85use CFPlus::DB;
86use CFPlus::UI; 86use CFPlus::UI;
87use CFPlus::UI::Canvas; 87use CFPlus::UI::Canvas;
88use CFPlus::UI::Inventory; 88use CFPlus::UI::Inventory;
89use CFPlus::UI::SpellList; 89use CFPlus::UI::SpellList;
90use CFPlus::UI::MessageWindow;
90use CFPlus::Pod; 91use CFPlus::Pod;
91use CFPlus::MapWidget; 92use CFPlus::MapWidget;
92use CFPlus::Macro; 93use CFPlus::Macro;
93 94
94$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 95$SIG{QUIT} = sub { Carp::cluck "QUIT" };
126 127
127our $MAP; 128our $MAP;
128our $MAPMAP; 129our $MAPMAP;
129our $MAPWIDGET; 130our $MAPWIDGET;
130our $BUTTONBAR; 131our $BUTTONBAR;
131our $LOGVIEW;
132our $CONSOLE;
133our $METASERVER; 132our $METASERVER;
134our $LOGIN_BUTTON; 133our $LOGIN_BUTTON;
135our $QUIT_DIALOG; 134our $QUIT_DIALOG;
136our $HOST_ENTRY; 135our $HOST_ENTRY;
137our $FULLSCREEN_ENABLE; 136our $FULLSCREEN_ENABLE;
192 $DEBUG_STATUS->set_text ($_[0]); 191 $DEBUG_STATUS->set_text ($_[0]);
193} 192}
194 193
195sub message { 194sub message {
196 my ($para) = @_; 195 my ($para) = @_;
197 196 $MESSAGE_WINDOW->message ($para);
198 my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0];
199
200 $para->{markup} = "<span foreground='#ffffff'>$time</span> $para->{markup}";
201
202 $LOGVIEW->add_paragraph ($para);
203 $LOGVIEW->scroll_to_bottom;
204} 197}
205 198
206sub destroy_query_dialog { 199sub destroy_query_dialog {
207 (delete $_[0]{query_dialog})->destroy 200 (delete $_[0]{query_dialog})->destroy
208 if $_[0]{query_dialog}; 201 if $_[0]{query_dialog};
461 maph => $mapsize, 454 maph => $mapsize,
462 455
463 client => "cfplus $CFPlus::VERSION $] $^O", 456 client => "cfplus $CFPlus::VERSION $] $^O",
464 457
465 map_widget => $MAPWIDGET, 458 map_widget => $MAPWIDGET,
466 logview => $LOGVIEW,
467 statusbox => $STATUSBOX, 459 statusbox => $STATUSBOX,
468 map => $MAP, 460 map => $MAP,
469 mapmap => $MAPMAP, 461 mapmap => $MAPMAP,
470 query => \&server_query, 462 query => \&server_query,
471 463
614 606
615 $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");
616 $table->add_at (1, $row++, new CFPlus::UI::Slider 608 $table->add_at (1, $row++, new CFPlus::UI::Slider
617 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], 609 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1],
618 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.",
619 on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, 611 on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 },
620 ); 612 );
621 613
622 $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");
623 $table->add_at (1, $row++, new CFPlus::UI::Slider 615 $table->add_at (1, $row++, new CFPlus::UI::Slider
624 range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], 616 range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1],
1224 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 "
1225 . "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 "
1226 . "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.",
1227 on_changed => sub { 1219 on_changed => sub {
1228 my ($self, $value) = @_; 1220 my ($self, $value) = @_;
1229 $LOGVIEW->{max_par} = $CFG->{logview_max_par} = $value*1; 1221 $MESSAGE_WINDOW->set_max_para ($CFG->{logview_max_par} = $value*1);
1230 0 1222 0
1231 }, 1223 },
1232 ); 1224 );
1233 1225
1234 $table 1226 $table
1235}
1236
1237sub message_window {
1238 my $window = new CFPlus::UI::Toplevel
1239 name => "message_window",
1240 title => "Messages",
1241 border_bg => [1, 1, 1, 1],
1242 x => "max",
1243 y => 0,
1244 force_w => $::WIDTH * 0.4,
1245 force_h => $::HEIGHT * 0.5,
1246 child => (my $vbox = new CFPlus::UI::VBox),
1247 has_close_button => 1;
1248
1249 $vbox->add ($LOGVIEW);
1250
1251 $vbox->add (my $input = new CFPlus::UI::Entry
1252 tooltip => "<b>Chat Box</b>. If you enter a text and press return/enter here, the current <i>communication command</i> "
1253 . "from the client setup will be prepended (e.g. <b>shout</b>, <b>chat</b>...). "
1254 . "If you prepend a slash (/), you will submit a command instead (similar to IRC). "
1255 . "A better way to submit commands (and the occasional chat command) is often the map command completer.",
1256 on_focus_in => sub {
1257 my ($input, $prev_focus) = @_;
1258
1259 delete $input->{refocus_map};
1260
1261 if ($prev_focus == $MAPWIDGET && $input->{auto_activated}) {
1262 $input->{refocus_map} = 1;
1263 }
1264 delete $input->{auto_activated};
1265
1266 0
1267 },
1268 on_activate => sub {
1269 my ($input, $text) = @_;
1270 $input->set_text ('');
1271
1272 if ($text =~ /^\/(.*)/) {
1273 $::CONN->user_send ($1);
1274 } else {
1275 my $say_cmd = $::CFG->{say_command} || 'say';
1276 $::CONN->user_send ("$say_cmd $text");
1277 }
1278 if ($input->{refocus_map}) {
1279 delete $input->{refocus_map};
1280 $MAPWIDGET->focus_in
1281 }
1282
1283 0
1284 },
1285 on_escape => sub {
1286 $MAPWIDGET->grab_focus;
1287
1288 0
1289 },
1290 );
1291
1292 $CONSOLE = {
1293 window => $window,
1294 input => $input,
1295 };
1296
1297 $window
1298} 1227}
1299 1228
1300sub autopickup_setup { 1229sub autopickup_setup {
1301 my $r = new CFPlus::UI::ScrolledWindow ( 1230 my $r = new CFPlus::UI::ScrolledWindow (
1302 expand => 1, 1231 expand => 1,
1801 1730
1802 $MAPWIDGET = new CFPlus::MapWidget; 1731 $MAPWIDGET = new CFPlus::MapWidget;
1803 $MAPWIDGET->connect (activate_console => sub { 1732 $MAPWIDGET->connect (activate_console => sub {
1804 my ($mapwidget, $preset) = @_; 1733 my ($mapwidget, $preset) = @_;
1805 1734
1806 if ($CONSOLE) { 1735 $MESSAGE_WINDOW->activate_console ($preset)
1807 $CONSOLE->{input}->{auto_activated} = 1; 1736 if $MESSAGE_WINDOW;
1808 $CONSOLE->{input}->grab_focus;
1809
1810 if ($preset && $CONSOLE->{input}->get_text eq '') {
1811 $CONSOLE->{input}->set_text ($preset);
1812 }
1813 }
1814 }); 1737 });
1815 $MAPWIDGET->show; 1738 $MAPWIDGET->show;
1816 $MAPWIDGET->grab_focus; 1739 $MAPWIDGET->grab_focus;
1817
1818 $LOGVIEW = new CFPlus::UI::TextScroller
1819 expand => 1,
1820 font => $FONT_FIXED,
1821 fontsize => $::CFG->{log_fontsize},
1822 indent => -4,
1823 can_hover => 1,
1824 can_events => 1,
1825 max_par => $CFG->{logview_max_par},
1826 tooltip => "<b>Server Log</b>. This text viewer contains all recent messages sent by the server.",
1827 ;
1828 1740
1829 $SETUP_DIALOG = new CFPlus::UI::Toplevel 1741 $SETUP_DIALOG = new CFPlus::UI::Toplevel
1830 title => "Setup", 1742 title => "Setup",
1831 name => "setup_dialog", 1743 name => "setup_dialog",
1832 x => 'center', 1744 x => 'center',
1836 force_h => $::HEIGHT * 0.6, 1748 force_h => $::HEIGHT * 0.6,
1837 has_close_button => 1, 1749 has_close_button => 1,
1838 ; 1750 ;
1839 1751
1840 $METASERVER = metaserver_dialog; 1752 $METASERVER = metaserver_dialog;
1753 $MESSAGE_WINDOW = new CFPlus::UI::MessageWindow;
1841 1754
1842 $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,
1843 filter => new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); 1756 filter => new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1);
1844 1757
1845 $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, 1758 $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup,
1863 $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
1864 1777
1865 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Setup", other => $SETUP_DIALOG, 1778 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Setup", other => $SETUP_DIALOG,
1866 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.");
1867 1780
1868 $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,
1869 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.");
1870 1783
1871 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
1872 1785
1873 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Playerbook", other => player_window, 1786 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Playerbook", other => player_window,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines