added journal-related script instructions

actorid
Marc Zinnschlag 14 years ago
parent b40117449a
commit e4a0702bb4

@ -93,6 +93,7 @@ set(GAMESCRIPT
mwscript/controlextensions.cpp
mwscript/extensions.cpp
mwscript/globalscripts.cpp
mwscript/dialogueextensions.cpp
)
set(GAMESCRIPT_HEADER
mwscript/locals.hpp
@ -111,6 +112,7 @@ set(GAMESCRIPT_HEADER
mwscript/extensions.hpp
mwscript/globalscripts.hpp
mwscript/ref.hpp
mwscript/dialogueextensions.hpp
)
source_group(apps\\openmw\\mwscript FILES ${GAMESCRIPT} ${GAMESCRIPT_HEADER})

@ -0,0 +1,94 @@
#include "dialogueextensions.hpp"
#include <components/compiler/extensions.hpp>
#include <components/interpreter/interpreter.hpp>
#include <components/interpreter/runtime.hpp>
#include <components/interpreter/opcodes.hpp>
#include "../mwdialogue/journal.hpp"
#include "interpretercontext.hpp"
namespace MWScript
{
namespace Dialogue
{
class OpJournal : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
MWScript::InterpreterContext& context
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
std::string quest = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();
Interpreter::Type_Integer index = runtime[0].mInteger;
runtime.pop();
context.getEnvironment().mJournal->addEntry (quest, index);
}
};
class OpSetJournalIndex : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
MWScript::InterpreterContext& context
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
std::string quest = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();
Interpreter::Type_Integer index = runtime[0].mInteger;
runtime.pop();
context.getEnvironment().mJournal->setJournalIndex (quest, index);
}
};
class OpGetJournalIndex : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
MWScript::InterpreterContext& context
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
std::string quest = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();
int index = context.getEnvironment().mJournal->getJournalIndex (quest);
runtime.push (index);
}
};
const int opcodeJournal = 0x2000133;
const int opcodeSetJournalIndex = 0x2000134;
const int opcodeGetJournalIndex = 0x2000135;
void registerExtensions (Compiler::Extensions& extensions)
{
extensions.registerInstruction ("journal", "cl", opcodeJournal);
extensions.registerInstruction ("setjournalindex", "cl", opcodeSetJournalIndex);
extensions.registerFunction ("getjournalindex", 'l', "c", opcodeGetJournalIndex);
}
void installOpcodes (Interpreter::Interpreter& interpreter)
{
interpreter.installSegment5 (opcodeJournal, new OpJournal);
interpreter.installSegment5 (opcodeSetJournalIndex, new OpSetJournalIndex);
interpreter.installSegment5 (opcodeGetJournalIndex, new OpGetJournalIndex);
}
}
}

@ -0,0 +1,25 @@
#ifndef GAME_SCRIPT_DIALOGUEEXTENSIONS_H
#define GAME_SCRIPT_DIALOGUEEXTENSIONS_H
namespace Compiler
{
class Extensions;
}
namespace Interpreter
{
class Interpreter;
}
namespace MWScript
{
/// \brief Dialogue/Journal-related script functionality
namespace Dialogue
{
void registerExtensions (Compiler::Extensions& extensions);
void installOpcodes (Interpreter::Interpreter& interpreter);
}
}
#endif

@ -104,4 +104,7 @@ op 0x2000115-0x200012f: ModSKill, explicit reference
op 0x2000130: ToggleCollision
op 0x2000131: GetInterior
op 0x2000132: ToggleCollsionDebug
opcodes 0x2000133-0x3ffffff unused
op 0x2000133: Journal
op 0x2000134: SetJournalIndex
op 0x2000135: GetJournalIndex
opcodes 0x2000136-0x3ffffff unused

@ -13,6 +13,7 @@
#include "containerextensions.hpp"
#include "aiextensions.hpp"
#include "controlextensions.hpp"
#include "dialogueextensions.hpp"
namespace MWScript
{
@ -27,6 +28,7 @@ namespace MWScript
Container::registerExtensions (extensions);
Ai::registerExtensions (extensions);
Control::registerExtensions (extensions);
Dialogue::registerExtensions (extensions);
}
void installOpcodes (Interpreter::Interpreter& interpreter)
@ -41,5 +43,6 @@ namespace MWScript
Container::installOpcodes (interpreter);
Ai::installOpcodes (interpreter);
Control::installOpcodes (interpreter);
Dialogue::installOpcodes (interpreter);
}
}

@ -260,6 +260,11 @@ namespace MWScript
mEnvironment.mWorld->disable (ref);
}
MWWorld::Environment& InterpreterContext::getEnvironment()
{
return mEnvironment;
}
MWGui::WindowManager& InterpreterContext::getWindowManager()
{
return *mEnvironment.mWindowManager;

@ -106,6 +106,10 @@ namespace MWScript
virtual void disable (const std::string& id = "");
MWWorld::Environment& getEnvironment();
/// \todo remove the following functions (extentions should use getEnvironment instead)
MWWorld::World& getWorld();
MWSound::SoundManager& getSoundManager();

Loading…
Cancel
Save