mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 20:15:33 +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)
|
||||
{
|
||||
mDragAndDrop->mIsOnDragAndDrop = true;
|
||||
_sender->detachFromWidget();
|
||||
_sender->attachToWidget(mDragAndDrop->mDragAndDropWidget);
|
||||
int count = (*_sender->getUserData<MWWorld::Ptr>()).getRefData().getCount();
|
||||
|
||||
MWWorld::Ptr object = *_sender->getUserData<MWWorld::Ptr>();
|
||||
mDragAndDrop->mStore.add(object);
|
||||
object.getRefData().setCount(0);
|
||||
|
||||
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);
|
||||
// hide the count text
|
||||
_sender->getChildAt(0)->getChildAt(0)->setVisible(false);
|
||||
drawItems();
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->setDragDrop(true);
|
||||
if (MWBase::Environment::get().getInputManager()->getShiftDown() || count == 1)
|
||||
{
|
||||
onSelectedItemImpl(_sender, count);
|
||||
}
|
||||
else if (MWBase::Environment::get().getInputManager()->getCtrlDown())
|
||||
{
|
||||
onSelectedItemImpl(_sender, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
/// \todo count selection window
|
||||
onSelectedItemImpl(_sender, count);
|
||||
}
|
||||
}
|
||||
else
|
||||
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)
|
||||
{
|
||||
if(mDragAndDrop->mIsOnDragAndDrop) //drop widget here
|
||||
|
@ -154,6 +174,8 @@ void ContainerBase::drawItems()
|
|||
+ 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)
|
||||
{
|
||||
index++;
|
||||
|
@ -194,13 +216,7 @@ void ContainerBase::drawItems()
|
|||
y = 0;
|
||||
}
|
||||
|
||||
if(iter->getRefData().getCount() > 1)
|
||||
{
|
||||
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()));
|
||||
}
|
||||
text->setCaption(getCountString(iter->getRefData().getCount()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,6 +225,16 @@ void ContainerBase::drawItems()
|
|||
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()
|
||||
{
|
||||
if(mDragAndDrop->mIsOnDragAndDrop)
|
||||
|
|
|
@ -74,9 +74,12 @@ namespace MWGui
|
|||
Filter mFilter;
|
||||
|
||||
void onSelectedItem(MyGUI::Widget* _sender);
|
||||
void onSelectedItemImpl(MyGUI::Widget* _sender, int count);
|
||||
void onContainerClicked(MyGUI::Widget* _sender);
|
||||
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
|
||||
|
||||
std::string getCountString(const int count);
|
||||
|
||||
void drawItems();
|
||||
};
|
||||
|
||||
|
@ -90,13 +93,9 @@ namespace MWGui
|
|||
void open(MWWorld::Ptr container);
|
||||
|
||||
protected:
|
||||
std::vector<MyGUI::WidgetPtr> mContainerWidgets;
|
||||
|
||||
MyGUI::Button* mTakeButton;
|
||||
MyGUI::Button* mCloseButton;
|
||||
|
||||
bool mIsValid;//is in the right GUI Mode
|
||||
|
||||
void onWindowResize(MyGUI::Window* window);
|
||||
void onCloseButtonClicked(MyGUI::Widget* _sender);
|
||||
void onTakeAllButtonClicked(MyGUI::Widget* _sender);
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace MWInput
|
|||
A_CycleWeaponRight,
|
||||
A_ToggleSneak, //Toggles Sneak, add Push-Sneak later
|
||||
A_ToggleWalk, //Toggle Walking/Running
|
||||
A_Crouch,
|
||||
A_Crouch,
|
||||
|
||||
A_QuickSave,
|
||||
A_QuickLoad,
|
||||
|
@ -69,6 +69,8 @@ namespace MWInput
|
|||
A_ToggleWeapon,
|
||||
A_ToggleSpell,
|
||||
|
||||
A_Shift,
|
||||
|
||||
A_ToggleFps, // Toggle FPS display (this is temporary)
|
||||
|
||||
A_LAST // Marker for the last item
|
||||
|
@ -90,6 +92,14 @@ namespace MWInput
|
|||
|
||||
bool mDragDrop;
|
||||
|
||||
bool mShiftDown;
|
||||
bool mCtrlDown;
|
||||
|
||||
public:
|
||||
bool getShiftDown() { return mShiftDown; }
|
||||
bool getCtrlDown() { return mCtrlDown; }
|
||||
|
||||
private:
|
||||
|
||||
/* InputImpl Methods */
|
||||
|
||||
|
@ -228,7 +238,9 @@ namespace MWInput
|
|||
player(_player),
|
||||
windows(_windows),
|
||||
mEngine (engine),
|
||||
mDragDrop(false)
|
||||
mDragDrop(false),
|
||||
mShiftDown(false),
|
||||
mCtrlDown(false)
|
||||
{
|
||||
using namespace OEngine::Input;
|
||||
using namespace OEngine::Render;
|
||||
|
@ -323,9 +335,11 @@ namespace MWInput
|
|||
poller.bind(A_MoveRight, KC_D);
|
||||
poller.bind(A_MoveForward, KC_W);
|
||||
poller.bind(A_MoveBackward, KC_S);
|
||||
|
||||
poller.bind(A_Jump, KC_E);
|
||||
poller.bind(A_Crouch, KC_LCONTROL);
|
||||
|
||||
poller.bind(A_Jump, KC_E);
|
||||
poller.bind(A_Crouch, KC_LCONTROL);
|
||||
|
||||
poller.bind(A_Shift, KC_LSHIFT);
|
||||
}
|
||||
|
||||
void setDragDrop(bool dragDrop)
|
||||
|
@ -347,6 +361,9 @@ namespace MWInput
|
|||
// event callbacks (which may crash)
|
||||
windows.update();
|
||||
|
||||
mShiftDown = poller.isDown(A_Shift);
|
||||
mCtrlDown = poller.isDown(A_Crouch);
|
||||
|
||||
// Disable movement in Gui mode
|
||||
if (windows.isGuiMode()) return;
|
||||
|
||||
|
@ -378,7 +395,7 @@ namespace MWInput
|
|||
else
|
||||
player.setForwardBackward (0);
|
||||
|
||||
if (poller.isDown(A_Jump))
|
||||
if (poller.isDown(A_Jump))
|
||||
player.setUpDown (1);
|
||||
else if (poller.isDown(A_Crouch))
|
||||
player.setUpDown (-1);
|
||||
|
@ -445,4 +462,14 @@ namespace MWInput
|
|||
{
|
||||
impl->setDragDrop(dragDrop);
|
||||
}
|
||||
|
||||
bool MWInputManager::getShiftDown()
|
||||
{
|
||||
return impl->getShiftDown();
|
||||
}
|
||||
|
||||
bool MWInputManager::getCtrlDown()
|
||||
{
|
||||
return impl->getCtrlDown();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,9 @@ namespace MWInput
|
|||
|
||||
void update();
|
||||
|
||||
bool getShiftDown();
|
||||
bool getCtrlDown();
|
||||
|
||||
void setDragDrop(bool dragDrop);
|
||||
|
||||
void setGuiMode(MWGui::GuiMode mode);
|
||||
|
|
Loading…
Reference in a new issue