6 Commits

Author SHA1 Message Date
2d35e3177b Update ruleset name for Malody extension. 2022-11-15 12:12:59 +08:00
7b1f639412 Code cleanup. 2022-11-15 12:12:29 +08:00
fcc9935325 Fix input config. 2022-11-15 12:10:54 +08:00
8b29cd2893 Generalize settings panel. 2022-11-15 12:10:34 +08:00
f44d9546e1 Implement config category switch. 2022-11-15 12:09:29 +08:00
1d1d2646c4 Passes chart detail on open and config. 2022-11-15 12:08:48 +08:00
13 changed files with 72 additions and 44 deletions

Binary file not shown.

View File

@@ -200,8 +200,7 @@ namespace Cryville.Common.Unity.UI {
void GenerateLine(int index, int line) { void GenerateLine(int index, int line) {
for (int j = 0; j < LineItemCount; j++) { for (int j = 0; j < LineItemCount; j++) {
var child = GameObject.Instantiate(m_itemTemplate); var child = GameObject.Instantiate(m_itemTemplate, transform, false);
child.transform.SetParent(transform, false);
lines[index][j] = child; lines[index][j] = child;
} }
LoadLine(index, line); LoadLine(index, line);

View File

@@ -60,10 +60,10 @@ namespace Cryville.Crtr.Browsing {
} }
} }
public void OnPlay() { public void OnPlay() {
Master.Open(_id); Master.Open(_id, _data);
} }
public void OnConfig() { public void OnConfig() {
Master.OpenConfig(_id); Master.OpenConfig(_id, _data);
} }
} }
} }

View File

@@ -32,8 +32,7 @@ namespace Cryville.Crtr.Browsing {
public void Load(string name, IEnumerable<PropertyInfo> props, object target) { public void Load(string name, IEnumerable<PropertyInfo> props, object target) {
Name = name.ToUpper(); Name = name.ToUpper();
foreach (var prop in props) { foreach (var prop in props) {
var obj = GameObject.Instantiate<GameObject>(m_propertyPrefab); var obj = GameObject.Instantiate<GameObject>(m_propertyPrefab, transform, false);
obj.transform.SetParent(transform, false);
obj.GetComponent<PropertyPanel>().Load(prop, target); obj.GetComponent<PropertyPanel>().Load(prop, target);
} }
} }

View File

@@ -33,7 +33,7 @@ namespace Cryville.Crtr.Browsing {
if (prop.PropertyType == typeof(bool)) vp = m_bool; if (prop.PropertyType == typeof(bool)) vp = m_bool;
else if (prop.PropertyType == typeof(float) || prop.PropertyType == typeof(int)) vp = m_number; else if (prop.PropertyType == typeof(float) || prop.PropertyType == typeof(int)) vp = m_number;
else return; else return;
_value = GameObject.Instantiate(vp, _valueContainer).GetComponent<PropertyValuePanel>(); _value = GameObject.Instantiate(vp, _valueContainer, false).GetComponent<PropertyValuePanel>();
if (_value is PVPNumber) { if (_value is PVPNumber) {
var t = (PVPNumber)_value; var t = (PVPNumber)_value;
t.IntegerMode = prop.PropertyType == typeof(int); t.IntegerMode = prop.PropertyType == typeof(int);

View File

@@ -64,8 +64,8 @@ namespace Cryville.Crtr.Browsing {
_units[_slideDest + 1].SlideToRight(); _units[_slideDest + 1].SlideToRight();
} }
public void Open(int id) { public void Open(int id, ChartDetail detail) {
SetDataSettings(id); SetDataSettings(id, detail);
#if UNITY_5_3_OR_NEWER #if UNITY_5_3_OR_NEWER
SceneManager.LoadScene("Play", LoadSceneMode.Additive); SceneManager.LoadScene("Play", LoadSceneMode.Additive);
#else #else
@@ -74,8 +74,8 @@ namespace Cryville.Crtr.Browsing {
GameObject.Find("/Master").GetComponent<Master>().HideMenu(); GameObject.Find("/Master").GetComponent<Master>().HideMenu();
} }
public void OpenConfig(int id) { public void OpenConfig(int id, ChartDetail detail) {
SetDataSettings(id); SetDataSettings(id, detail);
#if UNITY_5_3_OR_NEWER #if UNITY_5_3_OR_NEWER
SceneManager.LoadScene("Config", LoadSceneMode.Additive); SceneManager.LoadScene("Config", LoadSceneMode.Additive);
#else #else
@@ -84,9 +84,9 @@ namespace Cryville.Crtr.Browsing {
GameObject.Find("/Master").GetComponent<Master>().HideMenu(); GameObject.Find("/Master").GetComponent<Master>().HideMenu();
} }
void SetDataSettings(int id) { void SetDataSettings(int id, ChartDetail detail) {
Settings.Default.LoadRuleset = "key/.umgr"; Settings.Default.LoadRuleset = detail.Meta.ruleset + "/.umgr";
Settings.Default.LoadSkin = "key/0/.umgs"; Settings.Default.LoadSkin = detail.Meta.ruleset + "/Old KeyUI/.umgs";
Settings.Default.LoadChart = MainBrowser.ResourceManager.GetItemPath(id); Settings.Default.LoadChart = MainBrowser.ResourceManager.GetItemPath(id);
} }
} }

View File

@@ -3,6 +3,16 @@ using UnityEngine.SceneManagement;
namespace Cryville.Crtr.Config { namespace Cryville.Crtr.Config {
public class ConfigScene : MonoBehaviour { public class ConfigScene : MonoBehaviour {
[SerializeField]
Transform m_content;
public void SwitchCategory(GameObject cat) {
foreach (Transform c in m_content) {
c.gameObject.SetActive(false);
}
cat.SetActive(true);
}
public void ReturnToMenu() { public void ReturnToMenu() {
GameObject.Find("Master").GetComponent<Master>().ShowMenu(); GameObject.Find("Master").GetComponent<Master>().ShowMenu();
#if UNITY_5_5_OR_NEWER #if UNITY_5_5_OR_NEWER

View File

@@ -66,8 +66,7 @@ namespace Cryville.Crtr.Config {
ruleset.LoadPdt(dir); ruleset.LoadPdt(dir);
_proxy = new InputProxy(ruleset.Root, null); _proxy = new InputProxy(ruleset.Root, null);
foreach (var i in ruleset.Root.inputs) { foreach (var i in ruleset.Root.inputs) {
var e = GameObject.Instantiate(m_prefabInputConfigEntry).GetComponent<InputConfigEntry>(); var e = GameObject.Instantiate(m_prefabInputConfigEntry, m_entryList.transform).GetComponent<InputConfigEntry>();
e.transform.SetParent(m_entryList.transform);
_entries.Add(i.Key, e); _entries.Add(i.Key, e);
e.SetKey(this, i.Key); e.SetKey(this, i.Key);
} }
@@ -92,8 +91,7 @@ namespace Cryville.Crtr.Config {
void AddSourceItem(InputSource? src) { void AddSourceItem(InputSource? src) {
if (_recvsrcs.Contains(src)) return; if (_recvsrcs.Contains(src)) return;
_recvsrcs.Add(src); _recvsrcs.Add(src);
var obj = Instantiate(m_prefabListItem); var obj = Instantiate(m_prefabListItem, m_deviceList);
obj.transform.SetParent(m_deviceList);
obj.transform.Find("Text").GetComponent<Text>().text = src == null ? "None" : src.Value.Handler.GetTypeName(src.Value.Type); obj.transform.Find("Text").GetComponent<Text>().text = src == null ? "None" : src.Value.Handler.GetTypeName(src.Value.Type);
var btn = obj.GetComponent<Button>(); var btn = obj.GetComponent<Button>();
if (src != null) btn.interactable = !_proxy.IsUsed(src.Value); if (src != null) btn.interactable = !_proxy.IsUsed(src.Value);

View File

@@ -2,6 +2,7 @@ using Cryville.Crtr.Browsing;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -23,18 +24,23 @@ namespace Cryville.Crtr.Extensions.Malody {
if (src.meta.mode != 0) throw new NotImplementedException("The chart mode is not supported"); if (src.meta.mode != 0) throw new NotImplementedException("The chart mode is not supported");
if (src.meta.mode_ext.column != 4) throw new NotImplementedException("The key count is not supported"); if (src.meta.mode_ext.column != 4) throw new NotImplementedException("The key count is not supported");
var ruleset = "malody!" + MODES[src.meta.mode];
if (src.meta.mode == 0) {
ruleset += "." + src.meta.mode_ext.column.ToString(CultureInfo.InvariantCulture) + "k";
}
ChartMeta meta = new ChartMeta() { ChartMeta meta = new ChartMeta() {
song = new ChartMeta.MetaInfo() { song = new ChartMeta.MetaInfo() {
name = src.meta.song.titleorg != null ? src.meta.song.titleorg : src.meta.song.title, name = src.meta.song.titleorg != null ? src.meta.song.titleorg : src.meta.song.title,
author = src.meta.song.artistorg != null ? src.meta.song.artistorg : src.meta.song.artist, author = src.meta.song.artistorg != null ? src.meta.song.artistorg : src.meta.song.artist,
}, },
ruleset = "malody!" + MODES[src.meta.mode], ruleset = ruleset,
}; };
Chart chart = new Chart { Chart chart = new Chart {
format = 2, format = 2,
time = new BeatTime(-4, 0, 1), time = new BeatTime(-4, 0, 1),
ruleset = "malody!" + MODES[src.meta.mode], ruleset = ruleset,
sigs = new List<Chart.Signature>(), sigs = new List<Chart.Signature>(),
sounds = new List<Chart.Sound>(), sounds = new List<Chart.Sound>(),
motions = new List<Chart.Motion>(), motions = new List<Chart.Motion>(),

View File

@@ -43,8 +43,10 @@ namespace Cryville.Crtr {
if (_use[proxy.Target] > 0) if (_use[proxy.Target] > 0)
throw new InvalidOperationException("Input already assigned"); throw new InvalidOperationException("Input already assigned");
if (proxy.Source != null) { if (proxy.Source != null) {
if (_judge != null) {
proxy.Source.Value.Handler.OnInput -= OnInput; // Prevent duplicated hooks, no exception will be thrown proxy.Source.Value.Handler.OnInput -= OnInput; // Prevent duplicated hooks, no exception will be thrown
proxy.Source.Value.Handler.OnInput += OnInput; proxy.Source.Value.Handler.OnInput += OnInput;
}
_tproxies.Add(proxy.Target, proxy); _tproxies.Add(proxy.Target, proxy);
_sproxies.Add(proxy.Source.Value, proxy); _sproxies.Add(proxy.Source.Value, proxy);
IncrementUseRecursive(name); IncrementUseRecursive(name);
@@ -53,7 +55,7 @@ namespace Cryville.Crtr {
} }
void Remove(InputProxyEntry proxy) { void Remove(InputProxyEntry proxy) {
var name = proxy.Target; var name = proxy.Target;
proxy.Source.Value.Handler.OnInput -= OnInput; if (_judge != null) _tproxies[name].Source.Value.Handler.OnInput -= OnInput;
_sproxies.Remove(_tproxies[name].Source.Value); _sproxies.Remove(_tproxies[name].Source.Value);
_tproxies.Remove(name); _tproxies.Remove(name);
DecrementUseRecursive(name); DecrementUseRecursive(name);

View File

@@ -6,11 +6,13 @@ namespace Cryville.Crtr {
public class Menu : MonoBehaviour { public class Menu : MonoBehaviour {
#pragma warning disable IDE0044 #pragma warning disable IDE0044
[SerializeField] [SerializeField]
private ResourceBrowserMaster m_browserMaster; ResourceBrowserMaster m_browserMaster;
[SerializeField] [SerializeField]
private Animator m_targetAnimator; Animator m_targetAnimator;
[SerializeField] [SerializeField]
private ProgressBar m_progressBar; ProgressBar m_progressBar;
[SerializeField]
SettingsPanel m_settingsPanel;
#pragma warning restore IDE0044 #pragma warning restore IDE0044
bool initialized = false; bool initialized = false;
@@ -19,6 +21,7 @@ namespace Cryville.Crtr {
void Awake() { void Awake() {
Game.Init(); Game.Init();
transform.parent.Find("Canvas/Contents").gameObject.SetActive(true); transform.parent.Find("Canvas/Contents").gameObject.SetActive(true);
m_settingsPanel.Target = Settings.Default;
} }
void Update() { void Update() {
if (!initialized) { if (!initialized) {

View File

@@ -7,30 +7,41 @@ using UnityEngine;
namespace Cryville.Crtr { namespace Cryville.Crtr {
public class SettingsPanel : MonoBehaviour { public class SettingsPanel : MonoBehaviour {
[SerializeField] [SerializeField]
private GameObject m_categoryPrefab; GameObject m_categoryPrefab;
private Transform _container; [SerializeField]
Transform m_container;
#pragma warning disable IDE0051 bool _invalidated = true;
void Awake() { object m_target;
_container = transform.Find("Content/__content__"); public object Target {
get {
return m_target;
} }
public void Start() { set {
if (m_target != value) {
m_target = value;
_invalidated = true;
}
}
}
public void Update() {
if (!_invalidated) return;
LoadProperties(); LoadProperties();
foreach (Transform c in _container) GameObject.Destroy(c.gameObject); foreach (Transform c in m_container) GameObject.Destroy(c.gameObject);
foreach (var c in _categories) { foreach (var c in _categories) {
var obj = GameObject.Instantiate<GameObject>(m_categoryPrefab); var obj = GameObject.Instantiate<GameObject>(m_categoryPrefab, m_container, false);
obj.transform.SetParent(_container, false); obj.GetComponent<PropertyCategoryPanel>().Load(c.Key, c.Value, Target);
obj.GetComponent<PropertyCategoryPanel>().Load(c.Key, c.Value, Settings.Default);
} }
} }
#pragma warning restore IDE0051
Dictionary<string, List<PropertyInfo>> _categories = null; Dictionary<string, List<PropertyInfo>> _categories = new Dictionary<string, List<PropertyInfo>>();
public void LoadProperties() { public void LoadProperties() {
if (_categories != null) return; _categories.Clear();
_categories = new Dictionary<string, List<PropertyInfo>>(); _invalidated = false;
foreach (var p in typeof(Settings).GetProperties()) { if (Target == null) return;
foreach (var p in Target.GetType().GetProperties()) {
bool browsable = true; bool browsable = true;
string category = "miscellaneous"; string category = "miscellaneous";
foreach (var attr in p.GetCustomAttributes(true)) { foreach (var attr in p.GetCustomAttributes(true)) {

Binary file not shown.