From b490e463b0360908ca96196950020a691331b38a Mon Sep 17 00:00:00 2001 From: TtiPo Date: Tue, 1 Sep 2026 22:38:56 +0900 Subject: [PATCH] =?UTF-8?q?Godot=20=EC=8B=A4=ED=96=89=20=EC=8A=A4=ED=81=AC?= =?UTF-8?q?=EB=A6=BD=ED=8A=B8=EA=B0=80=20=EC=84=A4=EC=B9=98=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=EB=A5=BC=20=EC=8A=A4=EC=8A=A4=EB=A1=9C=20=EC=B0=BE?= =?UTF-8?q?=EB=8F=84=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit run.ps1과 test.ps1이 %LOCALAPPDATA%\Programs\Godot 한 곳만 보고 있어서 다른 데 설치하면 "Godot을 찾을 수 없습니다"로 끝났다. find-godot.ps1을 두어 GODOT_BIN 환경 변수 → 알려진 설치 폴더들(바탕화면·다운로드 포함) → PATH 순으로 찾고, 필요한 판(콘솔/일반)을 가려 쓰게 했다. 이름으로 훑기 때문에 버전이 올라가도 잡힌다. 클론 직후에는 .godot이 없어 class_name이 등록되지 않는다. 그 상태로 실행하면 game_state.gd 파싱이 실패해 오토로드가 통째로 죽으므로, 두 스크립트가 먼저 --import를 한 번 돌린다. 세 파일 모두 UTF-8 BOM으로 저장했다. BOM이 없으면 Windows PowerShell 5.1이 cp949로 읽어 한글 메시지가 깨진다. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01Uze4mF1NAGfFRio77cMFqg --- find-godot.ps1 | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ run.ps1 | 21 +++++++++++++++++---- test.ps1 | 19 +++++++++++++++++-- 3 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 find-godot.ps1 diff --git a/find-godot.ps1 b/find-godot.ps1 new file mode 100644 index 0000000..5949ed7 --- /dev/null +++ b/find-godot.ps1 @@ -0,0 +1,48 @@ +# Godot 4 실행 파일을 찾는다. 못 찾으면 아무것도 내놓지 않는다. +# .\find-godot.ps1 그냥 실행판 (창이 뜬다) +# .\find-godot.ps1 -Console 콘솔판 (--headless 용, 출력이 보인다) +# 찾는 순서: $env:GODOT_BIN > 아래 폴더들 > PATH 위의 godot +param([switch]$Console) + +$dirs = @( + "$env:LOCALAPPDATA\Programs\Godot", + [Environment]::GetFolderPath('Desktop'), + "$env:USERPROFILE\Desktop", + "$env:OneDrive\Desktop", + "$env:USERPROFILE\Downloads", + "$env:ProgramFiles\Godot" +) + +$found = $null + +if ($env:GODOT_BIN -and (Test-Path $env:GODOT_BIN)) { + $found = $env:GODOT_BIN +} + +if (-not $found) { + foreach ($d in $dirs) { + if (-not $d -or -not (Test-Path $d)) { continue } + # 버전이 올라가도 잡히도록 이름으로 훑고, 높은 버전을 먼저 쓴다 + $hit = Get-ChildItem -Path $d -Filter "Godot_v4*_win64.exe" -File -ErrorAction SilentlyContinue | + Where-Object { $_.Name -notlike "*_console.exe" } | + Sort-Object Name -Descending | Select-Object -First 1 + if ($hit) { $found = $hit.FullName; break } + } +} + +if (-not $found) { + $cmd = Get-Command godot -ErrorAction SilentlyContinue + if ($cmd) { $found = $cmd.Source } +} + +if (-not $found) { return } + +# 찾은 것과 원하는 판이 다르면 짝이 되는 파일로 바꿔 준다 +$isConsole = $found -like "*_console.exe" +if ($Console -ne $isConsole) { + if ($Console) { $alt = $found -replace '\.exe$', '_console.exe' } + else { $alt = $found -replace '_console\.exe$', '.exe' } + if (Test-Path $alt) { $found = $alt } +} + +return $found diff --git a/run.ps1 b/run.ps1 index ff27047..d9ad85e 100644 --- a/run.ps1 +++ b/run.ps1 @@ -1,7 +1,20 @@ -# 에디터 없이 게임만 바로 실행합니다. 사용: 우클릭 > PowerShell로 실행, 또는 .\run.ps1 -$godot = "$env:LOCALAPPDATA\Programs\Godot\Godot_v4.7.2-stable_win64.exe" -if (-not (Test-Path $godot)) { - Write-Error "Godot을 찾을 수 없습니다: $godot" +# 에디터 없이 게임만 바로 실행합니다. 사용: 우클릭 > PowerShell로 실행, 또는 .\run.ps1 +$godot = & "$PSScriptRoot\find-godot.ps1" +if (-not $godot) { + Write-Error "Godot 4를 찾을 수 없습니다. 실행 파일 경로를 GODOT_BIN 환경 변수에 넣어 주세요." exit 1 } + +# 클론 직후엔 .godot이 없다. 한 번 가져와야 class_name이 등록되고 스크립트가 뜬다. +if (-not (Test-Path "$PSScriptRoot\.godot")) { + Write-Host "첫 실행입니다. 프로젝트를 가져오는 중..." + $importer = & "$PSScriptRoot\find-godot.ps1" -Console + if (-not $importer) { $importer = $godot } + & $importer --headless --import --path $PSScriptRoot + if ($LASTEXITCODE -ne 0) { + Write-Error "가져오기에 실패했습니다." + exit 1 + } +} + Start-Process -FilePath $godot -ArgumentList @("--path", $PSScriptRoot) -WorkingDirectory $PSScriptRoot diff --git a/test.ps1 b/test.ps1 index a756272..b214ef1 100644 --- a/test.ps1 +++ b/test.ps1 @@ -1,4 +1,19 @@ -# 경제 로직 스모크 테스트를 돌립니다. 사용: .\test.ps1 -$godot = "$env:LOCALAPPDATA\Programs\Godot\Godot_v4.7.2-stable_win64_console.exe" +# 경제 로직 스모크 테스트를 돌립니다. 사용: .\test.ps1 +$godot = & "$PSScriptRoot\find-godot.ps1" -Console +if (-not $godot) { + Write-Error "Godot 4를 찾을 수 없습니다. 실행 파일 경로를 GODOT_BIN 환경 변수에 넣어 주세요." + exit 1 +} + +# 클론 직후엔 .godot이 없다. 한 번 가져와야 class_name이 등록되고 스크립트가 뜬다. +if (-not (Test-Path "$PSScriptRoot\.godot")) { + Write-Host "첫 실행입니다. 프로젝트를 가져오는 중..." + & $godot --headless --import --path $PSScriptRoot + if ($LASTEXITCODE -ne 0) { + Write-Error "가져오기에 실패했습니다." + exit 1 + } +} + & $godot --headless --path $PSScriptRoot res://tests/smoke.tscn exit $LASTEXITCODE