Fix crash in hyperspace with sector map opened
Add icon for DRIVE_ACTIVE status Add checks when rebuilding the jump route Remove some unused vars Fixes #5152master
parent
d43072f7c1
commit
452e9468bc
|
@ -2,7 +2,6 @@
|
||||||
-- Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
|
-- Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
|
||||||
|
|
||||||
local Game = require 'Game'
|
local Game = require 'Game'
|
||||||
local Event = require 'Event'
|
|
||||||
local Equipment = require 'Equipment'
|
local Equipment = require 'Equipment'
|
||||||
|
|
||||||
local Lang = require 'Lang'
|
local Lang = require 'Lang'
|
||||||
|
@ -26,14 +25,12 @@ local hyperJumpPlanner = {} -- for export
|
||||||
-- hyperjump route stuff
|
-- hyperjump route stuff
|
||||||
local hyperjump_route = {}
|
local hyperjump_route = {}
|
||||||
local route_jumps = 0
|
local route_jumps = 0
|
||||||
local auto_route_min_jump = 2 -- minimum jump distance when auto routing
|
|
||||||
local current_system
|
local current_system
|
||||||
local current_path
|
local current_path
|
||||||
local map_selected_path
|
local map_selected_path
|
||||||
local selected_jump
|
local selected_jump
|
||||||
local current_fuel
|
local current_fuel
|
||||||
local remove_first_if_current = true
|
local remove_first_if_current = true
|
||||||
local hideHyperJumpPlaner = false
|
|
||||||
local textIconSize = nil
|
local textIconSize = nil
|
||||||
|
|
||||||
local function textIcon(icon, tooltip)
|
local function textIcon(icon, tooltip)
|
||||||
|
@ -117,7 +114,8 @@ end --mainButton
|
||||||
local function buildJumpRouteList()
|
local function buildJumpRouteList()
|
||||||
hyperjump_route = {}
|
hyperjump_route = {}
|
||||||
local player = Game.player
|
local player = Game.player
|
||||||
local start = Game.system.path
|
-- if we are not in the system, then we are in hyperspace, we start building the route from the jump target
|
||||||
|
local start = Game.system and Game.system.path or player:GetHyperspaceDestination()
|
||||||
local drive = table.unpack(player:GetEquip("engine")) or nil
|
local drive = table.unpack(player:GetEquip("engine")) or nil
|
||||||
local fuel_type = drive and drive.fuel or Equipment.cargo.hydrogen
|
local fuel_type = drive and drive.fuel or Equipment.cargo.hydrogen
|
||||||
local current_fuel = player:CountEquip(fuel_type,"cargo")
|
local current_fuel = player:CountEquip(fuel_type,"cargo")
|
||||||
|
@ -151,7 +149,8 @@ local function updateHyperspaceTarget()
|
||||||
if #hyperjump_route > 0 then
|
if #hyperjump_route > 0 then
|
||||||
-- first waypoint is always the hyperspace target
|
-- first waypoint is always the hyperspace target
|
||||||
sectorView:SetHyperspaceTarget(hyperjump_route[1].path)
|
sectorView:SetHyperspaceTarget(hyperjump_route[1].path)
|
||||||
else
|
elseif not Game.InHyperspace() then
|
||||||
|
-- we will not reset the hyperjump target while we are in the hyperjump
|
||||||
sectorView:ResetHyperspaceTarget()
|
sectorView:ResetHyperspaceTarget()
|
||||||
selected_jump = nil
|
selected_jump = nil
|
||||||
end
|
end
|
||||||
|
@ -169,8 +168,6 @@ local function showJumpRoute()
|
||||||
|
|
||||||
mainButton(icons.current_line, lui.REMOVE_JUMP,
|
mainButton(icons.current_line, lui.REMOVE_JUMP,
|
||||||
function()
|
function()
|
||||||
local new_route = {}
|
|
||||||
local new_count = 0
|
|
||||||
if selected_jump then
|
if selected_jump then
|
||||||
sectorView:RemoveRouteItem(selected_jump)
|
sectorView:RemoveRouteItem(selected_jump)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
-- Copyright © 2008-2021 Pioneer Developers. See AUTHORS.txt for details
|
-- Copyright © 2008-2021 Pioneer Developers. See AUTHORS.txt for details
|
||||||
-- Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
|
-- Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
|
||||||
|
|
||||||
local Engine = require 'Engine'
|
|
||||||
local Game = require 'Game'
|
local Game = require 'Game'
|
||||||
local utils = require 'utils'
|
|
||||||
local Event = require 'Event'
|
local Event = require 'Event'
|
||||||
local Format = require 'Format'
|
local Format = require 'Format'
|
||||||
local SystemPath = require 'SystemPath'
|
local SystemPath = require 'SystemPath'
|
||||||
|
@ -26,7 +24,6 @@ local mainButtonFramePadding = 3
|
||||||
|
|
||||||
local font = ui.fonts.pionillium.medlarge
|
local font = ui.fonts.pionillium.medlarge
|
||||||
local smallfont = ui.fonts.pionillium.medium
|
local smallfont = ui.fonts.pionillium.medium
|
||||||
local MAX_SEARCH_STRINGS_VISIBLE = 15
|
|
||||||
local edgePadding = Vector2(font.size)
|
local edgePadding = Vector2(font.size)
|
||||||
|
|
||||||
local function setAlpha(c, a)
|
local function setAlpha(c, a)
|
||||||
|
@ -52,7 +49,6 @@ local draw_vertical_lines = false
|
||||||
local draw_out_range_labels = false
|
local draw_out_range_labels = false
|
||||||
local draw_uninhabited_labels = true
|
local draw_uninhabited_labels = true
|
||||||
local automatic_system_selection = true
|
local automatic_system_selection = true
|
||||||
local lock_hyperspace_target = false
|
|
||||||
|
|
||||||
local function mainMenuButton(icon, tooltip)
|
local function mainMenuButton(icon, tooltip)
|
||||||
return ui.coloredSelectedIconButton(icon, mainButtonSize, false, mainButtonFramePadding, svColor.BUTTON_ACTIVE, svColor.BUTTON_INK, tooltip)
|
return ui.coloredSelectedIconButton(icon, mainButtonSize, false, mainButtonFramePadding, svColor.BUTTON_ACTIVE, svColor.BUTTON_INK, tooltip)
|
||||||
|
@ -115,6 +111,7 @@ local Windows = {
|
||||||
|
|
||||||
local statusIcons = {
|
local statusIcons = {
|
||||||
OK = { icon = icons.route_destination },
|
OK = { icon = icons.route_destination },
|
||||||
|
DRIVE_ACTIVE = { icon = icons.ship },
|
||||||
CURRENT_SYSTEM = { icon = icons.navtarget },
|
CURRENT_SYSTEM = { icon = icons.navtarget },
|
||||||
INSUFFICIENT_FUEL = { icon = icons.fuel },
|
INSUFFICIENT_FUEL = { icon = icons.fuel },
|
||||||
OUT_OF_RANGE = { icon = icons.alert_generic },
|
OUT_OF_RANGE = { icon = icons.alert_generic },
|
||||||
|
|
Loading…
Reference in New Issue