Compare commits
191
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44f61f764e | ||
|
|
4961696fee | ||
|
|
b96b8b89c0 | ||
|
|
ed300d4e4f | ||
|
|
47808074ef | ||
|
|
dfccd091fd | ||
|
|
32693d303b | ||
|
|
91ba3d094d | ||
|
|
88a68a1443 | ||
|
|
7e22d875f6 | ||
|
|
c8c3666d26 | ||
|
|
93e3c8b0db | ||
|
|
e7bf25759f | ||
|
|
14a467dc69 | ||
|
|
e5cfbae7bd | ||
|
|
47effec8d6 | ||
|
|
7dba78ea67 | ||
|
|
0d24a11bcf | ||
|
|
85508ef3e9 | ||
|
|
4e3c197442 | ||
|
|
150a20b0ab | ||
|
|
83217c630e | ||
|
|
41c18da1ed | ||
|
|
8439f287b4 | ||
|
|
db1c3558d8 | ||
|
|
cf6b3a3733 | ||
|
|
ab3c14dd3d | ||
|
|
5756e2187a | ||
|
|
c8f2b5f330 | ||
|
|
d0983cbbcd | ||
|
|
f3e5363c13 | ||
|
|
3bbf419836 | ||
|
|
469e72b0f6 | ||
|
|
a26c99ce4a | ||
|
|
0a20b9880f | ||
|
|
ea840b45d1 | ||
|
|
2325a53f0e | ||
|
|
4f8aba5116 | ||
|
|
3c3e479878 | ||
|
|
b926957329 | ||
|
|
30a4211276 | ||
|
|
8325370069 | ||
|
|
f45df0cf86 | ||
|
|
a5e1dde029 | ||
|
|
9f15cf1e74 | ||
|
|
47cd4fb097 | ||
|
|
8cd71b838c | ||
|
|
f7fc4fbdd3 | ||
|
|
6e13128dd8 | ||
|
|
11c1fcb13a | ||
|
|
3be1099d93 | ||
|
|
f6210caef4 | ||
|
|
d621d9b03e | ||
|
|
b3f5e205a2 | ||
|
|
5482dedcbe | ||
|
|
7211a1038b | ||
|
|
7d5bd6cbd8 | ||
|
|
0777a00c88 | ||
|
|
020730bc9c | ||
|
|
e150e9a485 | ||
|
|
ee21346fb0 | ||
|
|
b985445ae9 | ||
|
|
7cbea2b907 | ||
|
|
7884051cad | ||
|
|
8c3b72cefc | ||
|
|
3e251c3c1c | ||
|
|
daeceb4633 | ||
|
|
a9b62d8149 | ||
|
|
1219adfab4 | ||
|
|
54428a87df | ||
|
|
88695149d2 | ||
|
|
f58a976745 | ||
|
|
c49033facb | ||
|
|
44782d4c42 | ||
|
|
70e62263d3 | ||
|
|
d2a4639007 | ||
|
|
4ead96be0c | ||
|
|
afd595fcc8 | ||
|
|
aaab114a3e | ||
|
|
c972b8687e | ||
|
|
08ef638950 | ||
|
|
ad82ac6a76 | ||
|
|
15f9b0c9a8 | ||
|
|
e3e9ca66cf | ||
|
|
2575d700f4 | ||
|
|
7a917cf93b | ||
|
|
c45db289ad | ||
|
|
9772679a2f | ||
|
|
473e5b075e | ||
|
|
0b7742f724 | ||
|
|
ac0215fab3 | ||
|
|
0e85441fa1 | ||
|
|
95c01cffb5 | ||
|
|
80b92b17b9 | ||
|
|
1d5ae4aa20 | ||
|
|
2d9e9e7347 | ||
|
|
178f5612a8 | ||
|
|
da220f353d | ||
|
|
405be9790a | ||
|
|
768dfcee86 | ||
|
|
3b8de2deac | ||
|
|
2d02567baa | ||
|
|
ad98116973 | ||
|
|
0f4593ac7c | ||
|
|
3b37b15ff0 | ||
|
|
8795794865 | ||
|
|
f31aa1f477 | ||
|
|
8f3911e881 | ||
|
|
26fa4c810d | ||
|
|
9598db0582 | ||
|
|
d147a3a469 | ||
|
|
5ec62b9d42 | ||
|
|
6d1c01cdb2 | ||
|
|
796fe0b4d1 | ||
|
|
ebf864b65d | ||
|
|
f966643e31 | ||
|
|
7a987e4347 | ||
|
|
abf2c1d96c | ||
|
|
d4113a99be | ||
|
|
afa9e73489 | ||
|
|
573d8cf727 | ||
|
|
8649384997 | ||
|
|
cdbcf5e2d1 | ||
|
|
286ccf26c7 | ||
|
|
cbf1ff2ad5 | ||
|
|
611f4bbb66 | ||
|
|
7023004046 | ||
|
|
01ca65e121 | ||
|
|
8f37dd7e9b | ||
|
|
5290847651 | ||
|
|
aef635d495 | ||
|
|
750a0e5934 | ||
|
|
9c75c86b95 | ||
|
|
affd251b10 | ||
|
|
a814d2bdb9 | ||
|
|
ad031a8e30 | ||
|
|
7a88fd96b9 | ||
|
|
f76814a03b | ||
|
|
b4062d8179 | ||
|
|
144ad84cac | ||
|
|
ad6ae689ed | ||
|
|
a219b2fb31 | ||
|
|
d1a78e672a | ||
|
|
470d7c38fc | ||
|
|
5136a16fc0 | ||
|
|
e204cdf74e | ||
|
|
fa180a1673 | ||
|
|
babf5f9821 | ||
|
|
e3df26ae07 | ||
|
|
e26987e563 | ||
|
|
16521b47b9 | ||
|
|
f37828e809 | ||
|
|
0cb889fea9 | ||
|
|
6643f72c35 | ||
|
|
210d423de6 | ||
|
|
f6e1086709 | ||
|
|
365db851e2 | ||
|
|
d3db778c7f | ||
|
|
4a1eb9472b | ||
|
|
623acf357b | ||
|
|
0824f7d315 | ||
|
|
23dc7925e2 | ||
|
|
7eeb3acbf0 | ||
|
|
17e1dc12d5 | ||
|
|
030cdc634f | ||
|
|
3b711c8792 | ||
|
|
955a44725c | ||
|
|
540fa7d601 | ||
|
|
d5a0efdb77 | ||
|
|
06c61055d4 | ||
|
|
70df0e0b33 | ||
|
|
3ba138e4cd | ||
|
|
27e1b7c8a3 | ||
|
|
57915ae6da | ||
|
|
bbe99d0685 | ||
|
|
b79913e592 | ||
|
|
2a08c1b2c0 | ||
|
|
139ba5fbf0 | ||
|
|
c3a39fd7a1 | ||
|
|
d5fa790ccc | ||
|
|
8f2a89d1a5 | ||
|
|
4302a0f048 | ||
|
|
f59f0af514 | ||
|
|
d109cd7c0d | ||
|
|
91f160806c | ||
|
|
232e06de6d | ||
|
|
aa8fa34a05 | ||
|
|
4ac92d0139 | ||
|
|
be8b1f7765 | ||
|
|
a581b69c2a | ||
|
|
d00d7150bb |
@@ -1 +0,0 @@
|
||||
# Tile Highlight Texture System
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(find:*)",
|
||||
"Bash(grep:*)",
|
||||
"Bash(dotnet build:*)",
|
||||
"Bash(git add:*)",
|
||||
"Bash(git commit:*)",
|
||||
"Bash(git push:*)",
|
||||
"Bash(python3:*)",
|
||||
"Bash(node:*)",
|
||||
"Bash(dotnet ef database update:*)",
|
||||
"Bash(dotnet ef migrations list:*)",
|
||||
"Bash(ls -la \"C:\\\\GameDev\\\\SOR\\\\Server\\\\src\\\\SOR.Content\\\\Handlers\"\" 2>/dev/null || echo \"Directory not found \")",
|
||||
"Bash(ls -la \"C:\\\\GameDev\\\\SOR\\\\Server\\\\src\\\\SOR.Cdn\"\" | grep -i \"cdnclient|httpclient \")",
|
||||
"Bash(dotnet ef migrations add:*)",
|
||||
"Bash(wc:*)"
|
||||
]
|
||||
}
|
||||
}
|
||||
Submodule .claude/worktrees/agent-ac72c5f4 deleted from c756b9cffa
@@ -3,6 +3,9 @@ name: Build & Push Web Client
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "Client/**"
|
||||
- ".gitea/workflows/build-push-client.yml"
|
||||
|
||||
env:
|
||||
REGISTRY: registry.aeternalisgames.com
|
||||
@@ -38,7 +41,7 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
SHA='${{ steps.tag.outputs.SHA }}'
|
||||
docker build -f Client/origin-client/Dockerfile.web \
|
||||
docker build --network host -f Client/origin-client/Dockerfile.web \
|
||||
-t "${{ env.REGISTRY }}/${{ env.PROJECT }}/sor-client:${SHA}" \
|
||||
-t "${{ env.REGISTRY }}/${{ env.PROJECT }}/sor-client:latest" \
|
||||
Client/origin-client
|
||||
|
||||
@@ -78,8 +78,16 @@ jobs:
|
||||
-t "${{ env.REGISTRY }}/${{ env.PROJECT }}/sor-admin:latest" \
|
||||
Server
|
||||
|
||||
docker build --network host -f Server/Dockerfile.website \
|
||||
-t "${{ env.REGISTRY }}/${{ env.PROJECT }}/sor-website:${SHA}" \
|
||||
-t "${{ env.REGISTRY }}/${{ env.PROJECT }}/sor-website:latest" \
|
||||
Server
|
||||
|
||||
docker push "${{ env.REGISTRY }}/${{ env.PROJECT }}/sor-server:${SHA}"
|
||||
docker push "${{ env.REGISTRY }}/${{ env.PROJECT }}/sor-server:latest"
|
||||
|
||||
docker push "${{ env.REGISTRY }}/${{ env.PROJECT }}/sor-admin:${SHA}"
|
||||
docker push "${{ env.REGISTRY }}/${{ env.PROJECT }}/sor-admin:latest"
|
||||
|
||||
docker push "${{ env.REGISTRY }}/${{ env.PROJECT }}/sor-website:${SHA}"
|
||||
docker push "${{ env.REGISTRY }}/${{ env.PROJECT }}/sor-website:latest"
|
||||
|
||||
@@ -6,3 +6,4 @@ deploy/secrets/*.yaml
|
||||
|
||||
# Local .NET SDK cache/sentinels
|
||||
.dotnet/
|
||||
.claude/
|
||||
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"godotTools.editorPath.godot4": "c:\\GameDev\\Godot_v4.5.1-stable_win64.exe"
|
||||
}
|
||||
@@ -0,0 +1,467 @@
|
||||
# Ability-Issues-Solutions
|
||||
|
||||
## Scope reviewed
|
||||
- `Server/src/SOR.Admin/Components/Pages/Cards/AbilityBuilder.razor` (UI + Help + compile/parse)
|
||||
- `Server/src/SOR.Game/Abilities/Models/*` (engine schema)
|
||||
- `Server/src/SOR.Game/Abilities/AbilitySystem.cs` (runtime behavior)
|
||||
|
||||
---
|
||||
|
||||
## Key gaps (what is missing / mismatched)
|
||||
|
||||
## 1) Trigger filter support is incomplete in Ability Builder
|
||||
|
||||
### Issue
|
||||
Many trigger models support `Filter` (or `UnitFilter`) fields, but Builder UI only exposes:
|
||||
- `OnDamageDealt.SourceFilter` (limited type-only selector)
|
||||
|
||||
Missing in Builder for trigger definitions:
|
||||
- `OnUnitMove.Filter`
|
||||
- `OnUnitAttack.Filter`
|
||||
- `OnUnitAbilityActivated.Filter`
|
||||
- `OnUnitMPSpent.Filter`
|
||||
- `OnDamagePrevented.Filter`
|
||||
- `OnHealed.Filter`
|
||||
- `BeforeUnitDeath.Filter`
|
||||
- `BeforeDamageApplied.Filter`
|
||||
- `OnUnitEnterBattlefield.Filter`
|
||||
- `OnUnitLeaveBattlefield.Filter`
|
||||
- `OnUnitDeath.Filter`
|
||||
- `OnUnitSentToDiscard.Filter`
|
||||
- `OnSpiritSacrificed.Filter`
|
||||
- `OnTokenSummoned.Filter`
|
||||
- `OnStatModified.Filter`
|
||||
- `OnAbilityAdded.Filter`
|
||||
- `OnAbilityRemoved.Filter`
|
||||
- `OnGenusChanged.Filter`
|
||||
- `OnUnitOccupyRuin.Filter`
|
||||
- `OnTileAffinityChanged.Filter`
|
||||
- `OnCardDrawn.Filter`
|
||||
- `OnCardDiscarded.Filter`
|
||||
- `OnCardReturnedToHand.Filter`
|
||||
- `OnCardReturnedToDeck.Filter`
|
||||
- `OnCardsRevealed.Filter`
|
||||
- `OnTargetedByAbility.Filter`
|
||||
- `OnEffectApplied.Filter`
|
||||
- `OnEnterAuraRange.Filter`
|
||||
- `OnLeaveAuraRange.Filter`
|
||||
|
||||
### Solution
|
||||
- Add a reusable Trigger Filter editor block in `RenderTriggerFields(...)`.
|
||||
- Support at least one fully-parameterized filter object initially, then expand to filter arrays.
|
||||
- Parse/compile these fields symmetrically.
|
||||
|
||||
---
|
||||
|
||||
## 2) Action target filter editor is type-only (no parameters)
|
||||
|
||||
### Issue
|
||||
Action target filtering currently stores only first filter `$type`:
|
||||
- Parse: first filter only
|
||||
- Compile: `{ "$type": action.FilterType }`
|
||||
|
||||
This drops required filter args for many filters:
|
||||
- `WithinRange(min,max)`, `DamageRange(min,max)`, `CardSPCostRange(min,max)`
|
||||
- `HasFlag(flag)`, `TierIs(tier)`
|
||||
- `TileIsOccupied(unitType)`
|
||||
- `TileIsAdjacentToUnit(ownership, unitFilter)`
|
||||
- etc.
|
||||
|
||||
### Solution
|
||||
- Replace `FilterType` string with `FilterDraft[]` on action target.
|
||||
- Provide per-filter field editors (same pattern as effect/condition editors).
|
||||
- Compile full filter object(s), not type-only placeholders.
|
||||
|
||||
---
|
||||
|
||||
## 3) Affinity expressions are narrowed to fixed only in builder for effects
|
||||
|
||||
### Issue
|
||||
Engine supports `AffinityExpr` with:
|
||||
- `Fixed`
|
||||
- `Ref` (dynamic reference)
|
||||
|
||||
Builder compiles affinity effects as fixed only:
|
||||
- `SetAffinity`
|
||||
- `SetBaseAffinity1`
|
||||
- `SetBaseAffinity2`
|
||||
- `PushAffinity`
|
||||
- `PushFinalAffinity`
|
||||
|
||||
So dynamic affinity references (e.g. `Action1.Target.Affinity`, `Self.Owner.ArchSpirit.Affinity`) cannot be authored in Builder.
|
||||
|
||||
### Solution
|
||||
- Add AffinityExpr UI equivalent to ValueExpr:
|
||||
- mode: Fixed / Ref
|
||||
- ref picker options (self, event data where valid, prior action target refs)
|
||||
- Compile as `{ "Fixed": ... }` or `{ "Ref": ... }`.
|
||||
|
||||
---
|
||||
|
||||
## 4) `ReturnToDeck` / `PlaceOnDeck` missing `random` option
|
||||
|
||||
### Issue
|
||||
Model supports `Position` values including `random`.
|
||||
Builder options only expose:
|
||||
- `Top`, `Bottom`
|
||||
|
||||
### Solution
|
||||
- Add `Random` to `PositionValues`.
|
||||
- Ensure compile uses canonical casing expected by engine (`top|bottom|random` normalization).
|
||||
|
||||
---
|
||||
|
||||
## 5) `ChannelCard` effect missing `CostMultiplier` in Builder
|
||||
|
||||
### Issue
|
||||
Model:
|
||||
- `ChannelCardEffect { PayCost, CostMultiplier }`
|
||||
|
||||
Builder currently only exposes/compiles `PayCost`.
|
||||
|
||||
### Solution
|
||||
- Add optional numeric field for `CostMultiplier`.
|
||||
- Parse/compile round-trip.
|
||||
|
||||
---
|
||||
|
||||
## 6) `RepositionUnit` missing destination tile filters in Builder
|
||||
|
||||
### Issue
|
||||
Model:
|
||||
- `RepositionUnitEffect` supports `DestinationTileFilters`.
|
||||
|
||||
Builder exposes:
|
||||
- tiles count / adjacency options / relative target refs
|
||||
|
||||
But cannot author `DestinationTileFilters`.
|
||||
|
||||
### Solution
|
||||
- Add tile filter editor subset for `DestinationTileFilters`.
|
||||
- Parse/compile full object(s).
|
||||
|
||||
---
|
||||
|
||||
## 7) `ReturnToBattlefield` missing `TileFilter` authoring in Builder
|
||||
|
||||
### Issue
|
||||
Model:
|
||||
- `ReturnToBattlefieldEffect { Controller?, TileFilter? }`
|
||||
|
||||
Builder exposes only `Controller`.
|
||||
|
||||
### Solution
|
||||
- Add optional tile filter editor for `TileFilter`.
|
||||
- Parse/compile support.
|
||||
|
||||
---
|
||||
|
||||
## 8) `SearchDeck.ThenAction` cannot be authored in Builder
|
||||
|
||||
### Issue
|
||||
Model:
|
||||
- `SearchDeckEffect { Filters?, Count, ThenAction? }`
|
||||
|
||||
Builder supports `N` only for SearchDeck and no editor for `ThenAction`.
|
||||
|
||||
### Solution
|
||||
- Add nested Action editor for `ThenAction` (single action draft).
|
||||
- Parse/compile including `SearchResult`-style targeting notes in help.
|
||||
|
||||
---
|
||||
|
||||
## 9) Trigger help/documentation in Builder omits advanced trigger filter capabilities
|
||||
|
||||
### Issue
|
||||
Help panel lists trigger names and ownership concepts, but does not document:
|
||||
- trigger-level filter support breadth
|
||||
- which triggers accept amount/stat/cause/causedBy/filter combos
|
||||
- serialization caveats
|
||||
|
||||
### Solution
|
||||
- Add a “Trigger Field Matrix” table in Help:
|
||||
- Trigger name
|
||||
- Supported properties
|
||||
- Whether filter is supported
|
||||
- Include examples for: `OnUnitSentToDiscard.CausedBy`, `OnDamageDealt.SourceFilter` with params.
|
||||
|
||||
---
|
||||
|
||||
## 10) Potential semantic mismatch to verify: `StatTarget` includes `Base` in Builder
|
||||
|
||||
### Issue
|
||||
Builder `StatTargetValues = ["Current", "Base", "Max"]`.
|
||||
Engine model `StatTarget` enum appears to define only `Current`, `Max`.
|
||||
|
||||
If true at runtime, selecting `Base` in UI can serialize invalid enum value.
|
||||
|
||||
### Solution
|
||||
- Verify enum/runtime parser behavior.
|
||||
- If model truly lacks Base, remove Base from Builder options.
|
||||
- If Base is intended, add it to model + runtime handling.
|
||||
|
||||
---
|
||||
|
||||
## 11) Ruin trigger UX: builder does not warn about source-self retrigger hazard
|
||||
|
||||
### Issue
|
||||
From gameplay behavior review, `OnRuinActivation` may unintentionally retrigger additional abilities if source trigger handling is not constrained.
|
||||
Builder help has no warning/pattern guidance for safe Ruin trigger authoring.
|
||||
|
||||
### Solution
|
||||
- Add Help note under Ruin triggers:
|
||||
- recommend `TriggerLimitPerTurn`
|
||||
- recommend ownership/condition patterns to prevent accidental cascade
|
||||
- After engine fix lands, document exact semantics in help.
|
||||
|
||||
---
|
||||
|
||||
## Recommended implementation order
|
||||
1. **High impact correctness**: #1, #2, #3
|
||||
2. **Model parity**: #5, #6, #7, #8
|
||||
3. **Low-risk UX/docs**: #4, #9, #11
|
||||
4. **Schema consistency check**: #10
|
||||
|
||||
---
|
||||
|
||||
## Acceptance criteria for completion
|
||||
- Builder can round-trip (parse + compile) all currently supported model fields without silent data loss.
|
||||
- No filter parameters are dropped when saving edited abilities.
|
||||
- Help panel accurately reflects trigger/effect/filter capabilities present in runtime.
|
||||
- Existing authored cards remain loadable and unchanged unless explicitly edited.
|
||||
|
||||
---
|
||||
|
||||
## 12) Product-direction recap (New Card Flow + Ability Builder v2)
|
||||
|
||||
> Source: Jason recap (2026-04-16). Keep this as implementation intent unless superseded.
|
||||
|
||||
### Goals
|
||||
- Mobile-friendly authoring flow first; desktop can add richer visual UX.
|
||||
- Support two authoring modes:
|
||||
1) visual node/bubble drag-drop + connections,
|
||||
2) plain-English prompt mapped to canonical ability JSON.
|
||||
- Final persisted result is a deterministic JSON block consumed by `AbilitySystem`.
|
||||
- Prioritize robustness and clarity over minimal feature set (high ceiling, even if some complexity is rarely used).
|
||||
|
||||
### New Card flow (target fields)
|
||||
- Core: `Name`, `CardType`, `Affinity`, `Description`, art preview metadata, `SPCost`, `STCost`.
|
||||
- `ArchSpirit` specifics:
|
||||
- `MinChannelRange`, `MaxChannelRange`, `Tier`.
|
||||
- If `Tier > 1`: `PreviousTierCardId` (search/select prior tier card).
|
||||
- `Spirit`/`ArchSpirit` combat/movement:
|
||||
- `AttackType` (initially melee/ranged, extensible), range fields when ranged.
|
||||
- stats: damage/health/defense/movement type/points.
|
||||
- `GenusTags` with autocomplete + create-new.
|
||||
- bool flags (attack/defend/be attacked/be blocked/move/obstruct/use ability/LOS behaviors).
|
||||
- Additional type gates:
|
||||
- Spirit can include `CanBeSacrificed`.
|
||||
- Repentance/Instinct LOS requirements as applicable.
|
||||
|
||||
### Ability type eligibility by CardType
|
||||
- `Spirit | ArchSpirit | SpiritToken | Ruin` => `Active`, `Triggered`, `Aura`, `Passive`.
|
||||
- `Instinct | Repentance` => `Active`, `Triggered`.
|
||||
|
||||
### Ability common contract (all types)
|
||||
- `Name` (for Instinct/Repentance default to card name; others author-defined).
|
||||
- `Description`.
|
||||
- `ActivationConditions` with nested logical groups (`AND`/`OR`/`XOR`) and N clauses.
|
||||
- Per-ability animation/sound assignment hooks.
|
||||
|
||||
### Passive / Aura semantics (authoritative distinction)
|
||||
- **Passive**
|
||||
- Always active while source is on battlefield.
|
||||
- Applies to all valid targets in scope.
|
||||
- Re-validated/applied each turn.
|
||||
- Removal behavior configurable when source leaves play.
|
||||
- **Aura**
|
||||
- Passive-like but range-scoped (`AuraMinRange`, `AuraMaxRange`).
|
||||
- Must support `OnEnterAuraRange` and `OnLeaveAuraRange` checks.
|
||||
- On-leave policy configurable: remove immediately / persist / linger duration.
|
||||
|
||||
### Triggered ability direction
|
||||
- Broad trigger-event map with per-event ownership/source/unit/property filters.
|
||||
- Trigger limit policy required:
|
||||
- unlimited
|
||||
- N per turn
|
||||
- N per game
|
||||
- Include dedicated support for aura range boundary events (`OnEnterAuraRange`, `OnLeaveAuraRange`).
|
||||
- **Trigger source-zone support**: triggers must be authorable to function while source card is in:
|
||||
- `Battlefield`
|
||||
- `Hand`
|
||||
- `Discard`
|
||||
- `Deck`
|
||||
(with explicit zone gating in trigger definition).
|
||||
|
||||
### Conditions and logic system direction
|
||||
- Use a reusable expression/group model for:
|
||||
- Activation conditions
|
||||
- Action conditions
|
||||
- Target property constraints
|
||||
- Cost option constraints
|
||||
- Group composition supports `AND`/`OR`/`XOR` recursively.
|
||||
- Comparators include `>`, `>=`, `==`, `!=`, `<=`, `<`.
|
||||
|
||||
### Cost system direction
|
||||
- Active abilities can be free or have one/more cost groups.
|
||||
- Cost groups support alternatives and logic composition (AND/OR/XOR).
|
||||
- Special UI/handler needs for interactive costs:
|
||||
- `DiscardFromHand`: random / self pick / enemy visible pick / enemy random pick.
|
||||
- `SendSpiritFromBattlefieldToDiscard` / `DealDamageToOwnSpirit`: random / self pick / enemy pick.
|
||||
|
||||
### Action system direction
|
||||
- Each ability has N actions.
|
||||
- Action groups can be composed with AND/OR/XOR; chooser can vary (self/opponent/random).
|
||||
- Each action defines:
|
||||
- scope (hand/deck/discard/battlefield/player and combinations),
|
||||
- target type,
|
||||
- target chooser,
|
||||
- count (N/all),
|
||||
- filters (typed + parameterized, not type-only),
|
||||
- optional action conditions,
|
||||
- one or more effects with chaining.
|
||||
- Variable effect amounts may be literal or sourced from target/source/expression refs.
|
||||
|
||||
### UI architecture implications
|
||||
- Reusable editors for:
|
||||
- logical groups,
|
||||
- typed filters + params,
|
||||
- ownership/location/range selectors,
|
||||
- effect payloads by scope/target.
|
||||
- Mobile UX should prefer progressive disclosure and compact cards/chips over large static forms.
|
||||
- Desktop UX can add graph view (nodes/edges) mapping 1:1 to canonical JSON.
|
||||
|
||||
### Canonicalization requirement
|
||||
- All authoring surfaces (form, graph, plain-English assistant) must map to the same JSON schema.
|
||||
- Parser/renderer must round-trip without semantic loss.
|
||||
- Prevent duplicate divergent representations between UI modes.
|
||||
|
||||
### Cleanup task noted by Jason
|
||||
- De-duplicate overlapping items in this document and extract reusable structure blocks (shared condition/filter/action schemas).
|
||||
|
||||
---
|
||||
|
||||
## 13) Normalized reusable schema blocks + Trigger Event Matrix (dedupe pass)
|
||||
|
||||
### A. Reusable blocks (single source of truth)
|
||||
|
||||
#### A1) `LogicGroup<T>`
|
||||
- `op`: `AND | OR | XOR`
|
||||
- `items`: `(T | LogicGroup<T>)[]`
|
||||
|
||||
Use for:
|
||||
- Activation conditions
|
||||
- Action conditions
|
||||
- Cost option groups
|
||||
- Target/property filter groups
|
||||
|
||||
#### A2) `Comparator`
|
||||
- `> | >= | == | != | <= | <`
|
||||
|
||||
#### A3) `ValueExpr`
|
||||
- `fixed` (literal)
|
||||
- `ref` (path/expression reference)
|
||||
|
||||
#### A4) `OwnershipScope`
|
||||
- `Self | Ally | Opponent | Any`
|
||||
|
||||
#### A5) `LocationScope`
|
||||
- `Hand | Deck | Discard | Battlefield | Player`
|
||||
- Composite scopes supported via explicit list.
|
||||
|
||||
#### A6) `RangeSpec`
|
||||
- `min`
|
||||
- `max`
|
||||
- optional LOS + shape flags (`requiresLos`, `linearOnly`, extensible)
|
||||
|
||||
#### A7) `FilterClause`
|
||||
- `field`
|
||||
- `comparator`
|
||||
- `value` (`ValueExpr`)
|
||||
|
||||
#### A8) `TargetSelector`
|
||||
- `scope`
|
||||
- `targetType`
|
||||
- `chooser` (`Self | Ally | Opponent | Random`)
|
||||
- `count` (`N | All`)
|
||||
- `filters` (`LogicGroup<FilterClause | TypedFilter>`)
|
||||
|
||||
#### A9) `TypedFilter`
|
||||
- `type`
|
||||
- `params` (strongly typed by filter kind; never type-only serialization)
|
||||
|
||||
#### A10) `DurationPolicy`
|
||||
- `instant`
|
||||
- `untilEndOfTurn`
|
||||
- `forTurns(n)`
|
||||
- `whileSourceInPlay`
|
||||
- `untilCondition`
|
||||
|
||||
#### A11) `LeavePolicy` (Aura/continuous cleanup)
|
||||
- `removeImmediately`
|
||||
- `persist`
|
||||
- `linger(duration)`
|
||||
|
||||
### B. Trigger Event Matrix (normalized)
|
||||
|
||||
> Intention: collapse large event list into consistent event families + shared payload contract.
|
||||
|
||||
#### B1) Turn / lifecycle
|
||||
- `OnTurnStart`, `OnTurnEnd`, `OnAscend`, `OnTransition`, `OnChanneled`
|
||||
- Common filters: actor ownership, source card/unit, unit property filters
|
||||
|
||||
#### B2) Unit combat / movement / ability
|
||||
- `OnUnitMove`, `OnUnitAttack`, `OnUnitAbilityActivated`, `OnUnitMPSpent`
|
||||
- `OnDamageDealt`, `OnDamagePrevented`, `OnHealed`, `BeforeDamageApplied`, `BeforeUnitDeath`
|
||||
- Common filters: actor ownership, unit filter, amount comparator
|
||||
|
||||
#### B3) Battlefield presence / status
|
||||
- `OnUnitEnterBattlefield`, `OnUnitLeaveBattlefield`, `OnUnitDeath`, `OnUnitSentToDiscard`
|
||||
- `OnSpiritSacrificed`, `OnTokenSummoned`, `OnStatModified`, `OnGenusChanged`
|
||||
- Common filters: ownership + unit/property filter
|
||||
|
||||
#### B4) Ability mutation / targeting
|
||||
- `OnAbilityAdded`, `OnAbilityRemoved`, `OnTargetedByAbility`, `OnEffectApplied`
|
||||
- Common filters: source ownership, affected-unit filter, ability/effect metadata filters
|
||||
|
||||
#### B5) Ruin / occupancy
|
||||
- `OnRuinActivation`, `OnUnitOccupyRuin`
|
||||
- Common filters: ruin ownership/state, occupant filter
|
||||
|
||||
#### B6) Tile / affinity
|
||||
- `OnTileAffinityChanged`
|
||||
- Common filters: tile ownership zone, tile property filter, nearby occupancy filters
|
||||
|
||||
#### B7) Resource / hand economy
|
||||
- `OnSPGained`, `OnSPSpent`, `OnSTGained`, `OnSTSpent`
|
||||
- Common filters: player ownership, amount comparator
|
||||
|
||||
#### B8) Card movement / visibility
|
||||
- `OnCardDrawn`, `OnCardDiscarded`, `OnCardReturnedToHand`, `OnCardReturnedToDeck`, `OnDeckShuffled`, `OnCardsRevealed`
|
||||
- Common filters: card ownership/type/affinity/cost + amount/count comparators
|
||||
|
||||
#### B9) Aura boundary
|
||||
- `OnEnterAuraRange`, `OnLeaveAuraRange`
|
||||
- Common filters: aura source, entering/leaving unit filter, ownership
|
||||
|
||||
### C. Unified trigger payload contract (engine + builder)
|
||||
- `eventType`
|
||||
- `actor` (who caused event)
|
||||
- `subject` (primary unit/card/tile/player affected)
|
||||
- `source` (ability/card/effect source)
|
||||
- `sourceZone` (`Battlefield | Hand | Discard | Deck`)
|
||||
- `amount?` (numeric payload for spend/damage/heal/etc.)
|
||||
- `context` (event-specific extras, e.g., occupant, causedBy, stat, affinity)
|
||||
- `turnIndex`
|
||||
- `timestamp`
|
||||
|
||||
This payload should be the basis for:
|
||||
- Trigger filter authoring
|
||||
- Plain-English prompt mapping
|
||||
- Debug/audit logs in admin/testing tools
|
||||
|
||||
### D. Near-term implementation split
|
||||
1. Add shared DSL models in admin builder drafts (`LogicGroup`, `TypedFilter`, `TargetSelector`, `DurationPolicy`).
|
||||
2. Refactor trigger editors to event-family templates instead of per-event bespoke forms.
|
||||
3. Add JSON canonicalization tests to guarantee graph/form/English mode parity.
|
||||
4. Add migration shim for legacy type-only filters.
|
||||
+1269
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,461 @@
|
||||
# AbilitySystem-R2-Shard
|
||||
|
||||
## Purpose
|
||||
Implementation plan for a full R2 revamp of:
|
||||
1) Ability engine/schema,
|
||||
2) Admin New Card Flow + Ability Builder,
|
||||
3) Runtime client prompt/response loop,
|
||||
4) Authoring UX in both drag/drop graph mode and plain-English mode,
|
||||
while preserving deterministic canonical Ability JSON consumed by `AbilitySystem`.
|
||||
|
||||
---
|
||||
|
||||
## 1) Product outcomes (definition of done)
|
||||
|
||||
- A designer can create any supported card + ability without hand-editing JSON.
|
||||
- Mobile flow is fully usable; desktop adds graph power tools.
|
||||
- Graph mode, form mode, and English mode all map to exactly the same canonical JSON.
|
||||
- Runtime can execute abilities deterministically with complete audit/debug traces.
|
||||
- Trigger/filter/condition/action systems support high complexity without schema drift.
|
||||
- Interactive effects/costs can request player input via explicit prompt contracts.
|
||||
|
||||
---
|
||||
|
||||
## 2) Architecture overview
|
||||
|
||||
## 2.1 Core principle: one canonical representation
|
||||
Use a single canonical `AbilityDefinitionR2` JSON contract.
|
||||
|
||||
All authoring surfaces are adapters:
|
||||
- **Form UI** ↔ Canonical JSON
|
||||
- **Graph UI** ↔ Canonical JSON
|
||||
- **English Draft** → Parsed Draft AST → Canonical JSON
|
||||
|
||||
No alternate persisted format.
|
||||
|
||||
## 2.2 Layers
|
||||
- **Engine layer** (`SOR.Game`)
|
||||
- Schema models
|
||||
- Trigger evaluation
|
||||
- Condition evaluation
|
||||
- Action/effect execution
|
||||
- Prompt orchestration for interactive steps
|
||||
- **Admin layer** (`SOR.Admin`)
|
||||
- New Card Flow
|
||||
- Ability Builder (form + graph + English)
|
||||
- Validation + simulation preview
|
||||
- **Client/runtime layer**
|
||||
- Prompt renderer and chooser UX
|
||||
- Prompt response payloads back to server
|
||||
- Latency-safe retries / idempotency
|
||||
|
||||
---
|
||||
|
||||
## 3) Canonical schema plan (R2)
|
||||
|
||||
## 3.1 Card definition (authoring-relevant)
|
||||
- `id`, `name`, `cardType`, `affinity`, `description`
|
||||
- art preview metadata
|
||||
- `spCost`, `stCost`
|
||||
- type-specific sections:
|
||||
- ArchSpirit: `tier`, `minChannelRange`, `maxChannelRange`, `previousTierCardId`
|
||||
- Spirit/ArchSpirit: attack/move/stats/tags/bools
|
||||
- type gated ability allowances
|
||||
|
||||
## 3.2 Ability definition root
|
||||
- `id`, `name`, `description`, `type` (`Active|Triggered|Aura|Passive`)
|
||||
- `activationConditions: LogicGroup<ConditionClause>`
|
||||
- `trigger?` (for Triggered/Aura boundary events)
|
||||
- `aura?` (for Aura)
|
||||
- `passive?` (for Passive)
|
||||
- `cost?` (main ability activation cost)
|
||||
- `actions: ActionGroup`
|
||||
- `limits` (`perTurn`, `perGame`, `cooldowns` if needed)
|
||||
- metadata: animation/sound hooks
|
||||
|
||||
## 3.3 Shared primitives
|
||||
- `LogicGroup<T>` with `AND|OR|XOR`
|
||||
- `Comparator` (`> >= == != <= <`)
|
||||
- `ValueExpr` (`fixed|ref`)
|
||||
- `TypedFilter { type, params }`
|
||||
- `TargetSelector`
|
||||
- `DurationPolicy`
|
||||
- `SourceZoneGate` (`Battlefield|Hand|Discard|Deck`)
|
||||
|
||||
## 3.4 Trigger contract
|
||||
- `eventType`
|
||||
- `sourceZoneGate[]` (explicitly supports in-hand/discard/deck triggers)
|
||||
- ownership/source/subject filters
|
||||
- optional amount/stat/cause/causedBy filters
|
||||
- limit policy (`unlimited|n/turn|n/game`)
|
||||
|
||||
## 3.5 Passive / Aura contract
|
||||
- Passive:
|
||||
- continuous application while source valid
|
||||
- recheck cadence (`turnStart|turnEnd|both|stateChange`)
|
||||
- `removeOnSourceLeave` policy
|
||||
- Aura:
|
||||
- `minRange`, `maxRange`
|
||||
- enter/leave trigger hooks
|
||||
- `leavePolicy` (`removeImmediately|persist|linger` + duration)
|
||||
|
||||
---
|
||||
|
||||
## 4) Trigger/event system implementation
|
||||
|
||||
## 4.1 Event bus normalization
|
||||
Implement a normalized internal event envelope:
|
||||
- `eventId`, `eventType`, `turnIndex`, `timestamp`
|
||||
- `actor`, `subject`, `source`, `sourceZone`
|
||||
- `amount?`
|
||||
- `context` map for event-specific extras
|
||||
|
||||
## 4.2 Event families
|
||||
Implement by family templates to reduce bespoke code:
|
||||
- Turn/lifecycle
|
||||
- Unit combat/movement
|
||||
- Battlefield state/status
|
||||
- Ability mutation/targeting
|
||||
- Ruin/occupancy
|
||||
- Tile/affinity
|
||||
- Resource economy
|
||||
- Card movement/visibility
|
||||
- Aura boundary
|
||||
|
||||
## 4.3 Safety controls
|
||||
- Retrigger/cascade guardrails (esp. Ruin/aura loops)
|
||||
- per-ability/per-source trigger counters
|
||||
- deterministic ordering and tie-breaks
|
||||
|
||||
---
|
||||
|
||||
## 5) Conditions, targeting, and filters
|
||||
|
||||
## 5.1 Conditions engine
|
||||
- Recursive logical groups
|
||||
- short-circuit evaluation
|
||||
- debug trace of each clause result
|
||||
|
||||
## 5.2 Targeting engine
|
||||
- Resolve scope → candidate set → filter pass → chooser policy → count
|
||||
- deterministic randomization via seedable RNG
|
||||
|
||||
## 5.3 Filter strategy
|
||||
- Replace type-only filter serialization with typed parameterized filters.
|
||||
- Registry-based filter factory:
|
||||
- validate params
|
||||
- compile to runtime predicate
|
||||
- expose metadata to UI editors
|
||||
|
||||
---
|
||||
|
||||
## 6) Action/effect execution pipeline
|
||||
|
||||
## 6.1 Action group execution
|
||||
- Support AND/OR/XOR action groups.
|
||||
- Choice authority configurable (`self|opponent|random|system`).
|
||||
|
||||
## 6.2 Effect resolution
|
||||
- Every effect receives:
|
||||
- `sourceRef`
|
||||
- resolved target set
|
||||
- evaluation context refs
|
||||
- effect amount can be literal or computed from refs.
|
||||
|
||||
## 6.3 Duration + cleanup
|
||||
- Central duration scheduler for temporary effects.
|
||||
- source-leave cleanup policies for passive/aura effects.
|
||||
|
||||
---
|
||||
|
||||
## 7) Interactive prompts (client orchestration)
|
||||
|
||||
## 7.1 When server must prompt client
|
||||
Any runtime branch requiring human input or hidden-zone choice emits a prompt.
|
||||
|
||||
Primary prompt categories:
|
||||
1. **Cost selection** (choose one cost branch)
|
||||
2. **Card selection from hidden/private zone**
|
||||
3. **Target selection when multiple legal options**
|
||||
4. **Order/placement choices** (top/bottom/random/manual order)
|
||||
5. **Optional effects / choose-one effects**
|
||||
6. **Opponent-mediated choices** (enemy chooses)
|
||||
|
||||
## 7.2 Prompt envelope (server → client)
|
||||
```json
|
||||
{
|
||||
"promptId": "uuid",
|
||||
"abilityInstanceId": "uuid",
|
||||
"actionNodeId": "a3",
|
||||
"promptType": "ChooseCostBranch",
|
||||
"actorPlayerId": "p1",
|
||||
"authority": "Self|Opponent",
|
||||
"expiresAt": "2026-...Z",
|
||||
"uiHints": { "title": "Pay cost", "min": 1, "max": 1 },
|
||||
"options": [
|
||||
{ "optionId": "opt1", "label": "Pay 2 SP + discard 3", "metadata": {...} },
|
||||
{ "optionId": "opt2", "label": "Pay 6 SP + 1 ST", "metadata": {...} }
|
||||
],
|
||||
"legalTargets": [...],
|
||||
"gameStateVersion": 1234
|
||||
}
|
||||
```
|
||||
|
||||
## 7.3 Prompt response (client → server)
|
||||
```json
|
||||
{
|
||||
"promptId": "uuid",
|
||||
"playerId": "p1",
|
||||
"selectedOptionIds": ["opt1"],
|
||||
"selectedTargetIds": ["card-7", "card-9", "card-12"],
|
||||
"ordering": ["card-12", "card-7", "card-9"],
|
||||
"clientContext": {
|
||||
"uiVersion": "x.y.z",
|
||||
"latencyMs": 88
|
||||
},
|
||||
"gameStateVersion": 1234
|
||||
}
|
||||
```
|
||||
|
||||
## 7.4 Idempotency/replay rules
|
||||
- Prompt responses are idempotent by `promptId` + submission hash.
|
||||
- Reject stale `gameStateVersion` with retry message.
|
||||
- Server returns normalized adjudication event for client reconciliation.
|
||||
|
||||
## 7.5 Prompt-specific details required
|
||||
|
||||
### A) `DiscardFromHand`
|
||||
Client must send:
|
||||
- chosen cards (if self-pick / enemy-visible-pick)
|
||||
- no cards needed for random modes (server rolls)
|
||||
- if enemy picks, include picker player id
|
||||
|
||||
### B) `SendSpiritFromBattlefieldToDiscard` / `DealDamageToOwnSpirit`
|
||||
Client must send (when non-random):
|
||||
- chosen unit ids
|
||||
- confirmation when effect is self-harm/sacrifice if required by UX rules
|
||||
|
||||
### C) Choose Action Branch (AND/OR/XOR groups with chooser)
|
||||
Client must send:
|
||||
- selected branch ids in execution order
|
||||
- optional target choices per branch if immediate binding is used
|
||||
|
||||
### D) Multi-target constrained prompts
|
||||
Client must send:
|
||||
- exact chosen targets count in allowed min/max
|
||||
- optional assignment map if effect needs target-role mapping
|
||||
|
||||
---
|
||||
|
||||
## 8) Admin UI implementation (mobile-first + desktop graph)
|
||||
|
||||
## 8.1 New Card Flow (wizard)
|
||||
Steps:
|
||||
1) Identity/core fields
|
||||
2) Type-specific fields
|
||||
3) Combat/stats/tags/bools
|
||||
4) Ability summary and add/edit
|
||||
5) Validation + preview + save
|
||||
|
||||
Mobile: stepper/cards, collapsed advanced sections, sticky validation summary.
|
||||
|
||||
## 8.2 Ability Builder Form mode
|
||||
Sections:
|
||||
- ability metadata
|
||||
- type-specific (active/triggered/aura/passive)
|
||||
- activation conditions (logic group editor)
|
||||
- costs (branch/group editor)
|
||||
- actions (group + per-action target/filter/effects)
|
||||
- animation/sfx mapping
|
||||
|
||||
## 8.3 Graph mode (drag/drop bubbles)
|
||||
Node types:
|
||||
- Trigger node
|
||||
- Condition group node
|
||||
- Cost group node
|
||||
- Target selector node
|
||||
- Action group node
|
||||
- Effect node
|
||||
- Duration/policy node
|
||||
|
||||
Edges define execution/decision flow; graph compiles into same canonical JSON.
|
||||
|
||||
### Graph constraints
|
||||
- enforce acyclic execution graph where required
|
||||
- typed edge compatibility (cannot connect invalid node ports)
|
||||
- show live JSON preview pane
|
||||
|
||||
## 8.4 English mode (plain-English authoring)
|
||||
Pipeline:
|
||||
1) user prompt text
|
||||
2) parser/LLM generates Draft AST + confidence/warnings
|
||||
3) deterministic normalizer maps Draft AST to canonical JSON
|
||||
4) validation pass + unresolved-slot checklist
|
||||
5) user confirms/fixes in form/graph
|
||||
|
||||
Must never save raw LLM output directly; only canonicalized validated JSON.
|
||||
|
||||
---
|
||||
|
||||
## 9) Validation, testing, and tooling
|
||||
|
||||
## 9.1 Validation layers
|
||||
- schema validation (shape/types)
|
||||
- semantic validation (gates/ranges/zone legality)
|
||||
- runtime validation (can execute deterministically)
|
||||
|
||||
## 9.2 Test matrix
|
||||
- round-trip tests: form ↔ json, graph ↔ json, english ↔ json
|
||||
- trigger correctness tests per family
|
||||
- prompt contract tests with mock clients
|
||||
- property-based tests for logic groups and filter combinations
|
||||
- migration tests for legacy abilities
|
||||
|
||||
## 9.3 Dev tooling
|
||||
- Ability simulator panel in admin:
|
||||
- inject game state snapshot
|
||||
- fire test events
|
||||
- show trigger/condition/effect trace
|
||||
- JSON diff viewer pre-save
|
||||
|
||||
---
|
||||
|
||||
## 10) Migration and rollout
|
||||
|
||||
## 10.1 Backward compatibility
|
||||
- Keep R1 parser alive behind adapter.
|
||||
- Introduce R1→R2 migration transformer.
|
||||
- Flag migrated fields that were previously lossy (e.g., filter params missing).
|
||||
|
||||
## 10.2 Feature flags
|
||||
- `AbilityR2Schema`
|
||||
- `AbilityBuilderGraphMode`
|
||||
- `AbilityBuilderEnglishMode`
|
||||
- `RuntimeInteractivePromptV2`
|
||||
|
||||
## 10.3 Rollout phases
|
||||
1) Schema + engine primitives
|
||||
2) Admin form parity (no data loss)
|
||||
3) Prompt protocol + client handlers
|
||||
4) Graph mode
|
||||
5) English mode
|
||||
6) Migrate existing cards and enable by default
|
||||
|
||||
---
|
||||
|
||||
## 11) Detailed backlog (suggested epics)
|
||||
|
||||
## Epic A — Schema/Foundation
|
||||
- Define `AbilityDefinitionR2` and shared primitives
|
||||
- Implement canonical serializer/deserializer
|
||||
- Implement migration adapter R1→R2
|
||||
|
||||
## Epic B — Trigger/Condition Runtime
|
||||
- Event envelope normalization
|
||||
- Trigger family evaluators
|
||||
- Source-zone gate support (Battlefield/Hand/Discard/Deck)
|
||||
- Trigger limits/counters
|
||||
|
||||
## Epic C — Target/Filter Runtime
|
||||
- Typed filter registry
|
||||
- Location/ownership/range resolver
|
||||
- deterministic random selector
|
||||
|
||||
## Epic D — Actions/Effects Runtime
|
||||
- Action group execution logic
|
||||
- Effect executor parity pass
|
||||
- duration/cleanup manager
|
||||
|
||||
## Epic E — Prompt Protocol + Client
|
||||
- Prompt envelope API
|
||||
- Client prompt rendering for each category
|
||||
- response validation/idempotency
|
||||
|
||||
## Epic F — Admin Builder V2 Form
|
||||
- New card wizard updates
|
||||
- ability form with reusable editors
|
||||
- validation + simulator panel
|
||||
|
||||
## Epic G — Graph Builder
|
||||
- node palette + edge validator
|
||||
- graph↔json compiler/decompiler
|
||||
- mobile fallback/read-only mini-map
|
||||
|
||||
## Epic H — English Authoring
|
||||
- drafting parser
|
||||
- canonicalizer
|
||||
- ambiguity resolver UI
|
||||
|
||||
## Epic I — Docs/QA/Operations
|
||||
- author docs + trigger matrix docs
|
||||
- migration playbook
|
||||
- telemetry dashboards (prompt failures, invalid configs)
|
||||
|
||||
---
|
||||
|
||||
## 12) Open decisions to lock
|
||||
|
||||
1. Exact enum lists and naming (avoid future migrations for casing drift).
|
||||
2. Whether XOR in action groups means “exactly one” or “odd parity” (recommend exactly one).
|
||||
3. Hidden information policy for prompts (what opponent can see in each mode).
|
||||
4. Timeout/default behavior for unresolved prompts.
|
||||
5. Hard caps for complexity (max nodes, max nested groups) for performance safety.
|
||||
|
||||
---
|
||||
|
||||
## 13) Suggested immediate next 5 tasks
|
||||
|
||||
1. Freeze R2 canonical schema draft (`AbilityDefinitionR2` JSON schema file).
|
||||
2. Implement typed filter registry and remove type-only filter save path.
|
||||
3. Add trigger `sourceZoneGate` end-to-end (builder + runtime).
|
||||
4. Build prompt envelope/response contracts in shared DTO package.
|
||||
5. Add round-trip tests proving no-loss serialization across builder modes.
|
||||
|
||||
---
|
||||
|
||||
## Appendix A — Minimal canonical JSON sketch
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "ability-123",
|
||||
"name": "Tactical Collapse",
|
||||
"type": "Triggered",
|
||||
"activationConditions": {
|
||||
"op": "AND",
|
||||
"items": [
|
||||
{ "type": "IsTurn", "owner": "Self" }
|
||||
]
|
||||
},
|
||||
"trigger": {
|
||||
"eventType": "OnUnitDeath",
|
||||
"sourceZoneGate": ["Battlefield", "Hand", "Discard", "Deck"],
|
||||
"filters": {
|
||||
"op": "AND",
|
||||
"items": [
|
||||
{ "type": "OwnershipIs", "value": "Opponent" }
|
||||
]
|
||||
},
|
||||
"limit": { "mode": "PerTurn", "count": 1 }
|
||||
},
|
||||
"actions": {
|
||||
"op": "AND",
|
||||
"items": [
|
||||
{
|
||||
"target": {
|
||||
"scope": ["Battlefield"],
|
||||
"targetType": "Spirit",
|
||||
"chooser": "Self",
|
||||
"count": { "mode": "N", "value": 1 }
|
||||
},
|
||||
"effects": [
|
||||
{ "type": "DealDamage", "amount": { "fixed": 2 } }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
This document is a planning blueprint; implementation details should be locked against actual engine/runtime code before final schema freeze.
|
||||
+392
@@ -0,0 +1,392 @@
|
||||
# BuilderR2
|
||||
|
||||
## Purpose
|
||||
Admin-side implementation plan for R2 **New Card Flow + Ability Builder** only.
|
||||
|
||||
Scope of this doc:
|
||||
- `SOR.Admin` UX + authoring data flow + validation process.
|
||||
- Canonical JSON authoring contract as consumed by engine.
|
||||
|
||||
Out of scope for this doc:
|
||||
- Engine runtime execution internals.
|
||||
- Client prompt transport/protocol implementation.
|
||||
|
||||
---
|
||||
|
||||
## 1) Product goals (Builder-only)
|
||||
|
||||
- Build cards/abilities without manual JSON editing.
|
||||
- Mobile-first usability; desktop adds graph authoring.
|
||||
- Form mode, graph mode, and English mode all emit identical canonical JSON.
|
||||
- Prevent lossy save behavior (especially typed filter params).
|
||||
- Provide clear pre-save validation + preview so designers can trust outputs.
|
||||
|
||||
---
|
||||
|
||||
## 2) Builder architecture
|
||||
|
||||
## 2.1 Single canonical model in admin
|
||||
Builder state should normalize into one canonical draft:
|
||||
- `CardDefinitionDraftR2`
|
||||
- `AbilityDefinitionDraftR2`
|
||||
|
||||
All UI surfaces are adapters:
|
||||
- Form editor ↔ Draft model
|
||||
- Graph editor ↔ Draft model
|
||||
- English parser draft → Draft model
|
||||
- Draft model → Canonical JSON
|
||||
|
||||
No mode-specific persisted format.
|
||||
|
||||
## 2.2 Authoring pipeline
|
||||
1. Input/edit in one of 3 modes.
|
||||
2. Normalize into draft model.
|
||||
3. Run validator pipeline (schema + semantic + flow checks).
|
||||
4. Show errors/warnings in a unified panel.
|
||||
5. Save canonical JSON only when passing required checks.
|
||||
|
||||
---
|
||||
|
||||
## 3) New Card Flow R2 (admin wizard)
|
||||
|
||||
## 3.1 Step plan
|
||||
1) **Core**
|
||||
- Name, CardType, Affinity, Description, art preview metadata, SP/ST cost.
|
||||
|
||||
2) **Type-specific**
|
||||
- ArchSpirit: min/max channel range, tier, previous tier selector (if tier > 1).
|
||||
- Spirit/ArchSpirit: attack type/range, stats, movement, genus tags.
|
||||
|
||||
3) **Flags + constraints**
|
||||
- Can booleans (attack/defend/move/etc.).
|
||||
- Type-gated booleans (e.g., spirit sacrifice).
|
||||
- LOS requirements where applicable.
|
||||
|
||||
4) **Abilities**
|
||||
- Add/edit/reorder abilities.
|
||||
- Type gating by card type:
|
||||
- Spirit/ArchSpirit/SpiritToken/Ruin: Active/Triggered/Aura/Passive
|
||||
- Instinct/Repentance: Active/Triggered
|
||||
|
||||
5) **Review + validate + save**
|
||||
- Human-readable summary + canonical JSON preview.
|
||||
- Blocking errors and non-blocking warnings.
|
||||
|
||||
## 3.2 UX notes
|
||||
- Mobile: progressive disclosure, chips/tags, sticky error summary.
|
||||
- Desktop: split pane with live JSON preview + structure outline.
|
||||
|
||||
---
|
||||
|
||||
## 4) Ability Builder R2 (form mode)
|
||||
|
||||
## 4.1 Common sections
|
||||
- Name, description, type
|
||||
- Activation conditions (`LogicGroup` with AND/OR/XOR)
|
||||
- Limits (per turn/game)
|
||||
- Animation/SFX
|
||||
|
||||
## 4.2 Type sections
|
||||
- **Active**: range/LOS/linear/uses per turn/cost groups
|
||||
- **Triggered**: event type + source zone gate + trigger filters + limits
|
||||
- **Passive**: continuous scope + recheck cadence + source-leave policy
|
||||
- **Aura**: min/max range + enter/leave hooks + leave policy
|
||||
|
||||
## 4.3 Action authoring
|
||||
Per action:
|
||||
- Action group nesting (AND/OR/XOR)
|
||||
- Chooser authority (self/opponent/random/system)
|
||||
- Scope + target type + chooser + count
|
||||
- Typed parameterized filters (not type-only)
|
||||
- Action conditions
|
||||
- Effect chain with per-effect duration override
|
||||
|
||||
## 4.4 Cost authoring
|
||||
- Free or grouped costs
|
||||
- Group logic with alternatives
|
||||
- Interactive cost metadata fields where needed (pick mode, chooser, etc.)
|
||||
|
||||
---
|
||||
|
||||
## 5) Trigger authoring requirements (builder)
|
||||
|
||||
## 5.1 Source-zone gating (required)
|
||||
Builder must allow trigger source to be active from:
|
||||
- Battlefield
|
||||
- Hand
|
||||
- Discard
|
||||
- Deck
|
||||
|
||||
UI control: multi-select `sourceZoneGate[]` with safe defaults by ability type.
|
||||
|
||||
## 5.2 Trigger matrix editor
|
||||
Author by event family templates instead of fully bespoke screens:
|
||||
- Lifecycle
|
||||
- Unit combat/move/ability
|
||||
- Battlefield state
|
||||
- Ability mutation/targeting
|
||||
- Ruin/occupancy
|
||||
- Tile/affinity
|
||||
- Resource economy
|
||||
- Card movement/visibility
|
||||
- Aura boundary
|
||||
|
||||
Each family exposes only valid fields for that event.
|
||||
|
||||
---
|
||||
|
||||
## 6) Graph builder vision (desktop-first)
|
||||
|
||||
## 6.1 Node palette
|
||||
- Trigger
|
||||
- Condition Group
|
||||
- Cost Group
|
||||
- Target Selector
|
||||
- Action Group
|
||||
- Effect
|
||||
- Duration/Policy
|
||||
|
||||
## 6.2 Edge semantics
|
||||
- Typed input/output ports
|
||||
- Invalid connections blocked at UI level
|
||||
- Execution path preview (readable sequence)
|
||||
|
||||
## 6.3 Graph parity requirement
|
||||
- Graph decompile from existing canonical JSON must be possible.
|
||||
- Round-trip graph -> json -> graph should preserve semantics.
|
||||
|
||||
---
|
||||
|
||||
## 7) English -> Ability JSON authoring flow
|
||||
|
||||
## 7.1 Pipeline
|
||||
1. Designer writes plain-English intent.
|
||||
2. Parser/assistant produces structured draft + confidence + unresolved slots.
|
||||
3. Builder maps draft to canonical draft model.
|
||||
4. Designer resolves ambiguities in form/graph UI.
|
||||
5. Save only validated canonical JSON.
|
||||
|
||||
## 7.2 Safety constraints
|
||||
- Never persist raw parser output as final ability.
|
||||
- Ambiguous items must remain explicit TODO slots until resolved.
|
||||
- Show diff between generated draft and final saved JSON.
|
||||
|
||||
---
|
||||
|
||||
## 8) Validation system (admin-side)
|
||||
|
||||
## 8.1 Validation stages
|
||||
1) **Schema validation**
|
||||
- Shape/types/enums/required fields.
|
||||
|
||||
2) **Semantic validation**
|
||||
- CardType gating for ability types.
|
||||
- Trigger/event compatibility.
|
||||
- Filter parameter correctness.
|
||||
- Range/value bounds.
|
||||
- Source zone legality.
|
||||
|
||||
3) **Flow validation**
|
||||
- Action graph/group solvable.
|
||||
- Chooser/target requirements satisfiable.
|
||||
- Cost branches executable.
|
||||
|
||||
## 8.2 Output model
|
||||
- `Error` (blocks save)
|
||||
- `Warning` (save allowed)
|
||||
- `Info` (quality hints)
|
||||
|
||||
Each issue should include:
|
||||
- stable code
|
||||
- path to field/node
|
||||
- suggested fix text
|
||||
|
||||
## 8.3 Pre-save checks specifically for interactive mechanics
|
||||
Builder should flag actions/effects that will require runtime prompts and ensure required metadata exists:
|
||||
- chooser authority
|
||||
- target selection mode
|
||||
- selection min/max
|
||||
- hidden-zone visibility policy
|
||||
- random/self/enemy pick modes
|
||||
|
||||
(Transport protocol stays out-of-scope here, but authoring completeness is validated.)
|
||||
|
||||
---
|
||||
|
||||
## 9) Builder simulator (admin tool)
|
||||
|
||||
Provide a lightweight simulation panel for author confidence:
|
||||
- load sample board/state fixture
|
||||
- fire selected trigger events
|
||||
- inspect condition pass/fail trace
|
||||
- inspect resolved target set and planned effects
|
||||
|
||||
This is a builder QA tool; not full runtime parity simulator.
|
||||
|
||||
---
|
||||
|
||||
## 10) Delivery plan (admin-only)
|
||||
|
||||
## Phase A — Foundation
|
||||
- Draft models + canonical mapper
|
||||
- Unified validation framework
|
||||
- Error panel + field/node mapping
|
||||
|
||||
## Phase B — Form parity
|
||||
- New card wizard upgrades
|
||||
- Full ability form for Active/Triggered/Aura/Passive
|
||||
- Typed filter editors + action/cost group editors
|
||||
|
||||
## Phase C — Trigger + zone support
|
||||
- Trigger family template editors
|
||||
- Source zone gate controls (battlefield/hand/discard/deck)
|
||||
|
||||
## Phase D — Graph mode
|
||||
- Node/edge authoring
|
||||
- graph <-> canonical draft compile/decompile
|
||||
- live preview and validation overlays
|
||||
|
||||
## Phase E — English mode
|
||||
- Draft import + unresolved slot UX
|
||||
- normalization + explicit confirm flow
|
||||
|
||||
## Phase F — Hardening
|
||||
- round-trip regression suite (form/graph/english)
|
||||
- legacy load/edit checks
|
||||
- UX polish for mobile
|
||||
|
||||
---
|
||||
|
||||
## 11) Acceptance criteria (BuilderR2)
|
||||
|
||||
- Designer can author complete cards/abilities via mobile-friendly form.
|
||||
- Trigger source-zone gating supports battlefield/hand/discard/deck.
|
||||
- Filters persist with full parameters (no type-only loss).
|
||||
- Form/graph/english pathways produce equivalent canonical JSON.
|
||||
- Validation catches invalid gates/combinations before save.
|
||||
- Existing content can be loaded and edited without silent mutation.
|
||||
|
||||
---
|
||||
|
||||
## 12) Immediate next tasks
|
||||
|
||||
1. Define `CardDefinitionDraftR2` + `AbilityDefinitionDraftR2` classes in admin.
|
||||
2. Implement unified validation result model and side panel UI.
|
||||
3. Build Trigger editor v2 with event family templates + sourceZoneGate.
|
||||
4. Replace all type-only filter save paths with typed param objects.
|
||||
5. Add canonical JSON preview + round-trip snapshot tests.
|
||||
|
||||
---
|
||||
|
||||
## 13) Coverage checklist from Jason long-form spec (exhaustiveness guard)
|
||||
|
||||
Use this as a **builder completeness checklist** so nothing from the spec is silently dropped.
|
||||
|
||||
### 13.1 Card fields and gates
|
||||
- Core fields: name, card type, affinity, description, art preview, SP cost, ST cost.
|
||||
- ArchSpirit-only:
|
||||
- min/max channel range
|
||||
- tier
|
||||
- previous-tier selector when tier > 1 (search `tier-1` card)
|
||||
- Spirit + ArchSpirit:
|
||||
- attack type (melee/ranged/extensible)
|
||||
- if ranged: min/max attack range
|
||||
- stats: damage, health, defense
|
||||
- movement type + movement points
|
||||
- genus tags (autocomplete + create new)
|
||||
- boolean permissions: attack/defend/be attacked/be blocked/move/be obstructed/use ability/LOS behavior
|
||||
- Type-specific booleans:
|
||||
- Spirit: can be sacrificed
|
||||
- Repentance/Instinct: LOS requirement handling
|
||||
- Ability type gates by card type:
|
||||
- Spirit/ArchSpirit/SpiritToken/Ruin => Active/Triggered/Aura/Passive
|
||||
- Instinct/Repentance => Active/Triggered
|
||||
|
||||
### 13.2 Ability common + Active specifics
|
||||
- Ability fields: name, description, type.
|
||||
- Naming rule: Instinct/Repentance default ability name to card name.
|
||||
- Active-only fields:
|
||||
- range min/max
|
||||
- requires LOS
|
||||
- linear only
|
||||
- uses per turn
|
||||
- cost model (free vs grouped)
|
||||
- Cost groups support AND/OR/XOR and alternatives.
|
||||
- Interactive cost selectors required in builder metadata:
|
||||
- `DiscardFromHand`: Random / SelfPick / EnemySeePick / EnemyRandomPick
|
||||
- `SendSpiritFromBattlefieldToDiscard`: Random / SelfPick / EnemyPick
|
||||
- `DealDamageToOwnSpirit`: Random / SelfPick / EnemyPick
|
||||
|
||||
### 13.3 Conditions model completeness
|
||||
- Activation conditions for all ability types.
|
||||
- Action conditions per action.
|
||||
- Target property conditions.
|
||||
- All condition families must use nested group logic AND/OR/XOR.
|
||||
- Comparator support: `>`, `==`, `<`, `!=`, `<=`, `>=`.
|
||||
- Condition domains to expose in UI:
|
||||
- turn/timing ownership
|
||||
- unit ownership/type/properties
|
||||
- this card properties
|
||||
- this card definition properties + count-in-zone rules
|
||||
- location scopes (deck/discard/hand/battlefield)
|
||||
- battlefield tile/surrounding tile properties
|
||||
- player properties (SP/ST/accumulation/hand/deck/discard metrics)
|
||||
|
||||
### 13.4 Trigger model completeness
|
||||
- Trigger event map must include the broad event set from spec (turn, channel, movement, combat, damage/heal, death, enter/leave battlefield, discard/sacrifice/token, stat/ability/genus, ruin occupancy/activation, tile affinity, resource gain/spend, card draw/discard/return/reveal/shuffle, targeted/effect applied, aura enter/leave).
|
||||
- Per-event filter capability must support:
|
||||
- ownership scopes (any/self/ally/opponent)
|
||||
- exact-card vs class vs filtered unit/card
|
||||
- comparator-based amount constraints where applicable
|
||||
- grouped property filters (AND/OR/XOR)
|
||||
- Trigger limits:
|
||||
- unlimited
|
||||
- N per turn
|
||||
- N per game
|
||||
- Source zone gating:
|
||||
- battlefield/hand/discard/deck
|
||||
|
||||
### 13.5 Action and targeting completeness
|
||||
- Ability has N actions.
|
||||
- Action grouping supports AND/OR/XOR.
|
||||
- Choice authority for action branching: self/opponent/random.
|
||||
- Action shape:
|
||||
- scope
|
||||
- target type
|
||||
- chooser
|
||||
- count (N/all)
|
||||
- filters
|
||||
- conditions
|
||||
- effects
|
||||
- Scope support:
|
||||
- hand, deck, discard, battlefield, player
|
||||
- combined scopes where needed
|
||||
- Target type support by scope:
|
||||
- zone cards by type
|
||||
- battlefield entities: tile, spirit, archspirit, spirit token, ruin
|
||||
- player targets: self/ally/opponent/all/random (with player-property filters)
|
||||
|
||||
### 13.6 Effect catalog coverage guard (builder)
|
||||
Builder should expose effect families from spec (with params), including:
|
||||
- Zone movement ops (send to hand/deck/discard with top/bottom/random and optional reset-to-definition)
|
||||
- Channeling ops by card type with constraints (control, ignore cost/range/affinity/turn constraints)
|
||||
- Deck ops (search/shuffle/stack/put results)
|
||||
- Unit ops (heal/damage/dot/hot/prevent damage/death/push/pull/displace/toggle bools/stat mods/attack range mods/genus/affinity)
|
||||
- ArchSpirit ops (ascend/transition variants, channel range mods)
|
||||
- Spirit ops (clone token, take control variants, zone sends, sacrifice token return mod)
|
||||
- SpiritToken ops (destroy)
|
||||
- Ruin ops (relocate/disable/activate ability/send zones)
|
||||
- Tile ops (set/push affinities and resolve behavior)
|
||||
- Player ops (draw/discard/SP/ST modifications/skip turn/toggle player channel capabilities)
|
||||
- Token creation/channeling from existing card or custom token template
|
||||
|
||||
### 13.7 Validation guardrails explicitly requested by spec intent
|
||||
- If a feature is available in UI, compile/parsing must round-trip without dropping params.
|
||||
- All interactive choices must include authorable metadata for runtime prompting.
|
||||
- Builder should warn on high-risk trigger loops (e.g., ruin/self-retrigger) and recommend limits.
|
||||
- Canonical JSON preview required before save.
|
||||
|
||||
### 13.8 Definition of “nothing left out” for BuilderR2
|
||||
For this doc, “nothing left out” means:
|
||||
- every major capability category from the long spec appears in at least one explicit checklist item,
|
||||
- and each category is mapped to a builder responsibility (field, editor, validation, or compile path).
|
||||
+1064
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 1.9 MiB |
@@ -0,0 +1,43 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://qmb76y70ds6a"
|
||||
path="res://.godot/imported/SOR.svg-0f2123773e47d81f336aec1000405619.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://SOR.svg"
|
||||
dest_files=["res://.godot/imported/SOR.svg-0f2123773e47d81f336aec1000405619.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
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/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
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=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 882 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://djlr6v2m1uegn"
|
||||
path="res://.godot/imported/TempSplash.png-f40bc9f31b75feab563b990d0087c6f7.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://TempSplash.png"
|
||||
dest_files=["res://.godot/imported/TempSplash.png-f40bc9f31b75feab563b990d0087c6f7.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
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/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
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=1
|
||||
@@ -101,6 +101,7 @@ func logout() -> void:
|
||||
_pending_keycloak_token = ""
|
||||
needs_starter_deck = false
|
||||
_refresh_in_progress = false
|
||||
session_expired.emit()
|
||||
_save_session()
|
||||
Network.force_reconnect()
|
||||
|
||||
|
||||
@@ -65,6 +65,9 @@ var notifications: Array = []
|
||||
var _overlay: CanvasLayer = null
|
||||
var _message_poll_timer: Timer = null
|
||||
var _message_poll_in_flight: Dictionary = {}
|
||||
var _bubble_visible_requested := false
|
||||
var _bubble_host: Control = null
|
||||
var _bubble_visibility_owners: Dictionary = {}
|
||||
|
||||
const MESSAGE_POLL_INTERVAL_SEC := 0.2
|
||||
|
||||
@@ -86,13 +89,19 @@ func _add_overlay() -> void:
|
||||
return
|
||||
_overlay = scene.instantiate() as CanvasLayer
|
||||
# Chat UI should only be visible for authenticated users.
|
||||
_overlay.visible = false
|
||||
if _overlay.has_method("set_overlay_visible"):
|
||||
_overlay.call("set_overlay_visible", _bubble_visible_requested)
|
||||
else:
|
||||
_overlay.visible = _bubble_visible_requested
|
||||
get_tree().get_root().add_child(_overlay)
|
||||
if _overlay.has_method("set_bubble_host"):
|
||||
_overlay.call("set_bubble_host", _bubble_host)
|
||||
|
||||
# ── Auth hooks ────────────────────────────────────────────────────────────────
|
||||
|
||||
func _on_auth_success(_uid: String, _dn: String) -> void:
|
||||
# Overlay visibility is controlled by individual scenes via set_bubble_visible().
|
||||
print("Your authed atleast per chat")
|
||||
_fetch_social()
|
||||
_fetch_channels()
|
||||
_fetch_notifications()
|
||||
@@ -103,13 +112,46 @@ func _on_auth_success(_uid: String, _dn: String) -> void:
|
||||
## Show or hide the chat bubble overlay. Call from scenes that want chat
|
||||
## (e.g. MainScreen._ready / _exit_tree).
|
||||
func set_bubble_visible(v: bool) -> void:
|
||||
_bubble_visible_requested = v
|
||||
_bubble_visibility_owners.clear()
|
||||
if is_instance_valid(_overlay):
|
||||
_overlay.visible = v
|
||||
if _overlay.has_method("set_overlay_visible"):
|
||||
_overlay.call("set_overlay_visible", v)
|
||||
else:
|
||||
_overlay.visible = v
|
||||
|
||||
|
||||
func claim_bubble_visibility(owner: Node) -> void:
|
||||
if not is_instance_valid(owner):
|
||||
return
|
||||
_bubble_visibility_owners[owner.get_instance_id()] = weakref(owner)
|
||||
_apply_bubble_visibility()
|
||||
|
||||
|
||||
func release_bubble_visibility(owner: Node) -> void:
|
||||
if not is_instance_valid(owner):
|
||||
return
|
||||
_bubble_visibility_owners.erase(owner.get_instance_id())
|
||||
_apply_bubble_visibility()
|
||||
|
||||
|
||||
func set_bubble_host(host: Control) -> void:
|
||||
_bubble_host = host
|
||||
if is_instance_valid(_overlay) and _overlay.has_method("set_bubble_host"):
|
||||
_overlay.call("set_bubble_host", host)
|
||||
|
||||
|
||||
func _clear_state() -> void:
|
||||
_bubble_visible_requested = false
|
||||
_bubble_host = null
|
||||
_bubble_visibility_owners.clear()
|
||||
if is_instance_valid(_overlay):
|
||||
_overlay.visible = false
|
||||
if _overlay.has_method("set_overlay_visible"):
|
||||
_overlay.call("set_overlay_visible", false)
|
||||
else:
|
||||
_overlay.visible = false
|
||||
if _overlay.has_method("set_bubble_host"):
|
||||
_overlay.call("set_bubble_host", null)
|
||||
_stop_message_polling()
|
||||
channels = []
|
||||
messages = {}
|
||||
@@ -330,6 +372,27 @@ func _setup_message_polling() -> void:
|
||||
add_child(_message_poll_timer)
|
||||
|
||||
|
||||
func _apply_bubble_visibility() -> void:
|
||||
var stale_ids: Array = []
|
||||
var should_show := false
|
||||
for owner_id: Variant in _bubble_visibility_owners.keys():
|
||||
var owner_ref: WeakRef = _bubble_visibility_owners[owner_id]
|
||||
var owner : Variant = owner_ref.get_ref()
|
||||
if owner == null:
|
||||
stale_ids.append(owner_id)
|
||||
continue
|
||||
should_show = true
|
||||
for owner_id: Variant in stale_ids:
|
||||
_bubble_visibility_owners.erase(owner_id)
|
||||
|
||||
_bubble_visible_requested = should_show
|
||||
if is_instance_valid(_overlay):
|
||||
if _overlay.has_method("set_overlay_visible"):
|
||||
_overlay.call("set_overlay_visible", should_show)
|
||||
else:
|
||||
_overlay.visible = should_show
|
||||
|
||||
|
||||
func _start_message_polling() -> void:
|
||||
if is_instance_valid(_message_poll_timer):
|
||||
_message_poll_timer.start()
|
||||
|
||||
@@ -12,6 +12,7 @@ var _loaded_player_id : String = ""
|
||||
var _cards_pages : Dictionary = {}
|
||||
var _decks_payload : Dictionary = {}
|
||||
var _deck_payloads : Dictionary = {}
|
||||
var _owned_map : Dictionary = {} ## definitionId(String) → ownedCount(int)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -138,6 +139,27 @@ func remove_deck(deck_id: String) -> void:
|
||||
_write_json_file(_decks_file_path(), _decks_payload)
|
||||
|
||||
|
||||
func get_owned_map() -> Dictionary:
|
||||
_ensure_loaded()
|
||||
if _loaded_player_id.is_empty():
|
||||
return {}
|
||||
if not _owned_map.is_empty():
|
||||
return _owned_map.duplicate(true)
|
||||
var payload := _read_json_file(_owned_file_path())
|
||||
if not payload.is_empty():
|
||||
_owned_map = payload
|
||||
return payload.duplicate(true)
|
||||
return {}
|
||||
|
||||
|
||||
func store_owned_map(map: Dictionary) -> void:
|
||||
_ensure_loaded()
|
||||
if _loaded_player_id.is_empty():
|
||||
return
|
||||
_owned_map = map.duplicate(true)
|
||||
_write_json_file(_owned_file_path(), _owned_map)
|
||||
|
||||
|
||||
func _ensure_loaded() -> void:
|
||||
var current_player_id := Auth.user_id
|
||||
if current_player_id == _loaded_player_id:
|
||||
@@ -146,6 +168,7 @@ func _ensure_loaded() -> void:
|
||||
_cards_pages.clear()
|
||||
_decks_payload.clear()
|
||||
_deck_payloads.clear()
|
||||
_owned_map.clear()
|
||||
|
||||
|
||||
func _player_dir() -> String:
|
||||
@@ -164,6 +187,10 @@ func _deck_file_path(deck_id: String) -> String:
|
||||
return "%s/deck_%s.json" % [_player_dir(), _sanitize_path_component(deck_id)]
|
||||
|
||||
|
||||
func _owned_file_path() -> String:
|
||||
return "%s/owned.json" % _player_dir()
|
||||
|
||||
|
||||
func _sanitize_path_component(value: String) -> String:
|
||||
var safe := value.strip_edges()
|
||||
if safe.is_empty():
|
||||
|
||||
@@ -20,7 +20,7 @@ extends Node
|
||||
const CACHE_DIR := "user://content"
|
||||
const CACHE_PATH := "user://content/defs.json"
|
||||
const TILE_MODELS_PATH := "user://content/tile_models.json"
|
||||
const TILE_BOTTOMS_PATH := "user://content/tile_bottoms.json"
|
||||
const TILE_BOTTOMS_PATH := "user://content/tile_bottoms_v2.json"
|
||||
const SKYBOXES_PATH := "user://content/skyboxes.json"
|
||||
const PAGE_SIZE := 200
|
||||
const REFRESH_INTERVAL_SECS := 300.0 # re-sync every 5 minutes during live play
|
||||
@@ -40,8 +40,9 @@ var _tile_models: Dictionary = {}
|
||||
## "Affinity_Shape" → CDN texture URL string (2D texture for placeholder tiles)
|
||||
var _tile_textures: Dictionary = {}
|
||||
|
||||
## Array of CDN URL strings for tile bottom (stalagmite) models.
|
||||
var _tile_bottom_urls: Array = []
|
||||
## CDN URL strings for tile bottom (stalagmite) models, split by tile shape.
|
||||
var _tile_bottom_urls_square: Array = []
|
||||
var _tile_bottom_urls_hex: Array = []
|
||||
|
||||
## Array of Dictionary (SkyboxDefinitionDto) for all active skyboxes.
|
||||
var _skyboxes: Array = []
|
||||
@@ -61,6 +62,23 @@ func get_definition(id: String) -> Dictionary:
|
||||
return _defs.get(id, {})
|
||||
|
||||
|
||||
## Return the CDN URL for the first Model3D asset in a card definition.
|
||||
## Returns "" if the definition is not cached or has no Model3D asset.
|
||||
## Intended for iOS Safari memory-management paths that need the URL without a
|
||||
## loaded unit dict (e.g. pre-eviction before a unit is placed).
|
||||
func get_model_url_for_definition(definition_id: String) -> String:
|
||||
var def := get_definition(definition_id)
|
||||
for asset: Variant in def.get("assets", []):
|
||||
var d: Dictionary = asset as Dictionary
|
||||
if d == null:
|
||||
continue
|
||||
if str(d.get("assetType", "")) == "Model3D":
|
||||
var url: String = str(d.get("cdnUrl", "")).strip_edges()
|
||||
if not url.is_empty() and url.to_lower() != "null":
|
||||
return url
|
||||
return ""
|
||||
|
||||
|
||||
## True if the definition is cached.
|
||||
func has_definition(id: String) -> bool:
|
||||
return _defs.has(id)
|
||||
@@ -129,11 +147,13 @@ func get_tile_texture_url(affinity: String, shape: String) -> String:
|
||||
return _tile_textures.get(affinity + "_" + shape, "")
|
||||
|
||||
|
||||
## Returns a random active tile bottom (stalagmite) CDN URL, or "" if none configured.
|
||||
func get_random_tile_bottom_url() -> String:
|
||||
if _tile_bottom_urls.is_empty():
|
||||
## Returns a random active tile bottom (stalagmite) CDN URL for the given shape,
|
||||
## or "" if none are configured. shape should be "Square" or "Hex".
|
||||
func get_random_tile_bottom_url(shape: String) -> String:
|
||||
var pool := _tile_bottom_urls_hex if shape == "Hex" else _tile_bottom_urls_square
|
||||
if pool.is_empty():
|
||||
return ""
|
||||
return _tile_bottom_urls[randi() % _tile_bottom_urls.size()] as String
|
||||
return pool[randi() % pool.size()] as String
|
||||
|
||||
|
||||
## Fetch tile bottom model URLs from the server and update the local cache.
|
||||
@@ -312,12 +332,15 @@ func _on_tile_models(payload: Variant) -> void:
|
||||
|
||||
|
||||
func _on_tile_bottoms(payload: Variant) -> void:
|
||||
var p := payload as Dictionary
|
||||
var urls : Array = p.get("urls", [])
|
||||
_tile_bottom_urls.clear()
|
||||
for u in urls:
|
||||
var p := payload as Dictionary
|
||||
_tile_bottom_urls_square.clear()
|
||||
_tile_bottom_urls_hex.clear()
|
||||
for u in p.get("squareUrls", []):
|
||||
if typeof(u) == TYPE_STRING and not (u as String).is_empty():
|
||||
_tile_bottom_urls.append(u as String)
|
||||
_tile_bottom_urls_square.append(u as String)
|
||||
for u in p.get("hexUrls", []):
|
||||
if typeof(u) == TYPE_STRING and not (u as String).is_empty():
|
||||
_tile_bottom_urls_hex.append(u as String)
|
||||
_save_tile_bottoms_to_disk()
|
||||
|
||||
|
||||
@@ -390,8 +413,12 @@ func _load_tile_bottoms_from_disk() -> void:
|
||||
return
|
||||
var parsed: Variant = JSON.parse_string(file.get_as_text())
|
||||
file.close()
|
||||
if typeof(parsed) == TYPE_ARRAY:
|
||||
_tile_bottom_urls = parsed as Array
|
||||
if typeof(parsed) == TYPE_DICTIONARY:
|
||||
var d := parsed as Dictionary
|
||||
if typeof(d.get("square")) == TYPE_ARRAY:
|
||||
_tile_bottom_urls_square = d["square"] as Array
|
||||
if typeof(d.get("hex")) == TYPE_ARRAY:
|
||||
_tile_bottom_urls_hex = d["hex"] as Array
|
||||
|
||||
|
||||
func _save_tile_bottoms_to_disk() -> void:
|
||||
@@ -399,7 +426,7 @@ func _save_tile_bottoms_to_disk() -> void:
|
||||
var file := FileAccess.open(TILE_BOTTOMS_PATH, FileAccess.WRITE)
|
||||
if not file:
|
||||
return
|
||||
file.store_string(JSON.stringify(_tile_bottom_urls))
|
||||
file.store_string(JSON.stringify({ "square": _tile_bottom_urls_square, "hex": _tile_bottom_urls_hex }))
|
||||
file.close()
|
||||
|
||||
|
||||
|
||||
@@ -57,6 +57,9 @@ signal lobby_notice(message: String)
|
||||
## Pushed (or acked) when the host changes a seat's team assignment.
|
||||
signal team_assignment_changed(seat_teams: Dictionary)
|
||||
|
||||
## Emitted when the AI slot list for the current lobby changes (add / server push).
|
||||
signal ai_slots_changed(ai_slots: Array)
|
||||
|
||||
# ── State ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
var lobby_id : String = ""
|
||||
@@ -72,6 +75,8 @@ var game_mode : String = "FFA"
|
||||
var team_count : int = 1
|
||||
## Seat index → team index overrides. Empty = use default (seat % team_count).
|
||||
var seat_teams : Dictionary = {}
|
||||
## Current AI slots in this lobby (array of dicts: accountId, displayName, difficulty, strategy, seatIndex).
|
||||
var ai_slots : Array = []
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -93,6 +98,7 @@ func clear_state() -> void:
|
||||
game_mode = "FFA"
|
||||
team_count = 1
|
||||
seat_teams = {}
|
||||
ai_slots = []
|
||||
|
||||
# ── Public actions ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -234,6 +240,7 @@ func update_rules(rules_override: Dictionary) -> void:
|
||||
var d := p as Dictionary
|
||||
var rules := d.get("rules", {}) as Dictionary
|
||||
if not rules.is_empty():
|
||||
lobby["rules"] = rules # keep lobby dict current for _refresh_display
|
||||
lobby_rules_updated.emit(rules),
|
||||
func(code: String, msg: String) -> void:
|
||||
print("[CustomLobby] ERR update_rules ", code, " ", msg))
|
||||
@@ -320,6 +327,34 @@ func reassign_team(seat_index: int, team_index: int) -> void:
|
||||
print("[CustomLobby] ERR reassign_team ", code, " ", msg))
|
||||
|
||||
|
||||
## Host-only: add an AI player to the current open lobby.
|
||||
## difficulty is 1-10, strategy is one of: Aggressive, Control, Balanced, Ramp, Swarm.
|
||||
func add_ai(difficulty: int, strategy: String,
|
||||
on_success: Callable = Callable(),
|
||||
on_error: Callable = Callable()) -> void:
|
||||
Network.request("game.ai.add",
|
||||
{ "lobbyId": lobby_id, "difficulty": difficulty, "strategy": strategy },
|
||||
func(_t: String, p: Variant) -> void:
|
||||
var d := p as Dictionary
|
||||
# Update ai_slots immediately from the ACK so the display
|
||||
# reflects the new AI before the push arrives.
|
||||
var seat := int(d.get("seatIndex", 1))
|
||||
ai_slots = ai_slots.filter(func(s: Dictionary) -> bool:
|
||||
return int(s.get("seatIndex", -1)) != seat)
|
||||
ai_slots.append({
|
||||
"accountId": str(d.get("aiAccountId", "")),
|
||||
"displayName": str(d.get("aiDisplayName", "AI")),
|
||||
"difficulty": difficulty,
|
||||
"strategy": strategy,
|
||||
"seatIndex": seat,
|
||||
})
|
||||
ai_slots_changed.emit(ai_slots)
|
||||
if on_success.is_valid(): on_success.call(d),
|
||||
func(code: String, msg: String) -> void:
|
||||
print("[CustomLobby] ERR add_ai ", code, " ", msg)
|
||||
if on_error.is_valid(): on_error.call(code, msg))
|
||||
|
||||
|
||||
# ── Private ───────────────────────────────────────────────────────────────────
|
||||
|
||||
func _on_server_push(type: String, payload: Variant) -> void:
|
||||
@@ -342,6 +377,8 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
||||
"game.custom.lobby_updated":
|
||||
var d := payload as Dictionary
|
||||
var rules := d.get("newRules", {}) as Dictionary
|
||||
if not rules.is_empty():
|
||||
lobby["rules"] = rules # keep lobby dict current for _refresh_display
|
||||
lobby_rules_updated.emit(rules)
|
||||
|
||||
"game.custom.lobby.deck_changed":
|
||||
@@ -412,6 +449,11 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
||||
"game.custom.lobby.rule_suggestion.rejected":
|
||||
rule_suggestion_rejected.emit()
|
||||
|
||||
"game.ai.slots_changed":
|
||||
var d := payload as Dictionary
|
||||
ai_slots = d.get("currentAiSlots", []) as Array
|
||||
ai_slots_changed.emit(ai_slots)
|
||||
|
||||
"game.custom.lobby.team_reassigned":
|
||||
var d := payload as Dictionary
|
||||
var raw := d.get("seatTeams", {}) as Dictionary
|
||||
|
||||
@@ -50,13 +50,59 @@ signal game_activity(event_type: String, session_id: String)
|
||||
## Payload keys: requestId, sourceInstanceId, abilityName, actionJson, rangeJson
|
||||
signal triggered_target_request(request_data: Dictionary)
|
||||
|
||||
## Emitted when an interactive cost requires the player to select cards/units.
|
||||
## Payload keys: requestId, sourceInstanceId, costType, amount, pickMode, filtersJson
|
||||
signal cost_pick_request(request_data: Dictionary)
|
||||
|
||||
## Emitted when a CostGroup OR/XOR requires the chooser to pick an option.
|
||||
## Payload keys: requestId, sourceInstanceId, costGroupJson
|
||||
signal cost_group_pick_request(request_data: Dictionary)
|
||||
|
||||
## Emitted when an ActionGroup OR/XOR requires the chooser to pick a branch.
|
||||
## Payload keys: requestId, sourceInstanceId, actionGroupJson
|
||||
signal action_group_pick_request(request_data: Dictionary)
|
||||
|
||||
## Emitted when a ChooseOne (Opponent/Ally chooser) requires a branch selection.
|
||||
## Payload keys: requestId, sourceInstanceId, branchCount, branchesJson
|
||||
signal branch_pick_request(request_data: Dictionary)
|
||||
|
||||
## Emitted when an action needs the Opponent/Ally to pick targets.
|
||||
## Payload keys: requestId, sourceInstanceId, actionJson, rangeJson
|
||||
signal target_pick_request(request_data: Dictionary)
|
||||
|
||||
## Emitted when an effect requires a tile selection.
|
||||
## Payload keys: requestId, sourceInstanceId, effectType, requireEmpty, requireOccupied,
|
||||
## occupantOwnership, maxRange, targetInstanceId
|
||||
signal tile_pick_request(request_data: Dictionary)
|
||||
|
||||
## Emitted when an effect requires a player selection.
|
||||
## Payload keys: requestId, sourceInstanceId, effectType, ownership, validPlayerIds, targetInstanceId
|
||||
signal player_pick_request(request_data: Dictionary)
|
||||
|
||||
## Emitted when cards are revealed and must be ordered by the chooser.
|
||||
## Payload keys: requestId, sourceInstanceId, effectType, revealedCardsJson, count
|
||||
signal reveal_choice_pick_request(request_data: Dictionary)
|
||||
|
||||
## Emitted when a Repentance card resolves with no custom animation asset.
|
||||
## Server only emits this when no active ability on the card has a usable AssetUrl.
|
||||
## Payload keys: eventId, sessionId, actorAccountId, sourceArchSpiritInstanceId,
|
||||
## cardInstanceId, cardDefinitionId, cardName, affinity, targets
|
||||
signal repentance_placeholder_visual(payload: Dictionary)
|
||||
|
||||
## Emitted when an Active ability fires with no custom animation asset.
|
||||
## Payload keys: eventId, sessionId, actorAccountId, sourceInstanceId,
|
||||
## abilityName, sourceAffinity, targets, targetMode
|
||||
signal ability_placeholder_visual(payload: Dictionary)
|
||||
|
||||
# ── State ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
var session_id : String = ""
|
||||
var state : Dictionary = {}
|
||||
var opponent_name : String = ""
|
||||
var is_spectating : bool = false
|
||||
var debug_output : bool = false
|
||||
var _state_version : int = -1
|
||||
var _syncing : bool = false # true while a game.get_state request is in-flight
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -72,6 +118,7 @@ func _clear_state() -> void:
|
||||
opponent_name = ""
|
||||
is_spectating = false
|
||||
_state_version = -1
|
||||
_syncing = false
|
||||
|
||||
|
||||
## Called on every auth_success (initial login AND reconnects).
|
||||
@@ -79,7 +126,11 @@ func _clear_state() -> void:
|
||||
## so the server re-registers this connection and we get state updates again.
|
||||
## The state check prevents sending stale session IDs from games that already ended.
|
||||
func _on_auth_reconnect(_uid: String, _dn: String) -> void:
|
||||
if not session_id.is_empty() and not state.is_empty():
|
||||
if session_id.is_empty():
|
||||
return
|
||||
if is_spectating:
|
||||
_request_spectator_state()
|
||||
elif not state.is_empty():
|
||||
send_ready()
|
||||
|
||||
|
||||
@@ -88,13 +139,21 @@ func start_spectating(sid: String) -> void:
|
||||
is_spectating = true
|
||||
state = {}
|
||||
session_id = sid
|
||||
_request_spectator_state()
|
||||
|
||||
|
||||
func _request_spectator_state() -> void:
|
||||
if session_id.is_empty():
|
||||
return
|
||||
Network.request("game.spectate",
|
||||
{ "sessionId": sid },
|
||||
{ "sessionId": session_id },
|
||||
func(_t: String, p: Variant) -> void:
|
||||
print("[Game] <<< game.spectate.ack")
|
||||
if debug_output:
|
||||
print("[Game] <<< game.spectate.ack")
|
||||
_apply_state_from_payload(p),
|
||||
func(code: String, msg: String) -> void:
|
||||
print("[Game] ERR spectate ", code, " ", msg)
|
||||
if debug_output:
|
||||
print("[Game] ERR spectate ", code, " ", msg)
|
||||
is_spectating = false)
|
||||
|
||||
|
||||
@@ -201,6 +260,24 @@ func get_all_enemy_units() -> Array:
|
||||
return units
|
||||
|
||||
|
||||
## Returns all units (field + archSpirit) belonging to allied players
|
||||
## (same team, not the local player). Empty in FFA games.
|
||||
func get_ally_units() -> Array:
|
||||
var my_team : int = int(get_my_player().get("teamIndex", -1))
|
||||
var units : Array = []
|
||||
if my_team < 0:
|
||||
return units
|
||||
for p: Dictionary in state.get("players", []):
|
||||
var pid : String = str(p.get("accountId", ""))
|
||||
if pid == Auth.user_id: continue
|
||||
if int(p.get("teamIndex", -2)) != my_team: continue
|
||||
units.append_array(_as_array(p.get("field", [])))
|
||||
var arch = p.get("archSpirit")
|
||||
if arch is Dictionary and not (arch as Dictionary).is_empty():
|
||||
units.append(arch)
|
||||
return units
|
||||
|
||||
|
||||
## Returns a TileDto dict by coord, or {}.
|
||||
func get_tile(x: int, y: int) -> Dictionary:
|
||||
for t: Dictionary in get_tiles():
|
||||
@@ -216,9 +293,10 @@ func get_unit_by_id(instance_id: String) -> Dictionary:
|
||||
for u: Dictionary in p.get("field", []):
|
||||
if u.get("instanceId", "") == instance_id:
|
||||
return u
|
||||
var arch: Dictionary = p.get("archSpirit", {})
|
||||
if arch.get("instanceId", "") == instance_id:
|
||||
return arch
|
||||
var arch_val: Variant = p.get("archSpirit")
|
||||
if arch_val is Dictionary and not (arch_val as Dictionary).is_empty():
|
||||
if (arch_val as Dictionary).get("instanceId", "") == instance_id:
|
||||
return arch_val
|
||||
return {}
|
||||
|
||||
|
||||
@@ -234,11 +312,13 @@ func board_height() -> int:
|
||||
# ── Server actions ────────────────────────────────────────────────────────────
|
||||
|
||||
func send_ready() -> void:
|
||||
print("[Game] >>> game.ready sessionId=", session_id)
|
||||
if debug_output:
|
||||
print("[Game] >>> game.ready sessionId=", session_id)
|
||||
Network.request("game.ready",
|
||||
{ "sessionId": session_id },
|
||||
func(_t: String, p: Variant) -> void:
|
||||
print("[Game] <<< game.ready.ack ", JSON.stringify(p))
|
||||
if debug_output:
|
||||
print("[Game] <<< game.ready.ack ", JSON.stringify(p))
|
||||
var d := p as Dictionary
|
||||
if d.get("status", "") == "AlreadyStarted":
|
||||
# Restore opponent name on rejoin — the server includes it in the ack.
|
||||
@@ -247,14 +327,21 @@ func send_ready() -> void:
|
||||
opponent_name = oname
|
||||
_fetch_state(),
|
||||
func(code: String, msg: String) -> void:
|
||||
print("[Game] ERR game.ready code=", code, " msg=", msg))
|
||||
if debug_output:
|
||||
print("[Game] ERR game.ready code=", code, " msg=", msg))
|
||||
|
||||
|
||||
func _fetch_state() -> void:
|
||||
if _syncing:
|
||||
return
|
||||
_syncing = true
|
||||
Network.request("game.get_state",
|
||||
{ "sessionId": session_id },
|
||||
func(_t: String, p: Variant) -> void: _apply_state_from_payload(p),
|
||||
func(_c: String, _m: String) -> void: pass)
|
||||
func(_t: String, p: Variant) -> void:
|
||||
_syncing = false
|
||||
_apply_state_from_payload(p),
|
||||
func(_c: String, _m: String) -> void:
|
||||
_syncing = false)
|
||||
|
||||
|
||||
func send_draw() -> void:
|
||||
@@ -344,31 +431,108 @@ func send_triggered_target_response(request_id: String, targets: Array) -> void:
|
||||
payload["targets"] = targets
|
||||
_game_request("game.triggered_target", payload)
|
||||
|
||||
|
||||
func send_cost_pick_response(request_id: String, selected_instance_ids: Array) -> void:
|
||||
_game_request("game.cost_pick", {
|
||||
"requestId": request_id,
|
||||
"selectedInstanceIds": selected_instance_ids
|
||||
})
|
||||
|
||||
|
||||
func send_cost_group_pick_response(request_id: String, choice_index: int) -> void:
|
||||
_game_request("game.cost_group_pick", {
|
||||
"requestId": request_id,
|
||||
"choiceIndex": choice_index
|
||||
})
|
||||
|
||||
|
||||
func send_action_group_pick_response(request_id: String, choice_index: int) -> void:
|
||||
_game_request("game.action_group_pick", {
|
||||
"requestId": request_id,
|
||||
"choiceIndex": choice_index
|
||||
})
|
||||
|
||||
|
||||
func send_branch_pick_response(request_id: String, branch_index: int) -> void:
|
||||
_game_request("game.branch_pick", {
|
||||
"requestId": request_id,
|
||||
"branchIndex": branch_index
|
||||
})
|
||||
|
||||
|
||||
func send_target_pick_response(request_id: String, targets: Array) -> void:
|
||||
var payload : Dictionary = { "requestId": request_id }
|
||||
if not targets.is_empty():
|
||||
payload["targets"] = targets
|
||||
_game_request("game.target_pick", payload)
|
||||
|
||||
|
||||
func send_tile_pick_response(request_id: String, x: int, y: int) -> void:
|
||||
_game_request("game.tile_pick", { "requestId": request_id, "x": x, "y": y })
|
||||
|
||||
|
||||
func send_player_pick_response(request_id: String, picked_player_id: String) -> void:
|
||||
_game_request("game.player_pick", {
|
||||
"requestId": request_id,
|
||||
"pickedPlayerId": picked_player_id
|
||||
})
|
||||
|
||||
|
||||
func send_reveal_choice_pick_response(request_id: String, ordered_indices: Array) -> void:
|
||||
_game_request("game.reveal_choice_pick", {
|
||||
"requestId": request_id,
|
||||
"orderedIndices": ordered_indices
|
||||
})
|
||||
|
||||
# ── Private ───────────────────────────────────────────────────────────────────
|
||||
|
||||
## Pick/response messages where the client optimistically tears down its prompt UI
|
||||
## before the server confirms. If the server rejects the pick, the pending prompt
|
||||
## still exists server-side — re-fetching state makes GameGetStateHandler re-push
|
||||
## it so the player is never stuck without a prompt.
|
||||
const _PROMPT_RESPONSE_TYPES: Array[String] = [
|
||||
"game.triggered_target", "game.cost_pick", "game.cost_group_pick",
|
||||
"game.action_group_pick", "game.branch_pick", "game.target_pick",
|
||||
"game.tile_pick", "game.player_pick", "game.reveal_choice_pick",
|
||||
]
|
||||
|
||||
func _game_request(msg_type: String, extra: Dictionary) -> void:
|
||||
var payload := { "sessionId": session_id }
|
||||
payload.merge(extra)
|
||||
print("[Game] >>> ", msg_type, " ", JSON.stringify(extra))
|
||||
if debug_output:
|
||||
print("[Game] >>> ", msg_type, " ", JSON.stringify(extra))
|
||||
Network.request(msg_type, payload,
|
||||
func(_t: String, p: Variant) -> void:
|
||||
print("[Game] <<< ", msg_type, ".ack payload=", JSON.stringify(p))
|
||||
if debug_output:
|
||||
print("[Game] <<< ", msg_type, ".ack payload=", JSON.stringify(p))
|
||||
_apply_state_from_payload(p),
|
||||
func(code: String, msg: String) -> void:
|
||||
print("[Game] ERR ", msg_type, " code=", code, " msg=", msg))
|
||||
if debug_output:
|
||||
print("[Game] ERR ", msg_type, " code=", code, " msg=", msg)
|
||||
if msg_type in _PROMPT_RESPONSE_TYPES:
|
||||
_fetch_state())
|
||||
|
||||
|
||||
func _apply_state_from_payload(p: Variant) -> void:
|
||||
var d := p as Dictionary
|
||||
var s := d.get("state", {}) as Dictionary
|
||||
if s.is_empty():
|
||||
print("[Game] _apply_state_from_payload: no 'state' key in payload ", JSON.stringify(p))
|
||||
if debug_output:
|
||||
print("[Game] _apply_state_from_payload: no 'state' key in payload ", JSON.stringify(p))
|
||||
return
|
||||
# Discard stale responses that belong to a session we have already left.
|
||||
var response_sid: String = str(s.get("sessionId", ""))
|
||||
if not session_id.is_empty() and not response_sid.is_empty() \
|
||||
and response_sid != session_id:
|
||||
if debug_output:
|
||||
print("[Game] _apply_state_from_payload: ignored stale response for session ", response_sid)
|
||||
return
|
||||
_state_version = int(s.get("stateVersion", -1))
|
||||
print("[Game] state applied phase=", s.get("phase","?"),
|
||||
" turn=", s.get("turnNumber","?"),
|
||||
" ver=", _state_version,
|
||||
" activePlayer=", str(s.get("activePlayerAccountId","?")).substr(0,8))
|
||||
if debug_output:
|
||||
print("[Game] state applied phase=", s.get("phase","?"),
|
||||
" turn=", s.get("turnNumber","?"),
|
||||
" ver=", _state_version,
|
||||
" activePlayer=", str(s.get("activePlayerAccountId","?")).substr(0,8))
|
||||
state = s
|
||||
state_updated.emit(state)
|
||||
|
||||
@@ -376,8 +540,12 @@ func _apply_state_from_payload(p: Variant) -> void:
|
||||
## Request a full state resync from the server (e.g. from in-game settings, or auto on missed delta).
|
||||
func request_sync() -> void:
|
||||
if session_id.is_empty(): return
|
||||
print("[Game] requesting full state sync")
|
||||
_fetch_state()
|
||||
if debug_output:
|
||||
print("[Game] requesting full state sync")
|
||||
if is_spectating:
|
||||
_request_spectator_state()
|
||||
else:
|
||||
_fetch_state()
|
||||
|
||||
|
||||
func _player_by_id(account_id: String) -> Dictionary:
|
||||
@@ -390,7 +558,8 @@ func _player_by_id(account_id: String) -> Dictionary:
|
||||
func _apply_delta(delta: Dictionary) -> void:
|
||||
# Helper: dict.get(key, default) returns null (not default) when the key exists with value null.
|
||||
# Use 'is Array' / 'is Dictionary' guards so typed assignment never receives null.
|
||||
print("DELTA: ", delta)
|
||||
if debug_output:
|
||||
print("DELTA: ", delta)
|
||||
# 1. Changed tiles
|
||||
var changed_tiles = delta.get("changedTiles")
|
||||
if changed_tiles is Array:
|
||||
@@ -507,7 +676,11 @@ func _apply_delta(delta: Dictionary) -> void:
|
||||
var arch_delta := arch_update.get("delta") as Dictionary
|
||||
if arch_delta.is_empty():
|
||||
continue
|
||||
var arch: Dictionary = player.get("archSpirit", {})
|
||||
var arch_val: Variant = player.get("archSpirit")
|
||||
if arch_val == null or not (arch_val is Dictionary):
|
||||
request_sync()
|
||||
continue
|
||||
var arch := arch_val as Dictionary
|
||||
if arch.is_empty():
|
||||
# Missing baseline (likely first sight of this arch). Ask for full sync.
|
||||
request_sync()
|
||||
@@ -538,10 +711,16 @@ func _apply_delta(delta: Dictionary) -> void:
|
||||
if meta.has("activePlayerAccountId") and meta["activePlayerAccountId"] != null: state["activePlayerAccountId"] = meta["activePlayerAccountId"]
|
||||
if meta.has("turnNumber") and meta["turnNumber"] != null: state["turnNumber"] = int(meta["turnNumber"])
|
||||
|
||||
# 10. Active effects (full replacement when changed)
|
||||
var active_effects = delta.get("activeEffects")
|
||||
if active_effects is Array:
|
||||
state["activeEffects"] = active_effects
|
||||
|
||||
_state_version = int(delta.get("stateVersion", _state_version))
|
||||
print("[Game] delta applied ver=", _state_version,
|
||||
" phase=", state.get("phase","?"),
|
||||
" turn=", state.get("turnNumber","?"))
|
||||
if debug_output:
|
||||
print("[Game] delta applied ver=", _state_version,
|
||||
" phase=", state.get("phase","?"),
|
||||
" turn=", state.get("turnNumber","?"))
|
||||
state_updated.emit(state)
|
||||
|
||||
|
||||
@@ -563,11 +742,14 @@ func _merge_unit_delta(unit: Dictionary, ud: Dictionary) -> void:
|
||||
if ud.has("effectsJson") and ud["effectsJson"] != null: unit["effectsJson"] = ud["effectsJson"]
|
||||
if ud.has("abilitiesJson") and ud["abilitiesJson"] != null: unit["abilitiesJson"] = ud["abilitiesJson"]
|
||||
if ud.has("abilityUsesJson") and ud["abilityUsesJson"] != null: unit["abilityUsesJson"] = ud["abilityUsesJson"]
|
||||
# art2dUrl and modelUrl are not merged from deltas — they are fixed per card definition
|
||||
# and are set once when the unit is added via unitsAdded (UnitSnapshot).
|
||||
|
||||
|
||||
func _on_server_push(type: String, payload: Variant) -> void:
|
||||
if type.begins_with("game.") or type.begins_with("matchmaking."):
|
||||
print("[Game] PUSH ", type, " ", JSON.stringify(payload).substr(0, 800))
|
||||
if debug_output:
|
||||
print("[Game] PUSH ", type, " ", JSON.stringify(payload).substr(0, 800))
|
||||
match type:
|
||||
"matchmaking.match_found":
|
||||
var d := payload as Dictionary
|
||||
@@ -583,15 +765,23 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
||||
var d := payload as Dictionary
|
||||
var s := d.get("state", {}) as Dictionary
|
||||
if not s.is_empty():
|
||||
# Drop stale spectator pushes that belong to a session we already left.
|
||||
var update_sid : String = str(s.get("sessionId", ""))
|
||||
if not session_id.is_empty() and update_sid != session_id:
|
||||
if debug_output:
|
||||
print("[Game] PUSH state_update IGNORED (wrong session): ", update_sid)
|
||||
return
|
||||
_state_version = int(s.get("stateVersion", -1))
|
||||
print("[Game] PUSH state_update phase=", s.get("phase","?"),
|
||||
" turn=", s.get("turnNumber","?"),
|
||||
" ver=", _state_version,
|
||||
" activePlayer=", str(s.get("activePlayerAccountId","?")).substr(0,8))
|
||||
if debug_output:
|
||||
print("[Game] PUSH state_update phase=", s.get("phase","?"),
|
||||
" turn=", s.get("turnNumber","?"),
|
||||
" ver=", _state_version,
|
||||
" activePlayer=", str(s.get("activePlayerAccountId","?")).substr(0,8))
|
||||
state = s
|
||||
state_updated.emit(state)
|
||||
else:
|
||||
print("[Game] PUSH state_update: no 'state' key")
|
||||
if debug_output:
|
||||
print("[Game] PUSH state_update: no 'state' key")
|
||||
|
||||
"game.state_delta":
|
||||
var d := payload as Dictionary
|
||||
@@ -602,11 +792,13 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
||||
# Already up to date — acting player received full state in ACK
|
||||
return
|
||||
if _state_version >= 0 and v > _state_version + 1:
|
||||
print("[Game] WARN: missed delta (have %d, got %d) — requesting full sync" \
|
||||
% [_state_version, v])
|
||||
if debug_output:
|
||||
print("[Game] WARN: missed delta (have %d, got %d) — requesting full sync" \
|
||||
% [_state_version, v])
|
||||
_fetch_state()
|
||||
return
|
||||
print("[Delta] ", delta)
|
||||
if debug_output:
|
||||
print("[Delta] ", delta)
|
||||
_apply_delta(delta)
|
||||
|
||||
"game.over":
|
||||
@@ -624,26 +816,30 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
||||
"game.session_abandoned":
|
||||
var d := payload as Dictionary
|
||||
var reason : String = str(d.get("reason", "unknown"))
|
||||
print("[Game] session abandoned: ", reason)
|
||||
if debug_output:
|
||||
print("[Game] session abandoned: ", reason)
|
||||
_clear_state()
|
||||
session_abandoned.emit(reason)
|
||||
|
||||
"game.opponent_inactive":
|
||||
var d := payload as Dictionary
|
||||
var sid : String = str(d.get("sessionId", ""))
|
||||
print("[Game] PUSH opponent_inactive session=", sid)
|
||||
if debug_output:
|
||||
print("[Game] PUSH opponent_inactive session=", sid)
|
||||
opponent_inactive.emit(sid)
|
||||
|
||||
"game.inactive_warning":
|
||||
var d := payload as Dictionary
|
||||
var sid : String = str(d.get("sessionId", ""))
|
||||
print("[Game] PUSH inactive_warning session=", sid)
|
||||
if debug_output:
|
||||
print("[Game] PUSH inactive_warning session=", sid)
|
||||
inactive_warning.emit(sid)
|
||||
|
||||
"game.both_idle_warning":
|
||||
var d := payload as Dictionary
|
||||
var sid : String = str(d.get("sessionId", ""))
|
||||
print("[Game] PUSH both_idle_warning session=", sid)
|
||||
if debug_output:
|
||||
print("[Game] PUSH both_idle_warning session=", sid)
|
||||
both_idle_warning.emit(sid)
|
||||
|
||||
"game.player_eliminated":
|
||||
@@ -662,3 +858,33 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
||||
|
||||
"game.ability.triggered_target_request":
|
||||
triggered_target_request.emit(payload as Dictionary)
|
||||
|
||||
"game.ability.cost_pick_request":
|
||||
cost_pick_request.emit(payload as Dictionary)
|
||||
|
||||
"game.ability.cost_group_pick_request":
|
||||
cost_group_pick_request.emit(payload as Dictionary)
|
||||
|
||||
"game.ability.action_group_pick_request":
|
||||
action_group_pick_request.emit(payload as Dictionary)
|
||||
|
||||
"game.ability.branch_pick_request":
|
||||
branch_pick_request.emit(payload as Dictionary)
|
||||
|
||||
"game.ability.target_pick_request":
|
||||
target_pick_request.emit(payload as Dictionary)
|
||||
|
||||
"game.ability.tile_pick_request":
|
||||
tile_pick_request.emit(payload as Dictionary)
|
||||
|
||||
"game.ability.player_pick_request":
|
||||
player_pick_request.emit(payload as Dictionary)
|
||||
|
||||
"game.ability.reveal_choice_pick_request":
|
||||
reveal_choice_pick_request.emit(payload as Dictionary)
|
||||
|
||||
"game.visual.repentance_placeholder":
|
||||
repentance_placeholder_visual.emit(payload as Dictionary)
|
||||
|
||||
"game.visual.ability_placeholder":
|
||||
ability_placeholder_visual.emit(payload as Dictionary)
|
||||
|
||||
@@ -15,6 +15,7 @@ extends Node
|
||||
## get_color() when get_texture() returns null.
|
||||
|
||||
signal loaded
|
||||
signal texture_loaded(type: String)
|
||||
|
||||
const CACHE_PATH := "user://highlight_config.json"
|
||||
const REQUEST_TYPE := "content.get_highlight_config"
|
||||
@@ -30,6 +31,7 @@ const DEFAULT_HEX : Dictionary = {
|
||||
|
||||
## Whether the server config has been loaded (or the cache has been used).
|
||||
var is_ready : bool = false
|
||||
var _fetch_in_flight : bool = false
|
||||
|
||||
# ── Internal state ─────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -50,7 +52,11 @@ var _pending_fetches : Dictionary = {}
|
||||
|
||||
func _ready() -> void:
|
||||
_load_cache()
|
||||
_fetch_from_server()
|
||||
_prefetch_known_textures()
|
||||
Auth.auth_success.connect(_on_auth_success)
|
||||
Network.connected.connect(_on_network_connected)
|
||||
if not Auth.user_id.is_empty():
|
||||
_fetch_from_server()
|
||||
|
||||
|
||||
# ── Public API ─────────────────────────────────────────────────────────────────
|
||||
@@ -58,6 +64,8 @@ func _ready() -> void:
|
||||
## 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:
|
||||
if not is_ready:
|
||||
_fetch_from_server()
|
||||
var key := type.to_lower()
|
||||
if _textures.has(key):
|
||||
return _textures[key]
|
||||
@@ -70,6 +78,8 @@ func get_texture(type: String) -> Texture2D:
|
||||
|
||||
## Returns the fallback Color for this highlight type.
|
||||
func get_color(type: String) -> Color:
|
||||
if not is_ready:
|
||||
_fetch_from_server()
|
||||
var key := type.to_lower()
|
||||
var cfg := _effective_config(key)
|
||||
var hex : String = cfg.get("fallbackHex", DEFAULT_HEX.get(key, "#FFFFFF66"))
|
||||
@@ -118,20 +128,29 @@ func _effective_config(key: String) -> Dictionary:
|
||||
|
||||
|
||||
func _fetch_from_server() -> void:
|
||||
if _fetch_in_flight:
|
||||
return
|
||||
if not Network.is_online():
|
||||
return
|
||||
if Auth.user_id.is_empty():
|
||||
return
|
||||
_fetch_in_flight = true
|
||||
Network.request(
|
||||
REQUEST_TYPE,
|
||||
{},
|
||||
func(_type: String, resp: Variant) -> void:
|
||||
_fetch_in_flight = false
|
||||
_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(code: String, msg: String) -> void:
|
||||
_fetch_in_flight = false
|
||||
if code not in ["DISCONNECTED", "AUTH_REQUIRED"]:
|
||||
push_warning("HighlightConfig: config fetch failed - %s %s" % [code, msg])
|
||||
)
|
||||
|
||||
|
||||
func _on_server_response(resp: Variant) -> void:
|
||||
var configs : Array = (resp as Dictionary).get("configs", [])
|
||||
_server_configs.clear()
|
||||
for entry : Dictionary in configs:
|
||||
var key : String = str(entry.get("highlightType", "")).to_lower()
|
||||
if key.is_empty():
|
||||
@@ -144,34 +163,51 @@ func _on_server_response(resp: Variant) -> void:
|
||||
"fallbackHex": str(entry.get("fallbackHex", DEFAULT_HEX.get(key, "#FFFFFF66"))),
|
||||
}
|
||||
_save_cache()
|
||||
_prefetch_known_textures()
|
||||
is_ready = true
|
||||
loaded.emit()
|
||||
|
||||
|
||||
func _on_auth_success(_user_id: String, _display_name: String) -> void:
|
||||
_fetch_from_server()
|
||||
|
||||
|
||||
func _on_network_connected() -> void:
|
||||
if not Auth.user_id.is_empty():
|
||||
_fetch_from_server()
|
||||
|
||||
|
||||
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", "")
|
||||
var url := _normalize_url(str(cfg.get("cdnPath", "")))
|
||||
if url.is_empty():
|
||||
return
|
||||
_pending_fetches[key] = true
|
||||
|
||||
var http := HTTPRequest.new()
|
||||
add_child(http)
|
||||
http.request_completed.connect(
|
||||
func(result: int, _code: int, _headers: PackedStringArray, body: PackedByteArray) -> void:
|
||||
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():
|
||||
if result != HTTPRequest.RESULT_SUCCESS or code != 200 or body.is_empty():
|
||||
push_warning("HighlightConfig: failed to download %s (result=%d http=%d url=%s)" % [key, result, code, url])
|
||||
return
|
||||
var img := Image.new()
|
||||
if img.load_png_from_buffer(body) != OK:
|
||||
if img.load_webp_from_buffer(body) != OK:
|
||||
return
|
||||
var err := _load_image_from_body(img, url, body)
|
||||
if err != OK:
|
||||
push_warning("HighlightConfig: failed to decode %s from %s" % [key, url])
|
||||
return
|
||||
var tex := ImageTexture.create_from_image(img)
|
||||
_textures[key] = tex
|
||||
texture_loaded.emit(key)
|
||||
)
|
||||
http.request(url)
|
||||
var err := http.request(url)
|
||||
if err != OK:
|
||||
_pending_fetches.erase(key)
|
||||
http.queue_free()
|
||||
push_warning("HighlightConfig: request start failed for %s (err=%d url=%s)" % [key, err, url])
|
||||
|
||||
|
||||
func _parse_hex(hex: String) -> Color:
|
||||
@@ -202,8 +238,39 @@ func _load_cache() -> void:
|
||||
|
||||
|
||||
func _save_cache() -> void:
|
||||
DirAccess.make_dir_recursive_absolute("user://")
|
||||
var f := FileAccess.open(CACHE_PATH, FileAccess.WRITE)
|
||||
if f == null:
|
||||
return
|
||||
f.store_string(JSON.stringify(_server_configs))
|
||||
f.close()
|
||||
|
||||
|
||||
func _prefetch_known_textures() -> void:
|
||||
for key in _server_configs.keys():
|
||||
var cfg := _effective_config(str(key))
|
||||
if not cfg.is_empty():
|
||||
_start_texture_load(str(key), cfg)
|
||||
for key in _overrides.keys():
|
||||
var cfg := _effective_config(str(key))
|
||||
if not cfg.is_empty():
|
||||
_start_texture_load(str(key), cfg)
|
||||
|
||||
|
||||
func _normalize_url(url: String) -> String:
|
||||
return url.strip_edges().replace(" ", "%20")
|
||||
|
||||
|
||||
func _load_image_from_body(img: Image, url: String, body: PackedByteArray) -> Error:
|
||||
var ext := url.split("?")[0].get_extension().to_lower()
|
||||
if ext in ["jpg", "jpeg"]:
|
||||
return img.load_jpg_from_buffer(body)
|
||||
if ext == "webp":
|
||||
return img.load_webp_from_buffer(body)
|
||||
var png_err := img.load_png_from_buffer(body)
|
||||
if png_err == OK:
|
||||
return OK
|
||||
var webp_err := img.load_webp_from_buffer(body)
|
||||
if webp_err == OK:
|
||||
return OK
|
||||
return img.load_jpg_from_buffer(body)
|
||||
|
||||
@@ -17,7 +17,7 @@ extends Node
|
||||
## stale .bin files from the old scheme are purged on first launch.
|
||||
|
||||
const _CACHE_DIR := "user://remote_model_cache"
|
||||
const _CACHE_VER := "v2" # bump this when the disk-key scheme changes
|
||||
const _CACHE_VER := "v3" # bump this when cached GLBs need to be re-fetched
|
||||
|
||||
# On web exports, direct CDN fetches are blocked by CORS (Ceph RadosGW doesn't send
|
||||
# Access-Control-Allow-Origin). Route through the game server proxy instead.
|
||||
@@ -30,6 +30,19 @@ static var _mem: Dictionary = {}
|
||||
# cache-key (String) → Array[Callable] (callbacks waiting on an in-flight download)
|
||||
static var _pending: Dictionary = {}
|
||||
|
||||
## Shared parse-budget cap. Both HTTP downloads and disk-cache parses count
|
||||
## against this limit because both call _parse_gltf() and spike the WASM heap.
|
||||
const _MAX_JOBS := 4
|
||||
|
||||
# Jobs queued while all slots are busy.
|
||||
# Each entry: { url, key, disk, parse_from_disk: bool }
|
||||
static var _job_queue: Array = []
|
||||
static var _active_jobs: int = 0
|
||||
|
||||
# Set to true during evict_all(); pending callbacks receive null instead of
|
||||
# firing into a freed scene context.
|
||||
static var _shutting_down: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
DirAccess.make_dir_recursive_absolute(_CACHE_DIR)
|
||||
@@ -69,6 +82,22 @@ func _migrate_cache() -> void:
|
||||
f.close()
|
||||
|
||||
|
||||
## Release a model from the in-memory cache without touching disk.
|
||||
## On iOS Safari this immediately frees resident memory when a unit leaves the board.
|
||||
## On other platforms this is a no-op — the OS manages heap pressure.
|
||||
## Disk cache (.bin) is intentionally kept so the model reloads instantly if the same
|
||||
## unit type is played again in the same session.
|
||||
func release_model(url: String, etag: String = "") -> void:
|
||||
if url.is_empty():
|
||||
return
|
||||
if not Platform.is_ios_safari():
|
||||
return
|
||||
var key := _cache_key(url, etag)
|
||||
_mem.erase(key)
|
||||
if OS.is_debug_build():
|
||||
print("ModelCache: released %s (mem_entries=%d)" % [url, _mem.size()])
|
||||
|
||||
|
||||
## Remove a cached entry (memory + disk) so the next load_model call re-downloads it.
|
||||
## Use before retrying a previously-failed URL.
|
||||
func evict(url: String, etag: String = "") -> void:
|
||||
@@ -79,12 +108,40 @@ func evict(url: String, etag: String = "") -> void:
|
||||
DirAccess.remove_absolute(disk)
|
||||
|
||||
|
||||
## Drop all in-memory PackedScene references and flush the pending queue.
|
||||
## Sets _shutting_down first so any in-flight HTTP callbacks that complete
|
||||
## after scene teardown return null instead of firing into freed nodes.
|
||||
## Disk cache (.bin files) is intentionally left intact so subsequent
|
||||
## sessions still benefit from skipping re-downloads.
|
||||
func evict_all() -> void:
|
||||
_shutting_down = true
|
||||
|
||||
# Flush all queued callbacks with null so callers don't hang.
|
||||
for key: String in _pending:
|
||||
for cb: Callable in _pending[key]:
|
||||
cb.call(null)
|
||||
_pending.clear()
|
||||
|
||||
_mem.clear()
|
||||
_job_queue.clear()
|
||||
# _active_jobs is intentionally left alone; in-flight HTTPRequest nodes own
|
||||
# those slots and will call _finish_job() when complete (draining an empty queue).
|
||||
|
||||
# Re-arm immediately so load_model() works for the next game.
|
||||
_shutting_down = false
|
||||
|
||||
if OS.is_debug_build():
|
||||
print("ModelCache: evict_all complete")
|
||||
|
||||
## Request a model by CDN URL.
|
||||
## callback(node: Node3D) is called on the main thread; node may be null.
|
||||
## If the same URL+ETag is already downloading, callbacks are queued and all
|
||||
## fire together when the download completes.
|
||||
## etag: the ContentETag from the server DTO (empty string = no etag, use URL only).
|
||||
func load_model(url: String, callback: Callable, etag: String = "") -> void:
|
||||
if _shutting_down:
|
||||
callback.call(null)
|
||||
return
|
||||
var key := _cache_key(url, etag)
|
||||
var disk := _disk_path(url, etag)
|
||||
|
||||
@@ -94,27 +151,32 @@ func load_model(url: String, callback: Callable, etag: String = "") -> void:
|
||||
callback.call(packed.instantiate() if packed != null else null)
|
||||
return
|
||||
|
||||
# 2 — disk hit (bytes from previous session)
|
||||
if FileAccess.file_exists(disk):
|
||||
var bytes := FileAccess.get_file_as_bytes(disk)
|
||||
if not bytes.is_empty():
|
||||
var packed := _parse_gltf(bytes)
|
||||
if packed != null:
|
||||
_mem[key] = packed
|
||||
callback.call(packed.instantiate())
|
||||
return
|
||||
# Corrupted cache file — delete and re-download.
|
||||
push_warning("ModelCache: deleting corrupt disk cache for %s" % url)
|
||||
DirAccess.remove_absolute(disk)
|
||||
|
||||
# 3 — already downloading → queue
|
||||
# 2 — already in-flight
|
||||
if _pending.has(key):
|
||||
_pending[key].append(callback)
|
||||
return
|
||||
|
||||
# 4 — start download
|
||||
# 3 — disk hit; queue a parse-only job if all slots are busy
|
||||
if FileAccess.file_exists(disk):
|
||||
_pending[key] = [callback]
|
||||
if _active_jobs < _MAX_JOBS:
|
||||
_active_jobs += 1
|
||||
_parse_disk_job(key, disk, url)
|
||||
else:
|
||||
_job_queue.append({ "url": url, "key": key, "disk": disk, "parse_from_disk": true })
|
||||
if OS.is_debug_build():
|
||||
print("ModelCache: disk-hit queued %s (jobs=%d queued=%d)" % [url, _active_jobs, _job_queue.size()])
|
||||
return
|
||||
|
||||
# 4 — start a network download
|
||||
_pending[key] = [callback]
|
||||
_download(url, key, disk)
|
||||
if _active_jobs < _MAX_JOBS:
|
||||
_active_jobs += 1
|
||||
_download(url, key, disk)
|
||||
else:
|
||||
_job_queue.append({ "url": url, "key": key, "disk": disk, "parse_from_disk": false })
|
||||
if OS.is_debug_build():
|
||||
print("ModelCache: net-queued %s (jobs=%d queued=%d)" % [url, _active_jobs, _job_queue.size()])
|
||||
|
||||
|
||||
## Returns the URL to actually fetch — on web, rewrites CDN URLs to go through
|
||||
@@ -125,23 +187,44 @@ func _fetch_url(url: String) -> String:
|
||||
return url
|
||||
|
||||
|
||||
## Parse a disk-cached model within a job slot.
|
||||
## Falls through to _download() if the disk file is corrupt or missing.
|
||||
func _parse_disk_job(key: String, disk: String, url: String) -> void:
|
||||
var bytes := FileAccess.get_file_as_bytes(disk)
|
||||
if not bytes.is_empty():
|
||||
var packed := _parse_gltf(bytes)
|
||||
if packed != null:
|
||||
_mem[key] = packed
|
||||
var callbacks: Array = _pending.get(key, [])
|
||||
_pending.erase(key)
|
||||
for cb: Callable in callbacks:
|
||||
if not _shutting_down:
|
||||
cb.call(packed.instantiate())
|
||||
_finish_job()
|
||||
return
|
||||
push_warning("ModelCache: corrupt disk cache for %s — re-downloading" % url)
|
||||
DirAccess.remove_absolute(disk)
|
||||
# Re-use the already-acquired job slot for the network download.
|
||||
_download(url, key, disk)
|
||||
|
||||
|
||||
func _download(url: String, key: String, disk: String) -> void:
|
||||
var fetch := _fetch_url(url)
|
||||
print("ModelCache: downloading — %s" % fetch)
|
||||
if OS.is_debug_build():
|
||||
print("ModelCache: downloading %s (active_jobs=%d)" % [fetch, _active_jobs])
|
||||
var http := HTTPRequest.new()
|
||||
http.body_size_limit = -1 # unlimited
|
||||
http.body_size_limit = -1
|
||||
add_child(http)
|
||||
|
||||
# CONNECT_ONE_SHOT auto-disconnects after first fire.
|
||||
http.request_completed.connect(
|
||||
func(res: int, code: int, headers: PackedStringArray, body: PackedByteArray):
|
||||
# Disconnect and free the requester before anything else.
|
||||
http.get_signal_connection_list("request_completed").clear()
|
||||
http.queue_free()
|
||||
|
||||
var callbacks: Array = _pending.get(key, [])
|
||||
_pending.erase(key)
|
||||
|
||||
# Log details to help diagnose content-type / truncation issues.
|
||||
# Log content-type and first bytes for CDN diagnosis.
|
||||
var ct := ""
|
||||
for h: String in headers:
|
||||
if h.to_lower().begins_with("content-type"):
|
||||
@@ -150,42 +233,44 @@ func _download(url: String, key: String, disk: String) -> void:
|
||||
var first_hex := ""
|
||||
for i in mini(16, body.size()):
|
||||
first_hex += "%02X " % body[i]
|
||||
print("ModelCache: result=%d http=%d size=%d [%s] first=[%s]" \
|
||||
% [res, code, body.size(), ct, first_hex.strip_edges()])
|
||||
if OS.is_debug_build():
|
||||
print("ModelCache: result=%d http=%d size=%d [%s] first=[%s]" % [res, code, body.size(), ct, first_hex.strip_edges()])
|
||||
|
||||
# res is the HTTPRequest.Result enum; anything != 0 means a network error.
|
||||
if res != HTTPRequest.RESULT_SUCCESS:
|
||||
push_warning("ModelCache: network error result=%d http=%d — %s" % [res, code, url])
|
||||
for cb: Callable in callbacks:
|
||||
cb.call(null)
|
||||
return
|
||||
if not _shutting_down: cb.call(null)
|
||||
_finish_job(); return
|
||||
|
||||
if code < 200 or code >= 300:
|
||||
push_warning("ModelCache: HTTP %d — %s" % [code, url])
|
||||
for cb: Callable in callbacks:
|
||||
cb.call(null)
|
||||
return
|
||||
if not _shutting_down: cb.call(null)
|
||||
_finish_job(); return
|
||||
|
||||
if body.is_empty():
|
||||
push_warning("ModelCache: empty response — %s" % url)
|
||||
for cb: Callable in callbacks:
|
||||
cb.call(null)
|
||||
return
|
||||
if not _shutting_down: cb.call(null)
|
||||
_finish_job(); return
|
||||
|
||||
# Parse directly from the downloaded bytes — avoids any file-path quirks.
|
||||
var packed := _parse_gltf(body)
|
||||
_mem[key] = packed
|
||||
_mem[key] = packed
|
||||
|
||||
if packed != null:
|
||||
# Only write a good file to the disk cache.
|
||||
var f := FileAccess.open(disk, FileAccess.WRITE)
|
||||
if f:
|
||||
f.store_buffer(body)
|
||||
f.close()
|
||||
|
||||
if OS.is_debug_build():
|
||||
print("ModelCache: parsed ok=%s mem_entries=%d active_jobs=%d" % [packed != null, _mem.size(), _active_jobs])
|
||||
|
||||
for cb: Callable in callbacks:
|
||||
cb.call(packed.instantiate() if packed != null else null)
|
||||
)
|
||||
if not _shutting_down:
|
||||
cb.call(packed.instantiate() if packed != null else null)
|
||||
_finish_job()
|
||||
, CONNECT_ONE_SHOT)
|
||||
|
||||
var err := http.request(fetch)
|
||||
if err != OK:
|
||||
@@ -193,9 +278,20 @@ func _download(url: String, key: String, disk: String) -> void:
|
||||
var callbacks: Array = _pending.get(key, [])
|
||||
_pending.erase(key)
|
||||
for cb: Callable in callbacks:
|
||||
cb.call(null)
|
||||
http.get_signal_connection_list("request_completed").clear()
|
||||
if not _shutting_down: cb.call(null)
|
||||
http.queue_free()
|
||||
_finish_job()
|
||||
|
||||
|
||||
func _finish_job() -> void:
|
||||
_active_jobs = maxi(0, _active_jobs - 1)
|
||||
if not _job_queue.is_empty() and _active_jobs < _MAX_JOBS:
|
||||
var next: Dictionary = _job_queue.pop_front()
|
||||
_active_jobs += 1
|
||||
if next.get("parse_from_disk", false):
|
||||
_parse_disk_job(next["key"], next["disk"], next["url"])
|
||||
else:
|
||||
_download(next["url"], next["key"], next["disk"])
|
||||
|
||||
|
||||
# Parse GLB/GLTF bytes using GLTFDocument.append_from_buffer.
|
||||
|
||||
@@ -1,153 +1,295 @@
|
||||
extends Node
|
||||
## Music autoload — fetches BGM config from the server and plays context-appropriate tracks.
|
||||
## Music autoload - fetches BGM config from the server and plays context-appropriate tracks.
|
||||
##
|
||||
## Usage:
|
||||
## Music.play_context("Game") # start/crossfade to the Game context track
|
||||
## Music.play_context("Lobby") # switch to Lobby context
|
||||
## Music.stop() # fade out and stop
|
||||
## Scene routing:
|
||||
## - GameScreen -> Game
|
||||
## - FreePlay / LobbyRoom -> Lobby
|
||||
## - Everything else -> Menu
|
||||
##
|
||||
## Volume and mute are controlled via Settings.music_volume / Settings.music_muted.
|
||||
## This node streams audio via an AudioStreamPlayer on the "Music" bus.
|
||||
## This node streams audio via AudioStreamPlayers on the "Music" bus.
|
||||
|
||||
const CROSSFADE_DURATION := 1.2 # seconds
|
||||
const CONTEXT_AUDIO_MSG := "content.get_audio_config"
|
||||
const CROSSFADE_DURATION := 1.2
|
||||
const CONTEXT_AUDIO_MSG := "content.get_audio_config"
|
||||
|
||||
## _tracks[context] = Array of { "name": String, "url": String }
|
||||
var _tracks : Dictionary = {}
|
||||
var _current_context: String = ""
|
||||
var _player_a : AudioStreamPlayer
|
||||
var _player_b : AudioStreamPlayer
|
||||
var _active_player : AudioStreamPlayer # the one currently audible
|
||||
const CONTEXT_MENU := "Menu"
|
||||
const CONTEXT_LOBBY := "Lobby"
|
||||
const CONTEXT_GAME := "Game"
|
||||
|
||||
const LOBBY_SCENES := {
|
||||
"res://scenes/free_play/FreePlayScreen.tscn": true,
|
||||
"res://scenes/free_play/LobbyRoomScreen.tscn": true,
|
||||
}
|
||||
|
||||
const GAME_SCENES := {
|
||||
"res://scenes/game/GameScreen.tscn": true,
|
||||
}
|
||||
|
||||
var _tracks: Dictionary = {}
|
||||
var _stream_cache: Dictionary = {}
|
||||
var _current_context: String = ""
|
||||
var _current_url: String = ""
|
||||
var _desired_context: String = ""
|
||||
var _last_scene_path: String = ""
|
||||
var _config_loaded: bool = false
|
||||
var _request_serial: int = 0
|
||||
|
||||
var _player_a: AudioStreamPlayer
|
||||
var _player_b: AudioStreamPlayer
|
||||
var _active_player: AudioStreamPlayer
|
||||
var _fade_tween: Tween = null
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
_player_a = _make_player()
|
||||
_player_b = _make_player()
|
||||
_active_player = _player_a
|
||||
|
||||
# Fetch BGM config once at startup (connection must be established by then).
|
||||
# Scenes that start music will typically call play_context after login.
|
||||
Auth.auth_success.connect(_on_auth_success)
|
||||
Auth.session_expired.connect(_on_session_expired)
|
||||
Settings.settings_changed.connect(_sync_player_volumes)
|
||||
|
||||
set_process(true)
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
var scene := get_tree().current_scene
|
||||
if scene == null:
|
||||
return
|
||||
|
||||
var scene_path := scene.scene_file_path
|
||||
if scene_path == _last_scene_path:
|
||||
return
|
||||
|
||||
_last_scene_path = scene_path
|
||||
var next_context := _context_for_scene(scene_path)
|
||||
if next_context.is_empty():
|
||||
stop()
|
||||
else:
|
||||
play_context(next_context)
|
||||
|
||||
|
||||
func _make_player() -> AudioStreamPlayer:
|
||||
var p := AudioStreamPlayer.new()
|
||||
p.bus = Settings.BUS_MUSIC
|
||||
p.volume_db = linear_to_db(Settings.music_volume) if not Settings.music_muted else -80.0
|
||||
add_child(p)
|
||||
return p
|
||||
var player := AudioStreamPlayer.new()
|
||||
player.bus = Settings.BUS_MUSIC
|
||||
player.volume_db = _target_volume_db()
|
||||
add_child(player)
|
||||
return player
|
||||
|
||||
# ── Public API ─────────────────────────────────────────────────────────────────
|
||||
|
||||
## Fetch the BGM track list from the server.
|
||||
## Call this once after the player is authenticated and connected.
|
||||
func fetch_config() -> void:
|
||||
Network.request(CONTEXT_AUDIO_MSG, {},
|
||||
func(_type: String, resp: Variant) -> void:
|
||||
var d := resp as Dictionary
|
||||
if not d.has("tracks"):
|
||||
return
|
||||
var data := resp as Dictionary
|
||||
_tracks.clear()
|
||||
for t: Dictionary in d.get("tracks", []):
|
||||
var ctx : String = str(t.get("context", ""))
|
||||
if ctx.is_empty():
|
||||
for entry: Dictionary in data.get("tracks", []):
|
||||
var context := str(entry.get("context", "")).strip_edges()
|
||||
var url := str(entry.get("trackCdnUrl", "")).strip_edges()
|
||||
if context.is_empty() or url.is_empty():
|
||||
continue
|
||||
if not _tracks.has(ctx):
|
||||
_tracks[ctx] = []
|
||||
_tracks[ctx].append({
|
||||
"name": str(t.get("trackName", "")),
|
||||
"url": str(t.get("trackCdnUrl", "")),
|
||||
}),
|
||||
if not _tracks.has(context):
|
||||
_tracks[context] = []
|
||||
_tracks[context].append({
|
||||
"name": str(entry.get("trackName", "")),
|
||||
"url": url,
|
||||
})
|
||||
|
||||
_config_loaded = true
|
||||
_apply_desired_context(),
|
||||
func(code: String, msg: String) -> void:
|
||||
push_warning("Music: fetch_config failed — %s: %s" % [code, msg]))
|
||||
_config_loaded = false
|
||||
push_warning("Music: fetch_config failed - %s: %s" % [code, msg]))
|
||||
|
||||
## Start playing a track for the given context.
|
||||
## Crossfades from the currently playing track. No-ops if already on this context.
|
||||
func play_context(ctx: String) -> void:
|
||||
if ctx == _current_context:
|
||||
|
||||
func play_context(context: String) -> void:
|
||||
_desired_context = context
|
||||
_apply_desired_context()
|
||||
|
||||
|
||||
func stop() -> void:
|
||||
_desired_context = ""
|
||||
_current_context = ""
|
||||
_current_url = ""
|
||||
_request_serial += 1
|
||||
_stop_inactive_player()
|
||||
_fade_out(_active_player)
|
||||
|
||||
|
||||
func _apply_desired_context() -> void:
|
||||
if _desired_context.is_empty():
|
||||
return
|
||||
if not _config_loaded:
|
||||
return
|
||||
if _desired_context == _current_context and not _current_url.is_empty() and _active_player.playing:
|
||||
_sync_player_volumes()
|
||||
return
|
||||
_current_context = ctx
|
||||
|
||||
var list : Array = _tracks.get(ctx, [])
|
||||
if list.is_empty():
|
||||
var options: Array = _tracks.get(_desired_context, [])
|
||||
if options.is_empty():
|
||||
stop()
|
||||
return
|
||||
|
||||
var entry : Dictionary = list[randi() % list.size()]
|
||||
var url : String = str(entry.get("url", ""))
|
||||
var entry: Dictionary = options[randi() % options.size()]
|
||||
var url := str(entry.get("url", ""))
|
||||
if url.is_empty():
|
||||
stop()
|
||||
return
|
||||
if url == _current_url and _active_player.playing:
|
||||
_current_context = _desired_context
|
||||
_sync_player_volumes()
|
||||
return
|
||||
|
||||
_crossfade_to(url)
|
||||
_request_serial += 1
|
||||
var serial := _request_serial
|
||||
_crossfade_to(url, _desired_context, serial)
|
||||
|
||||
## Stop music with a short fade-out.
|
||||
func stop() -> void:
|
||||
_current_context = ""
|
||||
_fade_out(_active_player)
|
||||
|
||||
# ── Internal ──────────────────────────────────────────────────────────────────
|
||||
|
||||
func _crossfade_to(url: String) -> void:
|
||||
var next : AudioStreamPlayer = _player_b if _active_player == _player_a else _player_a
|
||||
|
||||
# Load stream from URL (Godot's ResourceLoader supports http URLs if configured,
|
||||
# otherwise fall back to local path for bundled tracks).
|
||||
func _crossfade_to(url: String, context: String, serial: int) -> void:
|
||||
var next: AudioStreamPlayer = _player_b if _active_player == _player_a else _player_a
|
||||
var stream := await _load_stream(url)
|
||||
if serial != _request_serial:
|
||||
return
|
||||
if stream == null:
|
||||
return
|
||||
|
||||
next.stream = stream
|
||||
if _fade_tween != null:
|
||||
_fade_tween.kill()
|
||||
_fade_tween = null
|
||||
|
||||
next.stream = stream
|
||||
next.volume_db = -80.0
|
||||
next.play()
|
||||
|
||||
var tween := create_tween().set_parallel(true)
|
||||
tween.tween_property(next, "volume_db",
|
||||
linear_to_db(Settings.music_volume) if not Settings.music_muted else -80.0,
|
||||
CROSSFADE_DURATION)
|
||||
tween.tween_property(_active_player, "volume_db", -80.0, CROSSFADE_DURATION)
|
||||
await tween.finished
|
||||
_fade_tween = create_tween().set_parallel(true)
|
||||
_fade_tween.tween_property(next, "volume_db", _target_volume_db(), CROSSFADE_DURATION)
|
||||
_fade_tween.tween_property(_active_player, "volume_db", -80.0, CROSSFADE_DURATION)
|
||||
await _fade_tween.finished
|
||||
|
||||
if serial != _request_serial:
|
||||
return
|
||||
|
||||
_active_player.stop()
|
||||
_active_player = next
|
||||
_current_context = context
|
||||
_current_url = url
|
||||
_fade_tween = null
|
||||
_stop_inactive_player()
|
||||
_sync_player_volumes()
|
||||
|
||||
|
||||
func _fade_out(player: AudioStreamPlayer) -> void:
|
||||
if not player.playing:
|
||||
if player == null or not player.playing:
|
||||
return
|
||||
var tween := create_tween()
|
||||
tween.tween_property(player, "volume_db", -80.0, CROSSFADE_DURATION)
|
||||
await tween.finished
|
||||
player.stop()
|
||||
|
||||
if _fade_tween != null:
|
||||
_fade_tween.kill()
|
||||
_fade_tween = null
|
||||
|
||||
_fade_tween = create_tween()
|
||||
_fade_tween.tween_property(player, "volume_db", -80.0, CROSSFADE_DURATION)
|
||||
await _fade_tween.finished
|
||||
if player == _active_player and _request_serial >= 0:
|
||||
player.stop()
|
||||
player.stream = null
|
||||
_fade_tween = null
|
||||
|
||||
|
||||
func _stop_inactive_player() -> void:
|
||||
var inactive: AudioStreamPlayer = _player_b if _active_player == _player_a else _player_a
|
||||
inactive.stop()
|
||||
inactive.stream = null
|
||||
inactive.volume_db = -80.0
|
||||
|
||||
|
||||
func _sync_player_volumes() -> void:
|
||||
var target_db := _target_volume_db()
|
||||
if _fade_tween != null:
|
||||
if _active_player.playing:
|
||||
_active_player.volume_db = target_db
|
||||
return
|
||||
|
||||
if _active_player.playing:
|
||||
_active_player.volume_db = target_db
|
||||
var inactive: AudioStreamPlayer = _player_b if _active_player == _player_a else _player_a
|
||||
if not inactive.playing:
|
||||
inactive.volume_db = -80.0
|
||||
|
||||
|
||||
func _target_volume_db() -> float:
|
||||
if Settings.music_muted or Settings.music_volume <= 0.0:
|
||||
return -80.0
|
||||
return linear_to_db(Settings.music_volume)
|
||||
|
||||
|
||||
func _context_for_scene(scene_path: String) -> String:
|
||||
if scene_path.is_empty():
|
||||
return ""
|
||||
if GAME_SCENES.has(scene_path):
|
||||
return CONTEXT_GAME
|
||||
if LOBBY_SCENES.has(scene_path):
|
||||
return CONTEXT_LOBBY
|
||||
return CONTEXT_MENU
|
||||
|
||||
|
||||
func _on_auth_success(_user_id: String, _display_name: String) -> void:
|
||||
fetch_config()
|
||||
|
||||
|
||||
func _on_session_expired() -> void:
|
||||
_tracks.clear()
|
||||
_stream_cache.clear()
|
||||
_config_loaded = false
|
||||
_last_scene_path = ""
|
||||
stop()
|
||||
|
||||
|
||||
func _load_stream(url: String) -> AudioStream:
|
||||
# If it looks like a local resource path, load directly.
|
||||
if url.begins_with("res://") or url.begins_with("user://"):
|
||||
return load(url) as AudioStream
|
||||
if _stream_cache.has(url):
|
||||
return _stream_cache[url] as AudioStream
|
||||
|
||||
# For CDN URLs: use HTTPRequest to download and create stream from bytes.
|
||||
# This is an async download approach compatible with Godot 4.
|
||||
var stream: AudioStream = null
|
||||
if url.begins_with("res://") or url.begins_with("user://"):
|
||||
stream = load(url) as AudioStream
|
||||
else:
|
||||
stream = await _load_remote_stream(url)
|
||||
|
||||
if stream != null:
|
||||
_stream_cache[url] = stream
|
||||
return stream
|
||||
|
||||
|
||||
func _load_remote_stream(url: String) -> AudioStream:
|
||||
var request_url := _normalize_remote_url(url)
|
||||
var http := HTTPRequest.new()
|
||||
add_child(http)
|
||||
http.request(url)
|
||||
var result : Array = await http.request_completed
|
||||
var err := http.request(request_url)
|
||||
if err != OK:
|
||||
http.queue_free()
|
||||
push_warning("Music: request failed for %s (err %d)" % [request_url, err])
|
||||
return null
|
||||
|
||||
var result: Array = await http.request_completed
|
||||
http.queue_free()
|
||||
|
||||
var response_code : int = result[1]
|
||||
var body : PackedByteArray = result[3]
|
||||
var response_code: int = int(result[1])
|
||||
var body: PackedByteArray = result[3]
|
||||
if response_code != 200 or body.is_empty():
|
||||
push_warning("Music: failed to download %s (HTTP %d)" % [url, response_code])
|
||||
return null
|
||||
|
||||
# Determine format from URL extension and create appropriate stream.
|
||||
var ext := url.get_extension().to_lower()
|
||||
if ext == "ogg":
|
||||
return AudioStreamOggVorbis.load_from_buffer(body)
|
||||
elif ext in ["mp3"]:
|
||||
var stream := AudioStreamMP3.new()
|
||||
stream.data = body
|
||||
return stream
|
||||
elif ext == "wav":
|
||||
# WAV loading from bytes is not directly supported; warn and return null.
|
||||
push_warning("Music: WAV from URL not supported. Use OGG or MP3.")
|
||||
return null
|
||||
if ext == "mp3":
|
||||
var mp3 := AudioStreamMP3.new()
|
||||
mp3.data = body
|
||||
return mp3
|
||||
if ext == "wav":
|
||||
return AudioStreamWAV.load_from_buffer(body)
|
||||
|
||||
push_warning("Music: unknown audio format '%s'" % ext)
|
||||
push_warning("Music: unsupported format '%s'" % ext)
|
||||
return null
|
||||
|
||||
|
||||
func _normalize_remote_url(url: String) -> String:
|
||||
return url.replace(" ", "%20")
|
||||
|
||||
@@ -234,10 +234,22 @@ func _poll_packets() -> void:
|
||||
_last_rx_time = _now()
|
||||
_ping_sent_at = -1.0 # Any received packet resets the ping watchdog.
|
||||
|
||||
if raw.size() == 0 or text.strip_edges().is_empty():
|
||||
if debug_log_packets:
|
||||
print("[Net] << <empty packet>")
|
||||
continue
|
||||
|
||||
if debug_log_packets:
|
||||
print("[Net] << %s" % text)
|
||||
|
||||
var parsed: Variant = JSON.parse_string(text)
|
||||
var json := JSON.new()
|
||||
var err := json.parse(text)
|
||||
if err != OK:
|
||||
push_warning("Network: invalid JSON packet (%s) — %s"
|
||||
% [json.get_error_message(), text])
|
||||
continue
|
||||
|
||||
var parsed: Variant = json.data
|
||||
#print("[Parsed Type] ", type_string(typeof(parsed)))
|
||||
if typeof(parsed) != TYPE_DICTIONARY:
|
||||
if (parsed != null):
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
extends Node
|
||||
## Platform — thin detection helpers for per-platform code paths.
|
||||
##
|
||||
## Usage:
|
||||
## if Platform.is_ios_safari():
|
||||
## ... # memory-constrained path
|
||||
|
||||
## Returns true when running on iOS Safari (web export, Safari UA, iPhone/iPad,
|
||||
## not Chrome/CriOS). Used to gate memory-reduction paths for the ~300 MB per-tab
|
||||
## limit that iOS Safari enforces.
|
||||
static func is_ios_safari() -> bool:
|
||||
if not OS.has_feature("web"):
|
||||
return false
|
||||
var ua: String = JavaScriptBridge.eval("navigator.userAgent")
|
||||
var has_safari: bool = ua.contains("Safari")
|
||||
var has_chrome: bool = ua.contains("Chrome") or ua.contains("CriOS")
|
||||
var is_ios_device: bool = ua.contains("iPhone") or ua.contains("iPad")
|
||||
return has_safari and not has_chrome and is_ios_device
|
||||
@@ -0,0 +1 @@
|
||||
uid://boknaojgo0qni
|
||||
@@ -1,73 +1,92 @@
|
||||
extends Node
|
||||
## SFX autoload — fire-and-forget sound effects from CDN URLs.
|
||||
## SFX autoload - fire-and-forget sound effects from local assets or CDN URLs.
|
||||
##
|
||||
## Usage:
|
||||
## SFX.play("https://cdn.sor.gg/sfx/attack.ogg") # fire-and-forget
|
||||
## SFX.play("https://cdn.example.com/sfx/attack.wav")
|
||||
##
|
||||
## Volume and mute are applied globally through the "SFX" AudioServer bus
|
||||
## (managed by Settings.sfx_volume / Settings.sfx_muted).
|
||||
## Downloaded streams are cached in memory for the session so each URL
|
||||
## only hits the network once.
|
||||
|
||||
const POOL_SIZE := 8 # max simultaneous SFX
|
||||
const POOL_SIZE := 8
|
||||
|
||||
var _pool : Array[AudioStreamPlayer] = []
|
||||
var _cache : Dictionary = {} # url → AudioStream
|
||||
var _pool: Array[AudioStreamPlayer] = []
|
||||
var _cache: Dictionary = {}
|
||||
var _in_flight: Dictionary = {}
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
for _i in POOL_SIZE:
|
||||
var p := AudioStreamPlayer.new()
|
||||
p.bus = Settings.BUS_SFX
|
||||
add_child(p)
|
||||
_pool.append(p)
|
||||
var player := AudioStreamPlayer.new()
|
||||
player.bus = Settings.BUS_SFX
|
||||
add_child(player)
|
||||
_pool.append(player)
|
||||
|
||||
# ── Public API ────────────────────────────────────────────────────────────────
|
||||
|
||||
## Play [param url] asynchronously (fire-and-forget).
|
||||
## No-ops if url is empty or the download fails.
|
||||
func play(url: String) -> void:
|
||||
if url.is_empty():
|
||||
url = url.strip_edges()
|
||||
if not _is_supported_url(url):
|
||||
return
|
||||
_play_async(url)
|
||||
|
||||
# ── Internal ──────────────────────────────────────────────────────────────────
|
||||
|
||||
func prime(url: String) -> void:
|
||||
url = url.strip_edges()
|
||||
if not _is_supported_url(url):
|
||||
return
|
||||
if _cache.has(url) or _in_flight.has(url):
|
||||
return
|
||||
_prime_async(url)
|
||||
|
||||
|
||||
func _play_async(url: String) -> void:
|
||||
var stream : AudioStream = _cache.get(url, null)
|
||||
var stream: AudioStream = _cache.get(url, null)
|
||||
if stream == null:
|
||||
stream = await _load_stream(url)
|
||||
if _in_flight.has(url):
|
||||
await _in_flight[url]
|
||||
stream = _cache.get(url, null)
|
||||
else:
|
||||
stream = await _load_and_cache(url)
|
||||
if stream == null:
|
||||
return
|
||||
_cache[url] = stream
|
||||
|
||||
var player := _get_free_player()
|
||||
player.stream = stream
|
||||
player.play()
|
||||
|
||||
|
||||
func _prime_async(url: String) -> void:
|
||||
await _load_and_cache(url)
|
||||
|
||||
|
||||
func _get_free_player() -> AudioStreamPlayer:
|
||||
for p : AudioStreamPlayer in _pool:
|
||||
if not p.playing:
|
||||
return p
|
||||
# All slots busy — steal the oldest (index 0, round-robin would be nicer
|
||||
# but overkill for 8-slot game SFX).
|
||||
for player: AudioStreamPlayer in _pool:
|
||||
if not player.playing:
|
||||
return player
|
||||
return _pool[0]
|
||||
|
||||
|
||||
func _load_stream(url: String) -> AudioStream:
|
||||
if url.begins_with("res://") or url.begins_with("user://"):
|
||||
return load(url) as AudioStream
|
||||
if not (url.begins_with("http://") or url.begins_with("https://")):
|
||||
return null
|
||||
|
||||
var request_url := _normalize_remote_url(url)
|
||||
var http := HTTPRequest.new()
|
||||
add_child(http)
|
||||
http.request(url)
|
||||
var result : Array = await http.request_completed
|
||||
var err := http.request(request_url)
|
||||
if err != OK:
|
||||
http.queue_free()
|
||||
push_warning("SFX: request failed for %s (err %d)" % [request_url, err])
|
||||
return null
|
||||
|
||||
var result: Array = await http.request_completed
|
||||
http.queue_free()
|
||||
|
||||
var response_code : int = result[1]
|
||||
var body : PackedByteArray = result[3]
|
||||
var response_code: int = int(result[1])
|
||||
var body: PackedByteArray = result[3]
|
||||
if response_code != 200 or body.is_empty():
|
||||
push_warning("SFX: failed to download %s (HTTP %d)" % [url, response_code])
|
||||
return null
|
||||
@@ -75,10 +94,39 @@ func _load_stream(url: String) -> AudioStream:
|
||||
var ext := url.get_extension().to_lower()
|
||||
if ext == "ogg":
|
||||
return AudioStreamOggVorbis.load_from_buffer(body)
|
||||
elif ext == "mp3":
|
||||
var s := AudioStreamMP3.new()
|
||||
s.data = body
|
||||
return s
|
||||
if ext == "mp3":
|
||||
var mp3 := AudioStreamMP3.new()
|
||||
mp3.data = body
|
||||
return mp3
|
||||
if ext == "wav":
|
||||
return AudioStreamWAV.load_from_buffer(body)
|
||||
|
||||
push_warning("SFX: unsupported format '%s' — use OGG or MP3." % ext)
|
||||
push_warning("SFX: unsupported format '%s' - use OGG, MP3, or WAV." % ext)
|
||||
return null
|
||||
|
||||
|
||||
func _normalize_remote_url(url: String) -> String:
|
||||
return url.replace(" ", "%20")
|
||||
|
||||
|
||||
func _is_supported_url(url: String) -> bool:
|
||||
if url.is_empty() or url == "null":
|
||||
return false
|
||||
return url.begins_with("http://") or url.begins_with("https://") \
|
||||
or url.begins_with("res://") or url.begins_with("user://")
|
||||
|
||||
|
||||
func _load_and_cache(url: String) -> AudioStream:
|
||||
if _cache.has(url):
|
||||
return _cache[url] as AudioStream
|
||||
if _in_flight.has(url):
|
||||
while _in_flight.has(url):
|
||||
await get_tree().process_frame
|
||||
return _cache.get(url, null) as AudioStream
|
||||
|
||||
_in_flight[url] = true
|
||||
var stream := await _load_stream(url)
|
||||
_in_flight.erase(url)
|
||||
if stream != null:
|
||||
_cache[url] = stream
|
||||
return stream
|
||||
|
||||
@@ -64,6 +64,14 @@ var click_to_focus_camera : bool = false :
|
||||
_save()
|
||||
settings_changed.emit()
|
||||
|
||||
## When true, newly drawn cards pop up in the centre of the screen and must be
|
||||
## clicked before they slide into the hand.
|
||||
var draw_card_popup : bool = true :
|
||||
set(v):
|
||||
draw_card_popup = v
|
||||
_save()
|
||||
settings_changed.emit()
|
||||
|
||||
## Skybox display mode in gameplay scenes.
|
||||
## "live" — near-black sky with emissive stars; each star = an active game session.
|
||||
## "cdn" — server-configured panoramic or animated skybox image.
|
||||
@@ -111,12 +119,22 @@ func clear_highlight_override(type: String) -> void:
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
_ensure_buses()
|
||||
_load()
|
||||
_apply_music()
|
||||
_apply_sfx()
|
||||
|
||||
# ── Internal ──────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ensure_buses() -> void:
|
||||
for bus_name in [BUS_MUSIC, BUS_SFX]:
|
||||
if AudioServer.get_bus_index(bus_name) < 0:
|
||||
var idx := AudioServer.bus_count
|
||||
AudioServer.add_bus()
|
||||
AudioServer.set_bus_name(idx, bus_name)
|
||||
AudioServer.set_bus_send(idx, "Master")
|
||||
|
||||
|
||||
func _apply_music() -> void:
|
||||
var idx := AudioServer.get_bus_index(BUS_MUSIC)
|
||||
if idx < 0:
|
||||
@@ -157,6 +175,7 @@ func _load() -> void:
|
||||
sfx_muted = bool(cfg.get_value(SECTION, "sfx_muted", false))
|
||||
camera_follow_unit = bool(cfg.get_value(SECTION_GAMEPLAY, "camera_follow_unit", true))
|
||||
click_to_focus_camera = bool(cfg.get_value(SECTION_GAMEPLAY, "click_to_focus_camera", false))
|
||||
draw_card_popup = bool(cfg.get_value(SECTION_GAMEPLAY, "draw_card_popup", true))
|
||||
touch_camera_mode = str(cfg.get_value(SECTION_CAMERA, "touch_camera_mode", "gesture"))
|
||||
skybox_mode = str(cfg.get_value(SECTION_VISUAL, "skybox_mode", "live"))
|
||||
var raw_overrides = cfg.get_value(SECTION_HIGHLIGHTS, "highlight_overrides", {})
|
||||
@@ -172,6 +191,7 @@ func _save() -> void:
|
||||
cfg.set_value(SECTION, "sfx_muted", sfx_muted)
|
||||
cfg.set_value(SECTION_GAMEPLAY, "camera_follow_unit", camera_follow_unit)
|
||||
cfg.set_value(SECTION_GAMEPLAY, "click_to_focus_camera", click_to_focus_camera)
|
||||
cfg.set_value(SECTION_GAMEPLAY, "draw_card_popup", draw_card_popup)
|
||||
cfg.set_value(SECTION_CAMERA, "touch_camera_mode", touch_camera_mode)
|
||||
cfg.set_value(SECTION_VISUAL, "skybox_mode", skybox_mode)
|
||||
cfg.set_value(SECTION_HIGHLIGHTS, "highlight_overrides", highlight_overrides)
|
||||
|
||||
@@ -13,7 +13,8 @@ config_version=5
|
||||
config/name="Origin-Client"
|
||||
run/main_scene="res://scenes/login/LoginScreen.tscn"
|
||||
config/features=PackedStringArray("4.5", "GL Compatibility")
|
||||
config/icon="res://icon.svg"
|
||||
boot_splash/image="uid://djlr6v2m1uegn"
|
||||
config/icon="uid://qmb76y70ds6a"
|
||||
|
||||
[autoload]
|
||||
|
||||
@@ -28,6 +29,7 @@ Settings="*res://autoloads/Settings.gd"
|
||||
Game="*res://autoloads/Game.gd"
|
||||
CustomLobby="*res://autoloads/CustomLobby.gd"
|
||||
ModelCache="*res://autoloads/ModelCache.gd"
|
||||
Platform="*res://autoloads/Platform.gd"
|
||||
Music="*res://autoloads/Music.gd"
|
||||
SFX="*res://autoloads/SFX.gd"
|
||||
HighlightConfig="*res://autoloads/HighlightConfig.gd"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://c5johsq4wu63l"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/account/account_screen.gd" id="1_acc"]
|
||||
[ext_resource type="Script" uid="uid://b3kkhkytruoo4" path="res://scenes/account/account_screen.gd" id="1_acc"]
|
||||
|
||||
[node name="AccountScreen" type="Control"]
|
||||
layout_mode = 3
|
||||
@@ -18,7 +18,7 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.094, 0.094, 0.137, 1.0)
|
||||
color = Color(0.094, 0.094, 0.137, 1)
|
||||
|
||||
[node name="Layout" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
@@ -32,28 +32,28 @@ theme_override_constants/separation = 0
|
||||
[node name="TopBar" type="MarginContainer" parent="Layout"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 16
|
||||
theme_override_constants/margin_right = 16
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_right = 16
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="TopBarInner" type="HBoxContainer" parent="Layout/TopBar"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 40)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="BackBtn" type="Button" parent="Layout/TopBar/TopBarInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(40, 40)
|
||||
text = "←"
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 18
|
||||
text = "←"
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="Layout/TopBar/TopBarInner"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 18
|
||||
text = "Account"
|
||||
vertical_alignment = 1
|
||||
theme_override_font_sizes/font_size = 18
|
||||
|
||||
[node name="HSep" type="HSeparator" parent="Layout"]
|
||||
layout_mode = 2
|
||||
@@ -70,8 +70,8 @@ size_flags_horizontal = 3
|
||||
[node name="ContentMargin" type="MarginContainer" parent="Layout/Scroll/Content"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 20
|
||||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_top = 20
|
||||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="Sections" type="VBoxContainer" parent="Layout/Scroll/Content/ContentMargin"]
|
||||
@@ -83,55 +83,55 @@ layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="ProfileLabel" type="Label" parent="Layout/Scroll/Content/ContentMargin/Sections/ProfileSection"]
|
||||
modulate = Color(0.6, 0.6, 0.65, 1)
|
||||
layout_mode = 2
|
||||
text = "PROFILE"
|
||||
modulate = Color(0.6, 0.6, 0.65, 1.0)
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "PROFILE"
|
||||
|
||||
[node name="DisplayLabel" type="Label" parent="Layout/Scroll/Content/ContentMargin/Sections/ProfileSection"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "—"
|
||||
theme_override_font_sizes/font_size = 22
|
||||
text = "—"
|
||||
|
||||
[node name="OpLabel" type="Label" parent="Layout/Scroll/Content/ContentMargin/Sections/ProfileSection"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.95, 0.85, 0.3, 1)
|
||||
layout_mode = 2
|
||||
text = "◆ — OP"
|
||||
modulate = Color(0.95, 0.85, 0.30, 1.0)
|
||||
theme_override_font_sizes/font_size = 15
|
||||
text = "◆ — OP"
|
||||
|
||||
[node name="RankLabel" type="Label" parent="Layout/Scroll/Content/ContentMargin/Sections/ProfileSection"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.7, 0.7, 0.75, 1)
|
||||
layout_mode = 2
|
||||
text = "Rank: —"
|
||||
modulate = Color(0.7, 0.7, 0.75, 1.0)
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "Rank: —"
|
||||
|
||||
[node name="MailboxSection" type="VBoxContainer" parent="Layout/Scroll/Content/ContentMargin/Sections"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="MailboxLabel" type="Label" parent="Layout/Scroll/Content/ContentMargin/Sections/MailboxSection"]
|
||||
modulate = Color(0.6, 0.6, 0.65, 1)
|
||||
layout_mode = 2
|
||||
text = "MAILBOX"
|
||||
modulate = Color(0.6, 0.6, 0.65, 1.0)
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "MAILBOX"
|
||||
|
||||
[node name="LoadingLabel" type="Label" parent="Layout/Scroll/Content/ContentMargin/Sections/MailboxSection"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.7, 0.7, 0.75, 1)
|
||||
layout_mode = 2
|
||||
text = "Loading…"
|
||||
modulate = Color(0.7, 0.7, 0.75, 1.0)
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Loading…"
|
||||
|
||||
[node name="EmptyLabel" type="Label" parent="Layout/Scroll/Content/ContentMargin/Sections/MailboxSection"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "No messages yet."
|
||||
visible = false
|
||||
modulate = Color(0.55, 0.55, 0.60, 1.0)
|
||||
modulate = Color(0.55, 0.55, 0.6, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "No messages yet."
|
||||
|
||||
[node name="MailboxList" type="VBoxContainer" parent="Layout/Scroll/Content/ContentMargin/Sections/MailboxSection"]
|
||||
unique_name_in_owner = true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dafeibsfcbdc4"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/account/components/notification_row.gd" id="1_nr"]
|
||||
[ext_resource type="Script" uid="uid://q0hlke8ixefd" path="res://scenes/account/components/notification_row.gd" id="1_nr"]
|
||||
|
||||
[node name="NotificationRow" type="PanelContainer"]
|
||||
custom_minimum_size = Vector2(0, 72)
|
||||
@@ -9,8 +9,8 @@ script = ExtResource("1_nr")
|
||||
[node name="Margin" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="Margin"]
|
||||
@@ -24,7 +24,7 @@ theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="BodyLabel" type="Label" parent="Margin/VBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
autowrap_mode = 2
|
||||
modulate = Color(0.7, 0.7, 0.75, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 11
|
||||
autowrap_mode = 2
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://wnk2cbwr6rhj"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/bazaar/bazaar_screen.gd" id="1_bs"]
|
||||
[ext_resource type="Script" uid="uid://cq4fff6k71rpe" path="res://scenes/bazaar/bazaar_screen.gd" id="1_bs"]
|
||||
|
||||
[node name="BazaarScreen" type="VBoxContainer"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
@@ -15,47 +14,47 @@ script = ExtResource("1_bs")
|
||||
[node name="TopBarMargin" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="TopBar" type="HBoxContainer" parent="TopBarMargin"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 40)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="BackBtn" type="Button" parent="TopBarMargin/TopBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(40, 40)
|
||||
text = "←"
|
||||
layout_mode = 2
|
||||
tooltip_text = "Back"
|
||||
theme_override_font_sizes/font_size = 18
|
||||
text = "←"
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="TopBarMargin/TopBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 18
|
||||
text = "Bazaar"
|
||||
vertical_alignment = 1
|
||||
theme_override_font_sizes/font_size = 18
|
||||
|
||||
[node name="BalanceLabel" type="Label" parent="TopBarMargin/TopBar"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.95, 0.85, 0.3, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "◆ — OP"
|
||||
vertical_alignment = 1
|
||||
modulate = Color(0.95, 0.85, 0.30, 1.0)
|
||||
theme_override_font_sizes/font_size = 14
|
||||
|
||||
[node name="BuyOpBtn" type="Button" parent="TopBarMargin/TopBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
modulate = Color(0.95, 0.85, 0.3, 0.5)
|
||||
custom_minimum_size = Vector2(100, 32)
|
||||
disabled = true
|
||||
text = "+ Buy OP"
|
||||
layout_mode = 2
|
||||
tooltip_text = "Purchase Origin Points with real money — coming soon"
|
||||
theme_override_font_sizes/font_size = 12
|
||||
modulate = Color(0.95, 0.85, 0.30, 0.5)
|
||||
disabled = true
|
||||
text = "+ Buy OP"
|
||||
|
||||
[node name="HSep1" type="HSeparator" parent="."]
|
||||
layout_mode = 2
|
||||
@@ -63,46 +62,46 @@ layout_mode = 2
|
||||
[node name="TabBarMargin" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_bottom = 4
|
||||
|
||||
[node name="TabBar" type="HBoxContainer" parent="TabBarMargin"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 34)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 6
|
||||
|
||||
[node name="BoostersTabBtn" type="Button" parent="TabBarMargin/TabBar"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 34)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(0, 34)
|
||||
text = "Boosters"
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Boosters"
|
||||
|
||||
[node name="DecksTabBtn" type="Button" parent="TabBarMargin/TabBar"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 34)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(0, 34)
|
||||
text = "Decks"
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Decks"
|
||||
|
||||
[node name="CosmeticsTabBtn" type="Button" parent="TabBarMargin/TabBar"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 34)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(0, 34)
|
||||
text = "Cosmetics"
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Cosmetics"
|
||||
|
||||
[node name="CardsTabBtn" type="Button" parent="TabBarMargin/TabBar"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 34)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(0, 34)
|
||||
text = "Cards"
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Cards"
|
||||
|
||||
[node name="HSep2" type="HSeparator" parent="."]
|
||||
layout_mode = 2
|
||||
@@ -110,64 +109,64 @@ layout_mode = 2
|
||||
[node name="FilterBarMargin" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_bottom = 4
|
||||
|
||||
[node name="FilterBar" type="HBoxContainer" parent="FilterBarMargin"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 30)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="SortLabel" type="Label" parent="FilterBarMargin/FilterBar"]
|
||||
modulate = Color(0.7, 0.7, 0.75, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Sort:"
|
||||
vertical_alignment = 1
|
||||
theme_override_font_sizes/font_size = 12
|
||||
modulate = Color(0.7, 0.7, 0.75, 1.0)
|
||||
|
||||
[node name="SortOption" type="OptionButton" parent="FilterBarMargin/FilterBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(130, 28)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
|
||||
[node name="FilterSep" type="VSeparator" parent="FilterBarMargin/FilterBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="RarityLabel" type="Label" parent="FilterBarMargin/FilterBar"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
modulate = Color(0.7, 0.7, 0.75, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Rarity:"
|
||||
vertical_alignment = 1
|
||||
visible = false
|
||||
theme_override_font_sizes/font_size = 12
|
||||
modulate = Color(0.7, 0.7, 0.75, 1.0)
|
||||
|
||||
[node name="RarityOption" type="OptionButton" parent="FilterBarMargin/FilterBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(110, 28)
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(110, 28)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
|
||||
[node name="TypeLabel" type="Label" parent="FilterBarMargin/FilterBar"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
modulate = Color(0.7, 0.7, 0.75, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Type:"
|
||||
vertical_alignment = 1
|
||||
visible = false
|
||||
theme_override_font_sizes/font_size = 12
|
||||
modulate = Color(0.7, 0.7, 0.75, 1.0)
|
||||
|
||||
[node name="TypeOption" type="OptionButton" parent="FilterBarMargin/FilterBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(110, 28)
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(110, 28)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
|
||||
[node name="FilterSpacer" type="Control" parent="FilterBarMargin/FilterBar"]
|
||||
@@ -186,8 +185,8 @@ horizontal_scroll_mode = 0
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="ItemList" type="VBoxContainer" parent="Scroll/ItemListMargin"]
|
||||
@@ -197,24 +196,24 @@ size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 6
|
||||
|
||||
[node name="StatusRow" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 44)
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="LoadingLabel" type="Label" parent="StatusRow"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.75, 0.75, 0.8, 1)
|
||||
layout_mode = 2
|
||||
text = "Loading…"
|
||||
modulate = Color(0.75, 0.75, 0.8, 1.0)
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "Loading…"
|
||||
|
||||
[node name="EmptyLabel" type="Label" parent="StatusRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Nothing available right now."
|
||||
visible = false
|
||||
modulate = Color(0.6, 0.6, 0.65, 1.0)
|
||||
modulate = Color(0.6, 0.6, 0.65, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "Nothing available right now."
|
||||
|
||||
[node name="ConfirmDialog" type="ConfirmationDialog" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
extends VBoxContainer
|
||||
## Bazaar — Boosters, Decks, Cosmetics, and Cards marketplace.
|
||||
## Bazaar — Boosters, Decks, Cosmetics, Cards marketplace, and My Shop.
|
||||
##
|
||||
## Four tabs each with sort controls. The Cards tab additionally has
|
||||
## rarity/type filters and loads from the P2P marketplace.
|
||||
## Origin Points purchases are live. USD prices are shown but disabled.
|
||||
## Five tabs with sort/filter controls.
|
||||
## Cards tab: P2P marketplace with rarity/type filtering.
|
||||
## My Shop tab: own active listings with cancel + re-list actions, plus a
|
||||
## search field to navigate to another player's storefront.
|
||||
|
||||
const STORE_ITEM_ROW := preload("res://scenes/bazaar/components/StoreItemRow.tscn")
|
||||
|
||||
@@ -11,7 +12,7 @@ const FALLBACK_ART := "https://cdn.aeternalisgames.com/sor-assets/cardart/0_No-C
|
||||
|
||||
const RARITY_ORDER := { "Common": 0, "Uncommon": 1, "Rare": 2, "Epic": 3, "Legendary": 4 }
|
||||
|
||||
enum Tab { BOOSTERS, DECKS, COSMETICS, CARDS }
|
||||
enum Tab { BOOSTERS, DECKS, COSMETICS, CARDS, MY_SHOP }
|
||||
|
||||
# ── Node references ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -22,6 +23,7 @@ enum Tab { BOOSTERS, DECKS, COSMETICS, CARDS }
|
||||
@onready var decks_tab_btn : Button = %DecksTabBtn
|
||||
@onready var cosmetics_tab_btn : Button = %CosmeticsTabBtn
|
||||
@onready var cards_tab_btn : Button = %CardsTabBtn
|
||||
@onready var my_shop_tab_btn : Button = %MyShopTabBtn
|
||||
@onready var sort_option : OptionButton = %SortOption
|
||||
@onready var filter_sep : VSeparator = %FilterSep
|
||||
@onready var rarity_label : Label = %RarityLabel
|
||||
@@ -33,6 +35,10 @@ enum Tab { BOOSTERS, DECKS, COSMETICS, CARDS }
|
||||
@onready var empty_label : Label = %EmptyLabel
|
||||
@onready var confirm_dialog : ConfirmationDialog = %ConfirmDialog
|
||||
@onready var result_dialog : AcceptDialog = %ResultDialog
|
||||
# My Shop tab extras
|
||||
@onready var player_shop_row : HBoxContainer = %PlayerShopRow
|
||||
@onready var player_shop_input : LineEdit = %PlayerShopInput
|
||||
@onready var player_shop_btn : Button = %PlayerShopBtn
|
||||
|
||||
# ── Sort option labels per tab ─────────────────────────────────────────────────
|
||||
|
||||
@@ -41,6 +47,7 @@ const SORT_LABELS := {
|
||||
Tab.DECKS: ["Name A–Z", "Price ↑", "Price ↓", "Cards ↑"],
|
||||
Tab.COSMETICS: ["Name A–Z", "Price ↑", "Price ↓", "Type"],
|
||||
Tab.CARDS: ["Price ↑", "Price ↓", "Name A–Z", "Rarity"],
|
||||
Tab.MY_SHOP: ["Listed ↓", "Price ↑", "Price ↓"],
|
||||
}
|
||||
|
||||
# ── State ─────────────────────────────────────────────────────────────────────
|
||||
@@ -50,15 +57,20 @@ var _packs : Array = []
|
||||
var _decks : Array = []
|
||||
var _cosmetics : Array = []
|
||||
var _listings : Array = [] # Cards tab (marketplace)
|
||||
var _my_listings: Array = [] # My Shop tab
|
||||
|
||||
var _store_loaded := false
|
||||
var _bal_loaded := false
|
||||
var _listings_loaded := false
|
||||
var _store_loaded := false
|
||||
var _bal_loaded := false
|
||||
var _listings_loaded := false
|
||||
var _my_shop_loaded := false
|
||||
|
||||
var _pending_item : Dictionary = {}
|
||||
var _buying := false
|
||||
var _pending_item : Dictionary = {}
|
||||
var _pending_cancel_id : String = ""
|
||||
var _buying := false
|
||||
|
||||
var _sort : Dictionary = { Tab.BOOSTERS: 0, Tab.DECKS: 0, Tab.COSMETICS: 0, Tab.CARDS: 0 }
|
||||
var _sort : Dictionary = {
|
||||
Tab.BOOSTERS: 0, Tab.DECKS: 0, Tab.COSMETICS: 0, Tab.CARDS: 0, Tab.MY_SHOP: 0
|
||||
}
|
||||
var _rarity_filter : String = ""
|
||||
var _type_filter : String = ""
|
||||
|
||||
@@ -71,11 +83,13 @@ func _ready() -> void:
|
||||
decks_tab_btn.pressed.connect(func(): _switch_tab(Tab.DECKS))
|
||||
cosmetics_tab_btn.pressed.connect(func(): _switch_tab(Tab.COSMETICS))
|
||||
cards_tab_btn.pressed.connect(func(): _switch_tab(Tab.CARDS))
|
||||
my_shop_tab_btn.pressed.connect(func(): _switch_tab(Tab.MY_SHOP))
|
||||
|
||||
sort_option.item_selected.connect(_on_sort_changed)
|
||||
rarity_option.item_selected.connect(_on_rarity_changed)
|
||||
type_option.item_selected.connect(_on_type_changed)
|
||||
confirm_dialog.confirmed.connect(_on_purchase_confirmed)
|
||||
player_shop_btn.pressed.connect(_on_player_shop_search)
|
||||
|
||||
buy_op_btn.disabled = true # USD flow not yet available
|
||||
|
||||
@@ -154,6 +168,30 @@ func _on_listings_err(code: String, _msg: String) -> void:
|
||||
loading_label.visible = false
|
||||
_render_tab()
|
||||
|
||||
|
||||
func _fetch_my_listings() -> void:
|
||||
_my_shop_loaded = false
|
||||
Network.request(
|
||||
"bazaar.get_my_listings",
|
||||
{ "statusFilter": "Active" },
|
||||
_on_my_listings_ok,
|
||||
_on_my_listings_err
|
||||
)
|
||||
|
||||
|
||||
func _on_my_listings_ok(_t: String, p: Variant) -> void:
|
||||
_my_listings = (p as Dictionary).get("listings", [])
|
||||
_my_shop_loaded = true
|
||||
loading_label.visible = false
|
||||
_render_tab()
|
||||
|
||||
|
||||
func _on_my_listings_err(code: String, _msg: String) -> void:
|
||||
push_warning("Bazaar: get_my_listings failed — %s" % code)
|
||||
_my_shop_loaded = true
|
||||
loading_label.visible = false
|
||||
_render_tab()
|
||||
|
||||
# ── Tabs ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
func _switch_tab(tab: Tab) -> void:
|
||||
@@ -168,6 +206,13 @@ func _switch_tab(tab: Tab) -> void:
|
||||
_fetch_listings()
|
||||
return
|
||||
|
||||
if tab == Tab.MY_SHOP and not _my_shop_loaded:
|
||||
loading_label.visible = true
|
||||
empty_label.visible = false
|
||||
_clear_list()
|
||||
_fetch_my_listings()
|
||||
return
|
||||
|
||||
if _store_loaded and _bal_loaded:
|
||||
_render_tab()
|
||||
|
||||
@@ -177,6 +222,7 @@ func _apply_tab_styles() -> void:
|
||||
_style_tab(decks_tab_btn, _tab == Tab.DECKS)
|
||||
_style_tab(cosmetics_tab_btn, _tab == Tab.COSMETICS)
|
||||
_style_tab(cards_tab_btn, _tab == Tab.CARDS)
|
||||
_style_tab(my_shop_tab_btn, _tab == Tab.MY_SHOP)
|
||||
|
||||
|
||||
func _style_tab(btn: Button, active: bool) -> void:
|
||||
@@ -200,12 +246,15 @@ func _setup_filter_bar() -> void:
|
||||
sort_option.add_item(lbl)
|
||||
sort_option.selected = _sort[_tab]
|
||||
|
||||
var is_cards := _tab == Tab.CARDS
|
||||
var is_cards := _tab == Tab.CARDS
|
||||
var is_my_shop := _tab == Tab.MY_SHOP
|
||||
filter_sep.visible = is_cards
|
||||
rarity_label.visible = is_cards
|
||||
rarity_option.visible = is_cards
|
||||
type_label.visible = is_cards
|
||||
type_option.visible = is_cards
|
||||
# My Shop: show player shop search row
|
||||
player_shop_row.visible = is_my_shop
|
||||
|
||||
|
||||
func _rebuild_type_filter() -> void:
|
||||
@@ -252,6 +301,7 @@ func _render_tab() -> void:
|
||||
Tab.DECKS: items = _decks.duplicate()
|
||||
Tab.COSMETICS: items = _cosmetics.duplicate()
|
||||
Tab.CARDS: items = _listings.duplicate()
|
||||
Tab.MY_SHOP: items = _my_listings.duplicate()
|
||||
|
||||
items = _sort_items(items)
|
||||
if _tab == Tab.CARDS:
|
||||
@@ -264,9 +314,15 @@ func _render_tab() -> void:
|
||||
item_list.add_child(row)
|
||||
if _tab == Tab.CARDS:
|
||||
row.setup_listing(item, FALLBACK_ART)
|
||||
elif _tab == Tab.MY_SHOP:
|
||||
row.setup_listing(item, FALLBACK_ART)
|
||||
# Override buy button label to "Cancel" for own listings.
|
||||
if row.has_method("set_action_label"):
|
||||
row.set_action_label("Cancel")
|
||||
row.buy_pressed.connect(_on_cancel_listing_pressed)
|
||||
else:
|
||||
row.setup(item, FALLBACK_ART)
|
||||
row.buy_pressed.connect(_on_buy_pressed)
|
||||
row.buy_pressed.connect(_on_buy_pressed)
|
||||
|
||||
|
||||
func _clear_list() -> void:
|
||||
@@ -303,6 +359,11 @@ func _sort_items(items: Array) -> Array:
|
||||
2: items.sort_custom(func(a, b): return a.get("cardName","") < b.get("cardName",""))
|
||||
3: items.sort_custom(func(a, b):
|
||||
return RARITY_ORDER.get(a.get("rarity",""), 99) < RARITY_ORDER.get(b.get("rarity",""), 99))
|
||||
Tab.MY_SHOP:
|
||||
match idx:
|
||||
0: items.sort_custom(func(a, b): return str(a.get("listedAt","")) > str(b.get("listedAt","")))
|
||||
1: items.sort_custom(func(a, b): return float(a.get("price",0)) < float(b.get("price",0)))
|
||||
2: items.sort_custom(func(a, b): return float(a.get("price",0)) > float(b.get("price",0)))
|
||||
return items
|
||||
|
||||
|
||||
@@ -410,6 +471,78 @@ func _show_result(title: String, body: String) -> void:
|
||||
result_dialog.dialog_text = body
|
||||
result_dialog.popup_centered()
|
||||
|
||||
# ── My Shop: cancel listing ────────────────────────────────────────────────────
|
||||
|
||||
func _on_cancel_listing_pressed(item: Dictionary) -> void:
|
||||
var listing_id : String = str(item.get("id", ""))
|
||||
var card_name : String = item.get("cardName", "this listing")
|
||||
_pending_cancel_id = listing_id
|
||||
confirm_dialog.dialog_text = "Cancel listing for \"%s\"?" % card_name
|
||||
confirm_dialog.popup_centered()
|
||||
# Re-route the confirmed signal to the cancel handler for this press.
|
||||
if confirm_dialog.confirmed.is_connected(_on_purchase_confirmed):
|
||||
confirm_dialog.confirmed.disconnect(_on_purchase_confirmed)
|
||||
if not confirm_dialog.confirmed.is_connected(_on_cancel_listing_confirmed):
|
||||
confirm_dialog.confirmed.connect(_on_cancel_listing_confirmed, CONNECT_ONE_SHOT)
|
||||
|
||||
|
||||
func _on_cancel_listing_confirmed() -> void:
|
||||
if _pending_cancel_id.is_empty():
|
||||
return
|
||||
var lid := _pending_cancel_id
|
||||
_pending_cancel_id = ""
|
||||
Network.request(
|
||||
"bazaar.cancel_listing",
|
||||
{ "listingId": lid },
|
||||
func(_t: String, _p: Variant):
|
||||
_my_listings = _my_listings.filter(func(l: Dictionary) -> bool:
|
||||
return str(l.get("id","")) != lid)
|
||||
_render_tab()
|
||||
# Reconnect original confirmed handler.
|
||||
if not confirm_dialog.confirmed.is_connected(_on_purchase_confirmed):
|
||||
confirm_dialog.confirmed.connect(_on_purchase_confirmed),
|
||||
func(code: String, _msg: String):
|
||||
_show_result("Cancel Failed", "Error: %s" % code)
|
||||
if not confirm_dialog.confirmed.is_connected(_on_purchase_confirmed):
|
||||
confirm_dialog.confirmed.connect(_on_purchase_confirmed)
|
||||
)
|
||||
|
||||
# ── My Shop: view another player's storefront ──────────────────────────────────
|
||||
|
||||
func _on_player_shop_search() -> void:
|
||||
var seller_id := player_shop_input.text.strip_edges()
|
||||
if seller_id.is_empty():
|
||||
return
|
||||
loading_label.visible = true
|
||||
_clear_list()
|
||||
Network.request(
|
||||
"bazaar.get_player_shop",
|
||||
{ "sellerAccountId": seller_id, "page": 0, "pageSize": 50 },
|
||||
_on_player_shop_ok,
|
||||
_on_player_shop_err
|
||||
)
|
||||
|
||||
|
||||
func _on_player_shop_ok(_t: String, p: Variant) -> void:
|
||||
var d := p as Dictionary
|
||||
var name_ := str(d.get("sellerDisplayName", "Player"))
|
||||
var listings: Array = d.get("listings", [])
|
||||
loading_label.visible = false
|
||||
_clear_list()
|
||||
empty_label.visible = listings.is_empty()
|
||||
for item: Dictionary in listings:
|
||||
var row := STORE_ITEM_ROW.instantiate()
|
||||
item_list.add_child(row)
|
||||
row.setup_listing(item, FALLBACK_ART)
|
||||
row.buy_pressed.connect(_on_buy_pressed)
|
||||
# Show whose shop this is.
|
||||
_show_result("%s's Shop" % name_, "%d active listing(s)" % listings.size())
|
||||
|
||||
|
||||
func _on_player_shop_err(code: String, _msg: String) -> void:
|
||||
loading_label.visible = false
|
||||
_show_result("Shop Not Found", "Error: %s" % code)
|
||||
|
||||
# ── Navigation ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _on_back() -> void:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://cxqsbvyhgmesl"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/bazaar/components/store_item_row.gd" id="1_sir"]
|
||||
[ext_resource type="Script" uid="uid://bl4vmmiurfap2" path="res://scenes/bazaar/components/store_item_row.gd" id="1_sir"]
|
||||
|
||||
[node name="StoreItemRow" type="PanelContainer"]
|
||||
custom_minimum_size = Vector2(0, 88)
|
||||
@@ -9,8 +9,8 @@ script = ExtResource("1_sir")
|
||||
[node name="Margin" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="Margin"]
|
||||
@@ -19,8 +19,8 @@ theme_override_constants/separation = 12
|
||||
|
||||
[node name="ArtImage" type="TextureRect" parent="Margin/HBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(72, 72)
|
||||
layout_mode = 2
|
||||
expand_mode = 1
|
||||
stretch_mode = 6
|
||||
|
||||
@@ -37,27 +37,24 @@ theme_override_font_sizes/font_size = 14
|
||||
|
||||
[node name="DescLabel" type="Label" parent="Margin/HBox/Info"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = ""
|
||||
visible = false
|
||||
autowrap_mode = 2
|
||||
modulate = Color(0.70, 0.70, 0.75, 1.0)
|
||||
modulate = Color(0.7, 0.7, 0.75, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="SubLabel" type="Label" parent="Margin/HBox/Info"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = ""
|
||||
visible = false
|
||||
modulate = Color(0.55, 0.55, 0.60, 1.0)
|
||||
modulate = Color(0.55, 0.55, 0.6, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 11
|
||||
|
||||
[node name="TagsLabel" type="Label" parent="Margin/HBox/Info"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = ""
|
||||
visible = false
|
||||
modulate = Color(0.45, 0.65, 0.90, 1.0)
|
||||
modulate = Color(0.45, 0.65, 0.9, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 10
|
||||
|
||||
[node name="PriceBox" type="VBoxContainer" parent="Margin/HBox"]
|
||||
@@ -67,23 +64,22 @@ theme_override_constants/separation = 4
|
||||
|
||||
[node name="PriceLabel" type="Label" parent="Margin/HBox/PriceBox"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.95, 0.85, 0.3, 1)
|
||||
layout_mode = 2
|
||||
horizontal_alignment = 1
|
||||
modulate = Color(0.95, 0.85, 0.30, 1.0)
|
||||
theme_override_font_sizes/font_size = 13
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="BuyBtn" type="Button" parent="Margin/HBox/PriceBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(76, 32)
|
||||
text = "Buy"
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Buy"
|
||||
|
||||
[node name="UsdLabel" type="Label" parent="Margin/HBox/PriceBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
horizontal_alignment = 1
|
||||
text = ""
|
||||
visible = false
|
||||
modulate = Color(0.5, 0.5, 0.55, 0.7)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 10
|
||||
horizontal_alignment = 1
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://og17wax7syki"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/bug_report/bug_report_dialog.gd" id="1_brd"]
|
||||
[ext_resource type="Script" uid="uid://btgg7fge6j3j6" path="res://scenes/bug_report/bug_report_dialog.gd" id="1_brd"]
|
||||
|
||||
[node name="BugReportDialog" type="Window"]
|
||||
oversampling_override = 1.0
|
||||
title = "Report a Bug"
|
||||
initial_position = 2
|
||||
size = Vector2i(560, 520)
|
||||
script = ExtResource("1_brd")
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 16
|
||||
theme_override_constants/margin_right = 16
|
||||
theme_override_constants/margin_top = 12
|
||||
theme_override_constants/margin_right = 16
|
||||
theme_override_constants/margin_bottom = 12
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="Margin"]
|
||||
@@ -29,17 +29,17 @@ layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="CategoryLabel" type="Label" parent="Margin/VBox/CategoryRow"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(80, 0)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Category"
|
||||
vertical_alignment = 1
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="CategoryOption" type="OptionButton" parent="Margin/VBox/CategoryRow"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 32)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(0, 32)
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="TitleRow" type="HBoxContainer" parent="Margin/VBox"]
|
||||
@@ -47,52 +47,53 @@ layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="TitleRowLabel" type="Label" parent="Margin/VBox/TitleRow"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(80, 0)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Title"
|
||||
vertical_alignment = 1
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="TitleEdit" type="LineEdit" parent="Margin/VBox/TitleRow"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 32)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(0, 32)
|
||||
placeholder_text = "Short summary of the issue"
|
||||
theme_override_font_sizes/font_size = 13
|
||||
placeholder_text = "Short summary of the issue"
|
||||
|
||||
[node name="DescLabel" type="Label" parent="Margin/VBox"]
|
||||
layout_mode = 2
|
||||
text = "Description"
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Description"
|
||||
|
||||
[node name="DescEdit" type="TextEdit" parent="Margin/VBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 100)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
custom_minimum_size = Vector2(0, 100)
|
||||
placeholder_text = "Describe the bug in detail…"
|
||||
theme_override_font_sizes/font_size = 13
|
||||
placeholder_text = "Describe the bug in detail…"
|
||||
|
||||
[node name="StepsLabel" type="Label" parent="Margin/VBox"]
|
||||
modulate = Color(0.7, 0.7, 0.75, 1)
|
||||
layout_mode = 2
|
||||
text = "Steps to reproduce (optional)"
|
||||
modulate = Color(0.7, 0.7, 0.75, 1.0)
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Steps to reproduce (optional)"
|
||||
|
||||
[node name="StepsEdit" type="TextEdit" parent="Margin/VBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 80)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
custom_minimum_size = Vector2(0, 80)
|
||||
placeholder_text = "1. Open the bazaar\n2. Click Buy\n3. …"
|
||||
theme_override_font_sizes/font_size = 12
|
||||
placeholder_text = "1. Open the bazaar
|
||||
2. Click Buy
|
||||
3. …"
|
||||
|
||||
[node name="StatusLabel" type="Label" parent="Margin/VBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = ""
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="ButtonRow" type="HBoxContainer" parent="Margin/VBox"]
|
||||
@@ -105,14 +106,14 @@ size_flags_horizontal = 3
|
||||
|
||||
[node name="CancelBtn" type="Button" parent="Margin/VBox/ButtonRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(90, 36)
|
||||
text = "Cancel"
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Cancel"
|
||||
|
||||
[node name="SubmitBtn" type="Button" parent="Margin/VBox/ButtonRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(120, 36)
|
||||
text = "Submit Report"
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Submit Report"
|
||||
|
||||
@@ -1,44 +1,41 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dseump8dmnrra"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/chat/chat_overlay.gd" id="1_overlay"]
|
||||
[ext_resource type="Script" uid="uid://b04hb2kfvfmw2" path="res://scenes/chat/chat_overlay.gd" id="1_overlay"]
|
||||
|
||||
[node name="ChatOverlay" type="CanvasLayer"]
|
||||
layer = 100
|
||||
script = ExtResource("1_overlay")
|
||||
|
||||
[node name="ChatBubble" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -76.0
|
||||
offset_top = -76.0
|
||||
offset_right = -16.0
|
||||
offset_bottom = -16.0
|
||||
offset_left = -58.0
|
||||
offset_top = -219.0
|
||||
offset_right = 2.0
|
||||
offset_bottom = -159.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
text = "Chat"
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Chat"
|
||||
|
||||
[node name="BadgeLabel" type="Label" parent="ChatBubble"]
|
||||
visible = false
|
||||
layout_mode = 0
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.0
|
||||
offset_left = -18.0
|
||||
offset_top = -8.0
|
||||
offset_right = 8.0
|
||||
offset_bottom = 12.0
|
||||
visible = false
|
||||
text = ""
|
||||
horizontal_alignment = 1
|
||||
theme_override_font_sizes/font_size = 10
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="ChatPanel" type="PanelContainer" parent="."]
|
||||
visible = false
|
||||
layout_mode = 0
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
@@ -51,19 +48,14 @@ grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="RootVBox" type="VBoxContainer" parent="ChatPanel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="Header" type="MarginContainer" parent="ChatPanel/RootVBox"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 6
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 6
|
||||
|
||||
[node name="HeaderInner" type="HBoxContainer" parent="ChatPanel/RootVBox/Header"]
|
||||
@@ -74,73 +66,73 @@ theme_override_constants/separation = 8
|
||||
[node name="TitleLabel" type="Label" parent="ChatPanel/RootVBox/Header/HeaderInner"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Chat"
|
||||
theme_override_font_sizes/font_size = 15
|
||||
text = "Chat"
|
||||
|
||||
[node name="CloseBtn" type="Button" parent="ChatPanel/RootVBox/Header/HeaderInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
flat = true
|
||||
text = "✕"
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "✕"
|
||||
flat = true
|
||||
|
||||
[node name="HeaderSep" type="HSeparator" parent="ChatPanel/RootVBox"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TabBar" type="HBoxContainer" parent="ChatPanel/RootVBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 28)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="FriendsTabBtn" type="Button" parent="ChatPanel/RootVBox/TabBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
flat = true
|
||||
text = "Friends"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "Friends"
|
||||
flat = true
|
||||
|
||||
[node name="PresenceTabBtn" type="Button" parent="ChatPanel/RootVBox/TabBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
flat = true
|
||||
text = "Presence"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "Presence"
|
||||
flat = true
|
||||
|
||||
[node name="GlobalTabBtn" type="Button" parent="ChatPanel/RootVBox/TabBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
flat = true
|
||||
text = "Global"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "Global"
|
||||
flat = true
|
||||
|
||||
[node name="LobbyTabBtn" type="Button" parent="ChatPanel/RootVBox/TabBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
flat = true
|
||||
text = "Lobby"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "Lobby"
|
||||
flat = true
|
||||
|
||||
[node name="GameTabBtn" type="Button" parent="ChatPanel/RootVBox/TabBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
flat = true
|
||||
text = "Game"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "Game"
|
||||
flat = true
|
||||
|
||||
[node name="PartyTabBtn" type="Button" parent="ChatPanel/RootVBox/TabBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
flat = true
|
||||
text = "Party"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "Party"
|
||||
flat = true
|
||||
|
||||
[node name="DmsTabBtn" type="Button" parent="ChatPanel/RootVBox/TabBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
flat = true
|
||||
text = "DMs"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "DMs"
|
||||
flat = true
|
||||
|
||||
[node name="TabSep" type="HSeparator" parent="ChatPanel/RootVBox"]
|
||||
layout_mode = 2
|
||||
@@ -151,19 +143,19 @@ layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="FriendsPane" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="RequestsSection" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/FriendsPane"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="ReqMargin" type="MarginContainer" parent="ChatPanel/RootVBox/ContentArea/FriendsPane/RequestsSection"]
|
||||
@@ -173,10 +165,10 @@ theme_override_constants/margin_top = 6
|
||||
theme_override_constants/margin_bottom = 2
|
||||
|
||||
[node name="ReqHeader" type="Label" parent="ChatPanel/RootVBox/ContentArea/FriendsPane/RequestsSection/ReqMargin"]
|
||||
layout_mode = 2
|
||||
text = "FRIEND REQUESTS"
|
||||
modulate = Color(0.52, 0.52, 0.58, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 10
|
||||
text = "FRIEND REQUESTS"
|
||||
|
||||
[node name="RequestsList" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/FriendsPane/RequestsSection"]
|
||||
unique_name_in_owner = true
|
||||
@@ -198,20 +190,20 @@ size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="PresencePane" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="StatusMargin" type="MarginContainer" parent="ChatPanel/RootVBox/ContentArea/PresencePane"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="StatusHBox" type="HBoxContainer" parent="ChatPanel/RootVBox/ContentArea/PresencePane/StatusMargin"]
|
||||
@@ -222,8 +214,8 @@ theme_override_constants/separation = 8
|
||||
[node name="StatusLabel" type="Label" parent="ChatPanel/RootVBox/ContentArea/PresencePane/StatusMargin/StatusHBox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "My Status:"
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "My Status:"
|
||||
|
||||
[node name="PresenceOption" type="OptionButton" parent="ChatPanel/RootVBox/ContentArea/PresencePane/StatusMargin/StatusHBox"]
|
||||
unique_name_in_owner = true
|
||||
@@ -240,10 +232,10 @@ theme_override_constants/margin_top = 6
|
||||
theme_override_constants/margin_bottom = 2
|
||||
|
||||
[node name="PresenceHeaderLabel" type="Label" parent="ChatPanel/RootVBox/ContentArea/PresencePane/PresenceHeaderMargin"]
|
||||
layout_mode = 2
|
||||
text = "FRIENDS PRESENCE"
|
||||
modulate = Color(0.52, 0.52, 0.58, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 10
|
||||
text = "FRIENDS PRESENCE"
|
||||
|
||||
[node name="PresenceScroll" type="ScrollContainer" parent="ChatPanel/RootVBox/ContentArea/PresencePane"]
|
||||
layout_mode = 2
|
||||
@@ -257,13 +249,13 @@ size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="GlobalPane" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="GlobalScroll" type="ScrollContainer" parent="ChatPanel/RootVBox/ContentArea/GlobalPane"]
|
||||
@@ -275,8 +267,8 @@ horizontal_scroll_mode = 0
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 4
|
||||
|
||||
[node name="GlobalList" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/GlobalPane/GlobalScroll/GlobalMargin"]
|
||||
@@ -286,13 +278,13 @@ size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 2
|
||||
|
||||
[node name="LobbyPane" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="LobbyScroll" type="ScrollContainer" parent="ChatPanel/RootVBox/ContentArea/LobbyPane"]
|
||||
@@ -304,8 +296,8 @@ horizontal_scroll_mode = 0
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 4
|
||||
|
||||
[node name="LobbyList" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/LobbyPane/LobbyScroll/LobbyMargin"]
|
||||
@@ -315,13 +307,13 @@ size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 2
|
||||
|
||||
[node name="GamePane" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="GameScroll" type="ScrollContainer" parent="ChatPanel/RootVBox/ContentArea/GamePane"]
|
||||
@@ -333,8 +325,8 @@ horizontal_scroll_mode = 0
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 4
|
||||
|
||||
[node name="GameList" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/GamePane/GameScroll/GameMargin"]
|
||||
@@ -344,27 +336,27 @@ size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 2
|
||||
|
||||
[node name="PartyPane" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="PartyActionBar" type="HBoxContainer" parent="ChatPanel/RootVBox/ContentArea/PartyPane"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="PartyActionMargin" type="MarginContainer" parent="ChatPanel/RootVBox/ContentArea/PartyPane/PartyActionBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 4
|
||||
|
||||
[node name="PartyActionInner" type="HBoxContainer" parent="ChatPanel/RootVBox/ContentArea/PartyPane/PartyActionBar/PartyActionMargin"]
|
||||
@@ -373,26 +365,26 @@ theme_override_constants/separation = 6
|
||||
|
||||
[node name="PartyNameLabel" type="Label" parent="ChatPanel/RootVBox/ContentArea/PartyPane/PartyActionBar/PartyActionMargin/PartyActionInner"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.42, 1, 0.58, 1)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Party"
|
||||
modulate = Color(0.42, 1.0, 0.58, 1)
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Party"
|
||||
|
||||
[node name="RenameBtn" type="Button" parent="ChatPanel/RootVBox/ContentArea/PartyPane/PartyActionBar/PartyActionMargin/PartyActionInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
flat = true
|
||||
text = "Rename"
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "Rename"
|
||||
flat = true
|
||||
|
||||
[node name="LeaveBtn" type="Button" parent="ChatPanel/RootVBox/ContentArea/PartyPane/PartyActionBar/PartyActionMargin/PartyActionInner"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(1, 0.38, 0.38, 1)
|
||||
layout_mode = 2
|
||||
flat = true
|
||||
text = "Leave"
|
||||
modulate = Color(1.0, 0.38, 0.38, 1)
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "Leave"
|
||||
flat = true
|
||||
|
||||
[node name="PartyActionSep" type="HSeparator" parent="ChatPanel/RootVBox/ContentArea/PartyPane"]
|
||||
layout_mode = 2
|
||||
@@ -406,8 +398,8 @@ horizontal_scroll_mode = 0
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 4
|
||||
|
||||
[node name="PartyList" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/PartyPane/PartyScroll/PartyMargin"]
|
||||
@@ -417,18 +409,18 @@ size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 2
|
||||
|
||||
[node name="DmsPane" type="HBoxContainer" parent="ChatPanel/RootVBox/ContentArea"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
visible = false
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="DmConvArea" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/DmsPane"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(110, 0)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="DmConvScroll" type="ScrollContainer" parent="ChatPanel/RootVBox/ContentArea/DmsPane/DmConvArea"]
|
||||
@@ -459,8 +451,8 @@ horizontal_scroll_mode = 0
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 4
|
||||
|
||||
[node name="DmMsgList" type="VBoxContainer" parent="ChatPanel/RootVBox/ContentArea/DmsPane/DmMsgArea/DmMsgScroll/DmMsgMargin"]
|
||||
@@ -474,16 +466,16 @@ layout_mode = 2
|
||||
|
||||
[node name="InputBar" type="HBoxContainer" parent="ChatPanel/RootVBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="InputMargin" type="MarginContainer" parent="ChatPanel/RootVBox/InputBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 6
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 6
|
||||
|
||||
[node name="InputInner" type="HBoxContainer" parent="ChatPanel/RootVBox/InputBar/InputMargin"]
|
||||
@@ -495,13 +487,13 @@ theme_override_constants/separation = 6
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 13
|
||||
placeholder_text = "Type a message..."
|
||||
max_length = 500
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
[node name="SendBtn" type="Button" parent="ChatPanel/RootVBox/InputBar/InputMargin/InputInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(52, 0)
|
||||
text = "Send"
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Send"
|
||||
|
||||
@@ -72,6 +72,11 @@ var _current_tab : Tab = Tab.GLOBAL
|
||||
var _active_channel : String = "" # channel_id used by the input bar
|
||||
var _active_dm : String = "" # channel_id of the open DM conversation
|
||||
|
||||
const _BUBBLE_DEFAULT_LEFT := -58.0
|
||||
const _BUBBLE_DEFAULT_TOP := -219.0
|
||||
const _BUBBLE_DEFAULT_RIGHT := 2.0
|
||||
const _BUBBLE_DEFAULT_BOTTOM := -159.0
|
||||
|
||||
var _nicknames : Dictionary = {} # account_id → custom display name
|
||||
var _muted : Dictionary = {} # account_id → true
|
||||
|
||||
@@ -109,6 +114,45 @@ func _ready() -> void:
|
||||
_show_tab(Tab.GLOBAL)
|
||||
|
||||
|
||||
func set_overlay_visible(v: bool) -> void:
|
||||
visible = v
|
||||
var bubble := get_node_or_null("ChatBubble") as Control
|
||||
if is_instance_valid(bubble):
|
||||
bubble.visible = v
|
||||
if not v:
|
||||
var panel := get_node_or_null("ChatPanel") as Control
|
||||
if is_instance_valid(panel):
|
||||
panel.visible = false
|
||||
|
||||
|
||||
func set_bubble_host(host: Control) -> void:
|
||||
var bubble := get_node_or_null("ChatBubble") as Control
|
||||
if not is_instance_valid(bubble):
|
||||
return
|
||||
|
||||
var target: Node = self
|
||||
if is_instance_valid(host):
|
||||
target = host
|
||||
|
||||
if bubble.get_parent() != target:
|
||||
bubble.reparent(target)
|
||||
|
||||
if target == self:
|
||||
bubble.set_anchors_preset(Control.PRESET_BOTTOM_RIGHT)
|
||||
bubble.offset_left = _BUBBLE_DEFAULT_LEFT
|
||||
bubble.offset_top = _BUBBLE_DEFAULT_TOP
|
||||
bubble.offset_right = _BUBBLE_DEFAULT_RIGHT
|
||||
bubble.offset_bottom = _BUBBLE_DEFAULT_BOTTOM
|
||||
bubble.custom_minimum_size = Vector2.ZERO
|
||||
else:
|
||||
bubble.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
bubble.offset_left = 0.0
|
||||
bubble.offset_top = 0.0
|
||||
bubble.offset_right = 0.0
|
||||
bubble.offset_bottom = 0.0
|
||||
bubble.custom_minimum_size = Vector2(0, 36)
|
||||
|
||||
|
||||
func _connect_chat_signals() -> void:
|
||||
Chat.channels_updated.connect(_on_channels_updated)
|
||||
Chat.message_received.connect(_on_message_received)
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
[gd_scene load_steps=4 format=3]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://b6p3xap0lllom"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/collection/collection_screen.gd" id="1_cs"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/collection/views/CardsView.tscn" id="2_cv"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/collection/views/DecksView.tscn" id="3_dv"]
|
||||
[ext_resource type="Script" uid="uid://va08baxglyg5" path="res://scenes/collection/collection_screen.gd" id="1_cs"]
|
||||
[ext_resource type="PackedScene" uid="uid://ca8qmqtdwyt1s" path="res://scenes/collection/views/CardsView.tscn" id="2_cv"]
|
||||
[ext_resource type="PackedScene" uid="uid://rgeaiwwgwhli" path="res://scenes/collection/views/DecksView.tscn" id="3_dv"]
|
||||
|
||||
[node name="CollectionScreen" type="VBoxContainer"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
@@ -16,36 +15,35 @@ script = ExtResource("1_cs")
|
||||
[node name="TopBarMargin" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="TopBar" type="HBoxContainer" parent="TopBarMargin"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 40)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="BackBtn" type="Button" parent="TopBarMargin/TopBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(40, 40)
|
||||
text = "←"
|
||||
layout_mode = 2
|
||||
tooltip_text = "Back"
|
||||
theme_override_font_sizes/font_size = 18
|
||||
text = "←"
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="TopBarMargin/TopBar"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 18
|
||||
text = "Collection"
|
||||
vertical_alignment = 1
|
||||
theme_override_font_sizes/font_size = 18
|
||||
|
||||
[node name="SyncLabel" type="Label" parent="TopBarMargin/TopBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = ""
|
||||
visible = false
|
||||
modulate = Color(0.65, 0.65, 0.80, 1.0)
|
||||
modulate = Color(0.65, 0.65, 0.8, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="."]
|
||||
@@ -54,30 +52,30 @@ layout_mode = 2
|
||||
[node name="TabBarMargin" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 16
|
||||
theme_override_constants/margin_right = 16
|
||||
theme_override_constants/margin_top = 6
|
||||
theme_override_constants/margin_right = 16
|
||||
theme_override_constants/margin_bottom = 6
|
||||
|
||||
[node name="TabBar" type="HBoxContainer" parent="TabBarMargin"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="CardsTabBtn" type="Button" parent="TabBarMargin/TabBar"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
text = "Cards"
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "Cards"
|
||||
|
||||
[node name="DecksTabBtn" type="Button" parent="TabBarMargin/TabBar"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
text = "Decks"
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "Decks"
|
||||
|
||||
[node name="ContentArea" type="Control" parent="."]
|
||||
layout_mode = 2
|
||||
@@ -94,10 +92,10 @@ grow_vertical = 2
|
||||
|
||||
[node name="DecksView" parent="ContentArea" instance=ExtResource("3_dv")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
visible = false
|
||||
|
||||
@@ -29,7 +29,7 @@ func _ready() -> void:
|
||||
|
||||
# Add popup to the viewport root so it overlays above the VBoxContainer.
|
||||
_card_popup = CARD_DETAIL_POPUP.instantiate()
|
||||
get_tree().get_root().add_child(_card_popup)
|
||||
get_tree().get_root().call_deferred("add_child", _card_popup)
|
||||
cards_view.card_selected.connect(_on_card_selected)
|
||||
|
||||
_show_tab(0)
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://beig2rhm3ke2p"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/collection/components/ability_row.gd" id="1_ar"]
|
||||
[ext_resource type="Script" uid="uid://ci4kls86gx7tt" path="res://scenes/collection/components/ability_row.gd" id="1_ar"]
|
||||
|
||||
[sub_resource type="Theme" id="Theme_s626m"]
|
||||
|
||||
[node name="AbilityRow" type="VBoxContainer"]
|
||||
theme = SubResource("Theme_s626m")
|
||||
theme_override_constants/separation = 2
|
||||
script = ExtResource("1_ar")
|
||||
|
||||
[node name="NameLabel" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.9, 0.8, 0.5, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
modulate = Color(0.90, 0.80, 0.50, 1)
|
||||
|
||||
[node name="DescLabel" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.8, 0.8, 0.85, 1)
|
||||
layout_mode = 2
|
||||
autowrap_mode = 2
|
||||
modulate = Color(0.80, 0.80, 0.85, 1)
|
||||
theme_override_font_sizes/font_size = 12
|
||||
autowrap_mode = 2
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dinmbgl2jwppv"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dinmbgl2jwppv"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bbs4g6f1ax4er" path="res://scenes/collection/components/card_detail_popup.gd" id="1_cdp"]
|
||||
|
||||
[sub_resource type="Theme" id="Theme_jr2be"]
|
||||
|
||||
[node name="CardDetailPopup" type="Control"]
|
||||
visible = false
|
||||
layout_mode = 3
|
||||
@@ -10,6 +12,7 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = SubResource("Theme_jr2be")
|
||||
script = ExtResource("1_cdp")
|
||||
|
||||
[node name="Overlay" type="ColorRect" parent="."]
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
[node name="CardWidget" type="PanelContainer"]
|
||||
custom_minimum_size = Vector2(152, 238)
|
||||
offset_right = 160.0
|
||||
offset_bottom = 257.0
|
||||
script = ExtResource("1_cw")
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="."]
|
||||
@@ -53,7 +55,6 @@ unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(12, 12)
|
||||
layout_mode = 2
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="SpLabel" type="Label" parent="Margin/VBox/HeaderRow/CostColumn/SpRow"]
|
||||
unique_name_in_owner = true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bae5tlynmnhs1"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/collection/components/deck_editor_panel.gd" id="1_dep"]
|
||||
[ext_resource type="Script" uid="uid://bxbvry7ph16jy" path="res://scenes/collection/components/deck_editor_panel.gd" id="1_dep"]
|
||||
|
||||
[node name="DeckEditorPanel" type="VBoxContainer"]
|
||||
size_flags_horizontal = 3
|
||||
@@ -14,8 +14,8 @@ layout_mode = 2
|
||||
[node name="TopMargin" type="MarginContainer" parent="TopPanel"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="TopBar" type="HBoxContainer" parent="TopPanel/TopMargin"]
|
||||
@@ -24,24 +24,24 @@ theme_override_constants/separation = 8
|
||||
|
||||
[node name="BackBtn" type="Button" parent="TopPanel/TopMargin/TopBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(80, 32)
|
||||
layout_mode = 2
|
||||
text = "◄ Back"
|
||||
|
||||
[node name="TitleLabel" type="Label" parent="TopPanel/TopMargin/TopBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 15
|
||||
text = "Editing deck"
|
||||
text_overrun_behavior = 3
|
||||
theme_override_font_sizes/font_size = 15
|
||||
|
||||
[node name="CountLabel" type="Label" parent="TopPanel/TopMargin/TopBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "0 / 40"
|
||||
modulate = Color(0.75, 0.75, 0.8, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "0 / 40"
|
||||
|
||||
[node name="Split" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
@@ -57,8 +57,8 @@ theme_override_constants/separation = 4
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 6
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 6
|
||||
|
||||
[node name="LeftInner" type="VBoxContainer" parent="Split/Left/LeftMargin"]
|
||||
@@ -67,18 +67,18 @@ size_flags_vertical = 3
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="LeftHeader" type="Label" parent="Split/Left/LeftMargin/LeftInner"]
|
||||
layout_mode = 2
|
||||
text = "Deck Contents"
|
||||
modulate = Color(0.8, 0.8, 0.85, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Deck Contents"
|
||||
|
||||
[node name="DeckLoadingLabel" type="Label" parent="Split/Left/LeftMargin/LeftInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
visible = false
|
||||
text = "Loading…"
|
||||
modulate = Color(0.65, 0.65, 0.7, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Loading…"
|
||||
|
||||
[node name="DeckScroll" type="ScrollContainer" parent="Split/Left/LeftMargin/LeftInner"]
|
||||
layout_mode = 2
|
||||
@@ -103,8 +103,8 @@ theme_override_constants/separation = 4
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 6
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 6
|
||||
|
||||
[node name="RightInner" type="VBoxContainer" parent="Split/Right/RightMargin"]
|
||||
@@ -113,10 +113,10 @@ size_flags_vertical = 3
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="RightHeader" type="Label" parent="Split/Right/RightMargin/RightInner"]
|
||||
layout_mode = 2
|
||||
text = "Add Cards"
|
||||
modulate = Color(0.8, 0.8, 0.85, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Add Cards"
|
||||
|
||||
[node name="SearchBar" type="HBoxContainer" parent="Split/Right/RightMargin/RightInner"]
|
||||
layout_mode = 2
|
||||
@@ -124,25 +124,51 @@ theme_override_constants/separation = 4
|
||||
|
||||
[node name="SearchInput" type="LineEdit" parent="Split/Right/RightMargin/RightInner/SearchBar"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 30)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(0, 30)
|
||||
placeholder_text = "Search…"
|
||||
theme_override_font_sizes/font_size = 13
|
||||
placeholder_text = "Search…"
|
||||
|
||||
[node name="TypeOption" type="OptionButton" parent="Split/Right/RightMargin/RightInner/SearchBar"]
|
||||
unique_name_in_owner = true
|
||||
[node name="FilterBar" type="HBoxContainer" parent="Split/Right/RightMargin/RightInner"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="TypeOption" type="OptionButton" parent="Split/Right/RightMargin/RightInner/FilterBar"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(110, 30)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 12
|
||||
|
||||
[node name="AffinityMenuBtn" type="MenuButton" parent="Split/Right/RightMargin/RightInner/FilterBar"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(118, 30)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Affinities"
|
||||
|
||||
[node name="AffinityModeOption" type="OptionButton" parent="Split/Right/RightMargin/RightInner/FilterBar"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(72, 30)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
|
||||
[node name="SortOption" type="OptionButton" parent="Split/Right/RightMargin/RightInner/FilterBar"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(104, 30)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 12
|
||||
|
||||
[node name="CollLoadingLabel" type="Label" parent="Split/Right/RightMargin/RightInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
visible = false
|
||||
text = "Loading…"
|
||||
modulate = Color(0.65, 0.65, 0.7, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Loading…"
|
||||
|
||||
[node name="CollScroll" type="ScrollContainer" parent="Split/Right/RightMargin/RightInner"]
|
||||
layout_mode = 2
|
||||
@@ -157,6 +183,6 @@ theme_override_constants/separation = 2
|
||||
|
||||
[node name="LoadMoreBtn" type="Button" parent="Split/Right/RightMargin/RightInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
text = "Load More"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bqrlirkiqqpox"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/collection/components/deck_list_item.gd" id="1_di"]
|
||||
[ext_resource type="Script" uid="uid://dd5u354cto2ia" path="res://scenes/collection/components/deck_list_item.gd" id="1_di"]
|
||||
|
||||
[node name="DeckListItem" type="PanelContainer"]
|
||||
custom_minimum_size = Vector2(0, 64)
|
||||
@@ -30,16 +30,16 @@ theme_override_constants/separation = 0
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "Deck Name"
|
||||
text_overrun_behavior = 3
|
||||
theme_override_font_sizes/font_size = 14
|
||||
|
||||
[node name="NameEdit" type="LineEdit" parent="Margin/HBox/Info/NameRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(0, 28)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 14
|
||||
|
||||
[node name="SubRow" type="HBoxContainer" parent="Margin/HBox/Info"]
|
||||
@@ -50,23 +50,23 @@ theme_override_constants/separation = 8
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "No ArchSpirit"
|
||||
text_overrun_behavior = 3
|
||||
theme_override_font_sizes/font_size = 11
|
||||
|
||||
[node name="CountLabel" type="Label" parent="Margin/HBox/Info/SubRow"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.65, 0.65, 0.7, 1)
|
||||
layout_mode = 2
|
||||
text = "0 cards"
|
||||
modulate = Color(0.65, 0.65, 0.70, 1.0)
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "0 cards"
|
||||
|
||||
[node name="ValidLabel" type="Label" parent="Margin/HBox/Info/SubRow"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(1, 0.75, 0.2, 1)
|
||||
layout_mode = 2
|
||||
text = "⚠"
|
||||
modulate = Color(1.0, 0.75, 0.2, 1.0)
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "⚠"
|
||||
|
||||
[node name="Actions" type="HBoxContainer" parent="Margin/HBox"]
|
||||
layout_mode = 2
|
||||
@@ -74,50 +74,50 @@ theme_override_constants/separation = 4
|
||||
|
||||
[node name="EditBtn" type="Button" parent="Margin/HBox/Actions"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(60, 36)
|
||||
text = "Edit"
|
||||
layout_mode = 2
|
||||
tooltip_text = "Edit deck contents"
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Edit"
|
||||
|
||||
[node name="RenameBtn" type="Button" parent="Margin/HBox/Actions"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(36, 36)
|
||||
text = "✏"
|
||||
layout_mode = 2
|
||||
tooltip_text = "Rename"
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "✏"
|
||||
|
||||
[node name="CloneBtn" type="Button" parent="Margin/HBox/Actions"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(36, 36)
|
||||
text = "⧉"
|
||||
layout_mode = 2
|
||||
tooltip_text = "Clone deck"
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "⧉"
|
||||
|
||||
[node name="DeleteBtn" type="Button" parent="Margin/HBox/Actions"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(36, 36)
|
||||
text = "🗑"
|
||||
layout_mode = 2
|
||||
tooltip_text = "Delete deck"
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "🗑"
|
||||
|
||||
[node name="ConfirmRenameBtn" type="Button" parent="Margin/HBox/Actions"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(36, 36)
|
||||
text = "✓"
|
||||
tooltip_text = "Save name"
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(36, 36)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Save name"
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "✓"
|
||||
|
||||
[node name="CancelRenameBtn" type="Button" parent="Margin/HBox/Actions"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(36, 36)
|
||||
text = "✕"
|
||||
tooltip_text = "Cancel rename"
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(36, 36)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Cancel rename"
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "✕"
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://csxvfsdroxml1"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/collection/components/stat_row.gd" id="1_sr"]
|
||||
[ext_resource type="Script" uid="uid://cqckgl1qcf4ig" path="res://scenes/collection/components/stat_row.gd" id="1_sr"]
|
||||
|
||||
[sub_resource type="Theme" id="Theme_7pfs8"]
|
||||
|
||||
[node name="StatRow" type="HBoxContainer"]
|
||||
theme = SubResource("Theme_7pfs8")
|
||||
theme_override_constants/separation = 8
|
||||
script = ExtResource("1_sr")
|
||||
|
||||
[node name="KeyLabel" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(72, 0)
|
||||
modulate = Color(0.65, 0.65, 0.72, 1)
|
||||
custom_minimum_size = Vector2(72, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ValueLabel" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
@@ -6,11 +6,22 @@ extends Control
|
||||
##
|
||||
## Added to the viewport root at runtime by collection_screen.gd so it renders
|
||||
## above the VBoxContainer layout regardless of scene structure.
|
||||
##
|
||||
## Economy actions:
|
||||
## "List for Sale" — opens an inline listing form backed by bazaar.list_card.
|
||||
## "Salvage" — opens salvage_confirm_popup to destroy the card for OP.
|
||||
|
||||
const _CardWidget = preload("res://scenes/collection/components/card_widget.gd")
|
||||
const _StatRow = preload("res://scenes/collection/components/StatRow.tscn")
|
||||
const _AbilityRow = preload("res://scenes/collection/components/AbilityRow.tscn")
|
||||
|
||||
## Emitted after a successful salvage so the parent collection screen can
|
||||
## remove the card from its list without a full reload.
|
||||
signal card_salvaged(player_card_id: String)
|
||||
|
||||
## Emitted after a successful listing so the parent can update UI state.
|
||||
signal card_listed(player_card_id: String)
|
||||
|
||||
const RARITY_COLOR := {
|
||||
"Common": Color(0.67, 0.67, 0.67),
|
||||
"Uncommon": Color(0.27, 0.85, 0.27),
|
||||
@@ -19,6 +30,14 @@ const RARITY_COLOR := {
|
||||
"Legendary": Color(1.00, 0.67, 0.13),
|
||||
}
|
||||
|
||||
# Rarity → OP per combined SP+ST point (mirrors CardSalvageValues server-side).
|
||||
const SALVAGE_BASE := {
|
||||
"Common": 5, "Uncommon": 12, "Rare": 40, "Epic": 120, "Legendary": 300
|
||||
}
|
||||
const SALVAGE_COST_MULT := {
|
||||
"Common": 1, "Uncommon": 2, "Rare": 5, "Epic": 12, "Legendary": 25
|
||||
}
|
||||
|
||||
# ── Node refs ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@onready var overlay : ColorRect = %Overlay
|
||||
@@ -33,33 +52,69 @@ const RARITY_COLOR := {
|
||||
@onready var abilities_sep : HSeparator = %AbilitiesSep
|
||||
@onready var abilities_title: Label = %AbilitiesTitle
|
||||
@onready var abilities_list : VBoxContainer = %AbilitiesList
|
||||
@onready var action_row : HBoxContainer = %ActionRow
|
||||
@onready var list_btn : Button = %ListBtn
|
||||
@onready var salvage_btn : Button = %SalvageBtn
|
||||
@onready var list_form : VBoxContainer = %ListForm
|
||||
@onready var list_price_input : LineEdit = %ListPriceInput
|
||||
@onready var list_type_option : OptionButton = %ListTypeOption
|
||||
@onready var list_submit_btn : Button = %ListSubmitBtn
|
||||
@onready var list_cancel_btn : Button = %ListCancelBtn
|
||||
@onready var list_hint_label : Label = %ListHintLabel
|
||||
@onready var salvage_popup : Control = %SalvageConfirmPopup
|
||||
|
||||
# ── State ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
var _player_card_id : String = ""
|
||||
var _card_def_id : String = ""
|
||||
var _card_name : String = ""
|
||||
var _rarity : String = ""
|
||||
var _is_foil : bool = false
|
||||
var _sp_cost : int = 0
|
||||
var _st_cost : int = 0
|
||||
var _submitting : bool = false
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
overlay.gui_input.connect(_on_overlay_input)
|
||||
close_btn.pressed.connect(hide)
|
||||
list_btn.pressed.connect(_on_list_pressed)
|
||||
salvage_btn.pressed.connect(_on_salvage_pressed)
|
||||
list_submit_btn.pressed.connect(_on_list_submit)
|
||||
list_cancel_btn.pressed.connect(_hide_list_form)
|
||||
list_type_option.add_item("Fixed Price")
|
||||
list_type_option.add_item("Auction")
|
||||
|
||||
# ── Public API ────────────────────────────────────────────────────────────────
|
||||
|
||||
## show_card(dto, def)
|
||||
## dto: PlayerCardDto dict (playerCardId, isFoil, isTradeable, ...)
|
||||
## def: CardDefinition dict merged in by the collection screen (name, rarity, spCost, stCost, ...)
|
||||
func show_card(dto: Dictionary, def: Dictionary) -> void:
|
||||
var affinity := str(dto.get("affinity", ""))
|
||||
var rarity := str(dto.get("rarity", ""))
|
||||
var card_type := str(dto.get("cardType", ""))
|
||||
var is_foil := bool(dto.get("isFoil", false))
|
||||
_player_card_id = str(dto.get("playerCardId", ""))
|
||||
_card_def_id = str(dto.get("cardDefinitionId", def.get("cardDefinitionId", def.get("id", ""))))
|
||||
var affinity := str(dto.get("affinity", def.get("affinity", "")))
|
||||
_rarity = str(dto.get("rarity", def.get("rarity", "")))
|
||||
var card_type := str(dto.get("cardType", def.get("cardType", "")))
|
||||
_is_foil = bool(dto.get("isFoil", false))
|
||||
_sp_cost = int(def.get("spCost", 0))
|
||||
_st_cost = int(def.get("stCost", 0))
|
||||
_card_name = str(def.get("name", dto.get("name", "Unknown")))
|
||||
var is_tradeable := bool(dto.get("isTradeable", true))
|
||||
|
||||
# Header
|
||||
name_label.text = str(dto.get("name", "Unknown"))
|
||||
name_label.text = _card_name
|
||||
affinity_icon.texture = _CardWidget.affinity_icon(affinity)
|
||||
affinity_icon.modulate = _CardWidget.AFFINITY_BORDER.get(affinity, Color.WHITE)
|
||||
foil_badge.visible = is_foil
|
||||
foil_badge.visible = _is_foil
|
||||
|
||||
# Tags
|
||||
type_label.text = card_type
|
||||
affinity_label.text = affinity
|
||||
affinity_label.modulate = _CardWidget.AFFINITY_BORDER.get(affinity, Color.WHITE)
|
||||
rarity_label.text = rarity
|
||||
rarity_label.modulate = RARITY_COLOR.get(rarity, Color(0.67, 0.67, 0.67))
|
||||
rarity_label.text = _rarity
|
||||
rarity_label.modulate = RARITY_COLOR.get(_rarity, Color(0.67, 0.67, 0.67))
|
||||
|
||||
# Stats grid
|
||||
_populate_stats(def)
|
||||
@@ -67,8 +122,119 @@ func show_card(dto: Dictionary, def: Dictionary) -> void:
|
||||
# Abilities
|
||||
_populate_abilities(def)
|
||||
|
||||
# Economy buttons — only tradeable cards can be listed or salvaged.
|
||||
action_row.visible = is_tradeable
|
||||
list_btn.visible = is_tradeable
|
||||
salvage_btn.visible = is_tradeable
|
||||
if is_tradeable:
|
||||
var op := _calc_salvage_op()
|
||||
salvage_btn.text = "Salvage (%d OP)" % op
|
||||
|
||||
_hide_list_form()
|
||||
show()
|
||||
|
||||
# ── Economy helpers ───────────────────────────────────────────────────────────
|
||||
|
||||
func _calc_salvage_op() -> int:
|
||||
var base_val : int = SALVAGE_BASE.get(_rarity, 5)
|
||||
var mult : int = SALVAGE_COST_MULT.get(_rarity, 1)
|
||||
var value : int = base_val + (_sp_cost + _st_cost) * mult
|
||||
return value * 2 if _is_foil else value
|
||||
|
||||
|
||||
func _on_list_pressed() -> void:
|
||||
list_form.visible = true
|
||||
list_btn.visible = false
|
||||
# Fetch suggested price in the background; populate when it arrives.
|
||||
list_price_input.placeholder_text = "Loading suggestion..."
|
||||
list_hint_label.text = ""
|
||||
Network.request(
|
||||
"bazaar.get_suggested_price",
|
||||
{ "cardDefinitionId": _card_def_id, "isFoil": _is_foil },
|
||||
_on_price_suggestion_ok,
|
||||
_on_price_suggestion_err
|
||||
)
|
||||
|
||||
|
||||
func _on_price_suggestion_ok(_t: String, p: Variant) -> void:
|
||||
var d := p as Dictionary
|
||||
var suggested := float(d.get("suggestedPrice", 0))
|
||||
list_price_input.text = str(int(suggested))
|
||||
list_price_input.placeholder_text = ""
|
||||
var sale_count : int = int(d.get("saleCount", 0))
|
||||
if sale_count >= 3:
|
||||
list_hint_label.text = "Based on %d recent sales" % sale_count
|
||||
else:
|
||||
list_hint_label.text = "Suggested floor (no sale history)"
|
||||
|
||||
|
||||
func _on_price_suggestion_err(_code: String, _msg: String) -> void:
|
||||
var floor_op := _calc_salvage_op() * 4
|
||||
list_price_input.text = str(floor_op)
|
||||
list_price_input.placeholder_text = ""
|
||||
list_hint_label.text = "Using salvage-based floor"
|
||||
|
||||
|
||||
func _hide_list_form() -> void:
|
||||
list_form.visible = false
|
||||
list_btn.visible = true
|
||||
_submitting = false
|
||||
|
||||
|
||||
func _on_list_submit() -> void:
|
||||
if _submitting or _player_card_id.is_empty():
|
||||
return
|
||||
var price_str := list_price_input.text.strip_edges()
|
||||
if not price_str.is_valid_int() and not price_str.is_valid_float():
|
||||
list_hint_label.text = "Enter a valid price."
|
||||
return
|
||||
var price := float(price_str)
|
||||
if price <= 0:
|
||||
list_hint_label.text = "Price must be greater than 0."
|
||||
return
|
||||
|
||||
_submitting = true
|
||||
list_submit_btn.disabled = true
|
||||
list_hint_label.text = "Listing..."
|
||||
|
||||
var listing_type : String = "Fixed" if list_type_option.selected == 0 else "Auction"
|
||||
Network.request(
|
||||
"bazaar.list_card",
|
||||
{
|
||||
"playerCardId": _player_card_id,
|
||||
"price": price,
|
||||
"listingType": listing_type,
|
||||
"isMasked": false,
|
||||
},
|
||||
_on_list_ok,
|
||||
_on_list_err
|
||||
)
|
||||
|
||||
|
||||
func _on_list_ok(_t: String, _p: Variant) -> void:
|
||||
list_hint_label.text = "Listed successfully!"
|
||||
card_listed.emit(_player_card_id)
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
hide()
|
||||
|
||||
|
||||
func _on_list_err(code: String, _msg: String) -> void:
|
||||
_submitting = false
|
||||
list_submit_btn.disabled = false
|
||||
list_hint_label.text = "Error: %s" % code
|
||||
|
||||
|
||||
func _on_salvage_pressed() -> void:
|
||||
if _player_card_id.is_empty():
|
||||
return
|
||||
salvage_popup.show_confirm(_player_card_id, _card_name, _rarity, _is_foil, _calc_salvage_op())
|
||||
salvage_popup.confirmed.connect(_on_salvage_confirmed, CONNECT_ONE_SHOT)
|
||||
|
||||
|
||||
func _on_salvage_confirmed(player_card_id: String, op_awarded: int) -> void:
|
||||
card_salvaged.emit(player_card_id)
|
||||
hide()
|
||||
|
||||
|
||||
# ── Private ───────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ extends PanelContainer
|
||||
|
||||
const DEFAULT_CARD_ART_URL := "https://cdn.aeternalisgames.com/sor-assets/cardart/0_No-Card-Art.jpg"
|
||||
const GRAPHICS_BASE_URL := "https://cdn.aeternalisgames.com/sor-assets/graphics"
|
||||
const CDN_BASE_URL := "https://cdn.aeternalisgames.com"
|
||||
const CDN_PROXY_BASE_URL := "https://hub.aeternalisgames.com/cdn"
|
||||
const REMOTE_CACHE_DIR := "user://remote_texture_cache"
|
||||
const ICON_SP_URL := "%s/card_SP_Icon.png" % GRAPHICS_BASE_URL
|
||||
const ICON_ST_URL := "%s/card_ST_Icon.png" % GRAPHICS_BASE_URL
|
||||
@@ -312,7 +314,7 @@ func _format_genus(def: Dictionary) -> String:
|
||||
for tag in genus as Array:
|
||||
labels.append(str(tag))
|
||||
return ", ".join(labels)
|
||||
return "No Genus"
|
||||
return ""
|
||||
|
||||
|
||||
func _format_range(def: Dictionary) -> String:
|
||||
@@ -471,8 +473,8 @@ func _set_remote_texture(target: TextureRect, url: String, fallback_url: String
|
||||
requester.use_threads = true
|
||||
add_child(requester)
|
||||
requester.request_completed.connect(
|
||||
func(_result: int, response_code: int, _headers: PackedStringArray, body: PackedByteArray) -> void:
|
||||
if response_code >= 200 and response_code < 300:
|
||||
func(result: int, response_code: int, _headers: PackedStringArray, body: PackedByteArray) -> void:
|
||||
if result == HTTPRequest.RESULT_SUCCESS and response_code >= 200 and response_code < 300:
|
||||
var texture := _texture_from_bytes(final_url, body)
|
||||
if texture != null:
|
||||
_write_cache_file(cache_path, body)
|
||||
@@ -486,7 +488,7 @@ func _set_remote_texture(target: TextureRect, url: String, fallback_url: String
|
||||
requester.queue_free()
|
||||
)
|
||||
|
||||
var err := requester.request(final_url)
|
||||
var err := requester.request(_fetch_url(final_url))
|
||||
if err != OK:
|
||||
requester.queue_free()
|
||||
if not fallback_url.is_empty() and final_url != fallback_url:
|
||||
@@ -522,10 +524,26 @@ func _cache_path_for_url(url: String) -> String:
|
||||
|
||||
func _texture_from_bytes(url: String, body: PackedByteArray) -> Texture2D:
|
||||
var image := Image.new()
|
||||
var err := _load_image_from_bytes(image, url, body)
|
||||
if err != OK:
|
||||
return null
|
||||
|
||||
return ImageTexture.create_from_image(image)
|
||||
|
||||
|
||||
func _fetch_url(url: String) -> String:
|
||||
if OS.has_feature("web") and url.begins_with(CDN_BASE_URL + "/"):
|
||||
return CDN_PROXY_BASE_URL + "/" + url.substr(CDN_BASE_URL.length() + 1)
|
||||
return url
|
||||
|
||||
|
||||
func _load_image_from_bytes(image: Image, url: String, body: PackedByteArray) -> Error:
|
||||
var ext := url.get_file().get_extension().to_lower()
|
||||
var err := ERR_FILE_UNRECOGNIZED
|
||||
var sniffed := _sniff_image_format(body)
|
||||
var format := sniffed if not sniffed.is_empty() else ext
|
||||
|
||||
match ext:
|
||||
match format:
|
||||
"png":
|
||||
err = image.load_png_from_buffer(body)
|
||||
"jpg", "jpeg":
|
||||
@@ -534,15 +552,25 @@ func _texture_from_bytes(url: String, body: PackedByteArray) -> Texture2D:
|
||||
err = image.load_webp_from_buffer(body)
|
||||
"svg":
|
||||
err = image.load_svg_from_buffer(body)
|
||||
_:
|
||||
err = image.load_png_from_buffer(body)
|
||||
if err != OK:
|
||||
err = image.load_jpg_from_buffer(body)
|
||||
|
||||
if err != OK:
|
||||
return null
|
||||
return err
|
||||
|
||||
return ImageTexture.create_from_image(image)
|
||||
|
||||
func _sniff_image_format(body: PackedByteArray) -> String:
|
||||
if body.size() >= 8 \
|
||||
and body[0] == 0x89 and body[1] == 0x50 and body[2] == 0x4E and body[3] == 0x47 \
|
||||
and body[4] == 0x0D and body[5] == 0x0A and body[6] == 0x1A and body[7] == 0x0A:
|
||||
return "png"
|
||||
if body.size() >= 3 and body[0] == 0xFF and body[1] == 0xD8 and body[2] == 0xFF:
|
||||
return "jpg"
|
||||
if body.size() >= 12 \
|
||||
and body[0] == 0x52 and body[1] == 0x49 and body[2] == 0x46 and body[3] == 0x46 \
|
||||
and body[8] == 0x57 and body[9] == 0x45 and body[10] == 0x42 and body[11] == 0x50:
|
||||
return "webp"
|
||||
var preview := body.slice(0, mini(body.size(), 128)).get_string_from_utf8().strip_edges().to_lower()
|
||||
if preview.begins_with("<svg") or preview.begins_with("<?xml"):
|
||||
return "svg"
|
||||
return ""
|
||||
|
||||
|
||||
func _to_int(value: Variant) -> int:
|
||||
|
||||
@@ -4,22 +4,26 @@ extends VBoxContainer
|
||||
## Usage:
|
||||
## call open_deck(deck_id, deck_name) to load a deck for editing.
|
||||
## connect back_pressed to return to the deck list.
|
||||
##
|
||||
## The collection browser fetches the full owned map once (collection.get_owned)
|
||||
## and filters/sorts entirely client-side using ContentCache definitions.
|
||||
## No pagination or "load more" needed.
|
||||
|
||||
signal back_pressed()
|
||||
|
||||
const PAGE_SIZE := 100
|
||||
|
||||
# ── Node refs ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@onready var _title_lbl : Label = %TitleLabel
|
||||
@onready var _count_lbl : Label = %CountLabel
|
||||
@onready var _deck_loading_lbl : Label = %DeckLoadingLabel
|
||||
@onready var _title_lbl : Label = %TitleLabel
|
||||
@onready var _count_lbl : Label = %CountLabel
|
||||
@onready var _deck_loading_lbl : Label = %DeckLoadingLabel
|
||||
@onready var _deck_card_list : VBoxContainer = %DeckCardList
|
||||
@onready var _search_input : LineEdit = %SearchInput
|
||||
@onready var _type_option : OptionButton = %TypeOption
|
||||
@onready var _coll_loading_lbl : Label = %CollLoadingLabel
|
||||
@onready var _search_input : LineEdit = %SearchInput
|
||||
@onready var _type_option : OptionButton = %TypeOption
|
||||
@onready var _affinity_menu_btn : MenuButton = %AffinityMenuBtn
|
||||
@onready var _affinity_mode_option : OptionButton = %AffinityModeOption
|
||||
@onready var _sort_option : OptionButton = %SortOption
|
||||
@onready var _coll_loading_lbl : Label = %CollLoadingLabel
|
||||
@onready var _coll_list : VBoxContainer = %CollList
|
||||
@onready var _load_more_btn : Button = %LoadMoreBtn
|
||||
|
||||
# ── State ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -27,26 +31,54 @@ var _deck_id : String = ""
|
||||
var _deck_name : String = ""
|
||||
## { cardDefinitionId(String): quantity(int) } — kept in sync after mutations
|
||||
var _deck_qty : Dictionary = {}
|
||||
var _deck_cards : Array = []
|
||||
var _arch_spirit_id : String = ""
|
||||
var _arch_spirit_row : Control = null
|
||||
var _arch_picker_panel : Control = null
|
||||
|
||||
var _coll_page : int = 1
|
||||
var _coll_total : int = 0
|
||||
var _has_more : bool = false
|
||||
var _is_loading : bool = false
|
||||
var _search_timer : float = 0.0
|
||||
var _coll_req_gen : int = 0
|
||||
const _DEBOUNCE := 0.4
|
||||
## Full owned map fetched once: { definitionId(String) → ownedCount(int) }
|
||||
var _owned : Dictionary = {}
|
||||
var _search_timer : float = 0.0
|
||||
const _DEBOUNCE := 0.15
|
||||
const _AFFINITIES := [
|
||||
"Void", "Aether", "Lake", "Hill", "Forest", "Field",
|
||||
"Ocean", "Island", "Marsh", "Swamp",
|
||||
"Mountain", "Steppe", "Fort",
|
||||
"Plains", "Grove", "Jungle",
|
||||
"PerfectAether", "PureVoid",
|
||||
]
|
||||
const _AFFINITY_PARTS := {
|
||||
"Ocean": ["Lake"],
|
||||
"Island": ["Lake", "Hill"],
|
||||
"Marsh": ["Lake", "Forest"],
|
||||
"Swamp": ["Lake", "Field"],
|
||||
"Mountain": ["Hill"],
|
||||
"Steppe": ["Hill", "Forest"],
|
||||
"Fort": ["Hill", "Field"],
|
||||
"Plains": ["Forest"],
|
||||
"Grove": ["Forest", "Field"],
|
||||
"Jungle": ["Field"],
|
||||
"PerfectAether": ["Aether", "Lake", "Hill", "Forest", "Field"],
|
||||
"PureVoid": ["Void"],
|
||||
}
|
||||
var _selected_affinities : Array = []
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
%BackBtn.pressed.connect(func(): back_pressed.emit())
|
||||
_search_input.text_changed.connect(_on_search_changed)
|
||||
_type_option.item_selected.connect(func(_i): _reload_collection())
|
||||
_load_more_btn.pressed.connect(_on_load_more)
|
||||
_type_option.item_selected.connect(func(_i): _rebuild_coll_list())
|
||||
_affinity_mode_option.item_selected.connect(func(_i): _rebuild_coll_list())
|
||||
_sort_option.item_selected.connect(func(_i):
|
||||
_rebuild_coll_list()
|
||||
_render_deck_cards()
|
||||
)
|
||||
_affinity_menu_btn.get_popup().id_pressed.connect(_on_affinity_filter_pressed)
|
||||
%LoadMoreBtn.hide()
|
||||
_populate_type_options()
|
||||
_populate_affinity_options()
|
||||
_populate_sort_options()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
@@ -54,8 +86,7 @@ func _process(delta: float) -> void:
|
||||
_search_timer -= delta
|
||||
if _search_timer <= 0.0:
|
||||
_search_timer = 0.0
|
||||
_reload_collection()
|
||||
|
||||
_rebuild_coll_list()
|
||||
|
||||
|
||||
func _populate_type_options() -> void:
|
||||
@@ -64,6 +95,29 @@ func _populate_type_options() -> void:
|
||||
for t in ["ArchSpirit", "Spirit", "Ruin", "Terramorpha", "Repentance", "Instinct"]:
|
||||
_type_option.add_item(t)
|
||||
|
||||
|
||||
func _populate_affinity_options() -> void:
|
||||
_selected_affinities.clear()
|
||||
var popup := _affinity_menu_btn.get_popup()
|
||||
popup.clear()
|
||||
popup.add_check_item("Void", 0)
|
||||
for i in range(1, _AFFINITIES.size()):
|
||||
popup.add_check_item(str(_AFFINITIES[i]), i)
|
||||
_update_affinity_button_text()
|
||||
|
||||
_affinity_mode_option.clear()
|
||||
_affinity_mode_option.add_item("Any")
|
||||
_affinity_mode_option.add_item("All")
|
||||
_affinity_mode_option.selected = 0
|
||||
|
||||
|
||||
func _populate_sort_options() -> void:
|
||||
_sort_option.clear()
|
||||
_sort_option.add_item("Name")
|
||||
_sort_option.add_item("Type")
|
||||
_sort_option.add_item("Affinity")
|
||||
_sort_option.selected = 0
|
||||
|
||||
# ── Public ────────────────────────────────────────────────────────────────────
|
||||
|
||||
func open_deck(deck_id: String, deck_name: String) -> void:
|
||||
@@ -72,15 +126,20 @@ func open_deck(deck_id: String, deck_name: String) -> void:
|
||||
_title_lbl.text = "Editing: %s" % deck_name
|
||||
_search_input.text = ""
|
||||
_type_option.selected = 0
|
||||
_affinity_mode_option.selected = 0
|
||||
_sort_option.selected = 0
|
||||
_clear_affinity_filters()
|
||||
_deck_qty.clear()
|
||||
_deck_cards.clear()
|
||||
_load_deck_contents()
|
||||
_reload_collection()
|
||||
_fetch_owned()
|
||||
|
||||
# ── Deck contents ─────────────────────────────────────────────────────────────
|
||||
|
||||
func _load_deck_contents() -> void:
|
||||
for child in _deck_card_list.get_children():
|
||||
child.queue_free()
|
||||
_deck_cards.clear()
|
||||
_deck_loading_lbl.visible = true
|
||||
var cached := CollectionCache.get_deck_response(_deck_id)
|
||||
if not cached.is_empty():
|
||||
@@ -158,83 +217,73 @@ func _make_deck_row(card: Dictionary) -> Control:
|
||||
|
||||
return outer
|
||||
|
||||
# ── Collection browser ────────────────────────────────────────────────────────
|
||||
# ── Collection browser (client-side filtered) ─────────────────────────────────
|
||||
|
||||
func _reload_collection() -> void:
|
||||
_coll_page = 1
|
||||
_coll_total = 0
|
||||
_has_more = false
|
||||
func _fetch_owned() -> void:
|
||||
_coll_loading_lbl.visible = true
|
||||
var cached := CollectionCache.get_owned_map()
|
||||
if not cached.is_empty():
|
||||
_owned = cached
|
||||
_rebuild_coll_list()
|
||||
Network.request(
|
||||
"collection.get_owned",
|
||||
{},
|
||||
func(_t: String, p: Variant): _on_owned_response(p),
|
||||
func(_code: String, msg: String): _on_owned_error(msg)
|
||||
)
|
||||
|
||||
|
||||
func _on_owned_response(payload: Variant) -> void:
|
||||
var p := payload as Dictionary
|
||||
var raw : Variant = p.get("owned", {})
|
||||
_owned = raw if typeof(raw) == TYPE_DICTIONARY else {}
|
||||
CollectionCache.store_owned_map(_owned)
|
||||
_coll_loading_lbl.visible = false
|
||||
_rebuild_coll_list()
|
||||
|
||||
|
||||
func _on_owned_error(msg: String) -> void:
|
||||
_coll_loading_lbl.visible = false
|
||||
push_warning("DeckEditor owned: %s" % msg)
|
||||
|
||||
|
||||
func _rebuild_coll_list() -> void:
|
||||
for child in _coll_list.get_children():
|
||||
child.queue_free()
|
||||
_load_more_btn.visible = false
|
||||
var cached := CollectionCache.get_cards_response(_collection_query_key(1))
|
||||
if not cached.is_empty():
|
||||
_render_coll_response(cached, 1)
|
||||
_fetch_coll_page(1)
|
||||
|
||||
var search := _search_input.text.strip_edges().to_lower()
|
||||
var type_idx := _type_option.selected
|
||||
var type_filter := _type_option.get_item_text(type_idx) if type_idx > 0 else ""
|
||||
var sort_key := _sort_option.get_item_text(_sort_option.selected).to_lower()
|
||||
|
||||
func _fetch_coll_page(page: int) -> void:
|
||||
if _is_loading:
|
||||
return
|
||||
var rows : Array = []
|
||||
for def_id_var in _owned:
|
||||
var def_id := str(def_id_var)
|
||||
var def := ContentCache.get_definition(def_id)
|
||||
if def.is_empty():
|
||||
continue
|
||||
var card_name := str(def.get("name", ""))
|
||||
var card_type := str(def.get("cardType", ""))
|
||||
var affinity := str(def.get("affinity", ""))
|
||||
if not search.is_empty() and not card_name.to_lower().contains(search):
|
||||
continue
|
||||
if not type_filter.is_empty() and card_type != type_filter:
|
||||
continue
|
||||
if not _passes_affinity_filter(affinity):
|
||||
continue
|
||||
rows.append({
|
||||
"cardDefinitionId": def_id,
|
||||
"name": card_name,
|
||||
"cardType": card_type,
|
||||
"affinity": affinity,
|
||||
"rarity": str(def.get("rarity", "")),
|
||||
"tier": def.get("tier"),
|
||||
"ownedCount": int(_owned[def_id_var]),
|
||||
})
|
||||
|
||||
_is_loading = true
|
||||
_coll_loading_lbl.visible = true
|
||||
|
||||
# Bump generation so stale async responses can be ignored.
|
||||
_coll_req_gen += 1
|
||||
var req_gen := _coll_req_gen
|
||||
|
||||
var payload := { "page": page, "pageSize": PAGE_SIZE }
|
||||
payload["groupByDefinition"] = true
|
||||
var search := _search_input.text.strip_edges()
|
||||
if not search.is_empty():
|
||||
payload["nameFilter"] = search
|
||||
|
||||
var type_idx := _type_option.selected
|
||||
if type_idx > 0:
|
||||
payload["cardTypeFilter"] = _type_option.get_item_text(type_idx)
|
||||
|
||||
Network.request(
|
||||
"collection.get_cards",
|
||||
payload,
|
||||
func(_t: String, p: Variant):
|
||||
_on_coll_response(p, page, req_gen),
|
||||
func(_code: String, msg: String):
|
||||
# Only surface error if this is still current request generation.
|
||||
if req_gen == _coll_req_gen:
|
||||
_on_coll_error(msg)
|
||||
)
|
||||
|
||||
func _on_coll_response(payload: Variant, page: int, req_gen: int) -> void:
|
||||
if req_gen != _coll_req_gen:
|
||||
return
|
||||
var p_cache := payload as Dictionary
|
||||
CollectionCache.store_cards_response(_collection_query_key(page), p_cache)
|
||||
_render_coll_response(p_cache, page)
|
||||
#var cards : Array = []
|
||||
#
|
||||
## Track def_ids already in the list to avoid duplicates across pages
|
||||
#var seen : Dictionary = {}
|
||||
#for child in _coll_list.get_children():
|
||||
#if child.has_meta("def_id"):
|
||||
#seen[str(child.get_meta("def_id"))] = true
|
||||
#
|
||||
#for dto in cards:
|
||||
#var def_id := str(dto.get("cardDefinitionId", ""))
|
||||
#if def_id.is_empty() or def_id in seen:
|
||||
#continue
|
||||
### Tier 1 ArchSpirits are commanders — cannot be added as deck cards
|
||||
##if str(dto.get("cardType", "")) == "ArchSpirit" \
|
||||
##and int(dto.get("tier", 1)) <= 1:
|
||||
##continue
|
||||
#seen[def_id] = true
|
||||
#_coll_list.add_child(_make_coll_row(dto))
|
||||
|
||||
|
||||
func _on_coll_error(msg: String) -> void:
|
||||
_is_loading = false
|
||||
_coll_loading_lbl.visible = false
|
||||
push_warning("DeckEditor collection: %s" % msg)
|
||||
rows.sort_custom(func(a, b): return _sort_collection_rows(a, b, sort_key))
|
||||
for dto in rows:
|
||||
_coll_list.add_child(_make_coll_row(dto))
|
||||
|
||||
|
||||
func _make_coll_row(dto: Dictionary) -> Control:
|
||||
@@ -296,13 +345,86 @@ func _refresh_coll_in_deck_labels() -> void:
|
||||
(child.get_meta("deck_lbl") as Label).text = "In deck: %d" % in_deck
|
||||
|
||||
|
||||
func _on_load_more() -> void:
|
||||
_fetch_coll_page(_coll_page + 1)
|
||||
|
||||
|
||||
func _on_search_changed(_t: String) -> void:
|
||||
_search_timer = _DEBOUNCE
|
||||
|
||||
|
||||
func _on_affinity_filter_pressed(id: int) -> void:
|
||||
if id < 0 or id >= _AFFINITIES.size():
|
||||
return
|
||||
var affinity := str(_AFFINITIES[id])
|
||||
var popup := _affinity_menu_btn.get_popup()
|
||||
var idx := popup.get_item_index(id)
|
||||
var checked := not popup.is_item_checked(idx)
|
||||
popup.set_item_checked(idx, checked)
|
||||
if checked and affinity not in _selected_affinities:
|
||||
_selected_affinities.append(affinity)
|
||||
elif not checked:
|
||||
_selected_affinities.erase(affinity)
|
||||
_update_affinity_button_text()
|
||||
_rebuild_coll_list()
|
||||
|
||||
|
||||
func _clear_affinity_filters() -> void:
|
||||
_selected_affinities.clear()
|
||||
if not is_inside_tree():
|
||||
return
|
||||
var popup := _affinity_menu_btn.get_popup()
|
||||
for i in range(popup.item_count):
|
||||
popup.set_item_checked(i, false)
|
||||
_update_affinity_button_text()
|
||||
|
||||
|
||||
func _update_affinity_button_text() -> void:
|
||||
if _selected_affinities.is_empty():
|
||||
_affinity_menu_btn.text = "Affinities"
|
||||
elif _selected_affinities.size() == 1:
|
||||
_affinity_menu_btn.text = str(_selected_affinities[0])
|
||||
else:
|
||||
_affinity_menu_btn.text = "%d Affinities" % _selected_affinities.size()
|
||||
|
||||
|
||||
func _passes_affinity_filter(card_affinity: String) -> bool:
|
||||
if _selected_affinities.is_empty():
|
||||
return true
|
||||
var terms : Array = _affinity_terms(card_affinity)
|
||||
var require_all : bool = _affinity_mode_option.selected == 1
|
||||
for selected in _selected_affinities:
|
||||
var has_term : bool = selected in terms
|
||||
if require_all and not has_term:
|
||||
return false
|
||||
if not require_all and has_term:
|
||||
return true
|
||||
return require_all
|
||||
|
||||
|
||||
func _affinity_terms(card_affinity: String) -> Array:
|
||||
var terms : Array = []
|
||||
if not card_affinity.is_empty():
|
||||
terms.append(card_affinity)
|
||||
var parts : Variant = _AFFINITY_PARTS.get(card_affinity, [])
|
||||
if typeof(parts) == TYPE_ARRAY:
|
||||
for part in parts as Array:
|
||||
if str(part) not in terms:
|
||||
terms.append(str(part))
|
||||
return terms
|
||||
|
||||
|
||||
func _sort_collection_rows(a: Dictionary, b: Dictionary, sort_key: String) -> bool:
|
||||
match sort_key:
|
||||
"type":
|
||||
var type_cmp := str(a["cardType"]).naturalnocasecmp_to(str(b["cardType"]))
|
||||
if type_cmp != 0:
|
||||
return type_cmp < 0
|
||||
"affinity":
|
||||
var aff_cmp := str(a["affinity"]).naturalnocasecmp_to(str(b["affinity"]))
|
||||
if aff_cmp != 0:
|
||||
return aff_cmp < 0
|
||||
var name_cmp := str(a["name"]).naturalnocasecmp_to(str(b["name"]))
|
||||
if name_cmp != 0:
|
||||
return name_cmp < 0
|
||||
return str(a["cardDefinitionId"]) < str(b["cardDefinitionId"])
|
||||
|
||||
# ── Mutate: add / remove ──────────────────────────────────────────────────────
|
||||
|
||||
func _add_card(def_id: String) -> void:
|
||||
@@ -339,10 +461,9 @@ func _render_deck_response(payload: Dictionary) -> void:
|
||||
|
||||
# ── Commander (Tier-1 ArchSpirit) ───────────────────────────────────────
|
||||
_arch_spirit_id = str(deck.get("archSpiritCardDefinitionId", ""))
|
||||
_update_arch_spirit_row()
|
||||
|
||||
var cards : Array = deck.get("cards", [])
|
||||
_deck_qty.clear()
|
||||
_deck_cards.clear()
|
||||
var non_as_total := 0
|
||||
for raw_card in cards:
|
||||
var card := raw_card as Dictionary
|
||||
@@ -353,48 +474,14 @@ func _render_deck_response(payload: Dictionary) -> void:
|
||||
var def := ContentCache.get_definition(def_id)
|
||||
if str(def.get("cardType", "")) != "ArchSpirit":
|
||||
non_as_total += qty
|
||||
_deck_cards.append(_hydrate_card_dto(card, def))
|
||||
|
||||
_count_lbl.text = "%d / 40" % non_as_total
|
||||
|
||||
for raw_card in cards:
|
||||
var card := raw_card as Dictionary
|
||||
var def := ContentCache.get_definition(str(card.get("cardDefinitionId", "")))
|
||||
_deck_card_list.add_child(_make_deck_row(_hydrate_card_dto(card, def)))
|
||||
|
||||
_render_deck_cards()
|
||||
_refresh_coll_in_deck_labels()
|
||||
|
||||
|
||||
func _render_coll_response(payload: Dictionary, page: int) -> void:
|
||||
_is_loading = false
|
||||
_coll_loading_lbl.visible = false
|
||||
var cards : Array = payload.get("cards", [])
|
||||
_coll_total = int(payload.get("totalCount", 0))
|
||||
var page_size := int(payload.get("pageSize", PAGE_SIZE))
|
||||
_coll_page = page
|
||||
_has_more = (page * page_size) < _coll_total
|
||||
_load_more_btn.visible = _has_more
|
||||
|
||||
if page == 1:
|
||||
for child in _coll_list.get_children():
|
||||
child.queue_free()
|
||||
|
||||
var seen : Dictionary = {}
|
||||
if page > 1:
|
||||
for child in _coll_list.get_children():
|
||||
if child.has_meta("def_id"):
|
||||
seen[str(child.get_meta("def_id"))] = true
|
||||
|
||||
|
||||
for raw_dto in cards:
|
||||
var dto := raw_dto as Dictionary
|
||||
var def_id := str(dto.get("cardDefinitionId", ""))
|
||||
if def_id.is_empty() or def_id in seen:
|
||||
continue
|
||||
var def := ContentCache.get_definition(def_id)
|
||||
seen[def_id] = true
|
||||
_coll_list.add_child(_make_coll_row(_hydrate_card_dto(dto, def)))
|
||||
|
||||
|
||||
func _hydrate_card_dto(dto: Dictionary, def: Dictionary) -> Dictionary:
|
||||
var hydrated := dto.duplicate(true)
|
||||
if def.is_empty():
|
||||
@@ -407,18 +494,21 @@ func _hydrate_card_dto(dto: Dictionary, def: Dictionary) -> Dictionary:
|
||||
hydrated["tier"] = tier_value if tier_value != null else null
|
||||
return hydrated
|
||||
|
||||
|
||||
func _collection_query_key(page: int) -> String:
|
||||
var search := _search_input.text.strip_edges()
|
||||
var type_filter := ""
|
||||
var type_idx := _type_option.selected
|
||||
if type_idx > 0:
|
||||
type_filter = _type_option.get_item_text(type_idx)
|
||||
return CollectionCache.cards_query_key(page, PAGE_SIZE, search, type_filter)
|
||||
|
||||
|
||||
# ── Commander / ArchSpirit swap ───────────────────────────────────────────────
|
||||
|
||||
func _render_deck_cards() -> void:
|
||||
if not is_instance_valid(_deck_card_list):
|
||||
return
|
||||
for child in _deck_card_list.get_children():
|
||||
child.queue_free()
|
||||
_update_arch_spirit_row()
|
||||
var cards := _deck_cards.duplicate(true)
|
||||
var sort_key := _sort_option.get_item_text(_sort_option.selected).to_lower() if _sort_option.item_count > 0 else "name"
|
||||
cards.sort_custom(func(a, b): return _sort_collection_rows(a, b, sort_key))
|
||||
for card in cards:
|
||||
_deck_card_list.add_child(_make_deck_row(card as Dictionary))
|
||||
|
||||
|
||||
func _update_arch_spirit_row() -> void:
|
||||
if is_instance_valid(_arch_spirit_row):
|
||||
_arch_spirit_row.queue_free()
|
||||
@@ -513,36 +603,36 @@ func _build_arch_picker_panel() -> Control:
|
||||
list.add_theme_constant_override("separation", 4)
|
||||
scroll.add_child(list)
|
||||
|
||||
var loading_lbl := Label.new()
|
||||
loading_lbl.text = "Loading..."
|
||||
list.add_child(loading_lbl)
|
||||
# Build from owned map — no extra network request needed.
|
||||
# null Tier in definitions is treated as Tier 1 (matches server rule).
|
||||
var arch_spirits : Array = []
|
||||
for def_id_var in _owned:
|
||||
var def_id := str(def_id_var)
|
||||
var def := ContentCache.get_definition(def_id)
|
||||
if def.is_empty() or str(def.get("cardType", "")) != "ArchSpirit":
|
||||
continue
|
||||
var tier_val : Variant = def.get("tier", null)
|
||||
var tier_int := int(tier_val) if tier_val != null else 1
|
||||
if tier_int != 1:
|
||||
continue
|
||||
arch_spirits.append({ "def_id": def_id, "name": str(def.get("name", def_id)) })
|
||||
|
||||
arch_spirits.sort_custom(func(a, b): return str(a["name"]) < str(b["name"]))
|
||||
|
||||
for entry in arch_spirits:
|
||||
var row_btn := Button.new()
|
||||
row_btn.text = str(entry["name"])
|
||||
row_btn.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
||||
row_btn.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
row_btn.disabled = str(entry["def_id"]) == _arch_spirit_id
|
||||
row_btn.pressed.connect(_set_arch_spirit.bind(str(entry["def_id"])))
|
||||
list.add_child(row_btn)
|
||||
|
||||
if list.get_child_count() == 0:
|
||||
var empty_lbl := Label.new()
|
||||
empty_lbl.text = "No Tier-1 ArchSpirits in collection."
|
||||
list.add_child(empty_lbl)
|
||||
|
||||
Network.request(
|
||||
"collection.get_cards",
|
||||
{ "page": 1, "pageSize": 50, "cardTypeFilter": "ArchSpirit", "tierFilter": 1 },
|
||||
func(_t: String, p: Variant):
|
||||
if not is_instance_valid(list):
|
||||
return
|
||||
loading_lbl.queue_free()
|
||||
var cards : Array = (p as Dictionary).get("cards", [])
|
||||
for raw in cards:
|
||||
var dto := raw as Dictionary
|
||||
var def_id := str(dto.get("cardDefinitionId", ""))
|
||||
if def_id.is_empty():
|
||||
continue
|
||||
var def := ContentCache.get_definition(def_id)
|
||||
var card_name : String = str(def.get("name", dto.get("name", "?")))
|
||||
var row_btn := Button.new()
|
||||
row_btn.text = card_name
|
||||
row_btn.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
||||
row_btn.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
row_btn.disabled = def_id == _arch_spirit_id
|
||||
row_btn.pressed.connect(_set_arch_spirit.bind(def_id))
|
||||
list.add_child(row_btn),
|
||||
func(_code: String, msg: String):
|
||||
if is_instance_valid(loading_lbl):
|
||||
loading_lbl.text = "Failed: %s" % msg
|
||||
)
|
||||
return panel
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
extends Control
|
||||
## Salvage confirmation popup.
|
||||
##
|
||||
## Call show_confirm(...) to populate and display.
|
||||
## Emits confirmed(player_card_id, op_awarded) on success.
|
||||
## Emits cancelled() if the player backs out.
|
||||
##
|
||||
## The popup sends collection.salvage_card to the server and only emits
|
||||
## confirmed after a successful response, so the caller never needs to
|
||||
## handle partial state.
|
||||
|
||||
signal confirmed(player_card_id: String, op_awarded: int)
|
||||
signal cancelled
|
||||
|
||||
# ── Node refs ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@onready var overlay : ColorRect = %Overlay
|
||||
@onready var card_name_lbl: Label = %CardNameLbl
|
||||
@onready var rarity_lbl : Label = %RarityLbl
|
||||
@onready var foil_lbl : Label = %FoilLbl
|
||||
@onready var reward_lbl : Label = %RewardLbl
|
||||
@onready var confirm_btn : Button = %ConfirmBtn
|
||||
@onready var cancel_btn : Button = %CancelBtn
|
||||
@onready var status_lbl : Label = %StatusLbl
|
||||
|
||||
const RARITY_COLOR := {
|
||||
"Common": Color(0.67, 0.67, 0.67),
|
||||
"Uncommon": Color(0.27, 0.85, 0.27),
|
||||
"Rare": Color(0.27, 0.53, 1.00),
|
||||
"Epic": Color(0.67, 0.27, 1.00),
|
||||
"Legendary": Color(1.00, 0.67, 0.13),
|
||||
}
|
||||
|
||||
# ── State ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
var _player_card_id : String = ""
|
||||
var _op_preview : int = 0
|
||||
var _busy : bool = false
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
confirm_btn.pressed.connect(_on_confirm)
|
||||
cancel_btn.pressed.connect(_on_cancel)
|
||||
overlay.gui_input.connect(_on_overlay_input)
|
||||
hide()
|
||||
|
||||
# ── Public API ────────────────────────────────────────────────────────────────
|
||||
|
||||
func show_confirm(
|
||||
player_card_id : String,
|
||||
card_name : String,
|
||||
rarity : String,
|
||||
is_foil : bool,
|
||||
op_preview : int) -> void:
|
||||
_player_card_id = player_card_id
|
||||
_op_preview = op_preview
|
||||
_busy = false
|
||||
confirm_btn.disabled = false
|
||||
status_lbl.text = "This cannot be undone."
|
||||
|
||||
card_name_lbl.text = card_name
|
||||
rarity_lbl.text = rarity
|
||||
rarity_lbl.modulate = RARITY_COLOR.get(rarity, Color.WHITE)
|
||||
foil_lbl.visible = is_foil
|
||||
reward_lbl.text = "You will receive ◆ %d OP" % op_preview
|
||||
|
||||
show()
|
||||
|
||||
# ── Handlers ──────────────────────────────────────────────────────────────────
|
||||
|
||||
func _on_confirm() -> void:
|
||||
if _busy or _player_card_id.is_empty():
|
||||
return
|
||||
_busy = true
|
||||
confirm_btn.disabled = true
|
||||
status_lbl.text = "Salvaging..."
|
||||
|
||||
Network.request(
|
||||
"collection.salvage_card",
|
||||
{ "playerCardId": _player_card_id },
|
||||
_on_ok,
|
||||
_on_err
|
||||
)
|
||||
|
||||
|
||||
func _on_ok(_t: String, p: Variant) -> void:
|
||||
var d := p as Dictionary
|
||||
var op_awarded : int = int(d.get("originPointsAwarded", _op_preview))
|
||||
status_lbl.text = "Done! ◆ %d OP awarded." % op_awarded
|
||||
await get_tree().create_timer(0.8).timeout
|
||||
confirmed.emit(_player_card_id, op_awarded)
|
||||
hide()
|
||||
|
||||
|
||||
func _on_err(code: String, _msg: String) -> void:
|
||||
_busy = false
|
||||
confirm_btn.disabled = false
|
||||
status_lbl.text = "Error: %s" % code
|
||||
|
||||
|
||||
func _on_cancel() -> void:
|
||||
if _busy:
|
||||
return
|
||||
cancelled.emit()
|
||||
hide()
|
||||
|
||||
|
||||
func _on_overlay_input(event: InputEvent) -> void:
|
||||
if _busy:
|
||||
return
|
||||
if event is InputEventMouseButton and event.pressed:
|
||||
_on_cancel()
|
||||
elif event is InputEventScreenTouch and event.pressed:
|
||||
_on_cancel()
|
||||
@@ -0,0 +1 @@
|
||||
uid://borckhkljxkbb
|
||||
@@ -1,47 +1,46 @@
|
||||
[gd_scene load_steps=3 format=3]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://rgeaiwwgwhli"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/collection/views/decks_view.gd" id="1_dv"]
|
||||
[ext_resource type="Script" uid="uid://vbuabpoyb47" path="res://scenes/collection/views/decks_view.gd" id="1_dv"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/collection/components/DeckEditorPanel.tscn" id="2_dep"]
|
||||
|
||||
[node name="DecksView" type="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
script = ExtResource("1_dv")
|
||||
|
||||
[node name="HeaderMargin" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="Header" type="HBoxContainer" parent="HeaderMargin"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 34)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="HeaderLabel" type="Label" parent="HeaderMargin/Header"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Decks"
|
||||
theme_override_font_sizes/font_size = 16
|
||||
text = "Decks"
|
||||
|
||||
[node name="NewDeckBtn" type="Button" parent="HeaderMargin/Header"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 34)
|
||||
text = "+ New Deck"
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "+ New Deck"
|
||||
|
||||
[node name="NewDeckForm" type="PanelContainer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="FormMargin" type="MarginContainer" parent="NewDeckForm"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_top = 10
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_bottom = 10
|
||||
|
||||
[node name="FormVBox" type="VBoxContainer" parent="NewDeckForm/FormMargin"]
|
||||
@@ -50,25 +49,25 @@ theme_override_constants/separation = 10
|
||||
|
||||
[node name="FormTitle" type="Label" parent="NewDeckForm/FormMargin/FormVBox"]
|
||||
layout_mode = 2
|
||||
text = "New Deck"
|
||||
theme_override_font_sizes/font_size = 15
|
||||
text = "New Deck"
|
||||
|
||||
[node name="DeckNameInput" type="LineEdit" parent="NewDeckForm/FormMargin/FormVBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
placeholder_text = "Deck Name"
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 14
|
||||
placeholder_text = "Deck Name"
|
||||
|
||||
[node name="ArchSpiritLabel" type="Label" parent="NewDeckForm/FormMargin/FormVBox"]
|
||||
modulate = Color(0.8, 0.8, 0.85, 1)
|
||||
layout_mode = 2
|
||||
text = "ArchSpirit Card"
|
||||
theme_override_font_sizes/font_size = 13
|
||||
modulate = Color(0.8, 0.8, 0.85, 1.0)
|
||||
text = "ArchSpirit Card"
|
||||
|
||||
[node name="ArchSpiritScroll" type="ScrollContainer" parent="NewDeckForm/FormMargin/FormVBox"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 170)
|
||||
layout_mode = 2
|
||||
vertical_scroll_mode = 0
|
||||
|
||||
[node name="ArchSpiritGrid" type="HBoxContainer" parent="NewDeckForm/FormMargin/FormVBox/ArchSpiritScroll"]
|
||||
@@ -78,10 +77,10 @@ theme_override_constants/separation = 8
|
||||
|
||||
[node name="ArchSpiritHint" type="Label" parent="NewDeckForm/FormMargin/FormVBox"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(1, 0.75, 0.3, 1)
|
||||
layout_mode = 2
|
||||
text = "Select an ArchSpirit card to continue."
|
||||
modulate = Color(1.0, 0.75, 0.3, 1.0)
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Select an ArchSpirit card to continue."
|
||||
|
||||
[node name="FormButtons" type="HBoxContainer" parent="NewDeckForm/FormMargin/FormVBox"]
|
||||
layout_mode = 2
|
||||
@@ -89,20 +88,20 @@ theme_override_constants/separation = 8
|
||||
|
||||
[node name="CancelNewBtn" type="Button" parent="NewDeckForm/FormMargin/FormVBox/FormButtons"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
text = "Cancel"
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "Cancel"
|
||||
|
||||
[node name="CreateBtn" type="Button" parent="NewDeckForm/FormMargin/FormVBox/FormButtons"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
text = "Create"
|
||||
disabled = true
|
||||
theme_override_font_sizes/font_size = 14
|
||||
disabled = true
|
||||
text = "Create"
|
||||
|
||||
[node name="Scroll" type="ScrollContainer" parent="."]
|
||||
layout_mode = 2
|
||||
@@ -113,8 +112,8 @@ horizontal_scroll_mode = 0
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="DeckList" type="VBoxContainer" parent="Scroll/DeckListMargin"]
|
||||
@@ -124,30 +123,29 @@ size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="StatusRow" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 44)
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="LoadingLabel" type="Label" parent="StatusRow"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.75, 0.75, 0.8, 1)
|
||||
layout_mode = 2
|
||||
text = "Loading…"
|
||||
modulate = Color(0.75, 0.75, 0.8, 1.0)
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "Loading…"
|
||||
|
||||
[node name="EmptyLabel" type="Label" parent="StatusRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "No decks yet. Tap + to create one."
|
||||
visible = false
|
||||
modulate = Color(0.6, 0.6, 0.65, 1.0)
|
||||
modulate = Color(0.6, 0.6, 0.65, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "No decks yet. Tap + to create one."
|
||||
|
||||
[node name="DeckEditorPanel" parent="." instance=ExtResource("2_dep")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ConfirmDialog" type="ConfirmationDialog" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
@@ -1,36 +1,28 @@
|
||||
extends VBoxContainer
|
||||
## Cards tab — paginated, filterable grid of the player's owned cards.
|
||||
## Cards tab — filterable, sortable grid of the player's owned cards.
|
||||
##
|
||||
## Fetches from collection.get_cards (page, pageSize, nameFilter?,
|
||||
## cardTypeFilter?, affinityFilter?). Displays results as CardWidget
|
||||
## instances in a responsive GridContainer.
|
||||
##
|
||||
## Typing in the search box starts a 0.4 s debounce before reloading.
|
||||
## "Load More" appends the next page without clearing the existing cards.
|
||||
## Fetches the full owned map once (collection.get_owned), then all filtering,
|
||||
## search, and sorting happen client-side using ContentCache definitions.
|
||||
## No "load more" or pagination.
|
||||
|
||||
const CARD_WIDGET := preload("res://scenes/collection/components/CardWidget.tscn")
|
||||
const PAGE_SIZE := 20
|
||||
const CARD_WIDGET := preload("res://scenes/collection/components/CardWidget.tscn")
|
||||
const CARD_WIDTH_ESTIMATE := 168
|
||||
|
||||
# ── Node references ───────────────────────────────────────────────────────────
|
||||
|
||||
@onready var search_input : LineEdit = %SearchInput
|
||||
@onready var type_option : OptionButton = %TypeOption
|
||||
@onready var affinity_option : OptionButton = %AffinityOption
|
||||
@onready var card_grid : GridContainer = %CardGrid
|
||||
@onready var loading_label : Label = %LoadingLabel
|
||||
@onready var empty_label : Label = %EmptyLabel
|
||||
@onready var load_more_btn : Button = %LoadMoreBtn
|
||||
@onready var search_input : LineEdit = %SearchInput
|
||||
@onready var type_option : OptionButton = %TypeOption
|
||||
@onready var affinity_option : OptionButton = %AffinityOption
|
||||
@onready var card_grid : GridContainer = %CardGrid
|
||||
@onready var loading_label : Label = %LoadingLabel
|
||||
@onready var empty_label : Label = %EmptyLabel
|
||||
|
||||
# ── State ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
var _current_page : int = 1
|
||||
var _total_count : int = 0
|
||||
var _has_more : bool = false
|
||||
var _loading : bool = false
|
||||
var _search_timer : float = 0.0
|
||||
var _card_entries : Dictionary = {} ## definitionId(String) -> { count, label }
|
||||
const _SEARCH_DEBOUNCE := 0.4
|
||||
## Full owned map: { definitionId(String) → ownedCount(int) }
|
||||
var _owned : Dictionary = {}
|
||||
var _search_timer : float = 0.0
|
||||
const _SEARCH_DEBOUNCE := 0.15
|
||||
|
||||
# Emitted when the user taps a card — parent uses this to show the detail popup.
|
||||
signal card_selected(dto: Dictionary, def: Dictionary)
|
||||
@@ -42,11 +34,11 @@ func _ready() -> void:
|
||||
_populate_affinity_options()
|
||||
_update_columns()
|
||||
search_input.text_changed.connect(_on_search_changed)
|
||||
type_option.item_selected.connect(func(_i): _reload())
|
||||
affinity_option.item_selected.connect(func(_i): _reload())
|
||||
load_more_btn.pressed.connect(_on_load_more)
|
||||
type_option.item_selected.connect(func(_i): _rebuild_grid())
|
||||
affinity_option.item_selected.connect(func(_i): _rebuild_grid())
|
||||
%LoadMoreBtn.hide()
|
||||
get_viewport().size_changed.connect(_update_columns)
|
||||
_reload()
|
||||
_fetch_owned()
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
@@ -59,7 +51,7 @@ func _process(delta: float) -> void:
|
||||
_search_timer -= delta
|
||||
if _search_timer <= 0.0:
|
||||
_search_timer = 0.0
|
||||
_reload()
|
||||
_rebuild_grid()
|
||||
|
||||
# ── Option population ─────────────────────────────────────────────────────────
|
||||
|
||||
@@ -92,177 +84,119 @@ func _update_columns() -> void:
|
||||
available_width = get_viewport_rect().size.x - 16.0
|
||||
card_grid.columns = max(1, int(available_width / CARD_WIDTH_ESTIMATE))
|
||||
|
||||
# ── Data fetching ─────────────────────────────────────────────────────────────
|
||||
# ── Data fetching (one-time) ──────────────────────────────────────────────────
|
||||
|
||||
func _reload() -> void:
|
||||
_current_page = 1
|
||||
_total_count = 0
|
||||
_has_more = false
|
||||
_card_entries.clear()
|
||||
for child in card_grid.get_children():
|
||||
child.queue_free()
|
||||
var cached := CollectionCache.get_cards_response(_query_key_for_page(1))
|
||||
if not cached.is_empty():
|
||||
_render_cards_response(cached, 1)
|
||||
_fetch_page(1)
|
||||
|
||||
|
||||
func _fetch_page(page: int) -> void:
|
||||
if _loading:
|
||||
return
|
||||
_loading = true
|
||||
func _fetch_owned() -> void:
|
||||
_set_status("loading")
|
||||
|
||||
var payload := {
|
||||
"page": page,
|
||||
"pageSize": PAGE_SIZE,
|
||||
}
|
||||
var search := search_input.text.strip_edges()
|
||||
if not search.is_empty():
|
||||
payload["nameFilter"] = search
|
||||
|
||||
# Type filter — index 0 = "All Types" (skip)
|
||||
var type_idx := type_option.selected
|
||||
if type_idx > 0:
|
||||
payload["cardTypeFilter"] = type_option.get_item_text(type_idx)
|
||||
|
||||
# Affinity filter — index 0 = "All Affinities" (skip)
|
||||
var aff_idx := affinity_option.selected
|
||||
if aff_idx > 0:
|
||||
payload["affinityFilter"] = affinity_option.get_item_text(aff_idx)
|
||||
|
||||
var cached := CollectionCache.get_owned_map()
|
||||
if not cached.is_empty():
|
||||
_owned = cached
|
||||
_rebuild_grid()
|
||||
Network.request(
|
||||
"collection.get_cards",
|
||||
payload,
|
||||
func(_t: String, p: Variant): _on_cards_response(p, page),
|
||||
func(_code: String, msg: String): _on_error(msg)
|
||||
"collection.get_owned",
|
||||
{},
|
||||
func(_t: String, p: Variant): _on_owned_response(p),
|
||||
func(_code: String, msg: String): _on_owned_error(msg)
|
||||
)
|
||||
|
||||
|
||||
func _on_cards_response(payload: Variant, page: int) -> void:
|
||||
_loading = false
|
||||
var p := payload as Dictionary
|
||||
CollectionCache.store_cards_response(_query_key_for_page(page), p)
|
||||
_render_cards_response(p, page)
|
||||
func _on_owned_response(payload: Variant) -> void:
|
||||
var p := payload as Dictionary
|
||||
var raw : Variant = p.get("owned", {})
|
||||
_owned = raw if typeof(raw) == TYPE_DICTIONARY else {}
|
||||
CollectionCache.store_owned_map(_owned)
|
||||
_rebuild_grid()
|
||||
|
||||
|
||||
func _on_error(msg: String) -> void:
|
||||
_loading = false
|
||||
func _on_owned_error(msg: String) -> void:
|
||||
_set_status("empty")
|
||||
push_warning("CardsView: %s" % msg)
|
||||
|
||||
# ── Button handlers ───────────────────────────────────────────────────────────
|
||||
# ── Grid rendering (client-side filtered) ────────────────────────────────────
|
||||
|
||||
func _on_search_changed(_text: String) -> void:
|
||||
_search_timer = _SEARCH_DEBOUNCE
|
||||
func _rebuild_grid() -> void:
|
||||
for child in card_grid.get_children():
|
||||
child.queue_free()
|
||||
|
||||
|
||||
func _on_load_more() -> void:
|
||||
_fetch_page(_current_page + 1)
|
||||
|
||||
# ── Status helper ─────────────────────────────────────────────────────────────
|
||||
|
||||
func _set_status(state: String) -> void:
|
||||
loading_label.visible = (state == "loading")
|
||||
empty_label.visible = (state == "empty")
|
||||
if state != "loading":
|
||||
load_more_btn.visible = _has_more
|
||||
|
||||
|
||||
func _render_cards_response(payload: Dictionary, page: int) -> void:
|
||||
var cards : Array = payload.get("cards", [])
|
||||
_total_count = int(payload.get("totalCount", 0))
|
||||
var page_size : int = int(payload.get("pageSize", PAGE_SIZE))
|
||||
_current_page = page
|
||||
_has_more = (page * page_size) < _total_count
|
||||
|
||||
if page == 1:
|
||||
_card_entries.clear()
|
||||
for child in card_grid.get_children():
|
||||
child.queue_free()
|
||||
|
||||
for raw_dto in cards:
|
||||
var dto := raw_dto as Dictionary
|
||||
var def := ContentCache.get_definition(str(dto.get("cardDefinitionId", "")))
|
||||
var hydrated := _hydrate_card_dto(dto, def)
|
||||
_add_or_increment_card(hydrated, def)
|
||||
|
||||
if cards.is_empty() and page == 1:
|
||||
if _owned.is_empty():
|
||||
_set_status("empty")
|
||||
else:
|
||||
_set_status("done")
|
||||
|
||||
load_more_btn.visible = _has_more
|
||||
|
||||
|
||||
func _add_or_increment_card(dto: Dictionary, def: Dictionary) -> void:
|
||||
var def_id := str(dto.get("cardDefinitionId", ""))
|
||||
if def_id.is_empty():
|
||||
return
|
||||
|
||||
if _card_entries.has(def_id):
|
||||
var entry := _card_entries.get(def_id, {}) as Dictionary
|
||||
var next_count := int(entry.get("count", 1)) + 1
|
||||
entry["count"] = next_count
|
||||
var count_label := entry.get("label", null) as Label
|
||||
if count_label != null:
|
||||
count_label.text = "x%d" % next_count
|
||||
_card_entries[def_id] = entry
|
||||
var search := search_input.text.strip_edges().to_lower()
|
||||
var type_idx := type_option.selected
|
||||
var aff_idx := affinity_option.selected
|
||||
var type_filter := type_option.get_item_text(type_idx) if type_idx > 0 else ""
|
||||
var aff_filter := affinity_option.get_item_text(aff_idx) if aff_idx > 0 else ""
|
||||
|
||||
var entries : Array = []
|
||||
for def_id_var in _owned:
|
||||
var def_id := str(def_id_var)
|
||||
var count := int(_owned[def_id_var])
|
||||
var def := ContentCache.get_definition(def_id)
|
||||
if def.is_empty():
|
||||
continue
|
||||
var name := str(def.get("name", ""))
|
||||
var c_type := str(def.get("cardType", ""))
|
||||
var affinity := str(def.get("affinity", ""))
|
||||
if not search.is_empty() and not name.to_lower().contains(search):
|
||||
continue
|
||||
if not type_filter.is_empty() and c_type != type_filter:
|
||||
continue
|
||||
if not aff_filter.is_empty() and affinity != aff_filter:
|
||||
continue
|
||||
entries.append({
|
||||
"cardDefinitionId": def_id,
|
||||
"name": name,
|
||||
"cardType": c_type,
|
||||
"affinity": affinity,
|
||||
"rarity": str(def.get("rarity", "")),
|
||||
"tier": def.get("tier"),
|
||||
"copyCount": count,
|
||||
})
|
||||
|
||||
entries.sort_custom(func(a, b): return str(a["name"]) < str(b["name"]))
|
||||
|
||||
if entries.is_empty():
|
||||
_set_status("empty")
|
||||
return
|
||||
|
||||
for dto in entries:
|
||||
var def := ContentCache.get_definition(str(dto["cardDefinitionId"]))
|
||||
_add_card_to_grid(dto, def)
|
||||
|
||||
_set_status("done")
|
||||
|
||||
|
||||
func _add_card_to_grid(dto: Dictionary, def: Dictionary) -> void:
|
||||
var count := int(dto.get("copyCount", 1))
|
||||
|
||||
var wrapper := VBoxContainer.new()
|
||||
wrapper.add_theme_constant_override("separation", 4)
|
||||
wrapper.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
|
||||
|
||||
var widget := CARD_WIDGET.instantiate() as PanelContainer
|
||||
widget.card_pressed.connect(func(_pressed_id: String):
|
||||
var selected_dto := dto.duplicate(true)
|
||||
var entry := _card_entries.get(def_id, {}) as Dictionary
|
||||
selected_dto["copyCount"] = int(entry.get("count", 1))
|
||||
card_selected.emit(selected_dto, def))
|
||||
card_selected.emit(dto.duplicate(true), def))
|
||||
wrapper.add_child(widget)
|
||||
widget.setup(dto, def)
|
||||
|
||||
var count_label := Label.new()
|
||||
count_label.text = "x1"
|
||||
count_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
count_label.add_theme_font_size_override("font_size", 11)
|
||||
count_label.modulate = Color(0.72, 0.72, 0.80)
|
||||
wrapper.add_child(count_label)
|
||||
if count > 1:
|
||||
var count_label := Label.new()
|
||||
count_label.text = "x%d" % count
|
||||
count_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
count_label.add_theme_font_size_override("font_size", 11)
|
||||
count_label.modulate = Color(0.72, 0.72, 0.80)
|
||||
wrapper.add_child(count_label)
|
||||
|
||||
card_grid.add_child(wrapper)
|
||||
_card_entries[def_id] = {
|
||||
"count": 1,
|
||||
"label": count_label,
|
||||
}
|
||||
|
||||
# ── Event handlers ────────────────────────────────────────────────────────────
|
||||
|
||||
func _hydrate_card_dto(dto: Dictionary, def: Dictionary) -> Dictionary:
|
||||
var hydrated := dto.duplicate(true)
|
||||
if def.is_empty():
|
||||
return hydrated
|
||||
hydrated["name"] = str(def.get("name", hydrated.get("name", "")))
|
||||
hydrated["cardType"] = str(def.get("cardType", hydrated.get("cardType", "")))
|
||||
hydrated["affinity"] = str(def.get("affinity", hydrated.get("affinity", "")))
|
||||
hydrated["rarity"] = str(def.get("rarity", hydrated.get("rarity", "")))
|
||||
var tier_value: Variant = def.get("tier", hydrated.get("tier", null))
|
||||
hydrated["tier"] = tier_value if tier_value != null else null
|
||||
return hydrated
|
||||
func _on_search_changed(_text: String) -> void:
|
||||
_search_timer = _SEARCH_DEBOUNCE
|
||||
|
||||
# ── Status helper ─────────────────────────────────────────────────────────────
|
||||
|
||||
func _query_key_for_page(page: int) -> String:
|
||||
var search := search_input.text.strip_edges()
|
||||
var type_filter := ""
|
||||
var affinity_filter := ""
|
||||
var type_idx := type_option.selected
|
||||
if type_idx > 0:
|
||||
type_filter = type_option.get_item_text(type_idx)
|
||||
var aff_idx := affinity_option.selected
|
||||
if aff_idx > 0:
|
||||
affinity_filter = affinity_option.get_item_text(aff_idx)
|
||||
return CollectionCache.cards_query_key(
|
||||
page,
|
||||
PAGE_SIZE,
|
||||
search,
|
||||
type_filter,
|
||||
affinity_filter)
|
||||
func _set_status(state: String) -> void:
|
||||
loading_label.visible = (state == "loading")
|
||||
empty_label.visible = (state == "empty")
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
[gd_resource type="StyleBoxFlat" format=3 uid="uid://byrmjtubb13d"]
|
||||
|
||||
[resource]
|
||||
bg_color = Color(0.12085935, 0.5315289, 0.731907, 0.7411765)
|
||||
border_width_left = 2
|
||||
border_width_top = 2
|
||||
border_width_right = 2
|
||||
border_width_bottom = 2
|
||||
border_color = Color(0.49019608, 0.7529412, 0.70980394, 0.39607844)
|
||||
border_blend = true
|
||||
corner_radius_top_left = 2
|
||||
corner_radius_top_right = 7
|
||||
corner_radius_bottom_right = 2
|
||||
corner_radius_bottom_left = 7
|
||||
@@ -0,0 +1,14 @@
|
||||
[gd_resource type="StyleBoxFlat" format=3 uid="uid://cwmv43xafbylt"]
|
||||
|
||||
[resource]
|
||||
bg_color = Color(0.12156863, 0.53333336, 0.73333335, 0.4392157)
|
||||
border_width_left = 2
|
||||
border_width_top = 2
|
||||
border_width_right = 2
|
||||
border_width_bottom = 2
|
||||
border_color = Color(0.49019608, 0.7529412, 0.70980394, 0.9372549)
|
||||
border_blend = true
|
||||
corner_radius_top_left = 2
|
||||
corner_radius_top_right = 7
|
||||
corner_radius_bottom_right = 2
|
||||
corner_radius_bottom_left = 7
|
||||
@@ -200,6 +200,12 @@ modulate = Color(0.6, 0.6, 0.6, 1)
|
||||
layout_mode = 2
|
||||
text = "Not ready"
|
||||
|
||||
[node name="AddAiBtn" type="Button" parent="Layout/MainSplit/LeftPanel/LeftContent/LeftMargin/LeftInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Add AI Opponent"
|
||||
visible = false
|
||||
|
||||
[node name="AdditionalPlayersContainer" type="VBoxContainer" parent="Layout/MainSplit/LeftPanel/LeftContent/LeftMargin/LeftInner"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://wlmha2g85yl1"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/free_play/components/active_game_row.gd" id="1_agr"]
|
||||
[ext_resource type="Script" uid="uid://duvpyqc2piams" path="res://scenes/free_play/components/active_game_row.gd" id="1_agr"]
|
||||
|
||||
[node name="ActiveGameRow" type="VBoxContainer"]
|
||||
script = ExtResource("1_agr")
|
||||
|
||||
[node name="Row" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(0, 48)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="MatchupLabel" type="Label" parent="Row"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
clip_text = true
|
||||
vertical_alignment = 1
|
||||
clip_text = true
|
||||
|
||||
[node name="SpectateBtn" type="Button" parent="Row"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(80, 0)
|
||||
layout_mode = 2
|
||||
text = "Spectate"
|
||||
|
||||
[node name="Sep" type="HSeparator" parent="."]
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dxlpufl57hsb4"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/free_play/components/rules_editor_dialog.gd" id="1_red"]
|
||||
[ext_resource type="Script" uid="uid://dogruvcpjj2rt" path="res://scenes/free_play/components/rules_editor_dialog.gd" id="1_red"]
|
||||
|
||||
[node name="RulesEditorDialog" type="Window"]
|
||||
oversampling_override = 1.0
|
||||
title = "Rules Editor"
|
||||
initial_position = 1
|
||||
size = Vector2i(480, 600)
|
||||
@@ -10,7 +11,6 @@ exclusive = true
|
||||
script = ExtResource("1_red")
|
||||
|
||||
[node name="RootVBox" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
@@ -26,8 +26,8 @@ size_flags_vertical = 3
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_top = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_bottom = 12
|
||||
|
||||
[node name="FieldsBox" type="VBoxContainer" parent="RootVBox/Scroll/FieldsMargin"]
|
||||
@@ -42,8 +42,8 @@ layout_mode = 2
|
||||
[node name="FooterMargin" type="MarginContainer" parent="RootVBox"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="BtnRow" type="HBoxContainer" parent="RootVBox/FooterMargin"]
|
||||
|
||||
@@ -128,7 +128,7 @@ func _build_fields(r: Dictionary) -> void:
|
||||
var sq_shape_row := fields_box.get_child(fields_box.get_child_count() - 1)
|
||||
|
||||
# Hex-only rows
|
||||
add_int.call("Hex Sides", "hexSides", 3, 10, 5, "Hexagon only: tiles per side (3–10)")
|
||||
add_int.call("Hex Sides", "hexSides", 3, 10, 6, "Hexagon only: tiles per side (3–10)")
|
||||
var hex_sides_row := fields_box.get_child(fields_box.get_child_count() - 1)
|
||||
|
||||
# Board template picker — filtered by current grid type.
|
||||
|
||||
@@ -41,14 +41,14 @@ var _deck_btn_group : ButtonGroup = null
|
||||
|
||||
func _ready() -> void:
|
||||
ContentCache.apply_scene_background(self)
|
||||
Chat.set_bubble_visible(true)
|
||||
Chat.claim_bubble_visibility(self)
|
||||
_setup_ui()
|
||||
_load_decks() # load decks first; lobbies load after decks arrive
|
||||
_refresh_lobbies()
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
Chat.set_bubble_visible(false)
|
||||
Chat.release_bubble_visibility(self)
|
||||
|
||||
# ── UI setup ──────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ const RULES_DIALOG = preload("res://scenes/free_play/components/RulesEditorDialo
|
||||
@onready var suggestion_accept_btn : Button = %SuggestionAcceptBtn
|
||||
@onready var suggestion_reject_btn : Button = %SuggestionRejectBtn
|
||||
@onready var deck_picker_dialog : AcceptDialog = %DeckPickerDialog
|
||||
@onready var add_ai_btn : Button = %AddAiBtn
|
||||
@onready var deck_picker_container : VBoxContainer = %DeckPickerContainer
|
||||
@onready var preset_list_dialog : AcceptDialog = %PresetListDialog
|
||||
@onready var preset_list_container : VBoxContainer = %PresetListContainer
|
||||
@@ -50,17 +51,20 @@ const RULES_DIALOG = preload("res://scenes/free_play/components/RulesEditorDialo
|
||||
var _first_turn_pref : String = "random"
|
||||
var _current_rules : Dictionary = {}
|
||||
var _team_panel : VBoxContainer = null # dynamically added team-controls section
|
||||
var _ai_adding : bool = false # guard against concurrent add-AI requests
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
ContentCache.apply_scene_background(self)
|
||||
Chat.claim_bubble_visibility(self)
|
||||
_setup_ui()
|
||||
_connect_signals()
|
||||
_refresh_display()
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
Chat.release_bubble_visibility(self)
|
||||
CustomLobby.guest_joined.disconnect(_on_guest_joined)
|
||||
CustomLobby.ready_status_changed.disconnect(_on_ready_status_changed)
|
||||
CustomLobby.lobby_rules_updated.disconnect(_on_rules_updated)
|
||||
@@ -74,6 +78,7 @@ func _exit_tree() -> void:
|
||||
CustomLobby.rule_suggestion_rejected.disconnect(_on_rule_suggestion_rejected)
|
||||
CustomLobby.lobby_notice.disconnect(_on_lobby_notice)
|
||||
CustomLobby.team_assignment_changed.disconnect(_on_team_assignment_changed)
|
||||
CustomLobby.ai_slots_changed.disconnect(_on_ai_slots_changed)
|
||||
|
||||
# ── Setup ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -125,6 +130,10 @@ func _setup_ui() -> void:
|
||||
deck_picker_dialog.confirmed.connect(_on_deck_picker_confirmed)
|
||||
preset_list_dialog.confirmed.connect(_on_preset_confirmed)
|
||||
|
||||
# Add AI button (host-only, shown when guest slot is empty)
|
||||
add_ai_btn.visible = false
|
||||
add_ai_btn.pressed.connect(_on_add_ai_pressed)
|
||||
|
||||
|
||||
func _connect_signals() -> void:
|
||||
CustomLobby.guest_joined.connect(_on_guest_joined)
|
||||
@@ -140,6 +149,7 @@ func _connect_signals() -> void:
|
||||
CustomLobby.rule_suggestion_rejected.connect(_on_rule_suggestion_rejected)
|
||||
CustomLobby.lobby_notice.connect(_on_lobby_notice)
|
||||
CustomLobby.team_assignment_changed.connect(_on_team_assignment_changed)
|
||||
CustomLobby.ai_slots_changed.connect(_on_ai_slots_changed)
|
||||
|
||||
# ── Refresh ───────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -163,16 +173,29 @@ func _refresh_display() -> void:
|
||||
host_name_label.text = "Host: %s%s" % [str(lobby.get("hostDisplayName", Auth.display_name)), team_suffix_0]
|
||||
host_deck_label.text = "Deck: (selected)"
|
||||
|
||||
# Guest slot
|
||||
# Guest slot — may be a human, an AI (2-player only), or empty.
|
||||
# For 3+ player games the seat-1 AI is an additional player shown in the panel below.
|
||||
var team_suffix_1 : String = _team_label(game_mode, 1, team_count)
|
||||
var has_guest : bool = lobby.get("hasGuest", false) or lobby.get("guestAccountId", "") != ""
|
||||
if has_guest:
|
||||
var ai_in_guest_slot : Dictionary = _ai_slot_for_seat(1) if max_players == 2 else {}
|
||||
if not ai_in_guest_slot.is_empty():
|
||||
guest_name_label.text = "AI: %s%s" % [str(ai_in_guest_slot.get("displayName", "AI")), team_suffix_1]
|
||||
guest_deck_label.text = "Difficulty %d" % int(ai_in_guest_slot.get("difficulty", 1))
|
||||
guest_ready_indicator.text = "✓ READY"
|
||||
guest_ready_indicator.modulate = Color(0.2, 0.9, 0.3)
|
||||
elif has_guest:
|
||||
guest_name_label.text = "Guest: %s%s" % [str(lobby.get("guestDisplayName", "Guest")), team_suffix_1]
|
||||
guest_deck_label.text = "Deck: (selected)"
|
||||
else:
|
||||
guest_name_label.text = "Waiting for guest…"
|
||||
guest_deck_label.text = ""
|
||||
|
||||
# Show Add AI Opponent button only for 2-player lobbies (guest slot).
|
||||
# 3+ player lobbies use per-seat Add AI buttons in the additional players panel.
|
||||
var slot_open : bool = (not has_guest and ai_in_guest_slot.is_empty() and max_players == 2)
|
||||
add_ai_btn.visible = CustomLobby.is_host and slot_open and not CustomLobby.i_am_ready
|
||||
add_ai_btn.disabled = _ai_adding
|
||||
|
||||
# Additional players (3+) from lobby dict.
|
||||
_rebuild_additional_players_panel(lobby, max_players)
|
||||
|
||||
@@ -192,7 +215,9 @@ func _refresh_display() -> void:
|
||||
_update_rules_label()
|
||||
|
||||
|
||||
## Rebuild the additional players panel (seats 3+) from the lobby dict.
|
||||
## Rebuild the additional players panel (seats 2+) from the lobby dict.
|
||||
## For 3+ player lobbies this covers ALL non-host seats (seats 1–N when no guest is present,
|
||||
## seats 2–N when a human guest occupies seat 1).
|
||||
func _rebuild_additional_players_panel(lobby: Dictionary, max_players: int) -> void:
|
||||
for c in additional_players_container.get_children():
|
||||
c.queue_free()
|
||||
@@ -201,32 +226,40 @@ func _rebuild_additional_players_panel(lobby: Dictionary, max_players: int) -> v
|
||||
additional_players_container.visible = false
|
||||
return
|
||||
|
||||
var gm : String = str(lobby.get("gameMode", "FFA"))
|
||||
var tc : int = int(lobby.get("teamCount", 1))
|
||||
var gm : String = str(lobby.get("gameMode", "FFA"))
|
||||
var tc : int = int(lobby.get("teamCount", 1))
|
||||
|
||||
# The lobby dict may contain additionalPlayers array (from server push or join response).
|
||||
var addl : Array = lobby.get("additionalPlayers", []) as Array
|
||||
if addl.is_empty():
|
||||
# Show empty slots for players who haven't joined yet.
|
||||
# Host always occupies slot 1; guest slot 2 if guestAccountId is present.
|
||||
var has_host : bool = true # host is always present
|
||||
var has_guest : bool = lobby.get("hasGuest", false) or str(lobby.get("guestAccountId", "")) != ""
|
||||
var taken_slots : int = (1 if has_host else 0) + (1 if has_guest else 0)
|
||||
for i in range(max_players - taken_slots):
|
||||
var seat_n : int = taken_slots + i
|
||||
var tsuf : String = _team_label(gm, seat_n, tc)
|
||||
var row := _make_player_slot_row("Seat %d: Waiting…%s" % [seat_n + 1, tsuf], false)
|
||||
# Build a seat-index → addl-player dict for O(1) lookup.
|
||||
var addl_by_seat : Dictionary = {}
|
||||
for ap: Dictionary in (lobby.get("additionalPlayers", []) as Array):
|
||||
var si : int = int(ap.get("seatIndex", -1))
|
||||
if si >= 0:
|
||||
addl_by_seat[si] = ap
|
||||
|
||||
# First additional seat depends on whether a human occupies the guest slot (seat 1).
|
||||
var has_guest2 : bool = lobby.get("hasGuest", false) or str(lobby.get("guestAccountId", "")) != ""
|
||||
var first_addl : int = 2 if has_guest2 else 1
|
||||
|
||||
for seat_n in range(first_addl, max_players):
|
||||
var tsuf : String = _team_label(gm, seat_n, tc)
|
||||
var ai_slot : Dictionary = _ai_slot_for_seat(seat_n)
|
||||
if not ai_slot.is_empty():
|
||||
# AI occupies this seat.
|
||||
var row := _make_player_slot_row(
|
||||
"AI: %s%s" % [str(ai_slot.get("displayName", "AI")), tsuf], true)
|
||||
additional_players_container.add_child(row)
|
||||
else:
|
||||
for i2: int in addl.size():
|
||||
var entry : Dictionary = addl[i2] as Dictionary
|
||||
elif addl_by_seat.has(seat_n):
|
||||
# Human player occupies this seat.
|
||||
var entry : Dictionary = addl_by_seat[seat_n] as Dictionary
|
||||
var aid : String = str(entry.get("accountId", ""))
|
||||
var aname : String = str(entry.get("displayName", str(entry.get("accountId", "Player")).substr(0, 8)))
|
||||
var ready : bool = bool(entry.get("isReady", false))
|
||||
var seat_n2 : int = i2 + 2
|
||||
var tsuf2 : String = _team_label(gm, seat_n2, tc)
|
||||
var who := "You" if aid == Auth.user_id else aname
|
||||
var row := _make_player_slot_row("Player: %s%s" % [who, tsuf2], ready)
|
||||
var who : String = "You" if aid == Auth.user_id else aname
|
||||
var row := _make_player_slot_row("Player: %s%s" % [who, tsuf], ready)
|
||||
additional_players_container.add_child(row)
|
||||
else:
|
||||
# Seat is empty — show waiting row with Add AI button for the host.
|
||||
var row := _make_additional_seat_row("Seat %d: Waiting…%s" % [seat_n + 1, tsuf])
|
||||
additional_players_container.add_child(row)
|
||||
|
||||
additional_players_container.visible = true
|
||||
@@ -259,6 +292,24 @@ func _make_player_slot_row(label_text: String, is_ready: bool) -> HBoxContainer:
|
||||
return hbox
|
||||
|
||||
|
||||
func _make_additional_seat_row(label_text: String) -> HBoxContainer:
|
||||
var hbox := HBoxContainer.new()
|
||||
hbox.add_theme_constant_override("separation", 8)
|
||||
var name_lbl := Label.new()
|
||||
name_lbl.text = label_text
|
||||
name_lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
name_lbl.add_theme_font_size_override("font_size", 13)
|
||||
hbox.add_child(name_lbl)
|
||||
if CustomLobby.is_host and not CustomLobby.i_am_ready:
|
||||
var ai_btn := Button.new()
|
||||
ai_btn.text = "Add AI"
|
||||
ai_btn.custom_minimum_size = Vector2(70, 0)
|
||||
ai_btn.disabled = _ai_adding
|
||||
ai_btn.pressed.connect(_on_add_ai_pressed)
|
||||
hbox.add_child(ai_btn)
|
||||
return hbox
|
||||
|
||||
|
||||
## Rebuild the host-only team assignment panel (shown only in team game modes).
|
||||
## Each row: "[Seat N: <name>] [<] T0 [>]"
|
||||
func _rebuild_team_controls(lobby: Dictionary, max_players: int,
|
||||
@@ -511,6 +562,73 @@ func _format_rules_summary(rules: Dictionary) -> String:
|
||||
return "\n".join(lines) if not lines.is_empty() else "(no changes)"
|
||||
|
||||
|
||||
func _ai_slot_for_seat(seat: int) -> Dictionary:
|
||||
for slot: Dictionary in CustomLobby.ai_slots:
|
||||
if int(slot.get("seatIndex", -1)) == seat:
|
||||
return slot
|
||||
return {}
|
||||
|
||||
|
||||
func _on_ai_slots_changed(_slots: Array) -> void:
|
||||
_refresh_display()
|
||||
|
||||
|
||||
func _on_add_ai_pressed() -> void:
|
||||
if _ai_adding:
|
||||
return
|
||||
var dlg := AcceptDialog.new()
|
||||
dlg.title = "Add AI Opponent"
|
||||
dlg.ok_button_text = "Add"
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.add_theme_constant_override("separation", 8)
|
||||
|
||||
# Difficulty picker
|
||||
var diff_label := Label.new()
|
||||
diff_label.text = "Difficulty"
|
||||
diff_label.add_theme_font_size_override("font_size", 12)
|
||||
var diff_opts := OptionButton.new()
|
||||
var diff_names := ["D1 – Novice", "D2 – Apprentice", "D3 – Journeyman",
|
||||
"D4 – Adept", "D5 – Expert", "D6 – Master",
|
||||
"D7 – Grandmaster", "D8 – Champion", "D9 – Legend", "D10 – Mythic"]
|
||||
for dn: String in diff_names:
|
||||
diff_opts.add_item(dn)
|
||||
diff_opts.selected = 0 # default D1
|
||||
|
||||
# Strategy picker
|
||||
var strat_label := Label.new()
|
||||
strat_label.text = "Strategy"
|
||||
strat_label.add_theme_font_size_override("font_size", 12)
|
||||
var strat_opts := OptionButton.new()
|
||||
var strategies := ["Balanced", "Aggressive", "Control", "Ramp", "Swarm"]
|
||||
for s: String in strategies:
|
||||
strat_opts.add_item(s)
|
||||
strat_opts.selected = 0 # default Balanced
|
||||
|
||||
vbox.add_child(diff_label)
|
||||
vbox.add_child(diff_opts)
|
||||
vbox.add_child(strat_label)
|
||||
vbox.add_child(strat_opts)
|
||||
dlg.add_child(vbox)
|
||||
add_child(dlg)
|
||||
|
||||
dlg.confirmed.connect(func():
|
||||
var difficulty := diff_opts.selected + 1 # 1-indexed
|
||||
var strategy : Variant = strategies[strat_opts.selected]
|
||||
_ai_adding = true
|
||||
_refresh_display()
|
||||
CustomLobby.add_ai(difficulty, strategy,
|
||||
func(_d: Dictionary) -> void:
|
||||
_ai_adding = false
|
||||
_refresh_display(),
|
||||
func(_code: String, _msg: String) -> void:
|
||||
_ai_adding = false
|
||||
_refresh_display()
|
||||
_show_toast("Failed to add AI: " + _msg))
|
||||
dlg.queue_free())
|
||||
dlg.canceled.connect(func(): dlg.queue_free())
|
||||
dlg.popup_centered(Vector2(260, 160))
|
||||
|
||||
|
||||
func _on_lobby_left() -> void:
|
||||
get_tree().change_scene_to_file("res://scenes/free_play/FreePlayScreen.tscn")
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://b17evi1hw4dqu"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b8x84lb58h6gx" path="res://scenes/game/game_screen.gd" id="1_gscr"]
|
||||
[ext_resource type="Texture2D" uid="uid://dvmripj4jux0b" path="res://icons/SP-Symbol-White.png" id="2_056su"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/game/InGameSettings.tscn" id="2_igs"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_wukpb"]
|
||||
|
||||
[sub_resource type="Theme" id="Theme_056su"]
|
||||
[ext_resource type="PackedScene" uid="uid://doy6e5sb5bk48" path="res://scenes/game/components/hud/hud_controller.tscn" id="3_hudctrl"]
|
||||
[ext_resource type="PackedScene" uid="uid://cowqg2xdx0x7g" path="res://scenes/game/components/hud/hand_manager.tscn" id="4_handmgr"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/game/components/overlays/game_over_overlay.tscn" id="5_goo"]
|
||||
|
||||
[node name="GameScreen" type="Node3D"]
|
||||
script = ExtResource("1_gscr")
|
||||
@@ -34,124 +32,14 @@ transform = Transform3D(1, 0, 0, 0, 0.766044, 0.642788, 0, -0.642788, 0.766044,
|
||||
[node name="HUD" type="CanvasLayer" parent="."]
|
||||
layer = 10
|
||||
|
||||
[node name="TopBar" type="HBoxContainer" parent="HUD"]
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_bottom = 48.0
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="PhaseLabel" type="Label" parent="HUD/TopBar"]
|
||||
[node name="HudController" parent="HUD" instance=ExtResource("3_hudctrl")]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(140, 48)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Phase: —"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="TurnLabel" type="Label" parent="HUD/TopBar"]
|
||||
[node name="HandManager" parent="HUD" instance=ExtResource("4_handmgr")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Turn 1 — Your turn"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="TurnOrderStrip" type="HBoxContainer" parent="HUD/TopBar"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="OpponentPanel" type="HBoxContainer" parent="HUD/TopBar"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(240, 48)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="OppNameLabel" type="Label" parent="HUD/TopBar/OpponentPanel"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(1, 0.5, 0.5, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Opponent"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="OppHandLabel" type="Label" parent="HUD/TopBar/OpponentPanel"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Hand: 0"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="OppDeckLabel" type="Label" parent="HUD/TopBar/OpponentPanel"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Deck: 0"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="OppDiscardBtn" type="Button" parent="HUD/TopBar/OpponentPanel"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "Discard"
|
||||
|
||||
[node name="SP-ST Panel Container" type="PanelContainer" parent="HUD"]
|
||||
offset_left = 12.0
|
||||
offset_top = 374.0
|
||||
offset_right = 88.0
|
||||
offset_bottom = 508.0
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_wukpb")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="HUD/SP-ST Panel Container"]
|
||||
layout_mode = 2
|
||||
alignment = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="HUD/SP-ST Panel Container/VBoxContainer"]
|
||||
self_modulate = Color(0, 0.8117647, 0.77254903, 0.38039216)
|
||||
texture_filter = 5
|
||||
custom_minimum_size = Vector2(1.78, 76)
|
||||
layout_mode = 2
|
||||
theme = SubResource("Theme_056su")
|
||||
texture = ExtResource("2_056su")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="SpLabel" type="Label" parent="HUD/SP-ST Panel Container/VBoxContainer/TextureRect"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_left = 15.0
|
||||
offset_top = 5.0
|
||||
offset_right = 62.0
|
||||
offset_bottom = 51.0
|
||||
theme_override_colors/font_color = Color(0.012617188, 0.012617188, 0.012617188, 1)
|
||||
theme_override_font_sizes/font_size = 33
|
||||
text = "88"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="HandArea" type="PanelContainer" parent="HUD"]
|
||||
anchors_preset = -1
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.75
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -250.0
|
||||
|
||||
[node name="HandScroll" type="ScrollContainer" parent="HUD/HandArea"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
vertical_scroll_mode = 0
|
||||
|
||||
[node name="HandCards" type="HBoxContainer" parent="HUD/HandArea/HandScroll"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
theme_override_constants/separation = 6
|
||||
|
||||
[node name="RightPanel" type="PanelContainer" parent="HUD"]
|
||||
visible = false
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.75
|
||||
anchor_top = 1.0
|
||||
@@ -163,54 +51,20 @@ offset_right = -1.0
|
||||
offset_bottom = 9.0
|
||||
scale = Vector2(1, 0.96000004)
|
||||
|
||||
[node name="RightMargin" type="MarginContainer" parent="HUD/RightPanel"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="RightVBox" type="VBoxContainer" parent="HUD/RightPanel/RightMargin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 6
|
||||
|
||||
[node name="StLabel" type="Label" parent="HUD/RightPanel/RightMargin/RightVBox"]
|
||||
[node name="TileDrawerToggleBtn" type="Button" parent="HUD"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "ST: 0"
|
||||
|
||||
[node name="DeckLabel" type="Label" parent="HUD/RightPanel/RightMargin/RightVBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(36, 48)
|
||||
anchors_preset = 6
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -48.0
|
||||
offset_top = -24.0
|
||||
offset_right = -12.0
|
||||
offset_bottom = 24.0
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Deck: 0"
|
||||
|
||||
[node name="DiscardBtn" type="Button" parent="HUD/RightPanel/RightMargin/RightVBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "View Discard"
|
||||
|
||||
[node name="DrawBtn" type="Button" parent="HUD/RightPanel/RightMargin/RightVBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Draw Card"
|
||||
|
||||
[node name="EndTurnBtn" type="Button" parent="HUD/RightPanel/RightMargin/RightVBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "End Turn"
|
||||
|
||||
[node name="SettingsBtn" type="Button" parent="HUD/RightPanel/RightMargin/RightVBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Settings"
|
||||
text = "<"
|
||||
|
||||
[node name="ContextPopup" type="PanelContainer" parent="HUD"]
|
||||
unique_name_in_owner = true
|
||||
@@ -261,126 +115,50 @@ layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Close"
|
||||
|
||||
[node name="DiscardViewer" type="PanelContainer" parent="HUD"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.1
|
||||
anchor_top = 0.05
|
||||
anchor_right = 0.9
|
||||
anchor_bottom = 0.95
|
||||
|
||||
[node name="DVMargin" type="MarginContainer" parent="HUD/DiscardViewer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 16
|
||||
theme_override_constants/margin_top = 12
|
||||
theme_override_constants/margin_right = 16
|
||||
theme_override_constants/margin_bottom = 12
|
||||
|
||||
[node name="DVVBox" type="VBoxContainer" parent="HUD/DiscardViewer/DVMargin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="DVTitle" type="Label" parent="HUD/DiscardViewer/DVMargin/DVVBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 16
|
||||
text = "Discard Pile"
|
||||
|
||||
[node name="DVScroll" type="ScrollContainer" parent="HUD/DiscardViewer/DVMargin/DVVBox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="DVList" type="VBoxContainer" parent="HUD/DiscardViewer/DVMargin/DVVBox/DVScroll"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="DVCloseBtn" type="Button" parent="HUD/DiscardViewer/DVMargin/DVVBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Close"
|
||||
|
||||
[node name="GameOverOverlay" type="PanelContainer" parent="HUD"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.25
|
||||
anchor_top = 0.25
|
||||
anchor_right = 0.75
|
||||
anchor_bottom = 0.75
|
||||
|
||||
[node name="GOMargin" type="MarginContainer" parent="HUD/GameOverOverlay"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 24
|
||||
theme_override_constants/margin_top = 24
|
||||
theme_override_constants/margin_right = 24
|
||||
theme_override_constants/margin_bottom = 24
|
||||
|
||||
[node name="GOVBox" type="VBoxContainer" parent="HUD/GameOverOverlay/GOMargin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 16
|
||||
|
||||
[node name="GOResultLabel" type="Label" parent="HUD/GameOverOverlay/GOMargin/GOVBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 28
|
||||
text = "Game Over"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="GORankLabel" type="Label" parent="HUD/GameOverOverlay/GOMargin/GOVBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 15
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="GOMainMenuBtn" type="Button" parent="HUD/GameOverOverlay/GOMargin/GOVBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 44)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 15
|
||||
text = "Return to Main Menu"
|
||||
|
||||
[node name="InGameSettings" parent="HUD" instance=ExtResource("2_igs")]
|
||||
[node name="GameOverOverlay" parent="HUD" instance=ExtResource("5_goo")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="CamCtrlPanel" type="PanelContainer" parent="HUD"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
offset_left = 8.0
|
||||
offset_top = 56.0
|
||||
offset_right = 104.0
|
||||
offset_bottom = 200.0
|
||||
offset_left = 127.0
|
||||
offset_top = 1.0
|
||||
offset_right = 377.0
|
||||
offset_bottom = 47.0
|
||||
|
||||
[node name="CamCtrlVBox" type="VBoxContainer" parent="HUD/CamCtrlPanel"]
|
||||
[node name="CamCtrlVBox" type="HBoxContainer" parent="HUD/CamCtrlPanel"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 4
|
||||
theme_override_constants/separation = 6
|
||||
|
||||
[node name="CamOrbitBtn" type="Button" parent="HUD/CamCtrlPanel/CamCtrlVBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 44)
|
||||
custom_minimum_size = Vector2(76, 34)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Orbit camera"
|
||||
toggle_mode = true
|
||||
text = "Orbit"
|
||||
|
||||
[node name="CamPanBtn" type="Button" parent="HUD/CamCtrlPanel/CamCtrlVBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 44)
|
||||
custom_minimum_size = Vector2(76, 34)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Pan camera"
|
||||
toggle_mode = true
|
||||
text = "Pan"
|
||||
|
||||
[node name="CamZoomBtn" type="Button" parent="HUD/CamCtrlPanel/CamCtrlVBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 44)
|
||||
custom_minimum_size = Vector2(76, 34)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Zoom camera"
|
||||
toggle_mode = true
|
||||
text = "Zoom"
|
||||
|
||||
[node name="SettingsLayer" type="CanvasLayer" parent="."]
|
||||
layer = 15
|
||||
|
||||
[node name="InGameSettings" parent="SettingsLayer" instance=ExtResource("2_igs")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="HoldTimer" type="Timer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
wait_time = 0.5
|
||||
|
||||
@@ -113,6 +113,11 @@ unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Focus camera when clicking a tile"
|
||||
|
||||
[node name="DrawCardPopup" type="CheckButton" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Show drawn card popup"
|
||||
|
||||
[node name="HSeparatorCam" type="HSeparator" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
|
||||
@@ -0,0 +1,685 @@
|
||||
class_name BoardController
|
||||
extends Node
|
||||
|
||||
var tile_bodies: Dictionary = {}
|
||||
var tile_heights: Dictionary = {}
|
||||
var tile_y_bases: Dictionary = {}
|
||||
var tile_visual_tops: Dictionary = {}
|
||||
|
||||
# Set by parent
|
||||
var tiles_root: Node3D = null
|
||||
var units_root: Node3D = null
|
||||
var hi_root: Node3D = null
|
||||
var pathfinder: Pathfinder = null
|
||||
var cursor_highlight_ref: MeshInstance3D = null
|
||||
var hover_team_overlay_ref: MeshInstance3D = null
|
||||
var affinity_transition_shader: Shader = null
|
||||
var tile_materialize_shader: Shader = null
|
||||
|
||||
|
||||
func build_board(board: Dictionary) -> void:
|
||||
pathfinder.grid_type = board.get("gridType", "Square")
|
||||
pathfinder.hex_sides = int(board.get("hexSides", 0))
|
||||
for c in tiles_root.get_children(): c.queue_free()
|
||||
for c in units_root.get_children(): c.queue_free()
|
||||
for c: Node in hi_root.get_children():
|
||||
if c != cursor_highlight_ref and c != hover_team_overlay_ref:
|
||||
c.queue_free()
|
||||
tile_bodies.clear()
|
||||
tile_heights.clear()
|
||||
tile_y_bases.clear()
|
||||
tile_visual_tops.clear()
|
||||
for tile: Dictionary in board.get("tiles", []):
|
||||
var coord: Dictionary = tile.get("coord", {})
|
||||
add_tile(coord.get("x", 0), coord.get("y", 0),
|
||||
tile.get("resolvedAffinity", "Void"))
|
||||
|
||||
|
||||
func add_tile(x: int, y: int, affinity: String) -> void:
|
||||
var wp: Vector3 = pathfinder.coord_to_world(x, y)
|
||||
|
||||
# Every tile gets a seeded RNG for deterministic variety.
|
||||
# First roll: height (0.8-1.0 for model tiles, fixed 0.5 for placeholders).
|
||||
# Second roll: vertical stagger (±0.15) so the board isn't completely flat.
|
||||
var shape_key_chk: String = "Hex" if pathfinder.grid_type == "Hexagon" else "Square"
|
||||
var has_model: bool = not ContentCache.get_tile_model_url(affinity, shape_key_chk).is_empty()
|
||||
var rng: RandomNumberGenerator = RandomNumberGenerator.new()
|
||||
rng.seed = hash("%d_%d" % [x, y])
|
||||
var h: float = rng.randf_range(0.8, 1.0) if has_model else 0.5
|
||||
var y_base: float = rng.randf_range(-0.15, 0.15)
|
||||
tile_heights["%d,%d" % [x, y]] = h
|
||||
tile_y_bases["%d,%d" % [x, y]] = y_base
|
||||
tile_visual_tops["%d,%d" % [x, y]] = y_base + h # default = collision-box top; updated after 3D model loads
|
||||
|
||||
var body: StaticBody3D = StaticBody3D.new()
|
||||
body.position = wp + Vector3(0, y_base + h * 0.5, 0)
|
||||
body.set_meta("tile_coord", Vector2i(x, y))
|
||||
body.set_meta("tile_height", h) # used by bottom-model loader
|
||||
body.set_meta("affinity", affinity)
|
||||
|
||||
var shape: CollisionShape3D = CollisionShape3D.new()
|
||||
var mi: MeshInstance3D = MeshInstance3D.new()
|
||||
if pathfinder.grid_type == "Hexagon":
|
||||
var cyl: CylinderMesh = CylinderMesh.new()
|
||||
cyl.radial_segments = 6
|
||||
cyl.top_radius = GameConstants.HEX_TILE_RADIUS * GameConstants.HEX_TILE_SPACING
|
||||
cyl.bottom_radius = GameConstants.HEX_TILE_RADIUS * GameConstants.HEX_TILE_SPACING
|
||||
cyl.height = h
|
||||
mi.mesh = cyl
|
||||
var cshape: CylinderShape3D = CylinderShape3D.new()
|
||||
cshape.radius = GameConstants.HEX_TILE_RADIUS * GameConstants.HEX_TILE_SPACING
|
||||
cshape.height = h
|
||||
shape.shape = cshape
|
||||
else:
|
||||
var box: BoxShape3D = BoxShape3D.new()
|
||||
box.size = Vector3(0.98, h, 0.98)
|
||||
shape.shape = box
|
||||
var bm: BoxMesh = BoxMesh.new()
|
||||
bm.size = Vector3(0.98, h, 0.98)
|
||||
mi.mesh = bm
|
||||
body.add_child(shape)
|
||||
|
||||
# Placeholder: affinity-coloured mesh, swapped out if a 3D model loads.
|
||||
var mat: StandardMaterial3D = StandardMaterial3D.new()
|
||||
mat.albedo_color = GameConstants.AFFINITY_COLORS.get(affinity, Color(0.2, 0.2, 0.2))
|
||||
mat.roughness = 0.85
|
||||
mi.material_override = mat
|
||||
body.add_child(mi)
|
||||
|
||||
tiles_root.add_child(body)
|
||||
tile_bodies["%d,%d" % [x, y]] = body
|
||||
|
||||
# ── Try to load a 3D tile model for this affinity ──────────────────────
|
||||
try_load_tile_model(body, affinity)
|
||||
|
||||
|
||||
## Load (or replace) the 3D model on a tile body for the given affinity.
|
||||
## Also attaches a random stalagmite bottom model below the tile when available.
|
||||
## Safe to call any time affinity changes — replaces existing mesh if present.
|
||||
## PureVoid tiles never receive a stalagmite bottom model.
|
||||
func try_load_tile_model(body: StaticBody3D, affinity: String) -> void:
|
||||
var want_bottom: bool = affinity != "PureVoid"
|
||||
var shape_key: String = "Hex" if pathfinder.grid_type == "Hexagon" else "Square"
|
||||
var model_url: String = ContentCache.get_tile_model_url(affinity, shape_key)
|
||||
if model_url.is_empty():
|
||||
if pathfinder.grid_type == "Hexagon":
|
||||
# No hex model — keep the affinity-coloured cylinder placeholder.
|
||||
# Still attach a hex stalagmite below if one is available.
|
||||
if want_bottom:
|
||||
var bottom_url: String = ContentCache.get_random_tile_bottom_url("Hex")
|
||||
if not bottom_url.is_empty():
|
||||
try_load_tile_bottom(weakref(body), bottom_url)
|
||||
return
|
||||
# Square: apply a 2D texture and attach a stalagmite bottom.
|
||||
var tex_url: String = ContentCache.get_tile_texture_url(affinity, "Square")
|
||||
if not tex_url.is_empty():
|
||||
apply_tile_texture(body, tex_url)
|
||||
if want_bottom:
|
||||
var bottom_url: String = ContentCache.get_random_tile_bottom_url("Square")
|
||||
if not bottom_url.is_empty():
|
||||
try_load_tile_bottom(weakref(body), bottom_url)
|
||||
return
|
||||
|
||||
var body_ref: Variant = weakref(body)
|
||||
ModelCache.load_model(model_url, func(model_node: Node3D) -> void:
|
||||
var b: StaticBody3D = body_ref.get_ref() as StaticBody3D
|
||||
if not is_instance_valid(b):
|
||||
if model_node != null:
|
||||
model_node.queue_free()
|
||||
return
|
||||
if model_node == null:
|
||||
return
|
||||
|
||||
# Remove any existing mesh (placeholder or previously loaded model),
|
||||
# but leave the CollisionShape3D so click detection still works.
|
||||
for child in b.get_children():
|
||||
if not (child is CollisionShape3D) and not bool(child.get_meta("tile_fx", false)):
|
||||
child.queue_free()
|
||||
|
||||
b.add_child(model_node)
|
||||
# Scale so the XZ footprint fits the 0.98-unit tile square.
|
||||
fit_model_to_tile(model_node, 0.98)
|
||||
if str(b.get_meta("affinity_transition_affinity", "")) == affinity:
|
||||
var transition_color: Color = GameConstants.AFFINITY_COLORS.get(affinity, Color(0.8, 0.8, 0.9))
|
||||
_play_tile_materialize_shader(model_node, transition_color, 1.25)
|
||||
b.set_meta("affinity_transition_model_materialized", affinity)
|
||||
# Update the visual-top cache so highlights land just above the model surface,
|
||||
# not the collision box top (the two can differ when model height ≠ box height).
|
||||
var tc: Vector2i = b.get_meta("tile_coord", Vector2i(-1, -1))
|
||||
if tc.x >= 0:
|
||||
var ma: AABB = model_local_aabb(model_node)
|
||||
if ma.size != Vector3.ZERO:
|
||||
tile_visual_tops["%d,%d" % [tc.x, tc.y]] = \
|
||||
b.position.y + ma.size.y * model_node.scale.y
|
||||
|
||||
# Attach a random stalagmite bottom model below the tile (if any are configured).
|
||||
# PureVoid tiles are skipped — they float in empty space with no decoration below.
|
||||
if want_bottom:
|
||||
var bottom_url: String = ContentCache.get_random_tile_bottom_url(shape_key)
|
||||
if not bottom_url.is_empty():
|
||||
try_load_tile_bottom(body_ref, bottom_url)
|
||||
)
|
||||
|
||||
|
||||
## Loads a stalagmite bottom model and attaches it below the tile body.
|
||||
func try_load_tile_bottom(body_ref: Variant, url: String) -> void:
|
||||
ModelCache.load_model(url, func(bottom_node: Node3D) -> void:
|
||||
var b: StaticBody3D = body_ref.get_ref() as StaticBody3D
|
||||
if not is_instance_valid(b):
|
||||
if bottom_node != null:
|
||||
bottom_node.queue_free()
|
||||
return
|
||||
if bottom_node == null:
|
||||
return
|
||||
# IMPORTANT: add_child BEFORE fit_model_to_tile / model_local_aabb.
|
||||
# MeshInstance3D.get_aabb() returns a zero AABB until the node is in the
|
||||
# scene tree, so both functions must run after the node is parented.
|
||||
var tile_h: float = float(b.get_meta("tile_height", 1.0))
|
||||
b.add_child(bottom_node)
|
||||
|
||||
# Scale to fit the tile footprint. Now that the node is in the tree,
|
||||
# the internal model_local_aabb call returns a valid AABB.
|
||||
fit_model_to_tile(bottom_node, 0.75)
|
||||
|
||||
# After fit_model_to_tile: the model's AABB bottom (spike tip) is at
|
||||
# body-local Y=0 and the AABB top (wide base) is at body-local Y = scaled_h.
|
||||
# The affinity model's visual base sits at body-local Y=0 (tile centre,
|
||||
# world Y = tile_h/2), so we want the stalagmite base there too.
|
||||
# Shift down by exactly scaled_h to bring the AABB top to body-local Y=0.
|
||||
var btm_aabb: AABB = model_local_aabb(bottom_node)
|
||||
if btm_aabb.size != Vector3.ZERO:
|
||||
var scaled_h: float = bottom_node.scale.y * btm_aabb.size.y
|
||||
bottom_node.position.y -= scaled_h
|
||||
)
|
||||
|
||||
|
||||
## Downloads a CDN image and applies it as the albedo texture on the
|
||||
## placeholder BoxMesh of a tile body (used when no 3D model is assigned).
|
||||
func apply_tile_texture(body: StaticBody3D, tex_url: String) -> void:
|
||||
var mi: MeshInstance3D = null
|
||||
for child in body.get_children():
|
||||
if child is MeshInstance3D and not bool(child.get_meta("tile_fx", false)):
|
||||
mi = child as MeshInstance3D
|
||||
break
|
||||
if mi == null or tex_url.is_empty():
|
||||
return
|
||||
var requester: HTTPRequest = HTTPRequest.new()
|
||||
add_child(requester)
|
||||
requester.request_completed.connect(
|
||||
func(_result: int, code: int, _headers: PackedStringArray, data: PackedByteArray) -> void:
|
||||
requester.queue_free()
|
||||
if code < 200 or code >= 300 or not is_instance_valid(mi):
|
||||
return
|
||||
var img: Image = Image.new()
|
||||
var ext: String = tex_url.get_extension().to_lower()
|
||||
var err: int
|
||||
if ext in ["jpg", "jpeg"]:
|
||||
err = img.load_jpg_from_buffer(data)
|
||||
elif ext == "webp":
|
||||
err = img.load_webp_from_buffer(data)
|
||||
else:
|
||||
err = img.load_png_from_buffer(data)
|
||||
if err != OK:
|
||||
return
|
||||
var tex: ImageTexture = ImageTexture.create_from_image(img)
|
||||
var mat: StandardMaterial3D = mi.material_override as StandardMaterial3D
|
||||
if mat == null:
|
||||
mat = StandardMaterial3D.new()
|
||||
mat.roughness = 0.85
|
||||
mi.material_override = mat
|
||||
mat.albedo_texture = tex
|
||||
)
|
||||
requester.request(tex_url)
|
||||
|
||||
|
||||
## Scales model so its largest XZ dimension equals `tile_size`, then centres
|
||||
## it on XZ and seats the bottom at y = 0 in the parent body's local space.
|
||||
func fit_model_to_tile(model: Node3D, tile_size: float) -> void:
|
||||
var aabb: AABB = model_local_aabb(model)
|
||||
if aabb.size == Vector3.ZERO:
|
||||
return
|
||||
var footprint: float = max(aabb.size.x, aabb.size.z)
|
||||
if footprint <= 0.0:
|
||||
return
|
||||
var s: float = tile_size / footprint
|
||||
model.scale = Vector3.ONE * s
|
||||
var c: Vector3 = aabb.get_center()
|
||||
model.position = Vector3(-c.x * s, -aabb.position.y * s, -c.z * s)
|
||||
|
||||
|
||||
## Returns the combined AABB of all VisualInstance3D descendants expressed
|
||||
## in the root node's own local coordinate space (before root.scale/position).
|
||||
func model_local_aabb(root: Node3D) -> AABB:
|
||||
var result: AABB = AABB()
|
||||
var first: bool = true
|
||||
# Each entry: { n: Node3D, x: Transform3D } where x transforms from
|
||||
# that node's local space to root's local space.
|
||||
var stack: Array = [{ "n": root, "x": Transform3D.IDENTITY }]
|
||||
while not stack.is_empty():
|
||||
var e: Dictionary = stack.pop_back()
|
||||
var node: Node3D = e["n"]
|
||||
var xform: Transform3D = e["x"]
|
||||
if node is VisualInstance3D:
|
||||
var local_aabb: AABB = xform * (node as VisualInstance3D).get_aabb()
|
||||
result = local_aabb if first else result.merge(local_aabb)
|
||||
first = false
|
||||
for child in node.get_children():
|
||||
if child is Node3D:
|
||||
stack.push_back({ "n": child, "x": xform * (child as Node3D).transform })
|
||||
return result
|
||||
|
||||
|
||||
func update_tile_affinity(x: int, y: int, affinity: String) -> void:
|
||||
var body: StaticBody3D = tile_bodies.get("%d,%d" % [x, y]) as StaticBody3D
|
||||
if body == null: return
|
||||
var prev_affinity: String = str(body.get_meta("affinity", ""))
|
||||
var changed: bool = prev_affinity != affinity
|
||||
var prev_color: Color = GameConstants.AFFINITY_COLORS.get(prev_affinity, Color(0.25, 0.25, 0.3))
|
||||
var color: Color = GameConstants.AFFINITY_COLORS.get(affinity, Color(0.8, 0.8, 0.9))
|
||||
var shape_key: String = "Hex" if pathfinder.grid_type == "Hexagon" else "Square"
|
||||
var expects_model: bool = not ContentCache.get_tile_model_url(affinity, shape_key).is_empty()
|
||||
if changed:
|
||||
body.set_meta("affinity_transition_affinity", affinity)
|
||||
var outgoing_snapshot: Node3D = _make_outgoing_tile_snapshot(body)
|
||||
if outgoing_snapshot != null:
|
||||
_play_tile_dissolve_shader(outgoing_snapshot, prev_color, 1.1)
|
||||
get_tree().create_timer(1.3).timeout.connect(func() -> void:
|
||||
if is_instance_valid(outgoing_snapshot):
|
||||
outgoing_snapshot.queue_free()
|
||||
, CONNECT_ONE_SHOT)
|
||||
body.set_meta("affinity", affinity)
|
||||
|
||||
# Update the placeholder colour in case there is no model for this affinity.
|
||||
for child in body.get_children():
|
||||
if child is MeshInstance3D and not bool(child.get_meta("tile_fx", false)):
|
||||
var mat: StandardMaterial3D = child.material_override as StandardMaterial3D
|
||||
if mat: mat.albedo_color = color
|
||||
|
||||
# Attempt to swap in a real 3D model.
|
||||
try_load_tile_model(body, affinity)
|
||||
if changed:
|
||||
var body_ref: WeakRef = weakref(body)
|
||||
if not expects_model:
|
||||
get_tree().create_timer(0.14).timeout.connect(func() -> void:
|
||||
var b: StaticBody3D = body_ref.get_ref() as StaticBody3D
|
||||
if is_instance_valid(b) \
|
||||
and str(b.get_meta("affinity_transition_affinity", "")) == affinity \
|
||||
and str(b.get_meta("affinity_transition_model_materialized", "")) != affinity:
|
||||
_play_tile_materialize_shader(b, color, 1.25)
|
||||
, CONNECT_ONE_SHOT)
|
||||
play_affinity_change_effect(body, prev_affinity, affinity)
|
||||
get_tree().create_timer(4.0 if expects_model else 2.2).timeout.connect(func() -> void:
|
||||
var b: StaticBody3D = body_ref.get_ref() as StaticBody3D
|
||||
if is_instance_valid(b) and str(b.get_meta("affinity_transition_affinity", "")) == affinity:
|
||||
_apply_direct_tile_placeholder_color(b, color)
|
||||
b.remove_meta("affinity_transition_affinity")
|
||||
if str(b.get_meta("affinity_transition_model_materialized", "")) == affinity:
|
||||
b.remove_meta("affinity_transition_model_materialized")
|
||||
, CONNECT_ONE_SHOT)
|
||||
|
||||
|
||||
func play_affinity_change_effect(body: StaticBody3D, prev_affinity: String, affinity: String) -> void:
|
||||
if not is_instance_valid(body):
|
||||
return
|
||||
var prev_color: Color = GameConstants.AFFINITY_COLORS.get(prev_affinity, Color(0.25, 0.25, 0.3))
|
||||
var color: Color = GameConstants.AFFINITY_COLORS.get(affinity, Color(0.8, 0.8, 0.9))
|
||||
var root: Node3D = Node3D.new()
|
||||
root.name = "AffinityTransition"
|
||||
root.set_meta("tile_fx", true)
|
||||
root.position = Vector3(0.0, _tile_effect_local_y(body), 0.0)
|
||||
body.add_child(root)
|
||||
|
||||
var outgoing: MeshInstance3D = _make_affinity_transition_mesh(prev_color)
|
||||
outgoing.name = "OutgoingDissolve"
|
||||
outgoing.position.y = 0.006
|
||||
root.add_child(outgoing)
|
||||
|
||||
var incoming: MeshInstance3D = _make_affinity_transition_mesh(color)
|
||||
incoming.name = "IncomingMaterialize"
|
||||
incoming.position.y = 0.028
|
||||
root.add_child(incoming)
|
||||
|
||||
var motes: CPUParticles3D = _make_affinity_motes(color)
|
||||
motes.position = Vector3.ZERO
|
||||
root.add_child(motes)
|
||||
motes.emitting = true
|
||||
|
||||
var outgoing_mat: ShaderMaterial = outgoing.material_override as ShaderMaterial
|
||||
var incoming_mat: ShaderMaterial = incoming.material_override as ShaderMaterial
|
||||
if outgoing_mat != null:
|
||||
outgoing_mat.set_shader_parameter("reveal", 1.0)
|
||||
outgoing_mat.set_shader_parameter("alpha_scale", 0.72)
|
||||
if incoming_mat != null:
|
||||
incoming_mat.set_shader_parameter("reveal", 0.0)
|
||||
incoming_mat.set_shader_parameter("alpha_scale", 0.0)
|
||||
|
||||
var tween: Tween = create_tween()
|
||||
tween.set_parallel(true)
|
||||
tween.tween_property(root, "position:x", 0.025, 0.045).set_trans(Tween.TRANS_SINE)
|
||||
tween.tween_property(root, "position:z", -0.018, 0.045).set_trans(Tween.TRANS_SINE)
|
||||
tween.chain().tween_property(root, "position:x", -0.022, 0.055).set_trans(Tween.TRANS_SINE)
|
||||
tween.parallel().tween_property(root, "position:z", 0.022, 0.055).set_trans(Tween.TRANS_SINE)
|
||||
tween.chain().tween_property(root, "position", Vector3(0.0, _tile_effect_local_y(body), 0.0), 0.08)
|
||||
tween.parallel().tween_property(root, "scale", Vector3(1.08, 1.0, 1.08), 0.82)\
|
||||
.set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
|
||||
if outgoing_mat != null:
|
||||
tween.parallel().tween_method(func(value: float) -> void:
|
||||
outgoing_mat.set_shader_parameter("reveal", value)
|
||||
, 1.0, 0.0, 0.46).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_IN)
|
||||
tween.parallel().tween_method(func(value: float) -> void:
|
||||
outgoing_mat.set_shader_parameter("alpha_scale", value)
|
||||
, 0.72, 0.0, 0.5).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN)
|
||||
if incoming_mat != null:
|
||||
tween.parallel().tween_method(func(value: float) -> void:
|
||||
incoming_mat.set_shader_parameter("alpha_scale", value)
|
||||
, 0.0, 0.88, 0.18).set_delay(0.08).set_trans(Tween.TRANS_SINE)
|
||||
tween.parallel().tween_method(func(value: float) -> void:
|
||||
incoming_mat.set_shader_parameter("reveal", value)
|
||||
, 0.0, 1.0, 0.68).set_delay(0.08).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
|
||||
tween.parallel().tween_method(func(value: float) -> void:
|
||||
incoming_mat.set_shader_parameter("alpha_scale", value)
|
||||
, 0.88, 0.0, 0.32).set_delay(0.72).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN)
|
||||
tween.finished.connect(func() -> void:
|
||||
if is_instance_valid(root):
|
||||
root.queue_free()
|
||||
)
|
||||
|
||||
|
||||
func _tile_effect_local_y(body: StaticBody3D) -> float:
|
||||
var coord: Vector2i = body.get_meta("tile_coord", Vector2i(-1, -1))
|
||||
var visual_top: float = tile_visual_tops.get(
|
||||
"%d,%d" % [coord.x, coord.y],
|
||||
body.position.y + float(body.get_meta("tile_height", 1.0)) * 0.5)
|
||||
return visual_top - body.position.y + 0.055
|
||||
|
||||
|
||||
func _apply_direct_tile_placeholder_color(body: StaticBody3D, color: Color) -> void:
|
||||
for child in body.get_children():
|
||||
if child is MeshInstance3D and not bool(child.get_meta("tile_fx", false)):
|
||||
var mat: StandardMaterial3D = child.material_override as StandardMaterial3D
|
||||
if mat != null:
|
||||
mat.albedo_color = color
|
||||
|
||||
|
||||
func _make_outgoing_tile_snapshot(body: StaticBody3D) -> Node3D:
|
||||
var root: Node3D = Node3D.new()
|
||||
root.name = "OutgoingAffinityModel"
|
||||
root.set_meta("tile_fx", true)
|
||||
root.set_meta("tile_shader_fx", true)
|
||||
|
||||
for child in body.get_children():
|
||||
if child is CollisionShape3D or bool(child.get_meta("tile_fx", false)):
|
||||
continue
|
||||
var duplicate_child: Node = child.duplicate(Node.DUPLICATE_SIGNALS | Node.DUPLICATE_GROUPS | Node.DUPLICATE_SCRIPTS)
|
||||
if duplicate_child == null:
|
||||
continue
|
||||
root.add_child(duplicate_child)
|
||||
|
||||
if root.get_child_count() <= 0:
|
||||
root.queue_free()
|
||||
return null
|
||||
body.add_child(root)
|
||||
return root
|
||||
|
||||
|
||||
func _make_affinity_transition_mesh(color: Color) -> MeshInstance3D:
|
||||
var mi: MeshInstance3D = MeshInstance3D.new()
|
||||
if pathfinder.grid_type == "Hexagon":
|
||||
var hex_mesh: CylinderMesh = CylinderMesh.new()
|
||||
hex_mesh.height = 0.012
|
||||
hex_mesh.radial_segments = 6
|
||||
var radius: float = GameConstants.HEX_TILE_RADIUS * GameConstants.HEX_TILE_SPACING * 0.94
|
||||
hex_mesh.top_radius = radius
|
||||
hex_mesh.bottom_radius = radius
|
||||
mi.mesh = hex_mesh
|
||||
else:
|
||||
var box_mesh: BoxMesh = BoxMesh.new()
|
||||
box_mesh.size = Vector3(0.92, 0.012, 0.92)
|
||||
mi.mesh = box_mesh
|
||||
|
||||
var mat: ShaderMaterial = ShaderMaterial.new()
|
||||
mat.shader = _get_affinity_transition_shader()
|
||||
mat.set_shader_parameter("affinity_color", Color(color.r, color.g, color.b, 1.0))
|
||||
mat.set_shader_parameter("reveal", 0.0)
|
||||
mat.set_shader_parameter("alpha_scale", 0.0)
|
||||
mi.material_override = mat
|
||||
return mi
|
||||
|
||||
|
||||
func _get_affinity_transition_shader() -> Shader:
|
||||
if affinity_transition_shader != null:
|
||||
return affinity_transition_shader
|
||||
var shader: Shader = Shader.new()
|
||||
shader.code = """
|
||||
shader_type spatial;
|
||||
render_mode blend_mix, cull_disabled, unshaded;
|
||||
|
||||
uniform vec4 affinity_color : source_color = vec4(1.0, 0.85, 0.35, 1.0);
|
||||
uniform float reveal : hint_range(0.0, 1.0) = 0.0;
|
||||
uniform float alpha_scale : hint_range(0.0, 1.0) = 1.0;
|
||||
|
||||
varying vec3 local_pos;
|
||||
|
||||
float hash21(vec2 p) {
|
||||
p = fract(p * vec2(123.34, 456.21));
|
||||
p += dot(p, p + 45.32);
|
||||
return fract(p.x * p.y);
|
||||
}
|
||||
|
||||
float value_noise(vec2 p) {
|
||||
vec2 i = floor(p);
|
||||
vec2 f = fract(p);
|
||||
f = f * f * (3.0 - 2.0 * f);
|
||||
float a = hash21(i);
|
||||
float b = hash21(i + vec2(1.0, 0.0));
|
||||
float c = hash21(i + vec2(0.0, 1.0));
|
||||
float d = hash21(i + vec2(1.0, 1.0));
|
||||
return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);
|
||||
}
|
||||
|
||||
void vertex() {
|
||||
local_pos = VERTEX;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec2 p = local_pos.xz * 5.5;
|
||||
float n = value_noise(p) * 0.62 + value_noise(p * 2.15 + vec2(7.1, 3.4)) * 0.38;
|
||||
float radial = smoothstep(0.74, 0.08, length(local_pos.xz));
|
||||
float threshold = clamp(reveal, 0.001, 0.999);
|
||||
if (n > threshold) {
|
||||
discard;
|
||||
}
|
||||
float edge = 1.0 - smoothstep(0.0, 0.11, abs(n - threshold));
|
||||
float body_alpha = alpha_scale * (0.28 + edge * 0.58) * radial;
|
||||
ALBEDO = affinity_color.rgb * (0.55 + edge * 0.45);
|
||||
EMISSION = affinity_color.rgb * (1.2 + edge * 3.8);
|
||||
ALPHA = body_alpha;
|
||||
}
|
||||
"""
|
||||
affinity_transition_shader = shader
|
||||
return affinity_transition_shader
|
||||
|
||||
|
||||
func _play_tile_materialize_shader(visual: Node, color: Color, duration: float) -> void:
|
||||
if not is_instance_valid(visual):
|
||||
return
|
||||
var surfaces: Array[Dictionary] = []
|
||||
_collect_tile_materialize_surfaces(visual, surfaces)
|
||||
if surfaces.is_empty():
|
||||
return
|
||||
|
||||
var reveal_mats: Array[ShaderMaterial] = []
|
||||
for entry: Dictionary in surfaces:
|
||||
var mesh_ref: WeakRef = entry["mesh_ref"] as WeakRef
|
||||
var mi: MeshInstance3D = mesh_ref.get_ref() as MeshInstance3D if mesh_ref != null else null
|
||||
if not is_instance_valid(mi):
|
||||
continue
|
||||
var mat: ShaderMaterial = ShaderMaterial.new()
|
||||
mat.shader = _get_tile_materialize_shader()
|
||||
mat.set_shader_parameter("reveal", 0.0)
|
||||
mat.set_shader_parameter("team_color", Color(color.r, color.g, color.b, 1.0))
|
||||
mi.material_override = mat
|
||||
reveal_mats.append(mat)
|
||||
|
||||
var target_scale: Vector3 = Vector3.ONE
|
||||
var visual_3d: Node3D = visual as Node3D
|
||||
if visual_3d != null and not (visual_3d is StaticBody3D):
|
||||
target_scale = visual_3d.scale
|
||||
visual_3d.scale = target_scale * 0.96
|
||||
|
||||
var tween: Tween = create_tween()
|
||||
tween.set_trans(Tween.TRANS_CUBIC)
|
||||
tween.set_ease(Tween.EASE_OUT)
|
||||
if visual_3d != null and not (visual_3d is StaticBody3D):
|
||||
tween.parallel().tween_property(visual_3d, "scale", target_scale, duration)
|
||||
tween.parallel().tween_method(func(value: float) -> void:
|
||||
for mat: ShaderMaterial in reveal_mats:
|
||||
if mat != null:
|
||||
mat.set_shader_parameter("reveal", value)
|
||||
, 0.0, 1.0, duration)
|
||||
tween.tween_callback(func() -> void:
|
||||
for entry: Dictionary in surfaces:
|
||||
var mesh_ref: WeakRef = entry["mesh_ref"] as WeakRef
|
||||
var mi: MeshInstance3D = mesh_ref.get_ref() as MeshInstance3D if mesh_ref != null else null
|
||||
if is_instance_valid(mi):
|
||||
mi.material_override = entry["override"]
|
||||
)
|
||||
|
||||
|
||||
func _play_tile_dissolve_shader(visual: Node, color: Color, duration: float) -> void:
|
||||
if not is_instance_valid(visual):
|
||||
return
|
||||
var surfaces: Array[Dictionary] = []
|
||||
_collect_tile_materialize_surfaces(visual, surfaces)
|
||||
if surfaces.is_empty():
|
||||
return
|
||||
|
||||
var dissolve_mats: Array[ShaderMaterial] = []
|
||||
for entry: Dictionary in surfaces:
|
||||
var mesh_ref: WeakRef = entry["mesh_ref"] as WeakRef
|
||||
var mi: MeshInstance3D = mesh_ref.get_ref() as MeshInstance3D if mesh_ref != null else null
|
||||
if not is_instance_valid(mi):
|
||||
continue
|
||||
var mat: ShaderMaterial = ShaderMaterial.new()
|
||||
mat.shader = _get_tile_materialize_shader()
|
||||
mat.set_shader_parameter("reveal", 1.0)
|
||||
mat.set_shader_parameter("team_color", Color(color.r, color.g, color.b, 1.0))
|
||||
mi.material_override = mat
|
||||
dissolve_mats.append(mat)
|
||||
|
||||
var tween: Tween = create_tween()
|
||||
tween.set_trans(Tween.TRANS_CUBIC)
|
||||
tween.set_ease(Tween.EASE_IN)
|
||||
tween.tween_method(func(value: float) -> void:
|
||||
for mat: ShaderMaterial in dissolve_mats:
|
||||
if mat != null:
|
||||
mat.set_shader_parameter("reveal", value)
|
||||
, 1.0, 0.0, duration)
|
||||
tween.tween_callback(func() -> void:
|
||||
for entry: Dictionary in surfaces:
|
||||
var mesh_ref: WeakRef = entry["mesh_ref"] as WeakRef
|
||||
var mi: MeshInstance3D = mesh_ref.get_ref() as MeshInstance3D if mesh_ref != null else null
|
||||
if is_instance_valid(mi):
|
||||
mi.material_override = entry["override"]
|
||||
)
|
||||
|
||||
|
||||
func _collect_tile_materialize_surfaces(node: Node, surfaces: Array[Dictionary]) -> void:
|
||||
if bool(node.get_meta("tile_fx", false)) and not bool(node.get_meta("tile_shader_fx", false)):
|
||||
return
|
||||
if node is MeshInstance3D:
|
||||
var mi: MeshInstance3D = node as MeshInstance3D
|
||||
surfaces.append({
|
||||
"mesh_ref": weakref(mi),
|
||||
"override": mi.material_override
|
||||
})
|
||||
for child: Node in node.get_children():
|
||||
_collect_tile_materialize_surfaces(child, surfaces)
|
||||
|
||||
|
||||
func _get_tile_materialize_shader() -> Shader:
|
||||
if tile_materialize_shader != null:
|
||||
return tile_materialize_shader
|
||||
var shader: Shader = Shader.new()
|
||||
shader.code = """
|
||||
shader_type spatial;
|
||||
render_mode blend_mix, cull_disabled, depth_draw_opaque;
|
||||
|
||||
uniform float reveal : hint_range(0.0, 1.0) = 0.0;
|
||||
uniform vec4 team_color : source_color = vec4(0.35, 0.5, 1.0, 1.0);
|
||||
|
||||
varying vec3 local_pos;
|
||||
|
||||
float hash13(vec3 p) {
|
||||
p = fract(p * 0.1031);
|
||||
p += dot(p, p.yzx + 33.33);
|
||||
return fract((p.x + p.y) * p.z);
|
||||
}
|
||||
|
||||
void vertex() {
|
||||
local_pos = VERTEX;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec3 cell = floor((local_pos + vec3(0.0, TIME * 0.08, 0.0)) * 9.0);
|
||||
float bubble_noise = hash13(cell);
|
||||
float fine_noise = hash13(floor((local_pos + vec3(TIME * 0.12, 0.0, 0.0)) * 23.0));
|
||||
float threshold = clamp(reveal * 1.18 - 0.08, 0.0, 1.0);
|
||||
|
||||
if (bubble_noise > threshold) {
|
||||
discard;
|
||||
}
|
||||
|
||||
float edge = 1.0 - smoothstep(0.0, 0.16, abs(bubble_noise - threshold));
|
||||
float shimmer = smoothstep(0.72, 1.0, fine_noise) * (1.0 - reveal * 0.45);
|
||||
vec3 dark_affinity = team_color.rgb * 0.12;
|
||||
vec3 final_tint = mix(team_color.rgb * 0.45, team_color.rgb, reveal);
|
||||
vec3 color = mix(dark_affinity, final_tint, smoothstep(0.25, 1.0, reveal));
|
||||
color += team_color.rgb * (edge * 1.8 + shimmer * 0.9);
|
||||
|
||||
ALBEDO = color;
|
||||
EMISSION = team_color.rgb * (edge * 1.5 + shimmer);
|
||||
ROUGHNESS = 0.35;
|
||||
ALPHA = 1.0;
|
||||
}
|
||||
"""
|
||||
tile_materialize_shader = shader
|
||||
return tile_materialize_shader
|
||||
|
||||
|
||||
func _make_affinity_motes(color: Color) -> CPUParticles3D:
|
||||
var particles: CPUParticles3D = CPUParticles3D.new()
|
||||
particles.name = "AffinityMotes"
|
||||
particles.amount = 80
|
||||
particles.lifetime = 0.8
|
||||
particles.one_shot = true
|
||||
particles.explosiveness = 0.7
|
||||
particles.randomness = 0.82
|
||||
particles.lifetime_randomness = 0.35
|
||||
particles.local_coords = true
|
||||
particles.emission_shape = CPUParticles3D.EMISSION_SHAPE_SPHERE
|
||||
particles.emission_sphere_radius = 0.36
|
||||
particles.direction = Vector3.UP
|
||||
particles.spread = 110.0
|
||||
particles.gravity = Vector3(0.0, 0.05, 0.0)
|
||||
particles.initial_velocity_min = 0.04
|
||||
particles.initial_velocity_max = 0.42
|
||||
particles.scale_amount_min = 0.012
|
||||
particles.scale_amount_max = 0.045
|
||||
particles.color = Color(color.r, color.g, color.b, 0.82)
|
||||
|
||||
var mote_mesh: SphereMesh = SphereMesh.new()
|
||||
mote_mesh.radius = 0.035
|
||||
mote_mesh.height = 0.07
|
||||
mote_mesh.radial_segments = 10
|
||||
mote_mesh.rings = 5
|
||||
var mat: StandardMaterial3D = StandardMaterial3D.new()
|
||||
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
mat.albedo_color = Color(color.r, color.g, color.b, 0.72)
|
||||
mat.emission_enabled = true
|
||||
mat.emission = Color(color.r, color.g, color.b)
|
||||
mat.emission_energy_multiplier = 2.6
|
||||
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
mote_mesh.material = mat
|
||||
particles.mesh = mote_mesh
|
||||
return particles
|
||||
@@ -0,0 +1 @@
|
||||
uid://di6lk8rawljgn
|
||||
@@ -0,0 +1,229 @@
|
||||
class_name Pathfinder
|
||||
extends Node
|
||||
|
||||
## Encapsulates board math, raycasting, and grid pathfinding.
|
||||
##
|
||||
## Must be added as a child of GameScreen (or any Node3D that owns a World3D).
|
||||
## Set camera, grid_type, and hex_sides before use.
|
||||
|
||||
# Must be set by parent before use.
|
||||
var camera: Camera3D = null
|
||||
var grid_type: String = "Square"
|
||||
var hex_sides: int = 0
|
||||
|
||||
# ── Coord helpers ─────────────────────────────────────────────────────────────
|
||||
|
||||
## Convert grid coordinate (x, y) to world-space Vector3.
|
||||
func coord_to_world(x: int, y: int) -> Vector3:
|
||||
if grid_type == "Hexagon":
|
||||
var N: int = hex_sides
|
||||
var q: float = x - (N - 1)
|
||||
var r: float = y - (N - 1)
|
||||
var wx: float = GameConstants.HEX_TILE_SPACING * sqrt(3.0) * (q + r * 0.5)
|
||||
var wz: float = GameConstants.HEX_TILE_SPACING * 1.5 * r
|
||||
return Vector3(wx, 0.0, wz)
|
||||
return Vector3(
|
||||
x * GameConstants.TILE_SPACING - (Game.board_width() - 1) * GameConstants.TILE_SPACING * 0.5, 0.0,
|
||||
y * GameConstants.TILE_SPACING - (Game.board_height() - 1) * GameConstants.TILE_SPACING * 0.5)
|
||||
|
||||
|
||||
## Raycast from camera through mouse_pos and return the tile coord, or Vector2i(-1,-1).
|
||||
## tile_bodies: the "x,y" → StaticBody3D dictionary owned by GameScreen.
|
||||
func mouse_to_tile_coord(mouse_pos: Vector2, tile_bodies: Dictionary) -> Vector2i:
|
||||
var body: PhysicsBody3D = raycast_body(mouse_pos)
|
||||
if body == null:
|
||||
return Vector2i(-1, -1)
|
||||
if body.has_meta("tile_coord"):
|
||||
return body.get_meta("tile_coord") as Vector2i
|
||||
if body.has_meta("unit_id"):
|
||||
var unit_id: String = str(body.get_meta("unit_id"))
|
||||
if not unit_id.is_empty():
|
||||
var unit: Dictionary = Game.get_unit_by_id(unit_id)
|
||||
if not unit.is_empty():
|
||||
var pos: Dictionary = unit.get("position", {}) as Dictionary
|
||||
if not pos.is_empty():
|
||||
return Vector2i(int(pos.get("x", -1)), int(pos.get("y", -1)))
|
||||
return Vector2i(-1, -1)
|
||||
|
||||
|
||||
## Raycast from camera through mouse_pos and return the unit instance ID, or "".
|
||||
func mouse_to_unit_id(mouse_pos: Vector2) -> String:
|
||||
var body: PhysicsBody3D = raycast_body(mouse_pos)
|
||||
if body == null:
|
||||
return ""
|
||||
if body.has_meta("unit_id"):
|
||||
return str(body.get_meta("unit_id"))
|
||||
return ""
|
||||
|
||||
|
||||
## Raycast from camera through mouse_pos into the scene's physics world.
|
||||
## Returns the first PhysicsBody3D hit, or null.
|
||||
func raycast_body(mouse_pos: Vector2) -> PhysicsBody3D:
|
||||
var space: PhysicsDirectSpaceState3D = get_tree().get_root().get_world_3d().direct_space_state
|
||||
var from: Vector3 = camera.project_ray_origin(mouse_pos)
|
||||
var to: Vector3 = from + camera.project_ray_normal(mouse_pos) * 100.0
|
||||
var query: PhysicsRayQueryParameters3D = PhysicsRayQueryParameters3D.create(from, to)
|
||||
var result: Dictionary = space.intersect_ray(query)
|
||||
if result.is_empty():
|
||||
return null
|
||||
return result.get("collider") as PhysicsBody3D
|
||||
|
||||
# ── BFS pathfinding ───────────────────────────────────────────────────────────
|
||||
|
||||
## BFS on the game grid using the correct neighbour set for the current grid type.
|
||||
## blocked: Dictionary[Vector2i → true] of impassable tiles;
|
||||
## the destination 'to' is always reachable regardless.
|
||||
## tile_bodies: the "x,y" → StaticBody3D dictionary owned by GameScreen.
|
||||
## Returns the path steps NOT including 'from', including 'to'.
|
||||
## Falls back to [to] if no path found (shouldn't happen on a connected grid).
|
||||
func bfs_path(from: Vector2i, to: Vector2i, blocked: Dictionary, tile_bodies: Dictionary) -> Array[Vector2i]:
|
||||
if from == to:
|
||||
return []
|
||||
var bw: int = Game.board_width()
|
||||
var bh: int = Game.board_height()
|
||||
var DIRS: Array[Vector2i]
|
||||
if grid_type == "Hexagon":
|
||||
DIRS = [Vector2i(1,0), Vector2i(-1,0), Vector2i(0,1), Vector2i(0,-1),
|
||||
Vector2i(1,-1), Vector2i(-1,1)]
|
||||
else:
|
||||
DIRS = [Vector2i(1,0), Vector2i(-1,0), Vector2i(0,1), Vector2i(0,-1)]
|
||||
var visited: Dictionary = {from: true}
|
||||
# Queue entries: [pos: Vector2i, path: Array[Vector2i]]
|
||||
var queue: Array = [[from, []]]
|
||||
while not queue.is_empty():
|
||||
var front: Array = queue.pop_front()
|
||||
var cur: Vector2i = front[0]
|
||||
var path: Array = front[1] # untyped — stored in a plain Array queue
|
||||
for d: Vector2i in DIRS:
|
||||
var nxt: Vector2i = cur + d
|
||||
if nxt.x < 0 or nxt.x >= bw or nxt.y < 0 or nxt.y >= bh:
|
||||
continue
|
||||
if not tile_bodies.has("%d,%d" % [nxt.x, nxt.y]):
|
||||
continue
|
||||
if visited.has(nxt):
|
||||
continue
|
||||
if blocked.has(nxt) and nxt != to:
|
||||
continue
|
||||
visited[nxt] = true
|
||||
var new_path: Array = path.duplicate()
|
||||
new_path.append(nxt)
|
||||
if nxt == to:
|
||||
var typed: Array[Vector2i] = []
|
||||
typed.assign(new_path)
|
||||
return typed
|
||||
queue.append([nxt, new_path])
|
||||
return [to] # fallback: direct jump
|
||||
|
||||
|
||||
## BFS reachable set — returns all coords reachable within max_mp steps,
|
||||
## treating blocked_coords as impassable walls (destination included in check).
|
||||
## tile_bodies: the "x,y" → StaticBody3D dictionary owned by GameScreen.
|
||||
## Mirrors Pathfinding.GetReachableWithCost on the server.
|
||||
func bfs_reachable(fx: int, fy: int, max_mp: int, blocked_coords: Dictionary, tile_bodies: Dictionary) -> Array:
|
||||
var bw: int = Game.board_width()
|
||||
var bh: int = Game.board_height()
|
||||
var DIRS: Array[Vector2i]
|
||||
if grid_type == "Hexagon":
|
||||
DIRS = [Vector2i(1,0), Vector2i(-1,0), Vector2i(0,1), Vector2i(0,-1),
|
||||
Vector2i(1,-1), Vector2i(-1,1)]
|
||||
else:
|
||||
DIRS = [Vector2i(1,0), Vector2i(-1,0), Vector2i(0,1), Vector2i(0,-1)]
|
||||
var cost: Dictionary = { Vector2i(fx, fy): 0 }
|
||||
var queue: Array = [Vector2i(fx, fy)]
|
||||
while not queue.is_empty():
|
||||
var cur: Vector2i = queue.pop_front()
|
||||
var cur_cost: int = cost[cur]
|
||||
if cur_cost >= max_mp:
|
||||
continue
|
||||
for d: Vector2i in DIRS:
|
||||
var nxt: Vector2i = cur + d
|
||||
if nxt.x < 0 or nxt.x >= bw or nxt.y < 0 or nxt.y >= bh:
|
||||
continue
|
||||
if not tile_bodies.has("%d,%d" % [nxt.x, nxt.y]):
|
||||
continue
|
||||
if cost.has(nxt):
|
||||
continue
|
||||
if blocked_coords.has(nxt):
|
||||
continue
|
||||
cost[nxt] = cur_cost + 1
|
||||
queue.append(nxt)
|
||||
var results: Array = []
|
||||
for coord in cost.keys():
|
||||
if coord != Vector2i(fx, fy):
|
||||
results.append(coord)
|
||||
return results
|
||||
|
||||
|
||||
## Manhattan distance on square grids; cube-coordinate distance on hexagonal grids.
|
||||
func board_distance(x1: int, y1: int, x2: int, y2: int) -> int:
|
||||
if grid_type == "Hexagon":
|
||||
var N: int = hex_sides
|
||||
var dq: int = (x1 - (N - 1)) - (x2 - (N - 1))
|
||||
var dr: int = (y1 - (N - 1)) - (y2 - (N - 1))
|
||||
return (abs(dq) + abs(dr) + abs(dq + dr)) / 2
|
||||
return abs(x1 - x2) + abs(y1 - y2)
|
||||
|
||||
|
||||
## Line-of-sight check between two grid coordinates.
|
||||
## Returns true if no occupied tile blocks the line from (sx,sy) to (tx,ty).
|
||||
func client_has_los(sx: int, sy: int, tx: int, ty: int) -> bool:
|
||||
if sx == tx and sy == ty:
|
||||
return true
|
||||
if grid_type == "Hexagon":
|
||||
var N: int = hex_sides
|
||||
var aq: int = sx - (N - 1); var ar: int = sy - (N - 1)
|
||||
var bq: int = tx - (N - 1); var br: int = ty - (N - 1)
|
||||
var as_: int = -aq - ar; var bs: int = -bq - br
|
||||
var n: int = board_distance(sx, sy, tx, ty)
|
||||
if n == 0:
|
||||
return true
|
||||
for i in range(1, n):
|
||||
var t: float = float(i) / float(n)
|
||||
var fq: float = aq + (bq - aq) * t
|
||||
var fr: float = ar + (br - ar) * t
|
||||
var fs: float = as_ + (bs - as_) * t
|
||||
var rq: int = roundi(fq)
|
||||
var rr: int = roundi(fr)
|
||||
var rs: int = roundi(fs)
|
||||
if rq + rr + rs != 0:
|
||||
var eq: float = abs(rq - fq)
|
||||
var er: float = abs(rr - fr)
|
||||
var es: float = abs(rs - fs)
|
||||
if eq >= er and eq >= es:
|
||||
rq = -rr - rs
|
||||
elif er >= es:
|
||||
rr = -rq - rs
|
||||
else:
|
||||
rs = -rq - rr
|
||||
var cx: int = rq + (N - 1)
|
||||
var cy: int = rr + (N - 1)
|
||||
var tile: Dictionary = Game.get_tile(cx, cy)
|
||||
if not tile.is_empty() and str(tile.get("occupantId", "")) != "":
|
||||
return false
|
||||
return true
|
||||
# Square: supercover DDA
|
||||
var dx: int = tx - sx
|
||||
var dy: int = ty - sy
|
||||
var nx: int = absi(dx)
|
||||
var ny: int = absi(dy)
|
||||
var sign_x: int = 1 if dx > 0 else -1
|
||||
var sign_y: int = 1 if dy > 0 else -1
|
||||
var ix: int = 0
|
||||
var iy: int = 0
|
||||
var cx: int = sx
|
||||
var cy: int = sy
|
||||
while ix < nx or iy < ny:
|
||||
var t_x: float = (float(ix) + 0.5) / nx if nx > 0 else 1e9
|
||||
var t_y: float = (float(iy) + 0.5) / ny if ny > 0 else 1e9
|
||||
if t_x < t_y:
|
||||
cx += sign_x
|
||||
ix += 1
|
||||
else:
|
||||
cy += sign_y
|
||||
iy += 1
|
||||
if cx == tx and cy == ty:
|
||||
break
|
||||
var tile: Dictionary = Game.get_tile(cx, cy)
|
||||
if not tile.is_empty() and str(tile.get("occupantId", "")) != "":
|
||||
return false
|
||||
return true
|
||||
@@ -0,0 +1 @@
|
||||
uid://p60mlwa5sywi
|
||||
@@ -0,0 +1,309 @@
|
||||
class_name TileTargetResolver
|
||||
extends Node
|
||||
|
||||
## Computes valid tile/unit target sets for all game actions.
|
||||
##
|
||||
## Requires pathfinder and unit_registry to be set before any method is called.
|
||||
## tile_bodies must be passed into methods that need physics-body existence checks
|
||||
## (the "x,y" → StaticBody3D dictionary owned by GameScreen).
|
||||
|
||||
var pathfinder: Pathfinder = null
|
||||
var unit_registry: UnitRegistry = null
|
||||
|
||||
# ── Spirit card play targets ──────────────────────────────────────────────────
|
||||
|
||||
## Returns the array of Vector2i coords that are valid play targets for the given hand card.
|
||||
## tile_bodies: "x,y" → StaticBody3D dict from GameScreen.
|
||||
func valid_play_tiles(card: Dictionary, tile_bodies: Dictionary) -> Array:
|
||||
var results: Array = []
|
||||
var card_type: String = card.get("cardType", "")
|
||||
var board: Dictionary = Game.get_board()
|
||||
var bw: int = board.get("width", 8)
|
||||
var bh: int = board.get("height", 8)
|
||||
var arch: Dictionary = Game.get_my_player().get("archSpirit", {})
|
||||
var arch_pos: Dictionary = arch.get("position", {})
|
||||
|
||||
match card_type:
|
||||
"Spirit":
|
||||
if arch_pos.is_empty():
|
||||
return results
|
||||
var ax: int = arch_pos.get("x", 0)
|
||||
var ay: int = arch_pos.get("y", 0)
|
||||
# Channel range is validated by the server from the Spirit card being played.
|
||||
# dict.get(key, default) only uses the default when the key is ABSENT.
|
||||
# The server sends nullable ints (e.g. "minChannelRange": null), so the
|
||||
# key EXISTS but its value is null — GDScript returns null, which silently
|
||||
# coerces to 0 on a typed int variable, collapsing the range to nothing.
|
||||
# Read as Variant first, then substitute the default explicitly.
|
||||
var raw_min: Variant = card.get("minChannelRange")
|
||||
var raw_max: Variant = card.get("maxChannelRange")
|
||||
var min_r: int = 1 if raw_min == null else int(raw_min)
|
||||
var max_r: int = 1 if raw_max == null else int(raw_max)
|
||||
var card_affinity: String = card.get("affinity", "")
|
||||
for tx in range(bw):
|
||||
for ty in range(bh):
|
||||
if not tile_bodies.has("%d,%d" % [tx, ty]):
|
||||
continue
|
||||
var dist: int = pathfinder.board_distance(tx, ty, ax, ay)
|
||||
if dist < min_r or dist > max_r:
|
||||
continue
|
||||
var tile: Dictionary = Game.get_tile(tx, ty)
|
||||
print("tile", tile)
|
||||
print("[GettingAff]", card_affinity)
|
||||
if unit_registry.tile_has_blocking_occupant(tile):
|
||||
continue
|
||||
if card_affinity != "" and not tile_matches_channel_affinity(tile, card_affinity):
|
||||
continue
|
||||
results.append(Vector2i(tx, ty))
|
||||
|
||||
"Terramorpha":
|
||||
for tx in range(bw):
|
||||
for ty in range(bh):
|
||||
if not tile_bodies.has("%d,%d" % [tx, ty]):
|
||||
continue
|
||||
results.append(Vector2i(tx, ty))
|
||||
|
||||
"Repentance", "Instinct", "Ruin":
|
||||
pass # No tile target — played directly (server handles placement for Ruins, repentance and Instinct have own target systems).
|
||||
|
||||
return results
|
||||
|
||||
|
||||
## Returns the number of tile targets a Terramorpha card requires.
|
||||
func terra_count_for_card(card: Dictionary) -> int:
|
||||
match card.get("terramorphaMode", ""):
|
||||
"Mono": return 1
|
||||
"Di": return 2
|
||||
"Tri": return 3
|
||||
return 1
|
||||
|
||||
|
||||
## Returns true when the tile's resolved affinity matches the card affinity for channelling.
|
||||
func tile_matches_channel_affinity(tile: Dictionary, card_affinity: String) -> bool:
|
||||
var resolved_affinity: String = str(tile.get("resolvedAffinity", "Void"))
|
||||
print("[AFFINITY_TILE]", resolved_affinity, card_affinity)
|
||||
if resolved_affinity == "PerfectAether" and card_affinity in ["Lake", "Hill", "Forest", "Field"]:
|
||||
return true
|
||||
if resolved_affinity == "UnstableAether":
|
||||
return false
|
||||
if card_affinity in ["Lake", "Hill", "Forest", "Field"]:
|
||||
var base1: String = str(tile.get("base1", "Void"))
|
||||
var base2: String = str(tile.get("base2", "Void"))
|
||||
return base1 == card_affinity or base2 == card_affinity
|
||||
return resolved_affinity == card_affinity
|
||||
|
||||
# ── Unit movement targets ─────────────────────────────────────────────────────
|
||||
|
||||
## Returns the array of Vector2i coords that are valid destinations for a unit move.
|
||||
## tile_bodies: "x,y" → StaticBody3D dict from GameScreen.
|
||||
func valid_move_tiles(unit: Dictionary, tile_bodies: Dictionary) -> Array:
|
||||
var pos: Dictionary = unit.get("position", {})
|
||||
if pos.is_empty():
|
||||
return []
|
||||
var ux: int = pos.get("x", 0)
|
||||
var uy: int = pos.get("y", 0)
|
||||
var mp: int = unit.get("currentMp", 0)
|
||||
var mov: String = str(unit.get("movementType", "Walk")).to_lower()
|
||||
if not bool(unit.get("canMove", false)):
|
||||
return []
|
||||
if mp <= 0:
|
||||
return []
|
||||
|
||||
var bw: int = Game.board_width()
|
||||
var bh: int = Game.board_height()
|
||||
|
||||
# Walk / Flight: BFS — can't pass through blocked tiles
|
||||
if mov == "walk" or mov == "flight":
|
||||
# Build blocked set from all occupants, excluding this unit.
|
||||
var blocked: Dictionary = {}
|
||||
var extra_obstructors: Dictionary = unit_registry.units_obstructing_movement_type(mov)
|
||||
var moving_id: String = str(unit.get("instanceId", ""))
|
||||
for unit_dict: Dictionary in unit_registry.all_board_units():
|
||||
var up: Dictionary = unit_dict.get("position", {})
|
||||
if up.is_empty():
|
||||
continue
|
||||
var iid: String = str(unit_dict.get("instanceId", ""))
|
||||
if iid == moving_id:
|
||||
continue
|
||||
var cx: int = up.get("x", 0)
|
||||
var cy: int = up.get("y", 0)
|
||||
if cx == ux and cy == uy:
|
||||
continue # don't block own tile
|
||||
# Flight is blocked by other Flight units or explicit movement obstructors.
|
||||
if mov == "flight":
|
||||
var blocks_flight: bool = str(unit_dict.get("movementType", "Walk")).to_lower() == "flight"
|
||||
if not blocks_flight and not extra_obstructors.has(iid):
|
||||
continue
|
||||
blocked[Vector2i(cx, cy)] = true
|
||||
return pathfinder.bfs_reachable(ux, uy, mp, blocked, tile_bodies)
|
||||
|
||||
# Jump / Teleport: land on any unoccupied tile. Teleport also requires LOS.
|
||||
var results: Array = []
|
||||
if mov != "jump" and mov != "teleport":
|
||||
return results
|
||||
for tx in range(bw):
|
||||
for ty in range(bh):
|
||||
if not tile_bodies.has("%d,%d" % [tx, ty]):
|
||||
continue
|
||||
if tx == ux and ty == uy:
|
||||
continue
|
||||
if unit_registry.tile_has_blocking_occupant(Game.get_tile(tx, ty)):
|
||||
continue
|
||||
# Teleport additionally requires LOS to the destination.
|
||||
if mov == "teleport" and not pathfinder.client_has_los(ux, uy, tx, ty):
|
||||
continue
|
||||
results.append(Vector2i(tx, ty))
|
||||
return results
|
||||
|
||||
# ── Attack targets ────────────────────────────────────────────────────────────
|
||||
|
||||
## Returns the position Dictionaries of all valid attack targets for a unit.
|
||||
func valid_attack_target_coords(unit: Dictionary) -> Array:
|
||||
var results: Array = []
|
||||
var pos: Dictionary = unit.get("position", {})
|
||||
if pos.is_empty():
|
||||
return results
|
||||
var ux: int = pos.get("x", 0)
|
||||
var uy: int = pos.get("y", 0)
|
||||
var raw_min_r: Variant = unit.get("minAttackRange")
|
||||
var raw_max_r: Variant = unit.get("maxAttackRange")
|
||||
var min_r: int = 1 if raw_min_r == null else int(raw_min_r)
|
||||
var max_r: int = 1 if raw_max_r == null else int(raw_max_r)
|
||||
var needs_los: bool = bool(unit.get("attackRequiresLos", false))
|
||||
if unit.get("isExhausted", false) and unit.get("extraAttacksRemaining", 0) == 0:
|
||||
return results
|
||||
for t: Dictionary in Game.get_all_enemy_units():
|
||||
if unit_registry.is_ruin_unit(t):
|
||||
continue
|
||||
if not t.get("canBeAttacked", true):
|
||||
continue
|
||||
var _tpos: Variant = t.get("position")
|
||||
if not (_tpos is Dictionary):
|
||||
continue
|
||||
var tp: Dictionary = _tpos
|
||||
if tp.is_empty():
|
||||
continue
|
||||
var tx: int = tp.get("x", 0)
|
||||
var ty: int = tp.get("y", 0)
|
||||
var dist: int = pathfinder.board_distance(tx, ty, ux, uy)
|
||||
if dist < min_r or dist > max_r:
|
||||
continue
|
||||
if needs_los and not pathfinder.client_has_los(ux, uy, tx, ty):
|
||||
continue
|
||||
results.append(tp)
|
||||
return results
|
||||
|
||||
|
||||
## Returns the instance IDs of all valid attack target units for a unit.
|
||||
func valid_attack_target_ids(unit: Dictionary) -> Array:
|
||||
var results: Array = []
|
||||
var pos: Dictionary = unit.get("position", {})
|
||||
if pos.is_empty():
|
||||
return results
|
||||
var ux: int = pos.get("x", 0)
|
||||
var uy: int = pos.get("y", 0)
|
||||
var raw_min_r: Variant = unit.get("minAttackRange")
|
||||
var raw_max_r: Variant = unit.get("maxAttackRange")
|
||||
var min_r: int = 1 if raw_min_r == null else int(raw_min_r)
|
||||
var max_r: int = 1 if raw_max_r == null else int(raw_max_r)
|
||||
var needs_los: bool = bool(unit.get("attackRequiresLos", false))
|
||||
if unit.get("isExhausted", false) and unit.get("extraAttacksRemaining", 0) == 0:
|
||||
return results
|
||||
for t: Dictionary in Game.get_all_enemy_units():
|
||||
if not t.get("canBeAttacked", true):
|
||||
continue
|
||||
var tp: Dictionary = t.get("position", {})
|
||||
if tp.is_empty():
|
||||
continue
|
||||
var tx: int = tp.get("x", 0)
|
||||
var ty: int = tp.get("y", 0)
|
||||
var dist: int = pathfinder.board_distance(tx, ty, ux, uy)
|
||||
if dist < min_r or dist > max_r:
|
||||
continue
|
||||
if needs_los and not pathfinder.client_has_los(ux, uy, tx, ty):
|
||||
continue
|
||||
results.append(t.get("instanceId", ""))
|
||||
return results
|
||||
|
||||
|
||||
## All tiles within a unit's attack range (regardless of occupancy).
|
||||
## Used to show the orange reach area for ranged units.
|
||||
## tile_bodies: "x,y" → StaticBody3D dict from GameScreen.
|
||||
func attack_range_tiles(unit: Dictionary, tile_bodies: Dictionary) -> Array:
|
||||
var results: Array = []
|
||||
var pos: Dictionary = unit.get("position", {})
|
||||
if pos.is_empty():
|
||||
return results
|
||||
var ux: int = pos.get("x", 0)
|
||||
var uy: int = pos.get("y", 0)
|
||||
var min_r: int = unit.get("minAttackRange", 1)
|
||||
var max_r: int = unit.get("maxAttackRange", 1)
|
||||
var needs_los: bool = bool(unit.get("attackRequiresLos", false))
|
||||
if max_r <= 1:
|
||||
return results # skip melee — no separate range indicator needed
|
||||
var bw: int = Game.board_width()
|
||||
var bh: int = Game.board_height()
|
||||
for tx in range(bw):
|
||||
for ty in range(bh):
|
||||
if not tile_bodies.has("%d,%d" % [tx, ty]):
|
||||
continue
|
||||
var dist: int = pathfinder.board_distance(tx, ty, ux, uy)
|
||||
if dist < min_r or dist > max_r:
|
||||
continue
|
||||
if needs_los and not pathfinder.client_has_los(ux, uy, tx, ty):
|
||||
continue
|
||||
results.append(Vector2i(tx, ty))
|
||||
return results
|
||||
|
||||
# ── Placement targets ─────────────────────────────────────────────────────────
|
||||
|
||||
## Returns valid ArchSpirit placement tiles for the local player.
|
||||
func valid_placement_tiles() -> Array:
|
||||
var results: Array = []
|
||||
var my_id: String = Auth.user_id
|
||||
var my_seat: int = int(Game.get_my_player().get("seatIndex", 0))
|
||||
var board: Dictionary = Game.get_board()
|
||||
var sz_raw: Dictionary = board.get("startingZones", {})
|
||||
|
||||
if not sz_raw.is_empty():
|
||||
# N-player: use the StartingZones dict keyed by seatIndex.
|
||||
var seat_key: String = str(my_seat)
|
||||
var zone: Array = sz_raw.get(seat_key, []) as Array
|
||||
for coord: Dictionary in zone:
|
||||
var tx: int = int(coord.get("x", -1))
|
||||
var ty: int = int(coord.get("y", -1))
|
||||
if tx >= 0 and not Game.get_tile(tx, ty).get("occupantId"):
|
||||
results.append(Vector2i(tx, ty))
|
||||
else:
|
||||
# Legacy 1v1 fallback.
|
||||
var p1_id: String = str(Game.state.get("playerOneAccountId", ""))
|
||||
var bw: int = Game.board_width()
|
||||
var bh: int = Game.board_height()
|
||||
var row: int = 0 if my_id == p1_id else bh - 1
|
||||
for tx in range(bw):
|
||||
if not Game.get_tile(tx, row).get("occupantId"):
|
||||
results.append(Vector2i(tx, row))
|
||||
return results
|
||||
|
||||
# ── Sacrifice targets ─────────────────────────────────────────────────────────
|
||||
|
||||
## Friendly spirits adjacent to own ArchSpirit (sacrifice candidates).
|
||||
func valid_sacrifice_spirits() -> Array:
|
||||
var results: Array = []
|
||||
var arch: Dictionary = Game.get_my_player().get("archSpirit", {})
|
||||
var arch_pos: Dictionary = arch.get("position", {})
|
||||
if arch_pos.is_empty():
|
||||
return results
|
||||
var ax: int = arch_pos.get("x", 0)
|
||||
var ay: int = arch_pos.get("y", 0)
|
||||
for unit: Dictionary in Game.get_field():
|
||||
if unit_registry.is_ruin_unit(unit):
|
||||
continue
|
||||
var up: Dictionary = unit.get("position", {})
|
||||
if up.is_empty():
|
||||
continue
|
||||
var ux: int = up.get("x", 0)
|
||||
var uy: int = up.get("y", 0)
|
||||
if pathfinder.board_distance(ux, uy, ax, ay) == 1:
|
||||
results.append(unit)
|
||||
return results
|
||||
@@ -0,0 +1 @@
|
||||
uid://s23snjfooow7
|
||||
@@ -0,0 +1,135 @@
|
||||
class_name CameraController
|
||||
extends Node
|
||||
|
||||
signal deactivate_touch_modes_requested()
|
||||
signal orbit_btn_toggled(pressed: bool)
|
||||
signal pan_btn_toggled(pressed: bool)
|
||||
signal zoom_btn_toggled(pressed: bool)
|
||||
|
||||
var cam_yaw: float = 0.0
|
||||
var cam_pitch: float = 40.0
|
||||
var cam_distance: float = 14.0
|
||||
var cam_target_distance: float = 14.0
|
||||
var cam_pivot: Vector3 = Vector3.ZERO
|
||||
var cam_tween: Tween = null
|
||||
var cam_zoom_tween: Tween = null
|
||||
|
||||
const CAM_MIN_DISTANCE: float = 4.0
|
||||
const CAM_MAX_DISTANCE: float = 22.0
|
||||
const CAM_ZOOM_SENSITIVITY: float = 0.4
|
||||
const CAM_ZOOM_TWEEN_SECONDS: float = 0.12
|
||||
|
||||
# Set by parent
|
||||
var camera_rig: Node3D = null
|
||||
var camera: Camera3D = null
|
||||
var cam_ctrl_panel: Control = null
|
||||
var cam_orbit_btn: Button = null
|
||||
var cam_pan_btn: Button = null
|
||||
var cam_zoom_btn: Button = null
|
||||
|
||||
|
||||
func apply_camera() -> void:
|
||||
var pitch_rad: float = deg_to_rad(cam_pitch)
|
||||
camera_rig.position = cam_pivot
|
||||
camera_rig.rotation_degrees = Vector3(0.0, cam_yaw, 0.0)
|
||||
camera.position = Vector3(0.0,
|
||||
cam_distance * sin(pitch_rad),
|
||||
cam_distance * cos(pitch_rad))
|
||||
camera.rotation_degrees = Vector3(-cam_pitch, 0.0, 0.0)
|
||||
|
||||
|
||||
func zoom(delta: float) -> void:
|
||||
if cam_zoom_tween == null or not cam_zoom_tween.is_running():
|
||||
cam_target_distance = cam_distance
|
||||
cam_target_distance = clampf(
|
||||
cam_target_distance - (delta * CAM_ZOOM_SENSITIVITY),
|
||||
CAM_MIN_DISTANCE,
|
||||
CAM_MAX_DISTANCE)
|
||||
if cam_zoom_tween != null:
|
||||
cam_zoom_tween.kill()
|
||||
cam_zoom_tween = create_tween()
|
||||
cam_zoom_tween.tween_method(
|
||||
_set_distance,
|
||||
cam_distance,
|
||||
cam_target_distance,
|
||||
CAM_ZOOM_TWEEN_SECONDS
|
||||
).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
|
||||
|
||||
|
||||
func _set_distance(distance: float) -> void:
|
||||
cam_distance = distance
|
||||
apply_camera()
|
||||
|
||||
|
||||
func sync_cam_ctrl_panel() -> void:
|
||||
cam_ctrl_panel.visible = (Settings.touch_camera_mode == "buttons")
|
||||
if Settings.touch_camera_mode != "buttons":
|
||||
deactivate_touch_modes_requested.emit()
|
||||
|
||||
|
||||
func on_cam_orbit_btn_toggled(pressed: bool) -> void:
|
||||
if pressed:
|
||||
cam_pan_btn.set_pressed_no_signal(false)
|
||||
cam_zoom_btn.set_pressed_no_signal(false)
|
||||
orbit_btn_toggled.emit(pressed)
|
||||
|
||||
|
||||
func on_cam_pan_btn_toggled(pressed: bool) -> void:
|
||||
if pressed:
|
||||
cam_orbit_btn.set_pressed_no_signal(false)
|
||||
cam_zoom_btn.set_pressed_no_signal(false)
|
||||
pan_btn_toggled.emit(pressed)
|
||||
|
||||
|
||||
func on_cam_zoom_btn_toggled(pressed: bool) -> void:
|
||||
if pressed:
|
||||
cam_orbit_btn.set_pressed_no_signal(false)
|
||||
cam_pan_btn.set_pressed_no_signal(false)
|
||||
zoom_btn_toggled.emit(pressed)
|
||||
|
||||
|
||||
func on_cam_gesture_timer_fired(gesture_finger_count: int) -> void:
|
||||
if Settings.touch_camera_mode != "gesture":
|
||||
return
|
||||
match gesture_finger_count:
|
||||
1:
|
||||
orbit_btn_toggled.emit(true)
|
||||
pan_btn_toggled.emit(false)
|
||||
zoom_btn_toggled.emit(false)
|
||||
2:
|
||||
zoom_btn_toggled.emit(true)
|
||||
orbit_btn_toggled.emit(false)
|
||||
pan_btn_toggled.emit(false)
|
||||
3:
|
||||
pan_btn_toggled.emit(true)
|
||||
orbit_btn_toggled.emit(false)
|
||||
zoom_btn_toggled.emit(false)
|
||||
|
||||
|
||||
func apply_orbit(delta: Vector2) -> void:
|
||||
cam_yaw -= delta.x * 0.4
|
||||
cam_pitch = clampf(cam_pitch + delta.y * 0.3, 15.0, 75.0)
|
||||
apply_camera()
|
||||
|
||||
|
||||
func apply_pan(delta: Vector2, cam_dist: float) -> void:
|
||||
var ps: float = cam_dist * 0.0015
|
||||
var right: Vector3 = camera_rig.global_basis.x * delta.x * ps
|
||||
var fwd: Vector3 = Vector3(camera_rig.global_basis.z.x, 0.0, -camera_rig.global_basis.z.z).normalized()
|
||||
cam_pivot += right + fwd * -delta.y * ps
|
||||
var pan_lim: float = clampf(max(float(Game.board_width()), float(Game.board_height())) * GameConstants.TILE_SPACING * 0.5, 6.0, 20.0)
|
||||
cam_pivot.x = clampf(cam_pivot.x, -pan_lim, pan_lim)
|
||||
cam_pivot.z = clampf(cam_pivot.z, -pan_lim, pan_lim)
|
||||
apply_camera()
|
||||
|
||||
|
||||
func tween_to_pivot(target: Vector3) -> void:
|
||||
if cam_tween != null:
|
||||
cam_tween.kill()
|
||||
cam_tween = create_tween()
|
||||
cam_tween.tween_method(_set_pivot, cam_pivot, target, 0.35).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
|
||||
|
||||
|
||||
func _set_pivot(pos: Vector3) -> void:
|
||||
cam_pivot = pos
|
||||
apply_camera()
|
||||
@@ -0,0 +1 @@
|
||||
uid://ciuhvyg4j67vc
|
||||
@@ -0,0 +1,328 @@
|
||||
class_name AbilityPlaceholderFx
|
||||
extends Node
|
||||
|
||||
## Plays a placeholder VFX when an Active ability fires without a custom
|
||||
## animation asset. Behaviour depends on targetMode from the server:
|
||||
##
|
||||
## "Self" — glow ring + radial burst on the source unit, no projectile
|
||||
## "Unit" — orb projectile from source unit to target unit body
|
||||
## "Tile" — orb projectile from source unit to tile centre
|
||||
## "PlayerZone" — orb projectile from source unit to target player's ArchSpirit
|
||||
## "None" — fallback self glow burst
|
||||
##
|
||||
## The source is always the activating unit, not the ArchSpirit.
|
||||
##
|
||||
## External refs (set by game_screen._ready):
|
||||
## pathfinder — for coord_to_world
|
||||
## unit_bodies — Dictionary instanceId → StaticBody3D
|
||||
## units_root — Node3D that owns the 3D board unit nodes
|
||||
|
||||
# ── External refs ─────────────────────────────────────────────────────────────
|
||||
|
||||
var pathfinder : Pathfinder = null
|
||||
var unit_bodies : Dictionary = {} # instanceId → StaticBody3D
|
||||
var units_root : Node3D = null
|
||||
|
||||
# ── Public API ────────────────────────────────────────────────────────────────
|
||||
|
||||
## Called by game_screen when Game.ability_placeholder_visual fires.
|
||||
func play(payload: Dictionary) -> void:
|
||||
var actor_id: String = str(payload.get("actorAccountId", ""))
|
||||
var source_id: String = str(payload.get("sourceInstanceId", ""))
|
||||
var affinity: String = str(payload.get("sourceAffinity", ""))
|
||||
var target_mode: String = str(payload.get("targetMode", "None"))
|
||||
var targets_raw: Variant = payload.get("targets", [])
|
||||
var targets: Array = targets_raw as Array if targets_raw is Array else []
|
||||
|
||||
var affinity_color: Color = GameConstants.AFFINITY_COLORS.get(affinity, Color(0.7, 0.55, 0.9))
|
||||
var player_color: Color = _resolve_player_color(actor_id)
|
||||
|
||||
var src_pos: Vector3 = _resolve_unit_pos(source_id)
|
||||
|
||||
match target_mode:
|
||||
"Self", "None":
|
||||
_play_self_burst(src_pos, affinity_color, player_color)
|
||||
"Unit":
|
||||
var tgt_pos: Vector3 = _resolve_unit_target(targets, src_pos)
|
||||
_spawn_projectile(src_pos, tgt_pos, affinity_color, player_color)
|
||||
"Tile":
|
||||
var tgt_pos: Vector3 = _resolve_tile_target(targets, src_pos)
|
||||
_spawn_projectile(src_pos, tgt_pos, affinity_color, player_color)
|
||||
"PlayerZone":
|
||||
var tgt_pos: Vector3 = _resolve_player_arch_target(targets, src_pos)
|
||||
_spawn_projectile(src_pos, tgt_pos, affinity_color, player_color)
|
||||
_:
|
||||
_play_self_burst(src_pos, affinity_color, player_color)
|
||||
|
||||
|
||||
# ── Position resolution ───────────────────────────────────────────────────────
|
||||
|
||||
func _resolve_unit_pos(instance_id: String) -> Vector3:
|
||||
if not instance_id.is_empty():
|
||||
var body: StaticBody3D = unit_bodies.get(instance_id) as StaticBody3D
|
||||
if is_instance_valid(body):
|
||||
return body.global_position + Vector3(0, 0.5, 0)
|
||||
return Vector3.ZERO
|
||||
|
||||
|
||||
func _resolve_unit_target(targets: Array, fallback: Vector3) -> Vector3:
|
||||
for t: Variant in targets:
|
||||
if not (t is Dictionary):
|
||||
continue
|
||||
var td: Dictionary = t as Dictionary
|
||||
var inst_id: String = str(td.get("instanceId", td.get("instance_id", "")))
|
||||
if inst_id.is_empty():
|
||||
continue
|
||||
var body: StaticBody3D = unit_bodies.get(inst_id) as StaticBody3D
|
||||
if is_instance_valid(body):
|
||||
return body.global_position + Vector3(0, 0.5, 0)
|
||||
return fallback
|
||||
|
||||
|
||||
func _resolve_tile_target(targets: Array, fallback: Vector3) -> Vector3:
|
||||
for t: Variant in targets:
|
||||
if not (t is Dictionary):
|
||||
continue
|
||||
var td: Dictionary = t as Dictionary
|
||||
var coord_v: Variant = td.get("coord")
|
||||
if coord_v is Dictionary and pathfinder != null:
|
||||
var cd: Dictionary = coord_v as Dictionary
|
||||
return pathfinder.coord_to_world(int(cd.get("x", 0)), int(cd.get("y", 0))) \
|
||||
+ Vector3(0, 0.6, 0)
|
||||
return fallback
|
||||
|
||||
|
||||
func _resolve_player_arch_target(targets: Array, fallback: Vector3) -> Vector3:
|
||||
for t: Variant in targets:
|
||||
if not (t is Dictionary):
|
||||
continue
|
||||
var td: Dictionary = t as Dictionary
|
||||
var inst_id: String = str(td.get("instanceId", td.get("instance_id", "")))
|
||||
if inst_id.is_empty():
|
||||
continue
|
||||
# Try as unit body first (server may send ArchSpirit InstanceId directly).
|
||||
var body: StaticBody3D = unit_bodies.get(inst_id) as StaticBody3D
|
||||
if is_instance_valid(body):
|
||||
return body.global_position + Vector3(0, 0.5, 0)
|
||||
# Try as account id → ArchSpirit board position.
|
||||
var pd: Dictionary = _player_by_id(inst_id)
|
||||
var arch: Dictionary = pd.get("archSpirit", {})
|
||||
var apos: Dictionary = arch.get("position", {})
|
||||
if not apos.is_empty() and pathfinder != null:
|
||||
return pathfinder.coord_to_world(
|
||||
int(apos.get("x", 0)), int(apos.get("y", 0))) + Vector3(0, 0.8, 0)
|
||||
return fallback
|
||||
|
||||
|
||||
func _resolve_player_color(actor_id: String) -> Color:
|
||||
var player: Dictionary = _player_by_id(actor_id)
|
||||
var team_idx: int = int(player.get("teamIndex", -1))
|
||||
var team_colors: Dictionary = Game.state.get("teamColors", {})
|
||||
var hex: String = str(team_colors.get(team_idx, team_colors.get(str(team_idx), "")))
|
||||
if hex.length() >= 6:
|
||||
return Color.html("#" + hex if not hex.begins_with("#") else hex)
|
||||
return Color(0.9, 0.7, 0.3)
|
||||
|
||||
|
||||
func _player_by_id(account_id: String) -> Dictionary:
|
||||
for p: Variant in Game.state.get("players", []):
|
||||
if p is Dictionary and \
|
||||
str((p as Dictionary).get("accountId", "")).to_lower() == account_id.to_lower():
|
||||
return p as Dictionary
|
||||
return {}
|
||||
|
||||
|
||||
# ── Self burst (no projectile) ────────────────────────────────────────────────
|
||||
|
||||
func _play_self_burst(pos: Vector3, affinity_color: Color, player_color: Color) -> void:
|
||||
if units_root == null:
|
||||
return
|
||||
|
||||
var burst_dur: float = randf_range(0.45, 0.65)
|
||||
|
||||
# Expanding glow ring.
|
||||
var ring: MeshInstance3D = _make_impact_ring(
|
||||
affinity_color.lerp(player_color, 0.25), pos, 0.12, 0.16)
|
||||
units_root.add_child(ring)
|
||||
|
||||
# Larger outer ring (player color accent).
|
||||
var ring2: MeshInstance3D = _make_impact_ring(
|
||||
player_color.lerp(affinity_color, 0.3), pos, 0.22, 0.28)
|
||||
units_root.add_child(ring2)
|
||||
|
||||
# Radial motes.
|
||||
var rng: RandomNumberGenerator = RandomNumberGenerator.new()
|
||||
rng.randomize()
|
||||
var burst_root: Node3D = Node3D.new()
|
||||
burst_root.name = "SelfBurst"
|
||||
burst_root.position = pos
|
||||
units_root.add_child(burst_root)
|
||||
|
||||
for i: int in range(10):
|
||||
var angle: float = TAU * float(i) / 10.0 + rng.randf_range(-0.15, 0.15)
|
||||
var speed: float = rng.randf_range(0.18, 0.42)
|
||||
var col: Color = affinity_color if i % 2 == 0 else player_color
|
||||
var mote: MeshInstance3D = _make_orb(col, rng.randf_range(0.022, 0.05))
|
||||
mote.position = Vector3.ZERO
|
||||
burst_root.add_child(mote)
|
||||
var end_pos: Vector3 = Vector3(cos(angle) * speed, rng.randf_range(0.05, 0.28), sin(angle) * speed)
|
||||
var mt: Tween = create_tween()
|
||||
mt.set_parallel(true)
|
||||
mt.tween_property(mote, "position", end_pos, burst_dur)\
|
||||
.set_trans(Tween.TRANS_EXPO).set_ease(Tween.EASE_OUT)
|
||||
mt.tween_property(mote, "scale", Vector3.ZERO, burst_dur)\
|
||||
.set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN)
|
||||
|
||||
# Animate rings outward and fade.
|
||||
for ring_node: MeshInstance3D in [ring, ring2]:
|
||||
var rt: Tween = create_tween()
|
||||
rt.set_parallel(true)
|
||||
rt.tween_property(ring_node, "scale", Vector3.ONE * 2.8, burst_dur)\
|
||||
.set_trans(Tween.TRANS_EXPO).set_ease(Tween.EASE_OUT)
|
||||
var rmat: StandardMaterial3D = ring_node.material_override as StandardMaterial3D
|
||||
if rmat != null:
|
||||
rt.tween_method(func(a: float) -> void: rmat.albedo_color.a = a,
|
||||
0.75, 0.0, burst_dur)
|
||||
|
||||
# Cleanup.
|
||||
var cleanup: float = burst_dur + 0.3
|
||||
get_tree().create_timer(cleanup).timeout.connect(func() -> void:
|
||||
if is_instance_valid(ring): ring.queue_free()
|
||||
if is_instance_valid(ring2): ring2.queue_free()
|
||||
if is_instance_valid(burst_root): burst_root.queue_free())
|
||||
|
||||
|
||||
# ── Projectile (non-self targets) ─────────────────────────────────────────────
|
||||
|
||||
func _spawn_projectile(
|
||||
src: Vector3, tgt: Vector3,
|
||||
affinity_color: Color, player_color: Color) -> void:
|
||||
|
||||
if units_root == null:
|
||||
return
|
||||
|
||||
var dist: float = src.distance_to(tgt)
|
||||
var travel_dur: float = clampf(dist * 0.18, 0.35, 0.8)
|
||||
|
||||
var root: Node3D = Node3D.new()
|
||||
root.name = "AbilityPlaceholderFx"
|
||||
root.position = src
|
||||
units_root.add_child(root)
|
||||
|
||||
# Core orb (affinity color).
|
||||
root.add_child(_make_orb(affinity_color, 0.09))
|
||||
# Inner spark (player color).
|
||||
root.add_child(_make_orb(player_color, 0.045))
|
||||
|
||||
# Four trailing motes orbiting the orb.
|
||||
for i: int in range(4):
|
||||
var angle: float = TAU * float(i) / 4.0
|
||||
var offset: Vector3 = Vector3(cos(angle) * 0.06, 0.0, sin(angle) * 0.06)
|
||||
var mote: MeshInstance3D = _make_orb(player_color.lerp(affinity_color, 0.4), 0.028)
|
||||
mote.position = offset
|
||||
root.add_child(mote)
|
||||
|
||||
var tween: Tween = create_tween()
|
||||
tween.tween_property(root, "position", tgt, travel_dur)\
|
||||
.set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN)
|
||||
tween.tween_callback(func() -> void: _play_impact(root, tgt, affinity_color, player_color))
|
||||
|
||||
|
||||
func _play_impact(
|
||||
projectile: Node3D, pos: Vector3,
|
||||
affinity_color: Color, player_color: Color) -> void:
|
||||
|
||||
if is_instance_valid(projectile):
|
||||
projectile.queue_free()
|
||||
|
||||
if units_root == null:
|
||||
return
|
||||
|
||||
var impact_dur: float = randf_range(0.5, 0.8)
|
||||
|
||||
var ring: MeshInstance3D = _make_impact_ring(
|
||||
affinity_color.lerp(player_color, 0.35), pos, 0.18, 0.22)
|
||||
units_root.add_child(ring)
|
||||
|
||||
var rng: RandomNumberGenerator = RandomNumberGenerator.new()
|
||||
rng.randomize()
|
||||
var burst_root: Node3D = Node3D.new()
|
||||
burst_root.name = "ImpactBurst"
|
||||
burst_root.position = pos
|
||||
units_root.add_child(burst_root)
|
||||
|
||||
for i: int in range(8):
|
||||
var angle: float = TAU * float(i) / 8.0 + rng.randf_range(-0.2, 0.2)
|
||||
var speed: float = rng.randf_range(0.28, 0.56)
|
||||
var col: Color = affinity_color if i % 2 == 0 else player_color
|
||||
var mote: MeshInstance3D = _make_orb(col, rng.randf_range(0.024, 0.055))
|
||||
mote.position = Vector3.ZERO
|
||||
burst_root.add_child(mote)
|
||||
var end_pos: Vector3 = Vector3(
|
||||
cos(angle) * speed, rng.randf_range(0.0, 0.3), sin(angle) * speed)
|
||||
var mt: Tween = create_tween()
|
||||
mt.set_parallel(true)
|
||||
mt.tween_property(mote, "position", end_pos, impact_dur)\
|
||||
.set_trans(Tween.TRANS_EXPO).set_ease(Tween.EASE_OUT)
|
||||
mt.tween_property(mote, "scale", Vector3.ZERO, impact_dur)\
|
||||
.set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN)
|
||||
|
||||
var rt: Tween = create_tween()
|
||||
rt.set_parallel(true)
|
||||
rt.tween_property(ring, "scale", Vector3.ONE * 2.4, impact_dur)\
|
||||
.set_trans(Tween.TRANS_EXPO).set_ease(Tween.EASE_OUT)
|
||||
var ring_mat: StandardMaterial3D = ring.material_override as StandardMaterial3D
|
||||
if ring_mat != null:
|
||||
rt.tween_method(func(a: float) -> void: ring_mat.albedo_color.a = a,
|
||||
0.75, 0.0, impact_dur)
|
||||
|
||||
var cleanup: float = impact_dur + 0.4
|
||||
get_tree().create_timer(cleanup).timeout.connect(func() -> void:
|
||||
if is_instance_valid(ring): ring.queue_free()
|
||||
if is_instance_valid(burst_root): burst_root.queue_free())
|
||||
|
||||
|
||||
# ── Mesh helpers ──────────────────────────────────────────────────────────────
|
||||
|
||||
func _make_orb(color: Color, radius: float) -> MeshInstance3D:
|
||||
var mi: MeshInstance3D = MeshInstance3D.new()
|
||||
var mesh: SphereMesh = SphereMesh.new()
|
||||
mesh.radius = radius
|
||||
mesh.height = radius * 2.0
|
||||
mesh.radial_segments = 10
|
||||
mesh.rings = 5
|
||||
mi.mesh = mesh
|
||||
var mat: StandardMaterial3D = StandardMaterial3D.new()
|
||||
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
mat.albedo_color = Color(color.r, color.g, color.b, 0.85)
|
||||
mat.emission_enabled = true
|
||||
mat.emission = color
|
||||
mat.emission_energy_multiplier = 2.8
|
||||
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
mat.cull_mode = BaseMaterial3D.CULL_DISABLED
|
||||
mi.material_override = mat
|
||||
return mi
|
||||
|
||||
|
||||
func _make_impact_ring(
|
||||
color: Color, world_pos: Vector3,
|
||||
inner: float, outer: float) -> MeshInstance3D:
|
||||
var mi: MeshInstance3D = MeshInstance3D.new()
|
||||
var mesh: TorusMesh = TorusMesh.new()
|
||||
mesh.inner_radius = inner
|
||||
mesh.outer_radius = outer
|
||||
mesh.rings = 16
|
||||
mesh.ring_segments = 8
|
||||
mi.mesh = mesh
|
||||
mi.position = world_pos
|
||||
mi.rotation_degrees.x = 90.0
|
||||
var mat: StandardMaterial3D = StandardMaterial3D.new()
|
||||
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
mat.albedo_color = Color(color.r, color.g, color.b, 0.75)
|
||||
mat.emission_enabled = true
|
||||
mat.emission = color
|
||||
mat.emission_energy_multiplier = 1.8
|
||||
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
mat.cull_mode = BaseMaterial3D.CULL_DISABLED
|
||||
mi.material_override = mat
|
||||
return mi
|
||||
@@ -0,0 +1 @@
|
||||
uid://d4bnvq4ulqph8
|
||||
@@ -0,0 +1,257 @@
|
||||
class_name RepentancePlaceholderFx
|
||||
extends Node
|
||||
|
||||
## Plays a placeholder projectile VFX when a Repentance card resolves without
|
||||
## a custom animation asset. Spawns a glowing orb that travels from the acting
|
||||
## player's ArchSpirit to the resolved target, then bursts into an impact ring.
|
||||
##
|
||||
## External refs (set by game_screen._ready):
|
||||
## pathfinder — for coord_to_world and board_distance
|
||||
## unit_bodies — Dictionary instanceId → StaticBody3D
|
||||
## units_root — Node3D that owns the 3D board unit nodes
|
||||
|
||||
# ── External refs ─────────────────────────────────────────────────────────────
|
||||
|
||||
var pathfinder : Pathfinder = null
|
||||
var unit_bodies : Dictionary = {} # instanceId → StaticBody3D
|
||||
var units_root : Node3D = null
|
||||
|
||||
# ── Public API ────────────────────────────────────────────────────────────────
|
||||
|
||||
## Called by game_screen when Game.repentance_placeholder_visual fires.
|
||||
func play(payload: Dictionary) -> void:
|
||||
var actor_id: String = str(payload.get("actorAccountId", ""))
|
||||
var arch_id: String = str(payload.get("sourceArchSpiritInstanceId", ""))
|
||||
var affinity: String = str(payload.get("affinity", ""))
|
||||
var targets_raw: Variant = payload.get("targets", [])
|
||||
var targets: Array = targets_raw as Array if targets_raw is Array else []
|
||||
|
||||
var src_pos: Vector3 = _resolve_arch_spirit_pos(arch_id, actor_id)
|
||||
var tgt_pos: Vector3 = _resolve_target_pos(targets, actor_id, src_pos)
|
||||
|
||||
var affinity_color: Color = GameConstants.AFFINITY_COLORS.get(affinity, Color(0.7, 0.55, 0.9))
|
||||
var player_color: Color = _resolve_player_color(actor_id)
|
||||
|
||||
_spawn_projectile(src_pos, tgt_pos, affinity_color, player_color)
|
||||
|
||||
|
||||
# ── Position resolution ───────────────────────────────────────────────────────
|
||||
|
||||
func _resolve_arch_spirit_pos(arch_instance_id: String, actor_id: String) -> Vector3:
|
||||
if not arch_instance_id.is_empty():
|
||||
var body: StaticBody3D = unit_bodies.get(arch_instance_id) as StaticBody3D
|
||||
if is_instance_valid(body):
|
||||
return body.global_position + Vector3(0, 0.5, 0)
|
||||
|
||||
# Fallback: resolve the actor's ArchSpirit from game state (works for
|
||||
# opponent casts, spectators, and timing gaps during mesh rebuilds).
|
||||
var actor_player: Dictionary = _player_by_id(actor_id)
|
||||
var arch: Dictionary = actor_player.get("archSpirit", {})
|
||||
var pos: Dictionary = arch.get("position", {})
|
||||
if not pos.is_empty() and pathfinder != null:
|
||||
return pathfinder.coord_to_world(int(pos.get("x", 0)), int(pos.get("y", 0))) + Vector3(0, 0.8, 0)
|
||||
|
||||
return Vector3.ZERO
|
||||
|
||||
|
||||
func _resolve_target_pos(targets: Array, actor_id: String, fallback: Vector3) -> Vector3:
|
||||
# 1. Unit instance id → current board body position.
|
||||
for t: Variant in targets:
|
||||
if not (t is Dictionary):
|
||||
continue
|
||||
var td: Dictionary = t as Dictionary
|
||||
var inst_id: String = str(td.get("instanceId", td.get("instance_id", "")))
|
||||
if inst_id.is_empty():
|
||||
continue
|
||||
var body: StaticBody3D = unit_bodies.get(inst_id) as StaticBody3D
|
||||
if is_instance_valid(body):
|
||||
return body.global_position + Vector3(0, 0.5, 0)
|
||||
|
||||
# 2. Tile coordinate.
|
||||
for t: Variant in targets:
|
||||
if not (t is Dictionary):
|
||||
continue
|
||||
var td: Dictionary = t as Dictionary
|
||||
var coord_v: Variant = td.get("coord")
|
||||
if coord_v is Dictionary and pathfinder != null:
|
||||
var cd: Dictionary = coord_v as Dictionary
|
||||
return pathfinder.coord_to_world(int(cd.get("x", 0)), int(cd.get("y", 0))) + Vector3(0, 0.6, 0)
|
||||
|
||||
# 3. Player ArchSpirit (target player given by instanceId = accountId in player-target actions).
|
||||
for t: Variant in targets:
|
||||
if not (t is Dictionary):
|
||||
continue
|
||||
var td: Dictionary = t as Dictionary
|
||||
var inst_id: String = str(td.get("instanceId", td.get("instance_id", "")))
|
||||
if inst_id.is_empty():
|
||||
continue
|
||||
# Try it as an account id and look up that player's ArchSpirit position.
|
||||
var pd: Dictionary = _player_by_id(inst_id)
|
||||
var arch: Dictionary = pd.get("archSpirit", {})
|
||||
var apos: Dictionary = arch.get("position", {})
|
||||
if not apos.is_empty() and pathfinder != null:
|
||||
return pathfinder.coord_to_world(
|
||||
int(apos.get("x", 0)), int(apos.get("y", 0))) + Vector3(0, 0.8, 0)
|
||||
|
||||
# 4. Fallback to source.
|
||||
return fallback
|
||||
|
||||
|
||||
func _resolve_player_color(actor_id: String) -> Color:
|
||||
# Use the teamIndex on the player DTO — it is always set correctly for FFA,
|
||||
# Teams, and MultiTeam modes and directly keys into teamColors.
|
||||
var player: Dictionary = _player_by_id(actor_id)
|
||||
var team_idx: int = int(player.get("teamIndex", -1))
|
||||
var team_colors: Dictionary = Game.state.get("teamColors", {})
|
||||
var hex: String = str(team_colors.get(team_idx, team_colors.get(str(team_idx), "")))
|
||||
if hex.length() >= 6:
|
||||
return Color.html("#" + hex if not hex.begins_with("#") else hex)
|
||||
return Color(0.9, 0.7, 0.3)
|
||||
|
||||
|
||||
func _player_by_id(account_id: String) -> Dictionary:
|
||||
for p: Variant in Game.state.get("players", []):
|
||||
if p is Dictionary and str((p as Dictionary).get("accountId", "")).to_lower() == account_id.to_lower():
|
||||
return p as Dictionary
|
||||
return {}
|
||||
|
||||
|
||||
# ── Projectile spawning ───────────────────────────────────────────────────────
|
||||
|
||||
func _spawn_projectile(
|
||||
src: Vector3, tgt: Vector3,
|
||||
affinity_color: Color, player_color: Color) -> void:
|
||||
|
||||
if units_root == null:
|
||||
return
|
||||
|
||||
var dist: float = src.distance_to(tgt)
|
||||
var travel_dur: float = clampf(dist * 0.18, 0.35, 0.8)
|
||||
|
||||
var root: Node3D = Node3D.new()
|
||||
root.name = "RepentancePlaceholderFx"
|
||||
root.position = src
|
||||
units_root.add_child(root)
|
||||
|
||||
# Core orb (affinity color).
|
||||
var orb: MeshInstance3D = _make_orb(affinity_color, 0.09)
|
||||
root.add_child(orb)
|
||||
|
||||
# Inner spark (player color).
|
||||
var spark: MeshInstance3D = _make_orb(player_color, 0.045)
|
||||
root.add_child(spark)
|
||||
|
||||
# Trail motes orbiting the orb.
|
||||
for i: int in range(4):
|
||||
var angle: float = TAU * float(i) / 4.0
|
||||
var offset: Vector3 = Vector3(cos(angle) * 0.06, 0.0, sin(angle) * 0.06)
|
||||
var mote: MeshInstance3D = _make_orb(player_color.lerp(affinity_color, 0.4), 0.028)
|
||||
mote.position = offset
|
||||
root.add_child(mote)
|
||||
|
||||
# Travel tween.
|
||||
var tween: Tween = create_tween()
|
||||
tween.tween_property(root, "position", tgt, travel_dur)\
|
||||
.set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN)
|
||||
tween.tween_callback(func() -> void: _play_impact(root, tgt, affinity_color, player_color))
|
||||
|
||||
|
||||
func _play_impact(
|
||||
projectile: Node3D, pos: Vector3,
|
||||
affinity_color: Color, player_color: Color) -> void:
|
||||
|
||||
if is_instance_valid(projectile):
|
||||
projectile.queue_free()
|
||||
|
||||
if units_root == null:
|
||||
return
|
||||
|
||||
var impact_dur: float = randf_range(0.5, 0.8)
|
||||
|
||||
# Ring.
|
||||
var ring: MeshInstance3D = _make_impact_ring(
|
||||
affinity_color.lerp(player_color, 0.35), pos)
|
||||
units_root.add_child(ring)
|
||||
|
||||
# Burst motes.
|
||||
var rng: RandomNumberGenerator = RandomNumberGenerator.new()
|
||||
rng.randomize()
|
||||
var burst_root: Node3D = Node3D.new()
|
||||
burst_root.name = "ImpactBurst"
|
||||
burst_root.position = pos
|
||||
units_root.add_child(burst_root)
|
||||
|
||||
for i: int in range(8):
|
||||
var angle: float = TAU * float(i) / 8.0 + rng.randf_range(-0.2, 0.2)
|
||||
var speed: float = rng.randf_range(0.28, 0.56)
|
||||
var col: Color = affinity_color if i % 2 == 0 else player_color
|
||||
var mote: MeshInstance3D = _make_orb(col, rng.randf_range(0.024, 0.055))
|
||||
mote.position = Vector3.ZERO
|
||||
burst_root.add_child(mote)
|
||||
var end_pos: Vector3 = Vector3(cos(angle) * speed, rng.randf_range(0.0, 0.3), sin(angle) * speed)
|
||||
var mt: Tween = create_tween()
|
||||
mt.set_parallel(true)
|
||||
mt.tween_property(mote, "position", end_pos, impact_dur)\
|
||||
.set_trans(Tween.TRANS_EXPO).set_ease(Tween.EASE_OUT)
|
||||
mt.tween_property(mote, "scale", Vector3.ZERO, impact_dur)\
|
||||
.set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN)
|
||||
|
||||
# Ring scale + fade.
|
||||
var rt: Tween = create_tween()
|
||||
rt.set_parallel(true)
|
||||
rt.tween_property(ring, "scale", Vector3.ONE * 2.4, impact_dur)\
|
||||
.set_trans(Tween.TRANS_EXPO).set_ease(Tween.EASE_OUT)
|
||||
var ring_mat: StandardMaterial3D = ring.material_override as StandardMaterial3D
|
||||
if ring_mat != null:
|
||||
rt.tween_method(func(a: float) -> void:
|
||||
ring_mat.albedo_color.a = a, 0.75, 0.0, impact_dur)
|
||||
|
||||
# Cleanup.
|
||||
var cleanup_delay: float = impact_dur + 0.4
|
||||
get_tree().create_timer(cleanup_delay).timeout.connect(func() -> void:
|
||||
if is_instance_valid(ring): ring.queue_free()
|
||||
if is_instance_valid(burst_root): burst_root.queue_free())
|
||||
|
||||
|
||||
# ── Mesh helpers ──────────────────────────────────────────────────────────────
|
||||
|
||||
func _make_orb(color: Color, radius: float) -> MeshInstance3D:
|
||||
var mi: MeshInstance3D = MeshInstance3D.new()
|
||||
var mesh: SphereMesh = SphereMesh.new()
|
||||
mesh.radius = radius
|
||||
mesh.height = radius * 2.0
|
||||
mesh.radial_segments = 10
|
||||
mesh.rings = 5
|
||||
mi.mesh = mesh
|
||||
var mat: StandardMaterial3D = StandardMaterial3D.new()
|
||||
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
mat.albedo_color = Color(color.r, color.g, color.b, 0.85)
|
||||
mat.emission_enabled = true
|
||||
mat.emission = color
|
||||
mat.emission_energy_multiplier = 2.8
|
||||
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
mat.cull_mode = BaseMaterial3D.CULL_DISABLED
|
||||
mi.material_override = mat
|
||||
return mi
|
||||
|
||||
|
||||
func _make_impact_ring(color: Color, world_pos: Vector3) -> MeshInstance3D:
|
||||
var mi: MeshInstance3D = MeshInstance3D.new()
|
||||
var mesh: TorusMesh = TorusMesh.new()
|
||||
mesh.inner_radius = 0.18
|
||||
mesh.outer_radius = 0.22
|
||||
mesh.rings = 16
|
||||
mesh.ring_segments = 8
|
||||
mi.mesh = mesh
|
||||
mi.position = world_pos
|
||||
mi.rotation_degrees.x = 90.0
|
||||
var mat: StandardMaterial3D = StandardMaterial3D.new()
|
||||
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
mat.albedo_color = Color(color.r, color.g, color.b, 0.75)
|
||||
mat.emission_enabled = true
|
||||
mat.emission = color
|
||||
mat.emission_energy_multiplier = 1.8
|
||||
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
mat.cull_mode = BaseMaterial3D.CULL_DISABLED
|
||||
mi.material_override = mat
|
||||
return mi
|
||||
@@ -0,0 +1 @@
|
||||
uid://caefv6gdfthxp
|
||||
@@ -0,0 +1,438 @@
|
||||
class_name SkyboxController
|
||||
extends Node
|
||||
|
||||
## Manages all skybox modes: procedural, CDN panoramic/animated, cubemap,
|
||||
## and the live activity-feed star field.
|
||||
##
|
||||
## Call setup_environment() from game_screen._ready().
|
||||
## Call process_sky_rotation(delta) from game_screen._process(delta).
|
||||
## Call cleanup() from game_screen._exit_tree().
|
||||
|
||||
var skybox_sky: Sky = null
|
||||
var skybox_frames: Array = []
|
||||
var skybox_frame_idx: int = 0
|
||||
var skybox_timer: Timer = null
|
||||
var stars: Dictionary = {}
|
||||
var ambient_star_timer: Timer = null
|
||||
var ambient_star_ctr: int = 0
|
||||
|
||||
# Set by parent before setup_environment() is called.
|
||||
var world_environment: WorldEnvironment = null
|
||||
|
||||
# ── Setup ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
func setup_environment() -> void:
|
||||
var env: Environment = Environment.new()
|
||||
skybox_sky = Sky.new()
|
||||
env.background_mode = Environment.BG_SKY
|
||||
env.sky = skybox_sky
|
||||
env.ambient_light_source = Environment.AMBIENT_SOURCE_SKY
|
||||
world_environment.environment = env
|
||||
|
||||
match Settings.skybox_mode:
|
||||
"live":
|
||||
setup_live_skybox(env)
|
||||
"cdn":
|
||||
setup_procedural_sky(env)
|
||||
apply_skybox_from_cache()
|
||||
_:
|
||||
setup_procedural_sky(env)
|
||||
|
||||
if not Settings.settings_changed.is_connected(on_skybox_setting_changed):
|
||||
Settings.settings_changed.connect(on_skybox_setting_changed)
|
||||
|
||||
|
||||
## Dark blue procedural sky — shown for "off" mode and as CDN loading placeholder.
|
||||
func setup_procedural_sky(env: Environment = null) -> void:
|
||||
if skybox_timer != null:
|
||||
skybox_timer.queue_free()
|
||||
skybox_timer = null
|
||||
skybox_frames.clear()
|
||||
var proc: ProceduralSkyMaterial = ProceduralSkyMaterial.new()
|
||||
proc.sky_top_color = Color(0.08, 0.10, 0.20)
|
||||
proc.sky_horizon_color = Color(0.28, 0.38, 0.55)
|
||||
proc.ground_bottom_color = Color(0.373, 0.374, 0.484, 1.0)
|
||||
proc.ground_horizon_color = Color(0.20, 0.28, 0.38)
|
||||
if is_instance_valid(skybox_sky):
|
||||
skybox_sky.sky_material = proc
|
||||
var e: Environment = env if env != null else world_environment.environment
|
||||
if e != null:
|
||||
e.ambient_light_energy = 0.6
|
||||
|
||||
|
||||
## Near-black star sky — shown for "live" mode.
|
||||
func setup_live_skybox(env: Environment) -> void:
|
||||
clear_stars()
|
||||
var proc: ProceduralSkyMaterial = ProceduralSkyMaterial.new()
|
||||
proc.sky_top_color = Color(0.0, 0.0, 0.02)
|
||||
proc.sky_horizon_color = Color(0.01, 0.0, 0.03)
|
||||
proc.ground_bottom_color = Color(0.0, 0.0, 0.01)
|
||||
proc.ground_horizon_color = Color(0.01, 0.01, 0.02)
|
||||
if is_instance_valid(skybox_sky):
|
||||
skybox_sky.sky_material = proc
|
||||
env.ambient_light_energy = 0.25
|
||||
|
||||
if not Game.game_activity.is_connected(on_game_activity):
|
||||
Game.game_activity.connect(on_game_activity)
|
||||
|
||||
Network.request("game.subscribe_activity", {},
|
||||
func(_type: String, resp: Variant) -> void:
|
||||
var ids: Array = (resp as Dictionary).get("activeSessionIds", [])
|
||||
for sid: Variant in ids:
|
||||
add_star(str(sid), true),
|
||||
func(code: String, msg: String) -> void:
|
||||
push_warning("[SkyboxController] subscribe_activity failed — %s: %s" % [code, msg]))
|
||||
|
||||
start_ambient_star_cycle()
|
||||
|
||||
|
||||
func on_skybox_setting_changed() -> void:
|
||||
if Game.game_activity.is_connected(on_game_activity):
|
||||
Game.game_activity.disconnect(on_game_activity)
|
||||
clear_stars()
|
||||
if ambient_star_timer != null and is_instance_valid(ambient_star_timer):
|
||||
ambient_star_timer.queue_free()
|
||||
ambient_star_timer = null
|
||||
if skybox_timer != null:
|
||||
skybox_timer.queue_free()
|
||||
skybox_timer = null
|
||||
skybox_frames.clear()
|
||||
|
||||
var env: Environment = world_environment.environment as Environment
|
||||
match Settings.skybox_mode:
|
||||
"live":
|
||||
setup_live_skybox(env)
|
||||
"cdn":
|
||||
setup_procedural_sky()
|
||||
apply_skybox_from_cache()
|
||||
_:
|
||||
setup_procedural_sky()
|
||||
|
||||
|
||||
func on_game_activity(event_type: String, session_id: String) -> void:
|
||||
match event_type:
|
||||
"started": add_star(session_id, false)
|
||||
"ended": remove_star(session_id)
|
||||
|
||||
# ── Ambient star cycle ────────────────────────────────────────────────────────
|
||||
|
||||
func start_ambient_star_cycle() -> void:
|
||||
if ambient_star_timer != null and is_instance_valid(ambient_star_timer):
|
||||
ambient_star_timer.queue_free()
|
||||
ambient_star_timer = Timer.new()
|
||||
ambient_star_timer.wait_time = randf_range(2.5, 5.0)
|
||||
ambient_star_timer.one_shot = true
|
||||
add_child(ambient_star_timer)
|
||||
ambient_star_timer.timeout.connect(on_ambient_star_timer)
|
||||
ambient_star_timer.start()
|
||||
|
||||
|
||||
func on_ambient_star_timer() -> void:
|
||||
var fake_id: String = "~ambient~%d" % ambient_star_ctr
|
||||
ambient_star_ctr += 1
|
||||
add_star(fake_id, false)
|
||||
get_tree().create_timer(randf_range(15.0, 30.0)).timeout.connect(
|
||||
func() -> void: remove_star(fake_id))
|
||||
start_ambient_star_cycle()
|
||||
|
||||
# ── Star helpers ──────────────────────────────────────────────────────────────
|
||||
|
||||
func session_star_pos(session_id: String) -> Vector3:
|
||||
var rng: RandomNumberGenerator = RandomNumberGenerator.new()
|
||||
rng.seed = session_id.hash()
|
||||
var theta: float = rng.randf() * TAU
|
||||
var phi: float = rng.randf_range(0.15, 0.85) * PI
|
||||
var r: float = 280.0
|
||||
return Vector3(r * sin(phi) * cos(theta), r * cos(phi), r * sin(phi) * sin(theta))
|
||||
|
||||
|
||||
func add_star(session_id: String, instant: bool) -> void:
|
||||
if stars.has(session_id):
|
||||
return
|
||||
var mesh: MeshInstance3D = MeshInstance3D.new()
|
||||
var sphere: SphereMesh = SphereMesh.new()
|
||||
sphere.radius = 0.6
|
||||
sphere.height = 1.2
|
||||
sphere.radial_segments = 6
|
||||
sphere.rings = 4
|
||||
mesh.mesh = sphere
|
||||
var mat: StandardMaterial3D = StandardMaterial3D.new()
|
||||
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
mat.emission_enabled = true
|
||||
mat.emission = Color(0.85, 0.90, 1.0)
|
||||
mat.emission_energy_multiplier = 0.0
|
||||
mesh.material_override = mat
|
||||
mesh.global_position = session_star_pos(session_id)
|
||||
add_child(mesh)
|
||||
stars[session_id] = mesh
|
||||
|
||||
if instant:
|
||||
mat.emission_energy_multiplier = 1.0
|
||||
start_star_twinkle(mesh)
|
||||
else:
|
||||
var tw: Tween = create_tween()
|
||||
tw.tween_property(mat, "emission_energy_multiplier", 1.0, 2.0) \
|
||||
.set_trans(Tween.TRANS_CUBIC)
|
||||
tw.finished.connect(func() -> void: start_star_twinkle(mesh))
|
||||
|
||||
|
||||
func start_star_twinkle(mesh: MeshInstance3D) -> void:
|
||||
if not is_instance_valid(mesh):
|
||||
return
|
||||
var mat: StandardMaterial3D = mesh.material_override as StandardMaterial3D
|
||||
var rng: RandomNumberGenerator = RandomNumberGenerator.new()
|
||||
rng.seed = hash(mesh.global_position.x)
|
||||
var period: float = rng.randf_range(2.0, 5.5)
|
||||
var tw: Tween = create_tween().set_loops()
|
||||
tw.tween_property(mat, "emission_energy_multiplier", 1.6, period * 0.5) \
|
||||
.set_trans(Tween.TRANS_SINE)
|
||||
tw.tween_property(mat, "emission_energy_multiplier", 0.6, period * 0.5) \
|
||||
.set_trans(Tween.TRANS_SINE)
|
||||
|
||||
|
||||
func remove_star(session_id: String) -> void:
|
||||
if not stars.has(session_id):
|
||||
return
|
||||
var mesh: MeshInstance3D = stars[session_id]
|
||||
stars.erase(session_id)
|
||||
var mat: StandardMaterial3D = mesh.material_override as StandardMaterial3D
|
||||
var tw: Tween = create_tween()
|
||||
tw.tween_property(mat, "emission_energy_multiplier", 12.0, 0.12)
|
||||
tw.tween_property(mat, "emission_energy_multiplier", 0.0, 1.8) \
|
||||
.set_trans(Tween.TRANS_EXPO)
|
||||
tw.finished.connect(mesh.queue_free)
|
||||
|
||||
|
||||
func clear_stars() -> void:
|
||||
for mesh: Variant in stars.values():
|
||||
if is_instance_valid(mesh):
|
||||
(mesh as MeshInstance3D).queue_free()
|
||||
stars.clear()
|
||||
|
||||
# ── CDN skybox ────────────────────────────────────────────────────────────────
|
||||
|
||||
func apply_skybox_from_cache() -> void:
|
||||
var skybox: Dictionary = ContentCache.get_random_skybox()
|
||||
if skybox.is_empty():
|
||||
print("[SkyboxController] No active skybox — keeping procedural sky.")
|
||||
return
|
||||
var sky_type: String = str(skybox.get("type", "Panoramic"))
|
||||
print("[SkyboxController] Applying skybox type=%s" % sky_type)
|
||||
if sky_type == "Cubemap":
|
||||
load_cubemap_skybox(skybox)
|
||||
elif bool(skybox.get("isAnimated", false)) or sky_type == "AnimatedPanorama":
|
||||
load_animated_skybox(
|
||||
str(skybox.get("cdnPath", "")),
|
||||
int(skybox.get("frameCount", 1)),
|
||||
float(skybox.get("fps", 24.0)))
|
||||
else:
|
||||
load_static_skybox(str(skybox.get("cdnPath", "")))
|
||||
|
||||
|
||||
func load_cubemap_skybox(skybox: Dictionary) -> void:
|
||||
var urls: Array = [
|
||||
str(skybox.get("cubePxUrl", "")),
|
||||
str(skybox.get("cubeNxUrl", "")),
|
||||
str(skybox.get("cubePyUrl", "")),
|
||||
str(skybox.get("cubeNyUrl", "")),
|
||||
str(skybox.get("cubePzUrl", "")),
|
||||
str(skybox.get("cubeNzUrl", "")),
|
||||
]
|
||||
var images: Array = []
|
||||
images.resize(6)
|
||||
var pending: Array = [6]
|
||||
for i: int in 6:
|
||||
var idx: int = i
|
||||
var url: String = urls[idx]
|
||||
if url.is_empty():
|
||||
images[idx] = null
|
||||
pending[0] -= 1
|
||||
if pending[0] == 0:
|
||||
apply_cubemap_images(images)
|
||||
continue
|
||||
var http: HTTPRequest = HTTPRequest.new()
|
||||
add_child(http)
|
||||
http.request_completed.connect(func(_res: int, code: int, _hdrs: PackedStringArray, data: PackedByteArray) -> void:
|
||||
http.queue_free()
|
||||
if code >= 200 and code < 300 and not data.is_empty():
|
||||
var img: Image = Image.new()
|
||||
var ext: String = url.split("?")[0].get_extension().to_lower()
|
||||
var load_err: Error
|
||||
if ext in ["jpg", "jpeg"]:
|
||||
load_err = img.load_jpg_from_buffer(data)
|
||||
elif ext == "webp":
|
||||
load_err = img.load_webp_from_buffer(data)
|
||||
else:
|
||||
load_err = img.load_png_from_buffer(data)
|
||||
if load_err == OK:
|
||||
images[idx] = img
|
||||
else:
|
||||
push_warning("[SkyboxController] Cubemap face %d decode failed (ext=%s)" % [idx, ext])
|
||||
images[idx] = null
|
||||
else:
|
||||
push_warning("[SkyboxController] Cubemap face %d download failed: HTTP %d" % [idx, code])
|
||||
images[idx] = null
|
||||
pending[0] -= 1
|
||||
if pending[0] == 0:
|
||||
apply_cubemap_images.call_deferred(images))
|
||||
http.request(url)
|
||||
|
||||
|
||||
func apply_cubemap_images(raw: Array) -> void:
|
||||
var images: Array[Image] = []
|
||||
images.resize(6)
|
||||
var face_size: int = 1
|
||||
for i: int in 6:
|
||||
if raw[i] is Image:
|
||||
face_size = (raw[i] as Image).get_width()
|
||||
break
|
||||
for i: int in 6:
|
||||
if raw[i] is Image:
|
||||
var img: Image = raw[i] as Image
|
||||
if img.get_width() != face_size or img.get_height() != face_size:
|
||||
img.resize(face_size, face_size, Image.INTERPOLATE_LANCZOS)
|
||||
img.convert(Image.FORMAT_RGB8)
|
||||
images[i] = img
|
||||
else:
|
||||
var placeholder: Image = Image.create(face_size, face_size, false, Image.FORMAT_RGB8)
|
||||
placeholder.fill(Color.BLACK)
|
||||
images[i] = placeholder
|
||||
var cubemap: Cubemap = Cubemap.new()
|
||||
var err: Error = cubemap.create_from_images(images)
|
||||
if err != OK:
|
||||
push_warning("[SkyboxController] Cubemap.create_from_images failed: %d" % err)
|
||||
return
|
||||
apply_cubemap_material(cubemap)
|
||||
|
||||
|
||||
func apply_cubemap_material(cubemap: Cubemap) -> void:
|
||||
var shader: Shader = Shader.new()
|
||||
shader.code = """
|
||||
shader_type sky;
|
||||
uniform samplerCube environment : filter_linear, repeat_disable;
|
||||
void sky() { COLOR = texture(environment, EYEDIR).rgb; }
|
||||
"""
|
||||
var mat: ShaderMaterial = ShaderMaterial.new()
|
||||
mat.shader = shader
|
||||
mat.set_shader_parameter("environment", cubemap)
|
||||
var new_sky: Sky = Sky.new()
|
||||
new_sky.sky_material = mat
|
||||
skybox_sky = new_sky
|
||||
world_environment.environment.sky = new_sky
|
||||
world_environment.environment.background_mode = Environment.BG_SKY
|
||||
print("[SkyboxController] Cubemap sky applied.")
|
||||
|
||||
|
||||
func load_static_skybox(url: String) -> void:
|
||||
var http: HTTPRequest = HTTPRequest.new()
|
||||
add_child(http)
|
||||
http.request_completed.connect(
|
||||
func(_result: int, code: int, _headers: PackedStringArray, data: PackedByteArray) -> void:
|
||||
http.queue_free()
|
||||
if code < 200 or code >= 300 or data.is_empty():
|
||||
push_warning("[SkyboxController] Failed to download skybox: HTTP %d" % code)
|
||||
return
|
||||
var img: Image = Image.new()
|
||||
var clean_url: String = url.split("?")[0]
|
||||
var ext: String = clean_url.get_extension().to_lower()
|
||||
var err: int
|
||||
if ext in ["jpg", "jpeg"]:
|
||||
err = img.load_jpg_from_buffer(data)
|
||||
elif ext == "webp":
|
||||
err = img.load_webp_from_buffer(data)
|
||||
else:
|
||||
err = img.load_png_from_buffer(data)
|
||||
if err != OK:
|
||||
push_warning("[SkyboxController] Failed to decode skybox image (ext=%s)" % ext)
|
||||
return
|
||||
var tex: ImageTexture = ImageTexture.create_from_image(img)
|
||||
var mat: PanoramaSkyMaterial = PanoramaSkyMaterial.new()
|
||||
mat.panorama = tex
|
||||
if is_instance_valid(skybox_sky):
|
||||
skybox_sky.sky_material = mat
|
||||
print("[SkyboxController] CDN skybox applied."))
|
||||
http.request(url)
|
||||
|
||||
|
||||
func load_animated_skybox(base_url: String, frame_count: int, fps: float) -> void:
|
||||
skybox_frames.clear()
|
||||
skybox_frame_idx = 0
|
||||
var loaded: int = 0
|
||||
var frames_arr: Array = []
|
||||
frames_arr.resize(frame_count)
|
||||
|
||||
for i: int in frame_count:
|
||||
var url: String = "%s/%d.png" % [base_url, i]
|
||||
var http: HTTPRequest = HTTPRequest.new()
|
||||
var frame_idx: int = i
|
||||
add_child(http)
|
||||
http.request_completed.connect(
|
||||
func(_result: int, code: int, _headers: PackedStringArray, data: PackedByteArray) -> void:
|
||||
http.queue_free()
|
||||
loaded += 1
|
||||
if code >= 200 and code < 300 and not data.is_empty():
|
||||
var img: Image = Image.new()
|
||||
if img.load_png_from_buffer(data) == OK:
|
||||
frames_arr[frame_idx] = ImageTexture.create_from_image(img)
|
||||
if loaded == frame_count:
|
||||
skybox_frames = frames_arr.filter(func(f: Variant) -> bool: return f != null)
|
||||
if not skybox_frames.is_empty():
|
||||
start_skybox_animation(fps))
|
||||
http.request(url)
|
||||
|
||||
|
||||
func start_skybox_animation(fps: float) -> void:
|
||||
apply_skybox_frame(0)
|
||||
if skybox_frames.size() <= 1:
|
||||
return
|
||||
if skybox_timer != null:
|
||||
skybox_timer.queue_free()
|
||||
skybox_timer = Timer.new()
|
||||
skybox_timer.wait_time = 1.0 / maxf(fps, 1.0)
|
||||
skybox_timer.autostart = true
|
||||
skybox_timer.timeout.connect(on_skybox_frame_tick)
|
||||
add_child(skybox_timer)
|
||||
|
||||
|
||||
func apply_skybox_frame(idx: int) -> void:
|
||||
if skybox_frames.is_empty() or not is_instance_valid(skybox_sky):
|
||||
return
|
||||
var tex: ImageTexture = skybox_frames[idx % skybox_frames.size()]
|
||||
if tex == null:
|
||||
return
|
||||
var mat: Variant = skybox_sky.sky_material
|
||||
if not (mat is PanoramaSkyMaterial):
|
||||
mat = PanoramaSkyMaterial.new()
|
||||
skybox_sky.sky_material = mat
|
||||
(mat as PanoramaSkyMaterial).panorama = tex
|
||||
|
||||
|
||||
func on_skybox_frame_tick() -> void:
|
||||
skybox_frame_idx = (skybox_frame_idx + 1) % skybox_frames.size()
|
||||
apply_skybox_frame(skybox_frame_idx)
|
||||
|
||||
# ── Per-frame ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func process_sky_rotation(delta: float) -> void:
|
||||
var env: Environment = world_environment.environment as Environment
|
||||
if env != null:
|
||||
env.sky_rotation.y += delta * GameConstants.SKY_ROTATION_SPEED
|
||||
|
||||
# ── Cleanup ───────────────────────────────────────────────────────────────────
|
||||
|
||||
func cleanup() -> void:
|
||||
if ambient_star_timer != null and is_instance_valid(ambient_star_timer):
|
||||
ambient_star_timer.queue_free()
|
||||
ambient_star_timer = null
|
||||
if skybox_timer != null:
|
||||
skybox_timer.queue_free()
|
||||
skybox_timer = null
|
||||
if Settings.skybox_mode == "live":
|
||||
Network.request("game.unsubscribe_activity", {},
|
||||
func(_t: String, _r: Variant) -> void: pass,
|
||||
func(_c: String, _m: String) -> void: pass)
|
||||
clear_stars()
|
||||
if Game.game_activity.is_connected(on_game_activity):
|
||||
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)
|
||||
@@ -0,0 +1 @@
|
||||
uid://bei06l62sfffw
|
||||
@@ -0,0 +1,86 @@
|
||||
class_name GameConstants
|
||||
|
||||
# ── Affinity colors ───────────────────────────────────────────────────────────
|
||||
|
||||
const AFFINITY_COLORS: Dictionary = {
|
||||
"Void": Color(0.18, 0.18, 0.22),
|
||||
"Aether": Color(0.60, 0.45, 0.85),
|
||||
"Lake": Color(0.28, 0.52, 0.88),
|
||||
"Hill": Color(0.58, 0.44, 0.26),
|
||||
"Forest": Color(0.22, 0.52, 0.24),
|
||||
"Field": Color(0.62, 0.72, 0.28),
|
||||
"Ocean": Color(0.10, 0.20, 0.72),
|
||||
"Island": Color(0.38, 0.68, 0.84),
|
||||
"Marsh": Color(0.38, 0.52, 0.34),
|
||||
"Swamp": Color(0.24, 0.33, 0.20),
|
||||
"Mountain": Color(0.50, 0.44, 0.38),
|
||||
"Steppe": Color(0.72, 0.63, 0.38),
|
||||
"Fort": Color(0.40, 0.34, 0.30),
|
||||
"Plains": Color(0.78, 0.74, 0.50),
|
||||
"Grove": Color(0.33, 0.58, 0.28),
|
||||
"Jungle": Color(0.15, 0.42, 0.20),
|
||||
"PerfectAether": Color(0.88, 0.72, 1.00),
|
||||
"PureVoid": Color(0.05, 0.05, 0.10),
|
||||
"UnstableAether":Color(0.70, 0.55, 0.90),
|
||||
"GatewayLake": Color(0.22, 0.42, 0.70),
|
||||
"GatewayHill": Color(0.46, 0.34, 0.18),
|
||||
"GatewayForest": Color(0.18, 0.42, 0.18),
|
||||
"GatewayField": Color(0.52, 0.60, 0.22),
|
||||
}
|
||||
|
||||
# ── Highlight colors ──────────────────────────────────────────────────────────
|
||||
|
||||
const HI_GREEN: Color = Color(0.20, 0.90, 0.20, 0.40)
|
||||
const HI_RED: Color = Color(1.00, 0.25, 0.25, 0.50)
|
||||
const HI_BLUE: Color = Color(0.20, 0.50, 1.00, 0.40)
|
||||
const HI_YELLOW: Color = Color(1.00, 0.85, 0.10, 0.50)
|
||||
const HI_ORANGE: Color = Color(1.00, 0.60, 0.10, 0.45)
|
||||
|
||||
# ── Hitsplat ──────────────────────────────────────────────────────────────────
|
||||
|
||||
const HITSPLAT_LIFETIME: float = 0.75
|
||||
const HITSPLAT_RISE_PIXELS: float = 42.0
|
||||
|
||||
# ── Tile / board geometry ─────────────────────────────────────────────────────
|
||||
|
||||
## Grid spacing: 1.0 tile + 0.1 gap between tiles (visual only).
|
||||
const TILE_SPACING: float = 1.1
|
||||
const HEX_TILE_RADIUS: float = 0.5774 # ≈ 1/√3 — flat-to-flat = TILE_SPACING
|
||||
const HEX_TILE_SPACING: float = TILE_SPACING * 0.5 # hex boards use tighter spacing
|
||||
|
||||
# ── Animation timing ──────────────────────────────────────────────────────────
|
||||
|
||||
## Seconds per grid step when animating unit movement along the BFS path.
|
||||
const MOVE_STEP_SECS: float = 0.28
|
||||
## How long to hold after one-shot animations (attack / damaged / dying) before rebuilding.
|
||||
const POST_ANIM_SECS: float = 1.2
|
||||
## Seconds to skip at the start of looping animations on subsequent loop iterations.
|
||||
## GLB animations use the first N frames as a transition-in from idle; on repeat loops
|
||||
## we jump past them to avoid the bind-pose flash.
|
||||
const ANIM_TRANSITION_SECS: float = 5.0 / 30.0 # 5 frames at 30 fps
|
||||
|
||||
# ── Unit SFX ──────────────────────────────────────────────────────────────────
|
||||
|
||||
const UNIT_SFX_KEYS: Array = [
|
||||
"moveSoundUrl",
|
||||
"attackSoundUrl",
|
||||
"damagedSoundUrl",
|
||||
"deathSoundUrl",
|
||||
"blockedSoundUrl",
|
||||
]
|
||||
|
||||
# ── Animation aliases ─────────────────────────────────────────────────────────
|
||||
|
||||
## 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 = {
|
||||
"idle": ["idle", "idle_a", "idle1", "idle_loop"],
|
||||
"attack": ["attack", "attack_a", "attack1", "attack_b", "strike"],
|
||||
"damaged": ["damaged", "attacked", "hit", "hurt", "flinch"],
|
||||
"dying": ["dying", "death", "die", "dead"],
|
||||
"moving": ["moving", "move", "walk", "run", "walk_cycle"],
|
||||
}
|
||||
|
||||
# ── Skybox ────────────────────────────────────────────────────────────────────
|
||||
|
||||
const SKY_ROTATION_SPEED: float = 0.026 # rad/sec — ~4 min per full revolution
|
||||
@@ -0,0 +1 @@
|
||||
uid://dveqey2ixrmyb
|
||||
@@ -0,0 +1,649 @@
|
||||
class_name HandManager
|
||||
extends PanelContainer
|
||||
|
||||
signal hand_card_clicked(card_data: Dictionary)
|
||||
signal hand_spin_requested(direction: int)
|
||||
|
||||
# ── Preloaded resources ───────────────────────────────────────────────────────
|
||||
|
||||
const _CARD_WIDGET_SCENE: PackedScene = preload("res://scenes/collection/components/CardWidget.tscn")
|
||||
const _HAND_ARROW_REGULAR: Texture2D = preload("res://ui/icons/Green_Gem_Arrow_Button_Regular.png")
|
||||
const _HAND_ARROW_HOVER: Texture2D = preload("res://ui/icons/Green_Gem_Arrow_Button_Hover.png")
|
||||
const _HAND_ARROW_PRESSED: Texture2D = preload("res://ui/icons/Green_Gem_Arrow_Button_Click.png")
|
||||
|
||||
# ── Scene node refs ───────────────────────────────────────────────────────────
|
||||
|
||||
@onready var hand_cards : Control = %HandCards
|
||||
@onready var _hand_spin_left : TextureButton = %HandSpinLeft
|
||||
@onready var _hand_spin_right: TextureButton = %HandSpinRight
|
||||
|
||||
# ── Hand state ────────────────────────────────────────────────────────────────
|
||||
|
||||
var hand_focus_index: int = 0
|
||||
var hand_scroll_time: float = 0.0
|
||||
var cached_hand_iids: Array = []
|
||||
var pending_popup_cards: Array = []
|
||||
var popup_layer: CanvasLayer = null
|
||||
var sel_card_id: String = "" # set by selection_controller to highlight
|
||||
var _spin_layout_iids: Array = []
|
||||
var _spin_layout_viewport_size: Vector2 = Vector2.ZERO
|
||||
var _spin_layout_bounds: Rect2 = Rect2()
|
||||
var _spin_min_bounds: Rect2 = Rect2()
|
||||
var _has_spin_layout_bounds: bool = false
|
||||
var _has_spin_min_bounds: bool = false
|
||||
var _spin_min_card_count: int = 0
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
$HandScroll.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
hand_cards.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
configure_hand_spin_buttons()
|
||||
resized.connect(queue_hand_layout)
|
||||
resized.connect(layout_hand_spin_buttons)
|
||||
hand_cards.resized.connect(queue_hand_layout)
|
||||
|
||||
# ── Public API ────────────────────────────────────────────────────────────────
|
||||
|
||||
func on_hand_card_clicked(iid: String, _panel: PanelContainer) -> void:
|
||||
var card: Dictionary = find_hand_card(iid)
|
||||
if card.is_empty():
|
||||
return
|
||||
emit_signal("hand_card_clicked", card)
|
||||
|
||||
|
||||
func blocks_pointer(screen_pos: Vector2) -> bool:
|
||||
if not visible or not is_inside_tree():
|
||||
return false
|
||||
if _control_contains_global_point(_hand_spin_left, screen_pos):
|
||||
return true
|
||||
if _control_contains_global_point(_hand_spin_right, screen_pos):
|
||||
return true
|
||||
for child: Node in hand_cards.get_children():
|
||||
if child is Control and _control_contains_global_point(child as Control, screen_pos):
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _control_contains_global_point(control: Control, screen_pos: Vector2) -> bool:
|
||||
if control == null or not is_instance_valid(control):
|
||||
return false
|
||||
if not control.visible or control.mouse_filter == Control.MOUSE_FILTER_IGNORE:
|
||||
return false
|
||||
var local_pos: Vector2 = control.get_global_transform().affine_inverse() * screen_pos
|
||||
return Rect2(Vector2.ZERO, control.size).has_point(local_pos)
|
||||
|
||||
|
||||
func rebuild_hand(hand: Array, is_spectating: bool) -> void:
|
||||
var new_iids: Array = []
|
||||
for card: Dictionary in hand:
|
||||
var raw_iid: Variant = card.get("instanceId")
|
||||
new_iids.append(str(raw_iid) if raw_iid != null else "")
|
||||
if new_iids == cached_hand_iids:
|
||||
refresh_hand_selection()
|
||||
return
|
||||
|
||||
cached_hand_iids = new_iids
|
||||
|
||||
if is_spectating:
|
||||
apply_display_hand([])
|
||||
return
|
||||
|
||||
var pending_iids: Array = []
|
||||
for c: Dictionary in pending_popup_cards:
|
||||
pending_iids.append(c.get("instanceId", "") as String)
|
||||
|
||||
var brand_new: Array = []
|
||||
if Settings.draw_card_popup:
|
||||
for card: Dictionary in hand:
|
||||
var iid: String = card.get("instanceId", "")
|
||||
if iid not in cached_hand_iids and iid not in pending_iids:
|
||||
brand_new.append(card)
|
||||
|
||||
var kept: Array = []
|
||||
for c: Dictionary in pending_popup_cards:
|
||||
if c.get("instanceId", "") in new_iids:
|
||||
kept.append(c)
|
||||
pending_popup_cards = kept
|
||||
|
||||
for card: Dictionary in brand_new:
|
||||
pending_popup_cards.append(card)
|
||||
|
||||
var popup_iids: Array = []
|
||||
for c: Dictionary in pending_popup_cards:
|
||||
popup_iids.append(c.get("instanceId", "") as String)
|
||||
|
||||
var display_hand: Array = []
|
||||
for card: Dictionary in hand:
|
||||
if card.get("instanceId", "") not in popup_iids:
|
||||
display_hand.append(card)
|
||||
|
||||
apply_display_hand(display_hand)
|
||||
|
||||
if not pending_popup_cards.is_empty() and (popup_layer == null or not popup_layer.visible):
|
||||
show_next_card_popup()
|
||||
|
||||
|
||||
func apply_display_hand(hand: Array) -> void:
|
||||
if hand.is_empty():
|
||||
for c in hand_cards.get_children():
|
||||
hand_cards.remove_child(c)
|
||||
c.queue_free()
|
||||
hand_focus_index = 0
|
||||
_spin_layout_iids = []
|
||||
_has_spin_layout_bounds = false
|
||||
sync_hand_spin_buttons()
|
||||
return
|
||||
|
||||
var existing: Dictionary = {}
|
||||
for child in hand_cards.get_children():
|
||||
if child.has_meta("card_instance_id"):
|
||||
existing[str(child.get_meta("card_instance_id"))] = child
|
||||
|
||||
var hand_iids: Array = []
|
||||
for card: Dictionary in hand:
|
||||
hand_iids.append(card.get("instanceId", "") as String)
|
||||
|
||||
for iid: String in existing.keys():
|
||||
if iid not in hand_iids:
|
||||
var w: Node = existing[iid]
|
||||
existing.erase(iid)
|
||||
hand_cards.remove_child(w)
|
||||
w.queue_free()
|
||||
|
||||
var slot: int = 0
|
||||
for card: Dictionary in hand:
|
||||
var iid: String = card.get("instanceId", "")
|
||||
if not existing.has(iid):
|
||||
var widget: Control = make_hand_card(card)
|
||||
widget.set_meta("_fan_slot", slot)
|
||||
hand_cards.add_child(widget)
|
||||
else:
|
||||
(existing[iid] as Control).set_meta("_fan_slot", slot)
|
||||
slot += 1
|
||||
|
||||
hand_focus_index = posmod(hand_focus_index, hand.size())
|
||||
queue_hand_layout()
|
||||
sync_hand_spin_buttons()
|
||||
|
||||
|
||||
func show_next_card_popup() -> void:
|
||||
if pending_popup_cards.is_empty():
|
||||
return
|
||||
var card: Dictionary = pending_popup_cards[0]
|
||||
|
||||
if popup_layer == null or not is_instance_valid(popup_layer):
|
||||
popup_layer = CanvasLayer.new()
|
||||
popup_layer.layer = 20
|
||||
add_child(popup_layer)
|
||||
|
||||
for c in popup_layer.get_children():
|
||||
c.queue_free()
|
||||
popup_layer.visible = true
|
||||
|
||||
var bg: ColorRect = ColorRect.new()
|
||||
bg.color = Color(0.0, 0.0, 0.0, 0.65)
|
||||
bg.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
bg.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
popup_layer.add_child(bg)
|
||||
|
||||
var vbox: VBoxContainer = VBoxContainer.new()
|
||||
vbox.set_anchors_preset(Control.PRESET_CENTER)
|
||||
vbox.grow_horizontal = Control.GROW_DIRECTION_BOTH
|
||||
vbox.grow_vertical = Control.GROW_DIRECTION_BOTH
|
||||
vbox.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
popup_layer.add_child(vbox)
|
||||
vbox.add_theme_constant_override("separation", 16)
|
||||
|
||||
var lbl: Label = Label.new()
|
||||
lbl.text = "Card Drawn — click to add to hand"
|
||||
lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
vbox.add_child(lbl)
|
||||
lbl.add_theme_font_size_override("font_size", 16)
|
||||
|
||||
var widget: PanelContainer = _CARD_WIDGET_SCENE.instantiate()
|
||||
widget.custom_minimum_size = Vector2(200, 320)
|
||||
widget.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
var def_id: String = str(card.get("cardDefinitionId", ""))
|
||||
var def: Dictionary = ContentCache.get_definition(def_id)
|
||||
if def.is_empty():
|
||||
def = card.duplicate()
|
||||
def["movementPoints"] = card.get("maxMp", def.get("movementPoints", null))
|
||||
widget.setup(card, def)
|
||||
vbox.add_child(widget)
|
||||
|
||||
bg.gui_input.connect(func(ev: InputEvent) -> void:
|
||||
if ev is InputEventMouseButton and (ev as InputEventMouseButton).pressed:
|
||||
dismiss_card_popup())
|
||||
widget.card_pressed.connect(func(_id: String) -> void: dismiss_card_popup())
|
||||
|
||||
|
||||
func dismiss_card_popup() -> void:
|
||||
if pending_popup_cards.is_empty():
|
||||
return
|
||||
var card: Dictionary = pending_popup_cards.pop_front()
|
||||
|
||||
if is_instance_valid(popup_layer):
|
||||
popup_layer.visible = false
|
||||
|
||||
var display_iids: Array = []
|
||||
for child in hand_cards.get_children():
|
||||
if child.has_meta("card_instance_id"):
|
||||
display_iids.append(str(child.get_meta("card_instance_id")))
|
||||
display_iids.append(card.get("instanceId", "") as String)
|
||||
|
||||
var display_hand: Array = []
|
||||
for iid: String in cached_hand_iids:
|
||||
if iid in display_iids:
|
||||
if iid == card.get("instanceId", ""):
|
||||
display_hand.append(card)
|
||||
else:
|
||||
for hc: Dictionary in Game.get_hand():
|
||||
if hc.get("instanceId", "") == iid:
|
||||
display_hand.append(hc)
|
||||
break
|
||||
|
||||
apply_display_hand(display_hand)
|
||||
|
||||
if not pending_popup_cards.is_empty():
|
||||
show_next_card_popup()
|
||||
|
||||
|
||||
func make_hand_card(card: Dictionary) -> Control:
|
||||
var iid: String = card.get("instanceId", "")
|
||||
var def_id: String = str(card.get("cardDefinitionId", ""))
|
||||
|
||||
var widget: PanelContainer = _CARD_WIDGET_SCENE.instantiate()
|
||||
widget.top_level = false
|
||||
widget.anchor_left = 0.0
|
||||
widget.anchor_top = 0.0
|
||||
widget.anchor_right = 0.0
|
||||
widget.anchor_bottom = 0.0
|
||||
widget.position = Vector2.ZERO
|
||||
widget.size = widget.custom_minimum_size
|
||||
widget.visible = true
|
||||
widget.set_meta("card_instance_id", iid)
|
||||
|
||||
var def: Dictionary = ContentCache.get_definition(def_id)
|
||||
if def.is_empty():
|
||||
def = card.duplicate()
|
||||
def["movementPoints"] = card.get("maxMp", def.get("movementPoints", null))
|
||||
widget.setup(card, def)
|
||||
|
||||
widget.card_pressed.connect(func(_def_id: String) -> void:
|
||||
on_hand_card_clicked(iid, widget))
|
||||
|
||||
return widget
|
||||
|
||||
|
||||
func refresh_hand_selection() -> void:
|
||||
var needs_layout: bool = false
|
||||
for widget in hand_cards.get_children():
|
||||
if not widget.has_meta("card_instance_id"):
|
||||
continue
|
||||
var iid: String = str(widget.get_meta("card_instance_id"))
|
||||
var sel: bool = sel_card_id == iid and not sel_card_id.is_empty()
|
||||
if widget.has_method("set_selected"):
|
||||
widget.set_selected(sel)
|
||||
if sel != bool(widget.get_meta("_sel", false)):
|
||||
widget.set_meta("_sel", sel)
|
||||
needs_layout = true
|
||||
if needs_layout:
|
||||
queue_hand_layout()
|
||||
|
||||
|
||||
func tween_hand_card(widget: Control, sel: bool) -> void:
|
||||
if not is_instance_valid(widget):
|
||||
return
|
||||
widget.set_meta("_sel", sel)
|
||||
queue_hand_layout()
|
||||
|
||||
|
||||
func find_hand_card(iid: String) -> Dictionary:
|
||||
for card: Dictionary in Game.get_hand():
|
||||
if card.get("instanceId", "") == iid:
|
||||
return card
|
||||
return {}
|
||||
|
||||
|
||||
func configure_hand_spin_buttons() -> void:
|
||||
_hand_spin_left.texture_normal = _HAND_ARROW_REGULAR
|
||||
_hand_spin_left.texture_hover = _HAND_ARROW_HOVER
|
||||
_hand_spin_left.texture_pressed = _HAND_ARROW_PRESSED
|
||||
_hand_spin_left.modulate = Color(1, 1, 1, 0.92)
|
||||
_hand_spin_left.focus_mode = Control.FOCUS_NONE
|
||||
_hand_spin_left.rotation_degrees = 0.0
|
||||
if not _hand_spin_left.pressed.is_connected(_on_hand_spin_left_pressed):
|
||||
_hand_spin_left.pressed.connect(_on_hand_spin_left_pressed)
|
||||
|
||||
_hand_spin_right.texture_normal = _HAND_ARROW_REGULAR
|
||||
_hand_spin_right.texture_hover = _HAND_ARROW_HOVER
|
||||
_hand_spin_right.texture_pressed = _HAND_ARROW_PRESSED
|
||||
_hand_spin_right.modulate = Color(1, 1, 1, 0.92)
|
||||
_hand_spin_right.focus_mode = Control.FOCUS_NONE
|
||||
_hand_spin_right.rotation_degrees = 0.0
|
||||
if not _hand_spin_right.pressed.is_connected(_on_hand_spin_right_pressed):
|
||||
_hand_spin_right.pressed.connect(_on_hand_spin_right_pressed)
|
||||
layout_hand_spin_buttons()
|
||||
|
||||
|
||||
func _on_hand_spin_left_pressed() -> void:
|
||||
hand_spin_requested.emit(-1)
|
||||
|
||||
|
||||
func _on_hand_spin_right_pressed() -> void:
|
||||
hand_spin_requested.emit(1)
|
||||
|
||||
|
||||
func layout_hand_spin_buttons() -> void:
|
||||
_hand_spin_left.anchor_left = 0.0
|
||||
_hand_spin_left.anchor_top = 0.0
|
||||
_hand_spin_left.anchor_right = 0.0
|
||||
_hand_spin_left.anchor_bottom = 0.0
|
||||
_hand_spin_left.offset_left = 8.0
|
||||
_hand_spin_left.offset_top = 103.0
|
||||
_hand_spin_left.offset_right = 52.0
|
||||
_hand_spin_left.offset_bottom = 147.0
|
||||
#_hand_spin_left.custom_minimum_size = Vector2(44, 44)
|
||||
#_hand_spin_left.size = Vector2(44, 44)
|
||||
|
||||
_hand_spin_right.anchor_left = 0.0
|
||||
_hand_spin_right.anchor_top = 0.0
|
||||
_hand_spin_right.anchor_right = 0.0
|
||||
_hand_spin_right.anchor_bottom = 0.0
|
||||
_hand_spin_right.offset_left = maxf(8.0, size.x - 52.0)
|
||||
_hand_spin_right.offset_top = 103.0
|
||||
_hand_spin_right.offset_right = maxf(52.0, size.x - 8.0)
|
||||
_hand_spin_right.offset_bottom = 147.0
|
||||
#_hand_spin_right.custom_minimum_size = Vector2(44, 44)
|
||||
#_hand_spin_right.size = Vector2(44, 44)
|
||||
|
||||
|
||||
func sync_hand_spin_buttons() -> void:
|
||||
var enabled: bool = hand_cards.get_child_count() > 1
|
||||
_hand_spin_left.visible = enabled
|
||||
_hand_spin_right.visible = enabled
|
||||
_hand_spin_left.disabled = not enabled
|
||||
_hand_spin_right.disabled = not enabled
|
||||
|
||||
|
||||
func spin_hand(direction: int) -> void:
|
||||
var card_count: int = hand_cards.get_child_count()
|
||||
if card_count <= 1:
|
||||
return
|
||||
hand_focus_index = posmod(hand_focus_index + direction, card_count)
|
||||
layout_hand_cards()
|
||||
|
||||
|
||||
func focus_hand_card(iid: String) -> void:
|
||||
var idx: int = 0
|
||||
for widget in hand_cards.get_children():
|
||||
if str(widget.get_meta("card_instance_id", "")) == iid:
|
||||
hand_focus_index = idx
|
||||
layout_hand_cards()
|
||||
return
|
||||
idx += 1
|
||||
|
||||
|
||||
func queue_hand_layout() -> void:
|
||||
if not is_inside_tree():
|
||||
return
|
||||
layout_hand_cards.call_deferred()
|
||||
|
||||
|
||||
func layout_hand_cards() -> void:
|
||||
var widgets: Array = hand_cards.get_children()
|
||||
var widget_count: int = widgets.size()
|
||||
if widget_count == 0:
|
||||
return
|
||||
|
||||
hand_focus_index = posmod(hand_focus_index, widget_count)
|
||||
hand_cards.position = Vector2.ZERO
|
||||
hand_cards.size = size # self IS the hand area
|
||||
var viewport_size: Vector2 = size
|
||||
if viewport_size.x <= 0.0 or viewport_size.y <= 0.0:
|
||||
return
|
||||
|
||||
var sample: Control = widgets[0] as Control
|
||||
sample.size = sample.custom_minimum_size
|
||||
var sample_size: Vector2 = hand_card_size(sample)
|
||||
var side_margin: float = 64.0 if widget_count > 1 else 40.0
|
||||
var usable_width: float = maxf(120.0, viewport_size.x - side_margin * 2.0)
|
||||
var max_rel: int = 0
|
||||
var fan_half_width: float = minf(usable_width * 0.5 - sample_size.x * 0.5, 120.0 + widget_count * 18.0)
|
||||
fan_half_width = maxf(fan_half_width, 0.0)
|
||||
var fit_scale: float = minf(0.92, maxf(0.52, (viewport_size.y - 36.0) / sample_size.y))
|
||||
var scaled_height: float = sample_size.y * fit_scale
|
||||
var base_y: float = maxf(0.0, viewport_size.y - scaled_height - 28.0)
|
||||
var arc_height: float = minf(34.0, viewport_size.y * 0.14)
|
||||
var max_angle_deg: float = clampf(14.0 + widget_count * 2.4, 18.0, 34.0)
|
||||
|
||||
for i in range(widget_count):
|
||||
var slot_i: int = int((widgets[i] as Control).get_meta("_fan_slot", i))
|
||||
max_rel = max(max_rel, abs(wrapped_hand_delta(slot_i, widget_count)))
|
||||
|
||||
var hand_bounds: Rect2 = Rect2()
|
||||
var has_hand_bounds: bool = false
|
||||
var layout_entries: Array = []
|
||||
|
||||
for i in range(widget_count):
|
||||
var widget: Control = widgets[i] as Control
|
||||
if widget == null:
|
||||
continue
|
||||
widget.size = widget.custom_minimum_size
|
||||
|
||||
var slot: int = int(widget.get_meta("_fan_slot", i))
|
||||
var rel: int = wrapped_hand_delta(slot, widget_count)
|
||||
var t: float = 0.0 if max_rel == 0 else float(rel) / float(max_rel)
|
||||
var angle_deg: float = t * max_angle_deg
|
||||
var card_size: Vector2 = hand_card_size(widget)
|
||||
var edge_factor: float = absf(t)
|
||||
var lift: float = 0.0
|
||||
var scale_amt: float = fit_scale * lerpf(1.0, 0.84, edge_factor)
|
||||
var is_selected: bool = bool(widget.get_meta("_sel", false))
|
||||
|
||||
if is_selected:
|
||||
scale_amt += 0.08
|
||||
lift += 16.0
|
||||
|
||||
var pos: Vector2 = Vector2.ZERO
|
||||
pos.x = viewport_size.x * 0.5 + t * fan_half_width - (card_size.x * scale_amt) * 0.5
|
||||
pos.y = base_y + float(pow(edge_factor, 1.35)) * arc_height - lift
|
||||
pos.x = clampf(pos.x, side_margin, maxf(side_margin, viewport_size.x - side_margin - card_size.x * scale_amt))
|
||||
pos.y = clampf(pos.y, 0.0, maxf(0.0, viewport_size.y - card_size.y * scale_amt))
|
||||
var z: int = 20 + int((1.0 - edge_factor) * 100.0)
|
||||
if is_selected:
|
||||
z += 120
|
||||
widget.set_meta("_hand_stack", z)
|
||||
|
||||
var rot: float = deg_to_rad(angle_deg * 0.35)
|
||||
var card_bounds: Rect2 = transformed_card_rect(pos, card_size, rot, scale_amt)
|
||||
hand_bounds = card_bounds if not has_hand_bounds else hand_bounds.merge(card_bounds)
|
||||
has_hand_bounds = true
|
||||
|
||||
layout_entries.append({
|
||||
"widget": widget,
|
||||
"position": pos,
|
||||
"rotation": rot,
|
||||
"scale": scale_amt,
|
||||
"z": z,
|
||||
})
|
||||
|
||||
if has_hand_bounds:
|
||||
var stable_bounds: Rect2 = stable_hand_spin_bounds(hand_bounds, viewport_size)
|
||||
var fan_offset: Vector2 = stable_bounds.get_center() - hand_bounds.get_center()
|
||||
for entry: Dictionary in layout_entries:
|
||||
apply_hand_card_transform(
|
||||
entry["widget"] as Control,
|
||||
(entry["position"] as Vector2) + fan_offset,
|
||||
float(entry["rotation"]),
|
||||
float(entry["scale"]),
|
||||
int(entry["z"]))
|
||||
layout_hand_spin_buttons_near_cards(stable_bounds)
|
||||
|
||||
restack_hand_cards()
|
||||
|
||||
|
||||
func restack_hand_cards() -> void:
|
||||
var ordered: Array = []
|
||||
for child in hand_cards.get_children():
|
||||
if child is Control:
|
||||
ordered.append(child as Control)
|
||||
ordered.sort_custom(func(a: Control, b: Control) -> bool:
|
||||
return int(a.get_meta("_hand_stack", 0)) < int(b.get_meta("_hand_stack", 0))
|
||||
)
|
||||
for i in range(ordered.size()):
|
||||
hand_cards.move_child(ordered[i], i)
|
||||
|
||||
|
||||
func stable_hand_spin_bounds(current_bounds: Rect2, viewport_size: Vector2) -> Rect2:
|
||||
var current_iids: Array = current_display_hand_iids()
|
||||
if not _has_spin_min_bounds or (_spin_min_card_count <= 1 and current_iids.size() > 1):
|
||||
_spin_min_bounds = current_bounds
|
||||
_has_spin_min_bounds = true
|
||||
_spin_min_card_count = current_iids.size()
|
||||
|
||||
var next_bounds: Rect2 = expand_rect_to_min_size(current_bounds, _spin_min_bounds.size)
|
||||
var membership_changed: bool = current_iids != _spin_layout_iids
|
||||
var viewport_changed: bool = (
|
||||
absf(viewport_size.x - _spin_layout_viewport_size.x) > 0.5
|
||||
or absf(viewport_size.y - _spin_layout_viewport_size.y) > 0.5
|
||||
)
|
||||
|
||||
if not _has_spin_layout_bounds or membership_changed or viewport_changed:
|
||||
_spin_layout_iids = current_iids
|
||||
_spin_layout_viewport_size = viewport_size
|
||||
_spin_layout_bounds = next_bounds
|
||||
_has_spin_layout_bounds = true
|
||||
|
||||
return _spin_layout_bounds
|
||||
|
||||
|
||||
func current_display_hand_iids() -> Array:
|
||||
var iids: Array = []
|
||||
for child: Node in hand_cards.get_children():
|
||||
if child.has_meta("card_instance_id"):
|
||||
iids.append(str(child.get_meta("card_instance_id")))
|
||||
iids.sort()
|
||||
return iids
|
||||
|
||||
|
||||
func expand_rect_to_min_size(rect: Rect2, min_size: Vector2) -> Rect2:
|
||||
var next_size: Vector2 = Vector2(
|
||||
maxf(rect.size.x, min_size.x),
|
||||
maxf(rect.size.y, min_size.y)
|
||||
)
|
||||
return Rect2(rect.get_center() - next_size * 0.5, next_size)
|
||||
|
||||
|
||||
func layout_hand_spin_buttons_near_cards(hand_bounds: Rect2) -> void:
|
||||
var button_size: Vector2 = Vector2(44.0, 44.0)
|
||||
var gap: float = 10.0
|
||||
var y: float = clampf(
|
||||
hand_bounds.get_center().y - button_size.y * 0.5,
|
||||
4.0,
|
||||
maxf(4.0, size.y - button_size.y - 4.0))
|
||||
var left_x: float = clampf(
|
||||
hand_bounds.position.x - gap - button_size.x,
|
||||
4.0,
|
||||
maxf(4.0, size.x - button_size.x - 4.0))
|
||||
var right_x: float = clampf(
|
||||
hand_bounds.end.x + gap,
|
||||
4.0,
|
||||
maxf(4.0, size.x - button_size.x - 4.0))
|
||||
|
||||
position_hand_spin_button(_hand_spin_left, Vector2(left_x, y), button_size)
|
||||
position_hand_spin_button(_hand_spin_right, Vector2(right_x, y), button_size)
|
||||
|
||||
|
||||
func position_hand_spin_button(button: TextureButton, pos: Vector2, button_size: Vector2) -> void:
|
||||
var parent_control: Control = button.get_parent() as Control
|
||||
var local_pos: Vector2 = pos
|
||||
if parent_control != null:
|
||||
var global_pos: Vector2 = get_global_transform() * pos
|
||||
local_pos = parent_control.get_global_transform().affine_inverse() * global_pos
|
||||
button.anchor_left = 0.0
|
||||
button.anchor_top = 0.0
|
||||
button.anchor_right = 0.0
|
||||
button.anchor_bottom = 0.0
|
||||
button.offset_left = local_pos.x
|
||||
button.offset_top = local_pos.y
|
||||
button.offset_right = local_pos.x + button_size.x
|
||||
button.offset_bottom = local_pos.y + button_size.y
|
||||
|
||||
|
||||
func transformed_card_rect(pos: Vector2, card_size: Vector2, rot: float, scale_amt: float) -> Rect2:
|
||||
var pivot: Vector2 = card_size * 0.5
|
||||
var basis_x: Vector2 = Vector2(cos(rot), sin(rot)) * scale_amt
|
||||
var basis_y: Vector2 = Vector2(-sin(rot), cos(rot)) * scale_amt
|
||||
var corners: Array[Vector2] = [
|
||||
transformed_card_corner(pos, pivot, basis_x, basis_y, Vector2(0.0, 0.0)),
|
||||
transformed_card_corner(pos, pivot, basis_x, basis_y, Vector2(card_size.x, 0.0)),
|
||||
transformed_card_corner(pos, pivot, basis_x, basis_y, Vector2(card_size.x, card_size.y)),
|
||||
transformed_card_corner(pos, pivot, basis_x, basis_y, Vector2(0.0, card_size.y)),
|
||||
]
|
||||
var min_pos: Vector2 = corners[0]
|
||||
var max_pos: Vector2 = corners[0]
|
||||
for corner: Vector2 in corners:
|
||||
min_pos.x = minf(min_pos.x, corner.x)
|
||||
min_pos.y = minf(min_pos.y, corner.y)
|
||||
max_pos.x = maxf(max_pos.x, corner.x)
|
||||
max_pos.y = maxf(max_pos.y, corner.y)
|
||||
return Rect2(min_pos, max_pos - min_pos)
|
||||
|
||||
|
||||
func transformed_card_corner(
|
||||
pos: Vector2,
|
||||
pivot: Vector2,
|
||||
basis_x: Vector2,
|
||||
basis_y: Vector2,
|
||||
corner: Vector2) -> Vector2:
|
||||
var local: Vector2 = corner - pivot
|
||||
return pos + pivot + basis_x * local.x + basis_y * local.y
|
||||
|
||||
|
||||
func apply_hand_card_transform(widget: Control, pos: Vector2, rot: float, scale_amt: float, z: int) -> void:
|
||||
widget.pivot_offset = hand_card_size(widget) * 0.5
|
||||
widget.z_index = z
|
||||
if widget.has_meta("_hand_tween"):
|
||||
var existing: Variant = widget.get_meta("_hand_tween")
|
||||
if existing is Tween and is_instance_valid(existing):
|
||||
(existing as Tween).kill()
|
||||
widget.remove_meta("_hand_tween")
|
||||
|
||||
if not widget.has_meta("_hand_positioned"):
|
||||
widget.set_meta("_hand_positioned", true)
|
||||
widget.position = pos
|
||||
widget.rotation = rot
|
||||
widget.scale = Vector2.ONE * scale_amt
|
||||
return
|
||||
|
||||
var tw: Tween = create_tween().set_parallel(true)
|
||||
tw.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
|
||||
tw.tween_property(widget, "position", pos, 0.18)
|
||||
tw.tween_property(widget, "rotation", rot, 0.18)
|
||||
tw.tween_property(widget, "scale", Vector2.ONE * scale_amt, 0.18)
|
||||
widget.set_meta("_hand_tween", tw)
|
||||
|
||||
|
||||
func hand_card_size(widget: Control) -> Vector2:
|
||||
var size_v: Vector2 = widget.size
|
||||
if size_v.x <= 0.0 or size_v.y <= 0.0:
|
||||
size_v = widget.custom_minimum_size
|
||||
if size_v.x <= 0.0:
|
||||
size_v.x = 160.0
|
||||
if size_v.y <= 0.0:
|
||||
size_v.y = 257.0
|
||||
return size_v
|
||||
|
||||
|
||||
func wrapped_hand_delta(index: int, total: int) -> int:
|
||||
var delta: int = index - hand_focus_index
|
||||
if total <= 1:
|
||||
return 0
|
||||
if delta > total / 2:
|
||||
delta -= total
|
||||
elif delta < -int(ceil(total * 0.5)):
|
||||
delta += total
|
||||
return delta
|
||||
@@ -0,0 +1 @@
|
||||
uid://cjntlh271gouc
|
||||
@@ -0,0 +1,75 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://cowqg2xdx0x7g"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cjntlh271gouc" path="res://scenes/game/components/hud/hand_manager.gd" id="1_script"]
|
||||
[ext_resource type="Texture2D" uid="uid://psjb7swm36jx" path="res://ui/icons/Green_Gem_Arrow_Button_Click.png" id="2_arrow"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_hand"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_panel"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_panel2"]
|
||||
|
||||
[node name="HandManager" type="PanelContainer"]
|
||||
anchors_preset = -1
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.75
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 206.0
|
||||
offset_top = -248.0
|
||||
offset_bottom = 2.0
|
||||
mouse_filter = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_hand")
|
||||
script = ExtResource("1_script")
|
||||
|
||||
[node name="HandScroll" type="Control" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="HandCards" type="Control" parent="HandScroll"]
|
||||
unique_name_in_owner = true
|
||||
anchors_preset = 0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
layout_mode = 2
|
||||
mouse_filter = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_panel")
|
||||
|
||||
[node name="HandSpinLeft" type="TextureButton" parent="Panel"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(22, 22)
|
||||
layout_mode = 0
|
||||
offset_left = -2.0
|
||||
offset_top = -4.0
|
||||
offset_right = 69.0
|
||||
offset_bottom = 104.0
|
||||
scale = Vector2(1.9999998, 1.44)
|
||||
texture_normal = ExtResource("2_arrow")
|
||||
ignore_texture_size = true
|
||||
stretch_mode = 5
|
||||
flip_h = true
|
||||
|
||||
[node name="Panel2" type="Panel" parent="."]
|
||||
layout_mode = 2
|
||||
mouse_filter = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_panel2")
|
||||
|
||||
[node name="HandSpinRight" type="TextureButton" parent="Panel2"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(22, 22)
|
||||
layout_mode = 0
|
||||
offset_left = 806.0
|
||||
offset_top = 4.0
|
||||
offset_right = 873.0
|
||||
offset_bottom = 106.0
|
||||
scale = Vector2(2.08, 1.6)
|
||||
texture_normal = ExtResource("2_arrow")
|
||||
ignore_texture_size = true
|
||||
stretch_mode = 5
|
||||
@@ -0,0 +1,348 @@
|
||||
class_name HudController
|
||||
extends Control
|
||||
|
||||
## Owns all permanent HUD elements: TopBar, SP-ST panel, ActionRail, DiscardViewer,
|
||||
## SpectatorPanel. Emits signals for actions that GameScreen must handle.
|
||||
|
||||
signal draw_requested
|
||||
signal end_turn_requested
|
||||
signal settings_requested
|
||||
signal spectator_leave_requested
|
||||
|
||||
# ── Scene node refs ───────────────────────────────────────────────────────────
|
||||
|
||||
@onready var _phase_lbl : Label = %PhaseLabel
|
||||
@onready var _turn_lbl : Label = %TurnLabel
|
||||
@onready var _turn_order_strip : HBoxContainer = %TurnOrderStrip
|
||||
@onready var _opp_panel : HBoxContainer = %OpponentPanel
|
||||
@onready var _opp_name_lbl : Label = %OppNameLabel
|
||||
@onready var _opp_hand_lbl : Label = %OppHandLabel
|
||||
@onready var _opp_deck_lbl : Label = %OppDeckLabel
|
||||
@onready var _opp_discard_btn : Button = %OppDiscardBtn
|
||||
@onready var _sp_lbl : Label = %SpLabel
|
||||
@onready var _st_lbl : Label = %StLabel
|
||||
@onready var _deck_lbl : Label = %DeckLabel
|
||||
@onready var _discard_btn : Button = %DiscardBtn
|
||||
@onready var _discard_lbl : Label = %DiscardLabel
|
||||
@onready var _draw_btn : Button = %DrawBtn
|
||||
@onready var _end_turn_btn : Button = %EndTurnBtn
|
||||
@onready var _settings_btn : Button = %SettingsBtn
|
||||
@onready var _spectator_leave_btn : Button = %SpectatorLeaveBtn
|
||||
@onready var _dv_overlay : PanelContainer = %DiscardViewer
|
||||
@onready var _dv_title : Label = %DVTitle
|
||||
@onready var _dv_list : VBoxContainer = %DVList
|
||||
@onready var _dv_close_btn : Button = %DVCloseBtn
|
||||
@onready var _spectator_panel : PanelContainer = %SpectatorPlayersPanel
|
||||
@onready var _spectator_list : VBoxContainer = %SpectatorPlayerList
|
||||
@onready var _sp_st_panel : PanelContainer = $"SP-ST Panel Container"
|
||||
@onready var _deck_discard_panel: Control = $"ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container"
|
||||
@onready var _player_duel_hud : PlayerDuelHud = %PlayerDuelHud
|
||||
@onready var _turn_banner : TurnTransitionBanner = %TurnTransitionBanner
|
||||
|
||||
## Exposed so GameScreen can hand it to the Chat system.
|
||||
@onready var chat_bubble_host : Control = %ChatBubbleHost
|
||||
|
||||
var is_spectating: bool = false
|
||||
|
||||
# ── Lifecycle ─────────────────────────────────────────────────────────────────
|
||||
|
||||
func _ready() -> void:
|
||||
_draw_btn.pressed.connect(func() -> void: draw_requested.emit())
|
||||
_end_turn_btn.pressed.connect(func() -> void: end_turn_requested.emit())
|
||||
_settings_btn.pressed.connect(func() -> void: settings_requested.emit())
|
||||
_discard_btn.pressed.connect(func() -> void: show_own_discard(Game.state))
|
||||
_opp_discard_btn.pressed.connect(func() -> void: show_opp_discard(Game.state))
|
||||
_player_duel_hud.own_discard_requested.connect(func() -> void: show_own_discard(Game.state))
|
||||
_player_duel_hud.opponent_discard_requested.connect(func() -> void: show_opp_discard(Game.state))
|
||||
_dv_close_btn.pressed.connect(func() -> void: _dv_overlay.visible = false)
|
||||
_spectator_leave_btn.pressed.connect(func() -> void: spectator_leave_requested.emit())
|
||||
|
||||
# ── Public API ────────────────────────────────────────────────────────────────
|
||||
|
||||
func enter_spectator_mode() -> void:
|
||||
is_spectating = true
|
||||
_sp_st_panel.visible = false
|
||||
_deck_discard_panel.visible = false
|
||||
_draw_btn.visible = false
|
||||
_end_turn_btn.visible = false
|
||||
_player_duel_hud.visible = false
|
||||
_spectator_panel.visible = true
|
||||
_spectator_leave_btn.visible = true
|
||||
|
||||
|
||||
func update_hud(state: Dictionary) -> void:
|
||||
var phase: String = state.get("phase", "")
|
||||
var turn: int = state.get("turnNumber", 1)
|
||||
_phase_lbl.text = "TURN %d\n%s\nPhase: %s" % [
|
||||
turn,
|
||||
"YOUR TURN" if Game.is_my_turn() else "OPPONENT TURN",
|
||||
phase
|
||||
]
|
||||
_turn_banner.update_from_state(state, is_spectating)
|
||||
_player_duel_hud.update_from_state(state, is_spectating)
|
||||
|
||||
if is_spectating:
|
||||
update_hud_spectator(state)
|
||||
return
|
||||
|
||||
var is_mine: bool = Game.is_my_turn()
|
||||
var my: Dictionary = Game.get_my_player()
|
||||
var opp: Dictionary = Game.get_opponent()
|
||||
var all_players: Array = state.get("players", [])
|
||||
var is_duel: bool = all_players.size() == 2
|
||||
|
||||
_turn_lbl.text = "" if is_duel else "Turn %d - %s" % [turn, "Your turn" if is_mine else "Opponent's turn"]
|
||||
_turn_lbl.modulate = Color(0.4, 1.0, 0.5) if is_mine else Color(1.0, 0.6, 0.6)
|
||||
|
||||
_sp_lbl.text = "%d" % int(my.get("currentSp", 0))
|
||||
_st_lbl.text = "%d" % int(my.get("currentSt", 0))
|
||||
_deck_lbl.text = "%d" % int(my.get("deckCount", 0))
|
||||
var discard: Array = my.get("discard", [])
|
||||
_discard_lbl.text = "%d" % max(0, discard.size())
|
||||
|
||||
_opp_name_lbl.text = Game.get_display_name(str(opp.get("accountId", "")))
|
||||
_opp_hand_lbl.text = "Hand: %d" % int(opp.get("handCount", 0))
|
||||
_opp_deck_lbl.text = "Deck: %d" % int(opp.get("deckCount", 0))
|
||||
|
||||
if all_players.size() > 2:
|
||||
_opp_panel.visible = false
|
||||
_turn_order_strip.visible = true
|
||||
_sp_st_panel.visible = true
|
||||
_deck_discard_panel.visible = true
|
||||
rebuild_turn_order_strip(state)
|
||||
else:
|
||||
_opp_panel.visible = false
|
||||
_turn_order_strip.visible = false
|
||||
_sp_st_panel.visible = false
|
||||
_deck_discard_panel.visible = false
|
||||
|
||||
_draw_btn.visible = (phase == "Draw" and is_mine)
|
||||
_end_turn_btn.visible = (phase == "Main" and is_mine)
|
||||
_end_turn_btn.disabled = not is_mine
|
||||
|
||||
if phase == "Placement":
|
||||
var my_arch: Dictionary = my.get("archSpirit", {})
|
||||
var i_have_placed: bool = not my_arch.is_empty() and my_arch.get("position") != null
|
||||
if not i_have_placed:
|
||||
_phase_lbl.text = "TURN %d\nPLACEMENT\nPlace ArchSpirit" % turn
|
||||
else:
|
||||
_phase_lbl.text = "TURN %d\nPLACEMENT\nWaiting" % turn
|
||||
|
||||
|
||||
func update_hud_spectator(state: Dictionary) -> void:
|
||||
var turn: int = state.get("turnNumber", 1)
|
||||
var active_id: String = str(state.get("activePlayerAccountId", ""))
|
||||
var active_name: String = Game.get_display_name(active_id)
|
||||
_turn_lbl.text = "Turn %d — %s is acting" % [turn, active_name]
|
||||
_turn_lbl.modulate = Color(1.0, 0.76, 0.2)
|
||||
|
||||
_opp_panel.visible = false
|
||||
var all_players: Array = state.get("players", [])
|
||||
_turn_order_strip.visible = all_players.size() > 1
|
||||
if _turn_order_strip.visible:
|
||||
rebuild_turn_order_strip(state)
|
||||
|
||||
_draw_btn.visible = false
|
||||
_end_turn_btn.visible = false
|
||||
|
||||
rebuild_spectator_panel(state)
|
||||
|
||||
|
||||
func rebuild_spectator_panel(state: Dictionary) -> void:
|
||||
for c in _spectator_list.get_children():
|
||||
c.queue_free()
|
||||
|
||||
var active_id: String = str(state.get("activePlayerAccountId", ""))
|
||||
var players: Array = state.get("players", []).duplicate()
|
||||
var team_colors: Dictionary = state.get("teamColors", {})
|
||||
|
||||
players.sort_custom(func(a: Dictionary, b: Dictionary) -> bool:
|
||||
return int(a.get("seatIndex", 0)) < int(b.get("seatIndex", 0)))
|
||||
|
||||
for p: Dictionary in players:
|
||||
var pid: String = str(p.get("accountId", ""))
|
||||
var is_active: bool = pid == active_id
|
||||
var eliminated: bool = bool(p.get("isEliminated", false))
|
||||
var team_idx: int = int(p.get("teamIndex", -1))
|
||||
var hex_str: String = str(team_colors.get(str(team_idx), ""))
|
||||
var display: String = Game.get_display_name(pid)
|
||||
|
||||
var row: PanelContainer = PanelContainer.new()
|
||||
row.custom_minimum_size = Vector2(0, 40)
|
||||
row.self_modulate = Color(1, 1, 1, 0.4 if eliminated else 1.0)
|
||||
|
||||
var style: StyleBoxFlat = StyleBoxFlat.new()
|
||||
style.bg_color = Color(0.18, 0.16, 0.08, 0.92) if is_active else Color(0.10, 0.10, 0.13, 0.85)
|
||||
style.border_width_left = 4
|
||||
style.border_color = Color(1.0, 0.85, 0.2) if is_active \
|
||||
else (Color.html("#" + hex_str) if not hex_str.is_empty() else Color(0.4, 0.4, 0.4))
|
||||
row.add_theme_stylebox_override("panel", style)
|
||||
|
||||
var margin: MarginContainer = MarginContainer.new()
|
||||
margin.add_theme_constant_override("margin_left", 8)
|
||||
margin.add_theme_constant_override("margin_right", 8)
|
||||
margin.add_theme_constant_override("margin_top", 4)
|
||||
margin.add_theme_constant_override("margin_bottom", 4)
|
||||
row.add_child(margin)
|
||||
|
||||
var hbox: HBoxContainer = HBoxContainer.new()
|
||||
hbox.add_theme_constant_override("separation", 12)
|
||||
margin.add_child(hbox)
|
||||
|
||||
var name_lbl: Label = Label.new()
|
||||
name_lbl.text = ("★ " if is_active else "") + display + (" [X]" if eliminated else "")
|
||||
name_lbl.add_theme_font_size_override("font_size", 12)
|
||||
name_lbl.custom_minimum_size = Vector2(120, 0)
|
||||
name_lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
name_lbl.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
if is_active:
|
||||
name_lbl.add_theme_color_override("font_color", Color(1.0, 0.9, 0.3))
|
||||
elif eliminated:
|
||||
name_lbl.add_theme_color_override("font_color", Color(0.4, 0.4, 0.4))
|
||||
hbox.add_child(name_lbl)
|
||||
|
||||
var sp_lbl_row: Label = Label.new()
|
||||
sp_lbl_row.text = "SP: %d" % int(p.get("currentSp", 0))
|
||||
sp_lbl_row.add_theme_font_size_override("font_size", 11)
|
||||
sp_lbl_row.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
sp_lbl_row.tooltip_text = "Spirit Points"
|
||||
hbox.add_child(sp_lbl_row)
|
||||
|
||||
var st_lbl_row: Label = Label.new()
|
||||
st_lbl_row.text = "ST: %d" % int(p.get("currentSt", 0))
|
||||
st_lbl_row.add_theme_font_size_override("font_size", 11)
|
||||
st_lbl_row.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
st_lbl_row.tooltip_text = "Sacrifice Tokens"
|
||||
hbox.add_child(st_lbl_row)
|
||||
|
||||
var deck_lbl_row: Label = Label.new()
|
||||
deck_lbl_row.text = "Deck: %d" % int(p.get("deckCount", 0))
|
||||
deck_lbl_row.add_theme_font_size_override("font_size", 11)
|
||||
deck_lbl_row.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
hbox.add_child(deck_lbl_row)
|
||||
|
||||
var disc_cards: Array = p.get("discard", [])
|
||||
var disc_count: int = disc_cards.size() if not disc_cards.is_empty() else int(p.get("discardCount", 0))
|
||||
var disc_btn: Button = Button.new()
|
||||
disc_btn.text = "Discard: %d" % disc_count
|
||||
disc_btn.add_theme_font_size_override("font_size", 11)
|
||||
disc_btn.custom_minimum_size = Vector2(80, 0)
|
||||
if not disc_cards.is_empty():
|
||||
var cap_display: String = display
|
||||
var cap_cards: Array = disc_cards
|
||||
disc_btn.pressed.connect(func() -> void:
|
||||
show_discard_for("%s Discard" % cap_display, cap_cards))
|
||||
else:
|
||||
disc_btn.disabled = true
|
||||
hbox.add_child(disc_btn)
|
||||
|
||||
_spectator_list.add_child(row)
|
||||
|
||||
|
||||
func rebuild_turn_order_strip(state: Dictionary) -> void:
|
||||
for c in _turn_order_strip.get_children():
|
||||
c.queue_free()
|
||||
|
||||
var active_id: String = str(state.get("activePlayerAccountId", ""))
|
||||
var players: Array = state.get("players", []).duplicate()
|
||||
var team_colors: Dictionary = state.get("teamColors", {})
|
||||
|
||||
players.sort_custom(func(a: Dictionary, b: Dictionary) -> bool:
|
||||
return int(a.get("seatIndex", 0)) < int(b.get("seatIndex", 0)))
|
||||
|
||||
for p: Dictionary in players:
|
||||
var pid: String = str(p.get("accountId", ""))
|
||||
var is_me: bool = (not is_spectating) and pid == Auth.user_id
|
||||
var is_active: bool = pid == active_id
|
||||
var eliminated: bool = bool(p.get("isEliminated", false))
|
||||
var team_idx: int = int(p.get("teamIndex", -1))
|
||||
var hex_str: String = str(team_colors.get(str(team_idx), ""))
|
||||
var display: String = "You" if is_me else Game.get_display_name(pid)
|
||||
|
||||
var chip: PanelContainer = PanelContainer.new()
|
||||
chip.custom_minimum_size = Vector2(72, 36)
|
||||
chip.self_modulate = Color(1, 1, 1, 0.3 if eliminated else (0.95 if is_active else 0.6))
|
||||
chip.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
|
||||
var style: StyleBoxFlat = StyleBoxFlat.new()
|
||||
style.bg_color = Color(0.12, 0.12, 0.14, 0.85)
|
||||
style.border_width_left = 3
|
||||
if not hex_str.is_empty():
|
||||
style.border_color = Color.html("#" + hex_str)
|
||||
else:
|
||||
style.border_color = Color(0.4, 0.4, 0.4)
|
||||
chip.add_theme_stylebox_override("panel", style)
|
||||
|
||||
var lbl: Label = Label.new()
|
||||
lbl.text = ("★ " if is_active else "") + display + (" ✗" if eliminated else "")
|
||||
lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
lbl.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
lbl.add_theme_font_size_override("font_size", 10)
|
||||
lbl.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
if is_active:
|
||||
lbl.add_theme_color_override("font_color", Color(1.0, 0.9, 0.3))
|
||||
elif eliminated:
|
||||
lbl.add_theme_color_override("font_color", Color(0.4, 0.4, 0.4))
|
||||
elif is_me:
|
||||
lbl.add_theme_color_override("font_color", Color(0.5, 1.0, 0.5))
|
||||
|
||||
if not is_me:
|
||||
var sp: int = int(p.get("currentSp", 0))
|
||||
var st: int = int(p.get("currentSt", 0))
|
||||
var hand: int = int(p.get("handCount", 0))
|
||||
var deck: int = int(p.get("deckCount", 0))
|
||||
chip.tooltip_text = "%s\nSP: %d ST: %d\nHand: %d Deck: %d" % [
|
||||
display, sp, st, hand, deck]
|
||||
|
||||
chip.add_child(lbl)
|
||||
_turn_order_strip.add_child(chip)
|
||||
|
||||
|
||||
func show_own_discard(state: Dictionary) -> void:
|
||||
show_discard_for("Your Discard", Game.get_my_player().get("discard", []))
|
||||
|
||||
|
||||
func show_opp_discard(state: Dictionary) -> void:
|
||||
show_discard_for("Opponent Discard", Game.get_opponent().get("discard", []))
|
||||
|
||||
|
||||
func show_discard_for(title: String, cards: Array) -> void:
|
||||
_dv_title.text = "%s (%d)" % [title, cards.size()]
|
||||
_dv_overlay.move_to_front()
|
||||
for c in _dv_list.get_children():
|
||||
c.queue_free()
|
||||
if cards.is_empty():
|
||||
var lbl: Label = Label.new()
|
||||
lbl.text = "(empty)"
|
||||
lbl.add_theme_color_override("font_color", Color(0.55, 0.55, 0.6))
|
||||
_dv_list.add_child(lbl)
|
||||
else:
|
||||
for card: Dictionary in cards:
|
||||
_dv_list.add_child(make_discard_row(card))
|
||||
_dv_overlay.visible = true
|
||||
|
||||
|
||||
func make_discard_row(card: Dictionary) -> Control:
|
||||
var hbox: HBoxContainer = HBoxContainer.new()
|
||||
hbox.add_theme_constant_override("separation", 8)
|
||||
hbox.custom_minimum_size = Vector2(0, 32)
|
||||
var type_lbl: Label = Label.new()
|
||||
type_lbl.text = "[%s]" % card.get("cardType", "?")
|
||||
type_lbl.add_theme_font_size_override("font_size", 11)
|
||||
type_lbl.add_theme_color_override("font_color", Color(0.6, 0.6, 0.7))
|
||||
type_lbl.custom_minimum_size = Vector2(90, 0)
|
||||
type_lbl.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
hbox.add_child(type_lbl)
|
||||
var name_lbl: Label = Label.new()
|
||||
name_lbl.text = card.get("name", "Unknown")
|
||||
name_lbl.add_theme_font_size_override("font_size", 13)
|
||||
name_lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
name_lbl.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
hbox.add_child(name_lbl)
|
||||
var aff_lbl: Label = Label.new()
|
||||
aff_lbl.text = card.get("affinity", "")
|
||||
aff_lbl.add_theme_font_size_override("font_size", 11)
|
||||
aff_lbl.add_theme_color_override("font_color", Color(0.6, 0.7, 0.85))
|
||||
aff_lbl.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
hbox.add_child(aff_lbl)
|
||||
return hbox
|
||||
@@ -0,0 +1 @@
|
||||
uid://c0cr5qgneoab1
|
||||
@@ -0,0 +1,432 @@
|
||||
[gd_scene load_steps=17 format=3 uid="uid://doy6e5sb5bk48"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c0cr5qgneoab1" path="res://scenes/game/components/hud/hud_controller.gd" id="1_script"]
|
||||
[ext_resource type="Texture2D" uid="uid://dvmripj4jux0b" path="res://icons/SP-Symbol-White.png" id="2_sp"]
|
||||
[ext_resource type="Texture2D" uid="uid://csvmdo2kwnh7c" path="res://icons/ST-Symbol-White.png" id="3_st"]
|
||||
[ext_resource type="Texture2D" uid="uid://beyeu0y34m3v4" path="res://ui/icons/Deck Icon.png" id="4_deck"]
|
||||
[ext_resource type="Texture2D" uid="uid://c65s8sn4p7s37" path="res://ui/icons/Discard Icon.png" id="5_discard"]
|
||||
[ext_resource type="PackedScene" uid="uid://b4ogwqj0xql6y" path="res://scenes/game/components/hud/player_duel_hud.tscn" id="6_duel"]
|
||||
[ext_resource type="Script" uid="uid://kofrp8y3wdxj" path="res://scenes/game/components/hud/turn_transition_banner.gd" id="7_banner"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_spst"]
|
||||
|
||||
[sub_resource type="Theme" id="Theme_tex"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_action"]
|
||||
bg_color = Color(0.38039216, 0.38039216, 0.38039216, 0.58431375)
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_disc_normal"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_disc_pressed"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_disc_hover"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_disc_hovpressed"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_disc_disabled"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_disc_focus"]
|
||||
|
||||
[node name="HudController" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
script = ExtResource("1_script")
|
||||
|
||||
[node name="TopBar" type="HBoxContainer" parent="."]
|
||||
layout_mode = 0
|
||||
anchor_right = 1.0
|
||||
offset_bottom = 96.0
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="PhaseLabel" type="Label" parent="TopBar"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(154, 84)
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.74, 0.96, 1, 1)
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "TURN 1
|
||||
YOUR TURN
|
||||
Phase: Main"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="TurnLabel" type="Label" parent="TopBar"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 13
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="TurnOrderStrip" type="HBoxContainer" parent="TopBar"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="OpponentPanel" type="HBoxContainer" parent="TopBar"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(240, 48)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="OppNameLabel" type="Label" parent="TopBar/OpponentPanel"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(1, 0.5, 0.5, 1)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Opponent"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="OppHandLabel" type="Label" parent="TopBar/OpponentPanel"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Hand: 0"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="OppDeckLabel" type="Label" parent="TopBar/OpponentPanel"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Deck: 0"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="OppDiscardBtn" type="Button" parent="TopBar/OpponentPanel"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 11
|
||||
text = "Discard"
|
||||
|
||||
[node name="PlayerDuelHud" parent="." instance=ExtResource("6_duel")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
|
||||
[node name="TurnTransitionBanner" type="Control" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
script = ExtResource("7_banner")
|
||||
|
||||
[node name="SP-ST Panel Container" type="PanelContainer" parent="."]
|
||||
visible = false
|
||||
layout_mode = 0
|
||||
anchor_top = 0.675
|
||||
anchor_bottom = 0.675
|
||||
offset_top = -156.40002
|
||||
offset_right = 76.0
|
||||
offset_bottom = -0.4000244
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_spst")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="SP-ST Panel Container"]
|
||||
layout_mode = 2
|
||||
alignment = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="SP-ST Panel Container/VBoxContainer"]
|
||||
self_modulate = Color(0, 0.8117647, 0.77254903, 0.38039216)
|
||||
texture_filter = 5
|
||||
custom_minimum_size = Vector2(1.78, 76)
|
||||
layout_mode = 2
|
||||
theme = SubResource("Theme_tex")
|
||||
texture = ExtResource("2_sp")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="SpLabel" type="Label" parent="SP-ST Panel Container/VBoxContainer/TextureRect"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.513
|
||||
anchor_top = 0.36800003
|
||||
anchor_right = 0.513
|
||||
anchor_bottom = 0.36800003
|
||||
offset_left = -18.987999
|
||||
offset_top = -22.968002
|
||||
offset_right = 19.012001
|
||||
offset_bottom = 23.031998
|
||||
tooltip_text = "Spirit Points"
|
||||
mouse_filter = 1
|
||||
theme_override_colors/font_color = Color(0.012617188, 0.012617188, 0.012617188, 1)
|
||||
theme_override_font_sizes/font_size = 33
|
||||
text = "88"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="TextureRect2" type="TextureRect" parent="SP-ST Panel Container/VBoxContainer"]
|
||||
self_modulate = Color(0, 0.8117647, 0.77254903, 0.38039216)
|
||||
texture_filter = 5
|
||||
custom_minimum_size = Vector2(1.78, 76)
|
||||
layout_mode = 2
|
||||
theme = SubResource("Theme_tex")
|
||||
texture = ExtResource("3_st")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="StLabel" type="Label" parent="SP-ST Panel Container/VBoxContainer/TextureRect2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.32200003
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.32200003
|
||||
offset_left = -20.0
|
||||
offset_top = -20.472002
|
||||
offset_right = 22.0
|
||||
offset_bottom = 25.527998
|
||||
tooltip_text = "Sacrifice Tokens"
|
||||
mouse_filter = 1
|
||||
theme_override_colors/font_color = Color(0.06469653, 0.06469653, 0.06469653, 1)
|
||||
theme_override_font_sizes/font_size = 33
|
||||
text = "88"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="ActionRail" type="PanelContainer" parent="."]
|
||||
layout_mode = 0
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -262.0
|
||||
offset_top = -220.0
|
||||
offset_right = -70.0
|
||||
offset_bottom = -56.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_action")
|
||||
|
||||
[node name="RailMargin" type="MarginContainer" parent="ActionRail"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="RailHBox" type="HBoxContainer" parent="ActionRail/RailMargin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 12
|
||||
|
||||
[node name="Deck-Discard Panel Container" type="Control" parent="ActionRail/RailMargin/RailHBox"]
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(76, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
alignment = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container/VBoxContainer"]
|
||||
self_modulate = Color(0, 0.8117647, 0.77254903, 0.38039216)
|
||||
texture_filter = 5
|
||||
custom_minimum_size = Vector2(1.78, 76)
|
||||
layout_mode = 2
|
||||
theme = SubResource("Theme_tex")
|
||||
texture = ExtResource("4_deck")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="DeckLabel" type="Label" parent="ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container/VBoxContainer/TextureRect"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.507
|
||||
anchor_top = 0.40789473
|
||||
anchor_right = 0.507
|
||||
anchor_bottom = 0.40789473
|
||||
offset_left = -22.532001
|
||||
offset_top = -36.0
|
||||
offset_right = 22.467999
|
||||
offset_bottom = 10.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
tooltip_text = "Cards in Deck"
|
||||
mouse_filter = 1
|
||||
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||
theme_override_font_sizes/font_size = 33
|
||||
text = "88"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="TextureRect2" type="TextureRect" parent="ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container/VBoxContainer"]
|
||||
self_modulate = Color(0, 0.8117647, 0.77254903, 0.38039216)
|
||||
texture_filter = 5
|
||||
custom_minimum_size = Vector2(1.78, 76)
|
||||
layout_mode = 2
|
||||
theme = SubResource("Theme_tex")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="DiscardBtn" type="Button" parent="ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container/VBoxContainer/TextureRect2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_left = -4.000001
|
||||
offset_top = -5.000001
|
||||
offset_right = 568.0
|
||||
offset_bottom = 275.0
|
||||
scale = Vector2(0.14754085, 0.23068035)
|
||||
tooltip_text = "View Discard"
|
||||
theme_override_colors/icon_normal_color = Color(0.18431373, 0.49411765, 0.47843137, 1)
|
||||
theme_override_colors/icon_focus_color = Color(0.18431373, 0.49411765, 0.47843137, 1)
|
||||
theme_override_colors/icon_pressed_color = Color(0.35976923, 0.7944459, 0.77106035, 1)
|
||||
theme_override_colors/icon_hover_color = Color(0.18431373, 0.49411765, 0.47843137, 1)
|
||||
theme_override_colors/icon_hover_pressed_color = Color(0.18431373, 0.49411765, 0.47843137, 1)
|
||||
theme_override_font_sizes/font_size = 12
|
||||
theme_override_icons/icon = ExtResource("5_discard")
|
||||
theme_override_styles/normal = SubResource("StyleBoxEmpty_disc_normal")
|
||||
theme_override_styles/pressed = SubResource("StyleBoxEmpty_disc_pressed")
|
||||
theme_override_styles/hover = SubResource("StyleBoxEmpty_disc_hover")
|
||||
theme_override_styles/hover_pressed = SubResource("StyleBoxEmpty_disc_hovpressed")
|
||||
theme_override_styles/disabled = SubResource("StyleBoxEmpty_disc_disabled")
|
||||
theme_override_styles/focus = SubResource("StyleBoxEmpty_disc_focus")
|
||||
|
||||
[node name="DiscardLabel" type="Label" parent="ActionRail/RailMargin/RailHBox/Deck-Discard Panel Container/VBoxContainer/TextureRect2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.32200003
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.32200003
|
||||
offset_left = -20.0
|
||||
offset_top = -31.472002
|
||||
offset_right = 22.0
|
||||
offset_bottom = 14.527998
|
||||
theme_override_colors/font_color = Color(0.06469653, 0.06469653, 0.06469653, 1)
|
||||
theme_override_font_sizes/font_size = 33
|
||||
text = "88"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Controls" type="Control" parent="ActionRail/RailMargin/RailHBox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="RightVBox" type="VBoxContainer" parent="ActionRail/RailMargin/RailHBox/Controls"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/separation = 6
|
||||
|
||||
[node name="EndTurnBtn" type="Button" parent="ActionRail/RailMargin/RailHBox/Controls/RightVBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "End Turn"
|
||||
|
||||
[node name="DrawBtn" type="Button" parent="ActionRail/RailMargin/RailHBox/Controls/RightVBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Draw Card"
|
||||
|
||||
[node name="SettingsBtn" type="Button" parent="ActionRail/RailMargin/RailHBox/Controls/RightVBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Settings"
|
||||
|
||||
[node name="ChatBubbleHost" type="Control" parent="ActionRail/RailMargin/RailHBox/Controls/RightVBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="SpectatorLeaveBtn" type="Button" parent="ActionRail/RailMargin/RailHBox/Controls/RightVBox"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Leave Spectator"
|
||||
|
||||
[node name="DiscardViewer" type="PanelContainer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 0
|
||||
anchor_left = 0.1
|
||||
anchor_top = 0.05
|
||||
anchor_right = 0.9
|
||||
anchor_bottom = 0.95
|
||||
|
||||
[node name="DVMargin" type="MarginContainer" parent="DiscardViewer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 16
|
||||
theme_override_constants/margin_top = 12
|
||||
theme_override_constants/margin_right = 16
|
||||
theme_override_constants/margin_bottom = 12
|
||||
|
||||
[node name="DVVBox" type="VBoxContainer" parent="DiscardViewer/DVMargin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="DVTitle" type="Label" parent="DiscardViewer/DVMargin/DVVBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 16
|
||||
text = "Discard Pile"
|
||||
|
||||
[node name="DVScroll" type="ScrollContainer" parent="DiscardViewer/DVMargin/DVVBox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="DVList" type="VBoxContainer" parent="DiscardViewer/DVMargin/DVVBox/DVScroll"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="DVCloseBtn" type="Button" parent="DiscardViewer/DVMargin/DVVBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 36)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "Close"
|
||||
|
||||
[node name="SpectatorPlayersPanel" type="PanelContainer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.75
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -200.0
|
||||
|
||||
[node name="SpectatorMargin" type="MarginContainer" parent="SpectatorPlayersPanel"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="SpectatorScroll" type="ScrollContainer" parent="SpectatorPlayersPanel/SpectatorMargin"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="SpectatorPlayerList" type="VBoxContainer" parent="SpectatorPlayersPanel/SpectatorMargin/SpectatorScroll"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 4
|
||||
@@ -0,0 +1,212 @@
|
||||
class_name PlayerDuelHud
|
||||
extends Control
|
||||
|
||||
const DEFAULT_CARD_ART_URL := "https://cdn.aeternalisgames.com/sor-assets/cardart/0_No-Card-Art.jpg"
|
||||
const CDN_BASE_URL := "https://cdn.aeternalisgames.com"
|
||||
const CDN_PROXY_BASE_URL := "https://hub.aeternalisgames.com/cdn"
|
||||
static var _texture_cache: Dictionary = {}
|
||||
|
||||
signal own_discard_requested
|
||||
signal opponent_discard_requested
|
||||
|
||||
@onready var _opp_name_lbl: Label = %OppNameLabel
|
||||
@onready var _opp_arch_lbl: Label = %OppArchLabel
|
||||
@onready var _opp_hp_lbl: Label = %OppHpLabel
|
||||
@onready var _opp_hp_bar: ProgressBar = %OppHpBar
|
||||
@onready var _opp_sp_lbl: Label = %OppSpLabel
|
||||
@onready var _opp_st_lbl: Label = %OppStLabel
|
||||
@onready var _opp_hand_lbl: Label = %OppHandLabel
|
||||
@onready var _opp_deck_lbl: Label = %OppDeckLabel
|
||||
@onready var _opp_discard_btn: Button = %OppDiscardBtn
|
||||
@onready var _opp_portrait: TextureRect = %OppPortrait
|
||||
|
||||
@onready var _self_hp_lbl: Label = %SelfHpLabel
|
||||
@onready var _self_hp_bar: ProgressBar = %SelfHpBar
|
||||
@onready var _self_sp_lbl: Label = %SelfSpLabel
|
||||
@onready var _self_st_lbl: Label = %SelfStLabel
|
||||
@onready var _self_hand_lbl: Label = %SelfHandLabel
|
||||
@onready var _self_deck_lbl: Label = %SelfDeckLabel
|
||||
@onready var _self_discard_lbl: Label = %SelfDiscardLabel
|
||||
@onready var _self_discard_btn: TextureButton = %SelfDiscardBtn
|
||||
@onready var _self_portrait: TextureRect = %SelfPortrait
|
||||
@onready var _archspirit_mask: TextureRect = %ArchspiritMask
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
_self_portrait.material = _make_portrait_mask_material()
|
||||
_self_discard_btn.pressed.connect(func() -> void: own_discard_requested.emit())
|
||||
_opp_discard_btn.pressed.connect(func() -> void: opponent_discard_requested.emit())
|
||||
|
||||
|
||||
func update_from_state(state: Dictionary, spectating: bool) -> void:
|
||||
var players: Array = state.get("players", [])
|
||||
visible = not spectating and players.size() == 2
|
||||
if not visible:
|
||||
return
|
||||
|
||||
_apply_player(Game.get_my_player(), true)
|
||||
_apply_player(Game.get_opponent(), false)
|
||||
|
||||
|
||||
func _apply_player(player: Dictionary, self_side: bool) -> void:
|
||||
if player.is_empty():
|
||||
return
|
||||
|
||||
var arch_raw: Variant = player.get("archSpirit", {})
|
||||
var arch: Dictionary = {}
|
||||
if arch_raw is Dictionary:
|
||||
arch = arch_raw as Dictionary
|
||||
var def_id := str(arch.get("cardDefinitionId", ""))
|
||||
var def := ContentCache.get_definition(def_id)
|
||||
var current_hp := int(arch.get("currentHealth", 0))
|
||||
var max_hp := int(arch.get("maxHealth", def.get("maxHealth", max(1, current_hp))))
|
||||
max_hp = max(1, max_hp)
|
||||
|
||||
var discard_raw: Variant = player.get("discard", [])
|
||||
var discard: Array = []
|
||||
if discard_raw is Array:
|
||||
discard = discard_raw as Array
|
||||
var discard_count := discard.size() if not discard.is_empty() else int(player.get("discardCount", 0))
|
||||
|
||||
if self_side:
|
||||
_self_hp_lbl.text = "HP %d/%d" % [current_hp, max_hp]
|
||||
_self_hp_bar.max_value = max_hp
|
||||
_self_hp_bar.value = clampi(current_hp, 0, max_hp)
|
||||
_self_sp_lbl.text = "%d" % int(player.get("currentSp", 0))
|
||||
_self_st_lbl.text = "%d" % int(player.get("currentSt", 0))
|
||||
_self_hand_lbl.text = "%d" % int(player.get("handCount", 0))
|
||||
_self_deck_lbl.text = "%d" % int(player.get("deckCount", 0))
|
||||
_self_discard_lbl.text = "%d" % discard_count
|
||||
_set_remote_texture(_self_portrait, _find_card_art_url(def))
|
||||
else:
|
||||
var account_id := str(player.get("accountId", ""))
|
||||
_opp_name_lbl.text = Game.get_display_name(account_id)
|
||||
_opp_arch_lbl.text = str(arch.get("name", def.get("name", "ArchSpirit")))
|
||||
_opp_hp_lbl.text = "HP %d/%d" % [current_hp, max_hp]
|
||||
_opp_hp_bar.max_value = max_hp
|
||||
_opp_hp_bar.value = clampi(current_hp, 0, max_hp)
|
||||
_opp_sp_lbl.text = "%d" % int(player.get("currentSp", 0))
|
||||
_opp_st_lbl.text = "%d" % int(player.get("currentSt", 0))
|
||||
_opp_hand_lbl.text = "Hand %d" % int(player.get("handCount", 0))
|
||||
_opp_deck_lbl.text = "Deck %d" % int(player.get("deckCount", 0))
|
||||
_opp_discard_btn.text = "Discard %d" % discard_count
|
||||
_set_remote_texture(_opp_portrait, _find_card_art_url(def))
|
||||
|
||||
|
||||
func _find_card_art_url(def: Dictionary) -> String:
|
||||
var assets: Variant = def.get("assets", [])
|
||||
if typeof(assets) != TYPE_ARRAY:
|
||||
return DEFAULT_CARD_ART_URL
|
||||
|
||||
for asset in assets as Array:
|
||||
if typeof(asset) != TYPE_DICTIONARY:
|
||||
continue
|
||||
var d := asset as Dictionary
|
||||
if str(d.get("assetType", "")) == "Art2D":
|
||||
return str(d.get("cdnUrl", DEFAULT_CARD_ART_URL))
|
||||
|
||||
return DEFAULT_CARD_ART_URL
|
||||
|
||||
|
||||
func _set_remote_texture(target: TextureRect, url: String) -> void:
|
||||
if url.is_empty() or not is_instance_valid(target):
|
||||
return
|
||||
|
||||
var cached: Variant = _texture_cache.get(url, null)
|
||||
if cached != null:
|
||||
target.texture = cached as Texture2D
|
||||
return
|
||||
|
||||
if not url.begins_with("http"):
|
||||
return
|
||||
|
||||
var requester := HTTPRequest.new()
|
||||
requester.use_threads = true
|
||||
add_child(requester)
|
||||
requester.request_completed.connect(
|
||||
func(result: int, response_code: int, _headers: PackedStringArray, body: PackedByteArray) -> void:
|
||||
if result == HTTPRequest.RESULT_SUCCESS and response_code >= 200 and response_code < 300:
|
||||
var texture := _texture_from_bytes(url, body)
|
||||
if texture != null:
|
||||
_texture_cache[url] = texture
|
||||
if is_instance_valid(target):
|
||||
target.texture = texture
|
||||
elif url != DEFAULT_CARD_ART_URL:
|
||||
_set_remote_texture(target, DEFAULT_CARD_ART_URL)
|
||||
elif url != DEFAULT_CARD_ART_URL:
|
||||
_set_remote_texture(target, DEFAULT_CARD_ART_URL)
|
||||
requester.queue_free()
|
||||
)
|
||||
var err := requester.request(_fetch_url(url))
|
||||
if err != OK:
|
||||
requester.queue_free()
|
||||
if url != DEFAULT_CARD_ART_URL:
|
||||
_set_remote_texture(target, DEFAULT_CARD_ART_URL)
|
||||
|
||||
|
||||
func _texture_from_bytes(url: String, body: PackedByteArray) -> Texture2D:
|
||||
var image := Image.new()
|
||||
var err := _load_image_from_bytes(image, url, body)
|
||||
if err != OK:
|
||||
return null
|
||||
return ImageTexture.create_from_image(image)
|
||||
|
||||
|
||||
func _fetch_url(url: String) -> String:
|
||||
if OS.has_feature("web") and url.begins_with(CDN_BASE_URL + "/"):
|
||||
return CDN_PROXY_BASE_URL + "/" + url.substr(CDN_BASE_URL.length() + 1)
|
||||
return url
|
||||
|
||||
|
||||
func _load_image_from_bytes(image: Image, url: String, body: PackedByteArray) -> Error:
|
||||
var ext := url.get_file().get_extension().to_lower()
|
||||
var err := ERR_FILE_UNRECOGNIZED
|
||||
var sniffed := _sniff_image_format(body)
|
||||
var format := sniffed if not sniffed.is_empty() else ext
|
||||
|
||||
match format:
|
||||
"png":
|
||||
err = image.load_png_from_buffer(body)
|
||||
"jpg", "jpeg":
|
||||
err = image.load_jpg_from_buffer(body)
|
||||
"webp":
|
||||
err = image.load_webp_from_buffer(body)
|
||||
"svg":
|
||||
err = image.load_svg_from_buffer(body)
|
||||
return err
|
||||
|
||||
|
||||
func _sniff_image_format(body: PackedByteArray) -> String:
|
||||
if body.size() >= 8 \
|
||||
and body[0] == 0x89 and body[1] == 0x50 and body[2] == 0x4E and body[3] == 0x47 \
|
||||
and body[4] == 0x0D and body[5] == 0x0A and body[6] == 0x1A and body[7] == 0x0A:
|
||||
return "png"
|
||||
if body.size() >= 3 and body[0] == 0xFF and body[1] == 0xD8 and body[2] == 0xFF:
|
||||
return "jpg"
|
||||
if body.size() >= 12 \
|
||||
and body[0] == 0x52 and body[1] == 0x49 and body[2] == 0x46 and body[3] == 0x46 \
|
||||
and body[8] == 0x57 and body[9] == 0x45 and body[10] == 0x42 and body[11] == 0x50:
|
||||
return "webp"
|
||||
var preview := body.slice(0, mini(body.size(), 128)).get_string_from_utf8().strip_edges().to_lower()
|
||||
if preview.begins_with("<svg") or preview.begins_with("<?xml"):
|
||||
return "svg"
|
||||
return ""
|
||||
|
||||
|
||||
func _make_portrait_mask_material() -> ShaderMaterial:
|
||||
var shader := Shader.new()
|
||||
shader.code = """
|
||||
shader_type canvas_item;
|
||||
uniform sampler2D mask_tex;
|
||||
|
||||
void fragment() {
|
||||
vec4 color = texture(TEXTURE, UV);
|
||||
float mask_alpha = texture(mask_tex, UV).a;
|
||||
COLOR = vec4(color.rgb, color.a * mask_alpha);
|
||||
}
|
||||
"""
|
||||
var material := ShaderMaterial.new()
|
||||
material.shader = shader
|
||||
material.set_shader_parameter("mask_tex", _archspirit_mask.texture)
|
||||
return material
|
||||
@@ -0,0 +1 @@
|
||||
uid://v6rfnn2v3o73
|
||||
@@ -0,0 +1,588 @@
|
||||
[gd_scene load_steps=18 format=3 uid="uid://b4ogwqj0xql6y"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://v6rfnn2v3o73" path="res://scenes/game/components/hud/player_duel_hud.gd" id="1_script"]
|
||||
[ext_resource type="Texture2D" uid="uid://dvmripj4jux0b" path="res://icons/SP-Symbol-White.png" id="2_sp"]
|
||||
[ext_resource type="Texture2D" uid="uid://csvmdo2kwnh7c" path="res://icons/ST-Symbol-White.png" id="3_st"]
|
||||
[ext_resource type="Texture2D" uid="uid://cle8yc2o6vd2t" path="res://ui/icons/Archspirit Portrait Flair Background.png" id="4_flair"]
|
||||
[ext_resource type="Texture2D" uid="uid://s4q1bm6vkawk" path="res://ui/icons/Archspirit Portrait Light Reflection.png" id="5_light"]
|
||||
[ext_resource type="Texture2D" uid="uid://duilm8ch2kr05" path="res://ui/icons/Archspirit Portrait Outline.png" id="6_outline"]
|
||||
[ext_resource type="Texture2D" uid="uid://btflxbnlm1mja" path="res://ui/icons/Archspirit Portrait Shadow.png" id="7_shadow"]
|
||||
[ext_resource type="Texture2D" uid="uid://moqusmwltqh2" path="res://ui/icons/Archspirit Mask.png" id="8_mask"]
|
||||
[ext_resource type="Texture2D" uid="uid://beyeu0y34m3v4" path="res://ui/icons/Deck Icon.png" id="9_deck"]
|
||||
[ext_resource type="Texture2D" uid="uid://c65s8sn4p7s37" path="res://ui/icons/Discard Icon.png" id="10_discard"]
|
||||
[ext_resource type="Texture2D" uid="uid://bwgtejjr5gwi4" path="res://ui/icons/Hand Icon.png" id="11_hand"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="Panel_opp"]
|
||||
bg_color = Color(0.03, 0.07, 0.1, 0.78)
|
||||
border_width_left = 1
|
||||
border_width_top = 1
|
||||
border_width_right = 1
|
||||
border_width_bottom = 1
|
||||
border_color = Color(0.13, 0.75, 0.84, 0.75)
|
||||
corner_radius_top_left = 6
|
||||
corner_radius_top_right = 6
|
||||
corner_radius_bottom_right = 6
|
||||
corner_radius_bottom_left = 6
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="Hp_bg"]
|
||||
bg_color = Color(0.09, 0.07, 0.08, 0.95)
|
||||
corner_radius_top_left = 4
|
||||
corner_radius_top_right = 4
|
||||
corner_radius_bottom_right = 4
|
||||
corner_radius_bottom_left = 4
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="Hp_fill"]
|
||||
bg_color = Color(0.88, 0.22, 0.35, 0.95)
|
||||
corner_radius_top_left = 4
|
||||
corner_radius_top_right = 4
|
||||
corner_radius_bottom_right = 4
|
||||
corner_radius_bottom_left = 4
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="Panel_pill"]
|
||||
bg_color = Color(0.14, 0.16, 0.2, 0.82)
|
||||
border_width_left = 1
|
||||
border_width_top = 1
|
||||
border_width_right = 1
|
||||
border_width_bottom = 1
|
||||
border_color = Color(0.7, 0.95, 1, 0.16)
|
||||
corner_radius_top_left = 6
|
||||
corner_radius_top_right = 6
|
||||
corner_radius_bottom_right = 6
|
||||
corner_radius_bottom_left = 6
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="Panel_pill_hover"]
|
||||
bg_color = Color(0.24, 0.26, 0.31, 0.88)
|
||||
border_width_left = 1
|
||||
border_width_top = 1
|
||||
border_width_right = 1
|
||||
border_width_bottom = 1
|
||||
border_color = Color(0.7, 0.95, 1, 0.35)
|
||||
corner_radius_top_left = 6
|
||||
corner_radius_top_right = 6
|
||||
corner_radius_bottom_right = 6
|
||||
corner_radius_bottom_left = 6
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="Panel_hp"]
|
||||
bg_color = Color(0.42, 0.06, 0.12, 0.88)
|
||||
border_width_left = 1
|
||||
border_width_top = 1
|
||||
border_width_right = 1
|
||||
border_width_bottom = 1
|
||||
border_color = Color(0.8, 0.28, 0.36, 1)
|
||||
corner_radius_top_left = 6
|
||||
corner_radius_top_right = 6
|
||||
corner_radius_bottom_right = 6
|
||||
corner_radius_bottom_left = 6
|
||||
|
||||
[node name="PlayerDuelHud" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
script = ExtResource("1_script")
|
||||
|
||||
[node name="OpponentStatusBand" type="PanelContainer" parent="."]
|
||||
layout_mode = 0
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -310.0
|
||||
offset_top = 8.0
|
||||
offset_right = 310.0
|
||||
offset_bottom = 92.0
|
||||
grow_horizontal = 2
|
||||
mouse_filter = 2
|
||||
theme_override_styles/panel = SubResource("Panel_opp")
|
||||
|
||||
[node name="OppMargin" type="MarginContainer" parent="OpponentStatusBand"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_top = 6
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 6
|
||||
|
||||
[node name="OppRow" type="HBoxContainer" parent="OpponentStatusBand/OppMargin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="OppInfo" type="VBoxContainer" parent="OpponentStatusBand/OppMargin/OppRow"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 3
|
||||
|
||||
[node name="OppNameLabel" type="Label" parent="OpponentStatusBand/OppMargin/OppRow/OppInfo"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(1, 0.62, 0.7, 1)
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Opponent"
|
||||
text_overrun_behavior = 3
|
||||
|
||||
[node name="OppArchLabel" type="Label" parent="OpponentStatusBand/OppMargin/OppRow/OppInfo"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.62, 0.7, 0.78, 1)
|
||||
theme_override_font_sizes/font_size = 10
|
||||
text = "ArchSpirit"
|
||||
text_overrun_behavior = 3
|
||||
|
||||
[node name="OppHpRow" type="HBoxContainer" parent="OpponentStatusBand/OppMargin/OppRow/OppInfo"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 6
|
||||
|
||||
[node name="OppHpLabel" type="Label" parent="OpponentStatusBand/OppMargin/OppRow/OppInfo/OppHpRow"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(62, 0)
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(1, 0.48, 0.55, 1)
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "HP 0"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="OppHpBar" type="ProgressBar" parent="OpponentStatusBand/OppMargin/OppRow/OppInfo/OppHpRow"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 12)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_styles/background = SubResource("Hp_bg")
|
||||
theme_override_styles/fill = SubResource("Hp_fill")
|
||||
show_percentage = false
|
||||
|
||||
[node name="OppStats" type="HBoxContainer" parent="OpponentStatusBand/OppMargin/OppRow/OppInfo"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 7
|
||||
|
||||
[node name="OppSpStat" type="HBoxContainer" parent="OpponentStatusBand/OppMargin/OppRow/OppInfo/OppStats"]
|
||||
custom_minimum_size = Vector2(72, 24)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 6
|
||||
|
||||
[node name="OppSpIcon" type="TextureRect" parent="OpponentStatusBand/OppMargin/OppRow/OppInfo/OppStats/OppSpStat"]
|
||||
self_modulate = Color(0, 1, 0.94, 0.8)
|
||||
custom_minimum_size = Vector2(18, 18)
|
||||
layout_mode = 2
|
||||
texture = ExtResource("2_sp")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="OppSpLabel" type="Label" parent="OpponentStatusBand/OppMargin/OppRow/OppInfo/OppStats/OppSpStat"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(26, 0)
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.82, 0.98, 1, 1)
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "0"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="OppStStat" type="HBoxContainer" parent="OpponentStatusBand/OppMargin/OppRow/OppInfo/OppStats"]
|
||||
custom_minimum_size = Vector2(72, 24)
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 6
|
||||
|
||||
[node name="OppStIcon" type="TextureRect" parent="OpponentStatusBand/OppMargin/OppRow/OppInfo/OppStats/OppStStat"]
|
||||
self_modulate = Color(0, 1, 0.94, 0.8)
|
||||
custom_minimum_size = Vector2(18, 18)
|
||||
layout_mode = 2
|
||||
texture = ExtResource("3_st")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="OppStLabel" type="Label" parent="OpponentStatusBand/OppMargin/OppRow/OppInfo/OppStats/OppStStat"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(26, 0)
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.82, 0.98, 1, 1)
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "0"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="OppHandLabel" type="Label" parent="OpponentStatusBand/OppMargin/OppRow/OppInfo/OppStats"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(62, 22)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 10
|
||||
theme_override_styles/normal = SubResource("Panel_pill")
|
||||
text = "Hand 0"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="OppDeckLabel" type="Label" parent="OpponentStatusBand/OppMargin/OppRow/OppInfo/OppStats"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(62, 22)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 10
|
||||
theme_override_styles/normal = SubResource("Panel_pill")
|
||||
text = "Deck 0"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="OppDiscardBtn" type="Button" parent="OpponentStatusBand/OppMargin/OppRow/OppInfo/OppStats"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(72, 22)
|
||||
layout_mode = 2
|
||||
focus_mode = 0
|
||||
theme_override_font_sizes/font_size = 10
|
||||
theme_override_styles/normal = SubResource("Panel_pill")
|
||||
theme_override_styles/pressed = SubResource("Panel_pill")
|
||||
theme_override_styles/hover = SubResource("Panel_pill_hover")
|
||||
text = "Discard 0"
|
||||
|
||||
[node name="OppPortrait" type="TextureRect" parent="OpponentStatusBand/OppMargin/OppRow"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(72, 72)
|
||||
layout_mode = 2
|
||||
expand_mode = 1
|
||||
stretch_mode = 6
|
||||
|
||||
[node name="SelfStatusCluster" type="Control" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 16.0
|
||||
offset_top = -308.0
|
||||
offset_right = 308.0
|
||||
offset_bottom = -18.0
|
||||
grow_vertical = 0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="SelfSpToken" type="Control" parent="SelfStatusCluster"]
|
||||
anchors_preset = 0
|
||||
offset_left = 3.0
|
||||
offset_top = 8.0
|
||||
offset_right = 75.0
|
||||
offset_bottom = 80.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="SelfSpIcon" type="TextureRect" parent="SelfStatusCluster/SelfSpToken"]
|
||||
self_modulate = Color(0, 1, 0.9411765, 0.5764706)
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
tooltip_text = "Spirit Points"
|
||||
texture = ExtResource("2_sp")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="SelfSpLabel" type="Label" parent="SelfStatusCluster/SelfSpToken"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 9.0
|
||||
offset_top = 3.0
|
||||
offset_right = -9.0
|
||||
offset_bottom = -19.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_colors/font_color = Color(0.01, 0.02, 0.02, 1)
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "0"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="SelfStToken" type="Control" parent="SelfStatusCluster"]
|
||||
anchors_preset = 0
|
||||
offset_left = 83.0
|
||||
offset_top = 8.0
|
||||
offset_right = 155.0
|
||||
offset_bottom = 80.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="SelfStIcon" type="TextureRect" parent="SelfStatusCluster/SelfStToken"]
|
||||
self_modulate = Color(0, 1, 0.9411765, 0.5647059)
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
tooltip_text = "Sacrifice Tokens"
|
||||
texture = ExtResource("3_st")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="SelfStLabel" type="Label" parent="SelfStatusCluster/SelfStToken"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 11.0
|
||||
offset_top = 3.0
|
||||
offset_right = -11.0
|
||||
offset_bottom = -19.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_colors/font_color = Color(0.01, 0.02, 0.02, 1)
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "0"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="SelfHpBadge" type="PanelContainer" parent="SelfStatusCluster"]
|
||||
layout_mode = 0
|
||||
offset_left = 44.0
|
||||
offset_top = 81.0
|
||||
offset_right = 116.0
|
||||
offset_bottom = 115.0
|
||||
tooltip_text = "ArchSpirit Health"
|
||||
theme_override_styles/panel = SubResource("Panel_hp")
|
||||
|
||||
[node name="SelfHpLabel" type="Label" parent="SelfStatusCluster/SelfHpBadge"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(1, 0.48, 0.55, 1)
|
||||
theme_override_font_sizes/font_size = 13
|
||||
text = "HP 0/0"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="SelfHpBar" type="ProgressBar" parent="SelfStatusCluster"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_left = 20.0
|
||||
offset_top = 116.0
|
||||
offset_right = 138.0
|
||||
offset_bottom = 128.0
|
||||
theme_override_styles/background = SubResource("Hp_bg")
|
||||
theme_override_styles/fill = SubResource("Hp_fill")
|
||||
show_percentage = false
|
||||
|
||||
[node name="SelfPortraitFrame" type="Control" parent="SelfStatusCluster"]
|
||||
anchors_preset = 0
|
||||
offset_top = 118.0
|
||||
offset_right = 190.0
|
||||
offset_bottom = 308.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="Shadow" type="TextureRect" parent="SelfStatusCluster/SelfPortraitFrame"]
|
||||
self_modulate = Color(0, 0.36176714, 0.33852944, 0.5764706)
|
||||
layout_mode = 0
|
||||
offset_left = -1.0
|
||||
offset_top = 10.0
|
||||
offset_right = 149.0
|
||||
offset_bottom = 164.0
|
||||
scale = Vector2(1, 1.0399951)
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("7_shadow")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="FlairBackground" type="TextureRect" parent="SelfStatusCluster/SelfPortraitFrame"]
|
||||
self_modulate = Color(0, 0.8575818, 0.806699, 0.5764706)
|
||||
layout_mode = 0
|
||||
offset_left = 3.0
|
||||
offset_top = 2.0
|
||||
offset_right = 167.0
|
||||
offset_bottom = 162.0
|
||||
scale = Vector2(1, 1.0399951)
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("4_flair")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="PortraitClip" type="Control" parent="SelfStatusCluster/SelfPortraitFrame"]
|
||||
unique_name_in_owner = true
|
||||
clip_contents = true
|
||||
layout_mode = 1
|
||||
anchor_left = 0.053000003
|
||||
anchor_top = 0.068
|
||||
anchor_right = 0.80500007
|
||||
anchor_bottom = 0.85800004
|
||||
offset_left = 0.92999935
|
||||
offset_top = 0.0800066
|
||||
offset_right = -5.411667
|
||||
offset_bottom = -20.70964
|
||||
scale = Vector2(1.0400009, 1.16)
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="ArchspiritMask" type="TextureRect" parent="SelfStatusCluster/SelfPortraitFrame/PortraitClip"]
|
||||
unique_name_in_owner = true
|
||||
clip_children = 1
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = -0.049000002
|
||||
anchor_right = 1.056
|
||||
anchor_bottom = 1.0270001
|
||||
offset_left = 0.0067310333
|
||||
offset_top = -7.7586403
|
||||
offset_right = -6.4962616
|
||||
offset_bottom = -7.517975
|
||||
scale = Vector2(1.044615, 1.0567364)
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("8_mask")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="SelfPortrait" type="TextureRect" parent="SelfStatusCluster/SelfPortraitFrame/PortraitClip/ArchspiritMask"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 11.045649
|
||||
offset_top = 2.4473572
|
||||
offset_right = -3.6818695
|
||||
offset_bottom = 4.8947144
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
expand_mode = 1
|
||||
stretch_mode = 6
|
||||
|
||||
[node name="Outline" type="TextureRect" parent="SelfStatusCluster"]
|
||||
self_modulate = Color(0, 0.58431375, 0.54901963, 0.4)
|
||||
layout_mode = 0
|
||||
offset_left = -25.0
|
||||
offset_top = 111.0
|
||||
offset_right = 165.0
|
||||
offset_bottom = 287.0
|
||||
scale = Vector2(1, 1.16)
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("6_outline")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="LightReflection" type="TextureRect" parent="SelfStatusCluster"]
|
||||
self_modulate = Color(0, 1, 0.9411765, 0.43137255)
|
||||
layout_mode = 0
|
||||
offset_left = 66.0
|
||||
offset_top = 120.0
|
||||
offset_right = 162.0
|
||||
offset_bottom = 216.0
|
||||
scale = Vector2(1, 1.0399951)
|
||||
mouse_filter = 2
|
||||
texture = ExtResource("5_light")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="SelfHandToken" type="Control" parent="SelfStatusCluster"]
|
||||
anchors_preset = 0
|
||||
offset_left = 170.0
|
||||
offset_top = 126.0
|
||||
offset_right = 226.0
|
||||
offset_bottom = 182.0
|
||||
tooltip_text = "Hand"
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="SelfHandIcon" type="TextureRect" parent="SelfStatusCluster/SelfHandToken"]
|
||||
self_modulate = Color(0, 1, 0.9411765, 0.8)
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("11_hand")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="SelfHandLabel" type="Label" parent="SelfStatusCluster/SelfHandToken"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 7.0
|
||||
offset_top = 7.0
|
||||
offset_right = -9.0
|
||||
offset_bottom = -7.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_colors/font_color = Color(0.01, 0.02, 0.02, 1)
|
||||
theme_override_colors/font_shadow_color = Color(0, 1, 0.9411765, 0.8)
|
||||
theme_override_colors/font_outline_color = Color(0, 1, 0.9411765, 0.8)
|
||||
theme_override_constants/shadow_offset_x = 2
|
||||
theme_override_constants/shadow_offset_y = 2
|
||||
theme_override_constants/outline_size = 3
|
||||
theme_override_font_sizes/font_size = 20
|
||||
text = "0"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="SelfDeckToken" type="Control" parent="SelfStatusCluster"]
|
||||
anchors_preset = 0
|
||||
offset_left = 170.0
|
||||
offset_top = 162.0
|
||||
offset_right = 226.0
|
||||
offset_bottom = 218.0
|
||||
tooltip_text = "Deck"
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="SelfDeckIcon" type="TextureRect" parent="SelfStatusCluster/SelfDeckToken"]
|
||||
self_modulate = Color(0, 1, 0.9411765, 0.8)
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("9_deck")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="SelfDeckLabel" type="Label" parent="SelfStatusCluster/SelfDeckToken"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 8.0
|
||||
offset_top = 6.0
|
||||
offset_right = -8.0
|
||||
offset_bottom = -8.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_colors/font_color = Color(0.01, 0.02, 0.02, 1)
|
||||
theme_override_colors/font_shadow_color = Color(0, 1, 0.9411765, 0.8)
|
||||
theme_override_colors/font_outline_color = Color(0, 1, 0.9411765, 0.8)
|
||||
theme_override_constants/shadow_offset_x = 2
|
||||
theme_override_constants/shadow_offset_y = 2
|
||||
theme_override_constants/outline_size = 3
|
||||
theme_override_font_sizes/font_size = 20
|
||||
text = "0"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="SelfDiscardBtn" type="TextureButton" parent="SelfStatusCluster"]
|
||||
unique_name_in_owner = true
|
||||
self_modulate = Color(0, 1, 0.9411765, 0.8)
|
||||
layout_mode = 0
|
||||
offset_left = 165.00002
|
||||
offset_top = 201.0
|
||||
offset_right = 737.0
|
||||
offset_bottom = 481.0
|
||||
scale = Vector2(0.11999819, 0.16000307)
|
||||
tooltip_text = "Discard"
|
||||
focus_mode = 0
|
||||
texture_normal = ExtResource("10_discard")
|
||||
texture_pressed = ExtResource("10_discard")
|
||||
texture_hover = ExtResource("10_discard")
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="SelfDiscardLabel" type="Label" parent="SelfStatusCluster/SelfDiscardBtn"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.045
|
||||
anchor_top = 0.224
|
||||
anchor_right = 0.94400007
|
||||
anchor_bottom = 0.83400005
|
||||
offset_left = 99.2619
|
||||
offset_top = -25.220871
|
||||
offset_right = -376.58112
|
||||
offset_bottom = -168.02089
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
scale = Vector2(8.249869, 6.249839)
|
||||
theme_override_colors/font_color = Color(0.01, 0.02, 0.02, 1)
|
||||
theme_override_colors/font_shadow_color = Color(0, 1, 0.9411765, 0.8)
|
||||
theme_override_colors/font_outline_color = Color(0, 1, 0.9411765, 0.8)
|
||||
theme_override_constants/shadow_offset_x = 2
|
||||
theme_override_constants/shadow_offset_y = 2
|
||||
theme_override_constants/outline_size = 3
|
||||
theme_override_font_sizes/font_size = 20
|
||||
text = "0"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
@@ -0,0 +1,513 @@
|
||||
class_name TileDrawer
|
||||
extends Node
|
||||
|
||||
signal focus_camera_on_tile(world_pos: Vector3)
|
||||
|
||||
const TILE_DRAWER_WIDTH: float = 260.0
|
||||
const TILE_DRAWER_TOGGLE_WIDTH: float = 36.0
|
||||
const TILE_DRAWER_TOGGLE_MARGIN: float = 12.0
|
||||
|
||||
var tile_drawer: PanelContainer = null
|
||||
var tile_drawer_open: bool = false
|
||||
var tile_drawer_tween: Tween = null
|
||||
var tile_drawer_last_tile: Dictionary = {}
|
||||
var tile_drawer_tile_labels: Array = []
|
||||
var tile_drawer_spirit_labels: Array = []
|
||||
var tile_drawer_token_labels: Array = []
|
||||
var tile_drawer_arch_labels: Array = []
|
||||
var tile_drawer_ruin_labels: Array = []
|
||||
var tile_drawer_tile_section: Dictionary = {}
|
||||
var tile_drawer_spirit_section: Dictionary = {}
|
||||
var tile_drawer_token_section: Dictionary = {}
|
||||
var tile_drawer_arch_section: Dictionary = {}
|
||||
var tile_drawer_ruin_section: Dictionary = {}
|
||||
var tile_drawer_spirit_effects_section: Dictionary = {}
|
||||
var tile_drawer_token_effects_section: Dictionary = {}
|
||||
var tile_drawer_arch_effects_section: Dictionary = {}
|
||||
var tile_drawer_ruin_effects_section: Dictionary = {}
|
||||
var tile_drawer_spirit_effects_labels: Array = []
|
||||
var tile_drawer_token_effects_labels: Array = []
|
||||
var tile_drawer_arch_effects_labels: Array = []
|
||||
var tile_drawer_ruin_effects_labels: Array = []
|
||||
|
||||
# Set by parent
|
||||
var hud: CanvasLayer = null
|
||||
var tile_drawer_toggle_btn: Button = null
|
||||
|
||||
|
||||
func create_tile_drawer() -> void:
|
||||
var panel: PanelContainer = PanelContainer.new()
|
||||
panel.anchor_left = 1.0
|
||||
panel.anchor_right = 1.0
|
||||
panel.anchor_top = 0.0
|
||||
panel.anchor_bottom = 1.0
|
||||
panel.offset_left = 0.0
|
||||
panel.offset_right = 0.0
|
||||
panel.offset_top = 0.0
|
||||
panel.offset_bottom = 0.0
|
||||
panel.visible = false
|
||||
hud.add_child(panel)
|
||||
tile_drawer = panel
|
||||
|
||||
var margin: MarginContainer = MarginContainer.new()
|
||||
margin.layout_mode = 2
|
||||
margin.add_theme_constant_override("margin_left", 12)
|
||||
margin.add_theme_constant_override("margin_right", 12)
|
||||
margin.add_theme_constant_override("margin_top", 12)
|
||||
margin.add_theme_constant_override("margin_bottom", 12)
|
||||
panel.add_child(margin)
|
||||
|
||||
var vbox: VBoxContainer = VBoxContainer.new()
|
||||
vbox.layout_mode = 2
|
||||
vbox.add_theme_constant_override("separation", 6)
|
||||
margin.add_child(vbox)
|
||||
|
||||
# Title row with close button.
|
||||
var title_row: HBoxContainer = HBoxContainer.new()
|
||||
title_row.layout_mode = 2
|
||||
var title_lbl: Label = Label.new()
|
||||
title_lbl.text = "Tile Details"
|
||||
title_lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
title_lbl.add_theme_font_size_override("font_size", 15)
|
||||
var close_btn: Button = Button.new()
|
||||
close_btn.text = "×"
|
||||
close_btn.custom_minimum_size = Vector2(28, 28)
|
||||
close_btn.pressed.connect(close_tile_drawer)
|
||||
title_row.add_child(title_lbl)
|
||||
title_row.add_child(close_btn)
|
||||
vbox.add_child(title_row)
|
||||
|
||||
var sep: HSeparator = HSeparator.new()
|
||||
sep.layout_mode = 2
|
||||
vbox.add_child(sep)
|
||||
|
||||
tile_drawer_tile_section = create_tile_drawer_section(vbox, "Tile Details", true)
|
||||
tile_drawer_spirit_section = create_tile_drawer_section(vbox, "Spirit Details", false)
|
||||
tile_drawer_spirit_effects_section = create_scrollable_section(vbox, "Active Effects")
|
||||
tile_drawer_token_section = create_tile_drawer_section(vbox, "Spirit Token Details", false)
|
||||
tile_drawer_token_effects_section = create_scrollable_section(vbox, "Active Effects")
|
||||
tile_drawer_arch_section = create_tile_drawer_section(vbox, "ArchSpirit Details", false)
|
||||
tile_drawer_arch_effects_section = create_scrollable_section(vbox, "Active Effects")
|
||||
tile_drawer_ruin_section = create_tile_drawer_section(vbox, "Ruin Details", false)
|
||||
tile_drawer_ruin_effects_section = create_scrollable_section(vbox, "Active Effects")
|
||||
|
||||
tile_drawer_tile_labels = create_detail_labels(tile_drawer_tile_section["content"], 5)
|
||||
tile_drawer_spirit_labels = create_detail_labels(tile_drawer_spirit_section["content"], 5)
|
||||
tile_drawer_token_labels = create_detail_labels(tile_drawer_token_section["content"], 5)
|
||||
tile_drawer_arch_labels = create_detail_labels(tile_drawer_arch_section["content"], 6)
|
||||
tile_drawer_ruin_labels = create_detail_labels(tile_drawer_ruin_section["content"], 2)
|
||||
|
||||
set_tile_drawer_button_state()
|
||||
|
||||
|
||||
func create_tile_drawer_section(parent: VBoxContainer, title: String,
|
||||
expanded: bool) -> Dictionary:
|
||||
var section: VBoxContainer = VBoxContainer.new()
|
||||
section.layout_mode = 2
|
||||
section.add_theme_constant_override("separation", 4)
|
||||
parent.add_child(section)
|
||||
|
||||
var header: Button = Button.new()
|
||||
header.layout_mode = 2
|
||||
header.toggle_mode = true
|
||||
header.button_pressed = expanded
|
||||
header.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
header.text = tile_drawer_section_title(title, expanded)
|
||||
section.add_child(header)
|
||||
|
||||
var content: VBoxContainer = VBoxContainer.new()
|
||||
content.layout_mode = 2
|
||||
content.visible = expanded
|
||||
content.add_theme_constant_override("separation", 2)
|
||||
section.add_child(content)
|
||||
|
||||
section.visible = expanded
|
||||
|
||||
header.toggled.connect(func(is_pressed: bool) -> void:
|
||||
content.visible = is_pressed
|
||||
header.text = tile_drawer_section_title(title, is_pressed))
|
||||
|
||||
return {
|
||||
"root": section,
|
||||
"header": header,
|
||||
"content": content,
|
||||
"title": title,
|
||||
}
|
||||
|
||||
|
||||
func tile_drawer_section_title(title: String, expanded: bool) -> String:
|
||||
return "%s %s" % ["[-]" if expanded else "[+]", title]
|
||||
|
||||
|
||||
## Creates a collapsible section whose content sits inside a ScrollContainer so that
|
||||
## long effect lists don't overflow the drawer. The returned dict has the same keys
|
||||
## as create_tile_drawer_section ("root", "header", "content", "title") plus "scroll"
|
||||
## and a mutable "count" entry used to keep the header label up-to-date.
|
||||
func create_scrollable_section(parent: VBoxContainer, title: String) -> Dictionary:
|
||||
var section: VBoxContainer = VBoxContainer.new()
|
||||
section.layout_mode = 2
|
||||
section.add_theme_constant_override("separation", 4)
|
||||
parent.add_child(section)
|
||||
|
||||
var header: Button = Button.new()
|
||||
header.layout_mode = 2
|
||||
header.toggle_mode = true
|
||||
header.button_pressed = false
|
||||
header.alignment = HORIZONTAL_ALIGNMENT_LEFT
|
||||
header.text = tile_drawer_section_title(title, false)
|
||||
section.add_child(header)
|
||||
|
||||
var scroll: ScrollContainer = ScrollContainer.new()
|
||||
scroll.layout_mode = 2
|
||||
scroll.custom_minimum_size = Vector2(0, 90)
|
||||
scroll.vertical_scroll_mode = ScrollContainer.SCROLL_MODE_AUTO
|
||||
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
scroll.visible = false
|
||||
section.add_child(scroll)
|
||||
|
||||
var content: VBoxContainer = VBoxContainer.new()
|
||||
content.layout_mode = 2
|
||||
content.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
content.add_theme_constant_override("separation", 2)
|
||||
scroll.add_child(content)
|
||||
|
||||
section.visible = false
|
||||
|
||||
var data: Dictionary = {
|
||||
"root": section,
|
||||
"header": header,
|
||||
"scroll": scroll,
|
||||
"content": content,
|
||||
"title": title,
|
||||
"count": 0,
|
||||
}
|
||||
|
||||
header.toggled.connect(func(is_pressed: bool) -> void:
|
||||
scroll.visible = is_pressed
|
||||
var n: int = data.get("count", 0)
|
||||
var t: String = data.get("title", "Active Effects")
|
||||
var display: String = ("%s (%d)" % [t, n]) if n > 0 else t
|
||||
header.text = tile_drawer_section_title(display, is_pressed))
|
||||
|
||||
return data
|
||||
|
||||
|
||||
## Updates the effects section header text (e.g. "Active Effects (3)") and stores
|
||||
## the count so the toggle signal can rebuild the label correctly.
|
||||
func update_effects_section_header(section: Dictionary, count: int) -> void:
|
||||
section["count"] = count
|
||||
var header: Button = section.get("header") as Button
|
||||
if not is_instance_valid(header):
|
||||
return
|
||||
var title: String = section.get("title", "Active Effects")
|
||||
var display: String = ("%s (%d)" % [title, count]) if count > 0 else title
|
||||
header.text = tile_drawer_section_title(display, header.button_pressed)
|
||||
|
||||
|
||||
func create_detail_labels(parent: VBoxContainer, count: int) -> Array:
|
||||
var labels: Array = []
|
||||
for _i in range(count):
|
||||
var lbl: Label = Label.new()
|
||||
lbl.layout_mode = 2
|
||||
lbl.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
lbl.add_theme_font_size_override("font_size", 12)
|
||||
lbl.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
parent.add_child(lbl)
|
||||
labels.append(lbl)
|
||||
return labels
|
||||
|
||||
|
||||
func append_tile_drawer_label(parent: VBoxContainer, labels: Array) -> void:
|
||||
var lbl: Label = Label.new()
|
||||
lbl.layout_mode = 2
|
||||
lbl.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
lbl.add_theme_font_size_override("font_size", 12)
|
||||
lbl.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
parent.add_child(lbl)
|
||||
labels.append(lbl)
|
||||
|
||||
|
||||
func set_tile_drawer_lines(section: Dictionary, labels: Array, lines: Array,
|
||||
tooltips: Array = []) -> void:
|
||||
var root: Control = section.get("root") as Control
|
||||
var content: VBoxContainer = section.get("content") as VBoxContainer
|
||||
if root == null:
|
||||
return
|
||||
if content == null:
|
||||
return
|
||||
while labels.size() < lines.size():
|
||||
append_tile_drawer_label(content, labels)
|
||||
root.visible = not lines.is_empty()
|
||||
for i in range(labels.size()):
|
||||
var lbl: Label = labels[i] as Label
|
||||
var show_line: bool = i < lines.size()
|
||||
lbl.visible = show_line
|
||||
if show_line:
|
||||
lbl.text = str(lines[i])
|
||||
lbl.tooltip_text = str(tooltips[i]) if i < tooltips.size() else ""
|
||||
else:
|
||||
lbl.tooltip_text = ""
|
||||
|
||||
|
||||
## Clears a scrollable effects section and resets its cached header/toggle state so
|
||||
## the next inspected tile does not inherit a stale count or expanded body.
|
||||
func clear_effects_section(section: Dictionary, labels: Array) -> void:
|
||||
set_tile_drawer_lines(section, labels, [])
|
||||
section["count"] = 0
|
||||
var header: Button = section.get("header") as Button
|
||||
if is_instance_valid(header):
|
||||
header.button_pressed = false
|
||||
header.text = tile_drawer_section_title(str(section.get("title", "Active Effects")), false)
|
||||
var scroll: ScrollContainer = section.get("scroll") as ScrollContainer
|
||||
if is_instance_valid(scroll):
|
||||
scroll.visible = false
|
||||
scroll.scroll_vertical = 0
|
||||
|
||||
|
||||
func find_unit_owner_account_id(unit_id: String) -> String:
|
||||
if unit_id.is_empty():
|
||||
return ""
|
||||
for player: Dictionary in Game.state.get("players", []):
|
||||
for unit: Dictionary in player.get("field", []):
|
||||
if str(unit.get("instanceId", "")) == unit_id:
|
||||
return str(player.get("accountId", ""))
|
||||
var arch: Dictionary = player.get("archSpirit", {})
|
||||
if str(arch.get("instanceId", "")) == unit_id:
|
||||
return str(player.get("accountId", ""))
|
||||
return ""
|
||||
|
||||
|
||||
func build_unit_detail_lines(unit: Dictionary, owner_id: String,
|
||||
include_tier: bool = false) -> Dictionary:
|
||||
var lines: Array = [
|
||||
"Name: %s" % str(unit.get("name", "?")),
|
||||
"Owner: %s" % Game.get_display_name(owner_id),
|
||||
]
|
||||
var tooltips: Array = ["", ""]
|
||||
if include_tier:
|
||||
lines.append("Tier: %d" % int(unit.get("tier", 0)))
|
||||
tooltips.append("")
|
||||
lines.append("HP: %d / %d" % [int(unit.get("currentHealth", 0)), int(unit.get("maxHealth", 0))])
|
||||
lines.append("DEF: %d / %d" % [int(unit.get("currentDefense", 0)), int(unit.get("maxDefense", 0))])
|
||||
lines.append("ATK: %d" % int(unit.get("damage", 0)))
|
||||
lines.append("MP: %d / %d" % [int(unit.get("currentMp", 0)), int(unit.get("maxMp", 0))])
|
||||
lines.append("Can Move: %s" % ("Yes" if bool(unit.get("canMove", false)) else "No"))
|
||||
lines.append("Can Attack: %s" % ("Yes" if bool(unit.get("canAttack", false)) else "No"))
|
||||
tooltips.append_array(["", "", "", "", "", ""])
|
||||
|
||||
var raw_abilities: Variant = unit.get("abilitiesJson")
|
||||
var parsed_abilities: Variant = JSON.parse_string("[]" if raw_abilities == null else str(raw_abilities))
|
||||
if parsed_abilities is Array:
|
||||
for ability_index: int in range((parsed_abilities as Array).size()):
|
||||
var ability: Dictionary = (parsed_abilities as Array)[ability_index] as Dictionary
|
||||
var ability_name: String = str(ability.get("name", ability.get("Name", "Ability %d" % ability_index)))
|
||||
var ability_desc: String = str(ability.get("description", ability.get("Description", "")))
|
||||
lines.append("Ability: %s" % ability_name)
|
||||
tooltips.append(ability_desc)
|
||||
|
||||
return {
|
||||
"lines": lines,
|
||||
"tooltips": tooltips,
|
||||
}
|
||||
|
||||
|
||||
## Appends any active effects targeting [param target_ref] (unit instanceId or ruinId)
|
||||
## into the provided [param lines] and [param tooltips] arrays.
|
||||
func append_active_effect_lines(target_ref: String, lines: Array, tooltips: Array) -> void:
|
||||
if target_ref.is_empty():
|
||||
return
|
||||
var all_effects: Variant = Game.state.get("activeEffects")
|
||||
if not all_effects is Array:
|
||||
return
|
||||
for ae: Dictionary in (all_effects as Array):
|
||||
if str(ae.get("targetRef", "")) != target_ref:
|
||||
continue
|
||||
var label: String = str(ae.get("label", "?"))
|
||||
var source_name: String = str(ae.get("sourceName", ""))
|
||||
var dur_type: String = str(ae.get("durationType", ""))
|
||||
var turns: int = int(ae.get("turnsRemaining", 0))
|
||||
var dur_text: String
|
||||
match dur_type:
|
||||
"ForNTurns": dur_text = "%d turn%s" % [turns, "s" if turns != 1 else ""]
|
||||
"UntilEndOfTurn": dur_text = "until end of turn"
|
||||
"UntilStartOfOwnerTurn": dur_text = "until owner's next turn"
|
||||
"UntilStartOfSourceOwnerTurn": dur_text = "until source's next turn"
|
||||
"WhileSourceOnBattlefield": dur_text = "while source lives"
|
||||
"WhileCondition": dur_text = "conditional"
|
||||
_: dur_text = dur_type.to_lower().replace("_", " ")
|
||||
var line: String
|
||||
if source_name.is_empty() or source_name == ae.get("sourceInstanceId", ""):
|
||||
line = "[Effect] %s (%s)" % [label, dur_text]
|
||||
else:
|
||||
line = "[Effect] %s (%s, from %s)" % [label, dur_text, source_name]
|
||||
lines.append(line)
|
||||
tooltips.append("")
|
||||
|
||||
|
||||
func set_tile_drawer_content(tile_data: Dictionary, state: Dictionary) -> void:
|
||||
tile_drawer_last_tile = tile_data.duplicate(true)
|
||||
set_tile_drawer_button_state()
|
||||
if tile_data.is_empty():
|
||||
set_tile_drawer_lines(tile_drawer_tile_section, tile_drawer_tile_labels, [])
|
||||
set_tile_drawer_lines(tile_drawer_spirit_section, tile_drawer_spirit_labels, [])
|
||||
set_tile_drawer_lines(tile_drawer_token_section, tile_drawer_token_labels, [])
|
||||
set_tile_drawer_lines(tile_drawer_arch_section, tile_drawer_arch_labels, [])
|
||||
set_tile_drawer_lines(tile_drawer_ruin_section, tile_drawer_ruin_labels, [])
|
||||
clear_effects_section(tile_drawer_spirit_effects_section, tile_drawer_spirit_effects_labels)
|
||||
clear_effects_section(tile_drawer_token_effects_section, tile_drawer_token_effects_labels)
|
||||
clear_effects_section(tile_drawer_arch_effects_section, tile_drawer_arch_effects_labels)
|
||||
clear_effects_section(tile_drawer_ruin_effects_section, tile_drawer_ruin_effects_labels)
|
||||
return
|
||||
|
||||
var coord: Dictionary = tile_data.get("coord", {})
|
||||
var cx: int = int(coord.get("x", 0))
|
||||
var cy: int = int(coord.get("y", 0))
|
||||
var aff: String = str(tile_data.get("resolvedAffinity", "?"))
|
||||
var b1: String = str(tile_data.get("base1", "?"))
|
||||
var b2: String = str(tile_data.get("base2", "?"))
|
||||
var ruin_id_value: Variant = tile_data.get("ruinId", "")
|
||||
var ruin_id: String = "" if ruin_id_value == null else str(ruin_id_value)
|
||||
var ruin_owner_id: String = str(tile_data.get("ruinOwner", ""))
|
||||
var occ_id: String = str(tile_data.get("occupantId", ""))
|
||||
var occ_owner_id: String = str(tile_data.get("occupantOwner", ""))
|
||||
var occ_unit: Dictionary = Game.get_unit_by_id(occ_id)
|
||||
var occ_type: String = str(occ_unit.get("cardType", ""))
|
||||
var occ_name: String = str(occ_unit.get("name", occ_id))
|
||||
|
||||
var tile_lines: Array = [
|
||||
"Coord: (%d, %d)" % [cx, cy],
|
||||
"Affinity: %s" % aff,
|
||||
"Base1: %s" % b1,
|
||||
"Base2: %s" % b2,
|
||||
"Occupant: %s" % ("None" if occ_id.is_empty() or occ_id == "null" else "%s (%s)" % [occ_name, occ_type]),
|
||||
]
|
||||
set_tile_drawer_lines(tile_drawer_tile_section, tile_drawer_tile_labels, tile_lines)
|
||||
|
||||
if not occ_id.is_empty() and occ_id != "null" and occ_type == "Spirit":
|
||||
var spirit_owner_id: String = occ_owner_id if not occ_owner_id.is_empty() else find_unit_owner_account_id(occ_id)
|
||||
var spirit_detail: Dictionary = build_unit_detail_lines(occ_unit, spirit_owner_id)
|
||||
set_tile_drawer_lines(
|
||||
tile_drawer_spirit_section, tile_drawer_spirit_labels,
|
||||
spirit_detail.get("lines", []), spirit_detail.get("tooltips", []))
|
||||
set_effects_section(occ_id, tile_drawer_spirit_effects_section, tile_drawer_spirit_effects_labels)
|
||||
else:
|
||||
set_tile_drawer_lines(tile_drawer_spirit_section, tile_drawer_spirit_labels, [])
|
||||
clear_effects_section(tile_drawer_spirit_effects_section, tile_drawer_spirit_effects_labels)
|
||||
|
||||
if not occ_id.is_empty() and occ_id != "null" and occ_type == "SpiritToken":
|
||||
var token_owner_id: String = occ_owner_id if not occ_owner_id.is_empty() else find_unit_owner_account_id(occ_id)
|
||||
var token_detail: Dictionary = build_unit_detail_lines(occ_unit, token_owner_id)
|
||||
set_tile_drawer_lines(
|
||||
tile_drawer_token_section, tile_drawer_token_labels,
|
||||
token_detail.get("lines", []), token_detail.get("tooltips", []))
|
||||
set_effects_section(occ_id, tile_drawer_token_effects_section, tile_drawer_token_effects_labels)
|
||||
else:
|
||||
set_tile_drawer_lines(tile_drawer_token_section, tile_drawer_token_labels, [])
|
||||
clear_effects_section(tile_drawer_token_effects_section, tile_drawer_token_effects_labels)
|
||||
|
||||
if not occ_id.is_empty() and occ_id != "null" and occ_type == "ArchSpirit":
|
||||
var arch_owner_id: String = occ_owner_id if not occ_owner_id.is_empty() else find_unit_owner_account_id(occ_id)
|
||||
var arch_detail: Dictionary = build_unit_detail_lines(occ_unit, arch_owner_id, true)
|
||||
set_tile_drawer_lines(
|
||||
tile_drawer_arch_section, tile_drawer_arch_labels,
|
||||
arch_detail.get("lines", []), arch_detail.get("tooltips", []))
|
||||
set_effects_section(occ_id, tile_drawer_arch_effects_section, tile_drawer_arch_effects_labels)
|
||||
else:
|
||||
set_tile_drawer_lines(tile_drawer_arch_section, tile_drawer_arch_labels, [])
|
||||
clear_effects_section(tile_drawer_arch_effects_section, tile_drawer_arch_effects_labels)
|
||||
|
||||
if ruin_id_value != null and not ruin_id.is_empty() and ruin_id != "null":
|
||||
var ruin_lines: Array = ["Ruin: %s" % ruin_id, "Owner: %s" % Game.get_display_name(ruin_owner_id)]
|
||||
var ruin_tooltips: Array = ["", ""]
|
||||
set_tile_drawer_lines(tile_drawer_ruin_section, tile_drawer_ruin_labels, ruin_lines, ruin_tooltips)
|
||||
set_effects_section(ruin_id, tile_drawer_ruin_effects_section, tile_drawer_ruin_effects_labels)
|
||||
else:
|
||||
set_tile_drawer_lines(tile_drawer_ruin_section, tile_drawer_ruin_labels, [])
|
||||
clear_effects_section(tile_drawer_ruin_effects_section, tile_drawer_ruin_effects_labels)
|
||||
|
||||
|
||||
## Populates [param section] (a scrollable effects section) with effects targeting
|
||||
## [param target_ref], then updates the header count badge.
|
||||
func set_effects_section(target_ref: String, section: Dictionary, labels: Array) -> void:
|
||||
var effect_lines: Array = []
|
||||
var effect_tooltips: Array = []
|
||||
append_active_effect_lines(target_ref, effect_lines, effect_tooltips)
|
||||
set_tile_drawer_lines(section, labels, effect_lines, effect_tooltips)
|
||||
update_effects_section_header(section, effect_lines.size())
|
||||
|
||||
|
||||
func set_tile_drawer_button_state() -> void:
|
||||
if not is_instance_valid(tile_drawer_toggle_btn):
|
||||
return
|
||||
var has_tile: bool = not tile_drawer_last_tile.is_empty()
|
||||
tile_drawer_toggle_btn.disabled = not has_tile
|
||||
tile_drawer_toggle_btn.text = ">" if tile_drawer_open else "<"
|
||||
layout_tile_drawer_toggle_button()
|
||||
|
||||
|
||||
func layout_tile_drawer_toggle_button() -> void:
|
||||
if not is_instance_valid(tile_drawer_toggle_btn):
|
||||
return
|
||||
if tile_drawer_open:
|
||||
tile_drawer_toggle_btn.offset_left = -TILE_DRAWER_WIDTH - TILE_DRAWER_TOGGLE_WIDTH
|
||||
tile_drawer_toggle_btn.offset_right = -TILE_DRAWER_WIDTH
|
||||
else:
|
||||
tile_drawer_toggle_btn.offset_left = -(TILE_DRAWER_TOGGLE_WIDTH + TILE_DRAWER_TOGGLE_MARGIN)
|
||||
tile_drawer_toggle_btn.offset_right = -TILE_DRAWER_TOGGLE_MARGIN
|
||||
tile_drawer_toggle_btn.offset_top = -24.0
|
||||
tile_drawer_toggle_btn.offset_bottom = 24.0
|
||||
|
||||
|
||||
func on_tile_drawer_toggle_pressed() -> void:
|
||||
if tile_drawer_open:
|
||||
close_tile_drawer()
|
||||
return
|
||||
if tile_drawer_last_tile.is_empty():
|
||||
return
|
||||
open_tile_drawer(tile_drawer_last_tile)
|
||||
|
||||
|
||||
func open_tile_drawer(tile: Dictionary) -> void:
|
||||
if not is_instance_valid(tile_drawer): return
|
||||
set_tile_drawer_content(tile, Game.state)
|
||||
|
||||
if tile_drawer_open:
|
||||
set_tile_drawer_button_state()
|
||||
return # already open, content updated above
|
||||
tile_drawer_open = true
|
||||
tile_drawer.visible = true
|
||||
set_tile_drawer_button_state()
|
||||
if tile_drawer_tween: tile_drawer_tween.kill()
|
||||
tile_drawer.offset_left = 0.0
|
||||
tile_drawer_tween = create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_CUBIC)
|
||||
tile_drawer_tween.parallel().tween_property(tile_drawer, "offset_left", -TILE_DRAWER_WIDTH, 0.3)
|
||||
tile_drawer_tween.parallel().tween_property(
|
||||
tile_drawer_toggle_btn, "offset_left",
|
||||
-TILE_DRAWER_WIDTH - TILE_DRAWER_TOGGLE_WIDTH, 0.3)
|
||||
tile_drawer_tween.parallel().tween_property(
|
||||
tile_drawer_toggle_btn, "offset_right",
|
||||
-TILE_DRAWER_WIDTH, 0.3)
|
||||
|
||||
|
||||
func close_tile_drawer() -> void:
|
||||
if not is_instance_valid(tile_drawer) or not tile_drawer_open: return
|
||||
tile_drawer_open = false
|
||||
set_tile_drawer_button_state()
|
||||
if tile_drawer_tween: tile_drawer_tween.kill()
|
||||
tile_drawer_tween = create_tween().set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_CUBIC)
|
||||
tile_drawer_tween.parallel().tween_property(tile_drawer, "offset_left", 0.0, 0.25)
|
||||
tile_drawer_tween.parallel().tween_property(
|
||||
tile_drawer_toggle_btn, "offset_left",
|
||||
-(TILE_DRAWER_TOGGLE_WIDTH + TILE_DRAWER_TOGGLE_MARGIN), 0.25)
|
||||
tile_drawer_tween.parallel().tween_property(
|
||||
tile_drawer_toggle_btn, "offset_right",
|
||||
-TILE_DRAWER_TOGGLE_MARGIN, 0.25)
|
||||
tile_drawer_tween.tween_callback(func() -> void:
|
||||
if is_instance_valid(tile_drawer): tile_drawer.visible = false)
|
||||
|
||||
|
||||
## Emits focus_camera_on_tile with the world position of the given coord.
|
||||
## Accepts a pathfinder to resolve the coordinate to world space.
|
||||
func focus_camera_on_tile_at(coord: Vector2i, state: Dictionary, pathfinder: Pathfinder) -> void:
|
||||
var world_pos: Vector3 = pathfinder.coord_to_world(coord.x, coord.y)
|
||||
focus_camera_on_tile.emit(world_pos)
|
||||
@@ -0,0 +1 @@
|
||||
uid://cbvcxlj28mwp3
|
||||
@@ -0,0 +1,107 @@
|
||||
class_name TurnTransitionBanner
|
||||
extends Control
|
||||
|
||||
var _panel: PanelContainer = null
|
||||
var _label: Label = null
|
||||
var _last_active_id: String = ""
|
||||
var _last_phase: String = ""
|
||||
var _initialized: bool = false
|
||||
var _active_tween: Tween = null
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
_build_layout()
|
||||
move_to_front()
|
||||
|
||||
|
||||
func update_from_state(state: Dictionary, spectating: bool) -> void:
|
||||
if spectating:
|
||||
return
|
||||
|
||||
var phase := str(state.get("phase", ""))
|
||||
var active_id := str(state.get("activePlayerAccountId", ""))
|
||||
if not _initialized:
|
||||
_initialized = true
|
||||
_last_phase = phase
|
||||
_last_active_id = active_id
|
||||
return
|
||||
|
||||
var entered_main := phase == "Main" and (_last_phase != "Main" or _last_active_id != active_id)
|
||||
_last_phase = phase
|
||||
_last_active_id = active_id
|
||||
|
||||
if entered_main:
|
||||
var label_text := "Your Main Phase" if active_id == Auth.user_id else "%s Main Phase" % Game.get_display_name(active_id)
|
||||
show_banner(label_text)
|
||||
|
||||
|
||||
func show_banner(text: String) -> void:
|
||||
if _panel == null or _label == null:
|
||||
return
|
||||
|
||||
if _active_tween != null and _active_tween.is_running():
|
||||
_active_tween.kill()
|
||||
|
||||
_label.text = text
|
||||
_panel.visible = true
|
||||
_panel.modulate = Color(1, 1, 1, 0)
|
||||
|
||||
var viewport_size := get_viewport_rect().size
|
||||
var target_pos := Vector2((viewport_size.x - _panel.size.x) * 0.5, viewport_size.y * 0.38)
|
||||
if _panel.size.x <= 0.0:
|
||||
target_pos.x = (viewport_size.x - 420.0) * 0.5
|
||||
_panel.position = Vector2(-460.0, target_pos.y)
|
||||
|
||||
_active_tween = create_tween()
|
||||
_active_tween.set_parallel(true)
|
||||
_active_tween.tween_property(_panel, "position", target_pos, 0.42).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
|
||||
_active_tween.tween_property(_panel, "modulate:a", 1.0, 0.20)
|
||||
_active_tween.set_parallel(false)
|
||||
_active_tween.tween_interval(1.15)
|
||||
_active_tween.set_parallel(true)
|
||||
_active_tween.tween_property(_panel, "position:x", viewport_size.x + 24.0, 0.32).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_IN)
|
||||
_active_tween.tween_property(_panel, "modulate:a", 0.0, 0.25)
|
||||
_active_tween.finished.connect(func() -> void:
|
||||
if is_instance_valid(_panel):
|
||||
_panel.visible = false)
|
||||
|
||||
|
||||
func _build_layout() -> void:
|
||||
_panel = PanelContainer.new()
|
||||
_panel.visible = false
|
||||
_panel.custom_minimum_size = Vector2(420, 54)
|
||||
_panel.size = Vector2(420, 54)
|
||||
_panel.add_theme_stylebox_override("panel", _panel_style())
|
||||
add_child(_panel)
|
||||
|
||||
var margin := MarginContainer.new()
|
||||
margin.add_theme_constant_override("margin_left", 18)
|
||||
margin.add_theme_constant_override("margin_right", 18)
|
||||
margin.add_theme_constant_override("margin_top", 9)
|
||||
margin.add_theme_constant_override("margin_bottom", 9)
|
||||
_panel.add_child(margin)
|
||||
|
||||
_label = Label.new()
|
||||
_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
_label.add_theme_font_size_override("font_size", 24)
|
||||
_label.add_theme_color_override("font_color", Color(0.76, 0.98, 1.0))
|
||||
_label.text = "Main Phase"
|
||||
margin.add_child(_label)
|
||||
|
||||
|
||||
func _panel_style() -> StyleBoxFlat:
|
||||
var style := StyleBoxFlat.new()
|
||||
style.bg_color = Color(0.02, 0.05, 0.07, 0.88)
|
||||
style.border_color = Color(0.18, 0.86, 0.94, 0.9)
|
||||
style.border_width_left = 2
|
||||
style.border_width_top = 2
|
||||
style.border_width_right = 2
|
||||
style.border_width_bottom = 2
|
||||
style.corner_radius_top_left = 8
|
||||
style.corner_radius_top_right = 8
|
||||
style.corner_radius_bottom_left = 8
|
||||
style.corner_radius_bottom_right = 8
|
||||
return style
|
||||
@@ -0,0 +1 @@
|
||||
uid://kofrp8y3wdxj
|
||||
@@ -0,0 +1,393 @@
|
||||
class_name BoardInputHandler
|
||||
extends Node
|
||||
|
||||
# ── Signals ───────────────────────────────────────────────────────────────────
|
||||
|
||||
signal board_clicked(screen_pos: Vector2) # tap/click on board (no drag)
|
||||
signal board_held(coord: Vector2i) # long press on tile (hold timer fired)
|
||||
signal board_double_clicked(screen_pos: Vector2) # double-click on board tile
|
||||
signal board_orbit(delta: Vector2) # camera orbit delta
|
||||
signal board_pan(delta: Vector2, cam_distance: float) # camera pan delta
|
||||
signal board_zoom(amount: float) # scroll/pinch zoom
|
||||
signal hand_scroll(direction: int) # -1 = left, +1 = right
|
||||
signal deselect_pending() # left-click outside hand while card selected
|
||||
|
||||
# ── Touch / mouse state ───────────────────────────────────────────────────────
|
||||
|
||||
var last_mouse: Vector2 = Vector2.ZERO
|
||||
var drag_active: bool = false
|
||||
var press_was_on_board: bool = false
|
||||
var pan_active: bool = false
|
||||
var orbit_active: bool = false
|
||||
var touch_points: Dictionary = {}
|
||||
var pinch_dist: float = 0.0
|
||||
var was_multi_touch: bool = false
|
||||
var touch_drag_active: bool = false
|
||||
var touch_drag_total: float = 0.0
|
||||
var touch_start_pos: Vector2 = Vector2.ZERO
|
||||
var touch_cam_orbit: bool = false
|
||||
var touch_cam_pan: bool = false
|
||||
var touch_cam_zoom: bool = false
|
||||
var gesture_move_accum: float = 0.0
|
||||
var gesture_finger_count: int = 0
|
||||
|
||||
# ── Internal deselect state ───────────────────────────────────────────────────
|
||||
|
||||
var _deselect_pending: bool = false
|
||||
var _hand_scroll_time: float = 0.0
|
||||
var _suppress_click_release: bool = false
|
||||
|
||||
# ── References set by parent ──────────────────────────────────────────────────
|
||||
|
||||
# Timers
|
||||
var hold_timer: Timer = null
|
||||
var cam_gesture_timer: Timer = null
|
||||
|
||||
# UI reference — used to detect hand-area wheel scrolls / deselect guard
|
||||
var hand_area: PanelContainer = null
|
||||
|
||||
# Camera rig — used for pan/orbit basis calculations
|
||||
var camera_rig: Node3D = null
|
||||
|
||||
# Camera distance — kept in sync by camera_controller via property
|
||||
var cam_distance: float = 14.0
|
||||
|
||||
# ── Mode flags set by selection_controller ────────────────────────────────────
|
||||
|
||||
# true when a card is selected in hand
|
||||
var card_mode_active: bool = false
|
||||
# true when targeting for a card ability
|
||||
var ability_card_active: bool = false
|
||||
|
||||
# ── Held-coord (exposed so hold_timer signal handler in parent can read it) ───
|
||||
|
||||
var held_coord: Vector2i = Vector2i(-1, -1)
|
||||
|
||||
# ── Callbacks set by parent for raycast queries ───────────────────────────────
|
||||
# Assign Callables pointing at game_screen's _mouse_to_tile_coord and _mouse_to_unit_id.
|
||||
# Signature: func(screen_pos: Vector2) -> Vector2i
|
||||
var fn_mouse_to_tile_coord: Callable = Callable()
|
||||
# Signature: func(screen_pos: Vector2) -> String
|
||||
var fn_mouse_to_unit_id: Callable = Callable()
|
||||
|
||||
# ── Camera-button toggles (called by game_screen from button signals) ─────────
|
||||
|
||||
func on_cam_orbit_btn_toggled(pressed: bool) -> void:
|
||||
touch_cam_orbit = pressed
|
||||
if pressed:
|
||||
touch_cam_pan = false
|
||||
touch_cam_zoom = false
|
||||
|
||||
func on_cam_pan_btn_toggled(pressed: bool) -> void:
|
||||
touch_cam_pan = pressed
|
||||
if pressed:
|
||||
touch_cam_orbit = false
|
||||
touch_cam_zoom = false
|
||||
|
||||
func on_cam_zoom_btn_toggled(pressed: bool) -> void:
|
||||
touch_cam_zoom = pressed
|
||||
if pressed:
|
||||
touch_cam_orbit = false
|
||||
touch_cam_pan = false
|
||||
|
||||
# ── Gesture timer callback (called by cam_gesture_timer.timeout) ──────────────
|
||||
|
||||
func on_cam_gesture_timer_fired() -> void:
|
||||
if Settings.touch_camera_mode != "gesture":
|
||||
return
|
||||
match gesture_finger_count:
|
||||
1:
|
||||
touch_cam_orbit = true
|
||||
touch_cam_pan = false
|
||||
touch_cam_zoom = false
|
||||
2:
|
||||
touch_cam_zoom = true
|
||||
touch_cam_orbit = false
|
||||
touch_cam_pan = false
|
||||
3:
|
||||
touch_cam_pan = true
|
||||
touch_cam_orbit = false
|
||||
touch_cam_zoom = false
|
||||
# The user deliberately held — mark as drag so release won't fire a board click.
|
||||
touch_drag_active = true
|
||||
if is_instance_valid(hold_timer):
|
||||
hold_timer.stop()
|
||||
|
||||
# ── Deactivate all touch camera modes ────────────────────────────────────────
|
||||
|
||||
func deactivate_touch_cam_modes() -> void:
|
||||
touch_cam_orbit = false
|
||||
touch_cam_pan = false
|
||||
touch_cam_zoom = false
|
||||
|
||||
# ── _input: intercepts every event first (handles deselect guard) ─────────────
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
var mb: InputEventMouseButton = event as InputEventMouseButton
|
||||
if mb.button_index == MOUSE_BUTTON_LEFT and mb.pressed and not mb.double_click:
|
||||
var is_card_active: bool = card_mode_active or ability_card_active
|
||||
if is_card_active:
|
||||
if not _hand_blocks_pointer(mb.position):
|
||||
if _pointer_hits_board_target(mb.position):
|
||||
_deselect_pending = false
|
||||
else:
|
||||
_deselect_pending = true
|
||||
_do_deselect_if_pending.call_deferred()
|
||||
|
||||
# ── Deselect-if-pending (called deferred so board click can cancel it first) ──
|
||||
|
||||
func _do_deselect_if_pending() -> void:
|
||||
if _deselect_pending:
|
||||
_deselect_pending = false
|
||||
var is_card_active: bool = card_mode_active or ability_card_active
|
||||
if is_card_active:
|
||||
emit_signal("deselect_pending")
|
||||
|
||||
# ── _unhandled_input: board-level input, not consumed by UI ──────────────────
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
var mb: InputEventMouseButton = event as InputEventMouseButton
|
||||
# Left-click reaching here is a board click — cancel any pending deselect
|
||||
# so _do_deselect_if_pending won't wipe selection before the card is played.
|
||||
if mb.button_index == MOUSE_BUTTON_LEFT and mb.pressed:
|
||||
_deselect_pending = false
|
||||
if mb.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if hand_area != null and hand_area.get_global_rect().has_point(mb.position):
|
||||
var now: float = Time.get_ticks_msec() / 1000.0
|
||||
if now - _hand_scroll_time >= 0.15:
|
||||
_hand_scroll_time = now
|
||||
hand_scroll.emit(-1)
|
||||
return
|
||||
board_zoom.emit(1.5)
|
||||
return
|
||||
elif mb.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if hand_area != null and hand_area.get_global_rect().has_point(mb.position):
|
||||
var now: float = Time.get_ticks_msec() / 1000.0
|
||||
if now - _hand_scroll_time >= 0.15:
|
||||
_hand_scroll_time = now
|
||||
hand_scroll.emit(1)
|
||||
return
|
||||
board_zoom.emit(-1.5)
|
||||
return
|
||||
elif mb.button_index == MOUSE_BUTTON_MIDDLE:
|
||||
pan_active = mb.pressed
|
||||
last_mouse = mb.position
|
||||
elif mb.button_index == MOUSE_BUTTON_RIGHT:
|
||||
orbit_active = mb.pressed
|
||||
last_mouse = mb.position
|
||||
elif mb.button_index == MOUSE_BUTTON_LEFT:
|
||||
if mb.pressed:
|
||||
if _hand_blocks_pointer(mb.position):
|
||||
return
|
||||
if mb.double_click:
|
||||
var dbl_coord: Vector2i = Vector2i(-1, -1)
|
||||
if fn_mouse_to_tile_coord.is_valid():
|
||||
dbl_coord = fn_mouse_to_tile_coord.call(mb.position)
|
||||
if dbl_coord.x >= 0:
|
||||
_suppress_click_release = true
|
||||
board_double_clicked.emit(mb.position)
|
||||
return
|
||||
last_mouse = mb.position
|
||||
drag_active = false
|
||||
press_was_on_board = true # unhandled press = board area, not a UI card
|
||||
var coord: Vector2i = Vector2i(-1, -1)
|
||||
if fn_mouse_to_tile_coord.is_valid():
|
||||
coord = fn_mouse_to_tile_coord.call(mb.position)
|
||||
if coord.x >= 0:
|
||||
held_coord = coord
|
||||
if is_instance_valid(hold_timer):
|
||||
hold_timer.start()
|
||||
else:
|
||||
held_coord = Vector2i(-1, -1)
|
||||
else:
|
||||
if is_instance_valid(hold_timer):
|
||||
hold_timer.stop()
|
||||
if _suppress_click_release:
|
||||
_suppress_click_release = false
|
||||
elif not drag_active and not touch_drag_active and press_was_on_board:
|
||||
board_clicked.emit(mb.position)
|
||||
drag_active = false
|
||||
touch_drag_active = false
|
||||
touch_drag_total = 0.0
|
||||
press_was_on_board = false
|
||||
|
||||
elif event is InputEventMouseMotion:
|
||||
var mm: InputEventMouseMotion = event as InputEventMouseMotion
|
||||
var delta: Vector2 = mm.position - last_mouse
|
||||
last_mouse = mm.position
|
||||
# On some mobile browsers, pinch emits synthetic mouse-motion/left-drag
|
||||
# alongside touch/gesture events. Ignore mouse-orbit while touch is active.
|
||||
# Right-mouse drag orbits camera on desktop; left-click is reserved for board actions.
|
||||
if orbit_active and touch_points.is_empty() and not was_multi_touch:
|
||||
board_orbit.emit(delta)
|
||||
if pan_active:
|
||||
# Normalise sign convention: receiver applies right = basis.x * d.x, fwd = fwd_vec * d.y
|
||||
# Mouse: original used +delta.x right, -delta.y forward.
|
||||
board_pan.emit(Vector2(delta.x, -delta.y), cam_distance)
|
||||
|
||||
elif event is InputEventScreenTouch:
|
||||
var st: InputEventScreenTouch = event as InputEventScreenTouch
|
||||
if st.pressed:
|
||||
touch_points[st.index] = st.position
|
||||
if touch_points.size() == 1:
|
||||
# Single-touch start: arm tap + hold (touch right-click) behavior.
|
||||
touch_drag_active = false
|
||||
touch_drag_total = 0.0
|
||||
touch_start_pos = st.position
|
||||
press_was_on_board = true
|
||||
last_mouse = st.position
|
||||
var touch_coord: Vector2i = Vector2i(-1, -1)
|
||||
if fn_mouse_to_tile_coord.is_valid():
|
||||
touch_coord = fn_mouse_to_tile_coord.call(st.position)
|
||||
if touch_coord.x >= 0:
|
||||
held_coord = touch_coord
|
||||
if is_instance_valid(hold_timer):
|
||||
hold_timer.start()
|
||||
else:
|
||||
held_coord = Vector2i(-1, -1)
|
||||
elif touch_points.size() >= 2:
|
||||
pinch_dist = _touch_pair_dist()
|
||||
last_mouse = _touch_pair_mid()
|
||||
was_multi_touch = true
|
||||
held_coord = Vector2i(-1, -1)
|
||||
if is_instance_valid(hold_timer):
|
||||
hold_timer.stop()
|
||||
# Gesture mode: (re)start timer whenever finger count changes.
|
||||
if Settings.touch_camera_mode == "gesture":
|
||||
gesture_finger_count = touch_points.size()
|
||||
gesture_move_accum = 0.0
|
||||
if is_instance_valid(cam_gesture_timer):
|
||||
cam_gesture_timer.start()
|
||||
else:
|
||||
var released_pos: Vector2 = st.position
|
||||
var had_single_touch: bool = (touch_points.size() == 1 and touch_points.has(st.index))
|
||||
touch_points.erase(st.index)
|
||||
if had_single_touch and not was_multi_touch and press_was_on_board:
|
||||
# Use start-to-end distance, not cumulative, to detect taps.
|
||||
# Cumulative distance mis-classifies natural finger jitter (A→B→A) as a drag.
|
||||
var tap_dist: float = released_pos.distance_to(touch_start_pos)
|
||||
if tap_dist < 50.0 and not touch_drag_active:
|
||||
if is_instance_valid(hold_timer):
|
||||
hold_timer.stop()
|
||||
board_clicked.emit(released_pos)
|
||||
if touch_points.is_empty():
|
||||
was_multi_touch = false
|
||||
touch_drag_active = false
|
||||
touch_drag_total = 0.0
|
||||
touch_start_pos = Vector2.ZERO
|
||||
press_was_on_board = false
|
||||
held_coord = Vector2i(-1, -1)
|
||||
if is_instance_valid(hold_timer):
|
||||
hold_timer.stop()
|
||||
if is_instance_valid(cam_gesture_timer):
|
||||
cam_gesture_timer.stop()
|
||||
# Gesture mode: deactivate camera mode when all fingers lift.
|
||||
if Settings.touch_camera_mode == "gesture":
|
||||
deactivate_touch_cam_modes()
|
||||
gesture_move_accum = 0.0
|
||||
gesture_finger_count = 0
|
||||
|
||||
elif event is InputEventScreenDrag:
|
||||
var sd: InputEventScreenDrag = event as InputEventScreenDrag
|
||||
touch_points[sd.index] = sd.position
|
||||
|
||||
# Cancel gesture timer if fingers move significantly before the hold activates.
|
||||
if Settings.touch_camera_mode == "gesture":
|
||||
gesture_move_accum += sd.relative.length()
|
||||
if gesture_move_accum > 50.0:
|
||||
if is_instance_valid(cam_gesture_timer):
|
||||
cam_gesture_timer.stop()
|
||||
|
||||
if touch_points.size() == 1 and not was_multi_touch:
|
||||
touch_drag_total += sd.relative.length()
|
||||
if touch_drag_total > 36.0:
|
||||
if is_instance_valid(hold_timer):
|
||||
hold_timer.stop()
|
||||
# Only suppress the tap click when a camera action will actually happen.
|
||||
# Without this, a normal swipe with no camera mode active silently eats the touch.
|
||||
if touch_cam_orbit or touch_cam_pan or touch_cam_zoom:
|
||||
touch_drag_active = true
|
||||
if touch_drag_active:
|
||||
if touch_cam_orbit:
|
||||
board_orbit.emit(sd.relative)
|
||||
elif touch_cam_pan:
|
||||
# Negate x to match original sign convention (pan right moves camera right).
|
||||
var pan_delta_touch: Vector2 = Vector2(-sd.relative.x, sd.relative.y)
|
||||
board_pan.emit(pan_delta_touch, cam_distance)
|
||||
elif touch_cam_zoom:
|
||||
board_zoom.emit(sd.relative.y * -0.05)
|
||||
elif Settings.touch_camera_mode == "gesture" and touch_points.size() == 3 and touch_cam_pan:
|
||||
# 3-finger pan (gesture mode): only process the leading finger to avoid triple-apply.
|
||||
var keys3: Array = touch_points.keys()
|
||||
keys3.sort()
|
||||
if sd.index == keys3[0]:
|
||||
var pan_delta3: Vector2 = Vector2(-sd.relative.x, sd.relative.y)
|
||||
board_pan.emit(pan_delta3, cam_distance)
|
||||
elif Settings.touch_camera_mode == "gesture" and touch_points.size() >= 2:
|
||||
var keys: Array = touch_points.keys()
|
||||
var pos_a: Vector2 = touch_points[keys[0]]
|
||||
var pos_b: Vector2 = touch_points[keys[1]]
|
||||
var mid: Vector2 = (pos_a + pos_b) * 0.5
|
||||
var nd: float = pos_a.distance_to(pos_b)
|
||||
board_zoom.emit((nd - pinch_dist) * 0.03)
|
||||
pinch_dist = nd
|
||||
var cdelta: Vector2 = mid - last_mouse
|
||||
last_mouse = mid
|
||||
var pan_delta2: Vector2 = Vector2(-cdelta.x, cdelta.y)
|
||||
board_pan.emit(pan_delta2, cam_distance)
|
||||
|
||||
# ── Browser high-level gesture events (Chromium / WebKit) ──────────────────
|
||||
# Browsers sometimes emit these *instead of* dual ScreenDrag events.
|
||||
# factor > 1.0 = spreading (zoom in), < 1.0 = pinching (zoom out).
|
||||
elif event is InputEventMagnifyGesture:
|
||||
if Settings.touch_camera_mode == "gesture":
|
||||
var mg: InputEventMagnifyGesture = event as InputEventMagnifyGesture
|
||||
board_zoom.emit((mg.factor - 1.0) * 8.0)
|
||||
|
||||
elif event is InputEventPanGesture:
|
||||
if Settings.touch_camera_mode != "gesture":
|
||||
return
|
||||
# On touch devices, treat pan-gesture as two-finger pan only.
|
||||
# Some browsers emit PanGesture during single-finger movement;
|
||||
# ignore that so single-finger remains orbit.
|
||||
if touch_points.size() == 1 and not was_multi_touch:
|
||||
return
|
||||
var pg: InputEventPanGesture = event as InputEventPanGesture
|
||||
var pan_delta_pg: Vector2 = Vector2(-pg.delta.x, pg.delta.y)
|
||||
board_pan.emit(pan_delta_pg, cam_distance)
|
||||
|
||||
# ── Helpers ───────────────────────────────────────────────────────────────────
|
||||
|
||||
func _touch_pair_dist() -> float:
|
||||
var keys: Array = touch_points.keys()
|
||||
if keys.size() < 2:
|
||||
return 0.0
|
||||
return (touch_points[keys[0]] as Vector2).distance_to(touch_points[keys[1]])
|
||||
|
||||
|
||||
func _touch_pair_mid() -> Vector2:
|
||||
var keys: Array = touch_points.keys()
|
||||
if keys.size() < 2:
|
||||
return Vector2.ZERO
|
||||
return ((touch_points[keys[0]] as Vector2) + (touch_points[keys[1]] as Vector2)) * 0.5
|
||||
|
||||
|
||||
func _hand_blocks_pointer(screen_pos: Vector2) -> bool:
|
||||
if hand_area == null or not is_instance_valid(hand_area):
|
||||
return false
|
||||
if hand_area.has_method("blocks_pointer"):
|
||||
return bool(hand_area.call("blocks_pointer", screen_pos))
|
||||
return hand_area.get_global_rect().has_point(screen_pos)
|
||||
|
||||
|
||||
func _pointer_hits_board_target(screen_pos: Vector2) -> bool:
|
||||
if fn_mouse_to_tile_coord.is_valid():
|
||||
var coord: Vector2i = fn_mouse_to_tile_coord.call(screen_pos)
|
||||
if coord.x >= 0:
|
||||
return true
|
||||
if fn_mouse_to_unit_id.is_valid():
|
||||
var unit_id: String = str(fn_mouse_to_unit_id.call(screen_pos))
|
||||
return not unit_id.is_empty()
|
||||
return false
|
||||
@@ -0,0 +1 @@
|
||||
uid://cqs166tf6n0s0
|
||||
@@ -0,0 +1,51 @@
|
||||
class_name GameOverOverlay
|
||||
extends PanelContainer
|
||||
|
||||
## End-of-game Victory/Defeat overlay.
|
||||
## Self-contained: wires its own button and handles scene transitions internally.
|
||||
|
||||
@onready var _result_lbl : Label = %GOResultLabel
|
||||
@onready var _rank_lbl : Label = %GORankLabel
|
||||
@onready var _menu_btn : Button = %GOMainMenuBtn
|
||||
|
||||
func _ready() -> void:
|
||||
_menu_btn.pressed.connect(func() -> void:
|
||||
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn"))
|
||||
|
||||
|
||||
func show_result(winner_id: String, win_condition: String,
|
||||
winner_delta: int, loser_delta: int,
|
||||
player_outcomes: Array = []) -> void:
|
||||
var i_won: bool
|
||||
if not player_outcomes.is_empty():
|
||||
var my_outcome: String = ""
|
||||
for po: Dictionary in player_outcomes:
|
||||
if str(po.get("accountId", "")) == Auth.user_id:
|
||||
my_outcome = str(po.get("outcome", ""))
|
||||
break
|
||||
i_won = (my_outcome == "Winner")
|
||||
else:
|
||||
i_won = (winner_id == Auth.user_id)
|
||||
|
||||
_result_lbl.text = "Victory!" if i_won else "Defeat"
|
||||
_result_lbl.modulate = Color(0.4, 1.0, 0.5) if i_won else Color(1.0, 0.4, 0.4)
|
||||
|
||||
if not player_outcomes.is_empty():
|
||||
var outcome_lines: Array = []
|
||||
for po: Dictionary in player_outcomes:
|
||||
var pid: String = str(po.get("accountId", ""))
|
||||
var oc: String = str(po.get("outcome", "?"))
|
||||
var rd: int = int(po.get("rankDelta", 0))
|
||||
var sign: String = "+" if rd >= 0 else ""
|
||||
var label: String = "You" if pid == Auth.user_id else Game.get_display_name(pid)
|
||||
outcome_lines.append("%s: %s (%s%d)" % [label, oc, sign, rd])
|
||||
_rank_lbl.text = "[%s]\n" % win_condition + "\n".join(outcome_lines)
|
||||
else:
|
||||
var my_delta: int = winner_delta if i_won else loser_delta
|
||||
_rank_lbl.text = "Win by %s | Rank %s%d" % [
|
||||
win_condition, "+" if my_delta >= 0 else "", my_delta]
|
||||
visible = true
|
||||
|
||||
|
||||
func on_session_abandoned(_reason: String) -> void:
|
||||
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn")
|
||||
@@ -0,0 +1 @@
|
||||
uid://c1acrobstx4i5
|
||||
@@ -0,0 +1,43 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://game_over_overlay"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/game/components/overlays/game_over_overlay.gd" id="1_script"]
|
||||
|
||||
[node name="GameOverOverlay" type="PanelContainer"]
|
||||
visible = false
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.25
|
||||
anchor_top = 0.25
|
||||
anchor_right = 0.75
|
||||
anchor_bottom = 0.75
|
||||
script = ExtResource("1_script")
|
||||
|
||||
[node name="GOMargin" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 24
|
||||
theme_override_constants/margin_top = 24
|
||||
theme_override_constants/margin_right = 24
|
||||
theme_override_constants/margin_bottom = 24
|
||||
|
||||
[node name="GOVBox" type="VBoxContainer" parent="GOMargin"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 16
|
||||
|
||||
[node name="GOResultLabel" type="Label" parent="GOMargin/GOVBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 28
|
||||
text = "Game Over"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="GORankLabel" type="Label" parent="GOMargin/GOVBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 15
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="GOMainMenuBtn" type="Button" parent="GOMargin/GOVBox"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 44)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 15
|
||||
text = "Return to Main Menu"
|
||||
@@ -0,0 +1,72 @@
|
||||
class_name InactiveDialogs
|
||||
extends Node
|
||||
|
||||
## Creates inactivity and player-elimination dialogs dynamically.
|
||||
## Dialogs are added as children of this node (which is a child of game_screen).
|
||||
|
||||
signal spectator_mode_requested() # emitted when local player is eliminated
|
||||
|
||||
func on_opponent_inactive(_sid: String) -> void:
|
||||
var dialog: ConfirmationDialog = ConfirmationDialog.new()
|
||||
dialog.title = "Opponent Inactive"
|
||||
dialog.dialog_text = (
|
||||
"Your opponent has not acted for 5 minutes.\n"
|
||||
+ "Do you want to claim their forfeit?"
|
||||
)
|
||||
dialog.ok_button_text = "Accept Forfeit"
|
||||
dialog.cancel_button_text = "Wait"
|
||||
add_child(dialog)
|
||||
dialog.confirmed.connect(func() -> void:
|
||||
dialog.queue_free()
|
||||
Game.send_force_concede()
|
||||
)
|
||||
dialog.canceled.connect(func() -> void:
|
||||
dialog.queue_free()
|
||||
)
|
||||
dialog.popup_centered()
|
||||
|
||||
|
||||
func on_inactive_warning(_sid: String) -> void:
|
||||
var dialog: AcceptDialog = AcceptDialog.new()
|
||||
dialog.title = "Inactivity Warning"
|
||||
dialog.dialog_text = (
|
||||
"You have been inactive for 5 minutes.\n"
|
||||
+ "Your opponent may claim a forfeit."
|
||||
)
|
||||
add_child(dialog)
|
||||
dialog.confirmed.connect(func() -> void: dialog.queue_free())
|
||||
dialog.popup_centered()
|
||||
|
||||
|
||||
func on_both_idle_warning(_sid: String) -> void:
|
||||
for child: Node in get_children():
|
||||
if child is ConfirmationDialog or child is AcceptDialog:
|
||||
child.queue_free()
|
||||
var dialog: AcceptDialog = AcceptDialog.new()
|
||||
dialog.title = "Both Players Idle"
|
||||
dialog.dialog_text = (
|
||||
"Both players have been idle for 10 minutes.\n"
|
||||
+ "Please return to continue the game."
|
||||
)
|
||||
dialog.ok_button_text = "Wait"
|
||||
add_child(dialog)
|
||||
dialog.confirmed.connect(func() -> void: dialog.queue_free())
|
||||
dialog.popup_centered()
|
||||
|
||||
|
||||
func on_player_eliminated(session_id: String, elim_id: String, _seat_idx: int, _team_idx: int) -> void:
|
||||
if session_id != Game.session_id:
|
||||
return
|
||||
var is_me: bool = elim_id == Auth.user_id
|
||||
var msg: String = (
|
||||
"You have been eliminated!\nYou can continue watching the game as a spectator."
|
||||
if is_me
|
||||
else "Player %s has been eliminated from the game!" % Game.get_display_name(elim_id))
|
||||
var dlg: AcceptDialog = AcceptDialog.new()
|
||||
dlg.title = "Player Eliminated"
|
||||
dlg.dialog_text = msg
|
||||
add_child(dlg)
|
||||
dlg.confirmed.connect(func() -> void: dlg.queue_free())
|
||||
dlg.popup_centered()
|
||||
if is_me:
|
||||
emit_signal("spectator_mode_requested")
|
||||
@@ -0,0 +1 @@
|
||||
uid://cq32begww8vf5
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user