diff --git a/LICENSE.md b/LICENSE.md index 9bba6f8a..0dcca539 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -118,6 +118,7 @@ SOFTWARE. - dropdown - radar - radio +- target_info --- diff --git a/fx/wireframe.gdshader b/fx/wireframe.gdshader new file mode 100644 index 00000000..c54c6a87 --- /dev/null +++ b/fx/wireframe.gdshader @@ -0,0 +1,30 @@ +shader_type spatial; + +render_mode unshaded, wireframe; + +uniform vec4 wireframe_color : source_color = vec4(0.0, 0.0, 0.0, 1.0); +uniform float wireframe_thickness : hint_range(0.0, 10.0) = 1.0; +uniform float wireframe_smoothness : hint_range(0.0, 10.0) = 1.0; + +varying vec3 barycentric_coords; + +void vertex() { + // Calculate barycentric coordinates + float base = float(VERTEX_ID % 3); + barycentric_coords = vec3(0.0); + barycentric_coords[int(base)] = 1.0; +} + +void fragment() { + // Calculate the minimum distance to an edge + vec3 deltas = fwidth(barycentric_coords); + vec3 smoothing = deltas * wireframe_smoothness; + vec3 thickness = deltas * wireframe_thickness; + + vec3 barycentric = smoothstep(thickness, thickness + smoothing, barycentric_coords); + float min_distance = min(min(barycentric.x, barycentric.y), barycentric.z); + + // Mix the wireframe color with transparency based on the distance + ALBEDO = wireframe_color.rgb; + ALPHA = 1.0 - min_distance; +} diff --git a/gui/hud/images/target_info/bar_empty.png b/gui/hud/images/target_info/bar_empty.png new file mode 100644 index 00000000..f9fbcefe Binary files /dev/null and b/gui/hud/images/target_info/bar_empty.png differ diff --git a/gui/hud/images/target_info/bar_empty.png.import b/gui/hud/images/target_info/bar_empty.png.import new file mode 100644 index 00000000..07856d22 --- /dev/null +++ b/gui/hud/images/target_info/bar_empty.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cwdmvrqg25666" +path="res://.godot/imported/bar_empty.png-b104e5c09f9d9231156ca764a29a557a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://gui/hud/images/target_info/bar_empty.png" +dest_files=["res://.godot/imported/bar_empty.png-b104e5c09f9d9231156ca764a29a557a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/gui/hud/images/target_info/heading_border.png b/gui/hud/images/target_info/heading_border.png new file mode 100644 index 00000000..c0a98858 Binary files /dev/null and b/gui/hud/images/target_info/heading_border.png differ diff --git a/gui/hud/images/target_info/heading_border.png.import b/gui/hud/images/target_info/heading_border.png.import new file mode 100644 index 00000000..64f755bb --- /dev/null +++ b/gui/hud/images/target_info/heading_border.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dcg5m8doqdfc" +path="res://.godot/imported/heading_border.png-c966ae8439c2daa80140c98ef2f97888.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://gui/hud/images/target_info/heading_border.png" +dest_files=["res://.godot/imported/heading_border.png-c966ae8439c2daa80140c98ef2f97888.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/gui/hud/images/target_info/hull_fill.png b/gui/hud/images/target_info/hull_fill.png new file mode 100644 index 00000000..dfe2f475 Binary files /dev/null and b/gui/hud/images/target_info/hull_fill.png differ diff --git a/gui/hud/images/target_info/hull_fill.png.import b/gui/hud/images/target_info/hull_fill.png.import new file mode 100644 index 00000000..c42c357c --- /dev/null +++ b/gui/hud/images/target_info/hull_fill.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://e8r1y25pox5u" +path="res://.godot/imported/hull_fill.png-555f5f5b083a2023ff49c2a7584268d1.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://gui/hud/images/target_info/hull_fill.png" +dest_files=["res://.godot/imported/hull_fill.png-555f5f5b083a2023ff49c2a7584268d1.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/gui/hud/images/target_info/shields_fill.png b/gui/hud/images/target_info/shields_fill.png new file mode 100644 index 00000000..cec7f2fe Binary files /dev/null and b/gui/hud/images/target_info/shields_fill.png differ diff --git a/gui/hud/images/target_info/shields_fill.png.import b/gui/hud/images/target_info/shields_fill.png.import new file mode 100644 index 00000000..6033712d --- /dev/null +++ b/gui/hud/images/target_info/shields_fill.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bsf3tqgocto7h" +path="res://.godot/imported/shields_fill.png-9eebbd928584a892ac05d44c6835b499.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://gui/hud/images/target_info/shields_fill.png" +dest_files=["res://.godot/imported/shields_fill.png-9eebbd928584a892ac05d44c6835b499.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/gui/hud/images/target_info/target_bg.png b/gui/hud/images/target_info/target_bg.png new file mode 100644 index 00000000..4c72e046 Binary files /dev/null and b/gui/hud/images/target_info/target_bg.png differ diff --git a/gui/hud/images/target_info/target_bg.png.import b/gui/hud/images/target_info/target_bg.png.import new file mode 100644 index 00000000..9a659f7e --- /dev/null +++ b/gui/hud/images/target_info/target_bg.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://s173r8o180gv" +path="res://.godot/imported/target_bg.png-b5cf7ada0150f7b982841beebedcfc7e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://gui/hud/images/target_info/target_bg.png" +dest_files=["res://.godot/imported/target_bg.png-b5cf7ada0150f7b982841beebedcfc7e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=false +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/gui/hud/target_fill_bar.gd b/gui/hud/target_fill_bar.gd new file mode 100644 index 00000000..1af98160 --- /dev/null +++ b/gui/hud/target_fill_bar.gd @@ -0,0 +1,36 @@ +extends Control +class_name TargetFillBar + +@export var max_value: float: + get: + return self._max_value + set(value): + self._max_value = value + self._update() + +@export var value: float: + get: + return self._value + set(value): + self._value = value + self._update() + +@export var fill_rect: NinePatchRect + +@export var max_width: float +@export var min_width: float + +var _max_value: float +var _value: float + +func _ready() -> void: + self._update() + +func _update() -> void: + if self.fill_rect == null: + return + + var percentage := 0.0 if is_zero_approx(self.max_value) else clampf(self.value / self.max_value, 0.0, 1.0) + + self.fill_rect.visible = not is_zero_approx(percentage) + self.fill_rect.size.x = (self.max_width - self.min_width) * percentage + self.min_width diff --git a/gui/hud/target_fill_bar.tscn b/gui/hud/target_fill_bar.tscn new file mode 100644 index 00000000..ff49ea63 --- /dev/null +++ b/gui/hud/target_fill_bar.tscn @@ -0,0 +1,42 @@ +[gd_scene load_steps=4 format=3 uid="uid://bpav2va7o5qt4"] + +[ext_resource type="Script" path="res://gui/hud/target_fill_bar.gd" id="1_q2o4q"] +[ext_resource type="Texture2D" uid="uid://cwdmvrqg25666" path="res://gui/hud/images/target_info/bar_empty.png" id="1_slxrs"] +[ext_resource type="Texture2D" uid="uid://e8r1y25pox5u" path="res://gui/hud/images/target_info/hull_fill.png" id="2_gshbn"] + +[node name="TargetFillBar" type="Control" node_paths=PackedStringArray("fill_rect")] +custom_minimum_size = Vector2(100, 11) +layout_mode = 3 +anchors_preset = 0 +mouse_filter = 1 +script = ExtResource("1_q2o4q") +max_value = 10.0 +value = 7.0 +fill_rect = NodePath("NinePatchRect") +max_width = 184.0 +min_width = 16.0 + +[node name="Background" type="TextureRect" parent="."] +custom_minimum_size = Vector2(100, 11) +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +texture = ExtResource("1_slxrs") +expand_mode = 1 + +[node name="NinePatchRect" type="NinePatchRect" parent="."] +layout_mode = 0 +offset_left = -7.0 +offset_top = -6.0 +offset_right = 107.0 +offset_bottom = 17.0 +texture = ExtResource("2_gshbn") +region_rect = Rect2(2.08165e-12, 2.08165e-12, 278, 23) +patch_margin_left = 8 +patch_margin_top = 8 +patch_margin_right = 8 +patch_margin_bottom = 8 diff --git a/gui/hud/target_view.tscn b/gui/hud/target_view.tscn new file mode 100644 index 00000000..76cd8605 --- /dev/null +++ b/gui/hud/target_view.tscn @@ -0,0 +1,34 @@ +[gd_scene load_steps=5 format=3 uid="uid://boit6owlfi3h"] + +[ext_resource type="ArrayMesh" uid="uid://c2y60nf8m25ka" path="res://ships/frigate03/frigate03_mesh.tres" id="1_a2vil"] +[ext_resource type="Shader" path="res://fx/wireframe.gdshader" id="2_uts7q"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_yvqgq"] +render_priority = 0 +shader = ExtResource("2_uts7q") +shader_parameter/wireframe_color = Color(0.65098, 0.831373, 1, 1) +shader_parameter/wireframe_thickness = 1.0 +shader_parameter/wireframe_smoothness = 1.0 + +[sub_resource type="Environment" id="Environment_n1lj7"] +ambient_light_color = Color(1, 1, 1, 1) +reflected_light_source = 1 + +[node name="TargetView" type="Node3D"] + +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] +transform = Transform3D(-0.866023, -0.433016, 0.250001, 0, 0.499998, 0.866027, -0.500003, 0.749999, -0.43301, 0, 0, 0) +shadow_enabled = true + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +mesh = ExtResource("1_a2vil") +surface_material_override/0 = SubResource("ShaderMaterial_yvqgq") + +[node name="Camera3D" type="Camera3D" parent="."] +transform = Transform3D(0.707107, 0.5, -0.5, 2.4663e-16, 0.707107, 0.707107, 0.707107, -0.5, 0.5, -2, 2, 2) +current = true +near = 1.0 +far = 10.0 + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_n1lj7") diff --git a/main/game.tscn b/main/game.tscn index c0d756fd..7465e3cd 100644 --- a/main/game.tscn +++ b/main/game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=44 format=3 uid="uid://sunhu71swcs2"] +[gd_scene load_steps=50 format=3 uid="uid://sunhu71swcs2"] [ext_resource type="Script" path="res://utils/shader_precompiler.gd" id="1_kgmvv"] [ext_resource type="Script" path="res://main/hyperspace_controller.gd" id="2_5gj7y"] @@ -33,6 +33,11 @@ [ext_resource type="Texture2D" uid="uid://dif27wf74itjw" path="res://gui/hud/images/IconEnergy.png" id="24_iwm5p"] [ext_resource type="PackedScene" uid="uid://dl3xau7i06twf" path="res://gui/hud/vitals_fill_bar.tscn" id="25_qonn8"] [ext_resource type="PackedScene" uid="uid://kqong7nrl4p2" path="res://galaxy/map/galaxy_map.tscn" id="28_oyaod"] +[ext_resource type="Texture2D" uid="uid://s173r8o180gv" path="res://gui/hud/images/target_info/target_bg.png" id="31_s52vq"] +[ext_resource type="Texture2D" uid="uid://dcg5m8doqdfc" path="res://gui/hud/images/target_info/heading_border.png" id="32_h7f2h"] +[ext_resource type="PackedScene" uid="uid://bpav2va7o5qt4" path="res://gui/hud/target_fill_bar.tscn" id="33_oq34c"] +[ext_resource type="PackedScene" uid="uid://boit6owlfi3h" path="res://gui/hud/target_view.tscn" id="33_v8kjk"] +[ext_resource type="Texture2D" uid="uid://bsf3tqgocto7h" path="res://gui/hud/images/target_info/shields_fill.png" id="34_ajn47"] [sub_resource type="World3D" id="World3D_pvg5q"] environment = ExtResource("6_srnxb") @@ -83,6 +88,13 @@ content_margin_bottom = 12.0 texture = ExtResource("21_jwbi2") region_rect = Rect2(0, 0, 157, 161) +[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_lc8il"] +texture = ExtResource("31_s52vq") +texture_margin_left = 14.0 +texture_margin_top = 10.0 +texture_margin_right = 15.0 +texture_margin_bottom = 10.0 + [node name="Game" type="Node3D"] [node name="ShaderPrecompiler" type="SubViewport" parent="."] @@ -224,9 +236,9 @@ layout_mode = 2 tooltip_text = "Control scheme" item_count = 2 selected = 0 -popup/item_0/text = "Relative" +popup/item_0/text = "Relative controls" popup/item_0/id = 0 -popup/item_1/text = "Absolute" +popup/item_1/text = "Absolute controls" popup/item_1/id = 1 script = ExtResource("12_ti545") @@ -361,7 +373,6 @@ text_overrun_behavior = 3 uppercase = true [node name="TargetVitals" type="GridContainer" parent="HUD/Sidebar/TargetInfo"] -visible = false layout_mode = 2 columns = 2 @@ -405,6 +416,66 @@ size_flags_horizontal = 3 mouse_filter = 2 step = 2.08165e-12 +[node name="TargetInfoContainer" type="PanelContainer" parent="HUD/Sidebar"] +custom_minimum_size = Vector2(200, 194) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxTexture_lc8il") + +[node name="VBoxContainer" type="VBoxContainer" parent="HUD/Sidebar/TargetInfoContainer"] +layout_mode = 2 +theme_override_constants/separation = 0 + +[node name="HBoxContainer" type="HBoxContainer" parent="HUD/Sidebar/TargetInfoContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 0 + +[node name="Label" type="Label" parent="HUD/Sidebar/TargetInfoContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +theme_type_variation = &"HUDLabel" +theme_override_colors/font_color = Color(0.454902, 0.729412, 0.984314, 1) +text = "Target:" +uppercase = true + +[node name="TargetedShipLabel" type="Label" parent="HUD/Sidebar/TargetInfoContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_type_variation = &"HUDLabel" +text = "none" +text_overrun_behavior = 3 +uppercase = true + +[node name="TextureRect" type="TextureRect" parent="HUD/Sidebar/TargetInfoContainer/VBoxContainer"] +layout_mode = 2 +texture = ExtResource("32_h7f2h") +expand_mode = 5 + +[node name="SubViewportContainer" type="SubViewportContainer" parent="HUD/Sidebar/TargetInfoContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +stretch = true + +[node name="SubViewport" type="SubViewport" parent="HUD/Sidebar/TargetInfoContainer/VBoxContainer/SubViewportContainer"] +own_world_3d = true +transparent_bg = true +handle_input_locally = false +msaa_3d = 2 +gui_disable_input = true +size = Vector2i(171, 118) +render_target_update_mode = 4 + +[node name="TargetView" parent="HUD/Sidebar/TargetInfoContainer/VBoxContainer/SubViewportContainer/SubViewport" instance=ExtResource("33_v8kjk")] + +[node name="ShieldBar" parent="HUD/Sidebar/TargetInfoContainer/VBoxContainer" instance=ExtResource("33_oq34c")] +layout_mode = 2 +size_flags_vertical = 8 + +[node name="NinePatchRect" parent="HUD/Sidebar/TargetInfoContainer/VBoxContainer/ShieldBar" index="1"] +offset_right = 89.0 +texture = ExtResource("34_ajn47") + +[node name="HullBar" parent="HUD/Sidebar/TargetInfoContainer/VBoxContainer" instance=ExtResource("33_oq34c")] +layout_mode = 2 + [node name="GameOverDialog" type="AcceptDialog" parent="HUD"] scaling_3d_scale = 2.0 title = "Game Over" @@ -472,3 +543,4 @@ galaxy = ExtResource("3_j76v0") [connection signal="close_requested" from="HUD/GalaxyMapWindow" to="HUD/GalaxyMapWindow/SubViewportContainer/SubViewport/GalaxyMap" method="_on_window_close_requested"] [editable path="Player"] +[editable path="HUD/Sidebar/TargetInfoContainer/VBoxContainer/ShieldBar"] diff --git a/project.godot b/project.godot index e7c061ef..c26c9962 100644 --- a/project.godot +++ b/project.godot @@ -25,10 +25,12 @@ MathUtils="*res://utils/math_utils.gd" [display] -window/size/viewport_width=3072 -window/size/viewport_height=1728 +window/size/viewport_width=3840 +window/size/viewport_height=2160 +window/size/mode=3 window/stretch/mode="canvas_items" window/stretch/aspect="expand" +window/stretch/scale=2.0 [filesystem]