OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
musicdefinitions.cpp
Go to the documentation of this file.
1#include "musicdefinitions.h"
2
3#include <Tempest/Log>
4
5#include "gothic.h"
6
7using namespace Tempest;
8
10 vm = Gothic::inst().createPhoenixVm("Music.dat");
11
12 vm->enumerate_instances_by_class_name("C_MusicTheme", [this](zenkit::DaedalusSymbol& s) {
13 themes.push_back(vm->init_instance<zenkit::IMusicTheme>(&s));
14 });
15 }
16
19
20const zenkit::IMusicTheme* MusicDefinitions::operator [](std::string_view name) const {
21 if(!vm)
22 return nullptr;
23
24 auto id = vm->find_symbol_by_name(name);
25 if(id==nullptr)
26 return nullptr;
27 for(auto& i:themes) {
28 auto* sym = vm->find_symbol_by_instance(i);
29 if(sym->index() == id->index())
30 return i.get();
31 }
32 return nullptr;
33 }
static Gothic & inst()
Definition gothic.cpp:249
std::unique_ptr< zenkit::DaedalusVm > createPhoenixVm(std::string_view datFile, const ScriptLang lang=ScriptLang::NONE)
Definition gothic.cpp:711
const zenkit::IMusicTheme * operator[](std::string_view name) const