mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 17:06:43 +00:00
implemented ctrl and shift-keys for item drag&drop (take all, take 1)
This commit is contained in:
parent
933a40de14
commit
320cc7d020
4 changed files with 89 additions and 34 deletions
|
@ -49,29 +49,49 @@ void ContainerBase::onSelectedItem(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
if(!mDragAndDrop->mIsOnDragAndDrop)
|
if(!mDragAndDrop->mIsOnDragAndDrop)
|
||||||
{
|
{
|
||||||
mDragAndDrop->mIsOnDragAndDrop = true;
|
int count = (*_sender->getUserData<MWWorld::Ptr>()).getRefData().getCount();
|
||||||
_sender->detachFromWidget();
|
|
||||||
_sender->attachToWidget(mDragAndDrop->mDragAndDropWidget);
|
|
||||||
|
|
||||||
MWWorld::Ptr object = *_sender->getUserData<MWWorld::Ptr>();
|
if (MWBase::Environment::get().getInputManager()->getShiftDown() || count == 1)
|
||||||
mDragAndDrop->mStore.add(object);
|
{
|
||||||
object.getRefData().setCount(0);
|
onSelectedItemImpl(_sender, count);
|
||||||
|
}
|
||||||
std::string sound = MWWorld::Class::get(object).getUpSoundId(object);
|
else if (MWBase::Environment::get().getInputManager()->getCtrlDown())
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
{
|
||||||
|
onSelectedItemImpl(_sender, 1);
|
||||||
mDragAndDrop->mDraggedWidget = _sender;
|
}
|
||||||
mDragAndDrop->mContainerWindow = const_cast<MWGui::ContainerBase*>(this);
|
else
|
||||||
// hide the count text
|
{
|
||||||
_sender->getChildAt(0)->getChildAt(0)->setVisible(false);
|
/// \todo count selection window
|
||||||
drawItems();
|
onSelectedItemImpl(_sender, count);
|
||||||
|
}
|
||||||
MWBase::Environment::get().getWindowManager()->setDragDrop(true);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
onContainerClicked(mContainerWidget);
|
onContainerClicked(mContainerWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContainerBase::onSelectedItemImpl(MyGUI::Widget* _sender, int count)
|
||||||
|
{
|
||||||
|
mDragAndDrop->mIsOnDragAndDrop = true;
|
||||||
|
_sender->detachFromWidget();
|
||||||
|
_sender->attachToWidget(mDragAndDrop->mDragAndDropWidget);
|
||||||
|
|
||||||
|
MWWorld::Ptr object = *_sender->getUserData<MWWorld::Ptr>();
|
||||||
|
int originalCount = object.getRefData().getCount();
|
||||||
|
object.getRefData().setCount(count);
|
||||||
|
mDragAndDrop->mStore.add(object);
|
||||||
|
object.getRefData().setCount(originalCount - count);
|
||||||
|
|
||||||
|
std::string sound = MWWorld::Class::get(object).getUpSoundId(object);
|
||||||
|
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
||||||
|
|
||||||
|
mDragAndDrop->mDraggedWidget = _sender;
|
||||||
|
mDragAndDrop->mContainerWindow = const_cast<MWGui::ContainerBase*>(this);
|
||||||
|
static_cast<MyGUI::TextBox*>(_sender->getChildAt(0)->getChildAt(0))->setCaption(getCountString((*mDragAndDrop->mStore.begin()).getRefData().getCount()));
|
||||||
|
drawItems();
|
||||||
|
|
||||||
|
MWBase::Environment::get().getWindowManager()->setDragDrop(true);
|
||||||
|
}
|
||||||
|
|
||||||
void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
|
void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
if(mDragAndDrop->mIsOnDragAndDrop) //drop widget here
|
if(mDragAndDrop->mIsOnDragAndDrop) //drop widget here
|
||||||
|
@ -154,6 +174,8 @@ void ContainerBase::drawItems()
|
||||||
+ MWWorld::ContainerStore::Type_Apparatus;
|
+ MWWorld::ContainerStore::Type_Apparatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \todo performance improvement: don't create/destroy all the widgets everytime the container window changes size, only reposition them
|
||||||
|
|
||||||
for (MWWorld::ContainerStoreIterator iter (containerStore.begin(categories)); iter!=containerStore.end(); ++iter)
|
for (MWWorld::ContainerStoreIterator iter (containerStore.begin(categories)); iter!=containerStore.end(); ++iter)
|
||||||
{
|
{
|
||||||
index++;
|
index++;
|
||||||
|
@ -194,13 +216,7 @@ void ContainerBase::drawItems()
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(iter->getRefData().getCount() > 1)
|
text->setCaption(getCountString(iter->getRefData().getCount()));
|
||||||
{
|
|
||||||
if (iter->getRefData().getCount() > 9999)
|
|
||||||
text->setCaption(boost::lexical_cast<std::string>(iter->getRefData().getCount()/1000.f) + "k");
|
|
||||||
else
|
|
||||||
text->setCaption(boost::lexical_cast<std::string>(iter->getRefData().getCount()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,6 +225,16 @@ void ContainerBase::drawItems()
|
||||||
mContainerWidget->setSize(size);
|
mContainerWidget->setSize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ContainerBase::getCountString(const int count)
|
||||||
|
{
|
||||||
|
if (count == 1)
|
||||||
|
return "";
|
||||||
|
if (count > 9999)
|
||||||
|
return boost::lexical_cast<std::string>(count/1000.f) + "k";
|
||||||
|
else
|
||||||
|
return boost::lexical_cast<std::string>(count);
|
||||||
|
}
|
||||||
|
|
||||||
void ContainerBase::Update()
|
void ContainerBase::Update()
|
||||||
{
|
{
|
||||||
if(mDragAndDrop->mIsOnDragAndDrop)
|
if(mDragAndDrop->mIsOnDragAndDrop)
|
||||||
|
|
|
@ -74,9 +74,12 @@ namespace MWGui
|
||||||
Filter mFilter;
|
Filter mFilter;
|
||||||
|
|
||||||
void onSelectedItem(MyGUI::Widget* _sender);
|
void onSelectedItem(MyGUI::Widget* _sender);
|
||||||
|
void onSelectedItemImpl(MyGUI::Widget* _sender, int count);
|
||||||
void onContainerClicked(MyGUI::Widget* _sender);
|
void onContainerClicked(MyGUI::Widget* _sender);
|
||||||
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
|
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
|
||||||
|
|
||||||
|
std::string getCountString(const int count);
|
||||||
|
|
||||||
void drawItems();
|
void drawItems();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -90,13 +93,9 @@ namespace MWGui
|
||||||
void open(MWWorld::Ptr container);
|
void open(MWWorld::Ptr container);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<MyGUI::WidgetPtr> mContainerWidgets;
|
|
||||||
|
|
||||||
MyGUI::Button* mTakeButton;
|
MyGUI::Button* mTakeButton;
|
||||||
MyGUI::Button* mCloseButton;
|
MyGUI::Button* mCloseButton;
|
||||||
|
|
||||||
bool mIsValid;//is in the right GUI Mode
|
|
||||||
|
|
||||||
void onWindowResize(MyGUI::Window* window);
|
void onWindowResize(MyGUI::Window* window);
|
||||||
void onCloseButtonClicked(MyGUI::Widget* _sender);
|
void onCloseButtonClicked(MyGUI::Widget* _sender);
|
||||||
void onTakeAllButtonClicked(MyGUI::Widget* _sender);
|
void onTakeAllButtonClicked(MyGUI::Widget* _sender);
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace MWInput
|
||||||
A_CycleWeaponRight,
|
A_CycleWeaponRight,
|
||||||
A_ToggleSneak, //Toggles Sneak, add Push-Sneak later
|
A_ToggleSneak, //Toggles Sneak, add Push-Sneak later
|
||||||
A_ToggleWalk, //Toggle Walking/Running
|
A_ToggleWalk, //Toggle Walking/Running
|
||||||
A_Crouch,
|
A_Crouch,
|
||||||
|
|
||||||
A_QuickSave,
|
A_QuickSave,
|
||||||
A_QuickLoad,
|
A_QuickLoad,
|
||||||
|
@ -69,6 +69,8 @@ namespace MWInput
|
||||||
A_ToggleWeapon,
|
A_ToggleWeapon,
|
||||||
A_ToggleSpell,
|
A_ToggleSpell,
|
||||||
|
|
||||||
|
A_Shift,
|
||||||
|
|
||||||
A_ToggleFps, // Toggle FPS display (this is temporary)
|
A_ToggleFps, // Toggle FPS display (this is temporary)
|
||||||
|
|
||||||
A_LAST // Marker for the last item
|
A_LAST // Marker for the last item
|
||||||
|
@ -90,6 +92,14 @@ namespace MWInput
|
||||||
|
|
||||||
bool mDragDrop;
|
bool mDragDrop;
|
||||||
|
|
||||||
|
bool mShiftDown;
|
||||||
|
bool mCtrlDown;
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool getShiftDown() { return mShiftDown; }
|
||||||
|
bool getCtrlDown() { return mCtrlDown; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
/* InputImpl Methods */
|
/* InputImpl Methods */
|
||||||
|
|
||||||
|
@ -228,7 +238,9 @@ namespace MWInput
|
||||||
player(_player),
|
player(_player),
|
||||||
windows(_windows),
|
windows(_windows),
|
||||||
mEngine (engine),
|
mEngine (engine),
|
||||||
mDragDrop(false)
|
mDragDrop(false),
|
||||||
|
mShiftDown(false),
|
||||||
|
mCtrlDown(false)
|
||||||
{
|
{
|
||||||
using namespace OEngine::Input;
|
using namespace OEngine::Input;
|
||||||
using namespace OEngine::Render;
|
using namespace OEngine::Render;
|
||||||
|
@ -324,8 +336,10 @@ namespace MWInput
|
||||||
poller.bind(A_MoveForward, KC_W);
|
poller.bind(A_MoveForward, KC_W);
|
||||||
poller.bind(A_MoveBackward, KC_S);
|
poller.bind(A_MoveBackward, KC_S);
|
||||||
|
|
||||||
poller.bind(A_Jump, KC_E);
|
poller.bind(A_Jump, KC_E);
|
||||||
poller.bind(A_Crouch, KC_LCONTROL);
|
poller.bind(A_Crouch, KC_LCONTROL);
|
||||||
|
|
||||||
|
poller.bind(A_Shift, KC_LSHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDragDrop(bool dragDrop)
|
void setDragDrop(bool dragDrop)
|
||||||
|
@ -347,6 +361,9 @@ namespace MWInput
|
||||||
// event callbacks (which may crash)
|
// event callbacks (which may crash)
|
||||||
windows.update();
|
windows.update();
|
||||||
|
|
||||||
|
mShiftDown = poller.isDown(A_Shift);
|
||||||
|
mCtrlDown = poller.isDown(A_Crouch);
|
||||||
|
|
||||||
// Disable movement in Gui mode
|
// Disable movement in Gui mode
|
||||||
if (windows.isGuiMode()) return;
|
if (windows.isGuiMode()) return;
|
||||||
|
|
||||||
|
@ -378,7 +395,7 @@ namespace MWInput
|
||||||
else
|
else
|
||||||
player.setForwardBackward (0);
|
player.setForwardBackward (0);
|
||||||
|
|
||||||
if (poller.isDown(A_Jump))
|
if (poller.isDown(A_Jump))
|
||||||
player.setUpDown (1);
|
player.setUpDown (1);
|
||||||
else if (poller.isDown(A_Crouch))
|
else if (poller.isDown(A_Crouch))
|
||||||
player.setUpDown (-1);
|
player.setUpDown (-1);
|
||||||
|
@ -445,4 +462,14 @@ namespace MWInput
|
||||||
{
|
{
|
||||||
impl->setDragDrop(dragDrop);
|
impl->setDragDrop(dragDrop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MWInputManager::getShiftDown()
|
||||||
|
{
|
||||||
|
return impl->getShiftDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MWInputManager::getCtrlDown()
|
||||||
|
{
|
||||||
|
return impl->getCtrlDown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,9 @@ namespace MWInput
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
bool getShiftDown();
|
||||||
|
bool getCtrlDown();
|
||||||
|
|
||||||
void setDragDrop(bool dragDrop);
|
void setDragDrop(bool dragDrop);
|
||||||
|
|
||||||
void setGuiMode(MWGui::GuiMode mode);
|
void setGuiMode(MWGui::GuiMode mode);
|
||||||
|
|
Loading…
Reference in a new issue