Elaztek Developer Hub
Switch Project...
blam!
Editing Kit
Guerilla
Sapien
Tool
Foundry
Libraries
Keystone
Strings
Forums
Discord
Doxygen
Jenkins
Guides
Gitlab
Blamite Game Engine - blam!
00423.10.27.24.0533.blamite
The core library for the Blamite Game Engine.
set_project_root.hpp
Go to the documentation of this file.
1
#include "../console.h"
2
3
#include <Strings/components/utils/io/io.h>
4
5
#include "
components/diagnostics/logger/logger.h
"
6
#include "
components/diagnostics/crash/crash.h
"
7
#include "
components/content/project/project.h
"
8
9
namespace
Blam::Resources::Console
10
{
17
class
SetProjectRootCommand
:
public
BlamConsoleCommand
18
{
19
private
:
20
void
ChangeProjectRoot(std::string file_path)
21
{
22
if
(!file_path.ends_with(
"/"
))
23
{
24
file_path +=
"/"
;
25
}
26
27
BlamProjectInfo project_info =
Blam::Content::Project::GetCurrentProjectInfo
();
28
project_info.engine_settings.content_root = file_path;
29
Blam::Content::Project::SetActiveProjectInfo
(project_info);
30
}
31
32
public
:
33
SetProjectRootCommand
()
34
{
35
name
=
"set_project_root"
;
36
description
=
"Updates the content root of the engine. Only available in debug and test"
37
" builds, and is intended for use in conjunction with the Editing Kit."
;
38
39
type
=
BlamCommandType::Builtin
;
40
}
41
42
BlamResult
Execute
(std::vector<std::string> arguments)
43
{
44
if
(arguments.size() == 0)
45
{
46
Blam::Logger::LogEvent
(
"setting content root to application directory"
);
47
ChangeProjectRoot(
""
);
48
return
BlamResult::Success_OK;
49
}
50
51
std::string file_path =
""
;
52
53
for
(
int
i = 0; i < arguments.size(); i++)
54
{
55
if
(i == arguments.size() - 1)
56
{
57
file_path += arguments[i];
58
}
59
else
60
{
61
file_path += arguments[i] +
" "
;
62
}
63
}
64
65
file_path = BlamStrings::Utils::IO::NormalizePath(file_path);
66
67
if
(BlamStrings::Utils::IO::IsDirectory(file_path))
68
{
69
Blam::Logger::LogEvent
(
"setting content root to '"
+ file_path +
"'"
);
70
ChangeProjectRoot(file_path);
71
}
72
else
73
{
74
Blam::Logger::LogEvent
(
"cannot set content root to '"
+ file_path +
"': path does not exist, or is not a directory"
);
75
}
76
77
return
BlamResult::Success_OK;
78
}
79
};
80
}
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition:
aliases.cpp:130
BlamConsoleCommand::description
std::string description
An optional description of the command. Shown when using the classify command.
Definition:
console.h:36
logger.h
BlamConsoleCommand
Class used to represent a console command.
Definition:
console.h:33
project.h
Blam::Resources::Console::SetProjectRootCommand::Execute
BlamResult Execute(std::vector< std::string > arguments)
Called upon command execution.
Definition:
set_project_root.hpp:42
Blam::Content::Project::SetActiveProjectInfo
BLAM void SetActiveProjectInfo(BlamProjectInfo project_info)
Definition:
project.cpp:10
Blam::Content::Project::GetCurrentProjectInfo
BLAM BlamProjectInfo GetCurrentProjectInfo()
Definition:
project.cpp:5
BlamConsoleCommand::name
std::string name
The name of the console command.
Definition:
console.h:35
crash.h
BlamConsoleCommand::type
BlamCommandType type
The type of command this is. See #Blam::Resources::Console::BlamCommandType for more information.
Definition:
console.h:40
Blam::Resources::Console
Namespace for things relating to the debug console.
Definition:
abort.hpp:5
Blam::Resources::Console::SetProjectRootCommand
Class for the set_project_root command.
Definition:
set_project_root.hpp:17
Blam::Resources::Console::SetProjectRootCommand::SetProjectRootCommand
SetProjectRootCommand()
Definition:
set_project_root.hpp:33
BlamCommandType::Builtin
@ Builtin
A command that is hard-coded into the engine.
blam
components
resources
console
commands
set_project_root.hpp
Generated on Sun Oct 27 2024 06:11:32 for Blamite Game Engine - blam! by
1.8.17