added global methods to get bank data
This commit is contained in:
parent
7f04a7963a
commit
4da11f995d
84
src/studio.c
84
src/studio.c
|
@ -74,6 +74,15 @@ typedef struct
|
||||||
|
|
||||||
} MouseState;
|
} MouseState;
|
||||||
|
|
||||||
|
static const EditorMode Modes[] =
|
||||||
|
{
|
||||||
|
TIC_CODE_MODE,
|
||||||
|
TIC_SPRITE_MODE,
|
||||||
|
TIC_MAP_MODE,
|
||||||
|
TIC_SFX_MODE,
|
||||||
|
TIC_MUSIC_MODE,
|
||||||
|
};
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
tic80_local* tic80local;
|
tic80_local* tic80local;
|
||||||
|
@ -147,7 +156,21 @@ static struct
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
bool show;
|
bool show;
|
||||||
s32 index;
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
s32 code;
|
||||||
|
s32 tiles;
|
||||||
|
s32 map;
|
||||||
|
s32 sfx;
|
||||||
|
s32 music;
|
||||||
|
} index;
|
||||||
|
|
||||||
|
s32 indexes[COUNT_OF(Modes)];
|
||||||
|
};
|
||||||
|
|
||||||
} bank;
|
} bank;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
@ -260,7 +283,6 @@ static struct
|
||||||
.bank =
|
.bank =
|
||||||
{
|
{
|
||||||
.show = false,
|
.show = false,
|
||||||
.index = 0,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
.popup =
|
.popup =
|
||||||
|
@ -288,6 +310,41 @@ static struct
|
||||||
.floatSamples = NULL,
|
.floatSamples = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tic_tiles* getBankTiles()
|
||||||
|
{
|
||||||
|
return &studio.tic->cart.banks[studio.bank.index.tiles].tiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
tic_tiles* getBankSprites()
|
||||||
|
{
|
||||||
|
return &studio.tic->cart.banks[studio.bank.index.tiles].sprites;
|
||||||
|
}
|
||||||
|
|
||||||
|
tic_map* getBankMap()
|
||||||
|
{
|
||||||
|
return &studio.tic->cart.banks[studio.bank.index.map].map;
|
||||||
|
}
|
||||||
|
|
||||||
|
tic_sfx* getBankSfx()
|
||||||
|
{
|
||||||
|
return &studio.tic->cart.banks[studio.bank.index.sfx].sfx;
|
||||||
|
}
|
||||||
|
|
||||||
|
tic_music* getBankMusic()
|
||||||
|
{
|
||||||
|
return &studio.tic->cart.banks[studio.bank.index.music].music;
|
||||||
|
}
|
||||||
|
|
||||||
|
tic_code* getBankCode()
|
||||||
|
{
|
||||||
|
return &studio.tic->cart.banks[studio.bank.index.code].code;
|
||||||
|
}
|
||||||
|
|
||||||
|
tic_palette* getBankPalette()
|
||||||
|
{
|
||||||
|
return &studio.tic->cart.banks[studio.bank.index.tiles].palette;
|
||||||
|
}
|
||||||
|
|
||||||
void playSystemSfx(s32 id)
|
void playSystemSfx(s32 id)
|
||||||
{
|
{
|
||||||
const tic_sound_effect* effect = &studio.tic->config.sfx.data[id];
|
const tic_sound_effect* effect = &studio.tic->config.sfx.data[id];
|
||||||
|
@ -429,15 +486,6 @@ void showTooltip(const char* text)
|
||||||
strcpy(studio.tooltip.text, text);
|
strcpy(studio.tooltip.text, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const EditorMode Modes[] =
|
|
||||||
{
|
|
||||||
TIC_CODE_MODE,
|
|
||||||
TIC_SPRITE_MODE,
|
|
||||||
TIC_MAP_MODE,
|
|
||||||
TIC_SFX_MODE,
|
|
||||||
TIC_MUSIC_MODE,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void drawExtrabar(tic_mem* tic)
|
static void drawExtrabar(tic_mem* tic)
|
||||||
{
|
{
|
||||||
enum {Size = 7};
|
enum {Size = 7};
|
||||||
|
@ -553,6 +601,14 @@ static void drawBankIcon(s32 x, s32 y)
|
||||||
};
|
};
|
||||||
|
|
||||||
bool over = false;
|
bool over = false;
|
||||||
|
s32 mode = 0;
|
||||||
|
|
||||||
|
for(s32 i = 0; i < COUNT_OF(Modes); i++)
|
||||||
|
if(Modes[i] == studio.mode)
|
||||||
|
{
|
||||||
|
mode = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if(checkMousePos(&rect))
|
if(checkMousePos(&rect))
|
||||||
{
|
{
|
||||||
|
@ -583,15 +639,15 @@ static void drawBankIcon(s32 x, s32 y)
|
||||||
over = true;
|
over = true;
|
||||||
|
|
||||||
if(checkMouseClick(&rect, SDL_BUTTON_LEFT))
|
if(checkMouseClick(&rect, SDL_BUTTON_LEFT))
|
||||||
studio.bank.index = i;
|
studio.bank.indexes[mode] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i == studio.bank.index)
|
if(i == studio.bank.indexes[mode])
|
||||||
{
|
{
|
||||||
tic->api.rect(tic, rect.x, rect.y, rect.w, rect.h, tic_color_red);
|
tic->api.rect(tic, rect.x, rect.y, rect.w, rect.h, tic_color_red);
|
||||||
}
|
}
|
||||||
|
|
||||||
tic->api.draw_char(tic, '0' + i, rect.x+1, rect.y+1, i == studio.bank.index ? tic_color_white : over ? tic_color_red : tic_color_peach);
|
tic->api.draw_char(tic, '0' + i, rect.x+1, rect.y+1, i == studio.bank.indexes[mode] ? tic_color_white : over ? tic_color_red : tic_color_peach);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -199,3 +199,11 @@ void gotoCode();
|
||||||
void gotoSurf();
|
void gotoSurf();
|
||||||
void exitFromGameMenu();
|
void exitFromGameMenu();
|
||||||
void runProject();
|
void runProject();
|
||||||
|
|
||||||
|
tic_tiles* getBankTiles();
|
||||||
|
tic_tiles* getBankSprites();
|
||||||
|
tic_map* getBankMap();
|
||||||
|
tic_sfx* getBankSfx();
|
||||||
|
tic_music* getBankMusic();
|
||||||
|
tic_code* getBankCode();
|
||||||
|
tic_palette* getBankPalette();
|
||||||
|
|
Loading…
Reference in New Issue