mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 22:33:43 -07:00
got the hookshots rendering
This commit is contained in:
parent
d7bb8d7142
commit
7b1cb9af9c
7 changed files with 130 additions and 33 deletions
|
@ -132,6 +132,8 @@ static int frameDivisor = 1;
|
||||||
static void gfx_sdl_init(const char *game_name, bool start_in_fullscreen) {
|
static void gfx_sdl_init(const char *game_name, bool start_in_fullscreen) {
|
||||||
SDL_Init(SDL_INIT_VIDEO);
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
|
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
|
||||||
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||||
|
|
||||||
|
@ -227,8 +229,11 @@ static void gfx_sdl_onkeyup(int scancode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" void LoadItemLocations(const char* spoilerFileName);
|
||||||
|
|
||||||
static void gfx_sdl_handle_events(void) {
|
static void gfx_sdl_handle_events(void) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
char* dropped_filedir;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
SohImGui::EventImpl event_impl;
|
SohImGui::EventImpl event_impl;
|
||||||
event_impl.sdl = { &event };
|
event_impl.sdl = { &event };
|
||||||
|
@ -249,6 +254,11 @@ static void gfx_sdl_handle_events(void) {
|
||||||
window_height = event.window.data2;
|
window_height = event.window.data2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SDL_DROPFILE:
|
||||||
|
{
|
||||||
|
LoadItemLocations(event.drop.file);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
#include <variables.h>
|
#include <variables.h>
|
||||||
#include <macros.h>
|
#include <macros.h>
|
||||||
#include <objects/gameplay_keep/gameplay_keep.h>
|
#include <objects/gameplay_keep/gameplay_keep.h>
|
||||||
#include <objects/object_gi_bomb_1/object_gi_bomb_1.h>
|
#include <functions.h>
|
||||||
#include <objects/object_gi_letter/object_gi_letter.h>
|
#include <Cvar.h>
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
@ -643,24 +643,36 @@ s16 Randomizer::GetItemModelFromId(s16 itemId) {
|
||||||
return itemIdToModel[itemId];
|
return itemIdToModel[itemId];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Randomizer::LoadItemLocations() {
|
void Randomizer::LoadItemLocations(const char* spoilerFileName) {
|
||||||
// bandaid until new save stuff happens
|
// bandaid until new save stuff happens
|
||||||
ParseItemLocations("");
|
ParseItemLocations(spoilerFileName);
|
||||||
|
|
||||||
for(auto itemLocation : gSaveContext.itemLocations) {
|
for(auto itemLocation : gSaveContext.itemLocations) {
|
||||||
this->itemLocations[itemLocation.check] = itemLocation.get;
|
this->itemLocations[itemLocation.check] = itemLocation.get;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Randomizer::ParseItemLocations(std::string spoilerFileName) {
|
void Randomizer::ParseItemLocations(const char* spoilerFileName) {
|
||||||
// todo pull this in from cvar or something
|
// todo pull this in from cvar or something
|
||||||
std::ifstream spoilerFileStream("spoiler.json");
|
std::ifstream spoilerFileStream(spoilerFileName);
|
||||||
if (!spoilerFileStream)
|
if (!spoilerFileStream)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
bool success = false;
|
||||||
|
|
||||||
|
try {
|
||||||
json spoilerFileJson;
|
json spoilerFileJson;
|
||||||
spoilerFileStream >> spoilerFileJson;
|
spoilerFileStream >> spoilerFileJson;
|
||||||
json locationsJson = spoilerFileJson["locations"];
|
json locationsJson = spoilerFileJson["locations"];
|
||||||
|
json hashJson = spoilerFileJson["file_hash"];
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
for (auto it = hashJson.begin(); it != hashJson.end(); ++it) {
|
||||||
|
//gSaveContext.seedIcons[index] = gSeedTextures[it.value()];
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
index = 0;
|
||||||
for (auto it = locationsJson.begin(); it != locationsJson.end(); ++it) {
|
for (auto it = locationsJson.begin(); it != locationsJson.end(); ++it) {
|
||||||
if (it->is_structured()) {
|
if (it->is_structured()) {
|
||||||
json itemJson = *it;
|
json itemJson = *it;
|
||||||
|
@ -679,6 +691,17 @@ void Randomizer::ParseItemLocations(std::string spoilerFileName) {
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
||||||
|
success = true;
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
CVar_SetS32("gRandomizer", 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 Randomizer::GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 sceneNum, s16 actorParams, s32 homePosX, s32 homePosY, s32 homePosZ) {
|
s32 Randomizer::GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 sceneNum, s16 actorParams, s32 homePosX, s32 homePosY, s32 homePosZ) {
|
||||||
|
|
|
@ -21,8 +21,8 @@ class Randomizer {
|
||||||
~Randomizer();
|
~Randomizer();
|
||||||
|
|
||||||
s16 GetItemModelFromId(s16 itemId);
|
s16 GetItemModelFromId(s16 itemId);
|
||||||
void LoadItemLocations();
|
void LoadItemLocations(const char* spoilerFileName);
|
||||||
void ParseItemLocations(std::string spoilerfilename);
|
void ParseItemLocations(const char* spoilerFileName);
|
||||||
s32 GetRandomizedItemId(GetItemID ogId, s16 actorId = -1, s16 sceneNum = -1, s16 actorParams = -1, s32 homePosX = 0, s32 homePosY = 0, s32 homePosZ = 0);
|
s32 GetRandomizedItemId(GetItemID ogId, s16 actorId = -1, s16 sceneNum = -1, s16 actorParams = -1, s32 homePosX = 0, s32 homePosY = 0, s32 homePosZ = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1000,12 +1000,12 @@ extern "C" s16 GetItemModelFromId(s16 itemId) {
|
||||||
return OTRGlobals::Instance->gRandomizer->GetItemModelFromId(itemId);
|
return OTRGlobals::Instance->gRandomizer->GetItemModelFromId(itemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void LoadItemLocations() {
|
extern "C" void LoadItemLocations(const char* spoilerFileName) {
|
||||||
OTRGlobals::Instance->gRandomizer->LoadItemLocations();
|
OTRGlobals::Instance->gRandomizer->LoadItemLocations(spoilerFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void ParseItemLocations(const char* spoilerfilename) {
|
extern "C" void ParseItemLocations(const char* spoilerFileName) {
|
||||||
OTRGlobals::Instance->gRandomizer->ParseItemLocations(spoilerfilename);
|
OTRGlobals::Instance->gRandomizer->ParseItemLocations(spoilerFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" s32 GetRandomizedItemId(GetItemID ogId, s16 sceneNum, s16 actorParams) {
|
extern "C" s32 GetRandomizedItemId(GetItemID ogId, s16 sceneNum, s16 actorParams) {
|
||||||
|
|
|
@ -74,6 +74,7 @@ int AudioPlayer_GetDesiredBuffered(void);
|
||||||
void AudioPlayer_Play(const uint8_t* buf, uint32_t len);
|
void AudioPlayer_Play(const uint8_t* buf, uint32_t len);
|
||||||
void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples);
|
void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples);
|
||||||
int Controller_ShouldRumble(size_t i);
|
int Controller_ShouldRumble(size_t i);
|
||||||
|
void LoadItemLocations(const char* spoilerFileName);
|
||||||
void ParseItemLocations(const char* spoilerfilename);
|
void ParseItemLocations(const char* spoilerfilename);
|
||||||
s32 GetRandomizedItemId(GetItemID ogId, s16 sceneNum, s16 actorParams);
|
s32 GetRandomizedItemId(GetItemID ogId, s16 sceneNum, s16 actorParams);
|
||||||
s32 GetRandomizedItemIdFromActor(GetItemID ogId, s16 actorId);
|
s32 GetRandomizedItemIdFromActor(GetItemID ogId, s16 actorId);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "textures/title_static/title_static.h"
|
#include "textures/title_static/title_static.h"
|
||||||
#include "textures/parameter_static/parameter_static.h"
|
#include "textures/parameter_static/parameter_static.h"
|
||||||
|
#include <textures/icon_item_static/icon_item_static.h>
|
||||||
|
|
||||||
static s16 sUnused = 106;
|
static s16 sUnused = 106;
|
||||||
|
|
||||||
|
@ -63,6 +64,7 @@ void FileChoose_InitModeUpdate(GameState* thisx) {
|
||||||
this->configMode = CM_FADE_IN_START;
|
this->configMode = CM_FADE_IN_START;
|
||||||
this->nextTitleLabel = FS_TITLE_OPEN_FILE;
|
this->nextTitleLabel = FS_TITLE_OPEN_FILE;
|
||||||
osSyncPrintf("Sram Start─Load 》》》》》 ");
|
osSyncPrintf("Sram Start─Load 》》》》》 ");
|
||||||
|
CVar_SetS32("gRandomizer", 0);
|
||||||
Sram_VerifyAndLoadAllSaves(this, &this->sramCtx);
|
Sram_VerifyAndLoadAllSaves(this, &this->sramCtx);
|
||||||
osSyncPrintf("終了!!!\n");
|
osSyncPrintf("終了!!!\n");
|
||||||
}
|
}
|
||||||
|
@ -163,6 +165,65 @@ void FileChoose_FinishFadeIn(GameState* thisx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char tex[512];
|
||||||
|
uint16_t width;
|
||||||
|
uint16_t height;
|
||||||
|
uint8_t im_fmt;
|
||||||
|
uint8_t im_siz;
|
||||||
|
} Sprite;
|
||||||
|
|
||||||
|
Sprite sprDPad = { gHookshotIconTex, 32, 32, G_IM_FMT_RGBA, G_IM_SIZ_32b };
|
||||||
|
|
||||||
|
void SpriteLoad(FileChooseContext* this, Sprite* sprite) {
|
||||||
|
OPEN_DISPS(this->state.gfxCtx, "gfx.c", 12);
|
||||||
|
|
||||||
|
if (sprite->im_siz == G_IM_SIZ_16b) {
|
||||||
|
gDPLoadTextureBlock(POLY_OPA_DISP++, sprite->tex, sprite->im_fmt,
|
||||||
|
G_IM_SIZ_16b, // @TEMP until I figure out how to use sprite->im_siz
|
||||||
|
sprite->width, sprite->height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP,
|
||||||
|
G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
|
||||||
|
} else {
|
||||||
|
gDPLoadTextureBlock(POLY_OPA_DISP++, sprite->tex, sprite->im_fmt,
|
||||||
|
G_IM_SIZ_32b, // @TEMP until I figure out how to use sprite->im_siz
|
||||||
|
sprite->width, sprite->height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP,
|
||||||
|
G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
|
||||||
|
}
|
||||||
|
|
||||||
|
CLOSE_DISPS(this->state.gfxCtx, "gfx.c", 40);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpriteDraw(FileChooseContext* this, Sprite* sprite, int left, int top, int width, int height) {
|
||||||
|
int width_factor = (1 << 10) * sprite->width / width;
|
||||||
|
int height_factor = (1 << 10) * sprite->height / height;
|
||||||
|
|
||||||
|
OPEN_DISPS(this->state.gfxCtx, "gfx.c", 51);
|
||||||
|
|
||||||
|
gSPWideTextureRectangle(POLY_OPA_DISP++, left << 2, top << 2, (left + width) << 2, (top + height) << 2,
|
||||||
|
G_TX_RENDERTILE,
|
||||||
|
0, 0, width_factor, height_factor);
|
||||||
|
|
||||||
|
CLOSE_DISPS(this->state.gfxCtx, "gfx.c", 62);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawSeedHashSprites(FileChooseContext* this) {
|
||||||
|
OPEN_DISPS(this->state.gfxCtx, "dpad.c", 60);
|
||||||
|
gDPPipeSync(POLY_OPA_DISP++);
|
||||||
|
gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
|
||||||
|
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF);
|
||||||
|
|
||||||
|
// Draw Seed Icons
|
||||||
|
u16 xStart = 64;
|
||||||
|
for (u8 i = 0; i < 5; i++) {
|
||||||
|
SpriteLoad(this, &sprDPad);
|
||||||
|
SpriteDraw(this, &sprDPad, xStart + (40 * i), 10, 24, 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
gDPPipeSync(POLY_OPA_DISP++);
|
||||||
|
|
||||||
|
CLOSE_DISPS(this->state.gfxCtx, "dpad.c", 113);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the cursor and wait for the player to select a button to change menus accordingly.
|
* Update the cursor and wait for the player to select a button to change menus accordingly.
|
||||||
* If an empty file is selected, enter the name entry config mode.
|
* If an empty file is selected, enter the name entry config mode.
|
||||||
|
@ -814,6 +875,8 @@ void FileChoose_DrawFileInfo(GameState* thisx, s16 fileIndex, s16 isActive) {
|
||||||
s16 j;
|
s16 j;
|
||||||
s16 deathCountSplit[3];
|
s16 deathCountSplit[3];
|
||||||
|
|
||||||
|
DrawSeedHashSprites(this);
|
||||||
|
|
||||||
if (1) {}
|
if (1) {}
|
||||||
|
|
||||||
OPEN_DISPS(this->state.gfxCtx, "../z_file_choose.c", 1709);
|
OPEN_DISPS(this->state.gfxCtx, "../z_file_choose.c", 1709);
|
||||||
|
@ -1458,7 +1521,7 @@ void FileChoose_LoadGame(GameState* thisx) {
|
||||||
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
||||||
gSaveContext.fileNum = this->buttonIndex;
|
gSaveContext.fileNum = this->buttonIndex;
|
||||||
Sram_OpenSave(&this->sramCtx);
|
Sram_OpenSave(&this->sramCtx);
|
||||||
LoadItemLocations();
|
// LoadItemLocations();
|
||||||
gSaveContext.gameMode = 0;
|
gSaveContext.gameMode = 0;
|
||||||
SET_NEXT_GAMESTATE(&this->state, Select_Init, SelectContext);
|
SET_NEXT_GAMESTATE(&this->state, Select_Init, SelectContext);
|
||||||
this->state.running = false;
|
this->state.running = false;
|
||||||
|
@ -1466,7 +1529,7 @@ void FileChoose_LoadGame(GameState* thisx) {
|
||||||
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
||||||
gSaveContext.fileNum = this->buttonIndex;
|
gSaveContext.fileNum = this->buttonIndex;
|
||||||
Sram_OpenSave(&this->sramCtx);
|
Sram_OpenSave(&this->sramCtx);
|
||||||
LoadItemLocations();
|
// LoadItemLocations();
|
||||||
gSaveContext.gameMode = 0;
|
gSaveContext.gameMode = 0;
|
||||||
SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext);
|
SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext);
|
||||||
this->state.running = false;
|
this->state.running = false;
|
||||||
|
|
|
@ -449,7 +449,7 @@ void FileChoose_DrawNameEntry(GameState* thisx) {
|
||||||
|
|
||||||
dayTime = ((void)0, gSaveContext.dayTime);
|
dayTime = ((void)0, gSaveContext.dayTime);
|
||||||
|
|
||||||
ParseItemLocations("blarg");
|
// ParseItemLocations("blarg");
|
||||||
|
|
||||||
Sram_InitSave(this, &this->sramCtx);
|
Sram_InitSave(this, &this->sramCtx);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue