mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-14 05:35:08 +00:00
99f525faef
* favoriting and pick block
favoriting needs to not break after previewing (maybe make it persistent in the settings file?)
pick block needs to pick the icon, too. and preferably scroll to it as well
* final star anim + automatic icon game switching
before i make any more changes im making a checkpoint here cuz i know it works
* i want to add a way to specify which event SwitchGame() will switch to (because that's a cool feature for pick block)
* i'll have to figure out how to auto scroll to the game when the icon is selected
* the star now fully works, even between preview switches 👍
* fix the rest of the stuff
the event name gets colored correctly and hidden games are skipped over, but still loaded.
also i built mm ass buns
* tweaks + zoom and sorting
this stuff will be in the pr desc so it doesn't matter
* oop one more thing
* icons look better now :D
mipmaps to the rescue
* double date fix
90 lines
No EOL
2.6 KiB
C#
90 lines
No EOL
2.6 KiB
C#
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
|
|
using DG.Tweening;
|
|
|
|
namespace HeavenStudio.Editor
|
|
{
|
|
public class GridGameSelectorGame : MonoBehaviour
|
|
{
|
|
public GameObject GameTitlePreview;
|
|
public Animator StarAnim;
|
|
public bool StarActive;
|
|
|
|
public GridGameSelector GridGameSelector;
|
|
|
|
public Texture MaskTex;
|
|
public Texture BgTex;
|
|
private Material m_Material;
|
|
|
|
private void Start()
|
|
{
|
|
Tooltip.AddTooltip(this.gameObject, EventCaller.instance.GetMinigame(this.gameObject.name).displayName);
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
if (StarActive) StarAnim.Play("Appear", 0, 1);
|
|
}
|
|
|
|
public void SetupTextures()
|
|
{
|
|
if (m_Material == null)
|
|
{
|
|
m_Material = Instantiate(GetComponent<Image>().material);
|
|
GetComponent<Image>().material = m_Material;
|
|
}
|
|
m_Material.SetTexture("_MaskTex", MaskTex);
|
|
m_Material.SetTexture("_BgTex", BgTex);
|
|
}
|
|
|
|
public void OnClick()
|
|
{
|
|
if (Input.GetMouseButtonUp(0))
|
|
{
|
|
GridGameSelector.SelectGame(this.gameObject.name);
|
|
}
|
|
}
|
|
|
|
public void OnDown()
|
|
{
|
|
if (Input.GetMouseButtonDown(1))
|
|
{
|
|
// while holding shift and the game icon clicked has a star, it will disable all stars.
|
|
if (Input.GetKey(KeyCode.LeftShift)) {
|
|
if (!StarActive) return;
|
|
for (int i = 0; i < transform.parent.childCount; i++)
|
|
{
|
|
var ggsg = transform.parent.GetChild(i).GetComponent<GridGameSelectorGame>();
|
|
if (ggsg.StarActive) ggsg.Star();
|
|
}
|
|
} else {
|
|
Star();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Star()
|
|
{
|
|
StarAnim.CrossFade(StarActive ? "Disappear" : "Appear", 0.3f);
|
|
StarActive = !StarActive;
|
|
}
|
|
|
|
//TODO: animate between shapes
|
|
public void ClickIcon()
|
|
{
|
|
transform.DOScale(new Vector3(1.15f, 1.15f, 1f), 0.1f);
|
|
BgTex = Resources.Load<Texture>($"Sprites/GeneralPurpose/Circle");
|
|
SetupTextures();
|
|
}
|
|
|
|
public void UnClickIcon()
|
|
{
|
|
transform.DOScale(new Vector3(1f, 1f, 1f), 0.1f);
|
|
BgTex = Resources.Load<Texture>($"Sprites/GeneralPurpose/Square");
|
|
SetupTextures();
|
|
}
|
|
}
|
|
} |