Adds controller button support for skillbar
This commit is contained in:
parent
c3b2b6f214
commit
2919ebf97f
|
@ -28,6 +28,26 @@
|
|||
#include "update_data.h"
|
||||
#include "gui.h"
|
||||
|
||||
static bool controller_mode = false;
|
||||
|
||||
void
|
||||
skillbar_set_controller_mode(bool ctrl_mode)
|
||||
{
|
||||
controller_mode = ctrl_mode;
|
||||
}
|
||||
|
||||
static Sprite *
|
||||
create_controller_button_sprite(Position pos, SDL_Rect clip)
|
||||
{
|
||||
Texture *t = texturecache_add("Extras/Controller.png");
|
||||
Sprite *s = sprite_create();
|
||||
sprite_set_texture(s, t, 0);
|
||||
s->pos = pos;
|
||||
s->clip = clip;
|
||||
s->dim = DIM(16, 16);
|
||||
return s;
|
||||
}
|
||||
|
||||
static void
|
||||
load_texture(SkillBar *bar, const char *path, SDL_Renderer *renderer)
|
||||
{
|
||||
|
@ -35,6 +55,7 @@ load_texture(SkillBar *bar, const char *path, SDL_Renderer *renderer)
|
|||
t->dim.width = 16;
|
||||
t->dim.height = 16;
|
||||
|
||||
if (!controller_mode) {
|
||||
for (unsigned int i = 0; i < 5; ++i) {
|
||||
char buffer[4];
|
||||
Sprite *s = sprite_create();
|
||||
|
@ -46,6 +67,14 @@ load_texture(SkillBar *bar, const char *path, SDL_Renderer *renderer)
|
|||
texture_load_from_text(s->textures[0], buffer, C_YELLOW, C_BLACK, renderer);
|
||||
linkedlist_append(&bar->sprites, s);
|
||||
}
|
||||
} else {
|
||||
Uint8 i = 0;
|
||||
linkedlist_append(&bar->sprites, create_controller_button_sprite(POS(i++ * 32 + 16, 16), CLIP16(0, 0)));
|
||||
linkedlist_append(&bar->sprites, create_controller_button_sprite(POS(i++ * 32 + 16, 16), CLIP16(16, 0)));
|
||||
linkedlist_append(&bar->sprites, create_controller_button_sprite(POS(i++ * 32 + 16, 16), CLIP16(32, 0)));
|
||||
linkedlist_append(&bar->sprites, create_controller_button_sprite(POS(i++ * 32 + 16, 16), CLIP16(48, 0)));
|
||||
linkedlist_append(&bar->sprites, create_controller_button_sprite(POS(i++ * 32 + 16, 20), CLIP16(48, 48)));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -45,6 +45,9 @@ typedef struct SkillBar {
|
|||
Uint32 lastActivation;
|
||||
} SkillBar;
|
||||
|
||||
void
|
||||
skillbar_set_controller_mode(bool ctrl_mode);
|
||||
|
||||
SkillBar *
|
||||
skillbar_create(Camera*);
|
||||
|
||||
|
|
Loading…
Reference in New Issue