X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data/pigui/libs/forwarded.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ui.getTextLineHeightWithSpacing = pigui.GetTextLineHeightWithSpacing
ui.lowThrustButton = pigui.LowThrustButton
ui.thrustIndicator = pigui.ThrustIndicator
ui.isMouseClicked = pigui.IsMouseClicked
ui.isMouseDoubleClicked = pigui.IsMouseDoubleClicked
ui.isMouseDown = pigui.IsMouseDown
ui.getMousePos = pigui.GetMousePos
ui.getMouseWheel = pigui.GetMouseWheel
Expand Down
12 changes: 5 additions & 7 deletions data/pigui/modules/time-window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ local frame_padding = 3
local bg_color = colors.buttonBlue
local fg_color = colors.white


local function displayTimeWindow()
player = Game.player

-- HACK: Don't display the time window if we're in a bespoke view
if Game.CurrentView() == nil then return end

Expand All @@ -42,16 +39,17 @@ local function displayTimeWindow()
if requested == name and current ~= name then
color = colors.white
end
local time = name
-- translate only paused, the rest can stay
if time == "paused" then
time = lc.PAUSED
end
local time = (name == "paused") and lc.PAUSED or name
local tooltip = string.interp(lui.HUD_REQUEST_TIME_ACCEL, { time = time })
if ui.coloredSelectedIconButton(icons['time_accel_' .. name], button_size, current == name, frame_padding, color, fg_color, tooltip .. "##time_accel_"..name)
or (ui.shiftHeld() and ui.isKeyReleased(key)) then
Game.SetTimeAcceleration(name, ui.ctrlHeld() or ui.isMouseDown(1))
end
-- isItemHovered is true for ALL the buttons
if ui.isItemHovered(0) and ui.isMouseDoubleClicked(0) and (name == "paused") then
ui.optionsWindow:open()
end
ui.sameLine()
end

Expand Down
9 changes: 9 additions & 0 deletions src/lua/LuaPiGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,14 @@ static int l_pigui_is_mouse_clicked(lua_State *l)
return 1;
}

static int l_pigui_is_mouse_doubleclicked(lua_State *l)
{
PROFILE_SCOPED()
int button = LuaPull<int>(l, 1);
LuaPush(l, ImGui::IsMouseDoubleClicked(button));
return 1;
}

static int l_pigui_push_font(lua_State *l)
{
PROFILE_SCOPED()
Expand Down Expand Up @@ -2875,6 +2883,7 @@ void LuaObject<PiGui::Instance>::RegisterClass()
{ "PopID", l_pigui_pop_id },
{ "IsMouseReleased", l_pigui_is_mouse_released },
{ "IsMouseClicked", l_pigui_is_mouse_clicked },
{ "IsMouseDoubleClicked", l_pigui_is_mouse_doubleclicked },
{ "IsMouseDown", l_pigui_is_mouse_down },
{ "IsMouseHoveringRect", l_pigui_is_mouse_hovering_rect },
{ "IsWindowHovered", l_pigui_is_window_hovered },
Expand Down
X Tutup