/
TdmMissionSetup.h
88 lines (69 loc) · 1.95 KB
/
TdmMissionSetup.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#pragma once
#include "RadiantTest.h"
namespace test
{
// Test context setting up a temporary FM folder
class TdmMissionContext :
public radiant::TestContext
{
private:
std::string _projectFolder;
public:
TdmMissionContext()
{
// Set up the temporary settings folder
_projectFolder = (os::getTemporaryPath() / "tdm_fm/").string();
os::removeDirectory(_projectFolder);
os::makeDirectory(_projectFolder);
}
virtual ~TdmMissionContext()
{
if (!_projectFolder.empty())
{
os::removeDirectory(_projectFolder);
}
}
virtual std::string getTestProjectPath() const override
{
return os::standardPathWithSlash(_projectFolder);
}
};
// Test setup using an empty FM to be used as TDM project config
class TdmMissionSetup :
public RadiantTest
{
protected:
TdmMissionContext _context;
constexpr static const char* TestMissionName = "testfm";
constexpr static const char* MissionBasePath = "fms";
private:
std::string _testFmPath;
std::string _fmBasePath;
protected:
const std::string& getTestMissionPath()
{
return _testFmPath;
}
virtual void setupGameFolder() override
{
_fmBasePath = _context.getTestProjectPath() + MissionBasePath + "/";
_testFmPath = os::standardPathWithSlash(_fmBasePath + TestMissionName);
os::makeDirectory(_fmBasePath);
os::makeDirectory(_testFmPath);
}
virtual void TearDown() override
{
os::removeDirectory(_fmBasePath);
RadiantTest::TearDown();
}
virtual void handleGameConfigMessage(game::ConfigurationNeeded& message) override
{
game::GameConfiguration config;
config.gameType = "The Dark Mod 2.0 (Standalone)";
config.enginePath = _context.getTestProjectPath();
config.modPath = getTestMissionPath();
message.setConfig(config);
message.setHandled(true);
}
};
}