1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 15:45:31 +00:00

added script-gui interface and gui-related script instructions

This commit is contained in:
Marc Zinnschlag 2010-07-07 20:12:00 +02:00
parent 2c63d67ceb
commit 0efe4742a6
10 changed files with 237 additions and 74 deletions

View file

@ -40,6 +40,7 @@ set(GAMESCRIPT
apps/openmw/mwscript/interpretercontext.cpp
apps/openmw/mwscript/cellextensions.cpp
apps/openmw/mwscript/miscextensions.cpp
apps/openmw/mwscript/guiextensions.cpp
apps/openmw/mwscript/extensions.cpp
apps/openmw/mwscript/globalscripts.cpp
)
@ -50,6 +51,7 @@ set(GAMESCRIPT_HEADER
apps/openmw/mwscript/interpretercontext.hpp
apps/openmw/mwscript/cellextensions.hpp
apps/openmw/mwscript/miscextensions.hpp
apps/openmw/mwscript/guiextensions.hpp
apps/openmw/mwscript/extensions.hpp
apps/openmw/mwscript/globalscripts.hpp
)

View file

@ -5,59 +5,24 @@
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()
void GuiManager::enableDialogue (GuiDialogue dialogue)
{
std::cout << "" << std::endl;
std::cout << "enable dialogue: " << dialogue << std::endl;
}
void GuiManager::showRaceDialogue()
void GuiManager::showDialogue (GuiDialogue dialogue)
{
std::cout << "" << std::endl;
}
void GuiManager::showReviewDialogue()
{
std::cout << "" << std::endl;
}
void GuiManager::enableInventoryWindow()
{
std::cout << "" << std::endl;
}
void GuiManager::enableMagicWindow()
{
std::cout << "" << 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;
std::cout << "show dialogue: " << dialogue << std::endl;
}
bool GuiManager::isGuiActive() const

View file

@ -7,38 +7,31 @@ namespace MWGui
{
public:
void showBirthDialogue();
///< Birthsign (part of the character generation process)
enum GuiWindow
{
Gui_Inventory, Gui_Magic, Gui_Map, Gui_Status
};
void showClassDialogue();
///< Class selection (part of the character generation process)
enum GuiOneTimeDialogue // used only once
{
// character generation
Gui_Birth, Gui_Class, Gui_Name, Gui_Race, Gui_Review
};
void showNameDialogue();
///< Enter character name (part of the character generation process)
enum GuiDialogue
{
Gui_Rest
};
void showRaceDialogue();
///< Race selection (part of the character generation process)
void enableWindow (GuiWindow window);
///< diabled by default.
void showReviewDialogue();
///< Character generation review (final part of the character generation process)
void showOneTimeDialogue (GuiOneTimeDialogue dialogue);
void enableInventoryWindow();
///< Initially disabled.
void enableDialogue (GuiDialogue dialogue);
///< disabled by default.
void enableMagicWindow();
///< Initially disabled.
void enableMapWindow();
///< Initially disabled.
void enableStatsMenu();
///< Initially disabled.
void enableLevelUpDialogue();
///< Rest/Level-up. Initially disabled.
void showRestDialogue();
///< Rest dialogue: ask player how many hours he wants to sleep.
void showDialogue (GuiDialogue dialogue);
bool isGuiActive() const;
///< Any non-HUD GUI element active (dialogues and windows)?

View file

@ -35,5 +35,16 @@ op 0x200000a: StopSound
op 0x200000b: GetSoundPlaying
op 0x200000c: XBox (always 0)
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

View file

@ -5,6 +5,7 @@
#include "cellextensions.hpp"
#include "miscextensions.hpp"
#include "guiextensions.hpp"
namespace MWScript
{
@ -12,6 +13,7 @@ namespace MWScript
{
Cell::registerExtensions (extensions);
Misc::registerExtensions (extensions);
Gui::registerExtensions (extensions);
MWSound::registerExtensions (extensions);
}
}

View 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));
}
}
}

View 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

View file

@ -9,6 +9,8 @@
#include "../mwworld/world.hpp"
#include "../mwgui/guimanager.hpp"
#include "locals.hpp"
#include "globalscripts.hpp"
@ -78,7 +80,7 @@ namespace MWScript
bool InterpreterContext::menuMode()
{
return false;
return mEnvironment.mGuiManager->isGuiActive();
}
int InterpreterContext::getGlobalShort (const std::string& name) const
@ -164,6 +166,11 @@ namespace MWScript
return mEnvironment.mFrameDuration;
}
MWGui::GuiManager& InterpreterContext::getGuiManager()
{
return *mEnvironment.mGuiManager;
}
MWWorld::World& InterpreterContext::getWorld()
{
return *mEnvironment.mWorld;

View file

@ -77,6 +77,8 @@ namespace MWScript
MWSound::SoundManager& getSoundManager();
MWGui::GuiManager& getGuiManager();
MWWorld::Ptr getReference();
///< Reference, that the script is running from (can be empty)
};

View file

@ -19,6 +19,7 @@
#include "cellextensions.hpp"
#include "miscextensions.hpp"
#include "guiextensions.hpp"
namespace MWScript
{
@ -123,6 +124,7 @@ namespace MWScript
Interpreter::installOpcodes (interpreter);
Cell::installOpcodes (interpreter);
Misc::installOpcodes (interpreter);
Gui::installOpcodes (interpreter);
MWSound::installOpcodes (interpreter);
}
}