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.117 by elmex, Tue Aug 15 06:30:05 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 ($title, $cb, $txt, $tooltip) = @_;
1132 my $dialog = new CFPlus::UI::Toplevel
1133 x => "center",
1134 y => "center",
1135 z => 50,
1136 force_w => $WIDTH * 4/5,
1137 title => $title;
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 tooltip => $tooltip
1144 );
1145
1146 $e->grab_focus;
1147 $e->set_text ($txt) if $txt;
1148 $dialog->show;
1149}
1150
1151sub open_quit_dialog {
1152 unless ($QUIT_DIALOG) {
1153 $QUIT_DIALOG = new CFPlus::UI::Toplevel
1154 x => "center",
1155 y => "center",
1156 z => 50,
1157 title => "Really Quit?",
1158 on_key_down => sub {
1159 my ($dialog, $ev) = @_;
1160 $ev->{sym} == 27 and $dialog->hide;
1161 }
1162 ;
1163
1164 $QUIT_DIALOG->add (my $vb = new CFPlus::UI::VBox expand => 1);
1165
1166 $vb->add (new CFPlus::UI::Label
1167 text => "You should find a savebed and apply it first!",
1168 max_w => $WIDTH * 0.25,
1169 ellipsize => 0,
1170 );
1171 $vb->add (my $hb = new CFPlus::UI::HBox expand => 1);
1172 $hb->add (new CFPlus::UI::Button
1173 text => "Ok",
1174 expand => 1,
1175 on_activate => sub { $QUIT_DIALOG->hide; 0 },
1176 );
1177 $hb->add (new CFPlus::UI::Button
1178 text => "Quit anyway",
1179 expand => 1,
1180 on_activate => sub { exit },
1181 );
1182 }
1183
1184 $QUIT_DIALOG->show;
1185 $QUIT_DIALOG->grab_focus;
1186} 1137}
1187 1138
1188sub autopickup_setup { 1139sub autopickup_setup {
1189 my $table = new CFPlus::UI::Table; 1140 my $table = new CFPlus::UI::Table;
1190 1141
1399 1350
1400 my $refresh; 1351 my $refresh;
1401 $refresh = $BIND_UPD_CB = sub { 1352 $refresh = $BIND_UPD_CB = sub {
1402 $binding_list->clear (); 1353 $binding_list->clear ();
1403 1354
1355 return unless $PROFILE;
1356
1404 for my $mod (keys %{$::CFG->{profile}{default}{bindings}}) { 1357 for my $mod (keys %{$PROFILE->{bindings}}) {
1405 for my $sym (keys %{$::CFG->{profile}{default}{bindings}{$mod}}) { 1358 for my $sym (keys %{$PROFILE->{bindings}{$mod}}) {
1406 my $cmds = $::CFG->{profile}{default}{bindings}{$mod}{$sym}; 1359 my $cmds = $PROFILE->{bindings}{$mod}{$sym};
1407 next unless ref $cmds eq 'ARRAY' and @$cmds > 0; 1360 next unless ref $cmds eq 'ARRAY' and @$cmds > 0;
1408 1361
1409 my $lbl = join "; ", @$cmds; 1362 my $lbl = join "; ", @$cmds;
1410 my $nam = CFPlus::BindingEditor::keycombo_to_name ($mod, $sym); 1363 my $nam = CFPlus::BindingEditor::keycombo_to_name ($mod, $sym);
1411 $binding_list->add (my $hb = new CFPlus::UI::HBox); 1364 $binding_list->add (my $hb = new CFPlus::UI::HBox);
1412 $hb->add (new CFPlus::UI::Button 1365 $hb->add (new CFPlus::UI::Button
1413 text => "delete", 1366 text => "delete",
1414 tooltip => "Deletes the binding", 1367 tooltip => "Deletes the binding",
1415 on_activate => sub { 1368 on_activate => sub {
1416 $binding_list->remove ($hb); 1369 $binding_list->remove ($hb);
1417 delete $::CFG->{profile}{default}{bindings}{$mod}{$sym}; 1370 delete $PROFILE->{bindings}{$mod}{$sym};
1418 0 1371 0
1419 }); 1372 });
1420 1373
1421 $hb->add (new CFPlus::UI::Button 1374 $hb->add (new CFPlus::UI::Button
1422 text => "edit", 1375 text => "edit",
1423 tooltip => "Edits the binding", 1376 tooltip => "Edits the binding",
1424 on_activate => sub { 1377 on_activate => sub {
1425 $::BIND_EDITOR->set_binding ( 1378 $::BIND_EDITOR->set_binding (
1426 $mod, $sym, $::CFG->{profile}{default}{bindings}{$mod}{$sym}, 1379 $mod, $sym, $PROFILE->{bindings}{$mod}{$sym},
1427 sub { 1380 sub {
1428 my ($nmod, $nsym, $ncmds) = @_; 1381 my ($nmod, $nsym, $ncmds) = @_;
1429 $::BIND_EDITOR->cfg_unbind ($mod, $sym); 1382 $::BIND_EDITOR->cfg_unbind ($mod, $sym);
1430 $::BIND_EDITOR->cfg_bind ($nmod, $nsym, $ncmds); 1383 $::BIND_EDITOR->cfg_bind ($nmod, $nsym, $ncmds);
1431 $refresh->(); 1384 $refresh->();
1509 1462
1510sub help_window { 1463sub help_window {
1511 my $win = new CFPlus::UI::Toplevel 1464 my $win = new CFPlus::UI::Toplevel
1512 x => 'center', 1465 x => 'center',
1513 y => 'center', 1466 y => 'center',
1514 z => 2, 1467 z => 4,
1515 name => 'doc_browser', 1468 name => 'doc_browser',
1516 force_w => int $WIDTH * 7/8, 1469 force_w => int $WIDTH * 7/8,
1517 force_h => int $HEIGHT * 7/8, 1470 force_h => int $HEIGHT * 7/8,
1518 title => "Help Browser", 1471 title => "Help Browser",
1519 has_close_button => 1; 1472 has_close_button => 1;
1605 $load_node->((CFPlus::Pod::find @path)[0]); 1558 $load_node->((CFPlus::Pod::find @path)[0]);
1606 $win->show; 1559 $win->show;
1607 }; 1560 };
1608 1561
1609 $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;
1610} 1673}
1611 1674
1612sub sdl_init { 1675sub sdl_init {
1613 CFPlus::SDL_Init 1676 CFPlus::SDL_Init
1614 and die "SDL::Init failed!\n"; 1677 and die "SDL::Init failed!\n";
1973 output_sync => 1, 2036 output_sync => 1,
1974 output_count => 1, 2037 output_count => 1,
1975 pickup => 0, 2038 pickup => 0,
1976 inv_sort => "mtime", 2039 inv_sort => "mtime",
1977 default => "profile", # default profile 2040 default => "profile", # default profile
2041 show_tips => 1,
1978 ); 2042 );
1979 2043
1980 while (my ($k, $v) = each %DEF_CFG) { 2044 while (my ($k, $v) = each %DEF_CFG) {
1981 $CFG->{$k} = $v unless exists $CFG->{$k}; 2045 $CFG->{$k} = $v unless exists $CFG->{$k};
1982 } 2046 }
2030 2094
2031 video_init; 2095 video_init;
2032 audio_init; 2096 audio_init;
2033} 2097}
2034 2098
2099show_tip_of_the_day if $CFG->{show_tips};
2100
2101use Data::Dumper; warn Dumper [CFPlus::win32_proxy_info()];#d#
2102
2035Event::loop; 2103Event::loop;
2036#CFPlus::SDL_Quit; 2104#CFPlus::SDL_Quit;
2037#CFPlus::_exit 0; 2105#CFPlus::_exit 0;
2038 2106
2039END { CFPlus::SDL_Quit } 2107END { CFPlus::SDL_Quit }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines