Skip to content

Commit

Permalink
Adds Assets\Sprites\SongSelection and Assets\Scripts\Screens\SongSele…
Browse files Browse the repository at this point in the history
…ction

Oops I forgot this
  • Loading branch information
veroxzik committed Apr 5, 2020
1 parent 93517ed commit 4613288
Show file tree
Hide file tree
Showing 51 changed files with 2,491 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ sysinfo.txt
# Crashlytics generated file
crashlytics-build.properties

Songs*/
Songs/

StyleStarLog*
config.toml
27 changes: 27 additions & 0 deletions Assets/Scripts/Screens/SongSelection/CardBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using StyleStar;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CardBase
{
protected GameObject cardObj;
protected static int instanceNum = 0;
public bool IsActive { get { return cardObj.activeInHierarchy; } }

public CardBase(GameObject obj)
{
cardObj = obj;
cardObj.SetActive(true);
}

public void Shift(int cardIndex, int currentIndex)
{
cardObj.GetComponent<RectTransform>().anchoredPosition = Globals.CardOrigin + (cardIndex - currentIndex) * Globals.CardOffset;
}

public void SetActive(bool active)
{
cardObj.SetActive(active);
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Screens/SongSelection/CardBase.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Assets/Scripts/Screens/SongSelection/CardPoolGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using UnityEngine;

public class CardPoolGenerator : MonoBehaviour
{
public GameObject SongCard;
public GameObject FolderCard;
public int AmountToPool;
public bool CanExpand;
public GameObject ParentObject;

private void Awake()
{
Pools.SongCards = ScriptableObject.CreateInstance<ObjectPooler>();
Pools.SongCards.SetPool(SongCard, AmountToPool, CanExpand, ParentObject);

Pools.FolderCards = ScriptableObject.CreateInstance<ObjectPooler>();
Pools.FolderCards.SetPool(FolderCard, AmountToPool, CanExpand, ParentObject);
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Screens/SongSelection/CardPoolGenerator.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Assets/Scripts/Screens/SongSelection/FolderCard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using StyleStar;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FolderCard : CardBase
{
public FolderCard(GameObject obj, string text) : base(obj)
{
// Set colors
cardObj.SetColor(ThemeColors.GetColor(instanceNum));
cardObj.transform.Find("StarAccent").gameObject.SetColor(ThemeColors.GetColor(instanceNum).LerpBlackAlpha(0.3f, 0.1f));

// Set text
cardObj.transform.Find("Text").gameObject.SetText(text);

instanceNum++;
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Screens/SongSelection/FolderCard.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 89 additions & 0 deletions Assets/Scripts/Screens/SongSelection/SongCard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using StyleStar;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;

public class SongCard : CardBase
{
private SongMetadata metadata;
public string SongID { get { return metadata.SongID; } }

public SongCard(GameObject obj, SongMetadata meta) : base(obj)
{
metadata = meta;

// Set colors
cardObj.SetColor(meta.ColorBack.IfNull(ThemeColors.GetColor(instanceNum)));
cardObj.transform.Find("StarAccent").gameObject.SetColor(meta.ColorFore.IfNull(ThemeColors.GetColor(instanceNum).LerpBlackAlpha(0.3f, 0.1f)));
cardObj.transform.Find("AlbumAccent").gameObject.SetColor(meta.ColorFore.IfNull(ThemeColors.GetColor(instanceNum).LerpBlackAlpha(0.3f, 0.1f)));

// Set album image
if (metadata.AlbumImage != null)
cardObj.transform.Find("AlbumImage").gameObject.GetComponent<Image>().sprite = metadata.AlbumImage;

// Set title/artist cards or text depending on what's available
if(metadata.TitleImage != null)
{
cardObj.transform.Find("TitleImage").gameObject.GetComponent<Image>().sprite = metadata.TitleImage;
cardObj.transform.Find("TitleImage").gameObject.SetActive(true);
cardObj.transform.Find("TitleText").gameObject.SetActive(false);
}
else
cardObj.transform.Find("TitleText").gameObject.SetText(meta.Title);

if(metadata.ArtistImage != null)
{
cardObj.transform.Find("ArtistImage").gameObject.GetComponent<Image>().sprite = metadata.ArtistImage;
cardObj.transform.Find("ArtistImage").gameObject.SetActive(true);
cardObj.transform.Find("ArtistText").gameObject.SetActive(false);
}
else
cardObj.transform.Find("ArtistText").gameObject.SetText(meta.Artist);

// Set song difficulty numbers
string[] names = new string[] { "Difficulty", "ActiveDifficulty0", "ActiveDifficulty1", "ActiveDifficulty2" };

foreach (var name in names)
{
for (int i = 0; i < 3; i++)
{
var difficultyText = cardObj.transform.Find(name).gameObject.transform.Find("Difficulty" + i).gameObject;

if (meta.ChildMetadata.Count == 0)
{
if ((int)meta.Difficulty == i)
{
difficultyText.SetActive(true);
difficultyText.SetText(meta.Level.ToString("D2"));
}
else
difficultyText.SetActive(false);
}
else
{
var child = meta.ChildMetadata.FirstOrDefault(x => (int)x.Difficulty == i);
if (child != null)
{
difficultyText.SetActive(true);
difficultyText.SetText(child.Level.ToString("D2"));
}
else
difficultyText.SetActive(false);
}
if (name.Contains("Active"))
cardObj.transform.Find(name).gameObject.SetActive(false);
}
}


instanceNum++;
}

public void SetDifficulty(int difficulty)
{
for (int i = 0; i < 3; i++)
cardObj.transform.Find("ActiveDifficulty" + i).gameObject.SetActive(i == difficulty);
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Screens/SongSelection/SongCard.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4613288

Please sign in to comment.