Skip to content

Commit

Permalink
Lua can make use of ImGui Contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
SirRamEsq committed Jan 20, 2018
1 parent 10583d5 commit cab659d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Data/Resources/Scripts/worldStageIcon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ container.New = function(base)
class.LoadFont()
class.SetResolution()

class.CompPosition = c:GetPositionComponent(eid)
class.CompSprite = c:GetSpriteComponent(eid)
local spr = class.CompSprite
class.depth = spr:GetDepth()
Expand Down Expand Up @@ -96,6 +97,9 @@ container.New = function(base)
local windowFlags = imGuiFlags.NoTitleBar + imGuiFlags.NoResize +
imGuiFlags.NoMove + imGuiFlags.AlwaysAutoResize

--World Position
CPP.ImGui.SetContext(1)

--push style options
CPP.ImGui.PushStyleColorWindowBG(CPP.Color(0.2, 0.2, 0.2, 1))

Expand All @@ -115,7 +119,9 @@ container.New = function(base)
local target = CPP.Vec2(class.windowX, class.windowY)

target.x = class.SlideFromRight(target.x)
CPP.ImGui.SetWindowPos(class.stageName, target, 0)
CPP.ImGui.SetWindowPos(class.stageName, class.CompPosition:GetPositionWorld(), 0)

CPP.ImGui.SetContext(0)
end

table.insert(class.InitFunctions, Init)
Expand Down
2 changes: 2 additions & 0 deletions Source/Engine/gui/imgui_LEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ void ImGui::ExposeLuaInterface(lua_State *state) {
.addFunction("BeginFlags", &ImGui::BeginFlags)
.addFunction("End", &ImGui::End)

.addFunction("SetContext", &ImGui::SetContext)

.addFunction("SetWindowPos", &ImGui::SetWindowPosWrapper)
.addFunction("SetWindowSize", &ImGui::SetWindowSizeWrapper)
.addFunction("GetWindowSize", &ImGui::GetWindowSizeWrapper)
Expand Down

0 comments on commit cab659d

Please sign in to comment.