… | |
… | |
113 | our $CONN; |
113 | our $CONN; |
114 | our $PROFILE; # current profile |
114 | our $PROFILE; # current profile |
115 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
115 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
116 | |
116 | |
117 | our $WANT_REFRESH; |
117 | our $WANT_REFRESH; |
118 | our $CAN_REFRESH; |
|
|
119 | |
118 | |
120 | our @SDL_MODES; |
119 | our @SDL_MODES; |
121 | our $WIDTH; |
120 | our $WIDTH; |
122 | our $HEIGHT; |
121 | our $HEIGHT; |
123 | our $FULLSCREEN; |
122 | our $FULLSCREEN; |
… | |
… | |
127 | our $FONT_FIXED; |
126 | our $FONT_FIXED; |
128 | |
127 | |
129 | our $MAP; |
128 | our $MAP; |
130 | our $MAPMAP; |
129 | our $MAPMAP; |
131 | our $MAPWIDGET; |
130 | our $MAPWIDGET; |
|
|
131 | our $COMPLETER; |
132 | our $BUTTONBAR; |
132 | our $BUTTONBAR; |
133 | our $METASERVER; |
133 | our $METASERVER; |
134 | our $LOGIN_BUTTON; |
134 | our $LOGIN_BUTTON; |
135 | our $QUIT_DIALOG; |
135 | our $QUIT_DIALOG; |
136 | our $HOST_ENTRY; |
136 | our $HOST_ENTRY; |
… | |
… | |
147 | our $PL_WINDOW; |
147 | our $PL_WINDOW; |
148 | |
148 | |
149 | our $MUSIC_PLAYING_WIDGET; |
149 | our $MUSIC_PLAYING_WIDGET; |
150 | our $LICENSE_WIDGET; |
150 | our $LICENSE_WIDGET; |
151 | |
151 | |
|
|
152 | our $PICKUP_PAGE; |
152 | our $INVENTORY_PAGE; |
153 | our $INVENTORY_PAGE; |
153 | our $STATS_PAGE; |
154 | our $STATS_PAGE; |
154 | our $SKILL_PAGE; |
155 | our $SKILL_PAGE; |
155 | our $SPELL_PAGE; |
156 | our $SPELL_PAGE; |
156 | our $SPELL_LIST; |
157 | our $SPELL_LIST; |
… | |
… | |
168 | our $STATUSBOX; |
169 | our $STATUSBOX; |
169 | our $DEBUG_STATUS; |
170 | our $DEBUG_STATUS; |
170 | |
171 | |
171 | our $INV; |
172 | our $INV; |
172 | our $INVR; |
173 | our $INVR; |
173 | our $INV_RIGHT_HB; |
174 | our $INVR_HB; |
174 | |
|
|
175 | our $PICKUP_CFG; |
|
|
176 | |
175 | |
177 | ############################################################################# |
176 | ############################################################################# |
178 | |
177 | |
179 | sub status { |
178 | sub status { |
180 | $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
179 | $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
… | |
… | |
226 | for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) { |
225 | for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) { |
227 | my (undef, $dx, $dy, $vol) = @$_; |
226 | my (undef, $dx, $dy, $vol) = @$_; |
228 | |
227 | |
229 | my $channel = CFPlus::Channel::find; |
228 | my $channel = CFPlus::Channel::find; |
230 | $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255); |
229 | $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255); |
231 | $dx = $dx / 10 * 255; |
|
|
232 | $channel->set_panning (255 - $dx, 255 + $dx); |
|
|
233 | |
|
|
234 | # my $angle = $dx ? : $dx < 0 ? |
|
|
235 | # my $distance = -$vol; |
|
|
236 | # $channel->set_position ($angle, $distance); |
230 | $channel->set_position_r ($dx, $dy, 20); |
237 | |
|
|
238 | $chunk->play ($channel); |
231 | $chunk->play ($channel); |
239 | } |
232 | } |
240 | } else { |
233 | } else { |
241 | # sound_meta not set means data is in flight either way |
234 | # sound_meta not set means data is in flight either way |
242 | my $meta = $CONN->{sound_meta}{$face} |
235 | my $meta = $CONN->{face}[$face] |
243 | or return; |
236 | or return; |
244 | |
237 | |
|
|
238 | $meta->{data} |
|
|
239 | or return; |
|
|
240 | |
245 | # if its a jingle, play it as ambient music |
241 | # if its a jingle, play it as ambient music |
246 | if ($meta->{meta}{jingle}) { |
242 | if ($meta->{data}{jingle}) { |
247 | if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue |
243 | if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue |
248 | push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue |
244 | push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue |
249 | &audio_music_push ($face); |
245 | &audio_music_push ($face); |
250 | } |
246 | } |
251 | } else { |
247 | } else { |
252 | # fetch from database |
248 | # fetch from database |
253 | CFPlus::DB::get res_data => $meta->{name}, sub { |
249 | CFPlus::DB::get res_data => $meta->{name}, sub { |
254 | my $rwops = new CFPlus::RW $_[0]; |
250 | my $rwops = new CFPlus::RW $_[0]; |
255 | my $chunk = new CFPlus::MixChunk $rwops |
251 | my $chunk = new CFPlus::MixChunk $rwops |
256 | or Carp::confess "sound face " . (JSON::XS::to_json $meta) . " unloadable: " . CFPlus::Mix_GetError; |
252 | or Carp::confess "sound face " . (JSON::XS::to_json $meta) . " unloadable: " . CFPlus::Mix_GetError; |
257 | $chunk->volume (($meta->{meta}{volume} || 1) * 128); |
253 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
258 | $AUDIO_CHUNK{$face} = $chunk; |
254 | $AUDIO_CHUNK{$face} = $chunk; |
259 | |
255 | |
260 | audio_sound_push ($face); |
256 | audio_sound_push ($face); |
261 | }; |
257 | }; |
262 | } |
258 | } |
… | |
… | |
270 | or return; |
266 | or return; |
271 | $CFG->{effects_enable} |
267 | $CFG->{effects_enable} |
272 | or return; |
268 | or return; |
273 | |
269 | |
274 | my $queue = $AUDIO_PLAY{$face} ||= []; |
270 | my $queue = $AUDIO_PLAY{$face} ||= []; |
275 | push @$queue, [Event::time + 0.2, $dx, $dy, $vol]; # delay sound by max. 0.2s |
271 | push @$queue, [Event::time + 0.6, $dx, $dy, $vol]; # do not play sound for outdated events |
276 | audio_sound_push $face |
272 | audio_sound_push $face |
277 | unless @$queue > 1; |
273 | unless @$queue > 1; |
278 | } |
274 | } |
279 | |
275 | |
280 | sub audio_music_set_meta { |
276 | sub audio_music_set_meta { |
281 | my ($meta) = @_; |
277 | my ($meta) = @_; |
282 | |
278 | |
283 | $MUSIC_PLAYING_META = $meta; |
279 | $MUSIC_PLAYING_META = $meta; |
284 | $MUSIC_PLAYING_WIDGET->set_markup ( |
280 | $MUSIC_PLAYING_WIDGET->set_markup ( |
285 | "<b>Name</b>: " . (CFPlus::asxml $meta->{meta}{name}) . "\n" |
281 | "<b>Name</b>: " . (CFPlus::asxml $meta->{data}{name}) . "\n" |
286 | . "<b>Author</b>: " . (CFPlus::asxml $meta->{meta}{author}) . "\n" |
282 | . "<b>Author</b>: " . (CFPlus::asxml $meta->{data}{author}) . "\n" |
287 | . "<b>Source</b>: " . (CFPlus::asxml $meta->{meta}{source}) . "\n" |
283 | . "<b>Source</b>: " . (CFPlus::asxml $meta->{data}{source}) . "\n" |
288 | . "<b>License</b>: " . (CFPlus::asxml $meta->{meta}{license}) |
284 | . "<b>License</b>: " . (CFPlus::asxml $meta->{data}{license}) |
289 | ); |
285 | ); |
290 | } |
286 | } |
291 | |
287 | |
292 | sub audio_music_update_volume { |
288 | sub audio_music_update_volume { |
293 | return unless $MUSIC_PLAYING_META; |
289 | return unless $MUSIC_PLAYING_META; |
294 | my $volume = $MUSIC_PLAYING_META->{meta}{volume} || 1; |
290 | my $volume = $MUSIC_PLAYING_META->{data}{volume} || 1; |
295 | my $base = $MUSIC_PLAYING_META->{meta}{jingle} ? 1 : $CFG->{bgm_volume}; |
291 | my $base = $MUSIC_PLAYING_META->{data}{jingle} ? 1 : $CFG->{bgm_volume}; |
296 | CFPlus::MixMusic::volume $base * $volume * 128; |
292 | CFPlus::MixMusic::volume $base * $volume * 128; |
297 | } |
293 | } |
298 | |
294 | |
299 | sub audio_music_start { |
295 | sub audio_music_start { |
300 | my $meta = $MUSIC_PLAYING_META; |
296 | my $meta = $MUSIC_PLAYING_META; |
… | |
… | |
343 | $fade_out = 333; |
339 | $fade_out = 333; |
344 | } else { |
340 | } else { |
345 | return unless $CFG->{bgm_enable}; |
341 | return unless $CFG->{bgm_enable}; |
346 | |
342 | |
347 | my @have = |
343 | my @have = |
348 | grep $_, |
344 | grep $_ && $_->{data}, |
349 | map $CONN->{music_meta}{$_}, |
345 | map $CONN->{face}[$_], |
350 | @$MUSIC_WANT; |
346 | @$MUSIC_WANT; |
351 | |
347 | |
352 | @MUSIC_HAVE = @have |
348 | @MUSIC_HAVE = @have |
353 | if @have; |
349 | if @have; |
354 | |
350 | |
… | |
… | |
776 | state => $CFG->{fullscreen}, |
772 | state => $CFG->{fullscreen}, |
777 | tooltip => "Bring the client into fullscreen mode.", |
773 | tooltip => "Bring the client into fullscreen mode.", |
778 | on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } |
774 | on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } |
779 | ); |
775 | ); |
780 | |
776 | |
|
|
777 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Force OpenGL 1.1"); |
|
|
778 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
|
|
779 | state => $CFG->{force_opengl11}, |
|
|
780 | tooltip => "Limit CFPlus to use OpenGL 1.1 features only. This will normally result in " |
|
|
781 | . "higher memory usage and slower performance. It will, however, help tremendously on " |
|
|
782 | . "cards that claim to support a feature but fall back to software rendering. " |
|
|
783 | . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, " |
|
|
784 | . "but cards and drivers from other vendors (ATI) are often just as bad. <b>If you " |
|
|
785 | . "experience extremely low framerates and your card should do better, try this option.</b>", |
|
|
786 | on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 } |
|
|
787 | ); |
|
|
788 | |
|
|
789 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Compress Textures"); |
|
|
790 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
|
|
791 | state => $CFG->{texture_compression}, |
|
|
792 | tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " |
|
|
793 | . "will save a lot of memory and increase performance. The compression algorithm " |
|
|
794 | . "can differ form card to card, so your mileage may vary. This setting is ignored in " |
|
|
795 | . "forced OpenGL 1.1 mode.", |
|
|
796 | on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } |
|
|
797 | ); |
|
|
798 | |
781 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); |
799 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); |
782 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
800 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
783 | state => $CFG->{fast}, |
801 | state => $CFG->{fast}, |
784 | tooltip => "Lower the visual quality considerably to speed up rendering.", |
802 | tooltip => "Lower the visual quality considerably to speed up rendering.", |
785 | on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } |
803 | on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } |
… | |
… | |
811 | |
829 | |
812 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Smoothing"); |
830 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Smoothing"); |
813 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
831 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
814 | state => $CFG->{map_smoothing}, |
832 | state => $CFG->{map_smoothing}, |
815 | tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. " |
833 | tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. " |
816 | . "This increases load on the graphics subsystem and works only with 2.x servers. " |
834 | . "This increases load on the graphics subsystem and works only with TRT servers. " |
817 | . "Changes take effect at next connection only.", |
835 | . "Changes take effect at next login only.", |
818 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } |
836 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } |
819 | ); |
837 | ); |
820 | |
838 | |
821 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War"); |
839 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War"); |
822 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
840 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
… | |
… | |
833 | ); |
851 | ); |
834 | |
852 | |
835 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); |
853 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); |
836 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
854 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
837 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
855 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
838 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.", |
856 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant, " |
|
|
857 | . "but you still need to press apply to correctly re-layout the widget.", |
839 | on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
858 | on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
840 | ); |
859 | ); |
841 | |
860 | |
842 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
861 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
843 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
862 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
… | |
… | |
904 | expand => 1, state => $CFG->{bgm_enable}, |
923 | expand => 1, state => $CFG->{bgm_enable}, |
905 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
924 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
906 | on_changed => sub { |
925 | on_changed => sub { |
907 | $CFG->{bgm_enable} = $_[1]; |
926 | $CFG->{bgm_enable} = $_[1]; |
908 | $CONN->update_fx_want if $CONN; |
927 | $CONN->update_fx_want if $CONN; |
|
|
928 | audio_music_push; |
909 | 0 |
929 | 0 |
910 | } |
930 | } |
911 | ); |
931 | ); |
912 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
932 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
913 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
933 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
… | |
… | |
966 | $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health"); |
986 | $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health"); |
967 | $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana"); |
987 | $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana"); |
968 | $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace"); |
988 | $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace"); |
969 | $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food"); |
989 | $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food"); |
970 | |
990 | |
971 | $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); |
991 | $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); |
|
|
992 | $vbox->add (my $prg = new CFPlus::UI::ExperienceProgress); |
|
|
993 | $vbox->add (my $sklprg = new CFPlus::UI::ExperienceProgress); |
972 | $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); |
994 | $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); |
973 | |
995 | |
974 | $GAUGES = { |
996 | $GAUGES = { |
|
|
997 | exp => $exp, prg => $prg, sklprg => $sklprg, |
975 | exp => $exp, win => $win, range => $rng, |
998 | win => $win, range => $rng, |
976 | food => $fg, mana => $mg, hp => $hg, grace => $gg |
999 | hp => $hg, mana => $mg, grace => $gg, food => $fg, |
977 | }; |
1000 | }; |
978 | |
1001 | |
979 | &set_gauge_window_fontsize; |
1002 | &set_gauge_window_fontsize; |
980 | |
1003 | |
981 | $win |
1004 | $win |
… | |
… | |
1182 | $r |
1205 | $r |
1183 | } |
1206 | } |
1184 | |
1207 | |
1185 | sub skill_window { |
1208 | sub skill_window { |
1186 | my $sw = new CFPlus::UI::ScrolledWindow (expand => 1); |
1209 | my $sw = new CFPlus::UI::ScrolledWindow (expand => 1); |
|
|
1210 | |
1187 | $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, 0, 0, 1]); |
1211 | $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, .1, 0, 0, 1, .1]); |
|
|
1212 | |
1188 | $sw |
1213 | $sw |
1189 | } |
1214 | } |
1190 | |
1215 | |
1191 | sub formsep($) { |
1216 | sub formsep($) { |
1192 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
1217 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
… | |
… | |
1604 | $sw1->add ($INV = new CFPlus::UI::Inventory); |
1629 | $sw1->add ($INV = new CFPlus::UI::Inventory); |
1605 | $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}}); |
1630 | $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}}); |
1606 | |
1631 | |
1607 | $hb->add (my $vb2 = new CFPlus::UI::VBox); |
1632 | $hb->add (my $vb2 = new CFPlus::UI::VBox); |
1608 | |
1633 | |
1609 | $vb2->add ($INV_RIGHT_HB = new CFPlus::UI::HBox); |
1634 | $vb2->add ($INVR_HB = new CFPlus::UI::HBox); |
1610 | |
1635 | |
1611 | $vb2->add (my $sw2 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1636 | $vb2->add (my $sw2 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1612 | $sw2->add ($INVR = new CFPlus::UI::Inventory); |
1637 | $sw2->add ($INVR = new CFPlus::UI::Inventory); |
1613 | |
1638 | |
1614 | # XXX: Call after $INVR = ... because set_opencont sets the items |
1639 | # XXX: Call after $INVR = ... because set_opencont sets the items |
… | |
… | |
1637 | } |
1662 | } |
1638 | |
1663 | |
1639 | sub add_license { |
1664 | sub add_license { |
1640 | my ($meta) = @_; |
1665 | my ($meta) = @_; |
1641 | |
1666 | |
1642 | $meta = $meta->{meta} |
1667 | $meta = $meta->{data} |
1643 | or return; |
1668 | or return; |
1644 | |
1669 | |
1645 | $meta->{license} || $meta->{author} || $meta->{source} |
1670 | $meta->{license} || $meta->{author} || $meta->{source} |
1646 | or return; |
1671 | or return; |
1647 | |
1672 | |
… | |
… | |
1701 | $ntb->add_tab ( |
1726 | $ntb->add_tab ( |
1702 | "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, |
1727 | "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, |
1703 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1728 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1704 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1729 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1705 | ); |
1730 | ); |
1706 | $ntb->add_tab (Pickup => autopickup_setup, |
1731 | $ntb->add_tab (Pickup => $PICKUP_PAGE = autopickup_setup, |
1707 | "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); |
1732 | "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); |
1708 | |
1733 | |
1709 | $ntb->add_tab (Media => media_window, |
1734 | $ntb->add_tab (Media => media_window, |
1710 | "License, Author and Source info for media sent by the server."); |
1735 | "License, Author and Source info for media sent by the server."); |
1711 | |
1736 | |
… | |
… | |
1869 | on_activate => sub { $QUIT_DIALOG->hide; 0 }, |
1894 | on_activate => sub { $QUIT_DIALOG->hide; 0 }, |
1870 | ); |
1895 | ); |
1871 | $hb->add (new CFPlus::UI::Button |
1896 | $hb->add (new CFPlus::UI::Button |
1872 | text => "Quit anyway", |
1897 | text => "Quit anyway", |
1873 | expand => 1, |
1898 | expand => 1, |
1874 | on_activate => sub { exit }, |
1899 | on_activate => sub { Event::unloop_all }, |
1875 | ); |
1900 | ); |
1876 | } |
1901 | } |
1877 | |
1902 | |
1878 | $QUIT_DIALOG->show; |
1903 | $QUIT_DIALOG->show; |
1879 | $QUIT_DIALOG->grab_focus; |
1904 | $QUIT_DIALOG->grab_focus; |
… | |
… | |
1952 | |
1977 | |
1953 | $SDL_ACTIVE = 1; |
1978 | $SDL_ACTIVE = 1; |
1954 | $LAST_REFRESH = time - 0.01; |
1979 | $LAST_REFRESH = time - 0.01; |
1955 | |
1980 | |
1956 | CFPlus::OpenGL::init; |
1981 | CFPlus::OpenGL::init; |
|
|
1982 | CFPlus::Macro::init; |
1957 | |
1983 | |
1958 | $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
1984 | $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
1959 | |
1985 | |
1960 | $CFPlus::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# |
1986 | $CFPlus::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# |
1961 | |
1987 | |
1962 | ############################################################################# |
1988 | ############################################################################# |
1963 | |
1989 | |
1964 | if ($DEBUG_STATUS) { |
1990 | if ($DEBUG_STATUS) { |
1965 | CFPlus::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h; |
1991 | CFPlus::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h; |
1966 | } else { |
1992 | } else { |
1967 | # create the widgets |
1993 | # create/configure the widgets |
|
|
1994 | |
|
|
1995 | $CFPlus::UI::ROOT->connect (key_down => sub { |
|
|
1996 | my (undef, $ev) = @_; |
|
|
1997 | |
|
|
1998 | if (my @macros = CFPlus::Macro::find $ev) { |
|
|
1999 | CFPlus::Macro::execute $_ for @macros; |
|
|
2000 | |
|
|
2001 | return 1; |
|
|
2002 | } |
|
|
2003 | |
|
|
2004 | 0 |
|
|
2005 | }); |
1968 | |
2006 | |
1969 | $DEBUG_STATUS = new CFPlus::UI::Label |
2007 | $DEBUG_STATUS = new CFPlus::UI::Label |
1970 | padding => 0, |
2008 | padding => 0, |
1971 | z => 100, |
2009 | z => 100, |
1972 | force_x => "max", |
2010 | force_x => "max", |
… | |
… | |
2002 | $MESSAGE_WINDOW->activate_console ($preset) |
2040 | $MESSAGE_WINDOW->activate_console ($preset) |
2003 | if $MESSAGE_WINDOW; |
2041 | if $MESSAGE_WINDOW; |
2004 | }); |
2042 | }); |
2005 | $MAPWIDGET->show; |
2043 | $MAPWIDGET->show; |
2006 | $MAPWIDGET->grab_focus; |
2044 | $MAPWIDGET->grab_focus; |
|
|
2045 | |
|
|
2046 | $COMPLETER = new CFPlus::MapWidget::Command:: |
|
|
2047 | command => { }, |
|
|
2048 | tooltip => "#completer_help", |
|
|
2049 | ; |
2007 | |
2050 | |
2008 | $SETUP_DIALOG = new CFPlus::UI::Toplevel |
2051 | $SETUP_DIALOG = new CFPlus::UI::Toplevel |
2009 | title => "Setup", |
2052 | title => "Setup", |
2010 | name => "setup_dialog", |
2053 | name => "setup_dialog", |
2011 | x => 'center', |
2054 | x => 'center', |
… | |
… | |
2073 | tooltip => "Terminates the program", |
2116 | tooltip => "Terminates the program", |
2074 | on_activate => sub { |
2117 | on_activate => sub { |
2075 | if ($CONN) { |
2118 | if ($CONN) { |
2076 | open_quit_dialog; |
2119 | open_quit_dialog; |
2077 | } else { |
2120 | } else { |
2078 | exit; |
2121 | Event::unloop_all; |
2079 | } |
2122 | } |
2080 | 0 |
2123 | 0 |
2081 | }, |
2124 | }, |
2082 | ); |
2125 | ); |
2083 | |
2126 | |
2084 | $BUTTONBAR->show; |
2127 | $BUTTONBAR->show; |
2085 | $SETUP_DIALOG->show; |
2128 | $SETUP_DIALOG->show; |
|
|
2129 | $MESSAGE_WINDOW->show; |
2086 | } |
2130 | } |
2087 | |
2131 | |
2088 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2132 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2089 | } |
2133 | } |
2090 | |
2134 | |
… | |
… | |
2098 | my $animate_timer; |
2142 | my $animate_timer; |
2099 | |
2143 | |
2100 | my $fps = 9; |
2144 | my $fps = 9; |
2101 | |
2145 | |
2102 | sub force_refresh { |
2146 | sub force_refresh { |
|
|
2147 | if ($ENV{CFPLUS_DEBUG} & 4) { |
2103 | $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; |
2148 | $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; |
2104 | debug sprintf "%3.2f", $fps if $ENV{CFPLUS_DEBUG} & 4; |
2149 | debug sprintf "%3.2f", $fps; |
|
|
2150 | } |
2105 | |
2151 | |
2106 | $CFPlus::UI::ROOT->draw; |
2152 | $CFPlus::UI::ROOT->draw; |
2107 | |
2153 | CFPlus::SDL_GL_SwapBuffers; |
2108 | $WANT_REFRESH = 0; |
|
|
2109 | $CAN_REFRESH = 0; |
|
|
2110 | $LAST_REFRESH = $NOW; |
2154 | $LAST_REFRESH = $NOW; |
2111 | |
2155 | $WANT_REFRESH->stop; |
2112 | CFPlus::SDL_GL_SwapBuffers; |
|
|
2113 | } |
2156 | } |
2114 | |
2157 | |
|
|
2158 | $WANT_REFRESH = Event->idle (min => 0.001, max => 0.06, parked => 1, cb => \&force_refresh); |
|
|
2159 | |
2115 | my $refresh_watcher = Event->timer (after => 0, hard => 0, interval => 1 / $MAX_FPS, cb => sub { |
2160 | my $input = Event->timer (after => 0, hard => 0, interval => 1 / 50, cb => sub { |
2116 | $NOW = time; |
2161 | $NOW = time; |
2117 | |
2162 | |
2118 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
2163 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
2119 | for CFPlus::poll_events; |
2164 | for CFPlus::poll_events; |
2120 | |
2165 | |
2121 | if (%animate_object) { |
2166 | if (%animate_object) { |
2122 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2167 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2123 | ++$WANT_REFRESH; |
2168 | $WANT_REFRESH->start; |
2124 | } |
|
|
2125 | |
|
|
2126 | if ($WANT_REFRESH) { |
|
|
2127 | force_refresh; |
|
|
2128 | } else { |
|
|
2129 | $CAN_REFRESH = 1; |
|
|
2130 | } |
2169 | } |
2131 | }); |
2170 | }); |
2132 | |
2171 | |
2133 | sub animation_start { |
2172 | sub animation_start { |
2134 | my ($widget) = @_; |
2173 | my ($widget) = @_; |
… | |
… | |
2140 | delete $animate_object{$widget}; |
2179 | delete $animate_object{$widget}; |
2141 | } |
2180 | } |
2142 | |
2181 | |
2143 | %SDL_CB = ( |
2182 | %SDL_CB = ( |
2144 | CFPlus::SDL_QUIT => sub { |
2183 | CFPlus::SDL_QUIT => sub { |
2145 | exit; |
2184 | Event::unloop_all; |
2146 | }, |
2185 | }, |
2147 | CFPlus::SDL_VIDEORESIZE => sub { |
2186 | CFPlus::SDL_VIDEORESIZE => sub { |
2148 | }, |
2187 | }, |
2149 | CFPlus::SDL_VIDEOEXPOSE => sub { |
2188 | CFPlus::SDL_VIDEOEXPOSE => sub { |
2150 | CFPlus::UI::full_refresh; |
2189 | CFPlus::UI::full_refresh; |
… | |
… | |
2189 | CFPlus::DB::Server::run; |
2228 | CFPlus::DB::Server::run; |
2190 | |
2229 | |
2191 | CFPlus::UI::set_layout ($::CFG->{layout}); |
2230 | CFPlus::UI::set_layout ($::CFG->{layout}); |
2192 | |
2231 | |
2193 | my %DEF_CFG = ( |
2232 | my %DEF_CFG = ( |
2194 | sdl_mode => 0, |
2233 | sdl_mode => 0, |
2195 | fullscreen => 0, |
2234 | fullscreen => 0, |
2196 | fast => 0, |
2235 | fast => 0, |
|
|
2236 | force_opengl11 => undef, |
|
|
2237 | texture_compression => 1, |
2197 | map_scale => 1, |
2238 | map_scale => 1, |
2198 | fow_enable => 1, |
2239 | fow_enable => 1, |
2199 | fow_intensity => 0, |
2240 | fow_intensity => 0, |
2200 | map_smoothing => 1, |
2241 | map_smoothing => 1, |
2201 | gui_fontsize => 1, |
2242 | gui_fontsize => 1, |
2202 | log_fontsize => 0.7, |
2243 | log_fontsize => 0.7, |
2203 | gauge_fontsize => 1, |
2244 | gauge_fontsize => 1, |
2204 | gauge_size => 0.35, |
2245 | gauge_size => 0.35, |
2205 | stat_fontsize => 0.7, |
2246 | stat_fontsize => 0.7, |
2206 | mapsize => 100, |
2247 | mapsize => 100, |
2207 | audio_enable => 1, |
2248 | audio_enable => 1, |
2208 | effects_enable => 1, |
2249 | effects_enable => 1, |
2209 | effects_volume => 1, |
2250 | effects_volume => 1, |
2210 | bgm_enable => 1, |
2251 | bgm_enable => 1, |
2211 | bgm_volume => 0.5, |
2252 | bgm_volume => 0.5, |
2212 | output_sync => 1, |
2253 | output_sync => 1, |
2213 | output_count => 1, |
2254 | output_count => 1, |
2214 | output_rate => "", |
2255 | output_rate => "", |
2215 | pickup => 0, |
2256 | pickup => 0, |
2216 | inv_sort => "mtime", |
2257 | inv_sort => "mtime", |
2217 | default => "profile", # default profile |
2258 | default => "profile", # default profile |
2218 | show_tips => 1, |
2259 | show_tips => 1, |
2219 | logview_max_par => 1000, |
2260 | logview_max_par => 1000, |
2220 | ); |
2261 | ); |
2221 | |
2262 | |
2222 | while (my ($k, $v) = each %DEF_CFG) { |
2263 | while (my ($k, $v) = each %DEF_CFG) { |
2223 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2264 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2224 | } |
2265 | } |
… | |
… | |
2281 | # } |
2322 | # } |
2282 | # my $t2 = Time::HiRes::time; |
2323 | # my $t2 = Time::HiRes::time; |
2283 | # warn $t2-$t1; |
2324 | # warn $t2-$t1; |
2284 | # } |
2325 | # } |
2285 | |
2326 | |
2286 | $startup_done->(); |
|
|
2287 | |
|
|
2288 | video_init; |
2327 | video_init; |
2289 | audio_init; |
2328 | audio_init; |
2290 | } |
2329 | } |
2291 | |
2330 | |
2292 | show_tip_of_the_day if $CFG->{show_tips}; |
2331 | show_tip_of_the_day if $CFG->{show_tips}; |
2293 | |
2332 | |
|
|
2333 | Event->idle (cb => sub { |
|
|
2334 | $_[0]->w->cancel; |
|
|
2335 | $startup_done->(); |
|
|
2336 | }); |
|
|
2337 | |
2294 | Event::loop; |
2338 | Event::loop; |
|
|
2339 | |
|
|
2340 | #video_shutdown; |
|
|
2341 | #audio_shutdown; |
2295 | #CFPlus::SDL_Quit; |
2342 | CFPlus::SDL_Quit; |
2296 | #CFPlus::_exit 0; |
|
|
2297 | |
|
|
2298 | END { |
|
|
2299 | video_shutdown; |
|
|
2300 | audio_shutdown; |
|
|
2301 | CFPlus::SDL_Quit; |
|
|
2302 | CFPlus::DB::Server::stop; |
2343 | CFPlus::DB::Server::stop; |
2303 | } |
|
|
2304 | |
2344 | |
2305 | =head1 NAME |
2345 | =head1 NAME |
2306 | |
2346 | |
2307 | cfplus - A Crossfire TRT and Crossfire game client |
2347 | cfplus - A Crossfire TRT and Crossfire game client |
2308 | |
2348 | |