Tile highlight texture system with cursor + hover glow
Server / DB:
- New HighlightConfig entity (catalog.highlight_configs): one row per
highlight type (Movement/Attack/Ability/Terramorpha/Selector). Supports
static texture URL or animated (base folder + frame count + FPS) with a
FallbackHex RGBA colour for when no texture is configured.
- EF migration AddHighlightConfig.
- CosmeticType.HighlightPack added; AssetCdnUrl stores serialised JSON with
per-type texture config so players can buy full highlight packs in the Bazaar.
- content.get_highlight_config handler in SOR.Content; response DTOs added to
ContentMessages.cs; handler registered in ServiceRegistration.
Admin:
- /content/highlights page: inline editor for all five highlight types
(CDN path, animated toggle, frame count, FPS, fallback hex with swatch).
Upserts rows — no delete needed since there is always exactly one row per type.
- Highlights nav link added to Content section in NavMenu.
- CosmeticEditor: HighlightPack type renders a per-type table (Movement/
Attack/Ability/Terramorpha/Selector), serialising to JSON in AssetCdnUrl.
Client (Godot):
- HighlightConfig autoload: fetches content.get_highlight_config on startup,
caches to user://highlight_config.json. Provides get_texture(type) and
get_color(type). Supports set_override/clear_override/apply_cosmetic_pack
for cosmetic and settings overrides.
- Settings autoload: highlight_overrides Dictionary persisted in settings.cfg.
set_highlight_override/clear_highlight_override push into HighlightConfig.
- settings_screen.gd: programmatic "Highlight Texture Overrides" section added
with a LineEdit + Reset button per type; appended to Sections VBoxContainer.
- game_screen.gd:
• _add_highlight() rewritten to use flat PlaneMesh quads with textured
StandardMaterial3D. Accepts a string type key ("movement", "attack",
"ability", "terramorpha", "selector") instead of a Color constant.
• _cursor_highlight + _hover_team_overlay: two permanently-allocated quads
that are never freed. The selector highlights the tile under the mouse at
all times; the team overlay shows a coloured tint when hovering an occupied
tile. Both are preserved across _clear_highlights() and _build_board().
• _update_hover(): called on every InputEventMouseMotion event. Moves the
selector quad, shows the team-colour overlay when hovering an occupied tile,
and boosts MeshInstance3D emission on the hovered unit via
set_surface_override_material (reset when hover leaves).
• All existing _highlight_tiles() / _add_highlight() callers updated from
HI_* Color constants to type key strings.
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -0,0 +1,209 @@
|
||||
extends Node
|
||||
## HighlightConfig autoload — fetches and caches tile highlight texture configuration.
|
||||
##
|
||||
## Usage:
|
||||
## HighlightConfig.get_texture("movement") → Texture2D or null
|
||||
## HighlightConfig.get_color("movement") → Color (parsed from fallbackHex)
|
||||
## HighlightConfig.is_ready → bool
|
||||
##
|
||||
## Cosmetic overrides (via Settings.highlight_overrides or equipped HighlightPack):
|
||||
## HighlightConfig.set_override("movement", { cdnPath=…, isAnimated=false, … })
|
||||
## HighlightConfig.clear_override("movement")
|
||||
## HighlightConfig.clear_all_overrides()
|
||||
##
|
||||
## Texture loading is async. Callers should handle null gracefully and fall back to
|
||||
## get_color() when get_texture() returns null.
|
||||
|
||||
signal loaded
|
||||
|
||||
const CACHE_PATH := "user://highlight_config.json"
|
||||
const REQUEST_TYPE := "content.get_highlight_config"
|
||||
|
||||
## Default fallback colours used when no server config exists.
|
||||
const DEFAULT_HEX : Dictionary = {
|
||||
"movement": "#33FF3366",
|
||||
"attack": "#FF404080",
|
||||
"ability": "#3380FF66",
|
||||
"terramorpha": "#FF990073",
|
||||
"selector": "#FFFFFF40",
|
||||
}
|
||||
|
||||
## Whether the server config has been loaded (or the cache has been used).
|
||||
var is_ready : bool = false
|
||||
|
||||
# ── Internal state ─────────────────────────────────────────────────────────────
|
||||
|
||||
# Server-provided configs keyed by lowercase type name.
|
||||
# Each entry: { cdnPath, isAnimated, frameCount, fps, fallbackHex }
|
||||
var _server_configs : Dictionary = {}
|
||||
|
||||
# Admin/cosmetic overrides — same structure, keyed by lowercase type name.
|
||||
var _overrides : Dictionary = {}
|
||||
|
||||
# Loaded textures: type → Texture2D (null while loading or if failed).
|
||||
var _textures : Dictionary = {}
|
||||
|
||||
# HTTP fetch nodes keyed by type (to avoid duplicate requests).
|
||||
var _pending_fetches : Dictionary = {}
|
||||
|
||||
# ── Lifecycle ──────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
_load_cache()
|
||||
_fetch_from_server()
|
||||
|
||||
|
||||
# ── Public API ─────────────────────────────────────────────────────────────────
|
||||
|
||||
## Returns the loaded Texture2D for this highlight type, or null if not yet loaded.
|
||||
## Starts loading the texture on first call if not already in progress.
|
||||
func get_texture(type: String) -> Texture2D:
|
||||
var key := type.to_lower()
|
||||
if _textures.has(key):
|
||||
return _textures[key]
|
||||
# Start loading if we have a config for this type.
|
||||
var cfg := _effective_config(key)
|
||||
if not cfg.is_empty() and not cfg.get("cdnPath", "").is_empty():
|
||||
_start_texture_load(key, cfg)
|
||||
return null
|
||||
|
||||
|
||||
## Returns the fallback Color for this highlight type.
|
||||
func get_color(type: String) -> Color:
|
||||
var key := type.to_lower()
|
||||
var cfg := _effective_config(key)
|
||||
var hex : String = cfg.get("fallbackHex", DEFAULT_HEX.get(key, "#FFFFFF66"))
|
||||
return _parse_hex(hex)
|
||||
|
||||
|
||||
## Override a highlight type with a custom config dict.
|
||||
## Config keys: cdnPath (String), isAnimated (bool), frameCount (int), fps (float), fallbackHex (String).
|
||||
func set_override(type: String, config: Dictionary) -> void:
|
||||
var key := type.to_lower()
|
||||
_overrides[key] = config
|
||||
_textures.erase(key) # Invalidate cached texture so next get_texture() reloads.
|
||||
_pending_fetches.erase(key)
|
||||
|
||||
|
||||
## Remove override for one type.
|
||||
func clear_override(type: String) -> void:
|
||||
var key := type.to_lower()
|
||||
_overrides.erase(key)
|
||||
_textures.erase(key)
|
||||
_pending_fetches.erase(key)
|
||||
|
||||
|
||||
## Remove all cosmetic/settings overrides.
|
||||
func clear_all_overrides() -> void:
|
||||
_overrides.clear()
|
||||
_textures.clear()
|
||||
_pending_fetches.clear()
|
||||
|
||||
|
||||
## Apply an equipped HighlightPack cosmetic (parsed from AssetCdnUrl JSON).
|
||||
## pack_data: Dictionary keyed by lowercase type name, each value is a config dict.
|
||||
func apply_cosmetic_pack(pack_data: Dictionary) -> void:
|
||||
for key in pack_data:
|
||||
set_override(str(key).to_lower(), pack_data[key] as Dictionary)
|
||||
|
||||
|
||||
# ── Internal ───────────────────────────────────────────────────────────────────
|
||||
|
||||
func _effective_config(key: String) -> Dictionary:
|
||||
if _overrides.has(key):
|
||||
return _overrides[key] as Dictionary
|
||||
if _server_configs.has(key):
|
||||
return _server_configs[key] as Dictionary
|
||||
return {}
|
||||
|
||||
|
||||
func _fetch_from_server() -> void:
|
||||
Network.request(
|
||||
REQUEST_TYPE,
|
||||
{},
|
||||
func(_type: String, resp: Variant) -> void:
|
||||
_on_server_response(resp),
|
||||
func(_code: String, _msg: String) -> void:
|
||||
# Use cached config if available; set is_ready anyway.
|
||||
is_ready = true
|
||||
loaded.emit()
|
||||
)
|
||||
|
||||
|
||||
func _on_server_response(resp: Variant) -> void:
|
||||
var configs : Array = (resp as Dictionary).get("configs", [])
|
||||
for entry : Dictionary in configs:
|
||||
var key : String = str(entry.get("highlightType", "")).to_lower()
|
||||
if key.is_empty():
|
||||
continue
|
||||
_server_configs[key] = {
|
||||
"cdnPath": str(entry.get("cdnPath", "")),
|
||||
"isAnimated": bool(entry.get("isAnimated", false)),
|
||||
"frameCount": int(entry.get("frameCount", 1)),
|
||||
"fps": float(entry.get("fps", 12.0)),
|
||||
"fallbackHex": str(entry.get("fallbackHex", DEFAULT_HEX.get(key, "#FFFFFF66"))),
|
||||
}
|
||||
_save_cache()
|
||||
is_ready = true
|
||||
loaded.emit()
|
||||
|
||||
|
||||
func _start_texture_load(key: String, cfg: Dictionary) -> void:
|
||||
if _pending_fetches.has(key):
|
||||
return
|
||||
_pending_fetches[key] = true
|
||||
var url : String = cfg.get("cdnPath", "")
|
||||
if url.is_empty():
|
||||
return
|
||||
|
||||
var http := HTTPRequest.new()
|
||||
add_child(http)
|
||||
http.request_completed.connect(
|
||||
func(result: int, _code: int, _headers: PackedStringArray, body: PackedByteArray) -> void:
|
||||
http.queue_free()
|
||||
_pending_fetches.erase(key)
|
||||
if result != HTTPRequest.RESULT_SUCCESS or body.is_empty():
|
||||
return
|
||||
var img := Image.new()
|
||||
if img.load_png_from_buffer(body) != OK:
|
||||
if img.load_webp_from_buffer(body) != OK:
|
||||
return
|
||||
var tex := ImageTexture.create_from_image(img)
|
||||
_textures[key] = tex
|
||||
)
|
||||
http.request(url)
|
||||
|
||||
|
||||
func _parse_hex(hex: String) -> Color:
|
||||
var s := hex.strip_edges()
|
||||
if s.begins_with("#"):
|
||||
s = s.substr(1)
|
||||
match s.length():
|
||||
6: return Color(s.hex_to_int() << 8 | 0xFF) / float(0xFFFFFFFF)
|
||||
8:
|
||||
var v := s.hex_to_int()
|
||||
var r := ((v >> 24) & 0xFF) / 255.0
|
||||
var g := ((v >> 16) & 0xFF) / 255.0
|
||||
var b := ((v >> 8) & 0xFF) / 255.0
|
||||
var a := ( v & 0xFF) / 255.0
|
||||
return Color(r, g, b, a)
|
||||
return Color.WHITE
|
||||
|
||||
|
||||
func _load_cache() -> void:
|
||||
var f := FileAccess.open(CACHE_PATH, FileAccess.READ)
|
||||
if f == null:
|
||||
return
|
||||
var text := f.get_as_text()
|
||||
f.close()
|
||||
var parsed := JSON.parse_string(text)
|
||||
if parsed is Dictionary:
|
||||
_server_configs = parsed as Dictionary
|
||||
|
||||
|
||||
func _save_cache() -> void:
|
||||
var f := FileAccess.open(CACHE_PATH, FileAccess.WRITE)
|
||||
if f == null:
|
||||
return
|
||||
f.store_string(JSON.stringify(_server_configs))
|
||||
f.close()
|
||||
@@ -9,10 +9,11 @@ extends Node
|
||||
##
|
||||
## Changing any property automatically applies it to the AudioServer and saves.
|
||||
|
||||
const SAVE_PATH := "user://settings.cfg"
|
||||
const SECTION := "audio"
|
||||
const SECTION_GAMEPLAY := "gameplay"
|
||||
const SECTION_VISUAL := "visual"
|
||||
const SAVE_PATH := "user://settings.cfg"
|
||||
const SECTION := "audio"
|
||||
const SECTION_GAMEPLAY := "gameplay"
|
||||
const SECTION_VISUAL := "visual"
|
||||
const SECTION_HIGHLIGHTS := "highlights"
|
||||
|
||||
## Audio bus names as configured in the Godot project.
|
||||
const BUS_MUSIC := "Music"
|
||||
@@ -65,6 +66,31 @@ var skybox_mode : String = "live" :
|
||||
_save()
|
||||
settings_changed.emit()
|
||||
|
||||
## Per-type highlight texture URL overrides entered by the player.
|
||||
## Keys: "movement", "attack", "ability", "terramorpha", "selector"
|
||||
## Value: URL string, or "" to use the server default.
|
||||
var highlight_overrides : Dictionary = {} :
|
||||
set(v):
|
||||
highlight_overrides = v
|
||||
_apply_highlight_overrides()
|
||||
_save()
|
||||
settings_changed.emit()
|
||||
|
||||
|
||||
func set_highlight_override(type: String, url: String) -> void:
|
||||
var key := type.to_lower()
|
||||
if url.is_empty():
|
||||
highlight_overrides.erase(key)
|
||||
else:
|
||||
highlight_overrides[key] = url
|
||||
_apply_highlight_overrides()
|
||||
_save()
|
||||
settings_changed.emit()
|
||||
|
||||
|
||||
func clear_highlight_override(type: String) -> void:
|
||||
set_highlight_override(type.to_lower(), "")
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -82,6 +108,20 @@ func _apply_music() -> void:
|
||||
AudioServer.set_bus_mute(idx, music_muted)
|
||||
|
||||
|
||||
func _apply_highlight_overrides() -> void:
|
||||
if not is_node_ready():
|
||||
return
|
||||
# Wait until HighlightConfig has initialised (it's an autoload, loaded after Settings).
|
||||
if not Engine.has_singleton("HighlightConfig"):
|
||||
return
|
||||
HighlightConfig.clear_all_overrides()
|
||||
for key in highlight_overrides:
|
||||
var url : String = str(highlight_overrides[key])
|
||||
if not url.is_empty():
|
||||
HighlightConfig.set_override(key, { "cdnPath": url, "isAnimated": false,
|
||||
"frameCount": 1, "fps": 12.0, "fallbackHex": "" })
|
||||
|
||||
|
||||
func _apply_sfx() -> void:
|
||||
var idx := AudioServer.get_bus_index(BUS_SFX)
|
||||
if idx < 0:
|
||||
@@ -98,8 +138,11 @@ func _load() -> void:
|
||||
music_muted = bool(cfg.get_value(SECTION, "music_muted", false))
|
||||
sfx_volume = float(cfg.get_value(SECTION, "sfx_volume", 1.0))
|
||||
sfx_muted = bool(cfg.get_value(SECTION, "sfx_muted", false))
|
||||
camera_follow_unit = bool(cfg.get_value(SECTION_GAMEPLAY, "camera_follow_unit", true))
|
||||
skybox_mode = str(cfg.get_value(SECTION_VISUAL, "skybox_mode", "live"))
|
||||
camera_follow_unit = bool(cfg.get_value(SECTION_GAMEPLAY, "camera_follow_unit", true))
|
||||
skybox_mode = str(cfg.get_value(SECTION_VISUAL, "skybox_mode", "live"))
|
||||
var raw_overrides = cfg.get_value(SECTION_HIGHLIGHTS, "highlight_overrides", {})
|
||||
if raw_overrides is Dictionary:
|
||||
highlight_overrides = raw_overrides as Dictionary
|
||||
|
||||
|
||||
func _save() -> void:
|
||||
@@ -108,6 +151,7 @@ func _save() -> void:
|
||||
cfg.set_value(SECTION, "music_muted", music_muted)
|
||||
cfg.set_value(SECTION, "sfx_volume", sfx_volume)
|
||||
cfg.set_value(SECTION, "sfx_muted", sfx_muted)
|
||||
cfg.set_value(SECTION_GAMEPLAY, "camera_follow_unit", camera_follow_unit)
|
||||
cfg.set_value(SECTION_VISUAL, "skybox_mode", skybox_mode)
|
||||
cfg.set_value(SECTION_GAMEPLAY, "camera_follow_unit", camera_follow_unit)
|
||||
cfg.set_value(SECTION_VISUAL, "skybox_mode", skybox_mode)
|
||||
cfg.set_value(SECTION_HIGHLIGHTS, "highlight_overrides", highlight_overrides)
|
||||
cfg.save(SAVE_PATH)
|
||||
|
||||
@@ -28,6 +28,7 @@ CustomLobby="*res://autoloads/CustomLobby.gd"
|
||||
ModelCache="*res://autoloads/ModelCache.gd"
|
||||
Music="*res://autoloads/Music.gd"
|
||||
SFX="*res://autoloads/SFX.gd"
|
||||
HighlightConfig="*res://autoloads/HighlightConfig.gd"
|
||||
|
||||
[display]
|
||||
|
||||
|
||||
@@ -198,6 +198,16 @@ var _needs_face_rot : Dictionary = {} # iid → bool (team-based 180° f
|
||||
# Model retry tracking (when real GLB failed to download at placement time).
|
||||
var _unit_model_retries : Dictionary = {} # iid → attempt number (1-based, capped at 10)
|
||||
|
||||
# ── Cursor & hover state ───────────────────────────────────────────────────────
|
||||
## The selector highlight follows the mouse tile at all times.
|
||||
var _cursor_highlight : MeshInstance3D = null
|
||||
## Team-colour overlay shown when hovering an occupied tile or unit.
|
||||
var _hover_team_overlay : MeshInstance3D = null
|
||||
## Currently hovered tile coord (updated every mouse-motion event).
|
||||
var _hovered_coord : Vector2i = Vector2i(-1, -1)
|
||||
## The MeshInstance3D of the unit currently receiving a hover-glow override.
|
||||
var _hovered_unit_mesh : MeshInstance3D = null
|
||||
|
||||
## Animation name aliases: maps the canonical lower-case action to fallback track names.
|
||||
## The AnimationPlayer track list is matched case-insensitively against each entry.
|
||||
const ANIM_ALIASES : Dictionary = {
|
||||
@@ -213,6 +223,7 @@ const ANIM_ALIASES : Dictionary = {
|
||||
func _ready() -> void:
|
||||
_setup_environment()
|
||||
_apply_camera()
|
||||
_init_cursor_nodes()
|
||||
|
||||
_draw_btn.pressed.connect(_on_draw_pressed)
|
||||
_end_turn_btn.pressed.connect(_on_end_turn_pressed)
|
||||
@@ -269,6 +280,7 @@ func _exit_tree() -> void:
|
||||
Game.game_activity.disconnect(_on_game_activity)
|
||||
if Settings.settings_changed.is_connected(_on_skybox_setting_changed):
|
||||
Settings.settings_changed.disconnect(_on_skybox_setting_changed)
|
||||
_reset_unit_hover_glow()
|
||||
# Unsubscribe from activity feed and free star nodes.
|
||||
if _ambient_star_timer != null and is_instance_valid(_ambient_star_timer):
|
||||
_ambient_star_timer.queue_free()
|
||||
@@ -672,6 +684,8 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
_cam_yaw -= delta.x * 0.4
|
||||
_cam_pitch = clampf(_cam_pitch + delta.y * 0.3, 15.0, 75.0)
|
||||
_apply_camera()
|
||||
# Always update cursor/hover on mouse move (even while drag — hides during drag).
|
||||
_update_hover(mm.position)
|
||||
if _pan_active:
|
||||
var ps := _cam_distance * 0.0015
|
||||
var right := _camera_rig.global_basis.x * delta.x * ps
|
||||
@@ -791,7 +805,9 @@ func _rebuild_ownership(state: Dictionary) -> void:
|
||||
func _build_board(board: Dictionary) -> void:
|
||||
for c in _tiles_root.get_children(): c.queue_free()
|
||||
for c in _units_root.get_children(): c.queue_free()
|
||||
for c in _hi_root.get_children(): c.queue_free()
|
||||
for c : Node in _hi_root.get_children():
|
||||
if c != _cursor_highlight and c != _hover_team_overlay:
|
||||
c.queue_free()
|
||||
_tile_bodies.clear()
|
||||
_unit_meshes.clear()
|
||||
_unit_bodies.clear()
|
||||
@@ -1834,40 +1850,156 @@ func _schedule_rebuild(state: Dictionary, delay: float) -> void:
|
||||
# ── Highlights ────────────────────────────────────────────────────────────────
|
||||
|
||||
func _clear_highlights() -> void:
|
||||
print("Clearing")
|
||||
for c in _hi_root.get_children(): c.queue_free()
|
||||
# Preserve the two permanently-allocated hover quads (last two children).
|
||||
var children := _hi_root.get_children()
|
||||
for i in range(children.size()):
|
||||
var c : Node = children[i]
|
||||
if c != _cursor_highlight and c != _hover_team_overlay:
|
||||
c.queue_free()
|
||||
|
||||
|
||||
func _add_highlight(x: int, y: int, color: Color) -> void:
|
||||
## Update the always-visible cursor/hover state based on the current mouse position.
|
||||
## Called on every InputEventMouseMotion event.
|
||||
func _update_hover(mouse_pos: Vector2) -> void:
|
||||
if _cursor_highlight == null or _hover_team_overlay == null:
|
||||
return
|
||||
|
||||
# If dragging (camera rotation / pan), hide highlights.
|
||||
if _drag_active or _pan_active:
|
||||
_cursor_highlight.visible = false
|
||||
_hover_team_overlay.visible = false
|
||||
_reset_unit_hover_glow()
|
||||
_hovered_coord = Vector2i(-1, -1)
|
||||
return
|
||||
|
||||
var coord := _mouse_to_tile_coord(mouse_pos)
|
||||
if coord == _hovered_coord:
|
||||
return
|
||||
|
||||
# Reset previous unit glow.
|
||||
_reset_unit_hover_glow()
|
||||
|
||||
_hovered_coord = coord
|
||||
if coord.x < 0:
|
||||
_cursor_highlight.visible = false
|
||||
_hover_team_overlay.visible = false
|
||||
return
|
||||
|
||||
# Move selector cursor.
|
||||
var sel_tex : Texture2D = HighlightConfig.get_texture("selector")
|
||||
var sel_col : Color = HighlightConfig.get_color("selector")
|
||||
_place_highlight_quad(_cursor_highlight, coord.x, coord.y, sel_col, sel_tex)
|
||||
|
||||
# Check for an occupant on this tile and highlight with team colour.
|
||||
var tile : Dictionary = Game.get_tile(coord.x, coord.y)
|
||||
var occ_id : String = tile.get("occupantId", "")
|
||||
if occ_id.is_empty():
|
||||
_hover_team_overlay.visible = false
|
||||
return
|
||||
|
||||
var is_enemy : bool = _is_enemy_unit(occ_id)
|
||||
var team_col : Color = Color(1.0, 0.35, 0.35, 0.35) if is_enemy else Color(0.3, 0.5, 1.0, 0.35)
|
||||
|
||||
_place_highlight_quad(_hover_team_overlay, coord.x, coord.y, team_col)
|
||||
|
||||
# Boost emission on the unit mesh.
|
||||
if _unit_meshes.has(occ_id):
|
||||
var mesh : MeshInstance3D = _unit_meshes[occ_id] as MeshInstance3D
|
||||
if mesh != null:
|
||||
var orig_mat : Material = mesh.get_active_material(0)
|
||||
if orig_mat != null:
|
||||
var glow_mat : StandardMaterial3D = orig_mat.duplicate() as StandardMaterial3D
|
||||
glow_mat.emission_enabled = true
|
||||
glow_mat.emission = Color(team_col.r, team_col.g, team_col.b)
|
||||
glow_mat.emission_energy_multiplier = 2.5
|
||||
mesh.set_surface_override_material(0, glow_mat)
|
||||
_hovered_unit_mesh = mesh
|
||||
|
||||
|
||||
func _reset_unit_hover_glow() -> void:
|
||||
if _hovered_unit_mesh != null and is_instance_valid(_hovered_unit_mesh):
|
||||
_hovered_unit_mesh.set_surface_override_material(0, null)
|
||||
_hovered_unit_mesh = null
|
||||
|
||||
|
||||
## Create the two permanently-allocated hover/cursor quads.
|
||||
## Called once in _ready() after the scene is set up.
|
||||
func _init_cursor_nodes() -> void:
|
||||
_cursor_highlight = _make_highlight_quad(Color(1, 1, 1, 0.25))
|
||||
_hover_team_overlay = _make_highlight_quad(Color(0, 0, 0, 0))
|
||||
_hi_root.add_child(_cursor_highlight)
|
||||
_hi_root.add_child(_hover_team_overlay)
|
||||
_cursor_highlight.visible = false
|
||||
_hover_team_overlay.visible = false
|
||||
|
||||
|
||||
## Build a flat (PlaneMesh) highlight quad with the given fallback colour.
|
||||
## The caller positions it; the mesh is 0.96 × 0.96 lying flat (rotated -90° on X).
|
||||
func _make_highlight_quad(fallback: Color) -> MeshInstance3D:
|
||||
var mi := MeshInstance3D.new()
|
||||
var bm := BoxMesh.new()
|
||||
bm.size = Vector3(0.96, 0.06, 0.96)
|
||||
mi.mesh = bm
|
||||
var pm := PlaneMesh.new()
|
||||
pm.size = Vector2(0.96, 0.96)
|
||||
mi.mesh = pm
|
||||
var mat := StandardMaterial3D.new()
|
||||
# Use a solid opaque base + emission so the highlight is always visible
|
||||
# regardless of depth-sort or transparency ordering.
|
||||
mat.albedo_color = Color(color.r, color.g, color.b, 1.0)
|
||||
mat.emission_enabled = true
|
||||
mat.emission = Color(color.r, color.g, color.b)
|
||||
mat.emission_energy_multiplier = 2.0
|
||||
# Keep a mild transparency so the tile below is still readable.
|
||||
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
mat.albedo_color.a = 0.75
|
||||
mi.material_override = mat
|
||||
# Position just above the tile top (varies per-tile, accounting for stagger).
|
||||
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
mat.albedo_color = fallback
|
||||
mat.emission_enabled = true
|
||||
mat.emission = Color(fallback.r, fallback.g, fallback.b)
|
||||
mat.emission_energy_multiplier = 1.5
|
||||
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
mat.cull_mode = BaseMaterial3D.CULL_DISABLED
|
||||
mi.material_override = mat
|
||||
return mi
|
||||
|
||||
|
||||
## Add a textured highlight quad above tile (x, y) for the given game-action type.
|
||||
## type_key: "movement" | "attack" | "ability" | "terramorpha"
|
||||
## Falls back to HighlightConfig colours when no texture is loaded yet.
|
||||
func _add_highlight(x: int, y: int, type_key: String) -> void:
|
||||
var mi := MeshInstance3D.new()
|
||||
var pm := PlaneMesh.new()
|
||||
pm.size = Vector2(0.96, 0.96)
|
||||
mi.mesh = pm
|
||||
var mat := StandardMaterial3D.new()
|
||||
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
mat.emission_enabled = true
|
||||
mat.emission_energy_multiplier = 1.5
|
||||
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
mat.cull_mode = BaseMaterial3D.CULL_DISABLED
|
||||
var tex : Texture2D = HighlightConfig.get_texture(type_key)
|
||||
var col : Color = HighlightConfig.get_color(type_key)
|
||||
if tex != null:
|
||||
mat.albedo_texture = tex
|
||||
mat.albedo_color = Color(col.r, col.g, col.b, col.a)
|
||||
else:
|
||||
mat.albedo_color = col
|
||||
mat.emission = Color(col.r, col.g, col.b)
|
||||
mi.material_override = mat
|
||||
var _hi_tile_h : float = _tile_heights.get("%d,%d" % [x, y], 1.0)
|
||||
var _hi_tile_base : float = _tile_y_bases.get("%d,%d" % [x, y], 0.0)
|
||||
mi.position = _coord_to_world(x, y) + Vector3(0, _hi_tile_base + _hi_tile_h + 0.08, 0)
|
||||
mi.position = _coord_to_world(x, y) + Vector3(0, _hi_tile_base + _hi_tile_h + 0.05, 0)
|
||||
_hi_root.add_child(mi)
|
||||
print("[Highlight] added (%d,%d) hi_root children=%d" % [x, y, _hi_root.get_child_count()])
|
||||
|
||||
|
||||
func _highlight_tiles(coords: Array, color: Color) -> void:
|
||||
func _highlight_tiles(coords: Array, type_key: String) -> void:
|
||||
for coord in coords:
|
||||
if coord is Vector2i:
|
||||
_add_highlight(coord.x, coord.y, color)
|
||||
_add_highlight(coord.x, coord.y, type_key)
|
||||
elif coord is Dictionary:
|
||||
_add_highlight(coord.get("x", 0), coord.get("y", 0), color)
|
||||
_add_highlight(coord.get("x", 0), coord.get("y", 0), type_key)
|
||||
|
||||
|
||||
## Position a permanently-allocated highlight quad above tile (x, y).
|
||||
func _place_highlight_quad(quad: MeshInstance3D, x: int, y: int, col: Color, texture: Texture2D = null) -> void:
|
||||
var tile_h : float = _tile_heights.get("%d,%d" % [x, y], 1.0)
|
||||
var tile_base : float = _tile_y_bases.get("%d,%d" % [x, y], 0.0)
|
||||
quad.position = _coord_to_world(x, y) + Vector3(0, tile_base + tile_h + 0.05, 0)
|
||||
var mat := quad.material_override as StandardMaterial3D
|
||||
mat.albedo_color = col
|
||||
mat.emission = Color(col.r, col.g, col.b)
|
||||
if texture != null:
|
||||
mat.albedo_texture = texture
|
||||
quad.visible = true
|
||||
|
||||
# ── Valid target computation ──────────────────────────────────────────────────
|
||||
|
||||
@@ -2098,7 +2230,7 @@ func _handle_board_click(mouse_pos: Vector2) -> void:
|
||||
# More tiles needed — re-highlight: orange for picked, green for valid next.
|
||||
_clear_highlights()
|
||||
for t: Vector2i in _terra_targets:
|
||||
_add_highlight(t.x, t.y, HI_ORANGE)
|
||||
_add_highlight(t.x, t.y, "terramorpha")
|
||||
var last2 : Vector2i = _terra_targets.back()
|
||||
var bw2 := Game.board_width()
|
||||
var bh2 := Game.board_height()
|
||||
@@ -2107,7 +2239,7 @@ func _handle_board_click(mouse_pos: Vector2) -> void:
|
||||
var ny := last2.y + d.y
|
||||
if nx < 0 or ny < 0 or nx >= bw2 or ny >= bh2: continue
|
||||
if _terra_targets.has(Vector2i(nx, ny)): continue
|
||||
_add_highlight(nx, ny, HI_GREEN)
|
||||
_add_highlight(nx, ny, "movement")
|
||||
|
||||
Mode.UNIT_SELECTED:
|
||||
if not unit_id.is_empty():
|
||||
@@ -2177,7 +2309,7 @@ func _select_unit(unit_id: String) -> void:
|
||||
# Highlight own tile.
|
||||
var upos : Dictionary = unit.get("position", {})
|
||||
if not upos.is_empty():
|
||||
_add_highlight(upos.get("x", 0), upos.get("y", 0), HI_YELLOW)
|
||||
_add_highlight(upos.get("x", 0), upos.get("y", 0), "selector")
|
||||
# Smoothly pan camera to center on this unit if setting is enabled.
|
||||
if Settings.camera_follow_unit:
|
||||
var target := _coord_to_world(upos.get("x", 0), upos.get("y", 0))
|
||||
@@ -2188,13 +2320,13 @@ func _select_unit(unit_id: String) -> void:
|
||||
func(v: Vector3) -> void: _cam_pivot = v; _apply_camera(),
|
||||
from, target, 0.4)
|
||||
|
||||
# Movement range (green).
|
||||
_highlight_tiles(_valid_move_tiles(unit), HI_GREEN)
|
||||
# Movement range.
|
||||
_highlight_tiles(_valid_move_tiles(unit), "movement")
|
||||
|
||||
# Attack range area (orange) — visible reach even when no enemies are in range.
|
||||
_highlight_tiles(_attack_range_tiles(unit), HI_ORANGE)
|
||||
# Attackable enemies (red — drawn on top of orange).
|
||||
_highlight_tiles(_valid_attack_target_coords(unit), HI_RED)
|
||||
# Attack range area — visible reach even when no enemies are in range.
|
||||
_highlight_tiles(_attack_range_tiles(unit), "terramorpha")
|
||||
# Attackable enemies (drawn on top).
|
||||
_highlight_tiles(_valid_attack_target_coords(unit), "attack")
|
||||
|
||||
# Show ability panel if unit has active abilities.
|
||||
_show_ability_panel(unit_id, unit)
|
||||
@@ -2271,7 +2403,7 @@ func _start_sacrifice_mode() -> void:
|
||||
for spirit: Dictionary in _valid_sacrifice_spirits():
|
||||
var sp : Dictionary = spirit.get("position", {})
|
||||
if not sp.is_empty():
|
||||
_add_highlight(sp.get("x", 0), sp.get("y", 0), HI_GREEN)
|
||||
_add_highlight(sp.get("x", 0), sp.get("y", 0), "movement")
|
||||
|
||||
|
||||
func _confirm_sacrifice(unit_id: String, unit_name: String) -> void:
|
||||
@@ -2534,7 +2666,7 @@ func _highlight_ability_targets(action: Dictionary) -> void:
|
||||
for tx in range(bw):
|
||||
for ty in range(bh):
|
||||
if _tile_passes_filters(tx, ty, filters):
|
||||
_add_highlight(tx, ty, HI_BLUE)
|
||||
_add_highlight(tx, ty, "ability")
|
||||
return
|
||||
|
||||
# Unit-type target — highlight the board position of each matching unit.
|
||||
@@ -2572,7 +2704,7 @@ func _highlight_ability_targets(action: Dictionary) -> void:
|
||||
absi(int(pos.get("y", 0)) - int(src_pos_ab.get("y", 0))))
|
||||
if dist < int(_ability_range.get("min", 0)) or dist > int(_ability_range.get("max", 999)):
|
||||
continue
|
||||
_add_highlight(pos.get("x", 0), pos.get("y", 0), HI_BLUE)
|
||||
_add_highlight(pos.get("x", 0), pos.get("y", 0), "ability")
|
||||
|
||||
|
||||
## Returns true if the unit passes all client-evaluable filters.
|
||||
@@ -2791,7 +2923,7 @@ func _on_hand_card_clicked(iid: String, _panel: PanelContainer) -> void:
|
||||
_set_mode(Mode.TERRAMORPHA_SELECT)
|
||||
_terra_count = _terra_count_for_card(card)
|
||||
_clear_highlights()
|
||||
_highlight_tiles(_valid_play_tiles(card), HI_GREEN)
|
||||
_highlight_tiles(_valid_play_tiles(card), "movement")
|
||||
return
|
||||
|
||||
# Ruin — server auto-places it; channel immediately on click.
|
||||
@@ -2860,7 +2992,7 @@ func _on_hand_card_clicked(iid: String, _panel: PanelContainer) -> void:
|
||||
_sel_card_id = iid
|
||||
_set_mode(Mode.CARD_FROM_HAND)
|
||||
_clear_highlights()
|
||||
_highlight_tiles(_valid_play_tiles(card), HI_GREEN)
|
||||
_highlight_tiles(_valid_play_tiles(card), "movement")
|
||||
|
||||
# ── Hand display ──────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -2985,7 +3117,7 @@ func _update_hud(state: Dictionary) -> void:
|
||||
if _mode != Mode.PLACEMENT:
|
||||
_set_mode(Mode.PLACEMENT)
|
||||
_clear_highlights()
|
||||
_highlight_tiles(_valid_placement_tiles(), HI_GREEN)
|
||||
_highlight_tiles(_valid_placement_tiles(), "movement")
|
||||
else:
|
||||
_phase_lbl.text = "Phase: Placement — waiting for opponent…"
|
||||
if _mode == Mode.PLACEMENT:
|
||||
@@ -3216,7 +3348,7 @@ func _on_state_updated(state: Dictionary) -> void:
|
||||
# Re-apply highlights: board/units may have changed.
|
||||
print("[StateUpdate] preserving CARD_FROM_HAND, re-highlighting")
|
||||
_clear_highlights()
|
||||
_highlight_tiles(_valid_play_tiles(sel_card), HI_GREEN)
|
||||
_highlight_tiles(_valid_play_tiles(sel_card), "movement")
|
||||
_refresh_hand_selection() # mark the (new) widget as selected
|
||||
|
||||
_:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
extends Control
|
||||
## Settings screen — audio volume and mute controls.
|
||||
## Settings screen — audio volume, mute, gameplay, and highlight override controls.
|
||||
## Reads initial values from the Settings autoload and writes back on change.
|
||||
|
||||
@onready var back_btn : Button = %BackBtn
|
||||
@@ -9,6 +9,9 @@ extends Control
|
||||
@onready var sfx_mute_btn : CheckButton = %SfxMuteBtn
|
||||
@onready var camera_follow_btn : CheckButton = %CameraFollowBtn
|
||||
|
||||
const _HI_TYPES : Array = ["movement", "attack", "ability", "terramorpha", "selector"]
|
||||
const _HI_LABELS: Array = ["Movement", "Attack", "Ability", "Terramorpha", "Selector"]
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -20,6 +23,7 @@ func _ready() -> void:
|
||||
camera_follow_btn.set_pressed_no_signal(Settings.camera_follow_unit)
|
||||
|
||||
_refresh_slider_states()
|
||||
_build_highlight_section()
|
||||
|
||||
back_btn.pressed.connect(_on_back)
|
||||
music_slider.value_changed.connect(func(v): Settings.music_volume = v)
|
||||
@@ -43,3 +47,68 @@ func _refresh_slider_states() -> void:
|
||||
|
||||
func _on_back() -> void:
|
||||
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn")
|
||||
|
||||
|
||||
# ── Highlight override section (built programmatically) ───────────────────────
|
||||
|
||||
func _build_highlight_section() -> void:
|
||||
var sections : VBoxContainer = get_node_or_null(
|
||||
"Layout/ScrollContainer/Content/ContentMargin/Sections")
|
||||
if sections == null:
|
||||
return
|
||||
|
||||
var section := VBoxContainer.new()
|
||||
section.add_theme_constant_override("separation", 6)
|
||||
|
||||
var header := Label.new()
|
||||
header.text = "Highlight Texture Overrides"
|
||||
header.add_theme_font_size_override("font_size", 16)
|
||||
section.add_child(header)
|
||||
|
||||
var note := Label.new()
|
||||
note.text = "Enter a custom texture URL for each highlight type, or leave blank to use\nthe server default. Changes apply immediately."
|
||||
note.autowrap_mode = TextServer.AUTOWRAP_WORD
|
||||
note.modulate = Color(0.75, 0.75, 0.75)
|
||||
note.add_theme_font_size_override("font_size", 12)
|
||||
section.add_child(note)
|
||||
|
||||
for i in range(_HI_TYPES.size()):
|
||||
var key : String = _HI_TYPES[i]
|
||||
var label : String = _HI_LABELS[i]
|
||||
var row := _make_override_row(key, label)
|
||||
section.add_child(row)
|
||||
|
||||
sections.add_child(section)
|
||||
|
||||
|
||||
func _make_override_row(key: String, label: String) -> HBoxContainer:
|
||||
var row := HBoxContainer.new()
|
||||
row.add_theme_constant_override("separation", 8)
|
||||
|
||||
var lbl := Label.new()
|
||||
lbl.text = label
|
||||
lbl.custom_minimum_size = Vector2(90, 0)
|
||||
lbl.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
row.add_child(lbl)
|
||||
|
||||
var edit := LineEdit.new()
|
||||
edit.placeholder_text = "https://cdn.sor.gg/highlights/… (leave blank for default)"
|
||||
edit.text = str(Settings.highlight_overrides.get(key, ""))
|
||||
edit.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
row.add_child(edit)
|
||||
|
||||
var reset_btn := Button.new()
|
||||
reset_btn.text = "Reset"
|
||||
reset_btn.tooltip_text = "Remove override — use server default"
|
||||
row.add_child(reset_btn)
|
||||
|
||||
# Apply URL when the LineEdit loses focus or Enter is pressed.
|
||||
edit.text_submitted.connect(func(url: String) -> void:
|
||||
Settings.set_highlight_override(key, url.strip_edges()))
|
||||
edit.focus_exited.connect(func() -> void:
|
||||
Settings.set_highlight_override(key, edit.text.strip_edges()))
|
||||
reset_btn.pressed.connect(func() -> void:
|
||||
Settings.clear_highlight_override(key)
|
||||
edit.text = "")
|
||||
|
||||
return row
|
||||
|
||||
@@ -127,6 +127,11 @@
|
||||
<i class="bi bi-cloud-sun me-2"></i>Skyboxes
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<NavLink class="nav-link text-white-50 py-1" href="/content/highlights">
|
||||
<i class="bi bi-grid-fill me-2"></i>Highlights
|
||||
</NavLink>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
@using SOR.Database.Contexts
|
||||
@using SOR.Database.Entities.Bazaar
|
||||
@using SOR.Database.Enums
|
||||
@using System.Text.Json.Nodes
|
||||
@inject BazaarDbContext Db
|
||||
@inject CatalogDbContext CatalogDb
|
||||
@inject SOR.Cdn.ICdnClient Cdn
|
||||
@@ -110,23 +111,84 @@ else
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Asset -->
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header fw-medium">Asset URL (art / model)</div>
|
||||
<div class="card-body">
|
||||
<input @bind="_cosmetic.AssetCdnUrl"
|
||||
class="form-control form-control-sm mb-2"
|
||||
placeholder="https://cdn.sor.gg/…" />
|
||||
<label class="btn btn-sm btn-outline-primary @(_uploadingAsset ? "disabled" : "")">
|
||||
@if (_uploadingAsset) { <span class="spinner-border spinner-border-sm"></span> }
|
||||
else { <i class="bi bi-upload"></i> }
|
||||
<span class="ms-1">Upload</span>
|
||||
<InputFile style="display:none"
|
||||
accept="image/*,.glb,.gltf,.fbx"
|
||||
OnChange="UploadAssetAsync" />
|
||||
</label>
|
||||
<!-- Asset — normal types -->
|
||||
@if (_cosmetic.CosmeticType != CosmeticType.HighlightPack)
|
||||
{
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header fw-medium">Asset URL (art / model)</div>
|
||||
<div class="card-body">
|
||||
<input @bind="_cosmetic.AssetCdnUrl"
|
||||
class="form-control form-control-sm mb-2"
|
||||
placeholder="https://cdn.sor.gg/…" />
|
||||
<label class="btn btn-sm btn-outline-primary @(_uploadingAsset ? "disabled" : "")">
|
||||
@if (_uploadingAsset) { <span class="spinner-border spinner-border-sm"></span> }
|
||||
else { <i class="bi bi-upload"></i> }
|
||||
<span class="ms-1">Upload</span>
|
||||
<InputFile style="display:none"
|
||||
accept="image/*,.glb,.gltf,.fbx"
|
||||
OnChange="UploadAssetAsync" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<!-- HighlightPack — per-type texture editor -->
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header fw-medium">Highlight Pack Textures</div>
|
||||
<div class="card-body p-0">
|
||||
<table class="table table-sm mb-0 align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:110px">Type</th>
|
||||
<th>CDN Path</th>
|
||||
<th style="width:80px" class="text-center">Animated</th>
|
||||
<th style="width:65px">Frames</th>
|
||||
<th style="width:55px">FPS</th>
|
||||
<th style="width:105px">Fallback Hex</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var key in _packKeys)
|
||||
{
|
||||
var k = key;
|
||||
var p = _highlightPack[k];
|
||||
<tr>
|
||||
<td class="fw-medium">@k</td>
|
||||
<td>
|
||||
<input value="@p.CdnPath"
|
||||
@onchange='e => p.CdnPath = e.Value?.ToString() ?? ""'
|
||||
class="form-control form-control-sm font-monospace"
|
||||
placeholder="https://cdn.sor.gg/…" />
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<input type="checkbox" class="form-check-input"
|
||||
checked="@p.IsAnimated"
|
||||
@onchange='e => p.IsAnimated = (bool)(e.Value ?? false)' />
|
||||
</td>
|
||||
<td>
|
||||
<input value="@p.FrameCount" type="number" min="1" max="256"
|
||||
@onchange='e => p.FrameCount = int.TryParse(e.Value?.ToString(), out var n) ? n : 1'
|
||||
class="form-control form-control-sm" />
|
||||
</td>
|
||||
<td>
|
||||
<input value="@p.Fps" type="number" min="1" max="60" step="0.5"
|
||||
@onchange='e => p.Fps = float.TryParse(e.Value?.ToString(), out var f) ? f : 12f'
|
||||
class="form-control form-control-sm" />
|
||||
</td>
|
||||
<td>
|
||||
<input value="@p.FallbackHex"
|
||||
@onchange='e => p.FallbackHex = e.Value?.ToString() ?? "#FFFFFF66"'
|
||||
class="form-control form-control-sm font-monospace"
|
||||
placeholder="#RRGGBBAA" />
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -152,6 +214,25 @@ else
|
||||
@code {
|
||||
[Parameter] public Guid? Id { get; set; }
|
||||
|
||||
private sealed class PackEntry
|
||||
{
|
||||
public string CdnPath { get; set; } = string.Empty;
|
||||
public bool IsAnimated { get; set; }
|
||||
public int FrameCount { get; set; } = 1;
|
||||
public float Fps { get; set; } = 12f;
|
||||
public string FallbackHex{ get; set; } = "#FFFFFF66";
|
||||
}
|
||||
|
||||
private static readonly string[] _packKeys = ["Movement", "Attack", "Ability", "Terramorpha", "Selector"];
|
||||
private static readonly Dictionary<string, string> _packDefaultHex = new()
|
||||
{
|
||||
["Movement"] = "#33FF3366",
|
||||
["Attack"] = "#FF404080",
|
||||
["Ability"] = "#3380FF66",
|
||||
["Terramorpha"] = "#FF990073",
|
||||
["Selector"] = "#FFFFFF40",
|
||||
};
|
||||
|
||||
private bool IsNew => !Id.HasValue;
|
||||
private Cosmetic? _cosmetic;
|
||||
private string _cosmeticTypeStr = nameof(CosmeticType.CardBack);
|
||||
@@ -159,6 +240,11 @@ else
|
||||
private bool _saving, _uploadingPreview, _uploadingAsset;
|
||||
private string? _error;
|
||||
|
||||
// HighlightPack state — one entry per type.
|
||||
private Dictionary<string, PackEntry> _highlightPack = _packKeys.ToDictionary(
|
||||
k => k,
|
||||
k => new PackEntry { FallbackHex = _packDefaultHex.GetValueOrDefault(k, "#FFFFFF66") });
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (IsNew)
|
||||
@@ -171,6 +257,8 @@ else
|
||||
if (_cosmetic is null) { Nav.NavigateTo("/bazaar/cosmetics"); return; }
|
||||
_cosmeticTypeStr = _cosmetic.CosmeticType.ToString();
|
||||
_cardDefinitionIdStr = _cosmetic.CardDefinitionId?.ToString() ?? string.Empty;
|
||||
if (_cosmetic.CosmeticType == CosmeticType.HighlightPack)
|
||||
_ParseHighlightPack(_cosmetic.AssetCdnUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,18 +290,69 @@ else
|
||||
finally { _uploadingAsset = false; }
|
||||
}
|
||||
|
||||
private void _ParseHighlightPack(string json)
|
||||
{
|
||||
_highlightPack = _packKeys.ToDictionary(
|
||||
k => k,
|
||||
k => new PackEntry { FallbackHex = _packDefaultHex.GetValueOrDefault(k, "#FFFFFF66") });
|
||||
try
|
||||
{
|
||||
var root = JsonNode.Parse(json) as JsonObject;
|
||||
if (root is null) return;
|
||||
foreach (var key in _packKeys)
|
||||
{
|
||||
var lk = key.ToLowerInvariant();
|
||||
if (root[lk] is JsonObject o)
|
||||
{
|
||||
_highlightPack[key] = new PackEntry
|
||||
{
|
||||
CdnPath = o["cdnPath"]?.GetValue<string>() ?? "",
|
||||
IsAnimated = o["isAnimated"]?.GetValue<bool>() ?? false,
|
||||
FrameCount = o["frameCount"]?.GetValue<int>() ?? 1,
|
||||
Fps = (float)(o["fps"]?.GetValue<double>() ?? 12.0),
|
||||
FallbackHex = o["fallbackHex"]?.GetValue<string>() ?? _packDefaultHex.GetValueOrDefault(key, "#FFFFFF66"),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { /* malformed JSON — keep defaults */ }
|
||||
}
|
||||
|
||||
private string _SerializeHighlightPack()
|
||||
{
|
||||
var root = new JsonObject();
|
||||
foreach (var key in _packKeys)
|
||||
{
|
||||
var p = _highlightPack[key];
|
||||
root[key.ToLowerInvariant()] = new JsonObject
|
||||
{
|
||||
["cdnPath"] = p.CdnPath,
|
||||
["isAnimated"] = p.IsAnimated,
|
||||
["frameCount"] = p.FrameCount,
|
||||
["fps"] = p.Fps,
|
||||
["fallbackHex"] = p.FallbackHex,
|
||||
};
|
||||
}
|
||||
return root.ToJsonString();
|
||||
}
|
||||
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
_error = null;
|
||||
if (string.IsNullOrWhiteSpace(_cosmetic!.Name))
|
||||
{ _error = "Name is required."; return; }
|
||||
if (string.IsNullOrWhiteSpace(_cosmetic.AssetCdnUrl))
|
||||
{ _error = "Asset URL is required."; return; }
|
||||
|
||||
if (!Enum.TryParse<CosmeticType>(_cosmeticTypeStr, out var t))
|
||||
{ _error = "Invalid cosmetic type."; return; }
|
||||
_cosmetic.CosmeticType = t;
|
||||
|
||||
// For HighlightPack, AssetCdnUrl holds the serialized JSON pack.
|
||||
if (t == CosmeticType.HighlightPack)
|
||||
_cosmetic.AssetCdnUrl = _SerializeHighlightPack();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(_cosmetic.AssetCdnUrl))
|
||||
{ _error = "Asset URL is required."; return; }
|
||||
|
||||
_cosmetic.CardDefinitionId = string.IsNullOrWhiteSpace(_cardDefinitionIdStr) ? null
|
||||
: Guid.TryParse(_cardDefinitionIdStr, out var g) ? g : null;
|
||||
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
@page "/content/highlights"
|
||||
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using SOR.Database.Contexts
|
||||
@using SOR.Database.Entities.Catalog
|
||||
@inject CatalogDbContext Db
|
||||
|
||||
<PageTitle>Highlight Textures – SOR Admin</PageTitle>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h1 class="mb-0">Tile Highlight Textures</h1>
|
||||
<div class="text-muted small">
|
||||
Configure textures for each battlefield tile highlight type. The client applies these
|
||||
as flat quads on top of tiles. Leave CdnPath empty to use the fallback colour only.
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-outline-secondary btn-sm" @onclick="LoadAsync" disabled="@_loading">
|
||||
<i class="bi bi-arrow-clockwise me-1"></i>Refresh
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@if (_message is not null)
|
||||
{
|
||||
<div class="alert @(_isError ? "alert-danger" : "alert-success") alert-dismissible">
|
||||
@_message
|
||||
<button type="button" class="btn-close" @onclick='() => _message = null'></button>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (_loading)
|
||||
{
|
||||
<p class="text-muted">Loading…</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row g-3">
|
||||
@foreach (var row in _rows)
|
||||
{
|
||||
var r = row;
|
||||
<div class="col-12">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header d-flex align-items-center gap-2">
|
||||
<span class="fw-medium">@r.Config.HighlightType</span>
|
||||
@{
|
||||
var swatch = r.Config.FallbackHex;
|
||||
if (swatch.Length == 9) swatch = swatch[..7]; // strip alpha for CSS
|
||||
}
|
||||
<span class="rounded-2 border"
|
||||
style="display:inline-block;width:18px;height:18px;background:@swatch;"></span>
|
||||
<span class="text-muted small fst-italic">@r.Config.FallbackHex</span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row g-3 align-items-end">
|
||||
<div class="col-md-5">
|
||||
<label class="form-label small">CDN Path / URL</label>
|
||||
<input @bind='r.Config.CdnPath'
|
||||
class="form-control form-control-sm font-monospace"
|
||||
placeholder="https://cdn.sor.gg/highlights/… (leave empty for colour only)" />
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label small">Fallback Hex</label>
|
||||
<input @bind='r.Config.FallbackHex'
|
||||
class="form-control form-control-sm font-monospace"
|
||||
placeholder="#RRGGBBAA" />
|
||||
</div>
|
||||
<div class="col-auto d-flex align-items-end gap-3 pb-1">
|
||||
<div class="form-check mb-0">
|
||||
<input @bind='r.Config.IsAnimated' type="checkbox"
|
||||
class="form-check-input" id="@("anim_" + r.Config.HighlightType)" />
|
||||
<label class="form-check-label small"
|
||||
for="@("anim_" + r.Config.HighlightType)">Animated</label>
|
||||
</div>
|
||||
</div>
|
||||
@if (r.Config.IsAnimated)
|
||||
{
|
||||
<div class="col-md-1">
|
||||
<label class="form-label small">Frames</label>
|
||||
<input @bind='r.Config.FrameCount' type="number"
|
||||
class="form-control form-control-sm" min="1" max="256" />
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<label class="form-label small">FPS</label>
|
||||
<input @bind='r.Config.Fps' type="number"
|
||||
class="form-control form-control-sm" min="1" max="60" step="0.5" />
|
||||
</div>
|
||||
}
|
||||
<div class="col-auto ms-auto d-flex align-items-end pb-0">
|
||||
<button class="btn btn-sm btn-outline-primary"
|
||||
@onclick='() => SaveRowAsync(r)'>
|
||||
<i class="bi bi-floppy me-1"></i>Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@if (r.Config.IsAnimated && !string.IsNullOrEmpty(r.Config.CdnPath))
|
||||
{
|
||||
<div class="mt-2 text-muted small">
|
||||
Frames served at: <code>@r.Config.CdnPath/0.png</code> …
|
||||
<code>@r.Config.CdnPath/@(r.Config.FrameCount - 1).png</code>
|
||||
</div>
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(r.Config.CdnPath))
|
||||
{
|
||||
<div class="mt-2">
|
||||
<img src="@r.Config.CdnPath" alt="preview"
|
||||
style="max-height:48px;max-width:200px;border-radius:4px;border:1px solid #444" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
private sealed class HighlightRow { public HighlightConfig Config { get; set; } = null!; }
|
||||
|
||||
private static readonly string[] Types = ["Movement", "Attack", "Ability", "Terramorpha", "Selector"];
|
||||
|
||||
private static readonly Dictionary<string, string> DefaultHex = new()
|
||||
{
|
||||
["Movement"] = "#33FF3366",
|
||||
["Attack"] = "#FF404080",
|
||||
["Ability"] = "#3380FF66",
|
||||
["Terramorpha"]= "#FF990073",
|
||||
["Selector"] = "#FFFFFF40",
|
||||
};
|
||||
|
||||
private List<HighlightRow> _rows = new();
|
||||
private bool _loading = true;
|
||||
private string? _message;
|
||||
private bool _isError;
|
||||
|
||||
protected override async Task OnInitializedAsync() => await LoadAsync();
|
||||
|
||||
private async Task LoadAsync()
|
||||
{
|
||||
_loading = true;
|
||||
var existing = await Db.HighlightConfigs
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
|
||||
_rows = Types.Select(t =>
|
||||
{
|
||||
var cfg = existing.FirstOrDefault(e => string.Equals(e.HighlightType, t, StringComparison.OrdinalIgnoreCase))
|
||||
?? new HighlightConfig
|
||||
{
|
||||
HighlightType = t,
|
||||
FallbackHex = DefaultHex.GetValueOrDefault(t, "#FFFFFF66"),
|
||||
};
|
||||
return new HighlightRow { Config = cfg };
|
||||
}).ToList();
|
||||
|
||||
_loading = false;
|
||||
}
|
||||
|
||||
private async Task SaveRowAsync(HighlightRow row)
|
||||
{
|
||||
_message = null;
|
||||
try
|
||||
{
|
||||
var tracked = await Db.HighlightConfigs
|
||||
.FirstOrDefaultAsync(h => string.Equals(h.HighlightType, row.Config.HighlightType, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (tracked is null)
|
||||
{
|
||||
row.Config.Id = row.Config.Id == Guid.Empty ? Guid.NewGuid() : row.Config.Id;
|
||||
Db.HighlightConfigs.Add(row.Config);
|
||||
}
|
||||
else
|
||||
{
|
||||
tracked.CdnPath = row.Config.CdnPath;
|
||||
tracked.FallbackHex = row.Config.FallbackHex;
|
||||
tracked.IsAnimated = row.Config.IsAnimated;
|
||||
tracked.FrameCount = row.Config.FrameCount;
|
||||
tracked.Fps = row.Config.Fps;
|
||||
}
|
||||
|
||||
await Db.SaveChangesAsync();
|
||||
_message = $"{row.Config.HighlightType} highlight saved.";
|
||||
_isError = false;
|
||||
|
||||
// Re-attach the tracked entity to the row so future saves go through the tracked path.
|
||||
if (!Db.HighlightConfigs.Local.Any(h => h.HighlightType == row.Config.HighlightType))
|
||||
Db.Entry(row.Config).State = Microsoft.EntityFrameworkCore.EntityState.Detached;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_message = $"Save failed: {ex.Message}";
|
||||
_isError = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,6 +157,25 @@ public sealed record SkyboxDefinitionDto(
|
||||
int FrameCount,
|
||||
float Fps);
|
||||
|
||||
// ── Highlight config ──────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Fetch all configured tile highlight definitions.</summary>
|
||||
public sealed record GetHighlightConfigRequest;
|
||||
|
||||
public sealed record GetHighlightConfigResponse(IEnumerable<HighlightTypeConfigDto> Configs);
|
||||
|
||||
/// <summary>
|
||||
/// Visual configuration for one type of tile highlight (Movement, Attack, Ability,
|
||||
/// Terramorpha, or Selector). Mirrors the HighlightConfig DB entity.
|
||||
/// </summary>
|
||||
public sealed record HighlightTypeConfigDto(
|
||||
string HighlightType,
|
||||
bool IsAnimated,
|
||||
string CdnPath,
|
||||
int FrameCount,
|
||||
float Fps,
|
||||
string FallbackHex);
|
||||
|
||||
// ── BGM config ───────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Fetch all active background music tracks (keyed by game context).</summary>
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
namespace SOR.Content.Handlers;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SOR.Database.Contexts;
|
||||
using SOR.Networking.Abstractions.Messaging;
|
||||
using SOR.Networking.Abstractions.Transport;
|
||||
using SOR.Shared.Networking;
|
||||
|
||||
/// <summary>
|
||||
/// content.get_highlight_config — returns all configured tile highlight definitions.
|
||||
/// The client uses these to texture the Movement, Attack, Ability, Terramorpha, and
|
||||
/// Selector highlight quads on the battlefield. Returns all rows (not filtered by
|
||||
/// IsActive) so the admin can see partially-configured entries; the client just uses
|
||||
/// whatever is present.
|
||||
/// </summary>
|
||||
internal sealed class ContentGetHighlightConfigHandler : IMessageHandler
|
||||
{
|
||||
private readonly CatalogDbContext _catalogDb;
|
||||
|
||||
public ContentGetHighlightConfigHandler(CatalogDbContext catalogDb)
|
||||
{
|
||||
_catalogDb = catalogDb;
|
||||
}
|
||||
|
||||
public string MessageType => "content.get_highlight_config";
|
||||
|
||||
public async Task<IServerMessage?> HandleAsync(
|
||||
IClientMessage message,
|
||||
AuthenticatedConnection connection,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var configs = await _catalogDb.HighlightConfigs
|
||||
.AsNoTracking()
|
||||
.OrderBy(h => h.HighlightType)
|
||||
.Select(h => new HighlightTypeConfigDto(
|
||||
h.HighlightType,
|
||||
h.IsAnimated,
|
||||
h.CdnPath,
|
||||
h.FrameCount,
|
||||
h.Fps,
|
||||
h.FallbackHex))
|
||||
.ToListAsync(ct);
|
||||
|
||||
return ServerMessage.Reply("content.get_highlight_config.ack", message.Seq,
|
||||
new GetHighlightConfigResponse(configs));
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ public static class ServiceRegistration
|
||||
services.AddTransient<IMessageHandler, ContentGetTileBottomsHandler>();
|
||||
services.AddTransient<IMessageHandler, ContentGetAudioConfigHandler>();
|
||||
services.AddTransient<IMessageHandler, ContentGetSkyboxConfigHandler>();
|
||||
services.AddTransient<IMessageHandler, ContentGetHighlightConfigHandler>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public sealed class CatalogDbContext : DbContext
|
||||
public DbSet<TileBottomModel> TileBottomModels => Set<TileBottomModel>();
|
||||
public DbSet<GameAudioConfig> AudioConfigs => Set<GameAudioConfig>();
|
||||
public DbSet<SkyboxDefinition> SkyboxDefinitions => Set<SkyboxDefinition>();
|
||||
public DbSet<HighlightConfig> HighlightConfigs => Set<HighlightConfig>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
@@ -172,5 +173,16 @@ public sealed class CatalogDbContext : DbContext
|
||||
e.Property(s => s.CdnPath).IsRequired();
|
||||
e.HasIndex(s => s.IsActive);
|
||||
});
|
||||
|
||||
builder.Entity<HighlightConfig>(e =>
|
||||
{
|
||||
e.ToTable("highlight_configs");
|
||||
e.HasKey(h => h.Id);
|
||||
e.Property(h => h.HighlightType).IsRequired();
|
||||
e.Property(h => h.CdnPath).IsRequired();
|
||||
e.Property(h => h.FallbackHex).IsRequired();
|
||||
// One row per highlight type — admin does an upsert by type name.
|
||||
e.HasIndex(h => h.HighlightType).IsUnique();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
namespace SOR.Database.Entities.Catalog;
|
||||
|
||||
/// <summary>
|
||||
/// Configures the visual appearance of one type of tile highlight in the 3D gameplay scene.
|
||||
/// One row per highlight type; HighlightType is the natural key.
|
||||
///
|
||||
/// Static: CdnPath is a direct URL to a PNG/WebP texture applied to the flat highlight quad.
|
||||
/// Animated: CdnPath is a base folder URL; frames are sequential PNGs at /0.png, /1.png, …
|
||||
///
|
||||
/// FallbackHex is the RGBA hex colour used by the client when no texture is configured
|
||||
/// or when the texture fails to load (e.g. "#33FF3366" — green @ 40 % alpha).
|
||||
///
|
||||
/// HighlightType values (matched by the client, case-insensitive):
|
||||
/// Movement, Attack, Ability, Terramorpha, Selector
|
||||
/// </summary>
|
||||
public sealed class HighlightConfig
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
/// <summary>
|
||||
/// Identifier for the highlight type.
|
||||
/// One of: Movement | Attack | Ability | Terramorpha | Selector
|
||||
/// </summary>
|
||||
public string HighlightType { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// When false: CdnPath is a direct URL to a single texture image.
|
||||
/// When true: CdnPath is a base folder URL; frames are at {CdnPath}/0.png … /N.png.
|
||||
/// </summary>
|
||||
public bool IsAnimated { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Static: full CDN URL to the texture (e.g. https://cdn.sor.gg/highlights/move.png).
|
||||
/// Animated: base folder URL without trailing slash.
|
||||
/// Empty string means "use FallbackHex only, no texture."
|
||||
/// </summary>
|
||||
public string CdnPath { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>Number of animation frames. Always 1 for static highlights.</summary>
|
||||
public int FrameCount { get; set; } = 1;
|
||||
|
||||
/// <summary>Playback speed in frames per second. Ignored for static highlights.</summary>
|
||||
public float Fps { get; set; } = 12f;
|
||||
|
||||
/// <summary>
|
||||
/// RGBA hex colour used as the fallback (and as a texture tint when a texture IS set).
|
||||
/// Format: "#RRGGBBAA" (8-char with alpha) or "#RRGGBB" (opaque).
|
||||
/// Example defaults: Movement "#33FF3366", Attack "#FF404080",
|
||||
/// Ability "#3380FF66", Terramorpha "#FF990073", Selector "#FFFFFF40"
|
||||
/// </summary>
|
||||
public string FallbackHex { get; set; } = "#FFFFFF66";
|
||||
}
|
||||
@@ -40,13 +40,18 @@ public enum PurchaseProductType
|
||||
|
||||
/// <summary>
|
||||
/// Type of cosmetic item purchasable from the bazaar.
|
||||
/// CardBack — replaces the card back artwork globally (not card-specific).
|
||||
/// CardBack — replaces the card back artwork globally (not card-specific).
|
||||
/// AlternateCardArt — replaces the 2D art for a specific card definition.
|
||||
/// AlternateCardModel — replaces the 3D model for a specific card definition.
|
||||
/// HighlightPack — replaces battlefield tile highlight textures (Movement, Attack,
|
||||
/// Ability, Terramorpha, Selector). AssetCdnUrl stores a JSON blob:
|
||||
/// { "movement": {"cdnPath":"…","isAnimated":false,"frameCount":1,"fps":12,"fallbackHex":"#RGBA"},
|
||||
/// "attack":{…}, "ability":{…}, "terramorpha":{…}, "selector":{…} }
|
||||
/// </summary>
|
||||
public enum CosmeticType
|
||||
{
|
||||
CardBack,
|
||||
AlternateCardArt,
|
||||
AlternateCardModel,
|
||||
HighlightPack,
|
||||
}
|
||||
|
||||
+576
@@ -0,0 +1,576 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using SOR.Database.Contexts;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SOR.Database.Migrations.Catalog
|
||||
{
|
||||
[DbContext(typeof(CatalogDbContext))]
|
||||
[Migration("20260323102726_AddHighlightConfig")]
|
||||
partial class AddHighlightConfig
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasDefaultSchema("catalog")
|
||||
.HasAnnotation("ProductVersion", "8.0.0")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAnimationBinding", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("ActionName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("AnimationCdnUrl")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("AnimationTrackName")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("CardDefinitionId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("CastSoundCdnUrl")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ImpactSoundCdnUrl")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsAiGenerated")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CardDefinitionId", "ActionName")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("card_animation_bindings", "catalog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAsset", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("AssetType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("CardDefinitionId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("CdnUrl")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ContentETag")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<bool>("IsAiGenerated")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("MimeType")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ModelFacingDirection")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ModelTintMaskUrl")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CardDefinitionId", "AssetType");
|
||||
|
||||
b.ToTable("card_assets", "catalog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("AbilitiesJson")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("abilities");
|
||||
|
||||
b.Property<string>("Affinity")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("AttackSoundUrl")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("AttackType")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("BlockedSoundUrl")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool?>("CanAttack")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool?>("CanBeAttacked")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool?>("CanBeBlocked")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool?>("CanBeObstructed")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool?>("CanBeSacrificed")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool?>("CanDefend")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool?>("CanMove")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool?>("CanUseAbility")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("CardType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int?>("CollectorNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int?>("Damage")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("DamagedSoundUrl")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("DeathSoundUrl")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("DefinitionVersion")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasDefaultValue(0L);
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("EffectsJson")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("effects");
|
||||
|
||||
b.Property<string[]>("Genus")
|
||||
.HasColumnType("text[]");
|
||||
|
||||
b.Property<bool>("IsPublished")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("IsRetired")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int?>("MaxAttackRange")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("MaxChannelRange")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("MaxDefense")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("MaxHealth")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("MinAttackRange")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("MinChannelRange")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<float?>("ModelScale")
|
||||
.HasColumnType("real");
|
||||
|
||||
b.Property<string>("ModelTintColor")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("MoveSoundUrl")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int?>("MovementPoints")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("MovementType")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("OtherCostsJson")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("other_costs");
|
||||
|
||||
b.Property<Guid?>("PreviousTierId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Rarity")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool?>("RequiresLos")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateTimeOffset?>("RetiredAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid?>("SetId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("SpCost")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StCost")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("TerramorphaMode")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int?>("Tier")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTimeOffset>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Affinity");
|
||||
|
||||
b.HasIndex("CardType");
|
||||
|
||||
b.HasIndex("DefinitionVersion");
|
||||
|
||||
b.HasIndex("Name");
|
||||
|
||||
b.HasIndex("PreviousTierId");
|
||||
|
||||
b.HasIndex("Rarity");
|
||||
|
||||
b.HasIndex("SetId");
|
||||
|
||||
b.HasIndex("IsPublished", "SetId");
|
||||
|
||||
b.ToTable("card_definitions", "catalog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardSet", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Code")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateOnly?>("ReleaseDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Code")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("card_sets", "catalog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.CdnUploadRecord", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsAiGenerated")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("ObjectKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Prefix")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PublicUrl")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTimeOffset>("UploadedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IsAiGenerated");
|
||||
|
||||
b.HasIndex("ObjectKey")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("Prefix");
|
||||
|
||||
b.ToTable("cdn_upload_records", "catalog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.GameAudioConfig", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Context")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("TrackCdnUrl")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("TrackName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Context");
|
||||
|
||||
b.HasIndex("IsActive");
|
||||
|
||||
b.ToTable("game_audio_configs", "catalog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.HighlightConfig", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("CdnPath")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FallbackHex")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<float>("Fps")
|
||||
.HasColumnType("real");
|
||||
|
||||
b.Property<int>("FrameCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("HighlightType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsAnimated")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("HighlightType")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("highlight_configs", "catalog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.SkyboxDefinition", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("CdnPath")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<float>("Fps")
|
||||
.HasColumnType("real");
|
||||
|
||||
b.Property<int>("FrameCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("IsAnimated")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IsActive");
|
||||
|
||||
b.ToTable("skybox_definitions", "catalog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.TileBottomModel", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("CdnKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("PublicUrl")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTimeOffset>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IsActive");
|
||||
|
||||
b.ToTable("tile_bottom_models", "catalog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.TileModelBinding", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Affinity")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ModelCdnKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ModelPublicUrl")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Shape")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("TexturePublicUrl")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTimeOffset>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Affinity", "Shape")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("tile_model_bindings", "catalog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAnimationBinding", b =>
|
||||
{
|
||||
b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "CardDefinition")
|
||||
.WithMany("AnimationBindings")
|
||||
.HasForeignKey("CardDefinitionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CardDefinition");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAsset", b =>
|
||||
{
|
||||
b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "CardDefinition")
|
||||
.WithMany("Assets")
|
||||
.HasForeignKey("CardDefinitionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CardDefinition");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b =>
|
||||
{
|
||||
b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "PreviousTier")
|
||||
.WithMany()
|
||||
.HasForeignKey("PreviousTierId")
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
|
||||
b.HasOne("SOR.Database.Entities.Catalog.CardSet", "Set")
|
||||
.WithMany("Cards")
|
||||
.HasForeignKey("SetId")
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
|
||||
b.Navigation("PreviousTier");
|
||||
|
||||
b.Navigation("Set");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b =>
|
||||
{
|
||||
b.Navigation("AnimationBindings");
|
||||
|
||||
b.Navigation("Assets");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardSet", b =>
|
||||
{
|
||||
b.Navigation("Cards");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SOR.Database.Migrations.Catalog
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddHighlightConfig : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "highlight_configs",
|
||||
schema: "catalog",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
HighlightType = table.Column<string>(type: "text", nullable: false),
|
||||
IsAnimated = table.Column<bool>(type: "boolean", nullable: false),
|
||||
CdnPath = table.Column<string>(type: "text", nullable: false),
|
||||
FrameCount = table.Column<int>(type: "integer", nullable: false),
|
||||
Fps = table.Column<float>(type: "real", nullable: false),
|
||||
FallbackHex = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_highlight_configs", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_highlight_configs_HighlightType",
|
||||
schema: "catalog",
|
||||
table: "highlight_configs",
|
||||
column: "HighlightType",
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "highlight_configs",
|
||||
schema: "catalog");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -383,6 +383,41 @@ namespace SOR.Database.Migrations.Catalog
|
||||
b.ToTable("game_audio_configs", "catalog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.HighlightConfig", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("CdnPath")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FallbackHex")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<float>("Fps")
|
||||
.HasColumnType("real");
|
||||
|
||||
b.Property<int>("FrameCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("HighlightType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsAnimated")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("HighlightType")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("highlight_configs", "catalog");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SOR.Database.Entities.Catalog.SkyboxDefinition", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
||||
Reference in New Issue
Block a user