play mode info panel

This commit is contained in:
minenice55 2023-11-27 20:07:26 -05:00
parent dd071faa3d
commit 3a6727dcfa
4 changed files with 1721 additions and 91 deletions

File diff suppressed because it is too large Load diff

View file

@ -151,96 +151,99 @@ namespace HeavenStudio
Minigames.Minigame game; Minigames.Minigame game;
Minigames.GameAction action; Minigames.GameAction action;
System.Type type, pType; System.Type type, pType;
foreach (var e in data.entities) if (EventCaller.instance != null)
{ {
var gameName = e.datamodel.Split(0); foreach (var e in data.entities)
var actionName = e.datamodel.Split(1);
game = EventCaller.instance.GetMinigame(gameName);
if (game == null)
{ {
Debug.LogWarning($"Unknown game {gameName} found in remix.json! Adding game..."); var gameName = e.datamodel.Split(0);
game = new Minigames.Minigame(gameName, gameName.DisplayName() + " \n<color=#eb5454>[inferred from remix.json]</color>", "", false, false, new List<Minigames.GameAction>(), inferred: true); var actionName = e.datamodel.Split(1);
EventCaller.instance.minigames.Add(game); game = EventCaller.instance.GetMinigame(gameName);
if (Editor.Editor.instance != null) if (game == null)
Editor.Editor.instance.AddIcon(game);
}
action = EventCaller.instance.GetGameAction(game, actionName);
if (action == null)
{
Debug.LogWarning($"Unknown action {gameName}/{actionName} found in remix.json! Adding action...");
var parameters = new List<Minigames.Param>();
foreach (var item in e.dynamicData)
{ {
Debug.Log($"k: {item.Key}, v: {item.Value}"); Debug.LogWarning($"Unknown game {gameName} found in remix.json! Adding game...");
if (item.Key == "track") game = new Minigames.Minigame(gameName, gameName.DisplayName() + " \n<color=#eb5454>[inferred from remix.json]</color>", "", false, false, new List<Minigames.GameAction>(), inferred: true);
continue; EventCaller.instance.minigames.Add(game);
if (item.Value == null) if (Editor.Editor.instance != null)
continue; Editor.Editor.instance.AddIcon(game);
var value = item.Value;
if (value.GetType() == typeof(long))
value = new EntityTypes.Integer(int.MinValue, int.MaxValue, (int)value);
else if (value.GetType() == typeof(double))
value = new EntityTypes.Float(float.NegativeInfinity, float.PositiveInfinity, (float)value);
parameters.Add(new Minigames.Param(item.Key, value, item.Key.DisplayName(), "[inferred from remix.json]"));
} }
action = new Minigames.GameAction(actionName, actionName.DisplayName(), e.length, true, parameters); action = EventCaller.instance.GetGameAction(game, actionName);
game.actions.Add(action); if (action == null)
}
//check each param of the action
if (action.parameters != null)
{
foreach (var param in action.parameters)
{ {
type = param.parameter.GetType(); Debug.LogWarning($"Unknown action {gameName}/{actionName} found in remix.json! Adding action...");
//add property if it doesn't exist var parameters = new List<Minigames.Param>();
if (!e.dynamicData.ContainsKey(param.propertyName)) foreach (var item in e.dynamicData)
{ {
Debug.LogWarning($"Property {param.propertyName} does not exist in the entity's dynamic data! Adding..."); Debug.Log($"k: {item.Key}, v: {item.Value}");
if (type == typeof(EntityTypes.Integer)) if (item.Key == "track")
e.dynamicData.Add(param.propertyName, ((EntityTypes.Integer)param.parameter).val); continue;
else if (type == typeof(EntityTypes.Float)) if (item.Value == null)
e.dynamicData.Add(param.propertyName, ((EntityTypes.Float)param.parameter).val); continue;
else if (type.IsEnum) var value = item.Value;
e.dynamicData.Add(param.propertyName, (int)param.parameter); if (value.GetType() == typeof(long))
else value = new EntityTypes.Integer(int.MinValue, int.MaxValue, (int)value);
e.dynamicData.Add(param.propertyName, Convert.ChangeType(param.parameter, type)); else if (value.GetType() == typeof(double))
continue; value = new EntityTypes.Float(float.NegativeInfinity, float.PositiveInfinity, (float)value);
parameters.Add(new Minigames.Param(item.Key, value, item.Key.DisplayName(), "[inferred from remix.json]"));
} }
pType = e[param.propertyName].GetType(); action = new Minigames.GameAction(actionName, actionName.DisplayName(), e.length, true, parameters);
if (pType != type) game.actions.Add(action);
}
//check each param of the action
if (action.parameters != null)
{
foreach (var param in action.parameters)
{ {
try type = param.parameter.GetType();
//add property if it doesn't exist
if (!e.dynamicData.ContainsKey(param.propertyName))
{ {
Debug.LogWarning($"Property {param.propertyName} does not exist in the entity's dynamic data! Adding...");
if (type == typeof(EntityTypes.Integer)) if (type == typeof(EntityTypes.Integer))
e.dynamicData[param.propertyName] = (int)e[param.propertyName]; e.dynamicData.Add(param.propertyName, ((EntityTypes.Integer)param.parameter).val);
else if (type == typeof(EntityTypes.Float)) else if (type == typeof(EntityTypes.Float))
e.dynamicData[param.propertyName] = (float)e[param.propertyName]; e.dynamicData.Add(param.propertyName, ((EntityTypes.Float)param.parameter).val);
else if (type.IsEnum) else if (type.IsEnum)
{ e.dynamicData.Add(param.propertyName, (int)param.parameter);
if (pType == typeof(string))
e.dynamicData[param.propertyName] = (int)Enum.Parse(type, (string)e[param.propertyName]);
else
e.dynamicData[param.propertyName] = (int)e[param.propertyName];
}
else if (pType == typeof(Newtonsoft.Json.Linq.JObject))
e.dynamicData[param.propertyName] = e[param.propertyName].ToObject(type);
else else
e.dynamicData[param.propertyName] = Convert.ChangeType(e[param.propertyName], type); e.dynamicData.Add(param.propertyName, Convert.ChangeType(param.parameter, type));
continue;
} }
catch pType = e[param.propertyName].GetType();
if (pType != type)
{ {
Debug.LogWarning($"Could not convert {param.propertyName} to {type}! Using default value..."); try
// GlobalGameManager.ShowErrorMessage("Warning", $"Could not convert {e.datamodel}/{param.propertyName} to {type}! This will be loaded using the default value, so chart may be unstable."); {
// use default value if (type == typeof(EntityTypes.Integer))
if (type == typeof(EntityTypes.Integer)) e.dynamicData[param.propertyName] = (int)e[param.propertyName];
e.dynamicData[param.propertyName] = ((EntityTypes.Integer)param.parameter).val; else if (type == typeof(EntityTypes.Float))
else if (type == typeof(EntityTypes.Float)) e.dynamicData[param.propertyName] = (float)e[param.propertyName];
e.dynamicData[param.propertyName] = ((EntityTypes.Float)param.parameter).val; else if (type.IsEnum)
else if (type.IsEnum && param.propertyName != "ease") {
e.dynamicData[param.propertyName] = (int)param.parameter; if (pType == typeof(string))
else e.dynamicData[param.propertyName] = (int)Enum.Parse(type, (string)e[param.propertyName]);
e.dynamicData[param.propertyName] = Convert.ChangeType(param.parameter, type); else
e.dynamicData[param.propertyName] = (int)e[param.propertyName];
}
else if (pType == typeof(Newtonsoft.Json.Linq.JObject))
e.dynamicData[param.propertyName] = e[param.propertyName].ToObject(type);
else
e.dynamicData[param.propertyName] = Convert.ChangeType(e[param.propertyName], type);
}
catch
{
Debug.LogWarning($"Could not convert {param.propertyName} to {type}! Using default value...");
// GlobalGameManager.ShowErrorMessage("Warning", $"Could not convert {e.datamodel}/{param.propertyName} to {type}! This will be loaded using the default value, so chart may be unstable.");
// use default value
if (type == typeof(EntityTypes.Integer))
e.dynamicData[param.propertyName] = ((EntityTypes.Integer)param.parameter).val;
else if (type == typeof(EntityTypes.Float))
e.dynamicData[param.propertyName] = ((EntityTypes.Float)param.parameter).val;
else if (type.IsEnum && param.propertyName != "ease")
e.dynamicData[param.propertyName] = (int)param.parameter;
else
e.dynamicData[param.propertyName] = Convert.ChangeType(param.parameter, type);
}
} }
} }
} }

View file

@ -40,6 +40,11 @@ namespace HeavenStudio
[SerializeField] private GameObject snsPanel; [SerializeField] private GameObject snsPanel;
[SerializeField] private TMP_Text snsVersionText; [SerializeField] private TMP_Text snsVersionText;
[SerializeField] private GameObject playPanel;
[SerializeField] private TMP_Text chartTitleText;
[SerializeField] private TMP_Text chartMapperText;
[SerializeField] private TMP_Text chartDescText;
private AudioSource musicSource; private AudioSource musicSource;
private double songPosBeat; private double songPosBeat;
@ -208,9 +213,13 @@ namespace HeavenStudio
RiqFileHandler.UnlockCache(); RiqFileHandler.UnlockCache();
string tmpDir = RiqFileHandler.ExtractRiq(path); string tmpDir = RiqFileHandler.ExtractRiq(path);
Debug.Log("Imported RIQ successfully!"); Debug.Log("Imported RIQ successfully!");
RiqBeatmap beatmap = RiqFileHandler.ReadRiq();
GlobalGameManager.PlayOpenFile = path; GlobalGameManager.PlayOpenFile = path;
SoundByte.PlayOneShot("ui/UIEnter"); chartTitleText.text = beatmap["remixtitle"];
GlobalGameManager.LoadScene("Game", 0.35f, 0.5f); chartMapperText.text = beatmap["remixauthor"];
chartDescText.text = beatmap["remixdesc"];
playPanel.SetActive(true);
} }
catch (System.Exception e) catch (System.Exception e)
{ {
@ -222,6 +231,18 @@ namespace HeavenStudio
}); });
} }
public void PlayPanelAccept()
{
SoundByte.PlayOneShot("ui/UIEnter");
GlobalGameManager.LoadScene("Game", 0.35f, 0.5f);
}
public void PlayPanelBack()
{
SoundByte.PlayOneShot("ui/UICancel");
playPanel.SetActive(false);
}
public void SocialsPressed() public void SocialsPressed()
{ {
snsRevealed = true; snsRevealed = true;

View file

@ -17,4 +17,7 @@ EditorBuildSettings:
- enabled: 1 - enabled: 1
path: Assets/Scenes/Game.unity path: Assets/Scenes/Game.unity
guid: 2cda990e2423bbf4892e6590ba056729 guid: 2cda990e2423bbf4892e6590ba056729
- enabled: 1
path: Assets/Scenes/Judgement.unity
guid: 6284f8de74823fb4283c88febf8f4c98
m_configObjects: {} m_configObjects: {}