mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Squashed commit of the following:
commitaf4dab5546
Author: AbstractConcept <abstract.concept@mail.com> Date: Mon Oct 31 19:58:41 2022 -0500 Code refactor commite14a12f2ab
Author: AbstractConcept <abstract.concept@mail.com> Date: Mon Oct 31 00:44:53 2022 -0500 Code refactor commit5ca7e486f8
Author: AbstractConcept <abstract.concept@mail.com> Date: Fri Oct 28 19:52:58 2022 -0500 Code refactor commita55ba7b95b
Author: AbstractConcept <abstract.concept@mail.com> Date: Fri Oct 28 00:28:51 2022 -0500 Code refactor commit757badf4f6
Author: AbstractConcept <abstract.concept@mail.com> Date: Thu Oct 27 00:56:04 2022 -0500 Code refactor
This commit is contained in:
parent
cd4711a8e5
commit
bb2cc29393
603 changed files with 9200 additions and 7528 deletions
|
@ -17,25 +17,33 @@ namespace RimWorldAnimationStudio
|
|||
public Toggle isHumanoidToggle;
|
||||
public InputField scaleField;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
raceSelectDropdown.ClearOptions();
|
||||
raceSelectDropdown.AddOptions(PawnRaceDefs.allDefs.Select(x => x.defName).ToList());
|
||||
|
||||
base.OnEnable();
|
||||
}
|
||||
|
||||
public override void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
Reset();
|
||||
|
||||
AlienRaceDef alienRaceDef = GetCurrentRaceDef();
|
||||
if (alienRaceDef == null) return;
|
||||
PawnRaceDef pawnRaceDef = GetCurrentRaceDef();
|
||||
if (pawnRaceDef == null) return;
|
||||
|
||||
isHumanoidToggle.SetIsOnWithoutNotify(alienRaceDef.isHumanoid);
|
||||
isHumanoidToggle.SetIsOnWithoutNotify(pawnRaceDef.isHumanoid);
|
||||
|
||||
Text bodyGraphicsTitle = AddCloneObjectToParent(raceSettingsWindow, 2).GetComponent<Text>();
|
||||
bodyGraphicsTitle.text = "Body graphic filepaths";
|
||||
|
||||
List<string> allTags = alienRaceDef.isHumanoid ? Tags.bodyTypes : new List<string>() { "None" };
|
||||
List<string> allTags = pawnRaceDef.isHumanoid ? DefaultTags.bodyTypes : new List<string>() { "None" };
|
||||
|
||||
foreach (string bodyType in allTags)
|
||||
{
|
||||
string _bodyType = bodyType;
|
||||
|
||||
if (alienRaceDef.isHumanoid)
|
||||
if (pawnRaceDef.isHumanoid)
|
||||
{
|
||||
Text bodyTypeTitle = AddCloneObjectToParent(raceSettingsWindow, 2).GetComponent<Text>();
|
||||
bodyTypeTitle.text = bodyType;
|
||||
|
@ -49,15 +57,15 @@ namespace RimWorldAnimationStudio
|
|||
filepath.GetComponent<Text>().text = facing.ToString();
|
||||
filepath.transform.Find("FilepathButton").GetComponent<Button>().onClick.AddListener(delegate
|
||||
{
|
||||
SetBodyTypeGraphicPath(alienRaceDef, facing, _bodyType);
|
||||
SetBodyTypeGraphicPath(pawnRaceDef, facing, _bodyType);
|
||||
});
|
||||
filepath.transform.FindDeepChild("FilepathLabel").GetComponent<Text>().text = alienRaceDef.GetBodyTypeGraphicPath(facing, _bodyType);
|
||||
filepath.transform.FindDeepChild("FilepathLabel").GetComponent<Text>().text = pawnRaceDef.GetBodyTypeGraphicPath(facing, _bodyType);
|
||||
}
|
||||
|
||||
AddCloneObjectToParent(raceSettingsWindow, 3);
|
||||
}
|
||||
|
||||
if (alienRaceDef.isHumanoid)
|
||||
if (pawnRaceDef.isHumanoid)
|
||||
{
|
||||
Text headGraphics = AddCloneObjectToParent(raceSettingsWindow, 2).GetComponent<Text>();
|
||||
headGraphics.text = "Head graphic filepaths";
|
||||
|
@ -70,71 +78,73 @@ namespace RimWorldAnimationStudio
|
|||
filepath.GetComponent<Text>().text = facing.ToString();
|
||||
filepath.transform.Find("FilepathButton").GetComponent<Button>().onClick.AddListener(delegate
|
||||
{
|
||||
SetHeadGraphicPath(alienRaceDef, facing);
|
||||
SetHeadGraphicPath(pawnRaceDef, facing);
|
||||
});
|
||||
filepath.transform.FindDeepChild("FilepathLabel").GetComponent<Text>().text = alienRaceDef.GetHeadGraphicPath(facing);
|
||||
filepath.transform.FindDeepChild("FilepathLabel").GetComponent<Text>().text = pawnRaceDef.GetHeadGraphicPath(facing);
|
||||
}
|
||||
|
||||
AddCloneObjectToParent(raceSettingsWindow, 3);
|
||||
}
|
||||
|
||||
scaleField.text = string.Format("{0:0.000}", alienRaceDef.scale.ToString());
|
||||
scaleField.text = string.Format("{0:0.000}", pawnRaceDef.scale);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
RemoveCloneObjectsFromParent(raceSettingsWindow);
|
||||
RemoveCloneObjectsFromParent(raceSettingsWindow);
|
||||
}
|
||||
|
||||
public void SetIsHumanoid()
|
||||
{
|
||||
AlienRaceDef alienRaceDef = GetCurrentRaceDef();
|
||||
if (alienRaceDef == null) return;
|
||||
PawnRaceDef pawnRaceDef = GetCurrentRaceDef();
|
||||
if (pawnRaceDef == null) return;
|
||||
|
||||
alienRaceDef.isHumanoid = isHumanoidToggle.isOn;
|
||||
pawnRaceDef.isHumanoid = isHumanoidToggle.isOn;
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public void SetHeadGraphicPath(AlienRaceDef alienRaceDef, CardinalDirection direction)
|
||||
public void SetHeadGraphicPath(PawnRaceDef pawnRaceDef, CardinalDirection direction)
|
||||
{
|
||||
var paths = StandaloneFileBrowser.OpenFilePanel("Select texture File", "", "png", false);
|
||||
|
||||
if (paths == null || paths.Any() == false || File.Exists(paths[0]) == false)
|
||||
{ Debug.LogWarning("Selected file was null or invalid"); return; }
|
||||
|
||||
alienRaceDef.SetHeadGraphicPath(paths[0], direction);
|
||||
pawnRaceDef.SetHeadGraphicPath(paths[0], direction);
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public void SetBodyTypeGraphicPath(AlienRaceDef alienRaceDef, CardinalDirection direction, string bodyType)
|
||||
public void SetBodyTypeGraphicPath(PawnRaceDef pawnRaceDef, CardinalDirection direction, string bodyType)
|
||||
{
|
||||
var paths = StandaloneFileBrowser.OpenFilePanel("Select texture File", "", "png", false);
|
||||
|
||||
if (paths == null || paths.Any() == false || File.Exists(paths[0]) == false)
|
||||
{ Debug.LogWarning("Selected file was null or invalid"); return; }
|
||||
|
||||
alienRaceDef.SetBodyTypeGraphicPath(paths[0], direction, bodyType);
|
||||
pawnRaceDef.SetBodyTypeGraphicPath(paths[0], direction, bodyType);
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public AlienRaceDef GetCurrentRaceDef()
|
||||
public PawnRaceDef GetCurrentRaceDef()
|
||||
{
|
||||
string alienRaceDefName = raceSelectDropdown.value < raceSelectDropdown.options.Count ? raceSelectDropdown.options[raceSelectDropdown.value].text : "Human";
|
||||
if (alienRaceDefName == null || alienRaceDefName == "") alienRaceDefName = "Human";
|
||||
string pawnRaceDefName = raceSelectDropdown.value < raceSelectDropdown.options.Count ? raceSelectDropdown.options[raceSelectDropdown.value].text : "Human";
|
||||
if (pawnRaceDefName == null || pawnRaceDefName == "") pawnRaceDefName = "Human";
|
||||
|
||||
return AlienRaceDefs.GetNamed(alienRaceDefName);
|
||||
return PawnRaceDefs.GetNamed(pawnRaceDefName);
|
||||
}
|
||||
|
||||
public void SetRaceScale()
|
||||
{
|
||||
AlienRaceDef alienRaceDef = GetCurrentRaceDef();
|
||||
if (alienRaceDef == null) return;
|
||||
PawnRaceDef pawnRaceDef = GetCurrentRaceDef();
|
||||
if (pawnRaceDef == null) return;
|
||||
|
||||
float scale = float.Parse(scaleField.text);
|
||||
alienRaceDef.scale = Mathf.Clamp(scale, 0.05f, 100f);
|
||||
pawnRaceDef.scale = Mathf.Clamp(scale, 0.01f, 100f);
|
||||
|
||||
scaleField.text = string.Format("{0:0.000}", pawnRaceDef.scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue