-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rmlui integration #1076
Rmlui integration #1076
Conversation
rts/System/Input/MouseInput.cpp
Outdated
@@ -68,6 +69,9 @@ IMouseInput::~IMouseInput() | |||
|
|||
bool IMouseInput::HandleSDLMouseEvent(const SDL_Event& event) | |||
{ | |||
if (!mouse->ButtonPressed() && RmlGui::ProcessMouseEvent(event)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the !mouse->ButtonPressed()
check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only want to give a mouse event to RmlUi if the mouse isn't currently performing a drag. Otherwise box selections get stuck when the mouse goes over an Rml element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've taken the liberty of putting that as a comment in the code ca9aeb0
rts/Rml/RmlInputReceiver.h
Outdated
CRmlInputReceiver() : CInputReceiver(FRONT), rml_active(false){}; | ||
~CRmlInputReceiver() = default; | ||
|
||
bool IsAbove(int x, int y) { return rml_active; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this check if any actual gui panel is underneath?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinks like a dropdown combobox could drop below a gui panel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, by "gui panel" I mean anything drawn by rml at the coordinates being asked about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsAbove
is used for determining which cursor icon should be displayed. I track if the mouse is over an rml element in ProcessMouseEvent
and just return if rml is capturing the mouse since the xy is the mouse location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, put that in a comment at the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the comment, and integrated the mouse event handling with the main mouse handler
rts/Lua/LuaHandle.cpp
Outdated
@@ -172,6 +172,10 @@ void CLuaHandle::KillLua(bool inFreeHandler) | |||
if (inFreeHandler) | |||
Shutdown(); | |||
|
|||
if(rmlui) { | |||
RmlGui::Reload(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be some sort of shutdown and not reload?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completed. On luaui shutdown we will remove the lua rml plugin and all contexts/documents created from lua. This allows the engine to continue to use rml for it's interface.
ca9aeb0
to
449a692
Compare
rts/System/Input/MouseInput.cpp
Outdated
@@ -68,6 +69,10 @@ IMouseInput::~IMouseInput() | |||
|
|||
bool IMouseInput::HandleSDLMouseEvent(const SDL_Event& event) | |||
{ | |||
/* Only want to give a mouse event to RmlUI if the mouse isn't currently performing a drag. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to rts/Game/UI/MouseHandler.cpp
line 276.
Not all is ready and there will be more work needed on build system, but the basic integration of RmlUi Core is done. - I've not created and linked any of the provided GL3 or SDL backends, that needs separate work - Lua bindings are blocked on mikke89/RmlUi#302 we need to find some workaround for that - Tracy integration is blocked on mikke89/RmlUi#516
@@ -1,5 +1,7 @@ | |||
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it?
/* | ||
* This source file is part of RmlUi, the HTML/CSS Interface Middleware | ||
* This source file is dervied from the source code of RmlUi, the HTML/CSS Interface Middleware |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t. dervish
* This source file is dervied from the source code of RmlUi, the HTML/CSS Interface Middleware | |
* This source file is derived from the source code of RmlUi, the HTML/CSS Interface Middleware |
but also idk if it makes sense to modify this. did we actually change anything substantial?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is only minor changes that I do not know the full impact of.
The one I noted is that the shader GLSL version was changed.
@@ -59,7 +59,7 @@ static void ExitSpringProcess(const char* msg, const char* caption, unsigned int | |||
|
|||
static void ExitSpringProcess(const char* msg, const char* caption, unsigned int flags) | |||
{ | |||
LOG_L(L_ERROR, "[%s] errorMsg=\"%s\" msgCaption=\"%s\" mainThread=%d", __func__, msg, caption, Threading::IsMainThread()); | |||
LOG_L(L_FATAL, "[%s] errorMsg=\"%s\" msgCaption=\"%s\" mainThread=%d", __func__, msg, caption, Threading::IsMainThread()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could probably go to mainline separately
get rid of never-going-to-be-used code in RmlUi_Renderer_GL3 rename file/class to RmlUi_Renderer_GL3_Spring since it's now more deeply integrated with Spring move VFSInterface to own files
…ces-cleanup rts/Rml code cleanup + move general plugin init/destroy out of Lua-related code
…Texture code to be able to reuse already made textures
…Texture code to be able to reuse already made textures
As outlined in Discord, please extract the engine/build system integration and exclude:
Let this draft serve as work-in-progress branch, but extract the above into another PR/branch so it's easy to review and integrate. |
…ture-element custom <(lua)texture> element to reuse existing textures
@@ -657,6 +657,10 @@ bool RenderInterface_GL3_Spring::GenerateTexture(Rml::TextureHandle& texture_han | |||
|
|||
void RenderInterface_GL3_Spring::ReleaseTexture(Rml::TextureHandle texture_handle) | |||
{ | |||
// Something was using a texture loaded/managed outside of Rml. Do nothing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds worrisome, when can this happen? What if "the outside" frees the texture while RML is still using it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then you end up getting a broken texture when you try to render.
Same thing that can happen if RML (or anything else) frees up a texture that's still in use elsewhere.
I think it's a better solution than copying the texture data needlessly. Though I suppose someone could force a copy to happen.
This check was added because of the <lua-texture>
custom element which asks for texture handles from LuaOpenGLUtils::ParseTextureImage
.
Which I made because I think loading in another copy of all the buildpics/icons for use by RML is a terrible idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A copy texture function/element could also be made- for when you aren't certain that the original texture handle is going to stick around when you need it to.
Here is the PR for part 1: the non lua stuff |
I'm closing this PR as it's being replaced by #1415. The only difference is:
|
Ready for general reviews.
This MR integrates RmlUi into LuaUI so that Rml interfaces can be created in unsynced lua widgets. Overhead for games not adding RmlUi widgets is negligible.
Examples of two widgets using the rmlui interface can be found here.