mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 07:06:46 +00:00
Merge branch 'master' into inventoryGUI
This commit is contained in:
commit
e9a1ef4269
11 changed files with 138 additions and 14 deletions
|
@ -883,4 +883,11 @@ namespace MWDialogue
|
||||||
}
|
}
|
||||||
return factionID;
|
return factionID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DialogueManager::goodbye()
|
||||||
|
{
|
||||||
|
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
|
||||||
|
|
||||||
|
win->goodbye();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,8 @@ namespace MWDialogue
|
||||||
|
|
||||||
void askQuestion(std::string question,int choice);
|
void askQuestion(std::string question,int choice);
|
||||||
|
|
||||||
|
void goodbye();
|
||||||
|
|
||||||
///get the faction of the actor you are talking with
|
///get the faction of the actor you are talking with
|
||||||
std::string getFaction();
|
std::string getFaction();
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ std::string::size_type find_str_ci(const std::string& str, const std::string& su
|
||||||
|
|
||||||
DialogueWindow::DialogueWindow(WindowManager& parWindowManager)
|
DialogueWindow::DialogueWindow(WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_dialogue_window_layout.xml", parWindowManager)
|
: WindowBase("openmw_dialogue_window_layout.xml", parWindowManager)
|
||||||
|
, mEnabled(true)
|
||||||
{
|
{
|
||||||
// Centre dialog
|
// Centre dialog
|
||||||
center();
|
center();
|
||||||
|
@ -64,6 +65,7 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager)
|
||||||
MyGUI::ButtonPtr byeButton;
|
MyGUI::ButtonPtr byeButton;
|
||||||
getWidget(byeButton, "ByeButton");
|
getWidget(byeButton, "ByeButton");
|
||||||
byeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onByeClicked);
|
byeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onByeClicked);
|
||||||
|
byeButton->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGoodbye")->str);
|
||||||
|
|
||||||
getWidget(pDispositionBar, "Disposition");
|
getWidget(pDispositionBar, "Disposition");
|
||||||
getWidget(pDispositionText,"DispositionText");
|
getWidget(pDispositionText,"DispositionText");
|
||||||
|
@ -81,6 +83,10 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender)
|
||||||
|
|
||||||
size_t cursorPosition = t->getCursorPosition(lastPressed);
|
size_t cursorPosition = t->getCursorPosition(lastPressed);
|
||||||
MyGUI::UString color = history->getColorAtPos(cursorPosition);
|
MyGUI::UString color = history->getColorAtPos(cursorPosition);
|
||||||
|
|
||||||
|
if (!mEnabled && color == "#572D21")
|
||||||
|
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
|
||||||
|
|
||||||
if(color != "#B29154")
|
if(color != "#B29154")
|
||||||
{
|
{
|
||||||
UString key = history->getColorTextAt(cursorPosition);
|
UString key = history->getColorTextAt(cursorPosition);
|
||||||
|
@ -119,11 +125,15 @@ void DialogueWindow::onByeClicked(MyGUI::Widget* _sender)
|
||||||
|
|
||||||
void DialogueWindow::onSelectTopic(std::string topic)
|
void DialogueWindow::onSelectTopic(std::string topic)
|
||||||
{
|
{
|
||||||
|
if (!mEnabled) return;
|
||||||
|
|
||||||
MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(topic));
|
MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(topic));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueWindow::startDialogue(std::string npcName)
|
void DialogueWindow::startDialogue(std::string npcName)
|
||||||
{
|
{
|
||||||
|
mEnabled = true;
|
||||||
|
topicsList->setEnabled(true);
|
||||||
static_cast<MyGUI::Window*>(mMainWidget)->setCaption(npcName);
|
static_cast<MyGUI::Window*>(mMainWidget)->setCaption(npcName);
|
||||||
adjustWindowCaption();
|
adjustWindowCaption();
|
||||||
}
|
}
|
||||||
|
@ -224,3 +234,10 @@ void DialogueWindow::updateOptions()
|
||||||
pDispositionText->eraseText(0,pDispositionText->getTextLength());
|
pDispositionText->eraseText(0,pDispositionText->getTextLength());
|
||||||
pDispositionText->addText("#B29154"+std::string("40/100")+"#B29154");
|
pDispositionText->addText("#B29154"+std::string("40/100")+"#B29154");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DialogueWindow::goodbye()
|
||||||
|
{
|
||||||
|
history->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGoodbye")->str);
|
||||||
|
topicsList->setEnabled(false);
|
||||||
|
mEnabled = false;
|
||||||
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace MWGui
|
||||||
void addText(std::string text);
|
void addText(std::string text);
|
||||||
void addTitle(std::string text);
|
void addTitle(std::string text);
|
||||||
void askQuestion(std::string question);
|
void askQuestion(std::string question);
|
||||||
|
void goodbye();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onSelectTopic(std::string topic);
|
void onSelectTopic(std::string topic);
|
||||||
|
@ -60,6 +61,8 @@ namespace MWGui
|
||||||
*/
|
*/
|
||||||
std::string parseText(std::string text);
|
std::string parseText(std::string text);
|
||||||
|
|
||||||
|
bool mEnabled;
|
||||||
|
|
||||||
DialogueHistory* history;
|
DialogueHistory* history;
|
||||||
Widgets::MWList* topicsList;
|
Widgets::MWList* topicsList;
|
||||||
MyGUI::ProgressPtr pDispositionBar;
|
MyGUI::ProgressPtr pDispositionBar;
|
||||||
|
|
|
@ -115,6 +115,16 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class OpGoodbye : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute(Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getDialogueManager()->goodbye();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const int opcodeJournal = 0x2000133;
|
const int opcodeJournal = 0x2000133;
|
||||||
const int opcodeSetJournalIndex = 0x2000134;
|
const int opcodeSetJournalIndex = 0x2000134;
|
||||||
const int opcodeGetJournalIndex = 0x2000135;
|
const int opcodeGetJournalIndex = 0x2000135;
|
||||||
|
@ -122,6 +132,7 @@ namespace MWScript
|
||||||
const int opcodeChoice = 0x2000a;
|
const int opcodeChoice = 0x2000a;
|
||||||
const int opcodeForceGreeting = 0x200014f;
|
const int opcodeForceGreeting = 0x200014f;
|
||||||
const int opcodeForceGreetingExplicit = 0x2000150;
|
const int opcodeForceGreetingExplicit = 0x2000150;
|
||||||
|
const int opcodeGoodbye = 0x2000152;
|
||||||
|
|
||||||
void registerExtensions (Compiler::Extensions& extensions)
|
void registerExtensions (Compiler::Extensions& extensions)
|
||||||
{
|
{
|
||||||
|
@ -133,6 +144,7 @@ namespace MWScript
|
||||||
extensions.registerInstruction("forcegreeting","",opcodeForceGreeting);
|
extensions.registerInstruction("forcegreeting","",opcodeForceGreeting);
|
||||||
extensions.registerInstruction("forcegreeting","",opcodeForceGreeting,
|
extensions.registerInstruction("forcegreeting","",opcodeForceGreeting,
|
||||||
opcodeForceGreetingExplicit);
|
opcodeForceGreetingExplicit);
|
||||||
|
extensions.registerInstruction("goodbye", "", opcodeGoodbye);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
|
@ -144,6 +156,7 @@ namespace MWScript
|
||||||
interpreter.installSegment3 (opcodeChoice,new OpChoice);
|
interpreter.installSegment3 (opcodeChoice,new OpChoice);
|
||||||
interpreter.installSegment5 (opcodeForceGreeting, new OpForceGreeting<ImplicitRef>);
|
interpreter.installSegment5 (opcodeForceGreeting, new OpForceGreeting<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeForceGreetingExplicit, new OpForceGreeting<ExplicitRef>);
|
interpreter.installSegment5 (opcodeForceGreetingExplicit, new OpForceGreeting<ExplicitRef>);
|
||||||
|
interpreter.installSegment5 (opcodeGoodbye, new OpGoodbye);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,4 +145,5 @@ op 0x200014e: ModDisposition, explicit reference
|
||||||
op 0x200014f: ForceGreeting
|
op 0x200014f: ForceGreeting
|
||||||
op 0x2000150: ForceGreeting, explicit reference
|
op 0x2000150: ForceGreeting, explicit reference
|
||||||
op 0x2000151: ToggleFullHelp
|
op 0x2000151: ToggleFullHelp
|
||||||
opcodes 0x2000152-0x3ffffff unused
|
op 0x2000152: Goodbye
|
||||||
|
opcodes 0x2000153-0x3ffffff unused
|
||||||
|
|
|
@ -45,18 +45,27 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::end()
|
||||||
return ContainerStoreIterator (this);
|
return ContainerStoreIterator (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MWWorld::ContainerStore::stacks(const Ptr& ptr1, const Ptr& ptr2) const
|
||||||
|
{
|
||||||
|
/// \todo add current weapon/armor health, remaining lockpick/repair uses, current enchantment charge here as soon as they are implemented
|
||||||
|
if ( ptr1.mCellRef->refID == ptr2.mCellRef->refID
|
||||||
|
&& MWWorld::Class::get(ptr1).getScript(ptr1) == "" // item with a script never stacks
|
||||||
|
&& ptr1.mCellRef->owner == ptr2.mCellRef->owner
|
||||||
|
&& ptr1.mCellRef->soul == ptr2.mCellRef->soul
|
||||||
|
&& ptr1.mCellRef->charge == ptr2.mCellRef->charge)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void MWWorld::ContainerStore::add (const Ptr& ptr)
|
void MWWorld::ContainerStore::add (const Ptr& ptr)
|
||||||
{
|
{
|
||||||
int type = getType(ptr);
|
int type = getType(ptr);
|
||||||
|
|
||||||
// determine whether to stack or not
|
// determine whether to stack or not
|
||||||
// item stacking depends on owner, script, enchantment and name
|
|
||||||
for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter)
|
for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter)
|
||||||
{
|
{
|
||||||
if ( iter->mCellRef->refID == ptr.mCellRef->refID
|
if (stacks(*iter, ptr))
|
||||||
&& MWWorld::Class::get(*iter).getScript(*iter) == MWWorld::Class::get(ptr).getScript(ptr)
|
|
||||||
&& MWWorld::Class::get(*iter).getEnchantment(*iter) == MWWorld::Class::get(ptr).getEnchantment(ptr)
|
|
||||||
&& iter->mCellRef->owner == ptr.mCellRef->owner)
|
|
||||||
{
|
{
|
||||||
// stack
|
// stack
|
||||||
iter->getRefData().setCount( iter->getRefData().getCount() + ptr.getRefData().getCount() );
|
iter->getRefData().setCount( iter->getRefData().getCount() + ptr.getRefData().getCount() );
|
||||||
|
@ -66,7 +75,13 @@ void MWWorld::ContainerStore::add (const Ptr& ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type)
|
// if we got here, this means no stacking
|
||||||
|
addImpl(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MWWorld::ContainerStore::addImpl (const Ptr& ptr)
|
||||||
|
{
|
||||||
|
switch (getType(ptr))
|
||||||
{
|
{
|
||||||
case Type_Potion: potions.list.push_back (*ptr.get<ESM::Potion>()); break;
|
case Type_Potion: potions.list.push_back (*ptr.get<ESM::Potion>()); break;
|
||||||
case Type_Apparatus: appas.list.push_back (*ptr.get<ESM::Apparatus>()); break;
|
case Type_Apparatus: appas.list.push_back (*ptr.get<ESM::Apparatus>()); break;
|
||||||
|
|
|
@ -67,13 +67,23 @@ namespace MWWorld
|
||||||
ContainerStoreIterator end();
|
ContainerStoreIterator end();
|
||||||
|
|
||||||
void add (const Ptr& ptr);
|
void add (const Ptr& ptr);
|
||||||
///< Add the item pointed to by \a ptr to this container.
|
///< Add the item pointed to by \a ptr to this container. (Stacks automatically if needed)
|
||||||
///
|
///
|
||||||
/// \note The item pointed to is not required to exist beyond this function call.
|
/// \note The item pointed to is not required to exist beyond this function call.
|
||||||
///
|
///
|
||||||
/// \attention Do not add items to an existing stack by increasing the count instead of
|
/// \attention Do not add items to an existing stack by increasing the count instead of
|
||||||
/// calling this function!
|
/// calling this function!
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void addImpl (const Ptr& ptr);
|
||||||
|
///< Add the item to this container (no stacking)
|
||||||
|
|
||||||
|
virtual bool stacks (const Ptr& ptr1, const Ptr& ptr2) const;
|
||||||
|
///< @return true if the two specified objects can stack with each other
|
||||||
|
/// @note ptr1 is the item that is already in this container
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
void fill (const ESM::InventoryList& items, const ESMS::ESMStore& store);
|
void fill (const ESM::InventoryList& items, const ESMS::ESMStore& store);
|
||||||
///< Insert items into *this.
|
///< Insert items into *this.
|
||||||
|
|
||||||
|
|
|
@ -59,17 +59,38 @@ void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& ite
|
||||||
if (iterator.getContainerStore()!=this)
|
if (iterator.getContainerStore()!=this)
|
||||||
throw std::runtime_error ("attempt to equip an item that is not in the inventory");
|
throw std::runtime_error ("attempt to equip an item that is not in the inventory");
|
||||||
|
|
||||||
|
std::pair<std::vector<int>, bool> slots;
|
||||||
if (iterator!=end())
|
if (iterator!=end())
|
||||||
{
|
{
|
||||||
std::pair<std::vector<int>, bool> slots = Class::get (*iterator).getEquipmentSlots (*iterator);
|
slots = Class::get (*iterator).getEquipmentSlots (*iterator);
|
||||||
|
|
||||||
if (std::find (slots.first.begin(), slots.first.end(), slot)==slots.first.end())
|
if (std::find (slots.first.begin(), slots.first.end(), slot)==slots.first.end())
|
||||||
throw std::runtime_error ("invalid slot");
|
throw std::runtime_error ("invalid slot");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \todo restack item previously in this slot (if required)
|
// restack item previously in this slot (if required)
|
||||||
|
if (mSlots[slot] != end())
|
||||||
|
{
|
||||||
|
for (MWWorld::ContainerStoreIterator iter (begin()); iter!=end(); ++iter)
|
||||||
|
{
|
||||||
|
if (stacks(*iter, *mSlots[slot]))
|
||||||
|
{
|
||||||
|
iter->getRefData().setCount( iter->getRefData().getCount() + mSlots[slot]->getRefData().getCount() );
|
||||||
|
mSlots[slot]->getRefData().setCount(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// \todo unstack item pointed to by iterator if required)
|
// unstack item pointed to by iterator if required
|
||||||
|
if (iterator!=end() && !slots.second && iterator->getRefData().getCount() > 1) // if slots.second is true, item can stay stacked when equipped
|
||||||
|
{
|
||||||
|
// add the item again with a count of count-1, then set the count of the original (that will be equipped) to 1
|
||||||
|
int count = iterator->getRefData().getCount();
|
||||||
|
iterator->getRefData().setCount(count-1);
|
||||||
|
addImpl(*iterator);
|
||||||
|
iterator->getRefData().setCount(1);
|
||||||
|
}
|
||||||
|
|
||||||
mSlots[slot] = iterator;
|
mSlots[slot] = iterator;
|
||||||
|
|
||||||
|
@ -147,7 +168,18 @@ void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \todo unstack, if reqquired (itemsSlots.second)
|
if (!itemsSlots.second) // if itemsSlots.second is true, item can stay stacked when equipped
|
||||||
|
{
|
||||||
|
// unstack item pointed to by iterator if required
|
||||||
|
if (iter->getRefData().getCount() > 1)
|
||||||
|
{
|
||||||
|
// add the item again with a count of count-1, then set the count of the original (that will be equipped) to 1
|
||||||
|
int count = iter->getRefData().getCount();
|
||||||
|
iter->getRefData().setCount(count-1);
|
||||||
|
addImpl(*iter);
|
||||||
|
iter->getRefData().setCount(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
slots[*iter2] = iter;
|
slots[*iter2] = iter;
|
||||||
break;
|
break;
|
||||||
|
@ -168,3 +200,20 @@ void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats)
|
||||||
flagAsModified();
|
flagAsModified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MWWorld::InventoryStore::stacks(const Ptr& ptr1, const Ptr& ptr2) const
|
||||||
|
{
|
||||||
|
bool canStack = MWWorld::ContainerStore::stacks(ptr1, ptr2);
|
||||||
|
if (!canStack)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// don't stack if the item being checked against is currently equipped.
|
||||||
|
for (TSlots::const_iterator iter (mSlots.begin());
|
||||||
|
iter!=mSlots.end(); ++iter)
|
||||||
|
{
|
||||||
|
if (ptr1 == **iter)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -64,6 +64,13 @@ namespace MWWorld
|
||||||
|
|
||||||
void autoEquip (const MWMechanics::NpcStats& stats);
|
void autoEquip (const MWMechanics::NpcStats& stats);
|
||||||
///< Auto equip items according to stats and item value.
|
///< Auto equip items according to stats and item value.
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual bool stacks (const Ptr& ptr1, const Ptr& ptr2) const;
|
||||||
|
///< @return true if the two specified objects can stack with each other
|
||||||
|
/// @note ptr1 is the item that is already in this container
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,10 @@ ConfigurationManager::ConfigurationManager()
|
||||||
{
|
{
|
||||||
setupTokensMapping();
|
setupTokensMapping();
|
||||||
|
|
||||||
mPluginsCfgPath = mFixedPath.getGlobalPath() / pluginsCfgFile;
|
mPluginsCfgPath = mFixedPath.getLocalPath() / pluginsCfgFile;
|
||||||
if (!boost::filesystem::is_regular_file(mPluginsCfgPath))
|
if (!boost::filesystem::is_regular_file(mPluginsCfgPath))
|
||||||
{
|
{
|
||||||
mPluginsCfgPath = mFixedPath.getLocalPath() / pluginsCfgFile;
|
mPluginsCfgPath = mFixedPath.getGlobalPath() / pluginsCfgFile;
|
||||||
if (!boost::filesystem::is_regular_file(mPluginsCfgPath))
|
if (!boost::filesystem::is_regular_file(mPluginsCfgPath))
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to find " << pluginsCfgFile << " file!" << std::endl;
|
std::cerr << "Failed to find " << pluginsCfgFile << " file!" << std::endl;
|
||||||
|
|
Loading…
Reference in a new issue