forked from mirror/openmw-tes3mp
Fix topics that have the same name as a service opening that service when clicked
This commit is contained in:
parent
fbaad8e105
commit
a51b73b609
4 changed files with 57 additions and 44 deletions
|
@ -223,10 +223,21 @@ void DialogueWindow::onByeClicked(MyGUI::Widget* _sender)
|
||||||
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
|
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueWindow::onSelectTopic(std::string topic)
|
void DialogueWindow::onSelectTopic(const std::string& topic, int id)
|
||||||
{
|
{
|
||||||
if (!mEnabled) return;
|
if (!mEnabled) return;
|
||||||
|
|
||||||
|
int separatorPos = mTopicsList->getItemCount();
|
||||||
|
for (unsigned int i=0; i<mTopicsList->getItemCount(); ++i)
|
||||||
|
{
|
||||||
|
if (mTopicsList->getItemNameAt(i) == "")
|
||||||
|
separatorPos = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id > separatorPos)
|
||||||
|
MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(topic));
|
||||||
|
else
|
||||||
|
{
|
||||||
const MWWorld::Store<ESM::GameSetting> &gmst =
|
const MWWorld::Store<ESM::GameSetting> &gmst =
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||||
|
|
||||||
|
@ -265,8 +276,7 @@ void DialogueWindow::onSelectTopic(std::string topic)
|
||||||
mWindowManager.pushGuiMode(GM_Training);
|
mWindowManager.pushGuiMode(GM_Training);
|
||||||
mWindowManager.startTraining (mPtr);
|
mWindowManager.startTraining (mPtr);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(topic));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueWindow::startDialogue(MWWorld::Ptr actor, std::string npcName)
|
void DialogueWindow::startDialogue(MWWorld::Ptr actor, std::string npcName)
|
||||||
|
|
|
@ -85,7 +85,7 @@ namespace MWGui
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onSelectTopic(std::string topic);
|
void onSelectTopic(const std::string& topic, int id);
|
||||||
void onByeClicked(MyGUI::Widget* _sender);
|
void onByeClicked(MyGUI::Widget* _sender);
|
||||||
void onHistoryClicked(MyGUI::Widget* _sender);
|
void onHistoryClicked(MyGUI::Widget* _sender);
|
||||||
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
|
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
|
||||||
|
|
|
@ -56,6 +56,7 @@ void MWList::redraw(bool scrollbarShown)
|
||||||
}
|
}
|
||||||
|
|
||||||
mItemHeight = 0;
|
mItemHeight = 0;
|
||||||
|
int i=0;
|
||||||
for (std::vector<std::string>::const_iterator it=mItems.begin();
|
for (std::vector<std::string>::const_iterator it=mItems.begin();
|
||||||
it!=mItems.end(); ++it)
|
it!=mItems.end(); ++it)
|
||||||
{
|
{
|
||||||
|
@ -72,6 +73,7 @@ void MWList::redraw(bool scrollbarShown)
|
||||||
|
|
||||||
int height = button->getTextSize().height;
|
int height = button->getTextSize().height;
|
||||||
button->setSize(MyGUI::IntSize(button->getSize().width, height));
|
button->setSize(MyGUI::IntSize(button->getSize().width, height));
|
||||||
|
button->setUserData(i);
|
||||||
|
|
||||||
mItemHeight += height + spacing;
|
mItemHeight += height + spacing;
|
||||||
}
|
}
|
||||||
|
@ -84,6 +86,7 @@ void MWList::redraw(bool scrollbarShown)
|
||||||
|
|
||||||
mItemHeight += 18 + spacing;
|
mItemHeight += 18 + spacing;
|
||||||
}
|
}
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
mScrollView->setCanvasSize(mClient->getSize().width + (_scrollBarWidth-scrollBarWidth), std::max(mItemHeight, mClient->getSize().height));
|
mScrollView->setCanvasSize(mClient->getSize().width + (_scrollBarWidth-scrollBarWidth), std::max(mItemHeight, mClient->getSize().height));
|
||||||
|
|
||||||
|
@ -135,8 +138,8 @@ void MWList::onMouseWheel(MyGUI::Widget* _sender, int _rel)
|
||||||
void MWList::onItemSelected(MyGUI::Widget* _sender)
|
void MWList::onItemSelected(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
std::string name = static_cast<MyGUI::Button*>(_sender)->getCaption();
|
std::string name = static_cast<MyGUI::Button*>(_sender)->getCaption();
|
||||||
|
int id = *_sender->getUserData<int>();
|
||||||
eventItemSelected(name);
|
eventItemSelected(name, id);
|
||||||
eventWidgetSelected(_sender);
|
eventWidgetSelected(_sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,14 +30,14 @@ namespace MWGui
|
||||||
public:
|
public:
|
||||||
MWList();
|
MWList();
|
||||||
|
|
||||||
typedef MyGUI::delegates::CMultiDelegate1<std::string> EventHandle_String;
|
typedef MyGUI::delegates::CMultiDelegate2<const std::string&, int> EventHandle_StringInt;
|
||||||
typedef MyGUI::delegates::CMultiDelegate1<MyGUI::Widget*> EventHandle_Widget;
|
typedef MyGUI::delegates::CMultiDelegate1<MyGUI::Widget*> EventHandle_Widget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event: Item selected with the mouse.
|
* Event: Item selected with the mouse.
|
||||||
* signature: void method(std::string itemName)
|
* signature: void method(std::string itemName)
|
||||||
*/
|
*/
|
||||||
EventHandle_String eventItemSelected;
|
EventHandle_StringInt eventItemSelected;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event: Item selected with the mouse.
|
* Event: Item selected with the mouse.
|
||||||
|
|
Loading…
Reference in a new issue