dynamic inventory layout like morrowind

actorid
scrawl 13 years ago
parent d266b4fe87
commit 3a93df8db4

@ -66,8 +66,7 @@ void ContainerBase::onSelectedItem(MyGUI::Widget* _sender)
_sender->getChildAt(0)->getChildAt(0)->setVisible(false);
drawItems();
MWBase::Environment::get().getInputManager()->setDragDrop(true);
MWBase::Environment::get().getWindowManager()->setMouseVisible(false);
MWBase::Environment::get().getWindowManager()->setDragDrop(true);
}
else
onContainerClicked(mContainerWidget);
@ -93,8 +92,7 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
mDragAndDrop->mContainerWindow = 0;
drawItems();
MWBase::Environment::get().getInputManager()->setDragDrop(false);
MWBase::Environment::get().getWindowManager()->setMouseVisible(true);
MWBase::Environment::get().getWindowManager()->setDragDrop(false);
}
}
@ -128,7 +126,7 @@ void ContainerBase::drawItems()
int x = 0;
int y = 0;
int maxHeight = mItemView->getSize().height - 48;
int maxHeight = mItemView->getSize().height - 58;
int index = 0;
@ -195,7 +193,12 @@ void ContainerBase::drawItems()
}
if(iter->getRefData().getCount() > 1)
text->setCaption(boost::lexical_cast<std::string>(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,7 +212,7 @@ void ContainerBase::Update()
if(mDragAndDrop->mIsOnDragAndDrop)
{
if(mDragAndDrop->mDraggedWidget)
mDragAndDrop->mDraggedWidget->setPosition(MyGUI::InputManager::getInstance().getMousePosition());
mDragAndDrop->mDraggedWidget->setPosition(MyGUI::InputManager::getInstance().getMousePosition() - MyGUI::IntPoint(21, 21));
else mDragAndDrop->mIsOnDragAndDrop = false; //If this happens, there is a bug.
}
}

@ -35,6 +35,8 @@ namespace MWGui
getWidget(mFilterApparel, "ApparelButton");
getWidget(mFilterMagic, "MagicButton");
getWidget(mFilterMisc, "MiscButton");
getWidget(mLeftPane, "LeftPane");
getWidget(mRightPane, "RightPane");
MyGUI::ScrollView* itemView;
MyGUI::Widget* containerWidget;
@ -86,6 +88,12 @@ namespace MWGui
void InventoryWindow::onWindowResize(MyGUI::Window* _sender)
{
const float aspect = 0.5; // fixed aspect ratio for the left pane
mLeftPane->setSize( (_sender->getSize().height-44) * aspect, _sender->getSize().height-44 );
mRightPane->setCoord( mLeftPane->getPosition().left + (_sender->getSize().height-44) * aspect + 4,
mRightPane->getPosition().top,
_sender->getSize().width - 12 - (_sender->getSize().height-44) * aspect - 15,
_sender->getSize().height-44 );
drawItems();
}

@ -36,6 +36,9 @@ namespace MWGui
MyGUI::ProgressBar* mEncumbranceBar;
MyGUI::TextBox* mEncumbranceText;
MyGUI::Widget* mLeftPane;
MyGUI::Widget* mRightPane;
MyGUI::Button* mFilterAll;
MyGUI::Button* mFilterWeapon;
MyGUI::Button* mFilterApparel;

@ -16,6 +16,7 @@ ToolTips::ToolTips(WindowManager* windowManager) :
, mGameMode(true)
, mWindowManager(windowManager)
, mFullHelp(false)
, mEnabled(true)
{
getWidget(mDynamicToolTipBox, "DynamicToolTipBox");
@ -27,6 +28,11 @@ ToolTips::ToolTips(WindowManager* windowManager) :
mMainWidget->setNeedMouseFocus(false);
}
void ToolTips::setEnabled(bool enabled)
{
mEnabled = enabled;
}
void ToolTips::onFrame(float frameDuration)
{
MyGUI::Gui::getInstance().destroyWidget(mDynamicToolTipBox);
@ -36,6 +42,12 @@ void ToolTips::onFrame(float frameDuration)
const IntSize &viewSize = RenderManager::getInstance().getViewSize();
if (!mEnabled)
{
mDynamicToolTipBox->setVisible(false);
return;
}
if (!mGameMode)
{
Widget* focus = InputManager::getInstance().getMouseFocusWidget();

@ -39,6 +39,8 @@ namespace MWGui
void enterGameMode();
void enterGuiMode();
void setEnabled(bool enabled);
void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
bool getFullHelp() const;
@ -73,6 +75,8 @@ namespace MWGui
bool mGameMode;
bool mEnabled;
bool mFullHelp;
};
}

@ -563,3 +563,10 @@ void WindowManager::setMouseVisible(bool visible)
{
MyGUI::PointerManager::getInstance().setVisible(visible);
}
void WindowManager::setDragDrop(bool dragDrop)
{
mToolTips->setEnabled(!dragDrop);
MWBase::Environment::get().getInputManager()->setDragDrop(dragDrop);
setMouseVisible(!dragDrop);
}

@ -166,7 +166,8 @@ namespace MWGui
void setFocusObject(const MWWorld::Ptr& focus);
void setMouseVisible(bool visible);
void setMouseVisible(bool visible);
void setDragDrop(bool dragDrop);
void toggleFogOfWar();
void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)

@ -3,37 +3,44 @@
<MyGUI type="Layout">
<Widget type="Window" skin="MW_Window_Pinnable" layer="Windows" position="0 0 600 300" name="_Main">
<!-- Player encumbrance -->
<Widget type="ProgressBar" skin="MW_Progress_Blue" position="8 8 212 24" name="EncumbranceBar">
<Property key="Range" value="100"/>
<Property key="RangePosition" value="50"/>
<Widget type="TextBox" skin="ProgressText" position="0 0 212 24" align="Center" name="EncumbranceBarT">
<Property key="Caption" value="Encumbrance bar"/>
<Widget type="Widget" skin="" position="0 0 224 223" align="Left Top" name="LeftPane">
<!-- Player encumbrance -->
<Widget type="ProgressBar" skin="MW_Progress_Blue" position="8 8 212 24" name="EncumbranceBar" align="Left Top HStretch">
<Property key="Range" value="100"/>
<Property key="RangePosition" value="50"/>
<Widget type="TextBox" skin="ProgressText" position="0 0 212 24" align="Center Stretch" name="EncumbranceBarT">
<Property key="Caption" value="Encumbrance bar"/>
</Widget>
</Widget>
</Widget>
<!-- Avatar -->
<Widget type="Widget" skin="MW_Box" position="8 38 212 219" name="Avatar" align="Left Top VStretch">
<Widget type="TextBox" skin="ProgressText" position="0 180 212 24" align="HCenter Bottom" name="ArmorRating">
<Property key="Caption" value="Armor Rating goes here"/>
<!-- Avatar -->
<Widget type="Widget" skin="MW_Box" position="8 38 212 185" name="Avatar" align="Left Top Stretch">
<Widget type="TextBox" skin="ProgressText" position="0 150 212 24" align="HCenter Bottom" name="ArmorRating">
<Property key="Caption" value="Armor Rating"/>
</Widget>
</Widget>
</Widget>
<!-- Items in inventory -->
<Widget type="Widget" skin="MW_Box" position="228 38 300 219" name="box" align="Left Top Stretch">
<Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 292 215" align="Left Top Stretch" name="ItemView">
<Property key="CanvasSize" value="1024 1024"/>
<Widget type="Button" skin="" name="Items" position="0 0 292 215" name="Items" align="Left Top Stretch"/>
<Widget type="Widget" skin="" position="228 0 350 223" align="Left Top" name="RightPane">
<!-- Items in inventory -->
<Widget type="Widget" skin="MW_Box" position="0 38 350 185" name="box" align="Left Top Stretch">
<Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 342 181" align="Left Top Stretch" name="ItemView">
<Widget type="Button" skin="" name="Items" position="0 0 342 181" name="Items" align="Left Top Stretch"/>
</Widget>
</Widget>
<!-- Categories -->
<Widget type="Widget" position="0 8 350 24" align="Left Top HStretch" name="Categories">
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="AllButton"/>
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="WeaponButton"/>
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="ApparelButton"/>
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="MagicButton"/>
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="MiscButton"/>
</Widget>
</Widget>
<!-- Categories -->
<Widget type="Widget" position="228 8 300 24" align="ALIGN_TOP ALIGN_LEFT" name="Categories">
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="AllButton"/>
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="WeaponButton"/>
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="ApparelButton"/>
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="MagicButton"/>
<Widget type="Button" skin="MW_Button" position="0 0 60 24" name="MiscButton"/>
</Widget>
</Widget>

Loading…
Cancel
Save