Blamite Game Engine - Blam (Core)
cls.hpp
Go to the documentation of this file.
1 #include "../console.h"
3 #include "core.h"
5 
6 namespace Blam::Console
7 {
15  {
16  public:
18  {
19  name = "cls";
20  description = "Clears console log";
21  aliases = { "clear" };
22 
24  }
25 
27  {
28  delete this;
29  }
30 
31  CommandStatus onCommand(std::vector<std::string> arguments)
32  {
33  using namespace BlamRendering::RenderStack;
34 
35  StackObjectBase* stack_item = (StackObjectBase*)GetStackItem("console");
36 
37  if (stack_item)
38  {
39  if (stack_item->type_label == STACKTYPE_CONSOLE)
40  {
41  ConsoleUI* console = (ConsoleUI*)stack_item;
42 
43  console->clearScrollback();
44  }
45  else
46  {
47  Blam::Logger::LogEvent("### ERROR failed to retrieve console ui stack object (got wrong stack type)", WSV_ERROR);
48  }
49  }
50  else
51  {
52  Blam::Logger::LogEvent("### ERROR failed to retrieve console ui stack object (GetStackItem returned nullptr)", WSV_ERROR);
53  }
54 
55  return CommandStatus::Ok;
56  }
57  };
58 }
Blam::Console::ConsoleCommand::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:75
Blam::Console::ConsoleCommand::description
std::string description
An optional description of the command. Shown when using the classify command.
Definition: console.h:73
Blam::Console::ClearScreenCommand::~ClearScreenCommand
~ClearScreenCommand()
Definition: cls.hpp:26
Blam::Console::ConsoleCommand::type
CommandType type
The type of command this is. See Blam::Console::CommandType for more information.
Definition: console.h:77
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:33
Blam::Console::CommandStatus
CommandStatus
Indicates the return state of a console command.
Definition: console.h:28
logger.h
console.hpp
BlamRendering::RenderStack::StackObjectBase::type_label
StackType type_label
The type of the object.
Definition: render_stack.h:372
BlamRendering::RenderStack
Namespace containing things relating to the Render Stack.
Definition: drawing.h:14
Blam::Console::Builtin
@ Builtin
A command that is hard-coded into the engine.
Definition: console.h:41
Blam::Console::ConsoleCommand::name
std::string name
The name of the console command.
Definition: console.h:70
WSV_ERROR
#define WSV_ERROR
Macro for 'Error' log seveirty. Original pre-enum value was 2.
Definition: logger.h:17
Blam::Console::ClearScreenCommand::onCommand
CommandStatus onCommand(std::vector< std::string > arguments)
Called upon command execution.
Definition: cls.hpp:31
Blam::Console::ClearScreenCommand
Class for the cls command.
Definition: cls.hpp:14
STACKTYPE_CONSOLE
#define STACKTYPE_CONSOLE
Definition: render_stack.h:26
Blam::Console
Namespace for things relating to the debug console.
Definition: abort.hpp:5
Blam::Console::Ok
@ Ok
The command was run without error.
Definition: console.h:30
BlamRendering::RenderStack::ConsoleUI::clearScrollback
void clearScrollback()
Definition: console.hpp:420
Blam::Console::ConsoleCommand
Class used to represent a console command.
Definition: console.h:50
core.h
BlamRendering::RenderStack::StackObjectBase
Base class for all render stack objects.
Definition: render_stack.h:194
BlamRendering::RenderStack::GetStackItem
BLAM StackObjectBase * GetStackItem(std::string id)
Retrieves an item from the render stack.
Definition: render_stack.cpp:75
Blam::Console::ClearScreenCommand::ClearScreenCommand
ClearScreenCommand()
Definition: cls.hpp:17
BlamRendering::RenderStack::ConsoleUI
Definition: console.hpp:63