Skip to content

ゲーム起動/終了時のメイン画面フェード遷移を追加 - #8

Merged
RoperaSn88 merged 3 commits into
mainfrom
copilot/implement-fade-in-out-effect
Apr 21, 2026
Merged

ゲーム起動/終了時のメイン画面フェード遷移を追加#8
RoperaSn88 merged 3 commits into
mainfrom
copilot/implement-fade-in-out-effect

Conversation

Copilot AI commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

ゲーム開始時にメインウィンドウを徐々に暗転し、ゲーム終了時に暗転状態から徐々に復帰する要件に対応します。既存UI構造を維持しつつ、起動/終了境界に限定してフェード遷移を追加しました。

  • 変更概要

    • BackgroundPanel に黒オーバーレイ描画(アルファ制御)を追加。
    • GameSelectorGUI にフェード制御メソッドを追加し、開始時 0 -> 1、終了時 1 -> 0 の遷移を実装。
    • 既存の StartGame() フローへ組み込み、フェード完了後にゲームプロセスを起動し、終了後に復帰フェードを実行。
  • 遷移制御の改善

    • フェード用 Timer をクラスフィールド化し、再実行時に既存タイマーを停止して重複実行を防止。
    • ゲーム起動失敗時ログに実行パスを含め、失敗時でも復帰フェードが走るよう finally で統一。
public void StartGame(){
    if (Gaming) return;
    String GetPath = Games.get(selectNumber).path;
    Gaming = true;
    animateDarkOverlay(0f, 1f, FADE_DURATION, () -> {
        Thread gameThread = new Thread(() -> {
            try {
                Process process = new ProcessBuilder(GetPath).start();
                process.waitFor();
            } finally {
                SwingUtilities.invokeLater(
                    () -> animateDarkOverlay(1f, 0f, FADE_DURATION, () -> Gaming = false)
                );
            }
        }, "game-runner-thread");
        gameThread.start();
    });
}

Copilot AI linked an issue Apr 21, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add fade in and fade out effect to main window ゲーム起動/終了時のメイン画面フェード遷移を追加 Apr 21, 2026
Copilot AI requested a review from RoperaSn88 April 21, 2026 04:49
@RoperaSn88

Copy link
Copy Markdown
Owner

@copilot

Comment thread GameSelectorGUI.java
ArrayList<JLabel> GameTexts=new ArrayList<>();
int selectNumber=0;
public Boolean Gaming=false;
public volatile boolean Gaming=false;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

volatileってなんすか

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java の volatile は、あるスレッドで更新した値を他スレッドが読むときに“最新値”を見えるようにする修飾子です。Gaming だと、ゲーム起動処理側とUI側の状態ずれを防ぐ目的です(ただし排他制御そのものはしません)。

@RoperaSn88

Copy link
Copy Markdown
Owner

@copilot

Copilot AI requested a review from RoperaSn88 April 21, 2026 09:06
@RoperaSn88
RoperaSn88 marked this pull request as ready for review April 21, 2026 09:28
Copilot AI review requested due to automatic review settings April 21, 2026 09:28
@RoperaSn88
RoperaSn88 merged commit 30a78bb into main Apr 21, 2026
2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread GameSelectorGUI.java
Comment on lines +352 to +360
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));
}

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

がめんひょうじ

3 participants