Got this texture stuff working

This commit is contained in:
Linus Probert 2018-10-09 14:19:59 +02:00
parent 0723f62559
commit e845195823
3 changed files with 124 additions and 118 deletions

View File

@ -59,74 +59,74 @@
#endif // STEAM_BUILD #endif // STEAM_BUILD
static char *artifacts_tooltip[] = { static char *artifacts_tooltip[] = {
"CONGRATULATIONS!", "CONGRATULATIONS!", "",
"", "",
" You just picked up your first artifact!", " You just picked up your first artifact!", "",
"", "",
" Your current artifacts and corresponding level are", " Your current artifacts and corresponding level are", "",
" listed next to your skills." " listed next to your skills." "",
"", "",
"", "",
" Artifacts have mystical effects that improve your offensive", " Artifacts have mystical effects that improve your offensive", "",
" or defensive advantage in the dungeon. However it is sometimes", " or defensive advantage in the dungeon. However it is sometimes", "",
" hard to know what effect an artifact has.", " hard to know what effect an artifact has.", "",
"", "",
"", "",
" Perhaps an experienced dungeoner will know more?", " Perhaps an experienced dungeoner will know more?", "",
"", "",
"", "",
"Press ESC to close", "Press ", "ESC", " to close", "",
NULL NULL
}; };
static char *skills_tooltip[] = { static char *skills_tooltip[] = {
"CONGRATULATIONS!", "CONGRATULATIONS!", "",
"", "",
" You have aquired a new level and a new skill!", " You have aquired a new level and a new skill!", "",
"", "",
" Skills are listed in the bar below the game screen.", " Skills are listed in the bar below the game screen.", "",
"", "",
"", "",
" SKILL INFO: SHIFT + <NUM>", " SKILL INFO: SHIFT + <NUM>", "",
" Where <NUM> is the skill number (1-5)", " Where <NUM> is the skill number (1-5)", "",
"", "",
" DISABLE TOOLTIPS: CTRL + D", " DISABLE TOOLTIPS: CTRL + D", "",
"", "",
"", "",
"Press ESC to close", "Press ", "ESC", " to close", "",
NULL NULL
}; };
static char *how_to_play_tooltip[] = { static char *how_to_play_tooltip[] = {
"HOW TO PLAY", "HOW TO PLAY", "",
"", "",
" NAVIGATION: Use ARROWS or WASD or HJKL to move", " NAVIGATION: Use ARROWS or WASD or HJKL to move", "",
"", "",
" ATTACK: Walk into a monster to attack it", " ATTACK: Walk into a monster to attack it", "",
"", "",
" HOLD TURN: Press SPACE", " HOLD TURN: Press SPACE", "",
"", "",
" THROW DAGGER: Press 4 then chose a direction (nav keys)", " THROW DAGGER: Press 4 then chose a direction (nav keys)", "",
"", "",
" DRINK HEALTH: Press 5 (if you need health and have potions)", " DRINK HEALTH: Press 5 (if you need health and have potions)", "",
"", "",
" TOGGLE MUSIC: CTRL + M", " TOGGLE MUSIC: CTRL + M", "",
"", "",
" TOGGLE SOUND: CTRL + S", " TOGGLE SOUND: CTRL + S", "",
"", "",
" TOGGLE FULLSCREEN: CTRL + F", " TOGGLE FULLSCREEN: CTRL + F", "",
"", "",
" TOGGLE MENU: ESC", " TOGGLE MENU: ", "ESC", "",
"", "",
" Your stats and inventory are listed in the right panel", " Your stats and inventory are listed in the right panel", "",
"", "",
"", "",
" GOOD LUCK!", " GOOD LUCK!", "",
" May your death be quick and painless...", " May your death be quick and painless...", "",
"", "",
"", "",
"", "",
"Press ESC to close", "Press ", "ESC", " to close", "",
NULL NULL
}; };

View File

@ -38,163 +38,163 @@
#include "tooltip.h" #include "tooltip.h"
static char *flurry_tooltip[] = { static char *flurry_tooltip[] = {
"FLURRY", "FLURRY", "",
"", "",
" Hits an adjecant enemy with a flurry of three strikes.", " Hits an adjecant enemy with a flurry of three strikes.", "",
" Each strike has the same odds of hitting as a regular attack", " Each strike has the same odds of hitting as a regular attack", "",
"", "",
"COOLDOWN:", "COOLDOWN:", "",
" 5 turns", " 5 turns", "",
"", "",
"USAGE:", "USAGE:", "",
" activate the skill (press 1)", " activate the skill (press ", "1", ")", "",
" followed by a direction (left, right, up or down)", " followed by a direction (left, right, up or down)", "",
"", "",
"", "",
"Press ESC to close", "Press ", "ESC", " to close", "", "",
NULL NULL
}; };
static char *bash_tooltip[] = { static char *bash_tooltip[] = {
"BASH", "BASH", "",
"", "",
" Bashes an adjecant enemy with your shield", " Bashes an adjecant enemy with your shield", "",
" On a successful hit the target will be stunned for 2 turns", " On a successful hit the target will be stunned for 2 turns", "",
"", "",
"COOLDOWN:", "COOLDOWN:", "",
" 3 turns", " 3 turns", "",
"", "",
"USAGE:", "USAGE:", "",
" activate the skill (press 2)", " activate the skill (press ", "2", ")", "",
" followed by a direction (left, right, up or down)", " followed by a direction (left, right, up or down)", "",
"", "",
"", "",
"Press ESC to close", "Press ", "ESC", " to close", "",
NULL NULL
}; };
static char *trip_tooltip[] = { static char *trip_tooltip[] = {
"TRIP", "TRIP", "",
"", "",
" Trips an adjecant enemy causing him to fall (move), in", " Trips an adjecant enemy causing him to fall (move), in", "",
" the direction you tripped it in.", " the direction you tripped it in.", "",
" On a successful hit the enemy will also be stunned." " On a successful hit the enemy will also be stunned." "",
"", "",
" This can be combined with traps and pits to great effect.", " This can be combined with traps and pits to great effect.", "",
"", "",
"COOLDOWN:", "COOLDOWN:", "",
" 3 turns", " 3 turns", "",
"", "",
"USAGE:", "USAGE:", "",
" activate the skill (press 2)", " activate the skill (press ", "2", ")", "",
" followed by a direction (left, right, up or down)", " followed by a direction (left, right, up or down)", "",
"", "",
"", "",
"Press ESC to close", "Press ", "ESC", " to close", "",
NULL NULL
}; };
static char *backstab_tooltip[] = { static char *backstab_tooltip[] = {
"BACKSTAB", "BACKSTAB", "",
"", "",
" You flip over an adjecant enemy taking it's place and", " You flip over an adjecant enemy taking it's place and", "",
" it taking yours, finnishing off with a stab in the back", " it taking yours, finnishing off with a stab in the back", "",
" of your foe.", " of your foe.", "",
" A successful attack will also leave the enemy stunned." " A successful attack will also leave the enemy stunned." "",
"", "",
"COOLDOWN:", "COOLDOWN:", "",
" 5 turns", " 5 turns", "",
"", "",
"USAGE:", "USAGE:", "",
" activate the skill (press 1)", " activate the skill (press ", "1", ")", "",
" followed by a direction (left, right, up or down)", " followed by a direction (left, right, up or down)", "",
"", "",
"", "",
"Press ESC to close", "Press ", "ESC", " to close", "",
NULL NULL
}; };
static char *phase_tooltip[] = { static char *phase_tooltip[] = {
"PHASE", "PHASE", "",
"", "",
" You phase out of existence for a time. While you are phased you", " You phase out of existence for a time. While you are phased you", "",
" are unaffected by gravity, traps and enemies won't see you.", " are unaffected by gravity, traps and enemies won't see you.", "",
" You can also pass through enemies.", " You can also pass through enemies.", "",
"", "",
" The effect lasts for 3 turns", " The effect lasts for 3 turns", "",
"", "",
"COOLDOWN:", "COOLDOWN:", "",
" 8 turns", " 8 turns", "",
"", "",
"USAGE:", "USAGE:",
" activate the skill (press 3)", " activate the skill (press ", "3", ")", "",
" then move as normal", " then move as normal", "",
"", "",
"", "",
"Press ESC to close", "Press ", "ESC", " to close", "",
NULL NULL
}; };
static char *charge_tooltip[] = { static char *charge_tooltip[] = {
"CHARGE", "CHARGE", "",
"", "",
" You charge in a chosen direction into the first obstructing", " You charge in a chosen direction into the first obstructing", "",
" object. Charging into an enemy can deliver massive damage.", " object. Charging into an enemy can deliver massive damage.", "",
"", "",
" Damage is affected by charge distance.", " Damage is affected by charge distance.", "",
" Longer distance, more damage.", " Longer distance, more damage.", "",
"", "",
"COOLDOWN:", "COOLDOWN:", "",
" 5 turns", " 5 turns", "",
"", "",
"USAGE:", "USAGE:",
" activate the skill (press 3)", " activate the skill (press ", "3", ")", "",
" followed by a direction (left, right, up or down)", " followed by a direction (left, right, up or down)", "",
"", "",
"", "",
"Press ESC to close", "Press ", "ESC", " to close", "",
NULL NULL
}; };
static char *dagger_tooltip[] = { static char *dagger_tooltip[] = {
"THROW DAGGER", "THROW DAGGER", "",
"", "",
" You throw a dagger in the chosen direction.", " You throw a dagger in the chosen direction.", "",
"", "",
" Damage is affected by throwing distance.", " Damage is affected by throwing distance.", "",
" Longer distance, more damage.", " Longer distance, more damage.", "",
"", "",
" Dagger supply is not infinite, your current dagger", " Dagger supply is not infinite, your current dagger", "",
" inventory is displayed in the panel to the right.", " inventory is displayed in the panel to the right.", "",
"", "",
"COOLDOWN:", "COOLDOWN:", "",
" 0 turns", " 0 turns", "",
"", "",
"USAGE:", "USAGE:", "",
" activate the skill (press 4)", " activate the skill (press ", "4", ")", "",
" followed by a direction (left, right, up or down)", " followed by a direction (left, right, up or down)", "",
"", "",
"", "",
"Press ESC to close", "Press ", "ESC", " to close", "",
NULL NULL
}; };
static char *health_tooltip[] = { static char *health_tooltip[] = {
"DRINK HEALTH", "DRINK HEALTH", "",
"", "",
" You take a sip from your health vial", " You take a sip from your health vial", "",
"", "",
" The current amount of sips in your vials is", " The current amount of sips in your vials is", "",
" dsplayed in the panel to the right.", " dsplayed in the panel to the right.", "",
"", "",
"COOLDOWN:", "COOLDOWN:", "",
" 0 turns", " 0 turns", "",
"", "",
"USAGE:", "USAGE:", "",
" Sip health (press 5)", " Sip health (press ", "5", ")", "",
"", "",
"", "",
"Press ESC to close", "Press ", "ESC", " to close", "",
NULL NULL
}; };

View File

@ -30,11 +30,13 @@ render_button_texture_for(const char *text, Position pos, Camera *cam)
SDL_Rect clip = CLIP16(0, 0); SDL_Rect clip = CLIP16(0, 0);
if (strcmp(text, "1") == 0) { if (strcmp(text, "1") == 0) {
// no op // no op
} else if (strcmp(text, "2") == 0) {
clip = CLIP16(16, 0);
} else { } else {
return false; return false;
} }
SDL_Rect renderBox = { pos.x, pos.y, 8, 8 }; SDL_Rect renderBox = { pos.x, pos.y, 16, 16 };
texture_render_clip(t, &renderBox, &clip, cam); texture_render_clip(t, &renderBox, &clip, cam);
return true; return true;
} }
@ -66,10 +68,10 @@ tooltip_create(char **content, Camera *cam)
} }
Sprite *sprite = gui_util_create_tooltip_frame_sprite(BOTTOM_GUI_WIDTH/16 - 6, Sprite *sprite = gui_util_create_tooltip_frame_sprite(BOTTOM_GUI_WIDTH/16 - 6,
(Uint32) ((rowCount * 10 + 48)/16), (Uint32) ((rowCount * 9 + 48)/16),
cam); cam);
sprite->pos.x = 48; sprite->pos.x = 48;
sprite->pos.y = 96; sprite->pos.y = 48;
Texture *texture = sprite->textures[0]; Texture *texture = sprite->textures[0];
Texture *text = texture_create(); Texture *text = texture_create();
texture_load_font(text, "GUI/SDS_8x8.ttf", LOG_FONT_SIZE, 0); texture_load_font(text, "GUI/SDS_8x8.ttf", LOG_FONT_SIZE, 0);
@ -78,13 +80,17 @@ tooltip_create(char **content, Camera *cam)
while (*content) { while (*content) {
if (strlen(*content) > 0) { if (strlen(*content) > 0) {
if (!render_button_texture_for(*content, POS(renderBox.w, renderBox.y), cam)) { if (render_button_texture_for(*content, POS(renderBox.x, renderBox.y - 4), cam)) {
renderBox.x += 24;
} else {
load_texture_for(text, *content, &renderBox, cam->renderer); load_texture_for(text, *content, &renderBox, cam->renderer);
texture_render(text, &renderBox, cam); texture_render(text, &renderBox, cam);
renderBox.x += text->dim.width;
} }
} else {
renderBox.x = 16;
renderBox.y += 14;
} }
renderBox.y += 10;
content++; content++;
} }
SDL_SetRenderTarget(cam->renderer, NULL); SDL_SetRenderTarget(cam->renderer, NULL);