allow longer signs, add 'None' justification where the pointer line isn't drawn
signs have a longer width limit and hard 45 character limit from the textbox and when loading saves
This commit is contained in:
parent
4cc753edc1
commit
5caf8bc8e1
@ -517,7 +517,7 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
{
|
||||
if(strcmp(bson_iterator_key(&signiter), "text")==0 && bson_iterator_type(&signiter)==BSON_STRING)
|
||||
{
|
||||
tempSign.text = format::CleanString(bson_iterator_string(&signiter), true, true, true).substr(0, 255);
|
||||
tempSign.text = format::CleanString(bson_iterator_string(&signiter), true, true, true).substr(0, 45);
|
||||
}
|
||||
else if(strcmp(bson_iterator_key(&signiter), "justification")==0 && bson_iterator_type(&signiter)==BSON_INT)
|
||||
{
|
||||
@ -1713,7 +1713,7 @@ void GameSave::readPSv(char * data, int dataLength)
|
||||
x = 254;
|
||||
memcpy(tempSignText, d+p, x);
|
||||
tempSignText[x] = 0;
|
||||
tempSign.text = format::CleanString(tempSignText, true, true, true);
|
||||
tempSign.text = format::CleanString(tempSignText, true, true, true).substr(0, 45);
|
||||
tempSigns.push_back(tempSign);
|
||||
p += x;
|
||||
}
|
||||
|
@ -951,6 +951,8 @@ void Renderer::DrawSigns()
|
||||
else
|
||||
drawtext(x+3, y+3, text, 0, 191, 255, 255);
|
||||
|
||||
if (signs[i].ju != sign::None)
|
||||
{
|
||||
int x = signs[i].x;
|
||||
int y = signs[i].y;
|
||||
int dx = 1 - signs[i].ju;
|
||||
@ -968,6 +970,7 @@ void Renderer::DrawSigns()
|
||||
x += dx;
|
||||
y += dy;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef OGLR
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
};
|
||||
|
||||
SignWindow::SignWindow(SignTool * tool_, Simulation * sim_, int signID_, ui::Point position_):
|
||||
ui::Window(ui::Point(-1, -1), ui::Point(200, 87)),
|
||||
ui::Window(ui::Point(-1, -1), ui::Point(250, 87)),
|
||||
tool(tool_),
|
||||
movingSign(NULL),
|
||||
signMoving(false),
|
||||
@ -129,14 +129,16 @@ SignWindow::SignWindow(SignTool * tool_, Simulation * sim_, int signID_, ui::Poi
|
||||
justification = new ui::DropDown(ui::Point(52, 48), ui::Point(50, 16));
|
||||
AddComponent(justification);
|
||||
justification->AddOption(std::pair<std::string, int>("\x9D Left", (int)sign::Left));
|
||||
justification->AddOption(std::pair<std::string, int>("\x9E Centre", (int)sign::Centre));
|
||||
justification->AddOption(std::pair<std::string, int>("\x9E Middle", (int)sign::Middle));
|
||||
justification->AddOption(std::pair<std::string, int>("\x9F Right", (int)sign::Right));
|
||||
justification->AddOption(std::pair<std::string, int>(" None", (int)sign::None));
|
||||
justification->SetOption(1);
|
||||
justification->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||
|
||||
textField = new ui::Textbox(ui::Point(8, 25), ui::Point(Size.X-16, 17), "", "[message]");
|
||||
textField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||
textField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
textField->SetLimit(45);
|
||||
textField->SetActionCallback(new SignTextAction(this));
|
||||
AddComponent(textField);
|
||||
FocusComponent(textField);
|
||||
@ -193,6 +195,8 @@ void SignWindow::DoDraw()
|
||||
else
|
||||
g->drawtext(x+3, y+3, text, 0, 191, 255, 255);
|
||||
|
||||
if (currentSign.ju != sign::None)
|
||||
{
|
||||
x = currentSign.x;
|
||||
y = currentSign.y;
|
||||
dx = 1 - currentSign.ju;
|
||||
@ -210,6 +214,7 @@ void SignWindow::DoDraw()
|
||||
x+=dx;
|
||||
y+=dy;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if(!signMoving)
|
||||
|
@ -209,7 +209,7 @@ void Textbox::pasteIntoSelection()
|
||||
else
|
||||
newText = "";
|
||||
}
|
||||
else if (!multiline && Graphics::textwidth((char*)std::string(backingText+newText).c_str()) > regionWidth)
|
||||
if (!multiline && Graphics::textwidth((char*)std::string(backingText+newText).c_str()) > regionWidth)
|
||||
{
|
||||
int pLimit = regionWidth - Graphics::textwidth((char*)backingText.c_str());
|
||||
int cIndex = Graphics::CharIndexAtPosition((char *)newText.c_str(), pLimit, 0);
|
||||
@ -413,7 +413,7 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
||||
regionWidth -= 13;
|
||||
regionWidth -= Appearance.Margin.Left;
|
||||
regionWidth -= Appearance.Margin.Right;
|
||||
if ((limit==std::string::npos || backingText.length() < limit) && (Graphics::textwidth((char*)std::string(backingText+char(character)).c_str()) <= regionWidth || multiline || limit!=std::string::npos))
|
||||
if ((limit==std::string::npos || backingText.length() < limit) && (Graphics::textwidth((char*)std::string(backingText+char(character)).c_str()) <= regionWidth || multiline))
|
||||
{
|
||||
if (cursor == (int)backingText.length())
|
||||
{
|
||||
|
@ -56,8 +56,8 @@ void sign::pos(std::string signText, int & x0, int & y0, int & w, int & h)
|
||||
{
|
||||
w = Graphics::textwidth(signText.c_str()) + 5;
|
||||
h = 15;
|
||||
x0 = (ju == 2) ? x - w :
|
||||
(ju == 1) ? x - w/2 : x;
|
||||
x0 = (ju == Right) ? x - w :
|
||||
(ju == Left) ? x : x - w/2;
|
||||
y0 = (y > 18) ? y - 18 : y + 4;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ class Simulation;
|
||||
class sign
|
||||
{
|
||||
public:
|
||||
enum Justification { Left = 0, Centre = 1, Right = 2 };
|
||||
enum Justification { Left = 0, Middle = 1, Right = 2, None = 3 };
|
||||
sign(std::string text_, int x_, int y_, Justification justification_);
|
||||
int x, y;
|
||||
Justification ju;
|
||||
|
Loading…
Reference in New Issue
Block a user