mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Compare commits
18 Commits
main
...
feature-mu
Author | SHA1 | Date | |
---|---|---|---|
7406fa613b | |||
7b9ed99325 | |||
e069f85e56 | |||
2f2b6fb692 | |||
169f2e9bf1 | |||
eb033113b3 | |||
227c259e51 | |||
fc6820d73b | |||
9dc98a6f9d | |||
35fce78616 | |||
84611a26e8 | |||
a61a2b81a1 | |||
e37cf03f7b | |||
e6288942ea | |||
62bdd151e1 | |||
f5af8a4d53 | |||
df95601416 | |||
596675ad8d |
23
.github/workflows/ff-release.yml
vendored
23
.github/workflows/ff-release.yml
vendored
@ -1,23 +0,0 @@
|
||||
name: Fast-Forward Release Branch
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
fast-forward:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
ref: release
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Merge into Release
|
||||
run: git merge ${{github.ref_name}} --ff-only
|
||||
|
||||
- name: Push Changes
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: release
|
142
.github/workflows/ksp-publish.yml
vendored
142
.github/workflows/ksp-publish.yml
vendored
@ -1,142 +0,0 @@
|
||||
name: Build and Release
|
||||
on: [ push ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Setup .NET Core SDK
|
||||
uses: actions/setup-dotnet@v4.0.0
|
||||
with:
|
||||
dotnet-version: '6.0.x'
|
||||
|
||||
- name: Install Python Tools
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install yaclog yaclog-ksp
|
||||
|
||||
- name: Generate Version Info
|
||||
run: |
|
||||
yaclog show
|
||||
python Scripts/version.py
|
||||
yaclog-ksp -n "Conformal Decals"
|
||||
|
||||
- name: Validate Version Info
|
||||
uses: DasSkelett/AVC-VersionFileValidator@master
|
||||
|
||||
- name: Download DLL Dependencies
|
||||
working-directory: Source
|
||||
run: |
|
||||
wget --user drewcassidy --password ${{ secrets.PILE_OF_ROCKS_PASS }} https://pileof.rocks/Secret/conformal-decals-dependencies-1.zip
|
||||
unzip conformal-decals-dependencies-*.zip -d ConformalDecals/dlls
|
||||
|
||||
- name: Build DLL
|
||||
working-directory: Source
|
||||
run: |
|
||||
mkdir -p ../GameData/ConformalDecals/Plugins
|
||||
dotnet build --configuration Release ConformalDecals.sln
|
||||
|
||||
- name: Download KSP Dependencies
|
||||
run: |
|
||||
wget https://pileof.rocks/KSP/Shabby_v0.3.0.zip
|
||||
wget https://ksp.sarbian.com/jenkins/job/ModuleManager/161/artifact/ModuleManager.4.2.1.dll
|
||||
wget https://github.com/blowfishpro/B9PartSwitch/releases/download/v2.19.0/B9PartSwitch_v2.19.0.zip
|
||||
wget https://github.com/KSPModdingLibs/HarmonyKSP/releases/download/2.0.4.0/HarmonyKSP_2.0.4.0_for_KSP1.8+.zip
|
||||
unzip -d Shabby Shabby*.zip
|
||||
unzip -d B9PartSwitch B9PartSwitch*.zip
|
||||
unzip -d HarmonyKSP HarmonyKSP*.zip
|
||||
mv Shabby/GameData/Shabby GameData/
|
||||
mv ModuleManager*.dll GameData/
|
||||
mv B9PartSwitch/GameData/B9PartSwitch GameData/
|
||||
mv HarmonyKSP/GameData/000_Harmony GameData/
|
||||
|
||||
- name: Upload Unbundled Build
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ConformalDecals-unbundled
|
||||
path: |
|
||||
GameData/ConformalDecals/
|
||||
README.md
|
||||
CHANGELOG.md
|
||||
LICENSE-ART.md
|
||||
LICENSE-SOURCE.md
|
||||
|
||||
- name: Upload Bundled Build
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ConformalDecals
|
||||
path: |
|
||||
GameData/
|
||||
README.md
|
||||
CHANGELOG.md
|
||||
LICENSE-ART.md
|
||||
LICENSE-SOURCE.md
|
||||
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Install Python Tools
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install yaclog
|
||||
|
||||
- name: Get version name and body
|
||||
run: |
|
||||
echo "VERSION_TITLE=$(yaclog show -n)" >> $GITHUB_ENV
|
||||
yaclog show
|
||||
|
||||
- name: Download Build Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
|
||||
- name: Zip Download Packages
|
||||
run: |
|
||||
set -u
|
||||
mkdir bundled
|
||||
mkdir unbundled
|
||||
zip -r bundled/ConformalDecals-$VERSION_TITLE.zip ConformalDecals/*
|
||||
zip -r unbundled/ConformalDecals-$VERSION_TITLE.zip ConformalDecals-unbundled/*
|
||||
ls
|
||||
|
||||
- name: Publish to Spacedock
|
||||
run: |
|
||||
set -u
|
||||
curl -F "username=drewcassidy" -F "password=${{ secrets.SPACEDOCK_PASS }}" \
|
||||
-c ./cookies "https://spacedock.info/api/login"
|
||||
curl -c ./cookies -b ./cookies \
|
||||
-F "version=$VERSION_TITLE" \
|
||||
-F "changelog=$(yaclog show -mb)" \
|
||||
-F "game-version=1.12.5" \
|
||||
-F "notify-followers=yes" \
|
||||
-F "zipball=@bundled/ConformalDecals-$VERSION_TITLE.zip" \
|
||||
"https://spacedock.info/api/mod/2451/update"
|
||||
|
||||
- name: Publish to Github
|
||||
run: |
|
||||
set -u
|
||||
gh release create ${{ github.ref_name }} \
|
||||
--notes "$(yaclog show -mb)" \
|
||||
--title "Conformal Decals $VERSION_TITLE" \
|
||||
bundled/ConformalDecals-*.zip \
|
||||
ConformalDecals/GameData/ConformalDecals/Versioning/ConformalDecals.version
|
||||
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -16,9 +16,6 @@ Temp/
|
||||
GameData/ConformalDecals/Resources/Resources
|
||||
GameData/ConformalDecals/Resources/*.manifest
|
||||
|
||||
# DLLs
|
||||
GameData/ConformalDecals/Plugins
|
||||
|
||||
# Unity Project Files
|
||||
PartTools.cfg
|
||||
*.meta
|
||||
@ -52,6 +49,7 @@ Source/ConformalDecals/bin
|
||||
.ds_store
|
||||
*.sublime*
|
||||
.idea
|
||||
.vs
|
||||
obj
|
||||
*.swp
|
||||
@thumbs
|
||||
Source/.editorconfig
|
||||
|
1
.ksp_deploy_config.yml
Normal file
1
.ksp_deploy_config.yml
Normal file
@ -0,0 +1 @@
|
||||
USE_SSM_CREDENTIALS: false
|
30
.mod_data.yml
Normal file
30
.mod_data.yml
Normal file
@ -0,0 +1,30 @@
|
||||
# Example annotated build data file
|
||||
mod-name: ConformalDecals
|
||||
package:
|
||||
include-dependencies: true # Include dependencies in the package
|
||||
included-gamedata: # Include these gamedata-level folders in packages:
|
||||
- ConformalDecals
|
||||
included-support: # Include these root-level files in packages
|
||||
- README.md
|
||||
- LICENSE-ART.md
|
||||
- LICENSE-SOURCE.md
|
||||
- changelog.txt
|
||||
dependencies: # Configure dependencies
|
||||
ModuleManager:
|
||||
location: url
|
||||
url: https://ksp.sarbian.com/jenkins/job/ModuleManager/159/artifact/ModuleManager.4.1.4.dll
|
||||
zip: false
|
||||
B9PartSwitch:
|
||||
location: url
|
||||
url: http://pileof.rocks/KSP/B9PartSwitch-v2.16.0.zip
|
||||
zip: true
|
||||
Shabby:
|
||||
location: url
|
||||
url: http://taniwha.org/~bill/Shabby_v0.1.2.zip
|
||||
zip: true
|
||||
deploy:
|
||||
SpaceDock:
|
||||
enabled: true # activate/deactivate this deployment script
|
||||
mod-id: 2451 # The Spacedock mod ID for deployment
|
||||
GitHub:
|
||||
enabled: true # activate/deactivate this deployment script
|
25
.travis.yml
Normal file
25
.travis.yml
Normal file
@ -0,0 +1,25 @@
|
||||
language: python
|
||||
python:
|
||||
- 3.6
|
||||
before_install:
|
||||
- echo -e "machine github.com\n login $GITHUB_OAUTH_TOKEN" > ~/.netrc
|
||||
install:
|
||||
- pip install awscli boto3 requests
|
||||
branches:
|
||||
only:
|
||||
- release
|
||||
script:
|
||||
- git clone https://github.com/post-kerbin-mining-corporation/build-deploy.git
|
||||
- cd build-deploy
|
||||
- git checkout master
|
||||
- cd ..
|
||||
- pytest -s --testpath "GameData/" build-deploy/src/tests/ # run the deploy tests
|
||||
- python build-deploy/src/package.py --f ".mod_data.yml" # Build package
|
||||
before_deploy:
|
||||
- python build-deploy/src/stage.py --f ".mod_data.yml" # Run the staging script
|
||||
deploy:
|
||||
- provider: script
|
||||
script: python build-deploy/src/deploy.py --f ".mod_data.yml" # Deploy package to spacedock, curse, github
|
||||
skip_cleanup: true
|
||||
on:
|
||||
branch: release
|
@ -30,8 +30,6 @@ public class TextRenderTest : MonoBehaviour {
|
||||
Debug.Log("starting...");
|
||||
|
||||
StartCoroutine(OnRender());
|
||||
var thing = new GameObject();
|
||||
thing.AddComponent<TextMeshPro>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
@ -104,5 +104,8 @@
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// shadow casting support
|
||||
UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
|
||||
}
|
||||
}
|
@ -105,5 +105,8 @@
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// shadow casting support
|
||||
UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
|
||||
}
|
||||
}
|
229
CHANGELOG.md
229
CHANGELOG.md
@ -1,229 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file
|
||||
|
||||
| modName | Conformal Decals |
|
||||
| ------- |:-------------------------------------------------------------------------------------|
|
||||
| license | CC-By-SA & GPL3 |
|
||||
| website | https://forum.kerbalspaceprogram.com/index.php?/topic/194802-18-111-conformal-decals |
|
||||
| author | Andrew Cassidy |
|
||||
|
||||
## 0.2.14 - 2024-06-25
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed parts showing as all black with the Deferred Rendering mod
|
||||
|
||||
|
||||
## 0.2.13 - 2024-05-17
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed flag decals sometimes not respecting image aspect ratio
|
||||
|
||||
|
||||
## 0.2.12 - 2022-10-31
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated bundled Shabby to 0.3.0. Does not affect CKAN users
|
||||
- Made flag aspect ratio overrides configurable with `ASPECTRATIO` nodes in the config. User flags added to Squad/Flags should now be the correct aspect ratio
|
||||
- All decal aspect ratios can now be overriden with the `aspectRatio` field
|
||||
|
||||
### Fixed
|
||||
|
||||
- Reverted some changes from last version that were causing issues on launch
|
||||
|
||||
|
||||
## 0.2.11 - 2022-10-30
|
||||
|
||||
### Fixed
|
||||
|
||||
- PR by LinuxGuruGamer:
|
||||
- Fixed nullref caused when an entry in `_targets` was null
|
||||
- Fixed memory leak caused by the OnDestroy() methods not being called due to them being virtual
|
||||
|
||||
|
||||
## 0.2.10 - 2022-03-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed decals not projecting on loading prefabs
|
||||
|
||||
### Changed
|
||||
|
||||
- Re-enabled projecting onto TransparentFX layer
|
||||
|
||||
### Added
|
||||
|
||||
- Allowed for regular expressions to be used when blacklisting shaders
|
||||
- Added all Waterfall shaders to the shader blacklist when Waterfall is present
|
||||
|
||||
|
||||
## 0.2.9 - 2022-03-12
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed text decals breaking when used in symmetry
|
||||
- Fixed decals projecting onto the TransparentFX layer, such as Waterfall plumes
|
||||
|
||||
|
||||
## 0.2.8
|
||||
|
||||
- Update bundled Shabby to support Harmony 2 for compatibility with other mods
|
||||
- Update bundled B9PartSwitch to 2.18.0
|
||||
|
||||
|
||||
## 0.2.7
|
||||
|
||||
- Supported KSP versions: 1.8.x to 1.11.x
|
||||
|
||||
### Notes:
|
||||
|
||||
- Attaching decal parts in flight using engineer kerbals is not supported.
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed certain non-ascii strings not rendering correctly under certain circumstances.
|
||||
- Yet another attempted fix for the planet text glitch.
|
||||
|
||||
|
||||
## 0.2.6
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed stock flags appearing stretched by forcing their aspect ratio to be correct.
|
||||
- Another attempted fix for the planet text glitch.
|
||||
|
||||
|
||||
## 0.2.5
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed line spacing, character spacing, and vertical settings not applying to symmetry counterparts
|
||||
|
||||
|
||||
## 0.2.4
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed red text appearing on planets due to KSP bug by clearing render textures afterwards.
|
||||
- Fixed fonts not saving correctly.
|
||||
|
||||
### Changed:
|
||||
|
||||
- Lowered step size for decal size and depth to 1cm.
|
||||
- Changed default max size to 5m.
|
||||
- Changed default text decal size to 0.2m
|
||||
- Text decals now show as a circle if they contain only whitespace.
|
||||
|
||||
|
||||
## 0.2.3
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed TMP subobjects being deleted, causing fallback fonts to fail in some situations.
|
||||
- Started using URL-style encoding for text decals behind the scenes to prevent issues with certain characters.
|
||||
- Fixed text decals having zero size when they had only whitespace or an empty string.
|
||||
- Fixed decals having drag and causing issues when using FAR.
|
||||
- Fixed broken saving of text decals in certain circumstances.
|
||||
|
||||
|
||||
## 0.2.2
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed corrupted text rendering when a vessel loads during a scene change.
|
||||
|
||||
|
||||
## 0.2.1
|
||||
|
||||
### Changed:
|
||||
|
||||
- Pressing enter in the text entry window now types a newline.
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Renamed font assetbundle. The old extension was causing the game to try to load it twice on Windows due to legacy compatability features.
|
||||
- Fixed text rendering on DirectX resulting in black boxes by using ARGB32 instead of RG16 for the render texture in DirectX.
|
||||
|
||||
|
||||
## 0.2.0
|
||||
|
||||
### New Parts:
|
||||
|
||||
- CDL-3 Surface Base Decal: A set of conformal decals based on the symbols from the movie Moon (2009) designed by Gavin Rothery
|
||||
- CDL-T Custom Text Decal: A customizable text decal with a variety of fonts
|
||||
|
||||
### Changed:
|
||||
|
||||
- New ModuleConformalText module for customizable text
|
||||
- Text, font, and style can all be customized, as well as text fill and outline colors and widths
|
||||
- Same projection and opacity options as other conformal decals
|
||||
- New StandardText decal shader supporting the text module
|
||||
- Unified all decal shaders into a single "StandardDecal" shader with variants supporting any combination of bump, specular and emissive maps, plus SDF alphas.
|
||||
- Old shaders are remapped to Standard shader plus keywords automatically.
|
||||
- New SDF-based antialiasing for when decals extend to their borders, e.g. on opaque flags.
|
||||
- New "KEYWORD" material modifier, allowing for shader features to be enabled and disabled.
|
||||
- Material modifiers can now be removed in variants by setting `remove = true` inside them.
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed WIDTH and HEIGHT scale modes being flipped
|
||||
- Removed some debug log statements
|
||||
- Dependencies:
|
||||
- Updated ModuleManager to version 4.1.4
|
||||
|
||||
|
||||
## 0.1.4
|
||||
|
||||
Supported KSP versions: 1.8.x to 1.10.x
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed decals rendering onto disabled B9PS part variants
|
||||
- Decals will still not update whan their parent part's B9PS variant is changed, both in flight and in the editor. This is known and awaiting a change to B9PS to be fixed.
|
||||
- Fixed decal bounds rendering as dark cubes when shadowed by EVE clouds.
|
||||
- Fixed decals being shadowed by EVE clouds, causing the part underneath to appear overly dark.
|
||||
|
||||
|
||||
## 0.1.3
|
||||
|
||||
### Fixe:
|
||||
|
||||
- Fixed decals being able to be scaled down to 0
|
||||
|
||||
### Changed:
|
||||
|
||||
- Made decal bounds no longer collide in flight, this is done by repurposing layer 31 (which is configurable in the ConformalDecals.cfg file)
|
||||
- Decals will now be unselectable in flight by default. This can be disabled with the `selectableInFlight` value in ConformalDecals.cfg, or in the module config itself.
|
||||
- Decal parts will now destroy themselves automatically when the parent part is destroyed
|
||||
- Small refactor of node parsing code
|
||||
- Colors can now be specified in hex (#RGB, #RGBA, #RRGGBB, or #RRGGBBAA) or using the colors specified in the XKCDColors class
|
||||
|
||||
|
||||
## 0.1.2
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Disabled writing to the zbuffer in the decal bounds shader. Should fix any issues with Scatterer or EVE.
|
||||
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed flag decal not adjusting to new texture sizes immediately.
|
||||
- Fixed decal bounds being visible on launch.
|
||||
- Fixed decal bounds being visible in the part icon.
|
||||
|
||||
|
||||
## 0.1.0
|
||||
|
||||
Initial release!
|
||||
|
||||
### New Parts:
|
||||
|
||||
- CDL-F Flag Decal: Conformal flag decal, which uses either the mission flag or a flag of your choosing.
|
||||
- CDL-1 Generic Decal: A set of conformal generic decals for planes and rockets
|
||||
- CDL-2 Semiotic Standard Decal: A set of conformal decals based on the Semiotic Standard for All Commercial Trans-Stellar Utility Lifter and Transport Spacecraft designed by Ron Cobb for the movie Alien
|
@ -15,7 +15,7 @@ Localization
|
||||
#LOC_ConformalDecals_gui-opacity = Opacity
|
||||
#LOC_ConformalDecals_gui-cutoff = Cutoff
|
||||
#LOC_ConformalDecals_gui-wear = Edge Wear
|
||||
#LOC_ConformalDecals_gui-aspectratio = Aspect Ratio
|
||||
#LOC_ConformalDecals_gui-multiproject = Project onto Multiple
|
||||
#LOC_ConformalDecals_gui-select-flag = Select Flag
|
||||
#LOC_ConformalDecals_gui-reset-flag = Reset Flag
|
||||
#LOC_ConformalDecals_gui-set-text = Set Text
|
||||
|
@ -98,7 +98,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/DiffuseSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 0, 2, 128, 112
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +0,0 @@
|
||||
// Prevent projection onto Waterfall plumes
|
||||
|
||||
CONFORMALDECALS:NEEDS[Waterfall] {
|
||||
SHADERBLACKLIST {
|
||||
shaderRegex = Waterfall/.*
|
||||
}
|
||||
}
|
BIN
GameData/ConformalDecals/Plugins/ConformalDecals.dll
Normal file
BIN
GameData/ConformalDecals/Plugins/ConformalDecals.dll
Normal file
Binary file not shown.
@ -4,13 +4,21 @@ CONFORMALDECALS {
|
||||
|
||||
SHADERBLACKLIST {
|
||||
shader = DepthMask
|
||||
shader = KSP/Alpha/Cutoff
|
||||
shader = KSP/Alpha/Cutoff Bumped
|
||||
shader = KSP/Alpha/Translucent
|
||||
shader = KSP/Alpha/Translucent Additive
|
||||
shader = KSP/Alpha/Translucent Specular
|
||||
shader = KSP/Alpha/Unlit Transparent
|
||||
shader = KSP/Bumped Specular (Transparent)
|
||||
shader = KSP/FX/ScrollingUnlit
|
||||
shader = KSP/Particles/Additive
|
||||
shader = KSP/Particles/Additive (Soft)
|
||||
shader = KSP/Particles/Alpha Blended
|
||||
shader = KSP/Particles/Alpha Blended Emissive Cutout
|
||||
shader = KSP/Specular (Cutoff)
|
||||
shader = KSP/Specular (Transparent)
|
||||
shader = Solid Color (Alpha)
|
||||
shaderRegex = KSP/Alpha/.*
|
||||
shaderRegex = KSP/Particles/.*
|
||||
}
|
||||
|
||||
FONT {
|
||||
@ -49,309 +57,4 @@ CONFORMALDECALS {
|
||||
style = 32
|
||||
styleMask = 4
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/09
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/Sentinel_Flag
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/blorbs
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/bullseye
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/capsule
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/circles
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/default
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/hexagon
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/hexagonCircles
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/kerbal1
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/kerbal2
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/kerbin
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/kerbinmunflag
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/line
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/minimalistic
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/orbit
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/orbs
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/retro
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/rings
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/rocketScience
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/satellite
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/spheres
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/squadLogo
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/squadLogo2
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/stripes
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/trees
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/trippy
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/FlagsAgency/NASA
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/FlagsAgency/esa_dark_blue
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/FlagsAgency/uk_space_agency
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/FlagsOrganization/B612_Foundation_flag
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/FlagsOrganization/ESA_Arianespace
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/FlagsOrganization/electron
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/FlagsOrganization/rocketlab
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/C7AerospaceDivision
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/DinkelsteinKermansConstructionEmporium
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/ExperimentalEngineering
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/FlooydResearchLab
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/GoliathNationalProducts
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/IntegratedIntegrals
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/IonicSymphonicProtonicElectronics
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/JebsJunkyard
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/KerbalMotion
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/KerbinWorldFirstRecordKeepingSociety
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/Kerbodyne
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/Kerlington
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/MaxoConstructionToys
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/MovingPartsExpertsGroup
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/OMBDemolition
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/PeriapsisCo
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/Probodobodyne
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/R&D
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/ReactionSystemsLtd
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/Rockomax
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/Rokea
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/SeansCannery
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/SteadlerEngineeringCorps
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/StrutCo
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/Vac-Co
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/WinterOwl
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/ZaltonicElectronics
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
}
|
Binary file not shown.
@ -1,24 +1,28 @@
|
||||
{
|
||||
"NAME": "ConformalDecals",
|
||||
"URL": "https://github.com/drewcassidy/KSP-Conformal-Decals/releases/latest/download/ConformalDecals.version",
|
||||
"DOWNLOAD": "https://github.com/drewcassidy/KSP-Conformal-Decals/releases/latest",
|
||||
"CHANGE_LOG_URL": "https://raw.githubusercontent.com/drewcassidy/KSP-Conformal-Decals/release/CHANGELOG.md",
|
||||
"VERSION": {
|
||||
"MAJOR": 9,
|
||||
"MINOR": 9,
|
||||
"PATCH": 9,
|
||||
"BUILD": 100000
|
||||
"NAME":"ConformalDecals",
|
||||
"URL":"https://raw.githubusercontent.com/drewcassidy/KSP-Conformal-Decals/release/GameData/ConformalDecals/Versioning/ConformalDecals.version",
|
||||
"DOWNLOAD":"https://github.com/drewcassidy/KSP-Conformal-Decals/releases",
|
||||
"VERSION":
|
||||
{
|
||||
"MAJOR":0,
|
||||
"MINOR":2,
|
||||
"PATCH":7,
|
||||
"BUILD":0
|
||||
},
|
||||
"KSP_VERSION": {
|
||||
"MAJOR": 1,
|
||||
"MINOR": 12
|
||||
"KSP_VERSION":
|
||||
{
|
||||
"MAJOR":1,
|
||||
"MINOR":11,
|
||||
"PATCH":0
|
||||
},
|
||||
"KSP_VERSION_MIN": {
|
||||
"MAJOR": 1,
|
||||
"MINOR": 8
|
||||
"KSP_VERSION_MIN":{
|
||||
"MAJOR":1,
|
||||
"MINOR":8,
|
||||
"PATCH":0
|
||||
},
|
||||
"KSP_VERSION_MAX": {
|
||||
"MAJOR": 1,
|
||||
"MINOR": 12
|
||||
"KSP_VERSION_MAX":{
|
||||
"MAJOR":1,
|
||||
"MINOR":11,
|
||||
"PATCH":99
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
README.md
11
README.md
@ -1,5 +1,5 @@
|
||||
# Conformal Decals
|
||||
[](https://creativecommons.org/licenses/by-sa/4.0/) [](https://www.gnu.org/licenses/gpl-3.0) [](https://github.com/KSP-CKAN/CKAN)
|
||||
# Conformal Decals v0.2.7
|
||||
[](https://travis-ci.com/drewcassidy/KSP-Conformal-Decals) [](https://creativecommons.org/licenses/by-sa/4.0/) [](https://www.gnu.org/licenses/gpl-3.0)
|
||||
|
||||

|
||||
|
||||
@ -8,11 +8,10 @@ Conformal Decals adds a set of decal stickers to KSP, as well as providing a fra
|
||||
## Dependencies
|
||||
|
||||
Required:
|
||||
- KSP (1.8.x to 1.12.x)
|
||||
- B9 Part Switch (2.18.0). Bundled with release.
|
||||
- KSP (1.8.x to 1.10.x)
|
||||
- B9 Part Switch (2.16.0). Bundled with release.
|
||||
- ModuleManager (4.1.4). Bundled with release.
|
||||
- Shabby (0.2.0 unofficial build). Bundled with release.
|
||||
- HarmonyKSP (2.0.4.0). Bundled with release.
|
||||
- Shabby (0.1.2). Bundled with release.
|
||||
|
||||
Optional:
|
||||
- Wild Blue Tools. For custom decals category in the VAB and SPH.
|
||||
|
@ -1,61 +0,0 @@
|
||||
import yaclog
|
||||
import yaclog.version
|
||||
import git as gp
|
||||
import os
|
||||
import xml.dom.minidom as minidom
|
||||
import json
|
||||
|
||||
|
||||
def run():
|
||||
repo = gp.Repo(os.curdir)
|
||||
cl = yaclog.Changelog('CHANGELOG.md')
|
||||
version = str(cl.current_version(released=True).version)
|
||||
release = False
|
||||
|
||||
for tag in repo.tags:
|
||||
if tag.commit == repo.head.commit:
|
||||
release = True
|
||||
build = 100000
|
||||
break
|
||||
|
||||
if not release:
|
||||
build = int.from_bytes(repo.head.commit.binsha[0:2], byteorder='big')
|
||||
version = yaclog.version.increment_version(version, 2)
|
||||
|
||||
print(f'Setting up version {version} build {build}')
|
||||
|
||||
version_path = 'GameData/ConformalDecals/Versioning/ConformalDecals.version'
|
||||
with open(version_path, 'r+') as version_file:
|
||||
print('Updating version file')
|
||||
segments = version.split('.')
|
||||
# print(version_file.read())
|
||||
decoded = json.load(version_file)
|
||||
decoded['VERSION']['MAJOR'] = int(segments[0])
|
||||
decoded['VERSION']['MINOR'] = int(segments[1])
|
||||
decoded['VERSION']['PATCH'] = int(segments[2])
|
||||
decoded['VERSION']['BUILD'] = build
|
||||
|
||||
version_file.seek(0)
|
||||
json.dump(decoded, version_file, indent=4)
|
||||
version_file.truncate()
|
||||
|
||||
project_path = 'Source/ConformalDecals/ConformalDecals.csproj'
|
||||
with open(project_path, 'r+') as project_file:
|
||||
print('Updating csproj file')
|
||||
segments = version.split('.')
|
||||
decoded = minidom.parse(project_file)
|
||||
version_node = decoded.getElementsByTagName('AssemblyVersion')[0]
|
||||
if release:
|
||||
version_node.firstChild.nodeValue = f'{version}'
|
||||
else:
|
||||
version_node.firstChild.nodeValue = f'{version}.{build}'
|
||||
# version_node.value = f'{version}.{build}'
|
||||
project_file.seek(0)
|
||||
decoded.writexml(project_file)
|
||||
project_file.truncate()
|
||||
|
||||
print('Done!')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
@ -1,6 +1,12 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConformalDecals", "ConformalDecals/ConformalDecals.csproj", "{1EA983F9-42E5-494E-9683-FDAC9C9121F4}"
|
||||
# Visual Studio Version 16
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConformalDecals", "ConformalDecals\ConformalDecals.csproj", "{1EA983F9-42E5-494E-9683-FDAC9C9121F4}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C2564402-B081-479B-B723-D5C065BC884E}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -13,4 +19,28 @@ Global
|
||||
{1EA983F9-42E5-494E-9683-FDAC9C9121F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1EA983F9-42E5-494E-9683-FDAC9C9121F4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
Policies = $0
|
||||
$0.DotNetNamingPolicy = $1
|
||||
$1.DirectoryNamespaceAssociation = PrefixedHierarchical
|
||||
$0.TextStylePolicy = $2
|
||||
$2.FileWidth = 80
|
||||
$2.TabsToSpaces = True
|
||||
$2.scope = text/x-csharp
|
||||
$2.NoTabsAfterNonTabs = True
|
||||
$2.EolMarker = Unix
|
||||
$0.CSharpFormattingPolicy = $3
|
||||
$3.NewLinesForBracesInTypes = False
|
||||
$3.NewLinesForBracesInMethods = False
|
||||
$3.NewLinesForBracesInProperties = False
|
||||
$3.NewLinesForBracesInAccessors = False
|
||||
$3.NewLinesForBracesInAnonymousMethods = False
|
||||
$3.NewLinesForBracesInControlBlocks = False
|
||||
$3.NewLinesForBracesInAnonymousTypes = False
|
||||
$3.NewLinesForBracesInObjectCollectionArrayInitializers = False
|
||||
$3.NewLinesForBracesInLambdaExpressionBody = False
|
||||
$3.scope = text/x-csharp
|
||||
$3.SpaceAfterCast = True
|
||||
$0.StandardHeader = $4
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" ?><Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<LangVersion>8</LangVersion>
|
||||
<IsPackable>false</IsPackable>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<NoWarn>1701;1702;CS0649;CS1591</NoWarn>
|
||||
<AssemblyVersion>9.9.9</AssemblyVersion>
|
||||
<AssemblyVersion>0.2.7</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -36,20 +36,23 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="dlls\**"/>
|
||||
<Compile Remove="dlls\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Remove="dlls\**"/>
|
||||
<EmbeddedResource Remove="dlls\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="dlls\**"/>
|
||||
<None Remove="dlls\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\.editorconfig" />
|
||||
</ItemGroup>
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="/bin/cp -v '$(OutDir)ConformalDecals.dll' '$(SolutionDir)../GameData/ConformalDecals/Plugins/ConformalDecals.dll'" IgnoreExitCode="true"/>
|
||||
<!--Fuck you MSBuild stop trying to run CMD.exe on macOS-->
|
||||
<Exec Command="/bin/cp -v '$(OutDir)ConformalDecals.dll' '$(SolutionDir)../GameData/ConformalDecals/Plugins'" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
|
@ -1,21 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using ConformalDecals.Text;
|
||||
using ConformalDecals.Util;
|
||||
using TMPro;
|
||||
using UniLinq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals {
|
||||
public static class DecalConfig {
|
||||
private static Texture2D _blankNormal;
|
||||
private static List<string> _shaderBlacklist;
|
||||
private static List<Regex> _shaderRegexBlacklist;
|
||||
private static Dictionary<string, DecalFont> _fontList;
|
||||
private static int _decalLayer = 31;
|
||||
private static bool _selectableInFlight;
|
||||
private static Dictionary<string, float> _aspectRatios;
|
||||
|
||||
private struct LegacyShaderEntry {
|
||||
public string name;
|
||||
@ -54,24 +50,12 @@ namespace ConformalDecals {
|
||||
|
||||
public static IEnumerable<DecalFont> Fonts => _fontList.Values;
|
||||
|
||||
public static Dictionary<string, float> AspectRatios => _aspectRatios;
|
||||
|
||||
public static bool IsBlacklisted(Shader shader) {
|
||||
return IsBlacklisted(shader.name);
|
||||
}
|
||||
|
||||
public static bool IsBlacklisted(string shaderName) {
|
||||
if (_shaderBlacklist.Contains(shaderName)) return true;
|
||||
|
||||
foreach (var regex in _shaderRegexBlacklist) {
|
||||
if (regex.IsMatch(shaderName)) {
|
||||
_shaderBlacklist.Add(shaderName);
|
||||
Logging.Log($"Caching blacklisted shader name '{shaderName}' which matches '{regex}'");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return _shaderBlacklist.Contains(shaderName);
|
||||
}
|
||||
|
||||
public static bool IsLegacy(string shaderName, out string newShader, out string[] keywords) {
|
||||
@ -89,7 +73,8 @@ namespace ConformalDecals {
|
||||
public static DecalFont GetFont(string name) {
|
||||
if (_fontList.TryGetValue(name, out var font)) {
|
||||
return font;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
throw new KeyNotFoundException($"Font {name} not found");
|
||||
}
|
||||
}
|
||||
@ -103,29 +88,16 @@ namespace ConformalDecals {
|
||||
foreach (var shaderName in blacklist.GetValuesList("shader")) {
|
||||
_shaderBlacklist.Add(shaderName);
|
||||
}
|
||||
|
||||
foreach (var shaderRegex in blacklist.GetValuesList("shaderRegex")) {
|
||||
_shaderRegexBlacklist.Add(new Regex(shaderRegex));
|
||||
}
|
||||
}
|
||||
|
||||
var allFonts = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
|
||||
|
||||
foreach (var fontNode in node.GetNodes("FONT")) {
|
||||
try {
|
||||
var font = new DecalFont(fontNode, allFonts);
|
||||
var font = DecalFont.Parse(fontNode, allFonts);
|
||||
_fontList.Add(font.Name, font);
|
||||
} catch (Exception e) {
|
||||
Debug.LogException(e);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var ratioNode in node.GetNodes("ASPECTRATIO")) {
|
||||
try {
|
||||
var path = ParseUtil.ParseString(ratioNode, "path");
|
||||
var ratio = ParseUtil.ParseFloat(ratioNode, "aspectRatio");
|
||||
_aspectRatios[path] = ratio;
|
||||
} catch (Exception e) {
|
||||
catch (Exception e) {
|
||||
Debug.LogException(e);
|
||||
}
|
||||
}
|
||||
@ -139,12 +111,8 @@ namespace ConformalDecals {
|
||||
var colors = new[] {color, color, color, color};
|
||||
|
||||
var tex = new Texture2D(width, height, TextureFormat.RGBA32, false);
|
||||
for (var x = 0; x <= width; x++) {
|
||||
for (var y = 0; y < height; y++) {
|
||||
tex.SetPixels32(colors);
|
||||
}
|
||||
}
|
||||
|
||||
tex.SetPixels32(colors);
|
||||
tex.Apply();
|
||||
|
||||
return tex;
|
||||
@ -153,15 +121,13 @@ namespace ConformalDecals {
|
||||
// ReSharper disable once UnusedMember.Global
|
||||
public static void ModuleManagerPostLoad() {
|
||||
_shaderBlacklist = new List<string>();
|
||||
_shaderRegexBlacklist = new List<Regex>();
|
||||
_fontList = new Dictionary<string, DecalFont>();
|
||||
_aspectRatios = new Dictionary<string, float>();
|
||||
|
||||
var configs = GameDatabase.Instance.GetConfigs("CONFORMALDECALS");
|
||||
|
||||
if (configs.Length > 0) {
|
||||
Logging.Log("Loading config");
|
||||
foreach (var config in configs) {
|
||||
Logging.Log($"loading config node '{config.url}'");
|
||||
ParseConfig(config.config);
|
||||
}
|
||||
}
|
||||
|
8
Source/ConformalDecals/IProjectionTarget.cs
Normal file
8
Source/ConformalDecals/IProjectionTarget.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals {
|
||||
public interface IProjectionTarget {
|
||||
bool Project(Matrix4x4 orthoMatrix, Transform projector, Bounds projectionBounds);
|
||||
void Render(Material decalMaterial, MaterialPropertyBlock partMPB, Camera camera);
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ namespace ConformalDecals.MaterialProperties {
|
||||
public override void ParseNode(ConfigNode node) {
|
||||
base.ParseNode(node);
|
||||
|
||||
ParseUtil.ParseBoolIndirect(ref value, node, "value");
|
||||
value = ParseUtil.ParseBool(node, "value", true, true);
|
||||
}
|
||||
|
||||
public override void Modify(Material material) {
|
||||
|
@ -75,12 +75,7 @@ namespace ConformalDecals.MaterialProperties {
|
||||
}
|
||||
}
|
||||
|
||||
public float AspectRatio {
|
||||
get => MainTexture == null ? 1 : MainTexture.AspectRatio;
|
||||
set {
|
||||
if (MainTexture != null) MainTexture.AspectRatio = value;
|
||||
}
|
||||
}
|
||||
public float AspectRatio => MainTexture == null ? 1 : MainTexture.AspectRatio;
|
||||
|
||||
public void OnBeforeSerialize() {
|
||||
if (_materialProperties == null) throw new SerializationException("Tried to serialize an uninitialized MaterialPropertyCollection");
|
||||
@ -100,7 +95,7 @@ namespace ConformalDecals.MaterialProperties {
|
||||
var property = MaterialProperty.Instantiate(_serializedProperties[i]);
|
||||
_materialProperties.Add(_serializedNames[i], property);
|
||||
|
||||
if (property is MaterialTextureProperty textureProperty && textureProperty.isMain) {
|
||||
if (property is MaterialTextureProperty {isMain: true} textureProperty) {
|
||||
_mainTexture = textureProperty;
|
||||
}
|
||||
}
|
||||
@ -110,6 +105,28 @@ namespace ConformalDecals.MaterialProperties {
|
||||
_materialProperties ??= new Dictionary<string, MaterialProperty>();
|
||||
}
|
||||
|
||||
public void Load(ConfigNode node) {
|
||||
// add keyword nodes
|
||||
foreach (var keywordNode in node.GetNodes("KEYWORD")) {
|
||||
ParseProperty<MaterialKeywordProperty>(keywordNode);
|
||||
}
|
||||
|
||||
// add texture nodes
|
||||
foreach (var textureNode in node.GetNodes("TEXTURE")) {
|
||||
ParseProperty<MaterialTextureProperty>(textureNode);
|
||||
}
|
||||
|
||||
// add float nodes
|
||||
foreach (var floatNode in node.GetNodes("FLOAT")) {
|
||||
ParseProperty<MaterialTextureProperty>(floatNode);
|
||||
}
|
||||
|
||||
// add color nodes
|
||||
foreach (var colorNode in node.GetNodes("COLOR")) {
|
||||
ParseProperty<MaterialColorProperty>(colorNode);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDestroy() {
|
||||
if (_decalMaterial != null) Destroy(_decalMaterial);
|
||||
if (_previewMaterial != null) Destroy(_previewMaterial);
|
||||
@ -141,7 +158,8 @@ namespace ConformalDecals.MaterialProperties {
|
||||
public T GetProperty<T>(string propertyName) where T : MaterialProperty {
|
||||
if (_materialProperties.ContainsKey(propertyName) && _materialProperties[propertyName] is T property) {
|
||||
return property;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -149,7 +167,8 @@ namespace ConformalDecals.MaterialProperties {
|
||||
public T AddOrGetProperty<T>(string propertyName) where T : MaterialProperty {
|
||||
if (_materialProperties.ContainsKey(propertyName) && _materialProperties[propertyName] is T property) {
|
||||
return property;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return AddProperty<T>(propertyName);
|
||||
}
|
||||
}
|
||||
@ -159,10 +178,9 @@ namespace ConformalDecals.MaterialProperties {
|
||||
foreach (var material in Materials) {
|
||||
property.Remove(material);
|
||||
}
|
||||
|
||||
_materialProperties.Remove(propertyName);
|
||||
Destroy(property);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -196,7 +214,7 @@ namespace ConformalDecals.MaterialProperties {
|
||||
var newProperty = AddOrGetProperty<T>(propertyName);
|
||||
newProperty.ParseNode(node);
|
||||
|
||||
if (newProperty is MaterialTextureProperty textureProperty && textureProperty.isMain) {
|
||||
if (newProperty is MaterialTextureProperty {isMain: true} textureProperty) {
|
||||
_mainTexture = textureProperty;
|
||||
}
|
||||
|
||||
@ -208,7 +226,8 @@ namespace ConformalDecals.MaterialProperties {
|
||||
if (_shader == null) {
|
||||
Logging.Log("Using default decal shader");
|
||||
shaderName = "ConformalDecals/Decal/Standard";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -233,7 +252,7 @@ namespace ConformalDecals.MaterialProperties {
|
||||
|
||||
public void UpdateScale(Vector2 scale) {
|
||||
foreach (var entry in _materialProperties) {
|
||||
if (entry.Value is MaterialTextureProperty textureProperty && textureProperty.autoScale) {
|
||||
if (entry.Value is MaterialTextureProperty {autoScale: true} textureProperty) {
|
||||
textureProperty.SetScale(scale);
|
||||
}
|
||||
}
|
||||
@ -244,7 +263,7 @@ namespace ConformalDecals.MaterialProperties {
|
||||
var mainTexSize = _mainTexture.Dimensions;
|
||||
|
||||
foreach (var entry in _materialProperties) {
|
||||
if (entry.Value is MaterialTextureProperty textureProperty && textureProperty.autoTile) {
|
||||
if (entry.Value is MaterialTextureProperty {autoTile: true} textureProperty) {
|
||||
textureProperty.SetTile(tile, mainTexSize);
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,6 @@ namespace ConformalDecals.MaterialProperties {
|
||||
[SerializeField] private Vector2 _textureOffset;
|
||||
[SerializeField] private Vector2 _textureScale = Vector2.one;
|
||||
|
||||
[SerializeField] private float _aspectRatioOverride = -1.0f;
|
||||
|
||||
public Texture2D Texture {
|
||||
get => _texture;
|
||||
set => _texture = value;
|
||||
@ -45,12 +43,10 @@ namespace ConformalDecals.MaterialProperties {
|
||||
|
||||
public float AspectRatio {
|
||||
get {
|
||||
if (_aspectRatioOverride > 0) return _aspectRatioOverride;
|
||||
if (_texture == null) return 1;
|
||||
if (_textureUrl?.Contains("Squad/Flags") == true) return 0.625f; // squad flags are slightly stretched, so unstretch them
|
||||
return MaskedHeight / (float) MaskedWidth;
|
||||
}
|
||||
|
||||
set => _aspectRatioOverride = value;
|
||||
}
|
||||
|
||||
public override void ParseNode(ConfigNode node) {
|
||||
@ -68,7 +64,7 @@ namespace ConformalDecals.MaterialProperties {
|
||||
if (ParseUtil.ParseStringIndirect(ref _textureUrl, node, "textureUrl")) {
|
||||
_texture = LoadTexture(_textureUrl, isNormal);
|
||||
}
|
||||
|
||||
|
||||
if (_texture == null) {
|
||||
_texture = isNormal ? DecalConfig.BlankNormal : Texture2D.whiteTexture;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ConformalDecals.MaterialProperties;
|
||||
using ConformalDecals.Util;
|
||||
using UniLinq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals {
|
||||
@ -35,8 +36,6 @@ namespace ConformalDecals {
|
||||
|
||||
[KSPField] public DecalScaleMode scaleMode = DecalScaleMode.HEIGHT;
|
||||
|
||||
[KSPField] public float aspectRatio = -1.0f; // < 0 = use texture
|
||||
|
||||
[KSPField] public bool depthAdjustable = true;
|
||||
[KSPField] public float defaultDepth = 0.1f;
|
||||
[KSPField] public Vector2 depthRange = new Vector2(0, 2);
|
||||
@ -81,7 +80,9 @@ namespace ConformalDecals {
|
||||
UI_FloatRange()]
|
||||
public float wear = 100;
|
||||
|
||||
[KSPField(isPersistant = true)] public bool projectMultiple; // reserved for future features. do not modify
|
||||
[KSPField(guiName = "#LOC_ConformalDecals_gui-multiproject", guiActive = false, guiActiveEditor = true, isPersistant = true),
|
||||
UI_Toggle()]
|
||||
public bool projectMultiple = true;
|
||||
|
||||
[KSPField] public MaterialPropertyCollection materialProperties;
|
||||
|
||||
@ -98,7 +99,7 @@ namespace ConformalDecals {
|
||||
private const int DecalQueueMax = 2400;
|
||||
private static int _decalQueueCounter = -1;
|
||||
|
||||
private List<ProjectionTarget> _targets;
|
||||
private readonly Dictionary<Part, ProjectionPartTarget> _targets = new Dictionary<Part, ProjectionPartTarget>();
|
||||
|
||||
private bool _isAttached;
|
||||
private Matrix4x4 _orthoMatrix;
|
||||
@ -118,126 +119,43 @@ namespace ConformalDecals {
|
||||
}
|
||||
}
|
||||
|
||||
// EVENTS
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAwake() {
|
||||
base.OnAwake();
|
||||
|
||||
if (materialProperties == null) {
|
||||
materialProperties = ScriptableObject.CreateInstance<MaterialPropertyCollection>();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
materialProperties = ScriptableObject.Instantiate(materialProperties);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoad(ConfigNode node) {
|
||||
// Load
|
||||
try {
|
||||
// SETUP TRANSFORMS
|
||||
decalFrontTransform = part.FindModelTransform(decalFront);
|
||||
if (decalFrontTransform == null) throw new FormatException($"Could not find decalFront transform: '{decalFront}'.");
|
||||
|
||||
decalBackTransform = part.FindModelTransform(decalBack);
|
||||
if (decalBackTransform == null) throw new FormatException($"Could not find decalBack transform: '{decalBack}'.");
|
||||
|
||||
decalModelTransform = part.FindModelTransform(decalModel);
|
||||
if (decalModelTransform == null) throw new FormatException($"Could not find decalModel transform: '{decalModel}'.");
|
||||
|
||||
decalProjectorTransform = part.FindModelTransform(decalProjector);
|
||||
if (decalProjectorTransform == null) throw new FormatException($"Could not find decalProjector transform: '{decalProjector}'.");
|
||||
|
||||
decalColliderTransform = part.FindModelTransform(decalCollider);
|
||||
if (decalColliderTransform == null) throw new FormatException($"Could not find decalCollider transform: '{decalCollider}'.");
|
||||
|
||||
// SETUP BACK MATERIAL
|
||||
if (updateBackScale) {
|
||||
var backRenderer = decalBackTransform.GetComponent<MeshRenderer>();
|
||||
if (backRenderer == null) {
|
||||
this.LogError($"Specified decalBack transform {decalBack} has no renderer attached! Setting updateBackScale to false.");
|
||||
updateBackScale = false;
|
||||
} else {
|
||||
backMaterial = backRenderer.material;
|
||||
if (backMaterial == null) {
|
||||
this.LogError($"Specified decalBack transform {decalBack} has a renderer but no material! Setting updateBackScale to false.");
|
||||
updateBackScale = false;
|
||||
} else {
|
||||
if (backTextureBaseScale == default) backTextureBaseScale = backMaterial.GetTextureScale(PropertyIDs._MainTex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PARSE MATERIAL PROPERTIES
|
||||
|
||||
// set shader
|
||||
materialProperties.SetShader(shader);
|
||||
materialProperties.AddOrGetProperty<MaterialKeywordProperty>("DECAL_BASE_NORMAL").value = useBaseNormal;
|
||||
|
||||
// add keyword nodes
|
||||
foreach (var keywordNode in node.GetNodes("KEYWORD")) {
|
||||
materialProperties.ParseProperty<MaterialKeywordProperty>(keywordNode);
|
||||
}
|
||||
|
||||
// add texture nodes
|
||||
foreach (var textureNode in node.GetNodes("TEXTURE")) {
|
||||
materialProperties.ParseProperty<MaterialTextureProperty>(textureNode);
|
||||
}
|
||||
|
||||
// add float nodes
|
||||
foreach (var floatNode in node.GetNodes("FLOAT")) {
|
||||
materialProperties.ParseProperty<MaterialTextureProperty>(floatNode);
|
||||
}
|
||||
|
||||
// add color nodes
|
||||
foreach (var colorNode in node.GetNodes("COLOR")) {
|
||||
materialProperties.ParseProperty<MaterialColorProperty>(colorNode);
|
||||
}
|
||||
|
||||
// handle texture tiling parameters
|
||||
var tileString = node.GetValue("tile");
|
||||
if (!string.IsNullOrEmpty(tileString)) {
|
||||
var tileValid = ParseExtensions.TryParseRect(tileString, out tileRect);
|
||||
if (!tileValid) throw new FormatException($"Invalid rect value for tile '{tileString}'");
|
||||
}
|
||||
|
||||
if (tileRect.x >= 0) {
|
||||
materialProperties.UpdateTile(tileRect);
|
||||
} else if (tileIndex >= 0) {
|
||||
materialProperties.UpdateTile(tileIndex, tileSize);
|
||||
}
|
||||
|
||||
// handle aspect ratio overrides
|
||||
materialProperties.AspectRatio = aspectRatio;
|
||||
|
||||
} catch (Exception e) {
|
||||
this.LogException("Exception parsing partmodule", e);
|
||||
LoadDecal(node);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.LogException("Error loading decal", e);
|
||||
}
|
||||
|
||||
UpdateMaterials();
|
||||
|
||||
foreach (var keyword in _decalMaterial.shaderKeywords) {
|
||||
this.Log($"keyword: {keyword}");
|
||||
// Setup
|
||||
try {
|
||||
SetupDecal();
|
||||
}
|
||||
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
UpdateTweakables();
|
||||
}
|
||||
|
||||
if (HighLogic.LoadedSceneIsGame) {
|
||||
UpdateScale();
|
||||
} else {
|
||||
scale = defaultScale;
|
||||
depth = defaultDepth;
|
||||
opacity = defaultOpacity;
|
||||
cutoff = defaultCutoff;
|
||||
wear = defaultWear;
|
||||
|
||||
// QUEUE PART FOR ICON FIXING IN VAB
|
||||
DecalIconFixer.QueuePart(part.name);
|
||||
catch (Exception e) {
|
||||
this.LogException("Error setting up decal", e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnIconCreate() {
|
||||
UpdateScale();
|
||||
UpdateTextures();
|
||||
UpdateProjection();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -250,19 +168,21 @@ namespace ConformalDecals {
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
GameEvents.onEditorPartEvent.Add(OnEditorEvent);
|
||||
GameEvents.onVariantApplied.Add(OnVariantApplied);
|
||||
GameEvents.onEditorUndo.Add(OnEditorUndo);
|
||||
|
||||
UpdateTweakables();
|
||||
}
|
||||
}
|
||||
|
||||
/// Called after OnStart is finished for all parts
|
||||
/// This is mostly used to make sure all B9 variants are already in place for the rest of the vessel
|
||||
public override void OnStartFinished(StartState state) {
|
||||
// handle game events
|
||||
if (HighLogic.LoadedSceneIsGame) {
|
||||
// set initial attachment state
|
||||
if (part.parent == null) {
|
||||
OnDetach();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
OnAttach();
|
||||
}
|
||||
}
|
||||
@ -283,12 +203,12 @@ namespace ConformalDecals {
|
||||
}
|
||||
}
|
||||
|
||||
/// Called when the decal is destroyed
|
||||
public virtual void OnDestroy() {
|
||||
// remove GameEvents
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
GameEvents.onEditorPartEvent.Remove(OnEditorEvent);
|
||||
GameEvents.onVariantApplied.Remove(OnVariantApplied);
|
||||
GameEvents.onEditorUndo.Remove(OnEditorUndo);
|
||||
}
|
||||
|
||||
if (HighLogic.LoadedSceneIsFlight) {
|
||||
@ -302,17 +222,21 @@ namespace ConformalDecals {
|
||||
Destroy(materialProperties);
|
||||
}
|
||||
|
||||
protected void OnSizeTweakEvent(BaseField field, object obj) {
|
||||
/// Called when the decal's projection and scale is modified through a tweakable
|
||||
protected void OnProjectionTweakEvent(BaseField field, object obj) {
|
||||
// scale or depth values have been changed, so update scale
|
||||
// and update projection matrices if attached
|
||||
UpdateScale();
|
||||
UpdateProjection();
|
||||
UpdateTargets();
|
||||
|
||||
foreach (var counterpart in part.symmetryCounterparts) {
|
||||
var decal = counterpart.GetComponent<ModuleConformalDecal>();
|
||||
decal.UpdateScale();
|
||||
decal.UpdateProjection();
|
||||
decal.UpdateTargets();
|
||||
}
|
||||
}
|
||||
|
||||
/// Called when the decal's material is modified through a tweakable
|
||||
protected void OnMaterialTweakEvent(BaseField field, object obj) {
|
||||
materialProperties.SetOpacity(opacity);
|
||||
materialProperties.SetCutoff(cutoff);
|
||||
@ -330,39 +254,85 @@ namespace ConformalDecals {
|
||||
}
|
||||
}
|
||||
|
||||
/// Called when a new variant is applied in the editor
|
||||
protected void OnVariantApplied(Part eventPart, PartVariant variant) {
|
||||
if (_isAttached && eventPart == part.parent) {
|
||||
if (_isAttached && eventPart != null && (!projectMultiple || eventPart == part.parent)) {
|
||||
_targets.Remove(eventPart);
|
||||
UpdateTargets();
|
||||
}
|
||||
}
|
||||
|
||||
/// Called when an editor event occurs
|
||||
protected void OnEditorEvent(ConstructionEventType eventType, Part eventPart) {
|
||||
if (this.part != eventPart && !part.symmetryCounterparts.Contains(eventPart)) return;
|
||||
switch (eventType) {
|
||||
case ConstructionEventType.PartAttached:
|
||||
OnAttach();
|
||||
OnPartAttached(eventPart);
|
||||
break;
|
||||
case ConstructionEventType.PartDetached:
|
||||
OnDetach();
|
||||
OnPartDetached(eventPart);
|
||||
break;
|
||||
case ConstructionEventType.PartOffsetting:
|
||||
case ConstructionEventType.PartRotating:
|
||||
UpdateScale();
|
||||
OnPartTransformed(eventPart);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnEditorUndo(ShipConstruct sc) {
|
||||
UpdateTargets();
|
||||
/// Called when a part is transformed in the editor
|
||||
protected void OnPartTransformed(Part eventPart) {
|
||||
if (this.part == eventPart) {
|
||||
UpdateProjection();
|
||||
UpdateTargets();
|
||||
}
|
||||
else if (_isAttached && projectMultiple) {
|
||||
UpdatePartTarget(eventPart, _boundsRenderer.bounds);
|
||||
// recursively call for child parts
|
||||
foreach (var child in eventPart.children) {
|
||||
OnPartTransformed(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Called when a part is attached in the editor
|
||||
protected void OnPartAttached(Part eventPart) {
|
||||
if (this.part == eventPart) {
|
||||
OnAttach();
|
||||
}
|
||||
else if (_isAttached && projectMultiple) {
|
||||
UpdatePartTarget(eventPart, _boundsRenderer.bounds);
|
||||
// recursively call for child parts
|
||||
foreach (var child in eventPart.children) {
|
||||
OnPartAttached(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Called when a part is detached in the editor
|
||||
protected void OnPartDetached(Part eventPart) {
|
||||
if (this.part == eventPart) {
|
||||
OnDetach();
|
||||
}
|
||||
else if (_isAttached && projectMultiple) {
|
||||
_targets.Remove(eventPart);
|
||||
// recursively call for child parts
|
||||
foreach (var child in eventPart.children) {
|
||||
OnPartDetached(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Called when part `willDie` will be destroyed
|
||||
protected void OnPartWillDie(Part willDie) {
|
||||
if (willDie == part.parent) {
|
||||
this.Log("Parent part about to be destroyed! Killing decal part.");
|
||||
part.Die();
|
||||
}
|
||||
else if (_isAttached && projectMultiple) {
|
||||
_targets.Remove(willDie);
|
||||
}
|
||||
}
|
||||
|
||||
/// Called when decal is attached to a new part
|
||||
protected virtual void OnAttach() {
|
||||
if (part.parent == null) {
|
||||
this.LogError("Attach function called but part has no parent!");
|
||||
@ -371,6 +341,7 @@ namespace ConformalDecals {
|
||||
}
|
||||
|
||||
_isAttached = true;
|
||||
_targets.Clear();
|
||||
|
||||
// hide model
|
||||
decalModelTransform.gameObject.SetActive(false);
|
||||
@ -382,10 +353,11 @@ namespace ConformalDecals {
|
||||
Camera.onPreCull += Render;
|
||||
|
||||
UpdateMaterials();
|
||||
UpdateProjection();
|
||||
UpdateTargets();
|
||||
UpdateScale();
|
||||
}
|
||||
|
||||
/// Called when decal is detached from its parent part
|
||||
protected virtual void OnDetach() {
|
||||
_isAttached = false;
|
||||
|
||||
@ -399,114 +371,94 @@ namespace ConformalDecals {
|
||||
Camera.onPreCull -= Render;
|
||||
|
||||
UpdateMaterials();
|
||||
UpdateScale();
|
||||
UpdateProjection();
|
||||
}
|
||||
|
||||
protected void UpdateScale() {
|
||||
scale = Mathf.Max(0.01f, scale);
|
||||
depth = Mathf.Max(0.01f, depth);
|
||||
// FUNCTIONS
|
||||
|
||||
var sizeRatio = Mathf.Max(0.01f, materialProperties.AspectRatio);
|
||||
/// Load any settings from the decal config
|
||||
protected virtual void LoadDecal(ConfigNode node) {
|
||||
// PARSE TRANSFORMS
|
||||
decalFrontTransform = part.FindModelTransform(decalFront);
|
||||
if (decalFrontTransform == null) throw new FormatException($"Could not find decalFront transform: '{decalFront}'.");
|
||||
|
||||
Vector2 size;
|
||||
decalBackTransform = part.FindModelTransform(decalBack);
|
||||
if (decalBackTransform == null) throw new FormatException($"Could not find decalBack transform: '{decalBack}'.");
|
||||
|
||||
switch (scaleMode) {
|
||||
default:
|
||||
case DecalScaleMode.HEIGHT:
|
||||
size = new Vector2(scale / sizeRatio, scale);
|
||||
break;
|
||||
case DecalScaleMode.WIDTH:
|
||||
size = new Vector2(scale, scale * sizeRatio);
|
||||
break;
|
||||
case DecalScaleMode.AVERAGE:
|
||||
var width1 = 2 * scale / (1 + sizeRatio);
|
||||
size = new Vector2(width1, width1 * sizeRatio);
|
||||
break;
|
||||
case DecalScaleMode.AREA:
|
||||
var width2 = Mathf.Sqrt(scale / sizeRatio);
|
||||
size = new Vector2(width2, width2 * sizeRatio);
|
||||
break;
|
||||
case DecalScaleMode.MINIMUM:
|
||||
if (sizeRatio > 1) goto case DecalScaleMode.WIDTH;
|
||||
else goto case DecalScaleMode.HEIGHT;
|
||||
case DecalScaleMode.MAXIMUM:
|
||||
if (sizeRatio > 1) goto case DecalScaleMode.HEIGHT;
|
||||
else goto case DecalScaleMode.WIDTH;
|
||||
}
|
||||
decalModelTransform = part.FindModelTransform(decalModel);
|
||||
if (decalModelTransform == null) throw new FormatException($"Could not find decalModel transform: '{decalModel}'.");
|
||||
|
||||
// update material scale
|
||||
materialProperties.UpdateScale(size);
|
||||
decalProjectorTransform = part.FindModelTransform(decalProjector);
|
||||
if (decalProjectorTransform == null) throw new FormatException($"Could not find decalProjector transform: '{decalProjector}'.");
|
||||
|
||||
if (_isAttached) {
|
||||
// update orthogonal matrix
|
||||
_orthoMatrix = Matrix4x4.identity;
|
||||
_orthoMatrix[0, 3] = 0.5f;
|
||||
_orthoMatrix[1, 3] = 0.5f;
|
||||
decalColliderTransform = part.FindModelTransform(decalCollider);
|
||||
if (decalColliderTransform == null) throw new FormatException($"Could not find decalCollider transform: '{decalCollider}'.");
|
||||
|
||||
decalProjectorTransform.localScale = new Vector3(size.x, size.y, depth);
|
||||
|
||||
// update projection
|
||||
foreach (var target in _targets) {
|
||||
if (target.target == null) {
|
||||
_targets.Remove(target);
|
||||
} else {
|
||||
target.Project(_orthoMatrix, decalProjectorTransform, _boundsRenderer.bounds, useBaseNormal);
|
||||
// SETUP BACK MATERIAL
|
||||
if (updateBackScale) {
|
||||
var backRenderer = decalBackTransform.GetComponent<MeshRenderer>();
|
||||
if (backRenderer == null) {
|
||||
this.LogError($"Specified decalBack transform {decalBack} has no renderer attached! Setting updateBackScale to false.");
|
||||
updateBackScale = false;
|
||||
}
|
||||
else {
|
||||
backMaterial = backRenderer.material;
|
||||
if (backMaterial == null) {
|
||||
this.LogError($"Specified decalBack transform {decalBack} has a renderer but no material! Setting updateBackScale to false.");
|
||||
updateBackScale = false;
|
||||
}
|
||||
else {
|
||||
if (backTextureBaseScale == default) backTextureBaseScale = backMaterial.GetTextureScale(PropertyIDs._MainTex);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// rescale preview model
|
||||
decalModelTransform.localScale = new Vector3(size.x, size.y, (size.x + size.y) / 2);
|
||||
}
|
||||
|
||||
// update back material scale
|
||||
if (updateBackScale) {
|
||||
backMaterial.SetTextureScale(PropertyIDs._MainTex, new Vector2(size.x * backTextureBaseScale.x, size.y * backTextureBaseScale.y));
|
||||
}
|
||||
// PARSE MATERIAL PROPERTIES
|
||||
// set shader
|
||||
materialProperties.SetShader(shader);
|
||||
materialProperties.AddOrGetProperty<MaterialKeywordProperty>("DECAL_BASE_NORMAL").value = useBaseNormal;
|
||||
materialProperties.Load(node);
|
||||
|
||||
// handle texture tiling parameters
|
||||
var tileString = node.GetValue("tile");
|
||||
if (!string.IsNullOrEmpty(tileString)) {
|
||||
var tileValid = ParseExtensions.TryParseRect(tileString, out tileRect);
|
||||
if (!tileValid) throw new FormatException($"Invalid rect value for tile '{tileString}'");
|
||||
}
|
||||
|
||||
if (tileRect.x >= 0) {
|
||||
materialProperties.UpdateTile(tileRect);
|
||||
}
|
||||
else if (tileIndex >= 0) {
|
||||
materialProperties.UpdateTile(tileIndex, tileSize);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void UpdateMaterials() {
|
||||
materialProperties.UpdateMaterials();
|
||||
materialProperties.SetOpacity(opacity);
|
||||
materialProperties.SetCutoff(cutoff);
|
||||
if (useBaseNormal) {
|
||||
materialProperties.SetWear(wear);
|
||||
/// Setup decal by calling update functions relevent for the current situation
|
||||
protected virtual void SetupDecal() {
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
// Update tweakables in editor mode
|
||||
UpdateTweakables();
|
||||
}
|
||||
|
||||
_decalMaterial = materialProperties.DecalMaterial;
|
||||
_previewMaterial = materialProperties.PreviewMaterial;
|
||||
|
||||
if (!_isAttached) decalFrontTransform.GetComponent<MeshRenderer>().material = _previewMaterial;
|
||||
}
|
||||
|
||||
protected void UpdateTargets() {
|
||||
if (_targets == null) {
|
||||
_targets = new List<ProjectionTarget>();
|
||||
} else {
|
||||
_targets.Clear();
|
||||
if (HighLogic.LoadedSceneIsGame) {
|
||||
UpdateAll();
|
||||
}
|
||||
else {
|
||||
scale = defaultScale;
|
||||
depth = defaultDepth;
|
||||
opacity = defaultOpacity;
|
||||
cutoff = defaultCutoff;
|
||||
wear = defaultWear;
|
||||
|
||||
// find all valid renderers
|
||||
var renderers = part.parent.FindModelComponents<MeshRenderer>();
|
||||
foreach (var renderer in renderers) {
|
||||
// skip disabled renderers
|
||||
if (renderer.gameObject.activeInHierarchy == false) continue;
|
||||
UpdateAll();
|
||||
|
||||
// skip blacklisted shaders
|
||||
if (DecalConfig.IsBlacklisted(renderer.material.shader)) continue;
|
||||
|
||||
var meshFilter = renderer.GetComponent<MeshFilter>();
|
||||
if (meshFilter == null) continue; // object has a meshRenderer with no filter, invalid
|
||||
var mesh = meshFilter.mesh;
|
||||
if (mesh == null) continue; // object has a null mesh, invalid
|
||||
|
||||
// create new ProjectionTarget to represent the renderer
|
||||
var target = new ProjectionTarget(renderer, mesh);
|
||||
|
||||
// add the target to the list
|
||||
_targets.Add(target);
|
||||
// QUEUE PART FOR ICON FIXING IN VAB
|
||||
DecalIconFixer.QueuePart(part.name);
|
||||
}
|
||||
}
|
||||
|
||||
/// Update decal editor tweakables
|
||||
protected virtual void UpdateTweakables() {
|
||||
// setup tweakable fields
|
||||
var scaleField = Fields[nameof(scale)];
|
||||
@ -514,6 +466,7 @@ namespace ConformalDecals {
|
||||
var opacityField = Fields[nameof(opacity)];
|
||||
var cutoffField = Fields[nameof(cutoff)];
|
||||
var wearField = Fields[nameof(wear)];
|
||||
var multiprojectField = Fields[nameof(projectMultiple)];
|
||||
|
||||
scaleField.guiActiveEditor = scaleAdjustable;
|
||||
depthField.guiActiveEditor = depthAdjustable;
|
||||
@ -531,7 +484,7 @@ namespace ConformalDecals {
|
||||
scaleEditor.minValue = minValue;
|
||||
scaleEditor.maxValue = maxValue;
|
||||
scaleEditor.stepIncrement = 0.01f; //1cm
|
||||
scaleEditor.onFieldChanged = OnSizeTweakEvent;
|
||||
scaleEditor.onFieldChanged = OnProjectionTweakEvent;
|
||||
}
|
||||
|
||||
if (depthAdjustable) {
|
||||
@ -542,7 +495,7 @@ namespace ConformalDecals {
|
||||
depthEditor.minValue = minValue;
|
||||
depthEditor.maxValue = maxValue;
|
||||
depthEditor.stepIncrement = 0.01f; //1cm
|
||||
depthEditor.onFieldChanged = OnSizeTweakEvent;
|
||||
depthEditor.onFieldChanged = OnProjectionTweakEvent;
|
||||
}
|
||||
|
||||
if (opacityAdjustable) {
|
||||
@ -579,15 +532,145 @@ namespace ConformalDecals {
|
||||
wearEditor.stepIncrement = (maxValue - minValue) / steps;
|
||||
wearEditor.onFieldChanged = OnMaterialTweakEvent;
|
||||
}
|
||||
|
||||
var multiprojectEditor = (UI_Toggle) multiprojectField.uiControlEditor;
|
||||
multiprojectEditor.onFieldChanged = OnProjectionTweakEvent;
|
||||
}
|
||||
|
||||
/// Updates textures, materials, scale and targets
|
||||
protected virtual void UpdateAll() {
|
||||
UpdateTextures();
|
||||
UpdateMaterials();
|
||||
UpdateProjection();
|
||||
UpdateTargets();
|
||||
}
|
||||
|
||||
/// Update decal textures
|
||||
protected virtual void UpdateTextures() { }
|
||||
|
||||
/// Update decal materials
|
||||
protected virtual void UpdateMaterials() {
|
||||
materialProperties.UpdateMaterials();
|
||||
materialProperties.SetOpacity(opacity);
|
||||
materialProperties.SetCutoff(cutoff);
|
||||
if (useBaseNormal) {
|
||||
materialProperties.SetWear(wear);
|
||||
}
|
||||
|
||||
_decalMaterial = materialProperties.DecalMaterial;
|
||||
_previewMaterial = materialProperties.PreviewMaterial;
|
||||
|
||||
if (!_isAttached) decalFrontTransform.GetComponent<MeshRenderer>().material = _previewMaterial;
|
||||
}
|
||||
|
||||
/// Update decal scale and projection
|
||||
protected void UpdateProjection() {
|
||||
|
||||
// Update scale and depth
|
||||
scale = Mathf.Max(0.01f, scale);
|
||||
depth = Mathf.Max(0.01f, depth);
|
||||
var aspectRatio = Mathf.Max(0.01f, materialProperties.AspectRatio);
|
||||
Vector2 size;
|
||||
|
||||
switch (scaleMode) {
|
||||
default:
|
||||
case DecalScaleMode.HEIGHT:
|
||||
size = new Vector2(scale / aspectRatio, scale);
|
||||
break;
|
||||
case DecalScaleMode.WIDTH:
|
||||
size = new Vector2(scale, scale * aspectRatio);
|
||||
break;
|
||||
case DecalScaleMode.AVERAGE:
|
||||
var width1 = 2 * scale / (1 + aspectRatio);
|
||||
size = new Vector2(width1, width1 * aspectRatio);
|
||||
break;
|
||||
case DecalScaleMode.AREA:
|
||||
var width2 = Mathf.Sqrt(scale / aspectRatio);
|
||||
size = new Vector2(width2, width2 * aspectRatio);
|
||||
break;
|
||||
case DecalScaleMode.MINIMUM:
|
||||
if (aspectRatio > 1) goto case DecalScaleMode.WIDTH;
|
||||
else goto case DecalScaleMode.HEIGHT;
|
||||
case DecalScaleMode.MAXIMUM:
|
||||
if (aspectRatio > 1) goto case DecalScaleMode.HEIGHT;
|
||||
else goto case DecalScaleMode.WIDTH;
|
||||
}
|
||||
|
||||
// update material scale
|
||||
materialProperties.UpdateScale(size);
|
||||
|
||||
if (_isAttached) {
|
||||
// update orthogonal matrix
|
||||
_orthoMatrix = Matrix4x4.identity;
|
||||
_orthoMatrix[0, 3] = 0.5f;
|
||||
_orthoMatrix[1, 3] = 0.5f;
|
||||
|
||||
decalProjectorTransform.localScale = new Vector3(size.x, size.y, depth);
|
||||
}
|
||||
else {
|
||||
// rescale preview model
|
||||
decalModelTransform.localScale = new Vector3(size.x, size.y, (size.x + size.y) / 2);
|
||||
|
||||
// update back material scale
|
||||
if (updateBackScale) {
|
||||
backMaterial.SetTextureScale(PropertyIDs._MainTex, new Vector2(size.x * backTextureBaseScale.x, size.y * backTextureBaseScale.y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Called when updating decal targets
|
||||
protected void UpdateTargets() {
|
||||
if (!_isAttached) return;
|
||||
var projectionBounds = _boundsRenderer.bounds;
|
||||
|
||||
// disable all targets
|
||||
foreach (var target in _targets.Values) {
|
||||
target.enabled = false;
|
||||
}
|
||||
|
||||
// collect list of potential targets
|
||||
IEnumerable<Part> targetParts;
|
||||
if (projectMultiple) {
|
||||
targetParts = HighLogic.LoadedSceneIsFlight ? part.vessel.parts : EditorLogic.fetch.ship.parts;
|
||||
}
|
||||
else {
|
||||
targetParts = new[] {part.parent};
|
||||
}
|
||||
|
||||
foreach (var targetPart in targetParts) {
|
||||
UpdatePartTarget(targetPart, projectionBounds);
|
||||
}
|
||||
}
|
||||
|
||||
protected void UpdatePartTarget(Part targetPart, Bounds projectionBounds) {
|
||||
if (targetPart.GetComponent<ModuleConformalDecal>() != null) return; // skip other decals
|
||||
|
||||
this.Log($"Updating projection onto part {targetPart.name}");
|
||||
|
||||
if (!_targets.TryGetValue(targetPart, out var target)) {
|
||||
var rendererList = targetPart.FindModelComponents<MeshRenderer>();
|
||||
|
||||
if (rendererList.Any(o => projectionBounds.Intersects(o.bounds))) {
|
||||
target = new ProjectionPartTarget(targetPart, useBaseNormal);
|
||||
_targets.Add(targetPart, target);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.Log($"valid target: {targetPart.name}");
|
||||
|
||||
target.Project(_orthoMatrix, decalProjectorTransform, projectionBounds);
|
||||
}
|
||||
|
||||
/// Render the decal
|
||||
public void Render(Camera camera) {
|
||||
if (!_isAttached) return;
|
||||
|
||||
|
||||
// render on each target object
|
||||
foreach (var target in _targets) {
|
||||
if (ReferenceEquals(target.target, null)) _targets.Remove(target);
|
||||
else target.Render(_decalMaterial, part.mpb, camera);
|
||||
foreach (var target in _targets.Values) {
|
||||
target.Render(_decalMaterial, part.mpb, camera);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using ConformalDecals.Util;
|
||||
using ConformalDecals.MaterialProperties;
|
||||
using UniLinq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals {
|
||||
@ -9,7 +10,8 @@ namespace ConformalDecals {
|
||||
|
||||
[KSPField(isPersistant = true)] public bool useCustomFlag;
|
||||
|
||||
// The URL of the flag for the current mission or agency
|
||||
private MaterialTextureProperty _flagTextureProperty;
|
||||
|
||||
public string MissionFlagUrl {
|
||||
get {
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
@ -20,116 +22,74 @@ namespace ConformalDecals {
|
||||
return string.IsNullOrEmpty(part.flagURL) ? HighLogic.CurrentGame.flagURL : part.flagURL;
|
||||
}
|
||||
|
||||
// If we are not in game, use the default flag (for icon rendering)
|
||||
return DefaultFlag;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnLoad(ConfigNode node) {
|
||||
base.OnLoad(node);
|
||||
|
||||
// Since OnLoad is called for all modules, we only need to update this module
|
||||
// Updating symmetry counterparts would be redundent
|
||||
UpdateFlag();
|
||||
}
|
||||
|
||||
public override void OnStart(StartState state) {
|
||||
base.OnStart(state);
|
||||
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
// Register flag change event
|
||||
if (HighLogic.LoadedSceneIsGame) {
|
||||
GameEvents.onMissionFlagSelect.Add(OnEditorFlagSelected);
|
||||
|
||||
// Register reset button event
|
||||
Events[nameof(ResetFlag)].guiActiveEditor = useCustomFlag;
|
||||
}
|
||||
|
||||
// Since OnStart is called for all modules, we only need to update this module
|
||||
// Updating symmetry counterparts would be redundent
|
||||
UpdateFlag();
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
Events[nameof(ResetFlag)].guiActiveEditor = useCustomFlag;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDestroy() {
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
// Unregister flag change event
|
||||
GameEvents.onMissionFlagSelect.Remove(OnEditorFlagSelected);
|
||||
}
|
||||
|
||||
GameEvents.onMissionFlagSelect.Remove(OnEditorFlagSelected);
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
[KSPEvent(guiActive = false, guiActiveEditor = true, guiName = "#LOC_ConformalDecals_gui-select-flag")]
|
||||
public void SelectFlag() {
|
||||
// Button for selecting a flag
|
||||
// This is a bit of a hack to bring up the stock flag selection menu
|
||||
// When its done, it calls OnCustomFlagSelected()
|
||||
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
var flagBrowser = (Instantiate((Object) (new FlagBrowserGUIButton(null, null, null, null)).FlagBrowserPrefab) as GameObject).GetComponent<FlagBrowser>();
|
||||
flagBrowser.OnFlagSelected = OnCustomFlagSelected;
|
||||
var flagBrowser = (Instantiate((Object) (new FlagBrowserGUIButton(null, null, null, null)).FlagBrowserPrefab) as GameObject)?.GetComponent<FlagBrowser>();
|
||||
if (flagBrowser is { }) flagBrowser.OnFlagSelected = OnCustomFlagSelected;
|
||||
}
|
||||
|
||||
[KSPEvent(guiActive = false, guiActiveEditor = true, guiName = "#LOC_ConformalDecals_gui-reset-flag")]
|
||||
public void ResetFlag() {
|
||||
|
||||
// we are no longer using a custom flag, so instead use the mission or agency flag
|
||||
useCustomFlag = false;
|
||||
flagUrl = "Mission";
|
||||
UpdateFlag(true);
|
||||
|
||||
// disable the reset button, since it no longer makes sense
|
||||
Events[nameof(ResetFlag)].guiActiveEditor = false;
|
||||
flagUrl = MissionFlagUrl;
|
||||
useCustomFlag = false;
|
||||
UpdateAll();
|
||||
foreach (var decal in part.symmetryCounterparts.Select(o => o.GetComponent<ModuleConformalFlag>())) {
|
||||
decal.Events[nameof(ResetFlag)].guiActiveEditor = false;
|
||||
decal.flagUrl = flagUrl;
|
||||
decal.useCustomFlag = false;
|
||||
decal.UpdateAll();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCustomFlagSelected(FlagBrowser.FlagEntry newFlagEntry) {
|
||||
// Callback for when a flag is selected in the menu spawned by SelectFlag()
|
||||
|
||||
// we are now using a custom flag with the URL of the new flag entry
|
||||
useCustomFlag = true;
|
||||
flagUrl = newFlagEntry.textureInfo.name;
|
||||
UpdateFlag(true);
|
||||
|
||||
// make sure the reset button is now available
|
||||
Events[nameof(ResetFlag)].guiActiveEditor = true;
|
||||
flagUrl = newFlagEntry.textureInfo.name;
|
||||
useCustomFlag = true;
|
||||
UpdateAll();
|
||||
|
||||
foreach (var decal in part.symmetryCounterparts.Select(o => o.GetComponent<ModuleConformalFlag>())) {
|
||||
decal.Events[nameof(ResetFlag)].guiActiveEditor = true;
|
||||
decal.flagUrl = flagUrl;
|
||||
decal.useCustomFlag = true;
|
||||
decal.UpdateAll();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEditorFlagSelected(string newFlagUrl) {
|
||||
if (!useCustomFlag) {
|
||||
flagUrl = newFlagUrl;
|
||||
// Since this callback is called for all modules, we only need to update this module
|
||||
// Updating symmetry counterparts would be redundent
|
||||
UpdateFlag();
|
||||
}
|
||||
if (!useCustomFlag) UpdateAll();
|
||||
}
|
||||
|
||||
// Update the displayed flag texture for this decal or optionally any symmetry counterparts
|
||||
private void UpdateFlag(bool recursive = false) {
|
||||
// get the decal material property for the decal texture
|
||||
var textureProperty = materialProperties.AddOrGetTextureProperty("_Decal", true);
|
||||
protected override void UpdateTextures() {
|
||||
_flagTextureProperty ??= materialProperties.AddOrGetTextureProperty("_Decal", true);
|
||||
|
||||
string textureURL = useCustomFlag ? flagUrl : MissionFlagUrl;
|
||||
textureProperty.TextureUrl = textureURL;
|
||||
|
||||
if (DecalConfig.AspectRatios.ContainsKey(textureURL)) {
|
||||
var ratio = DecalConfig.AspectRatios[textureURL];
|
||||
this.Log($"Overriding aspect ratio for {textureURL} with {ratio}");
|
||||
textureProperty.AspectRatio = ratio;
|
||||
} else {
|
||||
textureProperty.AspectRatio = -1.0f;
|
||||
base.UpdateTextures();
|
||||
if (useCustomFlag) {
|
||||
_flagTextureProperty.TextureUrl = flagUrl;
|
||||
}
|
||||
|
||||
UpdateMaterials();
|
||||
UpdateScale();
|
||||
|
||||
if (recursive) {
|
||||
// for each symmetry counterpart, copy this part's properties and update it in turn
|
||||
foreach (var counterpart in part.symmetryCounterparts) {
|
||||
var decal = counterpart.GetComponent<ModuleConformalFlag>();
|
||||
|
||||
decal.useCustomFlag = useCustomFlag;
|
||||
decal.flagUrl = flagUrl;
|
||||
decal.UpdateFlag();
|
||||
}
|
||||
else {
|
||||
_flagTextureProperty.TextureUrl = MissionFlagUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using ConformalDecals.Text;
|
||||
using ConformalDecals.UI;
|
||||
using ConformalDecals.Util;
|
||||
using TMPro;
|
||||
using UniLinq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals {
|
||||
@ -89,41 +90,11 @@ namespace ConformalDecals {
|
||||
private MaterialColorProperty _outlineColorProperty;
|
||||
private MaterialFloatProperty _outlineWidthProperty;
|
||||
|
||||
private DecalText _currentText;
|
||||
private DecalText _currentText;
|
||||
|
||||
public override void OnLoad(ConfigNode node) {
|
||||
base.OnLoad(node);
|
||||
|
||||
string textRaw = "";
|
||||
if (ParseUtil.ParseStringIndirect(ref textRaw, node, "text")) {
|
||||
text = WebUtility.UrlDecode(textRaw);
|
||||
}
|
||||
|
||||
string fontName = "";
|
||||
if (ParseUtil.ParseStringIndirect(ref fontName, node, "fontName")) {
|
||||
font = DecalConfig.GetFont(fontName);
|
||||
}
|
||||
else if (font == null) font = DecalConfig.GetFont("Calibri SDF");
|
||||
|
||||
int styleInt = 0;
|
||||
if (ParseUtil.ParseIntIndirect(ref styleInt, node, "style")) {
|
||||
style = (FontStyles) styleInt;
|
||||
}
|
||||
|
||||
ParseUtil.ParseColor32Indirect(ref fillColor, node, "fillColor");
|
||||
ParseUtil.ParseColor32Indirect(ref outlineColor, node, "outlineColor");
|
||||
|
||||
if (HighLogic.LoadedSceneIsGame) {
|
||||
// For some reason, rendering doesnt work right on the first frame a scene is loaded
|
||||
// So delay any rendering until the next frame when called in OnLoad
|
||||
// This is probably a problem with Unity, not KSP
|
||||
StartCoroutine(UpdateTextLate());
|
||||
}
|
||||
else {
|
||||
UpdateText();
|
||||
}
|
||||
}
|
||||
// EVENTS
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSave(ConfigNode node) {
|
||||
node.AddValue("text", WebUtility.UrlEncode(text));
|
||||
node.AddValue("fontName", font.Name);
|
||||
@ -147,13 +118,23 @@ namespace ConformalDecals {
|
||||
}
|
||||
|
||||
public void OnTextUpdate(string newText, DecalFont newFont, FontStyles newStyle, bool newVertical, float newLineSpacing, float newCharSpacing) {
|
||||
this.text = newText;
|
||||
this.font = newFont;
|
||||
this.style = newStyle;
|
||||
this.vertical = newVertical;
|
||||
this.lineSpacing = newLineSpacing;
|
||||
this.charSpacing = newCharSpacing;
|
||||
UpdateText(true);
|
||||
text = newText;
|
||||
font = newFont;
|
||||
style = newStyle;
|
||||
vertical = newVertical;
|
||||
lineSpacing = newLineSpacing;
|
||||
charSpacing = newCharSpacing;
|
||||
UpdateAll();
|
||||
|
||||
foreach (var decal in part.symmetryCounterparts.Select(o => o.GetComponent<ModuleConformalText>())) {
|
||||
decal.text = newText;
|
||||
decal.font = newFont;
|
||||
decal.style = newStyle;
|
||||
decal.vertical = newVertical;
|
||||
decal.lineSpacing = newLineSpacing;
|
||||
decal.charSpacing = newCharSpacing;
|
||||
decal.UpdateAll();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnFillColorUpdate(Color rgb, Util.ColorHSV hsv) {
|
||||
@ -227,7 +208,7 @@ namespace ConformalDecals {
|
||||
if (_textEntryController != null) _textEntryController.Close();
|
||||
if (_fillColorPickerController != null) _fillColorPickerController.Close();
|
||||
if (_outlineColorPickerController != null) _outlineColorPickerController.Close();
|
||||
|
||||
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
@ -240,45 +221,70 @@ namespace ConformalDecals {
|
||||
base.OnDetach();
|
||||
}
|
||||
|
||||
private IEnumerator UpdateTextLate() {
|
||||
yield return null;
|
||||
UpdateText();
|
||||
// FUNCTIONS
|
||||
|
||||
protected override void LoadDecal(ConfigNode node) {
|
||||
base.LoadDecal(node);
|
||||
|
||||
string textRaw = "";
|
||||
if (ParseUtil.ParseStringIndirect(ref textRaw, node, "text")) {
|
||||
text = WebUtility.UrlDecode(textRaw);
|
||||
}
|
||||
|
||||
string fontName = "";
|
||||
if (ParseUtil.ParseStringIndirect(ref fontName, node, "fontName")) {
|
||||
font = DecalConfig.GetFont(fontName);
|
||||
}
|
||||
else if (font == null) font = DecalConfig.GetFont("Calibri SDF");
|
||||
|
||||
int styleInt = 0;
|
||||
if (ParseUtil.ParseIntIndirect(ref styleInt, node, "style")) {
|
||||
style = (FontStyles) styleInt;
|
||||
}
|
||||
|
||||
ParseUtil.ParseColor32Indirect(ref fillColor, node, "fillColor");
|
||||
ParseUtil.ParseColor32Indirect(ref outlineColor, node, "outlineColor");
|
||||
}
|
||||
|
||||
private void UpdateText(bool recursive = false) {
|
||||
// Render text
|
||||
var newText = new DecalText(text, font, style, vertical, lineSpacing, charSpacing);
|
||||
var output = TextRenderer.UpdateText(_currentText, newText);
|
||||
|
||||
// update the _currentText state variable
|
||||
// this is the ONLY place this variable should be set! otherwise the current state is lost
|
||||
_currentText = newText;
|
||||
protected override void SetupDecal() {
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
// Update tweakables in editor mode
|
||||
UpdateTweakables();
|
||||
}
|
||||
|
||||
// Update the texture with the new rendered output
|
||||
UpdateTexture(output);
|
||||
if (HighLogic.LoadedSceneIsGame) {
|
||||
// For some reason text rendering fails on the first frame of a scene, so this is my workaround
|
||||
StartCoroutine(UpdateTextLate());
|
||||
}
|
||||
else {
|
||||
scale = defaultScale;
|
||||
depth = defaultDepth;
|
||||
opacity = defaultOpacity;
|
||||
cutoff = defaultCutoff;
|
||||
wear = defaultWear;
|
||||
|
||||
// If recursive, copy parameters to other parts and perform the same operation
|
||||
if (recursive) {
|
||||
foreach (var counterpart in part.symmetryCounterparts) {
|
||||
var decal = counterpart.GetComponent<ModuleConformalText>();
|
||||
decal.text = text;
|
||||
decal.font = font;
|
||||
decal.style = style;
|
||||
decal.vertical = vertical;
|
||||
decal.charSpacing = charSpacing;
|
||||
decal.lineSpacing = lineSpacing;
|
||||
UpdateTextures();
|
||||
UpdateMaterials();
|
||||
UpdateProjection();
|
||||
|
||||
decal.UpdateText();
|
||||
}
|
||||
// QUEUE PART FOR ICON FIXING IN VAB
|
||||
DecalIconFixer.QueuePart(part.name);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateTexture(TextRenderOutput output) {
|
||||
private IEnumerator UpdateTextLate() {
|
||||
yield return null;
|
||||
UpdateAll();
|
||||
}
|
||||
|
||||
protected override void UpdateTextures() {
|
||||
// Render text
|
||||
var newText = new DecalText(text, font, style, vertical, lineSpacing, charSpacing);
|
||||
var output = TextRenderer.UpdateText(_currentText, newText);
|
||||
_currentText = newText;
|
||||
|
||||
_decalTextureProperty.Texture = output.Texture;
|
||||
_decalTextureProperty.SetTile(output.Window);
|
||||
|
||||
UpdateMaterials();
|
||||
UpdateScale();
|
||||
}
|
||||
|
||||
protected override void UpdateMaterials() {
|
||||
|
93
Source/ConformalDecals/ProjectionMeshTarget.cs
Normal file
93
Source/ConformalDecals/ProjectionMeshTarget.cs
Normal file
@ -0,0 +1,93 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace ConformalDecals {
|
||||
public class ProjectionMeshTarget : IProjectionTarget {
|
||||
public const string NodeName = "MESH_TARGET";
|
||||
|
||||
// enabled flag
|
||||
public bool enabled;
|
||||
|
||||
// Target object data
|
||||
public readonly Transform target;
|
||||
public readonly Transform root;
|
||||
public readonly Mesh mesh;
|
||||
public readonly MeshRenderer renderer;
|
||||
|
||||
// Projection data
|
||||
private Matrix4x4 _decalMatrix;
|
||||
private Vector3 _decalNormal;
|
||||
private Vector3 _decalTangent;
|
||||
|
||||
// property block
|
||||
private readonly MaterialPropertyBlock _decalMPB;
|
||||
|
||||
public ProjectionMeshTarget(Transform target, Transform root, MeshRenderer renderer, Mesh mesh, bool useBaseNormal) {
|
||||
this.root = root;
|
||||
this.target = target;
|
||||
this.renderer = renderer;
|
||||
this.mesh = mesh;
|
||||
_decalMPB = new MaterialPropertyBlock();
|
||||
|
||||
SetNormalMap(renderer.sharedMaterial, useBaseNormal);
|
||||
}
|
||||
|
||||
private void SetNormalMap(Material targetMaterial, bool useBaseNormal) {
|
||||
if (useBaseNormal && targetMaterial.HasProperty(DecalPropertyIDs._BumpMap)) {
|
||||
_decalMPB.SetTexture(DecalPropertyIDs._BumpMap, targetMaterial.GetTexture(DecalPropertyIDs._BumpMap));
|
||||
|
||||
var normalScale = targetMaterial.GetTextureScale(DecalPropertyIDs._BumpMap);
|
||||
var normalOffset = targetMaterial.GetTextureOffset(DecalPropertyIDs._BumpMap);
|
||||
|
||||
_decalMPB.SetVector(DecalPropertyIDs._BumpMap_ST, new Vector4(normalScale.x, normalScale.y, normalOffset.x, normalOffset.y));
|
||||
}
|
||||
else {
|
||||
_decalMPB.SetTexture(DecalPropertyIDs._BumpMap, DecalConfig.BlankNormal);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Project(Matrix4x4 orthoMatrix, Transform projector, Bounds projectionBounds) {
|
||||
if (projectionBounds.Intersects(renderer.bounds)) {
|
||||
enabled = true;
|
||||
|
||||
var projectorToTargetMatrix = target.worldToLocalMatrix * projector.localToWorldMatrix;
|
||||
|
||||
_decalMatrix = orthoMatrix * projectorToTargetMatrix.inverse;
|
||||
_decalNormal = projectorToTargetMatrix.MultiplyVector(Vector3.back).normalized;
|
||||
_decalTangent = projectorToTargetMatrix.MultiplyVector(Vector3.right).normalized;
|
||||
|
||||
_decalMPB.SetMatrix(DecalPropertyIDs._ProjectionMatrix, _decalMatrix);
|
||||
_decalMPB.SetVector(DecalPropertyIDs._DecalNormal, _decalNormal);
|
||||
_decalMPB.SetVector(DecalPropertyIDs._DecalTangent, _decalTangent);
|
||||
}
|
||||
else {
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void Render(Material decalMaterial, MaterialPropertyBlock partMPB, Camera camera) {
|
||||
if (!enabled) return;
|
||||
|
||||
_decalMPB.SetFloat(PropertyIDs._RimFalloff, partMPB.GetFloat(PropertyIDs._RimFalloff));
|
||||
_decalMPB.SetColor(PropertyIDs._RimColor, partMPB.GetColor(PropertyIDs._RimColor));
|
||||
|
||||
Graphics.DrawMesh(mesh, target.localToWorldMatrix, decalMaterial, 0, camera, 0, _decalMPB, ShadowCastingMode.Off, true);
|
||||
}
|
||||
|
||||
public static bool ValidateTarget(Transform target, MeshRenderer renderer, MeshFilter filter) {
|
||||
if (renderer == null) return false;
|
||||
if (filter == null) return false;
|
||||
if (!target.gameObject.activeInHierarchy) return false;
|
||||
|
||||
var material = renderer.material;
|
||||
if (material == null) return false;
|
||||
if (DecalConfig.IsBlacklisted(material.shader)) return false;
|
||||
|
||||
if (filter.sharedMesh == null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
50
Source/ConformalDecals/ProjectionPartTarget.cs
Normal file
50
Source/ConformalDecals/ProjectionPartTarget.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals {
|
||||
public class ProjectionPartTarget : IProjectionTarget {
|
||||
public const string NodeName = "PART_TARGET";
|
||||
|
||||
// enabled flag
|
||||
public bool enabled;
|
||||
|
||||
public readonly Part part;
|
||||
public readonly List<ProjectionMeshTarget> meshTargets = new List<ProjectionMeshTarget>();
|
||||
|
||||
|
||||
public ProjectionPartTarget(Part part, bool useBaseNormal) {
|
||||
this.part = part;
|
||||
|
||||
foreach (var renderer in part.FindModelComponents<MeshRenderer>()) {
|
||||
var target = renderer.transform;
|
||||
var filter = target.GetComponent<MeshFilter>();
|
||||
|
||||
// check if the target has any missing data
|
||||
if (!ProjectionMeshTarget.ValidateTarget(target, renderer, filter)) continue;
|
||||
|
||||
// create new ProjectionTarget to represent the renderer
|
||||
var projectionTarget = new ProjectionMeshTarget(target, part.transform, renderer, filter.sharedMesh, useBaseNormal);
|
||||
|
||||
// add the target to the list
|
||||
meshTargets.Add(projectionTarget);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Project(Matrix4x4 orthoMatrix, Transform projector, Bounds projectionBounds) {
|
||||
enabled = false;
|
||||
foreach (var meshTarget in meshTargets) {
|
||||
enabled |= meshTarget.Project(orthoMatrix, projector, projectionBounds);
|
||||
}
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void Render(Material decalMaterial, MaterialPropertyBlock partMPB, Camera camera) {
|
||||
if (!enabled) return;
|
||||
|
||||
foreach (var target in meshTargets) {
|
||||
target.Render(decalMaterial, partMPB, camera);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace ConformalDecals {
|
||||
public class ProjectionTarget {
|
||||
// Target object data
|
||||
public readonly Transform target;
|
||||
|
||||
private readonly Renderer _targetRenderer;
|
||||
private readonly Mesh _targetMesh;
|
||||
private bool _projectionEnabled;
|
||||
|
||||
// property block
|
||||
private readonly MaterialPropertyBlock _decalMPB;
|
||||
|
||||
public ProjectionTarget(MeshRenderer targetRenderer, Mesh targetMesh) {
|
||||
target = targetRenderer.transform;
|
||||
_targetRenderer = targetRenderer;
|
||||
_targetMesh = targetMesh;
|
||||
_decalMPB = new MaterialPropertyBlock();
|
||||
}
|
||||
|
||||
public void Project(Matrix4x4 orthoMatrix, Transform projector, Bounds projectorBounds, bool useBaseNormal) {
|
||||
|
||||
if (projectorBounds.Intersects(_targetRenderer.bounds)) {
|
||||
_projectionEnabled = true;
|
||||
var targetMaterial = _targetRenderer.sharedMaterial;
|
||||
var projectorToTargetMatrix = target.worldToLocalMatrix * projector.localToWorldMatrix;
|
||||
|
||||
var projectionMatrix = orthoMatrix * projectorToTargetMatrix.inverse;
|
||||
var decalNormal = projectorToTargetMatrix.MultiplyVector(Vector3.back).normalized;
|
||||
var decalTangent = projectorToTargetMatrix.MultiplyVector(Vector3.right).normalized;
|
||||
|
||||
_decalMPB.SetMatrix(DecalPropertyIDs._ProjectionMatrix, projectionMatrix);
|
||||
_decalMPB.SetVector(DecalPropertyIDs._DecalNormal, decalNormal);
|
||||
_decalMPB.SetVector(DecalPropertyIDs._DecalTangent, decalTangent);
|
||||
|
||||
if (useBaseNormal && targetMaterial.HasProperty(DecalPropertyIDs._BumpMap)) {
|
||||
_decalMPB.SetTexture(DecalPropertyIDs._BumpMap, targetMaterial.GetTexture(DecalPropertyIDs._BumpMap));
|
||||
|
||||
var normalScale = targetMaterial.GetTextureScale(DecalPropertyIDs._BumpMap);
|
||||
var normalOffset = targetMaterial.GetTextureOffset(DecalPropertyIDs._BumpMap);
|
||||
|
||||
_decalMPB.SetVector(DecalPropertyIDs._BumpMap_ST, new Vector4(normalScale.x, normalScale.y, normalOffset.x, normalOffset.y));
|
||||
}
|
||||
else {
|
||||
_decalMPB.SetTexture(DecalPropertyIDs._BumpMap, DecalConfig.BlankNormal);
|
||||
}
|
||||
}
|
||||
else {
|
||||
_projectionEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Render(Material decalMaterial, MaterialPropertyBlock partMPB, Camera camera) {
|
||||
if (_projectionEnabled) {
|
||||
_decalMPB.SetFloat(PropertyIDs._RimFalloff, partMPB.GetFloat(PropertyIDs._RimFalloff));
|
||||
_decalMPB.SetColor(PropertyIDs._RimColor, partMPB.GetColor(PropertyIDs._RimColor));
|
||||
|
||||
Graphics.DrawMesh(_targetMesh, target.localToWorldMatrix, decalMaterial, 0, camera, 0, _decalMPB, ShadowCastingMode.Off, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -46,21 +46,25 @@ namespace ConformalDecals.Text {
|
||||
public bool SmallCapsMask => (_fontStyleMask & FontStyles.SmallCaps) != 0;
|
||||
|
||||
|
||||
public DecalFont(ConfigNode node, IEnumerable<TMP_FontAsset> fontAssets) {
|
||||
public static DecalFont Parse(ConfigNode node, IEnumerable<TMP_FontAsset> fontAssets) {
|
||||
if (node == null) throw new ArgumentNullException(nameof(node));
|
||||
if (fontAssets == null) throw new ArgumentNullException(nameof(fontAssets));
|
||||
|
||||
var font = ScriptableObject.CreateInstance<DecalFont>();
|
||||
|
||||
var name = ParseUtil.ParseString(node, "name");
|
||||
_fontAsset = fontAssets.First(o => o.name == name);
|
||||
if (FontAsset == null) {
|
||||
var fontAsset = fontAssets.First(o => o.name == name);
|
||||
if (fontAsset == null) {
|
||||
throw new FormatException($"Could not find font asset named {name}");
|
||||
}
|
||||
|
||||
_title = ParseUtil.ParseString(node, "title", true, name);
|
||||
_fontStyle = (FontStyles) ParseUtil.ParseInt(node, "style", true);
|
||||
_fontStyleMask = (FontStyles) ParseUtil.ParseInt(node, "styleMask", true);
|
||||
}
|
||||
font._fontAsset = fontAsset;
|
||||
font._title = ParseUtil.ParseString(node, "title", true, name);
|
||||
font._fontStyle = (FontStyles) ParseUtil.ParseInt(node, "style", true);
|
||||
font._fontStyleMask = (FontStyles) ParseUtil.ParseInt(node, "styleMask", true);
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
public void SetupSample(TMP_Text tmp) {
|
||||
if (tmp == null) throw new ArgumentNullException(nameof(tmp));
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using ConformalDecals.Util;
|
||||
using TMPro;
|
||||
using UniLinq;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UniLinq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals.Util {
|
||||
@ -74,6 +75,14 @@ namespace ConformalDecals.Util {
|
||||
return ParseValueIndirect(ref value, node, valueName, int.TryParse);
|
||||
}
|
||||
|
||||
public static uint ParseUint(ConfigNode node, string valueName, bool isOptional = false, uint defaultValue = 0) {
|
||||
return ParseValue(node, valueName, uint.TryParse, isOptional, defaultValue);
|
||||
}
|
||||
|
||||
public static bool ParseUintIndirect(ref uint value, ConfigNode node, string valueName) {
|
||||
return ParseValueIndirect(ref value, node, valueName, uint.TryParse);
|
||||
}
|
||||
|
||||
public static Color32 ParseColor32(ConfigNode node, string valueName, bool isOptional = false, Color32 defaultValue = default) {
|
||||
return ParseValue(node, valueName, TryParseColor32, isOptional, defaultValue);
|
||||
}
|
||||
@ -106,6 +115,15 @@ namespace ConformalDecals.Util {
|
||||
return ParseValueIndirect(ref value, node, valueName, ParseExtensions.TryParseVector3);
|
||||
}
|
||||
|
||||
public static Matrix4x4 ParseMatrix4x4(ConfigNode node, string valueName, bool isOptional = false, Matrix4x4 defaultValue = default) {
|
||||
return ParseValue(node, valueName, ParseUtil.TryParseMatrix4x4, isOptional, defaultValue);
|
||||
}
|
||||
|
||||
public static bool ParseMatrix4x4Indirect(ref Matrix4x4 value, ConfigNode node, string valueName) {
|
||||
return ParseValueIndirect(ref value, node, valueName, ParseUtil.TryParseMatrix4x4);
|
||||
|
||||
}
|
||||
|
||||
public static T ParseValue<T>(ConfigNode node, string valueName, TryParseDelegate<T> tryParse, bool isOptional = false, T defaultValue = default) {
|
||||
string valueString = node.GetValue(valueName);
|
||||
|
||||
@ -145,6 +163,26 @@ namespace ConformalDecals.Util {
|
||||
throw new FormatException($"Improperly formatted {typeof(T)} value for {valueName} : '{valueString}");
|
||||
}
|
||||
|
||||
public static bool TryParseMatrix4x4(string valueString, out Matrix4x4 value) {
|
||||
value = new Matrix4x4();
|
||||
|
||||
var split = valueString.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
|
||||
for (int i = 0; i < split.Length; i++) {
|
||||
split[i] = split[i].Trim();
|
||||
}
|
||||
|
||||
if (split.Length != 16) return false;
|
||||
int index = 0;
|
||||
for (int row = 0; row < 4; row++) {
|
||||
for (int col = 0; col < 4; col++) {
|
||||
if (!float.TryParse(split[index], out float component)) return false;
|
||||
value[row, col] = component;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool TryParseHexColor(string valueString, out Color32 value) {
|
||||
value = new Color32(0, 0, 0, byte.MaxValue);
|
||||
|
||||
|
115
changelog.txt
Normal file
115
changelog.txt
Normal file
@ -0,0 +1,115 @@
|
||||
v0.2.7
|
||||
------
|
||||
- Supported KSP versions: 1.8.x to 1.11.x
|
||||
- Notes:
|
||||
- Attaching decal parts in flight using engineer kerbals is not supported.
|
||||
- Fixes:
|
||||
- Fixed certain non-ascii strings not rendering correctly under certain circumstances.
|
||||
- Yet another attempted fix for the planet text glitch.
|
||||
|
||||
v0.2.6
|
||||
------
|
||||
- Fixes:
|
||||
- Fixed stock flags appearing stretched by forcing their aspect ratio to be correct.
|
||||
- Another attempted fix for the planet text glitch.
|
||||
|
||||
v0.2.5
|
||||
------
|
||||
- Fixes:
|
||||
- Fixed line spacing, character spacing, and vertical settings not applying to symmetry counterparts
|
||||
|
||||
v0.2.4
|
||||
------
|
||||
- Fixes:
|
||||
- Fixed red text appearing on planets due to KSP bug by clearing render textures afterwards.
|
||||
- Fixed fonts not saving correctly.
|
||||
- Changes:
|
||||
- Lowered step size for decal size and depth to 1cm.
|
||||
- Changed default max size to 5m.
|
||||
- Changed default text decal size to 0.2m
|
||||
- Text decals now show as a circle if they contain only whitespace.
|
||||
|
||||
v0.2.3
|
||||
------
|
||||
- Fixes:
|
||||
- Fixed TMP subobjects being deleted, causing fallback fonts to fail in some situations.
|
||||
- Started using URL-style encoding for text decals behind the scenes to prevent issues with certain characters.
|
||||
- Fixed text decals having zero size when they had only whitespace or an empty string.
|
||||
- Fixed decals having drag and causing issues when using FAR.
|
||||
- Fixed broken saving of text decals in certain circumstances.
|
||||
|
||||
v0.2.2
|
||||
------
|
||||
- Fixes:
|
||||
- Fixed corrupted text rendering when a vessel loads during a scene change.
|
||||
|
||||
v0.2.1
|
||||
------
|
||||
- Changes:
|
||||
- Pressing enter in the text entry window now types a newline.
|
||||
- Fixes:
|
||||
- Renamed font assetbundle. The old extension was causing the game to try to load it twice on Windows due to legacy compatability features.
|
||||
- Fixed text rendering on DirectX resulting in black boxes by using ARGB32 instead of RG16 for the render texture in DirectX.
|
||||
|
||||
v0.2.0
|
||||
------
|
||||
- New Parts:
|
||||
- CDL-3 Surface Base Decal: A set of conformal decals based on the symbols from the movie Moon (2009) designed by Gavin Rothery
|
||||
- CDL-T Custom Text Decal: A customizable text decal with a variety of fonts
|
||||
- Changes:
|
||||
- New ModuleConformalText module for customizable text
|
||||
- Text, font, and style can all be customized, as well as text fill and outline colors and widths
|
||||
- Same projection and opacity options as other conformal decals
|
||||
- New StandardText decal shader supporting the text module
|
||||
- Unified all decal shaders into a single "StandardDecal" shader with variants supporting any combination of bump, specular and emissive maps, plus SDF alphas.
|
||||
- Old shaders are remapped to Standard shader plus keywords automatically.
|
||||
- New SDF-based antialiasing for when decals extend to their borders, e.g. on opaque flags.
|
||||
- New "KEYWORD" material modifier, allowing for shader features to be enabled and disabled.
|
||||
- Material modifiers can now be removed in variants by setting `remove = true` inside them.
|
||||
- Fixes:
|
||||
- Fixed WIDTH and HEIGHT scale modes being flipped
|
||||
- Removed some debug log statements
|
||||
- Dependencies:
|
||||
- Updated ModuleManager to version 4.1.4
|
||||
|
||||
v0.1.4
|
||||
------
|
||||
- Supported KSP versions: 1.8.x to 1.10.x
|
||||
- Fixes:
|
||||
- Fixed decals rendering onto disabled B9PS part variants
|
||||
- Decals will still not update whan their parent part's B9PS variant is changed, both in flight and in the editor. This is known and awaiting a change to B9PS to be fixed.
|
||||
- Fixed decal bounds rendering as dark cubes when shadowed by EVE clouds.
|
||||
- Fixed decals being shadowed by EVE clouds, causing the part underneath to appear overly dark.
|
||||
|
||||
v0.1.3
|
||||
------
|
||||
Fixes:
|
||||
- Fixed decals being able to be scaled down to 0
|
||||
|
||||
Changes:
|
||||
- Made decal bounds no longer collide in flight, this is done by repurposing layer 31 (which is configurable in the ConformalDecals.cfg file)
|
||||
- Decals will now be unselectable in flight by default. This can be disabled with the `selectableInFlight` value in ConformalDecals.cfg, or in the module config itself.
|
||||
- Decal parts will now destroy themselves automatically when the parent part is destroyed
|
||||
- Small refactor of node parsing code
|
||||
- Colors can now be specified in hex (#RGB, #RGBA, #RRGGBB, or #RRGGBBAA) or using the colors specified in the XKCDColors class
|
||||
|
||||
v0.1.2
|
||||
------
|
||||
Fixes:
|
||||
- Disabled writing to the zbuffer in the decal bounds shader. Should fix any issues with Scatterer or EVE.
|
||||
|
||||
v0.1.1
|
||||
------
|
||||
Fixes:
|
||||
- Fixed flag decal not adjusting to new texture sizes immediately.
|
||||
- Fixed decal bounds being visible on launch.
|
||||
- Fixed decal bounds being visible in the part icon.
|
||||
|
||||
v0.1.0
|
||||
------
|
||||
Initial release!
|
||||
|
||||
New parts:
|
||||
- CDL-F Flag Decal: Conformal flag decal, which uses either the mission flag or a flag of your choosing.
|
||||
- CDL-1 Generic Decal: A set of conformal generic decals for planes and rockets
|
||||
- CDL-2 Semiotic Standard Decal: A set of conformal decals based on the Semiotic Standard for All Commercial Trans-Stellar Utility Lifter and Transport Spacecraft designed by Ron Cobb for the movie Alien
|
Reference in New Issue
Block a user