Elaztek Developer Hub
Blamite Game Engine - blam!  00367.02.08.23.1815.blamite
The core library for the Blamite Game Engine.
cls.hpp
Go to the documentation of this file.
1 #include "../console.h"
2 
7 #include "core.h"
8 
10 {
18  {
19  public:
21  {
22  name = "cls";
23  description = "Clears console log";
24  aliases = { "clear" };
25 
27  }
28 
30  {
31  delete this;
32  }
33 
34  BlamCommandResult onCommand(std::vector<std::string> arguments)
35  {
37  {
38  using namespace BlamRendering::RenderStack;
39 
40  StackObjectBase* stack_item = (StackObjectBase*)GetStackItem("console");
41 
42  if (stack_item)
43  {
44  if (stack_item->type_label == STACKTYPE_CONSOLE)
45  {
46  ConsoleUI* console = (ConsoleUI*)stack_item;
47 
48  console->clearScrollback();
49  }
50  else
51  {
52  Blam::Logger::LogEvent("failed to retrieve console ui stack object (got wrong stack type)", WSV_ERROR);
53  }
54  }
55  else
56  {
57  Blam::Logger::LogEvent("failed to retrieve console ui stack object (GetStackItem returned nullptr)", WSV_ERROR);
58  }
59  }
61  {
63 
64  if (root)
65  {
66  for (BlamUIWidget* widget : root->children)
67  {
68  if (widget)
69  {
70  if (widget->GetType() == BlamWidgetType::Console)
71  {
72  BlamUIWidget_Console* console = (BlamUIWidget_Console*)widget;
73  console->ClearOutput();
74  }
75  }
76  }
77  }
78  else
79  {
80  Blam::Logger::LogEvent("error in function cls: ui root was null", WSV_ERROR);
81  }
82  }
83  else
84  {
85  Blam::Logger::LogEvent("console is not available in this rendering engine", WSV_ERROR);
86  }
87 
88  return BlamCommandResult::Ok;
89  }
90  };
91 }
ui.h
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:57
BlamUIWidget_Group
Definition: ui.h:113
logger.h
Blam::UI::GetUIRoot
BLAM BlamUIWidget_Group * GetUIRoot()
Definition: ui.cpp:70
BlamRendering::GetCurrentRenderingEngine
BLAM BlamRenderingEngine GetCurrentRenderingEngine()
Retrieves the current rendering engine being used.
Definition: rendering_abstraction.cpp:104
Blam::Resources::Console::ClearScreenCommand::onCommand
BlamCommandResult onCommand(std::vector< std::string > arguments)
Called upon command execution.
Definition: cls.hpp:34
console.h
OGRE
@ OGRE
Definition: rendering.h:35
BlamConsoleCommand
Class used to represent a console command.
Definition: console.h:54
Blam::Resources::Console::ClearScreenCommand
Class for the cls command.
Definition: cls.hpp:17
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
BlamUIWidget::GetType
BlamWidgetType GetType()
Definition: BlamUIWidget.cpp:147
Blam::Resources::Console::ClearScreenCommand::ClearScreenCommand
ClearScreenCommand()
Definition: cls.hpp:20
BlamCommandResult
BlamCommandResult
Indicates the return state of a console command.
Definition: console.h:22
BlamUIWidget_Group::children
std::vector< BlamUIWidget * > children
Definition: ui.h:119
BlamWidgetType::Console
@ Console
Special widget. Used for the in-game console.
Blam::Resources::Console::ClearScreenCommand::~ClearScreenCommand
~ClearScreenCommand()
Definition: cls.hpp:29
BlamConsoleCommand::name
std::string name
The name of the console command.
Definition: console.h:56
BlamUIWidget_Console::ClearOutput
void ClearOutput()
Clears the console output.
Definition: BlamUIWidget_Console.cpp:779
BlamUIWidget
Definition: ui.h:69
STACKTYPE_CONSOLE
#define STACKTYPE_CONSOLE
Definition: render_stack.h:26
BlamConsoleCommand::type
BlamCommandType type
The type of command this is. See #Blam::Resources::Console::BlamCommandType for more information.
Definition: console.h:61
DirectX11
@ DirectX11
Definition: rendering.h:33
BlamRendering::RenderStack::ConsoleUI::clearScrollback
void clearScrollback()
Definition: console.hpp:425
BlamUIWidget_Console
Class for the console UI widget.
Definition: console.h:48
core.h
BlamRendering::RenderStack::StackObjectBase
Base class for all render stack objects.
Definition: render_stack.h:194
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:59
BlamCommandResult::Ok
@ Ok
The command was run without error.
Blam::Resources::Console
Namespace for things relating to the debug console.
Definition: abort.hpp:5
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:66
console.hpp