diff --git a/Manual/content/changelog.html b/Manual/content/changelog.html index 40b5e682b..732af6fd9 100644 --- a/Manual/content/changelog.html +++ b/Manual/content/changelog.html @@ -42,12 +42,13 @@
hard_bubble
and frame_box
to the system assets.loop
property to object type sound data.set_song_pos_near_loop
maker tool.Changes the current position of all songs to be just a few seconds before their loop point. This is useful when you want to test the loop points and don't want to wait until the song gets there normally.
+ +set_song_pos_near_loop
.Toggles visibility of mob collision boxes/bubbles. This is just a simple unfilled circle or rectangle, and for objects that push with their hitboxes, each hitbox's bubble will be shown too.
diff --git a/Source/source/audio.cpp b/Source/source/audio.cpp index 2c11c499a..8862d29b1 100644 --- a/Source/source/audio.cpp +++ b/Source/source/audio.cpp @@ -701,7 +701,6 @@ bool audio_manager::set_current_song(const string &name, bool from_start) { break; } } - //TODO } //Get the new song to play, if applicable. @@ -744,6 +743,21 @@ bool audio_manager::set_current_song(const string &name, bool from_start) { } +/** + * @brief Sets the current position of all songs to be near the loop point. + * This is helpful for when you want to test said loop point. + */ +void audio_manager::set_song_pos_near_loop() { + for(auto s : songs) { + double pos = std::max(0.0, s.second.loop_end - 4.0f); + al_seek_audio_stream_secs(s.second.main_track, pos); + for(auto const &m : s.second.mix_tracks) { + al_seek_audio_stream_secs(m.second, pos); + } + } +} + + /** * @brief Sets the position of a positional sound effect source. * @@ -1217,6 +1231,9 @@ void song::load_from_data_node(data_node* node) { game.audio.streams.get(mix_track_node->value, mix_track_node); } + if(loop_end == 0.0f) { + loop_end = al_get_audio_stream_length_secs(main_track); + } if(loop_end < loop_start) { loop_start = 0.0f; } diff --git a/Source/source/audio.h b/Source/source/audio.h index 51db0bd81..7cd21b5d8 100644 --- a/Source/source/audio.h +++ b/Source/source/audio.h @@ -391,6 +391,7 @@ class audio_manager { bool schedule_emission(size_t source_id, bool first); void set_camera_pos(const point &cam_tl, const point &cam_br); bool set_current_song(const string &name, bool from_start = true); + void set_song_pos_near_loop(); bool set_sfx_source_pos(size_t source_id, const point &pos); void stop_all_playbacks(const ALLEGRO_SAMPLE* filter = nullptr); void tick(float delta_t); diff --git a/Source/source/controls.cpp b/Source/source/controls.cpp index 0a196a196..941f55fe3 100644 --- a/Source/source/controls.cpp +++ b/Source/source/controls.cpp @@ -522,6 +522,10 @@ void gameplay_state::process_system_key_press(const int keycode) { game.maker_tools.used_helping_tools = true; break; + } case MAKER_TOOL_TYPE_SET_SONG_POS_NEAR_LOOP: { + game.audio.set_song_pos_near_loop(); + break; + } case MAKER_TOOL_TYPE_TELEPORT: { sector* mouse_sector = get_sector(game.mouse_cursor.w_pos, nullptr, true); diff --git a/Source/source/misc_structs.cpp b/Source/source/misc_structs.cpp index e39f94502..e411fd668 100644 --- a/Source/source/misc_structs.cpp +++ b/Source/source/misc_structs.cpp @@ -127,6 +127,7 @@ const string NAMES[N_MAKER_TOOLS] = { "mob_info", "new_pikmin", "path_info", + "set_song_pos_near_loop", "teleport" }; diff --git a/Source/source/misc_structs.h b/Source/source/misc_structs.h index 7c4573b69..025af05fb 100644 --- a/Source/source/misc_structs.h +++ b/Source/source/misc_structs.h @@ -107,6 +107,9 @@ enum MAKER_TOOL_TYPE { //Show path info. MAKER_TOOL_TYPE_PATH_INFO, + //Set song position near loop. + MAKER_TOOL_TYPE_SET_SONG_POS_NEAR_LOOP, + //Teleport to mouse cursor. MAKER_TOOL_TYPE_TELEPORT,