From 630241c8e2c95c6c0ab01ea681e3cb6c796653ca Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 17 May 2012 13:12:38 +0200 Subject: [PATCH] load the AIDT (AI data) for creatures in the ESM loader, which also contains the Services enum. --- apps/openmw/mwgui/dialogue.cpp | 2 ++ apps/openmw/mwgui/list.cpp | 7 ------- apps/openmw/mwgui/list.hpp | 2 +- components/esm/loadcrea.cpp | 12 +++++++++--- components/esm/loadcrea.hpp | 12 ++++++++++++ 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 45163017a..1116eb272 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -145,6 +145,7 @@ void DialogueWindow::setKeywords(std::list keyWords) { topicsList->addItem(*it); } + topicsList->adjustSize(); } void DialogueWindow::removeKeyword(std::string keyWord) @@ -154,6 +155,7 @@ void DialogueWindow::removeKeyword(std::string keyWord) topicsList->removeItem(keyWord); pTopicsText.erase(keyWord); } + topicsList->adjustSize(); } void addColorInString(std::string& str, const std::string& keyword,std::string color1, std::string color2) diff --git a/apps/openmw/mwgui/list.cpp b/apps/openmw/mwgui/list.cpp index d66cc6f89..33f5a6fd1 100644 --- a/apps/openmw/mwgui/list.cpp +++ b/apps/openmw/mwgui/list.cpp @@ -28,8 +28,6 @@ void MWList::initialiseOverride() void MWList::addItem(const std::string& name) { mItems.push_back(name); - - redraw(); } void MWList::adjustSize() @@ -67,7 +65,6 @@ void MWList::redraw(bool scrollbarShown) mItemHeight += height + spacing; } mScrollView->setCanvasSize(mClient->getSize().width + (_scrollBarWidth-scrollBarWidth), std::max(mItemHeight, mClient->getSize().height)); - mScrollView->setViewOffset(MyGUI::IntPoint(0,0)); if (!scrollbarShown && mItemHeight > mClient->getSize().height) redraw(true); @@ -93,15 +90,11 @@ 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) ); - - redraw(); } void MWList::clear() { mItems.clear(); - - redraw(); } void MWList::onMouseWheel(MyGUI::Widget* _sender, int _rel) diff --git a/apps/openmw/mwgui/list.hpp b/apps/openmw/mwgui/list.hpp index a2e9afcd1..76ca5257f 100644 --- a/apps/openmw/mwgui/list.hpp +++ b/apps/openmw/mwgui/list.hpp @@ -26,7 +26,7 @@ namespace MWGui EventHandle_String eventItemSelected; /** - * Call after the size of the list changed + * Call after the size of the list changed, or items were inserted/removed */ void adjustSize(); diff --git a/components/esm/loadcrea.cpp b/components/esm/loadcrea.cpp index 651d9a318..8af3526a0 100644 --- a/components/esm/loadcrea.cpp +++ b/components/esm/loadcrea.cpp @@ -19,9 +19,15 @@ void Creature::load(ESMReader &esm, const std::string& id) inventory.load(esm); - // More subrecords: + if (esm.isNextSub("AIDT")) + { + esm.getHExact(&AI, sizeof(AI)); + hasAI = true; + } + else + hasAI = false; - // AIDT - data (12 bytes, unknown) + // More subrecords: // AI_W - wander (14 bytes, i don't understand it) // short distance // byte duration @@ -33,8 +39,8 @@ void Creature::load(ESMReader &esm, const std::string& id) // AI_F - follow? // AI_E - escort? // AI_A - activate? - esm.skipRecord(); + } } diff --git a/components/esm/loadcrea.hpp b/components/esm/loadcrea.hpp index 3c334ebbd..c3c5b181e 100644 --- a/components/esm/loadcrea.hpp +++ b/components/esm/loadcrea.hpp @@ -51,6 +51,15 @@ struct Creature int gold; }; // 96 bytes + struct AIDTstruct + { + // These are probabilities + char hello, u1, fight, flee, alarm, u2, u3, u4; + // The last u's might be the skills that this NPC can train you + // in? + int services; // See the NPC::Services enum + }; // 12 bytes + NPDTstruct data; int flags; @@ -61,6 +70,9 @@ struct Creature // Defined in loadcont.hpp InventoryList inventory; + bool hasAI; + AIDTstruct AI; + std::string mId; void load(ESMReader &esm, const std::string& id);