Compare commits
52 Commits
Author | SHA1 | Date | |
---|---|---|---|
e40c98ae1b | |||
642a9563ba | |||
4a1fa48352 | |||
4dc0767e91 | |||
9e82c04898 | |||
0776eca49d | |||
af01fb2119 | |||
9044631fe7 | |||
3b22d4fce3 | |||
5393ff1451 | |||
e34a9cc868 | |||
440581261e | |||
b78e99c59c | |||
3db8f61e3b | |||
8b64165fb7 | |||
799b1e12da | |||
957270c41a | |||
bc51a45df8 | |||
9b091a0084 | |||
98e35fc6f6 | |||
d83f447e82 | |||
898885b116 | |||
fd05f6c1dd | |||
86da71f2cb | |||
ba2f1d4858 | |||
3687a70aec | |||
8da54093aa | |||
b057ea8074 | |||
e7bc9d0294 | |||
08de91b04d | |||
ea70fbb051 | |||
cee6a08240 | |||
f04b9cfb75 | |||
1dcbc03829 | |||
d89423caf5 | |||
c9b348dd4f | |||
636f45f03f | |||
7fce9591a9 | |||
f65e4f1900 | |||
a4d0e3867a | |||
83b9c27e94 | |||
864ea91be0 | |||
ea02fc22bd | |||
60cc763cd0 | |||
8955b69cdf | |||
a7aff4d625 | |||
22cb8f0cb4 | |||
db07ace927 | |||
094c3fe2a3 | |||
cc156e0d81 | |||
9833052849 | |||
a6a0ac3f9e |
@@ -3,12 +3,12 @@ using System;
|
||||
namespace Cryville.Common.ComponentModel {
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
|
||||
public class RangeAttribute : Attribute {
|
||||
public RangeAttribute(float min, float max) {
|
||||
public RangeAttribute(double min, double max) {
|
||||
Min = min;
|
||||
Max = max;
|
||||
}
|
||||
|
||||
public float Min { get; set; }
|
||||
public float Max { get; set; }
|
||||
public double Min { get; set; }
|
||||
public double Max { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@ using System;
|
||||
namespace Cryville.Common.ComponentModel {
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
|
||||
public class StepAttribute : Attribute {
|
||||
public StepAttribute(float step) {
|
||||
public StepAttribute(double step) {
|
||||
Step = step;
|
||||
}
|
||||
public float Step { get; set; }
|
||||
public double Step { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -6,295 +6,295 @@ using System.Linq;
|
||||
namespace Cryville.Common.Font {
|
||||
public abstract class FontMatcher {
|
||||
protected FontManager Manager { get; private set; }
|
||||
public FontMatcher(FontManager manafer) { Manager = manafer; }
|
||||
public FontMatcher(FontManager manager) { Manager = manager; }
|
||||
public abstract IEnumerable<Typeface> MatchScript(string script = null, bool distinctFamily = false);
|
||||
}
|
||||
public class FallbackListFontMatcher : FontMatcher {
|
||||
public Dictionary<string, List<string>> MapScriptToTypefaces = new Dictionary<string, List<string>>();
|
||||
public void LoadDefaultWindowsFallbackList() {
|
||||
if (Environment.OSVersion.Platform != PlatformID.Win32NT) return;
|
||||
MapScriptToTypefaces.Clear();
|
||||
ScriptUtils.FillKeysWithScripts(MapScriptToTypefaces, () => new List<string>());
|
||||
public static Dictionary<string, List<string>> GetDefaultWindowsFallbackMap() {
|
||||
var map = new Dictionary<string, List<string>>();
|
||||
ScriptUtils.FillKeysWithScripts(map, () => new List<string>());
|
||||
// Reference: https://github.com/chromium/chromium/blob/main/third_party/blink/renderer/platform/fonts/win/font_fallback_win.cc
|
||||
MapScriptToTypefaces["zyyy"].Insert(0, "SimSun"); // Custom
|
||||
MapScriptToTypefaces["zyyy"].Insert(0, "SimHei"); // Custom
|
||||
MapScriptToTypefaces["zyyy"].Insert(0, "Microsoft YaHei"); // Custom
|
||||
MapScriptToTypefaces["zyyy"].Insert(0, "Arial");
|
||||
MapScriptToTypefaces["zyyy"].Insert(0, "Times New Roman");
|
||||
MapScriptToTypefaces["zyyy"].Insert(0, "Segoe UI"); // Custom
|
||||
MapScriptToTypefaces["arab"].Insert(0, "Tahoma");
|
||||
MapScriptToTypefaces["cyrl"].Insert(0, "Times New Roman");
|
||||
MapScriptToTypefaces["grek"].Insert(0, "Times New Roman");
|
||||
MapScriptToTypefaces["hebr"].Insert(0, "David");
|
||||
MapScriptToTypefaces["jpan"].Insert(0, "MS PGothic");
|
||||
MapScriptToTypefaces["latn"].Insert(0, "Times New Roman");
|
||||
MapScriptToTypefaces["hans"].Insert(0, "SimSun");
|
||||
MapScriptToTypefaces["hans"].Insert(0, "SimHei"); // Custom
|
||||
MapScriptToTypefaces["thai"].Insert(0, "Tahoma");
|
||||
MapScriptToTypefaces["hans"].Insert(0, "PMingLiU");
|
||||
map["zyyy"].Insert(0, "SimSun"); // Custom
|
||||
map["zyyy"].Insert(0, "SimHei"); // Custom
|
||||
map["zyyy"].Insert(0, "Microsoft YaHei"); // Custom
|
||||
map["zyyy"].Insert(0, "Arial");
|
||||
map["zyyy"].Insert(0, "Times New Roman");
|
||||
map["zyyy"].Insert(0, "Segoe UI"); // Custom
|
||||
map["arab"].Insert(0, "Tahoma");
|
||||
map["cyrl"].Insert(0, "Times New Roman");
|
||||
map["grek"].Insert(0, "Times New Roman");
|
||||
map["hebr"].Insert(0, "David");
|
||||
map["jpan"].Insert(0, "MS PGothic");
|
||||
map["latn"].Insert(0, "Times New Roman");
|
||||
map["hans"].Insert(0, "SimSun");
|
||||
map["hans"].Insert(0, "SimHei"); // Custom
|
||||
map["thai"].Insert(0, "Tahoma");
|
||||
map["hans"].Insert(0, "PMingLiU");
|
||||
// Reference: https://learn.microsoft.com/en-us/globalization/input/font-support
|
||||
var ver = Environment.OSVersion.Version;
|
||||
if (ver >= new Version(5, 0)) { // Windows 2000
|
||||
MapScriptToTypefaces["armn"].Insert(0, "Sylfaen");
|
||||
MapScriptToTypefaces["deva"].Insert(0, "Mangal");
|
||||
MapScriptToTypefaces["geor"].Insert(0, "Sylfaen");
|
||||
MapScriptToTypefaces["taml"].Insert(0, "Latha");
|
||||
map["armn"].Insert(0, "Sylfaen");
|
||||
map["deva"].Insert(0, "Mangal");
|
||||
map["geor"].Insert(0, "Sylfaen");
|
||||
map["taml"].Insert(0, "Latha");
|
||||
}
|
||||
if (ver >= new Version(5, 1)) { // Windows XP
|
||||
MapScriptToTypefaces["gujr"].Insert(0, "Shruti");
|
||||
MapScriptToTypefaces["guru"].Insert(0, "Raavi");
|
||||
MapScriptToTypefaces["knda"].Insert(0, "Tunga");
|
||||
MapScriptToTypefaces["syrc"].Insert(0, "Estrangelo Edessa");
|
||||
MapScriptToTypefaces["telu"].Insert(0, "Gautami");
|
||||
MapScriptToTypefaces["thaa"].Insert(0, "MV Boli");
|
||||
map["gujr"].Insert(0, "Shruti");
|
||||
map["guru"].Insert(0, "Raavi");
|
||||
map["knda"].Insert(0, "Tunga");
|
||||
map["syrc"].Insert(0, "Estrangelo Edessa");
|
||||
map["telu"].Insert(0, "Gautami");
|
||||
map["thaa"].Insert(0, "MV Boli");
|
||||
// SP2
|
||||
MapScriptToTypefaces["beng"].Insert(0, "Vrinda");
|
||||
MapScriptToTypefaces["mlym"].Insert(0, "Kartika");
|
||||
map["beng"].Insert(0, "Vrinda");
|
||||
map["mlym"].Insert(0, "Kartika");
|
||||
}
|
||||
if (ver >= new Version(6, 0)) { // Windows Vista
|
||||
MapScriptToTypefaces["cans"].Insert(0, "Euphemia");
|
||||
MapScriptToTypefaces["cher"].Insert(0, "Plantagenet");
|
||||
MapScriptToTypefaces["ethi"].Insert(0, "Nyala");
|
||||
MapScriptToTypefaces["khmr"].Insert(0, "DaunPenh MoolBoran");
|
||||
MapScriptToTypefaces["laoo"].Insert(0, "DokChampa");
|
||||
MapScriptToTypefaces["mong"].Insert(0, "Mongolian Baiti");
|
||||
MapScriptToTypefaces["orya"].Insert(0, "Kalinga");
|
||||
MapScriptToTypefaces["sinh"].Insert(0, "Iskoola Pota");
|
||||
MapScriptToTypefaces["tibt"].Insert(0, "Microsoft Himalaya");
|
||||
MapScriptToTypefaces["yiii"].Insert(0, "Microsoft Yi Baiti");
|
||||
MapScriptToTypefaces["arab"].Insert(0, "Segoe UI");
|
||||
MapScriptToTypefaces["cyrl"].Insert(0, "Segoe UI");
|
||||
MapScriptToTypefaces["grek"].Insert(0, "Segoe UI");
|
||||
MapScriptToTypefaces["latn"].Insert(0, "Segoe UI");
|
||||
MapScriptToTypefaces["hans"].Add("SimSun-ExtB");
|
||||
MapScriptToTypefaces["hant"].Add("MingLiU-ExtB");
|
||||
MapScriptToTypefaces["hant"].Add("MingLiU_HKSCS-ExtB");
|
||||
MapScriptToTypefaces["arab"].Add("Microsoft Uighur");
|
||||
MapScriptToTypefaces["zmth"].Insert(0, "Cambria Math");
|
||||
map["cans"].Insert(0, "Euphemia");
|
||||
map["cher"].Insert(0, "Plantagenet");
|
||||
map["ethi"].Insert(0, "Nyala");
|
||||
map["khmr"].Insert(0, "DaunPenh MoolBoran");
|
||||
map["laoo"].Insert(0, "DokChampa");
|
||||
map["mong"].Insert(0, "Mongolian Baiti");
|
||||
map["orya"].Insert(0, "Kalinga");
|
||||
map["sinh"].Insert(0, "Iskoola Pota");
|
||||
map["tibt"].Insert(0, "Microsoft Himalaya");
|
||||
map["yiii"].Insert(0, "Microsoft Yi Baiti");
|
||||
map["arab"].Insert(0, "Segoe UI");
|
||||
map["cyrl"].Insert(0, "Segoe UI");
|
||||
map["grek"].Insert(0, "Segoe UI");
|
||||
map["latn"].Insert(0, "Segoe UI");
|
||||
map["hans"].Add("SimSun-ExtB");
|
||||
map["hant"].Add("MingLiU-ExtB");
|
||||
map["hant"].Add("MingLiU_HKSCS-ExtB");
|
||||
map["arab"].Add("Microsoft Uighur");
|
||||
map["zmth"].Insert(0, "Cambria Math");
|
||||
// Reference: https://en.wikipedia.org/wiki/List_of_CJK_fonts
|
||||
MapScriptToTypefaces["jpan"].Insert(0, "Meiryo");
|
||||
MapScriptToTypefaces["hans"].Insert(0, "Microsoft YaHei");
|
||||
map["jpan"].Insert(0, "Meiryo");
|
||||
map["hans"].Insert(0, "Microsoft YaHei");
|
||||
}
|
||||
if (ver >= new Version(6, 1)) { // Windows 7
|
||||
MapScriptToTypefaces["brai"].Insert(0, "Segoe UI Symbol");
|
||||
MapScriptToTypefaces["dsrt"].Insert(0, "Segoe UI Symbol");
|
||||
MapScriptToTypefaces["talu"].Insert(0, "Microsoft New Tai Lue");
|
||||
MapScriptToTypefaces["ogam"].Insert(0, "Segoe UI Symbol");
|
||||
MapScriptToTypefaces["osma"].Insert(0, "Ebrima");
|
||||
MapScriptToTypefaces["phag"].Insert(0, "Microsoft PhagsPa");
|
||||
MapScriptToTypefaces["runr"].Insert(0, "Segoe UI Symbol");
|
||||
MapScriptToTypefaces["zsym"].Insert(0, "Segoe UI Symbol");
|
||||
MapScriptToTypefaces["tale"].Insert(0, "Microsoft Tai Le");
|
||||
MapScriptToTypefaces["tfng"].Insert(0, "Ebrima");
|
||||
MapScriptToTypefaces["vaii"].Insert(0, "Ebrima");
|
||||
map["brai"].Insert(0, "Segoe UI Symbol");
|
||||
map["dsrt"].Insert(0, "Segoe UI Symbol");
|
||||
map["talu"].Insert(0, "Microsoft New Tai Lue");
|
||||
map["ogam"].Insert(0, "Segoe UI Symbol");
|
||||
map["osma"].Insert(0, "Ebrima");
|
||||
map["phag"].Insert(0, "Microsoft PhagsPa");
|
||||
map["runr"].Insert(0, "Segoe UI Symbol");
|
||||
map["zsym"].Insert(0, "Segoe UI Symbol");
|
||||
map["tale"].Insert(0, "Microsoft Tai Le");
|
||||
map["tfng"].Insert(0, "Ebrima");
|
||||
map["vaii"].Insert(0, "Ebrima");
|
||||
}
|
||||
if (ver >= new Version(6, 2)) { // Windows 8
|
||||
MapScriptToTypefaces["glag"].Insert(0, "Segoe UI Symbol");
|
||||
MapScriptToTypefaces["goth"].Insert(0, "Segoe UI Symbol");
|
||||
MapScriptToTypefaces["hang"].Add("Malgun Gothic");
|
||||
MapScriptToTypefaces["ital"].Insert(0, "Segoe UI Symbol");
|
||||
MapScriptToTypefaces["lisu"].Insert(0, "Segoe UI");
|
||||
MapScriptToTypefaces["mymr"].Insert(0, "Myanmar Text");
|
||||
MapScriptToTypefaces["nkoo"].Insert(0, "Ebrima");
|
||||
MapScriptToTypefaces["orkh"].Insert(0, "Segoe UI Symbol");
|
||||
MapScriptToTypefaces["ethi"].Insert(0, "Ebrima");
|
||||
MapScriptToTypefaces["cans"].Insert(0, "Gadugi");
|
||||
MapScriptToTypefaces["hant"].Insert(0, "Microsoft JhengHei UI");
|
||||
MapScriptToTypefaces["hans"].Insert(0, "Microsoft YaHei UI");
|
||||
MapScriptToTypefaces["beng"].Insert(0, "Nirmala UI");
|
||||
MapScriptToTypefaces["deva"].Insert(0, "Nirmala UI");
|
||||
MapScriptToTypefaces["gujr"].Insert(0, "Nirmala UI");
|
||||
MapScriptToTypefaces["guru"].Insert(0, "Nirmala UI"); // NOT DOCUMENTED, UNVERIFIED
|
||||
MapScriptToTypefaces["knda"].Insert(0, "Nirmala UI"); // NOT DOCUMENTED, UNVERIFIED
|
||||
MapScriptToTypefaces["mlym"].Insert(0, "Nirmala UI");
|
||||
MapScriptToTypefaces["orya"].Insert(0, "Nirmala UI");
|
||||
MapScriptToTypefaces["sinh"].Insert(0, "Nirmala UI"); // NOT DOCUMENTED, UNVERIFIED
|
||||
MapScriptToTypefaces["taml"].Insert(0, "Nirmala UI"); // NOT DOCUMENTED, UNVERIFIED
|
||||
MapScriptToTypefaces["telu"].Insert(0, "Nirmala UI");
|
||||
MapScriptToTypefaces["armn"].Insert(0, "Segoe UI");
|
||||
MapScriptToTypefaces["geor"].Insert(0, "Segoe UI");
|
||||
MapScriptToTypefaces["hebr"].Insert(0, "Segoe UI");
|
||||
map["glag"].Insert(0, "Segoe UI Symbol");
|
||||
map["goth"].Insert(0, "Segoe UI Symbol");
|
||||
map["hang"].Add("Malgun Gothic");
|
||||
map["ital"].Insert(0, "Segoe UI Symbol");
|
||||
map["lisu"].Insert(0, "Segoe UI");
|
||||
map["mymr"].Insert(0, "Myanmar Text");
|
||||
map["nkoo"].Insert(0, "Ebrima");
|
||||
map["orkh"].Insert(0, "Segoe UI Symbol");
|
||||
map["ethi"].Insert(0, "Ebrima");
|
||||
map["cans"].Insert(0, "Gadugi");
|
||||
map["hant"].Insert(0, "Microsoft JhengHei UI");
|
||||
map["hans"].Insert(0, "Microsoft YaHei UI");
|
||||
map["beng"].Insert(0, "Nirmala UI");
|
||||
map["deva"].Insert(0, "Nirmala UI");
|
||||
map["gujr"].Insert(0, "Nirmala UI");
|
||||
map["guru"].Insert(0, "Nirmala UI"); // NOT DOCUMENTED, UNVERIFIED
|
||||
map["knda"].Insert(0, "Nirmala UI"); // NOT DOCUMENTED, UNVERIFIED
|
||||
map["mlym"].Insert(0, "Nirmala UI");
|
||||
map["orya"].Insert(0, "Nirmala UI");
|
||||
map["sinh"].Insert(0, "Nirmala UI"); // NOT DOCUMENTED, UNVERIFIED
|
||||
map["taml"].Insert(0, "Nirmala UI"); // NOT DOCUMENTED, UNVERIFIED
|
||||
map["telu"].Insert(0, "Nirmala UI");
|
||||
map["armn"].Insert(0, "Segoe UI");
|
||||
map["geor"].Insert(0, "Segoe UI");
|
||||
map["hebr"].Insert(0, "Segoe UI");
|
||||
}
|
||||
if (ver >= new Version(6, 3)) { // Windows 8.1
|
||||
MapScriptToTypefaces["bugi"].Insert(0, "Leelawadee UI");
|
||||
MapScriptToTypefaces["copt"].Insert(0, "Segoe UI Symbol");
|
||||
MapScriptToTypefaces["java"].Insert(0, "Javanese Text");
|
||||
MapScriptToTypefaces["merc"].Insert(0, "Segoe UI Symbol");
|
||||
MapScriptToTypefaces["olck"].Insert(0, "Nirmala UI");
|
||||
MapScriptToTypefaces["sora"].Insert(0, "Nirmala UI");
|
||||
MapScriptToTypefaces["khmr"].Insert(0, "Leelawadee UI");
|
||||
MapScriptToTypefaces["laoo"].Insert(0, "Leelawadee UI");
|
||||
MapScriptToTypefaces["thai"].Insert(0, "Leelawadee UI");
|
||||
MapScriptToTypefaces["zsye"].Insert(0, "Segoe UI Emoji");
|
||||
map["bugi"].Insert(0, "Leelawadee UI");
|
||||
map["copt"].Insert(0, "Segoe UI Symbol");
|
||||
map["java"].Insert(0, "Javanese Text");
|
||||
map["merc"].Insert(0, "Segoe UI Symbol");
|
||||
map["olck"].Insert(0, "Nirmala UI");
|
||||
map["sora"].Insert(0, "Nirmala UI");
|
||||
map["khmr"].Insert(0, "Leelawadee UI");
|
||||
map["laoo"].Insert(0, "Leelawadee UI");
|
||||
map["thai"].Insert(0, "Leelawadee UI");
|
||||
map["zsye"].Insert(0, "Segoe UI Emoji");
|
||||
}
|
||||
if (ver >= new Version(10, 0)) { // Windows 10
|
||||
MapScriptToTypefaces["brah"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["cari"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["cprt"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["egyp"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["armi"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["phli"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["prti"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["khar"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["lyci"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["lydi"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["phnx"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["xpeo"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["sarb"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["shaw"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["xsux"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["ugar"].Insert(0, "Segoe UI Historic");
|
||||
map["brah"].Insert(0, "Segoe UI Historic");
|
||||
map["cari"].Insert(0, "Segoe UI Historic");
|
||||
map["cprt"].Insert(0, "Segoe UI Historic");
|
||||
map["egyp"].Insert(0, "Segoe UI Historic");
|
||||
map["armi"].Insert(0, "Segoe UI Historic");
|
||||
map["phli"].Insert(0, "Segoe UI Historic");
|
||||
map["prti"].Insert(0, "Segoe UI Historic");
|
||||
map["khar"].Insert(0, "Segoe UI Historic");
|
||||
map["lyci"].Insert(0, "Segoe UI Historic");
|
||||
map["lydi"].Insert(0, "Segoe UI Historic");
|
||||
map["phnx"].Insert(0, "Segoe UI Historic");
|
||||
map["xpeo"].Insert(0, "Segoe UI Historic");
|
||||
map["sarb"].Insert(0, "Segoe UI Historic");
|
||||
map["shaw"].Insert(0, "Segoe UI Historic");
|
||||
map["xsux"].Insert(0, "Segoe UI Historic");
|
||||
map["ugar"].Insert(0, "Segoe UI Historic");
|
||||
// Segoe UI Symbol -> Segoe UI Historic
|
||||
MapScriptToTypefaces["glag"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["goth"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["merc"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["ogam"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["ital"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["orkh"].Insert(0, "Segoe UI Historic");
|
||||
MapScriptToTypefaces["runr"].Insert(0, "Segoe UI Historic");
|
||||
map["glag"].Insert(0, "Segoe UI Historic");
|
||||
map["goth"].Insert(0, "Segoe UI Historic");
|
||||
map["merc"].Insert(0, "Segoe UI Historic");
|
||||
map["ogam"].Insert(0, "Segoe UI Historic");
|
||||
map["ital"].Insert(0, "Segoe UI Historic");
|
||||
map["orkh"].Insert(0, "Segoe UI Historic");
|
||||
map["runr"].Insert(0, "Segoe UI Historic");
|
||||
//
|
||||
MapScriptToTypefaces["jpan"].Insert(0, "Yu Gothic UI");
|
||||
MapScriptToTypefaces["zsym"].Add("Segoe MDL2 Assets");
|
||||
map["jpan"].Insert(0, "Yu Gothic UI");
|
||||
map["zsym"].Add("Segoe MDL2 Assets");
|
||||
}
|
||||
return map;
|
||||
}
|
||||
public void LoadDefaultAndroidFallbackList() {
|
||||
if (Environment.OSVersion.Platform != PlatformID.Unix) return;
|
||||
MapScriptToTypefaces.Clear();
|
||||
ScriptUtils.FillKeysWithScripts(MapScriptToTypefaces, () => new List<string>());
|
||||
MapScriptToTypefaces["zyyy"].Insert(0, "Noto Sans CJK TC"); // TODO Modify default fallback
|
||||
MapScriptToTypefaces["zyyy"].Insert(0, "Noto Sans CJK JP");
|
||||
MapScriptToTypefaces["zyyy"].Insert(0, "Noto Sans CJK SC");
|
||||
MapScriptToTypefaces["zyyy"].Insert(0, "Roboto");
|
||||
MapScriptToTypefaces["zsye"].Insert(0, "Noto Color Emoji");
|
||||
MapScriptToTypefaces["zsye"].Add("Noto Color Emoji Flags");
|
||||
MapScriptToTypefaces["arab"].Insert(0, "Noto Naskh Arabic");
|
||||
MapScriptToTypefaces["adlm"].Insert(0, "Noto Sans Adlam");
|
||||
MapScriptToTypefaces["ahom"].Insert(0, "Noto Sans Ahom");
|
||||
MapScriptToTypefaces["hluw"].Insert(0, "Noto Sans Anatolian Hieroglyphs");
|
||||
MapScriptToTypefaces["armn"].Insert(0, "Noto Sans Armenian");
|
||||
MapScriptToTypefaces["avst"].Insert(0, "Noto Sans Avestan");
|
||||
MapScriptToTypefaces["bali"].Insert(0, "Noto Sans Balinese");
|
||||
MapScriptToTypefaces["bamu"].Insert(0, "Noto Sans Bamum");
|
||||
MapScriptToTypefaces["bass"].Insert(0, "Noto Sans Bassa Vah");
|
||||
MapScriptToTypefaces["batk"].Insert(0, "Noto Sans Batak");
|
||||
MapScriptToTypefaces["beng"].Insert(0, "Noto Sans Bengali");
|
||||
MapScriptToTypefaces["bhks"].Insert(0, "Noto Sans Bhaiksuki");
|
||||
MapScriptToTypefaces["brah"].Insert(0, "Noto Sans Brahmi");
|
||||
MapScriptToTypefaces["bugi"].Insert(0, "Noto Sans Buginese");
|
||||
MapScriptToTypefaces["buhd"].Insert(0, "Noto Sans Buhid");
|
||||
MapScriptToTypefaces["jpan"].Insert(0, "Noto Sans CJK JP");
|
||||
MapScriptToTypefaces["kore"].Insert(0, "Noto Sans CJK KR");
|
||||
MapScriptToTypefaces["hans"].Insert(0, "Noto Sans CJK SC");
|
||||
MapScriptToTypefaces["hant"].Insert(0, "Noto Sans CJK TC");
|
||||
MapScriptToTypefaces["hant"].Add("Noto Sans CJK HK");
|
||||
MapScriptToTypefaces["cans"].Insert(0, "Noto Sans Canadian Aboriginal");
|
||||
MapScriptToTypefaces["cari"].Insert(0, "Noto Sans Carian");
|
||||
MapScriptToTypefaces["cakm"].Insert(0, "Noto Sans Chakma");
|
||||
MapScriptToTypefaces["cham"].Insert(0, "Noto Sans Cham");
|
||||
MapScriptToTypefaces["cher"].Insert(0, "Noto Sans Cherokee");
|
||||
MapScriptToTypefaces["copt"].Insert(0, "Noto Sans Coptic");
|
||||
MapScriptToTypefaces["xsux"].Insert(0, "Noto Sans Cuneiform");
|
||||
MapScriptToTypefaces["cprt"].Insert(0, "Noto Sans Cypriot");
|
||||
MapScriptToTypefaces["dsrt"].Insert(0, "Noto Sans Deseret");
|
||||
MapScriptToTypefaces["deva"].Insert(0, "Noto Sans Devanagari");
|
||||
MapScriptToTypefaces["egyp"].Insert(0, "Noto Sans Egyptian Hieroglyphs");
|
||||
MapScriptToTypefaces["elba"].Insert(0, "Noto Sans Elbasan");
|
||||
MapScriptToTypefaces["ethi"].Insert(0, "Noto Sans Ethiopic");
|
||||
MapScriptToTypefaces["geor"].Insert(0, "Noto Sans Georgian");
|
||||
MapScriptToTypefaces["glag"].Insert(0, "Noto Sans Glagolitic");
|
||||
MapScriptToTypefaces["goth"].Insert(0, "Noto Sans Gothic");
|
||||
MapScriptToTypefaces["gran"].Insert(0, "Noto Sans Grantha");
|
||||
MapScriptToTypefaces["gujr"].Insert(0, "Noto Sans Gujarati");
|
||||
MapScriptToTypefaces["gong"].Insert(0, "Noto Sans Gunjala Gondi");
|
||||
MapScriptToTypefaces["guru"].Insert(0, "Noto Sans Gurmukhi");
|
||||
MapScriptToTypefaces["rohg"].Insert(0, "Noto Sans Hanifi Rohingya");
|
||||
MapScriptToTypefaces["hano"].Insert(0, "Noto Sans Hanunoo");
|
||||
MapScriptToTypefaces["hatr"].Insert(0, "Noto Sans Hatran");
|
||||
MapScriptToTypefaces["hebr"].Insert(0, "Noto Sans Hebrew");
|
||||
MapScriptToTypefaces["armi"].Insert(0, "Noto Sans Imperial Aramaic");
|
||||
MapScriptToTypefaces["phli"].Insert(0, "Noto Sans Inscriptional Pahlavi");
|
||||
MapScriptToTypefaces["prti"].Insert(0, "Noto Sans Inscriptional Parthian");
|
||||
MapScriptToTypefaces["java"].Insert(0, "Noto Sans Javanese");
|
||||
MapScriptToTypefaces["kthi"].Insert(0, "Noto Sans Kaithi");
|
||||
MapScriptToTypefaces["knda"].Insert(0, "Noto Sans Kannada");
|
||||
MapScriptToTypefaces["kali"].Insert(0, "Noto Sans KayahLi");
|
||||
MapScriptToTypefaces["khar"].Insert(0, "Noto Sans Kharoshthi");
|
||||
MapScriptToTypefaces["khmr"].Insert(0, "Noto Sans Khmer");
|
||||
MapScriptToTypefaces["khoj"].Insert(0, "Noto Sans Khojki");
|
||||
MapScriptToTypefaces["laoo"].Insert(0, "Noto Sans Lao");
|
||||
MapScriptToTypefaces["lepc"].Insert(0, "Noto Sans Lepcha");
|
||||
MapScriptToTypefaces["limb"].Insert(0, "Noto Sans Limbu");
|
||||
MapScriptToTypefaces["lina"].Insert(0, "Noto Sans Linear A");
|
||||
MapScriptToTypefaces["linb"].Insert(0, "Noto Sans Linear B");
|
||||
MapScriptToTypefaces["lisu"].Insert(0, "Noto Sans Lisu");
|
||||
MapScriptToTypefaces["lyci"].Insert(0, "Noto Sans Lycian");
|
||||
MapScriptToTypefaces["lydi"].Insert(0, "Noto Sans Lydian");
|
||||
MapScriptToTypefaces["mlym"].Insert(0, "Noto Sans Malayalam");
|
||||
MapScriptToTypefaces["mand"].Insert(0, "Noto Sans Mandiac");
|
||||
MapScriptToTypefaces["mani"].Insert(0, "Noto Sans Manichaean");
|
||||
MapScriptToTypefaces["marc"].Insert(0, "Noto Sans Marchen");
|
||||
MapScriptToTypefaces["gonm"].Insert(0, "Noto Sans Masaram Gondi");
|
||||
MapScriptToTypefaces["medf"].Insert(0, "Noto Sans Medefaidrin");
|
||||
MapScriptToTypefaces["mtei"].Insert(0, "Noto Sans Meetei Mayek");
|
||||
MapScriptToTypefaces["merc"].Insert(0, "Noto Sans Meroitic");
|
||||
MapScriptToTypefaces["mero"].Insert(0, "Noto Sans Meroitic");
|
||||
MapScriptToTypefaces["plrd"].Insert(0, "Noto Sans Miao");
|
||||
MapScriptToTypefaces["modi"].Insert(0, "Noto Sans Modi");
|
||||
MapScriptToTypefaces["mong"].Insert(0, "Noto Sans Mongolian");
|
||||
MapScriptToTypefaces["mroo"].Insert(0, "Noto Sans Mro");
|
||||
MapScriptToTypefaces["mult"].Insert(0, "Noto Sans Multani");
|
||||
MapScriptToTypefaces["mymr"].Insert(0, "Noto Sans Myanmar");
|
||||
MapScriptToTypefaces["nkoo"].Insert(0, "Noto Sans Nko");
|
||||
MapScriptToTypefaces["nbat"].Insert(0, "Noto Sans Nabataean");
|
||||
MapScriptToTypefaces["talu"].Insert(0, "Noto Sans New Tai Lue");
|
||||
MapScriptToTypefaces["newa"].Insert(0, "Noto Sans Newa");
|
||||
MapScriptToTypefaces["ogam"].Insert(0, "Noto Sans Ogham");
|
||||
MapScriptToTypefaces["olck"].Insert(0, "Noto Sans Ol Chiki");
|
||||
MapScriptToTypefaces["ital"].Insert(0, "Noto Sans Old Italian");
|
||||
MapScriptToTypefaces["narb"].Insert(0, "Noto Sans Old North Arabian");
|
||||
MapScriptToTypefaces["perm"].Insert(0, "Noto Sans Old Permic");
|
||||
MapScriptToTypefaces["xpeo"].Insert(0, "Noto Sans Old Persian");
|
||||
MapScriptToTypefaces["sarb"].Insert(0, "Noto Sans Old South Arabian");
|
||||
MapScriptToTypefaces["orkh"].Insert(0, "Noto Sans Old Turkic");
|
||||
MapScriptToTypefaces["orya"].Insert(0, "Noto Sans Oriya");
|
||||
MapScriptToTypefaces["osge"].Insert(0, "Noto Sans Osage");
|
||||
MapScriptToTypefaces["osma"].Insert(0, "Noto Sans Osmanya");
|
||||
MapScriptToTypefaces["hmng"].Insert(0, "Noto Sans Pahawh Hmong");
|
||||
MapScriptToTypefaces["palm"].Insert(0, "Noto Sans Palmyrene");
|
||||
MapScriptToTypefaces["pauc"].Insert(0, "Noto Sans Pau Cin Hau");
|
||||
MapScriptToTypefaces["phag"].Insert(0, "Noto Sans Phags Pa");
|
||||
MapScriptToTypefaces["phnx"].Insert(0, "Noto Sans Phoenician");
|
||||
MapScriptToTypefaces["rjng"].Insert(0, "Noto Sans Rejang");
|
||||
MapScriptToTypefaces["runr"].Insert(0, "Noto Sans Runic");
|
||||
MapScriptToTypefaces["samr"].Insert(0, "Noto Sans Samaritan");
|
||||
MapScriptToTypefaces["saur"].Insert(0, "Noto Sans Saurashtra");
|
||||
MapScriptToTypefaces["shrd"].Insert(0, "Noto Sans Sharada");
|
||||
MapScriptToTypefaces["shaw"].Insert(0, "Noto Sans Shavian");
|
||||
MapScriptToTypefaces["sinh"].Insert(0, "Noto Sans Sinhala");
|
||||
MapScriptToTypefaces["sora"].Insert(0, "Noto Sans Sora Sompeng");
|
||||
MapScriptToTypefaces["soyo"].Insert(0, "Noto Sans Soyombo");
|
||||
MapScriptToTypefaces["sund"].Insert(0, "Noto Sans Sundanese");
|
||||
MapScriptToTypefaces["sylo"].Insert(0, "Noto Sans Syloti Nagri");
|
||||
MapScriptToTypefaces["zsym"].Insert(0, "Noto Sans Symbols");
|
||||
MapScriptToTypefaces["syrn"].Insert(0, "Noto Sans Syriac Eastern");
|
||||
MapScriptToTypefaces["syre"].Insert(0, "Noto Sans Syriac Estrangela");
|
||||
MapScriptToTypefaces["syrj"].Insert(0, "Noto Sans Syriac Western");
|
||||
MapScriptToTypefaces["tglg"].Insert(0, "Noto Sans Tagalog");
|
||||
MapScriptToTypefaces["tagb"].Insert(0, "Noto Sans Tagbanwa");
|
||||
MapScriptToTypefaces["tale"].Insert(0, "Noto Sans Tai Le");
|
||||
MapScriptToTypefaces["lana"].Insert(0, "Noto Sans Tai Tham");
|
||||
MapScriptToTypefaces["tavt"].Insert(0, "Noto Sans Tai Viet");
|
||||
MapScriptToTypefaces["takr"].Insert(0, "Noto Sans Takri");
|
||||
MapScriptToTypefaces["taml"].Insert(0, "Noto Sans Tamil");
|
||||
MapScriptToTypefaces["telu"].Insert(0, "Noto Sans Telugu");
|
||||
MapScriptToTypefaces["thaa"].Insert(0, "Noto Sans Thaana");
|
||||
MapScriptToTypefaces["thai"].Insert(0, "Noto Sans Thai");
|
||||
MapScriptToTypefaces["tfng"].Insert(0, "Noto Sans Tifinagh");
|
||||
MapScriptToTypefaces["ugar"].Insert(0, "Noto Sans Ugaritic");
|
||||
MapScriptToTypefaces["vaii"].Insert(0, "Noto Sans Vai");
|
||||
MapScriptToTypefaces["wcho"].Insert(0, "Noto Sans Wancho");
|
||||
MapScriptToTypefaces["wara"].Insert(0, "Noto Sans Warang Citi");
|
||||
MapScriptToTypefaces["yiii"].Insert(0, "Noto Sans Yi");
|
||||
public static Dictionary<string, List<string>> GetDefaultAndroidFallbackMap() {
|
||||
var map = new Dictionary<string, List<string>>();
|
||||
ScriptUtils.FillKeysWithScripts(map, () => new List<string>());
|
||||
map["zyyy"].Insert(0, "Noto Sans CJK TC"); // TODO Modify default fallback
|
||||
map["zyyy"].Insert(0, "Noto Sans CJK JP");
|
||||
map["zyyy"].Insert(0, "Noto Sans CJK SC");
|
||||
map["zyyy"].Insert(0, "Roboto");
|
||||
map["zsye"].Insert(0, "Noto Color Emoji");
|
||||
map["zsye"].Add("Noto Color Emoji Flags");
|
||||
map["arab"].Insert(0, "Noto Naskh Arabic");
|
||||
map["adlm"].Insert(0, "Noto Sans Adlam");
|
||||
map["ahom"].Insert(0, "Noto Sans Ahom");
|
||||
map["hluw"].Insert(0, "Noto Sans Anatolian Hieroglyphs");
|
||||
map["armn"].Insert(0, "Noto Sans Armenian");
|
||||
map["avst"].Insert(0, "Noto Sans Avestan");
|
||||
map["bali"].Insert(0, "Noto Sans Balinese");
|
||||
map["bamu"].Insert(0, "Noto Sans Bamum");
|
||||
map["bass"].Insert(0, "Noto Sans Bassa Vah");
|
||||
map["batk"].Insert(0, "Noto Sans Batak");
|
||||
map["beng"].Insert(0, "Noto Sans Bengali");
|
||||
map["bhks"].Insert(0, "Noto Sans Bhaiksuki");
|
||||
map["brah"].Insert(0, "Noto Sans Brahmi");
|
||||
map["bugi"].Insert(0, "Noto Sans Buginese");
|
||||
map["buhd"].Insert(0, "Noto Sans Buhid");
|
||||
map["jpan"].Insert(0, "Noto Sans CJK JP");
|
||||
map["kore"].Insert(0, "Noto Sans CJK KR");
|
||||
map["hans"].Insert(0, "Noto Sans CJK SC");
|
||||
map["hant"].Insert(0, "Noto Sans CJK TC");
|
||||
map["hant"].Add("Noto Sans CJK HK");
|
||||
map["cans"].Insert(0, "Noto Sans Canadian Aboriginal");
|
||||
map["cari"].Insert(0, "Noto Sans Carian");
|
||||
map["cakm"].Insert(0, "Noto Sans Chakma");
|
||||
map["cham"].Insert(0, "Noto Sans Cham");
|
||||
map["cher"].Insert(0, "Noto Sans Cherokee");
|
||||
map["copt"].Insert(0, "Noto Sans Coptic");
|
||||
map["xsux"].Insert(0, "Noto Sans Cuneiform");
|
||||
map["cprt"].Insert(0, "Noto Sans Cypriot");
|
||||
map["dsrt"].Insert(0, "Noto Sans Deseret");
|
||||
map["deva"].Insert(0, "Noto Sans Devanagari");
|
||||
map["egyp"].Insert(0, "Noto Sans Egyptian Hieroglyphs");
|
||||
map["elba"].Insert(0, "Noto Sans Elbasan");
|
||||
map["ethi"].Insert(0, "Noto Sans Ethiopic");
|
||||
map["geor"].Insert(0, "Noto Sans Georgian");
|
||||
map["glag"].Insert(0, "Noto Sans Glagolitic");
|
||||
map["goth"].Insert(0, "Noto Sans Gothic");
|
||||
map["gran"].Insert(0, "Noto Sans Grantha");
|
||||
map["gujr"].Insert(0, "Noto Sans Gujarati");
|
||||
map["gong"].Insert(0, "Noto Sans Gunjala Gondi");
|
||||
map["guru"].Insert(0, "Noto Sans Gurmukhi");
|
||||
map["rohg"].Insert(0, "Noto Sans Hanifi Rohingya");
|
||||
map["hano"].Insert(0, "Noto Sans Hanunoo");
|
||||
map["hatr"].Insert(0, "Noto Sans Hatran");
|
||||
map["hebr"].Insert(0, "Noto Sans Hebrew");
|
||||
map["armi"].Insert(0, "Noto Sans Imperial Aramaic");
|
||||
map["phli"].Insert(0, "Noto Sans Inscriptional Pahlavi");
|
||||
map["prti"].Insert(0, "Noto Sans Inscriptional Parthian");
|
||||
map["java"].Insert(0, "Noto Sans Javanese");
|
||||
map["kthi"].Insert(0, "Noto Sans Kaithi");
|
||||
map["knda"].Insert(0, "Noto Sans Kannada");
|
||||
map["kali"].Insert(0, "Noto Sans KayahLi");
|
||||
map["khar"].Insert(0, "Noto Sans Kharoshthi");
|
||||
map["khmr"].Insert(0, "Noto Sans Khmer");
|
||||
map["khoj"].Insert(0, "Noto Sans Khojki");
|
||||
map["laoo"].Insert(0, "Noto Sans Lao");
|
||||
map["lepc"].Insert(0, "Noto Sans Lepcha");
|
||||
map["limb"].Insert(0, "Noto Sans Limbu");
|
||||
map["lina"].Insert(0, "Noto Sans Linear A");
|
||||
map["linb"].Insert(0, "Noto Sans Linear B");
|
||||
map["lisu"].Insert(0, "Noto Sans Lisu");
|
||||
map["lyci"].Insert(0, "Noto Sans Lycian");
|
||||
map["lydi"].Insert(0, "Noto Sans Lydian");
|
||||
map["mlym"].Insert(0, "Noto Sans Malayalam");
|
||||
map["mand"].Insert(0, "Noto Sans Mandiac");
|
||||
map["mani"].Insert(0, "Noto Sans Manichaean");
|
||||
map["marc"].Insert(0, "Noto Sans Marchen");
|
||||
map["gonm"].Insert(0, "Noto Sans Masaram Gondi");
|
||||
map["medf"].Insert(0, "Noto Sans Medefaidrin");
|
||||
map["mtei"].Insert(0, "Noto Sans Meetei Mayek");
|
||||
map["merc"].Insert(0, "Noto Sans Meroitic");
|
||||
map["mero"].Insert(0, "Noto Sans Meroitic");
|
||||
map["plrd"].Insert(0, "Noto Sans Miao");
|
||||
map["modi"].Insert(0, "Noto Sans Modi");
|
||||
map["mong"].Insert(0, "Noto Sans Mongolian");
|
||||
map["mroo"].Insert(0, "Noto Sans Mro");
|
||||
map["mult"].Insert(0, "Noto Sans Multani");
|
||||
map["mymr"].Insert(0, "Noto Sans Myanmar");
|
||||
map["nkoo"].Insert(0, "Noto Sans Nko");
|
||||
map["nbat"].Insert(0, "Noto Sans Nabataean");
|
||||
map["talu"].Insert(0, "Noto Sans New Tai Lue");
|
||||
map["newa"].Insert(0, "Noto Sans Newa");
|
||||
map["ogam"].Insert(0, "Noto Sans Ogham");
|
||||
map["olck"].Insert(0, "Noto Sans Ol Chiki");
|
||||
map["ital"].Insert(0, "Noto Sans Old Italian");
|
||||
map["narb"].Insert(0, "Noto Sans Old North Arabian");
|
||||
map["perm"].Insert(0, "Noto Sans Old Permic");
|
||||
map["xpeo"].Insert(0, "Noto Sans Old Persian");
|
||||
map["sarb"].Insert(0, "Noto Sans Old South Arabian");
|
||||
map["orkh"].Insert(0, "Noto Sans Old Turkic");
|
||||
map["orya"].Insert(0, "Noto Sans Oriya");
|
||||
map["osge"].Insert(0, "Noto Sans Osage");
|
||||
map["osma"].Insert(0, "Noto Sans Osmanya");
|
||||
map["hmng"].Insert(0, "Noto Sans Pahawh Hmong");
|
||||
map["palm"].Insert(0, "Noto Sans Palmyrene");
|
||||
map["pauc"].Insert(0, "Noto Sans Pau Cin Hau");
|
||||
map["phag"].Insert(0, "Noto Sans Phags Pa");
|
||||
map["phnx"].Insert(0, "Noto Sans Phoenician");
|
||||
map["rjng"].Insert(0, "Noto Sans Rejang");
|
||||
map["runr"].Insert(0, "Noto Sans Runic");
|
||||
map["samr"].Insert(0, "Noto Sans Samaritan");
|
||||
map["saur"].Insert(0, "Noto Sans Saurashtra");
|
||||
map["shrd"].Insert(0, "Noto Sans Sharada");
|
||||
map["shaw"].Insert(0, "Noto Sans Shavian");
|
||||
map["sinh"].Insert(0, "Noto Sans Sinhala");
|
||||
map["sora"].Insert(0, "Noto Sans Sora Sompeng");
|
||||
map["soyo"].Insert(0, "Noto Sans Soyombo");
|
||||
map["sund"].Insert(0, "Noto Sans Sundanese");
|
||||
map["sylo"].Insert(0, "Noto Sans Syloti Nagri");
|
||||
map["zsym"].Insert(0, "Noto Sans Symbols");
|
||||
map["syrn"].Insert(0, "Noto Sans Syriac Eastern");
|
||||
map["syre"].Insert(0, "Noto Sans Syriac Estrangela");
|
||||
map["syrj"].Insert(0, "Noto Sans Syriac Western");
|
||||
map["tglg"].Insert(0, "Noto Sans Tagalog");
|
||||
map["tagb"].Insert(0, "Noto Sans Tagbanwa");
|
||||
map["tale"].Insert(0, "Noto Sans Tai Le");
|
||||
map["lana"].Insert(0, "Noto Sans Tai Tham");
|
||||
map["tavt"].Insert(0, "Noto Sans Tai Viet");
|
||||
map["takr"].Insert(0, "Noto Sans Takri");
|
||||
map["taml"].Insert(0, "Noto Sans Tamil");
|
||||
map["telu"].Insert(0, "Noto Sans Telugu");
|
||||
map["thaa"].Insert(0, "Noto Sans Thaana");
|
||||
map["thai"].Insert(0, "Noto Sans Thai");
|
||||
map["tfng"].Insert(0, "Noto Sans Tifinagh");
|
||||
map["ugar"].Insert(0, "Noto Sans Ugaritic");
|
||||
map["vaii"].Insert(0, "Noto Sans Vai");
|
||||
map["wcho"].Insert(0, "Noto Sans Wancho");
|
||||
map["wara"].Insert(0, "Noto Sans Warang Citi");
|
||||
map["yiii"].Insert(0, "Noto Sans Yi");
|
||||
return map;
|
||||
}
|
||||
public FallbackListFontMatcher(FontManager manager) : base(manager) { }
|
||||
public override IEnumerable<Typeface> MatchScript(string script = null, bool distinctFamily = false) {
|
||||
|
8
Assets/Cryville/Common/Network/Http11.meta
Normal file
8
Assets/Cryville/Common/Network/Http11.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a624371d4108614b9cdc4acca1499e2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -4,12 +4,11 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
namespace Cryville.Common.Network {
|
||||
public class HttpClient {
|
||||
namespace Cryville.Common.Network.Http11 {
|
||||
public class Http11Client : IDisposable {
|
||||
private readonly string _directHost;
|
||||
protected string DirectHost { get { return _directHost; } }
|
||||
|
||||
@@ -19,29 +18,17 @@ namespace Cryville.Common.Network {
|
||||
readonly Uri _baseUri;
|
||||
readonly int origPort;
|
||||
|
||||
protected string Version = "HTTP/1.1";
|
||||
protected const string Version = "HTTP/1.1";
|
||||
protected TcpClient TcpClient { get; private set; }
|
||||
protected Stream RawTcpStream {
|
||||
get {
|
||||
return TcpClient.GetStream();
|
||||
}
|
||||
}
|
||||
protected virtual Stream Stream {
|
||||
get {
|
||||
return TcpClient.GetStream();
|
||||
}
|
||||
}
|
||||
protected virtual string WindowsProxyProtocolName {
|
||||
get {
|
||||
return "http";
|
||||
}
|
||||
}
|
||||
protected Stream RawTcpStream { get { return TcpClient.GetStream(); } }
|
||||
protected virtual Stream Stream { get { return TcpClient.GetStream(); } }
|
||||
protected virtual string WindowsProxyProtocolName { get { return "http"; } }
|
||||
|
||||
private readonly bool _proxied = false;
|
||||
|
||||
public Dictionary<string, string> Headers { get; set; }
|
||||
|
||||
public HttpClient(Uri baseUri, int port = 80) {
|
||||
public Http11Client(Uri baseUri, int port = 80) {
|
||||
_directHost = baseUri.Host;
|
||||
_directPort = port;
|
||||
_baseUri = baseUri;
|
||||
@@ -61,18 +48,29 @@ namespace Cryville.Common.Network {
|
||||
public virtual void Close() {
|
||||
TcpClient.Close();
|
||||
}
|
||||
|
||||
public HttpResponse Request(string method, Uri uri, string body = null, Encoding encoding = null) {
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public virtual void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
public Http11Response Request(string method, Uri uri, string body = null, Encoding encoding = null) {
|
||||
string struri = GetUri(uri).PathAndQuery;
|
||||
return Request(Stream, method, struri, body, encoding);
|
||||
}
|
||||
|
||||
public HttpResponse Request(Stream stream, string method, string uri, string body = null, Encoding encoding = null) {
|
||||
var headers = new Dictionary<string, string>();
|
||||
Http11Response Request(Stream stream, string method, string uri, string body = null, Encoding encoding = null) {
|
||||
var headers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var h in Headers)
|
||||
headers.Add(h.Key, h.Value);
|
||||
headers["Host"] = _baseUri.Host;
|
||||
byte[] payload = new byte[0];
|
||||
byte[] payload = null;
|
||||
if (body != null) {
|
||||
if (encoding == null)
|
||||
encoding = Encoding.UTF8;
|
||||
@@ -80,22 +78,24 @@ namespace Cryville.Common.Network {
|
||||
headers.Add("Content-Encoding", encoding.EncodingName);
|
||||
headers.Add("Content-Length", payload.Length.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
string request_line = string.Format(
|
||||
"{0} {1} {2}\r\n", method, uri, Version
|
||||
);
|
||||
string header_fields = string.Concat((
|
||||
from h in headers select h.Key + ":" + h.Value + "\r\n"
|
||||
).ToArray());
|
||||
byte[] buffer0 = Encoding.ASCII.GetBytes(string.Format(
|
||||
"{0}{1}\r\n", request_line, header_fields
|
||||
));
|
||||
byte[] buffer1 = new byte[buffer0.Length + payload.Length];
|
||||
Array.Copy(buffer0, buffer1, buffer0.Length);
|
||||
Array.Copy(payload, 0, buffer1, buffer0.Length, payload.Length);
|
||||
Logger.Log("main", 0, "Network", Encoding.UTF8.GetString(buffer1));
|
||||
stream.Write(buffer1, 0, buffer1.Length);
|
||||
stream.Flush();
|
||||
var response = new HttpResponse(stream);
|
||||
using (var writer = new StreamWriter(stream, Encoding.ASCII, 1024, true)) {
|
||||
writer.Write(method);
|
||||
writer.Write(' ');
|
||||
writer.Write(uri);
|
||||
writer.Write(' ');
|
||||
writer.Write(Version);
|
||||
writer.Write("\r\n");
|
||||
foreach (var header in headers) {
|
||||
writer.Write(header.Key);
|
||||
writer.Write(':');
|
||||
writer.Write(header.Value);
|
||||
writer.Write("\r\n");
|
||||
}
|
||||
writer.Write("\r\n");
|
||||
if (payload != null) writer.Write(payload);
|
||||
writer.Flush();
|
||||
}
|
||||
var response = new Http11Response(stream);
|
||||
Logger.Log("main", 0, "Network", "{0}", response);
|
||||
return response;
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9653d5e145f2866439a0fcd1b27f49c4
|
||||
guid: 5a795e416e54c69418de1a3c27a88932
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@@ -1,31 +1,41 @@
|
||||
using Cryville.Common.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Cryville.Common.Network {
|
||||
public class HttpResponse {
|
||||
namespace Cryville.Common.Network.Http11 {
|
||||
public class Http11Response : IDisposable {
|
||||
static readonly char[] spchar = new char[]{ ' ' };
|
||||
public string HttpVersion { get; private set; }
|
||||
public string StatusCode { get; private set; }
|
||||
public string ReasonPhase { get; private set; }
|
||||
public Dictionary<string, string> Headers { get; private set; }
|
||||
public HttpResponseStream MessageBody { get; private set; }
|
||||
internal HttpResponse(Stream stream) {
|
||||
public Http11ResponseStream MessageBody { get; private set; }
|
||||
internal Http11Response(Stream stream) {
|
||||
var reader = new BinaryReader(stream, Encoding.ASCII);
|
||||
var statu_line = ReadLine(reader).Split(spchar, 3);
|
||||
HttpVersion = statu_line[0];
|
||||
StatusCode = statu_line[1];
|
||||
ReasonPhase = statu_line[2];
|
||||
Logger.Log("main", 0, "Network", "Receive Response: {0} {1} {2}", HttpVersion, StatusCode, ReasonPhase);
|
||||
Headers = new Dictionary<string, string>();
|
||||
Headers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
while (ParseHeader(reader, Headers)) ;
|
||||
if (Headers.ContainsKey("content-length")) {
|
||||
int length = int.Parse(Headers["content-length"]);
|
||||
MessageBody = new HttpResponseBlockStream(reader, length);
|
||||
MessageBody = new Http11ResponseBlockStream(reader, length);
|
||||
}
|
||||
else if (Headers.ContainsKey("transfer-encoding") && Headers["transfer-encoding"] == "chunked") {
|
||||
MessageBody = new HttpResponseChunkedStream(reader);
|
||||
MessageBody = new Http11ResponseChunkedStream(reader);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public virtual void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
MessageBody.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,12 +47,11 @@ namespace Cryville.Common.Network {
|
||||
// TODO Multiline header
|
||||
var header = ReadLine(reader);
|
||||
if (header == "") return false;
|
||||
var s = header.Split(':');
|
||||
var s = header.Split(':', 2);
|
||||
string field_name = s[0].Trim().ToLower();
|
||||
string field_value = s[1].Trim();
|
||||
if (headers.ContainsKey(field_name)) headers[field_name] += "," + field_value;
|
||||
else headers.Add(field_name, field_value);
|
||||
Logger.Log("main", 0, "Network", "Receive Header {0}: {1}", field_name, field_value);
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,8 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ea931bf5488011468f3d1243a038874
|
||||
timeCreated: 1622589817
|
||||
licenseType: Free
|
||||
guid: 71234dd1c93d47b4893750686b2333a3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
@@ -1,12 +1,11 @@
|
||||
using Cryville.Common.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace Cryville.Common.Network {
|
||||
public abstract class HttpResponseStream : Stream {
|
||||
namespace Cryville.Common.Network.Http11 {
|
||||
public abstract class Http11ResponseStream : Stream {
|
||||
public override bool CanRead { get { return true; } }
|
||||
|
||||
public override bool CanSeek { get { return false; } }
|
||||
@@ -37,11 +36,11 @@ namespace Cryville.Common.Network {
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class HttpResponseBlockStream : HttpResponseStream {
|
||||
internal sealed class Http11ResponseBlockStream : Http11ResponseStream {
|
||||
readonly BinaryReader _reader;
|
||||
readonly int _length;
|
||||
int _pos = 0;
|
||||
internal HttpResponseBlockStream(BinaryReader reader, int length) {
|
||||
internal Http11ResponseBlockStream(BinaryReader reader, int length) {
|
||||
_reader = reader;
|
||||
_length = length;
|
||||
}
|
||||
@@ -51,7 +50,6 @@ namespace Cryville.Common.Network {
|
||||
if (recv_len == 0) return 0;
|
||||
while (recv < recv_len) {
|
||||
recv += _reader.Read(buffer, offset + recv, count - recv);
|
||||
Logger.Log("main", 0, "Network", "Message body received: {0}/{1}/{2}", recv, recv_len, _length);
|
||||
}
|
||||
_pos += recv_len;
|
||||
return recv_len;
|
||||
@@ -63,36 +61,34 @@ namespace Cryville.Common.Network {
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class HttpResponseChunkedStream : HttpResponseStream {
|
||||
internal sealed class Http11ResponseChunkedStream : Http11ResponseStream {
|
||||
readonly BinaryReader _reader;
|
||||
byte[] _chunk = null;
|
||||
int _pos = 0;
|
||||
internal HttpResponseChunkedStream(BinaryReader reader) {
|
||||
internal Http11ResponseChunkedStream(BinaryReader reader) {
|
||||
_reader = reader;
|
||||
ReadChunk();
|
||||
}
|
||||
public void ReadChunk() {
|
||||
if (_chunk != null && _chunk.Length == 0) return;
|
||||
string[] chunkHeader = HttpResponse.ReadLine(_reader).Split(';');
|
||||
// int chunkSize = Array.IndexOf(LEN, chunkHeader[0].ToLower()[0]);
|
||||
int chunkSize = int.Parse(chunkHeader[0], NumberStyles.HexNumber);
|
||||
if (chunkSize == -1)
|
||||
string[] chunkHeader = Http11Response.ReadLine(_reader).Split(';');
|
||||
int chunkSize;
|
||||
if (!int.TryParse(chunkHeader[0], NumberStyles.HexNumber, CultureInfo.InvariantCulture, out chunkSize))
|
||||
throw new IOException("Corrupted chunk received");
|
||||
if (chunkSize == 0) {
|
||||
_chunk = new byte[0];
|
||||
// TODO TE Header, now just discard
|
||||
var headers = new Dictionary<string, string>();
|
||||
while (HttpResponse.ParseHeader(_reader, headers)) ;
|
||||
while (Http11Response.ParseHeader(_reader, headers)) ;
|
||||
return;
|
||||
}
|
||||
_chunk = new byte[chunkSize];
|
||||
int recv = 0;
|
||||
while (recv < chunkSize) {
|
||||
recv += _reader.Read(_chunk, recv, chunkSize - recv);
|
||||
Logger.Log("main", 0, "Network", "Message chunk received: {0}/{1}", recv, chunkSize);
|
||||
}
|
||||
_pos = 0;
|
||||
if (HttpResponse.ReadLine(_reader) != "")
|
||||
if (Http11Response.ReadLine(_reader) != "")
|
||||
throw new IOException("Corrupted chunk received");
|
||||
}
|
||||
public override int Read(byte[] buffer, int offset, int count) {
|
@@ -1,8 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b35290e0e147a342acc29a20c8fceaf
|
||||
timeCreated: 1622503538
|
||||
licenseType: Free
|
||||
guid: 49a8d5b9869e5bb42bafbe71f84fecc5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Cryville.Common.Network {
|
||||
public class HttpsClient : HttpClient {
|
||||
namespace Cryville.Common.Network.Http11 {
|
||||
public class Https11Client : Http11Client {
|
||||
readonly TlsClient _tlsClient;
|
||||
|
||||
protected override Stream Stream {
|
||||
@@ -16,7 +16,7 @@ namespace Cryville.Common.Network {
|
||||
}
|
||||
}
|
||||
|
||||
public HttpsClient(Uri baseUri) : base(baseUri, 443) {
|
||||
public Https11Client(Uri baseUri) : base(baseUri, 443) {
|
||||
_tlsClient = new TlsClient(RawTcpStream, baseUri.Host);
|
||||
}
|
||||
|
@@ -1,8 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07e8215a93e3eb1418685009f0c58dcd
|
||||
timeCreated: 1622596274
|
||||
licenseType: Free
|
||||
guid: c5c233e6228ce204fa1a9724c48ac8fe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f191de447a708da4f9d230e6545ce0a6
|
||||
timeCreated: 1635470462
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,8 +1,8 @@
|
||||
using Cryville.Common.Logging;
|
||||
using Org.BouncyCastle.Security;
|
||||
using Org.BouncyCastle.Tls;
|
||||
using Org.BouncyCastle.Tls.Crypto;
|
||||
using Org.BouncyCastle.Tls.Crypto.Impl.BC;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -10,7 +10,7 @@ using System.Text;
|
||||
using BcTlsClient = Org.BouncyCastle.Tls.TlsClient;
|
||||
|
||||
namespace Cryville.Common.Network {
|
||||
public class TlsClient {
|
||||
public class TlsClient : IDisposable {
|
||||
readonly TlsClientProtocol _protocol;
|
||||
readonly BcTlsClient _tlsClient;
|
||||
public Stream Stream { get; private set; }
|
||||
@@ -28,6 +28,17 @@ namespace Cryville.Common.Network {
|
||||
_protocol.Close();
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public virtual void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTlsClient : DefaultTlsClient {
|
||||
readonly string _host;
|
||||
|
||||
@@ -72,20 +83,6 @@ namespace Cryville.Common.Network {
|
||||
public override TlsAuthentication GetAuthentication() {
|
||||
return new NullTlsAuthentication();
|
||||
}
|
||||
|
||||
public override void NotifyAlertReceived(short alertLevel, short alertDescription) {
|
||||
Logger.Log("main", 0, "Network/TLS", "TLS Alert {0} {1}", alertLevel, alertDescription);
|
||||
}
|
||||
|
||||
public override void NotifyServerVersion(ProtocolVersion serverVersion) {
|
||||
base.NotifyServerVersion(serverVersion);
|
||||
Logger.Log("main", 0, "Network/TLS", "NotifyServerVersion {0}", serverVersion);
|
||||
}
|
||||
|
||||
public override void NotifySelectedCipherSuite(int selectedCipherSuite) {
|
||||
base.NotifySelectedCipherSuite(selectedCipherSuite);
|
||||
Logger.Log("main", 0, "Network/TLS", "NotifySelectedCipherSuite {0}", selectedCipherSuite);
|
||||
}
|
||||
}
|
||||
|
||||
private class NullTlsAuthentication : TlsAuthentication {
|
||||
|
@@ -24,8 +24,8 @@ namespace Cryville.Common.Pdt {
|
||||
/// <param name="exp">The expression to evaluate.</param>
|
||||
/// <returns>Whether the evaluaton succeeded.</returns>
|
||||
public bool Evaluate(PdtOperator target, PdtExpression exp) {
|
||||
var prevFrameCount = _framecount;
|
||||
try {
|
||||
var prevFrameCount = _framecount;
|
||||
_revokepttconst = false;
|
||||
for (var ip = exp.Instructions.First; ip != null; ip = ip.Next)
|
||||
ip.Value.Execute(this, ref ip);
|
||||
@@ -33,12 +33,14 @@ namespace Cryville.Common.Pdt {
|
||||
exp.IsConstant = exp.IsPotentialConstant = !_revokepttconst;
|
||||
}
|
||||
var ret = Operate(target, _framecount - prevFrameCount, true);
|
||||
for (var i = prevFrameCount; i < _framecount; i++) DiscardStack();
|
||||
return ret;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new EvaluationFailureException(exp, ex);
|
||||
}
|
||||
finally {
|
||||
for (var i = prevFrameCount; i < _framecount; i++) DiscardStack();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Optimizes an expression by merging its instructions.
|
||||
@@ -133,10 +135,7 @@ namespace Cryville.Common.Pdt {
|
||||
for (var ins = il.First; ins != null; ins = ins.Next) {
|
||||
if (!(ins.Value is PdtInstruction.PushConstant)) {
|
||||
exp.IsConstant = false;
|
||||
}
|
||||
else if (!(ins.Value is PdtInstruction.PushVariable)) {
|
||||
exp.IsPotentialConstant = false;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -205,7 +204,7 @@ namespace Cryville.Common.Pdt {
|
||||
var frame = _stack[--_framecount];
|
||||
if (frame.Type == PdtInternalType.Error) {
|
||||
_framecount -= pc - i - 1;
|
||||
_stack[_framecount++] = new StackFrame { Type = PdtInternalType.Error, Offset = _goffset, Length = 0 };
|
||||
_stack[_framecount++] = new StackFrame { Type = PdtInternalType.Error, Offset = -1, Length = 0 };
|
||||
return false;
|
||||
}
|
||||
op.LoadOperand(new PdtVariableMemory(frame.Type, pmem + frame.Offset, frame.Length));
|
||||
@@ -218,13 +217,15 @@ namespace Cryville.Common.Pdt {
|
||||
internal unsafe void Collapse(int name, ref LinkedListNode<PdtInstruction> self, LinkedListNode<PdtInstruction> target) {
|
||||
fixed (byte* pmem = _mem) {
|
||||
var frame = _stack[--_framecount];
|
||||
_goffset -= frame.Length;
|
||||
if (frame.Type == PdtInternalType.Error) {
|
||||
_stack[_framecount++] = new StackFrame { Type = PdtInternalType.Error, Offset = _goffset, Length = 0 };
|
||||
_stack[_framecount++] = new StackFrame { Type = PdtInternalType.Error, Offset = -1, Length = 0 };
|
||||
self = target;
|
||||
return;
|
||||
}
|
||||
if (Collapse(name, new PdtVariableMemory(frame.Type, pmem + frame.Offset, frame.Length))) {
|
||||
_framecount++;
|
||||
_goffset += frame.Length;
|
||||
self = target;
|
||||
}
|
||||
}
|
||||
|
@@ -57,6 +57,7 @@ namespace Cryville.Common.Unity {
|
||||
suspended = true;
|
||||
if (currentNetworkTask != null) {
|
||||
currentNetworkTask.Cancel();
|
||||
networkTasks.Enqueue(currentNetworkTask);
|
||||
currentNetworkTask = null;
|
||||
}
|
||||
}
|
||||
@@ -91,15 +92,6 @@ namespace Cryville.Common.Unity {
|
||||
/// A network task.
|
||||
/// </summary>
|
||||
public abstract class NetworkTask {
|
||||
protected NetworkTask(string uri) {
|
||||
Uri = uri;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The URI of the resource.
|
||||
/// </summary>
|
||||
public string Uri { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the task is cancelled.
|
||||
/// </summary>
|
||||
@@ -108,40 +100,56 @@ namespace Cryville.Common.Unity {
|
||||
/// <summary>
|
||||
/// Cancels the task.
|
||||
/// </summary>
|
||||
public virtual void Cancel() {
|
||||
public void Cancel() {
|
||||
Cancelled = true;
|
||||
OnCancel();
|
||||
}
|
||||
protected virtual void OnCancel() { }
|
||||
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
protected UnityWebRequest www;
|
||||
|
||||
/// <summary>
|
||||
/// Starts the task.
|
||||
/// </summary>
|
||||
public virtual void Start() {
|
||||
www = new UnityWebRequest(Uri);
|
||||
www.SendWebRequest();
|
||||
}
|
||||
public abstract void Start();
|
||||
/// <summary>
|
||||
/// Gets whether the task is done.
|
||||
/// </summary>
|
||||
/// <returns>Whether the task is done.</returns>
|
||||
public virtual bool Done() {
|
||||
public abstract bool Done();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A Unity network task.
|
||||
/// </summary>
|
||||
public abstract class UnityNetworkTask : NetworkTask {
|
||||
protected UnityNetworkTask(string uri) {
|
||||
Uri = uri;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The URI of the resource.
|
||||
/// </summary>
|
||||
public string Uri { get; private set; }
|
||||
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
protected UnityWebRequest www;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Start() {
|
||||
www = new UnityWebRequest(Uri);
|
||||
www.SendWebRequest();
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public override bool Done() {
|
||||
if (!www.isDone) return false;
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
protected WWW www;
|
||||
/// <summary>
|
||||
/// Starts the task.
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public virtual void Start() {
|
||||
www = new WWW(Uri);
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether the task is done.
|
||||
/// </summary>
|
||||
/// <returns>Whether the task is done.</returns>
|
||||
/// <inheritdoc />
|
||||
public virtual bool Done() {
|
||||
if (!www.isDone) return false;
|
||||
return true;
|
||||
@@ -149,9 +157,9 @@ namespace Cryville.Common.Unity {
|
||||
#endif
|
||||
}
|
||||
/// <summary>
|
||||
/// A <see cref="NetworkTask" /> that loads a texture.
|
||||
/// A <see cref="UnityNetworkTask" /> that loads a texture.
|
||||
/// </summary>
|
||||
public class LoadTextureTask : NetworkTask {
|
||||
public class LoadTextureTask : UnityNetworkTask {
|
||||
/// <summary>
|
||||
/// Creates an instance of the <see cref="LoadTextureTask" /> class.
|
||||
/// </summary>
|
||||
|
26
Assets/Cryville/Common/Unity/UrlOpener.cs
Normal file
26
Assets/Cryville/Common/Unity/UrlOpener.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
namespace Cryville.Common.Unity {
|
||||
public static class UrlOpener {
|
||||
public static void Open(string url) {
|
||||
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
|
||||
System.Diagnostics.Process.Start(url);
|
||||
#elif UNITY_ANDROID
|
||||
using (var clazz = new UnityEngine.AndroidJavaClass("world.cryville.common.unity.UrlOpener")) {
|
||||
clazz.CallStatic("open", url);
|
||||
}
|
||||
#else
|
||||
#error Unknown platform.
|
||||
#endif
|
||||
}
|
||||
public static void OpenThreaded(string url) {
|
||||
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
|
||||
Open(url);
|
||||
#elif UNITY_ANDROID
|
||||
UnityEngine.AndroidJNI.AttachCurrentThread();
|
||||
Open(url);
|
||||
UnityEngine.AndroidJNI.DetachCurrentThread();
|
||||
#else
|
||||
#error Unknown platform.
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Common/Unity/UrlOpener.cs.meta
Normal file
11
Assets/Cryville/Common/Unity/UrlOpener.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c827ee181de8c51499777e5a822981b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
17
Assets/Cryville/Common/Unity/UrlOpener.java
Normal file
17
Assets/Cryville/Common/Unity/UrlOpener.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package world.cryville.common.unity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import com.unity3d.player.UnityPlayer;
|
||||
import com.unity3d.player.UnityPlayerActivity;
|
||||
|
||||
public final class UrlOpener {
|
||||
private UrlOpener() { }
|
||||
|
||||
static UnityPlayerActivity activity;
|
||||
|
||||
public static void open(String url) {
|
||||
if (activity == null) activity = (UnityPlayerActivity)UnityPlayer.currentActivity;
|
||||
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
|
||||
}
|
||||
}
|
32
Assets/Cryville/Common/Unity/UrlOpener.java.meta
Normal file
32
Assets/Cryville/Common/Unity/UrlOpener.java.meta
Normal file
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2d08ba79acb0564b9802b57dbc2f8d3
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -66,7 +66,7 @@ namespace Cryville.Crtr.Browsing {
|
||||
var coverFile = item.GetFiles(meta.cover);
|
||||
if (coverFile.Length > 0) {
|
||||
cover = new AsyncDelivery<Texture2D>();
|
||||
var task = new LoadTextureTask(Game.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
|
||||
var task = new LoadTextureTask(PlatformConfig.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
|
||||
cover.CancelSource = task.Cancel;
|
||||
Game.NetworkTaskWorker.SubmitNetworkTask(task);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ namespace Cryville.Crtr.Browsing {
|
||||
var coverFile = item.GetFiles(meta.cover);
|
||||
if (coverFile.Length > 0) {
|
||||
cover = new AsyncDelivery<Texture2D>();
|
||||
var task = new LoadTextureTask(Game.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
|
||||
var task = new LoadTextureTask(PlatformConfig.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
|
||||
cover.CancelSource = task.Cancel;
|
||||
Game.NetworkTaskWorker.SubmitNetworkTask(task);
|
||||
}
|
||||
|
@@ -1,76 +0,0 @@
|
||||
using Cryville.Common.ComponentModel;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using RangeAttribute = Cryville.Common.ComponentModel.RangeAttribute;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
public class PropertyPanel : MonoBehaviour {
|
||||
[SerializeField]
|
||||
GameObject m_bool;
|
||||
[SerializeField]
|
||||
GameObject m_number;
|
||||
[SerializeField]
|
||||
GameObject m_string;
|
||||
|
||||
PropertyInfo _property;
|
||||
object _target;
|
||||
|
||||
Text _key;
|
||||
Transform _valueContainer;
|
||||
PropertyValuePanel _value;
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
void Awake() {
|
||||
_key = transform.Find("Key").GetComponent<Text>();
|
||||
_valueContainer = transform.Find("Value");
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
public void Load(PropertyInfo prop, object target) {
|
||||
_target = target;
|
||||
_property = prop;
|
||||
_key.text = prop.Name;
|
||||
|
||||
GameObject vp;
|
||||
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(string)) vp = m_string;
|
||||
else return;
|
||||
_value = GameObject.Instantiate(vp, _valueContainer, false).GetComponent<PropertyValuePanel>();
|
||||
if (_value is PVPNumber) {
|
||||
var t = (PVPNumber)_value;
|
||||
t.IntegerMode = prop.PropertyType == typeof(int);
|
||||
var attr = prop.GetCustomAttributes(typeof(RangeAttribute), true);
|
||||
if (attr.Length > 0) {
|
||||
var u = (RangeAttribute)attr[0];
|
||||
t.Range = new Vector2(u.Min, u.Max);
|
||||
}
|
||||
attr = prop.GetCustomAttributes(typeof(PrecisionAttribute), true);
|
||||
if (attr.Length > 0) {
|
||||
var u = (PrecisionAttribute)attr[0];
|
||||
t.Precision = u.Precision;
|
||||
}
|
||||
attr = prop.GetCustomAttributes(typeof(StepAttribute), true);
|
||||
if (attr.Length > 0) {
|
||||
var u = (StepAttribute)attr[0];
|
||||
t.MaxStep = u.Step;
|
||||
}
|
||||
attr = prop.GetCustomAttributes(typeof(LogarithmicScaleAttribute), true);
|
||||
if (attr.Length > 0) {
|
||||
t.LogarithmicMode = true;
|
||||
}
|
||||
}
|
||||
_value.Callback = SetValueToObject;
|
||||
GetValueFromObject();
|
||||
}
|
||||
|
||||
void GetValueFromObject() {
|
||||
_value.Value = _property.GetValue(_target, null);
|
||||
}
|
||||
|
||||
void SetValueToObject(object value) {
|
||||
_property.SetValue(_target, value, null);
|
||||
GetValueFromObject();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
public abstract class PropertyValuePanel : MonoBehaviour {
|
||||
public Action<object> Callback { protected get; set; }
|
||||
public abstract object Value { get; set; }
|
||||
}
|
||||
}
|
@@ -215,11 +215,11 @@ namespace Cryville.Crtr {
|
||||
default: return base.GetEventsOfType(type);
|
||||
}
|
||||
}
|
||||
public override int Priority { get { return 10; } }
|
||||
public override int Priority { get { return 12; } }
|
||||
}
|
||||
|
||||
public class Track : EventContainer {
|
||||
public override int Priority { get { return 10; } }
|
||||
public override int Priority { get { return 14; } }
|
||||
}
|
||||
|
||||
public class Motion : ChartEvent {
|
||||
|
@@ -66,7 +66,7 @@ namespace Cryville.Crtr {
|
||||
if (comps[i] == "") comps[i] = "0";
|
||||
}
|
||||
_itor.SetSource(string.Format("({0});", string.Join(',', comps)));
|
||||
ChartPlayer.etor.Evaluate(_vecop, _itor.GetExp());
|
||||
PdtEvaluator.Instance.Evaluate(_vecop, _itor.GetExp());
|
||||
return _vecbuf;
|
||||
}
|
||||
}
|
||||
@@ -99,18 +99,18 @@ namespace Cryville.Crtr {
|
||||
var exp = _itor.GetExp();
|
||||
switch (c) {
|
||||
case '@':
|
||||
ChartPlayer.etor.Evaluate(_vecop, exp);
|
||||
PdtEvaluator.Instance.Evaluate(_vecop, exp);
|
||||
node.Time = new Vec1(_vecbuf);
|
||||
break;
|
||||
case '~':
|
||||
ChartPlayer.etor.Evaluate(_vecop, exp);
|
||||
PdtEvaluator.Instance.Evaluate(_vecop, exp);
|
||||
node.EndTime = new Vec1(_vecbuf);
|
||||
break;
|
||||
case '^':
|
||||
node.Transition = exp;
|
||||
break;
|
||||
case ':':
|
||||
ChartPlayer.etor.Evaluate(_vecop, exp);
|
||||
PdtEvaluator.Instance.Evaluate(_vecop, exp);
|
||||
node.Value = Vector.Construct(ChartPlayer.motionRegistry[name].Type, _vecbuf);
|
||||
break;
|
||||
default:
|
||||
|
@@ -1,5 +1,3 @@
|
||||
#define BUILD
|
||||
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Buffers;
|
||||
using Cryville.Crtr.Config;
|
||||
@@ -62,8 +60,6 @@ namespace Cryville.Crtr {
|
||||
public static float sv = 16f;
|
||||
|
||||
public static Dictionary<Identifier, MotionRegistry> motionRegistry;
|
||||
|
||||
public static PdtEvaluator etor;
|
||||
#endregion
|
||||
|
||||
#region MonoBehaviour
|
||||
@@ -82,7 +78,6 @@ namespace Cryville.Crtr {
|
||||
|
||||
status = GameObject.Find("Status").GetComponent<TextMeshProUGUI>();
|
||||
|
||||
#if BUILD
|
||||
try {
|
||||
Play();
|
||||
}
|
||||
@@ -91,7 +86,6 @@ namespace Cryville.Crtr {
|
||||
Popup.CreateException(ex);
|
||||
ReturnToMenu();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Camera.main.RenderToCubemap();
|
||||
}
|
||||
@@ -186,9 +180,7 @@ namespace Cryville.Crtr {
|
||||
Logger.Log("main", 4, "Load/MainThread", "Load failed");
|
||||
loadThread = null;
|
||||
Popup.CreateException(threadException);
|
||||
#if BUILD
|
||||
ReturnToMenu();
|
||||
#endif
|
||||
}
|
||||
else if (texloaddone) {
|
||||
if (texLoader == null) Stop();
|
||||
@@ -355,13 +347,19 @@ namespace Cryville.Crtr {
|
||||
forceSyncFrames = Settings.Default.ForceSyncFrames;
|
||||
Game.AudioClient.Start();
|
||||
inputProxy.UnlockTime();
|
||||
#if !UNITY_ANDROID || UNITY_EDITOR
|
||||
DiscordController.Instance.SetResume(cbus.Time);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
Game.AudioClient.Pause();
|
||||
inputProxy.LockTime();
|
||||
#if !UNITY_ANDROID || UNITY_EDITOR
|
||||
DiscordController.Instance.SetPaused();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Load
|
||||
void Play() {
|
||||
@@ -377,7 +375,7 @@ namespace Cryville.Crtr {
|
||||
areaJudgePrecision = 1 << Settings.Default.AreaJudgePrecision;
|
||||
forceSyncFrames = Settings.Default.ForceSyncFrames;
|
||||
texloaddone = false;
|
||||
Game.NetworkTaskWorker.SuspendBackgroundTasks();
|
||||
Game.SuspendBackgroundTasks();
|
||||
Game.AudioSession = Game.AudioSequencer.NewSession();
|
||||
|
||||
var hitPlane = new Plane(Vector3.forward, Vector3.zero);
|
||||
@@ -455,7 +453,7 @@ namespace Cryville.Crtr {
|
||||
for (int i = 0; i < queue.Count; i++) {
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
texHandler = new DownloadHandlerTexture();
|
||||
texLoader = new UnityWebRequest(Game.FileProtocolPrefix + queue[i], "GET", texHandler, null);
|
||||
texLoader = new UnityWebRequest(PlatformConfig.FileProtocolPrefix + queue[i], "GET", texHandler, null);
|
||||
texLoader.SendWebRequest();
|
||||
#else
|
||||
texLoader = new WWW(Game.FileProtocolPrefix + queue[i]);
|
||||
@@ -552,7 +550,7 @@ namespace Cryville.Crtr {
|
||||
effectManager.Dispose();
|
||||
effectManager = null;
|
||||
}
|
||||
etor = null;
|
||||
PdtEvaluator.Instance.Reset();
|
||||
motionRegistry = null;
|
||||
Logger.Log("main", 1, "Game", "Stopped");
|
||||
}
|
||||
@@ -568,10 +566,8 @@ namespace Cryville.Crtr {
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
Game.NetworkTaskWorker.ResumeBackgroundTasks();
|
||||
#if BUILD
|
||||
Game.ResumeBackgroundTasks();
|
||||
ReturnToMenu();
|
||||
#endif
|
||||
}
|
||||
|
||||
void OnSettingsUpdate() {
|
||||
@@ -588,11 +584,9 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
Exception threadException;
|
||||
#if !NO_THREAD
|
||||
Thread loadThread = null;
|
||||
volatile float loadPregress;
|
||||
Stopwatch workerTimer;
|
||||
#endif
|
||||
void Load(object _info) {
|
||||
var info = (LoadInfo)_info;
|
||||
try {
|
||||
@@ -622,7 +616,7 @@ namespace Cryville.Crtr {
|
||||
};
|
||||
|
||||
using (StreamReader reader = new StreamReader(info.chartFile.FullName, Encoding.UTF8)) {
|
||||
etor = new PdtEvaluator();
|
||||
PdtEvaluator.Instance.Reset();
|
||||
|
||||
LoadRuleset(info.rulesetFile); loadPregress = .05f;
|
||||
|
||||
@@ -642,7 +636,7 @@ namespace Cryville.Crtr {
|
||||
|
||||
Logger.Log("main", 0, "Load/WorkerThread", "Initializing judge and input"); loadPregress = .35f;
|
||||
judge = new Judge(this, pruleset);
|
||||
etor.ContextJudge = judge;
|
||||
PdtEvaluator.Instance.ContextJudge = judge;
|
||||
|
||||
inputProxy = new InputProxy(pruleset, judge, screenSize);
|
||||
inputProxy.LoadFrom(_rscfg.inputs);
|
||||
@@ -694,8 +688,9 @@ namespace Cryville.Crtr {
|
||||
if (ruleset.format != Ruleset.CURRENT_FORMAT) throw new FormatException("Invalid ruleset file version");
|
||||
ruleset.LoadPdt(dir);
|
||||
pruleset = ruleset.Root;
|
||||
pruleset.Optimize(etor);
|
||||
pruleset.Optimize(PdtEvaluator.Instance);
|
||||
}
|
||||
PdtEvaluator.Instance.ContextRulesetConfig = new RulesetConfigStore(pruleset.configs, _rscfg.configs);
|
||||
RMVPool.Shared = new RMVPool();
|
||||
MotionCachePool.Shared = new MotionCachePool();
|
||||
MotionNodePool.Shared = new MotionNodePool();
|
||||
@@ -706,7 +701,7 @@ namespace Cryville.Crtr {
|
||||
Logger.Log("main", 0, "Load/WorkerThread", "Loading skin: {0}", file);
|
||||
skin.LoadPdt(dir);
|
||||
pskin = skin.Root;
|
||||
pskin.Optimize(etor);
|
||||
pskin.Optimize(PdtEvaluator.Instance);
|
||||
effectManager = new EffectManager(pskin);
|
||||
}
|
||||
#endregion
|
||||
|
@@ -14,7 +14,10 @@ namespace Cryville.Crtr.Config {
|
||||
Transform m_content;
|
||||
|
||||
[SerializeField]
|
||||
SettingsPanel m_genericConfigPanel;
|
||||
PropertyMasterPanel m_genericConfigPanel;
|
||||
|
||||
[SerializeField]
|
||||
PropertyMasterPanel m_rulesetConfigPanel;
|
||||
|
||||
[SerializeField]
|
||||
InputConfigPanel m_inputConfigPanel;
|
||||
@@ -22,9 +25,11 @@ namespace Cryville.Crtr.Config {
|
||||
public Ruleset ruleset;
|
||||
RulesetConfig _rscfg;
|
||||
|
||||
bool _loaded;
|
||||
|
||||
void OnEnable() {
|
||||
try {
|
||||
ChartPlayer.etor = new PdtEvaluator();
|
||||
PdtEvaluator.Instance.Reset();
|
||||
FileInfo file = new FileInfo(
|
||||
Game.GameDataPath + "/rulesets/" + Settings.Default.LoadRuleset
|
||||
);
|
||||
@@ -54,13 +59,16 @@ namespace Cryville.Crtr.Config {
|
||||
}
|
||||
}
|
||||
|
||||
m_genericConfigPanel.Target = _rscfg.generic;
|
||||
m_genericConfigPanel.Adapter = new DefaultPropertyMasterAdapter(_rscfg.generic);
|
||||
m_rulesetConfigPanel.Adapter = new RulesetConfigPropertyMasterAdapter(ruleset.Root.configs, _rscfg.configs);
|
||||
|
||||
var proxy = new InputProxy(ruleset.Root, null, new Vector2(Screen.width, Screen.height));
|
||||
proxy.LoadFrom(_rscfg.inputs);
|
||||
m_inputConfigPanel.proxy = proxy;
|
||||
|
||||
m_inputConfigPanel.OnConfigEnable();
|
||||
|
||||
_loaded = true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Popup.CreateException(ex);
|
||||
@@ -77,15 +85,18 @@ namespace Cryville.Crtr.Config {
|
||||
}
|
||||
|
||||
void OnDisable() {
|
||||
m_inputConfigPanel.proxy.SaveTo(_rscfg.inputs);
|
||||
m_inputConfigPanel.proxy.Dispose();
|
||||
FileInfo cfgfile = new FileInfo(
|
||||
Game.GameDataPath + "/config/rulesets/" + Settings.Default.LoadRulesetConfig
|
||||
);
|
||||
using (StreamWriter cfgwriter = new StreamWriter(cfgfile.FullName, false, Encoding.UTF8)) {
|
||||
cfgwriter.Write(JsonConvert.SerializeObject(_rscfg, Game.GlobalJsonSerializerSettings));
|
||||
if (_loaded) {
|
||||
_loaded = false;
|
||||
m_inputConfigPanel.proxy.SaveTo(_rscfg.inputs);
|
||||
m_inputConfigPanel.proxy.Dispose();
|
||||
FileInfo cfgfile = new FileInfo(
|
||||
Game.GameDataPath + "/config/rulesets/" + Settings.Default.LoadRulesetConfig
|
||||
);
|
||||
using (StreamWriter cfgwriter = new StreamWriter(cfgfile.FullName, false, Encoding.UTF8)) {
|
||||
cfgwriter.Write(JsonConvert.SerializeObject(_rscfg, Game.GlobalJsonSerializerSettings));
|
||||
}
|
||||
m_inputConfigPanel.OnConfigDisable();
|
||||
}
|
||||
m_inputConfigPanel.OnConfigDisable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
101
Assets/Cryville/Crtr/Config/IPropertyAdapter.cs
Normal file
101
Assets/Cryville/Crtr/Config/IPropertyAdapter.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using Cryville.Common.ComponentModel;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Cryville.Crtr.Config {
|
||||
public interface IPropertyAdapter {
|
||||
string Category { get; }
|
||||
string Name { get; }
|
||||
PropertyType Type { get; }
|
||||
object[] Range { get; }
|
||||
object GetValue();
|
||||
void SetValue(object value);
|
||||
event Action ValueChanged;
|
||||
object MapValue(object value);
|
||||
bool SetMapped { get; }
|
||||
object MapValueInverse(object value);
|
||||
}
|
||||
|
||||
public enum PropertyType {
|
||||
Unknown,
|
||||
Number,
|
||||
NumberStepped,
|
||||
Boolean,
|
||||
String,
|
||||
}
|
||||
|
||||
public class DefaultPropertyAdapter : IPropertyAdapter {
|
||||
readonly object _target;
|
||||
readonly PropertyInfo _prop;
|
||||
public string Category { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public PropertyType Type { get; private set; }
|
||||
public object[] Range { get; private set; }
|
||||
public object GetValue() { return _prop.GetValue(_target, null); }
|
||||
public void SetValue(object value) { _prop.SetValue(_target, value, null); }
|
||||
|
||||
public event Action ValueChanged { add { } remove { } }
|
||||
|
||||
readonly double _precision;
|
||||
readonly double _step;
|
||||
readonly bool _logarithmic;
|
||||
public object MapValue(object value) {
|
||||
if (Type == PropertyType.Number || Type == PropertyType.NumberStepped) {
|
||||
var result = (double)value;
|
||||
if (_step != 0) result *= _step;
|
||||
if (_logarithmic) result = Math.Pow(Math.E, result);
|
||||
if (_precision != 0) result = Math.Round(result / _precision) * _precision;
|
||||
return Convert.ChangeType(result, _prop.PropertyType);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
public bool SetMapped { get { return true; } }
|
||||
public object MapValueInverse(object value) {
|
||||
if (Type == PropertyType.Number || Type == PropertyType.NumberStepped) {
|
||||
var result = Convert.ToDouble(value);
|
||||
if (_logarithmic) result = Math.Log(result);
|
||||
if (_step != 0) result /= _step;
|
||||
return result;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public DefaultPropertyAdapter(object target, PropertyInfo prop) {
|
||||
_target = target;
|
||||
_prop = prop;
|
||||
var attrs = prop.GetCustomAttributes(typeof(CategoryAttribute), true);
|
||||
if (attrs.Length > 0) Category = ((CategoryAttribute)attrs.Single()).Category;
|
||||
Name = prop.Name;
|
||||
if (prop.PropertyType == typeof(bool)) Type = PropertyType.Boolean;
|
||||
else if (prop.PropertyType == typeof(char)) throw new NotSupportedException();
|
||||
else if (prop.PropertyType.IsPrimitive) {
|
||||
Type = prop.GetCustomAttributes(typeof(StepAttribute), true).Length > 0
|
||||
? PropertyType.NumberStepped
|
||||
: PropertyType.Number;
|
||||
var attr = prop.GetCustomAttributes(typeof(RangeAttribute), true);
|
||||
if (attr.Length > 0) {
|
||||
var u = (RangeAttribute)attr.Single();
|
||||
Range = new object[] { u.Min, u.Max };
|
||||
}
|
||||
attr = prop.GetCustomAttributes(typeof(PrecisionAttribute), true);
|
||||
if (attr.Length > 0) {
|
||||
var u = (PrecisionAttribute)attr.Single();
|
||||
_precision = u.Precision;
|
||||
}
|
||||
attr = prop.GetCustomAttributes(typeof(StepAttribute), true);
|
||||
if (attr.Length > 0) {
|
||||
var u = (StepAttribute)attr.Single();
|
||||
_step = u.Step;
|
||||
}
|
||||
attr = prop.GetCustomAttributes(typeof(LogarithmicScaleAttribute), true);
|
||||
if (attr.Length > 0) {
|
||||
_logarithmic = true;
|
||||
}
|
||||
}
|
||||
else if (prop.PropertyType == typeof(string)) Type = PropertyType.String;
|
||||
else return;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/Config/IPropertyAdapter.cs.meta
Normal file
11
Assets/Cryville/Crtr/Config/IPropertyAdapter.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b3e9219783719544bcbceade34a1090
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29
Assets/Cryville/Crtr/Config/IPropertyMasterAdapter.cs
Normal file
29
Assets/Cryville/Crtr/Config/IPropertyMasterAdapter.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace Cryville.Crtr.Config {
|
||||
public interface IPropertyMasterAdapter {
|
||||
string DefaultCategory { get; }
|
||||
IEnumerable<IPropertyAdapter> GetProperties();
|
||||
}
|
||||
public class DefaultPropertyMasterAdapter : IPropertyMasterAdapter {
|
||||
readonly object _target;
|
||||
|
||||
public DefaultPropertyMasterAdapter(object target) {
|
||||
if (target == null) throw new ArgumentNullException("target");
|
||||
_target = target;
|
||||
}
|
||||
|
||||
public string DefaultCategory { get { return "miscellaneous"; } }
|
||||
|
||||
public IEnumerable<IPropertyAdapter> GetProperties() {
|
||||
return _target.GetType().GetProperties().Where(p => {
|
||||
var attrs = p.GetCustomAttributes(typeof(BrowsableAttribute), true);
|
||||
if (attrs.Length == 0) return true;
|
||||
else return ((BrowsableAttribute)attrs.Single()).Browsable;
|
||||
}).Select(p => new DefaultPropertyAdapter(_target, p));
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/Config/IPropertyMasterAdapter.cs.meta
Normal file
11
Assets/Cryville/Crtr/Config/IPropertyMasterAdapter.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e0b160d43716cf4d8ba20b5a7eafd13
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -30,6 +30,7 @@ namespace Cryville.Crtr.Config {
|
||||
public InputProxy proxy;
|
||||
readonly Dictionary<Identifier, InputConfigPanelEntry> _entries = new Dictionary<Identifier, InputConfigPanelEntry>();
|
||||
|
||||
int _applicableEntries;
|
||||
Identifier _sel;
|
||||
int _targetDim;
|
||||
PhysicalDimension? _targetPDim;
|
||||
@@ -45,6 +46,7 @@ namespace Cryville.Crtr.Config {
|
||||
CallHelper.Purge(m_deviceList);
|
||||
_consumer.EnumerateEvents(ev => { });
|
||||
_recvsrcs.Clear();
|
||||
_applicableEntries = 1;
|
||||
AddSourceItem(null);
|
||||
}
|
||||
|
||||
@@ -143,7 +145,7 @@ namespace Cryville.Crtr.Config {
|
||||
}
|
||||
else flag = true;
|
||||
btn.interactable = flag;
|
||||
obj.transform.SetSiblingIndex(flag ? 1 : m_deviceList.childCount - 1);
|
||||
obj.transform.SetSiblingIndex(flag ? _applicableEntries++ : m_deviceList.childCount - 1);
|
||||
}
|
||||
else {
|
||||
obj.transform.SetSiblingIndex(0);
|
||||
|
@@ -1,14 +1,8 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
namespace Cryville.Crtr.Config {
|
||||
public class PVPBool : PropertyValuePanel, IPointerClickHandler {
|
||||
bool _value;
|
||||
public override object Value {
|
||||
get { return _value; }
|
||||
set { _value = (bool)value; }
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
RectTransform m_on;
|
||||
[SerializeField]
|
||||
@@ -16,21 +10,22 @@ namespace Cryville.Crtr.Browsing {
|
||||
[SerializeField]
|
||||
RectTransform m_handle;
|
||||
|
||||
protected override void OnValueUpdated() { }
|
||||
|
||||
public void Toggle() {
|
||||
_value = !_value;
|
||||
Callback(Value);
|
||||
RawValue = !(bool)RawValue;
|
||||
}
|
||||
|
||||
const float SPEED = 8;
|
||||
float _ratio;
|
||||
#pragma warning disable IDE0051
|
||||
void Update() {
|
||||
if (_value && _ratio != 1) {
|
||||
if ((bool)RawValue && _ratio != 1) {
|
||||
_ratio += SPEED * Time.deltaTime;
|
||||
if (_ratio > 1) _ratio = 1;
|
||||
UpdateGraphics();
|
||||
}
|
||||
else if (!_value && _ratio != 0) {
|
||||
else if (!(bool)RawValue && _ratio != 0) {
|
||||
_ratio -= SPEED * Time.deltaTime;
|
||||
if (_ratio < 0) _ratio = 0;
|
||||
UpdateGraphics();
|
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b281561aca5d19f43ba8af035de8ec98
|
||||
guid: 362a7cfafb57b9f46bbca9ed88d18c53
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
27
Assets/Cryville/Crtr/Config/PVPNumber.cs
Normal file
27
Assets/Cryville/Crtr/Config/PVPNumber.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
|
||||
namespace Cryville.Crtr.Config {
|
||||
public class PVPNumber : PVPNumberBase {
|
||||
protected override void OnValueUpdated() {
|
||||
base.OnValueUpdated();
|
||||
if (Range != null && Range.Length == 2) {
|
||||
var min = (double)Range[0];
|
||||
var max = (double)Range[1];
|
||||
var value = Convert.ToDouble(RawValue);
|
||||
if (value < min) {
|
||||
value = min;
|
||||
RawValue = value;
|
||||
}
|
||||
else if (value > max) {
|
||||
value = max;
|
||||
RawValue = value;
|
||||
}
|
||||
SetRatio((float)((value - min) / (max - min)));
|
||||
}
|
||||
}
|
||||
protected override double GetValue(double ratio, float deltaTime, double min, double max) {
|
||||
// if (LogarithmicMode) throw new NotImplementedException();
|
||||
return (1 - ratio) * min + ratio * max;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1eb74ffd69f934d4a8eca80aa3077b6c
|
||||
guid: 5b5d86b95e0bf894b86c63127d5ac06c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@@ -1,52 +1,19 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
public class PVPNumber : PropertyValuePanel {
|
||||
double m_value;
|
||||
public override object Value {
|
||||
get {
|
||||
float s_value = GetDisplayValue();
|
||||
return IntegerMode ? (int)s_value : (object)s_value;
|
||||
}
|
||||
set {
|
||||
if (value is double) m_value = (double)value;
|
||||
else m_value = IntegerMode ? (int)value : (double)(float)value;
|
||||
float s_value = GetDisplayValue();
|
||||
m_text.text = s_value.ToString();
|
||||
if (Range != null && MaxStep == 0) {
|
||||
SetRatio((float)(m_value - Range.Value.x) / (Range.Value.y - Range.Value.x));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float GetDisplayValue() {
|
||||
double s_value = m_value;
|
||||
if (Precision > 0)
|
||||
s_value = Math.Round(s_value / Precision) * Precision;
|
||||
if (IntegerMode)
|
||||
s_value = Math.Round(s_value);
|
||||
return (float)s_value;
|
||||
}
|
||||
|
||||
public bool IntegerMode { get; set; }
|
||||
public bool LogarithmicMode { get; set; }
|
||||
public float MaxStep { get; set; }
|
||||
public double Precision { get; set; }
|
||||
public Vector2? Range { get; set; }
|
||||
|
||||
namespace Cryville.Crtr.Config {
|
||||
public abstract class PVPNumberBase : PropertyValuePanel {
|
||||
[SerializeField]
|
||||
EventTrigger m_ctn;
|
||||
[SerializeField]
|
||||
RectTransform m_handleArea;
|
||||
[SerializeField]
|
||||
RectTransform m_handle;
|
||||
Image m_handle;
|
||||
[SerializeField]
|
||||
Text m_text;
|
||||
#pragma warning disable IDE0051
|
||||
void Start() {
|
||||
protected void Start() {
|
||||
var ev = new EventTrigger.Entry { eventID = EventTriggerType.InitializePotentialDrag };
|
||||
ev.callback.AddListener(e => OnInitializePotentialDrag((PointerEventData)e));
|
||||
m_ctn.triggers.Add(ev);
|
||||
@@ -59,22 +26,28 @@ namespace Cryville.Crtr.Browsing {
|
||||
ev = new EventTrigger.Entry { eventID = EventTriggerType.PointerClick };
|
||||
ev.callback.AddListener(e => OnPointerClick((PointerEventData)e));
|
||||
m_ctn.triggers.Add(ev);
|
||||
|
||||
if (MaxStep != 0) SetRatio(0.5f);
|
||||
OnIdle();
|
||||
}
|
||||
|
||||
protected override void OnValueUpdated() {
|
||||
m_text.text = MappedValue.ToString();
|
||||
}
|
||||
|
||||
protected virtual void OnIdle() { }
|
||||
|
||||
void Update() {
|
||||
if (use && MaxStep != 0) {
|
||||
if (use) {
|
||||
SetRatio(GetRatioFromPos(pp));
|
||||
SetValueFromPos(pp);
|
||||
}
|
||||
}
|
||||
|
||||
void OnRectTransformDimensionsChange() {
|
||||
m_handleArea.sizeDelta = new Vector2(m_handle.rect.height - m_handle.rect.width, 0);
|
||||
m_handleArea.sizeDelta = new Vector2(m_handle.rectTransform.rect.height - m_handle.rectTransform.rect.width, 0);
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
Camera cam;
|
||||
Vector2 pp;
|
||||
bool use, nouse;
|
||||
public void OnInitializePotentialDrag(PointerEventData eventData) {
|
||||
@@ -84,6 +57,7 @@ namespace Cryville.Crtr.Browsing {
|
||||
|
||||
public void OnDrag(PointerEventData eventData) {
|
||||
if (nouse) return;
|
||||
cam = eventData.pressEventCamera;
|
||||
if (!use) {
|
||||
var delta = eventData.position - pp;
|
||||
float dx = Mathf.Abs(delta.x), dy = Mathf.Abs(delta.y);
|
||||
@@ -92,7 +66,6 @@ namespace Cryville.Crtr.Browsing {
|
||||
}
|
||||
if (use) {
|
||||
pp = eventData.position;
|
||||
if (MaxStep == 0) SetValueFromPos(eventData.position);
|
||||
eventData.Use();
|
||||
}
|
||||
}
|
||||
@@ -100,8 +73,7 @@ namespace Cryville.Crtr.Browsing {
|
||||
public void OnEndDrag(PointerEventData eventData) {
|
||||
if (!nouse) {
|
||||
SetValueFromPos(eventData.position);
|
||||
Callback(Value);
|
||||
if (MaxStep != 0) SetRatio(0.5f);
|
||||
OnIdle();
|
||||
eventData.Use();
|
||||
use = false;
|
||||
}
|
||||
@@ -110,13 +82,12 @@ namespace Cryville.Crtr.Browsing {
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData) {
|
||||
SetValueFromPos(eventData.position);
|
||||
Callback(Value);
|
||||
eventData.Use();
|
||||
}
|
||||
|
||||
float GetRatioFromPos(Vector2 pos) {
|
||||
Vector2 lp;
|
||||
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_handleArea, pos, null, out lp)) {
|
||||
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_handleArea, pos, cam, out lp)) {
|
||||
lp -= m_handleArea.rect.position;
|
||||
return Mathf.Clamp01(lp.x / m_handleArea.rect.width);
|
||||
}
|
||||
@@ -124,27 +95,24 @@ namespace Cryville.Crtr.Browsing {
|
||||
}
|
||||
|
||||
void SetValueFromPos(Vector2 pos) {
|
||||
double min = double.NegativeInfinity, max = double.PositiveInfinity;
|
||||
if (Range != null && Range.Length == 2) {
|
||||
min = (double)Range[0];
|
||||
max = (double)Range[1];
|
||||
}
|
||||
double ratio = GetRatioFromPos(pos);
|
||||
double result;
|
||||
if (MaxStep == 0) {
|
||||
if (LogarithmicMode) throw new NotImplementedException();
|
||||
else result = (1 - ratio) * Range.Value.x + ratio * Range.Value.y;
|
||||
}
|
||||
else {
|
||||
double delta = (ratio > 0.5 ? 1 : -1) * Math.Pow((ratio - 0.5f) * 2, 2) * MaxStep * Time.deltaTime;
|
||||
if (LogarithmicMode) result = Math.Pow(Math.E, Math.Log(m_value) + delta);
|
||||
else result = m_value + delta;
|
||||
}
|
||||
if (Range != null) {
|
||||
if (result < Range.Value.x) result = Range.Value.x;
|
||||
else if (result > Range.Value.y) result = Range.Value.y;
|
||||
}
|
||||
Value = result;
|
||||
double result = GetValue(ratio, Time.deltaTime, min, max);
|
||||
if (result < min) result = min;
|
||||
else if (result > max) result = max;
|
||||
RawValue = result;
|
||||
}
|
||||
|
||||
void SetRatio(float ratio) {
|
||||
m_handle.anchorMin = new Vector2(ratio, m_handle.anchorMin.y);
|
||||
m_handle.anchorMax = new Vector2(ratio, m_handle.anchorMax.y);
|
||||
protected abstract double GetValue(double ratio, float deltaTime, double min, double max);
|
||||
|
||||
protected void SetRatio(float ratio) {
|
||||
m_handle.rectTransform.anchorMin = new Vector2(ratio, m_handle.rectTransform.anchorMin.y);
|
||||
m_handle.rectTransform.anchorMax = new Vector2(ratio, m_handle.rectTransform.anchorMax.y);
|
||||
m_handle.rectTransform.anchoredPosition = Vector2.zero;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/Config/PVPNumberBase.cs.meta
Normal file
11
Assets/Cryville/Crtr/Config/PVPNumberBase.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32fb9b8479cd8294296453d1aa651ff4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
14
Assets/Cryville/Crtr/Config/PVPNumberStepped.cs
Normal file
14
Assets/Cryville/Crtr/Config/PVPNumberStepped.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace Cryville.Crtr.Config {
|
||||
public class PVPNumberStepped : PVPNumberBase {
|
||||
protected override void OnIdle() {
|
||||
SetRatio(0.5f);
|
||||
}
|
||||
protected override double GetValue(double ratio, float deltaTime, double min, double max) {
|
||||
double delta = (ratio > 0.5 ? 1 : -1) * Math.Pow((ratio - 0.5f) * 2, 2) * deltaTime;
|
||||
// if (LogarithmicMode) return Math.Pow(Math.E, Math.Log(m_value) + delta);
|
||||
return Convert.ToDouble(RawValue) + delta;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/Config/PVPNumberStepped.cs.meta
Normal file
11
Assets/Cryville/Crtr/Config/PVPNumberStepped.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f754d98e38098654a878fc9121db536d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,17 +1,8 @@
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
namespace Cryville.Crtr.Config {
|
||||
public class PVPString : PropertyValuePanel {
|
||||
string m_value;
|
||||
public override object Value {
|
||||
get {
|
||||
return m_value;
|
||||
}
|
||||
set {
|
||||
m_value = (string)value;
|
||||
_inputField.text = m_value;
|
||||
}
|
||||
}
|
||||
protected override void OnValueUpdated() { _inputField.text = (string)MappedValue; }
|
||||
|
||||
InputField _inputField;
|
||||
|
||||
@@ -21,8 +12,7 @@ namespace Cryville.Crtr.Browsing {
|
||||
}
|
||||
|
||||
void OnValueChanged(string value) {
|
||||
m_value = value;
|
||||
Callback(Value);
|
||||
RawValue = value;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aadf11739189bc94e9cb4f702eb7ccd3
|
||||
guid: 1b9a6e3b503784e4aa78215e9b004a8f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@@ -1,9 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
namespace Cryville.Crtr.Config {
|
||||
public class PropertyCategoryPanel : MonoBehaviour {
|
||||
[SerializeField]
|
||||
private GameObject m_propertyPrefab;
|
||||
@@ -29,11 +28,11 @@ namespace Cryville.Crtr.Browsing {
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
public void Load(string name, IEnumerable<PropertyInfo> props, object target) {
|
||||
public void Load(string name, IEnumerable<IPropertyAdapter> props) {
|
||||
Name = name.ToUpper();
|
||||
foreach (var prop in props) {
|
||||
var obj = GameObject.Instantiate<GameObject>(m_propertyPrefab, transform, false);
|
||||
obj.GetComponent<PropertyPanel>().Load(prop, target);
|
||||
var obj = Instantiate(m_propertyPrefab, transform, false);
|
||||
obj.GetComponent<PropertyPanel>().Load(prop);
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a13b7ea14b96e54ea8a7e6ba1275281
|
||||
timeCreated: 1638435211
|
||||
licenseType: Free
|
||||
guid: 71da54f24b65d2f41a00c5a4bd0ff1bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
51
Assets/Cryville/Crtr/Config/PropertyMasterPanel.cs
Normal file
51
Assets/Cryville/Crtr/Config/PropertyMasterPanel.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr.Config {
|
||||
public class PropertyMasterPanel : MonoBehaviour {
|
||||
[SerializeField]
|
||||
GameObject m_categoryPrefab;
|
||||
|
||||
[SerializeField]
|
||||
Transform m_container;
|
||||
|
||||
bool _invalidated = true;
|
||||
|
||||
public void Invalidate() {
|
||||
_invalidated = true;
|
||||
}
|
||||
|
||||
private IPropertyMasterAdapter m_adapter;
|
||||
public IPropertyMasterAdapter Adapter {
|
||||
get { return m_adapter; }
|
||||
set {
|
||||
m_adapter = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void Update() {
|
||||
if (!_invalidated) return;
|
||||
LoadProperties();
|
||||
foreach (Transform c in m_container) Destroy(c.gameObject);
|
||||
foreach (var c in _categories) {
|
||||
var obj = Instantiate(m_categoryPrefab, m_container, false);
|
||||
obj.GetComponent<PropertyCategoryPanel>().Load(c.Key, c.Value);
|
||||
}
|
||||
}
|
||||
|
||||
readonly Dictionary<string, List<IPropertyAdapter>> _categories = new Dictionary<string, List<IPropertyAdapter>>();
|
||||
public void LoadProperties() {
|
||||
_categories.Clear();
|
||||
_invalidated = false;
|
||||
if (Adapter == null) return;
|
||||
foreach (var p in Adapter.GetProperties()) {
|
||||
string category = p.Category;
|
||||
if (category == null) category = Adapter.DefaultCategory;
|
||||
if (!_categories.ContainsKey(category))
|
||||
_categories.Add(category, new List<IPropertyAdapter>());
|
||||
_categories[category].Add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/Config/PropertyMasterPanel.cs.meta
Normal file
11
Assets/Cryville/Crtr/Config/PropertyMasterPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e6129746af547242bfa4e7404185936
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
40
Assets/Cryville/Crtr/Config/PropertyPanel.cs
Normal file
40
Assets/Cryville/Crtr/Config/PropertyPanel.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Crtr.Config {
|
||||
public class PropertyPanel : MonoBehaviour {
|
||||
[SerializeField]
|
||||
GameObject m_bool;
|
||||
[SerializeField]
|
||||
GameObject m_number;
|
||||
[SerializeField]
|
||||
GameObject m_numberStepped;
|
||||
[SerializeField]
|
||||
GameObject m_string;
|
||||
|
||||
Text _key;
|
||||
Transform _valueContainer;
|
||||
PropertyValuePanel _value;
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
void Awake() {
|
||||
_key = transform.Find("Key").GetComponent<Text>();
|
||||
_valueContainer = transform.Find("Value");
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
public void Load(IPropertyAdapter prop) {
|
||||
_key.text = prop.Name;
|
||||
|
||||
GameObject vp;
|
||||
switch (prop.Type) {
|
||||
case PropertyType.Number: vp = m_number; break;
|
||||
case PropertyType.NumberStepped: vp = m_numberStepped; break;
|
||||
case PropertyType.Boolean: vp = m_bool; break;
|
||||
case PropertyType.String: vp = m_string; break;
|
||||
default: return;
|
||||
}
|
||||
_value = Instantiate(vp, _valueContainer, false).GetComponent<PropertyValuePanel>();
|
||||
_value.Init(prop);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,8 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcca29fea992ac24698a213f0e2baedc
|
||||
timeCreated: 1638435590
|
||||
licenseType: Free
|
||||
guid: e47c05cfd69aa3f4d9886293e66877e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
40
Assets/Cryville/Crtr/Config/PropertyValuePanel.cs
Normal file
40
Assets/Cryville/Crtr/Config/PropertyValuePanel.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr.Config {
|
||||
public abstract class PropertyValuePanel : MonoBehaviour {
|
||||
IPropertyAdapter _property;
|
||||
public void Init(IPropertyAdapter property) {
|
||||
_property = property;
|
||||
_property.ValueChanged += GetValue;
|
||||
GetValue();
|
||||
}
|
||||
protected object[] Range { get { return _property.Range; } }
|
||||
public object MappedValue { get; private set; }
|
||||
private object m_rawValue;
|
||||
public object RawValue {
|
||||
get { return m_rawValue; }
|
||||
set {
|
||||
m_rawValue = value;
|
||||
SetValue();
|
||||
}
|
||||
}
|
||||
protected abstract void OnValueUpdated();
|
||||
void GetValue() {
|
||||
if (_property.SetMapped) {
|
||||
MappedValue = _property.GetValue();
|
||||
m_rawValue = _property.MapValueInverse(MappedValue);
|
||||
}
|
||||
else {
|
||||
m_rawValue = _property.GetValue();
|
||||
MappedValue = _property.MapValue(m_rawValue);
|
||||
}
|
||||
OnValueUpdated();
|
||||
}
|
||||
void SetValue() {
|
||||
var outRaw = RawValue;
|
||||
MappedValue = _property.MapValue(outRaw);
|
||||
_property.SetValue(_property.SetMapped ? MappedValue : outRaw);
|
||||
OnValueUpdated();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fca3da10a8b0677439885f6732ac3b6e
|
||||
guid: c71cc11a0b1429c4fac91296bf8c5a63
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@@ -14,13 +14,13 @@ namespace Cryville.Crtr.Config {
|
||||
|
||||
[Category("gameplay")]
|
||||
[JsonProperty("sound_offset")]
|
||||
[Step(0.04f)]
|
||||
[Step(0.04)]
|
||||
[Precision(1e-3)]
|
||||
public float SoundOffset { get; set; }
|
||||
|
||||
[Category("deprecated")][Obsolete]
|
||||
[JsonProperty("scroll_velocity")][DefaultValue(1)]
|
||||
[LogarithmicScale][Step(0.5f)][Precision(1e-1)]
|
||||
[LogarithmicScale][Step(0.5)][Precision(1e-1)]
|
||||
public float ScrollVelocity { get; set; }
|
||||
|
||||
public Generic() {
|
||||
@@ -29,6 +29,8 @@ namespace Cryville.Crtr.Config {
|
||||
ScrollVelocity = 1;
|
||||
}
|
||||
}
|
||||
public Dictionary<string, object> configs
|
||||
= new Dictionary<string, object>();
|
||||
public Dictionary<string, InputEntry> inputs
|
||||
= new Dictionary<string, InputEntry>();
|
||||
public class InputEntry {
|
||||
|
99
Assets/Cryville/Crtr/Config/RulesetConfigPropertyAdapter.cs
Normal file
99
Assets/Cryville/Crtr/Config/RulesetConfigPropertyAdapter.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Pdt;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Crtr.Config {
|
||||
internal class RulesetConfigPropertyMasterAdapter : IPropertyMasterAdapter {
|
||||
readonly List<RulesetConfigPropertyAdapter> _props = new List<RulesetConfigPropertyAdapter>();
|
||||
readonly RulesetConfigStore _store;
|
||||
|
||||
public RulesetConfigPropertyMasterAdapter(Dictionary<Identifier, ConfigDefinition> defs, Dictionary<string, object> values) {
|
||||
_store = new RulesetConfigStore(defs, values);
|
||||
PdtEvaluator.Instance.ContextRulesetConfig = _store;
|
||||
if (defs == null) return;
|
||||
foreach (var def in defs) {
|
||||
_props.Add(new RulesetConfigPropertyAdapter(def.Key, def.Value, this));
|
||||
}
|
||||
}
|
||||
|
||||
public string DefaultCategory { get { return "miscellaneous"; } }
|
||||
|
||||
public IEnumerable<IPropertyAdapter> GetProperties() { return _props; }
|
||||
|
||||
public object GetValue(string key) {
|
||||
return _store[key];
|
||||
}
|
||||
|
||||
public void SetValue(string key, object value) {
|
||||
_store[key] = value;
|
||||
foreach (var prop in _props) {
|
||||
prop.OnValueChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class RulesetConfigPropertyAdapter : IPropertyAdapter {
|
||||
readonly RulesetConfigPropertyMasterAdapter _master;
|
||||
readonly ConfigDefinition _def;
|
||||
|
||||
public RulesetConfigPropertyAdapter(Identifier key, ConfigDefinition def, RulesetConfigPropertyMasterAdapter master) {
|
||||
_master = master;
|
||||
_def = def;
|
||||
Name = (string)key.Name;
|
||||
switch (_def.type) {
|
||||
case ConfigType.number: Type = PropertyType.Number; break;
|
||||
case ConfigType.number_stepped: Type = PropertyType.NumberStepped; break;
|
||||
default: Type = PropertyType.Unknown; break;
|
||||
}
|
||||
_rangeOp = new PropOp.Clip(v => {
|
||||
m_range[0] = (double)v.Behind;
|
||||
m_range[1] = (double)v.Ahead;
|
||||
});
|
||||
}
|
||||
|
||||
public string Category { get { return _def.category; } }
|
||||
|
||||
public string Name { get; private set; }
|
||||
|
||||
public PropertyType Type { get; private set; }
|
||||
|
||||
readonly PdtOperator _rangeOp;
|
||||
readonly object[] m_range = new object[] { double.NegativeInfinity, double.PositiveInfinity };
|
||||
public object[] Range {
|
||||
get {
|
||||
if (_def.range != null)
|
||||
PdtEvaluator.Instance.Evaluate(_rangeOp, _def.range);
|
||||
return m_range;
|
||||
}
|
||||
}
|
||||
|
||||
public object GetValue() {
|
||||
return _master.GetValue(Name);
|
||||
}
|
||||
|
||||
public void SetValue(object value) {
|
||||
_master.SetValue(Name, value);
|
||||
}
|
||||
|
||||
public event Action ValueChanged;
|
||||
public void OnValueChanged() {
|
||||
var ev = ValueChanged;
|
||||
if (ev != null) ev();
|
||||
}
|
||||
|
||||
public bool SetMapped { get { return false; } }
|
||||
|
||||
readonly PropStores.Float _numst = new PropStores.Float();
|
||||
public object MapValue(object value) {
|
||||
_numst.Value = (float)(double)value;
|
||||
if (_def.value == null) return _numst.Value;
|
||||
PdtEvaluator.Instance.ContextSelfValue = _numst.Source;
|
||||
PdtEvaluator.Instance.Evaluate(_numst.Target, _def.value);
|
||||
PdtEvaluator.Instance.ContextSelfValue = null;
|
||||
return _numst.Value;
|
||||
}
|
||||
|
||||
public object MapValueInverse(object value) { throw new NotSupportedException(); }
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8b12ed5f582bb24fbc508f74f8ef79e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
43
Assets/Cryville/Crtr/Config/RulesetConfigStore.cs
Normal file
43
Assets/Cryville/Crtr/Config/RulesetConfigStore.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Collections.Specialized;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Crtr.Config {
|
||||
public class RulesetConfigStore {
|
||||
readonly IntKeyedDictionary<PropSrc> _srcs = new IntKeyedDictionary<PropSrc>();
|
||||
readonly Dictionary<string, int> _revMap = new Dictionary<string, int>();
|
||||
readonly Dictionary<string, object> _values;
|
||||
public RulesetConfigStore(Dictionary<Identifier, ConfigDefinition> defs, Dictionary<string, object> values) {
|
||||
_values = values;
|
||||
if (defs == null) return;
|
||||
foreach (var def in defs) {
|
||||
var key = def.Key.Key;
|
||||
var name = (string)def.Key.Name;
|
||||
if (!_values.ContainsKey(name)) {
|
||||
double value = 0;
|
||||
PdtEvaluator.Instance.Evaluate(new PropOp.Float(v => value = v), def.Value.@default);
|
||||
_values.Add(name, value);
|
||||
}
|
||||
_revMap.Add(name, key);
|
||||
_srcs.Add(key, new PropSrc.Float(() => {
|
||||
float result = 0;
|
||||
PdtEvaluator.Instance.ContextSelfValue = new PropSrc.Float(() => Convert.ToSingle(_values[name]));
|
||||
PdtEvaluator.Instance.Evaluate(new PropOp.Float(v => result = v), def.Value.value);
|
||||
PdtEvaluator.Instance.ContextSelfValue = null;
|
||||
return result;
|
||||
}));
|
||||
}
|
||||
}
|
||||
public object this[string key] {
|
||||
get { return _values[key]; }
|
||||
set {
|
||||
_values[key] = value;
|
||||
_srcs[_revMap[key]].Invalidate();
|
||||
}
|
||||
}
|
||||
public bool TryGetMappedSource(int key, out PropSrc result) {
|
||||
return _srcs.TryGetValue(key, out result);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/Config/RulesetConfigStore.cs.meta
Normal file
11
Assets/Cryville/Crtr/Config/RulesetConfigStore.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d346b4bc0a3d4a44f90a924d01c0d2f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,4 +1,4 @@
|
||||
using Cryville.Common.Network;
|
||||
using Cryville.Common.Network.Http11;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
@@ -123,13 +123,13 @@ namespace Cryville.Crtr {
|
||||
try {
|
||||
switch (p[0]) {
|
||||
case "!http":
|
||||
var httpcl = new HttpClient(new Uri(p[1]));
|
||||
var httpcl = new Http11Client(new Uri(p[1]));
|
||||
httpcl.Connect();
|
||||
httpcl.Request("GET", new Uri(p[1])).MessageBody.ReadToEnd();
|
||||
httpcl.Close();
|
||||
break;
|
||||
case "!https":
|
||||
var httpscl = new HttpsClient(new Uri(p[1]));
|
||||
var httpscl = new Https11Client(new Uri(p[1]));
|
||||
httpscl.Connect();
|
||||
httpscl.Request("GET", new Uri(p[1])).MessageBody.ReadToEnd();
|
||||
httpscl.Close();
|
||||
|
89
Assets/Cryville/Crtr/Dialog.cs
Normal file
89
Assets/Cryville/Crtr/Dialog.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public class Dialog : MonoBehaviour {
|
||||
static Dialog _instance;
|
||||
[SerializeField] CanvasGroup m_group;
|
||||
[SerializeField] Text m_msgText;
|
||||
[SerializeField] Text m_button0Text;
|
||||
[SerializeField] Text m_button1Text;
|
||||
[SerializeField] GameObject m_button1;
|
||||
[SerializeField] AnimationCurve m_fadeCurve;
|
||||
float _fadeDuration;
|
||||
static readonly Queue<DialogEntry> _queue = new Queue<DialogEntry>();
|
||||
struct DialogEntry {
|
||||
public Action<int> callback;
|
||||
public string message;
|
||||
public string action0;
|
||||
public string action1;
|
||||
}
|
||||
void Awake() {
|
||||
_instance = this;
|
||||
_fadeDuration = m_fadeCurve[m_fadeCurve.length - 1].time;
|
||||
}
|
||||
float _timer;
|
||||
DialogEntry? _cur;
|
||||
static bool _suppressed;
|
||||
void Update() {
|
||||
if (_cur == null) {
|
||||
if (_timer > 0) {
|
||||
_timer -= Time.deltaTime;
|
||||
if (_timer < 0) {
|
||||
_timer = 0;
|
||||
m_group.gameObject.SetActive(false);
|
||||
}
|
||||
m_group.alpha = m_fadeCurve.Evaluate(_timer);
|
||||
}
|
||||
if (_queue.Count > 0 && !_suppressed) {
|
||||
m_group.gameObject.SetActive(true);
|
||||
_cur = _queue.Dequeue();
|
||||
m_msgText.text = _cur.Value.message;
|
||||
m_button0Text.text = _cur.Value.action0;
|
||||
m_button1Text.text = _cur.Value.action1;
|
||||
m_button1.SetActive(_cur.Value.action1 != null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (_timer < _fadeDuration) {
|
||||
_timer += Time.deltaTime;
|
||||
if (_timer > _fadeDuration) _timer = _fadeDuration;
|
||||
m_group.alpha = m_fadeCurve.Evaluate(_timer);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void OnButton(int id) {
|
||||
if (_cur == null) return;
|
||||
var cb = _cur.Value.callback;
|
||||
if (cb != null) cb(id);
|
||||
_cur = null;
|
||||
}
|
||||
public static void Suppress() {
|
||||
_suppressed = true;
|
||||
if (_instance._cur != null) {
|
||||
_queue.Enqueue(_instance._cur.Value);
|
||||
_instance._cur = null;
|
||||
}
|
||||
}
|
||||
public static void Release() {
|
||||
_suppressed = false;
|
||||
}
|
||||
public static void Show(Action<int> callback, string message, string action0 = "OK", string action1 = null) {
|
||||
_queue.Enqueue(new DialogEntry { callback = callback, message = message, action0 = action0, action1 = action1 });
|
||||
}
|
||||
public static int ShowAndWait(string message, string action0 = "OK", string action1 = null) {
|
||||
using (var ev = new AutoResetEvent(false)) {
|
||||
int result = 0;
|
||||
_queue.Enqueue(new DialogEntry {
|
||||
callback = r => { result = r; ev.Set(); },
|
||||
message = message, action0 = action0, action1 = action1,
|
||||
});
|
||||
ev.WaitOne();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/Dialog.cs.meta
Normal file
11
Assets/Cryville/Crtr/Dialog.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f866af19f9d7e3147bd73fdae32f8525
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -60,16 +60,43 @@ namespace Cryville.Crtr {
|
||||
}, Callback);
|
||||
}
|
||||
|
||||
string _detail;
|
||||
double? _duration;
|
||||
public void SetPlaying(string detail, double? duration) {
|
||||
if (dc == null) return;
|
||||
_detail = detail;
|
||||
_duration = duration;
|
||||
long now = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
|
||||
am.UpdateActivity(new Activity {
|
||||
State = "Playing a chart",
|
||||
Details = _detail,
|
||||
Instance = true,
|
||||
Timestamps = {
|
||||
Start = now,
|
||||
End = _duration == null ? 0 : now + (long)_duration,
|
||||
},
|
||||
}, Callback);
|
||||
}
|
||||
|
||||
public void SetPaused() {
|
||||
if (dc == null) return;
|
||||
am.UpdateActivity(new Activity {
|
||||
State = "Playing a chart (Paused)",
|
||||
Details = _detail,
|
||||
Instance = true,
|
||||
}, Callback);
|
||||
}
|
||||
|
||||
public void SetResume(double timestamp) {
|
||||
if (dc == null) return;
|
||||
long now = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
|
||||
am.UpdateActivity(new Activity {
|
||||
State = "Playing a chart",
|
||||
Details = detail,
|
||||
Details = _detail,
|
||||
Instance = true,
|
||||
Timestamps = {
|
||||
Start = now,
|
||||
End = duration == null ? 0 : now + (long)duration,
|
||||
Start = now - (long)timestamp,
|
||||
End = _duration == null ? 0 : now + (long)_duration - (long)timestamp,
|
||||
},
|
||||
}, Callback);
|
||||
}
|
||||
|
@@ -17,34 +17,28 @@ namespace Cryville.Crtr {
|
||||
_skinContainer = new SkinContainer(this, _def.elements);
|
||||
RootTransform = new GameObject("effect:" + GetHashCode().ToString(CultureInfo.InvariantCulture)).transform;
|
||||
SkinContext = new SkinContext(RootTransform);
|
||||
ChartPlayer.etor.ContextCascadeInsertBlock();
|
||||
PdtEvaluator.Instance.ContextCascadeInsertBlock();
|
||||
_skinContainer.MatchStatic();
|
||||
ChartPlayer.etor.ContextCascadeDiscardBlock();
|
||||
PdtEvaluator.Instance.ContextCascadeDiscardBlock();
|
||||
_comps = RootTransform.GetComponentsInChildren<SkinComponent>();
|
||||
foreach (var i in _comps) i.Init();
|
||||
_indexSrc = new PropSrc.Float(() => Index);
|
||||
_durationOp = new PropOp.Float(v => _duration = v);
|
||||
}
|
||||
public void Rewind(double time, Transform target) {
|
||||
_startTime = time;
|
||||
foreach (var i in _comps) i.Rewind(time, target);
|
||||
}
|
||||
private float m_index;
|
||||
public float Index {
|
||||
get { return m_index; }
|
||||
set {
|
||||
if (m_index == value) return;
|
||||
m_index = value;
|
||||
_indexSrc.Invalidate();
|
||||
}
|
||||
}
|
||||
Transform _currentTarget;
|
||||
Identifier _currentStateName = Identifier.Empty;
|
||||
EffectState _currentState;
|
||||
ChartEvent _ctxev;
|
||||
ContainerState _ctxstate;
|
||||
internal static readonly int _VAR_EFFECT_INDEX = IdentifierManager.Shared.Request("effect_index");
|
||||
readonly PropSrc _indexSrc;
|
||||
readonly PropStores.Float _indexst = new PropStores.Float();
|
||||
public float Index {
|
||||
get { return _indexst.Value; }
|
||||
set { _indexst.Value = value; }
|
||||
}
|
||||
double _startTime;
|
||||
float _duration;
|
||||
readonly PropOp _durationOp;
|
||||
@@ -57,8 +51,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
public void OnEmit(double time, Transform target) {
|
||||
_currentTarget = target;
|
||||
_ctxev = ChartPlayer.etor.ContextEvent;
|
||||
_ctxstate = ChartPlayer.etor.ContextState;
|
||||
_ctxev = PdtEvaluator.Instance.ContextEvent;
|
||||
_ctxstate = PdtEvaluator.Instance.ContextState;
|
||||
_skinContainer.MatchDynamic(0, true);
|
||||
if (_currentStateName.Key == 0) {
|
||||
EnterState(_def.init, time, _currentTarget, true);
|
||||
@@ -73,11 +67,11 @@ namespace Cryville.Crtr {
|
||||
_currentState = _def.states[name];
|
||||
Rewind(time, target);
|
||||
RootTransform.gameObject.SetActive(true);
|
||||
ChartPlayer.etor.ContextCascadeInsert();
|
||||
ChartPlayer.etor.ContextCascadeUpdate(_VAR_EFFECT_INDEX, _indexSrc);
|
||||
ChartPlayer.etor.Evaluate(_durationOp, _currentState.duration);
|
||||
PdtEvaluator.Instance.ContextCascadeInsert();
|
||||
PdtEvaluator.Instance.ContextCascadeUpdate(_VAR_EFFECT_INDEX, _indexst.Source);
|
||||
PdtEvaluator.Instance.Evaluate(_durationOp, _currentState.duration);
|
||||
_skinContainer.MatchDynamic(1, emitting);
|
||||
ChartPlayer.etor.ContextCascadeDiscard();
|
||||
PdtEvaluator.Instance.ContextCascadeDiscard();
|
||||
}
|
||||
public bool OnStateDone() {
|
||||
if (_currentState.next.Key == 0) {
|
||||
@@ -87,11 +81,11 @@ namespace Cryville.Crtr {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
ChartPlayer.etor.ContextEvent = _ctxev;
|
||||
ChartPlayer.etor.ContextState = _ctxstate;
|
||||
PdtEvaluator.Instance.ContextEvent = _ctxev;
|
||||
PdtEvaluator.Instance.ContextState = _ctxstate;
|
||||
EnterState(_currentState.next, EndTime, _currentTarget, false);
|
||||
ChartPlayer.etor.ContextEvent = null;
|
||||
ChartPlayer.etor.ContextState = null;
|
||||
PdtEvaluator.Instance.ContextEvent = null;
|
||||
PdtEvaluator.Instance.ContextState = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -127,12 +127,12 @@ namespace Cryville.Crtr.Event {
|
||||
a_tail = RegisterAnchor(_a_tail, true);
|
||||
}
|
||||
public virtual void Init() {
|
||||
ChartPlayer.etor.ContextState = ps;
|
||||
ChartPlayer.etor.ContextEvent = Container;
|
||||
PdtEvaluator.Instance.ContextState = ps;
|
||||
PdtEvaluator.Instance.ContextEvent = Container;
|
||||
skinContainer.MatchStatic();
|
||||
MatchDynamic(ps, 0);
|
||||
ChartPlayer.etor.ContextEvent = null;
|
||||
ChartPlayer.etor.ContextState = null;
|
||||
PdtEvaluator.Instance.ContextEvent = null;
|
||||
PdtEvaluator.Instance.ContextState = null;
|
||||
foreach (Transform child in RootTransform) {
|
||||
if (child.CompareTag(TagRootTransform)) continue;
|
||||
_comps.AddRange(child.GetComponentsInChildren<SkinComponent>());
|
||||
@@ -199,11 +199,11 @@ namespace Cryville.Crtr.Event {
|
||||
protected static bool CanDoGraphicalUpdate(ContainerState s) { return s.CloneType >= 2 && s.CloneType < 16; }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void MatchDynamic(ContainerState s, int dl) {
|
||||
ChartPlayer.etor.ContextState = s;
|
||||
ChartPlayer.etor.ContextEvent = Container;
|
||||
PdtEvaluator.Instance.ContextState = s;
|
||||
PdtEvaluator.Instance.ContextEvent = Container;
|
||||
skinContainer.MatchDynamic(dl);
|
||||
ChartPlayer.etor.ContextEvent = null;
|
||||
ChartPlayer.etor.ContextState = null;
|
||||
PdtEvaluator.Instance.ContextEvent = null;
|
||||
PdtEvaluator.Instance.ContextState = null;
|
||||
}
|
||||
#endregion
|
||||
#region Anchor
|
||||
|
@@ -453,19 +453,16 @@ namespace Cryville.Crtr.Event {
|
||||
}
|
||||
}
|
||||
}
|
||||
static float _ttime;
|
||||
static Vector4 _trans;
|
||||
static readonly PropSrc _ttimesrc = new PropSrc.Float(() => _ttime);
|
||||
static readonly PropOp _transop = new PropOp.Vector4(v => _trans = v);
|
||||
static readonly PropStores.Float _ttimest = new PropStores.Float();
|
||||
static readonly PropStores.Vector4 _transst = new PropStores.Vector4();
|
||||
Vector4 GetTransition(float time, PdtExpression transition) {
|
||||
if (time >= 1) return Vector4.one;
|
||||
if (transition == null) return new Vector4(time, time, time, time);
|
||||
_ttime = time;
|
||||
_ttimesrc.Invalidate();
|
||||
ChartPlayer.etor.ContextSelfValue = _ttimesrc;
|
||||
ChartPlayer.etor.Evaluate(_transop, transition);
|
||||
ChartPlayer.etor.ContextSelfValue = null;
|
||||
return _trans;
|
||||
_ttimest.Value = time;
|
||||
PdtEvaluator.Instance.ContextSelfValue = _ttimest.Source;
|
||||
PdtEvaluator.Instance.Evaluate(_transst.Target, transition);
|
||||
PdtEvaluator.Instance.ContextSelfValue = null;
|
||||
return _transst.Value;
|
||||
}
|
||||
|
||||
public void BroadcastPreInit() {
|
||||
|
@@ -6,7 +6,9 @@ using Cryville.Common.Unity;
|
||||
using Cryville.Common.Unity.UI;
|
||||
using Cryville.Input;
|
||||
using Cryville.Input.Unity;
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
using Cryville.Input.Unity.Android;
|
||||
#endif
|
||||
using FFmpeg.AutoGen;
|
||||
using Ionic.Zip;
|
||||
using Newtonsoft.Json;
|
||||
@@ -18,18 +20,8 @@ using unity = UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public static class Game {
|
||||
public static string GameDataPath {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public static readonly string FileProtocolPrefix
|
||||
#if UNITY_STANDALONE_WIN
|
||||
= "file:///";
|
||||
#elif UNITY_ANDROID
|
||||
= "file://";
|
||||
#else
|
||||
#error No file protocol prefix is defined.
|
||||
#endif
|
||||
public static string GameDataPath { get; private set; }
|
||||
public static string UnityDataPath { get; private set; }
|
||||
public static IAudioDeviceManager AudioManager;
|
||||
public static AudioClient AudioClient;
|
||||
public static SimpleSequencerSource AudioSequencer;
|
||||
@@ -60,10 +52,11 @@ namespace Cryville.Crtr {
|
||||
if (_bcflag) Logger.Log("main", 2, "Game", "Reset all settings");
|
||||
|
||||
GameDataPath = Settings.Default.GameDataPath;
|
||||
UnityDataPath = Application.dataPath;
|
||||
|
||||
unity::Input.simulateMouseWithTouches = false;
|
||||
var emptyObjectArray = new object[0];
|
||||
#if UNITY_ANDROID
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
InputManager.HandlerRegistries.Add(typeof(AndroidAccelerometerHandler), emptyObjectArray);
|
||||
InputManager.HandlerRegistries.Add(typeof(AndroidAccelerometerUncalibratedHandler), emptyObjectArray);
|
||||
InputManager.HandlerRegistries.Add(typeof(AndroidGameRotationVectorHandler), emptyObjectArray);
|
||||
@@ -129,19 +122,10 @@ namespace Cryville.Crtr {
|
||||
Settings.Default.Save();
|
||||
|
||||
Logger.Log("main", 1, "UI", "Initializing font manager");
|
||||
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
|
||||
var fontMatcher = new FallbackListFontMatcher(new FontManagerWindows());
|
||||
fontMatcher.LoadDefaultWindowsFallbackList();
|
||||
TMPAutoFont.FontMatcher = fontMatcher;
|
||||
TMPAutoFont.DefaultShader = Resources.Load<Shader>("TextMesh Pro/Shaders/TMP_SDF SSD");
|
||||
#elif UNITY_ANDROID
|
||||
var fontMatcher = new FallbackListFontMatcher(new FontManagerAndroid());
|
||||
fontMatcher.LoadDefaultAndroidFallbackList();
|
||||
TMPAutoFont.FontMatcher = fontMatcher;
|
||||
TMPAutoFont.DefaultShader = Resources.Load<Shader>("TextMesh Pro/Shaders/TMP_SDF-Mobile SSD");
|
||||
#else
|
||||
#error No font manager initialization logic.
|
||||
#endif
|
||||
TMPAutoFont.FontMatcher = new FallbackListFontMatcher(PlatformConfig.FontManager) {
|
||||
MapScriptToTypefaces = PlatformConfig.ScriptFontMap
|
||||
};
|
||||
TMPAutoFont.DefaultShader = Resources.Load<Shader>(PlatformConfig.TextShader);
|
||||
|
||||
Logger.Log("main", 1, "Game", "Initialized");
|
||||
}
|
||||
@@ -181,5 +165,14 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
Logger.Log("main", l, "Internal", "{0}\n{1}", condition, stackTrace);
|
||||
}
|
||||
|
||||
public static void SuspendBackgroundTasks() {
|
||||
NetworkTaskWorker.SuspendBackgroundTasks();
|
||||
Dialog.Suppress();
|
||||
}
|
||||
public static void ResumeBackgroundTasks() {
|
||||
Dialog.Release();
|
||||
NetworkTaskWorker.ResumeBackgroundTasks();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ namespace Cryville.Crtr {
|
||||
_vecsrcs[i] = vecsrc;
|
||||
_vecops[i] = new InputVectorOp(vecsrc);
|
||||
}
|
||||
_etor = judge != null ? judge._etor : ChartPlayer.etor;
|
||||
_etor = judge != null ? judge._etor : PdtEvaluator.Instance;
|
||||
_ruleset = ruleset;
|
||||
_judge = judge;
|
||||
_screenSize = new InputVector(screenSize.x, screenSize.y);
|
||||
@@ -197,8 +197,8 @@ namespace Cryville.Crtr {
|
||||
const int MAX_DIMENSION = 4;
|
||||
readonly InputVectorSrc[] _vecsrcs = new InputVectorSrc[MAX_DEPTH + 1];
|
||||
readonly InputVectorOp[] _vecops = new InputVectorOp[MAX_DEPTH + 1];
|
||||
unsafe class InputVectorSrc : PropSrc.FixedBuffer {
|
||||
public InputVectorSrc() : base(PdtInternalType.Vector, MAX_DIMENSION * sizeof(float) + sizeof(int)) {
|
||||
unsafe class InputVectorSrc : PropSrc.FixedBuffer<RVector4> {
|
||||
public InputVectorSrc() : base(PdtInternalType.Vector, MAX_DIMENSION * sizeof(float) + sizeof(int), null) {
|
||||
fixed (byte* ptr = buf) {
|
||||
*(int*)(ptr + MAX_DIMENSION * sizeof(float)) = PdtInternalType.Number;
|
||||
}
|
||||
@@ -262,10 +262,9 @@ namespace Cryville.Crtr {
|
||||
frame.Vector = vec;
|
||||
}
|
||||
else frame = rc.InverseTransform(frame);
|
||||
bool locked = false;
|
||||
Monitor.Enter(_etor);
|
||||
try {
|
||||
Profiler.BeginSample("InputProxy.OnInput");
|
||||
Monitor.Enter(_etor, ref locked);
|
||||
InputProxyEntry proxy;
|
||||
if (_sproxies.TryGetValue(id.Source, out proxy)) {
|
||||
float ft, tt = (float)GetSyncedTime(frame.Time, id.Source.Handler);
|
||||
@@ -289,8 +288,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (locked) Monitor.Exit(_etor);
|
||||
Profiler.EndSample();
|
||||
Monitor.Exit(_etor);
|
||||
}
|
||||
}
|
||||
static readonly int _var_fv = IdentifierManager.Shared.Request("input_vec_from");
|
||||
@@ -345,7 +344,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
else {
|
||||
var itv = ((InputVectorSrc)tv).Get();
|
||||
if (!hfv || _vecs[pid] != itv) _vecs[pid] = itv;
|
||||
if (!hfv || ifv != itv) _vecs[pid] = itv;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -367,19 +366,19 @@ namespace Cryville.Crtr {
|
||||
_vect[vec.Key.Source] = tt;
|
||||
}
|
||||
|
||||
Cleanup(proxy.Target, (float)GetSyncedTime(time, handler));
|
||||
Cleanup(proxy.Target, tt, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
void Cleanup(Identifier target, float tt, int depth = 0) {
|
||||
void Cleanup(Identifier target, float tt, bool batching = false, int depth = 0) {
|
||||
if (depth >= MAX_DEPTH) throw new InputProxyException("Input propagation limit reached\nThe ruleset has invalid input definitions");
|
||||
var def = _ruleset.inputs[target];
|
||||
if (def.pass != null) {
|
||||
foreach (var p in def.pass) {
|
||||
Cleanup(p.Key, tt, depth + 1);
|
||||
Cleanup(p.Key, tt, batching, depth + 1);
|
||||
}
|
||||
}
|
||||
else if (_targetActiveCount[target] == 0) {
|
||||
else if (batching || _targetActiveCount[target] == 0) {
|
||||
_judge.Cleanup(target, tt);
|
||||
}
|
||||
}
|
||||
|
@@ -62,12 +62,6 @@ namespace Cryville.Crtr {
|
||||
_etor.ContextJudge = this;
|
||||
_rs = rs;
|
||||
_areaFuncs = rs.areas;
|
||||
_numsrc1 = new PropSrc.Float(() => _numbuf1);
|
||||
_numsrc2 = new PropSrc.Float(() => _numbuf2);
|
||||
_numsrc3 = new PropSrc.Float(() => _numbuf3);
|
||||
_numsrc4 = new PropSrc.Float(() => _numbuf4);
|
||||
_jnumsrc = new PropSrc.Float(() => _jnumbuf);
|
||||
_jvecsrc = new PropSrc.Vector4(() => _jvecbuf);
|
||||
_identop = new PropOp.Identifier(v => _identbuf = new Identifier(v));
|
||||
_clipop = new PropOp.Clip(v => _clipbuf = v);
|
||||
_rs.judges.TryGetValue(new Identifier(_var_pause), out _judgePause);
|
||||
@@ -168,17 +162,23 @@ namespace Cryville.Crtr {
|
||||
|
||||
public void Clear() { Array.Clear(_sorts, 0, MAX_SORTS); }
|
||||
}
|
||||
static readonly int _var_fn = IdentifierManager.Shared.Request("note_time_from");
|
||||
static readonly int _var_tn = IdentifierManager.Shared.Request("note_time_to");
|
||||
static readonly int _var_fn = IdentifierManager.Shared.Request("judge_time_from");
|
||||
static readonly int _var_tn = IdentifierManager.Shared.Request("judge_time_to");
|
||||
static readonly int _var_ft = IdentifierManager.Shared.Request("input_time_from");
|
||||
static readonly int _var_tt = IdentifierManager.Shared.Request("input_time_to");
|
||||
float _numbuf1, _numbuf2, _numbuf3, _numbuf4;
|
||||
readonly PropSrc _numsrc1, _numsrc2, _numsrc3, _numsrc4;
|
||||
readonly PropStores.Float
|
||||
_numst1 = new PropStores.Float(),
|
||||
_numst2 = new PropStores.Float(),
|
||||
_numst3 = new PropStores.Float(),
|
||||
_numst4 = new PropStores.Float();
|
||||
|
||||
static readonly int _var_jt = IdentifierManager.Shared.Request("judge_time");
|
||||
static readonly int _var_jv = IdentifierManager.Shared.Request("judge_vec");
|
||||
float _jnumbuf; Vector4 _jvecbuf;
|
||||
readonly PropSrc _jnumsrc, _jvecsrc;
|
||||
static readonly int _var_jt = IdentifierManager.Shared.Request("hit_time");
|
||||
static readonly int _var_jdt = IdentifierManager.Shared.Request("hit_delta_time");
|
||||
static readonly int _var_jv = IdentifierManager.Shared.Request("hit_vec");
|
||||
readonly PropStores.Float
|
||||
_jnumst = new PropStores.Float(),
|
||||
_jdnumst = new PropStores.Float();
|
||||
readonly PropStores.Vector4 _jvecst = new PropStores.Vector4();
|
||||
|
||||
// Adopted from System.Collections.Generic.ArraySortHelper<T>.InternalBinarySearch(T[] array, int index, int length, T value, IComparer<T> comparer)
|
||||
int BinarySearch(List<JudgeEvent> list, float time, int stack) {
|
||||
@@ -208,12 +208,31 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
return ~num;
|
||||
}
|
||||
void UpdateContextJudgeEvent(JudgeEvent ev) {
|
||||
_numst1.Value = (float)ev.StartTime; _etor.ContextCascadeUpdate(_var_fn, _numst1.Source);
|
||||
_numst2.Value = (float)ev.EndTime; _etor.ContextCascadeUpdate(_var_tn, _numst2.Source);
|
||||
if (ev.BaseEvent != null) {
|
||||
_etor.ContextEvent = ev.BaseEvent;
|
||||
_etor.ContextState = ev.Handler.cs;
|
||||
}
|
||||
var call = ev.CallContext;
|
||||
if (call.ReturnEvent != null) {
|
||||
JudgeResult judgeResult = call.ReturnEvent.JudgeResult;
|
||||
_jnumst.Value = judgeResult.Time.Value; _etor.ContextCascadeUpdate(_var_jt, _jnumst.Source);
|
||||
_jdnumst.Value = (float)(judgeResult.Time.Value - call.ReturnEvent.StartTime); _etor.ContextCascadeUpdate(_var_jdt, _jdnumst.Source);
|
||||
_jvecst.Value = judgeResult.Vector; _etor.ContextCascadeUpdate(_var_jv, _jvecst.Source);
|
||||
}
|
||||
else {
|
||||
_etor.ContextCascadeUpdate(_var_jt, PropSrc.Null);
|
||||
_etor.ContextCascadeUpdate(_var_jv, PropSrc.Null);
|
||||
}
|
||||
}
|
||||
public void Feed(Identifier target, float ft, float tt) {
|
||||
Forward(target, tt);
|
||||
var actlist = activeEvs[target];
|
||||
if (actlist.Count > 0) {
|
||||
_numbuf3 = ft; _numsrc3.Invalidate(); _etor.ContextCascadeUpdate(_var_ft, _numsrc3);
|
||||
_numbuf4 = tt; _numsrc4.Invalidate(); _etor.ContextCascadeUpdate(_var_tt, _numsrc4);
|
||||
_numst3.Value = ft; _etor.ContextCascadeUpdate(_var_ft, _numst3.Source);
|
||||
_numst4.Value = tt; _etor.ContextCascadeUpdate(_var_tt, _numst4.Source);
|
||||
int index = 0, iter = 0;
|
||||
while (index < actlist.Count) {
|
||||
if (iter++ >= 16) throw new JudgePropagationException();
|
||||
@@ -223,12 +242,7 @@ namespace Cryville.Crtr {
|
||||
while (index >= 0 && index < actlist.Count) {
|
||||
var ev = actlist[index];
|
||||
if (ev.Definition.stack != cstack) break;
|
||||
_numbuf1 = (float)ev.StartTime; _numsrc1.Invalidate(); _etor.ContextCascadeUpdate(_var_fn, _numsrc1);
|
||||
_numbuf2 = (float)ev.EndTime; _numsrc2.Invalidate(); _etor.ContextCascadeUpdate(_var_tn, _numsrc2);
|
||||
if (ev.BaseEvent != null) {
|
||||
_etor.ContextEvent = ev.BaseEvent;
|
||||
_etor.ContextState = ev.Handler.cs;
|
||||
}
|
||||
UpdateContextJudgeEvent(ev);
|
||||
var def = ev.Definition;
|
||||
if (def.hit != null) {
|
||||
_etor.Evaluate(_hitop, def.hit);
|
||||
@@ -238,25 +252,16 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
else if (hitIndex == -1) hitIndex = index;
|
||||
_etor.ContextState = null;
|
||||
_etor.ContextEvent = null;
|
||||
index++;
|
||||
}
|
||||
if (hitIndex != -1) {
|
||||
var hitEvent = actlist[hitIndex];
|
||||
_numbuf1 = (float)hitEvent.StartTime; _numsrc1.Invalidate(); _etor.ContextCascadeUpdate(_var_fn, _numsrc1);
|
||||
_numbuf2 = (float)hitEvent.EndTime; _numsrc2.Invalidate(); _etor.ContextCascadeUpdate(_var_tn, _numsrc2);
|
||||
if (hitEvent.BaseEvent != null) {
|
||||
_etor.ContextEvent = hitEvent.BaseEvent;
|
||||
_etor.ContextState = hitEvent.Handler.cs;
|
||||
}
|
||||
UpdateContextJudgeEvent(hitEvent);
|
||||
var def = hitEvent.Definition;
|
||||
if (def == _judgePause) _sys.TogglePause();
|
||||
if (def.on_hit != null) Execute(hitEvent, (ft + tt) / 2, def.on_hit, false);
|
||||
if (def.persist != null) _etor.Evaluate(_flagop, def.persist);
|
||||
else _flag = false;
|
||||
_etor.ContextState = null;
|
||||
_etor.ContextEvent = null;
|
||||
Execute(hitEvent, (ft + tt) / 2, def.on_hit, false);
|
||||
if (!_flag) {
|
||||
actlist.RemoveAt(hitIndex);
|
||||
--index;
|
||||
@@ -267,6 +272,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
_etor.ContextState = null;
|
||||
_etor.ContextEvent = null;
|
||||
}
|
||||
}
|
||||
public void Cleanup(Identifier target, float tt) {
|
||||
@@ -294,9 +301,11 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
void Execute(JudgeEvent ev, float time, PairList<JudgeAction, PdtExpression> actions, bool onMiss, int depth = 0, int index = 0) {
|
||||
if (!onMiss && ev.JudgeResult.Time != null) {
|
||||
_jnumbuf = ev.JudgeResult.Time.Value; _jnumsrc.Invalidate(); _etor.ContextCascadeUpdate(_var_jt, _jnumsrc);
|
||||
_jvecbuf = ev.JudgeResult.Vector; _jvecsrc.Invalidate(); _etor.ContextCascadeUpdate(_var_jv, _jvecsrc);
|
||||
JudgeResult judgeResult = ev.JudgeResult;
|
||||
if (!onMiss && judgeResult.Time != null) {
|
||||
_jnumst.Value = judgeResult.Time.Value; _etor.ContextCascadeUpdate(_var_jt, _jnumst.Source);
|
||||
_jdnumst.Value = (float)(judgeResult.Time.Value - ev.StartTime); _etor.ContextCascadeUpdate(_var_jdt, _jdnumst.Source);
|
||||
_jvecst.Value = judgeResult.Vector; _etor.ContextCascadeUpdate(_var_jv, _jvecst.Source);
|
||||
}
|
||||
if (actions != null) {
|
||||
// Ensure that all actions that modifies judge result sources break the execution
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using Cryville.Common.Unity.UI;
|
||||
using Cryville.Crtr.Browsing;
|
||||
using Cryville.Crtr.Config;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -15,7 +16,7 @@ namespace Cryville.Crtr {
|
||||
[SerializeField]
|
||||
ProgressBar m_progressBar;
|
||||
[SerializeField]
|
||||
SettingsPanel m_settingsPanel;
|
||||
PropertyMasterPanel m_settingsPanel;
|
||||
[SerializeField]
|
||||
TMP_Text m_title;
|
||||
[SerializeField]
|
||||
@@ -29,7 +30,7 @@ namespace Cryville.Crtr {
|
||||
void Awake() {
|
||||
Game.Init();
|
||||
transform.parent.Find("Canvas/Contents").gameObject.SetActive(true);
|
||||
m_settingsPanel.Target = Settings.Default;
|
||||
m_settingsPanel.Adapter = new DefaultPropertyMasterAdapter(Settings.Default);
|
||||
PushTitle("Chart Browser");
|
||||
}
|
||||
void Update() {
|
||||
@@ -58,7 +59,7 @@ namespace Cryville.Crtr {
|
||||
void OnEnable() {
|
||||
Application.targetFrameRate = 60;
|
||||
if (animatorState != null) m_targetAnimator.PlayInFixedTime(animatorState, 0, 0);
|
||||
Game.NetworkTaskWorker.ResumeBackgroundTasks();
|
||||
Game.ResumeBackgroundTasks();
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
|
@@ -455,11 +455,9 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe class VectorSrc : PropSrc.FixedBuffer {
|
||||
public unsafe class VectorSrc : PropSrc.FixedBuffer<Vector> {
|
||||
const int MAX_DIMENSION = 4;
|
||||
protected readonly Func<Vector> _cb;
|
||||
public VectorSrc(Func<Vector> cb) : base(PdtInternalType.Vector, MAX_DIMENSION * sizeof(float) + sizeof(int)) {
|
||||
_cb = cb;
|
||||
public VectorSrc(Func<Vector> cb) : base(PdtInternalType.Vector, MAX_DIMENSION * sizeof(float) + sizeof(int), cb) {
|
||||
fixed (byte* rptr = buf) {
|
||||
var ptr = (float*)rptr;
|
||||
*(int*)(ptr + MAX_DIMENSION) = PdtInternalType.Number;
|
||||
@@ -475,9 +473,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
|
||||
public class VectorOp : PropOp {
|
||||
readonly Action<float[]> _cb;
|
||||
public VectorOp(Action<float[]> cb) { _cb = cb; }
|
||||
public class VectorOp : PropOp.Fixed<float[]> {
|
||||
public VectorOp(Action<float[]> cb) : base(cb) { }
|
||||
protected override unsafe void Execute() {
|
||||
var op = GetOperand(0);
|
||||
float[] values;
|
||||
|
8
Assets/Cryville/Crtr/Network.meta
Normal file
8
Assets/Cryville/Crtr/Network.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b40db90d3ad439498fc7ff01a5ea5f4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
194
Assets/Cryville/Crtr/Network/UpdateChecker.cs
Normal file
194
Assets/Cryville/Crtr/Network/UpdateChecker.cs
Normal file
@@ -0,0 +1,194 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Network.Http11;
|
||||
using Cryville.Common.Unity;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
|
||||
using System.Runtime.InteropServices;
|
||||
#endif
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using Logger = Cryville.Common.Logging.Logger;
|
||||
using ThreadPriority = System.Threading.ThreadPriority;
|
||||
|
||||
namespace Cryville.Crtr.Network {
|
||||
public class UpdateChecker : MonoBehaviour {
|
||||
string _currentVersion;
|
||||
Thread _thread;
|
||||
#pragma warning disable IDE0044
|
||||
bool _shutdown;
|
||||
#pragma warning restore IDE0044
|
||||
void Start() {
|
||||
_currentVersion = Application.version;
|
||||
_thread = new Thread(ThreadLogic) { IsBackground = true, Priority = ThreadPriority.BelowNormal };
|
||||
_thread.Start();
|
||||
}
|
||||
void Update() {
|
||||
if (!_thread.IsAlive) {
|
||||
enabled = false;
|
||||
if (_shutdown) Application.Quit();
|
||||
}
|
||||
}
|
||||
static readonly Uri BaseUri = new Uri("https://www.cryville.world/api/crtr/index");
|
||||
List<VersionInfo> _versions;
|
||||
void ThreadLogic() {
|
||||
try {
|
||||
CheckVersion();
|
||||
Logger.Log("main", 0, "Network", "Update checker exited normally");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Log("main", 4, "Network", "An error occurred while checking for update: {0}", ex);
|
||||
Dialog.Show(null, "Failed to check for update.");
|
||||
}
|
||||
}
|
||||
void CheckVersion() {
|
||||
using (var client = new Https11Client(BaseUri)) {
|
||||
client.Connect();
|
||||
using (var response = client.Request("GET", new Uri(BaseUri, "versions"))) {
|
||||
var data = Encoding.UTF8.GetString(response.MessageBody.ReadToEnd());
|
||||
_versions = JsonConvert.DeserializeObject<List<VersionInfo>>(data, Game.GlobalJsonSerializerSettings);
|
||||
}
|
||||
}
|
||||
var availableVersions = _versions.Where(v => v.platforms.ContainsKey(PlatformConfig.Name)).ToArray();
|
||||
var versionIndex = new Dictionary<string, int>(availableVersions.Length);
|
||||
for (int i = 0; i < availableVersions.Length; i++) versionIndex.Add(availableVersions[i].name, i);
|
||||
var currentVersion = availableVersions.Where(v => v.name == _currentVersion).SingleOrDefault();
|
||||
var latestVersion = availableVersions.Last();
|
||||
if (currentVersion == null) {
|
||||
Dialog.Show(null, string.Format("You are playing an unknown version of Cosmo Resona: {0}\nThe latest version is: {1}", _currentVersion, latestVersion.name));
|
||||
return;
|
||||
}
|
||||
if (latestVersion.name == _currentVersion) return;
|
||||
var latestResources = latestVersion.platforms[PlatformConfig.Name].resources;
|
||||
VersionResourceInfo fullPackage = null;
|
||||
if (latestResources != null) {
|
||||
fullPackage = (from r in latestResources where r.upstream == null select r).SingleOrDefault();
|
||||
}
|
||||
if (fullPackage == null) {
|
||||
Dialog.Show(null, string.Format("A new version is present: {0}\nUpdate is not available.", latestVersion.name));
|
||||
return;
|
||||
}
|
||||
long totalDiffSize = 0;
|
||||
int searchIndex = versionIndex[latestVersion.name], targetIndex = versionIndex[currentVersion.name];
|
||||
var stream = new List<VersionResourceInfo>();
|
||||
while (searchIndex != targetIndex) {
|
||||
var searchVersion = availableVersions[searchIndex];
|
||||
VersionResourceInfo matchedUpstream = null;
|
||||
var resources = searchVersion.platforms[PlatformConfig.Name].resources;
|
||||
if (resources == null) {
|
||||
totalDiffSize = 0;
|
||||
break;
|
||||
}
|
||||
foreach (var r in resources) {
|
||||
if (r.upstream == null) continue;
|
||||
var upstreamIndex = versionIndex[r.upstream];
|
||||
if (upstreamIndex >= targetIndex && upstreamIndex < searchIndex) {
|
||||
matchedUpstream = r;
|
||||
searchIndex = upstreamIndex;
|
||||
}
|
||||
}
|
||||
if (matchedUpstream != null) {
|
||||
if (matchedUpstream.external) {
|
||||
totalDiffSize = 0;
|
||||
Dialog.ShowAndWait("An error occurred while checking for update.\nPlease report this to the developers.");
|
||||
throw new InvalidOperationException("Diff package is external, which is not expected");
|
||||
}
|
||||
stream.Add(matchedUpstream);
|
||||
totalDiffSize += matchedUpstream.size;
|
||||
if (totalDiffSize >= fullPackage.size) {
|
||||
totalDiffSize = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
totalDiffSize = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (totalDiffSize == 0) {
|
||||
// TODO Check if external
|
||||
if (Dialog.ShowAndWait(string.Format("A new version is available: {0}\nYou have to download the full package.\nOpen the download link now?", latestVersion.name), "Yes", "No") == 0) {
|
||||
UrlOpener.OpenThreaded(fullPackage.url);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (Dialog.ShowAndWait(string.Format("A new version is available: {0}\nDo you want to update?", latestVersion.name), "Yes", "No") == 0) {
|
||||
var diffPaths = new List<string>();
|
||||
var updateDir = Directory.CreateDirectory(Path.Combine(Game.GameDataPath, "update")).FullName;
|
||||
foreach (var diff in stream) {
|
||||
string path = Path.Combine(updateDir, StringUtils.EscapeFileName(diff.upstream));
|
||||
diffPaths.Add(path);
|
||||
Download(diff, path);
|
||||
}
|
||||
while (Dialog.ShowAndWait("The new version has been downloaded.\nUpdate now?\n(The game will be shut down)", "OK", "Later") == 1)
|
||||
Thread.Sleep(60000);
|
||||
ExecuteUpdate(diffPaths);
|
||||
}
|
||||
}
|
||||
}
|
||||
void Download(VersionResourceInfo diff, string path) {
|
||||
var uri = new Uri(diff.url);
|
||||
using (var client = new Https11Client(uri)) {
|
||||
client.Connect();
|
||||
using (var response = client.Request("GET", uri)) {
|
||||
var data = response.MessageBody.ReadToEnd();
|
||||
using (var file = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None)) {
|
||||
file.Write(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void ExecuteUpdate(List<string> diffPaths) {
|
||||
#if UNITY_EDITOR
|
||||
Dialog.Show(null, "Could not update the game in editor");
|
||||
#elif UNITY_STANDALONE_WIN
|
||||
var gameDir = new DirectoryInfo(Game.UnityDataPath).Parent;
|
||||
var exe = new FileInfo(Path.Combine(gameDir.FullName, System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe"));
|
||||
var updateDir = Path.Combine(Game.GameDataPath, "update");
|
||||
File.Copy(Path.Combine(Game.UnityDataPath, "Plugins", "x86_64", "hpatchz.dll"), Path.Combine(updateDir, "hpatchz.exe"), true);
|
||||
var batchPath = Path.Combine(updateDir, "update.bat");
|
||||
var oldPath = Path.Combine(updateDir, "old");
|
||||
var newPath = Path.Combine(updateDir, "new");
|
||||
using (var batch = new StreamWriter(batchPath, false, new UTF8Encoding(false))) {
|
||||
batch.WriteLine("@echo off\r\ntitle [Updater] Cosmo Resona\r\necho Waiting for the game to shut down...\r\n:pending\r\ntasklist /fi \"ImageName eq {0}\" | find /i \"{0}\" >nul\r\nif \"%ERRORLEVEL%\" == \"0\" goto pending\r\necho Copying old data...\r\nrmdir /s /q {2}\r\nxcopy \"{1}\" \"{2}\" /s /e /h /i /q /y\r\nif not \"%ERRORLEVEL%\" == \"0\" goto error", exe.Name, gameDir, oldPath);
|
||||
for (int i = 0; i < diffPaths.Count; i++) {
|
||||
string path = diffPaths[i];
|
||||
batch.WriteLine("echo Applying patch... ({0}/{1})\r\nhpatchz -f \"{2}\" \"{3}\" \"{4}\"\r\nif not \"%ERRORLEVEL%\" == \"0\" goto error\r\nrmdir /s /q \"{2}\"\r\nmove /y \"{4}\" \"{2}\"\r\nif not \"%ERRORLEVEL%\" == \"0\" goto error", i + 1, diffPaths.Count, oldPath, path, newPath);
|
||||
}
|
||||
batch.WriteLine("echo Copying new data...\r\nrmdir /s /q {1}\r\nmove /y \"{0}\" \"{1}\"\r\nif not \"%ERRORLEVEL%\" == \"0\" goto error\r\nrmdir /s /q \"{2}\"\r\necho Update succeeded\r\npause\r\nexit\r\n:error\r\necho Update failed\r\npause\r\nexit", oldPath, gameDir, updateDir);
|
||||
}
|
||||
ShellExecute(IntPtr.Zero, "open", batchPath, null, Path.Combine(updateDir), 1);
|
||||
_shutdown = true;
|
||||
#elif UNITY_ANDROID
|
||||
// TODO
|
||||
#else
|
||||
#error No update logic for the selected platform.
|
||||
#endif
|
||||
}
|
||||
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
|
||||
[DllImport("shell32.dll")]
|
||||
static extern int ShellExecute(IntPtr hwnd, [MarshalAs(UnmanagedType.LPStr)] string lpOperation, [MarshalAs(UnmanagedType.LPStr)] string lpFile, [MarshalAs(UnmanagedType.LPStr)] string lpParameters, [MarshalAs(UnmanagedType.LPStr)] string lpDirectory, int nShowCmd);
|
||||
#endif
|
||||
class VersionInfo {
|
||||
[JsonRequired]
|
||||
public string name;
|
||||
public string type;
|
||||
public Dictionary<string, PlatformVersionInfo> platforms;
|
||||
}
|
||||
class PlatformVersionInfo {
|
||||
public List<VersionResourceInfo> resources;
|
||||
}
|
||||
class VersionResourceInfo {
|
||||
public bool external;
|
||||
public string upstream;
|
||||
[JsonRequired]
|
||||
public string url;
|
||||
[JsonRequired]
|
||||
public long size;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/Network/UpdateChecker.cs.meta
Normal file
11
Assets/Cryville/Crtr/Network/UpdateChecker.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a07bd0d5ae9f7b4fa13443638f4b7e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -23,27 +23,21 @@ namespace Cryville.Crtr {
|
||||
static readonly int _var_judge_time_absolute = IdentifierManager.Shared.Request("judge_time_absolute");
|
||||
static readonly int _var_judge_time_relative = IdentifierManager.Shared.Request("judge_time_relative");
|
||||
public Anchor StaticAnchor { get; private set; }
|
||||
public float AbsoluteTime { get; private set; }
|
||||
PropSrc _jtabsPropSrc;
|
||||
public float RelativeTime { get; private set; }
|
||||
PropSrc _jtrelPropSrc;
|
||||
public int Result { get; private set; }
|
||||
PropSrc _resultPropSrc;
|
||||
readonly PropStores.Float _jtabsst = new PropStores.Float();
|
||||
readonly PropStores.Float _jtrelst = new PropStores.Float();
|
||||
readonly PropStores.Identifier _resultst = new PropStores.Identifier();
|
||||
public JudgeState(NoteHandler handler, int name) {
|
||||
StaticAnchor = handler.RegisterAnchor(handler.judge.judgeMap[name], false, 3);
|
||||
}
|
||||
public void MarkJudged(float abs, float rel, int result) {
|
||||
AbsoluteTime = abs;
|
||||
RelativeTime = rel;
|
||||
Result = result;
|
||||
_jtabsPropSrc.Invalidate();
|
||||
_jtrelPropSrc.Invalidate();
|
||||
_resultPropSrc.Invalidate();
|
||||
_jtabsst.Value = abs;
|
||||
_jtrelst.Value = rel;
|
||||
_resultst.Value = result;
|
||||
}
|
||||
public void InitPropSrcs() {
|
||||
StaticAnchor.PropSrcs.Add(_var_judge_result, _resultPropSrc = new PropSrc.Identifier(() => Result));
|
||||
StaticAnchor.PropSrcs.Add(_var_judge_time_absolute, _jtabsPropSrc = new PropSrc.Float(() => AbsoluteTime));
|
||||
StaticAnchor.PropSrcs.Add(_var_judge_time_relative, _jtrelPropSrc = new PropSrc.Float(() => RelativeTime));
|
||||
StaticAnchor.PropSrcs.Add(_var_judge_result, _resultst.Source);
|
||||
StaticAnchor.PropSrcs.Add(_var_judge_time_absolute, _jtabsst.Source);
|
||||
StaticAnchor.PropSrcs.Add(_var_judge_time_relative, _jtrelst.Source);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -11,37 +11,42 @@ namespace Cryville.Crtr {
|
||||
var exp = (PdtExpression)value;
|
||||
if (type.Equals(typeof(bool))) {
|
||||
bool result = false;
|
||||
ChartPlayer.etor.Evaluate(new PropOp.Boolean(r => result = r), exp);
|
||||
PdtEvaluator.Instance.Evaluate(new PropOp.Boolean(r => result = r), exp);
|
||||
return result;
|
||||
}
|
||||
else if (type.Equals(typeof(int))) {
|
||||
int result = 0;
|
||||
ChartPlayer.etor.Evaluate(new PropOp.Integer(r => result = r), exp);
|
||||
PdtEvaluator.Instance.Evaluate(new PropOp.Integer(r => result = r), exp);
|
||||
return result;
|
||||
}
|
||||
else if (type.Equals(typeof(float))) {
|
||||
float result = 0;
|
||||
ChartPlayer.etor.Evaluate(new PropOp.Float(r => result = r), exp);
|
||||
PdtEvaluator.Instance.Evaluate(new PropOp.Float(r => result = r), exp);
|
||||
return result;
|
||||
}
|
||||
else if (type.Equals(typeof(string))) {
|
||||
string result = default(string);
|
||||
ChartPlayer.etor.Evaluate(new PropOp.String(r => result = r), exp);
|
||||
PdtEvaluator.Instance.Evaluate(new PropOp.String(r => result = r), exp);
|
||||
return result;
|
||||
}
|
||||
else if (type.IsEnum) {
|
||||
object result = null;
|
||||
PdtEvaluator.Instance.Evaluate(new PropOp.Enum(type, r => result = r), exp);
|
||||
return result;
|
||||
}
|
||||
else if (type.Equals(typeof(Clip))) {
|
||||
Clip result = default(Clip);
|
||||
ChartPlayer.etor.Evaluate(new PropOp.Clip(r => result = r), exp);
|
||||
PdtEvaluator.Instance.Evaluate(new PropOp.Clip(r => result = r), exp);
|
||||
return result;
|
||||
}
|
||||
else if (type.Equals(typeof(Identifier))) {
|
||||
Identifier result = default(Identifier);
|
||||
ChartPlayer.etor.Evaluate(new pop_identstr(r => result = r), exp);
|
||||
PdtEvaluator.Instance.Evaluate(new pop_identstr(r => result = r), exp);
|
||||
return result;
|
||||
}
|
||||
else if (type.Equals(typeof(Identifier[]))) {
|
||||
Identifier[] result = null;
|
||||
ChartPlayer.etor.Evaluate(new pop_identstrarr(r => result = r), exp);
|
||||
PdtEvaluator.Instance.Evaluate(new pop_identstrarr(r => result = r), exp);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ using Cryville.Common;
|
||||
using Cryville.Common.Collections.Specialized;
|
||||
using Cryville.Common.Math;
|
||||
using Cryville.Common.Pdt;
|
||||
using Cryville.Crtr.Config;
|
||||
using Cryville.Crtr.Event;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -10,6 +11,14 @@ using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public class PdtEvaluator : PdtEvaluatorBase {
|
||||
static PdtEvaluator m_instance;
|
||||
public static PdtEvaluator Instance {
|
||||
get {
|
||||
if (m_instance == null) m_instance = new PdtEvaluator();
|
||||
return m_instance;
|
||||
}
|
||||
}
|
||||
|
||||
readonly Dictionary<PdtOperatorSignature, PdtOperator> _shortops = new Dictionary<PdtOperatorSignature, PdtOperator>();
|
||||
readonly IntKeyedDictionary<PdtOperator> _ctxops = new IntKeyedDictionary<PdtOperator>();
|
||||
|
||||
@@ -32,7 +41,7 @@ namespace Cryville.Crtr {
|
||||
else if (name == _var_false) { LoadNum(0); type = PdtInternalType.Number; value = _numbuf; }
|
||||
else if (name == _var_null) { LoadIdent(0); type = PdtInternalType.Undefined; value = _numbuf; }
|
||||
else {
|
||||
PropSrc prop; SkinVariable variable;
|
||||
PropSrc prop; PropStores.Float variable;
|
||||
if (ContextEvent != null && ContextEvent.PropSrcs.TryGetValue(name, out prop)) {
|
||||
prop.Get(out type, out value);
|
||||
}
|
||||
@@ -40,13 +49,17 @@ namespace Cryville.Crtr {
|
||||
_vec = ContextState.GetComputedValue(name);
|
||||
_vecsrc.Invalidate();
|
||||
_vecsrc.Get(out type, out value);
|
||||
RevokePotentialConstant();
|
||||
}
|
||||
else if (ContextState != null && ContextState.Handler.PropSrcs.TryGetValue(name, out prop)) {
|
||||
prop.Get(out type, out value);
|
||||
RevokePotentialConstant();
|
||||
}
|
||||
else if (ContextSkinContainer != null && ContextSkinContainer.Variables.TryGetValue(name, out variable)) {
|
||||
variable.Src.Get(out type, out value);
|
||||
variable.Source.Get(out type, out value);
|
||||
}
|
||||
else if (ContextRulesetConfig != null && ContextRulesetConfig.TryGetMappedSource(name, out prop)) {
|
||||
prop.Get(out type, out value);
|
||||
}
|
||||
else if (ContextJudge != null && ContextJudge.TryGetScoreSrc(name, out prop)) {
|
||||
prop.Get(out type, out value);
|
||||
@@ -116,6 +129,7 @@ namespace Cryville.Crtr {
|
||||
public ContainerState ContextState { get; set; }
|
||||
public SkinContainer ContextSkinContainer { get; set; }
|
||||
public Transform ContextTransform { get; set; }
|
||||
public RulesetConfigStore ContextRulesetConfig { get; set; }
|
||||
public Judge ContextJudge { get; set; }
|
||||
public PropSrc ContextSelfValue { get; set; }
|
||||
|
||||
@@ -152,6 +166,19 @@ namespace Cryville.Crtr {
|
||||
ContextCascade[--_cascadeHeight].Clear();
|
||||
}
|
||||
|
||||
public void Reset() {
|
||||
_cascadeHeight = 0;
|
||||
ContextCascadeBlocks.Clear();
|
||||
ContextCascadeBlocks.Push(0);
|
||||
ContextEvent = null;
|
||||
ContextJudge = null;
|
||||
ContextRulesetConfig = null;
|
||||
ContextSelfValue = null;
|
||||
ContextSkinContainer = null;
|
||||
ContextState = null;
|
||||
ContextTransform = null;
|
||||
}
|
||||
|
||||
public PdtEvaluator() {
|
||||
ContextCascadeBlocks.Push(0);
|
||||
for (int i = 0; i < ContextCascade.Length; i++) ContextCascade[i] = new IntKeyedDictionary<PropSrc>();
|
||||
@@ -191,6 +218,8 @@ namespace Cryville.Crtr {
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("ease_out"), new func_cubic_bezier_fixed(0f, 0f, 0.58f, 1f, () => ContextSelfValue));
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("ease_in_out"), new func_cubic_bezier_fixed(0.42f, 0f, 0.58f, 1f, () => ContextSelfValue));
|
||||
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("precision"), new func_precision(() => ContextSelfValue));
|
||||
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("interval"), new func_interval(() => ContextSelfValue));
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("circle"), new func_sphere(() => ContextSelfValue));
|
||||
_ctxops.Add(IdentifierManager.Shared.Request("sphere"), new func_sphere(() => ContextSelfValue));
|
||||
@@ -621,6 +650,28 @@ namespace Cryville.Crtr {
|
||||
.SetNumber(CubicBezier.Evaluate(time, x1, y1, x2, y2, 1e-3f));
|
||||
}
|
||||
}
|
||||
class func_precision : PdtOperator {
|
||||
readonly Func<PropSrc> _ctxcb;
|
||||
public func_precision(Func<PropSrc> ctxcb) : base(2) {
|
||||
_ctxcb = ctxcb;
|
||||
}
|
||||
protected override unsafe void Execute() {
|
||||
var ret = GetReturnFrame(PdtInternalType.Number, sizeof(float));
|
||||
float v, p;
|
||||
switch (LoadedOperandCount) {
|
||||
case 1:
|
||||
v = oputil.AsNumber(_ctxcb());
|
||||
p = GetOperand(0).AsNumber(); break;
|
||||
case 2:
|
||||
v = GetOperand(0).AsNumber();
|
||||
p = GetOperand(1).AsNumber(); break;
|
||||
default: throw new ArgumentException("Argument count not 1 or 2");
|
||||
}
|
||||
double pp = Math.Pow(10, Math.Floor(Math.Log10(Math.Abs(p))) + 1);
|
||||
double dp = pp * Math.Round(p / pp, 7);
|
||||
ret.SetNumber((float)(Math.Round((double)v / dp) * dp));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Area Functions
|
||||
class func_interval : PdtOperator {
|
||||
@@ -678,8 +729,8 @@ namespace Cryville.Crtr {
|
||||
#endregion
|
||||
#region Judge Functions
|
||||
#region Primary
|
||||
static readonly int _var_fn = IdentifierManager.Shared.Request("note_time_from");
|
||||
static readonly int _var_tn = IdentifierManager.Shared.Request("note_time_to");
|
||||
static readonly int _var_fn = IdentifierManager.Shared.Request("judge_time_from");
|
||||
static readonly int _var_tn = IdentifierManager.Shared.Request("judge_time_to");
|
||||
static readonly int _var_ft = IdentifierManager.Shared.Request("input_time_from");
|
||||
static readonly int _var_tt = IdentifierManager.Shared.Request("input_time_to");
|
||||
static readonly int _var_fv = IdentifierManager.Shared.Request("input_vec_from");
|
||||
@@ -897,8 +948,8 @@ namespace Cryville.Crtr {
|
||||
#endregion
|
||||
#endregion
|
||||
#region Secondary
|
||||
static readonly int _var_jt = IdentifierManager.Shared.Request("judge_time");
|
||||
static readonly int _var_jv = IdentifierManager.Shared.Request("judge_vec");
|
||||
static readonly int _var_jt = IdentifierManager.Shared.Request("hit_time");
|
||||
static readonly int _var_jv = IdentifierManager.Shared.Request("hit_vec");
|
||||
class func_in_timing : PdtOperator {
|
||||
readonly Func<int, PropSrc> _ctxcb;
|
||||
public func_in_timing(Func<int, PropSrc> ctxcb) : base(2) {
|
||||
|
27
Assets/Cryville/Crtr/PlatformConfig.cs
Normal file
27
Assets/Cryville/Crtr/PlatformConfig.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Cryville.Common.Font;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
internal static class PlatformConfig {
|
||||
#if UNITY_STANDALONE_WIN
|
||||
public static readonly string Name = "windows";
|
||||
#elif UNITY_ANDROID
|
||||
public static readonly string Name = "android";
|
||||
#else
|
||||
#error Unknown platform.
|
||||
#endif
|
||||
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
|
||||
public static readonly string FileProtocolPrefix = "file:///";
|
||||
public static readonly FontManager FontManager = new FontManagerWindows();
|
||||
public static readonly Dictionary<string, List<string>> ScriptFontMap = FallbackListFontMatcher.GetDefaultWindowsFallbackMap();
|
||||
public static readonly string TextShader = "TextMesh Pro/Shaders/TMP_SDF SSD";
|
||||
#elif UNITY_ANDROID
|
||||
public static readonly string FileProtocolPrefix = "file://";
|
||||
public static readonly FontManager FontManager = new FontManagerAndroid();
|
||||
public static readonly Dictionary<string, List<string>> ScriptFontMap = FallbackListFontMatcher.GetDefaultAndroidFallbackMap();
|
||||
public static readonly string TextShader = "TextMesh Pro/Shaders/TMP_SDF-Mobile SSD";
|
||||
#else
|
||||
#error Unknown platform.
|
||||
#endif
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/PlatformConfig.cs.meta
Normal file
11
Assets/Cryville/Crtr/PlatformConfig.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b9be7f84b72ac9468dacec2d44003a9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -16,7 +16,7 @@ namespace Cryville.Crtr {
|
||||
group = GetComponent<CanvasGroup>();
|
||||
group.alpha = 0;
|
||||
GetComponentInChildren<Text>().text = Message;
|
||||
transform.SetParent(GameObject.Find("PopupList").transform);
|
||||
transform.SetParent(GameObject.Find("PopupList").transform, false);
|
||||
}
|
||||
|
||||
void Update() {
|
||||
|
@@ -21,49 +21,48 @@ namespace Cryville.Crtr {
|
||||
var op = GetOperand(0);
|
||||
var value = new byte[op.Length];
|
||||
op.CopyTo(value, 0);
|
||||
ChartPlayer.etor.ContextCascadeUpdate(Name, new PropSrc.Arbitrary(op.Type, value));
|
||||
PdtEvaluator.Instance.ContextCascadeUpdate(Name, new PropSrc.Arbitrary(op.Type, value));
|
||||
}
|
||||
}
|
||||
public class Boolean : PropOp {
|
||||
readonly Action<bool> _cb;
|
||||
public Boolean(Action<bool> cb) { _cb = cb; }
|
||||
public abstract class Fixed<T> : PropOp {
|
||||
protected readonly Action<T> _cb;
|
||||
public Fixed(Action<T> cb) { _cb = cb; }
|
||||
public Fixed(int pc, Action<T> cb) : base(pc) { _cb = cb; }
|
||||
}
|
||||
public class Boolean : Fixed<bool> {
|
||||
public Boolean(Action<bool> cb) : base(cb) { }
|
||||
protected override void Execute() {
|
||||
_cb(GetOperand(0).AsNumber() > 0);
|
||||
}
|
||||
}
|
||||
public class Clip : PropOp {
|
||||
readonly Action<RClip> _cb;
|
||||
public Clip(Action<RClip> cb) : base(2) { _cb = cb; }
|
||||
public class Clip : Fixed<RClip> {
|
||||
public Clip(Action<RClip> cb) : base(2, cb) { }
|
||||
protected override void Execute() {
|
||||
if (LoadedOperandCount < 2)
|
||||
throw new ArgumentException("Invalid clip syntax");
|
||||
_cb(new RClip(GetOperand(0).AsNumber(), GetOperand(1).AsNumber()));
|
||||
}
|
||||
}
|
||||
public class Integer : PropOp {
|
||||
readonly Action<int> _cb;
|
||||
public Integer(Action<int> cb) { _cb = cb; }
|
||||
public class Integer : Fixed<int> {
|
||||
public Integer(Action<int> cb) : base(cb) { }
|
||||
protected override void Execute() {
|
||||
_cb((int)GetOperand(0).AsNumber());
|
||||
}
|
||||
}
|
||||
public class Float : PropOp {
|
||||
readonly Action<float> _cb;
|
||||
public Float(Action<float> cb) { _cb = cb; }
|
||||
public class Float : Fixed<float> {
|
||||
public Float(Action<float> cb) : base(cb) { }
|
||||
protected override void Execute() {
|
||||
_cb(GetOperand(0).AsNumber());
|
||||
}
|
||||
}
|
||||
public class String : PropOp {
|
||||
readonly Action<string> _cb;
|
||||
public String(Action<string> cb) { _cb = cb; }
|
||||
public class String : Fixed<string> {
|
||||
public String(Action<string> cb) : base(cb) { }
|
||||
protected override void Execute() {
|
||||
_cb(GetOperand(0).AsString());
|
||||
}
|
||||
}
|
||||
public class StringArray : PropOp {
|
||||
readonly Action<string[]> _cb;
|
||||
public StringArray(Action<string[]> cb) { _cb = cb; }
|
||||
public class StringArray : Fixed<string[]> {
|
||||
public StringArray(Action<string[]> cb) : base(cb) { }
|
||||
protected override unsafe void Execute() {
|
||||
var op = GetOperand(0);
|
||||
int arrtype; int len;
|
||||
@@ -93,16 +92,32 @@ namespace Cryville.Crtr {
|
||||
target.Validate();
|
||||
}
|
||||
}
|
||||
public class Identifier : PropOp {
|
||||
readonly Action<int> _cb;
|
||||
public Identifier(Action<int> cb) { _cb = cb; }
|
||||
public class Identifier : Fixed<int> {
|
||||
public Identifier(Action<int> cb) : base(cb) { }
|
||||
protected override void Execute() {
|
||||
_cb(GetOperand(0).AsIdentifier());
|
||||
}
|
||||
}
|
||||
public class Enum<T> : PropOp {
|
||||
public class Enum : Fixed<object> {
|
||||
readonly Type _type;
|
||||
readonly IntKeyedDictionary<int> _cache = new IntKeyedDictionary<int>();
|
||||
public Enum(Type type, Action<object> cb) : base(cb) {
|
||||
if (!type.IsEnum)
|
||||
throw new ArgumentException("Type is not enum");
|
||||
_type = type;
|
||||
var names = type.GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||
for (int i = 0; i < names.Length; i++)
|
||||
_cache[IdentifierManager.Shared.Request(names[i].Name)] = Convert.ToInt32(names[i].GetValue(null));
|
||||
}
|
||||
protected override void Execute() {
|
||||
int result = 0;
|
||||
for (int i = 0; i < LoadedOperandCount; i++)
|
||||
result |= _cache[GetOperand(i).AsIdentifier()];
|
||||
_cb(System.Enum.ToObject(_type, result));
|
||||
}
|
||||
}
|
||||
public class Enum<T> : Fixed<T> {
|
||||
static readonly IntKeyedDictionary<int> _cache = new IntKeyedDictionary<int>();
|
||||
readonly Action<T> _cb;
|
||||
readonly Func<int, T> _caster;
|
||||
static Enum() {
|
||||
if (!typeof(T).IsEnum)
|
||||
@@ -111,8 +126,7 @@ namespace Cryville.Crtr {
|
||||
for (int i = 0; i < names.Length; i++)
|
||||
_cache[IdentifierManager.Shared.Request(names[i].Name)] = Convert.ToInt32(names[i].GetValue(null));
|
||||
}
|
||||
public Enum(Action<T> cb, Func<int, T> caster) {
|
||||
_cb = cb;
|
||||
public Enum(Action<T> cb, Func<int, T> caster) : base(cb) {
|
||||
_caster = caster;
|
||||
}
|
||||
protected override void Execute() {
|
||||
@@ -122,17 +136,15 @@ namespace Cryville.Crtr {
|
||||
_cb(_caster(result));
|
||||
}
|
||||
}
|
||||
public class BeatTime : PropOp {
|
||||
readonly Action<RBeatTime> _cb;
|
||||
public BeatTime(Action<RBeatTime> cb) { _cb = cb; }
|
||||
public class BeatTime : Fixed<RBeatTime> {
|
||||
public BeatTime(Action<RBeatTime> cb) : base(cb) { }
|
||||
protected override unsafe void Execute() {
|
||||
var o = GetOperand(0);
|
||||
_cb(o.As<RBeatTime>());
|
||||
}
|
||||
}
|
||||
public class Vector2 : PropOp {
|
||||
readonly Action<RVector2> _cb;
|
||||
public Vector2(Action<RVector2> cb) { _cb = cb; }
|
||||
public class Vector2 : Fixed<RVector2> {
|
||||
public Vector2(Action<RVector2> cb) : base(cb) { }
|
||||
protected override unsafe void Execute() {
|
||||
var o = GetOperand(0);
|
||||
switch ((o.Length - 4) / 4) {
|
||||
@@ -149,9 +161,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Vector3 : PropOp {
|
||||
readonly Action<RVector3> _cb;
|
||||
public Vector3(Action<RVector3> cb) { _cb = cb; }
|
||||
public class Vector3 : Fixed<RVector3> {
|
||||
public Vector3(Action<RVector3> cb) : base(cb) { }
|
||||
protected override unsafe void Execute() {
|
||||
var o = GetOperand(0);
|
||||
switch ((o.Length - 4) / 4) {
|
||||
@@ -166,9 +177,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Vector4 : PropOp {
|
||||
readonly Action<RVector4> _cb;
|
||||
public Vector4(Action<RVector4> cb) { _cb = cb; }
|
||||
public class Vector4 : Fixed<RVector4> {
|
||||
public Vector4(Action<RVector4> cb) : base(cb) { }
|
||||
protected override unsafe void Execute() {
|
||||
var o = GetOperand(0);
|
||||
switch ((o.Length - 4) / 4) {
|
||||
@@ -184,9 +194,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Color : PropOp {
|
||||
readonly Action<RColor> _cb;
|
||||
public Color(Action<RColor> cb) { _cb = cb; }
|
||||
public class Color : Fixed<RColor> {
|
||||
public Color(Action<RColor> cb) : base(cb) { }
|
||||
protected override unsafe void Execute() {
|
||||
var o = GetOperand(0);
|
||||
switch ((o.Length - 4) / 4) {
|
||||
|
@@ -18,11 +18,15 @@ namespace Cryville.Crtr {
|
||||
value = buf;
|
||||
}
|
||||
protected abstract void InternalGet();
|
||||
public abstract class FixedBuffer : PropSrc {
|
||||
public abstract class Fixed<T> : PropSrc {
|
||||
protected readonly Func<T> _cb;
|
||||
public Fixed(int type, Func<T> cb) : base(type) { _cb = cb; }
|
||||
}
|
||||
public abstract class FixedBuffer<T> : Fixed<T> {
|
||||
bool m_invalidated = true;
|
||||
protected override bool Invalidated { get { return m_invalidated; } }
|
||||
public override void Invalidate() { m_invalidated = true; }
|
||||
public FixedBuffer(int type, int size) : base(type) { buf = new byte[size]; }
|
||||
public FixedBuffer(int type, int size, Func<T> cb) : base(type, cb) { buf = new byte[size]; }
|
||||
protected override void InternalGet() {
|
||||
m_invalidated = false;
|
||||
}
|
||||
@@ -36,18 +40,16 @@ namespace Cryville.Crtr {
|
||||
buf = _value;
|
||||
}
|
||||
}
|
||||
public class Boolean : FixedBuffer {
|
||||
readonly Func<bool> _cb;
|
||||
public Boolean(Func<bool> cb) : base(PdtInternalType.Number, 4) { _cb = cb; }
|
||||
public class Boolean : FixedBuffer<bool> {
|
||||
public Boolean(Func<bool> cb) : base(PdtInternalType.Number, 4, cb) { }
|
||||
protected override void InternalGet() {
|
||||
base.InternalGet();
|
||||
buf[0] = _cb() ? (byte)1 : (byte)0;
|
||||
}
|
||||
}
|
||||
public static readonly PropSrc Error = new Arbitrary(PdtInternalType.Error, new byte[0]);
|
||||
public class Float : FixedBuffer {
|
||||
readonly Func<float> _cb;
|
||||
public Float(Func<float> cb) : base(PdtInternalType.Number, 4) { _cb = cb; }
|
||||
public class Float : FixedBuffer<float> {
|
||||
public Float(Func<float> cb) : base(PdtInternalType.Number, 4, cb) { }
|
||||
protected override unsafe void InternalGet() {
|
||||
base.InternalGet();
|
||||
fixed (byte* _ptr = buf) {
|
||||
@@ -56,9 +58,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
public static readonly PropSrc Null = new Arbitrary(PdtInternalType.Null, new byte[0]);
|
||||
public class String : PropSrc {
|
||||
readonly Func<string> _cb;
|
||||
public String(Func<string> cb) : base(PdtInternalType.String) { _cb = cb; }
|
||||
public class String : Fixed<string> {
|
||||
public String(Func<string> cb) : base(PdtInternalType.String, cb) { }
|
||||
protected override unsafe void InternalGet() {
|
||||
var v = _cb();
|
||||
int strlen = v.Length;
|
||||
@@ -71,9 +72,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Identifier : FixedBuffer {
|
||||
readonly Func<int> _cb;
|
||||
public Identifier(Func<int> cb) : base(PdtInternalType.Undefined, 4) { _cb = cb; }
|
||||
public class Identifier : FixedBuffer<int> {
|
||||
public Identifier(Func<int> cb) : base(PdtInternalType.Undefined, 4, cb) { }
|
||||
protected override unsafe void InternalGet() {
|
||||
base.InternalGet();
|
||||
fixed (byte* _ptr = buf) {
|
||||
@@ -81,9 +81,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
public class BeatTime : FixedBuffer {
|
||||
readonly Func<RBeatTime> _cb;
|
||||
public BeatTime(Func<RBeatTime> cb) : base(PdtInternalType.Vector, 4 * sizeof(int)) { _cb = cb; }
|
||||
public class BeatTime : FixedBuffer<RBeatTime> {
|
||||
public BeatTime(Func<RBeatTime> cb) : base(PdtInternalType.Vector, 4 * sizeof(int), cb) { }
|
||||
protected override unsafe void InternalGet() {
|
||||
base.InternalGet();
|
||||
var bt = _cb();
|
||||
@@ -96,9 +95,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Vector4 : FixedBuffer {
|
||||
readonly Func<RVector4> _cb;
|
||||
public Vector4(Func<RVector4> cb) : base(PdtInternalType.Vector, 4 * sizeof(float) + sizeof(int)) { _cb = cb; }
|
||||
public class Vector4 : FixedBuffer<RVector4> {
|
||||
public Vector4(Func<RVector4> cb) : base(PdtInternalType.Vector, 4 * sizeof(float) + sizeof(int), cb) { }
|
||||
protected override unsafe void InternalGet() {
|
||||
base.InternalGet();
|
||||
var vec = _cb();
|
||||
|
46
Assets/Cryville/Crtr/PropStore.cs
Normal file
46
Assets/Cryville/Crtr/PropStore.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using RVector4 = UnityEngine.Vector4;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public abstract class PropStore {
|
||||
protected PropSrc m_source;
|
||||
public PropSrc Source { get { return m_source; } }
|
||||
protected PropOp m_target;
|
||||
public PropOp Target { get { return m_target; } }
|
||||
}
|
||||
public abstract class PropStore<T> : PropStore where T : IEquatable<T> {
|
||||
T m_value;
|
||||
public T Value {
|
||||
get {
|
||||
return m_value;
|
||||
}
|
||||
set {
|
||||
if (m_value.Equals(value)) return;
|
||||
m_value = value;
|
||||
m_source.Invalidate();
|
||||
}
|
||||
}
|
||||
public new PropSrc.Fixed<T> Source { get { return (PropSrc.Fixed<T>)m_source; } }
|
||||
public new PropOp.Fixed<T> Target { get { return (PropOp.Fixed<T>)m_target; } }
|
||||
}
|
||||
public static class PropStores {
|
||||
public class Float : PropStore<float> {
|
||||
public Float() {
|
||||
m_source = new PropSrc.Float(() => Value);
|
||||
m_target = new PropOp.Float(v => Value = v);
|
||||
}
|
||||
}
|
||||
public class Identifier : PropStore<int> {
|
||||
public Identifier() {
|
||||
m_source = new PropSrc.Identifier(() => Value);
|
||||
m_target = new PropOp.Identifier(v => Value = v);
|
||||
}
|
||||
}
|
||||
public class Vector4 : PropStore<RVector4> {
|
||||
public Vector4() {
|
||||
m_source = new PropSrc.Vector4(() => Value);
|
||||
m_target = new PropOp.Vector4(v => Value = v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/PropStore.cs.meta
Normal file
11
Assets/Cryville/Crtr/PropStore.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1654dc7ab34163e4a849fb626a698fbb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -69,7 +69,14 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
public class ConfigDefinition {
|
||||
// TODO
|
||||
public string category;
|
||||
public ConfigType type;
|
||||
public PdtExpression @default;
|
||||
public PdtExpression range;
|
||||
public PdtExpression value;
|
||||
}
|
||||
public enum ConfigType {
|
||||
unknown, number, number_stepped,
|
||||
}
|
||||
public class MotionDefinition {
|
||||
// TODO
|
||||
@@ -141,7 +148,7 @@ namespace Cryville.Crtr {
|
||||
[ElementList]
|
||||
public PairList<RulesetSelectors, Constraint> Elements = new PairList<RulesetSelectors, Constraint>();
|
||||
[PropertyList]
|
||||
public PairList<PropertyKey, PdtExpression> Properties = new PairList<PropertyKey, PdtExpression>();
|
||||
public PairList<ConstraintKey, PdtExpression> Properties = new PairList<ConstraintKey, PdtExpression>();
|
||||
public void Optimize(PdtEvaluatorBase etor) {
|
||||
foreach (var e in Properties) {
|
||||
etor.Optimize(e.Value);
|
||||
@@ -152,20 +159,20 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
public void PrePatch(ChartEvent ev) {
|
||||
var etor = ChartPlayer.etor;
|
||||
var etor = PdtEvaluator.Instance;
|
||||
PropSrc src;
|
||||
etor.ContextCascadeInsert();
|
||||
etor.ContextEvent = ev;
|
||||
foreach (var prop in Properties) {
|
||||
var name = prop.Key.Name;
|
||||
switch (prop.Key.Type) {
|
||||
case PropertyType.Property:
|
||||
case ConstraintType.Property:
|
||||
if (ev.PropSrcs.TryGetValue(name, out src))
|
||||
etor.ContextSelfValue = src;
|
||||
etor.Evaluate(ev.PropOps[name], prop.Value);
|
||||
etor.ContextSelfValue = null;
|
||||
break;
|
||||
case PropertyType.Variable:
|
||||
case ConstraintType.Variable:
|
||||
_arbop.Name = name;
|
||||
etor.Evaluate(_arbop, prop.Value);
|
||||
break;
|
||||
@@ -182,22 +189,22 @@ namespace Cryville.Crtr {
|
||||
etor.ContextCascadeDiscard();
|
||||
}
|
||||
}
|
||||
public class PropertyKey {
|
||||
public PropertyType Type { get; private set; }
|
||||
public class ConstraintKey {
|
||||
public ConstraintType Type { get; private set; }
|
||||
public int Name { get; private set; }
|
||||
public PropertyKey(PropertyType type, string name) {
|
||||
public ConstraintKey(ConstraintType type, string name) {
|
||||
Type = type;
|
||||
Name = IdentifierManager.Shared.Request(name);
|
||||
}
|
||||
public override string ToString() {
|
||||
switch (Type) {
|
||||
case PropertyType.Property: return (string)IdentifierManager.Shared.Retrieve(Name);
|
||||
case PropertyType.Variable: return string.Format("@var {0}", IdentifierManager.Shared.Retrieve(Name));
|
||||
case ConstraintType.Property: return (string)IdentifierManager.Shared.Retrieve(Name);
|
||||
case ConstraintType.Variable: return string.Format("@var {0}", IdentifierManager.Shared.Retrieve(Name));
|
||||
default: return string.Format("<{0}> {1}", Type, IdentifierManager.Shared.Retrieve(Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
public enum PropertyType {
|
||||
public enum ConstraintType {
|
||||
Property,
|
||||
Variable,
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ namespace Cryville.Crtr {
|
||||
break;
|
||||
case ';':
|
||||
case ':':
|
||||
return new PropertyKey(a.Contains("var") ? PropertyType.Variable : PropertyType.Property, key);
|
||||
return new ConstraintKey(a.Contains("var") ? ConstraintType.Variable : ConstraintType.Property, key);
|
||||
case '{':
|
||||
return new RulesetSelectors(s);
|
||||
case '}':
|
||||
|
@@ -90,10 +90,10 @@ namespace Cryville.Crtr {
|
||||
etor.Optimize(_exp);
|
||||
}
|
||||
public override IEnumerable<ChartEvent> Match(ChartEvent ev) {
|
||||
ChartPlayer.etor.ContextEvent = ev;
|
||||
if (!ChartPlayer.etor.Evaluate(_op, _exp))
|
||||
PdtEvaluator.Instance.ContextEvent = ev;
|
||||
if (!PdtEvaluator.Instance.Evaluate(_op, _exp))
|
||||
throw new EvaluationFailureException();
|
||||
ChartPlayer.etor.ContextEvent = null;
|
||||
PdtEvaluator.Instance.ContextEvent = null;
|
||||
if (_flag) return new ChartEvent[] { ev };
|
||||
else return null;
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ using RangeAttribute = Cryville.Common.ComponentModel.RangeAttribute;
|
||||
namespace Cryville.Crtr {
|
||||
public class Settings {
|
||||
[Category("gameplay")]
|
||||
[Range(0f, 10f)][Precision(1)]
|
||||
[Range(0, 10)][Precision(1)]
|
||||
public int AreaJudgePrecision {
|
||||
get {
|
||||
return PlayerPrefs.GetInt("AreaJudgePrecision", 4);
|
||||
@@ -17,7 +17,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
[Category("graphics")]
|
||||
[LogarithmicScale][Range(0.01f, 20f)][Step(1f)][Precision(1e-2)]
|
||||
[LogarithmicScale][Range(-4.6, 3)][Step(1)][Precision(1e-2)]
|
||||
public float BackwardClippingDistance {
|
||||
get {
|
||||
return PlayerPrefs.GetFloat("BackwardClippingDistance", 0.2f);
|
||||
@@ -73,7 +73,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
[Category("gameplay")]
|
||||
[Step(0.02f)][Precision(1e-3)]
|
||||
[Step(0.02)][Precision(1e-3)]
|
||||
public float GraphicalOffset {
|
||||
get {
|
||||
return PlayerPrefs.GetFloat("GraphicalOffset", 0);
|
||||
@@ -142,7 +142,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
[Category("graphics")]
|
||||
[LogarithmicScale][Range(0.1f, 200f)][Step(1f)][Precision(1e-1)]
|
||||
[LogarithmicScale][Range(-2.3, 6)][Step(1)][Precision(1e-1)]
|
||||
public float RenderDistance {
|
||||
get {
|
||||
return PlayerPrefs.GetFloat("RenderDistance", 4);
|
||||
@@ -154,7 +154,7 @@ namespace Cryville.Crtr {
|
||||
|
||||
[Category("graphics")]
|
||||
[Description("The span before the renderer fetches the object data again. Smaller value generates more detailed objects while increasing CPU load. Leave 0 to let the game decides the value automatically.")]
|
||||
[Range(0, 0.1f)][Precision(1e-3)]
|
||||
[Range(0, 0.1)][Precision(1e-3)]
|
||||
public float RenderStep {
|
||||
get {
|
||||
return PlayerPrefs.GetFloat("RenderStep", 0f);
|
||||
@@ -165,7 +165,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
[Category("gameplay")]
|
||||
[Step(0.1f)][Precision(1e-3)]
|
||||
[Step(0.1)][Precision(1e-3)]
|
||||
public float SoundOffset {
|
||||
get {
|
||||
return PlayerPrefs.GetFloat("SoundOffset", 0);
|
||||
@@ -176,7 +176,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
[Category("debug")]
|
||||
[Range(0, float.PositiveInfinity)][Step(60f)][Precision(1e-1)]
|
||||
[Range(0, double.PositiveInfinity)][Step(60)][Precision(1e-1)]
|
||||
public float StartOffset {
|
||||
get {
|
||||
return PlayerPrefs.GetFloat("StartOffset", 0);
|
||||
@@ -187,7 +187,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
[Category("graphics")]
|
||||
[LogarithmicScale][Range(15, 1024)][Step(2f)]
|
||||
[LogarithmicScale][Range(1.15, 3.5)][Step(2)]
|
||||
public int TargetFrameRate {
|
||||
get {
|
||||
return PlayerPrefs.GetInt("TargetFrameRate", 60);
|
||||
|
@@ -1,63 +0,0 @@
|
||||
using Cryville.Crtr.Browsing;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public class SettingsPanel : MonoBehaviour {
|
||||
[SerializeField]
|
||||
GameObject m_categoryPrefab;
|
||||
|
||||
[SerializeField]
|
||||
Transform m_container;
|
||||
|
||||
bool _invalidated = true;
|
||||
object m_target;
|
||||
public object Target {
|
||||
get {
|
||||
return m_target;
|
||||
}
|
||||
set {
|
||||
if (m_target != value) {
|
||||
m_target = value;
|
||||
_invalidated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Update() {
|
||||
if (!_invalidated) return;
|
||||
LoadProperties();
|
||||
foreach (Transform c in m_container) GameObject.Destroy(c.gameObject);
|
||||
foreach (var c in _categories) {
|
||||
var obj = GameObject.Instantiate<GameObject>(m_categoryPrefab, m_container, false);
|
||||
obj.GetComponent<PropertyCategoryPanel>().Load(c.Key, c.Value, Target);
|
||||
}
|
||||
}
|
||||
|
||||
readonly Dictionary<string, List<PropertyInfo>> _categories = new Dictionary<string, List<PropertyInfo>>();
|
||||
public void LoadProperties() {
|
||||
_categories.Clear();
|
||||
_invalidated = false;
|
||||
if (Target == null) return;
|
||||
foreach (var p in Target.GetType().GetProperties()) {
|
||||
bool browsable = true;
|
||||
string category = "miscellaneous";
|
||||
foreach (var attr in p.GetCustomAttributes(true)) {
|
||||
if (attr is BrowsableAttribute) {
|
||||
browsable = ((BrowsableAttribute)attr).Browsable;
|
||||
if (!browsable) break;
|
||||
}
|
||||
else if (attr is CategoryAttribute) {
|
||||
category = ((CategoryAttribute)attr).Category;
|
||||
}
|
||||
}
|
||||
if (!browsable) continue;
|
||||
if (!_categories.ContainsKey(category))
|
||||
_categories.Add(category, new List<PropertyInfo>());
|
||||
_categories[category].Add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -10,7 +10,7 @@ namespace Cryville.Crtr {
|
||||
readonly SkinElement _rootElement;
|
||||
readonly DynamicStack[] _stacks = new DynamicStack[3];
|
||||
readonly HashSet<SkinPropertyKey> _once = new HashSet<SkinPropertyKey>();
|
||||
public readonly IntKeyedDictionary<SkinVariable> Variables = new IntKeyedDictionary<SkinVariable>();
|
||||
public readonly IntKeyedDictionary<PropStores.Float> Variables = new IntKeyedDictionary<PropStores.Float>();
|
||||
|
||||
class DynamicStack {
|
||||
public readonly List<DynamicProperty> Properties = new List<DynamicProperty>();
|
||||
@@ -34,7 +34,6 @@ namespace Cryville.Crtr {
|
||||
_group = group;
|
||||
_rootElement = rootElement;
|
||||
for (int i = 0; i < _stacks.Length; i++) _stacks[i] = new DynamicStack();
|
||||
_rtimeSrc = new PropSrc.Float(() => _rtime);
|
||||
}
|
||||
public void MatchStatic() {
|
||||
var stack = _stacks[0];
|
||||
@@ -43,8 +42,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
void MatchStatic(SkinElement rel, DynamicStack stack, RuntimeSkinContext ctx) {
|
||||
var rc = ctx.ReadContext;
|
||||
ChartPlayer.etor.ContextTransform = rc.Transform;
|
||||
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeInsert(rc.PropSrcs);
|
||||
PdtEvaluator.Instance.ContextTransform = rc.Transform;
|
||||
if (rc.PropSrcs != null) PdtEvaluator.Instance.ContextCascadeInsert(rc.PropSrcs);
|
||||
foreach (var p in rel.properties) {
|
||||
try {
|
||||
p.Key.ExecuteStatic(_group, ctx, p.Value, Variables);
|
||||
@@ -54,7 +53,7 @@ namespace Cryville.Crtr {
|
||||
new DynamicProperty { Context = ctx, Key = p.Key, Value = p.Value }
|
||||
);
|
||||
}
|
||||
ChartPlayer.etor.ContextTransform = null;
|
||||
PdtEvaluator.Instance.ContextTransform = null;
|
||||
foreach (var e in rel.elements) {
|
||||
try {
|
||||
var nctxs = e.Key.MatchStatic(_group, rc);
|
||||
@@ -73,7 +72,7 @@ namespace Cryville.Crtr {
|
||||
);
|
||||
}
|
||||
}
|
||||
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeDiscard();
|
||||
if (rc.PropSrcs != null) PdtEvaluator.Instance.ContextCascadeDiscard();
|
||||
}
|
||||
public void MatchDynamic(int dl, bool recursive = false) {
|
||||
var stack = _stacks[dl];
|
||||
@@ -81,7 +80,7 @@ namespace Cryville.Crtr {
|
||||
var nstack = dl + 1 < _stacks.Length ? _stacks[dl + 1] : null;
|
||||
if (nstack != null) nstack.Clear();
|
||||
Profiler.BeginSample("SkinContainer.MatchDynamic");
|
||||
if (!recursive) ChartPlayer.etor.ContextSkinContainer = this;
|
||||
if (!recursive) PdtEvaluator.Instance.ContextSkinContainer = this;
|
||||
for (int i = 0; i < stack.Properties.Count; i++) {
|
||||
DynamicProperty p = stack.Properties[i];
|
||||
p.Key.ExecuteDynamic(_group, p.Context, p.Value, Variables, dl);
|
||||
@@ -93,7 +92,7 @@ namespace Cryville.Crtr {
|
||||
for (int i = 0; i < stack.Elements.Count; i++) {
|
||||
DynamicElement e = stack.Elements[i];
|
||||
var psrcs = e.Context.ReadContext.PropSrcs;
|
||||
if (psrcs != null) ChartPlayer.etor.ContextCascadeInsert(psrcs);
|
||||
if (psrcs != null) PdtEvaluator.Instance.ContextCascadeInsert(psrcs);
|
||||
if (e.Selectors.IsUpdatable(_group, dl)) {
|
||||
try {
|
||||
var nctx = e.Selectors.MatchDynamic(_group, e.Context.ReadContext);
|
||||
@@ -115,15 +114,15 @@ namespace Cryville.Crtr {
|
||||
if (nstack == null) throw new SelectorNotAvailableException();
|
||||
nstack.Elements.Add(e);
|
||||
}
|
||||
if (psrcs != null) ChartPlayer.etor.ContextCascadeDiscard();
|
||||
if (psrcs != null) PdtEvaluator.Instance.ContextCascadeDiscard();
|
||||
}
|
||||
if (!recursive) ChartPlayer.etor.ContextSkinContainer = null;
|
||||
if (!recursive) PdtEvaluator.Instance.ContextSkinContainer = null;
|
||||
Profiler.EndSample();
|
||||
}
|
||||
void MatchDynamic(SkinElement rel, int dl, DynamicStack stack, RuntimeSkinContext ctx) {
|
||||
var rc = ctx.ReadContext;
|
||||
ChartPlayer.etor.ContextTransform = rc.Transform;
|
||||
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeInsert(rc.PropSrcs);
|
||||
PdtEvaluator.Instance.ContextTransform = rc.Transform;
|
||||
if (rc.PropSrcs != null) PdtEvaluator.Instance.ContextCascadeInsert(rc.PropSrcs);
|
||||
foreach (var p in rel.properties) {
|
||||
if (p.Key.annotations.Contains("once")) {
|
||||
if (_once.Contains(p.Key)) continue;
|
||||
@@ -134,7 +133,7 @@ namespace Cryville.Crtr {
|
||||
p.Key.ExecuteDynamic(_group, ctx, p.Value, Variables, dl);
|
||||
}
|
||||
}
|
||||
ChartPlayer.etor.ContextTransform = null;
|
||||
PdtEvaluator.Instance.ContextTransform = null;
|
||||
foreach (var e in rel.elements) {
|
||||
if (e.Key.IsUpdatable(_group, dl)) {
|
||||
SkinContext nctx = e.Key.MatchDynamic(_group, rc);
|
||||
@@ -149,20 +148,18 @@ namespace Cryville.Crtr {
|
||||
);
|
||||
}
|
||||
}
|
||||
if (rc.PropSrcs != null) ChartPlayer.etor.ContextCascadeDiscard();
|
||||
if (rc.PropSrcs != null) PdtEvaluator.Instance.ContextCascadeDiscard();
|
||||
}
|
||||
float _rtime;
|
||||
readonly PropSrc _rtimeSrc;
|
||||
readonly PropStores.Float _rtimest = new PropStores.Float();
|
||||
public void MatchAnimation(AnimationSpan span, float rtime, RuntimeSkinContext ctx) {
|
||||
ChartPlayer.etor.ContextSkinContainer = this;
|
||||
ChartPlayer.etor.ContextSelfValue = _rtimeSrc;
|
||||
PdtEvaluator.Instance.ContextSkinContainer = this;
|
||||
PdtEvaluator.Instance.ContextSelfValue = _rtimest.Source;
|
||||
MatchAnimationInternal(span, rtime, ctx);
|
||||
ChartPlayer.etor.ContextSelfValue = null;
|
||||
ChartPlayer.etor.ContextSkinContainer = null;
|
||||
PdtEvaluator.Instance.ContextSelfValue = null;
|
||||
PdtEvaluator.Instance.ContextSkinContainer = null;
|
||||
}
|
||||
void MatchAnimationInternal(AnimationSpan span, float rtime, RuntimeSkinContext ctx) {
|
||||
_rtime = rtime;
|
||||
_rtimeSrc.Invalidate();
|
||||
_rtimest.Value = rtime;
|
||||
foreach (var p in span.properties) {
|
||||
p.Key.ExecuteDynamic(_group, ctx, p.Value, Variables, 0);
|
||||
}
|
||||
@@ -215,17 +212,4 @@ namespace Cryville.Crtr {
|
||||
void RegisterAnchor(int name);
|
||||
void PushAnchorEvent(double time, int name);
|
||||
}
|
||||
public class SkinVariable {
|
||||
float _value;
|
||||
public PropOp Op { get; private set; }
|
||||
public PropSrc Src { get; private set; }
|
||||
public SkinVariable() {
|
||||
Op = new PropOp.Float(Set);
|
||||
Src = new PropSrc.Float(() => _value);
|
||||
}
|
||||
void Set(float value) {
|
||||
_value = value;
|
||||
Src.Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -51,8 +51,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
public abstract override string ToString();
|
||||
public abstract bool IsValueRequired { get; }
|
||||
public abstract void ExecuteStatic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<SkinVariable> vars);
|
||||
public abstract void ExecuteDynamic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<SkinVariable> vars, int dl);
|
||||
public abstract void ExecuteStatic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<PropStores.Float> vars);
|
||||
public abstract void ExecuteDynamic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<PropStores.Float> vars, int dl);
|
||||
public class CreateComponent : SkinPropertyKey {
|
||||
public Type Component { get; private set; }
|
||||
public CreateComponent(IEnumerable<string> a, Type component) : base(a) {
|
||||
@@ -62,10 +62,10 @@ namespace Cryville.Crtr {
|
||||
return string.Format("*{0}", Component.Name);
|
||||
}
|
||||
public override bool IsValueRequired { get { return false; } }
|
||||
public override void ExecuteStatic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<SkinVariable> vars) {
|
||||
public override void ExecuteStatic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<PropStores.Float> vars) {
|
||||
ctx.WriteTransform.gameObject.AddComponent(Component);
|
||||
}
|
||||
public override void ExecuteDynamic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<SkinVariable> vars, int dl) {
|
||||
public override void ExecuteDynamic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<PropStores.Float> vars, int dl) {
|
||||
throw new InvalidOperationException("Component creation in dynamic context is not allowed");
|
||||
}
|
||||
}
|
||||
@@ -80,20 +80,20 @@ namespace Cryville.Crtr {
|
||||
return string.Format("{0}.{1}", Component.Name, IdentifierManager.Shared.Retrieve(Name));
|
||||
}
|
||||
public override bool IsValueRequired { get { return true; } }
|
||||
public override void ExecuteStatic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<SkinVariable> vars) {
|
||||
public override void ExecuteStatic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<PropStores.Float> vars) {
|
||||
Execute(ctx, GetPropOp(ctx.WriteTransform).Operator, exp);
|
||||
}
|
||||
public override void ExecuteDynamic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<SkinVariable> vars, int dl) {
|
||||
public override void ExecuteDynamic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<PropStores.Float> vars, int dl) {
|
||||
var prop = GetPropOp(ctx.WriteTransform);
|
||||
if (dl > prop.UpdateDynamicLevel) return;
|
||||
Execute(ctx, prop.Operator, exp);
|
||||
}
|
||||
void Execute(RuntimeSkinContext ctx, PdtOperator op, PdtExpression exp) {
|
||||
var psrcs = ctx.ReadContext.PropSrcs;
|
||||
if (psrcs != null) ChartPlayer.etor.ContextCascadeInsert(psrcs);
|
||||
if (!ChartPlayer.etor.Evaluate(op, exp))
|
||||
if (psrcs != null) PdtEvaluator.Instance.ContextCascadeInsert(psrcs);
|
||||
if (!PdtEvaluator.Instance.Evaluate(op, exp))
|
||||
throw new EvaluationFailureException();
|
||||
if (psrcs != null) ChartPlayer.etor.ContextCascadeDiscard();
|
||||
if (psrcs != null) PdtEvaluator.Instance.ContextCascadeDiscard();
|
||||
}
|
||||
SkinProperty GetPropOp(Transform obj) {
|
||||
var ctype = Component;
|
||||
@@ -120,10 +120,10 @@ namespace Cryville.Crtr {
|
||||
return string.Format("@has {0}", IdentifierManager.Shared.Retrieve(Name));
|
||||
}
|
||||
public override bool IsValueRequired { get { return false; } }
|
||||
public override void ExecuteStatic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<SkinVariable> vars) {
|
||||
public override void ExecuteStatic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<PropStores.Float> vars) {
|
||||
group.RegisterAnchor(Name);
|
||||
}
|
||||
public override void ExecuteDynamic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<SkinVariable> vars, int dl) {
|
||||
public override void ExecuteDynamic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<PropStores.Float> vars, int dl) {
|
||||
throw new InvalidOperationException("Anchor creation in dynamic context is not allowed");
|
||||
}
|
||||
}
|
||||
@@ -137,18 +137,18 @@ namespace Cryville.Crtr {
|
||||
return string.Format("@at {0}", IdentifierManager.Shared.Retrieve(Name));
|
||||
}
|
||||
public override bool IsValueRequired { get { return true; } }
|
||||
public override void ExecuteStatic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<SkinVariable> vars) {
|
||||
public override void ExecuteStatic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<PropStores.Float> vars) {
|
||||
throw new InvalidOperationException("Setting anchor in static context is not allowed");
|
||||
}
|
||||
float _time;
|
||||
readonly PropOp _timeOp;
|
||||
public override void ExecuteDynamic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<SkinVariable> vars, int dl) {
|
||||
public override void ExecuteDynamic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<PropStores.Float> vars, int dl) {
|
||||
if (dl != 1) return;
|
||||
var psrcs = ctx.ReadContext.PropSrcs;
|
||||
if (psrcs != null) ChartPlayer.etor.ContextCascadeInsert(psrcs);
|
||||
if (!ChartPlayer.etor.Evaluate(_timeOp, exp))
|
||||
if (psrcs != null) PdtEvaluator.Instance.ContextCascadeInsert(psrcs);
|
||||
if (!PdtEvaluator.Instance.Evaluate(_timeOp, exp))
|
||||
throw new EvaluationFailureException();
|
||||
if (psrcs != null) ChartPlayer.etor.ContextCascadeDiscard();
|
||||
if (psrcs != null) PdtEvaluator.Instance.ContextCascadeDiscard();
|
||||
group.PushAnchorEvent(_time, Name);
|
||||
}
|
||||
}
|
||||
@@ -164,13 +164,13 @@ namespace Cryville.Crtr {
|
||||
return string.Format(IsSelf ? "@emit_self {0}" : "@emit {0}", IdentifierManager.Shared.Retrieve(Name));
|
||||
}
|
||||
public override bool IsValueRequired { get { return true; } }
|
||||
public override void ExecuteStatic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<SkinVariable> vars) {
|
||||
public override void ExecuteStatic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<PropStores.Float> vars) {
|
||||
throw new InvalidOperationException("Emitting effect in static context is not allowed");
|
||||
}
|
||||
float _index;
|
||||
readonly PropOp _op;
|
||||
public override void ExecuteDynamic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<SkinVariable> vars, int dl) {
|
||||
if (!ChartPlayer.etor.Evaluate(_op, exp))
|
||||
public override void ExecuteDynamic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<PropStores.Float> vars, int dl) {
|
||||
if (!PdtEvaluator.Instance.Evaluate(_op, exp))
|
||||
throw new EvaluationFailureException();
|
||||
if (IsSelf) ChartPlayer.effectManager.EmitSelf(Name, _index, ctx.WriteTransform);
|
||||
else ChartPlayer.effectManager.Emit(Name, _index);
|
||||
@@ -185,18 +185,18 @@ namespace Cryville.Crtr {
|
||||
return string.Format("@var {0}", IdentifierManager.Shared.Retrieve(Name));
|
||||
}
|
||||
public override bool IsValueRequired { get { return true; } }
|
||||
public override void ExecuteStatic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<SkinVariable> vars) {
|
||||
SkinVariable v;
|
||||
public override void ExecuteStatic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<PropStores.Float> vars) {
|
||||
PropStores.Float v;
|
||||
if (!vars.TryGetValue(Name, out v))
|
||||
vars.Add(Name, v = new SkinVariable());
|
||||
if (!ChartPlayer.etor.Evaluate(v.Op, exp))
|
||||
vars.Add(Name, v = new PropStores.Float());
|
||||
if (!PdtEvaluator.Instance.Evaluate(v.Target, exp))
|
||||
throw new EvaluationFailureException();
|
||||
}
|
||||
public override void ExecuteDynamic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<SkinVariable> vars, int dl) {
|
||||
SkinVariable v;
|
||||
public override void ExecuteDynamic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<PropStores.Float> vars, int dl) {
|
||||
PropStores.Float v;
|
||||
if (!vars.TryGetValue(Name, out v))
|
||||
throw new InvalidOperationException(string.Format("Variable \"{0}\" not defined", IdentifierManager.Shared.Retrieve(Name)));
|
||||
if (!ChartPlayer.etor.Evaluate(v.Op, exp))
|
||||
if (!PdtEvaluator.Instance.Evaluate(v.Target, exp))
|
||||
throw new EvaluationFailureException();
|
||||
}
|
||||
}
|
||||
|
@@ -129,9 +129,9 @@ namespace Cryville.Crtr {
|
||||
return Match(c);
|
||||
}
|
||||
public SkinContext Match(SkinContext a) {
|
||||
ChartPlayer.etor.ContextTransform = a.Transform;
|
||||
PdtEvaluator.Instance.ContextTransform = a.Transform;
|
||||
try {
|
||||
if (!ChartPlayer.etor.Evaluate(_op, _exp))
|
||||
if (!PdtEvaluator.Instance.Evaluate(_op, _exp))
|
||||
throw new EvaluationFailureException();
|
||||
return _flag ? a : null;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ namespace Cryville.Crtr {
|
||||
throw new SelectorNotAvailableException("The expression is not evaluatable under the current context", ex);
|
||||
}
|
||||
finally {
|
||||
ChartPlayer.etor.ContextTransform = null;
|
||||
PdtEvaluator.Instance.ContextTransform = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1358
Assets/Menu.unity
1358
Assets/Menu.unity
File diff suppressed because it is too large
Load Diff
@@ -522,7 +522,7 @@ RectTransform:
|
||||
- {fileID: 1070708391}
|
||||
- {fileID: 1482647535}
|
||||
m_Father: {fileID: 1487573536}
|
||||
m_RootOrder: 1
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
@@ -689,78 +689,6 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 816774408}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &996420700
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 996420701}
|
||||
- component: {fileID: 996420703}
|
||||
- component: {fileID: 996420702}
|
||||
m_Layer: 5
|
||||
m_Name: PopupList
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &996420701
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 996420700}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1417564168}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.1, y: 0.05}
|
||||
m_AnchorMax: {x: 0.9, y: 0.95}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &996420702
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 996420700}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Padding:
|
||||
m_Left: 0
|
||||
m_Right: 0
|
||||
m_Top: 0
|
||||
m_Bottom: 0
|
||||
m_ChildAlignment: 1
|
||||
m_Spacing: 10
|
||||
m_ChildForceExpandWidth: 1
|
||||
m_ChildForceExpandHeight: 0
|
||||
m_ChildControlWidth: 1
|
||||
m_ChildControlHeight: 1
|
||||
m_ChildScaleWidth: 0
|
||||
m_ChildScaleHeight: 0
|
||||
m_ReverseArrangement: 0
|
||||
--- !u!222 &996420703
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 996420700}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &1070708390
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1059,107 +987,6 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1095675885}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &1417564167
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1417564168}
|
||||
- component: {fileID: 1417564171}
|
||||
- component: {fileID: 1417564170}
|
||||
- component: {fileID: 1417564169}
|
||||
m_Layer: 5
|
||||
m_Name: PopupUI
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1417564168
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1417564167}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 996420701}
|
||||
m_Father: {fileID: 1487573536}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!114 &1417564169
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1417564167}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!114 &1417564170
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1417564167}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_UiScaleMode: 0
|
||||
m_ReferencePixelsPerUnit: 100
|
||||
m_ScaleFactor: 1
|
||||
m_ReferenceResolution: {x: 800, y: 600}
|
||||
m_ScreenMatchMode: 0
|
||||
m_MatchWidthOrHeight: 0
|
||||
m_PhysicalUnit: 3
|
||||
m_FallbackScreenDPI: 96
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
m_PresetInfoIsWorld: 0
|
||||
--- !u!223 &1417564171
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1417564167}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 0
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 100
|
||||
m_TargetDisplay: 0
|
||||
--- !u!1 &1482647531
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1350,7 +1177,6 @@ Transform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1417564168}
|
||||
- {fileID: 450649535}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
|
@@ -13,7 +13,7 @@ namespace Cryville.Input.Unity.Android {
|
||||
|
||||
readonly Thread _thread;
|
||||
private AndroidInputPoller() {
|
||||
_thread = new Thread(ThreadLogic);
|
||||
_thread = new Thread(ThreadLogic) { IsBackground = true, Priority = ThreadPriority.AboveNormal };
|
||||
_thread.Start();
|
||||
}
|
||||
|
||||
|
BIN
Assets/Plugins/Windows/hpatchz.dll
Normal file
BIN
Assets/Plugins/Windows/hpatchz.dll
Normal file
Binary file not shown.
70
Assets/Plugins/Windows/hpatchz.dll.meta
Normal file
70
Assets/Plugins/Windows/hpatchz.dll.meta
Normal file
@@ -0,0 +1,70 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5caa62ca31e13404ea507d8b08b57ea8
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 0
|
||||
Exclude Linux64: 0
|
||||
Exclude OSXUniversal: 0
|
||||
Exclude Win: 0
|
||||
Exclude Win64: 0
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/android_zip_patch.meta
Normal file
8
Assets/Plugins/android_zip_patch.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e301ce1881897e4438169fbad2bf5d40
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/android_zip_patch/java.meta
Normal file
8
Assets/Plugins/android_zip_patch/java.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbe8aa4bd321dea4d800822e685b1d92
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/android_zip_patch/java/com.meta
Normal file
8
Assets/Plugins/android_zip_patch/java/com.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44813649501c6ea4cb36aeba6606c31b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Plugins/android_zip_patch/java/com/github.meta
Normal file
8
Assets/Plugins/android_zip_patch/java/com/github.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3034edf2b73ec34e85f705d4b7f6ded
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f6a0edac2ccaad4587e7f2110f1d419
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,7 @@
|
||||
package com.github.sisong;
|
||||
|
||||
public class ApkPatch{
|
||||
// return TPatchResult, 0 is ok; patchFilePath file created by ZipDiff;
|
||||
public static native int patch(String oldApkPath,String patchFilePath,String outNewApkPath,
|
||||
long maxUncompressMemory,String tempUncompressFilePath,int threadNum);
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6b1fdf79e7183449aa54268b597c2a0
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user