| 58 | } |
| 59 | |
| 60 | void ScriptableCampaign::Initialize(Path script_path, std::string _campaign_id) { |
| 61 | campaign_id = _campaign_id; |
| 62 | |
| 63 | ASData as_data; |
| 64 | |
| 65 | as_context = new ASContext("scriptable_campaign", as_data); |
| 66 | |
| 67 | as_context->RegisterGlobalFunction("void SendLevelMessage(const string& in msg)", asFUNCTION(ASSendLevelMessage), asCALL_CDECL); |
| 68 | |
| 69 | AttachLevelSet(as_context); |
| 70 | AttachLevelXML(as_context); |
| 71 | AttachUIQueries(as_context); |
| 72 | AttachTokenIterator(as_context); |
| 73 | AttachSimpleFile(as_context); |
| 74 | AttachInterlevelData(as_context); |
| 75 | AttachEngine(as_context); |
| 76 | AttachOnline(as_context); |
| 77 | |
| 78 | AttachSaveFile(as_context, &Engine::Instance()->save_file_); |
| 79 | |
| 80 | as_funcs.init = as_context->RegisterExpectedFunction("void Init()", false); |
| 81 | as_funcs.receive_message = as_context->RegisterExpectedFunction("void ReceiveMessage(string)", false); |
| 82 | as_funcs.set_window_dimensions = as_context->RegisterExpectedFunction("void SetWindowDimensions(int width, int height)", false); |
| 83 | |
| 84 | as_funcs.update = as_context->RegisterExpectedFunction("void Update()", true); |
| 85 | as_funcs.dispose = as_context->RegisterExpectedFunction("void Dispose()", true); |
| 86 | as_funcs.enter_campaign = as_context->RegisterExpectedFunction("void EnterCampaign()", true); |
| 87 | as_funcs.enter_level = as_context->RegisterExpectedFunction("void EnterLevel()", true); |
| 88 | as_funcs.leave_campaign = as_context->RegisterExpectedFunction("void LeaveCampaign()", true); |
| 89 | as_funcs.leave_level = as_context->RegisterExpectedFunction("void LeaveLevel()", true); |
| 90 | |
| 91 | char path[kPathSize]; |
| 92 | FormatString(path, kPathSize, "%sasscriptable_campaign_docs.h", GetWritePath(CoreGameModID).c_str()); |
| 93 | as_context->ExportDocs(path); |
| 94 | |
| 95 | // Load script and run init function |
| 96 | as_context->LoadScript(script_path); |
| 97 | |
| 98 | as_context->CallScriptFunction(as_funcs.init); |
| 99 | } |
| 100 | |
| 101 | void ScriptableCampaign::Dispose() { |
| 102 | as_context->CallScriptFunction(as_funcs.dispose); |
nothing calls this directly
no test coverage detected