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:
parent
d8a8e44afa
commit
45e60fa69c
6 changed files with 58 additions and 18 deletions
|
@ -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))
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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,6 +784,12 @@ void scriptclass::run(void)
|
||||||
|
|
||||||
graphics.setimage(textbox_image);
|
graphics.setimage(textbox_image);
|
||||||
|
|
||||||
|
if (textbox_forcepos)
|
||||||
|
{
|
||||||
|
graphics.textboxforcepos(textx, texty);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (textx == -500 || textx == -1)
|
if (textx == -500 || textx == -1)
|
||||||
{
|
{
|
||||||
graphics.textboxcenterx();
|
graphics.textboxcenterx();
|
||||||
|
@ -785,6 +801,7 @@ void scriptclass::run(void)
|
||||||
graphics.textboxcentery();
|
graphics.textboxcentery();
|
||||||
textcrewmateposition.override_y = false;
|
textcrewmateposition.override_y = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TextboxOriginalContext context = TextboxOriginalContext();
|
TextboxOriginalContext context = TextboxOriginalContext();
|
||||||
context.text_case = textcase;
|
context.text_case = textcase;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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,6 +80,8 @@ void textboxclass::centery(void)
|
||||||
void textboxclass::applyposition(void)
|
void textboxclass::applyposition(void)
|
||||||
{
|
{
|
||||||
resize();
|
resize();
|
||||||
|
if (!position_forced)
|
||||||
|
{
|
||||||
reposition();
|
reposition();
|
||||||
if (should_centerx)
|
if (should_centerx)
|
||||||
{
|
{
|
||||||
|
@ -92,6 +96,7 @@ void textboxclass::applyposition(void)
|
||||||
adjust();
|
adjust();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void textboxclass::adjust(void)
|
void textboxclass::adjust(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -125,6 +125,8 @@ public:
|
||||||
|
|
||||||
bool large;
|
bool large;
|
||||||
|
|
||||||
|
bool position_forced;
|
||||||
|
|
||||||
bool should_centerx;
|
bool should_centerx;
|
||||||
bool should_centery;
|
bool should_centery;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue