Blamite Game Engine - Blam (Core)
history.hpp
Go to the documentation of this file.
1 #include "../console.h"
3 #include "core.h"
5 
6 namespace Blam::Console
7 {
14  {
15  public:
17  {
18  name = "history";
19  description = "Shows recently executed commands.";
20 
22  }
23 
25  {
26  delete this;
27  }
28 
29  CommandStatus onCommand(std::vector<std::string> arguments)
30  {
31  using namespace BlamRendering::RenderStack;
32 
33  StackObjectBase* stack_item = (StackObjectBase*)GetStackItem("console");
34 
35  if (stack_item)
36  {
37  if (stack_item->type_label == STACKTYPE_CONSOLE)
38  {
39  ConsoleUI* console = (ConsoleUI*)stack_item;
40 
41  if (console->getRecentInput().size() == 0)
42  {
43  Blam::Logger::LogEvent("no recent input found", WSV_NONE);
44  }
45  else
46  {
47  for (int i = 0; i < console->getRecentInput().size(); i++)
48  {
49  Blam::Logger::LogEvent(std::to_string(i + 1) + ". " + console->getRecentInput().at(i), WSV_NONE);
50  }
51  }
52  }
53  else
54  {
55  Blam::Logger::LogEvent("### ERROR failed to retrieve console ui stack object (got wrong stack type)", WSV_ERROR);
56  }
57  }
58  else
59  {
60  Blam::Logger::LogEvent("### ERROR failed to retrieve console ui stack object (GetStackItem returned nullptr)", WSV_ERROR);
61  }
62 
63  return CommandStatus::Ok;
64  }
65  };
66 }
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::HistoryCommand::~HistoryCommand
~HistoryCommand()
Definition: history.hpp:24
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
BlamRendering::RenderStack::ConsoleUI::getRecentInput
std::vector< std::string > getRecentInput()
Definition: console.hpp:415
Blam::Console::HistoryCommand::HistoryCommand
HistoryCommand()
Definition: history.hpp:16
WSV_NONE
#define WSV_NONE
Macro for 'None' log seveirty. Original pre-enum value was 0.
Definition: logger.h:15
Blam::Console::HistoryCommand::onCommand
CommandStatus onCommand(std::vector< std::string > arguments)
Called upon command execution.
Definition: history.hpp:29
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::HistoryCommand
Class for the history command.
Definition: history.hpp:13
Blam::Console::Ok
@ Ok
The command was run without error.
Definition: console.h:30
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
BlamRendering::RenderStack::ConsoleUI
Definition: console.hpp:63