From 82c6b0f92a69c36f3d84a00d734973a8fcb609a2 Mon Sep 17 00:00:00 2001 From: gugus Date: Wed, 7 Mar 2012 18:52:27 +0100 Subject: [PATCH] choice function. Do not work. --- apps/openmw/mwscript/dialogueextensions.cpp | 36 +++++++++++++++++++-- apps/openmw/mwscript/docs/vmformat.txt | 3 +- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index 26fb6d9be..09adc0060 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -89,17 +89,48 @@ namespace MWScript } }; + class OpChoice : public Interpreter::Opcode1 + { + public: + + virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) + { + std::cout << "CHOICECHOICEHOCQSCHQSHD"; + MWScript::InterpreterContext& context + = static_cast (runtime.getContext()); + MWDialogue::DialogueManager* dialogue = context.getEnvironment().mDialogueManager; + //int choice = 1; + while(arg0>0) + { + std::string question = runtime.getStringLiteral (runtime[0].mInteger); + runtime.pop(); + arg0 = arg0 -1; + Interpreter::Type_Integer choice = 1; + if(arg0>0) + { + choice = runtime[0].mInteger; + runtime.pop(); + arg0 = arg0 -1; + } + dialogue->askQuestion(question,choice); + } + } + }; + + const int opcodeJournal = 0x2000133; const int opcodeSetJournalIndex = 0x2000134; const int opcodeGetJournalIndex = 0x2000135; const int opcodeAddTopic = 0x200013a; + const int opcodeChoice = 0x2000a; void registerExtensions (Compiler::Extensions& extensions) { extensions.registerInstruction ("journal", "cl", opcodeJournal); extensions.registerInstruction ("setjournalindex", "cl", opcodeSetJournalIndex); extensions.registerFunction ("getjournalindex", 'l', "c", opcodeGetJournalIndex); - extensions.registerInstruction ("addtopic", "S" , opcodeAddTopic); + extensions.registerInstruction ("addtopic", "S" , opcodeAddTopic); + extensions.registerInstruction ("choice", "clcl", opcodeChoice); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -107,7 +138,8 @@ namespace MWScript interpreter.installSegment5 (opcodeJournal, new OpJournal); interpreter.installSegment5 (opcodeSetJournalIndex, new OpSetJournalIndex); interpreter.installSegment5 (opcodeGetJournalIndex, new OpGetJournalIndex); - interpreter.installSegment5 (opcodeAddTopic, new OpAddTopic); + interpreter.installSegment5 (opcodeAddTopic, new OpAddTopic); + interpreter.installSegment3 (opcodeChoice,new OpChoice); } } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 5fd3fe773..eab5bf846 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -23,7 +23,8 @@ op 0x20006: PlayAnim op 0x20007: PlayAnim, explicit reference op 0x20008: LoopAnim op 0x20009: LoopAnim, explicit reference -opcodes 0x2000a-0x3ffff unused +op 0x2000a: Choice +opcodes 0x2000b-0x3ffff unused Segment 4: (not implemented yet)