mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-06 17:15:35 +00:00
added script-gui interface and gui-related script instructions
This commit is contained in:
parent
2c63d67ceb
commit
0efe4742a6
10 changed files with 237 additions and 74 deletions
|
@ -40,6 +40,7 @@ set(GAMESCRIPT
|
||||||
apps/openmw/mwscript/interpretercontext.cpp
|
apps/openmw/mwscript/interpretercontext.cpp
|
||||||
apps/openmw/mwscript/cellextensions.cpp
|
apps/openmw/mwscript/cellextensions.cpp
|
||||||
apps/openmw/mwscript/miscextensions.cpp
|
apps/openmw/mwscript/miscextensions.cpp
|
||||||
|
apps/openmw/mwscript/guiextensions.cpp
|
||||||
apps/openmw/mwscript/extensions.cpp
|
apps/openmw/mwscript/extensions.cpp
|
||||||
apps/openmw/mwscript/globalscripts.cpp
|
apps/openmw/mwscript/globalscripts.cpp
|
||||||
)
|
)
|
||||||
|
@ -50,6 +51,7 @@ set(GAMESCRIPT_HEADER
|
||||||
apps/openmw/mwscript/interpretercontext.hpp
|
apps/openmw/mwscript/interpretercontext.hpp
|
||||||
apps/openmw/mwscript/cellextensions.hpp
|
apps/openmw/mwscript/cellextensions.hpp
|
||||||
apps/openmw/mwscript/miscextensions.hpp
|
apps/openmw/mwscript/miscextensions.hpp
|
||||||
|
apps/openmw/mwscript/guiextensions.hpp
|
||||||
apps/openmw/mwscript/extensions.hpp
|
apps/openmw/mwscript/extensions.hpp
|
||||||
apps/openmw/mwscript/globalscripts.hpp
|
apps/openmw/mwscript/globalscripts.hpp
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,61 +5,26 @@
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
void GuiManager::showBirthDialogue()
|
void GuiManager::enableWindow (GuiWindow window)
|
||||||
{
|
{
|
||||||
std::cout << "" << std::endl;
|
std::cout << "enable window: " << window << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiManager::showClassDialogue()
|
void GuiManager::showOneTimeDialogue (GuiOneTimeDialogue dialogue)
|
||||||
{
|
{
|
||||||
std::cout << "" << std::endl;
|
std::cout << "show one time dialogue: " << dialogue << std::endl;
|
||||||
}
|
|
||||||
|
|
||||||
void GuiManager::showNameDialogue()
|
|
||||||
{
|
|
||||||
std::cout << "" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GuiManager::showRaceDialogue()
|
|
||||||
{
|
|
||||||
std::cout << "" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiManager::showReviewDialogue()
|
void GuiManager::enableDialogue (GuiDialogue dialogue)
|
||||||
{
|
{
|
||||||
std::cout << "" << std::endl;
|
std::cout << "enable dialogue: " << dialogue << std::endl;
|
||||||
}
|
|
||||||
|
|
||||||
void GuiManager::enableInventoryWindow()
|
|
||||||
{
|
|
||||||
std::cout << "" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiManager::enableMagicWindow()
|
void GuiManager::showDialogue (GuiDialogue dialogue)
|
||||||
{
|
{
|
||||||
std::cout << "" << std::endl;
|
std::cout << "show dialogue: " << dialogue << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiManager::enableMapWindow()
|
|
||||||
{
|
|
||||||
std::cout << "" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GuiManager::enableStatsMenu()
|
|
||||||
{
|
|
||||||
std::cout << "" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GuiManager::enableLevelUpDialogue()
|
|
||||||
{
|
|
||||||
std::cout << "" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GuiManager::showRestDialogue()
|
|
||||||
{
|
|
||||||
std::cout << "" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GuiManager::isGuiActive() const
|
bool GuiManager::isGuiActive() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -7,38 +7,31 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void showBirthDialogue();
|
enum GuiWindow
|
||||||
///< Birthsign (part of the character generation process)
|
{
|
||||||
|
Gui_Inventory, Gui_Magic, Gui_Map, Gui_Status
|
||||||
|
};
|
||||||
|
|
||||||
void showClassDialogue();
|
enum GuiOneTimeDialogue // used only once
|
||||||
///< Class selection (part of the character generation process)
|
{
|
||||||
|
// character generation
|
||||||
|
Gui_Birth, Gui_Class, Gui_Name, Gui_Race, Gui_Review
|
||||||
|
};
|
||||||
|
|
||||||
|
enum GuiDialogue
|
||||||
|
{
|
||||||
|
Gui_Rest
|
||||||
|
};
|
||||||
|
|
||||||
void showNameDialogue();
|
void enableWindow (GuiWindow window);
|
||||||
///< Enter character name (part of the character generation process)
|
///< diabled by default.
|
||||||
|
|
||||||
void showRaceDialogue();
|
|
||||||
///< Race selection (part of the character generation process)
|
|
||||||
|
|
||||||
void showReviewDialogue();
|
void showOneTimeDialogue (GuiOneTimeDialogue dialogue);
|
||||||
///< Character generation review (final part of the character generation process)
|
|
||||||
|
|
||||||
void enableInventoryWindow();
|
|
||||||
///< Initially disabled.
|
|
||||||
|
|
||||||
void enableMagicWindow();
|
void enableDialogue (GuiDialogue dialogue);
|
||||||
///< Initially disabled.
|
///< disabled by default.
|
||||||
|
|
||||||
void enableMapWindow();
|
|
||||||
///< Initially disabled.
|
|
||||||
|
|
||||||
void enableStatsMenu();
|
|
||||||
///< Initially disabled.
|
|
||||||
|
|
||||||
void enableLevelUpDialogue();
|
void showDialogue (GuiDialogue dialogue);
|
||||||
///< Rest/Level-up. Initially disabled.
|
|
||||||
|
|
||||||
void showRestDialogue();
|
|
||||||
///< Rest dialogue: ask player how many hours he wants to sleep.
|
|
||||||
|
|
||||||
bool isGuiActive() const;
|
bool isGuiActive() const;
|
||||||
///< Any non-HUD GUI element active (dialogues and windows)?
|
///< Any non-HUD GUI element active (dialogues and windows)?
|
||||||
|
|
|
@ -35,5 +35,16 @@ op 0x200000a: StopSound
|
||||||
op 0x200000b: GetSoundPlaying
|
op 0x200000b: GetSoundPlaying
|
||||||
op 0x200000c: XBox (always 0)
|
op 0x200000c: XBox (always 0)
|
||||||
op 0x200000d: OnActivate
|
op 0x200000d: OnActivate
|
||||||
opcodes 0x200000e-0x3ffffff unused
|
op 0x200000e: EnableBirthMenu
|
||||||
|
op 0x200000f: EnableClassMenu
|
||||||
|
op 0x2000010: EnableNameMenu
|
||||||
|
op 0x2000011: EnableRaceMenu
|
||||||
|
op 0x2000012: EnableStatsReviewMenu
|
||||||
|
op 0x2000013: EnableInventoryMenu
|
||||||
|
op 0x2000014: EnableMagicMenu
|
||||||
|
op 0x2000015: EnableMapMenu
|
||||||
|
op 0x2000016: EnableStatsMenu
|
||||||
|
op 0x2000017: EnableRest
|
||||||
|
op 0x2000018: ShowRestMenu
|
||||||
|
opcodes 0x2000019-0x3ffffff unused
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include "cellextensions.hpp"
|
#include "cellextensions.hpp"
|
||||||
#include "miscextensions.hpp"
|
#include "miscextensions.hpp"
|
||||||
|
#include "guiextensions.hpp"
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
|
@ -12,6 +13,7 @@ namespace MWScript
|
||||||
{
|
{
|
||||||
Cell::registerExtensions (extensions);
|
Cell::registerExtensions (extensions);
|
||||||
Misc::registerExtensions (extensions);
|
Misc::registerExtensions (extensions);
|
||||||
|
Gui::registerExtensions (extensions);
|
||||||
MWSound::registerExtensions (extensions);
|
MWSound::registerExtensions (extensions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
153
apps/openmw/mwscript/guiextensions.cpp
Normal file
153
apps/openmw/mwscript/guiextensions.cpp
Normal file
|
@ -0,0 +1,153 @@
|
||||||
|
|
||||||
|
#include "guiextensions.hpp"
|
||||||
|
|
||||||
|
#include <components/compiler/extensions.hpp>
|
||||||
|
|
||||||
|
#include <components/interpreter/interpreter.hpp>
|
||||||
|
#include <components/interpreter/runtime.hpp>
|
||||||
|
#include <components/interpreter/opcodes.hpp>
|
||||||
|
|
||||||
|
#include "interpretercontext.hpp"
|
||||||
|
|
||||||
|
#include "../mwgui/guimanager.hpp"
|
||||||
|
|
||||||
|
namespace MWScript
|
||||||
|
{
|
||||||
|
namespace Gui
|
||||||
|
{
|
||||||
|
class OpEnableWindow : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
MWGui::GuiManager::GuiWindow mWindow;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
OpEnableWindow (MWGui::GuiManager::GuiWindow window) : mWindow (window) {}
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
InterpreterContext& context =
|
||||||
|
static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
context.getGuiManager().enableWindow (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
|
||||||
|
{
|
||||||
|
MWGui::GuiManager::GuiDialogue mDialogue;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
OpShowDialogue (MWGui::GuiManager::GuiDialogue dialogue)
|
||||||
|
: mDialogue (dialogue)
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
InterpreterContext& context =
|
||||||
|
static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
context.getGuiManager().enableDialogue (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 opcodeEnableClassMenu = 0x200000f;
|
||||||
|
const int opcodeEnableNameMenu = 0x2000010;
|
||||||
|
const int opcodeEnableRaceMenu = 0x2000011;
|
||||||
|
const int opcodeEnableStatsReviewMenu = 0x2000012;
|
||||||
|
const int opcodeEnableInventoryMenu = 0x2000013;
|
||||||
|
const int opcodeEnableMagicMenu = 0x2000014;
|
||||||
|
const int opcodeEnableMapMenu = 0x2000015;
|
||||||
|
const int opcodeEnableStatsMenu = 0x2000016;
|
||||||
|
const int opcodeEnableRest = 0x2000017;
|
||||||
|
const int opcodeShowRestMenu = 0x2000018;
|
||||||
|
|
||||||
|
void registerExtensions (Compiler::Extensions& extensions)
|
||||||
|
{
|
||||||
|
extensions.registerInstruction ("enablebirthmenu", "", opcodeEnableBirthMenu);
|
||||||
|
extensions.registerInstruction ("enableclassmenu", "", opcodeEnableClassMenu);
|
||||||
|
extensions.registerInstruction ("enablenamemenu", "", opcodeEnableNameMenu);
|
||||||
|
extensions.registerInstruction ("enableracemenu", "", opcodeEnableRaceMenu);
|
||||||
|
extensions.registerInstruction ("enablestatsreviewmenu", "",
|
||||||
|
opcodeEnableStatsReviewMenu);
|
||||||
|
|
||||||
|
extensions.registerInstruction ("enableinventorymenu", "", opcodeEnableInventoryMenu);
|
||||||
|
extensions.registerInstruction ("enablemagicmenu", "", opcodeEnableMagicMenu);
|
||||||
|
extensions.registerInstruction ("enablemapmenu", "", opcodeEnableMapMenu);
|
||||||
|
extensions.registerInstruction ("enablestatsmenu", "", opcodeEnableStatsMenu);
|
||||||
|
|
||||||
|
extensions.registerInstruction ("enablerestmenu", "", opcodeEnableRest);
|
||||||
|
extensions.registerInstruction ("enablelevelupmenu", "", opcodeEnableRest);
|
||||||
|
|
||||||
|
extensions.registerInstruction ("showrestmenu", "", opcodeShowRestMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
|
{
|
||||||
|
interpreter.installSegment5 (opcodeEnableBirthMenu,
|
||||||
|
new OpShowOneTimeDialogue (MWGui::GuiManager::Gui_Birth));
|
||||||
|
interpreter.installSegment5 (opcodeEnableClassMenu,
|
||||||
|
new OpShowOneTimeDialogue (MWGui::GuiManager::Gui_Class));
|
||||||
|
interpreter.installSegment5 (opcodeEnableNameMenu,
|
||||||
|
new OpShowOneTimeDialogue (MWGui::GuiManager::Gui_Name));
|
||||||
|
interpreter.installSegment5 (opcodeEnableRaceMenu,
|
||||||
|
new OpShowOneTimeDialogue (MWGui::GuiManager::Gui_Race));
|
||||||
|
interpreter.installSegment5 (opcodeEnableStatsReviewMenu,
|
||||||
|
new OpShowOneTimeDialogue (MWGui::GuiManager::Gui_Review));
|
||||||
|
|
||||||
|
interpreter.installSegment5 (opcodeEnableInventoryMenu,
|
||||||
|
new OpEnableWindow (MWGui::GuiManager::Gui_Inventory));
|
||||||
|
interpreter.installSegment5 (opcodeEnableMagicMenu,
|
||||||
|
new OpEnableWindow (MWGui::GuiManager:: Gui_Magic));
|
||||||
|
interpreter.installSegment5 (opcodeEnableMapMenu,
|
||||||
|
new OpEnableWindow (MWGui::GuiManager::Gui_Map));
|
||||||
|
interpreter.installSegment5 (opcodeEnableStatsMenu,
|
||||||
|
new OpEnableWindow (MWGui::GuiManager::Gui_Status));
|
||||||
|
|
||||||
|
interpreter.installSegment5 (opcodeEnableRest,
|
||||||
|
new OpEnableDialogue (MWGui::GuiManager::Gui_Rest));
|
||||||
|
|
||||||
|
interpreter.installSegment5 (opcodeShowRestMenu,
|
||||||
|
new OpShowDialogue (MWGui::GuiManager::Gui_Rest));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
apps/openmw/mwscript/guiextensions.hpp
Normal file
26
apps/openmw/mwscript/guiextensions.hpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef GAME_SCRIPT_GUIEXTENSIONS_H
|
||||||
|
#define GAME_SCRIPT_GUIEXTENSIONS_H
|
||||||
|
|
||||||
|
namespace Compiler
|
||||||
|
{
|
||||||
|
class Extensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Interpreter
|
||||||
|
{
|
||||||
|
class Interpreter;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWScript
|
||||||
|
{
|
||||||
|
/// \brief GUI-related script functionality
|
||||||
|
namespace Gui
|
||||||
|
{
|
||||||
|
void registerExtensions (Compiler::Extensions& extensions);
|
||||||
|
|
||||||
|
void installOpcodes (Interpreter::Interpreter& interpreter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/world.hpp"
|
||||||
|
|
||||||
|
#include "../mwgui/guimanager.hpp"
|
||||||
|
|
||||||
#include "locals.hpp"
|
#include "locals.hpp"
|
||||||
#include "globalscripts.hpp"
|
#include "globalscripts.hpp"
|
||||||
|
|
||||||
|
@ -78,7 +80,7 @@ namespace MWScript
|
||||||
|
|
||||||
bool InterpreterContext::menuMode()
|
bool InterpreterContext::menuMode()
|
||||||
{
|
{
|
||||||
return false;
|
return mEnvironment.mGuiManager->isGuiActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
int InterpreterContext::getGlobalShort (const std::string& name) const
|
int InterpreterContext::getGlobalShort (const std::string& name) const
|
||||||
|
@ -164,6 +166,11 @@ namespace MWScript
|
||||||
return mEnvironment.mFrameDuration;
|
return mEnvironment.mFrameDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWGui::GuiManager& InterpreterContext::getGuiManager()
|
||||||
|
{
|
||||||
|
return *mEnvironment.mGuiManager;
|
||||||
|
}
|
||||||
|
|
||||||
MWWorld::World& InterpreterContext::getWorld()
|
MWWorld::World& InterpreterContext::getWorld()
|
||||||
{
|
{
|
||||||
return *mEnvironment.mWorld;
|
return *mEnvironment.mWorld;
|
||||||
|
|
|
@ -72,10 +72,12 @@ namespace MWScript
|
||||||
virtual bool hasBeenActivated() const;
|
virtual bool hasBeenActivated() const;
|
||||||
|
|
||||||
virtual float getSecondsPassed() const;
|
virtual float getSecondsPassed() const;
|
||||||
|
|
||||||
MWWorld::World& getWorld();
|
MWWorld::World& getWorld();
|
||||||
|
|
||||||
MWSound::SoundManager& getSoundManager();
|
MWSound::SoundManager& getSoundManager();
|
||||||
|
|
||||||
|
MWGui::GuiManager& getGuiManager();
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "cellextensions.hpp"
|
#include "cellextensions.hpp"
|
||||||
#include "miscextensions.hpp"
|
#include "miscextensions.hpp"
|
||||||
|
#include "guiextensions.hpp"
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
|
@ -123,6 +124,7 @@ namespace MWScript
|
||||||
Interpreter::installOpcodes (interpreter);
|
Interpreter::installOpcodes (interpreter);
|
||||||
Cell::installOpcodes (interpreter);
|
Cell::installOpcodes (interpreter);
|
||||||
Misc::installOpcodes (interpreter);
|
Misc::installOpcodes (interpreter);
|
||||||
|
Gui::installOpcodes (interpreter);
|
||||||
MWSound::installOpcodes (interpreter);
|
MWSound::installOpcodes (interpreter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue