summaryrefslogtreecommitdiffstats
path: root/src/Render.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2021-07-04 14:47:44 +0200
committerGitHub <noreply@github.com>2021-07-04 14:47:44 +0200
commit8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a (patch)
tree1e9510a1c2ff7f6c0eaaba211c38e0a855b36ca9 /src/Render.cpp
parentMerge pull request #64 from LaG1924/ftr/render-optimization (diff)
parentAdded screenshot-mode (diff)
downloadAltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar.gz
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar.bz2
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar.lz
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar.xz
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar.zst
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.zip
Diffstat (limited to 'src/Render.cpp')
-rw-r--r--src/Render.cpp41
1 files changed, 30 insertions, 11 deletions
diff --git a/src/Render.cpp b/src/Render.cpp
index bee8ffb..896a05f 100644
--- a/src/Render.cpp
+++ b/src/Render.cpp
@@ -4,6 +4,7 @@
#include <optick.h>
#include <RmlUi/Core.h>
#include <RmlUi/Lua.h>
+#include <RmlUi/Debugger.h>
#include "Shader.hpp"
#include "AssetManager.hpp"
@@ -28,7 +29,8 @@ const std::map<SDL_Keycode, Rml::Input::KeyIdentifier> keyMapping = {
{SDLK_RIGHT, Rml::Input::KI_RIGHT},
{SDLK_UP, Rml::Input::KI_UP},
{SDLK_DOWN, Rml::Input::KI_DOWN},
- {SDLK_TAB, Rml::Input::KI_TAB}
+ {SDLK_TAB, Rml::Input::KI_TAB},
+ {SDLK_RETURN, Rml::Input::KI_RETURN}
};
inline int ConvertKeymodsSdlToRml(unsigned short keyMods) {
@@ -287,9 +289,19 @@ void Render::HandleEvents() {
if (state == State::Playing) {
SetState(State::Chat);
}
- else if (state == State::Chat) {
- SetState(State::Playing);
- }
+ break;
+ }
+
+ case SDL_SCANCODE_F4:
+ hideRml = !hideRml;
+ break;
+
+ case SDL_SCANCODE_F8:
+ Rml::Debugger::SetVisible(!Rml::Debugger::IsVisible());
+ break;
+
+ case SDL_SCANCODE_F7: {
+ SetMouseCapture(!isMouseCaptured);
break;
}
@@ -358,6 +370,11 @@ void Render::HandleEvents() {
break;
}
+ case SDL_MOUSEWHEEL: {
+ rmlContext->ProcessMouseWheel(-event.wheel.y, rmlKeymods);
+ break;
+ }
+
case SDL_TEXTINPUT: {
rmlContext->ProcessTextInput(Rml::String(event.text.text));
break;
@@ -417,7 +434,8 @@ void Render::Update() {
void Render::RenderGui() {
OPTICK_EVENT();
- rmlContext->Render();
+ if (!hideRml)
+ rmlContext->Render();
}
void Render::InitEvents() {
@@ -462,12 +480,6 @@ void Render::InitEvents() {
SetState(State::Loading);
});
- listener.RegisterHandler("ChatMessageReceived", [this](const Event& eventData) {
- auto data = eventData.get<std::tuple<Chat, unsigned char>>();
- std::string msg = "(" + std::to_string((int)std::get<1>(data)) + ") " + (std::get<0>(data).ToPlainText());
- chatMessages.push_back(msg);
- });
-
listener.RegisterHandler("StateUpdated", [this](const Event& eventData) {
switch (GetState()) {
case State::Playing:
@@ -498,6 +510,10 @@ void Render::InitEvents() {
PluginSystem::CallOnChangeState("Chat");
SetMouseCapture(false);
break;
+ case State::NeedRespawn:
+ PluginSystem::CallOnChangeState("NeedRespawn");
+ SetMouseCapture(false);
+ break;
}
});
@@ -563,4 +579,7 @@ void Render::InitRml() {
Rml::Lua::Initialise(PluginSystem::GetLuaState());
rmlContext = Rml::CreateContext("default", Rml::Vector2i(renderState.WindowWidth, renderState.WindowHeight));
+
+ if (!Rml::Debugger::Initialise(rmlContext))
+ LOG(WARNING) << "Rml debugger not initialized";
}