Elaztek Developer Hub
Blamite Game Engine - blam!  00398.09.22.23.2015.blamite
The core library for the Blamite Game Engine.
list_levels.hpp
Go to the documentation of this file.
1 #include "../console.h"
2 
3 #include <Strings/components/utils/io/io.h>
4 
8 #include "core.h"
9 
11 {
18  {
19  private:
20  void ShowTagDataFolderList(std::string levels_root)
21  {
22  std::vector<std::string> file_list = BlamStrings::Utils::IO::GetDeepFileList(levels_root);
23  int scenario_count = 0;
24 
25  for (std::string file : file_list)
26  {
27  if (file.ends_with(".scenario"))
28  {
30  scenario_count++;
31  }
32  }
33 
34  if (scenario_count == 0)
35  {
36  Blam::Logger::LogEvent("no scenarios could be found at this time", WSV_NONE);
37  }
38  }
39 
40  public:
42  {
43  name = "list_levels";
44  description = "Provides information on a command";
45  aliases = { "listlevels", "list_scenarios", "listscenarios", "list_maps", "listmaps" };
46 
48  }
49 
50  BlamCommandResult onCommand(std::vector<std::string> arguments)
51  {
52  std::vector<std::string> scenario_list = std::vector<std::string>();
53 
55  {
56  Blam::Logger::LogEvent("cache file support is not yet available", WSV_WARNING);
57 
58  std::string cache_file_root = ENGINE_DATA_PATH(BlamEngineDataFolder::Maps);
59 
60  std::vector<std::string> file_list = BlamStrings::Utils::IO::GetFileList(cache_file_root);
61  int scenario_count = 0;
62 
63  for (std::string file : file_list)
64  {
65  if (file.ends_with(".map"))
66  {
68  scenario_count++;
69  }
70  }
71 
72  if (scenario_count == 0)
73  {
74  Blam::Logger::LogEvent("no scenarios could be found at this time", WSV_NONE);
75  }
76  }
78  {
79  Blam::Logger::LogEvent(":: engine tags ::");
80  std::string levels_root_engine = ENGINE_DATA_PATH(BlamEngineDataFolder::Tags) + "levels/";
81  ShowTagDataFolderList(levels_root_engine);
82 
83  Blam::Logger::LogEvent(":: user tags ::");
84  std::string levels_root_user = USER_DATA_PATH(BlamUserDataFolder::Tags) + "levels/";
85  ShowTagDataFolderList(levels_root_user);
86  }
87  else
88  {
89  Blam::Logger::LogEvent("could not build scenario list, build is using an unknown runtime configuration?", WSV_NONE);
90  }
91 
92  return BlamCommandResult::Ok;
93  }
94  };
95 }
BlamContentSource::Cache
@ Cache
The engine will load all content from cache files.
BlamCommandType::Builtin
@ Builtin
A command that is hard-coded into the engine.
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:142
BlamConsoleCommand::description
std::string description
An optional description of the command. Shown when using the classify command.
Definition: console.h:59
logger.h
BlamEngineDataFolder::Tags
@ Tags
Directory used for reading engine tags. Defaults to ./tags/
BlamConsoleCommand
Class used to represent a console command.
Definition: console.h:56
USER_DATA_PATH
#define USER_DATA_PATH(path)
Macro to quickly access a user data folder.
Definition: config.h:43
Blam::Resources::Console::ListLevelsCommand::ListLevelsCommand
ListLevelsCommand()
Definition: list_levels.hpp:41
BlamContentSource::Tags
@ Tags
The engine will load all content from tags.
BlamCommandResult
BlamCommandResult
Indicates the return state of a console command.
Definition: console.h:22
ENGINE_DATA_PATH
#define ENGINE_DATA_PATH(path)
Macro to quickly access a game engine data folder.
Definition: config.h:36
Blam::Resources::Console::ListLevelsCommand::onCommand
BlamCommandResult onCommand(std::vector< std::string > arguments)
Called upon command execution.
Definition: list_levels.hpp:50
BlamConsoleCommand::name
std::string name
The name of the console command.
Definition: console.h:58
BlamEngineDataFolder::Maps
@ Maps
Directory used for storing built-in cache files. Defaults to ./maps/
engine_definitions.h
file
sock planetquake com All rights reserved Quake III Arena is a registered trademark of id Inc This level may be electronically distributed only at NO CHARGE to the recipient in its current MUST include this txt file
Definition: chiropteraDM.txt:95
Blam::GetContentSource
BLAM BlamContentSource GetContentSource()
Retrieves the current content source.
Definition: engine_definitions.cpp:32
Blam::Resources::Console::ListLevelsCommand
Class for the list_levels command.
Definition: list_levels.hpp:17
BlamConsoleCommand::type
BlamCommandType type
The type of command this is. See #Blam::Resources::Console::BlamCommandType for more information.
Definition: console.h:63
core.h
config.h
BlamConsoleCommand::aliases
std::vector< std::string > aliases
A list of aliases for the command. Executing any of these instead of the command name will behave the...
Definition: console.h:61
BlamUserDataFolder::Tags
@ Tags
Directory storing user-created tags. Defaults to {DataRoot}/tags/.
BlamCommandResult::Ok
@ Ok
The command was run without error.
Blam::Resources::Console
Namespace for things relating to the debug console.
Definition: abort.hpp:5