OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
cameradefinitions.cpp
Go to the documentation of this file.
1#include "cameradefinitions.h"
2
3#include "gothic.h"
4#include "utils/string_frm.h"
5
7 auto vm = Gothic::inst().createPhoenixVm("Camera.dat");
8
9 vm->enumerate_instances_by_class_name("CCAMSYS", [this, &vm](zenkit::DaedalusSymbol& s) {
10 try {
11 auto cam = vm->init_instance<zenkit::ICamera>(&s);
12 cameras.emplace_back(s.name(), *cam);
13 }
14 catch(const zenkit::DaedalusScriptError&) {
15 // There was an error initializing the ICamera. Ignore it.
16 }
17 });
18
19 camModDialog = getCam("CAMMODDIALOG");
20 camModInventory = getCam("CAMMODINVENTORY");
21 camModNormal = getCam("CAMMODNORMAL");
22 camModBack = getCam("CAMMODLOOKBACK");
23 camModFp = getCam("CAMMODFIRSTPERSON");
24 camModDeath = getCam("CAMMODDEATH");
25 camModMelee = getCam("CAMMODMELEE");
26 camModRange = getCam("CAMMODRANGED");
27 camModMage = getCam("CAMMODMAGIC");
28 camModSwim = getCam("CAMMODSWIM");
29 camModDive = getCam("CAMMODDIVE");
30 camModFall = getCam("CAMMODFALL");
31 }
32
33const zenkit::ICamera& CameraDefinitions::mobsiCam(std::string_view tag, std::string_view pos) const {
34 if(!pos.empty()) {
35 string_frm name("CAMMODMOB",tag,'_',pos);
36 if(auto* c = find(name))
37 return *c;
38 }
39
40 string_frm name("CAMMODMOB",tag);
41 if(auto* c = find(name))
42 return *c;
43 if(auto* c = find("CAMMODMOBDEFAULT"))
44 return *c;
45 return camModNormal;
46 }
47
48zenkit::ICamera CameraDefinitions::getCam(std::string_view name) {
49 for(auto& i:cameras)
50 if(i.first==name)
51 return i.second;
52
53 return {};
54 }
55
56const zenkit::ICamera* CameraDefinitions::find(std::string_view name) const {
57 for(auto& i:cameras)
58 if(i.first==name)
59 return &i.second;
60 return nullptr;
61 }
const zenkit::ICamera & mobsiCam(std::string_view tag, std::string_view pos) const
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