Skip to content

Commit

Permalink
Fix some bugs appeared
Browse files Browse the repository at this point in the history
- Move the drawing of the system map pigui to a separate handler to
  ensure that it will always be drawn strictly after the SystemView object
- Fix the setting of the m_colliding parameter of the ship during
  deserialization
  • Loading branch information
Gliese852 committed Apr 9, 2021
1 parent 02a405c commit d40efe8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
17 changes: 16 additions & 1 deletion data/pigui/baseui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,22 @@ ui.pi_4 = pi_4
ui.pi = pi

ui.anchor = { left = 1, right = 2, center = 3, top = 4, bottom = 5, baseline = 6 }

ui.fullScreenWindowFlags = ui.WindowFlags {"NoTitleBar", "NoResize", "NoMove", "NoInputs", "NoSavedSettings", "NoFocusOnAppearing", "NoBringToFrontOnFocus"}

-- make all the necessary preparations for displaying the full-screen UI, launch the drawing function
function ui.makeFullScreenHandler(window_name, window_fnc)
return function()
ui.setNextWindowPos(Vector2(0, 0), "Always")
ui.setNextWindowSize(Vector2(ui.screenWidth, ui.screenHeight), "Always")
ui.withStyleColors({ ["WindowBg"] = ui.theme.colors.transparent }, function()
ui.window(window_name, ui.fullScreenWindowFlags, function()
if ui.shouldDrawUI() then
window_fnc()
end
end)
end)
end
end

function ui.get_icon_tex_coords(icon)
assert(icon, "no icon given")
Expand Down
6 changes: 2 additions & 4 deletions data/pigui/modules/system-view-ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ local edgePadding = nil

local mainButtonSize = ui.rescaleUI(Vector2(32,32), Vector2(1600, 900))
local mainButtonFramePadding = 3
local itemSpacing = Vector2(8, 4) -- couldn't get default from ui
local indicatorSize = Vector2(30 , 30)

local selectedObject -- object, centered in SystemView
Expand Down Expand Up @@ -219,7 +218,7 @@ function Windows.orbitPlanner.Show()
ui.separator()
showDvLine(icons.decrease, icons.delta, icons.increase, "factor", function(i) return i, "x" end, luc.DECREASE, lc.PLANNER_RESET_FACTOR, luc.INCREASE)
showDvLine(icons.decrease, icons.clock, icons.increase, "starttime",
function(i)
function(_)
local now = Game.time
local start = systemView:GetOrbitPlannerStartTime()
if start then
Expand Down Expand Up @@ -626,6 +625,5 @@ local function displaySystemViewUI()
end

Event.Register("onGameStart", onGameStart)
ui.registerModule("game", displaySystemViewUI)

ui.registerHandler("system-view", ui.makeFullScreenHandler("system-view", displaySystemViewUI))
return {}
3 changes: 1 addition & 2 deletions data/pigui/views/game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ local function drawGameModules(delta_t)
end
end

local gameViewWindowFlags = ui.WindowFlags {"NoTitleBar", "NoResize", "NoMove", "NoInputs", "NoSavedSettings", "NoFocusOnAppearing", "NoBringToFrontOnFocus"}
ui.registerHandler('game', function(delta_t)
-- delta_t is ignored for now
player = Game.player
Expand All @@ -228,7 +227,7 @@ ui.registerHandler('game', function(delta_t)
ui.setNextWindowPos(Vector2(0, 0), "Always")
ui.setNextWindowSize(Vector2(ui.screenWidth, ui.screenHeight), "Always")
ui.withStyleColors({ ["WindowBg"] = colors.transparent }, function()
ui.window("HUD", gameViewWindowFlags, function()
ui.window("HUD", ui.fullScreenWindowFlags, function()
gameView.center = Vector2(ui.screenWidth / 2, ui.screenHeight / 2)
if ui.shouldDrawUI() then
if Game.CurrentView() == "world" then
Expand Down
2 changes: 1 addition & 1 deletion src/ModelBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ ModelBody::ModelBody(const Json &jsonObj, Space *space) :

try {
m_isStatic = modelBodyObj["is_static"];
m_colliding = modelBodyObj["is_colliding"];
SetModel(modelBodyObj["model_name"].get<std::string>().c_str());
SetColliding(modelBodyObj["is_colliding"]);
} catch (Json::type_error &) {
throw SavedGameCorruptException();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1030,10 +1030,10 @@ void GameLoop::Update(float deltaTime)
// TODO: this mechanism still isn't perfect, but it gets us out of newUI
if (Pi::luaConsole->IsActive())
Pi::luaConsole->Draw();
else
else {
Pi::GetView()->DrawPiGui();
PiGui::RunHandler(deltaTime, "game");

Pi::GetView()->DrawPiGui();
}
}

// Render this even when we're dead.
Expand Down

0 comments on commit d40efe8

Please sign in to comment.