GUI rearrangement

This commit is contained in:
AbstractConcept 2022-10-20 00:32:13 -05:00
parent 04f8c6a2e4
commit 2e50221118
90 changed files with 435 additions and 1440 deletions

View file

@ -0,0 +1,51 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
using UnityEngine;
namespace RimWorldAnimationStudio
{
[Serializable]
public class DirectionalGraphic
{
public string path = "Invalid file path";
[XmlIgnore] public Sprite sprite = null;
public void SetPath(string path)
{
string streamingAssets = Path.GetFullPath(Application.streamingAssetsPath);
string combinedPath = Path.GetFullPath(Path.Combine(streamingAssets, path));
if (path == null || path.Any() == false || Path.GetExtension(path) != ".png")
{ this.path = null; return; }
if (File.Exists(path) == false && File.Exists(combinedPath) == false)
{ this.path = null; return; }
if (path.Contains(streamingAssets))
{
path = path.Replace(streamingAssets, "");
path = path.TrimStart(new char[] { '\\', '/' });
}
this.path = path;
sprite = LoadSprite(Path.GetFullPath(Path.Combine(streamingAssets, path)));
}
public Sprite LoadSprite(string path)
{
if (path == null || path.Any() == false || File.Exists(path) == false || Path.GetExtension(path) != ".png") return null;
byte[] pngBytes = File.ReadAllBytes(path);
Texture2D texture = new Texture2D(2, 2);
texture.LoadImage(pngBytes);
Sprite sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 85.0f);
return sprite;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7eb64887148d9f44793b32cf5393c7ad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,50 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace RimWorldAnimationStudio
{
[Serializable]
public class MultiDirectionalGraphic
{
public string bodyType = "None";
public DirectionalGraphic northGraphic = new DirectionalGraphic();
public DirectionalGraphic eastGraphic = new DirectionalGraphic();
public DirectionalGraphic southGraphic = new DirectionalGraphic();
public MultiDirectionalGraphic() { }
public MultiDirectionalGraphic(string bodyType)
{
this.bodyType = bodyType;
}
public bool HasValidPathForDirection(CardinalDirection facing)
{
string path;
switch (facing)
{
case CardinalDirection.North: path = northGraphic.path; break;
case CardinalDirection.East: path = eastGraphic.path; break;
case CardinalDirection.South: path = southGraphic.path; break;
default: path = eastGraphic.path; break;
}
if (path == null || path.Any() == false || Path.GetExtension(path) != ".png")
{ return false; }
if (File.Exists(path) == false && File.Exists(Path.GetFullPath(Path.Combine(Application.streamingAssetsPath, path))) == false)
{ return false; }
return true;
}
//public bool ShouldSerializenorthGraphic() { return HasValidPathForDirection(CardinalDirection.North); }
//public bool ShouldSerializeeastGraphic() { return HasValidPathForDirection(CardinalDirection.East); }
//public bool ShouldSerializesouthGraphic() { return HasValidPathForDirection(CardinalDirection.South); }
//public bool ShouldSerializebodyType() { return ShouldSerializenorthGraphic() || ShouldSerializeeastGraphic() || ShouldSerializesouthGraphic(); }
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 86cb79b8d4c053f4a981ed17b86ae9bb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: