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.141 by elmex, Sat Dec 16 17:33:26 2006 UTC vs.
Revision 1.148 by root, Mon Apr 9 04:39:11 2007 UTC

58use Compress::LZF; 58use Compress::LZF;
59 59
60use CFPlus; 60use CFPlus;
61use CFPlus::OpenGL (); 61use CFPlus::OpenGL ();
62use CFPlus::Protocol; 62use CFPlus::Protocol;
63use CFPlus::DB;
63use CFPlus::UI; 64use CFPlus::UI;
64use CFPlus::UI::Inventory; 65use CFPlus::UI::Inventory;
65use CFPlus::UI::SpellList; 66use CFPlus::UI::SpellList;
66use CFPlus::Pod; 67use CFPlus::Pod;
67use CFPlus::MapWidget; 68use CFPlus::MapWidget;
465sub graphics_setup { 466sub graphics_setup {
466 my $vbox = new CFPlus::UI::VBox; 467 my $vbox = new CFPlus::UI::VBox;
467 468
468 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]); 469 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]);
469 470
471 my $row = 0;
472
473 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "OpenGL Info");
474 $table->add (1, $row++, new CFPlus::UI::Label valign => 0, fontsize => 0.8, text => CFPlus::OpenGL::gl_vendor . ", " . CFPlus::OpenGL::gl_version,
475 can_events => 1,
476 tooltip => "<tt><span size='8192'>" . (CFPlus::OpenGL::gl_extensions) . "</span></tt>");
477
470 $table->add (0, 0, new CFPlus::UI::Label valign => 0, align => 1, text => "Video Mode"); 478 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Video Mode");
471 $table->add (1, 0, my $hbox = new CFPlus::UI::HBox); 479 $table->add (1, $row++, my $hbox = new CFPlus::UI::HBox);
472 480
473 $hbox->add (my $mode_slider = new CFPlus::UI::Slider force_w => $WIDTH * 0.1, expand => 1, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 0, 1]); 481 $hbox->add (my $mode_slider = new CFPlus::UI::Slider force_w => $WIDTH * 0.1, expand => 1, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 0, 1]);
474 $hbox->add (my $mode_label = new CFPlus::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999"); 482 $hbox->add (my $mode_label = new CFPlus::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999");
475 483
476 $mode_slider->connect (changed => sub { 484 $mode_slider->connect (changed => sub {
478 486
479 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; 487 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value;
480 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); 488 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]});
481 }); 489 });
482 $mode_slider->emit (changed => $mode_slider->{range}[0]); 490 $mode_slider->emit (changed => $mode_slider->{range}[0]);
483
484 my $row = 1;
485 491
486 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fullscreen"); 492 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fullscreen");
487 $table->add (1, $row++, $FULLSCREEN_ENABLE = new CFPlus::UI::CheckBox 493 $table->add (1, $row++, $FULLSCREEN_ENABLE = new CFPlus::UI::CheckBox
488 state => $CFG->{fullscreen}, 494 state => $CFG->{fullscreen},
489 tooltip => "Bring the client into fullscreen mode.", 495 tooltip => "Bring the client into fullscreen mode.",
905 for 0 .. $#col; 911 for 0 .. $#col;
906 912
907 my @align = qw(1 0 1 1 -1); 913 my @align = qw(1 0 1 1 -1);
908 914
909 my $y = 0; 915 my $y = 0;
910 for my $m (
911 sort {
912 $b->{version} <=> $a->{version}
913 or $b->{users} <=> $a->{users}
914 }
915 @{ $msg->{servers} } 916 for my $m (@{ $msg->{servers} }) {
916 ) {
917 my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime) = 917 my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime, $highlight) =
918 @$m{qw(ip age hostname users version description ibytes obytes uptime)}; 918 @$m{qw(ip age hostname users version description ibytes obytes uptime highlight)};
919 919
920 for ($desc) { 920 for ($desc) {
921 s/<br>/\n/gi; 921 s/<br>/\n/gi;
922 s/<li>/\n· /gi; 922 s/<li>/\n· /gi;
923 s/<.*?>//sgi; 923 s/<.*?>//sgi;
953 max_w => $::WIDTH * 0.4, 953 max_w => $::WIDTH * 0.4,
954 ellipsise => 0, 954 ellipsise => 0,
955 align => $align[$_], 955 align => $align[$_],
956 text => $m->[$_], 956 text => $m->[$_],
957 tooltip => $tip[$_], 957 tooltip => $tip[$_],
958 fg => ($m->[3] =~ /\+$/ ? [1, 1, 1] : [.7, .7, .7]), 958 fg => ($highlight ? [1, 1, 1] : [.7, .7, .7]),
959 can_hover => 1, 959 can_hover => 1,
960 can_events => 1, 960 can_events => 1,
961 fontsize => 0.8) 961 fontsize => 0.8)
962 for 0 .. $#$m; 962 for 0 .. $#$m;
963 } 963 }
1064 . "so only set it if you really need to prefetch images. " 1064 . "so only set it if you really need to prefetch images. "
1065 . "This option can be set and unset any time.", 1065 . "This option can be set and unset any time.",
1066 on_changed => sub { $CFG->{face_prefetch} = $_[1]; 0 }, 1066 on_changed => sub { $CFG->{face_prefetch} = $_[1]; 0 },
1067 ); 1067 );
1068 1068
1069 $table->add (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Count"); 1069 $table->add (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Rate");
1070 $table->add (1, 9, new CFPlus::UI::Entry 1070 $table->add (1, 9, new CFPlus::UI::Entry
1071 text => $CFG->{output_rate},
1072 tooltip => "The approximate bandwidth in bytes per second that the server should not exceed "
1073 . "when sending images, to ensure interactiveness. When 0 or unset, the server "
1074 . "default will be used, which is usually around 100kb/s.",
1075 on_changed => sub { $CFG->{output_rate} = $_[1]; 0 },
1076 );
1077
1078 $table->add (0, 10, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Count");
1079 $table->add (1, 10, new CFPlus::UI::Entry
1071 text => $CFG->{output_count}, 1080 text => $CFG->{output_count},
1072 tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.", 1081 tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.",
1073 on_changed => sub { $CFG->{output_count} = $_[1]; 0 }, 1082 on_changed => sub { $CFG->{output_count} = $_[1]; 0 },
1074 ); 1083 );
1075 1084
1076 $table->add (0, 10, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Sync"); 1085 $table->add (0, 11, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Sync");
1077 $table->add (1, 10, new CFPlus::UI::Entry 1086 $table->add (1, 11, new CFPlus::UI::Entry
1078 text => $CFG->{output_sync}, 1087 text => $CFG->{output_sync},
1079 tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.", 1088 tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.",
1080 on_changed => sub { $CFG->{output_sync} = $_[1]; 0 }, 1089 on_changed => sub { $CFG->{output_sync} = $_[1]; 0 },
1081 ); 1090 );
1082 1091
1083 $table->add (1, 11, $LOGIN_BUTTON = new CFPlus::UI::Button 1092 $table->add (1, 12, $LOGIN_BUTTON = new CFPlus::UI::Button
1084 expand => 1, 1093 expand => 1,
1085 align => 0, 1094 align => 0,
1086 text => "Login", 1095 text => "Login",
1087 on_activate => sub { 1096 on_activate => sub {
1088 $CONN ? stop_game 1097 $CONN ? stop_game
1089 : start_game; 1098 : start_game;
1090 0 1099 0
1091 }, 1100 },
1092 ); 1101 );
1093 1102
1094 $table->add (0, 12, new CFPlus::UI::Label valign => 0, align => 1, text => "Chat Command"); 1103 $table->add (0, 13, new CFPlus::UI::Label valign => 0, align => 1, text => "Chat Command");
1095 $table->add (1, 12, my $saycmd = new CFPlus::UI::Entry 1104 $table->add (1, 13, my $saycmd = new CFPlus::UI::Entry
1096 text => $CFG->{say_command}, 1105 text => $CFG->{say_command},
1097 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. " 1106 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. "
1098 . "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " 1107 . "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
1099 . "But you could also set it to <b>tell <i>playername</i></b> to only chat with that user.", 1108 . "But you could also set it to <b>tell <i>playername</i></b> to only chat with that user.",
1100 on_changed => sub { 1109 on_changed => sub {
1102 $CFG->{say_command} = $value; 1111 $CFG->{say_command} = $value;
1103 0 1112 0
1104 } 1113 }
1105 ); 1114 );
1106 1115
1107 $table->add (0, 13, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day"); 1116 $table->add (0, 14, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day");
1108 $table->add (1, 13, my $saycmd = new CFPlus::UI::CheckBox 1117 $table->add (1, 14, my $saycmd = new CFPlus::UI::CheckBox
1109 state => $CFG->{show_tips}, 1118 state => $CFG->{show_tips},
1110 tooltip => "Show the <b>Tip of the day</b> window at startup?", 1119 tooltip => "Show the <b>Tip of the day</b> window at startup?",
1111 on_changed => sub { 1120 on_changed => sub {
1112 my ($self, $value) = @_; 1121 my ($self, $value) = @_;
1113 $CFG->{show_tips} = $value; 1122 $CFG->{show_tips} = $value;
1565 1574
1566sub show_tip_of_the_day { 1575sub show_tip_of_the_day {
1567 # find all tips 1576 # find all tips
1568 my @tod = CFPlus::Pod::find tip_of_the_day => "*"; 1577 my @tod = CFPlus::Pod::find tip_of_the_day => "*";
1569 1578
1570 my $todindex = $CFPlus::DB_STATE->get ("tip_of_the_day"); 1579 CFPlus::DB::get state => "tip_of_the_day", sub {
1580 my ($todindex) = @_;
1571 $todindex = 0 if $todindex >= @tod; 1581 $todindex = 0 if $todindex >= @tod;
1572 $CFPlus::DB_STATE->put (tip_of_the_day => $todindex + 1); 1582 CFPlus::DB::put state => tip_of_the_day => $todindex + 1, sub { };
1573 1583
1574 # create dialog 1584 # create dialog
1575 my $dialog; 1585 my $dialog;
1576 1586
1577 my $close = sub { 1587 my $close = sub {
1578 $dialog->destroy; 1588 $dialog->destroy;
1589 };
1590
1591 $dialog = new CFPlus::UI::Toplevel
1592 x => "center",
1593 y => "center",
1594 z => 3,
1595 name => 'tip_of_the_day',
1596 force_w => int $WIDTH * 4/9,
1597 force_h => int $WIDTH * 2/9,
1598 title => "Tip of the day #" . (1 + $todindex),
1599 child => my $vbox = new CFPlus::UI::VBox,
1600 has_close_button => 1,
1601 on_delete => $close,
1602 ;
1603
1604 $vbox->add (my $viewer = new CFPlus::UI::TextScroller
1605 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4);
1606 $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $tod[$todindex]);
1607
1608 $vbox->add (my $table = new CFPlus::UI::Table col_expand => [0, 1]);
1609
1610 $table->add (0, 0, new CFPlus::UI::Button
1611 text => "Close",
1612 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>.",
1613 on_activate => $close,
1614 );
1615
1616 $table->add (2, 0, new CFPlus::UI::Button
1617 text => "Next",
1618 tooltip => "Show the next <b>Tip of the day</b>.",
1619 on_activate => sub {
1620 $close->();
1621 &show_tip_of_the_day;
1622 },
1623 );
1624
1625 $dialog->show;
1579 }; 1626 };
1580
1581 $dialog = new CFPlus::UI::Toplevel
1582 x => "center",
1583 y => "center",
1584 z => 3,
1585 name => 'tip_of_the_day',
1586 force_w => int $WIDTH * 4/9,
1587 force_h => int $WIDTH * 2/9,
1588 title => "Tip of the day #" . (1 + $todindex),
1589 child => my $vbox = new CFPlus::UI::VBox,
1590 has_close_button => 1,
1591 on_delete => $close,
1592 ;
1593
1594 $vbox->add (my $viewer = new CFPlus::UI::TextScroller
1595 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4);
1596 $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $tod[$todindex]);
1597
1598 $vbox->add (my $table = new CFPlus::UI::Table col_expand => [0, 1]);
1599
1600 $table->add (0, 0, new CFPlus::UI::Button
1601 text => "Close",
1602 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>.",
1603 on_activate => $close,
1604 );
1605
1606 $table->add (2, 0, new CFPlus::UI::Button
1607 text => "Next",
1608 tooltip => "Show the next <b>Tip of the day</b>.",
1609 on_activate => sub {
1610 $close->();
1611 &show_tip_of_the_day;
1612 },
1613 );
1614
1615 $dialog->show;
1616} 1627}
1617 1628
1618sub sdl_init { 1629sub sdl_init {
1619 CFPlus::SDL_Init 1630 CFPlus::SDL_Init
1620 and die "SDL::Init failed!\n"; 1631 and die "SDL::Init failed!\n";
2074 2085
2075$SIG{INT} = $SIG{TERM} = sub { exit }; 2086$SIG{INT} = $SIG{TERM} = sub { exit };
2076 2087
2077{ 2088{
2078 CFPlus::read_cfg "$Crossfire::VARDIR/cfplusrc"; 2089 CFPlus::read_cfg "$Crossfire::VARDIR/cfplusrc";
2090 CFPlus::DB::Server::run;
2091
2079 CFPlus::UI::set_layout ($::CFG->{layout}); 2092 CFPlus::UI::set_layout ($::CFG->{layout});
2080 2093
2081 my %DEF_CFG = ( 2094 my %DEF_CFG = (
2082 sdl_mode => 0, 2095 sdl_mode => 0,
2083 width => 640, 2096 width => 640,
2099 bgm_enable => 1, 2112 bgm_enable => 1,
2100 bgm_volume => 0.25, 2113 bgm_volume => 0.25,
2101 face_prefetch => 0, 2114 face_prefetch => 0,
2102 output_sync => 1, 2115 output_sync => 1,
2103 output_count => 1, 2116 output_count => 1,
2117 output_rate => "",
2104 pickup => 0, 2118 pickup => 0,
2105 inv_sort => "mtime", 2119 inv_sort => "mtime",
2106 default => "profile", # default profile 2120 default => "profile", # default profile
2107 show_tips => 1, 2121 show_tips => 1,
2108 ); 2122 );

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines