Command line arguments and command line help has been completely redone. Usage is now displayed in a more compact manner (<required> [optional]). A help message can now be displayed that shows the usage of all command line arguments. This same message has also been added to the README. DoScan now takes an argument of the class ScanOptions instead of all of its boolean arguments.
Added a few new command line options. The last three have also been added as checkboxes to the Launcher form. This implements issue #53.
-help - Shows a detailed help message and exits the program. This command can be detected in-place of the PATH and FILTER positional arguments.
-selectmodel - After the scan is finished, the first-loaded model will be selected.
-drawvram - After the scan is finished, all loaded textures will be drawn to VRAM.
-attachlimbs - Sets the default Auto Attach Limbs setting to true.
Some issues have also been fixed:
The last change to handle threading with Application.Run would set the auto event before Application.Run was called, meaning the form may not have been ready, even if it was already assigned. This could cause issues where InvokeRequired would return false when it should have returned true. To fix this, the auto events are now set in a HandleCreated event. Unfortunately this will add a slight delay to the start of scanning, since it needs to wait for the Preview form to show. :(
Logger is now correctly assigned before Program attempts to use it when complaining that the path is not a file or directory.
Preview form's GetSelectedTexture would return null when passing a non-null index if the selected count was zero. Now it will only check the selected count if index is null.
*.user was mistakenly left commented out when .gitignore was added. This has been uncommented.
Preview of launcher window with new checkboxes
![image](https://github.com/rickomax/psxprev/assets/9752430/17be4b65-8792-4492-9291-ebce34acb7a1)
Detailed explanation
Program
Program has been refactored to more cleanly handle command line arguments.
Added ScanOptions nested class that contains all boolean command line options. This class is passed as an argument to DoScan instead of passing a wall of booleans.
Boolean command line options are now stored under the ScanOptions _options field.
Added a DefaultFilter constant, that is now used in-place of all "*.*" strings.
Added PrintUsage to automatically print the usage information of PSXPrev.
Added PrintHelp to print the full help message detailing the usage of each argument.
Added TryParseHelp to parse the special -help command, which is allowed to be used in-place of positional arguments PATH and FILTER. Returns true on success.
Added TryParseOption to parse all other boolean command line options. Returns true on success.
Initialize
Refactored to work around using ScanOptions and the new -help command.
-help is now checked for in both positional arguments before trying to parse them.
Changed _waitForLauncherForm.Set() to be called inside the HandleCreated event. Doing this is imporant if the form is going to do anything involving InvokeRequired.
DoScan
Now takes 3 arguments, string path, string filter, and ScanOptions options.
Fixed Logger not being assigned before using it to print an error if the path was not found.
CheckAll is now handled by the ScanOptions class instead of manually handling this during DoScan. Technically this is slightly less performant, but it's only called 10 times.
Changed _waitForPreviewForm.Set() to be called inside the HandleCreated event. Doing this is imporant if the form is going to do anything involving InvokeRequired. Unfortunately this will also delay the scan from starting until the Preview Form is ready, I'm not sure of a better way of handling this.
Added handling for setting the default Auto Attach Limbs setting before beginning the scan.
Added handling for selecting the first model and drawing all textures to VRAM after the scan is complete.
LauncherForm
Added checkboxes for Select First Model, Draw All to VRAM, and Auto Attach Limbs below the other Options checkboxes.
PreviewForm
Added SetAutoAttachLimbs function to set default setting for Auto Attached Limbs checkbox.
Added SelectFirstEntity function to select the first node in the entitiesTreeView tree view.
Added DrawAllTexturesToVRAM function to draw all textures in _textures to VRAM.
Added DrawTextureToVRAM helper function for drawing a single texture to VRAM to avoid code duplication.
drawToVRAMButton_Click and DrawAllTexturesToVRAM both use this function.
GetSelectedTexture
Fixed issue where function wouldn't return the texture (due to no selection) even if a non-null index was passed.
Short explanation
Command line arguments and command line help has been completely redone. Usage is now displayed in a more compact manner (
<required> [optional]
). A help message can now be displayed that shows the usage of all command line arguments. This same message has also been added to the README.DoScan
now takes an argument of the classScanOptions
instead of all of its boolean arguments.Added a few new command line options. The last three have also been added as checkboxes to the Launcher form. This implements issue #53.
-help
- Shows a detailed help message and exits the program. This command can be detected in-place of thePATH
andFILTER
positional arguments.-selectmodel
- After the scan is finished, the first-loaded model will be selected.-drawvram
- After the scan is finished, all loaded textures will be drawn to VRAM.-attachlimbs
- Sets the default Auto Attach Limbs setting to true.Some issues have also been fixed:
The last change to handle threading with
Application.Run
would set the auto event beforeApplication.Run
was called, meaning the form may not have been ready, even if it was already assigned. This could cause issues whereInvokeRequired
would return false when it should have returned true. To fix this, the auto events are now set in aHandleCreated
event. Unfortunately this will add a slight delay to the start of scanning, since it needs to wait for the Preview form to show. :(Logger
is now correctly assigned before Program attempts to use it when complaining that the path is not a file or directory.Preview form's
GetSelectedTexture
would return null when passing a non-nullindex
if the selected count was zero. Now it will only check the selected count ifindex
is null.*.user
was mistakenly left commented out when.gitignore
was added. This has been uncommented.Preview of launcher window with new checkboxes
![image](https://github.com/rickomax/psxprev/assets/9752430/17be4b65-8792-4492-9291-ebce34acb7a1)Detailed explanation
Program
ScanOptions
nested class that contains all boolean command line options. This class is passed as an argument toDoScan
instead of passing a wall of booleans.ScanOptions _options
field.DefaultFilter
constant, that is now used in-place of all"*.*"
strings.PrintUsage
to automatically print the usage information of PSXPrev.PrintHelp
to print the full help message detailing the usage of each argument.TryParseHelp
to parse the special-help
command, which is allowed to be used in-place of positional argumentsPATH
andFILTER
. Returns true on success.TryParseOption
to parse all other boolean command line options. Returns true on success.Initialize
ScanOptions
and the new-help
command.-help
is now checked for in both positional arguments before trying to parse them._waitForLauncherForm.Set()
to be called inside theHandleCreated
event. Doing this is imporant if the form is going to do anything involvingInvokeRequired
.DoScan
string path
,string filter
, andScanOptions options
.Logger
not being assigned before using it to print an error if the path was not found.CheckAll
is now handled by theScanOptions
class instead of manually handling this duringDoScan
. Technically this is slightly less performant, but it's only called 10 times._waitForPreviewForm.Set()
to be called inside theHandleCreated
event. Doing this is imporant if the form is going to do anything involvingInvokeRequired
. Unfortunately this will also delay the scan from starting until the Preview Form is ready, I'm not sure of a better way of handling this.LauncherForm
PreviewForm
SetAutoAttachLimbs
function to set default setting for Auto Attached Limbs checkbox.SelectFirstEntity
function to select the first node in theentitiesTreeView
tree view.DrawAllTexturesToVRAM
function to draw all textures in_textures
to VRAM.DrawTextureToVRAM
helper function for drawing a single texture to VRAM to avoid code duplication.drawToVRAMButton_Click
andDrawAllTexturesToVRAM
both use this function.GetSelectedTexture
index
was passed.