… | |
… | |
86 | use CFPlus::DB; |
86 | use CFPlus::DB; |
87 | use CFPlus::UI; |
87 | use CFPlus::UI; |
88 | use CFPlus::UI::Canvas; |
88 | use CFPlus::UI::Canvas; |
89 | use CFPlus::UI::Inventory; |
89 | use CFPlus::UI::Inventory; |
90 | use CFPlus::UI::SpellList; |
90 | use CFPlus::UI::SpellList; |
|
|
91 | use CFPlus::UI::Dockable; |
91 | use CFPlus::UI::MessageWindow; |
92 | use CFPlus::UI::MessageWindow; |
|
|
93 | use CFPlus::UI::ChatView; |
92 | use CFPlus::Pod; |
94 | use CFPlus::Pod; |
93 | use CFPlus::MapWidget; |
95 | use CFPlus::MapWidget; |
94 | use CFPlus::Macro; |
96 | use CFPlus::Macro; |
95 | |
97 | |
96 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
98 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
… | |
… | |
126 | our $FONT_FIXED; |
128 | our $FONT_FIXED; |
127 | |
129 | |
128 | our $MAP; |
130 | our $MAP; |
129 | our $MAPMAP; |
131 | our $MAPMAP; |
130 | our $MAPWIDGET; |
132 | our $MAPWIDGET; |
|
|
133 | our $COMPLETER; |
131 | our $BUTTONBAR; |
134 | our $BUTTONBAR; |
132 | our $METASERVER; |
135 | our $METASERVER; |
133 | our $LOGIN_BUTTON; |
136 | our $LOGIN_BUTTON; |
134 | our $QUIT_DIALOG; |
137 | our $QUIT_DIALOG; |
135 | our $HOST_ENTRY; |
138 | our $HOST_ENTRY; |
… | |
… | |
146 | our $PL_WINDOW; |
149 | our $PL_WINDOW; |
147 | |
150 | |
148 | our $MUSIC_PLAYING_WIDGET; |
151 | our $MUSIC_PLAYING_WIDGET; |
149 | our $LICENSE_WIDGET; |
152 | our $LICENSE_WIDGET; |
150 | |
153 | |
|
|
154 | our $PICKUP_PAGE; |
151 | our $INVENTORY_PAGE; |
155 | our $INVENTORY_PAGE; |
152 | our $STATS_PAGE; |
156 | our $STATS_PAGE; |
153 | our $SKILL_PAGE; |
157 | our $SKILL_PAGE; |
154 | our $SPELL_PAGE; |
158 | our $SPELL_PAGE; |
155 | our $SPELL_LIST; |
159 | our $SPELL_LIST; |
… | |
… | |
180 | sub debug { |
184 | sub debug { |
181 | $DEBUG_STATUS->set_text ($_[0]); |
185 | $DEBUG_STATUS->set_text ($_[0]); |
182 | } |
186 | } |
183 | |
187 | |
184 | sub message { |
188 | sub message { |
185 | my ($para) = @_; |
|
|
186 | $MESSAGE_WINDOW->message ($para); |
189 | $MESSAGE_WINDOW->message (@_); |
187 | } |
190 | } |
188 | |
191 | |
189 | ############################################################################# |
192 | ############################################################################# |
190 | #TODO: maybe move into own audio module... |
193 | #TODO: maybe move into own audio module... |
191 | |
194 | |
… | |
… | |
228 | $channel->set_position_r ($dx, $dy, 20); |
231 | $channel->set_position_r ($dx, $dy, 20); |
229 | $chunk->play ($channel); |
232 | $chunk->play ($channel); |
230 | } |
233 | } |
231 | } else { |
234 | } else { |
232 | # sound_meta not set means data is in flight either way |
235 | # sound_meta not set means data is in flight either way |
233 | my $meta = $CONN->{sound_meta}{$face} |
236 | my $meta = $CONN->{face}[$face] |
234 | or return; |
237 | or return; |
235 | |
238 | |
|
|
239 | $meta->{data} |
|
|
240 | or return; |
|
|
241 | |
236 | # if its a jingle, play it as ambient music |
242 | # if its a jingle, play it as ambient music |
237 | if ($meta->{meta}{jingle}) { |
243 | if ($meta->{data}{jingle}) { |
238 | if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue |
244 | if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue |
239 | push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue |
245 | push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue |
240 | &audio_music_push ($face); |
246 | &audio_music_push ($face); |
241 | } |
247 | } |
242 | } else { |
248 | } else { |
243 | # fetch from database |
249 | # fetch from database |
244 | CFPlus::DB::get res_data => $meta->{name}, sub { |
250 | CFPlus::DB::get res_data => $meta->{name}, sub { |
245 | my $rwops = new CFPlus::RW $_[0]; |
251 | my $rwops = new CFPlus::RW $_[0]; |
246 | my $chunk = new CFPlus::MixChunk $rwops |
252 | my $chunk = new CFPlus::MixChunk $rwops |
247 | or Carp::confess "sound face " . (JSON::XS::to_json $meta) . " unloadable: " . CFPlus::Mix_GetError; |
253 | or Carp::confess "sound face " . (JSON::XS::to_json $meta) . " unloadable: " . CFPlus::Mix_GetError; |
248 | $chunk->volume (($meta->{meta}{volume} || 1) * 128); |
254 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
249 | $AUDIO_CHUNK{$face} = $chunk; |
255 | $AUDIO_CHUNK{$face} = $chunk; |
250 | |
256 | |
251 | audio_sound_push ($face); |
257 | audio_sound_push ($face); |
252 | }; |
258 | }; |
253 | } |
259 | } |
… | |
… | |
271 | sub audio_music_set_meta { |
277 | sub audio_music_set_meta { |
272 | my ($meta) = @_; |
278 | my ($meta) = @_; |
273 | |
279 | |
274 | $MUSIC_PLAYING_META = $meta; |
280 | $MUSIC_PLAYING_META = $meta; |
275 | $MUSIC_PLAYING_WIDGET->set_markup ( |
281 | $MUSIC_PLAYING_WIDGET->set_markup ( |
276 | "<b>Name</b>: " . (CFPlus::asxml $meta->{meta}{name}) . "\n" |
282 | "<b>Name</b>: " . (CFPlus::asxml $meta->{data}{name}) . "\n" |
277 | . "<b>Author</b>: " . (CFPlus::asxml $meta->{meta}{author}) . "\n" |
283 | . "<b>Author</b>: " . (CFPlus::asxml $meta->{data}{author}) . "\n" |
278 | . "<b>Source</b>: " . (CFPlus::asxml $meta->{meta}{source}) . "\n" |
284 | . "<b>Source</b>: " . (CFPlus::asxml $meta->{data}{source}) . "\n" |
279 | . "<b>License</b>: " . (CFPlus::asxml $meta->{meta}{license}) |
285 | . "<b>License</b>: " . (CFPlus::asxml $meta->{data}{license}) |
280 | ); |
286 | ); |
281 | } |
287 | } |
282 | |
288 | |
283 | sub audio_music_update_volume { |
289 | sub audio_music_update_volume { |
284 | return unless $MUSIC_PLAYING_META; |
290 | return unless $MUSIC_PLAYING_META; |
285 | my $volume = $MUSIC_PLAYING_META->{meta}{volume} || 1; |
291 | my $volume = $MUSIC_PLAYING_META->{data}{volume} || 1; |
286 | my $base = $MUSIC_PLAYING_META->{meta}{jingle} ? 1 : $CFG->{bgm_volume}; |
292 | my $base = $MUSIC_PLAYING_META->{data}{jingle} ? 1 : $CFG->{bgm_volume}; |
287 | CFPlus::MixMusic::volume $base * $volume * 128; |
293 | CFPlus::MixMusic::volume $base * $volume * 128; |
288 | } |
294 | } |
289 | |
295 | |
290 | sub audio_music_start { |
296 | sub audio_music_start { |
291 | my $meta = $MUSIC_PLAYING_META; |
297 | my $meta = $MUSIC_PLAYING_META; |
… | |
… | |
310 | |
316 | |
311 | my $NOW = time; |
317 | my $NOW = time; |
312 | |
318 | |
313 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
319 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
314 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
320 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
315 | $MUSIC_PLAYER->fade_in_pos (0, 1000, $pos); |
321 | $MUSIC_PLAYER->fade_in_pos (0, 700, $pos); |
316 | $MUSIC_START = time - $pos; |
322 | $MUSIC_START = time - $pos; |
317 | } else { |
323 | } else { |
318 | $MUSIC_PLAYER->play (0); |
324 | $MUSIC_PLAYER->play (0); |
319 | $MUSIC_START = time; |
325 | $MUSIC_START = time; |
320 | } |
326 | } |
… | |
… | |
334 | $fade_out = 333; |
340 | $fade_out = 333; |
335 | } else { |
341 | } else { |
336 | return unless $CFG->{bgm_enable}; |
342 | return unless $CFG->{bgm_enable}; |
337 | |
343 | |
338 | my @have = |
344 | my @have = |
339 | grep $_, |
345 | grep $_ && $_->{data}, |
340 | map $CONN->{music_meta}{$_}, |
346 | map $CONN->{face}[$_], |
341 | @$MUSIC_WANT; |
347 | @$MUSIC_WANT; |
|
|
348 | |
|
|
349 | # randomize music a bit so that the order is not always the same |
|
|
350 | $_->{stop_time} ||= rand for @have; |
342 | |
351 | |
343 | @MUSIC_HAVE = @have |
352 | @MUSIC_HAVE = @have |
344 | if @have; |
353 | if @have; |
345 | |
354 | |
346 | # default MUSIC_HAVE == MUSIC_DEFAULT |
355 | # default MUSIC_HAVE == MUSIC_DEFAULT |
347 | @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_HAVE; |
356 | @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_HAVE; |
348 | $fade_out = 1000; |
357 | $fade_out = 700; |
349 | } |
358 | } |
350 | |
359 | |
351 | # if the currently playing song is acceptable, let it continue |
360 | # if the currently playing song is acceptable, let it continue |
352 | return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; |
361 | return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; |
353 | |
362 | |
… | |
… | |
362 | @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE; |
371 | @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE; |
363 | |
372 | |
364 | # if the most recently-played piece played very recently, |
373 | # if the most recently-played piece played very recently, |
365 | # resume it, else choose the oldest piece for rotation. |
374 | # resume it, else choose the oldest piece for rotation. |
366 | audio_music_set_meta |
375 | audio_music_set_meta |
367 | $MUSIC_HAVE[-1]{stop_time} > $NOW - $MUSIC_RESUME |
376 | $MUSIC_HAVE[-1]{stop_pos} && $MUSIC_HAVE[-1]{stop_time} > $NOW - $MUSIC_RESUME |
368 | ? $MUSIC_HAVE[-1] |
377 | ? $MUSIC_HAVE[-1] |
369 | : $MUSIC_HAVE[0]; |
378 | : $MUSIC_HAVE[0]; |
370 | |
379 | |
371 | audio_music_start; |
380 | audio_music_start; |
372 | } |
381 | } |
… | |
… | |
378 | $MUSIC_WANT = $songs; |
387 | $MUSIC_WANT = $songs; |
379 | audio_music_push; |
388 | audio_music_push; |
380 | } |
389 | } |
381 | |
390 | |
382 | sub audio_music_finished { |
391 | sub audio_music_finished { |
|
|
392 | if ($MUSIC_PLAYING_META) { |
|
|
393 | $MUSIC_PLAYING_META->{stop_time} = time; |
|
|
394 | } |
|
|
395 | |
383 | # we compress multiple jingles of the same type |
396 | # we compress multiple jingles of the same type |
384 | shift @MUSIC_JINGLE |
397 | shift @MUSIC_JINGLE |
385 | while @MUSIC_JINGLE && $MUSIC_PLAYING_META == $MUSIC_JINGLE[0]; |
398 | while @MUSIC_JINGLE && $MUSIC_PLAYING_META == $MUSIC_JINGLE[0]; |
386 | |
399 | |
387 | $MUSIC_PLAYING_WIDGET->clear; |
400 | $MUSIC_PLAYING_WIDGET->clear; |
… | |
… | |
769 | on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } |
782 | on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } |
770 | ); |
783 | ); |
771 | |
784 | |
772 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Force OpenGL 1.1"); |
785 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Force OpenGL 1.1"); |
773 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
786 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
774 | state => $CFG->{opengl11}, |
787 | state => $CFG->{force_opengl11}, |
775 | tooltip => "Limit CFPlus to use OpenGL 1.1 features only. This will normally result in " |
788 | tooltip => "Limit CFPlus to use OpenGL 1.1 features only. This will normally result in " |
776 | . "higher memory usage and slower performance. It will, however, help tremendously on " |
789 | . "higher memory usage and slower performance. It will, however, help tremendously on " |
777 | . "cards that claim to support a feature but fall back to software rendering. " |
790 | . "cards that claim to support a feature but fall back to software rendering. " |
778 | . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, " |
791 | . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, " |
779 | . "but cards and drivers from other vendors (ATI) are often just as bad. <b>If you " |
792 | . "but cards and drivers from other vendors (ATI) are often just as bad. <b>If you " |
780 | . "experience extremely low framerates and your card should do better, try this option.</b>", |
793 | . "experience extremely low framerates and your card should do better, try this option.</b>", |
781 | on_changed => sub { my ($self, $value) = @_; $CFG->{opengl11} = $value; 0 } |
794 | on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 } |
|
|
795 | ); |
|
|
796 | |
|
|
797 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Compress Textures"); |
|
|
798 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
|
|
799 | state => $CFG->{texture_compression}, |
|
|
800 | tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " |
|
|
801 | . "will save a lot of memory and increase performance. The compression algorithm " |
|
|
802 | . "can differ form card to card, so your mileage may vary. This setting is ignored in " |
|
|
803 | . "forced OpenGL 1.1 mode.", |
|
|
804 | on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } |
782 | ); |
805 | ); |
783 | |
806 | |
784 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); |
807 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); |
785 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
808 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
786 | state => $CFG->{fast}, |
809 | state => $CFG->{fast}, |
… | |
… | |
908 | expand => 1, state => $CFG->{bgm_enable}, |
931 | expand => 1, state => $CFG->{bgm_enable}, |
909 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
932 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
910 | on_changed => sub { |
933 | on_changed => sub { |
911 | $CFG->{bgm_enable} = $_[1]; |
934 | $CFG->{bgm_enable} = $_[1]; |
912 | $CONN->update_fx_want if $CONN; |
935 | $CONN->update_fx_want if $CONN; |
|
|
936 | audio_music_push; |
913 | 0 |
937 | 0 |
914 | } |
938 | } |
915 | ); |
939 | ); |
916 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
940 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
917 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
941 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
… | |
… | |
970 | $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health"); |
994 | $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health"); |
971 | $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana"); |
995 | $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana"); |
972 | $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace"); |
996 | $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace"); |
973 | $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food"); |
997 | $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food"); |
974 | |
998 | |
975 | $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); |
999 | $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); |
|
|
1000 | $vbox->add (my $prg = new CFPlus::UI::ExperienceProgress); |
|
|
1001 | $vbox->add (my $sklprg = new CFPlus::UI::ExperienceProgress); |
976 | $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); |
1002 | $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); |
977 | |
1003 | |
978 | $GAUGES = { |
1004 | $GAUGES = { |
|
|
1005 | exp => $exp, prg => $prg, sklprg => $sklprg, |
979 | exp => $exp, win => $win, range => $rng, |
1006 | win => $win, range => $rng, |
980 | food => $fg, mana => $mg, hp => $hg, grace => $gg |
1007 | hp => $hg, mana => $mg, grace => $gg, food => $fg, |
981 | }; |
1008 | }; |
982 | |
1009 | |
983 | &set_gauge_window_fontsize; |
1010 | &set_gauge_window_fontsize; |
984 | |
1011 | |
985 | $win |
1012 | $win |
… | |
… | |
1186 | $r |
1213 | $r |
1187 | } |
1214 | } |
1188 | |
1215 | |
1189 | sub skill_window { |
1216 | sub skill_window { |
1190 | my $sw = new CFPlus::UI::ScrolledWindow (expand => 1); |
1217 | my $sw = new CFPlus::UI::ScrolledWindow (expand => 1); |
|
|
1218 | |
1191 | $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, 0, 0, 1]); |
1219 | $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, .1, 0, 0, 1, .1]); |
|
|
1220 | |
1192 | $sw |
1221 | $sw |
1193 | } |
1222 | } |
1194 | |
1223 | |
1195 | sub formsep($) { |
1224 | sub formsep($) { |
1196 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
1225 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
… | |
… | |
1641 | } |
1670 | } |
1642 | |
1671 | |
1643 | sub add_license { |
1672 | sub add_license { |
1644 | my ($meta) = @_; |
1673 | my ($meta) = @_; |
1645 | |
1674 | |
1646 | $meta = $meta->{meta} |
1675 | $meta = $meta->{data} |
1647 | or return; |
1676 | or return; |
1648 | |
1677 | |
1649 | $meta->{license} || $meta->{author} || $meta->{source} |
1678 | $meta->{license} || $meta->{author} || $meta->{source} |
1650 | or return; |
1679 | or return; |
1651 | |
1680 | |
… | |
… | |
1705 | $ntb->add_tab ( |
1734 | $ntb->add_tab ( |
1706 | "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, |
1735 | "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, |
1707 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1736 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1708 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1737 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1709 | ); |
1738 | ); |
1710 | $ntb->add_tab (Pickup => autopickup_setup, |
1739 | $ntb->add_tab (Pickup => $PICKUP_PAGE = autopickup_setup, |
1711 | "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); |
1740 | "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); |
1712 | |
1741 | |
1713 | $ntb->add_tab (Media => media_window, |
1742 | $ntb->add_tab (Media => media_window, |
1714 | "License, Author and Source info for media sent by the server."); |
1743 | "License, Author and Source info for media sent by the server."); |
1715 | |
1744 | |
… | |
… | |
1956 | |
1985 | |
1957 | $SDL_ACTIVE = 1; |
1986 | $SDL_ACTIVE = 1; |
1958 | $LAST_REFRESH = time - 0.01; |
1987 | $LAST_REFRESH = time - 0.01; |
1959 | |
1988 | |
1960 | CFPlus::OpenGL::init; |
1989 | CFPlus::OpenGL::init; |
|
|
1990 | CFPlus::Macro::init; |
1961 | |
1991 | |
1962 | $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
1992 | $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
1963 | |
1993 | |
1964 | $CFPlus::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# |
1994 | $CFPlus::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# |
1965 | |
1995 | |
1966 | ############################################################################# |
1996 | ############################################################################# |
1967 | |
1997 | |
1968 | if ($DEBUG_STATUS) { |
1998 | if ($DEBUG_STATUS) { |
1969 | CFPlus::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h; |
1999 | CFPlus::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h; |
1970 | } else { |
2000 | } else { |
1971 | # create the widgets |
2001 | # create/configure the widgets |
|
|
2002 | |
|
|
2003 | $CFPlus::UI::ROOT->connect (key_down => sub { |
|
|
2004 | my (undef, $ev) = @_; |
|
|
2005 | |
|
|
2006 | if (my @macros = CFPlus::Macro::find $ev) { |
|
|
2007 | CFPlus::Macro::execute $_ for @macros; |
|
|
2008 | |
|
|
2009 | return 1; |
|
|
2010 | } |
|
|
2011 | |
|
|
2012 | 0 |
|
|
2013 | }); |
1972 | |
2014 | |
1973 | $DEBUG_STATUS = new CFPlus::UI::Label |
2015 | $DEBUG_STATUS = new CFPlus::UI::Label |
1974 | padding => 0, |
2016 | padding => 0, |
1975 | z => 100, |
2017 | z => 100, |
1976 | force_x => "max", |
2018 | force_x => "max", |
… | |
… | |
2006 | $MESSAGE_WINDOW->activate_console ($preset) |
2048 | $MESSAGE_WINDOW->activate_console ($preset) |
2007 | if $MESSAGE_WINDOW; |
2049 | if $MESSAGE_WINDOW; |
2008 | }); |
2050 | }); |
2009 | $MAPWIDGET->show; |
2051 | $MAPWIDGET->show; |
2010 | $MAPWIDGET->grab_focus; |
2052 | $MAPWIDGET->grab_focus; |
|
|
2053 | |
|
|
2054 | $COMPLETER = new CFPlus::MapWidget::Command:: |
|
|
2055 | command => { }, |
|
|
2056 | tooltip => "#completer_help", |
|
|
2057 | ; |
2011 | |
2058 | |
2012 | $SETUP_DIALOG = new CFPlus::UI::Toplevel |
2059 | $SETUP_DIALOG = new CFPlus::UI::Toplevel |
2013 | title => "Setup", |
2060 | title => "Setup", |
2014 | name => "setup_dialog", |
2061 | name => "setup_dialog", |
2015 | x => 'center', |
2062 | x => 'center', |
… | |
… | |
2140 | delete $animate_object{$widget}; |
2187 | delete $animate_object{$widget}; |
2141 | } |
2188 | } |
2142 | |
2189 | |
2143 | %SDL_CB = ( |
2190 | %SDL_CB = ( |
2144 | CFPlus::SDL_QUIT => sub { |
2191 | CFPlus::SDL_QUIT => sub { |
2145 | exit; |
2192 | Event::unloop_all; |
2146 | }, |
2193 | }, |
2147 | CFPlus::SDL_VIDEORESIZE => sub { |
2194 | CFPlus::SDL_VIDEORESIZE => sub { |
2148 | }, |
2195 | }, |
2149 | CFPlus::SDL_VIDEOEXPOSE => sub { |
2196 | CFPlus::SDL_VIDEOEXPOSE => sub { |
2150 | CFPlus::UI::full_refresh; |
2197 | CFPlus::UI::full_refresh; |
… | |
… | |
2189 | CFPlus::DB::Server::run; |
2236 | CFPlus::DB::Server::run; |
2190 | |
2237 | |
2191 | CFPlus::UI::set_layout ($::CFG->{layout}); |
2238 | CFPlus::UI::set_layout ($::CFG->{layout}); |
2192 | |
2239 | |
2193 | my %DEF_CFG = ( |
2240 | my %DEF_CFG = ( |
2194 | sdl_mode => 0, |
2241 | sdl_mode => 0, |
2195 | fullscreen => 0, |
2242 | fullscreen => 0, |
2196 | fast => 0, |
2243 | fast => 0, |
2197 | opengl11 => 0, |
2244 | force_opengl11 => undef, |
|
|
2245 | texture_compression => 1, |
2198 | map_scale => 1, |
2246 | map_scale => 1, |
2199 | fow_enable => 1, |
2247 | fow_enable => 1, |
2200 | fow_intensity => 0, |
2248 | fow_intensity => 0, |
2201 | map_smoothing => 1, |
2249 | map_smoothing => 1, |
2202 | gui_fontsize => 1, |
2250 | gui_fontsize => 1, |
2203 | log_fontsize => 0.7, |
2251 | log_fontsize => 0.7, |
2204 | gauge_fontsize => 1, |
2252 | gauge_fontsize => 1, |
2205 | gauge_size => 0.35, |
2253 | gauge_size => 0.35, |
2206 | stat_fontsize => 0.7, |
2254 | stat_fontsize => 0.7, |
2207 | mapsize => 100, |
2255 | mapsize => 100, |
2208 | audio_enable => 1, |
2256 | audio_enable => 1, |
2209 | effects_enable => 1, |
2257 | effects_enable => 1, |
2210 | effects_volume => 1, |
2258 | effects_volume => 1, |
2211 | bgm_enable => 1, |
2259 | bgm_enable => 1, |
2212 | bgm_volume => 0.5, |
2260 | bgm_volume => 0.5, |
2213 | output_sync => 1, |
2261 | output_sync => 1, |
2214 | output_count => 1, |
2262 | output_count => 1, |
2215 | output_rate => "", |
2263 | output_rate => "", |
2216 | pickup => 0, |
2264 | pickup => 0, |
2217 | inv_sort => "mtime", |
2265 | inv_sort => "mtime", |
2218 | default => "profile", # default profile |
2266 | default => "profile", # default profile |
2219 | show_tips => 1, |
2267 | show_tips => 1, |
2220 | logview_max_par => 1000, |
2268 | logview_max_par => 1000, |
2221 | ); |
2269 | ); |
2222 | |
2270 | |
2223 | while (my ($k, $v) = each %DEF_CFG) { |
2271 | while (my ($k, $v) = each %DEF_CFG) { |
2224 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2272 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2225 | } |
2273 | } |
… | |
… | |
2282 | # } |
2330 | # } |
2283 | # my $t2 = Time::HiRes::time; |
2331 | # my $t2 = Time::HiRes::time; |
2284 | # warn $t2-$t1; |
2332 | # warn $t2-$t1; |
2285 | # } |
2333 | # } |
2286 | |
2334 | |
2287 | $startup_done->(); |
|
|
2288 | |
|
|
2289 | video_init; |
2335 | video_init; |
2290 | audio_init; |
2336 | audio_init; |
2291 | } |
2337 | } |
2292 | |
2338 | |
2293 | show_tip_of_the_day if $CFG->{show_tips}; |
2339 | show_tip_of_the_day if $CFG->{show_tips}; |
|
|
2340 | |
|
|
2341 | Event->idle (cb => sub { |
|
|
2342 | $_[0]->w->cancel; |
|
|
2343 | $startup_done->(); |
|
|
2344 | }); |
2294 | |
2345 | |
2295 | Event::loop; |
2346 | Event::loop; |
2296 | |
2347 | |
2297 | #video_shutdown; |
2348 | #video_shutdown; |
2298 | #audio_shutdown; |
2349 | #audio_shutdown; |