Skip to content
Permalink
Browse files

VSCode support, fix issues reported by omnisharp

- add omisharp code formatting rules
- fix issues reported by omnisharp
- fix spelling mistakes
  • Loading branch information...
ducakar committed Oct 22, 2018
1 parent 69e3c26 commit 7d704d000aabac7d9a502006c3507d24a3bcca78
@@ -1,7 +1,7 @@
/.vs
/.vscode
/*/bin
/*/obj
/GameData/TextureReplacer/README.md
/GameData/TextureReplacer/Plugins
/KSP.log
*.dll
@@ -27,7 +27,7 @@ TextureReplacer
// This option is intended for texture pack designers.
logTextures = false

// Dump full hierarchy (nodes, meshes, textures ...) of kerbonauts.
// Dump full hierarchy (nodes, meshes, textures ...) of Kerbals.
// This option is intended for mod developers.
logKerbalHierarchy = false

0 GameData/TextureReplacer/TR.cfg 100755 → 100644
No changes.
@@ -21,7 +21,7 @@ stock textures and customise your Kerbals. More specifically, it can:

Special thanks to:

* RangeMachine for contributing reflection shaders and maintaing the mod in my
* RangeMachine for contributing reflection shaders and maintaining the mod in my
absence.
* rbray89 who contributed a reflective visor shader and for Active Texture
Management and Visual Enhancements where some code has been borrowed from,
@@ -31,7 +31,7 @@ Special thanks to:
determination and role-based suit assignment,
* Razchek and Starwaster for Reflection Plugin where I learnt how to implement
reflections,
* sarbian for fixing an issue with non-mupliple-of-4 texture dimensions,
* sarbian for fixing an issue with non-multiple-of-4 texture dimensions,
* therealcrow999 for testing and benchmarking this plugin,
* Ippo343 for contributing KSP-AVC configuration,
* JPLRepo for contributing DeepFreeze compatibility fixes,
@@ -153,12 +153,12 @@ reflections onto the windows of Mk1-2 pod:
There are several parameters, all optional:

* `shader`: Most shaders should be automatically mapped to their reflective
counterparts. In some cases, however, thare are no reflective version of a
counterparts. In some cases, however, there are no reflective version of a
shader, so you will have to manually specify appropriate shader.
* `colour`: Reflection is pre-multiplied by this RGB value before added to the
material. "0.5 0.5 0.5" by default.
* `interval`: Once in how many steps the reflection is updated. "1" by default.
* `meshes`: Space- and/or comma-sparated list of mesh names where to apply
* `meshes`: Space- and/or comma-separated list of mesh names where to apply
reflections. Reflection is applied to whole part if this parameter is empty or
non-existent. You may find `logReflectiveMeshes` configuration option very
helpful as it prints names of all meshes for each part with `TRReflection`
@@ -293,7 +293,7 @@ Change Log
- skin tweaks: removed teeth, softer eyelashes and fixed some artefacts
* 3.2
- added Veteran and Vintage [suit] toggles in GUI
- removed leagacy females option
- removed legacy females option
- removed static reflections
- removed cabin-specific suits
- removed support for old, non-existent mods from configuration
@@ -430,7 +430,7 @@ Change Log
- cabin suits are now persistent until embarking another capsule
- changed experiance-based suit assignment to work with stock exp. traits
rather than KerbalStats exp.
- completely changed settings for experiance-based suits
- completely changed settings for experience-based suits
- removed KerbalStats support
- removed `headMultiplier` and `suitMultiplier` settings
* 2.0.2
@@ -73,14 +73,6 @@ class Personaliser
set { isAtmSuitEnabled = value; }
}

/// <summary>
/// Whether a vessel is in a "safe" situation, so Kerbals don't need helmets (i.e. landed/splashed or in orbit).
/// </summary>
static bool IsSituationSafe(Vessel vessel)
{
return vessel.situation != Vessel.Situations.FLYING && vessel.situation != Vessel.Situations.SUB_ORBITAL;
}

/// <summary>
/// Whether the atmosphere is breathable.
/// </summary>
@@ -201,7 +201,6 @@ public static void UpdateScripts()
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
};
static readonly Shader TransparentSpecularShader = Shader.Find("Transparent/Specular");

readonly Dictionary<Shader, Shader> shaderMap = new Dictionary<Shader, Shader>();
// Reflection camera.
@@ -229,7 +228,7 @@ static void EnsureCamera()
camera = new GameObject("TRReflectionCamera", new[] { typeof(Camera) }).GetComponent<Camera>();
camera.enabled = false;
camera.clearFlags = CameraClearFlags.Depth;
// Any smaller number and visors will refect internals of helmets.
// Any smaller number and visors will reflect internals of helmets.
camera.nearClipPlane = 0.125f;
camera.layerCullDistances = CullDistances;
}
@@ -288,13 +287,13 @@ public void Load()
}
string shadersPath = IOUtils.GetFilePathFor(GetType(), shadersFileName);

AssetBundle shadersBoundle = null;
AssetBundle shadersBundle = null;
try {
shadersBoundle = AssetBundle.LoadFromFile(shadersPath);
if (shadersBoundle == null) {
shadersBundle = AssetBundle.LoadFromFile(shadersPath);
if (shadersBundle == null) {
log.Print("Failed to load shader asset file: {0}", shadersPath);
} else {
visorShader = shadersBoundle.LoadAsset<Shader>("assets/visor.shader");
visorShader = shadersBundle.LoadAsset<Shader>("assets/visor.shader");
if (visorShader == null) {
log.Print("Visor shader missing in the asset file");
} else {
@@ -304,8 +303,8 @@ public void Load()
} catch (System.Exception ex) {
log.Print("Visor shader loading failed: {0}", ex);
} finally {
if (shadersBoundle != null) {
shadersBoundle.Unload(false);
if (shadersBundle != null) {
shadersBundle.Unload(false);
}
}

@@ -31,12 +31,12 @@ namespace TextureReplacer
class Replacer
{
public const string TexturesDirectory = Util.Directory + "Default/";
public const string Navball = "NavBall";
public static readonly Vector2 NavballScale = new Vector2(-1.0f, 1.0f);
public const string NavBall = "NavBall";
public static readonly Vector2 NavBallScale = new Vector2(-1.0f, 1.0f);
public static readonly Shader BumpedHeadShader = Shader.Find("Bumped Diffuse");

static readonly Log log = new Log(nameof(Replacer));
static readonly Shader BasicVisorShader = Shader.Find("Transparent/Diffuse");
static readonly Shader BasicVisorShader = Shader.Find("Transparent/Specular");

// General texture replacements.
readonly List<string> paths = new List<string> { TexturesDirectory };
@@ -109,22 +109,22 @@ void ReplaceTextures()
/// <summary>
/// Replace NavBalls' textures.
/// </summary>
void UpdateNavball()
void UpdateNavBall()
{
if (navBallTexture != null) {
NavBall hudNavball = UnityEngine.Object.FindObjectOfType<NavBall>();
if (hudNavball != null) {
Material material = hudNavball.navBall.GetComponent<Renderer>().sharedMaterial;
NavBall hudNavBall = UnityEngine.Object.FindObjectOfType<NavBall>();
if (hudNavBall != null) {
Material material = hudNavBall.navBall.GetComponent<Renderer>().sharedMaterial;

material.SetTexture(Util.MainTextureProperty, navBallTexture);
}

InternalNavBall ivaNavball = InternalSpace.Instance.GetComponentInChildren<InternalNavBall>();
if (ivaNavball != null) {
Material material = ivaNavball.navBall.GetComponent<Renderer>().sharedMaterial;
InternalNavBall ivaNavBall = InternalSpace.Instance.GetComponentInChildren<InternalNavBall>();
if (ivaNavBall != null) {
Material material = ivaNavBall.navBall.GetComponent<Renderer>().sharedMaterial;

material.mainTexture = navBallTexture;
material.SetTextureScale(Util.MainTexProperty, NavballScale);
material.SetTextureScale(Util.MainTexProperty, NavBallScale);
}
}
}
@@ -218,7 +218,7 @@ void FixKerbalModels()

for (int i = 0; i < 3; ++i) {
foreach (SkinnedMeshRenderer smr in femaleMeshes[i]) {
// Here we must enumarate all meshes wherever we are replacing the material.
// Here we must enumerate all meshes wherever we are replacing the material.
switch (smr.name) {
case "mesh_female_kerbalAstronaut01_kerbalGirl_mesh_pCube1":
case "mesh_female_kerbalAstronaut01_kerbalGirl_mesh_polySurface51":
@@ -310,8 +310,8 @@ public void Load()
FixKerbalModels();

// Find NavBall replacement textures if available.
if (mappedTextures.TryGetValue(Navball, out navBallTexture)) {
mappedTextures.Remove(Navball);
if (mappedTextures.TryGetValue(NavBall, out navBallTexture)) {
mappedTextures.Remove(NavBall);

if (navBallTexture.mipmapCount != 1) {
log.Print("NavBall texture should not have mipmaps!");
@@ -322,7 +322,7 @@ public void Load()
public void OnBeginFlight()
{
if (navBallTexture != null) {
UpdateNavball();
UpdateNavBall();
}
}

@@ -23,7 +23,7 @@
namespace TextureReplacer
{
/// <summary>
/// This class takes cares of EVA Kerbal to assign appropriate suit on creation, watch for atmospehere charges (to put
/// This class takes cares of EVA Kerbal to assign appropriate suit on creation, watch for atmosphere charges (to put
/// on spacesuit of it leaves breathable atmosphere) and enables "Toggle EVA Suit" action.
///
/// It is added to EVA kerbal by Personaliser so it doesn't need to be public.
@@ -22,7 +22,6 @@

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;

namespace TextureReplacer
@@ -39,14 +38,6 @@ static class Util
public static readonly int ReflectColorProperty = Shader.PropertyToID("_ReflectColor");
public static readonly System.Random Random = new System.Random();

/// <summary>
/// True iff `i` is a power of two.
/// </summary>
public static bool IsPow2(int i)
{
return i > 0 && (i & (i - 1)) == 0;
}

/// <summary>
/// Split a space- and/or comma-separated configuration file value into its tokens.
/// </summary>
@@ -115,19 +106,7 @@ public static void AddLists(string[] listInstances, ICollection<string> jointLis
}

/// <summary>
/// Add all space-or-comma-separated regex values from listInstances strings to jointList.
/// </summary>
public static void AddRELists(string[] listInstances, ICollection<Regex> jointList)
{
foreach (string listInstance in listInstances) {
foreach (string item in SplitConfigValue(listInstance)) {
jointList.Add(new Regex(item));
}
}
}

/// <summary>
/// Print hierarchy under a fransform.
/// Print hierarchy under a transform.
/// </summary>
public static void LogDownHierarchy(Transform tf, int indent = 0)
{
@@ -160,6 +139,7 @@ public static void LogDownHierarchy(Transform tf, int indent = 0)
}
}

#if false
/// <summary>
/// Print hierarchy from a transform up to the root.
/// </summary>
@@ -179,5 +159,6 @@ public static void LogUpHierarchy(Transform tf)
}
}
}
#endif
}
}
@@ -0,0 +1,12 @@
{
"FormattingOptions": {
"TabSize": 8,
"IndentationSize": 2,
"NewLinesForBracesInProperties": false,
"NewLinesForBracesInControlBlocks": false,
"NewLinesForBracesInObjectCollectionArrayInitializers": false,
"NewLineForElse": false,
"NewLineForCatch": false,
"NewLineForFinally": false
}
}

0 comments on commit 7d704d0

Please sign in to comment.
You can’t perform that action at this time.