@@ -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+
761825async 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 ( ) {
0 commit comments