mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 19:15:41 +00:00
Added MyGUI to OpenMW, fully working (with events and script hooks)
This commit is contained in:
parent
4d74f85ae0
commit
c84672a560
18 changed files with 354 additions and 202 deletions
|
@ -53,9 +53,11 @@ source_group(components\\esm FILES ${ESM_HEADER})
|
||||||
# components/mw_gui
|
# components/mw_gui
|
||||||
set(MWGUI_HEADER
|
set(MWGUI_HEADER
|
||||||
${COMP_DIR}/mwgui/mw_layouts.hpp
|
${COMP_DIR}/mwgui/mw_layouts.hpp
|
||||||
${COMP_DIR}/mwgui/guimanager.hpp)
|
${COMP_DIR}/mwgui/window_manager.hpp
|
||||||
|
)
|
||||||
set(MWGUI
|
set(MWGUI
|
||||||
${COMP_DIR}/mwgui/guimanager.cpp)
|
${COMP_DIR}/mwgui/window_manager.cpp
|
||||||
|
)
|
||||||
source_group(components\\mwgui FILES ${MWGUI_HEADER} ${MWGUI})
|
source_group(components\\mwgui FILES ${MWGUI_HEADER} ${MWGUI})
|
||||||
|
|
||||||
set(COMMANDSERVER
|
set(COMMANDSERVER
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
add_executable(mygui_test
|
add_executable(mygui_test
|
||||||
main.cpp
|
main.cpp
|
||||||
${BSA} ${BSA_HEADER}
|
${BSA} ${BSA_HEADER}
|
||||||
|
${MWGUI} ${MWGUI_HEADER}
|
||||||
${OENGINE_OGRE}
|
${OENGINE_OGRE}
|
||||||
${OENGINE_GUI}
|
${OENGINE_GUI}
|
||||||
${MANGLE_INPUT}
|
${MANGLE_INPUT}
|
||||||
|
|
|
@ -7,7 +7,7 @@ using namespace std;
|
||||||
|
|
||||||
#include <mangle/input/servers/ois_driver.hpp>
|
#include <mangle/input/servers/ois_driver.hpp>
|
||||||
|
|
||||||
#include <components/mwgui/mw_layouts.hpp>
|
#include <components/mwgui/window_manager.hpp>
|
||||||
#include <components/bsa/bsa_archive.hpp>
|
#include <components/bsa/bsa_archive.hpp>
|
||||||
|
|
||||||
#include <OgreResourceGroupManager.h>
|
#include <OgreResourceGroupManager.h>
|
||||||
|
@ -66,23 +66,14 @@ int main()
|
||||||
cout << "Setting up MyGUI\n";
|
cout << "Setting up MyGUI\n";
|
||||||
OEngine::GUI::MyGUIManager gui(ogre.getWindow(), ogre.getScene());
|
OEngine::GUI::MyGUIManager gui(ogre.getWindow(), ogre.getScene());
|
||||||
|
|
||||||
int w = ogre.getWindow()->getWidth();
|
|
||||||
int h = ogre.getWindow()->getHeight();
|
|
||||||
|
|
||||||
cout << "Connecting to input\n";
|
cout << "Connecting to input\n";
|
||||||
OEngine::GUI::EventInjector *evt = new OEngine::GUI::EventInjector(gui.getGui());
|
OEngine::GUI::EventInjector *evt = new OEngine::GUI::EventInjector(gui.getGui());
|
||||||
input.setEvent(Mangle::Input::EventPtr(evt));
|
input.setEvent(Mangle::Input::EventPtr(evt));
|
||||||
|
|
||||||
cout << "Setting up the window layouts\n";
|
cout << "Setting up the window manager\n";
|
||||||
MWGui::HUD hud(w,h);
|
MWGui::WindowManager gm(gui.getGui());
|
||||||
MWGui::MapWindow map;
|
|
||||||
MWGui::MainMenu menu(w,h);
|
|
||||||
MWGui::StatsWindow stats;
|
|
||||||
|
|
||||||
hud.setVisible(true);
|
gm.setMode(MWGui::GM_Inventory);
|
||||||
map.setVisible(true);
|
|
||||||
menu.setVisible(false);
|
|
||||||
stats.setVisible(true);
|
|
||||||
|
|
||||||
cout << "Starting rendering loop\n";
|
cout << "Starting rendering loop\n";
|
||||||
cout << "PRESS ESCAPE TO EXIT\n";
|
cout << "PRESS ESCAPE TO EXIT\n";
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
#include <components/misc/fileops.hpp>
|
#include <components/misc/fileops.hpp>
|
||||||
#include <components/bsa/bsa_archive.hpp>
|
#include <components/bsa/bsa_archive.hpp>
|
||||||
|
|
||||||
#include <components/mwgui/guimanager.hpp>
|
#include <openengine/gui/manager.hpp>
|
||||||
|
#include <components/mwgui/window_manager.hpp>
|
||||||
|
|
||||||
#include "mwinput/inputmanager.hpp"
|
#include "mwinput/inputmanager.hpp"
|
||||||
|
|
||||||
|
@ -81,8 +82,8 @@ OMW::Engine::~Engine()
|
||||||
if (mspCommandServer.get())
|
if (mspCommandServer.get())
|
||||||
mspCommandServer->stop();
|
mspCommandServer->stop();
|
||||||
|
|
||||||
|
delete mGuiManager;
|
||||||
delete mEnvironment.mWorld;
|
delete mEnvironment.mWorld;
|
||||||
delete mEnvironment.mGuiManager;
|
|
||||||
delete mEnvironment.mSoundManager;
|
delete mEnvironment.mSoundManager;
|
||||||
delete mEnvironment.mGlobalScripts;
|
delete mEnvironment.mGlobalScripts;
|
||||||
delete mScriptManager;
|
delete mScriptManager;
|
||||||
|
@ -174,11 +175,7 @@ void OMW::Engine::go()
|
||||||
assert (!mCellName.empty());
|
assert (!mCellName.empty());
|
||||||
assert (!mMaster.empty());
|
assert (!mMaster.empty());
|
||||||
|
|
||||||
std::cout << "Hello, fellow traveler!\n";
|
std::cout << "Data directory: " << mDataDir << "\n";
|
||||||
|
|
||||||
std::cout << "Your data directory for today is: " << mDataDir << "\n";
|
|
||||||
|
|
||||||
std::cout << "Initializing OGRE\n";
|
|
||||||
|
|
||||||
const char* plugCfg = "plugins.cfg";
|
const char* plugCfg = "plugins.cfg";
|
||||||
|
|
||||||
|
@ -187,6 +184,10 @@ void OMW::Engine::go()
|
||||||
addResourcesDirectory (mDataDir / "Meshes");
|
addResourcesDirectory (mDataDir / "Meshes");
|
||||||
addResourcesDirectory (mDataDir / "Textures");
|
addResourcesDirectory (mDataDir / "Textures");
|
||||||
|
|
||||||
|
// This has to be added BEFORE MyGUI is initialized, as it needs
|
||||||
|
// to find core.xml here.
|
||||||
|
addResourcesDirectory("resources/mygui/");
|
||||||
|
|
||||||
// Create the window
|
// Create the window
|
||||||
mOgre.createWindow("OpenMW");
|
mOgre.createWindow("OpenMW");
|
||||||
|
|
||||||
|
@ -195,7 +196,12 @@ void OMW::Engine::go()
|
||||||
// Create the world
|
// Create the world
|
||||||
mEnvironment.mWorld = new MWWorld::World (mOgre, mDataDir, mMaster, mCellName, mNewGame);
|
mEnvironment.mWorld = new MWWorld::World (mOgre, mDataDir, mMaster, mCellName, mNewGame);
|
||||||
|
|
||||||
mEnvironment.mGuiManager = new MWGui::GuiManager;
|
// Set up the GUI system
|
||||||
|
mGuiManager = new OEngine::GUI::MyGUIManager(mOgre.getWindow(),
|
||||||
|
mOgre.getScene());
|
||||||
|
|
||||||
|
// Create window manager - this manages all the MW-specific GUI windows
|
||||||
|
mEnvironment.mWindowManager = new MWGui::WindowManager(mGuiManager->getGui());
|
||||||
|
|
||||||
mEnvironment.mSoundManager = new MWSound::SoundManager;
|
mEnvironment.mSoundManager = new MWSound::SoundManager;
|
||||||
|
|
||||||
|
@ -211,10 +217,9 @@ void OMW::Engine::go()
|
||||||
mEnvironment.mGlobalScripts = new MWScript::GlobalScripts (mEnvironment.mWorld->getStore(),
|
mEnvironment.mGlobalScripts = new MWScript::GlobalScripts (mEnvironment.mWorld->getStore(),
|
||||||
*mScriptManager);
|
*mScriptManager);
|
||||||
|
|
||||||
std::cout << "Setting up input system\n";
|
|
||||||
|
|
||||||
// Sets up the input system
|
// Sets up the input system
|
||||||
MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(), mDebug);
|
MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(),
|
||||||
|
*mEnvironment.mWindowManager, mDebug);
|
||||||
|
|
||||||
// Launch the console server
|
// Launch the console server
|
||||||
if (mEnableCommandServer)
|
if (mEnableCommandServer)
|
||||||
|
@ -226,14 +231,14 @@ void OMW::Engine::go()
|
||||||
else
|
else
|
||||||
std::cout << "Command server disabled" << std::endl;
|
std::cout << "Command server disabled" << std::endl;
|
||||||
|
|
||||||
std::cout << "\nStart! Press Q/ESC or close window to exit.\n";
|
std::cout << "\nPress Q/ESC or close window to exit.\n";
|
||||||
|
|
||||||
mOgre.getRoot()->addFrameListener (this);
|
mOgre.getRoot()->addFrameListener (this);
|
||||||
|
|
||||||
// Start the main rendering loop
|
// Start the main rendering loop
|
||||||
mOgre.start();
|
mOgre.start();
|
||||||
|
|
||||||
std::cout << "\nThat's all for now!\n";
|
std::cout << "Quitting peacefully.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,19 @@ namespace MWWorld
|
||||||
class World;
|
class World;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace MWGui
|
||||||
|
{
|
||||||
|
class WindowManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace OEngine
|
||||||
|
{
|
||||||
|
namespace GUI
|
||||||
|
{
|
||||||
|
class MyGUIManager;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace OMW
|
namespace OMW
|
||||||
{
|
{
|
||||||
/// \brief Main engine class, that brings together all the components of OpenMW
|
/// \brief Main engine class, that brings together all the components of OpenMW
|
||||||
|
@ -59,6 +72,7 @@ namespace OMW
|
||||||
MWScript::ScriptManager *mScriptManager;
|
MWScript::ScriptManager *mScriptManager;
|
||||||
Compiler::Extensions mExtensions;
|
Compiler::Extensions mExtensions;
|
||||||
Compiler::Context *mScriptContext;
|
Compiler::Context *mScriptContext;
|
||||||
|
OEngine::GUI::MyGUIManager *mGuiManager;
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
Engine (const Engine&);
|
Engine (const Engine&);
|
||||||
|
|
|
@ -4,10 +4,14 @@
|
||||||
#include <openengine/input/dispatcher.hpp>
|
#include <openengine/input/dispatcher.hpp>
|
||||||
#include <openengine/input/poller.hpp>
|
#include <openengine/input/poller.hpp>
|
||||||
|
|
||||||
|
#include <openengine/gui/events.hpp>
|
||||||
|
|
||||||
#include <openengine/ogre/exitlistener.hpp>
|
#include <openengine/ogre/exitlistener.hpp>
|
||||||
#include <openengine/ogre/mouselook.hpp>
|
#include <openengine/ogre/mouselook.hpp>
|
||||||
#include <openengine/ogre/renderer.hpp>
|
#include <openengine/ogre/renderer.hpp>
|
||||||
|
|
||||||
|
#include <components/mwgui/window_manager.hpp>
|
||||||
|
|
||||||
#include <mangle/input/servers/ois_driver.hpp>
|
#include <mangle/input/servers/ois_driver.hpp>
|
||||||
#include <mangle/input/filters/eventlist.hpp>
|
#include <mangle/input/filters/eventlist.hpp>
|
||||||
|
|
||||||
|
@ -27,6 +31,8 @@ namespace MWInput
|
||||||
|
|
||||||
A_Screenshot, // Take a screenshot
|
A_Screenshot, // Take a screenshot
|
||||||
|
|
||||||
|
A_Inventory, // Toggle inventory screen
|
||||||
|
|
||||||
A_MoveLeft, // Move player left / right
|
A_MoveLeft, // Move player left / right
|
||||||
A_MoveRight,
|
A_MoveRight,
|
||||||
A_MoveUp, // Move up / down
|
A_MoveUp, // Move up / down
|
||||||
|
@ -46,10 +52,11 @@ namespace MWInput
|
||||||
Mangle::Input::OISDriver input;
|
Mangle::Input::OISDriver input;
|
||||||
OEngine::Input::Poller poller;
|
OEngine::Input::Poller poller;
|
||||||
OEngine::Render::MouseLookEventPtr mouse;
|
OEngine::Render::MouseLookEventPtr mouse;
|
||||||
|
OEngine::GUI::EventInjectorPtr guiEvents;
|
||||||
MWRender::PlayerPos &player;
|
MWRender::PlayerPos &player;
|
||||||
|
MWGui::WindowManager &windows;
|
||||||
|
|
||||||
// Count screenshots. TODO: We should move this functionality to
|
// Count screenshots.
|
||||||
// OgreRender or somewhere else.
|
|
||||||
int shotCount;
|
int shotCount;
|
||||||
|
|
||||||
// Write screenshot to file.
|
// Write screenshot to file.
|
||||||
|
@ -66,18 +73,67 @@ namespace MWInput
|
||||||
ogre.screenshot(buf);
|
ogre.screenshot(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Switch between gui modes. Besides controlling the Gui windows
|
||||||
|
// this also makes sure input is directed to the right place
|
||||||
|
void setGuiMode(MWGui::GuiMode mode)
|
||||||
|
{
|
||||||
|
// Tell the GUI what to show (this also takes care of the mouse
|
||||||
|
// pointer)
|
||||||
|
windows.setMode(mode);
|
||||||
|
|
||||||
|
// Are we in GUI mode now?
|
||||||
|
if(windows.isGuiMode())
|
||||||
|
{
|
||||||
|
// Disable mouse look
|
||||||
|
mouse->setCamera(NULL);
|
||||||
|
|
||||||
|
// Enable GUI events
|
||||||
|
guiEvents->enabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Start mouse-looking again. TODO: This should also allow
|
||||||
|
// for other ways to disable mouselook, like paralyzation.
|
||||||
|
mouse->setCamera(player.getCamera());
|
||||||
|
|
||||||
|
// Disable GUI events
|
||||||
|
guiEvents->enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the user presses the button to toggle the inventory
|
||||||
|
// screen.
|
||||||
|
void toggleInventory()
|
||||||
|
{
|
||||||
|
using namespace MWGui;
|
||||||
|
|
||||||
|
GuiMode mode = windows.getMode();
|
||||||
|
|
||||||
|
// Toggle between game mode and inventory mode
|
||||||
|
if(mode == GM_Game)
|
||||||
|
setGuiMode(GM_Inventory);
|
||||||
|
else if(mode == GM_Inventory)
|
||||||
|
setGuiMode(GM_Game);
|
||||||
|
|
||||||
|
// .. but don't touch any other mode.
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MWInputManager(OEngine::Render::OgreRenderer &_ogre,
|
MWInputManager(OEngine::Render::OgreRenderer &_ogre,
|
||||||
MWRender::PlayerPos &_player, bool debug)
|
MWRender::PlayerPos &_player,
|
||||||
|
MWGui::WindowManager &_windows,
|
||||||
|
bool debug)
|
||||||
: ogre(_ogre),
|
: ogre(_ogre),
|
||||||
exit(ogre.getWindow()),
|
exit(ogre.getWindow()),
|
||||||
input(ogre.getWindow(), !debug),
|
input(ogre.getWindow(), !debug),
|
||||||
poller(input),
|
poller(input),
|
||||||
player(_player),
|
player(_player),
|
||||||
|
windows(_windows),
|
||||||
shotCount(0)
|
shotCount(0)
|
||||||
{
|
{
|
||||||
using namespace OEngine::Input;
|
using namespace OEngine::Input;
|
||||||
using namespace OEngine::Render;
|
using namespace OEngine::Render;
|
||||||
|
using namespace OEngine::GUI;
|
||||||
using namespace Mangle::Input;
|
using namespace Mangle::Input;
|
||||||
using namespace OIS;
|
using namespace OIS;
|
||||||
|
|
||||||
|
@ -88,6 +144,8 @@ namespace MWInput
|
||||||
"Quit program");
|
"Quit program");
|
||||||
disp->funcs.bind(A_Screenshot, boost::bind(&MWInputManager::screenshot, this),
|
disp->funcs.bind(A_Screenshot, boost::bind(&MWInputManager::screenshot, this),
|
||||||
"Screenshot");
|
"Screenshot");
|
||||||
|
disp->funcs.bind(A_Inventory, boost::bind(&MWInputManager::toggleInventory, this),
|
||||||
|
"Toggle inventory screen");
|
||||||
|
|
||||||
|
|
||||||
// Add the exit listener
|
// Add the exit listener
|
||||||
|
@ -98,6 +156,9 @@ namespace MWInput
|
||||||
// Set up the mouse handler and tell it about the player camera
|
// Set up the mouse handler and tell it about the player camera
|
||||||
mouse = MouseLookEventPtr(new MouseLookEvent(player.getCamera()));
|
mouse = MouseLookEventPtr(new MouseLookEvent(player.getCamera()));
|
||||||
|
|
||||||
|
// This event handler pumps events into MyGUI
|
||||||
|
guiEvents = EventInjectorPtr(new EventInjector(windows.getGui()));
|
||||||
|
|
||||||
// Hook 'mouse' and 'disp' up as event handlers into 'input'
|
// Hook 'mouse' and 'disp' up as event handlers into 'input'
|
||||||
// (the OIS driver and event source.) We do this through an
|
// (the OIS driver and event source.) We do this through an
|
||||||
// EventList which dispatches the event to multiple handlers for
|
// EventList which dispatches the event to multiple handlers for
|
||||||
|
@ -107,12 +168,25 @@ namespace MWInput
|
||||||
input.setEvent(EventPtr(lst));
|
input.setEvent(EventPtr(lst));
|
||||||
lst->add(mouse,Event::EV_MouseMove);
|
lst->add(mouse,Event::EV_MouseMove);
|
||||||
lst->add(disp,Event::EV_KeyDown);
|
lst->add(disp,Event::EV_KeyDown);
|
||||||
|
lst->add(guiEvents,Event::EV_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Key bindings
|
// Start out in game mode
|
||||||
|
setGuiMode(MWGui::GM_Game);
|
||||||
|
|
||||||
|
/**********************************
|
||||||
|
Key binding section
|
||||||
|
|
||||||
|
The rest of this function has hard coded key bindings, and is
|
||||||
|
intended to be replaced by user defined bindings later.
|
||||||
|
**********************************/
|
||||||
|
|
||||||
|
// Key bindings for keypress events
|
||||||
|
|
||||||
disp->bind(A_Quit, KC_Q);
|
disp->bind(A_Quit, KC_Q);
|
||||||
disp->bind(A_Quit, KC_ESCAPE);
|
disp->bind(A_Quit, KC_ESCAPE);
|
||||||
disp->bind(A_Screenshot, KC_SYSRQ);
|
disp->bind(A_Screenshot, KC_SYSRQ);
|
||||||
|
disp->bind(A_Inventory, KC_I);
|
||||||
|
|
||||||
// Key bindings for polled keys
|
// Key bindings for polled keys
|
||||||
|
|
||||||
|
@ -139,6 +213,9 @@ namespace MWInput
|
||||||
// Tell OIS to handle all input events
|
// Tell OIS to handle all input events
|
||||||
input.capture();
|
input.capture();
|
||||||
|
|
||||||
|
// Disable movement in Gui mode
|
||||||
|
if(windows.isGuiMode()) return true;
|
||||||
|
|
||||||
float speed = 300 * evt.timeSinceLastFrame;
|
float speed = 300 * evt.timeSinceLastFrame;
|
||||||
float moveX = 0, moveY = 0, moveZ = 0;
|
float moveX = 0, moveY = 0, moveZ = 0;
|
||||||
|
|
||||||
|
|
|
@ -7,58 +7,38 @@
|
||||||
#include <components/interpreter/runtime.hpp>
|
#include <components/interpreter/runtime.hpp>
|
||||||
#include <components/interpreter/opcodes.hpp>
|
#include <components/interpreter/opcodes.hpp>
|
||||||
|
|
||||||
#include <components/mwgui/guimanager.hpp>
|
#include <components/mwgui/window_manager.hpp>
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
#include "interpretercontext.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
namespace Gui
|
namespace Gui
|
||||||
{
|
{
|
||||||
class OpEnableWindow : public Interpreter::Opcode0
|
class OpEnableWindow : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
MWGui::GuiManager::GuiWindow mWindow;
|
MWGui::GuiWindow mWindow;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
OpEnableWindow (MWGui::GuiManager::GuiWindow window) : mWindow (window) {}
|
OpEnableWindow (MWGui::GuiWindow window) : mWindow (window) {}
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
InterpreterContext& context =
|
InterpreterContext& context =
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
context.getGuiManager().enableWindow (mWindow);
|
context.getWindowManager().allow (mWindow);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpShowOneTimeDialogue : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
MWGui::GuiManager::GuiOneTimeDialogue mOneTimeDialogue;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpShowOneTimeDialogue (MWGui::GuiManager::GuiOneTimeDialogue OneTimeDialogue)
|
|
||||||
: mOneTimeDialogue (OneTimeDialogue)
|
|
||||||
{}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
InterpreterContext& context =
|
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
context.getGuiManager().showOneTimeDialogue (mOneTimeDialogue);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpShowDialogue : public Interpreter::Opcode0
|
class OpShowDialogue : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
MWGui::GuiManager::GuiDialogue mDialogue;
|
MWGui::GuiMode mDialogue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
OpShowDialogue (MWGui::GuiManager::GuiDialogue dialogue)
|
OpShowDialogue (MWGui::GuiMode dialogue)
|
||||||
: mDialogue (dialogue)
|
: mDialogue (dialogue)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -67,29 +47,10 @@ namespace MWScript
|
||||||
InterpreterContext& context =
|
InterpreterContext& context =
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
context.getGuiManager().enableDialogue (mDialogue);
|
context.getWindowManager().setMode(mDialogue);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpEnableDialogue : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
MWGui::GuiManager::GuiDialogue mDialogue;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpEnableDialogue (MWGui::GuiManager::GuiDialogue dialogue)
|
|
||||||
: mDialogue (dialogue)
|
|
||||||
{}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
InterpreterContext& context =
|
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
context.getGuiManager().showDialogue (mDialogue);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const int opcodeEnableBirthMenu = 0x200000e;
|
const int opcodeEnableBirthMenu = 0x200000e;
|
||||||
const int opcodeEnableClassMenu = 0x200000f;
|
const int opcodeEnableClassMenu = 0x200000f;
|
||||||
const int opcodeEnableNameMenu = 0x2000010;
|
const int opcodeEnableNameMenu = 0x2000010;
|
||||||
|
@ -125,30 +86,34 @@ namespace MWScript
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
{
|
{
|
||||||
interpreter.installSegment5 (opcodeEnableBirthMenu,
|
interpreter.installSegment5 (opcodeEnableBirthMenu,
|
||||||
new OpShowOneTimeDialogue (MWGui::GuiManager::Gui_Birth));
|
new OpShowDialogue (MWGui::GM_Birth));
|
||||||
interpreter.installSegment5 (opcodeEnableClassMenu,
|
interpreter.installSegment5 (opcodeEnableClassMenu,
|
||||||
new OpShowOneTimeDialogue (MWGui::GuiManager::Gui_Class));
|
new OpShowDialogue (MWGui::GM_Class));
|
||||||
interpreter.installSegment5 (opcodeEnableNameMenu,
|
interpreter.installSegment5 (opcodeEnableNameMenu,
|
||||||
new OpShowOneTimeDialogue (MWGui::GuiManager::Gui_Name));
|
new OpShowDialogue (MWGui::GM_Name));
|
||||||
interpreter.installSegment5 (opcodeEnableRaceMenu,
|
interpreter.installSegment5 (opcodeEnableRaceMenu,
|
||||||
new OpShowOneTimeDialogue (MWGui::GuiManager::Gui_Race));
|
new OpShowDialogue (MWGui::GM_Race));
|
||||||
interpreter.installSegment5 (opcodeEnableStatsReviewMenu,
|
interpreter.installSegment5 (opcodeEnableStatsReviewMenu,
|
||||||
new OpShowOneTimeDialogue (MWGui::GuiManager::Gui_Review));
|
new OpShowDialogue (MWGui::GM_Review));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeEnableInventoryMenu,
|
interpreter.installSegment5 (opcodeEnableInventoryMenu,
|
||||||
new OpEnableWindow (MWGui::GuiManager::Gui_Inventory));
|
new OpEnableWindow (MWGui::GW_Inventory));
|
||||||
interpreter.installSegment5 (opcodeEnableMagicMenu,
|
interpreter.installSegment5 (opcodeEnableMagicMenu,
|
||||||
new OpEnableWindow (MWGui::GuiManager:: Gui_Magic));
|
new OpEnableWindow (MWGui::GW_Magic));
|
||||||
interpreter.installSegment5 (opcodeEnableMapMenu,
|
interpreter.installSegment5 (opcodeEnableMapMenu,
|
||||||
new OpEnableWindow (MWGui::GuiManager::Gui_Map));
|
new OpEnableWindow (MWGui::GW_Map));
|
||||||
interpreter.installSegment5 (opcodeEnableStatsMenu,
|
interpreter.installSegment5 (opcodeEnableStatsMenu,
|
||||||
new OpEnableWindow (MWGui::GuiManager::Gui_Status));
|
new OpEnableWindow (MWGui::GW_Stats));
|
||||||
|
|
||||||
|
/* Not done yet. Enabling rest mode is not really a gui
|
||||||
|
issue, it's a gameplay issue.
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeEnableRest,
|
interpreter.installSegment5 (opcodeEnableRest,
|
||||||
new OpEnableDialogue (MWGui::GuiManager::Gui_Rest));
|
new OpEnableDialogue (MWGui::GM_Rest));
|
||||||
|
*/
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeShowRestMenu,
|
interpreter.installSegment5 (opcodeShowRestMenu,
|
||||||
new OpShowDialogue (MWGui::GuiManager::Gui_Rest));
|
new OpShowDialogue (MWGui::GM_Rest));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/world.hpp"
|
||||||
|
|
||||||
#include <components/mwgui/guimanager.hpp>
|
#include <components/mwgui/window_manager.hpp>
|
||||||
|
|
||||||
#include "locals.hpp"
|
#include "locals.hpp"
|
||||||
#include "globalscripts.hpp"
|
#include "globalscripts.hpp"
|
||||||
|
@ -112,7 +112,7 @@ namespace MWScript
|
||||||
|
|
||||||
bool InterpreterContext::menuMode()
|
bool InterpreterContext::menuMode()
|
||||||
{
|
{
|
||||||
return mEnvironment.mGuiManager->isGuiActive();
|
return mEnvironment.mWindowManager->isGuiMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterpreterContext::getGlobalShort (const std::string& name) const
|
int InterpreterContext::getGlobalShort (const std::string& name) const
|
||||||
|
@ -215,9 +215,9 @@ namespace MWScript
|
||||||
mEnvironment.mWorld->disable (ref);
|
mEnvironment.mWorld->disable (ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
MWGui::GuiManager& InterpreterContext::getGuiManager()
|
MWGui::WindowManager& InterpreterContext::getWindowManager()
|
||||||
{
|
{
|
||||||
return *mEnvironment.mGuiManager;
|
return *mEnvironment.mWindowManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::World& InterpreterContext::getWorld()
|
MWWorld::World& InterpreterContext::getWorld()
|
||||||
|
|
|
@ -84,7 +84,7 @@ namespace MWScript
|
||||||
|
|
||||||
MWSound::SoundManager& getSoundManager();
|
MWSound::SoundManager& getSoundManager();
|
||||||
|
|
||||||
MWGui::GuiManager& getGuiManager();
|
MWGui::WindowManager& getWindowManager();
|
||||||
|
|
||||||
MWWorld::Ptr getReference();
|
MWWorld::Ptr getReference();
|
||||||
///< Reference, that the script is running from (can be empty)
|
///< Reference, that the script is running from (can be empty)
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace MWScript
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
class GuiManager;
|
class WindowManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
|
@ -25,13 +25,13 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Environment()
|
Environment()
|
||||||
: mWorld (0), mSoundManager (0), mGlobalScripts (0), mGuiManager (0), mFrameDuration (0)
|
: mWorld (0), mSoundManager (0), mGlobalScripts (0), mWindowManager (0), mFrameDuration (0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
World *mWorld;
|
World *mWorld;
|
||||||
MWSound::SoundManager *mSoundManager;
|
MWSound::SoundManager *mSoundManager;
|
||||||
MWScript::GlobalScripts *mGlobalScripts;
|
MWScript::GlobalScripts *mGlobalScripts;
|
||||||
MWGui::GuiManager *mGuiManager;
|
MWGui::WindowManager *mWindowManager;
|
||||||
float mFrameDuration;
|
float mFrameDuration;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,8 +175,6 @@ namespace MWWorld
|
||||||
*reinterpret_cast<Interpreter::Type_Data *> (&newGameState);
|
*reinterpret_cast<Interpreter::Type_Data *> (&newGameState);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "\nSetting up cell rendering\n";
|
|
||||||
|
|
||||||
// This connects the cell data with the rendering scene.
|
// This connects the cell data with the rendering scene.
|
||||||
mActiveCells.insert (std::make_pair (&mInteriors[startCell],
|
mActiveCells.insert (std::make_pair (&mInteriors[startCell],
|
||||||
new MWRender::InteriorCellRender (mInteriors[startCell], mScene)));
|
new MWRender::InteriorCellRender (mInteriors[startCell], mScene)));
|
||||||
|
|
|
@ -6,6 +6,7 @@ using namespace std;
|
||||||
using namespace ESM;
|
using namespace ESM;
|
||||||
using namespace ESMS;
|
using namespace ESMS;
|
||||||
|
|
||||||
|
/*
|
||||||
static string toStr(int i)
|
static string toStr(int i)
|
||||||
{
|
{
|
||||||
char name[5];
|
char name[5];
|
||||||
|
@ -13,6 +14,7 @@ static string toStr(int i)
|
||||||
name[4] = 0;
|
name[4] = 0;
|
||||||
return std::string(name);
|
return std::string(name);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void ESMStore::load(ESMReader &esm)
|
void ESMStore::load(ESMReader &esm)
|
||||||
{
|
{
|
||||||
|
@ -44,6 +46,9 @@ void ESMStore::load(ESMReader &esm)
|
||||||
all[id] = n.val;
|
all[id] = n.val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This information isn't needed on screen. But keep the code around
|
||||||
|
for debugging purposes later.
|
||||||
|
|
||||||
cout << "\n" << recLists.size() << " record types:\n";
|
cout << "\n" << recLists.size() << " record types:\n";
|
||||||
for(RecListList::iterator it = recLists.begin(); it != recLists.end(); it++)
|
for(RecListList::iterator it = recLists.begin(); it != recLists.end(); it++)
|
||||||
cout << " " << toStr(it->first) << ": " << it->second->getSize() << endl;
|
cout << " " << toStr(it->first) << ": " << it->second->getSize() << endl;
|
||||||
|
@ -52,4 +57,5 @@ void ESMStore::load(ESMReader &esm)
|
||||||
it != missing.end(); it++ )
|
it != missing.end(); it++ )
|
||||||
cout << *it << " ";
|
cout << *it << " ";
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
|
|
||||||
#include "guimanager.hpp"
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "mw_layouts.hpp"
|
|
||||||
|
|
||||||
namespace MWGui
|
|
||||||
{
|
|
||||||
void GuiManager::enableWindow (GuiWindow window)
|
|
||||||
{
|
|
||||||
std::cout << "enable window: " << window << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GuiManager::showOneTimeDialogue (GuiOneTimeDialogue dialogue)
|
|
||||||
{
|
|
||||||
std::cout << "show one time dialogue: " << dialogue << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GuiManager::enableDialogue (GuiDialogue dialogue)
|
|
||||||
{
|
|
||||||
std::cout << "enable dialogue: " << dialogue << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GuiManager::showDialogue (GuiDialogue dialogue)
|
|
||||||
{
|
|
||||||
std::cout << "show dialogue: " << dialogue << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GuiManager::isGuiActive() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
#ifndef GAME_SOUND_GUIMANAGER_H
|
|
||||||
#define GAME_SOUND_GUIMANAGER_H
|
|
||||||
|
|
||||||
namespace MWGui
|
|
||||||
{
|
|
||||||
// Predeclarations, these are defined in mw_layouts.hpp
|
|
||||||
class HUD;
|
|
||||||
class MapWindow;
|
|
||||||
class MainMenu;
|
|
||||||
class StatsWindow;
|
|
||||||
|
|
||||||
class GuiManager
|
|
||||||
{
|
|
||||||
HUD *hud;
|
|
||||||
MapWindow *map;
|
|
||||||
MainMenu *menu;
|
|
||||||
StatsWindow *stats;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
enum GuiWindow
|
|
||||||
{
|
|
||||||
Gui_Inventory, Gui_Magic, Gui_Map, Gui_Status
|
|
||||||
};
|
|
||||||
|
|
||||||
enum GuiOneTimeDialogue // used only once
|
|
||||||
{
|
|
||||||
// character generation
|
|
||||||
Gui_Birth, Gui_Class, Gui_Name, Gui_Race, Gui_Review
|
|
||||||
};
|
|
||||||
|
|
||||||
enum GuiDialogue
|
|
||||||
{
|
|
||||||
Gui_Rest
|
|
||||||
};
|
|
||||||
|
|
||||||
void enableWindow (GuiWindow window);
|
|
||||||
///< diabled by default.
|
|
||||||
|
|
||||||
void showOneTimeDialogue (GuiOneTimeDialogue dialogue);
|
|
||||||
|
|
||||||
void enableDialogue (GuiDialogue dialogue);
|
|
||||||
///< disabled by default.
|
|
||||||
|
|
||||||
void showDialogue (GuiDialogue dialogue);
|
|
||||||
|
|
||||||
bool isGuiActive() const;
|
|
||||||
///< Any non-HUD GUI element active (dialogues and windows)?
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
74
components/mwgui/window_manager.cpp
Normal file
74
components/mwgui/window_manager.cpp
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
#include "window_manager.hpp"
|
||||||
|
#include "mw_layouts.hpp"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
using namespace MWGui;
|
||||||
|
|
||||||
|
WindowManager::WindowManager(MyGUI::Gui *_gui)
|
||||||
|
: gui(_gui), mode(GM_Game), shown(GW_ALL), allowed(GW_ALL)
|
||||||
|
{
|
||||||
|
// Get size info from the Gui object
|
||||||
|
assert(gui);
|
||||||
|
int w = gui->getViewWidth();
|
||||||
|
int h = gui->getViewHeight();
|
||||||
|
|
||||||
|
hud = new HUD(w,h);
|
||||||
|
menu = new MainMenu(w,h);
|
||||||
|
map = new MapWindow();
|
||||||
|
stats = new StatsWindow();
|
||||||
|
|
||||||
|
// The HUD is always on
|
||||||
|
hud->setVisible(true);
|
||||||
|
|
||||||
|
// Set up visibility
|
||||||
|
updateVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
WindowManager::~WindowManager()
|
||||||
|
{
|
||||||
|
delete hud;
|
||||||
|
delete map;
|
||||||
|
delete menu;
|
||||||
|
delete stats;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowManager::updateVisible()
|
||||||
|
{
|
||||||
|
// Start out by hiding everything except the HUD
|
||||||
|
map->setVisible(false);
|
||||||
|
menu->setVisible(false);
|
||||||
|
stats->setVisible(false);
|
||||||
|
|
||||||
|
// Mouse is visible whenever we're not in game mode
|
||||||
|
gui->setVisiblePointer(isGuiMode());
|
||||||
|
|
||||||
|
// If in game mode, don't show anything.
|
||||||
|
if(mode == GM_Game)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mode == GM_MainMenu)
|
||||||
|
{
|
||||||
|
// Enable the main menu
|
||||||
|
menu->setVisible(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mode == GM_Inventory)
|
||||||
|
{
|
||||||
|
// Ah, inventory mode. First, compute the effective set of
|
||||||
|
// windows to show. This is controlled both by what windows the
|
||||||
|
// user has opened/closed (the 'shown' variable) and by what
|
||||||
|
// windows we are allowed to show (the 'allowed' var.)
|
||||||
|
int eff = shown & allowed;
|
||||||
|
|
||||||
|
// Show the windows we want
|
||||||
|
map -> setVisible( eff & GW_Map );
|
||||||
|
stats -> setVisible( eff & GW_Stats );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// All other modes are ignored
|
||||||
|
}
|
121
components/mwgui/window_manager.hpp
Normal file
121
components/mwgui/window_manager.hpp
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
#ifndef MWGUI_WINDOWMANAGER_H
|
||||||
|
#define MWGUI_WINDOWMANAGER_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
This class owns and controls all the MW specific windows in the
|
||||||
|
GUI. It can enable/disable Gui mode, and is responsible for sending
|
||||||
|
and retrieving information from the Gui.
|
||||||
|
|
||||||
|
MyGUI should be initialized separately before creating instances of
|
||||||
|
this class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace MyGUI
|
||||||
|
{
|
||||||
|
class Gui;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWGui
|
||||||
|
{
|
||||||
|
class HUD;
|
||||||
|
class MapWindow;
|
||||||
|
class MainMenu;
|
||||||
|
class StatsWindow;
|
||||||
|
|
||||||
|
enum GuiMode
|
||||||
|
{
|
||||||
|
GM_Game, // Game mode, only HUD
|
||||||
|
GM_Inventory, // Inventory mode
|
||||||
|
GM_MainMenu, // Main menu mode
|
||||||
|
|
||||||
|
// None of the following are implemented yet
|
||||||
|
|
||||||
|
GM_Dialogue, // NPC interaction
|
||||||
|
GM_Barter,
|
||||||
|
GM_Rest,
|
||||||
|
// .. more here ..
|
||||||
|
|
||||||
|
// Startup character creation dialogs
|
||||||
|
GM_Name,
|
||||||
|
GM_Race,
|
||||||
|
GM_Birth,
|
||||||
|
GM_Class,
|
||||||
|
GM_Review
|
||||||
|
};
|
||||||
|
|
||||||
|
// Windows shown in inventory mode
|
||||||
|
enum GuiWindow
|
||||||
|
{
|
||||||
|
GW_None = 0,
|
||||||
|
|
||||||
|
GW_Map = 0x01,
|
||||||
|
GW_Inventory = 0x02,
|
||||||
|
GW_Magic = 0x04,
|
||||||
|
GW_Stats = 0x08,
|
||||||
|
|
||||||
|
GW_ALL = 0xFF
|
||||||
|
};
|
||||||
|
|
||||||
|
class WindowManager
|
||||||
|
{
|
||||||
|
HUD *hud;
|
||||||
|
MapWindow *map;
|
||||||
|
MainMenu *menu;
|
||||||
|
StatsWindow *stats;
|
||||||
|
|
||||||
|
MyGUI::Gui *gui;
|
||||||
|
|
||||||
|
// Current gui mode
|
||||||
|
GuiMode mode;
|
||||||
|
|
||||||
|
// Currently shown windows in inventory mode
|
||||||
|
GuiWindow shown;
|
||||||
|
|
||||||
|
/* Currently ALLOWED windows in inventory mode. This is used at
|
||||||
|
the start of the game, when windows are enabled one by one
|
||||||
|
through script commands. You can manipulate this through using
|
||||||
|
allow() and disableAll().
|
||||||
|
|
||||||
|
The setting should also affect visibility of certain HUD
|
||||||
|
elements, but this is not done yet.
|
||||||
|
*/
|
||||||
|
GuiWindow allowed;
|
||||||
|
|
||||||
|
// Update visibility of all windows based on mode, shown and
|
||||||
|
// allowed settings.
|
||||||
|
void updateVisible();
|
||||||
|
|
||||||
|
public:
|
||||||
|
/// The constructor needs the main Gui object
|
||||||
|
WindowManager(MyGUI::Gui *_gui);
|
||||||
|
virtual ~WindowManager();
|
||||||
|
|
||||||
|
void setMode(GuiMode newMode)
|
||||||
|
{
|
||||||
|
mode = newMode;
|
||||||
|
updateVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiMode getMode() const { return mode; }
|
||||||
|
|
||||||
|
// Everything that is not game mode is considered "gui mode"
|
||||||
|
bool isGuiMode() const { return getMode() != GM_Game; }
|
||||||
|
|
||||||
|
// Disallow all inventory mode windows
|
||||||
|
void disallowAll()
|
||||||
|
{
|
||||||
|
allowed = GW_None;
|
||||||
|
updateVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow one or more windows
|
||||||
|
void allow(GuiWindow wnd)
|
||||||
|
{
|
||||||
|
allowed = (GuiWindow)(allowed | wnd);
|
||||||
|
updateVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
MyGUI::Gui* getGui() const { return gui; }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -1 +1 @@
|
||||||
Subproject commit fedb1a80256a093511075aeb88408c7c56a136ce
|
Subproject commit 82a3c071e56f2df451618e1371424c39aa299690
|
16
testall.sh
16
testall.sh
|
@ -1,16 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
function run()
|
|
||||||
{
|
|
||||||
echo
|
|
||||||
echo "$1/tests/:"
|
|
||||||
cd "$1/tests/"
|
|
||||||
./test.sh
|
|
||||||
cd ../../
|
|
||||||
}
|
|
||||||
|
|
||||||
run tools
|
|
||||||
run input
|
|
||||||
run bsa
|
|
||||||
run nif
|
|
||||||
run nifogre
|
|
Loading…
Reference in a new issue