drag and drop away!

This commit is contained in:
briaguya 2022-05-30 18:01:13 -04:00
commit 1d53c90a5f
6 changed files with 21 additions and 9 deletions

View file

@ -64,7 +64,7 @@ void CVar_SetFloat(const char* name, float value) {
cvar->value.valueFloat = value;
}
void CVar_SetString(const char* name, const char* value) {
extern "C" void CVar_SetString(const char* name, const char* value) {
auto& cvar = cvars[name];
if (!cvar) {
cvar = std::make_unique<CVar>();

View file

@ -27,6 +27,7 @@ s32 CVar_GetS32(const char* name, s32 defaultValue);
float CVar_GetFloat(const char* name, float defaultValue);
const char* CVar_GetString(const char* name, const char* defaultValue);
void CVar_SetS32(const char* name, s32 value);
void CVar_SetString(const char* name, const char* value);
void CVar_RegisterS32(const char* name, s32 defaultValue);
void CVar_RegisterFloat(const char* name, float defaultValue);
@ -44,6 +45,5 @@ void CVar_RegisterString(const char* name, const char* defaultValue);
extern std::map<std::string, std::unique_ptr<CVar>, std::less<>> cvars;
void CVar_SetFloat(const char* name, float value);
void CVar_SetString(const char* name, const char* value);
#endif
#endif

View file

@ -27,6 +27,7 @@
#include "gfx_screen_config.h"
#include "gfx_pc.h"
#include "../../SohImGuiImpl.h"
#include "../../Cvar.h"
#define DECLARE_GFX_DXGI_FUNCTIONS
#include "gfx_dxgi.h"
@ -271,7 +272,8 @@ static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_par
case WM_DROPFILES:
char fileName[256];
DragQueryFileA((HDROP)w_param, 0, fileName, 256);
LoadItemLocations(fileName);
CVar_SetString("gDroppedFile", fileName);
CVar_SetS32("gDroppedNewSpoilerFile", 1);
break;
case WM_SYSKEYDOWN:
if ((w_param == VK_RETURN) && ((l_param & 1 << 30) == 0)) {

View file

@ -20,6 +20,7 @@
#endif
#include "../../SohImGuiImpl.h"
#include "../../Cvar.h"
#include "gfx_window_manager_api.h"
#include "gfx_screen_config.h"
@ -228,8 +229,6 @@ static void gfx_sdl_onkeyup(int scancode) {
}
}
extern "C" void LoadItemLocations(const char* spoilerFileName);
static void gfx_sdl_handle_events(void) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
@ -253,9 +252,8 @@ static void gfx_sdl_handle_events(void) {
}
break;
case SDL_DROPFILE:
#ifndef __linux__
LoadItemLocations(event.drop.file);
#endif
CVar_SetString("gDroppedFile", event.drop.file);
CVar_SetS32("gDroppedNewSpoilerFile", 1);
break;
case SDL_QUIT:
SDL_Quit(); // bandaid fix for linux window closing issue

View file

@ -8,6 +8,7 @@
#include <Cvar.h>
#include <textures/icon_item_static/icon_item_static.h>
#include <textures/icon_item_24_static/icon_item_24_static.h>
#include <GameSettings.h>
using json = nlohmann::json;
@ -779,6 +780,8 @@ void Randomizer::ParseItemLocations(const char* spoilerFileName) {
if (success) {
CVar_SetS32("gRandomizer", 1);
CVar_SetS32("gDroppedNewSpoilerFile", 0);
Game::SaveSettings();
}
}

View file

@ -66,7 +66,13 @@ void FileChoose_InitModeUpdate(GameState* thisx) {
this->configMode = CM_FADE_IN_START;
this->nextTitleLabel = FS_TITLE_OPEN_FILE;
osSyncPrintf(" Start─Load 》》》》》 ");
CVar_SetS32("gRandomizer", 0);
if (strcmp(CVar_GetString("gDroppedFile", ""), "") != 0 && CVar_GetS32("gRandomizer", 0) != 0) {
LoadItemLocations(CVar_GetString("gDroppedFile", ""));
} else {
CVar_SetS32("gRandomizer", 0);
}
Sram_VerifyAndLoadAllSaves(this, &this->sramCtx);
osSyncPrintf("終了!!!\n");
}
@ -233,6 +239,9 @@ void FileChoose_UpdateMainMenu(GameState* thisx) {
SramContext* sramCtx = &this->sramCtx;
Input* input = &this->state.input[0];
bool dpad = CVar_GetS32("gDpadPauseName", 0);
if (strcmp(CVar_GetString("gDroppedFile", ""), "") != 0 && CVar_GetS32("gDroppedNewSpoilerFile", 0) != 0) {
LoadItemLocations(CVar_GetString("gDroppedFile", ""));
}
if (CHECK_BTN_ALL(input->press.button, BTN_START) || CHECK_BTN_ALL(input->press.button, BTN_A)) {
if (this->buttonIndex <= FS_BTN_MAIN_FILE_3) {