From 6e350a3dc0b596b1f76fab3b943b67b7713ea4fa Mon Sep 17 00:00:00 2001 From: hop311 Date: Mon, 4 Dec 2023 00:12:16 +0000 Subject: Sim submodule update + extension compatibility --- game/src/Game/Autoload/Argument/ArgumentOption.gd | 2 +- game/src/Game/GameSession/MapView.gd | 2 +- game/src/Game/GameSession/TerrainMap.gdshader | 2 +- game/src/Game/GlobalClass/ShaderManager.gd | 14 +- game/src/Game/LoadingScreen.gd | 2 +- game/src/Game/Theme/PieChart/PieChart.gd | 216 ---------------------- game/src/Game/Theme/PieChart/PieChart.tscn | 38 ---- 7 files changed, 13 insertions(+), 263 deletions(-) delete mode 100644 game/src/Game/Theme/PieChart/PieChart.gd delete mode 100644 game/src/Game/Theme/PieChart/PieChart.tscn (limited to 'game/src/Game') diff --git a/game/src/Game/Autoload/Argument/ArgumentOption.gd b/game/src/Game/Autoload/Argument/ArgumentOption.gd index f14cef0..f98b19c 100644 --- a/game/src/Game/Autoload/Argument/ArgumentOption.gd +++ b/game/src/Game/Autoload/Argument/ArgumentOption.gd @@ -20,7 +20,7 @@ extends Resource var default_value @export var description : String -func _init(_name = "", _type = TYPE_NIL, _description = "", default = null): +func _init(_name = "", _type = TYPE_NIL, _description = "", default = null): name = _name type = _type if default != null and typeof(default) == type: diff --git a/game/src/Game/GameSession/MapView.gd b/game/src/Game/GameSession/MapView.gd index 7093c69..62bdd20 100644 --- a/game/src/Game/GameSession/MapView.gd +++ b/game/src/Game/GameSession/MapView.gd @@ -30,7 +30,7 @@ var _window_in_focus : bool = true @export var _zoom_target : float = 1.0: get: return _zoom_target set(v): _zoom_target = clamp(v, _zoom_target_min, _zoom_target_max) -const _zoom_position_multiplier = 3.14159 # Horizontal movement coefficient during zoom +const _zoom_position_multiplier = 3.14159 # Horizontal movement coefficient during zoom var _zoom_position : Vector2 @export var _map_mesh_instance : MeshInstance3D diff --git a/game/src/Game/GameSession/TerrainMap.gdshader b/game/src/Game/GameSession/TerrainMap.gdshader index 35a108b..97b20e4 100644 --- a/game/src/Game/GameSession/TerrainMap.gdshader +++ b/game/src/Game/GameSession/TerrainMap.gdshader @@ -47,7 +47,7 @@ vec3 get_terrain_colour( vec3 tinted_terrain_colour = mix(terrain_colour, tint_colour, 0.3); vec3 mixed_colour = mix(tinted_terrain_colour, province_colour.rgb, province_colour.a); - float highlight_mix_val = 0.1 * (float(province_index == hover_index) + float(province_index == selected_index)); + float highlight_mix_val = 0.4 * (float(province_index == hover_index) + float(province_index == selected_index)); return mix(mixed_colour, highlight_colour, highlight_mix_val); } diff --git a/game/src/Game/GlobalClass/ShaderManager.gd b/game/src/Game/GlobalClass/ShaderManager.gd index ace3c3a..a6d555f 100644 --- a/game/src/Game/GlobalClass/ShaderManager.gd +++ b/game/src/Game/GlobalClass/ShaderManager.gd @@ -38,28 +38,32 @@ func set_up_shader(material : Material, add_cosmetic_textures : bool) -> Error: if province_shape_texture == null: push_error("Failed to get province shape texture!") ret = FAILED - shader_material.set_shader_parameter(param_province_shape_tex, province_shape_texture) + else: + shader_material.set_shader_parameter(param_province_shape_tex, province_shape_texture) var subdivisions := GameSingleton.get_province_shape_image_subdivisions() if subdivisions.x < 1 or subdivisions.y < 1: push_error("Invalid province shape image subdivision: ", subdivisions.x, "x", subdivisions.y) ret = FAILED - shader_material.set_shader_parameter(param_province_shape_subdivisions, Vector2(subdivisions)) + else: + shader_material.set_shader_parameter(param_province_shape_subdivisions, Vector2(subdivisions)) if add_cosmetic_textures: # Province colour texture var map_province_colour_texture := GameSingleton.get_province_colour_texture() if map_province_colour_texture == null: - push_error("Failed to get province colour image!") + push_error("Failed to get province colour texture!") ret = FAILED - shader_material.set_shader_parameter(param_province_colour_tex, map_province_colour_texture) + else: + shader_material.set_shader_parameter(param_province_colour_tex, map_province_colour_texture) # Terrain texture var terrain_texture := GameSingleton.get_terrain_texture() if terrain_texture == null: push_error("Failed to get terrain texture!") ret = FAILED - shader_material.set_shader_parameter(param_terrain_tex, terrain_texture) + else: + shader_material.set_shader_parameter(param_terrain_tex, terrain_texture) # Stripe texture if _set_shader_texture(shader_material, &"map/terrain/stripes.dds", param_stripe_tex) != OK: diff --git a/game/src/Game/LoadingScreen.gd b/game/src/Game/LoadingScreen.gd index ae04c85..c7dad9c 100644 --- a/game/src/Game/LoadingScreen.gd +++ b/game/src/Game/LoadingScreen.gd @@ -40,7 +40,7 @@ func _ready(): thread = Thread.new() # FS-3, UI-30, UIFUN-35 var quotes_file := FileAccess.open(quote_file_path, FileAccess.READ).get_as_text() - quotes = quotes_file.split("\n",false) + quotes = quotes_file.split("\n", false) if quotes.is_empty(): quotes = [""] animation_player.play("loadingscreen_gear") diff --git a/game/src/Game/Theme/PieChart/PieChart.gd b/game/src/Game/Theme/PieChart/PieChart.gd deleted file mode 100644 index 4b81b28..0000000 --- a/game/src/Game/Theme/PieChart/PieChart.gd +++ /dev/null @@ -1,216 +0,0 @@ -@tool -extends TextureRect - -class_name PieChart - - -@export var donut : bool = false -@export_range(0.0, 1.0) var donut_inner_radius : float = 0.5 -@export_range(0.0, 0.5) var radius : float = 0.4 -@export var shadow_displacement : Vector2 = Vector2(0.55, 0.6) -@export var shadow_tightness : float = 1.0 -@export var shadow_radius : float = 0.6 -@export var shadow_thickness : float = 1.0 - -@export var trim_colour : Color = Color(0.0, 0.0, 0.0) -@export_range(0.0, 1.0) var trim_size : float = 0.02 -@export var donut_inner_trim : bool = true -@export var slice_gradient_falloff : float = 3.6 -@export var slice_gradient_base : float = 3.1 - -@export var _rich_tooltip : RichTextLabel -var _pie_chart_image : Image - -# A data class for the pie chart -class SliceData: - extends RefCounted - # Primary properties, change these to change - # the displayed piechart - var colour : Color = Color(1.0, 0.0, 0.0) - var tooltip : String = "" - var quantity : float = -1 - # Derived properties, don't set from an external script - var final_angle : float = -1 - var percentage : float = 0: - get: - return percentage - set(value): - percentage = clampf(value, 0, 1) - - func _init(quantityIn : float, tooltipIn : String, colourIn : Color): - colour = colourIn - tooltip = tooltipIn - quantity = quantityIn - -# The key of an entry of this dictionary should be an easy to reference constant -# The tooltip label is what the user will actually read -var _slices : Dictionary = {} - -# Slice keys/labels in the order they should be displayed -var _slice_order : Array = [] - -# Example slices: -""" - "label1": SliceData.new(5, "Conservative", Color(0.0, 0.0, 1.0)), - "label2": SliceData.new(3, "Liberal", Color(1.0, 1.0, 0.0)), - "label3": SliceData.new(2, "Reactionary", Color(0.4, 0.0, 0.6)) -""" - -# These functions are the interface a developer will use to update the piechart -# The piechart will only redraw once one of these has been triggered -func add_or_replace_label(labelName : String, quantity : float, tooltip : String, colour : Color = Color(0.0, 0.0, 0.0)) -> void: - _slices[labelName] = SliceData.new(quantity, tooltip, colour) - if _slice_order.find(labelName) == -1: - _slice_order.push_back(labelName) - _recalculate() - -func update_label_quantity(labelName : String, quantity : float) -> void: - if _slices.has(labelName): - _slices[labelName].quantity = quantity - _recalculate() - -func update_label_colour(labelName : String, colour : Color) -> void: - if _slices.has(labelName): - _slices[labelName].colour = colour - _recalculate() - -func update_label_tooltip(labelName : String, tooltip : String) -> void: - if _slices.has(labelName): - _slices[labelName].tooltip = tooltip - -func remove_label(labelName : String) -> bool: - if _slices.erase(labelName): - var index := _slice_order.find(labelName) - if index == -1: - push_error("Slice in dictionary but not order list: ", labelName) - else: - _slice_order.remove_at(index) - _recalculate() - return true - return false - -func clear_slices() -> void: - _slices.clear() - _slice_order.clear() - -# Distribution dictionary of the form: -# { "