diff --git a/src/studio.c b/src/studio.c index 6bc80ff..4a12a2f 100644 --- a/src/studio.c +++ b/src/studio.c @@ -1875,6 +1875,7 @@ Studio* studioInit(s32 argc, char **argv, s32 samplerate, const char* folder, Sy studioImpl.studio.close = studioClose; studioImpl.studio.updateProject = updateStudioProject; studioImpl.studio.exit = exitStudio; + studioImpl.studio.config = getConfig; return &studioImpl.studio; } diff --git a/src/studio.h b/src/studio.h index d1a0ef9..df36f7a 100644 --- a/src/studio.h +++ b/src/studio.h @@ -64,50 +64,6 @@ #define PROJECT_JS_EXT ".js" #define PROJECT_WREN_EXT ".wren" -typedef struct -{ - struct - { - struct - { - s32 arrow; - s32 hand; - s32 ibeam; - - bool pixelPerfect; - } cursor; - - struct - { - tic_code_theme syntax; - - u8 bg; - u8 select; - u8 cursor; - bool shadow; - } code; - - struct - { - struct - { - u8 alpha; - } touch; - - } gamepad; - - } theme; - - s32 gifScale; - s32 gifLength; - - bool checkNewVersion; - bool noSound; - bool useVsync; - bool showSync; - -} StudioConfig; - typedef enum { TIC_START_MODE, @@ -185,7 +141,7 @@ void showTooltip(const char* text); tic_key* getKeymap(); -TIC80_API const StudioConfig* getConfig(); +const StudioConfig* getConfig(); void setSpritePixel(tic_tile* tiles, s32 x, s32 y, u8 color); u8 getSpritePixel(tic_tile* tiles, s32 x, s32 y); diff --git a/src/system.c b/src/system.c index 540ec81..4a44129 100644 --- a/src/system.c +++ b/src/system.c @@ -322,7 +322,7 @@ static bool checkTouch(const SDL_Rect* rect, s32* x, s32* y) if (!platform.gamepad.show) { - platform.gamepad.alpha = getConfig()->theme.gamepad.touch.alpha; + platform.gamepad.alpha = platform.studio->config()->theme.gamepad.touch.alpha; SDL_SetTextureAlphaMod(platform.gamepad.texture, platform.gamepad.alpha); platform.gamepad.show = true; return false; @@ -761,7 +761,7 @@ static void blitCursor(const u8* in) SDL_GetMouseState(&dst.x, &dst.y); - if(getConfig()->theme.cursor.pixelPerfect) + if(platform.studio->config()->theme.cursor.pixelPerfect) { dst.x -= (dst.x - rect.x) % scale; dst.y -= (dst.y - rect.y) % scale; @@ -779,10 +779,10 @@ static void renderCursor() { case tic_cursor_hand: { - if(getConfig()->theme.cursor.hand >= 0) + if(platform.studio->config()->theme.cursor.hand >= 0) { SDL_ShowCursor(SDL_DISABLE); - blitCursor(platform.studio->tic->config.bank0.tiles.data[getConfig()->theme.cursor.hand].data); + blitCursor(platform.studio->tic->config.bank0.tiles.data[platform.studio->config()->theme.cursor.hand].data); } else { @@ -793,10 +793,10 @@ static void renderCursor() break; case tic_cursor_ibeam: { - if(getConfig()->theme.cursor.ibeam >= 0) + if(platform.studio->config()->theme.cursor.ibeam >= 0) { SDL_ShowCursor(SDL_DISABLE); - blitCursor(platform.studio->tic->config.bank0.tiles.data[getConfig()->theme.cursor.ibeam].data); + blitCursor(platform.studio->tic->config.bank0.tiles.data[platform.studio->config()->theme.cursor.ibeam].data); } else { @@ -807,10 +807,10 @@ static void renderCursor() break; default: { - if(getConfig()->theme.cursor.arrow >= 0) + if(platform.studio->config()->theme.cursor.arrow >= 0) { SDL_ShowCursor(SDL_DISABLE); - blitCursor(platform.studio->tic->config.bank0.tiles.data[getConfig()->theme.cursor.arrow].data); + blitCursor(platform.studio->tic->config.bank0.tiles.data[platform.studio->config()->theme.cursor.arrow].data); } else { @@ -1039,7 +1039,7 @@ static s32 start(s32 argc, char **argv, const char* folder) #if defined(__CHIP__) SDL_RENDERER_SOFTWARE #else - SDL_RENDERER_ACCELERATED | (getConfig()->useVsync ? SDL_RENDERER_PRESENTVSYNC : 0) + SDL_RENDERER_ACCELERATED | (platform.studio->config()->useVsync ? SDL_RENDERER_PRESENTVSYNC : 0) #endif ); @@ -1049,7 +1049,7 @@ static s32 start(s32 argc, char **argv, const char* folder) #if defined(__EMSCRIPTEN__) - emscripten_set_main_loop(getConfig()->useVsync ? tick : emstick, 0, 1); + emscripten_set_main_loop(platform.studio->config()->useVsync ? tick : emstick, 0, 1); #else { diff --git a/src/system.h b/src/system.h index b7b333b..33ef9e6 100644 --- a/src/system.h +++ b/src/system.h @@ -24,6 +24,50 @@ typedef struct } System; +typedef struct +{ + struct + { + struct + { + s32 arrow; + s32 hand; + s32 ibeam; + + bool pixelPerfect; + } cursor; + + struct + { + tic_code_theme syntax; + + u8 bg; + u8 select; + u8 cursor; + bool shadow; + } code; + + struct + { + struct + { + u8 alpha; + } touch; + + } gamepad; + + } theme; + + s32 gifScale; + s32 gifLength; + + bool checkNewVersion; + bool noSound; + bool useVsync; + bool showSync; + +} StudioConfig; + typedef struct { tic_mem* tic; @@ -33,6 +77,7 @@ typedef struct void (*exit)(); void (*close)(); void (*updateProject)(); + const StudioConfig* (*config)(); } Studio;