diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-06-24 10:56:35 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-06-24 10:56:35 -0400 |
commit | f4177a77ceff0e1cffb7e968f3d48497fcd2d45c (patch) | |
tree | fe4473d5d0a36035902f58dda2bae130c2650558 /src | |
parent | 56d34b56e82821797bc97be7e36138057109f87e (diff) |
dialog wrap fix, removed junk files
Diffstat (limited to 'src')
-rw-r--r-- | src/entities.cpp | 2 | ||||
-rw-r--r-- | src/ui.cpp | 27 |
2 files changed, 11 insertions, 18 deletions
diff --git a/src/entities.cpp b/src/entities.cpp index cfc5922..60f49ee 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -679,7 +679,6 @@ COMMONAIFUNC: break; } while ((exml = exml->NextSiblingElement())); - std::cout << "b\n"; // handle quest tags if ((oxml = exml->FirstChildElement("quest"))) { std::string qname; @@ -733,7 +732,6 @@ COMMONAIFUNC: game::briceUpdate(); } - std::cout << "a\n"; // asdlfkj auto txml = exml->FirstChildElement("content"); if (txml == nullptr) @@ -178,7 +178,7 @@ namespace ui { unsigned char dialogOptChosen = 0; unsigned char merchOptChosen = 0; - unsigned int textWrapLimit = 110; + unsigned int textWrapLimit = 0; /* * Current font size. Changing this WILL NOT change the font size, see setFontSize() for @@ -363,24 +363,19 @@ namespace ui { */ float putString(const float x, const float y, std::string s) { - unsigned int i=0; + unsigned int i = 0, nl = 1; vec2 add, o = {x, y}; /* - * Loop on each character: - */ + * Loop on each character: + */ - do{ - if (i && ((i / 110.0) == (i / 110))) { - o.y -= fontSize * 1.05f; - o.x = x; - if (s[i] == ' ') - i++; - } + do { + if (dialogBoxExists && o.x > textWrapLimit * nl + x) { - if (i && (i / (float)textWrapLimit == i / textWrapLimit)) { o.y -= fontSize * 1.05f; o.x = x; + ++nl; // skip a space if it's there since we just newline'd if (s[i] == ' ') @@ -408,8 +403,7 @@ namespace ui { o.y += add.y; break; } - - }while(s[++i]); + } while (s[++i]); return o.x; // i.e. the string width } @@ -537,7 +531,8 @@ namespace ui { va_list dialogArgs; std::unique_ptr<char[]> printfbuf (new char[512]); - textWrapLimit = 110; + textWrapLimit = game::SCREEN_WIDTH - HLINES(20); + std::cout << textWrapLimit << '\n'; dialogPassive = passive; // add speaker prefix @@ -1093,7 +1088,7 @@ namespace ui { drawNiceBox(vec2 {x, y}, vec2 {x + SCREEN_WIDTH - HLINES(16), y - SCREEN_HEIGHT / 4}, -7.0); rtext = typeOut(dialogBoxText); - putString(x + (2*game::HLINE), y - fontSize - game::HLINE, rtext); + putString(x + HLINES(2), y - fontSize - game::HLINE, rtext); for(i=0;i<dialogOptText.size();i++) { setFontColor(255,255,255); |