Merge branch 'master' into add-squirrel

This commit is contained in:
Graham Clemo 2018-08-02 20:47:12 +01:00
commit 3e393ccec0
7 changed files with 42 additions and 9 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -86,6 +86,16 @@ static void readConfigCrtMonitor(Config* config, lua_State* lua)
lua_pop(lua, 1); lua_pop(lua, 1);
} }
static void readConfigUiScale(Config* config, lua_State* lua)
{
lua_getglobal(lua, "UI_SCALE");
if(lua_isinteger(lua, -1))
config->data.uiScale = lua_tointeger(lua, -1);
lua_pop(lua, 1);
}
static void readConfigCrtShader(Config* config, lua_State* lua) static void readConfigCrtShader(Config* config, lua_State* lua)
{ {
lua_getglobal(lua, "CRT_SHADER"); lua_getglobal(lua, "CRT_SHADER");
@ -277,6 +287,7 @@ static void readConfig(Config* config)
readConfigNoSound(config, lua); readConfigNoSound(config, lua);
readConfigShowSync(config, lua); readConfigShowSync(config, lua);
readConfigCrtMonitor(config, lua); readConfigCrtMonitor(config, lua);
readConfigUiScale(config, lua);
readTheme(config, lua); readTheme(config, lua);
} }

View File

@ -3089,6 +3089,24 @@ static bool cmdInjectMap(Console* console, const char* param, const char* name)
return done; return done;
} }
static bool checkUIScale(Console* console, const char* param, const char* value)
{
bool done = false;
if(strcmp(param, "-uiscale") == 0)
{
s32 scale = atoi(value);
if(scale > 0)
{
console->config->data.uiScale = scale;
done = true;
}
}
return done;
}
void initConsole(Console* console, tic_mem* tic, FileSystem* fs, Config* config, s32 argc, char **argv) void initConsole(Console* console, tic_mem* tic, FileSystem* fs, Config* config, s32 argc, char **argv)
{ {
if(!console->buffer) console->buffer = malloc(BufferSize(tic)); if(!console->buffer) console->buffer = malloc(BufferSize(tic));
@ -3191,7 +3209,8 @@ void initConsole(Console* console, tic_mem* tic, FileSystem* fs, Config* config,
if(cmdInjectCode(console, first, second) if(cmdInjectCode(console, first, second)
|| cmdInjectSprites(console, first, second) || cmdInjectSprites(console, first, second)
|| cmdInjectMap(console, first, second)) || cmdInjectMap(console, first, second)
|| checkUIScale(console, first, second))
argp |= mask; argp |= mask;
} }
} }

View File

@ -24,7 +24,7 @@
#include "fs.h" #include "fs.h"
#define DIALOG_WIDTH (TIC80_WIDTH/2) #define DIALOG_WIDTH (TIC80_WIDTH/2)
#define DIALOG_HEIGHT (TIC80_HEIGHT/2-TOOLBAR_SIZE) #define DIALOG_HEIGHT (TIC80_HEIGHT/2)
static const char* Rows[] = static const char* Rows[] =
{ {
@ -32,7 +32,8 @@ static const char* Rows[] =
"RESET GAME", "RESET GAME",
"GAMEPAD CONFIG", "GAMEPAD CONFIG",
"", "",
"EXIT TO TIC-80", "CLOSE GAME",
"QUIT TIC-80",
}; };
static void resumeGame(Menu* menu) static void resumeGame(Menu* menu)
@ -56,12 +57,12 @@ static void gamepadConfig(Menu* menu)
menu->gamepad.tab = 0; menu->gamepad.tab = 0;
} }
static void exitToTIC(Menu* menu) static void closeGame(Menu* menu)
{ {
exitFromGameMenu(); exitFromGameMenu();
} }
static void(*const MenuHandlers[])(Menu*) = {resumeGame, resetGame, gamepadConfig, NULL, exitToTIC}; static void(*const MenuHandlers[])(Menu*) = {resumeGame, resetGame, gamepadConfig, NULL, closeGame, exitStudio};
static tic_rect getRect(Menu* menu) static tic_rect getRect(Menu* menu)
{ {
@ -252,7 +253,7 @@ static void drawGamepadMenu(Menu* menu)
static const char Label[] = "BACK"; static const char Label[] = "BACK";
tic_rect rect = {dlgRect.x + 25, dlgRect.y + 49, (sizeof(Label)-1)*tic->font.width, tic->font.height}; tic_rect rect = {dlgRect.x + 25, dlgRect.y + 56, (sizeof(Label)-1)*tic->font.width, tic->font.height};
bool over = false; bool over = false;
bool down = false; bool down = false;

View File

@ -12,7 +12,6 @@
#include <emscripten.h> #include <emscripten.h>
#endif #endif
#define STUDIO_UI_SCALE 3
#define STUDIO_PIXEL_FORMAT GPU_FORMAT_RGBA #define STUDIO_PIXEL_FORMAT GPU_FORMAT_RGBA
#define TEXTURE_SIZE (TIC80_FULLWIDTH) #define TEXTURE_SIZE (TIC80_FULLWIDTH)
#define OFFSET_LEFT ((TIC80_FULLWIDTH-TIC80_WIDTH)/2) #define OFFSET_LEFT ((TIC80_FULLWIDTH-TIC80_WIDTH)/2)
@ -1180,7 +1179,8 @@ static s32 start(s32 argc, char **argv, const char* folder)
platform.studio = studioInit(argc, argv, platform.audio.spec.freq, folder, &systemInterface); platform.studio = studioInit(argc, argv, platform.audio.spec.freq, folder, &systemInterface);
enum{Width = TIC80_FULLWIDTH * STUDIO_UI_SCALE, Height = TIC80_FULLHEIGHT * STUDIO_UI_SCALE}; const s32 Width = TIC80_FULLWIDTH * platform.studio->config()->uiScale;
const s32 Height = TIC80_FULLHEIGHT * platform.studio->config()->uiScale;
platform.window = SDL_CreateWindow( TIC_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, platform.window = SDL_CreateWindow( TIC_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
Width, Height, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE| SDL_WINDOW_OPENGL); Width, Height, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE| SDL_WINDOW_OPENGL);

View File

@ -82,6 +82,8 @@ typedef struct
const char* crtShader; const char* crtShader;
const tic_cartridge* cart; const tic_cartridge* cart;
s32 uiScale;
} StudioConfig; } StudioConfig;
typedef struct typedef struct