mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 22:33:43 -07:00
Generation doesn't freeze the game anymore + funny music
This commit is contained in:
parent
37f46b6850
commit
df2b526975
5 changed files with 45 additions and 7 deletions
|
@ -25,6 +25,7 @@
|
||||||
#include "Lib/Fast3D/gfx_rendering_api.h"
|
#include "Lib/Fast3D/gfx_rendering_api.h"
|
||||||
#include "Lib/spdlog/include/spdlog/common.h"
|
#include "Lib/spdlog/include/spdlog/common.h"
|
||||||
#include "Utils/StringHelper.h"
|
#include "Utils/StringHelper.h"
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
#ifdef ENABLE_OPENGL
|
#ifdef ENABLE_OPENGL
|
||||||
#include "Lib/ImGui/backends/imgui_impl_opengl3.h"
|
#include "Lib/ImGui/backends/imgui_impl_opengl3.h"
|
||||||
|
@ -60,6 +61,8 @@ OSContPad* pads;
|
||||||
|
|
||||||
std::map<std::string, GameAsset*> DefaultAssets;
|
std::map<std::string, GameAsset*> DefaultAssets;
|
||||||
|
|
||||||
|
std::thread randoThread;
|
||||||
|
|
||||||
SpoilerData gSpoilerData;
|
SpoilerData gSpoilerData;
|
||||||
|
|
||||||
namespace SohImGui {
|
namespace SohImGui {
|
||||||
|
@ -419,6 +422,11 @@ namespace SohImGui {
|
||||||
pads = cont_pad;
|
pads = cont_pad;
|
||||||
});
|
});
|
||||||
Game::InitSettings();
|
Game::InitSettings();
|
||||||
|
|
||||||
|
CVar_SetS32("gRandomizer", 0);
|
||||||
|
CVar_SetS32("gRandoGenerating", 0);
|
||||||
|
CVar_SetS32("gDroppedNewSpoilerFile", 0);
|
||||||
|
Game::SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update(EventImpl event) {
|
void Update(EventImpl event) {
|
||||||
|
@ -1033,11 +1041,10 @@ namespace SohImGui {
|
||||||
|
|
||||||
if (ImGui::BeginMenu("Randomizer"))
|
if (ImGui::BeginMenu("Randomizer"))
|
||||||
{
|
{
|
||||||
EnhancementCheckbox("Enable Randomizer", "gRandomizer");
|
|
||||||
|
|
||||||
if (ImGui::Button("Generate Seed")) {
|
if (ImGui::Button("Generate Seed")) {
|
||||||
RandoMain::GenerateRando();
|
if (CVar_GetS32("gRandoGenerating", 0) == 0) {
|
||||||
Game::LoadSettings();
|
randoThread = std::thread(&SohImGui::GenerateRandomizerImgui);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
|
@ -1261,6 +1268,18 @@ namespace SohImGui {
|
||||||
overlay->Draw();
|
overlay->Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GenerateRandomizerImgui() {
|
||||||
|
CVar_SetS32("gRandoGenerating", 1);
|
||||||
|
Game::SaveSettings();
|
||||||
|
|
||||||
|
RandoMain::GenerateRando();
|
||||||
|
|
||||||
|
CVar_SetS32("gRandoGenerating", 0);
|
||||||
|
Game::SaveSettings();
|
||||||
|
|
||||||
|
Game::LoadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
void DrawFramebufferAndGameInput(void) {
|
void DrawFramebufferAndGameInput(void) {
|
||||||
const ImVec2 main_pos = ImGui::GetWindowPos();
|
const ImVec2 main_pos = ImGui::GetWindowPos();
|
||||||
ImVec2 size = ImGui::GetContentRegionAvail();
|
ImVec2 size = ImGui::GetContentRegionAvail();
|
||||||
|
|
|
@ -74,6 +74,7 @@ namespace SohImGui {
|
||||||
|
|
||||||
void DrawMainMenuAndCalculateGameSize(void);
|
void DrawMainMenuAndCalculateGameSize(void);
|
||||||
|
|
||||||
|
void GenerateRandomizerImgui();
|
||||||
void DrawFramebufferAndGameInput(void);
|
void DrawFramebufferAndGameInput(void);
|
||||||
void Render(void);
|
void Render(void);
|
||||||
void CancelFrame(void);
|
void CancelFrame(void);
|
||||||
|
|
|
@ -17,6 +17,7 @@ void RandoMain::GenerateRando() {
|
||||||
|
|
||||||
std::string fileName = GenerateRandomizer();
|
std::string fileName = GenerateRandomizer();
|
||||||
CVar_SetString("gSpoilerLog", fileName.c_str());
|
CVar_SetString("gSpoilerLog", fileName.c_str());
|
||||||
CVar_SetS32("gDroppedNewSpoilerFile", 1);
|
|
||||||
Game::SaveSettings();
|
Game::SaveSettings();
|
||||||
|
Game::LoadSettings();
|
||||||
|
CVar_SetS32("gDroppedNewSpoilerFile", 1);
|
||||||
}
|
}
|
|
@ -1159,7 +1159,7 @@ void Randomizer::ParseItemLocationsFile(const char* spoilerFileName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
CVar_SetS32("gDroppedNewSpoilerFile", 0);
|
CVar_SetS32("gRandomizer", 1);
|
||||||
Game::SaveSettings();
|
Game::SaveSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,6 +227,9 @@ void DrawSeedHashSprites(FileChooseContext* this) {
|
||||||
* Lastly, set any warning labels if appropriate.
|
* Lastly, set any warning labels if appropriate.
|
||||||
* Update function for `CM_MAIN_MENU`
|
* Update function for `CM_MAIN_MENU`
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
u8 generating;
|
||||||
|
|
||||||
void FileChoose_UpdateMainMenu(GameState* thisx) {
|
void FileChoose_UpdateMainMenu(GameState* thisx) {
|
||||||
static u8 emptyName[] = { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E };
|
static u8 emptyName[] = { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E };
|
||||||
FileChooseContext* this = (FileChooseContext*)thisx;
|
FileChooseContext* this = (FileChooseContext*)thisx;
|
||||||
|
@ -234,7 +237,21 @@ void FileChoose_UpdateMainMenu(GameState* thisx) {
|
||||||
Input* input = &this->state.input[0];
|
Input* input = &this->state.input[0];
|
||||||
bool dpad = CVar_GetS32("gDpadPauseName", 0);
|
bool dpad = CVar_GetS32("gDpadPauseName", 0);
|
||||||
|
|
||||||
if (CVar_GetS32("gDroppedNewSpoilerFile", 0) != 0) {
|
if (CVar_GetS32("gRandoGenerating", 0) != 0 && generating == 0) {
|
||||||
|
generating = 1;
|
||||||
|
func_800F5E18(SEQ_PLAYER_BGM_MAIN, NA_BGM_HORSE, 0, 7, 1);
|
||||||
|
return;
|
||||||
|
} else if (CVar_GetS32("gRandoGenerating", 0) == 0 && generating) {
|
||||||
|
Audio_PlayFanfare(NA_BGM_HORSE_GOAL);
|
||||||
|
func_800F5E18(SEQ_PLAYER_BGM_MAIN, NA_BGM_FILE_SELECT, 0, 7, 1);
|
||||||
|
generating = 0;
|
||||||
|
return;
|
||||||
|
} else if (generating) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CVar_GetS32("gDroppedNewSpoilerFile", 0) != 0 && !generating) {
|
||||||
|
CVar_SetS32("gDroppedNewSpoilerFile", 0);
|
||||||
const char* fileLoc = CVar_GetString("gSpoilerLog", "");
|
const char* fileLoc = CVar_GetString("gSpoilerLog", "");
|
||||||
LoadItemLocations(fileLoc);
|
LoadItemLocations(fileLoc);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue