Skip to content

Commit

Permalink
More code idk what
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaydax committed May 13, 2021
1 parent b42e01c commit fad3e9a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Chikara/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ void Config::Load(std::string& path) {
note_speed = GetFloat(reader, "Chikara", "NoteSpeed", note_speed);
rainbow_speed = GetFloat(reader, "Chikara", "RainbowSpeed", rainbow_speed);
start_delay = GetFloat(reader, "Chikara", "StartDelay", start_delay);
loader_buffer = GetFloat(reader, "Chikara", "LoaderBuffer", loader_buffer);

config_path = path;
}
Expand All @@ -57,6 +58,7 @@ bool Config::Save() {
WriteFloat(ini, "NoteSpeed", note_speed);
WriteFloat(ini, "RainbowSpeed", rainbow_speed);
WriteFloat(ini, "StartDelay", start_delay);
WriteFloat(ini, "LoaderBuffer", loader_buffer);

fclose(ini);

Expand Down
1 change: 1 addition & 0 deletions Chikara/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Config {
float note_speed = 0.15;
float rainbow_speed = 100;
float start_delay = 1;
float loader_buffer = 10;
private:
glm::vec3 GetVec3(INIReader& reader, const std::string& section, const std::string& name, glm::vec3& default_value);
float GetFloat(INIReader& reader, const std::string& section, const std::string& name, float& default_value);
Expand Down
2 changes: 1 addition & 1 deletion Chikara/GlobalTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ void GlobalTime::resume()

void GlobalTime::changeSpeed(float speed)
{
syncTime();
this->speed = speed;
syncTime();
}

void GlobalTime::skipForward(float seconds)
Expand Down
13 changes: 13 additions & 0 deletions Chikara/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ void Main::run(int argc, wchar_t** argv)
std::cout << "RPC Enabled: 0 (Discord Not Installed)" << std::endl;
Config::GetConfig().discord_rpc = false;
}

try
{
if(Config::GetConfig().loader_buffer < 0)
{
Config::GetConfig().loader_buffer = 0;
Config::GetConfig().Save();
}
}
catch (const std::exception& e)
{
//Config didn't exist, expecting it to just be 10;
}

wchar_t* filename_temp = _wcsdup(filename.c_str());
midi = new Midi(filename_temp);
Expand Down
3 changes: 2 additions & 1 deletion Chikara/Midi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "Main.h"
#include "Midi.h"
#include "KDMAPI.h"
#include "Config.h"
#include <fmt/locale.h>
#include <fmt/format.h>

Expand Down Expand Up @@ -309,7 +310,7 @@ void Midi::LoaderThread()
while(true)
{
memset(tracks_ended, 0, track_count);
while(seconds < renderer_time.load() + 10.0f)
while(seconds < renderer_time.load() + (Config::GetConfig().loader_buffer >= 0 ? Config::GetConfig().loader_buffer : 0))
{
for(int i = 0; i < track_count; i++)
{
Expand Down
3 changes: 3 additions & 0 deletions Chikara/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2050,10 +2050,13 @@ void Renderer::ImGuiFrame(GlobalTime* _gt)
ImGui::Checkbox("Toggle Discord Rich Presence*", &Config::GetConfig().discord_rpc);
ImGui::SliderFloat("Start Delay (Seconds)*", &Config::GetConfig().start_delay, 0, 60);
ImGui::SliderFloat("Note Speed", &Config::GetConfig().note_speed, 10, 0.01);
if(ImGui::SliderFloat("Note Buffer (Seconds)", &Config::GetConfig().loader_buffer, 1, 100)) if(Config::GetConfig().loader_buffer < 0) Config::GetConfig().loader_buffer = 0;
ImGui::Checkbox("Rainbow Bar", &Config::GetConfig().rainbow_bar);
ImGui::ColorEdit3("Background Color*", &Config::GetConfig().clear_color.r, ImGuiColorEditFlags_RGB);
ImGui::ColorEdit3("Bar Color", &Config::GetConfig().bar_color.r, ImGuiColorEditFlags_RGB); // haha undefined behavior go Segmentation fault
if(Config::GetConfig().rainbow_bar) ImGui::SliderFloat("Rainbow Speed", &Config::GetConfig().rainbow_speed, 1, 1000);
ImGui::Separator();
ImGui::Text("Note: Increasing the Note Buffer increases ram usage");
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Playback"))
Expand Down

0 comments on commit fad3e9a

Please sign in to comment.