moveref
scrawl 10 years ago
commit 7abbca8be9

@ -516,8 +516,13 @@ void OMW::Engine::activate()
if (ptr.getClass().getName(ptr) == "") // objects without name presented to user can never be activated if (ptr.getClass().getName(ptr) == "") // objects without name presented to user can never be activated
return; return;
if (ptr.getClass().isActor() && ptr.getClass().getCreatureStats(ptr).getAiSequence().isInCombat()) if (ptr.getClass().isActor())
return; {
MWMechanics::CreatureStats &stats = ptr.getClass().getCreatureStats(ptr);
if (stats.getAiSequence().isInCombat() && !stats.isDead())
return;
}
MWBase::Environment::get().getWorld()->activate(ptr, MWBase::Environment::get().getWorld()->getPlayerPtr()); MWBase::Environment::get().getWorld()->activate(ptr, MWBase::Environment::get().getWorld()->getPlayerPtr());
} }

@ -193,6 +193,9 @@ namespace MWGui
MyGUI::Gui::getInstance().destroyWidget(parent->getChildAt(0)); MyGUI::Gui::getInstance().destroyWidget(parent->getChildAt(0));
} }
mTextStyle = TextStyle();
mBlockStyle = BlockStyle();
MyGUI::Widget * paper = parent->createWidget<MyGUI::Widget>("Widget", MyGUI::IntCoord(0, 0, pag.getPageWidth(), pag.getPageHeight()), MyGUI::Align::Left | MyGUI::Align::Top); MyGUI::Widget * paper = parent->createWidget<MyGUI::Widget>("Widget", MyGUI::IntCoord(0, 0, pag.getPageWidth(), pag.getPageHeight()), MyGUI::Align::Left | MyGUI::Align::Top);
paper->setNeedMouseFocus(false); paper->setNeedMouseFocus(false);
@ -207,8 +210,25 @@ namespace MWGui
continue; continue;
std::string plainText = parser.getReadyText(); std::string plainText = parser.getReadyText();
// for cases when linebreaks are used to cause a shift to the next page
// if the split text block ends in an empty line, proceeding text block(s) should have leading empty lines removed
if (pag.getIgnoreLeadingEmptyLines())
{
while (!plainText.empty())
{
if (plainText[0] == '\n')
plainText.erase(plainText.begin());
else
{
pag.setIgnoreLeadingEmptyLines(false);
break;
}
}
}
if (plainText.empty()) if (plainText.empty())
brBeforeLastTag = false; brBeforeLastTag = true;
else else
{ {
// Each block of text (between two tags / boundary and tag) will be displayed in a separate editbox widget, // Each block of text (between two tags / boundary and tag) will be displayed in a separate editbox widget,
@ -252,6 +272,8 @@ namespace MWGui
{ {
case BookTextParser::Event_ImgTag: case BookTextParser::Event_ImgTag:
{ {
pag.setIgnoreLeadingEmptyLines(false);
const BookTextParser::Attributes & attr = parser.getAttributes(); const BookTextParser::Attributes & attr = parser.getAttributes();
if (attr.find("src") == attr.end() || attr.find("width") == attr.end() || attr.find("height") == attr.end()) if (attr.find("src") == attr.end() || attr.find("width") == attr.end() || attr.find("height") == attr.end())
@ -331,9 +353,7 @@ namespace MWGui
if (attr.find("face") != attr.end()) if (attr.find("face") != attr.end())
{ {
std::string face = attr.at("face"); std::string face = attr.at("face");
mTextStyle.mFont = face;
if (face != "Magic Cards")
mTextStyle.mFont = face;
} }
if (attr.find("size") != attr.end()) if (attr.find("size") != attr.end())
{ {
@ -408,13 +428,18 @@ namespace MWGui
// first empty lines that would go to the next page should be ignored // first empty lines that would go to the next page should be ignored
// unfortunately, getLineInfo method won't be available until 3.2.2 // unfortunately, getLineInfo method won't be available until 3.2.2
#if (MYGUI_VERSION >= MYGUI_DEFINE_VERSION(3, 2, 2)) #if (MYGUI_VERSION >= MYGUI_DEFINE_VERSION(3, 2, 2))
mPaginator.setIgnoreLeadingEmptyLines(true);
const MyGUI::VectorLineInfo & lines = mEditBox->getSubWidgetText()->castType<MyGUI::EditText>()->getLineInfo(); const MyGUI::VectorLineInfo & lines = mEditBox->getSubWidgetText()->castType<MyGUI::EditText>()->getLineInfo();
for (unsigned int i = lastLine; i < lines.size(); ++i) for (unsigned int i = lastLine; i < lines.size(); ++i)
{ {
if (lines[i].width == 0) if (lines[i].width == 0)
ret += lineHeight; ret += lineHeight;
else else
{
mPaginator.setIgnoreLeadingEmptyLines(false);
break; break;
}
} }
#endif #endif
return ret; return ret;

@ -81,7 +81,8 @@ namespace MWGui
Paginator(int pageWidth, int pageHeight) Paginator(int pageWidth, int pageHeight)
: mStartTop(0), mCurrentTop(0), : mStartTop(0), mCurrentTop(0),
mPageWidth(pageWidth), mPageHeight(pageHeight) mPageWidth(pageWidth), mPageHeight(pageHeight),
mIgnoreLeadingEmptyLines(false)
{ {
} }
@ -89,10 +90,12 @@ namespace MWGui
int getCurrentTop() const { return mCurrentTop; } int getCurrentTop() const { return mCurrentTop; }
int getPageWidth() const { return mPageWidth; } int getPageWidth() const { return mPageWidth; }
int getPageHeight() const { return mPageHeight; } int getPageHeight() const { return mPageHeight; }
bool getIgnoreLeadingEmptyLines() const { return mIgnoreLeadingEmptyLines; }
Pages getPages() const { return mPages; } Pages getPages() const { return mPages; }
void setStartTop(int top) { mStartTop = top; } void setStartTop(int top) { mStartTop = top; }
void setCurrentTop(int top) { mCurrentTop = top; } void setCurrentTop(int top) { mCurrentTop = top; }
void setIgnoreLeadingEmptyLines(bool ignore) { mIgnoreLeadingEmptyLines = ignore; }
Paginator & operator<<(const Page & page) Paginator & operator<<(const Page & page)
{ {
@ -103,6 +106,7 @@ namespace MWGui
private: private:
int mStartTop, mCurrentTop; int mStartTop, mCurrentTop;
int mPageWidth, mPageHeight; int mPageWidth, mPageHeight;
bool mIgnoreLeadingEmptyLines;
Pages mPages; Pages mPages;
}; };

@ -71,6 +71,7 @@ Michael Papageorgiou (werdanith)
Michał Bień (Glorf) Michał Bień (Glorf)
Miroslav Puda (pakanek) Miroslav Puda (pakanek)
MiroslavR MiroslavR
Narmo
Nathan Jeffords (blunted2night) Nathan Jeffords (blunted2night)
Nikolay Kasyanov (corristo) Nikolay Kasyanov (corristo)
nobrakal nobrakal

Loading…
Cancel
Save