mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Compare commits
75 Commits
Author | SHA1 | Date | |
---|---|---|---|
970a69be11 | |||
dddb7f09f3 | |||
3cd229bc23 | |||
4948818065 | |||
036b084d34 | |||
1e3addeb4d | |||
47c70d3071 | |||
9955b9ce30 | |||
32ddc54019 | |||
ff262d55c8 | |||
d1f3d1fa55 | |||
2965633235 | |||
a82369e595 | |||
16c4fa2b96 | |||
591ec0aa74 | |||
210d326469 | |||
dd405a21db | |||
c40f700235 | |||
36cc896b2a | |||
4c02e91dfd | |||
41b15477fb | |||
b61f71bc00 | |||
74fe42a7ff | |||
7fa8969d5b | |||
21f8332d66 | |||
cb219a52c0 | |||
f2f2100334 | |||
9bdb95527a | |||
ad504ce4cc | |||
18ebbd7b4c | |||
ba189f18c4 | |||
322aaa613e | |||
5443377bfe | |||
1ed6dc0f68 | |||
90dec1b42a | |||
80da98d95a | |||
76016fbbf1 | |||
53657b8fad | |||
9d7502091c | |||
f788c25837 | |||
017110738b | |||
fd7134ece9 | |||
68ceacfef4 | |||
a452844cd1 | |||
4b8d11e1de | |||
8f888ee552 | |||
95b99d1d42 | |||
ba6676b625 | |||
495441be06 | |||
8025a0a418 | |||
760609fae2 | |||
ecc60751f7 | |||
e10b7e4b51 | |||
a91a83a280 | |||
316f92df2c | |||
938babb41b | |||
3173dd914a | |||
5f6712f476 | |||
6b7996fdd7 | |||
5feb16dcfb | |||
bf8e98caf0 | |||
b634eb1e8e | |||
dadf38acd5 | |||
f42e0d78d6 | |||
1e7c6d81c9 | |||
dda988db17 | |||
900061f7f6 | |||
e56278c6cb | |||
2793f5fcb1 | |||
833ec43a52 | |||
e6856124e7 | |||
8ed7a130ab | |||
d8d3d4ed92 | |||
334af786f6 | |||
17ef93bb6e |
23
.github/workflows/ff-release.yml
vendored
Normal file
23
.github/workflows/ff-release.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
name: Fast-Forward Release Branch
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
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
|
139
.github/workflows/ksp-publish.yml
vendored
Normal file
139
.github/workflows/ksp-publish.yml
vendored
Normal file
@ -0,0 +1,139 @@
|
||||
name: Build and Release
|
||||
on: [ push ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Setup .NET Core SDK
|
||||
uses: actions/setup-dotnet@v1.7.2
|
||||
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: |
|
||||
echo "VERSION_TITLE=$(yaclog show -n)" >> $GITHUB_ENV
|
||||
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 http://pileof.rocks/KSP/Shabby_v0.2.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@v3
|
||||
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@v3
|
||||
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@v2
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- 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
|
||||
echo "$(yaclog show -mb)" >> RELEASE.md
|
||||
|
||||
- name: Download Build Artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
|
||||
- name: Zip Download Packages
|
||||
run: |
|
||||
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: |
|
||||
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.3" \
|
||||
-F "notify-followers=yes" \
|
||||
-F "zipball=@bundled/ConformalDecals-$VERSION_TITLE.zip" \
|
||||
"https://spacedock.info/api/mod/2451/update"
|
||||
|
||||
- name: Publish to Github
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
bundled/ConformalDecals-*.zip
|
||||
ConformalDecals/GameData/ConformalDecals/Versioning/ConformalDecals.version
|
||||
name: Conformal Decals ${{ env.VERSION_TITLE }}
|
||||
body_path: RELEASE.md
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -16,6 +16,9 @@ Temp/
|
||||
GameData/ConformalDecals/Resources/Resources
|
||||
GameData/ConformalDecals/Resources/*.manifest
|
||||
|
||||
# DLLs
|
||||
GameData/ConformalDecals/Plugins
|
||||
|
||||
# Unity Project Files
|
||||
PartTools.cfg
|
||||
*.meta
|
||||
@ -50,3 +53,5 @@ Source/ConformalDecals/bin
|
||||
*.sublime*
|
||||
.idea
|
||||
obj
|
||||
*.swp
|
||||
@thumbs
|
||||
|
@ -16,11 +16,15 @@ dependencies: # Configure dependencies
|
||||
zip: false
|
||||
B9PartSwitch:
|
||||
location: url
|
||||
url: http://pileof.rocks/KSP/B9PartSwitch-v2.16.0.zip
|
||||
url: http://pileof.rocks/KSP/B9PartSwitch-v2.18.0.zip
|
||||
zip: true
|
||||
Shabby:
|
||||
location: url
|
||||
url: http://taniwha.org/~bill/Shabby_v0.1.2.zip
|
||||
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:
|
||||
|
25
.travis.yml
25
.travis.yml
@ -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
|
@ -30,6 +30,8 @@ public class TextRenderTest : MonoBehaviour {
|
||||
Debug.Log("starting...");
|
||||
|
||||
StartCoroutine(OnRender());
|
||||
var thing = new GameObject();
|
||||
thing.AddComponent<TextMeshPro>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
193
CHANGELOG.md
Normal file
193
CHANGELOG.md
Normal file
@ -0,0 +1,193 @@
|
||||
# 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.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
|
7
GameData/ConformalDecals/Patches/Waterfall.cfg
Normal file
7
GameData/ConformalDecals/Patches/Waterfall.cfg
Normal file
@ -0,0 +1,7 @@
|
||||
// Prevent projection onto Waterfall plumes
|
||||
|
||||
CONFORMALDECALS:NEEDS[Waterfall] {
|
||||
SHADERBLACKLIST {
|
||||
shaderRegex = Waterfall/.*
|
||||
}
|
||||
}
|
Binary file not shown.
@ -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 {
|
||||
|
@ -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":4,
|
||||
"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":10,
|
||||
"PATCH":1
|
||||
"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":10,
|
||||
"PATCH":99
|
||||
"KSP_VERSION_MAX": {
|
||||
"MAJOR": 1,
|
||||
"MINOR": 12
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
# Conformal Decals v0.2.4
|
||||
[](https://travis-ci.org/drewcassidy/KSP-Conformal-Decals) [](https://creativecommons.org/licenses/by-sa/4.0/) [](https://www.gnu.org/licenses/gpl-3.0)
|
||||
# Conformal Decals
|
||||
[](https://creativecommons.org/licenses/by-sa/4.0/) [](https://www.gnu.org/licenses/gpl-3.0)
|
||||
|
||||

|
||||
|
||||
@ -9,9 +9,10 @@ Conformal Decals adds a set of decal stickers to KSP, as well as providing a fra
|
||||
|
||||
Required:
|
||||
- KSP (1.8.x to 1.10.x)
|
||||
- B9 Part Switch (2.16.0). Bundled with release.
|
||||
- B9 Part Switch (2.18.0). Bundled with release.
|
||||
- ModuleManager (4.1.4). Bundled with release.
|
||||
- Shabby (0.1.2). Bundled with release.
|
||||
- Shabby (0.2.0 unofficial build). Bundled with release.
|
||||
- HarmonyKSP (2.0.4.0). Bundled with release.
|
||||
|
||||
Optional:
|
||||
- Wild Blue Tools. For custom decals category in the VAB and SPH.
|
||||
|
61
Scripts/version.py
Normal file
61
Scripts/version.py
Normal 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()
|
@ -1,6 +1,6 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConformalDecals", "ConformalDecals/ConformalDecals.csproj", "{1ea983f9-42e5-494e-9683-fdac9c9121f4}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConformalDecals", "ConformalDecals/ConformalDecals.csproj", "{1EA983F9-42E5-494E-9683-FDAC9C9121F4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -8,9 +8,9 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1ea983f9-42e5-494e-9683-fdac9c9121f4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1ea983f9-42e5-494e-9683-fdac9c9121f4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{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
|
||||
{1EA983F9-42E5-494E-9683-FDAC9C9121F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1EA983F9-42E5-494E-9683-FDAC9C9121F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{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
|
||||
EndGlobal
|
||||
|
@ -1,115 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)/$(MSBuildToolsVersion)/Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)/$(MSBuildToolsVersion)/Microsoft.Common.props')" />
|
||||
<?xml version="1.0" ?><Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{1ea983f9-42e5-494e-9683-fdac9c9121f4}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<LangVersion>8</LangVersion>
|
||||
<RootNamespace>ConformalDecals</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin/Debug/</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin/Release/</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin/Release/ConformalDecals.xml</DocumentationFile>
|
||||
<NoWarn>CS1591,CS0649</NoWarn>
|
||||
<IsPackable>false</IsPackable>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<NoWarn>1701;1702;CS0649;CS1591</NoWarn>
|
||||
<AssemblyVersion>9.9.9</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls/Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="KSPAssets, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls\KSPAssets.dll</HintPath>
|
||||
<HintPath>dlls\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Shabby, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls/Shabby.dll</HintPath>
|
||||
<HintPath>dlls\Shabby.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls/UnityEngine.dll</HintPath>
|
||||
<HintPath>dlls\UnityEngine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.AssetBundleModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls/UnityEngine.AssetBundleModule.dll</HintPath>
|
||||
<HintPath>dlls\UnityEngine.AssetBundleModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls/UnityEngine.CoreModule.dll</HintPath>
|
||||
<HintPath>dlls\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls/UnityEngine.PhysicsModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.TextCoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls/UnityEngine.TextCoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.TextRenderingModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls/UnityEngine.TextRenderingModule.dll</HintPath>
|
||||
<HintPath>dlls\UnityEngine.PhysicsModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls/UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UIElementsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls/UnityEngine.UIElementsModule.dll</HintPath>
|
||||
<HintPath>dlls\UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UIModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls/UnityEngine.UIModule.dll</HintPath>
|
||||
<HintPath>dlls\UnityEngine.UIModule.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="DecalConfig.cs" />
|
||||
<Compile Include="DecalIconFixer.cs" />
|
||||
<Compile Include="DecalPropertyIDs.cs" />
|
||||
<Compile Include="MaterialProperties/MaterialColorProperty.cs" />
|
||||
<Compile Include="MaterialProperties/MaterialFloatProperty.cs" />
|
||||
<Compile Include="MaterialProperties/MaterialKeywordProperty.cs" />
|
||||
<Compile Include="MaterialProperties/MaterialProperty.cs" />
|
||||
<Compile Include="MaterialProperties/MaterialPropertyCollection.cs" />
|
||||
<Compile Include="MaterialProperties/MaterialTextureProperty.cs" />
|
||||
<Compile Include="ModuleConformalFlag.cs" />
|
||||
<Compile Include="ModuleConformalText.cs" />
|
||||
<Compile Include="ProjectionTarget.cs" />
|
||||
<Compile Include="ModuleConformalDecal.cs" />
|
||||
<Compile Include="Properties/AssemblyInfo.cs" />
|
||||
<Compile Include="Text/DecalFont.cs" />
|
||||
<Compile Include="Text/FontLoader.cs" />
|
||||
<Compile Include="Text/TextRenderer.cs" />
|
||||
<Compile Include="Text/DecalText.cs" />
|
||||
<Compile Include="Text\TextRenderOutput.cs" />
|
||||
<Compile Include="Text\TextRenderJob.cs" />
|
||||
<Compile Include="UI/ColorPickerController.cs" />
|
||||
<Compile Include="UI/FontMenuController.cs" />
|
||||
<Compile Include="UI/FontMenuItem.cs" />
|
||||
<Compile Include="UI/TextEntryController.cs" />
|
||||
<Compile Include="UI/UILoader.cs" />
|
||||
<Compile Include="UI/UITag.cs" />
|
||||
<Compile Include="UI\ColorBoxSlider.cs" />
|
||||
<Compile Include="UI\ColorChannelSlider.cs" />
|
||||
<Compile Include="Util/Logging.cs" />
|
||||
<Compile Include="Util/OrientedBounds.cs" />
|
||||
<Compile Include="Util/ParseUtil.cs" />
|
||||
<Compile Include="UI/BoxSlider.cs" />
|
||||
<Compile Include="Util\ColorHSL.cs" />
|
||||
<Compile Include="Util\ColorHSV.cs" />
|
||||
<Compile Include="Util\ColorUtil.cs" />
|
||||
<Compile Remove="dlls\**"/>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)/Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>sh -e -c "cp -v '$(TargetPath)' '$(SolutionDir)/../GameData/ConformalDecals/Plugins'"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Remove="dlls\**"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="dlls\**"/>
|
||||
</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-->
|
||||
</Target>
|
||||
|
||||
</Project>
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using ConformalDecals.Text;
|
||||
using ConformalDecals.Util;
|
||||
using TMPro;
|
||||
@ -10,6 +11,7 @@ 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;
|
||||
@ -50,15 +52,23 @@ namespace ConformalDecals {
|
||||
public static bool SelectableInFlight => _selectableInFlight;
|
||||
|
||||
public static IEnumerable<DecalFont> Fonts => _fontList.Values;
|
||||
|
||||
public static DecalFont FallbackFont { get; private set; }
|
||||
|
||||
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) {
|
||||
@ -91,10 +101,14 @@ 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);
|
||||
@ -128,13 +142,14 @@ namespace ConformalDecals {
|
||||
// ReSharper disable once UnusedMember.Global
|
||||
public static void ModuleManagerPostLoad() {
|
||||
_shaderBlacklist = new List<string>();
|
||||
_shaderRegexBlacklist = new List<Regex>();
|
||||
_fontList = new Dictionary<string, DecalFont>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,13 @@ namespace ConformalDecals.MaterialProperties {
|
||||
public Vector2 Dimensions => new Vector2(_texture.width, _texture.height);
|
||||
public Vector2 MaskedDimensions => _hasTile ? _tileRect.size : Dimensions;
|
||||
|
||||
public float AspectRatio => MaskedHeight / (float) MaskedWidth;
|
||||
public float AspectRatio {
|
||||
get {
|
||||
if (_texture == null) return 1;
|
||||
if (_textureUrl?.Contains("Squad/Flags") == true) return 0.625f;
|
||||
return MaskedHeight / (float) MaskedWidth;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ParseNode(ConfigNode node) {
|
||||
base.ParseNode(node);
|
||||
|
@ -400,7 +400,7 @@ namespace ConformalDecals {
|
||||
protected void UpdateScale() {
|
||||
scale = Mathf.Max(0.01f, scale);
|
||||
depth = Mathf.Max(0.01f, depth);
|
||||
var aspectRatio = materialProperties.AspectRatio;
|
||||
var aspectRatio = Mathf.Max(0.01f, materialProperties.AspectRatio);
|
||||
Vector2 size;
|
||||
|
||||
switch (scaleMode) {
|
||||
@ -481,7 +481,7 @@ namespace ConformalDecals {
|
||||
foreach (var renderer in renderers) {
|
||||
// skip disabled renderers
|
||||
if (renderer.gameObject.activeInHierarchy == false) continue;
|
||||
|
||||
|
||||
// skip blacklisted shaders
|
||||
if (DecalConfig.IsBlacklisted(renderer.material.shader)) continue;
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
using ConformalDecals.Util;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals {
|
||||
@ -9,6 +8,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 +19,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 +27,106 @@ 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}'.");
|
||||
|
||||
flagUrl = newFlagUrl;
|
||||
materialProperties.AddOrGetTextureProperty("_Decal", true).TextureUrl = 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);
|
||||
|
||||
if(useCustomFlag) {
|
||||
// set the texture to the custom flag
|
||||
textureProperty.TextureUrl = flagUrl;
|
||||
}
|
||||
else {
|
||||
// set the texture to the mission flag
|
||||
textureProperty.TextureUrl = MissionFlagUrl;
|
||||
}
|
||||
|
||||
UpdateMaterials();
|
||||
UpdateScale();
|
||||
}
|
||||
|
||||
private void SetFlagSymmetryCounterparts(string newFlagUrl) {
|
||||
foreach (var counterpart in part.symmetryCounterparts) {
|
||||
var decal = counterpart.GetComponent<ModuleConformalFlag>();
|
||||
|
||||
decal.SetFlag(newFlagUrl);
|
||||
decal.useCustomFlag = useCustomFlag;
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,6 @@ namespace ConformalDecals {
|
||||
private MaterialColorProperty _outlineColorProperty;
|
||||
private MaterialFloatProperty _outlineWidthProperty;
|
||||
|
||||
private TextRenderJob _currentJob;
|
||||
private DecalText _currentText;
|
||||
|
||||
public override void OnLoad(ConfigNode node) {
|
||||
@ -154,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) {
|
||||
@ -241,38 +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._currentJob = _currentJob;
|
||||
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.UpdateTextNow(_currentText, newText);
|
||||
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) {
|
||||
|
@ -1,38 +1 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ConformalDecals")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Cineboxandrew")]
|
||||
[assembly: AssemblyProduct("ConformalDecals")]
|
||||
[assembly: AssemblyCopyright("Copyright © Andrew Cassidy 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("1ea983f9-42e5-494e-9683-fdac9c9121f4")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
||||
[assembly: KSPAssembly("ConformalDecals", 0, 1, 0)]
|
||||
[assembly: KSPAssembly("ConformalDecals", 0, 2)]
|
@ -105,5 +105,9 @@ namespace ConformalDecals.Text {
|
||||
public void OnBeforeSerialize() { }
|
||||
|
||||
public void OnAfterDeserialize() { }
|
||||
|
||||
public override string ToString() {
|
||||
return _title;
|
||||
}
|
||||
}
|
||||
}
|
@ -86,5 +86,9 @@ namespace ConformalDecals.Text {
|
||||
public static bool operator !=(DecalText left, DecalText right) {
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return $"{nameof(_text)}: {_text}, {nameof(_font)}: {_font}, {nameof(_style)}: {_style}, {nameof(_vertical)}: {_vertical}, {nameof(_lineSpacing)}: {_lineSpacing}, {nameof(_charSpacing)}: {_charSpacing}";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace ConformalDecals.Text {
|
||||
public class TextRenderJob {
|
||||
public DecalText OldText { get; }
|
||||
public DecalText NewText { get; }
|
||||
public bool Needed { get; private set; }
|
||||
public bool IsStarted { get; private set; }
|
||||
public bool IsDone { get; private set; }
|
||||
|
||||
public readonly TextRenderer.TextRenderEvent onRenderFinished = new TextRenderer.TextRenderEvent();
|
||||
|
||||
public TextRenderJob(DecalText oldText, DecalText newText, UnityAction<TextRenderOutput> renderFinishedCallback) {
|
||||
OldText = oldText;
|
||||
NewText = newText ?? throw new ArgumentNullException(nameof(newText));
|
||||
Needed = true;
|
||||
|
||||
if (renderFinishedCallback != null) onRenderFinished.AddListener(renderFinishedCallback);
|
||||
}
|
||||
|
||||
public void Cancel() {
|
||||
Needed = false;
|
||||
}
|
||||
|
||||
public void Start() {
|
||||
IsStarted = true;
|
||||
}
|
||||
|
||||
public void Finish(TextRenderOutput output) {
|
||||
IsDone = true;
|
||||
onRenderFinished.Invoke(output);
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ namespace ConformalDecals.Text {
|
||||
/// The rectangle that the rendered text takes up within the texture
|
||||
public Rect Window { get; private set; }
|
||||
|
||||
/// The number of users for this render output. If 0, it can be discarded from the cache and the texture reused
|
||||
/// The number of users for this render output. If 0, it can be discarded from the cache
|
||||
public int UserCount { get; set; }
|
||||
|
||||
public TextRenderOutput(Texture2D texture, Rect window) {
|
||||
|
@ -3,16 +3,12 @@ using System.Collections.Generic;
|
||||
using ConformalDecals.Util;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Rendering;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace ConformalDecals.Text {
|
||||
// TODO: Testing shows the job system is unnecessary, so remove job system code.
|
||||
|
||||
/// Class handing text rendering.
|
||||
/// Is a singleton referencing a single gameobject in the scene which contains the TextMeshPro component
|
||||
[KSPAddon(KSPAddon.Startup.Instantly, true)]
|
||||
public class TextRenderer : MonoBehaviour {
|
||||
public static class TextRenderer {
|
||||
/// Texture format used for returned textures.
|
||||
/// Unfortunately due to how Unity textures work, this cannot be R8 or Alpha8,
|
||||
/// so theres always a superfluous green channel using memory
|
||||
@ -22,163 +18,73 @@ namespace ConformalDecals.Text {
|
||||
/// Overriden below to be ARGB32 on DirectX because DirectX is dumb
|
||||
public static RenderTextureFormat textRenderTextureFormat = RenderTextureFormat.R8;
|
||||
|
||||
/// The text renderer object within the scene which contains the TextMeshPro component used for rendering.
|
||||
public static TextRenderer Instance {
|
||||
get {
|
||||
if (!_instance._isSetup) {
|
||||
_instance.Setup();
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// Text Render unityevent, used with the job system to signal render completion
|
||||
[Serializable]
|
||||
public class TextRenderEvent : UnityEvent<TextRenderOutput> { }
|
||||
|
||||
private const string ShaderName = "ConformalDecals/Text Blit";
|
||||
private const int MaxTextureSize = 4096;
|
||||
private const float FontSize = 100;
|
||||
private const float PixelDensity = 5;
|
||||
|
||||
private static TextRenderer _instance;
|
||||
|
||||
private bool _isSetup;
|
||||
private TextMeshPro _tmp;
|
||||
private Shader _blitShader;
|
||||
private static Shader _blitShader;
|
||||
private static Texture2D _blankTexture;
|
||||
|
||||
private static readonly Dictionary<DecalText, TextRenderOutput> RenderCache = new Dictionary<DecalText, TextRenderOutput>();
|
||||
private static readonly Queue<TextRenderJob> RenderJobs = new Queue<TextRenderJob>();
|
||||
|
||||
/// Update text using the job queue
|
||||
public static TextRenderJob UpdateText(DecalText oldText, DecalText newText, UnityAction<TextRenderOutput> renderFinishedCallback) {
|
||||
if (newText == null) throw new ArgumentNullException(nameof(newText));
|
||||
|
||||
var job = new TextRenderJob(oldText, newText, renderFinishedCallback);
|
||||
RenderJobs.Enqueue(job);
|
||||
return job;
|
||||
}
|
||||
|
||||
/// Update text immediately without using job queue
|
||||
public static TextRenderOutput UpdateTextNow(DecalText oldText, DecalText newText) {
|
||||
public static TextRenderOutput UpdateText(DecalText oldText, DecalText newText) {
|
||||
if (newText == null) throw new ArgumentNullException(nameof(newText));
|
||||
|
||||
return Instance.RunJob(new TextRenderJob(oldText, newText, null), out _);
|
||||
if (!(oldText is null)) UnregisterText(oldText);
|
||||
|
||||
// now that all old references are handled, begin rendering the new output
|
||||
if (!RenderCache.TryGetValue(newText, out var renderOutput)) {
|
||||
renderOutput = RenderText(newText);
|
||||
RenderCache.Add(newText, renderOutput);
|
||||
}
|
||||
|
||||
renderOutput.UserCount++;
|
||||
return renderOutput;
|
||||
}
|
||||
|
||||
/// Unregister a user of a piece of text
|
||||
public static void UnregisterText(DecalText text) {
|
||||
if (text == null) throw new ArgumentNullException(nameof(text));
|
||||
|
||||
if (RenderCache.TryGetValue(text, out var renderedText)) {
|
||||
renderedText.UserCount--;
|
||||
if (renderedText.UserCount <= 0) {
|
||||
RenderCache.Remove(text);
|
||||
Destroy(renderedText.Texture);
|
||||
var texture = renderedText.Texture;
|
||||
if (texture != _blankTexture) Object.Destroy(texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Start() {
|
||||
if (_instance != null) {
|
||||
Logging.LogError("Duplicate TextRenderer created???");
|
||||
}
|
||||
|
||||
Logging.Log("Creating TextRenderer Object");
|
||||
_instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D12) {
|
||||
textRenderTextureFormat = RenderTextureFormat.ARGB32; // DirectX is dumb
|
||||
}
|
||||
|
||||
if (!SystemInfo.SupportsTextureFormat(textTextureFormat)) {
|
||||
Logging.LogError($"Text texture format {textTextureFormat} not supported on this platform.");
|
||||
}
|
||||
|
||||
if (!SystemInfo.SupportsRenderTextureFormat(textRenderTextureFormat)) {
|
||||
Logging.LogError($"Text texture format {textRenderTextureFormat} not supported on this platform.");
|
||||
}
|
||||
}
|
||||
|
||||
/// Setup this text renderer instance for rendering
|
||||
private void Setup() {
|
||||
if (_isSetup) return;
|
||||
|
||||
Logging.Log("Setting Up TextRenderer Object");
|
||||
|
||||
_tmp = gameObject.AddComponent<TextMeshPro>();
|
||||
_tmp.renderer.enabled = false; // dont automatically render
|
||||
|
||||
_blitShader = Shabby.Shabby.FindShader(ShaderName);
|
||||
if (_blitShader == null) Logging.LogError($"Could not find text blit shader named '{ShaderName}'");
|
||||
|
||||
_isSetup = true;
|
||||
}
|
||||
|
||||
/// Run a text render job
|
||||
private TextRenderOutput RunJob(TextRenderJob job, out bool renderNeeded) {
|
||||
if (!job.Needed) {
|
||||
renderNeeded = false;
|
||||
return null;
|
||||
}
|
||||
|
||||
job.Start();
|
||||
|
||||
Texture2D texture = null;
|
||||
if (job.OldText != null && RenderCache.TryGetValue(job.OldText, out var oldRender)) {
|
||||
// old output still exists
|
||||
|
||||
oldRender.UserCount--;
|
||||
|
||||
if (oldRender.UserCount <= 0) {
|
||||
// this is the only usage of this output, so we are free to re-render into the texture
|
||||
|
||||
texture = oldRender.Texture;
|
||||
RenderCache.Remove(job.OldText);
|
||||
}
|
||||
}
|
||||
|
||||
// now that all old references are handled, begin rendering the new output
|
||||
|
||||
if (RenderCache.TryGetValue(job.NewText, out var renderOutput)) {
|
||||
renderNeeded = false;
|
||||
}
|
||||
else {
|
||||
renderNeeded = true;
|
||||
|
||||
renderOutput = RenderText(job.NewText, texture);
|
||||
RenderCache.Add(job.NewText, renderOutput);
|
||||
}
|
||||
|
||||
renderOutput.UserCount++;
|
||||
|
||||
job.Finish(renderOutput);
|
||||
return renderOutput;
|
||||
}
|
||||
|
||||
/// Render a piece of text to a given texture
|
||||
public TextRenderOutput RenderText(DecalText text, Texture2D texture) {
|
||||
public static TextRenderOutput RenderText(DecalText text) {
|
||||
if (text == null) throw new ArgumentNullException(nameof(text));
|
||||
if (_tmp == null) throw new InvalidOperationException("TextMeshPro object not yet created.");
|
||||
|
||||
var tmpObject = new GameObject("Text Mesh Pro renderer");
|
||||
var tmp = tmpObject.AddComponent<TextMeshPro>();
|
||||
|
||||
// SETUP TMP OBJECT FOR RENDERING
|
||||
_tmp.text = text.FormattedText;
|
||||
_tmp.font = text.Font.FontAsset;
|
||||
_tmp.fontStyle = text.Style | text.Font.FontStyle;
|
||||
_tmp.lineSpacing = text.LineSpacing;
|
||||
_tmp.characterSpacing = text.CharSpacing;
|
||||
tmp.text = text.FormattedText;
|
||||
tmp.font = text.Font.FontAsset;
|
||||
tmp.fontStyle = text.Style | text.Font.FontStyle;
|
||||
tmp.lineSpacing = text.LineSpacing;
|
||||
tmp.characterSpacing = text.CharSpacing;
|
||||
|
||||
_tmp.extraPadding = true;
|
||||
_tmp.enableKerning = true;
|
||||
_tmp.enableWordWrapping = false;
|
||||
_tmp.overflowMode = TextOverflowModes.Overflow;
|
||||
_tmp.alignment = TextAlignmentOptions.Center;
|
||||
_tmp.fontSize = FontSize;
|
||||
tmp.extraPadding = true;
|
||||
tmp.enableKerning = true;
|
||||
tmp.enableWordWrapping = false;
|
||||
tmp.overflowMode = TextOverflowModes.Overflow;
|
||||
tmp.alignment = TextAlignmentOptions.Center;
|
||||
tmp.fontSize = FontSize;
|
||||
|
||||
// GENERATE MESH
|
||||
_tmp.ClearMesh(false);
|
||||
_tmp.ForceMeshUpdate();
|
||||
tmp.ClearMesh(false);
|
||||
tmp.ForceMeshUpdate();
|
||||
|
||||
var meshFilters = gameObject.GetComponentsInChildren<MeshFilter>();
|
||||
var meshFilters = tmpObject.GetComponentsInChildren<MeshFilter>();
|
||||
var meshes = new Mesh[meshFilters.Length];
|
||||
var materials = new Material[meshFilters.Length];
|
||||
|
||||
@ -189,9 +95,9 @@ namespace ConformalDecals.Text {
|
||||
var renderer = meshFilters[i].gameObject.GetComponent<MeshRenderer>();
|
||||
|
||||
meshes[i] = meshFilters[i].mesh;
|
||||
if (i == 0) meshes[i] = _tmp.mesh;
|
||||
if (i == 0) meshes[i] = tmp.mesh;
|
||||
|
||||
materials[i] = Instantiate(renderer.material);
|
||||
materials[i] = Object.Instantiate(renderer.material);
|
||||
materials[i].shader = _blitShader;
|
||||
|
||||
if (renderer == null) throw new FormatException($"Object {meshFilters[i].gameObject.name} has filter but no renderer");
|
||||
@ -209,15 +115,16 @@ namespace ConformalDecals.Text {
|
||||
var size = bounds.size * PixelDensity;
|
||||
size.x = Mathf.Max(size.x, 0.1f);
|
||||
size.y = Mathf.Max(size.y, 0.1f);
|
||||
|
||||
|
||||
var textureSize = new Vector2Int {
|
||||
x = Mathf.NextPowerOfTwo((int) size.x),
|
||||
y = Mathf.NextPowerOfTwo((int) size.y)
|
||||
};
|
||||
|
||||
if (textureSize.x == 0 || textureSize.y == 0) {
|
||||
Logging.LogWarning("No text present or error in texture size calculation. Aborting.");
|
||||
return new TextRenderOutput(Texture2D.blackTexture, Rect.zero);
|
||||
Logging.LogError("No text present or error in texture size calculation. Aborting.");
|
||||
Object.Destroy(tmpObject);
|
||||
return new TextRenderOutput(_blankTexture, Rect.zero);
|
||||
}
|
||||
|
||||
// make sure texture isnt too big, scale it down if it is
|
||||
@ -242,12 +149,7 @@ namespace ConformalDecals.Text {
|
||||
};
|
||||
|
||||
// SETUP TEXTURE
|
||||
if (texture == null) {
|
||||
texture = new Texture2D(textureSize.x, textureSize.y, textTextureFormat, true);
|
||||
}
|
||||
else if (texture.width != textureSize.x || texture.height != textureSize.y || texture.format != textTextureFormat) {
|
||||
texture.Resize(textureSize.x, textureSize.y, textTextureFormat, true);
|
||||
}
|
||||
var texture = new Texture2D(textureSize.x, textureSize.y, textTextureFormat, false);
|
||||
|
||||
// GENERATE PROJECTION MATRIX
|
||||
var halfSize = (Vector2) textureSize / PixelDensity / 2 / sizeRatio;
|
||||
@ -255,8 +157,7 @@ namespace ConformalDecals.Text {
|
||||
bounds.center.y - halfSize.y, bounds.center.y + halfSize.y, -1, 1);
|
||||
|
||||
// GET RENDERTEX
|
||||
var renderTex = RenderTexture.GetTemporary(textureSize.x, textureSize.y, 0, textRenderTextureFormat, RenderTextureReadWrite.Linear, 1);
|
||||
renderTex.autoGenerateMips = false;
|
||||
var renderTex = RenderTexture.GetTemporary(textureSize.x, textureSize.y, 0, textRenderTextureFormat, RenderTextureReadWrite.Linear);
|
||||
|
||||
// RENDER
|
||||
Graphics.SetRenderTarget(renderTex);
|
||||
@ -272,26 +173,42 @@ namespace ConformalDecals.Text {
|
||||
}
|
||||
}
|
||||
|
||||
// COPY TEXTURE BACK INTO RAM
|
||||
// COPY RENDERTEX INTO TEXTURE
|
||||
var prevRT = RenderTexture.active;
|
||||
RenderTexture.active = renderTex;
|
||||
texture.ReadPixels(new Rect(0, 0, textureSize.x, textureSize.y), 0, 0, true);
|
||||
texture.Apply();
|
||||
texture.ReadPixels(new Rect(0, 0, textureSize.x, textureSize.y), 0, 0, false);
|
||||
texture.Apply(false, true);
|
||||
RenderTexture.active = prevRT;
|
||||
|
||||
GL.Clear(false, true, Color.black); //KSP doesnt clear render textures before using them so we need to clear afterwards, as well. Thanks Squad.
|
||||
GL.PopMatrix();
|
||||
|
||||
|
||||
// RELEASE RENDERTEX
|
||||
RenderTexture.ReleaseTemporary(renderTex);
|
||||
|
||||
// CLEAR SUBMESHES
|
||||
_tmp.text = "";
|
||||
|
||||
for (int i = 0; i < transform.childCount; i++) {
|
||||
var child = transform.GetChild(i);
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
// DESTROY THE RENDERER OBJECT
|
||||
Object.Destroy(tmpObject);
|
||||
|
||||
return new TextRenderOutput(texture, window);
|
||||
}
|
||||
|
||||
/// Setup shader and texture
|
||||
public static void ModuleManagerPostLoad() {
|
||||
if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D12) {
|
||||
textRenderTextureFormat = RenderTextureFormat.ARGB32; // DirectX is dumb
|
||||
}
|
||||
|
||||
if (!SystemInfo.SupportsTextureFormat(textTextureFormat)) {
|
||||
Logging.LogError($"Text texture format {textTextureFormat} not supported on this platform.");
|
||||
}
|
||||
|
||||
if (!SystemInfo.SupportsRenderTextureFormat(textRenderTextureFormat)) {
|
||||
Logging.LogError($"Text texture format {textRenderTextureFormat} not supported on this platform.");
|
||||
}
|
||||
|
||||
_blankTexture = Texture2D.blackTexture;
|
||||
_blitShader = Shabby.Shabby.FindShader(ShaderName);
|
||||
if (_blitShader == null) Logging.LogError($"Could not find text blit shader named '{ShaderName}'");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ using ConformalDecals.Text;
|
||||
using ConformalDecals.Util;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ConformalDecals.UI {
|
||||
@ -35,14 +34,15 @@ namespace ConformalDecals.UI {
|
||||
private Vector2 _lineSpacingRange;
|
||||
private Vector2 _charSpacingRange;
|
||||
private TMP_InputField _textBoxTMP;
|
||||
private FontMenuController _fontMenu;
|
||||
private TextUpdateDelegate _onValueChanged;
|
||||
|
||||
private FontMenuController _fontMenu;
|
||||
private static int _lockCounter;
|
||||
|
||||
private bool _ignoreUpdates;
|
||||
private bool _isLocked;
|
||||
private string _lockString;
|
||||
private static int _lockCounter;
|
||||
private bool _ignoreUpdates;
|
||||
private bool _textUpdated;
|
||||
|
||||
public static TextEntryController Create(
|
||||
string text, DecalFont font, FontStyles style, bool vertical, float linespacing, float charspacing,
|
||||
@ -74,7 +74,7 @@ namespace ConformalDecals.UI {
|
||||
|
||||
public void SetControlLock(string value = null) {
|
||||
if (_isLocked) return;
|
||||
InputLockManager.SetControlLock(_lockString);
|
||||
InputLockManager.SetControlLock(ControlTypes.EDITOR_UI, _lockString);
|
||||
_isLocked = true;
|
||||
}
|
||||
|
||||
@ -86,8 +86,7 @@ namespace ConformalDecals.UI {
|
||||
|
||||
public void OnTextUpdate(string newText) {
|
||||
this._text = newText;
|
||||
|
||||
OnValueChanged();
|
||||
_textUpdated = true;
|
||||
}
|
||||
|
||||
public void OnFontMenu() {
|
||||
@ -105,7 +104,7 @@ namespace ConformalDecals.UI {
|
||||
_textBoxTMP.fontAsset = _font.FontAsset;
|
||||
|
||||
UpdateStyleButtons();
|
||||
OnValueChanged();
|
||||
_textUpdated = true;
|
||||
}
|
||||
|
||||
public void OnLineSpacingUpdate(float value) {
|
||||
@ -114,7 +113,7 @@ namespace ConformalDecals.UI {
|
||||
_lineSpacing = Mathf.Lerp(_lineSpacingRange.x, _lineSpacingRange.y, value);
|
||||
|
||||
UpdateLineSpacing();
|
||||
OnValueChanged();
|
||||
_textUpdated = true;
|
||||
}
|
||||
|
||||
public void OnLineSpacingUpdate(string text) {
|
||||
@ -128,7 +127,7 @@ namespace ConformalDecals.UI {
|
||||
}
|
||||
|
||||
UpdateLineSpacing();
|
||||
OnValueChanged();
|
||||
_textUpdated = true;
|
||||
}
|
||||
|
||||
public void OnCharSpacingUpdate(float value) {
|
||||
@ -137,7 +136,7 @@ namespace ConformalDecals.UI {
|
||||
_charSpacing = Mathf.Lerp(_charSpacingRange.x, _charSpacingRange.y, value);
|
||||
|
||||
UpdateCharSpacing();
|
||||
OnValueChanged();
|
||||
_textUpdated = true;
|
||||
}
|
||||
|
||||
public void OnCharSpacingUpdate(string text) {
|
||||
@ -151,7 +150,7 @@ namespace ConformalDecals.UI {
|
||||
}
|
||||
|
||||
UpdateCharSpacing();
|
||||
OnValueChanged();
|
||||
_textUpdated = true;
|
||||
}
|
||||
|
||||
public void OnBoldUpdate(bool state) {
|
||||
@ -163,7 +162,7 @@ namespace ConformalDecals.UI {
|
||||
_style &= ~FontStyles.Bold;
|
||||
|
||||
_textBoxTMP.textComponent.fontStyle = _style | _font.FontStyle & ~_font.FontStyleMask;
|
||||
OnValueChanged();
|
||||
_textUpdated = true;
|
||||
}
|
||||
|
||||
public void OnItalicUpdate(bool state) {
|
||||
@ -175,7 +174,7 @@ namespace ConformalDecals.UI {
|
||||
_style &= ~FontStyles.Italic;
|
||||
|
||||
_textBoxTMP.textComponent.fontStyle = _style | _font.FontStyle & ~_font.FontStyleMask;
|
||||
OnValueChanged();
|
||||
_textUpdated = true;
|
||||
}
|
||||
|
||||
public void OnUnderlineUpdate(bool state) {
|
||||
@ -187,7 +186,7 @@ namespace ConformalDecals.UI {
|
||||
_style &= ~FontStyles.Underline;
|
||||
|
||||
_textBoxTMP.textComponent.fontStyle = _style | _font.FontStyle & ~_font.FontStyleMask;
|
||||
OnValueChanged();
|
||||
_textUpdated = true;
|
||||
}
|
||||
|
||||
public void OnSmallCapsUpdate(bool state) {
|
||||
@ -199,19 +198,19 @@ namespace ConformalDecals.UI {
|
||||
_style &= ~FontStyles.SmallCaps;
|
||||
|
||||
_textBoxTMP.textComponent.fontStyle = _style | _font.FontStyle & ~_font.FontStyleMask;
|
||||
OnValueChanged();
|
||||
_textUpdated = true;
|
||||
}
|
||||
|
||||
public void OnVerticalUpdate(bool state) {
|
||||
if (_ignoreUpdates) return;
|
||||
|
||||
_vertical = state;
|
||||
OnValueChanged();
|
||||
_textUpdated = true;
|
||||
}
|
||||
|
||||
private void Start() {
|
||||
_lockString = $"ConformalDecals_TextEditor_{_lockCounter++}";
|
||||
|
||||
|
||||
_textBoxTMP = ((TMP_InputField) _textBox);
|
||||
_textBoxTMP.text = _text;
|
||||
_textBoxTMP.textComponent.fontStyle = _style | _font.FontStyle & ~_font.FontStyleMask;
|
||||
@ -229,9 +228,12 @@ namespace ConformalDecals.UI {
|
||||
private void OnDestroy() {
|
||||
RemoveControlLock();
|
||||
}
|
||||
|
||||
private void OnValueChanged() {
|
||||
_onValueChanged(_text, _font, _style, _vertical, _lineSpacing, _charSpacing);
|
||||
|
||||
private void LateUpdate() {
|
||||
if (_textUpdated) {
|
||||
_onValueChanged(_text, _font, _style, _vertical, _lineSpacing, _charSpacing);
|
||||
_textUpdated = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateStyleButtons() {
|
||||
|
@ -1,95 +0,0 @@
|
||||
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