forked from mirror/openmw-tes3mp
Merge remote branch 'scrawl/objectselection'
This commit is contained in:
commit
ad54955e95
17 changed files with 397 additions and 186 deletions
|
@ -138,6 +138,7 @@ namespace MWGui
|
|||
void Console::disable()
|
||||
{
|
||||
setVisible(false);
|
||||
setSelectedObject(MWWorld::Ptr());
|
||||
// Remove keyboard focus from the console input whenever the
|
||||
// console is turned off
|
||||
MyGUI::InputManager::getInstance().setKeyFocusWidget(NULL);
|
||||
|
@ -240,7 +241,7 @@ namespace MWGui
|
|||
{
|
||||
try
|
||||
{
|
||||
ConsoleInterpreterContext interpreterContext (*this, MWWorld::Ptr());
|
||||
ConsoleInterpreterContext interpreterContext (*this, mPtr);
|
||||
Interpreter::Interpreter interpreter;
|
||||
MWScript::installOpcodes (interpreter);
|
||||
std::vector<Interpreter::Type_Code> code;
|
||||
|
@ -375,4 +376,18 @@ namespace MWGui
|
|||
{
|
||||
setCoord(10,10, width-10, height/2);
|
||||
}
|
||||
|
||||
void Console::setSelectedObject(const MWWorld::Ptr& object)
|
||||
{
|
||||
mPtr = object;
|
||||
if (!mPtr.isEmpty())
|
||||
setTitle("#{sConsoleTitle} (" + mPtr.getCellRef().refID + ")");
|
||||
else
|
||||
setTitle("#{sConsoleTitle}");
|
||||
}
|
||||
|
||||
void Console::onReferenceUnavailable()
|
||||
{
|
||||
setSelectedObject(MWWorld::Ptr());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,11 @@
|
|||
#include "../mwscript/compilercontext.hpp"
|
||||
#include "../mwscript/interpretercontext.hpp"
|
||||
|
||||
#include "referenceinterface.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
class Console : private OEngine::GUI::Layout, private Compiler::ErrorHandler
|
||||
class Console : private OEngine::GUI::Layout, private Compiler::ErrorHandler, public ReferenceInterface
|
||||
{
|
||||
private:
|
||||
|
||||
|
@ -39,7 +41,17 @@ namespace MWGui
|
|||
/// \note The list may contain duplicates (if a name is a keyword and an identifier at the same
|
||||
/// time).
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
void setSelectedObject(const MWWorld::Ptr& object);
|
||||
///< Set the implicit object for script execution
|
||||
|
||||
protected:
|
||||
|
||||
virtual void onReferenceUnavailable();
|
||||
|
||||
|
||||
public:
|
||||
MyGUI::EditPtr command;
|
||||
MyGUI::EditPtr history;
|
||||
|
||||
|
|
|
@ -470,7 +470,7 @@ void ContainerBase::drawItems()
|
|||
if(displayCount > 0 && !(onlyMagic && it->second != ItemState_Barter && MWWorld::Class::get(*iter).getEnchantment(*iter) == "" && iter->getTypeName() != typeid(ESM::Potion).name()))
|
||||
{
|
||||
std::string path = std::string("icons\\");
|
||||
path+=MWWorld::Class::get(*iter).getInventoryIcon(*iter);
|
||||
path += MWWorld::Class::get(*iter).getInventoryIcon(*iter);
|
||||
|
||||
// background widget (for the "equipped" frame and magic item background image)
|
||||
bool isMagic = (MWWorld::Class::get(*iter).getEnchantment(*iter) != "");
|
||||
|
|
|
@ -12,8 +12,10 @@
|
|||
#include "../mwworld/world.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
|
||||
#include "inventorywindow.hpp"
|
||||
#include "window_manager.hpp"
|
||||
#include "container.hpp"
|
||||
#include "console.hpp"
|
||||
|
||||
using namespace MWGui;
|
||||
|
||||
|
@ -46,6 +48,7 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
|
|||
, mMapVisible(true)
|
||||
, mWeaponVisible(true)
|
||||
, mSpellVisible(true)
|
||||
, mWorldMouseOver(false)
|
||||
{
|
||||
setCoord(0,0, width, height);
|
||||
|
||||
|
@ -264,6 +267,33 @@ void HUD::onWorldClicked(MyGUI::Widget* _sender)
|
|||
mDragAndDrop->mDraggedWidget = 0;
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->setDragDrop(false);
|
||||
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->drawItems();
|
||||
}
|
||||
else
|
||||
{
|
||||
GuiMode mode = MWBase::Environment::get().getWindowManager()->getMode();
|
||||
|
||||
if ( (mode != GM_Console) && (mode != GM_Container) && (mode != GM_Inventory) )
|
||||
return;
|
||||
|
||||
std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle();
|
||||
MWWorld::Ptr object;
|
||||
try
|
||||
{
|
||||
object = MWBase::Environment::get().getWorld()->getPtrViaHandle(handle);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode == GM_Console)
|
||||
MWBase::Environment::get().getWindowManager()->getConsole()->setSelectedObject(object);
|
||||
else if ((mode == GM_Container) || (mode == GM_Inventory))
|
||||
{
|
||||
// pick up object
|
||||
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->pickUpObject(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,6 +301,8 @@ void HUD::onWorldMouseOver(MyGUI::Widget* _sender, int x, int y)
|
|||
{
|
||||
if (mDragAndDrop->mIsOnDragAndDrop)
|
||||
{
|
||||
mWorldMouseOver = false;
|
||||
|
||||
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
MyGUI::IntPoint cursorPosition = MyGUI::InputManager::getInstance().getMousePosition();
|
||||
float mouseX = cursorPosition.left / float(viewSize.width);
|
||||
|
@ -290,13 +322,14 @@ void HUD::onWorldMouseOver(MyGUI::Widget* _sender, int x, int y)
|
|||
else
|
||||
{
|
||||
MyGUI::PointerManager::getInstance().setPointer("arrow");
|
||||
/// \todo make it possible to pick up objects with the mouse, if inventory or container window is open
|
||||
mWorldMouseOver = true;
|
||||
}
|
||||
}
|
||||
|
||||
void HUD::onWorldMouseLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new)
|
||||
{
|
||||
MyGUI::PointerManager::getInstance().setPointer("arrow");
|
||||
mWorldMouseOver = false;
|
||||
}
|
||||
|
||||
void HUD::onHMSClicked(MyGUI::Widget* _sender)
|
||||
|
|
|
@ -33,6 +33,8 @@ namespace MWGui
|
|||
|
||||
void setCellName(const std::string& cellName);
|
||||
|
||||
bool getWorldMouseOver() { return mWorldMouseOver; }
|
||||
|
||||
MyGUI::ProgressPtr health, magicka, stamina;
|
||||
MyGUI::Widget* mHealthFrame;
|
||||
MyGUI::Widget *weapBox, *spellBox;
|
||||
|
@ -70,6 +72,8 @@ namespace MWGui
|
|||
bool mWeaponVisible;
|
||||
bool mSpellVisible;
|
||||
|
||||
bool mWorldMouseOver;
|
||||
|
||||
void onWorldClicked(MyGUI::Widget* _sender);
|
||||
void onWorldMouseOver(MyGUI::Widget* _sender, int x, int y);
|
||||
void onWorldMouseLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new);
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "../mwworld/player.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwworld/manualref.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
#include "window_manager.hpp"
|
||||
#include "widgets.hpp"
|
||||
|
@ -276,13 +278,65 @@ namespace MWGui
|
|||
if (mWindowManager.getSpellWindow())
|
||||
mWindowManager.getSpellWindow()->updateSpells();
|
||||
|
||||
// update selected weapon icon
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
|
||||
MWWorld::ContainerStoreIterator weaponSlot = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
if (weaponSlot == invStore.end())
|
||||
mWindowManager.unsetSelectedWeapon();
|
||||
else
|
||||
mWindowManager.setSelectedWeapon(*weaponSlot, 100); /// \todo track weapon durability
|
||||
// update selected weapon icon
|
||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
|
||||
MWWorld::ContainerStoreIterator weaponSlot = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
if (weaponSlot == invStore.end())
|
||||
mWindowManager.unsetSelectedWeapon();
|
||||
else
|
||||
mWindowManager.setSelectedWeapon(*weaponSlot, 100); /// \todo track weapon durability
|
||||
}
|
||||
|
||||
void InventoryWindow::pickUpObject (MWWorld::Ptr object)
|
||||
{
|
||||
/// \todo scripts
|
||||
|
||||
// make sure the object is of a type that can be picked up
|
||||
std::string type = object.getTypeName();
|
||||
if ( (type != typeid(ESM::Apparatus).name())
|
||||
&& (type != typeid(ESM::Armor).name())
|
||||
&& (type != typeid(ESM::Book).name())
|
||||
&& (type != typeid(ESM::Clothing).name())
|
||||
&& (type != typeid(ESM::Ingredient).name())
|
||||
&& (type != typeid(ESM::Light).name())
|
||||
&& (type != typeid(ESM::Miscellaneous).name())
|
||||
&& (type != typeid(ESM::Tool).name())
|
||||
&& (type != typeid(ESM::Probe).name())
|
||||
&& (type != typeid(ESM::Repair).name())
|
||||
&& (type != typeid(ESM::Potion).name()))
|
||||
return;
|
||||
|
||||
// sound
|
||||
std::string sound = MWWorld::Class::get(object).getUpSoundId(object);
|
||||
MWBase::Environment::get().getSoundManager()->playSound(sound, 1, 1);
|
||||
|
||||
int count = object.getRefData().getCount();
|
||||
MWWorld::ActionTake action(object);
|
||||
action.execute();
|
||||
mDragAndDrop->mIsOnDragAndDrop = true;
|
||||
mDragAndDrop->mDraggedCount = count;
|
||||
|
||||
std::string path = std::string("icons\\");
|
||||
path += MWWorld::Class::get(object).getInventoryIcon(object);
|
||||
MyGUI::ImageBox* baseWidget = mContainerWidget->createWidget<ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 42, 42), MyGUI::Align::Default);
|
||||
baseWidget->detachFromWidget();
|
||||
baseWidget->attachToWidget(mDragAndDrop->mDragAndDropWidget);
|
||||
baseWidget->setUserData(object);
|
||||
mDragAndDrop->mDraggedWidget = baseWidget;
|
||||
ImageBox* image = baseWidget->createWidget<ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||
int pos = path.rfind(".");
|
||||
path.erase(pos);
|
||||
path.append(".dds");
|
||||
image->setImageTexture(path);
|
||||
image->setNeedMouseFocus(false);
|
||||
|
||||
// text widget that shows item count
|
||||
MyGUI::TextBox* text = image->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(0, 14, 32, 18), MyGUI::Align::Default, std::string("Label"));
|
||||
text->setTextAlign(MyGUI::Align::Right);
|
||||
text->setNeedMouseFocus(false);
|
||||
text->setTextShadow(true);
|
||||
text->setTextShadowColour(MyGUI::Colour(0,0,0));
|
||||
text->setCaption(getCountString(count));
|
||||
mDragAndDrop->mDraggedFrom = this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ namespace MWGui
|
|||
|
||||
void onFrame();
|
||||
|
||||
void pickUpObject (MWWorld::Ptr object);
|
||||
|
||||
int getPlayerGold();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -89,6 +89,16 @@ namespace MWGui
|
|||
|
||||
bool allowSelectedItem = true;
|
||||
|
||||
// make sure that the item is still in the player inventory, otherwise it can't be selected
|
||||
bool found = false;
|
||||
for (MWWorld::ContainerStoreIterator it(store.begin()); it != store.end(); ++it)
|
||||
{
|
||||
if (*it == selectedItem)
|
||||
found = true;
|
||||
}
|
||||
if (!found)
|
||||
allowSelectedItem = false;
|
||||
|
||||
// if the selected item can be equipped, make sure that it actually is equipped
|
||||
std::pair<std::vector<int>, bool> slots;
|
||||
slots = MWWorld::Class::get(selectedItem).getEquipmentSlots(selectedItem);
|
||||
|
|
|
@ -67,158 +67,193 @@ void ToolTips::onFrame(float frameDuration)
|
|||
if (!mGameMode)
|
||||
{
|
||||
const MyGUI::IntPoint& mousePos = InputManager::getInstance().getMousePosition();
|
||||
const MyGUI::IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left);
|
||||
|
||||
if (mousePos == lastPressed) // mouseclick makes tooltip disappear
|
||||
return;
|
||||
|
||||
if (mousePos.left == mLastMouseX && mousePos.top == mLastMouseY)
|
||||
if (mWindowManager->getWorldMouseOver() && ((mWindowManager->getMode() == GM_Console)
|
||||
|| (mWindowManager->getMode() == GM_Container)
|
||||
|| (mWindowManager->getMode() == GM_Inventory)))
|
||||
{
|
||||
mRemainingDelay -= frameDuration;
|
||||
std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle();
|
||||
try
|
||||
{
|
||||
mFocusObject = MWBase::Environment::get().getWorld()->getPtrViaHandle(handle);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MyGUI::IntSize tooltipSize = getToolTipViaPtr(true);
|
||||
|
||||
IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24);
|
||||
|
||||
// make the tooltip stay completely in the viewport
|
||||
if ((tooltipPosition.left + tooltipSize.width) > viewSize.width)
|
||||
{
|
||||
tooltipPosition.left = viewSize.width - tooltipSize.width;
|
||||
}
|
||||
if ((tooltipPosition.top + tooltipSize.height) > viewSize.height)
|
||||
{
|
||||
tooltipPosition.top = viewSize.height - tooltipSize.height;
|
||||
}
|
||||
|
||||
setCoord(tooltipPosition.left, tooltipPosition.top, tooltipSize.width, tooltipSize.height);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
mRemainingDelay = mDelay;
|
||||
}
|
||||
mLastMouseX = mousePos.left;
|
||||
mLastMouseY = mousePos.top;
|
||||
const MyGUI::IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left);
|
||||
|
||||
if (mRemainingDelay > 0)
|
||||
return;
|
||||
|
||||
Widget* focus = InputManager::getInstance().getMouseFocusWidget();
|
||||
if (focus == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IntSize tooltipSize;
|
||||
|
||||
// try to go 1 level up until there is a widget that has tooltip
|
||||
// this is necessary because some skin elements are actually separate widgets
|
||||
int i=0;
|
||||
while (!focus->isUserString("ToolTipType"))
|
||||
{
|
||||
focus = focus->getParent();
|
||||
if (!focus)
|
||||
if (mousePos == lastPressed) // mouseclick makes tooltip disappear
|
||||
return;
|
||||
++i;
|
||||
}
|
||||
|
||||
std::string type = focus->getUserString("ToolTipType");
|
||||
std::string text = focus->getUserString("ToolTipText");
|
||||
|
||||
ToolTipInfo info;
|
||||
if (type == "")
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (type == "ItemPtr")
|
||||
{
|
||||
mFocusObject = *focus->getUserData<MWWorld::Ptr>();
|
||||
tooltipSize = getToolTipViaPtr(false);
|
||||
}
|
||||
else if (type == "Spell")
|
||||
{
|
||||
ToolTipInfo info;
|
||||
const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.find(focus->getUserString("Spell"));
|
||||
info.caption = spell->name;
|
||||
Widgets::SpellEffectList effects;
|
||||
std::vector<ESM::ENAMstruct>::const_iterator end = spell->effects.list.end();
|
||||
for (std::vector<ESM::ENAMstruct>::const_iterator it = spell->effects.list.begin(); it != end; ++it)
|
||||
if (mousePos.left == mLastMouseX && mousePos.top == mLastMouseY)
|
||||
{
|
||||
Widgets::SpellEffectParams params;
|
||||
params.mEffectID = it->effectID;
|
||||
params.mSkill = it->skill;
|
||||
params.mAttribute = it->attribute;
|
||||
params.mDuration = it->duration;
|
||||
params.mMagnMin = it->magnMin;
|
||||
params.mMagnMax = it->magnMax;
|
||||
params.mRange = it->range;
|
||||
params.mIsConstant = (spell->data.type == ESM::Spell::ST_Ability);
|
||||
effects.push_back(params);
|
||||
}
|
||||
info.effects = effects;
|
||||
tooltipSize = createToolTip(info);
|
||||
}
|
||||
else if (type == "Layout")
|
||||
{
|
||||
// tooltip defined in the layout
|
||||
MyGUI::Widget* tooltip;
|
||||
getWidget(tooltip, focus->getUserString("ToolTipLayout"));
|
||||
|
||||
tooltip->setVisible(true);
|
||||
if (!tooltip->isUserString("DontResize"))
|
||||
{
|
||||
tooltip->setCoord(0, 0, 450, 300); // this is the maximum width of the tooltip before it starts word-wrapping
|
||||
|
||||
tooltipSize = MyGUI::IntSize(0, tooltip->getSize().height);
|
||||
mRemainingDelay -= frameDuration;
|
||||
}
|
||||
else
|
||||
tooltipSize = tooltip->getSize();
|
||||
|
||||
std::map<std::string, std::string> userStrings = focus->getUserStrings();
|
||||
for (std::map<std::string, std::string>::iterator it = userStrings.begin();
|
||||
it != userStrings.end(); ++it)
|
||||
{
|
||||
if (it->first == "ToolTipType"
|
||||
|| it->first == "ToolTipLayout")
|
||||
continue;
|
||||
mRemainingDelay = mDelay;
|
||||
}
|
||||
mLastMouseX = mousePos.left;
|
||||
mLastMouseY = mousePos.top;
|
||||
|
||||
if (mRemainingDelay > 0)
|
||||
return;
|
||||
|
||||
size_t underscorePos = it->first.find("_");
|
||||
std::string propertyKey = it->first.substr(0, underscorePos);
|
||||
std::string widgetName = it->first.substr(underscorePos+1, it->first.size()-(underscorePos+1));
|
||||
|
||||
MyGUI::Widget* w;
|
||||
getWidget(w, widgetName);
|
||||
w->setProperty(propertyKey, it->second);
|
||||
Widget* focus = InputManager::getInstance().getMouseFocusWidget();
|
||||
if (focus == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i<tooltip->getChildCount(); ++i)
|
||||
IntSize tooltipSize;
|
||||
|
||||
// try to go 1 level up until there is a widget that has tooltip
|
||||
// this is necessary because some skin elements are actually separate widgets
|
||||
int i=0;
|
||||
while (!focus->isUserString("ToolTipType"))
|
||||
{
|
||||
MyGUI::Widget* w = tooltip->getChildAt(i);
|
||||
|
||||
if (w->isUserString("AutoResizeHorizontal"))
|
||||
{
|
||||
MyGUI::TextBox* text = w->castType<MyGUI::TextBox>();
|
||||
tooltipSize.width = std::max(tooltipSize.width, w->getLeft() + text->getTextSize().width + 8);
|
||||
}
|
||||
else if (!tooltip->isUserString("DontResize"))
|
||||
tooltipSize.width = std::max(tooltipSize.width, w->getLeft() + w->getWidth() + 8);
|
||||
|
||||
if (w->isUserString("AutoResizeVertical"))
|
||||
{
|
||||
MyGUI::TextBox* text = w->castType<MyGUI::TextBox>();
|
||||
int height = text->getTextSize().height;
|
||||
if (height > w->getHeight())
|
||||
{
|
||||
tooltipSize += MyGUI::IntSize(0, height - w->getHeight());
|
||||
}
|
||||
if (height < w->getHeight())
|
||||
{
|
||||
tooltipSize -= MyGUI::IntSize(0, w->getHeight() - height);
|
||||
}
|
||||
}
|
||||
focus = focus->getParent();
|
||||
if (!focus)
|
||||
return;
|
||||
++i;
|
||||
}
|
||||
tooltip->setCoord(0, 0, tooltipSize.width, tooltipSize.height);
|
||||
}
|
||||
else
|
||||
throw std::runtime_error ("unknown tooltip type");
|
||||
|
||||
IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24);
|
||||
std::string type = focus->getUserString("ToolTipType");
|
||||
std::string text = focus->getUserString("ToolTipText");
|
||||
|
||||
// make the tooltip stay completely in the viewport
|
||||
if ((tooltipPosition.left + tooltipSize.width) > viewSize.width)
|
||||
{
|
||||
tooltipPosition.left = viewSize.width - tooltipSize.width;
|
||||
}
|
||||
if ((tooltipPosition.top + tooltipSize.height) > viewSize.height)
|
||||
{
|
||||
tooltipPosition.top = viewSize.height - tooltipSize.height;
|
||||
}
|
||||
ToolTipInfo info;
|
||||
if (type == "")
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (type == "ItemPtr")
|
||||
{
|
||||
mFocusObject = *focus->getUserData<MWWorld::Ptr>();
|
||||
tooltipSize = getToolTipViaPtr(false);
|
||||
}
|
||||
else if (type == "Spell")
|
||||
{
|
||||
ToolTipInfo info;
|
||||
const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.find(focus->getUserString("Spell"));
|
||||
info.caption = spell->name;
|
||||
Widgets::SpellEffectList effects;
|
||||
std::vector<ESM::ENAMstruct>::const_iterator end = spell->effects.list.end();
|
||||
for (std::vector<ESM::ENAMstruct>::const_iterator it = spell->effects.list.begin(); it != end; ++it)
|
||||
{
|
||||
Widgets::SpellEffectParams params;
|
||||
params.mEffectID = it->effectID;
|
||||
params.mSkill = it->skill;
|
||||
params.mAttribute = it->attribute;
|
||||
params.mDuration = it->duration;
|
||||
params.mMagnMin = it->magnMin;
|
||||
params.mMagnMax = it->magnMax;
|
||||
params.mRange = it->range;
|
||||
params.mIsConstant = (spell->data.type == ESM::Spell::ST_Ability);
|
||||
effects.push_back(params);
|
||||
}
|
||||
info.effects = effects;
|
||||
tooltipSize = createToolTip(info);
|
||||
}
|
||||
else if (type == "Layout")
|
||||
{
|
||||
// tooltip defined in the layout
|
||||
MyGUI::Widget* tooltip;
|
||||
getWidget(tooltip, focus->getUserString("ToolTipLayout"));
|
||||
|
||||
setCoord(tooltipPosition.left, tooltipPosition.top, tooltipSize.width, tooltipSize.height);
|
||||
tooltip->setVisible(true);
|
||||
if (!tooltip->isUserString("DontResize"))
|
||||
{
|
||||
tooltip->setCoord(0, 0, 450, 300); // this is the maximum width of the tooltip before it starts word-wrapping
|
||||
|
||||
tooltipSize = MyGUI::IntSize(0, tooltip->getSize().height);
|
||||
}
|
||||
else
|
||||
tooltipSize = tooltip->getSize();
|
||||
|
||||
std::map<std::string, std::string> userStrings = focus->getUserStrings();
|
||||
for (std::map<std::string, std::string>::iterator it = userStrings.begin();
|
||||
it != userStrings.end(); ++it)
|
||||
{
|
||||
if (it->first == "ToolTipType"
|
||||
|| it->first == "ToolTipLayout")
|
||||
continue;
|
||||
|
||||
|
||||
size_t underscorePos = it->first.find("_");
|
||||
std::string propertyKey = it->first.substr(0, underscorePos);
|
||||
std::string widgetName = it->first.substr(underscorePos+1, it->first.size()-(underscorePos+1));
|
||||
|
||||
MyGUI::Widget* w;
|
||||
getWidget(w, widgetName);
|
||||
w->setProperty(propertyKey, it->second);
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i<tooltip->getChildCount(); ++i)
|
||||
{
|
||||
MyGUI::Widget* w = tooltip->getChildAt(i);
|
||||
|
||||
if (w->isUserString("AutoResizeHorizontal"))
|
||||
{
|
||||
MyGUI::TextBox* text = w->castType<MyGUI::TextBox>();
|
||||
tooltipSize.width = std::max(tooltipSize.width, w->getLeft() + text->getTextSize().width + 8);
|
||||
}
|
||||
else if (!tooltip->isUserString("DontResize"))
|
||||
tooltipSize.width = std::max(tooltipSize.width, w->getLeft() + w->getWidth() + 8);
|
||||
|
||||
if (w->isUserString("AutoResizeVertical"))
|
||||
{
|
||||
MyGUI::TextBox* text = w->castType<MyGUI::TextBox>();
|
||||
int height = text->getTextSize().height;
|
||||
if (height > w->getHeight())
|
||||
{
|
||||
tooltipSize += MyGUI::IntSize(0, height - w->getHeight());
|
||||
}
|
||||
if (height < w->getHeight())
|
||||
{
|
||||
tooltipSize -= MyGUI::IntSize(0, w->getHeight() - height);
|
||||
}
|
||||
}
|
||||
}
|
||||
tooltip->setCoord(0, 0, tooltipSize.width, tooltipSize.height);
|
||||
}
|
||||
else
|
||||
throw std::runtime_error ("unknown tooltip type");
|
||||
|
||||
IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24);
|
||||
|
||||
// make the tooltip stay completely in the viewport
|
||||
if ((tooltipPosition.left + tooltipSize.width) > viewSize.width)
|
||||
{
|
||||
tooltipPosition.left = viewSize.width - tooltipSize.width;
|
||||
}
|
||||
if ((tooltipPosition.top + tooltipSize.height) > viewSize.height)
|
||||
{
|
||||
tooltipPosition.top = viewSize.height - tooltipSize.height;
|
||||
}
|
||||
|
||||
setCoord(tooltipPosition.left, tooltipPosition.top, tooltipSize.width, tooltipSize.height);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -300,6 +300,8 @@ namespace MWGui
|
|||
services = ref->base->AI.services;
|
||||
}
|
||||
|
||||
/// \todo what about potions, there doesn't seem to be a flag for them??
|
||||
|
||||
if (item.getTypeName() == typeid(ESM::Weapon).name())
|
||||
return services & ESM::NPC::Weapon;
|
||||
else if (item.getTypeName() == typeid(ESM::Armor).name())
|
||||
|
|
|
@ -487,6 +487,7 @@ void WindowManager::onFrame (float frameDuration)
|
|||
mDialogueWindow->checkReferenceAvailable();
|
||||
mTradeWindow->checkReferenceAvailable();
|
||||
mContainerWindow->checkReferenceAvailable();
|
||||
console->checkReferenceAvailable();
|
||||
}
|
||||
|
||||
const ESMS::ESMStore& WindowManager::getStore() const
|
||||
|
@ -637,6 +638,7 @@ void WindowManager::processChangedSettings(const Settings::CategorySettingVector
|
|||
hud->onResChange(x, y);
|
||||
console->onResChange(x, y);
|
||||
mSettingsWindow->center();
|
||||
mDragAndDrop->mDragAndDropWidget->setSize(MyGUI::IntSize(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -708,3 +710,25 @@ void WindowManager::unsetSelectedWeapon()
|
|||
hud->unsetSelectedWeapon();
|
||||
mInventoryWindow->setTitle("#{sSkillHandtohand}");
|
||||
}
|
||||
|
||||
void WindowManager::getMousePosition(int &x, int &y)
|
||||
{
|
||||
const MyGUI::IntPoint& pos = MyGUI::InputManager::getInstance().getMousePosition();
|
||||
x = pos.left;
|
||||
y = pos.top;
|
||||
}
|
||||
|
||||
void WindowManager::getMousePosition(float &x, float &y)
|
||||
{
|
||||
const MyGUI::IntPoint& pos = MyGUI::InputManager::getInstance().getMousePosition();
|
||||
x = pos.left;
|
||||
y = pos.top;
|
||||
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
x /= viewSize.width;
|
||||
y /= viewSize.height;
|
||||
}
|
||||
|
||||
bool WindowManager::getWorldMouseOver()
|
||||
{
|
||||
return hud->getWorldMouseOver();
|
||||
}
|
||||
|
|
|
@ -155,6 +155,7 @@ namespace MWGui
|
|||
MWGui::ConfirmationDialog* getConfirmationDialog() {return mConfirmationDialog;}
|
||||
MWGui::TradeWindow* getTradeWindow() {return mTradeWindow;}
|
||||
MWGui::SpellWindow* getSpellWindow() {return mSpellWindow;}
|
||||
MWGui::Console* getConsole() {return console;}
|
||||
|
||||
MyGUI::Gui* getGui() const { return gui; }
|
||||
|
||||
|
@ -188,7 +189,10 @@ namespace MWGui
|
|||
void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y);
|
||||
|
||||
void setMouseVisible(bool visible);
|
||||
void getMousePosition(int &x, int &y);
|
||||
void getMousePosition(float &x, float &y);
|
||||
void setDragDrop(bool dragDrop);
|
||||
bool getWorldMouseOver();
|
||||
|
||||
void toggleFogOfWar();
|
||||
void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
|
||||
|
|
|
@ -66,7 +66,23 @@ namespace MWWorld
|
|||
|
||||
return mEngine->rayTest2(from,to);
|
||||
}
|
||||
void PhysicsSystem::setCurrentWater(bool hasWater, int waterHeight){
|
||||
|
||||
std::vector < std::pair <float, std::string> > PhysicsSystem::getFacedObjects (float mouseX, float mouseY)
|
||||
{
|
||||
Ray ray = mRender.getCamera()->getCameraToViewportRay(mouseX, mouseY);
|
||||
Ogre::Vector3 from = ray.getOrigin();
|
||||
Ogre::Vector3 to = ray.getPoint(500); /// \todo make this distance (ray length) configurable
|
||||
|
||||
btVector3 _from, _to;
|
||||
// OGRE to MW coordinates
|
||||
_from = btVector3(from.x, -from.z, from.y);
|
||||
_to = btVector3(to.x, -to.z, to.y);
|
||||
|
||||
return mEngine->rayTest2(_from,_to);
|
||||
}
|
||||
|
||||
void PhysicsSystem::setCurrentWater(bool hasWater, int waterHeight)
|
||||
{
|
||||
playerphysics->hasWater = hasWater;
|
||||
if(hasWater){
|
||||
playerphysics->waterHeight = waterHeight;
|
||||
|
@ -84,6 +100,14 @@ namespace MWWorld
|
|||
return result;
|
||||
}
|
||||
|
||||
btVector3 PhysicsSystem::getRayPoint(float extent, float mouseX, float mouseY)
|
||||
{
|
||||
//get a ray pointing to the center of the viewport
|
||||
Ray centerRay = mRender.getCamera()->getCameraToViewportRay(mouseX, mouseY);
|
||||
btVector3 result(centerRay.getPoint(500*extent).x,-centerRay.getPoint(500*extent).z,centerRay.getPoint(500*extent).y); /// \todo make this distance (ray length) configurable
|
||||
return result;
|
||||
}
|
||||
|
||||
bool PhysicsSystem::castRay(const Vector3& from, const Vector3& to)
|
||||
{
|
||||
btVector3 _from, _to;
|
||||
|
|
|
@ -47,9 +47,12 @@ namespace MWWorld
|
|||
std::pair<std::string, float> getFacedHandle (MWWorld::World& world);
|
||||
|
||||
btVector3 getRayPoint(float extent);
|
||||
btVector3 getRayPoint(float extent, float mouseX, float mouseY);
|
||||
|
||||
std::vector < std::pair <float, std::string> > getFacedObjects ();
|
||||
|
||||
std::vector < std::pair <float, std::string> > getFacedObjects (float mouseX, float mouseY);
|
||||
|
||||
// cast ray, return true if it hit something
|
||||
bool castRay(const Ogre::Vector3& from, const Ogre::Vector3& to);
|
||||
|
||||
|
|
|
@ -818,7 +818,15 @@ namespace MWWorld
|
|||
|
||||
// send new query
|
||||
// figure out which object we want to test against
|
||||
std::vector < std::pair < float, std::string > > results = mPhysics->getFacedObjects();
|
||||
std::vector < std::pair < float, std::string > > results;
|
||||
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
{
|
||||
float x, y;
|
||||
MWBase::Environment::get().getWindowManager()->getMousePosition(x, y);
|
||||
results = mPhysics->getFacedObjects(x, y);
|
||||
}
|
||||
else
|
||||
results = mPhysics->getFacedObjects();
|
||||
|
||||
// ignore the player and other things we're not interested in
|
||||
std::vector < std::pair < float, std::string > >::iterator it = results.begin();
|
||||
|
@ -843,7 +851,15 @@ namespace MWWorld
|
|||
mFaced1Name = results.front().second;
|
||||
mNumFacing = 1;
|
||||
|
||||
btVector3 p = mPhysics->getRayPoint(results.front().first);
|
||||
btVector3 p;
|
||||
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
{
|
||||
float x, y;
|
||||
MWBase::Environment::get().getWindowManager()->getMousePosition(x, y);
|
||||
p = mPhysics->getRayPoint(results.front().first, x, y);
|
||||
}
|
||||
else
|
||||
p = mPhysics->getRayPoint(results.front().first);
|
||||
Ogre::Vector3 pos(p.x(), p.z(), -p.y());
|
||||
Ogre::SceneNode* node = mFaced1.getRefData().getBaseNode();
|
||||
|
||||
|
@ -860,7 +876,15 @@ namespace MWWorld
|
|||
mFaced2 = getPtrViaHandle(results[1].second);
|
||||
mNumFacing = 2;
|
||||
|
||||
btVector3 p = mPhysics->getRayPoint(results[1].first);
|
||||
btVector3 p;
|
||||
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
{
|
||||
float x, y;
|
||||
MWBase::Environment::get().getWindowManager()->getMousePosition(x, y);
|
||||
p = mPhysics->getRayPoint(results[1].first, x, y);
|
||||
}
|
||||
else
|
||||
p = mPhysics->getRayPoint(results[1].first);
|
||||
Ogre::Vector3 pos(p.x(), p.z(), -p.y());
|
||||
Ogre::SceneNode* node1 = mFaced1.getRefData().getBaseNode();
|
||||
Ogre::SceneNode* node2 = mFaced2.getRefData().getBaseNode();
|
||||
|
|
|
@ -1,41 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Skin">
|
||||
<Skin name = "MW_ConsoleWindow" size = "256 54">
|
||||
<Property key="TextAlign" value = "ALIGN_CENTER" />
|
||||
<Property key="TextColour" value = "0.8 0.8 0.8" />
|
||||
<Property key="Snap" value = "true" />
|
||||
|
||||
<Child type="Widget" skin="BlackBG" offset = "4 4 248 46" align = "ALIGN_STRETCH" name = "Client"/>
|
||||
|
||||
<!-- Outer borders -->
|
||||
<Child type="Widget" skin="TB_T" offset="4 0 248 4" align="ALIGN_TOP ALIGN_HSTRETCH" name="Action">
|
||||
<Property key="Scale" value = "0 1 0 -1"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_L" offset="0 4 4 46" align="ALIGN_LEFT ALIGN_VSTRETCH" name="Action">
|
||||
<Property key="Scale" value = "1 0 -1 0"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_B" offset="4 50 248 4" align="ALIGN_BOTTOM ALIGN_HSTRETCH" name="Action">
|
||||
<Property key="Scale" value = "0 0 0 1"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_R" offset="252 4 4 46" align="ALIGN_RIGHT ALIGN_VSTRETCH" name="Action">
|
||||
<Property key="Scale" value = "0 0 1 0"/>
|
||||
</Child>
|
||||
|
||||
<Child type="Widget" skin="TB_BR" offset="252 50 4 4" align="ALIGN_RIGHT ALIGN_BOTTOM" name="Action">
|
||||
<Property key="Scale" value = "0 0 1 1"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_BL" offset="0 50 4 4" align="ALIGN_LEFT ALIGN_BOTTOM" name="Action">
|
||||
<Property key="Scale" value = "1 0 -1 1"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_TR" offset="252 0 4 4" align="ALIGN_RIGHT ALIGN_TOP" name="Action">
|
||||
<Property key="Scale" value = "0 1 1 -1"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_TL" offset="0 0 4 4" align="ALIGN_LEFT ALIGN_TOP" name="Action">
|
||||
<Property key="Scale" value = "1 1 -1 -1"/>
|
||||
</Child>
|
||||
</Skin>
|
||||
|
||||
<Skin name = "MW_LogClient" size = "10 10">
|
||||
<Property key="FontName" value = "MonoFont" />
|
||||
<Property key="TextAlign" value = "Left Top" />
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="Window" skin="MW_ConsoleWindow" position="0 0 400 400" layer="Console" name="_Main">
|
||||
<Property key="Caption" value="Console"/>
|
||||
<Widget type="Window" skin="MW_Window" position="0 0 400 400" layer="Console" name="_Main">
|
||||
<Property key="Caption" value="#{sConsoleTitle}"/>
|
||||
<Property key="MinSize" value="200 100"/>
|
||||
<Property key="MaxSize" value="2000 2000"/>
|
||||
|
||||
<!-- Log window -->
|
||||
<Widget type="EditBox" skin="MW_ConsoleLog" position="5 5 390 360" align="Stretch" name="list_History">
|
||||
<Widget type="EditBox" skin="MW_ConsoleLog" position="5 5 380 330" align="Stretch" name="list_History">
|
||||
<Property key="MultiLine" value="1"/>
|
||||
</Widget>
|
||||
|
||||
<!-- Command line -->
|
||||
<Widget type="EditBox" skin="MW_ConsoleCommand" position="0 365 392 28" align="HStretch Bottom" name="edit_Command"/>
|
||||
<Widget type="EditBox" skin="MW_ConsoleCommand" position="0 335 382 28" align="HStretch Bottom" name="edit_Command"/>
|
||||
|
||||
</Widget>
|
||||
</MyGUI>
|
||||
|
|
Loading…
Reference in a new issue