ゲーム起動/終了時のメイン画面フェード遷移を追加 - #8
Conversation
Agent-Logs-Url: https://github.com/RoperaSn88/GameSelectorGUI/sessions/de101b39-29b9-441b-afe7-216c6dbd77f8 Co-authored-by: RoperaSn88 <61645621+RoperaSn88@users.noreply.github.com>
Agent-Logs-Url: https://github.com/RoperaSn88/GameSelectorGUI/sessions/de101b39-29b9-441b-afe7-216c6dbd77f8 Co-authored-by: RoperaSn88 <61645621+RoperaSn88@users.noreply.github.com>
| ArrayList<JLabel> GameTexts=new ArrayList<>(); | ||
| int selectNumber=0; | ||
| public Boolean Gaming=false; | ||
| public volatile boolean Gaming=false; |
There was a problem hiding this comment.
Java の volatile は、あるスレッドで更新した値を他スレッドが読むときに“最新値”を見えるようにする修飾子です。Gaming だと、ゲーム起動処理側とUI側の状態ずれを防ぐ目的です(ただし排他制御そのものはしません)。
There was a problem hiding this comment.
Pull request overview
ゲーム開始時にメイン画面を暗転フェード(0→1)し、ゲーム終了後に復帰フェード(1→0)することで、起動/終了境界の視覚遷移を追加するPRです。既存のUI構造(BackgroundPanelで背景描画、GameSelectorGUIで操作/起動制御)を保ったまま、黒オーバーレイ描画とフェード制御を組み込んでいます。
Changes:
BackgroundPanelに黒オーバーレイ(アルファ制御)描画を追加GameSelectorGUIにフェード制御(Timer管理・重複防止)を追加し、StartGame フローに統合- ゲーム起動を別スレッドに移し、終了後の復帰フェードを
finallyで保証
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try { | ||
| ProcessBuilder builder = new ProcessBuilder(GetPath); | ||
| Process process=builder.start(); | ||
| process.waitFor(); | ||
| } catch (Exception e) { | ||
| System.out.println("Failed to launch game at path: " + GetPath + " (" + e.getMessage() + ")"); | ||
| } finally { | ||
| SwingUtilities.invokeLater(() -> animateDarkOverlay(1f, 0f, FADE_DURATION, () -> Gaming=false)); | ||
| } |
There was a problem hiding this comment.
The catch block also captures InterruptedException from process.waitFor(). Swallowing interrupts can break shutdown/cancellation flows. Consider catching InterruptedException separately, restoring the interrupt status (Thread.currentThread().interrupt()), and then proceeding to the fade-back / state reset (or returning early).
ゲーム開始時にメインウィンドウを徐々に暗転し、ゲーム終了時に暗転状態から徐々に復帰する要件に対応します。既存UI構造を維持しつつ、起動/終了境界に限定してフェード遷移を追加しました。
変更概要
BackgroundPanelに黒オーバーレイ描画(アルファ制御)を追加。GameSelectorGUIにフェード制御メソッドを追加し、開始時0 -> 1、終了時1 -> 0の遷移を実装。StartGame()フローへ組み込み、フェード完了後にゲームプロセスを起動し、終了後に復帰フェードを実行。遷移制御の改善
Timerをクラスフィールド化し、再実行時に既存タイマーを停止して重複実行を防止。finallyで統一。