Merge pull request #129 from minenice55/editor-bugfixes

Editor Bugfixes and Display Settings
This commit is contained in:
minenice55 2022-07-08 22:14:23 -04:00 committed by GitHub
commit 561ec7cd55
13 changed files with 5253 additions and 190 deletions

View File

@ -36,3 +36,4 @@ Material:
- _UseUIAlphaClip: 0
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,13 @@ namespace HeavenStudio
public static string levelLocation;
public static bool officialLevel;
public static int CustomScreenWidth = 1280;
public static int CustomScreenHeight = 720;
public static readonly (int width, int height)[] DEFAULT_SCREEN_SIZES = new[] { (1280, 720), (1920, 1080), (2560, 1440), (3840, 2160)};
public static readonly string[] DEFAULT_SCREEN_SIZES_STRING = new[] { "1280x720", "1920x1080", "2560x1440", "3840x2160", "Custom" };
public static int ScreenSizeIndex = 0;
public enum Scenes : int
{
SplashScreen = 0,
@ -97,6 +104,34 @@ namespace HeavenStudio
fade.GetComponent<SpriteRenderer>().color = new Color(0, 0, 0, 0);
fade.GetComponent<SpriteRenderer>().DOColor(Color.black, fadeDuration).OnComplete(() => { SceneManager.LoadScene(loadedScene); fade.GetComponent<SpriteRenderer>().DOColor(new Color(0, 0, 0, 0), fadeDuration).OnComplete(() => { Destroy(fade); }); });
}
}
public static void WindowFullScreen()
{
Debug.Log("WindowFullScreen");
if (!Screen.fullScreen)
{
// Set the resolution to the display's current resolution
Screen.SetResolution(Display.main.systemWidth, Display.main.systemHeight, FullScreenMode.FullScreenWindow);
Screen.fullScreen = true;
}
else
{
Screen.SetResolution(1280, 720, FullScreenMode.Windowed);
Screen.fullScreen = false;
}
}
public static void ChangeScreenSize()
{
FullScreenMode mode = Screen.fullScreenMode;
if (ScreenSizeIndex == DEFAULT_SCREEN_SIZES_STRING.Length - 1)
{
Screen.SetResolution(CustomScreenWidth, CustomScreenHeight, mode);
}
else
{
Screen.SetResolution(DEFAULT_SCREEN_SIZES[ScreenSizeIndex].width, DEFAULT_SCREEN_SIZES[ScreenSizeIndex].height, mode);
}
}
}
}

View File

@ -171,4 +171,38 @@ namespace HeavenStudio.Editor.Commands
}
}
}
public class Duplicate : IAction
{
List<TimelineEventObj> eventObjs;
List<TimelineEventObj> copiedObjs;
public Duplicate(List<TimelineEventObj> eventObjs)
{
this.eventObjs = eventObjs;
}
public void Execute()
{
}
public void Redo()
{
for (int i = 0; i < copiedObjs.Count; i++)
{
Beatmap.Entity e = copiedObjs[i].entity;
eventObjs[i] = Timeline.instance.AddEventObject(e.datamodel, false, new Vector3(e.beat, -e.track * Timeline.instance.LayerHeight()), e, true, e.eventObj.eventObjID);
}
}
public void Undo()
{
copiedObjs = eventObjs;
for (int i = 0; i < eventObjs.Count; i++)
{
Selections.instance.Deselect(eventObjs[i]);
Timeline.instance.DestroyEventObject(eventObjs[i].entity);
}
}
}
}

View File

@ -9,10 +9,8 @@ namespace HeavenStudio.Editor
{
public EventParameterManager eventParameterManager;
// this is programmed on duct tape https://youtu.be/zMWA0ipQ94w?t=868
private void LateUpdate()
{
eventParameterManager.canDisable = true;
for (int i = 0; i < transform.childCount; i++)
{
if (Editor.MouseInRectTransform(transform.GetChild(i).GetComponent<RectTransform>()))

View File

@ -199,7 +199,8 @@ namespace HeavenStudio.Editor
for (int i = 0; i < selectedEvents.Count; i++)
{
if (selectedEvents[i].isCreating == false)
//TODO: this is in LateUpdate, so this will never run! change this to something that works properly
if (!(selectedEvents[i].isCreating || selectedEvents[i].wasDuplicated))
{
result.Add(selectedEvents[i]);
}

View File

@ -49,6 +49,7 @@ namespace HeavenStudio.Editor
Disable();
}
}
canDisable = true;
}
public void Disable()

View File

@ -0,0 +1,57 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Editor.Track;
using TMPro;
namespace HeavenStudio.Editor
{
public class DispAudioSettings : MonoBehaviour
{
public TMP_Dropdown resolutionsDropdown;
public GameObject customSetter;
public TMP_InputField widthInputField, heightInputField;
private void Start() {
List<TMP_Dropdown.OptionData> dropDownData = new List<TMP_Dropdown.OptionData>();
var vals = GlobalGameManager.DEFAULT_SCREEN_SIZES_STRING;
for (int i = 0; i < vals.Length; i++)
{
TMP_Dropdown.OptionData optionData = new TMP_Dropdown.OptionData();
optionData.text = vals[i];
dropDownData.Add(optionData);
}
resolutionsDropdown.AddOptions(dropDownData);
resolutionsDropdown.value = GlobalGameManager.ScreenSizeIndex;
resolutionsDropdown.onValueChanged.AddListener(delegate
{
GlobalGameManager.ScreenSizeIndex = resolutionsDropdown.value;
customSetter.SetActive(resolutionsDropdown.value == GlobalGameManager.DEFAULT_SCREEN_SIZES_STRING.Length - 1);
});
widthInputField.onEndEdit.AddListener(delegate
{
GlobalGameManager.CustomScreenWidth = System.Math.Max(int.Parse(widthInputField.text), 64);
widthInputField.text = GlobalGameManager.CustomScreenWidth.ToString();
});
heightInputField.onEndEdit.AddListener(delegate
{
GlobalGameManager.CustomScreenHeight = System.Math.Max(int.Parse(heightInputField.text), 64);
heightInputField.text = GlobalGameManager.CustomScreenHeight.ToString();
});
}
public void WindowFullScreen()
{
GlobalGameManager.WindowFullScreen();
}
public void WindowConfirmSize()
{
GlobalGameManager.ChangeScreenSize();
}
}
}

View File

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

View File

@ -10,6 +10,7 @@ namespace HeavenStudio.Editor
public class SettingsDialog : MonoBehaviour
{
[SerializeField] private GameObject settingsMenu;
//this may all be moved to a different script in the future
private void Start() {}

View File

@ -330,11 +330,10 @@ namespace HeavenStudio.Editor.Track
{
movingPlayback = true;
}
else if (Input.GetMouseButtonUp(1))
else if (Input.GetMouseButtonUp(1) || Conductor.instance.isPlaying)
{
movingPlayback = false;
}
if (movingPlayback)
{
RectTransformUtility.ScreenPointToLocalPointInRectangle(TimelineContent, Input.mousePosition, Editor.instance.EditorCamera, out lastMousePos);
@ -554,7 +553,7 @@ namespace HeavenStudio.Editor.Track
else
{
entity.eventObj = g.GetComponent<TimelineEventObj>();
entity.track = (int)(g.transform.localPosition.y / LayerHeight() * -1);
entity.track = entity.eventObj.GetTrack();
}
@ -611,14 +610,22 @@ namespace HeavenStudio.Editor.Track
return eventObj;
}
public TimelineEventObj CopyEventObject(Beatmap.Entity e)
private List<TimelineEventObj> duplicatedEventObjs = new List<TimelineEventObj>();
public TimelineEventObj CopyEventObject(TimelineEventObj e)
{
Beatmap.Entity clone = e.DeepCopy();
Beatmap.Entity clone = e.entity.DeepCopy();
TimelineEventObj dup = AddEventObject(clone.datamodel, false, new Vector3(clone.beat, -clone.track * Timeline.instance.LayerHeight()), clone, true, RandomID());
duplicatedEventObjs.Add(dup);
return dup;
}
public void FinalizeDuplicateEventStack()
{
CommandManager.instance.Execute(new Commands.Duplicate(duplicatedEventObjs));
duplicatedEventObjs = new List<TimelineEventObj>();
}
public void DestroyEventObject(Beatmap.Entity entity)
{
if (EventParameterManager.instance.entity == entity)
@ -645,12 +652,12 @@ namespace HeavenStudio.Editor.Track
public float SnapToLayer(float y)
{
float size = LayerHeight();
return Mathf.Clamp(Mathp.Round2Nearest(y, size), -size * 3, 0);
return Mathf.Clamp(Mathp.Round2Nearest(y, size), -size * 3f, 0f);
}
public float LayerHeight()
{
return LayersRect.rect.height / 4;
return LayersRect.rect.height / 4f;
}
public void SetPlaybackSpeed(float speed)

View File

@ -38,11 +38,10 @@ namespace HeavenStudio.Editor.Track
public bool resizable;
public bool resizing;
public bool moving;
public bool wasDuplicated;
private bool resizingLeft;
private bool resizingRight;
private bool inResizeRegion;
private bool wasDuplicated;
public Vector2 lastMovePos;
public bool isCreating;
public string eventObjID;
@ -60,8 +59,6 @@ namespace HeavenStudio.Editor.Track
Destroy(resizeGraphic.gameObject);
}
lastMovePos = transform.localPosition;
// what the fuck????
// moveTemp = new GameObject();
// moveTemp.transform.SetParent(this.transform.parent);
@ -120,7 +117,10 @@ namespace HeavenStudio.Editor.Track
selectedImage.gameObject.SetActive(true);
for (int i = 0; i < outline.childCount; i++)
{
outline.GetChild(i).GetComponent<Image>().color = Color.cyan;
if (moving)
outline.GetChild(i).GetComponent<Image>().color = Color.magenta;
else
outline.GetChild(i).GetComponent<Image>().color = Color.cyan;
}
}
else
@ -153,29 +153,33 @@ namespace HeavenStudio.Editor.Track
if (!resizing)
{
if (Input.GetMouseButtonUp(0) && Timeline.instance.timelineState.selected)
{
if (Timeline.instance.eventObjs.FindAll(c => c.mouseHovering).Count == 0 && Timeline.instance.eventObjs.FindAll(c => c.moving).Count == 0 && !BoxSelection.instance.selecting && Timeline.instance.eventObjs.FindAll(c => c.resizing).Count == 0)
{
if (!Input.GetKey(KeyCode.LeftShift))
{
// Selections.instance.Deselect(this);
}
}
// OnUp();
}
if (Timeline.instance.eventObjs.FindAll(c => c.moving).Count > 0 && selected)
{
//duplicate the entity if holding alt or r-click
if ((!wasDuplicated) && (Input.GetKey(KeyCode.LeftAlt) || Input.GetMouseButton(1)))
Vector3 mousePos = Editor.instance.EditorCamera.ScreenToWorldPoint(Input.mousePosition);
//duplicate the entity if holding alt or m-click
if ((!wasDuplicated) && (Input.GetKey(KeyCode.LeftAlt) || Input.GetMouseButton(2)))
{
wasDuplicated = true;
var te = Timeline.instance.CopyEventObject(entity);
Selections.instance.Deselect(this);
this.wasDuplicated = false;
this.moving = false;
var te = Timeline.instance.CopyEventObject(this);
Selections.instance.DragSelect(te);
te.wasDuplicated = true;
te.transform.localPosition = transform.localPosition;
te.lastPos_ = transform.localPosition;
for (int i = 0; i < Timeline.instance.eventObjs.Count; i++)
{
Timeline.instance.eventObjs[i].startPosX = mousePos.x - Timeline.instance.eventObjs[i].transform.position.x;
Timeline.instance.eventObjs[i].startPosY = mousePos.y - Timeline.instance.eventObjs[i].transform.position.y;
}
te.moving = true;
}
Vector3 mousePos = Editor.instance.EditorCamera.ScreenToWorldPoint(Input.mousePosition);
lastPos_ = transform.localPosition;
@ -192,6 +196,9 @@ namespace HeavenStudio.Editor.Track
}
else if (resizingLeft)
{
if (moving)
moving = false;
SetPivot(new Vector2(1, rectTransform.pivot.y));
Vector2 sizeDelta = rectTransform.sizeDelta;
@ -207,6 +214,9 @@ namespace HeavenStudio.Editor.Track
}
else if (resizingRight)
{
if (moving)
moving = false;
Vector2 sizeDelta = rectTransform.sizeDelta;
Vector2 mousePos;
@ -231,7 +241,12 @@ namespace HeavenStudio.Editor.Track
if (resizable)
Cursor.SetCursor(Resources.Load<Texture2D>("Cursors/horizontal_resize"), new Vector2(8, 8), CursorMode.Auto);
}
else if (Timeline.instance.eventObjs.FindAll(c => c.inResizeRegion).Count == 0 && Timeline.instance.eventObjs.FindAll(c => c.resizing).Count == 0)
// should consider adding this someday
// else if (moving && selected || mouseHovering && selected)
// {
// Cursor.SetCursor(Resources.Load<Texture2D>("Cursors/move"), new Vector2(8, 8), CursorMode.Auto);
// }
else
{
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
}
@ -276,8 +291,6 @@ namespace HeavenStudio.Editor.Track
}
moving = true;
// lastMovePos = transform.localPosition;
// OnComplete();
}
}
else if (Input.GetMouseButton(1))
@ -293,13 +306,17 @@ namespace HeavenStudio.Editor.Track
if (selected && Timeline.instance.timelineState.selected)
{
if (wasDuplicated)
{
Timeline.instance.FinalizeDuplicateEventStack();
wasDuplicated = false;
}
if (eligibleToMove)
{
OnComplete(true);
}
moving = false;
wasDuplicated = false;
Cancel();
if (isCreating == true)
@ -390,7 +407,7 @@ namespace HeavenStudio.Editor.Track
private void OnMove()
{
if (GameManager.instance.Beatmap.entities.FindAll(c => c.beat == this.transform.localPosition.x && c.track == GetTrack()).Count > 0)
if (GameManager.instance.Beatmap.entities.FindAll(c => c.beat == this.transform.localPosition.x && c.track == GetTrack() && c != this.entity).Count > 0)
{
eligibleToMove = false;
}
@ -451,7 +468,7 @@ namespace HeavenStudio.Editor.Track
public int GetTrack()
{
return (int)(this.transform.localPosition.y / Timeline.instance.LayerHeight()) * -1;
return (int)Mathf.Round(this.transform.localPosition.y / Timeline.instance.LayerHeight()) * -1;
}
private void OnDestroy()

View File

@ -129,11 +129,11 @@ PlayerSettings:
vulkanEnableLateAcquireNextImage: 0
vulkanEnableCommandBufferRecycling: 1
m_SupportedAspectRatios:
4:3: 0
5:4: 0
16:10: 0
4:3: 1
5:4: 1
16:10: 1
16:9: 1
Others: 0
Others: 1
bundleVersion: 1.0
preloadedAssets: []
metroInputSource: 0