system cursor works

This commit is contained in:
BADIM-PC\Vadim 2018-02-12 14:51:57 +03:00
parent c3e7ff8e43
commit 0bbda15e1c
3 changed files with 57 additions and 6 deletions

View File

@ -513,7 +513,10 @@ static void processGamepad()
static void pollEvent()
{
tic80_input* input = &platform.studio->tic->ram.input;
input->mouse.btns = 0;
{
input->mouse.btns = 0;
}
SDL_Event event;
@ -784,6 +787,44 @@ static void renderGamepad()
platform.gamepad.show = false;
}
static void renderCursor()
{
if(platform.studio->tic->ram.vram.vars.cursor.system)
{
SDL_SystemCursor sdlCursor = SDL_SYSTEM_CURSOR_ARROW;
switch(platform.studio->tic->ram.vram.vars.cursor.sprite)
{
case tic_cursor_hand: sdlCursor = SDL_SYSTEM_CURSOR_HAND; break;
case tic_cursor_ibeam: sdlCursor = SDL_SYSTEM_CURSOR_IBEAM; break;
default: sdlCursor = SDL_SYSTEM_CURSOR_ARROW;
}
SDL_SetCursor(SDL_CreateSystemCursor(sdlCursor));
}
else
{
// render cursor here
}
// if(studioImpl.mode == TIC_RUN_MODE && !studioImpl.studio.tic->input.mouse)
// {
// SDL_ShowCursor(SDL_DISABLE);
// return;
// }
// if(studioImpl.mode == TIC_RUN_MODE && studioImpl.studio.tic->ram.vram.vars.cursor)
// {
// SDL_ShowCursor(SDL_DISABLE);
// blitCursor(studioImpl.studio.tic->ram.sprites.data[studioImpl.studio.tic->ram.vram.vars.cursor].data);
// return;
// }
// SDL_ShowCursor(getConfig()->theme.cursor.sprite >= 0 ? SDL_DISABLE : SDL_ENABLE);
// if(getConfig()->theme.cursor.sprite >= 0)
// blitCursor(studioImpl.studio.tic->config.bank0.tiles.data[getConfig()->theme.cursor.sprite].data);
}
static void tick()
{
pollEvent();
@ -808,6 +849,8 @@ static void tick()
blitTexture();
renderCursor();
// if(platform.mode == TIC_RUN_MODE && platform.studio->tic->input.gamepad)
renderGamepad();

View File

@ -130,7 +130,7 @@ static struct
// SDL_Texture* texture;
// const u8* src;
tic_cursor system;
// tic_cursor system;
} mouse;
struct
@ -1153,7 +1153,6 @@ bool checkMouseDown(const tic_rect* rect, s32 button)
return state->down && pointInRect(&state->start, rect);
}
bool getGesturePos(tic_point* pos)
{
if(studioImpl.gesture.active)
@ -1168,8 +1167,9 @@ bool getGesturePos(tic_point* pos)
void setCursor(tic_cursor id)
{
if(id != tic_cursor_arrow)
studioImpl.mouse.system = id;
tic_mem* tic = studioImpl.studio.tic;
tic->ram.vram.vars.cursor.sprite = id;
}
void hideDialog()
@ -2969,6 +2969,9 @@ static void processMouseStates()
tic_mem* tic = studioImpl.studio.tic;
tic->ram.vram.vars.cursor.sprite = tic_cursor_arrow;
tic->ram.vram.vars.cursor.system = true;
for(int i = 0; i < COUNT_OF(studioImpl.mouse.state); i++)
{
MouseState* state = &studioImpl.mouse.state[i];

View File

@ -385,7 +385,12 @@ typedef union
s8 y;
} offset;
u8 cursor;
struct
{
u8 sprite:7;
bool system:1;
} cursor;
} vars;
u8 reserved[4];