Feature: Textboxes and other text-related features (#90)

* Textboxes: setup prefab

* Textboxes: basic functionality finished

* Textbox: scaling

* Textbox: open captions

* Textbox: res edits

* Textbox: song artist

* Textbox: closed captions

* Textbox: fix not being able to use multiple text events

* I/O: save / load remixes using UTF-8 encoding

* Textboxes: stop editor shortcuts while typing
This commit is contained in:
minenice55
2022-06-03 23:15:05 -04:00
committed by GitHub
parent 7e6d50ef26
commit 12fb8c2117
79 changed files with 22812 additions and 2017 deletions

View File

@ -61,6 +61,7 @@ namespace HeavenStudio.Editor
private bool fullscreen;
public bool discordDuringTesting = false;
public bool canSelect = true;
public bool editingInputField = false;
public static Editor instance { get; private set; }
@ -75,6 +76,7 @@ namespace HeavenStudio.Editor
{
GameCamera.instance.camera.targetTexture = ScreenRenderTexture;
GameManager.instance.CursorCam.targetTexture = ScreenRenderTexture;
GameManager.instance.OverlayCamera.targetTexture = ScreenRenderTexture;
Screen.texture = ScreenRenderTexture;
GameManager.instance.Init();
@ -106,14 +108,18 @@ namespace HeavenStudio.Editor
{
if (Input.GetKeyDown(KeyCode.Tab))
{
Fullscreen();
if (!Editor.instance.editingInputField)
Fullscreen();
}
if (Input.GetKeyDown(KeyCode.Delete))
{
List<TimelineEventObj> ev = new List<TimelineEventObj>();
for (int i = 0; i < Selections.instance.eventsSelected.Count; i++) ev.Add(Selections.instance.eventsSelected[i]);
CommandManager.instance.Execute(new Commands.Deletion(ev));
if (!Editor.instance.editingInputField)
{
List<TimelineEventObj> ev = new List<TimelineEventObj>();
for (int i = 0; i < Selections.instance.eventsSelected.Count; i++) ev.Add(Selections.instance.eventsSelected[i]);
CommandManager.instance.Execute(new Commands.Deletion(ev));
}
}
if (CommandManager.instance.canUndo())
@ -312,7 +318,7 @@ namespace HeavenStudio.Editor
{
var levelFile = archive.CreateEntry("remix.json", System.IO.Compression.CompressionLevel.NoCompression);
using (var zipStream = levelFile.Open())
zipStream.Write(Encoding.ASCII.GetBytes(GetJson()), 0, Encoding.ASCII.GetBytes(GetJson()).Length);
zipStream.Write(Encoding.UTF8.GetBytes(GetJson()), 0, Encoding.UTF8.GetBytes(GetJson()).Length);
if (changedMusic || currentRemixPath != path)
{
@ -369,7 +375,7 @@ namespace HeavenStudio.Editor
{
stream.CopyTo(ms);
bytes = ms.ToArray();
string json = Encoding.Default.GetString(bytes);
string json = Encoding.UTF8.GetString(bytes);
LoadRemix(json);
}
}
@ -413,7 +419,8 @@ namespace HeavenStudio.Editor
MainCanvas.enabled = false;
EditorCamera.enabled = false;
GameCamera.instance.camera.targetTexture = null;
GameCamera.instance.camera.transform.parent.GetChild(1).GetComponent<Camera>().enabled = false;
GameManager.instance.CursorCam.enabled = false;
GameManager.instance.OverlayCamera.targetTexture = null;
fullscreen = true;
}
else
@ -421,7 +428,8 @@ namespace HeavenStudio.Editor
MainCanvas.enabled = true;
EditorCamera.enabled = true;
GameCamera.instance.camera.targetTexture = ScreenRenderTexture;
GameCamera.instance.camera.transform.parent.GetChild(1).GetComponent<Camera>().enabled = true;
GameManager.instance.CursorCam.enabled = true;
GameManager.instance.OverlayCamera.targetTexture = ScreenRenderTexture;
fullscreen = false;
}
}

View File

@ -18,6 +18,7 @@ namespace HeavenStudio.Editor
[SerializeField] private GameObject BooleanP;
[SerializeField] private GameObject DropdownP;
[SerializeField] private GameObject ColorP;
[SerializeField] private GameObject StringP;
public Beatmap.Entity entity;
@ -120,6 +121,10 @@ namespace HeavenStudio.Editor
{
prefab = ColorP;
}
else if(objType == typeof(string))
{
prefab = StringP;
}
GameObject input = Instantiate(prefab);
input.transform.SetParent(this.gameObject.transform);
@ -137,6 +142,7 @@ namespace HeavenStudio.Editor
private void DestroyParams()
{
Editor.instance.editingInputField = false;
active = false;
for (int i = childCountAtStart; i < transform.childCount; i++)
{

View File

@ -36,6 +36,10 @@ namespace HeavenStudio.Editor
public bool colorTableActive;
public ColorPreview colorPreview;
[Header("String")] //why wasn't this a thing before
[Space(10)]
public TMP_InputField inputFieldString;
private string propertyName;
public void SetProperties(string propertyName, object type, string caption)
@ -61,10 +65,16 @@ namespace HeavenStudio.Editor
parameterManager.entity[propertyName] = (int)slider.value;
});
inputField.onSelect.AddListener(delegate
{
Editor.instance.editingInputField = true;
});
inputField.onEndEdit.AddListener(delegate
{
slider.value = Mathf.RoundToInt(System.Convert.ToSingle(System.Convert.ToSingle(inputField.text)));
parameterManager.entity[propertyName] = (int)slider.value;
Editor.instance.editingInputField = false;
});
}
else if (objType == typeof(EntityTypes.Float))
@ -84,10 +94,16 @@ namespace HeavenStudio.Editor
parameterManager.entity[propertyName] = newValue;
});
inputField.onSelect.AddListener(delegate
{
Editor.instance.editingInputField = true;
});
inputField.onEndEdit.AddListener(delegate
{
slider.value = (float)System.Math.Round(System.Convert.ToSingle(inputField.text), 4);
parameterManager.entity[propertyName] = slider.value;
Editor.instance.editingInputField = false;
});
}
else if(type is bool)
@ -143,6 +159,24 @@ namespace HeavenStudio.Editor
colorPreview.ChangeColor(paramCol);
ColorTable.gameObject.SetActive(false);
}
//why the FUCK wasn't this a thing before lmao
else if(objType == typeof(string))
{
// Debug.Log("entity " + propertyName + " is: " + (string)(parameterManager.entity[propertyName]));
inputFieldString.text = (string)(parameterManager.entity[propertyName]);
inputFieldString.onSelect.AddListener(delegate
{
Editor.instance.editingInputField = true;
});
inputFieldString.onEndEdit.AddListener(delegate
{
// Debug.Log("setting " + propertyName + " to: " + inputFieldString.text);
parameterManager.entity[propertyName] = inputFieldString.text;
Editor.instance.editingInputField = false;
});
}
}
private void Update()

View File

@ -258,24 +258,29 @@ namespace HeavenStudio.Editor.Track
if (Input.GetKeyDown(KeyCode.Space))
{
if (Input.GetKey(KeyCode.LeftShift))
if (!Editor.instance.editingInputField)
{
PlayCheck(false);
}
else
{
PlayCheck(true);
if (Input.GetKey(KeyCode.LeftShift))
{
PlayCheck(false);
}
else
{
PlayCheck(true);
}
}
}
if (Input.GetKeyDown(KeyCode.P))
{
AutoPlayToggle();
if (!Editor.instance.editingInputField)
AutoPlayToggle();
}
if (Input.GetKeyDown(KeyCode.M))
{
MetronomeToggle();
if (!Editor.instance.editingInputField)
MetronomeToggle();
}
@ -302,13 +307,16 @@ namespace HeavenStudio.Editor.Track
float moveSpeed = 750;
if (Input.GetKey(KeyCode.LeftShift)) moveSpeed *= 2;
if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
if (!Editor.instance.editingInputField)
{
TimelineContent.transform.localPosition += new Vector3(moveSpeed * Time.deltaTime, 0);
}
else if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
{
TimelineContent.transform.localPosition += new Vector3(-moveSpeed * Time.deltaTime, 0);
if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
{
TimelineContent.transform.localPosition += new Vector3(moveSpeed * Time.deltaTime, 0);
}
else if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
{
TimelineContent.transform.localPosition += new Vector3(-moveSpeed * Time.deltaTime, 0);
}
}
if (Conductor.instance.isPlaying)