12 Commits

Author SHA1 Message Date
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
12 changed files with 415 additions and 99 deletions

View File

@ -46,7 +46,7 @@ jobs:
- name: Download KSP Dependencies
run: |
wget http://pileof.rocks/KSP/Shabby_v0.2.0.zip
wget http://taniwha.org/~bill/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

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

@ -8,6 +8,28 @@ All notable changes to this project will be documented in this file
| website | https://forum.kerbalspaceprogram.com/index.php?/topic/194802-18-111-conformal-decals |
| author | Andrew Cassidy |
## 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

View File

@ -49,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,5 +1,5 @@
# 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)
[![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)

View File

@ -15,6 +15,7 @@ namespace ConformalDecals {
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;
@ -53,6 +54,8 @@ namespace ConformalDecals {
public static IEnumerable<DecalFont> Fonts => _fontList.Values;
public static Dictionary<string, float> AspectRatios => _aspectRatios;
public static bool IsBlacklisted(Shader shader) {
return IsBlacklisted(shader.name);
}
@ -86,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");
}
}
@ -113,8 +115,17 @@ namespace ConformalDecals {
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);
}
}
@ -144,6 +155,7 @@ namespace ConformalDecals {
_shaderBlacklist = new List<string>();
_shaderRegexBlacklist = new List<Regex>();
_fontList = new Dictionary<string, DecalFont>();
_aspectRatios = new Dictionary<string, float>();
var configs = GameDatabase.Instance.GetConfigs("CONFORMALDECALS");

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,6 +159,7 @@ namespace ConformalDecals.MaterialProperties {
foreach (var material in Materials) {
property.Remove(material);
}
_materialProperties.Remove(propertyName);
Destroy(property);
@ -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) {

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;
@ -261,8 +261,7 @@ namespace ConformalDecals {
// set initial attachment state
if (part.parent == null) {
OnDetach();
}
else {
} else {
OnAttach();
}
}
@ -400,30 +399,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 +441,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 +475,7 @@ namespace ConformalDecals {
protected void UpdateTargets() {
if (_targets == null) {
_targets = new List<ProjectionTarget>();
}
else {
} else {
_targets.Clear();
}
@ -577,7 +580,8 @@ namespace ConformalDecals {
// 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

@ -1,3 +1,4 @@
using ConformalDecals.Util;
using UnityEngine;
namespace ConformalDecals {
@ -106,13 +107,13 @@ namespace ConformalDecals {
// 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;
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;
}
UpdateMaterials();