forked from teamnwah/openmw-tes3coop
basic tooltips
This commit is contained in:
parent
0c6862e3e6
commit
cac662ca98
8 changed files with 136 additions and 9 deletions
|
@ -25,7 +25,7 @@ add_openmw_dir (mwinput
|
|||
add_openmw_dir (mwgui
|
||||
layouts text_input widgets race class birth review window_manager console dialogue
|
||||
dialogue_history window_base stats_window messagebox journalwindow charactercreation
|
||||
map_window window_pinnable_base cursorreplace
|
||||
map_window window_pinnable_base cursorreplace tooltips
|
||||
)
|
||||
|
||||
add_openmw_dir (mwdialogue
|
||||
|
|
|
@ -133,14 +133,6 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
|||
if (mUseSound)
|
||||
mEnvironment.mSoundManager->update (evt.timeSinceLastFrame);
|
||||
|
||||
// update GUI
|
||||
Ogre::RenderWindow* window = mOgre->getWindow();
|
||||
mEnvironment.mWindowManager->wmUpdateFps(window->getLastFPS(),
|
||||
window->getTriangleCount(),
|
||||
window->getBatchCount());
|
||||
|
||||
mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration);
|
||||
|
||||
// global scripts
|
||||
mEnvironment.mGlobalScripts->run (mEnvironment);
|
||||
|
||||
|
@ -171,6 +163,14 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
|||
// update world
|
||||
mEnvironment.mWorld->update (evt.timeSinceLastFrame);
|
||||
|
||||
// update GUI
|
||||
Ogre::RenderWindow* window = mOgre->getWindow();
|
||||
mEnvironment.mWindowManager->wmUpdateFps(window->getLastFPS(),
|
||||
window->getTriangleCount(),
|
||||
window->getBatchCount());
|
||||
|
||||
mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration);
|
||||
|
||||
// report focus object (for debugging)
|
||||
if (mReportFocus)
|
||||
updateFocusReport (mEnvironment.mFrameDuration);
|
||||
|
|
63
apps/openmw/mwgui/tooltips.cpp
Normal file
63
apps/openmw/mwgui/tooltips.cpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
#include "tooltips.hpp"
|
||||
|
||||
using namespace MWGui;
|
||||
using namespace MyGUI;
|
||||
|
||||
ToolTips::ToolTips() :
|
||||
Layout("openmw_tooltips.xml")
|
||||
, mGameMode(true)
|
||||
{
|
||||
getWidget(mTextToolTip, "TextToolTip");
|
||||
getWidget(mTextToolTipBox, "TextToolTipBox");
|
||||
getWidget(mDynamicToolTipBox, "DynamicToolTipBox");
|
||||
|
||||
mDynamicToolTipBox->setVisible(false);
|
||||
|
||||
// turn off mouse focus so that getMouseFocusWidget returns the correct widget,
|
||||
// even if the mouse is over the tooltip
|
||||
mDynamicToolTipBox->setNeedMouseFocus(false);
|
||||
mTextToolTipBox->setNeedMouseFocus(false);
|
||||
mTextToolTip->setNeedMouseFocus(false);
|
||||
mMainWidget->setNeedMouseFocus(false);
|
||||
}
|
||||
|
||||
void ToolTips::onFrame(float frameDuration)
|
||||
{
|
||||
/// \todo Store a MWWorld::Ptr in the widget user data, retrieve it here and construct a tooltip dynamically
|
||||
|
||||
const IntSize &viewSize = RenderManager::getInstance().getViewSize();
|
||||
|
||||
Widget* focus = InputManager::getInstance().getMouseFocusWidget();
|
||||
if (focus == 0) return;
|
||||
|
||||
// this the maximum width of the tooltip before it starts word-wrapping
|
||||
setCoord(0, 0, 300, 300);
|
||||
|
||||
mTextToolTip->setCaption("Focused: " + focus->getName() + "\nType: " + focus->getTypeName());
|
||||
const IntSize &textSize = mTextToolTip->getTextSize();
|
||||
|
||||
IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24);
|
||||
|
||||
IntSize size = textSize + IntSize(12, 12);
|
||||
// make the tooltip stay completely in the viewport
|
||||
if ((tooltipPosition.left + size.width) > viewSize.width)
|
||||
{
|
||||
tooltipPosition.left = viewSize.width - size.width;
|
||||
}
|
||||
if ((tooltipPosition.top + size.height) > viewSize.height)
|
||||
{
|
||||
tooltipPosition.top = viewSize.height - size.height;
|
||||
}
|
||||
|
||||
setCoord(tooltipPosition.left, tooltipPosition.top, size.width, size.height);
|
||||
}
|
||||
|
||||
void ToolTips::enterGameMode()
|
||||
{
|
||||
mGameMode = true;
|
||||
}
|
||||
|
||||
void ToolTips::enterGuiMode()
|
||||
{
|
||||
mGameMode = false;
|
||||
}
|
30
apps/openmw/mwgui/tooltips.hpp
Normal file
30
apps/openmw/mwgui/tooltips.hpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
|
||||
#ifndef MWGUI_TOOLTIPS_H
|
||||
#define MWGUI_TOOLTIPS_H
|
||||
|
||||
#include <openengine/gui/layout.hpp>
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
class ToolTips : public OEngine::GUI::Layout
|
||||
{
|
||||
public:
|
||||
ToolTips();
|
||||
|
||||
void onFrame(float frameDuration);
|
||||
|
||||
void enterGameMode();
|
||||
void enterGuiMode();
|
||||
|
||||
void adjustScreen(int screenWidth, int screenHeight);
|
||||
|
||||
private:
|
||||
MyGUI::EditBox* mTextToolTip;
|
||||
MyGUI::Widget* mTextToolTipBox;
|
||||
|
||||
MyGUI::Widget* mDynamicToolTipBox;
|
||||
|
||||
bool mGameMode;
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -7,6 +7,7 @@
|
|||
#include "map_window.hpp"
|
||||
#include "stats_window.hpp"
|
||||
#include "messagebox.hpp"
|
||||
#include "tooltips.hpp"
|
||||
|
||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||
#include "../mwinput/inputmanager.hpp"
|
||||
|
@ -31,6 +32,7 @@ WindowManager::WindowManager(MWWorld::Environment& environment,
|
|||
, map(NULL)
|
||||
, menu(NULL)
|
||||
, stats(NULL)
|
||||
, mToolTips(NULL)
|
||||
, mMessageBoxManager(NULL)
|
||||
, console(NULL)
|
||||
, mJournal(NULL)
|
||||
|
@ -80,6 +82,7 @@ WindowManager::WindowManager(MWWorld::Environment& environment,
|
|||
mJournal = new JournalWindow(*this);
|
||||
mMessageBoxManager = new MessageBoxManager(this);
|
||||
dialogueWindow = new DialogueWindow(*this,environment);
|
||||
mToolTips = new ToolTips();
|
||||
|
||||
// The HUD is always on
|
||||
hud->setVisible(true);
|
||||
|
@ -118,6 +121,7 @@ WindowManager::~WindowManager()
|
|||
delete stats;
|
||||
delete mJournal;
|
||||
delete dialogueWindow;
|
||||
delete mToolTips;
|
||||
|
||||
delete mCharGen;
|
||||
|
||||
|
@ -183,6 +187,11 @@ void WindowManager::updateVisible()
|
|||
// Mouse is visible whenever we're not in game mode
|
||||
MyGUI::PointerManager::getInstance().setVisible(isGuiMode());
|
||||
|
||||
if (mode == GM_Game)
|
||||
mToolTips->enterGameMode();
|
||||
else
|
||||
mToolTips->enterGuiMode();
|
||||
|
||||
switch(mode) {
|
||||
case GM_Game:
|
||||
// If in game mode, don't show anything.
|
||||
|
@ -408,6 +417,7 @@ void WindowManager::onDialogueWindowBye()
|
|||
void WindowManager::onFrame (float frameDuration)
|
||||
{
|
||||
mMessageBoxManager->onFrame(frameDuration);
|
||||
mToolTips->onFrame(frameDuration);
|
||||
}
|
||||
|
||||
const ESMS::ESMStore& WindowManager::getStore() const
|
||||
|
|
|
@ -62,6 +62,7 @@ namespace MWGui
|
|||
class Console;
|
||||
class JournalWindow;
|
||||
class CharacterCreation;
|
||||
class ToolTips;
|
||||
|
||||
class TextInputDialog;
|
||||
class InfoBoxDialog;
|
||||
|
@ -196,6 +197,7 @@ namespace MWGui
|
|||
HUD *hud;
|
||||
MapWindow *map;
|
||||
MainMenu *menu;
|
||||
ToolTips *mToolTips;
|
||||
StatsWindow *stats;
|
||||
MessageBoxManager *mMessageBoxManager;
|
||||
Console *console;
|
||||
|
|
|
@ -50,6 +50,7 @@ configure_file("${SDIR}/openmw_messagebox_layout.xml" "${DDIR}/openmw_messagebox
|
|||
configure_file("${SDIR}/openmw_interactive_messagebox_layout.xml" "${DDIR}/openmw_interactive_messagebox_layout.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_journal_layout.xml" "${DDIR}/openmw_journal_layout.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_journal_skin.xml" "${DDIR}/openmw_journal_skin.xml" COPYONLY)
|
||||
configure_file("${SDIR}/openmw_tooltips.xml" "${DDIR}/openmw_tooltips.xml" COPYONLY)
|
||||
configure_file("${SDIR}/smallbars.png" "${DDIR}/smallbars.png" COPYONLY)
|
||||
configure_file("${SDIR}/transparent.png" "${DDIR}/transparent.png" COPYONLY)
|
||||
configure_file("${SDIR}/EBGaramond-Regular.ttf" "${DDIR}/EBGaramond-Regular.ttf" COPYONLY)
|
||||
|
|
21
files/mygui/openmw_tooltips.xml
Normal file
21
files/mygui/openmw_tooltips.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="Widget" layer="Popup" position="0 0 300 200" name="_Main">
|
||||
|
||||
<!-- Simple text-only tooltip -->
|
||||
<Widget type="Widget" skin="HUD_Box" position="0 0 300 200" align="Stretch" name="TextToolTipBox">
|
||||
<Widget type="EditBox" skin="MW_TextEdit" position="0 0 300 200" align="Stretch" name="TextToolTip">
|
||||
<Property key="WordWrap" value="true"/>
|
||||
<Property key="Static" value="true"/>
|
||||
<Property key="TextAlign" value="Left Top"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<!-- Dynamically constructed tooltip goes here -->
|
||||
<Widget type="Widget" skin="HUD_Box" position="0 0 300 200" align="Stretch" name="DynamicToolTipBox">
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
</MyGUI>
|
||||
|
Loading…
Reference in a new issue