80 Commits
0.2.8 ... main

Author SHA1 Message Date
6db2d6b82a Release 0.2.14
### Fixed

- Fixed parts showing as all black with the Deferred Rendering mod
2024-06-24 19:12:41 -07:00
37715a46ab Fix for Deferred support
very basic, can be improved later
2024-06-24 19:12:27 -07:00
60cc0d76bb KSP 0.12.5 2024-05-17 21:02:33 -07:00
e7307f95e9 Fix title 2024-05-17 21:01:21 -07:00
88da55123b Fix syntax error in deploy script 2024-05-17 21:00:02 -07:00
eda04235c3 I hate bash 2024-05-17 20:52:00 -07:00
65031be081 Fix missing env variables and make it error if they don't exist 2024-05-17 20:42:01 -07:00
0c7f6dd628 Update KSP version in README.md 2024-05-16 19:32:11 -07:00
883c027a1a Upload bundle in release 2024-05-16 19:23:25 -07:00
d51b240c6c Use download-artifact@v4 2024-05-16 19:17:36 -07:00
91b5e584a6 Release 0.2.13
### Fixed

- Fixed flag decals sometimes not respecting image aspect ratio
2024-05-16 19:12:10 -07:00
44a5aec21e Update github actions workflow 2024-05-15 20:49:41 -07:00
8e0a26f17c Use self-hosted shabby 2024-05-15 20:35:48 -07:00
b48db63a27 Fix flag decals not respecting aspect ratio 2024-05-15 20:25:50 -07:00
c0d20f847d Update targets on an undo 2022-11-24 14:22:38 -08:00
36732ed4d4 Release 0.2.12
### 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
2022-10-31 00:15:36 -07:00
d3388a4dad better null checking 2022-10-31 00:05:31 -07:00
ece9d959fd flag aspect ratio overrides are now configurable
no longer hard coded to Squad/Flags
2022-10-30 23:58:55 -07:00
dfdf280564 Fix OnDestroy not being called 2022-10-30 21:03:27 -07:00
2cca6c37bb Update bundled Shabby to 0.3.0 2022-10-30 17:26:55 -07:00
c653c9efc8 Release 0.2.11
### 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
2022-10-29 18:15:13 -07:00
374fc8b753 Format changelog 2022-10-29 18:13:46 -07:00
88b2b4841a Merge pull request #38 from linuxgurugamer/main
Nullref fix and memory leak fix
2022-10-05 22:53:10 -07:00
b2da56b1ca A few more edits 2022-09-03 18:03:01 -04:00
14bc694588 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
2022-09-03 18:01:15 -04:00
7e1b993d20 Update README.md 2022-03-19 20:34:33 -07:00
f8d692352d Remove leftover files from old deploy system 2022-03-14 21:52:43 -07:00
fa4b799788 Run on create 2022-03-13 19:12:18 -07:00
970a69be11 Release 0.2.10
### 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
2022-03-13 18:45:14 -07:00
dddb7f09f3 make log message make a bit more sense 2022-03-13 18:43:00 -07:00
3cd229bc23 Fix decals not projecting when loading prefabs
• Add support for regex shader blacklisting
• Re-allow projecting onto transparentFX
2022-03-13 14:02:39 -07:00
4948818065 Remove Travis badge 2022-03-11 23:10:20 -08:00
036b084d34 Fix remote version file url 2022-03-11 22:49:03 -08:00
1e3addeb4d Include Harmony in build 2022-03-11 22:42:31 -08:00
47c70d3071 Fix actions 2022-03-11 22:36:19 -08:00
9955b9ce30 Don't version the Readme 2022-03-11 22:33:05 -08:00
32ddc54019 Release 0.2.9
### Fixed

- Fixed text decals breaking when used in symmetry
- Fixed decals projecting onto the TransparentFX layer, such as Waterfall plumes
2022-03-11 22:29:14 -08:00
ff262d55c8 Automatically fast-forward the release branch on release 2022-03-11 22:28:15 -08:00
d1f3d1fa55 Merge branch 'release' 2022-03-11 22:10:05 -08:00
2965633235 Update changelog 2022-03-11 22:02:10 -08:00
a82369e595 Merge branch 'hotfix' 2022-03-11 21:57:18 -08:00
16c4fa2b96 Github mandates a .txt extension for text files??? 2022-03-11 21:31:45 -08:00
591ec0aa74 Setup version URL from releases
this is going to 404 until the next release but oh well
2022-03-11 21:28:14 -08:00
210d326469 Last touches 2022-03-10 19:31:16 -08:00
dd405a21db Fix speeling 2022-03-10 19:05:26 -08:00
c40f700235 Fix both deployment steps
thanks @DasSkelett!
2022-03-10 18:39:36 -08:00
36cc896b2a Fix file 2022-03-09 22:07:32 -08:00
4c02e91dfd Fix spacedock login 2022-03-09 22:05:26 -08:00
41b15477fb More shenanigans 2022-03-09 22:03:06 -08:00
b61f71bc00 github why 2022-03-09 21:53:46 -08:00
74fe42a7ff why 2022-03-09 21:37:22 -08:00
7fa8969d5b wtf 2022-03-09 21:36:33 -08:00
21f8332d66 Fix publish and artifact handling 2022-03-09 21:22:05 -08:00
cb219a52c0 Don't try to validate other mods version info 2022-03-09 21:03:38 -08:00
f2f2100334 fix spelling 2022-03-09 21:00:27 -08:00
9bdb95527a Fix python dependencies 2022-03-09 20:58:17 -08:00
ad504ce4cc Download dependencies and simple deploy script 2022-03-09 20:57:10 -08:00
18ebbd7b4c Pesky commas 2022-03-08 23:54:23 -08:00
ba189f18c4 Clean up version file and add some logging 2022-03-08 23:52:40 -08:00
322aaa613e Add script for updating version 2022-03-08 23:43:33 -08:00
5443377bfe Descriptive artifact name 2022-03-07 00:29:39 -08:00
1ed6dc0f68 Fix path 2022-03-07 00:28:00 -08:00
90dec1b42a Simplify uploading and ensure Plugin directory exists 2022-03-07 00:24:46 -08:00
80da98d95a Fix DLL copy snippet 2022-03-07 00:17:21 -08:00
76016fbbf1 Case sensitivity is evil 2022-03-07 00:10:10 -08:00
53657b8fad Fix zip command and name the artefact 2022-03-07 00:08:43 -08:00
9d7502091c Upload build output 2022-03-07 00:06:16 -08:00
f788c25837 Remove DLL from repo 2022-03-07 00:06:07 -08:00
017110738b correct dll location 2022-03-06 23:52:03 -08:00
fd7134ece9 Actually use the right command 2022-03-06 23:52:03 -08:00
68ceacfef4 URL is case sensitive 2022-03-06 23:52:03 -08:00
a452844cd1 Start on build script 2022-03-06 23:52:03 -08:00
4b8d11e1de Use markdown changelog 2022-03-06 23:52:03 -08:00
8f888ee552 Remove travis config 2022-03-06 23:52:03 -08:00
95b99d1d42 Clean up text update function 2022-03-06 00:01:23 -08:00
ba6676b625 Hide NRE warning in Rider
its terrible but I've never seen it NRE so 🤷‍♂️
2022-03-05 23:44:59 -08:00
495441be06 Fix text not updating correctly in symmetry 2022-03-05 23:38:12 -08:00
8025a0a418 Ignore thumbnails 2022-02-24 23:33:34 -08:00
760609fae2 Refactor flag decal
Not exhaustively tested but shouldnt be different from before
2022-02-24 23:33:07 -08:00
ecc60751f7 Don't project onto TransparentFX layer 2021-12-25 23:15:15 -08:00
24 changed files with 974 additions and 335 deletions

23
.github/workflows/ff-release.yml vendored Normal file
View File

@ -0,0 +1,23 @@
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 Normal file
View File

@ -0,0 +1,142 @@
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 }}

4
.gitignore vendored
View File

@ -16,6 +16,9 @@ Temp/
GameData/ConformalDecals/Resources/Resources
GameData/ConformalDecals/Resources/*.manifest
# DLLs
GameData/ConformalDecals/Plugins
# Unity Project Files
PartTools.cfg
*.meta
@ -51,3 +54,4 @@ Source/ConformalDecals/bin
.idea
obj
*.swp
@thumbs

View File

@ -1 +0,0 @@
USE_SSM_CREDENTIALS: false

View File

@ -1,34 +0,0 @@
# 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.18.0.zip
zip: true
Shabby:
location: url
url: http://pileof.rocks/KSP/Shabby_v0.2.0.zip
zip: true
HarmonyKSP:
location: url
url: https://github.com/KSPModdingLibs/HarmonyKSP/releases/download/2.0.4.0/HarmonyKSP_2.0.4.0_for_KSP1.8+.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

View File

@ -1,25 +0,0 @@
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

View File

@ -104,8 +104,5 @@
ENDCG
}
// shadow casting support
UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
}
}

View File

@ -105,8 +105,5 @@
ENDCG
}
// shadow casting support
UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
}
}

229
CHANGELOG.md Normal file
View File

@ -0,0 +1,229 @@
# 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

View File

@ -0,0 +1,7 @@
// Prevent projection onto Waterfall plumes
CONFORMALDECALS:NEEDS[Waterfall] {
SHADERBLACKLIST {
shaderRegex = Waterfall/.*
}
}

View File

@ -4,21 +4,13 @@ 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 {
@ -57,4 +49,309 @@ 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
}
}

View File

@ -1,28 +1,24 @@
{
"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":8,
"BUILD":0
"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
},
"KSP_VERSION":
{
"MAJOR":1,
"MINOR":11,
"PATCH":0
"KSP_VERSION": {
"MAJOR": 1,
"MINOR": 12
},
"KSP_VERSION_MIN":{
"MAJOR":1,
"MINOR":8,
"PATCH":0
"KSP_VERSION_MIN": {
"MAJOR": 1,
"MINOR": 8
},
"KSP_VERSION_MAX":{
"MAJOR":1,
"MINOR":11,
"PATCH":99
"KSP_VERSION_MAX": {
"MAJOR": 1,
"MINOR": 12
}
}
}

View File

@ -1,5 +1,5 @@
# Conformal Decals v0.2.8
[![Build Status](https://travis-ci.com/drewcassidy/KSP-Conformal-Decals.svg?branch=release)](https://travis-ci.com/drewcassidy/KSP-Conformal-Decals) [![Art: CC BY-SA 4.0](https://img.shields.io/badge/Art%20License-CC%20BY--SA%204.0-orange.svg)](https://creativecommons.org/licenses/by-sa/4.0/) [![Code: GPL v3](https://img.shields.io/badge/Code%20License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
# Conformal Decals
[![Art: CC BY-SA 4.0](https://img.shields.io/badge/Art%20License-CC%20BY--SA%204.0-orange.svg)](https://creativecommons.org/licenses/by-sa/4.0/) [![Code: GPL v3](https://img.shields.io/badge/Code%20License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![CKAN: Indexed](https://img.shields.io/badge/CKAN-Indexed-brightgreen.svg)](https://github.com/KSP-CKAN/CKAN)
![Screenshot](http://pileof.rocks/KSP/images/ConformalDecalsHeader.png)
@ -8,7 +8,7 @@ Conformal Decals adds a set of decal stickers to KSP, as well as providing a fra
## Dependencies
Required:
- KSP (1.8.x to 1.10.x)
- KSP (1.8.x to 1.12.x)
- B9 Part Switch (2.18.0). Bundled with release.
- ModuleManager (4.1.4). Bundled with release.
- Shabby (0.2.0 unofficial build). Bundled with release.

61
Scripts/version.py Normal file
View File

@ -0,0 +1,61 @@
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()

View File

@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<?xml version="1.0" ?><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>0.2.8</AssemblyVersion>
<AssemblyVersion>9.9.9</AssemblyVersion>
</PropertyGroup>
<ItemGroup>
@ -36,21 +36,20 @@
</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>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="/bin/cp -v '$(OutDir)ConformalDecals.dll' '$(SolutionDir)../GameData/ConformalDecals/Plugins'" IgnoreExitCode="true" />
<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-->
</Target>
</Project>
</Project>

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using ConformalDecals.Text;
using ConformalDecals.Util;
using TMPro;
@ -10,9 +11,11 @@ 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;
@ -50,15 +53,25 @@ namespace ConformalDecals {
public static bool SelectableInFlight => _selectableInFlight;
public static IEnumerable<DecalFont> Fonts => _fontList.Values;
public static DecalFont FallbackFont { get; private set; }
public static Dictionary<string, float> AspectRatios => _aspectRatios;
public static bool IsBlacklisted(Shader shader) {
return IsBlacklisted(shader.name);
}
public static bool IsBlacklisted(string shaderName) {
return _shaderBlacklist.Contains(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;
}
public static bool IsLegacy(string shaderName, out string newShader, out string[] keywords) {
@ -76,8 +89,7 @@ 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");
}
}
@ -91,16 +103,29 @@ 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);
_fontList.Add(font.Name, font);
} catch (Exception e) {
Debug.LogException(e);
}
catch (Exception 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) {
Debug.LogException(e);
}
}
@ -128,13 +153,15 @@ 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);
}
}

View File

@ -75,7 +75,12 @@ namespace ConformalDecals.MaterialProperties {
}
}
public float AspectRatio => MainTexture == null ? 1 : MainTexture.AspectRatio;
public float AspectRatio {
get => MainTexture == null ? 1 : MainTexture.AspectRatio;
set {
if (MainTexture != null) MainTexture.AspectRatio = value;
}
}
public void OnBeforeSerialize() {
if (_materialProperties == null) throw new SerializationException("Tried to serialize an uninitialized MaterialPropertyCollection");
@ -136,8 +141,7 @@ 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;
}
}
@ -145,8 +149,7 @@ 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);
}
}
@ -156,9 +159,10 @@ namespace ConformalDecals.MaterialProperties {
foreach (var material in Materials) {
property.Remove(material);
}
_materialProperties.Remove(propertyName);
Destroy(property);
return true;
}
@ -204,8 +208,7 @@ namespace ConformalDecals.MaterialProperties {
if (_shader == null) {
Logging.Log("Using default decal shader");
shaderName = "ConformalDecals/Decal/Standard";
}
else {
} else {
return;
}
}

View File

@ -19,6 +19,8 @@ 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;
@ -43,10 +45,12 @@ 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;
return MaskedHeight / (float) MaskedWidth;
}
set => _aspectRatioOverride = value;
}
public override void ParseNode(ConfigNode node) {
@ -64,7 +68,7 @@ namespace ConformalDecals.MaterialProperties {
if (ParseUtil.ParseStringIndirect(ref _textureUrl, node, "textureUrl")) {
_texture = LoadTexture(_textureUrl, isNormal);
}
if (_texture == null) {
_texture = isNormal ? DecalConfig.BlankNormal : Texture2D.whiteTexture;
}

View File

@ -35,6 +35,8 @@ 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);
@ -122,8 +124,7 @@ namespace ConformalDecals {
if (materialProperties == null) {
materialProperties = ScriptableObject.CreateInstance<MaterialPropertyCollection>();
}
else {
} else {
materialProperties = ScriptableObject.Instantiate(materialProperties);
}
}
@ -153,14 +154,12 @@ namespace ConformalDecals {
if (backRenderer == null) {
this.LogError($"Specified decalBack transform {decalBack} has no renderer attached! Setting updateBackScale to false.");
updateBackScale = false;
}
else {
} 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 {
} else {
if (backTextureBaseScale == default) backTextureBaseScale = backMaterial.GetTextureScale(PropertyIDs._MainTex);
}
}
@ -201,12 +200,14 @@ namespace ConformalDecals {
if (tileRect.x >= 0) {
materialProperties.UpdateTile(tileRect);
}
else if (tileIndex >= 0) {
} else if (tileIndex >= 0) {
materialProperties.UpdateTile(tileIndex, tileSize);
}
}
catch (Exception e) {
// handle aspect ratio overrides
materialProperties.AspectRatio = aspectRatio;
} catch (Exception e) {
this.LogException("Exception parsing partmodule", e);
}
@ -222,8 +223,7 @@ namespace ConformalDecals {
if (HighLogic.LoadedSceneIsGame) {
UpdateScale();
}
else {
} else {
scale = defaultScale;
depth = defaultDepth;
opacity = defaultOpacity;
@ -250,6 +250,7 @@ namespace ConformalDecals {
if (HighLogic.LoadedSceneIsEditor) {
GameEvents.onEditorPartEvent.Add(OnEditorEvent);
GameEvents.onVariantApplied.Add(OnVariantApplied);
GameEvents.onEditorUndo.Add(OnEditorUndo);
UpdateTweakables();
}
@ -261,8 +262,7 @@ namespace ConformalDecals {
// set initial attachment state
if (part.parent == null) {
OnDetach();
}
else {
} else {
OnAttach();
}
}
@ -288,6 +288,7 @@ namespace ConformalDecals {
if (HighLogic.LoadedSceneIsEditor) {
GameEvents.onEditorPartEvent.Remove(OnEditorEvent);
GameEvents.onVariantApplied.Remove(OnVariantApplied);
GameEvents.onEditorUndo.Remove(OnEditorUndo);
}
if (HighLogic.LoadedSceneIsFlight) {
@ -351,6 +352,10 @@ namespace ConformalDecals {
}
}
protected void OnEditorUndo(ShipConstruct sc) {
UpdateTargets();
}
protected void OnPartWillDie(Part willDie) {
if (willDie == part.parent) {
this.Log("Parent part about to be destroyed! Killing decal part.");
@ -400,30 +405,32 @@ namespace ConformalDecals {
protected void UpdateScale() {
scale = Mathf.Max(0.01f, scale);
depth = Mathf.Max(0.01f, depth);
var aspectRatio = Mathf.Max(0.01f, materialProperties.AspectRatio);
var sizeRatio = Mathf.Max(0.01f, materialProperties.AspectRatio);
Vector2 size;
switch (scaleMode) {
default:
case DecalScaleMode.HEIGHT:
size = new Vector2(scale / aspectRatio, scale);
size = new Vector2(scale / sizeRatio, scale);
break;
case DecalScaleMode.WIDTH:
size = new Vector2(scale, scale * aspectRatio);
size = new Vector2(scale, scale * sizeRatio);
break;
case DecalScaleMode.AVERAGE:
var width1 = 2 * scale / (1 + aspectRatio);
size = new Vector2(width1, width1 * aspectRatio);
var width1 = 2 * scale / (1 + sizeRatio);
size = new Vector2(width1, width1 * sizeRatio);
break;
case DecalScaleMode.AREA:
var width2 = Mathf.Sqrt(scale / aspectRatio);
size = new Vector2(width2, width2 * aspectRatio);
var width2 = Mathf.Sqrt(scale / sizeRatio);
size = new Vector2(width2, width2 * sizeRatio);
break;
case DecalScaleMode.MINIMUM:
if (aspectRatio > 1) goto case DecalScaleMode.WIDTH;
if (sizeRatio > 1) goto case DecalScaleMode.WIDTH;
else goto case DecalScaleMode.HEIGHT;
case DecalScaleMode.MAXIMUM:
if (aspectRatio > 1) goto case DecalScaleMode.HEIGHT;
if (sizeRatio > 1) goto case DecalScaleMode.HEIGHT;
else goto case DecalScaleMode.WIDTH;
}
@ -440,10 +447,13 @@ namespace ConformalDecals {
// update projection
foreach (var target in _targets) {
target.Project(_orthoMatrix, decalProjectorTransform, _boundsRenderer.bounds, useBaseNormal);
if (target.target == null) {
_targets.Remove(target);
} else {
target.Project(_orthoMatrix, decalProjectorTransform, _boundsRenderer.bounds, useBaseNormal);
}
}
}
else {
} else {
// rescale preview model
decalModelTransform.localScale = new Vector3(size.x, size.y, (size.x + size.y) / 2);
@ -471,8 +481,7 @@ namespace ConformalDecals {
protected void UpdateTargets() {
if (_targets == null) {
_targets = new List<ProjectionTarget>();
}
else {
} else {
_targets.Clear();
}
@ -574,10 +583,11 @@ namespace ConformalDecals {
public void Render(Camera camera) {
if (!_isAttached) return;
// render on each target object
foreach (var target in _targets) {
target.Render(_decalMaterial, part.mpb, camera);
if (ReferenceEquals(target.target, null)) _targets.Remove(target);
else target.Render(_decalMaterial, part.mpb, camera);
}
}
}

View File

@ -9,6 +9,7 @@ namespace ConformalDecals {
[KSPField(isPersistant = true)] public bool useCustomFlag;
// The URL of the flag for the current mission or agency
public string MissionFlagUrl {
get {
if (HighLogic.LoadedSceneIsEditor) {
@ -19,6 +20,7 @@ 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;
}
}
@ -26,84 +28,108 @@ namespace ConformalDecals {
public override void OnLoad(ConfigNode node) {
base.OnLoad(node);
if (useCustomFlag) {
SetFlag(flagUrl);
}
else {
SetFlag(MissionFlagUrl);
}
// 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.LoadedSceneIsGame) {
GameEvents.onMissionFlagSelect.Add(OnEditorFlagSelected);
}
if (HighLogic.LoadedSceneIsEditor) {
// Register flag change event
GameEvents.onMissionFlagSelect.Add(OnEditorFlagSelected);
// Register reset button event
Events[nameof(ResetFlag)].guiActiveEditor = useCustomFlag;
}
if (useCustomFlag) {
SetFlag(flagUrl);
}
else {
SetFlag(MissionFlagUrl);
}
// Since OnStart is called for all modules, we only need to update this module
// Updating symmetry counterparts would be redundent
UpdateFlag();
}
public override void OnDestroy() {
GameEvents.onMissionFlagSelect.Remove(SetFlag);
if (HighLogic.LoadedSceneIsEditor) {
// Unregister flag change event
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;
}
[KSPEvent(guiActive = false, guiActiveEditor = true, guiName = "#LOC_ConformalDecals_gui-reset-flag")]
public void ResetFlag() {
SetFlag(MissionFlagUrl);
SetFlagSymmetryCounterparts(MissionFlagUrl);
// 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;
}
private void OnCustomFlagSelected(FlagBrowser.FlagEntry newFlagEntry) {
SetFlag(newFlagEntry.textureInfo.name);
SetFlagSymmetryCounterparts(newFlagEntry.textureInfo.name);
// 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;
}
private void OnEditorFlagSelected(string newFlagUrl) {
if (!useCustomFlag) {
SetFlag(newFlagUrl);
SetFlagSymmetryCounterparts(newFlagUrl);
flagUrl = newFlagUrl;
// Since this callback is called for all modules, we only need to update this module
// Updating symmetry counterparts would be redundent
UpdateFlag();
}
}
private void SetFlag(string newFlagUrl) {
this.Log($"Loading flag texture '{newFlagUrl}'.");
// 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);
flagUrl = newFlagUrl;
materialProperties.AddOrGetTextureProperty("_Decal", true).TextureUrl = newFlagUrl;
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;
}
UpdateMaterials();
UpdateScale();
}
private void SetFlagSymmetryCounterparts(string newFlagUrl) {
foreach (var counterpart in part.symmetryCounterparts) {
var decal = counterpart.GetComponent<ModuleConformalFlag>();
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.SetFlag(newFlagUrl);
decal.useCustomFlag = useCustomFlag;
decal.useCustomFlag = useCustomFlag;
decal.flagUrl = flagUrl;
decal.UpdateFlag();
}
}
}
}

View File

@ -153,7 +153,7 @@ namespace ConformalDecals {
this.vertical = newVertical;
this.lineSpacing = newLineSpacing;
this.charSpacing = newCharSpacing;
UpdateTextRecursive();
UpdateText(true);
}
public void OnFillColorUpdate(Color rgb, Util.ColorHSV hsv) {
@ -227,7 +227,7 @@ namespace ConformalDecals {
if (_textEntryController != null) _textEntryController.Close();
if (_fillColorPickerController != null) _fillColorPickerController.Close();
if (_outlineColorPickerController != null) _outlineColorPickerController.Close();
base.OnDestroy();
}
@ -240,40 +240,37 @@ namespace ConformalDecals {
base.OnDetach();
}
private void UpdateTextRecursive() {
UpdateText();
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;
decal._currentText = _currentText;
decal.UpdateText();
}
}
private IEnumerator UpdateTextLate() {
yield return null;
UpdateText();
}
private void UpdateText() {
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;
// Update the texture with the new rendered output
UpdateTexture(output);
// TODO: ASYNC RENDERING
// var newText = new DecalText(text, _font, _style);
// _currentJob = TextRenderer.UpdateText(_currentText, newText, UpdateTexture);
// _currentText = newText;
// 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;
decal.UpdateText();
}
}
}
public void UpdateTexture(TextRenderOutput output) {

View File

@ -1,120 +0,0 @@
v0.2.8
------
- Update bundled Shabby to support Harmony 2 for compatibility with other mods
- Update bundled B9PartSwitch to 2.18.0
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