Added environment panel for depth, pressure and outside temperature.
This commit is contained in:
1 parent
2d91487c6a
commit
92006372da
21 files changed
+2825
-1616
No files matched your search
+86
-34
@@ -1,39 +1,36 @@
|
||||
extends SceneTree
|
||||
|
||||
const ACCENT = Color("ff7b00")
|
||||
const SECONDARY = Color("402e32")
|
||||
const CLEAR = Color.TRANSPARENT
|
||||
|
||||
const HIGH_CONTRAST = {
|
||||
"text": Color("f5f1ed"), "muted_text": Color("b9b0b3"),
|
||||
"active_text": Color("141114"), "surface": Color("201b1f"),
|
||||
"panel": Color("201b1f"), "input": Color("141114"),
|
||||
"hover": SECONDARY, "pressed": ACCENT, "fill": ACCENT,
|
||||
"disabled": Color("191619"), "border": Color("817278"),
|
||||
"disabled_border": Color("51464c"), "focus": ACCENT,
|
||||
"separator": SECONDARY, "thumb": Color("b9b0b3"),
|
||||
"fill_text": Color("141114"),
|
||||
}
|
||||
const SOFT = {
|
||||
"text": Color("e7e0dd"), "muted_text": Color("ada2a8"),
|
||||
"active_text": Color("f5f1ed"), "surface": Color("292126"),
|
||||
"panel": Color("201b1f"), "input": Color("141114"),
|
||||
"hover": SECONDARY, "pressed": SECONDARY,
|
||||
"fill": ACCENT, "disabled": Color("211c20"),
|
||||
"border": CLEAR, "disabled_border": CLEAR,
|
||||
"focus": ACCENT, "separator": SECONDARY,
|
||||
"thumb": Color("d2c6c9"), "fill_text": Color("141114"),
|
||||
}
|
||||
const COLORS = preload("res://themes/palette.gd")
|
||||
|
||||
func _initialize() -> void:
|
||||
for high_contrast in [false, true]:
|
||||
var palette: Dictionary = HIGH_CONTRAST if high_contrast else SOFT
|
||||
var palette: Dictionary = COLORS.HIGH_CONTRAST if high_contrast else COLORS.SOFT
|
||||
var path := "res://themes/theme_highcontrast.tres" if high_contrast else "res://themes/theme.tres"
|
||||
var error := ResourceSaver.save(_build_theme(palette, high_contrast), path)
|
||||
if error != OK:
|
||||
push_error("Could not save %s: %s" % [path, error_string(error)])
|
||||
quit(error)
|
||||
return
|
||||
var material := StandardMaterial3D.new()
|
||||
material.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
material.cull_mode = BaseMaterial3D.CULL_DISABLED
|
||||
material.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
material.albedo_color = COLORS.COMPASS_TEST
|
||||
material.albedo_texture = load("res://assets/vector/dial.svg")
|
||||
var material_error := ResourceSaver.save(material, "res://themes/compass_material.tres")
|
||||
if material_error != OK:
|
||||
push_error("Could not save compass material: " + error_string(material_error))
|
||||
quit(material_error)
|
||||
return
|
||||
var config := ConfigFile.new()
|
||||
var config_error := config.load("res://project.godot")
|
||||
if config_error == OK and config.get_value("rendering", "environment/defaults/default_clear_color") != COLORS.VIEWPORT_BACKGROUND:
|
||||
config.set_value("rendering", "environment/defaults/default_clear_color", COLORS.VIEWPORT_BACKGROUND)
|
||||
config_error = config.save("res://project.godot")
|
||||
if config_error != OK:
|
||||
push_error("Could not update viewport background: " + error_string(config_error))
|
||||
quit(config_error)
|
||||
return
|
||||
quit()
|
||||
|
||||
func _build_theme(palette: Dictionary, high_contrast: bool) -> Theme:
|
||||
@@ -48,7 +45,7 @@ func _build_theme(palette: Dictionary, high_contrast: bool) -> Theme:
|
||||
if "disabled" in name or "placeholder" in name or "readonly" in name:
|
||||
color = palette.muted_text
|
||||
elif "selection" in name:
|
||||
color = SECONDARY
|
||||
color = COLORS.SECONDARY
|
||||
elif name in ["font_pressed_color", "font_hover_pressed_color"] and type in ["Button", "OptionButton", "MenuButton"]:
|
||||
color = palette.active_text
|
||||
elif name == "font_selected_color" and type == "TabContainer":
|
||||
@@ -56,11 +53,11 @@ func _build_theme(palette: Dictionary, high_contrast: bool) -> Theme:
|
||||
elif name == "font_color" and type == "ProgressBar":
|
||||
color = palette.fill_text
|
||||
elif "background" in name:
|
||||
color = CLEAR
|
||||
color = COLORS.CLEAR
|
||||
elif "caret" in name or "accent" in name:
|
||||
color = ACCENT
|
||||
color = COLORS.ACCENT
|
||||
elif "shadow" in name or "outline" in name:
|
||||
color = CLEAR
|
||||
color = COLORS.CLEAR
|
||||
theme.set_color(name, type, color)
|
||||
for name in theme.get_stylebox_list(type):
|
||||
var original := theme.get_stylebox(name, type)
|
||||
@@ -99,13 +96,11 @@ func _build_theme(palette: Dictionary, high_contrast: bool) -> Theme:
|
||||
style.bg_color = palette.separator
|
||||
style.border_color = palette.separator
|
||||
theme.set_stylebox(name, type, style)
|
||||
# Slider thumbs use square textures instead of the engine's round icons.
|
||||
for type in ["HSlider", "VSlider"]:
|
||||
for name in ["grabber", "grabber_highlight", "grabber_disabled"]:
|
||||
var bitmap := Image.create(14, 18, false, Image.FORMAT_RGBA8)
|
||||
bitmap.fill(ACCENT if name == "grabber_highlight" else palette.thumb)
|
||||
bitmap.fill(COLORS.ACCENT if name == "grabber_highlight" else palette.thumb)
|
||||
theme.set_icon(name, type, ImageTexture.create_from_image(bitmap))
|
||||
# Dedicated panel states used by the keyboard focus containers.
|
||||
var panel := theme.get_stylebox("panel", "PanelContainer").duplicate() as StyleBoxFlat
|
||||
theme.set_stylebox("panel_inactive", "SurfaceSide", panel)
|
||||
var active := panel.duplicate() as StyleBoxFlat
|
||||
@@ -114,6 +109,63 @@ func _build_theme(palette: Dictionary, high_contrast: bool) -> Theme:
|
||||
if not high_contrast:
|
||||
active.border_width_top = 2
|
||||
theme.set_stylebox("panel_active", "SurfaceSide", active)
|
||||
theme.set_color("accent", "SurfaceSide", ACCENT)
|
||||
theme.set_color("secondary", "SurfaceSide", SECONDARY)
|
||||
theme.set_color("accent", "SurfaceSide", COLORS.ACCENT)
|
||||
theme.set_color("secondary", "SurfaceSide", COLORS.SECONDARY)
|
||||
_add_instrument_theme(theme, palette)
|
||||
for role in COLORS.STATUS:
|
||||
theme.set_color(role, "SurfaceSide", COLORS.STATUS[role])
|
||||
theme.set_type_variation("VehicleWarningText", "Label")
|
||||
theme.set_color("font_color", "VehicleWarningText", COLORS.STATUS.status_ink)
|
||||
theme.set_type_variation("VehicleFaultText", "Label")
|
||||
theme.set_color("font_color", "VehicleFaultText", COLORS.WHITE)
|
||||
theme.set_type_variation("VehicleBackground", "PanelContainer")
|
||||
var vehicle_background := StyleBoxFlat.new()
|
||||
vehicle_background.bg_color = palette.panel
|
||||
vehicle_background.border_color = palette.border
|
||||
vehicle_background.set_border_width_all(1 if high_contrast else 0)
|
||||
theme.set_stylebox("panel", "VehicleBackground", vehicle_background)
|
||||
theme.set_type_variation("LayoutItemBackground", "Panel")
|
||||
theme.set_stylebox("panel", "LayoutItemBackground", vehicle_background)
|
||||
theme.set_type_variation("LayoutLibraryList", "ItemList")
|
||||
theme.set_color("guide_color", "LayoutLibraryList", COLORS.SECONDARY if high_contrast else COLORS.CLEAR)
|
||||
theme.set_constant("v_separation", "LayoutLibraryList", 8)
|
||||
for variant in ["LinkRateNormal", "LinkRateWarning", "LinkRateFault", "LinkMuted"]:
|
||||
theme.set_type_variation(variant, "Label")
|
||||
theme.set_color("font_color", "LinkRateNormal", COLORS.INSTRUMENT.instrument_accent)
|
||||
theme.set_color("font_color", "LinkRateWarning", COLORS.WARNING)
|
||||
theme.set_color("font_color", "LinkRateFault", COLORS.FAULT)
|
||||
theme.set_color("font_color", "LinkMuted", palette.muted_text)
|
||||
for variant in ["InstrumentWarning", "InstrumentFault", "InstrumentMuted"]:
|
||||
theme.set_type_variation(variant, "Label")
|
||||
theme.set_color("font_color", "InstrumentWarning", COLORS.WARNING)
|
||||
theme.set_color("font_color", "InstrumentFault", COLORS.FAULT)
|
||||
theme.set_color("font_color", "InstrumentMuted", palette.muted_text)
|
||||
return theme
|
||||
|
||||
func _add_instrument_theme(theme: Theme, palette: Dictionary) -> void:
|
||||
for role in COLORS.INSTRUMENT:
|
||||
theme.set_color(role, "SurfaceSide", COLORS.INSTRUMENT[role])
|
||||
theme.set_color("instrument_empty", "SurfaceSide", palette.input)
|
||||
theme.set_color("instrument_axis", "SurfaceSide", palette.muted_text)
|
||||
theme.set_type_variation("MotionBackground", "Panel")
|
||||
var background := StyleBoxFlat.new()
|
||||
background.bg_color = palette.panel
|
||||
theme.set_stylebox("panel", "MotionBackground", background)
|
||||
for vertical in [false, true]:
|
||||
var type := "MotionVSeparator" if vertical else "MotionHSeparator"
|
||||
theme.set_type_variation(type, "VSeparator" if vertical else "HSeparator")
|
||||
var separator := StyleBoxLine.new()
|
||||
separator.color = COLORS.INSTRUMENT.instrument_grid
|
||||
separator.thickness = 1
|
||||
separator.vertical = vertical
|
||||
theme.set_stylebox("separator", type, separator)
|
||||
theme.set_type_variation("MotionAlertPanel", "PanelContainer")
|
||||
var alert := StyleBoxFlat.new()
|
||||
alert.bg_color = COLORS.INSTRUMENT.alert_background
|
||||
alert.content_margin_top = 7
|
||||
alert.content_margin_bottom = 7
|
||||
theme.set_stylebox("panel", "MotionAlertPanel", alert)
|
||||
theme.set_type_variation("MotionAlertText", "Label")
|
||||
theme.set_color("font_color", "MotionAlertText", COLORS.INSTRUMENT.alert_text)
|
||||
theme.set_type_variation("MotionWarning", "Label")
|
||||
theme.set_color("font_color", "MotionWarning", COLORS.INSTRUMENT.instrument_accent)
|
||||
@@ -8,6 +8,8 @@ const PANEL = Color("201b1f")
|
||||
const SKY = Color("172f40")
|
||||
const GROUND = Color("4b3930")
|
||||
const COMPASS_TEST = Color(0.44361365, 0.72118443, 0, 1)
|
||||
const WARNING = Color("f5c542")
|
||||
const FAULT = Color("dc414b")
|
||||
const WHITE = Color.WHITE
|
||||
const CLEAR = Color.TRANSPARENT
|
||||
|
||||
@@ -55,3 +57,12 @@ static var INSTRUMENT: Dictionary = {
|
||||
"alert_background": ACCENT_DARK,
|
||||
"alert_text": WHITE,
|
||||
}
|
||||
|
||||
static var STATUS: Dictionary = {
|
||||
"warning": WARNING,
|
||||
"warning_alternate": WARNING.darkened(0.36),
|
||||
"fault": FAULT,
|
||||
"fault_alternate": FAULT.darkened(0.50),
|
||||
"status_ink": INPUT,
|
||||
"status_icon": ACCENT_LIGHT,
|
||||
}
|
||||
+1409
-803
File diff suppressed because it is too large.
Load diff
+830
-756
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user