Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/settings cli #282

Draft
wants to merge 69 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
58ff74b
build: add publishing profiles
BinToss Jan 5, 2022
6f9868c
ci(release): change RID to a matrix variable for win-x86, win-x64
BinToss Jan 9, 2022
ebbebb4
ci:(release): de-ref CSPROJ_RELPATH via workflow syntax instead of Po…
BinToss Jan 9, 2022
ee202e4
ci(release): trim comments and empty lines for Dotnet block
BinToss Jan 9, 2022
909c4d8
ci(release): set Target Framework to net6.0-windows
BinToss Jan 9, 2022
ae54b9d
ci(release): change path of packaged Publish artifacts
BinToss Jan 9, 2022
62fef9b
build: IncludeNativeLibrariesForSelfExtract
BinToss Jan 9, 2022
b81b70a
build: EnableCompressionInSingleFile
BinToss Jan 9, 2022
b1ca4a0
build: if undefined, set RuntimeIdentifier to win-x64
BinToss Jan 9, 2022
948d8f8
build: explicitly enable SelfContained
BinToss Jan 9, 2022
20ddf0c
build: enable isTrimmable
BinToss Jan 9, 2022
ce61dfc
Merge branch 'singlefile' into develop
BinToss Jan 9, 2022
b31efb9
fix: replace WMI for filesystem compression with DotNet functionality
BinToss Jan 9, 2022
929c51e
chore(vscode): add markdown rules
BinToss Jan 9, 2022
0a8ab77
docs(readme): add Requirements
BinToss Jan 9, 2022
2c21150
feat: Add CLI alternative to Positions GUI
BinToss Feb 14, 2022
0f7825b
fix: support targeting NETFX 4.6.2, 4.8.0
BinToss Feb 14, 2022
0bd3125
fix: remove/replace WinForms references
BinToss Feb 20, 2022
1ed397f
build: simplify GitVersion prebuild script
BinToss Feb 20, 2022
40fed6b
style: add end-of-file newline
BinToss Feb 20, 2022
ee1f6f5
build: change CPU arch conditions from Equals to Contains
BinToss Feb 20, 2022
c6006af
build: set satellite resource langs to en-us
BinToss Feb 20, 2022
881e50f
build: enable InvariantGlobalization
BinToss Feb 20, 2022
2302717
build: set custom var `Win7SF` if SDK version is 6.0.300 or greater
BinToss Feb 20, 2022
35c25b6
build: only allow PublishSingleFile with Win7 if Win7SF is True
BinToss Feb 20, 2022
505c511
build: do not publish Release symbols
BinToss Feb 20, 2022
757790c
build: move publish-related props and conditions
BinToss Feb 20, 2022
0fddbba
style: fix indentation
BinToss Feb 20, 2022
06a5490
style: set charset to UTF-8 BOM
BinToss Feb 20, 2022
cacc0e2
refactor: remove unnecessary using System.Reflection
BinToss Feb 20, 2022
fe6773b
fix: add using System.Linq
BinToss Feb 20, 2022
3fffced
feat: add --cli arg
BinToss Feb 20, 2022
9c44fb0
refactor: move NewLine appendix in Exception output
BinToss Feb 20, 2022
417b217
refactor: change input prompt for --infer
BinToss Feb 20, 2022
135921b
refactor: use Exit.WithCode() instead of Exit()
BinToss Feb 20, 2022
4f54a0b
fix: re-throw exceptions during --test
BinToss Feb 20, 2022
292d67f
style: sort usings
BinToss Feb 20, 2022
cee28c7
docs: add TODO regarding --silent
BinToss Feb 20, 2022
251136e
refactor: add const string ExceptionHeader
BinToss Feb 20, 2022
73bee93
style: fix indentation
BinToss Feb 20, 2022
6e68934
refactor: add Results list for returning result type and message
BinToss Feb 20, 2022
b33daa8
refactor: consolidate Process' error output
BinToss Feb 20, 2022
b40915b
refactor: add class `ResultAndType`
BinToss Feb 20, 2022
89f00bf
docs: update Infer()'s summary
BinToss Feb 20, 2022
5f5323e
refactor: move process matching from Infer() to DeeperCheck()
BinToss Feb 20, 2022
e7c3076
refactor: set Process to static
BinToss Feb 20, 2022
13fe9c4
refactor: combine Result and ResultAndType
BinToss Feb 20, 2022
76dfafb
refactor: add LastResult for random access and returned values
BinToss Feb 20, 2022
9f26d75
refactor: move Halo PC workload to InspectHPC()
BinToss Feb 20, 2022
f099197
refactor: move MCC workload to InspectMCC()
BinToss Feb 20, 2022
4e76bcf
refactor: set LastResult members in Infer()
BinToss Feb 20, 2022
a6258ad
refactor: remove unused Results list
BinToss Feb 20, 2022
aecf6e1
docs: add summary of DeeperCheck's switch statement
BinToss Feb 20, 2022
a891134
feat: add InferResult()
BinToss Feb 20, 2022
38f09eb
Merge branch 'feat/HXE.Process.InferResult()' into develop
BinToss Feb 20, 2022
d835abe
docs: add summary and return docs to InferResult()
BinToss Feb 20, 2022
420a295
docs: remove old TODO note
BinToss Feb 20, 2022
4ba3e57
style: add end-of-file newline
BinToss Feb 20, 2022
6a43e97
style: format document
BinToss Feb 20, 2022
56fe482
refactor: remove unused using
BinToss Feb 20, 2022
3109533
style: convert indentation to Tabs
BinToss Feb 20, 2022
92de665
refactor: move members from Settings to SettingsCore
BinToss Feb 20, 2022
83f08e1
refactor: simplify Mode/SelectedIndex switches
BinToss Feb 20, 2022
6666260
refactor: close Settings window instead of hiding it
BinToss Feb 20, 2022
b70d7df
docs: update Copyright
BinToss Feb 20, 2022
7ab6c60
build: add/rename Publish profiles
BinToss Feb 20, 2022
3a0e336
Merge branch 'refactor/SettingsCore' into develop
BinToss Feb 20, 2022
6fac0c1
feat: add unfinished Settings CLI
BinToss Feb 20, 2022
8d0db9f
feat: allow Settings CLI to be invokable via `hxe.exe --config --cli`
BinToss Feb 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ jobs:
name: Build
runs-on: windows-latest
env:
RID: "win-x86"
TFM: "net5.0-windows"
TFM: "net6.0-windows"
ASSEMBLYNAME: "HXE"
PROJPATH: "./src/HXE.csproj"
strategy:
fail-fast: false
matrix:
RID: [ "win-x86", "win-x64" ]

steps:
################
Expand All @@ -37,31 +40,28 @@ jobs:
- run: npm install
# Dependents: Semantic Release

# Authenticates packages to push to GPR
- uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.x" # SDK Version to use.
dotnet-version: "6.0.x"
include-prerelease: true

- name: Add GitHub Package Repository
run: dotnet nuget add source https://nuget.pkg.github.com/HaloSPV3/index.json -n "github" -u USERNAME -p ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text

- name: Set NuGet.org Credentials
run: dotnet nuget update source "nuget.org" -u USERNAME -p ${{ secrets.NUGET_TOKEN }} --store-password-in-clear-text

################
# BUILD
################
- name: dotnet-publish
run: dotnet publish $env:CSPROJ_RELPATH -c Release --no-self-contained -p:ContinuousIntegrationBuild=true
run: dotnet publish ${{ env.CSPROJ_RELPATH }} -c Release -t ${{ env.TFM }} --RID ${{ matrix.RID }} -p:ContinuousIntegrationBuild=true

# required variables: TargetFramework, RuntimeIdentifier, GitVersion_FullSemVer
- name: Compress-PublishArtifacts
run: |
$publishPath = Resolve-Path ".\bin\Release\$env:TFM\$env:RID\publish";
$archiveName = "$env:ASSEMBLYNAME.$env:TFM-$env:RID.$env:GitVersion_FullSemVer.zip";
Set-Location $publishPath;
Compress-Archive -Path $publishPath -DestinationPath $archiveName -CompressionLevel Optimal;
Compress-Archive -Path $publishPath -DestinationPath ${{ github.workspace }}\bin\Release\publish\$archiveName -CompressionLevel Optimal;

################
# RELEASE
Expand All @@ -77,7 +77,7 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: publish-artifacts
path: bin/Release/${{ env.TFM }}/${{ env.RID }}/publish
path: bin/Release/publish

- name: Publish to GitHub Packages
working-directory: bin/Release
Expand Down
2 changes: 1 addition & 1 deletion .releaserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
['@semantic-release/github',
{
"assets": [
{"path": "bin/release/win-x64/publish"}
{"path": "bin/release/publish"}
]
}
]
Expand Down
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,11 @@
"conv-pr", // Conventional Pull Request config
"commitizen",
"pull-requests" // pull requests workflow
]
],
"markdownlint.config": {
"MD028": false,
"MD025": {
"front_matter_title": ""
}
}
}
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,30 @@ The USAGE document goes into detail on how to use HXE. In a nutshell:

# configure the kernel
.\hxe.exe -config

# Requirements

## Operating System

| Minimum | Recommended
| ---------------------------------------- | -----------
| Windows 7 SP1 32-bit (w/ addl. software) | Windows 10 64-bit

## .NET 6.0

Because HXE is built on the relatively new .NET 6, you may need to download the [.NET 6.0 Desktop Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) for this app to work. Hopefully, this will be distributed via Windows Updates to Windows 10 and Windows 11 sooner rather than later.
For 64-bit PCs: [Dotnet Runtime (Desktop) 6.0.1 Windows x64 Installer](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-desktop-6.0.1-windows-x64-installer)
For 32-bit PCs: [Dotnet Runtime (Desktop) 6.0.1 Windows x86 Installer](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-desktop-6.0.1-windows-x86-installer)

### Windows 7/8.1

Additional software dependencies to be installed for this .NET-based app to work on Windows 8.1 and Windows 7
Read the [Microsoft docs](https://docs.microsoft.com/en-us/dotnet/core/install/windows?tabs=net60#additional-deps) to learn what you need and how to get it.

## Note: Upgrading To Windows 10

Using the [Windows Installation Media Creation Tool](https://www.microsoft.com/en-us/software-download/windows10?36261b60-2f68-4336-abe2-4b00f210b6aa=True), you can still upgrade to Windows 10 with your Windows 7/8/8.1 license.
HOWEVER...

- If your hardware distributor does not make Windows 10 drivers for your hardware, you may have a worse Windows 10 experience than expected.
- Some drivers made for earlier Windows releases may work on Windows 10; some won't. You won't know until you try.
53 changes: 10 additions & 43 deletions src/.msb.prebuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,59 +8,26 @@

function prebuild
{
$minVer_isShallow = [version]'2.15.0.0';
$minVer_unshallow = [version]'2.1.4.0';
$gitBinVer = "";
$isShallow = $true;

# 0. Announce
Write-Host "0. GitVersion cannot determine the next version in shallow reposistories.`n",
"`tWe will use Git to determine if the current repository needs to be un-shallowed.`n",
"Checking if Git is available...";
# Announce
Write-Host "GitVersion requires unshallow repositories.`n",
"We will use Git to determine if the current repository needs to be un-shallowed.";

# 1. Ensure Git is available
try
{
Write-Host "1. Git was found.`n",
"It is $(git --version) at...`n",
(Get-Command -Name git).path

$gitBinVer = [version]('{2}.{3}.{4}.{6}' -f (git --version).split(' ').split('.'))
}
catch
{
Write-Error "Git is not installed or it is not in PATH!";
throw
}

# 2. Check if the repository is shallow
Write-Host "2. Checking if repository is shallow..."
if ($gitBinVer -gt $minVer_isShallow) # GitVersion >= 2.15.0.0
{
$isShallow = git rev-parse --is-shallow-repository
}
else
{
Write-Debug "Git Version less than 2.15.0.0"
$isShallow = Test-Path (Join-Path $GitStatus.GitDir shallow)
}
# Check if the repository is shallow
Write-Host "Checking if repository is shallow..."
$isShallow = git rev-parse --is-shallow-repository

# 3. If the repository is shallow, then unshallow
# If the repository is shallow, then unshallow
if ($isShallow -eq $true)
{
Write-Host "3. Repository is shallow. Fetching full history..."
if ($gitBinVer -lt $minVer_unshallow) # GitVersion < 2.1.4.0 (exact version unknown)
{
git fetch --depth=0;
}
else {
git fetch --unshallow
}
Write-Warning "Repository is shallow. Fetching full history..."
git fetch --unshallow
Write-Host "Fetch Completed. Proceeding to Build...`n"
}
else
{
Write-Host "3. Repository is complete. Proceeding to Build..."
Write-Host "Repository is complete. Proceeding to Build..."
}
}

Expand Down
157 changes: 157 additions & 0 deletions src/CLI/Positions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/**
* Copyright (c) 2022 Noah Sherwin
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/

using System;
using System.IO;

namespace HXE.CLI
{
public static class Positions
{
public static void Run(string source = null, string target = null)
{
Console.Info("Read the file \"OS_Settings.User.xml\" and write its weapons positions to a .bin file.");
FileInfo fiSource = null;
FileInfo fiTarget = null;

while (fiSource == null)
{
try
{
fiSource = GetSource();
}
catch (Exception e)
{
Console.Error(e.ToString());
}
}

while (fiTarget == null)
{
try
{
fiTarget = GetTarget();
}
catch (Exception e)
{
Console.Error(e.ToString());
}
}

try
{
Save(fiSource, fiTarget);
}
catch (Exception e)
{
Console.Error(e.ToString());
}


}

private static FileInfo GetSource(string source = null)
{
FileInfo fileInfo = null;

Console.Info("Full path of OS_Settings.User.xml:");

if (source == null)
{
string input = System.Console.In.ReadLine();

if (string.IsNullOrWhiteSpace(input))
{
throw new NullReferenceException("The supplied path was null, empty, or whitespace.");
}

fileInfo = new FileInfo(Path.GetFullPath(input));
}
else
{
Console.Info(source);
fileInfo = new FileInfo(Path.GetFullPath(source));
}

if (!fileInfo.Exists)
{
throw new FileNotFoundException($"The file {fileInfo.Name} was not found.");
}

if (fileInfo.Name != "OS_Settings.User.xml")
{
throw new ArgumentException("The provided file is not OS_Settings.User.xml.");
}

return fileInfo;
}

private static FileInfo GetTarget(string target = null)
{
FileInfo fileInfo;

Console.Info("Full path of target/output .bin file:");

if (target == null)
{
string input = System.Console.In.ReadLine();

if (string.IsNullOrWhiteSpace(input))
{
throw new NullReferenceException("The supplied path was null, empty, or whitespace.");
}

fileInfo = new FileInfo(Path.GetFullPath(input));
}
else
{
Console.Info(target);
fileInfo = new FileInfo(Path.GetFullPath(target));
}

if (!fileInfo.Exists)
{
throw new FileNotFoundException($"The file {fileInfo.Name} was not found.");
}

if (!fileInfo.Extension.EndsWith("bin"))
{
throw new ArgumentException("The provided file lacks the .bin extension.");
}

return fileInfo;

}

private static void Save(FileInfo source, FileInfo target)
{
Console.Info("Saving weapon positions...");

var openSauce = (OpenSauce) source.FullName;

openSauce.Load();
openSauce.Objects.Weapon.Save(target.FullName);
openSauce.Objects.Weapon.Load(target.FullName);

foreach (var position in openSauce.Objects.Weapon.Positions)
Console.Debug($"Weapon: {position.Name} | I/J/K: {position.Position.I}/{position.Position.J}/{position.Position.K}");
}
}
}
Loading