Fix some bugs appeared

- 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
master
Gliese852 2021-04-09 19:01:18 +03:00 committed by Webster Sheets
parent 20551ae2ea
commit 6081f3e29a
6 changed files with 28 additions and 10 deletions

View File

@ -25,7 +25,20 @@ 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", "NoBackground" }
-- 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.window(window_name, ui.fullScreenWindowFlags, function()
if ui.shouldDrawUI() then
window_fnc()
end
end)
end
end
function ui.get_icon_tex_coords(icon)
assert(icon, "no icon given")

View File

@ -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
@ -109,6 +108,12 @@ local onGameStart = function ()
systemView:SetVisibility(show_grid)
end
local onEnterSystem = function (ship)
if ship == Game.player then
Game.systemView:SetVisibility("RESET_VIEW");
end
end
local function textIcon(icon, tooltip)
ui.icon(icon, textIconSize, svColor.FONT, tooltip)
end
@ -219,7 +224,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
@ -626,6 +631,6 @@ local function displaySystemViewUI()
end
Event.Register("onGameStart", onGameStart)
ui.registerModule("game", displaySystemViewUI)
Event.Register("onEnterSystem", onEnterSystem)
ui.registerHandler("system-view", ui.makeFullScreenHandler("system-view", displaySystemViewUI))
return {}

View File

@ -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
@ -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

View File

@ -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();
}

View File

@ -1032,10 +1032,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.

View File

@ -307,6 +307,7 @@ static LuaFlags<ImGuiWindowFlags_> imguiWindowFlagsTable = {
{ "NoScrollWithMouse", ImGuiWindowFlags_NoScrollWithMouse },
{ "NoCollapse", ImGuiWindowFlags_NoCollapse },
{ "AlwaysAutoResize", ImGuiWindowFlags_AlwaysAutoResize },
{ "NoBackground", ImGuiWindowFlags_NoBackground },
{ "NoSavedSettings", ImGuiWindowFlags_NoSavedSettings },
{ "NoInputs", ImGuiWindowFlags_NoInputs },
{ "MenuBar", ImGuiWindowFlags_MenuBar },