Skip to content

Commit

Permalink
Added the "set_song_pos_near_loop" maker tool.
Browse files Browse the repository at this point in the history
  • Loading branch information
Espyo committed Sep 23, 2024
1 parent 1b8d0b2 commit 8f870ec
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Manual/content/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ <h2 id="0.26.0">0.26.0</h2>

<ul>
<li>
Sound logic:
Sound features:
<ul>
<li><span class="cl-a">Added</span> some sounds to the <a href="misc_config.html">system assets</a>.</li>
<li><span class="cl-a">Added</span> <code>hard_bubble</code> and <code>frame_box</code> to the <a href="misc_config.html">system assets</a>.</li>
<li><span class="cl-a">Added</span> the <code>loop</code> property to <a href="mob_type.html">object type</a> sound data.</li>
<li><span class="cl-a">Added</span> expected sounds to <a href="mob_onion.html">Onion</a> object types.</li>
<li><span class="cl-a">Added</span> the <code>set_song_pos_near_loop</code> <a href="maker_toolkit.html">maker tool</a>.</li>
</ul>
</li>
<li>
Expand Down
9 changes: 9 additions & 0 deletions Manual/content/maker_toolkit.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ <h3 id="path-info">Path info</h3>
<li>Settings: none.</li>
</ul>

<h3 id="set-song-pos-near-loop">Set song position near loop</h3>

<p>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.</p>

<ul>
<li>Tool ID: <code>set_song_pos_near_loop</code>.</li>
<li>Settings: none.</li>
</ul>

<h3 id="collision">Show collision</h3>

<p>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.</p>
Expand Down
19 changes: 18 additions & 1 deletion Source/source/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions Source/source/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions Source/source/controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions Source/source/misc_structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const string NAMES[N_MAKER_TOOLS] = {
"mob_info",
"new_pikmin",
"path_info",
"set_song_pos_near_loop",
"teleport"
};

Expand Down
3 changes: 3 additions & 0 deletions Source/source/misc_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down

0 comments on commit 8f870ec

Please sign in to comment.