… | |
… | |
110 | } |
110 | } |
111 | |
111 | |
112 | sub client_setup { |
112 | sub client_setup { |
113 | my $dialog = new CFClient::UI::FancyFrame |
113 | my $dialog = new CFClient::UI::FancyFrame |
114 | child => (my $vbox = new CFClient::UI::VBox); |
114 | child => (my $vbox = new CFClient::UI::VBox); |
115 | $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); |
115 | $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Client Setup"); |
116 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
116 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
117 | |
117 | |
118 | $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode"); |
118 | $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode"); |
119 | $table->add (1, 0, my $hbox = new CFClient::UI::HBox); |
119 | $table->add (1, 0, my $hbox = new CFClient::UI::HBox); |
120 | |
120 | |
121 | $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]); |
121 | $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]); |
122 | $hbox->add (my $mode_label = new CFClient::UI::Label height => $FONTSIZE * 0.8); |
122 | $hbox->add (my $mode_label = new CFClient::UI::Label valign => 0, height => 0.8); |
123 | |
123 | |
124 | $mode_slider->connect (changed => sub { |
124 | $mode_slider->connect (changed => sub { |
125 | my ($self, $value) = @_; |
125 | my ($self, $value) = @_; |
126 | |
126 | |
127 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
127 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
128 | $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); |
128 | $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); |
129 | }); |
129 | }); |
130 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
130 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
131 | |
131 | |
132 | $table->add (0, 1, new CFClient::UI::Label align => 1, text => "Fullscreen"); |
132 | $table->add (0, 1, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen"); |
133 | $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub { |
133 | $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub { |
134 | my ($self, $value) = @_; |
134 | my ($self, $value) = @_; |
135 | $CFG->{fullscreen} = $value; |
135 | $CFG->{fullscreen} = $value; |
136 | }); |
136 | }); |
137 | |
137 | |
138 | $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Fast & Ugly"); |
138 | $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); |
139 | $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub { |
139 | $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub { |
140 | my ($self, $value) = @_; |
140 | my ($self, $value) = @_; |
141 | $CFG->{fast} = $value; |
141 | $CFG->{fast} = $value; |
142 | }); |
142 | }); |
143 | |
143 | |
144 | $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Fog of War"); |
144 | $table->add (0, 3, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War"); |
145 | $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub { |
145 | $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub { |
146 | my ($self, $value) = @_; |
146 | my ($self, $value) = @_; |
147 | $CFG->{fow_enable} = $value; |
147 | $CFG->{fow_enable} = $value; |
148 | }); |
148 | }); |
149 | |
149 | |
150 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "FoW Intensity"); |
150 | $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity"); |
151 | $table->add (1, 4, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub { |
151 | $table->add (1, 4, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub { |
152 | my ($self, $value) = @_; |
152 | my ($self, $value) = @_; |
153 | $CFG->{fow_intensity} = $value; |
153 | $CFG->{fow_intensity} = $value; |
154 | }); |
154 | }); |
155 | |
155 | |
156 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth"); |
156 | $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Smooth"); |
157 | $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
157 | $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
158 | my ($self, $value) = @_; |
158 | my ($self, $value) = @_; |
159 | $CFG->{fow_smooth} = $value; |
159 | $CFG->{fow_smooth} = $value; |
160 | status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; |
160 | status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; |
161 | }); |
161 | }); |
162 | |
162 | |
163 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Log Fontsize"); |
163 | $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Log Fontsize"); |
|
|
164 | $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{gui_fontsize}, 0.5, 1.5, 0.1], connect_changed => sub { |
|
|
165 | $CFG->{gui_fontsize} = 0.1 * int $_[0] * 10; |
|
|
166 | # $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
|
|
167 | }); |
|
|
168 | |
|
|
169 | $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Log Fontsize"); |
164 | $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 8, 30, 1], connect_changed => sub { |
170 | $table->add (1, 7, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 0.7, 1.5, 0.1], connect_changed => sub { |
165 | my ($self, $value) = @_; |
|
|
166 | $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = int $value); |
171 | $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[0] * 10); |
167 | }); |
172 | }); |
168 | |
173 | |
169 | $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
174 | $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
170 | video_shutdown (); |
175 | video_shutdown (); |
171 | video_init (); |
176 | video_init (); |
172 | }); |
177 | }); |
173 | |
178 | |
174 | $table->add (0, 8, new CFClient::UI::Label align => 1, text => "Sound"); |
179 | $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable"); |
175 | $table->add (1, 8, new CFClient::UI::CheckBox state => $CFG->{audio_enable}, connect_changed => sub { |
180 | $table->add (1, 9, new CFClient::UI::CheckBox state => $CFG->{audio_enable}, connect_changed => sub { |
176 | my ($self, $value) = @_; |
|
|
177 | $CFG->{audio_enable} = $value; |
181 | $CFG->{audio_enable} = $_[1]; |
|
|
182 | }); |
|
|
183 | # $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 | # $CFG->{effects_volume} = $_[1]; |
178 | }); |
186 | # }); |
179 | $table->add (0, 9, new CFClient::UI::Label align => 1, text => "Bg. Music"); |
187 | $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Bg. Music"); |
|
|
188 | $table->add (1, 10, my $hbox = new CFClient::UI::HBox); |
180 | $table->add (1, 9, new CFClient::UI::CheckBox state => $CFG->{bgm_enable}, connect_changed => sub { |
189 | $hbox->add (new CFClient::UI::CheckBox expand => 1, state => $CFG->{bgm_enable}, connect_changed => sub { |
181 | my ($self, $value) = @_; |
|
|
182 | $CFG->{bgm_enable} = $value; |
190 | $CFG->{bgm_enable} = $_[1]; |
183 | }); |
191 | }); |
|
|
192 | $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 128, 1], connect_changed => sub { |
|
|
193 | $CFG->{bgm_volume} = $_[1]; |
|
|
194 | $SDL_MIXER->music_volume ($_[1]); |
|
|
195 | }); |
|
|
196 | |
184 | $table->add (1, 10, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
197 | $table->add (1, 11, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
185 | audio_shutdown (); |
198 | audio_shutdown (); |
186 | audio_init (); |
199 | audio_init (); |
187 | }); |
200 | }); |
188 | |
201 | |
189 | $dialog |
202 | $dialog |
… | |
… | |
255 | $HOST->set_text ($CFG->{host} = $host); |
268 | $HOST->set_text ($CFG->{host} = $host); |
256 | }), |
269 | }), |
257 | (new CFClient::UI::Empty expand => 1), |
270 | (new CFClient::UI::Empty expand => 1), |
258 | ]); |
271 | ]); |
259 | |
272 | |
260 | $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => $FONTSIZE * 0.8) |
273 | $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => 0.8) |
261 | for 0 .. $#$m; |
274 | for 0 .. $#$m; |
262 | } |
275 | } |
263 | } |
276 | } |
264 | }); |
277 | }); |
265 | } |
278 | } |
… | |
… | |
416 | |
429 | |
417 | $LAST_REFRESH = time - 0.01; |
430 | $LAST_REFRESH = time - 0.01; |
418 | |
431 | |
419 | CFClient::gl_init; |
432 | CFClient::gl_init; |
420 | |
433 | |
421 | $FONTSIZE = int $HEIGHT / 40; |
434 | $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
422 | |
435 | |
423 | ############################################################################# |
436 | ############################################################################# |
424 | |
437 | |
425 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; |
438 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; |
426 | $CFClient::UI::ROOT->add ($DEBUG_STATUS); |
439 | $DEBUG_STATUS->show; |
427 | |
440 | |
428 | $STATUS_LINE = new CFClient::UI::Label |
441 | $STATUS_LINE = new CFClient::UI::Label |
429 | padding => 0, |
442 | padding => 0, |
430 | y => $HEIGHT * 44 / 45 - $FONTSIZE; |
443 | y => $HEIGHT - $FONTSIZE * 1.8; |
431 | $CFClient::UI::ROOT->add ($STATUS_LINE); |
444 | $STATUS_LINE->show; |
432 | |
445 | |
433 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
446 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
434 | padding => 0, |
447 | padding => 0, |
435 | y => $HEIGHT * 44 / 45, |
|
|
436 | fontsize => $HEIGHT / 45, |
448 | fontsize => 0.8, |
437 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
449 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
438 | $CFClient::UI::ROOT->add ($ALT_ENTER_MESSAGE); |
450 | $ALT_ENTER_MESSAGE->show; |
|
|
451 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); |
439 | |
452 | |
440 | $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget); |
453 | $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget); |
441 | $MAPWIDGET->focus_in; |
454 | $MAPWIDGET->focus_in; |
442 | $MAPWIDGET->connect (activate_console => sub { |
455 | $MAPWIDGET->connect (activate_console => sub { |
443 | my ($mapwidget, $preset) = @_; |
456 | my ($mapwidget, $preset) = @_; |
… | |
… | |
493 | |
506 | |
494 | # TODO: hack, do play loop and mood music |
507 | # TODO: hack, do play loop and mood music |
495 | if ($CFG->{bgm_enable}) { |
508 | if ($CFG->{bgm_enable}) { |
496 | $bgmusic = new SDL::Music CFClient::find_rcfile "music/game3.ogg"; |
509 | $bgmusic = new SDL::Music CFClient::find_rcfile "music/game3.ogg"; |
497 | $SDL_MIXER->play_music ($bgmusic, -1); |
510 | $SDL_MIXER->play_music ($bgmusic, -1); |
|
|
511 | $SDL_MIXER->music_volume ($CFG->{bgm_volume}); |
498 | } |
512 | } |
499 | |
513 | |
500 | while (<$fh>) { |
514 | while (<$fh>) { |
501 | next if /^\s*#/; |
515 | next if /^\s*#/; |
502 | next if /^\s*$/; |
516 | next if /^\s*$/; |
… | |
… | |
867 | fullscreen => 0, |
881 | fullscreen => 0, |
868 | fast => 0, |
882 | fast => 0, |
869 | fow_enable => 1, |
883 | fow_enable => 1, |
870 | fow_intensity => 0.45, |
884 | fow_intensity => 0.45, |
871 | fow_smooth => 0, |
885 | fow_smooth => 0, |
|
|
886 | gui_fontsize => 1, |
872 | log_fontsize => 14, |
887 | log_fontsize => 14, |
873 | mapsize => 100, |
888 | mapsize => 100, |
874 | host => "crossfire.schmorp.de", |
889 | host => "crossfire.schmorp.de", |
875 | say_command => 'say', |
890 | say_command => 'say', |
876 | audio_enable => 1, |
891 | audio_enable => 1, |
877 | bgm_enable => 1, |
892 | bgm_enable => 1, |
|
|
893 | bgm_volume => 64, |
878 | ); |
894 | ); |
879 | |
895 | |
880 | while (my ($k, $v) = each %DEF_CFG) { |
896 | while (my ($k, $v) = each %DEF_CFG) { |
881 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
897 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
882 | } |
898 | } |