forked from mirror/openmw-tes3mp
some unfinished work on quick keys window
parent
f7d537cb28
commit
fab4cfecb1
@ -0,0 +1,39 @@
|
||||
#include "itemselection.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
ItemSelectionDialog::ItemSelectionDialog(const std::string &label, ContainerBase::Filter filter, MWBase::WindowManager& parWindowManager)
|
||||
: ContainerBase(NULL)
|
||||
, WindowModal("openmw_itemselection_dialog.layout", parWindowManager)
|
||||
{
|
||||
mFilter = filter;
|
||||
|
||||
MyGUI::ScrollView* itemView;
|
||||
MyGUI::Widget* containerWidget;
|
||||
getWidget(containerWidget, "Items");
|
||||
getWidget(itemView, "ItemView");
|
||||
setWidgets(containerWidget, itemView);
|
||||
|
||||
MyGUI::TextBox* l;
|
||||
getWidget(l, "Label");
|
||||
l->setCaptionWithReplacing (label);
|
||||
|
||||
MyGUI::Button* cancelButton;
|
||||
getWidget(cancelButton, "CancelButton");
|
||||
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemSelectionDialog::onCancelButtonClicked);
|
||||
|
||||
center();
|
||||
}
|
||||
|
||||
void ItemSelectionDialog::onSelectedItemImpl(MWWorld::Ptr item)
|
||||
{
|
||||
eventItemSelected(item);
|
||||
}
|
||||
|
||||
void ItemSelectionDialog::onCancelButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
eventDialogCanceled();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
#include "container.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
class ItemSelectionDialog : public ContainerBase, public WindowModal
|
||||
{
|
||||
public:
|
||||
ItemSelectionDialog(const std::string& label, ContainerBase::Filter filter, MWBase::WindowManager& parWindowManager);
|
||||
|
||||
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||
typedef MyGUI::delegates::CMultiDelegate1<MWWorld::Ptr> EventHandle_Item;
|
||||
|
||||
EventHandle_Item eventItemSelected;
|
||||
EventHandle_Void eventDialogCanceled;
|
||||
|
||||
|
||||
private:
|
||||
virtual void onReferenceUnavailable() { ; }
|
||||
|
||||
virtual void onSelectedItemImpl(MWWorld::Ptr item);
|
||||
|
||||
void onCancelButtonClicked(MyGUI::Widget* sender);
|
||||
};
|
||||
|
||||
}
|
@ -0,0 +1,237 @@
|
||||
#include "quickkeysmenu.hpp"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
|
||||
#include "windowmanagerimp.hpp"
|
||||
#include "itemselection.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
QuickKeysMenu::QuickKeysMenu(MWBase::WindowManager& parWindowManager)
|
||||
: WindowBase("openmw_quickkeys_menu.layout", parWindowManager)
|
||||
, mAssignDialog(0)
|
||||
, mItemSelectionDialog(0)
|
||||
, mMagicSelectionDialog(0)
|
||||
{
|
||||
getWidget(mOkButton, "OKButton");
|
||||
getWidget(mInstructionLabel, "InstructionLabel");
|
||||
|
||||
mMainWidget->setSize(mMainWidget->getWidth(),
|
||||
mMainWidget->getHeight() + (mInstructionLabel->getTextSize().height - mInstructionLabel->getHeight()));
|
||||
|
||||
int okButtonWidth = mOkButton->getTextSize ().width + 24;
|
||||
mOkButton->setCoord(mOkButton->getLeft() - (okButtonWidth - mOkButton->getWidth()),
|
||||
mOkButton->getTop(),
|
||||
okButtonWidth,
|
||||
mOkButton->getHeight());
|
||||
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onOkButtonClicked);
|
||||
|
||||
center();
|
||||
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
MyGUI::Button* button;
|
||||
getWidget(button, "QuickKey" + boost::lexical_cast<std::string>(i+1));
|
||||
|
||||
if (i != 9) // 10th quick key is always set to hand-to-hand
|
||||
button->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
||||
|
||||
unassign(button, i);
|
||||
|
||||
mQuickKeyButtons.push_back(button);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
QuickKeysMenu::~QuickKeysMenu()
|
||||
{
|
||||
delete mAssignDialog;
|
||||
}
|
||||
|
||||
void QuickKeysMenu::unassign(MyGUI::Widget* key, int index)
|
||||
{
|
||||
while (key->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (key->getChildAt(0));
|
||||
|
||||
MyGUI::TextBox* textBox = key->createWidgetReal<MyGUI::TextBox>("SandText", MyGUI::FloatCoord(0,0,1,1), MyGUI::Align::Default);
|
||||
textBox->setTextAlign (MyGUI::Align::Center);
|
||||
textBox->setCaption (boost::lexical_cast<std::string>(index+1));
|
||||
textBox->setNeedMouseFocus (false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onQuickKeyButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
int index = -1;
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
if (sender == mQuickKeyButtons[i] || sender->getParent () == mQuickKeyButtons[i])
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(index != -1);
|
||||
mSelectedIndex = index;
|
||||
|
||||
{
|
||||
// open assign dialog
|
||||
if (!mAssignDialog)
|
||||
mAssignDialog = new QuickKeysMenuAssign(mWindowManager, this);
|
||||
mAssignDialog->setVisible (true);
|
||||
}
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onOkButtonClicked (MyGUI::Widget *sender)
|
||||
{
|
||||
mWindowManager.removeGuiMode(GM_QuickKeysMenu);
|
||||
}
|
||||
|
||||
|
||||
void QuickKeysMenu::onItemButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
if (!mItemSelectionDialog )
|
||||
{
|
||||
mItemSelectionDialog = new ItemSelectionDialog("#{sQuickMenu6}", ContainerBase::Filter_All, mWindowManager);
|
||||
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &QuickKeysMenu::onAssignItem);
|
||||
mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &QuickKeysMenu::onAssignItemCancel);
|
||||
}
|
||||
mItemSelectionDialog->setVisible(true);
|
||||
mItemSelectionDialog->openContainer(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
||||
mItemSelectionDialog->drawItems ();
|
||||
|
||||
mAssignDialog->setVisible (false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onMagicButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
if (!mMagicSelectionDialog )
|
||||
{
|
||||
mMagicSelectionDialog = new MagicSelectionDialog(mWindowManager, this);
|
||||
}
|
||||
mMagicSelectionDialog->setVisible(true);
|
||||
|
||||
mAssignDialog->setVisible (false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onUnassignButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
unassign(mQuickKeyButtons[mSelectedIndex], mSelectedIndex);
|
||||
mAssignDialog->setVisible (false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onCancelButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
mAssignDialog->setVisible (false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onAssignItem(MWWorld::Ptr item)
|
||||
{
|
||||
MyGUI::Button* button = mQuickKeyButtons[mSelectedIndex];
|
||||
while (button->getChildCount ())
|
||||
MyGUI::Gui::getInstance ().destroyWidget (button->getChildAt(0));
|
||||
|
||||
MyGUI::ImageBox* image = button->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(9, 8, 42, 42), MyGUI::Align::Default);
|
||||
image->setUserString ("ToolTipType", "ItemPtr");
|
||||
image->setUserData(item);
|
||||
std::string path = std::string("icons\\");
|
||||
path += MWWorld::Class::get(item).getInventoryIcon(item);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture (path);
|
||||
image->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked);
|
||||
|
||||
mItemSelectionDialog->setVisible(false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onAssignItemCancel()
|
||||
{
|
||||
mItemSelectionDialog->setVisible(false);
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onAssignMagicItem (MWWorld::Ptr item)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onAssignMagic (const std::string& spellId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QuickKeysMenu::onAssignMagicCancel ()
|
||||
{
|
||||
mMagicSelectionDialog->setVisible(false);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------
|
||||
|
||||
QuickKeysMenuAssign::QuickKeysMenuAssign (MWBase::WindowManager &parWindowManager, QuickKeysMenu* parent)
|
||||
: WindowModal("openmw_quickkeys_menu_assign.layout", parWindowManager)
|
||||
, mParent(parent)
|
||||
{
|
||||
getWidget(mLabel, "Label");
|
||||
getWidget(mItemButton, "ItemButton");
|
||||
getWidget(mMagicButton, "MagicButton");
|
||||
getWidget(mUnassignButton, "UnassignButton");
|
||||
getWidget(mCancelButton, "CancelButton");
|
||||
|
||||
mItemButton->eventMouseButtonClick += MyGUI::newDelegate(mParent, &QuickKeysMenu::onItemButtonClicked);
|
||||
mMagicButton->eventMouseButtonClick += MyGUI::newDelegate(mParent, &QuickKeysMenu::onMagicButtonClicked);
|
||||
mUnassignButton->eventMouseButtonClick += MyGUI::newDelegate(mParent, &QuickKeysMenu::onUnassignButtonClicked);
|
||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(mParent, &QuickKeysMenu::onCancelButtonClicked);
|
||||
|
||||
|
||||
int maxWidth = mItemButton->getTextSize ().width + 24;
|
||||
maxWidth = std::max(maxWidth, mMagicButton->getTextSize ().width + 24);
|
||||
maxWidth = std::max(maxWidth, mUnassignButton->getTextSize ().width + 24);
|
||||
maxWidth = std::max(maxWidth, mCancelButton->getTextSize ().width + 24);
|
||||
|
||||
mMainWidget->setSize(maxWidth + 24, mMainWidget->getHeight());
|
||||
mLabel->setSize(maxWidth, mLabel->getHeight());
|
||||
|
||||
mItemButton->setCoord((maxWidth - mItemButton->getTextSize().width-24)/2 + 8,
|
||||
mItemButton->getTop(),
|
||||
mItemButton->getTextSize().width + 24,
|
||||
mItemButton->getHeight());
|
||||
mMagicButton->setCoord((maxWidth - mMagicButton->getTextSize().width-24)/2 + 8,
|
||||
mMagicButton->getTop(),
|
||||
mMagicButton->getTextSize().width + 24,
|
||||
mMagicButton->getHeight());
|
||||
mUnassignButton->setCoord((maxWidth - mUnassignButton->getTextSize().width-24)/2 + 8,
|
||||
mUnassignButton->getTop(),
|
||||
mUnassignButton->getTextSize().width + 24,
|
||||
mUnassignButton->getHeight());
|
||||
mCancelButton->setCoord((maxWidth - mCancelButton->getTextSize().width-24)/2 + 8,
|
||||
mCancelButton->getTop(),
|
||||
mCancelButton->getTextSize().width + 24,
|
||||
mCancelButton->getHeight());
|
||||
|
||||
center();
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------
|
||||
|
||||
MagicSelectionDialog::MagicSelectionDialog(MWBase::WindowManager &parWindowManager, QuickKeysMenu* parent)
|
||||
: WindowModal("openmw_magicselection_dialog.layout", parWindowManager)
|
||||
, mParent(parent)
|
||||
{
|
||||
getWidget(mCancelButton, "CancelButton");
|
||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MagicSelectionDialog::onCancelButtonClicked);
|
||||
|
||||
center();
|
||||
}
|
||||
|
||||
void MagicSelectionDialog::onCancelButtonClicked (MyGUI::Widget *sender)
|
||||
{
|
||||
mParent->onAssignMagicCancel ();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
#ifndef MWGUI_QUICKKEYS_H
|
||||
#define MWGUI_QUICKKEYS_H
|
||||
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
#include "window_base.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
class QuickKeysMenuAssign;
|
||||
class ItemSelectionDialog;
|
||||
class MagicSelectionDialog;
|
||||
|
||||
class QuickKeysMenu : public WindowBase
|
||||
{
|
||||
public:
|
||||
QuickKeysMenu(MWBase::WindowManager& parWindowManager);
|
||||
~QuickKeysMenu();
|
||||
|
||||
|
||||
void onItemButtonClicked(MyGUI::Widget* sender);
|
||||
void onMagicButtonClicked(MyGUI::Widget* sender);
|
||||
void onUnassignButtonClicked(MyGUI::Widget* sender);
|
||||
void onCancelButtonClicked(MyGUI::Widget* sender);
|
||||
|
||||
void onAssignItem (MWWorld::Ptr item);
|
||||
void onAssignItemCancel ();
|
||||
void onAssignMagicItem (MWWorld::Ptr item);
|
||||
void onAssignMagic (const std::string& spellId);
|
||||
void onAssignMagicCancel ();
|
||||
|
||||
|
||||
private:
|
||||
MyGUI::EditBox* mInstructionLabel;
|
||||
MyGUI::Button* mOkButton;
|
||||
|
||||
std::vector<MyGUI::Button*> mQuickKeyButtons;
|
||||
|
||||
QuickKeysMenuAssign* mAssignDialog;
|
||||
ItemSelectionDialog* mItemSelectionDialog;
|
||||
MagicSelectionDialog* mMagicSelectionDialog;
|
||||
|
||||
int mSelectedIndex;
|
||||
|
||||
|
||||
void onQuickKeyButtonClicked(MyGUI::Widget* sender);
|
||||
void onOkButtonClicked(MyGUI::Widget* sender);
|
||||
|
||||
void unassign(MyGUI::Widget* key, int index);
|
||||
};
|
||||
|
||||
class QuickKeysMenuAssign : public WindowModal
|
||||
{
|
||||
public:
|
||||
QuickKeysMenuAssign(MWBase::WindowManager& parWindowManager, QuickKeysMenu* parent);
|
||||
|
||||
private:
|
||||
MyGUI::TextBox* mLabel;
|
||||
MyGUI::Button* mItemButton;
|
||||
MyGUI::Button* mMagicButton;
|
||||
MyGUI::Button* mUnassignButton;
|
||||
MyGUI::Button* mCancelButton;
|
||||
|
||||
QuickKeysMenu* mParent;
|
||||
};
|
||||
|
||||
class MagicSelectionDialog : public WindowModal
|
||||
{
|
||||
public:
|
||||
MagicSelectionDialog(MWBase::WindowManager& parWindowManager, QuickKeysMenu* parent);
|
||||
|
||||
private:
|
||||
MyGUI::Button* mCancelButton;
|
||||
|
||||
QuickKeysMenu* mParent;
|
||||
|
||||
void onCancelButtonClicked (MyGUI::Widget* sender);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="Window" skin="MW_Dialog" position="0 0 380 155" layer="Windows" name="_Main">
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="8 8 300 18" name="Label"/>
|
||||
|
||||
<Widget type="Widget" skin="MW_Box" position="8 34 340 70" name="box" align="Left Top Stretch">
|
||||
<Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 332 62" name="ItemView" align="Left Top Stretch">
|
||||
<Property key="CanvasAlign" value="Left Top"/>
|
||||
<Widget type="Button" skin="" name="Items" position="0 0 332 62" name="Items" align="Left Top Stretch"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<Widget type="Button" skin="MW_Button" position="350 110 24 24" name="CancelButton">
|
||||
<Property key="Caption" value="#{sCancel}"/>
|
||||
</Widget>
|
||||
|
||||
|
||||
</Widget>
|
||||
</MyGUI>
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="Window" skin="MW_Dialog" position="0 0 330 370" layer="Windows" name="_Main">
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="8 8 300 24">
|
||||
<Property key="Caption" value="Select a magic to quick key."/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="Widget" skin="MW_Box" position="8 38 314 285" name="box" align="Left Top Stretch">
|
||||
<Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 306 277" name="MagicList" align="Left Top Stretch">
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<Widget type="Button" skin="MW_Button" name="CancelButton" position="288 340 32 24" align="Right Bottom">
|
||||
<Property key="Caption" value="#{sCancel}"/>
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
</MyGUI>
|
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="Window" skin="MW_Dialog" position="0 0 370 230" layer="Windows" name="_Main">
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="8 8 354 18">
|
||||
<Property key="Caption" value="#{sQuickMenuTitle}"/>
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="EditBox" skin="SandText" position="8 26 354 18" name="InstructionLabel" align="Left Top VStretch">
|
||||
<Property key="Caption" value="#{sQuickMenuInstruc}"/>
|
||||
<Property key="MultiLine" value="true"/>
|
||||
<Property key="WordWrap" value="true"/>
|
||||
<Property key="Static" value="true"/>
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="Widget" skin="" position="15 55 332 128" align="Left Bottom HCenter">
|
||||
|
||||
<Widget type="Button" skin="MW_Box" position="0 0 60 59" name="QuickKey1"/>
|
||||
<Widget type="Button" skin="MW_Box" position="68 0 60 59" name="QuickKey2"/>
|
||||
<Widget type="Button" skin="MW_Box" position="136 0 60 59" name="QuickKey3"/>
|
||||
<Widget type="Button" skin="MW_Box" position="204 0 60 59" name="QuickKey4"/>
|
||||
<Widget type="Button" skin="MW_Box" position="272 0 60 59" name="QuickKey5"/>
|
||||
<Widget type="Button" skin="MW_Box" position="0 67 60 59" name="QuickKey6"/>
|
||||
<Widget type="Button" skin="MW_Box" position="68 67 60 59" name="QuickKey7"/>
|
||||
<Widget type="Button" skin="MW_Box" position="136 67 60 59" name="QuickKey8"/>
|
||||
<Widget type="Button" skin="MW_Box" position="204 67 60 59" name="QuickKey9"/>
|
||||
<Widget type="Button" skin="MW_Box" position="272 67 60 59" name="QuickKey10"/>
|
||||
|
||||
</Widget>
|
||||
|
||||
<Widget type="Button" skin="MW_Button" name="OKButton" position="315 190 32 24" align="Right Bottom">
|
||||
<Property key="Caption" value="#{sOK}"/>
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
</MyGUI>
|
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="Window" skin="MW_Dialog" position="0 0 16 154" layer="Windows" name="_Main">
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="8 8 0 18" name="Label">
|
||||
<Property key="Caption" value="#{sQuickMenu1}"/>
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="Button" skin="MW_Button" position="8 28 0 24" name="ItemButton">
|
||||
<Property key="Caption" value="#{sQuickMenu2}"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="Button" skin="MW_Button" position="8 56 0 24" name="MagicButton">
|
||||
<Property key="Caption" value="#{sQuickMenu3}"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="Button" skin="MW_Button" position="8 84 0 24" name="UnassignButton">
|
||||
<Property key="Caption" value="#{sQuickMenu4}"/>
|
||||
</Widget>
|
||||
|
||||
|
||||
<Widget type="Button" skin="MW_Button" position="8 112 0 24" name="CancelButton">
|
||||
<Property key="Caption" value="#{sCancel}"/>
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
</MyGUI>
|
Loading…
Reference in New Issue