xan1242 / NFS-XtendedInput

NFS (Black Box, MW & newer) - XInput Plugin
MIT License
101 stars 7 forks source link

Abstract controller icon modes & autogenerate them & add slots for custom icons #49

Open xan1242 opened 1 year ago

xan1242 commented 1 year ago

Abstract controller icons

Currently the hardcoded icons have to be manually put in the code due to the nature of hashes.

This step can be automated and abstracted to its own header file before compilation. It will ensure easier modification and/or expansion of the hardcoded controller icon pool.

Here's an example of one part of it being abstracted - TPK generation.

This is the first version of the script.

@echo off
:: TPK Generator for XNFSTPKTool
set ININAME=test.ini

ECHO [TPK]> %ININAME%
ECHO Name = XTENDEDINPUTBUTTONS>> %ININAME%
<nul (set/p nlv=Version = 4)>> %ININAME%
ECHO(>> %ININAME%
ECHO Filename = XtendedInputButtons>> %ININAME%
<nul (set/p nlv=FilenameHash = 0x)>> %ININAME%
strhash XtendedInputButtons>> %ININAME%
ECHO(>> %ININAME%
<nul (set/p nlv=Animations = 0)>> %ININAME%
ECHO(>> %ININAME%
ECHO(>> %ININAME%
FOR /R . %%T IN (*.dds) DO (
<nul (set/p nlv=[)>> %ININAME%
strhash %%~nT>> %ININAME%
ECHO ] >> %ININAME%
ECHO File = %%~dpnT.dds>> %ININAME%
ECHO Name = %%~nT>> %ININAME%
ECHO ClassNameHash = 0x1A93CF >> %ININAME%
ECHO ImageCompressionType = 0x24 >> %ININAME%
ECHO PaletteCompressionType = 0x0 >> %ININAME%
ECHO NumPaletteEntries = 0 >> %ININAME%
ECHO TilableUV = 0 >> %ININAME%
ECHO BiasLevel = 0 >> %ININAME%
ECHO RenderingOrder = 5 >> %ININAME%
ECHO ScrollType = 0 >> %ININAME%
ECHO UsedFlag = 0 >> %ININAME%
ECHO ApplyAlphaSorting = 0 >> %ININAME%
ECHO AlphaUsageType = 2 >> %ININAME%
ECHO AlphaBlendType = 1 >> %ININAME%
ECHO Flags = 0x0 >> %ININAME%
ECHO ScrollTimeStep = 0 >> %ININAME%
ECHO ScrollSpeedS = 0 >> %ININAME%
ECHO ScrollSpeedT = 0 >> %ININAME%
ECHO OffsetS = 0 >> %ININAME%
ECHO OffsetT = 256 >> %ININAME%
ECHO ScaleS = 256 >> %ININAME%
ECHO ScaleT = 0 >> %ININAME%
ECHO PixelFormatUnk1 = 0x1 >> %ININAME%
ECHO PixelFormatUnk2 = 0x5 >> %ININAME%
ECHO PixelFormatUnk3 = 0x6 >> %ININAME%
ECHO( >> %ININAME%
)

Add custom slots

This would ensure users can load their own custom controller TPKs without having to edit the existing hardcoded pool (and therefore no need to recompile the program).

So for each controller button there will be an appropriate slot that can be used. This will be based on the existing DualShock 2 references in the code.

Example: CUSTOM0_CROSS, CUSTOM0_CIRCLE, CUSTOM1_CROSS, CUSTOM1_CIRCLE, etc.