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.116 by root, Mon Aug 14 04:15:04 2006 UTC vs.
Revision 1.120 by root, Sun Oct 1 14:48:51 2006 UTC

47 47
48$Event::Eval = 0; 48$Event::Eval = 0;
49$Event::DIED = sub { 49$Event::DIED = sub {
50 # TODO: display dialog box or so 50 # TODO: display dialog box or so
51 Carp::cluck $_[1];#d#TODO: remove when stable 51 Carp::cluck $_[1];#d#TODO: remove when stable
52 CFPlus::error $_[1]; 52 return;#d#
53 CFPlus::fatal ($_[1]);
53}; 54};
54 55
55$SIG{__DIE__} = sub {
56 return if CFPlus::in_destruct;
57 Carp::cluck $_[0];
58 CFPlus::error $_[0];
59 return;#d#
60 #return unless defined $^S && !$^S;
61 $Event::DIED->(undef, $_[0]);
62};
63
64our $VERSION = '0.1'; 56our $VERSION = '0.9';
65 57
66my $MAX_FPS = 60; 58my $MAX_FPS = 60;
67my $MIN_FPS = 5; # unused as of yet 59my $MIN_FPS = 5; # unused as of yet
68 60
69our $META_SERVER = "crossfire.real-time.com:13326"; 61our $META_SERVER = "crossfire.real-time.com:13326";
71our $LAST_REFRESH; 63our $LAST_REFRESH;
72our $NOW; 64our $NOW;
73 65
74our $CFG; 66our $CFG;
75our $CONN; 67our $CONN;
68our $PROFILE; # current profile
76our $FAST; # fast, low-quality mode, possibly useful for software-rendering 69our $FAST; # fast, low-quality mode, possibly useful for software-rendering
77 70
78our $WANT_REFRESH; 71our $WANT_REFRESH;
79our $CAN_REFRESH; 72our $CAN_REFRESH;
80 73
352 status "logging in..."; 345 status "logging in...";
353 346
354 $LOGIN_BUTTON->set_text ("Logout"); 347 $LOGIN_BUTTON->set_text ("Logout");
355 $SETUP_DIALOG->hide; 348 $SETUP_DIALOG->hide;
356 349
350 $PROFILE = $CFG->{profile}{default};
351
357 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 352 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
358 353
359 my ($host, $port) = split /:/, $CFG->{profile}{default}{host}; 354 my ($host, $port) = split /:/, $PROFILE->{host};
360 355
361 $MAP = new CFPlus::Map $mapsize, $mapsize; 356 $MAP = new CFPlus::Map $mapsize, $mapsize;
362 357
363 $CONN = eval { 358 $CONN = eval {
364 new CFPlus::Protocol 359 new CFPlus::Protocol
365 host => $host, 360 host => $host,
366 port => $port || 13327, 361 port => $port || 13327,
367 user => $CFG->{profile}{default}{user}, 362 user => $PROFILE->{user},
368 pass => $CFG->{profile}{default}{password}, 363 pass => $PROFILE->{password},
369 mapw => $mapsize, 364 mapw => $mapsize,
370 maph => $mapsize, 365 maph => $mapsize,
366
367 client => "cfplus $VERSION $] $^O",
371 368
372 map_widget => $MAPWIDGET, 369 map_widget => $MAPWIDGET,
373 logview => $LOGVIEW, 370 logview => $LOGVIEW,
374 statusbox => $STATUSBOX, 371 statusbox => $STATUSBOX,
375 map => $MAP, 372 map => $MAP,
413 destroy_query_dialog $CONN; 410 destroy_query_dialog $CONN;
414 $CONN->destroy; 411 $CONN->destroy;
415 $CONN = 0; # false, does not autovivify 412 $CONN = 0; # false, does not autovivify
416 413
417 undef $MAP; 414 undef $MAP;
415 undef $PROFILE;
418} 416}
419 417
420sub graphics_setup { 418sub graphics_setup {
421 my $vbox = new CFPlus::UI::VBox; 419 my $vbox = new CFPlus::UI::VBox;
422 420
1043 }, 1041 },
1044 ); 1042 );
1045 1043
1046 $table->add (0, 12, new CFPlus::UI::Label valign => 0, align => 1, text => "Chat Command"); 1044 $table->add (0, 12, new CFPlus::UI::Label valign => 0, align => 1, text => "Chat Command");
1047 $table->add (1, 12, my $saycmd = new CFPlus::UI::Entry 1045 $table->add (1, 12, my $saycmd = new CFPlus::UI::Entry
1048 text => $CFG->{say_command}, 1046 text => $CFG->{say_command},
1049 tooltip => "This is the command that will be used if you write a line in the message window entry or press <b>\"</b> in the map window. " 1047 tooltip => "This is the command that will be used if you write a line in the message window entry or press <b>\"</b> in the map window. "
1050 . "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " 1048 . "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
1051 . "But you could also set it to <b>tell <i>playername</i></b> to only chat with that user.", 1049 . "But you could also set it to <b>tell <i>playername</i></b> to only chat with that user.",
1052 on_changed => sub { 1050 on_changed => sub {
1053 my ($self, $value) = @_; 1051 my ($self, $value) = @_;
1054 $CFG->{say_command} = $value; 1052 $CFG->{say_command} = $value;
1053 0
1054 }
1055 );
1056
1057 $table->add (0, 13, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day");
1058 $table->add (1, 13, my $saycmd = new CFPlus::UI::CheckBox
1059 state => $CFG->{show_tips},
1060 tooltip => "Show the <b>Tip of the day</b> window at startup?",
1061 on_changed => sub {
1062 my ($self, $value) = @_;
1063 $CFG->{shop_tips} = $value;
1055 0 1064 0
1056 } 1065 }
1057 ); 1066 );
1058 1067
1059 $vbox->add (new CFPlus::UI::FancyFrame 1068 $vbox->add (new CFPlus::UI::FancyFrame
1123 window => $window, 1132 window => $window,
1124 input => $input, 1133 input => $input,
1125 }; 1134 };
1126 1135
1127 $window 1136 $window
1128}
1129
1130sub open_string_query {
1131 my $cb = $_[1];
1132 my $dialog = new CFPlus::UI::Toplevel
1133 x => "center",
1134 y => "center",
1135 z => 50,
1136 force_w => $WIDTH * 4/5,
1137 title => $_[0];
1138
1139 $dialog->add (
1140 my $e = new CFPlus::UI::Entry
1141 on_activate => sub { $cb->(@_); $dialog->hide; 0 },
1142 on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 },
1143 );
1144
1145 $e->grab_focus;
1146 $dialog->show;
1147}
1148
1149sub open_quit_dialog {
1150 unless ($QUIT_DIALOG) {
1151 $QUIT_DIALOG = new CFPlus::UI::Toplevel
1152 x => "center",
1153 y => "center",
1154 z => 50,
1155 title => "Really Quit?",
1156 on_key_down => sub {
1157 my ($dialog, $ev) = @_;
1158 $ev->{sym} == 27 and $dialog->hide;
1159 }
1160 ;
1161
1162 $QUIT_DIALOG->add (my $vb = new CFPlus::UI::VBox expand => 1);
1163
1164 $vb->add (new CFPlus::UI::Label
1165 text => "You should find a savebed and apply it first!",
1166 max_w => $WIDTH * 0.25,
1167 ellipsize => 0,
1168 );
1169 $vb->add (my $hb = new CFPlus::UI::HBox expand => 1);
1170 $hb->add (new CFPlus::UI::Button
1171 text => "Ok",
1172 expand => 1,
1173 on_activate => sub { $QUIT_DIALOG->hide; 0 },
1174 );
1175 $hb->add (new CFPlus::UI::Button
1176 text => "Quit anyway",
1177 expand => 1,
1178 on_activate => sub { exit },
1179 );
1180 }
1181
1182 $QUIT_DIALOG->show;
1183 $QUIT_DIALOG->grab_focus;
1184} 1137}
1185 1138
1186sub autopickup_setup { 1139sub autopickup_setup {
1187 my $table = new CFPlus::UI::Table; 1140 my $table = new CFPlus::UI::Table;
1188 1141
1397 1350
1398 my $refresh; 1351 my $refresh;
1399 $refresh = $BIND_UPD_CB = sub { 1352 $refresh = $BIND_UPD_CB = sub {
1400 $binding_list->clear (); 1353 $binding_list->clear ();
1401 1354
1355 return unless $PROFILE;
1356
1402 for my $mod (keys %{$::CFG->{profile}{default}{bindings}}) { 1357 for my $mod (keys %{$PROFILE->{bindings}}) {
1403 for my $sym (keys %{$::CFG->{profile}{default}{bindings}{$mod}}) { 1358 for my $sym (keys %{$PROFILE->{bindings}{$mod}}) {
1404 my $cmds = $::CFG->{profile}{default}{bindings}{$mod}{$sym}; 1359 my $cmds = $PROFILE->{bindings}{$mod}{$sym};
1405 next unless ref $cmds eq 'ARRAY' and @$cmds > 0; 1360 next unless ref $cmds eq 'ARRAY' and @$cmds > 0;
1406 1361
1407 my $lbl = join "; ", @$cmds; 1362 my $lbl = join "; ", @$cmds;
1408 my $nam = CFPlus::BindingEditor::keycombo_to_name ($mod, $sym); 1363 my $nam = CFPlus::BindingEditor::keycombo_to_name ($mod, $sym);
1409 $binding_list->add (my $hb = new CFPlus::UI::HBox); 1364 $binding_list->add (my $hb = new CFPlus::UI::HBox);
1410 $hb->add (new CFPlus::UI::Button 1365 $hb->add (new CFPlus::UI::Button
1411 text => "delete", 1366 text => "delete",
1412 tooltip => "Deletes the binding", 1367 tooltip => "Deletes the binding",
1413 on_activate => sub { 1368 on_activate => sub {
1414 $binding_list->remove ($hb); 1369 $binding_list->remove ($hb);
1415 delete $::CFG->{profile}{default}{bindings}{$mod}{$sym}; 1370 delete $PROFILE->{bindings}{$mod}{$sym};
1416 0 1371 0
1417 }); 1372 });
1418 1373
1419 $hb->add (new CFPlus::UI::Button 1374 $hb->add (new CFPlus::UI::Button
1420 text => "edit", 1375 text => "edit",
1421 tooltip => "Edits the binding", 1376 tooltip => "Edits the binding",
1422 on_activate => sub { 1377 on_activate => sub {
1423 $::BIND_EDITOR->set_binding ( 1378 $::BIND_EDITOR->set_binding (
1424 $mod, $sym, $::CFG->{profile}{default}{bindings}{$mod}{$sym}, 1379 $mod, $sym, $PROFILE->{bindings}{$mod}{$sym},
1425 sub { 1380 sub {
1426 my ($nmod, $nsym, $ncmds) = @_; 1381 my ($nmod, $nsym, $ncmds) = @_;
1427 $::BIND_EDITOR->cfg_unbind ($mod, $sym); 1382 $::BIND_EDITOR->cfg_unbind ($mod, $sym);
1428 $::BIND_EDITOR->cfg_bind ($nmod, $nsym, $ncmds); 1383 $::BIND_EDITOR->cfg_bind ($nmod, $nsym, $ncmds);
1429 $refresh->(); 1384 $refresh->();
1507 1462
1508sub help_window { 1463sub help_window {
1509 my $win = new CFPlus::UI::Toplevel 1464 my $win = new CFPlus::UI::Toplevel
1510 x => 'center', 1465 x => 'center',
1511 y => 'center', 1466 y => 'center',
1512 z => 2, 1467 z => 4,
1513 name => 'doc_browser', 1468 name => 'doc_browser',
1514 force_w => int $WIDTH * 7/8, 1469 force_w => int $WIDTH * 7/8,
1515 force_h => int $HEIGHT * 7/8, 1470 force_h => int $HEIGHT * 7/8,
1516 title => "Help Browser", 1471 title => "Help Browser",
1517 has_close_button => 1; 1472 has_close_button => 1;
1603 $load_node->((CFPlus::Pod::find @path)[0]); 1558 $load_node->((CFPlus::Pod::find @path)[0]);
1604 $win->show; 1559 $win->show;
1605 }; 1560 };
1606 1561
1607 $win 1562 $win
1563}
1564
1565sub open_string_query {
1566 my ($title, $cb, $txt, $tooltip) = @_;
1567 my $dialog = new CFPlus::UI::Toplevel
1568 x => "center",
1569 y => "center",
1570 z => 50,
1571 force_w => $WIDTH * 4/5,
1572 title => $title;
1573
1574 $dialog->add (
1575 my $e = new CFPlus::UI::Entry
1576 on_activate => sub { $cb->(@_); $dialog->hide; 0 },
1577 on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 },
1578 tooltip => $tooltip
1579 );
1580
1581 $e->grab_focus;
1582 $e->set_text ($txt) if $txt;
1583 $dialog->show;
1584}
1585
1586sub open_quit_dialog {
1587 unless ($QUIT_DIALOG) {
1588 $QUIT_DIALOG = new CFPlus::UI::Toplevel
1589 x => "center",
1590 y => "center",
1591 z => 50,
1592 title => "Really Quit?",
1593 on_key_down => sub {
1594 my ($dialog, $ev) = @_;
1595 $ev->{sym} == 27 and $dialog->hide;
1596 }
1597 ;
1598
1599 $QUIT_DIALOG->add (my $vb = new CFPlus::UI::VBox expand => 1);
1600
1601 $vb->add (new CFPlus::UI::Label
1602 text => "You should find a savebed and apply it first!",
1603 max_w => $WIDTH * 0.25,
1604 ellipsize => 0,
1605 );
1606 $vb->add (my $hb = new CFPlus::UI::HBox expand => 1);
1607 $hb->add (new CFPlus::UI::Button
1608 text => "Ok",
1609 expand => 1,
1610 on_activate => sub { $QUIT_DIALOG->hide; 0 },
1611 );
1612 $hb->add (new CFPlus::UI::Button
1613 text => "Quit anyway",
1614 expand => 1,
1615 on_activate => sub { exit },
1616 );
1617 }
1618
1619 $QUIT_DIALOG->show;
1620 $QUIT_DIALOG->grab_focus;
1621}
1622
1623sub show_tip_of_the_day {
1624 # find all tips
1625 my @tod = CFPlus::Pod::find tip_of_the_day => "*";
1626
1627 my $todindex = $CFPlus::DB_STATE->get ("tip_of_the_day");
1628 $todindex = 0 if $todindex >= @tod;
1629 $CFPlus::DB_STATE->put (tip_of_the_day => $todindex + 1);
1630
1631 # create dialog
1632 my $dialog;
1633
1634 my $close = sub {
1635 $dialog->destroy;
1636 };
1637
1638 $dialog = new CFPlus::UI::Toplevel
1639 x => "center",
1640 y => "center",
1641 z => 3,
1642 name => 'tip_of_the_day',
1643 force_w => int $WIDTH * 4/9,
1644 force_h => int $WIDTH * 2/9,
1645 title => "Tip of the day #" . (1 + $todindex),
1646 child => my $vbox = new CFPlus::UI::VBox,
1647 has_close_button => 1,
1648 on_delete => $close,
1649 ;
1650
1651 $vbox->add (my $viewer = new CFPlus::UI::TextScroller
1652 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4);
1653 $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $tod[$todindex]);
1654
1655 $vbox->add (my $table = new CFPlus::UI::Table);
1656
1657 $table->add (0, 0, new CFPlus::UI::Button
1658 text => "Close",
1659 tooltip => "Close the tip of the day window. To never see it again, disable the tip of the day in the <b>Server Setup</b>.",
1660 on_activate => $close,
1661 );
1662
1663 $table->add (2, 0, new CFPlus::UI::Button
1664 text => "Next",
1665 tooltip => "Show the next <b>Tip of the day</b>.",
1666 on_activate => sub {
1667 $close->();
1668 &show_tip_of_the_day;
1669 },
1670 );
1671
1672 $dialog->show;
1608} 1673}
1609 1674
1610sub sdl_init { 1675sub sdl_init {
1611 CFPlus::SDL_Init 1676 CFPlus::SDL_Init
1612 and die "SDL::Init failed!\n"; 1677 and die "SDL::Init failed!\n";
1971 output_sync => 1, 2036 output_sync => 1,
1972 output_count => 1, 2037 output_count => 1,
1973 pickup => 0, 2038 pickup => 0,
1974 inv_sort => "mtime", 2039 inv_sort => "mtime",
1975 default => "profile", # default profile 2040 default => "profile", # default profile
2041 show_tips => 1,
1976 ); 2042 );
1977 2043
1978 while (my ($k, $v) = each %DEF_CFG) { 2044 while (my ($k, $v) = each %DEF_CFG) {
1979 $CFG->{$k} = $v unless exists $CFG->{$k}; 2045 $CFG->{$k} = $v unless exists $CFG->{$k};
1980 } 2046 }
2028 2094
2029 video_init; 2095 video_init;
2030 audio_init; 2096 audio_init;
2031} 2097}
2032 2098
2099show_tip_of_the_day if $CFG->{show_tips};
2100
2101use Data::Dumper; warn Dumper [CFPlus::win32_proxy_info()];#d#
2102
2033Event::loop; 2103Event::loop;
2034#CFPlus::SDL_Quit; 2104#CFPlus::SDL_Quit;
2035#CFPlus::_exit 0; 2105#CFPlus::_exit 0;
2036 2106
2037END { CFPlus::SDL_Quit } 2107END { CFPlus::SDL_Quit }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines