-
-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for showing gauges. Add planetary info.
Modules can now add gauges with ui.registerGauge (see data/pigui/modules/gauges.lua for details). Latitude/Longitude are now shown with imgui.
- Loading branch information
Showing
16 changed files
with
388 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
local Engine = import('Engine') | ||
local Game = import('Game') | ||
local ui = import('pigui/pigui.lua') | ||
local Vector = import('Vector') | ||
local Color = import('Color') | ||
local Lang = import("Lang") | ||
local lc = Lang.GetResource("core"); | ||
local lui = Lang.GetResource("ui-core"); | ||
local utils = import("utils") | ||
local Event = import("Event") | ||
|
||
local pionillium = ui.fonts.pionillium | ||
local pionicons = ui.fonts.pionicons | ||
local colors = ui.theme.colors | ||
local icons = ui.theme.icons | ||
|
||
|
||
function addGauge(priority, valueFun, unit, format, min, max, icon, color, tooltip) | ||
ui.registerGauge(function() | ||
local v = valueFun() | ||
return { value = v, unit = unit, format = format, min = min, max = max, icon = icon, color = color, tooltip = tooltip } | ||
end | ||
, priority) | ||
end | ||
|
||
addGauge(0, function () | ||
local t = Game.player:GetGunTemperature(0) * 100 | ||
if t and t > 0 then | ||
return t | ||
else | ||
return nil | ||
end | ||
end, '%', '%i', 0, 100, icons.forward, colors.gaugeWeapon, lui.HUD_FORWARD_GUN_TEMPERATURE) | ||
addGauge(1, function () | ||
local t = Game.player:GetGunTemperature(1) * 100 | ||
if t and t > 0 then | ||
return t | ||
else | ||
return nil | ||
end | ||
end, '%', '%i', 0, 100, icons.backward, colors.gaugeWeapon, lui.HUD_BACKWARD_GUN_TEMPERATURE) | ||
addGauge(2, function () | ||
local frame = Game.player.frameBody | ||
if frame then | ||
local pressure, density = frame:GetAtmosphericState() | ||
return pressure | ||
else | ||
return nil | ||
end | ||
end, | ||
'atm', '%.2f', 0, 15, icons.pressure, colors.gaugePressure, lui.HUD_ATMOSPHERIC_PRESSURE) | ||
addGauge(3, function () | ||
local t = Game.player:GetHullTemperature() * 100 | ||
if t and t > 0 then | ||
return t | ||
else | ||
return nil | ||
end | ||
end, '%', '%i', 0, 100, icons.temperature, colors.gaugeTemperature, lui.HUD_HULL_TEMPERATURE) | ||
addGauge(4, function () return Game.player:GetHullPercent() end, '%', '%i', 0, 100, icons.hull, colors.gaugeHull, lui.HUD_HULL_STRENGTH) | ||
addGauge(5, function () return Game.player:GetShieldsPercent() end, '%', '%i', 0, 100, icons.shield, colors.gaugeShield, lui.HUD_SHIELD_STRENGTH) | ||
|
||
return {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
local Engine = import('Engine') | ||
local Game = import('Game') | ||
local ui = import('pigui/pigui.lua') | ||
local Vector = import('Vector') | ||
local Color = import('Color') | ||
local Lang = import("Lang") | ||
local lc = Lang.GetResource("core"); | ||
local lui = Lang.GetResource("ui-core"); | ||
local utils = import("utils") | ||
local Event = import("Event") | ||
|
||
local player = nil | ||
local pionillium = ui.fonts.pionillium | ||
local pionicons = ui.fonts.pionicons | ||
local colors = ui.theme.colors | ||
local icons = ui.theme.icons | ||
|
||
local iconSize = Vector(16,16) | ||
|
||
local function displayPlanetaryInfo() | ||
local player = Game.player | ||
local alt, vspd, latitude, longitude = player:GetGPS() | ||
if latitude and longitude and alt and vspd then | ||
ui.setNextWindowSize(Vector(140,120), "Always") | ||
ui.window("PlanetaryInfo", {"NoTitleBar", "NoResize", "NoFocusOnAppearing", "NoBringToFrontOnFocus"}, | ||
function() | ||
ui.withFont(pionillium.medium.name, pionillium.medium.size, function() | ||
ui.icon(icons.altitude, iconSize, colors.reticuleCircle) | ||
ui.sameLine() | ||
local altitude,altitude_unit = ui.Format.Distance(alt) | ||
ui.text(altitude .. altitude_unit) | ||
ui.icon(icons.normal, iconSize, colors.reticuleCircle) | ||
ui.sameLine() | ||
local speed,speed_unit = ui.Format.Distance(vspd) | ||
ui.text(speed .. speed_unit) | ||
ui.icon(icons.latitude, iconSize, colors.reticuleCircle) | ||
ui.sameLine() | ||
ui.text(ui.Format.Latitude(latitude)) | ||
ui.icon(icons.longitude, iconSize, colors.reticuleCircle) | ||
ui.sameLine() | ||
ui.text(ui.Format.Longitude(longitude)) | ||
|
||
end) | ||
end) | ||
end | ||
end | ||
|
||
ui.registerModule("game", displayPlanetaryInfo) | ||
|
||
return {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.