… | |
… | |
1071 | text => $CFG->{profile}{default}{host}, |
1071 | text => $CFG->{profile}{default}{host}, |
1072 | tooltip => "The hostname or ip address of the Crossfire(+) server to connect to", |
1072 | tooltip => "The hostname or ip address of the Crossfire(+) server to connect to", |
1073 | on_changed => sub { |
1073 | on_changed => sub { |
1074 | my ($self, $value) = @_; |
1074 | my ($self, $value) = @_; |
1075 | $CFG->{profile}{default}{host} = $value; |
1075 | $CFG->{profile}{default}{host} = $value; |
1076 | 0 |
1076 | 1 |
1077 | } |
1077 | } |
1078 | ); |
1078 | ); |
1079 | |
1079 | |
1080 | $vbox->add (new CFPlus::UI::Button |
1080 | $vbox->add (new CFPlus::UI::Button |
1081 | expand => 1, |
1081 | expand => 1, |
1082 | text => "Server List", |
1082 | text => "Server List", |
1083 | other => $METASERVER, |
1083 | other => $METASERVER, |
1084 | tooltip => "Show a list of available crossfire servers", |
1084 | tooltip => "Show a list of available crossfire servers", |
1085 | on_activate => sub { $METASERVER->toggle_visibility; 0 }, |
1085 | on_activate => sub { $METASERVER->toggle_visibility; 0 }, |
1086 | on_visibility_change => sub { $METASERVER->hide unless $_[1]; 0 }, |
1086 | on_visibility_change => sub { $METASERVER->hide unless $_[1]; 1 }, |
1087 | ); |
1087 | ); |
1088 | } |
1088 | } |
1089 | |
1089 | |
1090 | $table->add_at (0, 4, new CFPlus::UI::Label valign => 0, align => 1, text => "Username"); |
1090 | $table->add_at (0, 4, new CFPlus::UI::Label valign => 0, align => 1, text => "Username"); |
1091 | $table->add_at (1, 4, new CFPlus::UI::Entry |
1091 | $table->add_at (1, 4, new CFPlus::UI::Entry |
1092 | text => $CFG->{profile}{default}{user}, |
1092 | text => $CFG->{profile}{default}{user}, |
1093 | tooltip => "The name of your character on the server", |
1093 | tooltip => "The name of your character on the server", |
1094 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value } |
1094 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 } |
1095 | ); |
1095 | ); |
1096 | |
1096 | |
1097 | $table->add_at (0, 5, new CFPlus::UI::Label valign => 0, align => 1, text => "Password"); |
1097 | $table->add_at (0, 5, new CFPlus::UI::Label valign => 0, align => 1, text => "Password"); |
1098 | $table->add_at (1, 5, new CFPlus::UI::Entry |
1098 | $table->add_at (1, 5, new CFPlus::UI::Entry |
1099 | text => $CFG->{profile}{default}{password}, |
1099 | text => $CFG->{profile}{default}{password}, |
1100 | hidden => 1, |
1100 | hidden => 1, |
1101 | tooltip => "The password for your character", |
1101 | tooltip => "The password for your character", |
1102 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value } |
1102 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value; 1 } |
1103 | ); |
1103 | ); |
1104 | |
1104 | |
1105 | $table->add_at (0, 7, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Size"); |
1105 | $table->add_at (0, 7, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Size"); |
1106 | $table->add_at (1, 7, new CFPlus::UI::Slider |
1106 | $table->add_at (1, 7, new CFPlus::UI::Slider |
1107 | force_w => 100, |
1107 | force_w => 100, |
1108 | range => [$CFG->{mapsize}, 10, 100, 0, 1], |
1108 | range => [$CFG->{mapsize}, 10, 100, 0, 1], |
1109 | tooltip => "This is the size of the portion of the map update the server sends you. " |
1109 | tooltip => "This is the size of the portion of the map update the server sends you. " |
1110 | . "If you set this to a high value you will be able to see further, " |
1110 | . "If you set this to a high value you will be able to see further, " |
1111 | . "but you also increase bandwidth requirements and latency. " |
1111 | . "but you also increase bandwidth requirements and latency. " |
1112 | . "This option is only used once at log-in.", |
1112 | . "This option is only used once at log-in.", |
1113 | on_changed => sub { my ($self, $value) = @_; $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 0 }, |
1113 | on_changed => sub { my ($self, $value) = @_; $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 1 }, |
1114 | ); |
1114 | ); |
1115 | |
1115 | |
1116 | $table->add_at (0, 8, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Rate"); |
1116 | $table->add_at (0, 8, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Rate"); |
1117 | $table->add_at (1, 8, new CFPlus::UI::Entry |
1117 | $table->add_at (1, 8, new CFPlus::UI::Entry |
1118 | text => $CFG->{output_rate}, |
1118 | text => $CFG->{output_rate}, |
1119 | tooltip => "The approximate bandwidth in bytes per second that the server should not exceed " |
1119 | tooltip => "The maximum bandwidth in bytes per second that the server should not exceed " |
1120 | . "when sending images, to ensure interactiveness. When 0 or unset, the server " |
1120 | . "when sending data. When 0 or unset, the server " |
1121 | . "default will be used, which is usually around 100kb/s.", |
1121 | . "default will be used, which is usually around 100kb/s. Most servers will " |
|
|
1122 | . "dynamically find an optimal rate, so adjust this only when necessary.", |
1122 | on_changed => sub { $CFG->{output_rate} = $_[1]; 0 }, |
1123 | on_changed => sub { $CFG->{output_rate} = $_[1]; 1 }, |
1123 | ); |
1124 | ); |
1124 | |
1125 | |
1125 | $table->add_at (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Count"); |
1126 | $table->add_at (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Count"); |
1126 | $table->add_at (1, 9, new CFPlus::UI::Entry |
1127 | $table->add_at (1, 9, new CFPlus::UI::Entry |
1127 | text => $CFG->{output_count}, |
1128 | text => $CFG->{output_count}, |
1128 | tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.", |
1129 | tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.", |
1129 | on_changed => sub { $CFG->{output_count} = $_[1]; 0 }, |
1130 | on_changed => sub { $CFG->{output_count} = $_[1]; 1 }, |
1130 | ); |
1131 | ); |
1131 | |
1132 | |
1132 | $table->add_at (0, 10, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Sync"); |
1133 | $table->add_at (0, 10, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Sync"); |
1133 | $table->add_at (1, 10, new CFPlus::UI::Entry |
1134 | $table->add_at (1, 10, new CFPlus::UI::Entry |
1134 | text => $CFG->{output_sync}, |
1135 | text => $CFG->{output_sync}, |
1135 | tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.", |
1136 | tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.", |
1136 | on_changed => sub { $CFG->{output_sync} = $_[1]; 0 }, |
1137 | on_changed => sub { $CFG->{output_sync} = $_[1]; 1 }, |
1137 | ); |
1138 | ); |
1138 | |
1139 | |
1139 | $table->add_at (1, 11, $LOGIN_BUTTON = new CFPlus::UI::Button |
1140 | $table->add_at (1, 11, $LOGIN_BUTTON = new CFPlus::UI::Button |
1140 | expand => 1, |
1141 | expand => 1, |
1141 | align => 0, |
1142 | align => 0, |
1142 | text => "Login", |
1143 | text => "Login", |
1143 | on_activate => sub { |
1144 | on_activate => sub { |
1144 | $CONN ? stop_game |
1145 | $CONN ? stop_game |
1145 | : start_game; |
1146 | : start_game; |
1146 | 0 |
1147 | 1 |
1147 | }, |
1148 | }, |
1148 | ); |
1149 | ); |
1149 | |
1150 | |
1150 | $vbox->add (new CFPlus::UI::FancyFrame |
1151 | $vbox->add (new CFPlus::UI::FancyFrame |
1151 | label => "Server Info", |
1152 | label => "Server Info", |
… | |
… | |
1819 | my $meta = $CONN->{sound_meta}{$face} |
1820 | my $meta = $CONN->{sound_meta}{$face} |
1820 | or return; |
1821 | or return; |
1821 | |
1822 | |
1822 | # fetch from database |
1823 | # fetch from database |
1823 | CFPlus::DB::get res_data => $meta->{name}, sub { |
1824 | CFPlus::DB::get res_data => $meta->{name}, sub { |
1824 | my $vol = $meta->{meta}{volume} || 100; |
1825 | my $vol = $meta->{meta}{volume} || 1; |
1825 | my $rwops = new CFPlus::RW $_[0]; |
1826 | my $rwops = new CFPlus::RW $_[0]; |
1826 | my $chunk = new CFPlus::MixChunk $rwops; |
1827 | my $chunk = new CFPlus::MixChunk $rwops; |
1827 | $chunk->volume ($vol * 128 / 100); |
1828 | $chunk->volume ($vol * 128); |
1828 | $AUDIO_CHUNK{$face} = $chunk; |
1829 | $AUDIO_CHUNK{$face} = $chunk; |
1829 | |
1830 | |
1830 | audio_sound_push ($face); |
1831 | audio_sound_push ($face); |
1831 | }; |
1832 | }; |
1832 | } |
1833 | } |
… | |
… | |
1961 | |
1962 | |
1962 | my %animate_object; |
1963 | my %animate_object; |
1963 | my $animate_timer; |
1964 | my $animate_timer; |
1964 | |
1965 | |
1965 | my $fps = 9; |
1966 | my $fps = 9; |
1966 | |
|
|
1967 | my %demo;#d# |
|
|
1968 | |
1967 | |
1969 | sub force_refresh { |
1968 | sub force_refresh { |
1970 | $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; |
1969 | $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; |
1971 | debug sprintf "%3.2f", $fps if $ENV{CFPLUS_DEBUG} & 4; |
1970 | debug sprintf "%3.2f", $fps if $ENV{CFPLUS_DEBUG} & 4; |
1972 | |
1971 | |
… | |
… | |
2057 | |
2056 | |
2058 | CFPlus::UI::set_layout ($::CFG->{layout}); |
2057 | CFPlus::UI::set_layout ($::CFG->{layout}); |
2059 | |
2058 | |
2060 | my %DEF_CFG = ( |
2059 | my %DEF_CFG = ( |
2061 | sdl_mode => 0, |
2060 | sdl_mode => 0, |
2062 | width => 640, |
|
|
2063 | height => 480, |
|
|
2064 | fullscreen => 0, |
2061 | fullscreen => 0, |
2065 | fast => 0, |
2062 | fast => 0, |
2066 | map_scale => 1, |
2063 | map_scale => 1, |
2067 | fow_enable => 1, |
2064 | fow_enable => 1, |
2068 | fow_intensity => 0, |
2065 | fow_intensity => 0, |