mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Race customization and data saving
This commit is contained in:
parent
2f3f807911
commit
d3b676df06
456 changed files with 6388 additions and 419 deletions
|
@ -36,7 +36,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (eventData.pointerCurrentRaycast.gameObject.GetComponent<ActorBody>() == null)
|
||||
if (eventData.pointerCurrentRaycast.gameObject.GetComponent<ActorBodyPart>())
|
||||
{ return; }
|
||||
|
||||
Activate();
|
||||
|
@ -61,7 +61,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
else if (Workspace.actorManipulationMode == ActorManipulationMode.Rotate)
|
||||
{
|
||||
float angle = Vector2.SignedAngle(Vector2.down, (Vector2)mousePosition - (Vector2)transform.position);
|
||||
float angle = -Vector2.SignedAngle(Vector2.down, (Vector2)mousePosition - (Vector2)transform.position);
|
||||
keyframe.bodyAngle = angle;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
else if (Workspace.actorManipulationMode == ActorManipulationMode.Rotate)
|
||||
{
|
||||
float angle = Vector2.SignedAngle(Vector2.down, (Vector2)mousePosition - (Vector2)transform.position);
|
||||
float angle = -Vector2.SignedAngle(Vector2.down, (Vector2)mousePosition - (Vector2)transform.position);
|
||||
keyframe.headAngle = angle;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,6 @@ namespace RimWorldAnimationStudio
|
|||
public InputField bodyOffsetZField;
|
||||
public Toggle initiatorToggle;
|
||||
|
||||
private int actorID = -1;
|
||||
private bool isDirty = false;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
Actor actor = Workspace.animationDef.actors[Workspace.actorID];
|
||||
|
@ -45,7 +42,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public void OnValueChanged()
|
||||
{
|
||||
if (Workspace.animationDef == null || isDirty) return;
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
||||
Actor actor = Workspace.animationDef.actors[Workspace.actorID];
|
||||
|
||||
|
@ -68,66 +65,28 @@ namespace RimWorldAnimationStudio
|
|||
Workspace.Instance.RecordEvent("Actor body type offset data");
|
||||
}
|
||||
|
||||
/*public void OpenSelectBodyPartsDialog()
|
||||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
||||
Actor actor = Workspace.animationDef.actors[Workspace.actorID];
|
||||
var dialog = Resources.FindObjectsOfTypeAll(typeof(SelectBodyPartsDialog)) as SelectBodyPartsDialog[];
|
||||
|
||||
if (dialog != null)
|
||||
{ dialog[0].Initialize(actor); dialog[0].Pop(); }
|
||||
}
|
||||
|
||||
public void OpenSelectDefNamesDialog()
|
||||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
||||
Actor actor = Workspace.animationDef.actors[Workspace.actorID];
|
||||
var dialog = Resources.FindObjectsOfTypeAll(typeof(SelectDefNamesDialog)) as SelectDefNamesDialog[];
|
||||
|
||||
if (dialog != null)
|
||||
{ dialog[0].Initialize(actor); dialog[0].Pop(); }
|
||||
}
|
||||
|
||||
public void OpenSelectBodyDefTypesDialog()
|
||||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
||||
Actor actor = Workspace.animationDef.actors[Workspace.actorID];
|
||||
var dialog = Resources.FindObjectsOfTypeAll(typeof(SelectBodyDefTypesDialog)) as SelectBodyDefTypesDialog[];
|
||||
|
||||
if (dialog != null)
|
||||
{ dialog[0].Initialize(actor); dialog[0].Pop(); }
|
||||
}*/
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
||||
if (actorID != Workspace.actorID)
|
||||
{
|
||||
isDirty = true;
|
||||
if (Workspace.actorID >= AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>().Count())
|
||||
{ Debug.Log("Waiting for actors to initialize..."); return; }
|
||||
|
||||
if (Workspace.actorID >= AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>().Count())
|
||||
{ Debug.Log("Waiting for actors to initialize..."); return; }
|
||||
Actor actor = Workspace.animationDef.actors[Workspace.actorID];
|
||||
ActorBody actorBody = AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>()[Workspace.actorID];
|
||||
|
||||
Actor actor = Workspace.animationDef.actors[Workspace.actorID];
|
||||
ActorBody actorBody = AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>()[Workspace.actorID];
|
||||
|
||||
string bodyType = actorBody.bodyType;
|
||||
bodyType = bodyType == null || bodyType == "" ? "Male" : bodyType;
|
||||
string bodyType = actorBody.bodyType;
|
||||
bodyType = bodyType == null || bodyType == "" ? "Male" : bodyType;
|
||||
|
||||
bodyTypeDropdown.value = bodyTypeDropdown.options.IndexOf(bodyTypeDropdown.options.First(x => x.text == bodyType));
|
||||
bodyOffsetXField.text = actor.bodyTypeOffset.GetOffset(bodyType).x.ToString();
|
||||
bodyOffsetZField.text = actor.bodyTypeOffset.GetOffset(bodyType).z.ToString();
|
||||
bodyTypeDropdown.value = bodyTypeDropdown.options.IndexOf(bodyTypeDropdown.options.First(x => x.text == bodyType));
|
||||
|
||||
initiatorToggle.isOn = actor.initiator;
|
||||
if (bodyOffsetXField.isFocused == false)
|
||||
{ bodyOffsetXField.text = actor.bodyTypeOffset.GetOffset(bodyType).x.ToString(); }
|
||||
|
||||
actorID = Workspace.actorID;
|
||||
if (bodyOffsetZField.isFocused == false)
|
||||
{ bodyOffsetZField.text = actor.bodyTypeOffset.GetOffset(bodyType).z.ToString(); }
|
||||
|
||||
isDirty = false;
|
||||
}
|
||||
initiatorToggle.isOn = actor.initiator;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,18 @@ namespace RimWorldAnimationStudio
|
|||
Initialize(true);
|
||||
}
|
||||
|
||||
public void AddCustomRace(InputField field)
|
||||
{
|
||||
if (field?.text == null || field.text == "")
|
||||
{ return; }
|
||||
|
||||
AlienRaceDefs.AddDef(new AlienRaceDef(field.text));
|
||||
|
||||
ApplicationManager.Instance.SaveAlienRaceDefs();
|
||||
|
||||
Initialize(true);
|
||||
}
|
||||
|
||||
public virtual void Initialize(bool addedNewTag = false) { }
|
||||
}
|
||||
}
|
||||
|
|
127
Assets/Scripts/GUI/DialogBoxes/RaceSettingsDialog.cs
Normal file
127
Assets/Scripts/GUI/DialogBoxes/RaceSettingsDialog.cs
Normal file
|
@ -0,0 +1,127 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using SFB;
|
||||
using System.IO;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class RaceSettingsDialog : DialogBox
|
||||
{
|
||||
public Dropdown raceSelectDropdown;
|
||||
public Transform raceSettingsWindow;
|
||||
public Toggle isHumanoidToggle;
|
||||
|
||||
public override void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
Reset();
|
||||
|
||||
string alienRaceDefName = raceSelectDropdown.value < raceSelectDropdown.options.Count ? raceSelectDropdown.options[raceSelectDropdown.value].text : "Human";
|
||||
if (alienRaceDefName == null || alienRaceDefName == "") alienRaceDefName = "Human";
|
||||
|
||||
AlienRaceDef alienRaceDef = AlienRaceDefs.GetNamed(alienRaceDefName);
|
||||
if (alienRaceDef == null) return;
|
||||
|
||||
isHumanoidToggle.isOn = alienRaceDef.isHumanoid;
|
||||
|
||||
Text bodyGraphicsTitle = AddCloneObjectToParent(raceSettingsWindow, 2).GetComponent<Text>();
|
||||
bodyGraphicsTitle.text = "Body graphic filepaths";
|
||||
|
||||
foreach (string bodyType in Tags.bodyTypes)
|
||||
{
|
||||
string _bodyType = alienRaceDef.isHumanoid ? bodyType : "None";
|
||||
|
||||
if (alienRaceDef.isHumanoid)
|
||||
{
|
||||
Text bodyTypeTitle = AddCloneObjectToParent(raceSettingsWindow, 2).GetComponent<Text>();
|
||||
bodyTypeTitle.text = bodyType;
|
||||
}
|
||||
|
||||
for (int i = 2; i >= 0; i--)
|
||||
{
|
||||
CardinalDirection facing = (CardinalDirection)i;
|
||||
|
||||
GameObject filepath = AddCloneObjectToParent(raceSettingsWindow, 0);
|
||||
filepath.GetComponent<Text>().text = facing.ToString();
|
||||
filepath.transform.Find("FilepathButton").GetComponent<Button>().onClick.AddListener(delegate
|
||||
{
|
||||
SetBodyTypeGraphicPath(alienRaceDef, facing, _bodyType);
|
||||
});
|
||||
filepath.transform.FindDeepChild("FilepathLabel").GetComponent<Text>().text = alienRaceDef.GetBodyTypeGraphicPath(facing, _bodyType);
|
||||
}
|
||||
|
||||
AddCloneObjectToParent(raceSettingsWindow, 3);
|
||||
|
||||
if (alienRaceDef.isHumanoid == false)
|
||||
{ break; }
|
||||
}
|
||||
|
||||
if (alienRaceDef.isHumanoid)
|
||||
{
|
||||
Text headGraphics = AddCloneObjectToParent(raceSettingsWindow, 2).GetComponent<Text>();
|
||||
headGraphics.text = "Head graphic filepaths";
|
||||
|
||||
for (int i = 2; i >= 0; i--)
|
||||
{
|
||||
CardinalDirection facing = (CardinalDirection)i;
|
||||
|
||||
GameObject filepath = AddCloneObjectToParent(raceSettingsWindow, 0);
|
||||
filepath.GetComponent<Text>().text = facing.ToString();
|
||||
filepath.transform.Find("FilepathButton").GetComponent<Button>().onClick.AddListener(delegate
|
||||
{
|
||||
SetHeadGraphicPath(alienRaceDef, facing);
|
||||
});
|
||||
filepath.transform.FindDeepChild("FilepathLabel").GetComponent<Text>().text = alienRaceDef.GetHeadGraphicPath(facing);
|
||||
}
|
||||
|
||||
AddCloneObjectToParent(raceSettingsWindow, 3);
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
RemoveCloneObjectsFromParent(raceSettingsWindow);
|
||||
}
|
||||
|
||||
public void SetIsHumanoid()
|
||||
{
|
||||
string alienRaceDefName = raceSelectDropdown.value < raceSelectDropdown.options.Count ? raceSelectDropdown.options[raceSelectDropdown.value].text : "Human";
|
||||
if (alienRaceDefName == null || alienRaceDefName == "") alienRaceDefName = "Human";
|
||||
|
||||
AlienRaceDef alienRaceDef = AlienRaceDefs.GetNamed(alienRaceDefName);
|
||||
if (alienRaceDef == null) return;
|
||||
|
||||
alienRaceDef.isHumanoid = isHumanoidToggle.isOn;
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public void SetHeadGraphicPath(AlienRaceDef alienRaceDef, CardinalDirection direction)
|
||||
{
|
||||
var paths = StandaloneFileBrowser.OpenFilePanel("Select texture File", "", "png", false);
|
||||
|
||||
if (paths == null || paths.Any() == false || File.Exists(paths[0]) == false)
|
||||
{ Debug.LogError("Selected file was null or invalid"); return; }
|
||||
|
||||
alienRaceDef.SetHeadGraphicPath(paths[0], direction);
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public void SetBodyTypeGraphicPath(AlienRaceDef alienRaceDef, 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.LogError("Selected file was null or invalid"); return; }
|
||||
|
||||
alienRaceDef.SetBodyTypeGraphicPath(paths[0], direction, bodyType);
|
||||
|
||||
Initialize();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,11 +10,6 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public class SelectActorLayerDialog : DialogBox
|
||||
{
|
||||
public void OnEnable()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public override void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
IEnumerable<string> allTags = Tags.bodyDefTypes.Concat(CustomTags.interactionDefTypes);
|
||||
IEnumerable<string> allTags = Tags.bodyDefTypes.Concat(CustomTags.bodyDefTypes);
|
||||
string placeHolderText = "Enter new body def type...";
|
||||
|
||||
Actor actor = Workspace.animationDef.actors[Workspace.actorID];
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public override void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
IEnumerable<string> allTags = Tags.bodyParts.Concat(CustomTags.interactionDefTypes);
|
||||
IEnumerable<string> allTags = Tags.bodyParts.Concat(CustomTags.bodyParts);
|
||||
string placeHolderText = "Enter new body part name...";
|
||||
|
||||
Actor actor = Workspace.animationDef.actors[Workspace.actorID];
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public override void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
IEnumerable<string> allTags = Tags.defNames.Concat(CustomTags.interactionDefTypes);
|
||||
IEnumerable<string> allTags = AlienRaceDefs.allDefs.Select(x => x.defName);
|
||||
string placeHolderText = "Enter new def name...";
|
||||
|
||||
Actor actor = Workspace.animationDef.actors[Workspace.actorID];
|
||||
|
@ -47,7 +47,7 @@ namespace RimWorldAnimationStudio
|
|||
_optionField.Find("Placeholder").GetComponent<Text>().text = placeHolderText;
|
||||
|
||||
InputField fieldComp = _optionField.GetComponent<InputField>();
|
||||
fieldComp.onEndEdit.AddListener(delegate { AddCustomTag(fieldComp, ref Tags.defNames, ref CustomTags.defNames); });
|
||||
fieldComp.onEndEdit.AddListener(delegate { AddCustomRace(fieldComp); });
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class SelectRaceDialog : DialogBox
|
||||
{
|
||||
public override void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
IEnumerable<string> allTags = Tags.defNames.Concat(CustomTags.interactionDefTypes);
|
||||
string placeHolderText = "Enter new def name...";
|
||||
|
||||
Actor actor = Workspace.animationDef.actors[Workspace.actorID];
|
||||
Transform contentWindow = transform.FindDeepChild("Content");
|
||||
Reset();
|
||||
|
||||
for (int i = 0; i < allTags.Count(); i++)
|
||||
{
|
||||
string tag = allTags.ElementAt(i);
|
||||
|
||||
Transform _optionToggle = AddCloneObjectToParent(contentWindow).transform;
|
||||
_optionToggle.Find("Text").GetComponent<Text>().text = tag;
|
||||
|
||||
Toggle toggleComp = _optionToggle.GetComponent<Toggle>();
|
||||
toggleComp.isOn = actor.defNames.Contains(tag);
|
||||
toggleComp.onValueChanged.AddListener(delegate
|
||||
{
|
||||
if (toggleComp.isOn && actor.defNames.Contains(tag) == false)
|
||||
{ actor.defNames.Add(tag); }
|
||||
|
||||
else if (toggleComp.isOn == false && actor.defNames.Contains(tag))
|
||||
{ actor.defNames.Remove(tag); }
|
||||
|
||||
Workspace.Instance.RecordEvent("Actor def name");
|
||||
});
|
||||
|
||||
if (addedNewTag && i == allTags.Count() - 1)
|
||||
{ toggleComp.isOn = true; }
|
||||
}
|
||||
|
||||
Transform _optionField = AddCloneObjectToParent(contentWindow, 1).transform;
|
||||
_optionField.Find("Placeholder").GetComponent<Text>().text = placeHolderText;
|
||||
|
||||
InputField fieldComp = _optionField.GetComponent<InputField>();
|
||||
fieldComp.onEndEdit.AddListener(delegate { AddCustomTag(fieldComp, ref Tags.defNames, ref CustomTags.defNames); });
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Transform contentWindow = transform.FindDeepChild("Content");
|
||||
RemoveCloneObjectsFromParent(contentWindow);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public override void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
IEnumerable<string> allTags = Tags.sexTypes.Concat(CustomTags.interactionDefTypes);
|
||||
IEnumerable<string> allTags = Tags.sexTypes.Concat(CustomTags.sexTypes);
|
||||
string placeHolderText = "Enter new sex type...";
|
||||
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public override void Initialize(bool addedNewTag = false)
|
||||
{
|
||||
IEnumerable<string> allTags = Tags.soundDefs.Concat(CustomTags.interactionDefTypes);
|
||||
IEnumerable<string> allTags = Tags.soundDefs.Concat(CustomTags.soundDefs);
|
||||
string placeHolderText = "Enter new sound def...";
|
||||
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue