updating ignore

This commit is contained in:
hz
2026-05-18 14:54:37 -05:00
parent afeb9cf625
commit 32b953aa61
62 changed files with 295 additions and 2313 deletions
+2
View File
@@ -1,3 +1,5 @@
# Godot 4+ specific ignores
.godot/
/android/
export_presets.cfg
export_credentials.cfg
@@ -65,6 +65,16 @@ func _build_ui() -> void:
title.add_theme_font_override("font", title_font)
top_content.add_child(title)
var legend := HBoxContainer.new()
legend.add_theme_constant_override("separation", 12)
top_content.add_child(legend)
legend.add_child(_legend_item(Color(0.78, 0.62, 0.19), "Home"))
legend.add_child(_legend_item(Color(0.26, 0.62, 0.32), "Yours"))
legend.add_child(_legend_item(Color(0.58, 0.28, 0.24), "Rival"))
legend.add_child(_legend_item(Color(0.38, 0.56, 0.36), "Open"))
legend.add_child(_legend_item(Color(0.045, 0.065, 0.065), "Unknown"))
var user_label := Label.new()
user_label.text = _session_name()
user_label.add_theme_font_size_override("font_size", 15)
@@ -236,3 +246,21 @@ func _panel_style(color: Color, border_color: Color, border_width: int, radius:
style.set_border_width_all(border_width)
style.set_corner_radius_all(radius)
return style
func _legend_item(color: Color, label_text: String) -> HBoxContainer:
var item := HBoxContainer.new()
item.add_theme_constant_override("separation", 5)
var swatch := ColorRect.new()
swatch.color = color
swatch.custom_minimum_size = Vector2(18, 18)
item.add_child(swatch)
var label := Label.new()
label.text = label_text
label.add_theme_font_size_override("font_size", 12)
label.add_theme_color_override("font_color", Color(0.72, 0.82, 0.78))
item.add_child(label)
return item
@@ -18,6 +18,7 @@ var home_tile: Vector2i = Vector2i(9999, 9999)
var tiles: Array[Dictionary] = []
var visible_tiles: Dictionary = {}
var owned_tiles: Dictionary = {}
var rival_tiles: Dictionary = {}
func _ready() -> void:
@@ -127,23 +128,22 @@ func _draw_tile(tile: Dictionary) -> void:
var key: String = _tile_key(q, r)
var is_visible: bool = visible_tiles.has(key)
var is_owned: bool = owned_tiles.has(key)
var is_rival: bool = rival_tiles.has(key)
var side_points: PackedVector2Array = PackedVector2Array([points[2], points[3], points[4], points[4] + Vector2(0, 14), points[3] + Vector2(0, 14), points[2] + Vector2(0, 14)])
var draw_color: Color = color if is_visible else Color(0.045, 0.065, 0.065)
var draw_color: Color = _ownership_fill_color(color, coord, is_visible, is_owned, is_rival)
draw_colored_polygon(side_points, draw_color.darkened(0.28))
if not is_visible:
draw_colored_polygon(points, Color(0.055, 0.075, 0.075))
draw_colored_polygon(points, draw_color)
elif is_selected:
draw_colored_polygon(points, color.lightened(0.22))
draw_colored_polygon(points, draw_color.lightened(0.2))
elif coord == home_tile:
draw_colored_polygon(points, Color(0.72, 0.58, 0.2))
elif is_owned:
draw_colored_polygon(points, Color(0.34, 0.52, 0.36))
draw_colored_polygon(points, draw_color)
elif is_hovered:
draw_colored_polygon(points, color.lightened(0.13))
draw_colored_polygon(points, draw_color.lightened(0.13))
else:
draw_colored_polygon(points, color)
draw_colored_polygon(points, draw_color)
draw_polyline(_closed_points(points), Color(0.04, 0.065, 0.06, 0.72), 2.0)
@@ -154,7 +154,9 @@ func _draw_tile(tile: Dictionary) -> void:
elif coord == home_tile:
draw_polyline(_closed_points(points), Color(1.0, 0.88, 0.38), 3.0)
elif is_owned:
draw_polyline(_closed_points(points), Color(0.66, 0.9, 0.56), 2.5)
draw_polyline(_closed_points(points), Color(0.48, 0.95, 0.55), 3.0)
elif is_rival:
draw_polyline(_closed_points(points), Color(0.94, 0.36, 0.29), 3.0)
func _update_hover(mouse_position: Vector2) -> void:
@@ -178,7 +180,7 @@ func _update_hover(mouse_position: Vector2) -> void:
if hovered_tile.x != 9999:
var data: Dictionary = _tile_data(hovered_tile.x, hovered_tile.y)
var key: String = _tile_key(hovered_tile.x, hovered_tile.y)
var terrain: String = str(data.get("terrain", "Open")) if visible_tiles.has(key) else "Unexplored"
var terrain: String = _tile_display_label(key, data) if visible_tiles.has(key) else "Unexplored"
tile_hovered.emit(hovered_tile.x, hovered_tile.y, terrain)
queue_redraw()
@@ -232,6 +234,7 @@ func set_home_location(q: int, r: int) -> void:
func set_visible_locations(locations: Array, username: String) -> void:
visible_tiles.clear()
owned_tiles.clear()
rival_tiles.clear()
for item in locations:
if typeof(item) != TYPE_DICTIONARY:
@@ -241,14 +244,17 @@ func set_visible_locations(locations: Array, username: String) -> void:
var q: int = int(location.get("q", 0))
var r: int = int(location.get("r", 0))
var terrain: String = str(location.get("terrain", "Field"))
var owner: String = str(location.get("ownerUsername", ""))
var owner: String = _owner_username(location)
var key: String = _tile_key(q, r)
visible_tiles[key] = location
_add_or_update_tile(q, r, terrain)
if not owner.is_empty() and owner == username:
owned_tiles[key] = location
if not owner.is_empty():
if owner == username:
owned_tiles[key] = location
else:
rival_tiles[key] = location
queue_redraw()
@@ -257,6 +263,40 @@ func _tile_key(q: int, r: int) -> String:
return "%d,%d" % [q, r]
func _ownership_fill_color(base_color: Color, coord: Vector2i, is_visible: bool, is_owned: bool, is_rival: bool) -> Color:
if not is_visible:
return Color(0.045, 0.065, 0.065)
if coord == home_tile:
return Color(0.78, 0.62, 0.19)
if is_owned:
return Color(0.26, 0.62, 0.32)
if is_rival:
return Color(0.58, 0.28, 0.24)
return base_color
func _tile_display_label(key: String, data: Dictionary) -> String:
var terrain: String = str(data.get("terrain", "Open"))
if home_tile == Vector2i(int(data.get("q", 0)), int(data.get("r", 0))):
return "%s | Your home" % terrain
if owned_tiles.has(key):
return "%s | Your territory" % terrain
if rival_tiles.has(key):
var rival_data: Dictionary = rival_tiles[key]
var owner: String = _owner_username(rival_data)
if owner.is_empty():
return "%s | Unclaimed" % terrain
return "%s | Controlled by %s" % [terrain, owner]
return "%s | Unclaimed" % terrain
func _owner_username(location: Dictionary) -> String:
var owner_value: Variant = location.get("ownerUsername", "")
if owner_value == null:
return ""
return str(owner_value)
func _tile_height(q: int, r: int) -> float:
var distance: int = max(max(abs(q), abs(r)), abs(-q - r))
if distance <= 1:
@@ -271,8 +311,6 @@ func _tile_height(q: int, r: int) -> float:
func _terrain_name(q: int, r: int, height: float) -> String:
if height >= 19.0:
return "Highland"
if abs(q) <= 1 and abs(r) <= 1:
return "Command"
if (q + r) % 4 == 0:
return "Forest"
if (q * 3 - r) % 6 == 0: