1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 09:39:43 +01:00

Add position(force)

This argument forces the textbox position, meaning it won't be moved
to be inside of the bounds of the screen (nor have the 10 pixel padding
on each side.)
This commit is contained in:
NyakoFox 2024-11-03 15:08:24 -04:00 committed by Misa Elizabeth Kai
parent d8a8e44afa
commit 45e60fa69c
6 changed files with 58 additions and 18 deletions

View file

@ -3204,6 +3204,19 @@ SDL_Color Graphics::bigchunkygetcol(int t)
return color; return color;
} }
void Graphics::textboxforcepos(int x, int y)
{
if (!INBOUNDS_VEC(m, textboxes))
{
vlog_error("textboxforcepos() out-of-bounds!");
return;
}
textboxes[m].position_forced = true;
textboxes[m].xp = x;
textboxes[m].yp = y;
}
void Graphics::textboxcenterx(void) void Graphics::textboxcenterx(void)
{ {
if (!INBOUNDS_VEC(m, textboxes)) if (!INBOUNDS_VEC(m, textboxes))

View file

@ -94,6 +94,8 @@ public:
int r, int g, int b int r, int g, int b
); );
void textboxforcepos(int x, int y);
void textboxcenterx(void); void textboxcenterx(void);
int textboxwidth(void); int textboxwidth(void);

View file

@ -53,6 +53,7 @@ scriptclass::scriptclass(void)
textlarge = false; textlarge = false;
textbox_sprites.clear(); textbox_sprites.clear();
textbox_image = TEXTIMAGE_NONE; textbox_image = TEXTIMAGE_NONE;
textbox_forcepos = false;
} }
void scriptclass::add_default_colours(void) void scriptclass::add_default_colours(void)
@ -566,11 +567,13 @@ void scriptclass::run(void)
textcrewmateposition = TextboxCrewmatePosition(); textcrewmateposition = TextboxCrewmatePosition();
textbox_sprites.clear(); textbox_sprites.clear();
textbox_image = TEXTIMAGE_NONE; textbox_image = TEXTIMAGE_NONE;
textbox_forcepos = false;
} }
else if (words[0] == "position") else if (words[0] == "position")
{ {
//are we facing left or right? for some objects we don't care, default at 0. //are we facing left or right? for some objects we don't care, default at 0.
j = 0; j = 0;
textbox_forcepos = false;
//the first word is the object to position relative to //the first word is the object to position relative to
if (words[1] == "centerx") if (words[1] == "centerx")
@ -592,6 +595,13 @@ void scriptclass::run(void)
textx = -500; textx = -500;
texty = -500; texty = -500;
} }
else if (words[1] == "force")
{
words[2] = "donothing";
j = -1;
textbox_forcepos = true;
}
else // Well, are they asking for a crewmate...? else // Well, are they asking for a crewmate...?
{ {
i = getcrewmanfromname(words[1]); i = getcrewmanfromname(words[1]);
@ -774,16 +784,23 @@ void scriptclass::run(void)
graphics.setimage(textbox_image); graphics.setimage(textbox_image);
if (textx == -500 || textx == -1) if (textbox_forcepos)
{ {
graphics.textboxcenterx(); graphics.textboxforcepos(textx, texty);
textcrewmateposition.override_x = false;
} }
else
if (texty == -500)
{ {
graphics.textboxcentery(); if (textx == -500 || textx == -1)
textcrewmateposition.override_y = false; {
graphics.textboxcenterx();
textcrewmateposition.override_x = false;
}
if (texty == -500)
{
graphics.textboxcentery();
textcrewmateposition.override_y = false;
}
} }
TextboxOriginalContext context = TextboxOriginalContext(); TextboxOriginalContext context = TextboxOriginalContext();

View file

@ -122,6 +122,7 @@ public:
int textboxtimer; int textboxtimer;
std::vector<TextboxSprite> textbox_sprites; std::vector<TextboxSprite> textbox_sprites;
TextboxImage textbox_image; TextboxImage textbox_image;
bool textbox_forcepos;
//Misc //Misc
int i, j, k; int i, j, k;

View file

@ -29,6 +29,8 @@ textboxclass::textboxclass(int gap)
large = false; large = false;
position_forced = false;
should_centerx = false; should_centerx = false;
should_centery = false; should_centery = false;
@ -78,18 +80,21 @@ void textboxclass::centery(void)
void textboxclass::applyposition(void) void textboxclass::applyposition(void)
{ {
resize(); resize();
reposition(); if (!position_forced)
if (should_centerx)
{ {
centerx(); reposition();
} if (should_centerx)
if (should_centery) {
{ centerx();
centery(); }
} if (should_centery)
if (translate == TEXTTRANSLATE_CUTSCENE) {
{ centery();
adjust(); }
if (translate == TEXTTRANSLATE_CUTSCENE)
{
adjust();
}
} }
} }

View file

@ -125,6 +125,8 @@ public:
bool large; bool large;
bool position_forced;
bool should_centerx; bool should_centerx;
bool should_centery; bool should_centery;