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.74 by root, Sun Jun 18 17:13:12 2006 UTC vs.
Revision 1.80 by root, Mon Jun 26 21:59:04 2006 UTC

36 36
37use CFClient; 37use CFClient;
38use CFClient::OpenGL (); 38use CFClient::OpenGL ();
39use CFClient::Protocol; 39use CFClient::Protocol;
40use CFClient::UI; 40use CFClient::UI;
41use CFClient::BindingEditor;
41use CFClient::MapWidget; 42use CFClient::MapWidget;
42 43
43$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 44$SIG{QUIT} = sub { Carp::cluck "QUIT" };
44 45
45$Event::DIED = sub { 46$Event::DIED = sub {
115our $INV; 116our $INV;
116our $INVR; 117our $INVR;
117our $INV_RIGHT_HB; 118our $INV_RIGHT_HB;
118 119
119our $BIND_EDITOR; 120our $BIND_EDITOR;
121our $BIND_UPD_CB;
120 122
121our $PICKUP_CFG; 123our $PICKUP_CFG;
122 124
123sub status { 125sub status {
124 $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); 126 $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
324 $LOGIN_BUTTON->set_text ("Logout"); 326 $LOGIN_BUTTON->set_text ("Logout");
325 $SETUP_DIALOG->hide; 327 $SETUP_DIALOG->hide;
326 328
327 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 329 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
328 330
329 my ($host, $port) = split /:/, $CFG->{host}; 331 my ($host, $port) = split /:/, $CFG->{profile}{default}{host};
330 332
331 $MAP = new CFClient::Map $mapsize, $mapsize; 333 $MAP = new CFClient::Map $mapsize, $mapsize;
332 334
333 $CONN = eval { 335 $CONN = eval {
334 new CFClient::Protocol 336 new CFClient::Protocol
335 host => $host, 337 host => $host,
336 port => $port || 13327, 338 port => $port || 13327,
337 user => $CFG->{user}, 339 user => $CFG->{profile}{default}{user},
338 pass => $CFG->{password}, 340 pass => $CFG->{profile}{default}{password},
339 mapw => $mapsize, 341 mapw => $mapsize,
340 maph => $mapsize, 342 maph => $mapsize,
341 343
342 map_widget => $MAPWIDGET, 344 map_widget => $MAPWIDGET,
343 logview => $LOGVIEW, 345 logview => $LOGVIEW,
381 status "connection closed"; 383 status "connection closed";
382 384
383 destroy_query_dialog $CONN; 385 destroy_query_dialog $CONN;
384 $CONN->destroy; 386 $CONN->destroy;
385 $CONN = 0; # false, does not autovivify 387 $CONN = 0; # false, does not autovivify
388
389 undef $MAP;
386} 390}
387 391
388sub graphics_setup { 392sub graphics_setup {
389 my $vbox = new CFClient::UI::VBox; 393 my $vbox = new CFClient::UI::VBox;
390 394
746 ); 750 );
747 $tbl2->add ($col + 1, $row, new CFClient::UI::Image 751 $tbl2->add ($col + 1, $row, new CFClient::UI::Image
748 font => $FONT_FIXED, 752 font => $FONT_FIXED,
749 can_hover => 1, 753 can_hover => 1,
750 can_events => 1, 754 can_events => 1,
751 image => "ui/resist/resist_$_.png", 755 path => "ui/resist/resist_$_.png",
752 tooltip => $resist_names{$_}, 756 tooltip => $resist_names{$_},
753 ); 757 );
754 758
755 $row++; 759 $row++;
756 if ($row % 6 == 0) { 760 if ($row % 6 == 0) {
912 $table->add (scalar @$m, $y, new CFClient::UI::VBox children => [ 916 $table->add (scalar @$m, $y, new CFClient::UI::VBox children => [
913 (new CFClient::UI::Button 917 (new CFClient::UI::Button
914 text => "Use", 918 text => "Use",
915 tooltip => "Put this server into the <b>Host:Port</b> field", 919 tooltip => "Put this server into the <b>Host:Port</b> field",
916 on_activate => sub { 920 on_activate => sub {
917 $HOST_ENTRY->set_text ($CFG->{host} = $host); 921 $HOST_ENTRY->set_text ($CFG->{profile}{default}{host} = $host);
918 $METASERVER->hide; 922 $METASERVER->hide;
919 0 923 0
920 }, 924 },
921 ), 925 ),
922 (new CFClient::UI::Empty expand => 1), 926 (new CFClient::UI::Empty expand => 1),
943 x => 'center', 947 x => 'center',
944 y => 'center', 948 y => 'center',
945 z => 3, 949 z => 3,
946 force_h => $::HEIGHT * 0.4, 950 force_h => $::HEIGHT * 0.4,
947 child => (my $vbox = new CFClient::UI::VBox), 951 child => (my $vbox = new CFClient::UI::VBox),
952 has_close_button => 1,
948 on_visibility_change => sub { 953 on_visibility_change => sub {
949 update_metaserver if $_[1]; 954 update_metaserver if $_[1];
950 0 955 0
951 }, 956 },
952 ; 957 ;
968 $table->add (1, 2, my $vbox = new CFClient::UI::VBox); 973 $table->add (1, 2, my $vbox = new CFClient::UI::VBox);
969 974
970 $vbox->add ( 975 $vbox->add (
971 $HOST_ENTRY = new CFClient::UI::Entry 976 $HOST_ENTRY = new CFClient::UI::Entry
972 expand => 1, 977 expand => 1,
973 text => $CFG->{host}, 978 text => $CFG->{profile}{default}{host},
974 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to", 979 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to",
975 on_changed => sub { 980 on_changed => sub {
976 my ($self, $value) = @_; 981 my ($self, $value) = @_;
977 $CFG->{host} = $value; 982 $CFG->{profile}{default}{host} = $value;
978 0 983 0
979 } 984 }
980 ); 985 );
981 986
982 $METASERVER = metaserver_dialog; 987 $METASERVER = metaserver_dialog;
991 ); 996 );
992 } 997 }
993 998
994 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username"); 999 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
995 $table->add (1, 4, new CFClient::UI::Entry 1000 $table->add (1, 4, new CFClient::UI::Entry
996 text => $CFG->{user}, 1001 text => $CFG->{profile}{default}{user},
997 tooltip => "The name of your character on the server", 1002 tooltip => "The name of your character on the server",
998 on_changed => sub { my ($self, $value) = @_; $CFG->{user} = $value; 0 } 1003 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value }
999 ); 1004 );
1000 1005
1001 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password"); 1006 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password");
1002 $table->add (1, 5, new CFClient::UI::Entry 1007 $table->add (1, 5, new CFClient::UI::Entry
1003 text => $CFG->{password}, 1008 text => $CFG->{profile}{default}{password},
1004 hidden => 1, 1009 hidden => 1,
1005 tooltip => "The password for your character", 1010 tooltip => "The password for your character",
1006 on_changed => sub { my ($self, $value) = @_; $CFG->{password} = $value; 0 } 1011 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value }
1007 ); 1012 );
1008 1013
1009 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); 1014 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
1010 $table->add (1, 7, new CFClient::UI::Slider 1015 $table->add (1, 7, new CFClient::UI::Slider
1011 force_w => 100, 1016 force_w => 100,
1299 1304
1300sub spell_setup { 1305sub spell_setup {
1301 new CFClient::UI::SpellList 1306 new CFClient::UI::SpellList
1302} 1307}
1303 1308
1309sub update_bindings {
1310 $BIND_UPD_CB->() if $BIND_UPD_CB;
1311}
1312
1304sub keyboard_setup { 1313sub keyboard_setup {
1305 my $binding_list = new CFClient::UI::VBox; 1314 my $binding_list = new CFClient::UI::VBox;
1306 1315
1307 my $refresh; 1316 my $refresh;
1308 $refresh = sub { 1317 $refresh = $BIND_UPD_CB = sub {
1309 $binding_list->clear (); 1318 $binding_list->clear ();
1310 1319
1311 for my $mod (keys %{$::CFG->{bindings}}) { 1320 for my $mod (keys %{$::CFG->{profile}{default}{bindings}}) {
1312 for my $sym (keys %{$::CFG->{bindings}->{$mod}}) { 1321 for my $sym (keys %{$::CFG->{profile}{default}{bindings}{$mod}}) {
1313 my $cmds = $::CFG->{bindings}->{$mod}->{$sym}; 1322 my $cmds = $::CFG->{profile}{default}{bindings}{$mod}{$sym};
1314 next unless ref $cmds eq 'ARRAY' and @$cmds > 0; 1323 next unless ref $cmds eq 'ARRAY' and @$cmds > 0;
1315 1324
1316 my $lbl = join "; ", @$cmds; 1325 my $lbl = join "; ", @$cmds;
1317 my $nam = CFClient::Binder::keycombo_to_name ($mod, $sym); 1326 my $nam = CFClient::Binder::keycombo_to_name ($mod, $sym);
1318 $binding_list->add (my $hb = new CFClient::UI::HBox); 1327 $binding_list->add (my $hb = new CFClient::UI::HBox);
1319 $hb->add (new CFClient::UI::Button 1328 $hb->add (new CFClient::UI::Button
1320 text => "delete", 1329 text => "delete",
1321 tooltip => "Deletes the binding", 1330 tooltip => "Deletes the binding",
1322 on_activate => sub { 1331 on_activate => sub {
1323 $binding_list->remove ($hb); 1332 $binding_list->remove ($hb);
1324 delete $::CFG->{bindings}->{$mod}->{$sym}; 1333 delete $::CFG->{profile}{default}{bindings}{$mod}{$sym};
1325 0 1334 0
1326 }); 1335 });
1327 1336
1328 $hb->add (new CFClient::UI::Button 1337 $hb->add (new CFClient::UI::Button
1329 text => "edit", 1338 text => "edit",
1330 tooltip => "Edits the binding", 1339 tooltip => "Edits the binding",
1331 on_activate => sub { 1340 on_activate => sub {
1332 $::BIND_EDITOR->set_binding ( 1341 $::BIND_EDITOR->set_binding (
1333 $mod, $sym, $::CFG->{bindings}->{$mod}->{$sym}, 1342 $mod, $sym, $::CFG->{profile}{default}{bindings}{$mod}{$sym},
1334 sub { 1343 sub {
1335 my ($nmod, $nsym, $ncmds) = @_; 1344 my ($nmod, $nsym, $ncmds) = @_;
1336 delete $::CFG->{bindings}->{$mod}->{$sym}; 1345 $::BIND_EDITOR->cfg_unbind ($mod, $sym);
1337 $::CFG->{bindings}->{$nmod}->{$nsym} = $ncmds; 1346 $::BIND_EDITOR->cfg_bind ($nmod, $nsym, $ncmds);
1338 $refresh->(); 1347 $refresh->();
1339 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); 1348 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD);
1340 $SETUP_DIALOG->show; 1349 $SETUP_DIALOG->show;
1341 }, 1350 },
1342 sub { 1351 sub {
1376 tooltip => "This button opens the binding editor with an empty binding.", 1385 tooltip => "This button opens the binding editor with an empty binding.",
1377 on_activate => sub { 1386 on_activate => sub {
1378 $::BIND_EDITOR->set_binding (undef, undef, [], 1387 $::BIND_EDITOR->set_binding (undef, undef, [],
1379 sub { 1388 sub {
1380 my ($mod, $sym, $cmds) = @_; 1389 my ($mod, $sym, $cmds) = @_;
1381 $::CFG->{bindings}->{$mod}->{$sym} = $cmds; 1390 $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds);
1382 $refresh->(); 1391 $refresh->();
1383 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); 1392 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD);
1384 $SETUP_DIALOG->show; 1393 $SETUP_DIALOG->show;
1385 }, 1394 },
1386 sub { 1395 sub {
1428 $buttons->add (new CFClient::UI::Label text => "Choose a document to display: "); 1437 $buttons->add (new CFClient::UI::Label text => "Choose a document to display: ");
1429 $buttons->add (my $combo = new CFClient::UI::Combobox 1438 $buttons->add (my $combo = new CFClient::UI::Combobox
1430 value => undef, 1439 value => undef,
1431 options => [ 1440 options => [
1432 [intro => "Introduction"], 1441 [intro => "Introduction"],
1433 [manual => "Manual"], 1442 [manual => "Main Manual"],
1434 [skill_help => "Skills"], 1443 [skill_help => "Skill Reference"],
1435 [command_help => "Commands"], 1444 [command_help => "Command Reference"],
1436 [dmcommand_help => "DM Commands"], 1445 [dmcommand_help => "DM Commands"],
1437 [COPYING => "License Terms"], 1446 [COPYING => "License Terms"],
1438 ], 1447 ],
1439 on_changed => sub { 1448 on_changed => sub {
1440 my ($self, $pod) = @_; 1449 my ($self, $pod) = @_;
1441 1450
1442 my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", 1451 my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod",
1443 doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; 1452 doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] };
1444 1453
1445 $viewer->clear; 1454 $viewer->clear;
1455
1456# $viewer->add_paragraph ([1, 1, 1, 1], ["<big>Test</big>\n\n \x{fffc} \x{fffc}\n",
1457# (new CFClient::UI::Image path => "x.png", can_hover => 1, can_events => 1),
1458# (new CFClient::UI::Label text => "üüüü", can_hover => 1, can_events => 1, tooltip => "??"),
1459# ]);#d#
1446 1460
1447 $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) 1461 $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0])
1448 for @$pom; 1462 for @$pom;
1449 1463
1450 $viewer->set_offset (0); 1464 $viewer->set_offset (0);
1465
1451 0 1466 0
1452 }, 1467 },
1453 on_visibility_change => sub { 1468 on_visibility_change => sub {
1454 my ($self, $visible) = @_; 1469 my ($self, $visible) = @_;
1455 return unless $visible; 1470 return unless $visible;
1502 z => 100, 1517 z => 100,
1503 force_x => "max", 1518 force_x => "max",
1504 force_y => 0; 1519 force_y => 0;
1505 $DEBUG_STATUS->show; 1520 $DEBUG_STATUS->show;
1506 1521
1507 $BIND_EDITOR = new CFClient::UI::BindEditor (x => "max", y => 0); 1522 $BIND_EDITOR = new CFClient::BindingEditor (x => "max", y => 0);
1508 1523
1509 $STATUSBOX = new CFClient::UI::Statusbox; 1524 $STATUSBOX = new CFClient::UI::Statusbox;
1510 $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", timeout => 864000, pri => -100, color => [1, 1, 1, 0.8]); 1525 $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", timeout => 864000, pri => -100, color => [1, 1, 1, 0.8]);
1511 1526
1512 (new CFClient::UI::Frame 1527 (new CFClient::UI::Frame
1575 $SETUP_NOTEBOOK->add (Graphics => graphics_setup, 1590 $SETUP_NOTEBOOK->add (Graphics => graphics_setup,
1576 "Configure the video mode, performance, fonts and other graphical aspects of the game."); 1591 "Configure the video mode, performance, fonts and other graphical aspects of the game.");
1577 $SETUP_NOTEBOOK->add (Audio => audio_setup, 1592 $SETUP_NOTEBOOK->add (Audio => audio_setup,
1578 "Configure the use of audio, sound effects and background music."); 1593 "Configure the use of audio, sound effects and background music.");
1579 $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup, 1594 $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup,
1580 "Lets you define, edit and delete bindings." 1595 "Lets you define, edit and delete key bindings."
1581 . "There is a shortcut for making bindings: <b>Left Control + Insert</b> opens the binding editor " 1596 . "There is a shortcut for making bindings: <b>Control-Insert</b> opens the binding editor "
1582 . "with nothing set and the recording started. After doing the actions you " 1597 . "with nothing set and the recording started. After doing the actions you "
1583 . "want to record press <b>Insert</b> and you will be asked to press a key-combo. " 1598 . "want to record press <b>Insert</b> and you will be asked to press a key-combo. "
1584 . "After pressing the combo the binding will be saved automatically and the " 1599 . "After pressing the combo the binding will be saved automatically and the "
1585 . "binding editor closes"); 1600 . "binding editor closes");
1586 $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup, 1601 $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup,
1587 "Displays all spells you have and lets you edit keyboard shortcuts for them."); 1602 "Displays all spells you have and lets you edit keyboard shortcuts for them.");
1588 $SETUP_NOTEBOOK->add (Debug => debug_setup, 1603 $SETUP_NOTEBOOK->add (Debug => debug_setup,
1589 "Some debuggign options. Do not ask."); 1604 "Some debuggin' options. Do not ask.");
1590 1605
1591 $BUTTONBAR = new CFClient::UI::Buttonbar x => 0, y => 0, z => 200; # put on top 1606 $BUTTONBAR = new CFClient::UI::Buttonbar x => 0, y => 0, z => 200; # put on top
1592 1607
1593 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG, 1608 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG,
1594 tooltip => "Toggles a dialog where you can configure all aspects of this client."); 1609 tooltip => "Toggles a dialog where you can configure all aspects of this client.");
1864 1879
1865 CFClient::read_cfg "$Crossfire::VARDIR/cfplusrc"; 1880 CFClient::read_cfg "$Crossfire::VARDIR/cfplusrc";
1866 CFClient::UI::set_layout ($::CFG->{layout}); 1881 CFClient::UI::set_layout ($::CFG->{layout});
1867 1882
1868 my %DEF_CFG = ( 1883 my %DEF_CFG = (
1869 sdl_mode => 0, 1884 sdl_mode => 0,
1870 width => 640, 1885 width => 640,
1871 height => 480, 1886 height => 480,
1872 fullscreen => 0, 1887 fullscreen => 0,
1873 fast => 0, 1888 fast => 0,
1874 map_scale => 1, 1889 map_scale => 1,
1875 fow_enable => 1, 1890 fow_enable => 1,
1876 fow_intensity => 0.45, 1891 fow_intensity => 0.45,
1877 fow_smooth => 0, 1892 fow_smooth => 0,
1878 gui_fontsize => 1, 1893 gui_fontsize => 1,
1879 log_fontsize => 0.7, 1894 log_fontsize => 0.7,
1880 gauge_fontsize=> 1, 1895 gauge_fontsize => 1,
1881 gauge_size => 0.35, 1896 gauge_size => 0.35,
1882 stat_fontsize => 0.7, 1897 stat_fontsize => 0.7,
1883 mapsize => 100, 1898 mapsize => 100,
1884 host => "crossfire.schmorp.de",
1885 say_command => 'say', 1899 say_command => 'say',
1886 audio_enable => 1, 1900 audio_enable => 1,
1887 bgm_enable => 1, 1901 bgm_enable => 1,
1888 bgm_volume => 0.25, 1902 bgm_volume => 0.25,
1889 face_prefetch => 0, 1903 face_prefetch => 0,
1890 output_sync => 1, 1904 output_sync => 1,
1891 output_count => 1, 1905 output_count => 1,
1892 pickup => 0, 1906 pickup => 0,
1907 default => "profile", # default profile
1908 );
1893 ); 1909
1894
1895 while (my ($k, $v) = each %DEF_CFG) { 1910 while (my ($k, $v) = each %DEF_CFG) {
1896 $CFG->{$k} = $v unless exists $CFG->{$k}; 1911 $CFG->{$k} = $v unless exists $CFG->{$k};
1897 } 1912 }
1913
1914 $CFG->{profile}{default}{host} ||= "crossfire.schmorp.de";
1898 1915
1899 sdl_init; 1916 sdl_init;
1900 1917
1901 @SDL_MODES = reverse 1918 @SDL_MODES = reverse
1902 grep $_->[0] >= 640 && $_->[1] >= 480, 1919 grep $_->[0] >= 640 && $_->[1] >= 480,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines