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()
|
void Console::disable()
|
||||||
{
|
{
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
setSelectedObject(MWWorld::Ptr());
|
||||||
// Remove keyboard focus from the console input whenever the
|
// Remove keyboard focus from the console input whenever the
|
||||||
// console is turned off
|
// console is turned off
|
||||||
MyGUI::InputManager::getInstance().setKeyFocusWidget(NULL);
|
MyGUI::InputManager::getInstance().setKeyFocusWidget(NULL);
|
||||||
|
@ -240,7 +241,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ConsoleInterpreterContext interpreterContext (*this, MWWorld::Ptr());
|
ConsoleInterpreterContext interpreterContext (*this, mPtr);
|
||||||
Interpreter::Interpreter interpreter;
|
Interpreter::Interpreter interpreter;
|
||||||
MWScript::installOpcodes (interpreter);
|
MWScript::installOpcodes (interpreter);
|
||||||
std::vector<Interpreter::Type_Code> code;
|
std::vector<Interpreter::Type_Code> code;
|
||||||
|
@ -375,4 +376,18 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
setCoord(10,10, width-10, height/2);
|
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/compilercontext.hpp"
|
||||||
#include "../mwscript/interpretercontext.hpp"
|
#include "../mwscript/interpretercontext.hpp"
|
||||||
|
|
||||||
|
#include "referenceinterface.hpp"
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
class Console : private OEngine::GUI::Layout, private Compiler::ErrorHandler
|
class Console : private OEngine::GUI::Layout, private Compiler::ErrorHandler, public ReferenceInterface
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -39,6 +41,16 @@ namespace MWGui
|
||||||
/// \note The list may contain duplicates (if a name is a keyword and an identifier at the same
|
/// \note The list may contain duplicates (if a name is a keyword and an identifier at the same
|
||||||
/// time).
|
/// time).
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
void setSelectedObject(const MWWorld::Ptr& object);
|
||||||
|
///< Set the implicit object for script execution
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual void onReferenceUnavailable();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MyGUI::EditPtr command;
|
MyGUI::EditPtr command;
|
||||||
MyGUI::EditPtr history;
|
MyGUI::EditPtr history;
|
||||||
|
|
|
@ -12,8 +12,10 @@
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/world.hpp"
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
|
#include "inventorywindow.hpp"
|
||||||
#include "window_manager.hpp"
|
#include "window_manager.hpp"
|
||||||
#include "container.hpp"
|
#include "container.hpp"
|
||||||
|
#include "console.hpp"
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
|
||||||
|
@ -46,6 +48,7 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
|
||||||
, mMapVisible(true)
|
, mMapVisible(true)
|
||||||
, mWeaponVisible(true)
|
, mWeaponVisible(true)
|
||||||
, mSpellVisible(true)
|
, mSpellVisible(true)
|
||||||
|
, mWorldMouseOver(false)
|
||||||
{
|
{
|
||||||
setCoord(0,0, width, height);
|
setCoord(0,0, width, height);
|
||||||
|
|
||||||
|
@ -264,6 +267,33 @@ void HUD::onWorldClicked(MyGUI::Widget* _sender)
|
||||||
mDragAndDrop->mDraggedWidget = 0;
|
mDragAndDrop->mDraggedWidget = 0;
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->setDragDrop(false);
|
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)
|
if (mDragAndDrop->mIsOnDragAndDrop)
|
||||||
{
|
{
|
||||||
|
mWorldMouseOver = false;
|
||||||
|
|
||||||
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||||
MyGUI::IntPoint cursorPosition = MyGUI::InputManager::getInstance().getMousePosition();
|
MyGUI::IntPoint cursorPosition = MyGUI::InputManager::getInstance().getMousePosition();
|
||||||
float mouseX = cursorPosition.left / float(viewSize.width);
|
float mouseX = cursorPosition.left / float(viewSize.width);
|
||||||
|
@ -290,13 +322,14 @@ void HUD::onWorldMouseOver(MyGUI::Widget* _sender, int x, int y)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MyGUI::PointerManager::getInstance().setPointer("arrow");
|
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)
|
void HUD::onWorldMouseLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new)
|
||||||
{
|
{
|
||||||
MyGUI::PointerManager::getInstance().setPointer("arrow");
|
MyGUI::PointerManager::getInstance().setPointer("arrow");
|
||||||
|
mWorldMouseOver = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HUD::onHMSClicked(MyGUI::Widget* _sender)
|
void HUD::onHMSClicked(MyGUI::Widget* _sender)
|
||||||
|
|
|
@ -33,6 +33,8 @@ namespace MWGui
|
||||||
|
|
||||||
void setCellName(const std::string& cellName);
|
void setCellName(const std::string& cellName);
|
||||||
|
|
||||||
|
bool getWorldMouseOver() { return mWorldMouseOver; }
|
||||||
|
|
||||||
MyGUI::ProgressPtr health, magicka, stamina;
|
MyGUI::ProgressPtr health, magicka, stamina;
|
||||||
MyGUI::Widget* mHealthFrame;
|
MyGUI::Widget* mHealthFrame;
|
||||||
MyGUI::Widget *weapBox, *spellBox;
|
MyGUI::Widget *weapBox, *spellBox;
|
||||||
|
@ -70,6 +72,8 @@ namespace MWGui
|
||||||
bool mWeaponVisible;
|
bool mWeaponVisible;
|
||||||
bool mSpellVisible;
|
bool mSpellVisible;
|
||||||
|
|
||||||
|
bool mWorldMouseOver;
|
||||||
|
|
||||||
void onWorldClicked(MyGUI::Widget* _sender);
|
void onWorldClicked(MyGUI::Widget* _sender);
|
||||||
void onWorldMouseOver(MyGUI::Widget* _sender, int x, int y);
|
void onWorldMouseOver(MyGUI::Widget* _sender, int x, int y);
|
||||||
void onWorldMouseLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new);
|
void onWorldMouseLostFocus(MyGUI::Widget* _sender, MyGUI::Widget* _new);
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwworld/manualref.hpp"
|
#include "../mwworld/manualref.hpp"
|
||||||
|
#include "../mwworld/actiontake.hpp"
|
||||||
|
#include "../mwsound/soundmanager.hpp"
|
||||||
|
|
||||||
#include "window_manager.hpp"
|
#include "window_manager.hpp"
|
||||||
#include "widgets.hpp"
|
#include "widgets.hpp"
|
||||||
|
@ -283,6 +285,58 @@ namespace MWGui
|
||||||
mWindowManager.unsetSelectedWeapon();
|
mWindowManager.unsetSelectedWeapon();
|
||||||
else
|
else
|
||||||
mWindowManager.setSelectedWeapon(*weaponSlot, 100); /// \todo track weapon durability
|
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 onFrame();
|
||||||
|
|
||||||
|
void pickUpObject (MWWorld::Ptr object);
|
||||||
|
|
||||||
int getPlayerGold();
|
int getPlayerGold();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -89,6 +89,16 @@ namespace MWGui
|
||||||
|
|
||||||
bool allowSelectedItem = true;
|
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
|
// if the selected item can be equipped, make sure that it actually is equipped
|
||||||
std::pair<std::vector<int>, bool> slots;
|
std::pair<std::vector<int>, bool> slots;
|
||||||
slots = MWWorld::Class::get(selectedItem).getEquipmentSlots(selectedItem);
|
slots = MWWorld::Class::get(selectedItem).getEquipmentSlots(selectedItem);
|
||||||
|
|
|
@ -67,6 +67,40 @@ void ToolTips::onFrame(float frameDuration)
|
||||||
if (!mGameMode)
|
if (!mGameMode)
|
||||||
{
|
{
|
||||||
const MyGUI::IntPoint& mousePos = InputManager::getInstance().getMousePosition();
|
const MyGUI::IntPoint& mousePos = InputManager::getInstance().getMousePosition();
|
||||||
|
|
||||||
|
if (mWindowManager->getWorldMouseOver() && ((mWindowManager->getMode() == GM_Console)
|
||||||
|
|| (mWindowManager->getMode() == GM_Container)
|
||||||
|
|| (mWindowManager->getMode() == GM_Inventory)))
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
const MyGUI::IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left);
|
const MyGUI::IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left);
|
||||||
|
|
||||||
if (mousePos == lastPressed) // mouseclick makes tooltip disappear
|
if (mousePos == lastPressed) // mouseclick makes tooltip disappear
|
||||||
|
@ -220,6 +254,7 @@ void ToolTips::onFrame(float frameDuration)
|
||||||
|
|
||||||
setCoord(tooltipPosition.left, tooltipPosition.top, tooltipSize.width, tooltipSize.height);
|
setCoord(tooltipPosition.left, tooltipPosition.top, tooltipSize.width, tooltipSize.height);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!mFocusObject.isEmpty())
|
if (!mFocusObject.isEmpty())
|
||||||
|
|
|
@ -300,6 +300,8 @@ namespace MWGui
|
||||||
services = ref->base->AI.services;
|
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())
|
if (item.getTypeName() == typeid(ESM::Weapon).name())
|
||||||
return services & ESM::NPC::Weapon;
|
return services & ESM::NPC::Weapon;
|
||||||
else if (item.getTypeName() == typeid(ESM::Armor).name())
|
else if (item.getTypeName() == typeid(ESM::Armor).name())
|
||||||
|
|
|
@ -487,6 +487,7 @@ void WindowManager::onFrame (float frameDuration)
|
||||||
mDialogueWindow->checkReferenceAvailable();
|
mDialogueWindow->checkReferenceAvailable();
|
||||||
mTradeWindow->checkReferenceAvailable();
|
mTradeWindow->checkReferenceAvailable();
|
||||||
mContainerWindow->checkReferenceAvailable();
|
mContainerWindow->checkReferenceAvailable();
|
||||||
|
console->checkReferenceAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
const ESMS::ESMStore& WindowManager::getStore() const
|
const ESMS::ESMStore& WindowManager::getStore() const
|
||||||
|
@ -637,6 +638,7 @@ void WindowManager::processChangedSettings(const Settings::CategorySettingVector
|
||||||
hud->onResChange(x, y);
|
hud->onResChange(x, y);
|
||||||
console->onResChange(x, y);
|
console->onResChange(x, y);
|
||||||
mSettingsWindow->center();
|
mSettingsWindow->center();
|
||||||
|
mDragAndDrop->mDragAndDropWidget->setSize(MyGUI::IntSize(x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,3 +710,25 @@ void WindowManager::unsetSelectedWeapon()
|
||||||
hud->unsetSelectedWeapon();
|
hud->unsetSelectedWeapon();
|
||||||
mInventoryWindow->setTitle("#{sSkillHandtohand}");
|
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::ConfirmationDialog* getConfirmationDialog() {return mConfirmationDialog;}
|
||||||
MWGui::TradeWindow* getTradeWindow() {return mTradeWindow;}
|
MWGui::TradeWindow* getTradeWindow() {return mTradeWindow;}
|
||||||
MWGui::SpellWindow* getSpellWindow() {return mSpellWindow;}
|
MWGui::SpellWindow* getSpellWindow() {return mSpellWindow;}
|
||||||
|
MWGui::Console* getConsole() {return console;}
|
||||||
|
|
||||||
MyGUI::Gui* getGui() const { return gui; }
|
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 setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y);
|
||||||
|
|
||||||
void setMouseVisible(bool visible);
|
void setMouseVisible(bool visible);
|
||||||
|
void getMousePosition(int &x, int &y);
|
||||||
|
void getMousePosition(float &x, float &y);
|
||||||
void setDragDrop(bool dragDrop);
|
void setDragDrop(bool dragDrop);
|
||||||
|
bool getWorldMouseOver();
|
||||||
|
|
||||||
void toggleFogOfWar();
|
void toggleFogOfWar();
|
||||||
void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
|
void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
|
||||||
|
|
|
@ -66,7 +66,23 @@ namespace MWWorld
|
||||||
|
|
||||||
return mEngine->rayTest2(from,to);
|
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;
|
playerphysics->hasWater = hasWater;
|
||||||
if(hasWater){
|
if(hasWater){
|
||||||
playerphysics->waterHeight = waterHeight;
|
playerphysics->waterHeight = waterHeight;
|
||||||
|
@ -84,6 +100,14 @@ namespace MWWorld
|
||||||
return result;
|
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)
|
bool PhysicsSystem::castRay(const Vector3& from, const Vector3& to)
|
||||||
{
|
{
|
||||||
btVector3 _from, _to;
|
btVector3 _from, _to;
|
||||||
|
|
|
@ -47,9 +47,12 @@ namespace MWWorld
|
||||||
std::pair<std::string, float> getFacedHandle (MWWorld::World& world);
|
std::pair<std::string, float> getFacedHandle (MWWorld::World& world);
|
||||||
|
|
||||||
btVector3 getRayPoint(float extent);
|
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 ();
|
||||||
|
|
||||||
|
std::vector < std::pair <float, std::string> > getFacedObjects (float mouseX, float mouseY);
|
||||||
|
|
||||||
// cast ray, return true if it hit something
|
// cast ray, return true if it hit something
|
||||||
bool castRay(const Ogre::Vector3& from, const Ogre::Vector3& to);
|
bool castRay(const Ogre::Vector3& from, const Ogre::Vector3& to);
|
||||||
|
|
||||||
|
|
|
@ -818,7 +818,15 @@ namespace MWWorld
|
||||||
|
|
||||||
// send new query
|
// send new query
|
||||||
// figure out which object we want to test against
|
// 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
|
// ignore the player and other things we're not interested in
|
||||||
std::vector < std::pair < float, std::string > >::iterator it = results.begin();
|
std::vector < std::pair < float, std::string > >::iterator it = results.begin();
|
||||||
|
@ -843,7 +851,15 @@ namespace MWWorld
|
||||||
mFaced1Name = results.front().second;
|
mFaced1Name = results.front().second;
|
||||||
mNumFacing = 1;
|
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::Vector3 pos(p.x(), p.z(), -p.y());
|
||||||
Ogre::SceneNode* node = mFaced1.getRefData().getBaseNode();
|
Ogre::SceneNode* node = mFaced1.getRefData().getBaseNode();
|
||||||
|
|
||||||
|
@ -860,7 +876,15 @@ namespace MWWorld
|
||||||
mFaced2 = getPtrViaHandle(results[1].second);
|
mFaced2 = getPtrViaHandle(results[1].second);
|
||||||
mNumFacing = 2;
|
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::Vector3 pos(p.x(), p.z(), -p.y());
|
||||||
Ogre::SceneNode* node1 = mFaced1.getRefData().getBaseNode();
|
Ogre::SceneNode* node1 = mFaced1.getRefData().getBaseNode();
|
||||||
Ogre::SceneNode* node2 = mFaced2.getRefData().getBaseNode();
|
Ogre::SceneNode* node2 = mFaced2.getRefData().getBaseNode();
|
||||||
|
|
|
@ -1,41 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<MyGUI type="Skin">
|
<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">
|
<Skin name = "MW_LogClient" size = "10 10">
|
||||||
<Property key="FontName" value = "MonoFont" />
|
<Property key="FontName" value = "MonoFont" />
|
||||||
<Property key="TextAlign" value = "Left Top" />
|
<Property key="TextAlign" value = "Left Top" />
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<MyGUI type="Layout">
|
<MyGUI type="Layout">
|
||||||
<Widget type="Window" skin="MW_ConsoleWindow" position="0 0 400 400" layer="Console" name="_Main">
|
<Widget type="Window" skin="MW_Window" position="0 0 400 400" layer="Console" name="_Main">
|
||||||
<Property key="Caption" value="Console"/>
|
<Property key="Caption" value="#{sConsoleTitle}"/>
|
||||||
<Property key="MinSize" value="200 100"/>
|
<Property key="MinSize" value="200 100"/>
|
||||||
<Property key="MaxSize" value="2000 2000"/>
|
<Property key="MaxSize" value="2000 2000"/>
|
||||||
|
|
||||||
<!-- Log window -->
|
<!-- 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"/>
|
<Property key="MultiLine" value="1"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
<!-- Command line -->
|
<!-- 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>
|
</Widget>
|
||||||
</MyGUI>
|
</MyGUI>
|
||||||
|
|
Loading…
Reference in a new issue