mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-05 00:19:44 +01:00
Add textbuttons() script command, make Violet's ENTER dialogue dynamic
Violet's dialogue now looks like this: squeak(purple) text(purple,0,0,2) Remember that you can press {b_map} to check where you are on the map! position(purple,above) textbuttons() speak_active The new textbuttons() command sets the next textbox to replace {b_map} with the map button, and {b_int} with the interact button. The remaining keys would be added as soon as they need to be added to ActionSets.h as well.
This commit is contained in:
parent
3354a1a352
commit
620365614d
8 changed files with 75 additions and 4 deletions
desktop_version
|
@ -76,10 +76,11 @@
|
|||
<cutscene id="bigopenworldskip" explanation="">
|
||||
<dialogue speaker="purple" english="I'll be right here if you need any help!" translation=""/>
|
||||
</cutscene>
|
||||
<cutscene id="talkpurple_intro" explanation="">
|
||||
<cutscene id="talkpurple_intro" explanation="***ENTER is OUTDATED***">
|
||||
<dialogue speaker="player" english="I'm feeling a bit overwhelmed, Doctor." translation=""/>
|
||||
<dialogue speaker="player" english="Where do I begin?" translation=""/>
|
||||
<dialogue speaker="purple" english="Remember that you can press ENTER to check where you are on the map!" translation=""/>
|
||||
<dialogue speaker="purple" english="Remember that you can press {b_map} to check where you are on the map!" translation=""/>
|
||||
<dialogue speaker="purple" english="Look for areas where the rest of the crew might be..." translation=""/>
|
||||
<dialogue speaker="purple" english="If you get lost, you can get back to the ship from any teleporter." translation=""/>
|
||||
<dialogue speaker="purple" english="And don't worry! We'll find everyone!" translation=""/>
|
||||
|
|
|
@ -764,6 +764,17 @@ void Graphics::drawtile3( int x, int y, int t, int off, int height_subtract /*=
|
|||
draw_texture_part(grphx.im_tiles3, x, y, x2, y2, 8, 8 - height_subtract, 1, 1);
|
||||
}
|
||||
|
||||
static void fill_buttons(char* buffer, const size_t buffer_len, const char* line)
|
||||
{
|
||||
vformat_buf(buffer, buffer_len,
|
||||
line,
|
||||
"b_int:but,"
|
||||
"b_map:but",
|
||||
vformat_button(ActionSet_InGame, Action_InGame_Interact),
|
||||
vformat_button(ActionSet_InGame, Action_InGame_Map)
|
||||
);
|
||||
}
|
||||
|
||||
void Graphics::drawgui(void)
|
||||
{
|
||||
int text_sign;
|
||||
|
@ -840,15 +851,44 @@ void Graphics::drawgui(void)
|
|||
const int b = textboxes[i].b * tl_lerp;
|
||||
size_t j;
|
||||
|
||||
drawpixeltextbox(textboxes[i].xp, yp, textboxes[i].w, textboxes[i].h, r, g, b);
|
||||
int w = textboxes[i].w;
|
||||
if (textboxes[i].fill_buttons)
|
||||
{
|
||||
/* If we can fill in buttons, the width of the box may change...
|
||||
* This is Violet's fault. She decided to say a button name out loud. */
|
||||
int max = 0;
|
||||
char buffer[SCREEN_WIDTH_CHARS + 1];
|
||||
for (j = 0; j < textboxes[i].lines.size(); j++)
|
||||
{
|
||||
fill_buttons(buffer, sizeof(buffer), textboxes[i].lines[j].c_str());
|
||||
int len = font::len(textboxes[i].print_flags, buffer);
|
||||
if (len > max)
|
||||
{
|
||||
max = len;
|
||||
}
|
||||
}
|
||||
w = max + 16;
|
||||
}
|
||||
|
||||
drawpixeltextbox(textboxes[i].xp, yp, w, textboxes[i].h, r, g, b);
|
||||
|
||||
for (j = 0; j < textboxes[i].lines.size(); j++)
|
||||
{
|
||||
const char* line = textboxes[i].lines[j].c_str();
|
||||
char buffer[SCREEN_WIDTH_CHARS + 1];
|
||||
|
||||
if (textboxes[i].fill_buttons)
|
||||
{
|
||||
// Fill button placeholders like {b_map} in dialogue text.
|
||||
fill_buttons(buffer, sizeof(buffer), line);
|
||||
line = buffer;
|
||||
}
|
||||
|
||||
font::print(
|
||||
textboxes[i].print_flags | PR_BRIGHTNESS(tl_lerp*255) | PR_CJK_LOW,
|
||||
textboxes[i].xp + 8,
|
||||
yp + text_yoff + text_sign * (j * font_height),
|
||||
textboxes[i].lines[j],
|
||||
line,
|
||||
textboxes[i].r, textboxes[i].g, textboxes[i].b
|
||||
);
|
||||
}
|
||||
|
@ -3148,6 +3188,17 @@ void Graphics::textboxprintflags(const uint32_t flags)
|
|||
textboxes[m].resize();
|
||||
}
|
||||
|
||||
void Graphics::textboxbuttons(void)
|
||||
{
|
||||
if (!INBOUNDS_VEC(m, textboxes))
|
||||
{
|
||||
vlog_error("textboxbuttons() out-of-bounds!");
|
||||
return;
|
||||
}
|
||||
|
||||
textboxes[m].fill_buttons = true;
|
||||
}
|
||||
|
||||
void Graphics::textboxcommsrelay(void)
|
||||
{
|
||||
/* Special treatment for the gamestate textboxes in Comms Relay */
|
||||
|
|
|
@ -111,6 +111,8 @@ public:
|
|||
|
||||
void textboxprintflags(uint32_t flags);
|
||||
|
||||
void textboxbuttons(void);
|
||||
|
||||
void textboxcommsrelay(void);
|
||||
|
||||
void textboxadjust(void);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <limits.h>
|
||||
#include <SDL_timer.h>
|
||||
|
||||
#include "Alloc.h"
|
||||
#include "Constants.h"
|
||||
#include "CustomLevels.h"
|
||||
#include "Editor.h"
|
||||
|
@ -48,6 +49,7 @@ scriptclass::scriptclass(void)
|
|||
textpad_right = 0;
|
||||
textpadtowidth = 0;
|
||||
textcase = 1;
|
||||
textbuttons = false;
|
||||
textlarge = false;
|
||||
}
|
||||
|
||||
|
@ -798,6 +800,12 @@ void scriptclass::run(void)
|
|||
|| key.isDown(KEYBOARD_UP) || key.isDown(KEYBOARD_DOWN)) game.jumpheld = true;
|
||||
}
|
||||
game.backgroundtext = false;
|
||||
|
||||
if (textbuttons)
|
||||
{
|
||||
graphics.textboxbuttons();
|
||||
}
|
||||
textbuttons = false;
|
||||
}
|
||||
else if (words[0] == "endtext")
|
||||
{
|
||||
|
@ -2427,6 +2435,11 @@ void scriptclass::run(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (words[0] == "textbuttons")
|
||||
{
|
||||
// Parse buttons in the next textbox
|
||||
textbuttons = true;
|
||||
}
|
||||
else if (words[0] == "textcase")
|
||||
{
|
||||
// Used to disambiguate identical textboxes for translations (1 by default)
|
||||
|
|
|
@ -111,6 +111,7 @@ public:
|
|||
size_t textpad_right;
|
||||
size_t textpadtowidth;
|
||||
char textcase;
|
||||
bool textbuttons;
|
||||
bool textlarge;
|
||||
|
||||
//Misc
|
||||
|
|
|
@ -5054,9 +5054,10 @@ bool scriptclass::load(const std::string& name)
|
|||
|
||||
"squeak(purple)",
|
||||
"text(purple,0,0,2)",
|
||||
"Remember that you can press ENTER",
|
||||
"Remember that you can press {b_map}",
|
||||
"to check where you are on the map!",
|
||||
"position(purple,above)",
|
||||
"textbuttons()",
|
||||
"speak_active",
|
||||
|
||||
"squeak(purple)",
|
||||
|
|
|
@ -27,6 +27,7 @@ textboxclass::textboxclass(void)
|
|||
large = false;
|
||||
|
||||
print_flags = PR_FONT_LEVEL;
|
||||
fill_buttons = false;
|
||||
}
|
||||
|
||||
void textboxclass::centerx(void)
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
bool large;
|
||||
|
||||
uint32_t print_flags;
|
||||
bool fill_buttons;
|
||||
};
|
||||
|
||||
#endif /* TEXTBOX_H */
|
||||
|
|
Loading…
Reference in a new issue