Skip to content

Commit

Permalink
Merge branch 'master' into HeroGuardPostCapture
Browse files Browse the repository at this point in the history
  • Loading branch information
walt253 authored Oct 8, 2024
2 parents ea7664b + 7debbdf commit c0cca07
Show file tree
Hide file tree
Showing 1,051 changed files with 128,425 additions and 140,225 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: Trass3r/setup-cpp@master
Expand All @@ -19,19 +19,19 @@ jobs:
set -eux
sudo apt update
sudo apt install -y build-essential g++-mingw-w64-i686 libpng16-16
- name: build
run: |
set -eux
BUILD_NUMBER=$(git rev-list --count origin/master)
GITHUB_SHA=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.sha)
PACKAGE_SUFFIX=Prototype_$(git rev-parse --short=7 "$GITHUB_SHA")
make -j`nproc` BUILD_NUMBER=$BUILD_NUMBER PACKAGE_SUFFIX=$PACKAGE_SUFFIX heavylog DEBUG=1 -k
make -j`nproc` BUILD_NUMBER=$BUILD_NUMBER PACKAGE_SUFFIX=$PACKAGE_SUFFIX standard
make -j`nproc` BUILD_NUMBER=$BUILD_NUMBER PACKAGE_SUFFIX=$PACKAGE_SUFFIX package
make BUILD_NUMBER=$BUILD_NUMBER PACKAGE_SUFFIX=$PACKAGE_SUFFIX heavylog DEBUG=1 -k
make BUILD_NUMBER=$BUILD_NUMBER PACKAGE_SUFFIX=$PACKAGE_SUFFIX standard
make BUILD_NUMBER=$BUILD_NUMBER PACKAGE_SUFFIX=$PACKAGE_SUFFIX package
echo "ZIP_NAME=$(basename -s .7z pkg/keeperfx*.7z)" >> $GITHUB_ENV
rm pkg/keeperfx*.7z
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ env.ZIP_NAME }}
path: pkg/**
17 changes: 12 additions & 5 deletions .github/workflows/Push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: Trass3r/setup-cpp@master
Expand All @@ -21,17 +21,24 @@ jobs:
sudo apt update
sudo apt install -y build-essential g++-mingw-w64-i686 libpng16-16
- name: build gfx
run: |
set -eux
BUILD_NUMBER=$(git rev-list --count HEAD)
PACKAGE_SUFFIX=Alpha
make BUILD_NUMBER=$BUILD_NUMBER PACKAGE_SUFFIX=$PACKAGE_SUFFIX pkg-enginegfx
- name: build
run: |
set -eux
BUILD_NUMBER=$(git rev-list --count HEAD)
PACKAGE_SUFFIX=Alpha
make -j`nproc` BUILD_NUMBER=$BUILD_NUMBER PACKAGE_SUFFIX=$PACKAGE_SUFFIX heavylog DEBUG=1 -k
make -j`nproc` BUILD_NUMBER=$BUILD_NUMBER PACKAGE_SUFFIX=$PACKAGE_SUFFIX standard
make -j`nproc` BUILD_NUMBER=$BUILD_NUMBER PACKAGE_SUFFIX=$PACKAGE_SUFFIX package
make BUILD_NUMBER=$BUILD_NUMBER PACKAGE_SUFFIX=$PACKAGE_SUFFIX heavylog DEBUG=1 -k
make BUILD_NUMBER=$BUILD_NUMBER PACKAGE_SUFFIX=$PACKAGE_SUFFIX standard
make BUILD_NUMBER=$BUILD_NUMBER PACKAGE_SUFFIX=$PACKAGE_SUFFIX package
echo "ZIP_NAME=$(basename -s .7z pkg/keeperfx*.7z)" >> $GITHUB_ENV
rm pkg/keeperfx*.7z
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ env.ZIP_NAME }}
path: pkg/**
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ build*/
docs/html
docs/latex
*.o
*.Po
*.d
*.Tpo
res/keeperfx_icon.ico
.header_checksum
18 changes: 18 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "MinGW",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/i686-w64-mingw32-gcc",
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "windows-gcc-x86",
//"configurationProvider": "ms-vscode.makefile-tools",
//"compileCommands": "${workspaceFolder}/compile_commands.json",
}
],
"version": 4
}
90 changes: 90 additions & 0 deletions .vscode/compile_and_copy_files.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# receive params for script (must be first line in file, other than comments)
Param( $workspaceFolder, $launchJsonFile, $compileSettingsFile )

# show param inputs
Write-Host "workspaceFolder: '$workspaceFolder'" -ForegroundColor DarkGray
Write-Host "launchJsonFile: '$launchJsonFile'" -ForegroundColor DarkGray
Write-Host "compileSettingsFile: '$compileSettingsFile'" -ForegroundColor DarkGray

# validate param inputs
if( -not (Test-Path $workspaceFolder))
{
Write-Host "Invalid workspaceFolder '$workspaceFolder'. Something went wrong." -ForegroundColor Red;
exit;
}
if( -not (Test-Path $launchJsonFile))
{
Write-Host "Invalid launchJsonFile '$launchJsonFile'. Something went wrong." -ForegroundColor Red;
exit;
}
if( -not (Test-Path $compileSettingsFile))
{
Write-Host "Invalid compileSettingsFile '$compileSettingsFile'. Something went wrong." -ForegroundColor Red;
exit;
}

# inform user of relevant information
Write-Host ('Source Code directory: ' + "${workspaceFolder}".Replace('\\', '/')) -ForegroundColor White;

# grab game directory via regex
$regexPattern = '\"cwd\"\s*:\s*\"(.*?)\"';
Write-Host "regexPattern: '$regexPattern'" -ForegroundColor DarkGray;

$regexResult = (Get-Content -Raw "$launchJsonFile" | Select-String -Pattern $regexPattern);

if( -not $regexResult.Matches -or $regexResult.Matches.Length -le 0 -or -not $regexResult.Matches.Groups -or $regexResult.Matches.Groups.Length -le 1 )
{
Write-Host "The current working directory `"cwd`" could not be found in '$launchJsonFile', please edit the file and update it." -ForegroundColor Red;
Write-Host "Example: `"cwd`": `"D:/Games/DungeonKeeper/`" (be sure to use forward slashes)." -ForegroundColor Red;
exit;
}

$gameDir = $regexResult.Matches[0].Groups[1].Value.Replace('\\', '/');
Write-Host "Found current working directory (cwd): '$gameDir' in '$launchJsonFile'" -ForegroundColor White;
if( -not (Test-Path $gameDir) )
{
Write-Host "Directory '$gameDir' invalid, make sure it exists on-disk and the path is spelled correctly." -ForegroundColor Red;
Write-Host "Example: `"cwd`": `"D:/Games/DungeonKeeper/`" (be sure to use forward slashes)." -ForegroundColor Red;
exit;
}
else
{
Write-Host "Directory '$gameDir' valid, exists on-disk" -ForegroundColor DarkGray;
}

$debugFlag = 'DEBUG=0';
$debugFlagFTest = 'FTEST_DEBUG=0';

$compileSetting = (Get-Content "$compileSettingsFile" -Raw).Trim();
if ($compileSetting -like '*DEBUG=1*')
{
$debugFlag = 'DEBUG=1';
}
if ($compileSetting -like 'FTEST_DEBUG=*')
{
$debugFlagFTest = 'FTEST_DEBUG=1';
}

if ($debugFlag -eq 'DEBUG=1')
{
Write-Host 'Compiling with DEBUG=1' -ForegroundColor Yellow;
}
else
{
Write-Host 'Compiling with DEBUG=0' -ForegroundColor Green;
}

if ($debugFlagFTest -eq 'FTEST_DEBUG=1')
{
Write-Host 'Compiling with FTEST_DEBUG=1' -ForegroundColor Magenta;
}
wsl make all -j`nproc` $debugFlag $debugFlagFTest;
if ($?) {
Write-Host 'Compilation successful!' -ForegroundColor Green;
}
else
{
Write-Host 'Compilation failed!' -ForegroundColor Red;
exit 1;
}
Copy-Item -Path "${workspaceFolder}\\bin\\*" -Destination $gameDir -Force;
1 change: 1 addition & 0 deletions .vscode/compile_settings.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEBUG=0
158 changes: 158 additions & 0 deletions .vscode/create_settings_and_launch_files.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# receive params for script (must be first line in file, other than comments)
Param( $workspaceFolder, $templateSettingsFile, $templateLaunchFile, $settingsJsonFile, $launchJsonFile )

# sanitize inputs
$workspaceFolder = $workspaceFolder.Replace('\', '/')
$templateSettingsFile = $templateSettingsFile.Replace('\', '/')
$templateLaunchFile = $templateLaunchFile.Replace('\', '/')
$settingsJsonFile = $settingsJsonFile.Replace('\', '/')
$launchJsonFile = $launchJsonFile.Replace('\', '/')
$driveLetter = (Split-Path -Path $workspaceFolder -Qualifier).Split(":").Get(0)
$driveLetterLower = $driveLetter.ToLower()

# show param inputs
Write-Host "workspaceFolder: '$workspaceFolder'" -ForegroundColor DarkGray
Write-Host "templateSettingsFile: '$templateSettingsFile'" -ForegroundColor DarkGray
Write-Host "templateLaunchFile: '$templateLaunchFile'" -ForegroundColor DarkGray
Write-Host "settingsJsonFile: '$settingsJsonFile'" -ForegroundColor DarkGray
Write-Host "launchJsonFile: '$launchJsonFile'" -ForegroundColor DarkGray

# validate param inputs
if( -not (Test-Path $workspaceFolder))
{
Write-Host "Invalid workspaceFolder '$workspaceFolder'. Something went wrong." -ForegroundColor Red
exit
}
if( -not (Test-Path $templateSettingsFile))
{
Write-Host "Invalid templateSettingsFile '$templateSettingsFile'. Something went wrong." -ForegroundColor Red
exit
}
if( -not (Test-Path $templateLaunchFile))
{
Write-Host "Invalid templateLaunchFile '$templateLaunchFile'. Something went wrong." -ForegroundColor Red
exit
}

# inform user of relevant information
Write-Host ('Source Code directory: ' + "${workspaceFolder}") -ForegroundColor White

# import windows gui stuff
Add-Type -AssemblyName System.Windows.Forms

# check for / copy settings.json
if( Test-Path $settingsJsonFile )
{
Write-Host ("settingsJsonFile '$settingsJsonFile' exists, skipping generation") -ForegroundColor DarkGray
}
else
{
Copy-Item "${templateSettingsFile}" $settingsJsonFile
Write-Host ("settingsJsonFile '$settingsJsonFile' was created.") -ForegroundColor White
}

# check for / generate / copy launch.json
if( Test-Path $launchJsonFile )
{
Write-Host ("launchJsonFile '$launchJsonFile' exists, skipping generation") -ForegroundColor DarkGray
}
else
{
# determine KeeperFx executable path from user dialog
$keeperFxExecutable = ""
$doneSelectingFilepath = $false
:fileLoop while( -not $doneSelectingFilepath )
{
# prompt user with file browser dialog to locate keeperfx.exe
Write-Host "Prompting user for KeeperFX executable filepath..." -ForegroundColor DarkGray
$FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
InitialDirectory = [Environment]::GetFolderPath('Desktop')
Filter = 'Installed KeeperFX executable|keeperfx.exe'
Title = "Please select the installed Game executable (keeperfx.exe)"
}

$FileBrowserResult = $FileBrowser.ShowDialog((New-Object System.Windows.Forms.Form -Property @{TopMost = $true }))
Write-Host "User selected '$FileBrowserResult'" -ForegroundColor DarkGray
if( $FileBrowserResult -ne "OK" )
{
# DO NOT use this -> [System.Windows.Forms.MessageBox]::Show, because it breaks the current window focus, and consecutive windows will be in the background, confusing users
# Instead, use custom windows form below, for a simple yes/no popup.

$form = New-Object System.Windows.Forms.Form
$form.Text = 'KeeperFX.exe not found'
$form.Size = New-Object System.Drawing.Size(312,128)
$form.AutoSize = $false
$form.StartPosition = 'CenterScreen'
$form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedSingle;
$form.MinimizeBox = $false
$form.MaximizeBox = $false

# form icon using base64 string of 32x32 keeperfx icon
$iconBase64 = 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAAAG1BMVEX///8AAAD//wCAgACAgICAAAD/AADAwMD///8oIYO3AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQflBRgWJxAIya1SAAAA40lEQVQoz1WRQY7DIAxF8Q1CUg5QWT1AmlnMtqp6gCj5ZLazcC6AInU/rdRjl2ZCMKysxwPMt7GmWGTqqgDWNMdCOBo6a6VuTaEQx12tfISPkojltaJzux1IRcNrM9TwplJ3i4TctU13HQBrHcb9dgf4GcAOCDPES58bciIQUS3T5P2kBEM/C+4FkHHErwZ+mrw23PAY/1Bp8EQJwverWzTg0IVTBgTmwKdegcDMiwZDBMgg/jbwkn9LN8gQILhsoPlyXmICh65K4cdAZunTQCiOwcXEKmP/Z0ZrwrDrqPPLqX4Dt+cuw4zSIHYAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjEtMDUtMjRUMjI6Mzk6MDQrMDA6MDA1uUv2AAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIwLTA4LTI5VDIzOjA2OjM3KzAwOjAwZ7W8mwAAAA5lWElmTU0AKgAAAAgAAAAAAAAA0lOTAAAAAElFTkSuQmCC'
$iconBytes = [Convert]::FromBase64String($iconBase64)
$stream = [System.IO.MemoryStream]::new($iconBytes, 0, $iconBytes.Length)
$form.Icon = [System.Drawing.Icon]::FromHandle(([System.Drawing.Bitmap]::new($stream).GetHIcon()))

$okButton = New-Object System.Windows.Forms.Button
$okButton.Location = New-Object System.Drawing.Point(85,55)
$okButton.Size = New-Object System.Drawing.Size(50,25)
$okButton.Text = 'Yes'
$okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $okButton
$form.Controls.Add($okButton)

$cancelButton = New-Object System.Windows.Forms.Button
$cancelButton.Location = New-Object System.Drawing.Point(160,55)
$cancelButton.Size = New-Object System.Drawing.Size(50,25)
$cancelButton.Text = 'No'
$cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $cancelButton
$form.Controls.Add($cancelButton)

$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,60)
$label.AutoSize = $false
$label.TextAlign = [System.Drawing.ContentAlignment]::TopCenter
$label.Text = 'Would you like to retry selecting the installed KeeperFX Game executable?'
$form.Controls.Add($label)

$form.Topmost = $true
$form.ActiveControl = $okButton
$form.Add_Load({$form.Activate()})

$result = $form.ShowDialog()

if ($result -ne [System.Windows.Forms.DialogResult]::OK)
{
Write-Host "User aborted KeeperFX executable selection." -ForegroundColor Red
Write-Host "Restart VSCode to re-open file browser, OR enter them manually inside launch.json" -ForegroundColor Red
exit
}
else
{
Write-Host "Retrying..." -ForegroundColor DarkGray
continue fileLoop
}
}

# keeperfx exe filepath is validated by OpenFileDialog by default
$keeperFxExecutable = $FileBrowser.FileName.Replace('\', '/')
$doneSelectingFilepath = $true
}

Write-Host ('KeeperFX executable path: ' + "${keeperFxExecutable}") -ForegroundColor White

# generate launch.json from template, replacing "program", "cwd" and "sourceFileMap"
$programRegexReplace = '(\"program\"\s*:\s*\")(.*?)(\")'
$cwdRegexReplace = '(\"cwd\"\s*:\s*\")(.*?)(\")'
$sourceFileMapRegexReplace = '(\/\/)(\"sourceFileMap\"\s*:\s*{\s*\"\/mnt\/)(.*?)(\/\"\s*:\s*\")(.*?)(:\/\")'
Write-Host "Generating ${launchJsonFile}" -ForegroundColor DarkGray
$newLaunchFileContents = Get-Content ${templateLaunchFile} # read in template launch file
$newLaunchFileContents = ($newLaunchFileContents) -replace $programRegexReplace, ('$1{0}$3' -f "${keeperFxExecutable}") # replace "program" of new launch file
$newLaunchFileContents = ($newLaunchFileContents) -replace $cwdRegexReplace, ('$1{0}$3' -f (Split-Path -Path "${keeperFxExecutable}").Replace('\', '/')) # replace "cwd" of new launch file
$newLaunchFileContents = ($newLaunchFileContents) -replace $sourceFileMapRegexReplace, ('$2{0}$4{1}$6' -f "${driveLetterLower}", "${driveLetter}") # replace "sourceFileMap" of new launch file

[System.IO.File]::WriteAllLines( ${launchJsonFile}, $newLaunchFileContents) # write out new launch file
Write-Host ("launchJsonFile '$launchJsonFile' was created.") -ForegroundColor White
}
Loading

0 comments on commit c0cca07

Please sign in to comment.