mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 11:40:52 +01:00
Compare commits
557 Commits
godot-kill
...
cubed
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d356eb8f7 | ||
|
|
457705ae9c | ||
|
|
a9d8fed436 | ||
|
|
72bcc4a35e | ||
|
|
0f0d47c629 | ||
|
|
027e36f125 | ||
|
|
298efa3a91 | ||
|
|
8c335fc5d0 | ||
|
|
2a2c97e5ba | ||
|
|
117f4a94c2 | ||
|
|
a692dc7817 | ||
|
|
c8b2394dfb | ||
|
|
4417f685ac | ||
|
|
fc9f7827d5 | ||
|
|
8e19f7f14c | ||
|
|
ada2c3f39c | ||
|
|
11f4f3820c | ||
|
|
d3997b51e8 | ||
|
|
2a3624c89c | ||
|
|
62b31d36a4 | ||
|
|
f33f9a7b52 | ||
|
|
467dd0dc28 | ||
|
|
768121bc57 | ||
|
|
3d11cf2f87 | ||
|
|
4eb29a9e80 | ||
|
|
42932b3ff6 | ||
|
|
9f956cef95 | ||
|
|
bd7b316f1d | ||
|
|
df9be436c4 | ||
|
|
6870cef9e6 | ||
|
|
5fd0718f6a | ||
|
|
343667442b | ||
|
|
9fd675a8b9 | ||
|
|
e10707982c | ||
|
|
4b5cf26153 | ||
|
|
9b8c122f03 | ||
|
|
766e2c81e2 | ||
|
|
a4bf3161fc | ||
|
|
4a3aacedea | ||
|
|
f360978973 | ||
|
|
d945247f31 | ||
|
|
997f1c031f | ||
|
|
613368edde | ||
|
|
33a62127a9 | ||
|
|
28fe0313d1 | ||
|
|
8f16b188dd | ||
|
|
ae1e9c3a71 | ||
|
|
d1dc84c632 | ||
|
|
861e19da76 | ||
|
|
3ab02acf46 | ||
|
|
103fca8bc7 | ||
|
|
dd98f3cbad | ||
|
|
e7ccef53de | ||
|
|
4e3f5508e9 | ||
|
|
a2ea21c3c5 | ||
|
|
e2bbffd509 | ||
|
|
0e721feea3 | ||
|
|
ab465d2af8 | ||
|
|
9b77ba4605 | ||
|
|
132f15b32d | ||
|
|
6249ae8d0d | ||
|
|
0cda9ecbee | ||
|
|
ae85645e23 | ||
|
|
237c6e433c | ||
|
|
dfc1e99092 | ||
|
|
1f0ec7fa68 | ||
|
|
18f90bd125 | ||
|
|
22cf53fd1c | ||
|
|
0739367013 | ||
|
|
d14348dfa5 | ||
|
|
0348919104 | ||
|
|
414a264ea9 | ||
|
|
c09fc5f021 | ||
|
|
b458dd96a3 | ||
|
|
ed134da488 | ||
|
|
32db0f82f1 | ||
|
|
6817969c8b | ||
|
|
5c77c1a8b8 | ||
|
|
30db86fae8 | ||
|
|
78a33076f9 | ||
|
|
7a77fa59e2 | ||
|
|
22bf1516cf | ||
|
|
14116cdbdf | ||
|
|
74a940ca9e | ||
|
|
7339be51fe | ||
|
|
dadaa3fb8f | ||
|
|
150c899f6f | ||
|
|
928a5e3521 | ||
|
|
5037ace00b | ||
|
|
3faa52ee01 | ||
|
|
7d8992e0ca | ||
|
|
131a1ee3bd | ||
|
|
ba390ba466 | ||
|
|
a69738a7a4 | ||
|
|
8d30bcb041 | ||
|
|
da579d6b57 | ||
|
|
4e6906fa7f | ||
|
|
45c77e10a1 | ||
|
|
4a900cbd7f | ||
|
|
9b5b8205b9 | ||
|
|
37aee07596 | ||
|
|
58d0a771e8 | ||
|
|
aa3e126249 | ||
|
|
1c39a36297 | ||
|
|
259f6c8ea4 | ||
|
|
6d8bfcc7bb | ||
|
|
900910e4de | ||
|
|
3f979ef7f2 | ||
|
|
1a4196697f | ||
|
|
a76191c138 | ||
|
|
cb563c75fd | ||
|
|
472bd67ace | ||
|
|
2f94beb4b5 | ||
|
|
47d4a8f628 | ||
|
|
3c08f56619 | ||
|
|
761b06d68a | ||
|
|
2b037c3bf2 | ||
|
|
f2c8b343bb | ||
|
|
531cfeb9e6 | ||
|
|
21b29e26e2 | ||
|
|
2b8645b60f | ||
|
|
f5c0dba194 | ||
|
|
2c7630f4f1 | ||
|
|
610bfea95c | ||
|
|
6c0c395dc7 | ||
|
|
99f96aee27 | ||
|
|
d075c82041 | ||
|
|
f71d72d88c | ||
|
|
df34ce025a | ||
|
|
5ff164e762 | ||
|
|
9f7a1e066b | ||
|
|
58dcea5bda | ||
|
|
3f0032911a | ||
|
|
c8c17da176 | ||
|
|
08ba611fe6 | ||
|
|
7442f52297 | ||
|
|
ba80ba5cc1 | ||
|
|
1db0694541 | ||
|
|
f6b894f274 | ||
|
|
52e5afd277 | ||
|
|
1899544500 | ||
|
|
f893d308ad | ||
|
|
2fc8e6af46 | ||
|
|
3095952dcb | ||
|
|
ea8e5e9fe7 | ||
|
|
026f6cb118 | ||
|
|
12787db8de | ||
|
|
31fb926127 | ||
|
|
66ea13684b | ||
|
|
69ff3638ba | ||
|
|
6cfe6caae2 | ||
|
|
ab1f4fb0e7 | ||
|
|
9b15070126 | ||
|
|
4eb100076d | ||
|
|
6156a9eae8 | ||
|
|
2e762fbaf4 | ||
|
|
dec9ea744d | ||
|
|
89094458cd | ||
|
|
31adf9e4fc | ||
|
|
563cc262cb | ||
|
|
13ef4e8423 | ||
|
|
f3669e6646 | ||
|
|
d9a411b260 | ||
|
|
9de0c9b299 | ||
|
|
73e89f9e27 | ||
|
|
063c30e2bf | ||
|
|
1263e10f5e | ||
|
|
36822462ba | ||
|
|
519c28cad2 | ||
|
|
e82f969589 | ||
|
|
c67a1475f9 | ||
|
|
1353dde41d | ||
|
|
a9ce50a6a5 | ||
|
|
134141feaf | ||
|
|
844e9776f3 | ||
|
|
cbe2fe698a | ||
|
|
da440bbf28 | ||
|
|
5025178203 | ||
|
|
1493f67c94 | ||
|
|
07b0548532 | ||
|
|
d3e7e12adf | ||
|
|
89f6a0917a | ||
|
|
a3879b7bbd | ||
|
|
64112c556e | ||
|
|
a7abfcdf0f | ||
|
|
344325c9a4 | ||
|
|
ffe506ef94 | ||
|
|
b105ef3e7b | ||
|
|
a7d7fdd12b | ||
|
|
86be98005c | ||
|
|
6e621f6398 | ||
|
|
5c550888f6 | ||
|
|
bc6a0f4578 | ||
|
|
e2fcf919c5 | ||
|
|
3f1c33fc96 | ||
|
|
0494d59a5a | ||
|
|
5b35e1b016 | ||
|
|
d092a63b28 | ||
|
|
182c4fb5dc | ||
|
|
631ff903b4 | ||
|
|
e3d28423c5 | ||
|
|
64b33439e5 | ||
|
|
bf7c49041f | ||
|
|
68db826e8e | ||
|
|
e519b6b53d | ||
|
|
0a976b5438 | ||
|
|
cd7a4f0b15 | ||
|
|
30fff3fba5 | ||
|
|
9d4dec2ea7 | ||
|
|
6e2458f708 | ||
|
|
5c64190733 | ||
|
|
44ada991f2 | ||
|
|
5e37c7a746 | ||
|
|
08c4ef1ccf | ||
|
|
baf85f6ab2 | ||
|
|
72402f3983 | ||
|
|
5252b1e99b | ||
|
|
896b664590 | ||
|
|
381efbd857 | ||
|
|
be2904ca17 | ||
|
|
414177973d | ||
|
|
8aaacce195 | ||
|
|
6ecd86b9af | ||
|
|
324770630d | ||
|
|
78ebf99296 | ||
|
|
ac254c3eac | ||
|
|
9d8d712aea | ||
|
|
dc2c139692 | ||
|
|
6fdb09aa06 | ||
|
|
ce44aa0060 | ||
|
|
5baf2678c3 | ||
|
|
650b93ce37 | ||
|
|
9f20366c43 | ||
|
|
333801b1c9 | ||
|
|
7067c120ed | ||
|
|
9868f186f3 | ||
|
|
56f566af7b | ||
|
|
437fd04e87 | ||
|
|
72f7310890 | ||
|
|
7dde058319 | ||
|
|
55a50ff7ba | ||
|
|
1da37d24ae | ||
|
|
81641f49dc | ||
|
|
5d5b897a9b | ||
|
|
65a8d33d0c | ||
|
|
b397a43845 | ||
|
|
2651a3db56 | ||
|
|
2fc636b7b9 | ||
|
|
fd47179d79 | ||
|
|
6ed7684954 | ||
|
|
b40413dfd6 | ||
|
|
3d2228e64e | ||
|
|
60fa8080c4 | ||
|
|
11046f8068 | ||
|
|
8a61259c11 | ||
|
|
7239e70294 | ||
|
|
00f982cb89 | ||
|
|
d08823322a | ||
|
|
7fc99ee528 | ||
|
|
dc57178258 | ||
|
|
b87adb2294 | ||
|
|
e2c60871e9 | ||
|
|
c8ff91bf72 | ||
|
|
1108fd94ce | ||
|
|
73a34fc53a | ||
|
|
64ff64ea77 | ||
|
|
566ed9cbdc | ||
|
|
782f36ee63 | ||
|
|
f05f3eec3e | ||
|
|
240c9a2df0 | ||
|
|
ea18d6983e | ||
|
|
ebc7c1ab3f | ||
|
|
4d30d5af78 | ||
|
|
dba0815585 | ||
|
|
5b3aaea5ec | ||
|
|
58aac5ea2b | ||
|
|
f2eb035ed8 | ||
|
|
dccdbe743c | ||
|
|
5fee08e68b | ||
|
|
0477b58861 | ||
|
|
c5c9f2dbd3 | ||
|
|
1c059e2437 | ||
|
|
94e1f90c97 | ||
|
|
daf0d1dd6c | ||
|
|
f2ac151917 | ||
|
|
5c445229d4 | ||
|
|
8765c67872 | ||
|
|
c0b19dcca1 | ||
|
|
3d00d491c4 | ||
|
|
b421143463 | ||
|
|
25f14ff1b6 | ||
|
|
0a5f9d4b0b | ||
|
|
4cc30823a6 | ||
|
|
e790e97a50 | ||
|
|
62f25669c7 | ||
|
|
814b686cb7 | ||
|
|
d0ec77e804 | ||
|
|
eff7fa8408 | ||
|
|
51989a8ccc | ||
|
|
c16ef6ce77 | ||
|
|
2a08389235 | ||
|
|
dd7159eec0 | ||
|
|
366d0ab2d5 | ||
|
|
7dc32af73f | ||
|
|
943b000950 | ||
|
|
bb322e30ee | ||
|
|
117cf14e5c | ||
|
|
081ced42df | ||
|
|
3a9ccfe470 | ||
|
|
19d7cd4455 | ||
|
|
97d8f7d936 | ||
|
|
6833ffd19f | ||
|
|
509497b784 | ||
|
|
d3b8a07350 | ||
|
|
8291294aa1 | ||
|
|
a8d6c294ab | ||
|
|
fc67c5069c | ||
|
|
7f9f593989 | ||
|
|
ff5334f446 | ||
|
|
cb5f2ffae1 | ||
|
|
cdac0d5757 | ||
|
|
c727dbd07e | ||
|
|
95f9126d12 | ||
|
|
265a9abeb6 | ||
|
|
6e32588be7 | ||
|
|
71fd6d427c | ||
|
|
aff2631f23 | ||
|
|
3f01fb0879 | ||
|
|
02ca521cc5 | ||
|
|
468fbda539 | ||
|
|
175085f32e | ||
|
|
96543421f2 | ||
|
|
10261a15b2 | ||
|
|
11ac144ae1 | ||
|
|
db6d9160e4 | ||
|
|
896758e176 | ||
|
|
768fed2421 | ||
|
|
98c1e43fe6 | ||
|
|
7fce46ec44 | ||
|
|
b1b6e2dd5c | ||
|
|
9ea9f452ec | ||
|
|
d9968e2e62 | ||
|
|
5e2a1d889d | ||
|
|
72c4d56639 | ||
|
|
e7bf2d0ac9 | ||
|
|
daa13de9ed | ||
|
|
8d0012223e | ||
|
|
78416ad157 | ||
|
|
fc4e3be40a | ||
|
|
57fb38c04d | ||
|
|
5fd7f9a6d8 | ||
|
|
096b7f6bca | ||
|
|
6a331cfdf6 | ||
|
|
b6bc2e591b | ||
|
|
89726ebeec | ||
|
|
0a41ef3c9a | ||
|
|
0e65843f39 | ||
|
|
066f6b9443 | ||
|
|
be0c520455 | ||
|
|
e62021cb92 | ||
|
|
c0eca4f6c2 | ||
|
|
bcf60c404d | ||
|
|
6f201ccddc | ||
|
|
85a4375905 | ||
|
|
fa10e1c330 | ||
|
|
170b8717c1 | ||
|
|
effb731340 | ||
|
|
7e08c5d743 | ||
|
|
0e31193e7f | ||
|
|
97c8297ce1 | ||
|
|
120cab811f | ||
|
|
d7e5c12a3d | ||
|
|
4eb4e47975 | ||
|
|
3d0d999f25 | ||
|
|
7e13447455 | ||
|
|
fdfbf92223 | ||
|
|
9290ab445a | ||
|
|
51bbc7e565 | ||
|
|
be379b2e20 | ||
|
|
6d377ee1e3 | ||
|
|
a1d899ee31 | ||
|
|
39a2c9db86 | ||
|
|
66999a4a5d | ||
|
|
2d30eb0321 | ||
|
|
b26a370504 | ||
|
|
30cafea218 | ||
|
|
d9297fa1c9 | ||
|
|
9355938f6a | ||
|
|
c5ef7fd134 | ||
|
|
112b694099 | ||
|
|
e0512a1052 | ||
|
|
ed56c39e1b | ||
|
|
117fcf2aa2 | ||
|
|
4fd24e8de9 | ||
|
|
a4f2441153 | ||
|
|
e1f2742c8f | ||
|
|
6f26f77ce6 | ||
|
|
da1baba550 | ||
|
|
dd53239554 | ||
|
|
25f9ba5ec2 | ||
|
|
ed97cbb42d | ||
|
|
78bbac52f0 | ||
|
|
83c738e423 | ||
|
|
b0a8e3923b | ||
|
|
311bd2b874 | ||
|
|
59caaeca8c | ||
|
|
832be75c5c | ||
|
|
08e214b3d2 | ||
|
|
f75ee08030 | ||
|
|
cd9aed6696 | ||
|
|
040dc2445c | ||
|
|
414bd95eb2 | ||
|
|
17424cc3f3 | ||
|
|
795af9d0f4 | ||
|
|
91d0936a99 | ||
|
|
89ff434528 | ||
|
|
8c46c06497 | ||
|
|
04c95d4ff8 | ||
|
|
ecb641f403 | ||
|
|
e10e7d165a | ||
|
|
03edfc46cb | ||
|
|
13ad6f3f37 | ||
|
|
8ec83a7654 | ||
|
|
de68a62187 | ||
|
|
95197075a5 | ||
|
|
167aa4791b | ||
|
|
f38eb13866 | ||
|
|
0c1c6cee0e | ||
|
|
c8a28b8c83 | ||
|
|
81b521a8e4 | ||
|
|
441980e1cb | ||
|
|
8f976ce810 | ||
|
|
c2e8ee0fcd | ||
|
|
8d2ea9aed1 | ||
|
|
31ca502418 | ||
|
|
7318247da2 | ||
|
|
bed9a082bc | ||
|
|
5694f4ff28 | ||
|
|
0865398fe1 | ||
|
|
fb2feee93b | ||
|
|
093481cb77 | ||
|
|
60f46afddd | ||
|
|
c504e58226 | ||
|
|
4cb9bd3332 | ||
|
|
f2cdb0d68c | ||
|
|
e3720ebe01 | ||
|
|
5d07887251 | ||
|
|
ed340f7df9 | ||
|
|
0de8615033 | ||
|
|
091c1b935b | ||
|
|
04b14e92e7 | ||
|
|
e6c4cbb662 | ||
|
|
1b57d4ec0b | ||
|
|
2a6696f7e3 | ||
|
|
981bbc61ee | ||
|
|
78c393aac5 | ||
|
|
09c36b57cd | ||
|
|
a8be3a2844 | ||
|
|
4ae2f6b667 | ||
|
|
eb683e1838 | ||
|
|
222e19ddc4 | ||
|
|
ae42a3e3fa | ||
|
|
9a4c1cae1e | ||
|
|
67f433aeb2 | ||
|
|
413680b602 | ||
|
|
822e6b7f6d | ||
|
|
d3a67107bb | ||
|
|
00995d6a30 | ||
|
|
ef57a4f4c3 | ||
|
|
1c2caca7e1 | ||
|
|
9115610d2f | ||
|
|
99c956dfb4 | ||
|
|
6a1bed31ae | ||
|
|
017a63f41c | ||
|
|
5e872ec1e3 | ||
|
|
e314446575 | ||
|
|
58c7255087 | ||
|
|
58ac8f0dba | ||
|
|
e5024e80f4 | ||
|
|
00f6564351 | ||
|
|
b32f695509 | ||
|
|
f74bf680e7 | ||
|
|
02802c0e70 | ||
|
|
300c2c05e4 | ||
|
|
f9e192b01e | ||
|
|
7c6c8dcd41 | ||
|
|
18c91e6be4 | ||
|
|
6a9a727e1f | ||
|
|
d7f5c1d9db | ||
|
|
97dfe3c216 | ||
|
|
b65f108268 | ||
|
|
4892d0d0fa | ||
|
|
bb4a1eda8e | ||
|
|
110bd0921a | ||
|
|
61aba8fc50 | ||
|
|
dc4cc71c72 | ||
|
|
322c706924 | ||
|
|
8650143b8c | ||
|
|
b92ea9a2aa | ||
|
|
1b38996905 | ||
|
|
e7a8e9b1aa | ||
|
|
a7d3b31ec4 | ||
|
|
10440648bc | ||
|
|
5226039b7c | ||
|
|
3bad55a705 | ||
|
|
bb7288d26a | ||
|
|
b30c2155c7 | ||
|
|
70449b9ca2 | ||
|
|
7323e454e4 | ||
|
|
f7ccac2c11 | ||
|
|
4d233ef6c2 | ||
|
|
c10f7f2707 | ||
|
|
9db3473b7a | ||
|
|
0b63dbd1f2 | ||
|
|
1403c14acb | ||
|
|
ab8feee660 | ||
|
|
e6417582c8 | ||
|
|
977f51a9be | ||
|
|
9977d64e2f | ||
|
|
2d6a529725 | ||
|
|
ddbeccdb8c | ||
|
|
1fd6488362 | ||
|
|
f954bcb3e8 | ||
|
|
17ebeac107 | ||
|
|
c4fb96b5e8 | ||
|
|
2a9441a6da | ||
|
|
55cf1c10a8 | ||
|
|
967f144970 | ||
|
|
f548fd970e | ||
|
|
5077b5ec4e | ||
|
|
cd919302f8 | ||
|
|
f1c450e588 | ||
|
|
d6f288b667 | ||
|
|
6a9dac1b4e | ||
|
|
dec103ac1b | ||
|
|
d6a9343635 | ||
|
|
dc6e186a26 | ||
|
|
4c02a2c059 | ||
|
|
7d8ba30844 | ||
|
|
1b4cbf58b8 | ||
|
|
6da21ab6c1 | ||
|
|
0340cecd6d | ||
|
|
878fade1bd | ||
|
|
285f68b4dd | ||
|
|
afc2a747c8 | ||
|
|
3c9bcae474 | ||
|
|
5c8986c075 | ||
|
|
454e5df939 | ||
|
|
c83ad3ab94 | ||
|
|
1572d1fb3d | ||
|
|
e032557c08 | ||
|
|
4979620486 | ||
|
|
3889066e9c | ||
|
|
2c523115ab | ||
|
|
d62a6041ed | ||
|
|
cde26f0567 | ||
|
|
cf2995437f |
@@ -9,7 +9,7 @@ version: 0.1.0.{build}
|
||||
pull_requests:
|
||||
do_not_increment_build_number: true
|
||||
|
||||
image: Visual Studio 2017
|
||||
image: Visual Studio 2019
|
||||
install:
|
||||
- ps: >
|
||||
if (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER -And $env:APPVEYOR_REPO_BRANCH -Eq "master")
|
||||
@@ -19,23 +19,19 @@ install:
|
||||
|
||||
before_build:
|
||||
- cmd: py -3.5 -m pip install --user requests
|
||||
- cmd: py -3.5 Tools\download_godotsharp.py
|
||||
- cmd: py -3.5 RUN_THIS.py --no-prompt
|
||||
- cmd: nuget restore RobustToolbox.sln
|
||||
- ps: >
|
||||
if (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER -And $env:APPVEYOR_REPO_BRANCH -Eq "master")
|
||||
{
|
||||
SonarScanner.MSBuild.exe begin /k:"ss14" /d:"sonar.host.url=https://sonarqube.com" /d:"sonar.login=$env:sonarqubekey" /o:"space-wizards" /d:"sonar.exclusions=SFML/**" /d:sonar.cs.nunit.reportsPaths="$(Get-Location)\nunitTestResult.xml";
|
||||
SonarScanner.MSBuild.exe begin /k:"ss14" /d:"sonar.host.url=https://sonarcloud.io" /d:"sonar.login=$env:sonarqubekey" /o:"space-wizards" /d:sonar.cs.nunit.reportsPaths="$(Get-Location)\nunitTestResult.xml";
|
||||
}
|
||||
|
||||
platform: x64
|
||||
configuration: Debug
|
||||
|
||||
cache:
|
||||
- packages -> **\packages.config
|
||||
- packages -> **\*.csproj
|
||||
- Dependencies
|
||||
- Robust.Client.Godot\.mono\assemblies\GodotSharp.dll
|
||||
- Robust.Client.Godot\.mono\assemblies\LAST_MODIFIED
|
||||
|
||||
build:
|
||||
project: RobustToolbox.sln
|
||||
@@ -43,12 +39,10 @@ build:
|
||||
verbosity: minimal
|
||||
|
||||
build_script:
|
||||
- ps: msbuild RobustToolbox.sln /verbosity:minimal /nologo /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Platform=x64 /p:Configuration=Debug /p:AppVeyor=yes
|
||||
- ps: dotnet build RobustToolbox.sln /p:AppVeyor=yes
|
||||
|
||||
test_script:
|
||||
- ps: nunit3-console.exe .\bin\UnitTesting\Robust.UnitTesting.dll;
|
||||
|
||||
|
||||
- ps: dotnet test Robust.UnitTesting/Robust.UnitTesting.csproj
|
||||
|
||||
after_test:
|
||||
- ps: >
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -92,3 +92,4 @@ Dependencies/
|
||||
__pycache__
|
||||
.mypy_cache
|
||||
|
||||
MSBuild/Robust.Custom.targets
|
||||
|
||||
10
.travis.yml
10
.travis.yml
@@ -2,6 +2,8 @@ language: csharp
|
||||
|
||||
dist: trusty
|
||||
sudo: false
|
||||
mono: none
|
||||
# dotnet: 3.1.100 # Travis is shitting itself right now and it can't locate .NET Core packages.
|
||||
|
||||
os:
|
||||
- linux
|
||||
@@ -22,6 +24,9 @@ cache:
|
||||
- Dependencies/
|
||||
- Robust.Client.Godot/.mono/assemblies/
|
||||
|
||||
install:
|
||||
- curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version 3.1.100
|
||||
|
||||
#before_install:
|
||||
# - if [ $TRAVIS_OS_NAME = osx ]; then brew update && brew upgrade python; fi
|
||||
|
||||
@@ -31,11 +36,8 @@ before_script:
|
||||
#- "python3.6 -m pip --v"
|
||||
#- "python3.6 -m pip install --user --upgrade requests"
|
||||
- "python3.5 -m pip install --user requests"
|
||||
- "nuget restore RobustToolbox.sln"
|
||||
- "python3.5 RUN_THIS.py --no-prompt"
|
||||
- "Tools/download_godotsharp.py"
|
||||
|
||||
script:
|
||||
- "msbuild /p:Configuration=Debug /p:Platform=x64 /p:HEADLESS=1 /nologo /m /p:AllowMissingMacNatives=yes RobustToolbox.sln /p:Python=python3.5"
|
||||
- "mono --debug packages/nunit.consolerunner/3.9.0/tools/nunit3-console.exe bin/UnitTesting/Robust.UnitTesting.dll"
|
||||
- "Tools/run_travis.sh"
|
||||
|
||||
|
||||
@@ -26,8 +26,6 @@ https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFrameworkMoniker>.NETFramework, Version=v4.6.1</TargetFrameworkMoniker>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' " />
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' " />
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' " />
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' " />
|
||||
<PropertyGroup>
|
||||
@@ -42,4 +40,4 @@ https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild
|
||||
</Target>
|
||||
<Target Name="Compile" />
|
||||
<Target Name="CoreCompile" />
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -81,7 +81,7 @@ def install_hooks():
|
||||
|
||||
for filename in os.listdir(str(hooks_source_dir)):
|
||||
print("Copying hook {}".format(filename))
|
||||
shutil.copyfile(str(hooks_source_dir/filename), str(hooks_target_dir/filename))
|
||||
shutil.copy2(str(hooks_source_dir/filename), str(hooks_target_dir/filename))
|
||||
|
||||
|
||||
def reset_solution():
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
public abstract class NetCryptoProviderBase : NetEncryption
|
||||
{
|
||||
protected SymmetricAlgorithm m_algorithm;
|
||||
|
||||
public NetCryptoProviderBase(NetPeer peer, SymmetricAlgorithm algo)
|
||||
: base(peer)
|
||||
{
|
||||
m_algorithm = algo;
|
||||
m_algorithm.GenerateKey();
|
||||
m_algorithm.GenerateIV();
|
||||
}
|
||||
|
||||
public override void SetKey(byte[] data, int offset, int count)
|
||||
{
|
||||
int len = m_algorithm.Key.Length;
|
||||
var key = new byte[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
key[i] = data[offset + (i % count)];
|
||||
m_algorithm.Key = key;
|
||||
|
||||
len = m_algorithm.IV.Length;
|
||||
key = new byte[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
key[len - 1 - i] = data[offset + (i % count)];
|
||||
m_algorithm.IV = key;
|
||||
}
|
||||
|
||||
public override bool Encrypt(NetOutgoingMessage msg)
|
||||
{
|
||||
int unEncLenBits = msg.LengthBits;
|
||||
|
||||
var ms = new MemoryStream();
|
||||
var cs = new CryptoStream(ms, m_algorithm.CreateEncryptor(), CryptoStreamMode.Write);
|
||||
cs.Write(msg.m_data, 0, msg.LengthBytes);
|
||||
cs.Close();
|
||||
|
||||
// get results
|
||||
var arr = ms.ToArray();
|
||||
ms.Close();
|
||||
|
||||
msg.EnsureBufferSize((arr.Length + 4) * 8);
|
||||
msg.LengthBits = 0; // reset write pointer
|
||||
msg.Write((uint)unEncLenBits);
|
||||
msg.Write(arr);
|
||||
msg.LengthBits = (arr.Length + 4) * 8;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Decrypt(NetIncomingMessage msg)
|
||||
{
|
||||
int unEncLenBits = (int)msg.ReadUInt32();
|
||||
|
||||
var ms = new MemoryStream(msg.m_data, 4, msg.LengthBytes - 4);
|
||||
var cs = new CryptoStream(ms, m_algorithm.CreateDecryptor(), CryptoStreamMode.Read);
|
||||
|
||||
var byteLen = NetUtility.BytesToHoldBits(unEncLenBits);
|
||||
var result = m_peer.GetStorage(byteLen);
|
||||
cs.Read(result, 0, byteLen);
|
||||
cs.Close();
|
||||
|
||||
// TODO: recycle existing msg
|
||||
|
||||
msg.m_data = result;
|
||||
msg.m_bitLength = unEncLenBits;
|
||||
msg.m_readPosition = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
public abstract class NetCryptoProviderEncryption : NetEncryption
|
||||
{
|
||||
public NetCryptoProviderEncryption(NetPeer peer)
|
||||
: base(peer)
|
||||
{
|
||||
}
|
||||
|
||||
protected abstract CryptoStream GetEncryptStream(MemoryStream ms);
|
||||
|
||||
protected abstract CryptoStream GetDecryptStream(MemoryStream ms);
|
||||
|
||||
public override bool Encrypt(NetOutgoingMessage msg)
|
||||
{
|
||||
int unEncLenBits = msg.LengthBits;
|
||||
|
||||
var ms = new MemoryStream();
|
||||
var cs = GetEncryptStream(ms);
|
||||
cs.Write(msg.m_data, 0, msg.LengthBytes);
|
||||
cs.Close();
|
||||
|
||||
// get results
|
||||
var arr = ms.ToArray();
|
||||
ms.Close();
|
||||
|
||||
msg.EnsureBufferSize((arr.Length + 4) * 8);
|
||||
msg.LengthBits = 0; // reset write pointer
|
||||
msg.Write((uint)unEncLenBits);
|
||||
msg.Write(arr);
|
||||
msg.LengthBits = (arr.Length + 4) * 8;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Decrypt(NetIncomingMessage msg)
|
||||
{
|
||||
int unEncLenBits = (int)msg.ReadUInt32();
|
||||
|
||||
var ms = new MemoryStream(msg.m_data, 4, msg.LengthBytes - 4);
|
||||
var cs = GetDecryptStream(ms);
|
||||
|
||||
var result = m_peer.GetStorage(unEncLenBits);
|
||||
cs.Read(result, 0, NetUtility.BytesToHoldBits(unEncLenBits));
|
||||
cs.Close();
|
||||
|
||||
// TODO: recycle existing msg
|
||||
|
||||
msg.m_data = result;
|
||||
msg.m_bitLength = unEncLenBits;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,294 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<ProjectType>Local</ProjectType>
|
||||
<ProductVersion>12.0.31101.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{59250BAF-0000-0000-0000-000000000000}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
|
||||
<ApplicationIcon />
|
||||
<AssemblyKeyContainerName />
|
||||
<AssemblyName>Lidgren.Network</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder />
|
||||
<RootNamespace>Lidgren.Network</RootNamespace>
|
||||
<StartupObject />
|
||||
<StartArguments />
|
||||
<FileUpgradeFlags />
|
||||
<ConfigurationOverrideFile />
|
||||
<TargetFrameworkProfile />
|
||||
<DocumentationFile />
|
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<OutputPath>..\bin\Lidgren\</OutputPath>
|
||||
<RegisterForComInterop>False</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||
<NoStdLib>False</NoStdLib>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
<SonarQubeExclude>true</SonarQubeExclude>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<DebugType Condition="'$(AppVeyor)' != 'yes'">portable</DebugType>
|
||||
<DebugType Condition="'$(AppVeyor)' == 'yes'">full</DebugType>
|
||||
<Optimize>False</Optimize>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DebugSymbols>False</DebugSymbols>
|
||||
<Optimize>True</Optimize>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<DebugType Condition="'$(AppVeyor)' != 'yes'">portable</DebugType>
|
||||
<DebugType Condition="'$(AppVeyor)' == 'yes'">full</DebugType>
|
||||
<Optimize>False</Optimize>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DebugSymbols>False</DebugSymbols>
|
||||
<Optimize>True</Optimize>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<DebugType Condition="'$(AppVeyor)' != 'yes'">portable</DebugType>
|
||||
<DebugType Condition="'$(AppVeyor)' == 'yes'">full</DebugType>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugSymbols>False</DebugSymbols>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp">
|
||||
<Name>Microsoft.CSharp</Name>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System">
|
||||
<Name>System</Name>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Core">
|
||||
<Name>System.Core</Name>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Data">
|
||||
<Name>System.Data</Name>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml">
|
||||
<Name>System.Xml</Name>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Encryption\INetEncryption.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Encryption\NetAESEncryption.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Encryption\NetBlockEncryptionBase.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Encryption\NetXteaEncryption.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NamespaceDoc.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetBigInteger.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetBitVector.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetBitWriter.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetBuffer.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetBuffer.Peek.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetBuffer.Read.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetBuffer.Read.Reflection.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetBuffer.Write.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetBuffer.Write.Reflection.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetClient.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetConnection.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetConnection.Handshake.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetConnection.Latency.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetConnection.MTU.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetConnectionStatistics.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetConnectionStatus.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetConstants.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetDeliveryMethod.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetException.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetFragmentationHelper.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetIncomingMessage.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetIncomingMessageType.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetMessageType.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetNatIntroduction.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetOutgoingMessage.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetPeer.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetPeer.Discovery.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetPeer.Fragmentation.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetPeer.Internal.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetPeer.LatencySimulation.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetPeer.Logging.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetPeer.MessagePools.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetPeer.Send.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetPeerConfiguration.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetPeerStatistics.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetPeerStatus.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetQueue.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetRandom.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetReceiverChannelBase.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetReliableOrderedReceiver.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetReliableSenderChannel.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetReliableSequencedReceiver.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetReliableUnorderedReceiver.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetSenderChannelBase.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetSendResult.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetServer.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetSRP.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetStoredReliableMessage.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetTime.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetTuple.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetUnreliableSenderChannel.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetUnreliableSequencedReceiver.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetUnreliableUnorderedReceiver.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetUPnP.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NetUtility.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SenderChannelBase.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -1,314 +0,0 @@
|
||||
/* Copyright (c) 2010 Michael Lidgren
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom
|
||||
the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
public partial class NetIncomingMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the internal data buffer, don't modify
|
||||
/// </summary>
|
||||
public byte[] PeekDataBuffer()
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
//
|
||||
// 1 bit
|
||||
//
|
||||
/// <summary>
|
||||
/// Reads a 1-bit Boolean without advancing the read pointer
|
||||
/// </summary>
|
||||
public bool PeekBoolean()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 1, c_readOverflowError);
|
||||
byte retval = NetBitWriter.ReadByte(m_data, 1, m_readPosition);
|
||||
return (retval > 0 ? true : false);
|
||||
}
|
||||
|
||||
//
|
||||
// 8 bit
|
||||
//
|
||||
/// <summary>
|
||||
/// Reads a Byte without advancing the read pointer
|
||||
/// </summary>
|
||||
public byte PeekByte()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 8, c_readOverflowError);
|
||||
byte retval = NetBitWriter.ReadByte(m_data, 8, m_readPosition);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads an SByte without advancing the read pointer
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public sbyte PeekSByte()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 8, c_readOverflowError);
|
||||
byte retval = NetBitWriter.ReadByte(m_data, 8, m_readPosition);
|
||||
return (sbyte)retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the specified number of bits into a Byte without advancing the read pointer
|
||||
/// </summary>
|
||||
public byte PeekByte(int numberOfBits)
|
||||
{
|
||||
byte retval = NetBitWriter.ReadByte(m_data, numberOfBits, m_readPosition);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the specified number of bytes without advancing the read pointer
|
||||
/// </summary>
|
||||
public byte[] PeekBytes(int numberOfBytes)
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= (numberOfBytes * 8), c_readOverflowError);
|
||||
|
||||
byte[] retval = new byte[numberOfBytes];
|
||||
NetBitWriter.ReadBytes(m_data, numberOfBytes, m_readPosition, retval, 0);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the specified number of bytes without advancing the read pointer
|
||||
/// </summary>
|
||||
public void PeekBytes(byte[] into, int offset, int numberOfBytes)
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= (numberOfBytes * 8), c_readOverflowError);
|
||||
NetException.Assert(offset + numberOfBytes <= into.Length);
|
||||
|
||||
NetBitWriter.ReadBytes(m_data, numberOfBytes, m_readPosition, into, offset);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// 16 bit
|
||||
//
|
||||
/// <summary>
|
||||
/// Reads an Int16 without advancing the read pointer
|
||||
/// </summary>
|
||||
public Int16 PeekInt16()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 16, c_readOverflowError);
|
||||
uint retval = NetBitWriter.ReadUInt32(m_data, 16, m_readPosition);
|
||||
return (short)retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a UInt16 without advancing the read pointer
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public UInt16 PeekUInt16()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 16, c_readOverflowError);
|
||||
uint retval = NetBitWriter.ReadUInt32(m_data, 16, m_readPosition);
|
||||
return (ushort)retval;
|
||||
}
|
||||
|
||||
//
|
||||
// 32 bit
|
||||
//
|
||||
/// <summary>
|
||||
/// Reads an Int32 without advancing the read pointer
|
||||
/// </summary>
|
||||
public Int32 PeekInt32()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 32, c_readOverflowError);
|
||||
uint retval = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
|
||||
return (Int32)retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the specified number of bits into an Int32 without advancing the read pointer
|
||||
/// </summary>
|
||||
public Int32 PeekInt32(int numberOfBits)
|
||||
{
|
||||
NetException.Assert((numberOfBits > 0 && numberOfBits <= 32), "ReadInt() can only read between 1 and 32 bits");
|
||||
NetException.Assert(m_bitLength - m_readPosition >= numberOfBits, c_readOverflowError);
|
||||
|
||||
uint retval = NetBitWriter.ReadUInt32(m_data, numberOfBits, m_readPosition);
|
||||
|
||||
if (numberOfBits == 32)
|
||||
return (int)retval;
|
||||
|
||||
int signBit = 1 << (numberOfBits - 1);
|
||||
if ((retval & signBit) == 0)
|
||||
return (int)retval; // positive
|
||||
|
||||
// negative
|
||||
unchecked
|
||||
{
|
||||
uint mask = ((uint)-1) >> (33 - numberOfBits);
|
||||
uint tmp = (retval & mask) + 1;
|
||||
return -((int)tmp);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a UInt32 without advancing the read pointer
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public UInt32 PeekUInt32()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 32, c_readOverflowError);
|
||||
uint retval = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the specified number of bits into a UInt32 without advancing the read pointer
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public UInt32 PeekUInt32(int numberOfBits)
|
||||
{
|
||||
NetException.Assert((numberOfBits > 0 && numberOfBits <= 32), "ReadUInt() can only read between 1 and 32 bits");
|
||||
//NetException.Assert(m_bitLength - m_readBitPtr >= numberOfBits, "tried to read past buffer size");
|
||||
|
||||
UInt32 retval = NetBitWriter.ReadUInt32(m_data, numberOfBits, m_readPosition);
|
||||
return retval;
|
||||
}
|
||||
|
||||
//
|
||||
// 64 bit
|
||||
//
|
||||
/// <summary>
|
||||
/// Reads a UInt64 without advancing the read pointer
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public UInt64 PeekUInt64()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 64, c_readOverflowError);
|
||||
|
||||
ulong low = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
|
||||
ulong high = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition + 32);
|
||||
|
||||
ulong retval = low + (high << 32);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads an Int64 without advancing the read pointer
|
||||
/// </summary>
|
||||
public Int64 PeekInt64()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 64, c_readOverflowError);
|
||||
unchecked
|
||||
{
|
||||
ulong retval = PeekUInt64();
|
||||
long longRetval = (long)retval;
|
||||
return longRetval;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the specified number of bits into an UInt64 without advancing the read pointer
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public UInt64 PeekUInt64(int numberOfBits)
|
||||
{
|
||||
NetException.Assert((numberOfBits > 0 && numberOfBits <= 64), "ReadUInt() can only read between 1 and 64 bits");
|
||||
NetException.Assert(m_bitLength - m_readPosition >= numberOfBits, c_readOverflowError);
|
||||
|
||||
ulong retval;
|
||||
if (numberOfBits <= 32)
|
||||
{
|
||||
retval = (ulong)NetBitWriter.ReadUInt32(m_data, numberOfBits, m_readPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
|
||||
retval |= NetBitWriter.ReadUInt32(m_data, numberOfBits - 32, m_readPosition) << 32;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the specified number of bits into an Int64 without advancing the read pointer
|
||||
/// </summary>
|
||||
public Int64 PeekInt64(int numberOfBits)
|
||||
{
|
||||
NetException.Assert(((numberOfBits > 0) && (numberOfBits < 65)), "ReadInt64(bits) can only read between 1 and 64 bits");
|
||||
return (long)PeekUInt64(numberOfBits);
|
||||
}
|
||||
|
||||
//
|
||||
// Floating point
|
||||
//
|
||||
/// <summary>
|
||||
/// Reads a 32-bit Single without advancing the read pointer
|
||||
/// </summary>
|
||||
public float PeekFloat()
|
||||
{
|
||||
return PeekSingle();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 32-bit Single without advancing the read pointer
|
||||
/// </summary>
|
||||
public float PeekSingle()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 32, c_readOverflowError);
|
||||
|
||||
if ((m_readPosition & 7) == 0) // read directly
|
||||
{
|
||||
float retval = BitConverter.ToSingle(m_data, m_readPosition >> 3);
|
||||
return retval;
|
||||
}
|
||||
|
||||
byte[] bytes = PeekBytes(4);
|
||||
return BitConverter.ToSingle(bytes, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 64-bit Double without advancing the read pointer
|
||||
/// </summary>
|
||||
public double PeekDouble()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 64, c_readOverflowError);
|
||||
|
||||
if ((m_readPosition & 7) == 0) // read directly
|
||||
{
|
||||
// read directly
|
||||
double retval = BitConverter.ToDouble(m_data, m_readPosition >> 3);
|
||||
return retval;
|
||||
}
|
||||
|
||||
byte[] bytes = PeekBytes(8);
|
||||
return BitConverter.ToDouble(bytes, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a string without advancing the read pointer
|
||||
/// </summary>
|
||||
public string PeekString()
|
||||
{
|
||||
int wasReadPosition = m_readPosition;
|
||||
string retval = ReadString();
|
||||
m_readPosition = wasReadPosition;
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
/* Copyright (c) 2010 Michael Lidgren
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom
|
||||
the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
public partial class NetIncomingMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads all public and private declared instance fields of the object in alphabetical order using reflection
|
||||
/// </summary>
|
||||
public void ReadAllFields(object target)
|
||||
{
|
||||
ReadAllFields(target, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads all fields with the specified binding of the object in alphabetical order using reflection
|
||||
/// </summary>
|
||||
public void ReadAllFields(object target, BindingFlags flags)
|
||||
{
|
||||
if (target == null)
|
||||
return;
|
||||
Type tp = target.GetType();
|
||||
|
||||
FieldInfo[] fields = tp.GetFields(flags);
|
||||
NetUtility.SortMembersList(fields);
|
||||
|
||||
foreach (FieldInfo fi in fields)
|
||||
{
|
||||
object value;
|
||||
|
||||
// find read method
|
||||
MethodInfo readMethod;
|
||||
if (s_readMethods.TryGetValue(fi.FieldType, out readMethod))
|
||||
{
|
||||
// read value
|
||||
value = readMethod.Invoke(this, null);
|
||||
|
||||
// set the value
|
||||
fi.SetValue(target, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads all public and private declared instance fields of the object in alphabetical order using reflection
|
||||
/// </summary>
|
||||
public void ReadAllProperties(object target)
|
||||
{
|
||||
ReadAllProperties(target, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads all fields with the specified binding of the object in alphabetical order using reflection
|
||||
/// </summary>
|
||||
public void ReadAllProperties(object target, BindingFlags flags)
|
||||
{
|
||||
if (target == null)
|
||||
throw new ArgumentNullException("target");
|
||||
|
||||
if (target == null)
|
||||
return;
|
||||
Type tp = target.GetType();
|
||||
|
||||
PropertyInfo[] fields = tp.GetProperties(flags);
|
||||
NetUtility.SortMembersList(fields);
|
||||
foreach (PropertyInfo fi in fields)
|
||||
{
|
||||
object value;
|
||||
|
||||
// find read method
|
||||
MethodInfo readMethod;
|
||||
if (s_readMethods.TryGetValue(fi.PropertyType, out readMethod))
|
||||
{
|
||||
// read value
|
||||
value = readMethod.Invoke(this, null);
|
||||
|
||||
// set the value
|
||||
MethodInfo setMethod = fi.GetSetMethod((flags & BindingFlags.NonPublic) == BindingFlags.NonPublic);
|
||||
setMethod.Invoke(target, new object[] { value });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,714 +0,0 @@
|
||||
/* Copyright (c) 2010 Michael Lidgren
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom
|
||||
the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
public partial class NetIncomingMessage
|
||||
{
|
||||
private const string c_readOverflowError = "Trying to read past the buffer size - likely caused by mismatching Write/Reads, different size or order.";
|
||||
|
||||
private static readonly Dictionary<Type, MethodInfo> s_readMethods;
|
||||
|
||||
internal int m_readPosition;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the read position in the buffer, in bits (not bytes)
|
||||
/// </summary>
|
||||
public long Position
|
||||
{
|
||||
get { return (long)m_readPosition; }
|
||||
set { m_readPosition = (int)value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the position in the buffer in bytes; note that the bits of the first returned byte may already have been read - check the Position property to make sure.
|
||||
/// </summary>
|
||||
public int PositionInBytes
|
||||
{
|
||||
get { return (int)(m_readPosition / 8); }
|
||||
}
|
||||
|
||||
static NetIncomingMessage()
|
||||
{
|
||||
Type[] integralTypes = typeof(Byte).Assembly.GetTypes();
|
||||
|
||||
s_readMethods = new Dictionary<Type, MethodInfo>();
|
||||
MethodInfo[] methods = typeof(NetIncomingMessage).GetMethods(BindingFlags.Instance | BindingFlags.Public);
|
||||
foreach (MethodInfo mi in methods)
|
||||
{
|
||||
if (mi.GetParameters().Length == 0 && mi.Name.StartsWith("Read", StringComparison.InvariantCulture))
|
||||
{
|
||||
string n = mi.Name.Substring(4);
|
||||
foreach (Type it in integralTypes)
|
||||
{
|
||||
if (it.Name == n)
|
||||
s_readMethods[it] = mi;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a boolean value (stored as a single bit) written using Write(bool)
|
||||
/// </summary>
|
||||
public bool ReadBoolean()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 1, c_readOverflowError);
|
||||
byte retval = NetBitWriter.ReadByte(m_data, 1, m_readPosition);
|
||||
m_readPosition += 1;
|
||||
return (retval > 0 ? true : false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a byte
|
||||
/// </summary>
|
||||
public byte ReadByte()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 8, c_readOverflowError);
|
||||
byte retval = NetBitWriter.ReadByte(m_data, 8, m_readPosition);
|
||||
m_readPosition += 8;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a byte and returns true or false for success
|
||||
/// </summary>
|
||||
public bool ReadByte(out byte result)
|
||||
{
|
||||
if (m_bitLength - m_readPosition < 8)
|
||||
{
|
||||
result = 0;
|
||||
return false;
|
||||
}
|
||||
result = NetBitWriter.ReadByte(m_data, 8, m_readPosition);
|
||||
m_readPosition += 8;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a signed byte
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public sbyte ReadSByte()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 8, c_readOverflowError);
|
||||
byte retval = NetBitWriter.ReadByte(m_data, 8, m_readPosition);
|
||||
m_readPosition += 8;
|
||||
return (sbyte)retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads 1 to 8 bits into a byte
|
||||
/// </summary>
|
||||
public byte ReadByte(int numberOfBits)
|
||||
{
|
||||
NetException.Assert(numberOfBits > 0 && numberOfBits <= 8, "ReadByte(bits) can only read between 1 and 8 bits");
|
||||
byte retval = NetBitWriter.ReadByte(m_data, numberOfBits, m_readPosition);
|
||||
m_readPosition += numberOfBits;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the specified number of bytes
|
||||
/// </summary>
|
||||
public byte[] ReadBytes(int numberOfBytes)
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition + 7 >= (numberOfBytes * 8), c_readOverflowError);
|
||||
|
||||
byte[] retval = new byte[numberOfBytes];
|
||||
NetBitWriter.ReadBytes(m_data, numberOfBytes, m_readPosition, retval, 0);
|
||||
m_readPosition += (8 * numberOfBytes);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the specified number of bytes and returns true for success
|
||||
/// </summary>
|
||||
public bool ReadBytes(int numberOfBytes, out byte[] result)
|
||||
{
|
||||
if (m_bitLength - m_readPosition + 7 < (numberOfBytes * 8))
|
||||
{
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
result = new byte[numberOfBytes];
|
||||
NetBitWriter.ReadBytes(m_data, numberOfBytes, m_readPosition, result, 0);
|
||||
m_readPosition += (8 * numberOfBytes);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the specified number of bytes into a preallocated array
|
||||
/// </summary>
|
||||
/// <param name="into">The destination array</param>
|
||||
/// <param name="offset">The offset where to start writing in the destination array</param>
|
||||
/// <param name="numberOfBytes">The number of bytes to read</param>
|
||||
public void ReadBytes(byte[] into, int offset, int numberOfBytes)
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition + 7 >= (numberOfBytes * 8), c_readOverflowError);
|
||||
NetException.Assert(offset + numberOfBytes <= into.Length);
|
||||
|
||||
NetBitWriter.ReadBytes(m_data, numberOfBytes, m_readPosition, into, offset);
|
||||
m_readPosition += (8 * numberOfBytes);
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the specified number of bits into a preallocated array
|
||||
/// </summary>
|
||||
/// <param name="into">The destination array</param>
|
||||
/// <param name="offset">The offset where to start writing in the destination array</param>
|
||||
/// <param name="numberOfBits">The number of bits to read</param>
|
||||
public void ReadBits(byte[] into, int offset, int numberOfBits)
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= numberOfBits, c_readOverflowError);
|
||||
NetException.Assert(offset + NetUtility.BytesToHoldBits(numberOfBits) <= into.Length);
|
||||
|
||||
int numberOfWholeBytes = numberOfBits / 8;
|
||||
int extraBits = numberOfBits - (numberOfWholeBytes * 8);
|
||||
|
||||
NetBitWriter.ReadBytes(m_data, numberOfWholeBytes, m_readPosition, into, offset);
|
||||
m_readPosition += (8 * numberOfWholeBytes);
|
||||
|
||||
if (extraBits > 0)
|
||||
into[offset + numberOfWholeBytes] = ReadByte(extraBits);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 16 bit signed integer written using Write(Int16)
|
||||
/// </summary>
|
||||
public Int16 ReadInt16()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 16, c_readOverflowError);
|
||||
uint retval = NetBitWriter.ReadUInt32(m_data, 16, m_readPosition);
|
||||
m_readPosition += 16;
|
||||
return (short)retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 16 bit unsigned integer written using Write(UInt16)
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public UInt16 ReadUInt16()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 16, c_readOverflowError);
|
||||
uint retval = NetBitWriter.ReadUInt32(m_data, 16, m_readPosition);
|
||||
m_readPosition += 16;
|
||||
return (ushort)retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 32 bit signed integer written using Write(Int32)
|
||||
/// </summary>
|
||||
public Int32 ReadInt32()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 32, c_readOverflowError);
|
||||
uint retval = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
|
||||
m_readPosition += 32;
|
||||
return (Int32)retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 32 bit signed integer written using Write(Int32)
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public bool ReadInt32(out Int32 result)
|
||||
{
|
||||
if (m_bitLength - m_readPosition < 32)
|
||||
{
|
||||
result = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
result = (Int32)NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
|
||||
m_readPosition += 32;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a signed integer stored in 1 to 32 bits, written using Write(Int32, Int32)
|
||||
/// </summary>
|
||||
public Int32 ReadInt32(int numberOfBits)
|
||||
{
|
||||
NetException.Assert(numberOfBits > 0 && numberOfBits <= 32, "ReadInt32(bits) can only read between 1 and 32 bits");
|
||||
NetException.Assert(m_bitLength - m_readPosition >= numberOfBits, c_readOverflowError);
|
||||
|
||||
uint retval = NetBitWriter.ReadUInt32(m_data, numberOfBits, m_readPosition);
|
||||
m_readPosition += numberOfBits;
|
||||
|
||||
if (numberOfBits == 32)
|
||||
return (int)retval;
|
||||
|
||||
int signBit = 1 << (numberOfBits - 1);
|
||||
if ((retval & signBit) == 0)
|
||||
return (int)retval; // positive
|
||||
|
||||
// negative
|
||||
unchecked
|
||||
{
|
||||
uint mask = ((uint)-1) >> (33 - numberOfBits);
|
||||
uint tmp = (retval & mask) + 1;
|
||||
return -((int)tmp);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads an 32 bit unsigned integer written using Write(UInt32)
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public UInt32 ReadUInt32()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 32, c_readOverflowError);
|
||||
uint retval = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
|
||||
m_readPosition += 32;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads an 32 bit unsigned integer written using Write(UInt32) and returns true for success
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public bool ReadUInt32(out UInt32 result)
|
||||
{
|
||||
if (m_bitLength - m_readPosition < 32)
|
||||
{
|
||||
result = 0;
|
||||
return false;
|
||||
}
|
||||
result = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
|
||||
m_readPosition += 32;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads an unsigned integer stored in 1 to 32 bits, written using Write(UInt32, Int32)
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public UInt32 ReadUInt32(int numberOfBits)
|
||||
{
|
||||
NetException.Assert(numberOfBits > 0 && numberOfBits <= 32, "ReadUInt32(bits) can only read between 1 and 32 bits");
|
||||
//NetException.Assert(m_bitLength - m_readBitPtr >= numberOfBits, "tried to read past buffer size");
|
||||
|
||||
UInt32 retval = NetBitWriter.ReadUInt32(m_data, numberOfBits, m_readPosition);
|
||||
m_readPosition += numberOfBits;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 64 bit unsigned integer written using Write(UInt64)
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public UInt64 ReadUInt64()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 64, c_readOverflowError);
|
||||
|
||||
ulong low = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
|
||||
m_readPosition += 32;
|
||||
ulong high = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
|
||||
|
||||
ulong retval = low + (high << 32);
|
||||
|
||||
m_readPosition += 32;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 64 bit signed integer written using Write(Int64)
|
||||
/// </summary>
|
||||
public Int64 ReadInt64()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 64, c_readOverflowError);
|
||||
unchecked
|
||||
{
|
||||
ulong retval = ReadUInt64();
|
||||
long longRetval = (long)retval;
|
||||
return longRetval;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads an unsigned integer stored in 1 to 64 bits, written using Write(UInt64, Int32)
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public UInt64 ReadUInt64(int numberOfBits)
|
||||
{
|
||||
NetException.Assert(numberOfBits > 0 && numberOfBits <= 64, "ReadUInt64(bits) can only read between 1 and 64 bits");
|
||||
NetException.Assert(m_bitLength - m_readPosition >= numberOfBits, c_readOverflowError);
|
||||
|
||||
ulong retval;
|
||||
if (numberOfBits <= 32)
|
||||
{
|
||||
retval = (ulong)NetBitWriter.ReadUInt32(m_data, numberOfBits, m_readPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
|
||||
retval |= NetBitWriter.ReadUInt32(m_data, numberOfBits - 32, m_readPosition) << 32;
|
||||
}
|
||||
m_readPosition += numberOfBits;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a signed integer stored in 1 to 64 bits, written using Write(Int64, Int32)
|
||||
/// </summary>
|
||||
public Int64 ReadInt64(int numberOfBits)
|
||||
{
|
||||
NetException.Assert(((numberOfBits > 0) && (numberOfBits <= 64)), "ReadInt64(bits) can only read between 1 and 64 bits");
|
||||
return (long)ReadUInt64(numberOfBits);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 32 bit floating point value written using Write(Single)
|
||||
/// </summary>
|
||||
public float ReadFloat()
|
||||
{
|
||||
return ReadSingle();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 32 bit floating point value written using Write(Single)
|
||||
/// </summary>
|
||||
public float ReadSingle()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 32, c_readOverflowError);
|
||||
|
||||
if ((m_readPosition & 7) == 0) // read directly
|
||||
{
|
||||
float retval = BitConverter.ToSingle(m_data, m_readPosition >> 3);
|
||||
m_readPosition += 32;
|
||||
return retval;
|
||||
}
|
||||
|
||||
byte[] bytes = ReadBytes(4);
|
||||
return BitConverter.ToSingle(bytes, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 32 bit floating point value written using Write(Single)
|
||||
/// </summary>
|
||||
public bool ReadSingle(out float result)
|
||||
{
|
||||
if (m_bitLength - m_readPosition < 32)
|
||||
{
|
||||
result = 0.0f;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((m_readPosition & 7) == 0) // read directly
|
||||
{
|
||||
result = BitConverter.ToSingle(m_data, m_readPosition >> 3);
|
||||
m_readPosition += 32;
|
||||
return true;
|
||||
}
|
||||
|
||||
byte[] bytes = ReadBytes(4);
|
||||
result = BitConverter.ToSingle(bytes, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 64 bit floating point value written using Write(Double)
|
||||
/// </summary>
|
||||
public double ReadDouble()
|
||||
{
|
||||
NetException.Assert(m_bitLength - m_readPosition >= 64, c_readOverflowError);
|
||||
|
||||
if ((m_readPosition & 7) == 0) // read directly
|
||||
{
|
||||
// read directly
|
||||
double retval = BitConverter.ToDouble(m_data, m_readPosition >> 3);
|
||||
m_readPosition += 64;
|
||||
return retval;
|
||||
}
|
||||
|
||||
byte[] bytes = ReadBytes(8);
|
||||
return BitConverter.ToDouble(bytes, 0);
|
||||
}
|
||||
|
||||
//
|
||||
// Variable bit count
|
||||
//
|
||||
|
||||
/// <summary>
|
||||
/// Reads a variable sized UInt32 written using WriteVariableUInt32()
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public uint ReadVariableUInt32()
|
||||
{
|
||||
int num1 = 0;
|
||||
int num2 = 0;
|
||||
while (true)
|
||||
{
|
||||
byte num3 = this.ReadByte();
|
||||
num1 |= (num3 & 0x7f) << num2;
|
||||
num2 += 7;
|
||||
if ((num3 & 0x80) == 0)
|
||||
return (uint)num1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a variable sized UInt32 written using WriteVariableUInt32() and returns true for success
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public bool ReadVariableUInt32(out uint result)
|
||||
{
|
||||
int num1 = 0;
|
||||
int num2 = 0;
|
||||
while (true)
|
||||
{
|
||||
byte num3;
|
||||
if (ReadByte(out num3) == false)
|
||||
{
|
||||
result = 0;
|
||||
return false;
|
||||
}
|
||||
num1 |= (num3 & 0x7f) << num2;
|
||||
num2 += 7;
|
||||
if ((num3 & 0x80) == 0)
|
||||
{
|
||||
result = (uint)num1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a variable sized Int32 written using WriteVariableInt32()
|
||||
/// </summary>
|
||||
public int ReadVariableInt32()
|
||||
{
|
||||
uint n = ReadVariableUInt32();
|
||||
return (int)(n >> 1) ^ -(int)(n & 1); // decode zigzag
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a variable sized Int64 written using WriteVariableInt64()
|
||||
/// </summary>
|
||||
public Int64 ReadVariableInt64()
|
||||
{
|
||||
UInt64 n = ReadVariableUInt64();
|
||||
return (Int64)(n >> 1) ^ -(long)(n & 1); // decode zigzag
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a variable sized UInt32 written using WriteVariableInt64()
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public UInt64 ReadVariableUInt64()
|
||||
{
|
||||
UInt64 num1 = 0;
|
||||
int num2 = 0;
|
||||
while (true)
|
||||
{
|
||||
//if (num2 == 0x23)
|
||||
// throw new FormatException("Bad 7-bit encoded integer");
|
||||
|
||||
byte num3 = this.ReadByte();
|
||||
num1 |= ((UInt64)num3 & 0x7f) << num2;
|
||||
num2 += 7;
|
||||
if ((num3 & 0x80) == 0)
|
||||
return num1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 32 bit floating point value written using WriteSignedSingle()
|
||||
/// </summary>
|
||||
/// <param name="numberOfBits">The number of bits used when writing the value</param>
|
||||
/// <returns>A floating point value larger or equal to -1 and smaller or equal to 1</returns>
|
||||
public float ReadSignedSingle(int numberOfBits)
|
||||
{
|
||||
uint encodedVal = ReadUInt32(numberOfBits);
|
||||
int maxVal = (1 << numberOfBits) - 1;
|
||||
return ((float)(encodedVal + 1) / (float)(maxVal + 1) - 0.5f) * 2.0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 32 bit floating point value written using WriteUnitSingle()
|
||||
/// </summary>
|
||||
/// <param name="numberOfBits">The number of bits used when writing the value</param>
|
||||
/// <returns>A floating point value larger or equal to 0 and smaller or equal to 1</returns>
|
||||
public float ReadUnitSingle(int numberOfBits)
|
||||
{
|
||||
uint encodedVal = ReadUInt32(numberOfBits);
|
||||
int maxVal = (1 << numberOfBits) - 1;
|
||||
return (float)(encodedVal + 1) / (float)(maxVal + 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 32 bit floating point value written using WriteRangedSingle()
|
||||
/// </summary>
|
||||
/// <param name="min">The minimum value used when writing the value</param>
|
||||
/// <param name="max">The maximum value used when writing the value</param>
|
||||
/// <param name="numberOfBits">The number of bits used when writing the value</param>
|
||||
/// <returns>A floating point value larger or equal to MIN and smaller or equal to MAX</returns>
|
||||
public float ReadRangedSingle(float min, float max, int numberOfBits)
|
||||
{
|
||||
float range = max - min;
|
||||
int maxVal = (1 << numberOfBits) - 1;
|
||||
float encodedVal = (float)ReadUInt32(numberOfBits);
|
||||
float unit = encodedVal / (float)maxVal;
|
||||
return min + (unit * range);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a 32 bit integer value written using WriteRangedInteger()
|
||||
/// </summary>
|
||||
/// <param name="min">The minimum value used when writing the value</param>
|
||||
/// <param name="max">The maximum value used when writing the value</param>
|
||||
/// <returns>A signed integer value larger or equal to MIN and smaller or equal to MAX</returns>
|
||||
public int ReadRangedInteger(int min, int max)
|
||||
{
|
||||
uint range = (uint)(max - min);
|
||||
int numBits = NetUtility.BitsToHoldUInt(range);
|
||||
|
||||
uint rvalue = ReadUInt32(numBits);
|
||||
return (int)(min + rvalue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a string written using Write(string)
|
||||
/// </summary>
|
||||
public string ReadString()
|
||||
{
|
||||
int byteLen = (int)ReadVariableUInt32();
|
||||
|
||||
if (byteLen == 0)
|
||||
return String.Empty;
|
||||
|
||||
NetException.Assert(m_bitLength - m_readPosition >= (byteLen * 8), c_readOverflowError);
|
||||
|
||||
if ((m_readPosition & 7) == 0)
|
||||
{
|
||||
// read directly
|
||||
string retval = System.Text.Encoding.UTF8.GetString(m_data, m_readPosition >> 3, byteLen);
|
||||
m_readPosition += (8 * byteLen);
|
||||
return retval;
|
||||
}
|
||||
|
||||
byte[] bytes = ReadBytes(byteLen);
|
||||
return System.Text.Encoding.UTF8.GetString(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a string written using Write(string) and returns true for success
|
||||
/// </summary>
|
||||
public bool ReadString(out string result)
|
||||
{
|
||||
uint byteLen;
|
||||
if (ReadVariableUInt32(out byteLen) == false)
|
||||
{
|
||||
result = String.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (byteLen == 0)
|
||||
{
|
||||
result = String.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_bitLength - m_readPosition < (byteLen * 8))
|
||||
{
|
||||
result = String.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((m_readPosition & 7) == 0)
|
||||
{
|
||||
// read directly
|
||||
result = System.Text.Encoding.UTF8.GetString(m_data, m_readPosition >> 3, (int)byteLen);
|
||||
m_readPosition += (8 * (int)byteLen);
|
||||
return true;
|
||||
}
|
||||
|
||||
byte[] bytes;
|
||||
if (ReadBytes((int)byteLen, out bytes) == false)
|
||||
{
|
||||
result = String.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
result = System.Text.Encoding.UTF8.GetString(bytes, 0, bytes.Length);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a stored IPv4 endpoint description
|
||||
/// </summary>
|
||||
public IPEndPoint ReadIPEndpoint()
|
||||
{
|
||||
byte len = ReadByte();
|
||||
byte[] addressBytes = ReadBytes(len);
|
||||
int port = (int)ReadUInt16();
|
||||
|
||||
IPAddress address = new IPAddress(addressBytes);
|
||||
return new IPEndPoint(address, port);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a value, in local time comparable to NetTime.Now, written using WriteTime()
|
||||
/// Must have a connected sender
|
||||
/// </summary>
|
||||
public double ReadTime(bool highPrecision)
|
||||
{
|
||||
double remoteTime = (highPrecision ? ReadDouble() : (double)ReadSingle());
|
||||
|
||||
if (m_senderConnection == null)
|
||||
throw new NetException("Cannot call ReadTime() on message without a connected sender (ie. unconnected messages)");
|
||||
|
||||
// lets bypass NetConnection.GetLocalTime for speed
|
||||
return remoteTime - m_senderConnection.m_remoteTimeOffset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pads data with enough bits to reach a full byte. Decreases cpu usage for subsequent byte writes.
|
||||
/// </summary>
|
||||
public void SkipPadBits()
|
||||
{
|
||||
m_readPosition = ((m_readPosition + 7) >> 3) * 8;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pads data with enough bits to reach a full byte. Decreases cpu usage for subsequent byte writes.
|
||||
/// </summary>
|
||||
public void ReadPadBits()
|
||||
{
|
||||
m_readPosition = ((m_readPosition + 7) >> 3) * 8;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pads data with the specified number of bits.
|
||||
/// </summary>
|
||||
public void SkipPadBits(int numberOfBits)
|
||||
{
|
||||
m_readPosition += numberOfBits;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,475 +0,0 @@
|
||||
/* Copyright (c) 2010 Michael Lidgren
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom
|
||||
the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
public partial class NetIncomingMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// Ensures the buffer can hold this number of bits
|
||||
/// </summary>
|
||||
private void InternalEnsureBufferSize(int numberOfBits)
|
||||
{
|
||||
int byteLen = ((numberOfBits + 7) >> 3);
|
||||
if (m_data == null)
|
||||
{
|
||||
m_data = new byte[byteLen];
|
||||
return;
|
||||
}
|
||||
if (m_data.Length < byteLen)
|
||||
Array.Resize<byte>(ref m_data, byteLen);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// 1 bit
|
||||
//
|
||||
internal void Write(bool value)
|
||||
{
|
||||
InternalEnsureBufferSize(m_bitLength + 1);
|
||||
NetBitWriter.WriteByte((value ? (byte)1 : (byte)0), 1, m_data, m_bitLength);
|
||||
m_bitLength += 1;
|
||||
}
|
||||
|
||||
//
|
||||
// 8 bit
|
||||
//
|
||||
internal void Write(byte source)
|
||||
{
|
||||
InternalEnsureBufferSize(m_bitLength + 8);
|
||||
NetBitWriter.WriteByte(source, 8, m_data, m_bitLength);
|
||||
m_bitLength += 8;
|
||||
}
|
||||
|
||||
internal void Write(sbyte source)
|
||||
{
|
||||
InternalEnsureBufferSize(m_bitLength + 8);
|
||||
NetBitWriter.WriteByte((byte)source, 8, m_data, m_bitLength);
|
||||
m_bitLength += 8;
|
||||
}
|
||||
|
||||
internal void Write(byte source, int numberOfBits)
|
||||
{
|
||||
NetException.Assert((numberOfBits > 0 && numberOfBits <= 8), "Write(byte, numberOfBits) can only write between 1 and 8 bits");
|
||||
InternalEnsureBufferSize(m_bitLength + numberOfBits);
|
||||
NetBitWriter.WriteByte(source, numberOfBits, m_data, m_bitLength);
|
||||
m_bitLength += numberOfBits;
|
||||
}
|
||||
|
||||
internal void Write(byte[] source)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException("source");
|
||||
int bits = source.Length * 8;
|
||||
InternalEnsureBufferSize(m_bitLength + bits);
|
||||
NetBitWriter.WriteBytes(source, 0, source.Length, m_data, m_bitLength);
|
||||
m_bitLength += bits;
|
||||
}
|
||||
|
||||
internal void Write(byte[] source, int offsetInBytes, int numberOfBytes)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException("source");
|
||||
int bits = numberOfBytes * 8;
|
||||
InternalEnsureBufferSize(m_bitLength + bits);
|
||||
NetBitWriter.WriteBytes(source, offsetInBytes, numberOfBytes, m_data, m_bitLength);
|
||||
m_bitLength += bits;
|
||||
}
|
||||
|
||||
//
|
||||
// 16 bit
|
||||
//
|
||||
internal void Write(UInt16 source)
|
||||
{
|
||||
InternalEnsureBufferSize(m_bitLength + 16);
|
||||
NetBitWriter.WriteUInt32((uint)source, 16, m_data, m_bitLength);
|
||||
m_bitLength += 16;
|
||||
}
|
||||
|
||||
internal void Write(UInt16 source, int numberOfBits)
|
||||
{
|
||||
NetException.Assert((numberOfBits > 0 && numberOfBits <= 16), "Write(ushort, numberOfBits) can only write between 1 and 16 bits");
|
||||
InternalEnsureBufferSize(m_bitLength + numberOfBits);
|
||||
NetBitWriter.WriteUInt32((uint)source, numberOfBits, m_data, m_bitLength);
|
||||
m_bitLength += numberOfBits;
|
||||
}
|
||||
|
||||
internal void Write(Int16 source)
|
||||
{
|
||||
InternalEnsureBufferSize(m_bitLength + 16);
|
||||
NetBitWriter.WriteUInt32((uint)source, 16, m_data, m_bitLength);
|
||||
m_bitLength += 16;
|
||||
}
|
||||
|
||||
//
|
||||
// 32 bit
|
||||
//
|
||||
#if UNSAFE
|
||||
internal unsafe void Write(Int32 source)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + 32);
|
||||
|
||||
// can write fast?
|
||||
if (m_bitLength % 8 == 0)
|
||||
{
|
||||
fixed (byte* numRef = &Data[m_bitLength / 8])
|
||||
{
|
||||
*((int*)numRef) = source;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NetBitWriter.WriteUInt32((UInt32)source, 32, Data, m_bitLength);
|
||||
}
|
||||
m_bitLength += 32;
|
||||
}
|
||||
#else
|
||||
internal void Write(Int32 source)
|
||||
{
|
||||
InternalEnsureBufferSize(m_bitLength + 32);
|
||||
NetBitWriter.WriteUInt32((UInt32)source, 32, m_data, m_bitLength);
|
||||
m_bitLength += 32;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNSAFE
|
||||
internal unsafe void Write(UInt32 source)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + 32);
|
||||
|
||||
// can write fast?
|
||||
if (m_bitLength % 8 == 0)
|
||||
{
|
||||
fixed (byte* numRef = &Data[m_bitLength / 8])
|
||||
{
|
||||
*((uint*)numRef) = source;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NetBitWriter.WriteUInt32(source, 32, Data, m_bitLength);
|
||||
}
|
||||
|
||||
m_bitLength += 32;
|
||||
}
|
||||
#else
|
||||
internal void Write(UInt32 source)
|
||||
{
|
||||
InternalEnsureBufferSize(m_bitLength + 32);
|
||||
NetBitWriter.WriteUInt32(source, 32, m_data, m_bitLength);
|
||||
m_bitLength += 32;
|
||||
}
|
||||
#endif
|
||||
|
||||
internal void Write(UInt32 source, int numberOfBits)
|
||||
{
|
||||
NetException.Assert((numberOfBits > 0 && numberOfBits <= 32), "Write(uint, numberOfBits) can only write between 1 and 32 bits");
|
||||
InternalEnsureBufferSize(m_bitLength + numberOfBits);
|
||||
NetBitWriter.WriteUInt32(source, numberOfBits, m_data, m_bitLength);
|
||||
m_bitLength += numberOfBits;
|
||||
}
|
||||
|
||||
internal void Write(Int32 source, int numberOfBits)
|
||||
{
|
||||
NetException.Assert((numberOfBits > 0 && numberOfBits <= 32), "Write(int, numberOfBits) can only write between 1 and 32 bits");
|
||||
InternalEnsureBufferSize(m_bitLength + numberOfBits);
|
||||
|
||||
if (numberOfBits != 32)
|
||||
{
|
||||
// make first bit sign
|
||||
int signBit = 1 << (numberOfBits - 1);
|
||||
if (source < 0)
|
||||
source = (-source - 1) | signBit;
|
||||
else
|
||||
source &= (~signBit);
|
||||
}
|
||||
|
||||
NetBitWriter.WriteUInt32((uint)source, numberOfBits, m_data, m_bitLength);
|
||||
|
||||
m_bitLength += numberOfBits;
|
||||
}
|
||||
|
||||
//
|
||||
// 64 bit
|
||||
//
|
||||
internal void Write(UInt64 source)
|
||||
{
|
||||
InternalEnsureBufferSize(m_bitLength + 64);
|
||||
NetBitWriter.WriteUInt64(source, 64, m_data, m_bitLength);
|
||||
m_bitLength += 64;
|
||||
}
|
||||
|
||||
internal void Write(UInt64 source, int numberOfBits)
|
||||
{
|
||||
InternalEnsureBufferSize(m_bitLength + numberOfBits);
|
||||
NetBitWriter.WriteUInt64(source, numberOfBits, m_data, m_bitLength);
|
||||
m_bitLength += numberOfBits;
|
||||
}
|
||||
|
||||
internal void Write(Int64 source)
|
||||
{
|
||||
InternalEnsureBufferSize(m_bitLength + 64);
|
||||
ulong usource = (ulong)source;
|
||||
NetBitWriter.WriteUInt64(usource, 64, m_data, m_bitLength);
|
||||
m_bitLength += 64;
|
||||
}
|
||||
|
||||
internal void Write(Int64 source, int numberOfBits)
|
||||
{
|
||||
InternalEnsureBufferSize(m_bitLength + numberOfBits);
|
||||
ulong usource = (ulong)source;
|
||||
NetBitWriter.WriteUInt64(usource, numberOfBits, m_data, m_bitLength);
|
||||
m_bitLength += numberOfBits;
|
||||
}
|
||||
|
||||
//
|
||||
// Floating point
|
||||
//
|
||||
#if UNSAFE
|
||||
internal unsafe void Write(float source)
|
||||
{
|
||||
uint val = *((uint*)&source);
|
||||
#if BIGENDIAN
|
||||
val = NetUtility.SwapByteOrder(val);
|
||||
#endif
|
||||
Write(val);
|
||||
}
|
||||
#else
|
||||
internal void Write(float source)
|
||||
{
|
||||
byte[] val = BitConverter.GetBytes(source);
|
||||
#if BIGENDIAN
|
||||
// swap byte order
|
||||
byte tmp = val[3];
|
||||
val[3] = val[0];
|
||||
val[0] = tmp;
|
||||
tmp = val[2];
|
||||
val[2] = val[1];
|
||||
val[1] = tmp;
|
||||
#endif
|
||||
Write(val);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNSAFE
|
||||
internal unsafe void Write(double source)
|
||||
{
|
||||
ulong val = *((ulong*)&source);
|
||||
#if BIGENDIAN
|
||||
val = NetUtility.SwapByteOrder(val);
|
||||
#endif
|
||||
Write(val);
|
||||
}
|
||||
#else
|
||||
internal void Write(double source)
|
||||
{
|
||||
byte[] val = BitConverter.GetBytes(source);
|
||||
#if BIGENDIAN
|
||||
// 0 1 2 3 4 5 6 7
|
||||
|
||||
// swap byte order
|
||||
byte tmp = val[7];
|
||||
val[7] = val[0];
|
||||
val[0] = tmp;
|
||||
|
||||
tmp = val[6];
|
||||
val[6] = val[1];
|
||||
val[1] = tmp;
|
||||
|
||||
tmp = val[5];
|
||||
val[5] = val[2];
|
||||
val[2] = tmp;
|
||||
|
||||
tmp = val[4];
|
||||
val[4] = val[3];
|
||||
val[3] = tmp;
|
||||
#endif
|
||||
Write(val);
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Variable bits
|
||||
//
|
||||
|
||||
/// <summary>
|
||||
/// Write Base128 encoded variable sized unsigned integer
|
||||
/// </summary>
|
||||
/// <returns>number of bytes written</returns>
|
||||
internal int WriteVariableUInt32(uint value)
|
||||
{
|
||||
int retval = 1;
|
||||
uint num1 = (uint)value;
|
||||
while (num1 >= 0x80)
|
||||
{
|
||||
this.Write((byte)(num1 | 0x80));
|
||||
num1 = num1 >> 7;
|
||||
retval++;
|
||||
}
|
||||
this.Write((byte)num1);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write Base128 encoded variable sized signed integer
|
||||
/// </summary>
|
||||
/// <returns>number of bytes written</returns>
|
||||
internal int WriteVariableInt32(int value)
|
||||
{
|
||||
int retval = 1;
|
||||
uint num1 = (uint)((value << 1) ^ (value >> 31));
|
||||
while (num1 >= 0x80)
|
||||
{
|
||||
this.Write((byte)(num1 | 0x80));
|
||||
num1 = num1 >> 7;
|
||||
retval++;
|
||||
}
|
||||
this.Write((byte)num1);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write Base128 encoded variable sized unsigned integer
|
||||
/// </summary>
|
||||
/// <returns>number of bytes written</returns>
|
||||
internal int WriteVariableUInt64(UInt64 value)
|
||||
{
|
||||
int retval = 1;
|
||||
UInt64 num1 = (UInt64)value;
|
||||
while (num1 >= 0x80)
|
||||
{
|
||||
this.Write((byte)(num1 | 0x80));
|
||||
num1 = num1 >> 7;
|
||||
retval++;
|
||||
}
|
||||
this.Write((byte)num1);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compress (lossy) a float in the range -1..1 using numberOfBits bits
|
||||
/// </summary>
|
||||
internal void WriteSignedSingle(float value, int numberOfBits)
|
||||
{
|
||||
NetException.Assert(((value >= -1.0) && (value <= 1.0)), " WriteSignedSingle() must be passed a float in the range -1 to 1; val is " + value);
|
||||
|
||||
float unit = (value + 1.0f) * 0.5f;
|
||||
int maxVal = (1 << numberOfBits) - 1;
|
||||
uint writeVal = (uint)(unit * (float)maxVal);
|
||||
|
||||
Write(writeVal, numberOfBits);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compress (lossy) a float in the range 0..1 using numberOfBits bits
|
||||
/// </summary>
|
||||
internal void WriteUnitSingle(float value, int numberOfBits)
|
||||
{
|
||||
NetException.Assert(((value >= 0.0) && (value <= 1.0)), " WriteUnitSingle() must be passed a float in the range 0 to 1; val is " + value);
|
||||
|
||||
int maxValue = (1 << numberOfBits) - 1;
|
||||
uint writeVal = (uint)(value * (float)maxValue);
|
||||
|
||||
Write(writeVal, numberOfBits);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compress a float within a specified range using a certain number of bits
|
||||
/// </summary>
|
||||
internal void WriteRangedSingle(float value, float min, float max, int numberOfBits)
|
||||
{
|
||||
NetException.Assert(((value >= min) && (value <= max)), " WriteRangedSingle() must be passed a float in the range MIN to MAX; val is " + value);
|
||||
|
||||
float range = max - min;
|
||||
float unit = ((value - min) / range);
|
||||
int maxVal = (1 << numberOfBits) - 1;
|
||||
Write((UInt32)((float)maxVal * unit), numberOfBits);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an integer with the least amount of bits need for the specified range
|
||||
/// Returns number of bits written
|
||||
/// </summary>
|
||||
internal int WriteRangedInteger(int min, int max, int value)
|
||||
{
|
||||
NetException.Assert(value >= min && value <= max, "Value not within min/max range!");
|
||||
|
||||
uint range = (uint)(max - min);
|
||||
int numBits = NetUtility.BitsToHoldUInt(range);
|
||||
|
||||
uint rvalue = (uint)(value - min);
|
||||
Write(rvalue, numBits);
|
||||
|
||||
return numBits;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write a string
|
||||
/// </summary>
|
||||
internal void Write(string source)
|
||||
{
|
||||
if (string.IsNullOrEmpty(source))
|
||||
{
|
||||
InternalEnsureBufferSize(m_bitLength + 8);
|
||||
WriteVariableUInt32(0);
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(source);
|
||||
InternalEnsureBufferSize(m_bitLength + ((bytes.Length + 2) * 8));
|
||||
WriteVariableUInt32((uint)bytes.Length);
|
||||
Write(bytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an endpoint description
|
||||
/// </summary>
|
||||
internal void Write(IPEndPoint endPoint)
|
||||
{
|
||||
byte[] bytes = endPoint.Address.GetAddressBytes();
|
||||
Write((byte)bytes.Length);
|
||||
Write(bytes);
|
||||
Write((ushort)endPoint.Port);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pads data with enough bits to reach a full byte. Decreases cpu usage for subsequent byte writes.
|
||||
/// </summary>
|
||||
internal void WritePadBits()
|
||||
{
|
||||
m_bitLength = ((m_bitLength + 7) / 8) * 8;
|
||||
InternalEnsureBufferSize(m_bitLength);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pads data with the specified number of bits.
|
||||
/// </summary>
|
||||
internal void WritePadBits(int numberOfBits)
|
||||
{
|
||||
m_bitLength += numberOfBits;
|
||||
InternalEnsureBufferSize(m_bitLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
/* Copyright (c) 2010 Michael Lidgren
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom
|
||||
the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
public partial class NetOutgoingMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// Writes all public and private declared instance fields of the object in alphabetical order using reflection
|
||||
/// </summary>
|
||||
public void WriteAllFields(object ob)
|
||||
{
|
||||
WriteAllFields(ob, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes all fields with specified binding in alphabetical order using reflection
|
||||
/// </summary>
|
||||
public void WriteAllFields(object ob, BindingFlags flags)
|
||||
{
|
||||
if (ob == null)
|
||||
return;
|
||||
Type tp = ob.GetType();
|
||||
|
||||
FieldInfo[] fields = tp.GetFields(flags);
|
||||
NetUtility.SortMembersList(fields);
|
||||
|
||||
foreach (FieldInfo fi in fields)
|
||||
{
|
||||
object value = fi.GetValue(ob);
|
||||
|
||||
// find the appropriate Write method
|
||||
MethodInfo writeMethod;
|
||||
if (s_writeMethods.TryGetValue(fi.FieldType, out writeMethod))
|
||||
writeMethod.Invoke(this, new object[] { value });
|
||||
else
|
||||
throw new NetException("Failed to find write method for type " + fi.FieldType);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes all public and private declared instance properties of the object in alphabetical order using reflection
|
||||
/// </summary>
|
||||
public void WriteAllProperties(object ob)
|
||||
{
|
||||
WriteAllProperties(ob, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes all properties with specified binding in alphabetical order using reflection
|
||||
/// </summary>
|
||||
public void WriteAllProperties(object ob, BindingFlags flags)
|
||||
{
|
||||
if (ob == null)
|
||||
return;
|
||||
Type tp = ob.GetType();
|
||||
|
||||
PropertyInfo[] fields = tp.GetProperties(flags);
|
||||
NetUtility.SortMembersList(fields);
|
||||
|
||||
foreach (PropertyInfo fi in fields)
|
||||
{
|
||||
MethodInfo getMethod = fi.GetGetMethod((flags & BindingFlags.NonPublic) == BindingFlags.NonPublic);
|
||||
object value = getMethod.Invoke(ob, null);
|
||||
|
||||
// find the appropriate Write method
|
||||
MethodInfo writeMethod;
|
||||
if (s_writeMethods.TryGetValue(fi.PropertyType, out writeMethod))
|
||||
writeMethod.Invoke(this, new object[] { value });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,659 +0,0 @@
|
||||
/* Copyright (c) 2010 Michael Lidgren
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom
|
||||
the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
public sealed partial class NetOutgoingMessage
|
||||
{
|
||||
private const int c_overAllocateAmount = 4;
|
||||
|
||||
private static Dictionary<Type, MethodInfo> s_writeMethods;
|
||||
|
||||
internal byte[] m_data;
|
||||
internal int m_bitLength;
|
||||
|
||||
static NetOutgoingMessage()
|
||||
{
|
||||
s_writeMethods = new Dictionary<Type, MethodInfo>();
|
||||
MethodInfo[] methods = typeof(NetOutgoingMessage).GetMethods(BindingFlags.Instance | BindingFlags.Public);
|
||||
foreach (MethodInfo mi in methods)
|
||||
{
|
||||
if (mi.Name.Equals("Write", StringComparison.InvariantCulture))
|
||||
{
|
||||
ParameterInfo[] pis = mi.GetParameters();
|
||||
if (pis.Length == 1)
|
||||
s_writeMethods[pis[0].ParameterType] = mi;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the internal data buffer, don't modify
|
||||
/// </summary>
|
||||
public byte[] PeekDataBuffer()
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the length of the buffer in bytes
|
||||
/// </summary>
|
||||
public int LengthBytes
|
||||
{
|
||||
get { return ((m_bitLength + 7) >> 3); }
|
||||
set
|
||||
{
|
||||
m_bitLength = value * 8;
|
||||
InternalEnsureBufferSize(m_bitLength);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the length of the buffer in bits
|
||||
/// </summary>
|
||||
public int LengthBits
|
||||
{
|
||||
get { return m_bitLength; }
|
||||
set
|
||||
{
|
||||
m_bitLength = value;
|
||||
InternalEnsureBufferSize(m_bitLength);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures the buffer can hold this number of bits
|
||||
/// </summary>
|
||||
public void EnsureBufferSize(int numberOfBits)
|
||||
{
|
||||
int byteLen = ((numberOfBits + 7) >> 3);
|
||||
if (m_data == null)
|
||||
{
|
||||
m_data = new byte[byteLen + c_overAllocateAmount];
|
||||
return;
|
||||
}
|
||||
if (m_data.Length < byteLen)
|
||||
Array.Resize<byte>(ref m_data, byteLen + c_overAllocateAmount);
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures the buffer can hold this number of bits
|
||||
/// </summary>
|
||||
public void InternalEnsureBufferSize(int numberOfBits)
|
||||
{
|
||||
int byteLen = ((numberOfBits + 7) >> 3);
|
||||
if (m_data == null)
|
||||
{
|
||||
m_data = new byte[byteLen];
|
||||
return;
|
||||
}
|
||||
if (m_data.Length < byteLen)
|
||||
Array.Resize<byte>(ref m_data, byteLen);
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a boolean value using 1 bit
|
||||
/// </summary>
|
||||
public void Write(bool value)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + 1);
|
||||
NetBitWriter.WriteByte((value ? (byte)1 : (byte)0), 1, m_data, m_bitLength);
|
||||
m_bitLength += 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write a byte
|
||||
/// </summary>
|
||||
public void Write(byte source)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + 8);
|
||||
NetBitWriter.WriteByte(source, 8, m_data, m_bitLength);
|
||||
m_bitLength += 8;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a signed byte
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public void Write(sbyte source)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + 8);
|
||||
NetBitWriter.WriteByte((byte)source, 8, m_data, m_bitLength);
|
||||
m_bitLength += 8;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes 1 to 8 bits of a byte
|
||||
/// </summary>
|
||||
public void Write(byte source, int numberOfBits)
|
||||
{
|
||||
NetException.Assert((numberOfBits > 0 && numberOfBits <= 8), "Write(byte, numberOfBits) can only write between 1 and 8 bits");
|
||||
EnsureBufferSize(m_bitLength + numberOfBits);
|
||||
NetBitWriter.WriteByte(source, numberOfBits, m_data, m_bitLength);
|
||||
m_bitLength += numberOfBits;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes all bytes in an array
|
||||
/// </summary>
|
||||
public void Write(byte[] source)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException("source");
|
||||
int bits = source.Length * 8;
|
||||
EnsureBufferSize(m_bitLength + bits);
|
||||
NetBitWriter.WriteBytes(source, 0, source.Length, m_data, m_bitLength);
|
||||
m_bitLength += bits;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the specified number of bytes from an array
|
||||
/// </summary>
|
||||
public void Write(byte[] source, int offsetInBytes, int numberOfBytes)
|
||||
{
|
||||
if (source == null)
|
||||
throw new ArgumentNullException("source");
|
||||
int bits = numberOfBytes * 8;
|
||||
EnsureBufferSize(m_bitLength + bits);
|
||||
NetBitWriter.WriteBytes(source, offsetInBytes, numberOfBytes, m_data, m_bitLength);
|
||||
m_bitLength += bits;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an unsigned 16 bit integer
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
[CLSCompliant(false)]
|
||||
public void Write(UInt16 source)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + 16);
|
||||
NetBitWriter.WriteUInt32((uint)source, 16, m_data, m_bitLength);
|
||||
m_bitLength += 16;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an unsigned integer using 1 to 16 bits
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public void Write(UInt16 source, int numberOfBits)
|
||||
{
|
||||
NetException.Assert((numberOfBits > 0 && numberOfBits <= 16), "Write(ushort, numberOfBits) can only write between 1 and 16 bits");
|
||||
EnsureBufferSize(m_bitLength + numberOfBits);
|
||||
NetBitWriter.WriteUInt32((uint)source, numberOfBits, m_data, m_bitLength);
|
||||
m_bitLength += numberOfBits;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a signed 16 bit integer
|
||||
/// </summary>
|
||||
public void Write(Int16 source)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + 16);
|
||||
NetBitWriter.WriteUInt32((uint)source, 16, m_data, m_bitLength);
|
||||
m_bitLength += 16;
|
||||
}
|
||||
|
||||
#if UNSAFE
|
||||
/// <summary>
|
||||
/// Writes a 32 bit signed integer
|
||||
/// </summary>
|
||||
public unsafe void Write(Int32 source)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + 32);
|
||||
|
||||
// can write fast?
|
||||
if (m_bitLength % 8 == 0)
|
||||
{
|
||||
fixed (byte* numRef = &Data[m_bitLength / 8])
|
||||
{
|
||||
*((int*)numRef) = source;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NetBitWriter.WriteUInt32((UInt32)source, 32, Data, m_bitLength);
|
||||
}
|
||||
m_bitLength += 32;
|
||||
}
|
||||
#else
|
||||
/// <summary>
|
||||
/// Writes a 32 bit signed integer
|
||||
/// </summary>
|
||||
public void Write(Int32 source)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + 32);
|
||||
NetBitWriter.WriteUInt32((UInt32)source, 32, m_data, m_bitLength);
|
||||
m_bitLength += 32;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNSAFE
|
||||
/// <summary>
|
||||
/// Writes a 32 bit unsigned integer
|
||||
/// </summary>
|
||||
public unsafe void Write(UInt32 source)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + 32);
|
||||
|
||||
// can write fast?
|
||||
if (m_bitLength % 8 == 0)
|
||||
{
|
||||
fixed (byte* numRef = &Data[m_bitLength / 8])
|
||||
{
|
||||
*((uint*)numRef) = source;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NetBitWriter.WriteUInt32(source, 32, Data, m_bitLength);
|
||||
}
|
||||
|
||||
m_bitLength += 32;
|
||||
}
|
||||
#else
|
||||
/// <summary>
|
||||
/// Writes a 32 bit unsigned integer
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public void Write(UInt32 source)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + 32);
|
||||
NetBitWriter.WriteUInt32(source, 32, m_data, m_bitLength);
|
||||
m_bitLength += 32;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Writes a 32 bit signed integer
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public void Write(UInt32 source, int numberOfBits)
|
||||
{
|
||||
NetException.Assert((numberOfBits > 0 && numberOfBits <= 32), "Write(uint, numberOfBits) can only write between 1 and 32 bits");
|
||||
EnsureBufferSize(m_bitLength + numberOfBits);
|
||||
NetBitWriter.WriteUInt32(source, numberOfBits, m_data, m_bitLength);
|
||||
m_bitLength += numberOfBits;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a signed integer using 1 to 32 bits
|
||||
/// </summary>
|
||||
public void Write(Int32 source, int numberOfBits)
|
||||
{
|
||||
NetException.Assert((numberOfBits > 0 && numberOfBits <= 32), "Write(int, numberOfBits) can only write between 1 and 32 bits");
|
||||
EnsureBufferSize(m_bitLength + numberOfBits);
|
||||
|
||||
if (numberOfBits != 32)
|
||||
{
|
||||
// make first bit sign
|
||||
int signBit = 1 << (numberOfBits - 1);
|
||||
if (source < 0)
|
||||
source = (-source - 1) | signBit;
|
||||
else
|
||||
source &= (~signBit);
|
||||
}
|
||||
|
||||
NetBitWriter.WriteUInt32((uint)source, numberOfBits, m_data, m_bitLength);
|
||||
|
||||
m_bitLength += numberOfBits;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a 64 bit unsigned integer
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public void Write(UInt64 source)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + 64);
|
||||
NetBitWriter.WriteUInt64(source, 64, m_data, m_bitLength);
|
||||
m_bitLength += 64;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an unsigned integer using 1 to 64 bits
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public void Write(UInt64 source, int numberOfBits)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + numberOfBits);
|
||||
NetBitWriter.WriteUInt64(source, numberOfBits, m_data, m_bitLength);
|
||||
m_bitLength += numberOfBits;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a 64 bit signed integer
|
||||
/// </summary>
|
||||
public void Write(Int64 source)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + 64);
|
||||
ulong usource = (ulong)source;
|
||||
NetBitWriter.WriteUInt64(usource, 64, m_data, m_bitLength);
|
||||
m_bitLength += 64;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a signed integer using 1 to 64 bits
|
||||
/// </summary>
|
||||
public void Write(Int64 source, int numberOfBits)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + numberOfBits);
|
||||
ulong usource = (ulong)source;
|
||||
NetBitWriter.WriteUInt64(usource, numberOfBits, m_data, m_bitLength);
|
||||
m_bitLength += numberOfBits;
|
||||
}
|
||||
|
||||
//
|
||||
// Floating point
|
||||
//
|
||||
#if UNSAFE
|
||||
/// <summary>
|
||||
/// Writes a 32 bit floating point value
|
||||
/// </summary>
|
||||
public unsafe void Write(float source)
|
||||
{
|
||||
uint val = *((uint*)&source);
|
||||
#if BIGENDIAN
|
||||
val = NetUtility.SwapByteOrder(val);
|
||||
#endif
|
||||
Write(val);
|
||||
}
|
||||
#else
|
||||
/// <summary>
|
||||
/// Writes a 32 bit floating point value
|
||||
/// </summary>
|
||||
public void Write(float source)
|
||||
{
|
||||
// Use union to avoid BitConverter.GetBytes() which allocates memory on the heap
|
||||
SingleUIntUnion su;
|
||||
su.UIntValue = 0; // must initialize every member of the union to avoid warning
|
||||
su.SingleValue = source;
|
||||
|
||||
#if BIGENDIAN
|
||||
// swap byte order
|
||||
su.UIntValue = NetUtility.SwapByteOrder(su.UIntValue);
|
||||
#endif
|
||||
Write(su.UIntValue);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNSAFE
|
||||
/// <summary>
|
||||
/// Writes a 64 bit floating point value
|
||||
/// </summary>
|
||||
public unsafe void Write(double source)
|
||||
{
|
||||
ulong val = *((ulong*)&source);
|
||||
#if BIGENDIAN
|
||||
val = NetUtility.SwapByteOrder(val);
|
||||
#endif
|
||||
Write(val);
|
||||
}
|
||||
#else
|
||||
/// <summary>
|
||||
/// Writes a 64 bit floating point value
|
||||
/// </summary>
|
||||
public void Write(double source)
|
||||
{
|
||||
byte[] val = BitConverter.GetBytes(source);
|
||||
#if BIGENDIAN
|
||||
// 0 1 2 3 4 5 6 7
|
||||
|
||||
// swap byte order
|
||||
byte tmp = val[7];
|
||||
val[7] = val[0];
|
||||
val[0] = tmp;
|
||||
|
||||
tmp = val[6];
|
||||
val[6] = val[1];
|
||||
val[1] = tmp;
|
||||
|
||||
tmp = val[5];
|
||||
val[5] = val[2];
|
||||
val[2] = tmp;
|
||||
|
||||
tmp = val[4];
|
||||
val[4] = val[3];
|
||||
val[3] = tmp;
|
||||
#endif
|
||||
Write(val);
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Variable bits
|
||||
//
|
||||
|
||||
/// <summary>
|
||||
/// Write Base128 encoded variable sized unsigned integer of up to 32 bits
|
||||
/// </summary>
|
||||
/// <returns>number of bytes written</returns>
|
||||
[CLSCompliant(false)]
|
||||
public int WriteVariableUInt32(uint value)
|
||||
{
|
||||
int retval = 1;
|
||||
uint num1 = (uint)value;
|
||||
while (num1 >= 0x80)
|
||||
{
|
||||
this.Write((byte)(num1 | 0x80));
|
||||
num1 = num1 >> 7;
|
||||
retval++;
|
||||
}
|
||||
this.Write((byte)num1);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write Base128 encoded variable sized signed integer of up to 32 bits
|
||||
/// </summary>
|
||||
/// <returns>number of bytes written</returns>
|
||||
public int WriteVariableInt32(int value)
|
||||
{
|
||||
uint zigzag = (uint)(value << 1) ^ (uint)(value >> 31);
|
||||
return WriteVariableUInt32(zigzag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write Base128 encoded variable sized signed integer of up to 64 bits
|
||||
/// </summary>
|
||||
/// <returns>number of bytes written</returns>
|
||||
public int WriteVariableInt64(Int64 value)
|
||||
{
|
||||
ulong zigzag = (ulong)(value << 1) ^ (ulong)(value >> 63);
|
||||
return WriteVariableUInt64(zigzag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write Base128 encoded variable sized unsigned integer of up to 64 bits
|
||||
/// </summary>
|
||||
/// <returns>number of bytes written</returns>
|
||||
[CLSCompliant(false)]
|
||||
public int WriteVariableUInt64(UInt64 value)
|
||||
{
|
||||
int retval = 1;
|
||||
UInt64 num1 = (UInt64)value;
|
||||
while (num1 >= 0x80)
|
||||
{
|
||||
this.Write((byte)(num1 | 0x80));
|
||||
num1 = num1 >> 7;
|
||||
retval++;
|
||||
}
|
||||
this.Write((byte)num1);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compress (lossy) a float in the range -1..1 using numberOfBits bits
|
||||
/// </summary>
|
||||
public void WriteSignedSingle(float value, int numberOfBits)
|
||||
{
|
||||
NetException.Assert(((value >= -1.0) && (value <= 1.0)), " WriteSignedSingle() must be passed a float in the range -1 to 1; val is " + value);
|
||||
|
||||
float unit = (value + 1.0f) * 0.5f;
|
||||
int maxVal = (1 << numberOfBits) - 1;
|
||||
uint writeVal = (uint)(unit * (float)maxVal);
|
||||
|
||||
Write(writeVal, numberOfBits);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compress (lossy) a float in the range 0..1 using numberOfBits bits
|
||||
/// </summary>
|
||||
public void WriteUnitSingle(float value, int numberOfBits)
|
||||
{
|
||||
NetException.Assert(((value >= 0.0) && (value <= 1.0)), " WriteUnitSingle() must be passed a float in the range 0 to 1; val is " + value);
|
||||
|
||||
int maxValue = (1 << numberOfBits) - 1;
|
||||
uint writeVal = (uint)(value * (float)maxValue);
|
||||
|
||||
Write(writeVal, numberOfBits);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compress a float within a specified range using a certain number of bits
|
||||
/// </summary>
|
||||
public void WriteRangedSingle(float value, float min, float max, int numberOfBits)
|
||||
{
|
||||
NetException.Assert(((value >= min) && (value <= max)), " WriteRangedSingle() must be passed a float in the range MIN to MAX; val is " + value);
|
||||
|
||||
float range = max - min;
|
||||
float unit = ((value - min) / range);
|
||||
int maxVal = (1 << numberOfBits) - 1;
|
||||
Write((UInt32)((float)maxVal * unit), numberOfBits);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an integer with the least amount of bits need for the specified range
|
||||
/// Returns number of bits written
|
||||
/// </summary>
|
||||
public int WriteRangedInteger(int min, int max, int value)
|
||||
{
|
||||
NetException.Assert(value >= min && value <= max, "Value not within min/max range!");
|
||||
|
||||
uint range = (uint)(max - min);
|
||||
int numBits = NetUtility.BitsToHoldUInt(range);
|
||||
|
||||
uint rvalue = (uint)(value - min);
|
||||
Write(rvalue, numBits);
|
||||
|
||||
return numBits;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write a string
|
||||
/// </summary>
|
||||
public void Write(string source)
|
||||
{
|
||||
if (string.IsNullOrEmpty(source))
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + 8);
|
||||
WriteVariableUInt32(0);
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(source);
|
||||
EnsureBufferSize(m_bitLength + 8 + (bytes.Length * 8));
|
||||
WriteVariableUInt32((uint)bytes.Length);
|
||||
Write(bytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an endpoint description
|
||||
/// </summary>
|
||||
public void Write(IPEndPoint endPoint)
|
||||
{
|
||||
byte[] bytes = endPoint.Address.GetAddressBytes();
|
||||
Write((byte)bytes.Length);
|
||||
Write(bytes);
|
||||
Write((ushort)endPoint.Port);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the local time to a message; readable (and convertable to local time) by the remote host using ReadTime()
|
||||
/// </summary>
|
||||
public void WriteTime(double localTime, bool highPrecision)
|
||||
{
|
||||
if (highPrecision)
|
||||
Write(localTime);
|
||||
else
|
||||
Write((float)localTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pads data with enough bits to reach a full byte. Decreases cpu usage for subsequent byte writes.
|
||||
/// </summary>
|
||||
public void WritePadBits()
|
||||
{
|
||||
m_bitLength = ((m_bitLength + 7) >> 3) * 8;
|
||||
EnsureBufferSize(m_bitLength);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pads data with the specified number of bits.
|
||||
/// </summary>
|
||||
public void WritePadBits(int numberOfBits)
|
||||
{
|
||||
m_bitLength += numberOfBits;
|
||||
EnsureBufferSize(m_bitLength);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append all the bits of message to this message
|
||||
/// </summary>
|
||||
public void Write(NetOutgoingMessage message)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + (message.LengthBytes * 8));
|
||||
|
||||
Write(message.m_data, 0, message.LengthBytes);
|
||||
|
||||
// did we write excessive bits?
|
||||
int bitsInLastByte = (message.m_bitLength % 8);
|
||||
if (bitsInLastByte != 0)
|
||||
{
|
||||
int excessBits = 8 - bitsInLastByte;
|
||||
m_bitLength -= excessBits;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append all the bits of message to this message
|
||||
/// </summary>
|
||||
public void Write(NetIncomingMessage message)
|
||||
{
|
||||
EnsureBufferSize(m_bitLength + (message.LengthBytes * 8));
|
||||
|
||||
Write(message.m_data, 0, message.LengthBytes);
|
||||
|
||||
// did we write excessive bits?
|
||||
int bitsInLastByte = (message.m_bitLength % 8);
|
||||
if (bitsInLastByte != 0)
|
||||
{
|
||||
int excessBits = 8 - bitsInLastByte;
|
||||
m_bitLength -= excessBits;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,281 +0,0 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
/// <summary>
|
||||
/// Multiply With Carry random
|
||||
/// </summary>
|
||||
public class MWCRandom : NetRandom
|
||||
{
|
||||
/// <summary>
|
||||
/// Get global instance of MWCRandom
|
||||
/// </summary>
|
||||
public static new readonly MWCRandom Instance = new MWCRandom();
|
||||
|
||||
private uint m_w, m_z;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with randomized seed
|
||||
/// </summary>
|
||||
public MWCRandom()
|
||||
{
|
||||
Initialize(NetRandomSeed.GetUInt64());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// (Re)initialize this instance with provided 32 bit seed
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public override void Initialize(uint seed)
|
||||
{
|
||||
m_w = seed;
|
||||
m_z = seed * 16777619;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// (Re)initialize this instance with provided 64 bit seed
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public void Initialize(ulong seed)
|
||||
{
|
||||
m_w = (uint)seed;
|
||||
m_z = (uint)(seed >> 32);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a random value from UInt32.MinValue to UInt32.MaxValue, inclusively
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public override uint NextUInt32()
|
||||
{
|
||||
m_z = 36969 * (m_z & 65535) + (m_z >> 16);
|
||||
m_w = 18000 * (m_w & 65535) + (m_w >> 16);
|
||||
return ((m_z << 16) + m_w);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Xor Shift based random
|
||||
/// </summary>
|
||||
public sealed class XorShiftRandom : NetRandom
|
||||
{
|
||||
/// <summary>
|
||||
/// Get global instance of XorShiftRandom
|
||||
/// </summary>
|
||||
public static new readonly XorShiftRandom Instance = new XorShiftRandom();
|
||||
|
||||
private const uint c_x = 123456789;
|
||||
private const uint c_y = 362436069;
|
||||
private const uint c_z = 521288629;
|
||||
private const uint c_w = 88675123;
|
||||
|
||||
private uint m_x, m_y, m_z, m_w;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with randomized seed
|
||||
/// </summary>
|
||||
public XorShiftRandom()
|
||||
{
|
||||
Initialize(NetRandomSeed.GetUInt64());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with provided 64 bit seed
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public XorShiftRandom(ulong seed)
|
||||
{
|
||||
Initialize(seed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// (Re)initialize this instance with provided 32 bit seed
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public override void Initialize(uint seed)
|
||||
{
|
||||
m_x = (uint)seed;
|
||||
m_y = c_y;
|
||||
m_z = c_z;
|
||||
m_w = c_w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// (Re)initialize this instance with provided 64 bit seed
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public void Initialize(ulong seed)
|
||||
{
|
||||
m_x = (uint)seed;
|
||||
m_y = c_y;
|
||||
m_z = (uint)(seed << 32);
|
||||
m_w = c_w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a random value from UInt32.MinValue to UInt32.MaxValue, inclusively
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public override uint NextUInt32()
|
||||
{
|
||||
uint t = (m_x ^ (m_x << 11));
|
||||
m_x = m_y; m_y = m_z; m_z = m_w;
|
||||
return (m_w = (m_w ^ (m_w >> 19)) ^ (t ^ (t >> 8)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mersenne Twister based random
|
||||
/// </summary>
|
||||
public sealed class MersenneTwisterRandom : NetRandom
|
||||
{
|
||||
/// <summary>
|
||||
/// Get global instance of MersenneTwisterRandom
|
||||
/// </summary>
|
||||
public static new readonly MersenneTwisterRandom Instance = new MersenneTwisterRandom();
|
||||
|
||||
private const int N = 624;
|
||||
private const int M = 397;
|
||||
private const uint MATRIX_A = 0x9908b0dfU;
|
||||
private const uint UPPER_MASK = 0x80000000U;
|
||||
private const uint LOWER_MASK = 0x7fffffffU;
|
||||
private const uint TEMPER1 = 0x9d2c5680U;
|
||||
private const uint TEMPER2 = 0xefc60000U;
|
||||
private const int TEMPER3 = 11;
|
||||
private const int TEMPER4 = 7;
|
||||
private const int TEMPER5 = 15;
|
||||
private const int TEMPER6 = 18;
|
||||
|
||||
private UInt32[] mt;
|
||||
private int mti;
|
||||
private UInt32[] mag01;
|
||||
|
||||
private const double c_realUnitInt = 1.0 / ((double)int.MaxValue + 1.0);
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with randomized seed
|
||||
/// </summary>
|
||||
public MersenneTwisterRandom()
|
||||
{
|
||||
Initialize(NetRandomSeed.GetUInt32());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with provided 32 bit seed
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public MersenneTwisterRandom(uint seed)
|
||||
{
|
||||
Initialize(seed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// (Re)initialize this instance with provided 32 bit seed
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public override void Initialize(uint seed)
|
||||
{
|
||||
mt = new UInt32[N];
|
||||
mti = N + 1;
|
||||
mag01 = new UInt32[] { 0x0U, MATRIX_A };
|
||||
mt[0] = seed;
|
||||
for (int i = 1; i < N; i++)
|
||||
mt[i] = (UInt32)(1812433253 * (mt[i - 1] ^ (mt[i - 1] >> 30)) + i);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a random value from UInt32.MinValue to UInt32.MaxValue, inclusively
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public override uint NextUInt32()
|
||||
{
|
||||
UInt32 y;
|
||||
if (mti >= N)
|
||||
{
|
||||
GenRandAll();
|
||||
mti = 0;
|
||||
}
|
||||
y = mt[mti++];
|
||||
y ^= (y >> TEMPER3);
|
||||
y ^= (y << TEMPER4) & TEMPER1;
|
||||
y ^= (y << TEMPER5) & TEMPER2;
|
||||
y ^= (y >> TEMPER6);
|
||||
return y;
|
||||
}
|
||||
|
||||
private void GenRandAll()
|
||||
{
|
||||
int kk = 1;
|
||||
UInt32 y;
|
||||
UInt32 p;
|
||||
y = mt[0] & UPPER_MASK;
|
||||
do
|
||||
{
|
||||
p = mt[kk];
|
||||
mt[kk - 1] = mt[kk + (M - 1)] ^ ((y | (p & LOWER_MASK)) >> 1) ^ mag01[p & 1];
|
||||
y = p & UPPER_MASK;
|
||||
} while (++kk < N - M + 1);
|
||||
do
|
||||
{
|
||||
p = mt[kk];
|
||||
mt[kk - 1] = mt[kk + (M - N - 1)] ^ ((y | (p & LOWER_MASK)) >> 1) ^ mag01[p & 1];
|
||||
y = p & UPPER_MASK;
|
||||
} while (++kk < N);
|
||||
p = mt[0];
|
||||
mt[N - 1] = mt[M - 1] ^ ((y | (p & LOWER_MASK)) >> 1) ^ mag01[p & 1];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RNGCryptoServiceProvider based random; very slow but cryptographically safe
|
||||
/// </summary>
|
||||
public class CryptoRandom : NetRandom
|
||||
{
|
||||
/// <summary>
|
||||
/// Global instance of CryptoRandom
|
||||
/// </summary>
|
||||
public static new readonly CryptoRandom Instance = new CryptoRandom();
|
||||
|
||||
private RandomNumberGenerator m_rnd = new RNGCryptoServiceProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Seed in CryptoRandom does not create deterministic sequences
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public override void Initialize(uint seed)
|
||||
{
|
||||
byte[] tmp = new byte[seed % 16];
|
||||
m_rnd.GetBytes(tmp); // just prime it
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a random value from UInt32.MinValue to UInt32.MaxValue, inclusively
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public override uint NextUInt32()
|
||||
{
|
||||
var bytes = new byte[4];
|
||||
m_rnd.GetBytes(bytes);
|
||||
return (uint)bytes[0] | (((uint)bytes[1]) << 8) | (((uint)bytes[2]) << 16) | (((uint)bytes[3]) << 24);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fill the specified buffer with random values
|
||||
/// </summary>
|
||||
public override void NextBytes(byte[] buffer)
|
||||
{
|
||||
m_rnd.GetBytes(buffer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills all bytes from offset to offset + length in buffer with random values
|
||||
/// </summary>
|
||||
public override void NextBytes(byte[] buffer, int offset, int length)
|
||||
{
|
||||
var bytes = new byte[length];
|
||||
m_rnd.GetBytes(bytes);
|
||||
Array.Copy(bytes, 0, buffer, offset, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for generating random seeds
|
||||
/// </summary>
|
||||
public static class NetRandomSeed
|
||||
{
|
||||
private static int m_seedIncrement = -1640531527;
|
||||
|
||||
/// <summary>
|
||||
/// Generates a 32 bit random seed
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public static uint GetUInt32()
|
||||
{
|
||||
ulong seed = GetUInt64();
|
||||
uint low = (uint)seed;
|
||||
uint high = (uint)(seed >> 32);
|
||||
return low ^ high;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a 64 bit random seed
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public static ulong GetUInt64()
|
||||
{
|
||||
var guidBytes = Guid.NewGuid().ToByteArray();
|
||||
ulong seed =
|
||||
((ulong)guidBytes[0] << (8 * 0)) |
|
||||
((ulong)guidBytes[1] << (8 * 1)) |
|
||||
((ulong)guidBytes[2] << (8 * 2)) |
|
||||
((ulong)guidBytes[3] << (8 * 3)) |
|
||||
((ulong)guidBytes[4] << (8 * 4)) |
|
||||
((ulong)guidBytes[5] << (8 * 5)) |
|
||||
((ulong)guidBytes[6] << (8 * 6)) |
|
||||
((ulong)guidBytes[7] << (8 * 7));
|
||||
|
||||
return seed ^ NetUtility.GetPlatformSeed(m_seedIncrement);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,7 +176,7 @@ namespace Lidgren.Network
|
||||
|
||||
try
|
||||
{
|
||||
var entry = await Task.Factory.FromAsync(Dns.BeginGetHostEntry, Dns.EndGetHostEntry, ipOrHost, null);
|
||||
var entry = await Dns.GetHostEntryAsync(ipOrHost);
|
||||
return entry.AddressList;
|
||||
}
|
||||
catch (SocketException)
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
#if __ANDROID__
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
public static partial class NetUtility
|
||||
{
|
||||
private static byte[] s_randomMacBytes;
|
||||
|
||||
static NetUtility()
|
||||
{
|
||||
s_randomMacBytes = new byte[8];
|
||||
MWCRandom.Instance.NextBytes(s_randomMacBytes);
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public static ulong GetPlatformSeed(int seedInc)
|
||||
{
|
||||
ulong seed = (ulong)Environment.TickCount + (ulong)seedInc;
|
||||
return seed ^ ((ulong)(new object().GetHashCode()) << 32);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets my local IPv4 address (not necessarily external) and subnet mask
|
||||
/// </summary>
|
||||
public static IPAddress GetMyAddress(out IPAddress mask)
|
||||
{
|
||||
mask = null;
|
||||
try
|
||||
{
|
||||
Android.Net.Wifi.WifiManager wifi = (Android.Net.Wifi.WifiManager)Android.App.Application.Context.GetSystemService(Android.App.Activity.WifiService);
|
||||
if (!wifi.IsWifiEnabled)
|
||||
return null;
|
||||
|
||||
var dhcp = wifi.DhcpInfo;
|
||||
int addr = dhcp.IpAddress;
|
||||
byte[] quads = new byte[4];
|
||||
for (int k = 0; k < 4; k++)
|
||||
quads[k] = (byte)((addr >> k * 8) & 0xFF);
|
||||
return new IPAddress(quads);
|
||||
}
|
||||
catch // Catch Access Denied errors
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] GetMacAddressBytes()
|
||||
{
|
||||
return s_randomMacBytes;
|
||||
}
|
||||
|
||||
public static void Sleep(int milliseconds)
|
||||
{
|
||||
System.Threading.Thread.Sleep(milliseconds);
|
||||
}
|
||||
|
||||
public static IPAddress GetBroadcastAddress()
|
||||
{
|
||||
return IPAddress.Broadcast;
|
||||
}
|
||||
|
||||
public static IPAddress CreateAddressFromBytes(byte[] bytes)
|
||||
{
|
||||
return new IPAddress(bytes);
|
||||
}
|
||||
|
||||
private static readonly SHA1 s_sha = SHA1.Create();
|
||||
public static byte[] ComputeSHAHash(byte[] bytes, int offset, int count)
|
||||
{
|
||||
return s_sha.ComputeHash(bytes, offset, count);
|
||||
}
|
||||
}
|
||||
|
||||
public static partial class NetTime
|
||||
{
|
||||
private static readonly long s_timeInitialized = Environment.TickCount;
|
||||
|
||||
/// <summary>
|
||||
/// Get number of seconds since the application started
|
||||
/// </summary>
|
||||
public static double Now { get { return (double)((uint)Environment.TickCount - s_timeInitialized) / 1000.0; } }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,86 +0,0 @@
|
||||
#if __CONSTRAINED__ || UNITY_STANDALONE_LINUX
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
public static partial class NetUtility
|
||||
{
|
||||
private static byte[] s_randomMacBytes;
|
||||
|
||||
static NetUtility()
|
||||
{
|
||||
s_randomMacBytes = new byte[8];
|
||||
MWCRandom.Instance.NextBytes(s_randomMacBytes);
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public static ulong GetPlatformSeed(int seedInc)
|
||||
{
|
||||
ulong seed = (ulong)Environment.TickCount + (ulong)seedInc;
|
||||
return seed ^ ((ulong)(new object().GetHashCode()) << 32);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets my local IPv4 address (not necessarily external) and subnet mask
|
||||
/// </summary>
|
||||
public static IPAddress GetMyAddress(out IPAddress mask)
|
||||
{
|
||||
mask = null;
|
||||
#if UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_IOS
|
||||
try
|
||||
{
|
||||
if (!(UnityEngine.Application.internetReachability == UnityEngine.NetworkReachability.NotReachable))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return IPAddress.Parse(UnityEngine.Network.player.externalIP);
|
||||
}
|
||||
catch // Catch Access Denied errors
|
||||
{
|
||||
return null;
|
||||
}
|
||||
#endif
|
||||
return null;
|
||||
}
|
||||
|
||||
public static byte[] GetMacAddressBytes()
|
||||
{
|
||||
return s_randomMacBytes;
|
||||
}
|
||||
|
||||
public static IPAddress GetBroadcastAddress()
|
||||
{
|
||||
return IPAddress.Broadcast;
|
||||
}
|
||||
|
||||
public static void Sleep(int milliseconds)
|
||||
{
|
||||
System.Threading.Thread.Sleep(milliseconds);
|
||||
}
|
||||
|
||||
public static IPAddress CreateAddressFromBytes(byte[] bytes)
|
||||
{
|
||||
return new IPAddress(bytes);
|
||||
}
|
||||
|
||||
private static readonly SHA1 s_sha = SHA1.Create();
|
||||
public static byte[] ComputeSHAHash(byte[] bytes, int offset, int count)
|
||||
{
|
||||
return s_sha.ComputeHash(bytes, offset, count);
|
||||
}
|
||||
}
|
||||
|
||||
public static partial class NetTime
|
||||
{
|
||||
private static readonly long s_timeInitialized = Environment.TickCount;
|
||||
|
||||
/// <summary>
|
||||
/// Get number of seconds since the application started
|
||||
/// </summary>
|
||||
public static double Now { get { return (double)((uint)Environment.TickCount - s_timeInitialized) / 1000.0; } }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,156 +0,0 @@
|
||||
#if !__ANDROID__ && !__CONSTRAINED__ && !WINDOWS_RUNTIME && !UNITY_STANDALONE_LINUX
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
public static partial class NetUtility
|
||||
{
|
||||
private static readonly long s_timeInitialized = Stopwatch.GetTimestamp();
|
||||
private static readonly double s_dInvFreq = 1.0 / (double)Stopwatch.Frequency;
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public static ulong GetPlatformSeed(int seedInc)
|
||||
{
|
||||
ulong seed = (ulong)System.Diagnostics.Stopwatch.GetTimestamp();
|
||||
return seed ^ ((ulong)Environment.WorkingSet + (ulong)seedInc);
|
||||
}
|
||||
|
||||
public static double Now { get { return (double)(Stopwatch.GetTimestamp() - s_timeInitialized) * s_dInvFreq; } }
|
||||
|
||||
private static NetworkInterface GetNetworkInterface()
|
||||
{
|
||||
var computerProperties = IPGlobalProperties.GetIPGlobalProperties();
|
||||
if (computerProperties == null)
|
||||
return null;
|
||||
|
||||
var nics = NetworkInterface.GetAllNetworkInterfaces();
|
||||
if (nics == null || nics.Length < 1)
|
||||
return null;
|
||||
|
||||
NetworkInterface best = null;
|
||||
foreach (NetworkInterface adapter in nics)
|
||||
{
|
||||
if (adapter.NetworkInterfaceType == NetworkInterfaceType.Loopback || adapter.NetworkInterfaceType == NetworkInterfaceType.Unknown)
|
||||
continue;
|
||||
if (!adapter.Supports(NetworkInterfaceComponent.IPv4))
|
||||
continue;
|
||||
if (best == null)
|
||||
best = adapter;
|
||||
if (adapter.OperationalStatus != OperationalStatus.Up)
|
||||
continue;
|
||||
|
||||
// make sure this adapter has any ipv4 addresses
|
||||
IPInterfaceProperties properties = adapter.GetIPProperties();
|
||||
foreach (UnicastIPAddressInformation unicastAddress in properties.UnicastAddresses)
|
||||
{
|
||||
if (unicastAddress != null && unicastAddress.Address != null && unicastAddress.Address.AddressFamily == AddressFamily.InterNetwork)
|
||||
{
|
||||
// Yes it does, return this network interface.
|
||||
return adapter;
|
||||
}
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If available, returns the bytes of the physical (MAC) address for the first usable network interface
|
||||
/// </summary>
|
||||
public static byte[] GetMacAddressBytes()
|
||||
{
|
||||
var ni = GetNetworkInterface();
|
||||
if (ni == null)
|
||||
return null;
|
||||
return ni.GetPhysicalAddress().GetAddressBytes();
|
||||
}
|
||||
|
||||
public static IPAddress GetBroadcastAddress()
|
||||
{
|
||||
var ni = GetNetworkInterface();
|
||||
if (ni == null)
|
||||
return null;
|
||||
|
||||
var properties = ni.GetIPProperties();
|
||||
foreach (UnicastIPAddressInformation unicastAddress in properties.UnicastAddresses)
|
||||
{
|
||||
if (unicastAddress != null && unicastAddress.Address != null && unicastAddress.Address.AddressFamily == AddressFamily.InterNetwork)
|
||||
{
|
||||
var mask = unicastAddress.IPv4Mask;
|
||||
byte[] ipAdressBytes = unicastAddress.Address.GetAddressBytes();
|
||||
byte[] subnetMaskBytes = mask.GetAddressBytes();
|
||||
|
||||
if (ipAdressBytes.Length != subnetMaskBytes.Length)
|
||||
throw new ArgumentException("Lengths of IP address and subnet mask do not match.");
|
||||
|
||||
byte[] broadcastAddress = new byte[ipAdressBytes.Length];
|
||||
for (int i = 0; i < broadcastAddress.Length; i++)
|
||||
{
|
||||
broadcastAddress[i] = (byte)(ipAdressBytes[i] | (subnetMaskBytes[i] ^ 255));
|
||||
}
|
||||
return new IPAddress(broadcastAddress);
|
||||
}
|
||||
}
|
||||
return IPAddress.Broadcast;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets my local IPv4 address (not necessarily external) and subnet mask
|
||||
/// </summary>
|
||||
public static IPAddress GetMyAddress(out IPAddress mask)
|
||||
{
|
||||
var ni = GetNetworkInterface();
|
||||
if (ni == null)
|
||||
{
|
||||
mask = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
IPInterfaceProperties properties = ni.GetIPProperties();
|
||||
foreach (UnicastIPAddressInformation unicastAddress in properties.UnicastAddresses)
|
||||
{
|
||||
if (unicastAddress != null && unicastAddress.Address != null && unicastAddress.Address.AddressFamily == AddressFamily.InterNetwork)
|
||||
{
|
||||
mask = unicastAddress.IPv4Mask;
|
||||
return unicastAddress.Address;
|
||||
}
|
||||
}
|
||||
|
||||
mask = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void Sleep(int milliseconds)
|
||||
{
|
||||
System.Threading.Thread.Sleep(milliseconds);
|
||||
}
|
||||
|
||||
public static IPAddress CreateAddressFromBytes(byte[] bytes)
|
||||
{
|
||||
return new IPAddress(bytes);
|
||||
}
|
||||
|
||||
private static readonly SHA256 s_sha = SHA256.Create();
|
||||
public static byte[] ComputeSHAHash(byte[] bytes, int offset, int count)
|
||||
{
|
||||
return s_sha.ComputeHash(bytes, offset, count);
|
||||
}
|
||||
}
|
||||
|
||||
public static partial class NetTime
|
||||
{
|
||||
private static readonly long s_timeInitialized = Stopwatch.GetTimestamp();
|
||||
private static readonly double s_dInvFreq = 1.0 / (double)Stopwatch.Frequency;
|
||||
|
||||
/// <summary>
|
||||
/// Get number of seconds since the application started
|
||||
/// </summary>
|
||||
public static double Now { get { return (double)(Stopwatch.GetTimestamp() - s_timeInitialized) * s_dInvFreq; } }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,102 +0,0 @@
|
||||
#if WINDOWS_RUNTIME
|
||||
//
|
||||
//
|
||||
//
|
||||
// Completely broken right now
|
||||
//
|
||||
//
|
||||
//
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Lidgren.Network
|
||||
{
|
||||
public class NetAddress
|
||||
{
|
||||
public static readonly HostName Any = null;
|
||||
}
|
||||
|
||||
public class NetEndPoint
|
||||
{
|
||||
public NetEndPoint(HostName hostname, int port) { HostName = hostname; Port = port; }
|
||||
public NetEndPoint(HostName hostname, string port) { HostName = hostname; Port = int.Parse(port); }
|
||||
public NetEndPoint(string hostname, int port) { HostName = (hostname == null) ? null : new HostName(hostname); Port = port; }
|
||||
public HostName HostName;
|
||||
public int Port;
|
||||
public override string ToString() { return string.Format("{0}:{1}", HostName, Port); }
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HostName.RawName.GetHashCode() + Port;
|
||||
}
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var ep = obj as NetEndPoint;
|
||||
if (ep == null) return false;
|
||||
if (Port != ep.Port) return false;
|
||||
return HostName.RawName.Equals(ep.HostName.RawName);
|
||||
}
|
||||
};
|
||||
|
||||
public static partial class NetUtility
|
||||
{
|
||||
[CLSCompliant(false)]
|
||||
public static ulong GetPlatformSeed(int seedInc)
|
||||
{
|
||||
ulong seed = (ulong)Environment.TickCount + (ulong)seedInc;
|
||||
return seed ^ ((ulong)(new object().GetHashCode()) << 32);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the physical (MAC) address for the first usable network interface
|
||||
/// </summary>
|
||||
public static PhysicalAddress GetMacAddress()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static IPAddress GetBroadcastAddress()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets my local IPv4 address (not necessarily external) and subnet mask
|
||||
/// </summary>
|
||||
public static IPAddress GetMyAddress(out IPAddress mask)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static void Sleep(int milliseconds)
|
||||
{
|
||||
Task.Delay(50).Wait();
|
||||
}
|
||||
|
||||
public static NetAddress CreateAddressFromBytes(byte[] bytes)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static readonly SHA1CryptoServiceProvider s_sha = new SHA1CryptoServiceProvider();
|
||||
public static byte[] ComputeSHAHash(byte[] bytes, int offset, int count)
|
||||
{
|
||||
return s_sha.ComputeHash(bytes, offset, count);
|
||||
}
|
||||
}
|
||||
|
||||
public static partial class NetTime
|
||||
{
|
||||
private static readonly long s_timeInitialized = Environment.TickCount;
|
||||
|
||||
/// <summary>
|
||||
/// Get number of seconds since the application started
|
||||
/// </summary>
|
||||
public static double Now { get { return (double)((uint)Environment.TickCount - s_timeInitialized) / 1000.0; } }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -17,4 +17,7 @@
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
<PropertyGroup Condition="'$(FullRelease)' == 'True'">
|
||||
<DefineConstants>$(DefineConstants);FULL_RELEASE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,20 +1,27 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
|
||||
<Target Name="CopyResourcesFromShared">
|
||||
<ItemGroup>
|
||||
<_ResourceFiles Include="$(SolutionDir)bin\Shared\Resources\**\*.*" />
|
||||
</ItemGroup>
|
||||
<RemoveDir Directories="$(OutputPath)Resources" />
|
||||
<Copy SourceFiles="@(_ResourceFiles)" DestinationFolder="$(OutputPath)Resources\%(RecursiveDir)" />
|
||||
<PropertyGroup>
|
||||
<RobustToolsPath>$(MSBuildThisFileDirectory)/../Tools/</RobustToolsPath>
|
||||
</PropertyGroup>
|
||||
<Target Name="CopySwnfd">
|
||||
<CombinePath BasePath="$(RobustToolsPath)" Paths="download_swnfd.py">
|
||||
<Output TaskParameter="CombinedPaths" PropertyName="ScriptPath" />
|
||||
</CombinePath>
|
||||
<Exec Condition="'$(Platform)' == 'x64'" Command="$(Python) "$(ScriptPath)" $(Platform) $(TargetOS) $(OutputPath)" CustomErrorRegularExpression="^Error" />
|
||||
<Warning Condition="'$(Platform)' != 'x64'" Text="Did not download swnfd because the platform is not set to x64. Only use this build for unit testing!" />
|
||||
</Target>
|
||||
<Target Name="CopySS14Noise">
|
||||
<Exec Condition="'$(Platform)' == 'x64'" Command="$(Python) ../Tools/download_ss14_noise.py $(Platform) $(TargetOS) $(OutputPath)" CustomErrorRegularExpression="^Error" />
|
||||
<Warning Condition="'$(Platform)' != 'x64'" Text="Did not download ss14_noise because the platform is not set to x64. Only use this build for unit testing!" />
|
||||
<Target Name="CopyGlfw">
|
||||
<CombinePath BasePath="$(RobustToolsPath)" Paths="download_glfw.py">
|
||||
<Output TaskParameter="CombinedPaths" PropertyName="ScriptPath" />
|
||||
</CombinePath>
|
||||
<Exec Condition="'$(Platform)' == 'x64'" Command="$(Python) "$(ScriptPath)" $(Platform) $(TargetOS) $(OutputPath)" CustomErrorRegularExpression="^Error" />
|
||||
<Warning Condition="'$(Platform)' != 'x64'" Text="Did not download GLFW because the platform is not set to x64. Only use this build for unit testing!" />
|
||||
</Target>
|
||||
<Target Name="CopyMiscDependencies">
|
||||
<Exec Condition="'$(Platform)' == 'x64'" Command="$(Python) ../Tools/download_misc_dependencies.py $(Platform) $(TargetOS) $(OutputPath)" CustomErrorRegularExpression="^Error" />
|
||||
<CombinePath BasePath="$(RobustToolsPath)" Paths="download_misc_dependencies.py">
|
||||
<Output TaskParameter="CombinedPaths" PropertyName="ScriptPath" />
|
||||
</CombinePath>
|
||||
<Exec Condition="'$(Platform)' == 'x64'" Command="$(Python) "$(ScriptPath)" $(Platform) $(TargetOS) $(OutputPath)" CustomErrorRegularExpression="^Error" />
|
||||
<Warning Condition="'$(Platform)' != 'x64'" Text="Did not download misc dependencies because the platform is not set to x64. Only use this build for unit testing!" />
|
||||
</Target>
|
||||
<Target Name="DownloadGodotSharp">
|
||||
<Exec Command="$(Python) ../Tools/download_godotsharp.py" CustomErrorRegularExpression="^Error" />
|
||||
</Target>
|
||||
<Target Name="ClientAfterBuild" DependsOnTargets="CopyMiscDependencies;CopySwnfd;CopyGlfw" />
|
||||
</Project>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
|
||||
<Import Project="Robust.Custom.targets" Condition="Exists('Robust.Custom.targets')"/>
|
||||
<!-- MSBuild hurts and I can't find a foolproof way to detect platform. -->
|
||||
<PropertyGroup>
|
||||
<OS Condition="'$(OS)' == ''">Windows_NT</OS>
|
||||
@@ -25,5 +26,6 @@
|
||||
<TargetOS Condition="'$(TargetOS)' == ''">$(ActualOS)</TargetOS>
|
||||
<Python>python3</Python>
|
||||
<Python Condition="'$(ActualOS)' == 'Windows'">py -3</Python>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<!-- Common target to copy content assemblies to the parent projects. -->
|
||||
<Target Name="CopyContentAssemblies">
|
||||
<Copy SourceFiles="@(ContentAssemblies)" DestinationFolder="$(ContentAssemblyTarget)" />
|
||||
</Target>
|
||||
<ItemDefinitionGroup>
|
||||
<ContentAssemblies>
|
||||
<Visible>False</Visible>
|
||||
</ContentAssemblies>
|
||||
</ItemDefinitionGroup>
|
||||
</Project>
|
||||
18
OpenToolkit.GraphicsLibraryFramework/Cursor.cs
Normal file
18
OpenToolkit.GraphicsLibraryFramework/Cursor.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Cursor.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Opaque handle to a GLFW cursor.
|
||||
/// </summary>
|
||||
public struct Cursor
|
||||
{
|
||||
}
|
||||
}
|
||||
33
OpenToolkit.GraphicsLibraryFramework/Enums/ClientApi.cs
Normal file
33
OpenToolkit.GraphicsLibraryFramework/Enums/ClientApi.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// ClientApi.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// The context client APIs.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintClientApi,ClientApi)"/>
|
||||
public enum ClientApi
|
||||
{
|
||||
/// <summary>
|
||||
/// No context API is created.
|
||||
/// </summary>
|
||||
NoApi = 0,
|
||||
|
||||
/// <summary>
|
||||
/// OpenGL context is created.
|
||||
/// </summary>
|
||||
OpenGlApi = 0x00030001,
|
||||
|
||||
/// <summary>
|
||||
/// OpenGL ES context is created.
|
||||
/// </summary>
|
||||
OpenGlEsApi = 0x00030002
|
||||
}
|
||||
}
|
||||
27
OpenToolkit.GraphicsLibraryFramework/Enums/ConnectedState.cs
Normal file
27
OpenToolkit.GraphicsLibraryFramework/Enums/ConnectedState.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// ConnectedState.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies connected state of devices.
|
||||
/// </summary>
|
||||
public enum ConnectedState
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that a device is connected.
|
||||
/// </summary>
|
||||
Connected = 0x00040001,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that a device is disconnected.
|
||||
/// </summary>
|
||||
Disconnected = 0x00040002
|
||||
}
|
||||
}
|
||||
27
OpenToolkit.GraphicsLibraryFramework/Enums/ContextApi.cs
Normal file
27
OpenToolkit.GraphicsLibraryFramework/Enums/ContextApi.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// ContextApi.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// The context API used to create the window context.
|
||||
/// </summary>
|
||||
public enum ContextApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Uses the native context API to create the window context.
|
||||
/// </summary>
|
||||
NativeContextApi = 0x00036001,
|
||||
|
||||
/// <summary>
|
||||
/// Uses Egl to create the window context.
|
||||
/// </summary>
|
||||
EglContextApi = 0x00036002
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// CursorModeValue.cs
|
||||
//
|
||||
// Copyright (C) 2018 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// The GLFW cursor modes.
|
||||
/// See <a href="https://www.glfw.org/docs/latest/input_guide.html#cursor_mode">cursor modes</a>.
|
||||
/// </summary>
|
||||
public enum CursorModeValue
|
||||
{
|
||||
/// <summary>
|
||||
/// The regular arrow cursor (or another cursor set with <see cref="GLFW.SetCursor"/>) is used
|
||||
/// and cursor motion is not limited.
|
||||
/// </summary>
|
||||
CursorNormal = 0x00034001,
|
||||
|
||||
/// <summary>
|
||||
/// Hides the arrow cursor when over a window.
|
||||
/// </summary>
|
||||
CursorHidden = 0x00034002,
|
||||
|
||||
/// <summary>
|
||||
/// Will hide the cursor and lock it to the specified window.
|
||||
/// GLFW will then take care of all the details of cursor re-centering and offset calculation
|
||||
/// and providing the application with a virtual cursor position.
|
||||
/// This virtual position is provided normally via both the cursor position callback and through polling.
|
||||
/// </summary>
|
||||
CursorDisabled = 0x00034003
|
||||
}
|
||||
}
|
||||
47
OpenToolkit.GraphicsLibraryFramework/Enums/CursorShape.cs
Normal file
47
OpenToolkit.GraphicsLibraryFramework/Enums/CursorShape.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// CursorShape.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Standard cursor shapes.
|
||||
/// </summary>
|
||||
public enum CursorShape
|
||||
{
|
||||
/// <summary>
|
||||
/// The standard arrow shape. Used in almost all situations.
|
||||
/// </summary>
|
||||
Arrow = 0x00036001,
|
||||
|
||||
/// <summary>
|
||||
/// The I-Beam shape. Used when mousing over a place where text can be entered.
|
||||
/// </summary>
|
||||
IBeam = 0x00036002,
|
||||
|
||||
/// <summary>
|
||||
/// The crosshair shape. Used when dragging and dropping.
|
||||
/// </summary>
|
||||
Crosshair = 0x00036003,
|
||||
|
||||
/// <summary>
|
||||
/// The hand shape. Used when mousing over something that can be dragged around.
|
||||
/// </summary>
|
||||
Hand = 0x00036004,
|
||||
|
||||
/// <summary>
|
||||
/// The horizontal resize shape. Used when mousing over something that can be horizontally resized.
|
||||
/// </summary>
|
||||
HResize = 0x00036005,
|
||||
|
||||
/// <summary>
|
||||
/// The vertical resize shape. Used when mousing over something that can be vertically resized.
|
||||
/// </summary>
|
||||
VResize = 0x00036006
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// CursorStateAttribute.cs
|
||||
//
|
||||
// Copyright (C) 2018 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute for setting <see cref="CursorModeValue"/> of the cursor.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.SetInputMode(Window*,CursorStateAttribute,CursorModeValue)"/>
|
||||
/// <seealso cref="GLFW.GetInputMode(Window*,CursorStateAttribute)"/>
|
||||
public enum CursorStateAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute for setting <see cref="CursorModeValue"/> of the cursor.
|
||||
/// </summary>
|
||||
Cursor = 0x00033001,
|
||||
}
|
||||
}
|
||||
103
OpenToolkit.GraphicsLibraryFramework/Enums/ErrorCode.cs
Normal file
103
OpenToolkit.GraphicsLibraryFramework/Enums/ErrorCode.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// ErrorCode.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Error codes, used in the error callback.
|
||||
/// </summary>
|
||||
public enum ErrorCode
|
||||
{
|
||||
/// <summary>
|
||||
/// Everything is running as intended. Yay!
|
||||
/// </summary>
|
||||
NoError = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Called a function before calling <see cref="GLFW.Init"/>. Initialize GLFW and then try again.
|
||||
/// </summary>
|
||||
NotInitialized = 0x00010001,
|
||||
|
||||
/// <summary>
|
||||
/// No OpenGL/OpenGL ES context on this thread.
|
||||
/// </summary>
|
||||
NoContext = 0x00010002,
|
||||
|
||||
/// <summary>
|
||||
/// Used an invalid enum value on a function.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This should hopefully never happen in the bindings, due to the added type safety of C# enums VS. GLFW's native #defines
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
InvalidEnum = 0x00010003,
|
||||
|
||||
/// <summary>
|
||||
/// Called a function with an invalid argument.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This can happen if you request an OpenGL version that doesn't exist, like 2.7.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// If you request a version of OpenGL that exists, but isn't supported by this graphics card, it will return VersionUnavailable instead.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
InvalidValue = 0x00010004,
|
||||
|
||||
/// <summary>
|
||||
/// A memory allocation failed on GLFW's end.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Report this to the GLFW issue tracker if encountered.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
OutOfMemory = 0x00010005,
|
||||
|
||||
/// <summary>
|
||||
/// The requested API is not available on the system.
|
||||
/// </summary>
|
||||
ApiUnavailable = 0x00010006,
|
||||
|
||||
/// <summary>
|
||||
/// The requested OpenGL version is not available on the system.
|
||||
/// </summary>
|
||||
VersionUnavailable = 0x00010007,
|
||||
|
||||
/// <summary>
|
||||
/// A platform-specific error occurred that doesn't fit into any more specific category.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Report this to the GLFW issue tracker if encountered.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
PlatformError = 0x00010008,
|
||||
|
||||
/// <summary>
|
||||
/// The requested format is unavailable.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// If emitted during window creation, the requested pixel format isn't available.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// If emitted when using the clipboard, the contents of the clipboard couldn't be converted to the requested format.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
FormatUnavailable = 0x00010009,
|
||||
|
||||
/// <summary>
|
||||
/// There is no OpenGL/OpenGL ES context attached to this window.
|
||||
/// </summary>
|
||||
NoWindowContext = 0x0001000A
|
||||
}
|
||||
}
|
||||
46
OpenToolkit.GraphicsLibraryFramework/Enums/InitHintBool.cs
Normal file
46
OpenToolkit.GraphicsLibraryFramework/Enums/InitHintBool.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// InitHint.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialization hints are set before <see cref="GLFW.Init"/> and affect how the library behaves until termination.
|
||||
/// Hints are set with <see cref="GLFW.InitHint(InitHintBool, bool)"/>.
|
||||
/// </summary>
|
||||
public enum InitHintBool
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to specify whether to also expose joystick hats as buttons,
|
||||
/// for compatibility with earlier versions of GLFW that did not have
|
||||
/// <see cref="GLFW.GetJoystickHats"/>.
|
||||
/// Set this with <see cref="GLFW.InitHint(InitHintBool, bool)"/>.
|
||||
/// </summary>
|
||||
JoystickHatButtons = 0x00050001,
|
||||
|
||||
/// <summary>
|
||||
/// Used to specify whether to set the current directory to the application to the Contents/Resources
|
||||
/// subdirectory of the application's bundle, if present.
|
||||
/// Set this with <see cref="GLFW.InitHint(InitHintBool, bool)"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only affects macOS; no effect on other platforms.
|
||||
/// </remarks>
|
||||
CocoaChdirResources = 0x00051001,
|
||||
|
||||
/// <summary>
|
||||
/// Used to specify whether to create a basic menu bar, either from a nib or manually,
|
||||
/// when the first window is created, which is when AppKit is initialized.
|
||||
/// Set this with <see cref="GLFW.InitHint(InitHintBool, bool)"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only affects macOS; no effect on other platforms.
|
||||
/// </remarks>
|
||||
CocoaMenubar = 0x00051002
|
||||
}
|
||||
}
|
||||
15
OpenToolkit.GraphicsLibraryFramework/Enums/InitHintInt.cs
Normal file
15
OpenToolkit.GraphicsLibraryFramework/Enums/InitHintInt.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialization hints are set before <see cref="GLFW.Init"/> and affect how the library behaves until termination.
|
||||
/// Hints are set with <see cref="GLFW.InitHint(InitHintInt, int)"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// While this enum has no members,
|
||||
/// it can still be useful because it allows you to access the direct <c>glfwInitHint(int, int)</c> API.
|
||||
/// In case a future version of GLFW adds an int-taking int hint and we don't handle it.
|
||||
/// </remarks>
|
||||
public enum InitHintInt
|
||||
{
|
||||
}
|
||||
}
|
||||
33
OpenToolkit.GraphicsLibraryFramework/Enums/InputAction.cs
Normal file
33
OpenToolkit.GraphicsLibraryFramework/Enums/InputAction.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// InputAction.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines event information for <see cref="GLFWCallbacks.KeyCallback"/>
|
||||
/// or <see cref="GLFWCallbacks.MouseButtonCallback"/>.
|
||||
/// </summary>
|
||||
public enum InputAction
|
||||
{
|
||||
/// <summary>
|
||||
/// The key or mouse button was released.
|
||||
/// </summary>
|
||||
Release = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The key or mouse button was pressed.
|
||||
/// </summary>
|
||||
Press = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The key was held down until it repeated.
|
||||
/// </summary>
|
||||
Repeat = 2
|
||||
}
|
||||
}
|
||||
53
OpenToolkit.GraphicsLibraryFramework/Enums/JoystickHats.cs
Normal file
53
OpenToolkit.GraphicsLibraryFramework/Enums/JoystickHats.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Status of a joystick hat.
|
||||
/// </summary>
|
||||
public enum JoystickHats : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Hat is centered.
|
||||
/// </summary>
|
||||
Centered = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Hat is pointing up.
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Hat is pointing right.
|
||||
/// </summary>
|
||||
Right = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Hat is pointing down.
|
||||
/// </summary>
|
||||
Down = 4,
|
||||
|
||||
/// <summary>
|
||||
/// Hat is pointing left.
|
||||
/// </summary>
|
||||
Left = 8,
|
||||
|
||||
/// <summary>
|
||||
/// Hat is pointing up and to the right.
|
||||
/// </summary>
|
||||
RightUp = Right | Up,
|
||||
|
||||
/// <summary>
|
||||
/// Hat is pointing down and to the right.
|
||||
/// </summary>
|
||||
RightDown = Right | Down,
|
||||
|
||||
/// <summary>
|
||||
/// Hat is pointing up and to the left.
|
||||
/// </summary>
|
||||
LeftUp = Left | Up,
|
||||
|
||||
/// <summary>
|
||||
/// Hat is pointing down and to the left.
|
||||
/// </summary>
|
||||
LeftDown = Left | Down,
|
||||
}
|
||||
}
|
||||
50
OpenToolkit.GraphicsLibraryFramework/Enums/KeyModifiers.cs
Normal file
50
OpenToolkit.GraphicsLibraryFramework/Enums/KeyModifiers.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// KeyModifiers.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Key modifiers, such as Shift or CTRL.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum KeyModifiers
|
||||
{
|
||||
/// <summary>
|
||||
/// if one or more Shift keys were held down.
|
||||
/// </summary>
|
||||
Shift = 0x0001,
|
||||
|
||||
/// <summary>
|
||||
/// If one or more Control keys were held down.
|
||||
/// </summary>
|
||||
Control = 0x0002,
|
||||
|
||||
/// <summary>
|
||||
/// If one or more Alt keys were held down.
|
||||
/// </summary>
|
||||
Alt = 0x0004,
|
||||
|
||||
/// <summary>
|
||||
/// If one or more Super keys were held down.
|
||||
/// </summary>
|
||||
Super = 0x0008,
|
||||
|
||||
/// <summary>
|
||||
/// If caps lock is enabled.
|
||||
/// </summary>
|
||||
CapsLock = 0x0010,
|
||||
|
||||
/// <summary>
|
||||
/// If num lock is enabled.
|
||||
/// </summary>
|
||||
NumLock = 0x0020,
|
||||
}
|
||||
}
|
||||
627
OpenToolkit.GraphicsLibraryFramework/Enums/Keys.cs
Normal file
627
OpenToolkit.GraphicsLibraryFramework/Enums/Keys.cs
Normal file
@@ -0,0 +1,627 @@
|
||||
//
|
||||
// Keys.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies key codes and modifiers in US keyboard layout.
|
||||
/// </summary>
|
||||
public enum Keys
|
||||
{
|
||||
/// <summary>
|
||||
/// An unknown key.
|
||||
/// </summary>
|
||||
Unknown = -1,
|
||||
|
||||
/// <summary>
|
||||
/// The spacebar key.
|
||||
/// </summary>
|
||||
Space = 32,
|
||||
|
||||
/// <summary>
|
||||
/// The apostrophe key.
|
||||
/// </summary>
|
||||
Apostrophe = 39 /* ' */,
|
||||
|
||||
/// <summary>
|
||||
/// The comma key.
|
||||
/// </summary>
|
||||
Comma = 44 /* , */,
|
||||
|
||||
/// <summary>
|
||||
/// The minus key.
|
||||
/// </summary>
|
||||
Minus = 45 /* - */,
|
||||
|
||||
/// <summary>
|
||||
/// The period key.
|
||||
/// </summary>
|
||||
Period = 46 /* . */,
|
||||
|
||||
/// <summary>
|
||||
/// The slash key.
|
||||
/// </summary>
|
||||
Slash = 47 /* / */,
|
||||
|
||||
/// <summary>
|
||||
/// The 0 key.
|
||||
/// </summary>
|
||||
D0 = 48,
|
||||
|
||||
/// <summary>
|
||||
/// The 1 key.
|
||||
/// </summary>
|
||||
D1 = 49,
|
||||
|
||||
/// <summary>
|
||||
/// The 2 key.
|
||||
/// </summary>
|
||||
D2 = 50,
|
||||
|
||||
/// <summary>
|
||||
/// The 3 key.
|
||||
/// </summary>
|
||||
D3 = 51,
|
||||
|
||||
/// <summary>
|
||||
/// The 4 key.
|
||||
/// </summary>
|
||||
D4 = 52,
|
||||
|
||||
/// <summary>
|
||||
/// The 5 key.
|
||||
/// </summary>
|
||||
D5 = 53,
|
||||
|
||||
/// <summary>
|
||||
/// The 6 key.
|
||||
/// </summary>
|
||||
D6 = 54,
|
||||
|
||||
/// <summary>
|
||||
/// The 7 key.
|
||||
/// </summary>
|
||||
D7 = 55,
|
||||
|
||||
/// <summary>
|
||||
/// The 8 key.
|
||||
/// </summary>
|
||||
D8 = 56,
|
||||
|
||||
/// <summary>
|
||||
/// The 9 key.
|
||||
/// </summary>
|
||||
D9 = 57,
|
||||
|
||||
/// <summary>
|
||||
/// The semicolon key.
|
||||
/// </summary>
|
||||
Semicolon = 59 /* ; */,
|
||||
|
||||
/// <summary>
|
||||
/// The equal key.
|
||||
/// </summary>
|
||||
Equal = 61 /* = */,
|
||||
|
||||
/// <summary>
|
||||
/// The A key.
|
||||
/// </summary>
|
||||
A = 65,
|
||||
|
||||
/// <summary>
|
||||
/// The B key.
|
||||
/// </summary>
|
||||
B = 66,
|
||||
|
||||
/// <summary>
|
||||
/// The C key.
|
||||
/// </summary>
|
||||
C = 67,
|
||||
|
||||
/// <summary>
|
||||
/// The D key.
|
||||
/// </summary>
|
||||
D = 68,
|
||||
|
||||
/// <summary>
|
||||
/// The E key.
|
||||
/// </summary>
|
||||
E = 69,
|
||||
|
||||
/// <summary>
|
||||
/// The F key.
|
||||
/// </summary>
|
||||
F = 70,
|
||||
|
||||
/// <summary>
|
||||
/// The G key.
|
||||
/// </summary>
|
||||
G = 71,
|
||||
|
||||
/// <summary>
|
||||
/// The H key.
|
||||
/// </summary>
|
||||
H = 72,
|
||||
|
||||
/// <summary>
|
||||
/// The I key.
|
||||
/// </summary>
|
||||
I = 73,
|
||||
|
||||
/// <summary>
|
||||
/// The J key.
|
||||
/// </summary>
|
||||
J = 74,
|
||||
|
||||
/// <summary>
|
||||
/// The K key.
|
||||
/// </summary>
|
||||
K = 75,
|
||||
|
||||
/// <summary>
|
||||
/// The L key.
|
||||
/// </summary>
|
||||
L = 76,
|
||||
|
||||
/// <summary>
|
||||
/// The M key.
|
||||
/// </summary>
|
||||
M = 77,
|
||||
|
||||
/// <summary>
|
||||
/// The N key.
|
||||
/// </summary>
|
||||
N = 78,
|
||||
|
||||
/// <summary>
|
||||
/// The O key.
|
||||
/// </summary>
|
||||
O = 79,
|
||||
|
||||
/// <summary>
|
||||
/// The P key.
|
||||
/// </summary>
|
||||
P = 80,
|
||||
|
||||
/// <summary>
|
||||
/// The Q key.
|
||||
/// </summary>
|
||||
Q = 81,
|
||||
|
||||
/// <summary>
|
||||
/// The R key.
|
||||
/// </summary>
|
||||
R = 82,
|
||||
|
||||
/// <summary>
|
||||
/// The S key.
|
||||
/// </summary>
|
||||
S = 83,
|
||||
|
||||
/// <summary>
|
||||
/// The T key.
|
||||
/// </summary>
|
||||
T = 84,
|
||||
|
||||
/// <summary>
|
||||
/// The U key.
|
||||
/// </summary>
|
||||
U = 85,
|
||||
|
||||
/// <summary>
|
||||
/// The V key.
|
||||
/// </summary>
|
||||
V = 86,
|
||||
|
||||
/// <summary>
|
||||
/// The W key.
|
||||
/// </summary>
|
||||
W = 87,
|
||||
|
||||
/// <summary>
|
||||
/// The X key.
|
||||
/// </summary>
|
||||
X = 88,
|
||||
|
||||
/// <summary>
|
||||
/// The Y key.
|
||||
/// </summary>
|
||||
Y = 89,
|
||||
|
||||
/// <summary>
|
||||
/// The Z key.
|
||||
/// </summary>
|
||||
Z = 90,
|
||||
|
||||
/// <summary>
|
||||
/// The left bracket(opening bracket) key.
|
||||
/// </summary>
|
||||
LeftBracket = 91 /* [ */,
|
||||
|
||||
/// <summary>
|
||||
/// The backslash.
|
||||
/// </summary>
|
||||
Backslash = 92 /* \ */,
|
||||
|
||||
/// <summary>
|
||||
/// The right bracket(closing bracket) key.
|
||||
/// </summary>
|
||||
RightBracket = 93 /* ] */,
|
||||
|
||||
/// <summary>
|
||||
/// The grave accent key.
|
||||
/// </summary>
|
||||
GraveAccent = 96 /* ` */,
|
||||
|
||||
/// <summary>
|
||||
/// Non US keyboard layout key 1.
|
||||
/// </summary>
|
||||
World1 = 161 /* non-US #1 */,
|
||||
|
||||
/// <summary>
|
||||
/// Non US keyboard layout key 2.
|
||||
/// </summary>
|
||||
World2 = 162 /* non-US #2 */,
|
||||
|
||||
/// <summary>
|
||||
/// The escape key.
|
||||
/// </summary>
|
||||
Escape = 256,
|
||||
|
||||
/// <summary>
|
||||
/// The enter key.
|
||||
/// </summary>
|
||||
Enter = 257,
|
||||
|
||||
/// <summary>
|
||||
/// The tab key.
|
||||
/// </summary>
|
||||
Tab = 258,
|
||||
|
||||
/// <summary>
|
||||
/// The backspace key.
|
||||
/// </summary>
|
||||
Backspace = 259,
|
||||
|
||||
/// <summary>
|
||||
/// The insert key.
|
||||
/// </summary>
|
||||
Insert = 260,
|
||||
|
||||
/// <summary>
|
||||
/// The delete key.
|
||||
/// </summary>
|
||||
Delete = 261,
|
||||
|
||||
/// <summary>
|
||||
/// The right arrow key.
|
||||
/// </summary>
|
||||
Right = 262,
|
||||
|
||||
/// <summary>
|
||||
/// The left arrow key.
|
||||
/// </summary>
|
||||
Left = 263,
|
||||
|
||||
/// <summary>
|
||||
/// The down arrow key.
|
||||
/// </summary>
|
||||
Down = 264,
|
||||
|
||||
/// <summary>
|
||||
/// The up arrow key.
|
||||
/// </summary>
|
||||
Up = 265,
|
||||
|
||||
/// <summary>
|
||||
/// The page up key.
|
||||
/// </summary>
|
||||
PageUp = 266,
|
||||
|
||||
/// <summary>
|
||||
/// The page down key.
|
||||
/// </summary>
|
||||
PageDown = 267,
|
||||
|
||||
/// <summary>
|
||||
/// The home key.
|
||||
/// </summary>
|
||||
Home = 268,
|
||||
|
||||
/// <summary>
|
||||
/// The end key.
|
||||
/// </summary>
|
||||
End = 269,
|
||||
|
||||
/// <summary>
|
||||
/// The caps lock key.
|
||||
/// </summary>
|
||||
CapsLock = 280,
|
||||
|
||||
/// <summary>
|
||||
/// The scroll lock key.
|
||||
/// </summary>
|
||||
ScrollLock = 281,
|
||||
|
||||
/// <summary>
|
||||
/// The num lock key.
|
||||
/// </summary>
|
||||
NumLock = 282,
|
||||
|
||||
/// <summary>
|
||||
/// The print screen key.
|
||||
/// </summary>
|
||||
PrintScreen = 283,
|
||||
|
||||
/// <summary>
|
||||
/// The pause key.
|
||||
/// </summary>
|
||||
Pause = 284,
|
||||
|
||||
/// <summary>
|
||||
/// The F1 key.
|
||||
/// </summary>
|
||||
F1 = 290,
|
||||
|
||||
/// <summary>
|
||||
/// The F2 key.
|
||||
/// </summary>
|
||||
F2 = 291,
|
||||
|
||||
/// <summary>
|
||||
/// The F3 key.
|
||||
/// </summary>
|
||||
F3 = 292,
|
||||
|
||||
/// <summary>
|
||||
/// The F4 key.
|
||||
/// </summary>
|
||||
F4 = 293,
|
||||
|
||||
/// <summary>
|
||||
/// The F5 key.
|
||||
/// </summary>
|
||||
F5 = 294,
|
||||
|
||||
/// <summary>
|
||||
/// The F6 key.
|
||||
/// </summary>
|
||||
F6 = 295,
|
||||
|
||||
/// <summary>
|
||||
/// The F7 key.
|
||||
/// </summary>
|
||||
F7 = 296,
|
||||
|
||||
/// <summary>
|
||||
/// The F8 key.
|
||||
/// </summary>
|
||||
F8 = 297,
|
||||
|
||||
/// <summary>
|
||||
/// The F9 key.
|
||||
/// </summary>
|
||||
F9 = 298,
|
||||
|
||||
/// <summary>
|
||||
/// The F10 key.
|
||||
/// </summary>
|
||||
F10 = 299,
|
||||
|
||||
/// <summary>
|
||||
/// The F11 key.
|
||||
/// </summary>
|
||||
F11 = 300,
|
||||
|
||||
/// <summary>
|
||||
/// The F12 key.
|
||||
/// </summary>
|
||||
F12 = 301,
|
||||
|
||||
/// <summary>
|
||||
/// The F13 key.
|
||||
/// </summary>
|
||||
F13 = 302,
|
||||
|
||||
/// <summary>
|
||||
/// The F14 key.
|
||||
/// </summary>
|
||||
F14 = 303,
|
||||
|
||||
/// <summary>
|
||||
/// The F15 key.
|
||||
/// </summary>
|
||||
F15 = 304,
|
||||
|
||||
/// <summary>
|
||||
/// The F16 key.
|
||||
/// </summary>
|
||||
F16 = 305,
|
||||
|
||||
/// <summary>
|
||||
/// The F17 key.
|
||||
/// </summary>
|
||||
F17 = 306,
|
||||
|
||||
/// <summary>
|
||||
/// The F18 key.
|
||||
/// </summary>
|
||||
F18 = 307,
|
||||
|
||||
/// <summary>
|
||||
/// The F19 key.
|
||||
/// </summary>
|
||||
F19 = 308,
|
||||
|
||||
/// <summary>
|
||||
/// The F20 key.
|
||||
/// </summary>
|
||||
F20 = 309,
|
||||
|
||||
/// <summary>
|
||||
/// The F21 key.
|
||||
/// </summary>
|
||||
F21 = 310,
|
||||
|
||||
/// <summary>
|
||||
/// The F22 key.
|
||||
/// </summary>
|
||||
F22 = 311,
|
||||
|
||||
/// <summary>
|
||||
/// The F23 key.
|
||||
/// </summary>
|
||||
F23 = 312,
|
||||
|
||||
/// <summary>
|
||||
/// The F24 key.
|
||||
/// </summary>
|
||||
F24 = 313,
|
||||
|
||||
/// <summary>
|
||||
/// The F25 key.
|
||||
/// </summary>
|
||||
F25 = 314,
|
||||
|
||||
/// <summary>
|
||||
/// The 0 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad0 = 320,
|
||||
|
||||
/// <summary>
|
||||
/// The 1 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad1 = 321,
|
||||
|
||||
/// <summary>
|
||||
/// The 2 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad2 = 322,
|
||||
|
||||
/// <summary>
|
||||
/// The 3 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad3 = 323,
|
||||
|
||||
/// <summary>
|
||||
/// The 4 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad4 = 324,
|
||||
|
||||
/// <summary>
|
||||
/// The 5 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad5 = 325,
|
||||
|
||||
/// <summary>
|
||||
/// The 6 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad6 = 326,
|
||||
|
||||
/// <summary>
|
||||
/// The 7 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad7 = 327,
|
||||
|
||||
/// <summary>
|
||||
/// The 8 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad8 = 328,
|
||||
|
||||
/// <summary>
|
||||
/// The 9 key on the key pad.
|
||||
/// </summary>
|
||||
KeyPad9 = 329,
|
||||
|
||||
/// <summary>
|
||||
/// The decimal key on the key pad.
|
||||
/// </summary>
|
||||
KeyPadDecimal = 330,
|
||||
|
||||
/// <summary>
|
||||
/// The divide key on the key pad.
|
||||
/// </summary>
|
||||
KeyPadDivide = 331,
|
||||
|
||||
/// <summary>
|
||||
/// The multiply key on the key pad.
|
||||
/// </summary>
|
||||
KeyPadMultiply = 332,
|
||||
|
||||
/// <summary>
|
||||
/// The subtract key on the key pad.
|
||||
/// </summary>
|
||||
KeyPadSubtract = 333,
|
||||
|
||||
/// <summary>
|
||||
/// The add key on the key pad.
|
||||
/// </summary>
|
||||
KeyPadAdd = 334,
|
||||
|
||||
/// <summary>
|
||||
/// The enter key on the key pad.
|
||||
/// </summary>
|
||||
KeyPadEnter = 335,
|
||||
|
||||
/// <summary>
|
||||
/// The equal key on the key pad.
|
||||
/// </summary>
|
||||
KeyPadEqual = 336,
|
||||
|
||||
/// <summary>
|
||||
/// The left shift key.
|
||||
/// </summary>
|
||||
LeftShift = 340,
|
||||
|
||||
/// <summary>
|
||||
/// The left control key.
|
||||
/// </summary>
|
||||
LeftControl = 341,
|
||||
|
||||
/// <summary>
|
||||
/// The left alt key.
|
||||
/// </summary>
|
||||
LeftAlt = 342,
|
||||
|
||||
/// <summary>
|
||||
/// The left super key.
|
||||
/// </summary>
|
||||
LeftSuper = 343,
|
||||
|
||||
/// <summary>
|
||||
/// The right shift key.
|
||||
/// </summary>
|
||||
RightShift = 344,
|
||||
|
||||
/// <summary>
|
||||
/// The right control key.
|
||||
/// </summary>
|
||||
RightControl = 345,
|
||||
|
||||
/// <summary>
|
||||
/// The right alt key.
|
||||
/// </summary>
|
||||
RightAlt = 346,
|
||||
|
||||
/// <summary>
|
||||
/// The right super key.
|
||||
/// </summary>
|
||||
RightSuper = 347,
|
||||
|
||||
/// <summary>
|
||||
/// The menu key.
|
||||
/// </summary>
|
||||
Menu = 348,
|
||||
|
||||
/// <summary>
|
||||
/// The last valid key in this enum.
|
||||
/// </summary>
|
||||
LastKey = Menu
|
||||
}
|
||||
}
|
||||
68
OpenToolkit.GraphicsLibraryFramework/Enums/MouseButton.cs
Normal file
68
OpenToolkit.GraphicsLibraryFramework/Enums/MouseButton.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the buttons of a mouse.
|
||||
/// </summary>
|
||||
public enum MouseButton
|
||||
{
|
||||
/// <summary>
|
||||
/// The first button.
|
||||
/// </summary>
|
||||
Button1 = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The second button.
|
||||
/// </summary>
|
||||
Button2 = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The third button.
|
||||
/// </summary>
|
||||
Button3 = 2,
|
||||
|
||||
/// <summary>
|
||||
/// The fourth button.
|
||||
/// </summary>
|
||||
Button4 = 3,
|
||||
|
||||
/// <summary>
|
||||
/// The fifth button.
|
||||
/// </summary>
|
||||
Button5 = 4,
|
||||
|
||||
/// <summary>
|
||||
/// The sixth button.
|
||||
/// </summary>
|
||||
Button6 = 5,
|
||||
|
||||
/// <summary>
|
||||
/// The seventh button.
|
||||
/// </summary>
|
||||
Button7 = 6,
|
||||
|
||||
/// <summary>
|
||||
/// The eighth button.
|
||||
/// </summary>
|
||||
Button8 = 7,
|
||||
|
||||
/// <summary>
|
||||
/// The left mouse button. This corresponds to <see cref="Button1"/>.
|
||||
/// </summary>
|
||||
Left = Button1,
|
||||
|
||||
/// <summary>
|
||||
/// The right mouse button. This corresponds to <see cref="Button2"/>.
|
||||
/// </summary>
|
||||
Right = Button2,
|
||||
|
||||
/// <summary>
|
||||
/// The middle mouse button. This corresponds to <see cref="Button3"/>.
|
||||
/// </summary>
|
||||
Middle = Button3,
|
||||
|
||||
/// <summary>
|
||||
/// The highest mouse button available.
|
||||
/// </summary>
|
||||
Last = Button8,
|
||||
}
|
||||
}
|
||||
32
OpenToolkit.GraphicsLibraryFramework/Enums/OpenGlProfile.cs
Normal file
32
OpenToolkit.GraphicsLibraryFramework/Enums/OpenGlProfile.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// OpenGlProfile.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// The OpenGL context profiles.
|
||||
/// </summary>
|
||||
public enum OpenGlProfile
|
||||
{
|
||||
/// <summary>
|
||||
/// Used for unknown OpenGL profile or OpenGL ES.
|
||||
/// </summary>
|
||||
Any = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Known OpenGL Core profile.
|
||||
/// </summary>
|
||||
Core = 0x00032001,
|
||||
|
||||
/// <summary>
|
||||
/// Known OpenGL compatibility profile.
|
||||
/// </summary>
|
||||
Compat = 0x00032002
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// ReleaseBehavior.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// The context release behaviors.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintReleaseBehavior,ReleaseBehavior)"/>
|
||||
public enum ReleaseBehavior
|
||||
{
|
||||
/// <summary>
|
||||
/// Use the default release behavior of the platform.
|
||||
/// </summary>
|
||||
Any = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The pipeline will be flushed whenever the context is released from being the current one.
|
||||
/// </summary>
|
||||
Flush = 0x00035001,
|
||||
|
||||
/// <summary>
|
||||
/// The pipeline will not be flushed on release.
|
||||
/// </summary>
|
||||
None = 0x00035002
|
||||
}
|
||||
}
|
||||
32
OpenToolkit.GraphicsLibraryFramework/Enums/Robustness.cs
Normal file
32
OpenToolkit.GraphicsLibraryFramework/Enums/Robustness.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Robustness.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// OpenGL context robustness strategy.
|
||||
/// </summary>
|
||||
public enum Robustness
|
||||
{
|
||||
/// <summary>
|
||||
/// No context robustness strategy.
|
||||
/// </summary>
|
||||
NoRobustness = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Robust context without a reset notification.
|
||||
/// </summary>
|
||||
NoResetNotification = 0x00031001,
|
||||
|
||||
/// <summary>
|
||||
/// Lose context on reset.
|
||||
/// </summary>
|
||||
LoseContextOnReset = 0x00031002
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// StickyAttributes.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Attributes related to sticky keys and buttons.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.SetInputMode(Window*,StickyAttributes,bool)"/>
|
||||
/// <seealso cref="GLFW.GetInputMode(Window*,StickyAttributes)"/>
|
||||
public enum StickyAttributes
|
||||
{
|
||||
/// <summary>
|
||||
/// Specify whether keyboard input should be sticky or not.
|
||||
/// </summary>
|
||||
StickyKeys = 0x00033002,
|
||||
|
||||
/// <summary>
|
||||
/// Specify whether mouse button input should be sticky or not.
|
||||
/// </summary>
|
||||
StickyMouseButtons = 0x00033003
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
//
|
||||
// WindowAttributeSetter.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to get window related attributes.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.GetWindowAttrib"/>
|
||||
public enum WindowAttributeGetter
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window has input focus.
|
||||
/// Initial input focus is controlled by the window hint with the same name
|
||||
/// </summary>
|
||||
Focused = WindowHintBool.Focused,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is iconified,
|
||||
/// whether by the user or with <see cref="GLFW.IconifyWindow"/>.
|
||||
/// </summary>
|
||||
Iconified = WindowHintBool.Iconified,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is resizable by the user.
|
||||
/// This is set on creation with the window hint with the same name.
|
||||
/// </summary>
|
||||
Resizable = WindowHintBool.Resizable,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is visible.
|
||||
/// Window visibility can be controlled with <see cref="GLFW.ShowWindow"/> and <see cref="GLFW.HideWindow"/>
|
||||
/// and initial visibility is controlled by the window hint with the same name.
|
||||
/// </summary>
|
||||
Visible = WindowHintBool.Visible,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window has decorations such as a border,a close widget, etc.
|
||||
/// This is set on creation with the window hint with the same name.
|
||||
/// </summary>
|
||||
Decorated = WindowHintBool.Decorated,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the full screen window will automatically iconify and restore
|
||||
/// the previous video mode on input focus loss.
|
||||
/// Possible values are <c>true</c> and <c>false</c>. This hint is ignored for windowed mode windows.
|
||||
/// </summary>
|
||||
AutoIconify = WindowHintBool.AutoIconify,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is floating, also called topmost or always-on-top.
|
||||
/// This is controlled by the window hint with the same name.
|
||||
/// </summary>
|
||||
Floating = WindowHintBool.Floating,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is maximized,
|
||||
/// whether by the user or with <see cref="GLFW.MaximizeWindow"/>.
|
||||
/// </summary>
|
||||
Maximized = WindowHintBool.Maximized,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the cursor should be centered over newly created full screen windows.
|
||||
/// Possible values are <c>true</c> and <c>false</c>. This hint is ignored for windowed mode windows.
|
||||
/// </summary>
|
||||
CenterCursor = WindowHintBool.CenterCursor,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the window framebuffer will be transparent.
|
||||
/// If enabled and supported by the system, the window framebuffer alpha channel will be used
|
||||
/// to combine the framebuffer with the background.
|
||||
/// This does not affect window decorations. Possible values are <c>true</c> and <c>false</c>.
|
||||
/// </summary>
|
||||
TransparentFramebuffer = WindowHintBool.TransparentFramebuffer,
|
||||
|
||||
/// <summary>
|
||||
/// indicates whether the cursor is currently directly over the client area of the window,
|
||||
/// with no other windows between.
|
||||
/// See <a href="https://www.glfw.org/docs/3.3/input_guide.html#cursor_enter">Cursor enter/leave events</a>
|
||||
/// for details.
|
||||
/// </summary>
|
||||
Hovered = WindowHintBool.Hovered,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the window will be given input focus when <see cref="GLFW.ShowWindow"/> is called.
|
||||
/// Possible values are <c>true</c> and <c>false</c>.
|
||||
/// </summary>
|
||||
FocusOnShow = WindowHintBool.FocusOnShow,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// WindowAttributeSetter.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to set window related attributes.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.SetWindowAttrib"/>
|
||||
public enum WindowAttributeSetter
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is resizable by the user.
|
||||
/// This is set on creation with the window hint with the same name.
|
||||
/// </summary>
|
||||
Resizable = WindowHintBool.Resizable,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window has decorations such as a border,a close widget, etc.
|
||||
/// This is set on creation with the window hint with the same name.
|
||||
/// </summary>
|
||||
Decorated = WindowHintBool.Decorated,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the full screen window will automatically iconify and restore
|
||||
/// the previous video mode on input focus loss.
|
||||
/// Possible values are <c>true</c> and <c>false</c>. This hint is ignored for windowed mode windows.
|
||||
/// </summary>
|
||||
AutoIconify = WindowHintBool.AutoIconify,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is floating, also called topmost or always-on-top.
|
||||
/// This is controlled by the window hint with the same name.
|
||||
/// </summary>
|
||||
Floating = WindowHintBool.Floating,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the window will be given input focus when <see cref="GLFW.ShowWindow"/> is called.
|
||||
/// Possible values are <c>true</c> and <c>false</c>.
|
||||
/// </summary>
|
||||
FocusOnShow = WindowHintBool.FocusOnShow
|
||||
}
|
||||
}
|
||||
133
OpenToolkit.GraphicsLibraryFramework/Enums/WindowHintBool.cs
Normal file
133
OpenToolkit.GraphicsLibraryFramework/Enums/WindowHintBool.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
//
|
||||
// WindowHintBool.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Context related boolean attributes.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintBool,bool)"/>
|
||||
public enum WindowHintBool
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window has input focus.
|
||||
/// Initial input focus is controlled by the window hint with the same name
|
||||
/// </summary>
|
||||
Focused = 0x00020001,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is iconified,
|
||||
/// whether by the user or with <see cref="GLFW.IconifyWindow"/>.
|
||||
/// </summary>
|
||||
Iconified = 0x00020002,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is resizable by the user.
|
||||
/// This is set on creation with the window hint with the same name.
|
||||
/// </summary>
|
||||
Resizable = 0x00020003,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is visible.
|
||||
/// Window visibility can be controlled with <see cref="GLFW.ShowWindow"/> and <see cref="GLFW.HideWindow"/>
|
||||
/// and initial visibility is controlled by the window hint with the same name.
|
||||
/// </summary>
|
||||
Visible = 0x00020004,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window has decorations such as a border,a close widget, etc.
|
||||
/// This is set on creation with the window hint with the same name.
|
||||
/// </summary>
|
||||
Decorated = 0x00020005,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the full screen window will automatically iconify and restore
|
||||
/// the previous video mode on input focus loss.
|
||||
/// Possible values are <c>true</c> and <c>false</c>. This hint is ignored for windowed mode windows.
|
||||
/// </summary>
|
||||
AutoIconify = 0x00020006,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is floating, also called topmost or always-on-top.
|
||||
/// This is controlled by the window hint with the same name.
|
||||
/// </summary>
|
||||
Floating = 0x00020007,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified window is maximized,
|
||||
/// whether by the user or with <see cref="GLFW.MaximizeWindow"/>.
|
||||
/// </summary>
|
||||
Maximized = 0x00020008,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the cursor should be centered over newly created full screen windows.
|
||||
/// Possible values are <c>true</c> and <c>false</c>. This hint is ignored for windowed mode windows.
|
||||
/// </summary>
|
||||
CenterCursor = 0x00020009,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the window framebuffer will be transparent.
|
||||
/// If enabled and supported by the system, the window framebuffer alpha channel will be used
|
||||
/// to combine the framebuffer with the background.
|
||||
/// This does not affect window decorations. Possible values are <c>true</c> and <c>false</c>.
|
||||
/// </summary>
|
||||
TransparentFramebuffer = 0x0002000A,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the cursor is currently directly over the client area of the window,
|
||||
/// with no other windows between.
|
||||
/// See <a href="https://www.glfw.org/docs/3.3/input_guide.html#cursor_enter">Cursor enter/leave events</a>
|
||||
/// for details.
|
||||
/// </summary>
|
||||
Hovered = 0x0002000B,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the window will be given input focus when <see cref="GLFW.ShowWindow"/> is called.
|
||||
/// Possible values are <c>true</c> and <c>false</c>.
|
||||
/// </summary>
|
||||
FocusOnShow = 0x0002000C,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the window's context is an OpenGL forward-compatible one.
|
||||
/// Possible values are <c>true</c> and <c>false</c>.
|
||||
/// </summary>
|
||||
OpenGLForwardCompat = 0x00022006,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the window's context is an OpenGL debug context.
|
||||
/// Possible values are <c>true</c> and <c>false</c>.
|
||||
/// </summary>
|
||||
OpenGLDebugContext = 0x00022007,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether errors should be generated by the context.
|
||||
/// If enabled, situations that would have generated errors instead cause undefined behavior.
|
||||
/// </summary>
|
||||
ContextNoError = 0x0002200A,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether to use stereoscopic rendering. This is a hard constraint.
|
||||
/// </summary>
|
||||
Stereo = 0x0002100C,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the framebuffer should be double buffered.
|
||||
/// You nearly always want to use double buffering. This is a hard constraint.
|
||||
/// </summary>
|
||||
DoubleBuffer = 0x00021010,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether the framebuffer should be sRGB capable.
|
||||
/// If supported, a created OpenGL context will support the
|
||||
/// <c>GL_FRAMEBUFFER_SRGB</c> enable( also called <c>GL_FRAMEBUFFER_SRGB_EXT</c>)
|
||||
/// for controlling sRGB rendering and a created OpenGL ES context will always have sRGB rendering enabled.
|
||||
/// </summary>
|
||||
SrgbCapable = 0x0002100E,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// WindowHintClientApi.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Context related client API attribute.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintClientApi,ClientApi)"/>
|
||||
public enum WindowHintClientApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the client API provided by the window's context;
|
||||
/// either <see cref="GraphicsLibraryFramework.ClientApi.OpenGlApi"/>,
|
||||
/// <see cref="GraphicsLibraryFramework.ClientApi.OpenGlEsApi"/> or
|
||||
/// <see cref="GraphicsLibraryFramework.ClientApi.NoApi"/>.
|
||||
/// </summary>
|
||||
ClientApi = 0x00022001,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// WindowHintContextApi.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to specify the context creation API.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintContextApi,ContextApi)"/>
|
||||
public enum WindowHintContextApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the context creation API used to create the window's context;
|
||||
/// either <see cref="ContextApi.NativeContextApi"/> or <see cref="ContextApi.EglContextApi"/>.
|
||||
/// </summary>
|
||||
ContextCreationApi = 0x0002200B,
|
||||
}
|
||||
}
|
||||
117
OpenToolkit.GraphicsLibraryFramework/Enums/WindowHintInt.cs
Normal file
117
OpenToolkit.GraphicsLibraryFramework/Enums/WindowHintInt.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
//
|
||||
// WindowHintInt.cs
|
||||
//
|
||||
// Copyright (C) 2018 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Context related attributes.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintInt,int)"/>
|
||||
public enum WindowHintInt
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicate the client API version(major part) of the window's context.
|
||||
/// </summary>
|
||||
ContextVersionMajor = 0x00022002,
|
||||
|
||||
/// <summary>
|
||||
/// Indicate the client API version(minor part) of the window's context.
|
||||
/// </summary>
|
||||
ContextVersionMinor = 0x00022003,
|
||||
|
||||
/// <summary>
|
||||
/// Indicate the client API version(revision part) of the window's context.
|
||||
/// </summary>
|
||||
ContextRevision = 0x00022004,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the red component of the default framebuffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
RedBits = 0x00021001,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the green component of the default framebuffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
GreenBits = 0x00021002,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the blue component of the default framebuffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
BlueBits = 0x00021003,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the alpha component of the default framebuffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
AlphaBits = 0x00021004,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the depth component of the default framebuffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
DepthBits = 0x00021005,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the stencil component of the default framebuffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
StencilBits = 0x00021006,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the red component of the accumulation buffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
/// <remarks>Accumulation buffers are a legacy OpenGL feature and should not be used in new code.</remarks>
|
||||
AccumRedBits = 0x00021007,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the green component of the accumulation buffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
/// <remarks>Accumulation buffers are a legacy OpenGL feature and should not be used in new code.</remarks>
|
||||
AccumGreenBits = 0x00021008,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the blue component of the accumulation buffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
/// <remarks>Accumulation buffers are a legacy OpenGL feature and should not be used in new code.</remarks>
|
||||
AccumBlueBits = 0x00021009,
|
||||
|
||||
/// <summary>
|
||||
/// Specify the desired bit depths of the alpha component of the accumulation buffer.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
/// <remarks>Accumulation buffers are a legacy OpenGL feature and should not be used in new code.</remarks>
|
||||
AccumAlphaBits = 0x0002100A,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the desired number of auxiliary buffers.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
/// <remarks>Auxiliary buffers are a legacy OpenGL feature and should not be used in new code.</remarks>
|
||||
AuxBuffers = 0x0002100B,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the desired number of samples to use for multisampling. Zero disables multisampling.
|
||||
/// <see cref="GLFW.DontCare"/> means the application has no preference.
|
||||
/// </summary>
|
||||
Samples = 0x0002100D,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the desired refresh rate for full screen windows.
|
||||
/// If set to <see cref="GLFW.DontCare"/>,
|
||||
/// the highest available refresh rate will be used. This hint is ignored for windowed mode windows.
|
||||
/// </summary>
|
||||
RefreshRate = 0x0002100F,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// WindowHintOpenGlProfile.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to set the OpenGlProfile attribute.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintOpenGlProfile,OpenGlProfile)"/>
|
||||
public enum WindowHintOpenGlProfile
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the OpenGL profile used by the context.
|
||||
/// This is <see cref="GraphicsLibraryFramework.OpenGlProfile.Core"/>
|
||||
/// or <see cref="GraphicsLibraryFramework.OpenGlProfile.Compat"/>
|
||||
/// if the context uses a known profile, or <see cref="GraphicsLibraryFramework.OpenGlProfile.Any"/>
|
||||
/// if the OpenGL profile is unknown or the context is an OpenGL ES context.
|
||||
/// Note that the returned profile may not match the profile bits of the context flags,
|
||||
/// as GLFW will try other means of detecting the profile when no bits are set. TODO: enum for missing crefs
|
||||
/// </summary>
|
||||
OpenGlProfile = 0x00022008,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// WindowHintReleaseBehavior.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to specify the release behavior used by the local context.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintReleaseBehavior,ReleaseBehavior)"/>
|
||||
public enum WindowHintReleaseBehavior
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the release behavior to be used by the context.
|
||||
/// Possible values are one of <see cref="ReleaseBehavior.Any"/>,
|
||||
/// <see cref="ReleaseBehavior.Flush"/> or <see cref="ReleaseBehavior.None"/>.
|
||||
/// If the behavior is <see cref="ReleaseBehavior"/>, the default behavior
|
||||
/// of the context creation API will be used.
|
||||
/// If the behavior is <see cref="ReleaseBehavior.Flush"/>, the pipeline will be flushed
|
||||
/// whenever the context is released from being the current one.
|
||||
/// If the behavior is <see cref="ReleaseBehavior.None"/>, the pipeline will not be flushed on release.
|
||||
/// </summary>
|
||||
ContextReleaseBehavior = 0x00022009,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// WindowHintRobustness.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to set context robustness attribute.
|
||||
/// </summary>
|
||||
/// <seealso cref="GLFW.WindowHint(WindowHintRobustness,Robustness)"/>
|
||||
public enum WindowHintRobustness
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the robustness strategy used by the context.
|
||||
/// This is <see cref="Robustness.LoseContextOnReset"/> or <see cref="Robustness.NoResetNotification"/>
|
||||
/// if the window's context supports robustness, or <see cref="Robustness.NoRobustness"/> otherwise.
|
||||
/// </summary>
|
||||
ContextRobustness = 0x00022005,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Window hints for the WindowHintString function.
|
||||
/// </summary>
|
||||
public enum WindowHintString
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the frame name on Cocoa. On any other platform, this does nothing.
|
||||
/// </summary>
|
||||
CocoaFrameName = 0x00023002,
|
||||
|
||||
/// <summary>
|
||||
/// Sets the class name on X11. On any other platform, this does nothing.
|
||||
/// </summary>
|
||||
X11ClassName = 0x00024001,
|
||||
|
||||
/// <summary>
|
||||
/// Sets the instance name on X11. on any other platform, this does nothing.
|
||||
/// </summary>
|
||||
X11InstanceName = 0x00024002,
|
||||
}
|
||||
}
|
||||
5550
OpenToolkit.GraphicsLibraryFramework/GLFW.cs
Normal file
5550
OpenToolkit.GraphicsLibraryFramework/GLFW.cs
Normal file
File diff suppressed because it is too large
Load Diff
180
OpenToolkit.GraphicsLibraryFramework/GLFWCallbacks.cs
Normal file
180
OpenToolkit.GraphicsLibraryFramework/GLFWCallbacks.cs
Normal file
@@ -0,0 +1,180 @@
|
||||
//
|
||||
// GLFWCallbacks.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Class containing GLFW related callbacks.
|
||||
/// </summary>
|
||||
public static unsafe class GLFWCallbacks
|
||||
{
|
||||
/// <summary>
|
||||
/// The function signature for Unicode character callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that received the event.</param>
|
||||
/// <param name="codepoint">The Unicode code point of the character.</param>
|
||||
/// <seealso cref="GLFW.SetCharCallback"/>
|
||||
public delegate void CharCallback(Window* window, uint codepoint);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for Unicode character with modifiers callback functions.
|
||||
/// It is called for each input character, regardless of what modifier keys are held down.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that received the event.</param>
|
||||
/// <param name="codepoint">The Unicode code point of the character.</param>
|
||||
/// <param name="modifiers">Bit field describing which modifier keys were held down.</param>
|
||||
/// <seealso cref="GLFW.SetCharModsCallback"/>
|
||||
public delegate void CharModsCallback(Window* window, uint codepoint, KeyModifiers modifiers);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for cursor enter/leave callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that received the event.</param>
|
||||
/// <param name="entered"><c>true</c> if the cursor entered the window's client area, or <c>false</c> if it left it.</param>
|
||||
/// <seealso cref="GLFW.SetCursorEnterCallback"/>
|
||||
public delegate void CursorEnterCallback(Window* window, bool entered);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for cursor position callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that received the event.</param>
|
||||
/// <param name="x">The new cursor x-coordinate, relative to the left edge of the client area.</param>
|
||||
/// <param name="y">The new cursor y-coordinate, relative to the top edge of the client area.</param>
|
||||
/// <seealso cref="GLFW.SetCursorPosCallback"/>
|
||||
public delegate void CursorPosCallback(Window* window, double x, double y);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for file drop callbacks.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that received the event.</param>
|
||||
/// <param name="count">The number of dropped files.</param>
|
||||
/// <param name="paths">The UTF-8 encoded file and/or directory path names.</param>
|
||||
/// <seealso cref="GLFW.SetDropCallback"/>
|
||||
public delegate void DropCallback(Window* window, int count, byte** paths);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for joystick configuration callback functions.
|
||||
/// </summary>
|
||||
/// <param name="joystick">The joystick that was connected or disconnected.</param>
|
||||
/// <param name="state">
|
||||
/// One of <see cref="ConnectedState.Connected"/> or <see cref="ConnectedState.Disconnected"/>.
|
||||
/// </param>
|
||||
/// <seealso cref="GLFW.SetJoystickCallback"/>
|
||||
public delegate void JoystickCallback(int joystick, ConnectedState state);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for keyboard key callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that received the event.</param>
|
||||
/// <param name="key">The keyboard key that was pressed or released.</param>
|
||||
/// <param name="scanCode">The system-specific scancode of the key.</param>
|
||||
/// <param name="action">The <see cref="InputAction"/> for that <paramref name="key"/>.</param>
|
||||
/// <param name="mods">Bit field describing which modifier keys were held down.</param>
|
||||
/// <seealso cref="GLFW.SetKeyCallback"/>
|
||||
public delegate void KeyCallback(Window* window, Keys key, int scanCode, InputAction action, KeyModifiers mods);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for mouse button callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that received the event.</param>
|
||||
/// <param name="button">The mouse button that was pressed or released.</param>
|
||||
/// <param name="action">One of <see cref="InputAction.Press"/> or <see cref="InputAction.Release"/>.</param>
|
||||
/// <param name="mods">Bit field describing which modifier keys were held down.</param>
|
||||
/// <seealso cref="GLFW.SetMouseButtonCallback"/>
|
||||
public delegate void MouseButtonCallback(Window* window, MouseButton button, InputAction action, KeyModifiers mods); // TODO: Make enums for int params in callback
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for scroll callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that received the event.</param>
|
||||
/// <param name="offsetX">The scroll offset along the x-axis.</param>
|
||||
/// <param name="offsetY">The scroll offset along the y-axis.</param>
|
||||
/// <seealso cref="GLFW.SetScrollCallback"/>
|
||||
public delegate void ScrollCallback(Window* window, double offsetX, double offsetY);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for monitor configuration callback functions.
|
||||
/// </summary>
|
||||
/// <param name="monitor">The monitor that was connected or disconnected.</param>
|
||||
/// <param name="state">
|
||||
/// One <see cref="ConnectedState.Connected"/> of or <see cref="ConnectedState.Disconnected"/>.
|
||||
/// </param>
|
||||
/// <seealso cref="GLFW.SetMonitorCallback"/>
|
||||
public delegate void MonitorCallback(Monitor* monitor, ConnectedState state);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for window close callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that the user attempted to close.</param>
|
||||
/// <seealso cref="GLFW.SetWindowCloseCallback"/>
|
||||
public delegate void WindowCloseCallback(Window* window);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for window focus callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that gained or lost input focus.</param>
|
||||
/// <param name="focused"><c>true</c> if the window was given input focus, or <c>false</c> if it lost it.</param>
|
||||
/// <seealso cref="GLFW.SetWindowFocusCallback"/>
|
||||
public delegate void WindowFocusCallback(Window* window, bool focused);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for window iconify/restore callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that was iconified or restored.</param>
|
||||
/// <param name="iconified"><c>true</c> if the window was iconified(minimized), or <c>false</c> if it was restored.</param>
|
||||
/// <seealso cref="GLFW.SetWindowIconifyCallback"/>
|
||||
public delegate void WindowIconifyCallback(Window* window, bool iconified);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for window position callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that was moved.</param>
|
||||
/// <param name="x">
|
||||
/// The new x-coordinate, in screen coordinates, of the upper-left corner of the client area of the window.
|
||||
/// </param>
|
||||
/// <param name="y">
|
||||
/// The new y-coordinate, in screen coordinates, of the upper-left corner of the client area of the window.
|
||||
/// </param>
|
||||
/// <seealso cref="GLFW.SetWindowPosCallback"/>
|
||||
public delegate void WindowPosCallback(Window* window, int x, int y);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for window size callback functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that was resized.</param>
|
||||
/// <param name="width">The new width, in screen coordinates, of the window.</param>
|
||||
/// <param name="height">The new height, in screen coordinates, of the window.</param>
|
||||
/// <seealso cref="GLFW.SetWindowSizeCallback"/>
|
||||
public delegate void WindowSizeCallback(Window* window, int width, int height);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for error callback functions.
|
||||
/// </summary>
|
||||
/// <param name="error">An error code.</param>
|
||||
/// <param name="description">A UTF-8 encoded string describing the error.</param>
|
||||
public delegate void ErrorCallback(ErrorCode error, string description);
|
||||
|
||||
/// <summary>
|
||||
/// The function signature for window refresh functions.
|
||||
/// </summary>
|
||||
/// <param name="window">The window that needs to be refreshed.</param>
|
||||
public delegate void WindowRefreshCallback(Window* window);
|
||||
|
||||
/// <summary>
|
||||
/// This is the function pointer type for window content scale callbacks.
|
||||
/// </summary>
|
||||
/// <param name="window">The window whose content scale changed. </param>
|
||||
/// <param name="xscale">The new x-axis content scale of the window. </param>
|
||||
/// <param name="yscale">The new y-axis content scale of the window.</param>
|
||||
/// <seealso cref="GLFW.SetWindowContentScaleCallback"/>
|
||||
public delegate void WindowContentScaleCallback(Window* window, float xscale, float yscale);
|
||||
}
|
||||
}
|
||||
78
OpenToolkit.GraphicsLibraryFramework/GLFWException.cs
Normal file
78
OpenToolkit.GraphicsLibraryFramework/GLFWException.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// GLFWException.cs
|
||||
//
|
||||
// Copyright (C) 2018 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents errors that occur within GLFW.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class GLFWException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the underlying GLFW-error code.
|
||||
/// </summary>
|
||||
public ErrorCode ErrorCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GLFWException"/> class.
|
||||
/// </summary>
|
||||
public GLFWException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GLFWException"/> class with the specified detailed description.
|
||||
/// </summary>
|
||||
/// <param name="message">A detailed description of the error.</param>
|
||||
public GLFWException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GLFWException"/> class
|
||||
/// with the specified detailed description and GLFW error code.
|
||||
/// </summary>
|
||||
/// <param name="message">A detailed description of the error.</param>
|
||||
/// <param name="errorCode">The GLFW error code causing the exception.</param>
|
||||
public GLFWException(string message, ErrorCode errorCode)
|
||||
: base(message)
|
||||
{
|
||||
ErrorCode = errorCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GLFWException"/> class with the specified detailed description
|
||||
/// and the specified exception.
|
||||
/// </summary>
|
||||
/// <param name="message">A detailed description of the error.</param>
|
||||
/// <param name="innerException">A reference to the inner exception that is the cause of this exception.</param>
|
||||
public GLFWException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GLFWException"/> class with the specified context
|
||||
/// and the serialization information.
|
||||
/// </summary>
|
||||
/// <param name="info">The <see cref="SerializationInfo"/> associated with this exception.</param>
|
||||
/// <param name="context">
|
||||
/// A <see cref="StreamingContext"/> that represents the context of this exception.
|
||||
/// </param>
|
||||
protected GLFWException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
406
OpenToolkit.GraphicsLibraryFramework/GLFWNative.cs
Normal file
406
OpenToolkit.GraphicsLibraryFramework/GLFWNative.cs
Normal file
@@ -0,0 +1,406 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
internal static unsafe class GLFWNative
|
||||
{
|
||||
private const string LibraryName = "glfw3.dll";
|
||||
|
||||
public const int GLFW_TRUE = 1;
|
||||
public const int GLFW_FALSE = 0;
|
||||
|
||||
#if NETCOREAPP
|
||||
static GLFWNative()
|
||||
{
|
||||
// Register DllImport resolver so that the correct dynamic library is loaded on all platforms.
|
||||
// On net472, we rely on Mono's DllMap for this. See the .dll.config file.
|
||||
NativeLibrary.SetDllImportResolver(typeof(GLFWNative).Assembly, (name, assembly, path) =>
|
||||
{
|
||||
if (name != "glfw3.dll")
|
||||
{
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
return NativeLibrary.Load("libglfw.so.3", assembly, path);
|
||||
}
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
return NativeLibrary.Load("libglfw.3.dylib", assembly, path);
|
||||
}
|
||||
|
||||
return IntPtr.Zero;
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwInit();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwTerminate();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwInitHint(int hint, int value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetVersion(int* major, int* minor, int* revision);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern byte* glfwGetVersionString();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern ErrorCode glfwGetError(byte** description);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern Monitor** glfwGetMonitors(int* count);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetMonitorPos(Monitor* monitor, int* x, int* y);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetMonitorPhysicalSize(Monitor* monitor, int* width, int* height);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetMonitorContentScale(Monitor* monitor, float* xscale, float* yscale);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern byte* glfwGetMonitorName(Monitor* monitor);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetMonitorUserPointer(Monitor* monitor, void* pointer);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void* glfwGetMonitorUserPointer(Monitor* monitor);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern VideoMode* glfwGetVideoModes(Monitor* monitor, int* count);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetGamma(Monitor* monitor, float gamma);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern GammaRamp* glfwGetGammaRamp(Monitor* monitor);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetGammaRamp(Monitor* monitor, GammaRamp* ramp);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwDefaultWindowHints();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWindowHintString(int hint, byte* value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowSizeLimits(Window* window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowAspectRatio(Window* window, int numer, int denom);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetWindowFrameSize(Window* window, int* left, int* top, int* right, int* bottom);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetWindowContentScale(Window* window, float* xscale, float* yscale);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern float glfwGetWindowOpacity(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowOpacity(Window* window, float opacity);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwRequestWindowAttention(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowAttrib(Window* window, WindowAttributeSetter attrib, int value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwRawMouseMotionSupported();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern byte* glfwGetKeyName(Keys key, int scancode);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwGetKeyScancode(Keys key);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern InputAction glfwGetKey(Window* window, Keys key);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern InputAction glfwGetMouseButton(Window* window, MouseButton button);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetCursorPos(Window* window, double* xpos, double* ypos);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetCursorPos(Window* window, double xpos, double ypos);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern Cursor* glfwCreateCursor(Image* image, int xhot, int yhot);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern Cursor* glfwCreateStandardCursor(CursorShape shape);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwDestroyCursor(Cursor* cursor);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetCursor(Window* window, Cursor* cursor);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwJoystickPresent(int jid);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern float* glfwGetJoystickAxes(int jid, int* count);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern InputAction* glfwGetJoystickButtons(int jid, int* count);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern JoystickHats* glfwGetJoystickHats(int jid, int* count);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern byte* glfwGetJoystickName(int jid);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern byte* glfwGetJoystickGUID(int jid);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetJoystickUserPointer(int jid, void* ptr);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void* glfwGetJoystickUserPointer(int jid);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwJoystickIsGamepad(int jid);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwUpdateGamepadMappings(byte* newMapping);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern byte* glfwGetGamepadName(int jid);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwGetGamepadState(int jid, GamepadState* state);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern double glfwGetTime();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetTime(double time);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern long glfwGetTimerValue();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern long glfwGetTimerFrequency();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern Window* glfwGetCurrentContext();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSwapBuffers(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwExtensionSupported(byte* extensionName);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwGetProcAddress(byte* procame);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern Window* glfwCreateWindow(int width, int height, byte* title, Monitor* monitor, Window* share);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern Monitor* glfwGetPrimaryMonitor();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwDestroyWindow(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwFocusWindow(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetFramebufferSize(Window* window, int* width, int* height);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern CursorModeValue glfwGetInputMode(Window* window, CursorStateAttribute mode);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwGetInputMode(Window* window, StickyAttributes mode);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwRestoreWindow(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern VideoMode* glfwGetVideoMode(Monitor* monitor);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwGetWindowAttrib(Window* window, WindowAttributeGetter attribute);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetWindowSize(Window* window, int* width, int* height);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwGetWindowPos(Window* window, int* x, int* y);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern Monitor* glfwGetWindowMonitor(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwHideWindow(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwIconifyWindow(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwMakeContextCurrent(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwMaximizeWindow(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwPollEvents();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwPostEmptyEvent();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWindowHint(WindowHintInt hint, int value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWindowHint(WindowHintBool hint, int value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWindowHint(WindowHintClientApi hint, ClientApi value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWindowHint(WindowHintReleaseBehavior hint, ReleaseBehavior value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWindowHint(WindowHintContextApi hint, ContextApi value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWindowHint(WindowHintRobustness hint, Robustness value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWindowHint(WindowHintOpenGlProfile hint, OpenGlProfile value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwWindowShouldClose(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetCharCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetCharModsCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetCursorEnterCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetCursorPosCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetDropCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetErrorCallback(IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetInputMode(Window* window, CursorStateAttribute mode, CursorModeValue value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetInputMode(Window* window, StickyAttributes mode, int value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetJoystickCallback(IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetKeyCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetScrollCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetMonitorCallback(IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetMouseButtonCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetWindowCloseCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetWindowFocusCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowIcon(Window* window, int count, Image* images);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetWindowIconifyCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetWindowContentScaleCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowTitle(Window* window, byte* title);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwShowWindow(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowSize(Window* window, int width, int height);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetWindowSizeCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowShouldClose(Window* window, int value);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowMonitor(Window* window, Monitor* monitor, int x, int y, int width, int height, int refreshRate);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetWindowPos(Window* window, int x, int y);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetWindowPosCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwSetWindowRefreshCallback(Window* window, IntPtr callback);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSwapInterval(int interval);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWaitEvents();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwWaitEventsTimeout(double timeout);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern byte* glfwGetClipboardString(Window* window);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern void glfwSetClipboardString(Window* window, byte* data);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwVulkanSupported();
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern byte** glfwGetRequiredInstanceExtensions(uint* count);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern IntPtr glfwGetInstanceProcAddress(VkHandle instance, byte* procName);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwGetPhysicalDevicePresentationSupport(VkHandle instance, VkHandle device, int queueFamily);
|
||||
|
||||
[DllImport(LibraryName)]
|
||||
public static extern int glfwCreateWindowSurface(VkHandle instance, Window* window, void* allocator, VkHandle surface);
|
||||
}
|
||||
}
|
||||
27
OpenToolkit.GraphicsLibraryFramework/GamepadState.cs
Normal file
27
OpenToolkit.GraphicsLibraryFramework/GamepadState.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// GamepadState.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// This describes the input state of a gamepad.
|
||||
/// </summary>
|
||||
public struct GamepadState
|
||||
{
|
||||
/// <summary>
|
||||
/// State of each of the 15 gamepad buttons, equal to <see cref="InputAction.Press"/> or <see cref="InputAction.Release"/>.
|
||||
/// </summary>
|
||||
public unsafe fixed byte Buttons[15];
|
||||
|
||||
/// <summary>
|
||||
/// State of each of the 6 gamepad axes, ranging from -1.0 to 1.0.
|
||||
/// </summary>
|
||||
public unsafe fixed float Axes[6];
|
||||
}
|
||||
}
|
||||
37
OpenToolkit.GraphicsLibraryFramework/GammaRamp.cs
Normal file
37
OpenToolkit.GraphicsLibraryFramework/GammaRamp.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// GammaRamp.cs
|
||||
//
|
||||
// Copyright (C) 2019 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Gamma ramp for a <see cref="Monitor"/>.
|
||||
/// </summary>
|
||||
public unsafe struct GammaRamp
|
||||
{
|
||||
/// <summary>
|
||||
/// Red components of the gamma ramp.
|
||||
/// </summary>
|
||||
public ushort* Red;
|
||||
|
||||
/// <summary>
|
||||
/// Green components of the gamma ramp.
|
||||
/// </summary>
|
||||
public ushort* Green;
|
||||
|
||||
/// <summary>
|
||||
/// Blue components of the gamma ramp.
|
||||
/// </summary>
|
||||
public ushort* Blue;
|
||||
|
||||
/// <summary>
|
||||
/// Length of the arrays.
|
||||
/// </summary>
|
||||
public uint Size;
|
||||
}
|
||||
}
|
||||
47
OpenToolkit.GraphicsLibraryFramework/Image.cs
Normal file
47
OpenToolkit.GraphicsLibraryFramework/Image.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// Image.cs
|
||||
//
|
||||
// Copyright (C) 2018 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains GLFW Image data.
|
||||
/// </summary>
|
||||
public unsafe struct Image
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Image"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="width">The width of the image in pixels.</param>
|
||||
/// <param name="height">The height of the image in pixels.</param>
|
||||
/// <param name="pixels"><see cref="IntPtr"/> pointing to the RGBA pixel data of the image.</param>
|
||||
public Image(int width, int height, byte* pixels)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
Pixels = pixels;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The width, in pixels, of this <see cref="Image"/>.
|
||||
/// </summary>
|
||||
public int Width;
|
||||
|
||||
/// <summary>
|
||||
/// The height, in pixels, of this <see cref="Image"/>.
|
||||
/// </summary>
|
||||
public int Height;
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="byte"/> pointer pointing to the RGBA pixel data.
|
||||
/// </summary>
|
||||
public byte* Pixels;
|
||||
}
|
||||
}
|
||||
23
OpenToolkit.GraphicsLibraryFramework/LICENSE.md
Normal file
23
OpenToolkit.GraphicsLibraryFramework/LICENSE.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# MIT License
|
||||
|
||||
Copyright (c) 2006-2019 Stefanos Apostolopoulos for the Open Toolkit project.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
- The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
#### Third party licenses may be applicable. These have been disclosed in [THIRD_PARTIES.md](THIRD_PARTIES.md)
|
||||
18
OpenToolkit.GraphicsLibraryFramework/Monitor.cs
Normal file
18
OpenToolkit.GraphicsLibraryFramework/Monitor.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Monitor.cs
|
||||
//
|
||||
// Copyright (C) 2018 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Opaque handle to a GLFW monitor.
|
||||
/// </summary>
|
||||
public struct Monitor
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\MSBuild\Robust.Properties.targets" />
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- Work around https://github.com/dotnet/project-system/issues/4314 -->
|
||||
<TargetFramework>$(TargetFramework)</TargetFramework>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Platforms>x64</Platforms>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\MSBuild\Robust.DefineConstants.targets" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Condition="'$(TargetFramework)' == 'net472'" Include="System.Memory" Version="4.5.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="OpenToolkit.GraphicsLibraryFramework.dll.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,5 @@
|
||||
<configuration>
|
||||
<!-- I actually have no idea whether this works on FreeBSD but it can't hurt to set it as such. -->
|
||||
<dllmap os="linux,freebsd" dll="glfw3.dll" target="glfw.so.3" />
|
||||
<dllmap os="osx" dll="glfw3.dll" target="glfw.3.dylib" />
|
||||
</configuration>
|
||||
20
OpenToolkit.GraphicsLibraryFramework/THIRD_PARTIES.md
Normal file
20
OpenToolkit.GraphicsLibraryFramework/THIRD_PARTIES.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Third parties
|
||||
|
||||
## AdvancedDLSupport
|
||||
> OpenTK uses AdvancedDLSupport for native interoperability. To enable compatibility with the LGPLv3 License, Firwood has given us a licensing exception.
|
||||
|
||||
* Read the [license grant](AdvancedDLSupport-LICENSE.pdf).
|
||||
* Read the [license summary](Short-LICENSE.md) for an easy-to-understand version.
|
||||
|
||||
## OpenEXR
|
||||
|
||||
> OpenTK.Half offers Half-to-Single and Single-to-Half conversions based on OpenEXR source code, which is covered by the following license:
|
||||
|
||||
Copyright (c) 2002, Industrial Light & Magic, a division of Lucas Digital Ltd. LLC. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Industrial Light & Magic nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
50
OpenToolkit.GraphicsLibraryFramework/VideoMode.cs
Normal file
50
OpenToolkit.GraphicsLibraryFramework/VideoMode.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// VideoMode.cs
|
||||
//
|
||||
// Copyright (C) 2018 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Replicated handle to a GLFW VideoMode.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct VideoMode
|
||||
{
|
||||
/// <summary>
|
||||
/// The width, in screen coordinates, of the <see cref="VideoMode"/>.
|
||||
/// </summary>
|
||||
public int Width;
|
||||
|
||||
/// <summary>
|
||||
/// The height, in screen coordinates, of the <see cref="VideoMode"/>.
|
||||
/// </summary>
|
||||
public int Height;
|
||||
|
||||
/// <summary>
|
||||
/// The bit depth of the red channel of the <see cref="VideoMode"/>.
|
||||
/// </summary>
|
||||
public int RedBits;
|
||||
|
||||
/// <summary>
|
||||
/// The bit depth of the green channel of the <see cref="VideoMode"/>.
|
||||
/// </summary>
|
||||
public int GreenBits;
|
||||
|
||||
/// <summary>
|
||||
/// The bit depth of the blue channel of the <see cref="VideoMode"/>.
|
||||
/// </summary>
|
||||
public int BlueBits;
|
||||
|
||||
/// <summary>
|
||||
/// The refresh rate, in Hz, of the <see cref="VideoMode"/>.
|
||||
/// </summary>
|
||||
public int RefreshRate;
|
||||
}
|
||||
}
|
||||
29
OpenToolkit.GraphicsLibraryFramework/VkHandle.cs
Normal file
29
OpenToolkit.GraphicsLibraryFramework/VkHandle.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// A handle to a Vulkan object.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct VkHandle
|
||||
{
|
||||
/// <summary>
|
||||
/// The actual value of the Vulkan handle.
|
||||
/// </summary>
|
||||
public IntPtr Handle;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VkHandle"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="handle">
|
||||
/// The native Vulkan handle.
|
||||
/// This is NOT a pointer to a field containing the handle, this is the actual handle itself.
|
||||
/// </param>
|
||||
public VkHandle(IntPtr handle)
|
||||
{
|
||||
Handle = handle;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
OpenToolkit.GraphicsLibraryFramework/Window.cs
Normal file
18
OpenToolkit.GraphicsLibraryFramework/Window.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Window.cs
|
||||
//
|
||||
// Copyright (C) 2018 OpenTK
|
||||
//
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the MIT license. See the LICENSE file for details.
|
||||
//
|
||||
|
||||
namespace OpenToolkit.GraphicsLibraryFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Opaque handle to a GLFW window.
|
||||
/// </summary>
|
||||
public struct Window
|
||||
{
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB |
Binary file not shown.
BIN
Resources/Midi/fallback.sf2
Normal file
BIN
Resources/Midi/fallback.sf2
Normal file
Binary file not shown.
@@ -1,15 +0,0 @@
|
||||
- type: shader
|
||||
id: selection_outline
|
||||
kind: source
|
||||
path: "/Shaders/outline.swsl"
|
||||
params:
|
||||
outline_width: 1
|
||||
outline_color: "#FF000055"
|
||||
|
||||
- type: shader
|
||||
id: selection_outline_unshaded
|
||||
kind: source
|
||||
path: "/Shaders/outline_unshaded.swsl"
|
||||
params:
|
||||
outline_width: 1
|
||||
outline_color: "#FF000055"
|
||||
@@ -1,115 +0,0 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Engine/Scenes/SS14Window/SS14Window.tscn" type="PackedScene" id=1]
|
||||
|
||||
[node name="SS14Window" instance=ExtResource( 1 )]
|
||||
|
||||
margin_left = 370.0
|
||||
margin_top = 112.0
|
||||
margin_right = 519.0
|
||||
margin_bottom = 239.0
|
||||
mouse_default_cursor_shape = 0
|
||||
|
||||
[node name="Contents" parent="." index="0"]
|
||||
|
||||
mouse_default_cursor_shape = 0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Contents" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
alignment = 0
|
||||
|
||||
[node name="VSyncCheckBox" type="CheckBox" parent="Contents/VBoxContainer" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 129.0
|
||||
margin_bottom = 24.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||
toggle_mode = true
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "VSync"
|
||||
flat = false
|
||||
align = 0
|
||||
_sections_unfolded = [ "custom_colors" ]
|
||||
|
||||
[node name="FullscreenCheckBox" type="CheckBox" parent="Contents/VBoxContainer" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 28.0
|
||||
margin_right = 129.0
|
||||
margin_bottom = 52.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
toggle_mode = true
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "FullScreen"
|
||||
flat = false
|
||||
align = 0
|
||||
|
||||
[node name="ApplyButton" type="Button" parent="Contents/VBoxContainer" index="2"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 56.0
|
||||
margin_right = 129.0
|
||||
margin_bottom = 76.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
disabled = true
|
||||
toggle_mode = false
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "Apply Changes"
|
||||
flat = false
|
||||
align = 1
|
||||
_sections_unfolded = [ "Margin" ]
|
||||
|
||||
[node name="Header" parent="." index="1"]
|
||||
|
||||
mouse_default_cursor_shape = 0
|
||||
|
||||
[node name="Header Text" parent="Header" index="0"]
|
||||
|
||||
mouse_default_cursor_shape = 0
|
||||
text = "Options Menu"
|
||||
|
||||
[node name="CloseButton" parent="Header" index="1"]
|
||||
|
||||
focus_mode = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id=1]
|
||||
|
||||
content_margin_left = -1.0
|
||||
content_margin_right = -1.0
|
||||
content_margin_top = -1.0
|
||||
content_margin_bottom = -1.0
|
||||
|
||||
[node name="EntitySpawnItem" type="PanelContainer"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 102.0
|
||||
margin_bottom = 32.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
_sections_unfolded = [ "Grow Direction", "Mouse", "Rect", "Size Flags", "custom_styles" ]
|
||||
|
||||
[node name="Button" type="Button" parent="." index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 102.0
|
||||
margin_bottom = 32.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
toggle_mode = true
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
flat = false
|
||||
align = 1
|
||||
_sections_unfolded = [ "Size Flags" ]
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="." index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 102.0
|
||||
margin_bottom = 32.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
alignment = 0
|
||||
_sections_unfolded = [ "Grow Direction", "Mouse", "Size Flags" ]
|
||||
|
||||
[node name="TextureWrap" type="Control" parent="HBoxContainer" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 32.0
|
||||
margin_bottom = 32.0
|
||||
rect_min_size = Vector2( 32, 32 )
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
rect_clip_content = true
|
||||
_sections_unfolded = [ "Mouse", "Rect" ]
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/TextureWrap" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
_sections_unfolded = [ "Focus", "Grow Direction", "Hint", "Margin", "Mouse", "Rect", "Size Flags", "Theme" ]
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxContainer" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 36.0
|
||||
margin_top = 9.0
|
||||
margin_right = 95.0
|
||||
margin_bottom = 23.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 4
|
||||
text = "Backpack"
|
||||
percent_visible = 1.0
|
||||
lines_skipped = 0
|
||||
max_lines_visible = -1
|
||||
_sections_unfolded = [ "Mouse" ]
|
||||
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Engine/Scenes/SS14Window/SS14Window.tscn" type="PackedScene" id=1]
|
||||
|
||||
[node name="SS14Window" instance=ExtResource( 1 )]
|
||||
|
||||
margin_right = 532.0
|
||||
margin_bottom = 398.0
|
||||
_sections_unfolded = [ "Margin" ]
|
||||
|
||||
[node name="Contents" parent="." index="0"]
|
||||
|
||||
mouse_filter = 1
|
||||
|
||||
[node name="HSplitContainer" type="HSplitContainer" parent="Contents" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
split_offset = 0
|
||||
collapsed = false
|
||||
dragger_visibility = 0
|
||||
_sections_unfolded = [ "Mouse" ]
|
||||
|
||||
[node name="PrototypeListScrollContainer" type="ScrollContainer" parent="Contents/HSplitContainer" index="0"]
|
||||
|
||||
editor/display_folded = true
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 310.0
|
||||
rect_min_size = Vector2( 200, 0 )
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = true
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
scroll_horizontal_enabled = true
|
||||
scroll_horizontal = 0
|
||||
scroll_vertical_enabled = true
|
||||
scroll_vertical = 0
|
||||
_sections_unfolded = [ "Anchor", "Grow Direction", "Margin", "Mouse", "Rect", "Scroll", "Size Flags" ]
|
||||
|
||||
[node name="PrototypeList" type="VBoxContainer" parent="Contents/HSplitContainer/PrototypeListScrollContainer" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 200.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
custom_constants/separation = 2
|
||||
alignment = 0
|
||||
_sections_unfolded = [ "Focus", "Hint", "Mouse", "Rect", "Size Flags", "custom_constants" ]
|
||||
|
||||
[node name="Options" type="VBoxContainer" parent="Contents/HSplitContainer" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 212.0
|
||||
margin_right = 412.0
|
||||
margin_bottom = 310.0
|
||||
rect_min_size = Vector2( 200, 0 )
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
alignment = 0
|
||||
_sections_unfolded = [ "Hint", "Margin", "Mouse", "Rect" ]
|
||||
|
||||
[node name="SearchBar" type="LineEdit" parent="Contents/HSplitContainer/Options" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 24.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 1
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
focus_mode = 2
|
||||
context_menu_enabled = true
|
||||
placeholder_text = "Search Entities"
|
||||
placeholder_alpha = 0.6
|
||||
caret_blink = false
|
||||
caret_blink_speed = 0.65
|
||||
caret_position = 0
|
||||
_sections_unfolded = [ "Placeholder" ]
|
||||
|
||||
[node name="Buttons!" type="HBoxContainer" parent="Contents/HSplitContainer/Options" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 28.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 48.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
focus_mode = 2
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
alignment = 1
|
||||
_sections_unfolded = [ "Mouse" ]
|
||||
|
||||
[node name="ClearButton" type="Button" parent="Contents/HSplitContainer/Options/Buttons!" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 98.0
|
||||
margin_bottom = 20.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
disabled = true
|
||||
toggle_mode = false
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "Clear Search"
|
||||
flat = false
|
||||
align = 1
|
||||
_sections_unfolded = [ "Grow Direction", "Rect", "Size Flags" ]
|
||||
|
||||
[node name="EraseButton" type="Button" parent="Contents/HSplitContainer/Options/Buttons!" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 102.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 20.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
toggle_mode = true
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "Erase Mode"
|
||||
flat = false
|
||||
align = 1
|
||||
|
||||
[node name="OverridePlacementText" type="Label" parent="Contents/HSplitContainer/Options" index="2"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 52.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 66.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 4
|
||||
text = "Override Placement:"
|
||||
percent_visible = 1.0
|
||||
lines_skipped = 0
|
||||
max_lines_visible = -1
|
||||
|
||||
[node name="OverrideMenu" type="OptionButton" parent="Contents/HSplitContainer/Options" index="3"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 70.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 90.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
toggle_mode = false
|
||||
action_mode = 0
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
flat = false
|
||||
align = 0
|
||||
selected = -1
|
||||
items = [ ]
|
||||
|
||||
[node name="Header Text" parent="Header" index="0"]
|
||||
|
||||
text = "Entity Spawn Panel"
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id=1]
|
||||
|
||||
content_margin_left = -1.0
|
||||
content_margin_right = -1.0
|
||||
content_margin_top = -1.0
|
||||
content_margin_bottom = -1.0
|
||||
|
||||
[node name="EntitySpawnItem" type="PanelContainer"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 102.0
|
||||
margin_bottom = 32.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
_sections_unfolded = [ "Grow Direction", "Mouse", "Rect", "Size Flags", "custom_styles" ]
|
||||
|
||||
[node name="Button" type="Button" parent="." index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 102.0
|
||||
margin_bottom = 32.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
toggle_mode = true
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "Space"
|
||||
flat = false
|
||||
align = 0
|
||||
_sections_unfolded = [ "Size Flags" ]
|
||||
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Engine/Scenes/SS14Window/SS14Window.tscn" type="PackedScene" id=1]
|
||||
|
||||
[node name="SS14Window" index="0" instance=ExtResource( 1 )]
|
||||
|
||||
margin_right = 532.0
|
||||
margin_bottom = 398.0
|
||||
_sections_unfolded = [ "Margin" ]
|
||||
|
||||
[node name="Contents" parent="." index="0"]
|
||||
|
||||
mouse_filter = 1
|
||||
|
||||
[node name="HSplitContainer" type="HSplitContainer" parent="Contents" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
split_offset = 0
|
||||
collapsed = false
|
||||
dragger_visibility = 0
|
||||
_sections_unfolded = [ "Mouse" ]
|
||||
|
||||
[node name="TileListScrollContainer" type="ScrollContainer" parent="Contents/HSplitContainer" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 310.0
|
||||
rect_min_size = Vector2( 200, 0 )
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = true
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
scroll_horizontal_enabled = true
|
||||
scroll_horizontal = 0
|
||||
scroll_vertical_enabled = true
|
||||
scroll_vertical = 0
|
||||
_sections_unfolded = [ "Anchor", "Grow Direction", "Margin", "Mouse", "Rect", "Scroll", "Size Flags" ]
|
||||
|
||||
[node name="TileList" type="VBoxContainer" parent="Contents/HSplitContainer/TileListScrollContainer" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 200.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
custom_constants/separation = 2
|
||||
alignment = 0
|
||||
_sections_unfolded = [ "Focus", "Hint", "Mouse", "Rect", "Size Flags", "custom_constants" ]
|
||||
|
||||
[node name="Options" type="VBoxContainer" parent="Contents/HSplitContainer" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 212.0
|
||||
margin_right = 412.0
|
||||
margin_bottom = 310.0
|
||||
rect_min_size = Vector2( 200, 0 )
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
alignment = 0
|
||||
_sections_unfolded = [ "Hint", "Margin", "Mouse", "Rect" ]
|
||||
|
||||
[node name="SearchBar" type="LineEdit" parent="Contents/HSplitContainer/Options" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 24.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 1
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
focus_mode = 2
|
||||
context_menu_enabled = true
|
||||
placeholder_text = "Search Tiles"
|
||||
placeholder_alpha = 0.6
|
||||
caret_blink = false
|
||||
caret_blink_speed = 0.65
|
||||
caret_position = 0
|
||||
_sections_unfolded = [ "Placeholder" ]
|
||||
|
||||
[node name="ClearButton" type="Button" parent="Contents/HSplitContainer/Options" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 28.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 48.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
disabled = true
|
||||
toggle_mode = false
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "Clear Search"
|
||||
flat = false
|
||||
align = 1
|
||||
_sections_unfolded = [ "Grow Direction", "Rect", "Size Flags" ]
|
||||
|
||||
[node name="Header Text" parent="Header" index="0"]
|
||||
|
||||
text = "Tile Spawn Panel"
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://Engine/Scenes/SS14Window/closewindow.png" type="Texture" id=1]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
|
||||
bg_color = Color( 0.234375, 0.234375, 0.234375, 1 )
|
||||
|
||||
[node name="SS14Window" type="Panel"]
|
||||
margin_left = 100.0
|
||||
margin_top = 38.0
|
||||
margin_right = 878.0
|
||||
margin_bottom = 519.0
|
||||
|
||||
[node name="Contents" type="MarginContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 0.0
|
||||
margin_top = 30.0
|
||||
margin_right = 0.0
|
||||
margin_bottom = 0.0
|
||||
rect_min_size = Vector2( 50, 50 )
|
||||
rect_clip_content = true
|
||||
mouse_filter = 2
|
||||
custom_constants/margin_right = 10
|
||||
custom_constants/margin_left = 10
|
||||
custom_constants/margin_bottom = 10
|
||||
custom_constants/margin_top = 10
|
||||
|
||||
[node name="Header" type="Panel" parent="."]
|
||||
anchor_right = 1.0
|
||||
margin_bottom = 25.0
|
||||
mouse_filter = 2
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
|
||||
[node name="Header Text" type="Label" parent="Header"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_right = -25.0
|
||||
text = "Exemplary Window Title Here"
|
||||
align = 1
|
||||
valign = 1
|
||||
clip_text = true
|
||||
|
||||
[node name="CloseButton" type="TextureButton" parent="Header"]
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = -25.0
|
||||
texture_normal = ExtResource( 1 )
|
||||
expand = true
|
||||
stretch_mode = 5
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 239 B |
@@ -1,31 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/closewindow.png-27200ff550a4cc91ea5c13546f44ca18.stex"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Engine/Scenes/SS14Window/closewindow.png"
|
||||
dest_files=[ "res://.import/closewindow.png-27200ff550a4cc91ea5c13546f44ca18.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
@@ -1,17 +0,0 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://SpriteView.cs" type="Script" id=1]
|
||||
|
||||
[node name="SpriteView" type="Control"]
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
script = ExtResource( 1 )
|
||||
|
||||
5
Resources/Shaders/Internal/default-model.swsl
Normal file
5
Resources/Shaders/Internal/default-model.swsl
Normal file
@@ -0,0 +1,5 @@
|
||||
kind model;
|
||||
|
||||
void fragment() {
|
||||
COLOR = texture(TEXTURE, UV);
|
||||
}
|
||||
@@ -6,12 +6,14 @@ const float LIGHTING_HEIGHT = 1;
|
||||
|
||||
// Position of the fragment, in world coordinates.
|
||||
in vec2 worldPosition;
|
||||
in vec2 UV;
|
||||
|
||||
uniform vec4 lightColor;
|
||||
// Position of the light, in world coordinates.
|
||||
uniform vec2 lightCenter;
|
||||
uniform float lightRange;
|
||||
uniform float lightPower;
|
||||
uniform sampler2D lightMask;
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -21,6 +23,7 @@ void main()
|
||||
float val = clamp((1 - clamp(sqrt(dist) / lightRange, 0, 1)) * (1 / (sqrt(dist + 1))), 0, 1);
|
||||
|
||||
val *= lightPower;
|
||||
val *= texture(lightMask, UV).r;
|
||||
|
||||
FragColor = vec4(lightColor.rgb, val);
|
||||
}
|
||||
|
||||
@@ -2,22 +2,26 @@
|
||||
|
||||
// Vertex position.
|
||||
layout (location = 0) in vec2 aPos;
|
||||
// Texture coordinates.
|
||||
layout (location = 1) in vec2 tCoord;
|
||||
|
||||
out vec2 UV;
|
||||
out vec2 worldPosition;
|
||||
|
||||
uniform mat3 modelMatrix;
|
||||
|
||||
layout (std140) uniform projectionViewMatrices
|
||||
{
|
||||
mat3 projectionMatrix;
|
||||
mat3 viewMatrix;
|
||||
mat4 projectionMatrix;
|
||||
mat4 viewMatrix;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 transformed = modelMatrix * vec3(aPos, 1.0);
|
||||
vec4 transformed = mat4(modelMatrix) * vec4(aPos, 1.0, 1.0);
|
||||
worldPosition = transformed.xy;
|
||||
transformed = projectionMatrix * viewMatrix * transformed;
|
||||
|
||||
gl_Position = vec4(transformed, 1.0);
|
||||
gl_Position = transformed;
|
||||
UV = tCoord;
|
||||
}
|
||||
|
||||
34
Resources/Shaders/Internal/model.frag
Normal file
34
Resources/Shaders/Internal/model.frag
Normal file
@@ -0,0 +1,34 @@
|
||||
#version 330 core
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec2 UV;
|
||||
in vec2 Pos;
|
||||
|
||||
uniform sampler2D TEXTURE;
|
||||
uniform sampler2D lightMap;
|
||||
uniform vec4 modulate;
|
||||
|
||||
layout (std140) uniform uniformConstants
|
||||
{
|
||||
vec2 SCREEN_PIXEL_SIZE;
|
||||
float TIME;
|
||||
};
|
||||
|
||||
uniform vec2 TEXTURE_PIXEL_SIZE;
|
||||
|
||||
[SHADER_HEADER_CODE]
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 FRAGCOORD = gl_FragCoord;
|
||||
|
||||
vec4 COLOR;
|
||||
|
||||
[SHADER_CODE]
|
||||
|
||||
FragColor = COLOR * modulate;
|
||||
|
||||
if (FragColor.a < 0.5)
|
||||
discard;
|
||||
}
|
||||
41
Resources/Shaders/Internal/model.vert
Normal file
41
Resources/Shaders/Internal/model.vert
Normal file
@@ -0,0 +1,41 @@
|
||||
#version 330 core
|
||||
|
||||
// Vertex position.
|
||||
layout (location = 0) in vec3 aPos;
|
||||
// Texture coordinates.
|
||||
layout (location = 1) in vec2 tCoord;
|
||||
|
||||
out vec2 UV;
|
||||
out vec2 Pos;
|
||||
|
||||
// Maybe we should merge these CPU side.
|
||||
// idk yet.
|
||||
uniform mat4 modelMatrix;
|
||||
layout (std140) uniform projectionViewMatrices
|
||||
{
|
||||
mat4 projectionMatrix;
|
||||
mat4 viewMatrix;
|
||||
};
|
||||
|
||||
layout (std140) uniform uniformConstants
|
||||
{
|
||||
vec2 SCREEN_PIXEL_SIZE;
|
||||
float TIME;
|
||||
};
|
||||
|
||||
// Allows us to do texture atlassing with texture coordinates 0->1
|
||||
// Input texture coordinates get mapped to this range.
|
||||
uniform vec4 modifyUV;
|
||||
|
||||
[SHADER_HEADER_CODE]
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 VERTEX = projectionMatrix * viewMatrix * modelMatrix * vec4(aPos, 1.0);
|
||||
|
||||
[SHADER_CODE]
|
||||
|
||||
gl_Position = VERTEX;
|
||||
Pos = (VERTEX.xy + 1) / 2;
|
||||
UV = mix(modifyUV.xy, modifyUV.zw, tCoord);
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec2 UV;
|
||||
in vec2 Pos;
|
||||
|
||||
uniform sampler2D TEXTURE;
|
||||
uniform sampler2D lightMap;
|
||||
@@ -26,8 +27,7 @@ void main()
|
||||
|
||||
[SHADER_CODE]
|
||||
|
||||
vec2 lightSampleUv = (FRAGCOORD.xy * SCREEN_PIXEL_SIZE);
|
||||
vec3 lightSample = texture(lightMap, lightSampleUv).rgb;
|
||||
vec3 lightSample = texture(lightMap, Pos).rgb;
|
||||
|
||||
FragColor = COLOR * modulate * vec4(lightSample, 1);
|
||||
}
|
||||
|
||||
@@ -6,14 +6,15 @@ layout (location = 0) in vec2 aPos;
|
||||
layout (location = 1) in vec2 tCoord;
|
||||
|
||||
out vec2 UV;
|
||||
out vec2 Pos;
|
||||
|
||||
// Maybe we should merge these CPU side.
|
||||
// idk yet.
|
||||
uniform mat3 modelMatrix;
|
||||
layout (std140) uniform projectionViewMatrices
|
||||
{
|
||||
mat3 projectionMatrix;
|
||||
mat3 viewMatrix;
|
||||
mat4 projectionMatrix;
|
||||
mat4 viewMatrix;
|
||||
};
|
||||
|
||||
layout (std140) uniform uniformConstants
|
||||
@@ -30,7 +31,7 @@ uniform vec4 modifyUV;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 transformed = projectionMatrix * viewMatrix * modelMatrix * vec3(aPos, 1.0);
|
||||
vec4 transformed = projectionMatrix * viewMatrix * mat4(modelMatrix) * vec4(aPos, 1.0, 1.0);
|
||||
vec2 VERTEX = transformed.xy;
|
||||
|
||||
[SHADER_CODE]
|
||||
@@ -43,5 +44,6 @@ void main()
|
||||
VERTEX -= 1;
|
||||
|
||||
gl_Position = vec4(VERTEX, 0.0, 1.0);
|
||||
Pos = (VERTEX + 1) / 2;
|
||||
UV = mix(modifyUV.xy, modifyUV.zw, tCoord);
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
//shader_type canvas_item;
|
||||
uniform float outline_width = 2.0;
|
||||
// TODO: implement that hint_color thingy.
|
||||
//uniform vec4 outline_color: hint_color;
|
||||
uniform vec4 outline_color=vec4(1,0,0,0.33);
|
||||
|
||||
void fragment() {
|
||||
// I, for some reason, cannot put this comment in the top of the file.
|
||||
// Taken from the godot-demo-projects repo.
|
||||
// GODOT ENGINE
|
||||
// http://www.godotengine.org
|
||||
//
|
||||
// ************************************************************************
|
||||
//
|
||||
// Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//************************************************************************
|
||||
|
||||
vec4 col = texture(TEXTURE, UV);
|
||||
vec2 ps = TEXTURE_PIXEL_SIZE;
|
||||
float a;
|
||||
float maxa = col.a;
|
||||
float mina = col.a;
|
||||
|
||||
a = texture(TEXTURE, UV + vec2(0, -outline_width)*ps).a;
|
||||
maxa = max(a, maxa);
|
||||
mina = min(a, mina);
|
||||
|
||||
a = texture(TEXTURE, UV + vec2(0, outline_width)*ps).a;
|
||||
maxa = max(a, maxa);
|
||||
mina = min(a, mina);
|
||||
|
||||
a = texture(TEXTURE, UV + vec2(-outline_width,0)*ps).a;
|
||||
maxa = max(a, maxa);
|
||||
mina = min(a, mina);
|
||||
|
||||
a = texture(TEXTURE, UV + vec2(outline_width, 0)*ps).a;
|
||||
maxa = max(a, maxa);
|
||||
mina = min(a, mina);
|
||||
|
||||
COLOR = mix(col, outline_color, maxa-col.a);
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
render_mode unshaded;
|
||||
uniform float outline_width = 2.0;
|
||||
// TODO: implement that hint_color thingy.
|
||||
//uniform vec4 outline_color: hint_color;
|
||||
uniform vec4 outline_color=vec4(1,0,0,0.33);
|
||||
|
||||
void fragment() {
|
||||
// I, for some reason, cannot put this comment in the top of the file.
|
||||
// Taken from the godot-demo-projects repo.
|
||||
// GODOT ENGINE
|
||||
// http://www.godotengine.org
|
||||
//
|
||||
// ************************************************************************
|
||||
//
|
||||
// Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//************************************************************************
|
||||
|
||||
vec4 col = texture(TEXTURE, UV);
|
||||
vec2 ps = TEXTURE_PIXEL_SIZE;
|
||||
float a;
|
||||
float maxa = col.a;
|
||||
|
||||
a = texture(TEXTURE, UV + vec2(0, -outline_width)*ps).a;
|
||||
maxa = max(a, maxa);
|
||||
|
||||
a = texture(TEXTURE, UV + vec2(0, outline_width)*ps).a;
|
||||
maxa = max(a, maxa);
|
||||
|
||||
a = texture(TEXTURE, UV + vec2(-outline_width,0)*ps).a;
|
||||
maxa = max(a, maxa);
|
||||
|
||||
a = texture(TEXTURE, UV + vec2(outline_width, 0)*ps).a;
|
||||
maxa = max(a, maxa);
|
||||
|
||||
COLOR = mix(col, outline_color, maxa-col.a);
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.6 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user