… | |
… | |
18 | use CFClient; |
18 | use CFClient; |
19 | use CFClient::UI; |
19 | use CFClient::UI; |
20 | |
20 | |
21 | our $VERSION = '0.1'; |
21 | our $VERSION = '0.1'; |
22 | |
22 | |
23 | my $MAX_FPS = 500; |
23 | my $MAX_FPS = 60; |
24 | my $MIN_FPS = 5; # unused as of yet |
24 | my $MIN_FPS = 5; # unused as of yet |
25 | |
25 | |
26 | our $FACECACHE; |
26 | our $FACECACHE; |
27 | |
27 | |
28 | our $LAST_REFRESH; |
28 | our $LAST_REFRESH; |
… | |
… | |
46 | our %SDL_CB; |
46 | our %SDL_CB; |
47 | |
47 | |
48 | our $ALT_ENTER_MESSAGE; |
48 | our $ALT_ENTER_MESSAGE; |
49 | our $STATUS_LINE; |
49 | our $STATUS_LINE; |
50 | our $DEBUG_STATUS; |
50 | our $DEBUG_STATUS; |
|
|
51 | our $BUTTONBAR; |
51 | |
52 | |
52 | sub status { |
53 | sub status { |
53 | $STATUS_LINE->set_text ($_[0]); |
54 | $STATUS_LINE->set_text ($_[0]); |
54 | my ($w, $h) = $STATUS_LINE->size_request; |
55 | my ($w, $h) = $STATUS_LINE->size_request; |
55 | $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); |
56 | $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); |
… | |
… | |
117 | my ($self, $value) = @_; |
118 | my ($self, $value) = @_; |
118 | $CFG->{fast} = $value; |
119 | $CFG->{fast} = $value; |
119 | }); |
120 | }); |
120 | |
121 | |
121 | $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Fog of War"); |
122 | $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Fog of War"); |
|
|
123 | $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub { |
|
|
124 | my ($self, $value) = @_; |
|
|
125 | $CFG->{fow_enable} = $value; |
|
|
126 | }); |
|
|
127 | |
|
|
128 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "FoW Intensity"); |
122 | $table->add (1, 3, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub { |
129 | $table->add (1, 4, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub { |
123 | my ($self, $value) = @_; |
130 | my ($self, $value) = @_; |
124 | $CFG->{fow_intensity} = $value; |
131 | $CFG->{fow_intensity} = $value; |
125 | }); |
132 | }); |
126 | |
133 | |
127 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Smooth FoW"); |
134 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth"); |
128 | $table->add (1, 4, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
135 | $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
129 | my ($self, $value) = @_; |
136 | my ($self, $value) = @_; |
130 | $CFG->{fow_smooth} = $value; |
137 | $CFG->{fow_smooth} = $value; |
131 | }); |
138 | }); |
132 | |
139 | |
133 | $table->add (1, 5, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
140 | $table->add (1, 6, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
134 | destroy_screen (); |
141 | destroy_screen (); |
135 | init_screen (); |
142 | init_screen (); |
136 | }); |
143 | }); |
137 | |
144 | |
138 | $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); |
145 | $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); |
… | |
… | |
168 | |
175 | |
169 | $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub { |
176 | $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub { |
170 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
177 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
171 | status "Configuration Saved"; |
178 | status "Configuration Saved"; |
172 | }); |
179 | }); |
173 | $CFClient::UI::TOPLEVEL->add ($dialog); |
180 | |
|
|
181 | $dialog |
174 | } |
182 | } |
175 | |
183 | |
176 | sub sdl_init { |
184 | sub sdl_init { |
177 | SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE |
185 | SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE |
178 | and die "SDL::Init failed!\n"; |
186 | and die "SDL::Init failed!\n"; |
… | |
… | |
232 | y => $HEIGHT * 49 / 50, |
240 | y => $HEIGHT * 49 / 50, |
233 | height => $HEIGHT / 50, |
241 | height => $HEIGHT / 50, |
234 | text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
242 | text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
235 | $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE); |
243 | $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE); |
236 | |
244 | |
237 | $MAPWIDGET = new CFClient::UI::MapWidget; |
|
|
238 | $CFClient::UI::TOPLEVEL->add ($MAPWIDGET); |
245 | $CFClient::UI::TOPLEVEL->add ($MAPWIDGET = new CFClient::UI::MapWidget); |
239 | $MAPWIDGET->focus_in; |
246 | $MAPWIDGET->focus_in; |
240 | |
247 | |
241 | config_dialog; |
248 | $CFClient::UI::TOPLEVEL->add ($BUTTONBAR = new CFClient::UI::HBox); |
|
|
249 | |
|
|
250 | $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Setup", other => config_dialog, state => 1); |
242 | } |
251 | } |
243 | |
252 | |
244 | sub destroy_screen { |
253 | sub destroy_screen { |
245 | $CFClient::UI::TOPLEVEL->{children} = []; |
254 | $CFClient::UI::TOPLEVEL->{children} = []; |
246 | undef $SDL_ACTIVE; |
255 | undef $SDL_ACTIVE; |
… | |
… | |
258 | |
267 | |
259 | sub force_refresh { |
268 | sub force_refresh { |
260 | $fps = $fps * 0.95 + 1 / ($NOW - $LAST_REFRESH) * 0.05; |
269 | $fps = $fps * 0.95 + 1 / ($NOW - $LAST_REFRESH) * 0.05; |
261 | debug sprintf "%3.2f", $fps; |
270 | debug sprintf "%3.2f", $fps; |
262 | |
271 | |
263 | # $want_refresh = 0;#d# |
272 | $want_refresh = 0; |
264 | $can_refresh = 0; |
273 | $can_refresh = 0; |
265 | |
274 | |
266 | glViewport 0, 0, $WIDTH, $HEIGHT; |
275 | glViewport 0, 0, $WIDTH, $HEIGHT; |
267 | |
276 | |
268 | glMatrixMode GL_PROJECTION; |
277 | glMatrixMode GL_PROJECTION; |
… | |
… | |
411 | |
420 | |
412 | my %DEF_CFG = ( |
421 | my %DEF_CFG = ( |
413 | width => 640, |
422 | width => 640, |
414 | height => 480, |
423 | height => 480, |
415 | fast => 0, |
424 | fast => 0, |
|
|
425 | fow_enable => 1, |
416 | fow_intensity => 0.45, |
426 | fow_intensity => 0.45, |
417 | fow_smooth => 0, |
427 | fow_smooth => 0, |
418 | fullscreen => 0, |
428 | fullscreen => 0, |
419 | sdl_mode => 0, |
429 | sdl_mode => 0, |
420 | mapsize => 100, |
430 | mapsize => 100, |