small fixes on text defines

actorid
Tom Mason 12 years ago
parent e9ba7339f3
commit a14b7e4a0f

@ -74,7 +74,7 @@ std::vector<std::string> BookTextParser::split(std::string text, const int width
std::vector<std::string> result; std::vector<std::string> result;
MWScript::InterpreterContext interpreterContext(NULL, MWWorld::Ptr()); // empty arguments, because there is no locals or actor MWScript::InterpreterContext interpreterContext(NULL, MWWorld::Ptr()); // empty arguments, because there is no locals or actor
text = Interpreter::fixDefinesDialog(text, interpreterContext); text = Interpreter::fixDefinesBook(text, interpreterContext);
boost::algorithm::replace_all(text, "<BR>", "\n"); boost::algorithm::replace_all(text, "<BR>", "\n");
boost::algorithm::replace_all(text, "<P>", "\n\n"); boost::algorithm::replace_all(text, "<P>", "\n\n");
@ -176,7 +176,7 @@ std::vector<std::string> BookTextParser::split(std::string text, const int width
MyGUI::IntSize BookTextParser::parse(std::string text, MyGUI::Widget* parent, const int width) MyGUI::IntSize BookTextParser::parse(std::string text, MyGUI::Widget* parent, const int width)
{ {
MWScript::InterpreterContext interpreterContext(NULL, MWWorld::Ptr()); // empty arguments, because there is no locals or actor MWScript::InterpreterContext interpreterContext(NULL, MWWorld::Ptr()); // empty arguments, because there is no locals or actor
text = Interpreter::fixDefinesDialog(text, interpreterContext); text = Interpreter::fixDefinesBook(text, interpreterContext);
mParent = parent; mParent = parent;

@ -1,6 +1,5 @@
#include "defines.hpp" #include "defines.hpp"
#include <iostream>
#include <algorithm> #include <algorithm>
#include <string> #include <string>
#include <vector> #include <vector>
@ -22,7 +21,7 @@ namespace Interpreter{
return a.length() > b.length(); return a.length() > b.length();
} }
std::string fixDefinesReal(std::string text, char eschar, Context& context){ std::string fixDefinesReal(std::string text, char eschar, bool isBook, Context& context){
unsigned int start = 0; unsigned int start = 0;
std::string retval = ""; std::string retval = "";
@ -107,7 +106,7 @@ namespace Interpreter{
retval += context.getCurrentCellName(); retval += context.getCurrentCellName();
} }
else if(eschar == '%'){ // In Dialogue, not messagebox else if(eschar == '%' && !isBook) { // In Dialogue, not messagebox
if( (found = Check(temp, "faction", &i, &start))){ if( (found = Check(temp, "faction", &i, &start))){
retval += context.getNPCFaction(); retval += context.getNPCFaction();
} }
@ -134,9 +133,9 @@ namespace Interpreter{
retval += context.getNPCName(); retval += context.getNPCName();
} }
} }
else if(eschar == '^') { // In messagebox, not dialogue else { // In messagebox or book, not dialogue
/* empty in messageboxes */ /* empty outside dialogue */
if( (found = Check(temp, "faction", &i, &start))); if( (found = Check(temp, "faction", &i, &start)));
else if((found = Check(temp, "nextpcrank", &i, &start))); else if((found = Check(temp, "nextpcrank", &i, &start)));
else if((found = Check(temp, "pcnextrank", &i, &start))); else if((found = Check(temp, "pcnextrank", &i, &start)));
@ -164,6 +163,11 @@ namespace Interpreter{
} }
for(unsigned int j = 0; j < globals.size(); j++){ for(unsigned int j = 0; j < globals.size(); j++){
if(globals[j].length() > temp.length()){ // Just in case there's a global with a huuuge name
std::string temp = text.substr(i+1, globals[j].length());
transform(temp.begin(), temp.end(), temp.begin(), ::tolower);
}
if((found = Check(temp, globals[j], &i, &start))){ if((found = Check(temp, globals[j], &i, &start))){
char type = context.getGlobalType(globals[j]); char type = context.getGlobalType(globals[j]);
@ -191,10 +195,14 @@ namespace Interpreter{
} }
std::string fixDefinesDialog(std::string text, Context& context){ std::string fixDefinesDialog(std::string text, Context& context){
return fixDefinesReal(text, '%', context); return fixDefinesReal(text, '%', false, context);
} }
std::string fixDefinesMsgBox(std::string text, Context& context){ std::string fixDefinesMsgBox(std::string text, Context& context){
return fixDefinesReal(text, '^', context); return fixDefinesReal(text, '^', false, context);
}
std::string fixDefinesBook(std::string text, Context& context){
return fixDefinesReal(text, '%', true, context);
} }
} }

@ -7,6 +7,7 @@
namespace Interpreter{ namespace Interpreter{
std::string fixDefinesDialog(std::string text, Context& context); std::string fixDefinesDialog(std::string text, Context& context);
std::string fixDefinesMsgBox(std::string text, Context& context); std::string fixDefinesMsgBox(std::string text, Context& context);
std::string fixDefinesBook(std::string text, Context& context);
} }
#endif #endif

Loading…
Cancel
Save