mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 01:29: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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (!INBOUNDS_VEC(m, textboxes))
|
||||
|
|
|
@ -94,6 +94,8 @@ public:
|
|||
int r, int g, int b
|
||||
);
|
||||
|
||||
void textboxforcepos(int x, int y);
|
||||
|
||||
void textboxcenterx(void);
|
||||
|
||||
int textboxwidth(void);
|
||||
|
|
|
@ -53,6 +53,7 @@ scriptclass::scriptclass(void)
|
|||
textlarge = false;
|
||||
textbox_sprites.clear();
|
||||
textbox_image = TEXTIMAGE_NONE;
|
||||
textbox_forcepos = false;
|
||||
}
|
||||
|
||||
void scriptclass::add_default_colours(void)
|
||||
|
@ -566,11 +567,13 @@ void scriptclass::run(void)
|
|||
textcrewmateposition = TextboxCrewmatePosition();
|
||||
textbox_sprites.clear();
|
||||
textbox_image = TEXTIMAGE_NONE;
|
||||
textbox_forcepos = false;
|
||||
}
|
||||
else if (words[0] == "position")
|
||||
{
|
||||
//are we facing left or right? for some objects we don't care, default at 0.
|
||||
j = 0;
|
||||
textbox_forcepos = false;
|
||||
|
||||
//the first word is the object to position relative to
|
||||
if (words[1] == "centerx")
|
||||
|
@ -592,6 +595,13 @@ void scriptclass::run(void)
|
|||
textx = -500;
|
||||
texty = -500;
|
||||
}
|
||||
else if (words[1] == "force")
|
||||
{
|
||||
words[2] = "donothing";
|
||||
j = -1;
|
||||
textbox_forcepos = true;
|
||||
|
||||
}
|
||||
else // Well, are they asking for a crewmate...?
|
||||
{
|
||||
i = getcrewmanfromname(words[1]);
|
||||
|
@ -774,16 +784,23 @@ void scriptclass::run(void)
|
|||
|
||||
graphics.setimage(textbox_image);
|
||||
|
||||
if (textx == -500 || textx == -1)
|
||||
if (textbox_forcepos)
|
||||
{
|
||||
graphics.textboxcenterx();
|
||||
textcrewmateposition.override_x = false;
|
||||
graphics.textboxforcepos(textx, texty);
|
||||
}
|
||||
|
||||
if (texty == -500)
|
||||
else
|
||||
{
|
||||
graphics.textboxcentery();
|
||||
textcrewmateposition.override_y = false;
|
||||
if (textx == -500 || textx == -1)
|
||||
{
|
||||
graphics.textboxcenterx();
|
||||
textcrewmateposition.override_x = false;
|
||||
}
|
||||
|
||||
if (texty == -500)
|
||||
{
|
||||
graphics.textboxcentery();
|
||||
textcrewmateposition.override_y = false;
|
||||
}
|
||||
}
|
||||
|
||||
TextboxOriginalContext context = TextboxOriginalContext();
|
||||
|
|
|
@ -122,6 +122,7 @@ public:
|
|||
int textboxtimer;
|
||||
std::vector<TextboxSprite> textbox_sprites;
|
||||
TextboxImage textbox_image;
|
||||
bool textbox_forcepos;
|
||||
|
||||
//Misc
|
||||
int i, j, k;
|
||||
|
|
|
@ -29,6 +29,8 @@ textboxclass::textboxclass(int gap)
|
|||
|
||||
large = false;
|
||||
|
||||
position_forced = false;
|
||||
|
||||
should_centerx = false;
|
||||
should_centery = false;
|
||||
|
||||
|
@ -78,18 +80,21 @@ void textboxclass::centery(void)
|
|||
void textboxclass::applyposition(void)
|
||||
{
|
||||
resize();
|
||||
reposition();
|
||||
if (should_centerx)
|
||||
if (!position_forced)
|
||||
{
|
||||
centerx();
|
||||
}
|
||||
if (should_centery)
|
||||
{
|
||||
centery();
|
||||
}
|
||||
if (translate == TEXTTRANSLATE_CUTSCENE)
|
||||
{
|
||||
adjust();
|
||||
reposition();
|
||||
if (should_centerx)
|
||||
{
|
||||
centerx();
|
||||
}
|
||||
if (should_centery)
|
||||
{
|
||||
centery();
|
||||
}
|
||||
if (translate == TEXTTRANSLATE_CUTSCENE)
|
||||
{
|
||||
adjust();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,6 +125,8 @@ public:
|
|||
|
||||
bool large;
|
||||
|
||||
bool position_forced;
|
||||
|
||||
bool should_centerx;
|
||||
bool should_centery;
|
||||
|
||||
|
|
Loading…
Reference in a new issue