Roblox backend: block game input with a 1x1 frame under the mouse instead of Active tiles
This commit is contained in:
+16
-7
@@ -33542,7 +33542,6 @@ local function GetTile(bd, index, tx, ty)
|
||||
label.ResampleMode = Enum.ResamplerMode.Pixelated
|
||||
label.ImageContent = Content.fromObject(img)
|
||||
label.Visible = false
|
||||
label.Active = bd.TilesActive
|
||||
label.Parent = bd.Gui
|
||||
tile = { Image = img, Label = label, Buffer = buffer.create(TILE * TILE * 4), H1 = -1, H2 = -1, Visible = false }
|
||||
bd.Tiles[index] = tile
|
||||
@@ -33731,10 +33730,22 @@ function ImGui_ImplRoblox_Init(parent, render_scale)
|
||||
local bd = {
|
||||
Time = os.clock(), Gui = gui, Connections = {},
|
||||
Textures = {}, TextureCount = 0, MouseX = -1, MouseY = -1,
|
||||
Tiles = {}, TileCols = 0, TileRows = 0, Scale = render_scale or 1, TilesActive = false, TH1 = {}, TH2 = {}, TN = {}, TL = {}, LastPrimCount = 0, ForceRedraw = true,
|
||||
Tiles = {}, TileCols = 0, TileRows = 0, Scale = render_scale or 1, TH1 = {}, TH2 = {}, TN = {}, TL = {}, LastPrimCount = 0, ForceRedraw = true,
|
||||
}
|
||||
io.BackendPlatformUserData = bd
|
||||
|
||||
-- 1x1 Active frame that follows the mouse while imgui wants it: sinks clicks/wheel only where imgui owns the mouse
|
||||
local blocker = Instance.new("Frame")
|
||||
blocker.Name = "InputBlocker"
|
||||
blocker.BackgroundTransparency = 1
|
||||
blocker.BorderSizePixel = 0
|
||||
blocker.Active = true
|
||||
blocker.ZIndex = 2
|
||||
blocker.Size = UDim2.fromOffset(1, 1)
|
||||
blocker.Visible = false
|
||||
blocker.Parent = gui
|
||||
bd.Blocker = blocker
|
||||
|
||||
io.BackendFlags = bit32.bor(io.BackendFlags, ImGuiBackendFlags.RendererHasTextures, ImGuiBackendFlags.RendererHasVtxOffset)
|
||||
|
||||
local platform_io = ImGui.GetPlatformIO()
|
||||
@@ -33826,12 +33837,10 @@ function ImGui_ImplRoblox_NewFrame()
|
||||
io:AddMousePosEvent(m.X * bd.Scale, m.Y * bd.Scale)
|
||||
end
|
||||
|
||||
-- While the mouse is over imgui, make the tiles Active so Roblox stops passing clicks/wheel to the game (camera zoom etc.)
|
||||
-- Keep the blocker under the mouse while imgui wants it, so the game (camera zoom etc.) doesn't get the input
|
||||
local want = io.WantCaptureMouse
|
||||
if want ~= bd.TilesActive then
|
||||
bd.TilesActive = want
|
||||
for _, tile in pairs(bd.Tiles) do tile.Label.Active = want end
|
||||
end
|
||||
bd.Blocker.Visible = want
|
||||
if want then bd.Blocker.Position = UDim2.fromOffset(m.X, m.Y) end
|
||||
end
|
||||
|
||||
function ImGui_ImplRoblox_SetRenderScale(scale)
|
||||
|
||||
@@ -471,7 +471,6 @@ local function GetTile(bd, index, tx, ty)
|
||||
label.ResampleMode = Enum.ResamplerMode.Pixelated
|
||||
label.ImageContent = Content.fromObject(img)
|
||||
label.Visible = false
|
||||
label.Active = bd.TilesActive
|
||||
label.Parent = bd.Gui
|
||||
tile = { Image = img, Label = label, Buffer = buffer.create(TILE * TILE * 4), H1 = -1, H2 = -1, Visible = false }
|
||||
bd.Tiles[index] = tile
|
||||
@@ -660,10 +659,22 @@ function ImGui_ImplRoblox_Init(parent, render_scale)
|
||||
local bd = {
|
||||
Time = os.clock(), Gui = gui, Connections = {},
|
||||
Textures = {}, TextureCount = 0, MouseX = -1, MouseY = -1,
|
||||
Tiles = {}, TileCols = 0, TileRows = 0, Scale = render_scale or 1, TilesActive = false, TH1 = {}, TH2 = {}, TN = {}, TL = {}, LastPrimCount = 0, ForceRedraw = true,
|
||||
Tiles = {}, TileCols = 0, TileRows = 0, Scale = render_scale or 1, TH1 = {}, TH2 = {}, TN = {}, TL = {}, LastPrimCount = 0, ForceRedraw = true,
|
||||
}
|
||||
io.BackendPlatformUserData = bd
|
||||
|
||||
-- 1x1 Active frame that follows the mouse while imgui wants it: sinks clicks/wheel only where imgui owns the mouse
|
||||
local blocker = Instance.new("Frame")
|
||||
blocker.Name = "InputBlocker"
|
||||
blocker.BackgroundTransparency = 1
|
||||
blocker.BorderSizePixel = 0
|
||||
blocker.Active = true
|
||||
blocker.ZIndex = 2
|
||||
blocker.Size = UDim2.fromOffset(1, 1)
|
||||
blocker.Visible = false
|
||||
blocker.Parent = gui
|
||||
bd.Blocker = blocker
|
||||
|
||||
io.BackendFlags = bit32.bor(io.BackendFlags, ImGuiBackendFlags.RendererHasTextures, ImGuiBackendFlags.RendererHasVtxOffset)
|
||||
|
||||
local platform_io = ImGui.GetPlatformIO()
|
||||
@@ -755,12 +766,10 @@ function ImGui_ImplRoblox_NewFrame()
|
||||
io:AddMousePosEvent(m.X * bd.Scale, m.Y * bd.Scale)
|
||||
end
|
||||
|
||||
-- While the mouse is over imgui, make the tiles Active so Roblox stops passing clicks/wheel to the game (camera zoom etc.)
|
||||
-- Keep the blocker under the mouse while imgui wants it, so the game (camera zoom etc.) doesn't get the input
|
||||
local want = io.WantCaptureMouse
|
||||
if want ~= bd.TilesActive then
|
||||
bd.TilesActive = want
|
||||
for _, tile in pairs(bd.Tiles) do tile.Label.Active = want end
|
||||
end
|
||||
bd.Blocker.Visible = want
|
||||
if want then bd.Blocker.Position = UDim2.fromOffset(m.X, m.Y) end
|
||||
end
|
||||
|
||||
function ImGui_ImplRoblox_SetRenderScale(scale)
|
||||
|
||||
Reference in New Issue
Block a user