From 4f89c3e77ae78e8334cca850cfa3e256235bdc5d Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Sat, 20 Sep 2014 00:11:04 +0200 Subject: [PATCH 01/58] Rework book formatter (Fixes #1148) --- apps/openmw/mwgui/bookwindow.cpp | 61 ++-- apps/openmw/mwgui/bookwindow.hpp | 6 +- apps/openmw/mwgui/formatting.cpp | 478 +++++++++++------------------ apps/openmw/mwgui/formatting.hpp | 155 ++++++---- apps/openmw/mwgui/scrollwindow.cpp | 5 +- files/mygui/openmw_book.layout | 4 +- 6 files changed, 318 insertions(+), 391 deletions(-) diff --git a/apps/openmw/mwgui/bookwindow.cpp b/apps/openmw/mwgui/bookwindow.cpp index 372e81844..92e876708 100644 --- a/apps/openmw/mwgui/bookwindow.cpp +++ b/apps/openmw/mwgui/bookwindow.cpp @@ -70,11 +70,6 @@ namespace MWGui void BookWindow::clearPages() { - for (std::vector::iterator it=mPages.begin(); - it!=mPages.end(); ++it) - { - MyGUI::Gui::getInstance().destroyWidget(*it); - } mPages.clear(); } @@ -89,25 +84,9 @@ namespace MWGui MWWorld::LiveCellRef *ref = mBook.get(); - BookTextParser parser; - std::vector results = parser.split(ref->mBase->mText, mLeftPage->getSize().width, mLeftPage->getSize().height); - - int i=0; - for (std::vector::iterator it=results.begin(); - it!=results.end(); ++it) - { - MyGUI::Widget* parent; - if (i%2 == 0) - parent = mLeftPage; - else - parent = mRightPage; - - MyGUI::Widget* pageWidget = parent->createWidgetReal("", MyGUI::FloatCoord(0.0,0.0,1.0,1.0), MyGUI::Align::Default, "BookPage" + boost::lexical_cast(i)); - pageWidget->setNeedMouseFocus(false); - parser.parsePage(*it, pageWidget, mLeftPage->getSize().width); - mPages.push_back(pageWidget); - ++i; - } + Formatting::BookFormatter formatter; + mPages = formatter.markupToWidget(mLeftPage, ref->mBase->mText); + formatter.markupToWidget(mRightPage, ref->mBase->mText); updatePages(); @@ -164,19 +143,6 @@ namespace MWGui mLeftPageNumber->setCaption( boost::lexical_cast(mCurrentPage*2 + 1) ); mRightPageNumber->setCaption( boost::lexical_cast(mCurrentPage*2 + 2) ); - unsigned int i=0; - for (std::vector::iterator it = mPages.begin(); - it != mPages.end(); ++it) - { - if (mCurrentPage*2 == i || mCurrentPage*2+1 == i) - (*it)->setVisible(true); - else - { - (*it)->setVisible(false); - } - ++i; - } - //If it is the last page, hide the button "Next Page" if ( (mCurrentPage+1)*2 == mPages.size() || (mCurrentPage+1)*2 == mPages.size() + 1) @@ -191,6 +157,27 @@ namespace MWGui } else { mPrevPageButton->setVisible(true); } + + if (mPages.empty()) + return; + + MyGUI::Widget * paper; + + paper = mLeftPage->getChildAt(0); + paper->setCoord(paper->getPosition().left, -mPages[mCurrentPage*2].first, + paper->getWidth(), mPages[mCurrentPage*2].second); + + paper = mRightPage->getChildAt(0); + if ((mCurrentPage+1)*2 <= mPages.size()) + { + paper->setCoord(paper->getPosition().left, -mPages[mCurrentPage*2+1].first, + paper->getWidth(), mPages[mCurrentPage*2+1].second); + paper->setVisible(true); + } + else + { + paper->setVisible(false); + } } void BookWindow::adjustButton (Gui::ImageButton* button) diff --git a/apps/openmw/mwgui/bookwindow.hpp b/apps/openmw/mwgui/bookwindow.hpp index e0f921dc1..ea3057a6f 100644 --- a/apps/openmw/mwgui/bookwindow.hpp +++ b/apps/openmw/mwgui/bookwindow.hpp @@ -34,17 +34,21 @@ namespace MWGui void adjustButton(Gui::ImageButton* button); private: + typedef std::pair Page; + typedef std::vector Pages; + Gui::ImageButton* mCloseButton; Gui::ImageButton* mTakeButton; Gui::ImageButton* mNextPageButton; Gui::ImageButton* mPrevPageButton; + MyGUI::TextBox* mLeftPageNumber; MyGUI::TextBox* mRightPageNumber; MyGUI::Widget* mLeftPage; MyGUI::Widget* mRightPage; unsigned int mCurrentPage; // 0 is first page - std::vector mPages; + Pages mPages; MWWorld::Ptr mBook; diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index 42dfb1310..25091def9 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -11,68 +11,14 @@ #include #include #include -#include +#include #include +#include + namespace { - int convertFromHex(std::string hex) - { - int value = 0; - - int a = 0; - int b = hex.length() - 1; - for (; b >= 0; a++, b--) - { - if (hex[b] >= '0' && hex[b] <= '9') - { - value += (hex[b] - '0') * (1 << (a * 4)); - } - else - { - switch (hex[b]) - { - case 'A': - case 'a': - value += 10 * (1 << (a * 4)); - break; - - case 'B': - case 'b': - value += 11 * (1 << (a * 4)); - break; - - case 'C': - case 'c': - value += 12 * (1 << (a * 4)); - break; - - case 'D': - case 'd': - value += 13 * (1 << (a * 4)); - break; - - case 'E': - case 'e': - value += 14 * (1 << (a * 4)); - break; - - case 'F': - case 'f': - value += 15 * (1 << (a * 4)); - break; - - default: - throw std::runtime_error("invalid character in hex number"); - break; - } - } - } - - return value; - } - Ogre::UTFString::unicode_char unicodeCharFromChar(char ch) { std::string s; @@ -80,56 +26,56 @@ namespace Ogre::UTFString string(s); return string.getChar(0); } - - bool is_not_empty(const std::string& s) { - std::string temp = s; - boost::algorithm::trim(temp); - return !temp.empty(); - } } namespace MWGui { - - std::vector BookTextParser::split(std::string utf8Text, const int width, const int height) + namespace Formatting { - using Ogre::UTFString; - std::vector result; + Paginator::Pages BookFormatter::markupToWidget(MyGUI::Widget * parent, std::string utf8Text, const int pageWidth, const int pageHeight) + { + using Ogre::UTFString; - MWScript::InterpreterContext interpreterContext(NULL, MWWorld::Ptr()); // empty arguments, because there is no locals or actor - utf8Text = Interpreter::fixDefinesBook(utf8Text, interpreterContext); + MWScript::InterpreterContext interpreterContext(NULL, MWWorld::Ptr()); // empty arguments, because there is no locals or actor + utf8Text = Interpreter::fixDefinesBook(utf8Text, interpreterContext); - boost::algorithm::replace_all(utf8Text, "\n", ""); - boost::algorithm::replace_all(utf8Text, "\r", ""); - boost::algorithm::replace_all(utf8Text, "
", "\n"); - boost::algorithm::replace_all(utf8Text, "

", "\n\n"); + boost::algorithm::replace_all(utf8Text, "\n", ""); + boost::algorithm::replace_all(utf8Text, "\r", ""); + boost::algorithm::replace_all(utf8Text, "
", "\n"); + boost::algorithm::replace_all(utf8Text, "

", "\n\n"); - UTFString text(utf8Text); - const int spacing = 48; + UTFString text(utf8Text); + UTFString plainText; - const UTFString::unicode_char LEFT_ANGLE = unicodeCharFromChar('<'); - const UTFString::unicode_char NEWLINE = unicodeCharFromChar('\n'); - const UTFString::unicode_char SPACE = unicodeCharFromChar(' '); + const UTFString::unicode_char LEFT_ANGLE = unicodeCharFromChar('<'); + const UTFString::unicode_char NEWLINE = unicodeCharFromChar('\n'); - while (!text.empty()) - { - // read in characters until we have exceeded the size, or run out of text - int currentWidth = 0; - int currentHeight = 0; + Paginator pag(pageWidth, pageHeight); - size_t currentWordStart = 0; - size_t index = 0; - + while (parent->getChildCount()) { - std::string texToTrim = text.asUTF8(); - boost::algorithm::trim( texToTrim ); - text = UTFString(texToTrim); + MyGUI::Gui::getInstance().destroyWidget(parent->getChildAt(0)); } - - - while (currentHeight <= height - spacing && index < text.size()) + + MyGUI::Widget * paper = parent->createWidget("Widget", MyGUI::IntCoord(0, 0, pag.getPageWidth(), pag.getPageHeight()), MyGUI::Align::Left | MyGUI::Align::Top); + paper->setNeedMouseFocus(false); + + bool ignoreNewlines = true; + for (size_t index = 0; index < text.size(); ++index) { const UTFString::unicode_char ch = text.getChar(index); + if (!plainText.empty() && (ch == LEFT_ANGLE || index == text.size() - 1)) + { + // if there's a newline at the end of the box caption, remove it + if (plainText[plainText.size()-1] == NEWLINE) + plainText.erase(plainText.end()-1); + + TextElement elem(paper, pag, mTextStyle, plainText.asUTF8()); + elem.paginate(); + + plainText.clear(); + } + if (ch == LEFT_ANGLE) { const size_t tagStart = index + 1; @@ -140,263 +86,203 @@ namespace MWGui if (boost::algorithm::starts_with(tag, "IMG")) { - const int h = mHeight; - parseImage(tag, false); - currentHeight += (mHeight - h); - currentWidth = 0; + ImageElement elem(paper, pag, mTextStyle, tag); + elem.paginate(); + + ignoreNewlines = false; } else if (boost::algorithm::starts_with(tag, "FONT")) { parseFont(tag); - if (currentWidth != 0) { - currentHeight += currentFontHeight(); - } - currentWidth = 0; } else if (boost::algorithm::starts_with(tag, "DIV")) { parseDiv(tag); - if (currentWidth != 0) { - currentHeight += currentFontHeight(); - currentWidth = 0; - } } + index = tagEnd; } - else if (ch == NEWLINE) - { - currentHeight += currentFontHeight(); - currentWidth = 0; - currentWordStart = index; - } - else if (ch == SPACE) - { - currentWidth += 3; // keep this in sync with the font's SpaceWidth property - currentWordStart = index; - } else { - currentWidth += widthForCharGlyph(ch); - } - - if (currentWidth > width) - { - currentHeight += currentFontHeight(); - currentWidth = 0; - // add size of the current word - UTFString word = text.substr(currentWordStart, index - currentWordStart); - for (UTFString::const_iterator it = word.begin(), end = word.end(); it != end; ++it) - currentWidth += widthForCharGlyph(it.getCharacter()); + if (!ignoreNewlines || ch != NEWLINE) + { + plainText.push_back(ch); + ignoreNewlines = false; + } } - index += UTFString::_utf16_char_length(ch); } - const size_t pageEnd = (currentHeight > height - spacing && currentWordStart != 0) - ? currentWordStart : index; - result.push_back(text.substr(0, pageEnd).asUTF8()); - text.erase(0, pageEnd); - } - - std::vector nonEmptyPages; - boost::copy(result | boost::adaptors::filtered(is_not_empty), std::back_inserter(nonEmptyPages)); - return nonEmptyPages; - } - - float BookTextParser::widthForCharGlyph(unsigned unicodeChar) const - { - std::string fontName(mTextStyle.mFont == "Default" ? MyGUI::FontManager::getInstance().getDefaultFont() : mTextStyle.mFont); - return MyGUI::FontManager::getInstance().getByName(fontName) - ->getGlyphInfo(unicodeChar)->width; - } - - float BookTextParser::currentFontHeight() const - { - std::string fontName(mTextStyle.mFont == "Default" ? MyGUI::FontManager::getInstance().getDefaultFont() : mTextStyle.mFont); - return MyGUI::FontManager::getInstance().getByName(fontName)->getDefaultHeight(); - } + // insert last page + pag << Paginator::Page(pag.getStartTop(), pag.getStartTop() + pag.getPageHeight()); - MyGUI::IntSize BookTextParser::parsePage(std::string text, MyGUI::Widget* parent, const int width) - { - MWScript::InterpreterContext interpreterContext(NULL, MWWorld::Ptr()); // empty arguments, because there is no locals or actor - text = Interpreter::fixDefinesBook(text, interpreterContext); + paper->setSize(paper->getWidth(), pag.getCurrentTop()); - mParent = parent; - mWidth = width; - mHeight = 0; + return pag.getPages(); + } - assert(mParent); - while (mParent->getChildCount()) + Paginator::Pages BookFormatter::markupToWidget(MyGUI::Widget * parent, std::string utf8Text) { - MyGUI::Gui::getInstance().destroyWidget(mParent->getChildAt(0)); + return markupToWidget(parent, utf8Text, parent->getWidth(), parent->getHeight()); } - // remove trailing " - if (text[text.size()-1] == '\"') - text.erase(text.size()-1); - - parseSubText(text); - return MyGUI::IntSize(mWidth, mHeight); - } - - MyGUI::IntSize BookTextParser::parseScroll(std::string text, MyGUI::Widget* parent, const int width) - { - MWScript::InterpreterContext interpreterContext(NULL, MWWorld::Ptr()); // empty arguments, because there is no locals or actor - text = Interpreter::fixDefinesBook(text, interpreterContext); - - mParent = parent; - mWidth = width; - mHeight = 0; - - assert(mParent); - while (mParent->getChildCount()) + void BookFormatter::parseDiv(std::string tag) { - MyGUI::Gui::getInstance().destroyWidget(mParent->getChildAt(0)); + if (tag.find("ALIGN=") == std::string::npos) + return; + + int align_start = tag.find("ALIGN=")+7; + std::string align = tag.substr(align_start, tag.find('"', align_start)-align_start); + if (align == "CENTER") + mTextStyle.mTextAlign = MyGUI::Align::HCenter; + else if (align == "LEFT") + mTextStyle.mTextAlign = MyGUI::Align::Left; } - boost::algorithm::replace_all(text, "
", "\n"); - boost::algorithm::replace_all(text, "

", "\n\n"); - boost::algorithm::trim_left(text); - - // remove trailing " - if (text[text.size()-1] == '\"') - text.erase(text.size()-1); - - parseSubText(text); - return MyGUI::IntSize(mWidth, mHeight); - } - + void BookFormatter::parseFont(std::string tag) + { + if (tag.find("COLOR=") != std::string::npos) + { + int color_start = tag.find("COLOR=")+7; - void BookTextParser::parseImage(std::string tag, bool createWidget) - { - int src_start = tag.find("SRC=")+5; + int color; + std::stringstream ss; + ss << tag.substr(color_start, tag.find('"', color_start)-color_start); + ss >> std::hex >> color; - int width_start = tag.find("WIDTH=")+7; - int width = boost::lexical_cast(tag.substr(width_start, tag.find('"', width_start)-width_start)); + mTextStyle.mColour = MyGUI::Colour( + (color>>16 & 0xFF) / 255.f, + (color>>8 & 0xFF) / 255.f, + (color & 0xFF) / 255.f); + } + if (tag.find("FACE=") != std::string::npos) + { + int face_start = tag.find("FACE=")+6; + std::string face = tag.substr(face_start, tag.find('"', face_start)-face_start); - int height_start = tag.find("HEIGHT=")+8; - int height = boost::lexical_cast(tag.substr(height_start, tag.find('"', height_start)-height_start)); + if (face != "Magic Cards") + mTextStyle.mFont = face; + } + if (tag.find("SIZE=") != std::string::npos) + { + /// \todo + } + } - if (createWidget) + /* GraphicElement */ + GraphicElement::GraphicElement(MyGUI::Widget * parent, Paginator & pag, const TextStyle & style) + : mParent(parent), mPaginator(pag), mStyle(style) { - MyGUI::ImageBox* box = mParent->createWidget ("ImageBox", - MyGUI::IntCoord(0, mHeight, width, height), MyGUI::Align::Left | MyGUI::Align::Top, - mParent->getName() + boost::lexical_cast(mParent->getChildCount())); - - std::string image = Misc::ResourceHelpers::correctBookartPath(tag.substr(src_start, tag.find('"', src_start)-src_start), width, height); - box->setImageTexture(image); - box->setProperty("NeedMouse", "false"); } - mWidth = std::max(mWidth, width); - mHeight += height; - } + void GraphicElement::paginate() + { + int newTop = mPaginator.getCurrentTop() + getHeight(); + while (newTop-mPaginator.getStartTop() > mPaginator.getPageHeight()) + { + int newStartTop = pageSplit(); + mPaginator << Paginator::Page(mPaginator.getStartTop(), newStartTop); + mPaginator.setStartTop(newStartTop); + } - void BookTextParser::parseDiv(std::string tag) - { - if (tag.find("ALIGN=") == std::string::npos) - return; - - int align_start = tag.find("ALIGN=")+7; - std::string align = tag.substr(align_start, tag.find('"', align_start)-align_start); - if (align == "CENTER") - mTextStyle.mTextAlign = MyGUI::Align::HCenter; - else if (align == "LEFT") - mTextStyle.mTextAlign = MyGUI::Align::Left; - } + mPaginator.modifyCurrentTop(getHeight()); + } - void BookTextParser::parseFont(std::string tag) - { - if (tag.find("COLOR=") != std::string::npos) + int GraphicElement::pageSplit() { - int color_start = tag.find("COLOR=")+7; - std::string color = tag.substr(color_start, tag.find('"', color_start)-color_start); - - mTextStyle.mColour = MyGUI::Colour( - convertFromHex(color.substr(0, 2))/255.0, - convertFromHex(color.substr(2, 2))/255.0, - convertFromHex(color.substr(4, 2))/255.0); + return mPaginator.getStartTop() + mPaginator.getPageHeight(); } - if (tag.find("FACE=") != std::string::npos) + + int GraphicElement::currentFontHeight() const { - int face_start = tag.find("FACE=")+6; - std::string face = tag.substr(face_start, tag.find('"', face_start)-face_start); + std::string fontName(mStyle.mFont == "Default" ? MyGUI::FontManager::getInstance().getDefaultFont() : mStyle.mFont); + return MyGUI::FontManager::getInstance().getByName(fontName)->getDefaultHeight(); + } - if (face != "Magic Cards") - mTextStyle.mFont = face; + float GraphicElement::widthForCharGlyph(MyGUI::Char unicodeChar) const + { + std::string fontName(mStyle.mFont == "Default" ? MyGUI::FontManager::getInstance().getDefaultFont() : mStyle.mFont); + return MyGUI::FontManager::getInstance().getByName(fontName) + ->getGlyphInfo(unicodeChar)->width; } - if (tag.find("SIZE=") != std::string::npos) + + /* TextElement */ + TextElement::TextElement(MyGUI::Widget * parent, Paginator & pag, const TextStyle & style, const std::string & text) + : GraphicElement(parent, pag, style) { - /// \todo + MyGUI::EditBox* box = parent->createWidget("NormalText", + MyGUI::IntCoord(0, pag.getCurrentTop(), pag.getPageWidth(), 0), MyGUI::Align::Left | MyGUI::Align::Top, + parent->getName() + boost::lexical_cast(parent->getChildCount())); + box->setProperty("Static", "true"); + box->setProperty("MultiLine", "true"); + box->setProperty("WordWrap", "true"); + box->setProperty("NeedMouse", "false"); + box->setMaxTextLength(text.size()); + box->setTextAlign(mStyle.mTextAlign); + box->setTextColour(mStyle.mColour); + box->setFontName(mStyle.mFont); + box->setCaption(MyGUI::TextIterator::toTagsString(text)); + box->setSize(box->getSize().width, box->getTextSize().height); + mEditBox = box; } - } - void BookTextParser::parseSubText(std::string text) - { - if (text[0] == '<') + int TextElement::getHeight() { - const size_t tagStart = 1; - const size_t tagEnd = text.find('>', tagStart); - if (tagEnd == std::string::npos) - throw std::runtime_error("BookTextParser Error: Tag is not terminated"); - const std::string tag = text.substr(tagStart, tagEnd - tagStart); - - if (boost::algorithm::starts_with(tag, "IMG")) - parseImage(tag); - if (boost::algorithm::starts_with(tag, "FONT")) - parseFont(tag); - if (boost::algorithm::starts_with(tag, "DIV")) - parseDiv(tag); - - text.erase(0, tagEnd + 1); + return mEditBox->getTextSize().height; } - size_t tagStart = std::string::npos; - std::string realText; // real text, without tags - for (size_t i = 0; i= MYGUI_DEFINE_VERSION(3, 2, 2)) + const MyGUI::VectorLineInfo & lines = mEditBox->getSubWidgetText()->castType()->getLineInfo(); + for (unsigned int i = lastLine; i < lines.size(); ++i) { - if ((i + 1 < text.size()) && text[i+1] == '/') // ignore closing tags - { - while (c != '>') - { - if (i >= text.size()) - throw std::runtime_error("BookTextParser Error: Tag is not terminated"); - ++i; - c = text[i]; - } - continue; - } + if (lines[i].width == 0) + ret += lineHeight; else - { - tagStart = i; break; - } } - else - realText += c; +#endif + return ret; } - MyGUI::EditBox* box = mParent->createWidget("NormalText", - MyGUI::IntCoord(0, mHeight, mWidth, 24), MyGUI::Align::Left | MyGUI::Align::Top, - mParent->getName() + boost::lexical_cast(mParent->getChildCount())); - box->setProperty("Static", "true"); - box->setProperty("MultiLine", "true"); - box->setProperty("WordWrap", "true"); - box->setProperty("NeedMouse", "false"); - box->setMaxTextLength(realText.size()); - box->setTextAlign(mTextStyle.mTextAlign); - box->setTextColour(mTextStyle.mColour); - box->setFontName(mTextStyle.mFont); - box->setCaption(MyGUI::TextIterator::toTagsString(realText)); - box->setSize(box->getSize().width, box->getTextSize().height); - mHeight += box->getTextSize().height; - - if (tagStart != std::string::npos) + /* ImageElement */ + ImageElement::ImageElement(MyGUI::Widget * parent, Paginator & pag, const TextStyle & style, const std::string & tag) + : GraphicElement(parent, pag, style), + mImageHeight(0) { - parseSubText(text.substr(tagStart, text.size())); + int src_start = tag.find("SRC=")+5; + std::string src = tag.substr(src_start, tag.find('"', src_start)-src_start); + + int width_start = tag.find("WIDTH=")+7; + int width = boost::lexical_cast(tag.substr(width_start, tag.find('"', width_start)-width_start)); + + int height_start = tag.find("HEIGHT=")+8; + mImageHeight = boost::lexical_cast(tag.substr(height_start, tag.find('"', height_start)-height_start)); + + mImageBox = parent->createWidget ("ImageBox", + MyGUI::IntCoord(0, pag.getCurrentTop(), width, mImageHeight), MyGUI::Align::Left | MyGUI::Align::Top, + parent->getName() + boost::lexical_cast(parent->getChildCount())); + + std::string image = Misc::ResourceHelpers::correctBookartPath(src, width, mImageHeight); + mImageBox->setImageTexture(image); + mImageBox->setProperty("NeedMouse", "false"); } - } + int ImageElement::getHeight() + { + return mImageHeight; + } + + int ImageElement::pageSplit() + { + return mPaginator.getCurrentTop(); + } + } } diff --git a/apps/openmw/mwgui/formatting.hpp b/apps/openmw/mwgui/formatting.hpp index a32d98fe5..b0a8bce0f 100644 --- a/apps/openmw/mwgui/formatting.hpp +++ b/apps/openmw/mwgui/formatting.hpp @@ -5,63 +5,112 @@ namespace MWGui { - struct TextStyle + namespace Formatting { - TextStyle() : - mColour(0,0,0) - , mFont("Default") - , mTextSize(16) - , mTextAlign(MyGUI::Align::Left | MyGUI::Align::Top) + struct TextStyle { - } + TextStyle() : + mColour(0,0,0) + , mFont("Default") + , mTextSize(16) + , mTextAlign(MyGUI::Align::Left | MyGUI::Align::Top) + { + } - MyGUI::Colour mColour; - std::string mFont; - int mTextSize; - MyGUI::Align mTextAlign; - }; + MyGUI::Colour mColour; + std::string mFont; + int mTextSize; + MyGUI::Align mTextAlign; + }; - /// \brief utilities for parsing book/scroll text as mygui widgets - class BookTextParser - { - public: - /** - * Parse markup as MyGUI widgets - * @param markup to parse - * @param parent for the created widgets - * @param maximum width - * @return size of the created widgets - */ - MyGUI::IntSize parsePage(std::string text, MyGUI::Widget* parent, const int width); - - /** - * Parse markup as MyGUI widgets - * @param markup to parse - * @param parent for the created widgets - * @param maximum width - * @return size of the created widgets - */ - MyGUI::IntSize parseScroll(std::string text, MyGUI::Widget* parent, const int width); - - /** - * Split the specified text into pieces that fit in the area specified by width and height parameters - */ - std::vector split(std::string text, const int width, const int height); - - protected: - float widthForCharGlyph(unsigned unicodeChar) const; - float currentFontHeight() const; - void parseSubText(std::string text); - - void parseImage(std::string tag, bool createWidget=true); - void parseDiv(std::string tag); - void parseFont(std::string tag); - private: - MyGUI::Widget* mParent; - int mWidth; // maximum width - int mHeight; // current height - TextStyle mTextStyle; - }; + class Paginator + { + public: + typedef std::pair Page; + typedef std::vector Pages; + + Paginator(int pageWidth, int pageHeight) + : mStartTop(0), mCurrentTop(0), + mPageWidth(pageWidth), mPageHeight(pageHeight) + { + } + + int getStartTop() const { return mStartTop; } + int getCurrentTop() const { return mCurrentTop; } + int getPageWidth() const { return mPageWidth; } + int getPageHeight() const { return mPageHeight; } + Pages getPages() const { return mPages; } + + void setStartTop(int top) { mStartTop = top; } + void setCurrentTop(int top) { mCurrentTop = top; } + void modifyStartTop(int mod) { mStartTop += mod; } + void modifyCurrentTop(int mod) { mCurrentTop += mod; } + + Paginator & operator<<(const Page & page) + { + mPages.push_back(page); + return *this; + } + + private: + int mStartTop, mCurrentTop; + int mPageWidth, mPageHeight; + Pages mPages; + }; + + /// \brief utilities for parsing book/scroll text as mygui widgets + class BookFormatter + { + public: + Paginator::Pages markupToWidget(MyGUI::Widget * parent, std::string utf8Text, const int pageWidth, const int pageHeight); + Paginator::Pages markupToWidget(MyGUI::Widget * parent, std::string utf8Text); + + protected: + void parseDiv(std::string tag); + void parseFont(std::string tag); + private: + TextStyle mTextStyle; + }; + + class GraphicElement + { + public: + GraphicElement(MyGUI::Widget * parent, Paginator & pag, const TextStyle & style); + virtual int getHeight() = 0; + virtual void paginate(); + virtual int pageSplit(); + + protected: + int currentFontHeight() const; + float widthForCharGlyph(MyGUI::Char unicodeChar) const; + + MyGUI::Widget * mParent; + Paginator & mPaginator; + TextStyle mStyle; + }; + + class TextElement : public GraphicElement + { + public: + TextElement(MyGUI::Widget * parent, Paginator & pag, const TextStyle & style, const std::string & text); + virtual int getHeight(); + virtual int pageSplit(); + private: + MyGUI::EditBox * mEditBox; + }; + + class ImageElement : public GraphicElement + { + public: + ImageElement(MyGUI::Widget * parent, Paginator & pag, const TextStyle & style, const std::string & tag); + virtual int getHeight(); + virtual int pageSplit(); + + private: + int mImageHeight; + MyGUI::ImageBox * mImageBox; + }; + } } #endif diff --git a/apps/openmw/mwgui/scrollwindow.cpp b/apps/openmw/mwgui/scrollwindow.cpp index 7530d7a9e..038d91ca9 100644 --- a/apps/openmw/mwgui/scrollwindow.cpp +++ b/apps/openmw/mwgui/scrollwindow.cpp @@ -54,8 +54,9 @@ namespace MWGui MWWorld::LiveCellRef *ref = mScroll.get(); - BookTextParser parser; - MyGUI::IntSize size = parser.parseScroll(ref->mBase->mText, mTextView, 390); + Formatting::BookFormatter formatter; + formatter.markupToWidget(mTextView, ref->mBase->mText, 390, mTextView->getHeight()); + MyGUI::IntSize size = mTextView->getChildAt(0)->getSize(); // Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden mTextView->setVisibleVScroll(false); diff --git a/files/mygui/openmw_book.layout b/files/mygui/openmw_book.layout index 9f30bf253..f91cd696e 100644 --- a/files/mygui/openmw_book.layout +++ b/files/mygui/openmw_book.layout @@ -41,8 +41,8 @@ - - + + From 84d27d55e22fa2df43c70b9393e0f4ab0cca53f7 Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Sat, 20 Sep 2014 00:51:46 +0200 Subject: [PATCH 02/58] Remove redundant includes --- apps/openmw/mwgui/formatting.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index 25091def9..67ef59236 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -7,10 +7,7 @@ #include #include -#include #include -#include -#include #include #include From c362ec0f95ebacd7160789b3adb9630724261b20 Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Sun, 21 Sep 2014 19:47:52 +0200 Subject: [PATCH 03/58] Book formatting: Handle line endings as per vanilla, fix tall images causing infinite loop, cleanup --- apps/openmw/mwgui/formatting.cpp | 320 +++++++++++++++++++++---------- apps/openmw/mwgui/formatting.hpp | 58 +++++- files/mygui/openmw_book.layout | 4 +- 3 files changed, 265 insertions(+), 117 deletions(-) diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index 67ef59236..a7aee1bc9 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "../mwscript/interpretercontext.hpp" @@ -14,39 +15,167 @@ #include -namespace -{ - Ogre::UTFString::unicode_char unicodeCharFromChar(char ch) - { - std::string s; - s += ch; - Ogre::UTFString string(s); - return string.getChar(0); - } -} - namespace MWGui { namespace Formatting { - Paginator::Pages BookFormatter::markupToWidget(MyGUI::Widget * parent, std::string utf8Text, const int pageWidth, const int pageHeight) + /* BookTextParser */ + BookTextParser::BookTextParser(const std::string & text) + : mIndex(-1), mText(text), mIgnoreNewlineTags(true), mIgnoreLineEndings(true) { - using Ogre::UTFString; - MWScript::InterpreterContext interpreterContext(NULL, MWWorld::Ptr()); // empty arguments, because there is no locals or actor - utf8Text = Interpreter::fixDefinesBook(utf8Text, interpreterContext); + mText = Interpreter::fixDefinesBook(mText, interpreterContext); + + boost::algorithm::replace_all(mText, "\r", ""); + + registerTag("br", Event_BrTag); + registerTag("p", Event_PTag); + registerTag("img", Event_ImgTag); + registerTag("div", Event_DivTag); + registerTag("font", Event_FontTag); + } + + void BookTextParser::registerTag(const std::string & tag, BookTextParser::Events type) + { + mTagTypes[tag] = type; + } + + std::string BookTextParser::getReadyText() + { + return mReadyText; + } + + BookTextParser::Events BookTextParser::next() + { + while (1) + { + ++mIndex; + if (mIndex >= mText.size()) + return Event_EOF; + + char ch = mText[mIndex]; + if (ch == '<') + { + const size_t tagStart = mIndex + 1; + const size_t tagEnd = mText.find('>', tagStart); + if (tagEnd == std::string::npos) + throw std::runtime_error("BookTextParser Error: Tag is not terminated"); + parseTag(mText.substr(tagStart, tagEnd - tagStart)); + mIndex = tagEnd; + + if (mTagTypes.find(mTag) != mTagTypes.end()) + { + Events type = mTagTypes.at(mTag); + + if (type == Event_BrTag || type == Event_PTag) + { + if (!mIgnoreNewlineTags) + { + if (type == Event_BrTag) + mBuffer.push_back('\n'); + else + { + mBuffer.append("\n\n"); + } + } + mIgnoreLineEndings = true; + } + else + flushBuffer(); + + if (type == Event_ImgTag) + { + mIgnoreLineEndings = false; + mIgnoreNewlineTags = false; + } + + return type; + } + } + else + { + if (!mIgnoreLineEndings || ch != '\n') + { + mBuffer.push_back(ch); + mIgnoreLineEndings = false; + mIgnoreNewlineTags = false; + } + } + + if (mIndex == mText.size() - 1) + { + flushBuffer(); + return Event_LastText; + } + } + } + + void BookTextParser::flushBuffer() + { + mReadyText = mBuffer; + mBuffer.clear(); + } + + const BookTextParser::Attributes & BookTextParser::getAttributes() const + { + return mAttributes; + } + + void BookTextParser::parseTag(std::string tag) + { + size_t tagNameEndPos = tag.find(' '); + mTag = tag.substr(0, tagNameEndPos); + Misc::StringUtils::toLower(mTag); + mAttributes.clear(); + if (tagNameEndPos == std::string::npos) + return; + tag.erase(0, tagNameEndPos+1); + + while (!tag.empty()) + { + int sepPos = tag.find('='); + if (sepPos == std::string::npos) + return; - boost::algorithm::replace_all(utf8Text, "\n", ""); - boost::algorithm::replace_all(utf8Text, "\r", ""); - boost::algorithm::replace_all(utf8Text, "
", "\n"); - boost::algorithm::replace_all(utf8Text, "

", "\n\n"); + std::string key = tag.substr(0, sepPos); + Misc::StringUtils::toLower(key); + tag.erase(0, sepPos+1); - UTFString text(utf8Text); - UTFString plainText; + std::string value; - const UTFString::unicode_char LEFT_ANGLE = unicodeCharFromChar('<'); - const UTFString::unicode_char NEWLINE = unicodeCharFromChar('\n'); + if (tag.empty()) + return; + if (tag[0] == '"') + { + size_t quoteEndPos = tag.find('"', 1); + if (quoteEndPos == std::string::npos) + throw std::runtime_error("BookTextParser Error: Missing end quote in tag"); + value = tag.substr(1, quoteEndPos-1); + tag.erase(0, quoteEndPos+2); + } + else + { + size_t valEndPos = tag.find(' '); + if (valEndPos == std::string::npos) + { + value = tag; + tag.erase(); + } + else + { + value = tag.substr(0, valEndPos); + tag.erase(0, valEndPos+1); + } + } + + mAttributes[key] = value; + } + } + + /* BookFormatter */ + Paginator::Pages BookFormatter::markupToWidget(MyGUI::Widget * parent, const std::string & markup, const int pageWidth, const int pageHeight) + { Paginator pag(pageWidth, pageHeight); while (parent->getChildCount()) @@ -57,55 +186,49 @@ namespace MWGui MyGUI::Widget * paper = parent->createWidget("Widget", MyGUI::IntCoord(0, 0, pag.getPageWidth(), pag.getPageHeight()), MyGUI::Align::Left | MyGUI::Align::Top); paper->setNeedMouseFocus(false); - bool ignoreNewlines = true; - for (size_t index = 0; index < text.size(); ++index) + BookTextParser parser(markup); + BookTextParser::Events event; + while ((event = parser.next()) != BookTextParser::Event_EOF) { - const UTFString::unicode_char ch = text.getChar(index); - if (!plainText.empty() && (ch == LEFT_ANGLE || index == text.size() - 1)) + if (event == BookTextParser::Event_BrTag || event == BookTextParser::Event_PTag) + continue; + + std::string plainText = parser.getReadyText(); + if (!plainText.empty()) { // if there's a newline at the end of the box caption, remove it - if (plainText[plainText.size()-1] == NEWLINE) + if (plainText[plainText.size()-1] == '\n') plainText.erase(plainText.end()-1); - TextElement elem(paper, pag, mTextStyle, plainText.asUTF8()); + TextElement elem(paper, pag, mTextStyle, plainText); elem.paginate(); - - plainText.clear(); } - if (ch == LEFT_ANGLE) + switch (event) { - const size_t tagStart = index + 1; - const size_t tagEnd = text.find('>', tagStart); - if (tagEnd == UTFString::npos) - throw std::runtime_error("BookTextParser Error: Tag is not terminated"); - const std::string tag = text.substr(tagStart, tagEnd - tagStart).asUTF8(); - - if (boost::algorithm::starts_with(tag, "IMG")) + case BookTextParser::Event_ImgTag: { - ImageElement elem(paper, pag, mTextStyle, tag); - elem.paginate(); + const BookTextParser::Attributes & attr = parser.getAttributes(); - ignoreNewlines = false; - } - else if (boost::algorithm::starts_with(tag, "FONT")) - { - parseFont(tag); - } - else if (boost::algorithm::starts_with(tag, "DIV")) - { - parseDiv(tag); - } + if (attr.find("src") == attr.end() || attr.find("width") == attr.end() || attr.find("height") == attr.end()) + continue; - index = tagEnd; - } - else - { - if (!ignoreNewlines || ch != NEWLINE) - { - plainText.push_back(ch); - ignoreNewlines = false; + std::string src = attr.at("src"); + int width = boost::lexical_cast(attr.at("width")); + int height = boost::lexical_cast(attr.at("height")); + + ImageElement elem(paper, pag, src, width, height); + elem.paginate(); + break; } + case BookTextParser::Event_FontTag: + handleFont(parser.getAttributes()); + break; + case BookTextParser::Event_DivTag: + handleDiv(parser.getAttributes()); + break; + default: + break; } } @@ -117,33 +240,31 @@ namespace MWGui return pag.getPages(); } - Paginator::Pages BookFormatter::markupToWidget(MyGUI::Widget * parent, std::string utf8Text) + Paginator::Pages BookFormatter::markupToWidget(MyGUI::Widget * parent, const std::string & markup) { - return markupToWidget(parent, utf8Text, parent->getWidth(), parent->getHeight()); + return markupToWidget(parent, markup, parent->getWidth(), parent->getHeight()); } - void BookFormatter::parseDiv(std::string tag) + void BookFormatter::handleDiv(const BookTextParser::Attributes & attr) { - if (tag.find("ALIGN=") == std::string::npos) + if (attr.find("align") == attr.end()) return; - int align_start = tag.find("ALIGN=")+7; - std::string align = tag.substr(align_start, tag.find('"', align_start)-align_start); - if (align == "CENTER") + std::string align = attr.at("align"); + + if (Misc::StringUtils::ciEqual(align, "center")) mTextStyle.mTextAlign = MyGUI::Align::HCenter; - else if (align == "LEFT") + else if (Misc::StringUtils::ciEqual(align, "left")) mTextStyle.mTextAlign = MyGUI::Align::Left; } - void BookFormatter::parseFont(std::string tag) + void BookFormatter::handleFont(const BookTextParser::Attributes & attr) { - if (tag.find("COLOR=") != std::string::npos) + if (attr.find("color") != attr.end()) { - int color_start = tag.find("COLOR=")+7; - int color; std::stringstream ss; - ss << tag.substr(color_start, tag.find('"', color_start)-color_start); + ss << attr.at("color"); ss >> std::hex >> color; mTextStyle.mColour = MyGUI::Colour( @@ -151,23 +272,22 @@ namespace MWGui (color>>8 & 0xFF) / 255.f, (color & 0xFF) / 255.f); } - if (tag.find("FACE=") != std::string::npos) + if (attr.find("face") != attr.end()) { - int face_start = tag.find("FACE=")+6; - std::string face = tag.substr(face_start, tag.find('"', face_start)-face_start); + std::string face = attr.at("face"); if (face != "Magic Cards") mTextStyle.mFont = face; } - if (tag.find("SIZE=") != std::string::npos) + if (attr.find("size") != attr.end()) { /// \todo } } /* GraphicElement */ - GraphicElement::GraphicElement(MyGUI::Widget * parent, Paginator & pag, const TextStyle & style) - : mParent(parent), mPaginator(pag), mStyle(style) + GraphicElement::GraphicElement(MyGUI::Widget * parent, Paginator & pag) + : mParent(parent), mPaginator(pag) { } @@ -189,22 +309,11 @@ namespace MWGui return mPaginator.getStartTop() + mPaginator.getPageHeight(); } - int GraphicElement::currentFontHeight() const - { - std::string fontName(mStyle.mFont == "Default" ? MyGUI::FontManager::getInstance().getDefaultFont() : mStyle.mFont); - return MyGUI::FontManager::getInstance().getByName(fontName)->getDefaultHeight(); - } - - float GraphicElement::widthForCharGlyph(MyGUI::Char unicodeChar) const - { - std::string fontName(mStyle.mFont == "Default" ? MyGUI::FontManager::getInstance().getDefaultFont() : mStyle.mFont); - return MyGUI::FontManager::getInstance().getByName(fontName) - ->getGlyphInfo(unicodeChar)->width; - } - /* TextElement */ - TextElement::TextElement(MyGUI::Widget * parent, Paginator & pag, const TextStyle & style, const std::string & text) - : GraphicElement(parent, pag, style) + TextElement::TextElement(MyGUI::Widget * parent, Paginator & pag, + const TextStyle & style, const std::string & text) + : GraphicElement(parent, pag), + mStyle(style) { MyGUI::EditBox* box = parent->createWidget("NormalText", MyGUI::IntCoord(0, pag.getCurrentTop(), pag.getPageWidth(), 0), MyGUI::Align::Left | MyGUI::Align::Top, @@ -222,6 +331,12 @@ namespace MWGui mEditBox = box; } + int TextElement::currentFontHeight() const + { + std::string fontName(mStyle.mFont == "Default" ? MyGUI::FontManager::getInstance().getDefaultFont() : mStyle.mFont); + return MyGUI::FontManager::getInstance().getByName(fontName)->getDefaultHeight(); + } + int TextElement::getHeight() { return mEditBox->getTextSize().height; @@ -250,19 +365,11 @@ namespace MWGui } /* ImageElement */ - ImageElement::ImageElement(MyGUI::Widget * parent, Paginator & pag, const TextStyle & style, const std::string & tag) - : GraphicElement(parent, pag, style), - mImageHeight(0) + ImageElement::ImageElement(MyGUI::Widget * parent, Paginator & pag, + const std::string & src, int width, int height) + : GraphicElement(parent, pag), + mImageHeight(height) { - int src_start = tag.find("SRC=")+5; - std::string src = tag.substr(src_start, tag.find('"', src_start)-src_start); - - int width_start = tag.find("WIDTH=")+7; - int width = boost::lexical_cast(tag.substr(width_start, tag.find('"', width_start)-width_start)); - - int height_start = tag.find("HEIGHT=")+8; - mImageHeight = boost::lexical_cast(tag.substr(height_start, tag.find('"', height_start)-height_start)); - mImageBox = parent->createWidget ("ImageBox", MyGUI::IntCoord(0, pag.getCurrentTop(), width, mImageHeight), MyGUI::Align::Left | MyGUI::Align::Top, parent->getName() + boost::lexical_cast(parent->getChildCount())); @@ -279,6 +386,9 @@ namespace MWGui int ImageElement::pageSplit() { + // if the image is larger than the page, fall back to the default pageSplit implementation + if (mImageHeight > mPaginator.getPageHeight()) + return GraphicElement::pageSplit(); return mPaginator.getCurrentTop(); } } diff --git a/apps/openmw/mwgui/formatting.hpp b/apps/openmw/mwgui/formatting.hpp index b0a8bce0f..545c1f31d 100644 --- a/apps/openmw/mwgui/formatting.hpp +++ b/apps/openmw/mwgui/formatting.hpp @@ -2,6 +2,7 @@ #define MWGUI_FORMATTING_H #include +#include namespace MWGui { @@ -23,6 +24,44 @@ namespace MWGui MyGUI::Align mTextAlign; }; + class BookTextParser + { + public: + typedef std::map Attributes; + enum Events + { + Event_None = -2, + Event_EOF = -1, + Event_LastText = 0, + Event_BrTag, + Event_PTag, + Event_ImgTag, + Event_DivTag, + Event_FontTag + }; + + BookTextParser(const std::string & text); + void registerTag(const std::string & tag, Events type); + std::string getReadyText(); + + Events next(); + void flushBuffer(); + const Attributes & getAttributes() const; + void parseTag(std::string tag); + + private: + int mIndex; + std::string mText; + std::string mReadyText; + + bool mIgnoreNewlineTags; + bool mIgnoreLineEndings; + Attributes mAttributes; + std::string mTag; + std::map mTagTypes; + std::string mBuffer; + }; + class Paginator { public: @@ -62,12 +101,13 @@ namespace MWGui class BookFormatter { public: - Paginator::Pages markupToWidget(MyGUI::Widget * parent, std::string utf8Text, const int pageWidth, const int pageHeight); - Paginator::Pages markupToWidget(MyGUI::Widget * parent, std::string utf8Text); + Paginator::Pages markupToWidget(MyGUI::Widget * parent, const std::string & markup, const int pageWidth, const int pageHeight); + Paginator::Pages markupToWidget(MyGUI::Widget * parent, const std::string & markup); protected: - void parseDiv(std::string tag); - void parseFont(std::string tag); + void handleImg(const BookTextParser::Attributes & attr); + void handleDiv(const BookTextParser::Attributes & attr); + void handleFont(const BookTextParser::Attributes & attr); private: TextStyle mTextStyle; }; @@ -75,18 +115,14 @@ namespace MWGui class GraphicElement { public: - GraphicElement(MyGUI::Widget * parent, Paginator & pag, const TextStyle & style); + GraphicElement(MyGUI::Widget * parent, Paginator & pag); virtual int getHeight() = 0; virtual void paginate(); virtual int pageSplit(); protected: - int currentFontHeight() const; - float widthForCharGlyph(MyGUI::Char unicodeChar) const; - MyGUI::Widget * mParent; Paginator & mPaginator; - TextStyle mStyle; }; class TextElement : public GraphicElement @@ -96,13 +132,15 @@ namespace MWGui virtual int getHeight(); virtual int pageSplit(); private: + int currentFontHeight() const; + TextStyle mStyle; MyGUI::EditBox * mEditBox; }; class ImageElement : public GraphicElement { public: - ImageElement(MyGUI::Widget * parent, Paginator & pag, const TextStyle & style, const std::string & tag); + ImageElement(MyGUI::Widget * parent, Paginator & pag, const std::string & src, int width, int height); virtual int getHeight(); virtual int pageSplit(); diff --git a/files/mygui/openmw_book.layout b/files/mygui/openmw_book.layout index f91cd696e..3b1cfea64 100644 --- a/files/mygui/openmw_book.layout +++ b/files/mygui/openmw_book.layout @@ -41,8 +41,8 @@ - - + + From 51cd2678aeb094b1b50d417b8d189b0331b4ab56 Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Sun, 21 Sep 2014 22:25:54 +0200 Subject: [PATCH 04/58] Book formatter: Fix last block of text not displaying --- apps/openmw/mwgui/formatting.cpp | 18 +++++++++++------- apps/openmw/mwgui/formatting.hpp | 1 - 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index a7aee1bc9..c8b6f3983 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -50,8 +50,12 @@ namespace MWGui while (1) { ++mIndex; + if (mIndex >= mText.size()) + { + flushBuffer(); return Event_EOF; + } char ch = mText[mIndex]; if (ch == '<') @@ -102,11 +106,7 @@ namespace MWGui } } - if (mIndex == mText.size() - 1) - { - flushBuffer(); - return Event_LastText; - } + } } @@ -133,7 +133,7 @@ namespace MWGui while (!tag.empty()) { - int sepPos = tag.find('='); + size_t sepPos = tag.find('='); if (sepPos == std::string::npos) return; @@ -188,8 +188,9 @@ namespace MWGui BookTextParser parser(markup); BookTextParser::Events event; - while ((event = parser.next()) != BookTextParser::Event_EOF) + for (;;) { + event = parser.next(); if (event == BookTextParser::Event_BrTag || event == BookTextParser::Event_PTag) continue; @@ -204,6 +205,9 @@ namespace MWGui elem.paginate(); } + if (event == BookTextParser::Event_EOF) + break; + switch (event) { case BookTextParser::Event_ImgTag: diff --git a/apps/openmw/mwgui/formatting.hpp b/apps/openmw/mwgui/formatting.hpp index 545c1f31d..71e398f7f 100644 --- a/apps/openmw/mwgui/formatting.hpp +++ b/apps/openmw/mwgui/formatting.hpp @@ -32,7 +32,6 @@ namespace MWGui { Event_None = -2, Event_EOF = -1, - Event_LastText = 0, Event_BrTag, Event_PTag, Event_ImgTag, From 4b1df64fba0ec3a79c2773b231f014035f2f3c82 Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Mon, 22 Sep 2014 16:28:17 +0200 Subject: [PATCH 05/58] Book parser: Fix comparison between signed and unsigned integer expressions --- apps/openmw/mwgui/formatting.cpp | 18 +++++++----------- apps/openmw/mwgui/formatting.hpp | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index c8b6f3983..f7188c8b6 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -21,7 +21,7 @@ namespace MWGui { /* BookTextParser */ BookTextParser::BookTextParser(const std::string & text) - : mIndex(-1), mText(text), mIgnoreNewlineTags(true), mIgnoreLineEndings(true) + : mIndex(0), mText(text), mIgnoreNewlineTags(true), mIgnoreLineEndings(true) { MWScript::InterpreterContext interpreterContext(NULL, MWWorld::Ptr()); // empty arguments, because there is no locals or actor mText = Interpreter::fixDefinesBook(mText, interpreterContext); @@ -47,16 +47,8 @@ namespace MWGui BookTextParser::Events BookTextParser::next() { - while (1) + while (mIndex < mText.size()) { - ++mIndex; - - if (mIndex >= mText.size()) - { - flushBuffer(); - return Event_EOF; - } - char ch = mText[mIndex]; if (ch == '<') { @@ -93,6 +85,7 @@ namespace MWGui mIgnoreNewlineTags = false; } + ++mIndex; return type; } } @@ -106,8 +99,11 @@ namespace MWGui } } - + ++mIndex; } + + flushBuffer(); + return Event_EOF; } void BookTextParser::flushBuffer() diff --git a/apps/openmw/mwgui/formatting.hpp b/apps/openmw/mwgui/formatting.hpp index 71e398f7f..f119422c9 100644 --- a/apps/openmw/mwgui/formatting.hpp +++ b/apps/openmw/mwgui/formatting.hpp @@ -49,7 +49,7 @@ namespace MWGui void parseTag(std::string tag); private: - int mIndex; + size_t mIndex; std::string mText; std::string mReadyText; From f87d7c3fce95b33dbfd0cfad155053fe76fc4694 Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Mon, 22 Sep 2014 21:25:41 +0200 Subject: [PATCH 06/58] Book formatter: Do not insert last page if it's empty, code cleanup --- apps/openmw/mwgui/formatting.cpp | 5 +++-- apps/openmw/mwgui/formatting.hpp | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index f7188c8b6..9c918e626 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -233,7 +233,8 @@ namespace MWGui } // insert last page - pag << Paginator::Page(pag.getStartTop(), pag.getStartTop() + pag.getPageHeight()); + if (pag.getStartTop() != pag.getCurrentTop()) + pag << Paginator::Page(pag.getStartTop(), pag.getStartTop() + pag.getPageHeight()); paper->setSize(paper->getWidth(), pag.getCurrentTop()); @@ -301,7 +302,7 @@ namespace MWGui mPaginator.setStartTop(newStartTop); } - mPaginator.modifyCurrentTop(getHeight()); + mPaginator.setCurrentTop(newTop); } int GraphicElement::pageSplit() diff --git a/apps/openmw/mwgui/formatting.hpp b/apps/openmw/mwgui/formatting.hpp index f119422c9..cf55b36fb 100644 --- a/apps/openmw/mwgui/formatting.hpp +++ b/apps/openmw/mwgui/formatting.hpp @@ -81,8 +81,6 @@ namespace MWGui void setStartTop(int top) { mStartTop = top; } void setCurrentTop(int top) { mCurrentTop = top; } - void modifyStartTop(int mod) { mStartTop += mod; } - void modifyCurrentTop(int mod) { mCurrentTop += mod; } Paginator & operator<<(const Page & page) { From 608e1518a5d078a08e6137b8348a527c5d61330e Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Mon, 22 Sep 2014 21:47:21 +0200 Subject: [PATCH 07/58] Hack to prevent newlines at the end of books possibly creating unnecessary pages for mygui versions lower than 3.2.2 --- apps/openmw/mwgui/formatting.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index 9c918e626..7de4950ee 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -197,6 +197,18 @@ namespace MWGui if (plainText[plainText.size()-1] == '\n') plainText.erase(plainText.end()-1); +#if (MYGUI_VERSION < MYGUI_DEFINE_VERSION(3, 2, 2)) + // splitting won't be fully functional until 3.2.2 (see TextElement::pageSplit()) + // hack: prevent newlines at the end of the book possibly creating unnecessary pages + if (event == BookTextParser::Event_EOF) + { + while (plainText[plainText.size()-1] == '\n') + { + plainText.erase(plainText.end()-1); + } + } +#endif + TextElement elem(paper, pag, mTextStyle, plainText); elem.paginate(); } From 22c71cec18c5e73e3cd90afaec6bd625fd81cd18 Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Mon, 22 Sep 2014 23:17:44 +0200 Subject: [PATCH 08/58] Check for text size --- apps/openmw/mwgui/formatting.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index 7de4950ee..d838ae8af 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -202,10 +202,8 @@ namespace MWGui // hack: prevent newlines at the end of the book possibly creating unnecessary pages if (event == BookTextParser::Event_EOF) { - while (plainText[plainText.size()-1] == '\n') - { + while (plainText.size() && plainText[plainText.size()-1] == '\n') plainText.erase(plainText.end()-1); - } } #endif From 06e683d37841190d55232c00e6a3c90f8ae14905 Mon Sep 17 00:00:00 2001 From: Ragora Date: Sun, 14 Sep 2014 16:29:06 -0400 Subject: [PATCH 09/58] Added code to play music on level up and on death --- apps/openmw/mwgui/levelupdialog.cpp | 4 ++++ apps/openmw/mwmechanics/actors.cpp | 11 ++++++----- apps/openmw/mwmechanics/character.cpp | 4 ++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index 272a9b27b..7188ab9df 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -5,6 +5,7 @@ #include "../mwbase/windowmanager.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" +#include "../mwbase/soundmanager.hpp" #include "../mwworld/class.hpp" #include "../mwworld/fallback.hpp" @@ -191,6 +192,9 @@ namespace MWGui setAttributeValues(); center(); + + // Play LevelUp Music + MWBase::Environment::get().getSoundManager()->streamMusic("Special/MW_Triumph.mp3"); } void LevelupDialog::onOkButtonClicked(MyGUI::Widget* sender) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 31a085660..ee54e48eb 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -275,7 +275,7 @@ namespace MWMechanics void Actors::engageCombat (const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2, bool againstPlayer) { CreatureStats& creatureStats = actor1.getClass().getCreatureStats(actor1); - + if (actor2.getClass().getCreatureStats(actor2).isDead() || actor1.getClass().getCreatureStats(actor1).isDead()) return; @@ -296,7 +296,7 @@ namespace MWMechanics bool aggressive; - if (againstPlayer) + if (againstPlayer) { // followers with high fight should not engage in combat with the player (e.g. bm_bear_black_summon) const std::list& followers = getActorsFollowing(actor2); @@ -1096,7 +1096,7 @@ namespace MWMechanics void Actors::update (float duration, bool paused) { if(!paused) - { + { static float timerUpdateAITargets = 0; // target lists get updated once every 1.0 sec @@ -1207,12 +1207,13 @@ namespace MWMechanics // check if we still have any player enemies to switch music static bool isBattleMusic = false; - if (isBattleMusic && hostilesCount == 0) + if (isBattleMusic && hostilesCount == 0 && !(player.getClass().getCreatureStats(player).isDead() && + MWBase::Environment::get().getSoundManager()->isMusicPlaying())) { MWBase::Environment::get().getSoundManager()->playPlaylist(std::string("Explore")); isBattleMusic = false; } - else if (!isBattleMusic && hostilesCount > 0) + else if (!isBattleMusic && hostilesCount > 0) { MWBase::Environment::get().getSoundManager()->playPlaylist(std::string("Battle")); isBattleMusic = true; diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 9d1e5e52f..c7c171982 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1634,6 +1634,10 @@ bool CharacterController::kill() mIdleState = CharState_None; mCurrentIdle.clear(); + // Play Death Music if it was the player dying + if(mPtr.getRefData().getHandle()=="player") + MWBase::Environment::get().getSoundManager()->streamMusic("Special/MW_Death.mp3"); + return true; } From aabbcd6ce426d5255268161779b64a1e6ffdd7a0 Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski Date: Tue, 23 Sep 2014 23:01:52 +0200 Subject: [PATCH 10/58] Added Okulo's name and surname, moved Nekochan to the inactive contributors. Signed-off-by: Lukasz Gromanowski --- credits.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/credits.txt b/credits.txt index fadc7de45..ab83b93be 100644 --- a/credits.txt +++ b/credits.txt @@ -110,8 +110,7 @@ Alex McKibben (WeirdSexy) - Podcaster Artem Kotsynyak (greye) - Russian News Writer Jim Clauwaert (Zedd) - Public Outreach Julien Voisin (jvoisin/ap0) - French News Writer -Okulo - English News Writer -Nekochan - English News Writer +Tom Koenderink (Okulo) - English News Writer Lukasz Gromanowski (lgro) - English News Writer Mickey Lyle (raevol) - Release Manager Pithorn - Chinese News Writer @@ -137,7 +136,7 @@ Sadler Artwork: Necrod - OpenMW Logo Mickey Lyle (raevol) - Wordpress Theme -Okulo, SirHerrbatka, crysthala - OpenMW Editor Icons +Tom Koenderink (Okulo), SirHerrbatka, crysthala - OpenMW Editor Icons Inactive Contributors: Ardekantur @@ -156,6 +155,7 @@ Kingpix Lordrea Michal Sciubidlo Nicolay Korslund +Nekochan pchan3 penguinroad psi29a From 45b43042371dd2ccba7073d446f8281f9e7aab30 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 21 Sep 2014 13:37:20 +0200 Subject: [PATCH 11/58] Store levitation/teleport enabled state in savegames (Fixes #1923) --- apps/openmw/mwstate/statemanagerimp.cpp | 1 + apps/openmw/mwworld/worldimp.cpp | 41 ++++++++++++++++--------- components/esm/defs.hpp | 1 + 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwstate/statemanagerimp.cpp b/apps/openmw/mwstate/statemanagerimp.cpp index aa2d48372..18ebe11ce 100644 --- a/apps/openmw/mwstate/statemanagerimp.cpp +++ b/apps/openmw/mwstate/statemanagerimp.cpp @@ -351,6 +351,7 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl case ESM::REC_ACTC: case ESM::REC_PROJ: case ESM::REC_MPRJ: + case ESM::REC_ENAB: MWBase::Environment::get().getWorld()->readRecord (reader, n.val, contentFileMap); break; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 425fa20e5..aff24abbd 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -302,7 +302,8 @@ namespace MWWorld +mProjectileManager->countSavedGameRecords() +1 // player record +1 // weather record - +1; // actorId counter + +1 // actorId counter + +1; // levitation/teleport enabled state } void World::write (ESM::ESMWriter& writer, Loading::Listener& progress) const @@ -325,25 +326,37 @@ namespace MWWorld mPlayer->write (writer, progress); mWeatherManager->write (writer, progress); mProjectileManager->write (writer, progress); + + writer.startRecord(ESM::REC_ENAB); + writer.writeHNT("TELE", mTeleportEnabled); + writer.writeHNT("LEVT", mLevitationEnabled); + writer.endRecord(ESM::REC_ENAB); + progress.increaseProgress(); } void World::readRecord (ESM::ESMReader& reader, int32_t type, const std::map& contentFileMap) { - if (type == ESM::REC_ACTC) - { - MWMechanics::CreatureStats::readActorIdCounter(reader); - return; - } - - if (!mStore.readRecord (reader, type) && - !mGlobalVariables.readRecord (reader, type) && - !mPlayer->readRecord (reader, type) && - !mWeatherManager->readRecord (reader, type) && - !mCells.readRecord (reader, type, contentFileMap) && - !mProjectileManager->readRecord (reader, type)) + switch (type) { - throw std::runtime_error ("unknown record in saved game"); + case ESM::REC_ACTC: + MWMechanics::CreatureStats::readActorIdCounter(reader); + return; + case ESM::REC_ENAB: + reader.getHNT(mTeleportEnabled, "TELE"); + reader.getHNT(mLevitationEnabled, "LEVT"); + return; + default: + if (!mStore.readRecord (reader, type) && + !mGlobalVariables.readRecord (reader, type) && + !mPlayer->readRecord (reader, type) && + !mWeatherManager->readRecord (reader, type) && + !mCells.readRecord (reader, type, contentFileMap) && + !mProjectileManager->readRecord (reader, type)) + { + throw std::runtime_error ("unknown record in saved game"); + } + break; } } diff --git a/components/esm/defs.hpp b/components/esm/defs.hpp index 67461d467..d5ba919b0 100644 --- a/components/esm/defs.hpp +++ b/components/esm/defs.hpp @@ -113,6 +113,7 @@ enum RecNameInts REC_PROJ = FourCC<'P','R','O','J'>::value, REC_DCOU = FourCC<'D','C','O','U'>::value, REC_MARK = FourCC<'M','A','R','K'>::value, + REC_ENAB = FourCC<'E','N','A','B'>::value, // format 1 REC_FILT = 0x544C4946, From 5d77c5e8cac1c506f50a9e415dfeb489c0704ddb Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 21 Sep 2014 18:01:52 +0200 Subject: [PATCH 12/58] Transfer item ownership to the buyer if item wasn't stolen (Fixes #1933) --- apps/openmw/mwgui/containeritemmodel.cpp | 2 +- apps/openmw/mwgui/tradeitemmodel.cpp | 8 +++++--- apps/openmw/mwgui/tradeitemmodel.hpp | 3 ++- apps/openmw/mwgui/tradewindow.cpp | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwgui/containeritemmodel.cpp b/apps/openmw/mwgui/containeritemmodel.cpp index b2befc3ba..520a32ef8 100644 --- a/apps/openmw/mwgui/containeritemmodel.cpp +++ b/apps/openmw/mwgui/containeritemmodel.cpp @@ -76,7 +76,7 @@ MWWorld::Ptr ContainerItemModel::copyItem (const ItemStack& item, size_t count, const MWWorld::Ptr& source = mItemSources[mItemSources.size()-1]; if (item.mBase.getContainerStore() == &source.getClass().getContainerStore(source)) throw std::runtime_error("Item to copy needs to be from a different container!"); - return *source.getClass().getContainerStore(source).add(item.mBase, count, source); + return *source.getClass().getContainerStore(source).add(item.mBase, count, source, setNewOwner); } void ContainerItemModel::removeItem (const ItemStack& item, size_t count) diff --git a/apps/openmw/mwgui/tradeitemmodel.cpp b/apps/openmw/mwgui/tradeitemmodel.cpp index 3abfac997..e1283c89d 100644 --- a/apps/openmw/mwgui/tradeitemmodel.cpp +++ b/apps/openmw/mwgui/tradeitemmodel.cpp @@ -119,7 +119,7 @@ namespace MWGui return mBorrowedToUs; } - void TradeItemModel::transferItems() + void TradeItemModel::transferItems(const MWWorld::Ptr& transferFrom) { std::vector::iterator it = mBorrowedToUs.begin(); for (; it != mBorrowedToUs.end(); ++it) @@ -135,9 +135,11 @@ namespace MWGui if (i == sourceModel->getItemCount()) throw std::runtime_error("The borrowed item disappeared"); - // reset owner while copying, but only for items bought by the player - bool setNewOwner = (mMerchant.isEmpty()); const ItemStack& item = sourceModel->getItem(i); + + bool setNewOwner = Misc::StringUtils::ciEqual(item.mBase.getCellRef().getOwner(), transferFrom.getCellRef().getRefId()) + || item.mBase.getCellRef().getOwner().empty(); + // copy the borrowed items to our model copyItem(item, it->mCount, setNewOwner); // then remove them from the source model diff --git a/apps/openmw/mwgui/tradeitemmodel.hpp b/apps/openmw/mwgui/tradeitemmodel.hpp index 1bfee9b2a..c463bf40b 100644 --- a/apps/openmw/mwgui/tradeitemmodel.hpp +++ b/apps/openmw/mwgui/tradeitemmodel.hpp @@ -30,7 +30,8 @@ namespace MWGui void returnItemBorrowedFromUs (ModelIndex itemIndex, ItemModel* source, size_t count); /// Permanently transfers items that were borrowed to us from another model to this model - void transferItems (); + /// @param transferFrom the actor that lent us the items + void transferItems (const MWWorld::Ptr& transferFrom); /// Aborts trade void abort(); diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index f09aff5ac..bf4a4c192 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -360,8 +360,8 @@ namespace MWGui MWBase::Environment::get().getDialogueManager()->applyDispositionChange(iBarterSuccessDisposition); // make the item transfer - mTradeModel->transferItems(); - playerItemModel->transferItems(); + mTradeModel->transferItems(player); + playerItemModel->transferItems(mPtr); // transfer the gold if (mCurrentBalance != 0) From a7c0e07d780527782a6650beec8cf1429ff53a88 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 21 Sep 2014 19:51:33 +0200 Subject: [PATCH 13/58] Add missing World cleanup for mLevitationEnabled --- apps/openmw/mwworld/worldimp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index aff24abbd..ed66ae427 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -289,6 +289,7 @@ namespace MWWorld mGodMode = false; mSky = true; mTeleportEnabled = true; + mLevitationEnabled = true; mGlobalVariables.fill (mStore); } From 0f99a959eb76e4d4a679720dcd976e189ad9b314 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 22 Sep 2014 11:26:16 +0200 Subject: [PATCH 14/58] Update barter offer for all items when another item is added (Fixes #1935) --- apps/openmw/mwgui/inventorywindow.cpp | 4 ++-- apps/openmw/mwgui/tradewindow.cpp | 34 +++++++++++++++++++-------- apps/openmw/mwgui/tradewindow.hpp | 2 ++ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 151016fe3..2786f6bd3 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -278,14 +278,14 @@ namespace MWGui if (item.mType == ItemStack::Type_Barter) { // this was an item borrowed to us by the merchant - MWBase::Environment::get().getWindowManager()->getTradeWindow()->returnItem(mSelectedItem, count); mTradeModel->returnItemBorrowedToUs(mSelectedItem, count); + MWBase::Environment::get().getWindowManager()->getTradeWindow()->returnItem(mSelectedItem, count); } else { // borrow item to the merchant - MWBase::Environment::get().getWindowManager()->getTradeWindow()->borrowItem(mSelectedItem, count); mTradeModel->borrowItemFromUs(mSelectedItem, count); + MWBase::Environment::get().getWindowManager()->getTradeWindow()->borrowItem(mSelectedItem, count); } mItemView->update(); diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index bf4a4c192..00f812c11 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -480,24 +480,38 @@ namespace MWGui mMerchantGold->setCaptionWithReplacing("#{sSellerGold} " + boost::lexical_cast(getMerchantGold())); } - void TradeWindow::sellToNpc(const MWWorld::Ptr& item, int count, bool boughtItem) + void TradeWindow::updateOffer() { - int diff = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(item, count), boughtItem); + TradeItemModel* playerTradeModel = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel(); - mCurrentBalance += diff; - mCurrentMerchantOffer += diff; + int merchantOffer = 0; + + std::vector playerBorrowed = playerTradeModel->getItemsBorrowedToUs(); + for (std::vector::const_iterator it = playerBorrowed.begin(); it != playerBorrowed.end(); ++it) + { + merchantOffer -= MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(it->mBase, it->mCount), true); + } + + std::vector merchantBorrowed = mTradeModel->getItemsBorrowedToUs(); + for (std::vector::const_iterator it = merchantBorrowed.begin(); it != merchantBorrowed.end(); ++it) + { + merchantOffer += MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(it->mBase, it->mCount), false); + } + int diff = merchantOffer - mCurrentMerchantOffer; + mCurrentMerchantOffer = merchantOffer; + mCurrentBalance += diff; updateLabels(); } - void TradeWindow::buyFromNpc(const MWWorld::Ptr& item, int count, bool soldItem) + void TradeWindow::sellToNpc(const MWWorld::Ptr& item, int count, bool boughtItem) { - int diff = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, getEffectiveValue(item, count), !soldItem); - - mCurrentBalance -= diff; - mCurrentMerchantOffer -= diff; + updateOffer(); + } - updateLabels(); + void TradeWindow::buyFromNpc(const MWWorld::Ptr& item, int count, bool soldItem) + { + updateOffer(); } void TradeWindow::onReferenceUnavailable() diff --git a/apps/openmw/mwgui/tradewindow.hpp b/apps/openmw/mwgui/tradewindow.hpp index b822331c3..11c0614b7 100644 --- a/apps/openmw/mwgui/tradewindow.hpp +++ b/apps/openmw/mwgui/tradewindow.hpp @@ -72,6 +72,8 @@ namespace MWGui void sellToNpc(const MWWorld::Ptr& item, int count, bool boughtItem); ///< only used for adjusting the gold balance void buyFromNpc(const MWWorld::Ptr& item, int count, bool soldItem); ///< only used for adjusting the gold balance + void updateOffer(); + void onItemSelected (int index); void sellItem (MyGUI::Widget* sender, int count); From 62ea913e697233a767a6bc78bdff38c7d79c455b Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 24 Sep 2014 20:09:48 +0200 Subject: [PATCH 15/58] Fix cmake warning --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2165fa07a..542ea3e94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -607,8 +607,8 @@ if (WIN32) foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) - set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(SolutionDir)$(Configuration)\" ) - set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(ProjectDir)$(Configuration)\" ) + set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(SolutionDir)$(Configuration)" ) + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(ProjectDir)$(Configuration)" ) endforeach( OUTPUTCONFIG ) if (USE_DEBUG_CONSOLE) From 088d01d7275fbf5735ae08d931a90e9782a5e774 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 24 Sep 2014 23:50:28 +0200 Subject: [PATCH 16/58] Minor cleanup --- apps/openmw/mwgui/class.cpp | 12 ------------ files/mygui/openmw_chargen_select_attribute.layout | 4 ++-- files/mygui/openmw_chargen_select_skill.layout | 10 +++++----- .../openmw_chargen_select_specialization.layout | 4 ++-- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index b661f9945..b4308858a 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -671,8 +671,6 @@ namespace MWGui // Centre dialog center(); - setText("LabelT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sSpecializationMenu1", "")); - getWidget(mSpecialization0, "Specialization0"); getWidget(mSpecialization1, "Specialization1"); getWidget(mSpecialization2, "Specialization2"); @@ -694,7 +692,6 @@ namespace MWGui MyGUI::Button* cancelButton; getWidget(cancelButton, "CancelButton"); - cancelButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sCancel", "")); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked); } @@ -737,8 +734,6 @@ namespace MWGui // Centre dialog center(); - setText("LabelT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sAttributesMenu1", "")); - for (int i = 0; i < 8; ++i) { Widgets::MWAttributePtr attribute; @@ -752,7 +747,6 @@ namespace MWGui MyGUI::Button* cancelButton; getWidget(cancelButton, "CancelButton"); - cancelButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sCancel", "")); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked); } @@ -788,11 +782,6 @@ namespace MWGui // Centre dialog center(); - setText("LabelT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sSkillsMenu1", "")); - setText("CombatLabelT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sSpecializationCombat", "")); - setText("MagicLabelT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sSpecializationMagic", "")); - setText("StealthLabelT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sSpecializationStealth", "")); - for(int i = 0; i < 9; i++) { char theIndex = '0'+i; @@ -849,7 +838,6 @@ namespace MWGui MyGUI::Button* cancelButton; getWidget(cancelButton, "CancelButton"); - cancelButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sCancel", "")); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked); } diff --git a/files/mygui/openmw_chargen_select_attribute.layout b/files/mygui/openmw_chargen_select_attribute.layout index a93b5c453..cd722ef3e 100644 --- a/files/mygui/openmw_chargen_select_attribute.layout +++ b/files/mygui/openmw_chargen_select_attribute.layout @@ -5,7 +5,7 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/files/mygui/openmw_chargen_select_skill.layout b/files/mygui/openmw_chargen_select_skill.layout index dc1798995..8d4ffdba2 100644 --- a/files/mygui/openmw_chargen_select_skill.layout +++ b/files/mygui/openmw_chargen_select_skill.layout @@ -5,13 +5,13 @@ - + - + @@ -26,7 +26,7 @@ - + @@ -41,7 +41,7 @@ - + @@ -57,7 +57,7 @@ - + diff --git a/files/mygui/openmw_chargen_select_specialization.layout b/files/mygui/openmw_chargen_select_specialization.layout index 7f8b5e02b..d0b74104b 100644 --- a/files/mygui/openmw_chargen_select_specialization.layout +++ b/files/mygui/openmw_chargen_select_specialization.layout @@ -6,7 +6,7 @@ - + @@ -24,7 +24,7 @@ - + From 62ab35881e60f7729aab1b11e5f66aadf123487c Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 25 Sep 2014 00:03:55 +0200 Subject: [PATCH 17/58] Don't advance skills in werewolf mode (thanks Hrnchamd) --- apps/openmw/mwclass/npc.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 80b6088f2..e8daaf4ff 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -1127,6 +1127,9 @@ namespace MWClass { MWMechanics::NpcStats& stats = getNpcStats (ptr); + if (stats.isWerewolf()) + return; + MWWorld::LiveCellRef *ref = ptr.get(); const ESM::Class *class_ = From 1afcc7adb56c8792577f326735ec1725ab748ad6 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 25 Sep 2014 00:04:38 +0200 Subject: [PATCH 18/58] Add imported font colors from openmw.cfg to MyGUI plugin --- apps/openmw/mwgui/windowmanagerimp.cpp | 42 ++--------------- components/CMakeLists.txt | 2 +- components/widgets/tags.cpp | 57 ++++++++++++++++++++++++ components/widgets/tags.hpp | 16 +++++++ plugins/mygui_resource_plugin/plugin.cpp | 54 +++++++++++++++++++++- plugins/mygui_resource_plugin/plugin.hpp | 5 +++ 6 files changed, 135 insertions(+), 41 deletions(-) create mode 100644 components/widgets/tags.cpp create mode 100644 components/widgets/tags.hpp diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 3bf4e588a..198d293b3 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -19,6 +19,7 @@ #include #include +#include #include "../mwbase/inputmanager.hpp" #include "../mwbase/statemanager.hpp" @@ -991,50 +992,13 @@ namespace MWGui std::string tokenToFind = "sCell="; size_t tokenLength = tokenToFind.length(); - std::string fontcolour = "fontcolour="; - size_t fontcolourLength = fontcolour.length(); - - std::string fontcolourhtml = "fontcolourhtml="; - size_t fontcolourhtmlLength = fontcolourhtml.length(); - if (tag.compare(0, tokenLength, tokenToFind) == 0) { _result = mTranslationDataStorage.translateCellName(tag.substr(tokenLength)); } - else if (tag.compare(0, fontcolourLength, fontcolour) == 0) + else if (Gui::replaceTag(tag, _result, mFallbackMap)) { - std::string fallbackName = "FontColor_color_" + tag.substr(fontcolourLength); - std::map::const_iterator it = mFallbackMap.find(fallbackName); - if (it == mFallbackMap.end()) - throw std::runtime_error("Unknown fallback name: " + fallbackName); - std::string str = it->second; - - std::string ret[3]; - unsigned int j=0; - for(unsigned int i=0;i::const_iterator it = mFallbackMap.find(fallbackName); - if (it == mFallbackMap.end()) - throw std::runtime_error("Unknown fallback name: " + fallbackName); - std::string str = it->second; - - std::string ret[3]; - unsigned int j=0; - for(unsigned int i=0;i + +namespace Gui +{ + +bool replaceTag(const MyGUI::UString& tag, MyGUI::UString& out, const std::map& fallbackSettings) +{ + std::string fontcolour = "fontcolour="; + size_t fontcolourLength = fontcolour.length(); + + std::string fontcolourhtml = "fontcolourhtml="; + size_t fontcolourhtmlLength = fontcolourhtml.length(); + + if (tag.compare(0, fontcolourLength, fontcolour) == 0) + { + std::string fallbackName = "FontColor_color_" + tag.substr(fontcolourLength); + std::map::const_iterator it = fallbackSettings.find(fallbackName); + if (it == fallbackSettings.end()) + throw std::runtime_error("Unknown fallback name: " + fallbackName); + std::string str = it->second; + + std::string ret[3]; + unsigned int j=0; + for(unsigned int i=0;i::const_iterator it = fallbackSettings.find(fallbackName); + if (it == fallbackSettings.end()) + throw std::runtime_error("Unknown fallback name: " + fallbackName); + std::string str = it->second; + + std::string ret[3]; + unsigned int j=0; + for(unsigned int i=0;i +#include +#include + +namespace Gui +{ + +/// Try to replace a tag. Returns true on success and writes the result to \a out. +bool replaceTag (const MyGUI::UString& tag, MyGUI::UString& out, const std::map& fallbackSettings); + +} + +#endif diff --git a/plugins/mygui_resource_plugin/plugin.cpp b/plugins/mygui_resource_plugin/plugin.cpp index 9633bc51b..7b5572e62 100644 --- a/plugins/mygui_resource_plugin/plugin.cpp +++ b/plugins/mygui_resource_plugin/plugin.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -12,10 +13,49 @@ #include #include +#include #include #include +//FIXME: code duplication +namespace boost +{ +struct FallbackMap { + std::map mMap; +}; + +void validate(boost::any &v, std::vector const &tokens, FallbackMap*, int) +{ + if(v.empty()) + { + v = boost::any(FallbackMap()); + } + + FallbackMap *map = boost::any_cast(&v); + + std::map::iterator mapIt; + for(std::vector::const_iterator it=tokens.begin(); it != tokens.end(); ++it) + { + int sep = it->find(","); + if(sep < 1 || sep == (int)it->length()-1) +#if (BOOST_VERSION < 104200) + throw boost::program_options::validation_error("invalid value"); +#else + throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value); +#endif + + std::string key(it->substr(0,sep)); + std::string value(it->substr(sep+1)); + + if((mapIt = map->mMap.find(key)) == map->mMap.end()) + { + map->mMap.insert(std::make_pair (key,value)); + } + } +} +} + namespace MyGUIPlugin { @@ -51,7 +91,9 @@ namespace MyGUIPlugin ("fs-strict", boost::program_options::value()->implicit_value(true)->default_value(false)) ("fallback-archive", boost::program_options::value >()-> default_value(std::vector(), "fallback-archive")->multitoken()) - ("encoding", boost::program_options::value()->default_value("win1252")); + ("encoding", boost::program_options::value()->default_value("win1252")) + ("fallback", boost::program_options::value()->default_value(boost::FallbackMap(), "") + ->multitoken()->composing(), "fallback values"); boost::program_options::notify(variables); @@ -86,6 +128,8 @@ namespace MyGUIPlugin Gui::FontLoader loader(ToUTF8::calculateEncoding(encoding)); loader.loadAllFonts(false); + + mFallbackMap = variables["fallback"].as().mMap; } void ResourcePlugin::registerWidgets() @@ -126,6 +170,8 @@ namespace MyGUIPlugin registerResources(); registerWidgets(); createTransparentBGTexture(); + + MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &ResourcePlugin::onRetrieveTag); } void ResourcePlugin::shutdown() @@ -135,4 +181,10 @@ namespace MyGUIPlugin MYGUI_LOGGING("OpenMW_Resource_Plugin", Info, "shutdown"); } + void ResourcePlugin::onRetrieveTag(const MyGUI::UString& tag, MyGUI::UString& out) + { + if (!Gui::replaceTag(tag, out, mFallbackMap)) + out = tag; + } + } diff --git a/plugins/mygui_resource_plugin/plugin.hpp b/plugins/mygui_resource_plugin/plugin.hpp index 9d035f09c..6a06060d9 100644 --- a/plugins/mygui_resource_plugin/plugin.hpp +++ b/plugins/mygui_resource_plugin/plugin.hpp @@ -2,6 +2,7 @@ #define OPENMW_MYGUI_RESOURCE_PLUGIN_H #include +#include namespace MyGUIPlugin { @@ -40,6 +41,10 @@ namespace MyGUIPlugin void registerResources(); void registerWidgets(); void createTransparentBGTexture(); + + void onRetrieveTag(const MyGUI::UString& tag, MyGUI::UString& out); + + std::map mFallbackMap; }; } From 40587f984d365b2879bae0940e0390e2245e6a1a Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 25 Sep 2014 12:25:57 +0200 Subject: [PATCH 19/58] Implement price-based mercantile skill progress (Fixes #1947), thanks Hrnchamd Correct barter formula (removed erroneous clamping) --- apps/openmw/mwclass/npc.cpp | 4 ++-- apps/openmw/mwclass/npc.hpp | 2 +- apps/openmw/mwgui/tradewindow.cpp | 22 +++++++++++++++------- apps/openmw/mwmechanics/npcstats.cpp | 8 +++++--- apps/openmw/mwmechanics/npcstats.hpp | 4 ++-- apps/openmw/mwworld/class.cpp | 2 +- apps/openmw/mwworld/class.hpp | 2 +- 7 files changed, 27 insertions(+), 17 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index e8daaf4ff..dd879305d 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -1123,7 +1123,7 @@ namespace MWClass return cast.cast(id); } - void Npc::skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const + void Npc::skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType, float extraFactor) const { MWMechanics::NpcStats& stats = getNpcStats (ptr); @@ -1137,7 +1137,7 @@ namespace MWClass ref->mBase->mClass ); - stats.useSkill (skill, *class_, usageType); + stats.useSkill (skill, *class_, usageType, extraFactor); } float Npc::getArmorRating (const MWWorld::Ptr& ptr) const diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index 71e34e498..05594a530 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -136,7 +136,7 @@ namespace MWClass virtual void adjustScale (const MWWorld::Ptr &ptr, float &scale) const; - virtual void skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const; + virtual void skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType, float extraFactor=1.f) const; ///< Inform actor \a ptr that a skill use has succeeded. virtual void adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const; diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 00f812c11..3d888e468 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -324,12 +324,12 @@ namespace MWGui const MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr); const MWMechanics::CreatureStats &playerStats = player.getClass().getCreatureStats(player); - float a1 = std::min(player.getClass().getSkill(player, ESM::Skill::Mercantile), 100); - float b1 = std::min(0.1f * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f); - float c1 = std::min(0.2f * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f); - float d1 = std::min(mPtr.getClass().getSkill(mPtr, ESM::Skill::Mercantile), 100); - float e1 = std::min(0.1f * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f); - float f1 = std::min(0.2f * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f); + float a1 = player.getClass().getSkill(player, ESM::Skill::Mercantile); + float b1 = 0.1f * playerStats.getAttribute(ESM::Attribute::Luck).getModified(); + float c1 = 0.2f * playerStats.getAttribute(ESM::Attribute::Personality).getModified(); + float d1 = mPtr.getClass().getSkill(mPtr, ESM::Skill::Mercantile); + float e1 = 0.1f * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(); + float f1 = 0.2f * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(); float pcTerm = (clampedDisposition - 50 + a1 + b1 + c1) * playerStats.getFatigueTerm(); float npcTerm = (d1 + e1 + f1) * sellerStats.getFatigueTerm(); @@ -352,7 +352,15 @@ namespace MWGui } //skill use! - player.getClass().skillUsageSucceeded(player, ESM::Skill::Mercantile, 0); + float skillGain = 0.f; + int finalPrice = std::abs(mCurrentBalance); + int initialMerchantOffer = std::abs(mCurrentMerchantOffer); + if (!buying && (finalPrice > initialMerchantOffer) && finalPrice > 0) + skillGain = int(100 * (finalPrice - initialMerchantOffer) / float(finalPrice)); + else if (buying && (finalPrice < initialMerchantOffer) && initialMerchantOffer > 0) + skillGain = int(100 * (initialMerchantOffer - finalPrice) / float(initialMerchantOffer)); + + player.getClass().skillUsageSucceeded(player, ESM::Skill::Mercantile, 0, skillGain); } int iBarterSuccessDisposition = gmst.find("iBarterSuccessDisposition")->getInt(); diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 87fb835a7..370c47b1f 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -107,7 +107,7 @@ bool MWMechanics::NpcStats::isSameFaction (const NpcStats& npcStats) const } float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& class_, int usageType, - int level) const + int level, float extraFactor) const { if (level<0) level = static_cast (getSkill (skillIndex).getBase()); @@ -131,6 +131,8 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla return 0; } + skillFactor *= extraFactor; + const MWWorld::Store &gmst = MWBase::Environment::get().getWorld()->getStore().get(); @@ -167,7 +169,7 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla return 1.0 / ((level+1) * (1.0/skillFactor) * typeFactor * specialisationFactor); } -void MWMechanics::NpcStats::useSkill (int skillIndex, const ESM::Class& class_, int usageType) +void MWMechanics::NpcStats::useSkill (int skillIndex, const ESM::Class& class_, int usageType, float extraFactor) { // Don't increase skills as a werewolf if(mIsWerewolf) @@ -175,7 +177,7 @@ void MWMechanics::NpcStats::useSkill (int skillIndex, const ESM::Class& class_, MWMechanics::SkillValue& value = getSkill (skillIndex); - value.setProgress(value.getProgress() + getSkillGain (skillIndex, class_, usageType)); + value.setProgress(value.getProgress() + getSkillGain (skillIndex, class_, usageType, -1, extraFactor)); if (value.getProgress()>=1) { diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 406db7762..4ea5d4578 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -81,12 +81,12 @@ namespace MWMechanics ///< Do *this and \a npcStats share a faction? float getSkillGain (int skillIndex, const ESM::Class& class_, int usageType = -1, - int level = -1) const; + int level = -1, float extraFactor=1.f) const; ///< \param usageType: Usage specific factor, specified in the respective skill record; /// -1: use a factor of 1.0 instead. /// \param level Level to base calculation on; -1: use current level. - void useSkill (int skillIndex, const ESM::Class& class_, int usageType = -1); + void useSkill (int skillIndex, const ESM::Class& class_, int usageType = -1, float extraFactor=1.f); ///< Increase skill by usage. void increaseSkill (int skillIndex, const ESM::Class& class_, bool preserveProgress); diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 59fc86d0d..c0654a7f4 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -52,7 +52,7 @@ namespace MWWorld return false; } - void Class::skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const + void Class::skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType, float extraFactor) const { throw std::runtime_error ("class does not represent an actor"); } diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 64e83179d..5d9c0a0ea 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -231,7 +231,7 @@ namespace MWWorld /// /// (default implementation: ignore and return false) - virtual void skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const; + virtual void skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType, float extraFactor=1.f) const; ///< Inform actor \a ptr that a skill use has succeeded. /// /// (default implementations: throws an exception) From ad318c1f9dc522594e59b574476f336e5b9b1196 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 25 Sep 2014 15:07:15 +0200 Subject: [PATCH 20/58] Add XML definition file for the MyGUI plugin --- files/mygui/CMakeLists.txt | 1 + files/mygui/OpenMWResourcePlugin.xml | 30 ++++++++++++++++++++++++++++ files/mygui/core_layouteditor.xml | 1 + 3 files changed, 32 insertions(+) create mode 100644 files/mygui/OpenMWResourcePlugin.xml diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index bfd622bd3..323371eb7 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -86,6 +86,7 @@ set(MYGUI_FILES DejaVuLGCSansMono.ttf markers.png ../launcher/images/openmw.png + OpenMWResourcePlugin.xml ) diff --git a/files/mygui/OpenMWResourcePlugin.xml b/files/mygui/OpenMWResourcePlugin.xml new file mode 100644 index 000000000..e1de58a1d --- /dev/null +++ b/files/mygui/OpenMWResourcePlugin.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + ./Plugin_MyGUI_OpenMW_Resources + ./Plugin_MyGUI_OpenMW_Resources_d + + + diff --git a/files/mygui/core_layouteditor.xml b/files/mygui/core_layouteditor.xml index 007b5e638..a945f2aae 100644 --- a/files/mygui/core_layouteditor.xml +++ b/files/mygui/core_layouteditor.xml @@ -1,6 +1,7 @@ + From 206609720280ae35250132b4a7fa8b63a8f4792d Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 25 Sep 2014 15:28:02 +0200 Subject: [PATCH 21/58] Fix incorrect reading of global map state in some cases when the map size changed (Fixes #1946) --- apps/openmw/mwrender/globalmap.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index d543308ff..6ebcfcd26 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -326,7 +326,8 @@ namespace MWRender mOverlayTexture->getBuffer()->blit(tex->getBuffer(), srcBox, destBox); if (srcBox.left == destBox.left && srcBox.right == destBox.right - && srcBox.top == destBox.top && srcBox.bottom == destBox.bottom) + && srcBox.top == destBox.top && srcBox.bottom == destBox.bottom + && int(image.getWidth()) == mWidth && int(image.getHeight()) == mHeight) mOverlayImage = image; else mOverlayTexture->convertToImage(mOverlayImage); From 6b65502557038c8b050a49e30efe43d53cf0cbc1 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 25 Sep 2014 16:25:08 +0200 Subject: [PATCH 22/58] Add properties for new widget classes to MyGUI plugin --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwgui/dialogue.cpp | 3 +- apps/openmw/mwgui/dialogue.hpp | 12 +- apps/openmw/mwgui/journalwindow.cpp | 15 +- apps/openmw/mwgui/list.cpp | 169 ---------------------- apps/openmw/mwgui/list.hpp | 74 ---------- apps/openmw/mwgui/spellcreationdialog.cpp | 2 +- apps/openmw/mwgui/spellcreationdialog.hpp | 7 +- apps/openmw/mwgui/windowmanagerimp.cpp | 2 +- components/CMakeLists.txt | 2 +- components/widgets/box.cpp | 2 +- components/widgets/list.cpp | 165 +++++++++++++++++++++ components/widgets/list.hpp | 71 +++++++++ files/mygui/OpenMWResourcePlugin.xml | 94 ++++++++---- plugins/mygui_resource_plugin/plugin.cpp | 2 + 15 files changed, 329 insertions(+), 293 deletions(-) delete mode 100644 apps/openmw/mwgui/list.cpp delete mode 100644 apps/openmw/mwgui/list.hpp create mode 100644 components/widgets/list.cpp create mode 100644 components/widgets/list.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 0ad2cbd2a..2417091f8 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -32,7 +32,7 @@ add_openmw_dir (mwinput add_openmw_dir (mwgui textinput widgets race class birth review windowmanagerimp console dialogue windowbase statswindow messagebox journalwindow charactercreation - mapwindow windowpinnablebase tooltips scrollwindow bookwindow list + mapwindow windowpinnablebase tooltips scrollwindow bookwindow formatting inventorywindow container hud countdialog tradewindow settingswindow confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog spellcreationdialog diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 4931c6787..28639a8e1 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -3,6 +3,8 @@ #include #include +#include + #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" #include "../mwbase/mechanicsmanager.hpp" @@ -17,7 +19,6 @@ #include "../mwdialogue/dialoguemanagerimp.hpp" #include "widgets.hpp" -#include "list.hpp" #include "tradewindow.hpp" #include "spellbuyingwindow.hpp" #include "travelwindow.hpp" diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 6f16fcb03..18f1f1555 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -8,14 +8,14 @@ #include "keywordsearch.hpp" +namespace Gui +{ + class MWList; +} + namespace MWGui { class WindowManager; - - namespace Widgets - { - class MWList; - } } /* @@ -169,7 +169,7 @@ namespace MWGui KeywordSearchT mKeywordSearch; BookPage* mHistory; - Widgets::MWList* mTopicsList; + Gui::MWList* mTopicsList; MyGUI::ScrollBar* mScrollBar; MyGUI::Progress* mDispositionBar; MyGUI::EditBox* mDispositionText; diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index bc7fbde15..6cf8bb003 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -4,7 +4,6 @@ #include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" #include "../mwbase/journal.hpp" -#include "list.hpp" #include #include @@ -16,12 +15,12 @@ #include "boost/lexical_cast.hpp" #include +#include #include "bookpage.hpp" #include "windowbase.hpp" #include "journalviewmodel.hpp" #include "journalbooks.hpp" -#include "list.hpp" namespace { @@ -111,10 +110,10 @@ namespace adviseButtonClick (ShowAllBTN, &JournalWindowImpl::notifyShowAll ); adviseButtonClick (ShowActiveBTN, &JournalWindowImpl::notifyShowActive); - MWGui::Widgets::MWList* list = getWidget(QuestsList); + Gui::MWList* list = getWidget(QuestsList); list->eventItemSelected += MyGUI::newDelegate(this, &JournalWindowImpl::notifyQuestClicked); - MWGui::Widgets::MWList* topicsList = getWidget(TopicsList); + Gui::MWList* topicsList = getWidget(TopicsList); topicsList->eventItemSelected += MyGUI::newDelegate(this, &JournalWindowImpl::notifyTopicSelected); { @@ -412,7 +411,7 @@ namespace setVisible (RightTopicIndex, false); setVisible (TopicsList, true); - MWGui::Widgets::MWList* list = getWidget(TopicsList); + Gui::MWList* list = getWidget(TopicsList); list->clear(); AddNamesToList add(list); @@ -435,9 +434,9 @@ namespace struct AddNamesToList { - AddNamesToList(MWGui::Widgets::MWList* list) : mList(list) {} + AddNamesToList(Gui::MWList* list) : mList(list) {} - MWGui::Widgets::MWList* mList; + Gui::MWList* mList; void operator () (const std::string& name) { mList->addItem(name); @@ -455,7 +454,7 @@ namespace setVisible (ShowAllBTN, !mAllQuests); setVisible (ShowActiveBTN, mAllQuests); - MWGui::Widgets::MWList* list = getWidget(QuestsList); + Gui::MWList* list = getWidget(QuestsList); list->clear(); AddNamesToList add(list); diff --git a/apps/openmw/mwgui/list.cpp b/apps/openmw/mwgui/list.cpp deleted file mode 100644 index ff14bcf61..000000000 --- a/apps/openmw/mwgui/list.cpp +++ /dev/null @@ -1,169 +0,0 @@ -#include "list.hpp" - -#include -#include -#include -#include - -namespace MWGui -{ - - namespace Widgets - { - - MWList::MWList() : - mClient(0) - , mScrollView(0) - , mItemHeight(0) - { - } - - void MWList::initialiseOverride() - { - Base::initialiseOverride(); - - assignWidget(mClient, "Client"); - if (mClient == 0) - mClient = this; - - mScrollView = mClient->createWidgetReal( - "MW_ScrollView", MyGUI::FloatCoord(0.0, 0.0, 1.0, 1.0), - MyGUI::Align::Top | MyGUI::Align::Left | MyGUI::Align::Stretch, getName() + "_ScrollView"); - } - - void MWList::addItem(const std::string& name) - { - mItems.push_back(name); - } - - void MWList::addSeparator() - { - mItems.push_back(""); - } - - void MWList::adjustSize() - { - redraw(); - } - - void MWList::redraw(bool scrollbarShown) - { - const int _scrollBarWidth = 20; // fetch this from skin? - const int scrollBarWidth = scrollbarShown ? _scrollBarWidth : 0; - const int spacing = 3; - size_t viewPosition = -mScrollView->getViewOffset().top; - - while (mScrollView->getChildCount()) - { - MyGUI::Gui::getInstance().destroyWidget(mScrollView->getChildAt(0)); - } - - mItemHeight = 0; - int i=0; - for (std::vector::const_iterator it=mItems.begin(); - it!=mItems.end(); ++it) - { - if (*it != "") - { - if (mListItemSkin.empty()) - throw std::runtime_error("MWList needs a ListItemSkin property"); - MyGUI::Button* button = mScrollView->createWidget( - mListItemSkin, MyGUI::IntCoord(0, mItemHeight, mScrollView->getSize().width - scrollBarWidth - 2, 24), - MyGUI::Align::Left | MyGUI::Align::Top, getName() + "_item_" + (*it)); - button->setCaption((*it)); - button->getSubWidgetText()->setWordWrap(true); - button->getSubWidgetText()->setTextAlign(MyGUI::Align::Left); - button->eventMouseWheel += MyGUI::newDelegate(this, &MWList::onMouseWheel); - button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWList::onItemSelected); - - int height = button->getTextSize().height; - button->setSize(MyGUI::IntSize(button->getSize().width, height)); - button->setUserData(i); - - mItemHeight += height + spacing; - } - else - { - MyGUI::ImageBox* separator = mScrollView->createWidget("MW_HLine", - MyGUI::IntCoord(2, mItemHeight, mScrollView->getWidth() - scrollBarWidth - 4, 18), - MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch); - separator->setNeedMouseFocus(false); - - mItemHeight += 18 + spacing; - } - ++i; - } - - // Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden - mScrollView->setVisibleVScroll(false); - mScrollView->setCanvasSize(mClient->getSize().width, std::max(mItemHeight, mClient->getSize().height)); - mScrollView->setVisibleVScroll(true); - - if (!scrollbarShown && mItemHeight > mClient->getSize().height) - redraw(true); - - size_t viewRange = mScrollView->getCanvasSize().height; - if(viewPosition > viewRange) - viewPosition = viewRange; - mScrollView->setViewOffset(MyGUI::IntPoint(0, viewPosition * -1)); - } - - void MWList::setPropertyOverride(const std::string &_key, const std::string &_value) - { - if (_key == "ListItemSkin") - mListItemSkin = _value; - else - Base::setPropertyOverride(_key, _value); - } - - bool MWList::hasItem(const std::string& name) - { - return (std::find(mItems.begin(), mItems.end(), name) != mItems.end()); - } - - unsigned int MWList::getItemCount() - { - return mItems.size(); - } - - std::string MWList::getItemNameAt(unsigned int at) - { - assert(at < mItems.size() && "List item out of bounds"); - return mItems[at]; - } - - void MWList::removeItem(const std::string& name) - { - assert( std::find(mItems.begin(), mItems.end(), name) != mItems.end() ); - mItems.erase( std::find(mItems.begin(), mItems.end(), name) ); - } - - void MWList::clear() - { - mItems.clear(); - } - - void MWList::onMouseWheel(MyGUI::Widget* _sender, int _rel) - { - //NB view offset is negative - if (mScrollView->getViewOffset().top + _rel*0.3 > 0) - mScrollView->setViewOffset(MyGUI::IntPoint(0, 0)); - else - mScrollView->setViewOffset(MyGUI::IntPoint(0, mScrollView->getViewOffset().top + _rel*0.3)); - } - - void MWList::onItemSelected(MyGUI::Widget* _sender) - { - std::string name = _sender->castType()->getCaption(); - int id = *_sender->getUserData(); - eventItemSelected(name, id); - eventWidgetSelected(_sender); - } - - MyGUI::Widget* MWList::getItemWidget(const std::string& name) - { - return mScrollView->findWidget (getName() + "_item_" + name); - } - - } -} diff --git a/apps/openmw/mwgui/list.hpp b/apps/openmw/mwgui/list.hpp deleted file mode 100644 index acf078a2c..000000000 --- a/apps/openmw/mwgui/list.hpp +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef MWGUI_LIST_HPP -#define MWGUI_LIST_HPP - -#include - -namespace MWGui -{ - namespace Widgets - { - /** - * \brief a very simple list widget that supports word-wrapping entries - * \note if the width or height of the list changes, you must call adjustSize() method - */ - class MWList : public MyGUI::Widget - { - MYGUI_RTTI_DERIVED(MWList) - public: - MWList(); - - typedef MyGUI::delegates::CMultiDelegate2 EventHandle_StringInt; - typedef MyGUI::delegates::CMultiDelegate1 EventHandle_Widget; - - /** - * Event: Item selected with the mouse. - * signature: void method(std::string itemName, int index) - */ - EventHandle_StringInt eventItemSelected; - - /** - * Event: Item selected with the mouse. - * signature: void method(MyGUI::Widget* sender) - */ - EventHandle_Widget eventWidgetSelected; - - - /** - * Call after the size of the list changed, or items were inserted/removed - */ - void adjustSize(); - - void addItem(const std::string& name); - void addSeparator(); ///< add a seperator between the current and the next item. - void removeItem(const std::string& name); - bool hasItem(const std::string& name); - unsigned int getItemCount(); - std::string getItemNameAt(unsigned int at); ///< \attention if there are separators, this method will return "" at the place where the separator is - void clear(); - - MyGUI::Widget* getItemWidget(const std::string& name); - ///< get widget for an item name, useful to set up tooltip - - virtual void setPropertyOverride(const std::string& _key, const std::string& _value); - - protected: - void initialiseOverride(); - - void redraw(bool scrollbarShown = false); - - void onMouseWheel(MyGUI::Widget* _sender, int _rel); - void onItemSelected(MyGUI::Widget* _sender); - - private: - MyGUI::ScrollView* mScrollView; - MyGUI::Widget* mClient; - std::string mListItemSkin; - - std::vector mItems; - - int mItemHeight; // height of all items - }; - } -} - -#endif diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index e6da3d692..cdab79af1 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -522,7 +522,7 @@ namespace MWGui updateEffectsView (); } - void EffectEditorBase::setWidgets (Widgets::MWList *availableEffectsList, MyGUI::ScrollView *usedEffectsView) + void EffectEditorBase::setWidgets (Gui::MWList *availableEffectsList, MyGUI::ScrollView *usedEffectsView) { mAvailableEffectsList = availableEffectsList; mUsedEffectsView = usedEffectsView; diff --git a/apps/openmw/mwgui/spellcreationdialog.hpp b/apps/openmw/mwgui/spellcreationdialog.hpp index be984c8d4..e77c0eecf 100644 --- a/apps/openmw/mwgui/spellcreationdialog.hpp +++ b/apps/openmw/mwgui/spellcreationdialog.hpp @@ -1,9 +1,10 @@ #ifndef MWGUI_SPELLCREATION_H #define MWGUI_SPELLCREATION_H +#include + #include "windowbase.hpp" #include "referenceinterface.hpp" -#include "list.hpp" #include "widgets.hpp" namespace MWGui @@ -97,7 +98,7 @@ namespace MWGui protected: std::map mButtonMapping; // maps button ID to effect ID - Widgets::MWList* mAvailableEffectsList; + Gui::MWList* mAvailableEffectsList; MyGUI::ScrollView* mUsedEffectsView; EditEffectDialog mAddEffectDialog; @@ -124,7 +125,7 @@ namespace MWGui void updateEffectsView(); void startEditing(); - void setWidgets (Widgets::MWList* availableEffectsList, MyGUI::ScrollView* usedEffectsView); + void setWidgets (Gui::MWList* availableEffectsList, MyGUI::ScrollView* usedEffectsView); virtual void notifyEffectsChanged () {} diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 198d293b3..1b400bb58 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -165,7 +165,7 @@ namespace MWGui MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index c0065937a..baddfd6a2 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -96,7 +96,7 @@ add_component_dir (ogreinit ) add_component_dir (widgets - box imagebutton tags + box imagebutton tags list ) add_component_dir (fontloader diff --git a/components/widgets/box.cpp b/components/widgets/box.cpp index 6ec471b65..e1c148271 100644 --- a/components/widgets/box.cpp +++ b/components/widgets/box.cpp @@ -8,7 +8,7 @@ namespace Gui MyGUI::Widget * parent = w->getParent(); if (parent != 0) { - if (mExpandDirection == MyGUI::Align::Left) + if (mExpandDirection.isLeft()) { int hdiff = getRequestedSize ().width - w->getSize().width; w->setPosition(w->getPosition() - MyGUI::IntPoint(hdiff, 0)); diff --git a/components/widgets/list.cpp b/components/widgets/list.cpp new file mode 100644 index 000000000..86db2fdf4 --- /dev/null +++ b/components/widgets/list.cpp @@ -0,0 +1,165 @@ +#include "list.hpp" + +#include +#include +#include +#include + +namespace Gui +{ + + MWList::MWList() : + mClient(0) + , mScrollView(0) + , mItemHeight(0) + { + } + + void MWList::initialiseOverride() + { + Base::initialiseOverride(); + + assignWidget(mClient, "Client"); + if (mClient == 0) + mClient = this; + + mScrollView = mClient->createWidgetReal( + "MW_ScrollView", MyGUI::FloatCoord(0.0, 0.0, 1.0, 1.0), + MyGUI::Align::Top | MyGUI::Align::Left | MyGUI::Align::Stretch, getName() + "_ScrollView"); + } + + void MWList::addItem(const std::string& name) + { + mItems.push_back(name); + } + + void MWList::addSeparator() + { + mItems.push_back(""); + } + + void MWList::adjustSize() + { + redraw(); + } + + void MWList::redraw(bool scrollbarShown) + { + const int _scrollBarWidth = 20; // fetch this from skin? + const int scrollBarWidth = scrollbarShown ? _scrollBarWidth : 0; + const int spacing = 3; + size_t viewPosition = -mScrollView->getViewOffset().top; + + while (mScrollView->getChildCount()) + { + MyGUI::Gui::getInstance().destroyWidget(mScrollView->getChildAt(0)); + } + + mItemHeight = 0; + int i=0; + for (std::vector::const_iterator it=mItems.begin(); + it!=mItems.end(); ++it) + { + if (*it != "") + { + if (mListItemSkin.empty()) + return; + MyGUI::Button* button = mScrollView->createWidget( + mListItemSkin, MyGUI::IntCoord(0, mItemHeight, mScrollView->getSize().width - scrollBarWidth - 2, 24), + MyGUI::Align::Left | MyGUI::Align::Top, getName() + "_item_" + (*it)); + button->setCaption((*it)); + button->getSubWidgetText()->setWordWrap(true); + button->getSubWidgetText()->setTextAlign(MyGUI::Align::Left); + button->eventMouseWheel += MyGUI::newDelegate(this, &MWList::onMouseWheel); + button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWList::onItemSelected); + + int height = button->getTextSize().height; + button->setSize(MyGUI::IntSize(button->getSize().width, height)); + button->setUserData(i); + + mItemHeight += height + spacing; + } + else + { + MyGUI::ImageBox* separator = mScrollView->createWidget("MW_HLine", + MyGUI::IntCoord(2, mItemHeight, mScrollView->getWidth() - scrollBarWidth - 4, 18), + MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch); + separator->setNeedMouseFocus(false); + + mItemHeight += 18 + spacing; + } + ++i; + } + + // Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden + mScrollView->setVisibleVScroll(false); + mScrollView->setCanvasSize(mClient->getSize().width, std::max(mItemHeight, mClient->getSize().height)); + mScrollView->setVisibleVScroll(true); + + if (!scrollbarShown && mItemHeight > mClient->getSize().height) + redraw(true); + + size_t viewRange = mScrollView->getCanvasSize().height; + if(viewPosition > viewRange) + viewPosition = viewRange; + mScrollView->setViewOffset(MyGUI::IntPoint(0, viewPosition * -1)); + } + + void MWList::setPropertyOverride(const std::string &_key, const std::string &_value) + { + if (_key == "ListItemSkin") + mListItemSkin = _value; + else + Base::setPropertyOverride(_key, _value); + } + + bool MWList::hasItem(const std::string& name) + { + return (std::find(mItems.begin(), mItems.end(), name) != mItems.end()); + } + + unsigned int MWList::getItemCount() + { + return mItems.size(); + } + + std::string MWList::getItemNameAt(unsigned int at) + { + assert(at < mItems.size() && "List item out of bounds"); + return mItems[at]; + } + + void MWList::removeItem(const std::string& name) + { + assert( std::find(mItems.begin(), mItems.end(), name) != mItems.end() ); + mItems.erase( std::find(mItems.begin(), mItems.end(), name) ); + } + + void MWList::clear() + { + mItems.clear(); + } + + void MWList::onMouseWheel(MyGUI::Widget* _sender, int _rel) + { + //NB view offset is negative + if (mScrollView->getViewOffset().top + _rel*0.3 > 0) + mScrollView->setViewOffset(MyGUI::IntPoint(0, 0)); + else + mScrollView->setViewOffset(MyGUI::IntPoint(0, mScrollView->getViewOffset().top + _rel*0.3)); + } + + void MWList::onItemSelected(MyGUI::Widget* _sender) + { + std::string name = _sender->castType()->getCaption(); + int id = *_sender->getUserData(); + eventItemSelected(name, id); + eventWidgetSelected(_sender); + } + + MyGUI::Widget* MWList::getItemWidget(const std::string& name) + { + return mScrollView->findWidget (getName() + "_item_" + name); + } + +} diff --git a/components/widgets/list.hpp b/components/widgets/list.hpp new file mode 100644 index 000000000..8b4955a2d --- /dev/null +++ b/components/widgets/list.hpp @@ -0,0 +1,71 @@ +#ifndef MWGUI_LIST_HPP +#define MWGUI_LIST_HPP + +#include + +namespace Gui +{ + /** + * \brief a very simple list widget that supports word-wrapping entries + * \note if the width or height of the list changes, you must call adjustSize() method + */ + class MWList : public MyGUI::Widget + { + MYGUI_RTTI_DERIVED(MWList) + public: + MWList(); + + typedef MyGUI::delegates::CMultiDelegate2 EventHandle_StringInt; + typedef MyGUI::delegates::CMultiDelegate1 EventHandle_Widget; + + /** + * Event: Item selected with the mouse. + * signature: void method(std::string itemName, int index) + */ + EventHandle_StringInt eventItemSelected; + + /** + * Event: Item selected with the mouse. + * signature: void method(MyGUI::Widget* sender) + */ + EventHandle_Widget eventWidgetSelected; + + + /** + * Call after the size of the list changed, or items were inserted/removed + */ + void adjustSize(); + + void addItem(const std::string& name); + void addSeparator(); ///< add a seperator between the current and the next item. + void removeItem(const std::string& name); + bool hasItem(const std::string& name); + unsigned int getItemCount(); + std::string getItemNameAt(unsigned int at); ///< \attention if there are separators, this method will return "" at the place where the separator is + void clear(); + + MyGUI::Widget* getItemWidget(const std::string& name); + ///< get widget for an item name, useful to set up tooltip + + virtual void setPropertyOverride(const std::string& _key, const std::string& _value); + + protected: + void initialiseOverride(); + + void redraw(bool scrollbarShown = false); + + void onMouseWheel(MyGUI::Widget* _sender, int _rel); + void onItemSelected(MyGUI::Widget* _sender); + + private: + MyGUI::ScrollView* mScrollView; + MyGUI::Widget* mClient; + std::string mListItemSkin; + + std::vector mItems; + + int mItemHeight; // height of all items + }; +} + +#endif diff --git a/files/mygui/OpenMWResourcePlugin.xml b/files/mygui/OpenMWResourcePlugin.xml index e1de58a1d..4b2ad3f7b 100644 --- a/files/mygui/OpenMWResourcePlugin.xml +++ b/files/mygui/OpenMWResourcePlugin.xml @@ -1,30 +1,70 @@ - - - - - - - - - - - - - - - - - - - - - - - - ./Plugin_MyGUI_OpenMW_Resources - ./Plugin_MyGUI_OpenMW_Resources_d - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ./Plugin_MyGUI_OpenMW_Resources + ./Plugin_MyGUI_OpenMW_Resources_d + + diff --git a/plugins/mygui_resource_plugin/plugin.cpp b/plugins/mygui_resource_plugin/plugin.cpp index 7b5572e62..349b440a5 100644 --- a/plugins/mygui_resource_plugin/plugin.cpp +++ b/plugins/mygui_resource_plugin/plugin.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -142,6 +143,7 @@ namespace MyGUIPlugin MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); } void ResourcePlugin::createTransparentBGTexture() From f721b7adfbf2df6bcc35ff9a4bf4955826edca25 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 25 Sep 2014 16:41:27 +0200 Subject: [PATCH 23/58] Change skin files to use ResourceSkin (Skin is deprecated) - now the SkinEditor can load them --- files/mygui/core.skin | 18 +- files/mygui/openmw_box.skin.xml | 42 ++-- files/mygui/openmw_button.skin.xml | 38 ++-- files/mygui/openmw_console.skin.xml | 10 +- files/mygui/openmw_dialogue_window_skin.xml | 6 +- files/mygui/openmw_edit.skin.xml | 18 +- files/mygui/openmw_hud_box.skin.xml | 14 +- files/mygui/openmw_hud_energybar.skin.xml | 62 ++--- files/mygui/openmw_journal_skin.xml | 18 +- files/mygui/openmw_list.skin.xml | 66 +++--- files/mygui/openmw_mainmenu_skin.xml | 2 +- files/mygui/openmw_map_window_skin.xml | 6 +- files/mygui/openmw_progress.skin.xml | 54 ++--- files/mygui/openmw_scroll_skin.xml | 10 +- files/mygui/openmw_text.skin.xml | 78 +++---- files/mygui/openmw_windows.skin.xml | 238 ++++++++++---------- 16 files changed, 340 insertions(+), 340 deletions(-) diff --git a/files/mygui/core.skin b/files/mygui/core.skin index fbcc73d8a..9aa566451 100644 --- a/files/mygui/core.skin +++ b/files/mygui/core.skin @@ -1,19 +1,19 @@ - - + + - + - - - - - + - + + + + + diff --git a/files/mygui/openmw_box.skin.xml b/files/mygui/openmw_box.skin.xml index e1d0e5dec..8ff21807d 100644 --- a/files/mygui/openmw_box.skin.xml +++ b/files/mygui/openmw_box.skin.xml @@ -3,9 +3,9 @@ - + - + @@ -13,8 +13,8 @@ as around the sections of the stats window, or around popup info windows --> - - + + @@ -22,8 +22,8 @@ as around the sections of the stats window, or around popup info windows --> - - + + @@ -31,8 +31,8 @@ as around the sections of the stats window, or around popup info windows --> - - + + @@ -40,30 +40,30 @@ as around the sections of the stats window, or around popup info windows --> - - + + - - + + - - + + - - + + - + - + @@ -72,10 +72,10 @@ as around the sections of the stats window, or around popup info windows --> - + - + - + diff --git a/files/mygui/openmw_button.skin.xml b/files/mygui/openmw_button.skin.xml index 9b0783160..9193e3874 100644 --- a/files/mygui/openmw_button.skin.xml +++ b/files/mygui/openmw_button.skin.xml @@ -1,8 +1,8 @@ - + - + @@ -10,8 +10,8 @@ - - + + @@ -19,8 +19,8 @@ - - + + @@ -28,8 +28,8 @@ - - + + @@ -37,30 +37,30 @@ - - + + - - + + - - + + - - + + - + - + @@ -83,5 +83,5 @@ - + diff --git a/files/mygui/openmw_console.skin.xml b/files/mygui/openmw_console.skin.xml index f36d9af46..4190e7976 100644 --- a/files/mygui/openmw_console.skin.xml +++ b/files/mygui/openmw_console.skin.xml @@ -1,20 +1,20 @@ - + - + - + - + - + diff --git a/files/mygui/openmw_dialogue_window_skin.xml b/files/mygui/openmw_dialogue_window_skin.xml index 5d8c98dad..3f7987f7a 100644 --- a/files/mygui/openmw_dialogue_window_skin.xml +++ b/files/mygui/openmw_dialogue_window_skin.xml @@ -1,14 +1,14 @@ - + - + - + diff --git a/files/mygui/openmw_edit.skin.xml b/files/mygui/openmw_edit.skin.xml index 31ba579bb..5ec48f752 100644 --- a/files/mygui/openmw_edit.skin.xml +++ b/files/mygui/openmw_edit.skin.xml @@ -1,17 +1,17 @@ - + - + - + - + @@ -25,9 +25,9 @@ - + - + @@ -39,9 +39,9 @@ - + - + @@ -56,6 +56,6 @@ - + diff --git a/files/mygui/openmw_hud_box.skin.xml b/files/mygui/openmw_hud_box.skin.xml index 770d28425..e7457e7d2 100644 --- a/files/mygui/openmw_hud_box.skin.xml +++ b/files/mygui/openmw_hud_box.skin.xml @@ -1,10 +1,10 @@ - + - + @@ -14,13 +14,13 @@ - + - + - + - + @@ -30,6 +30,6 @@ - + diff --git a/files/mygui/openmw_hud_energybar.skin.xml b/files/mygui/openmw_hud_energybar.skin.xml index c6f4c763c..640133d66 100644 --- a/files/mygui/openmw_hud_energybar.skin.xml +++ b/files/mygui/openmw_hud_energybar.skin.xml @@ -1,109 +1,109 @@ - + - + - - + + - - + + - + - + - - + + - - + + - - + + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + diff --git a/files/mygui/openmw_journal_skin.xml b/files/mygui/openmw_journal_skin.xml index d35ce68cf..942c9a4d4 100644 --- a/files/mygui/openmw_journal_skin.xml +++ b/files/mygui/openmw_journal_skin.xml @@ -1,26 +1,26 @@ - - + + - + - + - + - + - + - + @@ -32,5 +32,5 @@ - + diff --git a/files/mygui/openmw_list.skin.xml b/files/mygui/openmw_list.skin.xml index 01270ef23..21b17c8f0 100644 --- a/files/mygui/openmw_list.skin.xml +++ b/files/mygui/openmw_list.skin.xml @@ -1,10 +1,10 @@ - + - + @@ -32,9 +32,9 @@ - + - + @@ -42,11 +42,11 @@ - + - + @@ -76,9 +76,9 @@ - + - + @@ -87,26 +87,26 @@ - + - - + + - + - + - + @@ -120,9 +120,9 @@ - + - + @@ -133,9 +133,9 @@ - + - + @@ -146,58 +146,58 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/files/mygui/openmw_mainmenu_skin.xml b/files/mygui/openmw_mainmenu_skin.xml index af41d3a1e..33c1e7d62 100644 --- a/files/mygui/openmw_mainmenu_skin.xml +++ b/files/mygui/openmw_mainmenu_skin.xml @@ -1,4 +1,4 @@ - + diff --git a/files/mygui/openmw_map_window_skin.xml b/files/mygui/openmw_map_window_skin.xml index 03578f95b..31a70191f 100644 --- a/files/mygui/openmw_map_window_skin.xml +++ b/files/mygui/openmw_map_window_skin.xml @@ -1,11 +1,11 @@ - - + + - + diff --git a/files/mygui/openmw_progress.skin.xml b/files/mygui/openmw_progress.skin.xml index 7b1e413e5..761574c15 100644 --- a/files/mygui/openmw_progress.skin.xml +++ b/files/mygui/openmw_progress.skin.xml @@ -1,94 +1,94 @@ - + - + - - + + - - + + - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -99,5 +99,5 @@ - + diff --git a/files/mygui/openmw_scroll_skin.xml b/files/mygui/openmw_scroll_skin.xml index e40b5fd52..b0b9dca17 100644 --- a/files/mygui/openmw_scroll_skin.xml +++ b/files/mygui/openmw_scroll_skin.xml @@ -1,15 +1,15 @@ - + - + - + - + - + diff --git a/files/mygui/openmw_text.skin.xml b/files/mygui/openmw_text.skin.xml index b9b30e751..bae094ef6 100644 --- a/files/mygui/openmw_text.skin.xml +++ b/files/mygui/openmw_text.skin.xml @@ -1,6 +1,6 @@ - + - + - + - + - + - + - + - + - + - + @@ -49,28 +49,28 @@ color_misc=0,205,205 # ???? - + - + - + - + - + - + - + - + @@ -83,9 +83,9 @@ color_misc=0,205,205 # ???? - + - + @@ -98,9 +98,9 @@ color_misc=0,205,205 # ???? - + - + @@ -113,49 +113,49 @@ color_misc=0,205,205 # ???? - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/files/mygui/openmw_windows.skin.xml b/files/mygui/openmw_windows.skin.xml index 6a3b31edd..d01bd8ef2 100644 --- a/files/mygui/openmw_windows.skin.xml +++ b/files/mygui/openmw_windows.skin.xml @@ -1,100 +1,100 @@ - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + @@ -106,8 +106,8 @@ - - + + @@ -119,18 +119,18 @@ - + - + - + - + @@ -138,9 +138,9 @@ - + - + @@ -148,45 +148,45 @@ - + - + - + - + - + - + - - + + - - + + - - + + - + - + @@ -195,9 +195,9 @@ - + - + @@ -206,9 +206,9 @@ - + - + @@ -217,9 +217,9 @@ - + - + @@ -228,93 +228,93 @@ - + - + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -322,9 +322,9 @@ - + - + @@ -332,9 +332,9 @@ - + - + @@ -342,42 +342,42 @@ - + - + - + - + - + - + - - + + - - + + - - + + - + - + @@ -387,11 +387,11 @@ - + - + @@ -406,7 +406,7 @@ - + - + @@ -551,9 +551,9 @@ - + - + @@ -687,9 +687,9 @@ - + - + @@ -830,9 +830,9 @@ - + - + @@ -861,5 +861,5 @@ - + From 40ce5add59a4387ef7b2be833fac2753042a35eb Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 25 Sep 2014 17:32:44 +0200 Subject: [PATCH 24/58] Don't report crime for attacking an NPC that is already in combat with another NPC (Fixes #1908, Fixes #1821) --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index b0e92d0a8..f908072e3 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -1128,9 +1128,21 @@ namespace MWMechanics } } - // Attacking peaceful NPCs is a crime + // Attacking an NPC that is already in combat with any other NPC is not a crime + AiSequence& seq = ptr.getClass().getCreatureStats(ptr).getAiSequence(); + bool isFightingNpc = false; + for (std::list::const_iterator it = seq.begin(); it != seq.end(); ++it) + { + if ((*it)->getTypeId() == AiPackage::TypeIdCombat) + { + MWWorld::Ptr target = static_cast(*it)->getTarget(); + if (!target.isEmpty() && target.getClass().isNpc()) + isFightingNpc = true; + } + } + if (ptr.getClass().isNpc() && !attacker.isEmpty() && !ptr.getClass().getCreatureStats(ptr).getAiSequence().isInCombat(attacker) - && !isAggressive(ptr, attacker)) + && !isAggressive(ptr, attacker) && !isFightingNpc) commitCrime(attacker, ptr, MWBase::MechanicsManager::OT_Assault); if (!attacker.isEmpty() && (attacker.getClass().getCreatureStats(attacker).getAiSequence().isInCombat(ptr) From 8ad2b95208573b69a8dc31adb0defedec19ac939 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 25 Sep 2014 17:56:46 +0200 Subject: [PATCH 25/58] Revert "AiFollow: return from execute() if target is not player" This reverts commit 061c7813f6362b8ed16d6c79c016e6d5be18fdef. Fixes #1898. --- apps/openmw/mwmechanics/aifollow.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/apps/openmw/mwmechanics/aifollow.cpp b/apps/openmw/mwmechanics/aifollow.cpp index a10f97e78..abde80c71 100644 --- a/apps/openmw/mwmechanics/aifollow.cpp +++ b/apps/openmw/mwmechanics/aifollow.cpp @@ -50,11 +50,6 @@ bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor,float duration) ) return true; //Target doesn't exist - // Only the player can be actively followed. AiFollow packages with targets other than the player - // are only used for defining combat alliances, since NPCs will defend whoever they are following or being followed by. - if (target != MWBase::Environment::get().getWorld()->getPlayerPtr()) - return false; - actor.getClass().getCreatureStats(actor).setDrawState(DrawState_Nothing); ESM::Position pos = actor.getRefData().getPosition(); //position of the actor From f56711f443bdf3b90cd2cf4bd894f58747834dc1 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 25 Sep 2014 18:00:32 +0200 Subject: [PATCH 26/58] Fix crash caused by teleportation spells (Fixes #1904) --- apps/openmw/mwmechanics/actors.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 7045a7168..fb387afea 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -1175,14 +1175,26 @@ namespace MWMechanics iter->second->updateContinuousVfx(); // Animation/movement update + CharacterController* playerCharacter = NULL; for(PtrControllerMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter) { if (iter->first.getClass().getCreatureStats(iter->first).getMagicEffects().get( ESM::MagicEffect::Paralyze).getMagnitude() > 0) iter->second->skipAnim(); + + // Handle player last, in case a cell transition occurs by casting a teleportation spell + // (would invalidate the iterator) + if (iter->first.getCellRef().getRefId() == "player") + { + playerCharacter = iter->second; + continue; + } iter->second->update(duration); } + if (playerCharacter) + playerCharacter->update(duration); + for(PtrControllerMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter) { const MWWorld::Class &cls = iter->first.getClass(); From e4c097b4f7d89fae6b2ed52755bd941df5b907c4 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 25 Sep 2014 19:22:26 +0200 Subject: [PATCH 27/58] Fix wrong default ExpandDirection for AutoSizedButton --- components/widgets/box.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/widgets/box.hpp b/components/widgets/box.hpp index 40e76aca0..ccdc5784b 100644 --- a/components/widgets/box.hpp +++ b/components/widgets/box.hpp @@ -12,6 +12,8 @@ namespace Gui class AutoSizedWidget { public: + AutoSizedWidget() : mExpandDirection(MyGUI::Align::Right) {} + virtual MyGUI::IntSize getRequestedSize() = 0; protected: From 0bc840aadd8473158948e72fc69d1e4523fbf0db Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 25 Sep 2014 20:28:00 +0200 Subject: [PATCH 28/58] Add NumericEditBox widget --- apps/openmw/mwgui/countdialog.cpp | 32 ++++------ apps/openmw/mwgui/countdialog.hpp | 9 ++- apps/openmw/mwgui/tradewindow.cpp | 32 ++++------ apps/openmw/mwgui/tradewindow.hpp | 9 ++- apps/openmw/mwgui/windowmanagerimp.cpp | 10 +--- components/CMakeLists.txt | 2 +- components/widgets/numericeditbox.cpp | 74 ++++++++++++++++++++++++ components/widgets/numericeditbox.hpp | 45 ++++++++++++++ components/widgets/widgets.cpp | 25 ++++++++ components/widgets/widgets.hpp | 12 ++++ files/mygui/openmw_count_window.layout | 2 +- files/mygui/openmw_trade_window.layout | 2 +- plugins/mygui_resource_plugin/plugin.cpp | 12 +--- 13 files changed, 196 insertions(+), 70 deletions(-) create mode 100644 components/widgets/numericeditbox.cpp create mode 100644 components/widgets/numericeditbox.hpp create mode 100644 components/widgets/widgets.cpp create mode 100644 components/widgets/widgets.hpp diff --git a/apps/openmw/mwgui/countdialog.cpp b/apps/openmw/mwgui/countdialog.cpp index 53c33b3c4..24d0af0d7 100644 --- a/apps/openmw/mwgui/countdialog.cpp +++ b/apps/openmw/mwgui/countdialog.cpp @@ -2,6 +2,8 @@ #include +#include + #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" @@ -19,7 +21,7 @@ namespace MWGui mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CountDialog::onCancelButtonClicked); mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CountDialog::onOkButtonClicked); - mItemEdit->eventEditTextChange += MyGUI::newDelegate(this, &CountDialog::onEditTextChange); + mItemEdit->eventValueChanged += MyGUI::newDelegate(this, &CountDialog::onEditValueChanged); mSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &CountDialog::onSliderMoved); // make sure we read the enter key being pressed to accept multiple items mItemEdit->eventEditSelectAccept += MyGUI::newDelegate(this, &CountDialog::onEnterKeyPressed); @@ -46,7 +48,10 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mItemEdit); mSlider->setScrollPosition(maxCount-1); - mItemEdit->setCaption(boost::lexical_cast(maxCount)); + + mItemEdit->setMinValue(1); + mItemEdit->setMaxValue(maxCount); + mItemEdit->setValue(maxCount); } void CountDialog::cancel() //Keeping this here as I don't know if anything else relies on it. @@ -80,30 +85,13 @@ namespace MWGui setVisible(false); } - void CountDialog::onEditTextChange(MyGUI::EditBox* _sender) + void CountDialog::onEditValueChanged(int value) { - if (_sender->getCaption() == "") - return; - - unsigned int count; - try - { - count = boost::lexical_cast(_sender->getCaption()); - } - catch (std::bad_cast&) - { - count = 1; - } - if (count > mSlider->getScrollRange()) - { - count = mSlider->getScrollRange(); - } - mSlider->setScrollPosition(count-1); - onSliderMoved(mSlider, count-1); + mSlider->setScrollPosition(value-1); } void CountDialog::onSliderMoved(MyGUI::ScrollBar* _sender, size_t _position) { - mItemEdit->setCaption(boost::lexical_cast(_position+1)); + mItemEdit->setValue(_position+1); } } diff --git a/apps/openmw/mwgui/countdialog.hpp b/apps/openmw/mwgui/countdialog.hpp index a00b0b223..a54e99cf4 100644 --- a/apps/openmw/mwgui/countdialog.hpp +++ b/apps/openmw/mwgui/countdialog.hpp @@ -3,6 +3,11 @@ #include "windowbase.hpp" +namespace Gui +{ + class NumericEditBox; +} + namespace MWGui { class CountDialog : public WindowModal @@ -22,7 +27,7 @@ namespace MWGui private: MyGUI::ScrollBar* mSlider; - MyGUI::EditBox* mItemEdit; + Gui::NumericEditBox* mItemEdit; MyGUI::TextBox* mItemText; MyGUI::TextBox* mLabelText; MyGUI::Button* mOkButton; @@ -30,7 +35,7 @@ namespace MWGui void onCancelButtonClicked(MyGUI::Widget* _sender); void onOkButtonClicked(MyGUI::Widget* _sender); - void onEditTextChange(MyGUI::EditBox* _sender); + void onEditValueChanged(int value); void onSliderMoved(MyGUI::ScrollBar* _sender, size_t _position); void onEnterKeyPressed(MyGUI::EditBox* _sender); }; diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 3d888e468..081a1e2c2 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -2,6 +2,8 @@ #include +#include + #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/soundmanager.hpp" @@ -86,7 +88,7 @@ namespace MWGui mDecreaseButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &TradeWindow::onDecreaseButtonPressed); mDecreaseButton->eventMouseButtonReleased += MyGUI::newDelegate(this, &TradeWindow::onBalanceButtonReleased); - mTotalBalance->eventEditTextChange += MyGUI::newDelegate(this, &TradeWindow::onBalanceEdited); + mTotalBalance->eventValueChanged += MyGUI::newDelegate(this, &TradeWindow::onBalanceValueChanged); setCoord(400, 0, 400, 300); } @@ -433,21 +435,14 @@ namespace MWGui MyGUI::ControllerManager::getInstance().removeItem(_sender); } - void TradeWindow::onBalanceEdited(MyGUI::EditBox *_sender) + void TradeWindow::onBalanceValueChanged(int value) { - try - { - unsigned int count = boost::lexical_cast(_sender->getCaption()); - mCurrentBalance = count * (mCurrentBalance >= 0 ? 1 : -1); - updateLabels(); - } - catch (std::bad_cast&) - { - if (_sender->getCaption().empty()) - mTotalBalance->setCaption("0"); - else - mTotalBalance->setCaption(boost::lexical_cast(std::abs(mCurrentBalance))); - } + // Entering a "-" sign inverts the buying/selling state + mCurrentBalance = (mCurrentBalance >= 0 ? 1 : -1) * value; + updateLabels(); + + if (value != std::abs(value)) + mTotalBalance->setValue(std::abs(value)); } void TradeWindow::onIncreaseButtonTriggered() @@ -471,19 +466,16 @@ namespace MWGui mPlayerGold->setCaptionWithReplacing("#{sYourGold} " + boost::lexical_cast(playerGold)); - std::string balanceCaption; if (mCurrentBalance > 0) { mTotalBalanceLabel->setCaptionWithReplacing("#{sTotalSold}"); - balanceCaption = boost::lexical_cast(mCurrentBalance); } else { mTotalBalanceLabel->setCaptionWithReplacing("#{sTotalCost}"); - balanceCaption = boost::lexical_cast(-mCurrentBalance); } - if (balanceCaption != mTotalBalance->getCaption().asUTF8()) // Don't reset text cursor if text doesn't need to be changed - mTotalBalance->setCaption(balanceCaption); + + mTotalBalance->setValue(std::abs(mCurrentBalance)); mMerchantGold->setCaptionWithReplacing("#{sSellerGold} " + boost::lexical_cast(getMerchantGold())); } diff --git a/apps/openmw/mwgui/tradewindow.hpp b/apps/openmw/mwgui/tradewindow.hpp index 11c0614b7..47de9215a 100644 --- a/apps/openmw/mwgui/tradewindow.hpp +++ b/apps/openmw/mwgui/tradewindow.hpp @@ -3,10 +3,9 @@ #include "container.hpp" -namespace MyGUI +namespace Gui { - class Gui; - class Widget; + class NumericEditBox; } namespace MWGui @@ -54,7 +53,7 @@ namespace MWGui MyGUI::Button* mIncreaseButton; MyGUI::Button* mDecreaseButton; MyGUI::TextBox* mTotalBalanceLabel; - MyGUI::EditBox* mTotalBalance; + Gui::NumericEditBox* mTotalBalance; MyGUI::Widget* mBottomPane; @@ -84,7 +83,7 @@ namespace MWGui void onIncreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id); void onDecreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id); void onBalanceButtonReleased(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id); - void onBalanceEdited(MyGUI::EditBox* _sender); + void onBalanceValueChanged(int value); void onRepeatClick(MyGUI::Widget* widget, MyGUI::ControllerItem* controller); void addRepeatController(MyGUI::Widget* widget); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 1b400bb58..ef7622a62 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -18,7 +18,7 @@ #include -#include +#include #include #include "../mwbase/inputmanager.hpp" @@ -165,13 +165,6 @@ namespace MWGui MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); @@ -179,6 +172,7 @@ namespace MWGui BookPage::registerMyGUIComponents (); ItemView::registerComponents(); ItemWidget::registerComponents(); + Gui::registerAllWidgets(); MyGUI::FactoryManager::getInstance().registerFactory("Controller"); MyGUI::FactoryManager::getInstance().registerFactory("Controller"); diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index baddfd6a2..d0508e9d4 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -96,7 +96,7 @@ add_component_dir (ogreinit ) add_component_dir (widgets - box imagebutton tags list + box imagebutton tags list numericeditbox widgets ) add_component_dir (fontloader diff --git a/components/widgets/numericeditbox.cpp b/components/widgets/numericeditbox.cpp new file mode 100644 index 000000000..5361b3127 --- /dev/null +++ b/components/widgets/numericeditbox.cpp @@ -0,0 +1,74 @@ +#include "numericeditbox.hpp" + +#include + +namespace Gui +{ + + void NumericEditBox::initialiseOverride() + { + Base::initialiseOverride(); + eventEditTextChange += MyGUI::newDelegate(this, &NumericEditBox::onEditTextChange); + + mValue = 0; + setCaption("0"); + } + + void NumericEditBox::shutdownOverride() + { + Base::shutdownOverride(); + eventEditTextChange -= MyGUI::newDelegate(this, &NumericEditBox::onEditTextChange); + } + + void NumericEditBox::onEditTextChange(MyGUI::EditBox *sender) + { + std::string newCaption = sender->getCaption(); + if (newCaption.empty()) + { + return; + } + + try + { + mValue = boost::lexical_cast(newCaption); + int capped = std::min(mMaxValue, std::max(mValue, mMinValue)); + if (capped != mValue) + { + mValue = capped; + setCaption(MyGUI::utility::toString(mValue)); + } + } + catch (boost::bad_lexical_cast&) + { + setCaption(MyGUI::utility::toString(mValue)); + } + + eventValueChanged(mValue); + } + + void NumericEditBox::setValue(int value) + { + if (value != mValue) + { + setCaption(MyGUI::utility::toString(value)); + mValue = value; + } + } + + void NumericEditBox::setMinValue(int minValue) + { + mMinValue = minValue; + } + + void NumericEditBox::setMaxValue(int maxValue) + { + mMaxValue = maxValue; + } + + void NumericEditBox::onKeyLostFocus(MyGUI::Widget* _new) + { + Base::onKeyLostFocus(_new); + setCaption(MyGUI::utility::toString(mValue)); + } + +} diff --git a/components/widgets/numericeditbox.hpp b/components/widgets/numericeditbox.hpp new file mode 100644 index 000000000..bbc0e48f4 --- /dev/null +++ b/components/widgets/numericeditbox.hpp @@ -0,0 +1,45 @@ +#ifndef OPENMW_NUMERIC_EDIT_BOX_H +#define OPENMW_NUMERIC_EDIT_BOX_H + +#include + +namespace Gui +{ + + /** + * @brief A variant of the EditBox that only allows integer inputs + */ + class NumericEditBox : public MyGUI::EditBox + { + MYGUI_RTTI_DERIVED(NumericEditBox) + + public: + NumericEditBox() + : mValue(0), mMinValue(std::numeric_limits().min()), + mMaxValue(std::numeric_limits().max()) + {} + + void initialiseOverride(); + void shutdownOverride(); + + typedef MyGUI::delegates::CMultiDelegate1 EventHandle_ValueChanged; + EventHandle_ValueChanged eventValueChanged; + + /// @note Does not trigger eventValueChanged + void setValue (int value); + + void setMinValue(int minValue); + void setMaxValue(int maxValue); + private: + void onEditTextChange(MyGUI::EditBox* sender); + void onKeyLostFocus(MyGUI::Widget* _new); + + int mValue; + + int mMinValue; + int mMaxValue; + }; + +} + +#endif diff --git a/components/widgets/widgets.cpp b/components/widgets/widgets.cpp new file mode 100644 index 000000000..b35dc88a4 --- /dev/null +++ b/components/widgets/widgets.cpp @@ -0,0 +1,25 @@ +#include "widgets.hpp" + +#include + +#include "list.hpp" +#include "numericeditbox.hpp" +#include "box.hpp" +#include "imagebutton.hpp" + +namespace Gui +{ + + void registerAllWidgets() + { + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + } + +} diff --git a/components/widgets/widgets.hpp b/components/widgets/widgets.hpp new file mode 100644 index 000000000..d17132135 --- /dev/null +++ b/components/widgets/widgets.hpp @@ -0,0 +1,12 @@ +#ifndef OPENMW_COMPONENTS_WIDGETS_H +#define OPENMW_COMPONENTS_WIDGETS_H + +namespace Gui +{ + + /// Register all widgets from this component with MyGUI's factory manager. + void registerAllWidgets(); + +} + +#endif diff --git a/files/mygui/openmw_count_window.layout b/files/mygui/openmw_count_window.layout index 5f3a30af4..c5fe9e2c5 100644 --- a/files/mygui/openmw_count_window.layout +++ b/files/mygui/openmw_count_window.layout @@ -12,7 +12,7 @@ - + diff --git a/files/mygui/openmw_trade_window.layout b/files/mygui/openmw_trade_window.layout index cb00d7d50..b2017661b 100644 --- a/files/mygui/openmw_trade_window.layout +++ b/files/mygui/openmw_trade_window.layout @@ -44,7 +44,7 @@ - + diff --git a/plugins/mygui_resource_plugin/plugin.cpp b/plugins/mygui_resource_plugin/plugin.cpp index 349b440a5..ac4c9a3d4 100644 --- a/plugins/mygui_resource_plugin/plugin.cpp +++ b/plugins/mygui_resource_plugin/plugin.cpp @@ -11,10 +11,8 @@ #include #include -#include -#include #include -#include +#include #include #include @@ -137,13 +135,7 @@ namespace MyGUIPlugin { MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + Gui::registerAllWidgets(); } void ResourcePlugin::createTransparentBGTexture() From b75b464495a934ed2df6eebb761f3d791721b62a Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 25 Sep 2014 20:39:14 +0200 Subject: [PATCH 29/58] Move Cancel buttons to right side of dialog (Fixes #1715) --- files/mygui/openmw_count_window.layout | 6 +++--- files/mygui/openmw_edit_note.layout | 6 +++--- files/mygui/openmw_savegame_dialog.layout | 7 +++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/files/mygui/openmw_count_window.layout b/files/mygui/openmw_count_window.layout index c5fe9e2c5..29e07d28e 100644 --- a/files/mygui/openmw_count_window.layout +++ b/files/mygui/openmw_count_window.layout @@ -25,12 +25,12 @@ - - - + + + diff --git a/files/mygui/openmw_edit_note.layout b/files/mygui/openmw_edit_note.layout index 4985b5187..652f67f0c 100644 --- a/files/mygui/openmw_edit_note.layout +++ b/files/mygui/openmw_edit_note.layout @@ -22,12 +22,12 @@ - - - + + + diff --git a/files/mygui/openmw_savegame_dialog.layout b/files/mygui/openmw_savegame_dialog.layout index a2b2bcca7..c97e7f815 100644 --- a/files/mygui/openmw_savegame_dialog.layout +++ b/files/mygui/openmw_savegame_dialog.layout @@ -65,13 +65,12 @@ - - - - + + + From 9fbc7ebc026f63dac24bf79f805d2235bf07ec06 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 25 Sep 2014 20:52:27 +0200 Subject: [PATCH 30/58] Tweak CountDialog layout First time using the LayoutEditor. Success! --- files/mygui/openmw_count_window.layout | 31 ++++++++++---------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/files/mygui/openmw_count_window.layout b/files/mygui/openmw_count_window.layout index 29e07d28e..e9a1cb2c8 100644 --- a/files/mygui/openmw_count_window.layout +++ b/files/mygui/openmw_count_window.layout @@ -1,37 +1,30 @@ - - - - + + + - - + - - + - - + - - + - - - - + + - + - + - + From 764c6287e11f5af0eccc59af8e2f102bf4bb8cc5 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 26 Sep 2014 12:36:55 +0200 Subject: [PATCH 31/58] Remove some garbage --- files/mygui/openmw_resources.xml | 190 ------------------------------- 1 file changed, 190 deletions(-) diff --git a/files/mygui/openmw_resources.xml b/files/mygui/openmw_resources.xml index 5e987efff..e85fad244 100644 --- a/files/mygui/openmw_resources.xml +++ b/files/mygui/openmw_resources.xml @@ -25,196 +25,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 4f0fc79ea4b0aac71019f9d23559d66aacdfc784 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 26 Sep 2014 12:47:33 +0200 Subject: [PATCH 32/58] Change global map cell size from 24 to 18 and make it configurable --- apps/openmw/mwgui/mapwindow.cpp | 8 ++++--- apps/openmw/mwrender/globalmap.cpp | 36 ++++++++++++++---------------- apps/openmw/mwrender/globalmap.hpp | 8 +++++-- files/settings-default.cfg | 4 ++++ 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index cea505465..43ea6f7f9 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -675,10 +675,12 @@ namespace MWGui float worldX, worldY; mGlobalMapRender->cellTopLeftCornerToImageSpace (x, y, worldX, worldY); + int markerSize = 12; + int offset = mGlobalMapRender->getCellSize()/2 - markerSize/2; MyGUI::IntCoord widgetCoord( - worldX * mGlobalMapRender->getWidth()+6, - worldY * mGlobalMapRender->getHeight()+6, - 12, 12); + worldX * mGlobalMapRender->getWidth()+offset, + worldY * mGlobalMapRender->getHeight()+offset, + markerSize, markerSize); static int _counter=0; MyGUI::Button* markerWidget = mGlobalMapOverlay->createWidget("ButtonImage", diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index 6ebcfcd26..4e0bd00f9 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -29,6 +29,7 @@ namespace MWRender , mWidth(0) , mHeight(0) { + mCellSize = Settings::Manager::getInt("global map cell size", "Map"); } GlobalMap::~GlobalMap() @@ -57,9 +58,8 @@ namespace MWRender mMaxY = it->getGridY(); } - int cellSize = 24; - mWidth = cellSize*(mMaxX-mMinX+1); - mHeight = cellSize*(mMaxY-mMinY+1); + mWidth = mCellSize*(mMaxX-mMinX+1); + mHeight = mCellSize*(mMaxY-mMinY+1); loadingListener->loadingOn(); loadingListener->setLabel("Creating map"); @@ -90,16 +90,16 @@ namespace MWRender land->loadData(mask); } - for (int cellY=0; cellY mMaxX || cellX < mMinX || cellY > mMaxY || cellY < mMinY) return; @@ -213,17 +211,17 @@ namespace MWRender { mOverlayTexture->load(); mOverlayTexture->getBuffer()->blit(localMapTexture->getBuffer(), Ogre::Image::Box(0,0,512,512), - Ogre::Image::Box(originX,originY,originX+size,originY+size)); + Ogre::Image::Box(originX,originY,originX+mCellSize,originY+mCellSize)); Ogre::Image backup; std::vector data; - data.resize(size*size*4, 0); - backup.loadDynamicImage(&data[0], size, size, Ogre::PF_A8B8G8R8); + data.resize(mCellSize*mCellSize*4, 0); + backup.loadDynamicImage(&data[0], mCellSize, mCellSize, Ogre::PF_A8B8G8R8); localMapTexture->getBuffer()->blitToMemory(Ogre::Image::Box(0,0,512,512), backup.getPixelBox()); - for (int x=0; x no need to blit anything if (bounds.mMaxX < mMinX diff --git a/apps/openmw/mwrender/globalmap.hpp b/apps/openmw/mwrender/globalmap.hpp index 66fe89f73..b3ae85b11 100644 --- a/apps/openmw/mwrender/globalmap.hpp +++ b/apps/openmw/mwrender/globalmap.hpp @@ -26,8 +26,10 @@ namespace MWRender void render(Loading::Listener* loadingListener); - int getWidth() { return mWidth; } - int getHeight() { return mHeight; } + int getWidth() const { return mWidth; } + int getHeight() const { return mHeight; } + + int getCellSize() const { return mCellSize; } void worldPosToImageSpace(float x, float z, float& imageX, float& imageY); @@ -46,6 +48,8 @@ namespace MWRender private: std::string mCacheDir; + int mCellSize; + std::vector< std::pair > mExploredCells; Ogre::TexturePtr mOverlayTexture; diff --git a/files/settings-default.cfg b/files/settings-default.cfg index fc651f463..67fd5ee8c 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -108,6 +108,10 @@ num lights = 8 # Use static geometry for static objects. Improves rendering speed. use static geometry = true +[Map] +# Adjusts the scale of the global map +global map cell size = 18 + [Viewing distance] # Limit the rendering distance of small objects limit small object distance = false From 97df7c9b22ed635e66aec8c3296c89d170f1d102 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 26 Sep 2014 13:40:10 +0200 Subject: [PATCH 33/58] Get rid of markers.png and use original MW texture, cleanup --- apps/openmw/mwgui/mapwindow.cpp | 111 +++++++++++++++++++++++-------- files/mygui/CMakeLists.txt | 1 - files/mygui/markers.png | Bin 245 -> 0 bytes files/mygui/openmw_resources.xml | 34 ++-------- 4 files changed, 87 insertions(+), 59 deletions(-) delete mode 100644 files/mygui/markers.png diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 43ea6f7f9..2fba92372 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -26,15 +26,55 @@ namespace const int cellSize = 8192; - enum WidgetDepth + enum LocalMapWidgetDepth { - CompassLayer = 0, - MarkerAboveFogLayer = 1, - FogLayer = 2, - MarkerLayer = 3, - MapLayer = 4 + Local_CompassLayer = 0, + Local_MarkerAboveFogLayer = 1, + Local_FogLayer = 2, + Local_MarkerLayer = 3, + Local_MapLayer = 4 }; + enum GlobalMapWidgetDepth + { + Global_CompassLayer = 0, + Global_MarkerLayer = 1, + Global_ExploreOverlayLayer = 2, + Global_MapLayer = 3 + }; + + + /// @brief A widget that changes its color when hovered. + class MarkerWidget: public MyGUI::Widget + { + MYGUI_RTTI_DERIVED(MarkerWidget) + + public: + void setNormalColour(const MyGUI::Colour& colour) + { + mNormalColour = colour; + setColour(colour); + } + + void setHoverColour(const MyGUI::Colour& colour) + { + mHoverColour = colour; + } + + private: + MyGUI::Colour mNormalColour; + MyGUI::Colour mHoverColour; + + void onMouseLostFocus(MyGUI::Widget* _new) + { + setColour(mNormalColour); + } + + void onMouseSetFocus(MyGUI::Widget* _old) + { + setColour(mHoverColour); + } + }; } namespace MWGui @@ -140,7 +180,7 @@ namespace MWGui mLocalMap = widget; mCompass = compass; - mCompass->setDepth(CompassLayer); + mCompass->setDepth(Local_CompassLayer); mCompass->setNeedMouseFocus(false); // create 3x3 map widgets, 512x512 each, holding a 1024x1024 texture each @@ -151,12 +191,12 @@ namespace MWGui MyGUI::ImageBox* map = mLocalMap->createWidget("ImageBox", MyGUI::IntCoord(mx*widgetSize, my*widgetSize, widgetSize, widgetSize), MyGUI::Align::Top | MyGUI::Align::Left); - map->setDepth(MapLayer); + map->setDepth(Local_MapLayer); MyGUI::ImageBox* fog = mLocalMap->createWidget("ImageBox", MyGUI::IntCoord(mx*widgetSize, my*widgetSize, widgetSize, widgetSize), MyGUI::Align::Top | MyGUI::Align::Left); - fog->setDepth(FogLayer); + fog->setDepth(Local_FogLayer); map->setNeedMouseFocus(false); fog->setNeedMouseFocus(false); @@ -273,15 +313,17 @@ namespace MWGui MyGUI::IntCoord widgetCoord(widgetPos.left - 4, widgetPos.top - 4, 8, 8); - MyGUI::Button* markerWidget = mLocalMap->createWidget("ButtonImage", + MarkerWidget* markerWidget = mLocalMap->createWidget("MarkerButton", widgetCoord, MyGUI::Align::Default); - markerWidget->setDepth(MarkerAboveFogLayer); - markerWidget->setImageResource("DoorMarker"); + markerWidget->setDepth(Local_MarkerAboveFogLayer); markerWidget->setUserString("ToolTipType", "Layout"); markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); markerWidget->setUserString("Caption_TextOneLine", MyGUI::TextIterator::toTagsString(marker.mNote)); markerWidget->setColour(MyGUI::Colour(1.0,0.3,0.3)); + markerWidget->setNormalColour(MyGUI::Colour(1.0,0.3,0.3)); + markerWidget->setHoverColour(MyGUI::Colour(1.0,0.5,0.5)); markerWidget->setUserData(marker); + markerWidget->setNeedMouseFocus(true); markerWidget->eventMouseButtonDoubleClick += MyGUI::newDelegate(this, &LocalMapBase::onCustomMarkerDoubleClicked); mCustomMarkerWidgets.push_back(markerWidget); } @@ -357,10 +399,12 @@ namespace MWGui widgetPos.top - 4, 8, 8); ++counter; - MyGUI::Button* markerWidget = mLocalMap->createWidget("ButtonImage", + MarkerWidget* markerWidget = mLocalMap->createWidget("MarkerButton", widgetCoord, MyGUI::Align::Default); - markerWidget->setDepth(MarkerLayer); - markerWidget->setImageResource("DoorMarker"); + markerWidget->setNormalColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal}"))); + markerWidget->setHoverColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal_over}"))); + markerWidget->setDepth(Local_MarkerLayer); + markerWidget->setNeedMouseFocus(true); markerWidget->setUserString("ToolTipType", "Layout"); markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); markerWidget->setUserString("Caption_TextOneLine", marker.name); @@ -458,7 +502,7 @@ namespace MWGui ++counter; MyGUI::ImageBox* markerWidget = mLocalMap->createWidget("ImageBox", widgetCoord, MyGUI::Align::Default); - markerWidget->setDepth(MarkerAboveFogLayer); + markerWidget->setDepth(Local_MarkerAboveFogLayer); markerWidget->setImageTexture(markerTexture); markerWidget->setUserString("IsMarker", "true"); markerWidget->setUserData(markerPos); @@ -503,7 +547,7 @@ namespace MWGui 8, 8); MyGUI::ImageBox* markerWidget = mLocalMap->createWidget("ImageBox", widgetCoord, MyGUI::Align::Default); - markerWidget->setDepth(MarkerAboveFogLayer); + markerWidget->setDepth(Local_MarkerAboveFogLayer); markerWidget->setImageTexture("textures\\menu_map_smark.dds"); markerWidget->setUserString("IsMarker", "true"); markerWidget->setUserData(markerPos); @@ -523,7 +567,18 @@ namespace MWGui , mGlobalMap(0) , mGlobalMapRender(0) , mEditNoteDialog() + , mEventBoxGlobal(NULL) + , mEventBoxLocal(NULL) + , mGlobalMapImage(NULL) + , mGlobalMapOverlay(NULL) { + static bool registered = false; + if (!registered) + { + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + registered = true; + } + mEditNoteDialog.setVisible(false); mEditNoteDialog.eventOkClicked += MyGUI::newDelegate(this, &MapWindow::onNoteEditOk); mEditNoteDialog.eventDeleteClicked += MyGUI::newDelegate(this, &MapWindow::onNoteEditDelete); @@ -537,6 +592,11 @@ namespace MWGui getWidget(mPlayerArrowLocal, "CompassLocal"); getWidget(mPlayerArrowGlobal, "CompassGlobal"); + mPlayerArrowGlobal->setDepth(Global_CompassLayer); + mPlayerArrowGlobal->setNeedMouseFocus(false); + mGlobalMapImage->setDepth(Global_MapLayer); + mGlobalMapOverlay->setDepth(Global_ExploreOverlayLayer); + mLastScrollWindowCoordinates = mLocalMap->getCoord(); mLocalMap->eventChangeCoord += MyGUI::newDelegate(this, &MapWindow::onChangeScrollWindowCoord); @@ -549,6 +609,8 @@ namespace MWGui getWidget(mEventBoxGlobal, "EventBoxGlobal"); mEventBoxGlobal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); mEventBoxGlobal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); + mEventBoxGlobal->setDepth(Global_ExploreOverlayLayer); + getWidget(mEventBoxLocal, "EventBoxLocal"); mEventBoxLocal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); mEventBoxLocal->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); @@ -683,21 +745,16 @@ namespace MWGui markerSize, markerSize); static int _counter=0; - MyGUI::Button* markerWidget = mGlobalMapOverlay->createWidget("ButtonImage", + MyGUI::Widget* markerWidget = mGlobalMap->createWidget("MarkerButton", widgetCoord, MyGUI::Align::Default); - markerWidget->setImageResource("DoorMarker"); + markerWidget->setNeedMouseFocus(true); + markerWidget->setColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal}"))); markerWidget->setUserString("ToolTipType", "Layout"); markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); markerWidget->setUserString("Caption_TextOneLine", name); + markerWidget->setDepth(Global_MarkerLayer); ++_counter; - markerWidget = mEventBoxGlobal->createWidget("", - widgetCoord, MyGUI::Align::Default); - markerWidget->setNeedMouseFocus (true); - markerWidget->setUserString("ToolTipType", "Layout"); - markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); - markerWidget->setUserString("Caption_TextOneLine", name); - CellId cell; cell.first = x; cell.second = y; @@ -829,8 +886,6 @@ namespace MWGui while (mEventBoxGlobal->getChildCount()) MyGUI::Gui::getInstance().destroyWidget(mEventBoxGlobal->getChildAt(0)); - while (mGlobalMapOverlay->getChildCount()) - MyGUI::Gui::getInstance().destroyWidget(mGlobalMapOverlay->getChildAt(0)); } void MapWindow::write(ESM::ESMWriter &writer, Loading::Listener& progress) diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index 323371eb7..87e750cc9 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -84,7 +84,6 @@ set(MYGUI_FILES openmw_screen_fader.layout openmw_edit_note.layout DejaVuLGCSansMono.ttf - markers.png ../launcher/images/openmw.png OpenMWResourcePlugin.xml ) diff --git a/files/mygui/markers.png b/files/mygui/markers.png deleted file mode 100644 index 76b6b9913b01cd9f805d1a9d7ff7693cf49c99fe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 245 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~c!3HEhl+{lMQfx`y?k)`fL2$v|<&%LToCO|{ z#S9GG!XV7ZFl&wkP>{XE)7O>#4u_0@5~t(+j%PrjCQlc~5RLQ6JiQ!qPd2bbNJdQD z$+KUw&iKLP^u&aOgov#*p;F9Z0BR06 zaSc8`saxaIQNyTA9w6{J(G|8nV(z}2qnk?DWEf`K2s5`fu+9{g60{PwoxpMOFz*4; i2?h - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + From 603e558fb7e9976d1d4b1faf3c1bc7b818cb1d5a Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 26 Sep 2014 14:16:46 +0200 Subject: [PATCH 34/58] Fix broken getCollidingPc / getCollidingActor (cppcheck) --- apps/openmw/mwscript/miscextensions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index bd91943ad..be8c85bbf 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -617,7 +617,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { MWWorld::Ptr ptr = R()(runtime); - runtime.push (MWBase::Environment::get().getWorld()->getPlayerStandingOn(ptr)); + runtime.push (MWBase::Environment::get().getWorld()->getPlayerCollidingWith(ptr)); } }; @@ -629,7 +629,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { MWWorld::Ptr ptr = R()(runtime); - runtime.push (MWBase::Environment::get().getWorld()->getActorStandingOn(ptr)); + runtime.push (MWBase::Environment::get().getWorld()->getActorCollidingWith(ptr)); } }; From 18be152ab1c5537fdb05d0d3952ed77a2c5d634d Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 26 Sep 2014 14:27:52 +0200 Subject: [PATCH 35/58] Allow dragging map even when a marker is hovered --- apps/openmw/mwgui/mapwindow.cpp | 19 +++++++++++++++++-- apps/openmw/mwgui/mapwindow.hpp | 8 ++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 2fba92372..67d8518ac 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -319,12 +319,11 @@ namespace MWGui markerWidget->setUserString("ToolTipType", "Layout"); markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); markerWidget->setUserString("Caption_TextOneLine", MyGUI::TextIterator::toTagsString(marker.mNote)); - markerWidget->setColour(MyGUI::Colour(1.0,0.3,0.3)); markerWidget->setNormalColour(MyGUI::Colour(1.0,0.3,0.3)); markerWidget->setHoverColour(MyGUI::Colour(1.0,0.5,0.5)); markerWidget->setUserData(marker); markerWidget->setNeedMouseFocus(true); - markerWidget->eventMouseButtonDoubleClick += MyGUI::newDelegate(this, &LocalMapBase::onCustomMarkerDoubleClicked); + customMarkerCreated(markerWidget); mCustomMarkerWidgets.push_back(markerWidget); } redraw(); @@ -411,6 +410,7 @@ namespace MWGui // Used by tooltips to not show the tooltip if marker is hidden by fog of war markerWidget->setUserString("IsMarker", "true"); markerWidget->setUserData(markerPos); + doorMarkerCreated(markerWidget); mDoorMarkerWidgets.push_back(markerWidget); } @@ -753,6 +753,8 @@ namespace MWGui markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); markerWidget->setUserString("Caption_TextOneLine", name); markerWidget->setDepth(Global_MarkerLayer); + markerWidget->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); + markerWidget->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); ++_counter; CellId cell; @@ -928,6 +930,19 @@ namespace MWGui (*it)->setVisible(alpha == 1); } + void MapWindow::customMarkerCreated(MyGUI::Widget *marker) + { + marker->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); + marker->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); + marker->eventMouseButtonDoubleClick += MyGUI::newDelegate(this, &MapWindow::onCustomMarkerDoubleClicked); + } + + void MapWindow::doorMarkerCreated(MyGUI::Widget *marker) + { + marker->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); + marker->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); + } + // ------------------------------------------------------------------- EditNoteDialog::EditNoteDialog() diff --git a/apps/openmw/mwgui/mapwindow.hpp b/apps/openmw/mwgui/mapwindow.hpp index 279f20786..9ea90061a 100644 --- a/apps/openmw/mwgui/mapwindow.hpp +++ b/apps/openmw/mwgui/mapwindow.hpp @@ -119,7 +119,8 @@ namespace MWGui virtual void notifyPlayerUpdate() {} virtual void notifyMapChanged() {} - virtual void onCustomMarkerDoubleClicked(MyGUI::Widget* sender) {} + virtual void customMarkerCreated(MyGUI::Widget* marker) {} + virtual void doorMarkerCreated(MyGUI::Widget* marker) {} void updateMagicMarkers(); void addDetectionMarkers(int type); @@ -199,6 +200,7 @@ namespace MWGui void onMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id); void onWorldButtonClicked(MyGUI::Widget* _sender); void onMapDoubleClicked(MyGUI::Widget* sender); + void onCustomMarkerDoubleClicked(MyGUI::Widget* sender); void onNoteEditOk(); void onNoteEditDelete(); void onNoteEditDeleteConfirm(); @@ -235,7 +237,9 @@ namespace MWGui virtual void onPinToggled(); virtual void onTitleDoubleClicked(); - virtual void onCustomMarkerDoubleClicked(MyGUI::Widget* sender); + + virtual void doorMarkerCreated(MyGUI::Widget* marker); + virtual void customMarkerCreated(MyGUI::Widget *marker); virtual void notifyPlayerUpdate(); From fc4f069d0fb9d6df942fb75e99ef98845bc0398a Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 26 Sep 2014 15:22:02 +0200 Subject: [PATCH 36/58] Remove old BSA tests --- components/bsa/tests/.gitignore | 3 -- components/bsa/tests/Makefile | 15 ------- components/bsa/tests/bsa_file_test.cpp | 44 ------------------- components/bsa/tests/ogre_archive_test.cpp | 34 -------------- components/bsa/tests/output/bsa_file_test.out | 17 ------- .../bsa/tests/output/ogre_archive_test.out | 2 - components/bsa/tests/test.sh | 18 -------- 7 files changed, 133 deletions(-) delete mode 100644 components/bsa/tests/.gitignore delete mode 100644 components/bsa/tests/Makefile delete mode 100644 components/bsa/tests/bsa_file_test.cpp delete mode 100644 components/bsa/tests/ogre_archive_test.cpp delete mode 100644 components/bsa/tests/output/bsa_file_test.out delete mode 100644 components/bsa/tests/output/ogre_archive_test.out delete mode 100755 components/bsa/tests/test.sh diff --git a/components/bsa/tests/.gitignore b/components/bsa/tests/.gitignore deleted file mode 100644 index e2f2f332d..000000000 --- a/components/bsa/tests/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*_test -bsatool -*.bsa diff --git a/components/bsa/tests/Makefile b/components/bsa/tests/Makefile deleted file mode 100644 index 73e20d7b3..000000000 --- a/components/bsa/tests/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -GCC=g++ - -all: bsa_file_test ogre_archive_test - -I_OGRE=$(shell pkg-config --cflags OGRE) -L_OGRE=$(shell pkg-config --libs OGRE) - -bsa_file_test: bsa_file_test.cpp ../bsa_file.cpp - $(GCC) $^ -o $@ - -ogre_archive_test: ogre_archive_test.cpp ../bsa_file.cpp ../bsa_archive.cpp - $(GCC) $^ -o $@ $(I_OGRE) $(L_OGRE) - -clean: - rm *_test diff --git a/components/bsa/tests/bsa_file_test.cpp b/components/bsa/tests/bsa_file_test.cpp deleted file mode 100644 index 07ee73d17..000000000 --- a/components/bsa/tests/bsa_file_test.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "../bsa_file.hpp" - -/* - Test of the BSAFile class - - This test requires that data/Morrowind.bsa exists in the root - directory of OpenMW. - - */ - -#include - -using namespace std; -using namespace Bsa; - -BSAFile bsa; - -void find(const char* file) -{ - cout << "Does file '" << file << "' exist?\n "; - if(bsa.exists(file)) - { - cout << "Yes.\n "; - cout << bsa.getFile(file)->size() << " bytes\n"; - } - else cout << "No.\n"; -} - -int main() -{ - cout << "Reading Morrowind.bsa\n"; - bsa.open("../../data/Morrowind.bsa"); - - const BSAFile::FileList &files = bsa.getList(); - - cout << "First 10 files in archive:\n"; - for(int i=0; i<10; i++) - cout << " " << files[i].name - << " (" << files[i].fileSize << " bytes @" - << files[i].offset << ")\n"; - - find("meshes\\r\\xnetch_betty.nif"); - find("humdrum"); -} diff --git a/components/bsa/tests/ogre_archive_test.cpp b/components/bsa/tests/ogre_archive_test.cpp deleted file mode 100644 index 9cd57240f..000000000 --- a/components/bsa/tests/ogre_archive_test.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include - -// This is a test of the BSA archive handler for OGRE. - -#include "../bsa_archive.hpp" - -using namespace Ogre; -using namespace std; - -int main() -{ - // Disable Ogre logging - new LogManager; - Log *log = LogManager::getSingleton().createLog(""); - log->setDebugOutputEnabled(false); - - // Set up Root - Root *root = new Root("","",""); - - // Add the BSA - Bsa::addBSA("../../data/Morrowind.bsa"); - - // Pick a sample file - String tex = "textures\\tx_natural_cavern_wall13.dds"; - cout << "Opening file: " << tex << endl; - - // Get it from the resource system - DataStreamPtr data = ResourceGroupManager::getSingleton().openResource(tex, "General"); - - cout << "Size: " << data->size() << endl; - - return 0; -} diff --git a/components/bsa/tests/output/bsa_file_test.out b/components/bsa/tests/output/bsa_file_test.out deleted file mode 100644 index 0d8e76cdd..000000000 --- a/components/bsa/tests/output/bsa_file_test.out +++ /dev/null @@ -1,17 +0,0 @@ -Reading Morrowind.bsa -First 10 files in archive: - meshes\m\probe_journeyman_01.nif (6276 bytes @126646052) - textures\menu_rightbuttonup_top.dds (256 bytes @218530052) - textures\menu_rightbuttonup_right.dds (256 bytes @218529796) - textures\menu_rightbuttonup_left.dds (256 bytes @218529540) - textures\menu_rightbuttondown_top.dds (256 bytes @218528196) - meshes\b\b_n_redguard_f_skins.nif (41766 bytes @17809778) - meshes\b\b_n_redguard_m_skins.nif (41950 bytes @18103107) - meshes\b\b_n_redguard_f_wrist.nif (2355 bytes @17858132) - meshes\b\b_n_redguard_m_foot.nif (4141 bytes @17862081) - meshes\b\b_n_redguard_m_knee.nif (2085 bytes @18098101) -Does file 'meshes\r\xnetch_betty.nif' exist? - Yes. - 53714 bytes -Does file 'humdrum' exist? - No. diff --git a/components/bsa/tests/output/ogre_archive_test.out b/components/bsa/tests/output/ogre_archive_test.out deleted file mode 100644 index 748e4b1e7..000000000 --- a/components/bsa/tests/output/ogre_archive_test.out +++ /dev/null @@ -1,2 +0,0 @@ -Opening file: textures\tx_natural_cavern_wall13.dds -Size: 43808 diff --git a/components/bsa/tests/test.sh b/components/bsa/tests/test.sh deleted file mode 100755 index 2d07708ad..000000000 --- a/components/bsa/tests/test.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -make || exit - -mkdir -p output - -PROGS=*_test - -for a in $PROGS; do - if [ -f "output/$a.out" ]; then - echo "Running $a:" - ./$a | diff output/$a.out - - else - echo "Creating $a.out" - ./$a > "output/$a.out" - git add "output/$a.out" - fi -done From 487e318ede4492d9e540c19ca7ca98cb78ec9215 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 26 Sep 2014 15:25:51 +0200 Subject: [PATCH 37/58] Remove old niftool test --- components/nif/tests/niftool.cpp | 232 ------------------------------- 1 file changed, 232 deletions(-) delete mode 100644 components/nif/tests/niftool.cpp diff --git a/components/nif/tests/niftool.cpp b/components/nif/tests/niftool.cpp deleted file mode 100644 index b34084e12..000000000 --- a/components/nif/tests/niftool.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/* - Test of the NIFFile class - */ - -#include "../nif_file.hpp" -#include -#include -#include "../../mangle/stream/servers/file_stream.hpp" -#include "../node.hpp" -#include "../controller.hpp" -#include "../data.hpp" - -using namespace Mangle::Stream; -using namespace std; -using namespace Nif; - -// Display very verbose information -bool verbose = false; - -void doVector(const Vector *vec) -{ - cout << "[" - << vec->array[0] << "," - << vec->array[1] << "," - << vec->array[2] << "]\n"; -} - -void doVector4(const Vector4 *vec) -{ - cout << "[" - << vec->array[0] << "," - << vec->array[1] << "," - << vec->array[2] << "," - << vec->array[3] << "]\n"; -} - -void doMatrix(const Matrix *mat) -{ - cout << "Matrix:\n"; - for(int i=0; i<3; i++) - { - cout << " "; - doVector(&mat->v[i]); - } -} - -void doTrafo(const Transformation* trafo) -{ - cout << "--- transformation:\n"; - cout << "Pos: "; doVector(&trafo->pos); - cout << "Rot: "; doMatrix(&trafo->rotation); - cout << "Scale: " << trafo->scale << endl; - cout << "Vel: "; doVector(&trafo->velocity); - cout << "--- end transformation\n"; -} - -void doExtra(Extra *e) -{ - cout << "Extra: " << e->extra.getIndex() << endl; -} - -void doControlled(Controlled *c) -{ - doExtra(c); - cout << "Controller: " << c->controller.getIndex() << endl; -} - -void doNamed(Named *n) -{ - doControlled(n); - cout << "Name: " << n->name.toString() << endl; -} - -void doNode(Node *n) -{ - doNamed(n); - - cout << "Flags: 0x" << hex << n->flags << dec << endl; - doTrafo(n->trafo); - - cout << "Properties:"; - for(int i=0; iprops.length(); i++) - cout << " " << n->props.getIndex(i); - cout << endl; - - if(n->hasBounds) - { - cout << "Bounding box:\n"; - doVector(n->boundPos); - doMatrix(n->boundRot); - doVector(n->boundXYZ); - } - - if(n->boneTrafo) - { - cout << "This is a bone: "; - if(n->boneIndex == -1) - cout << "root bone\n"; - else - cout << "index " << n->boneIndex << endl; - } -} - -void doNiTriShape(NiTriShape *n) -{ - doNode(n); - - cout << "Shape data: " << n->data.getIndex() << endl; - cout << "Skin instance: " << n->skin.getIndex() << endl; -} - -void doNiSkinData(NiSkinData *n) -{ - int c = n->bones.size(); - - cout << "Global transformation:\n"; - doMatrix(&n->trafo->rotation); - doVector(&n->trafo->trans); - cout << "Scale: " << n->trafo->scale << endl; - - cout << "Bone number: " << c << endl; - for(int i=0; ibones[i]; - - cout << "-- Bone " << i << ":\n"; - doMatrix(&bi.trafo->rotation); - doVector(&bi.trafo->trans); - cout << "Scale: " << bi.trafo->scale << endl; - cout << "Unknown: "; doVector4(bi.unknown); - cout << "Weight number: " << bi.weights.length << endl; - - if(verbose) - for(int j=0; jdata.getIndex() << endl; - cout << "Root: " << n->root.getIndex() << endl; - cout << "Bones:"; - for(int i=0; ibones.length(); i++) - cout << " " << n->bones.getIndex(i); - cout << endl; -} - -void doNiNode(NiNode *n) -{ - doNode(n); - - cout << "Children:"; - for(int i=0; ichildren.length(); i++) - cout << " " << n->children.getIndex(i); - cout << endl; - - cout << "Effects:"; - for(int i=0; ieffects.length(); i++) - cout << " " << n->effects.getIndex(i); - cout << endl; -} - -void doNiStringExtraData(NiStringExtraData *s) -{ - doExtra(s); - cout << "String: " << s->string.toString() << endl; -} - -void doNiTextKeyExtraData(NiTextKeyExtraData *t) -{ - doExtra(t); - for(int i=0; ilist.size(); i++) - { - cout << "@time " << t->list[i].time << ":\n\"" - << t->list[i].text.toString() << "\"" << endl; - } -} - -void doController(Controller *r) -{ - cout << "Next controller: " << r->next.getIndex() << endl; - cout << "Flags: " << hex << r->flags << dec << endl; - cout << "Frequency: " << r->frequency << endl; - cout << "Phase: " << r->phase << endl; - cout << "Time start: " << r->timeStart << endl; - cout << "Time stop: " << r->timeStop << endl; - cout << "Target: " << r->target.getIndex() << endl; -} - -void doNiKeyframeController(NiKeyframeController *k) -{ - doController(k); - cout << "Data: " << k->data.getIndex() << endl; -} - -int main(int argc, char **args) -{ - if(argc != 2) - { - cout << "Specify a NIF file on the command line\n"; - return 1; - } - - StreamPtr file(new FileStream(args[1])); - NIFFile nif(file, args[1]); - - int num = nif.numRecords(); - - for(int i=0; irecName.toString() << endl; - - switch(r->recType) - { - case RC_NiNode: doNiNode((NiNode*)r); break; - case RC_NiSkinData: doNiSkinData((NiSkinData*)r); break; - case RC_NiSkinInstance: doNiSkinInstance((NiSkinInstance*)r); break; - case RC_NiTriShape: doNiTriShape((NiTriShape*)r); break; - case RC_NiStringExtraData: doNiStringExtraData((NiStringExtraData*)r); break; - case RC_NiSequenceStreamHelper: doNamed((Named*)r); break; - case RC_NiTextKeyExtraData: doNiTextKeyExtraData((NiTextKeyExtraData*)r); break; - case RC_NiKeyframeController: doNiKeyframeController((NiKeyframeController*)r); break; - } - - cout << endl; - } -} From 6b82e3665be6846df3b21ee9b8aba2e0476bf9c8 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 26 Sep 2014 16:10:55 +0200 Subject: [PATCH 38/58] Remove old nifbullet test --- components/nifbullet/test/test.cpp | 209 ----------------------------- 1 file changed, 209 deletions(-) delete mode 100644 components/nifbullet/test/test.cpp diff --git a/components/nifbullet/test/test.cpp b/components/nifbullet/test/test.cpp deleted file mode 100644 index 261edf512..000000000 --- a/components/nifbullet/test/test.cpp +++ /dev/null @@ -1,209 +0,0 @@ -#include "bullet_nif_loader.hpp" -#include "..\nifogre\ogre_nif_loader.hpp" -#include "..\bsa\bsa_archive.hpp" -#include "..\nifogre\ogre_nif_loader.hpp" -#include -#include -#include -#include -#include "BtOgrePG.h" -#include "BtOgreGP.h" -#include "BtOgreExtras.h" - -const char* mesh = "meshes\\x\\ex_hlaalu_b_24.nif"; - -class MyMotionState : public btMotionState { -public: - MyMotionState(const btTransform &initialpos, Ogre::SceneNode *node) { - mVisibleobj = node; - mPos1 = initialpos; - node->setPosition(initialpos.getOrigin().x(),initialpos.getOrigin().y(),initialpos.getOrigin().z()); - } - - virtual ~MyMotionState() { - } - - void setNode(Ogre::SceneNode *node) { - mVisibleobj = node; - } - - virtual void getWorldTransform(btTransform &worldTrans) const { - worldTrans = mPos1; - } - - virtual void setWorldTransform(const btTransform &worldTrans) { - if(NULL == mVisibleobj) return; // silently return before we set a node - btQuaternion rot = worldTrans.getRotation(); - mVisibleobj->setOrientation(rot.w(), rot.x(), rot.y(), rot.z()); - btVector3 pos = worldTrans.getOrigin(); - mVisibleobj->setPosition(pos.x(), pos.y(), pos.z()); - } - -protected: - Ogre::SceneNode *mVisibleobj; - btTransform mPos1; -}; - - -int main() -{ - try - { - //Ogre stuff - - Ogre::Root* pRoot = new Ogre::Root(); - pRoot->showConfigDialog(); - - BulletShapeManager* manag = new BulletShapeManager(); - - Ogre::RenderWindow* win = pRoot->initialise(true,"test"); - Ogre::SceneManager* scmg = pRoot->createSceneManager(Ogre::ST_GENERIC,"MonGestionnaireDeScene"); - Ogre::Camera* pCamera = scmg->createCamera("test"); - Ogre::Viewport* pViewport = win->addViewport(pCamera); - pCamera->setPosition(-50,0,0); - pCamera->setFarClipDistance(10000); - pCamera->setNearClipDistance(1.); - pCamera->lookAt(0,0,0); - //Ogre::ResourceGroupManager::getSingleton().addResourceLocation("C++/OgreSK/media/models","FileSystem","General"); - Ogre::ResourceGroupManager::getSingleton().addResourceLocation("","FileSystem","General"); - /*Ogre::ResourceGroupManager::getSingleton().addResourceLocation("C++/OgreSK/media/materials/scripts","FileSystem","General"); - Ogre::ResourceGroupManager::getSingleton().addResourceLocation("C++/OgreSK/media/materials/textures","FileSystem","General"); - Ogre::ResourceGroupManager::getSingleton().addResourceLocation("C++/OgreSK/media/materials/programs","FileSystem","General");*/ - - - //OIS stuff - OIS::ParamList pl; - size_t windowHnd = 0; - std::ostringstream windowHndStr; - win->getCustomAttribute("WINDOW", &windowHnd); - windowHndStr << windowHnd; - pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); - OIS::InputManager *pInputManager = OIS::InputManager::createInputSystem( pl ); - OIS::Mouse *pMouse = static_cast(pInputManager->createInputObject(OIS::OISMouse, false)); - OIS::Keyboard* pKeyboard = static_cast(pInputManager->createInputObject(OIS::OISKeyboard, false)); - unsigned int width, height, depth; - int top, left; - win->getMetrics(width, height, depth, left, top); - const OIS::MouseState &ms = pMouse->getMouseState(); - ms.width = width; - ms.height = height; - - - //Ressources stuff - Bsa::addBSA("Morrowind.bsa"); - //Ogre::ResourceGroupManager::getSingleton().createResourceGroup("general"); - - Ogre::ResourcePtr ptr = BulletShapeManager::getSingleton().getByName(mesh,"General"); - NifBullet::ManualBulletShapeLoader* ShapeLoader = new NifBullet::ManualBulletShapeLoader(); - - ShapeLoader->load(mesh,"General"); - //BulletShapeManager::getSingleton().unload(mesh); - //ShapeLoader->load(mesh,"General"); - - NIFLoader::load(mesh); - - Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); - //BulletShapeManager::getSingleton(). - BulletShapePtr shape = BulletShapeManager::getSingleton().getByName(mesh,"General"); - BulletShapeManager::getSingleton().load(mesh,"General"); - BulletShapeManager::getSingleton().unload(mesh); - BulletShapeManager::getSingleton().load(mesh,"General"); - BulletShapeManager::getSingleton().load(mesh,"General"); - //shape->load(); - //shape->unload(); - //shape->load(); - - //Bullet init - btBroadphaseInterface* broadphase = new btDbvtBroadphase(); - - // Set up the collision configuration and dispatcher - btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration(); - btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration); - - // The actual physics solver - btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver; - - // The world. - btDiscreteDynamicsWorld* dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration); - dynamicsWorld->setGravity(btVector3(0,-10,0)); - - - - //le sol? - Ogre::SceneNode *node = scmg->getRootSceneNode()->createChildSceneNode("node"); - Ogre::Entity *ent = scmg->createEntity("Mesh1",mesh); - node->attachObject(ent); - MyMotionState* mst = new MyMotionState(btTransform::getIdentity(),node); - - btRigidBody::btRigidBodyConstructionInfo groundRigidBodyCI(0,mst,shape->Shape,btVector3(0,0,0)); - btRigidBody* groundRigidBody = new btRigidBody(groundRigidBodyCI); - dynamicsWorld->addRigidBody(groundRigidBody); - - //une balle: - Ogre::SceneNode *node2 = scmg->getRootSceneNode()->createChildSceneNode("node2"); - Ogre::Entity *ent2 = scmg->createEntity("Mesh2","ogrehead.mesh"); - node2->attachObject(ent2); - node2->setPosition(0,500,0); - btTransform iT; - iT.setIdentity(); - iT.setOrigin(btVector3(0,5000,0)); - MyMotionState* mst2 = new MyMotionState(btTransform::getIdentity(),node2); - - btSphereShape* sphereshape = new btSphereShape(10); - btRigidBody::btRigidBodyConstructionInfo sphereCI(10,mst2,sphereshape,btVector3(0,0,0)); - btRigidBody* sphere = new btRigidBody(sphereCI); - dynamicsWorld->addRigidBody(sphere); - - - //btOgre! - BtOgre::DebugDrawer* mDebugDrawer = new BtOgre::DebugDrawer(scmg->getRootSceneNode(), dynamicsWorld); - dynamicsWorld->setDebugDrawer(mDebugDrawer); - - Ogre::Timer timer; - timer.reset(); - bool cont = true; - while(cont) - { - if(timer.getMilliseconds()>30) - { - pMouse->capture(); - pKeyboard->capture(); - - Ogre::Vector3 a(0,0,0); - - if(pKeyboard->isKeyDown(OIS::KC_UP)) - { - a = a + Ogre::Vector3(0,0,-20); - } - if(pKeyboard->isKeyDown(OIS::KC_DOWN)) - { - a = a + Ogre::Vector3(0,0,20); - } - if(pKeyboard->isKeyDown(OIS::KC_ESCAPE)) - { - cont = false; - } - OIS::MouseState MS = pMouse->getMouseState(); - pCamera->yaw(-Ogre::Degree(MS.X.rel)); - pCamera->pitch(-Ogre::Degree(MS.Y.rel)); - pCamera->moveRelative(a); - - pRoot->renderOneFrame(); - mDebugDrawer->step(); - timer.reset(); - dynamicsWorld->stepSimulation(0.03); - } - } - std::cout << "cool"; - delete manag; - delete pRoot; - char a; - std::cin >> a; - } - catch(Ogre::Exception& e) - { - std::cout << e.getFullDescription(); - char a; - std::cin >> a; - } -} From 790e0150b1bb388f44c443034244cea039129114 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 26 Sep 2014 16:51:48 +0200 Subject: [PATCH 39/58] Fix global map markers being duplicated when cell is visited again --- apps/openmw/mwgui/mapwindow.cpp | 49 ++++++++++++++++----------------- apps/openmw/mwgui/mapwindow.hpp | 2 +- components/esm/globalmap.cpp | 4 +-- components/esm/globalmap.hpp | 3 +- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 67d8518ac..37bc4d1e3 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -734,33 +734,32 @@ namespace MWGui void MapWindow::addVisitedLocation(const std::string& name, int x, int y) { - float worldX, worldY; - mGlobalMapRender->cellTopLeftCornerToImageSpace (x, y, worldX, worldY); - - int markerSize = 12; - int offset = mGlobalMapRender->getCellSize()/2 - markerSize/2; - MyGUI::IntCoord widgetCoord( - worldX * mGlobalMapRender->getWidth()+offset, - worldY * mGlobalMapRender->getHeight()+offset, - markerSize, markerSize); - - static int _counter=0; - MyGUI::Widget* markerWidget = mGlobalMap->createWidget("MarkerButton", - widgetCoord, MyGUI::Align::Default); - markerWidget->setNeedMouseFocus(true); - markerWidget->setColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal}"))); - markerWidget->setUserString("ToolTipType", "Layout"); - markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); - markerWidget->setUserString("Caption_TextOneLine", name); - markerWidget->setDepth(Global_MarkerLayer); - markerWidget->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); - markerWidget->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); - ++_counter; - CellId cell; cell.first = x; cell.second = y; - mMarkers.push_back(cell); + if (mMarkers.insert(cell).second) + { + float worldX, worldY; + mGlobalMapRender->cellTopLeftCornerToImageSpace (x, y, worldX, worldY); + + int markerSize = 12; + int offset = mGlobalMapRender->getCellSize()/2 - markerSize/2; + MyGUI::IntCoord widgetCoord( + worldX * mGlobalMapRender->getWidth()+offset, + worldY * mGlobalMapRender->getHeight()+offset, + markerSize, markerSize); + + MyGUI::Widget* markerWidget = mGlobalMap->createWidget("MarkerButton", + widgetCoord, MyGUI::Align::Default); + markerWidget->setNeedMouseFocus(true); + markerWidget->setColour(MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=normal}"))); + markerWidget->setUserString("ToolTipType", "Layout"); + markerWidget->setUserString("ToolTipLayout", "TextToolTipOneLine"); + markerWidget->setUserString("Caption_TextOneLine", name); + markerWidget->setDepth(Global_MarkerLayer); + markerWidget->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); + markerWidget->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart); + } } void MapWindow::cellExplored(int x, int y) @@ -912,7 +911,7 @@ namespace MWGui mGlobalMapRender->read(map); - for (std::vector::iterator it = map.mMarkers.begin(); it != map.mMarkers.end(); ++it) + for (std::set::iterator it = map.mMarkers.begin(); it != map.mMarkers.end(); ++it) { const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getStore().get().search(it->first, it->second); if (cell && !cell->mName.empty()) diff --git a/apps/openmw/mwgui/mapwindow.hpp b/apps/openmw/mwgui/mapwindow.hpp index 9ea90061a..e9c0c1a69 100644 --- a/apps/openmw/mwgui/mapwindow.hpp +++ b/apps/openmw/mwgui/mapwindow.hpp @@ -221,7 +221,7 @@ namespace MWGui // Markers on global map typedef std::pair CellId; - std::vector mMarkers; + std::set mMarkers; // Cells that should be explored in the next frame (i.e. their map revealed on the global map) // We can't do this immediately, because the map update is not immediate either (see mNeedMapUpdate in scene.cpp) diff --git a/components/esm/globalmap.cpp b/components/esm/globalmap.cpp index f17c071ff..190329c61 100644 --- a/components/esm/globalmap.cpp +++ b/components/esm/globalmap.cpp @@ -21,7 +21,7 @@ void ESM::GlobalMap::load (ESMReader &esm) CellId cell; esm.getT(cell.first); esm.getT(cell.second); - mMarkers.push_back(cell); + mMarkers.insert(cell); } } @@ -33,7 +33,7 @@ void ESM::GlobalMap::save (ESMWriter &esm) const esm.write(&mImageData[0], mImageData.size()); esm.endRecord("DATA"); - for (std::vector::const_iterator it = mMarkers.begin(); it != mMarkers.end(); ++it) + for (std::set::const_iterator it = mMarkers.begin(); it != mMarkers.end(); ++it) { esm.startSubRecord("MRK_"); esm.writeT(it->first); diff --git a/components/esm/globalmap.hpp b/components/esm/globalmap.hpp index 158f70a6e..e89123f89 100644 --- a/components/esm/globalmap.hpp +++ b/components/esm/globalmap.hpp @@ -2,6 +2,7 @@ #define OPENMW_COMPONENTS_ESM_GLOBALMAP_H #include +#include namespace ESM { @@ -26,7 +27,7 @@ namespace ESM std::vector mImageData; typedef std::pair CellId; - std::vector mMarkers; + std::set mMarkers; void load (ESMReader &esm); void save (ESMWriter &esm) const; From 7252cb63a6b129811d4594ee97e29c1b7fb5cedf Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 26 Sep 2014 17:12:48 +0200 Subject: [PATCH 40/58] Fix cppcheck issues --- apps/esmtool/labels.cpp | 890 +++++++++--------- apps/esmtool/record.cpp | 38 +- apps/mwiniimporter/importer.cpp | 7 +- apps/mwiniimporter/main.cpp | 2 + apps/opencs/model/doc/savingstages.hpp | 5 - apps/opencs/view/render/navigation.cpp | 7 +- apps/opencs/view/render/navigation.hpp | 1 + apps/opencs/view/render/scenewidget.cpp | 5 - apps/opencs/view/render/scenewidget.hpp | 2 - .../opencs/view/world/datadisplaydelegate.cpp | 2 +- .../opencs/view/world/datadisplaydelegate.hpp | 2 +- apps/openmw/crashcatcher.cpp | 2 +- apps/openmw/main.cpp | 3 +- apps/openmw/mwbase/windowmanager.hpp | 1 - apps/openmw/mwclass/npc.cpp | 7 - apps/openmw/mwclass/npc.hpp | 2 - apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 6 +- apps/openmw/mwgui/class.cpp | 8 - apps/openmw/mwgui/class.hpp | 2 - apps/openmw/mwgui/console.cpp | 5 - apps/openmw/mwgui/console.hpp | 2 - apps/openmw/mwgui/dialogue.cpp | 4 +- apps/openmw/mwgui/formatting.cpp | 3 +- apps/openmw/mwgui/itemmodel.cpp | 3 +- apps/openmw/mwgui/journalviewmodel.cpp | 18 +- apps/openmw/mwgui/journalviewmodel.hpp | 3 - apps/openmw/mwgui/journalwindow.cpp | 12 - apps/openmw/mwgui/levelupdialog.cpp | 2 +- apps/openmw/mwgui/messagebox.cpp | 8 +- apps/openmw/mwgui/messagebox.hpp | 1 - apps/openmw/mwgui/race.cpp | 3 +- apps/openmw/mwgui/settingswindow.cpp | 3 +- apps/openmw/mwgui/spellcreationdialog.cpp | 3 +- apps/openmw/mwgui/spellcreationdialog.hpp | 2 - apps/openmw/mwgui/widgets.cpp | 19 +- apps/openmw/mwgui/widgets.hpp | 3 - apps/openmw/mwgui/windowmanagerimp.cpp | 10 +- apps/openmw/mwgui/windowmanagerimp.hpp | 1 - apps/openmw/mwmechanics/actors.cpp | 10 +- apps/openmw/mwmechanics/aiactivate.hpp | 2 - apps/openmw/mwmechanics/aiavoiddoor.cpp | 2 +- apps/openmw/mwmechanics/aicombataction.cpp | 22 +- apps/openmw/mwmechanics/aiescort.cpp | 1 + apps/openmw/mwmechanics/aipackage.hpp | 1 - apps/openmw/mwmechanics/aipursue.hpp | 2 - apps/openmw/mwmechanics/aisequence.cpp | 37 +- apps/openmw/mwmechanics/aisequence.hpp | 4 - apps/openmw/mwmechanics/aiwander.cpp | 11 +- apps/openmw/mwmechanics/alchemy.cpp | 5 + apps/openmw/mwmechanics/alchemy.hpp | 2 + apps/openmw/mwmechanics/combat.cpp | 4 +- apps/openmw/mwmechanics/creaturestats.cpp | 11 - apps/openmw/mwmechanics/creaturestats.hpp | 5 - apps/openmw/mwmechanics/enchanting.cpp | 13 +- apps/openmw/mwmechanics/pathfinding.cpp | 7 - apps/openmw/mwmechanics/pathfinding.hpp | 2 - apps/openmw/mwrender/animation.cpp | 5 +- apps/openmw/mwrender/camera.cpp | 8 - apps/openmw/mwrender/camera.hpp | 3 - apps/openmw/mwrender/characterpreview.cpp | 2 +- apps/openmw/mwrender/creatureanimation.cpp | 2 +- apps/openmw/mwrender/globalmap.cpp | 4 +- apps/openmw/mwrender/npcanimation.cpp | 15 +- apps/openmw/mwrender/renderingmanager.cpp | 23 - apps/openmw/mwrender/renderingmanager.hpp | 3 - apps/openmw/mwrender/ripplesimulation.hpp | 3 + apps/openmw/mwrender/shadows.cpp | 10 - apps/openmw/mwrender/shadows.hpp | 2 - apps/openmw/mwrender/sky.cpp | 17 +- apps/openmw/mwrender/sky.hpp | 3 - apps/openmw/mwrender/videoplayer.cpp | 8 +- apps/openmw/mwrender/videoplayer.hpp | 4 - apps/openmw/mwscript/interpretercontext.cpp | 6 - apps/openmw/mwscript/interpretercontext.hpp | 3 - apps/openmw/mwscript/scriptmanagerimp.cpp | 3 +- apps/openmw/mwsound/ffmpeg_decoder.cpp | 3 +- apps/openmw/mwworld/class.cpp | 4 - apps/openmw/mwworld/class.hpp | 2 - apps/openmw/mwworld/inventorystore.cpp | 16 +- apps/openmw/mwworld/scene.cpp | 7 +- apps/openmw/mwworld/worldimp.cpp | 2 +- components/compiler/generator.cpp | 15 - components/compiler/generator.hpp | 2 - components/compiler/lineparser.cpp | 6 +- components/compiler/parser.cpp | 7 - components/compiler/parser.hpp | 3 - .../contentselector/model/contentmodel.cpp | 1 - components/esm/esmreader.cpp | 8 - components/esm/esmreader.hpp | 3 - components/esm/esmwriter.cpp | 7 +- components/esm/loadcell.cpp | 5 - components/esm/loadcell.hpp | 1 - components/esm/loadland.cpp | 4 +- components/nif/niffile.cpp | 2 +- components/nifogre/material.hpp | 6 - components/nifogre/ogrenifloader.cpp | 2 +- components/nifogre/particles.cpp | 2 +- components/ogreinit/ogreinit.cpp | 2 +- components/terrain/defaultworld.hpp | 4 +- components/terrain/world.cpp | 2 + components/translation/translation.cpp | 5 + components/translation/translation.hpp | 1 + components/widgets/list.cpp | 5 - components/widgets/list.hpp | 1 - extern/oics/CMakeLists.txt | 1 + extern/oics/ICSChannel.cpp | 31 +- extern/oics/ICSControl.cpp | 8 +- extern/oics/ICSInputControlSystem.cpp | 14 +- .../oics/ICSInputControlSystem_joystick.cpp | 4 +- .../oics/ICSInputControlSystem_keyboard.cpp | 2 +- extern/oics/ICSInputControlSystem_mouse.cpp | 4 +- extern/oics/ICSPrerequisites.h | 4 +- libs/openengine/bullet/physic.cpp | 4 - libs/openengine/bullet/physic.hpp | 12 +- libs/openengine/gui/manager.cpp | 14 - libs/openengine/gui/manager.hpp | 2 - libs/openengine/ogre/renderer.cpp | 5 - libs/openengine/ogre/renderer.hpp | 2 - plugins/mygui_resource_plugin/plugin.cpp | 3 +- 119 files changed, 655 insertions(+), 945 deletions(-) diff --git a/apps/esmtool/labels.cpp b/apps/esmtool/labels.cpp index 74b2c5fd2..9543628f5 100644 --- a/apps/esmtool/labels.cpp +++ b/apps/esmtool/labels.cpp @@ -18,137 +18,143 @@ std::string bodyPartLabel(int idx) { - const char *bodyPartLabels[] = { - "Head", - "Hair", - "Neck", - "Cuirass", - "Groin", - "Skirt", - "Right Hand", - "Left Hand", - "Right Wrist", - "Left Wrist", - "Shield", - "Right Forearm", - "Left Forearm", - "Right Upperarm", - "Left Upperarm", - "Right Foot", - "Left Foot", - "Right Ankle", - "Left Ankle", - "Right Knee", - "Left Knee", - "Right Leg", - "Left Leg", - "Right Shoulder", - "Left Shoulder", - "Weapon", - "Tail" - }; - if (idx >= 0 && idx <= 26) + { + const char *bodyPartLabels[] = { + "Head", + "Hair", + "Neck", + "Cuirass", + "Groin", + "Skirt", + "Right Hand", + "Left Hand", + "Right Wrist", + "Left Wrist", + "Shield", + "Right Forearm", + "Left Forearm", + "Right Upperarm", + "Left Upperarm", + "Right Foot", + "Left Foot", + "Right Ankle", + "Left Ankle", + "Right Knee", + "Left Knee", + "Right Leg", + "Left Leg", + "Right Shoulder", + "Left Shoulder", + "Weapon", + "Tail" + }; return bodyPartLabels[idx]; + } else return "Invalid"; } std::string meshPartLabel(int idx) { - const char *meshPartLabels[] = { - "Head", - "Hair", - "Neck", - "Chest", - "Groin", - "Hand", - "Wrist", - "Forearm", - "Upperarm", - "Foot", - "Ankle", - "Knee", - "Upper Leg", - "Clavicle", - "Tail" - }; - if (idx >= 0 && idx <= ESM::BodyPart::MP_Tail) + { + const char *meshPartLabels[] = { + "Head", + "Hair", + "Neck", + "Chest", + "Groin", + "Hand", + "Wrist", + "Forearm", + "Upperarm", + "Foot", + "Ankle", + "Knee", + "Upper Leg", + "Clavicle", + "Tail" + }; return meshPartLabels[idx]; + } else return "Invalid"; } std::string meshTypeLabel(int idx) { - const char *meshTypeLabels[] = { - "Skin", - "Clothing", - "Armor" - }; - if (idx >= 0 && idx <= ESM::BodyPart::MT_Armor) + { + const char *meshTypeLabels[] = { + "Skin", + "Clothing", + "Armor" + }; return meshTypeLabels[idx]; + } else return "Invalid"; } std::string clothingTypeLabel(int idx) { - const char *clothingTypeLabels[] = { - "Pants", - "Shoes", - "Shirt", - "Belt", - "Robe", - "Right Glove", - "Left Glove", - "Skirt", - "Ring", - "Amulet" - }; - if (idx >= 0 && idx <= 9) + { + const char *clothingTypeLabels[] = { + "Pants", + "Shoes", + "Shirt", + "Belt", + "Robe", + "Right Glove", + "Left Glove", + "Skirt", + "Ring", + "Amulet" + }; return clothingTypeLabels[idx]; + } else return "Invalid"; } std::string armorTypeLabel(int idx) -{ - const char *armorTypeLabels[] = { - "Helmet", - "Cuirass", - "Left Pauldron", - "Right Pauldron", - "Greaves", - "Boots", - "Left Gauntlet", - "Right Gauntlet", - "Shield", - "Left Bracer", - "Right Bracer" - }; - +{ if (idx >= 0 && idx <= 10) + { + const char *armorTypeLabels[] = { + "Helmet", + "Cuirass", + "Left Pauldron", + "Right Pauldron", + "Greaves", + "Boots", + "Left Gauntlet", + "Right Gauntlet", + "Shield", + "Left Bracer", + "Right Bracer" + }; return armorTypeLabels[idx]; + } else return "Invalid"; } std::string dialogTypeLabel(int idx) { - const char *dialogTypeLabels[] = { - "Topic", - "Voice", - "Greeting", - "Persuasion", - "Journal" - }; - if (idx >= 0 && idx <= 4) + { + const char *dialogTypeLabels[] = { + "Topic", + "Voice", + "Greeting", + "Persuasion", + "Journal" + }; return dialogTypeLabels[idx]; + } else if (idx == -1) return "Deleted"; else @@ -157,75 +163,79 @@ std::string dialogTypeLabel(int idx) std::string questStatusLabel(int idx) { - const char *questStatusLabels[] = { - "None", - "Name", - "Finished", - "Restart", - "Deleted" - }; - if (idx >= 0 && idx <= 4) + { + const char *questStatusLabels[] = { + "None", + "Name", + "Finished", + "Restart", + "Deleted" + }; return questStatusLabels[idx]; + } else return "Invalid"; } std::string creatureTypeLabel(int idx) { - const char *creatureTypeLabels[] = { - "Creature", - "Daedra", - "Undead", - "Humanoid", - }; - if (idx >= 0 && idx <= 3) + { + const char *creatureTypeLabels[] = { + "Creature", + "Daedra", + "Undead", + "Humanoid", + }; return creatureTypeLabels[idx]; + } else return "Invalid"; } std::string soundTypeLabel(int idx) { - const char *soundTypeLabels[] = { - "Left Foot", - "Right Foot", - "Swim Left", - "Swim Right", - "Moan", - "Roar", - "Scream", - "Land" - }; - if (idx >= 0 && idx <= 7) + { + const char *soundTypeLabels[] = { + "Left Foot", + "Right Foot", + "Swim Left", + "Swim Right", + "Moan", + "Roar", + "Scream", + "Land" + }; return soundTypeLabels[idx]; + } else return "Invalid"; } std::string weaponTypeLabel(int idx) { - const char *weaponTypeLabels[] = { - "Short Blade One Hand", - "Long Blade One Hand", - "Long Blade Two Hand", - "Blunt One Hand", - "Blunt Two Close", - "Blunt Two Wide", - "Spear Two Wide", - "Axe One Hand", - "Axe Two Hand", - "Marksman Bow", - "Marksman Crossbow", - "Marksman Thrown", - "Arrow", - "Bolt" - }; - if (idx >= 0 && idx <= 13) + { + const char *weaponTypeLabels[] = { + "Short Blade One Hand", + "Long Blade One Hand", + "Long Blade Two Hand", + "Blunt One Hand", + "Blunt Two Close", + "Blunt Two Wide", + "Spear Two Wide", + "Axe One Hand", + "Axe Two Hand", + "Marksman Bow", + "Marksman Crossbow", + "Marksman Thrown", + "Arrow", + "Bolt" + }; return weaponTypeLabels[idx]; + } else return "Invalid"; } @@ -242,377 +252,397 @@ std::string aiTypeLabel(int type) std::string magicEffectLabel(int idx) { - const char* magicEffectLabels [] = { - "Water Breathing", - "Swift Swim", - "Water Walking", - "Shield", - "Fire Shield", - "Lightning Shield", - "Frost Shield", - "Burden", - "Feather", - "Jump", - "Levitate", - "SlowFall", - "Lock", - "Open", - "Fire Damage", - "Shock Damage", - "Frost Damage", - "Drain Attribute", - "Drain Health", - "Drain Magicka", - "Drain Fatigue", - "Drain Skill", - "Damage Attribute", - "Damage Health", - "Damage Magicka", - "Damage Fatigue", - "Damage Skill", - "Poison", - "Weakness to Fire", - "Weakness to Frost", - "Weakness to Shock", - "Weakness to Magicka", - "Weakness to Common Disease", - "Weakness to Blight Disease", - "Weakness to Corprus Disease", - "Weakness to Poison", - "Weakness to Normal Weapons", - "Disintegrate Weapon", - "Disintegrate Armor", - "Invisibility", - "Chameleon", - "Light", - "Sanctuary", - "Night Eye", - "Charm", - "Paralyze", - "Silence", - "Blind", - "Sound", - "Calm Humanoid", - "Calm Creature", - "Frenzy Humanoid", - "Frenzy Creature", - "Demoralize Humanoid", - "Demoralize Creature", - "Rally Humanoid", - "Rally Creature", - "Dispel", - "Soultrap", - "Telekinesis", - "Mark", - "Recall", - "Divine Intervention", - "Almsivi Intervention", - "Detect Animal", - "Detect Enchantment", - "Detect Key", - "Spell Absorption", - "Reflect", - "Cure Common Disease", - "Cure Blight Disease", - "Cure Corprus Disease", - "Cure Poison", - "Cure Paralyzation", - "Restore Attribute", - "Restore Health", - "Restore Magicka", - "Restore Fatigue", - "Restore Skill", - "Fortify Attribute", - "Fortify Health", - "Fortify Magicka", - "Fortify Fatigue", - "Fortify Skill", - "Fortify Maximum Magicka", - "Absorb Attribute", - "Absorb Health", - "Absorb Magicka", - "Absorb Fatigue", - "Absorb Skill", - "Resist Fire", - "Resist Frost", - "Resist Shock", - "Resist Magicka", - "Resist Common Disease", - "Resist Blight Disease", - "Resist Corprus Disease", - "Resist Poison", - "Resist Normal Weapons", - "Resist Paralysis", - "Remove Curse", - "Turn Undead", - "Summon Scamp", - "Summon Clannfear", - "Summon Daedroth", - "Summon Dremora", - "Summon Ancestral Ghost", - "Summon Skeletal Minion", - "Summon Bonewalker", - "Summon Greater Bonewalker", - "Summon Bonelord", - "Summon Winged Twilight", - "Summon Hunger", - "Summon Golden Saint", - "Summon Flame Atronach", - "Summon Frost Atronach", - "Summon Storm Atronach", - "Fortify Attack", - "Command Creature", - "Command Humanoid", - "Bound Dagger", - "Bound Longsword", - "Bound Mace", - "Bound Battle Axe", - "Bound Spear", - "Bound Longbow", - "EXTRA SPELL", - "Bound Cuirass", - "Bound Helm", - "Bound Boots", - "Bound Shield", - "Bound Gloves", - "Corprus", - "Vampirism", - "Summon Centurion Sphere", - "Sun Damage", - "Stunted Magicka", - "Summon Fabricant", - "sEffectSummonCreature01", - "sEffectSummonCreature02", - "sEffectSummonCreature03", - "sEffectSummonCreature04", - "sEffectSummonCreature05" - }; if (idx >= 0 && idx <= 142) + { + const char* magicEffectLabels [] = { + "Water Breathing", + "Swift Swim", + "Water Walking", + "Shield", + "Fire Shield", + "Lightning Shield", + "Frost Shield", + "Burden", + "Feather", + "Jump", + "Levitate", + "SlowFall", + "Lock", + "Open", + "Fire Damage", + "Shock Damage", + "Frost Damage", + "Drain Attribute", + "Drain Health", + "Drain Magicka", + "Drain Fatigue", + "Drain Skill", + "Damage Attribute", + "Damage Health", + "Damage Magicka", + "Damage Fatigue", + "Damage Skill", + "Poison", + "Weakness to Fire", + "Weakness to Frost", + "Weakness to Shock", + "Weakness to Magicka", + "Weakness to Common Disease", + "Weakness to Blight Disease", + "Weakness to Corprus Disease", + "Weakness to Poison", + "Weakness to Normal Weapons", + "Disintegrate Weapon", + "Disintegrate Armor", + "Invisibility", + "Chameleon", + "Light", + "Sanctuary", + "Night Eye", + "Charm", + "Paralyze", + "Silence", + "Blind", + "Sound", + "Calm Humanoid", + "Calm Creature", + "Frenzy Humanoid", + "Frenzy Creature", + "Demoralize Humanoid", + "Demoralize Creature", + "Rally Humanoid", + "Rally Creature", + "Dispel", + "Soultrap", + "Telekinesis", + "Mark", + "Recall", + "Divine Intervention", + "Almsivi Intervention", + "Detect Animal", + "Detect Enchantment", + "Detect Key", + "Spell Absorption", + "Reflect", + "Cure Common Disease", + "Cure Blight Disease", + "Cure Corprus Disease", + "Cure Poison", + "Cure Paralyzation", + "Restore Attribute", + "Restore Health", + "Restore Magicka", + "Restore Fatigue", + "Restore Skill", + "Fortify Attribute", + "Fortify Health", + "Fortify Magicka", + "Fortify Fatigue", + "Fortify Skill", + "Fortify Maximum Magicka", + "Absorb Attribute", + "Absorb Health", + "Absorb Magicka", + "Absorb Fatigue", + "Absorb Skill", + "Resist Fire", + "Resist Frost", + "Resist Shock", + "Resist Magicka", + "Resist Common Disease", + "Resist Blight Disease", + "Resist Corprus Disease", + "Resist Poison", + "Resist Normal Weapons", + "Resist Paralysis", + "Remove Curse", + "Turn Undead", + "Summon Scamp", + "Summon Clannfear", + "Summon Daedroth", + "Summon Dremora", + "Summon Ancestral Ghost", + "Summon Skeletal Minion", + "Summon Bonewalker", + "Summon Greater Bonewalker", + "Summon Bonelord", + "Summon Winged Twilight", + "Summon Hunger", + "Summon Golden Saint", + "Summon Flame Atronach", + "Summon Frost Atronach", + "Summon Storm Atronach", + "Fortify Attack", + "Command Creature", + "Command Humanoid", + "Bound Dagger", + "Bound Longsword", + "Bound Mace", + "Bound Battle Axe", + "Bound Spear", + "Bound Longbow", + "EXTRA SPELL", + "Bound Cuirass", + "Bound Helm", + "Bound Boots", + "Bound Shield", + "Bound Gloves", + "Corprus", + "Vampirism", + "Summon Centurion Sphere", + "Sun Damage", + "Stunted Magicka", + "Summon Fabricant", + "sEffectSummonCreature01", + "sEffectSummonCreature02", + "sEffectSummonCreature03", + "sEffectSummonCreature04", + "sEffectSummonCreature05" + }; return magicEffectLabels[idx]; + } else return "Invalid"; } std::string attributeLabel(int idx) { - const char* attributeLabels [] = { - "Strength", - "Intelligence", - "Willpower", - "Agility", - "Speed", - "Endurance", - "Personality", - "Luck" - }; if (idx >= 0 && idx <= 7) + { + const char* attributeLabels [] = { + "Strength", + "Intelligence", + "Willpower", + "Agility", + "Speed", + "Endurance", + "Personality", + "Luck" + }; return attributeLabels[idx]; + } else return "Invalid"; } std::string spellTypeLabel(int idx) { - const char* spellTypeLabels [] = { - "Spells", - "Abilities", - "Blight Disease", - "Disease", - "Curse", - "Powers" - }; if (idx >= 0 && idx <= 5) + { + const char* spellTypeLabels [] = { + "Spells", + "Abilities", + "Blight Disease", + "Disease", + "Curse", + "Powers" + }; return spellTypeLabels[idx]; + } else return "Invalid"; } std::string specializationLabel(int idx) { - const char* specializationLabels [] = { - "Combat", - "Magic", - "Stealth" - }; if (idx >= 0 && idx <= 2) + { + const char* specializationLabels [] = { + "Combat", + "Magic", + "Stealth" + }; return specializationLabels[idx]; + } else return "Invalid"; } std::string skillLabel(int idx) { - const char* skillLabels [] = { - "Block", - "Armorer", - "Medium Armor", - "Heavy Armor", - "Blunt Weapon", - "Long Blade", - "Axe", - "Spear", - "Athletics", - "Enchant", - "Destruction", - "Alteration", - "Illusion", - "Conjuration", - "Mysticism", - "Restoration", - "Alchemy", - "Unarmored", - "Security", - "Sneak", - "Acrobatics", - "Light Armor", - "Short Blade", - "Marksman", - "Mercantile", - "Speechcraft", - "Hand-to-hand" - }; if (idx >= 0 && idx <= 26) + { + const char* skillLabels [] = { + "Block", + "Armorer", + "Medium Armor", + "Heavy Armor", + "Blunt Weapon", + "Long Blade", + "Axe", + "Spear", + "Athletics", + "Enchant", + "Destruction", + "Alteration", + "Illusion", + "Conjuration", + "Mysticism", + "Restoration", + "Alchemy", + "Unarmored", + "Security", + "Sneak", + "Acrobatics", + "Light Armor", + "Short Blade", + "Marksman", + "Mercantile", + "Speechcraft", + "Hand-to-hand" + }; return skillLabels[idx]; + } else return "Invalid"; } std::string apparatusTypeLabel(int idx) { - const char* apparatusTypeLabels [] = { - "Mortar", - "Alembic", - "Calcinator", - "Retort", - }; if (idx >= 0 && idx <= 3) + { + const char* apparatusTypeLabels [] = { + "Mortar", + "Alembic", + "Calcinator", + "Retort", + }; return apparatusTypeLabels[idx]; + } else return "Invalid"; } std::string rangeTypeLabel(int idx) { - const char* rangeTypeLabels [] = { - "Self", - "Touch", - "Target" - }; if (idx >= 0 && idx <= 2) + { + const char* rangeTypeLabels [] = { + "Self", + "Touch", + "Target" + }; return rangeTypeLabels[idx]; + } else return "Invalid"; } std::string schoolLabel(int idx) { - const char* schoolLabels [] = { - "Alteration", - "Conjuration", - "Destruction", - "Illusion", - "Mysticism", - "Restoration" - }; if (idx >= 0 && idx <= 5) + { + const char* schoolLabels [] = { + "Alteration", + "Conjuration", + "Destruction", + "Illusion", + "Mysticism", + "Restoration" + }; return schoolLabels[idx]; + } else return "Invalid"; } std::string enchantTypeLabel(int idx) { - const char* enchantTypeLabels [] = { - "Cast Once", - "Cast When Strikes", - "Cast When Used", - "Constant Effect" - }; if (idx >= 0 && idx <= 3) + { + const char* enchantTypeLabels [] = { + "Cast Once", + "Cast When Strikes", + "Cast When Used", + "Constant Effect" + }; return enchantTypeLabels[idx]; + } else return "Invalid"; } std::string ruleFunction(int idx) { - std::string ruleFunctions[] = { - "Reaction Low", - "Reaction High", - "Rank Requirement", - "NPC? Reputation", - "Health Percent", - "Player Reputation", - "NPC Level", - "Player Health Percent", - "Player Magicka", - "Player Fatigue", - "Player Attribute Strength", - "Player Skill Block", - "Player Skill Armorer", - "Player Skill Medium Armor", - "Player Skill Heavy Armor", - "Player Skill Blunt Weapon", - "Player Skill Long Blade", - "Player Skill Axe", - "Player Skill Spear", - "Player Skill Athletics", - "Player Skill Enchant", - "Player Skill Destruction", - "Player Skill Alteration", - "Player Skill Illusion", - "Player Skill Conjuration", - "Player Skill Mysticism", - "Player SKill Restoration", - "Player Skill Alchemy", - "Player Skill Unarmored", - "Player Skill Security", - "Player Skill Sneak", - "Player Skill Acrobatics", - "Player Skill Light Armor", - "Player Skill Short Blade", - "Player Skill Marksman", - "Player Skill Mercantile", - "Player Skill Speechcraft", - "Player Skill Hand to Hand", - "Player Gender", - "Player Expelled from Faction", - "Player Diseased (Common)", - "Player Diseased (Blight)", - "Player Clothing Modifier", - "Player Crime Level", - "Player Same Sex", - "Player Same Race", - "Player Same Faction", - "Faction Rank Difference", - "Player Detected", - "Alarmed", - "Choice Selected", - "Player Attribute Intelligence", - "Player Attribute Willpower", - "Player Attribute Agility", - "Player Attribute Speed", - "Player Attribute Endurance", - "Player Attribute Personality", - "Player Attribute Luck", - "Player Diseased (Corprus)", - "Weather", - "Player is a Vampire", - "Player Level", - "Attacked", - "NPC Talked to Player", - "Player Health", - "Creature Target", - "Friend Hit", - "Fight", - "Hello", - "Alarm", - "Flee", - "Should Attack", - "Werewolf" - }; if (idx >= 0 && idx <= 72) + { + std::string ruleFunctions[] = { + "Reaction Low", + "Reaction High", + "Rank Requirement", + "NPC? Reputation", + "Health Percent", + "Player Reputation", + "NPC Level", + "Player Health Percent", + "Player Magicka", + "Player Fatigue", + "Player Attribute Strength", + "Player Skill Block", + "Player Skill Armorer", + "Player Skill Medium Armor", + "Player Skill Heavy Armor", + "Player Skill Blunt Weapon", + "Player Skill Long Blade", + "Player Skill Axe", + "Player Skill Spear", + "Player Skill Athletics", + "Player Skill Enchant", + "Player Skill Destruction", + "Player Skill Alteration", + "Player Skill Illusion", + "Player Skill Conjuration", + "Player Skill Mysticism", + "Player SKill Restoration", + "Player Skill Alchemy", + "Player Skill Unarmored", + "Player Skill Security", + "Player Skill Sneak", + "Player Skill Acrobatics", + "Player Skill Light Armor", + "Player Skill Short Blade", + "Player Skill Marksman", + "Player Skill Mercantile", + "Player Skill Speechcraft", + "Player Skill Hand to Hand", + "Player Gender", + "Player Expelled from Faction", + "Player Diseased (Common)", + "Player Diseased (Blight)", + "Player Clothing Modifier", + "Player Crime Level", + "Player Same Sex", + "Player Same Race", + "Player Same Faction", + "Faction Rank Difference", + "Player Detected", + "Alarmed", + "Choice Selected", + "Player Attribute Intelligence", + "Player Attribute Willpower", + "Player Attribute Agility", + "Player Attribute Speed", + "Player Attribute Endurance", + "Player Attribute Personality", + "Player Attribute Luck", + "Player Diseased (Corprus)", + "Weather", + "Player is a Vampire", + "Player Level", + "Attacked", + "NPC Talked to Player", + "Player Health", + "Creature Target", + "Friend Hit", + "Fight", + "Hello", + "Alarm", + "Flee", + "Should Attack", + "Werewolf" + }; return ruleFunctions[idx]; + } else return "Invalid"; } diff --git a/apps/esmtool/record.cpp b/apps/esmtool/record.cpp index 07c1ef431..3f2ebc2ba 100644 --- a/apps/esmtool/record.cpp +++ b/apps/esmtool/record.cpp @@ -412,7 +412,7 @@ void Record::print() std::cout << " Armor: " << mData.mData.mArmor << std::endl; std::cout << " Enchantment Points: " << mData.mData.mEnchant << std::endl; std::vector::iterator pit; - for (pit = mData.mParts.mParts.begin(); pit != mData.mParts.mParts.end(); pit++) + for (pit = mData.mParts.mParts.begin(); pit != mData.mParts.mParts.end(); ++pit) { std::cout << " Body Part: " << bodyPartLabel(pit->mPart) << " (" << (int)(pit->mPart) << ")" << std::endl; @@ -484,7 +484,7 @@ void Record::print() std::cout << " Texture: " << mData.mTexture << std::endl; std::cout << " Description: " << mData.mDescription << std::endl; std::vector::iterator pit; - for (pit = mData.mPowers.mList.begin(); pit != mData.mPowers.mList.end(); pit++) + for (pit = mData.mPowers.mList.begin(); pit != mData.mPowers.mList.end(); ++pit) std::cout << " Power: " << *pit << std::endl; } @@ -554,7 +554,7 @@ void Record::print() std::cout << " Value: " << mData.mData.mValue << std::endl; std::cout << " Enchantment Points: " << mData.mData.mEnchant << std::endl; std::vector::iterator pit; - for (pit = mData.mParts.mParts.begin(); pit != mData.mParts.mParts.end(); pit++) + for (pit = mData.mParts.mParts.begin(); pit != mData.mParts.mParts.end(); ++pit) { std::cout << " Body Part: " << bodyPartLabel(pit->mPart) << " (" << (int)(pit->mPart) << ")" << std::endl; @@ -574,7 +574,7 @@ void Record::print() std::cout << " Flags: " << containerFlags(mData.mFlags) << std::endl; std::cout << " Weight: " << mData.mWeight << std::endl; std::vector::iterator cit; - for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); cit++) + for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); ++cit) std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount << " Item: " << cit->mItem.toString() << std::endl; } @@ -619,12 +619,12 @@ void Record::print() std::cout << " Gold: " << mData.mData.mGold << std::endl; std::vector::iterator cit; - for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); cit++) + for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); ++cit) std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount << " Item: " << cit->mItem.toString() << std::endl; std::vector::iterator sit; - for (sit = mData.mSpells.mList.begin(); sit != mData.mSpells.mList.end(); sit++) + for (sit = mData.mSpells.mList.begin(); sit != mData.mSpells.mList.end(); ++sit) std::cout << " Spell: " << *sit << std::endl; std::cout << " Artifical Intelligence: " << mData.mHasAI << std::endl; @@ -639,7 +639,7 @@ void Record::print() std::cout << " AI Services:" << boost::format("0x%08X") % mData.mAiData.mServices << std::endl; std::vector::iterator pit; - for (pit = mData.mAiPackage.mList.begin(); pit != mData.mAiPackage.mList.end(); pit++) + for (pit = mData.mAiPackage.mList.begin(); pit != mData.mAiPackage.mList.end(); ++pit) printAIPackage(*pit); } @@ -706,7 +706,7 @@ void Record::print() << mData.mData.mRankData[i].mFactReaction << std::endl; } std::map::iterator rit; - for (rit = mData.mReactions.begin(); rit != mData.mReactions.end(); rit++) + for (rit = mData.mReactions.begin(); rit != mData.mReactions.end(); ++rit) std::cout << " Reaction: " << rit->second << " = " << rit->first << std::endl; } @@ -763,7 +763,7 @@ void Record::print() std::cout << " Unknown2: " << (int)mData.mData.mUnknown2 << std::endl; std::vector::iterator sit; - for (sit = mData.mSelects.begin(); sit != mData.mSelects.end(); sit++) + for (sit = mData.mSelects.begin(); sit != mData.mSelects.end(); ++sit) std::cout << " Select Rule: " << ruleString(*sit) << std::endl; if (mData.mResultScript != "") @@ -835,7 +835,7 @@ void Record::print() std::cout << " Flags: " << creatureListFlags(mData.mFlags) << std::endl; std::cout << " Number of items: " << mData.mList.size() << std::endl; std::vector::iterator iit; - for (iit = mData.mList.begin(); iit != mData.mList.end(); iit++) + for (iit = mData.mList.begin(); iit != mData.mList.end(); ++iit) std::cout << " Creature: Level: " << iit->mLevel << " Creature: " << iit->mId << std::endl; } @@ -847,7 +847,7 @@ void Record::print() std::cout << " Flags: " << itemListFlags(mData.mFlags) << std::endl; std::cout << " Number of items: " << mData.mList.size() << std::endl; std::vector::iterator iit; - for (iit = mData.mList.begin(); iit != mData.mList.end(); iit++) + for (iit = mData.mList.begin(); iit != mData.mList.end(); ++iit) std::cout << " Inventory: Level: " << iit->mLevel << " Item: " << iit->mId << std::endl; } @@ -1031,16 +1031,16 @@ void Record::print() } std::vector::iterator cit; - for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); cit++) + for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); ++cit) std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount << " Item: " << cit->mItem.toString() << std::endl; std::vector::iterator sit; - for (sit = mData.mSpells.mList.begin(); sit != mData.mSpells.mList.end(); sit++) + for (sit = mData.mSpells.mList.begin(); sit != mData.mSpells.mList.end(); ++sit) std::cout << " Spell: " << *sit << std::endl; std::vector::iterator dit; - for (dit = mData.mTransport.begin(); dit != mData.mTransport.end(); dit++) + for (dit = mData.mTransport.begin(); dit != mData.mTransport.end(); ++dit) { std::cout << " Destination Position: " << boost::format("%12.3f") % dit->mPos.pos[0] << "," @@ -1066,7 +1066,7 @@ void Record::print() std::cout << " AI Services:" << boost::format("0x%08X") % mData.mAiData.mServices << std::endl; std::vector::iterator pit; - for (pit = mData.mAiPackage.mList.begin(); pit != mData.mAiPackage.mList.end(); pit++) + for (pit = mData.mAiPackage.mList.begin(); pit != mData.mAiPackage.mList.end(); ++pit) printAIPackage(*pit); } @@ -1140,7 +1140,7 @@ void Record::print() << mData.mData.mBonus[i].mBonus << std::endl; std::vector::iterator sit; - for (sit = mData.mPowers.mList.begin(); sit != mData.mPowers.mList.end(); sit++) + for (sit = mData.mPowers.mList.begin(); sit != mData.mPowers.mList.end(); ++sit) std::cout << " Power: " << *sit << std::endl; } @@ -1164,7 +1164,7 @@ void Record::print() if (mData.mSleepList != "") std::cout << " Sleep List: " << mData.mSleepList << std::endl; std::vector::iterator sit; - for (sit = mData.mSoundList.begin(); sit != mData.mSoundList.end(); sit++) + for (sit = mData.mSoundList.begin(); sit != mData.mSoundList.end(); ++sit) std::cout << " Sound: " << (int)sit->mChance << " = " << sit->mSound.toString() << std::endl; } @@ -1181,12 +1181,12 @@ void Record::print() std::vector::iterator vit; - for (vit = mData.mVarNames.begin(); vit != mData.mVarNames.end(); vit++) + for (vit = mData.mVarNames.begin(); vit != mData.mVarNames.end(); ++vit) std::cout << " Variable: " << *vit << std::endl; std::cout << " ByteCode: "; std::vector::iterator cit; - for (cit = mData.mScriptData.begin(); cit != mData.mScriptData.end(); cit++) + for (cit = mData.mScriptData.begin(); cit != mData.mScriptData.end(); ++cit) std::cout << boost::format("%02X") % (int)(*cit); std::cout << std::endl; diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index 3a52592ae..80f186b1f 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -15,6 +15,7 @@ namespace bfs = boost::filesystem; MwIniImporter::MwIniImporter() : mVerbose(false) + , mEncoding(ToUTF8::WINDOWS_1250) { const char *map[][2] = { @@ -709,8 +710,7 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(const std::string& filenam continue; } - multistrmap::iterator it; - if((it = map.find(key)) == map.end()) { + if(map.find(key) == map.end()) { map.insert( std::make_pair (key, std::vector() ) ); } map[key].push_back(value); @@ -746,8 +746,7 @@ MwIniImporter::multistrmap MwIniImporter::loadCfgFile(const std::string& filenam std::string key(line.substr(0,pos)); std::string value(line.substr(pos+1)); - multistrmap::iterator it; - if((it = map.find(key)) == map.end()) { + if(map.find(key) == map.end()) { map.insert( std::make_pair (key, std::vector() ) ); } map[key].push_back(value); diff --git a/apps/mwiniimporter/main.cpp b/apps/mwiniimporter/main.cpp index c10103cd6..fdf6db804 100644 --- a/apps/mwiniimporter/main.cpp +++ b/apps/mwiniimporter/main.cpp @@ -37,6 +37,8 @@ public: char **get() const { return const_cast(argv); } private: + utf8argv(const utf8argv&); + utf8argv& operator=(const utf8argv&); const char **argv; std::vector args; diff --git a/apps/opencs/model/doc/savingstages.hpp b/apps/opencs/model/doc/savingstages.hpp index d766b774e..54e877ef3 100644 --- a/apps/opencs/model/doc/savingstages.hpp +++ b/apps/opencs/model/doc/savingstages.hpp @@ -103,11 +103,6 @@ namespace CSMDoc if (state==CSMWorld::RecordBase::State_Modified || state==CSMWorld::RecordBase::State_ModifiedOnly) { - std::string type; - for (int i=0; i<4; ++i) - /// \todo make endianess agnostic (change ESMWriter interface?) - type += reinterpret_cast (&mCollection.getRecord (stage).mModified.sRecordId)[i]; - mState.getWriter().startRecord (mCollection.getRecord (stage).mModified.sRecordId); mState.getWriter().writeHNCString ("NAME", mCollection.getId (stage)); mCollection.getRecord (stage).mModified.save (mState.getWriter()); diff --git a/apps/opencs/view/render/navigation.cpp b/apps/opencs/view/render/navigation.cpp index 14ae7f0b7..705759104 100644 --- a/apps/opencs/view/render/navigation.cpp +++ b/apps/opencs/view/render/navigation.cpp @@ -11,9 +11,14 @@ float CSVRender::Navigation::getFactor (bool mouse) const return factor; } +CSVRender::Navigation::Navigation() + : mFastModeFactor(1) +{ +} + CSVRender::Navigation::~Navigation() {} void CSVRender::Navigation::setFastModeFactor (float factor) { mFastModeFactor = factor; -} \ No newline at end of file +} diff --git a/apps/opencs/view/render/navigation.hpp b/apps/opencs/view/render/navigation.hpp index 873519609..ead8f3e13 100644 --- a/apps/opencs/view/render/navigation.hpp +++ b/apps/opencs/view/render/navigation.hpp @@ -20,6 +20,7 @@ namespace CSVRender public: + Navigation(); virtual ~Navigation(); void setFastModeFactor (float factor); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 1a720ff33..06b041786 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -361,11 +361,6 @@ namespace CSVRender } } - int SceneWidget::getFastFactor() const - { - return mFast ? mFastFactor : 1; - } - void SceneWidget::setLighting (Lighting *lighting) { if (mLighting) diff --git a/apps/opencs/view/render/scenewidget.hpp b/apps/opencs/view/render/scenewidget.hpp index 9f79aee17..6361589a4 100644 --- a/apps/opencs/view/render/scenewidget.hpp +++ b/apps/opencs/view/render/scenewidget.hpp @@ -80,8 +80,6 @@ namespace CSVRender void updateOgreWindow(); - int getFastFactor() const; - void setLighting (Lighting *lighting); ///< \attention The ownership of \a lighting is not transferred to *this. diff --git a/apps/opencs/view/world/datadisplaydelegate.cpp b/apps/opencs/view/world/datadisplaydelegate.cpp index 20cf22cdf..46ca17a29 100644 --- a/apps/opencs/view/world/datadisplaydelegate.cpp +++ b/apps/opencs/view/world/datadisplaydelegate.cpp @@ -38,7 +38,7 @@ void CSVWorld::DataDisplayDelegate::buildPixmaps () } } -void CSVWorld::DataDisplayDelegate::setIconSize(const QSize size) +void CSVWorld::DataDisplayDelegate::setIconSize(const QSize& size) { mIconSize = size; buildPixmaps(); diff --git a/apps/opencs/view/world/datadisplaydelegate.hpp b/apps/opencs/view/world/datadisplaydelegate.hpp index a29675e74..73790e3c6 100755 --- a/apps/opencs/view/world/datadisplaydelegate.hpp +++ b/apps/opencs/view/world/datadisplaydelegate.hpp @@ -50,7 +50,7 @@ namespace CSVWorld virtual void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; /// pass a QSize defining height / width of icon. Default is QSize (16,16). - void setIconSize (const QSize icon); + void setIconSize (const QSize& icon); /// offset the horizontal position of the icon from the left edge of the cell. Default is 3 pixels. void setIconLeftOffset (int offset); diff --git a/apps/openmw/crashcatcher.cpp b/apps/openmw/crashcatcher.cpp index a21583402..b9d78540e 100644 --- a/apps/openmw/crashcatcher.cpp +++ b/apps/openmw/crashcatcher.cpp @@ -127,7 +127,6 @@ static int (*cc_user_info)(char*, char*); static void gdb_info(pid_t pid) { char respfile[64]; - char cmd_buf[128]; FILE *f; int fd; @@ -156,6 +155,7 @@ static void gdb_info(pid_t pid) fclose(f); /* Run gdb and print process info. */ + char cmd_buf[128]; snprintf(cmd_buf, sizeof(cmd_buf), "gdb --quiet --batch --command=%s", respfile); printf("Executing: %s\n", cmd_buf); fflush(stdout); diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index ebadeb732..744780b25 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -62,7 +62,6 @@ void validate(boost::any &v, std::vector const &tokens, FallbackMap FallbackMap *map = boost::any_cast(&v); - std::map::iterator mapIt; for(std::vector::const_iterator it=tokens.begin(); it != tokens.end(); ++it) { int sep = it->find(","); @@ -76,7 +75,7 @@ void validate(boost::any &v, std::vector const &tokens, FallbackMap std::string key(it->substr(0,sep)); std::string value(it->substr(sep+1)); - if((mapIt = map->mMap.find(key)) == map->mMap.end()) + if(map->mMap.find(key) == map->mMap.end()) { map->mMap.insert(std::make_pair (key,value)); } diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index b4332b0fd..e8286bdd1 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -225,7 +225,6 @@ namespace MWBase virtual void showCrosshair(bool show) = 0; virtual bool getSubtitlesEnabled() = 0; - virtual void toggleHud() = 0; virtual bool toggleGui() = 0; virtual void disallowMouse() = 0; diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index dd879305d..cf1b74485 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -1188,13 +1188,6 @@ namespace MWClass + shield; } - - void Npc::adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const - { - y = 0; - x = 0; - } - void Npc::adjustScale(const MWWorld::Ptr &ptr, float &scale) const { MWWorld::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index 05594a530..fd16e6f08 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -139,8 +139,6 @@ namespace MWClass virtual void skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType, float extraFactor=1.f) const; ///< Inform actor \a ptr that a skill use has succeeded. - virtual void adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const; - virtual bool isEssential (const MWWorld::Ptr& ptr) const; ///< Is \a ptr essential? (i.e. may losing \a ptr make the game unwinnable) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index f09b81b40..892669678 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -729,10 +729,10 @@ namespace MWDialogue { std::vector result; MyGUI::UString utext(text); - size_t pos_begin, pos_end, iteration_pos = 0; + size_t pos_end, iteration_pos = 0; for(;;) { - pos_begin = utext.find('@', iteration_pos); + size_t pos_begin = utext.find('@', iteration_pos); if (pos_begin != std::string::npos) pos_end = utext.find('#', pos_begin); @@ -758,12 +758,12 @@ namespace MWDialogue size_t RemovePseudoAsterisks(std::string& phrase) { size_t pseudoAsterisksCount = 0; - const char specialPseudoAsteriskCharacter = 127; if( !phrase.empty() ) { std::string::reverse_iterator rit = phrase.rbegin(); + const char specialPseudoAsteriskCharacter = 127; while( rit != phrase.rend() && *rit == specialPseudoAsteriskCharacter ) { pseudoAsterisksCount++; diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index b4308858a..4e45f1a7c 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -277,7 +277,6 @@ namespace MWGui InfoBoxDialog::InfoBoxDialog() : WindowModal("openmw_infobox.layout") - , mCurrentButton(-1) { getWidget(mTextBox, "TextBox"); getWidget(mText, "Text"); @@ -306,7 +305,6 @@ namespace MWGui MyGUI::Gui::getInstance().destroyWidget(*it); } this->mButtons.clear(); - mCurrentButton = -1; // TODO: The buttons should be generated from a template in the layout file, ie. cloning an existing widget MyGUI::Button* button; @@ -336,11 +334,6 @@ namespace MWGui center(); } - int InfoBoxDialog::getChosenButton() const - { - return mCurrentButton; - } - void InfoBoxDialog::onButtonClicked(MyGUI::Widget* _sender) { std::vector::const_iterator end = mButtons.end(); @@ -349,7 +342,6 @@ namespace MWGui { if (*it == _sender) { - mCurrentButton = i; eventButtonSelected(i); return; } diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index 846edc667..40056ca5e 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -24,7 +24,6 @@ namespace MWGui void setButtons(ButtonList &buttons); virtual void open(); - int getChosenButton() const; // Events typedef MyGUI::delegates::CMultiDelegate1 EventHandle_Int; @@ -41,7 +40,6 @@ namespace MWGui void fitToText(MyGUI::TextBox* widget); void layoutVertically(MyGUI::Widget* widget, int margin); - int mCurrentButton; MyGUI::Widget* mTextBox; MyGUI::TextBox* mText; MyGUI::Widget* mButtonBar; diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index af0eb6ef9..5a7193d65 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -155,11 +155,6 @@ namespace MWGui mCommandLine->setFontName(fntName); } - void Console::clearHistory() - { - mHistory->setCaption(""); - } - void Console::print(const std::string &msg) { mHistory->addText(msg); diff --git a/apps/openmw/mwgui/console.hpp b/apps/openmw/mwgui/console.hpp index 90da740c2..09a05be48 100644 --- a/apps/openmw/mwgui/console.hpp +++ b/apps/openmw/mwgui/console.hpp @@ -48,8 +48,6 @@ namespace MWGui void onResChange(int width, int height); - void clearHistory(); - // Print a message to the console. Messages may contain color // code, eg. "#FFFFFF this is white". void print(const std::string &msg); diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 28639a8e1..a3f82e65d 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -125,10 +125,10 @@ namespace MWGui // We need this copy for when @# hyperlinks are replaced std::string text = mText; - size_t pos_begin, pos_end; + size_t pos_end; for(;;) { - pos_begin = text.find('@'); + size_t pos_begin = text.find('@'); if (pos_begin != std::string::npos) pos_end = text.find('#', pos_begin); diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index d838ae8af..096c7db0b 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -183,10 +183,9 @@ namespace MWGui paper->setNeedMouseFocus(false); BookTextParser parser(markup); - BookTextParser::Events event; for (;;) { - event = parser.next(); + BookTextParser::Events event = parser.next(); if (event == BookTextParser::Event_BrTag || event == BookTextParser::Event_PTag) continue; diff --git a/apps/openmw/mwgui/itemmodel.cpp b/apps/openmw/mwgui/itemmodel.cpp index 17f787dcb..f5135ce80 100644 --- a/apps/openmw/mwgui/itemmodel.cpp +++ b/apps/openmw/mwgui/itemmodel.cpp @@ -36,7 +36,8 @@ namespace MWGui Misc::StringUtils::toLower(currentGMSTID); // Don't bother checking this GMST if it's not a sMagicBound* one. - if (currentGMSTID.find("smagicbound") != 0) + const std::string& toFind = "smagicbound"; + if (currentGMSTID.compare(0, toFind.length(), toFind) != 0) continue; // All sMagicBound* GMST's should be of type string diff --git a/apps/openmw/mwgui/journalviewmodel.cpp b/apps/openmw/mwgui/journalviewmodel.cpp index b71e64a19..45a1858d2 100644 --- a/apps/openmw/mwgui/journalviewmodel.cpp +++ b/apps/openmw/mwgui/journalviewmodel.cpp @@ -113,10 +113,10 @@ struct JournalViewModelImpl : JournalViewModel utf8text = getText (); - size_t pos_begin, pos_end; + size_t pos_end = 0; for(;;) { - pos_begin = utf8text.find('@'); + size_t pos_begin = utf8text.find('@'); if (pos_begin != std::string::npos) pos_end = utf8text.find('#', pos_begin); @@ -223,15 +223,6 @@ struct JournalViewModelImpl : JournalViewModel } } - void visitQuestName (QuestId questId, boost::function visitor) const - { - MWDialogue::Quest const * quest = reinterpret_cast (questId); - - std::string name = quest->getName (); - - visitor (toUtf8Span (name)); - } - template struct JournalEntryImpl : BaseEntry { @@ -301,11 +292,6 @@ struct JournalViewModelImpl : JournalViewModel } } - void visitTopics (boost::function visitor) const - { - throw std::runtime_error ("not implemented"); - } - void visitTopicName (TopicId topicId, boost::function visitor) const { MWDialogue::Topic const & topic = * reinterpret_cast (topicId); diff --git a/apps/openmw/mwgui/journalviewmodel.hpp b/apps/openmw/mwgui/journalviewmodel.hpp index 4b827d1ab..5f0189b59 100644 --- a/apps/openmw/mwgui/journalviewmodel.hpp +++ b/apps/openmw/mwgui/journalviewmodel.hpp @@ -67,9 +67,6 @@ namespace MWGui /// returns true if their are no journal entries to display virtual bool isEmpty () const = 0; - /// provides access to the name of the quest with the specified identifier - virtual void visitQuestName (TopicId topicId, boost::function visitor) const = 0; - /// walks the active and optionally completed, quests providing the name virtual void visitQuestNames (bool active_only, boost::function visitor) const = 0; diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 6cf8bb003..4139a7d24 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -393,18 +393,6 @@ namespace popBook (); } - void showList (char const * listId, char const * pageId, Book book) - { - std::pair size = book->getSize (); - - getPage (pageId)->showPage (book, 0); - - // Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden - getWidget (listId)->setVisibleVScroll(false); - getWidget (listId)->setCanvasSize (size.first, size.second); - getWidget (listId)->setVisibleVScroll(true); - } - void notifyIndexLinkClicked (MWGui::TypesetBook::InteractiveId character) { setVisible (LeftTopicIndex, false); diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index 7188ab9df..56a231947 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -140,7 +140,7 @@ namespace MWGui // Vanilla uses thief.dds for custom classes. // Choosing Stealth specialization and Speed/Agility as attributes, if possible. Otherwise fall back to first class found. MWWorld::SharedIterator it = world->getStore().get().begin(); - for(; it != world->getStore().get().end(); it++) + for(; it != world->getStore().get().end(); ++it) { if(it->mData.mIsPlayable && it->mData.mSpecialization == 2 && it->mData.mAttribute[0] == 4 && it->mData.mAttribute[1] == 3) break; diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 09074d8f0..80f38ba40 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -139,11 +139,6 @@ namespace MWGui return false; } - void MessageBoxManager::setMessageBoxSpeed (int speed) - { - mMessageBoxSpeed = speed; - } - int MessageBoxManager::readPressedButton () { int pressed = mLastButtonPressed; @@ -218,7 +213,6 @@ namespace MWGui MyGUI::IntSize gameWindowSize = MyGUI::RenderManager::getInstance().getViewSize(); int biggestButtonWidth = 0; - int buttonWidth = 0; int buttonsWidth = 0; int buttonsHeight = 0; int buttonHeight = 0; @@ -241,7 +235,7 @@ namespace MWGui if (buttonsWidth != 0) buttonsWidth += buttonLeftPadding; - buttonWidth = button->getTextSize().width + 2*buttonPadding; + int buttonWidth = button->getTextSize().width + 2*buttonPadding; buttonsWidth += buttonWidth; buttonHeight = button->getTextSize().height + 2*buttonPadding; diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 406d98c48..5f180df20 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -34,7 +34,6 @@ namespace MWGui void clear(); bool removeMessageBox (MessageBox *msgbox); - void setMessageBoxSpeed (int speed); int readPressedButton (); diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index a51250c9d..e3bec3789 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -393,7 +393,6 @@ namespace MWGui if (mCurrentRaceId.empty()) return; - Widgets::MWSpellPtr spellPowerWidget; const int lineHeight = 18; MyGUI::IntCoord coord(0, 0, mSpellPowerList->getWidth(), 18); @@ -405,7 +404,7 @@ namespace MWGui for (int i = 0; it != end; ++it) { const std::string &spellpower = *it; - spellPowerWidget = mSpellPowerList->createWidget("MW_StatName", coord, MyGUI::Align::Default, std::string("SpellPower") + boost::lexical_cast(i)); + Widgets::MWSpellPtr spellPowerWidget = mSpellPowerList->createWidget("MW_StatName", coord, MyGUI::Align::Default, std::string("SpellPower") + boost::lexical_cast(i)); spellPowerWidget->setSpellId(spellpower); spellPowerWidget->setUserString("ToolTipType", "Spell"); spellPowerWidget->setUserString("Spell", spellpower); diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index 71cf7fdb3..74def66e3 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -362,8 +362,7 @@ namespace MWGui void SettingsWindow::onShaderModeToggled(MyGUI::Widget* _sender) { - std::string val = _sender->castType()->getCaption(); - val = hlslGlsl(); + std::string val = hlslGlsl(); _sender->castType()->setCaption(val); diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index cdab79af1..1116d6543 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -39,6 +39,7 @@ namespace MWGui EditEffectDialog::EditEffectDialog() : WindowModal("openmw_edit_effect.layout") , mEditing(false) + , mMagicEffect(NULL) { getWidget(mCancelButton, "CancelButton"); getWidget(mOkButton, "OkButton"); @@ -181,7 +182,7 @@ namespace MWGui { mAreaBox->setPosition(mAreaBox->getPosition().left, curY); mAreaBox->setVisible (true); - curY += mAreaBox->getSize().height; + //curY += mAreaBox->getSize().height; } } diff --git a/apps/openmw/mwgui/spellcreationdialog.hpp b/apps/openmw/mwgui/spellcreationdialog.hpp index e77c0eecf..ecccf3baf 100644 --- a/apps/openmw/mwgui/spellcreationdialog.hpp +++ b/apps/openmw/mwgui/spellcreationdialog.hpp @@ -158,8 +158,6 @@ namespace MWGui MyGUI::Button* mCancelButton; MyGUI::TextBox* mPriceLabel; - Widgets::MWEffectList* mUsedEffectsList; - ESM::Spell mSpell; }; diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 6059d2d0d..d7bc2c96e 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -225,11 +225,10 @@ namespace MWGui const ESM::Spell *spell = store.get().search(mId); MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found"); - MWSpellEffectPtr effect = NULL; std::vector::const_iterator end = spell->mEffects.mList.end(); for (std::vector::const_iterator it = spell->mEffects.mList.begin(); it != end; ++it) { - effect = creator->createWidget("MW_EffectImage", coord, MyGUI::Align::Default); + MWSpellEffectPtr effect = creator->createWidget("MW_EffectImage", coord, MyGUI::Align::Default); SpellEffectParams params; params.mEffectID = it->mEffectID; params.mSkill = it->mSkill; @@ -565,22 +564,6 @@ namespace MWGui } } - void MWScrollBar::setEnableRepeat(bool enable) - { - mEnableRepeat = enable; - } - - bool MWScrollBar::getEnableRepeat() - { - return mEnableRepeat; - } - - void MWScrollBar::getRepeat(float &trigger, float &step) - { - trigger = mRepeatTriggerTime; - step = mRepeatStepTime; - } - void MWScrollBar::setRepeat(float trigger, float step) { mRepeatTriggerTime = trigger; diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index fff7bdbfc..aae28a686 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -307,9 +307,6 @@ namespace MWGui MWScrollBar(); virtual ~MWScrollBar(); - void setEnableRepeat(bool enable); - bool getEnableRepeat(); - void getRepeat(float &trigger, float &step); void setRepeat(float trigger, float step); protected: diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index ef7622a62..fabdf4dae 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1348,12 +1348,6 @@ namespace MWGui return mSubtitlesEnabled; } - void WindowManager::toggleHud () - { - mHudEnabled = !mHudEnabled; - mHud->setVisible (mHudEnabled); - } - bool WindowManager::toggleGui() { mGuiEnabled = !mGuiEnabled; @@ -1669,7 +1663,7 @@ namespace MWGui WindowModal* WindowManager::getCurrentModal() const { - if(mCurrentModals.size() > 0) + if(!mCurrentModals.empty()) return mCurrentModals.top(); else return NULL; @@ -1679,7 +1673,7 @@ namespace MWGui { // Only remove the top if it matches the current pointer. A lot of things hide their visibility before showing it, //so just popping the top would cause massive issues. - if(mCurrentModals.size() > 0) + if(!mCurrentModals.empty()) if(input == mCurrentModals.top()) mCurrentModals.pop(); } diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 21a2cc45b..e7853b84f 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -222,7 +222,6 @@ namespace MWGui virtual void showCrosshair(bool show); virtual bool getSubtitlesEnabled(); - virtual void toggleHud(); /// Turn visibility of *all* GUI elements on or off (HUD and all windows, except the console) virtual bool toggleGui(); diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index fb387afea..e55ccba17 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -1232,14 +1232,14 @@ namespace MWMechanics } static float sneakTimer = 0.f; // times update of sneak icon - static float sneakSkillTimer = 0.f; // times sneak skill progress from "avoid notice" // if player is in sneak state see if anyone detects him if (player.getClass().getCreatureStats(player).getMovementFlag(MWMechanics::CreatureStats::Flag_Sneak)) { + static float sneakSkillTimer = 0.f; // times sneak skill progress from "avoid notice" + const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); const int radius = esmStore.get().find("fSneakUseDist")->getInt(); - bool detected = false; static float fSneakUseDelay = esmStore.get().find("fSneakUseDelay")->getFloat(); @@ -1251,6 +1251,8 @@ namespace MWMechanics // Set when an NPC is within line of sight and distance, but is still unaware. Used for skill progress. bool avoidedNotice = false; + bool detected = false; + for (PtrControllerMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter) { if (iter->first == player) // not the player @@ -1418,7 +1420,7 @@ namespace MWMechanics std::list Actors::getActorsFollowing(const MWWorld::Ptr& actor) { std::list list; - for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();iter++) + for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter) { const MWWorld::Class &cls = iter->first.getClass(); CreatureStats &stats = cls.getCreatureStats(iter->first); @@ -1450,7 +1452,7 @@ namespace MWMechanics getObjectsInRange(position, MWBase::Environment::get().getWorld()->getStore().get().find("fAlarmRadius")->getFloat(), neighbors); //only care about those within the alarm disance - for(std::vector::iterator iter(neighbors.begin());iter != neighbors.end();iter++) + for(std::vector::iterator iter(neighbors.begin());iter != neighbors.end();++iter) { const MWWorld::Class &cls = iter->getClass(); CreatureStats &stats = cls.getCreatureStats(*iter); diff --git a/apps/openmw/mwmechanics/aiactivate.hpp b/apps/openmw/mwmechanics/aiactivate.hpp index 8003c2a36..2a0f67709 100644 --- a/apps/openmw/mwmechanics/aiactivate.hpp +++ b/apps/openmw/mwmechanics/aiactivate.hpp @@ -35,8 +35,6 @@ namespace MWMechanics private: std::string mObjectId; - int mCellX; - int mCellY; }; } #endif // GAME_MWMECHANICS_AIACTIVATE_H diff --git a/apps/openmw/mwmechanics/aiavoiddoor.cpp b/apps/openmw/mwmechanics/aiavoiddoor.cpp index eea1b4850..7cb4f1c25 100644 --- a/apps/openmw/mwmechanics/aiavoiddoor.cpp +++ b/apps/openmw/mwmechanics/aiavoiddoor.cpp @@ -64,7 +64,7 @@ bool MWMechanics::AiAvoidDoor::execute (const MWWorld::Ptr& actor,float duration // Make all nearby actors also avoid the door std::vector actors; MWBase::Environment::get().getMechanicsManager()->getActorsInRange(Ogre::Vector3(pos.pos[0],pos.pos[1],pos.pos[2]),100,actors); - for(std::vector::iterator it = actors.begin(); it != actors.end(); it++) { + for(std::vector::iterator it = actors.begin(); it != actors.end(); ++it) { if(*it != MWBase::Environment::get().getWorld()->getPlayerPtr()) { //Not the player MWMechanics::AiSequence& seq = it->getClass().getCreatureStats(*it).getAiSequence(); if(seq.getTypeId() != MWMechanics::AiPackage::TypeIdAvoidDoor) { //Only add it once diff --git a/apps/openmw/mwmechanics/aicombataction.cpp b/apps/openmw/mwmechanics/aicombataction.cpp index 67afad7a5..152854af9 100644 --- a/apps/openmw/mwmechanics/aicombataction.cpp +++ b/apps/openmw/mwmechanics/aicombataction.cpp @@ -301,18 +301,20 @@ namespace MWMechanics if (!target.isEmpty() && target.getClass().getCreatureStats(target).getAttribute(effect.mAttribute).getModified() <= 0) return 0.f; { - const float attributePriorities[ESM::Attribute::Length] = { - 1.f, // Strength - 0.5, // Intelligence - 0.6, // Willpower - 0.7, // Agility - 0.5, // Speed - 0.8, // Endurance - 0.7, // Personality - 0.3 // Luck - }; if (effect.mAttribute >= 0 && effect.mAttribute < ESM::Attribute::Length) + { + const float attributePriorities[ESM::Attribute::Length] = { + 1.f, // Strength + 0.5, // Intelligence + 0.6, // Willpower + 0.7, // Agility + 0.5, // Speed + 0.8, // Endurance + 0.7, // Personality + 0.3 // Luck + }; rating *= attributePriorities[effect.mAttribute]; + } } break; diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp index 02ad2d0a2..98fc64090 100644 --- a/apps/openmw/mwmechanics/aiescort.cpp +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -54,6 +54,7 @@ namespace MWMechanics , mCellY(std::numeric_limits::max()) , mCellId(escort->mCellId) , mRemainingDuration(escort->mRemainingDuration) + , mMaxDist(450) { } diff --git a/apps/openmw/mwmechanics/aipackage.hpp b/apps/openmw/mwmechanics/aipackage.hpp index 0a5e1c545..ff3e84b98 100644 --- a/apps/openmw/mwmechanics/aipackage.hpp +++ b/apps/openmw/mwmechanics/aipackage.hpp @@ -69,7 +69,6 @@ namespace MWMechanics PathFinder mPathFinder; ObstacleCheck mObstacleCheck; - float mDoorCheckDuration; float mTimer; float mStuckTimer; diff --git a/apps/openmw/mwmechanics/aipursue.hpp b/apps/openmw/mwmechanics/aipursue.hpp index 18a22b676..a6eef2984 100644 --- a/apps/openmw/mwmechanics/aipursue.hpp +++ b/apps/openmw/mwmechanics/aipursue.hpp @@ -41,8 +41,6 @@ namespace MWMechanics private: int mTargetActorId; // The actor to pursue - int mCellX; - int mCellY; }; } #endif diff --git a/apps/openmw/mwmechanics/aisequence.cpp b/apps/openmw/mwmechanics/aisequence.cpp index f15b357e5..0341c9745 100644 --- a/apps/openmw/mwmechanics/aisequence.cpp +++ b/apps/openmw/mwmechanics/aisequence.cpp @@ -31,9 +31,11 @@ void AiSequence::copy (const AiSequence& sequence) AiSequence::AiSequence() : mDone (false), mLastAiPackage(-1) {} -AiSequence::AiSequence (const AiSequence& sequence) : mDone (false) +AiSequence::AiSequence (const AiSequence& sequence) { copy (sequence); + mDone = sequence.mDone; + mLastAiPackage = sequence.mLastAiPackage; } AiSequence& AiSequence::operator= (const AiSequence& sequence) @@ -43,6 +45,7 @@ AiSequence& AiSequence::operator= (const AiSequence& sequence) clear(); copy (sequence); mDone = sequence.mDone; + mLastAiPackage = sequence.mLastAiPackage; } return *this; @@ -120,33 +123,6 @@ bool AiSequence::isInCombat(const MWWorld::Ptr &actor) const return false; } -bool AiSequence::canAddTarget(const ESM::Position& actorPos, float distToTarget) const -{ - bool firstCombatFound = false; - MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); - - for(std::list::const_iterator it = mPackages.begin(); it != mPackages.end(); ++it) - { - if ((*it)->getTypeId() == AiPackage::TypeIdCombat) - { - firstCombatFound = true; - - const AiCombat *combat = static_cast(*it); - if (combat->getTarget() != player ) return false; // only 1 non-player target allowed - else - { - // add new target only if current target (player) is farther - const ESM::Position &targetPos = combat->getTarget().getRefData().getPosition(); - - float distToCurrTarget = (Ogre::Vector3(targetPos.pos) - Ogre::Vector3(actorPos.pos)).length(); - return (distToCurrTarget > distToTarget); - } - } - else if (firstCombatFound) break; // assumes combat packages go one-by-one in packages list - } - return true; -} - void AiSequence::stopCombat() { while (getTypeId() == AiPackage::TypeIdCombat) @@ -295,11 +271,6 @@ void AiSequence::stack (const AiPackage& package, const MWWorld::Ptr& actor) mPackages.push_front (package.clone()); } -void AiSequence::queue (const AiPackage& package) -{ - mPackages.push_back (package.clone()); -} - AiPackage* MWMechanics::AiSequence::getActivePackage() { if(mPackages.empty()) diff --git a/apps/openmw/mwmechanics/aisequence.hpp b/apps/openmw/mwmechanics/aisequence.hpp index c7d176661..56f5dee31 100644 --- a/apps/openmw/mwmechanics/aisequence.hpp +++ b/apps/openmw/mwmechanics/aisequence.hpp @@ -98,10 +98,6 @@ namespace MWMechanics @param actor The actor that owns this AiSequence **/ void stack (const AiPackage& package, const MWWorld::Ptr& actor); - /// Add \a package to the end of the sequence - /** Executed after all other packages have been completed **/ - void queue (const AiPackage& package); - /// Return the current active package. /** If there is no active package, it will throw an exception **/ AiPackage* getActivePackage(); diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index eafbdd59c..aee3e654d 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -686,16 +686,15 @@ namespace MWMechanics } AiWander::AiWander (const ESM::AiSequence::AiWander* wander) + : mDistance(wander->mData.mDistance) + , mDuration(wander->mData.mDuration) + , mStartTime(MWWorld::TimeStamp(wander->mStartTime)) + , mTimeOfDay(wander->mData.mTimeOfDay) + , mRepeat(wander->mData.mShouldRepeat) { - mDistance = wander->mData.mDistance; - mDuration = wander->mData.mDuration; - mStartTime = MWWorld::TimeStamp(wander->mStartTime); - mTimeOfDay = wander->mData.mTimeOfDay; for (int i=0; i<8; ++i) mIdle.push_back(wander->mData.mIdle[i]); - mRepeat = wander->mData.mShouldRepeat; - init(); } } diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 5b81dff61..24e7b5aa1 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -27,6 +27,11 @@ #include "creaturestats.hpp" #include "npcstats.hpp" +MWMechanics::Alchemy::Alchemy() + : mValue(0) +{ +} + std::set MWMechanics::Alchemy::listEffects() const { std::map effects; diff --git a/apps/openmw/mwmechanics/alchemy.hpp b/apps/openmw/mwmechanics/alchemy.hpp index 91e024574..a2429ca8e 100644 --- a/apps/openmw/mwmechanics/alchemy.hpp +++ b/apps/openmw/mwmechanics/alchemy.hpp @@ -22,6 +22,8 @@ namespace MWMechanics { public: + Alchemy(); + typedef std::vector TToolsContainer; typedef TToolsContainer::const_iterator TToolsIterator; diff --git a/apps/openmw/mwmechanics/combat.cpp b/apps/openmw/mwmechanics/combat.cpp index 657cbf92e..f48e82324 100644 --- a/apps/openmw/mwmechanics/combat.cpp +++ b/apps/openmw/mwmechanics/combat.cpp @@ -193,13 +193,11 @@ namespace MWMechanics return; } - float damage = 0.0f; - float fDamageStrengthBase = gmst.find("fDamageStrengthBase")->getFloat(); float fDamageStrengthMult = gmst.find("fDamageStrengthMult")->getFloat(); const unsigned char* attack = weapon.get()->mBase->mData.mChop; - damage = attack[0] + ((attack[1]-attack[0])*attackerStats.getAttackStrength()); // Bow/crossbow damage + float damage = attack[0] + ((attack[1]-attack[0])*attackerStats.getAttackStrength()); // Bow/crossbow damage if (weapon != projectile) { // Arrow/bolt damage diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 8020db85b..c4d316ad6 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -120,11 +120,6 @@ namespace MWMechanics return mSpells; } - void CreatureStats::setSpells(const Spells &spells) - { - mSpells = spells; - } - ActiveSpells &CreatureStats::getActiveSpells() { return mActiveSpells; @@ -200,11 +195,6 @@ namespace MWMechanics mLevel = level; } - void CreatureStats::setActiveSpells(const ActiveSpells &active) - { - mActiveSpells = active; - } - void CreatureStats::modifyMagicEffects(const MagicEffects &effects) { if (effects.get(ESM::MagicEffect::FortifyMaximumMagicka).getModifier() @@ -536,7 +526,6 @@ namespace MWMechanics mLastRestock = MWWorld::TimeStamp(state.mTradeTime); mGoldPool = state.mGoldPool; - mFallHeight = state.mFallHeight; mDead = state.mDead; mDied = state.mDied; diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index 941668fb2..5e169ffb0 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -40,7 +40,6 @@ namespace MWMechanics bool mTalkedTo; bool mAlarmed; bool mAttacked; - bool mHostile; bool mAttackingOrSpell; bool mKnockdown; bool mKnockdownOneFrame; @@ -138,10 +137,6 @@ namespace MWMechanics void setDynamic (int index, const DynamicStat &value); - void setSpells(const Spells &spells); - - void setActiveSpells(const ActiveSpells &active); - /// Set Modifier for each magic effect according to \a effects. Does not touch Base values. void modifyMagicEffects(const MagicEffects &effects); diff --git a/apps/openmw/mwmechanics/enchanting.cpp b/apps/openmw/mwmechanics/enchanting.cpp index 9663a2d51..63ffbc7e8 100644 --- a/apps/openmw/mwmechanics/enchanting.cpp +++ b/apps/openmw/mwmechanics/enchanting.cpp @@ -166,16 +166,15 @@ namespace MWMechanics float enchantmentCost = 0; int effectsLeftCnt = mEffects.size(); - float baseCost, magnitudeCost, areaCost; - int magMin, magMax, area; for (std::vector::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) { - baseCost = (store.get().find(it->mEffectID))->mData.mBaseCost; + float baseCost = (store.get().find(it->mEffectID))->mData.mBaseCost; // To reflect vanilla behavior - magMin = (it->mMagnMin == 0) ? 1 : it->mMagnMin; - magMax = (it->mMagnMax == 0) ? 1 : it->mMagnMax; - area = (it->mArea == 0) ? 1 : it->mArea; + int magMin = (it->mMagnMin == 0) ? 1 : it->mMagnMin; + int magMax = (it->mMagnMax == 0) ? 1 : it->mMagnMax; + int area = (it->mArea == 0) ? 1 : it->mArea; + float magnitudeCost = 0; if (mCastStyle == ESM::Enchantment::ConstantEffect) { magnitudeCost = (magMin + magMax) * baseCost * 2.5; @@ -187,7 +186,7 @@ namespace MWMechanics magnitudeCost *= 1.5; } - areaCost = area * 0.025 * baseCost; + float areaCost = area * 0.025 * baseCost; if (it->mRange == ESM::RT_Target) areaCost *= 1.5; diff --git a/apps/openmw/mwmechanics/pathfinding.cpp b/apps/openmw/mwmechanics/pathfinding.cpp index 62c1756c2..62e23db58 100644 --- a/apps/openmw/mwmechanics/pathfinding.cpp +++ b/apps/openmw/mwmechanics/pathfinding.cpp @@ -283,13 +283,6 @@ namespace MWMechanics return Ogre::Radian(Ogre::Math::ACos(directionY / directionResult) * sgn(Ogre::Math::ASin(directionX / directionResult))).valueDegrees(); } - // Used by AiCombat, use Euclidean distance - float PathFinder::getDistToNext(float x, float y, float z) - { - ESM::Pathgrid::Point nextPoint = *mPath.begin(); - return distance(nextPoint, x, y, z); - } - bool PathFinder::checkWaypoint(float x, float y, float z) { if(mPath.empty()) diff --git a/apps/openmw/mwmechanics/pathfinding.hpp b/apps/openmw/mwmechanics/pathfinding.hpp index 603a04f8c..482808dac 100644 --- a/apps/openmw/mwmechanics/pathfinding.hpp +++ b/apps/openmw/mwmechanics/pathfinding.hpp @@ -47,8 +47,6 @@ namespace MWMechanics float getZAngleToNext(float x, float y) const; - float getDistToNext(float x, float y, float z); - bool isPathConstructed() const { return mIsPathConstructed; diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index e4ee1cbe6..12ba3c2da 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -521,7 +521,7 @@ float Animation::getVelocity(const std::string &groupname) const { /* Look in reverse; last-inserted source has priority. */ AnimSourceList::const_reverse_iterator animsrc(mAnimSources.rbegin()); - for(;animsrc != mAnimSources.rend();animsrc++) + for(;animsrc != mAnimSources.rend();++animsrc) { const NifOgre::TextKeyMap &keys = (*animsrc)->mTextKeys; if(findGroupStart(keys, groupname) != keys.end()) @@ -831,8 +831,7 @@ void Animation::handleTextKey(AnimState &state, const std::string &groupname, co void Animation::changeGroups(const std::string &groupname, int groups) { - AnimStateMap::iterator stateiter = mStates.begin(); - stateiter = mStates.find(groupname); + AnimStateMap::iterator stateiter = mStates.find(groupname); if(stateiter != mStates.end()) { if(stateiter->second.mGroups != groups) diff --git a/apps/openmw/mwrender/camera.cpp b/apps/openmw/mwrender/camera.cpp index f38e00cce..bb196f282 100644 --- a/apps/openmw/mwrender/camera.cpp +++ b/apps/openmw/mwrender/camera.cpp @@ -26,7 +26,6 @@ namespace MWRender mNearest(30.f), mFurthest(800.f), mIsNearest(false), - mIsFurthest(false), mHeight(128.f), mCameraDistance(300.f), mDistanceAdjusted(false), @@ -292,7 +291,6 @@ namespace MWRender if(mFirstPersonView && !mPreviewMode && !mVanity.enabled) return; - mIsFurthest = false; mIsNearest = false; Ogre::Vector3 v(0.f, 0.f, dist); @@ -301,7 +299,6 @@ namespace MWRender } if (v.z >= mFurthest) { v.z = mFurthest; - mIsFurthest = true; } else if (!override && v.z < 10.f) { v.z = 10.f; } else if (override && v.z <= mNearest) { @@ -389,9 +386,4 @@ namespace MWRender { return mIsNearest; } - - bool Camera::isFurthest() - { - return mIsFurthest; - } } diff --git a/apps/openmw/mwrender/camera.hpp b/apps/openmw/mwrender/camera.hpp index 1e86bfb48..f7b0ae6e8 100644 --- a/apps/openmw/mwrender/camera.hpp +++ b/apps/openmw/mwrender/camera.hpp @@ -36,7 +36,6 @@ namespace MWRender float mNearest; float mFurthest; bool mIsNearest; - bool mIsFurthest; struct { bool enabled, allowed; @@ -118,8 +117,6 @@ namespace MWRender bool isVanityOrPreviewModeEnabled(); bool isNearest(); - - bool isFurthest(); }; } diff --git a/apps/openmw/mwrender/characterpreview.cpp b/apps/openmw/mwrender/characterpreview.cpp index 1af11996e..1630e4005 100644 --- a/apps/openmw/mwrender/characterpreview.cpp +++ b/apps/openmw/mwrender/characterpreview.cpp @@ -281,9 +281,9 @@ namespace MWRender RaceSelectionPreview::RaceSelectionPreview() : CharacterPreview(MWBase::Environment::get().getWorld()->getPlayerPtr(), 512, 512, "CharacterHeadPreview", Ogre::Vector3(0, 6, -35), Ogre::Vector3(0,125,0)) + , mBase (*mCharacter.get()->mBase) , mRef(&mBase) { - mBase = *mCharacter.get()->mBase; mCharacter = MWWorld::Ptr(&mRef, NULL); } diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index e4806072a..247a0ba14 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -150,7 +150,7 @@ void CreatureWeaponAnimation::updatePart(NifOgre::ObjectScenePtr& scene, int slo } std::vector >::iterator ctrl(scene->mControllers.begin()); - for(;ctrl != scene->mControllers.end();ctrl++) + for(;ctrl != scene->mControllers.end();++ctrl) { if(ctrl->getSource().isNull()) { diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index 4e0bd00f9..fd8b91936 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -106,13 +106,13 @@ namespace MWRender if (land) { const float landHeight = land->mLandData->mHeights[vertexY * ESM::Land::LAND_SIZE + vertexX]; - const float mountainHeight = 15000.f; - const float hillHeight = 2500.f; if (landHeight >= 0) { + const float hillHeight = 2500.f; if (landHeight >= hillHeight) { + const float mountainHeight = 15000.f; float factor = std::min(1.f, float(landHeight-hillHeight)/mountainHeight); r = (hillColour.r * (1-factor) + mountainColour.r * factor) * 255; g = (hillColour.g * (1-factor) + mountainColour.g * factor) * 255; diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 303917c95..9e93bd314 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -410,15 +410,18 @@ void NpcAnimation::updateParts() // Remember body parts so we only have to search through the store once for each race/gender/viewmode combination static std::map< std::pair,std::vector > sRaceMapping; - static const int Flag_Female = 1<<0; - static const int Flag_FirstPerson = 1<<1; - bool isWerewolf = (mNpcType == Type_Werewolf); int flags = (isWerewolf ? -1 : 0); if(!mNpc->isMale()) + { + static const int Flag_Female = 1<<0; flags |= Flag_Female; + } if(mViewMode == VM_FirstPerson) + { + static const int Flag_FirstPerson = 1<<1; flags |= Flag_FirstPerson; + } std::string race = (isWerewolf ? "werewolf" : Misc::StringUtils::lowerCase(mNpc->mRace)); std::pair thisCombination = std::make_pair(race, flags); @@ -604,7 +607,7 @@ Ogre::Vector3 NpcAnimation::runAnimation(float timepassed) if (mObjectParts[i].isNull()) continue; std::vector >::iterator ctrl(mObjectParts[i]->mControllers.begin()); - for(;ctrl != mObjectParts[i]->mControllers.end();ctrl++) + for(;ctrl != mObjectParts[i]->mControllers.end();++ctrl) ctrl->update(); Ogre::Entity *ent = mObjectParts[i]->mSkelBase; @@ -678,7 +681,7 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g } std::vector >::iterator ctrl(mObjectParts[type]->mControllers.begin()); - for(;ctrl != mObjectParts[type]->mControllers.end();ctrl++) + for(;ctrl != mObjectParts[type]->mControllers.end();++ctrl) { if(ctrl->getSource().isNull()) { @@ -715,7 +718,7 @@ void NpcAnimation::addPartGroup(int group, int priority, const std::vector::const_iterator part(parts.begin()); - for(;part != parts.end();part++) + for(;part != parts.end();++part) { const ESM::BodyPart *bodypart = 0; if(!mNpc->isMale() && !part->mFemale.empty()) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index ef5418159..4512bbbeb 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -574,24 +574,6 @@ void RenderingManager::configureAmbient(MWWorld::CellStore &mCell) sunEnable(false); } } -// Switch through lighting modes. - -void RenderingManager::toggleLight() -{ - if (mAmbientMode==2) - mAmbientMode = 0; - else - ++mAmbientMode; - - switch (mAmbientMode) - { - case 0: std::cout << "Setting lights to normal\n"; break; - case 1: std::cout << "Turning the lights up\n"; break; - case 2: std::cout << "Turning the lights to full\n"; break; - } - - setAmbientMode(); -} void RenderingManager::setSunColour(const Ogre::ColourValue& colour) { @@ -695,11 +677,6 @@ void RenderingManager::enableLights(bool sun) sunEnable(sun); } -Shadows* RenderingManager::getShadows() -{ - return mShadows; -} - void RenderingManager::notifyWorldSpaceChanged() { mEffectManager->clear(); diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index c5a77afc7..43d22d5ca 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -93,7 +93,6 @@ public: MWRender::Camera* getCamera() const; - void toggleLight(); bool toggleRenderMode(int mode); void removeCell (MWWorld::CellStore *store); @@ -157,8 +156,6 @@ public: float getTerrainHeightAt (Ogre::Vector3 worldPos); - Shadows* getShadows(); - void notifyWorldSpaceChanged(); void getTriangleBatchCount(unsigned int &triangles, unsigned int &batches); diff --git a/apps/openmw/mwrender/ripplesimulation.hpp b/apps/openmw/mwrender/ripplesimulation.hpp index 7e7eebc1c..e203212cf 100644 --- a/apps/openmw/mwrender/ripplesimulation.hpp +++ b/apps/openmw/mwrender/ripplesimulation.hpp @@ -41,6 +41,9 @@ public: void updateEmitterPtr (const MWWorld::Ptr& old, const MWWorld::Ptr& ptr); private: + RippleSimulation(const RippleSimulation&); + RippleSimulation& operator=(const RippleSimulation&); + std::vector mEmitters; Ogre::RenderTexture* mRenderTargets[4]; diff --git a/apps/openmw/mwrender/shadows.cpp b/apps/openmw/mwrender/shadows.cpp index 33e337649..596c6697a 100644 --- a/apps/openmw/mwrender/shadows.cpp +++ b/apps/openmw/mwrender/shadows.cpp @@ -186,13 +186,3 @@ PSSMShadowCameraSetup* Shadows::getPSSMSetup() { return mPSSMSetup; } - -float Shadows::getShadowFar() const -{ - return mShadowFar; -} - -float Shadows::getFadeStart() const -{ - return mFadeStart; -} diff --git a/apps/openmw/mwrender/shadows.hpp b/apps/openmw/mwrender/shadows.hpp index bc2b141f7..fe125f54c 100644 --- a/apps/openmw/mwrender/shadows.hpp +++ b/apps/openmw/mwrender/shadows.hpp @@ -23,8 +23,6 @@ namespace MWRender void recreate(); Ogre::PSSMShadowCameraSetup* getPSSMSetup(); - float getShadowFar() const; - float getFadeStart() const; protected: OEngine::Render::OgreRenderer* mRendering; diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 229bf92e7..4620173b5 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -188,11 +188,6 @@ void Moon::setPhase(const Moon::Phase& phase) mPhase = phase; } -Moon::Phase Moon::getPhase() const -{ - return mPhase; -} - unsigned int Moon::getPhaseInt() const { if (mPhase == Moon::Phase_New) return 0; @@ -418,7 +413,6 @@ void SkyManager::updateRain(float dt) // Spawn new rain float rainFrequency = mRainFrequency; - float startHeight = 700; if (mRainEnabled) { mRainTimer += dt; @@ -434,6 +428,7 @@ void SkyManager::updateRain(float dt) // Create a separate node to control the offset, since a node with setInheritOrientation(false) will still // consider the orientation of the parent node for its position, just not for its orientation + float startHeight = 700; Ogre::SceneNode* offsetNode = sceneNode->createChildSceneNode(Ogre::Vector3(xOffs,yOffs,startHeight)); NifOgre::ObjectScenePtr objects = NifOgre::Loader::createObjects(offsetNode, mRainEffect); @@ -752,16 +747,6 @@ void SkyManager::setLightningStrength(const float factor) else mLightning->setVisible(false); } -void SkyManager::setLightningEnabled(bool enabled) -{ - /// \todo -} - -void SkyManager::setLightningDirection(const Ogre::Vector3& dir) -{ - if (!mCreated) return; - mLightning->setDirection (dir); -} void SkyManager::setMasserFade(const float fade) { diff --git a/apps/openmw/mwrender/sky.hpp b/apps/openmw/mwrender/sky.hpp index 7c31150f3..e40eb1dce 100644 --- a/apps/openmw/mwrender/sky.hpp +++ b/apps/openmw/mwrender/sky.hpp @@ -103,7 +103,6 @@ namespace MWRender void setPhase(const Phase& phase); void setType(const Type& type); - Phase getPhase() const; unsigned int getPhaseInt() const; private: @@ -169,8 +168,6 @@ namespace MWRender void secundaDisable(); void setLightningStrength(const float factor); - void setLightningDirection(const Ogre::Vector3& dir); - void setLightningEnabled(bool enabled); ///< disable prior to map render void setGlare(const float glare); void setGlareEnabled(bool enabled); diff --git a/apps/openmw/mwrender/videoplayer.cpp b/apps/openmw/mwrender/videoplayer.cpp index ed9ed3f2a..072653898 100644 --- a/apps/openmw/mwrender/videoplayer.cpp +++ b/apps/openmw/mwrender/videoplayer.cpp @@ -864,7 +864,6 @@ void VideoState::video_thread_loop(VideoState *self) AVPacket pkt1, *packet = &pkt1; int frameFinished; AVFrame *pFrame; - double pts; pFrame = av_frame_alloc(); @@ -879,7 +878,7 @@ void VideoState::video_thread_loop(VideoState *self) if(avcodec_decode_video2((*self->video_st)->codec, pFrame, &frameFinished, packet) < 0) throw std::runtime_error("Error decoding video frame"); - pts = 0; + double pts = 0; if(IS_NOTEQ_NOPTS_VAL(packet->dts)) pts = packet->dts; else if(pFrame->opaque && IS_NOTEQ_NOPTS_VAL_PTR(pFrame->opaque)) @@ -1232,11 +1231,6 @@ int VideoPlayer::getVideoHeight() return height; } -void VideoPlayer::stopVideo () -{ - close(); -} - void VideoPlayer::close() { if(mState) diff --git a/apps/openmw/mwrender/videoplayer.hpp b/apps/openmw/mwrender/videoplayer.hpp index 47e252cc1..69b214870 100644 --- a/apps/openmw/mwrender/videoplayer.hpp +++ b/apps/openmw/mwrender/videoplayer.hpp @@ -21,7 +21,6 @@ namespace MWRender void update(); void close(); - void stopVideo(); bool isPlaying(); @@ -32,9 +31,6 @@ namespace MWRender private: VideoState* mState; - - int mWidth; - int mHeight; }; } diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 336e9431b..21fee5f57 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -480,12 +480,6 @@ namespace MWScript mActivationHandled = true; } - void InterpreterContext::clearActivation() - { - mActivated = MWWorld::Ptr(); - mActivationHandled = false; - } - float InterpreterContext::getSecondsPassed() const { return MWBase::Environment::get().getFrameDuration(); diff --git a/apps/openmw/mwscript/interpretercontext.hpp b/apps/openmw/mwscript/interpretercontext.hpp index bc43f3e44..b54339965 100644 --- a/apps/openmw/mwscript/interpretercontext.hpp +++ b/apps/openmw/mwscript/interpretercontext.hpp @@ -146,9 +146,6 @@ namespace MWScript void executeActivation(MWWorld::Ptr ptr, MWWorld::Ptr actor); ///< Execute the activation action for this ptr. If ptr is mActivated, mark activation as handled. - void clearActivation(); - ///< Discard the action defined by the last activate call. - virtual float getSecondsPassed() const; virtual bool isDisabled (const std::string& id = "") const; diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index 5af214268..811080361 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -43,13 +43,12 @@ namespace MWScript mParser.reset(); mErrorHandler.reset(); - bool Success = true; - if (const ESM::Script *script = mStore.get().find (name)) { if (mVerbose) std::cout << "compiling script: " << name << std::endl; + bool Success = true; try { std::istringstream input (script->mScriptText); diff --git a/apps/openmw/mwsound/ffmpeg_decoder.cpp b/apps/openmw/mwsound/ffmpeg_decoder.cpp index 7b6e12576..414e31d70 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.cpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.cpp @@ -83,7 +83,7 @@ bool FFmpeg_Decoder::getNextPacket() bool FFmpeg_Decoder::getAVAudioData() { - int got_frame, len; + int got_frame; if((*mStream)->codec->codec_type != AVMEDIA_TYPE_AUDIO) return false; @@ -93,6 +93,7 @@ bool FFmpeg_Decoder::getAVAudioData() return false; /* Decode some data, and check for errors */ + int len = 0; if((len=avcodec_decode_audio4((*mStream)->codec, mFrame, &got_frame, &mPacket)) < 0) return false; diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index c0654a7f4..ebe08dc44 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -303,10 +303,6 @@ namespace MWWorld { } - void Class::adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const - { - } - std::string Class::getModel(const MWWorld::Ptr &ptr) const { return ""; diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 5d9c0a0ea..8ac39eaa9 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -267,8 +267,6 @@ namespace MWWorld virtual void adjustScale(const MWWorld::Ptr& ptr,float& scale) const; - virtual void adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const; - virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const; ///< Determine whether or not \a item can be sold to an npc with the given \a npcServices diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index d9139a666..f515f1efb 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -73,15 +73,14 @@ MWWorld::InventoryStore::InventoryStore() } MWWorld::InventoryStore::InventoryStore (const InventoryStore& store) -: ContainerStore (store) + : ContainerStore (store) , mSelectedEnchantItem(end()) + , mMagicEffects(store.mMagicEffects) + , mFirstAutoEquip(store.mFirstAutoEquip) + , mListener(store.mListener) + , mUpdatesEnabled(store.mUpdatesEnabled) + , mPermanentMagicEffectMagnitudes(store.mPermanentMagicEffectMagnitudes) { - mMagicEffects = store.mMagicEffects; - mFirstAutoEquip = store.mFirstAutoEquip; - mListener = store.mListener; - mUpdatesEnabled = store.mUpdatesEnabled; - - mPermanentMagicEffectMagnitudes = store.mPermanentMagicEffectMagnitudes; copySlots (store); } @@ -218,8 +217,6 @@ void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor) // Equipping weapons is handled by AiCombat. Anything else (lockpicks, probes) can't be used by NPCs anyway (yet) continue; - bool use = false; - if (slots_.at (*iter2)!=end()) { Ptr old = *slots_.at (*iter2); @@ -227,6 +224,7 @@ void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor) // check skill int oldSkill = old.getClass().getEquipmentSkill (old); + bool use = false; if (testSkill!=-1 && oldSkill==-1) use = true; else if (testSkill!=-1 && oldSkill!=-1 && testSkill!=oldSkill) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 80ad66743..a316f0bb2 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -268,8 +268,6 @@ namespace MWWorld loadingListener->setLabel(loadingExteriorText); CellStoreCollection::iterator active = mActiveCells.begin(); - - active = mActiveCells.begin(); while (active!=mActiveCells.end()) { if ((*active)->getCell()->isExterior()) @@ -414,12 +412,9 @@ namespace MWWorld std::cout << "Changing to interior\n"; - // remove active - CellStoreCollection::iterator active = mActiveCells.begin(); - // unload int current = 0; - active = mActiveCells.begin(); + CellStoreCollection::iterator active = mActiveCells.begin(); while (active!=mActiveCells.end()) { unloadCell (active++); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index ed66ae427..c49f1f483 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1315,7 +1315,7 @@ namespace MWWorld const PtrVelocityList &results = mPhysics->applyQueuedMovement(duration); PtrVelocityList::const_iterator player(results.end()); - for(PtrVelocityList::const_iterator iter(results.begin());iter != results.end();iter++) + for(PtrVelocityList::const_iterator iter(results.begin());iter != results.end();++iter) { if(iter->first.getRefData().getHandle() == "player") { diff --git a/components/compiler/generator.cpp b/components/compiler/generator.cpp index 235b163ad..2efa2477e 100644 --- a/components/compiler/generator.cpp +++ b/components/compiler/generator.cpp @@ -105,11 +105,6 @@ namespace code.push_back (Compiler::Generator::segment5 (17)); } - void opFloatToInt1 (Compiler::Generator::CodeContainer& code) - { - code.push_back (Compiler::Generator::segment5 (18)); - } - void opSquareRoot (Compiler::Generator::CodeContainer& code) { code.push_back (Compiler::Generator::segment5 (19)); @@ -606,16 +601,6 @@ namespace Compiler jump (code, offset); } - void jumpOnNonZero (CodeContainer& code, int offset) - { - opSkipOnZero (code); - - if (offset<0) - --offset; // compensate for skip instruction - - jump (code, offset); - } - void compare (CodeContainer& code, char op, char valueType1, char valueType2) { if (valueType1=='l' && valueType2=='l') diff --git a/components/compiler/generator.hpp b/components/compiler/generator.hpp index 2619033c8..a56d7c1f1 100644 --- a/components/compiler/generator.hpp +++ b/components/compiler/generator.hpp @@ -89,8 +89,6 @@ namespace Compiler void jumpOnZero (CodeContainer& code, int offset); - void jumpOnNonZero (CodeContainer& code, int offset); - void compare (CodeContainer& code, char op, char valueType1, char valueType2); void menuMode (CodeContainer& code); diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index 7d554f2ec..dc19b9a4b 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -57,7 +57,7 @@ namespace Compiler Literals& literals, std::vector& code, bool allowExpression) : Parser (errorHandler, context), mLocals (locals), mLiterals (literals), mCode (code), mState (BeginState), mExprParser (errorHandler, context, locals, literals), - mAllowExpression (allowExpression), mButtons(0), mType(0) + mAllowExpression (allowExpression), mButtons(0), mType(0), mReferenceMember(false) {} bool LineParser::parseInt (int value, const TokenLoc& loc, Scanner& scanner) @@ -295,8 +295,6 @@ namespace Compiler mExplicit.clear(); } - int optionals = 0; - try { // workaround for broken positioncell instructions. @@ -306,7 +304,7 @@ namespace Compiler errorDowngrade.reset (new ErrorDowngrade (getErrorHandler())); std::vector code; - optionals = mExprParser.parseArguments (argumentType, scanner, code); + int optionals = mExprParser.parseArguments (argumentType, scanner, code); mCode.insert (mCode.end(), code.begin(), code.end()); extensions->generateInstructionCode (keyword, mCode, mLiterals, mExplicit, optionals); diff --git a/components/compiler/parser.cpp b/components/compiler/parser.cpp index 781fbad8c..0f442c350 100644 --- a/components/compiler/parser.cpp +++ b/components/compiler/parser.cpp @@ -21,13 +21,6 @@ namespace Compiler throw SourceException(); } - // Report the error - - void Parser::reportError (const std::string& message, const TokenLoc& loc) - { - mErrorHandler.error (message, loc); - } - // Report the warning without throwing an exception. void Parser::reportWarning (const std::string& message, const TokenLoc& loc) diff --git a/components/compiler/parser.hpp b/components/compiler/parser.hpp index 54e913b20..2ef6e85b9 100644 --- a/components/compiler/parser.hpp +++ b/components/compiler/parser.hpp @@ -26,9 +26,6 @@ namespace Compiler void reportSeriousError (const std::string& message, const TokenLoc& loc); ///< Report the error and throw a exception. - void reportError (const std::string& message, const TokenLoc& loc); - ///< Report the error - void reportWarning (const std::string& message, const TokenLoc& loc); ///< Report the warning without throwing an exception. diff --git a/components/contentselector/model/contentmodel.cpp b/components/contentselector/model/contentmodel.cpp index e76930e81..a6e594d2e 100644 --- a/components/contentselector/model/contentmodel.cpp +++ b/components/contentselector/model/contentmodel.cpp @@ -276,7 +276,6 @@ bool ContentSelectorModel::ContentModel::setData(const QModelIndex &index, const case Qt::CheckStateRole: { int checkValue = value.toInt(); - bool success = false; bool setState = false; if ((checkValue==Qt::Checked) && !isChecked(file->filePath())) { diff --git a/components/esm/esmreader.cpp b/components/esm/esmreader.cpp index ebdb1e41f..6facee381 100644 --- a/components/esm/esmreader.cpp +++ b/components/esm/esmreader.cpp @@ -250,14 +250,6 @@ void ESMReader::skipRecord() mCtx.leftRec = 0; } -void ESMReader::skipHRecord() -{ - if (!mCtx.leftFile) - return; - getRecHeader(); - skipRecord(); -} - void ESMReader::getRecHeader(uint32_t &flags) { // General error checking diff --git a/components/esm/esmreader.hpp b/components/esm/esmreader.hpp index 730bdd8c7..1549e15f5 100644 --- a/components/esm/esmreader.hpp +++ b/components/esm/esmreader.hpp @@ -216,9 +216,6 @@ public: // already been read void skipRecord(); - // Skip an entire record, including the header (but not the name) - void skipHRecord(); - /* Read record header. This updatesleftFile BEYOND the data that follows the header, ie beyond the entire record. You should use leftRec to orient yourself inside the record itself. diff --git a/components/esm/esmwriter.cpp b/components/esm/esmwriter.cpp index 06572ce8f..544f8bbed 100644 --- a/components/esm/esmwriter.cpp +++ b/components/esm/esmwriter.cpp @@ -6,7 +6,12 @@ namespace ESM { - ESMWriter::ESMWriter() : mEncoder (0), mRecordCount (0), mCounting (true) {} + ESMWriter::ESMWriter() + : mEncoder (0) + , mRecordCount (0) + , mCounting (true) + , mStream(NULL) + {} unsigned int ESMWriter::getVersion() const { diff --git a/components/esm/loadcell.cpp b/components/esm/loadcell.cpp index 91da936a4..bbd6696f1 100644 --- a/components/esm/loadcell.cpp +++ b/components/esm/loadcell.cpp @@ -113,11 +113,6 @@ void Cell::loadData(ESMReader &esm) esm.getHNT(mData, "DATA", 12); } -void Cell::preLoad(ESMReader &esm) //Can't be "load" because it conflicts with function in esmtool -{ - this->load(esm, false); -} - void Cell::postLoad(ESMReader &esm) { // Save position of the cell references and move on diff --git a/components/esm/loadcell.hpp b/components/esm/loadcell.hpp index f40b3db61..a24b106d4 100644 --- a/components/esm/loadcell.hpp +++ b/components/esm/loadcell.hpp @@ -104,7 +104,6 @@ struct Cell CellRefTracker mLeasedRefs; MovedCellRefTracker mMovedRefs; - void preLoad(ESMReader &esm); void postLoad(ESMReader &esm); // This method is left in for compatibility with esmtool. Parsing moved references currently requires diff --git a/components/esm/loadland.cpp b/components/esm/loadland.cpp index 1b701229e..91b062596 100644 --- a/components/esm/loadland.cpp +++ b/components/esm/loadland.cpp @@ -19,14 +19,14 @@ void Land::LandData::save(ESMWriter &esm) offsets.mUnk1 = mUnk1; offsets.mUnk2 = mUnk2; - float prevY = mHeights[0], prevX; + float prevY = mHeights[0]; int number = 0; // avoid multiplication for (int i = 0; i < LAND_SIZE; ++i) { float diff = (mHeights[number] - prevY) / HEIGHT_SCALE; offsets.mHeightData[number] = (diff >= 0) ? (int8_t) (diff + 0.5) : (int8_t) (diff - 0.5); - prevX = prevY = mHeights[number]; + float prevX = prevY = mHeights[number]; ++number; for (int j = 1; j < LAND_SIZE; ++j) { diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index d53c7d865..2240d65b0 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -18,7 +18,7 @@ NIFFile::NIFFile(const std::string &name) NIFFile::~NIFFile() { - for (std::vector::iterator it = records.begin() ; it != records.end(); it++) + for (std::vector::iterator it = records.begin() ; it != records.end(); ++it) { delete *it; } diff --git a/components/nifogre/material.hpp b/components/nifogre/material.hpp index fc978549e..d485439cf 100644 --- a/components/nifogre/material.hpp +++ b/components/nifogre/material.hpp @@ -29,12 +29,6 @@ class NIFMaterialLoader { std::cerr << "NIFMaterialLoader: Warn: " << msg << std::endl; } - static void fail(const std::string &msg) - { - std::cerr << "NIFMaterialLoader: Fail: "<< msg << std::endl; - abort(); - } - static std::map sMaterialMap; public: diff --git a/components/nifogre/ogrenifloader.cpp b/components/nifogre/ogrenifloader.cpp index 57d3cbe17..dcc34f627 100644 --- a/components/nifogre/ogrenifloader.cpp +++ b/components/nifogre/ogrenifloader.cpp @@ -1048,7 +1048,7 @@ class NIFObjectLoader { std::string::const_iterator last = str.end(); do { - last--; + --last; } while(last != str.begin() && ::isspace(*last)); nextpos = std::distance(str.begin(), ++last); } diff --git a/components/nifogre/particles.cpp b/components/nifogre/particles.cpp index caf82cf42..316e4edc2 100644 --- a/components/nifogre/particles.cpp +++ b/components/nifogre/particles.cpp @@ -130,8 +130,8 @@ public: NifEmitter(Ogre::ParticleSystem *psys) : Ogre::ParticleEmitter(psys) + , mEmitterBones(Ogre::any_cast(psys->getUserObjectBindings().getUserAny()).mBones) { - mEmitterBones = Ogre::any_cast(psys->getUserObjectBindings().getUserAny()).mBones; assert (!mEmitterBones.empty()); Ogre::TagPoint* tag = static_cast(mParent->getParentNode()); mParticleBone = static_cast(tag->getParent()); diff --git a/components/ogreinit/ogreinit.cpp b/components/ogreinit/ogreinit.cpp index 60306459a..40712e282 100644 --- a/components/ogreinit/ogreinit.cpp +++ b/components/ogreinit/ogreinit.cpp @@ -45,7 +45,7 @@ namespace LogListener(const std::string &path) : file((bfs::path(path))) { - memset(buffer, sizeof(buffer), 0); + memset(buffer, 0, sizeof(buffer)); } void timestamp() diff --git a/components/terrain/defaultworld.hpp b/components/terrain/defaultworld.hpp index 8769a0d88..62441c420 100644 --- a/components/terrain/defaultworld.hpp +++ b/components/terrain/defaultworld.hpp @@ -70,9 +70,9 @@ namespace Terrain private: // Called from a background worker thread - Ogre::WorkQueue::Response* handleRequest(const Ogre::WorkQueue::Request* req, const Ogre::WorkQueue* srcQ); + virtual Ogre::WorkQueue::Response* handleRequest(const Ogre::WorkQueue::Request* req, const Ogre::WorkQueue* srcQ); // Called from the main thread - void handleResponse(const Ogre::WorkQueue::Response* res, const Ogre::WorkQueue* srcQ); + virtual void handleResponse(const Ogre::WorkQueue::Response* res, const Ogre::WorkQueue* srcQ); Ogre::uint16 mWorkQueueChannel; bool mVisible; diff --git a/components/terrain/world.cpp b/components/terrain/world.cpp index 49fb9b5c9..93caeb8df 100644 --- a/components/terrain/world.cpp +++ b/components/terrain/world.cpp @@ -15,6 +15,8 @@ World::World(Ogre::SceneManager* sceneMgr, , mShaders(shaders) , mAlign(align) , mCache(storage->getCellVertices()) + , mShadows(false) + , mSplitShadows(false) { } diff --git a/components/translation/translation.cpp b/components/translation/translation.cpp index 5341240af..51947f6f9 100644 --- a/components/translation/translation.cpp +++ b/components/translation/translation.cpp @@ -6,6 +6,11 @@ namespace Translation { + Storage::Storage() + : mEncoder(NULL) + { + } + void Storage::loadTranslationData(const Files::Collections& dataFileCollections, const std::string& esmFileName) { diff --git a/components/translation/translation.hpp b/components/translation/translation.hpp index bca9ea255..6a3f84ba1 100644 --- a/components/translation/translation.hpp +++ b/components/translation/translation.hpp @@ -9,6 +9,7 @@ namespace Translation class Storage { public: + Storage(); void loadTranslationData(const Files::Collections& dataFileCollections, const std::string& esmFileName); diff --git a/components/widgets/list.cpp b/components/widgets/list.cpp index 86db2fdf4..28271e87d 100644 --- a/components/widgets/list.cpp +++ b/components/widgets/list.cpp @@ -113,11 +113,6 @@ namespace Gui Base::setPropertyOverride(_key, _value); } - bool MWList::hasItem(const std::string& name) - { - return (std::find(mItems.begin(), mItems.end(), name) != mItems.end()); - } - unsigned int MWList::getItemCount() { return mItems.size(); diff --git a/components/widgets/list.hpp b/components/widgets/list.hpp index 8b4955a2d..093cd8c18 100644 --- a/components/widgets/list.hpp +++ b/components/widgets/list.hpp @@ -39,7 +39,6 @@ namespace Gui void addItem(const std::string& name); void addSeparator(); ///< add a seperator between the current and the next item. void removeItem(const std::string& name); - bool hasItem(const std::string& name); unsigned int getItemCount(); std::string getItemNameAt(unsigned int at); ///< \attention if there are separators, this method will return "" at the place where the separator is void clear(); diff --git a/extern/oics/CMakeLists.txt b/extern/oics/CMakeLists.txt index 5c1edbf62..52ffb42a2 100644 --- a/extern/oics/CMakeLists.txt +++ b/extern/oics/CMakeLists.txt @@ -9,6 +9,7 @@ set(OICS_SOURCE_FILES ICSInputControlSystem_keyboard.cpp ICSInputControlSystem_mouse.cpp ICSInputControlSystem_joystick.cpp + ICSPrerequisites.h ) set(TINYXML_SOURCE_FILES diff --git a/extern/oics/ICSChannel.cpp b/extern/oics/ICSChannel.cpp index 178fe5aa3..82042d321 100644 --- a/extern/oics/ICSChannel.cpp +++ b/extern/oics/ICSChannel.cpp @@ -58,22 +58,23 @@ namespace ICS return mValue; } - BezierFunction::iterator it = mBezierFunction.begin(); - //size_t size_minus_1 = mBezierFunction.size() - 1; - BezierFunction::iterator last = mBezierFunction.end(); - last--; - for ( ; it != last ; ) - { - BezierPoint left = (*it); - BezierPoint right = (*(++it)); + assert (!mBezierFunction.empty()); + BezierFunction::iterator it = mBezierFunction.begin(); + //size_t size_minus_1 = mBezierFunction.size() - 1; + BezierFunction::iterator last = mBezierFunction.end(); + --last; + for ( ; it != last ; ) + { + BezierPoint left = (*it); + BezierPoint right = (*(++it)); - if( (left.x <= mValue) && (right.x > mValue) ) - { - float val = left.y - (left.x - mValue) * (left.y - right.y) / (left.x - right.x); + if( (left.x <= mValue) && (right.x > mValue) ) + { + float val = left.y - (left.x - mValue) * (left.y - right.y) / (left.x - right.x); - return std::max(0.0,std::min(1.0, val)); - } - } + return std::max(0.0,std::min(1.0, val)); + } + } return -1; } @@ -95,7 +96,7 @@ namespace ICS std::list::iterator pos = mListeners.begin(); while (pos != mListeners.end()) { - ((ChannelListener* )(*pos))->channelChanged((Channel*)this, this->getValue(), previousValue); + (*pos)->channelChanged((Channel*)this, this->getValue(), previousValue); ++pos; } } diff --git a/extern/oics/ICSControl.cpp b/extern/oics/ICSControl.cpp index 934c661c9..7c804d6ee 100644 --- a/extern/oics/ICSControl.cpp +++ b/extern/oics/ICSControl.cpp @@ -86,7 +86,7 @@ namespace ICS std::list::iterator pos = mListeners.begin(); while (pos != mListeners.end()) { - ((ControlListener* )(*pos))->controlChanged((Control*)this, this->getValue(), previousValue); + (*pos)->controlChanged((Control*)this, this->getValue(), previousValue); ++pos; } } @@ -99,13 +99,13 @@ namespace ICS void Control::update(float timeSinceLastFrame) { - if(mPendingActions.size() > 0) + if(!mPendingActions.empty()) { size_t timedActionsCount = 0; std::list::iterator cached_end = mPendingActions.end(); for(std::list::iterator it = mPendingActions.begin() ; - it != cached_end ; it++) + it != cached_end ; ++it) { if( (*it) != Control::STOP ) { @@ -115,7 +115,7 @@ namespace ICS float timeSinceLastFramePart = timeSinceLastFrame / std::max(1, timedActionsCount); for(std::list::iterator it = mPendingActions.begin() ; - it != cached_end ; it++) + it != cached_end ; ++it) { if( (*it) != Control::STOP ) { diff --git a/extern/oics/ICSInputControlSystem.cpp b/extern/oics/ICSInputControlSystem.cpp index e493cdf26..7dc026c7e 100644 --- a/extern/oics/ICSInputControlSystem.cpp +++ b/extern/oics/ICSInputControlSystem.cpp @@ -120,8 +120,6 @@ namespace ICS if(type == "bezier") { - float step = 0.1; - float startX = FromString(xmlInterval->Attribute("startX")); float startY = FromString(xmlInterval->Attribute("startY")); float midX = FromString(xmlInterval->Attribute("midX")); @@ -129,7 +127,7 @@ namespace ICS float endX = FromString(xmlInterval->Attribute("endX")); float endY = FromString(xmlInterval->Attribute("endY")); - step = FromString(xmlInterval->Attribute("step")); + float step = FromString(xmlInterval->Attribute("step")); ICS_LOG("Applying Bezier filter to channel [number=" + ToString(ch) + ", startX=" @@ -334,7 +332,7 @@ namespace ICS TiXmlElement Controller( "Controller" ); - for(std::vector::const_iterator o = mChannels.begin() ; o != mChannels.end(); o++) + for(std::vector::const_iterator o = mChannels.begin() ; o != mChannels.end(); ++o) { ICS::IntervalList intervals = (*o)->getIntervals(); @@ -371,14 +369,14 @@ namespace ICS ChannelFilter.InsertEndChild(XMLInterval); } - interval++; + ++interval; } Controller.InsertEndChild(ChannelFilter); } } - for(std::vector::const_iterator o = mControls.begin() ; o != mControls.end(); o++) + for(std::vector::const_iterator o = mControls.begin() ; o != mControls.end(); ++o) { TiXmlElement control( "Control" ); @@ -687,13 +685,13 @@ namespace ICS control.InsertEndChild(binder); } - it++; + ++it; } std::list channels = (*o)->getAttachedChannels(); for(std::list::iterator it = channels.begin() ; - it != channels.end() ; it++) + it != channels.end() ; ++it) { TiXmlElement binder( "Channel" ); diff --git a/extern/oics/ICSInputControlSystem_joystick.cpp b/extern/oics/ICSInputControlSystem_joystick.cpp index 35762d2b3..8bf931788 100644 --- a/extern/oics/ICSInputControlSystem_joystick.cpp +++ b/extern/oics/ICSInputControlSystem_joystick.cpp @@ -192,7 +192,7 @@ namespace ICS { return it->first; } - it++; + ++it; } } @@ -210,7 +210,7 @@ namespace ICS { return it->first; } - it++; + ++it; } } diff --git a/extern/oics/ICSInputControlSystem_keyboard.cpp b/extern/oics/ICSInputControlSystem_keyboard.cpp index fbfa9af52..af0eec82a 100644 --- a/extern/oics/ICSInputControlSystem_keyboard.cpp +++ b/extern/oics/ICSInputControlSystem_keyboard.cpp @@ -80,7 +80,7 @@ namespace ICS { return it->first; } - it++; + ++it; } return SDL_SCANCODE_UNKNOWN; diff --git a/extern/oics/ICSInputControlSystem_mouse.cpp b/extern/oics/ICSInputControlSystem_mouse.cpp index fb1100528..d1ef721b2 100644 --- a/extern/oics/ICSInputControlSystem_mouse.cpp +++ b/extern/oics/ICSInputControlSystem_mouse.cpp @@ -149,7 +149,7 @@ namespace ICS { return (InputControlSystem::NamedAxis)(it->first); } - it++; + ++it; } return /*NamedAxis::*/UNASSIGNED; @@ -179,7 +179,7 @@ namespace ICS { return it->first; } - it++; + ++it; } return ICS_MAX_DEVICE_BUTTONS; diff --git a/extern/oics/ICSPrerequisites.h b/extern/oics/ICSPrerequisites.h index 6e6cd814b..ed99f4f54 100644 --- a/extern/oics/ICSPrerequisites.h +++ b/extern/oics/ICSPrerequisites.h @@ -77,7 +77,7 @@ namespace ICS { std::stringstream ss(Text); T result; - return ss >> result ? true : false; + return (ss >> result) ? true : false; } // from http://www.cplusplus.com/forum/articles/9645/ @@ -95,7 +95,7 @@ namespace ICS { //character array as argument std::stringstream ss(Text); T result; - return ss >> result ? result : 0; + return (ss >> result) ? result : 0; } class InputControlSystem; diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index 50d82cd37..f2be11386 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -735,10 +735,6 @@ namespace Physic } } - void PhysicEngine::emptyEventLists(void) - { - } - std::pair PhysicEngine::rayTest(const btVector3 &from, const btVector3 &to, bool raycastingObjectOnly, bool ignoreHeightMap, Ogre::Vector3* normal) { std::string name = ""; diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index d882d85bb..e330a7621 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -168,6 +168,9 @@ namespace Physic std::string mMesh; std::string mName; PhysicEngine *mEngine; + + PhysicActor(const PhysicActor&); + PhysicActor& operator=(const PhysicActor&); }; @@ -272,11 +275,6 @@ namespace Physic */ void stepSimulation(double deltaT); - /** - * Empty events lists - */ - void emptyEventLists(void); - /** * Create a debug rendering. It is called by setDebgRenderingMode if it's not created yet. * Important Note: this will crash if the Render is not yet initialise! @@ -352,6 +350,10 @@ namespace Physic BtOgre::DebugDrawer* mDebugDrawer; bool isDebugCreated; bool mDebugActive; + + private: + PhysicEngine(const PhysicEngine&); + PhysicEngine& operator=(const PhysicEngine&); }; diff --git a/libs/openengine/gui/manager.cpp b/libs/openengine/gui/manager.cpp index 8238a25d4..30a5b938c 100644 --- a/libs/openengine/gui/manager.cpp +++ b/libs/openengine/gui/manager.cpp @@ -638,20 +638,6 @@ void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool mGui->initialise(""); } -void MyGUIManager::updateWindow (Ogre::RenderWindow *wnd) -{ - if (mShaderRenderManager) - { - mShaderRenderManager->setRenderWindow (wnd); - mShaderRenderManager->setActiveViewport(0); - } - else - { - mRenderManager->setRenderWindow (wnd); - mRenderManager->setActiveViewport(0); - } -} - void MyGUIManager::windowResized() { #ifndef ANDROID diff --git a/libs/openengine/gui/manager.hpp b/libs/openengine/gui/manager.hpp index 3fb5245f3..28eb6419b 100644 --- a/libs/openengine/gui/manager.hpp +++ b/libs/openengine/gui/manager.hpp @@ -43,8 +43,6 @@ namespace GUI shutdown(); } - void updateWindow (Ogre::RenderWindow* wnd); - void windowResized(); void setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false, const std::string& logDir = std::string("")); diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index fa98433ac..eb33d5876 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -83,11 +83,6 @@ void OgreRenderer::screenshot(const std::string &file, const std::string& imageF } } -float OgreRenderer::getFPS() -{ - return mWindow->getLastFPS(); -} - void OgreRenderer::configure(const std::string &logPath, const std::string& renderSystem, const std::string& rttMode diff --git a/libs/openengine/ogre/renderer.hpp b/libs/openengine/ogre/renderer.hpp index 5dba15b5a..e56f5f816 100644 --- a/libs/openengine/ogre/renderer.hpp +++ b/libs/openengine/ogre/renderer.hpp @@ -110,8 +110,6 @@ namespace OEngine /// Write a screenshot to file void screenshot(const std::string &file, const std::string& imageFormat); - float getFPS(); - void windowResized(int x, int y); /// Get the Root diff --git a/plugins/mygui_resource_plugin/plugin.cpp b/plugins/mygui_resource_plugin/plugin.cpp index ac4c9a3d4..1b718b547 100644 --- a/plugins/mygui_resource_plugin/plugin.cpp +++ b/plugins/mygui_resource_plugin/plugin.cpp @@ -33,7 +33,6 @@ void validate(boost::any &v, std::vector const &tokens, FallbackMap FallbackMap *map = boost::any_cast(&v); - std::map::iterator mapIt; for(std::vector::const_iterator it=tokens.begin(); it != tokens.end(); ++it) { int sep = it->find(","); @@ -47,7 +46,7 @@ void validate(boost::any &v, std::vector const &tokens, FallbackMap std::string key(it->substr(0,sep)); std::string value(it->substr(sep+1)); - if((mapIt = map->mMap.find(key)) == map->mMap.end()) + if(map->mMap.find(key) == map->mMap.end()) { map->mMap.insert(std::make_pair (key,value)); } From 4b8ea25cf0c47f3b906169ff81c96e0996240d1a Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 26 Sep 2014 20:45:45 +0200 Subject: [PATCH 41/58] Add missing case folding for dependency filenames (Fixes #1940) --- components/contentselector/model/contentmodel.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/contentselector/model/contentmodel.cpp b/components/contentselector/model/contentmodel.cpp index a6e594d2e..0d4f2365a 100644 --- a/components/contentselector/model/contentmodel.cpp +++ b/components/contentselector/model/contentmodel.cpp @@ -77,7 +77,7 @@ const ContentSelectorModel::EsmFile *ContentSelectorModel::ContentModel::item(co foreach (const EsmFile *file, mFiles) { - if (name == file->fileProperty (fp).toString()) + if (name.compare(file->fileProperty (fp).toString(), Qt::CaseInsensitive) == 0) return file; } return 0; @@ -120,7 +120,7 @@ Qt::ItemFlags ContentSelectorModel::ContentModel::flags(const QModelIndex &index { //compare filenames only. Multiple instances //of the filename (with different paths) is not relevant here. - depFound = (dependency->fileName() == fileName); + depFound = (dependency->fileName().compare(fileName, Qt::CaseInsensitive) == 0); if (!depFound) continue; @@ -299,7 +299,7 @@ bool ContentSelectorModel::ContentModel::setData(const QModelIndex &index, const foreach (EsmFile *file, mFiles) { - if (file->gameFiles().contains(fileName)) + if (file->gameFiles().contains(fileName, Qt::CaseInsensitive)) { QModelIndex idx = indexFromItem(file); emit dataChanged(idx, idx); @@ -500,7 +500,7 @@ void ContentSelectorModel::ContentModel::sortFiles() //dependencies appear. for (int j = i + 1; j < fileCount; j++) { - if (gamefiles.contains(mFiles.at(j)->fileName())) + if (gamefiles.contains(mFiles.at(j)->fileName(), Qt::CaseInsensitive)) { mFiles.move(j, i); @@ -589,7 +589,7 @@ bool ContentSelectorModel::ContentModel::setCheckState(const QString &filepath, QFileInfo fileInfo(filepath); QString filename = fileInfo.fileName(); - if (downstreamFile->gameFiles().contains(filename)) + if (downstreamFile->gameFiles().contains(filename, Qt::CaseInsensitive)) { if (mCheckStates.contains(downstreamFile->filePath())) mCheckStates[downstreamFile->filePath()] = Qt::Unchecked; From e868a48a638d6e02a9a5c8ac3a1328db473ab6e9 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 26 Sep 2014 22:08:07 +0200 Subject: [PATCH 42/58] Don't trigger OnPcHitMe for friendly hits (Fixes #1950) Don't consider actors as followers if they are also in combat with the follow target --- apps/openmw/mwbase/mechanicsmanager.hpp | 3 ++- apps/openmw/mwclass/creature.cpp | 5 +++-- apps/openmw/mwclass/npc.cpp | 6 ++++-- apps/openmw/mwmechanics/actors.cpp | 6 +++++- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 8 +++++--- apps/openmw/mwmechanics/mechanicsmanagerimp.hpp | 3 ++- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwbase/mechanicsmanager.hpp b/apps/openmw/mwbase/mechanicsmanager.hpp index e99f4ca3c..c75581488 100644 --- a/apps/openmw/mwbase/mechanicsmanager.hpp +++ b/apps/openmw/mwbase/mechanicsmanager.hpp @@ -128,7 +128,8 @@ namespace MWBase OffenseType type, int arg=0) = 0; virtual void reportCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim, OffenseType type, int arg=0) = 0; - virtual void actorAttacked (const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker) = 0; + /// @return false if the attack was considered a "friendly hit" and forgiven + virtual bool actorAttacked (const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker) = 0; /// Utility to check if taking this item is illegal and calling commitCrime if so virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, int count) = 0; /// Utility to check if opening (i.e. unlocking) this object is illegal and calling commitCrime if so diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index f0c95e123..0d88a2e10 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -338,11 +338,12 @@ namespace MWClass getCreatureStats(ptr).setAttacked(true); // Self defense + bool setOnPcHitMe = true; // Note OnPcHitMe is not set for friendly hits. if ((canWalk(ptr) || canFly(ptr) || canSwim(ptr)) // No retaliation for totally static creatures // (they have no movement or attacks anyway) && !attacker.isEmpty()) { - MWBase::Environment::get().getMechanicsManager()->actorAttacked(ptr, attacker); + setOnPcHitMe = MWBase::Environment::get().getMechanicsManager()->actorAttacked(ptr, attacker); } if(!successful) @@ -357,7 +358,7 @@ namespace MWClass if(!object.isEmpty()) getCreatureStats(ptr).setLastHitObject(object.getClass().getId(object)); - if(!attacker.isEmpty() && attacker.getRefData().getHandle() == "player") + if(setOnPcHitMe && !attacker.isEmpty() && attacker.getRefData().getHandle() == "player") { const std::string &script = ptr.get()->mBase->mScript; /* Set the OnPCHitMe script variable. The script is responsible for clearing it. */ diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index cf1b74485..5d5b8a689 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -644,11 +644,13 @@ namespace MWClass bool wasDead = getCreatureStats(ptr).isDead(); + // Note OnPcHitMe is not set for friendly hits. + bool setOnPcHitMe = true; if (!attacker.isEmpty() && !ptr.getClass().getCreatureStats(ptr).getAiSequence().isInCombat(attacker)) { getCreatureStats(ptr).setAttacked(true); - MWBase::Environment::get().getMechanicsManager()->actorAttacked(ptr, attacker); + setOnPcHitMe = MWBase::Environment::get().getMechanicsManager()->actorAttacked(ptr, attacker); } if(!successful) @@ -663,7 +665,7 @@ namespace MWClass if(!object.isEmpty()) getCreatureStats(ptr).setLastHitObject(object.getClass().getId(object)); - if(!attacker.isEmpty() && attacker.getRefData().getHandle() == "player") + if(setOnPcHitMe && !attacker.isEmpty() && attacker.getRefData().getHandle() == "player") { const std::string &script = ptr.getClass().getScript(ptr); /* Set the OnPCHitMe script variable. The script is responsible for clearing it. */ diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index e55ccba17..efca99b4e 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -323,8 +323,9 @@ namespace MWMechanics for (std::list::const_iterator it = followers.begin(); it != followers.end(); ++it) { // need to check both ways since player doesn't use AI packages - if (creatureStats2.getAiSequence().isInCombat(*it) + if ((creatureStats2.getAiSequence().isInCombat(*it) || it->getClass().getCreatureStats(*it).getAiSequence().isInCombat(actor2)) + && !creatureStats.getAiSequence().isInCombat(*it)) aggressive = true; } @@ -337,6 +338,9 @@ namespace MWMechanics if (followTarget.isEmpty()) continue; + if (creatureStats.getAiSequence().isInCombat(followTarget)) + continue; + // need to check both ways since player doesn't use AI packages if (creatureStats2.getAiSequence().isInCombat(followTarget) || followTarget.getClass().getCreatureStats(followTarget).getAiSequence().isInCombat(actor2)) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index f908072e3..6ca4a4336 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -1111,10 +1111,10 @@ namespace MWMechanics } } - void MechanicsManager::actorAttacked(const MWWorld::Ptr &ptr, const MWWorld::Ptr &attacker) + bool MechanicsManager::actorAttacked(const MWWorld::Ptr &ptr, const MWWorld::Ptr &attacker) { if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr()) - return; + return false; std::list followers = getActorsFollowing(attacker); if (std::find(followers.begin(), followers.end(), ptr) != followers.end()) @@ -1124,7 +1124,7 @@ namespace MWMechanics if (ptr.getClass().getCreatureStats(ptr).getFriendlyHits() < 4) { MWBase::Environment::get().getDialogueManager()->say(ptr, "hit"); - return; + return false; } } @@ -1153,6 +1153,8 @@ namespace MWMechanics // Note: accidental or collateral damage attacks are ignored. startCombat(ptr, attacker); } + + return true; } bool MechanicsManager::awarenessCheck(const MWWorld::Ptr &ptr, const MWWorld::Ptr &observer) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp index cc93f7be7..dc5479ecd 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp @@ -120,7 +120,8 @@ namespace MWMechanics OffenseType type, int arg=0); virtual void reportCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim, OffenseType type, int arg=0); - virtual void actorAttacked (const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker); + /// @return false if the attack was considered a "friendly hit" and forgiven + virtual bool actorAttacked (const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker); /// Utility to check if taking this item is illegal and calling commitCrime if so virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, int count); /// Utility to check if opening (i.e. unlocking) this object is illegal and calling commitCrime if so From 810ba6190921572d3ac01cfb5d82bbe4b7fb171d Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 27 Sep 2014 17:46:48 +1000 Subject: [PATCH 43/58] While loading overwrite records with the same id. Should resolve bug #1750. --- apps/opencs/model/world/collection.hpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/apps/opencs/model/world/collection.hpp b/apps/opencs/model/world/collection.hpp index 1fb3e1f1d..387b33cf3 100644 --- a/apps/opencs/model/world/collection.hpp +++ b/apps/opencs/model/world/collection.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include @@ -431,18 +432,27 @@ namespace CSMWorld const Record& record2 = dynamic_cast&> (record); - mRecords.insert (mRecords.begin()+index, record2); + std::pair::iterator, bool> insertResult = + mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (IdAccessorT().getId (record2.get())), + index)); + + if(!insertResult.second) // duplicate index found, replace the current record + { + std::cerr << "Duplicate record found, using new: " + IdAccessorT().getId(record2.get()) << std::endl; + replace(insertResult.first->second, record2); + return; + } + // else update the index except for the record to be inserted if (index (mRecords.size())-1) { - for (std::map::iterator iter (mIndex.begin()); iter!=mIndex.end(); - ++iter) - if (iter->second>=index) + std::string id = IdAccessorT().getId(record2.get()); + for (std::map::iterator iter (mIndex.begin()); iter!=mIndex.end(); ++iter) + if (iter->second > index || (iter->second == index && iter->first != id)) ++(iter->second); } - mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (IdAccessorT().getId ( - record2.get())), index)); + mRecords.insert (mRecords.begin()+index, record2); } template From a2d043f43a31195acd357f937a9cc8d9c5534b26 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 27 Sep 2014 23:36:27 +1000 Subject: [PATCH 44/58] Re-check unknown record id after loading. --- apps/opencs/model/world/idcollection.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/opencs/model/world/idcollection.hpp b/apps/opencs/model/world/idcollection.hpp index 7e7756ff3..940181c24 100644 --- a/apps/opencs/model/world/idcollection.hpp +++ b/apps/opencs/model/world/idcollection.hpp @@ -71,6 +71,14 @@ namespace CSMWorld record.load (reader); + if (index==-1) + { + std::string newId = IdAccessorT().getId(record); + int newIndex = this->searchId(newId); + if (newIndex != -1 && id != newId) + index = newIndex; + } + load (record, base, index); } } From d790b8edfa5d41107fb5f55e3eecf0455679f660 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 27 Sep 2014 23:39:22 +1000 Subject: [PATCH 45/58] Revert old fix. --- apps/opencs/model/world/collection.hpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/apps/opencs/model/world/collection.hpp b/apps/opencs/model/world/collection.hpp index 387b33cf3..1fb3e1f1d 100644 --- a/apps/opencs/model/world/collection.hpp +++ b/apps/opencs/model/world/collection.hpp @@ -7,7 +7,6 @@ #include #include #include -#include #include @@ -432,27 +431,18 @@ namespace CSMWorld const Record& record2 = dynamic_cast&> (record); - std::pair::iterator, bool> insertResult = - mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (IdAccessorT().getId (record2.get())), - index)); - - if(!insertResult.second) // duplicate index found, replace the current record - { - std::cerr << "Duplicate record found, using new: " + IdAccessorT().getId(record2.get()) << std::endl; - replace(insertResult.first->second, record2); - return; - } + mRecords.insert (mRecords.begin()+index, record2); - // else update the index except for the record to be inserted if (index (mRecords.size())-1) { - std::string id = IdAccessorT().getId(record2.get()); - for (std::map::iterator iter (mIndex.begin()); iter!=mIndex.end(); ++iter) - if (iter->second > index || (iter->second == index && iter->first != id)) + for (std::map::iterator iter (mIndex.begin()); iter!=mIndex.end(); + ++iter) + if (iter->second>=index) ++(iter->second); } - mRecords.insert (mRecords.begin()+index, record2); + mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (IdAccessorT().getId ( + record2.get())), index)); } template From ea956b537cc63f369daddcfea848b4ffb948bd81 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 27 Sep 2014 15:19:15 +0200 Subject: [PATCH 46/58] Don't search for fFatigueReturnBase and fFatigueReturnMult every frame --- apps/openmw/mwmechanics/actors.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index efca99b4e..cbc43636c 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -470,13 +470,13 @@ namespace MWMechanics return; MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats (ptr); - const MWWorld::Store& settings = MWBase::Environment::get().getWorld()->getStore().get(); int endurance = stats.getAttribute (ESM::Attribute::Endurance).getModified (); // restore fatigue - float fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat (); - float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat (); + const MWWorld::Store& settings = MWBase::Environment::get().getWorld()->getStore().get(); + static float fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat (); + static float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat (); float x = fFatigueReturnBase + fFatigueReturnMult * endurance; From 02dec787fda62398de31d0c2740ab9fc250f9b48 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 27 Sep 2014 22:44:20 +0200 Subject: [PATCH 47/58] Cache GMSTs in getDerivedDisposition --- .../mwmechanics/mechanicsmanagerimp.cpp | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 6ca4a4336..d5cb23806 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -566,11 +566,14 @@ namespace MWMechanics MWWorld::LiveCellRef* player = playerPtr.get(); const MWMechanics::NpcStats &playerStats = playerPtr.getClass().getNpcStats(playerPtr); + const MWWorld::Store& gmst = MWBase::Environment::get().getWorld()->getStore().get(); + static float fDispRaceMod = gmst.find("fDispRaceMod")->getFloat(); if (Misc::StringUtils::ciEqual(npc->mBase->mRace, player->mBase->mRace)) - x += MWBase::Environment::get().getWorld()->getStore().get().find("fDispRaceMod")->getFloat(); + x += fDispRaceMod; - x += MWBase::Environment::get().getWorld()->getStore().get().find("fDispPersonalityMult")->getFloat() - * (playerStats.getAttribute(ESM::Attribute::Personality).getModified() - MWBase::Environment::get().getWorld()->getStore().get().find("fDispPersonalityBase")->getFloat()); + static float fDispPersonalityMult = gmst.find("fDispPersonalityMult")->getFloat(); + static float fDispPersonalityBase = gmst.find("fDispPersonalityBase")->getFloat(); + x += fDispPersonalityMult * (playerStats.getAttribute(ESM::Attribute::Personality).getModified() - fDispPersonalityBase); float reaction = 0; int rank = 0; @@ -606,16 +609,23 @@ namespace MWMechanics reaction = 0; rank = 0; } - x += (MWBase::Environment::get().getWorld()->getStore().get().find("fDispFactionRankMult")->getFloat() * rank - + MWBase::Environment::get().getWorld()->getStore().get().find("fDispFactionRankBase")->getFloat()) - * MWBase::Environment::get().getWorld()->getStore().get().find("fDispFactionMod")->getFloat() * reaction; - x -= MWBase::Environment::get().getWorld()->getStore().get().find("fDispCrimeMod")->getFloat() * playerStats.getBounty(); + static float fDispFactionRankMult = gmst.find("fDispFactionRankMult")->getFloat(); + static float fDispFactionRankBase = gmst.find("fDispFactionRankBase")->getFloat(); + static float fDispFactionMod = gmst.find("fDispFactionMod")->getFloat(); + x += (fDispFactionRankMult * rank + + fDispFactionRankBase) + * fDispFactionMod * reaction; + + static float fDispCrimeMod = gmst.find("fDispCrimeMod")->getFloat(); + static float fDispDiseaseMod = gmst.find("fDispDiseaseMod")->getFloat(); + x -= fDispCrimeMod * playerStats.getBounty(); if (playerStats.hasCommonDisease() || playerStats.hasBlightDisease()) - x += MWBase::Environment::get().getWorld()->getStore().get().find("fDispDiseaseMod")->getFloat(); + x += fDispDiseaseMod; + static float fDispWeaponDrawn = gmst.find("fDispWeaponDrawn")->getFloat(); if (playerStats.getDrawState() == MWMechanics::DrawState_Weapon) - x += MWBase::Environment::get().getWorld()->getStore().get().find("fDispWeaponDrawn")->getFloat(); + x += fDispWeaponDrawn; x += ptr.getClass().getCreatureStats(ptr).getMagicEffects().get(ESM::MagicEffect::Charm).getMagnitude(); From 58571f7ac2c250ae73674f0225854c2b2f38b9b9 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 28 Sep 2014 12:18:46 +0200 Subject: [PATCH 48/58] Revert "Transfer item ownership to the buyer if item wasn't stolen" Fixes #1953. This reverts commit 5d77c5e8cac1c506f50a9e415dfeb489c0704ddb. --- apps/openmw/mwgui/containeritemmodel.cpp | 2 +- apps/openmw/mwgui/tradeitemmodel.cpp | 8 +++----- apps/openmw/mwgui/tradeitemmodel.hpp | 3 +-- apps/openmw/mwgui/tradewindow.cpp | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwgui/containeritemmodel.cpp b/apps/openmw/mwgui/containeritemmodel.cpp index 520a32ef8..b2befc3ba 100644 --- a/apps/openmw/mwgui/containeritemmodel.cpp +++ b/apps/openmw/mwgui/containeritemmodel.cpp @@ -76,7 +76,7 @@ MWWorld::Ptr ContainerItemModel::copyItem (const ItemStack& item, size_t count, const MWWorld::Ptr& source = mItemSources[mItemSources.size()-1]; if (item.mBase.getContainerStore() == &source.getClass().getContainerStore(source)) throw std::runtime_error("Item to copy needs to be from a different container!"); - return *source.getClass().getContainerStore(source).add(item.mBase, count, source, setNewOwner); + return *source.getClass().getContainerStore(source).add(item.mBase, count, source); } void ContainerItemModel::removeItem (const ItemStack& item, size_t count) diff --git a/apps/openmw/mwgui/tradeitemmodel.cpp b/apps/openmw/mwgui/tradeitemmodel.cpp index e1283c89d..3abfac997 100644 --- a/apps/openmw/mwgui/tradeitemmodel.cpp +++ b/apps/openmw/mwgui/tradeitemmodel.cpp @@ -119,7 +119,7 @@ namespace MWGui return mBorrowedToUs; } - void TradeItemModel::transferItems(const MWWorld::Ptr& transferFrom) + void TradeItemModel::transferItems() { std::vector::iterator it = mBorrowedToUs.begin(); for (; it != mBorrowedToUs.end(); ++it) @@ -135,11 +135,9 @@ namespace MWGui if (i == sourceModel->getItemCount()) throw std::runtime_error("The borrowed item disappeared"); + // reset owner while copying, but only for items bought by the player + bool setNewOwner = (mMerchant.isEmpty()); const ItemStack& item = sourceModel->getItem(i); - - bool setNewOwner = Misc::StringUtils::ciEqual(item.mBase.getCellRef().getOwner(), transferFrom.getCellRef().getRefId()) - || item.mBase.getCellRef().getOwner().empty(); - // copy the borrowed items to our model copyItem(item, it->mCount, setNewOwner); // then remove them from the source model diff --git a/apps/openmw/mwgui/tradeitemmodel.hpp b/apps/openmw/mwgui/tradeitemmodel.hpp index c463bf40b..1bfee9b2a 100644 --- a/apps/openmw/mwgui/tradeitemmodel.hpp +++ b/apps/openmw/mwgui/tradeitemmodel.hpp @@ -30,8 +30,7 @@ namespace MWGui void returnItemBorrowedFromUs (ModelIndex itemIndex, ItemModel* source, size_t count); /// Permanently transfers items that were borrowed to us from another model to this model - /// @param transferFrom the actor that lent us the items - void transferItems (const MWWorld::Ptr& transferFrom); + void transferItems (); /// Aborts trade void abort(); diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 081a1e2c2..a4e5bbc16 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -370,8 +370,8 @@ namespace MWGui MWBase::Environment::get().getDialogueManager()->applyDispositionChange(iBarterSuccessDisposition); // make the item transfer - mTradeModel->transferItems(player); - playerItemModel->transferItems(mPtr); + mTradeModel->transferItems(); + playerItemModel->transferItems(); // transfer the gold if (mCurrentBalance != 0) From e9ed0211c9ef71b63c924c14727bd02a89425290 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 28 Sep 2014 12:44:47 +0200 Subject: [PATCH 49/58] Attempt to fix Clang warnings --- apps/openmw/mwgui/savegamedialog.cpp | 3 ++- apps/openmw/mwgui/windowbase.cpp | 2 ++ apps/openmw/mwmechanics/aiescort.cpp | 6 +++++- apps/openmw/mwmechanics/autocalcspell.cpp | 2 +- apps/openmw/mwmechanics/character.cpp | 2 +- apps/openmw/mwworld/physicssystem.cpp | 2 -- apps/openmw/mwworld/weather.cpp | 3 ++- apps/openmw/mwworld/worldimp.cpp | 2 +- components/esmterrain/storage.cpp | 4 ++-- components/widgets/box.cpp | 26 +++++++++++++++++++---- 10 files changed, 38 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp index 3920a5dcb..66c7a9238 100644 --- a/apps/openmw/mwgui/savegamedialog.cpp +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -322,7 +322,8 @@ namespace MWGui if (i == pos) mCurrentSlot = &*it; } - assert(mCurrentSlot && "Can't find selected slot"); + if (!mCurrentSlot) + throw std::runtime_error("Can't find selected slot"); std::stringstream text; time_t time = mCurrentSlot->mTimeStamp; diff --git a/apps/openmw/mwgui/windowbase.cpp b/apps/openmw/mwgui/windowbase.cpp index 432510a3e..9c12b04ef 100644 --- a/apps/openmw/mwgui/windowbase.cpp +++ b/apps/openmw/mwgui/windowbase.cpp @@ -76,6 +76,8 @@ void WindowModal::close() NoDrop::NoDrop(DragAndDrop *drag, MyGUI::Widget *widget) : mDrag(drag), mWidget(widget), mTransparent(false) { + if (!mWidget) + throw std::runtime_error("NoDrop needs a non-NULL widget!"); } void NoDrop::onFrame(float dt) diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp index 98fc64090..324bef322 100644 --- a/apps/openmw/mwmechanics/aiescort.cpp +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -92,7 +92,11 @@ namespace MWMechanics if(distanceBetweenResult <= mMaxDist * mMaxDist) { - if(pathTo(actor,ESM::Pathgrid::Point(mX,mY,mZ),duration)) //Returns true on path complete + ESM::Pathgrid::Point point(mX,mY,mZ); + point.mAutogenerated = 0; + point.mConnectionNum = 0; + point.mUnknown = 0; + if(pathTo(actor,point,duration)) //Returns true on path complete return true; mMaxDist = 450; } diff --git a/apps/openmw/mwmechanics/autocalcspell.cpp b/apps/openmw/mwmechanics/autocalcspell.cpp index 255decdf7..01447c6e4 100644 --- a/apps/openmw/mwmechanics/autocalcspell.cpp +++ b/apps/openmw/mwmechanics/autocalcspell.cpp @@ -220,7 +220,7 @@ namespace MWMechanics if (spell->mData.mFlags & ESM::Spell::F_Always) return 100.f; - float skillTerm; + float skillTerm = 0; if (effectiveSchool != -1) skillTerm = 2.f * actorSkills[mapSchoolToSkill(effectiveSchool)]; else diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 8f1a8f718..7c7ea0c95 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1611,7 +1611,7 @@ void CharacterController::update(float duration) if(mMovementAnimationControlled && mPtr.getClass().isActor()) world->queueMovement(mPtr, moved); } - else if (mAnimation) + else mAnimation->updateEffects(duration); mSkipAnim = false; diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 31d52e39d..d5267b8cf 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -385,7 +385,6 @@ namespace MWWorld if(tracer.mFraction >= 1.0f) { newPosition = tracer.mEndPos; // ok to move, so set newPosition - remainingTime *= (1.0f-tracer.mFraction); // FIXME: remainingTime is no longer used so don't set it? break; } else @@ -406,7 +405,6 @@ namespace MWWorld // precision can be lost due to any math Bullet does internally). Since we // aren't performing any collision detection, we want to reject the next // position, so that we don't slowly move inside another object. - remainingTime *= (1.0f-tracer.mFraction); // FIXME: remainingTime is no longer used so don't set it? break; } diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 613fd712f..525352e7f 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -498,7 +498,8 @@ void WeatherManager::update(float duration) else if (sound == 1) soundName = &mThunderSoundID1; else if (sound == 2) soundName = &mThunderSoundID2; else if (sound == 3) soundName = &mThunderSoundID3; - MWBase::Environment::get().getSoundManager()->playSound(*soundName, 1.0, 1.0); + if (soundName) + MWBase::Environment::get().getSoundManager()->playSound(*soundName, 1.0, 1.0); mThunderSoundDelay = 1000; } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index c49f1f483..1f3cf01e1 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1045,7 +1045,7 @@ namespace MWWorld CellStore *currCell = ptr.isInCell() ? ptr.getCell() : NULL; // currCell == NULL should only happen for player, during initial startup bool isPlayer = ptr == mPlayer->getPlayer(); - bool haveToMove = isPlayer || mWorldScene->isCellActive(*currCell); + bool haveToMove = isPlayer || (currCell && mWorldScene->isCellActive(*currCell)); if (currCell != newCell) { diff --git a/components/esmterrain/storage.cpp b/components/esmterrain/storage.cpp index 585c1495d..c4152533e 100644 --- a/components/esmterrain/storage.cpp +++ b/components/esmterrain/storage.cpp @@ -147,8 +147,8 @@ namespace ESMTerrain Ogre::Vector3 normal; Ogre::ColourValue color; - float vertY; - float vertX; + float vertY = 0; + float vertX = 0; float vertY_ = 0; // of current cell corner for (int cellY = startY; cellY < startY + std::ceil(size); ++cellY) diff --git a/components/widgets/box.cpp b/components/widgets/box.cpp index e1c148271..0ac2ff7fd 100644 --- a/components/widgets/box.cpp +++ b/components/widgets/box.cpp @@ -197,8 +197,17 @@ namespace Gui MyGUI::IntCoord widgetCoord; widgetCoord.left = curX; widgetCoord.top = mPadding + (getSize().height-mPadding*2 - height) / 2; - int width = sizes[i].second ? sizes[i].first.width + (getSize().width-mPadding*2 - total_width)/h_stretched_count - : sizes[i].first.width; + + int width = 0; + if (sizes[i].second) + { + if (h_stretched_count == 0) + throw std::logic_error("unexpected"); + width = sizes[i].first.width + (getSize().width-mPadding*2 - total_width)/h_stretched_count; + } + else + width = sizes[i].first.width; + widgetCoord.width = width; widgetCoord.height = height; w->setCoord(widgetCoord); @@ -334,8 +343,17 @@ namespace Gui MyGUI::IntCoord widgetCoord; widgetCoord.top = curY; widgetCoord.left = mPadding + (getSize().width-mPadding*2 - width) / 2; - int height = sizes[i].second ? sizes[i].first.height + (getSize().height-mPadding*2 - total_height)/v_stretched_count - : sizes[i].first.height; + + int height = 0; + if (sizes[i].second) + { + if (v_stretched_count == 0) + throw std::logic_error("unexpected"); + height = sizes[i].first.height + (getSize().height-mPadding*2 - total_height)/v_stretched_count; + } + else + height = sizes[i].first.height; + widgetCoord.height = height; widgetCoord.width = width; w->setCoord(widgetCoord); From 7c52d05f8527b075a07c92fd8e77f9aff81a22f0 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 28 Sep 2014 14:00:15 +0200 Subject: [PATCH 50/58] Disable topics list visually when in a choice --- apps/openmw/mwgui/dialogue.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index a3f82e65d..196e7d8c7 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -562,12 +562,11 @@ namespace MWGui MyGUI::Button* byeButton; getWidget(byeButton, "ByeButton"); - if(MWBase::Environment::get().getDialogueManager()->isInChoice() && !mGoodbye) { - byeButton->setEnabled(false); - } - else { - byeButton->setEnabled(true); - } + bool goodbyeEnabled = !MWBase::Environment::get().getDialogueManager()->isInChoice() || mGoodbye; + byeButton->setEnabled(goodbyeEnabled); + + bool topicsEnabled = !MWBase::Environment::get().getDialogueManager()->isInChoice() && !mGoodbye; + mTopicsList->setEnabled(topicsEnabled); } void DialogueWindow::notifyLinkClicked (TypesetBook::InteractiveId link) @@ -657,7 +656,6 @@ namespace MWGui { mLinks.push_back(new Goodbye()); mGoodbye = true; - mTopicsList->setEnabled(false); mEnabled = false; updateHistory(); } From fedfd7129de88edaea4001ac5624a114e92a57d0 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 28 Sep 2014 15:33:36 +0200 Subject: [PATCH 51/58] Add spacing between buttons to TabControl skin --- files/mygui/openmw_button.skin.xml | 30 ++++++++++++++++++++++++++++++ files/mygui/openmw_resources.xml | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/files/mygui/openmw_button.skin.xml b/files/mygui/openmw_button.skin.xml index 9193e3874..73c266818 100644 --- a/files/mygui/openmw_button.skin.xml +++ b/files/mygui/openmw_button.skin.xml @@ -73,6 +73,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/mygui/openmw_resources.xml b/files/mygui/openmw_resources.xml index ad5ac84bb..7d7ba07b6 100644 --- a/files/mygui/openmw_resources.xml +++ b/files/mygui/openmw_resources.xml @@ -33,7 +33,7 @@ - + @@ -46,7 +46,7 @@ - + From ff0b4e0583d7f0d1dd3b64fcfc273b8ea56b24d0 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 28 Sep 2014 17:57:14 +0200 Subject: [PATCH 52/58] Add debug window (F10), displays Bullet's profiler output --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwbase/windowmanager.hpp | 2 + apps/openmw/mwgui/debugwindow.cpp | 116 +++++++++++++++++++++++ apps/openmw/mwgui/debugwindow.hpp | 24 +++++ apps/openmw/mwgui/windowmanagerimp.cpp | 11 +++ apps/openmw/mwgui/windowmanagerimp.hpp | 4 + apps/openmw/mwinput/inputmanagerimp.cpp | 4 + apps/openmw/mwinput/inputmanagerimp.hpp | 2 + files/mygui/CMakeLists.txt | 2 + files/mygui/core.xml | 1 + files/mygui/openmw_debug_window.layout | 16 ++++ files/mygui/openmw_debug_window.skin.xml | 17 ++++ files/mygui/openmw_layers.xml | 1 + 13 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 apps/openmw/mwgui/debugwindow.cpp create mode 100644 apps/openmw/mwgui/debugwindow.hpp create mode 100644 files/mygui/openmw_debug_window.layout create mode 100644 files/mygui/openmw_debug_window.skin.xml diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 2417091f8..e37cd1391 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -40,7 +40,7 @@ add_openmw_dir (mwgui merchantrepair repair soulgemdialog companionwindow bookpage journalviewmodel journalbooks keywordsearch itemmodel containeritemmodel inventoryitemmodel sortfilteritemmodel itemview tradeitemmodel companionitemmodel pickpocketitemmodel controllers savegamedialog - recharge mode videowidget backgroundimage itemwidget screenfader + recharge mode videowidget backgroundimage itemwidget screenfader debugwindow ) add_openmw_dir (mwdialogue diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index e8286bdd1..bce3f516e 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -337,6 +337,8 @@ namespace MWBase virtual void fadeScreenTo(const int percent, const float time) = 0; /// Darken the screen by \a factor (1.0 = no darkening). Works independently from screen fading. virtual void setScreenFactor (float factor) = 0; + + virtual void toggleDebugWindow() = 0; }; } diff --git a/apps/openmw/mwgui/debugwindow.cpp b/apps/openmw/mwgui/debugwindow.cpp new file mode 100644 index 000000000..fab386bda --- /dev/null +++ b/apps/openmw/mwgui/debugwindow.cpp @@ -0,0 +1,116 @@ +#include "debugwindow.hpp" + + +#include + +namespace +{ + void bulletDumpRecursive(CProfileIterator* pit, int spacing, std::stringstream& os) + { + pit->First(); + if (pit->Is_Done()) + return; + + float accumulated_time=0,parent_time = pit->Is_Root() ? CProfileManager::Get_Time_Since_Reset() : pit->Get_Current_Parent_Total_Time(); + int i,j; + int frames_since_reset = CProfileManager::Get_Frame_Count_Since_Reset(); + for (i=0;iGet_Current_Parent_Name())+" (total running time: "+MyGUI::utility::toString(parent_time,3)+" ms) ---\n"; + os << s; + //float totalTime = 0.f; + + int numChildren = 0; + + for (i = 0; !pit->Is_Done(); i++,pit->Next()) + { + numChildren++; + float current_total_time = pit->Get_Current_Total_Time(); + accumulated_time += current_total_time; + float fraction = parent_time > SIMD_EPSILON ? (current_total_time / parent_time) * 100 : 0.f; + + for (j=0;jGet_Current_Name()+" ("+MyGUI::utility::toString(fraction,2)+" %) :: "+MyGUI::utility::toString(ms,3)+" ms / frame ("+MyGUI::utility::toString(pit->Get_Current_Total_Calls())+" calls)\n"; + os << s; + //totalTime += current_total_time; + //recurse into children + } + + if (parent_time < accumulated_time) + { + os << "what's wrong\n"; + } + for (i=0;i SIMD_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f; + s = "Unaccounted: ("+MyGUI::utility::toString(unaccounted,3)+" %) :: "+MyGUI::utility::toString(parent_time - accumulated_time,3)+" ms\n"; + os << s; + + for (i=0;iEnter_Child(i); + bulletDumpRecursive(pit, spacing+3, os); + pit->Enter_Parent(); + } + } + + void bulletDumpAll(std::stringstream& os) + { + CProfileIterator* profileIterator = 0; + profileIterator = CProfileManager::Get_Iterator(); + + bulletDumpRecursive(profileIterator, 0, os); + + CProfileManager::Release_Iterator(profileIterator); + } +} + + +namespace MWGui +{ + + DebugWindow::DebugWindow() + : WindowBase("openmw_debug_window.layout") + { + getWidget(mTabControl, "TabControl"); + + // Ideas for other tabs: + // - Texture / compositor texture viewer + // - Log viewer + // - Material editor + // - Shader editor + + MyGUI::TabItem* item = mTabControl->addItem("Physics Profiler"); + mBulletProfilerEdit = item->createWidgetReal + ("LogEdit", MyGUI::FloatCoord(0,0,1,1), MyGUI::Align::Stretch); + + MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize(); + mMainWidget->setSize(viewSize); + } + + void DebugWindow::onFrame(float dt) + { + if (!isVisible()) + return; + + static float timer = 0; + timer -= dt; + + if (timer > 0) + return; + timer = 1; + + std::stringstream stream; + bulletDumpAll(stream); + + if (mBulletProfilerEdit->isTextSelection()) // pause updating while user is trying to copy text + return; + + size_t previousPos = mBulletProfilerEdit->getVScrollPosition(); + mBulletProfilerEdit->setCaption(stream.str()); + mBulletProfilerEdit->setVScrollPosition(std::min(previousPos, mBulletProfilerEdit->getVScrollRange()-1)); + } + +} diff --git a/apps/openmw/mwgui/debugwindow.hpp b/apps/openmw/mwgui/debugwindow.hpp new file mode 100644 index 000000000..af5b914ea --- /dev/null +++ b/apps/openmw/mwgui/debugwindow.hpp @@ -0,0 +1,24 @@ +#ifndef OPENMW_MWGUI_DEBUGWINDOW_H +#define OPENMW_MWGUI_DEBUGWINDOW_H + +#include "windowbase.hpp" + +namespace MWGui +{ + + class DebugWindow : public WindowBase + { + public: + DebugWindow(); + + void onFrame(float dt); + + private: + MyGUI::TabControl* mTabControl; + + MyGUI::EditBox* mBulletProfilerEdit; + }; + +} + +#endif diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index fabdf4dae..70f4b5a2f 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -72,6 +72,7 @@ #include "backgroundimage.hpp" #include "itemwidget.hpp" #include "screenfader.hpp" +#include "debugwindow.hpp" namespace MWGui { @@ -120,6 +121,7 @@ namespace MWGui , mVideoBackground(NULL) , mVideoWidget(NULL) , mScreenFader(NULL) + , mDebugWindow(NULL) , mTranslationDataStorage (translationDataStorage) , mCharGen(NULL) , mInputBlocker(NULL) @@ -266,6 +268,7 @@ namespace MWGui mCompanionWindow = new CompanionWindow(mDragAndDrop, mMessageBoxManager); trackWindow(mCompanionWindow, "companion"); mScreenFader = new ScreenFader(); + mDebugWindow = new DebugWindow(); mInputBlocker = MyGUI::Gui::getInstance().createWidget("",0,0,w,h,MyGUI::Align::Stretch,"Overlay"); @@ -357,6 +360,7 @@ namespace MWGui delete mRecharge; delete mCompanionWindow; delete mScreenFader; + delete mDebugWindow; cleanupGarbage(); @@ -859,6 +863,8 @@ namespace MWGui mCompanionWindow->onFrame(); mScreenFader->update(frameDuration); + + mDebugWindow->onFrame(frameDuration); } void WindowManager::changeCell(MWWorld::CellStore* cell) @@ -1749,4 +1755,9 @@ namespace MWGui SDL_free(text); } + void WindowManager::toggleDebugWindow() + { + mDebugWindow->setVisible(!mDebugWindow->isVisible()); + } + } diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index e7853b84f..29d40c2e7 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -89,6 +89,7 @@ namespace MWGui class VideoWidget; class WindowModal; class ScreenFader; + class DebugWindow; class WindowManager : public MWBase::WindowManager { @@ -333,6 +334,8 @@ namespace MWGui /// Darken the screen by \a factor (1.0 = no darkening). Works independently from screen fading. virtual void setScreenFactor (float factor); + virtual void toggleDebugWindow(); + private: bool mConsoleOnlyScripts; @@ -386,6 +389,7 @@ namespace MWGui MyGUI::ImageBox* mVideoBackground; VideoWidget* mVideoWidget; ScreenFader* mScreenFader; + DebugWindow* mDebugWindow; Translation::Storage& mTranslationDataStorage; Cursor* mSoftwareCursor; diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 86b01cdc4..3cd30819c 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -279,6 +279,9 @@ namespace MWInput case A_ToggleHUD: MWBase::Environment::get().getWindowManager()->toggleGui(); break; + case A_ToggleDebug: + MWBase::Environment::get().getWindowManager()->toggleDebugWindow(); + break; case A_QuickSave: quickSave(); break; @@ -902,6 +905,7 @@ namespace MWInput defaultKeyBindings[A_QuickKey10] = SDL_SCANCODE_0; defaultKeyBindings[A_Screenshot] = SDL_SCANCODE_F12; defaultKeyBindings[A_ToggleHUD] = SDL_SCANCODE_F11; + defaultKeyBindings[A_ToggleDebug] = SDL_SCANCODE_F10; defaultKeyBindings[A_AlwaysRun] = SDL_SCANCODE_CAPSLOCK; defaultKeyBindings[A_QuickSave] = SDL_SCANCODE_F5; defaultKeyBindings[A_QuickLoad] = SDL_SCANCODE_F9; diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp index a94b61c8b..346e02ff9 100644 --- a/apps/openmw/mwinput/inputmanagerimp.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -259,6 +259,8 @@ namespace MWInput A_ToggleHUD, + A_ToggleDebug, + A_Last // Marker for the last item }; }; diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index 87e750cc9..651adf403 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -83,6 +83,8 @@ set(MYGUI_FILES openmw_recharge_dialog.layout openmw_screen_fader.layout openmw_edit_note.layout + openmw_debug_window.layout + openmw_debug_window.skin.xml DejaVuLGCSansMono.ttf ../launcher/images/openmw.png OpenMWResourcePlugin.xml diff --git a/files/mygui/core.xml b/files/mygui/core.xml index ea1627875..133109375 100644 --- a/files/mygui/core.xml +++ b/files/mygui/core.xml @@ -22,6 +22,7 @@ + diff --git a/files/mygui/openmw_debug_window.layout b/files/mygui/openmw_debug_window.layout new file mode 100644 index 000000000..9af646c6e --- /dev/null +++ b/files/mygui/openmw_debug_window.layout @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/files/mygui/openmw_debug_window.skin.xml b/files/mygui/openmw_debug_window.skin.xml new file mode 100644 index 000000000..587101b7f --- /dev/null +++ b/files/mygui/openmw_debug_window.skin.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/files/mygui/openmw_layers.xml b/files/mygui/openmw_layers.xml index 1df4841af..38a98d133 100644 --- a/files/mygui/openmw_layers.xml +++ b/files/mygui/openmw_layers.xml @@ -6,6 +6,7 @@ + From bdab3fa3216a5c4ee5385c7131604bfd40fb143a Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 28 Sep 2014 18:02:57 +0200 Subject: [PATCH 53/58] Bullet optimization: Don't update AABBs of static objects every frame --- apps/openmw/mwworld/physicssystem.cpp | 18 +++++++++++++++--- libs/openengine/bullet/physic.cpp | 7 +++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index d5267b8cf..97ea7ca91 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -40,7 +40,7 @@ using namespace Ogre; namespace { -void animateCollisionShapes (std::map& map) +void animateCollisionShapes (std::map& map, btDynamicsWorld* dynamicsWorld) { for (std::map::iterator it = map.begin(); it != map.end(); ++it) @@ -79,6 +79,9 @@ void animateCollisionShapes (std::mapgetChildShape(shapeIt->second)->setLocalScaling(BtOgre::Convert::toBullet(bone->_getDerivedScale())); compound->updateChildTransform(shapeIt->second, trans); } + + // needed because we used btDynamicsWorld::setForceUpdateAllAabbs(false) + dynamicsWorld->updateSingleAabb(it->first); } } @@ -670,11 +673,18 @@ namespace MWWorld const Ogre::Vector3 &position = node->getPosition(); if(OEngine::Physic::RigidBody *body = mEngine->getRigidBody(handle)) + { body->getWorldTransform().setOrigin(btVector3(position.x,position.y,position.z)); + mEngine->mDynamicsWorld->updateSingleAabb(body); + } if(OEngine::Physic::RigidBody *body = mEngine->getRigidBody(handle, true)) + { body->getWorldTransform().setOrigin(btVector3(position.x,position.y,position.z)); + mEngine->mDynamicsWorld->updateSingleAabb(body); + } + // Actors update their AABBs every frame (DISABLE_DEACTIVATION), so no need to do it manually if(OEngine::Physic::PhysicActor *physact = mEngine->getCharacter(handle)) physact->setPosition(position); } @@ -696,6 +706,7 @@ namespace MWWorld body->getWorldTransform().setRotation(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w)); else mEngine->boxAdjustExternal(handleToMesh[handle], body, node->getScale().x, node->getPosition(), rotation); + mEngine->mDynamicsWorld->updateSingleAabb(body); } if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle, true)) { @@ -703,6 +714,7 @@ namespace MWWorld body->getWorldTransform().setRotation(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w)); else mEngine->boxAdjustExternal(handleToMesh[handle], body, node->getScale().x, node->getPosition(), rotation); + mEngine->mDynamicsWorld->updateSingleAabb(body); } } @@ -864,8 +876,8 @@ namespace MWWorld void PhysicsSystem::stepSimulation(float dt) { - animateCollisionShapes(mEngine->mAnimatedShapes); - animateCollisionShapes(mEngine->mAnimatedRaycastingShapes); + animateCollisionShapes(mEngine->mAnimatedShapes, mEngine->mDynamicsWorld); + animateCollisionShapes(mEngine->mAnimatedRaycastingShapes, mEngine->mDynamicsWorld); mEngine->stepSimulation(dt); } diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index f2be11386..d3aa714f1 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -97,6 +97,8 @@ namespace Physic (0,0, mShape.get()); mBody = new RigidBody(CI, name); mBody->mPlaceable = false; + mBody->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT); + mBody->setActivationState(DISABLE_DEACTIVATION); setPosition(position); setRotation(rotation); @@ -233,6 +235,11 @@ namespace Physic // The world. mDynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration); + + // Don't update AABBs of all objects every frame. Most objects in MW are static, so we don't need this. + // Should a "static" object ever be moved, we have to update its AABB manually using DynamicsWorld::updateSingleAabb. + mDynamicsWorld->setForceUpdateAllAabbs(false); + mDynamicsWorld->setGravity(btVector3(0,0,-10)); if(BulletShapeManager::getSingletonPtr() == NULL) From 358257ca6b0e02d0e7f4c5b80da7d1f7b7edb36a Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 28 Sep 2014 18:11:19 +0200 Subject: [PATCH 54/58] Rename some skin files to .skin.xml for consistency --- files/mygui/CMakeLists.txt | 10 +++++----- files/mygui/core.xml | 10 +++++----- ...window_skin.xml => openmw_dialogue_window.skin.xml} | 0 ...openmw_journal_skin.xml => openmw_journal.skin.xml} | 0 ...enmw_mainmenu_skin.xml => openmw_mainmenu.skin.xml} | 0 ..._map_window_skin.xml => openmw_map_window.skin.xml} | 0 .../{openmw_scroll_skin.xml => openmw_scroll.skin.xml} | 0 7 files changed, 10 insertions(+), 10 deletions(-) rename files/mygui/{openmw_dialogue_window_skin.xml => openmw_dialogue_window.skin.xml} (100%) rename files/mygui/{openmw_journal_skin.xml => openmw_journal.skin.xml} (100%) rename files/mygui/{openmw_mainmenu_skin.xml => openmw_mainmenu.skin.xml} (100%) rename files/mygui/{openmw_map_window_skin.xml => openmw_map_window.skin.xml} (100%) rename files/mygui/{openmw_scroll_skin.xml => openmw_scroll.skin.xml} (100%) diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index 651adf403..0099f9a46 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -28,7 +28,7 @@ set(MYGUI_FILES openmw_container_window.layout openmw_count_window.layout openmw_dialogue_window.layout - openmw_dialogue_window_skin.xml + openmw_dialogue_window.skin.xml openmw_edit.skin.xml openmw_font.xml openmw_hud_box.skin.xml @@ -38,19 +38,19 @@ set(MYGUI_FILES openmw_interactive_messagebox.layout openmw_inventory_window.layout openmw_journal.layout - openmw_journal_skin.xml + openmw_journal.skin.xml openmw_layers.xml openmw_list.skin.xml openmw_mainmenu.layout - openmw_mainmenu_skin.xml + openmw_mainmenu.skin.xml openmw_map_window.layout - openmw_map_window_skin.xml + openmw_map_window.skin.xml openmw_messagebox.layout openmw_pointer.xml openmw_progress.skin.xml openmw_resources.xml openmw_scroll.layout - openmw_scroll_skin.xml + openmw_scroll.skin.xml openmw_settings_window.layout openmw_settings.xml openmw_spell_window.layout diff --git a/files/mygui/core.xml b/files/mygui/core.xml index 133109375..f3b482d50 100644 --- a/files/mygui/core.xml +++ b/files/mygui/core.xml @@ -15,12 +15,12 @@ - + - - - - + + + + diff --git a/files/mygui/openmw_dialogue_window_skin.xml b/files/mygui/openmw_dialogue_window.skin.xml similarity index 100% rename from files/mygui/openmw_dialogue_window_skin.xml rename to files/mygui/openmw_dialogue_window.skin.xml diff --git a/files/mygui/openmw_journal_skin.xml b/files/mygui/openmw_journal.skin.xml similarity index 100% rename from files/mygui/openmw_journal_skin.xml rename to files/mygui/openmw_journal.skin.xml diff --git a/files/mygui/openmw_mainmenu_skin.xml b/files/mygui/openmw_mainmenu.skin.xml similarity index 100% rename from files/mygui/openmw_mainmenu_skin.xml rename to files/mygui/openmw_mainmenu.skin.xml diff --git a/files/mygui/openmw_map_window_skin.xml b/files/mygui/openmw_map_window.skin.xml similarity index 100% rename from files/mygui/openmw_map_window_skin.xml rename to files/mygui/openmw_map_window.skin.xml diff --git a/files/mygui/openmw_scroll_skin.xml b/files/mygui/openmw_scroll.skin.xml similarity index 100% rename from files/mygui/openmw_scroll_skin.xml rename to files/mygui/openmw_scroll.skin.xml From 7f18f85a1d51c122e919f69d36110d0d838b957f Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 29 Sep 2014 12:04:19 +0200 Subject: [PATCH 55/58] Forgot const --- apps/openmw/mwmechanics/actors.cpp | 4 ++-- .../openmw/mwmechanics/mechanicsmanagerimp.cpp | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index cbc43636c..a5063594a 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -475,8 +475,8 @@ namespace MWMechanics // restore fatigue const MWWorld::Store& settings = MWBase::Environment::get().getWorld()->getStore().get(); - static float fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat (); - static float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat (); + static const float fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat (); + static const float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat (); float x = fFatigueReturnBase + fFatigueReturnMult * endurance; diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index d5cb23806..ef03d285c 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -567,12 +567,12 @@ namespace MWMechanics const MWMechanics::NpcStats &playerStats = playerPtr.getClass().getNpcStats(playerPtr); const MWWorld::Store& gmst = MWBase::Environment::get().getWorld()->getStore().get(); - static float fDispRaceMod = gmst.find("fDispRaceMod")->getFloat(); + static const float fDispRaceMod = gmst.find("fDispRaceMod")->getFloat(); if (Misc::StringUtils::ciEqual(npc->mBase->mRace, player->mBase->mRace)) x += fDispRaceMod; - static float fDispPersonalityMult = gmst.find("fDispPersonalityMult")->getFloat(); - static float fDispPersonalityBase = gmst.find("fDispPersonalityBase")->getFloat(); + static const float fDispPersonalityMult = gmst.find("fDispPersonalityMult")->getFloat(); + static const float fDispPersonalityBase = gmst.find("fDispPersonalityBase")->getFloat(); x += fDispPersonalityMult * (playerStats.getAttribute(ESM::Attribute::Personality).getModified() - fDispPersonalityBase); float reaction = 0; @@ -610,20 +610,20 @@ namespace MWMechanics rank = 0; } - static float fDispFactionRankMult = gmst.find("fDispFactionRankMult")->getFloat(); - static float fDispFactionRankBase = gmst.find("fDispFactionRankBase")->getFloat(); - static float fDispFactionMod = gmst.find("fDispFactionMod")->getFloat(); + static const float fDispFactionRankMult = gmst.find("fDispFactionRankMult")->getFloat(); + static const float fDispFactionRankBase = gmst.find("fDispFactionRankBase")->getFloat(); + static const float fDispFactionMod = gmst.find("fDispFactionMod")->getFloat(); x += (fDispFactionRankMult * rank + fDispFactionRankBase) * fDispFactionMod * reaction; - static float fDispCrimeMod = gmst.find("fDispCrimeMod")->getFloat(); - static float fDispDiseaseMod = gmst.find("fDispDiseaseMod")->getFloat(); + static const float fDispCrimeMod = gmst.find("fDispCrimeMod")->getFloat(); + static const float fDispDiseaseMod = gmst.find("fDispDiseaseMod")->getFloat(); x -= fDispCrimeMod * playerStats.getBounty(); if (playerStats.hasCommonDisease() || playerStats.hasBlightDisease()) x += fDispDiseaseMod; - static float fDispWeaponDrawn = gmst.find("fDispWeaponDrawn")->getFloat(); + static const float fDispWeaponDrawn = gmst.find("fDispWeaponDrawn")->getFloat(); if (playerStats.getDrawState() == MWMechanics::DrawState_Weapon) x += fDispWeaponDrawn; From b345c50a86531d9c8b93899ef0716cf780aa7168 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 29 Sep 2014 14:55:31 +0200 Subject: [PATCH 56/58] Run stepSimulation before moving actors Shouldn't make too much of a difference, but a nice side effect is seeing the convexSweepTest calls for actor movements in the profiler results. --- apps/openmw/mwworld/worldimp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 1f3cf01e1..dd766eed1 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1309,6 +1309,8 @@ namespace MWWorld void World::doPhysics(float duration) { + mPhysics->stepSimulation(duration); + processDoors(duration); mProjectileManager->update(duration); @@ -1327,8 +1329,6 @@ namespace MWWorld } if(player != results.end()) moveObjectImp(player->first, player->second.x, player->second.y, player->second.z); - - mPhysics->stepSimulation(duration); } bool World::castRay (float x1, float y1, float z1, float x2, float y2, float z2) From 3e153d0a9b8ce88e4d74ef54ab46aee631ee5749 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 29 Sep 2014 22:30:21 +0200 Subject: [PATCH 57/58] Optimize actor physics: Use only one convexSweepTest for stepping down and checking onGround status, instead of 2 --- apps/openmw/mwworld/physicssystem.cpp | 36 +++++++++++---------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 97ea7ca91..7ca3c10cf 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -286,8 +286,9 @@ namespace MWWorld */ OEngine::Physic::ActorTracer tracer; - bool wasOnGround = false; - bool isOnGround = false; + bool isOnGround = physicActor->getOnGround(); + if (movement.z > 0.f) + isOnGround = false; Ogre::Vector3 inertia(0.0f); Ogre::Vector3 velocity; @@ -320,23 +321,6 @@ namespace MWWorld velocity = newVelocity; } inertia = velocity; // NOTE: velocity is for z axis only in this code block - - if(!(movement.z > 0.0f)) // falling or moving horizontally (or stationary?) check if we're on ground now - { - wasOnGround = physicActor->getOnGround(); // store current state - tracer.doTrace(colobj, position, position - Ogre::Vector3(0,0,2), engine); // check if down 2 possible - if(tracer.mFraction < 1.0f && getSlope(tracer.mPlaneNormal) <= sMaxSlope) - { - const btCollisionObject* standingOn = tracer.mHitObject; - if (const OEngine::Physic::RigidBody* body = dynamic_cast(standingOn)) - { - standingCollisionTracker[ptr.getRefData().getHandle()] = body->mName; - } - isOnGround = true; - // if we're on the ground, don't try to fall any more - velocity.z = std::max(0.0f, velocity.z); - } - } } ptr.getClass().getMovementSettings(ptr).mPosition[2] = 0; @@ -439,12 +423,22 @@ namespace MWWorld } } - if(isOnGround || wasOnGround) + if (!(inertia.z > 0.f) && !(newPosition.z < waterlevel || isFlying)) { - tracer.doTrace(colobj, newPosition, newPosition - Ogre::Vector3(0,0,sStepSize+2.0f), engine); + Ogre::Vector3 from = newPosition; + Ogre::Vector3 to = newPosition - (isOnGround ? + Ogre::Vector3(0,0,sStepSize+2.f) : Ogre::Vector3(0,0,2.f)); + tracer.doTrace(colobj, from, to, engine); if(tracer.mFraction < 1.0f && getSlope(tracer.mPlaneNormal) <= sMaxSlope) { + const btCollisionObject* standingOn = tracer.mHitObject; + if (const OEngine::Physic::RigidBody* body = dynamic_cast(standingOn)) + { + standingCollisionTracker[ptr.getRefData().getHandle()] = body->mName; + } + newPosition.z = tracer.mEndPos.z + 1.0f; + isOnGround = true; } else From 850a40d4e2fa963e53cf4bface73a702f236084b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 30 Sep 2014 13:15:15 +0200 Subject: [PATCH 58/58] fixed resources table drag source problem --- apps/opencs/model/world/resourcesmanager.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/opencs/model/world/resourcesmanager.cpp b/apps/opencs/model/world/resourcesmanager.cpp index ec6746521..50014f4b5 100644 --- a/apps/opencs/model/world/resourcesmanager.cpp +++ b/apps/opencs/model/world/resourcesmanager.cpp @@ -6,18 +6,20 @@ void CSMWorld::ResourcesManager::addResources (const Resources& resources) { mResources.insert (std::make_pair (resources.getType(), resources)); + mResources.insert (std::make_pair (UniversalId::getParentType (resources.getType()), + resources)); } void CSMWorld::ResourcesManager::listResources() { static const char * const sMeshTypes[] = { "nif", 0 }; - addResources (Resources ("meshes", UniversalId::Type_Meshes, sMeshTypes)); - addResources (Resources ("icons", UniversalId::Type_Icons)); - addResources (Resources ("music", UniversalId::Type_Musics)); - addResources (Resources ("sound", UniversalId::Type_SoundsRes)); - addResources (Resources ("textures", UniversalId::Type_Textures)); - addResources (Resources ("videos", UniversalId::Type_Videos)); + addResources (Resources ("meshes", UniversalId::Type_Mesh, sMeshTypes)); + addResources (Resources ("icons", UniversalId::Type_Icon)); + addResources (Resources ("music", UniversalId::Type_Music)); + addResources (Resources ("sound", UniversalId::Type_SoundRes)); + addResources (Resources ("textures", UniversalId::Type_Texture)); + addResources (Resources ("videos", UniversalId::Type_Video)); } const CSMWorld::Resources& CSMWorld::ResourcesManager::get (UniversalId::Type type) const