… | |
… | |
22 | |
22 | |
23 | use Compress::LZF; |
23 | use Compress::LZF; |
24 | |
24 | |
25 | use CFClient; |
25 | use CFClient; |
26 | use CFClient::UI; |
26 | use CFClient::UI; |
|
|
27 | use CFClient::MapWidget; |
27 | |
28 | |
28 | our $VERSION = '0.1'; |
29 | our $VERSION = '0.1'; |
29 | |
30 | |
30 | my $MAX_FPS = 60; |
31 | my $MAX_FPS = 60; |
31 | my $MIN_FPS = 5; # unused as of yet |
32 | my $MIN_FPS = 5; # unused as of yet |
… | |
… | |
158 | my ($self, $value) = @_; |
159 | my ($self, $value) = @_; |
159 | $CFG->{fow_smooth} = $value; |
160 | $CFG->{fow_smooth} = $value; |
160 | status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; |
161 | status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; |
161 | }); |
162 | }); |
162 | |
163 | |
163 | $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Log Fontsize"); |
164 | $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); |
164 | $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{gui_fontsize}, 0.5, 1.5, 0.1], connect_changed => sub { |
165 | $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{gui_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub { |
165 | $CFG->{gui_fontsize} = 0.1 * int $_[0] * 10; |
166 | $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10; |
166 | # $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
167 | # $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
167 | }); |
168 | }); |
168 | |
169 | |
169 | $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Log Fontsize"); |
170 | $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize"); |
170 | $table->add (1, 7, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 0.7, 1.5, 0.1], connect_changed => sub { |
171 | $table->add (1, 7, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub { |
171 | $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[0] * 10); |
172 | $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10); |
172 | }); |
173 | }); |
173 | |
174 | |
174 | $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
175 | $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
175 | video_shutdown (); |
176 | video_shutdown (); |
176 | video_init (); |
177 | video_init (); |
… | |
… | |
182 | }); |
183 | }); |
183 | # $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume"); |
184 | # $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume"); |
184 | # $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], connect_changed => sub { |
185 | # $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], connect_changed => sub { |
185 | # $CFG->{effects_volume} = $_[1]; |
186 | # $CFG->{effects_volume} = $_[1]; |
186 | # }); |
187 | # }); |
187 | $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Bg. Music"); |
188 | $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music"); |
188 | $table->add (1, 10, my $hbox = new CFClient::UI::HBox); |
189 | $table->add (1, 10, my $hbox = new CFClient::UI::HBox); |
189 | $hbox->add (new CFClient::UI::CheckBox expand => 1, state => $CFG->{bgm_enable}, connect_changed => sub { |
190 | $hbox->add (new CFClient::UI::CheckBox expand => 1, state => $CFG->{bgm_enable}, connect_changed => sub { |
190 | $CFG->{bgm_enable} = $_[1]; |
191 | $CFG->{bgm_enable} = $_[1]; |
191 | }); |
192 | }); |
192 | $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 128, 1], connect_changed => sub { |
193 | $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 128, 1], connect_changed => sub { |
… | |
… | |
279 | |
280 | |
280 | sub server_setup { |
281 | sub server_setup { |
281 | my $dialog = new CFClient::UI::FancyFrame |
282 | my $dialog = new CFClient::UI::FancyFrame |
282 | child => (my $vbox = new CFClient::UI::VBox); |
283 | child => (my $vbox = new CFClient::UI::VBox); |
283 | |
284 | |
284 | $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); |
285 | $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Server Setup"); |
285 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
286 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
286 | $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host:Port"); |
287 | $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); |
287 | |
288 | |
288 | { |
289 | { |
289 | $table->add (1, 2, my $vbox = new CFClient::UI::VBox); |
290 | $table->add (1, 2, my $vbox = new CFClient::UI::VBox); |
290 | |
291 | |
291 | $vbox->add (my $HOST = new CFClient::UI::Entry text => $CFG->{host}, connect_changed => sub { |
292 | $vbox->add (my $HOST = new CFClient::UI::Entry expand => 1, text => $CFG->{host}, connect_changed => sub { |
292 | my ($self, $value) = @_; |
293 | my ($self, $value) = @_; |
293 | $CFG->{host} = $value; |
294 | $CFG->{host} = $value; |
294 | }); |
295 | }); |
295 | |
296 | |
296 | $METASERVER = metaserver_dialog; |
297 | $METASERVER = metaserver_dialog; |
297 | |
298 | |
298 | $vbox->add (new CFClient::UI::Flopper text => "Metaserver", other => $METASERVER, connect_open => sub { |
299 | $vbox->add (new CFClient::UI::Flopper expand => 1, text => "Metaserver", other => $METASERVER, connect_open => sub { |
299 | update_metaserver $HOST; |
300 | update_metaserver $HOST; |
300 | }); |
301 | }); |
301 | } |
302 | } |
302 | |
303 | |
303 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username"); |
304 | $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username"); |
304 | $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { |
305 | $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { |
305 | my ($self, $value) = @_; |
306 | my ($self, $value) = @_; |
306 | $CFG->{user} = $value; |
307 | $CFG->{user} = $value; |
307 | }); |
308 | }); |
308 | |
309 | |
309 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password"); |
310 | $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password"); |
310 | $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { |
311 | $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { |
311 | my ($self, $value) = @_; |
312 | my ($self, $value) = @_; |
312 | $CFG->{password} = $value; |
313 | $CFG->{password} = $value; |
313 | }); |
314 | }); |
314 | |
315 | |
315 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Def. say cmd"); |
316 | $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); |
316 | $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { |
317 | $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { |
317 | my ($self, $value) = @_; |
318 | my ($self, $value) = @_; |
318 | $CFG->{say_command} = $value; |
319 | $CFG->{say_command} = $value; |
319 | }); |
320 | }); |
320 | |
321 | |
321 | $table->add (0, 7, new CFClient::UI::Label align => 1, text => "Map Size"); |
322 | $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); |
322 | $table->add (1, 7, new CFClient::UI::Slider |
323 | $table->add (1, 7, new CFClient::UI::Slider |
323 | req_w => 100, |
324 | req_w => 100, |
324 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
325 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
325 | connect_changed => sub { |
326 | connect_changed => sub { |
326 | my ($self, $value) = @_; |
327 | my ($self, $value) = @_; |
… | |
… | |
448 | fontsize => 0.8, |
449 | fontsize => 0.8, |
449 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
450 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
450 | $ALT_ENTER_MESSAGE->show; |
451 | $ALT_ENTER_MESSAGE->show; |
451 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); |
452 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); |
452 | |
453 | |
453 | $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget); |
454 | $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::MapWidget); |
454 | $MAPWIDGET->focus_in; |
455 | $MAPWIDGET->focus_in; |
455 | $MAPWIDGET->connect (activate_console => sub { |
456 | $MAPWIDGET->connect (activate_console => sub { |
456 | my ($mapwidget, $preset) = @_; |
457 | my ($mapwidget, $preset) = @_; |
457 | |
458 | |
458 | if ($CONSOLE) { |
459 | if ($CONSOLE) { |