20 Commits

Author SHA1 Message Date
1e7c6d81c9 Merge branch 'main' into release 2020-11-29 16:31:55 -08:00
dda988db17 Quick bugfix 2020-11-29 16:31:41 -08:00
900061f7f6 Merge branch 'main' into release 2020-11-29 16:09:03 -08:00
e56278c6cb Fix stock flags being stretched 2020-11-29 16:02:45 -08:00
2793f5fcb1 Fix DLL copying 2020-11-26 19:17:31 -08:00
833ec43a52 Update project files 2020-11-26 17:47:42 -08:00
e6856124e7 Another attempt at fixing the planet glitch 2020-11-25 02:44:04 -08:00
8ed7a130ab Alternate rendertex handling 2020-11-22 20:18:16 -08:00
d8d3d4ed92 Merge branch 'main' into release 2020-11-16 16:49:01 -08:00
334af786f6 Version change 2020-11-16 16:48:45 -08:00
17ef93bb6e Copy other text parameters to symmetry counterparts 2020-11-16 16:45:54 -08:00
a6d58690f9 Merge branch 'main' into release 2020-11-16 15:45:16 -08:00
a6de537e4a ScaleRange change 2020-11-16 15:44:40 -08:00
33b0307aa2 Lower text decal default size 2020-11-16 15:39:41 -08:00
121428414c Add input locks for text entry 2020-11-16 15:34:10 -08:00
98f774b2ae More font fixes and UI changes
- Lowered step size for decal size and depth to 1cm.
 - Changed default max size to 10m.
 - Text decals now show as a circle if they contain only whitespace.
 - Fixed font name in config and defaulted to Calibri if its missing
2020-11-16 15:05:55 -08:00
d31576fb0b Fix font saving and rendering 2020-11-16 14:44:07 -08:00
c9853049c5 Clear rendertex because KSP wont 2020-11-16 14:01:10 -08:00
f108341068 Merge branch 'main' into release 2020-11-14 21:26:28 -08:00
40d4e2cc8a Update changelog 2020-11-14 21:26:16 -08:00
15 changed files with 141 additions and 167 deletions

1
.gitignore vendored
View File

@ -50,3 +50,4 @@ Source/ConformalDecals/bin
*.sublime* *.sublime*
.idea .idea
obj obj
*.swp

View File

@ -52,7 +52,7 @@ PART
name = ModuleConformalText name = ModuleConformalText
text = Text text = Text
font = Calibri SDF fontName = Calibri SDF
fillColor = #000000FF fillColor = #000000FF
outlineColor = #FFFFFFFF outlineColor = #FFFFFFFF
fillEnabled = true fillEnabled = true
@ -62,6 +62,7 @@ PART
useBaseNormal = true useBaseNormal = true
scaleMode = MINIMUM scaleMode = MINIMUM
defaultScale = 0.2
defaultDepth = 0.2 defaultDepth = 0.2
defaultCutoff = 0.5 defaultCutoff = 0.5
} }

View File

@ -6,8 +6,8 @@
{ {
"MAJOR":0, "MAJOR":0,
"MINOR":2, "MINOR":2,
"PATCH":3, "PATCH":6,
"BUILD":0 "BUILD":1
}, },
"KSP_VERSION": "KSP_VERSION":
{ {

View File

@ -1,4 +1,4 @@
# Conformal Decals v0.2.3 # Conformal Decals v0.2.6
[![Build Status](https://travis-ci.org/drewcassidy/KSP-Conformal-Decals.svg?branch=release)](https://travis-ci.org/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) [![Build Status](https://travis-ci.org/drewcassidy/KSP-Conformal-Decals.svg?branch=release)](https://travis-ci.org/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)
![Screenshot](http://pileof.rocks/KSP/images/ConformalDecalsHeader.png) ![Screenshot](http://pileof.rocks/KSP/images/ConformalDecalsHeader.png)

View File

@ -1,6 +1,6 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 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 EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -8,9 +8,9 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1ea983f9-42e5-494e-9683-fdac9c9121f4}.Debug|Any CPU.ActiveCfg = Debug|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}.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.ActiveCfg = Release|Any CPU
{1ea983f9-42e5-494e-9683-fdac9c9121f4}.Release|Any CPU.Build.0 = Release|Any CPU {1EA983F9-42E5-494E-9683-FDAC9C9121F4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -1,115 +1,55 @@
<?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk">
<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')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <TargetFramework>net48</TargetFramework>
<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>
<LangVersion>8</LangVersion> <LangVersion>8</LangVersion>
<RootNamespace>ConformalDecals</RootNamespace> <IsPackable>false</IsPackable>
</PropertyGroup> <PlatformTarget>x64</PlatformTarget>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <NoWarn>1701;1702;CS0649;CS1591</NoWarn>
<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>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>dlls/Assembly-CSharp.dll</HintPath> <HintPath>dlls\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="KSPAssets, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>dlls\KSPAssets.dll</HintPath>
</Reference> </Reference>
<Reference Include="Shabby, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="Shabby, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>dlls/Shabby.dll</HintPath> <HintPath>dlls\Shabby.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>dlls/UnityEngine.dll</HintPath> <HintPath>dlls\UnityEngine.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEngine.AssetBundleModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <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>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <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>
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>dlls/UnityEngine.PhysicsModule.dll</HintPath> <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>
</Reference> </Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>dlls/UnityEngine.UI.dll</HintPath> <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>
</Reference> </Reference>
<Reference Include="UnityEngine.UIModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <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> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="DecalConfig.cs" /> <Compile Remove="dlls\**"/>
<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" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)/Microsoft.CSharp.targets" />
<PropertyGroup> <ItemGroup>
<PostBuildEvent>sh -e -c "cp -v '$(TargetPath)' '$(SolutionDir)/../GameData/ConformalDecals/Plugins'"</PostBuildEvent> <EmbeddedResource Remove="dlls\**"/>
</PropertyGroup> </ItemGroup>
<ItemGroup>
<None Remove="dlls\**"/>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="/bin/cp -v '$(OutDir)ConformalDecals.dll' '$(SolutionDir)../GameData/ConformalDecals/Plugins'" IgnoreExitCode="true"/>
<!--Fuck you MSBuild stop trying to run CMD.exe on macOS-->
</Target>
</Project> </Project>

View File

@ -41,7 +41,13 @@ namespace ConformalDecals.MaterialProperties {
public Vector2 Dimensions => new Vector2(_texture.width, _texture.height); public Vector2 Dimensions => new Vector2(_texture.width, _texture.height);
public Vector2 MaskedDimensions => _hasTile ? _tileRect.size : Dimensions; 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) { public override void ParseNode(ConfigNode node) {
base.ParseNode(node); base.ParseNode(node);

View File

@ -31,7 +31,7 @@ namespace ConformalDecals {
[KSPField] public bool scaleAdjustable = true; [KSPField] public bool scaleAdjustable = true;
[KSPField] public float defaultScale = 1; [KSPField] public float defaultScale = 1;
[KSPField] public Vector2 scaleRange = new Vector2(0, 4); [KSPField] public Vector2 scaleRange = new Vector2(0, 5);
[KSPField] public DecalScaleMode scaleMode = DecalScaleMode.HEIGHT; [KSPField] public DecalScaleMode scaleMode = DecalScaleMode.HEIGHT;
@ -60,19 +60,19 @@ namespace ConformalDecals {
// INTERNAL VALUES // INTERNAL VALUES
[KSPField(guiName = "#LOC_ConformalDecals_gui-scale", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F2", guiUnits = "m"), [KSPField(guiName = "#LOC_ConformalDecals_gui-scale", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F2", guiUnits = "m"),
UI_FloatRange(stepIncrement = 0.05f)] UI_FloatRange()]
public float scale = 1.0f; public float scale = 1.0f;
[KSPField(guiName = "#LOC_ConformalDecals_gui-depth", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F2", guiUnits = "m"), [KSPField(guiName = "#LOC_ConformalDecals_gui-depth", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F2", guiUnits = "m"),
UI_FloatRange(stepIncrement = 0.02f)] UI_FloatRange()]
public float depth = 0.2f; public float depth = 0.2f;
[KSPField(guiName = "#LOC_ConformalDecals_gui-opacity", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "P0"), [KSPField(guiName = "#LOC_ConformalDecals_gui-opacity", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "P0"),
UI_FloatRange(stepIncrement = 0.05f)] UI_FloatRange()]
public float opacity = 1.0f; public float opacity = 1.0f;
[KSPField(guiName = "#LOC_ConformalDecals_gui-cutoff", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "P0"), [KSPField(guiName = "#LOC_ConformalDecals_gui-cutoff", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "P0"),
UI_FloatRange(stepIncrement = 0.05f)] UI_FloatRange()]
public float cutoff = 0.5f; public float cutoff = 0.5f;
[KSPField(guiName = "#LOC_ConformalDecals_gui-wear", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F0"), [KSPField(guiName = "#LOC_ConformalDecals_gui-wear", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F0"),
@ -215,7 +215,7 @@ namespace ConformalDecals {
foreach (var keyword in _decalMaterial.shaderKeywords) { foreach (var keyword in _decalMaterial.shaderKeywords) {
this.Log($"keyword: {keyword}"); this.Log($"keyword: {keyword}");
} }
if (HighLogic.LoadedSceneIsEditor) { if (HighLogic.LoadedSceneIsEditor) {
UpdateTweakables(); UpdateTweakables();
} }
@ -400,7 +400,7 @@ namespace ConformalDecals {
protected void UpdateScale() { protected void UpdateScale() {
scale = Mathf.Max(0.01f, scale); scale = Mathf.Max(0.01f, scale);
depth = Mathf.Max(0.01f, depth); depth = Mathf.Max(0.01f, depth);
var aspectRatio = materialProperties.AspectRatio; var aspectRatio = Mathf.Max(0.01f, materialProperties.AspectRatio);
Vector2 size; Vector2 size;
switch (scaleMode) { switch (scaleMode) {
@ -512,7 +512,7 @@ namespace ConformalDecals {
cutoffField.guiActiveEditor = cutoffAdjustable; cutoffField.guiActiveEditor = cutoffAdjustable;
wearField.guiActiveEditor = useBaseNormal; wearField.guiActiveEditor = useBaseNormal;
var steps = 40; var steps = 20;
if (scaleAdjustable) { if (scaleAdjustable) {
var minValue = Mathf.Max(Mathf.Epsilon, scaleRange.x); var minValue = Mathf.Max(Mathf.Epsilon, scaleRange.x);
@ -521,7 +521,7 @@ namespace ConformalDecals {
var scaleEditor = (UI_FloatRange) scaleField.uiControlEditor; var scaleEditor = (UI_FloatRange) scaleField.uiControlEditor;
scaleEditor.minValue = minValue; scaleEditor.minValue = minValue;
scaleEditor.maxValue = maxValue; scaleEditor.maxValue = maxValue;
scaleEditor.stepIncrement = (maxValue - minValue) / steps; scaleEditor.stepIncrement = 0.01f; //1cm
scaleEditor.onFieldChanged = OnSizeTweakEvent; scaleEditor.onFieldChanged = OnSizeTweakEvent;
} }
@ -532,7 +532,7 @@ namespace ConformalDecals {
var depthEditor = (UI_FloatRange) depthField.uiControlEditor; var depthEditor = (UI_FloatRange) depthField.uiControlEditor;
depthEditor.minValue = minValue; depthEditor.minValue = minValue;
depthEditor.maxValue = maxValue; depthEditor.maxValue = maxValue;
depthEditor.stepIncrement = (maxValue - minValue) / steps; depthEditor.stepIncrement = 0.01f; //1cm
depthEditor.onFieldChanged = OnSizeTweakEvent; depthEditor.onFieldChanged = OnSizeTweakEvent;
} }

View File

@ -94,12 +94,25 @@ namespace ConformalDecals {
public override void OnLoad(ConfigNode node) { public override void OnLoad(ConfigNode node) {
base.OnLoad(node); base.OnLoad(node);
text = WebUtility.UrlDecode(ParseUtil.ParseString(node, "text"));
font = DecalConfig.GetFont(ParseUtil.ParseString(node, "font", true, "Calibri SDF")); string textRaw = "";
if (ParseUtil.ParseStringIndirect(ref textRaw, node, "text")) {
text = WebUtility.UrlDecode(textRaw);
}
string fontName = "";
if (ParseUtil.ParseStringIndirect(ref fontName, node, "fontName")) {
font = DecalConfig.GetFont(fontName);
}
else if (font == null) font = DecalConfig.GetFont("Calibri SDF");
int styleInt = 0; int styleInt = 0;
if (ParseUtil.ParseIntIndirect(ref styleInt, node, "style")) style = (FontStyles) styleInt; if (ParseUtil.ParseIntIndirect(ref styleInt, node, "style")) {
if (!ParseUtil.ParseColor32Indirect(ref fillColor, node, "fillColor")) fillColor = Color.magenta; style = (FontStyles) styleInt;
if (!ParseUtil.ParseColor32Indirect(ref outlineColor, node, "outlineColor")) outlineColor = Color.magenta; }
ParseUtil.ParseColor32Indirect(ref fillColor, node, "fillColor");
ParseUtil.ParseColor32Indirect(ref outlineColor, node, "outlineColor");
if (HighLogic.LoadedSceneIsGame) { if (HighLogic.LoadedSceneIsGame) {
// For some reason, rendering doesnt work right on the first frame a scene is loaded // For some reason, rendering doesnt work right on the first frame a scene is loaded
@ -210,12 +223,12 @@ namespace ConformalDecals {
public override void OnDestroy() { public override void OnDestroy() {
if (HighLogic.LoadedSceneIsGame && _currentText != null) TextRenderer.UnregisterText(_currentText); if (HighLogic.LoadedSceneIsGame && _currentText != null) TextRenderer.UnregisterText(_currentText);
// close all UIs // close all UIs
if (_textEntryController != null) _textEntryController.Close(); if (_textEntryController != null) _textEntryController.Close();
if (_fillColorPickerController != null) _fillColorPickerController.Close(); if (_fillColorPickerController != null) _fillColorPickerController.Close();
if (_outlineColorPickerController != null) _outlineColorPickerController.Close(); if (_outlineColorPickerController != null) _outlineColorPickerController.Close();
base.OnDestroy(); base.OnDestroy();
} }
@ -236,6 +249,9 @@ namespace ConformalDecals {
decal.text = text; decal.text = text;
decal.font = font; decal.font = font;
decal.style = style; decal.style = style;
decal.vertical = vertical;
decal.charSpacing = charSpacing;
decal.lineSpacing = lineSpacing;
decal._currentJob = _currentJob; decal._currentJob = _currentJob;
decal._currentText = _currentText; decal._currentText = _currentText;

View File

@ -1,38 +1 @@
using System.Reflection; [assembly: KSPAssembly("ConformalDecals", 0, 2, 6)]
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)]

View File

@ -32,6 +32,7 @@ namespace ConformalDecals.Text {
/// The text formatted with newlines for vertical text /// The text formatted with newlines for vertical text
public string FormattedText { public string FormattedText {
get { get {
if (string.IsNullOrWhiteSpace(Text)) return "•";
if (Vertical) { if (Vertical) {
return Regex.Replace(Text, @"(.)", "$1\n"); return Regex.Replace(Text, @"(.)", "$1\n");
} }

View File

@ -255,8 +255,7 @@ namespace ConformalDecals.Text {
bounds.center.y - halfSize.y, bounds.center.y + halfSize.y, -1, 1); bounds.center.y - halfSize.y, bounds.center.y + halfSize.y, -1, 1);
// GET RENDERTEX // GET RENDERTEX
var renderTex = RenderTexture.GetTemporary(textureSize.x, textureSize.y, 0, textRenderTextureFormat, RenderTextureReadWrite.Linear, 1); var renderTex = new RenderTexture(textureSize.x, textureSize.y, 0, textRenderTextureFormat, RenderTextureReadWrite.Linear) {autoGenerateMips = false};
renderTex.autoGenerateMips = false;
// RENDER // RENDER
Graphics.SetRenderTarget(renderTex); Graphics.SetRenderTarget(renderTex);
@ -272,15 +271,18 @@ namespace ConformalDecals.Text {
} }
} }
GL.PopMatrix();
// COPY TEXTURE BACK INTO RAM // COPY TEXTURE BACK INTO RAM
var prevRT = RenderTexture.active;
RenderTexture.active = renderTex; RenderTexture.active = renderTex;
texture.ReadPixels(new Rect(0, 0, textureSize.x, textureSize.y), 0, 0, true); texture.ReadPixels(new Rect(0, 0, textureSize.x, textureSize.y), 0, 0, true);
texture.Apply(); texture.Apply();
RenderTexture.active = prevRT;
GL.PopMatrix();
// RELEASE RENDERTEX // RELEASE RENDERTEX
RenderTexture.ReleaseTemporary(renderTex); renderTex.Release();
RenderTexture.Destroy(renderTex);
// CLEAR SUBMESHES // CLEAR SUBMESHES
_tmp.text = ""; _tmp.text = "";

View File

@ -11,7 +11,6 @@ namespace ConformalDecals.UI {
[Serializable] [Serializable]
public delegate void TextUpdateDelegate(string newText, DecalFont newFont, FontStyles style, bool vertical, float linespacing, float charspacing); public delegate void TextUpdateDelegate(string newText, DecalFont newFont, FontStyles style, bool vertical, float linespacing, float charspacing);
[SerializeField] private Selectable _textBox; [SerializeField] private Selectable _textBox;
[SerializeField] private Button _fontButton; [SerializeField] private Button _fontButton;
@ -40,7 +39,10 @@ namespace ConformalDecals.UI {
private FontMenuController _fontMenu; private FontMenuController _fontMenu;
private bool _ignoreUpdates; private bool _ignoreUpdates;
private bool _isLocked;
private string _lockString;
private static int _lockCounter;
public static TextEntryController Create( public static TextEntryController Create(
string text, DecalFont font, FontStyles style, bool vertical, float linespacing, float charspacing, string text, DecalFont font, FontStyles style, bool vertical, float linespacing, float charspacing,
@ -70,6 +72,18 @@ namespace ConformalDecals.UI {
Destroy(gameObject); Destroy(gameObject);
} }
public void SetControlLock(string value = null) {
if (_isLocked) return;
InputLockManager.SetControlLock(_lockString);
_isLocked = true;
}
public void RemoveControlLock(string value = null) {
if (!_isLocked) return;
InputLockManager.RemoveControlLock(_lockString);
_isLocked = false;
}
public void OnTextUpdate(string newText) { public void OnTextUpdate(string newText) {
this._text = newText; this._text = newText;
@ -195,12 +209,15 @@ namespace ConformalDecals.UI {
OnValueChanged(); OnValueChanged();
} }
private void Start() { private void Start() {
_lockString = $"ConformalDecals_TextEditor_{_lockCounter++}";
_textBoxTMP = ((TMP_InputField) _textBox); _textBoxTMP = ((TMP_InputField) _textBox);
_textBoxTMP.text = _text; _textBoxTMP.text = _text;
_textBoxTMP.textComponent.fontStyle = _style | _font.FontStyle & ~_font.FontStyleMask; _textBoxTMP.textComponent.fontStyle = _style | _font.FontStyle & ~_font.FontStyleMask;
_textBoxTMP.fontAsset = _font.FontAsset; _textBoxTMP.fontAsset = _font.FontAsset;
_textBoxTMP.onSelect.AddListener(SetControlLock);
_textBoxTMP.onDeselect.AddListener(RemoveControlLock);
_font.SetupSample(_fontButton.GetComponentInChildren<TextMeshProUGUI>()); _font.SetupSample(_fontButton.GetComponentInChildren<TextMeshProUGUI>());
@ -209,6 +226,10 @@ namespace ConformalDecals.UI {
UpdateCharSpacing(); UpdateCharSpacing();
} }
private void OnDestroy() {
RemoveControlLock();
}
private void OnValueChanged() { private void OnValueChanged() {
_onValueChanged(_text, _font, _style, _vertical, _lineSpacing, _charSpacing); _onValueChanged(_text, _font, _style, _vertical, _lineSpacing, _charSpacing);
} }

View File

@ -1,11 +1,34 @@
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 v0.2.3
------ ------
- Fixes: - Fixes:
- Fixed TMP subobjects being deleted, causing fallback fonts to fail in some situations. - 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. - 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 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 decals having drag and causing issues when using FAR.
- Fixed broken saving of text decals in certain circumstances.
v0.2.2 v0.2.2
------ ------
- Fixes: - Fixes: