Skip to content

Commit 1bb66e9

Browse files
committed
.NET: Rename web API test to reflect new code, hide dashboard entries
1 parent 7013fdd commit 1bb66e9

6 files changed

Lines changed: 86 additions & 44 deletions

File tree

csharp-api/CMakeLists.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -542,23 +542,23 @@ if(REFRAMEWORK_REF_ASSEMBLIES_EXIST_MHWILDS) # build-csharp-test-mhwilds
542542
set_dotnet_references(CSharpAPITestMHWilds "mhwilds" "${MHWILDS_DLLS}")
543543

544544
endif()
545-
# Target: CSharpAPITestMHWildsWebAPI
545+
# Target: CSharpAPITestWebAPI
546546
if(REFRAMEWORK_REF_ASSEMBLIES_EXIST_MHWILDS) # build-csharp-test-mhwilds
547-
set(CSharpAPITestMHWildsWebAPI_SOURCES
548-
"test/Test/TestMHWildsWebAPI.cs"
547+
set(CSharpAPITestWebAPI_SOURCES
548+
"test/Test/TestWebAPI.cs"
549549
cmake.toml
550550
)
551551

552-
add_library(CSharpAPITestMHWildsWebAPI SHARED)
552+
add_library(CSharpAPITestWebAPI SHARED)
553553

554-
target_sources(CSharpAPITestMHWildsWebAPI PRIVATE ${CSharpAPITestMHWildsWebAPI_SOURCES})
555-
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${CSharpAPITestMHWildsWebAPI_SOURCES})
554+
target_sources(CSharpAPITestWebAPI PRIVATE ${CSharpAPITestWebAPI_SOURCES})
555+
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${CSharpAPITestWebAPI_SOURCES})
556556

557-
target_link_libraries(CSharpAPITestMHWildsWebAPI PUBLIC
557+
target_link_libraries(CSharpAPITestWebAPI PUBLIC
558558
csharp-api
559559
)
560560

561-
set_target_properties(CSharpAPITestMHWildsWebAPI PROPERTIES
561+
set_target_properties(CSharpAPITestWebAPI PROPERTIES
562562
RUNTIME_OUTPUT_DIRECTORY_RELEASE
563563
"${CMAKE_BINARY_DIR}/bin/"
564564
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO
@@ -579,8 +579,8 @@ if(REFRAMEWORK_REF_ASSEMBLIES_EXIST_MHWILDS) # build-csharp-test-mhwilds
579579
ClassLibrary
580580
)
581581

582-
set(CMKR_TARGET CSharpAPITestMHWildsWebAPI)
583-
set_dotnet_references(CSharpAPITestMHWildsWebAPI "mhwilds" "${MHWILDS_DLLS}")
582+
set(CMKR_TARGET CSharpAPITestWebAPI)
583+
set_dotnet_references(CSharpAPITestWebAPI "mhwilds" "${MHWILDS_DLLS}")
584584

585585
endif()
586586
# Target: CSharpAPITestRE9

csharp-api/cmake.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,13 @@ cmake-after = """
270270
set_dotnet_references(CSharpAPITestMHWilds "mhwilds" "${MHWILDS_DLLS}")
271271
"""
272272

273-
[target.CSharpAPITestMHWildsWebAPI]
273+
[target.CSharpAPITestWebAPI]
274274
condition = "build-csharp-test-mhwilds"
275275
type = "CSharpSharedTarget"
276-
sources = ["test/Test/TestMHWildsWebAPI.cs"]
276+
sources = ["test/Test/TestWebAPI.cs"]
277277
link-libraries = ["csharp-api"]
278278
cmake-after = """
279-
set_dotnet_references(CSharpAPITestMHWildsWebAPI "mhwilds" "${MHWILDS_DLLS}")
279+
set_dotnet_references(CSharpAPITestWebAPI "mhwilds" "${MHWILDS_DLLS}")
280280
"""
281281

282282
[target.CSharpAPITestRE9]

csharp-api/make_symlinks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def symlink_main(gamedir=None, bindir="build/bin", just_copy=False, skip_test_sc
3535
"Test/Test/TestRE2.cs",
3636
"Test/Test/TestRE4.cs",
3737
"Test/Test/TestMHWilds.cs",
38-
"Test/Test/TestMHWildsWebAPI.cs",
38+
"Test/Test/TestWebAPI.cs",
3939
"Test/Test/TestRE9.cs",
4040
"Test/Test/ObjectExplorer.cs",
4141
]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using REFrameworkNET;
1010
using REFrameworkNET.Attributes;
1111

12-
class MHWildsWebAPI {
12+
class REFrameworkWebAPI {
1313
static HttpListener s_listener;
1414
static Thread s_thread;
1515
static CancellationTokenSource s_cts = new();
@@ -25,7 +25,7 @@ class MHWildsWebAPI {
2525
[PluginEntryPoint]
2626
public static void Main() {
2727
try {
28-
var pluginDir = API.GetPluginDirectory(typeof(MHWildsWebAPI).Assembly);
28+
var pluginDir = API.GetPluginDirectory(typeof(REFrameworkWebAPI).Assembly);
2929
s_webRoot = Path.Combine(pluginDir, "WebAPI");
3030

3131
if (!Directory.Exists(s_webRoot)) {

csharp-api/test/Test/WebAPI/dashboard.js

Lines changed: 68 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -758,39 +758,81 @@ async function updateChat() {
758758
});
759759
})();
760760

761+
// ── Game name mapping ──────────────────────────────────────────────
762+
const GAME_NAMES = {
763+
MonsterHunterWilds: 'Monster Hunter Wilds',
764+
DevilMayCry5: 'Devil May Cry 5',
765+
re2: 'Resident Evil 2',
766+
re3: 'Resident Evil 3',
767+
re4: 'Resident Evil 4',
768+
re8: 'Resident Evil Village',
769+
StreetFighter6: 'Street Fighter 6',
770+
DragonsDogma2: "Dragon's Dogma 2",
771+
};
772+
773+
let gameEndpoints = [];
774+
775+
async function initDashboard() {
776+
try {
777+
const info = await fetchJson('/api');
778+
const game = info.game || 'REFramework';
779+
const title = GAME_NAMES[game] || game;
780+
document.getElementById('game-title').textContent = title;
781+
document.title = title + ' Dashboard';
782+
gameEndpoints = info.endpoints || [];
783+
} catch {
784+
document.getElementById('game-title').textContent = 'REFramework (offline)';
785+
}
786+
787+
const has = (ep) => gameEndpoints.includes(ep);
788+
789+
// Hide cards for endpoints not available in this game
790+
const cardMap = {
791+
'/api/player': 'player-card',
792+
'/api/weather': 'weather-card',
793+
'/api/map': 'map-card',
794+
'/api/equipment': 'equip-card',
795+
'/api/palico': 'palico-card',
796+
'/api/huntlog': 'huntlog-card',
797+
'/api/inventory': 'inventory-card',
798+
'/api/meshes': 'mesh-card',
799+
'/api/chat': 'chat-card',
800+
'/api/lobby': 'lobby-card',
801+
};
802+
for (const [ep, cardId] of Object.entries(cardMap)) {
803+
if (!has(ep)) {
804+
const el = document.getElementById(cardId);
805+
if (el) el.style.display = 'none';
806+
}
807+
}
808+
809+
// Fast-polling data (camera always, player if available) every 500ms
810+
setInterval(poll, 500);
811+
poll();
812+
813+
// Medium-polling: only start polls for endpoints the game exposes
814+
if (has('/api/lobby')) { updateLobby(); setInterval(updateLobby, 5000); }
815+
if (has('/api/weather')) { updateWeather(); setInterval(updateWeather, 5000); }
816+
if (has('/api/equipment')) { updateEquipment(); setInterval(updateEquipment, 5000); }
817+
if (has('/api/inventory')) { updateInventory(); setInterval(updateInventory, 5000); }
818+
if (has('/api/meshes')) { updateMeshes(); setInterval(updateMeshes, 5000); }
819+
if (has('/api/map')) { updateMap(); setInterval(updateMap, 5000); }
820+
if (has('/api/chat')) { updateChat(); setInterval(updateChat, 3000); }
821+
if (has('/api/huntlog')) { updateHuntLog(); setInterval(updateHuntLog, 10000); }
822+
if (has('/api/palico')) { updatePalico(); setInterval(updatePalico, 5000); }
823+
}
824+
761825
async function poll() {
762826
pollCount++;
763827
const start = performance.now();
764-
await Promise.all([updatePlayer(), updateCamera(), updateFPSFast()]);
828+
const tasks = [updateCamera(), updateFPSFast()];
829+
if (gameEndpoints.includes('/api/player')) tasks.push(updatePlayer());
830+
await Promise.all(tasks);
765831
const ms = (performance.now() - start).toFixed(0);
766832
document.getElementById('poll-info').textContent = `Poll #${pollCount} | ${ms}ms | ${new Date().toLocaleTimeString()}`;
767833
}
768834

769-
// Fast-polling data (player, camera) every 500ms
770-
setInterval(poll, 500);
771-
772-
// Medium-polling data (lobby, weather, equipment, map) every 5s
773-
updateLobby();
774-
updateWeather();
775-
updateEquipment();
776-
updateInventory();
777-
updateMeshes();
778-
updateMap();
779-
updateChat();
780-
updateHuntLog();
781-
updatePalico();
782-
setInterval(updateLobby, 5000);
783-
setInterval(updateWeather, 5000);
784-
setInterval(updateEquipment, 5000);
785-
setInterval(updateInventory, 5000);
786-
setInterval(updateMeshes, 5000);
787-
setInterval(updateMap, 5000);
788-
setInterval(updateChat, 3000);
789-
setInterval(updateHuntLog, 10000);
790-
setInterval(updatePalico, 5000);
791-
792-
// Initial fast poll
793-
poll();
835+
initDashboard();
794836

795837
// ── Tooltip for [data-tip] elements ──────────────────────────────
796838
(function() {

csharp-api/test/Test/WebAPI/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1">
6-
<title>MHWilds Dashboard</title>
6+
<title>REFramework Dashboard</title>
77
<link rel="stylesheet" href="/style.css">
88
</head>
99
<body>
10-
<h1>Monster Hunter Wilds</h1>
10+
<h1 id="game-title">REFramework</h1>
1111
<p class="subtitle">REFramework.NET Live Dashboard &mdash; <a class="nav-link" href="/explorer.html">Object Explorer</a></p>
1212

1313
<div class="grid">

0 commit comments

Comments
 (0)