425 Commits
0.5.1 ... 0.7.0

Author SHA1 Message Date
82060a6403 Disable Android input handlers in non-Android systems. 2023-06-06 11:45:01 +08:00
02441eb328 Update Cryville.Input. 2023-06-06 10:05:02 +08:00
2fe2a40e74 Add stub for config and motion definition in ruleset. 2023-06-06 09:46:39 +08:00
754e3be906 Add stub for judge action @var. 2023-06-06 09:44:00 +08:00
65c225e93b Fix incorrect miss flag on judge pass. 2023-06-02 22:40:52 +08:00
74ce265016 Fix logic of function release_timed_area. 2023-06-02 22:39:37 +08:00
2eba0e490f Code cleanup. 2023-06-02 18:23:44 +08:00
82f769f798 Add context state and context event access for judge. 2023-06-02 18:23:12 +08:00
a008760918 Add secondary judge functions in_timing and in_area. 2023-06-02 18:22:21 +08:00
832facdf5b Add stub for "call" judge action. 2023-06-02 18:20:20 +08:00
d5ba09cbea Implement primary judge result passing. 2023-06-02 18:17:10 +08:00
59b4f14fb3 Make judge functions return judge time and judge vector. 2023-06-02 18:05:25 +08:00
4d13c06f27 Rename internal judge note time variables. 2023-06-02 17:58:53 +08:00
de72fcf572 Rename function in_area to is_in. 2023-06-02 17:48:20 +08:00
1470dbb5aa Fix error while optimizing ruleset when no judge area is defined. 2023-06-02 17:46:13 +08:00
ce31f3e15f Discards context cascades on error. 2023-06-02 17:42:41 +08:00
f6741d0acc Improve error description for missing effect. 2023-06-02 17:41:09 +08:00
910e3ce277 Split (judge) area definition from judges list. 2023-06-02 11:08:43 +08:00
52adef8e9b Modify the logic of "and" and "or" operator. 2023-06-01 23:16:45 +08:00
3d7639b94e Code cleanup. 2023-06-01 23:14:14 +08:00
b306a9d3d1 Remove function contact_timing and contact_timed_area. 2023-05-31 23:19:13 +08:00
0cc15f0c8e Fix potential field align error when dereferencing pointers. 2023-05-31 22:52:18 +08:00
0959b5cc25 Code cleanup. 2023-05-30 22:14:18 +08:00
44c54cd837 Add function sphere. 2023-05-30 22:13:58 +08:00
6e553b9ebb Improve error description for evaluation failure. 2023-05-29 17:06:30 +08:00
88a46127d7 Adapt PDT evaluator to pseudo-lambda expressions. 2023-05-29 17:04:22 +08:00
4310b67e7b Implement extension importer. 2023-05-29 15:04:19 +08:00
7deff3c6be Allow playing chart without input config completed. 2023-05-25 15:07:45 +08:00
5f4d35b3b3 Add exception description for invalid child index. 2023-05-25 15:02:03 +08:00
5b510fa5da Make long motion events standalone to avoid transition overflow. 2023-05-25 14:59:02 +08:00
17042b6664 Code cleanup. 2023-05-25 14:57:42 +08:00
3fb123ff30 Optimize GC while preparing judge events. 2023-05-20 22:58:05 +08:00
ca928eb731 Make judge event internal. 2023-05-20 22:36:08 +08:00
906c82972b Fix typo in a translation file of the skin editor. 2023-05-20 16:37:59 +08:00
cee74b9e31 Code cleanup. 2023-05-20 16:31:23 +08:00
25b4f3ccb7 Add judge action fields on_hit and on_miss. 2023-05-20 16:23:59 +08:00
d1b9b9607b Move nested class JudgeEvent out of Judge. 2023-05-20 16:17:36 +08:00
6ccc86c28d Add constructors for ScoreOperation. 2023-05-20 16:15:12 +08:00
3d75cd9a11 Updates active vectors in input proxy on batch. 2023-05-19 23:58:50 +08:00
b30d35c937 Update global suppressions. 2023-05-19 23:17:56 +08:00
a8231f7c86 Code cleanup. 2023-05-19 23:17:32 +08:00
ed60859406 Add GC-less standalone input module. 2023-05-19 23:14:59 +08:00
0d0902735a Code cleanup. 2023-05-19 00:46:45 +08:00
5bed3cf05b Fix active vectors in input proxy referring to temporary property sources. 2023-05-19 00:45:14 +08:00
5d520609b5 Rename the identifier of input proxy vector. 2023-05-18 14:58:05 +08:00
bf53298706 Modify the internal effect identifier to avoid naming conflict. 2023-05-18 14:55:31 +08:00
3d09ec8c94 Make PdtExpression.Empty public. 2023-05-18 13:28:46 +08:00
bc083541aa Code cleanup. 2023-05-18 00:44:18 +08:00
5b04426cd3 Update Cryville.Crtr.Extension. 2023-05-17 20:43:04 +08:00
8d606524fc Fix the logic of area judge functions. 2023-05-14 19:22:09 +08:00
5bab0ca648 Add area judge functions. 2023-05-14 12:06:32 +08:00
fb31e833cb Code cleanup. 2023-05-14 10:48:26 +08:00
346040574a Modify the default value and the range of force sync frames settings. 2023-05-14 10:47:27 +08:00
959d07b0a9 Add area judge precision settings. 2023-05-14 10:46:32 +08:00
c41d41c881 Make the function interval contextual and linear. 2023-05-12 11:37:14 +08:00
f09e3d3545 Adapt judge functions to Vector4. 2023-05-12 11:33:56 +08:00
12b3373aeb Modify the parameter order of function clamp. 2023-05-12 11:29:06 +08:00
9480904db7 Add judge area definition. (Amend) 2023-05-11 16:19:30 +08:00
bee3401283 Make hit expression comparable. 2023-05-11 16:18:36 +08:00
fe4280aa2e Add judge area definition. 2023-05-11 16:15:57 +08:00
3e273d67ba Fix physical dimension parsing. 2023-05-10 11:10:11 +08:00
fcec43f694 Disable rendering on startup. 2023-05-09 21:28:34 +08:00
904581c520 Allows stopping during chart loading. 2023-05-09 21:27:48 +08:00
b983e32d56 Improve performance for prehandling by disabling rendering. 2023-05-09 21:25:49 +08:00
f2aea2bd40 Improve the ordering logic for input handlers in input config. 2023-05-09 19:02:43 +08:00
cc8e1f7ce4 Update Cryville.Input. 2023-05-09 19:02:17 +08:00
749e1395bc Invalidates handlers with unmatched physical dimension or nullablility in input config. 2023-05-09 19:00:49 +08:00
21af9582f8 Add field for physical dimension in input definition. 2023-05-09 18:58:45 +08:00
26dd373e7b Add function map. 2023-05-09 12:09:08 +08:00
1bd35d2c51 Cleanup. 2023-05-09 11:20:14 +08:00
d275f61602 Update docs from Cryville.Input. 2023-05-09 11:17:49 +08:00
f5f1a5de67 Update Cryville.Audio. 2023-05-09 11:16:18 +08:00
56153f5eed Cleanup. 2023-05-07 21:30:34 +08:00
b4984c0b3a Update Cryville.Input. Fix cleanup logic for input proxy. 2023-05-07 21:30:00 +08:00
dad399facf Fix audio time syncing. 2023-05-07 21:28:17 +08:00
b536871da7 Modify the format of time status debug information. 2023-05-07 21:27:18 +08:00
bd028c1b72 Update Cryville.Input. 2023-05-07 13:42:53 +08:00
fa9303c0a1 Fix chart importing. 2023-05-07 13:40:15 +08:00
d030c48b4d Optimize GC for input config. 2023-05-07 13:38:41 +08:00
beab3d7f8b Fix misspelling. 2023-05-05 00:42:20 +08:00
0b2ea3ddbc Move part of the input module to Cryville.Input. 2023-05-05 00:40:51 +08:00
b143fb49ce Move some classes to Cryville.Common. 2023-05-03 22:51:30 +08:00
8f211568be Fix error caused by threaded input handlers before time syncing. 2023-04-22 21:19:31 +08:00
6d276c99ac Add Android touch handler. 2023-04-22 21:17:00 +08:00
72a93721f9 Fix race condition for the shared evaluator when any active input handler is threaded. 2023-04-22 21:16:17 +08:00
a1fd420493 Fix error handling in PDT evaluator. 2023-04-22 21:09:53 +08:00
d72afaa75b Code cleanup. 2023-04-22 21:08:06 +08:00
2784544884 Fix memory leak from object pools. 2023-04-21 12:18:29 +08:00
c39a02a1c2 Fix event priority. (2) 2023-04-21 00:56:58 +08:00
4c397ab2f7 Switch serialization mode to text mode. 2023-04-21 00:03:13 +08:00
6b3a9c9f0a Fix event priority. 2023-04-20 20:05:59 +08:00
1c1560f17f Fix transition clipping. 2023-04-20 19:47:35 +08:00
0699bc5614 Code cleanup. 2023-04-20 19:47:10 +08:00
d86da00258 Fix unexpected shared vector references. 2023-04-20 19:46:46 +08:00
d1ad68debe Share realtime relative motion nodes across state clones. 2023-04-20 19:45:25 +08:00
b937285a74 Fix polysec not generating mesh if body not specified. 2023-04-20 19:40:50 +08:00
69fe03475b Fix mesh.color not working on polysec. 2023-04-20 19:40:12 +08:00
e5956f2b34 Fix position anchoring. (2) 2023-04-20 14:31:49 +08:00
fdb4ab55a3 (Amend to 61b72107) 2023-04-20 14:31:03 +08:00
e30df8bdbc Fix pre-graphical update not ended within a frame. 2023-04-20 14:29:50 +08:00
251b7bc352 Matches root transform with tag. 2023-04-20 11:37:19 +08:00
61b72107ae Pull up TransformHandler. 2023-04-20 11:36:38 +08:00
d6208f19fb Fix position anchoring. 2023-04-20 00:21:39 +08:00
93d9fdd4b8 Code cleanup. 2023-04-20 00:20:28 +08:00
8670482c04 Implement new transition. 2023-04-20 00:18:49 +08:00
d2b71e41c9 Fix CubicBezier algorithm. 2023-04-20 00:15:06 +08:00
29a8ac2136 Code cleanup. 2023-04-19 15:33:45 +08:00
a9fc5130bb Move BeatTime to separate file. 2023-04-19 15:33:17 +08:00
b51c7d2352 Add chart compatibility handler. 2023-04-19 15:32:16 +08:00
56fd0936bb Fix the recycle of RMV. 2023-04-19 13:56:13 +08:00
2b3898655f Re-implement relative motion. 2023-04-19 13:54:35 +08:00
1b30d3e62c Code cleanup. 2023-04-19 13:52:55 +08:00
bdbb1fcb07 Optimize GC caused by playing motions. 2023-04-19 13:49:55 +08:00
659f2165ff Remove motion lerper. Reconstruct RMV and motion node. Add motion node pool. 2023-04-19 13:48:06 +08:00
a5439430fb Fix the position of the head anchors of tracks. 2023-04-19 13:33:41 +08:00
0f683e403c Resets object on return instead of on rent. 2023-04-19 13:32:06 +08:00
cf6a7a795b Code cleanup. 2023-04-19 13:31:17 +08:00
f664708165 Optimize GC for motion string parsing. 2023-04-18 10:10:11 +08:00
a7be55f2b0 (Amend to f4411629) 2023-04-18 10:05:14 +08:00
398cec1fc5 Code cleanup. 2023-04-18 09:47:37 +08:00
a8b9ba0af4 Loads ruleset before chart loading. 2023-04-18 09:47:07 +08:00
f54564c567 Unify VecPtComp with Vec1, and VecPt with Vec2. 2023-04-18 09:45:46 +08:00
a2c5850fcd Optimize GC while prehandling. 2023-04-18 09:35:37 +08:00
f4411629e4 Obsolete transition and rate, and add end time for relative motion node. 2023-04-18 09:33:47 +08:00
17d620ff0c Fix error on element/property list is null. (2) 2023-04-14 20:32:00 +08:00
5887b1267a Fix relative node interpolation. 2023-04-14 14:47:07 +08:00
400723d83b Make parameters of relative node optional. 2023-04-14 14:46:03 +08:00
07babcb0ff Fix position and rotation of track anchors not set. 2023-04-14 14:39:48 +08:00
f7bfe07660 Fix multiple init calls on skin components. 2023-04-14 14:32:31 +08:00
3690adf5dd Add component linesec. 2023-04-14 14:31:08 +08:00
48349b598d Separate PolygonSGO to individual file. 2023-04-14 14:29:17 +08:00
d6e3d3ad00 Make clip field in JudgeDefinition dynamic. 2023-04-09 22:13:50 +08:00
c57c82bdd1 Add progress tracking for chart loading. 2023-04-09 22:11:29 +08:00
4bc921d47e Fix error on element/property list is null. 2023-04-08 13:39:00 +08:00
8907dd19b0 Remove methods for constructor in ReflectionHelper. 2023-04-08 13:36:52 +08:00
2221658e7a Fix error when member is not found with string key during PDT interpretation. 2023-04-08 13:34:37 +08:00
916c55b4b2 Fix error when trying to generate PDT error message at the very beginning or end of the source. 2023-04-08 13:31:26 +08:00
3d8a4a64a9 Fix potential order inconsistency of pass and score lists. 2023-04-07 13:56:21 +08:00
6cb36a7064 Clean up logic of object interpretation in PDT interpreter. 2023-04-07 12:21:20 +08:00
1fc5ea8ac6 Resource cleanup. 2023-04-04 22:54:11 +08:00
6fd8e44d10 Update project settings. 2023-04-04 22:12:22 +08:00
ff19b45a9f Code cleanup. 2023-04-04 22:12:10 +08:00
f467832115 Fix logic of lerping a missing relative motion node. 2023-04-04 22:11:36 +08:00
0a25b5260d Restore PDT evaluator exception. 2023-04-04 22:09:57 +08:00
c877437ab6 Fix optimization for collapse operators. 2023-04-04 22:08:38 +08:00
676d19f452 Unify absolute value and relative node of motion event. 2023-04-04 21:18:34 +08:00
fd7c1e6635 Fix constant expression flagging in PDT evaluator. 2023-04-04 20:49:46 +08:00
c98536e8ab Prune and clean up code. 2023-04-04 20:48:17 +08:00
a013d59379 Disable warnings from TextMesh Pro. 2023-04-04 20:40:12 +08:00
2e69035618 Returns whether PDT evaluation succeeded. 2023-04-03 17:00:05 +08:00
072703efe7 Pull up error handling in PDT evaluator. 2023-04-03 16:49:34 +08:00
0c796c4d7a Fix "at anchor" selector not working in effects. 2023-03-30 14:16:25 +08:00
ee4b0c5483 Adjust steps for some settings. 2023-03-30 12:20:49 +08:00
ba7a458e7c Update Cryville.Audio. 2023-03-30 12:20:03 +08:00
06d9df304e Add start offset settings. 2023-03-30 10:37:59 +08:00
578e10bbd7 Update Cryville.Audio. 2023-03-30 10:37:08 +08:00
c685e634d5 Documentation cleanup. 2023-03-27 12:52:58 +08:00
824f401b77 Fix encoding. 2023-03-26 23:25:20 +08:00
aafc326f95 Fix collapse operators not correctly parsed after the scope is downgraded. 2023-03-26 22:40:19 +08:00
88a6410439 Re-enable mipmaps for dynamic sprites. 2023-03-26 17:09:02 +08:00
d6e1b19d32 Prevents dynamically loaded sprites from creating physical shapes. 2023-03-26 17:07:19 +08:00
6fa459e5d3 Update Unity to 2021.3.21. 2023-03-26 17:06:09 +08:00
bde6216295 Optimize GC for enumeration in context cascade insertion. 2023-03-24 20:58:45 +08:00
e03dbef5ff Optimize GC for mesh wrapper. 2023-03-24 17:10:30 +08:00
e2c683567e Introduce IntKeyedDictionary to improve performance. 2023-03-24 17:06:47 +08:00
89f391f040 Update project version. 2023-03-23 19:28:18 +08:00
92a3d5018f Merge 'dev-extension' into 'master'. 2023-03-23 19:25:14 +08:00
d510fec57b Update version. 2023-03-23 19:11:24 +08:00
054b17811d Preserve Convert. 2023-03-22 20:04:32 +08:00
94d5f7f82e Preserve BinaryReader and StreamReader. 2023-03-19 14:13:36 +08:00
0e4445e52b Detects assembly references and determines loading order automatically. 2023-03-18 13:46:13 +08:00
c5214dd477 Update gitignore. 2023-03-17 18:08:11 +08:00
ed2c216cf4 Implement extension. 2023-03-17 18:03:59 +08:00
609645c108 Import HybridCLR. 2023-03-17 18:03:22 +08:00
d280d27a0a Improve error log on resource import failure. 2023-03-17 18:00:46 +08:00
5b727065f3 Adapt conversion for RawChartResource. 2023-03-17 17:59:59 +08:00
7aa2577059 Move UMG importers to extensions. 2023-03-17 17:58:45 +08:00
c1b7e9ab55 Separate extension classes into external assembly. 2023-03-17 17:56:12 +08:00
99384397ed Remove extensions. 2023-03-17 17:49:54 +08:00
a2391aeb22 Cleanup. (Skin editor) 2023-03-15 15:44:32 +08:00
2207c80951 Fix incorrect style for single-statement blocks in expression. 2023-03-15 15:43:30 +08:00
bf578d7cb9 Make statements in expression not sortable. 2023-03-15 15:41:02 +08:00
0bc57c368f Improve scaling logic of popup list in skin editor.. 2023-03-15 15:39:31 +08:00
b64f85aaa2 Add category for expression list in skin editor. 2023-03-15 15:36:45 +08:00
93fa2f2d7e Sync some constants, operators, and functions for skin editor. (3) 2023-03-15 15:34:33 +08:00
d72216de8b Sync some constants, operators, and functions for skin editor. (2) 2023-03-15 10:02:09 +08:00
df5133a91a Sync some constants, operators, and functions for skin editor. 2023-03-15 00:46:19 +08:00
88b959a118 Modify border color of expression statement. 2023-03-15 00:44:44 +08:00
310bf91fbd Always collapses delete button in skin editor. 2023-03-15 00:43:49 +08:00
699f47f98d Fix the height of popup list in skin editor. 2023-03-15 00:43:07 +08:00
24e881b138 Sync component and property list for skin editor. 2023-03-14 23:32:35 +08:00
2eef1b5c4e Update translations for skin editor. 2023-03-14 17:27:05 +08:00
c18ceb50d4 Update skin structure in editor. 2023-03-14 17:24:32 +08:00
27ca1a7292 Implement expression in skin editor. 2023-03-14 17:22:48 +08:00
dc59176eac Fix encoding for skin editor. 2023-03-14 16:59:37 +08:00
aec7470ff8 Optimize css for skin editor. 2023-03-14 16:58:03 +08:00
983cba6843 Detects user chart path for Malody chart finder. 2023-03-11 21:41:54 +08:00
871782e73f Remove potentially buggy syncing logic. 2023-03-11 21:41:22 +08:00
9aaa96fe10 Optimize GC for input proxy. 2023-03-11 21:40:34 +08:00
22190a29c1 Fix incorrect array length for vector operator. 2023-03-11 21:39:26 +08:00
613ca467d0 Fix offset error on function anim. 2023-03-09 22:02:34 +08:00
536a3066b2 Fix array operator creating array of type error. 2023-03-09 16:27:16 +08:00
43488cd002 Add "emit effect on self" annotation. 2023-03-09 16:26:43 +08:00
a11ccbd39c Cleanup variable name. 2023-03-09 11:41:25 +08:00
76df4929a7 Implement set variable annotation. 2023-03-09 11:38:49 +08:00
505b826627 Move up non-generic collection types and add debug view. 2023-03-09 11:37:23 +08:00
26a8675922 Make animation time of subspan relative. 2023-03-09 10:07:24 +08:00
b89e1f983e Code cleanup. 2023-03-08 20:36:18 +08:00
717e77b47e Fix inaccurate beat snapping for Quaver charts. 2023-03-06 08:16:42 +08:00
2f10c79dee Adjust offset for osu chart converter. 2023-03-05 23:06:18 +08:00
55f7790f89 Fix potential error on vector property source. 2023-03-05 23:05:48 +08:00
ae5f4a8c16 (Amend to 1851bd3c) 2023-03-05 21:53:30 +08:00
1851bd3c54 Fix inaccurate beat snapping for osu charts. Fix osu charts with too low BPM not able to be imported. 2023-03-05 20:40:02 +08:00
6d74685cb7 Add anim.iteration, anim.direction, and anim.delay properties. 2023-03-03 15:10:52 +08:00
03fd7f6d01 Add inf constant. 2023-03-03 15:09:08 +08:00
28c878f3e5 Code cleanup. 2023-03-03 13:34:12 +08:00
7736eba14d Supplement generic PairCollection. 2023-03-03 13:26:11 +08:00
2e54b38d2b Supplement Insert methods for pair list. 2023-03-03 11:49:32 +08:00
da60dc0903 Fix potential order inconsistency of element and property lists. 2023-03-03 11:45:16 +08:00
215f72b3b5 Add cubic bezier functions. 2023-03-02 10:40:18 +08:00
a93c081dd8 Add easing function parameter to anim function. 2023-03-02 10:39:39 +08:00
456782930a Fix incorrect zero format specifier range. 2023-03-01 17:55:09 +08:00
ba3cbbd64c Add state-based effect. 2023-03-01 00:37:22 +08:00
dfc3e9ca06 Refactor OpenedAnchorName in ISkinnableGroup. (Amend) 2023-03-01 00:36:09 +08:00
f567a2b78e Fix error on setting anim.name to null. 2023-03-01 00:35:19 +08:00
c7e7bd8a77 Add Identifier.Empty. 2023-03-01 00:33:28 +08:00
67720fd0e1 Refactor OpenedAnchorName in ISkinnableGroup. 2023-03-01 00:33:01 +08:00
1a30149942 Prevents infinite propagation on input proxy and judge. 2023-02-28 13:47:38 +08:00
a755cc13bd Implement animation. 2023-02-27 00:17:14 +08:00
9a51cf1b56 Add rewind and tick mechanism for skin component. 2023-02-27 00:16:44 +08:00
256c656e9c Fix once annotation not working on certain properties. 2023-02-27 00:13:38 +08:00
2ac7f05316 Add contextual function anim. 2023-02-27 00:11:37 +08:00
28d46dbabe Disallows multiple meshes in one object. 2023-02-26 16:24:58 +08:00
18b3e0bc84 Code cleanup. 2023-02-26 16:24:28 +08:00
23f2e7c1f2 Fix multiple flags ignored in enum property operator. 2023-02-26 16:23:17 +08:00
998713b41f Pull some init logic in enum property operator to static constructor. 2023-02-26 16:22:37 +08:00
3561354231 Implement execute once annotation on properties. 2023-02-26 16:21:33 +08:00
0cccb170c1 Support extra annotations on skin property key. Code cleanup. 2023-02-26 16:20:25 +08:00
d2480b8a6f Update global suppressions. 2023-02-26 16:16:46 +08:00
6837d3f7ee Make the group in skin container readonly. 2023-02-24 15:25:04 +08:00
3ecf3b4bfc Code cleanup. 2023-02-21 22:47:42 +08:00
1da8647ff1 Re-add start offset stub. 2023-02-21 22:47:24 +08:00
2f19e8daad Add limit for render distance settings. 2023-02-21 22:45:51 +08:00
07f62c7aeb Reduce font size for extra tag in input config. 2023-02-21 22:43:38 +08:00
39db8dfa45 Code cleanup. 2023-02-21 18:43:21 +08:00
f04cd370f1 Allow vector as number in contextual operators. 2023-02-21 18:42:58 +08:00
5c4acd54ce Add ticking stub for effect. 2023-02-21 18:42:03 +08:00
82dbc5c479 Add event property for event. 2023-02-21 18:41:32 +08:00
1f1663d714 Rename index to effect_index. 2023-02-21 18:29:25 +08:00
a3c5392caa Optimize GC for vector property source. 2023-02-21 18:27:29 +08:00
6c983cc2cb Add backward compatibility for opacity property. 2023-02-19 22:44:12 +08:00
3bf3fdac3d Code cleanup. 2023-02-19 22:15:46 +08:00
f2f3dba098 Fix effect queue with multiple items of the same instance. 2023-02-19 22:15:25 +08:00
3728360dd2 Fix index invalidation for effects. 2023-02-19 22:13:57 +08:00
887837bb3d Fix main thread stuck on texture missing. 2023-02-19 22:13:18 +08:00
99b4c2dfc1 Fix error on text frame update if texture not found. 2023-02-19 22:11:59 +08:00
e59769158a Change materials to shared mode in components. 2023-02-19 22:08:09 +08:00
ba3238614b Pull up mesh.color. Remove *.opacity properties. 2023-02-19 22:06:20 +08:00
a115999aab Add additive shader. 2023-02-19 21:57:06 +08:00
393947db9f Add image.shader property. 2023-02-19 21:56:30 +08:00
e9b2a7f894 Fix error on dynamic expressions in static context. 2023-02-19 21:55:01 +08:00
9c73455761 Fix error on appending arg set when current length equals to capacity in string formatter. 2023-02-19 11:07:50 +08:00
59c2210359 Prevents dimension-unapplicable inputs from being assigned. 2023-02-18 15:51:21 +08:00
4fab20953a Improve text hints in input config. 2023-02-18 15:49:45 +08:00
ee7b0f5081 Make pause input optional. 2023-02-18 15:48:02 +08:00
33ee7a9a87 Code cleanup. 2023-02-18 15:46:32 +08:00
900bd7b77a Implement effect. 2023-02-18 14:51:28 +08:00
6bd32c9aef Add context cascade blocking. 2023-02-18 14:48:43 +08:00
13893b2853 Add execute once annotation. 2023-02-18 14:48:09 +08:00
23789c15eb Pull up material disposal to MeshBase. (Amend) 2023-02-18 14:46:38 +08:00
a1f7418d32 Code cleanup. 2023-02-18 14:46:08 +08:00
274a823d02 Fix log not cleared on log toggle. 2023-02-18 14:44:05 +08:00
ba6239068a Optimize GC for sprite update. 2023-02-18 14:42:42 +08:00
ff8c925f32 Optimize GC for setting image.frame. 2023-02-18 14:40:56 +08:00
2a6a33e60c Pull up material disposal to MeshBase. 2023-02-18 14:39:45 +08:00
8910b1f4a0 Allow dynamic anchor reset. 2023-02-17 23:14:51 +08:00
36dddea4d9 Code cleanup. 2023-02-17 21:13:19 +08:00
6a648c2dcd Fix error on image.frame(s) not set. 2023-02-17 21:12:41 +08:00
2d4087dc89 Fix behaviour on parameter overflow. 2023-02-17 21:11:38 +08:00
f91aacd78e Code cleanup. 2023-02-17 18:11:04 +08:00
9c08cbf0d2 Remove some dedicated properties on ISkinnableGroup. 2023-02-17 18:10:46 +08:00
88d35e4eaf Add backward compatibility for skin. (Amend) 2023-02-17 16:27:49 +08:00
675ce68073 Add backward compatibility for skin. 2023-02-17 16:24:24 +08:00
db0165d145 Pull up ISkinnableGroup. 2023-02-17 15:19:18 +08:00
7015426300 Add error handling for setting text.frames. 2023-02-17 14:41:12 +08:00
0d4cc5e208 Add skin property image.frames and image.index. 2023-02-17 14:40:34 +08:00
e7ce0985fb Add effect emitting stub. 2023-02-15 18:13:04 +08:00
eb6dafbd60 Add animation stub and effect stub for skin. 2023-02-15 18:12:41 +08:00
b6e238780e Change fixed skin root to configurable root element in skin container. 2023-02-15 18:09:21 +08:00
c7ea6f1d4b Cleanup logic of PDT interpreter. 2023-02-15 18:07:36 +08:00
4a5b2a6889 Add effect definition. 2023-02-15 15:35:09 +08:00
b84d645aee Pull up PdtBinder. 2023-02-15 15:34:27 +08:00
67b44db1ae Code cleanup. 2023-02-13 16:09:19 +08:00
ee4399109a Optimize GC for log in gameplay scene. 2023-02-12 21:50:57 +08:00
87ef534f59 Fix resize logic in StringBuffer. 2023-02-12 21:48:39 +08:00
87362b47c5 Cleanup CategorizedPool. 2023-02-12 17:27:54 +08:00
f60ba1088d Fix input conflict in input config. 2023-02-12 17:27:15 +08:00
abb7ad6f24 Adjust offset for osu chart converter. 2023-02-11 23:13:30 +08:00
880b475c07 Update project version. 2023-02-11 23:12:01 +08:00
4707c40e6a Add object pool related debug status info. 2023-02-11 23:11:45 +08:00
7f87c23da2 Fix contextual state variables available in static context. 2023-02-11 23:11:15 +08:00
6df10837fe Eliminate Array.Copy GC in SquareMatrix. 2023-02-11 23:09:46 +08:00
42cb54de1d Add RentedCount for ObjectPool. 2023-02-11 23:09:05 +08:00
9fd685b8b3 Pull up CategorizedPool. Add Reset method for ObjectPool. 2023-02-11 23:08:43 +08:00
b364005741 Update UnsafeIL. 2023-02-10 17:52:45 +08:00
7d938de409 Code cleanup. 2023-02-10 17:36:36 +08:00
bb4ecfcd8c Add graphical offset global settings. 2023-02-10 17:36:19 +08:00
ff410529b0 Add invisible_bounds contextual variable. 2023-02-10 17:35:36 +08:00
fdc55a8e3b Pull current_time to container handler. 2023-02-10 17:34:40 +08:00
fc8512ff63 Combine score and score string property sources. 2023-02-10 17:32:59 +08:00
1b1ed42a1b Code cleanup. 2023-02-10 15:50:49 +08:00
b437925f92 Replace TrustedAsOfLength with safe As and Set. 2023-02-10 15:47:20 +08:00
c04e50e959 Modify priority logic for normal/temporary events. 2023-02-09 18:22:39 +08:00
314cdb9935 Implement transform update for static judge anchor. 2023-02-09 18:21:17 +08:00
77c91d015a Add standalone event property. 2023-02-09 18:20:36 +08:00
291a018c13 Activates anchors only on set. 2023-02-09 18:19:46 +08:00
18ff4b8e16 Code cleanup. 2023-02-09 18:18:34 +08:00
7714c277fd Modify text in status debug info. 2023-02-09 18:14:07 +08:00
d6c2ac6be6 Fix TypedChildren shared across ContainerState. 2023-02-09 18:12:33 +08:00
682fe38d40 Fix priority for manually set special anchors. 2023-02-09 18:11:32 +08:00
3e525842cb Modify texts in input config panel. 2023-02-09 18:09:40 +08:00
3dd25b51a8 Fix wrong context access in component creation. 2023-02-09 18:08:12 +08:00
041c1e374e Optimize GC for frame calculation. 2023-02-09 18:07:06 +08:00
16b1d323dc Add exception handling for invalid key interpretation in PDT. 2023-02-09 12:21:41 +08:00
c4d5e5f480 Matches member name first then generic list in PDT. 2023-02-09 12:15:07 +08:00
187f07d2c9 Optimize GC for motions. 2023-02-07 23:15:52 +08:00
4e9d7e5b87 Optimize GC for SectionalGameObject. 2023-02-07 23:15:11 +08:00
7df5b15e2e Animation cleanup. 2023-02-07 16:36:17 +08:00
4863aa0ae7 Add persist in judge definition. 2023-02-07 16:24:27 +08:00
eb53c3465b Implement pausing. 2023-02-07 16:23:16 +08:00
f683d61298 Reorganize resources. 2023-02-07 14:20:47 +08:00
fbd03c8037 Add sound offset for ruleset config. 2023-02-06 22:55:43 +08:00
da68c8b877 Move ruleset config to main scene. Add title for UI. 2023-02-06 22:55:14 +08:00
c0744a3464 Add interval function. 2023-02-06 15:16:35 +08:00
3ca3746cec Fix judge passing for inputs without any events. 2023-02-06 15:16:02 +08:00
5e76ddf2cd Fix use of discarded digits in rounded numbers in string formatter. 2023-02-06 15:14:54 +08:00
dca1ba304e Code cleanup. 2023-02-05 23:01:46 +08:00
8dd32afb74 Prevents dynamic anchor set twice. Implement special dynamic anchors. 2023-02-05 22:13:44 +08:00
313824b4bb Fix abnormal shaking at dynamic anchor. 2023-02-05 22:12:47 +08:00
b166c0f5ef Fix overflowed integral digits always prepended in string formatter. 2023-02-05 22:03:31 +08:00
300e44bd4b Code cleanup. 2023-02-05 15:59:20 +08:00
ab6f983392 Implement meta table for font. 2023-02-05 15:59:12 +08:00
596c6395e4 Prevent non-Windows system trying to initialize WindowsPointerHandler. 2023-02-05 15:58:31 +08:00
404a36f9b8 Replace text components in the main browser with TMP. 2023-02-05 15:56:56 +08:00
1711fbadf7 Add fallback logic for TMP auto font. 2023-02-05 15:55:53 +08:00
84b7a6d183 Seperate matcher from font manager. 2023-02-05 15:53:30 +08:00
6d0fd0f9ec Support multiple fonts with the same full name. 2023-02-05 15:51:18 +08:00
b407ba88c4 Add system font matcher. 2023-02-02 18:35:18 +08:00
bd256ba1a6 Reimport upgraded TextMesh Pro, modified. 2023-02-01 22:14:43 +08:00
623c53f79a Cleanup. 2023-01-31 22:56:19 +08:00
969fdc8069 Optimize GC for status info. 2023-01-31 22:56:06 +08:00
cbc874dd72 Optimize GC for proxied input variables. 2023-01-31 22:51:17 +08:00
450bd52095 Implement dynamic stack for skin. 2023-01-31 22:50:24 +08:00
5727fcf177 Introduce UnsafeIL for IL2CPP compatibility. 2023-01-31 22:49:04 +08:00
8ab0c2698b Fix TargetString stuck when length was 0. Add TargetString.TrustedAsArray. 2023-01-31 22:47:35 +08:00
6c7b52d93c Import TextMesh Pro. 2023-01-31 22:44:54 +08:00
91f55cd9a3 Add state count debug info. 2023-01-31 15:54:46 +08:00
a1ce459a0e Restructure event/container system. 2023-01-31 15:53:43 +08:00
9700992c3a Add DisposeAll. 2023-01-31 15:39:40 +08:00
f9a1ea72fe Refactor ReleaseEvent. 2023-01-31 15:30:27 +08:00
507b656eab Pull up StampedEvent.Temporary. Fix temporary event discarding. 2023-01-31 15:26:13 +08:00
c16776aee9 Code cleanup. (Amend) 2023-01-31 15:18:24 +08:00
e109e0bd24 Separate dynamic anchors. 2023-01-31 15:15:13 +08:00
776a615464 Code cleanup. 2023-01-31 15:06:31 +08:00
5514b6cf37 Pull up clip from judge definition. Add clip to event container. 2023-01-31 14:55:41 +08:00
8932d1b8d0 Add current_time variable. 2023-01-28 11:58:13 +08:00
10988847b3 Implement anchor related annotations. 2023-01-28 11:57:49 +08:00
c4b139c7a4 Code cleanup. 2023-01-27 17:30:10 +08:00
130896df1f Fix SkinSelectors.ToString. (2) 2023-01-27 16:54:11 +08:00
5d5c519a1d Remove dynamic judge anchors. (Amend) 2023-01-27 16:41:40 +08:00
3d1a11f78b Remove dynamic judge anchors. Add judge time properties. 2023-01-27 16:05:57 +08:00
cc985844cd Optimize GC for identifier and beat time property source. 2023-01-27 16:03:27 +08:00
feffbaa5a6 Refactor SkinPropertyKey. 2023-01-27 15:31:51 +08:00
d0f0c8ce6d Fix SkinSelectors.ToString. 2023-01-27 15:28:22 +08:00
3fdc236b1d Fix EmptyBinder not identifying inheritance. 2023-01-27 15:24:48 +08:00
46870e163a Code cleanup. 2023-01-26 18:12:22 +08:00
601f64cc61 Introduce no GC string formatter to optimize score string formatting. 2023-01-26 16:52:05 +08:00
c015b60dc3 Code cleanup. 2023-01-26 16:47:56 +08:00
5e01b654bd Optimize GC for enumerating TargetString. 2023-01-26 16:46:43 +08:00
2304257201 Add exception description on PDT parsing error. 2023-01-24 23:10:52 +08:00
02794d88b9 Fix config scene stuck on ruleset format error. 2023-01-22 22:29:16 +08:00
9f73c8ffad Code cleanup. 2023-01-21 20:14:41 +08:00
c1c354959d Add MotionCache. 2023-01-21 20:13:40 +08:00
94428d9e18 Append IDE warning suppression. 2023-01-21 20:12:03 +08:00
5198ecec1f Optimize code structure for input module. 2023-01-21 17:04:29 +08:00
6779b88055 Code cleanup. 2023-01-21 16:59:19 +08:00
c5dab3a232 Refactor SelectorNotAvailableException. 2023-01-20 22:50:31 +08:00
a7608bcd7e Matches dynamic on anchoring. 2023-01-20 22:50:05 +08:00
be64bc76b5 Revert "Revise update clone type to update depth."
This reverts commit 4185303bd2.
2023-01-20 22:26:56 +08:00
39bc34fd42 Fix dynamic judge anchors not updated if note is not working. 2023-01-17 22:16:40 +08:00
4185303bd2 Revise update clone type to update depth. 2023-01-17 22:16:09 +08:00
3280693e8f Update project version. 2023-01-16 22:11:19 +08:00
29432feabc Fix error on "(at) anchor" selector when no anchor is opened. 2023-01-16 20:57:19 +08:00
86559c681e Fix relative time calculation in judge report. 2023-01-16 20:55:32 +08:00
79f11b9c33 Implement judge_result contextual variable. 2023-01-16 20:54:53 +08:00
5b9149cb34 Make the output type of a property source read-only. 2023-01-16 20:53:45 +08:00
9d6bdd968f Implement write-only context. 2023-01-16 20:50:14 +08:00
bc4fec33ef Add null constant. 2023-01-16 20:47:54 +08:00
09e917dbe8 Add is function. 2023-01-16 20:46:57 +08:00
1003a0e199 Add forced variable syntax in PDT. 2023-01-16 20:45:06 +08:00
e3a805b855 Implement skin context property source injection. 2023-01-16 15:23:57 +08:00
4222176979 Add temporary event discard handling. 2023-01-16 15:09:34 +08:00
43c87fba70 Wrap Transform into SkinContext. Implement r/w context separation for skins. 2023-01-16 15:08:25 +08:00
d0a23aaf30 Add static judge anchor. Change dynamic anchors to single only. 2023-01-16 13:35:51 +08:00
a09a5686d7 Change anchor opening to single only. 2023-01-16 13:33:25 +08:00
609bb317d0 Code cleanup. 2023-01-15 11:54:11 +08:00
898fb7d557 Pull down chart field from StateBase. 2023-01-15 11:52:28 +08:00
c39f258a19 Code cleanup. 2023-01-14 22:03:08 +08:00
4fdd4e1935 Implement multiple static matching. 2023-01-14 22:01:29 +08:00
7662011d60 Pull down some judge preparation logic. 2023-01-14 21:39:10 +08:00
c24372b308 Pull up tail anchoring. 2023-01-14 21:35:15 +08:00
5e4c53113a Revise anchor data structure. 2023-01-14 21:34:13 +08:00
4f93995bbd Pull down EvaluationFailureException. 2023-01-13 22:18:13 +08:00
5b14466059 Add error handling for Discord callback. 2023-01-13 22:16:16 +08:00
1d3aa85446 Fix polysec.part. Enable judge anchor. 2023-01-13 16:46:29 +08:00
6efe70d751 Implement coevent. (2) 2023-01-13 16:37:31 +08:00
555c88855c Adapt Bestdori chart converter to coevents. 2023-01-12 18:05:20 +08:00
105aacc133 Fix config scene not unloaded if the ruleset is not present. 2023-01-10 21:41:48 +08:00
ea9000f2b0 Cleanup. 2023-01-09 22:17:42 +08:00
4e851d9b73 Implement coevent. 2023-01-09 16:28:36 +08:00
0a1e512f41 Code cleanup. 2023-01-08 16:27:02 +08:00
a7baef2c9d Add NoRequireDiscord flag when initializing Discord GameSDK. 2023-01-08 13:00:35 +08:00
723ec937ad Remove callback parameters on states. 2023-01-03 12:09:16 +08:00
7c77ba83f8 Fix polysec not mapping textures correctly if texture set partly. 2023-01-03 11:58:39 +08:00
6da4b96b24 Optimize motion invalidation performance. 2023-01-02 20:05:14 +08:00
1181 changed files with 118977 additions and 36812 deletions

View File

@@ -1,6 +1,9 @@
# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true
[*]
charset = utf-8
# C# files
[*.cs]

1
.gitignore vendored
View File

@@ -68,3 +68,4 @@ crashlytics-build.properties
/UserSettings
/*.zip
*.lnk
/HybridCLRData

Binary file not shown.

View File

@@ -0,0 +1,431 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: IConfig
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.016666668
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Contents/Config
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.016666668
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Contents/MainContents
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.016666668
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: SettingsOverlay
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.016666668
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Settings/OverlayBack
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: -1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.016666668
value: -1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMin.x
path: Contents
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.016666668
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMax.x
path: Contents
classID: 224
script: {fileID: 0}
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 1063882198
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 512889948
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 135068749
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 3949350096
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 1301050145
attribute: 2089119715
script: {fileID: 0}
typeID: 224
customType: 28
isPPtrCurve: 0
- serializedVersion: 2
path: 1301050145
attribute: 2711263438
script: {fileID: 0}
typeID: 224
customType: 28
isPPtrCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.016666668
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.016666668
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Contents/Config
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.016666668
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Contents/MainContents
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.016666668
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: SettingsOverlay
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.016666668
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Settings/OverlayBack
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: -1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.016666668
value: -1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMin.x
path: Contents
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.016666668
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMax.x
path: Contents
classID: 224
script: {fileID: 0}
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2e0c61e29fd90f04b9e41265d93e2029
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,305 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: TConfig_Main
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.33333334
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Contents/Config
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.33333334
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Contents/MainContents
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMax.x
path: Contents
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: -1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMin.x
path: Contents
classID: 224
script: {fileID: 0}
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 1063882198
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 512889948
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 1301050145
attribute: 2711263438
script: {fileID: 0}
typeID: 224
customType: 28
isPPtrCurve: 0
- serializedVersion: 2
path: 1301050145
attribute: 2089119715
script: {fileID: 0}
typeID: 224
customType: 28
isPPtrCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.33333334
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.33333334
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Contents/Config
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.33333334
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Contents/MainContents
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMax.x
path: Contents
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: -1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMin.x
path: Contents
classID: 224
script: {fileID: 0}
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d815e4d844e6a1c4d849e96e199f8881
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,224 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: TMain_Config
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: -1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMin.x
path: Contents
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMax.x
path: Contents
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Contents/Config
classID: 1
script: {fileID: 0}
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 1301050145
attribute: 2089119715
script: {fileID: 0}
typeID: 224
customType: 28
isPPtrCurve: 0
- serializedVersion: 2
path: 1301050145
attribute: 2711263438
script: {fileID: 0}
typeID: 224
customType: 28
isPPtrCurve: 0
- serializedVersion: 2
path: 1063882198
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.33333334
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: -1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMin.x
path: Contents
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_AnchorMax.x
path: Contents
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Contents/Config
classID: 1
script: {fileID: 0}
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 82867c59112ff5a419fbea2ebff2d3b9
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,368 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: TSettings_
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: SettingsOverlay
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Settings
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 0.88
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Pivot.y
path: Settings
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0.5019608
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.a
path: SettingsOverlay
classID: 114
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.33333334
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Settings/OverlayBack
classID: 1
script: {fileID: 0}
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 135068749
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 473154195
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 473154195
attribute: 2952582672
script: {fileID: 0}
typeID: 224
customType: 28
isPPtrCurve: 0
- serializedVersion: 2
path: 135068749
attribute: 304273561
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
typeID: 114
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 3949350096
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.33333334
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: SettingsOverlay
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Settings
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 0.88
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Pivot.y
path: Settings
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0.5019608
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.a
path: SettingsOverlay
classID: 114
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.33333334
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Settings/OverlayBack
classID: 1
script: {fileID: 0}
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,368 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: T_Settings
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0.88
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Pivot.y
path: Settings
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Settings
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: SettingsOverlay
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 0.5019608
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.a
path: SettingsOverlay
classID: 114
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.33333334
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Settings/OverlayBack
classID: 1
script: {fileID: 0}
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 473154195
attribute: 2952582672
script: {fileID: 0}
typeID: 224
customType: 28
isPPtrCurve: 0
- serializedVersion: 2
path: 135068749
attribute: 304273561
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
typeID: 114
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 3949350096
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 473154195
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 135068749
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.33333334
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0.88
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Pivot.y
path: Settings
classID: 224
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Settings
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: SettingsOverlay
classID: 1
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.33333334
value: 0.5019608
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.a
path: SettingsOverlay
classID: 114
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.33333334
value: 1
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Settings/OverlayBack
classID: 1
script: {fileID: 0}
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,4 @@
using System;
using System;
namespace Cryville.Common {
/// <summary>

View File

@@ -13,7 +13,7 @@ namespace Cryville.Common {
public static Binder CreateBinderOfType(Type type) {
var l = type.GetCustomAttributes(typeof(BinderAttribute), true);
if (l.Length > 0) {
return (Binder)ReflectionHelper.InvokeEmptyConstructor(
return (Binder)Activator.CreateInstance(
((BinderAttribute)l[0]).BinderType
);
}
@@ -33,12 +33,12 @@ namespace Cryville.Common {
public override object ChangeType(object value, Type type, CultureInfo culture) {
if (value == null)
return null;
else if (type == value.GetType())
else if (type.IsAssignableFrom(value.GetType()))
return value;
else if (type.IsEnum && value is string) {
return Enum.Parse(type, (string)value);
}
throw new InvalidCastException();
throw new InvalidCastException(string.Format("Cannot cast {0} to {1}", value.GetType(), type));
}
public override void ReorderArgumentArray(ref object[] args, object state) {

View File

@@ -1,65 +0,0 @@
namespace Cryville.Common.Buffers {
/// <summary>
/// A resource pool that allows reusing instances of arrays of type <typeparamref name="T" />.
/// </summary>
/// <typeparam name="T">The item type of the arrays in the pool.</typeparam>
public class ArrayPool<T> {
private class Bucket : ObjectPool<T[]> {
readonly int _size;
public Bucket(int size, int capacity) : base(capacity) {
_size = size;
}
protected override T[] Construct() {
return new T[_size];
}
}
readonly Bucket[] _buckets;
/// <summary>
/// Creates an instance of the <see cref="ArrayPool{T}" /> class with the default maximum list size and bucket capacity.
/// </summary>
public ArrayPool() : this(0x40000000, 256) { }
/// <summary>
/// Creates an instance of the <see cref="ArrayPool{T}" /> class.
/// </summary>
/// <param name="maxSize">The maximum size of the arrays in the pool.</param>
/// <param name="capacityPerBucket">The capacity of each bucket. The pool groups arrays of similar sizes into buckets for faster access.</param>
public ArrayPool(int maxSize, int capacityPerBucket) {
if (maxSize < 16) maxSize = 16;
int num = GetID(maxSize) + 1;
_buckets = new Bucket[num];
for (int i = 0; i < num; i++) {
_buckets[i] = new Bucket(GetSize(i), capacityPerBucket);
}
}
/// <summary>
/// Rents an array that is at least the specified size from the pool.
/// </summary>
/// <param name="size">The minimum size of the array.</param>
/// <returns>An array of type <see cref="T" /> that is at least the specified size.</returns>
public T[] Rent(int size) {
int len2 = size;
if (len2 < 16) len2 = 16;
var arr = _buckets[GetID(len2)].Rent();
return arr;
}
/// <summary>
/// Returns a rented array to the pool.
/// </summary>
/// <param name="arr">The array to return.</param>
public void Return(T[] arr) {
int len2 = arr.Length;
if (len2 < 16) len2 = 16;
_buckets[GetID(len2)].Return(arr);
}
static int GetID(int size) {
size -= 1;
size >>= 4;
int num = 0;
for (; size != 0; size >>= 1) num++;
return num;
}
static int GetSize(int id) {
return 0x10 << id;
}
}
}

View File

@@ -1,71 +0,0 @@
using System.Collections.Generic;
namespace Cryville.Common.Buffers {
/// <summary>
/// A resource pool that allows reusing instances of lists of type <typeparamref name="T" />.
/// </summary>
/// <typeparam name="T">The item type of the lists in the pool.</typeparam>
public class ListPool<T> {
private class Bucket : ObjectPool<List<T>> {
readonly int _size;
public Bucket(int size, int capacity) : base(capacity) {
_size = size;
}
protected override List<T> Construct() {
return new List<T>(_size);
}
}
readonly Bucket[] _buckets;
/// <summary>
/// Creates an instance of the <see cref="ListPool{T}" /> class with the default maximum list size and bucket capacity.
/// </summary>
public ListPool() : this(0x40000000, 256) { }
/// <summary>
/// Creates an instance of the <see cref="ListPool{T}" /> class.
/// </summary>
/// <param name="maxSize">The maximum size of the lists in the pool.</param>
/// <param name="capacityPerBucket">The capacity of each bucket. The pool groups lists of similar sizes into buckets for faster access.</param>
public ListPool(int maxSize, int capacityPerBucket) {
if (maxSize < 16) maxSize = 16;
int num = GetID(maxSize) + 1;
_buckets = new Bucket[num];
for (int i = 0; i < num; i++) {
_buckets[i] = new Bucket(GetSize(i), capacityPerBucket);
}
}
/// <summary>
/// Rents a list of the specified size from the pool. The size of the list must not be changed when it is rented.
/// </summary>
/// <param name="size">The size of the list.</param>
/// <returns>A <see cref="List{T}" /> of the specified size.</returns>
public List<T> Rent(int size) {
int len2 = size;
if (len2 < 16) len2 = 16;
var list = _buckets[GetID(len2)].Rent();
if (list.Count < size)
for (int i = list.Count; i < size; i++) list.Add(default(T));
else if (list.Count > size)
list.RemoveRange(size, list.Count - size);
return list;
}
/// <summary>
/// Returns a rented list to the pool.
/// </summary>
/// <param name="list">The list to return.</param>
public void Return(List<T> list) {
int len2 = list.Capacity;
if (len2 < 16) len2 = 16;
_buckets[GetID(len2)].Return(list);
}
static int GetID(int size) {
size -= 1;
size >>= 4;
int num = 0;
for (; size != 0; size >>= 1) num++;
return num;
}
static int GetSize(int id) {
return 0x10 << id;
}
}
}

View File

@@ -1,42 +0,0 @@
namespace Cryville.Common.Buffers {
/// <summary>
/// A resource pool that allows reusing instances of type <typeparamref name="T" />.
/// </summary>
/// <typeparam name="T">The type of the objects in the pool.</typeparam>
public abstract class ObjectPool<T> where T : class {
int _index;
readonly T[] _objs;
/// <summary>
/// Creates an instance of the <see cref="ObjectPool{T}" /> class.
/// </summary>
/// <param name="capacity">The capacity of the pool.</param>
public ObjectPool(int capacity) {
_objs = new T[capacity];
}
/// <summary>
/// Rents a object from the pool.
/// </summary>
/// <returns>The rented object.</returns>
public T Rent() {
T obj = null;
if (_index < _objs.Length) {
obj = _objs[_index];
_objs[_index++] = null;
}
if (obj == null) obj = Construct();
return obj;
}
/// <summary>
/// Returns a rented object to the pool.
/// </summary>
/// <param name="obj">The object to return.</param>
public void Return(T obj) {
if (_index > 0) _objs[--_index] = obj;
}
/// <summary>
/// Constructs a new instance of type <typeparamref name="T" />.
/// </summary>
/// <returns>The new instance.</returns>
protected abstract T Construct();
}
}

View File

@@ -1,16 +0,0 @@
namespace Cryville.Common.Buffers {
/// <summary>
/// A resource pool that allows reusing instances of type <typeparamref name="T" />, which has a parameterless constructor.
/// </summary>
/// <typeparam name="T">The type of the objects in the pool.</typeparam>
public class SimpleObjectPool<T> : ObjectPool<T> where T : class, new() {
/// <summary>
/// Creates an instance of the <see cref="SimpleObjectPool{T}" /> class.
/// </summary>
/// <param name="capacity">The capacity of the pool.</param>
public SimpleObjectPool(int capacity) : base(capacity) { }
protected override T Construct() {
return new T();
}
}
}

View File

@@ -1,120 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace Cryville.Common.Buffers {
/// <summary>
/// An auto-resized <see cref="char" /> array as a variable-length string used as a target that is modified frequently.
/// </summary>
public class TargetString : IEnumerable<char> {
public event Action OnUpdate;
char[] _arr;
bool _invalidated;
/// <summary>
/// Creates an instance of the <see cref="TargetString" /> class with a capacity of 16.
/// </summary>
public TargetString() : this(16) { }
/// <summary>
/// Creates an instance of the <see cref="TargetString" /> class.
/// </summary>
/// <param name="capacity">The initial capacity of the string.</param>
public TargetString(int capacity) {
_arr = new char[capacity];
}
/// <summary>
/// Gets or sets one of the characters in the string.
/// </summary>
/// <param name="index">The zero-based index of the character.</param>
/// <returns>The character at the given index.</returns>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="index" /> is less than 0 or not less than <see cref="Length" />.</exception>
/// <remarks>
/// <para>Set <see cref="Length" /> to a desired value before updating the characters.</para>
/// <para>Call <see cref=" Validate" /> after all the characters are updated.</para>
/// </remarks>
public char this[int index] {
get {
if (index < 0 || index >= m_length)
throw new ArgumentOutOfRangeException("index");
return _arr[index];
}
set {
if (index < 0 || index >= m_length)
throw new ArgumentOutOfRangeException("index");
if (_arr[index] == value) return;
_arr[index] = value;
_invalidated = true;
}
}
int m_length;
/// <summary>
/// The length of the string.
/// </summary>
public int Length {
get {
return m_length;
}
set {
if (m_length == value) return;
if (_arr.Length < value) {
var len = m_length;
while (len < value) len *= 2;
var arr2 = new char[len];
Array.Copy(_arr, arr2, m_length);
_arr = arr2;
}
m_length = value;
_invalidated = true;
}
}
/// <summary>
/// Validates the string.
/// </summary>
public void Validate() {
if (!_invalidated) return;
_invalidated = false;
var ev = OnUpdate;
if (ev != null) ev.Invoke();
}
IEnumerator IEnumerable.GetEnumerator() {
return GetEnumerator();
}
public IEnumerator<char> GetEnumerator() {
return new Enumerator(this);
}
class Enumerator : IEnumerator<char> {
readonly TargetString _self;
int _index = -1;
public Enumerator(TargetString self) { _self = self; }
public char Current {
get {
if (_index < 0)
throw new InvalidOperationException(_index == -1 ? "Enum not started" : "Enum ended");
return _self[_index];
}
}
object IEnumerator.Current { get { return Current; } }
public void Dispose() {
_index = -2;
}
public bool MoveNext() {
if (_index == -2) return false;
_index++;
if (_index >= _self.Length) {
_index = -2;
return false;
}
return true;
}
public void Reset() {
_index = -1;
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: f0fc34ac257793d4883a9cfcdb6941b9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,4 +1,4 @@
using System;
using System;
namespace Cryville.Common.ComponentModel {
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]

View File

@@ -1,4 +1,4 @@
using System;
using System;
namespace Cryville.Common.ComponentModel {
[AttributeUsage(AttributeTargets.Property, Inherited = false)]

View File

@@ -1,4 +1,4 @@
using System;
using System;
namespace Cryville.Common.ComponentModel {
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]

View File

@@ -1,4 +1,4 @@
using System;
using System;
namespace Cryville.Common.ComponentModel {
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]

View File

@@ -0,0 +1,26 @@
using System.Collections.Generic;
using System.Diagnostics;
namespace Cryville.Common {
public class Coroutine {
readonly IEnumerator<float> _enumerator;
readonly Stopwatch _stopwatch = new Stopwatch();
public float Progress { get; private set; }
public Coroutine(IEnumerator<float> enumerator) {
_enumerator = enumerator;
}
public bool TickOnce() {
if (!_enumerator.MoveNext()) return false;
Progress = _enumerator.Current;
return true;
}
public bool Tick(double minTime) {
_stopwatch.Restart();
while (_stopwatch.Elapsed.TotalSeconds < minTime) {
if (!_enumerator.MoveNext()) return false;
Progress = _enumerator.Current;
}
return true;
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 2745c44c3cc32be4ab3a43888c14b9a1
guid: 387adc7d494be0147b7cb930bc2e726b
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 53f4e3167a1eee2478b0abc6302aee8f
guid: 520554ce9a8205b4b91e0ff2b8011673
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace Cryville.Common.Culture {
public static class ScriptUtils {
public static string[] Scripts = new string[] { "adlm", "afak", "aghb", "ahom", "arab", "aran", "armi", "armn", "avst", "bali", "bamu", "bass", "batk", "beng", "bhks", "blis", "bopo", "brah", "brai", "bugi", "buhd", "cakm", "cans", "cari", "cham", "cher", "chrs", "cirt", "copt", "cpmn", "cprt", "cyrl", "cyrs", "deva", "diak", "dogr", "dsrt", "dupl", "egyd", "egyh", "egyp", "elba", "elym", "ethi", "geok", "geor", "glag", "gong", "gonm", "goth", "gran", "grek", "gujr", "guru", "hanb", "hang", "hani", "hano", "hans", "hant", "hatr", "hebr", "hira", "hluw", "hmng", "hmnp", "hrkt", "hung", "inds", "ital", "jamo", "java", "jpan", "jurc", "kali", "kana", "khar", "khmr", "khoj", "kitl", "kits", "knda", "kore", "kpel", "kthi", "lana", "laoo", "latf", "latg", "latn", "leke", "lepc", "limb", "lina", "linb", "lisu", "loma", "lyci", "lydi", "mahj", "maka", "mand", "mani", "marc", "maya", "medf", "mend", "merc", "mero", "mlym", "modi", "mong", "moon", "mroo", "mtei", "mult", "mymr", "nand", "narb", "nbat", "newa", "nkdb", "nkgb", "nkoo", "nshu", "ogam", "olck", "orkh", "orya", "osge", "osma", "ougr", "palm", "pauc", "pcun", "pelm", "perm", "phag", "phli", "phlp", "phlv", "phnx", "piqd", "plrd", "prti", "psin", "qaaa", "qaai", "qabx", "ranj", "rjng", "rohg", "roro", "runr", "samr", "sara", "sarb", "saur", "sgnw", "shaw", "shrd", "shui", "sidd", "sind", "sinh", "sogd", "sogo", "sora", "soyo", "sund", "sylo", "syrc", "syre", "syrj", "syrn", "tagb", "takr", "tale", "talu", "taml", "tang", "tavt", "telu", "teng", "tfng", "tglg", "thaa", "thai", "tibt", "tirh", "toto", "ugar", "vaii", "visp", "wara", "wcho", "wole", "xpeo", "xsux", "yezi", "yiii", "zanb", "zinh", "zmth", "zsye", "zsym", "zxxx", "zyyy", "zzzz", };
public static string UltimateFallbackScript = "zyyy";
public static Dictionary<string, string[]> FallbackScriptMap = new Dictionary<string, string[]> {
{ "aran", new string[] { "arab" } }, { "cyrs", new string[] { "cyrl" } },
{ "hanb", new string[] { "hant", "bopo" } }, { "hans", new string[] { "hani" } }, { "hant", new string[] { "hani" } },
{ "hrkt", new string[] { "hira", "kana" } }, { "jpan", new string[] { "hani", "hira", "kana" } },
{ "jamo", new string[] { "hang" } }, { "kore", new string[] { "hang", "hani" } },
{ "latf", new string[] { "latn" } }, { "latg", new string[] { "latn" } },
{ "syre", new string[] { "syrc" } }, { "syrj", new string[] { "syrc" } }, { "syrn", new string[] { "syrc" } },
{ "zsye", new string[] { "zsym" } },
};
public static void FillKeysWithScripts(IDictionary dict, Func<object> value) {
foreach (var s in Scripts) dict.Add(s, value());
}
public static IEnumerable<string> EnumerateFallbackScripts(string script) {
if (string.IsNullOrEmpty(script)) throw new ArgumentNullException("script");
script = script.ToLower();
if (script == UltimateFallbackScript) {
yield return null;
yield break;
}
string[] fblist;
if (FallbackScriptMap.TryGetValue(script, out fblist)) {
foreach (var fb in fblist) {
yield return fb;
}
}
else yield return UltimateFallbackScript;
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: df66519fa93e1b94ea5bb1702cc91b3f
guid: ae9dab8f520fadc4194032f523ca87c1
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,4 +1,4 @@
using System;
using System;
namespace Cryville.Common {
public class FileStringAttribute : Attribute {

View File

@@ -0,0 +1,113 @@
using Cryville.Common.IO;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
namespace Cryville.Common.Font {
public abstract class FontFile : IEnumerable<Typeface> {
public abstract int Count { get; }
public abstract Typeface this[int index] { get; }
protected FileInfo File { get; private set; }
protected BinaryReader Reader { get; private set; }
public FontFile(FileInfo file) {
File = file;
Reader = new BinaryReaderBE(new FileStream(file.FullName, FileMode.Open, FileAccess.Read));
}
public void Close() { Reader.Close(); }
public static FontFile Create(FileInfo file) {
switch (file.Extension) {
case ".ttf": case ".otf": return new FontFileTTF(file);
case ".ttc": case ".otc": return new FontFileTTC(file);
default: return null;
}
}
public Enumerator GetEnumerator() {
return new Enumerator(this);
}
IEnumerator<Typeface> IEnumerable<Typeface>.GetEnumerator() {
return GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() {
return GetEnumerator();
}
public struct Enumerator : IEnumerator<Typeface> {
readonly FontFile _self;
int _index;
internal Enumerator(FontFile self) {
_self = self;
_index = -1;
}
public Typeface Current {
get {
if (_index < 0)
throw new InvalidOperationException(_index == -1 ? "Enum not started" : "Enum ended");
return _self[_index];
}
}
object IEnumerator.Current { get { return Current; } }
public void Dispose() {
_index = -2;
}
public bool MoveNext() {
if (_index == -2) return false;
_index++;
if (_index >= _self.Count) {
_index = -2;
return false;
}
return true;
}
public void Reset() {
_index = -1;
}
}
}
public class FontFileTTF : FontFile {
public override int Count { get { return 1; } }
public override Typeface this[int index] {
get {
if (index != 0) throw new ArgumentOutOfRangeException("index");
try {
return new TypefaceTTF(Reader, File, index);
}
catch (Exception) {
throw new InvalidDataException("Invalid font");
}
}
}
public FontFileTTF(FileInfo file) : base(file) { }
}
public class FontFileTTC : FontFile {
readonly IReadOnlyList<uint> _offsets;
public override int Count { get { return _offsets.Count; } }
public override Typeface this[int index] {
get {
if (index < 0 || index >= Count) throw new ArgumentOutOfRangeException("index");
Reader.BaseStream.Position = _offsets[index];
try {
return new TypefaceTTF(Reader, File, index);
}
catch (Exception) {
throw new InvalidDataException("Invalid font");
}
}
}
public FontFileTTC(FileInfo file) : base(file) {
try {
_offsets = new TTCHeader(Reader, 0).GetItems();
}
catch (Exception) {
throw new InvalidDataException("Invalid font");
}
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 2b7b45ff20c33ac47b476371673b037c
guid: c9f44ccf8ddd364418b4f4965414ff9c
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,63 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Cryville.Common.Font {
public abstract class FontManager {
public IReadOnlyDictionary<string, IReadOnlyCollection<Typeface>> MapFullNameToTypeface { get; private set; }
public IReadOnlyDictionary<string, IReadOnlyCollection<Typeface>> MapNameToTypefaces { get; private set; }
public FontManager() {
var map1 = new Dictionary<string, List<Typeface>>();
var map2 = new Dictionary<string, List<Typeface>>();
foreach (var f in EnumerateAllTypefaces()) {
List<Typeface> set1;
if (!map1.TryGetValue(f.FullName, out set1)) {
map1.Add(f.FullName, set1 = new List<Typeface>());
}
set1.Add(f);
List<Typeface> set2;
if (!map2.TryGetValue(f.FamilyName, out set2)) {
map2.Add(f.FamilyName, set2 = new List<Typeface>());
}
set2.Add(f);
}
MapFullNameToTypeface = map1.ToDictionary(i => i.Key, i => (IReadOnlyCollection<Typeface>)i.Value);
MapNameToTypefaces = map2.ToDictionary(i => i.Key, i => (IReadOnlyCollection<Typeface>)i.Value);
}
protected abstract IEnumerable<Typeface> EnumerateAllTypefaces();
protected static IEnumerable<Typeface> ScanDirectoryForTypefaces(string dir) {
foreach (var f in new DirectoryInfo(dir).EnumerateFiles()) {
FontFile file;
try {
file = FontFile.Create(f);
}
catch (InvalidDataException) {
continue;
}
if (file == null) continue;
var enumerator = file.GetEnumerator();
while (enumerator.MoveNext()) {
Typeface ret;
try {
ret = enumerator.Current;
}
catch (InvalidDataException) {
continue;
}
yield return ret;
}
file.Close();
}
}
}
public class FontManagerAndroid : FontManager {
protected override IEnumerable<Typeface> EnumerateAllTypefaces() {
return ScanDirectoryForTypefaces("/system/fonts");
}
}
public class FontManagerWindows : FontManager {
protected override IEnumerable<Typeface> EnumerateAllTypefaces() {
return ScanDirectoryForTypefaces("C:/Windows/Fonts");
}
}
}

View File

@@ -0,0 +1,329 @@
using Cryville.Common.Culture;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Cryville.Common.Font {
public abstract class FontMatcher {
protected FontManager Manager { get; private set; }
public FontMatcher(FontManager manafer) { Manager = manafer; }
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>());
// 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");
// 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");
}
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");
// SP2
MapScriptToTypefaces["beng"].Insert(0, "Vrinda");
MapScriptToTypefaces["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");
// Reference: https://en.wikipedia.org/wiki/List_of_CJK_fonts
MapScriptToTypefaces["jpan"].Insert(0, "Meiryo");
MapScriptToTypefaces["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");
}
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");
}
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");
}
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");
// 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");
//
MapScriptToTypefaces["jpan"].Insert(0, "Yu Gothic UI");
MapScriptToTypefaces["zsym"].Add("Segoe MDL2 Assets");
}
}
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 FallbackListFontMatcher(FontManager manager) : base(manager) { }
public override IEnumerable<Typeface> MatchScript(string script = null, bool distinctFamily = false) {
if (string.IsNullOrEmpty(script)) script = ScriptUtils.UltimateFallbackScript;
List<string> candidates;
IEnumerable<string> candidateScripts = new string[] { script };
while (candidateScripts != null) {
foreach (var candidateScript in candidateScripts) {
if (MapScriptToTypefaces.TryGetValue(candidateScript, out candidates)) {
foreach (var candidate in candidates) {
IReadOnlyCollection<Typeface> typefaces1;
if (Manager.MapFullNameToTypeface.TryGetValue(candidate, out typefaces1)) {
foreach (var typeface in typefaces1) {
yield return typeface;
}
}
if (distinctFamily) continue;
IReadOnlyCollection<Typeface> typefaces2;
if (Manager.MapNameToTypefaces.TryGetValue(candidate, out typefaces2)) {
foreach (var typeface in typefaces2) {
if (typefaces1.Contains(typeface)) continue;
yield return typeface;
}
}
}
}
}
candidateScripts = ScriptUtils.EnumerateFallbackScripts(script);
}
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: b8cd439340f088d4eb83711a5bc6384d
guid: afcde0ad1865db24da79ca1ce7256791
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,222 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Cryville.Common.Font {
public abstract class FontTable<T> {
protected UInt32 Offset { get; private set; }
protected BinaryReader Reader { get; private set; }
protected FontTable(BinaryReader reader, UInt32 offset) {
Reader = reader;
Offset = offset;
reader.BaseStream.Position = offset;
}
public abstract IReadOnlyList<T> GetItems();
}
public abstract class FontTable<T, U> : FontTable<T> {
protected FontTable(BinaryReader reader, UInt32 offset) : base(reader, offset) { }
public abstract U GetSubTable(T item);
}
public sealed class TTCHeader : FontTable<UInt32, TableDirectory> {
readonly String ttcTag;
readonly UInt16 majorVersion;
readonly UInt16 minorVersion;
readonly UInt32 numFonts;
readonly List<UInt32> tableDirectoryOffsets = new List<UInt32>();
readonly String dsigTag;
readonly UInt32 dsigLength;
readonly UInt32 dsigOffset;
public TTCHeader(BinaryReader reader, UInt32 offset) : base(reader, offset) {
ttcTag = reader.ReadTag();
if (ttcTag != "ttcf") throw new NotImplementedException();
majorVersion = reader.ReadUInt16();
minorVersion = reader.ReadUInt16();
numFonts = reader.ReadUInt32();
for (UInt32 i = 0; i < numFonts; i++) tableDirectoryOffsets.Add(reader.ReadUInt32());
if (majorVersion == 2) {
dsigTag = reader.ReadTag();
dsigLength = reader.ReadUInt32();
dsigOffset = reader.ReadUInt32();
}
}
public override IReadOnlyList<UInt32> GetItems() {
return tableDirectoryOffsets;
}
public override TableDirectory GetSubTable(UInt32 item) {
var i = item;
return new TableDirectory(Reader, i);
}
}
public sealed class TableDirectory : FontTable<TableRecord, object> {
readonly UInt32 sfntVersion;
readonly UInt16 numTables;
readonly UInt16 searchRange;
readonly UInt16 entrySelector;
readonly UInt16 rangeShift;
readonly List<TableRecord> tableRecords = new List<TableRecord>();
public TableDirectory(BinaryReader reader, UInt32 offset) : base(reader, offset) {
sfntVersion = reader.ReadUInt32();
numTables = reader.ReadUInt16();
searchRange = reader.ReadUInt16();
entrySelector = reader.ReadUInt16();
rangeShift = reader.ReadUInt16();
for (int i = 0; i < numTables; i++)
tableRecords.Add(new TableRecord {
tableTag = reader.ReadTag(),
checksum = reader.ReadUInt32(),
offset = reader.ReadUInt32(),
length = reader.ReadUInt32(),
});
}
public override IReadOnlyList<TableRecord> GetItems() {
return tableRecords;
}
public override object GetSubTable(TableRecord item) {
switch (item.tableTag) {
case "name": return new NameTable(Reader, item.offset);
case "meta": return new MetaTable(Reader, item.offset);
default: throw new NotImplementedException();
}
}
}
public struct TableRecord {
public string tableTag;
public UInt32 checksum;
public UInt32 offset;
public UInt32 length;
}
public sealed class NameTable : FontTable<NameRecord> {
readonly UInt16 version;
readonly UInt16 count;
readonly UInt16 storageOffset;
readonly List<NameRecord> nameRecord = new List<NameRecord>();
readonly UInt16 langTagCount;
readonly List<LangTagRecord> langTagRecord = new List<LangTagRecord>();
public NameTable(BinaryReader reader, UInt32 offset) : base(reader, offset) {
version = reader.ReadUInt16();
count = reader.ReadUInt16();
storageOffset = reader.ReadUInt16();
for (UInt16 i = 0; i < count; i++)
nameRecord.Add(new NameRecord {
platformID = reader.ReadUInt16(),
encodingID = reader.ReadUInt16(),
languageID = reader.ReadUInt16(),
nameID = (NameID)reader.ReadUInt16(),
length = reader.ReadUInt16(),
stringOffset = reader.ReadUInt16(),
});
if (version == 1) {
langTagCount = reader.ReadUInt16();
for (UInt16 i = 0; i < langTagCount; i++)
langTagRecord.Add(new LangTagRecord {
length = reader.ReadUInt16(),
langTagOffset = reader.ReadUInt16(),
});
}
UInt32 origin = (UInt32)reader.BaseStream.Position;
for (int i = 0; i < nameRecord.Count; i++) nameRecord[i] = nameRecord[i].Load(reader, origin);
for (int i = 0; i < langTagRecord.Count; i++) langTagRecord[i] = langTagRecord[i].Load(reader, origin);
}
public sealed override IReadOnlyList<NameRecord> GetItems() {
return nameRecord;
}
}
public struct NameRecord {
public UInt16 platformID;
public UInt16 encodingID;
public UInt16 languageID;
public NameID nameID;
public UInt16 length;
public UInt16 stringOffset;
public String value { get; private set; }
public NameRecord Load(BinaryReader reader, UInt32 origin) {
reader.BaseStream.Position = origin + stringOffset;
Encoding encoding;
switch (platformID) {
case 0: encoding = Encoding.BigEndianUnicode; break;
case 3: encoding = Encoding.BigEndianUnicode; break;
default: return this;
}
value = encoding.GetString(reader.ReadBytes(length));
return this;
}
}
public enum NameID : UInt16 {
CopyrightNotice = 0,
FontFamilyName = 1,
FontSubfamilyName = 2,
UniqueFontIdentifier = 3,
FullFontName = 4,
VersionString = 5,
PostScriptName = 6,
Trademark = 7,
ManufacturerName = 8,
Designer = 9,
Description = 10,
URLVendor = 11,
URLDesigner = 12,
LicenseDescription = 13,
LicenseInfoURL = 14,
TypographicFamilyName = 16,
TypographicSubfamilyName = 17,
CompatibleFull = 18,
SampleText = 19,
PostScriptCIDFindfontName = 20,
WWSFamilyName = 21,
WWSSubfamilyName = 22,
LightBackgroundPalette = 23,
DarkBackgroundPalette = 24,
VariationsPostScriptNamePrefix = 25,
}
public struct LangTagRecord {
public UInt16 length;
public UInt16 langTagOffset;
public String value { get; private set; }
public LangTagRecord Load(BinaryReader reader, UInt32 origin) {
reader.BaseStream.Position = origin + langTagOffset;
value = Encoding.BigEndianUnicode.GetString(reader.ReadBytes(length));
return this;
}
}
public sealed class MetaTable : FontTable<DataMap> {
readonly UInt32 version;
readonly UInt32 flags;
readonly UInt32 dataMapCount;
readonly List<DataMap> dataMaps = new List<DataMap>();
public MetaTable(BinaryReader reader, UInt32 offset) : base(reader, offset) {
version = reader.ReadUInt32();
flags = reader.ReadUInt32();
reader.ReadUInt32();
dataMapCount = reader.ReadUInt32();
for (UInt32 i = 0; i < dataMapCount; i++)
dataMaps.Add(new DataMap {
tag = reader.ReadTag(),
dataOffset = reader.ReadUInt32(),
dataLength = reader.ReadUInt32(),
});
for (int i = 0; i < dataMaps.Count; i++) dataMaps[i] = dataMaps[i].Load(reader, offset);
}
public sealed override IReadOnlyList<DataMap> GetItems() {
return dataMaps;
}
}
public struct DataMap {
public String tag;
public UInt32 dataOffset;
public UInt32 dataLength;
public String value { get; private set; }
public DataMap Load(BinaryReader reader, UInt32 origin) {
reader.BaseStream.Position = origin + dataOffset;
value = Encoding.ASCII.GetString(reader.ReadBytes((int)dataLength));
return this;
}
}
public static class BinaryReaderExtensions {
public static string ReadTag(this BinaryReader reader) {
return Encoding.ASCII.GetString(reader.ReadBytes(4));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3eed6aa2387582346b7b21c6f8de5e1f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,9 +0,0 @@
using System.Globalization;
namespace Cryville.Common.Font {
public static class FontUtil {
/*public static string MatchFontNameWithLang(string lang) {
}*/
}
}

View File

@@ -0,0 +1,31 @@
using System.IO;
using System.Linq;
namespace Cryville.Common.Font {
public abstract class Typeface {
public FileInfo File { get; private set; }
public int IndexInFile { get; private set; }
public string FamilyName { get; protected set; }
public string SubfamilyName { get; protected set; }
public string FullName { get; protected set; }
protected abstract void GetName(BinaryReader reader);
public Typeface(BinaryReader reader, FileInfo file, int index) {
File = file;
IndexInFile = index;
GetName(reader);
}
}
public class TypefaceTTF : Typeface {
public TypefaceTTF(BinaryReader reader, FileInfo file, int index)
: base(reader, file, index) { }
protected override void GetName(BinaryReader reader) {
var dir = new TableDirectory(reader, (uint)reader.BaseStream.Position);
var nameTable = (NameTable)dir.GetSubTable((from i in dir.GetItems() where i.tableTag == "name" select i).Single());
FamilyName = (from i in nameTable.GetItems() where i.nameID == NameID.FontFamilyName && i.value != null select i.value).First();
SubfamilyName = (from i in nameTable.GetItems() where i.nameID == NameID.FontSubfamilyName && i.value != null select i.value).First();
FullName = (from i in nameTable.GetItems() where i.nameID == NameID.FullFontName && i.value != null select i.value).First();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0968fc12b50cffb4682f0c28d0d14703
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 6823ead66b33bc048bbad48719feb25d
guid: aaa0d8cecafb37b46a6abe372cfefd93
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -0,0 +1,75 @@
using System;
using System.IO;
using System.Text;
namespace Cryville.Common.IO {
public class BinaryReaderBE : BinaryReader {
readonly byte[] m_buffer = new byte[8];
public BinaryReaderBE(Stream input) : base(input) { }
public BinaryReaderBE(Stream input, Encoding encoding) : base(input, encoding) { }
public BinaryReaderBE(Stream input, Encoding encoding, bool leaveOpen) : base(input, encoding, leaveOpen) { }
public override short ReadInt16() {
FillBuffer(2);
return (short)(m_buffer[1] | (m_buffer[0] << 8));
}
public override ushort ReadUInt16() {
FillBuffer(2);
return (ushort)(m_buffer[1] | (m_buffer[0] << 8));
}
public override int ReadInt32() {
FillBuffer(4);
return m_buffer[3] | (m_buffer[2] << 8) | (m_buffer[1] << 16) | (m_buffer[0] << 24);
}
public override uint ReadUInt32() {
FillBuffer(4);
return (uint)(m_buffer[3] | (m_buffer[2] << 8) | (m_buffer[1] << 16) | (m_buffer[0] << 24));
}
public override long ReadInt64() {
FillBuffer(8);
uint num = (uint)(m_buffer[7] | (m_buffer[6] << 8) | (m_buffer[5] << 16) | (m_buffer[4] << 24));
uint num2 = (uint)(m_buffer[3] | (m_buffer[2] << 8) | (m_buffer[1] << 16) | (m_buffer[0] << 24));
return (long)(((ulong)num2 << 32) | num);
}
public override ulong ReadUInt64() {
FillBuffer(8);
uint num = (uint)(m_buffer[7] | (m_buffer[6] << 8) | (m_buffer[5] << 16) | (m_buffer[4] << 24));
uint num2 = (uint)(m_buffer[3] | (m_buffer[2] << 8) | (m_buffer[1] << 16) | (m_buffer[0] << 24));
return ((ulong)num2 << 32) | num;
}
protected new void FillBuffer(int numBytes) {
if (m_buffer != null && (numBytes < 0 || numBytes > m_buffer.Length)) {
throw new ArgumentOutOfRangeException("numBytes", "Requested numBytes is larger than the internal buffer size");
}
int num = 0, num2;
if (BaseStream == null) {
throw new IOException("File not open");
}
if (numBytes == 1) {
num2 = BaseStream.ReadByte();
if (num2 == -1) {
throw new EndOfStreamException("The end of the stream is reached before numBytes could be read");
}
m_buffer[0] = (byte)num2;
return;
}
do {
num2 = BaseStream.Read(m_buffer, num, numBytes - num);
if (num2 == 0) {
throw new EndOfStreamException("The end of the stream is reached before numBytes could be read");
}
num += num2;
}
while (num < numBytes);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aee537c74ab935940b54cb5d784b7f56
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,14 +1,15 @@
using System;
using System;
namespace Cryville.Common {
public struct Identifier : IEquatable<Identifier> {
public static Identifier Empty = new Identifier(0);
public int Key { get; private set; }
public object Name { get { return IdentifierManager.SharedInstance.Retrieve(Key); } }
public object Name { get { return IdentifierManager.Shared.Retrieve(Key); } }
public Identifier(int key) {
Key = key;
}
public Identifier(object name) {
Key = IdentifierManager.SharedInstance.Request(name);
Key = IdentifierManager.Shared.Request(name);
}
public override bool Equals(object obj) {
if (obj == null || !(obj is Identifier)) return false;
@@ -24,11 +25,11 @@ namespace Cryville.Common {
if (Key == 0) return "";
return Name.ToString();
}
public static implicit operator Identifier(string identifier) {
return new Identifier(identifier);
public static bool operator ==(Identifier lhs, Identifier rhs) {
return lhs.Equals(rhs);
}
public static implicit operator string(Identifier identifier) {
return identifier.ToString();
public static bool operator !=(Identifier lhs, Identifier rhs) {
return !lhs.Equals(rhs);
}
}
}

View File

@@ -1,52 +0,0 @@
using System.Collections.Generic;
namespace Cryville.Common {
/// <summary>
/// A manager that assigns each given identifiers a unique integer ID.
/// </summary>
public class IdentifierManager {
/// <summary>
/// A shared instance of the <see cref="IdentifierManager" /> class.
/// </summary>
public static IdentifierManager SharedInstance = new IdentifierManager();
readonly Dictionary<object, int> _idents = new Dictionary<object, int>();
readonly List<object> _ids = new List<object>();
readonly object _syncRoot = new object();
/// <summary>
/// Creates an instance of the <see cref="IdentifierManager" /> class.
/// </summary>
public IdentifierManager() {
Request(this);
}
/// <summary>
/// Requests an integer ID for an identifier.
/// </summary>
/// <param name="ident">The identifier.</param>
/// <returns>The integer ID.</returns>
public int Request(object ident) {
lock (_syncRoot) {
int id;
if (!_idents.TryGetValue(ident, out id)) {
_idents.Add(ident, id = _idents.Count);
_ids.Add(ident);
}
return id;
}
}
/// <summary>
/// Retrieves the identifier assigned with an integer ID.
/// </summary>
/// <param name="id">The integer ID.</param>
/// <returns>The identifier.</returns>
public object Retrieve(int id) {
lock (_syncRoot) {
return _ids[id];
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 478086496f56eaf46be4df4e2ad37fee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,128 +0,0 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
namespace Cryville.Common {
/// <summary>
/// A logger.
/// </summary>
public abstract class Logger {
static readonly Dictionary<string, Logger> Instances = new Dictionary<string, Logger>();
static readonly Dictionary<string, StreamWriter> Files = new Dictionary<string, StreamWriter>();
static string logPath = null;
/// <summary>
/// Sets the path where the log files shall be stored.
/// </summary>
/// <param name="path">The path.</param>
public static void SetLogPath(string path) {
logPath = path;
var dir = new DirectoryInfo(path);
if (!dir.Exists) dir.Create();
}
/// <summary>
/// Logs to the specified logger.
/// </summary>
/// <param name="key">The key of the logger.</param>
/// <param name="level">The severity level.</param>
/// <param name="module">The module that is logging.</param>
/// <param name="format">The format string.</param>
/// <param name="args">The arguments for formatting.</param>
public static void Log(string key, int level, string module, string format, params object[] args) {
if (!Instances.ContainsKey(key)) return;
Instances[key].Log(level, module, string.Format(format, args));
if (Files.ContainsKey(key)) Files[key].WriteLine("[{0:O}] [{1}] <{2}> {3}", DateTime.UtcNow, level, module, string.Format(format, args));
}
/// <summary>
/// Adds a created logger to the shared logger manager.
/// </summary>
/// <param name="key">The key of the logger.</param>
/// <param name="logger">The logger.</param>
public static void Create(string key, Logger logger) {
Instances[key] = logger;
if (logPath != null) {
Files[key] = new StreamWriter(logPath + "/" + ((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds).ToString(CultureInfo.InvariantCulture) + "-" + key + ".log") {
AutoFlush = true
};
}
}
/// <summary>
/// Closes all loggers and related file streams.
/// </summary>
public static void Close() {
Instances.Clear();
foreach (var f in Files) f.Value.Dispose();
Files.Clear();
}
/// <summary>
/// Logs to the logger.
/// </summary>
/// <param name="level">The severity level.</param>
/// <param name="module">The module that is logging.</param>
/// <param name="msg">The message.</param>
public virtual void Log(int level, string module, string msg) { }
}
/// <summary>
/// A <see cref="Logger" /> that calls a callback function on log.
/// </summary>
public class InstantLogger : Logger {
readonly Action<int, string, string> callback;
/// <summary>
/// Creates an instance of the <see cref="InstantLogger" /> class.
/// </summary>
/// <param name="callback">The callback function.</param>
/// <exception cref="ArgumentNullException"><paramref name="callback" /> is <see langword="null" />.</exception>
public InstantLogger(Action<int, string, string> callback) {
if (callback == null)
throw new ArgumentNullException("callback");
this.callback = callback;
}
/// <inheritdoc />
public override void Log(int level, string module, string msg) {
base.Log(level, module, msg);
callback(level, module, msg);
}
}
/// <summary>
/// A <see cref="Logger" /> that buffers the logs for enumeration.
/// </summary>
public class BufferedLogger : Logger {
readonly List<LogEntry> buffer = new List<LogEntry>();
/// <summary>
/// Creates an instance of the <see cref="BufferedLogger" /> class.
/// </summary>
public BufferedLogger() { }
/// <inheritdoc />
public override void Log(int level, string module, string msg) {
base.Log(level, module, msg);
lock (buffer) {
buffer.Add(new LogEntry(level, module, msg));
}
}
/// <summary>
/// Enumerates the buffered logs.
/// </summary>
/// <param name="callback">The callback function to receive the logs.</param>
public void Enumerate(Action<int, string, string> callback) {
lock (buffer) {
foreach (var i in buffer) {
callback(i.level, i.module, i.msg);
}
}
buffer.Clear();
}
}
struct LogEntry {
public int level;
public string module;
public string msg;
public LogEntry(int level, string module, string msg) {
this.level = level;
this.module = module;
this.msg = msg;
}
}
}

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 1c1729cfde78f1c479c9f7eb166e0107
timeCreated: 1611126212
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -54,16 +54,13 @@ namespace Cryville.Common.Math {
return res;
}
/// <summary>
/// Creates a <see cref="System.Single" /> column vector and fills it with polynomial coefficients.
/// Fills a <see cref="System.Single" /> column vector with polynomial coefficients.
/// </summary>
/// <param name="size">The size of the column vector.</param>
/// <param name="vec">The column vector.</param>
/// <param name="num">The base number.</param>
/// <returns>A <see cref="System.Single" /> column vector filled with polynomial coefficients.</returns>
public static ColumnVector<float> WithPolynomialCoefficients(int size, float num) {
var m = new ColumnVector<float>(size);
for (var i = 0; i < size; i++)
m[i] = (float)System.Math.Pow(num, i);
return m;
public static void FillWithPolynomialCoefficients(ColumnVector<float> vec, float num) {
for (var i = 0; i < vec.Size; i++)
vec[i] = (float)System.Math.Pow(num, i);
}
}
}

View File

@@ -0,0 +1,27 @@
using SMath = System.Math;
namespace Cryville.Common.Math {
// Ported from https://github.com/arian/cubic-bezier/blob/master/index.js
public static class CubicBezier {
public static float Evaluate(float t, float x1, float y1, float x2, float y2, float epsilon) {
float x = t, t0 = 0, t1 = 1, t2 = x;
if (t2 < t0) return Curve(t0, y1, y2);
if (t2 > t1) return Curve(t1, y1, y2);
while (t0 < t1) {
float tx = Curve(t2, x1, x2);
if (SMath.Abs(tx - x) < epsilon) return Curve(t2, y1, y2);
if (x > tx) t0 = t2;
else t1 = t2;
t2 = (t1 - t0) * .5f + t0;
}
return Curve(t2, y1, y2);
}
static float Curve(float t, float p1, float p2) {
float v = 1 - t;
return 3 * v * v * t * p1 + 3 * v * t * t * p2 + t * t * t;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 17dd6f775fc965f43960da7166b55b87
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,4 +1,4 @@
using System;
using System;
namespace Cryville.Common.Math {
/// <summary>
@@ -12,12 +12,12 @@ namespace Cryville.Common.Math {
/// <param name="error">The error.</param>
/// <param name="n">The numerator.</param>
/// <param name="d">The denominator.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is less than 0 or <paramref name="error" /> is not greater than 0 or not less than 1.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is less than 0 or <paramref name="error" /> is not greater than 0 or greater than 1.</exception>
public static void ToFraction(double value, double error, out int n, out int d) {
if (value < 0.0)
throw new ArgumentOutOfRangeException("value", "Must be >= 0.");
if (error <= 0.0 || error >= 1.0)
throw new ArgumentOutOfRangeException("accuracy", "Must be > 0 and < 1.");
if (error <= 0.0 || error > 1.0)
throw new ArgumentOutOfRangeException("error", "Must be > 0 and <= 1.");
int num = (int)System.Math.Floor(value);
value -= num;

View File

@@ -1,4 +1,4 @@
using System;
using UnsafeIL;
namespace Cryville.Common.Math {
/// <summary>
@@ -40,11 +40,11 @@ namespace Cryville.Common.Math {
/// </summary>
/// <typeparam name="T">The vector type.</typeparam>
/// <param name="v">The column vector.</param>
/// <param name="result">The result column vector.</param>
/// <param name="o">The column operator.</param>
/// <returns>The column vector eliminated.</returns>
public ColumnVector<T> Eliminate<T>(ColumnVector<T> v, IVectorOperator<T> o) {
public void Eliminate<T>(ColumnVector<T> v, ColumnVector<T> result, IVectorOperator<T> o) {
int s = Size;
Array.Copy(content, buffer, Size * Size);
FillBuffer();
for (int i = 0; i < s; i++) refl[i] = i;
for (int r = 0; r < s; r++) {
for (int r0 = r; r0 < s; r0++)
@@ -66,14 +66,17 @@ namespace Cryville.Common.Math {
v[or1] = o.Add(v[or1], o.ScalarMultiply(-sf1, v[or]));
}
}
ColumnVector<T> res = new ColumnVector<T>(s);
for (int r2 = s - 1; r2 >= 0; r2--) {
var v2 = v[refl[r2]];
for (int c2 = r2 + 1; c2 < s; c2++)
v2 = o.Add(v2, o.ScalarMultiply(-buffer[refl[r2], c2], res[refl[c2]]));
res[refl[r2]] = v2;
v2 = o.Add(v2, o.ScalarMultiply(-buffer[refl[r2], c2], result[refl[c2]]));
result[refl[r2]] = v2;
}
}
unsafe void FillBuffer() {
fixed (void* ptrc = content, ptrb = buffer) {
Unsafe.CopyBlock(ptrb, ptrc, (uint)(Size * Size * sizeof(float)));
}
return res;
}
/// <summary>
/// Creates a square matrix and fills it with polynomial coefficients.

View File

@@ -1,3 +1,4 @@
using Cryville.Common.Logging;
using Microsoft.Win32;
using System;
using System.Collections.Generic;

View File

@@ -1,3 +1,4 @@
using Cryville.Common.Logging;
using System.Collections.Generic;
using System.IO;
using System.Text;

View File

@@ -1,4 +1,5 @@
using System;
using Cryville.Common.Logging;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@@ -130,4 +131,4 @@ namespace Cryville.Common.Network {
}
}
}
}
}

View File

@@ -1,3 +1,4 @@
using Cryville.Common.Logging;
using Org.BouncyCastle.Security;
using Org.BouncyCastle.Tls;
using Org.BouncyCastle.Tls.Crypto;

View File

@@ -1,7 +1,21 @@
using System;
using System;
namespace Cryville.Common.Pdt {
/// <summary>
/// Indicates that the attributed member is an element list.
/// </summary>
/// <remarks>
/// <para>An element list is a <see cref="System.Collections.IDictionary" /> or <see cref="Cryville.Common.Collections.IPairList" /> that represents a collection of PDT elements. There must be at most one element list in a class.</para>
/// </remarks>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class ElementListAttribute : Attribute { }
public class ComponentListAttribute : Attribute { }
/// <summary>
/// Indicates that the attributed member is a property list.
/// </summary>
/// <remarks>
/// <para>A property list is a <see cref="System.Collections.IDictionary" /> or <see cref="Cryville.Common.Collections.IPairList" /> that represents a collection of PDT properties. There must be at most one property list in a class.</para>
/// </remarks>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class PropertyListAttribute : Attribute { }
}

View File

@@ -1,5 +1,6 @@
using System;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Cryville.Common.Pdt {
/// <summary>
@@ -16,32 +17,28 @@ namespace Cryville.Common.Pdt {
readonly StackFrame[] _stack = new StackFrame[256];
readonly byte[] _mem = new byte[0x100000];
bool _revokepttconst;
LinkedListNode<PdtInstruction> _rip;
/// <summary>
/// Evaluates an expression and passes the result to a target operator.
/// </summary>
/// <param name="target">The target operator.</param>
/// <param name="exp">The expression to evaluate.</param>
public void Evaluate(PdtOperator target, PdtExpression exp) {
_framecount = 0;
_goffset = 0;
_revokepttconst = false;
for (_rip = exp.Instructions.First; _rip != null; _rip = _rip.Next)
_rip.Value.Execute(this);
Operate(target, _framecount, true);
if (exp.IsPotentialConstant) {
exp.IsConstant = exp.IsPotentialConstant = !_revokepttconst;
/// <returns>Whether the evaluaton succeeded.</returns>
public bool Evaluate(PdtOperator target, PdtExpression exp) {
try {
var prevFrameCount = _framecount;
_revokepttconst = false;
for (var ip = exp.Instructions.First; ip != null; ip = ip.Next)
ip.Value.Execute(this, ref ip);
if (exp.IsPotentialConstant) {
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);
}
}
/// <summary>
/// Patches an expression with a lefthand variable and a compound operator.
/// </summary>
/// <param name="target">The name of the lefthand variable.</param>
/// <param name="op">The name of the compound operator.</param>
/// <param name="exp">The expression.</param>
public void PatchCompound(int target, int op, PdtExpression exp) {
exp.Instructions.AddFirst(new PdtInstruction.PushVariable(target));
exp.Instructions.AddLast(new PdtInstruction.Operate(op, 2));
}
/// <summary>
/// Optimizes an expression by merging its instructions.
@@ -53,12 +50,14 @@ namespace Cryville.Common.Pdt {
List<PdtInstruction.Collapse> ct;
var cols = new Dictionary<LinkedListNode<PdtInstruction>, List<PdtInstruction.Collapse>>();
var il = exp.Instructions;
for (_rip = il.First; _rip != null; _rip = _rip == null ? il.First : _rip.Next) {
var i = _rip.Value;
var ip = il.First;
while (ip != null) {
bool nextFlag = false;
var i = ip.Value;
if (i is PdtInstruction.Operate) {
int fc0 = _framecount;
int fc1 = ((PdtInstruction.Operate)i).Signature.ParamCount;
try { i.Execute(this); } catch (Exception) { }
try { i.Execute(this, ref ip); } catch (Exception) { }
if (fc0 - _framecount == fc1) {
unsafe {
fixed (StackFrame* frame = &_stack[_framecount++]) {
@@ -70,29 +69,38 @@ namespace Cryville.Common.Pdt {
}
else {
var frame = _stack[_framecount - 1];
_rip = il.AddAfter(_rip, new PdtInstruction.PushConstant(frame.Type, _mem, frame.Offset, frame.Length));
for (var j = 0; j <= fc1; j++) il.Remove(_rip.Previous);
if (frame.Type != PdtInternalType.Error) {
ReplaceIP(il, ref ip, new PdtInstruction.PushConstant(frame.Type, _mem, frame.Offset, frame.Length), cols);
for (var j = 0; j < fc1; j++) il.Remove(ip.Previous);
}
}
}
else if (i is PdtInstruction.Collapse) {
var t = (PdtInstruction.Collapse)i;
try {
var pins = _rip;
i.Execute(this);
if (_rip == pins) {
_rip = _rip.Next;
il.Remove(_rip.Previous);
il.Remove(_rip.Previous);
_rip = _rip.Previous;
var pins = ip;
i.Execute(this, ref ip);
if (_stack[_framecount - 1].Type == PdtInternalType.Error) {
throw new EvaluationFailureException();
}
if (ip == pins) {
ip = ip.Next;
il.Remove(ip.Previous);
il.Remove(ip.Previous);
ip = ip.Previous;
if (ip == null) {
ip = il.First;
nextFlag = true;
}
}
else {
_rip = pins.Previous;
while (_rip.Next != t.Target) il.Remove(_rip.Next);
il.Remove(_rip.Next);
ip = pins.Previous;
while (ip.Next != t.Target) il.Remove(ip.Next);
il.Remove(ip.Next);
if (cols.TryGetValue(t.Target, out ct)) {
foreach (var u in ct) u.Target = _rip;
foreach (var u in ct) u.Target = ip;
cols.Remove(t.Target);
cols.Add(_rip, ct);
cols.Add(ip, ct);
}
}
}
@@ -102,15 +110,14 @@ namespace Cryville.Common.Pdt {
}
}
else if (i is PdtInstruction.PushVariable) {
i.Execute(this);
i.Execute(this, ref ip);
var frame = _stack[_framecount - 1];
if (frame.Type != PdtInternalType.Undefined) {
_rip = il.AddAfter(_rip, new PdtInstruction.PushConstant(frame.Type, _mem, frame.Offset, frame.Length));
il.Remove(_rip.Previous);
if (frame.Type != PdtInternalType.Undefined && frame.Type != PdtInternalType.Error) {
ReplaceIP(il, ref ip, new PdtInstruction.PushConstant(frame.Type, _mem, frame.Offset, frame.Length), cols);
}
}
else i.Execute(this);
if (_rip != null && cols.TryGetValue(_rip, out ct)) {
else i.Execute(this, ref ip);
if (ip != null && cols.TryGetValue(ip, out ct)) {
unsafe {
fixed (StackFrame* frame = &_stack[_framecount - 1]) {
frame->Type = PdtInternalType.Error;
@@ -119,6 +126,7 @@ namespace Cryville.Common.Pdt {
}
}
}
if (!nextFlag) ip = ip.Next;
}
exp.IsConstant = true;
exp.IsPotentialConstant = true;
@@ -132,6 +140,13 @@ namespace Cryville.Common.Pdt {
}
}
}
void ReplaceIP(LinkedList<PdtInstruction> il, ref LinkedListNode<PdtInstruction> ip, PdtInstruction ins, Dictionary<LinkedListNode<PdtInstruction>, List<PdtInstruction.Collapse>> cols) {
List<PdtInstruction.Collapse> cins;
if (cols.TryGetValue(ip, out cins)) cols.Remove(ip);
ip = il.AddAfter(ip, ins);
il.Remove(ip.Previous);
if (cins != null) cols.Add(ip, cins);
}
/// <summary>
/// Revokes the potential constant mark of the current expression.
/// </summary>
@@ -147,10 +162,10 @@ namespace Cryville.Common.Pdt {
_goffset += value.Length;
}
}
internal unsafe void PushVariable(int name) {
internal unsafe void PushVariable(int name, bool forced) {
fixed (StackFrame* frame = &_stack[_framecount++]) {
byte[] value;
GetVariable(name, out frame->Type, out value);
GetVariable(name, forced, out frame->Type, out value);
frame->Offset = _goffset;
frame->Length = value.Length;
Array.Copy(value, 0, _mem, _goffset, value.Length);
@@ -161,16 +176,17 @@ namespace Cryville.Common.Pdt {
/// Gets a variable of the specified name.
/// </summary>
/// <param name="name">The name of the variable.</param>
/// <param name="forced">Whether to produce an error stack instead of an identifier stack if the variable is not found.</param>
/// <param name="type">The type of the variable.</param>
/// <param name="value">The value of the variable.</param>
protected abstract void GetVariable(int name, out int type, out byte[] value);
protected abstract void GetVariable(int name, bool forced, out int type, out byte[] value);
internal void Operate(PdtOperatorSignature sig) {
PdtOperator op;
try { op = GetOperator(sig); }
catch (Exception) {
catch (Exception ex) {
for (int i = 0; i < sig.ParamCount; i++)
DiscardStack();
throw;
throw new EvaluationFailureException(string.Format("Failed to get operator {0}", sig), ex);
}
Operate(op, sig.ParamCount);
}
@@ -182,23 +198,34 @@ namespace Cryville.Common.Pdt {
/// <returns>An operator of the specific name.</returns>
/// <remarks>The parameter count of the returned operator does not necessarily equal to <paramref name="pc" />.</remarks>
protected abstract PdtOperator GetOperator(PdtOperatorSignature sig);
unsafe void Operate(PdtOperator op, int pc, bool noset = false) {
unsafe bool Operate(PdtOperator op, int pc, bool noset = false) {
fixed (byte* pmem = _mem) {
op.Begin(this);
op.Begin(this, pc);
for (int i = 0; i < pc; i++) {
var frame = _stack[--_framecount];
if (frame.Type == PdtInternalType.Error) {
_framecount -= pc - i - 1;
_stack[_framecount++] = new StackFrame { Type = PdtInternalType.Error, Offset = _goffset, Length = 0 };
return false;
}
op.LoadOperand(new PdtVariableMemory(frame.Type, pmem + frame.Offset, frame.Length));
_goffset -= frame.Length;
}
op.Call(pmem + _goffset, noset);
return true;
}
}
internal unsafe void Collapse(int name, LinkedListNode<PdtInstruction> target) {
internal unsafe void Collapse(int name, ref LinkedListNode<PdtInstruction> self, LinkedListNode<PdtInstruction> target) {
fixed (byte* pmem = _mem) {
var frame = _stack[--_framecount];
if (frame.Type == PdtInternalType.Error) {
_stack[_framecount++] = new StackFrame { Type = PdtInternalType.Error, Offset = _goffset, Length = 0 };
self = target;
return;
}
if (Collapse(name, new PdtVariableMemory(frame.Type, pmem + frame.Offset, frame.Length))) {
_framecount++;
_rip = target;
self = target;
}
}
}
@@ -222,4 +249,29 @@ namespace Cryville.Common.Pdt {
_goffset -= _stack[--_framecount].Length;
}
}
/// <summary>
/// The exception that is thrown when the evaluation of a <see cref="PdtExpression" /> fails.
/// </summary>
public class EvaluationFailureException : Exception {
/// <inheritdoc />
public EvaluationFailureException() : base("Evaluation failed") { }
/// <inheritdoc />
public EvaluationFailureException(string message) : base(message) { }
/// <inheritdoc />
public EvaluationFailureException(string message, Exception innerException) : base(message, innerException) { }
/// <inheritdoc />
protected EvaluationFailureException(SerializationInfo info, StreamingContext context) : base(info, context) { }
/// <summary>
/// Creates an instance of the <see cref="EvaluationFailureException" /> class with the failing expression.
/// </summary>
/// <param name="exp">The failing expression.</param>
public EvaluationFailureException(PdtExpression exp) : base("Evaluation failed for the expression: " + exp.ToString()) { }
/// <summary>
/// Creates an instance of the <see cref="EvaluationFailureException" /> class with the failing expression and the inner exception.
/// </summary>
/// <param name="exp">The failing expression.</param>
/// <param name="innerException">The inner exception.</param>
public EvaluationFailureException(PdtExpression exp, Exception innerException) : base("Evaluation failed for the expression: " + exp.ToString(), innerException) { }
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;
@@ -7,11 +7,23 @@ namespace Cryville.Common.Pdt {
/// PDT expression.
/// </summary>
public class PdtExpression {
/// <summary>
/// The empty expression.
/// </summary>
public static readonly PdtExpression Empty;
static PdtExpression() {
var ins = new LinkedList<PdtInstruction>();
ins.AddLast(new PdtInstruction.PushConstant(
PdtInternalType.Number, BitConverter.GetBytes(1f)
));
Empty = new PdtExpression(ins);
}
internal LinkedList<PdtInstruction> Instructions;
/// <summary>
/// Whether the value of this expression is constant.
/// </summary>
/// <remarks>The value of this property is <c>false</c> until it is optimized.</remarks>
/// <remarks>The value of this property is <see langword="false" /> until it is optimized.</remarks>
public bool IsConstant { get; internal set; }
internal bool IsPotentialConstant;
internal PdtExpression(LinkedList<PdtInstruction> ins) {
@@ -27,9 +39,19 @@ namespace Cryville.Common.Pdt {
}
return r;
}
/// <summary>
/// Patches an expression with a lefthand variable and a compound operator.
/// </summary>
/// <param name="target">The name of the lefthand variable.</param>
/// <param name="op">The name of the compound operator.</param>
/// <param name="exp">The expression.</param>
public static void PatchCompound(int target, int op, PdtExpression exp) {
exp.Instructions.AddFirst(new PdtInstruction.PushVariable(target));
exp.Instructions.AddLast(new PdtInstruction.Operate(op, 2));
}
}
internal abstract class PdtInstruction {
internal abstract void Execute(PdtEvaluatorBase etor);
internal abstract void Execute(PdtEvaluatorBase etor, ref LinkedListNode<PdtInstruction> self);
public class PushConstant : PdtInstruction {
public int Type { get; private set; }
public byte[] Value { get; private set; }
@@ -42,7 +64,7 @@ namespace Cryville.Common.Pdt {
Value = new byte[len];
Array.Copy(buffer, offset, Value, 0, len);
}
internal override void Execute(PdtEvaluatorBase etor) {
internal override void Execute(PdtEvaluatorBase etor, ref LinkedListNode<PdtInstruction> self) {
etor.PushConstant(Type, Value);
}
public override string ToString() {
@@ -51,13 +73,14 @@ namespace Cryville.Common.Pdt {
}
public class PushVariable : PdtInstruction {
public int Name { get; private set; }
public PushVariable(int name) { Name = name; }
public PushVariable(string name) : this(IdentifierManager.SharedInstance.Request(name)) { }
internal override void Execute(PdtEvaluatorBase etor) {
etor.PushVariable(Name);
public bool Forced { get; private set; }
public PushVariable(int name, bool forced = false) { Name = name; Forced = forced; }
public PushVariable(string name, bool forced = false) : this(IdentifierManager.Shared.Request(name)) { Forced = forced; }
internal override void Execute(PdtEvaluatorBase etor, ref LinkedListNode<PdtInstruction> self) {
etor.PushVariable(Name, Forced);
}
public override string ToString() {
return string.Format("pushv {0}", IdentifierManager.SharedInstance.Retrieve(Name));
return string.Format(Forced ? "pushv ?{0}" : "pushv {0}", IdentifierManager.Shared.Retrieve(Name));
}
}
public class Operate : PdtInstruction {
@@ -68,7 +91,7 @@ namespace Cryville.Common.Pdt {
public Operate(string name, int paramCount) {
Signature = new PdtOperatorSignature(name, paramCount);
}
internal override void Execute(PdtEvaluatorBase etor) {
internal override void Execute(PdtEvaluatorBase etor, ref LinkedListNode<PdtInstruction> self) {
etor.Operate(Signature);
}
public override string ToString() {
@@ -79,19 +102,19 @@ namespace Cryville.Common.Pdt {
public int Name { get; private set; }
public LinkedListNode<PdtInstruction> Target { get; internal set; }
public Collapse(string name, LinkedListNode<PdtInstruction> target) {
Name = IdentifierManager.SharedInstance.Request(name);
Name = IdentifierManager.Shared.Request(name);
Target = target;
}
internal override void Execute(PdtEvaluatorBase etor) {
etor.Collapse(Name, Target);
internal override void Execute(PdtEvaluatorBase etor, ref LinkedListNode<PdtInstruction> self) {
etor.Collapse(Name, ref self, Target);
}
public override string ToString() {
return string.Format("col {0}{{{1}}}", IdentifierManager.SharedInstance.Retrieve(Name), Target.Value);
return string.Format("col {0}{{{1}}}", IdentifierManager.Shared.Retrieve(Name), Target.Value);
}
}
}
public partial class PdtInterpreter<T> {
readonly static Dictionary<char, int> OP_PRIORITY = new Dictionary<char, int> {
public partial class PdtInterpreter {
static readonly Dictionary<char, int> OP_PRIORITY = new Dictionary<char, int> {
{ '@', 7 },
{ '*', 6 }, { '/', 6 }, { '%', 6 },
{ '+', 5 }, { '-', 5 },
@@ -102,7 +125,7 @@ namespace Cryville.Common.Pdt {
{ ',', 0 },
{ '$', -1 },
};
readonly static Dictionary<char, int> OP_TYPE = new Dictionary<char, int> {
static readonly Dictionary<char, int> OP_TYPE = new Dictionary<char, int> {
{ '@', 0 },
{ '*', 0 }, { '/', 0 }, { '%', 0 },
{ '+', 0 }, { '-', 0 },
@@ -114,15 +137,6 @@ namespace Cryville.Common.Pdt {
{ '$', -1 },
};
readonly static PdtExpression _emptyexp;
static PdtInterpreter() {
var ins = new LinkedList<PdtInstruction>();
ins.AddLast(new PdtInstruction.PushConstant(
PdtInternalType.Number, BitConverter.GetBytes(1f)
));
_emptyexp = new PdtExpression(ins);
}
PdtExpToken GetToken() {
ws();
var result = new PdtExpToken {
@@ -142,7 +156,7 @@ namespace Cryville.Common.Pdt {
public override string ToString() {
return string.Format("0x{0:x4}: {1}", Type, Value);
}
public readonly static PdtExpToken EmptyOperator = new PdtExpToken {
public static readonly PdtExpToken EmptyOperator = new PdtExpToken {
Type = 0x0080,
Value = "$",
};
@@ -194,7 +208,7 @@ namespace Cryville.Common.Pdt {
default: pc++; break;
}
}
else if (OP_TYPE[t2.Value[0]] == 1) {
if (OP_TYPE[t2.Value[0]] == 1) {
colp = new Dictionary<LinkedListNode<PdtInstruction>, string> { { ins.Last, t2.Value } };
}
t1 = t2;
@@ -239,7 +253,11 @@ namespace Cryville.Common.Pdt {
if (defs.TryGetValue(buf.Value.Value, out def)) {
foreach (var i in def.Instructions) ins.AddLast(i);
}
else ins.AddLast(new PdtInstruction.PushVariable(buf.Value.Value));
else {
var name = buf.Value.Value;
if (name[0] == '?') ins.AddLast(new PdtInstruction.PushVariable(name.Substring(1), true));
else ins.AddLast(new PdtInstruction.PushVariable(name));
}
buf = null;
TryPushAdjMul(ins, ref flag);
}

View File

@@ -0,0 +1,59 @@
using System;
using System.Reflection;
namespace Cryville.Common.Pdt {
/// <summary>
/// Interpreter for fragments in Property Definition Tree (PDT) file format.
/// </summary>
public class PdtFragmentInterpreter : PdtInterpreter {
public PdtFragmentInterpreter() : base(null, new EmptyBinder()) { }
/// <summary>
/// Sets the new source string for the fragment interpreter and resets the position.
/// </summary>
/// <param name="value">The new source string.</param>
public void SetSource(string value) {
Source = value;
Position = 0;
}
/// <summary>
/// The binder.
/// </summary>
public Binder Binder {
get { return _binder; }
set { _binder = value; }
}
/// <summary>
/// Reads the current character and increments the position.
/// </summary>
/// <returns>The current character.</returns>
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
public new char GetChar() { return base.GetChar(); }
/// <summary>
/// Reads an identifier.
/// </summary>
/// <returns>An identifier.</returns>
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
public new string GetIdentifier() { return base.GetIdentifier(); }
/// <summary>
/// Reads a number.
/// </summary>
/// <returns>A number.</returns>
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
public new string GetNumber() { return base.GetNumber(); }
/// <summary>
/// Reads a string.
/// </summary>
/// <returns>A string.</returns>
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
public new string GetString() { return base.GetString(); }
/// <summary>
/// Reads an expression.
/// </summary>
/// <returns>An expression.</returns>
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
public new PdtExpression GetExp() { return base.GetExp(); }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f7088ba23ed4b424eadaf664be48e376
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,4 +1,4 @@
namespace Cryville.Common.Pdt {
namespace Cryville.Common.Pdt {
/// <summary>
/// The identifiers of the internal types of PDT.
/// </summary>
@@ -6,30 +6,30 @@
/// <summary>
/// Error type.
/// </summary>
public readonly static int Error = 0x00525245;
public const int Error = 0x00525245;
/// <summary>
/// Array of a same variable-length type, with a suffix indicating the element count and the element type.
/// </summary>
public readonly static int Array = 0x00525241;
public const int Array = 0x00525241;
/// <summary>
/// Null type.
/// </summary>
public readonly static int Null = 0x4c4c554e;
public const int Null = 0x4c4c554e;
/// <summary>
/// IEEE 754 32-bit floating-point number.
/// </summary>
public readonly static int Number = 0x004d554e;
public const int Number = 0x004d554e;
/// <summary>
/// A sequence of UTF-16 code units, with a prefix indicating the number of the code units.
/// </summary>
public readonly static int String = 0x00525453;
public const int String = 0x00525453;
/// <summary>
/// A sequence of UTF-16 code units, with a prefix indicating the number of the code units, representing the name of an undefined variable.
/// </summary>
public readonly static int Undefined = 0x00444e55;
public const int Undefined = 0x00444e55;
/// <summary>
/// Vector of a same constant-length type, with a suffix indicating the element type.
/// </summary>
public readonly static int Vector = 0x00434556;
public const int Vector = 0x00434556;
}
}

View File

@@ -1,15 +1,18 @@
using System;
using System.Collections;
using Cryville.Common.Collections;
using Cryville.Common.Logging;
using Cryville.Common.Reflection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using CMath = System.Math;
namespace Cryville.Common.Pdt {
/// <summary>
/// Interpreter for Property Definition Tree (PDT) file format.
/// </summary>
/// <typeparam name="T">The object type represented by the PDT.</typeparam>
public partial class PdtInterpreter<T> {
public partial class PdtInterpreter {
/// <summary>
/// The character category map.
/// </summary>
@@ -27,16 +30,16 @@ namespace Cryville.Common.Pdt {
/// <item><term><c>0x1000</c></term><description>End of Key</description></item>
/// </list>
/// </remarks>
readonly static int[] cm = new int[] {
static readonly int[] cm = new int[] {
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0001, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0001, 0x0080, 0x0100, 0x0000, 0x0030, 0x0080, 0x0080, 0x0000, 0x0200, 0x0400, 0x0080, 0x0080, 0x0080, 0x0080, 0x0040, 0x0080,
0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x1000, 0x1800, 0x0080, 0x0080, 0x0080, 0x0000,
0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x1000, 0x1800, 0x0080, 0x0080, 0x0080, 0x0030,
0x0080, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030,
0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0000, 0x0000, 0x0000, 0x0000, 0x0030,
0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0000, 0x0080, 0x0000, 0x0080, 0x0030,
0x0000, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030,
0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x1000, 0x0080, 0x1000, 0x0000, 0x0000,
0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x0030, 0x1000, 0x0080, 0x1000, 0x0080, 0x0000,
};
/// <summary>
@@ -44,52 +47,102 @@ namespace Cryville.Common.Pdt {
/// </summary>
/// <param name="src">The source string.</param>
/// <returns>The interpreted object.</returns>
public static T Interpret(string src) {
return Interpret(src, BinderAttribute.CreateBinderOfType(typeof(T)));
public static T Interpret<T>(string src) {
return Interpret<T>(src, BinderAttribute.CreateBinderOfType(typeof(T)));
}
/// <summary>
/// Interprets a source string to an object of type <typeparamref name="T" /> with a binder.
/// Interprets a source string to an object of type <typeparamref name="T"/> with a binder.
/// </summary>
/// <param name="src">The source string.</param>
/// <param name="binder">The binder.</param>
/// <returns>The interpreted object.</returns>
public static T Interpret(string src, Binder binder) {
return new PdtInterpreter<T>(src, binder).Interpret();
public static T Interpret<T>(string src, Binder binder) {
return (T)new PdtInterpreter(src, binder).Interpret(typeof(T));
}
readonly string _src;
readonly Binder _binder;
protected int Position { get; private set; }
/// <summary>
/// The source string.
/// </summary>
public string Source { get; protected set; }
protected Binder _binder;
/// <summary>
/// The current position in the string being parsed by the interpreter.
/// </summary>
public int Position { get; protected set; }
#pragma warning disable IDE1006
protected char cc { get { return _src[Position]; } }
/// <summary>
/// The character at the current position.
/// </summary>
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
protected char cc { get { return Source[Position]; } }
/// <summary>
/// The category of the character.
/// </summary>
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
protected int ct { get { return cm[cc]; } }
protected string tokenb(int flag) { // Token Whitelist
/// <summary>
/// Reads a token until a character of type <paramref name="flag" /> is met.
/// </summary>
/// <param name="flag">The type filter.</param>
/// <returns>A token from the current position (inclusive) to the next character of type <paramref name="flag" /> (exclusive).</returns>
/// <exception cref="IndexOutOfRangeException">No character of type <paramref name="flag" /> is met.</exception>
protected string tokenb(int flag) {
int sp = Position;
while ((ct & flag) == 0) Position++;
return _src.Substring(sp, Position - sp);
return Source.Substring(sp, Position - sp);
}
protected string tokenw(int flag) { // Token Whitelist
/// <summary>
/// Reads a token until a character that is not of type <paramref name="flag" /> is met.
/// </summary>
/// <param name="flag">The type filter.</param>
/// <returns>A token from the current position (inclusive) to the next character that is not of type <paramref name="flag" /> (exclusive).</returns>
/// <exception cref="IndexOutOfRangeException">No character that is not of type <paramref name="flag" /> is met.</exception>
protected string tokenw(int flag) {
int sp = Position;
while ((ct & flag) != 0) Position++;
return _src.Substring(sp, Position - sp);
return Source.Substring(sp, Position - sp);
}
/// <summary>
/// Skips over whitespaces.
/// </summary>
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
protected void ws() {
while ((ct & 0x0001) != 0) Position++;
}
#pragma warning restore IDE1006
/// <summary>
/// Reads the current character and increments the position.
/// </summary>
/// <returns>The current character.</returns>
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
protected char GetChar() {
char r = cc;
Position++;
return r;
}
/// <summary>
/// Reads an identifier.
/// </summary>
/// <returns>An identifier.</returns>
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
protected string GetIdentifier() {
if ((ct & 0x0020) == 0) return "";
return tokenw(0x0010);
}
/// <summary>
/// Reads a number.
/// </summary>
/// <returns>A number.</returns>
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
protected string GetNumber() {
return tokenw(0x0040);
}
/// <summary>
/// Reads a string.
/// </summary>
/// <returns>A string.</returns>
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
protected string GetString() {
int sp = Position;
do {
@@ -97,8 +150,13 @@ namespace Cryville.Common.Pdt {
Position++;
} while (ct != 0x0100);
Position++;
return Regex.Replace(_src.Substring(sp + 1, Position - sp - 2), @"\\(.)", "$1");
return Regex.Replace(Source.Substring(sp + 1, Position - sp - 2), @"\\(.)", "$1");
}
/// <summary>
/// Reads an expression.
/// </summary>
/// <returns>An expression.</returns>
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
protected PdtExpression GetExp() {
var ins = new LinkedList<PdtInstruction>();
int _;
@@ -108,23 +166,34 @@ namespace Cryville.Common.Pdt {
readonly Dictionary<string, PdtExpression> defs = new Dictionary<string, PdtExpression>();
/// <summary>
/// Creates an instance of the <see cref="PdtInterpreter{T}" /> class.
/// Creates an instance of the <see cref="PdtInterpreter" /> class.
/// </summary>
/// <param name="src">The source string.</param>
/// <param name="binder">The binder. May be <c>null</c>.</param>
public PdtInterpreter(string src, Binder binder) {
_src = src;
Source = src;
_binder = binder;
if (_binder == null)
_binder = BinderAttribute.CreateBinderOfType(typeof(T));
}
int[] m_formatVersion;
public int[] GetFormatVersion() {
if (m_formatVersion == null) InterpretDirectives();
return m_formatVersion;
}
/// <summary>
/// Interprets the source to an object of type <typeparamref name="T" />.
/// Interprets the source to an object.
/// </summary>
/// <param name="type">The output type.</param>
/// <returns>The interpreted object.</returns>
public T Interpret() {
InterpretDirectives();
return (T)InterpretObject(typeof(T));
public object Interpret(Type type) {
try {
if (m_formatVersion == null) InterpretDirectives();
if (_binder == null)
_binder = BinderAttribute.CreateBinderOfType(type);
return InterpretObject(type);
}
catch (Exception ex) {
throw new PdtParsingException(this, ex);
}
}
void InterpretDirectives() {
bool flag = false;
@@ -138,7 +207,10 @@ namespace Cryville.Common.Pdt {
break;
case "format":
ws();
if (GetNumber() != "1")
m_formatVersion = (from i in GetNumber().Split('.') select int.Parse(i)).ToArray();
if (m_formatVersion.Length == 0)
throw new FormatException("Invalid format version");
if (m_formatVersion[0] != 1)
throw new NotSupportedException("Format not supported");
flag = true;
break;
@@ -158,75 +230,105 @@ namespace Cryville.Common.Pdt {
if (!flag) throw new FormatException("Format directive not found");
}
object InterpretObject(Type type) {
var result = ReflectionHelper.InvokeEmptyConstructor(type);
bool dictflag = ReflectionHelper.IsGenericDictionary(type);
var result = Activator.CreateInstance(type);
bool pcflag = PairCollection.IsPairCollection(type);
while (true) {
try { ws(); }
catch (IndexOutOfRangeException) { return result; }
if (cc == '}') {
GetChar();
return result;
}
object pkey = InterpretKey(type);
char c = GetChar();
switch (c) {
case '{':
if (dictflag) {
var ktype = type.GetGenericArguments()[0];
var ptype = type.GetGenericArguments()[1];
object key = _binder.ChangeType(pkey, ktype, null);
object value = InterpretObject(ptype);
((IDictionary)result).Add(key, value);
}
else {
MemberInfo prop;
bool flag = ReflectionHelper.TryFindMemberWithAttribute<ElementListAttribute>(type, out prop);
if (!flag && pkey is string) prop = ReflectionHelper.GetMember(type, (string)pkey);
Type ptype = ReflectionHelper.GetMemberType(prop);
if (ReflectionHelper.IsGenericDictionary(ptype)) {
var ktype = ptype.GetGenericArguments()[0];
var vtype = ptype.GetGenericArguments()[1];
if (flag) {
object key = _binder.ChangeType(pkey, ktype, null);
object value = InterpretObject(vtype);
((IDictionary)ReflectionHelper.GetValue(prop, result)).Add(key, value);
}
else ReflectionHelper.SetValue(prop, result, InterpretObject(ptype));
}
else ReflectionHelper.SetValue(prop, result, InterpretObject(ptype));
}
InterpretObjectInternal<ElementListAttribute>(pcflag, type, pkey, result, type => InterpretObject(type));
break;
case ':':
case ';':
var exp = c == ';' ? _emptyexp : GetExp();
if (dictflag) {
var ktype = type.GetGenericArguments()[0];
var vtype = type.GetGenericArguments()[1];
object key = _binder.ChangeType(pkey, ktype, null);
object value = _binder.ChangeType(exp, vtype, null);
((IDictionary)result).Add(key, value);
}
else {
MemberInfo prop;
bool flag = ReflectionHelper.TryFindMemberWithAttribute<PropertyListAttribute>(type, out prop);
if (!flag && pkey is string) prop = ReflectionHelper.GetMember(type, (string)pkey);
var ptype = ReflectionHelper.GetMemberType(prop);
if (!typeof(IDictionary).IsAssignableFrom(ptype)) {
object value = _binder.ChangeType(exp, ptype, null);
ReflectionHelper.SetValue(prop, result, value, _binder);
}
else {
var ktype = ptype.GetGenericArguments()[0];
var vtype = ptype.GetGenericArguments()[1];
object key = _binder.ChangeType(pkey, ktype, null);
object value = _binder.ChangeType(exp, vtype, null);
((IDictionary)ReflectionHelper.GetValue(prop, result)).Add(key, value);
}
}
var exp = c == ';' ? PdtExpression.Empty : GetExp();
InterpretObjectInternal<PropertyListAttribute>(pcflag, type, pkey, result, type => _binder.ChangeType(exp, type, null));
break;
case '}':
return result;
default:
throw new InvalidOperationException("Internal error: Invalid key interpretation");
}
}
}
void InterpretObjectInternal<T>(bool pcflag, Type type, object pkey, object result, Func<Type, object> vfunc) where T : Attribute {
if (pcflag) {
using (var collection = new PairCollection(result)) {
var ktype = type.GetGenericArguments()[0];
var ptype = type.GetGenericArguments()[1];
object key = _binder.ChangeType(pkey, ktype, null);
object value = vfunc(ptype);
collection.Add(key, value);
}
}
else {
MemberInfo prop = null;
bool flag = false;
if (pkey is string) prop = FieldLikeHelper.GetMember(type, (string)pkey);
if (prop == null) {
prop = FieldLikeHelper.FindMemberWithAttribute<T>(type);
flag = true;
}
if (prop == null) throw new MissingMemberException(string.Format("The property \"{0}\" is not found", pkey));
Type ptype = FieldLikeHelper.GetMemberType(prop);
if (flag) {
var origCollection = FieldLikeHelper.GetValue(prop, result);
if (origCollection == null) {
FieldLikeHelper.SetValue(prop, result, origCollection = Activator.CreateInstance(ptype));
}
using (var collection = new PairCollection(origCollection)) {
var ktype = ptype.GetGenericArguments()[0];
var vtype = ptype.GetGenericArguments()[1];
object key = _binder.ChangeType(pkey, ktype, null);
object value = vfunc(vtype);
collection.Add(key, value);
}
}
else FieldLikeHelper.SetValue(prop, result, vfunc(ptype), _binder);
}
}
/// <summary>
/// Interprets a key from the current position.
/// </summary>
/// <returns>The interpreted key.</returns>
protected virtual object InterpretKey(Type type) {
return tokenb(0x1000).Trim();
}
}
/// <summary>
/// The exception that is thrown when the interpretation of a PDT fails.
/// </summary>
public class PdtParsingException : Exception {
public PdtParsingException(PdtInterpreter interpreter) : this(interpreter, null) { }
public PdtParsingException(PdtInterpreter interpreter, Exception innerException)
: base(GenerateMessage(interpreter, innerException), innerException) { }
static string GenerateMessage(PdtInterpreter interpreter, Exception innerException) {
string src = interpreter.Source;
int pos = interpreter.Position;
if (pos >= src.Length) return "Failed to interpret the PDT: There are some missing or redundant tokens";
int lineStartPos = src.LastIndexOf('\n', pos) + 1;
int previewStartPos = src.LastIndexOf('\n', pos, CMath.Min(64, pos));
if (previewStartPos == -1) {
previewStartPos = pos - 64;
if (previewStartPos < 0) previewStartPos = 0;
}
else previewStartPos++;
int previewEndPos = src.IndexOf('\n', pos, CMath.Min(64, src.Length - pos));
if (previewEndPos == -1) {
previewEndPos = pos + 64;
if (previewEndPos > src.Length) previewEndPos = src.Length;
}
return string.Format(
"Failed to interpret the PDT at line {0}, position {1}: {2}\n{3}",
src.Take(interpreter.Position).Count(c => c == '\n') + 1,
pos - lineStartPos + 1,
innerException == null ? "Unknown error" : innerException.Message,
src.Substring(previewStartPos, previewEndPos - previewStartPos)
);
}
}
}

View File

@@ -1,17 +1,17 @@
using System;
using System;
namespace Cryville.Common.Pdt {
/// <summary>
/// PDT operator.
/// </summary>
public unsafe abstract class PdtOperator {
public abstract unsafe class PdtOperator {
byte* _prmem;
int _loadindex;
readonly PdtVariableMemory[] _operands;
/// <summary>
/// The count of the operands loaded.
/// </summary>
protected int LoadedOperandCount { get { return ParamCount - _loadindex; } }
protected int LoadedOperandCount { get; private set; }
/// <summary>
/// Gets the operand at the specified index.
/// </summary>
@@ -24,37 +24,40 @@ namespace Cryville.Common.Pdt {
int i = index + _loadindex;
return _operands[i];
}
internal int ParamCount { get; private set; }
readonly int _pc;
/// <summary>
/// Creates an instance of the <see cref="PdtOperator" /> class.
/// </summary>
/// <param name="pc">The suggested parameter count.</param>
protected PdtOperator(int pc) {
ParamCount = pc;
_pc = pc;
_operands = new PdtVariableMemory[pc];
}
PdtEvaluatorBase _etor;
bool _rfreq = true;
internal void Begin(PdtEvaluatorBase etor) {
internal void Begin(PdtEvaluatorBase etor, int pc) {
_etor = etor;
_loadindex = ParamCount;
_loadindex = LoadedOperandCount = pc;
}
internal void LoadOperand(PdtVariableMemory mem) {
if (_loadindex == 0) return;
_operands[--_loadindex] = mem;
if (--_loadindex >= _pc) return;
_operands[_loadindex] = mem;
}
internal void Call(byte* prmem, bool noset) {
_prmem = prmem;
_rfreq = false;
try { Execute(); } catch (Exception ex) {
if (_rfreq) _etor.DiscardStack();
throw new InvalidOperationException("Evaluation failed", ex);
throw new EvaluationFailureException("Evaluation failed", ex);
}
if (!_rfreq && !noset) throw new InvalidOperationException("Return frame not set");
if (!_rfreq && !noset) throw new EvaluationFailureException("Return frame not set");
}
/// <summary>
/// Executes the operator.
/// </summary>
/// <remarks>
/// <para>When overridden, this method reads operands by calling <see cref="GetOperand(int)" />, and writes the result to the frame obtained by calling <see cref="GetReturnFrame(int, int)" />.</para>
/// </remarks>
protected abstract void Execute();
/// <summary>
/// Gets a return frame.
@@ -88,7 +91,7 @@ namespace Cryville.Common.Pdt {
/// <param name="name">The name of the operator.</param>
/// <param name="paramCount">The parameter count.</param>
public PdtOperatorSignature(string name, int paramCount)
: this(IdentifierManager.SharedInstance.Request(name), paramCount) { }
: this(IdentifierManager.Shared.Request(name), paramCount) { }
/// <summary>
/// Creates an operator signature.
/// </summary>
@@ -110,7 +113,7 @@ namespace Cryville.Common.Pdt {
return _hash;
}
public override string ToString() {
return string.Format("{0}({1})", IdentifierManager.SharedInstance.Retrieve(Name), ParamCount);
return string.Format("{0}({1})", IdentifierManager.Shared.Retrieve(Name), ParamCount);
}
}
}
}

View File

@@ -1,10 +1,11 @@
using System;
using System;
using UnsafeIL;
namespace Cryville.Common.Pdt {
/// <summary>
/// Span on the memory of a <see cref="PdtEvaluatorBase" />.
/// </summary>
public unsafe struct PdtVariableMemory {
public unsafe struct PdtVariableMemory : IEquatable<PdtVariableMemory> {
readonly byte* _ptr;
/// <summary>
/// The length of the span.
@@ -42,10 +43,20 @@ namespace Cryville.Common.Pdt {
/// <param name="dest">The destination buffer.</param>
/// <param name="destOffset">The offset on the destination buffer to start copying to.</param>
/// <param name="length">The length to copy.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="length" /> is greater than the length of the span.</exception>
public void CopyTo(byte* dest, int destOffset, int length) {
if (length > Length) throw new ArgumentOutOfRangeException("length");
for (int i = 0; i < length; i++)
dest[destOffset + i] = _ptr[i];
}
/// <inheritdoc />
public bool Equals(PdtVariableMemory obj) {
if (Type != obj.Type || Length != obj.Length) return false;
for (int i = 0; i < Length; i++) {
if (*(_ptr + i) != *(obj._ptr + i)) return false;
}
return true;
}
/// <summary>
/// Gets the memory of the span as a number.
/// </summary>
@@ -118,10 +129,43 @@ namespace Cryville.Common.Pdt {
throw new InvalidCastException("Not an identifier");
return *(int*)(_ptr + offset);
}
internal void* TrustedAsOfLength(int len) {
if (Length < len)
throw new InvalidCastException("Type not matched");
return _ptr;
/// <summary>
/// Gets the memory of the span as an instance of the specified type.
/// </summary>
/// <typeparam name="T">The specified type.</typeparam>
/// <param name="offset">The offset on the span to start reading from.</param>
/// <returns>An instance of the specified type.</returns>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="offset" /> is not less than the length of the span.</exception>
/// <exception cref="InvalidCastException">The length of the span is not sufficient.</exception>
/// <remarks>
/// <para>Use <see cref="AsNumber(int)" /> instead while reading an unaligned number.</para>
/// </remarks>
public T As<T>(int offset = 0) {
var len = Unsafe.SizeOf<T>();
if (offset >= Length)
throw new ArgumentOutOfRangeException("offset");
if (offset + len > Length)
throw new InvalidCastException("Frame length not sufficient");
return Unsafe.Read<T>(_ptr + offset);
}
/// <summary>
/// Sets the memory of the span to an instance of the specified type.
/// </summary>
/// <typeparam name="T">The specified type.</typeparam>
/// <param name="value">The value.</param>
/// <param name="offset">The offset from the start of the span.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="offset" /> is not less than the length of the span.</exception>
/// <exception cref="InvalidCastException">The length of the span is not sufficient.</exception>
/// <remarks>
/// <para>Use <see cref="SetNumber(float, int)" /> instead while writing an unaligned number.</para>
/// </remarks>
public void Set<T>(T value, int offset = 0) {
var len = Unsafe.SizeOf<T>();
if (offset >= Length)
throw new ArgumentOutOfRangeException("offset");
if (offset + len > Length)
throw new InvalidCastException("Frame length not sufficient");
Unsafe.Write(_ptr + offset, value);
}
/// <summary>
/// Gets the array suffix.

View File

@@ -1,186 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Cryville.Common {
/// <summary>
/// Provides a set of <see langword="static" /> methods for refletion.
/// </summary>
public static class ReflectionHelper {
static readonly Type[] emptyTypeArray = {};
/// <summary>
/// Gets the parameterless constructor of a type.
/// </summary>
/// <param name="type">The type.</param>
/// <returns>The parameterless constructor of the type.</returns>
public static ConstructorInfo GetEmptyConstructor(Type type) {
return type.GetConstructor(emptyTypeArray);
}
static readonly object[] emptyObjectArray = {};
/// <summary>
/// Invokes the parameterless constructor of a type and returns the result.
/// </summary>
/// <param name="type">The type.</param>
/// <returns>The created instance.</returns>
public static object InvokeEmptyConstructor(Type type) {
return GetEmptyConstructor(type).Invoke(emptyObjectArray);
}
/// <summary>
/// Tries to find a member with the specified attribute type in a type.
/// </summary>
/// <typeparam name="T">The attribute type.</typeparam>
/// <param name="t">The type containing the member with the specified attribute type.</param>
/// <param name="mi">The member.</param>
/// <returns>Whether the member is found.</returns>
public static bool TryFindMemberWithAttribute<T>(Type t, out MemberInfo mi) where T : Attribute {
try {
mi = FindMemberWithAttribute<T>(t);
return true;
}
catch (MissingMemberException) {
mi = null;
return false;
}
}
/// <summary>
/// Finds a member with the specified attribute type in a type.
/// </summary>
/// <typeparam name="T">The attribute type.</typeparam>
/// <param name="type">The type containing the member with the specified attribute type.</param>
/// <returns></returns>
/// <exception cref="MissingMemberException">The member is not found or multiple members are found.</exception>
public static MemberInfo FindMemberWithAttribute<T>(Type type) where T : Attribute {
var mil = type.FindMembers(
MemberTypes.Field | MemberTypes.Property,
BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static,
(m, o) => m.GetCustomAttributes(typeof(T), true).Length != 0,
null
);
if (mil.Length != 1)
throw new MissingMemberException(type.Name, typeof(T).Name);
return mil[0];
}
/// <summary>
/// Gets whether a type is a <see cref="Dictionary{TKey, TValue}" />.
/// </summary>
/// <param name="type">The type.</param>
/// <returns>Whether the type is a <see cref="Dictionary{TKey, TValue}" />.</returns>
public static bool IsGenericDictionary(Type type) {
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary<,>);
}
/// <summary>
/// Gets the member from a type with the specified name.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="name">The name of the member.</param>
/// <returns>The member.</returns>
/// <exception cref="MissingMemberException">The member is not found or multiple members are found.</exception>
public static MemberInfo GetMember(Type type, string name) {
var mil = type.GetMember(
name,
MemberTypes.Field | MemberTypes.Property,
BindingFlags.Public | BindingFlags.Instance
);
if (mil.Length != 1)
throw new MissingMemberException(type.Name, name);
return mil[0];
}
/// <summary>
/// Gets the type of a member.
/// </summary>
/// <param name="mi">The member.</param>
/// <returns>The type of the member.</returns>
/// <exception cref="ArgumentException"><paramref name="mi" /> is not a field or a property.</exception>
public static Type GetMemberType(MemberInfo mi) {
if (mi is FieldInfo)
return ((FieldInfo)mi).FieldType;
if (mi is PropertyInfo)
return ((PropertyInfo)mi).PropertyType;
else
throw new ArgumentException("Member is not field or property.");
}
/// <summary>
/// Gets the value of a member of an object.
/// </summary>
/// <param name="mi">The member.</param>
/// <param name="obj">The object.</param>
/// <returns>The value.</returns>
/// <exception cref="ArgumentException"><paramref name="mi" /> is not a field or a property.</exception>
public static object GetValue(MemberInfo mi, object obj) {
if (mi is FieldInfo)
return ((FieldInfo)mi).GetValue(obj);
else if (mi is PropertyInfo)
return ((PropertyInfo)mi).GetValue(obj, new object[]{});
else
throw new ArgumentException();
}
/// <summary>
/// Sets the value of a member of an object.
/// </summary>
/// <param name="mi">The member.</param>
/// <param name="obj">The object.</param>
/// <param name="value">The value.</param>
/// <param name="binder">An optional binder to convert the value.</param>
/// <exception cref="ArgumentException"><paramref name="mi" /> is not a field or a property.</exception>
public static void SetValue(MemberInfo mi, object obj, object value, Binder binder = null) {
if (mi is FieldInfo)
((FieldInfo)mi).SetValue(obj, value, BindingFlags.Default, binder, null);
else if (mi is PropertyInfo)
((PropertyInfo)mi).SetValue(obj, value, BindingFlags.Default, binder, emptyObjectArray, null);
else
throw new ArgumentException();
}
/// <summary>
/// Gets all the subclasses of a type in the current app domain.
/// </summary>
/// <typeparam name="T">The type.</typeparam>
/// <returns>An array containing all the subclasses of the type in the current app domain.</returns>
public static Type[] GetSubclassesOf<T>() where T : class {
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
IEnumerable<Type> r = new List<Type>();
foreach (var a in assemblies)
r = r.Concat(a.GetTypes().Where(
t => t.IsClass
&& !t.IsAbstract
&& t.IsSubclassOf(typeof(T))
));
return r.ToArray();
}
/// <summary>
/// Gets a simple name of a type.
/// </summary>
/// <param name="type">The type.</param>
/// <returns>A simple name of the class.</returns>
public static string GetSimpleName(Type type) {
string result = type.Name;
var typeargs = type.GetGenericArguments();
if (typeargs.Length > 0) {
result = string.Format("{0}[{1}]", result, string.Join(",", from a in typeargs select GetSimpleName(a)));
}
return result;
}
/// <summary>
/// Gets the namespace qualified name of a type.
/// </summary>
/// <param name="type">The type.</param>
/// <returns>The namespace qualified name of the class.</returns>
public static string GetNamespaceQualifiedName(Type type) {
string result = type.Namespace + "." + type.Name;
var typeargs = type.GetGenericArguments();
if (typeargs.Length > 0) {
result = string.Format("{0}[{1}]", result, string.Join(",", from a in typeargs select GetNamespaceQualifiedName(a)));
}
return result;
}
}
}

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 16857d076fc8d534788424e6c6d180e0
timeCreated: 1608801352
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Text;
using System.Text.RegularExpressions;

View File

@@ -1,4 +1,4 @@
using System;
using System;
using UnityEngine;
namespace Cryville.Common.Unity {

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
@@ -28,8 +28,8 @@ namespace Cryville.Common.Unity {
set { m_filter = value; }
}
public Dictionary<string, string> m_presetPaths = new Dictionary<string, string>();
public Dictionary<string, string> PresetPaths {
public IReadOnlyDictionary<string, string> m_presetPaths = new Dictionary<string, string>();
public IReadOnlyDictionary<string, string> PresetPaths {
get { return m_presetPaths; }
set { m_presetPaths = value; }
}

View File

@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 7548d5a078795b04b8c54524389ba0fe
folderAsset: yes
timeCreated: 1611035780
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,108 +0,0 @@
using System;
using UnityEngine;
namespace Cryville.Common.Unity.Input {
public delegate void InputEventDelegate(InputIdentifier id, InputVector vec);
public abstract class InputHandler : IDisposable {
public event InputEventDelegate OnInput;
~InputHandler() {
Dispose(false);
}
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
public bool Activated { get; private set; }
public void Activate() {
if (Activated) return;
Activated = true;
ActivateImpl();
}
protected abstract void ActivateImpl();
public void Deactivate() {
if (!Activated) return;
Activated = false;
DeactivateImpl();
}
protected abstract void DeactivateImpl();
public abstract void Dispose(bool disposing);
public abstract bool IsNullable(int type);
public abstract byte GetDimension(int type);
public abstract string GetTypeName(int type);
public abstract double GetCurrentTimestamp();
protected void Feed(int type, int id, InputVector vec) {
var del = OnInput;
if (del != null) del(new InputIdentifier { Source = new InputSource { Handler = this, Type = type }, Id = id }, vec);
}
}
public struct InputSource : IEquatable<InputSource> {
public InputHandler Handler { get; set; }
public int Type { get; set; }
public override bool Equals(object obj) {
if (obj == null || !(obj is InputSource)) return false;
return Equals((InputSource)obj);
}
public bool Equals(InputSource other) {
return Handler == other.Handler && Type == other.Type;
}
public override int GetHashCode() {
return Handler.GetHashCode() ^ Type;
}
public override string ToString() {
return string.Format("{0}:{1}", ReflectionHelper.GetSimpleName(Handler.GetType()), Handler.GetTypeName(Type));
}
public static bool operator ==(InputSource lhs, InputSource rhs) {
return lhs.Equals(rhs);
}
public static bool operator !=(InputSource lhs, InputSource rhs) {
return !lhs.Equals(rhs);
}
}
public struct InputIdentifier : IEquatable<InputIdentifier> {
public InputSource Source { get; set; }
public int Id { get; set; }
public override bool Equals(object obj) {
if (obj == null || !(obj is InputIdentifier)) return false;
return Equals((InputIdentifier)obj);
}
public bool Equals(InputIdentifier other) {
return Source == other.Source && Id == other.Id;
}
public override int GetHashCode() {
return Source.GetHashCode() ^ ((Id << 16) | (Id >> 16));
}
public override string ToString() {
return string.Format("{0},{1}", Source, Id);
}
public static bool operator ==(InputIdentifier lhs, InputIdentifier rhs) {
return lhs.Equals(rhs);
}
public static bool operator !=(InputIdentifier lhs, InputIdentifier rhs) {
return !lhs.Equals(rhs);
}
}
public struct InputVector {
public double Time { get; set; }
public bool IsNull { get; set; }
public Vector3 Vector { get; set; }
public InputVector(double time) {
Time = time;
IsNull = true;
Vector = default(Vector3);
}
public InputVector(double time, Vector3 vector) {
Time = time;
IsNull = false;
Vector = vector;
}
public override string ToString() {
if (IsNull) return string.Format("null@{0}", Time);
else return string.Format("{0}@{1}", Vector.ToString("G9"), Time);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 139cf0675329c9d46b902249fecdb500
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,93 +0,0 @@
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Cryville.Common.Unity.Input {
public class InputManager {
static readonly List<Type> HandlerRegistries = new List<Type> {
typeof(WindowsPointerHandler),
typeof(UnityKeyHandler<UnityKeyboardReceiver>),
typeof(UnityKeyHandler<UnityMouseButtonReceiver>),
typeof(UnityMouseHandler),
typeof(UnityTouchHandler),
};
readonly List<InputHandler> _handlers = new List<InputHandler>();
readonly Dictionary<Type, InputHandler> _typemap = new Dictionary<Type, InputHandler>();
readonly Dictionary<InputHandler, double> _timeOrigins = new Dictionary<InputHandler, double>();
readonly object _lock = new object();
readonly Dictionary<InputIdentifier, InputVector> _vectors = new Dictionary<InputIdentifier, InputVector>();
readonly List<InputEvent> _events = new List<InputEvent>();
public InputManager() {
foreach (var t in HandlerRegistries) {
try {
if (!typeof(InputHandler).IsAssignableFrom(t)) continue;
var h = (InputHandler)ReflectionHelper.InvokeEmptyConstructor(t);
_typemap.Add(t, h);
h.OnInput += OnInput;
_handlers.Add(h);
_timeOrigins.Add(h, 0);
Logger.Log("main", 1, "Input", "Initialized {0}", ReflectionHelper.GetSimpleName(t));
}
catch (TargetInvocationException ex) {
Logger.Log("main", 1, "Input", "Cannot initialize {0}: {1}", ReflectionHelper.GetSimpleName(t), ex.InnerException.Message);
}
}
}
public InputHandler GetHandler(string name) {
return _typemap[Type.GetType(name)];
}
public void Activate() {
lock (_lock) {
_events.Clear();
}
foreach (var h in _handlers) h.Activate();
}
public void SyncTime(double time) {
foreach (var h in _handlers) {
_timeOrigins[h] = time - h.GetCurrentTimestamp();
}
}
public void Deactivate() {
foreach (var h in _handlers) h.Deactivate();
}
void OnInput(InputIdentifier id, InputVector vec) {
lock (_lock) {
double timeOrigin = _timeOrigins[id.Source.Handler];
vec.Time += timeOrigin;
InputVector vec0;
if (_vectors.TryGetValue(id, out vec0)) {
_events.Add(new InputEvent {
Id = id,
From = vec0,
To = vec,
});
if (vec.IsNull) _vectors.Remove(id);
else _vectors[id] = vec;
}
else {
_events.Add(new InputEvent {
Id = id,
From = new InputVector(vec.Time),
To = vec,
});
_vectors.Add(id, vec);
}
}
}
public void EnumerateEvents(Action<InputEvent> cb) {
lock (_lock) {
foreach (var ev in _events) cb(ev);
_events.Clear();
}
}
}
public struct InputEvent {
public InputIdentifier Id { get; set; }
public InputVector From { get; set; }
public InputVector To { get; set; }
public override string ToString() {
return string.Format("[{0}] {1} -> {2}", Id, From, To);
}
}
}

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: aaf7daeaf7afb3146b3eea2a07f88055
timeCreated: 1611035810
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,528 +0,0 @@
namespace Cryville.Common.Unity.Input {
public enum WindowMessages : uint {
WM_NULL = 0x0000,
WM_CREATE = 0x0001,
WM_DESTROY = 0x0002,
WM_MOVE = 0x0003,
WM_SIZE = 0x0005,
WM_ACTIVATE = 0x0006,
/*
* WM_ACTIVATE state values
*/
WA_INACTIVE = 0,
WA_ACTIVE = 1,
WA_CLICKACTIVE = 2,
WM_SETFOCUS = 0x0007,
WM_KILLFOCUS = 0x0008,
WM_ENABLE = 0x000A,
WM_SETREDRAW = 0x000B,
WM_SETTEXT = 0x000C,
WM_GETTEXT = 0x000D,
WM_GETTEXTLENGTH = 0x000E,
WM_PAINT = 0x000F,
WM_CLOSE = 0x0010,
//#ifndef _WIN32_WCE
WM_QUERYENDSESSION = 0x0011,
WM_QUERYOPEN = 0x0013,
WM_ENDSESSION = 0x0016,
//#endif
WM_QUIT = 0x0012,
WM_ERASEBKGND = 0x0014,
WM_SYSCOLORCHANGE = 0x0015,
WM_SHOWWINDOW = 0x0018,
WM_WININICHANGE = 0x001A,
//#if(WINVER >= 0x0400)
WM_SETTINGCHANGE = WM_WININICHANGE,
//#endif /* WINVER >= 0x0400 */
WM_DEVMODECHANGE = 0x001B,
WM_ACTIVATEAPP = 0x001C,
WM_FONTCHANGE = 0x001D,
WM_TIMECHANGE = 0x001E,
WM_CANCELMODE = 0x001F,
WM_SETCURSOR = 0x0020,
WM_MOUSEACTIVATE = 0x0021,
WM_CHILDACTIVATE = 0x0022,
WM_QUEUESYNC = 0x0023,
WM_GETMINMAXINFO = 0x0024,
WM_PAINTICON = 0x0026,
WM_ICONERASEBKGND = 0x0027,
WM_NEXTDLGCTL = 0x0028,
WM_SPOOLERSTATUS = 0x002A,
WM_DRAWITEM = 0x002B,
WM_MEASUREITEM = 0x002C,
WM_DELETEITEM = 0x002D,
WM_VKEYTOITEM = 0x002E,
WM_CHARTOITEM = 0x002F,
WM_SETFONT = 0x0030,
WM_GETFONT = 0x0031,
WM_SETHOTKEY = 0x0032,
WM_GETHOTKEY = 0x0033,
WM_QUERYDRAGICON = 0x0037,
WM_COMPAREITEM = 0x0039,
//#if(WINVER >= 0x0500)
//#ifndef _WIN32_WCE
WM_GETOBJECT = 0x003D,
//#endif
//#endif /* WINVER >= 0x0500 */
WM_COMPACTING = 0x0041,
WM_COMMNOTIFY = 0x0044, /* no longer suported */
WM_WINDOWPOSCHANGING = 0x0046,
WM_WINDOWPOSCHANGED = 0x0047,
WM_POWER = 0x0048,
/*
* wParam for WM_POWER window message and DRV_POWER driver notification
*/
/*PWR_OK = 1,
PWR_FAIL = (-1),
PWR_SUSPENDREQUEST = 1,
PWR_SUSPENDRESUME = 2,
PWR_CRITICALRESUME = 3,*/
WM_COPYDATA = 0x004A,
WM_CANCELJOURNAL = 0x004B,
//#if(WINVER >= 0x0400)
WM_NOTIFY = 0x004E,
WM_INPUTLANGCHANGEREQUEST = 0x0050,
WM_INPUTLANGCHANGE = 0x0051,
WM_TCARD = 0x0052,
WM_HELP = 0x0053,
WM_USERCHANGED = 0x0054,
WM_NOTIFYFORMAT = 0x0055,
NFR_ANSI = 1,
NFR_UNICODE = 2,
NF_QUERY = 3,
NF_REQUERY = 4,
WM_CONTEXTMENU = 0x007B,
WM_STYLECHANGING = 0x007C,
WM_STYLECHANGED = 0x007D,
WM_DISPLAYCHANGE = 0x007E,
WM_GETICON = 0x007F,
WM_SETICON = 0x0080,
//#endif /* WINVER >= 0x0400 */
WM_NCCREATE = 0x0081,
WM_NCDESTROY = 0x0082,
WM_NCCALCSIZE = 0x0083,
WM_NCHITTEST = 0x0084,
WM_NCPAINT = 0x0085,
WM_NCACTIVATE = 0x0086,
WM_GETDLGCODE = 0x0087,
//#ifndef _WIN32_WCE
WM_SYNCPAINT = 0x0088,
//#endif
WM_NCMOUSEMOVE = 0x00A0,
WM_NCLBUTTONDOWN = 0x00A1,
WM_NCLBUTTONUP = 0x00A2,
WM_NCLBUTTONDBLCLK = 0x00A3,
WM_NCRBUTTONDOWN = 0x00A4,
WM_NCRBUTTONUP = 0x00A5,
WM_NCRBUTTONDBLCLK = 0x00A6,
WM_NCMBUTTONDOWN = 0x00A7,
WM_NCMBUTTONUP = 0x00A8,
WM_NCMBUTTONDBLCLK = 0x00A9,
//#if(_WIN32_WINNT >= 0x0500)
WM_NCXBUTTONDOWN = 0x00AB,
WM_NCXBUTTONUP = 0x00AC,
WM_NCXBUTTONDBLCLK = 0x00AD,
//#endif /* _WIN32_WINNT >= 0x0500 */
//#if(_WIN32_WINNT >= 0x0501)
WM_INPUT_DEVICE_CHANGE = 0x00FE,
//#endif /* _WIN32_WINNT >= 0x0501 */
//#if(_WIN32_WINNT >= 0x0501)
WM_INPUT = 0x00FF,
//#endif /* _WIN32_WINNT >= 0x0501 */
WM_KEYFIRST = 0x0100,
WM_KEYDOWN = 0x0100,
WM_KEYUP = 0x0101,
WM_CHAR = 0x0102,
WM_DEADCHAR = 0x0103,
WM_SYSKEYDOWN = 0x0104,
WM_SYSKEYUP = 0x0105,
WM_SYSCHAR = 0x0106,
WM_SYSDEADCHAR = 0x0107,
//#if(_WIN32_WINNT >= 0x0501)
WM_UNICHAR = 0x0109,
WM_KEYLAST = 0x0109,
UNICODE_NOCHAR = 0xFFFF,
//#else
WM_KEYLAST__WIN2000 = 0x0108,
//#endif /* _WIN32_WINNT >= 0x0501 */
//#if(WINVER >= 0x0400)
WM_IME_STARTCOMPOSITION = 0x010D,
WM_IME_ENDCOMPOSITION = 0x010E,
WM_IME_COMPOSITION = 0x010F,
WM_IME_KEYLAST = 0x010F,
//#endif /* WINVER >= 0x0400 */
WM_INITDIALOG = 0x0110,
WM_COMMAND = 0x0111,
WM_SYSCOMMAND = 0x0112,
WM_TIMER = 0x0113,
WM_HSCROLL = 0x0114,
WM_VSCROLL = 0x0115,
WM_INITMENU = 0x0116,
WM_INITMENUPOPUP = 0x0117,
//#if(WINVER >= 0x0601)
WM_GESTURE = 0x0119,
WM_GESTURENOTIFY = 0x011A,
//#endif /* WINVER >= 0x0601 */
WM_MENUSELECT = 0x011F,
WM_MENUCHAR = 0x0120,
WM_ENTERIDLE = 0x0121,
//#if(WINVER >= 0x0500)
//#ifndef _WIN32_WCE
WM_MENURBUTTONUP = 0x0122,
WM_MENUDRAG = 0x0123,
WM_MENUGETOBJECT = 0x0124,
WM_UNINITMENUPOPUP = 0x0125,
WM_MENUCOMMAND = 0x0126,
//#ifndef _WIN32_WCE
//#if(_WIN32_WINNT >= 0x0500)
WM_CHANGEUISTATE = 0x0127,
WM_UPDATEUISTATE = 0x0128,
WM_QUERYUISTATE = 0x0129,
/*
* LOWORD(wParam) values in WM_*UISTATE*
*/
UIS_SET = 1,
UIS_CLEAR = 2,
UIS_INITIALIZE = 3,
/*
* HIWORD(wParam) values in WM_*UISTATE*
*/
UISF_HIDEFOCUS = 0x1,
UISF_HIDEACCEL = 0x2,
//#if(_WIN32_WINNT >= 0x0501)
UISF_ACTIVE = 0x4,
//#endif /* _WIN32_WINNT >= 0x0501 */
//#endif /* _WIN32_WINNT >= 0x0500 */
//#endif
//#endif
//#endif /* WINVER >= 0x0500 */
WM_CTLCOLORMSGBOX = 0x0132,
WM_CTLCOLOREDIT = 0x0133,
WM_CTLCOLORLISTBOX = 0x0134,
WM_CTLCOLORBTN = 0x0135,
WM_CTLCOLORDLG = 0x0136,
WM_CTLCOLORSCROLLBAR = 0x0137,
WM_CTLCOLORSTATIC = 0x0138,
MN_GETHMENU = 0x01E1,
WM_MOUSEFIRST = 0x0200,
WM_MOUSEMOVE = 0x0200,
WM_LBUTTONDOWN = 0x0201,
WM_LBUTTONUP = 0x0202,
WM_LBUTTONDBLCLK = 0x0203,
WM_RBUTTONDOWN = 0x0204,
WM_RBUTTONUP = 0x0205,
WM_RBUTTONDBLCLK = 0x0206,
WM_MBUTTONDOWN = 0x0207,
WM_MBUTTONUP = 0x0208,
WM_MBUTTONDBLCLK = 0x0209,
//#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
WM_MOUSEWHEEL = 0x020A,
//#endif
//#if (_WIN32_WINNT >= 0x0500)
WM_XBUTTONDOWN = 0x020B,
WM_XBUTTONUP = 0x020C,
WM_XBUTTONDBLCLK = 0x020D,
//#endif
//#if (_WIN32_WINNT >= 0x0600)
WM_MOUSEHWHEEL = 0x020E,
//#endif
//#if (_WIN32_WINNT >= 0x0600)
WM_MOUSELAST = 0x020E,
//#elif (_WIN32_WINNT >= 0x0500)
WM_MOUSELAST__WIN2000 = 0x020D,
//#elif (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
WM_MOUSELAST__WIN4 = 0x020A,
//#else
WM_MOUSELAST__WIN3 = 0x0209,
//#endif /* (_WIN32_WINNT >= 0x0600) */
//#if(_WIN32_WINNT >= 0x0400)
/* Value for rolling one detent */
WHEEL_DELTA = 120,
//GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam))
/* Setting to scroll one page for SPI_GET/SETWHEELSCROLLLINES */
WHEEL_PAGESCROLL = (uint.MaxValue),
//#endif /* _WIN32_WINNT >= 0x0400 */
//#if(_WIN32_WINNT >= 0x0500)
//GET_KEYSTATE_WPARAM(wParam) (LOWORD(wParam))
//GET_NCHITTEST_WPARAM(wParam) ((short)LOWORD(wParam))
//GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))
/* XButton values are WORD flags */
XBUTTON1 = 0x0001,
XBUTTON2 = 0x0002,
/* Were there to be an XBUTTON3, its value would be 0x0004 */
//#endif /* _WIN32_WINNT >= 0x0500 */
WM_PARENTNOTIFY = 0x0210,
WM_ENTERMENULOOP = 0x0211,
WM_EXITMENULOOP = 0x0212,
//#if(WINVER >= 0x0400)
WM_NEXTMENU = 0x0213,
WM_SIZING = 0x0214,
WM_CAPTURECHANGED = 0x0215,
WM_MOVING = 0x0216,
WM_POWERBROADCAST = 0x0218,
//#endif /* WINVER >= 0x0400 */
//#if(WINVER >= 0x0400)
WM_DEVICECHANGE = 0x0219,
//#endif /* WINVER >= 0x0400 */
WM_MDICREATE = 0x0220,
WM_MDIDESTROY = 0x0221,
WM_MDIACTIVATE = 0x0222,
WM_MDIRESTORE = 0x0223,
WM_MDINEXT = 0x0224,
WM_MDIMAXIMIZE = 0x0225,
WM_MDITILE = 0x0226,
WM_MDICASCADE = 0x0227,
WM_MDIICONARRANGE = 0x0228,
WM_MDIGETACTIVE = 0x0229,
WM_MDISETMENU = 0x0230,
WM_ENTERSIZEMOVE = 0x0231,
WM_EXITSIZEMOVE = 0x0232,
WM_DROPFILES = 0x0233,
WM_MDIREFRESHMENU = 0x0234,
//#if(WINVER >= 0x0602)
WM_POINTERDEVICECHANGE = 0x238,
WM_POINTERDEVICEINRANGE = 0x239,
WM_POINTERDEVICEOUTOFRANGE = 0x23A,
//#endif /* WINVER >= 0x0602 */
//#if(WINVER >= 0x0601)
WM_TOUCH = 0x0240,
//#endif /* WINVER >= 0x0601 */
//#if(WINVER >= 0x0602)
WM_NCPOINTERUPDATE = 0x0241,
WM_NCPOINTERDOWN = 0x0242,
WM_NCPOINTERUP = 0x0243,
WM_POINTERUPDATE = 0x0245,
WM_POINTERDOWN = 0x0246,
WM_POINTERUP = 0x0247,
WM_POINTERENTER = 0x0249,
WM_POINTERLEAVE = 0x024A,
WM_POINTERACTIVATE = 0x024B,
WM_POINTERCAPTURECHANGED = 0x024C,
WM_TOUCHHITTESTING = 0x024D,
WM_POINTERWHEEL = 0x024E,
WM_POINTERHWHEEL = 0x024F,
DM_POINTERHITTEST = 0x0250,
WM_POINTERROUTEDTO = 0x0251,
WM_POINTERROUTEDAWAY = 0x0252,
WM_POINTERROUTEDRELEASED = 0x0253,
//#endif /* WINVER >= 0x0602 */
//#if(WINVER >= 0x0400)
WM_IME_SETCONTEXT = 0x0281,
WM_IME_NOTIFY = 0x0282,
WM_IME_CONTROL = 0x0283,
WM_IME_COMPOSITIONFULL = 0x0284,
WM_IME_SELECT = 0x0285,
WM_IME_CHAR = 0x0286,
//#endif /* WINVER >= 0x0400 */
//#if(WINVER >= 0x0500)
WM_IME_REQUEST = 0x0288,
//#endif /* WINVER >= 0x0500 */
//#if(WINVER >= 0x0400)
WM_IME_KEYDOWN = 0x0290,
WM_IME_KEYUP = 0x0291,
//#endif /* WINVER >= 0x0400 */
//#if((_WIN32_WINNT >= 0x0400) || (WINVER >= 0x0500))
WM_MOUSEHOVER = 0x02A1,
WM_MOUSELEAVE = 0x02A3,
//#endif
//#if(WINVER >= 0x0500)
WM_NCMOUSEHOVER = 0x02A0,
WM_NCMOUSELEAVE = 0x02A2,
//#endif /* WINVER >= 0x0500 */
//#if(_WIN32_WINNT >= 0x0501)
WM_WTSSESSION_CHANGE = 0x02B1,
WM_TABLET_FIRST = 0x02c0,
WM_TABLET_LAST = 0x02df,
//#endif /* _WIN32_WINNT >= 0x0501 */
//#if(WINVER >= 0x0601)
WM_DPICHANGED = 0x02E0,
//#endif /* WINVER >= 0x0601 */
//#if(WINVER >= 0x0605)
WM_DPICHANGED_BEFOREPARENT = 0x02E2,
WM_DPICHANGED_AFTERPARENT = 0x02E3,
WM_GETDPISCALEDSIZE = 0x02E4,
//#endif /* WINVER >= 0x0605 */
WM_CUT = 0x0300,
WM_COPY = 0x0301,
WM_PASTE = 0x0302,
WM_CLEAR = 0x0303,
WM_UNDO = 0x0304,
WM_RENDERFORMAT = 0x0305,
WM_RENDERALLFORMATS = 0x0306,
WM_DESTROYCLIPBOARD = 0x0307,
WM_DRAWCLIPBOARD = 0x0308,
WM_PAINTCLIPBOARD = 0x0309,
WM_VSCROLLCLIPBOARD = 0x030A,
WM_SIZECLIPBOARD = 0x030B,
WM_ASKCBFORMATNAME = 0x030C,
WM_CHANGECBCHAIN = 0x030D,
WM_HSCROLLCLIPBOARD = 0x030E,
WM_QUERYNEWPALETTE = 0x030F,
WM_PALETTEISCHANGING = 0x0310,
WM_PALETTECHANGED = 0x0311,
WM_HOTKEY = 0x0312,
//#if(WINVER >= 0x0400)
WM_PRINT = 0x0317,
WM_PRINTCLIENT = 0x0318,
//#endif /* WINVER >= 0x0400 */
//#if(_WIN32_WINNT >= 0x0500)
WM_APPCOMMAND = 0x0319,
//#endif /* _WIN32_WINNT >= 0x0500 */
//#if(_WIN32_WINNT >= 0x0501)
WM_THEMECHANGED = 0x031A,
//#endif /* _WIN32_WINNT >= 0x0501 */
//#if(_WIN32_WINNT >= 0x0501)
WM_CLIPBOARDUPDATE = 0x031D,
//#endif /* _WIN32_WINNT >= 0x0501 */
//#if(_WIN32_WINNT >= 0x0600)
WM_DWMCOMPOSITIONCHANGED = 0x031E,
WM_DWMNCRENDERINGCHANGED = 0x031F,
WM_DWMCOLORIZATIONCOLORCHANGED= 0x0320,
WM_DWMWINDOWMAXIMIZEDCHANGE = 0x0321,
//#endif /* _WIN32_WINNT >= 0x0600 */
//#if(_WIN32_WINNT >= 0x0601)
WM_DWMSENDICONICTHUMBNAIL = 0x0323,
WM_DWMSENDICONICLIVEPREVIEWBITMAP = 0x0326,
//#endif /* _WIN32_WINNT >= 0x0601 */
//#if(WINVER >= 0x0600)
WM_GETTITLEBARINFOEX = 0x033F,
//#endif /* WINVER >= 0x0600 */
//#if(WINVER >= 0x0400)
//#endif /* WINVER >= 0x0400 */
//#if(WINVER >= 0x0400)
WM_HANDHELDFIRST = 0x0358,
WM_HANDHELDLAST = 0x035F,
WM_AFXFIRST = 0x0360,
WM_AFXLAST = 0x037F,
//#endif /* WINVER >= 0x0400 */
WM_PENWINFIRST = 0x0380,
WM_PENWINLAST = 0x038F,
//#if(WINVER >= 0x0400)
WM_APP = 0x8000,
//#endif /* WINVER >= 0x0400 */
/*
* NOTE: All Message Numbers below 0x0400 are RESERVED.
*
* Private Window Messages Start Here:
*/
WM_USER = 0x0400,
//#if(WINVER >= 0x0400)
/* wParam for WM_SIZING message */
WMSZ_LEFT = 1,
WMSZ_RIGHT = 2,
WMSZ_TOP = 3,
WMSZ_TOPLEFT = 4,
WMSZ_TOPRIGHT = 5,
WMSZ_BOTTOM = 6,
WMSZ_BOTTOMLEFT = 7,
WMSZ_BOTTOMRIGHT = 8,
//#endif /* WINVER >= 0x0400 */
//#ifndef NONCMESSAGES
/*
* WM_NCHITTEST and MOUSEHOOKSTRUCT Mouse Position Codes
*/
/*HTERROR = (-2),
HTTRANSPARENT = (-1),
HTNOWHERE = 0,
HTCLIENT = 1,
HTCAPTION = 2,
HTSYSMENU = 3,
HTGROWBOX = 4,
HTSIZE = HTGROWBOX,
HTMENU = 5,
HTHSCROLL = 6,
HTVSCROLL = 7,
HTMINBUTTON = 8,
HTMAXBUTTON = 9,
HTLEFT = 10,
HTRIGHT = 11,
HTTOP = 12,
HTTOPLEFT = 13,
HTTOPRIGHT = 14,
HTBOTTOM = 15,
HTBOTTOMLEFT = 16,
HTBOTTOMRIGHT = 17,
HTBORDER = 18,
HTREDUCE = HTMINBUTTON,
HTZOOM = HTMAXBUTTON,
HTSIZEFIRST = HTLEFT,
HTSIZELAST = HTBOTTOMRIGHT,
//#if(WINVER >= 0x0400)
HTOBJECT = 19,
HTCLOSE = 20,
HTHELP = 21,
//#endif /* WINVER >= 0x0400 */
}
}

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 466300df0840ba54d95240e3a800a642
timeCreated: 1611373988
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,252 +0,0 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace Cryville.Common.Unity.Input {
static class NativeMethods {
[StructLayout(LayoutKind.Sequential)]
public struct MONITORINFO {
public int cbSize;
public RECT rcMonitor;
public RECT rcWork;
public uint dwFlags;
}
[StructLayout(LayoutKind.Sequential)]
public struct RECT {
public int Left, Top, Right, Bottom;
public RECT(int left, int top, int right, int bottom) {
Left = left;
Top = top;
Right = right;
Bottom = bottom;
}
public int X {
get { return Left; }
set {
Right -= (Left - value);
Left = value;
}
}
public int Y {
get { return Top; }
set {
Bottom -= (Top - value);
Top = value;
}
}
public int Height {
get { return Bottom - Top; }
set { Bottom = value + Top; }
}
public int Width {
get { return Right - Left; }
set { Right = value + Left; }
}
}
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetTouchInputInfo(IntPtr hTouchInput, int cInputs, [Out] TOUCHINPUT[] pInputs, int cbSize);
[StructLayout(LayoutKind.Sequential)]
public struct TOUCHINPUT {
public int x;
public int y;
public IntPtr hSource;
public int dwID;
public TOUCHINPUT_Flags dwFlags;
public TOUCHINPUT_Mask dwMask;
public int dwTime;
public IntPtr dwExtraInfo;
public int cxContact;
public int cyContact;
}
[Flags]
public enum TOUCHINPUT_Flags : int {
TOUCHEVENTF_MOVE = 0x0001,
TOUCHEVENTF_DOWN = 0x0002,
TOUCHEVENTF_UP = 0x0004,
TOUCHEVENTF_INRANGE = 0x0008,
TOUCHEVENTF_PRIMARY = 0x0010,
TOUCHEVENTF_NOCOALESCE = 0x0020,
TOUCHEVENTF_PEN = 0x0040,
TOUCHEVENTF_PALM = 0x0080,
}
[Flags]
public enum TOUCHINPUT_Mask : int {
TOUCHINPUTMASKF_CONTACTAREA = 0x0004,
TOUCHINPUTMASKF_EXTRAINFO = 0x0002,
TOUCHINPUTMASKF_TIMEFROMSYSTEM = 0x0001,
}
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPointerInfo(int pointerID, ref POINTER_INFO pPointerInfo);
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct POINTER_INFO {
public POINTER_INPUT_TYPE pointerType;
public UInt32 pointerId;
public UInt32 frameId;
public POINTER_FLAGS pointerFlags;
public IntPtr sourceDevice;
public IntPtr hwndTarget;
public POINT ptPixelLocation;
public POINT ptHimetricLocation;
public POINT ptPixelLocationRaw;
public POINT ptHimetricLocationRaw;
public UInt32 dwTime;
public UInt32 historyCount;
public Int32 inputData;
public UInt32 dwKeyStates;
public UInt64 PerformanceCount;
public POINTER_BUTTON_CHANGE_TYPE ButtonChangeType;
}
public enum POINTER_INPUT_TYPE {
PT_POINTER = 0x00000001,
PT_TOUCH = 0x00000002,
PT_PEN = 0x00000003,
PT_MOUSE = 0x00000004,
PT_TOUCHPAD = 0x00000005,
}
[Flags]
public enum POINTER_FLAGS {
POINTER_FLAG_NONE = 0x00000000,
POINTER_FLAG_NEW = 0x00000001,
POINTER_FLAG_INRANGE = 0x00000002,
POINTER_FLAG_INCONTACT = 0x00000004,
POINTER_FLAG_FIRSTBUTTON = 0x00000010,
POINTER_FLAG_SECONDBUTTON = 0x00000020,
POINTER_FLAG_THIRDBUTTON = 0x00000040,
POINTER_FLAG_FOURTHBUTTON = 0x00000080,
POINTER_FLAG_FIFTHBUTTON = 0x00000100,
POINTER_FLAG_PRIMARY = 0x00002000,
POINTER_FLAG_CONFIDENCE = 0x00004000,
POINTER_FLAG_CANCELED = 0x00008000,
POINTER_FLAG_DOWN = 0x00010000,
POINTER_FLAG_UPDATE = 0x00020000,
POINTER_FLAG_UP = 0x00040000,
POINTER_FLAG_WHEEL = 0x00080000,
POINTER_FLAG_HWHEEL = 0x00100000,
POINTER_FLAG_CAPTURECHANGED = 0x00200000,
POINTER_FLAG_HASTRANSFORM = 0x00400000,
}
public enum POINTER_BUTTON_CHANGE_TYPE {
POINTER_CHANGE_NONE,
POINTER_CHANGE_FIRSTBUTTON_DOWN,
POINTER_CHANGE_FIRSTBUTTON_UP,
POINTER_CHANGE_SECONDBUTTON_DOWN,
POINTER_CHANGE_SECONDBUTTON_UP,
POINTER_CHANGE_THIRDBUTTON_DOWN,
POINTER_CHANGE_THIRDBUTTON_UP,
POINTER_CHANGE_FOURTHBUTTON_DOWN,
POINTER_CHANGE_FOURTHBUTTON_UP,
POINTER_CHANGE_FIFTHBUTTON_DOWN,
POINTER_CHANGE_FIFTHBUTTON_UP,
}
[StructLayout(LayoutKind.Sequential)]
public struct POINT {
public int X;
public int Y;
}
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPointerTouchInfo(int pointerId, ref POINTER_TOUCH_INFO touchInfo);
[StructLayout(LayoutKind.Sequential)]
public struct POINTER_TOUCH_INFO {
public POINTER_INFO pointerInfo;
public TOUCH_FLAGS touchFlags;
public TOUCH_MASK touchMask;
public RECT rcContact;
public RECT rcContactRaw;
public uint orientation;
public uint pressure;
}
[Flags]
public enum TOUCH_FLAGS {
TOUCH_FLAG_NONE = 0x00000000,
}
[Flags]
public enum TOUCH_MASK {
TOUCH_MASK_NONE = 0x00000000,
TOUCH_MASK_CONTACTAREA = 0x00000001,
TOUCH_MASK_ORIENTATION = 0x00000002,
TOUCH_MASK_PRESSURE = 0x00000004,
}
[DllImport("user32.dll")]
public static extern IntPtr EnableMouseInPointer(bool value);
[DllImport("kernel32.dll")]
public static extern uint GetCurrentThreadId();
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int GetClassName(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
public delegate bool EnumWindowsProc(IntPtr hWnd,IntPtr lParam);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumThreadWindows(uint dwThreadId, EnumWindowsProc lpEnumFunc, IntPtr lParam);
[DllImport("user32.dll")]
public static extern IntPtr MonitorFromWindow(IntPtr hwnd, uint dwFlags);
[DllImport("user32.dll")]
public static extern bool GetMonitorInfo(IntPtr hMonitor, ref MONITORINFO lpmi);
[DllImport("user32.dll", EntryPoint = "SetWindowLong")]
public static extern int SetWindowLong32(IntPtr hWnd, int nIndex, int dwNewLong);
[DllImport("user32.dll", EntryPoint = "SetWindowLongPtr")]
public static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
[DllImport("user32.dll")]
public static extern IntPtr CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hWnd, uint msg, IntPtr wParam,
IntPtr lParam);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool RegisterTouchWindow(IntPtr hWnd, TOUCH_WINDOW_FLAGS ulFlags);
[Flags]
public enum TOUCH_WINDOW_FLAGS {
TWF_FINETOUCH = 1,
TWF_WANTPALM = 2,
}
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool UnregisterTouchWindow(IntPtr hWnd);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern void CloseTouchInputHandle(IntPtr lParam);
[DllImport("user32.dll")]
public static extern bool ScreenToClient(IntPtr hWnd, ref POINT lpPoint);
[DllImport("Kernel32.dll", CharSet = CharSet.Unicode)]
public static extern ushort GlobalAddAtom(string lpString);
[DllImport("Kernel32.dll")]
public static extern ushort GlobalDeleteAtom(ushort nAtom);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int SetProp(IntPtr hWnd, string lpString, int hData);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int RemoveProp(IntPtr hWnd, string lpString);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
[DllImport("kernel32.dll")]
public static extern uint QueryPerformanceFrequency(out Int64 lpFrequency);
[DllImport("kernel32.dll")]
public static extern uint QueryPerformanceCounter(out Int64 lpPerformanceCount);
}
}

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: a6ff72ea2b7f71345aa19940faf026e8
timeCreated: 1622589747
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
using UnityEngine;
namespace Cryville.Common.Unity.Input {
public static class UnityCameraUtils {
public static Vector2 ScreenToWorldPoint(Vector2 pos) {
Vector3 i = pos;
i.z = -Camera.main.transform.localPosition.z;
i = Camera.main.ScreenToWorldPoint(i);
return i;
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 35a1c45601c39f94db20178505a68be2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,114 +0,0 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Cryville.Common.Unity.Input {
public class UnityKeyHandler<T> : InputHandler where T : UnityKeyReceiver<T> {
GameObject receiver;
T recvcomp;
public UnityKeyHandler() { }
protected override void ActivateImpl() {
receiver = new GameObject("__keyrecv__");
recvcomp = receiver.AddComponent<T>();
recvcomp.SetCallback(Feed);
}
protected override void DeactivateImpl() {
if (receiver) GameObject.Destroy(receiver);
}
public override void Dispose(bool disposing) {
if (disposing) {
DeactivateImpl();
}
}
public override bool IsNullable(int type) {
return false;
}
public override byte GetDimension(int type) {
return 0;
}
public override string GetTypeName(int type) {
return recvcomp.GetKeyName(type);
}
public override double GetCurrentTimestamp() {
return Time.realtimeSinceStartupAsDouble;
}
}
public abstract class UnityKeyReceiver<T> : MonoBehaviour where T : UnityKeyReceiver<T> {
protected Action<int, int, InputVector> Callback;
protected readonly List<int> Keys = new List<int>();
public void SetCallback(Action<int, int, InputVector> h) {
Callback = h;
}
public abstract string GetKeyName(int type);
void Awake() {
useGUILayout = false;
}
void Update() {
double time = Time.realtimeSinceStartupAsDouble;
foreach (var k in Keys) {
Callback(k, 0, new InputVector(time, Vector3.zero));
}
}
}
public class UnityKeyboardReceiver : UnityKeyReceiver<UnityKeyboardReceiver> {
public override string GetKeyName(int type) {
return Enum.GetName(typeof(KeyCode), type);
}
void OnGUI() {
var e = Event.current;
if (e.keyCode == KeyCode.None) return;
double time = Time.realtimeSinceStartupAsDouble;
var key = (int)e.keyCode;
switch (e.type) {
case EventType.KeyDown:
if (!Keys.Contains(key)) {
Callback(key, 0, new InputVector(time, Vector3.zero));
Keys.Add(key);
}
break;
case EventType.KeyUp:
Keys.Remove(key);
Callback(key, 0, new InputVector(time));
break;
}
}
}
public class UnityMouseButtonReceiver : UnityKeyReceiver<UnityMouseButtonReceiver> {
public override string GetKeyName(int type) {
switch (type) {
case 0: return "Mouse Left";
case 1: return "Mouse Right";
case 2: return "Mouse Middle";
default: return string.Format("Mouse Button {0}", type);
}
}
void OnGUI() {
var e = Event.current;
double time = Time.realtimeSinceStartupAsDouble;
var key = e.button;
switch (e.type) {
case EventType.MouseDown:
if (!Keys.Contains(key)) {
Callback(key, 0, new InputVector(time, Vector3.zero));
Keys.Add(key);
}
break;
case EventType.MouseUp:
Keys.Remove(key);
Callback(key, 0, new InputVector(time));
break;
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 8aa36fa1966064f489cf5c318f576d3f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,63 +0,0 @@
using System;
using UnityEngine;
using unity = UnityEngine;
namespace Cryville.Common.Unity.Input {
public class UnityMouseHandler : InputHandler {
GameObject receiver;
public UnityMouseHandler() {
if (!unity::Input.mousePresent) {
throw new NotSupportedException("Unity mouse is not supported on this device");
}
}
protected override void ActivateImpl() {
receiver = new GameObject("__mouserecv__");
receiver.AddComponent<UnityMouseReceiver>().SetHandler(this);
}
protected override void DeactivateImpl() {
if (receiver) GameObject.Destroy(receiver);
}
public override void Dispose(bool disposing) {
if (disposing) {
DeactivateImpl();
}
}
public override bool IsNullable(int type) {
if (type != 0) throw new ArgumentOutOfRangeException("type");
return false;
}
public override byte GetDimension(int type) {
if (type != 0) throw new ArgumentOutOfRangeException("type");
return 2;
}
public override string GetTypeName(int type) {
switch (type) {
case 0: return "Mouse Position";
default: throw new ArgumentOutOfRangeException("type");
}
}
public override double GetCurrentTimestamp() {
return Time.realtimeSinceStartupAsDouble;
}
public class UnityMouseReceiver : MonoBehaviour {
UnityMouseHandler handler;
public void SetHandler(UnityMouseHandler h) {
handler = h;
}
void Update() {
double time = Time.realtimeSinceStartupAsDouble;
Vector3 pos = UnityCameraUtils.ScreenToWorldPoint(unity::Input.mousePosition);
handler.Feed(0, 0, new InputVector(time, pos));
}
}
}
}

View File

@@ -1,73 +0,0 @@
using System;
using UnityEngine;
using unity = UnityEngine;
namespace Cryville.Common.Unity.Input {
public class UnityTouchHandler : InputHandler {
GameObject receiver;
public UnityTouchHandler() {
if (!unity::Input.touchSupported) {
throw new NotSupportedException("Unity touch is not supported on this device");
}
}
protected override void ActivateImpl() {
receiver = new GameObject("__touchrecv__");
receiver.AddComponent<UnityPointerReceiver>().SetHandler(this);
}
protected override void DeactivateImpl() {
if (receiver) GameObject.Destroy(receiver);
}
public override void Dispose(bool disposing) {
if (disposing) {
DeactivateImpl();
}
}
public override bool IsNullable(int type) {
if (type != 0) throw new ArgumentOutOfRangeException("type");
return true;
}
public override byte GetDimension(int type) {
if (type != 0) throw new ArgumentOutOfRangeException("type");
return 2;
}
public override string GetTypeName(int type) {
switch (type) {
case 0: return "Touch";
default: throw new ArgumentOutOfRangeException("type");
}
}
public override double GetCurrentTimestamp() {
return Time.realtimeSinceStartupAsDouble;
}
public class UnityPointerReceiver : MonoBehaviour {
UnityTouchHandler handler;
public void SetHandler(UnityTouchHandler h) {
handler = h;
}
void Update() {
double time = Time.realtimeSinceStartupAsDouble;
for (int i = 0; i < unity::Input.touchCount; i++) {
var t = unity::Input.GetTouch(i);
Vector2 pos = UnityCameraUtils.ScreenToWorldPoint(t.position);
var vec = new InputVector(time, pos);
if (t.phase == TouchPhase.Began || t.phase == TouchPhase.Stationary || t.phase == TouchPhase.Moved) {
handler.Feed(0, t.fingerId, vec);
}
else if (t.phase == TouchPhase.Ended || t.phase == TouchPhase.Canceled) {
handler.Feed(0, t.fingerId, vec);
handler.Feed(0, t.fingerId, new InputVector(time));
}
}
}
}
}
}

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 93f60577ebaa5824dba5f322bbd1ad26
timeCreated: 1618910605
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More