@@ -140,9 +140,34 @@ export class UIManager {
140140 <span class="stat-value" id="stat-water">0%</span>
141141 </div>
142142 </div>
143+ <div class="demand-meter-container-mobile" id="demand-meter-container-mobile" style="display: none;">
144+ <div class="demand-meter-mobile">
145+ <span>🏘️ <span id="demand-value-residential-mobile">50</span></span>
146+ </div>
147+ <div class="demand-meter-mobile">
148+ <span>🏪 <span id="demand-value-commercial-mobile">50</span></span>
149+ </div>
150+ <div class="demand-meter-mobile">
151+ <span>🏭 <span id="demand-value-industrial-mobile">50</span></span>
152+ </div>
153+ </div>
143154 ` ;
144155 tabContent . appendChild ( statsTab ) ;
145156
157+ // ステータスタブにトグルボタンを追加
158+ const toggleDemandBtn = document . createElement ( 'button' ) ;
159+ toggleDemandBtn . id = 'btn-toggle-demand-mobile' ;
160+ toggleDemandBtn . className = 'btn-toggle-demand-mobile' ;
161+ toggleDemandBtn . textContent = '📊 需要メーター' ;
162+ toggleDemandBtn . addEventListener ( 'click' , ( ) => {
163+ const container = document . getElementById ( 'demand-meter-container-mobile' ) ;
164+ if ( container ) {
165+ container . style . display = container . style . display === 'none' ? 'block' : 'none' ;
166+ this . engine . state . showDemandMeters = container . style . display !== 'none' ;
167+ }
168+ } ) ;
169+ statsTab . appendChild ( toggleDemandBtn ) ;
170+
146171 // 建設タブ
147172 const buildTab = document . createElement ( 'div' ) ;
148173 buildTab . className = 'mobile-tab-pane' ;
@@ -368,6 +393,30 @@ export class UIManager {
368393 <span class="stat-value" id="stat-water">0%</span>
369394 </div>
370395 </div>
396+ <div class="demand-meter-container" id="demand-meter-container" style="display: none;">
397+ <div class="demand-meter">
398+ <span class="demand-label">🏘️</span>
399+ <div class="demand-bar">
400+ <div class="demand-fill" id="demand-residential" style="width: 50%"></div>
401+ </div>
402+ <span class="demand-value" id="demand-value-residential">50</span>
403+ </div>
404+ <div class="demand-meter">
405+ <span class="demand-label">🏪</span>
406+ <div class="demand-bar">
407+ <div class="demand-fill" id="demand-commercial" style="width: 50%"></div>
408+ </div>
409+ <span class="demand-value" id="demand-value-commercial">50</span>
410+ </div>
411+ <div class="demand-meter">
412+ <span class="demand-label">🏭</span>
413+ <div class="demand-bar">
414+ <div class="demand-fill" id="demand-industrial" style="width: 50%"></div>
415+ </div>
416+ <span class="demand-value" id="demand-value-industrial">50</span>
417+ </div>
418+ </div>
419+ <button id="btn-toggle-demand" class="btn-toggle-demand" title="需要メーター表示">📊</button>
371420 ` ;
372421 container . appendChild ( dashboard ) ;
373422
@@ -611,13 +660,46 @@ export class UIManager {
611660 document . getElementById ( 'stat-international' ) ! . textContent = Math . round ( this . engine . state . internationalLevel ) . toString ( ) ;
612661 document . getElementById ( 'stat-power' ) ! . textContent = Math . round ( this . engine . state . powerSupplyRate ) . toString ( ) + '%' ;
613662 document . getElementById ( 'stat-water' ) ! . textContent = Math . round ( this . engine . state . waterSupplyRate ) . toString ( ) + '%' ;
663+
664+ // デマンドメーター表示(デスクトップ)
665+ if ( this . engine . state . showDemandMeters ) {
666+ const residentialDemand = Math . round ( this . engine . state . residentialDemand ) ;
667+ const commercialDemand = Math . round ( this . engine . state . commercialDemand ) ;
668+ const industrialDemand = Math . round ( this . engine . state . industrialDemand ) ;
669+
670+ const resFill = document . getElementById ( 'demand-residential' ) as HTMLElement ;
671+ const comFill = document . getElementById ( 'demand-commercial' ) as HTMLElement ;
672+ const indFill = document . getElementById ( 'demand-industrial' ) as HTMLElement ;
673+
674+ if ( resFill ) resFill . style . width = Math . max ( 0 , Math . min ( 100 , residentialDemand ) ) + '%' ;
675+ if ( comFill ) comFill . style . width = Math . max ( 0 , Math . min ( 100 , commercialDemand ) ) + '%' ;
676+ if ( indFill ) indFill . style . width = Math . max ( 0 , Math . min ( 100 , industrialDemand ) ) + '%' ;
677+
678+ document . getElementById ( 'demand-value-residential' ) ! . textContent = residentialDemand . toString ( ) ;
679+ document . getElementById ( 'demand-value-commercial' ) ! . textContent = commercialDemand . toString ( ) ;
680+ document . getElementById ( 'demand-value-industrial' ) ! . textContent = industrialDemand . toString ( ) ;
681+
682+ // モバイル版
683+ document . getElementById ( 'demand-value-residential-mobile' ) ! . textContent = residentialDemand . toString ( ) ;
684+ document . getElementById ( 'demand-value-commercial-mobile' ) ! . textContent = commercialDemand . toString ( ) ;
685+ document . getElementById ( 'demand-value-industrial-mobile' ) ! . textContent = industrialDemand . toString ( ) ;
686+ }
614687 }
615688
616689 private attachEventListeners ( ) : void {
617690 // GUI表示/非表示トグル
618691 document . getElementById ( 'btn-toggle-gui' ) ?. addEventListener ( 'click' , ( ) => this . toggleGUI ( ) ) ;
619692 document . getElementById ( 'btn-close-gui' ) ?. addEventListener ( 'click' , ( ) => this . toggleGUI ( ) ) ;
620693
694+ // デマンドメーター トグル(デスクトップ)
695+ document . getElementById ( 'btn-toggle-demand' ) ?. addEventListener ( 'click' , ( ) => {
696+ const container = document . getElementById ( 'demand-meter-container' ) ;
697+ if ( container ) {
698+ container . style . display = container . style . display === 'none' ? 'block' : 'none' ;
699+ this . engine . state . showDemandMeters = container . style . display !== 'none' ;
700+ }
701+ } ) ;
702+
621703 // 時間制御ボタン
622704 document . getElementById ( 'btn-pause' ) ?. addEventListener ( 'click' , ( ) => this . setGameSpeed ( 0 ) ) ;
623705 document . getElementById ( 'btn-slow' ) ?. addEventListener ( 'click' , ( ) => this . setGameSpeed ( 0.5 ) ) ;
0 commit comments