mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-23 16:41:37 +00:00
journal formating. Problems with french accents.
This commit is contained in:
parent
5cfac197d4
commit
428d0ce820
1 changed files with 58 additions and 17 deletions
|
@ -4,19 +4,31 @@
|
||||||
#include "../mwworld/environment.hpp"
|
#include "../mwworld/environment.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/world.hpp"
|
||||||
|
|
||||||
|
struct book
|
||||||
std::list<std::string> formatText(std::string text)
|
{
|
||||||
|
int endLine;
|
||||||
|
std::list<std::string> pages;
|
||||||
|
};
|
||||||
|
|
||||||
|
book formatText(std::string text,book mBook,int maxLine, int lineSize)
|
||||||
{
|
{
|
||||||
std::cout << "\n \n \n";
|
|
||||||
std::list<std::string> stringList;
|
|
||||||
//stringList.push_back("");
|
//stringList.push_back("");
|
||||||
int maxLine = 10;
|
|
||||||
int lineSize = 20;
|
|
||||||
|
|
||||||
int cLineSize = 0;
|
int cLineSize = 0;
|
||||||
int cLine = 0;
|
int cLine = mBook.endLine +1;
|
||||||
std::string cString;
|
std::string cString;
|
||||||
|
|
||||||
|
if(mBook.pages.empty())
|
||||||
|
{
|
||||||
|
cString = "";
|
||||||
|
cLine = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cString = mBook.pages.back() + std::string("\n");
|
||||||
|
mBook.pages.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
std::string::iterator wordBegin = text.begin();
|
std::string::iterator wordBegin = text.begin();
|
||||||
std::string::iterator wordEnd;
|
std::string::iterator wordEnd;
|
||||||
|
|
||||||
|
@ -24,17 +36,14 @@ std::list<std::string> formatText(std::string text)
|
||||||
|
|
||||||
while(cText.length() != 0)
|
while(cText.length() != 0)
|
||||||
{
|
{
|
||||||
std::cout << "a";
|
|
||||||
size_t firstSpace = cText.find_first_of(' ');
|
size_t firstSpace = cText.find_first_of(' ');
|
||||||
if(firstSpace == std::string::npos)
|
if(firstSpace == std::string::npos)
|
||||||
{
|
{
|
||||||
cString = cString + cText;
|
cString = cString + cText;
|
||||||
stringList.push_back(cString);
|
mBook.pages.push_back(cString);
|
||||||
//TODO:finnish this
|
//TODO:finnish this
|
||||||
std::cout << "brerak?";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
std::cout << "notbreak";
|
|
||||||
if(firstSpace + cLineSize <= lineSize)
|
if(firstSpace + cLineSize <= lineSize)
|
||||||
{
|
{
|
||||||
cLineSize = firstSpace + cLineSize;
|
cLineSize = firstSpace + cLineSize;
|
||||||
|
@ -51,16 +60,16 @@ std::list<std::string> formatText(std::string text)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cLine = 0;
|
cLine = 0;
|
||||||
stringList.push_back(cString);
|
mBook.pages.push_back(cString);
|
||||||
cString = cText.substr(0,firstSpace +1);
|
cString = cText.substr(0,firstSpace +1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//std::cout << cText << "\n";
|
//std::cout << cText << "\n";
|
||||||
std::cout << cText.length();
|
//std::cout << cText.length();
|
||||||
if(firstSpace == cText.length()) std::cout << "maxi error en veu";
|
|
||||||
cText = cText.substr(firstSpace +1,cText.length() - firstSpace -1);
|
cText = cText.substr(firstSpace +1,cText.length() - firstSpace -1);
|
||||||
}
|
}
|
||||||
return stringList;
|
mBook.endLine = cLine;
|
||||||
|
return mBook;
|
||||||
//std::string
|
//std::string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,8 +108,40 @@ void MWGui::JournalWindow::open()
|
||||||
{
|
{
|
||||||
if(mWindowManager.getEnvironment().mJournal->begin()!=mWindowManager.getEnvironment().mJournal->end())
|
if(mWindowManager.getEnvironment().mJournal->begin()!=mWindowManager.getEnvironment().mJournal->end())
|
||||||
{
|
{
|
||||||
std::string a = mWindowManager.getEnvironment().mJournal->begin()->getText(mWindowManager.getEnvironment().mWorld->getStore());
|
std::vector<std::string> leftPages;
|
||||||
std::cout << a;
|
std::vector<std::string> rightPages;
|
||||||
|
|
||||||
|
book journal;
|
||||||
|
journal.endLine = 0;
|
||||||
|
|
||||||
|
for(std::deque<MWDialogue::StampedJournalEntry>::const_iterator it = mWindowManager.getEnvironment().mJournal->begin();it!=mWindowManager.getEnvironment().mJournal->end();it++)
|
||||||
|
{
|
||||||
|
std::string a = it->getText(mWindowManager.getEnvironment().mWorld->getStore());
|
||||||
|
std::cout << a;
|
||||||
|
journal = formatText(a,journal,10,20);
|
||||||
|
journal.endLine = journal.endLine +1;
|
||||||
|
journal.pages.back() = journal.pages.back() + std::string("\n");
|
||||||
|
}
|
||||||
|
//std::string a = mWindowManager.getEnvironment().mJournal->begin()->getText(mWindowManager.getEnvironment().mWorld->getStore());
|
||||||
|
//std::list<std::string> journal = formatText(a,10,20,1);
|
||||||
|
bool left = true;
|
||||||
|
for(std::list<std::string>::iterator it = journal.pages.begin(); it != journal.pages.end();it++)
|
||||||
|
{
|
||||||
|
if(left)
|
||||||
|
{
|
||||||
|
leftPages.push_back(*it);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rightPages.push_back(*it);
|
||||||
|
}
|
||||||
|
left = !left;
|
||||||
|
}
|
||||||
|
if(!left) rightPages.push_back("");
|
||||||
|
|
||||||
|
displayLeftText(leftPages.back());
|
||||||
|
displayRightText(rightPages.back());
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue