Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8919f7f169 | ||
|
|
e3222805cb |
119 changed files with 1952 additions and 7063 deletions
80
Changelog/2026-10-14-sk-engine-work-through-10-13.md
Normal file
80
Changelog/2026-10-14-sk-engine-work-through-10-13.md
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
# SK engine and UI work through 2026-10-13, on 2026.10.13.3
|
||||
|
||||
Everything from SK's build since the 2026-10-11 batch that main doesn't have yet, merged onto
|
||||
release 2026.10.13.3 with the conflicts resolved. Goes with RynthSuite's
|
||||
`Changelog/2026-10-14-sk-rynthai-work-through-10-13.md`.
|
||||
|
||||
Left out on purpose: SK's local installer scripts and release records, `.github` and
|
||||
`.gitignore` edits for SK's fork, `BUILD.md` notes about SK's release script, and the
|
||||
per-release changelogs (this file sums them up).
|
||||
|
||||
## Merge notes for 2026.10.13.3
|
||||
|
||||
- **Plugin API v86.** 2026.10.13.3 took v84 for `GetObjectProperties`, so SK's additions follow it:
|
||||
- v85: `ArmConfirmationFn`, `GetLastConfirmationFn` (craft-chance and other confirmation prompts);
|
||||
- v86: `GetServerStateJsonFn` (the engine's server verdicts for plugins).
|
||||
- `PluginContractVersion.Current` and `RynthCoreSdkApiVersion` are 86. In the SDK,
|
||||
`HasConfirmationAnswers` needs v85+ and `HasGetServerStateJson` v86+.
|
||||
- `tools/PluginManifestTests` checks the slot order (`GetObjectProperties` before `ArmConfirmation`).
|
||||
- Plugins built against an older SK SDK must be rebuilt.
|
||||
|
||||
## Confirmation answers (v85)
|
||||
|
||||
- `Compatibility/ConfirmationResponder.cs` (new) binds `CM_Character::Event_ConfirmationResponse`
|
||||
by byte pattern. `SmartBoxHooks` hands each ConfirmationRequest (game event 0x0274) to it.
|
||||
- A plugin arms one answer (`ArmConfirmation`); the next matching prompt is answered and the result
|
||||
is readable with `GetLastConfirmation`. Unarmed prompts go to the client as before.
|
||||
- Char menu > Crafting opens RynthAi's Crafting tab.
|
||||
|
||||
## One plugin per server, server verdicts (v86)
|
||||
|
||||
- **Server plugins.** A plugin's manifest can name a server (id, hosts, world names).
|
||||
`PluginManifestGate.SelectServerPlugins` loads only the matching server's plugin; with no match
|
||||
every server plugin loads (fail-open).
|
||||
- **Server verdicts.** The engine decides which servers are active (built-in ILT and Aelrynth, plus
|
||||
every server a plugin declares) and exports them as JSON through `GetServerStateJson`.
|
||||
- **Per-character override.** `ServerForce` / `ServerForceStore` save Auto, On or Off per
|
||||
character; `/rc server <id> auto|on|off` and a server picker in Options > Diagnostics set it.
|
||||
- **Diagnostics server list.** `ServerMenus.Tick` runs every frame, bar or rail, so the list fills
|
||||
in and each server plugin gets its "servermenu" verdict. Server plugins the gate skipped are
|
||||
listed as "installed but not loaded"; forcing one On loads only that plugin on the pump thread
|
||||
(`PluginManager.ServerPlugins.cs`, `UI/Sections/NotLoadedServers.cs`).
|
||||
- **Launcher.** The Server Profile dialog has a known-server picker
|
||||
(`src/RynthCore.App/KnownServerCatalog.cs`).
|
||||
- `IltInfo.Refresh` logs its verdict at Info once per world (`RynthLog.Milestone`).
|
||||
|
||||
## Mini Remote sections
|
||||
|
||||
- `SectionRegistry`, `SectionCatalog` and the sections rail: each section draws the engine panels
|
||||
that belong to it as tabs, then one collapsing group per active server. Plugins add sections
|
||||
through `RynthPluginGetSectionsJson`.
|
||||
- With the rail hidden, the plugin tabs come back in RynthAi's tab bar.
|
||||
- "Char" is now "Session Stats" (the id stays `char`). Character and Charms moved to RynthOracle,
|
||||
Banking to RynthInventory's Global Inventory.
|
||||
- Char menu: Fellowship, and the quests open RynthOracle. The separate Hub launcher is removed
|
||||
(the Mini Remote button, `/rc miniremote` and Char > Mini Remote open the same window).
|
||||
|
||||
## Panels and settings
|
||||
|
||||
- **Items panel:** weapons colored by damage type (UB-ILT palette, `DamageTypeColors`).
|
||||
- **Progression:** one Attributes section; Infinite Leaftide's infinite attributes appear under the
|
||||
retail XP costs when RynthILT reports them.
|
||||
- **Settings and Damage panel:** environment-hit throttle for missile and magic (move closer, new
|
||||
target or off) and per-monster attack power (High, Reckless, Variable, Reckless + Variable, with
|
||||
`VariablePowerMin` / `VariablePowerMax`).
|
||||
- **Session stats:** the luminance total behind luminance per hour is in the status JSON
|
||||
(`luminanceSession`, additive).
|
||||
|
||||
## Security review fixes
|
||||
|
||||
- **A `%` in shown text could crash the client.** `ImGui/SafeImGui.cs` doubles every `%` before
|
||||
ImGui formats it; 246 calls in 39 engine files use it.
|
||||
- **Spoofed server replies.** The engine's own `/mastery-data` and `/mule-data` readers skip player
|
||||
chat types (`Net/ChatOrigin.cs`), and the vault wire needs its marker at the start of the line.
|
||||
- **StatusAgent 1.0.1:** hardening of the status server before it is opened to other PCs.
|
||||
|
||||
## Tests
|
||||
|
||||
- `tools/PluginManifestTests` (236 assertions), `tools/SectionsTests` (148 checks),
|
||||
`tools/ObjectPropertyTests`, `EngineSettingsTests`, `LauncherSettingsTests`, `NetMessageTests`,
|
||||
`StatusAgentTests`: all pass on this commit.
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
# 2026.10.5.64 - engine: second client can open the DAT files again (2025 client)
|
||||
|
||||
Previous release: 2026.10.5.62.
|
||||
|
||||
## Problem
|
||||
|
||||
With "Allow multiple clients" on, only the first client started. Every client launched after it
|
||||
(Silentstorm, SK, ...) showed "Can't open the data files. Check that they exist and that you
|
||||
have permission to write to them. The program will now exit." about half a second after the
|
||||
engine loaded.
|
||||
|
||||
The 2025 client (`C:\Turbine\Asheron's Call-ryn\ACClient.exe`, 0.0.11.6096) does not import
|
||||
`kernel32!CreateFileW`. A Layer-for-Unicode style stub at `0x006B8D00` looks it up on first use
|
||||
and stores it in a private slot at `0x00837374`, and AC opens every DAT file through that slot.
|
||||
|
||||
- Up to 2026.10.5.60 the DAT share hook detoured the kernel32 export, so it caught those opens.
|
||||
The log showed them as `Compat: DAT share - W [filtered]: client_portal.dat ... share=0x1->0x7`.
|
||||
- 2026.10.5.61 moved the hook to the import tables of `acclient.exe` and `MSVCR70.dll`, to keep
|
||||
Direct3D and drivers out of it. The private slot is in no import table, so from .61 on no DAT
|
||||
open was rewritten. The `W [filtered]` lines stopped appearing.
|
||||
- The first client then opened the DATs read/write and denied writes to everyone else
|
||||
(`share=0x1`). A second client's own read/write open failed with a sharing violation.
|
||||
|
||||
Confirmed on the running client: the three import slots pointed at the engine's detours, but the
|
||||
private slot `0x00837374` still held `kernel32!CreateFileW`.
|
||||
|
||||
## Change
|
||||
|
||||
- The DAT share hook also finds acclient.exe's private CreateFileW/CreateFileA slots, then points
|
||||
them at the same detours. Uninstall restores them like the import slots.
|
||||
- The slots are found by the stub's full byte pattern, not a fixed address:
|
||||
- push slot, push the function name, push "kernel32.dll", call the resolver, then
|
||||
`jmp [slot]` through the same slot;
|
||||
- the name must stand alone ("MyCreateFileW" does not count);
|
||||
- the DLL operand must name kernel32.dll.
|
||||
- If the slot hasn't been resolved yet (it still points at its stub), the detour calls
|
||||
`kernel32!CreateFileW` directly, because calling the stub would overwrite the slot.
|
||||
- Direct3D, drivers, the runtime and plugins still call CreateFile without the engine in the way.
|
||||
- The startup log lists the slot, for example
|
||||
`Compat: DAT share - hooked acclient.exe!CreateFileW private slot (stub 0x006B8D00) (slot 0x00837374, was 0x76ACEA10).`
|
||||
With multi-client on, the `W [filtered]: client_portal.dat` lines come back.
|
||||
|
||||
## Code
|
||||
|
||||
- `src/RynthCore.Engine/Compatibility/LazyImportSlotScanner.cs` (new): reads the section table
|
||||
of a mapped image and finds the stubs (`ReadSections`, `FindSlots`).
|
||||
- `src/RynthCore.Engine/Compatibility/DatFileShareHooks.cs`:
|
||||
- `HookLazySlots` hooks the private slots;
|
||||
- `HookSlot` builds the A/W detour for import slots and private slots alike;
|
||||
- the log line names the kind of slot.
|
||||
- `tools/DatShareSlotTests` (new), 20 checks:
|
||||
- synthetic stubs;
|
||||
- near misses that must not match (another jmp slot, another DLL, a longer name, no call, a
|
||||
slot outside the image, a lone push of the name);
|
||||
- the real 2025 client: slot `0x00837374`, stub `0x006B8D00`, no CreateFileA slot.
|
||||
|
||||
## Tests
|
||||
|
||||
- `dotnet run -c Release --project tools\DatShareSlotTests`: 20 checks, 0 failed.
|
||||
- `dotnet build src\RynthCore.Engine -c Release`: 0 errors, no new warnings.
|
||||
|
||||
## Before updating
|
||||
|
||||
Close the other clients first. A client already running on .61/.62 holds the DATs deny-write,
|
||||
so a new client can't start alongside it until it is closed, even on .64.
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
# Breadcrumbs and Route overlay on Settings > Navigation (2026.10.5.62)
|
||||
|
||||
Date: 2026-10-15
|
||||
|
||||
| Component | Version | Previous release |
|
||||
|---|---|---|
|
||||
| RynthCore.Engine | 2026.10.5.62 | 2026.10.5.61 |
|
||||
|
||||
## What's new
|
||||
|
||||
Settings > Navigation now has the Nav panel's two overlay switches, at the top of "Nav Marker
|
||||
Display":
|
||||
|
||||
- **Breadcrumbs**: record the trail you walk and draw it on the ground (`/ra navtrail on|off`).
|
||||
- **Route Overlay**: draw the route in the world, meaning the waypoint rings and lines, the
|
||||
waypoint labels and the guide line (`/ra navoverlay on|off`).
|
||||
|
||||
They are the same switches as on the Nav panel, not copies. A change in either place shows in the
|
||||
other:
|
||||
|
||||
- The Nav panel's toggle also asks the Settings page to fetch again. It updates the Nav panel's
|
||||
own settings copy too, so a nav point reach saved straight afterwards doesn't send the old value
|
||||
back.
|
||||
- A save from the Settings page also asks the Nav panel to fetch again.
|
||||
|
||||
Both panels share the tooltips (`SettingsSchema.BreadcrumbsTip` and `RouteOverlayTip`).
|
||||
|
||||
## Compatibility
|
||||
|
||||
The new fields (`TrackBreadcrumbs` and `ShowRouteOverlay` in `RynthAiSettings`) are nullable.
|
||||
|
||||
- **Older RynthAi:** it doesn't send them, so the two rows stay hidden, and a save sends null,
|
||||
which RynthAi reads as unchanged.
|
||||
- **RynthAi 0.5.70-legacy-ui or later:** sends and applies them.
|
||||
|
||||
## Files
|
||||
|
||||
- `src/RynthCore.Engine/UI/Data/SettingsData.cs`: the fields, the two rows, the shared tooltips,
|
||||
and the Nav refresh after a save.
|
||||
- `src/RynthCore.Engine/ImGui/Panels/NavFace.cs`: the shared tooltips and the local settings copy.
|
||||
- `src/RynthCore.Engine/UI/Data/RynthAiData.cs`: a Settings refresh after each nav command.
|
||||
|
||||
## Install
|
||||
|
||||
The installer build (`installer\Build-Installer.ps1`) stamps the engine as 2026.10.5.62.
|
||||
91
docs/ACCLIENT_HOOK_INVENTORY.md
Normal file
91
docs/ACCLIENT_HOOK_INVENTORY.md
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
# ACClient Hook Inventory
|
||||
|
||||
This file tracks RynthCore hook targets against the user's real AC client binary, with the AC client decompile used for semantics and the live binary used as the source of truth for hook placement.
|
||||
|
||||
## Client Fingerprint
|
||||
|
||||
- Path: `C:\Turbine\Asheron's Call\acclient.exe`
|
||||
- File size: `4,841,472` bytes
|
||||
- SHA256: `BCA95BBEBED4B9ED1FF09D0DA83144E2FC4208F63AD7ADA5CB47C3CA207CCBA9`
|
||||
- PE machine: `0x014C` (`x86`)
|
||||
- PE image size: `0x0056D000`
|
||||
|
||||
## Rules For This Inventory
|
||||
|
||||
- Use the decompile to understand semantics, call order, and callback behavior.
|
||||
- Use the live `acclient.exe` to derive patterns, validate uniqueness, and choose the real hook address.
|
||||
- Do not ship fixed RVAs from the decompile unless they have been validated against the live binary.
|
||||
- Prefer hooking the AC client function that already implements the desired behavior over lower-level memory access.
|
||||
- Every production hook should eventually have:
|
||||
- a primary binary pattern
|
||||
- at least one fallback pattern or alternate seam when practical
|
||||
- runtime validation
|
||||
- an explicit unsupported-state log/UI message
|
||||
|
||||
## Priority Inventory
|
||||
|
||||
### Lifecycle And UI
|
||||
|
||||
| Surface | Decompiled seam | Actual-binary plan for this client | Status | Priority |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| `OnLoginComplete` | `CPlayerSystem::SendLoginCompleteNotification` in `CPlayerSystem.cpp:4017-4031` | Pattern-scan the containing function using the unique `SetDisplayInventory(1)` plus `BroadcastGlobalMessage(..., 0xB, 0)` sequence, then hook the containing `thiscall` function. | Live in RynthCore | P0 |
|
||||
| `OnUIInitialized` | `ClientUISystem::OnStartup` in `ClientUISystem.cpp:48` and `APIManager::SetUIReady(1)` in `APIManager.cpp:134` | Hook the tiny `OnStartup -> SetUIReady(1)` wrapper or the `SetUIReady(1)` transition path. Prefer the wrapper if the pattern is unique in the live binary. | Not implemented | P0 |
|
||||
| `OnBusyCountIncremented` | `ClientUISystem::IncrementBusyCount` in `ClientUISystem.cpp:630` | Hook the wrapper that increments `m_cBusy` and updates cursor state when crossing `0 -> 1`. | Not implemented | P1 |
|
||||
| `OnBusyCountDecremented` | `ClientUISystem::DecrementBusyCount` in `ClientUISystem.cpp:641` | Hook the wrapper that decrements `m_cBusy` and updates cursor state when crossing `1 -> 0`. | Not implemented | P1 |
|
||||
|
||||
### Chat And Command
|
||||
|
||||
| Surface | Decompiled seam | Actual-binary plan for this client | Status | Priority |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| `OnChatWindowText` | `ClientSystem.cpp:108` | Hook the function that allocates a BSTR from `i_text`, calls `GetACPlugin()->OnChatWindowText`, then checks `bEat` before continuing UI output. | Ready for binary patterning | P0 |
|
||||
| `OnChatBarEnter` | `ClientCommunicationSystem.cpp:14407` | Hook the function that allocates a BSTR from the entered line, calls `GetACPlugin()->OnChatBarEnter`, and returns early when the plugin consumes the line. | Ready for binary patterning | P0 |
|
||||
|
||||
### World, Target, And Object Flow
|
||||
|
||||
| Surface | Decompiled seam | Actual-binary plan for this client | Status | Priority |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| `OnDeleteObject` | `ACCObjectMaint::DeleteObject` in `ACCObjectMaint.cpp:73-85` | Hook the clean wrapper that checks `APIIsReady`, calls `OnDeleteObject`, then calls `ACCWeenieObject::SetCorpseDeleted` and `CObjectMaint::DeleteObject`. | Ready for binary patterning | P0 |
|
||||
| `OnSelectedTargetChange` | `ACCWeenieObject.cpp:710` and `ACCWeenieObject.cpp:1997` | Hook the selected-target setter path after `CM_UI::SendNotice_SelectionChanged` and before the direct plugin callback. | Ready for binary patterning | P0 |
|
||||
| World/object dispatch | `ACSmartBox::DispatchSmartBoxEvent` in `ACSmartBox.cpp:37-171` | Hook the SmartBox dispatch seam as the high-value world/object/network filter layer. This is the likely replacement for many WorldFilter-style surfaces. | Ready for binary patterning | P0 |
|
||||
| Object creation | `ACCObjectMaint::CreateObject` in `ACCObjectMaint.cpp:196` | Hook the object creation wrapper for higher-level object lifecycle callbacks when we need richer data than a raw SmartBox event. | Ready for binary patterning | P1 |
|
||||
| Object inventory updates | `ACCObjectMaint::UpdateObjectInventory` in `ACCObjectMaint.cpp:377` | Hook the inventory update path for container/item-change compatibility events. | Ready for binary patterning | P1 |
|
||||
| Update/create/delete server dispatch | `CM_Physics::DispatchSB_CreateObject`, `DispatchSB_UpdateObject`, `DispatchSB_DeleteObject` in `CM_Physics.cpp` | Use as fallback seams if the outer SmartBox dispatcher proves too broad or unstable. | Decompile-confirmed | P1 |
|
||||
|
||||
### Combat And Trade
|
||||
|
||||
| Surface | Decompiled seam | Actual-binary plan for this client | Status | Priority |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| `OnCombatModeChange` | `ClientCombatSystem.cpp:1564` | Hook the branch that invokes the plugin callback after the combat mode change resolves and auto-targeting logic runs. | Ready for binary patterning | P1 |
|
||||
| Trade window opened | `ClientTradeSystem.cpp:525` | Hook `Handle_Trade__Recv_RegisterTrade` after `CM_Trade::SendNotice_RegisterTrade` and before the internal attempt-to-trade follow-up. | Ready for binary patterning | P1 |
|
||||
| Trade item added | `ClientTradeSystem::Handle_Trade__Recv_AddToTrade` in `ClientTradeSystem.cpp:560+` | Hook the direct wrapper that calls `CM_Trade::SendNotice_AddItemToTrade` and then `OnTradeWindowItemAdded`. | Ready for binary patterning | P1 |
|
||||
| Trade completed | `ClientCommunicationSystem.cpp:3106` | Hook the message-switch case for `0x529` (`Trade Complete!`) that directly invokes `OnTradeCompleted`. | Ready for binary patterning | P1 |
|
||||
| Trade accept/decline/close/clear | `ClientTradeSystem.cpp` | Hook the direct trade-system wrappers that invoke the corresponding plugin callback. | Decompiled seam confirmed, binary anchor still needed | P1 |
|
||||
|
||||
## Host Call Surface To Expose Through RynthCore
|
||||
|
||||
These are not plugin callback hooks, but they are part of the host API surface we should expose once the callback layer is in place.
|
||||
|
||||
| API surface | Decompiled seam | Notes | Priority |
|
||||
| --- | --- | --- | --- |
|
||||
| `WriteToChat` | `APIManager__IAsheronsCallImpl.cpp` | Safe early host helper. | P0 |
|
||||
| Selection get/set | `APIManager__IAsheronsCallImpl.cpp` | Pairs naturally with target-change callbacks. | P0 |
|
||||
| `UseObject`, `UseObjectOn`, `UseEquippedItem` | `APIManager__IAsheronsCallImpl.cpp` | Good interaction helpers once lifecycle is stable. | P1 |
|
||||
| `MoveItemExternal`, `MoveItemInternal` | `APIManager__IAsheronsCallImpl.cpp` | Useful once inventory callbacks exist. | P1 |
|
||||
| `IsStandingStill`, `StopCompletely`, `TurnToHeading`, `SetAutoRun` | `APIManager__IAsheronsCallImpl.cpp` | Movement helper layer. Some of this already overlaps with existing RynthCore action hooks. | P0 |
|
||||
| `GetCurCoords`, `GetPlayerID`, `GetGroundContainerID` | `APIManager__IAsheronsCallImpl.cpp` | Good basic state helpers. | P0 |
|
||||
| `GetScreenDimensions`, `ItemIsKnown`, `GetItemName` | `APIManager__IAsheronsCallImpl.cpp` | Low-risk host helpers. | P1 |
|
||||
| `IssueChatBarCommand` | `APIManager__IAsheronsCallImpl.cpp` | Treat as stub-like until runtime behavior is validated against the live client. | Hold |
|
||||
| `GetCombatMode`, `GetBusyCount`, salvage panel APIs | `APIManager__IAsheronsCallImpl_vtbl.cpp` | Declared but not yet fully validated in the split. | Hold |
|
||||
|
||||
## Implementation Waves
|
||||
|
||||
1. Finish lifecycle/UI: `OnLoginComplete`, `OnUIInitialized`, busy count.
|
||||
2. Add chat interception: `OnChatWindowText`, `OnChatBarEnter`.
|
||||
3. Add world/object seams: SmartBox dispatch, delete/create/inventory, selected target.
|
||||
4. Add combat/trade callbacks.
|
||||
5. Expose the confirmed `IAsheronsCall` subset through RynthCore-native host APIs.
|
||||
|
||||
## Notes
|
||||
|
||||
- The split decompile is still very useful, but the login-complete work already showed that its function RVAs do not always line up with the user's live client binary.
|
||||
- For this reason, future hook work should be tracked here first against the fingerprint above, then implemented in RynthCore with pattern scanning rather than fixed addresses.
|
||||
|
|
@ -43,12 +43,7 @@ param(
|
|||
# portals.tsv and locations.json from this folder. Only re-uploaded when the set changes
|
||||
# (its id is a hash of every file); otherwise the live feed's entry is carried over.
|
||||
[string]$NavDataDir = "C:\Games\RynthCore\NavData",
|
||||
[switch]$SkipNavData, # leave navdata out of this feed (launchers then keep what they have)
|
||||
# The World Map's optional sizes (RynthNav.Baker --map-world): worldmap-hd.rmap, worldmap-ultra.rmap and worldmap-p32.rmap from this
|
||||
# folder are offered by the launcher as separate downloads ("mappacks" in the feed). Each is uploaded once under
|
||||
# mappacks/<first 16 hex of its SHA-256>/ and kept by later releases. Without this folder the live feed's packs are
|
||||
# carried over unchanged, so a release that doesn't touch the maps never drops them.
|
||||
[string]$MapPacksDir = ""
|
||||
[switch]$SkipNavData # leave navdata out of this feed (launchers then keep what they have)
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
|
@ -149,19 +144,6 @@ foreach ($name in $suitePlugins) {
|
|||
Copy-Item "$rel\build\$name\RynthCore.Plugin.$name.dll" "$rel\plugins\"
|
||||
}
|
||||
|
||||
# Server plugins (Plugins\Shared\ServerPack; SilentKelpie's): one per game server, each loaded by the
|
||||
# engine only for its own server. They go in the feed only, so the launcher offers each one under
|
||||
# Available plugins for the player to install; not in RynthSuite-Plugins.zip or the installer.
|
||||
$serverPlugins = "RynthAChard", "RynthAelrynth", "RynthColdeve", "RynthConquest", "RynthDerptide", "RynthDreamWeave", "RynthEversong",
|
||||
"RynthFrostACE", "RynthFrostcull", "RynthLeafDawn", "RynthLeafdawning", "RynthPortalStorm", "RynthReefcull", "RynthSundering", "RynthThistlecrown"
|
||||
foreach ($name in $serverPlugins) {
|
||||
Step "Building $name (server plugin, feed only)"
|
||||
$proj = Join-Path $RynthSuiteRoot "Plugins\RynthCore.Plugin.$name\RynthCore.Plugin.$name.csproj"
|
||||
dotnet publish $proj -c Release "-p:Version=$Version" "-p:PublishDir=$rel\build\$name\" -v q -nologo
|
||||
if ($LASTEXITCODE -ne 0) { throw "dotnet publish failed for $name" }
|
||||
Copy-Item "$rel\build\$name\RynthCore.Plugin.$name.dll" "$rel\plugins\"
|
||||
}
|
||||
|
||||
Step "Packing RynthSuite-Plugins.zip"
|
||||
$zipRoot = "$rel\build\zip"
|
||||
foreach ($name in $suitePlugins) {
|
||||
|
|
@ -220,19 +202,12 @@ Compress-Archive -Path "$zipRoot\*" -DestinationPath "$rel\RynthSuite-Plugins.zi
|
|||
$navData = $null
|
||||
$navZip = $null
|
||||
if (-not $SkipNavData) {
|
||||
Step "RynthNav data (tiles, route graph, portals, Atlas, Town Network, World Map) from $NavDataDir"
|
||||
$navFiles = @(Get-ChildItem $NavDataDir -File | Where-Object { $_.Name -match '^(nav_[0-9A-Fa-f]{4}\.tile|portals\.tsv|locations\.json|navgraph\.bin|townnet\.json|worldmap\.rmap|worldmap\.vec)$' } | Sort-Object Name)
|
||||
Step "RynthNav data (tiles, route graph, portals, Atlas, Town Network) from $NavDataDir"
|
||||
$navFiles = @(Get-ChildItem $NavDataDir -File | Where-Object { $_.Name -match '^(nav_[0-9A-Fa-f]{4}\.tile|portals\.tsv|locations\.json|navgraph\.bin|townnet\.json)$' } | Sort-Object Name)
|
||||
$tileCount = @($navFiles | Where-Object { $_.Extension -eq ".tile" }).Count
|
||||
if ($tileCount -eq 0) { throw "$NavDataDir has no tiles. Pass -NavDataDir, or -SkipNavData to publish without them." }
|
||||
# The long-range route graph (RynthNav.Baker --graph) must come from these very tiles: the
|
||||
# plugin ignores a graph whose tiles don't match (long gotos then walk the straight line).
|
||||
# The World Map's picture (RynthNav.Baker --map --map-tiles from the dats; the terrain doesn't change between releases).
|
||||
if (-not ($navFiles | Where-Object { $_.Name -eq "worldmap.rmap" })) {
|
||||
Write-Warning "No worldmap.rmap in ${NavDataDir}: the World Map has no picture. Run: RynthNav.Baker --map --map-tiles --out <dir> and copy worldmap.rmap there."
|
||||
}
|
||||
if (-not ($navFiles | Where-Object { $_.Name -eq "worldmap.vec" })) {
|
||||
Write-Warning "No worldmap.vec in ${NavDataDir}: the World Map has no buildings or roads. Run: RynthNav.Baker --map-vectors --out <dir> and copy worldmap.vec there."
|
||||
}
|
||||
$graph = $navFiles | Where-Object { $_.Name -eq "navgraph.bin" }
|
||||
$newestTile = ($navFiles | Where-Object { $_.Extension -eq ".tile" } | Measure-Object LastWriteTimeUtc -Maximum).Maximum
|
||||
if (-not $graph) { Write-Warning "No navgraph.bin in ${NavDataDir}: long gotos will walk the straight line. Run: RynthNav.Baker --graph $NavDataDir" }
|
||||
|
|
@ -280,41 +255,6 @@ if (-not $SkipNavData) {
|
|||
}
|
||||
}
|
||||
|
||||
# ── World map packs (optional sizes) ─────────────────────────────────────────
|
||||
# key -> what the launcher shows; the file names are what RynthNav.Baker --map-world writes (extreme = --ppc 32, whose default name is worldmap-p32.rmap).
|
||||
$mapPackDefs = [ordered]@{
|
||||
hd = @{ name = "HD"; file = "worldmap-hd.rmap"; description = "Sharper ground, roads, rooftops and trees." }
|
||||
ultra = @{ name = "Ultra"; file = "worldmap-ultra.rmap"; description = "Very sharp: individual roofs and trees. Large download." }
|
||||
extreme = @{ name = "Extreme"; file = "worldmap-p32.rmap"; description = "Every roof, road and tree in detail. Very large download (about 1 GB)." }
|
||||
# (The 64 px "Maximum" map, worldmap-p64.rmap, is deliberately NOT here: it is for private use only and is never offered to players.)
|
||||
}
|
||||
$mapPacks = @()
|
||||
$mapPackUploads = @() # files to put on the server: @{ Path; Remote; Sha }
|
||||
if ($MapPacksDir) {
|
||||
Step "World map packs from $MapPacksDir"
|
||||
foreach ($key in $mapPackDefs.Keys) {
|
||||
$def = $mapPackDefs[$key]
|
||||
$f = Join-Path $MapPacksDir $def.file
|
||||
if (-not (Test-Path $f)) { Write-Host " $($def.name): no $($def.file) here, not offered by this feed"; continue }
|
||||
$sha = Sha256 $f
|
||||
$id = $sha.Substring(0, 16)
|
||||
$mapPacks += [ordered]@{
|
||||
key = $key; name = $def.name; file = $def.file
|
||||
url = "$BaseUrl/mappacks/$id/$($def.file)"
|
||||
size = [long](Get-Item $f).Length; sha256 = $sha; release = $release; description = $def.description
|
||||
}
|
||||
$mapPackUploads += @{ Path = $f; Remote = "mappacks/$id/$($def.file)"; Sha = $sha }
|
||||
Write-Host (" {0}: {1:N1} MB, {2}" -f $def.name, ((Get-Item $f).Length / 1MB), $id)
|
||||
}
|
||||
} elseif ($liveManifest -and $liveManifest.mappacks) {
|
||||
# Carried over from the live feed (ConvertFrom-Json): force the whole numbers back to integers.
|
||||
$mapPacks = @($liveManifest.mappacks | ForEach-Object {
|
||||
[ordered]@{ key = [string]$_.key; name = [string]$_.name; file = [string]$_.file; url = [string]$_.url; size = [long]$_.size
|
||||
sha256 = [string]$_.sha256; release = [long]$_.release; description = [string]$_.description }
|
||||
})
|
||||
Write-Host " map packs: $($mapPacks.Count) carried over from the live feed"
|
||||
}
|
||||
|
||||
# ── 3. Manifest + signature ──────────────────────────────────────────────────
|
||||
Step "Writing and signing the manifest"
|
||||
$setup = Get-Item "$rel\RynthCore-Setup.exe"
|
||||
|
|
@ -351,11 +291,9 @@ $plugins = foreach ($dll in Get-ChildItem "$rel\plugins\*.dll" | Sort-Object Nam
|
|||
size = $dll.Length
|
||||
sha256 = Sha256 $dll.FullName
|
||||
}
|
||||
$pm = Get-RynthPluginManifest $dll.FullName
|
||||
# The table first; a server plugin's own manifest description otherwise (its csproj's RynthPluginDescription).
|
||||
if ($pluginDescriptions[$pluginName]) { $entry.description = $pluginDescriptions[$pluginName] }
|
||||
elseif ($pm -and $pm.description) { $entry.description = [string]$pm.description }
|
||||
else { Write-Warning "No description for $pluginName - the launcher shows its own (or none). Add one to `$pluginDescriptions." }
|
||||
$pm = Get-RynthPluginManifest $dll.FullName
|
||||
if ($pm) {
|
||||
if ($pm.name -ne $pluginName) { throw "$($dll.Name): its manifest says '$($pm.name)', the feed would say '$pluginName'." }
|
||||
if ($pm.version -and $pm.version -ne $Version) { throw "$($dll.Name): its manifest is version $($pm.version), not $Version (stale build?)." }
|
||||
|
|
@ -389,7 +327,6 @@ $manifest = [ordered]@{
|
|||
plugins = @($plugins)
|
||||
}
|
||||
if ($navData) { $manifest.navdata = $navData }
|
||||
if ($mapPacks.Count -gt 0) { $manifest.mappacks = @($mapPacks) }
|
||||
Set-Content "$rel\update.payload.json" ($manifest | ConvertTo-Json -Depth 5) -Encoding utf8NoBOM
|
||||
& (Join-Path $ScriptDir "Sign-Update.ps1") -PayloadPath "$rel\update.payload.json" -OutPath "$rel\update.json" -KeyDir $KeyDir
|
||||
if (-not (Test-Envelope "$rel\update.json" $trusted)) { throw "Signed feed does not verify against UpdateTrust.cs" }
|
||||
|
|
@ -425,23 +362,6 @@ if ($navZip) {
|
|||
$navSum = " RynthNav-NavData.zip"
|
||||
}
|
||||
|
||||
# World map packs: content-addressed (the folder is the start of the file's SHA-256), so a pack already on the server
|
||||
# is not sent again and an old release's URL keeps working.
|
||||
foreach ($up in $mapPackUploads) {
|
||||
$remoteFile = "$RemoteDir/$($up.Remote)"
|
||||
ssh $SshHost "test -f '$remoteFile'"
|
||||
if ($LASTEXITCODE -eq 0) { Write-Host " $($up.Remote): already on the server"; continue }
|
||||
ssh $SshHost "mkdir -p '$(Split-Path $remoteFile -Parent | ForEach-Object { $_ -replace '\\','/' })'"
|
||||
if ($LASTEXITCODE -ne 0) { throw "ssh mkdir for $($up.Remote) failed" }
|
||||
scp -q $up.Path "${SshHost}:$remoteFile.part"
|
||||
if ($LASTEXITCODE -ne 0) { throw "scp of $($up.Remote) failed" }
|
||||
$got = (ssh $SshHost "sha256sum '$remoteFile.part'") -split '\s+' | Select-Object -First 1
|
||||
if ($got -ne $up.Sha) { ssh $SshHost "rm -f '$remoteFile.part'"; throw "Hash mismatch on the server for $($up.Remote) — feed NOT published" }
|
||||
ssh $SshHost "mv -f '$remoteFile.part' '$remoteFile'"
|
||||
if ($LASTEXITCODE -ne 0) { throw "Publishing $($up.Remote) failed" }
|
||||
Write-Host " $($up.Remote): uploaded and hash-checked"
|
||||
}
|
||||
|
||||
$remoteSums = ssh $SshHost "cd '$remoteRel' && sha256sum RynthCore-Setup.exe plugins/*.dll$navSum"
|
||||
$expect = @{ "RynthCore-Setup.exe" = $manifest.core.sha256 }
|
||||
if ($navZip) { $expect["RynthNav-NavData.zip"] = $navData.sha256 }
|
||||
|
|
|
|||
|
|
@ -141,17 +141,6 @@
|
|||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- The World Map's optional sizes (MainWindow.RefreshMapPacksCard; the feed's "mappacks"). -->
|
||||
<Border x:Name="MapPacksCard" Background="#132028" CornerRadius="16" Padding="18" IsVisible="False"
|
||||
BorderBrush="#243742" BorderThickness="1">
|
||||
<StackPanel Spacing="8">
|
||||
<TextBlock Text="World map detail" FontSize="16" FontWeight="SemiBold" Foreground="#26C1A6" />
|
||||
<TextBlock TextWrapping="Wrap" Foreground="#9AA8B3"
|
||||
Text="The in-game World Map comes in sizes. The standard one is installed with RynthNav; the sharper ones are optional downloads. The map uses the best size you have installed, and its Show menu lets you switch between them." />
|
||||
<StackPanel x:Name="MapPacksPanel" Spacing="8" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border Background="#132028" CornerRadius="16" Padding="18">
|
||||
<StackPanel Spacing="8">
|
||||
<TextBlock Text="Launch Targets" FontSize="16" FontWeight="SemiBold" Foreground="#26C1A6" />
|
||||
|
|
|
|||
|
|
@ -2520,100 +2520,6 @@ internal partial class MainWindow : Window
|
|||
}
|
||||
}
|
||||
|
||||
// ── World map sizes (RynthUpdater.MapPacks.cs) ───────────────────────
|
||||
|
||||
private string _mapPacksShown = "";
|
||||
|
||||
/// <summary>
|
||||
/// The front page's "World map detail" card: a row per size the feed offers (name, download size, whether it is
|
||||
/// installed) with Download / Update / Remove. Rebuilt only when what it shows changes; the buttons are off while
|
||||
/// a download or an update runs. Called from RefreshUpdateCard, so it follows every check and download.
|
||||
/// </summary>
|
||||
private void RefreshMapPacksCard()
|
||||
{
|
||||
IReadOnlyList<RynthUpdater.MapPackStatus> packs = _updateCheck?.MapPacks ?? Array.Empty<RynthUpdater.MapPackStatus>();
|
||||
MapPacksCard.IsVisible = packs.Count > 0;
|
||||
bool busy = _updateBusy || _downloadCts != null;
|
||||
string signature = busy + "|" + string.Join(";", packs.Select(p => $"{p.Entry.Key}:{p.State}:{p.Entry.Sha256}"));
|
||||
if (signature == _mapPacksShown) return;
|
||||
_mapPacksShown = signature;
|
||||
MapPacksPanel.Children.Clear();
|
||||
foreach (RynthUpdater.MapPackStatus st in packs)
|
||||
{
|
||||
RynthUpdater.MapPackEntry e = st.Entry;
|
||||
string state = st.State switch
|
||||
{
|
||||
RynthUpdater.MapPackState.UpToDate => "installed",
|
||||
RynthUpdater.MapPackState.NeedsUpdate => "installed, a newer one is available",
|
||||
_ => "not installed",
|
||||
};
|
||||
var title = new TextBlock { Text = $"{e.Name} - {DownloadProgress.FormatMb(e.Size)}", FontWeight = global::Avalonia.Media.FontWeight.SemiBold, Foreground = global::Avalonia.Media.Brushes.White };
|
||||
var detail = new TextBlock { Text = (e.Description.Length > 0 ? e.Description + " " : "") + "(" + state + ")", TextWrapping = global::Avalonia.Media.TextWrapping.Wrap, Foreground = global::Avalonia.Media.Brush.Parse("#9AA8B3") };
|
||||
var text = new StackPanel { Spacing = 2, VerticalAlignment = global::Avalonia.Layout.VerticalAlignment.Center };
|
||||
text.Children.Add(title);
|
||||
text.Children.Add(detail);
|
||||
|
||||
var buttons = new WrapPanel { Orientation = global::Avalonia.Layout.Orientation.Horizontal, VerticalAlignment = global::Avalonia.Layout.VerticalAlignment.Center, Margin = new global::Avalonia.Thickness(12, 0, 0, 0) };
|
||||
if (st.State != RynthUpdater.MapPackState.UpToDate)
|
||||
{
|
||||
var get = new Button { Content = st.State == RynthUpdater.MapPackState.NeedsUpdate ? "Update" : "Download", IsEnabled = !busy, Margin = new global::Avalonia.Thickness(0, 0, 8, 0) };
|
||||
get.Click += async (_, _) => await InstallMapPackAsync(st);
|
||||
buttons.Children.Add(get);
|
||||
}
|
||||
if (st.State != RynthUpdater.MapPackState.NotInstalled)
|
||||
{
|
||||
var remove = new Button { Content = "Remove", IsEnabled = !busy };
|
||||
remove.Click += async (_, _) => await RemoveMapPackAsync(st);
|
||||
buttons.Children.Add(remove);
|
||||
}
|
||||
var row = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto") };
|
||||
Grid.SetColumn(text, 0);
|
||||
Grid.SetColumn(buttons, 1);
|
||||
row.Children.Add(text);
|
||||
row.Children.Add(buttons);
|
||||
MapPacksPanel.Children.Add(row);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task InstallMapPackAsync(RynthUpdater.MapPackStatus st)
|
||||
{
|
||||
if (_updateBusy || _downloadCts != null) return;
|
||||
_updateBusy = true;
|
||||
RefreshUpdateCard();
|
||||
try
|
||||
{
|
||||
string line = await RunDownloadAsync((progress, ct) => _updater.InstallMapPackAsync(st.Entry, progress, ct));
|
||||
AppendActivity(line);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
AppendActivity($"World map ({st.Entry.Name}) download cancelled. Nothing was changed.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppendActivity($"World map ({st.Entry.Name}) download failed: {ex.Message}");
|
||||
}
|
||||
finally { _updateBusy = false; }
|
||||
_updateCheck = await _updater.CheckAsync(_pluginDllPaths.ToList());
|
||||
RefreshUpdateCard();
|
||||
}
|
||||
|
||||
private async Task RemoveMapPackAsync(RynthUpdater.MapPackStatus st)
|
||||
{
|
||||
if (_updateBusy || _downloadCts != null) return;
|
||||
try
|
||||
{
|
||||
bool had = await Task.Run(() => _updater.RemoveMapPack(st.Entry));
|
||||
AppendActivity(had ? $"World map ({st.Entry.Name}) removed." : $"World map ({st.Entry.Name}) wasn't installed.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppendActivity($"World map ({st.Entry.Name}) couldn't be removed: {ex.Message} (a running game client may have it open).");
|
||||
}
|
||||
_updateCheck = await _updater.CheckAsync(_pluginDllPaths.ToList());
|
||||
RefreshUpdateCard();
|
||||
}
|
||||
|
||||
private void CancelDownload()
|
||||
{
|
||||
if (_downloadCts is not { IsCancellationRequested: false } cts) return;
|
||||
|
|
@ -2643,7 +2549,6 @@ internal partial class MainWindow : Window
|
|||
/// <summary>Redraws the front page's update card, the Plugins tab's status line and the header.</summary>
|
||||
private void RefreshUpdateCard()
|
||||
{
|
||||
RefreshMapPacksCard();
|
||||
RynthUpdater.CheckResult? c = _updateCheck;
|
||||
bool coreUpdate = c?.CoreUpdateAvailable == true;
|
||||
var card = UpdateCardModel.Build(new UpdateCardInput
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\RynthCore.App\LaunchServerProfile.cs" Link="Shared\LaunchServerProfile.cs" />
|
||||
<Compile Include="..\RynthCore.App\KnownServerCatalog.cs" Link="Shared\KnownServerCatalog.cs" />
|
||||
<Compile Include="..\RynthCore.App\LaunchAccountProfile.cs" Link="Shared\LaunchAccountProfile.cs" />
|
||||
<Compile Include="..\RynthCore.App\AccountPasswordProtection.cs" Link="Shared\AccountPasswordProtection.cs" />
|
||||
<Compile Include="..\RynthCore.App\InjectionMode.cs" Link="Shared\InjectionMode.cs" />
|
||||
|
|
|
|||
|
|
@ -1,146 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RynthCore.App.Avalonia;
|
||||
|
||||
/// <summary>
|
||||
/// The World Map's optional sizes. The Standard map ships in the NavData archive like the tiles; the bigger
|
||||
/// ones (worldmap-hd.rmap, worldmap-ultra.rmap: tens to hundreds of MB) are separate, optional downloads the
|
||||
/// player picks on the launcher's front page, each a single file the feed lists under "mappacks":
|
||||
/// { "key": "hd", "name": "HD", "file": "worldmap-hd.rmap", "url": "...", "size": N, "sha256": "...",
|
||||
/// "release": N, "description": "..." }
|
||||
/// A pack is downloaded to MapPacks\<file>.part, checked against the feed's size and SHA-256, and moved into
|
||||
/// place; MapPacks\<file>.sha256 records which build is installed (so a changed pack shows as an update).
|
||||
/// MapPacks sits beside the NavData folder (C:\Games\RynthCore\MapPacks by default), not inside it, because
|
||||
/// a NavData update swaps that whole folder. The engine's World Map uses the best map it finds in either
|
||||
/// place, so installing a pack needs no restart; a client picks it up when the panel next opens.
|
||||
/// </summary>
|
||||
internal sealed partial class RynthUpdater
|
||||
{
|
||||
public const string MapPackDisplayName = "World map";
|
||||
public const string MapPacksFolder = "MapPacks";
|
||||
private const long MaxMapPackBytes = 4L << 30;
|
||||
|
||||
private static readonly Regex MapPackKey = new(@"^[a-z0-9]{1,16}$", RegexOptions.CultureInvariant);
|
||||
private static readonly Regex MapPackFile = new(@"^worldmap-[a-z0-9]{1,16}\.rmap$", RegexOptions.CultureInvariant);
|
||||
|
||||
public sealed record MapPackEntry(string Key, string Name, string File, string Url, long Size, string Sha256, int Release, string Description);
|
||||
public enum MapPackState { NotInstalled, UpToDate, NeedsUpdate }
|
||||
public sealed record MapPackStatus(MapPackEntry Entry, string Path, MapPackState State);
|
||||
|
||||
/// <summary>Where the packs are installed: beside the NavData folder.</summary>
|
||||
public string MapPacksDir
|
||||
{
|
||||
get
|
||||
{
|
||||
string nav = NavDataDir.TrimEnd('\\', '/');
|
||||
return System.IO.Path.Combine(System.IO.Path.GetDirectoryName(nav) ?? nav, MapPacksFolder);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The feed's map packs. One that can't be read is left out (the rest still show).</summary>
|
||||
private IReadOnlyList<MapPackEntry> ReadMapPacks(JsonElement root)
|
||||
{
|
||||
var list = new List<MapPackEntry>();
|
||||
if (!root.TryGetProperty("mappacks", out JsonElement arr) || arr.ValueKind != JsonValueKind.Array) return list;
|
||||
var keys = new HashSet<string>();
|
||||
foreach (JsonElement p in arr.EnumerateArray())
|
||||
{
|
||||
try
|
||||
{
|
||||
string key = (p.GetProperty("key").GetString() ?? "").ToLowerInvariant();
|
||||
string file = p.GetProperty("file").GetString() ?? "";
|
||||
if (!MapPackKey.IsMatch(key) || !MapPackFile.IsMatch(file) || !keys.Add(key)) continue;
|
||||
long size = WholeNumber(p.GetProperty("size"));
|
||||
if (size <= 0 || size > MaxMapPackBytes) continue;
|
||||
string sha = (p.GetProperty("sha256").GetString() ?? "").ToLowerInvariant();
|
||||
if (sha.Length != 64) continue;
|
||||
list.Add(new MapPackEntry(key, p.TryGetProperty("name", out JsonElement n) ? n.GetString() ?? key : key, file,
|
||||
CheckUrl(p.GetProperty("url").GetString()), size, sha,
|
||||
p.TryGetProperty("release", out JsonElement rel) ? (int)WholeNumber(rel) : 0,
|
||||
p.TryGetProperty("description", out JsonElement d) ? d.GetString() ?? "" : ""));
|
||||
}
|
||||
catch (Exception ex) when (ex is InvalidDataException or FormatException or InvalidOperationException or KeyNotFoundException)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"RynthUpdater: a map pack entry is unreadable ({ex.Message}); skipped.");
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private IReadOnlyList<MapPackStatus> CheckMapPacks(Manifest manifest)
|
||||
{
|
||||
string dir = MapPacksDir;
|
||||
var list = new List<MapPackStatus>();
|
||||
foreach (MapPackEntry e in manifest.MapPacks)
|
||||
{
|
||||
string path = System.IO.Path.Combine(dir, e.File);
|
||||
MapPackState state;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(path)) state = MapPackState.NotInstalled;
|
||||
else
|
||||
{
|
||||
string marker = path + ".sha256";
|
||||
string installed = File.Exists(marker) ? File.ReadAllText(marker).Trim().ToLowerInvariant() : "";
|
||||
// No marker: a file put there by hand counts as current if it is the size the feed says.
|
||||
state = installed.Length > 0 ? (installed == e.Sha256 ? MapPackState.UpToDate : MapPackState.NeedsUpdate)
|
||||
: new FileInfo(path).Length == e.Size ? MapPackState.UpToDate : MapPackState.NeedsUpdate;
|
||||
}
|
||||
}
|
||||
catch { state = MapPackState.NotInstalled; }
|
||||
list.Add(new MapPackStatus(e, path, state));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Downloads, verifies and installs a map pack (or replaces an older build of it). Returns a line for the
|
||||
/// activity log. Throws on anything wrong (disk space, a bad download); the file that was there stays as it
|
||||
/// was. Cancel deletes the partial download.
|
||||
/// </summary>
|
||||
public async Task<string> InstallMapPackAsync(MapPackEntry e, IProgress<DownloadProgress>? progress = null, CancellationToken ct = default)
|
||||
{
|
||||
string dir = MapPacksDir;
|
||||
Directory.CreateDirectory(dir);
|
||||
// The pack is downloaded beside where it goes, so the finishing move is a rename.
|
||||
long need = e.Size + (64L << 20);
|
||||
long free = new DriveInfo(System.IO.Path.GetPathRoot(System.IO.Path.GetFullPath(dir))!).AvailableFreeSpace;
|
||||
if (free < need)
|
||||
throw new IOException($"not enough disk space for the {e.Name} map: {need >> 20} MB needed, {free >> 20} MB free on {System.IO.Path.GetPathRoot(dir)}");
|
||||
|
||||
string target = System.IO.Path.Combine(dir, e.File), part = target + ".part";
|
||||
string what = $"{MapPackDisplayName} ({e.Name})";
|
||||
try
|
||||
{
|
||||
await DownloadVerifiedAsync(e.Url, e.Size, e.Sha256, MaxMapPackBytes, part, ct, what, progress);
|
||||
ct.ThrowIfCancellationRequested();
|
||||
progress?.Report(new DownloadProgress(what, DownloadStage.Installing, 0, 0));
|
||||
Retry(() => File.Move(part, target, overwrite: true)); // a client may have it open for a moment
|
||||
File.WriteAllText(target + ".sha256", e.Sha256);
|
||||
}
|
||||
catch
|
||||
{
|
||||
try { if (File.Exists(part)) File.Delete(part); } catch { }
|
||||
throw;
|
||||
}
|
||||
return $"{MapPackDisplayName} ({e.Name}) installed: {target} ({DownloadProgress.FormatMb(e.Size)}). The World Map uses the best installed size; a map that is already open picks it up when you reopen it.";
|
||||
}
|
||||
|
||||
/// <summary>Deletes an installed map pack (and its marker). Returns false when it wasn't there.</summary>
|
||||
public bool RemoveMapPack(MapPackEntry e)
|
||||
{
|
||||
string target = System.IO.Path.Combine(MapPacksDir, e.File);
|
||||
bool had = File.Exists(target);
|
||||
Retry(() => { if (File.Exists(target)) File.Delete(target); });
|
||||
try { if (File.Exists(target + ".sha256")) File.Delete(target + ".sha256"); } catch { }
|
||||
try { if (File.Exists(target + ".part")) File.Delete(target + ".part"); } catch { }
|
||||
return had;
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ namespace RynthCore.App.Avalonia;
|
|||
/// The signature covers it exactly like the plugins; the archive is checked against the signed
|
||||
/// size and SHA-256 before it is opened, and only plain file names RynthNav reads
|
||||
/// (nav_XXXX.tile, portals.tsv, locations.json, navgraph.bin: the long-range route graph,
|
||||
/// townnet.json: the Town Network's portals and the walks inside, worldmap.rmap and worldmap.vec: the World Map's tiles, buildings and roads) are
|
||||
/// townnet.json: the Town Network's portals and the walks inside) are
|
||||
/// accepted from it.
|
||||
///
|
||||
/// Install: only when RynthNav is in the plugin list and the folder's navdata.id differs from the
|
||||
|
|
@ -40,7 +40,7 @@ internal sealed partial class RynthUpdater
|
|||
private const long MaxNavDataBytes = 3L << 30; // the archive
|
||||
private const long MaxNavDataEntryBytes = 32L << 20; // one file in it
|
||||
|
||||
private static readonly Regex ShippedName = new(@"^(nav_[0-9A-Fa-f]{4}\.tile|portals\.tsv|locations\.json|navgraph\.bin|townnet\.json|worldmap\.rmap|worldmap\.vec)$", RegexOptions.CultureInvariant);
|
||||
private static readonly Regex ShippedName = new(@"^(nav_[0-9A-Fa-f]{4}\.tile|portals\.tsv|locations\.json|navgraph\.bin|townnet\.json)$", RegexOptions.CultureInvariant);
|
||||
private static readonly Regex IdPattern = new(@"^[0-9a-f]{16,64}$", RegexOptions.CultureInvariant);
|
||||
|
||||
public sealed record NavDataEntry(string Id, int Release, string Url, long Size, string Sha256, int Files, long Bytes);
|
||||
|
|
|
|||
|
|
@ -58,8 +58,6 @@ internal sealed partial class RynthUpdater
|
|||
/// signed with the rest). Empty for older feeds, which only have <see cref="Notes"/>.
|
||||
/// </summary>
|
||||
public IReadOnlyList<string> Changes { get; init; } = Array.Empty<string>();
|
||||
/// <summary>The optional World Map sizes the feed offers (RynthUpdater.MapPacks.cs); empty for older feeds.</summary>
|
||||
public IReadOnlyList<MapPackEntry> MapPacks { get; init; } = Array.Empty<MapPackEntry>();
|
||||
}
|
||||
|
||||
/// <summary>One installed copy of a plugin the feed knows.</summary>
|
||||
|
|
@ -93,8 +91,6 @@ internal sealed partial class RynthUpdater
|
|||
/// <summary>RynthNav's tiles: null when the feed has none or RynthNav isn't in the plugin list.</summary>
|
||||
public NavDataStatus? NavData { get; init; }
|
||||
public bool NavDataUpdateAvailable => NavData is { State: NavDataState.NeedsUpdate };
|
||||
/// <summary>The optional World Map sizes: what the feed offers and what is installed. Not part of "Update plugins": the player chooses.</summary>
|
||||
public IReadOnlyList<MapPackStatus> MapPacks { get; init; } = Array.Empty<MapPackStatus>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -217,7 +213,6 @@ internal sealed partial class RynthUpdater
|
|||
{
|
||||
Companions = companions,
|
||||
NavData = CheckNavData(manifest, pluginPaths),
|
||||
MapPacks = CheckMapPacks(manifest),
|
||||
Available = available,
|
||||
NewlyAnnounced = available.Where(a => fresh.Contains(a.Entry.Name)).ToList(),
|
||||
};
|
||||
|
|
@ -401,7 +396,6 @@ internal sealed partial class RynthUpdater
|
|||
r.TryGetProperty("navdata", out JsonElement nd) && nd.ValueKind == JsonValueKind.Object ? TryParseNavData(nd) : null)
|
||||
{
|
||||
Changes = ReadChanges(r),
|
||||
MapPacks = ReadMapPacks(r),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="RynthCore.App.Avalonia.ServerProfileDialog"
|
||||
Width="520"
|
||||
Height="420"
|
||||
Width="560"
|
||||
Height="560"
|
||||
CanResize="False"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Title="Server Profile"
|
||||
Background="#132028">
|
||||
<Grid RowDefinitions="*,Auto" Margin="18">
|
||||
<StackPanel Spacing="12">
|
||||
<TextBlock Text="Known server" Foreground="#EAF0F4" />
|
||||
<ComboBox x:Name="KnownServerBox" HorizontalAlignment="Stretch" />
|
||||
<TextBlock x:Name="KnownServerNote" Foreground="#9FB3C0" FontSize="12" TextWrapping="Wrap" />
|
||||
<TextBlock Text="Server Name" Foreground="#EAF0F4" />
|
||||
<TextBox x:Name="NameBox" />
|
||||
<TextBlock Text="Alias" Foreground="#EAF0F4" />
|
||||
|
|
|
|||
|
|
@ -1,12 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Avalonia.Controls;
|
||||
using RynthCore.App;
|
||||
|
||||
namespace RynthCore.App.Avalonia;
|
||||
|
||||
internal partial class ServerProfileDialog : Window
|
||||
{
|
||||
/// <summary>The picker's first entry: keep whatever is typed in the fields.</summary>
|
||||
private const string CustomServerLabel = "Custom server (fill in the fields below)";
|
||||
|
||||
private readonly RynthCore.App.LaunchServerProfile _profile;
|
||||
|
||||
/// <summary>True while the constructor selects the profile's known server, so it isn't re-applied.</summary>
|
||||
private bool _loading;
|
||||
|
||||
public ServerProfileDialog(RynthCore.App.LaunchServerProfile profile)
|
||||
{
|
||||
_profile = profile;
|
||||
|
|
@ -20,10 +28,47 @@ internal partial class ServerProfileDialog : Window
|
|||
EmulatorBox.SelectedItem = profile.Emulator.ToString();
|
||||
RodatCheck.IsChecked = profile.RodatEnabled;
|
||||
|
||||
var choices = new List<object> { CustomServerLabel };
|
||||
choices.AddRange(KnownServerCatalog.All);
|
||||
KnownServerBox.ItemsSource = choices;
|
||||
KnownServerBox.SelectionChanged += (_, _) => OnKnownServerChanged();
|
||||
|
||||
_loading = true;
|
||||
KnownServer? current = KnownServerCatalog.FindByHost(profile.Host);
|
||||
KnownServerBox.SelectedItem = current != null ? current : CustomServerLabel;
|
||||
_loading = false;
|
||||
ShowKnownServerNote(current);
|
||||
|
||||
SaveButton.Click += (_, _) => SaveAndClose();
|
||||
CancelButton.Click += (_, _) => Close(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Picking a known server fills Name, Host, Port and Emulator from the catalog; Alias and
|
||||
/// Rodat stay as typed. Picking "Custom server" leaves the fields alone.
|
||||
/// </summary>
|
||||
private void OnKnownServerChanged()
|
||||
{
|
||||
KnownServer? server = KnownServerBox.SelectedItem as KnownServer;
|
||||
ShowKnownServerNote(server);
|
||||
if (_loading || server == null)
|
||||
return;
|
||||
|
||||
NameBox.Text = server.Name;
|
||||
HostBox.Text = server.Host;
|
||||
PortBox.Text = server.Port.ToString();
|
||||
EmulatorBox.SelectedItem = server.Emulator.ToString();
|
||||
ValidationText.Text = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>The picked server's description and the RynthSuite plugin RynthCore loads for it.</summary>
|
||||
private void ShowKnownServerNote(KnownServer? server)
|
||||
{
|
||||
KnownServerNote.Text = server == null
|
||||
? "Any server works. Known servers fill in the connection details and have a RynthSuite server plugin."
|
||||
: $"{server.Note} Server plugin: {server.PluginName} (RynthCore loads it when you connect to {server.Host}).";
|
||||
}
|
||||
|
||||
private void SaveAndClose()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(NameBox.Text))
|
||||
|
|
|
|||
|
|
@ -4,24 +4,20 @@ namespace RynthCore.App;
|
|||
|
||||
internal sealed class AppSettings
|
||||
{
|
||||
// A new install starts with the standard client folder (2026-10-14); a saved path always wins.
|
||||
public string AcClientPath { get; set; } = DefaultAcClientPath;
|
||||
public const string DefaultAcClientPath = @"C:\Turbine\Asheron's Call\acclient.exe";
|
||||
public string AcClientPath { get; set; } = string.Empty;
|
||||
public string EnginePath { get; set; } = string.Empty;
|
||||
public string LaunchArguments { get; set; } = string.Empty;
|
||||
public string SelectedServerProfileId { get; set; } = string.Empty;
|
||||
public string SelectedAccountProfileId { get; set; } = string.Empty;
|
||||
public List<string> CheckedLaunchAccountProfileIds { get; set; } = [];
|
||||
public string SelectedMainTabId { get; set; } = "launcher";
|
||||
// New-install defaults (2026-10-14): multiple clients, no intro videos or logos, inject after
|
||||
// launch, kill stuck clients; leave clients launched outside RynthCore alone.
|
||||
public bool AllowMultipleClients { get; set; } = true;
|
||||
public bool SkipIntroVideos { get; set; } = true;
|
||||
public bool SkipLoginLogos { get; set; } = true;
|
||||
public bool AllowMultipleClients { get; set; }
|
||||
public bool SkipIntroVideos { get; set; }
|
||||
public bool SkipLoginLogos { get; set; }
|
||||
public bool AutoLaunch { get; set; }
|
||||
public bool AutoInjectAfterLaunch { get; set; } = true;
|
||||
public bool WatchForAcStart { get; set; }
|
||||
public bool InjectAllRunningClients { get; set; }
|
||||
public bool WatchForAcStart { get; set; } = true;
|
||||
public bool InjectAllRunningClients { get; set; } = true;
|
||||
public string LoggingLevel { get; set; } = "Info";
|
||||
public int LaunchStaggerMs { get; set; } = 250;
|
||||
public int CrashRelaunchLimitInWindow { get; set; } = 3;
|
||||
|
|
@ -52,7 +48,7 @@ internal sealed class AppSettings
|
|||
/// patcher hangs, and "you have been disconnected" failure screens at
|
||||
/// the front of the launch flow. Off by default — destructive.
|
||||
/// Decal-mode clients are skipped (no engine = no IsLoggedIn signal).
|
||||
public bool KillStuckClients { get; set; } = true;
|
||||
public bool KillStuckClients { get; set; }
|
||||
public int StuckClientTimeoutSeconds { get; set; } = 60;
|
||||
|
||||
/// When true (default), the launcher kills+relaunches a RynthCore-mode
|
||||
|
|
|
|||
159
src/RynthCore.App/KnownServerCatalog.cs
Normal file
159
src/RynthCore.App/KnownServerCatalog.cs
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace RynthCore.App;
|
||||
|
||||
/// <summary>
|
||||
/// One server RynthSuite ships a server plugin for: where to connect, and which plugin
|
||||
/// (C:\Games\RynthSuite\<PluginName>\) RynthCore loads for it.
|
||||
/// </summary>
|
||||
/// <param name="Id">The plugin's manifest server id (lower-case, "a-z0-9-").</param>
|
||||
/// <param name="Name">The server's name, used as the profile's Server Name.</param>
|
||||
/// <param name="Host">The host the launcher connects to (the client's -h).</param>
|
||||
/// <param name="Port">The login port.</param>
|
||||
/// <param name="Emulator">The server software.</param>
|
||||
/// <param name="Ruleset">"PvE" or "PvP", as the server lists itself.</param>
|
||||
/// <param name="PluginName">The RynthSuite server plugin for this server.</param>
|
||||
/// <param name="Note">One line about the server, shown under the picker.</param>
|
||||
internal sealed record KnownServer(
|
||||
string Id,
|
||||
string Name,
|
||||
string Host,
|
||||
int Port,
|
||||
AcEmulatorKind Emulator,
|
||||
string Ruleset,
|
||||
string PluginName,
|
||||
string Note)
|
||||
{
|
||||
/// <summary>"host:port", as the server list shows it.</summary>
|
||||
public string Address => $"{Host}:{Port}";
|
||||
|
||||
/// <summary>The picker's line for this server.</summary>
|
||||
public override string ToString() => $"{Name} - {Address} ({Ruleset})";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The servers RynthSuite has a server plugin for, so an account can be set up on one by picking
|
||||
/// it. Hosts, ports and emulators come from the public server list
|
||||
/// (github.com/acresources/serverslist, Servers.xml, checked 2026-10-13); Aelrynth is not on
|
||||
/// that list and uses aelrynth.com:9020. Each Host must stay inside the matching plugin's
|
||||
/// RynthPluginServerHosts, or RynthCore's load gate won't pick the plugin for it
|
||||
/// (RynthServerPack.Tests checks this).
|
||||
/// </summary>
|
||||
internal static class KnownServerCatalog
|
||||
{
|
||||
/// <summary>Every known server, in the order the picker lists them (by name).</summary>
|
||||
public static IReadOnlyList<KnownServer> All { get; } = new[]
|
||||
{
|
||||
new KnownServer("achard", "AChard", "a-chard.ddns.net", 9000, AcEmulatorKind.Ace, "PvP", "RynthAChard",
|
||||
"End-of-retail PvP server with custom PK content and kill rankings."),
|
||||
new KnownServer("aelrynth", "Aelrynth", "aelrynth.com", 9020, AcEmulatorKind.Ace, "PvE", "RynthAelrynth",
|
||||
"Aelrynth (aelrynth.com), an ACE server with its own mods."),
|
||||
new KnownServer("coldeve", "Coldeve", "play.coldeve.ac", 9000, AcEmulatorKind.Ace, "PvE", "RynthColdeve",
|
||||
"PvE server evolving toward an end-of-retail experience."),
|
||||
new KnownServer("conquest", "Conquest", "acconquest.ddns.net", 9000, AcEmulatorKind.Ace, "PvE", "RynthConquest",
|
||||
"Custom PvE server with live events, deep crafting and a PK system."),
|
||||
new KnownServer("derptide", "Derptide", "ac.derptide.net", 9000, AcEmulatorKind.Ace, "PvE", "RynthDerptide",
|
||||
"End-of-retail server with custom content, upgraded quest weapons and live events."),
|
||||
new KnownServer("dreamweave", "DreamWeave", "play.acdreamweave.com", 9000, AcEmulatorKind.Ace, "PvE", "RynthDreamWeave",
|
||||
"Lore-driven PvE server: new class abilities, new crafting, an up-to-date wiki."),
|
||||
new KnownServer("eversong", "Eversong", "eversong.abrdns.com", 9000, AcEmulatorKind.Ace, "PvE", "RynthEversong",
|
||||
"Five difficulty worlds, enlightenment, banking and lockboxes, invasions."),
|
||||
new KnownServer("frostace", "FrostACE", "172.111.230.127", 9000, AcEmulatorKind.Ace, "PvE", "RynthFrostACE",
|
||||
"New accounts include level 275 starter characters; retail restoration supported."),
|
||||
new KnownServer("frostcull", "Frostcull", "frostcull.ddns.net", 9000, AcEmulatorKind.Ace, "PvE", "RynthFrostcull",
|
||||
"No level or attribute cap, 10x XP and luminance, 25x drop rate."),
|
||||
new KnownServer("ilt", "Infinite Leaftide", "game.infiniteleaftide.online", 9000, AcEmulatorKind.Ace, "PvE", "RynthILT",
|
||||
"Infinite levels and enlightenment, custom content, constant development."),
|
||||
new KnownServer("leafdawn", "LeafDawn", "leafdawn.hopto.org", 9000, AcEmulatorKind.Ace, "PvE", "RynthLeafDawn",
|
||||
"End-of-retail PvE server with some custom content."),
|
||||
new KnownServer("leafdawning", "Leafdawning", "leafdawning.duckdns.org", 9000, AcEmulatorKind.Ace, "PvE", "RynthLeafdawning",
|
||||
"No-frills end-of-retail PvE server. Enforced 3 account limit."),
|
||||
new KnownServer("levistras", "Levistras", "levistras.acportalstorm.com", 9000, AcEmulatorKind.Ace, "PvE", "RynthLevistras",
|
||||
"Botting-free PvE server (automation is not allowed). 2 account limit."),
|
||||
new KnownServer("portalstorm", "PortalStorm", "ac.portalstorm.us.com", 9020, AcEmulatorKind.Ace, "PvE", "RynthPortalStorm",
|
||||
"15 tiers, 10 enlightenments, infinite luminance augmentations, custom skills."),
|
||||
new KnownServer("reefcull", "Reefcull", "reefcull.gdleac.com", 9000, AcEmulatorKind.Gdle, "PvE", "RynthReefcull",
|
||||
"GDLE PvE server that mimics end-of-game retail."),
|
||||
new KnownServer("sundering", "Sundering", "ace.sunderingac.com", 9000, AcEmulatorKind.Ace, "PvE", "RynthSundering",
|
||||
"End-of-retail feel with convenience changes. 3 active character limit."),
|
||||
new KnownServer("thistlecrown", "Thistlecrown", "thistlecrown.ddns.net", 9000, AcEmulatorKind.Ace, "PvE", "RynthThistlecrown",
|
||||
"Recreation of Thistledown. 3 account limit."),
|
||||
};
|
||||
|
||||
/// <summary>The known server with this id (case-insensitive), or null.</summary>
|
||||
public static KnownServer? FindById(string? id)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(id))
|
||||
return null;
|
||||
string wanted = id.Trim();
|
||||
return All.FirstOrDefault(s => string.Equals(s.Id, wanted, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The known server a saved profile points at, by host: the same host, or one under the known
|
||||
/// host's parent domain ("infiniteleaftide.online" also finds ILT). An IP matches only itself.
|
||||
/// Null when the host is empty or not a known server.
|
||||
/// </summary>
|
||||
public static KnownServer? FindByHost(string? host)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(host))
|
||||
return null;
|
||||
string h = host.Trim().TrimEnd('.');
|
||||
foreach (KnownServer s in All)
|
||||
{
|
||||
if (string.Equals(h, s.Host, StringComparison.OrdinalIgnoreCase))
|
||||
return s;
|
||||
}
|
||||
foreach (KnownServer s in All)
|
||||
{
|
||||
string domain = ParentDomain(s.Host);
|
||||
if (domain.Length == 0)
|
||||
continue;
|
||||
if (string.Equals(h, domain, StringComparison.OrdinalIgnoreCase) ||
|
||||
h.EndsWith("." + domain, StringComparison.OrdinalIgnoreCase))
|
||||
return s;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills a profile's connection fields from a known server: Name, Host, Port and Emulator.
|
||||
/// Id, Alias and RodatEnabled are the user's and are left alone.
|
||||
/// </summary>
|
||||
public static void ApplyTo(KnownServer server, LaunchServerProfile profile)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(server);
|
||||
ArgumentNullException.ThrowIfNull(profile);
|
||||
profile.Name = server.Name;
|
||||
profile.Host = server.Host;
|
||||
profile.Port = server.Port;
|
||||
profile.Emulator = server.Emulator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The domain a host sits under, for matching a typed host to a known one:
|
||||
/// "game.infiniteleaftide.online" gives "infiniteleaftide.online". Hosts on shared dynamic-DNS
|
||||
/// domains (ddns.net, duckdns.org, ...) and IPs give "" so they match only themselves.
|
||||
/// </summary>
|
||||
private static string ParentDomain(string host)
|
||||
{
|
||||
if (System.Net.IPAddress.TryParse(host, out _))
|
||||
return "";
|
||||
string[] labels = host.Split('.');
|
||||
if (labels.Length < 3)
|
||||
return host;
|
||||
string parent = string.Join('.', labels.Skip(1));
|
||||
return SharedDomains.Contains(parent) ? "" : parent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dynamic-DNS domains several servers share; a host under one is not that server's domain.
|
||||
/// </summary>
|
||||
private static readonly HashSet<string> SharedDomains = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
"ddns.net", "duckdns.org", "hopto.org", "abrdns.com", "zapto.org", "redirectme.net",
|
||||
"dynamic-dns.net", "gdleac.com", "acportalstorm.com",
|
||||
};
|
||||
}
|
||||
|
|
@ -374,7 +374,7 @@ internal static class ClientHelperHooks
|
|||
// Skills panel raises (CM_Train senders).
|
||||
try { PlayerTraining.Probe(text); }
|
||||
catch (Exception ex) { RynthLog.Compat($"Compat: raise senders binding failed - {ex.Message}"); }
|
||||
// v85 confirmation answers (CM_Character::Event_ConfirmationResponse).
|
||||
// v81 confirmation answers (CM_Character::Event_ConfirmationResponse).
|
||||
try { ConfirmationResponder.Probe(text); }
|
||||
catch (Exception ex) { RynthLog.Compat($"Compat: confirmation response binding failed - {ex.Message}"); }
|
||||
_initialized = true;
|
||||
|
|
|
|||
|
|
@ -169,7 +169,8 @@ internal static class ClientObjectHooks
|
|||
// 1 TotalExperience, 2 AvailableExperience, 6 AvailableLuminance, 7 MaximumLuminance, then
|
||||
// Aelrynth's Bank session totals (custom ids, absent on other servers): 9101 Radiance earned,
|
||||
// 9102 Luminance auto-banked, 9103 Luminance drawn from the bank. RynthTracker reads them.
|
||||
private static readonly uint[] PlayerQuadStypes = { 1u, 2u, 6u, 7u, 9101u, 9102u, 9103u };
|
||||
// 9005 is ACECustom's banked luminance (the session rates count its rises as income).
|
||||
private static readonly uint[] PlayerQuadStypes = { 1u, 2u, 6u, 7u, 9005u, 9101u, 9102u, 9103u };
|
||||
private static readonly Dictionary<uint, long> _cachedPlayerQuad = new();
|
||||
// Secondary attributes (vitals) by stype 1..6 from InqAttribute2ndBaseLevel: the buffed
|
||||
// maximums RynthAi's getcharvital_buffedmax and RynthLua read.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - Compatibility/ConfirmationResponder.cs
|
||||
//
|
||||
// Plugin API v85: answer the server's yes/no prompts (craft chance, augmentation,
|
||||
// Plugin API v81: answer the server's yes/no prompts (craft chance, augmentation,
|
||||
// ...) for a plugin, the way UtilityBelt's helper clicks "Yes" on the tinkering
|
||||
// dialog, without the client ever opening that dialog.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -29,13 +29,8 @@ namespace RynthCore.Engine.Compatibility;
|
|||
///
|
||||
/// Why IAT-hook instead of MinHook on the kernel32 export:
|
||||
/// Only the modules that open AC's data files are hooked: acclient.exe
|
||||
/// (imports CreateFileA), its CRT MSVCR70.dll (CreateFileA/W, behind
|
||||
/// fopen/_wfopen), and acclient.exe's private CreateFileW slot, which the
|
||||
/// 2025 client fills on first use and opens every DAT through (it is in no
|
||||
/// import table; <see cref="LazyImportSlotScanner"/>). Missing that slot let
|
||||
/// the first client open the DATs read/write, deny-write, and every later
|
||||
/// client failed with "Can't open the data files" (2026-10-15).
|
||||
/// A kernel32 export hook also caught every other module,
|
||||
/// (imports CreateFileA) and its CRT MSVCR70.dll (CreateFileA/W, behind
|
||||
/// fopen/_wfopen). A kernel32 export hook also caught every other module,
|
||||
/// including d3d9.dll and the GPU driver while AC created its device: their
|
||||
/// CreateFile calls went through managed code, could wait on the runtime
|
||||
/// while plugins loaded, and on some PCs AC then failed with "Could not
|
||||
|
|
@ -143,20 +138,11 @@ internal static class DatFileShareHooks
|
|||
return;
|
||||
}
|
||||
|
||||
// acclient.exe opens DATs with its own CreateFileA import, or (the 2025 client)
|
||||
// through a private CreateFileW slot its Layer-for-Unicode stub fills; its CRT
|
||||
// acclient.exe opens DATs with its own CreateFileA import; its CRT
|
||||
// (MSVCR70.dll, statically imported, so loaded by now) does fopen/_wfopen
|
||||
// opens through its CreateFileA/W imports. Nothing else is hooked.
|
||||
HookModuleImports("acclient.exe", moduleBase);
|
||||
HookModuleImports("MSVCR70.dll", GetModuleHandleW("MSVCR70.dll"));
|
||||
try
|
||||
{
|
||||
HookLazySlots(moduleBase);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RynthLog.Compat($"Compat: DAT share - private slot scan failed: {ex.Message}");
|
||||
}
|
||||
|
||||
if (_iatHooks.Count == 0)
|
||||
{
|
||||
|
|
@ -191,69 +177,20 @@ internal static class DatFileShareHooks
|
|||
return;
|
||||
}
|
||||
|
||||
foreach (string function in new[] { "CreateFileW", "CreateFileA" })
|
||||
if (TryPatchIatSlot(moduleBase, "CreateFileW", out IntPtr wSlot, out IntPtr wCurrent))
|
||||
{
|
||||
if (TryPatchIatSlot(moduleBase, function, out IntPtr slot, out IntPtr current))
|
||||
HookSlot(moduleName, function, "import", slot, current, current);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Points acclient.exe's private CreateFileA/W slots (filled on first use by a Layer-for-Unicode
|
||||
/// style stub, see <see cref="LazyImportSlotScanner"/>) at the detours. The 2025 client opens
|
||||
/// its DAT files through the CreateFileW one; it is not in any import table.
|
||||
/// </summary>
|
||||
private static unsafe void HookLazySlots(IntPtr moduleBase)
|
||||
{
|
||||
byte* basePtr = (byte*)moduleBase;
|
||||
int peOffset = *(int*)(basePtr + 0x3C);
|
||||
uint sizeOfImage = *(uint*)(basePtr + peOffset + 24 + 56);
|
||||
var image = new ReadOnlySpan<byte>(basePtr, (int)sizeOfImage);
|
||||
uint imageBase = (uint)moduleBase.ToInt32();
|
||||
var sections = LazyImportSlotScanner.ReadSections(image);
|
||||
|
||||
foreach (string function in new[] { "CreateFileW", "CreateFileA" })
|
||||
{
|
||||
foreach (LazyImportSlot lazy in LazyImportSlotScanner.FindSlots(image, imageBase, sections, "kernel32.dll", function))
|
||||
{
|
||||
var slot = (IntPtr)(int)lazy.SlotVa;
|
||||
IntPtr current = Marshal.ReadIntPtr(slot);
|
||||
// Not resolved yet: the slot still points at its stub inside acclient.exe. Calling
|
||||
// the stub would overwrite the slot with the real function (dropping the detour),
|
||||
// so the detour calls the kernel32 export the stub would have resolved.
|
||||
IntPtr target = current;
|
||||
if ((uint)current.ToInt32() - imageBase < sizeOfImage)
|
||||
target = GetProcAddress(GetModuleHandleW("kernel32.dll"), function);
|
||||
if (target == IntPtr.Zero)
|
||||
{
|
||||
RynthLog.Compat($"Compat: DAT share - kernel32!{function} not found; private slot 0x{lazy.SlotVa:X8} left alone.");
|
||||
continue;
|
||||
}
|
||||
HookSlot("acclient.exe", function, $"private slot (stub 0x{lazy.StubVa:X8})", slot, current, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the detour for <paramref name="function"/> calling <paramref name="callTarget"/>,
|
||||
/// and points <paramref name="slot"/> at it. <paramref name="restoreValue"/> is what
|
||||
/// <see cref="Uninstall"/> writes back.
|
||||
/// </summary>
|
||||
private static void HookSlot(string moduleName, string function, string kind, IntPtr slot, IntPtr restoreValue, IntPtr callTarget)
|
||||
{
|
||||
if (function == "CreateFileW")
|
||||
{
|
||||
CreateFileWDelegate original = Marshal.GetDelegateForFunctionPointer<CreateFileWDelegate>(callTarget);
|
||||
CreateFileWDelegate original = Marshal.GetDelegateForFunctionPointer<CreateFileWDelegate>(wCurrent);
|
||||
CreateFileWDelegate detour = (name, access, share, security, disposition, flags, template) =>
|
||||
CreateFileWDetour(original, name, access, share, security, disposition, flags, template);
|
||||
InstallSlot(moduleName, function, kind, slot, restoreValue, detour, Marshal.GetFunctionPointerForDelegate(detour));
|
||||
InstallSlot(moduleName, "CreateFileW", wSlot, wCurrent, detour, Marshal.GetFunctionPointerForDelegate(detour));
|
||||
}
|
||||
else
|
||||
|
||||
if (TryPatchIatSlot(moduleBase, "CreateFileA", out IntPtr aSlot, out IntPtr aCurrent))
|
||||
{
|
||||
CreateFileADelegate original = Marshal.GetDelegateForFunctionPointer<CreateFileADelegate>(callTarget);
|
||||
CreateFileADelegate original = Marshal.GetDelegateForFunctionPointer<CreateFileADelegate>(aCurrent);
|
||||
CreateFileADelegate detour = (name, access, share, security, disposition, flags, template) =>
|
||||
CreateFileADetour(original, name, access, share, security, disposition, flags, template);
|
||||
InstallSlot(moduleName, function, kind, slot, restoreValue, detour, Marshal.GetFunctionPointerForDelegate(detour));
|
||||
InstallSlot(moduleName, "CreateFileA", aSlot, aCurrent, detour, Marshal.GetFunctionPointerForDelegate(detour));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -261,7 +198,7 @@ internal static class DatFileShareHooks
|
|||
/// Records the hook (so the delegate stays reachable) before the slot is written: the
|
||||
/// detour can run on any thread the moment the pointer lands.
|
||||
/// </summary>
|
||||
private static void InstallSlot(string moduleName, string function, string kind, IntPtr slot, IntPtr original, Delegate detour, IntPtr detourPtr)
|
||||
private static void InstallSlot(string moduleName, string function, IntPtr slot, IntPtr original, Delegate detour, IntPtr detourPtr)
|
||||
{
|
||||
var hook = new IatHook(moduleName, function, slot, original, detour);
|
||||
_iatHooks.Add(hook);
|
||||
|
|
@ -269,7 +206,7 @@ internal static class DatFileShareHooks
|
|||
|
||||
if (WriteIatPointer(slot, detourPtr))
|
||||
{
|
||||
RynthLog.Info($"Compat: DAT share - hooked {moduleName}!{function} {kind} (slot 0x{slot.ToInt32():X8}, was 0x{original.ToInt32():X8}).");
|
||||
RynthLog.Info($"Compat: DAT share - hooked {moduleName}!{function} import (slot 0x{slot.ToInt32():X8}, was 0x{original.ToInt32():X8}).");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,13 +42,55 @@ internal static class EngineStatusMetrics
|
|||
_mReconciles = reconciles; _mForceClears = forceClears;
|
||||
}
|
||||
|
||||
// Per-process session baselines for the per-hour rates. Each client is its own
|
||||
// process, so these naturally reset per launch; we also reset on an XP drop
|
||||
// (relog / char swap).
|
||||
private static long _xpBaseline = -1;
|
||||
private static long _lumBaseline = -1;
|
||||
// The session's XP / luminance totals and rates: RynthSuite's shared formula (SessionRates),
|
||||
// a new session per character. Locked: the status JSON and the Mini Remote's Session Stats
|
||||
// section read it from different threads, and chat lines arrive on a third.
|
||||
private static readonly object _ratesLock = new();
|
||||
private static readonly SessionRates _rates = new();
|
||||
private static int _deathsBaseline = -1;
|
||||
private static DateTime _statsSessionStartUtc = DateTime.UtcNow;
|
||||
private static uint _deathsCharacter;
|
||||
private const uint Int64BankedLuminance = 9005; // ACECustom bank
|
||||
private const uint Int64AelLuminanceBanked = 9102; // Aelrynth bank: luminance auto-banked
|
||||
private const uint Int64AelLuminanceDrawn = 9103; // Aelrynth bank: luminance drawn
|
||||
|
||||
/// <summary>A chat line (PluginManager.QueueChatWindowText): luminance moved into the bank isn't income.</summary>
|
||||
internal static void OnChatLine(string? text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text) || !SessionRates.TryMovedIntoBank(text, out _)) return;
|
||||
lock (_ratesLock) _rates.OnChat(text, DateTime.UtcNow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Samples the player now and returns the session's totals and rates (the Mini Remote's
|
||||
/// Session Stats section). Any thread; reads only the main-thread-cached player stats.
|
||||
/// </summary>
|
||||
internal static SessionRatesView SessionView()
|
||||
{
|
||||
try
|
||||
{
|
||||
ClientObjectHooks.TryGetPlayerStats(out long xp, out long lum, out _, out _, out _, out _, out _, out _, out _, out _);
|
||||
return SampleRates(xp, lum);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new SessionRatesView(DateTime.UtcNow, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Feeds one read to the shared-formula session (bank properties read from the property cache).</summary>
|
||||
private static SessionRatesView SampleRates(long xp, long lum)
|
||||
{
|
||||
uint player = ClientHelperHooks.GetPlayerId();
|
||||
long? Quad(uint stype) => player != 0 && ClientObjectHooks.TryGetObjectQuadProperty(player, stype, out long v) ? v : null;
|
||||
var sample = new SessionRatesSample(xp > 0 ? xp : null, lum > 0 ? lum : null,
|
||||
Quad(Int64BankedLuminance), Quad(Int64AelLuminanceBanked), Quad(Int64AelLuminanceDrawn));
|
||||
DateTime now = DateTime.UtcNow;
|
||||
lock (_ratesLock)
|
||||
{
|
||||
_rates.Sample(player, sample, now);
|
||||
return _rates.View(now);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compose the engine-side status fields as a JSON object string, from the
|
||||
|
|
@ -120,17 +162,15 @@ internal static class EngineStatusMetrics
|
|||
out int encVal, out int encCap, out uint landcell,
|
||||
out float px, out float py, out float pz);
|
||||
double vitaePct = Math.Clamp((1.0 - vitae) * 100.0, 0.0, 100.0);
|
||||
// Lazy baselines; reset on an XP drop (relog / char change).
|
||||
if (xp > 0 && (_xpBaseline < 0 || xp < _xpBaseline))
|
||||
{
|
||||
_xpBaseline = xp; _deathsBaseline = deaths; _statsSessionStartUtc = DateTime.UtcNow;
|
||||
}
|
||||
if (_deathsBaseline < 0 && xp > 0) _deathsBaseline = deaths;
|
||||
if (lum > 0 && (_lumBaseline < 0 || lum < _lumBaseline)) _lumBaseline = lum;
|
||||
double hours = (DateTime.UtcNow - _statsSessionStartUtc).TotalHours;
|
||||
double xpPerHour = (hours > 1.0 / 3600.0 && _xpBaseline >= 0 && xp >= _xpBaseline) ? (xp - _xpBaseline) / hours : 0;
|
||||
double lumPerHour = (hours > 1.0 / 3600.0 && _lumBaseline >= 0 && lum >= _lumBaseline) ? (lum - _lumBaseline) / hours : 0;
|
||||
long xpSession = (_xpBaseline >= 0 && xp >= _xpBaseline) ? xp - _xpBaseline : 0;
|
||||
// XP and luminance: the shared formula (sum of rises, ACECustom / Aelrynth bank aware),
|
||||
// one session per character, the same numbers RynthAi and RynthTracker show.
|
||||
SessionRatesView rates = SampleRates(xp, lum);
|
||||
double xpPerHour = rates.XpPerHour;
|
||||
double lumPerHour = rates.LumPerHour;
|
||||
long xpSession = rates.Xp;
|
||||
// Deaths this session: from the first read for this character.
|
||||
uint who = ClientHelperHooks.GetPlayerId();
|
||||
if (who != 0 && who != _deathsCharacter) { _deathsCharacter = who; _deathsBaseline = deaths; }
|
||||
int deathsSession = (_deathsBaseline >= 0 && deaths >= _deathsBaseline) ? deaths - _deathsBaseline : 0;
|
||||
double burdenPct = encCap > 0 ? Math.Round((double)encVal / encCap * 100.0) : 0;
|
||||
w.WriteNumber("deaths", deaths);
|
||||
|
|
@ -139,6 +179,7 @@ internal static class EngineStatusMetrics
|
|||
w.WriteNumber("xpPerHour", Math.Round(xpPerHour));
|
||||
w.WriteNumber("luminancePerHour", Math.Round(lumPerHour));
|
||||
w.WriteNumber("xpSession", xpSession);
|
||||
w.WriteNumber("luminanceSession", rates.Lum); // additive (2026.10.5.54): the luminance total behind luminancePerHour
|
||||
w.WriteNumber("burdenPct", burdenPct);
|
||||
w.WriteString("area", landcell != 0 ? (landcell >> 16).ToString("X4") : "");
|
||||
// [status-export] live map-dot position. wx/wy are ABSOLUTE world coords (cell-local origin + the
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ internal static class LauncherSettings
|
|||
{
|
||||
private static readonly object Sync = new();
|
||||
private static bool _loaded;
|
||||
// The launcher's own default (AppSettings.AllowMultipleClients, on since 2026-10-14) until it has saved one.
|
||||
private static bool _allowMultipleClients = true;
|
||||
private static bool _allowMultipleClients;
|
||||
private static string _statusMessage = "Launcher settings not loaded.";
|
||||
|
||||
public static bool AllowMultipleClientsEnabled
|
||||
|
|
|
|||
|
|
@ -1,187 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace RynthCore.Engine.Compatibility;
|
||||
|
||||
/// <summary>One section of a PE image as it is mapped in memory (RVA layout, not file layout).</summary>
|
||||
internal readonly record struct ImageSection(string Name, uint Rva, uint Size, bool Executable);
|
||||
|
||||
/// <summary>A private function-pointer slot filled by a lazy-resolve stub, and the stub that fills it.</summary>
|
||||
internal readonly record struct LazyImportSlot(uint SlotVa, uint StubVa);
|
||||
|
||||
/// <summary>
|
||||
/// Finds the private pointer slots that Layer-for-Unicode style stubs fill on first use.
|
||||
///
|
||||
/// The 2025 ACClient.exe (0.0.11.6096) does not import kernel32!CreateFileW. It resolves it the
|
||||
/// first time it is called, with a stub of this exact shape, and every call goes through the slot:
|
||||
/// <code>
|
||||
/// 68 xx xx xx xx push fallback
|
||||
/// FF 35 xx xx xx xx push [module handle cache]
|
||||
/// 68 SS SS SS SS push slot (the pointer the stub fills)
|
||||
/// 68 NN NN NN NN push "CreateFileW"
|
||||
/// 68 DD DD DD DD push "kernel32.dll"
|
||||
/// E8 xx xx xx xx call resolver
|
||||
/// FF 25 SS SS SS SS jmp [slot]
|
||||
/// </code>
|
||||
/// AC opens its DAT files through that slot, so a hook on the import table alone never sees them.
|
||||
/// The pattern is matched in full (both slot operands must agree, and the DLL operand must name
|
||||
/// <c>dll</c>), so a stray push of the name string is never taken for a stub.
|
||||
/// </summary>
|
||||
internal static class LazyImportSlotScanner
|
||||
{
|
||||
private const byte PushImm32 = 0x68;
|
||||
private const byte CallRel32 = 0xE8;
|
||||
private const int IMAGE_SCN_CNT_CODE = 0x00000020;
|
||||
private const int IMAGE_SCN_MEM_EXECUTE = 0x20000000;
|
||||
|
||||
// Offsets inside the stub, from the "push name" instruction.
|
||||
private const int SlotPushBack = 5; // push slot sits right before push name
|
||||
private const int DllPushAhead = 5; // push dll sits right after it
|
||||
private const int CallAhead = 10;
|
||||
private const int JmpAhead = 15; // FF 25 <slot>, after the 5-byte call
|
||||
private const int StubHeadBytes = 11; // push fallback (5) + push [handle cache] (6), before push slot
|
||||
|
||||
/// <summary>
|
||||
/// Reads the section table of a PE32 image mapped at RVA layout (a module's memory, or a test
|
||||
/// buffer laid out the same way). Returns an empty list when the headers don't parse.
|
||||
/// </summary>
|
||||
public static List<ImageSection> ReadSections(ReadOnlySpan<byte> image)
|
||||
{
|
||||
var sections = new List<ImageSection>();
|
||||
if (image.Length < 0x40)
|
||||
return sections;
|
||||
|
||||
int pe = BitConverter.ToInt32(image.Slice(0x3C, 4));
|
||||
if (pe <= 0 || pe + 24 > image.Length || BitConverter.ToUInt32(image.Slice(pe, 4)) != 0x00004550) // "PE\0\0"
|
||||
return sections;
|
||||
|
||||
int count = BitConverter.ToUInt16(image.Slice(pe + 6, 2));
|
||||
int optionalSize = BitConverter.ToUInt16(image.Slice(pe + 20, 2));
|
||||
int table = pe + 24 + optionalSize;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int h = table + 40 * i;
|
||||
if (h + 40 > image.Length)
|
||||
break;
|
||||
string name = Encoding.ASCII.GetString(image.Slice(h, 8)).TrimEnd('\0');
|
||||
uint virtualSize = BitConverter.ToUInt32(image.Slice(h + 8, 4));
|
||||
uint rva = BitConverter.ToUInt32(image.Slice(h + 12, 4));
|
||||
uint rawSize = BitConverter.ToUInt32(image.Slice(h + 16, 4));
|
||||
int flags = BitConverter.ToInt32(image.Slice(h + 36, 4));
|
||||
uint size = virtualSize != 0 ? virtualSize : rawSize;
|
||||
// Clamp to the buffer: a section can't be scanned past the mapped image.
|
||||
if (rva >= image.Length)
|
||||
continue;
|
||||
size = (uint)Math.Min(size, image.Length - rva);
|
||||
bool executable = (flags & (IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_CNT_CODE)) != 0;
|
||||
sections.Add(new ImageSection(name, rva, size, executable));
|
||||
}
|
||||
return sections;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Every slot a stub fills with <paramref name="dll"/>!<paramref name="function"/>, as absolute
|
||||
/// addresses (the stubs push absolute addresses, already relocated to <paramref name="imageBase"/>).
|
||||
/// </summary>
|
||||
public static List<LazyImportSlot> FindSlots(ReadOnlySpan<byte> image, uint imageBase,
|
||||
IReadOnlyList<ImageSection> sections, string dll, string function)
|
||||
{
|
||||
var found = new List<LazyImportSlot>();
|
||||
Span<byte> needle = stackalloc byte[5];
|
||||
foreach (uint nameVa in FindNameStrings(image, imageBase, sections, function))
|
||||
{
|
||||
needle[0] = PushImm32;
|
||||
BitConverter.TryWriteBytes(needle.Slice(1), nameVa);
|
||||
|
||||
foreach (ImageSection code in sections)
|
||||
{
|
||||
if (!code.Executable)
|
||||
continue;
|
||||
ReadOnlySpan<byte> text = image.Slice((int)code.Rva, (int)code.Size);
|
||||
int from = 0;
|
||||
while (true)
|
||||
{
|
||||
int hit = text.Slice(from).IndexOf(needle);
|
||||
if (hit < 0)
|
||||
break;
|
||||
int at = from + hit;
|
||||
from = at + 1;
|
||||
if (TryReadStub(text, at, image, imageBase, dll, out uint slotVa))
|
||||
found.Add(new LazyImportSlot(slotVa, imageBase + code.Rva + (uint)Math.Max(0, at - SlotPushBack - StubHeadBytes)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
// The NUL-terminated name, not as the tail of a longer identifier (e.g. "MyCreateFileW").
|
||||
private static IEnumerable<uint> FindNameStrings(ReadOnlySpan<byte> image, uint imageBase,
|
||||
IReadOnlyList<ImageSection> sections, string function)
|
||||
{
|
||||
byte[] name = Encoding.ASCII.GetBytes(function + "\0");
|
||||
var hits = new List<uint>();
|
||||
foreach (ImageSection s in sections)
|
||||
{
|
||||
if (s.Executable)
|
||||
continue;
|
||||
ReadOnlySpan<byte> data = image.Slice((int)s.Rva, (int)s.Size);
|
||||
int from = 0;
|
||||
while (true)
|
||||
{
|
||||
int hit = data.Slice(from).IndexOf(name);
|
||||
if (hit < 0)
|
||||
break;
|
||||
int at = from + hit;
|
||||
from = at + 1;
|
||||
if (at > 0 && IsIdentifierByte(data[at - 1]))
|
||||
continue;
|
||||
hits.Add(imageBase + s.Rva + (uint)at);
|
||||
}
|
||||
}
|
||||
return hits;
|
||||
}
|
||||
|
||||
private static bool TryReadStub(ReadOnlySpan<byte> text, int namePush, ReadOnlySpan<byte> image,
|
||||
uint imageBase, string dll, out uint slotVa)
|
||||
{
|
||||
slotVa = 0;
|
||||
int slotPush = namePush - SlotPushBack;
|
||||
if (slotPush < 0 || namePush + JmpAhead + 6 > text.Length)
|
||||
return false;
|
||||
if (text[slotPush] != PushImm32
|
||||
|| text[namePush + DllPushAhead] != PushImm32
|
||||
|| text[namePush + CallAhead] != CallRel32
|
||||
|| text[namePush + JmpAhead] != 0xFF || text[namePush + JmpAhead + 1] != 0x25)
|
||||
return false;
|
||||
|
||||
uint slot = BitConverter.ToUInt32(text.Slice(slotPush + 1, 4));
|
||||
uint jmpSlot = BitConverter.ToUInt32(text.Slice(namePush + JmpAhead + 2, 4));
|
||||
if (slot != jmpSlot || !InImage(slot, 4, imageBase, image.Length))
|
||||
return false;
|
||||
|
||||
uint dllVa = BitConverter.ToUInt32(text.Slice(namePush + DllPushAhead + 1, 4));
|
||||
if (!string.Equals(ReadAsciiz(image, imageBase, dllVa), dll, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
slotVa = slot;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool InImage(uint va, int size, uint imageBase, int imageLength) =>
|
||||
va >= imageBase && (long)va - imageBase + size <= imageLength;
|
||||
|
||||
private static string? ReadAsciiz(ReadOnlySpan<byte> image, uint imageBase, uint va)
|
||||
{
|
||||
if (!InImage(va, 1, imageBase, image.Length))
|
||||
return null;
|
||||
ReadOnlySpan<byte> rest = image.Slice((int)(va - imageBase));
|
||||
int end = rest.IndexOf((byte)0);
|
||||
if (end < 0 || end > 260)
|
||||
return null;
|
||||
return Encoding.ASCII.GetString(rest.Slice(0, end));
|
||||
}
|
||||
|
||||
private static bool IsIdentifierByte(byte b) =>
|
||||
b is >= (byte)'A' and <= (byte)'Z' or >= (byte)'a' and <= (byte)'z' or >= (byte)'0' and <= (byte)'9' or (byte)'_';
|
||||
}
|
||||
|
|
@ -1,152 +0,0 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - Compatibility/MemoryUse.cs
|
||||
//
|
||||
// Where the memory goes while the engine and its plugins start (a client start or a
|
||||
// hot reload). 2026-10-15: a reload frees the old engine (~550 MB of address space
|
||||
// back) and the new one takes ~400 MB again within two seconds of the plugins starting,
|
||||
// all of it freshly touched, so the working set jumps from ~480 MB to ~1.1 GB. The log
|
||||
// had no per-plugin numbers, so nobody could say what takes it.
|
||||
//
|
||||
// Mark(label) logs one "[Mem]" line with private bytes (committed), the .NET heap
|
||||
// (all managed plugins share the one runtime), the working set and free address
|
||||
// space, each with its change since the last mark. StartBurst samples every 100 ms for
|
||||
// a while and logs every rise of BurstStepMb or more in private bytes with the last
|
||||
// mark's label, so work a plugin does after its Init returns (a background load, its
|
||||
// first ticks) is still caught. Never throws; any thread.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace RynthCore.Engine.Compatibility;
|
||||
|
||||
internal static class MemoryUse
|
||||
{
|
||||
/// <summary>A burst logs each rise in private bytes of at least this much.</summary>
|
||||
private const long BurstStepMb = 16;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct PROCESS_MEMORY_COUNTERS_EX
|
||||
{
|
||||
public uint cb;
|
||||
public uint PageFaultCount;
|
||||
public nuint PeakWorkingSetSize;
|
||||
public nuint WorkingSetSize;
|
||||
public nuint QuotaPeakPagedPoolUsage;
|
||||
public nuint QuotaPagedPoolUsage;
|
||||
public nuint QuotaPeakNonPagedPoolUsage;
|
||||
public nuint QuotaNonPagedPoolUsage;
|
||||
public nuint PagefileUsage;
|
||||
public nuint PeakPagefileUsage;
|
||||
public nuint PrivateUsage;
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern IntPtr GetCurrentProcess();
|
||||
|
||||
[DllImport("psapi.dll", SetLastError = true)]
|
||||
private static extern bool GetProcessMemoryInfo(IntPtr process, out PROCESS_MEMORY_COUNTERS_EX counters, uint size);
|
||||
|
||||
/// <summary>One reading, in MB (-1 when a value couldn't be read).</summary>
|
||||
internal readonly record struct Reading(long PrivateMb, long WorkingSetMb, long GcHeapMb, long GcCommittedMb, long VaFreeMb);
|
||||
|
||||
private static readonly object Gate = new();
|
||||
private static Reading _lastMark;
|
||||
private static bool _haveMark;
|
||||
private static volatile string _label = "start";
|
||||
private static int _burstRunning;
|
||||
|
||||
public static Reading Read()
|
||||
{
|
||||
long priv = -1, ws = -1, gcHeap = -1, gcCommit = -1;
|
||||
try
|
||||
{
|
||||
var c = new PROCESS_MEMORY_COUNTERS_EX { cb = (uint)Marshal.SizeOf<PROCESS_MEMORY_COUNTERS_EX>() };
|
||||
if (GetProcessMemoryInfo(GetCurrentProcess(), out c, c.cb))
|
||||
{
|
||||
priv = (long)((ulong)c.PrivateUsage >> 20);
|
||||
ws = (long)((ulong)c.WorkingSetSize >> 20);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
GCMemoryInfo gc = GC.GetGCMemoryInfo();
|
||||
gcHeap = gc.HeapSizeBytes >> 20;
|
||||
gcCommit = gc.TotalCommittedBytes >> 20;
|
||||
}
|
||||
catch { }
|
||||
long va = AddressSpace.FreeAndLargestMb().FreeMb;
|
||||
return new Reading(priv, ws, gcHeap, gcCommit, va);
|
||||
}
|
||||
|
||||
/// <summary>Logs a reading with its change since the last mark, and names what runs next.</summary>
|
||||
public static void Mark(string label)
|
||||
{
|
||||
try
|
||||
{
|
||||
Reading now = Read();
|
||||
Reading prev;
|
||||
bool had;
|
||||
lock (Gate)
|
||||
{
|
||||
prev = _lastMark;
|
||||
had = _haveMark;
|
||||
_lastMark = now;
|
||||
_haveMark = true;
|
||||
_label = label;
|
||||
}
|
||||
RynthLog.Info($"[Mem] {label}: {Format(now, had ? prev : (Reading?)null)}");
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Samples every 100 ms for <paramref name="seconds"/> and logs each rise in private
|
||||
/// bytes of BurstStepMb or more, with the label of the last <see cref="Mark"/>. One
|
||||
/// burst at a time.
|
||||
/// </summary>
|
||||
public static void StartBurst(int seconds, string why)
|
||||
{
|
||||
if (Interlocked.Exchange(ref _burstRunning, 1) == 1) return;
|
||||
try
|
||||
{
|
||||
var t = new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Reading start = Read();
|
||||
Reading last = start;
|
||||
RynthLog.Info($"[Mem] burst for {seconds} s ({why}): {Format(start, null)}");
|
||||
long end = Environment.TickCount64 + seconds * 1000L;
|
||||
while (Environment.TickCount64 < end)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
Reading r = Read();
|
||||
if (r.PrivateMb >= 0 && last.PrivateMb >= 0 && r.PrivateMb - last.PrivateMb >= BurstStepMb)
|
||||
{
|
||||
RynthLog.Info($"[Mem] +{r.PrivateMb - last.PrivateMb} MB private during '{_label}': {Format(r, last)}");
|
||||
last = r;
|
||||
}
|
||||
}
|
||||
Reading done = Read();
|
||||
RynthLog.Info($"[Mem] burst done ({why}): {Format(done, start)} (change over the whole burst)");
|
||||
}
|
||||
catch { }
|
||||
finally { Interlocked.Exchange(ref _burstRunning, 0); }
|
||||
})
|
||||
{ IsBackground = true, Name = "RynthCore.MemoryUse" };
|
||||
t.Start();
|
||||
}
|
||||
catch { Interlocked.Exchange(ref _burstRunning, 0); }
|
||||
}
|
||||
|
||||
private static string Format(Reading r, Reading? prev)
|
||||
{
|
||||
static string D(long now, long? before) => before is long b && b >= 0 && now >= 0 ? $" ({now - b:+0;-0})" : "";
|
||||
return $"private {r.PrivateMb} MB{D(r.PrivateMb, prev?.PrivateMb)}, .NET heap {r.GcHeapMb} MB{D(r.GcHeapMb, prev?.GcHeapMb)}" +
|
||||
$" (committed {r.GcCommittedMb}{D(r.GcCommittedMb, prev?.GcCommittedMb)}), working set {r.WorkingSetMb} MB{D(r.WorkingSetMb, prev?.WorkingSetMb)}," +
|
||||
$" free address space {r.VaFreeMb} MB{D(r.VaFreeMb, prev?.VaFreeMb)}";
|
||||
}
|
||||
}
|
||||
|
|
@ -30,9 +30,6 @@ namespace RynthCore.Engine.Compatibility;
|
|||
/// <item><c>/rc ui barsize [0-10|+|-|status]</c> - the RynthCore bar's size (its own text
|
||||
/// size step, <see cref="UI.PanelTextScale"/>; saved for the PC, also in Settings >
|
||||
/// Display). Alone it reports the size.</item>
|
||||
/// <item><c>/rc ui barrows [1-6|+|-|status]</c> and <c>/rc ui baricons [2-30|none|+|-|status]</c>
|
||||
/// - the bar's rows and the most icons a row holds (none = no limit; <see cref="UI.BarLayout"/>,
|
||||
/// saved for the PC, also in the grip's menu and Settings > Display). Alone each reports both.</item>
|
||||
/// <item><c>/rc vendor [list|info|status|buy <id|sel> [n]|sell <id|sel> [id ...]]</c>
|
||||
/// — read / trade with the open vendor through the engine's vendor
|
||||
/// primitives (<see cref="VendorTrade"/>); a manual test hook for the
|
||||
|
|
@ -150,7 +147,7 @@ internal static class RynthCoreChatCommands
|
|||
return true;
|
||||
}
|
||||
|
||||
// /rc ui list | open|close|popout|redock|snap <Panel> | bar settings (HandleUiCommand)
|
||||
// /rc ui list | /rc ui <Panel> avalonia|imgui|both
|
||||
if (sub.Equals("ui", StringComparison.OrdinalIgnoreCase)
|
||||
|| sub.StartsWith("ui ", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
|
|
@ -353,9 +350,9 @@ internal static class RynthCoreChatCommands
|
|||
// /rc miniremote [show|hide|toggle|tab <tab>|section <id>] : the ImGui Mini Remote panel, like
|
||||
// its bar button (RynthAi's dashboard and "/ra hub" use show / hide). "tab" opens it on one of
|
||||
// its tabs (RynthAi's pets, crafting; RynthILT's gear, games; none = the remote). Quests are
|
||||
// RynthOracle's window (/ro) since 2026-10-13. Since 2026.10.5.54 the old "character" tab
|
||||
// (the generic overview) opens RynthOracle's Character tab (/ro character). Infinite
|
||||
// Leaftide's own tabs ("charms", "banking", "gear", "games") stay RynthILT's, in this window.
|
||||
// RynthOracle's window (/ro) since 2026-10-13. Since 2026.10.5.54 the old "character" and
|
||||
// "charms" tabs open RynthOracle's Character tab (/ro character) and "banking" opens
|
||||
// RynthInventory's Global Inventory on its Banking tab (/ginv bank).
|
||||
// "section" opens it on one of its sections (char = Session Stats, map, skills, ...; "remote" = the remote).
|
||||
if (IsVerb(sub, "miniremote", out string remoteArgs) || IsVerb(sub, "remote", out remoteArgs))
|
||||
{
|
||||
|
|
@ -563,10 +560,9 @@ internal static class RynthCoreChatCommands
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// /rc ui list (each panel's face and placement, UI.PanelRouter), open/close/popout/
|
||||
/// redock/snap a panel, and the bar's settings. /rc ui <Panel|bar> avalonia|imgui|both
|
||||
/// no longer picks a face (2026-10-14: docked panels and the bar are always ImGui); it
|
||||
/// says so. Replies are queued to chat, not written from inside this outgoing-chat hook.
|
||||
/// /rc ui list, or /rc ui <Panel> avalonia|imgui|both: which face shows a
|
||||
/// panel while it is docked in the client (UI.PanelRouter). Replies are
|
||||
/// queued to chat, not written from inside this outgoing-chat hook.
|
||||
/// </summary>
|
||||
private static void HandleUiCommand(string args)
|
||||
{
|
||||
|
|
@ -616,52 +612,6 @@ internal static class RynthCoreChatCommands
|
|||
return;
|
||||
}
|
||||
|
||||
// /rc ui barrows [1-6|+|-|status]: the bar's rows. Alone it reports the rows and the limit.
|
||||
if (parts[0].Equals("barrows", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
int cur = ImGuiBackend.ImGuiBar.Rows;
|
||||
if (parts.Length >= 2 && !parts[1].Equals("status", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
int next;
|
||||
// Bare + / -: one row. +n / -n: that many. Plain n: that many rows.
|
||||
if (parts[1] == "+") next = cur + 1;
|
||||
else if (parts[1] == "-") next = cur - 1;
|
||||
else if (!int.TryParse(parts[1], System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out next))
|
||||
{
|
||||
Reply("Usage: /rc ui barrows [1-6|+|-|status]");
|
||||
return;
|
||||
}
|
||||
else if (parts[1][0] is '+' or '-')
|
||||
next += cur;
|
||||
ImGuiBackend.ImGuiBar.SetRowLayout(next, ImGuiBackend.ImGuiBar.MaxPerRow);
|
||||
}
|
||||
Reply(ImGuiBackend.ImGuiBar.DescribeRowLayout());
|
||||
return;
|
||||
}
|
||||
|
||||
// /rc ui baricons [2-30|none|+|-|status]: the most icons a bar row holds (none or 0 = no
|
||||
// limit). + / - step like the grip's menu (past 30 is no limit). Alone it reports both.
|
||||
if (parts[0].Equals("baricons", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
int cur = ImGuiBackend.ImGuiBar.MaxPerRow;
|
||||
if (parts.Length >= 2 && !parts[1].Equals("status", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
int next;
|
||||
if (parts[1] == "+" || parts[1] == "-")
|
||||
next = UI.BarLayout.StepMaxPerRow(cur, parts[1] == "+" ? 1 : -1, ImGuiBackend.ImGuiBar.ShownPerRow);
|
||||
else if (parts[1].Equals("none", StringComparison.OrdinalIgnoreCase) || parts[1].Equals("off", StringComparison.OrdinalIgnoreCase))
|
||||
next = UI.BarLayout.NoLimit;
|
||||
else if (!int.TryParse(parts[1], System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out next))
|
||||
{
|
||||
Reply("Usage: /rc ui baricons [2-30|none|+|-|status]");
|
||||
return;
|
||||
}
|
||||
ImGuiBackend.ImGuiBar.SetRowLayout(ImGuiBackend.ImGuiBar.Rows, next);
|
||||
}
|
||||
Reply(ImGuiBackend.ImGuiBar.DescribeRowLayout());
|
||||
return;
|
||||
}
|
||||
|
||||
// /rc ui open|close|popout|redock|snap <Panel>: drive a panel by name (tests,
|
||||
// dispatch.txt). Names may have spaces ("Monster Detail").
|
||||
string verb = parts[0].ToLowerInvariant();
|
||||
|
|
@ -692,14 +642,13 @@ internal static class RynthCoreChatCommands
|
|||
return;
|
||||
}
|
||||
|
||||
// The old face choice: nothing to pick any more (nothing is stored either).
|
||||
if (parts.Length == 2 && UI.PanelFaceStore.TryParseFace(parts[1], out _))
|
||||
if (parts.Length != 2 || !UI.PanelFaceStore.TryParseFace(parts[1], out UI.PanelFace face))
|
||||
{
|
||||
Reply("The Avalonia / Both faces are gone: docked panels and the bar always show their ImGui face.");
|
||||
Reply("Usage: /rc ui list | /rc ui <Panel|bar> avalonia|imgui|both | /rc ui open|close|popout|redock|snap <Panel> | /rc ui retailvitals [on|off] | /rc ui barsize [0-10|+|-|status]");
|
||||
return;
|
||||
}
|
||||
|
||||
Reply("Usage: /rc ui list | /rc ui open|close|popout|redock|snap <Panel> | /rc ui retailvitals [on|off] | /rc ui barsize [0-10|+|-|status] | /rc ui barrows [1-6|+|-] | /rc ui baricons [2-30|none|+|-]");
|
||||
Reply(UI.PanelRouter.SetDockedFace(parts[0], face));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1018,13 +967,14 @@ internal static class RynthCoreChatCommands
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// The command for a Mini Remote tab that moved out (2026.10.5.54): "character" (the generic
|
||||
/// overview) is RynthOracle's Character tab. Null for a tab still in the Mini Remote, which
|
||||
/// includes RynthILT's Leaftide tabs (Charms, Banking, Gear, Games): those stay RynthILT's.
|
||||
/// The command for a Mini Remote tab that moved out (2026.10.5.54): "character" and "charms"
|
||||
/// are RynthOracle's Character tab, "banking" is RynthInventory's Global Inventory Banking tab.
|
||||
/// Null for a tab still in the Mini Remote.
|
||||
/// </summary>
|
||||
internal static string? MovedTabCommand(string tab) => tab.Trim().ToLowerInvariant() switch
|
||||
{
|
||||
"character" or "char" => "/ro character",
|
||||
"character" or "char" or "charms" => "/ro character",
|
||||
"banking" or "bank" => "/ginv bank",
|
||||
_ => null,
|
||||
};
|
||||
|
||||
|
|
|
|||
160
src/RynthCore.Engine/Compatibility/SessionRates.cs
Normal file
160
src/RynthCore.Engine/Compatibility/SessionRates.cs
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - Compatibility/SessionRates.cs
|
||||
// The engine's XP / luminance session totals and per-hour rates: the status feed
|
||||
// (EngineStatusMetrics, GetEngineStatusJson) and the Mini Remote's Session Stats
|
||||
// section. Same formula as RynthSuite's Plugins/Shared/SessionStats.cs, which
|
||||
// RynthAi, RynthTracker, RynthOracle and RynthILT show (2026-10-13), so every
|
||||
// XP/hour and lum/hour on screen agrees:
|
||||
// - a total is the sum of every rise of the property since the session began;
|
||||
// a drop (spending luminance, a server resetting a session total) only moves
|
||||
// the baseline, never takes earnings back;
|
||||
// - ACECustom's bank (Int64 9005) counts its rises as income, and once it has
|
||||
// been read the character's AvailableLuminance rises are withdrawals, not income;
|
||||
// a deposit or incoming transfer seen in chat ("Deposited N luminance") is moved
|
||||
// money, so that much of the next bank rise isn't counted;
|
||||
// - Aelrynth's bank: luminance auto-banked (9102) was earned before it left the
|
||||
// character, luminance drawn (9103) landed on the character without being earned;
|
||||
// - rate = total / session hours, the session at least one second long.
|
||||
// A different character (or the first read) starts a new session.
|
||||
//
|
||||
// Pure: no AC, no engine state (tools/SectionsTests compiles it). Not thread-safe:
|
||||
// one caller at a time (EngineStatusMetrics locks around it).
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
|
||||
namespace RynthCore.Engine.Compatibility;
|
||||
|
||||
/// <summary>One read of the player's properties (null = not readable on this server or yet).</summary>
|
||||
internal readonly record struct SessionRatesSample(
|
||||
long? TotalXp, long? AvailableLum, long? BankLum, long? AelBanked, long? AelDrawn);
|
||||
|
||||
/// <summary>The totals and rates as of the last sample.</summary>
|
||||
internal readonly record struct SessionRatesView(
|
||||
DateTime StartUtc, double Seconds, long Xp, double XpPerHour, long Lum, double LumPerHour);
|
||||
|
||||
internal sealed class SessionRates
|
||||
{
|
||||
private uint _character;
|
||||
private DateTime _startUtc;
|
||||
private long _xp, _lum;
|
||||
private Rise _xpRise, _lumRise, _bankRise, _aelBankedRise, _aelDrawnRise;
|
||||
private bool _bankTracked;
|
||||
// Luminance deposited (or transferred in) waiting for its bank rise, which isn't income.
|
||||
private long _movedIntoBank;
|
||||
private DateTime _movedIntoBankUntil;
|
||||
private static readonly TimeSpan MovedIntoBankLife = TimeSpan.FromSeconds(60);
|
||||
|
||||
/// <summary>The character the session belongs to (0 = none yet).</summary>
|
||||
public uint Character => _character;
|
||||
|
||||
/// <summary>Starts a fresh session for <paramref name="character"/> at <paramref name="nowUtc"/>.</summary>
|
||||
public void Reset(uint character, DateTime nowUtc)
|
||||
{
|
||||
_character = character;
|
||||
_startUtc = nowUtc;
|
||||
_xp = _lum = 0;
|
||||
_xpRise = default; _lumRise = default; _bankRise = default; _aelBankedRise = default; _aelDrawnRise = default;
|
||||
_bankTracked = false;
|
||||
_movedIntoBank = 0;
|
||||
_movedIntoBankUntil = DateTime.MinValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A chat line: "Deposited N luminance" (character to bank) or "Received N luminance from X"
|
||||
/// (a transfer) means the next N of bank rise is moved money, not income.
|
||||
/// </summary>
|
||||
public void OnChat(string? text, DateTime nowUtc)
|
||||
{
|
||||
if (!TryMovedIntoBank(text, out long moved)) return;
|
||||
_movedIntoBank += moved;
|
||||
_movedIntoBankUntil = nowUtc + MovedIntoBankLife;
|
||||
}
|
||||
|
||||
/// <summary>The deposit / incoming-transfer lines (the shared SessionLumChat.TryMovedIntoBank).</summary>
|
||||
internal static bool TryMovedIntoBank(string? text, out long amount)
|
||||
=> TryAmount(text, "Deposited ", " luminance", out amount)
|
||||
|| TryAmount(text, "Received ", " luminance from ", out amount);
|
||||
|
||||
// The line starts with the prefix (a player quoting it in a tell doesn't), then "1,234,567", then the suffix.
|
||||
private static bool TryAmount(string? text, string prefix, string suffix, out long amount)
|
||||
{
|
||||
amount = 0;
|
||||
if (string.IsNullOrEmpty(text)) return false;
|
||||
int i = 0;
|
||||
while (i < text.Length && char.IsWhiteSpace(text[i])) i++;
|
||||
if (string.Compare(text, i, prefix, 0, prefix.Length, StringComparison.OrdinalIgnoreCase) != 0) return false;
|
||||
i += prefix.Length;
|
||||
int digits = 0;
|
||||
long value = 0;
|
||||
for (; i < text.Length; i++)
|
||||
{
|
||||
char c = text[i];
|
||||
if (c == ',') continue;
|
||||
if (c < '0' || c > '9') break;
|
||||
if (value > (long.MaxValue - 9) / 10) return false;
|
||||
value = value * 10 + (c - '0');
|
||||
digits++;
|
||||
}
|
||||
if (digits == 0) return false;
|
||||
if (string.Compare(text, i, suffix, 0, suffix.Length, StringComparison.OrdinalIgnoreCase) != 0) return false;
|
||||
amount = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Takes one read; a new character starts a new session first.</summary>
|
||||
public void Sample(uint character, in SessionRatesSample s, DateTime nowUtc)
|
||||
{
|
||||
if (character == 0) return;
|
||||
if (character != _character) Reset(character, nowUtc);
|
||||
|
||||
if (s.TotalXp is long xp && xp > 0) _xp += _xpRise.Take(xp);
|
||||
|
||||
if (nowUtc > _movedIntoBankUntil) _movedIntoBank = 0;
|
||||
|
||||
long lumUp = 0;
|
||||
// ACECustom's bank first, so the character rise below already knows it is tracked.
|
||||
if (s.BankLum is long bank && bank >= 0)
|
||||
{
|
||||
_bankTracked = true;
|
||||
long up = _bankRise.Take(bank);
|
||||
long moved = Math.Min(up, _movedIntoBank);
|
||||
_movedIntoBank -= moved;
|
||||
lumUp += up - moved;
|
||||
}
|
||||
long charUp = 0;
|
||||
if (s.AvailableLum is long lum && lum >= 0)
|
||||
{
|
||||
long up = _lumRise.Take(lum);
|
||||
if (!_bankTracked) charUp += up;
|
||||
}
|
||||
if (s.AelDrawn is long drawn) charUp -= _aelDrawnRise.Take(drawn);
|
||||
if (s.AelBanked is long banked) charUp += _aelBankedRise.Take(banked);
|
||||
if (charUp > 0) lumUp += charUp;
|
||||
_lum += lumUp;
|
||||
}
|
||||
|
||||
/// <summary>The totals and per-hour rates at <paramref name="nowUtc"/> (zeros before the first sample).</summary>
|
||||
public SessionRatesView View(DateTime nowUtc)
|
||||
{
|
||||
if (_character == 0) return new SessionRatesView(nowUtc, 0, 0, 0, 0, 0);
|
||||
double seconds = Math.Max(1.0, (nowUtc - _startUtc).TotalSeconds);
|
||||
double hours = seconds / 3600.0;
|
||||
return new SessionRatesView(_startUtc, seconds, _xp, _xp / hours, _lum, _lum / hours);
|
||||
}
|
||||
|
||||
/// <summary>How much a value went up since the last read; the first read is the baseline.</summary>
|
||||
private struct Rise
|
||||
{
|
||||
private long _last;
|
||||
private bool _seen;
|
||||
|
||||
public long Take(long value)
|
||||
{
|
||||
long up = _seen && value > _last ? value - _last : 0;
|
||||
_last = value;
|
||||
_seen = true;
|
||||
return up;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ internal static class SmartBoxHooks
|
|||
ParseGameEvent(eventType, data, (uint)len);
|
||||
if ((eventType >= 0x02C2 && eventType <= 0x02C8) || eventType == 0x0312)
|
||||
enchantment = CaptureEnchantmentEvent(eventType, data, (uint)len);
|
||||
// v85: a prompt a plugin armed an answer for is answered here instead of
|
||||
// v81: a prompt a plugin armed an answer for is answered here instead of
|
||||
// opening AC's dialog.
|
||||
if (eventType == ConfirmationResponder.EventConfirmationRequest)
|
||||
answered = ConfirmationResponder.OnRequest(data, (uint)len);
|
||||
|
|
|
|||
|
|
@ -80,9 +80,7 @@ internal static class D3D9Bootstrapper
|
|||
if (earlyModule != IntPtr.Zero)
|
||||
{
|
||||
RynthLog.D3D9("D3D9Bootstrapper: d3d9.dll loaded — discovering EndScene via NULLREF device.");
|
||||
Compatibility.MemoryUse.Mark("D3D9 bootstrap: NULLREF device for the vtable");
|
||||
EndSceneHook.Install("post-login-vtable");
|
||||
Compatibility.MemoryUse.Mark("EndScene hook installed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -599,11 +599,10 @@ public static class EntryPoint
|
|||
{
|
||||
// RynthILT's ILT tabs in RynthAi's Mini Remote (shown once the server reports each on).
|
||||
// A RynthAi that doesn't publish sections gets these stand-ins; one that does lists them itself.
|
||||
// Character (the generic overview) is RynthOracle's Character tab since 2026.10.5.54;
|
||||
// the Leaftide tabs (Charms, Banking, Gear, Games) stay RynthILT's.
|
||||
// Character and Charms are RynthOracle's Character tab and Banking is RynthInventory's
|
||||
// Global Inventory since 2026.10.5.54, so only Gear and Games are left here.
|
||||
foreach ((string label, string tab, string section) in new[]
|
||||
{
|
||||
("Charms", "charms", "inventory"), ("Banking", "banking", "inventory"),
|
||||
("Gear", "gear", "inventory"), ("Games", "games", "fellowship"),
|
||||
})
|
||||
{
|
||||
|
|
@ -1103,8 +1102,6 @@ public static class EntryPoint
|
|||
ImGuiBackend.Panels.VisionFace.Register();
|
||||
if (HasPluginDll("RynthCore.Plugin.RynthNav.dll"))
|
||||
ImGuiBackend.Panels.RynthNavFace.Register();
|
||||
if (HasPluginDll("RynthCore.Plugin.RynthNav.dll"))
|
||||
ImGuiBackend.Panels.WorldMapFace.Register();
|
||||
// Characters (your other RynthCore clients, through RynthNet): only with RynthNet installed.
|
||||
if (HasPluginDll("RynthCore.Plugin.RynthNet.dll"))
|
||||
ImGuiBackend.Panels.CharactersFace.Register();
|
||||
|
|
@ -1141,8 +1138,6 @@ public static class EntryPoint
|
|||
// RynthAiPanel: see the dispatcher invariant above ChatModel.EnsureSettingsLoaded.
|
||||
RynthAiDashboardState.EnsureLoaded();
|
||||
}
|
||||
// The colour theme (theme.txt), here rather than on AC's thread; every ImGui face reads it.
|
||||
ImGuiBackend.RynthTheme.EnsureLoaded();
|
||||
RegisterServerMenus(HasPluginDll("RynthCore.Plugin.RynthAi.dll"), HasPluginDll("RynthCore.Plugin.RynthILT.dll"));
|
||||
if (trackerPresent)
|
||||
TrackerSettings.EnsureLoaded();
|
||||
|
|
@ -1153,7 +1148,6 @@ public static class EntryPoint
|
|||
if (avalonia && !dcompTest)
|
||||
AvaloniaOverlay.Start();
|
||||
RynthLog.Info("RynthCore bootstrap initialized.");
|
||||
Compatibility.MemoryUse.Mark("bootstrap initialized");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -270,27 +270,27 @@ internal sealed unsafe class CodeEditor : IDisposable
|
|||
return new[]
|
||||
{
|
||||
C(0xFFD9E6F2), // Default
|
||||
RynthTheme.Accent, // Keyword
|
||||
C(0xFF26D9E6), // Keyword
|
||||
C(0xFF99E699), // Number
|
||||
C(0xFFE6C07B), // String
|
||||
C(0xFFE6C07B), // CharLiteral
|
||||
C(0xFFCC88CC), // Punctuation
|
||||
C(0xFF8CA6BF), // Preprocessor
|
||||
C(0xFFD9E6F2), // Identifier
|
||||
RynthTheme.Highlight, // KnownIdentifier
|
||||
C(0xFFE8B333), // KnownIdentifier
|
||||
C(0xFF7BB8FF), // PreprocIdentifier
|
||||
C(0xFF6A7A8A), // Comment
|
||||
C(0xFF6A7A8A), // MultiLineComment
|
||||
RynthTheme.Field, // Background
|
||||
C(0xFF141F29), // Background
|
||||
C(0xFFE6F2FF), // Cursor
|
||||
C(0x80305A80), // Selection
|
||||
C(0x80B02020), // ErrorMarker
|
||||
RynthTheme.BarButtonBorder, // ControlCharacter
|
||||
C(0xFF3A4A5A), // ControlCharacter
|
||||
C(0x40F08000), // Breakpoint
|
||||
C(0xFF4F6478), // LineNumber
|
||||
C(0x40263A50), // CurrentLineFill
|
||||
C(0x20263A50), // CurrentLineFillInactive
|
||||
RynthTheme.WithAlpha(RynthTheme.DashBorder, 0x40), // CurrentLineEdge
|
||||
C(0x40264059), // CurrentLineEdge
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ internal static unsafe class DX9Backend
|
|||
private const uint D3DPT_TRIANGLELIST = 4;
|
||||
private const uint D3DFMT_INDEX16 = 101;
|
||||
private const uint D3DFMT_A8R8G8B8 = 21;
|
||||
private const uint D3DFMT_DXT1 = 0x31545844; // the FourCC 'DXT1'
|
||||
private const uint D3DPOOL_MANAGED = 1;
|
||||
private const uint D3DUSAGE_DYNAMIC = 0x200;
|
||||
private const uint D3DPOOL_DEFAULT = 0;
|
||||
|
|
@ -951,16 +950,6 @@ internal static unsafe class DX9Backend
|
|||
|
||||
// Store texture ID for ImGui
|
||||
io.Fonts.SetTexID(_fontTexture);
|
||||
|
||||
// The glyphs are baked and uploaded: the atlas's input data is no longer read. ImGui
|
||||
// copies the whole TTF into the atlas for every font it adds (main font, Segoe UI
|
||||
// Symbol and Phosphor per size, ~3.8 MB each), so with the panel text sizes in use
|
||||
// that was ~400 MB kept for the life of the atlas (2026-10-15, [Mem] lines). Every
|
||||
// re-bake builds a fresh atlas from ImGuiFonts' own copies, and the pixels and TexReady
|
||||
// stay, so nothing needs it back.
|
||||
Compatibility.MemoryUse.Mark("font atlas uploaded");
|
||||
io.Fonts.ClearInputData();
|
||||
Compatibility.MemoryUse.Mark("font input data freed");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1004,38 +993,6 @@ internal static unsafe class DX9Backend
|
|||
return tex;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A managed-pool DXT1 texture (4x4 blocks of 8 bytes: two RGB565 colours and sixteen 2-bit indices, a sixth
|
||||
/// of A8R8G8B8's size) holding <paramref name="blocks"/> as they are: <paramref name="width"/> x
|
||||
/// <paramref name="height"/> a multiple of 4, (w/4) * (h/4) * 8 bytes, top row of blocks first (the World
|
||||
/// Map's tiles). Zero on failure or when the device can't make DXT1. AC's render thread.
|
||||
/// </summary>
|
||||
public static IntPtr CreateTextureDxt1(IntPtr pDevice, int width, int height, ReadOnlySpan<byte> blocks)
|
||||
{
|
||||
int rowBytes = width / 4 * 8, rows = height / 4;
|
||||
if (_createTexture == null || pDevice == IntPtr.Zero || width <= 0 || height <= 0 || width % 4 != 0 || height % 4 != 0
|
||||
|| blocks.Length < rowBytes * rows)
|
||||
return IntPtr.Zero;
|
||||
int hr = _createTexture(pDevice, (uint)width, (uint)height, 1, 0,
|
||||
D3DFMT_DXT1, D3DPOOL_MANAGED, out IntPtr tex, IntPtr.Zero);
|
||||
if (hr < 0 || tex == IntPtr.Zero)
|
||||
return IntPtr.Zero;
|
||||
|
||||
var lockRect = GetTexMethod<TexLockRectD>(tex, TextureVTableIndex.LockRect);
|
||||
var unlockRect = GetTexMethod<TexUnlockRectD>(tex, TextureVTableIndex.UnlockRect);
|
||||
D3DLOCKED_RECT locked;
|
||||
if (lockRect(tex, 0, &locked, IntPtr.Zero, 0) < 0 || locked.pBits == IntPtr.Zero)
|
||||
{
|
||||
ReleaseComObject(tex);
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
byte* dst = (byte*)locked.pBits;
|
||||
for (int y = 0; y < rows; y++) // the pitch of a compressed surface is the bytes of one row of blocks
|
||||
blocks.Slice(y * rowBytes, rowBytes).CopyTo(new Span<byte>(dst + y * locked.Pitch, rowBytes));
|
||||
unlockRect(tex, 0);
|
||||
return tex;
|
||||
}
|
||||
|
||||
/// <summary>Releases a texture made by <see cref="CreateTextureRgba"/>. AC's render thread.</summary>
|
||||
public static void ReleaseTexture(IntPtr tex) => ReleaseComObject(tex);
|
||||
|
||||
|
|
|
|||
|
|
@ -134,17 +134,14 @@ internal static class EngineFrameController
|
|||
|
||||
// Before any context exists: the loaded cimgui.dll must be the exact
|
||||
// build ImGui.NET wraps, or every struct read below is at wrong offsets.
|
||||
Compatibility.MemoryUse.Mark("ImGui init: before the self-test");
|
||||
if (!ImGuiSelfTest.Run(EntryPoint.ImGuiNativeHandle))
|
||||
return false;
|
||||
Compatibility.MemoryUse.Mark("ImGui self-test done");
|
||||
|
||||
IntPtr previousContext = ImGuiNET.ImGui.GetCurrentContext();
|
||||
if (previousContext != IntPtr.Zero)
|
||||
RynthLog.Render($"EngineFrameController: Existing ImGui context detected (0x{previousContext:X8}) - isolating RynthCore context.");
|
||||
|
||||
_context = ImGuiNET.ImGui.CreateContext();
|
||||
Compatibility.MemoryUse.Mark("ImGui context created");
|
||||
bool initSucceeded = false;
|
||||
try
|
||||
{
|
||||
|
|
@ -182,7 +179,6 @@ internal static class EngineFrameController
|
|||
_uiScale = UiScale.ForWindow(_gameHwnd);
|
||||
RynthLog.UI($"EngineFrameController: ImGui scale {_uiScale:0.##} (Avalonia input scale {UI.AvaloniaOverlay.InputScale:0.##}).");
|
||||
RynthTheme.Apply(ImGuiNET.ImGui.GetStyle(), _uiScale);
|
||||
Compatibility.MemoryUse.Mark("ImGui theme applied");
|
||||
ImGuiFonts.Build(io, _uiScale);
|
||||
|
||||
if (!Win32Backend.Init(_gameHwnd))
|
||||
|
|
@ -191,13 +187,11 @@ internal static class EngineFrameController
|
|||
return false;
|
||||
}
|
||||
|
||||
Compatibility.MemoryUse.Mark("Win32 backend ready");
|
||||
if (!DX9Backend.InitImGui(pDevice))
|
||||
{
|
||||
_initFailStep = "DX9Backend.InitImGui";
|
||||
return false;
|
||||
}
|
||||
Compatibility.MemoryUse.Mark("DX9 backend ready (font texture)");
|
||||
|
||||
_lastFrameTicks = Stopwatch.GetTimestamp();
|
||||
_imguiInitialized = true;
|
||||
|
|
@ -239,8 +233,6 @@ internal static class EngineFrameController
|
|||
// Its lists are drawn by DX9Backend from the DIP hook, which is still live.
|
||||
UnderUiLayer.Shutdown();
|
||||
ScriptIcons.Shutdown(); // script window icon textures, before the backend goes
|
||||
WorldMapTiles.Shutdown(); // the world map's tile textures, likewise
|
||||
WorldMapVectors.Shutdown();
|
||||
RetailSprites.Shutdown(); // retail UI pictures (Inventory Classic view), likewise
|
||||
DX9Backend.Shutdown();
|
||||
// Do NOT call Win32Backend.Shutdown() here. EngineLifecycle.Shutdown
|
||||
|
|
@ -602,7 +594,6 @@ internal static class EngineFrameController
|
|||
|
||||
/// <summary>DPI scale the fonts and style were built for (see Init).</summary>
|
||||
private static float _uiScale = 1f;
|
||||
private static int _themeApplied; // RynthTheme.Version the base style was coloured at
|
||||
|
||||
/// <summary>The scale the fonts and style were built for.</summary>
|
||||
internal static float FontScale => _uiScale;
|
||||
|
|
@ -714,7 +705,6 @@ internal static class EngineFrameController
|
|||
// Script window icons decoded since the last frame become textures, and the least
|
||||
// recently drawn go, before anything draws (no draw list points at them any more).
|
||||
ScriptIcons.BeginFrame(pDevice);
|
||||
WorldMapTiles.BeginFrame(pDevice); // world map tiles read since the last frame become textures
|
||||
RetailSprites.BeginFrame(pDevice); // retail UI pictures decoded since the last frame (kept, never evicted)
|
||||
DX9Backend.NewFrame();
|
||||
Win32Backend.NewFrame(clientW, clientH);
|
||||
|
|
@ -731,7 +721,6 @@ internal static class EngineFrameController
|
|||
_lastFrameTicks = now;
|
||||
io.DeltaTime = dt > 0f ? dt : 1f / 60f;
|
||||
|
||||
RynthTheme.RefreshStyle(ref _themeApplied); // a theme change re-colours the base style
|
||||
ImGuiNET.ImGui.NewFrame();
|
||||
frameStarted = true;
|
||||
// Before any window: a drag from a popped-out Inventory or AC's inventory becomes
|
||||
|
|
|
|||
|
|
@ -9,39 +9,25 @@
|
|||
// asked for a button (WindowFlags.BarButton: RynthSort, Oracle, ...; tooltip =
|
||||
// its title; the set is rebuilt as plugins come and go), reload (RL) and pop out.
|
||||
// Dragging the grip moves the bar; the position is the shared bar= row in
|
||||
// panel_state.txt. Right-click the grip for the bar's menu: its size, its rows
|
||||
// and "Report a problem" (panel buttons have no menu). Pop out moves the ImGui
|
||||
// bar into its own window (ImGuiPopOuts, sized to its content; dock back
|
||||
// returns it).
|
||||
// panel_state.txt. Right-click a panel button (or the grip for the bar
|
||||
// itself) to choose which face shows it docked; the grip's menu also has the
|
||||
// bar's size and "Report a problem". Pop out moves the ImGui bar
|
||||
// into its own window (ImGuiPopOuts, sized to its content; dock back
|
||||
// returns it); a bar whose face is Avalonia/Both still pops out as the
|
||||
// Avalonia bar.
|
||||
//
|
||||
// The bar's size is its own text size step (PanelTextScale chrome row): the bar's
|
||||
// fonts come from that baked set and its metrics scale by the step's factor. Set it
|
||||
// from the grip's right-click menu, Ctrl+wheel over the bar, Settings > Display or
|
||||
// /rc ui barsize.
|
||||
//
|
||||
// Rows (BarLayout): the player picks how many rows the bar has (1-6) and the most
|
||||
// icons a row may hold (no limit, or 2-30): icons per row = ceil(icons / rows),
|
||||
// capped at the limit, so the cap can add rows. The icons (panels, plugin windows,
|
||||
// ILT, Scripts) fill rows left to right, top to bottom, each row starting under the
|
||||
// first icon: the grip and the collapse caret lead the first row only. RL and pop out
|
||||
// stay at the end of the first row, so one row looks as it always did and they keep
|
||||
// their spot as icons come and go on the rows below. The window sizes to its content
|
||||
// as before (AlwaysAutoResize; popped out, ImGuiPopOuts sizes to it); a folded bar is
|
||||
// still just the grip and caret. Set from the grip's right-click menu, Settings >
|
||||
// Display or /rc ui barrows / baricons; kept in panel_state.txt's barlayout= row.
|
||||
//
|
||||
// The bar is always this ImGui face while the ImGui layer is on (Tom, 2026-10-14:
|
||||
// the Avalonia and Both faces are gone). The old choice (face key "__bar" in
|
||||
// panel_faces.txt, the grip's and panel buttons' Avalonia / ImGui / Both menu
|
||||
// items) is no longer offered, and a saved Avalonia or Both is read as ImGui
|
||||
// (ResolveFace); docked panels already ignore theirs (PanelRouter.ResolveDockedFace).
|
||||
// While the ImGui bar shows, the docked Avalonia bar is hidden and takes no
|
||||
// clicks (AvaloniaOverlay.DockedBarSuppressed). AC thread except where noted.
|
||||
// Face key "__bar" in panel_faces.txt; code default Avalonia. While the ImGui
|
||||
// bar shows, the docked Avalonia bar is hidden and takes no clicks
|
||||
// (AvaloniaOverlay.DockedBarSuppressed). AC thread except where noted.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using System.Threading;
|
||||
using ImGuiNET;
|
||||
|
|
@ -61,10 +47,13 @@ internal static class ImGuiBar
|
|||
private static readonly HashSet<string> LauncherOnly = new(StringComparer.OrdinalIgnoreCase)
|
||||
{ "Monsters", "Damage", "Settings", "Nav", "Meta", "Items" };
|
||||
|
||||
private static readonly PanelFace[] Faces = { PanelFace.Avalonia, PanelFace.ImGui, PanelFace.Both };
|
||||
private static readonly string[] FaceNames = { "Avalonia", "ImGui", "Both (side by side)" };
|
||||
|
||||
// Window: a plugin's script window with a bar button of its own (WindowFlags.BarButton);
|
||||
// the button toggles it through ScriptWindowRegistry, like the Scripts menu does.
|
||||
private sealed record ButtonInfo(string Title, string Id, string Icon, bool Letter, string Tooltip,
|
||||
ScriptWindow? Window = null);
|
||||
private sealed record ButtonInfo(string Title, string Id, string PopupId, string Icon, bool Letter, string Tooltip,
|
||||
bool ImGuiOnly = false, ScriptWindow? Window = null);
|
||||
|
||||
// Engine panels with an ImGui face only (no OverlayHost entry) that get a bar button.
|
||||
private static readonly string[] ImGuiOnlyBarPanels =
|
||||
|
|
@ -146,51 +135,6 @@ internal static class ImGuiBar
|
|||
private static bool _userMoved;
|
||||
private static int _lastStep, _sizeWatch;
|
||||
|
||||
// The bar's rows and icons-per-row limit (BarLayout). Read from panel_state once, then kept
|
||||
// here so a change shows at once (the file is written in the background); one reference, so
|
||||
// a reader on another thread never sees half a change.
|
||||
private sealed record RowSettings(int Rows, int MaxPerRow);
|
||||
private static RowSettings? _rowSettings, _lastRowSettings;
|
||||
// Icons per row as last drawn: where the icons-per-row "-" starts from when there is no limit.
|
||||
private static int _shownPerRow = 1;
|
||||
|
||||
private static RowSettings RowLayout
|
||||
{
|
||||
get
|
||||
{
|
||||
RowSettings? cur = Volatile.Read(ref _rowSettings);
|
||||
if (cur != null) return cur;
|
||||
var (rows, max) = PanelStateStore.BarRows;
|
||||
Interlocked.CompareExchange(ref _rowSettings, new RowSettings(rows, max), null);
|
||||
return Volatile.Read(ref _rowSettings)!;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The bar's rows (1-6). Any thread.</summary>
|
||||
public static int Rows => RowLayout.Rows;
|
||||
|
||||
/// <summary>The most icons a bar row holds; 0 = no limit. Any thread.</summary>
|
||||
public static int MaxPerRow => RowLayout.MaxPerRow;
|
||||
|
||||
/// <summary>Icons per row as the bar last drew them. Any thread.</summary>
|
||||
public static int ShownPerRow => Volatile.Read(ref _shownPerRow);
|
||||
|
||||
/// <summary>Sets the bar's rows and icons-per-row limit (clamped; BarLayout) and saves them. Any thread.</summary>
|
||||
public static void SetRowLayout(int rows, int maxPerRow)
|
||||
{
|
||||
var next = new RowSettings(BarLayout.ClampRows(rows), BarLayout.ClampMaxPerRow(maxPerRow));
|
||||
if (next == RowLayout) return;
|
||||
Volatile.Write(ref _rowSettings, next);
|
||||
UiBackgroundWriter.Enqueue("persist bar rows", () => PanelStateStore.SetBarRows(next.Rows, next.MaxPerRow));
|
||||
}
|
||||
|
||||
/// <summary>"Bar rows: 2, icons per row: no limit." for chat. Any thread.</summary>
|
||||
public static string DescribeRowLayout()
|
||||
{
|
||||
RowSettings cur = RowLayout;
|
||||
return $"Bar rows: {cur.Rows.ToString(CultureInfo.InvariantCulture)}, icons per row: {BarLayout.DescribeMaxPerRow(cur.MaxPerRow).ToLowerInvariant()}.";
|
||||
}
|
||||
|
||||
private const string PopOutTitle = "__bar";
|
||||
// Popped out (the ImGui bar in its own window). Read from panel_state once,
|
||||
// then kept here so a switch shows at once (the file is written in the background).
|
||||
|
|
@ -200,12 +144,13 @@ internal static class ImGuiBar
|
|||
/// <summary>True when the ImGui bar is popped out into its own window.</summary>
|
||||
public static bool PoppedOut => ResolveFace() == PanelFace.ImGui && Floating;
|
||||
|
||||
/// <summary>
|
||||
/// The bar's docked face: ImGui whenever the ImGui layer is on, Avalonia only without it.
|
||||
/// A face saved in panel_faces.txt (Avalonia or Both, from before) is ignored. Any thread.
|
||||
/// </summary>
|
||||
public static PanelFace ResolveFace() =>
|
||||
Plugins.EngineSettings.EnableImGuiBackend ? PanelFace.ImGui : PanelFace.Avalonia;
|
||||
/// <summary>The bar's docked face. Any thread.</summary>
|
||||
public static PanelFace ResolveFace()
|
||||
{
|
||||
if (!Plugins.EngineSettings.EnableImGuiBackend) return PanelFace.Avalonia;
|
||||
if (!Plugins.EngineSettings.EnableAvaloniaOverlay) return PanelFace.ImGui;
|
||||
return PanelFaceStore.TryGet(FaceKey, out PanelFace f) ? f : PanelFace.ImGui;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows/hides the docked Avalonia bar to match the bar's face. Call at
|
||||
|
|
@ -217,7 +162,7 @@ internal static class ImGuiBar
|
|||
_placed = false; // re-read the shared position next frame
|
||||
}
|
||||
|
||||
/// <summary>True when the ImGui bar should draw (the ImGui layer on, not popped out).</summary>
|
||||
/// <summary>True when the ImGui bar should draw (docked face ImGui/Both, not popped out).</summary>
|
||||
public static bool Visible => ResolveFace() != PanelFace.Avalonia && !Floating;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -273,6 +218,7 @@ internal static class ImGuiBar
|
|||
EnsureButtons();
|
||||
int step = ChromeStep(out float factor);
|
||||
s *= factor;
|
||||
float place = AvaloniaOverlay.InputScale > 0 ? AvaloniaOverlay.InputScale : 1f;
|
||||
ImGuiNET.ImGui.SetNextWindowPos(ImGuiPopOuts.PanelOrigin, ImGuiCond.Always);
|
||||
PushBarWindowStyle(s);
|
||||
ImGuiNET.ImGui.Begin("##rc_bar", BarFlags);
|
||||
|
|
@ -280,7 +226,7 @@ internal static class ImGuiBar
|
|||
{
|
||||
ImGuiFonts.CurrentStep = step;
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
|
||||
DrawContent(s, popped: true);
|
||||
DrawContent(s, place, popped: true);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
// Not on its first frame: an auto-resizing window has no content size yet
|
||||
// and reports just its padding (8x6), which would shrink the window to it.
|
||||
|
|
@ -323,29 +269,27 @@ internal static class ImGuiBar
|
|||
int step = ChromeStep(out float factor);
|
||||
s *= factor;
|
||||
float place = AvaloniaOverlay.InputScale > 0 ? AvaloniaOverlay.InputScale : 1f;
|
||||
bool both = ResolveFace() == PanelFace.Both;
|
||||
|
||||
if (!_placed)
|
||||
{
|
||||
var saved = PanelStateStore.BarPosition;
|
||||
Vector2 logical = saved.HasValue ? new Vector2((float)saved.Value.Left, (float)saved.Value.Top) : new Vector2(50, 5);
|
||||
if (both) logical += new Vector2(24, 24);
|
||||
_pos = _persistedPos = logical * place;
|
||||
ImGuiNET.ImGui.SetNextWindowPos(_pos, ImGuiCond.Always);
|
||||
_placed = true;
|
||||
_lastStep = step; // the size the bar loads at is the baseline, not a change
|
||||
_lastRowSettings = RowLayout;
|
||||
}
|
||||
|
||||
if (step != _lastStep) { _lastStep = step; _sizeWatch = 4; }
|
||||
// New rows reshape the bar (wider or taller): the same pull back on screen as a new size.
|
||||
RowSettings rowsNow = RowLayout;
|
||||
if (!ReferenceEquals(rowsNow, _lastRowSettings)) { _lastRowSettings = rowsNow; _sizeWatch = 4; }
|
||||
PushBarWindowStyle(s);
|
||||
ImGuiNET.ImGui.Begin("##rc_bar", BarFlags);
|
||||
try
|
||||
{
|
||||
ImGuiFonts.CurrentStep = step;
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
|
||||
DrawContent(s, popped: false);
|
||||
DrawContent(s, place, popped: false);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
KeepOnScreen();
|
||||
}
|
||||
|
|
@ -362,17 +306,17 @@ internal static class ImGuiBar
|
|||
_persistedPos = _pos;
|
||||
if (_userMoved || _sizeWatch > 0)
|
||||
{
|
||||
Vector2 logical = _pos / place;
|
||||
Vector2 logical = _pos / place - (both ? new Vector2(24, 24) : Vector2.Zero);
|
||||
double left = logical.X, top = logical.Y;
|
||||
UiBackgroundWriter.Enqueue("persist bar", () => PanelStateStore.SetBarPosition(left, top));
|
||||
AvaloniaOverlay.SyncDockedBarPosition(left, top);
|
||||
if (!both) AvaloniaOverlay.SyncDockedBarPosition(left, top);
|
||||
}
|
||||
_userMoved = false;
|
||||
}
|
||||
if (_sizeWatch > 0) _sizeWatch--;
|
||||
}
|
||||
|
||||
/// <summary>A bigger size or new rows can push the bar's right or bottom end off the screen: pull it back (not while it is being dragged).</summary>
|
||||
/// <summary>A bigger size can push the bar's right end off the screen: pull it back (not while it is being dragged).</summary>
|
||||
private static void KeepOnScreen()
|
||||
{
|
||||
Vector2 display = ImGuiNET.ImGui.GetIO().DisplaySize;
|
||||
|
|
@ -382,7 +326,7 @@ internal static class ImGuiBar
|
|||
if (next != pos) ImGuiNET.ImGui.SetWindowPos(next);
|
||||
}
|
||||
|
||||
private static void DrawContent(float s, bool popped)
|
||||
private static void DrawContent(float s, float place, bool popped)
|
||||
{
|
||||
// Ctrl+wheel over the bar steps its size (the panels' title bars do the same).
|
||||
ImGuiIOPtr io = ImGuiNET.ImGui.GetIO();
|
||||
|
|
@ -415,9 +359,9 @@ internal static class ImGuiBar
|
|||
}
|
||||
SafeImGui.SetItemTooltip(_tooltip);
|
||||
if (ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
||||
ImGuiNET.ImGui.OpenPopup("##bar_menu");
|
||||
ImGuiNET.ImGui.OpenPopup("##face_bar");
|
||||
PhosphorIcons.DrawCentered(dl, iconFont, PhosphorIcons.DotsSixVertical, rcPos, new Vector2(square.X * 0.8f, square.Y), RynthTheme.RcLabel);
|
||||
BarMenu(s);
|
||||
FacePopup("##face_bar", FaceKey, hasImGuiFace: true, s);
|
||||
|
||||
// Collapse: the bar folds to its grip and this caret.
|
||||
bool collapsed = RynthAiDashboardState.BarCollapsed;
|
||||
|
|
@ -432,37 +376,29 @@ internal static class ImGuiBar
|
|||
caretHot ? RynthTheme.RcLabel : 0xFF9A9A9Au);
|
||||
if (collapsed) return;
|
||||
|
||||
// Rows (header): perRow icons a row, each row from iconsX (under the first icon);
|
||||
// RL and pop out go at the end of the first row (NextSlot, or after the icons when
|
||||
// they all fit on it).
|
||||
int iltCount = IltPanelCount();
|
||||
ScriptBarItem[] scripts = ScriptWindowRegistry.BarItems;
|
||||
int icons = _buttons!.Length + (iltCount > 0 ? 1 : 0) + (scripts.Length > 0 ? 1 : 0);
|
||||
RowSettings rows = RowLayout;
|
||||
int perRow = BarLayout.PerRow(icons, rows.Rows, rows.MaxPerRow);
|
||||
Volatile.Write(ref _shownPerRow, perRow);
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
float iconsX = ImGuiNET.ImGui.GetCursorPosX();
|
||||
int slot = 0;
|
||||
|
||||
PushBarButtonStyle(s);
|
||||
ImFontPtr letterFont = ImGuiFonts.Get(UiFont.UiBold11);
|
||||
foreach (ButtonInfo b in _buttons!)
|
||||
{
|
||||
NextSlot(ref slot, perRow, iconsX, s, iconFont, popped);
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
if (IconButton(b.Id, b.Letter ? letterFont : iconFont, b.Icon, square, RynthTheme.BarText))
|
||||
{
|
||||
if (b.Window != null) ScriptWindowRegistry.PlayerSetVisible(b.Window, !ImGuiPanelHost.IsOpen(b.Window.PanelKey));
|
||||
else PanelRouter.Toggle(b.Title);
|
||||
}
|
||||
SafeImGui.SetItemTooltip(b.Tooltip);
|
||||
ImGuiNET.ImGui.SetItemTooltip(b.Tooltip); // a plugin window's title arrives with '%' doubled (EnsureButtons)
|
||||
if (b.ImGuiOnly) continue; // no Avalonia face: no face to choose
|
||||
if (ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
||||
ImGuiNET.ImGui.OpenPopup(b.PopupId);
|
||||
FacePopup(b.PopupId, b.Title, ImGuiPanelHost.HasFace(b.Title));
|
||||
}
|
||||
|
||||
// The ILT section: one button, only on Infinite Leaftide with ILT panels registered
|
||||
// (Bounties, Guardian). With one panel it toggles that panel; with more it opens a menu.
|
||||
int iltCount = IltPanelCount();
|
||||
if (iltCount > 0)
|
||||
{
|
||||
NextSlot(ref slot, perRow, iconsX, s, iconFont, popped);
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
string? only = iltCount == 1 ? FirstIltPanel() : null;
|
||||
if (IconButton("##ilt", iconFont, PhosphorIcons.Leaf, square, RynthTheme.BarText))
|
||||
{
|
||||
|
|
@ -475,47 +411,15 @@ internal static class ImGuiBar
|
|||
// Script windows (decision 2): one button with a menu, only while a ShowInBar
|
||||
// script window exists. A window that also sets BarButton (plugin windows such as
|
||||
// RynthSort's) has a button of its own instead (EnsureButtons) and isn't listed here.
|
||||
ScriptBarItem[] scripts = ScriptWindowRegistry.BarItems;
|
||||
if (scripts.Length > 0)
|
||||
{
|
||||
NextSlot(ref slot, perRow, iconsX, s, iconFont, popped);
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
if (IconButton("##scripts", iconFont, PhosphorIcons.AppWindow, square, RynthTheme.BarText))
|
||||
ImGuiNET.ImGui.OpenPopup("##scripts_menu");
|
||||
ImGuiNET.ImGui.SetItemTooltip("Script windows");
|
||||
}
|
||||
|
||||
// Every icon fit on the first row: RL and pop out follow them.
|
||||
if (slot <= perRow) DrawControls(s, iconFont, popped);
|
||||
PopBarButtonStyle();
|
||||
|
||||
// Drawn after the bar buttons' style is popped, so the menu has the normal look.
|
||||
ScriptsMenu(scripts);
|
||||
IltMenu();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Places the next icon: beside the last one, or at the start of a new row (under the first
|
||||
/// icon) every <paramref name="perRow"/> icons. Leaving the first row, RL and pop out go at
|
||||
/// its end first. AC thread, inside the bar window with the bar buttons' style pushed.
|
||||
/// </summary>
|
||||
private static void NextSlot(ref int slot, int perRow, float iconsX, float s, ImFontPtr iconFont, bool popped)
|
||||
{
|
||||
// Slot 0: DrawContent's SameLine after the caret already placed it.
|
||||
if (slot > 0)
|
||||
{
|
||||
if (slot % perRow != 0) ImGuiNET.ImGui.SameLine();
|
||||
else
|
||||
{
|
||||
if (slot == perRow) DrawControls(s, iconFont, popped);
|
||||
ImGuiNET.ImGui.SetCursorPosX(iconsX);
|
||||
}
|
||||
}
|
||||
slot++;
|
||||
}
|
||||
|
||||
/// <summary>RL and pop out, after the first row's last icon (or the caret on a bar with no icons). AC thread.</summary>
|
||||
private static void DrawControls(float s, ImFontPtr iconFont, bool popped)
|
||||
{
|
||||
var square = new Vector2(ButtonSize, ButtonSize) * s;
|
||||
ImGuiNET.ImGui.SameLine(0, 6 * s);
|
||||
if (IconButton("##reload", iconFont, PhosphorIcons.ArrowsClockwise, square, RynthTheme.ReloadLabel))
|
||||
{
|
||||
|
|
@ -525,11 +429,28 @@ internal static class ImGuiBar
|
|||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("Engine reload (RL) — shut down, FreeLibrary, reload from disk, re-init.");
|
||||
|
||||
// The bar draws only as the ImGui face (ResolveFace), so it pops out as itself.
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
if (IconButton("##popout", iconFont, popped ? PhosphorIcons.ArrowSquareIn : PhosphorIcons.ArrowSquareOut, square, RynthTheme.PopOutLabel))
|
||||
SetPoppedOut(!popped);
|
||||
SafeImGui.SetItemTooltip(popped ? "Dock the bar back into the game window." : "Pop the bar out into its own floating window.");
|
||||
if (ResolveFace() == PanelFace.ImGui)
|
||||
{
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
if (IconButton("##popout", iconFont, popped ? PhosphorIcons.ArrowSquareIn : PhosphorIcons.ArrowSquareOut, square, RynthTheme.PopOutLabel))
|
||||
SetPoppedOut(!popped);
|
||||
SafeImGui.SetItemTooltip(popped ? "Dock the bar back into the game window." : "Pop the bar out into its own floating window.");
|
||||
}
|
||||
else if (Plugins.EngineSettings.EnableAvaloniaOverlay) // Avalonia/Both bar: pops out as the Avalonia bar
|
||||
{
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
if (IconButton("##popout", iconFont, PhosphorIcons.ArrowSquareOut, square, RynthTheme.PopOutLabel))
|
||||
{
|
||||
Vector2 logical = ImGuiNET.ImGui.GetWindowPos() / place;
|
||||
AvaloniaOverlay.PopOutBarFrom(logical.X, logical.Y);
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("Pop the bar out into its own floating window.");
|
||||
}
|
||||
PopBarButtonStyle();
|
||||
|
||||
// Drawn after the bar buttons' style is popped, so the menu has the normal look.
|
||||
ScriptsMenu(scripts);
|
||||
IltMenu();
|
||||
}
|
||||
|
||||
/// <summary>The ILT panels the bar offers now: 0 off Infinite Leaftide or without RynthILT. AC thread.</summary>
|
||||
|
|
@ -609,14 +530,24 @@ internal static class ImGuiBar
|
|||
return clicked;
|
||||
}
|
||||
|
||||
/// <summary>The grip's right-click menu: the bar's size, its rows and "Report a problem".</summary>
|
||||
private static void BarMenu(float s)
|
||||
private static void FacePopup(string popupId, string title, bool hasImGuiFace, float s = 1f)
|
||||
{
|
||||
if (!ImGuiNET.ImGui.BeginPopup("##bar_menu")) return;
|
||||
ImGuiNET.ImGui.TextDisabled("RynthCore bar");
|
||||
BarSizeRows(s);
|
||||
BarLayoutRows(s);
|
||||
ReportRow();
|
||||
if (!ImGuiNET.ImGui.BeginPopup(popupId)) return;
|
||||
SafeImGui.TextDisabled(title == FaceKey ? "Bar, docked, shows as" : "Docked, shows as");
|
||||
PanelFace current = title == FaceKey ? ResolveFace() : PanelRouter.ResolveDockedFace(title);
|
||||
for (int i = 0; i < Faces.Length; i++)
|
||||
{
|
||||
bool enabled = Faces[i] == PanelFace.Avalonia || hasImGuiFace;
|
||||
if (ImGuiNET.ImGui.MenuItem(FaceNames[i], "", current == Faces[i], enabled))
|
||||
PanelRouter.SetDockedFace(title, Faces[i]);
|
||||
}
|
||||
if (!hasImGuiFace)
|
||||
ImGuiNET.ImGui.TextDisabled("(no ImGui version yet)");
|
||||
if (title == FaceKey)
|
||||
{
|
||||
BarSizeRows(s);
|
||||
ReportRow();
|
||||
}
|
||||
ImGuiNET.ImGui.EndPopup();
|
||||
}
|
||||
|
||||
|
|
@ -655,49 +586,6 @@ internal static class ImGuiBar
|
|||
ImGuiNET.ImGui.SetItemTooltip("Back to normal size");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The grip menu's Rows and Icons per row steppers (BarLayout, header). Icons per row runs
|
||||
/// 2..30 then No limit; its "-" from No limit caps one below what a row shows now.
|
||||
/// </summary>
|
||||
private static void BarLayoutRows(float s)
|
||||
{
|
||||
RowSettings cur = RowLayout;
|
||||
ImGuiNET.ImGui.Separator();
|
||||
int d = Stepper("##br_rows", "Rows", cur.Rows.ToString(CultureInfo.InvariantCulture),
|
||||
cur.Rows > BarLayout.MinRows, cur.Rows < BarLayout.MaxRows, "Fewer rows", "More rows", s);
|
||||
if (d != 0) SetRowLayout(cur.Rows + d, cur.MaxPerRow);
|
||||
d = Stepper("##br_max", "Icons per row", BarLayout.DescribeMaxPerRow(cur.MaxPerRow),
|
||||
cur.MaxPerRow != BarLayout.MinPerRow, cur.MaxPerRow != BarLayout.NoLimit,
|
||||
"Fewer icons per row (more rows when the bar has more icons)", "More icons per row (past 30: no limit)", s);
|
||||
if (d != 0) SetRowLayout(cur.Rows, BarLayout.StepMaxPerRow(cur.MaxPerRow, d, ShownPerRow));
|
||||
}
|
||||
|
||||
/// <summary>A label, then - and + buttons and the value (the bar size row's look). -1, 0 or +1 for the click.</summary>
|
||||
private static int Stepper(string id, string label, string value, bool canDown, bool canUp, string downTip, string upTip, float s)
|
||||
{
|
||||
float btn = ButtonSize * s;
|
||||
ImFontPtr iconFont = ImGuiFonts.Get(UiFont.Ui14);
|
||||
uint text = ImGuiNET.ImGui.GetColorU32(ImGuiCol.Text);
|
||||
int delta = 0;
|
||||
|
||||
ImGuiNET.ImGui.TextUnformatted(label);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, Vector2.Zero);
|
||||
ImGuiNET.ImGui.BeginDisabled(!canDown);
|
||||
if (IconButton(id + "_down", iconFont, PhosphorIcons.Minus, new Vector2(btn, btn), text)) delta = -1;
|
||||
ImGuiNET.ImGui.EndDisabled();
|
||||
SafeImGui.SetItemTooltip(downTip);
|
||||
ImGuiNET.ImGui.SameLine(0, 4 * s);
|
||||
ImGuiNET.ImGui.BeginDisabled(!canUp);
|
||||
if (IconButton(id + "_up", iconFont, PhosphorIcons.Plus, new Vector2(btn, btn), text)) delta = 1;
|
||||
ImGuiNET.ImGui.EndDisabled();
|
||||
SafeImGui.SetItemTooltip(upTip);
|
||||
ImGuiNET.ImGui.PopStyleVar();
|
||||
ImGuiNET.ImGui.SameLine(0, 8 * s);
|
||||
ImGuiNET.ImGui.AlignTextToFramePadding();
|
||||
ImGuiNET.ImGui.TextUnformatted(value);
|
||||
return delta;
|
||||
}
|
||||
|
||||
/// <summary>The grip menu's "Report a problem" entry (Report/ProblemReport.cs).</summary>
|
||||
private static void ReportRow()
|
||||
{
|
||||
|
|
@ -714,8 +602,8 @@ internal static class ImGuiBar
|
|||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1f);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 2f);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Button, RynthTheme.BarButton);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ButtonHovered, RynthTheme.FrameHover);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ButtonActive, RynthTheme.FrameActive);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ButtonHovered, RynthTheme.Argb(0xFF2A3850));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ButtonActive, RynthTheme.Argb(0xFF34466A));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, RynthTheme.BarButtonBorder);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, RynthTheme.BarText);
|
||||
}
|
||||
|
|
@ -752,13 +640,14 @@ internal static class ImGuiBar
|
|||
if (!LauncherOnly.Contains(title))
|
||||
{
|
||||
string icon = IconFor(title, out bool letter);
|
||||
list.Add(new ButtonInfo(title, "##bar_" + title, icon, letter, title));
|
||||
list.Add(new ButtonInfo(title, "##bar_" + title, "##face_" + title, icon, letter,
|
||||
title + "\nRight-click: which face shows it docked."));
|
||||
}
|
||||
foreach (string title in ImGuiOnlyBarPanels)
|
||||
if (ImGuiPanelHost.HasFace(title) && !LauncherOnly.Contains(title))
|
||||
{
|
||||
string icon = IconFor(title, out bool letter);
|
||||
list.Add(new ButtonInfo(title, "##bar_" + title, icon, letter, title));
|
||||
list.Add(new ButtonInfo(title, "##bar_" + title, "##face_" + title, icon, letter, title, ImGuiOnly: true));
|
||||
}
|
||||
// Plugin script windows that asked for a button (RynthSort, Oracle, ...): after the
|
||||
// engine's own. Only while the plugin is loaded and has submitted the window.
|
||||
|
|
@ -768,9 +657,10 @@ internal static class ImGuiBar
|
|||
string title = w.Title.Length > 0 ? w.Title : w.Key;
|
||||
string icon = IconFor(title, out bool letter);
|
||||
string id = "##bar_sw" + w.Hash.ToString("X8");
|
||||
list.Add(new ButtonInfo(title, id, icon, letter, title, Window: w));
|
||||
// The tooltip goes through SetItemTooltip, a format function: the plugin's text with '%' doubled.
|
||||
list.Add(new ButtonInfo(title, id, id + "_face", icon, letter, title.Replace("%", "%%"), ImGuiOnly: true, Window: w));
|
||||
}
|
||||
_buttons = list.ToArray();
|
||||
_tooltip = $"RynthCore {EntryPoint.BuildStamp}\nDrag here to move the bar. Right-click: bar size and rows. Ctrl+wheel over the bar: size.";
|
||||
_tooltip = $"RynthCore {EntryPoint.BuildStamp}\nDrag here to move the bar. Right-click: bar face and size. Ctrl+wheel over the bar: size.";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,8 @@
|
|||
// Consolas 9/10/12 (Tracker, Log, Meta rows), Cascadia Mono 12 (Meta
|
||||
// source; Consolas if missing), and the chat monospace at 8-18 in steps
|
||||
// of 2 (the chat font slider snaps to the nearest).
|
||||
// The few symbol glyphs still drawn as text (SymbolCodepoints) come from the
|
||||
// main font itself (Segoe UI, Consolas and Cascadia Mono all have them); Segoe UI
|
||||
// Symbol is merged only into a font whose file lacks one (HasGlyphs). ImGui copies
|
||||
// the whole TTF into the atlas for every font it adds, and Segoe UI Symbol is
|
||||
// 2.4 MB: merged into every size (~107 with the panel text sizes) it made ~250 MB
|
||||
// of the atlas's input data for three glyphs (2026-10-15). DX9Backend frees the
|
||||
// input data once the texture is uploaded (ClearInputData).
|
||||
// The few symbol glyphs still drawn as text (SymbolCodepoints) are merged in
|
||||
// from Segoe UI Symbol wherever the main font lacks them.
|
||||
//
|
||||
// Icons: the Phosphor icon font (MIT, Assets/Fonts/Phosphor.ttf, embedded in
|
||||
// this assembly) is merged into every baked font, the scaled sets included,
|
||||
|
|
@ -62,8 +57,7 @@ internal static unsafe class ImGuiFonts
|
|||
private static readonly string FontsDir = Environment.GetFolderPath(Environment.SpecialFolder.Fonts);
|
||||
|
||||
// Main text: Basic Latin + Latin-1, general punctuation (— – … • ‘ ’ “ ”), arrows.
|
||||
// Plus the SymbolCodepoints (≤ ≥ ●), which the main fonts have.
|
||||
private static readonly ushort[] MainRanges = { 0x0020, 0x00FF, 0x2010, 0x2027, 0x2190, 0x21FF, 0x2264, 0x2265, 0x25CF, 0x25CF, 0 };
|
||||
private static readonly ushort[] MainRanges = { 0x0020, 0x00FF, 0x2010, 0x2027, 0x2190, 0x21FF, 0 };
|
||||
|
||||
// Symbols still drawn as text, merged from Segoe UI Symbol where the main font
|
||||
// lacks them. The panels' other symbols (⚔ ✦ ➤ ◫ ♥ ◆ ⚙ ▾ ▴ ↗ ↙ ◢ ✕ ☑ ☐ ▶ ▼ ▲ ◀ ■
|
||||
|
|
@ -87,8 +81,6 @@ internal static unsafe class ImGuiFonts
|
|||
// Phosphor's regular strokes are 1/16 em: at 9-13 px they rasterize thin and grey.
|
||||
private const float IconRasterizerMultiply = 1.2f;
|
||||
private static volatile bool _preloaded;
|
||||
// Fonts the last AddAll merged Segoe UI Symbol into (their file lacked a symbol glyph).
|
||||
private static int _symbolMerges;
|
||||
private static readonly List<IntPtr> NativeBuffers = new();
|
||||
private static readonly ImFontPtr[] Fonts = new ImFontPtr[(int)UiFont.Count];
|
||||
|
||||
|
|
@ -205,7 +197,6 @@ internal static unsafe class ImGuiFonts
|
|||
{
|
||||
long t0 = Stopwatch.GetTimestamp();
|
||||
PrepareNativeData();
|
||||
Compatibility.MemoryUse.Mark("font files read");
|
||||
|
||||
ScaledFonts.Clear();
|
||||
AddAll(io.Fonts, scale, RynthCore.Engine.UI.PanelTextScale.StepsInUse(), Fonts, ScaledFonts);
|
||||
|
|
@ -217,9 +208,8 @@ internal static unsafe class ImGuiFonts
|
|||
|
||||
double ms = (Stopwatch.GetTimestamp() - t0) * 1000.0 / Stopwatch.Frequency;
|
||||
RynthLog.UI($"ImGuiFonts: {CountBaked()} fonts queued at scale {scale:0.##} in {ms:0.0} ms " +
|
||||
$"(Cascadia Mono {(_cascadia != null ? "found" : "missing, using Consolas")}, symbols from the main fonts{(_symbolMerges > 0 ? $" (Segoe UI Symbol merged into {_symbolMerges})" : "")}, " +
|
||||
$"(Cascadia Mono {(_cascadia != null ? "found" : "missing, using Consolas")}, symbols {(_symbol != null ? "merged" : "missing")}, " +
|
||||
$"icons {(_phosphor != null ? $"{IconCount()} merged" : "missing")}).");
|
||||
Compatibility.MemoryUse.Mark("ImGui fonts queued");
|
||||
}
|
||||
|
||||
/// <summary>The font files and glyph ranges as native memory, made once (rebuilds reuse them). AC thread.</summary>
|
||||
|
|
@ -260,16 +250,6 @@ internal static unsafe class ImGuiFonts
|
|||
ImFontPtr[] target = baseSet;
|
||||
float factor = 1f;
|
||||
|
||||
// Whether each main font file lacks a symbol glyph (only then is Segoe UI Symbol merged in).
|
||||
_symbolMerges = 0;
|
||||
var needsSymbol = new Dictionary<byte[], bool>(ReferenceEqualityComparer.Instance);
|
||||
bool NeedsSymbol(byte[] b)
|
||||
{
|
||||
if (!needsSymbol.TryGetValue(b, out bool need))
|
||||
needsSymbol[b] = need = !HasGlyphs(b, SymbolCodepoints);
|
||||
return need;
|
||||
}
|
||||
|
||||
void Add(UiFont id, IntPtr data, byte[]? bytes, FaceMetrics metrics, float px)
|
||||
{
|
||||
if (data == IntPtr.Zero || bytes == null) return;
|
||||
|
|
@ -279,9 +259,8 @@ internal static unsafe class ImGuiFonts
|
|||
{
|
||||
cfg.FontDataOwnedByAtlas = false;
|
||||
target[(int)id] = atlas.AddFontFromMemoryTTF(data, bytes.Length, size, cfg, (IntPtr)mainRanges);
|
||||
if (symbol != IntPtr.Zero && _symbol != null && NeedsSymbol(bytes))
|
||||
if (symbol != IntPtr.Zero && _symbol != null)
|
||||
{
|
||||
_symbolMerges++;
|
||||
cfg.MergeMode = true;
|
||||
cfg.GlyphMinAdvanceX = 0;
|
||||
atlas.AddFontFromMemoryTTF(symbol, _symbol.Length, size, cfg, (IntPtr)symbolRanges);
|
||||
|
|
@ -555,63 +534,6 @@ internal static unsafe class ImGuiFonts
|
|||
|
||||
private static int IconCount() => new HashSet<char>(PhosphorIcons.Baked).Count;
|
||||
|
||||
/// <summary>
|
||||
/// True when the TrueType font has a glyph for every code point (its cmap, format 4:
|
||||
/// the Basic Multilingual Plane). False when unreadable, so the caller falls back to
|
||||
/// merging. Pure: tools\PanelTextScaleTests can drive it.
|
||||
/// </summary>
|
||||
internal static bool HasGlyphs(byte[]? ttf, ushort[] codepoints)
|
||||
{
|
||||
if (ttf == null || ttf.Length < 12) return false;
|
||||
try
|
||||
{
|
||||
static int U16(byte[] b, int at) => b[at] << 8 | b[at + 1];
|
||||
static int U32(byte[] b, int at) => b[at] << 24 | b[at + 1] << 16 | b[at + 2] << 8 | b[at + 3];
|
||||
int cmap = -1;
|
||||
int tables = U16(ttf, 4);
|
||||
for (int i = 0; i < tables; i++)
|
||||
{
|
||||
int rec = 12 + i * 16;
|
||||
if (U32(ttf, rec) == 0x636D6170) { cmap = U32(ttf, rec + 8); break; } // "cmap"
|
||||
}
|
||||
if (cmap < 0) return false;
|
||||
int subtables = U16(ttf, cmap + 2);
|
||||
for (int s = 0; s < subtables; s++)
|
||||
{
|
||||
int sub = cmap + U32(ttf, cmap + 4 + s * 8 + 4);
|
||||
if (U16(ttf, sub) != 4) continue;
|
||||
int segX2 = U16(ttf, sub + 6), ends = sub + 14, starts = ends + segX2 + 2;
|
||||
int deltas = starts + segX2, offsets = deltas + segX2;
|
||||
bool all = true;
|
||||
foreach (ushort cp in codepoints)
|
||||
{
|
||||
int glyph = 0;
|
||||
for (int k = 0; k < segX2 / 2; k++)
|
||||
{
|
||||
int end = U16(ttf, ends + k * 2), start = U16(ttf, starts + k * 2);
|
||||
if (cp > end) continue;
|
||||
if (cp < start) break;
|
||||
int delta = (short)U16(ttf, deltas + k * 2), ro = U16(ttf, offsets + k * 2);
|
||||
if (ro == 0) glyph = (cp + delta) & 0xFFFF;
|
||||
else
|
||||
{
|
||||
glyph = U16(ttf, offsets + k * 2 + ro + 2 * (cp - start));
|
||||
if (glyph != 0) glyph = (glyph + delta) & 0xFFFF;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (glyph == 0) { all = false; break; }
|
||||
}
|
||||
return all;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (IndexOutOfRangeException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A TrueType font's em as a fraction of the ImGui pixel size (ImGui sizes a
|
||||
/// font so hhea ascent - descent = the size) and half its cap height in em.
|
||||
|
|
|
|||
|
|
@ -77,7 +77,6 @@ internal static unsafe class ImGuiPopOuts
|
|||
public readonly List<InputMessage> Input = new(32);
|
||||
public readonly bool[] Buttons = new bool[3];
|
||||
public long LastFrameTicks;
|
||||
public int ThemeApplied; // RynthTheme.Version this context's style was coloured at
|
||||
public int HotFrames = HotFramesAfterInput;
|
||||
public bool WantTextInput, DropTextFocus;
|
||||
public bool Hovered;
|
||||
|
|
@ -485,7 +484,6 @@ internal static unsafe class ImGuiPopOuts
|
|||
|
||||
_current = pop;
|
||||
ImGuiTextFocus.BeginFrame();
|
||||
RynthTheme.RefreshStyle(ref pop.ThemeApplied); // this context's base style follows a theme change
|
||||
ImGuiNET.ImGui.NewFrame();
|
||||
started = true;
|
||||
if (pop.DropTextFocus)
|
||||
|
|
|
|||
|
|
@ -84,9 +84,8 @@ internal static class MonsterHud
|
|||
private static readonly uint BarBack = C(0xE00C1118), BarEdge = C(0xFF000000), Tick = C(0x70000000),
|
||||
Shine = C(0x38FFFFFF), Trail = C(0xFFF3E2A8), Gold = C(0xFFE6C766), GoldBright = C(0xFFFFD966),
|
||||
GoldGlow = C(0x55E6C766), NameText = C(0xFFF2E8DC), AttackerText = C(0xFFFF8A7A), Outline = C(0xE6000000),
|
||||
HpText = C(0xFFFFFFFF), DimText = C(0xFFB8C4D0), BadgeBack = C(0xD0101820), Leader = C(0x60FFFFFF),
|
||||
HoverEdge = C(0xC0FFFFFF), UnknownFill = C(0xFF5E8A6A), IconBack = C(0xD80B1219), OthersTint = C(0xFFFF8A7A);
|
||||
private static uint BadgeEdge => RynthTheme.Border;
|
||||
HpText = C(0xFFFFFFFF), DimText = C(0xFFB8C4D0), BadgeBack = C(0xD0101820), BadgeEdge = C(0xFF34587A),
|
||||
Leader = C(0x60FFFFFF), HoverEdge = C(0xC0FFFFFF), UnknownFill = C(0xFF5E8A6A), IconBack = C(0xD80B1219), OthersTint = C(0xFFFF8A7A);
|
||||
private static readonly Vector3 HpHigh = new(0x3F, 0xD0, 0x6A), HpMid = new(0xE8, 0xB3, 0x33), HpLow = new(0xE0, 0x4A, 0x4A);
|
||||
|
||||
// Element colours, shared by the "weak to" pill and the vulnerability icons.
|
||||
|
|
|
|||
|
|
@ -16,12 +16,8 @@ namespace RynthCore.Engine.ImGuiBackend.Hud;
|
|||
|
||||
internal static class MonsterHudSettingsUi
|
||||
{
|
||||
private static readonly uint ToggleOn = C(0xFF33FF33), ToggleOff = C(0xFF334455);
|
||||
private static uint Amber => RynthTheme.Highlight;
|
||||
private static uint TextDim => RynthTheme.Text;
|
||||
private static uint Mute => RynthTheme.TextMuted;
|
||||
private static uint BtnBord => RynthTheme.Border;
|
||||
private static uint BtnFill => RynthTheme.Button;
|
||||
private static readonly uint Amber = C(0xFFE8B333), TextDim = C(0xFFF2F7FC), Mute = C(0xFFB8C8D8),
|
||||
ToggleOn = C(0xFF33FF33), ToggleOff = C(0xFF334455), BtnBord = C(0xFF34587A), BtnFill = C(0xFF16283A);
|
||||
private static uint C(uint argb) => RynthTheme.Argb(argb);
|
||||
|
||||
private static bool Loading(float w)
|
||||
|
|
|
|||
|
|
@ -46,9 +46,8 @@ internal static class PlayerPlate
|
|||
private const float HeadHeight = 2.05f; // metres above the feet (human-sized characters)
|
||||
private const float FirstPersonDistance = 1.3f; // camera this close to the head = first person
|
||||
|
||||
private static readonly uint HealthCol = MonsterHud.C(0xFFE04A4A), ManaCol = MonsterHud.C(0xFF3F8FE8),
|
||||
NameCol = MonsterHud.C(0xFFF2E8DC), NumCol = MonsterHud.C(0xFFFFFFFF);
|
||||
private static uint StaminaCol => RynthTheme.Highlight;
|
||||
private static readonly uint HealthCol = MonsterHud.C(0xFFE04A4A), StaminaCol = MonsterHud.C(0xFFE8B333),
|
||||
ManaCol = MonsterHud.C(0xFF3F8FE8), NameCol = MonsterHud.C(0xFFF2E8DC), NumCol = MonsterHud.C(0xFFFFFFFF);
|
||||
|
||||
private struct BarState
|
||||
{
|
||||
|
|
@ -218,8 +217,7 @@ internal static class PlayerPlate
|
|||
Paint(dl, ref l, left, y);
|
||||
}
|
||||
|
||||
private static uint FrameCol => RynthTheme.WithAlpha(RynthTheme.Accent, 0xB0);
|
||||
private static uint FrameHot => RynthTheme.Accent;
|
||||
private static readonly uint FrameCol = MonsterHud.C(0xB026D9E6), FrameHot = MonsterHud.C(0xFF26D9E6);
|
||||
|
||||
/// <summary>Hover and a left-drag on the unlocked plate (the MonsterHud plate-click pattern).</summary>
|
||||
private static void Drag(bool unlocked, Vector2 r0, Vector2 r1, Vector2 centre)
|
||||
|
|
|
|||
|
|
@ -65,14 +65,11 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
new PanelSpec(new Vector2(460, 300), new Vector2(260, 140), Background: 0, EdgeToEdge: true, GripInBody: true),
|
||||
() => new ChatFace());
|
||||
|
||||
private static readonly uint TabAdd = RynthTheme.Argb(0xFF7AE09A), InputActive = RynthTheme.Argb(0xFFFFD700),
|
||||
SelBg = RynthTheme.Argb(0x663A6EA5), TellBg = RynthTheme.Argb(0xFF0E2E3A),
|
||||
private static readonly uint TabActive = RynthTheme.Argb(0xFF264C59), TabAdd = RynthTheme.Argb(0xFF7AE09A),
|
||||
InputBg = RynthTheme.Argb(0xFF0A121A), InputBorder = RynthTheme.Argb(0xFF264C59), InputActive = RynthTheme.Argb(0xFFFFD700),
|
||||
SelBg = RynthTheme.Argb(0x663A6EA5), FlashBg = RynthTheme.Argb(0xE0264C59), TellBg = RynthTheme.Argb(0xFF0E2E3A),
|
||||
TsColor = RynthTheme.Argb(0xFF6F8397), MentionBg = RynthTheme.Argb(0x33FFC857),
|
||||
BadgeBg = RynthTheme.Argb(0xFF1F6F7A), BadgeMention = RynthTheme.Argb(0xFFB8860B);
|
||||
private static uint TabActive => RynthTheme.AccentFill;
|
||||
private static uint InputBg => RynthTheme.BoxBg;
|
||||
private static uint InputBorder => RynthTheme.AccentFill;
|
||||
private static uint FlashBg => RynthTheme.WithAlpha(RynthTheme.AccentFill, 0xE0);
|
||||
private const float StickThreshold = 24f;
|
||||
|
||||
// Visible lines for the current tab + search, with wrapped heights; _lay
|
||||
|
|
@ -997,7 +994,7 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
ChatModel.SetHistoryLines(_historyEdit);
|
||||
_historyEdit = 0;
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("How many lines the chat keeps, all tabs together (default 2000).\n" +
|
||||
SafeImGui.SetItemTooltip("How many lines the chat keeps, all tabs together (default 2000).\n" +
|
||||
"About 2 MB of memory per 1000 lines. Lowering it drops the oldest lines.");
|
||||
ImGuiNET.ImGui.PopItemWidth();
|
||||
|
||||
|
|
@ -1028,7 +1025,7 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
ChatModel.LogEnabled = log;
|
||||
ChatModel.SaveSettings();
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("%%AppData%%\\RynthCore\\ChatLogs\\<character>.log"); // a format string: %% is a literal %
|
||||
SafeImGui.SetItemTooltip("%AppData%\\RynthCore\\ChatLogs\\<character>.log"); // SafeImGui doubles the % itself
|
||||
bool through = ChatModel.CtrlGatedClickThrough;
|
||||
if (ImGuiNET.ImGui.Checkbox("Click-through (hold Ctrl to interact)", ref through))
|
||||
ChatModel.SetCtrlGatedClickThrough(through);
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ internal sealed class ChatFiltersFace : IImGuiPanel
|
|||
new PanelSpec(new Vector2(600, 460), new Vector2(440, 260), EdgeToEdge: true, GripInBody: true),
|
||||
() => new ChatFiltersFace());
|
||||
|
||||
private static readonly uint CardBg = RynthTheme.Argb(0xFF0E1822), FocusBorder = RynthTheme.Argb(0xFFFFD700);
|
||||
private static uint AddBg => RynthTheme.AccentFill;
|
||||
private static readonly uint AddBg = RynthTheme.Argb(0xFF264C59), CardBg = RynthTheme.Argb(0xFF0E1822),
|
||||
FocusBorder = RynthTheme.Argb(0xFFFFD700);
|
||||
|
||||
private sealed class Buffers
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,15 +57,10 @@ internal sealed class DamageDetailFace : IImGuiPanel
|
|||
}
|
||||
|
||||
private static uint C(uint argb) => RynthTheme.Argb(argb);
|
||||
private static readonly uint Gold = C(0xFFFFD16A), ToggleOn = C(0xFF33CC66), ToggleOff = C(0xFF4D4D4D),
|
||||
BarBg = C(0xFF16222E), Good = C(0xFF33CC66), Bad = C(0xFFE05A5A), DeleteBg = C(0xFF6E1E1E),
|
||||
private static readonly uint Teal = C(0xFF26D9E6), Gold = C(0xFFFFD16A), Dim = C(0xFFC8D4E0), White = C(0xFFF2F7FC),
|
||||
EntryBg = C(0xFF16283A), EntryBorder = C(0xFF34587A), ToggleOn = C(0xFF33CC66), ToggleOff = C(0xFF4D4D4D),
|
||||
BarBg = C(0xFF16222E), Good = C(0xFF33CC66), Mid = C(0xFFE8B333), Bad = C(0xFFE05A5A), DeleteBg = C(0xFF6E1E1E),
|
||||
DeleteBorder = C(0xFFFF8A8A);
|
||||
private static uint Teal => RynthTheme.Accent;
|
||||
private static uint Dim => RynthTheme.MuteAlt;
|
||||
private static uint White => RynthTheme.Text;
|
||||
private static uint EntryBg => RynthTheme.Button;
|
||||
private static uint EntryBorder => RynthTheme.Border;
|
||||
private static uint Mid => RynthTheme.Highlight;
|
||||
|
||||
private MonsterDetail? _detail;
|
||||
private long _seenVersion = -1, _seenRulesVersion = -1;
|
||||
|
|
@ -409,6 +404,17 @@ internal sealed class DamageDetailFace : IImGuiPanel
|
|||
pick => DamageCommands.EditRule(name, r => r.ExVuln = pick),
|
||||
"A vulnerability of another element, on top of Vuln (which follows the attack's element).");
|
||||
|
||||
// Melee/missile attack power against it
|
||||
string power = string.IsNullOrEmpty(view.AttackPower) ? "Default" : view.AttackPower;
|
||||
Combo("Power", "##power", DamageCommands.AttackPowerModes, power,
|
||||
pick => DamageCommands.EditRule(name, r => r.AttackPower = pick),
|
||||
(isDefault
|
||||
? "Melee/missile attack power for every monster without its own. Default = the Power settings (Melee Combat).\n"
|
||||
: "Melee/missile attack power against the monsters it covers. Default = the DEFAULT line's.\n") +
|
||||
"High = 100%. Reckless = 80% (needs Recklessness trained, else 100%).\n" +
|
||||
"Variable = a new random power each attack, between Variable Min and Max (Settings).\n" +
|
||||
"Reckless + Variable = random, kept inside the Recklessness band (20-80%).");
|
||||
|
||||
// Match expression (Default never matches by name, so it has none)
|
||||
if (!isDefault)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,17 +45,11 @@ internal sealed class DamageFace : IImGuiPanel
|
|||
() => new DamageFace());
|
||||
|
||||
// ── Palette (MonsterDamagePanel's, a little brighter) ───────────────
|
||||
private static readonly uint Gold = C(0xFFFFD16A), HeaderBg = C(0xFF121C26), PanelBg = C(0xF0081018),
|
||||
RowBg = C(0x40203040), PickerBg = C(0xFF0A141E), SearchBg = C(0xFF16222E), ToggleOn = C(0xFF33CC66),
|
||||
ToggleOff = C(0xFF4D4D4D), DeleteRed = C(0xFFFF8A8A), FilterBg = C(0xFF203A52), NearbyBg = C(0x3833CC66),
|
||||
NearbyBar = C(0xFF33CC66), ResetBg = C(0xFF5A2020), ResetBorder = C(0xFFFF8A8A), ClearBg = C(0xFF6E1E1E);
|
||||
private static uint Teal => RynthTheme.Accent;
|
||||
private static uint Dim => RynthTheme.MuteAlt;
|
||||
private static uint White => RynthTheme.Text;
|
||||
private static uint PickSel => RynthTheme.Selected;
|
||||
private static uint EntryBg => RynthTheme.Button;
|
||||
private static uint EntryBorder => RynthTheme.Border;
|
||||
private static uint TargetBg => RynthTheme.WithAlpha(RynthTheme.Accent, 0x50);
|
||||
private static readonly uint Teal = C(0xFF26D9E6), Gold = C(0xFFFFD16A), Dim = C(0xFFC8D4E0),
|
||||
White = C(0xFFF2F7FC), HeaderBg = C(0xFF121C26), PanelBg = C(0xF0081018), RowBg = C(0x40203040),
|
||||
PickerBg = C(0xFF0A141E), PickSel = C(0xFF1A2E42), EntryBg = C(0xFF16283A), EntryBorder = C(0xFF34587A),
|
||||
SearchBg = C(0xFF16222E), ToggleOn = C(0xFF33CC66), ToggleOff = C(0xFF4D4D4D), DeleteRed = C(0xFFFF8A8A),
|
||||
FilterBg = C(0xFF203A52), TargetBg = C(0x5026D9E6), NearbyBg = C(0x3833CC66), NearbyBar = C(0xFF33CC66), ResetBg = C(0xFF5A2020), ResetBorder = C(0xFFFF8A8A), ClearBg = C(0xFF6E1E1E);
|
||||
private static uint C(uint argb) => RynthTheme.Argb(argb);
|
||||
|
||||
// Column widths (the Avalonia grid's) and their left edges.
|
||||
|
|
@ -527,7 +521,7 @@ internal sealed class DamageFace : IImGuiPanel
|
|||
if (all == null || count == 0)
|
||||
{
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 3));
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), all == null
|
||||
SafeImGui.TextColored(RynthTheme.Vec(0xFFC8D4E0), all == null
|
||||
? " Monster rules not loaded yet." : " No name rules yet: add one below.");
|
||||
}
|
||||
else
|
||||
|
|
@ -714,7 +708,7 @@ internal sealed class DamageFace : IImGuiPanel
|
|||
bool filtering = _filterWid != 0 || _searchText.Length > 0;
|
||||
bool anyData = _view.Rows.Exists(r => !r.IsDefault);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), anyData && filtering
|
||||
SafeImGui.TextColored(RynthTheme.Vec(0xFFC8D4E0), anyData && filtering
|
||||
? " No monsters match the current filter."
|
||||
: " No monsters yet: fight some and they show up here.");
|
||||
}
|
||||
|
|
@ -1012,16 +1006,16 @@ internal sealed class DamageFace : IImGuiPanel
|
|||
Rule? view = RuleFor(name, out bool custom);
|
||||
bool isDefault = name.Equals("Default", StringComparison.OrdinalIgnoreCase);
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11));
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.Accent), "Debuffs · " + name);
|
||||
SafeImGui.TextColored(RynthTheme.Vec(0xFF26D9E6), "Debuffs · " + name);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
if (view == null)
|
||||
{
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), "Monster rules not loaded yet.");
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D4E0), "Monster rules not loaded yet.");
|
||||
ImGuiNET.ImGui.EndPopup();
|
||||
return;
|
||||
}
|
||||
ImGuiNET.ImGui.PushTextWrapPos(0);
|
||||
SafeImGui.TextColored((custom || isDefault ? RynthTheme.Vec(0xFFFFD16A) : RynthTheme.VecOf(RynthTheme.MuteAlt)),
|
||||
SafeImGui.TextColored(RynthTheme.Vec(custom || isDefault ? 0xFFFFD16A : 0xFFC8D4E0),
|
||||
isDefault ? "Every monster set to Default uses these." : custom ? "This monster's own debuffs." : "Following Default: a change here gives it its own.");
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
|
||||
|
|
@ -1037,7 +1031,7 @@ internal sealed class DamageFace : IImGuiPanel
|
|||
SafeImGui.SetItemTooltip(tip);
|
||||
}
|
||||
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), "Extra Vuln");
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D4E0), "Extra Vuln");
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
string ex = string.IsNullOrEmpty(view.ExVuln) ? "None" : view.ExVuln;
|
||||
ImGuiNET.ImGui.SetNextItemWidth(ImGuiNET.ImGui.CalcTextSize("Lightning").X + 40);
|
||||
|
|
@ -1054,7 +1048,7 @@ internal sealed class DamageFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.SetItemTooltip("A vulnerability of another element, on top of Vuln (which follows the attack's element).");
|
||||
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), "Your own (comma separated):");
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D4E0), "Your own (comma separated):");
|
||||
ImGuiNET.ImGui.SetNextItemWidth(-1);
|
||||
bool enter = ImGuiNET.ImGui.InputText("##db_custom", _customBuf, (uint)_customBuf.Length, ImGuiInputTextFlags.EnterReturnsTrue);
|
||||
if (enter || ImGuiNET.ImGui.IsItemDeactivatedAfterEdit())
|
||||
|
|
@ -1322,9 +1316,9 @@ internal sealed class DamageFace : IImGuiPanel
|
|||
if (ropen)
|
||||
{
|
||||
ImGuiNET.ImGui.PushTextWrapPos(0);
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.Text), "Remove " + _removeName + "?");
|
||||
SafeImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC), "Remove " + _removeName + "?");
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Text),
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC),
|
||||
"Its learned numbers and your settings for it (weapon, offhand, pet, HP) are deleted. It comes back if you meet it again.");
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 6));
|
||||
|
|
@ -1360,9 +1354,9 @@ internal sealed class DamageFace : IImGuiPanel
|
|||
if (open)
|
||||
{
|
||||
ImGuiNET.ImGui.PushTextWrapPos(0);
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Text), "Reset ALL learned damage statistics?");
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC), "Reset ALL learned damage statistics?");
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Text),
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC),
|
||||
"Monster names and your settings (manual HP, weapon/offhand picks, debuffs) are KEPT — only the learned damage, crit, casts-to-kill, kills and HP are cleared. This cannot be undone.");
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 6));
|
||||
|
|
|
|||
32
src/RynthCore.Engine/ImGui/Panels/DamageTypeColors.cs
Normal file
32
src/RynthCore.Engine/ImGui/Panels/DamageTypeColors.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/DamageTypeColors.cs
|
||||
// Text colour per damage type, from UB-ILT's LeaftideDamageTypeVtColors (the
|
||||
// Virindi Tank / Leaftide label palette its Items, Spell and Pets tabs share).
|
||||
// RynthAi's Pets roster uses the same values (IltHub\IltDamageTypeTint.cs);
|
||||
// keep the two tables in step. Colours are the panels' ABGR (RynthTheme.Argb).
|
||||
// ============================================================================
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
internal static class DamageTypeColors
|
||||
{
|
||||
private static uint C(uint argb) => RynthTheme.Argb(argb);
|
||||
|
||||
public static readonly uint Slash = C(0xFFFFB478), Pierce = C(0xFFF0C88C), Bludgeon = C(0xFFDCBE8C),
|
||||
Cold = C(0xFFA0D2FF), Fire = C(0xFFFF8246), Acid = C(0xFFA0FF8C), Lightning = C(0xFFFFF078),
|
||||
Nether = C(0xFFC8A0FF);
|
||||
|
||||
/// <summary>Colour for an element name as the panels write it; <paramref name="fallback"/> for anything else (Shield, Auto, None).</summary>
|
||||
public static uint For(string? element, uint fallback) => element switch
|
||||
{
|
||||
"Slash" or "Slashing" => Slash,
|
||||
"Pierce" or "Piercing" => Pierce,
|
||||
"Bludgeon" or "Bludgeoning" => Bludgeon,
|
||||
"Cold" or "Frost" => Cold,
|
||||
"Fire" => Fire,
|
||||
"Acid" => Acid,
|
||||
"Lightning" or "Electric" or "Storm" => Lightning,
|
||||
"Nether" => Nether,
|
||||
_ => fallback,
|
||||
};
|
||||
}
|
||||
|
|
@ -1,36 +1,25 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/DashboardDrawers.cs
|
||||
// The RynthAi dashboard's slide-out drawers (Tom 2026-10-05: drawers on the
|
||||
// dashboard's edges; only the vitals / target bars stay at its bottom). One
|
||||
// tab per drawer, stacked down the dashboard's left or right edge; a click
|
||||
// slides that drawer's panel out on its tab's side. One drawer is open per
|
||||
// side, so a left and a right drawer can be out together.
|
||||
// The RynthAi dashboard's slide-out drawers (Tom 2026-10-05: every drawer on
|
||||
// the dashboard's left edge; only the vitals / target bars stay at its
|
||||
// bottom). One tab per drawer, stacked down the left edge; a click slides
|
||||
// that drawer's panel out to the left (to the right when the dashboard sits
|
||||
// too close to the screen's left edge for the widest drawer). One drawer is
|
||||
// open at a time: opening one closes the other, so the panels never stack
|
||||
// and the tabs never jump.
|
||||
//
|
||||
// Sides (2026-10-14): each drawer starts on a side (StartsRight) and a
|
||||
// dashboard drawer can be moved to the other one from its tab's right-click
|
||||
// (saved with the dashboard's state). The tabs never switch sides on their
|
||||
// own any more; a panel with no room on its side stays on the screen over
|
||||
// the dashboard instead.
|
||||
// The mechanics live here (tabs, slide, side, placement, the one window);
|
||||
// each drawer only draws its panel (DashboardDrawer.DrawPanel) and says how
|
||||
// big it is. Drawers today: Ranges (RangesSlideOut.cs), Loaded files,
|
||||
// Patrol and Mini Remote (RynthAiFace.Drawers.cs).
|
||||
//
|
||||
// The look: a closed tab is a button with its drawer's icon that peeks out a
|
||||
// little on hover; the open tab joins its panel (same background, a teal
|
||||
// edge, an accent bar against the dashboard), and the panel has a teal
|
||||
// outline. Panels slide out with an ease-out.
|
||||
//
|
||||
// The mechanics live here (tabs, slide, side, placement, the windows); each
|
||||
// drawer only draws its panel (DashboardDrawer.DrawPanel) and says how big it
|
||||
// is. Drawers today: Ranges (RangesSlideOut.cs), Loaded files, Patrol, Mini
|
||||
// Remote (RynthAiFace.Drawers.cs) and My settings (QuickSettingsDrawer.cs);
|
||||
// RynthChat's Channels (ChatFace.cs) uses the same host.
|
||||
//
|
||||
// One top-level ImGui window per side, begun from inside the dashboard's Draw
|
||||
// and placed against the dashboard's window every frame, so the drawers
|
||||
// follow the dashboard (and go away with it). Each drawer's open/closed is
|
||||
// saved with the dashboard's state (RynthAiDashboardState). Popped out the
|
||||
// tabs are hidden: a popped-out dashboard is its own small window and the
|
||||
// area around it lets clicks through to the game, so a drawer beside it
|
||||
// couldn't be used (the dashboard falls back to its inline files block and
|
||||
// patrol popup).
|
||||
// A top-level ImGui window of its own, begun from inside the dashboard's Draw
|
||||
// and placed against the dashboard's window every frame, so it follows the
|
||||
// dashboard (and goes away with it). Each drawer's open/closed is saved with
|
||||
// the dashboard's state (RynthAiDashboardState). Popped out the tabs are
|
||||
// hidden: a popped-out dashboard is its own small window and the area around
|
||||
// it lets clicks through to the game, so a drawer beside it couldn't be used
|
||||
// (the dashboard falls back to its inline files block and patrol popup).
|
||||
//
|
||||
// AC thread only (inside the dashboard's Draw).
|
||||
// ============================================================================
|
||||
|
|
@ -42,7 +31,7 @@ using RynthCore.Engine.UI;
|
|||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
/// <summary>One drawer on the dashboard's edge: its tab's look and its panel.</summary>
|
||||
/// <summary>One drawer on the dashboard's left edge: its tab's look and its panel.</summary>
|
||||
internal abstract class DashboardDrawer
|
||||
{
|
||||
/// <summary>Set by the host: close this drawer from inside the panel (its close button).</summary>
|
||||
|
|
@ -54,7 +43,7 @@ internal abstract class DashboardDrawer
|
|||
public abstract string Icon { get; }
|
||||
/// <summary>Lower-case name for "Hide the …" tooltips.</summary>
|
||||
public abstract string Name { get; }
|
||||
/// <summary>The closed tab's tooltip; <paramref name="right"/>: the drawer is on the right.</summary>
|
||||
/// <summary>The closed tab's tooltip; <paramref name="right"/>: it slides out to the right.</summary>
|
||||
public abstract string TabTooltip(bool right);
|
||||
|
||||
/// <summary>Panel size in pixels at text scale <paramref name="k"/>.</summary>
|
||||
|
|
@ -71,22 +60,10 @@ internal abstract class DashboardDrawer
|
|||
public abstract bool SavedOpen { get; }
|
||||
public abstract void SaveOpen(bool open);
|
||||
|
||||
/// <summary>The side the drawer starts on (false: left).</summary>
|
||||
public virtual bool StartsRight => false;
|
||||
/// <summary>The tab's right-click can move it to the other side (and the move is saved).</summary>
|
||||
public virtual bool CanMove => false;
|
||||
/// <summary>Moved to the side it doesn't start on.</summary>
|
||||
public virtual bool Moved => false;
|
||||
public virtual void SaveMoved(bool moved) { }
|
||||
|
||||
/// <summary>The side it is on now.</summary>
|
||||
public bool OnRight => StartsRight != Moved;
|
||||
|
||||
private string? _tabId, _hideTip, _sideMenuId;
|
||||
private string? _tabId, _hideTip;
|
||||
/// <summary>The tab's ImGui id and open tooltip (built once).</summary>
|
||||
internal string TabId => _tabId ??= "##drawer_tab_" + Key;
|
||||
internal string HideTip => _hideTip ??= "Hide the " + Name + ".";
|
||||
internal string SideMenuId => _sideMenuId ??= "##drawer_side_" + Key;
|
||||
|
||||
protected void Close() => Host?.Close(this);
|
||||
|
||||
|
|
@ -100,11 +77,8 @@ internal abstract class DashboardDrawer
|
|||
|
||||
// ── The shared panel frame: background, title row (icon + TITLE + note | close) ──
|
||||
|
||||
protected static uint DTeal => RynthTheme.Accent;
|
||||
protected static uint DMute => RynthTheme.TextMuted;
|
||||
protected static uint DWhite => RynthTheme.Text;
|
||||
protected static uint DBtnFill => RynthTheme.Button;
|
||||
protected static uint DBtnBord => RynthTheme.Border;
|
||||
protected static readonly uint DTeal = RynthTheme.Argb(0xFF26D9E6), DMute = RynthTheme.Argb(0xFFB8C8D8),
|
||||
DWhite = RynthTheme.Argb(0xFFF2F7FC), DBtnFill = RynthTheme.Argb(0xFF16283A), DBtnBord = RynthTheme.Argb(0xFF34587A);
|
||||
protected const float Pad = 6, TitleH = 18;
|
||||
|
||||
/// <summary>Paints the panel's background and title row; returns the y under the title (pixels).</summary>
|
||||
|
|
@ -112,7 +86,7 @@ internal abstract class DashboardDrawer
|
|||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
dl.AddRectFilled(origin, origin + new Vector2(panelW, panelH), RynthTheme.RynthAiBackground, RynthTheme.RynthAiRounding);
|
||||
dl.AddRect(origin, origin + new Vector2(panelW, panelH), DTeal, RynthTheme.RynthAiRounding);
|
||||
dl.AddRect(origin, origin + new Vector2(panelW, panelH), RynthTheme.RynthAiBorder, RynthTheme.RynthAiRounding);
|
||||
|
||||
float x = origin.X + Pad * k, w = panelW - 2 * Pad * k, y = origin.Y + Pad * k;
|
||||
ImFontPtr f11 = ImGuiFonts.Get(UiFont.Dash11), f9 = ImGuiFonts.Get(UiFont.Dash9);
|
||||
|
|
@ -134,37 +108,19 @@ internal abstract class DashboardDrawer
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>A RynthAi dashboard drawer: movable to the other side, the side saved with the dashboard's state.</summary>
|
||||
internal abstract class RynthAiDrawer : DashboardDrawer
|
||||
{
|
||||
public override bool CanMove => true;
|
||||
public override bool Moved => RynthAiDashboardState.DrawerMoved(Key);
|
||||
public override void SaveMoved(bool moved) => RynthAiDashboardState.SetDrawerMoved(Key, moved);
|
||||
}
|
||||
|
||||
/// <summary>The tabs and the open drawers beside the RynthAi dashboard (one open per side).</summary>
|
||||
/// <summary>The tabs and the one open drawer beside the RynthAi dashboard.</summary>
|
||||
internal sealed class DashboardDrawers
|
||||
{
|
||||
private readonly string[] _windowIds; // left, right ("##rynthai_drawers" for the dashboard; the chat has its own)
|
||||
private const float SlideSeconds = 0.16f;
|
||||
private readonly string WindowId; // "##rynthai_drawers" for the dashboard; the chat has its own
|
||||
private const float SlideSeconds = 0.14f;
|
||||
|
||||
private static uint Teal => RynthTheme.Accent;
|
||||
private static uint Mute => RynthTheme.TextMuted;
|
||||
private static uint White => RynthTheme.Text;
|
||||
private static uint BtnFill => RynthTheme.Button;
|
||||
private static uint BtnBord => RynthTheme.Border;
|
||||
private static uint ShellBg => RynthTheme.Background;
|
||||
private static readonly uint Teal = RynthTheme.Argb(0xFF26D9E6), Mute = RynthTheme.Argb(0xFFB8C8D8),
|
||||
White = RynthTheme.Argb(0xFFF2F7FC), BtnFill = RynthTheme.Argb(0xFF16283A), BtnBord = RynthTheme.Argb(0xFF34587A);
|
||||
|
||||
private readonly DashboardDrawer[] _drawers;
|
||||
|
||||
/// <summary>One edge's drawers: which is open, which draws, how far it has slid.</summary>
|
||||
private sealed class Side
|
||||
{
|
||||
public int Open = -1; // the drawer open (or opening); -1 none
|
||||
public int Shown = -1; // the drawer whose panel draws (a closing one until it has slid in)
|
||||
public float T; // slide position of Shown, 0 closed .. 1 open
|
||||
}
|
||||
private readonly Side[] _sides = { new(), new() };
|
||||
private int _open = -1; // the drawer open (or opening); -1 none
|
||||
private int _shown = -1; // the drawer whose panel draws (a closing one until it has slid in)
|
||||
private float _t; // slide position of _shown, 0 closed .. 1 open
|
||||
private bool _loaded;
|
||||
|
||||
public DashboardDrawers(params DashboardDrawer[] drawers) : this("##rynthai_drawers", drawers) { }
|
||||
|
|
@ -172,20 +128,14 @@ internal sealed class DashboardDrawers
|
|||
/// <summary>A drawer set beside another panel (RynthChat's channels): its own window id.</summary>
|
||||
public DashboardDrawers(string windowId, params DashboardDrawer[] drawers)
|
||||
{
|
||||
_windowIds = new[] { windowId, windowId + "_right" };
|
||||
WindowId = windowId;
|
||||
_drawers = drawers;
|
||||
foreach (DashboardDrawer d in drawers) d.Host = this;
|
||||
}
|
||||
|
||||
private Side SideOf(DashboardDrawer d) => _sides[d.OnRight ? 1 : 0];
|
||||
public bool IsOpen(DashboardDrawer d) => _open >= 0 && _drawers[_open] == d;
|
||||
|
||||
public bool IsOpen(DashboardDrawer d)
|
||||
{
|
||||
Side s = SideOf(d);
|
||||
return s.Open >= 0 && _drawers[s.Open] == d;
|
||||
}
|
||||
|
||||
/// <summary>Opens <paramref name="d"/> (closing the one open on its side), or closes it when it is open.</summary>
|
||||
/// <summary>Opens <paramref name="d"/> (closing the open one), or closes it when it is the open one.</summary>
|
||||
public void Toggle(DashboardDrawer d)
|
||||
{
|
||||
if (IsOpen(d)) Close(d);
|
||||
|
|
@ -196,41 +146,25 @@ internal sealed class DashboardDrawers
|
|||
{
|
||||
EnsureLoaded();
|
||||
int i = Array.IndexOf(_drawers, d);
|
||||
Side s = SideOf(d);
|
||||
if (i < 0 || i == s.Open) return;
|
||||
if (s.Open >= 0) _drawers[s.Open].SaveOpen(false);
|
||||
s.Open = i;
|
||||
if (i < 0 || i == _open) return;
|
||||
if (_open >= 0) _drawers[_open].SaveOpen(false);
|
||||
_open = i;
|
||||
d.SaveOpen(true);
|
||||
if (s.Shown != i)
|
||||
if (_shown != i)
|
||||
{
|
||||
// Another drawer was out on this side (or sliding in): this one slides out from closed.
|
||||
s.Shown = i;
|
||||
s.T = 0f;
|
||||
// Another drawer was out (or sliding in): this one slides out from closed.
|
||||
_shown = i;
|
||||
_t = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void Close(DashboardDrawer d)
|
||||
{
|
||||
if (!IsOpen(d)) return;
|
||||
SideOf(d).Open = -1;
|
||||
_open = -1;
|
||||
d.SaveOpen(false);
|
||||
}
|
||||
|
||||
/// <summary>Moves <paramref name="d"/> to the other side; an open drawer opens again there.</summary>
|
||||
public void Move(DashboardDrawer d)
|
||||
{
|
||||
if (!d.CanMove) return;
|
||||
EnsureLoaded();
|
||||
bool wasOpen = IsOpen(d);
|
||||
int i = Array.IndexOf(_drawers, d);
|
||||
Side from = SideOf(d);
|
||||
if (wasOpen) from.Open = -1;
|
||||
if (from.Shown == i) { from.Shown = -1; from.T = 0f; }
|
||||
d.Update(false);
|
||||
d.SaveMoved(!d.Moved);
|
||||
if (wasOpen) { d.SaveOpen(false); Open(d); }
|
||||
}
|
||||
|
||||
/// <summary>The dashboard closed: every drawer drops its subscriptions. AC thread.</summary>
|
||||
public void Detach()
|
||||
{
|
||||
|
|
@ -241,18 +175,19 @@ internal sealed class DashboardDrawers
|
|||
{
|
||||
if (_loaded) return;
|
||||
_loaded = true;
|
||||
// The first drawer saved open on each side wins (one per side); any other saved open is closed.
|
||||
// The first drawer saved open wins (one at a time); any other saved open is closed.
|
||||
for (int i = 0; i < _drawers.Length; i++)
|
||||
{
|
||||
if (!_drawers[i].SavedOpen) continue;
|
||||
Side s = SideOf(_drawers[i]);
|
||||
if (s.Open < 0) { s.Open = i; s.Shown = i; s.T = 1f; }
|
||||
if (_open < 0) _open = i;
|
||||
else _drawers[i].SaveOpen(false);
|
||||
}
|
||||
_shown = _open;
|
||||
_t = _open >= 0 ? 1f : 0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the tabs and the open drawers. Call at the end of the dashboard's Draw, inside its
|
||||
/// Draws the tabs and the open drawer. Call at the end of the dashboard's Draw, inside its
|
||||
/// body child (whose rect is the dashboard's: the face is chromeless).
|
||||
/// </summary>
|
||||
public void Draw()
|
||||
|
|
@ -265,51 +200,42 @@ internal sealed class DashboardDrawers
|
|||
}
|
||||
EnsureLoaded();
|
||||
|
||||
Vector2 dashPos = ImGuiNET.ImGui.GetWindowPos(), dashSize = ImGuiNET.ImGui.GetWindowSize();
|
||||
float k = MathF.Max(1f, ImGuiFonts.Get(UiFont.Dash11).FontSize / 11f);
|
||||
DrawSide(0, dashPos, dashSize, k);
|
||||
DrawSide(1, dashPos, dashSize, k);
|
||||
}
|
||||
|
||||
private void DrawSide(int sideIdx, Vector2 dashPos, Vector2 dashSize, float k)
|
||||
{
|
||||
bool right = sideIdx == 1;
|
||||
Side side = _sides[sideIdx];
|
||||
int n = 0;
|
||||
foreach (DashboardDrawer d in _drawers) if (d.OnRight == right) n++;
|
||||
if (n == 0) { side.Open = side.Shown = -1; return; }
|
||||
|
||||
// Slide.
|
||||
float target = side.Open >= 0 && side.Open == side.Shown ? 1f : 0f;
|
||||
if (side.T != target)
|
||||
float target = _open >= 0 && _open == _shown ? 1f : 0f;
|
||||
if (_t != target)
|
||||
{
|
||||
float step = ImGuiNET.ImGui.GetIO().DeltaTime / SlideSeconds;
|
||||
if (step <= 0 || float.IsNaN(step)) step = 1f;
|
||||
side.T = target > side.T ? MathF.Min(1f, side.T + step) : MathF.Max(0f, side.T - step);
|
||||
_t = target > _t ? MathF.Min(1f, _t + step) : MathF.Max(0f, _t - step);
|
||||
}
|
||||
if (side.T <= 0f && side.Open < 0) side.Shown = -1;
|
||||
float u = 1f - side.T;
|
||||
float ease = 1f - u * u * u; // ease-out: quick to start, settling at the end
|
||||
bool showing = side.Shown >= 0 && ease > 0.001f;
|
||||
for (int i = 0; i < _drawers.Length; i++)
|
||||
if (_drawers[i].OnRight == right) _drawers[i].Update(showing && i == side.Shown);
|
||||
if (_t <= 0f && _open < 0) _shown = -1;
|
||||
float ease = _t * _t * (3f - 2f * _t);
|
||||
bool showing = _shown >= 0 && ease > 0.001f;
|
||||
for (int i = 0; i < _drawers.Length; i++) _drawers[i].Update(showing && i == _shown);
|
||||
|
||||
// Geometry (pixels; k follows the dashboard's text size).
|
||||
Vector2 dashPos = ImGuiNET.ImGui.GetWindowPos(), dashSize = ImGuiNET.ImGui.GetWindowSize();
|
||||
Vector2 display = ImGuiNET.ImGui.GetIO().DisplaySize;
|
||||
float tabW = 17 * k, tabGap = 3 * k, tabTop = 4 * k, peek = 3 * k;
|
||||
float k = MathF.Max(1f, ImGuiFonts.Get(UiFont.Dash11).FontSize / 11f);
|
||||
int n = _drawers.Length;
|
||||
float tabW = 14 * k, tabGap = 3 * k, tabTop = 4 * k;
|
||||
// Tabs share the dashboard's height (40 tall at most, 20 at least: they may run past a minimized dashboard).
|
||||
float tabH = MathF.Max(20 * k, MathF.Min(40 * k, (dashSize.Y - 2 * tabTop - (n - 1) * tabGap) / n));
|
||||
float tabH = MathF.Max(20 * k, MathF.Min(40 * k, (dashSize.Y - 2 * tabTop - (n - 1) * tabGap) / Math.Max(1, n)));
|
||||
float tabsH = n * tabH + (n - 1) * tabGap;
|
||||
float panelW = showing ? _drawers[side.Shown].Width(k) : 0;
|
||||
float panelH = showing ? _drawers[side.Shown].Height(k) : 0;
|
||||
float shown = showing ? panelW * ease : 0;
|
||||
float outer = MathF.Max(shown, peek); // room beyond the tabs: the panel, or a hovered tab's peek
|
||||
|
||||
float widest = 0;
|
||||
foreach (DashboardDrawer d in _drawers) widest = MathF.Max(widest, d.Width(k));
|
||||
float panelW = showing ? _drawers[_shown].Width(k) : widest;
|
||||
float panelH = showing ? _drawers[_shown].Height(k) : 0;
|
||||
float dashRight = dashPos.X + dashSize.X;
|
||||
// Left unless there's no room there for the widest drawer and more on the right (so the tabs never switch sides
|
||||
// as drawers open and close).
|
||||
bool right = dashPos.X < tabW + widest && display.X - dashRight > dashPos.X;
|
||||
float shown = showing ? panelW * ease : 0;
|
||||
|
||||
float winX = right ? dashRight : dashPos.X - tabW - shown;
|
||||
float winW = tabW + shown;
|
||||
float tabX = right ? dashRight : dashPos.X - tabW;
|
||||
float winX = right ? tabX : tabX - outer;
|
||||
float winW = tabW + outer;
|
||||
// No room on this side (the dashboard against the screen's edge): stay on the screen, over the dashboard.
|
||||
// Neither side has room (a very wide dashboard): keep it on the screen, over the dashboard.
|
||||
float shift = 0;
|
||||
if (winX < 0) shift = -winX;
|
||||
else if (display.X > 1 && winX + winW > display.X) shift = display.X - (winX + winW);
|
||||
|
|
@ -329,40 +255,36 @@ internal sealed class DashboardDrawers
|
|||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0f);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0f);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowMinSize, Vector2.One);
|
||||
bool visible = ImGuiNET.ImGui.Begin(_windowIds[sideIdx], WindowFlags);
|
||||
bool visible = ImGuiNET.ImGui.Begin(WindowId, WindowFlags);
|
||||
ImGuiNET.ImGui.PopStyleVar(4);
|
||||
try
|
||||
{
|
||||
if (!visible) return;
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Dash10));
|
||||
try
|
||||
if (visible)
|
||||
{
|
||||
if (showing)
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Dash10));
|
||||
try
|
||||
{
|
||||
// The panel's visible part; its content slides with the open edge.
|
||||
float visX0 = right ? tabX + tabW : tabX - shown;
|
||||
float contentX = right ? tabX + tabW + shown - panelW : tabX - shown;
|
||||
Vector2 vMin = new(visX0, winY), vMax = new(visX0 + shown, winY + panelH);
|
||||
DashboardDrawer d = _drawers[side.Shown];
|
||||
ImGuiNET.ImGui.PushClipRect(vMin, vMax, true);
|
||||
ImGuiNET.ImGui.PushID(d.Key);
|
||||
try { d.DrawPanel(new Vector2(contentX, winY), panelW, panelH, k); }
|
||||
finally
|
||||
if (showing)
|
||||
{
|
||||
ImGuiNET.ImGui.PopID();
|
||||
ImGuiNET.ImGui.PopClipRect();
|
||||
// The panel's visible part; its content slides with the open edge.
|
||||
float visX0 = right ? tabX + tabW : winX;
|
||||
float contentX = right ? tabX + tabW + shown - panelW : winX;
|
||||
Vector2 vMin = new(visX0, winY), vMax = new(visX0 + shown, winY + panelH);
|
||||
DashboardDrawer d = _drawers[_shown];
|
||||
ImGuiNET.ImGui.PushClipRect(vMin, vMax, true);
|
||||
ImGuiNET.ImGui.PushID(d.Key);
|
||||
try { d.DrawPanel(new Vector2(contentX, winY), panelW, panelH, k); }
|
||||
finally
|
||||
{
|
||||
ImGuiNET.ImGui.PopID();
|
||||
ImGuiNET.ImGui.PopClipRect();
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < n; i++)
|
||||
DrawTab(_drawers[i], new Vector2(tabX, tabY + i * (tabH + tabGap)), new Vector2(tabW, tabH), right, k);
|
||||
}
|
||||
int slot = 0;
|
||||
for (int i = 0; i < _drawers.Length; i++)
|
||||
{
|
||||
if (_drawers[i].OnRight != right) continue;
|
||||
DrawTab(_drawers[i], new Vector2(tabX, tabY + slot * (tabH + tabGap)), new Vector2(tabW, tabH), right,
|
||||
joined: showing && i == side.Shown && side.Open == i, canPeek: !showing, k);
|
||||
slot++;
|
||||
}
|
||||
finally { ImGuiNET.ImGui.PopFont(); }
|
||||
}
|
||||
finally { ImGuiNET.ImGui.PopFont(); }
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
@ -375,66 +297,27 @@ internal sealed class DashboardDrawers
|
|||
| ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoDocking
|
||||
| ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoNav;
|
||||
|
||||
/// <param name="joined">The open drawer's tab, drawn as part of its panel.</param>
|
||||
/// <param name="canPeek">No panel is out on this side, so a hovered tab may peek out.</param>
|
||||
private void DrawTab(DashboardDrawer d, Vector2 pos, Vector2 size, bool right, bool joined, bool canPeek, float k)
|
||||
private void DrawTab(DashboardDrawer d, Vector2 pos, Vector2 size, bool right, float k)
|
||||
{
|
||||
bool open = IsOpen(d);
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton(d.TabId, size, ImGuiButtonFlags.MouseButtonLeft | ImGuiButtonFlags.MouseButtonRight)
|
||||
&& ImGuiNET.ImGui.IsMouseReleased(ImGuiMouseButton.Left);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton(d.TabId, size);
|
||||
bool hot = ImGuiNET.ImGui.IsItemHovered();
|
||||
bool rightClicked = d.CanMove && ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right);
|
||||
// Like SetItemTooltip (same delay), but the closed tooltip is only built while it shows.
|
||||
if (ImGuiNET.ImGui.IsItemHovered(ImGuiHoveredFlags.ForTooltip))
|
||||
SafeImGui.SetTooltip(open ? d.HideTip : d.TabTooltip(right) + (d.CanMove ? MoveHint : ""));
|
||||
SafeImGui.SetTooltip(open ? d.HideTip : d.TabTooltip(right));
|
||||
if (clicked) Toggle(d);
|
||||
if (rightClicked) ImGuiNET.ImGui.OpenPopup(d.SideMenuId);
|
||||
|
||||
uint fill = ImGuiNET.ImGui.IsItemActive() ? FaceKit.Darken(BtnFill) : hot ? FaceKit.Lighten(BtnFill) : BtnFill;
|
||||
ImDrawFlags corners = right ? ImDrawFlags.RoundCornersRight : ImDrawFlags.RoundCornersLeft;
|
||||
dl.AddRectFilled(pos, pos + size, fill, 4 * k, corners);
|
||||
dl.AddRect(pos, pos + size, open ? Teal : BtnBord, 4 * k, corners);
|
||||
ImFontPtr f10 = ImGuiFonts.Get(UiFont.Dash10);
|
||||
float edge = 2 * k; // the accent bar against the dashboard
|
||||
if (joined)
|
||||
{
|
||||
// Part of the panel: its background, reaching over the panel's edge so there's no seam,
|
||||
// a teal outline on the three other sides and an accent bar against the dashboard.
|
||||
float over = 1.5f * k;
|
||||
Vector2 a = right ? pos : pos - new Vector2(over, 0), b = right ? pos + size + new Vector2(over, 0) : pos + size;
|
||||
dl.AddRectFilled(a, b, RynthTheme.RynthAiBackground);
|
||||
float inner = right ? pos.X : pos.X + size.X;
|
||||
float outerX = right ? pos.X + size.X + over : pos.X - over;
|
||||
dl.AddLine(new Vector2(inner, pos.Y), new Vector2(outerX, pos.Y), Teal);
|
||||
dl.AddLine(new Vector2(inner, pos.Y + size.Y - 1), new Vector2(outerX, pos.Y + size.Y - 1), Teal);
|
||||
dl.AddRectFilled(new Vector2(right ? inner : inner - edge, pos.Y), new Vector2(right ? inner + edge : inner, pos.Y + size.Y), Teal);
|
||||
PhosphorIcons.DrawCentered(dl, f10, d.Icon, pos, size, Teal);
|
||||
}
|
||||
else
|
||||
{
|
||||
// A hovered tab peeks out a little, as if it pulls.
|
||||
float peek = canPeek && hot ? 2 * k : 0;
|
||||
Vector2 p = pos + new Vector2(right ? peek : -peek, 0);
|
||||
uint fill = ImGuiNET.ImGui.IsItemActive() ? FaceKit.Darken(BtnFill) : hot ? FaceKit.Lighten(BtnFill) : BtnFill;
|
||||
ImDrawFlags corners = right ? ImDrawFlags.RoundCornersRight : ImDrawFlags.RoundCornersLeft;
|
||||
dl.AddRectFilled(p, p + size, fill, 4 * k, corners);
|
||||
dl.AddRect(p, p + size, open ? Teal : BtnBord, 4 * k, corners);
|
||||
PhosphorIcons.DrawCentered(dl, f10, d.Icon, p, size, open ? Teal : hot ? White : Mute);
|
||||
}
|
||||
|
||||
// Right-click: move the drawer to the other side.
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, ShellBg);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(8 * k, 6 * k));
|
||||
bool menu = ImGuiNET.ImGui.BeginPopup(d.SideMenuId);
|
||||
ImGuiNET.ImGui.PopStyleVar();
|
||||
ImGuiNET.ImGui.PopStyleColor(2);
|
||||
if (!menu) return;
|
||||
try
|
||||
{
|
||||
if (ImGuiNET.ImGui.MenuItem(right ? PhosphorIcons.CaretLeft + " Move to the left side" : PhosphorIcons.CaretRight + " Move to the right side"))
|
||||
Move(d);
|
||||
}
|
||||
finally { ImGuiNET.ImGui.EndPopup(); }
|
||||
float half = size.Y * 0.5f;
|
||||
PhosphorIcons.DrawCentered(dl, f10, d.Icon, pos, new Vector2(size.X, half), open ? Teal : Mute);
|
||||
// The caret points the way the drawer will move.
|
||||
string caret = right == open ? PhosphorIcons.CaretLeft : PhosphorIcons.CaretRight;
|
||||
PhosphorIcons.DrawCentered(dl, f10, caret, pos + new Vector2(0, half), new Vector2(size.X, half), hot ? White : Mute);
|
||||
}
|
||||
|
||||
private const string MoveHint = "\nRight-click: move it to the other side of the dashboard.";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,13 +72,12 @@ internal sealed class DungeonMapFace : IImGuiPanel
|
|||
|
||||
// ── Palette (the plugin map's colours, ARGB) ──────────────────────────
|
||||
private const uint CanvasBgArgb = 0xFF0A121F, ToolbarBgArgb = 0xE00A121A;
|
||||
private static readonly uint CanvasBorder = C(0xFF334D66), Wall = C(0xFF8CCCFF), PlayerCol = C(0xFF33FF66),
|
||||
Portal = C(0xFFE673FF), PortalRing = C(0xB3FFBFFF), PortalLabel = C(0xFFFFE0FF), Door = C(0xFFBF8C40),
|
||||
DoorRing = C(0xB3E6BF80), DoorLabel = C(0xFFF2D9A6), Monster = C(0xFFFF4033), MonsterRing = C(0xB3FF8C80),
|
||||
Npc = C(0xFFFFD933), NpcRing = C(0xB3FFF28C), CreatureLabel = C(0xFFFFE6E6), Hint = C(0xFF8FA3B8),
|
||||
private static readonly uint CanvasBorder = C(0xFF334D66), Wall = C(0xFF8CCCFF),
|
||||
PlayerCol = C(0xFF33FF66), Portal = C(0xFFE673FF), PortalRing = C(0xB3FFBFFF), PortalLabel = C(0xFFFFE0FF),
|
||||
Door = C(0xFFBF8C40), DoorRing = C(0xB3E6BF80), DoorLabel = C(0xFFF2D9A6),
|
||||
Monster = C(0xFFFF4033), MonsterRing = C(0xB3FF8C80), Npc = C(0xFFFFD933), NpcRing = C(0xB3FFF28C),
|
||||
CreatureLabel = C(0xFFFFE6E6), Hint = C(0xFF8FA3B8), ButtonBg = C(0xC0141F29), ButtonBorder = C(0xFF34587A),
|
||||
FloorOn = C(0xFF2673B3), FloorHere = C(0xFF1AA64D);
|
||||
private static uint ButtonBg => RynthTheme.WithAlpha(RynthTheme.Field, 0xC0);
|
||||
private static uint ButtonBorder => RynthTheme.Border;
|
||||
private const uint FillFlat = 0x662E8C38, FillUp = 0x668C1F14, FillDown = 0x661A8026, FillVisited = 0xB84D6B94;
|
||||
// Route (ARGB, alpha scaled per floor).
|
||||
private const uint RouteLegArgb = 0xD9FFA733, RoutePointArgb = 0xFFFFC266, RouteActiveArgb = 0xFFFFF04D,
|
||||
|
|
|
|||
|
|
@ -20,18 +20,10 @@ internal static class FaceKit
|
|||
{
|
||||
private static uint C(uint argb) => RynthTheme.Argb(argb);
|
||||
|
||||
public static readonly uint Green = C(0xFF33CC66), Red = C(0xFFE05A5A), StartBg = C(0xFF196119),
|
||||
StopBg = C(0xFF801919), DeleteBg = C(0xFF801A1A);
|
||||
public static uint Teal => RynthTheme.Accent;
|
||||
public static uint Amber => RynthTheme.Highlight;
|
||||
public static uint Mute => RynthTheme.MuteAlt;
|
||||
public static uint Text => RynthTheme.Text;
|
||||
public static uint ShellBg => RynthTheme.Background;
|
||||
public static uint PanelBg => RynthTheme.Field;
|
||||
public static uint RowAlt => RynthTheme.RowAlt;
|
||||
public static uint BtnFill => RynthTheme.Button;
|
||||
public static uint BtnBord => RynthTheme.Border;
|
||||
public static uint Selected => RynthTheme.Selected;
|
||||
public static readonly uint Teal = C(0xFF26D9E6), Amber = C(0xFFE8B333), Green = C(0xFF33CC66),
|
||||
Red = C(0xFFE05A5A), Mute = C(0xFFC8D6E4), Text = C(0xFFF2F7FC), ShellBg = C(0xFF0A0F14),
|
||||
PanelBg = C(0xFF141F29), RowAlt = C(0xFF101822), BtnFill = C(0xFF16283A), BtnBord = C(0xFF34587A),
|
||||
Selected = C(0xFF1A2E42), StartBg = C(0xFF196119), StopBg = C(0xFF801919), DeleteBg = C(0xFF801A1A);
|
||||
|
||||
// ── Frame ────────────────────────────────────────────────────────────
|
||||
|
||||
|
|
|
|||
|
|
@ -26,16 +26,10 @@ internal sealed class HotkeysSettingsUi
|
|||
{
|
||||
public const string TabName = "Hotkeys";
|
||||
|
||||
private static readonly uint ToggleOn = C(0xFF33FF33), ToggleOff = C(0xFF334455), Warn = C(0xFFFFB347);
|
||||
private static uint Teal => RynthTheme.Accent;
|
||||
private static uint Amber => RynthTheme.Highlight;
|
||||
private static uint Mute => RynthTheme.TextMuted;
|
||||
private static uint TextDim => RynthTheme.Text;
|
||||
private static uint ShellBg => RynthTheme.Background;
|
||||
private static uint PanelBg => RynthTheme.Field;
|
||||
private static uint BtnFill => RynthTheme.Button;
|
||||
private static uint BtnBord => RynthTheme.Border;
|
||||
private static uint TabActive => RynthTheme.Selected;
|
||||
private static readonly uint Teal = C(0xFF26D9E6), Amber = C(0xFFE8B333), Mute = C(0xFFB8C8D8),
|
||||
TextDim = C(0xFFF2F7FC), ShellBg = C(0xFF0A0F14), PanelBg = C(0xFF141F29), BtnFill = C(0xFF16283A),
|
||||
BtnBord = C(0xFF34587A), ToggleOn = C(0xFF33FF33), ToggleOff = C(0xFF334455), TabActive = C(0xFF1A2E42),
|
||||
Warn = C(0xFFFFB347);
|
||||
private static uint C(uint argb) => RynthTheme.Argb(argb);
|
||||
|
||||
private const string ChatCommandItem = "Chat command...";
|
||||
|
|
@ -404,7 +398,7 @@ internal sealed class HotkeysSettingsUi
|
|||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, TextDim);
|
||||
ImGuiNET.ImGui.TextUnformatted(text);
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
SafeImGui.SetItemTooltip(tip);
|
||||
ImGuiNET.ImGui.SetItemTooltip(tip);
|
||||
}
|
||||
|
||||
private static void Section(string text, float w)
|
||||
|
|
|
|||
|
|
@ -58,11 +58,9 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
private const float Cell = 38, Icon = 32, RowH = 24, PackRowH = 38, ZoneH = 30, StatusH = 20;
|
||||
private const uint AllPacks = 0, WornPacks = 1; // pseudo pack ids (real ids are never 0 or 1)
|
||||
|
||||
private static readonly uint CellHot = RynthTheme.Argb(0xFF1C3148), StackCol = RynthTheme.Argb(0xFFFFFFFF),
|
||||
StackShadow = RynthTheme.Argb(0xE0000000), DropHot = RynthTheme.Argb(0xFF1F5A3A),
|
||||
Placeholder = RynthTheme.Argb(0xFF1A2633);
|
||||
private static uint CellBg => RynthTheme.RowAlt;
|
||||
private static uint CellSel => RynthTheme.Accent;
|
||||
private static readonly uint CellBg = RynthTheme.Argb(0xFF101822), CellHot = RynthTheme.Argb(0xFF1C3148),
|
||||
CellSel = RynthTheme.Argb(0xFF26D9E6), StackCol = RynthTheme.Argb(0xFFFFFFFF), StackShadow = RynthTheme.Argb(0xE0000000),
|
||||
DropHot = RynthTheme.Argb(0xFF1F5A3A), Placeholder = RynthTheme.Argb(0xFF1A2633);
|
||||
|
||||
private static readonly string[] SortNames = { "Pack order", "Name", "Value", "Burden", "Type", "Stack" };
|
||||
private static readonly string[] SortLabels = Array.ConvertAll(SortNames, n => PhosphorIcons.SortAscending + " " + n);
|
||||
|
|
@ -656,7 +654,7 @@ internal sealed partial class InventoryFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, size);
|
||||
bool hot = ImGuiNET.ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenBlockedByActiveItem);
|
||||
SafeImGui.SetItemTooltip(tip);
|
||||
SafeImGui.SetItemTooltip(tip); // the Give zone's tip carries the target's name
|
||||
bool dropHot = enabled && _dragItem != null && hot;
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
uint fill = dropHot ? DropHot : _dragItem != null && enabled ? Selected : hot && enabled ? Lighten(BtnFill) : BtnFill;
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ internal sealed class ItemsFace : IImGuiPanel
|
|||
{
|
||||
ItemsPanel.WeaponEntry wpn = _data.Weapons[i];
|
||||
ImGuiNET.ImGui.PushID("w" + i);
|
||||
int r = Row(wpn.Name, wpn.Element, i, bw, _data.MissingIds.Contains(wpn.Id));
|
||||
int r = Row(wpn.Name, wpn.Element, i, bw, _data.MissingIds.Contains(wpn.Id), DamageTypeColors.For(wpn.Element, Text));
|
||||
ImGuiNET.ImGui.PopID();
|
||||
if (r == 1)
|
||||
{
|
||||
|
|
@ -103,7 +103,7 @@ internal sealed class ItemsFace : IImGuiPanel
|
|||
{
|
||||
ItemsPanel.ConsumableEntry c = _data.Consumables[i];
|
||||
ImGuiNET.ImGui.PushID("c" + i);
|
||||
int r = Row(c.Name, c.Type, i, bw, missing: false);
|
||||
int r = Row(c.Name, c.Type, i, bw, missing: false, Text);
|
||||
ImGuiNET.ImGui.PopID();
|
||||
if (r == 1)
|
||||
{
|
||||
|
|
@ -214,9 +214,10 @@ internal sealed class ItemsFace : IImGuiPanel
|
|||
/// <summary>
|
||||
/// Name | [value picker] | Del. Returns 1 when the picker was clicked, 2 for Del, else 0.
|
||||
/// <paramref name="missing"/>: the item isn't carried any more (amber, a warning icon,
|
||||
/// "(missing)" and a tooltip saying what to do).
|
||||
/// "(missing)" and a tooltip saying what to do). Otherwise the name and value are drawn in
|
||||
/// <paramref name="tint"/> (a weapon's damage-type colour, as UB-ILT's Items tab).
|
||||
/// </summary>
|
||||
private static int Row(string name, string value, int index, float w, bool missing)
|
||||
private static int Row(string name, string value, int index, float w, bool missing, uint tint)
|
||||
{
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
|
|
@ -235,14 +236,14 @@ internal sealed class ItemsFace : IImGuiPanel
|
|||
}
|
||||
else
|
||||
{
|
||||
dl.AddText(new Vector2(p.X + 6, ty), Text, name);
|
||||
dl.AddText(new Vector2(p.X + 6, ty), tint, name);
|
||||
}
|
||||
dl.PopClipRect();
|
||||
if (missing && ImGuiNET.ImGui.IsWindowHovered() && ImGuiNET.ImGui.IsMouseHoveringRect(p, p + new Vector2(nameW, 24)))
|
||||
ImGuiNET.ImGui.SetTooltip("Not in your pack any more - select the item in your inventory and click\n"
|
||||
SafeImGui.SetTooltip("Not in your pack any more - select the item in your inventory and click\n"
|
||||
+ "Add Selected Weapon again, or remove this entry.");
|
||||
int result = 0;
|
||||
if (Button("##pick", value, new Vector2(p.X + nameW + 2, p.Y + 2), new Vector2(96, 20), Text, BtnFill)) result = 1;
|
||||
if (Button("##pick", value, new Vector2(p.X + nameW + 2, p.Y + 2), new Vector2(96, 20), tint, BtnFill)) result = 1;
|
||||
if (IconButton("##del", PhosphorIcons.Trash, new Vector2(p.X + nameW + 102, p.Y + 2), new Vector2(42, 20), Red, BtnFill)) result = 2;
|
||||
ImGuiNET.ImGui.SetItemTooltip("Remove");
|
||||
NextLine(p, 24);
|
||||
|
|
|
|||
|
|
@ -555,7 +555,7 @@ internal sealed class LuaFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.PushTextWrapPos(0);
|
||||
string text = _data?.Console ?? string.Empty;
|
||||
if (text.Length > 0) ImGuiNET.ImGui.TextUnformatted(text);
|
||||
if (_note.Length > 0) SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.Highlight), "[panel] " + _note);
|
||||
if (_note.Length > 0) SafeImGui.TextColored(RynthTheme.Vec(0xFFE8B333), "[panel] " + _note);
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
|
|
|
|||
|
|
@ -1,78 +0,0 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/MapProjection.cs
|
||||
// The World Map's geometry, with no ImGui in it (tools\WorldMapTilesTests checks it offline):
|
||||
// map cells (x east, y north, one cell = 24 yards) to screen pixels and back, through the view
|
||||
// centre, the zoom (pixels per cell) and a rotation.
|
||||
//
|
||||
// screen = centre + R(phi) * (dx * scale, -dy * scale), dx, dy = cell - view centre cell
|
||||
// R(phi) = [cos -sin; sin cos] on a y-down screen (so a positive phi turns the map clockwise)
|
||||
//
|
||||
// Rotating with the player: heading is in degrees, 0 = east, 90 = north (AC), so the heading
|
||||
// direction is (cos h, sin h) in the map; phi = heading - 90 degrees turns it to straight up.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
internal readonly struct MapProjection
|
||||
{
|
||||
public readonly Vector2 Centre; // screen position of the view centre cell
|
||||
public readonly double CentreX, CentreY; // the view centre, in cells
|
||||
public readonly float Scale; // screen pixels per cell
|
||||
public readonly float Cos, Sin; // of the rotation
|
||||
|
||||
public MapProjection(Vector2 centre, double centreX, double centreY, float scale, float phi)
|
||||
{
|
||||
Centre = centre; CentreX = centreX; CentreY = centreY; Scale = scale;
|
||||
Cos = MathF.Cos(phi); Sin = MathF.Sin(phi);
|
||||
}
|
||||
|
||||
public bool Turned => Sin != 0f;
|
||||
|
||||
/// <summary>The rotation that turns the way you face to up, for a heading in degrees (0 = east, 90 = north).</summary>
|
||||
public static float PhiForHeading(float headingDegrees) => (headingDegrees - 90f) * MathF.PI / 180f;
|
||||
|
||||
public Vector2 Project(double cellX, double cellY)
|
||||
{
|
||||
float sx = (float)((cellX - CentreX) * Scale), sy = (float)(-(cellY - CentreY) * Scale);
|
||||
return new Vector2(Centre.X + sx * Cos - sy * Sin, Centre.Y + sx * Sin + sy * Cos);
|
||||
}
|
||||
|
||||
public void Unproject(Vector2 p, out double cellX, out double cellY) => Unproject(p, Scale, out cellX, out cellY);
|
||||
|
||||
public void Unproject(Vector2 p, float scale, out double cellX, out double cellY)
|
||||
{
|
||||
Vector2 d = p - Centre;
|
||||
float ux = d.X * Cos + d.Y * Sin, uy = -d.X * Sin + d.Y * Cos;
|
||||
cellX = CentreX + ux / scale;
|
||||
cellY = CentreY - uy / scale;
|
||||
}
|
||||
|
||||
/// <summary>A map direction (east, north) as a screen direction.</summary>
|
||||
public Vector2 ScreenDir(float east, float north)
|
||||
{
|
||||
float sx = east, sy = -north;
|
||||
return new Vector2(sx * Cos - sy * Sin, sx * Sin + sy * Cos);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The view centre (cells) that keeps the cell under <paramref name="screenPoint"/> where it is
|
||||
/// when the zoom changes from this projection's scale to <paramref name="newScale"/>.
|
||||
/// </summary>
|
||||
public (double X, double Y) CentreForZoomAbout(Vector2 screenPoint, float newScale)
|
||||
{
|
||||
Unproject(screenPoint, out double mx, out double my);
|
||||
Vector2 d = screenPoint - Centre;
|
||||
float ux = d.X * Cos + d.Y * Sin, uy = -d.X * Sin + d.Y * Cos;
|
||||
return (mx - ux / newScale, my + uy / newScale);
|
||||
}
|
||||
|
||||
/// <summary>The view centre (cells) after dragging the map by <paramref name="screenDelta"/> pixels.</summary>
|
||||
public (double X, double Y) CentreAfterDrag(Vector2 screenDelta)
|
||||
{
|
||||
float ux = screenDelta.X * Cos + screenDelta.Y * Sin, uy = -screenDelta.X * Sin + screenDelta.Y * Cos;
|
||||
return (CentreX - ux / Scale, CentreY + uy / Scale);
|
||||
}
|
||||
}
|
||||
|
|
@ -524,7 +524,7 @@ internal sealed partial class MetaFace
|
|||
ImGuiNET.ImGui.SetCursorScreenPos(p);
|
||||
DataBox(id, c, action: false, MetaVocabulary.ConditionHint(c.Condition), width, height);
|
||||
if (c.Condition == MetaRuleEdit.NoKillsWithinMinutes)
|
||||
SafeImGui.SetItemTooltip(MetaRuleEdit.NoKillsTooltip(c.ConditionData));
|
||||
SafeImGui.SetItemTooltip(MetaRuleEdit.NoKillsTooltip(c.ConditionData)); // typed text may hold %: SafeImGui escapes it
|
||||
}
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + height));
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 0));
|
||||
|
|
@ -861,7 +861,7 @@ internal sealed partial class MetaFace
|
|||
private static void Note(string text)
|
||||
{
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), text);
|
||||
SafeImGui.TextColored(RynthTheme.Vec(0xFFC8D6E4), text);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,11 +61,10 @@ namespace RynthCore.Engine.ImGuiBackend.Panels;
|
|||
internal sealed partial class MetaFace
|
||||
{
|
||||
// ── Rule text colours (MetaTone) and list lines ──────────────────────
|
||||
private static readonly uint ToneLabel = C(0xFF8FA9C2), ToneCode = C(0xFF9CC8FF), ToneJoin = C(0xFF4FC3CF), CurrentHdr = C(0xFF0D2B36), // Every other rule a clearly different shade (Tom, 2026-10-11: the old pair was hard to tell apart).
|
||||
private static readonly uint ToneLabel = C(0xFF8FA9C2), ToneCode = C(0xFF9CC8FF), ToneJoin = C(0xFF4FC3CF),
|
||||
RowLine = C(0x7034587A), ColLine = C(0x5834587A), GuideLine = C(0x6034587A), CurrentHdr = C(0xFF0D2B36),
|
||||
// Every other rule a clearly different shade (Tom, 2026-10-11: the old pair was hard to tell apart).
|
||||
StripeA = C(0xFF121B25), StripeB = C(0xFF1C2B3A);
|
||||
private static uint RowLine => RynthTheme.WithAlpha(RynthTheme.Border, 0x70);
|
||||
private static uint ColLine => RynthTheme.WithAlpha(RynthTheme.Border, 0x58);
|
||||
private static uint GuideLine => RynthTheme.WithAlpha(RynthTheme.Border, 0x60);
|
||||
|
||||
private static uint ToneColor(MetaTone tone) => tone switch
|
||||
{
|
||||
|
|
@ -311,7 +310,7 @@ internal sealed partial class MetaFace
|
|||
if (_groups.Count == 0)
|
||||
{
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), " No rules. Click New Rule to add one.");
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D6E4), " No rules. Click New Rule to add one.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -465,7 +464,7 @@ internal sealed partial class MetaFace
|
|||
dl.AddRect(a, b, Teal, 8);
|
||||
dl.AddText(small, small.FontSize, new Vector2(a.X + 5, a.Y + 2), Teal, tag);
|
||||
if (_stateClock.Known && ImGuiNET.ImGui.IsMouseHoveringRect(a, b))
|
||||
ImGuiNET.ImGui.SetTooltip("The meta's current state, and how long it has been in it (what \"In state >= N s\" rules count).");
|
||||
SafeImGui.SetTooltip("The meta's current state, and how long it has been in it (what \"In state >= N s\" rules count).");
|
||||
rx = a.X - 6;
|
||||
|
||||
// The Watchdog, while one is set: it sends the meta to its state when the time runs out
|
||||
|
|
@ -482,8 +481,8 @@ internal sealed partial class MetaFace
|
|||
dl.AddRect(wa, wb, Amber, 8);
|
||||
dl.AddText(small, small.FontSize, new Vector2(wa.X + 5, wa.Y + 2), Amber, wtag);
|
||||
if (ImGuiNET.ImGui.IsMouseHoveringRect(wa, wb))
|
||||
SafeImGui.SetTooltip("Watchdog: unless you move far enough, the meta goes to " +
|
||||
(wdState.Length > 0 ? wdState : "its state") + " when this runs out.");
|
||||
ImGuiNET.ImGui.SetTooltip("Watchdog: unless you move far enough, the meta goes to " +
|
||||
(wdState.Length > 0 ? wdState.Replace("%", "%%") : "its state") + " when this runs out.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ internal sealed partial class MetaFace
|
|||
Separator(w);
|
||||
if (sc == null)
|
||||
{
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), " This RynthAi has no Meta Manager (update RynthAi).");
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D6E4), " This RynthAi has no Meta Manager (update RynthAi).");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -183,9 +183,9 @@ internal sealed partial class MetaFace
|
|||
: sc.LastPollMs == 0 ? "Waiting for the first /myquests."
|
||||
: $"{sc.QuestCount} quest timer(s), /myquests {Span(now - sc.LastPollMs)} ago.";
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(sc.ServerDisabled ? RynthTheme.Highlight : RynthTheme.MuteAlt), Fit(poll, w));
|
||||
SafeImGui.TextColored(RynthTheme.Vec(sc.ServerDisabled ? 0xFFE8B333 : 0xFFC8D6E4), Fit(poll, w));
|
||||
if (sc.LastSwitch.Length > 0)
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.Accent),
|
||||
SafeImGui.TextColored(RynthTheme.Vec(0xFF26D9E6),
|
||||
Fit($"Last: {sc.LastSwitch}{(sc.LastSwitchMs > 0 ? $", {Span(now - sc.LastSwitchMs)} ago" : "")}", w));
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
|
|
@ -195,8 +195,8 @@ internal sealed partial class MetaFace
|
|||
if (sc.Rules.Count == 0)
|
||||
{
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), " No rules. New Rule: when a timer runs out, load a meta.");
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), " The first due rule (top to bottom) wins.");
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D6E4), " No rules. New Rule: when a timer runs out, load a meta.");
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D6E4), " The first due rule (top to bottom) wins.");
|
||||
return;
|
||||
}
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
|
|
@ -367,7 +367,7 @@ internal sealed partial class MetaFace
|
|||
ScheduleRuleDto r = _schedRule;
|
||||
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11));
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.Accent), _schedEdit == -1 ? "New rule" : $"Edit rule {_schedEdit + 1}");
|
||||
SafeImGui.TextColored(RynthTheme.Vec(0xFF26D9E6), _schedEdit == -1 ? "New rule" : $"Edit rule {_schedEdit + 1}");
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
|
||||
FieldLabel("When:");
|
||||
|
|
@ -436,7 +436,7 @@ internal sealed partial class MetaFace
|
|||
if (_schedEdit >= 0)
|
||||
{
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), "Saving re-arms the rule (clears fired / error).");
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFC8D6E4), "Saving re-arms the rule (clears fired / error).");
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
ImGuiNET.ImGui.EndChild();
|
||||
|
|
|
|||
|
|
@ -54,18 +54,11 @@ internal sealed partial class MetaFace : IImGuiPanel
|
|||
() => new MetaFace());
|
||||
|
||||
// ── Palette (MetaPanel's, ARGB) ─────────────────────────────────────
|
||||
private static readonly uint Green = C(0xFF33CC66), Red = C(0xFFE04848), Fired = C(0xFF3A1212),
|
||||
BtnOn = C(0xFF0E2E3A), StateHdrA = C(0xFF0E1E30), DelFill = C(0xFF7A1414), NewFill = C(0xFF0E2E1A);
|
||||
private static uint Teal => RynthTheme.Accent;
|
||||
private static uint Amber => RynthTheme.Highlight;
|
||||
private static uint Mute => RynthTheme.MuteAlt;
|
||||
private static uint TextDim => RynthTheme.Text;
|
||||
private static uint ShellBg => RynthTheme.Background;
|
||||
private static uint PanelBg => RynthTheme.Field;
|
||||
private static uint RowAlt => RynthTheme.RowAlt;
|
||||
private static uint BtnFill => RynthTheme.Button;
|
||||
private static uint BtnBord => RynthTheme.Border;
|
||||
private static uint PickSel => RynthTheme.Selected;
|
||||
private static readonly uint Teal = C(0xFF26D9E6), Amber = C(0xFFE8B333), Green = C(0xFF33CC66),
|
||||
Red = C(0xFFE04848), Mute = C(0xFFC8D6E4), TextDim = C(0xFFF2F7FC), ShellBg = C(0xFF0A0F14),
|
||||
PanelBg = C(0xFF141F29), RowAlt = C(0xFF101822), BtnFill = C(0xFF16283A), BtnBord = C(0xFF34587A),
|
||||
Fired = C(0xFF3A1212), BtnOn = C(0xFF0E2E3A), StateHdrA = C(0xFF0E1E30),
|
||||
DelFill = C(0xFF7A1414), NewFill = C(0xFF0E2E1A), PickSel = C(0xFF1A2E42);
|
||||
private static uint C(uint argb) => RynthTheme.Argb(argb);
|
||||
private static uint Faded(uint abgr) => (abgr & 0x00FFFFFF) | ((abgr >> 25) << 24); // half alpha
|
||||
|
||||
|
|
@ -471,12 +464,12 @@ internal sealed partial class MetaFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
}
|
||||
if (_sourceStale)
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Highlight), "The meta changed since you started editing. Revert loads it.");
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFE8B333), "The meta changed since you started editing. Revert loads it.");
|
||||
|
||||
if (_editor == null || !CodeEditor.Available)
|
||||
{
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFCC3333),
|
||||
"The source editor needs the new cimgui.dll (a full RynthCore deploy).");
|
||||
"The source editor needs the new cimgui.dll (a full RynthCore deploy). Use the Avalonia face meanwhile: /rc ui Meta avalonia");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -994,7 +987,7 @@ internal sealed partial class MetaFace : IImGuiPanel
|
|||
private static void FieldLabel(string text)
|
||||
{
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 1));
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), text);
|
||||
SafeImGui.TextColored(RynthTheme.Vec(0xFFC8D6E4), text);
|
||||
}
|
||||
|
||||
private static void Separator(float w)
|
||||
|
|
|
|||
|
|
@ -1,70 +0,0 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/MiniMapFace.cs
|
||||
// The Mini Map: a small window with the same map as the World Map, following you and turned so the
|
||||
// way you face is up (both switchable from the right-click menu), without a toolbar. The wheel
|
||||
// zooms, a drag pans (Follow off), a double click comes back to you; right-click for Follow /
|
||||
// Rotate / zoom / Go here / Open the World Map. Opened from the RynthNav panel's Mini button.
|
||||
// Its zoom, Follow and Rotate are its own (WorldMapSettings.Mini); the layers are shared with the
|
||||
// World Map's Show menu.
|
||||
// ============================================================================
|
||||
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
internal sealed class MiniMapFace : IImGuiPanel
|
||||
{
|
||||
public const string Title = "Mini Map";
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
ImGuiPanelHost.Register(Title,
|
||||
new PanelSpec(new Vector2(290, 310), new Vector2(150, 150), EdgeToEdge: true, GripInBody: true, NoPopOut: true),
|
||||
() => new MiniMapFace());
|
||||
}
|
||||
|
||||
private readonly WorldMapView _view = new(mini: true);
|
||||
private bool _charsSub;
|
||||
|
||||
public void OnShown() => WorldMapFeeds.Subscribe();
|
||||
|
||||
public void OnHidden()
|
||||
{
|
||||
WorldMapFeeds.Unsubscribe();
|
||||
WorldMapFeeds.ReleaseCharacters(ref _charsSub);
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
WorldMapFeeds.SyncCharacters(ref _charsSub);
|
||||
Vector2 origin = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
Vector2 size = ImGuiNET.ImGui.GetContentRegionAvail();
|
||||
if (size.X < 40 || size.Y < 40) return;
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
|
||||
try
|
||||
{
|
||||
RynthNavStatus? st = UiSources.RynthNav.Current?.Value;
|
||||
MapPlayer pl = WorldMapView.GatherPlayer(st, UiSources.Radar.Current?.Value);
|
||||
CharacterRow[]? chars = WorldMapSettings.Characters ? UiSources.Characters.Current?.Value?.Rows : null;
|
||||
_view.Blocked = null;
|
||||
_view.Draw(origin + new Vector2(1, 1), origin + size - new Vector2(1, 1), pl, st, chars);
|
||||
|
||||
string tip = _view.HoverText;
|
||||
if (tip.Length > 0)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(tip);
|
||||
Vector2 a = origin + new Vector2(6, 6), b = a + ts + new Vector2(10, 6);
|
||||
if (b.X < origin.X + size.X - 4)
|
||||
{
|
||||
dl.AddRectFilled(a, b, RynthTheme.Argb(0xD00A121A), 4);
|
||||
dl.AddText(a + new Vector2(5, 3), FaceKit.Text, tip);
|
||||
}
|
||||
}
|
||||
WorldMapSettings.FlushIfDue();
|
||||
}
|
||||
finally { ImGuiNET.ImGui.PopFont(); }
|
||||
}
|
||||
}
|
||||
|
|
@ -59,9 +59,6 @@ internal sealed partial class MiniRemoteFace
|
|||
|
||||
private static bool IsRemote => _section.Equals(SectionCatalog.RemoteId, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>Whether the window is on section <paramref name="sectionId"/> (the dashboard's lit Char launcher).</summary>
|
||||
public static bool ShowsSection(string sectionId) => _section.Equals(sectionId, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
private static bool RailShown => PanelColumnStore.Get(RailKey, 1f) >= 0.5f;
|
||||
|
||||
// ── Requests (commands; render thread) ──────────────────────────────
|
||||
|
|
@ -459,9 +456,9 @@ internal sealed partial class MiniRemoteFace
|
|||
// ── Session Stats overview ──────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// The Session Stats section's stand-in, shown only while no plugin fills the section (RynthAi
|
||||
/// does, with its session XP, luminance, kills and rates). The engine keeps no session totals
|
||||
/// of its own here: it names the character and says where the numbers come from.
|
||||
/// The Session Stats section's stand-in (shown only while no plugin fills the section; RynthAi
|
||||
/// does): this session's XP and luminance with their per-hour rates, from the engine's
|
||||
/// SessionRates, the same formula RynthAi, RynthTracker, RynthOracle and RynthILT use.
|
||||
/// Character details are RynthOracle's Character tab; server picks are Options > Diagnostics.
|
||||
/// </summary>
|
||||
private void DrawOverview(SectionRegistry.Snapshot snap, Vector2 box)
|
||||
|
|
@ -476,10 +473,20 @@ internal sealed partial class MiniRemoteFace
|
|||
Label(who.Length > 0 ? who : "No character logged in", Teal);
|
||||
float w = ImGuiNET.ImGui.GetContentRegionAvail().X;
|
||||
Separator(w);
|
||||
|
||||
SessionRatesView r = EngineStatusMetrics.SessionView();
|
||||
if (r.Seconds <= 0)
|
||||
{
|
||||
ImGuiNET.ImGui.TextDisabled("The session starts once a character is in the world.");
|
||||
return;
|
||||
}
|
||||
StatRow("Session", FormatDuration(r.Seconds));
|
||||
StatRow("XP", $"{Compact(r.Xp)} ({Compact(r.XpPerHour)}/hr)");
|
||||
StatRow("Luminance", $"{Compact(r.Lum)} ({Compact(r.LumPerHour)}/hr)");
|
||||
ImGuiNET.ImGui.Spacing();
|
||||
ImGuiNET.ImGui.PushTextWrapPos(0f);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Faded(Mute));
|
||||
SafeImGui.TextWrapped("This session's XP, luminance, kills and their per-hour rates come with RynthAi's "
|
||||
+ "Session Stats; RynthAi isn't loaded (or is too old to show them here). "
|
||||
SafeImGui.TextWrapped("Kills, deaths and per-kill XP come with RynthAi's session stats. "
|
||||
+ "Character details: RynthOracle's Character tab (/ro character). Server picks: Options > Diagnostics.");
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
|
|
@ -490,6 +497,30 @@ internal sealed partial class MiniRemoteFace
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>One "label value" row of the overview.</summary>
|
||||
private static void StatRow(string label, string value)
|
||||
{
|
||||
Label(label, Mute);
|
||||
ImGuiNET.ImGui.SameLine(90f);
|
||||
ImGuiNET.ImGui.TextUnformatted(value);
|
||||
}
|
||||
|
||||
/// <summary>12.3k, 4.5m, 1.2b (the Mini Remote's compact numbers).</summary>
|
||||
private static string Compact(double v)
|
||||
{
|
||||
double a = Math.Abs(v);
|
||||
if (a >= 1e9) return (v / 1e9).ToString("0.0", System.Globalization.CultureInfo.InvariantCulture) + "b";
|
||||
if (a >= 1e6) return (v / 1e6).ToString("0.0", System.Globalization.CultureInfo.InvariantCulture) + "m";
|
||||
if (a >= 1e4) return (v / 1e3).ToString("0.0", System.Globalization.CultureInfo.InvariantCulture) + "k";
|
||||
return v.ToString("0", System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary>"1h 05m" or "4m 12s".</summary>
|
||||
private static string FormatDuration(double seconds)
|
||||
{
|
||||
var t = TimeSpan.FromSeconds(Math.Max(0, seconds));
|
||||
return t.TotalHours >= 1 ? $"{(int)t.TotalHours}h {t.Minutes:00}m" : $"{t.Minutes}m {t.Seconds:00}s";
|
||||
}
|
||||
// ── Menu ────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>The menu's section half: every section, the active servers' items, the rail switch.</summary>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
// With RynthAi loaded it hosts RynthAi's Mini Remote (session rates, target,
|
||||
// summon, item slots, toggles, bank, rebuff, Translate, Guardian and its
|
||||
// Options menu, its Quests and Pets tabs, plus on ILT worlds the RynthILT
|
||||
// plugin's tabs Charms, Banking, Gear and Games (Character moved to RynthOracle, 2026.10.5.54), which RynthAi asks
|
||||
// plugin's tabs Gear and Games (Character and Charms moved to RynthOracle, Banking to RynthInventory, 2026.10.5.54), which RynthAi asks
|
||||
// RynthILT to draw), drawn by the plugin through
|
||||
// RynthPluginRenderEmbed ("miniremote-window"). The window fits itself to what
|
||||
// the plugin asks for whenever that changes (another tab, a section shown or
|
||||
|
|
|
|||
|
|
@ -157,21 +157,19 @@ internal sealed class NavFace : IImGuiPanel
|
|||
|
||||
// Breadcrumbs | Route overlay (RynthAi's NavOverlaySettings; saved per character)
|
||||
p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
// Also on Settings > Navigation. The local settings copy takes the new value too, so a reach
|
||||
// save from this panel before the next settings fetch doesn't send the old one back.
|
||||
if (OverlayToggle("##crumbs", "Breadcrumbs", _data.TrackBreadcrumbs, p, half, SettingsSchema.BreadcrumbsTip))
|
||||
if (OverlayToggle("##crumbs", "Breadcrumbs", _data.TrackBreadcrumbs, p, half,
|
||||
"Record the trail you walk and draw it on the ground (/ra navtrail on|off).\nTurning it off hides the trail; /ra navtrail clear wipes it."))
|
||||
{
|
||||
bool on = !_data.TrackBreadcrumbs;
|
||||
NavCommands.Send(new NavCmd { Cmd = "setBreadcrumbs", On = on });
|
||||
_data.TrackBreadcrumbs = on;
|
||||
if (_settings?.TrackBreadcrumbs != null) _settings.TrackBreadcrumbs = on;
|
||||
}
|
||||
if (OverlayToggle("##routeovl", "Route overlay", _data.ShowRouteOverlay, new Vector2(p.X + half + 4, p.Y), half, SettingsSchema.RouteOverlayTip))
|
||||
if (OverlayToggle("##routeovl", "Route overlay", _data.ShowRouteOverlay, new Vector2(p.X + half + 4, p.Y), half,
|
||||
"Draw the route in the world: waypoint rings and lines, waypoint labels and the guide line\nto the active waypoint (/ra navoverlay on|off). The waypoint HUD window is separate."))
|
||||
{
|
||||
bool on = !_data.ShowRouteOverlay;
|
||||
NavCommands.Send(new NavCmd { Cmd = "setRouteOverlay", On = on });
|
||||
_data.ShowRouteOverlay = on;
|
||||
if (_settings?.ShowRouteOverlay != null) _settings.ShowRouteOverlay = on;
|
||||
}
|
||||
NextLine(p, 26);
|
||||
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ internal sealed class TrackerFace : IImGuiPanel
|
|||
private static readonly Vector4 TitleColor = RynthTheme.Vec(0xFFE6B450);
|
||||
private static readonly Vector4 LabelColor = RynthTheme.Vec(0xFF999999);
|
||||
private static readonly uint ResetBg = RynthTheme.Argb(0xFF1A2E40);
|
||||
private static uint ResetBorder => RynthTheme.AccentFill;
|
||||
private static readonly uint ResetBorder = RynthTheme.Argb(0xFF264C59);
|
||||
private int _opacity;
|
||||
|
||||
public void OnShown()
|
||||
|
|
|
|||
|
|
@ -1,200 +0,0 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/QuickSettingsDrawer.cs
|
||||
// The dashboard's My settings drawer (Tom 2026-10-14): the settings the player
|
||||
// pinned, drawn with the Settings panel's own rows (SettingsRows.cs), so a
|
||||
// setting changed here is the same setting, saved the same way.
|
||||
//
|
||||
// Pin from any setting's right-click (the Settings panel, the Patrol drawer,
|
||||
// this drawer) or from the + button here, a searchable list of every setting
|
||||
// that can be pinned (UI/QuickSettings.cs keeps the pins and their order).
|
||||
// Here a row's right-click also moves it up or down. Starts on the
|
||||
// dashboard's right edge; its tab's right-click moves it to the left.
|
||||
// AC thread only (inside the dashboard's Draw).
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.UI;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
internal sealed class QuickSettingsDrawer : RynthAiDrawer
|
||||
{
|
||||
private readonly SettingsRows _rows = new();
|
||||
private bool _sub;
|
||||
private string _filter = string.Empty;
|
||||
private const string AddPopupId = "##quick_add";
|
||||
|
||||
// Rows are drawn at the Settings panel's fixed sizes: about this tall each (pixels).
|
||||
private const float RowH = 28, EmptyH = 70, MinBodyH = 60;
|
||||
|
||||
public override string Key => "quick";
|
||||
public override string Icon => PhosphorIcons.SlidersHorizontal;
|
||||
public override string Name => "My settings drawer";
|
||||
public override bool StartsRight => true;
|
||||
public override bool SavedOpen => RynthAiDashboardState.QuickOpen;
|
||||
public override void SaveOpen(bool open) => RynthAiDashboardState.SetQuickOpen(open);
|
||||
|
||||
public override string TabTooltip(bool right) =>
|
||||
"My settings: the settings you pinned, to change them without opening Settings.\n" +
|
||||
"Pin one by right-clicking it in Settings, or with + in the drawer. Click to slide it out.";
|
||||
|
||||
public override float Width(float k) => 300 * k;
|
||||
|
||||
public override float Height(float k)
|
||||
{
|
||||
int pins = 0;
|
||||
foreach (string key in QuickSettings.Pins)
|
||||
if (QuickSettings.RowOf(key) != null) pins++;
|
||||
float body = pins == 0 ? EmptyH : MathF.Max(MinBodyH, pins * RowH + 6);
|
||||
float frame = (Pad + TitleH + 4 + Pad) * k;
|
||||
float screen = ImGuiNET.ImGui.GetIO().DisplaySize.Y;
|
||||
float max = screen > 1 ? MathF.Max(120 * k, screen - 8 * k) : 900 * k;
|
||||
return MathF.Min(frame + body, max);
|
||||
}
|
||||
|
||||
public override void Update(bool showing)
|
||||
{
|
||||
if (showing == _sub) return;
|
||||
_sub = showing;
|
||||
if (showing) { UiSources.Settings.Subscribe(); UiSources.Settings.RequestRefresh(); }
|
||||
else UiSources.Settings.Unsubscribe();
|
||||
}
|
||||
|
||||
public override void DrawPanel(Vector2 origin, float panelW, float panelH, float k)
|
||||
{
|
||||
float y = PanelFrame(origin, panelW, panelH, k, PhosphorIcons.SlidersHorizontal, "MY SETTINGS", null, "Hide My settings");
|
||||
float x = origin.X + Pad * k, w = panelW - 2 * Pad * k;
|
||||
|
||||
// + beside the close button: pick settings to pin.
|
||||
Vector2 btn = new(18 * k, 16 * k);
|
||||
Vector2 addPos = new(x + w - 2 * btn.X - 3 * k, origin.Y + Pad * k + (TitleH * k - btn.Y) * 0.5f);
|
||||
if (FaceKit.IconButton("##quick_plus", PhosphorIcons.Plus, addPos, btn, DTeal, DBtnFill, border: DBtnBord, font: UiFont.Dash10))
|
||||
{
|
||||
_filter = string.Empty;
|
||||
ImGuiNET.ImGui.SetNextWindowPos(new Vector2(addPos.X + btn.X, addPos.Y + btn.Y + 2 * k), ImGuiCond.Always, new Vector2(1, 0));
|
||||
ImGuiNET.ImGui.OpenPopup(AddPopupId);
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("Pin or unpin settings");
|
||||
AddPopup(k);
|
||||
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(x, y));
|
||||
Vector2 size = new(w, MathF.Max(1, origin.Y + panelH - Pad * k - y));
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
|
||||
bool open = ImGuiNET.ImGui.BeginChild("##quick_body", size, ImGuiChildFlags.None, ImGuiWindowFlags.NoBackground);
|
||||
ImGuiNET.ImGui.PopStyleVar();
|
||||
try
|
||||
{
|
||||
if (!open) return;
|
||||
_rows.Sync();
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(4, 0));
|
||||
try
|
||||
{
|
||||
float rw = ImGuiNET.ImGui.GetContentRegionAvail().X - 2 * k;
|
||||
string[] pins = QuickSettings.Pins;
|
||||
int drawn = 0;
|
||||
for (int i = 0; i < pins.Length; i++)
|
||||
{
|
||||
SettingRow? row = QuickSettings.RowOf(pins[i]);
|
||||
if (row == null) continue;
|
||||
drawn++;
|
||||
if (!row.IsVisible(_rows.Data)) continue;
|
||||
ImGuiNET.ImGui.PushID(pins[i]);
|
||||
_rows.DrawRow(row, rw, extraMenu: MoveItems);
|
||||
ImGuiNET.ImGui.PopID();
|
||||
}
|
||||
if (drawn == 0)
|
||||
{
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, DMute);
|
||||
ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + rw);
|
||||
ImGuiNET.ImGui.TextUnformatted("Pin the settings you change most. Right-click a setting in Settings (or in the Patrol drawer) " +
|
||||
"and pick Pin to My settings, or click + above.");
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ImGuiNET.ImGui.PopStyleVar();
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
}
|
||||
finally { ImGuiNET.ImGui.EndChild(); }
|
||||
}
|
||||
|
||||
/// <summary>A pinned row's right-click, after Remove: Move up / Move down.</summary>
|
||||
private static void MoveItems(string key)
|
||||
{
|
||||
string[] pins = QuickSettings.Pins;
|
||||
int i = Array.IndexOf(pins, key);
|
||||
if (ImGuiNET.ImGui.MenuItem(PhosphorIcons.CaretUp + " Move up", null, false, i > 0)) QuickSettings.Move(key, -1);
|
||||
if (ImGuiNET.ImGui.MenuItem(PhosphorIcons.CaretDown + " Move down", null, false, i >= 0 && i < pins.Length - 1)) QuickSettings.Move(key, +1);
|
||||
}
|
||||
|
||||
/// <summary>Every setting that can be pinned, by tab, with a search box; a click pins or unpins it.</summary>
|
||||
private void AddPopup(float k)
|
||||
{
|
||||
ImGuiNET.ImGui.SetNextWindowSize(new Vector2(320 * k, 420 * k));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, RynthTheme.Background);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, DTeal);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(8 * k, 6 * k));
|
||||
bool open = ImGuiNET.ImGui.BeginPopup(AddPopupId);
|
||||
ImGuiNET.ImGui.PopStyleVar();
|
||||
ImGuiNET.ImGui.PopStyleColor(2);
|
||||
if (!open) return;
|
||||
try
|
||||
{
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
|
||||
ImGuiNET.ImGui.SetNextItemWidth(-1);
|
||||
if (ImGuiNET.ImGui.IsWindowAppearing()) ImGuiNET.ImGui.SetKeyboardFocusHere();
|
||||
ImGuiNET.ImGui.InputTextWithHint("##quick_search", "Search settings", ref _filter, 64);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
ImGuiNET.ImGui.BeginChild("##quick_list", new Vector2(0, 0));
|
||||
string filter = _filter.Trim();
|
||||
foreach (SettingsTab tab in SettingsSchema.Tabs)
|
||||
{
|
||||
bool header = false;
|
||||
string section = "";
|
||||
foreach (SettingRow row in tab.Rows)
|
||||
{
|
||||
if (row.Kind == SettingKind.Section) { section = row.Label.Trim(); continue; }
|
||||
string? key = QuickSettings.KeyOf(row);
|
||||
if (key == null) continue;
|
||||
string label = row.Label.Trim();
|
||||
if (filter.Length > 0 && label.IndexOf(filter, StringComparison.OrdinalIgnoreCase) < 0
|
||||
&& section.IndexOf(filter, StringComparison.OrdinalIgnoreCase) < 0
|
||||
&& tab.Name.IndexOf(filter, StringComparison.OrdinalIgnoreCase) < 0)
|
||||
continue;
|
||||
if (!header)
|
||||
{
|
||||
header = true;
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 3));
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.Highlight), tab.Name);
|
||||
}
|
||||
bool pinned = QuickSettings.IsPinned(key);
|
||||
ImGuiNET.ImGui.PushID(key);
|
||||
// Stays open, so several can be pinned in one go; the section shows dimmed at the right.
|
||||
if (ImGuiNET.ImGui.Selectable((pinned ? PhosphorIcons.Check : " ") + " " + label, pinned, ImGuiSelectableFlags.NoAutoClosePopups))
|
||||
QuickSettings.SetPinned(key, !pinned);
|
||||
if (row.Tooltip != null) SafeImGui.SetItemTooltip(row.Tooltip);
|
||||
if (section.Length > 0)
|
||||
{
|
||||
Vector2 max = ImGuiNET.ImGui.GetItemRectMax(), min = ImGuiNET.ImGui.GetItemRectMin();
|
||||
float sw = ImGuiNET.ImGui.CalcTextSize(section).X;
|
||||
float sx = MathF.Max(min.X + ImGuiNET.ImGui.CalcTextSize(" " + label).X + 24, max.X - sw - 4);
|
||||
if (sx + sw <= max.X)
|
||||
ImGuiNET.ImGui.GetWindowDrawList().AddText(new Vector2(sx, min.Y), RynthTheme.Argb(0xFF6E8197), section);
|
||||
}
|
||||
ImGuiNET.ImGui.PopID();
|
||||
}
|
||||
}
|
||||
ImGuiNET.ImGui.EndChild();
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
finally { ImGuiNET.ImGui.EndPopup(); }
|
||||
}
|
||||
}
|
||||
|
|
@ -43,10 +43,9 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
|
||||
// ── Palette (RadarPanel's, ARGB) ────────────────────────────────────
|
||||
private const uint FrameOuterArgb = 0xFF0A0D14, CanvasBgArgb = 0xFF0A121A;
|
||||
private static readonly uint FrameInner = C(0xFF9E853D), FrameAccent = C(0xFFE6C766), Crosshair = C(0x994D6680),
|
||||
Cardinal = C(0xFFFFFFFF), CoordText = C(0xFFF2F8FF), Outline = C(0xF2000000), PlayerCol = C(0xFF33FF66);
|
||||
private static uint ButtonBg => RynthTheme.WithAlpha(RynthTheme.Field, 0xC0);
|
||||
private static uint ButtonBorder => RynthTheme.Border;
|
||||
private static readonly uint FrameInner = C(0xFF9E853D), FrameAccent = C(0xFFE6C766),
|
||||
Crosshair = C(0x994D6680), Cardinal = C(0xFFFFFFFF), CoordText = C(0xFFF2F8FF), Outline = C(0xF2000000),
|
||||
PlayerCol = C(0xFF33FF66), ButtonBg = C(0xC0141F29), ButtonBorder = C(0xFF34587A);
|
||||
// Marker colours per kind (RadarSettingsStore.KindColors, user-pickable), refreshed each frame.
|
||||
private static readonly uint[] KindCols = new uint[RadarKind.Count];
|
||||
private const uint WallUnseen = 0xFFFFFFFF, WallVisited = 0xFF4099FF, FloorFlat = 0x8C2E8C38,
|
||||
|
|
@ -536,7 +535,7 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
private void SettingsWindow()
|
||||
{
|
||||
if (!_settingsOpen) return;
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.WindowBg, RynthTheme.BoxBg);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.WindowBg, C(0xFF0A121A));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, ButtonBorder);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 4f);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(10, 10));
|
||||
|
|
|
|||
|
|
@ -46,18 +46,12 @@ using Rule = RynthCore.Engine.UI.Panels.MonstersPanel.Rule;
|
|||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
internal sealed class RangesSlideOut : RynthAiDrawer
|
||||
internal sealed class RangesSlideOut : DashboardDrawer
|
||||
{
|
||||
// ── Palette (the dashboard's, ARGB) ────────────────────────────────
|
||||
private static readonly uint Gold = C(0xFFFFD16A);
|
||||
private static uint Teal => RynthTheme.Accent;
|
||||
private static uint TealSoft => RynthTheme.AccentFill;
|
||||
private static uint Amber => RynthTheme.Highlight;
|
||||
private static uint Mute => RynthTheme.TextMuted;
|
||||
private static uint White => RynthTheme.Text;
|
||||
private static uint BarBg => RynthTheme.Field;
|
||||
private static uint BtnFill => RynthTheme.Button;
|
||||
private static uint BtnBord => RynthTheme.Border;
|
||||
private static readonly uint Teal = C(0xFF26D9E6), TealSoft = C(0xFF264C59), Amber = C(0xFFE8B333),
|
||||
Gold = C(0xFFFFD16A), Mute = C(0xFFB8C8D8), White = C(0xFFF2F7FC), BarBg = C(0xFF141F29),
|
||||
BtnFill = C(0xFF16283A), BtnBord = C(0xFF34587A);
|
||||
private static uint C(uint argb) => RynthTheme.Argb(argb);
|
||||
|
||||
// ── Rows: (Settings row label, short label here) ────────────────────
|
||||
|
|
@ -135,8 +129,9 @@ internal sealed class RangesSlideOut : RynthAiDrawer
|
|||
public override bool SavedOpen => RynthAiDashboardState.RangesOpen;
|
||||
public override void SaveOpen(bool open) => RynthAiDashboardState.SetRangesOpen(open);
|
||||
|
||||
public override string TabTooltip(bool right) =>
|
||||
"Ranges: monster range, nav point reach and more, and the selected monster.\nClick to slide them out.";
|
||||
public override string TabTooltip(bool right) => right
|
||||
? "Ranges: monster range, nav point reach and more, and the selected monster.\nClick to slide them out (to the right: there's no room on the left)."
|
||||
: "Ranges: monster range, nav point reach and more, and the selected monster.\nClick to slide them out.";
|
||||
|
||||
public override float Width(float k) => 250 * k;
|
||||
public override float Height(float k) => PanelHeight(k);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace RynthCore.Engine.ImGuiBackend.Panels;
|
|||
internal sealed partial class RynthAiFace
|
||||
{
|
||||
/// <summary>Meta state, bot activity and the five file pickers.</summary>
|
||||
private sealed class FilesDrawer : RynthAiDrawer
|
||||
private sealed class FilesDrawer : DashboardDrawer
|
||||
{
|
||||
private readonly RynthAiFace _face;
|
||||
public FilesDrawer(RynthAiFace face) => _face = face;
|
||||
|
|
@ -51,7 +51,7 @@ internal sealed partial class RynthAiFace
|
|||
"Profile: " + (v?.ProfileText ?? "Default") + "\nNav: " + (v?.NavText ?? "None") +
|
||||
"\nLoot: " + (v?.LootText ?? "None") + "\nMeta: " + (v?.MetaText ?? "None") +
|
||||
"\nBuffs: " + (v?.BuffText ?? "Built-in") +
|
||||
"\n\nClick to slide them out.";
|
||||
(right ? "\n\nClick to slide them out (to the right: there's no room on the left)." : "\n\nClick to slide them out.");
|
||||
}
|
||||
|
||||
// The picker rows are the dashboard's own (Selector), so they take its size factor (_k);
|
||||
|
|
@ -100,14 +100,10 @@ internal sealed partial class RynthAiFace
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>The Dungeon Patrol settings, hazard cells and saved routes (the Patrol launcher's right-click).</summary>
|
||||
private sealed class PatrolDrawer : RynthAiDrawer
|
||||
/// <summary>Hazard cells and saved routes (the Patrol launcher's right-click).</summary>
|
||||
private sealed class PatrolDrawer : DashboardDrawer
|
||||
{
|
||||
private bool _sub;
|
||||
// Settings > Navigation > Dungeon Patrol, drawn here too (2026-10-14).
|
||||
private readonly SettingsRows _rows = new();
|
||||
private static SettingRow[]? _settingRows;
|
||||
private static SettingRow[] SettingRows => _settingRows ??= QuickSettings.SectionRows("Navigation", "Dungeon Patrol");
|
||||
|
||||
public override string Key => "patrol";
|
||||
public override string Icon => PhosphorIcons.Footprints;
|
||||
|
|
@ -115,32 +111,19 @@ internal sealed partial class RynthAiFace
|
|||
public override bool SavedOpen => RynthAiDashboardState.PatrolOpen;
|
||||
public override void SaveOpen(bool open) => RynthAiDashboardState.SetPatrolOpen(open);
|
||||
|
||||
public override string TabTooltip(bool right) =>
|
||||
"Patrol: the Dungeon Patrol settings, this dungeon's hazard cells, recorded hazards and saved routes\n(also: right-click Patrol). Click to slide it out.";
|
||||
public override string TabTooltip(bool right) => right
|
||||
? "Patrol: this dungeon's hazard cells, recorded hazards and saved routes (also: right-click Patrol).\nClick to slide it out (to the right: there's no room on the left)."
|
||||
: "Patrol: this dungeon's hazard cells, recorded hazards and saved routes (also: right-click Patrol).\nClick to slide it out.";
|
||||
|
||||
public override float Width(float k) => 290 * k;
|
||||
|
||||
public override float Height(float k)
|
||||
{
|
||||
// Never taller than the screen: the body scrolls instead.
|
||||
float screen = ImGuiNET.ImGui.GetIO().DisplaySize.Y;
|
||||
return screen > 1 ? MathF.Min(500 * k, MathF.Max(200 * k, screen - 8 * k)) : 500 * k;
|
||||
}
|
||||
public override float Width(float k) => 260 * k;
|
||||
public override float Height(float k) => 320 * k;
|
||||
|
||||
public override void Update(bool showing)
|
||||
{
|
||||
if (showing == _sub) return;
|
||||
_sub = showing;
|
||||
if (showing)
|
||||
{
|
||||
UiSources.Patrol.Subscribe(); UiSources.Patrol.RequestRefresh();
|
||||
UiSources.Settings.Subscribe(); UiSources.Settings.RequestRefresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
UiSources.Patrol.Unsubscribe();
|
||||
UiSources.Settings.Unsubscribe();
|
||||
}
|
||||
if (showing) { UiSources.Patrol.Subscribe(); UiSources.Patrol.RequestRefresh(); }
|
||||
else UiSources.Patrol.Unsubscribe();
|
||||
}
|
||||
|
||||
public override void DrawPanel(Vector2 origin, float panelW, float panelH, float k)
|
||||
|
|
@ -158,27 +141,6 @@ internal sealed partial class RynthAiFace
|
|||
{
|
||||
if (open)
|
||||
{
|
||||
if (Mini(PhosphorIcons.Play + " Start patrol"))
|
||||
RynthAiCommands.SendNavCommand("{\"Cmd\":\"dunPatrol\"}");
|
||||
ImGuiNET.ImGui.SetItemTooltip("Start the Dungeon Patrol here (the same as left-clicking Patrol).");
|
||||
|
||||
// The settings, with the Settings panel's rows (right-click one to pin it to My settings).
|
||||
Section("SETTINGS");
|
||||
_rows.Sync();
|
||||
float w = ImGuiNET.ImGui.GetContentRegionAvail().X - 2 * k;
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(4, 0));
|
||||
SettingRow[] rows = SettingRows;
|
||||
for (int i = 0; i < rows.Length; i++)
|
||||
{
|
||||
if (!rows[i].IsVisible(_rows.Data)) continue;
|
||||
ImGuiNET.ImGui.PushID(i);
|
||||
_rows.DrawRow(rows[i], w);
|
||||
ImGuiNET.ImGui.PopID();
|
||||
}
|
||||
ImGuiNET.ImGui.PopStyleVar();
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
|
||||
PatrolInfo info = UiSources.Patrol.Current?.Value ?? new PatrolInfo();
|
||||
PatrolBody(info, withTitle: false);
|
||||
}
|
||||
|
|
@ -188,7 +150,7 @@ internal sealed partial class RynthAiFace
|
|||
}
|
||||
|
||||
/// <summary>RynthAi's Mini Remote, drawn by the plugin into this drawer (its drawer tab).</summary>
|
||||
private sealed class RemoteDrawer : RynthAiDrawer
|
||||
private sealed class RemoteDrawer : DashboardDrawer
|
||||
{
|
||||
/// <summary>The plugin surface name, NUL-terminated for the export.</summary>
|
||||
private static ReadOnlySpan<byte> Surface => "miniremote\0"u8;
|
||||
|
|
@ -208,7 +170,7 @@ internal sealed partial class RynthAiFace
|
|||
public override string TabTooltip(bool right) =>
|
||||
"Mini Remote: session rates, attack target, summon, item slots, toggles, bank, rebuff, Translate.\n" +
|
||||
"Its Options button picks the sections. RynthILT's ILT tabs are in the Mini Remote window (Char, or the bar button).\n" +
|
||||
"Click to slide it out.";
|
||||
(right ? "Click to slide it out (to the right: there's no room on the left)." : "Click to slide it out.");
|
||||
|
||||
public override float Width(float k) =>
|
||||
Math.Clamp(_want.X > 0 ? _want.X : MinW * k, MinW * k, MaxW * k) + 2 * Pad * k;
|
||||
|
|
|
|||
|
|
@ -3,33 +3,24 @@
|
|||
// ImGui face of the RynthAi dashboard (docs/IMGUI_PARITY_PLAN.md §2.1),
|
||||
// first laid out from the Avalonia face (UI/Panels/RynthAiPanel.cs), then
|
||||
// made compact with Phosphor icons, after DrakBot's dashboard. Top to bottom:
|
||||
// title row RYNTH, running/stopped | target, vitals, lock, opacity -/+,
|
||||
// minimize, pop out; a teal accent line along the top edge
|
||||
// title row RYNTH | target, vitals, lock, opacity -/+,
|
||||
// minimize, pop out
|
||||
// header grid popped out only: meta state, bot activity | pickers (docked,
|
||||
// they are the Loaded files drawer)
|
||||
// control row macro start/stop, combat, buffing, nav, looting and meta
|
||||
// toggles (on: lit with a bar under the icon; off: dimmed),
|
||||
// bot activity as a coloured label ... force rebuff. A
|
||||
// toggle's right-click opens its settings (2026-10-14):
|
||||
// Combat the Monsters panel, Buffing Settings > Buffing,
|
||||
// Navigation the Nav panel, Looting the Loot Editor on the
|
||||
// loot profile in use, Meta the Meta panel.
|
||||
// toggles, bot activity ... force rebuff
|
||||
// launchers one row of icon buttons (names in tooltips; labels too
|
||||
// when the panel is wide enough); a button lights up while
|
||||
// its window (or drawer) is open. Nav and Meta left the row
|
||||
// for their toggles' right-click (2026-10-14).
|
||||
// footer FPS (coloured by rate) | version | uptime
|
||||
// when the panel is wide enough)
|
||||
// footer FPS | version | uptime
|
||||
// bars player vitals, then the target (name + health), each
|
||||
// toggled from the title row. Last on purpose, like DrakBot's
|
||||
// target row: what comes and goes with a fight never moves
|
||||
// the buttons above it.
|
||||
// drawers tabs on the dashboard's edges (DashboardDrawers.cs), one
|
||||
// open per side, windows of their own beside the dashboard:
|
||||
// Ranges (RangesSlideOut.cs), Loaded files, Patrol and Mini
|
||||
// Remote (RynthAiFace.Drawers.cs) on the left, My settings
|
||||
// (QuickSettingsDrawer.cs) on the right; a tab's right-click
|
||||
// moves its drawer to the other side. Only the bars stay at
|
||||
// the bottom (Tom 2026-10-05).
|
||||
// drawers tabs on the left edge (DashboardDrawers.cs), one open at a
|
||||
// time, a window of their own beside the dashboard: Ranges
|
||||
// (RangesSlideOut.cs), Loaded files, Patrol and Mini Remote
|
||||
// (RynthAiFace.Drawers.cs). Everything that slides out goes
|
||||
// left; only the bars stay at the bottom (Tom 2026-10-05).
|
||||
// Minimized keeps the title row, the control row and the bars. The window's
|
||||
// minimum height is the content's, and toggling the bars or minimize fits the
|
||||
// window to the content. Data: UiSources.RynthAi (a RynthAiView with every
|
||||
|
|
@ -80,18 +71,11 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
private const float MinWidth = 280;
|
||||
|
||||
// ── Palette (RynthAiPanel's, ARGB) ─────────────────────────────────
|
||||
private static readonly uint Green = C(0xFF40D973), White = C(0xFFFFFFFF), Hp = C(0xFFD93333), Mana = C(0xFF268CF2),
|
||||
MacroRun = C(0xFF1A5926), MacroStop = C(0xFF401F1F), FrFill = C(0xFF47330A), SelectorBg = C(0xFF2D3847),
|
||||
Off = C(0xFF6E8197), Faint = C(0xFF5A7088), RunGlow = C(0x5540D973);
|
||||
private static uint Teal => RynthTheme.Accent;
|
||||
private static uint TealSoft => RynthTheme.AccentFill;
|
||||
private static uint Amber => RynthTheme.Highlight;
|
||||
private static uint Mute => RynthTheme.TextMuted;
|
||||
private static uint TextDim => RynthTheme.Text;
|
||||
private static uint ShellBg => RynthTheme.Background;
|
||||
private static uint BarBg => RynthTheme.Field;
|
||||
private static uint BtnFill => RynthTheme.Button;
|
||||
private static uint BtnBord => RynthTheme.Border;
|
||||
private static readonly uint Teal = C(0xFF26D9E6), TealSoft = C(0xFF264C59), Amber = C(0xFFE8B333),
|
||||
Green = C(0xFF40D973), Mute = C(0xFFB8C8D8), TextDim = C(0xFFF2F7FC), White = C(0xFFFFFFFF),
|
||||
Hp = C(0xFFD93333), Mana = C(0xFF268CF2), ShellBg = C(0xFF0A0F14), BarBg = C(0xFF141F29),
|
||||
BtnFill = C(0xFF16283A), BtnBord = C(0xFF34587A), MacroRun = C(0xFF1A5926), MacroStop = C(0xFF401F1F),
|
||||
FrFill = C(0xFF47330A), SelectorBg = C(0xFF2D3847);
|
||||
private static uint C(uint argb) => RynthTheme.Argb(argb);
|
||||
|
||||
private static readonly uint[] SegmentColors = BuildSegmentColors();
|
||||
|
|
@ -134,8 +118,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
public RynthAiFace()
|
||||
{
|
||||
// Tab order top to bottom; the first one saved open wins at load.
|
||||
// Each side's in this order; My settings starts on the right.
|
||||
_drawers = new DashboardDrawers(new RangesSlideOut(), new FilesDrawer(this), _patrol, _remote, new QuickSettingsDrawer());
|
||||
_drawers = new DashboardDrawers(new RangesSlideOut(), new FilesDrawer(this), _patrol, _remote);
|
||||
}
|
||||
|
||||
public Vector2? MinSize
|
||||
|
|
@ -172,7 +155,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
bool popped = ImGuiPopOuts.InPopOutFrame;
|
||||
_view = view;
|
||||
_raw = raw;
|
||||
uint boxBg = (RynthTheme.BoxBg & 0x00FFFFFF) | ((uint)(view?.PanelAlpha ?? 242) << 24);
|
||||
uint boxBg = (C(0xFF0A121A) & 0x00FFFFFF) | ((uint)(view?.PanelAlpha ?? 242) << 24);
|
||||
// The host set the step these fonts are drawn at; the boxes take the same step's factor.
|
||||
_k = PanelTextScale.Factor(ImGuiFonts.CurrentStep);
|
||||
// Enlarged: tooltips and menus opened from the dashboard at its size too. (At size 0 the
|
||||
|
|
@ -185,7 +168,6 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
float x0 = start.X;
|
||||
float width = ImGuiNET.ImGui.GetContentRegionAvail().X;
|
||||
|
||||
AccentLine();
|
||||
TitleRow(raw, x0, width, minimized);
|
||||
Gap(4);
|
||||
// Popped out (no drawers there): the Profile/Nav/Loot/Meta pickers inline while expanded
|
||||
|
|
@ -257,15 +239,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
_fitWidth = width;
|
||||
}
|
||||
|
||||
/// <summary>A thin teal line along the window's top edge, inside its rounded corners.</summary>
|
||||
private static void AccentLine()
|
||||
{
|
||||
Vector2 wp = ImGuiNET.ImGui.GetWindowPos(), ws = ImGuiNET.ImGui.GetWindowSize();
|
||||
float r = RynthTheme.RynthAiRounding;
|
||||
ImGuiNET.ImGui.GetWindowDrawList().AddRectFilled(new Vector2(wp.X + r, wp.Y), new Vector2(wp.X + ws.X - r, wp.Y + MathF.Max(1.5f, Px(2))), Teal);
|
||||
}
|
||||
|
||||
// ── Title row: "R" + "YNTH", running | chips (drag surface) ──────
|
||||
// ── Title row: "R" + "YNTH" | chips (drag surface) ──────
|
||||
|
||||
private void TitleRow(RynthAiSnapshot raw, float x0, float width, bool minimized)
|
||||
{
|
||||
|
|
@ -288,19 +262,6 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
dl.AddText(title, title.FontSize, new Vector2(x0, ty), Teal, "R");
|
||||
float rw = CalcWidth(title, "R");
|
||||
dl.AddText(title, title.FontSize, new Vector2(x0 + rw, ty), White, "YNTH");
|
||||
// Running / stopped, at a glance: a dot and the word in a pill after the name.
|
||||
{
|
||||
ImFontPtr pf = ImGuiFonts.Get(UiFont.Dash9);
|
||||
bool run = raw.MacroRunning;
|
||||
string word = run ? "running" : "stopped";
|
||||
float px = x0 + rw + CalcWidth(title, "YNTH") + Px(7);
|
||||
float ph = pf.FontSize + Px(4), pw = Px(13) + CalcWidth(pf, word) + Px(6);
|
||||
float py = y + (rowH - ph) * 0.5f;
|
||||
uint col = run ? Green : Off;
|
||||
dl.AddRect(new Vector2(px, py), new Vector2(px + pw, py + ph), run ? MacroRun : BtnBord, ph * 0.5f);
|
||||
dl.AddCircleFilled(new Vector2(px + Px(7), py + ph * 0.5f), Px(2.5f), col);
|
||||
dl.AddText(pf, pf.FontSize, new Vector2(px + Px(13), py + (ph - pf.FontSize) * 0.5f), col, word);
|
||||
}
|
||||
dl.PopClipRect();
|
||||
|
||||
float cx = x0 + width - chipsW;
|
||||
|
|
@ -569,29 +530,21 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
// Macro start/stop: a square like the toggles, green with a Stop glyph while running.
|
||||
{
|
||||
bool on = raw.MacroRunning;
|
||||
// Running: a soft green halo around the square.
|
||||
if (on) dl.AddRect(new Vector2(x - Px(1.5f), y - Px(1.5f)), new Vector2(x + sq + Px(1.5f), y + sq + Px(1.5f)), RunGlow, round + Px(1.5f), ImDrawFlags.None, Px(2));
|
||||
if (IconButton("##macro", new Vector2(x, y), square, on ? PhosphorIcons.Stop : PhosphorIcons.Play,
|
||||
UiFont.Dash14, on ? MacroRun : BarBg, on ? White : Mute, on ? Green : BtnBord, round))
|
||||
RynthAiCommands.ToggleMacro();
|
||||
SafeImGui.SetItemTooltip(on ? "Macro running. Click to stop it." : "Macro stopped. Click to start it.");
|
||||
x += sqStep + Px(6);
|
||||
}
|
||||
Toggle("##t_combat", PhosphorIcons.Sword, raw.CombatEnabled, 0, new Vector2(x, y), "Combat",
|
||||
"the Monsters panel (weapons, spells and rules per monster)", PanelRouter.ToggleMonsters);
|
||||
Toggle("##t_combat", PhosphorIcons.Sword, raw.CombatEnabled, 0, new Vector2(x, y), "Combat");
|
||||
x += sqStep;
|
||||
Toggle("##t_buff", PhosphorIcons.Sparkle, raw.BuffingEnabled, 1, new Vector2(x, y), "Buffing",
|
||||
"the buffing settings", () => ShowSettingsTab("Buffing"));
|
||||
Toggle("##t_buff", PhosphorIcons.Sparkle, raw.BuffingEnabled, 1, new Vector2(x, y), "Buffing");
|
||||
x += sqStep;
|
||||
Toggle("##t_nav", PhosphorIcons.SneakerMove, raw.NavigationEnabled, 2, new Vector2(x, y), "Navigation",
|
||||
"the Nav panel (routes)", () => PanelRouter.Toggle("Nav"));
|
||||
Toggle("##t_nav", PhosphorIcons.SneakerMove, raw.NavigationEnabled, 2, new Vector2(x, y), "Navigation");
|
||||
x += sqStep;
|
||||
string lootPath = raw.CurrentLootPath ?? string.Empty;
|
||||
Toggle("##t_loot", PhosphorIcons.Bag, raw.LootingEnabled, 3, new Vector2(x, y), "Looting",
|
||||
"the Loot Editor on the loot profile in use", () => LootEditorFace.ToggleFor(lootPath));
|
||||
Toggle("##t_loot", PhosphorIcons.Bag, raw.LootingEnabled, 3, new Vector2(x, y), "Looting");
|
||||
x += sqStep;
|
||||
Toggle("##t_meta", PhosphorIcons.Code, raw.MetaEnabled, 4, new Vector2(x, y), "Meta (the macro rules)",
|
||||
"the Meta panel", () => PanelRouter.Toggle("Meta"));
|
||||
Toggle("##t_meta", PhosphorIcons.Code, raw.MetaEnabled, 4, new Vector2(x, y), "Meta (the macro rules)");
|
||||
x += sqStep;
|
||||
// RynthSort's auto-sort, when RynthSort is loaded and knows the character.
|
||||
int sort = RynthSortWatch.State;
|
||||
|
|
@ -628,19 +581,9 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
if (aRight - ax > Px(20))
|
||||
{
|
||||
string activity = view?.BotActivityText ?? "Idle";
|
||||
// A pill coloured by what the bot is doing, with its icon.
|
||||
ActivityStyle(activity, out uint fg, out uint bg, out string icon);
|
||||
float ph = MathF.Min(sq, af.FontSize + Px(6));
|
||||
float py = y + (sq - ph) * 0.5f;
|
||||
float iconW = icon.Length > 0 ? CalcWidth(af, icon) + Px(4) : 0;
|
||||
float pw = MathF.Min(aRight - ax, Px(8) + iconW + CalcWidth(af, activity) + Px(8));
|
||||
float ay = y + (sq - af.FontSize) * 0.5f;
|
||||
dl.PushClipRect(new Vector2(ax, y), new Vector2(aRight, y + sq), true);
|
||||
dl.AddRectFilled(new Vector2(ax, py), new Vector2(ax + pw, py + ph), bg, ph * 0.5f);
|
||||
float tx = ax + Px(8), ay = py + (ph - af.FontSize) * 0.5f;
|
||||
if (icon.Length > 0) dl.AddText(af, af.FontSize, new Vector2(tx, ay), fg, icon);
|
||||
dl.PushClipRect(new Vector2(ax, py), new Vector2(ax + pw - Px(6), py + ph), true);
|
||||
dl.AddText(af, af.FontSize, new Vector2(tx + iconW, ay), fg, activity);
|
||||
dl.PopClipRect();
|
||||
dl.AddText(af, af.FontSize, new Vector2(ax, ay), Amber, activity);
|
||||
dl.PopClipRect();
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(ax, y));
|
||||
ImGuiNET.ImGui.InvisibleButton("##activity", new Vector2(aRight - ax, sq));
|
||||
|
|
@ -660,47 +603,11 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.Dummy(new Vector2(width, 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A subsystem toggle: on is lit (teal, with a bar under the icon), off is dimmed so a subsystem
|
||||
/// left off stands out. Right-click runs <paramref name="onRight"/>, which opens
|
||||
/// <paramref name="rightWhat"/> (its settings).
|
||||
/// </summary>
|
||||
private void Toggle(string id, string icon, bool on, int subsystem, Vector2 pos, string name, string rightWhat, Action onRight)
|
||||
private void Toggle(string id, string icon, bool on, int subsystem, Vector2 pos, string name)
|
||||
{
|
||||
float sq = Px(Square);
|
||||
if (IconButton(id, pos, new Vector2(sq, sq), icon, UiFont.Dash14, on ? TealSoft : BarBg, on ? Teal : Off, on ? Teal : BtnBord, Px(3)))
|
||||
if (IconButton(id, pos, new Vector2(Px(Square), Px(Square)), icon, UiFont.Dash14, on ? TealSoft : BarBg, on ? Teal : Mute, on ? Teal : BtnBord, Px(3)))
|
||||
RynthAiCommands.SetSubsystemEnabled(subsystem, !on);
|
||||
bool right = ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right);
|
||||
SafeImGui.SetItemTooltip((on ? name + " on. Click to turn it off." : name + " off. Click to turn it on.") +
|
||||
"\nRight-click: " + rightWhat + ".");
|
||||
if (on)
|
||||
ImGuiNET.ImGui.GetWindowDrawList().AddRectFilled(new Vector2(pos.X + Px(5), pos.Y + sq - Px(3.5f)),
|
||||
new Vector2(pos.X + sq - Px(5), pos.Y + sq - Px(1.5f)), Teal, Px(1));
|
||||
if (right) onRight();
|
||||
}
|
||||
|
||||
/// <summary>Opens Settings (if closed) on tab <paramref name="tab"/>.</summary>
|
||||
private static void ShowSettingsTab(string tab)
|
||||
{
|
||||
SettingsFace.RequestTab(tab);
|
||||
if (!ImGuiPanelHost.IsOpen(SettingsFace.Title)) PanelRouter.Toggle(SettingsFace.Title);
|
||||
}
|
||||
|
||||
/// <summary>The activity pill's colours and icon: red in a fight, gold looting, teal moving, and so on; grey idle.</summary>
|
||||
private static void ActivityStyle(string activity, out uint fg, out uint bg, out string icon)
|
||||
{
|
||||
switch (activity)
|
||||
{
|
||||
case "Combat": fg = C(0xFFFF7A7A); bg = C(0xFF4A1A1A); icon = PhosphorIcons.Sword; break;
|
||||
case "Looting":
|
||||
case "Salvaging": fg = Amber; bg = FrFill; icon = PhosphorIcons.Bag; break;
|
||||
case "Navigating": fg = Teal; bg = TealSoft; icon = PhosphorIcons.SneakerMove; break;
|
||||
case "Buffing": fg = C(0xFFC2A8FF); bg = C(0xFF2E2350); icon = PhosphorIcons.Sparkle; break;
|
||||
case "Healing": fg = C(0xFFFF8A8A); bg = C(0xFF4A1A1A); icon = PhosphorIcons.Heart; break;
|
||||
case "Restoring mana": fg = C(0xFF6CB4FF); bg = C(0xFF15304D); icon = PhosphorIcons.Drop; break;
|
||||
case "Restoring stamina": fg = Green; bg = C(0xFF173D24); icon = PhosphorIcons.Lightning; break;
|
||||
default: fg = Mute; bg = C(0xFF1C2733); icon = ""; break;
|
||||
}
|
||||
SafeImGui.SetItemTooltip(on ? name + " on. Click to turn it off." : name + " off. Click to turn it on.");
|
||||
}
|
||||
|
||||
// ── Launchers: one row of icon buttons ──────────────────────────────
|
||||
|
|
@ -710,37 +617,36 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
private void Launchers(float x0, float width)
|
||||
{
|
||||
float y = ImGuiNET.ImGui.GetCursorScreenPos().Y;
|
||||
// Nav and Meta left the row (2026-10-14): right-click the Navigation and Meta toggles.
|
||||
// Hub left it 2026-10-15 (the Mini Remote: the bar button, Char's menu, its drawer tab).
|
||||
const int buttons = 7;
|
||||
const int buttons = 9;
|
||||
float gap = Px(LauncherGap);
|
||||
float bw = MathF.Floor((width - buttons * gap) / buttons);
|
||||
// Short labels only when every button has room for its icon and label.
|
||||
bool labels = bw >= Px(68);
|
||||
float x = x0;
|
||||
|
||||
Launcher("##l_lua", PhosphorIcons.FileCode, "Lua", "Lua scripts", x, y, bw, labels, () => PanelRouter.Toggle("Lua"),
|
||||
ImGuiPanelHost.IsOpen("Lua"));
|
||||
Launcher("##l_meta", PhosphorIcons.ListChecks, "Meta", "Meta: the macro rules", x, y, bw, labels, () => PanelRouter.Toggle("Meta"));
|
||||
x += bw + gap;
|
||||
Launcher("##l_lua", PhosphorIcons.FileCode, "Lua", "Lua scripts", x, y, bw, labels, () => PanelRouter.Toggle("Lua"));
|
||||
x += bw + gap;
|
||||
// Monsters opens the Damage panel (the basic Monsters panel and its
|
||||
// Simple/Advanced chip were retired 2026-10-01).
|
||||
Launcher("##l_mon", PhosphorIcons.Skull, "Monsters", "Monsters: weapons, spells and rules per monster (the Damage panel)",
|
||||
x, y, bw, labels, PanelRouter.ToggleMonsters, ImGuiPanelHost.IsOpen(PanelRouter.Canonical("Monsters")));
|
||||
x, y, bw, labels, PanelRouter.ToggleMonsters);
|
||||
x += bw + gap;
|
||||
Launcher("##l_set", PhosphorIcons.Gear, "Settings", "Settings", x, y, bw, labels, () => PanelRouter.Toggle("Settings"),
|
||||
ImGuiPanelHost.IsOpen(SettingsFace.Title));
|
||||
Launcher("##l_set", PhosphorIcons.Gear, "Settings", "Settings", x, y, bw, labels, () => PanelRouter.Toggle("Settings"));
|
||||
x += bw + gap;
|
||||
Launcher("##l_nav", PhosphorIcons.MapTrifold, "Nav", "Nav: routes", x, y, bw, labels, () => PanelRouter.Toggle("Nav"));
|
||||
x += bw + gap;
|
||||
Launcher("##l_map", PhosphorIcons.MapPin, "Map", "Dungeon Map (shows while you're in a dungeon)", x, y, bw, labels,
|
||||
() => PanelRouter.Toggle(DungeonMapFace.Title), ImGuiPanelHost.IsOpen(DungeonMapFace.Title));
|
||||
() => PanelRouter.Toggle(DungeonMapFace.Title));
|
||||
x += bw + gap;
|
||||
Launcher("##l_items", PhosphorIcons.Backpack, "Items", "Items", x, y, bw, labels, () => PanelRouter.Toggle("Items"),
|
||||
ImGuiPanelHost.IsOpen("Items"));
|
||||
Launcher("##l_items", PhosphorIcons.Backpack, "Items", "Items", x, y, bw, labels, () => PanelRouter.Toggle("Items"));
|
||||
x += bw + gap;
|
||||
bool popped = ImGuiPopOuts.InPopOutFrame;
|
||||
Launcher("##l_patrol", PhosphorIcons.Footprints, "Patrol",
|
||||
popped ? "Patrol. Left-click: start dungeon patrol. Right-click: routes & recorded hazards."
|
||||
: "Patrol. Left-click: start dungeon patrol. Right-click: the Patrol drawer (patrol settings, hazards and routes).",
|
||||
x, y, bw, labels, () => RynthAiCommands.SendNavCommand("{\"Cmd\":\"dunPatrol\"}"), !popped && _drawers.IsOpen(_patrol));
|
||||
: "Patrol. Left-click: start dungeon patrol. Right-click: routes & recorded hazards (the Patrol drawer, left).",
|
||||
x, y, bw, labels, () => RynthAiCommands.SendNavCommand("{\"Cmd\":\"dunPatrol\"}"));
|
||||
if (ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
||||
{
|
||||
if (popped)
|
||||
|
|
@ -753,15 +659,13 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
}
|
||||
x += bw + gap;
|
||||
|
||||
// Char opens RynthOracle's Character tab (character, level XP, session rates) since
|
||||
// 2026.10.5.54 (Infinite Leaftide's charms stay RynthILT's, in the Mini Remote's ILT tabs,
|
||||
// Char's right-click > Server); without RynthOracle, the Mini Remote's
|
||||
// Char opens RynthOracle's Character tab (character, level XP, session rates and, on
|
||||
// Infinite Leaftide, the charms) since 2026.10.5.54; without RynthOracle, the Mini Remote's
|
||||
// Session Stats section. The Mini Remote as it was left is the bar button (/rc miniremote)
|
||||
// and "Mini Remote" in Char's right-click menu; its drawer is the drawer tab on the dashboard's
|
||||
// edge. (The Hub launcher, which opened the same window, left the row 2026-10-15.)
|
||||
// and "Mini Remote" in Char's right-click menu; its drawer is the drawer tab on the dashboard's edge.
|
||||
Launcher("##l_char", PhosphorIcons.User, "Char",
|
||||
"Char. Left-click: RynthOracle's Character tab (Infinite Leaftide's charms and banking: the Mini Remote's ILT tabs). Right-click: Character windows (Mini Remote, Spells, Quests, Pets, Crafting, Fellowship, Skills, Inventory...), then Server: this server's plugin windows.",
|
||||
x, y, bw, labels, ShowCharacter, CharacterOpen());
|
||||
"Char. Left-click: RynthOracle's Character tab (charms on Infinite Leaftide). Right-click: Character windows (Mini Remote, Spells, Quests, Pets, Crafting, Fellowship, Skills, Inventory...), then Server: this server's plugin windows.",
|
||||
x, y, bw, labels, ShowCharacter);
|
||||
if (ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
||||
{
|
||||
ImGuiNET.ImGui.SetNextWindowPos(ImGuiNET.ImGui.GetItemRectMin(), ImGuiCond.Always, new Vector2(0, 1));
|
||||
|
|
@ -771,37 +675,32 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(x0, y + Px(LauncherH)));
|
||||
}
|
||||
|
||||
/// <param name="lit">Its window (or drawer) is open: teal icon and outline, with a bar along the bottom.</param>
|
||||
private void Launcher(string id, string icon, string label, string tooltip, float x, float y, float w, bool showLabel, Action? onClick, bool lit)
|
||||
private void Launcher(string id, string icon, string label, string tooltip, float x, float y, float w, bool showLabel, Action? onClick)
|
||||
{
|
||||
var pos = new Vector2(x, y);
|
||||
float lh = Px(LauncherH);
|
||||
var size = new Vector2(Math.Max(Px(10), w), lh);
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, size, ImGuiButtonFlags.MouseButtonLeft | ImGuiButtonFlags.MouseButtonRight)
|
||||
&& ImGuiNET.ImGui.IsMouseReleased(ImGuiMouseButton.Left);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, size);
|
||||
SafeImGui.SetItemTooltip(tooltip);
|
||||
bool hot = ImGuiNET.ImGui.IsItemHovered();
|
||||
uint fill = ImGuiNET.ImGui.IsItemActive() ? Darken(BtnFill) : hot ? Lighten(BtnFill) : BtnFill;
|
||||
uint fg = lit ? Teal : hot ? White : Mute;
|
||||
uint fill = ImGuiNET.ImGui.IsItemActive() ? Darken(BtnFill) : ImGuiNET.ImGui.IsItemHovered() ? Lighten(BtnFill) : BtnFill;
|
||||
dl.AddRectFilled(pos, pos + size, fill, Px(3));
|
||||
dl.AddRect(pos, pos + size, lit ? Teal : BtnBord, Px(3));
|
||||
if (lit) dl.AddRectFilled(new Vector2(pos.X + Px(3), pos.Y + lh - Px(2)), new Vector2(pos.X + size.X - Px(3), pos.Y + lh - Px(0.5f)), Teal);
|
||||
dl.AddRect(pos, pos + size, BtnBord, Px(3));
|
||||
|
||||
ImFontPtr iconFont = ImGuiFonts.Get(UiFont.Dash14);
|
||||
if (showLabel)
|
||||
{
|
||||
ImFontPtr f9 = ImGuiFonts.Get(UiFont.Dash9);
|
||||
float iconBox = Px(16);
|
||||
PhosphorIcons.DrawCentered(dl, iconFont, icon, pos + new Vector2(Px(4), 0), new Vector2(iconBox, lh), fg);
|
||||
PhosphorIcons.DrawCentered(dl, iconFont, icon, pos + new Vector2(Px(4), 0), new Vector2(iconBox, lh), Mute);
|
||||
dl.PushClipRect(pos, pos + size, true);
|
||||
dl.AddText(f9, f9.FontSize, new Vector2(pos.X + Px(4) + iconBox + Px(4), pos.Y + (lh - f9.FontSize) * 0.5f), fg, label);
|
||||
dl.AddText(f9, f9.FontSize, new Vector2(pos.X + Px(4) + iconBox + Px(4), pos.Y + (lh - f9.FontSize) * 0.5f), Mute, label);
|
||||
dl.PopClipRect();
|
||||
}
|
||||
else
|
||||
{
|
||||
PhosphorIcons.DrawCentered(dl, iconFont, icon, pos, size, fg);
|
||||
PhosphorIcons.DrawCentered(dl, iconFont, icon, pos, size, Mute);
|
||||
}
|
||||
if (clicked && onClick != null)
|
||||
{
|
||||
|
|
@ -856,9 +755,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
ImFontPtr f10 = ImGuiFonts.Get(UiFont.Dash10);
|
||||
float y = ImGuiNET.ImGui.GetCursorScreenPos().Y;
|
||||
float fpsW = CalcWidth(f10, _fpsText), upW = CalcWidth(f10, _upText);
|
||||
// FPS coloured by rate: green smooth, amber workable, red struggling.
|
||||
uint fpsCol = fps <= 0 ? Mute : fps >= 45 ? Green : fps >= 25 ? Amber : C(0xFFFF6B6B);
|
||||
dl.AddText(f10, f10.FontSize, new Vector2(x0, y), fpsCol, _fpsText);
|
||||
dl.AddText(f10, f10.FontSize, new Vector2(x0, y), Mute, _fpsText);
|
||||
dl.AddText(f10, f10.FontSize, new Vector2(x0 + width - upW, y), Mute, _upText);
|
||||
|
||||
// The version between them: centred when there's room, else after FPS, clipped short of the uptime.
|
||||
|
|
@ -872,7 +769,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
float vx = x0 + (width - vw) * 0.5f;
|
||||
if (vx < left || vx + vw > right) vx = left;
|
||||
dl.PushClipRect(new Vector2(left, y), new Vector2(right, y + f10.FontSize + Px(2)), true);
|
||||
dl.AddText(f10, f10.FontSize, new Vector2(vx, y), Faint, version);
|
||||
dl.AddText(f10, f10.FontSize, new Vector2(vx, y), Mute, version);
|
||||
dl.PopClipRect();
|
||||
}
|
||||
}
|
||||
|
|
@ -989,8 +886,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
|
||||
/// <summary>
|
||||
/// RynthOracle's Character tab ("/ro character"), or the Mini Remote's Session Stats section
|
||||
/// when RynthOracle isn't loaded. Every generic "Character" link goes here (Leaftide's Charms
|
||||
/// and Banking are RynthILT's Mini Remote tabs, in the menu's server half).
|
||||
/// when RynthOracle isn't loaded. Every "Character" / "Charms" link goes here.
|
||||
/// </summary>
|
||||
private static void ShowCharacter()
|
||||
{
|
||||
|
|
@ -998,12 +894,6 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
else UI.ServerMenus.Run("/rc miniremote section char");
|
||||
}
|
||||
|
||||
/// <summary>The Char launcher is lit: RynthOracle's window is open (else the Mini Remote on Session Stats).</summary>
|
||||
private static bool CharacterOpen() =>
|
||||
UI.ScriptWindows.ScriptWindowRegistry.Has(OracleMainKey)
|
||||
? UI.ScriptWindows.ScriptWindowRegistry.IsOpen(OracleMainKey)
|
||||
: ImGuiPanelHost.IsOpen(MiniRemoteFace.Title) && MiniRemoteFace.ShowsSection("char");
|
||||
|
||||
/// <summary>A Char menu item that toggles a registered ImGui panel (checked while open).</summary>
|
||||
private static void PanelMenuItem(string title, string command)
|
||||
{
|
||||
|
|
@ -1026,7 +916,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
bool open = has && UI.ScriptWindows.ScriptWindowRegistry.IsOpen(key);
|
||||
if (ImGuiNET.ImGui.MenuItem(label, command, open, has))
|
||||
UI.ScriptWindows.ScriptWindowRegistry.PlayerSetVisible(key, !open);
|
||||
SafeImGui.SetItemTooltip(has ? tooltip : tooltip + " (RynthOracle isn't loaded.)");
|
||||
ImGuiNET.ImGui.SetItemTooltip(has ? tooltip : tooltip + " (RynthOracle isn't loaded.)");
|
||||
}
|
||||
|
||||
private static void CharMenu()
|
||||
|
|
@ -1043,8 +933,8 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.TextDisabled("Character");
|
||||
bool hasOracle = UI.ScriptWindows.ScriptWindowRegistry.Has(OracleMainKey);
|
||||
if (ImGuiNET.ImGui.MenuItem("Character", "/ro character", false, hasOracle)) ShowCharacter();
|
||||
SafeImGui.SetItemTooltip(hasOracle
|
||||
? "RynthOracle's Character tab: level, XP and session rates. Infinite Leaftide's charms and banking are the Mini Remote's ILT tabs (Server, below)."
|
||||
ImGuiNET.ImGui.SetItemTooltip(hasOracle
|
||||
? "RynthOracle's Character tab: level, XP, session rates and (Infinite Leaftide) your charms."
|
||||
: "RynthOracle's Character tab (RynthOracle isn't loaded).");
|
||||
if (ImGuiNET.ImGui.MenuItem("Mini Remote", "/rc miniremote", ImGuiPanelHost.IsOpen(MiniRemoteFace.Title)))
|
||||
ShowMiniRemoteTab("");
|
||||
|
|
@ -1062,8 +952,9 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
if (ImGuiNET.ImGui.MenuItem("Crafting", "/rc miniremote tab crafting")) ShowMiniRemoteTab("crafting");
|
||||
ImGuiNET.ImGui.SetItemTooltip("The Mini Remote's Crafting tab: armor, weapon, jewelry and item tinkering, chunking and arrows (RynthAi).");
|
||||
// Fellowship is RynthOracle's Fellowship tab ("/ro fellowship" opens the window on it).
|
||||
if (ImGuiNET.ImGui.MenuItem("Fellowship", "/ro fellowship", false, hasOracle)) UI.ServerMenus.Run("/ro fellowship");
|
||||
SafeImGui.SetItemTooltip(hasOracle
|
||||
bool oracle = hasOracle;
|
||||
if (ImGuiNET.ImGui.MenuItem("Fellowship", "/ro fellowship", false, oracle)) UI.ServerMenus.Run("/ro fellowship");
|
||||
ImGuiNET.ImGui.SetItemTooltip(oracle
|
||||
? "RynthOracle's Fellowship tab: members, leader, open / locked, XP sharing and (Infinite Leaftide) the /fship commands."
|
||||
: "RynthOracle's Fellowship tab (RynthOracle isn't loaded).");
|
||||
PanelMenuItem(SkillsFace.Title, "/rc skills");
|
||||
|
|
@ -1112,14 +1003,14 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
if (withTitle)
|
||||
{
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Dash11));
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.Accent), PatrolTitle);
|
||||
SafeImGui.TextColored(RynthTheme.Vec(0xFF26D9E6), PatrolTitle);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
|
||||
Section("THIS DUNGEON");
|
||||
if (info.InDungeon)
|
||||
{
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.Text), $"0x{info.CurrentLandblock} · {info.CurrentHazards} hazard cell(s)");
|
||||
SafeImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC), $"0x{info.CurrentLandblock} · {info.CurrentHazards} hazard cell(s)");
|
||||
if (info.CurrentHazards > 0)
|
||||
{
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
|
|
@ -1132,24 +1023,24 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
if (Mini("Unmark"))
|
||||
RynthAiCommands.SendNavCommand("{\"Cmd\":\"unmarkHazardHere\"}", refreshPatrol: true);
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Dash9));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, RynthTheme.VecOf(RynthTheme.TextMuted));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, RynthTheme.Vec(0xFFB8C8D8));
|
||||
ImGuiNET.ImGui.TextWrapped("Stand on the lava/acid, click Mark, then re-run Patrol.");
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.TextMuted), "Not in a dungeon.");
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFB8C8D8), "Not in a dungeon.");
|
||||
}
|
||||
|
||||
Section($"RECORDED HAZARDS ({info.Dungeons.Length})");
|
||||
if (info.Dungeons.Length == 0)
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.TextMuted), "None recorded yet.");
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFB8C8D8), "None recorded yet.");
|
||||
for (int i = 0; i < info.Dungeons.Length; i++)
|
||||
{
|
||||
DungeonHazards d = info.Dungeons[i];
|
||||
ImGuiNET.ImGui.PushID(i);
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.Text), $"0x{d.Landblock} · {d.Cells} cell(s)");
|
||||
SafeImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC), $"0x{d.Landblock} · {d.Cells} cell(s)");
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
if (Mini("Clear"))
|
||||
RynthAiCommands.SendNavCommand($"{{\"Cmd\":\"clearHazards\",\"NavName\":\"{d.Landblock}\"}}", refreshPatrol: true);
|
||||
|
|
@ -1160,9 +1051,9 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
|
||||
Section($"SAVED ROUTES ({info.Routes.Length})");
|
||||
if (info.Routes.Length == 0)
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.TextMuted), "No .nav routes saved.");
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.Vec(0xFFB8C8D8), "No .nav routes saved.");
|
||||
foreach (string name in info.Routes)
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.Text), "• " + name);
|
||||
SafeImGui.TextColored(RynthTheme.Vec(0xFFF2F7FC), "• " + name);
|
||||
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
|
|
@ -1174,7 +1065,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
{
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, Px(4)));
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Dash9));
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.TextMuted), text);
|
||||
SafeImGui.TextColored(RynthTheme.Vec(0xFFB8C8D8), text);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,9 +51,8 @@ internal sealed class RynthNavArrowFace : IImGuiPanel
|
|||
/// <summary>The arrow turns with you: redraw popped out often enough to look smooth.</summary>
|
||||
public int PopOutIdleHz => 20;
|
||||
|
||||
private static readonly uint Ring = RynthTheme.Argb(0xFF1A2A39), InputBg = RynthTheme.Argb(0xFF0E1822),
|
||||
Purple = RynthTheme.Argb(0xFFB48CF0), Done = Faded(Mute);
|
||||
private static uint Glass => RynthTheme.WithAlpha(RynthTheme.Background, 0xDC);
|
||||
private static readonly uint Glass = RynthTheme.Argb(0xDC0A0F14), Ring = RynthTheme.Argb(0xFF1A2A39),
|
||||
InputBg = RynthTheme.Argb(0xFF0E1822), Purple = RynthTheme.Argb(0xFFB48CF0), Done = Faded(Mute);
|
||||
|
||||
private const int MaxRouteRows = 8;
|
||||
|
||||
|
|
|
|||
|
|
@ -57,8 +57,7 @@ internal sealed class RynthNavFace : IImGuiPanel
|
|||
}
|
||||
|
||||
private static readonly uint RunGreen = RynthTheme.Argb(0xFF40D973), Sep = RynthTheme.Argb(0xFF1A2A39),
|
||||
Gold = RynthTheme.Argb(0xFFFFD24D), Purple = RynthTheme.Argb(0xFFBF4DFF);
|
||||
private static uint RowHot => RynthTheme.Button;
|
||||
RowHot = RynthTheme.Argb(0xFF16283A), Gold = RynthTheme.Argb(0xFFFFD24D), Purple = RynthTheme.Argb(0xFFBF4DFF);
|
||||
|
||||
private const int TabGo = 0, TabAtlas = 1, TabArrow = 2;
|
||||
|
||||
|
|
@ -128,16 +127,6 @@ internal sealed class RynthNavFace : IImGuiPanel
|
|||
dl.AddText(big, big.FontSize, p + new Vector2(16, 1), Teal, "RynthNav");
|
||||
float tw = ImGuiNET.ImGui.CalcTextSize("RynthNav").X * big.FontSize / ImGuiNET.ImGui.GetFontSize();
|
||||
dl.AddText(p + new Vector2(24 + tw, 6), Mute, "go · atlas · arrow");
|
||||
if (ImGuiPanelHost.HasFace(WorldMapFace.Title))
|
||||
{
|
||||
bool mapOpen = ImGuiPanelHost.IsOpen(WorldMapFace.Title), miniOpen = ImGuiPanelHost.IsOpen(MiniMapFace.Title);
|
||||
if (Button("##rnav_worldmap", PhosphorIcons.GlobeHemisphereWest + " Map", new Vector2(p.X + w - 62, p.Y - 1), new Vector2(62, 22),
|
||||
mapOpen ? Teal : Text, mapOpen ? Selected : BtnFill, border: mapOpen ? Teal : 0))
|
||||
UI.PanelRouter.Toggle(WorldMapFace.Title);
|
||||
if (Button("##rnav_minimap", "Mini", new Vector2(p.X + w - 62 - 4 - 40, p.Y - 1), new Vector2(40, 22),
|
||||
miniOpen ? Teal : Text, miniOpen ? Selected : BtnFill, border: miniOpen ? Teal : 0))
|
||||
UI.PanelRouter.Toggle(MiniMapFace.Title);
|
||||
}
|
||||
NextLine(p, 22);
|
||||
DrawTabs(w);
|
||||
DrawStatusLine(w);
|
||||
|
|
|
|||
|
|
@ -4,10 +4,14 @@
|
|||
//
|
||||
// Draws SettingsSchema (UI/Data/SettingsData.cs), the same list the Avalonia
|
||||
// face builds from, with that face's look: 150 px tab sidebar, "Advanced
|
||||
// Settings > Tab" header, then the tab's rows (SettingsRows.cs draws and
|
||||
// edits them; right-click a row to pin it to the dashboard's My settings
|
||||
// drawer). Rows that show or hide other rows need nothing special:
|
||||
// visibility is re-evaluated every frame.
|
||||
// Settings > Tab" header, square toggle dots, - [value] + steppers (typed
|
||||
// values commit on Enter or when the field loses focus, then clamp; bad
|
||||
// input reverts), combo pickers, amber section headers, tooltips.
|
||||
//
|
||||
// Edits a private copy of the hub's settings and saves the whole copy
|
||||
// (SettingsCommands.Save) on each change; a newer fetch replaces the copy
|
||||
// only while no field here is being typed in. Rows that show or hide other
|
||||
// rows need nothing special: visibility is re-evaluated every frame.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
|
|
@ -29,23 +33,30 @@ internal sealed class SettingsFace : IImGuiPanel
|
|||
() => new SettingsFace());
|
||||
|
||||
// ── Palette (SettingsPanel's, ARGB) ─────────────────────────────────
|
||||
private static readonly uint ToggleOn = C(0xFF33FF33), ToggleOff = C(0xFF334455);
|
||||
private static uint Teal => RynthTheme.Accent;
|
||||
private static uint Amber => RynthTheme.Highlight;
|
||||
private static uint Mute => RynthTheme.TextMuted;
|
||||
private static uint TextDim => RynthTheme.Text;
|
||||
private static uint ShellBg => RynthTheme.Background;
|
||||
private static uint PanelBg => RynthTheme.Field;
|
||||
private static uint BtnFill => RynthTheme.Button;
|
||||
private static uint BtnBord => RynthTheme.Border;
|
||||
private static uint TabActive => RynthTheme.Selected;
|
||||
private static readonly uint Teal = C(0xFF26D9E6), Amber = C(0xFFE8B333), Mute = C(0xFFB8C8D8),
|
||||
TextDim = C(0xFFF2F7FC), ShellBg = C(0xFF0A0F14), PanelBg = C(0xFF141F29), BtnFill = C(0xFF16283A),
|
||||
BtnBord = C(0xFF34587A), ToggleOn = C(0xFF33FF33), ToggleOff = C(0xFF334455), TabActive = C(0xFF1A2E42);
|
||||
private static uint C(uint argb) => RynthTheme.Argb(argb);
|
||||
|
||||
private static readonly string[] Headers = BuildHeaders();
|
||||
|
||||
private RynthAiSettings _data = new();
|
||||
private long _seenVersion = -1;
|
||||
private int _tab;
|
||||
// The rows (SettingsRows.cs: the edited copy, typed values, the hotkeys editor).
|
||||
private readonly SettingsRows _rows = new();
|
||||
private bool _editing;
|
||||
|
||||
// Typed-value buffers, one per numeric row (UTF-8, NUL-terminated).
|
||||
private sealed class NumberEdit
|
||||
{
|
||||
public readonly byte[] Buffer = new byte[24];
|
||||
public double Shown = double.NaN;
|
||||
public bool Active; // the box had keyboard focus last frame
|
||||
}
|
||||
private readonly Dictionary<SettingRow, NumberEdit> _edits = new();
|
||||
// Text rows being typed in (the saved value shows again once the box loses focus).
|
||||
private readonly Dictionary<SettingRow, string> _textEdits = new();
|
||||
// The Hotkeys tab (engine-side; not part of RynthAi's settings).
|
||||
private readonly HotkeysSettingsUi _hotkeys = new();
|
||||
|
||||
// A tab asked for from outside (/rc hotkeys), taken on the next draw.
|
||||
private static volatile string? _requestedTab;
|
||||
|
|
@ -62,13 +73,19 @@ internal sealed class SettingsFace : IImGuiPanel
|
|||
public void OnHidden()
|
||||
{
|
||||
UiSources.Settings.Unsubscribe();
|
||||
_rows.LeaveHotkeys();
|
||||
_hotkeys.Leave();
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
// Take a newer fetch unless a value is being typed in.
|
||||
_rows.Sync();
|
||||
var snap = UiSources.Settings.Current;
|
||||
if (snap != null && snap.Version != _seenVersion && !_editing)
|
||||
{
|
||||
_seenVersion = snap.Version;
|
||||
_data = snap.Value.Clone();
|
||||
}
|
||||
_editing = false;
|
||||
|
||||
if (_requestedTab is { } wanted)
|
||||
{
|
||||
|
|
@ -159,7 +176,7 @@ internal sealed class SettingsFace : IImGuiPanel
|
|||
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11));
|
||||
if (_tab >= SettingsSchema.Tabs.Length) _tab = 0;
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.Accent), Headers[_tab]);
|
||||
SafeImGui.TextColored(RynthTheme.Vec(0xFF26D9E6), Headers[_tab]);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
Vector2 lp = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
|
|
@ -167,13 +184,13 @@ internal sealed class SettingsFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.Dummy(new Vector2(0, 6));
|
||||
|
||||
SettingRow[] rows = SettingsSchema.Tabs[_tab].Rows;
|
||||
if (SettingsSchema.Tabs[_tab].Name != HotkeysSettingsUi.TabName) _rows.LeaveHotkeys();
|
||||
if (SettingsSchema.Tabs[_tab].Name != HotkeysSettingsUi.TabName) _hotkeys.Leave();
|
||||
for (int i = 0; i < rows.Length; i++)
|
||||
{
|
||||
SettingRow row = rows[i];
|
||||
if (!row.IsVisible(_rows.Data)) continue;
|
||||
if (!row.IsVisible(_data)) continue;
|
||||
ImGuiNET.ImGui.PushID(i);
|
||||
_rows.DrawRow(row, w);
|
||||
DrawRow(row, w);
|
||||
ImGuiNET.ImGui.PopID();
|
||||
}
|
||||
|
||||
|
|
@ -181,6 +198,376 @@ internal sealed class SettingsFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.EndChild();
|
||||
}
|
||||
|
||||
private void DrawRow(SettingRow row, float w)
|
||||
{
|
||||
switch (row.Kind)
|
||||
{
|
||||
case SettingKind.Bool: BoolRow(row, w); break;
|
||||
case SettingKind.Int:
|
||||
case SettingKind.Float:
|
||||
case SettingKind.Double: NumberRow(row, w); break;
|
||||
case SettingKind.Combo: ComboRow(row, w); break;
|
||||
case SettingKind.Section: Section(row.Label, w); break;
|
||||
case SettingKind.Spacer: ImGuiNET.ImGui.Dummy(new Vector2(0, 6)); break;
|
||||
case SettingKind.Note: Note(row.Label, w); break;
|
||||
case SettingKind.CraftingStatus: CraftingStatus(row); break;
|
||||
case SettingKind.Button: ButtonRow(row, w); break;
|
||||
case SettingKind.TraceCategories: TraceCategoriesRow(row, w); break;
|
||||
case SettingKind.Text: TextRow(row, w); break;
|
||||
case SettingKind.Status: StatusRow(row, w); break;
|
||||
case SettingKind.Hotkeys: _editing |= _hotkeys.Draw(w); break;
|
||||
case SettingKind.ServerPick: ServerPickSettingsUi.Draw(w, row.Tooltip); break;
|
||||
}
|
||||
}
|
||||
|
||||
// [All on] [All off], then a 3-column grid of square toggles, one per
|
||||
// RynthAi trace category. Edits the copy's DiagCategories and saves like any other row.
|
||||
private void TraceCategoriesRow(SettingRow row, float w)
|
||||
{
|
||||
var cats = TraceCategoryLevels.Parse(_data.DiagCategories);
|
||||
if (cats.Count == 0)
|
||||
{
|
||||
Note("Waiting for RynthAi...", w);
|
||||
return;
|
||||
}
|
||||
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
if (ImGuiNET.ImGui.Button("All on")) SaveCategories(TraceCategoryLevels.Set(_data.DiagCategories, "", true));
|
||||
ImGuiNET.ImGui.SameLine(0, 6);
|
||||
if (ImGuiNET.ImGui.Button("All off")) SaveCategories(TraceCategoryLevels.Set(_data.DiagCategories, "", false));
|
||||
Tooltip(row);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
float colW = Math.Max(80f, w / 3f);
|
||||
int perRow = Math.Max(1, (int)(w / colW));
|
||||
Vector2 start = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
for (int i = 0; i < cats.Count; i++)
|
||||
{
|
||||
var (name, level) = cats[i];
|
||||
bool on = level != TraceCategoryLevels.Off;
|
||||
string label = TraceCategoryLevels.Label(name, level);
|
||||
var p = start + new Vector2(i % perRow * colW, i / perRow * 18f);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(p);
|
||||
ImGuiNET.ImGui.PushID(name);
|
||||
if (ImGuiNET.ImGui.InvisibleButton("##cat", new Vector2(colW - 4, 16)))
|
||||
SaveCategories(TraceCategoryLevels.Set(_data.DiagCategories, name, !on));
|
||||
if (ImGuiNET.ImGui.IsItemHovered()) ImGuiNET.ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
|
||||
ImGuiNET.ImGui.PopID();
|
||||
dl.AddRectFilled(p + new Vector2(0, 2), p + new Vector2(12, 14), on ? ToggleOn : ToggleOff, 2);
|
||||
dl.PushClipRect(p, p + new Vector2(colW - 4, 16), true);
|
||||
dl.AddText(p + new Vector2(18, (16 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, label);
|
||||
dl.PopClipRect();
|
||||
}
|
||||
int rowsUsed = (cats.Count + perRow - 1) / perRow;
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(start + new Vector2(0, rowsUsed * 18f));
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
}
|
||||
|
||||
private void SaveCategories(string levels)
|
||||
{
|
||||
_data.DiagCategories = levels;
|
||||
SettingsCommands.Save(_data.Clone());
|
||||
}
|
||||
|
||||
// Label, then a full-width box; the value commits on Enter or focus loss (like the number boxes).
|
||||
private void TextRow(SettingRow row, float w)
|
||||
{
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, TextDim);
|
||||
ImGuiNET.ImGui.TextUnformatted(row.Label);
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
Tooltip(row);
|
||||
|
||||
string saved = row.GetText?.Invoke(_data) ?? string.Empty;
|
||||
string text = _textEdits.TryGetValue(row, out string? typing) ? typing : saved;
|
||||
ImGuiNET.ImGui.SetNextItemWidth(Math.Max(80, w - 4));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, PanelBg);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Amber);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1f);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0f);
|
||||
bool enter = ImGuiNET.ImGui.InputTextWithHint("##text", row.Hint ?? string.Empty, ref text, 512u,
|
||||
ImGuiInputTextFlags.EnterReturnsTrue);
|
||||
bool active = ImGuiNET.ImGui.IsItemActive();
|
||||
bool committed = enter || ImGuiNET.ImGui.IsItemDeactivatedAfterEdit();
|
||||
ImGuiNET.ImGui.PopStyleVar(2);
|
||||
ImGuiNET.ImGui.PopStyleColor(3);
|
||||
Tooltip(row);
|
||||
_editing |= active;
|
||||
|
||||
if (committed)
|
||||
{
|
||||
_textEdits.Remove(row);
|
||||
if (!string.Equals(text, saved, StringComparison.Ordinal))
|
||||
{
|
||||
row.SetText?.Invoke(_data, text);
|
||||
SettingsCommands.Save(_data.Clone());
|
||||
}
|
||||
}
|
||||
else if (active) _textEdits[row] = text;
|
||||
else _textEdits.Remove(row);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
}
|
||||
|
||||
// RynthAi's one-line status (teal), wrapped to the column.
|
||||
private void StatusRow(SettingRow row, float w)
|
||||
{
|
||||
string text = row.GetText?.Invoke(_data) ?? string.Empty;
|
||||
if (text.Length == 0) return;
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Teal);
|
||||
ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + w);
|
||||
ImGuiNET.ImGui.TextUnformatted(text);
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
}
|
||||
|
||||
// Label | [caption]; Edit changes the copy and saves it like any other row, Click posts its
|
||||
// own work (never runs plugin code on AC's thread).
|
||||
private void ButtonRow(SettingRow row, float w)
|
||||
{
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, TextDim);
|
||||
ImGuiNET.ImGui.AlignTextToFramePadding();
|
||||
ImGuiNET.ImGui.TextUnformatted(row.Label);
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
ImGuiNET.ImGui.SameLine(Math.Max(ImGuiNET.ImGui.GetCursorPosX() + 8, w * 0.45f));
|
||||
if (ImGuiNET.ImGui.Button(row.ButtonText ?? row.Label))
|
||||
{
|
||||
if (row.Edit != null)
|
||||
{
|
||||
row.Edit(_data);
|
||||
SettingsCommands.Save(_data.Clone());
|
||||
}
|
||||
row.Click?.Invoke();
|
||||
}
|
||||
Tooltip(row);
|
||||
}
|
||||
|
||||
private void Changed(SettingRow row, double value)
|
||||
{
|
||||
row.Set!(_data, value);
|
||||
SettingsCommands.Save(_data.Clone());
|
||||
}
|
||||
|
||||
// Square dot + label; the whole row toggles.
|
||||
private void BoolRow(SettingRow row, float w)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
bool on = row.Get!(_data) != 0;
|
||||
float labelW = ImGuiNET.ImGui.CalcTextSize(row.Label).X;
|
||||
if (ImGuiNET.ImGui.InvisibleButton("##b", new Vector2(Math.Min(w, 18 + labelW), 16)))
|
||||
Changed(row, on ? 0 : 1);
|
||||
if (ImGuiNET.ImGui.IsItemHovered()) ImGuiNET.ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
|
||||
Tooltip(row);
|
||||
dl.AddRectFilled(p + new Vector2(0, 2), p + new Vector2(12, 14), on ? ToggleOn : ToggleOff, 2);
|
||||
dl.AddText(p + new Vector2(18, (16 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, row.Label);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
}
|
||||
|
||||
// Label | [-] [value] [+]; the value commits on Enter or focus loss.
|
||||
private void NumberRow(SettingRow row, float w)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
bool isInt = row.Kind == SettingKind.Int;
|
||||
float boxW = isInt ? 52 : 64, boxCol = isInt ? 56 : 68;
|
||||
double value = Math.Clamp(row.Get!(_data), row.Min, row.Max);
|
||||
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
float right = p.X + w;
|
||||
dl.AddText(p + new Vector2(0, (22 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, row.Label);
|
||||
ImGuiNET.ImGui.InvisibleButton("##label", new Vector2(Math.Max(1, w - 40 - boxCol), 22));
|
||||
Tooltip(row);
|
||||
|
||||
float plusX = right - 20, boxX = plusX - boxCol + (boxCol - boxW) * 0.5f, minusX = right - 20 - boxCol - 20;
|
||||
if (StepButton("##minus", new Vector2(minusX + 1, p.Y + 1), PhosphorIcons.Minus))
|
||||
Changed(row, Math.Clamp(value - row.Step, row.Min, row.Max));
|
||||
|
||||
// Typed value (amber on the panel colour).
|
||||
NumberEdit edit = EditFor(row);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(boxX, p.Y + 1));
|
||||
ImGuiNET.ImGui.SetNextItemWidth(boxW);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, PanelBg);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Amber);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1f);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(4, (20 - ImGuiNET.ImGui.GetFontSize()) * 0.5f));
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0f);
|
||||
if (!edit.Active && edit.Shown != value)
|
||||
WriteValue(edit, value, isInt);
|
||||
ImGuiNET.ImGui.InputText("##v", edit.Buffer, (uint)edit.Buffer.Length,
|
||||
ImGuiInputTextFlags.CharsDecimal | ImGuiInputTextFlags.AutoSelectAll);
|
||||
bool active = ImGuiNET.ImGui.IsItemActive();
|
||||
edit.Active = active;
|
||||
_editing |= active;
|
||||
if (ImGuiNET.ImGui.IsItemDeactivatedAfterEdit())
|
||||
{
|
||||
if (TryParse(edit.Buffer, out double typed))
|
||||
{
|
||||
double clamped = Math.Clamp(isInt ? Math.Round(typed) : typed, row.Min, row.Max);
|
||||
Changed(row, clamped);
|
||||
WriteValue(edit, clamped, isInt);
|
||||
}
|
||||
else WriteValue(edit, value, isInt); // bad input reverts
|
||||
}
|
||||
ImGuiNET.ImGui.PopStyleVar(3);
|
||||
ImGuiNET.ImGui.PopStyleColor(3);
|
||||
|
||||
if (StepButton("##plus", new Vector2(plusX + 1, p.Y + 1), PhosphorIcons.Plus))
|
||||
Changed(row, Math.Clamp(value + row.Step, row.Min, row.Max));
|
||||
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + 22));
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
}
|
||||
|
||||
private NumberEdit EditFor(SettingRow row)
|
||||
{
|
||||
if (!_edits.TryGetValue(row, out NumberEdit? e))
|
||||
_edits[row] = e = new NumberEdit();
|
||||
return e;
|
||||
}
|
||||
|
||||
private static void WriteValue(NumberEdit edit, double value, bool isInt)
|
||||
{
|
||||
string text = isInt ? ((long)Math.Round(value)).ToString(CultureInfo.InvariantCulture)
|
||||
: value.ToString("G4", CultureInfo.InvariantCulture);
|
||||
int n = Encoding.UTF8.GetBytes(text, 0, text.Length, edit.Buffer, 0);
|
||||
edit.Buffer[Math.Min(n, edit.Buffer.Length - 1)] = 0;
|
||||
edit.Shown = value;
|
||||
}
|
||||
|
||||
private static bool TryParse(byte[] buffer, out double value)
|
||||
{
|
||||
int len = Array.IndexOf(buffer, (byte)0);
|
||||
if (len < 0) len = buffer.Length;
|
||||
return double.TryParse(Encoding.UTF8.GetString(buffer, 0, len), NumberStyles.Float, CultureInfo.InvariantCulture, out value);
|
||||
}
|
||||
|
||||
// Label | [current item]; click opens a 220 px list with the current item highlighted.
|
||||
private void ComboRow(SettingRow row, float w)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
string[] items = row.Items!;
|
||||
int current = Math.Clamp((int)row.Get!(_data), 0, items.Length - 1);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
dl.AddText(p + new Vector2(0, (22 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, row.Label);
|
||||
|
||||
ImFontPtr f10 = ImGuiFonts.Get(UiFont.Ui10);
|
||||
const float btnW = 160;
|
||||
var bp = new Vector2(p.X + w - btnW, p.Y + 1);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(bp);
|
||||
if (ImGuiNET.ImGui.InvisibleButton("##combo", new Vector2(btnW, 20)))
|
||||
{
|
||||
ImGuiNET.ImGui.SetNextWindowPos(new Vector2(Math.Max(bp.X + btnW - 220, 0), bp.Y + 20));
|
||||
ImGuiNET.ImGui.OpenPopup("##combo_list");
|
||||
}
|
||||
bool hot = ImGuiNET.ImGui.IsItemHovered();
|
||||
Tooltip(row);
|
||||
dl.AddRectFilled(bp, bp + new Vector2(btnW, 20), hot ? Lighten(BtnFill) : BtnFill);
|
||||
dl.AddRect(bp, bp + new Vector2(btnW, 20), BtnBord);
|
||||
dl.PushClipRect(bp, bp + new Vector2(btnW - 16, 20), true);
|
||||
dl.AddText(f10, f10.FontSize, bp + new Vector2(4, (20 - f10.FontSize) * 0.5f), TextDim, items[current]);
|
||||
dl.PopClipRect();
|
||||
PhosphorIcons.DrawCentered(dl, f10, PhosphorIcons.CaretDown, bp + new Vector2(btnW - 16, 0), new Vector2(14, 20), Mute);
|
||||
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, ShellBg);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, Teal);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.PopupRounding, 4f);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(2, 2));
|
||||
ImGuiNET.ImGui.SetNextWindowSize(new Vector2(220, items.Length * 21 + 4));
|
||||
bool open = ImGuiNET.ImGui.BeginPopup("##combo_list");
|
||||
ImGuiNET.ImGui.PopStyleVar(2);
|
||||
ImGuiNET.ImGui.PopStyleColor(2);
|
||||
if (open)
|
||||
{
|
||||
var pdl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
float iw = ImGuiNET.ImGui.GetContentRegionAvail().X;
|
||||
for (int i = 0; i < items.Length; i++)
|
||||
{
|
||||
ImGuiNET.ImGui.PushID(i);
|
||||
Vector2 ip = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
bool picked = ImGuiNET.ImGui.InvisibleButton("##item", new Vector2(iw, 20));
|
||||
bool ih = ImGuiNET.ImGui.IsItemHovered();
|
||||
ImGuiNET.ImGui.PopID();
|
||||
bool sel = i == current;
|
||||
pdl.AddRectFilled(ip, ip + new Vector2(iw, 20), sel ? TabActive : ih ? Lighten(BtnFill) : BtnFill);
|
||||
pdl.AddRect(ip, ip + new Vector2(iw, 20), BtnBord);
|
||||
pdl.AddText(f10, f10.FontSize, ip + new Vector2(6, (20 - f10.FontSize) * 0.5f), sel ? Teal : TextDim, items[i]);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 1));
|
||||
if (picked)
|
||||
{
|
||||
Changed(row, i);
|
||||
ImGuiNET.ImGui.CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
ImGuiNET.ImGui.EndPopup();
|
||||
}
|
||||
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + 22));
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
}
|
||||
|
||||
private static void Section(string text, float w)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
ImFontPtr bold = ImGuiFonts.Get(UiFont.UiBold11);
|
||||
float h = bold.FontSize + 4;
|
||||
dl.AddRectFilled(p, p + new Vector2(w, h), TabActive);
|
||||
dl.AddText(bold, bold.FontSize, p + new Vector2(4, 2), Amber, text);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(w, h));
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
}
|
||||
|
||||
private static void Note(string text, float w)
|
||||
{
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
bool small = !text.StartsWith('(');
|
||||
if (small) ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui10));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Mute);
|
||||
ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + w);
|
||||
ImGuiNET.ImGui.TextUnformatted(text);
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
if (small) ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
|
||||
private void CraftingStatus(SettingRow row)
|
||||
{
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
SafeImGui.TextColored(RynthTheme.Vec(0xFFB8C8D8), row.Label);
|
||||
ImGuiNET.ImGui.SameLine(0, 6);
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11));
|
||||
SafeImGui.TextColored(RynthTheme.Vec(_data.MissileCraftingActive ? 0xFFE8B333 : 0xFFB8C8D8), _data.MissileCraftingState);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
if (!string.IsNullOrEmpty(_data.MissileCraftingStatus))
|
||||
{
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui10));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, TextDim);
|
||||
SafeImGui.TextWrapped(_data.MissileCraftingStatus);
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
}
|
||||
|
||||
private static bool StepButton(string id, Vector2 pos, string glyph)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, new Vector2(18, 20));
|
||||
uint bg = ImGuiNET.ImGui.IsItemActive() ? Darken(BtnFill) : ImGuiNET.ImGui.IsItemHovered() ? Lighten(BtnFill) : BtnFill;
|
||||
dl.AddRectFilled(pos, pos + new Vector2(18, 20), bg);
|
||||
dl.AddRect(pos, pos + new Vector2(18, 20), BtnBord);
|
||||
PhosphorIcons.DrawCentered(dl, ImGuiFonts.Get(UiFont.Ui11), glyph, pos, new Vector2(18, 20), TextDim);
|
||||
return clicked;
|
||||
}
|
||||
|
||||
// Tab icons by tab name (SettingsSchema); a tab not listed shows its name alone.
|
||||
private static readonly System.Collections.Generic.Dictionary<string, string> TabIcons = new()
|
||||
{
|
||||
|
|
@ -210,6 +597,11 @@ internal sealed class SettingsFace : IImGuiPanel
|
|||
return label;
|
||||
}
|
||||
|
||||
private static void Tooltip(SettingRow row)
|
||||
{
|
||||
if (row.Tooltip != null) SafeImGui.SetItemTooltip(row.Tooltip);
|
||||
}
|
||||
|
||||
private static uint Lighten(uint abgr) => Scale(abgr, 1.25f, 12);
|
||||
private static uint Darken(uint abgr) => Scale(abgr, 0.8f, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,543 +0,0 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/SettingsRows.cs
|
||||
// Draws rows of the Settings schema (UI/Data/SettingsData.cs) with the
|
||||
// Settings panel's look: square toggle dots, - [value] + steppers (typed
|
||||
// values commit on Enter or when the field loses focus, then clamp; bad
|
||||
// input reverts), combo pickers, amber section headers, tooltips. Moved out
|
||||
// of SettingsFace (2026-10-14) so the dashboard's drawers draw the same rows:
|
||||
// My settings (QuickSettingsDrawer.cs) and the Patrol drawer's settings.
|
||||
//
|
||||
// Each user keeps a private copy of the hub's settings and saves the whole
|
||||
// copy (SettingsCommands.Save) on each change; a newer fetch replaces the
|
||||
// copy only while none of its fields is being typed in (Sync, once a frame).
|
||||
// The owner subscribes UiSources.Settings while it shows.
|
||||
//
|
||||
// Right-click a row: Pin to / Remove from My settings (UI/QuickSettings.cs),
|
||||
// plus whatever the owner adds (the drawer's Move up / down).
|
||||
// AC thread only.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.UI;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
internal sealed class SettingsRows
|
||||
{
|
||||
// ── Palette (SettingsPanel's, ARGB) ─────────────────────────────────
|
||||
private static readonly uint ToggleOn = C(0xFF33FF33), ToggleOff = C(0xFF334455);
|
||||
private static uint Teal => RynthTheme.Accent;
|
||||
private static uint Amber => RynthTheme.Highlight;
|
||||
private static uint Mute => RynthTheme.TextMuted;
|
||||
private static uint TextDim => RynthTheme.Text;
|
||||
private static uint ShellBg => RynthTheme.Background;
|
||||
private static uint PanelBg => RynthTheme.Field;
|
||||
private static uint BtnFill => RynthTheme.Button;
|
||||
private static uint BtnBord => RynthTheme.Border;
|
||||
private static uint TabActive => RynthTheme.Selected;
|
||||
private static uint C(uint argb) => RynthTheme.Argb(argb);
|
||||
|
||||
private RynthAiSettings _data = new();
|
||||
private long _seenVersion = -1;
|
||||
private bool _editing;
|
||||
|
||||
// Typed-value buffers, one per numeric row (UTF-8, NUL-terminated).
|
||||
private sealed class NumberEdit
|
||||
{
|
||||
public readonly byte[] Buffer = new byte[24];
|
||||
public double Shown = double.NaN;
|
||||
public bool Active; // the box had keyboard focus last frame
|
||||
}
|
||||
private readonly Dictionary<SettingRow, NumberEdit> _edits = new();
|
||||
// Text rows being typed in (the saved value shows again once the box loses focus).
|
||||
private readonly Dictionary<SettingRow, string> _textEdits = new();
|
||||
// The Hotkeys tab (engine-side; not part of RynthAi's settings).
|
||||
private readonly HotkeysSettingsUi _hotkeys = new();
|
||||
|
||||
/// <summary>The copy being edited (the last fetch, plus this view's own changes).</summary>
|
||||
public RynthAiSettings Data => _data;
|
||||
|
||||
/// <summary>Once a frame, before the rows: takes a newer fetch unless a value is being typed in.</summary>
|
||||
public void Sync()
|
||||
{
|
||||
var snap = UiSources.Settings.Current;
|
||||
if (snap != null && snap.Version != _seenVersion && !_editing)
|
||||
{
|
||||
_seenVersion = snap.Version;
|
||||
_data = snap.Value.Clone();
|
||||
}
|
||||
_editing = false;
|
||||
}
|
||||
|
||||
/// <summary>The hotkeys editor's tab was left (or the panel closed).</summary>
|
||||
public void LeaveHotkeys() => _hotkeys.Leave();
|
||||
|
||||
/// <summary>
|
||||
/// One row at the cursor, <paramref name="w"/> wide. The caller pushes an ID per row.
|
||||
/// <paramref name="pinMenu"/>: right-click offers Pin to / Remove from My settings;
|
||||
/// <paramref name="extraMenu"/> adds items to that menu (given the row's pin key).
|
||||
/// </summary>
|
||||
public void DrawRow(SettingRow row, float w, bool pinMenu = true, Action<string>? extraMenu = null)
|
||||
{
|
||||
Vector2 top = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
DrawRowBody(row, w);
|
||||
if (!pinMenu) return;
|
||||
string? key = QuickSettings.KeyOf(row);
|
||||
if (key == null) return;
|
||||
Vector2 bottom = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
if (ImGuiNET.ImGui.IsMouseClicked(ImGuiMouseButton.Right)
|
||||
&& ImGuiNET.ImGui.IsWindowHovered(ImGuiHoveredFlags.AllowWhenBlockedByActiveItem)
|
||||
&& ImGuiNET.ImGui.IsMouseHoveringRect(top, new Vector2(top.X + w, MathF.Max(bottom.Y, top.Y + 4))))
|
||||
ImGuiNET.ImGui.OpenPopup("##pin_menu");
|
||||
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, ShellBg);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(8, 6));
|
||||
bool open = ImGuiNET.ImGui.BeginPopup("##pin_menu");
|
||||
ImGuiNET.ImGui.PopStyleVar();
|
||||
ImGuiNET.ImGui.PopStyleColor(2);
|
||||
if (!open) return;
|
||||
try
|
||||
{
|
||||
bool pinned = QuickSettings.IsPinned(key);
|
||||
if (ImGuiNET.ImGui.MenuItem(pinned ? PhosphorIcons.X + " Remove from My settings" : PhosphorIcons.PushPin + " Pin to My settings"))
|
||||
QuickSettings.SetPinned(key, !pinned);
|
||||
SafeImGui.SetItemTooltip(pinned
|
||||
? "Take it out of the My settings drawer on the dashboard (the setting itself doesn't change)."
|
||||
: "Add it to the My settings drawer on the dashboard, for quick changes.");
|
||||
extraMenu?.Invoke(key);
|
||||
}
|
||||
finally { ImGuiNET.ImGui.EndPopup(); }
|
||||
}
|
||||
|
||||
private void DrawRowBody(SettingRow row, float w)
|
||||
{
|
||||
switch (row.Kind)
|
||||
{
|
||||
case SettingKind.Bool: BoolRow(row, w); break;
|
||||
case SettingKind.Int:
|
||||
case SettingKind.Float:
|
||||
case SettingKind.Double: NumberRow(row, w); break;
|
||||
case SettingKind.Combo: ComboRow(row, w); break;
|
||||
case SettingKind.Section: Section(row.Label, w); break;
|
||||
case SettingKind.Spacer: ImGuiNET.ImGui.Dummy(new Vector2(0, 6)); break;
|
||||
case SettingKind.Note: Note(row.Label, w); break;
|
||||
case SettingKind.CraftingStatus: CraftingStatus(row); break;
|
||||
case SettingKind.Button: ButtonRow(row, w); break;
|
||||
case SettingKind.TraceCategories: TraceCategoriesRow(row, w); break;
|
||||
case SettingKind.Text: TextRow(row, w); break;
|
||||
case SettingKind.Status: StatusRow(row, w); break;
|
||||
case SettingKind.Hotkeys: _editing |= _hotkeys.Draw(w); break;
|
||||
case SettingKind.ServerPick: ServerPickSettingsUi.Draw(w, row.Tooltip); break;
|
||||
case SettingKind.Color: ColorRow(row, w); break;
|
||||
}
|
||||
}
|
||||
|
||||
// [All on] [All off], then a 3-column grid of square toggles, one per
|
||||
// RynthAi trace category. Edits the copy's DiagCategories and saves like any other row.
|
||||
private void TraceCategoriesRow(SettingRow row, float w)
|
||||
{
|
||||
var cats = TraceCategoryLevels.Parse(_data.DiagCategories);
|
||||
if (cats.Count == 0)
|
||||
{
|
||||
Note("Waiting for RynthAi...", w);
|
||||
return;
|
||||
}
|
||||
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
if (ImGuiNET.ImGui.Button("All on")) SaveCategories(TraceCategoryLevels.Set(_data.DiagCategories, "", true));
|
||||
ImGuiNET.ImGui.SameLine(0, 6);
|
||||
if (ImGuiNET.ImGui.Button("All off")) SaveCategories(TraceCategoryLevels.Set(_data.DiagCategories, "", false));
|
||||
Tooltip(row);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
float colW = Math.Max(80f, w / 3f);
|
||||
int perRow = Math.Max(1, (int)(w / colW));
|
||||
Vector2 start = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
for (int i = 0; i < cats.Count; i++)
|
||||
{
|
||||
var (name, level) = cats[i];
|
||||
bool on = level != TraceCategoryLevels.Off;
|
||||
string label = TraceCategoryLevels.Label(name, level);
|
||||
var p = start + new Vector2(i % perRow * colW, i / perRow * 18f);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(p);
|
||||
ImGuiNET.ImGui.PushID(name);
|
||||
if (ImGuiNET.ImGui.InvisibleButton("##cat", new Vector2(colW - 4, 16)))
|
||||
SaveCategories(TraceCategoryLevels.Set(_data.DiagCategories, name, !on));
|
||||
if (ImGuiNET.ImGui.IsItemHovered()) ImGuiNET.ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
|
||||
ImGuiNET.ImGui.PopID();
|
||||
dl.AddRectFilled(p + new Vector2(0, 2), p + new Vector2(12, 14), on ? ToggleOn : ToggleOff, 2);
|
||||
dl.PushClipRect(p, p + new Vector2(colW - 4, 16), true);
|
||||
dl.AddText(p + new Vector2(18, (16 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, label);
|
||||
dl.PopClipRect();
|
||||
}
|
||||
int rowsUsed = (cats.Count + perRow - 1) / perRow;
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(start + new Vector2(0, rowsUsed * 18f));
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
}
|
||||
|
||||
private void SaveCategories(string levels)
|
||||
{
|
||||
_data.DiagCategories = levels;
|
||||
SettingsCommands.Save(_data.Clone());
|
||||
}
|
||||
|
||||
// Label, then a full-width box; the value commits on Enter or focus loss (like the number boxes).
|
||||
private void TextRow(SettingRow row, float w)
|
||||
{
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, TextDim);
|
||||
ImGuiNET.ImGui.TextUnformatted(row.Label);
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
Tooltip(row);
|
||||
|
||||
string saved = row.GetText?.Invoke(_data) ?? string.Empty;
|
||||
string text = _textEdits.TryGetValue(row, out string? typing) ? typing : saved;
|
||||
ImGuiNET.ImGui.SetNextItemWidth(Math.Max(80, w - 4));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, PanelBg);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Amber);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1f);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0f);
|
||||
bool enter = ImGuiNET.ImGui.InputTextWithHint("##text", row.Hint ?? string.Empty, ref text, 512u,
|
||||
ImGuiInputTextFlags.EnterReturnsTrue);
|
||||
bool active = ImGuiNET.ImGui.IsItemActive();
|
||||
bool committed = enter || ImGuiNET.ImGui.IsItemDeactivatedAfterEdit();
|
||||
ImGuiNET.ImGui.PopStyleVar(2);
|
||||
ImGuiNET.ImGui.PopStyleColor(3);
|
||||
Tooltip(row);
|
||||
_editing |= active;
|
||||
|
||||
if (committed)
|
||||
{
|
||||
_textEdits.Remove(row);
|
||||
if (!string.Equals(text, saved, StringComparison.Ordinal))
|
||||
{
|
||||
row.SetText?.Invoke(_data, text);
|
||||
SettingsCommands.Save(_data.Clone());
|
||||
}
|
||||
}
|
||||
else if (active) _textEdits[row] = text;
|
||||
else _textEdits.Remove(row);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
}
|
||||
|
||||
// RynthAi's one-line status (teal), wrapped to the column.
|
||||
private void StatusRow(SettingRow row, float w)
|
||||
{
|
||||
string text = row.GetText?.Invoke(_data) ?? string.Empty;
|
||||
if (text.Length == 0) return;
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Teal);
|
||||
ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + w);
|
||||
ImGuiNET.ImGui.TextUnformatted(text);
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
}
|
||||
|
||||
// Label | [caption]; Click posts its own work (never runs plugin code on AC's thread).
|
||||
private static void ButtonRow(SettingRow row, float w)
|
||||
{
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, TextDim);
|
||||
ImGuiNET.ImGui.AlignTextToFramePadding();
|
||||
ImGuiNET.ImGui.TextUnformatted(row.Label);
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
ImGuiNET.ImGui.SameLine(Math.Max(ImGuiNET.ImGui.GetCursorPosX() + 8, w * 0.45f));
|
||||
if (ImGuiNET.ImGui.Button(row.ButtonText ?? row.Label))
|
||||
row.Click?.Invoke();
|
||||
Tooltip(row);
|
||||
}
|
||||
|
||||
private void Changed(SettingRow row, double value)
|
||||
{
|
||||
row.Set!(_data, value);
|
||||
SettingsCommands.Save(_data.Clone());
|
||||
}
|
||||
|
||||
// Square dot + label; the whole row toggles.
|
||||
private void BoolRow(SettingRow row, float w)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
bool on = row.Get!(_data) != 0;
|
||||
float labelW = ImGuiNET.ImGui.CalcTextSize(row.Label).X;
|
||||
if (ImGuiNET.ImGui.InvisibleButton("##b", new Vector2(Math.Min(w, 18 + labelW), 16)))
|
||||
Changed(row, on ? 0 : 1);
|
||||
if (ImGuiNET.ImGui.IsItemHovered()) ImGuiNET.ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
|
||||
Tooltip(row);
|
||||
dl.AddRectFilled(p + new Vector2(0, 2), p + new Vector2(12, 14), on ? ToggleOn : ToggleOff, 2);
|
||||
dl.AddText(p + new Vector2(18, (16 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, row.Label);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
}
|
||||
|
||||
// Label | [-] [value] [+]; the value commits on Enter or focus loss.
|
||||
private void NumberRow(SettingRow row, float w)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
bool isInt = row.Kind == SettingKind.Int;
|
||||
float boxW = isInt ? 52 : 64, boxCol = isInt ? 56 : 68;
|
||||
double value = Math.Clamp(row.Get!(_data), row.Min, row.Max);
|
||||
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
float right = p.X + w;
|
||||
dl.AddText(p + new Vector2(0, (22 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, row.Label);
|
||||
ImGuiNET.ImGui.InvisibleButton("##label", new Vector2(Math.Max(1, w - 40 - boxCol), 22));
|
||||
Tooltip(row);
|
||||
|
||||
float plusX = right - 20, boxX = plusX - boxCol + (boxCol - boxW) * 0.5f, minusX = right - 20 - boxCol - 20;
|
||||
if (StepButton("##minus", new Vector2(minusX + 1, p.Y + 1), PhosphorIcons.Minus))
|
||||
Changed(row, Math.Clamp(value - row.Step, row.Min, row.Max));
|
||||
|
||||
// Typed value (amber on the panel colour).
|
||||
NumberEdit edit = EditFor(row);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(boxX, p.Y + 1));
|
||||
ImGuiNET.ImGui.SetNextItemWidth(boxW);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, PanelBg);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Amber);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1f);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(4, (20 - ImGuiNET.ImGui.GetFontSize()) * 0.5f));
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0f);
|
||||
if (!edit.Active && edit.Shown != value)
|
||||
WriteValue(edit, value, isInt);
|
||||
ImGuiNET.ImGui.InputText("##v", edit.Buffer, (uint)edit.Buffer.Length,
|
||||
ImGuiInputTextFlags.CharsDecimal | ImGuiInputTextFlags.AutoSelectAll);
|
||||
bool active = ImGuiNET.ImGui.IsItemActive();
|
||||
edit.Active = active;
|
||||
_editing |= active;
|
||||
if (ImGuiNET.ImGui.IsItemDeactivatedAfterEdit())
|
||||
{
|
||||
if (TryParse(edit.Buffer, out double typed))
|
||||
{
|
||||
double clamped = Math.Clamp(isInt ? Math.Round(typed) : typed, row.Min, row.Max);
|
||||
Changed(row, clamped);
|
||||
WriteValue(edit, clamped, isInt);
|
||||
}
|
||||
else WriteValue(edit, value, isInt); // bad input reverts
|
||||
}
|
||||
ImGuiNET.ImGui.PopStyleVar(3);
|
||||
ImGuiNET.ImGui.PopStyleColor(3);
|
||||
|
||||
if (StepButton("##plus", new Vector2(plusX + 1, p.Y + 1), PhosphorIcons.Plus))
|
||||
Changed(row, Math.Clamp(value + row.Step, row.Min, row.Max));
|
||||
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + 22));
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
}
|
||||
|
||||
// Label | [swatch]; a click opens a colour picker. These are the theme's colours (engine-stored): each
|
||||
// change applies at once and is saved by the theme, so the profile isn't saved for it.
|
||||
private void ColorRow(SettingRow row, float w)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
dl.AddText(p + new Vector2(0, (22 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, row.Label);
|
||||
const float swatchW = 52;
|
||||
ImGuiNET.ImGui.InvisibleButton("##label", new Vector2(Math.Max(1, w - swatchW - 8), 22));
|
||||
Tooltip(row);
|
||||
|
||||
uint argb = (uint)row.Get!(_data);
|
||||
var col = new Vector4(((argb >> 16) & 0xFF) / 255f, ((argb >> 8) & 0xFF) / 255f, (argb & 0xFF) / 255f, 1f);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X + w - swatchW, p.Y + 1));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1f);
|
||||
if (ImGuiNET.ImGui.ColorButton("##swatch", col, ImGuiColorEditFlags.NoAlpha | ImGuiColorEditFlags.NoTooltip, new Vector2(swatchW, 20)))
|
||||
ImGuiNET.ImGui.OpenPopup("##picker");
|
||||
ImGuiNET.ImGui.PopStyleVar();
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
ImGuiNET.ImGui.SetItemTooltip("Click to pick a colour.");
|
||||
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, ShellBg);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord);
|
||||
bool open = ImGuiNET.ImGui.BeginPopup("##picker");
|
||||
ImGuiNET.ImGui.PopStyleColor(2);
|
||||
if (open)
|
||||
{
|
||||
var rgb = new Vector3(col.X, col.Y, col.Z);
|
||||
ImGuiNET.ImGui.SetNextItemWidth(200);
|
||||
if (ImGuiNET.ImGui.ColorPicker3("##pick", ref rgb, ImGuiColorEditFlags.NoAlpha | ImGuiColorEditFlags.NoSidePreview
|
||||
| ImGuiColorEditFlags.PickerHueWheel | ImGuiColorEditFlags.DisplayHex))
|
||||
{
|
||||
uint packed = 0xFF000000 | ((uint)MathF.Round(Math.Clamp(rgb.X, 0f, 1f) * 255) << 16)
|
||||
| ((uint)MathF.Round(Math.Clamp(rgb.Y, 0f, 1f) * 255) << 8) | (uint)MathF.Round(Math.Clamp(rgb.Z, 0f, 1f) * 255);
|
||||
row.Set!(_data, packed);
|
||||
}
|
||||
ImGuiNET.ImGui.EndPopup();
|
||||
}
|
||||
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + 22));
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
}
|
||||
|
||||
private NumberEdit EditFor(SettingRow row)
|
||||
{
|
||||
if (!_edits.TryGetValue(row, out NumberEdit? e))
|
||||
_edits[row] = e = new NumberEdit();
|
||||
return e;
|
||||
}
|
||||
|
||||
private static void WriteValue(NumberEdit edit, double value, bool isInt)
|
||||
{
|
||||
string text = isInt ? ((long)Math.Round(value)).ToString(CultureInfo.InvariantCulture)
|
||||
: value.ToString("G4", CultureInfo.InvariantCulture);
|
||||
int n = Encoding.UTF8.GetBytes(text, 0, text.Length, edit.Buffer, 0);
|
||||
edit.Buffer[Math.Min(n, edit.Buffer.Length - 1)] = 0;
|
||||
edit.Shown = value;
|
||||
}
|
||||
|
||||
private static bool TryParse(byte[] buffer, out double value)
|
||||
{
|
||||
int len = Array.IndexOf(buffer, (byte)0);
|
||||
if (len < 0) len = buffer.Length;
|
||||
return double.TryParse(Encoding.UTF8.GetString(buffer, 0, len), NumberStyles.Float, CultureInfo.InvariantCulture, out value);
|
||||
}
|
||||
|
||||
// Label | [current item]; click opens a 220 px list with the current item highlighted.
|
||||
private void ComboRow(SettingRow row, float w)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
string[] items = row.Items!;
|
||||
int current = Math.Clamp((int)row.Get!(_data), 0, items.Length - 1);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
dl.AddText(p + new Vector2(0, (22 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), TextDim, row.Label);
|
||||
|
||||
ImFontPtr f10 = ImGuiFonts.Get(UiFont.Ui10);
|
||||
const float btnW = 160;
|
||||
var bp = new Vector2(p.X + w - btnW, p.Y + 1);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(bp);
|
||||
if (ImGuiNET.ImGui.InvisibleButton("##combo", new Vector2(btnW, 20)))
|
||||
{
|
||||
ImGuiNET.ImGui.SetNextWindowPos(new Vector2(Math.Max(bp.X + btnW - 220, 0), bp.Y + 20));
|
||||
ImGuiNET.ImGui.OpenPopup("##combo_list");
|
||||
}
|
||||
bool hot = ImGuiNET.ImGui.IsItemHovered();
|
||||
Tooltip(row);
|
||||
dl.AddRectFilled(bp, bp + new Vector2(btnW, 20), hot ? Lighten(BtnFill) : BtnFill);
|
||||
dl.AddRect(bp, bp + new Vector2(btnW, 20), BtnBord);
|
||||
dl.PushClipRect(bp, bp + new Vector2(btnW - 16, 20), true);
|
||||
dl.AddText(f10, f10.FontSize, bp + new Vector2(4, (20 - f10.FontSize) * 0.5f), TextDim, items[current]);
|
||||
dl.PopClipRect();
|
||||
PhosphorIcons.DrawCentered(dl, f10, PhosphorIcons.CaretDown, bp + new Vector2(btnW - 16, 0), new Vector2(14, 20), Mute);
|
||||
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, ShellBg);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, Teal);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.PopupRounding, 4f);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(2, 2));
|
||||
ImGuiNET.ImGui.SetNextWindowSize(new Vector2(220, items.Length * 21 + 4));
|
||||
bool open = ImGuiNET.ImGui.BeginPopup("##combo_list");
|
||||
ImGuiNET.ImGui.PopStyleVar(2);
|
||||
ImGuiNET.ImGui.PopStyleColor(2);
|
||||
if (open)
|
||||
{
|
||||
var pdl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
float iw = ImGuiNET.ImGui.GetContentRegionAvail().X;
|
||||
for (int i = 0; i < items.Length; i++)
|
||||
{
|
||||
ImGuiNET.ImGui.PushID(i);
|
||||
Vector2 ip = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
bool picked = ImGuiNET.ImGui.InvisibleButton("##item", new Vector2(iw, 20));
|
||||
bool ih = ImGuiNET.ImGui.IsItemHovered();
|
||||
ImGuiNET.ImGui.PopID();
|
||||
bool sel = i == current;
|
||||
pdl.AddRectFilled(ip, ip + new Vector2(iw, 20), sel ? TabActive : ih ? Lighten(BtnFill) : BtnFill);
|
||||
pdl.AddRect(ip, ip + new Vector2(iw, 20), BtnBord);
|
||||
pdl.AddText(f10, f10.FontSize, ip + new Vector2(6, (20 - f10.FontSize) * 0.5f), sel ? Teal : TextDim, items[i]);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 1));
|
||||
if (picked)
|
||||
{
|
||||
Changed(row, i);
|
||||
ImGuiNET.ImGui.CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
ImGuiNET.ImGui.EndPopup();
|
||||
}
|
||||
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + 22));
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
}
|
||||
|
||||
private static void Section(string text, float w)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
ImFontPtr bold = ImGuiFonts.Get(UiFont.UiBold11);
|
||||
float h = bold.FontSize + 4;
|
||||
dl.AddRectFilled(p, p + new Vector2(w, h), TabActive);
|
||||
dl.AddText(bold, bold.FontSize, p + new Vector2(4, 2), Amber, text);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(w, h));
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
}
|
||||
|
||||
private static void Note(string text, float w)
|
||||
{
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
bool small = !text.StartsWith('(');
|
||||
if (small) ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui10));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Mute);
|
||||
ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + w);
|
||||
ImGuiNET.ImGui.TextUnformatted(text);
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
if (small) ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
|
||||
private void CraftingStatus(SettingRow row)
|
||||
{
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(RynthTheme.TextMuted), row.Label);
|
||||
ImGuiNET.ImGui.SameLine(0, 6);
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11));
|
||||
SafeImGui.TextColored(RynthTheme.VecOf(_data.MissileCraftingActive ? RynthTheme.Highlight : RynthTheme.TextMuted), _data.MissileCraftingState);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
if (!string.IsNullOrEmpty(_data.MissileCraftingStatus))
|
||||
{
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui10));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, TextDim);
|
||||
SafeImGui.TextWrapped(_data.MissileCraftingStatus);
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
}
|
||||
|
||||
private static bool StepButton(string id, Vector2 pos, string glyph)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, new Vector2(18, 20));
|
||||
uint bg = ImGuiNET.ImGui.IsItemActive() ? Darken(BtnFill) : ImGuiNET.ImGui.IsItemHovered() ? Lighten(BtnFill) : BtnFill;
|
||||
dl.AddRectFilled(pos, pos + new Vector2(18, 20), bg);
|
||||
dl.AddRect(pos, pos + new Vector2(18, 20), BtnBord);
|
||||
PhosphorIcons.DrawCentered(dl, ImGuiFonts.Get(UiFont.Ui11), glyph, pos, new Vector2(18, 20), TextDim);
|
||||
return clicked;
|
||||
}
|
||||
|
||||
private static void Tooltip(SettingRow row)
|
||||
{
|
||||
if (row.Tooltip != null) SafeImGui.SetItemTooltip(row.Tooltip);
|
||||
}
|
||||
|
||||
private static uint Lighten(uint abgr) => Scale(abgr, 1.25f, 12);
|
||||
private static uint Darken(uint abgr) => Scale(abgr, 0.8f, 0);
|
||||
|
||||
private static uint Scale(uint abgr, float k, int add)
|
||||
{
|
||||
uint a = abgr & 0xFF000000;
|
||||
uint r = (uint)Math.Min(255, (int)((abgr & 0xFF) * k) + add);
|
||||
uint g = (uint)Math.Min(255, (int)(((abgr >> 8) & 0xFF) * k) + add);
|
||||
uint b = (uint)Math.Min(255, (int)(((abgr >> 16) & 0xFF) * k) + add);
|
||||
return a | (b << 16) | (g << 8) | r;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/SkillsFace.Progression.cs
|
||||
// The Skills panel's Progression tab, shown on ILT-like worlds only:
|
||||
// - XP planner: exact XP for the next N raises of every attribute and vital,
|
||||
// from the client's XP tables (raising stays on the Attributes & Vitals tab).
|
||||
// - Attribute raiser: infinite attributes past the retail cap. RynthILT reads the
|
||||
// server's costs ("/xp all") and raises with "/attr", by hand or on a timer from
|
||||
// unassigned XP, in the order and mode set here. Laid out like UB's Leaftide XP
|
||||
// tab: "+1 Level" / "+10 Levels" buttons labelled with their (projected) cost.
|
||||
// - Attributes: one section - client XP-table planner for retail ranks, plus (when the
|
||||
// server supports infinite attributes) the ILT raiser to auto-raise past the retail
|
||||
// cap with "/xp all" + "/attr" (UB Leaftide XP tab layout). RynthILT reads the
|
||||
// server's costs and raises, by hand or on a timer from unassigned XP.
|
||||
// - Augmentations: UB's Augs tab - Refresh current (/aug), Current / Target / Inc /
|
||||
// Luminance / Coins with a totals row, Reset targets, Copy Discord / In-Game.
|
||||
// - Augmentations / Enlightenment: the ILT Hub's planners (RynthILT's since
|
||||
|
|
@ -100,15 +98,14 @@ internal sealed partial class SkillsFace
|
|||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(6, 4));
|
||||
try
|
||||
{
|
||||
DrawXpPlanner(w);
|
||||
// One Attributes section: retail XP planner + (when supported) infinite-attr raiser.
|
||||
DrawAttributes(info?.Attr, w);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 6));
|
||||
if (info == null || !info.Available)
|
||||
{
|
||||
Message("Augmentations and Enlightenment need RynthILT's ILT features on an ILT world.", w);
|
||||
return;
|
||||
}
|
||||
DrawAttrRaiser(info.Attr, w);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 6));
|
||||
DrawAugPlanner(info.Aug, w);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 6));
|
||||
DrawEnlPlanner(info.Enl, w);
|
||||
|
|
@ -120,15 +117,50 @@ internal sealed partial class SkillsFace
|
|||
}
|
||||
}
|
||||
|
||||
private void DrawXpPlanner(float w)
|
||||
/// <summary>
|
||||
/// Single Attributes section: client XP-table costs up to the retail cap, and - when the
|
||||
/// server supports infinite attributes - the controls to auto-raise past that cap.
|
||||
/// </summary>
|
||||
private void DrawAttributes(AttrRaiser? a, float w)
|
||||
{
|
||||
Section("Attributes", w);
|
||||
ImGuiNET.ImGui.Indent(8);
|
||||
float wrap = ImGuiNET.ImGui.GetCursorPosX() + w - 24;
|
||||
ImGuiNET.ImGui.PushTextWrapPos(wrap);
|
||||
try
|
||||
{
|
||||
DrawRetailXpPlanner(w);
|
||||
|
||||
// Infinite-attributes segment: only when RynthILT reports the server can raise past retail.
|
||||
bool infiniteOk = a != null && !a.Off;
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
ImGuiNET.ImGui.Separator();
|
||||
Label(infiniteOk
|
||||
? "Infinite attributes (past retail max)"
|
||||
: "Infinite attributes",
|
||||
infiniteOk ? Amber : Mute);
|
||||
if (a == null)
|
||||
Label("Update RynthILT to raise attributes past the retail cap on this server.", Mute);
|
||||
else if (a.Off)
|
||||
Label(a.Reason.Length > 0 ? a.Reason : "This server does not support infinite attributes (/xp /attr).", Mute);
|
||||
else
|
||||
DrawInfiniteAttrControls(a, w);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
ImGuiNET.ImGui.Unindent(8);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Client XP tables for the next N retail raises (Attributes & Vitals tab still spends them).</summary>
|
||||
private void DrawRetailXpPlanner(float w)
|
||||
{
|
||||
Section("XP planner", w);
|
||||
if (_snap == null || _dat == null || _attributes.Count == 0)
|
||||
{
|
||||
Message("Waiting for your character's data...", w);
|
||||
return;
|
||||
}
|
||||
ImGuiNET.ImGui.Indent(8);
|
||||
long have = _snap.UnassignedXp;
|
||||
Label($"Unassigned XP: {have:N0}", have > 0 ? Teal : Mute);
|
||||
ImGuiNET.ImGui.SetNextItemWidth(160);
|
||||
|
|
@ -146,9 +178,7 @@ internal sealed partial class SkillsFace
|
|||
foreach (Row r in _vitals) PlannerRow(r, have);
|
||||
ImGuiNET.ImGui.EndTable();
|
||||
}
|
||||
Label("Exact costs from the client's XP tables. Raise on the Attributes & Vitals tab"
|
||||
+ (ProgressionTabVisible ? ", or past the cap with the Attribute raiser below." : "."), Dim);
|
||||
ImGuiNET.ImGui.Unindent(8);
|
||||
Label("Exact costs from the client's XP tables (up to the retail cap). Raise those on the Attributes & Vitals tab.", Dim);
|
||||
}
|
||||
|
||||
private void PlannerRow(Row r, long have)
|
||||
|
|
@ -180,89 +210,76 @@ internal sealed partial class SkillsFace
|
|||
private string? _attrKeepEdit; // reserve box being typed in (null = show RynthAi's value)
|
||||
private int? _attrEveryEdit; // interval box being typed in
|
||||
|
||||
private void DrawAttrRaiser(AttrRaiser? a, float w)
|
||||
/// <summary>Infinite-attribute raiser controls (only drawn when the server supports /xp + /attr past retail).</summary>
|
||||
private void DrawInfiniteAttrControls(AttrRaiser a, float w)
|
||||
{
|
||||
Section("Attribute raiser (infinite attributes)", w);
|
||||
ImGuiNET.ImGui.Indent(8);
|
||||
float wrap = ImGuiNET.ImGui.GetCursorPosX() + w - 24;
|
||||
ImGuiNET.ImGui.PushTextWrapPos(wrap);
|
||||
try
|
||||
Label(a.XpHeader.Length > 0 ? a.XpHeader : a.Unassigned, Teal);
|
||||
if (a.XpHeader.Length > 0 && a.Unassigned.Contains("spendable", StringComparison.Ordinal)) Label(a.Unassigned, Dim);
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
if (a.Running)
|
||||
{
|
||||
if (a == null) { Label("Update RynthAi to use the attribute raiser.", Mute); return; }
|
||||
if (a.Off) { Label(a.Reason, Mute); return; }
|
||||
|
||||
Label(a.XpHeader.Length > 0 ? a.XpHeader : a.Unassigned, Teal);
|
||||
if (a.XpHeader.Length > 0 && a.Unassigned.Contains("spendable", StringComparison.Ordinal)) Label(a.Unassigned, Dim);
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
if (a.Running)
|
||||
{
|
||||
if (Button("##attr_stop", "Stop", p, new Vector2(90, 24), Text, StopBg)) SendProg("attrstop");
|
||||
}
|
||||
else if (Button("##attr_run", "Raise now", p, new Vector2(110, 24), Text, StartBg, border: Teal))
|
||||
SendProg("attrrun");
|
||||
if (Button("##attr_costs", "Refresh XP", new Vector2(p.X + 116, p.Y), new Vector2(100, 24), Text, BtnFill, enabled: !a.Running))
|
||||
SendProg("attrcosts");
|
||||
ImGuiNET.ImGui.SetItemTooltip("Re-reads every next-level cost with /xp all.");
|
||||
if (a.Updated.Length > 0)
|
||||
{
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X + 224, p.Y + 4));
|
||||
Label("Last updated: " + a.Updated, Dim);
|
||||
}
|
||||
NextLine(p, 28);
|
||||
if (a.Status.Length > 0) SafeImGui.TextWrapped(a.Status);
|
||||
if (a.LastRun.Length > 0) Label("Last run: " + a.LastRun, Dim);
|
||||
|
||||
ImGuiNET.ImGui.Separator();
|
||||
bool auto = a.Auto;
|
||||
if (ImGuiNET.ImGui.Checkbox("Auto-raise from unassigned XP##attr_auto", ref auto))
|
||||
SendProg("attrauto " + (auto ? "on" : "off"));
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
// Commit on Enter, the +/- buttons or focus loss (not on every keystroke: each send
|
||||
// restarts the auto-raise timer).
|
||||
int every = _attrEveryEdit ?? a.Every;
|
||||
ImGuiNET.ImGui.SetNextItemWidth(90);
|
||||
bool everyCommit = ImGuiNET.ImGui.InputInt("every (min)##attr_every", ref every, 1, 10, ImGuiInputTextFlags.EnterReturnsTrue);
|
||||
bool everyActive = ImGuiNET.ImGui.IsItemActive();
|
||||
if (everyCommit || ImGuiNET.ImGui.IsItemDeactivatedAfterEdit())
|
||||
{
|
||||
_attrEveryEdit = null;
|
||||
if (every != a.Every) SendProg("attrevery " + Math.Clamp(every, 1, 1440).ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
else _attrEveryEdit = everyActive ? every : null;
|
||||
if (a.Auto && a.Next.Length > 0) Label($"Next auto-raise: {a.Next}", Dim);
|
||||
|
||||
int mode = Math.Clamp(a.Mode, 0, AttrModes.Length - 1);
|
||||
ImGuiNET.ImGui.SetNextItemWidth(260);
|
||||
if (ImGuiNET.ImGui.Combo("Raise order##attr_mode", ref mode, AttrModes, AttrModes.Length))
|
||||
SendProg("attrmode " + mode.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
// The box holds the exact reserve (KeepFull); it is sent only when the text changed, so an
|
||||
// Enter on an untouched box can't round the reserve.
|
||||
string shownKeep = a.KeepFull.Length > 0 ? a.KeepFull : a.Keep;
|
||||
string keep = _attrKeepEdit ?? shownKeep;
|
||||
ImGuiNET.ImGui.SetNextItemWidth(140);
|
||||
bool enter = ImGuiNET.ImGui.InputTextWithHint("Keep in reserve (XP)##attr_keep", "0, 500m, 2b", ref keep, 32u,
|
||||
ImGuiInputTextFlags.EnterReturnsTrue);
|
||||
bool keepActive = ImGuiNET.ImGui.IsItemActive();
|
||||
if (enter || ImGuiNET.ImGui.IsItemDeactivatedAfterEdit())
|
||||
{
|
||||
_attrKeepEdit = null;
|
||||
if (!string.Equals(keep.Trim(), shownKeep, StringComparison.Ordinal))
|
||||
SendProg("attrkeep " + keep.Replace(" ", "", StringComparison.Ordinal).Replace(",", "", StringComparison.Ordinal));
|
||||
}
|
||||
else _attrKeepEdit = keepActive ? keep : null;
|
||||
ImGuiNET.ImGui.SetItemTooltip("Unassigned XP the raiser never spends. Accepts k / m / b / t suffixes.");
|
||||
|
||||
DrawAttrTable(a, w);
|
||||
Label("Auto: the stats Raise now / auto-raise may spend on; arrows set the order. "
|
||||
+ "+1 / +10 raise by hand (red = not enough unassigned XP). "
|
||||
+ "+10 is an estimate (7.7% dearer per level); the server charges the real cost. " + a.CostsAge + ".", Dim);
|
||||
if (Button("##attr_stop", "Stop", p, new Vector2(90, 24), Text, StopBg)) SendProg("attrstop");
|
||||
}
|
||||
finally
|
||||
else if (Button("##attr_run", "Raise now", p, new Vector2(110, 24), Text, StartBg, border: Teal))
|
||||
SendProg("attrrun");
|
||||
if (Button("##attr_costs", "Refresh XP", new Vector2(p.X + 116, p.Y), new Vector2(100, 24), Text, BtnFill, enabled: !a.Running))
|
||||
SendProg("attrcosts");
|
||||
ImGuiNET.ImGui.SetItemTooltip("Re-reads every next-level cost with /xp all.");
|
||||
if (a.Updated.Length > 0)
|
||||
{
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
ImGuiNET.ImGui.Unindent(8);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X + 224, p.Y + 4));
|
||||
Label("Last updated: " + a.Updated, Dim);
|
||||
}
|
||||
NextLine(p, 28);
|
||||
if (a.Status.Length > 0) ImGuiNET.ImGui.TextWrapped(a.Status);
|
||||
if (a.LastRun.Length > 0) Label("Last run: " + a.LastRun, Dim);
|
||||
|
||||
ImGuiNET.ImGui.Separator();
|
||||
bool auto = a.Auto;
|
||||
if (ImGuiNET.ImGui.Checkbox("Auto-raise past retail max##attr_auto", ref auto))
|
||||
SendProg("attrauto " + (auto ? "on" : "off"));
|
||||
ImGuiNET.ImGui.SetItemTooltip("Spends unassigned XP with /attr past the retail attribute cap (server costs from /xp all).");
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
// Commit on Enter, the +/- buttons or focus loss (not on every keystroke: each send
|
||||
// restarts the auto-raise timer).
|
||||
int every = _attrEveryEdit ?? a.Every;
|
||||
ImGuiNET.ImGui.SetNextItemWidth(90);
|
||||
bool everyCommit = ImGuiNET.ImGui.InputInt("every (min)##attr_every", ref every, 1, 10, ImGuiInputTextFlags.EnterReturnsTrue);
|
||||
bool everyActive = ImGuiNET.ImGui.IsItemActive();
|
||||
if (everyCommit || ImGuiNET.ImGui.IsItemDeactivatedAfterEdit())
|
||||
{
|
||||
_attrEveryEdit = null;
|
||||
if (every != a.Every) SendProg("attrevery " + Math.Clamp(every, 1, 1440).ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
else _attrEveryEdit = everyActive ? every : null;
|
||||
if (a.Auto && a.Next.Length > 0) Label($"Next auto-raise: {a.Next}", Dim);
|
||||
|
||||
int mode = Math.Clamp(a.Mode, 0, AttrModes.Length - 1);
|
||||
ImGuiNET.ImGui.SetNextItemWidth(260);
|
||||
if (ImGuiNET.ImGui.Combo("Raise order##attr_mode", ref mode, AttrModes, AttrModes.Length))
|
||||
SendProg("attrmode " + mode.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
// The box holds the exact reserve (KeepFull); it is sent only when the text changed, so an
|
||||
// Enter on an untouched box can't round the reserve.
|
||||
string shownKeep = a.KeepFull.Length > 0 ? a.KeepFull : a.Keep;
|
||||
string keep = _attrKeepEdit ?? shownKeep;
|
||||
ImGuiNET.ImGui.SetNextItemWidth(140);
|
||||
bool enter = ImGuiNET.ImGui.InputTextWithHint("Keep in reserve (XP)##attr_keep", "0, 500m, 2b", ref keep, 32u,
|
||||
ImGuiInputTextFlags.EnterReturnsTrue);
|
||||
bool keepActive = ImGuiNET.ImGui.IsItemActive();
|
||||
if (enter || ImGuiNET.ImGui.IsItemDeactivatedAfterEdit())
|
||||
{
|
||||
_attrKeepEdit = null;
|
||||
if (!string.Equals(keep.Trim(), shownKeep, StringComparison.Ordinal))
|
||||
SendProg("attrkeep " + keep.Replace(" ", "", StringComparison.Ordinal).Replace(",", "", StringComparison.Ordinal));
|
||||
}
|
||||
else _attrKeepEdit = keepActive ? keep : null;
|
||||
ImGuiNET.ImGui.SetItemTooltip("Unassigned XP the raiser never spends. Accepts k / m / b / t suffixes.");
|
||||
|
||||
DrawAttrTable(a, w);
|
||||
Label("Auto: the stats Raise now / auto-raise may spend on; arrows set the order. "
|
||||
+ "+1 / +10 raise by hand (red = not enough unassigned XP). "
|
||||
+ "+10 is an estimate (7.7% dearer per level); the server charges the real cost. " + a.CostsAge + ".", Dim);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -338,7 +355,7 @@ internal sealed partial class SkillsFace
|
|||
: $"{what}: {exact} XP.";
|
||||
if (known && !afford) tip += " Not enough unassigned XP.";
|
||||
if (a.Running) tip += " Wait for the raise run to finish.";
|
||||
SafeImGui.SetItemTooltip(tip);
|
||||
ImGuiNET.ImGui.SetItemTooltip(tip);
|
||||
}
|
||||
|
||||
/// <summary>The client's own base value for a raiser row (0 when the snapshot has none).</summary>
|
||||
|
|
@ -574,7 +591,7 @@ internal sealed partial class SkillsFace
|
|||
}
|
||||
else if (active) _augTargetEdit[row.Key] = tgt;
|
||||
else _augTargetEdit.Remove(row.Key);
|
||||
SafeImGui.SetItemTooltip($"Target {row.Label} level (up to {row.Cap.ToString("N0", CultureInfo.InvariantCulture)}).");
|
||||
ImGuiNET.ImGui.SetItemTooltip($"Target {row.Label} level (up to {row.Cap.ToString("N0", CultureInfo.InvariantCulture)}).");
|
||||
}
|
||||
|
||||
private void DrawEnlPlanner(EnlPlanner e, float w)
|
||||
|
|
@ -593,7 +610,7 @@ internal sealed partial class SkillsFace
|
|||
ImGuiNET.ImGui.SetNextItemWidth(100);
|
||||
if (ImGuiNET.ImGui.InputInt("Plan to level##prog_enlt", ref target))
|
||||
SendProg("enltarget " + Math.Max(e.Level + 1, target).ToString(CultureInfo.InvariantCulture));
|
||||
foreach (string line in e.Plan) SafeImGui.BulletText(line);
|
||||
foreach (string line in e.Plan) ImGuiNET.ImGui.BulletText(line);
|
||||
|
||||
int coinsPerToken = e.CoinsPerToken;
|
||||
ImGuiNET.ImGui.SetNextItemWidth(100);
|
||||
|
|
@ -640,7 +657,7 @@ internal sealed partial class SkillsFace
|
|||
if (ImGuiNET.ImGui.InputInt("Check every (s)##prog_every", ref every))
|
||||
SendProg("checkevery " + Math.Max(10, every).ToString(CultureInfo.InvariantCulture));
|
||||
Label(e.Armed ? "Armed." : "Disarmed.", e.Armed ? Amber : Dim);
|
||||
if (e.Status.Length > 0) SafeImGui.TextWrapped(e.Status);
|
||||
if (e.Status.Length > 0) ImGuiNET.ImGui.TextWrapped(e.Status);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ internal sealed partial class SkillsFace : IImGuiPanel
|
|||
|
||||
// ── Palette (FaceKit's, plus the vitals') ────────────────────────────
|
||||
private static readonly uint Mana = RynthTheme.Argb(0xFF4DA6FF), Dim = RynthTheme.Argb(0xFF7F8FA0),
|
||||
GroupBg = RynthTheme.Argb(0xFF0F1A24), MasteryColor = RynthTheme.Argb(0xFFC9A2FF);
|
||||
private static uint ExpandedBg => RynthTheme.Selected;
|
||||
ExpandedBg = RynthTheme.Argb(0xFF1A2E42), GroupBg = RynthTheme.Argb(0xFF0F1A24),
|
||||
MasteryColor = RynthTheme.Argb(0xFFC9A2FF);
|
||||
|
||||
private const float RowH = 24f, IconSize = 20f, ColBuffed = 46f, ColBase = 46f, ColCost = 76f, ColButton = 52f,
|
||||
CaretW = 16f, MultiW = 190f;
|
||||
|
|
|
|||
|
|
@ -1,264 +0,0 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/WorldMapFace.cs
|
||||
// The World Map: an interactive map of Dereth, opened from the RynthNav panel's Map button.
|
||||
// The map itself is WorldMapView (also the Mini Map's); this face is the toolbar around it:
|
||||
// Follow keeps you centred (a drag, or Fit, turns it off; a double click on the map turns it on)
|
||||
// Rotate turns the map so the way you face is up
|
||||
// - + Fit zoom out / in / the whole world
|
||||
// Show which kinds of place, and the labels / route / path / grid / characters / buildings layers
|
||||
// Find a place by name (the Atlas's surface places, towns and dungeons first): Enter or a click
|
||||
// centres on it, zooms in and rings it
|
||||
// and, over the map's top-left, what is under the cursor: its coordinates, the place's name, and how
|
||||
// far and which way it is from you.
|
||||
// Settings (zoom, Follow, Rotate, the layers) last across sessions (WorldMapSettings).
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
using static RynthCore.Engine.ImGuiBackend.Panels.FaceKit;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
/// <summary>The data both map faces draw from: subscribed while a face is open.</summary>
|
||||
internal static class WorldMapFeeds
|
||||
{
|
||||
private static readonly string VectorPath = System.IO.Path.Combine(RynthCore.Install.RynthInstallPaths.CoreDir, "NavData", "worldmap.vec");
|
||||
|
||||
public static void Subscribe()
|
||||
{
|
||||
UiSources.RynthNav.Subscribe();
|
||||
UiSources.RynthNav.RequestRefresh();
|
||||
UiSources.Radar.Subscribe();
|
||||
UiSources.Radar.RequestRefresh();
|
||||
RynthNavAtlas.EnsureLoadedForNames();
|
||||
WorldMapMaps.Refresh(); // finds which map pictures are installed and opens the one to use
|
||||
WorldMapVectors.Open(VectorPath);
|
||||
}
|
||||
|
||||
public static void Unsubscribe()
|
||||
{
|
||||
UiSources.RynthNav.Unsubscribe();
|
||||
UiSources.Radar.Unsubscribe();
|
||||
}
|
||||
|
||||
/// <summary>The characters feed (RynthNet) is polled only while the layer is on; each face keeps its own flag.</summary>
|
||||
public static void SyncCharacters(ref bool subscribed)
|
||||
{
|
||||
bool want = WorldMapSettings.Characters;
|
||||
if (want == subscribed) return;
|
||||
subscribed = want;
|
||||
if (want) { UiSources.Characters.Subscribe(); UiSources.Characters.RequestRefresh(); }
|
||||
else UiSources.Characters.Unsubscribe();
|
||||
}
|
||||
|
||||
public static void ReleaseCharacters(ref bool subscribed)
|
||||
{
|
||||
if (subscribed) UiSources.Characters.Unsubscribe();
|
||||
subscribed = false;
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class WorldMapFace : IImGuiPanel
|
||||
{
|
||||
public const string Title = "World Map";
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
WorldMapSettings.Load(); // engine init thread: the file read stays off AC's thread
|
||||
ImGuiPanelHost.Register(Title,
|
||||
new PanelSpec(new Vector2(680, 600), new Vector2(340, 280), EdgeToEdge: true, GripInBody: true, NoPopOut: true, OpenCentered: true),
|
||||
() => new WorldMapFace());
|
||||
MiniMapFace.Register();
|
||||
}
|
||||
|
||||
private readonly WorldMapView _view = new(mini: false);
|
||||
private bool _charsSub;
|
||||
private readonly byte[] _find = new byte[64];
|
||||
private string _findText = "";
|
||||
private List<NavPlace> _found = new();
|
||||
private bool _findOpen;
|
||||
private Vector2 _findBoxMin, _findBoxMax;
|
||||
|
||||
public void OnShown() => WorldMapFeeds.Subscribe();
|
||||
|
||||
public void OnHidden()
|
||||
{
|
||||
WorldMapFeeds.Unsubscribe();
|
||||
WorldMapFeeds.ReleaseCharacters(ref _charsSub);
|
||||
_findOpen = false;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
WorldMapFeeds.SyncCharacters(ref _charsSub);
|
||||
float w = Begin(out Vector2 origin, out Vector2 size);
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
|
||||
try
|
||||
{
|
||||
RynthNavStatus? st = UiSources.RynthNav.Current?.Value;
|
||||
RadarView? radar = UiSources.Radar.Current?.Value;
|
||||
MapPlayer pl = WorldMapView.GatherPlayer(st, radar);
|
||||
CharacterRow[]? chars = WorldMapSettings.Characters ? UiSources.Characters.Current?.Value?.Rows : null;
|
||||
|
||||
Vector2 barPos = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
float canvasTop = DrawToolbar(barPos, w, pl.Known);
|
||||
var canvasMin = new Vector2(origin.X + 1, canvasTop);
|
||||
var canvasMax = new Vector2(origin.X + size.X - 1, origin.Y + size.Y - 1);
|
||||
|
||||
// The find dropdown covers part of the map: tell the map to ignore the mouse there.
|
||||
(Vector2, Vector2)? drop = null;
|
||||
if (_findOpen && _found.Count > 0)
|
||||
{
|
||||
var dmin = new Vector2(_findBoxMin.X, _findBoxMax.Y + 2);
|
||||
drop = (dmin, dmin + new Vector2(Math.Max(_findBoxMax.X - _findBoxMin.X, 250f), _found.Count * 20 + 4));
|
||||
}
|
||||
_view.Blocked = drop;
|
||||
_view.Draw(canvasMin, canvasMax, pl, st, chars);
|
||||
|
||||
// What's under the cursor, over the map's top-left.
|
||||
string tip = _view.HoverText;
|
||||
if (tip.Length > 0)
|
||||
{
|
||||
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(tip);
|
||||
Vector2 a = canvasMin + new Vector2(8, 8), b = a + ts + new Vector2(12, 8);
|
||||
if (b.X < canvasMax.X - 8)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
dl.AddRectFilled(a, b, RynthTheme.Argb(0xD00A121A), 4);
|
||||
dl.AddText(a + new Vector2(6, 4), Text, tip);
|
||||
}
|
||||
}
|
||||
|
||||
DrawFindDropdown(drop);
|
||||
WorldMapSettings.FlushIfDue();
|
||||
}
|
||||
finally
|
||||
{
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
End(origin, size);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Toolbar ──────────────────────────────────────────────────────────
|
||||
private float DrawToolbar(Vector2 pos, float width, bool canFollow)
|
||||
{
|
||||
float x = pos.X, y = pos.Y;
|
||||
const float h = 22f;
|
||||
bool follow = _view.Follow, rotate = _view.Rotate;
|
||||
if (Button("##wm_follow", "Follow", new Vector2(x, y), new Vector2(54, h), follow ? Teal : Text, follow ? Selected : BtnFill,
|
||||
enabled: canFollow, border: follow ? Teal : 0))
|
||||
_view.Follow = !follow;
|
||||
x += 58;
|
||||
if (Button("##wm_rotate", "Rotate", new Vector2(x, y), new Vector2(52, h), rotate ? Teal : Text, rotate ? Selected : BtnFill,
|
||||
enabled: canFollow, border: rotate ? Teal : 0))
|
||||
_view.Rotate = !rotate;
|
||||
x += 56;
|
||||
if (Button("##wm_out", "-", new Vector2(x, y), new Vector2(24, h), Text, BtnFill)) _view.ZoomBy(1f / 1.5f);
|
||||
x += 28;
|
||||
if (Button("##wm_in", "+", new Vector2(x, y), new Vector2(24, h), Text, BtnFill)) _view.ZoomBy(1.5f);
|
||||
x += 28;
|
||||
if (Button("##wm_fit", "Fit", new Vector2(x, y), new Vector2(34, h), Text, BtnFill)) _view.FitWorld();
|
||||
x += 38;
|
||||
if (Button("##wm_show", "Show", new Vector2(x, y), new Vector2(46, h), Text, BtnFill)) ImGuiNET.ImGui.OpenPopup("##wm_show_pop");
|
||||
var showMenuAt = new Vector2(x, y + h + 2);
|
||||
x += 50;
|
||||
|
||||
ImGuiNET.ImGui.SetNextWindowPos(showMenuAt);
|
||||
if (ImGuiNET.ImGui.BeginPopup("##wm_show_pop"))
|
||||
{
|
||||
// Which picture: the best installed, or one of the installed ones.
|
||||
var installed = WorldMapMaps.Installed;
|
||||
if (installed.Length > 0)
|
||||
{
|
||||
SafeImGui.TextDisabled("Map detail" + (WorldMapMaps.CurrentLabel.Length > 0 ? ": " + WorldMapMaps.CurrentLabel : ""));
|
||||
if (ImGuiNET.ImGui.RadioButton("Best installed", WorldMapSettings.Detail.Length == 0)) { WorldMapSettings.Detail = ""; WorldMapSettings.MarkDirty(); WorldMapMaps.Apply(); }
|
||||
foreach (var t in installed)
|
||||
if (ImGuiNET.ImGui.RadioButton(t.Label, WorldMapSettings.Detail == t.Key)) { WorldMapSettings.Detail = t.Key; WorldMapSettings.MarkDirty(); WorldMapMaps.Apply(); }
|
||||
ImGuiNET.ImGui.Separator();
|
||||
}
|
||||
for (int k = 0; k < (int)WorldMapView.Kind.Count; k++)
|
||||
if (ImGuiNET.ImGui.Checkbox(WorldMapView.KindNames[k], ref WorldMapSettings.Show[k])) WorldMapSettings.MarkDirty();
|
||||
ImGuiNET.ImGui.Separator();
|
||||
if (ImGuiNET.ImGui.Checkbox("Labels", ref WorldMapSettings.Labels)) WorldMapSettings.MarkDirty();
|
||||
if (ImGuiNET.ImGui.Checkbox("Route", ref WorldMapSettings.Route)) WorldMapSettings.MarkDirty();
|
||||
if (ImGuiNET.ImGui.Checkbox("Walking path", ref WorldMapSettings.WalkPath)) WorldMapSettings.MarkDirty();
|
||||
if (ImGuiNET.ImGui.Checkbox("Grid", ref WorldMapSettings.Grid)) WorldMapSettings.MarkDirty();
|
||||
if (ImGuiNET.ImGui.Checkbox("Other characters", ref WorldMapSettings.Characters)) WorldMapSettings.MarkDirty();
|
||||
if (ImGuiNET.ImGui.Checkbox("Buildings and roads", ref WorldMapSettings.Buildings)) WorldMapSettings.MarkDirty();
|
||||
ImGuiNET.ImGui.EndPopup();
|
||||
}
|
||||
|
||||
// Find: the rest of the row, at most 220 px.
|
||||
float room = pos.X + width - x;
|
||||
if (room >= 90)
|
||||
{
|
||||
float fw = Math.Min(room, 220f);
|
||||
_findBoxMin = new Vector2(x, y);
|
||||
_findBoxMax = new Vector2(x + fw, y + h);
|
||||
bool enter = TextBox("##wm_findbox", _find, _findBoxMin, fw, "Find a place", out bool active, ImGuiInputTextFlags.EnterReturnsTrue);
|
||||
string text = Utf8(_find).Trim();
|
||||
if (text != _findText)
|
||||
{
|
||||
_findText = text;
|
||||
_found = WorldMapView.Find(text, 8);
|
||||
_findOpen = text.Length > 0;
|
||||
}
|
||||
else if (active && text.Length > 0) _findOpen = true;
|
||||
if (active && ImGuiNET.ImGui.IsKeyPressed(ImGuiKey.Escape, false)) ClearFind();
|
||||
if (enter && _found.Count > 0) PickFound(_found[0]);
|
||||
else if (enter) ClearFind();
|
||||
}
|
||||
else _findBoxMin = _findBoxMax = new Vector2(x, y);
|
||||
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(pos.X, y + 28));
|
||||
return y + 28;
|
||||
}
|
||||
|
||||
private void ClearFind()
|
||||
{
|
||||
Array.Clear(_find);
|
||||
_findText = "";
|
||||
_found = new List<NavPlace>();
|
||||
_findOpen = false;
|
||||
}
|
||||
|
||||
private void PickFound(NavPlace p)
|
||||
{
|
||||
float zoom = p.Type switch { "Town" => 3.5f, "Dungeon" => 5f, _ => 7f };
|
||||
_view.Show(p.Name, p.Ns, p.Ew, zoom);
|
||||
ClearFind();
|
||||
}
|
||||
|
||||
/// <summary>The results under the find box. Drawn after the map, so its buttons win the mouse.</summary>
|
||||
private void DrawFindDropdown((Vector2 Min, Vector2 Max)? drop)
|
||||
{
|
||||
if (drop is not { } d || !_findOpen || _found.Count == 0) return;
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
Vector2 mouse = ImGuiNET.ImGui.GetIO().MousePos;
|
||||
bool inBox = mouse.X >= _findBoxMin.X && mouse.X <= _findBoxMax.X && mouse.Y >= _findBoxMin.Y && mouse.Y <= _findBoxMax.Y;
|
||||
bool inDrop = mouse.X >= d.Min.X && mouse.X <= d.Max.X && mouse.Y >= d.Min.Y && mouse.Y <= d.Max.Y;
|
||||
if (ImGuiNET.ImGui.IsMouseClicked(ImGuiMouseButton.Left) && !inBox && !inDrop) { _findOpen = false; return; }
|
||||
|
||||
dl.AddRectFilled(d.Min, d.Max, ShellBg, 4);
|
||||
dl.AddRect(d.Min, d.Max, Teal, 4);
|
||||
NavPlace? pick = null;
|
||||
for (int i = 0; i < _found.Count; i++)
|
||||
{
|
||||
NavPlace p = _found[i];
|
||||
var rowMin = new Vector2(d.Min.X + 2, d.Min.Y + 2 + i * 20);
|
||||
var rowSize = new Vector2(d.Max.X - d.Min.X - 4, 20);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(rowMin);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton("##wm_found" + i, rowSize);
|
||||
if (ImGuiNET.ImGui.IsItemHovered()) dl.AddRectFilled(rowMin, rowMin + rowSize, Selected, 3);
|
||||
dl.AddText(rowMin + new Vector2(6, 3), Text, p.Name);
|
||||
string t = p.Type;
|
||||
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(t);
|
||||
dl.AddText(rowMin + new Vector2(rowSize.X - ts.X - 6, 3), Mute, t);
|
||||
if (clicked) pick = p;
|
||||
}
|
||||
if (pick != null) PickFound(pick);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/WorldMapMaps.cs
|
||||
// Which World Map picture to use. NavData and MapPacks can hold up to four, each a pyramid of tiles at its own
|
||||
// resolution (RynthNav.Baker --map-world): worldmap-p64.rmap (Maximum, 64 px per cell), worldmap-p32.rmap (Extreme, 32), worldmap-ultra.rmap (16), worldmap-hd.rmap (8) and
|
||||
// worldmap.rmap (Standard: the one everybody gets). The launcher offers the bigger ones as optional
|
||||
// downloads, so a PC may have any of them: by default the best installed is used, and the Show menu's Detail
|
||||
// list lets a player pick another that is installed. The choice is remembered (WorldMapSettings.Detail).
|
||||
// The folder is scanned on a pool thread (no file access on AC's thread); a change of file is made by
|
||||
// WorldMapTiles.Switch at the start of the next frame.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
internal static class WorldMapMaps
|
||||
{
|
||||
internal readonly record struct Tier(string Key, string Label, string File);
|
||||
|
||||
/// <summary>Best first.</summary>
|
||||
public static readonly Tier[] Tiers =
|
||||
{
|
||||
new("maximum", "Maximum", "worldmap-p64.rmap"),
|
||||
new("extreme", "Extreme", "worldmap-p32.rmap"),
|
||||
new("ultra", "Ultra", "worldmap-ultra.rmap"),
|
||||
new("hd", "HD", "worldmap-hd.rmap"),
|
||||
new("standard", "Standard", "worldmap.rmap"),
|
||||
};
|
||||
|
||||
private static volatile Tier[] _installed = Array.Empty<Tier>();
|
||||
private static volatile bool _scanned;
|
||||
private static volatile Dictionary<string, string> _paths = new(); // tier key -> the file found
|
||||
|
||||
/// <summary>RynthNav's data folder: where the plugin says it is, else the default. Any thread.</summary>
|
||||
public static string Dir
|
||||
{
|
||||
get
|
||||
{
|
||||
string dir = UiSources.RynthNav.Current?.Value?.NavDir ?? "";
|
||||
return dir.Length > 0 && Path.IsPathFullyQualified(dir) ? dir.TrimEnd((char)92, (char)47) : Path.Combine(RynthCore.Install.RynthInstallPaths.CoreDir, "NavData");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Where the launcher puts the optional sizes: MapPacks, beside the NavData folder.</summary>
|
||||
public static string PacksDir => Path.Combine(Path.GetDirectoryName(Dir) ?? Dir, "MapPacks");
|
||||
|
||||
/// <summary>The tiers found on the last scan, best first (empty until the first scan finishes).</summary>
|
||||
public static Tier[] Installed => _installed;
|
||||
public static bool Scanned => _scanned;
|
||||
|
||||
/// <summary>The file found for a tier (the NavData name when none was found, so a status can name it).</summary>
|
||||
public static string PathOf(Tier t) => _paths.TryGetValue(t.Key, out string? p) ? p : Path.Combine(Dir, t.File);
|
||||
|
||||
/// <summary>The tier the setting calls for: that one if installed, else the best installed ("" and null when none).</summary>
|
||||
public static Tier? Resolve(string preference)
|
||||
{
|
||||
Tier[] have = _installed;
|
||||
if (have.Length == 0) return null;
|
||||
foreach (Tier t in have) if (t.Key == preference) return t;
|
||||
return have[0];
|
||||
}
|
||||
|
||||
/// <summary>Scans the folder and (re)opens the chosen file, without touching AC's thread. Any thread.</summary>
|
||||
public static void Refresh()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
var found = new List<Tier>();
|
||||
var paths = new Dictionary<string, string>();
|
||||
string[] dirs = { PacksDir, Dir }; // a pack the launcher installed, else the one with the RynthNav data
|
||||
foreach (Tier t in Tiers)
|
||||
{
|
||||
foreach (string d in dirs)
|
||||
{
|
||||
string f = Path.Combine(d, t.File);
|
||||
try { if (File.Exists(f)) { found.Add(t); paths[t.Key] = f; break; } } catch { }
|
||||
}
|
||||
}
|
||||
_paths = paths;
|
||||
_installed = found.ToArray();
|
||||
_scanned = true;
|
||||
Apply();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Opens (or switches to) the file the current setting resolves to.</summary>
|
||||
public static void Apply()
|
||||
{
|
||||
Tier? t = Resolve(WorldMapSettings.Detail);
|
||||
// Nothing installed: ask for the Standard name, so the faces say "No world map file yet".
|
||||
string path = t is Tier tier ? PathOf(tier) : PathOf(Tiers[^1]);
|
||||
if (WorldMapTiles.CurrentPath.Length == 0) WorldMapTiles.Open(path);
|
||||
else WorldMapTiles.Switch(path);
|
||||
}
|
||||
|
||||
/// <summary>The label of the tier in use ("" until a file is open).</summary>
|
||||
public static string CurrentLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
string cur = WorldMapTiles.CurrentPath;
|
||||
foreach (Tier t in Tiers) if (cur.EndsWith(t.File, StringComparison.OrdinalIgnoreCase)) return t.Label;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/WorldMapSettings.cs
|
||||
// What the World Map and the Mini Map remember: each view's zoom, Follow and Rotate, and the layer
|
||||
// switches they share (which kinds of place, labels, route, path, grid, other characters).
|
||||
// Engine-wide, in %LOCALAPPDATA%\RynthCore\world_map_settings.txt, like dungeon_map_settings.txt.
|
||||
// Zoom changes a lot (every wheel tick), so a change only marks the settings dirty; Draw calls
|
||||
// FlushIfDue and the file is written (in the background) once nothing has changed for 1.5 s.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using RynthCore.Engine.UI;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
internal static class WorldMapSettings
|
||||
{
|
||||
internal sealed class ViewState
|
||||
{
|
||||
public float Scale = 1.5f; // screen px per cell
|
||||
public bool Follow = true, Rotate;
|
||||
}
|
||||
|
||||
public static readonly ViewState Full = new() { Scale = 1.5f, Follow = true, Rotate = false };
|
||||
public static readonly ViewState Mini = new() { Scale = 2.5f, Follow = true, Rotate = true };
|
||||
|
||||
/// <summary>Which kinds of place show (WorldMapView.Kind order).</summary>
|
||||
public static readonly bool[] Show = { true, true, true, true, true, true, true, true };
|
||||
/// <summary>Which map picture: a WorldMapMaps tier key ("ultra", "hd", "standard"), or "" for the best installed.</summary>
|
||||
public static string Detail = "";
|
||||
public static bool Labels = true, Route = true, WalkPath = true, Grid = true, Characters = true, Buildings = true;
|
||||
|
||||
private static readonly object Sync = new();
|
||||
private static bool _loaded;
|
||||
private static long _dirtyAtMs; // 0: nothing to write
|
||||
|
||||
private static string FilePath =>
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "RynthCore", "world_map_settings.txt");
|
||||
|
||||
/// <summary>Reads the file once. Engine init thread or any pool thread (not AC's).</summary>
|
||||
public static void Load()
|
||||
{
|
||||
lock (Sync)
|
||||
{
|
||||
if (_loaded) return;
|
||||
_loaded = true;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(FilePath)) return;
|
||||
foreach (string raw in File.ReadAllLines(FilePath))
|
||||
{
|
||||
string line = raw.Trim();
|
||||
if (line.Length == 0 || line[0] == '#') continue;
|
||||
int eq = line.IndexOf('=');
|
||||
if (eq <= 0) continue;
|
||||
string key = line[..eq].Trim(), val = line[(eq + 1)..].Trim();
|
||||
bool on = val == "1";
|
||||
switch (key)
|
||||
{
|
||||
case "full.scale": Full.Scale = ParseScale(val, Full.Scale); break;
|
||||
case "full.follow": Full.Follow = on; break;
|
||||
case "full.rotate": Full.Rotate = on; break;
|
||||
case "mini.scale": Mini.Scale = ParseScale(val, Mini.Scale); break;
|
||||
case "mini.follow": Mini.Follow = on; break;
|
||||
case "mini.rotate": Mini.Rotate = on; break;
|
||||
case "detail": Detail = val is "maximum" or "extreme" or "ultra" or "hd" or "standard" ? val : ""; break;
|
||||
case "labels": Labels = on; break;
|
||||
case "route": Route = on; break;
|
||||
case "path": WalkPath = on; break;
|
||||
case "grid": Grid = on; break;
|
||||
case "characters": Characters = on; break;
|
||||
case "buildings": Buildings = on; break;
|
||||
default:
|
||||
if (key.StartsWith("show.", StringComparison.Ordinal)
|
||||
&& int.TryParse(key.AsSpan(5), NumberStyles.Integer, CultureInfo.InvariantCulture, out int k) && (uint)k < (uint)Show.Length)
|
||||
Show[k] = on;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { /* best-effort: the defaults are in place */ }
|
||||
}
|
||||
}
|
||||
|
||||
private static float ParseScale(string v, float fallback) =>
|
||||
float.TryParse(v, NumberStyles.Float, CultureInfo.InvariantCulture, out float f) && float.IsFinite(f) ? Math.Clamp(f, 0.12f, 14f) : fallback;
|
||||
|
||||
/// <summary>Something changed: the file is written when it has been quiet for a moment. Any thread.</summary>
|
||||
public static void MarkDirty() => _dirtyAtMs = Math.Max(1, Environment.TickCount64);
|
||||
|
||||
/// <summary>AC's render thread, once a frame: writes the file if a change has settled.</summary>
|
||||
public static void FlushIfDue()
|
||||
{
|
||||
long at = _dirtyAtMs;
|
||||
if (at == 0 || Environment.TickCount64 - at < 1500) return;
|
||||
_dirtyAtMs = 0;
|
||||
var sb = new StringBuilder("# RynthCore world map settings - auto-generated, hand-edits OK.\n");
|
||||
void Flag(string k, bool v) => sb.Append(k).Append('=').Append(v ? '1' : '0').Append('\n');
|
||||
sb.Append(CultureInfo.InvariantCulture, $"full.scale={Full.Scale:0.###}\n"); Flag("full.follow", Full.Follow); Flag("full.rotate", Full.Rotate);
|
||||
sb.Append(CultureInfo.InvariantCulture, $"mini.scale={Mini.Scale:0.###}\n"); Flag("mini.follow", Mini.Follow); Flag("mini.rotate", Mini.Rotate);
|
||||
for (int i = 0; i < Show.Length; i++) Flag("show." + i, Show[i]);
|
||||
sb.Append("detail=").Append(Detail).Append((char)10);
|
||||
Flag("labels", Labels); Flag("route", Route); Flag("path", WalkPath); Flag("grid", Grid); Flag("characters", Characters); Flag("buildings", Buildings);
|
||||
string text = sb.ToString();
|
||||
UiBackgroundWriter.Enqueue("world map settings", () =>
|
||||
{
|
||||
lock (Sync)
|
||||
{
|
||||
try
|
||||
{
|
||||
string? dir = Path.GetDirectoryName(FilePath);
|
||||
if (!string.IsNullOrEmpty(dir)) Directory.CreateDirectory(dir);
|
||||
File.WriteAllText(FilePath, text);
|
||||
}
|
||||
catch { /* non-fatal */ }
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1,833 +0,0 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/WorldMapView.cs
|
||||
// The map itself, drawn into a rectangle by the World Map face (full: toolbar, find box) and the
|
||||
// Mini Map face (a small follow-you view). One class so both look and behave the same.
|
||||
//
|
||||
// The picture is NavData\worldmap.rmap (WorldMapTiles; RynthNav.Baker --map --map-tiles renders it
|
||||
// from client_cell_1.dat): a pyramid of 256 px tiles, so zooming in loads sharper tiles under the
|
||||
// view and the coarser ones already loaded show meanwhile.
|
||||
//
|
||||
// On it (bottom to top): the tiles; a coordinate grid with edge labels; RynthNav's route (legs
|
||||
// between its steps, a dashed jump for a portal / recall / Town Network step, the current step
|
||||
// ringed) and the walking path it worked out; the Atlas's places (each kind from its own zoom,
|
||||
// labels from a closer one, none that would overlap one already drawn); your other characters
|
||||
// (RynthNet); a search highlight; the arrow's target; you (an arrow while RynthAi's radar feed
|
||||
// gives a heading, a dot from RynthNav alone, dimmed at the last outdoor spot while indoors).
|
||||
//
|
||||
// Rotate turns the map so the way you face is up (the arrow points up, the compass shows north).
|
||||
// Drag pans (and turns Follow off), the wheel zooms about the cursor. A click (full) or a right
|
||||
// click (both) on the map or a place opens a menu: Go here, Route here, Arrow here, Copy
|
||||
// coordinates (RynthNav's commands, RynthNavCommands).
|
||||
//
|
||||
// Coordinates: a "cell" is 24 yards, 10 per map degree: cell = degrees * 10 + 1019.5 on each axis
|
||||
// (the same numbers as NavCoords). The map works in cell units; the picture is cells * PixelsPerCell.
|
||||
// Screen = centre + R(phi) * (east, -north) * scale, phi = heading - 90 degrees when rotating.
|
||||
//
|
||||
// Data (subscribed by the faces while open): UiSources.RynthNav (position, route, arrow, path),
|
||||
// UiSources.Radar (heading), UiSources.Characters (other characters, when that layer is on).
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
using static RynthCore.Engine.ImGuiBackend.Panels.FaceKit;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
/// <summary>Where you are, for the toolbar and the view: this frame's reading, with the last outdoor spot kept.</summary>
|
||||
internal readonly struct MapPlayer
|
||||
{
|
||||
public MapPlayer(bool have, double ns, double ew, float heading, bool indoors, double lastNs, double lastEw)
|
||||
{ Have = have; Ns = ns; Ew = ew; Heading = heading; Indoors = indoors; LastNs = lastNs; LastEw = lastEw; }
|
||||
/// <summary>An outdoor position this frame.</summary>
|
||||
public readonly bool Have;
|
||||
public readonly double Ns, Ew;
|
||||
public readonly float Heading; // degrees, 0 = east, 90 = north; NaN when only RynthNav's pose is known
|
||||
public readonly bool Indoors;
|
||||
public readonly double LastNs, LastEw; // the last outdoor spot (NaN: never outdoors this session)
|
||||
public bool Known => Have || !double.IsNaN(LastNs);
|
||||
public double ShowNs => Have ? Ns : LastNs;
|
||||
public double ShowEw => Have ? Ew : LastEw;
|
||||
}
|
||||
|
||||
internal sealed class WorldMapView
|
||||
{
|
||||
public enum Kind { Town, Landmark, Dungeon, Lifestone, Bindstone, Portal, Vendor, Npc, Count }
|
||||
public static readonly string[] KindNames = { "Towns", "Landmarks", "Dungeons", "Lifestones", "Bindstones", "Portals", "Vendors", "NPCs" };
|
||||
|
||||
// ── Constants ────────────────────────────────────────────────────────
|
||||
public const double Origin = 1019.5; // cell = degrees * 10 + Origin
|
||||
public const float MinScale = 0.12f, MaxScale = 14f, AbsMaxScale = 160f; // screen px per cell
|
||||
/// <summary>How far in the open map is worth zooming: a sharper map (more pixels per cell) allows more, up to 1.25x its own detail.</summary>
|
||||
private static float MaxScaleNow => WorldMapTiles.IsOpen ? Math.Clamp(WorldMapTiles.PixelsPerCell * 1.25f, MaxScale, AbsMaxScale) : MaxScale;
|
||||
private static readonly float[] ShowFrom = { 0f, 1.2f, 1.0f, 2.0f, 2.0f, 3.0f, 5.0f, 6.0f };
|
||||
private static readonly float[] LabelFrom = { 0.45f, 3f, 2.5f, 5f, 5f, 6f, 8f, 10f };
|
||||
private static readonly uint OceanBg = RynthTheme.Argb(0xFF1C4276);
|
||||
private static readonly uint[] KindColour =
|
||||
{
|
||||
RynthTheme.Argb(0xFFFFD24D), RynthTheme.Argb(0xFFFFFFFF), RynthTheme.Argb(0xFFC77DFF), RynthTheme.Argb(0xFF5CE1E6),
|
||||
RynthTheme.Argb(0xFF3DDC97), RynthTheme.Argb(0xFFFF6BD6), RynthTheme.Argb(0xFFFF9F43), RynthTheme.Argb(0xFFF2F2A0),
|
||||
};
|
||||
private static readonly uint LabelCol = RynthTheme.Argb(0xFFF4F7FA), LabelHalo = RynthTheme.Argb(0xE0000000),
|
||||
RouteCol = RynthTheme.Argb(0xFFFFA733), RouteActive = RynthTheme.Argb(0xFFFFF04D), PathCol = RynthTheme.Argb(0xFF5AD2FF),
|
||||
TargetCol = RynthTheme.Argb(0xFF4DD2FF), PlayerFill = RynthTheme.Argb(0xFF33FF66), PlayerEdge = RynthTheme.Argb(0xFF0A2A12),
|
||||
CharCol = RynthTheme.Argb(0xFF6EA8FF), HintCol = RynthTheme.Argb(0xFF9FB3C8), BarBg = RynthTheme.Argb(0xE00A121A),
|
||||
RoadCol = RynthTheme.Argb(0xFFE6CD78), RoadHalo = RynthTheme.Argb(0xB0301C08), BuildFill = RynthTheme.Argb(0xFF9A4B40),
|
||||
BuildEdge = RynthTheme.Argb(0xFF2A1410), GridLine = RynthTheme.Argb(0x30FFFFFF), GridLabel = RynthTheme.Argb(0xC0DDE8F4), HighlightCol = RynthTheme.Argb(0xFFFFFFFF);
|
||||
|
||||
// ── Places (shared by every view; rebuilt when the Atlas reloads) ────
|
||||
private readonly struct Mark
|
||||
{
|
||||
public Mark(float cx, float cy, string name, Kind kind, NavPlace place) { Cx = cx; Cy = cy; Name = name; Kind = kind; Place = place; }
|
||||
public readonly float Cx, Cy;
|
||||
public readonly string Name;
|
||||
public readonly Kind Kind;
|
||||
public readonly NavPlace Place;
|
||||
}
|
||||
private static Mark[]? _marks;
|
||||
private static long _marksVersion = -1;
|
||||
private static double _lastNs = double.NaN, _lastEw = double.NaN; // the last outdoor spot, shared by both views
|
||||
|
||||
public static double CellOf(double degrees) => degrees * 10.0 + Origin;
|
||||
public static double DegreesOf(double cell) => (cell - Origin) / 10.0;
|
||||
|
||||
// ── This view ────────────────────────────────────────────────────────
|
||||
public readonly bool Mini;
|
||||
private readonly WorldMapSettings.ViewState _st;
|
||||
private double _ccx = 1019.5, _ccy = 1019.5; // map cell at the canvas centre
|
||||
private bool _fitNext, _centreNext;
|
||||
private Vector2 _centre;
|
||||
private float _phi; // the map's rotation this frame (radians)
|
||||
private float _scale;
|
||||
private MapProjection Proj => new(_centre, _ccx, _ccy, _scale, _phi);
|
||||
|
||||
public float Scale => _scale;
|
||||
public bool Follow { get => _st.Follow; set { if (_st.Follow != value) { _st.Follow = value; WorldMapSettings.MarkDirty(); } } }
|
||||
public bool Rotate { get => _st.Rotate; set { if (_st.Rotate != value) { _st.Rotate = value; WorldMapSettings.MarkDirty(); } } }
|
||||
/// <summary>The line the toolbar shows for the point under the cursor ("" when none).</summary>
|
||||
public string HoverText { get; private set; } = "";
|
||||
/// <summary>A screen rectangle the face has covered (a dropdown): the map ignores the mouse inside it.</summary>
|
||||
public (Vector2 Min, Vector2 Max)? Blocked;
|
||||
|
||||
// Interaction.
|
||||
private bool _pressing, _pressMoved;
|
||||
private int _hoverMark = -1, _hoverChar = -1;
|
||||
private double _ctxNs, _ctxEw;
|
||||
private string _ctxName = "";
|
||||
private bool _openCtx;
|
||||
private readonly string _ctxId;
|
||||
private string _hiName = "";
|
||||
private double _hiNs, _hiEw;
|
||||
private long _hiUntilMs;
|
||||
private readonly List<(Vector2 Min, Vector2 Max)> _labelRects = new(128);
|
||||
private readonly List<(Vector2 Pos, int Index)> _drawn = new(256);
|
||||
private readonly List<(Vector2 Pos, int Index)> _drawnChars = new(16);
|
||||
private readonly List<(int Dist, int Col, int Row)> _tileOrder = new(128);
|
||||
private CharacterRow[] _chars = Array.Empty<CharacterRow>();
|
||||
|
||||
public WorldMapView(bool mini)
|
||||
{
|
||||
Mini = mini;
|
||||
_st = mini ? WorldMapSettings.Mini : WorldMapSettings.Full;
|
||||
_scale = Math.Clamp(_st.Scale, MinScale, AbsMaxScale);
|
||||
_ctxId = mini ? "##mm_ctx" : "##wm_ctx";
|
||||
}
|
||||
|
||||
// ── Commands from the face ───────────────────────────────────────────
|
||||
public void FitWorld() { _fitNext = true; }
|
||||
|
||||
public void ZoomBy(float k, Vector2? about = null)
|
||||
{
|
||||
float old = _scale;
|
||||
float next = Math.Clamp(_scale * k, MinScale, MaxScaleNow);
|
||||
if (next == old) return;
|
||||
if (about is Vector2 m && !_st.Follow)
|
||||
(_ccx, _ccy) = Proj.CentreForZoomAbout(m, next);
|
||||
_scale = next;
|
||||
_st.Scale = _scale;
|
||||
WorldMapSettings.MarkDirty();
|
||||
}
|
||||
|
||||
/// <summary>Centres on a map point (degrees), zooming in to at least <paramref name="minScale"/>, and rings it for a few seconds.</summary>
|
||||
public void Show(string name, double ns, double ew, float minScale)
|
||||
{
|
||||
Follow = false;
|
||||
_ccx = CellOf(ew); _ccy = CellOf(ns);
|
||||
if (_scale < minScale) { _scale = Math.Min(minScale, MaxScaleNow); _st.Scale = _scale; WorldMapSettings.MarkDirty(); }
|
||||
_hiName = name; _hiNs = ns; _hiEw = ew;
|
||||
_hiUntilMs = Environment.TickCount64 + 6000;
|
||||
}
|
||||
|
||||
// ── Projection (MapProjection) ───────────────────────────────────────
|
||||
private Vector2 Project(double cx, double cy) => Proj.Project(cx, cy);
|
||||
private Vector2 ProjectDeg(double ns, double ew) => Proj.Project(CellOf(ew), CellOf(ns));
|
||||
private void Unproject(Vector2 p, out double cx, out double cy) => Proj.Unproject(p, out cx, out cy);
|
||||
private Vector2 ScreenDir(float east, float north) => Proj.ScreenDir(east, north);
|
||||
|
||||
// ── Player ───────────────────────────────────────────────────────────
|
||||
/// <summary>Reads where you are: the radar feed (heading), else RynthNav's pose. Indoors keeps the last outdoor spot.</summary>
|
||||
public static MapPlayer GatherPlayer(RynthNavStatus? st, RadarView? radar)
|
||||
{
|
||||
double ns = double.NaN, ew = double.NaN;
|
||||
float heading = float.NaN;
|
||||
bool indoors = false;
|
||||
if (radar != null)
|
||||
{
|
||||
indoors = radar.Live.IsIndoor;
|
||||
if (!indoors && !double.IsNaN(radar.Live.Ns) && !double.IsNaN(radar.Live.Ew)) { ns = radar.Live.Ns; ew = radar.Live.Ew; heading = radar.Live.Player.Heading; }
|
||||
}
|
||||
if (double.IsNaN(ns) && st != null && st.HasPose)
|
||||
{
|
||||
indoors = indoors || st.Indoors;
|
||||
if (!st.Indoors) { ns = st.NS; ew = st.EW; }
|
||||
}
|
||||
if (!double.IsNaN(ns)) { _lastNs = ns; _lastEw = ew; }
|
||||
return new MapPlayer(!double.IsNaN(ns), ns, ew, heading, indoors, _lastNs, _lastEw);
|
||||
}
|
||||
|
||||
// ── The frame ────────────────────────────────────────────────────────
|
||||
/// <summary>Draws the map into the canvas and handles its input. AC's render thread, inside a face's Draw.</summary>
|
||||
public void Draw(Vector2 canvasMin, Vector2 canvasMax, in MapPlayer pl, RynthNavStatus? st, CharacterRow[]? chars)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
Vector2 csize = canvasMax - canvasMin;
|
||||
if (csize.X < 40 || csize.Y < 40) return;
|
||||
_centre = (canvasMin + canvasMax) * 0.5f;
|
||||
_chars = chars ?? Array.Empty<CharacterRow>();
|
||||
|
||||
if (_fitNext)
|
||||
{
|
||||
_fitNext = false;
|
||||
Follow = false; Rotate = false;
|
||||
_scale = Math.Clamp(Math.Min(csize.X, csize.Y) / (float)WorldMapTiles.CellsHigh, MinScale, MaxScale);
|
||||
_st.Scale = _scale;
|
||||
_ccx = WorldMapTiles.CellsWide * 0.5; _ccy = WorldMapTiles.CellsHigh * 0.5;
|
||||
WorldMapSettings.MarkDirty();
|
||||
}
|
||||
if (_scale > MaxScaleNow) { _scale = MaxScaleNow; _st.Scale = _scale; }
|
||||
_phi = _st.Rotate && !float.IsNaN(pl.Heading) && pl.Have ? MapProjection.PhiForHeading(pl.Heading) : 0f;
|
||||
if (_st.Follow && pl.Known) { _ccx = CellOf(pl.ShowEw); _ccy = CellOf(pl.ShowNs); }
|
||||
|
||||
dl.AddRectFilled(canvasMin, canvasMax, OceanBg);
|
||||
dl.PushClipRect(canvasMin, canvasMax, true);
|
||||
DrawTiles(dl, canvasMin, canvasMax);
|
||||
_labelRects.Clear(); _drawn.Clear(); _drawnChars.Clear();
|
||||
if (WorldMapSettings.Grid) DrawGrid(dl, canvasMin, canvasMax, _phi != 0f);
|
||||
if (WorldMapSettings.Buildings) DrawVectors(dl, canvasMin, canvasMax);
|
||||
if (WorldMapSettings.Route) DrawRoute(dl, st, pl);
|
||||
DrawMarkers(dl, canvasMin, canvasMax);
|
||||
if (WorldMapSettings.Characters) DrawCharacters(dl, canvasMin, canvasMax);
|
||||
DrawHighlight(dl);
|
||||
DrawTarget(dl, st);
|
||||
DrawPlayer(dl, pl);
|
||||
dl.PopClipRect();
|
||||
dl.AddRect(canvasMin, canvasMax, BtnBord);
|
||||
DrawScaleBar(dl, canvasMin, canvasMax);
|
||||
DrawCompass(dl, canvasMax);
|
||||
|
||||
if (!WorldMapTiles.IsOpen || WorldMapTiles.Levels.Count == 0)
|
||||
DrawCentred(dl, _centre, WorldMapTiles.Status.Length > 0 ? WorldMapTiles.Status : "Loading the map...");
|
||||
else if (pl.Indoors && !pl.Have && pl.Known && _st.Follow)
|
||||
DrawCentred(dl, new Vector2(_centre.X, canvasMin.Y + 20), "Indoors: the map shows where you went in.");
|
||||
else if (!pl.Known && _st.Follow)
|
||||
DrawCentred(dl, new Vector2(_centre.X, canvasMin.Y + 20), "Waiting for your position...");
|
||||
|
||||
Input(canvasMin, canvasMax, pl);
|
||||
DrawContextMenu();
|
||||
}
|
||||
|
||||
// ── Tiles ────────────────────────────────────────────────────────────
|
||||
private void DrawTiles(ImDrawListPtr dl, Vector2 canvasMin, Vector2 canvasMax)
|
||||
{
|
||||
var levels = WorldMapTiles.Levels;
|
||||
if (!WorldMapTiles.IsOpen || levels.Count == 0) return;
|
||||
int ppc0 = WorldMapTiles.PixelsPerCell, top = levels.Count - 1;
|
||||
double cellsHigh = WorldMapTiles.CellsHigh;
|
||||
// The map area in view: the canvas as it is, or (turned) the circle around it.
|
||||
double halfW = (canvasMax.X - canvasMin.X) * 0.5, halfH = (canvasMax.Y - canvasMin.Y) * 0.5;
|
||||
if (_phi != 0f) { halfW = halfH = Math.Sqrt(halfW * halfW + halfH * halfH); }
|
||||
double cxMin = _ccx - halfW / _scale, cxMax = _ccx + halfW / _scale;
|
||||
double cyMin = _ccy - halfH / _scale, cyMax = _ccy + halfH / _scale;
|
||||
|
||||
// The sharpest level whose pixels are at least as dense as the screen's; a coarser one if that is too many tiles.
|
||||
int L = Math.Clamp((int)Math.Floor(Math.Log2(ppc0 / (double)_scale)), 0, top);
|
||||
while (L < top && VisibleTiles(L, ppc0, cellsHigh, cxMin, cxMax, cyMin, cyMax) > 80) L++;
|
||||
|
||||
// Coarse to fine: the top level (always loaded) first, so whatever hasn't arrived shows blurry, not blank.
|
||||
for (int lv = top; lv >= L; lv--)
|
||||
DrawLevel(dl, lv, ppc0, cellsHigh, cxMin, cxMax, cyMin, cyMax, request: lv <= Math.Min(top, L + 1));
|
||||
}
|
||||
|
||||
private static int VisibleTiles(int lv, int ppc0, double cellsHigh, double cxMin, double cxMax, double cyMin, double cyMax)
|
||||
{
|
||||
double cpt = WorldMapTiles.TileSize * (double)(1 << lv) / ppc0;
|
||||
int cols = (int)Math.Floor(Math.Min(cxMax, WorldMapTiles.CellsWide) / cpt) - (int)Math.Floor(Math.Max(cxMin, 0) / cpt) + 1;
|
||||
int rows = (int)Math.Floor((cellsHigh - Math.Max(cyMin, 0)) / cpt) - (int)Math.Floor((cellsHigh - Math.Min(cyMax, cellsHigh)) / cpt) + 1;
|
||||
return Math.Max(cols, 0) * Math.Max(rows, 0);
|
||||
}
|
||||
|
||||
private void DrawLevel(ImDrawListPtr dl, int lv, int ppc0, double cellsHigh, double cxMin, double cxMax, double cyMin, double cyMax, bool request)
|
||||
{
|
||||
var lvl = WorldMapTiles.Levels[lv];
|
||||
double cpt = WorldMapTiles.TileSize * (double)(1 << lv) / ppc0;
|
||||
int c0 = Math.Max(0, (int)Math.Floor(cxMin / cpt)), c1 = Math.Min(lvl.Cols - 1, (int)Math.Floor(cxMax / cpt));
|
||||
int r0 = Math.Max(0, (int)Math.Floor((cellsHigh - cyMax) / cpt)), r1 = Math.Min(lvl.Rows - 1, (int)Math.Floor((cellsHigh - cyMin) / cpt));
|
||||
if (c1 < c0 || r1 < r0) return;
|
||||
|
||||
// Centre-out, so the tiles you're looking at load first.
|
||||
_tileOrder.Clear();
|
||||
double ccol = _ccx / cpt, crow = (cellsHigh - _ccy) / cpt;
|
||||
for (int r = r0; r <= r1; r++)
|
||||
for (int c = c0; c <= c1; c++)
|
||||
{
|
||||
double dx = c + 0.5 - ccol, dy = r + 0.5 - crow;
|
||||
_tileOrder.Add(((int)((dx * dx + dy * dy) * 1000), c, r));
|
||||
}
|
||||
_tileOrder.Sort(static (a, b) => a.Dist.CompareTo(b.Dist));
|
||||
|
||||
bool turned = _phi != 0f;
|
||||
for (int i = _tileOrder.Count - 1; i >= 0; i--) // draw far to near; nothing overlaps within a level
|
||||
{
|
||||
var (_, c, r) = _tileOrder[i];
|
||||
IntPtr tex;
|
||||
if (!(request ? WorldMapTiles.TryGet(lv, c, r, out tex) : WorldMapTiles.Peek(lv, c, r, out tex))) continue;
|
||||
double left = c * cpt, right = (c + 1) * cpt, topCell = cellsHigh - r * cpt, bottomCell = cellsHigh - (r + 1) * cpt;
|
||||
if (!turned)
|
||||
{
|
||||
// Edges from the same formula for both neighbours, rounded to whole pixels: no seams, no gaps.
|
||||
float x0 = MathF.Round(_centre.X + (float)((left - _ccx) * _scale)), x1 = MathF.Round(_centre.X + (float)((right - _ccx) * _scale));
|
||||
float y0 = MathF.Round(_centre.Y - (float)((topCell - _ccy) * _scale)), y1 = MathF.Round(_centre.Y - (float)((bottomCell - _ccy) * _scale));
|
||||
dl.AddImage(tex, new Vector2(x0, y0), new Vector2(x1, y1));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Turned: a quad, grown by a pixel so neighbours overlap instead of showing a hairline.
|
||||
Vector2 tl = Project(left, topCell), tr = Project(right, topCell), br = Project(right, bottomCell), bl = Project(left, bottomCell);
|
||||
Vector2 mid = (tl + br) * 0.5f;
|
||||
tl = Grow(tl, mid); tr = Grow(tr, mid); br = Grow(br, mid); bl = Grow(bl, mid);
|
||||
dl.AddImageQuad(tex, tl, tr, br, bl, new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Vector2 Grow(Vector2 p, Vector2 mid)
|
||||
{
|
||||
Vector2 d = p - mid;
|
||||
float len = d.Length();
|
||||
return len < 1f ? p : p + d / len * 0.8f;
|
||||
}
|
||||
|
||||
// ── Grid ─────────────────────────────────────────────────────────────
|
||||
private void DrawGrid(ImDrawListPtr dl, Vector2 canvasMin, Vector2 canvasMax, bool turned)
|
||||
{
|
||||
float pxPerDeg = 10f * _scale;
|
||||
float[] steps = { 50f, 20f, 10f, 5f, 2f, 1f, 0.5f, 0.2f, 0.1f, 0.05f };
|
||||
float step = steps[0];
|
||||
foreach (float s in steps) if (s * pxPerDeg >= 90f) step = s;
|
||||
if (step * pxPerDeg < 40f) return;
|
||||
double halfW = (canvasMax.X - canvasMin.X) * 0.5, halfH = (canvasMax.Y - canvasMin.Y) * 0.5;
|
||||
double r = Math.Sqrt(halfW * halfW + halfH * halfH) / _scale; // cells, the circle around the canvas
|
||||
double nsMin = DegreesOf(_ccy - r), nsMax = DegreesOf(_ccy + r), ewMin = DegreesOf(_ccx - r), ewMax = DegreesOf(_ccx + r);
|
||||
string fmt = step >= 1f ? "0" : step >= 0.1f ? "0.0" : "0.00";
|
||||
int lines = 0;
|
||||
for (double ns = Math.Ceiling(nsMin / step) * step; ns <= nsMax && lines < 60; ns += step, lines++)
|
||||
{
|
||||
Vector2 a = ProjectDeg(ns, ewMin), b = ProjectDeg(ns, ewMax);
|
||||
dl.AddLine(a, b, GridLine, 1f);
|
||||
if (!turned) EdgeLabel(dl, new Vector2(canvasMin.X + 4, a.Y - 14), canvasMin, canvasMax, Fmt(ns, fmt, 'N', 'S'));
|
||||
}
|
||||
for (double ew = Math.Ceiling(ewMin / step) * step; ew <= ewMax && lines < 120; ew += step, lines++)
|
||||
{
|
||||
Vector2 a = ProjectDeg(nsMin, ew), b = ProjectDeg(nsMax, ew);
|
||||
dl.AddLine(a, b, GridLine, 1f);
|
||||
if (!turned) EdgeLabel(dl, new Vector2(a.X + 3, canvasMin.Y + 3), canvasMin, canvasMax, Fmt(ew, fmt, 'E', 'W'));
|
||||
}
|
||||
}
|
||||
|
||||
private static string Fmt(double v, string fmt, char pos, char neg) =>
|
||||
Math.Abs(v).ToString(fmt, CultureInfo.InvariantCulture) + (v >= 0 ? pos : neg);
|
||||
|
||||
private static void EdgeLabel(ImDrawListPtr dl, Vector2 at, Vector2 min, Vector2 max, string text)
|
||||
{
|
||||
if (at.X < min.X || at.Y < min.Y || at.X > max.X - 30 || at.Y > max.Y - 14) return;
|
||||
dl.AddText(at + new Vector2(1, 1), LabelHalo, text);
|
||||
dl.AddText(at, GridLabel, text);
|
||||
}
|
||||
|
||||
// ── Roads and buildings (WorldMapVectors) ────────────────────────────
|
||||
private const float RoadsFrom = 1.5f, BuildingsFrom = 3f;
|
||||
private readonly Vector2[] _poly = new Vector2[16];
|
||||
|
||||
private void DrawVectors(ImDrawListPtr dl, Vector2 canvasMin, Vector2 canvasMax)
|
||||
{
|
||||
if (_scale < RoadsFrom) return;
|
||||
if (WorldMapTiles.IsOpen && WorldMapTiles.PixelsPerCell >= 8) return; // HD and up have the roads and the real roofs in the picture
|
||||
WorldMapVectors.Data? v = WorldMapVectors.Current;
|
||||
if (v == null) return;
|
||||
// The map area in view, in cells (the circle around the canvas when turned).
|
||||
double halfW = (canvasMax.X - canvasMin.X) * 0.5, halfH = (canvasMax.Y - canvasMin.Y) * 0.5;
|
||||
if (_phi != 0f) halfW = halfH = Math.Sqrt(halfW * halfW + halfH * halfH);
|
||||
float xMin = (float)(_ccx - halfW / _scale) - 1, xMax = (float)(_ccx + halfW / _scale) + 1;
|
||||
float yMin = (float)(_ccy - halfH / _scale) - 1, yMax = (float)(_ccy + halfH / _scale) + 1;
|
||||
|
||||
// Roads: a dark under-stroke and the road colour over it; wider as you zoom in.
|
||||
float w = Math.Clamp(_scale * 0.4f, 1.5f, 6f);
|
||||
ushort[] roads = v.Roads;
|
||||
int visible = 0;
|
||||
for (int i = 0; i + 3 < roads.Length && visible < 6000; i += 4)
|
||||
{
|
||||
float x0 = roads[i], y0 = roads[i + 1], x1 = roads[i + 2], y1 = roads[i + 3];
|
||||
if ((x0 < xMin && x1 < xMin) || (x0 > xMax && x1 > xMax) || (y0 < yMin && y1 < yMin) || (y0 > yMax && y1 > yMax)) continue;
|
||||
visible++;
|
||||
Vector2 a = Project(x0, y0), b = Project(x1, y1);
|
||||
dl.AddLine(a, b, RoadHalo, w + 1.5f);
|
||||
}
|
||||
visible = 0;
|
||||
for (int i = 0; i + 3 < roads.Length && visible < 6000; i += 4)
|
||||
{
|
||||
float x0 = roads[i], y0 = roads[i + 1], x1 = roads[i + 2], y1 = roads[i + 3];
|
||||
if ((x0 < xMin && x1 < xMin) || (x0 > xMax && x1 > xMax) || (y0 < yMin && y1 < yMin) || (y0 > yMax && y1 > yMax)) continue;
|
||||
visible++;
|
||||
dl.AddLine(Project(x0, y0), Project(x1, y1), RoadCol, w);
|
||||
}
|
||||
|
||||
if (_scale < BuildingsFrom) return;
|
||||
for (int i = 0; i < v.Buildings.Length; i++)
|
||||
{
|
||||
Vector4 bb = v.BuildingBounds[i];
|
||||
if (bb.Z < xMin || bb.X > xMax || bb.W < yMin || bb.Y > yMax) continue;
|
||||
Vector2[] pts = v.Buildings[i];
|
||||
int n = Math.Min(pts.Length, _poly.Length);
|
||||
if (n < 3) continue;
|
||||
float area = 0;
|
||||
for (int k = 0; k < n; k++)
|
||||
{
|
||||
Vector2 p = Project(pts[k].X, pts[k].Y);
|
||||
_poly[k] = p;
|
||||
}
|
||||
for (int k = 0; k < n; k++) { Vector2 a = _poly[k], b = _poly[(k + 1) % n]; area += a.X * b.Y - b.X * a.Y; }
|
||||
if (area < 0) Array.Reverse(_poly, 0, n); // ImGui wants one winding; the flip of y makes it vary
|
||||
dl.AddConvexPolyFilled(ref _poly[0], n, BuildFill);
|
||||
for (int k = 0; k < n; k++) dl.AddLine(_poly[k], _poly[(k + 1) % n], BuildEdge, 1.2f);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Places ───────────────────────────────────────────────────────────
|
||||
private static void EnsureMarks()
|
||||
{
|
||||
long v = RynthNavAtlas.Version;
|
||||
if (_marks != null && v == _marksVersion) return;
|
||||
var list = new List<Mark>(8192);
|
||||
foreach (NavPlace p in RynthNavAtlas.Places)
|
||||
{
|
||||
if (!p.OnMap || double.IsNaN(p.Ns) || double.IsNaN(p.Ew)) continue;
|
||||
Kind k;
|
||||
switch (p.Type)
|
||||
{
|
||||
case "Town": k = Kind.Town; break;
|
||||
case "Landmark": k = Kind.Landmark; break;
|
||||
case "Dungeon": k = Kind.Dungeon; break;
|
||||
case "Lifestone": k = Kind.Lifestone; break;
|
||||
case "Bindstone": k = Kind.Bindstone; break;
|
||||
case "Portal": k = Kind.Portal; break;
|
||||
case "Vendor": k = Kind.Vendor; break;
|
||||
case "NPC": k = Kind.Npc; break;
|
||||
default: continue;
|
||||
}
|
||||
list.Add(new Mark((float)CellOf(p.Ew), (float)CellOf(p.Ns), p.Name, k, p));
|
||||
}
|
||||
_marks = list.ToArray();
|
||||
_marksVersion = v;
|
||||
}
|
||||
|
||||
/// <summary>The Atlas's surface places whose name has <paramref name="query"/> in it, towns and dungeons first. Any thread.</summary>
|
||||
public static List<NavPlace> Find(string query, int max)
|
||||
{
|
||||
var res = new List<(int Rank, NavPlace Place)>();
|
||||
if (query.Length == 0) return new List<NavPlace>();
|
||||
foreach (NavPlace p in RynthNavAtlas.Places)
|
||||
{
|
||||
if (!p.OnMap || p.Name.Length == 0) continue;
|
||||
int at = p.Name.IndexOf(query, StringComparison.OrdinalIgnoreCase);
|
||||
if (at < 0) continue;
|
||||
int kind = p.Type switch { "Town" => 0, "Dungeon" => 1, "Landmark" => 2, "Lifestone" => 3, "Bindstone" => 3, "Portal" => 4, _ => 5 };
|
||||
res.Add((kind * 1000 + (at == 0 ? 0 : 400) + Math.Min(p.Name.Length, 399), p));
|
||||
}
|
||||
res.Sort(static (a, b) => a.Rank.CompareTo(b.Rank));
|
||||
var list = new List<NavPlace>(Math.Min(max, res.Count));
|
||||
for (int i = 0; i < res.Count && list.Count < max; i++) list.Add(res[i].Place);
|
||||
return list;
|
||||
}
|
||||
|
||||
private void DrawMarkers(ImDrawListPtr dl, Vector2 canvasMin, Vector2 canvasMax)
|
||||
{
|
||||
EnsureMarks();
|
||||
Mark[]? marks = _marks;
|
||||
if (marks == null) return;
|
||||
float s = _scale;
|
||||
// Towns first (they win a label overlap), then the rest in kind order.
|
||||
for (int pass = 0; pass < (int)Kind.Count; pass++)
|
||||
{
|
||||
if (!WorldMapSettings.Show[pass] || s < ShowFrom[pass]) continue;
|
||||
uint col = KindColour[pass];
|
||||
float rad = pass == (int)Kind.Town ? 5f : pass is (int)Kind.Npc or (int)Kind.Vendor ? 2.5f : 3.5f;
|
||||
bool label = WorldMapSettings.Labels && s >= LabelFrom[pass];
|
||||
for (int i = 0; i < marks.Length; i++)
|
||||
{
|
||||
ref readonly Mark m = ref marks[i];
|
||||
if ((int)m.Kind != pass) continue;
|
||||
Vector2 pt = Project(m.Cx, m.Cy);
|
||||
if (pt.X < canvasMin.X - 40 || pt.X > canvasMax.X + 40 || pt.Y < canvasMin.Y - 12 || pt.Y > canvasMax.Y + 12) continue;
|
||||
_drawn.Add((pt, i));
|
||||
bool hot = i == _hoverMark;
|
||||
DrawMarkShape(dl, pt, m.Kind, col, hot ? rad + 1.5f : rad);
|
||||
if (label || hot) DrawLabel(dl, pt, m.Name, rad, hot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawMarkShape(ImDrawListPtr dl, Vector2 p, Kind k, uint col, float r)
|
||||
{
|
||||
switch (k)
|
||||
{
|
||||
case Kind.Dungeon:
|
||||
dl.AddQuadFilled(p + new Vector2(0, -r - 1), p + new Vector2(r + 1, 0), p + new Vector2(0, r + 1), p + new Vector2(-r - 1, 0), col);
|
||||
dl.AddQuad(p + new Vector2(0, -r - 1), p + new Vector2(r + 1, 0), p + new Vector2(0, r + 1), p + new Vector2(-r - 1, 0), LabelHalo, 1f);
|
||||
break;
|
||||
case Kind.Town:
|
||||
dl.AddCircleFilled(p, r + 1, LabelHalo);
|
||||
dl.AddCircleFilled(p, r, col);
|
||||
dl.AddCircleFilled(p, r - 2.5f, LabelHalo);
|
||||
break;
|
||||
default:
|
||||
dl.AddCircleFilled(p, r + 1, LabelHalo);
|
||||
dl.AddCircleFilled(p, r, col);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawLabel(ImDrawListPtr dl, Vector2 pt, string text, float rad, bool force, uint? colour = null)
|
||||
{
|
||||
if (text.Length == 0) return;
|
||||
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(text);
|
||||
var min = new Vector2(pt.X + rad + 4, pt.Y - ts.Y * 0.5f);
|
||||
var max = min + ts;
|
||||
if (!force)
|
||||
{
|
||||
for (int i = 0; i < _labelRects.Count; i++)
|
||||
{
|
||||
var (a, b) = _labelRects[i];
|
||||
if (min.X < b.X + 2 && max.X > a.X - 2 && min.Y < b.Y && max.Y > a.Y) return;
|
||||
}
|
||||
}
|
||||
_labelRects.Add((min, max));
|
||||
dl.AddText(min + new Vector2(1, 1), LabelHalo, text);
|
||||
dl.AddText(min + new Vector2(-1, 1), LabelHalo, text);
|
||||
dl.AddText(min, force ? Text : colour ?? LabelCol, text);
|
||||
}
|
||||
|
||||
// ── Other characters (RynthNet) ──────────────────────────────────────
|
||||
private void DrawCharacters(ImDrawListPtr dl, Vector2 canvasMin, Vector2 canvasMax)
|
||||
{
|
||||
for (int i = 0; i < _chars.Length; i++)
|
||||
{
|
||||
CharacterRow c = _chars[i];
|
||||
if (c.IsSelf || c.LoggedOut || !c.HasMap) continue;
|
||||
Vector2 p = ProjectDeg(c.MapNs, c.MapEw);
|
||||
if (p.X < canvasMin.X - 60 || p.X > canvasMax.X + 60 || p.Y < canvasMin.Y - 12 || p.Y > canvasMax.Y + 12) continue;
|
||||
_drawnChars.Add((p, i));
|
||||
uint col = c.Stale ? (CharCol & 0x00FFFFFF) | 0x80000000u : CharCol;
|
||||
var tri = new[] { p + new Vector2(0, -6), p + new Vector2(5.5f, 4), p + new Vector2(-5.5f, 4) };
|
||||
dl.AddTriangleFilled(tri[0], tri[1], tri[2], col);
|
||||
dl.AddTriangle(tri[0], tri[1], tri[2], LabelHalo, 1.5f);
|
||||
DrawLabel(dl, p, c.Name, 6f, i == _hoverChar, CharCol);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Route, path, target, highlight, player ───────────────────────────
|
||||
private void DrawRoute(ImDrawListPtr dl, RynthNavStatus? st, in MapPlayer pl)
|
||||
{
|
||||
if (st == null) return;
|
||||
bool haveFrom = pl.Known;
|
||||
|
||||
// The walking path RynthNav worked out (when it sends one): a line under the route's dots, a segment per walk.
|
||||
bool havePath = WorldMapSettings.WalkPath && st.PathSegments.Length > 0;
|
||||
if (havePath)
|
||||
{
|
||||
foreach (float[] seg in st.PathSegments)
|
||||
{
|
||||
Vector2 prevP = ProjectDeg(seg[0], seg[1]);
|
||||
for (int i = 2; i + 1 < seg.Length; i += 2)
|
||||
{
|
||||
Vector2 q = ProjectDeg(seg[i], seg[i + 1]);
|
||||
dl.AddLine(prevP, q, LabelHalo, 4f);
|
||||
dl.AddLine(prevP, q, PathCol, 2.5f);
|
||||
prevP = q;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (st.Route.Length > 0)
|
||||
{
|
||||
Vector2 prev = haveFrom ? ProjectDeg(pl.ShowNs, pl.ShowEw) : default;
|
||||
bool havePrev = haveFrom;
|
||||
for (int i = 0; i < st.Route.Length; i++)
|
||||
{
|
||||
RynthNavRouteStep step = st.Route[i];
|
||||
bool jump = step.Kind is "recall" or "portal" or "town";
|
||||
bool hasHere = step.Kind != "recall" && !(step.Ns == 0 && step.Ew == 0);
|
||||
uint col = i == st.RouteIdx ? RouteActive : RouteCol;
|
||||
if (hasHere)
|
||||
{
|
||||
Vector2 p = ProjectDeg(step.Ns, step.Ew);
|
||||
if (havePrev && !havePath) dl.AddLine(prev, p, col, 2f); // straight legs only without a real path
|
||||
DrawStepDot(dl, p, col, i == st.RouteIdx, jump);
|
||||
prev = p; havePrev = true;
|
||||
}
|
||||
if (jump && step.HasLanding)
|
||||
{
|
||||
Vector2 q = ProjectDeg(step.LandNs, step.LandEw);
|
||||
if (havePrev) DashedLine(dl, prev, q, col);
|
||||
DrawStepDot(dl, q, col, false, false);
|
||||
prev = q; havePrev = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawTarget(ImDrawListPtr dl, RynthNavStatus? st)
|
||||
{
|
||||
RynthNavArrow? ar = st?.Arrow;
|
||||
if (ar == null || !ar.OnMap) return;
|
||||
Vector2 t = ProjectDeg(ar.Ns, ar.Ew);
|
||||
dl.AddCircle(t, 8f, LabelHalo, 24, 4f);
|
||||
dl.AddCircle(t, 8f, TargetCol, 24, 2f);
|
||||
dl.AddCircleFilled(t, 2.5f, TargetCol);
|
||||
}
|
||||
|
||||
private void DrawHighlight(ImDrawListPtr dl)
|
||||
{
|
||||
long left = _hiUntilMs - Environment.TickCount64;
|
||||
if (left <= 0) return;
|
||||
Vector2 p = ProjectDeg(_hiNs, _hiEw);
|
||||
float pulse = 10f + 5f * MathF.Sin(Environment.TickCount64 * 0.008f);
|
||||
uint a = (uint)Math.Clamp(left / 6000f * 255f * 1.5f, 0, 255);
|
||||
uint col = (HighlightCol & 0x00FFFFFF) | (a << 24);
|
||||
dl.AddCircle(p, pulse + 1.5f, LabelHalo & 0x00FFFFFF | (a << 24), 28, 5f);
|
||||
dl.AddCircle(p, pulse, col, 28, 2.5f);
|
||||
if (_hiName.Length > 0) DrawLabel(dl, p, _hiName, pulse, true);
|
||||
}
|
||||
|
||||
private static void DrawStepDot(ImDrawListPtr dl, Vector2 p, uint col, bool current, bool jump)
|
||||
{
|
||||
dl.AddCircleFilled(p, 4.5f, LabelHalo);
|
||||
dl.AddCircleFilled(p, jump ? 3.5f : 3f, col);
|
||||
if (current) dl.AddCircle(p, 8f, col, 20, 2f);
|
||||
}
|
||||
|
||||
private static void DashedLine(ImDrawListPtr dl, Vector2 a, Vector2 b, uint col)
|
||||
{
|
||||
Vector2 d = b - a;
|
||||
float len = d.Length();
|
||||
if (len < 1f || len > 20000f) return;
|
||||
Vector2 u = d / len;
|
||||
for (float t = 0; t < len; t += 12f)
|
||||
dl.AddLine(a + u * t, a + u * Math.Min(t + 6f, len), col, 2f);
|
||||
}
|
||||
|
||||
private void DrawPlayer(ImDrawListPtr dl, in MapPlayer pl)
|
||||
{
|
||||
if (!pl.Known) return;
|
||||
Vector2 p = ProjectDeg(pl.ShowNs, pl.ShowEw);
|
||||
uint fill = pl.Have ? PlayerFill : (PlayerFill & 0x00FFFFFF) | 0x80000000u;
|
||||
if (pl.Have && !float.IsNaN(pl.Heading))
|
||||
{
|
||||
float h = pl.Heading * MathF.PI / 180f; // AC: 0 = east, 90 = north
|
||||
Vector2 fwd = ScreenDir(MathF.Cos(h), MathF.Sin(h));
|
||||
var side = new Vector2(-fwd.Y, fwd.X);
|
||||
Vector2 tip = p + fwd * 10f, l = p - fwd * 6f + side * 6f, r = p - fwd * 6f - side * 6f, back = p - fwd * 2.5f;
|
||||
dl.AddTriangleFilled(tip, l, back, fill);
|
||||
dl.AddTriangleFilled(tip, back, r, fill);
|
||||
dl.AddTriangle(tip, l, r, PlayerEdge, 1.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
dl.AddCircleFilled(p, 6f, PlayerEdge);
|
||||
dl.AddCircleFilled(p, 4.5f, fill);
|
||||
}
|
||||
if (pl.Indoors && !pl.Have) dl.AddCircle(p, 10f, fill, 24, 1.5f);
|
||||
}
|
||||
|
||||
// ── Furniture ────────────────────────────────────────────────────────
|
||||
private void DrawScaleBar(ImDrawListPtr dl, Vector2 canvasMin, Vector2 canvasMax)
|
||||
{
|
||||
// A cell is 24 yards: pick the roundest length under ~140 px (90 on the mini map).
|
||||
float limit = Mini ? 90f : 140f;
|
||||
float[] yards = { 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000 };
|
||||
float best = yards[0];
|
||||
foreach (float y in yards) if (y / 24f * _scale <= limit) best = y;
|
||||
float px = best / 24f * _scale;
|
||||
var a = new Vector2(canvasMin.X + 12, canvasMax.Y - 14);
|
||||
var b = new Vector2(a.X + px, a.Y);
|
||||
dl.AddLine(a + new Vector2(1, 1), b + new Vector2(1, 1), LabelHalo, 3f);
|
||||
dl.AddLine(a, b, LabelCol, 2f);
|
||||
dl.AddLine(a + new Vector2(0, -4), a + new Vector2(0, 2), LabelCol, 2f);
|
||||
dl.AddLine(b + new Vector2(0, -4), b + new Vector2(0, 2), LabelCol, 2f);
|
||||
string t = best >= 1000 ? (best / 1000).ToString("0.#", CultureInfo.InvariantCulture) + " k yd" : best.ToString("0", CultureInfo.InvariantCulture) + " yd";
|
||||
dl.AddText(a + new Vector2(1, -17), LabelHalo, t);
|
||||
dl.AddText(a + new Vector2(0, -18), LabelCol, t);
|
||||
}
|
||||
|
||||
private void DrawCompass(ImDrawListPtr dl, Vector2 canvasMax)
|
||||
{
|
||||
// A needle at north: straight up while the map is north-up, turning as it rotates.
|
||||
var c = new Vector2(canvasMax.X - 20, canvasMax.Y - 26);
|
||||
Vector2 n = ScreenDir(0, 1);
|
||||
var side = new Vector2(-n.Y, n.X);
|
||||
dl.AddCircleFilled(c, 12, BarBg);
|
||||
dl.AddCircle(c, 12, BtnBord);
|
||||
dl.AddTriangleFilled(c + n * 9f, c - n * 1f + side * 3.5f, c - n * 1f - side * 3.5f, LabelCol);
|
||||
dl.AddTriangleFilled(c - n * 9f, c + n * 1f + side * 3.5f, c + n * 1f - side * 3.5f, RynthTheme.Argb(0xFF6C7C8C));
|
||||
Vector2 ts = ImGuiNET.ImGui.CalcTextSize("N");
|
||||
Vector2 lp = c + n * 17f - ts * 0.5f;
|
||||
if (lp.Y > canvasMax.Y - 40) lp = c - n * 17f - ts * 0.5f;
|
||||
dl.AddText(lp, LabelCol, "N");
|
||||
}
|
||||
|
||||
private static void DrawCentred(ImDrawListPtr dl, Vector2 at, string text)
|
||||
{
|
||||
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(text);
|
||||
Vector2 min = at - ts * 0.5f - new Vector2(8, 5), max = at + ts * 0.5f + new Vector2(8, 5);
|
||||
dl.AddRectFilled(min, max, BarBg, 4);
|
||||
dl.AddText(at - ts * 0.5f, HintCol, text);
|
||||
}
|
||||
|
||||
// ── Input ────────────────────────────────────────────────────────────
|
||||
private void Input(Vector2 canvasMin, Vector2 canvasMax, in MapPlayer pl)
|
||||
{
|
||||
ImGuiIOPtr io = ImGuiNET.ImGui.GetIO();
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(canvasMin);
|
||||
ImGuiNET.ImGui.InvisibleButton(Mini ? "##mm_canvas" : "##wm_canvas", Vector2.Max(canvasMax - canvasMin, new Vector2(1, 1)),
|
||||
ImGuiButtonFlags.MouseButtonLeft | ImGuiButtonFlags.MouseButtonRight);
|
||||
Vector2 mouse = io.MousePos;
|
||||
bool blocked = Blocked is { } b && mouse.X >= b.Min.X && mouse.X <= b.Max.X && mouse.Y >= b.Min.Y && mouse.Y <= b.Max.Y;
|
||||
bool hovered = ImGuiNET.ImGui.IsItemHovered() && !blocked;
|
||||
|
||||
// Nearest drawn character or place within reach, else the map point under the cursor.
|
||||
_hoverMark = -1; _hoverChar = -1;
|
||||
if (hovered || _pressing)
|
||||
{
|
||||
float best = 11f * 11f;
|
||||
foreach (var (pos, idx) in _drawnChars)
|
||||
{
|
||||
float dd = Vector2.DistanceSquared(pos, mouse);
|
||||
if (dd < best) { best = dd; _hoverChar = idx; _hoverMark = -1; }
|
||||
}
|
||||
foreach (var (pos, idx) in _drawn)
|
||||
{
|
||||
float dd = Vector2.DistanceSquared(pos, mouse);
|
||||
if (dd < best) { best = dd; _hoverMark = idx; _hoverChar = -1; }
|
||||
}
|
||||
}
|
||||
HoverText = "";
|
||||
if (hovered)
|
||||
{
|
||||
Unproject(mouse, out double hcx, out double hcy);
|
||||
double hn = DegreesOf(hcy), he = DegreesOf(hcx);
|
||||
string where = RynthNavStatus.Coord(hn, he);
|
||||
string name = "";
|
||||
if (_hoverChar >= 0 && _hoverChar < _chars.Length) { name = _chars[_hoverChar].Name + " (character)"; hn = _chars[_hoverChar].MapNs; he = _chars[_hoverChar].MapEw; where = RynthNavStatus.Coord(hn, he); }
|
||||
else if (_hoverMark >= 0 && _marks != null && _hoverMark < _marks.Length) { Mark m = _marks[_hoverMark]; name = m.Name + " (" + m.Place.Type + ")"; hn = m.Place.Ns; he = m.Place.Ew; where = RynthNavStatus.Coord(hn, he); }
|
||||
HoverText = (name.Length > 0 ? name + " " : "") + where + FromYou(pl, hn, he);
|
||||
}
|
||||
|
||||
if (hovered && ImGuiNET.ImGui.IsMouseClicked(ImGuiMouseButton.Left)) { _pressing = true; _pressMoved = false; }
|
||||
if (hovered && ImGuiNET.ImGui.IsMouseDoubleClicked(ImGuiMouseButton.Left) && pl.Known) { Follow = true; _pressing = false; }
|
||||
if (_pressing && ImGuiNET.ImGui.IsMouseDown(ImGuiMouseButton.Left) && ImGuiNET.ImGui.IsMouseDragging(ImGuiMouseButton.Left, 4f))
|
||||
{
|
||||
_pressMoved = true;
|
||||
Vector2 d = io.MouseDelta;
|
||||
if (float.IsFinite(d.X) && float.IsFinite(d.Y) && d != Vector2.Zero)
|
||||
{
|
||||
Follow = false;
|
||||
(_ccx, _ccy) = Proj.CentreAfterDrag(d);
|
||||
}
|
||||
}
|
||||
if (_pressing && ImGuiNET.ImGui.IsMouseReleased(ImGuiMouseButton.Left))
|
||||
{
|
||||
if (!_pressMoved && hovered && !Mini) OpenMenuAt(mouse);
|
||||
_pressing = false;
|
||||
}
|
||||
if (!ImGuiNET.ImGui.IsMouseDown(ImGuiMouseButton.Left)) _pressing = false;
|
||||
if (hovered && ImGuiNET.ImGui.IsMouseClicked(ImGuiMouseButton.Right)) OpenMenuAt(mouse);
|
||||
|
||||
if (hovered)
|
||||
{
|
||||
float wheel = io.MouseWheel;
|
||||
if (float.IsFinite(wheel) && wheel != 0f) ZoomBy(MathF.Pow(1.25f, wheel), mouse);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>" · 1.2 k yd NNE" from you to a point, or "".</summary>
|
||||
private static string FromYou(in MapPlayer pl, double ns, double ew)
|
||||
{
|
||||
if (!pl.Known) return "";
|
||||
double dn = ns - pl.ShowNs, de = ew - pl.ShowEw;
|
||||
double yards = Math.Sqrt(dn * dn + de * de) * 240.0;
|
||||
if (yards < 5) return " · here";
|
||||
double bearing = Math.Atan2(de, dn) * 180.0 / Math.PI;
|
||||
if (bearing < 0) bearing += 360.0;
|
||||
string dist = yards >= 1000 ? (yards / 1000).ToString("0.0", CultureInfo.InvariantCulture) + " k yd" : ((int)yards).ToString(CultureInfo.InvariantCulture) + " yd";
|
||||
return " · " + dist + " " + RynthNavAtlas.CompassPoint(bearing);
|
||||
}
|
||||
|
||||
private void OpenMenuAt(Vector2 mouse)
|
||||
{
|
||||
if (_hoverChar >= 0 && _hoverChar < _chars.Length)
|
||||
{
|
||||
CharacterRow c = _chars[_hoverChar];
|
||||
_ctxNs = Math.Round(c.MapNs, 2); _ctxEw = Math.Round(c.MapEw, 2); _ctxName = c.Name;
|
||||
}
|
||||
else if (_hoverMark >= 0 && _marks != null && _hoverMark < _marks.Length)
|
||||
{
|
||||
Mark m = _marks[_hoverMark];
|
||||
_ctxNs = m.Place.Ns; _ctxEw = m.Place.Ew; _ctxName = m.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
Unproject(mouse, out double cx, out double cy);
|
||||
_ctxNs = Math.Round(DegreesOf(cy), 2);
|
||||
_ctxEw = Math.Round(DegreesOf(cx), 2);
|
||||
_ctxName = "";
|
||||
}
|
||||
_openCtx = true;
|
||||
}
|
||||
|
||||
private void DrawContextMenu()
|
||||
{
|
||||
if (_openCtx) { ImGuiNET.ImGui.OpenPopup(_ctxId); _openCtx = false; }
|
||||
if (!ImGuiNET.ImGui.BeginPopup(_ctxId)) return;
|
||||
string where = _ctxName.Length > 0 ? _ctxName : "Map point";
|
||||
SafeImGui.TextColored(new Vector4(1f, 0.82f, 0.3f, 1f), where);
|
||||
SafeImGui.TextDisabled(RynthNavStatus.Coord(_ctxNs, _ctxEw));
|
||||
ImGuiNET.ImGui.Separator();
|
||||
if (ImGuiNET.ImGui.Selectable("Go here")) RynthNavCommands.Go(where, _ctxNs, _ctxEw);
|
||||
if (ImGuiNET.ImGui.Selectable("Route here")) RynthNavCommands.Route(where, _ctxNs, _ctxEw);
|
||||
if (ImGuiNET.ImGui.Selectable("Arrow here")) RynthNavCommands.Arrow(where, _ctxNs, _ctxEw);
|
||||
if (ImGuiNET.ImGui.Selectable("Copy coordinates")) ImGuiNET.ImGui.SetClipboardText(RynthNavStatus.CommandCoord(_ctxNs, _ctxEw));
|
||||
if (Mini)
|
||||
{
|
||||
ImGuiNET.ImGui.Separator();
|
||||
bool follow = Follow, rotate = Rotate;
|
||||
if (ImGuiNET.ImGui.Checkbox("Follow me", ref follow)) Follow = follow;
|
||||
if (ImGuiNET.ImGui.Checkbox("Rotate with me", ref rotate)) Rotate = rotate;
|
||||
if (ImGuiNET.ImGui.Selectable("Zoom in")) ZoomBy(1.5f);
|
||||
if (ImGuiNET.ImGui.Selectable("Zoom out")) ZoomBy(1f / 1.5f);
|
||||
if (ImGuiNET.ImGui.Selectable("Open the World Map")) UI.PanelRouter.Toggle(WorldMapFace.Title);
|
||||
}
|
||||
ImGuiNET.ImGui.EndPopup();
|
||||
}
|
||||
}
|
||||
|
|
@ -111,8 +111,6 @@ internal static unsafe class PhosphorIcons
|
|||
public const string Play = "\uE3D0";
|
||||
public const string Package = "\uE390";
|
||||
public const string Plus = "\uE3D4";
|
||||
public const string SlidersHorizontal = "\uE434";
|
||||
public const string PushPin = "\uE3E2";
|
||||
public const string Power = "\uE3DA";
|
||||
public const string Resize = "\uED6E";
|
||||
public const string Robot = "\uE762";
|
||||
|
|
@ -171,8 +169,7 @@ internal static unsafe class PhosphorIcons
|
|||
+ ArrowCircleUp + Barbell + Brain + GraduationCap + Hourglass + SortDescending + Package
|
||||
+ Binoculars + Crown + Sun
|
||||
+ CastleTurret + ClockCounterClockwise + GlobeHemisphereWest + Path + Star + Target + User
|
||||
+ TextAa + Leaf + Keyboard
|
||||
+ PushPin + SlidersHorizontal + Wrench;
|
||||
+ TextAa + Leaf + Keyboard;
|
||||
|
||||
/// <summary>
|
||||
/// Draws <paramref name="glyph"/> (one icon) centred in the box at
|
||||
|
|
|
|||
|
|
@ -5,137 +5,17 @@
|
|||
// (docs/IMGUI_PARITY_PLAN.md §4.4). Tokens are ABGR-packed ImGui colours
|
||||
// (ImGui.GetColorU32 order) built from the Avalonia #AARRGGBB literals.
|
||||
//
|
||||
// Colour themes (Tom 2026-10-14): the structural colours come from a palette
|
||||
// the player can change in Settings > Display: a preset (RynthCore, Ember,
|
||||
// Verdant, Amethyst, Crimson, Slate) or their own eight colours (accent,
|
||||
// highlight, background, title bars, buttons, borders, text, muted text).
|
||||
// The other shades (selected rows, fields, hover, the dashboard's border...)
|
||||
// are worked out from those eight; the RynthCore preset keeps every original
|
||||
// colour exactly. Status colours (health, mana, the green on/red off of
|
||||
// toggles, radar gold) don't follow the theme. The faces read the tokens
|
||||
// (properties) every frame, so a change shows at once; the base ImGui style
|
||||
// is re-coloured before the next frame (RefreshStyle, each ImGui context).
|
||||
// Saved to %AppData%\RynthCore\theme.txt (preset=, then name=AARRGGBB for a
|
||||
// custom palette's eight colours).
|
||||
//
|
||||
// Apply() sets the base style once at context creation; per-window colours
|
||||
// (bar, RynthAi, Radar) are pushed around Begin by the panel host.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.UI;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend;
|
||||
|
||||
/// <summary>One colour theme: the eight colours a player picks, then the shades worked out from them (#AARRGGBB).</summary>
|
||||
internal sealed class ThemePalette
|
||||
{
|
||||
public const int Primaries = 8;
|
||||
/// <summary>The eight colours a player picks, in Settings order.</summary>
|
||||
public static readonly string[] PrimaryNames = { "Accent", "Highlight", "Background", "Title bars", "Buttons", "Borders", "Text", "Muted text" };
|
||||
private static readonly string[] PrimaryKeys = { "accent", "highlight", "background", "titlebar", "button", "border", "text", "muted" };
|
||||
|
||||
public readonly uint[] P = new uint[Primaries]; // Accent, Highlight, Background, TitleBar, Button, Border, Text, TextMuted
|
||||
|
||||
// The shades worked out from P (Derive), or the original literals (Default).
|
||||
public uint AccentFill, AccentAlt, BoxBg, Field, Selected, WindowBorder, DashBorder, PanelGlass, BarBg, FrameBg,
|
||||
FrameHover, FrameActive, BarButtonBorder, RowAlt, MuteAlt, StyleText, PopupBg, FrameBgHover, FrameBgActive, SliderGrab;
|
||||
|
||||
/// <summary>A copy (its own array of the eight).</summary>
|
||||
public ThemePalette Clone()
|
||||
{
|
||||
var c = new ThemePalette
|
||||
{
|
||||
AccentFill = AccentFill, AccentAlt = AccentAlt, BoxBg = BoxBg, Field = Field, Selected = Selected,
|
||||
WindowBorder = WindowBorder, DashBorder = DashBorder, PanelGlass = PanelGlass, BarBg = BarBg, FrameBg = FrameBg,
|
||||
FrameHover = FrameHover, FrameActive = FrameActive, BarButtonBorder = BarButtonBorder, RowAlt = RowAlt,
|
||||
MuteAlt = MuteAlt, StyleText = StyleText, PopupBg = PopupBg, FrameBgHover = FrameBgHover,
|
||||
FrameBgActive = FrameBgActive, SliderGrab = SliderGrab,
|
||||
};
|
||||
Array.Copy(P, c.P, Primaries);
|
||||
return c;
|
||||
}
|
||||
|
||||
/// <summary>RynthCore's own colours, every shade exactly as it was before themes.</summary>
|
||||
public static ThemePalette Default()
|
||||
{
|
||||
var t = new ThemePalette();
|
||||
t.P[0] = 0xFF26D9E6; t.P[1] = 0xFFE8B333; t.P[2] = 0xFF0A0F14; t.P[3] = 0xFF1A1A28;
|
||||
t.P[4] = 0xFF16283A; t.P[5] = 0xFF34587A; t.P[6] = 0xFFF2F7FC; t.P[7] = 0xFFB8C8D8;
|
||||
t.AccentFill = 0xFF264C59; t.AccentAlt = 0xFF26C1A6; t.BoxBg = 0xFF0A121A; t.Field = 0xFF141F29;
|
||||
t.Selected = 0xFF1A2E42; t.WindowBorder = 0xFF008080; t.DashBorder = 0xFF264059; t.PanelGlass = 0xFF12121C;
|
||||
t.BarBg = 0xFF0A0A14; t.FrameBg = 0xFF1A2230; t.FrameHover = 0xFF2A3850; t.FrameActive = 0xFF34466A;
|
||||
t.BarButtonBorder = 0xFF3A4A5A; t.RowAlt = 0xFF101822; t.MuteAlt = 0xFFC8D6E4; t.StyleText = 0xFFE6E6E6;
|
||||
t.PopupBg = 0xFF14141E; t.FrameBgHover = 0xFF243044; t.FrameBgActive = 0xFF2C3A52; t.SliderGrab = 0xFF26A18C;
|
||||
return t;
|
||||
}
|
||||
|
||||
/// <summary>A palette from eight colours, the other shades worked out from them.</summary>
|
||||
public static ThemePalette From(params uint[] primaries)
|
||||
{
|
||||
var t = new ThemePalette();
|
||||
for (int i = 0; i < Primaries; i++) t.P[i] = 0xFF000000 | primaries[i];
|
||||
t.Derive();
|
||||
return t;
|
||||
}
|
||||
|
||||
/// <summary>Works out the shades from the eight colours (each a mix of two of them, like the originals).</summary>
|
||||
public void Derive()
|
||||
{
|
||||
uint accent = P[0], bg = P[2], title = P[3], button = P[4], border = P[5], text = P[6], muted = P[7];
|
||||
AccentFill = Mix(bg, accent, 0.30f);
|
||||
AccentAlt = Mix(accent, bg, 0.12f);
|
||||
BoxBg = Mix(bg, button, 0.15f);
|
||||
Field = Mix(bg, button, 0.45f);
|
||||
Selected = Mix(button, accent, 0.12f);
|
||||
WindowBorder = Mix(bg, accent, 0.50f);
|
||||
DashBorder = Mix(bg, border, 0.65f);
|
||||
PanelGlass = Mix(bg, title, 0.40f);
|
||||
BarBg = bg;
|
||||
FrameBg = Mix(bg, button, 0.80f);
|
||||
FrameHover = Mix(button, border, 0.40f);
|
||||
FrameActive = Mix(button, border, 0.70f);
|
||||
BarButtonBorder = Mix(button, border, 0.60f);
|
||||
RowAlt = Mix(bg, button, 0.30f);
|
||||
MuteAlt = Mix(muted, text, 0.30f);
|
||||
StyleText = Mix(text, muted, 0.25f);
|
||||
PopupBg = Mix(bg, title, 0.50f);
|
||||
FrameBgHover = Mix(FrameBg, FrameHover, 0.50f);
|
||||
FrameBgActive = Mix(FrameHover, FrameActive, 0.50f);
|
||||
SliderGrab = Mix(AccentAlt, bg, 0.17f);
|
||||
}
|
||||
|
||||
/// <summary>#AARRGGBB mix: <paramref name="t"/> of the way from <paramref name="a"/> to <paramref name="b"/>, opaque.</summary>
|
||||
public static uint Mix(uint a, uint b, float t)
|
||||
{
|
||||
static uint Ch(uint x, int shift) => (x >> shift) & 0xFF;
|
||||
uint r = (uint)MathF.Round(Ch(a, 16) + (Ch(b, 16) - (float)Ch(a, 16)) * t);
|
||||
uint g = (uint)MathF.Round(Ch(a, 8) + (Ch(b, 8) - (float)Ch(a, 8)) * t);
|
||||
uint bl = (uint)MathF.Round(Ch(a, 0) + (Ch(b, 0) - (float)Ch(a, 0)) * t);
|
||||
return 0xFF000000 | (r << 16) | (g << 8) | bl;
|
||||
}
|
||||
|
||||
// ── Presets ─────────────────────────────────────────────────────────
|
||||
public static readonly string[] PresetNames = { "RynthCore", "Ember", "Verdant", "Amethyst", "Crimson", "Slate" };
|
||||
|
||||
public static ThemePalette Preset(int index) => index switch
|
||||
{
|
||||
1 => From(0xFF8A3D, 0xFFD166, 0x140C0A, 0x24150F, 0x3A2116, 0x7A4A34, 0xFCF4F0, 0xD8C4B8),
|
||||
2 => From(0x4ADE80, 0xE8D333, 0x0A140D, 0x12201A, 0x16352A, 0x347A58, 0xF2FCF5, 0xB8D8C4),
|
||||
3 => From(0xB98CFF, 0xFFC857, 0x0F0A16, 0x1C1428, 0x2A1C40, 0x5A4A8A, 0xF6F2FC, 0xCBBEDC),
|
||||
4 => From(0xFF5C6C, 0xFFC857, 0x140A0C, 0x241216, 0x3A161E, 0x7A3442, 0xFCF2F3, 0xD8B8BE),
|
||||
5 => From(0xD0D8E0, 0xF0C060, 0x0E0F11, 0x1A1C20, 0x24282E, 0x4A5260, 0xF4F5F7, 0xB4BAC2),
|
||||
_ => Default(),
|
||||
};
|
||||
|
||||
// ── File (theme.txt) ────────────────────────────────────────────────
|
||||
public static string Key(int primary) => PrimaryKeys[primary];
|
||||
}
|
||||
|
||||
internal static class RynthTheme
|
||||
{
|
||||
/// <summary>Avalonia #AARRGGBB → ImGui packed colour (0xAABBGGRR).</summary>
|
||||
|
|
@ -145,91 +25,30 @@ internal static class RynthTheme
|
|||
public static Vector4 Vec(uint argb) => new(
|
||||
((argb >> 16) & 0xFF) / 255f, ((argb >> 8) & 0xFF) / 255f, (argb & 0xFF) / 255f, (argb >> 24) / 255f);
|
||||
|
||||
/// <summary>An ImGui packed colour (a token) as a Vector4 (TextColored, style colours).</summary>
|
||||
public static Vector4 VecOf(uint abgr) => ImGuiNET.ImGui.ColorConvertU32ToFloat4(abgr);
|
||||
|
||||
/// <summary>A token with another alpha (0..255).</summary>
|
||||
public static uint WithAlpha(uint abgr, uint alpha) => (abgr & 0x00FFFFFF) | (alpha << 24);
|
||||
|
||||
// ── The palette ────────────────────────────────────────────────────
|
||||
// The current palette's tokens, ABGR, swapped whole on a change (readers never lock).
|
||||
private sealed class Tokens
|
||||
{
|
||||
public uint Accent, Highlight, Background, TitleBar, Button, Border, Text, TextMuted,
|
||||
AccentFill, AccentAlt, BoxBg, Field, Selected, WindowBorder, DashBorder, PanelGlass, BarBg, FrameBg,
|
||||
FrameHover, FrameActive, BarButtonBorder, RowAlt, MuteAlt, StyleText, PopupBg, FrameBgHover, FrameBgActive, SliderGrab;
|
||||
|
||||
public Tokens(ThemePalette p)
|
||||
{
|
||||
Accent = Argb(p.P[0]); Highlight = Argb(p.P[1]); Background = Argb(p.P[2]); TitleBar = Argb(p.P[3]);
|
||||
Button = Argb(p.P[4]); Border = Argb(p.P[5]); Text = Argb(p.P[6]); TextMuted = Argb(p.P[7]);
|
||||
AccentFill = Argb(p.AccentFill); AccentAlt = Argb(p.AccentAlt); BoxBg = Argb(p.BoxBg); Field = Argb(p.Field);
|
||||
Selected = Argb(p.Selected); WindowBorder = Argb(p.WindowBorder); DashBorder = Argb(p.DashBorder);
|
||||
PanelGlass = Argb(p.PanelGlass); BarBg = Argb(p.BarBg); FrameBg = Argb(p.FrameBg); FrameHover = Argb(p.FrameHover);
|
||||
FrameActive = Argb(p.FrameActive); BarButtonBorder = Argb(p.BarButtonBorder); RowAlt = Argb(p.RowAlt);
|
||||
MuteAlt = Argb(p.MuteAlt); StyleText = Argb(p.StyleText); PopupBg = Argb(p.PopupBg);
|
||||
FrameBgHover = Argb(p.FrameBgHover); FrameBgActive = Argb(p.FrameBgActive); SliderGrab = Argb(p.SliderGrab);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly object Sync = new();
|
||||
private static ThemePalette _palette = ThemePalette.Default();
|
||||
private static volatile Tokens _t = new(_palette);
|
||||
private static int _preset; // ThemePalette.PresetNames index, or Custom
|
||||
private static int _version;
|
||||
private static bool _loaded;
|
||||
public const int Custom = -1;
|
||||
|
||||
/// <summary>Bumped on every change: each ImGui context re-colours its base style when it differs.</summary>
|
||||
public static int Version => System.Threading.Volatile.Read(ref _version);
|
||||
|
||||
// Theme tokens (ABGR). The eight a player picks:
|
||||
public static uint Accent => _t.Accent;
|
||||
public static uint Highlight => _t.Highlight;
|
||||
public static uint Background => _t.Background;
|
||||
public static uint TitleBar => _t.TitleBar;
|
||||
public static uint Button => _t.Button;
|
||||
public static uint Border => _t.Border;
|
||||
public static uint Text => _t.Text;
|
||||
public static uint TextMuted => _t.TextMuted;
|
||||
// ...and the shades worked out from them:
|
||||
public static uint AccentFill => _t.AccentFill;
|
||||
public static uint AccentAlt => _t.AccentAlt;
|
||||
public static uint BoxBg => _t.BoxBg;
|
||||
public static uint Field => _t.Field;
|
||||
public static uint Selected => _t.Selected;
|
||||
public static uint WindowBorder => _t.WindowBorder;
|
||||
public static uint DashBorder => _t.DashBorder;
|
||||
public static uint FrameBg => _t.FrameBg;
|
||||
public static uint FrameHover => _t.FrameHover;
|
||||
public static uint FrameActive => _t.FrameActive;
|
||||
public static uint BarButtonBorder => _t.BarButtonBorder;
|
||||
public static uint RowAlt => _t.RowAlt;
|
||||
public static uint MuteAlt => _t.MuteAlt;
|
||||
|
||||
// ── Bar (AvaloniaOverlay.cs BuildRoot) ─────────────────────────────
|
||||
public static uint BarBackground => WithAlpha(_t.BarBg, 0xE6);
|
||||
public static readonly uint BarBackground = Argb(0xE60A0A14);
|
||||
public const float BarRounding = 4f;
|
||||
public static uint BarButton => _t.FrameBg;
|
||||
public static readonly uint BarButton = Argb(0xFF1A2230);
|
||||
public static readonly uint BarButtonBorder = Argb(0xFF3A4A5A);
|
||||
public static readonly uint BarText = Argb(0xFFFFFFFF);
|
||||
public static readonly uint RcLabel = Argb(0xFF90EE90); // LightGreen
|
||||
public static readonly uint ReloadLabel = Argb(0xFFF0E68C); // Khaki
|
||||
public static readonly uint PopOutLabel = Argb(0xFF87CEFA); // LightSkyBlue
|
||||
|
||||
// ── Standard panel frame ───────────────────────────────────────────
|
||||
public static uint PanelGlass => WithAlpha(_t.PanelGlass, 0xF2); // was D2: the game showed through behind text
|
||||
public static uint PanelBorder => _t.WindowBorder;
|
||||
public static readonly uint PanelGlass = Argb(0xF212121C); // was D2: the game showed through behind text
|
||||
public static readonly uint PanelBorder = Argb(0xFF008080); // Teal
|
||||
public const float PanelRounding = 4f;
|
||||
public static uint PanelHeader => _t.TitleBar;
|
||||
public static uint DragLabel => _t.WindowBorder;
|
||||
public static readonly uint PanelHeader = Argb(0xFF1A1A28);
|
||||
public static readonly uint DragLabel = Argb(0xFF008080);
|
||||
public const float HeaderHeight = 24f;
|
||||
public static uint GripIdle => WithAlpha(_t.AccentAlt, 0x20);
|
||||
public static uint GripHover => WithAlpha(_t.AccentAlt, 0x55);
|
||||
public static uint GripGlyph => _t.WindowBorder;
|
||||
public static readonly uint GripIdle = Argb(0x2026C1A6);
|
||||
public static readonly uint GripHover = Argb(0x5526C1A6);
|
||||
public static readonly uint GripGlyph = Argb(0xFF008080);
|
||||
|
||||
// ── RynthAi dashboard ──────────────────────────────────────────────
|
||||
public static uint RynthAiBackground => WithAlpha(_t.Background, 0xF2);
|
||||
public static uint RynthAiBorder => _t.DashBorder;
|
||||
public static readonly uint RynthAiBackground = Argb(0xF20A0F14);
|
||||
public static readonly uint RynthAiBorder = Argb(0xFF264059);
|
||||
public const float RynthAiRounding = 3f;
|
||||
|
||||
// ── Radar ──────────────────────────────────────────────────────────
|
||||
|
|
@ -237,148 +56,6 @@ internal static class RynthTheme
|
|||
public static readonly uint RadarGripIdle = Argb(0x400A121A);
|
||||
public static readonly uint RadarGripHover = Argb(0xA00A121A);
|
||||
|
||||
// ── Choosing a theme (Settings > Display) ───────────────────────────
|
||||
|
||||
/// <summary>The preset in use (ThemePalette.PresetNames index), or Custom.</summary>
|
||||
public static int Preset { get { EnsureLoaded(); return _preset; } }
|
||||
|
||||
/// <summary>Settings' Theme picker: the presets, then "Custom" while the player's own colours are in use.</summary>
|
||||
public static readonly string[] PickerNames = BuildPickerNames();
|
||||
public static int PickerIndex => Preset == Custom ? PickerNames.Length - 1 : Preset;
|
||||
|
||||
private static string[] BuildPickerNames()
|
||||
{
|
||||
var names = new string[ThemePalette.PresetNames.Length + 1];
|
||||
Array.Copy(ThemePalette.PresetNames, names, ThemePalette.PresetNames.Length);
|
||||
names[^1] = "Custom";
|
||||
return names;
|
||||
}
|
||||
|
||||
/// <summary>Uses preset <paramref name="index"/> (the picker's last item, Custom, keeps the colours as they are).</summary>
|
||||
public static void SetPreset(int index)
|
||||
{
|
||||
EnsureLoaded();
|
||||
if (index < 0 || index >= ThemePalette.PresetNames.Length)
|
||||
{
|
||||
lock (Sync) _preset = Custom;
|
||||
Changed();
|
||||
return;
|
||||
}
|
||||
lock (Sync)
|
||||
{
|
||||
_preset = index;
|
||||
_palette = ThemePalette.Preset(index);
|
||||
}
|
||||
Changed();
|
||||
}
|
||||
|
||||
/// <summary>One of the eight colours (#AARRGGBB).</summary>
|
||||
public static uint GetPrimary(int i)
|
||||
{
|
||||
EnsureLoaded();
|
||||
lock (Sync) return _palette.P[Math.Clamp(i, 0, ThemePalette.Primaries - 1)];
|
||||
}
|
||||
|
||||
/// <summary>Changes one of the eight colours (#RRGGBB, opaque): the theme becomes Custom and its shades follow.</summary>
|
||||
public static void SetPrimary(int i, uint argb)
|
||||
{
|
||||
EnsureLoaded();
|
||||
if (i < 0 || i >= ThemePalette.Primaries) return;
|
||||
argb |= 0xFF000000;
|
||||
lock (Sync)
|
||||
{
|
||||
if (_palette.P[i] == argb) return;
|
||||
var p = _palette.Clone();
|
||||
p.P[i] = argb;
|
||||
p.Derive();
|
||||
_palette = p;
|
||||
_preset = Custom;
|
||||
}
|
||||
Changed();
|
||||
}
|
||||
|
||||
private static void Changed()
|
||||
{
|
||||
lock (Sync) _t = new Tokens(_palette);
|
||||
System.Threading.Interlocked.Increment(ref _version);
|
||||
UiBackgroundWriter.Enqueue("theme", Save);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Re-colours the current context's base style when the theme changed since <paramref name="applied"/>
|
||||
/// (a field the context's owner keeps). Call before NewFrame. AC thread.
|
||||
/// </summary>
|
||||
public static void RefreshStyle(ref int applied)
|
||||
{
|
||||
int v = Version;
|
||||
if (v == applied) return;
|
||||
applied = v;
|
||||
ApplyColors(ImGuiNET.ImGui.GetStyle());
|
||||
}
|
||||
|
||||
/// <summary>Reads theme.txt if it hasn't been read yet. Engine init calls this so AC's thread never does.</summary>
|
||||
public static void EnsureLoaded()
|
||||
{
|
||||
if (_loaded) return;
|
||||
lock (Sync)
|
||||
{
|
||||
if (_loaded) return;
|
||||
try
|
||||
{
|
||||
if (File.Exists(FilePath))
|
||||
{
|
||||
int preset = 0;
|
||||
var custom = ThemePalette.Default();
|
||||
foreach (string raw in File.ReadAllLines(FilePath))
|
||||
{
|
||||
string line = raw.Trim();
|
||||
int eq = line.IndexOf('=');
|
||||
if (eq <= 0) continue;
|
||||
string key = line[..eq].Trim(), value = line[(eq + 1)..].Trim();
|
||||
if (key.Equals("preset", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
int idx = Array.FindIndex(ThemePalette.PresetNames, n => n.Equals(value, StringComparison.OrdinalIgnoreCase));
|
||||
preset = idx >= 0 ? idx : Custom;
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < ThemePalette.Primaries; i++)
|
||||
if (key.Equals(ThemePalette.Key(i), StringComparison.OrdinalIgnoreCase)
|
||||
&& uint.TryParse(value, System.Globalization.NumberStyles.HexNumber, null, out uint c))
|
||||
custom.P[i] = 0xFF000000 | c;
|
||||
}
|
||||
_preset = preset;
|
||||
if (preset == Custom) { custom.Derive(); _palette = custom; }
|
||||
else _palette = ThemePalette.Preset(preset);
|
||||
_t = new Tokens(_palette);
|
||||
_version++;
|
||||
}
|
||||
}
|
||||
catch { /* unreadable: RynthCore's colours */ }
|
||||
_loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static string FilePath =>
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RynthCore", "theme.txt");
|
||||
|
||||
private static void Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
var sb = new System.Text.StringBuilder();
|
||||
lock (Sync)
|
||||
{
|
||||
sb.Append("preset=").Append(_preset == Custom ? "Custom" : ThemePalette.PresetNames[_preset]).Append('\n');
|
||||
if (_preset == Custom)
|
||||
for (int i = 0; i < ThemePalette.Primaries; i++)
|
||||
sb.Append(ThemePalette.Key(i)).Append('=').Append((_palette.P[i] & 0xFFFFFF).ToString("X6")).Append('\n');
|
||||
}
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(FilePath)!);
|
||||
File.WriteAllText(FilePath, sb.ToString());
|
||||
}
|
||||
catch { /* best-effort */ }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Base style for every ImGui face, scaled for <paramref name="scale"/>
|
||||
/// (DPI / 96). AC thread, once, right after the context is created.
|
||||
|
|
@ -401,51 +78,43 @@ internal static class RynthTheme
|
|||
style.ScrollbarSize = 12f;
|
||||
style.WindowMinSize = new Vector2(20f, 20f);
|
||||
|
||||
ApplyColors(style);
|
||||
Set(style, ImGuiCol.Text, 0xFFE6E6E6);
|
||||
Set(style, ImGuiCol.TextDisabled, 0xFF808080);
|
||||
Set(style, ImGuiCol.WindowBg, 0xD212121C);
|
||||
Set(style, ImGuiCol.ChildBg, 0x00000000);
|
||||
Set(style, ImGuiCol.PopupBg, 0xF214141E);
|
||||
Set(style, ImGuiCol.Border, 0xFF008080);
|
||||
Set(style, ImGuiCol.FrameBg, 0xFF1A2230);
|
||||
Set(style, ImGuiCol.FrameBgHovered, 0xFF243044);
|
||||
Set(style, ImGuiCol.FrameBgActive, 0xFF2C3A52);
|
||||
Set(style, ImGuiCol.TitleBg, 0xFF1A1A28);
|
||||
Set(style, ImGuiCol.TitleBgActive, 0xFF1A1A28);
|
||||
Set(style, ImGuiCol.Button, 0xFF1A2230);
|
||||
Set(style, ImGuiCol.ButtonHovered, 0xFF2A3850);
|
||||
Set(style, ImGuiCol.ButtonActive, 0xFF34466A);
|
||||
Set(style, ImGuiCol.Header, 0xFF1A2230);
|
||||
Set(style, ImGuiCol.HeaderHovered, 0xFF2A3850);
|
||||
Set(style, ImGuiCol.HeaderActive, 0xFF34466A);
|
||||
Set(style, ImGuiCol.CheckMark, 0xFF26C1A6);
|
||||
Set(style, ImGuiCol.SliderGrab, 0xFF26A18C);
|
||||
Set(style, ImGuiCol.SliderGrabActive, 0xFF26C1A6);
|
||||
Set(style, ImGuiCol.Separator, 0x503A4A5A);
|
||||
Set(style, ImGuiCol.ResizeGrip, 0x2026C1A6);
|
||||
Set(style, ImGuiCol.ResizeGripHovered, 0x5526C1A6);
|
||||
Set(style, ImGuiCol.ResizeGripActive, 0x8026C1A6);
|
||||
Set(style, ImGuiCol.ScrollbarBg, 0x40000000);
|
||||
Set(style, ImGuiCol.ScrollbarGrab, 0xFF2A3850);
|
||||
Set(style, ImGuiCol.TableHeaderBg, 0xFF1A1A28);
|
||||
Set(style, ImGuiCol.TableBorderStrong, 0xFF3A4A5A);
|
||||
Set(style, ImGuiCol.TableBorderLight, 0x503A4A5A);
|
||||
Set(style, ImGuiCol.TableRowBgAlt, 0x10FFFFFF);
|
||||
Set(style, ImGuiCol.ModalWindowDimBg, 0x00000000);
|
||||
|
||||
if (scale != 1f)
|
||||
style.ScaleAllSizes(scale);
|
||||
}
|
||||
|
||||
/// <summary>The base style's colours from the theme (Apply, and RefreshStyle after a change).</summary>
|
||||
private static void ApplyColors(ImGuiStylePtr style)
|
||||
{
|
||||
Tokens t = _t;
|
||||
Set(style, ImGuiCol.Text, t.StyleText);
|
||||
Set(style, ImGuiCol.TextDisabled, Argb(0xFF808080));
|
||||
Set(style, ImGuiCol.WindowBg, WithAlpha(t.PanelGlass, 0xD2));
|
||||
Set(style, ImGuiCol.ChildBg, 0);
|
||||
Set(style, ImGuiCol.PopupBg, WithAlpha(t.PopupBg, 0xF2));
|
||||
Set(style, ImGuiCol.Border, t.WindowBorder);
|
||||
Set(style, ImGuiCol.FrameBg, t.FrameBg);
|
||||
Set(style, ImGuiCol.FrameBgHovered, t.FrameBgHover);
|
||||
Set(style, ImGuiCol.FrameBgActive, t.FrameBgActive);
|
||||
Set(style, ImGuiCol.TitleBg, t.TitleBar);
|
||||
Set(style, ImGuiCol.TitleBgActive, t.TitleBar);
|
||||
Set(style, ImGuiCol.Button, t.FrameBg);
|
||||
Set(style, ImGuiCol.ButtonHovered, t.FrameHover);
|
||||
Set(style, ImGuiCol.ButtonActive, t.FrameActive);
|
||||
Set(style, ImGuiCol.Header, t.FrameBg);
|
||||
Set(style, ImGuiCol.HeaderHovered, t.FrameHover);
|
||||
Set(style, ImGuiCol.HeaderActive, t.FrameActive);
|
||||
Set(style, ImGuiCol.CheckMark, t.AccentAlt);
|
||||
Set(style, ImGuiCol.SliderGrab, t.SliderGrab);
|
||||
Set(style, ImGuiCol.SliderGrabActive, t.AccentAlt);
|
||||
Set(style, ImGuiCol.Separator, WithAlpha(t.BarButtonBorder, 0x50));
|
||||
Set(style, ImGuiCol.ResizeGrip, WithAlpha(t.AccentAlt, 0x20));
|
||||
Set(style, ImGuiCol.ResizeGripHovered, WithAlpha(t.AccentAlt, 0x55));
|
||||
Set(style, ImGuiCol.ResizeGripActive, WithAlpha(t.AccentAlt, 0x80));
|
||||
Set(style, ImGuiCol.ScrollbarBg, Argb(0x40000000));
|
||||
Set(style, ImGuiCol.ScrollbarGrab, t.FrameHover);
|
||||
Set(style, ImGuiCol.TableHeaderBg, t.TitleBar);
|
||||
Set(style, ImGuiCol.TableBorderStrong, t.BarButtonBorder);
|
||||
Set(style, ImGuiCol.TableBorderLight, WithAlpha(t.BarButtonBorder, 0x50));
|
||||
Set(style, ImGuiCol.TableRowBgAlt, Argb(0x10FFFFFF));
|
||||
Set(style, ImGuiCol.ModalWindowDimBg, 0);
|
||||
}
|
||||
|
||||
private static void Set(ImGuiStylePtr style, ImGuiCol col, uint abgr) => style.Colors[(int)col] = new Vector4(
|
||||
(abgr & 0xFF) / 255f, ((abgr >> 8) & 0xFF) / 255f, ((abgr >> 16) & 0xFF) / 255f, (abgr >> 24) / 255f);
|
||||
private static void Set(ImGuiStylePtr style, ImGuiCol col, uint argb) => style.Colors[(int)col] = Vec(argb);
|
||||
}
|
||||
|
||||
/// <summary>DPI scale for the ImGui faces.</summary>
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ internal static class VideoPatchBanner
|
|||
private const string Line2 = "Type /rc video off, or Settings > Misc > Video patch";
|
||||
|
||||
private static readonly uint Back = RynthTheme.Argb(0xC0101820);
|
||||
private static uint Border => RynthTheme.Border;
|
||||
private static uint Title => RynthTheme.Accent;
|
||||
private static uint Text => RynthTheme.TextMuted;
|
||||
private static readonly uint Border = RynthTheme.Argb(0xFF34587A);
|
||||
private static readonly uint Title = RynthTheme.Argb(0xFF26D9E6);
|
||||
private static readonly uint Text = RynthTheme.Argb(0xFFB8C8D8);
|
||||
|
||||
public static void Draw()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,318 +0,0 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/WorldMapTiles.cs
|
||||
// The World Map's picture: NavData\worldmap.rmap (RynthNav.Baker --map --map-tiles) is a pyramid of
|
||||
// 256 px tiles, each a zlib stream of RGB pixels. The face asks for the tiles it is about to draw;
|
||||
// this reads and inflates them on a worker thread and makes D3D9 textures from the results on AC's
|
||||
// render thread (WorldMapFace.Draw is the only caller, plus the frame hooks), like ScriptIcons.
|
||||
//
|
||||
// File layout (little-endian): "RMAP", u32 version (1), u32 tile size, u32 levels, u32 pixels per
|
||||
// cell at level 0, u32 cells wide, u32 cells high; per level u32 width, height, columns, rows,
|
||||
// first tile; u32 tile count; per tile u64 offset + u32 length; the tiles. Level 0 is the full
|
||||
// resolution, each level above half of it, the last one a single tile. Row 0 is the north edge.
|
||||
//
|
||||
// Bounded: at most MaxTextures tiles alive (256 KB each, twice with the managed pool's system
|
||||
// copy), MaxPending reads in flight, MaxCreatesPerFrame textures made a frame. A tile drawn in the
|
||||
// last frame is never evicted, and the top level (the whole map in one tile) never is, so the face
|
||||
// always has something to show under the sharper tiles still loading.
|
||||
//
|
||||
// Threads: AC's render thread owns the texture table and every D3D call (TryGet, BeginFrame,
|
||||
// Shutdown). One pool worker at a time reads and inflates; the two meet in two queues under Sync.
|
||||
// The header is read on the pool too (Open), so no file read happens on AC's thread.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend;
|
||||
|
||||
internal static class WorldMapTiles
|
||||
{
|
||||
public const int TileSize = 256;
|
||||
private const int MaxTexturesRgba = 96, MaxTexturesDxt = 192, MaxCreatesPerFrame = 4, MaxPending = 24;
|
||||
// A DXT1 tile is 32 KB (RGBA 256 KB), so twice as many are kept.
|
||||
private static int MaxTextures => _header?.Dxt == true ? MaxTexturesDxt : MaxTexturesRgba;
|
||||
|
||||
internal readonly record struct Level(int Width, int Height, int Cols, int Rows, int First);
|
||||
|
||||
// ── The file's header: written once by the Open worker, then only read ─────────────────
|
||||
private static volatile Header? _header;
|
||||
private static volatile int _openState; // 0 not tried, 1 opening, 2 open, 3 failed
|
||||
private static volatile string _status = "";
|
||||
private static string _path = "";
|
||||
|
||||
private sealed class Header
|
||||
{
|
||||
public Level[] Levels = Array.Empty<Level>();
|
||||
public ulong[] Offsets = Array.Empty<ulong>();
|
||||
public uint[] Lengths = Array.Empty<uint>();
|
||||
public int PixelsPerCell, CellsWide, CellsHigh;
|
||||
public bool Dxt; // version 2: each tile is DXT1 blocks (32 KB inflated), not RGB
|
||||
}
|
||||
|
||||
public static bool IsOpen => _openState == 2;
|
||||
/// <summary>The file in use (or being opened); "" before the first Open.</summary>
|
||||
public static string CurrentPath => _path;
|
||||
/// <summary>True when the open file holds DXT1 tiles (a World Map HD / Ultra / textured Standard file), false for the flat RGB one.</summary>
|
||||
public static bool IsDxt => _header?.Dxt == true;
|
||||
private static volatile string? _switchTo;
|
||||
|
||||
/// <summary>
|
||||
/// Changes to another map file at the start of the next frame (BeginFrame): the textures of the old one are
|
||||
/// released then, before anything draws with them. Any thread.
|
||||
/// </summary>
|
||||
public static void Switch(string path) { if (!string.Equals(path, _path, StringComparison.OrdinalIgnoreCase)) _switchTo = path; }
|
||||
public static string Status => _status;
|
||||
public static IReadOnlyList<Level> Levels => _header?.Levels ?? Array.Empty<Level>();
|
||||
/// <summary>Pixels per cell at level 0.</summary>
|
||||
public static int PixelsPerCell => _header?.PixelsPerCell ?? 2;
|
||||
public static int CellsWide => _header?.CellsWide ?? 2048;
|
||||
public static int CellsHigh => _header?.CellsHigh ?? 2048;
|
||||
|
||||
/// <summary>Starts reading the header (once per path; a changed path starts over). Any thread.</summary>
|
||||
public static void Open(string path)
|
||||
{
|
||||
if (_openState == 1 || (_openState != 0 && path == _path)) return;
|
||||
_path = path;
|
||||
_openState = 1;
|
||||
_status = "Loading the map...";
|
||||
Task.Run(() =>
|
||||
{
|
||||
try { _header = ReadHeader(path); _openState = 2; _status = ""; }
|
||||
catch (FileNotFoundException) { _openState = 3; _status = "No world map file yet (NavData\\worldmap.rmap)."; }
|
||||
catch (Exception ex) { _openState = 3; _status = "The world map file didn't load: " + ex.Message; }
|
||||
});
|
||||
}
|
||||
|
||||
private static Header ReadHeader(string path)
|
||||
{
|
||||
using var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
using var r = new BinaryReader(fs);
|
||||
if (r.ReadUInt32() != 0x5041_4D52u) throw new InvalidDataException("not a map file"); // "RMAP"
|
||||
uint version = r.ReadUInt32();
|
||||
if (version != 1u && version != 2u) throw new InvalidDataException("a newer map file version");
|
||||
if (r.ReadUInt32() != TileSize) throw new InvalidDataException("unexpected tile size");
|
||||
int levels = checked((int)r.ReadUInt32());
|
||||
if (levels < 1 || levels > 14) throw new InvalidDataException("bad level count");
|
||||
var h = new Header { Dxt = version == 2u, PixelsPerCell = (int)r.ReadUInt32(), CellsWide = (int)r.ReadUInt32(), CellsHigh = (int)r.ReadUInt32() };
|
||||
h.Levels = new Level[levels];
|
||||
for (int i = 0; i < levels; i++)
|
||||
h.Levels[i] = new Level((int)r.ReadUInt32(), (int)r.ReadUInt32(), (int)r.ReadUInt32(), (int)r.ReadUInt32(), (int)r.ReadUInt32());
|
||||
int count = checked((int)r.ReadUInt32());
|
||||
if (count < 1 || count > 4000000) throw new InvalidDataException("bad tile count");
|
||||
h.Offsets = new ulong[count];
|
||||
h.Lengths = new uint[count];
|
||||
for (int i = 0; i < count; i++) { h.Offsets[i] = r.ReadUInt64(); h.Lengths[i] = r.ReadUInt32(); }
|
||||
foreach (Level l in h.Levels)
|
||||
if (l.First < 0 || l.First + l.Cols * l.Rows > count) throw new InvalidDataException("bad level table");
|
||||
return h;
|
||||
}
|
||||
|
||||
// ── AC's render thread ─────────────────────────────────────────────────────────────────
|
||||
private sealed class Tile
|
||||
{
|
||||
public IntPtr Ptr;
|
||||
public int LastUsed;
|
||||
public bool Pending;
|
||||
public int Failures, RetryAt; // a tile that didn't load is asked for again at frame RetryAt, three times at most
|
||||
}
|
||||
|
||||
private static readonly Dictionary<int, Tile> Tiles = new(MaxTexturesDxt + 8);
|
||||
private static readonly List<int> EvictScratch = new(MaxTexturesDxt + 8);
|
||||
private static int _frame;
|
||||
private static int _pending;
|
||||
|
||||
// ── Shared with the worker, under Sync ─────────────────────────────────────────────────
|
||||
private static readonly object Sync = new();
|
||||
private static readonly Queue<int> Requests = new();
|
||||
private static readonly Queue<(int Index, int Generation, byte[]? Rgba)> Results = new();
|
||||
private static bool _draining;
|
||||
private static int _generation;
|
||||
|
||||
public static int LiveTextures { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The texture of tile (col, row) at <paramref name="level"/> if it is ready; otherwise false and, if
|
||||
/// it isn't already, it is queued. AC's render thread, during a draw.
|
||||
/// </summary>
|
||||
public static bool TryGet(int level, int col, int row, out IntPtr texture)
|
||||
{
|
||||
texture = IntPtr.Zero;
|
||||
Header? h = _header;
|
||||
if (h == null || (uint)level >= (uint)h.Levels.Length) return false;
|
||||
Level l = h.Levels[level];
|
||||
if ((uint)col >= (uint)l.Cols || (uint)row >= (uint)l.Rows) return false;
|
||||
int index = l.First + row * l.Cols + col;
|
||||
|
||||
if (Tiles.TryGetValue(index, out Tile? t))
|
||||
{
|
||||
t.LastUsed = _frame;
|
||||
if (t.Ptr != IntPtr.Zero) { texture = t.Ptr; return true; }
|
||||
if (!t.Pending && t.Failures > 0 && t.Failures < 3 && _frame >= t.RetryAt && _pending < MaxPending)
|
||||
{
|
||||
t.Pending = true;
|
||||
_pending++;
|
||||
Enqueue(h, index);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (_pending >= MaxPending) return false;
|
||||
Tiles[index] = new Tile { LastUsed = _frame, Pending = true };
|
||||
_pending++;
|
||||
Enqueue(h, index);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>A tile that is already loaded (a coarse one under a sharper level), without asking for it. AC's render thread.</summary>
|
||||
public static bool Peek(int level, int col, int row, out IntPtr texture)
|
||||
{
|
||||
texture = IntPtr.Zero;
|
||||
Header? h = _header;
|
||||
if (h == null || (uint)level >= (uint)h.Levels.Length) return false;
|
||||
Level l = h.Levels[level];
|
||||
if ((uint)col >= (uint)l.Cols || (uint)row >= (uint)l.Rows) return false;
|
||||
if (!Tiles.TryGetValue(l.First + row * l.Cols + col, out Tile? t) || t.Ptr == IntPtr.Zero) return false;
|
||||
t.LastUsed = _frame;
|
||||
texture = t.Ptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void Enqueue(Header h, int index)
|
||||
{
|
||||
lock (Sync)
|
||||
{
|
||||
Requests.Enqueue(index);
|
||||
if (_draining) return;
|
||||
_draining = true;
|
||||
}
|
||||
int gen = _generation;
|
||||
Task.Run(() => Drain(h, gen));
|
||||
}
|
||||
|
||||
private static void Drain(Header h, int generation)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var fs = new FileStream(_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
while (true)
|
||||
{
|
||||
int index;
|
||||
lock (Sync)
|
||||
{
|
||||
if (generation != _generation || Requests.Count == 0) { _draining = false; return; }
|
||||
index = Requests.Dequeue();
|
||||
}
|
||||
byte[]? rgba = null;
|
||||
try { rgba = Inflate(fs, h, index); } catch { }
|
||||
lock (Sync) Results.Enqueue((index, generation, rgba));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
lock (Sync)
|
||||
{
|
||||
// The file couldn't be opened: answer what's queued as failed so the tiles retry later.
|
||||
_draining = false;
|
||||
while (Requests.Count > 0) Results.Enqueue((Requests.Dequeue(), generation, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] Inflate(FileStream fs, Header h, int index)
|
||||
{
|
||||
var comp = new byte[h.Lengths[index]];
|
||||
fs.Seek((long)h.Offsets[index], SeekOrigin.Begin);
|
||||
fs.ReadExactly(comp);
|
||||
if (h.Dxt)
|
||||
{
|
||||
var blocks = new byte[TileSize / 4 * (TileSize / 4) * 8]; // 32 KB: what the GPU holds as it is
|
||||
using var zb = new ZLibStream(new MemoryStream(comp), CompressionMode.Decompress);
|
||||
zb.ReadExactly(blocks);
|
||||
return blocks;
|
||||
}
|
||||
var rgb = new byte[TileSize * TileSize * 3];
|
||||
using (var z = new ZLibStream(new MemoryStream(comp), CompressionMode.Decompress))
|
||||
z.ReadExactly(rgb);
|
||||
var rgba = new byte[TileSize * TileSize * 4];
|
||||
for (int i = 0, o = 0; i < rgb.Length; i += 3, o += 4)
|
||||
{
|
||||
rgba[o] = rgb[i]; rgba[o + 1] = rgb[i + 1]; rgba[o + 2] = rgb[i + 2]; rgba[o + 3] = 255;
|
||||
}
|
||||
return rgba;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes textures from the tiles read since the last frame (at most MaxCreatesPerFrame) and evicts the
|
||||
/// least recently drawn over the cap, before anything draws. AC's render thread, once a frame.
|
||||
/// </summary>
|
||||
public static void BeginFrame(IntPtr device)
|
||||
{
|
||||
_frame++;
|
||||
if (_switchTo is string next) { _switchTo = null; Shutdown(); Open(next); return; }
|
||||
if (_pending == 0 && Tiles.Count <= MaxTextures) return;
|
||||
int made = 0;
|
||||
while (made < MaxCreatesPerFrame)
|
||||
{
|
||||
(int Index, int Generation, byte[]? Rgba) r;
|
||||
lock (Sync)
|
||||
{
|
||||
if (Results.Count == 0) break;
|
||||
r = Results.Dequeue();
|
||||
}
|
||||
if (r.Generation != _generation || !Tiles.TryGetValue(r.Index, out Tile? t) || !t.Pending) continue;
|
||||
t.Pending = false;
|
||||
_pending = Math.Max(0, _pending - 1);
|
||||
IntPtr ptr = IntPtr.Zero;
|
||||
if (r.Rgba != null)
|
||||
{
|
||||
try { ptr = _header?.Dxt == true ? DX9Backend.CreateTextureDxt1(device, TileSize, TileSize, r.Rgba) : DX9Backend.CreateTextureRgba(device, TileSize, TileSize, r.Rgba); } catch { }
|
||||
made++;
|
||||
}
|
||||
if (ptr != IntPtr.Zero) { t.Ptr = ptr; LiveTextures++; }
|
||||
else { t.Failures++; t.RetryAt = _frame + 300; } // an empty slot: retried in ~5 s, dropped when it ages out
|
||||
}
|
||||
if (Tiles.Count > MaxTextures) Evict();
|
||||
}
|
||||
|
||||
private static void Evict()
|
||||
{
|
||||
Header? h = _header;
|
||||
int top = h == null ? -1 : h.Levels[^1].First; // the single top tile is never evicted
|
||||
EvictScratch.Clear();
|
||||
foreach (var kv in Tiles)
|
||||
if (!kv.Value.Pending && kv.Key != top && kv.Value.LastUsed < _frame - 1) EvictScratch.Add(kv.Key);
|
||||
EvictScratch.Sort((a, b) => Tiles[a].LastUsed.CompareTo(Tiles[b].LastUsed));
|
||||
int excess = Tiles.Count - MaxTextures;
|
||||
for (int i = 0; i < EvictScratch.Count && excess > 0; i++, excess--)
|
||||
{
|
||||
Tile t = Tiles[EvictScratch[i]];
|
||||
if (t.Ptr != IntPtr.Zero) { try { DX9Backend.ReleaseTexture(t.Ptr); } catch { } LiveTextures--; }
|
||||
Tiles.Remove(EvictScratch[i]);
|
||||
}
|
||||
EvictScratch.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Engine shutdown or ImGui teardown (hot reload, unload): releases every texture and drops the
|
||||
/// queues; a worker still running finishes into a generation nobody reads. AC's render thread.
|
||||
/// </summary>
|
||||
public static void Shutdown()
|
||||
{
|
||||
lock (Sync)
|
||||
{
|
||||
_generation++;
|
||||
Requests.Clear();
|
||||
Results.Clear();
|
||||
}
|
||||
foreach (Tile t in Tiles.Values)
|
||||
if (t.Ptr != IntPtr.Zero) { try { DX9Backend.ReleaseTexture(t.Ptr); } catch { } t.Ptr = IntPtr.Zero; }
|
||||
Tiles.Clear();
|
||||
EvictScratch.Clear();
|
||||
LiveTextures = 0;
|
||||
_pending = 0;
|
||||
_openState = 0;
|
||||
_header = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/WorldMapVectors.cs
|
||||
// The World Map's vector layers: NavData\worldmap.vec (RynthNav.Baker --map-vectors), the outlines of
|
||||
// Dereth's buildings and its roads, drawn over the tiles when you zoom in. About 7,000 buildings and
|
||||
// 9,000 road segments, so the whole lot is held in memory (a few hundred KB) and culled per frame.
|
||||
//
|
||||
// File layout (little-endian): "RVEC", u32 version (1), u32 building count, u32 road segment count;
|
||||
// per building u8 corner count and that many (f32 x, f32 y) in map cells; per road segment u16 x0,
|
||||
// y0, x1, y1 in cells. A cell is 24 yards; y is north.
|
||||
//
|
||||
// Read once on a pool thread (Open); after that the arrays are immutable and any thread may read.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend;
|
||||
|
||||
internal static class WorldMapVectors
|
||||
{
|
||||
internal sealed class Data
|
||||
{
|
||||
/// <summary>Each building's outline corners (cells), with the outline's bounds for culling.</summary>
|
||||
public Vector2[][] Buildings = Array.Empty<Vector2[]>();
|
||||
public Vector4[] BuildingBounds = Array.Empty<Vector4>(); // minX, minY, maxX, maxY
|
||||
/// <summary>Road segments: x0, y0, x1, y1 in cells.</summary>
|
||||
public ushort[] Roads = Array.Empty<ushort>();
|
||||
public int RoadCount => Roads.Length / 4;
|
||||
}
|
||||
|
||||
private static volatile Data? _data;
|
||||
private static volatile int _state; // 0 not tried, 1 opening, 2 open, 3 failed
|
||||
private static string _path = "";
|
||||
|
||||
public static Data? Current => _state == 2 ? _data : null;
|
||||
public static bool Failed => _state == 3;
|
||||
|
||||
/// <summary>Starts reading the file (once per path). Any thread.</summary>
|
||||
public static void Open(string path)
|
||||
{
|
||||
if (_state == 1 || (_state != 0 && path == _path)) return;
|
||||
_path = path;
|
||||
_state = 1;
|
||||
Task.Run(() =>
|
||||
{
|
||||
try { _data = Read(path); _state = 2; }
|
||||
catch { _state = 3; } // no file or a bad one: the layer is simply absent
|
||||
});
|
||||
}
|
||||
|
||||
public static void Shutdown() { _state = 0; _data = null; }
|
||||
|
||||
internal static Data Read(string path)
|
||||
{
|
||||
using var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
using var r = new BinaryReader(fs);
|
||||
if (r.ReadUInt32() != 0x4345_5652u) throw new InvalidDataException("not a vector file"); // "RVEC"
|
||||
if (r.ReadUInt32() != 1u) throw new InvalidDataException("a newer vector file version");
|
||||
int buildings = checked((int)r.ReadUInt32()), roads = checked((int)r.ReadUInt32());
|
||||
if (buildings < 0 || buildings > 500000 || roads < 0 || roads > 5000000) throw new InvalidDataException("bad counts");
|
||||
var d = new Data { Buildings = new Vector2[buildings][], BuildingBounds = new Vector4[buildings], Roads = new ushort[roads * 4] };
|
||||
for (int i = 0; i < buildings; i++)
|
||||
{
|
||||
int n = r.ReadByte();
|
||||
var pts = new Vector2[n];
|
||||
float minX = float.MaxValue, minY = float.MaxValue, maxX = float.MinValue, maxY = float.MinValue;
|
||||
for (int k = 0; k < n; k++)
|
||||
{
|
||||
float x = r.ReadSingle(), y = r.ReadSingle();
|
||||
pts[k] = new Vector2(x, y);
|
||||
if (x < minX) minX = x; if (x > maxX) maxX = x;
|
||||
if (y < minY) minY = y; if (y > maxY) maxY = y;
|
||||
}
|
||||
d.Buildings[i] = pts;
|
||||
d.BuildingBounds[i] = new Vector4(minX, minY, maxX, maxY);
|
||||
}
|
||||
for (int i = 0; i < roads * 4; i++) d.Roads[i] = r.ReadUInt16();
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
|
@ -941,8 +941,8 @@ internal struct RynthCoreAPI
|
|||
/// for every plugin: each server the engine knows (built in, or declared by a loaded plugin)
|
||||
/// with its verdict, this character's override, why, and the plugin that owns its settings;
|
||||
/// plus the active server and the Diagnostics pick (UI/Sections/ServerStateJson.cs has the
|
||||
/// schema). Returns the UTF-8 byte length; when it is >= capacity nothing was written (call
|
||||
/// again with a bigger buffer). -1 on failure. Any thread. Requires API v86+.</summary>
|
||||
/// schema). Copies NUL-terminated UTF-8 JSON when it fits and returns its byte length either
|
||||
/// way (length >= capacity: call again with a bigger buffer). Any thread. Requires API v86+.</summary>
|
||||
public IntPtr GetServerStateJsonFn;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,8 @@ internal static class PluginContractVersion
|
|||
// v82: SalvageDirect (salvage without the salvage panel; was v81 on feature/salvage-direct).
|
||||
// v83: GetObjectServerAge and RemoveClientObject (ghost creatures, 2026-10-12).
|
||||
// v84: GetObjectProperties (every property of an object, for /ub propertydump; 2026-10-13).
|
||||
// v85: ArmConfirmation and GetLastConfirmation (answer the server's yes/no prompt, e.g. the
|
||||
// craft chance, for a plugin; from SilentKelpie's build, 2026-10-15).
|
||||
// v86: GetServerStateJson (the server list, active server and owning plugins for every plugin;
|
||||
// server plugins declare their server in their manifest; from SilentKelpie's build).
|
||||
// v85: ArmConfirmation and GetLastConfirmation (answer the craft-chance prompt for a plugin;
|
||||
// was v81, then v84 on build-comp-10-11, renumbered after upstream's v81-v84).
|
||||
// v86: GetServerStateJson (the server list, active server and owning plugins for every plugin).
|
||||
public const uint Current = 86;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ internal static partial class PluginManager
|
|||
return;
|
||||
}
|
||||
|
||||
RynthLog.Plugin($"PluginManager: {s.ServerName} ({s.ServerId}) is this server (its world name, or forced On) - loading {file} (va before: {Compatibility.AddressSpace.Describe()})");
|
||||
RynthLog.Plugin($"PluginManager: {s.ServerName} ({s.ServerId}) forced On - loading {file} (va before: {Compatibility.AddressSpace.Describe()})");
|
||||
LoadedPlugin? plugin = PluginLoader.LoadSingle(s.Path, _shadowRootDir, _loadGeneration);
|
||||
RynthLog.Plugin($"PluginManager: loaded {file}{(plugin == null ? " (FAILED)" : "")} (va after: {Compatibility.AddressSpace.Describe()})");
|
||||
if (plugin == null)
|
||||
|
|
@ -113,7 +113,7 @@ internal static partial class PluginManager
|
|||
UI.Sections.SectionRegistry.RefreshManifests();
|
||||
|
||||
if (plugin.Initialized && !plugin.Failed)
|
||||
AcMainThreadQueue.EnqueueWriteToChat($"[RynthCore] Loaded {s.PluginName} for {s.ServerName} (its world name, or picked in Options > Diagnostics).", 1);
|
||||
AcMainThreadQueue.EnqueueWriteToChat($"[RynthCore] Loaded {s.PluginName} for {s.ServerName} (forced On in Options > Diagnostics).", 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -328,9 +328,6 @@ internal static partial class PluginManager
|
|||
|
||||
public static void LoadPlugins(string engineDir)
|
||||
{
|
||||
// Where the memory goes while the plugins start (Compatibility/MemoryUse.cs).
|
||||
Compatibility.MemoryUse.Mark("before the plugins load");
|
||||
Compatibility.MemoryUse.StartBurst(60, "plugins starting");
|
||||
if (_loaded)
|
||||
return;
|
||||
|
||||
|
|
@ -666,6 +663,8 @@ internal static partial class PluginManager
|
|||
ImGuiBackend.Hud.HudFeed.OnChat(text);
|
||||
// Who to /reply and /retell to (ChatCommandDispatcher rewrites those to a /tell).
|
||||
Compatibility.TellMemory.Shared.OnChatLine(text);
|
||||
// Luminance deposited into ACECustom's bank isn't session income (SessionRates).
|
||||
Compatibility.EngineStatusMetrics.OnChatLine(text);
|
||||
|
||||
if (!_initialized || _plugins.Count == 0)
|
||||
return false;
|
||||
|
|
@ -2691,7 +2690,6 @@ internal static partial class PluginManager
|
|||
RynthLog.Plugin($"PluginManager: Loading extra plugin: {dllPath} (va before: {Compatibility.AddressSpace.Describe()})");
|
||||
var plugin = PluginLoader.LoadSingle(dllPath, _shadowRootDir, _loadGeneration);
|
||||
RynthLog.Plugin($"PluginManager: loaded {Path.GetFileName(dllPath)}{(plugin == null ? " (FAILED)" : "")} (va after: {Compatibility.AddressSpace.Describe()})");
|
||||
Compatibility.MemoryUse.Mark($"{Path.GetFileNameWithoutExtension(dllPath)} loaded");
|
||||
if (plugin != null)
|
||||
{
|
||||
plugin.Manifest = manifest;
|
||||
|
|
@ -2831,7 +2829,6 @@ internal static partial class PluginManager
|
|||
plugin.UIInitializedDispatched = false;
|
||||
plugin.LoginCompleteDispatched = false;
|
||||
RynthLog.Plugin($"PluginManager: {plugin.DisplayName} initialized OK (api v{PluginContractVersion.Current}).");
|
||||
Compatibility.MemoryUse.Mark($"{plugin.DisplayName} Init");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2944,7 +2941,6 @@ internal static partial class PluginManager
|
|||
plugin.OnLoginComplete();
|
||||
plugin.LoginCompleteDispatched = true;
|
||||
RynthLog.Plugin($"PluginManager: {plugin.DisplayName} received OnLoginComplete.");
|
||||
Compatibility.MemoryUse.Mark($"{plugin.DisplayName} OnLoginComplete");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -4049,14 +4045,14 @@ internal static partial class PluginManager
|
|||
}
|
||||
}
|
||||
|
||||
// v85: arm one answer for the next server yes/no prompt (ConfirmationResponder).
|
||||
// v81: arm one answer for the next server yes/no prompt (ConfirmationResponder).
|
||||
private static int ArmConfirmationAction(uint type, int minPercent, int timeoutMs)
|
||||
{
|
||||
try { return ConfirmationResponder.Arm(type, minPercent, timeoutMs); }
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
// v85: the last server yes/no prompt and what happened to it.
|
||||
// v81: the last server yes/no prompt and what happened to it.
|
||||
private static unsafe int GetLastConfirmationAction(uint* type, uint* contextId, int* percent, int* outcome, int* ageMs)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -104,13 +104,10 @@ internal static class PluginManifestGate
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// The server plugins to leave out (their paths). With <paramref name="connectHost"/> known,
|
||||
/// only the plugins that list it load; when none does, none load (every server plugin is a
|
||||
/// runtime in a 32-bit client, and a dozen of them for a server nobody claims only cost address
|
||||
/// space). A skipped plugin still loads late when its server announces a world name it lists,
|
||||
/// or when the character forces its server On (SectionRegistry), so a server that moved to a
|
||||
/// new host still gets its plugin. With no host (an externally launched client) all load.
|
||||
/// Nothing is left out when <paramref name="loadAll"/> is set.
|
||||
/// The server plugins to leave out (their paths). Fail-open: a server plugin is left out only
|
||||
/// when <paramref name="connectHost"/> is known and another installed server plugin claims it,
|
||||
/// so a server that moved to a new host still gets its plugin (all of them load, each shows
|
||||
/// only on its own server). Nothing is left out when <paramref name="loadAll"/> is set.
|
||||
/// </summary>
|
||||
internal static HashSet<string> SelectServerPlugins(IReadOnlyList<PluginCandidate> candidates, string? connectHost,
|
||||
bool loadAll, List<string> log)
|
||||
|
|
@ -137,14 +134,16 @@ internal static class PluginManifestGate
|
|||
if (c.Manifest!.Server!.MatchesHost(host, out string hit))
|
||||
claimants.Add($"{c.Manifest.Name} ({c.Manifest.Server.Id}, \"{hit}\")");
|
||||
if (claimants.Count == 0)
|
||||
log.Add($"{servers.Count} server plugin(s): none lists host {host}, so none load now (one loads once its world name is announced, or when its server is picked).");
|
||||
{
|
||||
log.Add($"{servers.Count} server plugin(s): none lists host {host}, so all load (each shows only on its own server).");
|
||||
return skip;
|
||||
}
|
||||
|
||||
foreach (PluginCandidate c in servers)
|
||||
{
|
||||
if (c.Manifest!.Server!.MatchesHost(host, out _)) continue;
|
||||
skip.Add(c.Key);
|
||||
if (claimants.Count > 0)
|
||||
log.Add($"{Path.GetFileName(c.Key)}: not loaded - it is for {c.Manifest.Server.Name}, and host {host} is {string.Join(", ", claimants)}.");
|
||||
log.Add($"{Path.GetFileName(c.Key)}: not loaded - it is for {c.Manifest.Server.Name}, and host {host} is {string.Join(", ", claimants)}.");
|
||||
}
|
||||
return skip;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,109 +0,0 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - UI/BarLayout.cs
|
||||
// The toolbar's rows (ImGuiBar): how many rows the player wants (1-6, default
|
||||
// 1) and the most icons a row may hold (0 = no limit, the default, else
|
||||
// 2-30). Icons per row = ceil(icons / rows), capped at the limit, so the cap
|
||||
// can add rows beyond the chosen count. Rows fill left to right, top to bottom.
|
||||
//
|
||||
// Pure (no ImGui, no files): the clamps, the per-row count, the menu's steps
|
||||
// and the barlayout= row of panel_state.txt (PanelStateStore) that keeps them.
|
||||
// A file without that row, or with a row this can't read, gives the defaults.
|
||||
// Tests: tools/BarLayoutTests. Any thread.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace RynthCore.Engine.UI;
|
||||
|
||||
internal static class BarLayout
|
||||
{
|
||||
public const int MinRows = 1, MaxRows = 6, DefaultRows = 1;
|
||||
/// <summary>Icons per row: 0 is "no limit"; a limit is MinPerRow..MaxPerRow.</summary>
|
||||
public const int NoLimit = 0, MinPerRow = 2, MaxPerRow = 30;
|
||||
|
||||
public static int ClampRows(int rows) => Math.Clamp(rows, MinRows, MaxRows);
|
||||
|
||||
/// <summary>0 or less = no limit; 1 becomes 2 (a one-icon row is just a column of rows); above 30 = 30.</summary>
|
||||
public static int ClampMaxPerRow(int max) => max <= NoLimit ? NoLimit : Math.Clamp(max, MinPerRow, MaxPerRow);
|
||||
|
||||
/// <summary>Icons in each row (the last may hold fewer): ceil(icons / rows), capped at the limit. At least 1.</summary>
|
||||
public static int PerRow(int icons, int rows, int maxPerRow)
|
||||
{
|
||||
rows = ClampRows(rows);
|
||||
maxPerRow = ClampMaxPerRow(maxPerRow);
|
||||
int perRow = Math.Max(1, (Math.Max(0, icons) + rows - 1) / rows);
|
||||
return maxPerRow > 0 ? Math.Min(perRow, maxPerRow) : perRow;
|
||||
}
|
||||
|
||||
/// <summary>The rows the icons take (at least 1: an empty bar is still its grip row).</summary>
|
||||
public static int RowCount(int icons, int perRow) =>
|
||||
icons <= 0 ? 1 : (icons + Math.Max(1, perRow) - 1) / Math.Max(1, perRow);
|
||||
|
||||
/// <summary>
|
||||
/// The icons-per-row menu's - / + from <paramref name="max"/>. No limit sits above 30: + at 30
|
||||
/// is no limit, and - from no limit caps one below what a row shows now (<paramref name="shownPerRow"/>),
|
||||
/// so the first click changes the bar. - stops at 2, + stops at no limit.
|
||||
/// </summary>
|
||||
public static int StepMaxPerRow(int max, int delta, int shownPerRow)
|
||||
{
|
||||
max = ClampMaxPerRow(max);
|
||||
if (delta == 0) return max;
|
||||
if (max == NoLimit)
|
||||
return delta > 0 ? NoLimit : Math.Clamp(shownPerRow - 1, MinPerRow, MaxPerRow);
|
||||
int next = max + delta;
|
||||
if (next > MaxPerRow) return NoLimit;
|
||||
return Math.Max(MinPerRow, next);
|
||||
}
|
||||
|
||||
/// <summary>Settings > Display picker labels: rows "1".."6" (index = rows - 1).</summary>
|
||||
public static readonly string[] RowNames = Names(MinRows, MaxRows, null);
|
||||
|
||||
/// <summary>Settings > Display picker labels: "No limit", then "2".."30" (MaxPerRowToIndex).</summary>
|
||||
public static readonly string[] MaxPerRowNames = Names(MinPerRow, MaxPerRow, "No limit");
|
||||
|
||||
/// <summary>The MaxPerRowNames index for a limit: 0 = no limit, 1 = 2, ... 29 = 30.</summary>
|
||||
public static int MaxPerRowToIndex(int max)
|
||||
{
|
||||
max = ClampMaxPerRow(max);
|
||||
return max == NoLimit ? 0 : max - MinPerRow + 1;
|
||||
}
|
||||
|
||||
public static int IndexToMaxPerRow(int index) => index <= 0 ? NoLimit : ClampMaxPerRow(index + MinPerRow - 1);
|
||||
|
||||
private static string[] Names(int from, int to, string? first)
|
||||
{
|
||||
int lead = first != null ? 1 : 0;
|
||||
var names = new string[to - from + 1 + lead];
|
||||
if (first != null) names[0] = first;
|
||||
for (int i = from; i <= to; i++) names[i - from + lead] = i.ToString(CultureInfo.InvariantCulture);
|
||||
return names;
|
||||
}
|
||||
|
||||
/// <summary>"No limit" or the number.</summary>
|
||||
public static string DescribeMaxPerRow(int max)
|
||||
{
|
||||
max = ClampMaxPerRow(max);
|
||||
return max == NoLimit ? "No limit" : max.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary>The value of panel_state.txt's barlayout= row: "<rows>,<maxPerRow>".</summary>
|
||||
public static string Format(int rows, int maxPerRow) =>
|
||||
FormattableString.Invariant($"{ClampRows(rows)},{ClampMaxPerRow(maxPerRow)}");
|
||||
|
||||
/// <summary>Reads a barlayout= value, clamped. False (and the defaults) when it isn't two integers.</summary>
|
||||
public static bool TryParse(string? value, out int rows, out int maxPerRow)
|
||||
{
|
||||
rows = DefaultRows;
|
||||
maxPerRow = NoLimit;
|
||||
if (string.IsNullOrWhiteSpace(value)) return false;
|
||||
string[] parts = value.Split(',');
|
||||
if (parts.Length != 2
|
||||
|| !int.TryParse(parts[0].Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int r)
|
||||
|| !int.TryParse(parts[1].Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int m))
|
||||
return false;
|
||||
rows = ClampRows(r);
|
||||
maxPerRow = ClampMaxPerRow(m);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -50,9 +50,6 @@ internal sealed class CharacterRow
|
|||
public string DistanceText = "";
|
||||
public string Compass = "";
|
||||
public string Location = "";
|
||||
/// <summary>Where it is on the surface map, in degrees (the World Map's other-characters layer): set when it is outdoors or in an overworld building.</summary>
|
||||
public bool HasMap;
|
||||
public double MapNs, MapEw;
|
||||
|
||||
public string StateText = "";
|
||||
public CharStateKind StateKind;
|
||||
|
|
@ -264,13 +261,6 @@ internal sealed unsafe class CharactersSource : UiSource<CharactersView>
|
|||
else if (e.Portal) row.Location = "portal space";
|
||||
else if (hasPose)
|
||||
{
|
||||
if (_isOverworldBlock(cell >> 16))
|
||||
{
|
||||
// A pose is relative to its landblock, indoors too: the surface coordinates of the spot.
|
||||
row.HasMap = true;
|
||||
row.MapEw = (((cell >> 24) & 0xFF) * 8.0 + x / 24.0 - 1019.5) / 10.0;
|
||||
row.MapNs = (((cell >> 16) & 0xFF) * 8.0 + y / 24.0 - 1019.5) / 10.0;
|
||||
}
|
||||
CharPlace p = canMeasure
|
||||
? CharactersModel.Locate(myCell, mx, my, mz, cell, x, y, z, _isOverworldBlock, _dungeonName)
|
||||
: CharactersModel.Locate(0, 0, 0, 0, cell, x, y, z, _isOverworldBlock, _dungeonName);
|
||||
|
|
@ -283,7 +273,6 @@ internal sealed unsafe class CharactersSource : UiSource<CharactersView>
|
|||
else if (e.HasCoords)
|
||||
{
|
||||
row.Location = CharactersModel.CoordsText(e.Ns, e.Ew);
|
||||
row.HasMap = true; row.MapNs = e.Ns; row.MapEw = e.Ew;
|
||||
}
|
||||
|
||||
row.Tooltip = Tooltip(e, row, cell, hasPose);
|
||||
|
|
|
|||
|
|
@ -676,22 +676,22 @@ internal static unsafe class DamageCommands
|
|||
MonstersPanel.Rule? from = string.IsNullOrEmpty(copyFrom) ? null
|
||||
: rules.Rules.Find(r => !IsDefault(r) && r.Name.Equals(copyFrom, StringComparison.OrdinalIgnoreCase));
|
||||
MonstersPanel.Rule clone = CopyOfDefault(from ?? s, name);
|
||||
if (from != null) { clone.OffhandId = from.OffhandId; clone.PetDamage = from.PetDamage; } // a name rule's own choices, kept
|
||||
if (from != null) { clone.OffhandId = from.OffhandId; clone.PetDamage = from.PetDamage; clone.AttackPower = from.AttackPower; } // a name rule's own choices, kept
|
||||
rules.Rules.Insert(defIdx >= 0 ? defIdx + 1 : 0, clone);
|
||||
return clone;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A new rule named <paramref name="name"/> with Default's settings. Off hand and pet are
|
||||
/// left on "follow Default" (0 / PAuto) rather than copied, so a later change on the
|
||||
/// DEFAULT line still reaches it.
|
||||
/// A new rule named <paramref name="name"/> with Default's settings. Off hand, pet and attack
|
||||
/// power are left on "follow Default" (0 / PAuto / Default) rather than copied, so a later
|
||||
/// change on the DEFAULT line still reaches it.
|
||||
/// </summary>
|
||||
private static MonstersPanel.Rule CopyOfDefault(MonstersPanel.Rule s, string name) => new()
|
||||
{
|
||||
Name = name, Category = s.Category,
|
||||
MatchExpression = "", // an exact-name rule matches by name, not by a (possibly false) expression
|
||||
Priority = s.Priority, DamageType = s.DamageType, WeaponId = s.WeaponId, OffhandId = 0,
|
||||
ExVuln = s.ExVuln, PetDamage = "PAuto",
|
||||
ExVuln = s.ExVuln, PetDamage = "PAuto", AttackPower = "Default",
|
||||
Fester = s.Fester, Broadside = s.Broadside, GravityWell = s.GravityWell,
|
||||
Imperil = s.Imperil, Yield = s.Yield, Vuln = s.Vuln,
|
||||
UseArc = s.UseArc, UseBolt = s.UseBolt, UseRing = s.UseRing, UseStreak = s.UseStreak, UseBlast = s.UseBlast, UseWall = s.UseWall,
|
||||
|
|
@ -790,6 +790,10 @@ internal static unsafe class DamageCommands
|
|||
/// <summary>Rule.OffhandId as RynthAi reads it: 0 = follow the DEFAULT line, 1-4 a mode, anything else an item id.</summary>
|
||||
public static readonly string[] OffhandModeNames = { "Default", "Auto", "Shield", "Dual wield", "None" };
|
||||
|
||||
/// <summary>Rule.AttackPower choices, spelled as RynthAi reads them (AttackPowerModes).</summary>
|
||||
public static readonly string[] AttackPowerModes =
|
||||
{ "Default", "High", "Reckless", "Variable", "Reckless + Variable" };
|
||||
|
||||
/// <summary>Rule.PetDamage choices; "PAuto" is shown as Auto.</summary>
|
||||
public static readonly string[] PetDamageTypes =
|
||||
{ "PAuto", "Slash", "Pierce", "Bludgeon", "Fire", "Cold", "Lightning", "Acid", "Nether" };
|
||||
|
|
|
|||
|
|
@ -371,7 +371,6 @@ internal static unsafe class RynthAiCommands
|
|||
finally { Marshal.FreeHGlobal(p); }
|
||||
if (refreshPatrol) UiSources.Patrol.RequestRefresh();
|
||||
UiSources.Nav.RequestRefresh(); // the plugin applied it: the Nav panels show it next poll
|
||||
UiSources.Settings.RequestRefresh(); // Breadcrumbs / Route overlay are on Settings > Navigation too
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -84,8 +84,6 @@ internal sealed class RynthNavStatus
|
|||
public int OpenArrow;
|
||||
public RynthNavArrow? Arrow;
|
||||
public string RouteFor = "", RouteSummary = "";
|
||||
/// <summary>The walking path RynthNav worked out for the trip: segments (one per walk), each a flat list of ns, ew pairs in degrees. Empty: none (older RynthNav, or no trip on the ground).</summary>
|
||||
public float[][] PathSegments = Array.Empty<float[]>();
|
||||
public bool RouteActive;
|
||||
public int RouteIdx = -1;
|
||||
public RynthNavRouteStep[] Route = Array.Empty<RynthNavRouteStep>();
|
||||
|
|
@ -290,23 +288,6 @@ internal sealed class RynthNavStatus
|
|||
s.MarkersShown = Int(mk, "shown") != 0;
|
||||
s.MarkerStatus = Str(mk, "status");
|
||||
}
|
||||
if (r.TryGetProperty("path", out var pa) && pa.ValueKind == JsonValueKind.Array)
|
||||
{
|
||||
var segs = new List<float[]>();
|
||||
foreach (JsonElement seg in pa.EnumerateArray())
|
||||
{
|
||||
if (seg.ValueKind != JsonValueKind.Array) continue;
|
||||
var arr = new float[seg.GetArrayLength() & ~1]; // whole ns, ew pairs
|
||||
int i = 0;
|
||||
foreach (JsonElement v in seg.EnumerateArray())
|
||||
{
|
||||
if (i >= arr.Length) break;
|
||||
arr[i++] = v.ValueKind == JsonValueKind.Number ? (float)v.GetDouble() : 0f;
|
||||
}
|
||||
if (arr.Length >= 4) segs.Add(arr);
|
||||
}
|
||||
s.PathSegments = segs.ToArray();
|
||||
}
|
||||
if (r.TryGetProperty("save", out var sv) && sv.ValueKind == JsonValueKind.Object)
|
||||
{
|
||||
s.HasSave = true;
|
||||
|
|
|
|||
|
|
@ -106,10 +106,6 @@ internal sealed class RynthAiSettings
|
|||
public int DeathRecallSpellId { get; set; } = 48; // Primary Portal Recall
|
||||
public string DeathRecallItem { get; set; } = string.Empty;
|
||||
public bool StopMacroOnNoComponents { get; set; }
|
||||
// Recall When Low On Components (RynthAi's RynthAiPlugin.LowComponents.cs). An older RynthAi ignores them.
|
||||
public bool LowCompsRecall { get; set; }
|
||||
public int LowCompsTaperMin { get; set; } = 10;
|
||||
public int LowCompsScarabMin { get; set; } = 2;
|
||||
public bool StopLootingWhenPackFull { get; set; } = true;
|
||||
public bool StopMacroWhenPackFull { get; set; }
|
||||
// Melee Combat
|
||||
|
|
@ -121,6 +117,17 @@ internal sealed class RynthAiSettings
|
|||
public bool UseNativeAttack { get; set; } = true;
|
||||
public bool SummonPets { get; set; }
|
||||
public int PetMinMonsters { get; set; } = 1;
|
||||
// RynthAi 0.5.47 (2026-10-12): Variable attack power and the environment-impact throttle.
|
||||
// Nullable in RynthAi's payload: an older RynthAi omits them and these defaults show.
|
||||
public int VariablePowerMin { get; set; } = 50;
|
||||
public int VariablePowerMax { get; set; } = 100;
|
||||
public int MissileEnvironmentResponse { get; set; }
|
||||
public int MagicEnvironmentResponse { get; set; }
|
||||
public int EnvironmentImpactLimit { get; set; } = 2;
|
||||
public int EnvironmentImpactWindowSec { get; set; } = 20;
|
||||
public int EnvironmentApproachMeters { get; set; } = 6;
|
||||
public int EnvironmentMinDistance { get; set; } = 3;
|
||||
public int EnvironmentSkipSec { get; set; } = 30;
|
||||
// Spell Combat
|
||||
public int SpellCastIntervalMs { get; set; } = 400;
|
||||
public int AttackSpellIntervalMs { get; set; } = 1500;
|
||||
|
|
@ -160,19 +167,13 @@ internal sealed class RynthAiSettings
|
|||
// RynthAi NavResumeNearest: macro start, route loads and resuming after a pause that moved
|
||||
// the character head for the closest waypoint. On by default; an older plugin ignores it.
|
||||
public bool NavResumeNearest { get; set; } = true;
|
||||
// RynthAi NavOverlay.TrackBreadcrumbs / ShowRouteMarkers: the Nav panel's Breadcrumbs and Route
|
||||
// overlay switches, also on Settings > Navigation. Null = a RynthAi that doesn't send them: the
|
||||
// rows hide, and a save sends null back, which RynthAi reads as unchanged.
|
||||
public bool? TrackBreadcrumbs { get; set; }
|
||||
public bool? ShowRouteOverlay { get; set; }
|
||||
// RynthAi dungeon patrol (/ra dunnav-patrol; RynthAi DungeonPatrolOptions). The defaults are
|
||||
// the patrol as it was before these settings; an older plugin ignores them.
|
||||
public int DunPatrolCoverage { get; set; } // 0 whole dungeon, 1 loops only, 2 everything, 3 sweep
|
||||
public int DunPatrolCoverage { get; set; } // 0 whole dungeon, 1 loops only, 2 everything
|
||||
public int DunPatrolSkipDeadEnds { get; set; } = 10; // dead-end areas of up to this many cells skipped (0 = none)
|
||||
public bool DunPatrolAvoidFloors { get; set; } = true; // lava/acid floor cells kept out of the patrol
|
||||
public float DunPatrolWallDistance { get; set; } = 1f; // every patrol point this far from walls where there is room
|
||||
public float DunPatrolLookInSize { get; set; } = 10f; // rooms this big the patrol only skirts get a walk to their middle
|
||||
public float DunPatrolSightYd { get; set; } = 20f; // sweep: how far a monster notices you (lane spacing)
|
||||
public bool OpenDoors { get; set; }
|
||||
public float OpenDoorRange { get; set; } = 5f;
|
||||
public bool AutoUnlockDoors { get; set; }
|
||||
|
|
@ -326,7 +327,6 @@ internal static unsafe class SettingsCommands
|
|||
try { _setSettingsJson(ansi); }
|
||||
finally { Marshal.FreeHGlobal(ansi); }
|
||||
UiSources.Settings.RequestRefresh();
|
||||
UiSources.Nav.RequestRefresh(); // the Nav panel's Breadcrumbs / Route overlay switches
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -373,8 +373,6 @@ internal static class LootTimerDefaults
|
|||
internal enum SettingKind { Bool, Int, Float, Double, Combo, Section, Spacer, Note, CraftingStatus, Button, TraceCategories, Text, Status,
|
||||
/// <summary>The user hotkeys editor (ImGui/Panels/HotkeysSettingsUi.cs; stored by the engine, not RynthAi).</summary>
|
||||
Hotkeys,
|
||||
/// <summary>A colour (#AARRGGBB in Get/Set): a swatch that opens a picker. The theme's colours (engine-stored).</summary>
|
||||
Color,
|
||||
/// <summary>
|
||||
/// The server picker and the server list (Diagnostics): which server this character counts
|
||||
/// as, from the servers the engine and the loaded plugins know (UI/Sections/ServerSelection.cs).
|
||||
|
|
@ -479,15 +477,6 @@ internal static class SettingsSchema
|
|||
"close to its leader, and the nav marker ring shows it. Dungeon doorways use at most 1 yd. Up to 2 yd, " +
|
||||
"nav walks right up to each point before turning (tight dungeons); bigger values round corners.";
|
||||
|
||||
// The Nav panel's two overlay switches (ImGui/Panels/NavFace.cs), also on Settings > Navigation.
|
||||
public const string BreadcrumbsTip =
|
||||
"Record the trail you walk and draw it on the ground (/ra navtrail on|off).\n" +
|
||||
"Turning it off hides the trail; /ra navtrail clear wipes it.";
|
||||
public const string RouteOverlayTip =
|
||||
"Draw the route in the world: waypoint rings and lines, waypoint labels and the guide line\n" +
|
||||
"to the active waypoint (/ra navoverlay on|off). The waypoint HUD window is separate.";
|
||||
private const string SameAsNavPanel = "\nThe same switch as on the Nav panel.";
|
||||
|
||||
// Also shown by the dashboard's Ranges slide-out (ImGui/Panels/RangesSlideOut.cs), which
|
||||
// edits these same rows (found by label with Find).
|
||||
public const string MonsterRangeTip =
|
||||
|
|
@ -512,9 +501,11 @@ internal static class SettingsSchema
|
|||
}
|
||||
|
||||
public static readonly string[] AttackHeights = { "Low", "Medium", "High" };
|
||||
// RynthAi's EnvironmentResponse, in its order (0 Off .. 3).
|
||||
public static readonly string[] EnvironmentResponses = { "Off", "Move closer", "New target", "Move closer, then new target" };
|
||||
public static readonly string[] LootOwnershipModes = { "My Kills Only", "Fellowship Kills", "All Corpses" };
|
||||
public static readonly string[] NavLabelModes = { "Off", "Numbers", "Numbers and names" };
|
||||
public static readonly string[] DunPatrolCoverages = { "Whole dungeon", "Loops only", "Everything", "Sweep (by sight)" };
|
||||
public static readonly string[] DunPatrolCoverages = { "Whole dungeon", "Loops only", "Everything" };
|
||||
public static readonly string[] DeathRecallModes = { "Off", "Cast a recall spell", "Use a recall item" };
|
||||
|
||||
// The nav editor's recall spells. Filled with "Spell N (N)" and named from the client's spell
|
||||
|
|
@ -560,11 +551,6 @@ internal static class SettingsSchema
|
|||
"Text size for this panel in the game: 0 = normal, each step 10% bigger, yourjokin = 2.5x.")
|
||||
with { VisibleWhen = _ => PanelTextScale.PerPanel };
|
||||
|
||||
// One of the theme's eight colours (ImGuiBackend.RynthTheme); the settings object is ignored.
|
||||
private static SettingRow Colour(int index, string tip) =>
|
||||
new(SettingKind.Color, ImGuiBackend.ThemePalette.PrimaryNames[index], tip,
|
||||
_ => ImGuiBackend.RynthTheme.GetPrimary(index), (_, v) => ImGuiBackend.RynthTheme.SetPrimary(index, (uint)v));
|
||||
|
||||
private static SettingRow Section(string text, Func<RynthAiSettings, bool>? when = null) =>
|
||||
new(SettingKind.Section, text, VisibleWhen: when);
|
||||
|
||||
|
|
@ -661,33 +647,11 @@ internal static class SettingsSchema
|
|||
(_, v) => { Plugins.EngineSettings.InsertReleasesUi = v; if (!v) ImGuiBackend.Win32Backend.ReclaimUi(); },
|
||||
"On: Insert switches between UI and GAME (shown on the RynthCore bar). In GAME, clicks pass through\nRynth windows to the game and Rynth text boxes can't be typed in. Press Insert again to get the UI back.\nOff (default): Insert does nothing. Applies to all your clients; others pick it up when they start."),
|
||||
Spacer(),
|
||||
// The colour theme is stored by the engine (theme.txt, ImGuiBackend.RynthTheme), not in the RynthAi profile.
|
||||
Section("Colour Theme"),
|
||||
Combo("Theme", ImGuiBackend.RynthTheme.PickerNames, _ => ImGuiBackend.RynthTheme.PickerIndex, (_, v) => ImGuiBackend.RynthTheme.SetPreset(v),
|
||||
"The colours of every RynthCore window: RynthCore's own, a preset, or Custom (your own colours below).\nChanging any colour below makes the theme Custom. Applies to all your clients as they start."),
|
||||
Colour(0, "The main highlight: outlines, selected tabs and buttons, toggles that are on, the dashboard's accent line."),
|
||||
Colour(1, "Values, section headings and the bot's busy states (amber in RynthCore's colours)."),
|
||||
Colour(2, "Window and drawer backgrounds. The fields, rows and popups are shades of it."),
|
||||
Colour(3, "Panel title bars and table headers."),
|
||||
Colour(4, "Button and tab backgrounds."),
|
||||
Colour(5, "Button and field outlines; the dashboard's frame is a shade of it."),
|
||||
Colour(6, "Main text."),
|
||||
Colour(7, "Labels and quieter text."),
|
||||
Button("Reset Colours", "Use RynthCore's", () => ImGuiBackend.RynthTheme.SetPreset(0),
|
||||
"Back to RynthCore's own colours (the RynthCore theme)."),
|
||||
Spacer(),
|
||||
Section("Text Size (in-game panels)"),
|
||||
Combo("All Panels", PanelTextScale.SizeNames, _ => PanelTextScale.GetAll(), (_, v) => PanelTextScale.SetAll(v),
|
||||
"Text size for every in-game panel: 0 = normal, each step 10% bigger, yourjokin = 2.5x."),
|
||||
Combo("Toolbar", PanelTextScale.SizeNames, _ => PanelTextScale.GetChrome(), (_, v) => PanelTextScale.SetChrome(v),
|
||||
"Size of the RynthCore icon bar (its icons and tooltips), separate from the panels: 0 = normal, each step 10% bigger.\nAlso: right-click the bar's grip, Ctrl+wheel over the bar, or /rc ui barsize."),
|
||||
// The bar's rows are stored by the engine (panel_state.txt, ImGuiBar), not in the RynthAi profile.
|
||||
Combo("Toolbar Rows", BarLayout.RowNames, _ => ImGuiBackend.ImGuiBar.Rows - BarLayout.MinRows,
|
||||
(_, v) => ImGuiBackend.ImGuiBar.SetRowLayout(v + BarLayout.MinRows, ImGuiBackend.ImGuiBar.MaxPerRow),
|
||||
"How many rows the RynthCore icon bar spreads its icons over (Icons Per Row can add more).\nAlso: right-click the bar's grip, or /rc ui barrows."),
|
||||
Combo("Toolbar Icons Per Row", BarLayout.MaxPerRowNames, _ => BarLayout.MaxPerRowToIndex(ImGuiBackend.ImGuiBar.MaxPerRow),
|
||||
(_, v) => ImGuiBackend.ImGuiBar.SetRowLayout(ImGuiBackend.ImGuiBar.Rows, BarLayout.IndexToMaxPerRow(v)),
|
||||
"The most icons one row of the bar holds; more icons start another row. No limit: the rows share them evenly.\nAlso: right-click the bar's grip, or /rc ui baricons."),
|
||||
Bool("Size Each Panel Separately", _ => PanelTextScale.PerPanel, (_, v) => PanelTextScale.PerPanel = v,
|
||||
"Off: every panel uses All Panels. On: set each panel's text size below.", gates: true),
|
||||
TextSize("RynthAi Dashboard", "RynthAi"),
|
||||
|
|
@ -863,18 +827,6 @@ internal static class SettingsSchema
|
|||
"Stop the macro when you die. Off by default: most metas run back on their own."),
|
||||
Bool("Stop Macro On No Components", s => s.StopMacroOnNoComponents, (s, v) => s.StopMacroOnNoComponents = v,
|
||||
"Stop the macro after 3 \"missing components\" failures within a minute."),
|
||||
Bool("Recall When Low On Components", s => s.LowCompsRecall, (s, v) => s.LowCompsRecall = v,
|
||||
"With the macro running: when your tapers (all kinds together) drop to Low Tapers At, or any one kind of\n" +
|
||||
"scarab (not Diamond) drops to Low Scarabs At, stop the macro and recall to the lifestone, and say in chat\n" +
|
||||
"which ran low. Only kinds you've carried this session count, so a character with no scarabs isn't 'low'.\n" +
|
||||
"Off by default.", gates: true),
|
||||
Int("Low Tapers At", s => s.LowCompsTaperMin, (s, v) => s.LowCompsTaperMin = v, 0, 500, 5,
|
||||
"Recall when your tapers, all kinds together, are at or under this many. 0 = don't check tapers. Default 10.",
|
||||
when: s => s.LowCompsRecall),
|
||||
Int("Low Scarabs At", s => s.LowCompsScarabMin, (s, v) => s.LowCompsScarabMin = v, 0, 50, 1,
|
||||
"Recall when any one kind of scarab (Lead, Iron, Copper, Silver, Gold, Pyreal, Platinum, Mana; not Diamond)\n" +
|
||||
"is at or under this many. 0 = don't check scarabs. Default 2.",
|
||||
when: s => s.LowCompsRecall),
|
||||
Bool("Stop Macro When Pack Full", s => s.StopMacroWhenPackFull, (s, v) => s.StopMacroWhenPackFull = v,
|
||||
"Stop the macro when no pack has a free slot."),
|
||||
Spacer(),
|
||||
|
|
@ -917,6 +869,30 @@ internal static class SettingsSchema
|
|||
Int("Missile Power %", s => s.MissileAttackPower, (s, v) => s.MissileAttackPower = v, 0, 100, 5, when: s => s.MissileAttackPower >= 0),
|
||||
Combo("Missile Attack Height", AttackHeights, s => s.MissileAttackHeight, (s, v) => s.MissileAttackHeight = v),
|
||||
Spacer(),
|
||||
Section("Variable Power (monster rules)"),
|
||||
Int("Variable Min %", s => s.VariablePowerMin, (s, v) => s.VariablePowerMin = v, 0, 100, 5,
|
||||
"A monster rule's Power picks per monster (Damage panel, a monster's detail):\n" +
|
||||
"Default (the settings above), High (100%), Reckless (80%, needs Recklessness trained),\n" +
|
||||
"Variable (a new random power each attack, between these two), or Reckless + Variable\n" +
|
||||
"(random, kept inside the Recklessness band 20-80%)."),
|
||||
Int("Variable Max %", s => s.VariablePowerMax, (s, v) => s.VariablePowerMax = v, 0, 100, 5),
|
||||
Spacer(),
|
||||
Section("Hitting the Environment"),
|
||||
Combo("Missile Response", EnvironmentResponses, s => s.MissileEnvironmentResponse, (s, v) => s.MissileEnvironmentResponse = v,
|
||||
"When arrows or bolts keep hitting walls or objects instead of the target\n" +
|
||||
"(\"Your missile attack hit the environment.\"), stop shooting and:\n" +
|
||||
" Move closer - run toward the target for a clearer shot\n" +
|
||||
" New target - skip this one for a while and fight another\n" +
|
||||
" Move closer, then new target - one approach, then switch\n" +
|
||||
"The only monster in reach is never skipped. Magic: Spell Combat tab."),
|
||||
Int("Hits to trip", s => s.EnvironmentImpactLimit, (s, v) => s.EnvironmentImpactLimit = v, 1, 10, 1,
|
||||
"Environment hits on one target, within the window, before combat reacts (missiles and magic)."),
|
||||
Int("Window (s)", s => s.EnvironmentImpactWindowSec, (s, v) => s.EnvironmentImpactWindowSec = v, 5, 120, 5),
|
||||
Int("Move closer by (m)", s => s.EnvironmentApproachMeters, (s, v) => s.EnvironmentApproachMeters = v, 1, 30, 1),
|
||||
Int("Closest (m)", s => s.EnvironmentMinDistance, (s, v) => s.EnvironmentMinDistance = v, 1, 30, 1,
|
||||
"Never moves nearer than this. Already this close, a new target is picked instead."),
|
||||
Int("Skip target (s)", s => s.EnvironmentSkipSec, (s, v) => s.EnvironmentSkipSec = v, 5, 300, 5),
|
||||
Spacer(),
|
||||
Bool("Use Native Attack", s => s.UseNativeAttack, (s, v) => s.UseNativeAttack = v,
|
||||
"Uses the client's combat pipeline for attacks.\nThe client handles turn-to-face naturally (no backwards arrows)."),
|
||||
Spacer(),
|
||||
|
|
@ -948,6 +924,16 @@ internal static class SettingsSchema
|
|||
Int("Min Wall Targets", s => s.MinWallTargets, (s, v) => s.MinWallTargets = v, 1, 20, 1,
|
||||
"How many monsters (the target included) must be in the wall's path, within Wall Range."),
|
||||
Spacer(),
|
||||
Section("Hitting the Environment"),
|
||||
Combo("Magic Response", EnvironmentResponses, s => s.MagicEnvironmentResponse, (s, v) => s.MagicEnvironmentResponse = v,
|
||||
"When bolts, streaks, arcs or blasts keep stopping short of the target\n" +
|
||||
"(a wall, a pillar, the ceiling) with no hit or resist, stop casting and:\n" +
|
||||
" Move closer - run toward the target for a clearer line\n" +
|
||||
" New target - skip this one for a while and fight another\n" +
|
||||
" Move closer, then new target - one approach, then switch\n" +
|
||||
"Rings and walls aren't judged. The only monster in reach is never skipped.\n" +
|
||||
"Hits to trip, the window, distances and the skip time: Melee Combat tab."),
|
||||
Spacer(),
|
||||
Section("Spell Difficulty (Min Buffed Skill)"),
|
||||
Tiers(
|
||||
new Func<RynthAiSettings, int>[] { s => s.MinSkillLevelTier1, s => s.MinSkillLevelTier2, s => s.MinSkillLevelTier3, s => s.MinSkillLevelTier4,
|
||||
|
|
@ -985,10 +971,6 @@ internal static class SettingsSchema
|
|||
Float(NavPointReachLabel, s => s.FollowNavMin, (s, v) => s.FollowNavMin = v, 0.5f, 20f, 0.1f, NavPointReachTip),
|
||||
Spacer(),
|
||||
Section("Nav Marker Display"),
|
||||
Bool("Breadcrumbs", s => s.TrackBreadcrumbs ?? true, (s, v) => s.TrackBreadcrumbs = v,
|
||||
BreadcrumbsTip + SameAsNavPanel, when: s => s.TrackBreadcrumbs.HasValue),
|
||||
Bool("Route Overlay", s => s.ShowRouteOverlay ?? true, (s, v) => s.ShowRouteOverlay = v,
|
||||
RouteOverlayTip + SameAsNavPanel, when: s => s.ShowRouteOverlay.HasValue),
|
||||
Float("Ring Thickness", s => s.NavRingThickness, (s, v) => s.NavRingThickness = v, 1f, 16f, 1f),
|
||||
Float("Line Thickness", s => s.NavLineThickness, (s, v) => s.NavLineThickness = v, 1f, 16f, 1f),
|
||||
Float("Height Offset", s => s.NavHeightOffset, (s, v) => s.NavHeightOffset = v, -5f, 5f, 0.05f,
|
||||
|
|
@ -1023,14 +1005,7 @@ internal static class SettingsSchema
|
|||
"Loops only: just the corridors that go round in a loop or join two junctions. Every dead-end branch is left\n" +
|
||||
"out, however long: quicker laps, but in a hive most of the dungeon is never visited.\n" +
|
||||
"Everything: every dead end too, closets and all.\n" +
|
||||
"Sweep: the same parts as Whole dungeon, but walked only close enough that every spot is within Sight\n" +
|
||||
"Distance of the route with no wall in between. For open halls and pillar rooms, where Whole dungeon walks\n" +
|
||||
"every lane: monsters a few lanes over notice you anyway. Corridors and crypts change little.\n" +
|
||||
"A dungeon that is one long corridor is walked end to end whatever this says."),
|
||||
Float("Sight Distance (yd)", s => s.DunPatrolSightYd, (s, v) => s.DunPatrolSightYd = Math.Clamp(v, 5f, 60f), 5f, 60f, 1f,
|
||||
"Sweep: how far away a monster notices you, so how far apart the patrol's lanes may be. Bigger means wider\n" +
|
||||
"lanes and a shorter lap; too big and monsters out of sight around pillars get missed. Default 20.",
|
||||
when: s => s.DunPatrolCoverage == 3),
|
||||
Int("Skip Dead Ends Up To (cells)", s => s.DunPatrolSkipDeadEnds, (s, v) => s.DunPatrolSkipDeadEnds = v, 0, 30, 1,
|
||||
"Dead-end areas this small are not walked into: a closet, a short corridor with a small room at its end,\n" +
|
||||
"a little loop off a corridor. Counted in dungeon cells (the pieces a dungeon is built from: a stretch of\n" +
|
||||
|
|
|
|||
|
|
@ -7,15 +7,13 @@
|
|||
//
|
||||
// File format:
|
||||
// bar=<left>,<top>[,<docked|floating>,<floatingLeft>,<floatingTop>]
|
||||
// barlayout=<rows>,<maxIconsPerRow> (BarLayout; only when not 1,0)
|
||||
// panel.<title>=<open|closed>,<left>,<top>,<width>,<height>
|
||||
// [,<docked|floating>,<screenLeft>,<screenTop>]
|
||||
//
|
||||
// The trailing three columns on each row were added when panels (and later
|
||||
// the bar itself) gained the ability to detach into their own top-level
|
||||
// layered windows. Files that pre-date the feature still parse — the floating
|
||||
// mode just defaults to docked and the screen coords default to 0. A file
|
||||
// without a barlayout= row gives the toolbar one row, no icon limit.
|
||||
// mode just defaults to docked and the screen coords default to 0.
|
||||
//
|
||||
// Stored under %LocalAppData%\RynthCore\panel_state.txt — survives reloads
|
||||
// and out-of-game (the Runtime dir might be wiped during deploy).
|
||||
|
|
@ -45,7 +43,6 @@ internal static class PanelStateStore
|
|||
private static (double Left, double Top)? _barPosition;
|
||||
private static bool _barFloating;
|
||||
private static (double Left, double Top)? _barFloatingPosition;
|
||||
private static int _barRows = BarLayout.DefaultRows, _barMaxPerRow = BarLayout.NoLimit;
|
||||
private static bool _loaded;
|
||||
|
||||
private static string FilePath
|
||||
|
|
@ -80,26 +77,6 @@ internal static class PanelStateStore
|
|||
get { lock (Sync) { Load(); return _barFloatingPosition; } }
|
||||
}
|
||||
|
||||
/// <summary>The toolbar's rows and icons-per-row limit (BarLayout; 1 and no limit unless set).</summary>
|
||||
public static (int Rows, int MaxPerRow) BarRows
|
||||
{
|
||||
get { lock (Sync) { Load(); return (_barRows, _barMaxPerRow); } }
|
||||
}
|
||||
|
||||
public static void SetBarRows(int rows, int maxPerRow)
|
||||
{
|
||||
lock (Sync)
|
||||
{
|
||||
Load();
|
||||
rows = BarLayout.ClampRows(rows);
|
||||
maxPerRow = BarLayout.ClampMaxPerRow(maxPerRow);
|
||||
if (rows == _barRows && maxPerRow == _barMaxPerRow) return;
|
||||
_barRows = rows;
|
||||
_barMaxPerRow = maxPerRow;
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryGetPanel(string title, out PanelEntry entry)
|
||||
{
|
||||
lock (Sync)
|
||||
|
|
@ -209,11 +186,6 @@ internal static class PanelStateStore
|
|||
_barFloatingPosition = (floatingVals[0], floatingVals[1]);
|
||||
}
|
||||
}
|
||||
else if (string.Equals(key, "barlayout", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// An unreadable row leaves the defaults (TryParse sets them).
|
||||
BarLayout.TryParse(value, out _barRows, out _barMaxPerRow);
|
||||
}
|
||||
else if (key.StartsWith("panel.", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
string title = key["panel.".Length..];
|
||||
|
|
@ -276,10 +248,6 @@ internal static class PanelStateStore
|
|||
}
|
||||
}
|
||||
|
||||
// Only when changed: a file that never had the row reads back the same.
|
||||
if (_barRows != BarLayout.DefaultRows || _barMaxPerRow != BarLayout.NoLimit)
|
||||
sw.WriteLine("barlayout=" + BarLayout.Format(_barRows, _barMaxPerRow));
|
||||
|
||||
foreach (var kv in Panels)
|
||||
{
|
||||
PanelEntry e = kv.Value;
|
||||
|
|
|
|||
|
|
@ -127,6 +127,10 @@ internal static class MonstersPanel
|
|||
public string PetDamage { get; set; } = "PAuto";
|
||||
/// <summary>Debuffs the player typed in, comma separated (spell base or full names).</summary>
|
||||
public string CustomDebuffs { get; set; } = string.Empty;
|
||||
/// <summary>Melee/missile attack power for this monster: one of DamageData.AttackPowerModes
|
||||
/// ("Default" follows the DEFAULT line, which follows the global Power settings). Rules saved
|
||||
/// before 2026-10-12 load as Default.</summary>
|
||||
public string AttackPower { get; set; } = "Default";
|
||||
|
||||
public bool GetToggle(string field) => field switch
|
||||
{
|
||||
|
|
@ -1016,6 +1020,7 @@ internal static class MonstersPanel
|
|||
var x = a[i]; var y = b[i];
|
||||
if (x.Name != y.Name || x.Category != y.Category || x.Priority != y.Priority
|
||||
|| x.DamageType != y.DamageType || x.ExVuln != y.ExVuln || x.PetDamage != y.PetDamage
|
||||
|| (x.AttackPower ?? "") != (y.AttackPower ?? "")
|
||||
|| x.WeaponId != y.WeaponId || x.OffhandId != y.OffhandId
|
||||
|| x.MatchExpression != y.MatchExpression
|
||||
|| x.Fester != y.Fester || x.Broadside != y.Broadside || x.GravityWell != y.GravityWell
|
||||
|
|
|
|||
|
|
@ -598,19 +598,13 @@ internal static partial class RynthAiPanel
|
|||
ClosePicker();
|
||||
RynthAiCommands.ApplyRemoteCommand("hub", "show");
|
||||
});
|
||||
ToolTip.SetTip(charBtn, "Open the Mini Remote (/ra hub show).");
|
||||
|
||||
// Hub: the Mini Remote and the Inventory HUDs setup are ImGui windows inside RynthAi.
|
||||
var hudBtn = AddLauncher(launcherGrid, 2, 1, "Hub", "▣",
|
||||
onClick: () =>
|
||||
{
|
||||
ClosePicker();
|
||||
RynthAiCommands.ApplyRemoteCommand("remote", "toggle");
|
||||
});
|
||||
ToolTip.SetTip(hudBtn, "Left-click: show/hide the Mini Remote (/ra remote). Right-click: Inventory HUDs setup (/ra huds).");
|
||||
hudBtn.PointerPressed += (_, e) =>
|
||||
ToolTip.SetTip(charBtn, "Left-click: open the Mini Remote (/ra hub show). Right-click: Inventory HUDs setup (/ra huds).");
|
||||
// The separate Hub launcher (the same Mini Remote again) was removed 2026-10-13, as on the
|
||||
// ImGui dashboard; its right-click, the Inventory HUDs setup (an ImGui window inside
|
||||
// RynthAi), moved to Char.
|
||||
charBtn.PointerPressed += (_, e) =>
|
||||
{
|
||||
if (e.GetCurrentPoint(hudBtn).Properties.IsRightButtonPressed)
|
||||
if (e.GetCurrentPoint(charBtn).Properties.IsRightButtonPressed)
|
||||
{
|
||||
e.Handled = true;
|
||||
ClosePicker();
|
||||
|
|
|
|||
|
|
@ -348,6 +348,20 @@ internal static class SettingsPanel
|
|||
}, row.Tooltip);
|
||||
case SettingKind.TraceCategories:
|
||||
return TraceCategoriesRow(state, row);
|
||||
case SettingKind.ServerPick:
|
||||
{
|
||||
// The picker itself is the ImGui face's; here, what is picked and how to change it.
|
||||
var snap = UI.Sections.SectionRegistry.Current;
|
||||
string pick = UI.Sections.ServerSelection.CurrentPick(snap.Servers) ?? "mixed";
|
||||
var active = UI.Sections.ServerSelection.ActiveServer(snap.Servers);
|
||||
return new TextBlock
|
||||
{
|
||||
Text = $"Server: {(active == null ? "none active" : active.Name + " (" + active.Id + ")")}, pick {pick}. "
|
||||
+ "Change it with /rc server pick <id>|auto (the ImGui panel has a picker).",
|
||||
Foreground = ColTeal, FontSize = 11,
|
||||
TextWrapping = Avalonia.Media.TextWrapping.Wrap, Margin = new Thickness(0, 2, 0, 2),
|
||||
};
|
||||
}
|
||||
case SettingKind.Text:
|
||||
return TextRow(row.Label, row.GetText?.Invoke(d) ?? string.Empty, row.Hint, v =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,167 +0,0 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - UI/QuickSettings.cs
|
||||
// The settings a player pinned to the dashboard's My settings drawer
|
||||
// (ImGui/Panels/QuickSettingsDrawer.cs), in the order they pinned them.
|
||||
//
|
||||
// A pin is a row of the Settings schema (UI/Data/SettingsData.cs), named by
|
||||
// "Tab/Section/Label" (the section it sits under; "" before the first one),
|
||||
// since labels repeat across tabs ("Level 1" in Buffing and Spell Combat).
|
||||
// Only rows that edit or do something can be pinned (Pinnable); a pin whose
|
||||
// row no longer exists (renamed in an update) is kept in the file but not
|
||||
// drawn, so it comes back if the row does.
|
||||
//
|
||||
// Persisted to %AppData%\RynthCore\rynthai_quick_settings.txt, one key per
|
||||
// line, written in the background (UiBackgroundWriter). The pins are the
|
||||
// player's, not the profile's: the same drawer on every character; the values
|
||||
// are each profile's own. Any thread for reads; changes on AC's thread.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
|
||||
namespace RynthCore.Engine.UI;
|
||||
|
||||
internal static class QuickSettings
|
||||
{
|
||||
private static readonly object Sync = new();
|
||||
private static List<string> _pins = new();
|
||||
private static bool _loaded;
|
||||
|
||||
private static Dictionary<string, SettingRow>? _byKey;
|
||||
private static Dictionary<SettingRow, string>? _keyOf;
|
||||
|
||||
private static string FilePath =>
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RynthCore", "rynthai_quick_settings.txt");
|
||||
|
||||
/// <summary>Rows that edit a value or do something; headings, notes and the hotkeys editor can't be pinned.</summary>
|
||||
public static bool Pinnable(SettingRow row) => row.Kind is SettingKind.Bool or SettingKind.Int or SettingKind.Float
|
||||
or SettingKind.Double or SettingKind.Combo or SettingKind.Text or SettingKind.Button or SettingKind.Color;
|
||||
|
||||
/// <summary>The row's pin key ("Tab/Section/Label"), or null for a row that can't be pinned.</summary>
|
||||
public static string? KeyOf(SettingRow row)
|
||||
{
|
||||
EnsureIndex();
|
||||
return _keyOf!.TryGetValue(row, out string? key) ? key : null;
|
||||
}
|
||||
|
||||
public static SettingRow? RowOf(string key)
|
||||
{
|
||||
EnsureIndex();
|
||||
return _byKey!.TryGetValue(key, out SettingRow? row) ? row : null;
|
||||
}
|
||||
|
||||
/// <summary>The pinned keys, in order (a copy).</summary>
|
||||
public static string[] Pins
|
||||
{
|
||||
get { EnsureLoaded(); lock (Sync) return _pins.ToArray(); }
|
||||
}
|
||||
|
||||
public static bool IsPinned(string key)
|
||||
{
|
||||
EnsureLoaded();
|
||||
lock (Sync) return _pins.Contains(key);
|
||||
}
|
||||
|
||||
/// <summary>Pins <paramref name="key"/> at the end, or unpins it.</summary>
|
||||
public static void SetPinned(string key, bool pinned)
|
||||
{
|
||||
EnsureLoaded();
|
||||
lock (Sync)
|
||||
{
|
||||
if (pinned == _pins.Contains(key)) return;
|
||||
if (pinned) _pins.Add(key);
|
||||
else _pins.Remove(key);
|
||||
}
|
||||
UiBackgroundWriter.Enqueue("quick settings", Save);
|
||||
}
|
||||
|
||||
/// <summary>Moves a pin up (-1) or down (+1) among the pins.</summary>
|
||||
public static void Move(string key, int by)
|
||||
{
|
||||
EnsureLoaded();
|
||||
lock (Sync)
|
||||
{
|
||||
int i = _pins.IndexOf(key);
|
||||
int j = i + by;
|
||||
if (i < 0 || j < 0 || j >= _pins.Count) return;
|
||||
(_pins[i], _pins[j]) = (_pins[j], _pins[i]);
|
||||
}
|
||||
UiBackgroundWriter.Enqueue("quick settings", Save);
|
||||
}
|
||||
|
||||
/// <summary>The rows under section <paramref name="section"/> of tab <paramref name="tab"/> (up to the next section).</summary>
|
||||
public static SettingRow[] SectionRows(string tab, string section)
|
||||
{
|
||||
var list = new List<SettingRow>();
|
||||
foreach (SettingsTab t in SettingsSchema.Tabs)
|
||||
{
|
||||
if (!t.Name.Equals(tab, StringComparison.OrdinalIgnoreCase)) continue;
|
||||
bool inside = false;
|
||||
foreach (SettingRow row in t.Rows)
|
||||
{
|
||||
if (row.Kind == SettingKind.Section)
|
||||
{
|
||||
if (inside) break;
|
||||
inside = row.Label.Equals(section, StringComparison.OrdinalIgnoreCase);
|
||||
continue;
|
||||
}
|
||||
if (inside && row.Kind != SettingKind.Spacer) list.Add(row);
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
private static void EnsureIndex()
|
||||
{
|
||||
if (_byKey != null) return;
|
||||
var byKey = new Dictionary<string, SettingRow>(StringComparer.OrdinalIgnoreCase);
|
||||
var keyOf = new Dictionary<SettingRow, string>(ReferenceEqualityComparer.Instance);
|
||||
foreach (SettingsTab tab in SettingsSchema.Tabs)
|
||||
{
|
||||
string section = "";
|
||||
foreach (SettingRow row in tab.Rows)
|
||||
{
|
||||
if (row.Kind == SettingKind.Section) { section = row.Label.Trim(); continue; }
|
||||
if (!Pinnable(row)) continue;
|
||||
string key = tab.Name + "/" + section + "/" + row.Label.Trim();
|
||||
if (byKey.TryAdd(key, row)) keyOf[row] = key;
|
||||
}
|
||||
}
|
||||
_keyOf = keyOf;
|
||||
_byKey = byKey;
|
||||
}
|
||||
|
||||
private static void EnsureLoaded()
|
||||
{
|
||||
if (_loaded) return;
|
||||
lock (Sync)
|
||||
{
|
||||
if (_loaded) return;
|
||||
try
|
||||
{
|
||||
if (File.Exists(FilePath))
|
||||
foreach (string line in File.ReadAllLines(FilePath))
|
||||
{
|
||||
string key = line.Trim();
|
||||
if (key.Length > 0 && !_pins.Contains(key)) _pins.Add(key);
|
||||
}
|
||||
}
|
||||
catch { /* unreadable: start with no pins */ }
|
||||
_loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] lines;
|
||||
lock (Sync) lines = _pins.ToArray();
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(FilePath)!);
|
||||
File.WriteAllLines(FilePath, lines);
|
||||
}
|
||||
catch { /* best-effort */ }
|
||||
}
|
||||
}
|
||||
|
|
@ -6,10 +6,8 @@
|
|||
// minimized|expanded, line 2 unused, line 3 target|notarget, line 4
|
||||
// vitals|novitals; line 5 filesopen|nofiles, the Loaded files drawer; line 9
|
||||
// ranges|noranges, the Ranges drawer; line 10 patrol|nopatrol, the Patrol
|
||||
// drawer; line 11 remote|noremote, the Mini Remote drawer; line 12 the
|
||||
// drawers moved to the side they don't start on, "moved:key,key"; line 13
|
||||
// quick|noquick, the My settings drawer: the drawers on the dashboard's
|
||||
// edges, ImGui/Panels/DashboardDrawers.cs). Line 2
|
||||
// drawer; line 11 remote|noremote, the Mini Remote drawer: the left-edge
|
||||
// drawers, ImGui/Panels/DashboardDrawers.cs). Line 2
|
||||
// was the Monsters button's Simple/Advanced mode, retired 2026-10-01 with the
|
||||
// basic Monsters panel: it is still written ("advanced") so the lines after
|
||||
// it keep their places, and ignored on read. Lines 7 and 8 (the dashboard's
|
||||
|
|
@ -41,9 +39,6 @@ internal static class RynthAiDashboardState
|
|||
private static volatile bool _rangesOpen; // the Ranges drawer beside the dashboard is open
|
||||
private static volatile bool _patrolOpen; // the Patrol drawer beside the dashboard is open
|
||||
private static volatile bool _remoteOpen; // the Mini Remote drawer beside the dashboard is open
|
||||
private static volatile bool _quickOpen; // the My settings drawer beside the dashboard is open
|
||||
// Drawer keys on the side they don't start on (a tab's right-click moves it). Copy-on-write.
|
||||
private static volatile string[] _moved = Array.Empty<string>();
|
||||
// Lines 7 and 8, unused since 2026-10-05: written back as read.
|
||||
private static string _line7 = "-", _line8 = "-";
|
||||
private static bool _loaded;
|
||||
|
|
@ -160,38 +155,6 @@ internal static class RynthAiDashboardState
|
|||
UiBackgroundWriter.Enqueue("rynthai dashboard state", Save);
|
||||
}
|
||||
|
||||
/// <summary>The My settings drawer (pinned settings) is open beside the dashboard. Any thread.</summary>
|
||||
public static bool QuickOpen
|
||||
{
|
||||
get { EnsureLoaded(); return _quickOpen; }
|
||||
}
|
||||
|
||||
public static void SetQuickOpen(bool open)
|
||||
{
|
||||
EnsureLoaded();
|
||||
_quickOpen = open;
|
||||
UiBackgroundWriter.Enqueue("rynthai dashboard state", Save);
|
||||
}
|
||||
|
||||
/// <summary>The drawer <paramref name="key"/> sits on the side it doesn't start on. Any thread.</summary>
|
||||
public static bool DrawerMoved(string key)
|
||||
{
|
||||
EnsureLoaded();
|
||||
return Array.IndexOf(_moved, key) >= 0;
|
||||
}
|
||||
|
||||
public static void SetDrawerMoved(string key, bool moved)
|
||||
{
|
||||
EnsureLoaded();
|
||||
string[] cur = _moved;
|
||||
if ((Array.IndexOf(cur, key) >= 0) == moved) return;
|
||||
var list = new System.Collections.Generic.List<string>(cur);
|
||||
if (moved) list.Add(key);
|
||||
else list.Remove(key);
|
||||
_moved = list.ToArray();
|
||||
UiBackgroundWriter.Enqueue("rynthai dashboard state", Save);
|
||||
}
|
||||
|
||||
/// <summary>Reads the file if it hasn't been read yet. Engine init calls this so AC's thread never does.</summary>
|
||||
public static void EnsureLoaded()
|
||||
{
|
||||
|
|
@ -216,9 +179,6 @@ internal static class RynthAiDashboardState
|
|||
_rangesOpen = lines.Length >= 9 && lines[8].Trim().Equals("ranges", StringComparison.OrdinalIgnoreCase);
|
||||
_patrolOpen = lines.Length >= 10 && lines[9].Trim().Equals("patrol", StringComparison.OrdinalIgnoreCase);
|
||||
_remoteOpen = lines.Length >= 11 && lines[10].Trim().Equals("remote", StringComparison.OrdinalIgnoreCase);
|
||||
if (lines.Length >= 12 && lines[11].Trim().StartsWith("moved:", StringComparison.OrdinalIgnoreCase))
|
||||
_moved = lines[11].Trim().Substring(6).Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
_quickOpen = lines.Length >= 13 && lines[12].Trim().Equals("quick", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
catch { /* corrupt cache: start expanded */ }
|
||||
|
|
@ -237,8 +197,7 @@ internal static class RynthAiDashboardState
|
|||
+ (_filesOpen ? "filesopen" : "nofiles") + "\n" + (_barCollapsed ? "barcollapsed" : "bar") + "\n"
|
||||
+ _line7 + "\n" + _line8 + "\n"
|
||||
+ (_rangesOpen ? "ranges" : "noranges") + "\n" + (_patrolOpen ? "patrol" : "nopatrol") + "\n"
|
||||
+ (_remoteOpen ? "remote" : "noremote") + "\n"
|
||||
+ "moved:" + string.Join(",", _moved) + "\n" + (_quickOpen ? "quick" : "noquick") + "\n");
|
||||
+ (_remoteOpen ? "remote" : "noremote") + "\n");
|
||||
}
|
||||
catch { /* best-effort */ }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ using System.Collections.Generic;
|
|||
namespace RynthCore.Engine.UI.Sections;
|
||||
|
||||
/// <summary>An installed server plugin that is not loaded: its server and the plugin's name.</summary>
|
||||
internal readonly record struct NotLoadedServer(string Id, string Name, string Plugin, string[]? WorldNames = null);
|
||||
internal readonly record struct NotLoadedServer(string Id, string Name, string Plugin);
|
||||
|
||||
internal static class NotLoadedServers
|
||||
{
|
||||
|
|
@ -39,25 +39,10 @@ internal static class NotLoadedServers
|
|||
|
||||
/// <summary>The not-loaded servers this character forces On: their plugins should load now.</summary>
|
||||
public static List<string> ForcedOn(IReadOnlyList<NotLoadedServer> notLoaded, Func<string, ServerForce> force)
|
||||
=> ToLoad(notLoaded, force, world: null);
|
||||
|
||||
/// <summary>
|
||||
/// The not-loaded servers whose plugins should load now: forced On by this character, or (not
|
||||
/// forced Off) named by the world name the server announced (<paramref name="world"/>; null or
|
||||
/// empty before login). The host left them out, but the world says this is their server.
|
||||
/// </summary>
|
||||
public static List<string> ToLoad(IReadOnlyList<NotLoadedServer> notLoaded, Func<string, ServerForce> force, string? world)
|
||||
{
|
||||
var ids = new List<string>();
|
||||
foreach (NotLoadedServer s in notLoaded)
|
||||
{
|
||||
if (s.Id.Length == 0) continue;
|
||||
ServerForce f = force(s.Id);
|
||||
if (f == ServerForce.On
|
||||
|| (f != ServerForce.Off && !string.IsNullOrWhiteSpace(world) && s.WorldNames is { Length: > 0 }
|
||||
&& Compatibility.IltDetect.WorldNameMatches(world, s.WorldNames, out _)))
|
||||
ids.Add(s.Id);
|
||||
}
|
||||
if (s.Id.Length > 0 && force(s.Id) == ServerForce.On) ids.Add(s.Id);
|
||||
return ids;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ internal static class SectionRegistry
|
|||
// loaded as soon as this character forces their server On (picker, chat or saved override).
|
||||
List<NotLoadedServer> notLoaded = NotLoadedServerPlugins();
|
||||
NotLoadedServers.Append(servers, notLoaded, ServerForceStore.Get);
|
||||
foreach (string id in NotLoadedServers.ToLoad(notLoaded, ServerForceStore.Get, AccountHooks.AnnouncedWorldName))
|
||||
foreach (string id in NotLoadedServers.ForcedOn(notLoaded, ServerForceStore.Get))
|
||||
Plugins.PluginManager.RequestServerPluginLoad(id);
|
||||
|
||||
List<SectionView> sections = SectionCatalog.Build(manifests, ImGuiBackend.ImGuiPanelHost.CanEmbed, servers);
|
||||
|
|
@ -253,7 +253,7 @@ internal static class SectionRegistry
|
|||
IReadOnlyList<Plugins.SkippedServerPlugin> skipped = Plugins.PluginManager.SkippedServerPlugins;
|
||||
var list = new List<NotLoadedServer>(skipped.Count);
|
||||
foreach (Plugins.SkippedServerPlugin s in skipped)
|
||||
list.Add(new NotLoadedServer(SectionManifestParser.Id(s.ServerId), s.ServerName, s.PluginName, s.Manifest.Server!.WorldNames.ToArray()));
|
||||
list.Add(new NotLoadedServer(SectionManifestParser.Id(s.ServerId), s.ServerName, s.PluginName));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ internal static class ServerMenus
|
|||
/// </summary>
|
||||
public static void Tick()
|
||||
{
|
||||
SectionRegistry.Tick(); // the server verdicts (GetServerStateJson) and late server-plugin loads
|
||||
SectionRegistry.Tick();
|
||||
SectionRegistry.Snapshot snap = SectionRegistry.Current;
|
||||
List<string> serverPlugins = ServerPluginTargets(snap);
|
||||
if (!PushToRynthAi && !PushToRynthIlt && serverPlugins.Count == 0) return;
|
||||
|
|
@ -256,7 +256,7 @@ internal static class ServerMenus
|
|||
{
|
||||
if (ImGuiNET.ImGui.MenuItem("Treat this world as " + g.Server.Name + "##srvforce_" + g.Server.Id))
|
||||
Run(ForceCommand(g.Server.Id));
|
||||
SafeImGui.SetItemTooltip("Saved for this character. Undo with /rc server " + g.Server.Id + " auto, or in the Mini Remote's Char section.");
|
||||
ImGuiNET.ImGui.SetItemTooltip("Saved for this character. Undo with /rc server " + g.Server.Id + " auto, or in the Mini Remote's Char section.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -646,11 +646,11 @@ public readonly unsafe struct RynthCoreHost
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// v85: answer the next server prompt of <paramref name="type"/> (a
|
||||
/// v81: answer the next server prompt of <paramref name="type"/> (a
|
||||
/// <see cref="ConfirmationKind"/>) that arrives within <paramref name="timeoutMs"/>,
|
||||
/// without the client opening its dialog: Yes when the server's "N percent chance" is at
|
||||
/// least <paramref name="minPercent"/> (or it is 0), else No. One-shot; timeoutMs <= 0
|
||||
/// disarms. 1 armed, 0 unavailable (engine before v85, sender or hook missing), -3 bad
|
||||
/// disarms. 1 armed, 0 unavailable (engine before v81, sender or hook missing), -3 bad
|
||||
/// arguments.
|
||||
/// </summary>
|
||||
public int ArmConfirmation(uint type, int minPercent, int timeoutMs)
|
||||
|
|
@ -661,27 +661,22 @@ public readonly unsafe struct RynthCoreHost
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// v85: the last prompt the server sent. <paramref name="seq"/> counts them (0 = none yet);
|
||||
/// <paramref name="contextId"/> is the server's context for it; <paramref name="percent"/> is
|
||||
/// -1 when the text has none; <paramref name="outcome"/> is a <see cref="ConfirmationOutcome"/>.
|
||||
/// False on an engine before v85.
|
||||
/// v81: the last prompt the server sent. <paramref name="seq"/> counts them (0 = none yet);
|
||||
/// <paramref name="percent"/> is -1 when the text has none; <paramref name="outcome"/> is a
|
||||
/// <see cref="ConfirmationOutcome"/>. False on an engine before v81.
|
||||
/// </summary>
|
||||
public bool TryGetLastConfirmation(out int seq, out uint type, out uint contextId, out int percent, out int outcome, out int ageMs)
|
||||
public bool TryGetLastConfirmation(out int seq, out uint type, out int percent, out int outcome, out int ageMs)
|
||||
{
|
||||
seq = 0; type = 0; contextId = 0; percent = -1; outcome = 0; ageMs = 0;
|
||||
seq = 0; type = 0; percent = -1; outcome = 0; ageMs = 0;
|
||||
if (!HasConfirmationAnswers)
|
||||
return false;
|
||||
uint t = 0, ctx = 0;
|
||||
int pct = -1, oc = 0, age = 0;
|
||||
seq = ((delegate* unmanaged[Cdecl]<uint*, uint*, int*, int*, int*, int>)_api.GetLastConfirmationFn)(&t, &ctx, &pct, &oc, &age);
|
||||
type = t; contextId = ctx; percent = pct; outcome = oc; ageMs = age;
|
||||
type = t; percent = pct; outcome = oc; ageMs = age;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>v85: <see cref="TryGetLastConfirmation(out int, out uint, out uint, out int, out int, out int)"/> without the context id.</summary>
|
||||
public bool TryGetLastConfirmation(out int seq, out uint type, out int percent, out int outcome, out int ageMs)
|
||||
=> TryGetLastConfirmation(out seq, out type, out _, out percent, out outcome, out ageMs);
|
||||
|
||||
/// <summary>
|
||||
/// Gives an item to an NPC or another player by sending the F7B1 give
|
||||
/// GameAction (CM_Inventory::Event_GiveObjectRequest). This is the correct
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue