diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp index e6cd7031b..1766a8b0a 100644 --- a/src/client/GameSave.cpp +++ b/src/client/GameSave.cpp @@ -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; } diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index 871199731..4cca85f8f 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -951,22 +951,25 @@ void Renderer::DrawSigns() else drawtext(x+3, y+3, text, 0, 191, 255, 255); - int x = signs[i].x; - int y = signs[i].y; - int dx = 1 - signs[i].ju; - int dy = (signs[i].y > 18) ? -1 : 1; -#ifdef OGLR - glBegin(GL_LINES); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glVertex2i(x, y); - glVertex2i(x+(dx*4), y+(dy*4)); - glEnd(); -#else - for (int j = 0; j < 4; j++) + if (signs[i].ju != sign::None) { - blendpixel(x, y, 192, 192, 192, 255); - x += dx; - y += dy; + int x = signs[i].x; + int y = signs[i].y; + int dx = 1 - signs[i].ju; + int dy = (signs[i].y > 18) ? -1 : 1; +#ifdef OGLR + glBegin(GL_LINES); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glVertex2i(x, y); + glVertex2i(x+(dx*4), y+(dy*4)); + glEnd(); +#else + for (int j = 0; j < 4; j++) + { + blendpixel(x, y, 192, 192, 192, 255); + x += dx; + y += dy; + } } #endif } diff --git a/src/gui/game/SignTool.cpp b/src/gui/game/SignTool.cpp index 94bb936d2..5c8a2fcfc 100644 --- a/src/gui/game/SignTool.cpp +++ b/src/gui/game/SignTool.cpp @@ -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("\x9D Left", (int)sign::Left)); - justification->AddOption(std::pair("\x9E Centre", (int)sign::Centre)); + justification->AddOption(std::pair("\x9E Middle", (int)sign::Middle)); justification->AddOption(std::pair("\x9F Right", (int)sign::Right)); + justification->AddOption(std::pair(" 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,22 +195,25 @@ void SignWindow::DoDraw() else g->drawtext(x+3, y+3, text, 0, 191, 255, 255); - x = currentSign.x; - y = currentSign.y; - dx = 1 - currentSign.ju; - dy = (currentSign.y > 18) ? -1 : 1; -#ifdef OGLR - glBegin(GL_LINES); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glVertex2i(x, y); - glVertex2i(x+(dx*4), y+(dy*4)); - glEnd(); -#else - for (int j=0; j<4; j++) + if (currentSign.ju != sign::None) { - g->blendpixel(x, y, 192, 192, 192, 255); - x+=dx; - y+=dy; + x = currentSign.x; + y = currentSign.y; + dx = 1 - currentSign.ju; + dy = (currentSign.y > 18) ? -1 : 1; +#ifdef OGLR + glBegin(GL_LINES); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glVertex2i(x, y); + glVertex2i(x+(dx*4), y+(dy*4)); + glEnd(); +#else + for (int j=0; j<4; j++) + { + g->blendpixel(x, y, 192, 192, 192, 255); + x+=dx; + y+=dy; + } } #endif } diff --git a/src/gui/interface/Textbox.cpp b/src/gui/interface/Textbox.cpp index e831e9d1c..5c35ce007 100644 --- a/src/gui/interface/Textbox.cpp +++ b/src/gui/interface/Textbox.cpp @@ -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()) { diff --git a/src/simulation/Sign.cpp b/src/simulation/Sign.cpp index 01b4ff2ec..5bec677d5 100644 --- a/src/simulation/Sign.cpp +++ b/src/simulation/Sign.cpp @@ -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; } diff --git a/src/simulation/Sign.h b/src/simulation/Sign.h index b75df1a46..ee93f8127 100644 --- a/src/simulation/Sign.h +++ b/src/simulation/Sign.h @@ -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;