Compare commits

..

557 Commits

Author SHA1 Message Date
Acruid
0d356eb8f7 Removed wrong assert, rebase damage? 2021-03-13 00:29:37 -08:00
Adam Coggeshall
457705ae9c Improve 3D render bounds + draw order. 2021-03-13 00:15:46 -08:00
Adam Coggeshall
a9d8fed436 Fix 3D grid culling. 2021-03-13 00:15:45 -08:00
Adam Coggeshall
72bcc4a35e Increase accuracy of angle -> direction conversons for sprites. 2021-03-13 00:15:45 -08:00
Adam Coggeshall
0f0d47c629 Make 3D sprites rotate based on camera rotation. 2021-03-13 00:15:45 -08:00
Adam Coggeshall
027e36f125 Enable depth buffer and 3D wall rendering 2021-03-13 00:15:44 -08:00
Adam Coggeshall
298efa3a91 Add 3D sprite rendering modes + very dumb mode inference system. 2021-03-13 00:15:44 -08:00
Adam Coggeshall
8c335fc5d0 Add 3D sprites. 2021-03-13 00:15:44 -08:00
Adam Coggeshall
2a2c97e5ba 3D sprites work but are untextured. 2021-03-13 00:15:43 -08:00
Adam Coggeshall
117f4a94c2 Very basic 3D maybe almost works? 2021-03-13 00:15:43 -08:00
Adam Coggeshall
a692dc7817 Progress on 3D rendering (DOES NOT BUILD) 2021-03-13 00:15:42 -08:00
Adam Coggeshall
c8b2394dfb Add toggle-able 3D rendering mode. 2021-03-13 00:15:42 -08:00
Adam Coggeshall
4417f685ac Add support for 3D view/proj matrices. 2021-03-13 00:15:42 -08:00
Pieter-Jan Briers
fc9f7827d5 Remove package dir override. 2020-01-28 16:06:06 +01:00
DamianX
8e19f7f14c Workaround for the discord rich presence library spamming the logs (#942) 2020-01-27 07:29:42 +01:00
Pieter-Jan Briers
ada2c3f39c Fix handling of disconnects in the integration test netmanager.
Clients would treat any message coming in as being from the server they're connected to, instead of ignoring them if they're not correct.

This made the client crash inside integration tests because messages came in while disconnected.

This fixes that.
2020-01-26 23:51:57 +01:00
Pieter-Jan Briers
11f4f3820c Skip entity drawing if we are in nullspace. 2020-01-26 18:34:40 +01:00
Pieter-Jan Briers
d3997b51e8 Add assert that function in InputSystem.HandleInputCommand is correct. 2020-01-26 03:32:12 +01:00
Pieter-Jan Briers
2a3624c89c Add debugging to ModLoader.cs 2020-01-25 23:16:16 +01:00
Pieter-Jan Briers
62b31d36a4 Uhhh try to figure out why the public server is brokn. 2020-01-25 22:41:10 +01:00
Acruid
f33f9a7b52 Move raycasting into the broadphase algorithm.
Raycasts now require a MapID so that the ray is restricted to a single map.
2020-01-25 12:14:09 -08:00
Pieter-Jan Briers
467dd0dc28 Fix threaded lazy loading of content assembly dependencies.
This is necessary because content now loads the preferences database from the thread pool. This causes the assembly loads for that (they're lazy by the runtime) to run in that thread, which means that the resolver callback we set up in ModLoader did not work (it has to do an IoC resolve).

This change creates a new AssemblyLoadContext for every ModLoader and as such we can tie the loading in said context to a specific ModLoader, thus cutting out the need for a static IoC resolve.

This also paves the way to assembly unloadability a bit.
2020-01-25 20:39:07 +01:00
Pieter-Jan Briers
768121bc57 Fix popups going off-screen with a new PopupContainer. 2020-01-25 17:26:37 +01:00
Pieter-Jan Briers
3d11cf2f87 No running AssemblyTypeChecker unless necessary, use less dumb byte copies. 2020-01-25 16:27:30 +01:00
Acruid
4eb29a9e80 Removed GridCoordinates.ConvertToGrid because it is completely pointless.
Removed GridCoordinates.ToWorld in preparation for removing Map Default Grids.
2020-01-25 01:37:37 -08:00
Acruid
42932b3ff6 Adds IMapGrid.CollidesWithGrid() which tests if a point is actually inside a non-empty tile. 2020-01-24 17:10:05 -08:00
Acruid
9f956cef95 Renamed SpawnEntityAt to SpawnEntity.
SpawnEntity now throws an exception if an invalid GridID is passed in the coordinates.
2020-01-24 15:44:08 -08:00
Acruid
bd7b316f1d Pulled all entity spatial queries up from client/server EntityManagers to shared EntityManager. 2020-01-24 14:53:12 -08:00
Acruid
df9be436c4 Removed the StateType property from every component. This field was completely unused except for a debug assertion. 2020-01-24 14:07:46 -08:00
Pieter-Jan Briers
6870cef9e6 Fix YamlException handling in PrototypeManager.LoadDirectory 2020-01-24 16:38:43 +01:00
Pieter-Jan Briers
5fd0718f6a Add error log to SpriteSpecifierExt.Frame0. 2020-01-24 16:31:46 +01:00
Pieter-Jan Briers
343667442b Make MarshalHelper.cs use .NET Core 3 Marshal functions. 2020-01-24 13:18:39 +01:00
Pieter-Jan Briers
9fd675a8b9 Handle SIGTERM on Linux again. 2020-01-24 01:33:31 +01:00
Pieter-Jan Briers
e10707982c Add assertions to Control.cs 2020-01-24 00:49:10 +01:00
Pieter-Jan Briers
4b5cf26153 Try to fix Windows builds... (#939)
* Try to fix Windows builds...

* AppVeyor stop being drunk.

* Attempt 3
2020-01-23 00:42:00 +01:00
Pieter-Jan Briers
9b8c122f03 Enable nullability for Robust.Shared.Maths 2020-01-22 23:56:13 +01:00
Pieter-Jan Briers
766e2c81e2 Fixes debug coords panel throwing in main menu.
Fixes #938
2020-01-22 23:55:41 +01:00
Pieter-Jan Briers
a4bf3161fc Clyde windowing improvements:
Pauses rendering if the window is minimized.
Fixes #931

I apologize in advanced for the non-atomic commit.
2020-01-22 23:45:12 +01:00
Pieter-Jan Briers
4a3aacedea I am a very big idiot. 2020-01-22 20:24:48 +01:00
Pieter-Jan Briers
f360978973 Fix spaces in filenames of build directory. 2020-01-22 20:23:32 +01:00
Pieter-Jan Briers
d945247f31 Add necessary infrastructure to allow content to launch game from itself.
This allows us to make Content.Client and Content.Server Exe projects so that they can be executed directly via your IDE. This'll help wtih not forgetting to do a full rebuild and such.
2020-01-22 20:16:29 +01:00
Pieter-Jan Briers
997f1c031f Use shutil.copy2 instead of shutil.copyfile for git_helper.py 2020-01-22 17:09:17 +01:00
Tad Hardesty
613368edde Fix Sonar warnings in MidiRenderer (#937) 2020-01-22 08:23:57 +01:00
L.E.D
33a62127a9 Assert for normalized direction vector (#936) 2020-01-21 23:28:37 +01:00
Pieter-Jan Briers
28fe0313d1 Added stencil testing support to shader instances. 2020-01-21 18:10:44 +01:00
moneyl
8f16b188dd Add delete key behavior to LineEdit (#934)
* Add delete key behavior to LineEdit

Pressing delete will now delete the character in front of your cursor like usual.

* Update Robust.Client/UserInterface/Controls/LineEdit.cs

Co-Authored-By: Pieter-Jan Briers <pieterjan.briers@gmail.com>

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2020-01-21 18:10:26 +01:00
DamianX
ae1e9c3a71 Entity spawn window's search bar grabs keyboard focus (#928) 2020-01-21 18:10:04 +01:00
moneyl
d1dc84c632 Fix crash when minimizing game window (#933)
Returns early if the window or framebuffer width or height = 0 to avoid dividing by zero. Checked the vector components individually instead of using `Vector2i.Equals()` because you can end up in a situation where width is non-zero and height is zero if you manually resize the window instead of using the minimize button.
2020-01-21 03:18:11 +01:00
Pieter-Jan Briers
861e19da76 Clarify terminology in debug memory panel. 2020-01-21 02:11:09 +01:00
Pieter-Jan Briers
3ab02acf46 Try to avoid server integration tests causing weird output on Travis. 2020-01-20 22:36:31 +01:00
Pieter-Jan Briers
103fca8bc7 Add MapCoordinates.Nullspace. 2020-01-20 22:26:04 +01:00
Pieter-Jan Briers
dd98f3cbad Adds IntegrationInstance.Assert to aid using assertions. 2020-01-20 22:09:15 +01:00
Pieter-Jan Briers
e7ccef53de Update NuGet dependencies. 2020-01-20 20:41:01 +01:00
Pieter-Jan Briers
4e3f5508e9 Custom command line args & CVar override on Client. 2020-01-20 20:33:11 +01:00
Pieter-Jan Briers
a2ea21c3c5 Gave custom command line parser an "unknown argument" error condition. 2020-01-20 20:32:53 +01:00
Pieter-Jan Briers
e2bbffd509 Fix CVar overriding not running ValueChanged correctly. 2020-01-20 20:32:36 +01:00
Pieter-Jan Briers
0e721feea3 Add --cvar command line option.
Also rewrote the command line parser to be manual. Removes a dependency, speeds it up, and actually makes --cvar capable of using a sane syntax.
2020-01-20 19:49:07 +01:00
Pieter-Jan Briers
ab465d2af8 Fix unit tests. 2020-01-20 18:47:44 +01:00
Pieter-Jan Briers
9b77ba4605 Fix building on release. 2020-01-20 18:40:53 +01:00
Pieter-Jan Briers
132f15b32d Rendering optimizations. 2020-01-20 17:45:33 +01:00
Acruid
6249ae8d0d Fixes issue where map entity was not being deleted from Nullspace on restart. 2020-01-20 00:04:13 -08:00
Pieter-Jan Briers
0cda9ecbee Fix sprites not cloning the serialization cache correctly. 2020-01-20 08:17:29 +01:00
Pieter-Jan Briers
ae85645e23 IRobustRandom.Shuffle<T>(IList<T>) 2020-01-19 19:07:12 +01:00
Pieter-Jan Briers
237c6e433c dumpentities command is now sorted. 2020-01-19 12:41:41 +01:00
Pieter-Jan Briers
dfc1e99092 Fix OptionButton throwing an exception when the first item added doesn't have ID 0. 2020-01-19 03:17:08 +01:00
Pieter-Jan Briers
1f0ec7fa68 Pulling down debug console no longer captures all mouse input. 2020-01-18 03:18:33 +01:00
DamianX
18f90bd125 HOME and END keys work in LineEdit (#929) 2020-01-16 13:19:47 +01:00
Pieter-Jan Briers
22cf53fd1c Optimizations:
Use PLINQ for prototype loading. Most of the time is spent reading YAML so this should help a lot.
Don't regenerate collision for every tile placed by the map loader.
2020-01-15 16:13:22 +01:00
Pieter-Jan Briers
0739367013 Fix a bunch of compiler warnings. 2020-01-15 14:50:46 +01:00
Pieter-Jan Briers
d14348dfa5 Ignore framework version warnings. 2020-01-15 14:39:21 +01:00
Pieter-Jan Briers
0348919104 Implement Slider UI control. 2020-01-15 14:10:05 +01:00
Pieter-Jan Briers
414a264ea9 Adds Range.SetAsRatio. 2020-01-15 14:10:05 +01:00
Pieter-Jan Briers
c09fc5f021 TabContainer no longer crashes on controls without name. 2020-01-15 14:10:05 +01:00
Pieter-Jan Briers
b458dd96a3 Fix Clyde erroneously culling on chunk rendering.
Fixes #912
2020-01-15 14:10:05 +01:00
Acruid
ed134da488 MapManager_Tests now work on both client and server sides. 2020-01-15 03:07:37 -08:00
Acruid
32db0f82f1 Grid chunks now use the GridChunkPartition method for generating a set of collision rectangles and their bounds.
Grid collision rectangles are now drawn as a blue overlay in the CollisionOverlay debug view.
GridChunkPartition now also returns the bounding rectangle, which is a union of all the collision rectangles.
Each IPhysShape now handles it's own debug drawing with a new method, DebugDraw.
2020-01-13 13:40:09 -08:00
Acruid
6817969c8b Adds a helper class that can partition a map grid chunk into a set of rectangles. 2020-01-13 11:23:35 -08:00
Pieter-Jan Briers
5c77c1a8b8 Color.[Try]FromHex now takes ROS<char> and no longer allocates.
Also added a test to ensure it works.
2020-01-12 01:56:27 +01:00
Acruid
30db86fae8 Collidable Components are now added to grids when they are created. 2020-01-11 15:13:15 -08:00
Acruid
78a33076f9 Merged client and server CollidableComponent into a shared version. Now shared code can add collidable components to entities. 2020-01-11 14:10:25 -08:00
Acruid
7a77fa59e2 Switched physics collision broadphase from spatial partition to Naive.
Grid->Grid collision works.
2020-01-10 15:39:34 -08:00
Acruid
22bf1516cf Adds the new PhysShapeGrid.
Grids now have their own collision group.
2020-01-09 18:26:54 -08:00
Pieter-Jan Briers
14116cdbdf Fix LayoutContainer on HiDPI. 2020-01-09 03:12:35 +01:00
Pieter-Jan Briers
74a940ca9e Apparently that's not how window scaling works in GLFW.
Fixes mouse input issues on certain non-macOS platforms.
2020-01-09 03:09:16 +01:00
Pieter-Jan Briers
7339be51fe Fix unit test. 2020-01-09 00:42:54 +01:00
Pieter-Jan Briers
dadaa3fb8f Very basic GUI animations. 2020-01-09 00:13:37 +01:00
Acruid
150c899f6f Removed generic constraints from TryGetComponent<T> to match all the other functions. 2020-01-08 15:12:24 -08:00
moneyl
928a5e3521 Fix the entity spawn panel clear button (#926)
Previously the entity spawn panel clear button caused nothing to show up. This fixes that so it rebuilds the entity list with a empty search.
2020-01-08 17:37:13 +01:00
ShadowCommander
5037ace00b Fix mouse input on HiDPI monitors (#927) 2020-01-08 11:50:25 +01:00
Pieter-Jan Briers
3faa52ee01 Call MinimumSizeChanged on AddChild and RemoveChild. 2020-01-05 15:47:27 +01:00
Pieter-Jan Briers
7d8992e0ca Some doc comments for type abbreviations. 2020-01-05 15:42:20 +01:00
Pieter-Jan Briers
131a1ee3bd Type Abbreviation utility.
Just to neaten up VV a little.
2020-01-05 01:51:25 +01:00
Acruid
ba390ba466 Hopefully fixes the client freezing when a GameState is lost in transit (or is never sent). 2020-01-04 16:19:19 -08:00
Pieter-Jan Briers
a69738a7a4 Terrible fix for physics crashes. 2020-01-05 00:48:45 +01:00
Acruid
8d30bcb041 Added a ShowContents flag to containers so that the contents can be rendered.
Added `bool TryGetContainer(IEntity, out IContainer)` to containers.
Changed the API of ContainerHelpers.
2020-01-03 15:16:07 -08:00
Pieter-Jan Briers
da579d6b57 Replace a glBufferSubData call with a glBufferData call.
No real reason to subdata this.
2020-01-02 11:16:18 +01:00
Pieter-Jan Briers
4e6906fa7f Remove unused code in Clyde.Windowing.cs 2020-01-02 02:04:08 +01:00
Pieter-Jan Briers
45c77e10a1 Console command to add component to entity. 2020-01-02 02:04:08 +01:00
Acruid
4a900cbd7f Removed IoCManager.Resolve calls from IMapGrid. 2019-12-29 23:20:36 -08:00
Acruid
9b5b8205b9 Renamed GridCoordinates.Nullspace to GridCoordinates.InvalidGrid, because it has nothing to do with Nullspace anymore. 2019-12-29 18:12:29 -08:00
Acruid
37aee07596 Rename GridId.Nullspace to GridId.Invalid, because it has nothing to do with Nullspace anymore. 2019-12-29 18:02:02 -08:00
Acruid
58d0a771e8 TransformComponent.GridID now returns GridID.Nullspace instead of throwing when the entity in question is not on a grid.
Added MapManager.Restart().
Added MapManager.CreateNewMapEntity() and MapManager.SetMapEntity() for manipulating the map root entity.
You can now spawn entities directly into Nullspace, after setting up the Nullspace map entity.
2019-12-29 16:08:46 -08:00
Pieter-Jan Briers
aa3e126249 Fix dump entities command blowing up due to grid entities. 2019-12-29 01:20:43 +01:00
Pieter-Jan Briers
1c39a36297 Fix SpriteComponent not respecting SetAutoAnimated anymore. 2019-12-29 01:20:31 +01:00
Pieter-Jan Briers
259f6c8ea4 Fix bullets crashing the server.
This is not a proper fix. A proper fix would be a better physics engine.

But as it stands I really wanna get a progress report out and having to refactor physics to do it would just suck.
2019-12-29 01:06:57 +01:00
Pieter-Jan Briers
6d8bfcc7bb Avoid breaking batching on every shader change.
This fixes batching not working for sprite layers. They'd set & reset the active shader constantly which broke batching.

Active shader is now part of batch meta data and broken like other data like textures.
2019-12-28 13:25:28 +01:00
Pieter-Jan Briers
900910e4de Fix crime of using static for stock Textures. 2019-12-28 12:52:19 +01:00
Pieter-Jan Briers
3f979ef7f2 Fix crash on server shutdown.
This also fixes integration tests.
2019-12-28 12:45:29 +01:00
Acruid
1a4196697f Refactors HandleEntityState off of Entity.
Refactors GetEntityState off of Entity.
IComponentManager.GetNetComponents(EntityUid) now returns deleted entities.
2019-12-27 21:41:12 -08:00
Pieter-Jan Briers
a76191c138 Use R11FG11FB10F for lighting framebuffer.
This halves the memory necessary for the lighting framebuffer, so probably helps with bandwidth usage (especially on integrated GPUs) too.

I couldn't notice a decline in visual quality on my (admittedly) bad laptop screen.
2019-12-28 03:28:41 +01:00
Pieter-Jan Briers
cb563c75fd Update map loader to work with grid entities. 2019-12-28 03:22:09 +01:00
Pieter-Jan Briers
472bd67ace Fix edge sliding.
The "too close" threshold on Transform WorldPosition set was way too high, so the low movement speed when edge sliding was seen as not moving at all.
2019-12-24 15:26:23 +01:00
Pieter-Jan Briers
2f94beb4b5 Fix ContainerManagerComponent.ContainsEntity not returning correct results for multiple containers. 2019-12-24 15:16:14 +01:00
Pieter-Jan Briers
47d4a8f628 Improve ModLoader to fix loading issues for Dapper.dll 2019-12-24 02:52:38 +01:00
Pieter-Jan Briers
3c08f56619 Sprite orientation improvements (#917)
* Fold animation delays into a single set for all directions.

* Update systems to use new RSI animations API.

* Fetching layer directions now done in sprite render.

* Allow overriding direction in SpriteView.
2019-12-24 01:15:44 +01:00
Pieter-Jan Briers
761b06d68a Add threading assertions to IoCManager. 2019-12-22 21:47:00 +01:00
Pieter-Jan Briers
2b037c3bf2 Synchronize containers to the client. 2019-12-22 21:43:03 +01:00
Pieter-Jan Briers
f2c8b343bb Fix initialize not getting called for components added during initialize. 2019-12-22 21:42:30 +01:00
Pieter-Jan Briers
531cfeb9e6 KVPair<K, V> now shows in VV. Client only. 2019-12-22 21:38:21 +01:00
Pieter-Jan Briers
21b29e26e2 Fix a bunch of warnings. 2019-12-22 13:50:29 +01:00
Pieter-Jan Briers
2b8645b60f Fix some Robust.Server namespaces in Robust.Shared. 2019-12-22 13:40:43 +01:00
Acruid
f5c0dba194 Map & Grid Entities (#916)
* Adds Map components to the ECS system.

* Grid entities are now created along with map grids.
Grid components are now properly reused from map deserialization when a grid is created through the MapManager.

* Make MapGridComponent shared.
Don't send Nullspace default grid to client, they have their own.
Properly link the new grid with the entity sent from the server.

* Fixes nullRefException when ToString() is called on an Entity with no Prototype.

* Adds logging debug info about binding a map/grid to an entity.
Nightly Commit.

* Client map networking now properly pivots a grid from the client entity to the shared entity.
Added IMapGridComponent.ClearGridId() to properly dissociate the component from a grid before deleting it.
WorldPosition of a default grid is always 0,0 regardless of the entity transform (if any).
Nullspace map and default grid are not bound to an entity.
Nullspace map and default grid cannot be deleted.

* Map Entities are now created along with new maps.

* Client & Server load with new scene hierarchy.

* Fix rebase damage.

* Added ContainerHelpers helper class.

* Fix Container checks.

* Fixed clothes.

* Fixing unit tests.

* Removed disabled code.

* Actually initialize and startup the Map and Grid entities.
2019-12-21 22:11:17 +01:00
Acruid
2c7630f4f1 Adds assertions in various places to make sure entities are being initialized properly before the game state is built. 2019-12-19 11:16:43 -08:00
Pieter-Jan Briers
610bfea95c Clyde improvements.
Reduced the amount of buffer data calls to the OpenGL driver significantly, cleaned some code up to make it easier to extend Clyde.
2019-12-18 12:21:52 +01:00
Pieter-Jan Briers
6c0c395dc7 Remove lite stuff from Clyde. 2019-12-17 19:25:05 +01:00
Pieter-Jan Briers
99f96aee27 Remove Robust.Lite 2019-12-17 16:09:55 +01:00
Pieter-Jan Briers
d075c82041 Switch to C# 8 2019-12-17 16:06:46 +01:00
DamianX
f71d72d88c Added Sqlite dependency (#915) 2019-12-17 15:58:21 +01:00
Acruid
df34ce025a Entities now require a location when being spawned. 2019-12-16 21:43:24 -08:00
DamianX
5ff164e762 Expose IWritableDirProvider.RootDir (#913)
* Expose IWritableDirProvider.UserDir

* Update WritableDirProvider.cs
2019-12-16 09:56:37 +01:00
Pieter-Jan Briers
9f7a1e066b Try to fix crash loop on game server 2019-12-16 01:03:55 +01:00
Pieter-Jan Briers
58dcea5bda Try to fix AppVeyor. 2019-12-15 22:31:29 +01:00
Pieter-Jan Briers
3f0032911a Try to fix travis.. 2019-12-15 22:28:33 +01:00
Pieter-Jan Briers
c8c17da176 Remove reference to System.Net.Http. 2019-12-15 22:26:48 +01:00
Pieter-Jan Briers
08ba611fe6 Forgot to commit the travis script. 2019-12-15 22:24:33 +01:00
Pieter-Jan Briers
7442f52297 Try to fix CI. 2019-12-15 22:22:24 +01:00
Pieter-Jan Briers
ba80ba5cc1 Try to fix CI. 2019-12-15 22:17:18 +01:00
Pieter-Jan Briers
1db0694541 Try to fix CI. 2019-12-15 22:13:54 +01:00
Pieter-Jan Briers
f6b894f274 .NET Core time. 2019-12-15 16:01:08 +01:00
Pieter-Jan Briers
52e5afd277 Switch to GLFW for windowing (#914)
* Use GLFW instead of OpenTK windows

* Seems to work pretty well now.

* Fix stackalloc issue on Framework.

* Add GLFW project to sln.

* Fix package downgrade.

* Fix SLN more.

* Please work.

* Fix C# version error.
2019-12-15 15:53:30 +01:00
Pieter-Jan Briers
1899544500 Server optimizations.
1. NetManager.IsConnected no longer uses LINQ.
2. creating net messages for sending/receiving now uses cached DynamicMethods to improve speed (bypasses Activator.CreateInstance and params allocations)
3. Entity.GetComponentStates uses GetNetComponents now.
4. PhysicsManager allocates significantly less now.
2019-12-11 17:08:46 +01:00
Pieter-Jan Briers
f893d308ad Cut cruft from DebugCoordsPanel. 2019-12-11 07:50:19 +01:00
Pieter-Jan Briers
2fc8e6af46 Remove dependency on ConcurrentDataStructures by pulling in their PriorityQueue<T> implementation. 2019-12-11 07:16:52 +01:00
Pieter-Jan Briers
3095952dcb Use our own SpaceWizards.SharpFont for better .NET Core support. 2019-12-11 06:46:26 +01:00
Acruid
ea8e5e9fe7 EventBus Refactor (#909)
* Extracts the ECS event system out of EntityManager, and into a new class called EventBus.
XML Docs and full test coverage for EventBus.
2019-12-08 19:36:52 -08:00
Pieter-Jan Briers
026f6cb118 Use new icon 2019-12-06 17:38:08 +01:00
Pieter-Jan Briers
12787db8de Avoid crash in Clyde if the GLSL compiler optimizes out uniforms. 2019-12-06 02:29:58 +01:00
Pieter-Jan Briers
31fb926127 Remove selection outline code from ClickableComponent 2019-12-06 01:18:37 +01:00
Pieter-Jan Briers
66ea13684b Remove GameScreen from engine. 2019-12-06 00:40:37 +01:00
Pieter-Jan Briers
69ff3638ba Make framegraph not catch clicks. 2019-12-06 00:10:14 +01:00
Pieter-Jan Briers
6cfe6caae2 guidump lists attached properties. 2019-12-05 15:37:11 +01:00
Pieter-Jan Briers
ab1f4fb0e7 UI layout v2. (#908)
* UI layout v2.

All controls now act like containers.
Moved anchor/margin layout model to LayoutContainer

Implement basic WPF-like attached properties for the above LayoutContainer.

* Fix VV.
2019-12-05 13:37:58 +01:00
Pieter-Jan Briers
9b15070126 Remove allocations from PhysicsSystem HandleMovement.
LINQ is bad alright.
This removes approx 20% of allocations on the server.
2019-12-04 13:48:45 +01:00
Pieter-Jan Briers
4eb100076d Entity spawn window no longer lags when opening. 2019-12-04 13:26:37 +01:00
Pieter-Jan Briers
6156a9eae8 Fix crash on detaching from deleted entity. 2019-12-04 02:16:20 +01:00
Pieter-Jan Briers
2e762fbaf4 Give RSISchema.json a logical name in the csproj.
This *should* fix random occurrences of the compiler putting it somewhere else and the schema failing to load.
2019-12-01 15:15:57 +01:00
Pieter-Jan Briers
dec9ea744d Static localization manager class for convenience. 2019-12-01 15:13:00 +01:00
Pieter-Jan Briers
89094458cd Add documentation to ILocalizationManager 2019-12-01 15:12:35 +01:00
Pieter-Jan Briers
31adf9e4fc Mention thread locality in IoCManager documentation. 2019-12-01 15:12:06 +01:00
Pieter-Jan Briers
563cc262cb Add !Deleted assertion to Entity.GetComponent() 2019-12-01 15:08:53 +01:00
Pieter-Jan Briers
13ef4e8423 Various optimizations focused on the entity spawn panel:
Give BoxContainer a preset capacity to reduce allocations in layout.

Removed Control.GetChild(string) and similar. This was no longer used (and was a pretty bad idea in general), and the implementation had a lot of wasted book keeping to do.

Use UpdateLayout() instead of DoUpdateLayout() in Control minsize changed to avoid doing redundant layout, and by extension style & minsize, updates.

Used RemoveAllChildren instead of DisposeAllChildren in EntitySpawnWindow because it's faster (way less stuff to clear, just let the GC handle it).

Optimized ResourcePath with a better GetHashCode(), better Equals, replacement for List<T>.ToArray()

Fixed enumerator allocations in stylesheet SelectorElement matching to speed up style updates.

ResourceCache now caches fallbacks to avoid constructing Resource instance when fetching fallback explicitly.

ResourceCache now has nested dictionaries for Type -> ResourcePath -> BaseResource storage of resources.

Use calculated property instead of auto property for TextureResource.Fallback
2019-11-28 14:19:02 +01:00
Pieter-Jan Briers
f3669e6646 Sound system improvements.
This just makes the sound system more flexible so content can do more stuff.
2019-11-27 00:33:54 +01:00
Acruid
d9a411b260 Shared IMap/Map class removal (#904)
* Moved IMap from Shared/Interfaces/Map to Shared/Map namespace.

* Extracted Map class out of the MapManager class.

* Removed the Map class and interface.

* Fully removed the Map and IMap class.
2019-11-26 20:47:04 +01:00
Acruid
9de0c9b299 Adds the RemoveMap concommand rmmap to the engine.
Adds the RemoveGrid concommand `rmgrid` to the engine.
2019-11-25 23:13:07 -08:00
Acruid
73e89f9e27 Fixes a bug where the using the TP player command with a destination on top of a grid resulted in the player teleporting to the wrong location. 2019-11-24 15:45:01 -08:00
Peter Wedder
063c30e2bf Scrollbar minimum size (#903) 2019-11-24 11:35:52 +01:00
ShadowCommander
1263e10f5e Add exception to catch rendering deleted entities in UI (#902) 2019-11-24 10:44:42 +01:00
Pieter-Jan Briers
36822462ba Improve ray debug drawing.
Fixes unit tests.
Made ray color change if successful hit.
Made ray length based on actual ray results.
2019-11-24 00:44:47 +01:00
Ephememory
519c28cad2 Add a DebugDrawingManager for drawing server side events like Ra… (#892)
* add basis for debug drawing raycasts

* rays

* this was too much work

* i assumed you could do string object stuff. you cant.

* fixed a crash

* Greatly improved DebugDrawingManager code with a struct and list as opposed to dictionary

* change default ray debug color from green to magenta

* reviewed changes

* reviewed changes and adds network message to physicsmanager so it works without much user config
2019-11-23 13:09:48 +01:00
Acruid
e82f969589 Adds missing using statement, Master compiles again. 2019-11-22 15:04:29 -08:00
DamianX
c67a1475f9 Added Color.TryFromHex (#900) 2019-11-22 19:50:58 +01:00
Pieter-Jan Briers
1353dde41d Implement shader instances and uniforms. 2019-11-22 17:55:39 +01:00
Pieter-Jan Briers
a9ce50a6a5 Invert icon cutout.
This fixes the ugly border around the exported png.
2019-11-22 12:53:09 +01:00
ShadowCommander
134141feaf Implement SpawnRepeating (#898)
* Implement SpawnRepeating

Allows repeating timer events to be used.

* Update doc comments
2019-11-21 23:21:14 +01:00
DamianX
844e9776f3 Public YamlMappingFix (#897) 2019-11-21 20:27:19 +01:00
Ephememory
cbe2fe698a Fix window width/height being equal to 0 equal game crash (#896)
* Fix window width/height being equal to 0 equal game crash

* suggested changes
2019-11-18 19:11:55 -08:00
Pieter-Jan Briers
da440bbf28 Use new logo 2019-11-18 00:51:07 +01:00
Pieter-Jan Briers
5025178203 Very shitty allocation rate tracker. 2019-11-17 22:31:21 +01:00
ShadowCommander
1493f67c94 Add to OptionButton and SpinBox (#893)
* Add prefix to OptionButton

* Add validation to SpinBox
2019-11-17 18:38:56 +01:00
Pieter-Jan Briers
07b0548532 Input monitor. 2019-11-17 17:28:20 +01:00
bgare89
d3e7e12adf Code smell for loop braces (#884)
* Use curly braces or indentation to denote the code conditionally executed by this 'for'

* 7 less code smells.
2019-11-13 22:42:27 +01:00
Pieter-Jan Briers
89f6a0917a I'm bad at coding 2019-11-12 19:36:59 +01:00
Pieter-Jan Briers
a3879b7bbd Remove outline shaders from engine 2019-11-12 18:47:39 +01:00
Pieter-Jan Briers
64112c556e Work to make the client launchable by launcher. 2019-11-11 08:36:13 +01:00
bgare89
a7abfcdf0f CodeSmell: The variable 'e' is declared but never used (#883) 2019-11-10 16:39:14 +01:00
Pieter-Jan Briers
344325c9a4 Enable status always, add connection redirect address to status under /info. 2019-11-09 13:21:23 +01:00
Víctor Aguilera Puerto
ffe506ef94 Adds Midi playback, Midi input, etc. (#873)
* raw PCM audio for clyde

* Remove soundfont.cs

* Midi stuff

* Some more work

* This actually works now!

* update

* Add nfluidsynth submodule.

* fuck

* Midi audio works!

* Lots of stuff, and cool interfaces for items

* Update

* Note limit

* Moving out of range of UI raises OnClosed now as well

* It just works

* Update nfluidsynth submodule

* Remove managed-midi, remove unused methods I added to clyde

* Remove remnants of older NFluidsynth

* Update nfluidsynth submodule.

* Fix some of MidiManager

* Add changes PJB made to soundfont loading

* Delete OpenAL source/buffers when disposed

* Remove remnants of "Rendering"

* Use ReadOnlySpan, make interface/implementation arguments consistent

* Improve EmptyBuffers performance

* Make renderers use an enum for their status

* MidiRenderer events are now invoked on the main thread

* MidiManager now has a method to dispose renderers

* Lock player

* Fun stuff

* Update nfluidsynth submodule.

* Fix midi audio rendering

* Address a few reviews

* Revert changes made to Clyde

* Create sfloader per midi renderer

* Midi file size check

* Now OpenMidi/OpenInput and their respective close methods return bools.

* Update nfluidsynth submodule.

* Move number to constant.

* Use BufferedAudioSource

* Remove unused using statements

* Use new API

* Lock player and synth correctly

* Use midi sawmill

* Adds "Disposed" property to MidiRenderer

* Remove DisposeRenderer, let midi render thread handle it instead

* Renderer position is updated from main loop

* Use nfluidsynth from nuget

* Fix appveyor, lazy fluidsynth init

* Only join MidiThread if it actually exists...
2019-10-30 16:45:11 +01:00
moneyl
b105ef3e7b Add way to check permissions client-side (#880)
Added IClientConGroupController and implemented it as ClientConGroupController. Lets client-side code check what commands the client can use based on their console group. Serves the same purpose as the server-side IConGroupController except it doesn't load a list of permissions from groups.yml. Instead,  the server ConGroupController sends updated permissions to clients whenever they change.
2019-10-25 12:00:32 +02:00
Pieter-Jan Briers
a7d7fdd12b Fix crash apparently. 2019-10-22 18:55:12 +02:00
Pieter-Jan Briers
86be98005c Some engine optimizations. 2019-10-22 18:05:08 +02:00
DamianX
6e621f6398 Scrollbars properly handle clicks (#881) 2019-10-20 01:45:31 +02:00
Pieter-Jan Briers
5c550888f6 Fix DefaultSeparation in BoxContainer being hardcoded. 2019-10-20 01:36:04 +02:00
Pieter-Jan Briers
bc6a0f4578 Server no longer logs a warning if config file is missing.
server_config.toml should eventually be removed from the repo since defaults should be in-code.
2019-10-20 01:27:33 +02:00
Pieter-Jan Briers
e2fcf919c5 Fix changing minsize not updating controls outside containers. 2019-10-20 01:16:56 +02:00
Pieter-Jan Briers
3f1c33fc96 Implement radio buttons. 2019-10-20 00:50:35 +02:00
Pieter-Jan Briers
0494d59a5a Fix GridContainer minimum size calculation. 2019-10-19 02:13:58 +02:00
Pieter-Jan Briers
5b35e1b016 Make vv command able to vv hovered GUI control. 2019-10-19 02:13:13 +02:00
Pieter-Jan Briers
d092a63b28 Adds debug panel to show Clyde info & stats. 2019-10-18 14:28:54 +02:00
Acruid
182c4fb5dc Fix integration tests. 2019-10-17 20:55:52 -07:00
Pieter-Jan Briers
631ff903b4 Implement tiling textures in StyleBoxTexture. 2019-10-18 01:05:36 +02:00
Pieter-Jan Briers
e3d28423c5 Add some helpers for working with style sheets. 2019-10-18 01:05:36 +02:00
Pieter-Jan Briers
64b33439e5 Fix disposed controls getting deferred updates ran. 2019-10-18 01:05:36 +02:00
Pieter-Jan Briers
bf7c49041f Fix UriOpener on .NET Core. 2019-10-18 01:05:35 +02:00
Pieter-Jan Briers
68db826e8e Add + (float, float, float, float) operators to UIBox2.
Extremely convenient to work with.
2019-10-18 01:05:35 +02:00
Pieter-Jan Briers
e519b6b53d Delete some dead code. (#876)
Mostly utility classes and ancient legacy.
2019-10-17 01:52:58 +02:00
Víctor Aguilera Puerto
0a976b5438 Add BufferedAudioSource to Clyde.Audio (#877)
* Add BufferedAudioSource

* Address reviews

* Address reviews 2: Span boogaloo

* Update EmptyBuffers to use new API.

* Only map needed handles

* Delete buffers on dispose.
2019-10-17 01:52:23 +02:00
Pieter-Jan Briers
cd7a4f0b15 Clean up styleboxes and add support for padding. 2019-10-15 13:11:33 +02:00
Pieter-Jan Briers
30fff3fba5 Fix config file loading on server. 2019-10-15 13:10:51 +02:00
Pieter-Jan Briers
9d4dec2ea7 Fix SnapGridComponent not correctly cleaning up when moved between grids. 2019-10-14 17:09:28 +02:00
Pieter-Jan Briers
6e2458f708 Sort ListCommand output. 2019-10-14 14:50:05 +02:00
Pieter-Jan Briers
5c64190733 Don't use ReadOnlySpan<char> yet. 2019-10-13 23:40:41 +02:00
Pieter-Jan Briers
44ada991f2 Fix plural bugs in LocalizationManager. 2019-10-13 22:48:13 +02:00
Pieter-Jan Briers
5e37c7a746 Add BBCode-like markup parser for FormattedMessage. 2019-10-13 22:47:51 +02:00
Pieter-Jan Briers
08c4ef1ccf Fixes entity prototypes not inheriting description. 2019-10-13 17:08:27 +02:00
Pieter-Jan Briers
baf85f6ab2 Uninitialized maps are treated as paused. 2019-10-13 16:25:51 +02:00
Pieter-Jan Briers
72402f3983 Cull entity, light & chunk rendering. 2019-10-13 15:23:20 +02:00
Pieter-Jan Briers
5252b1e99b Add some extra helpers to Box2. 2019-10-13 15:22:47 +02:00
Pieter-Jan Briers
896b664590 Make ItemList ScrollFollowing default to false. 2019-10-13 01:27:14 +02:00
Pieter-Jan Briers
381efbd857 Any focusing input drops current mouse focus. 2019-10-13 01:27:04 +02:00
Pieter-Jan Briers
be2904ca17 Fix Scrollbar and ItemList while placement is active. 2019-10-12 23:27:28 +02:00
Pieter-Jan Briers
414177973d Fix SS14Window handling with UI Scaling applied. 2019-10-10 17:23:36 +02:00
Pieter-Jan Briers
8aaacce195 Fix TextureRect and TextureButton UI scaling.
Thanks to nirnael for helping me investigate this and getting me to do it.
2019-10-10 17:14:00 +02:00
Pieter-Jan Briers
6ecd86b9af Fancy animation for debug console opening. 2019-10-10 16:18:57 +02:00
Pieter-Jan Briers
324770630d Reduce speed of scrollbar animation.
Makes it way easier to track for me.
2019-10-10 16:17:27 +02:00
Pieter-Jan Briers
78ebf99296 Fix a compiler warning. 2019-10-10 15:48:00 +02:00
Pieter-Jan Briers
ac254c3eac Add TypeHelpers.GetAllNestedTypes 2019-10-10 12:14:58 +02:00
moneyl
9d8d712aea Make IConGroupController and ConGroupIndex public so they can be used in content (#875)
By making these public they can now be used by content to check if players are in the right group (admin, mod, etc) before doing certain things. Required for PR 380 on content (https://github.com/space-wizards/space-station-14/pull/380)
2019-10-09 23:39:11 +02:00
Pieter-Jan Briers
dc2c139692 Actually run MarshalHelper_Test. 2019-10-08 00:50:51 +02:00
Pieter-Jan Briers
6fdb09aa06 Show collections count in memory debug. 2019-10-08 00:50:20 +02:00
Pieter-Jan Briers
ce44aa0060 Make ResourceManager thread safe. 2019-10-06 23:14:28 +02:00
Pieter-Jan Briers
5baf2678c3 Update NetSerializer to latest version. 2019-10-05 15:37:48 +02:00
Pieter-Jan Briers
650b93ce37 Fix PlayerStatusChanged old value being the new value. 2019-10-02 10:44:31 +02:00
Pieter-Jan Briers
9f20366c43 Adds IEntity.EnsureComponent extension methods. 2019-09-25 00:25:59 +02:00
Pieter-Jan Briers
333801b1c9 TypeEntityQuery improvements.
Added TypeEntityQuery<T> which requires T : IComponent
Added an assert to TypeEntityQuery so the type must inherit IComponent.
2019-09-25 00:25:23 +02:00
Pieter-Jan Briers
7067c120ed Mark PrototypeAttribute as MeansImplicitUse. 2019-09-24 23:07:14 +02:00
Pieter-Jan Briers
9868f186f3 Remove some unecessary NuGet dependencies. (#871)
Also made the window icon work again.
2019-09-24 12:42:59 +02:00
moneyl
56f566af7b Add support for OnMouseEntered and OnMouseExited actions to Cont… (#870)
Allows adding custom hover & mouse enter/exit behavior to a control without creating a derived class for control or modifying an existing one.
2019-09-22 18:04:27 +02:00
DamianX
437fd04e87 AnimationTrackSpriteFlick ignores missing RSI states (#869)
* AnimationTrackSpriteFlick ignores missing RSI states

* changed the thing
2019-09-21 23:19:56 +02:00
Acruid
72f7310890 Entities without a prototype were causing an exception in the MetaDataComponent networking. 2019-09-20 13:15:59 -07:00
DamianX
7dde058319 Removed debug message from ItemList (#868) 2019-09-19 16:53:20 -07:00
Acruid
55a50ff7ba Setting the Component.Running property now calls the Startup/Shutdown methods automatically. Startup/Shutdown are now protected. This makes the system more foolproof, previously if the component did not call the base method inside Startup/Shutdown, everything would break. This also allows a component to be started/stopped from the VV system by simply setting the property. 2019-09-18 11:24:15 -07:00
Acruid
1da37d24ae Removes the old obsolete input system where the state system directly handles input. Everything is using the InputManager/InputSystem now. 2019-09-17 16:24:10 -07:00
Acruid
81641f49dc Command handlers now return a boolean signaling if the command was "handled" or not. This allows clientside handlers to intercept input commands and optionally handle them before they are sent to the server. Previously, registering a clientside handler would completely block the input command from being sent to the server. 2019-09-17 16:04:26 -07:00
Pieter-Jan Briers
5d5b897a9b Property animations track (#867)
* WiP property animations system

* Use better lerp for Angle property animations.

* Fix handling of offset in sprite component.

* Allow animating some sprite layer properties.

* Allow animating some Transform properties.

Obviously not advisable for server entities, but great for client side entities!

* Improve animation property interpolation handling.

Added a "previous" mode.
Made values that cannot be sanely interpolated fall back to this mode.

* Improve some animation docs.
2019-09-17 22:57:12 +02:00
Pieter-Jan Briers
65a8d33d0c Optimize YamlHelpers to avoid allocations by using a thread local. 2019-09-17 15:38:03 +02:00
Pieter-Jan Briers
b397a43845 Implement light masks. 2019-09-17 15:24:14 +02:00
Pieter-Jan Briers
2651a3db56 Texture loading improvements.
Can load non-sRGB Gray8 images.
Allow disabling sRGB on textures.
2019-09-17 15:24:13 +02:00
Acruid
2fc636b7b9 The YamlSerializer now properly checks that the type is an enum. Previously it checked if the typed equaled Enum, which isn't the same thing and is always false. 2019-09-16 16:26:33 -07:00
Acruid
fd47179d79 The intention was to delete the key, not set it to null. Previously if ContainerManagerComponent.ForceRemove was called multiple times with a Deleted container, it would throw a NullRefException. 2019-09-16 16:24:47 -07:00
Acruid
6ed7684954 Reverts 00f982cb89.
Reverts b40413dfd6.
Decorates EntityPrototype.Name with CanBeNull.
The entity spawn window now properly handles prototypes with null names. Previously, a null name would throw a NullException. Entities with null names will never show up in the spawn window search results.
2019-09-16 13:08:59 -07:00
Acruid
b40413dfd6 Fixes issue with prototype parent's name not being deserialized properly. This fixes the failing unit test. 2019-09-16 12:17:26 -07:00
Pieter-Jan Briers
3d2228e64e Add a command to spawn entities client side. 2019-09-16 20:57:00 +02:00
Acruid
60fa8080c4 Properly implements the Concrete Type Tag system for serialization. 2019-09-16 11:13:09 -07:00
Acruid
11046f8068 Apply a work-around fix to a bug in the current version of YamlDotNet, where it would not serialize Tags on a mapping. 2019-09-16 11:08:37 -07:00
Acruid
8a61259c11 Renames the yaml key name for the BodyType on CollidableComponent so that it does not collide with the component type field. This previously caused deserialization to fail. 2019-09-16 11:06:33 -07:00
Acruid
7239e70294 When an item is inserted into a container, it's LocalPosition is set to (0,0). This causes the position of the contained entity to == the container's position. Entities are now spatially inside their containers. Previously, the local position was not set, so contained entities could be tens of meters away from their containers, preventing things like FindInSphere from working intuitively. 2019-09-15 14:47:09 -07:00
Pieter-Jan Briers
00f982cb89 Entity prototypes default to empty name instead of null 2019-09-15 20:15:07 +02:00
ShadowCommander
d08823322a Implemented SpinBox and added a filter to LineEdit (#866)
* Implemented SpinBox and added a filter to LineEdit

* Update SpinBox.cs

* Added requested changes and summaries
2019-09-15 20:07:28 +02:00
Víctor Aguilera Puerto
7fc99ee528 Improved ItemLists (#863)
* Improve ItemList

* Address reviews

* Items can only be at one ItemList at a time

* Nested Item class
2019-09-13 15:23:04 +02:00
DamianX
dc57178258 Added FirstOrDefault extension method (#865) 2019-09-11 23:11:12 +02:00
Pieter-Jan Briers
b87adb2294 Actually use SpriteComponent.Offset for rendering. 2019-09-11 20:02:54 +02:00
Acruid
e2c60871e9 ContainerManagerComponent now checks if the container is deleted before trying to remove an entity from it. Previously it would blindly call ForceRemove on a deleted container, causing a NullRefException.
Added some debug assertions to Container. These should help verify that a deleted container is not being accessed.
2019-09-09 12:22:32 -07:00
Acruid
c8ff91bf72 Entity Containers now raise a ContainerContentsModifiedMessage Component Message when their set of entities is modified.
Code cleanup in Container.cs
2019-09-09 10:37:10 -07:00
Pieter-Jan Briers
1108fd94ce Add Vector3 & 4 support to YamlObjectSerializer. 2019-09-09 16:20:33 +02:00
Pieter-Jan Briers
73a34fc53a Use DynamicMethod for dependency injection. (#864)
* Use DynamicMethod for dependency injection.

Should be way faster to initialize types and also have no allocation overhead

* Cleanup, don't make injectors for types without dependencies

* Fix Framework, maybe?

* Test the new system explicitly.
2019-09-09 01:43:22 +02:00
Pieter-Jan Briers
64ff64ea77 Add command to dump memory usage on server. 2019-09-08 21:06:41 +02:00
Pieter-Jan Briers
566ed9cbdc Fix EffectSystem timing.
The bug with effects dying in transit has since been fixed,
so proper timing can be re-added.
2019-09-06 22:42:14 +02:00
DamianX
782f36ee63 Create BoundUserInterfaces with DynamicTypeFactory (#862) 2019-09-06 15:05:37 +02:00
DamianX
f05f3eec3e Added PopupRoot to draw popup messages above UI windows (#861) 2019-09-06 10:04:17 +02:00
Acruid
240c9a2df0 Removes EyeComponent's reliance on TransformComponent.OnMove. Now is uses an EntitySystem that is ran every frame. (#860)
Refactored some functions off of Eye, removed the IEyeManager dependence from it.
2019-09-06 08:09:49 +02:00
Acruid
ea18d6983e If the current map an eye is on does not exist, fallback to the default eye's map. Previously Clyde would throw an exception, crashing the process. 2019-09-05 16:08:57 -07:00
Acruid
ebc7c1ab3f Removed the LocalPlayer.EntityMoved event. This was unused and has known issues. 2019-09-05 16:04:33 -07:00
Acruid
4d30d5af78 TransformComponent now properly rebuilds its matrices on startup. This resolves https://github.com/space-wizards/space-station-14/issues/224.
Fixed bug with ParentChangedMessage using the wrong entity in its OldEntity argument.
2019-09-05 16:00:41 -07:00
Acruid
dba0815585 When an entity is deleted, its children are now implicitly deleted as well. Previously, the children were orphaned onto the map. This resolves space-wizards/RobustToolbox/#855. 2019-09-04 11:44:27 -07:00
Acruid
5b3aaea5ec A null event handler delegate cannot be subscribed to an event type.
Resolved https://github.com/space-wizards/RobustToolbox/issues/575.
2019-09-03 13:36:52 -07:00
Acruid
58aac5ea2b Refactored the entity event handling spaghetti.
Renamed some of the code regions to better reflect what the functions were a part of.
2019-09-03 13:32:11 -07:00
Acruid
f2eb035ed8 Physics Shapes (#847)
* Adds a new IPhysicsShape object where you can define what collisions shape a PhysBody has.
AABB is now accessed through the PhysicsShape, so the BoundingBoxComponent is not required.

* Default PhysShape now copies the AABB of the BoundingBoxComponent.

* Fixed issue with serialization of PhysShapeAabbComp.

* Spatial queries now use ICollidableComponent instead of BoundingBoxComponent.
showbb now draws entities using the obsolete BoundingBoxComponent in Aqua.

* Renamed PhysShapeAabbComp to PhysShapeAabb.
Removed BoundingBoxComponent.

* Default CollidableComponent does not collide with anything now.

* Renamed ICollidable to IPhysBody.
Moved ICollidable to the Robust.Shared/Physics namespace.

* PhysShapes are now a collection of primitive shapes that contribute to the whole PhysBody.
ObjectSerializer.DataField can now deal with abstract types using YAML tags.

* Added LocalBounds property to ClickableComponent.
Added state to ClickableComponent.

* Added a Rectangle physics shape.

* ClickableComponent now actually checks that a click is inside its bounds.

* Reverted the addition of a try/catch around map loading. Any errors can propagate to the code trying to load the map again.
2019-09-03 22:06:50 +02:00
Pieter-Jan Briers
dccdbe743c Fix hitting ctrl-C crashing on Core. 2019-09-03 21:57:28 +02:00
Pieter-Jan Briers
5fee08e68b Fix NuGet mess again hopefully 2019-09-01 09:53:41 +02:00
Acruid
0477b58861 Removed IEntityNetworkManager.SendDirectedComponentNetworkMessage. The directed functionality was added to implementations of IEntityNetworkManager.SendComponentNetworkMessage (it already existed on server anyways). This resolves https://github.com/space-wizards/RobustToolbox/issues/717. 2019-08-31 20:25:13 -07:00
Acruid
c5c9f2dbd3 Move ClientChangedHandMsg to Content assembly. This Resolves https://github.com/space-wizards/RobustToolbox/issues/703. 2019-08-31 17:46:52 -07:00
Pieter-Jan Briers
1c059e2437 Fix client build for some people 2019-08-31 19:13:22 +02:00
Pieter-Jan Briers
94e1f90c97 Add console commands to force run the GC 2019-08-31 18:39:31 +02:00
Pieter-Jan Briers
daf0d1dd6c Fix memory leak with entity spawn window 2019-08-31 18:39:19 +02:00
Pieter-Jan Briers
f2ac151917 Scrolling so smooth it puts half the apps I use daily to shame. 2019-08-31 17:32:48 +02:00
Pieter-Jan Briers
5c445229d4 Fix build related to old OpenTK package. 2019-08-31 14:24:07 +02:00
Acruid
8765c67872 All entities are now allocated with a TransformComponent.
Prototypes will now use existing components, like transform, when loading an entity. Previously they blindly created new ones on the entity.
AddComponent now cannot overwrite a protected component, ie TransformComponent and MetaDataComponent. Entity caches these components, they cannot be changed.
Regular RemoveComponent functions are now not able to remove protected components.
2019-08-30 00:49:20 -07:00
Pieter-Jan Briers
c0b19dcca1 Hide property overrides in VV.
Fixes #857.
2019-08-30 09:38:02 +02:00
Pieter-Jan Briers
3d00d491c4 BoxContainer ignores invisible children for minsize calculations.
This is inline with what Godot does and it makes VV a hell of a lot compacter.
2019-08-30 08:53:13 +02:00
Víctor Aguilera Puerto
b421143463 Clear server VVTraitEnumerable cache on refresh (#856) 2019-08-30 05:59:49 +02:00
Pieter-Jan Briers
25f14ff1b6 Great that PrivateAssets stuff breaks .NET Core publishes. 2019-08-29 23:50:30 +02:00
Pieter-Jan Briers
0a5f9d4b0b Fix parallax gen being broken on Windows. 2019-08-29 23:08:33 +02:00
Pieter-Jan Briers
4cc30823a6 Fix build on .NET Framework. 2019-08-29 20:29:36 +02:00
Pieter-Jan Briers
e790e97a50 Fix some compiler warnings. 2019-08-29 16:59:52 +02:00
Pieter-Jan Briers
62f25669c7 Make it possible to VV containers. 2019-08-29 14:36:07 +02:00
Pieter-Jan Briers
814b686cb7 Explicitly dispose ImageSharp images. 2019-08-28 12:08:05 +02:00
Pieter-Jan Briers
d0ec77e804 Blit fonts manually to reduce created garbage. 2019-08-27 23:13:06 +02:00
Pieter-Jan Briers
eff7fa8408 Remove PrivateAssets rules from shared. 2019-08-27 23:11:01 +02:00
Pieter-Jan Briers
51989a8ccc Mark a bunch of packages as private assets.
This will prevent them being referenced in content, so stuff like OpenTK isn't "accessible" from Content.Client.
2019-08-27 22:51:31 +02:00
Pieter-Jan Briers
c16ef6ce77 Update all the NuGet packages. 2019-08-27 22:38:49 +02:00
Pieter-Jan Briers
2a08389235 Remove dependency on Smocks.ExtensionPackage.
It didn't support .NET Standard and it wasn't used anyways.
2019-08-27 22:34:32 +02:00
Pieter-Jan Briers
dd7159eec0 Update CommandLineParser. Refactor some code to make it work. 2019-08-27 21:47:15 +02:00
ShadowCommander
366d0ab2d5 Fixed LineEdit triggering when hovered but not selected (#854)
* Revert "Don't fire regular keybinds for controls under the mouse."

This reverts commit bb322e30ee.

* Fixed LineEdit triggering when hovered
2019-08-26 00:23:09 +02:00
DamianX
7dc32af73f DefaultColorsInverted ignores duplicates (#853) 2019-08-25 23:45:33 +02:00
DamianX
943b000950 Things for wires (#852)
* Things for wires

* Fixed things
2019-08-25 23:18:03 +02:00
Pieter-Jan Briers
bb322e30ee Don't fire regular keybinds for controls under the mouse. 2019-08-25 22:53:49 +02:00
ShadowCommander
117cf14e5c Add a check in OnContextChanged to fix some crashes and refactored BaseButton (#851)
* Add a check in OnContextChanged to fix some crashes

Fixes crashes due to double input like the Quit button in the Esc menu

* Changed BaseButton to only trigger on KeyBindDown and KeyBindUp on the same control
2019-08-25 13:13:07 +02:00
Pieter-Jan Briers
081ced42df Make fetching minimum size force style update if necessary. 2019-08-25 12:55:16 +02:00
Pieter-Jan Briers
3a9ccfe470 Fix more bad logging categories. 2019-08-25 12:55:16 +02:00
Acruid
19d7cd4455 ViewVariables can now edit Enums. The input field will accept either an enumeration label or a numerical value. 2019-08-22 13:43:00 -07:00
Pieter-Jan Briers
97d8f7d936 Remove code from EntityPrototype to change Entity container type. 2019-08-22 21:54:18 +02:00
Pieter-Jan Briers
6833ffd19f Fix build. 2019-08-22 20:16:47 +02:00
Pieter-Jan Briers
509497b784 Check that file paths are valid on all file systems.
Fix #525
2019-08-22 15:46:14 +02:00
Pieter-Jan Briers
d3b8a07350 Try to fix weird integration tests issues. 2019-08-22 10:21:36 +02:00
Pieter-Jan Briers
8291294aa1 Fix tests on .NET Core. 2019-08-21 23:39:52 +02:00
ShadowCommander
a8d6c294ab Input System Refactor (#840)
* Fixes right click menu stopping input

Removed a flag change when the modal stack was showing, which preventing the click from getting passed to the next function.

* Added parsing for mod2 and mod3 from Keybind YAML

* Fixes a crash on context change when a keybind is not defined in keybinds.yml

* Implemented ShowDebugConsole Hotkey

* Refactored input system

Refactored input system to run Key and Mouse input through the InputManager before doing stuff.

* Upgraded LineEdit and classes that use it. Fixed input while KeyboardFocused.

Upgraded LineEdit to use Keybinds.
Upgraded DebugConsole to use Keybinds.
Replaced all references to MouseDown, MouseUp, KeyDown, and KeyUp with KeyBindUp and KeyBindDown.
Moved UserInterfaceManager call from GameController.Input to InputManager event.
Stopped input going to simulation while a control has focus in UserInterfaceManager.

* Some fixes for input system

Fixed keybinds getting stuck when selecting a LineEdit.
Changed MenuBar to not error.
Fixed a few cases where LineEdit would eat input if you hovered over it and where mouse input got eaten when clicking in the world while a LineEdit was selected.

* Removed extra dependencies

* Added GUIBoundKeyEventArgs to ButtonEventArgs

* Fixes for input with LineEdit selected

Fixed multiple keybinds mapped to the same key not triggering.
Fixed keybind input not getting to LineEdit when hovering over a control.

* Implemented Key Repeat for LineEdit

* Fix for input on Robust.Lite Launcher

* Renames NonFocusKeybinds to EnableAllKeybinds

Renamed NonFocusKeybinds to EnableAllKeybinds and added comment to clarify usage

* Adds repeating keybinds

Used for TextBackspace, TextCursorLeft, and TextCursorRight
Reverts a change to LineEdit that implemented repeating keys
Adds some documentation comments
2019-08-21 17:13:48 +02:00
CatTheSystem
fc67c5069c Allowed multiple Pseudo Classes per element. (#846)
* Quick fix to flashlight radius

* SomethingAbout CSS Class

* Shitty update

* fuck

* Creativ!

* Last But not least

* Quick Change

* Fixed version

* Tiny fix

* Next Fix

* Another fix
2019-08-20 21:22:14 +02:00
DamianX
7f9f593989 Implemented RobustRandom (#845)
* Implemented RobustRandom

* Fixed RandomString
2019-08-16 21:43:59 +02:00
CatTheSystem
ff5334f446 Quick fix to flashlight radius (#844) 2019-08-15 09:52:54 +02:00
Pieter-Jan Briers
cb5f2ffae1 Refactor UI system. (#843)
* Refactor UI system.

Deferred updating is used for styling & layout. This fixes the awful time complexity of containers.
Removed SetDefaults and Initialize. They were a bad idea alright.

* Fix build on .NET Framework.
2019-08-14 22:03:51 +02:00
Pieter-Jan Briers
cdac0d5757 Correctly delete disposed audio sources on the main thread. 2019-08-14 10:48:54 +02:00
Pieter-Jan Briers
c727dbd07e Gets rid of some [SRV] loggings. 2019-08-14 10:32:23 +02:00
Pieter-Jan Briers
95f9126d12 Detect exception-loop softlocks and shut down server if it happens. 2019-08-13 23:51:54 +02:00
Pieter-Jan Briers
265a9abeb6 Metadata component can send component state with null prototype ID. 2019-08-13 23:21:42 +02:00
Pieter-Jan Briers
6e32588be7 Adds new placement alignment mode to place lights correctly. 2019-08-13 12:05:08 +02:00
Pieter-Jan Briers
71fd6d427c Fix prototype manager not compiling on .NET Framework. 2019-08-13 10:30:31 +02:00
Pieter-Jan Briers
aff2631f23 Make VV command not crash as easily. 2019-08-13 01:02:42 +02:00
Pieter-Jan Briers
3f01fb0879 More VV attributes for Control. 2019-08-13 00:55:56 +02:00
Pieter-Jan Briers
02ca521cc5 Adds useless version label to main menu. 2019-08-12 18:53:41 +02:00
Pieter-Jan Briers
468fbda539 Ensure stable sort in the entity rendering sort. 2019-08-12 18:46:34 +02:00
Pieter-Jan Briers
175085f32e Make prototype loader ignore unix hidden files. 2019-08-11 23:13:25 +02:00
Pieter-Jan Briers
96543421f2 Update help for monitor command. 2019-08-11 22:50:01 +02:00
Pieter-Jan Briers
10261a15b2 Fix flick animations. 2019-08-11 16:45:59 +02:00
Pieter-Jan Briers
11ac144ae1 Make component state type check an assert. 2019-08-11 01:38:25 +02:00
Pieter-Jan Briers
db6d9160e4 Remove LINQ usage from Entity.cs 2019-08-11 01:33:09 +02:00
Pieter-Jan Briers
896758e176 Make IEntity.GetAllComponents no longer return duplicates.
Remove the Instances method that did that instead.
2019-08-11 01:22:59 +02:00
Pieter-Jan Briers
768fed2421 Optimize Matrix3 Vector2 transforms. 2019-08-11 01:01:40 +02:00
Pieter-Jan Briers
98c1e43fe6 Optimize that color lerp more because I wanted to mess with SIMD. 2019-08-11 00:21:05 +02:00
Pieter-Jan Briers
7fce46ec44 Fix some issues Sonar caught. 2019-08-10 14:17:13 +02:00
Pieter-Jan Briers
b1b6e2dd5c Fix cache rules in .appveyor.yml. 2019-08-10 13:54:38 +02:00
Pieter-Jan Briers
9ea9f452ec Maybe fix AppVeyor? 2019-08-10 13:49:38 +02:00
Pieter-Jan Briers
d9968e2e62 Fix failing test harder. 2019-08-10 01:22:12 +02:00
Pieter-Jan Briers
5e2a1d889d Fix failing test. 2019-08-10 01:18:55 +02:00
Pieter-Jan Briers
72c4d56639 Remove a bunch of oldcode from FloatMath.
Did we need to store 256 KiB worth of inaccurate sin/cos lookup? Nah.
2019-08-08 00:41:03 +02:00
Pieter-Jan Briers
e7bf2d0ac9 Use MathF for sqrt in vector types. 2019-08-07 23:16:05 +02:00
Pieter-Jan Briers
daa13de9ed Did you know that working on two things at once can
cause you to forget to commit files?
2019-08-07 20:56:37 +02:00
Pieter-Jan Briers
8d0012223e Optimize sRGB conversions on .NET Core. 2019-08-07 15:47:49 +02:00
Pieter-Jan Briers
78416ad157 Refactor Color.InterpolateBetween to be faster and make more sense. 2019-08-07 14:52:14 +02:00
Pieter-Jan Briers
fc4e3be40a Replace SS14 noise dependency with FastNoise. 2019-08-07 14:51:23 +02:00
Pieter-Jan Briers
57fb38c04d Improve Random.NextFloat() to be faster. 2019-08-07 14:50:48 +02:00
Pieter-Jan Briers
5fd7f9a6d8 Re-add tile build overlay. 2019-08-06 13:50:23 +02:00
Acruid
096b7f6bca Removed TransformComponent.VisibleWhileParented.
Removed `TransformComponent.ParentChangedEventArgs`, this was dead code from the removed `TransformComponent.OnParentChanged` event.
2019-08-05 13:21:55 -07:00
Pieter-Jan Briers
6a331cfdf6 Re-organize OpenGL init so debug callback gets initialized earlier. 2019-08-05 15:58:58 +02:00
Pieter-Jan Briers
b6bc2e591b Very rough menu bar control. 2019-08-05 14:45:38 +02:00
DamianX
89726ebeec Fix missing semicolon (#839)
* Fix missing semicolon

* Fixed CopyToArray
2019-08-04 11:42:40 +02:00
Pieter-Jan Briers
0a41ef3c9a Unified those messy FrameEventArgs. 2019-08-04 01:08:44 +02:00
Pieter-Jan Briers
0e65843f39 Memory debug panel to show memory usage info. 2019-08-03 23:59:54 +02:00
Acruid
066f6b9443 Adds a Setup function to the AILogicProcessor that is called once when the processor is initialized. 2019-08-03 12:43:38 -07:00
Pieter-Jan Briers
be0c520455 Fix examine crash. 2019-08-03 15:20:45 +02:00
Pieter-Jan Briers
e62021cb92 Try to work around space-wizards/space-station-14#284 2019-08-03 15:07:43 +02:00
Pieter-Jan Briers
c0eca4f6c2 .NET Core support. 2019-08-02 02:07:03 +02:00
Pieter-Jan Briers
bcf60c404d More optimized ImageSharp blit. 2019-08-01 19:43:00 +02:00
Pieter-Jan Briers
6f201ccddc Renderer optimizations.
Nothing major, but it should be a bit faster now.
2019-08-01 02:14:03 +02:00
Pieter-Jan Briers
85a4375905 Various performance optimizations. 2019-08-01 00:10:20 +02:00
Pieter-Jan Briers
fa10e1c330 Automatic component registration attributes. 2019-07-31 15:00:33 +02:00
Pieter-Jan Briers
170b8717c1 Fix some compiler warnings. 2019-07-31 13:47:34 +02:00
Pieter-Jan Briers
effb731340 GameScreen: don't wipe StateRoot. 2019-07-31 13:43:10 +02:00
Pieter-Jan Briers
7e08c5d743 Only load prototypes from .yml files.
I had some .directory files that were being loaded. This fixes that.
2019-07-31 13:16:35 +02:00
Pieter-Jan Briers
0e31193e7f Improve rich text system.
Improved word wrapping to reduce edge cases.
Allowed setting a "maximum" size for rich text label.
2019-07-30 23:10:03 +02:00
Pieter-Jan Briers
97c8297ce1 Noise generator improvements:
Added method to generate 1D noise.
Made all the methods take in doubles.
  They already converted to it anyways.
2019-07-30 18:49:56 +02:00
Pieter-Jan Briers
120cab811f Implement tuple -> vector conversions for double vectors. 2019-07-30 18:48:05 +02:00
Pieter-Jan Briers
d7e5c12a3d Make FpsCounter internal so it gets out of my face. 2019-07-30 13:55:58 +02:00
Pieter-Jan Briers
4eb4e47975 Remove unused SpeechBubble.cs 2019-07-30 13:50:27 +02:00
Pieter-Jan Briers
3d0d999f25 Remove ControlWrapAttribute. 2019-07-30 13:46:33 +02:00
Pieter-Jan Briers
7e13447455 Remove Godot scene instantiation. 2019-07-30 13:39:56 +02:00
Pieter-Jan Briers
fdfbf92223 Remove a ton of lighting system cruft.
Basically just kills the light manager.
Clyde was already using the ECS anyways.
2019-07-30 13:31:05 +02:00
Pieter-Jan Briers
9290ab445a Fix Stylesheet tests. 2019-07-30 13:02:40 +02:00
Acruid
51bbc7e565 Removed obsolete TransformComponent.OnParentChanged event. Use the component or entity system message for this event. 2019-07-29 16:16:55 -07:00
Pieter-Jan Briers
be379b2e20 Remove a bunch of cruft from the engine.
Unused textures & fonts, really.
2019-07-30 00:56:51 +02:00
Pieter-Jan Briers
6d377ee1e3 Robust Lite, also known as "Qt was too hard to distribute". 2019-07-29 23:08:50 +02:00
Pieter-Jan Briers
a1d899ee31 Updating control size flags now notifies parent container. 2019-07-29 23:08:49 +02:00
Pieter-Jan Briers
39a2c9db86 Fix parenting a control not correctly setting its layout. 2019-07-29 23:08:49 +02:00
Pieter-Jan Briers
66999a4a5d Extract user data dir locating to a helper class. 2019-07-29 23:08:49 +02:00
Pieter-Jan Briers
2d30eb0321 Adds way to open URIs in the user's browser. 2019-07-29 23:08:49 +02:00
Acruid
b26a370504 You can now call IoCManager.Clear() regardless of the container being instantiated for your thread. Previously you would get a null exception. Now the function does nothing (as expected) if the container does not exist. 2019-07-29 11:39:42 -07:00
Acruid
30cafea218 Adds a debug net graph to the game state system. 2019-07-29 11:25:20 -07:00
Pieter-Jan Briers
d9297fa1c9 Add [ViewVariables] to PlayerData. 2019-07-26 23:37:26 +02:00
Pieter-Jan Briers
9355938f6a Don't try to send unserializable value types over the wire with VV. 2019-07-26 23:36:24 +02:00
Pieter-Jan Briers
c5ef7fd134 Fix VV crash when viewing empty enumerable. 2019-07-26 22:56:37 +02:00
Pieter-Jan Briers
112b694099 Better error feedback on VV command. 2019-07-26 18:39:00 +02:00
Pieter-Jan Briers
e0512a1052 Use RemoveAllChildren() in GameScreen switch. 2019-07-26 17:55:30 +02:00
Pieter-Jan Briers
ed56c39e1b Add more parent/child helpers to Control. 2019-07-26 17:55:06 +02:00
Pieter-Jan Briers
117fcf2aa2 Make entity spawn window text more in line with the tile spawn window. 2019-07-26 17:54:10 +02:00
Pieter-Jan Briers
4fd24e8de9 Optimize UI system somewhat.
Especially styling should be significantly faster now.
2019-07-26 17:32:58 +02:00
Pieter-Jan Briers
a4f2441153 Adds SnapGridComponent.GetLocal() 2019-07-26 13:49:09 +02:00
Pieter-Jan Briers
e1f2742c8f Optimize RSI loading significantly. 2019-07-26 12:21:50 +02:00
Pieter-Jan Briers
6f26f77ce6 Add efficient ImageSharp blitting method. 2019-07-26 12:20:59 +02:00
Pieter-Jan Briers
da1baba550 Add cast from Vector2u to Vector2i. 2019-07-26 12:20:34 +02:00
Pieter-Jan Briers
dd53239554 Change to new freetype build.
This hopefully fixes #835
2019-07-25 14:03:40 +02:00
Pieter-Jan Briers
25f9ba5ec2 Remove debug drawing of rotated rect. 2019-07-25 14:03:40 +02:00
Acruid
ed97cbb42d The *World functions on TransformComponent now properly account for the grid world location. This fixes entities being drawn around the world origin when they touch a grid that isn't at 0,0 in the world. 2019-07-24 10:29:40 -07:00
Pieter-Jan Briers
78bbac52f0 Fix entity spawn erase mode. 2019-07-24 16:10:12 +02:00
Pieter-Jan Briers
83c738e423 Correctly handle fractional scrolling coming in from OpenTK. 2019-07-24 09:31:16 +02:00
Pieter-Jan Briers
b0a8e3923b Give bad username feedback before attempting connection. 2019-07-24 00:40:49 +02:00
Pieter-Jan Briers
311bd2b874 Fix UIManager popups. 2019-07-24 00:27:51 +02:00
Pieter-Jan Briers
59caaeca8c Better feedback for why usernames are invalid. 2019-07-24 00:27:21 +02:00
Pieter-Jan Briers
832be75c5c Fix UITest command. 2019-07-24 00:27:09 +02:00
Pieter-Jan Briers
08e214b3d2 Add SS14Window.OpenCenteredMinSize 2019-07-24 00:27:03 +02:00
Pieter-Jan Briers
f75ee08030 Add some separators to the main menu to make grouping easier. 2019-07-23 23:28:52 +02:00
Pieter-Jan Briers
cd9aed6696 Less ugly debug console color. 2019-07-23 23:14:36 +02:00
Pieter-Jan Briers
040dc2445c Use new IDynamicTypeFactory extension method. 2019-07-23 21:34:13 +02:00
Pieter-Jan Briers
414bd95eb2 DynamicTypeFactory improvements:
Can now make instances with constructor arguments.
Adds some helpers.
2019-07-23 21:08:01 +02:00
Pieter-Jan Briers
17424cc3f3 TextureButton can now be scaled. 2019-07-23 19:44:24 +02:00
Pieter-Jan Briers
795af9d0f4 Fix precise scrolling. 2019-07-23 19:43:03 +02:00
Acruid
91d0936a99 Eye now uses MapCoordinates instead of Grid Coordinates when building the view matrix. This fixes the bug where the view offsets from the map origin when the player touches a grid in the world that isn't positioned at the origin. 2019-07-20 14:07:38 -07:00
Acruid
89ff434528 Fixes ScreenToWorld entity picking. Now when you mouse over a grid it does not pick entities at the map origin. 2019-07-20 12:47:09 -07:00
Acruid
8c46c06497 Setting the world position of a Transform now properly sets the grid index. 2019-07-20 12:37:46 -07:00
Acruid
04c95d4ff8 Fixes a bug where the VV window did not open. 2019-07-20 12:18:45 -07:00
Pieter-Jan Briers
ecb641f403 Allow scaling SpriteView. 2019-07-20 15:49:44 +02:00
Pieter-Jan Briers
e10e7d165a Make outlines less ugly. 2019-07-20 15:49:11 +02:00
Pieter-Jan Briers
03edfc46cb Actually apply fullscreen preference on client restart. 2019-07-19 23:59:49 +02:00
Pieter-Jan Briers
13ad6f3f37 Show a warning in the main menu on old OpenGL versions. 2019-07-19 23:57:41 +02:00
Pieter-Jan Briers
8ec83a7654 Allow Clyde to draw rotated boxes. 2019-07-19 22:12:33 +02:00
Acruid
de68a62187 Box2Rotated & Vector2 Rotation (#827)
* Adds a function to rotate a vector by an Angle.
Adds the Box2Rotated struct for holding a rotated box.

* Use ApproxEqualityConstraint
2019-07-19 21:48:40 +02:00
Pieter-Jan Briers
95197075a5 Prune dead NetIDs. 2019-07-19 16:35:14 +02:00
Pieter-Jan Briers
167aa4791b Remove instance of Visibility = false for windows. 2019-07-19 16:08:19 +02:00
Pieter-Jan Briers
f38eb13866 Make opening a window twice not crash. 2019-07-19 16:07:01 +02:00
Pieter-Jan Briers
0c1c6cee0e Generate basic cyrillic for font atlasses. 2019-07-19 14:13:37 +02:00
Pieter-Jan Briers
c8a28b8c83 Allow using C# Object Initializers for Controls layout.
It's far from a good declarative syntax, but better than before.
2019-07-19 12:38:54 +02:00
Pieter-Jan Briers
81b521a8e4 Re-organize entity spawn window. 2019-07-19 12:07:58 +02:00
Pieter-Jan Briers
441980e1cb Remove spawnwindow command. 2019-07-19 12:07:41 +02:00
Pieter-Jan Briers
8f976ce810 Window titles left aligned, text clipping if necessary. 2019-07-19 11:31:04 +02:00
Pieter-Jan Briers
c2e8ee0fcd Change default rich text entry color to 200,200,200.
Less blinding white in the tutorial.
2019-07-19 10:55:43 +02:00
Pieter-Jan Briers
8d2ea9aed1 Remove SS14Window.AddToScreen and related systems. 2019-07-18 22:48:51 +02:00
Pieter-Jan Briers
31ca502418 Less fragile kdialog detection. 2019-07-17 14:03:13 +02:00
Pieter-Jan Briers
7318247da2 Do not attempt to open file dialogs on headless 2019-07-17 14:00:54 +02:00
Pieter-Jan Briers
bed9a082bc Probably fix AppVeyor. 2019-07-17 13:56:01 +02:00
Pieter-Jan Briers
5694f4ff28 Actually use sprite layer colors.
They were previously ignored.
2019-07-17 00:35:29 +02:00
Pieter-Jan Briers
0865398fe1 Never trust me to actually commit files. 2019-07-14 08:54:14 +02:00
Pieter-Jan Briers
fb2feee93b Finish file dialog support.
Implemented automatic download of swnfd.
Made swnfd run synchronously on macOS to prevent issues.
2019-07-14 08:53:00 +02:00
Pieter-Jan Briers
093481cb77 Better documentation for FileDialogManager. 2019-07-13 22:05:34 +02:00
Pieter-Jan Briers
60f46afddd Tooltips do not block the mouse. 2019-07-13 22:03:38 +02:00
Pieter-Jan Briers
c504e58226 Remove a bunch of cruft from RobustUnitTest. 2019-07-13 21:55:47 +02:00
Pieter-Jan Briers
4cb9bd3332 Deduplicate IoC init. 2019-07-13 21:51:57 +02:00
Pieter-Jan Briers
f2cdb0d68c File dialog API.
Only works on KDE Linux right now until I compile the natives.
I'll ship libswnfd when I got it compiled for all platforms.
2019-07-13 17:54:21 +02:00
Pieter-Jan Briers
e3720ebe01 Implement MinSize for TextureButton 2019-07-13 14:49:46 +02:00
Pieter-Jan Briers
5d07887251 TextureRect can now be scaled. 2019-07-12 19:11:43 +02:00
Pieter-Jan Briers
ed340f7df9 Optimize the code to reduce a ton of allocations. 2019-07-11 14:51:20 +02:00
Pieter-Jan Briers
0de8615033 Document some GUI controls. 2019-07-08 23:02:59 +02:00
Pieter-Jan Briers
091c1b935b Implement GrowDirection on controls. 2019-07-08 21:00:28 +02:00
Pieter-Jan Briers
04b14e92e7 Fix #265 2019-07-08 16:45:08 +02:00
Pieter-Jan Briers
e6c4cbb662 Make placement respect map init. 2019-07-08 13:46:14 +02:00
Pieter-Jan Briers
1b57d4ec0b Remove TrySpawn* entity methods. (#833) 2019-07-07 22:24:21 +02:00
Pieter-Jan Briers
2a6696f7e3 Make outline corners smoother. 2019-07-06 22:38:58 +02:00
Pieter-Jan Briers
981bbc61ee Re-implement hollow rectangle drawing.
I missed a TODO.
2019-07-06 22:37:58 +02:00
Pieter-Jan Briers
78c393aac5 Fix Travis 2019-07-06 19:19:37 +02:00
Pieter-Jan Briers
09c36b57cd Shift half of Clyde around to implement better outline rendering. (#830)
* Attempted Clyde cleanup, didn't get far.

* Add negation operator to Vector2i.

* Add RenderOrder to ISpriteComponent.

* Post process shaders.

Adds "post process" shaders to sprite component.
These are executed on the WHOLE sprite component (every layer)
in one draw.

This is necessary to implement functional outlines.
2019-07-06 19:17:33 +02:00
Pieter-Jan Briers
a8be3a2844 Delete dead closewindow.png 2019-06-29 19:55:17 +02:00
Pieter-Jan Briers
4ae2f6b667 Helping content get AppVeyor 2019-06-29 16:55:53 +02:00
Pieter-Jan Briers
eb683e1838 Damnit Rider. 2019-06-29 01:56:56 +02:00
ZNixian
222e19ddc4 Add support for diagonal RSI sprites (#828) 2019-06-29 01:54:34 +02:00
Pieter-Jan Briers
ae42a3e3fa Integration testing improvements.
They no longer load system-wide config or user data.
User data is emulated through a VFS.

Also added more hooks to improve the customizability of the test,
for example allowing content to hijack their IoC registrations.
2019-06-29 01:51:40 +02:00
Pieter-Jan Briers
9a4c1cae1e Networked integration tests work. 2019-06-28 16:03:58 +02:00
Pieter-Jan Briers
67f433aeb2 Maybe fix loading on Windows 2019-06-23 11:29:17 +02:00
Pieter-Jan Briers
413680b602 Try to figure out why the launcher doesn't work with better logs. 2019-06-23 11:08:18 +02:00
Pieter-Jan Briers
822e6b7f6d Clean up signal handling and make it work on the client. 2019-06-05 12:12:10 +02:00
Pieter-Jan Briers
d3a67107bb Fix Join Public Server button. 2019-06-05 11:12:58 +02:00
Pieter-Jan Briers
00995d6a30 Do not try to set server console title in non-interactive shells. 2019-06-04 23:25:28 +02:00
Pieter-Jan Briers
ef57a4f4c3 Improve QoL of integration test API, document it. 2019-06-04 23:25:08 +02:00
Pieter-Jan Briers
1c2caca7e1 Fix dependency copy. 2019-06-04 19:07:49 +02:00
Pieter-Jan Briers
9115610d2f Integration testing v2 (#826)
* Rewrite Integration testing, add support for the client.

* Rewrite AssemblyLoader to not be static.

* Adds ability to post messages into thread.
2019-06-04 19:05:16 +02:00
Injazz
99c956dfb4 Circle Ranges (#825)
* Circle Range for Tiles

* fixes
2019-06-03 20:13:38 +02:00
Pieter-Jan Briers
6a1bed31ae Fix integration tests. 2019-06-02 20:15:28 +02:00
Pieter-Jan Briers
017a63f41c How the hell did I fail to commit this file. 2019-06-02 06:59:52 +02:00
Pieter-Jan Briers
5e872ec1e3 Implement animated RSI rendering for effects.
Fixes #822.
2019-06-02 01:14:14 +02:00
Pieter-Jan Briers
e314446575 Allow components to be created while iterating them. (#821)
This is necessary to avoid tons of papercuts with entity systems.
Without this it is not possible to create entities inside the update loop of an entity system, which is too common for me to disallow.

As for performance, I offset it by removing the LINQ usage.
It's marginally faster than before even.
2019-06-01 00:16:19 +02:00
Pieter-Jan Briers
58c7255087 Can now load wav PCM audio.
Clyde had the code for a while now but I didn't expose it because Godot
didn't either.
2019-06-01 00:13:34 +02:00
Pieter-Jan Briers
58ac8f0dba Log warning when using stereo audio positionally.
OpenAL doesn't support this so this should help avoid confusion.
2019-06-01 00:06:32 +02:00
Pieter-Jan Briers
e5024e80f4 Update Nett dependency. 2019-05-29 01:48:25 +02:00
Pieter-Jan Briers
00f6564351 Update some NuGet dependencies. 2019-05-29 01:45:31 +02:00
Pieter-Jan Briers
b32f695509 Make Sonar ignore Lidgren. 2019-05-29 01:18:36 +02:00
Pieter-Jan Briers
f74bf680e7 Add an assert to lighting rendering. 2019-05-29 01:11:45 +02:00
Pieter-Jan Briers
02802c0e70 Clip VV ToString() text to reduce some ridiculous cases. 2019-05-29 01:06:05 +02:00
Pieter-Jan Briers
300c2c05e4 Implement Label ClipText. 2019-05-29 01:05:43 +02:00
Pieter-Jan Briers
f9e192b01e Vertically center checkboxes. 2019-05-29 00:55:34 +02:00
Pieter-Jan Briers
7c6c8dcd41 Do not crash if client disconnects during initial handshake. 2019-05-28 20:59:39 +02:00
Pieter-Jan Briers
18c91e6be4 Fix bad copypaste with DebugPositions 2019-05-28 20:34:36 +02:00
moneyl
6a9a727e1f Add Control.SetOnlyStyleClass (#820)
This clears the collection of style classes and adds the new one. This allows controls to easily switch between several style classes without needing to keep track of the active one in their own code.
2019-05-28 20:32:32 +02:00
Pieter-Jan Briers
d7f5c1d9db Debug drawing to show exact entity positions. 2019-05-28 13:35:24 +02:00
Pieter-Jan Briers
97dfe3c216 Fix GetEntitiesInArc's using half range. 2019-05-28 13:35:09 +02:00
Pieter-Jan Briers
b65f108268 Load vsync from config on startup. 2019-05-28 01:59:27 +02:00
Pieter-Jan Briers
4892d0d0fa Fix some compiler warnings and remove dead code. 2019-05-28 00:30:18 +02:00
Pieter-Jan Briers
bb4a1eda8e Project file refactor (#819)
* Project file refactor

Move all the .csproj files to the new .NET Core style.
This doesn't make any difference for compiling for Framework,
but it does reduce a ton of useless boilerplate.

As an extension of this, killed a bunch of uncompiled & unmaintained .cs files.

Compiling for release (to profile) works now.
Removed AnyCPU targets from the solution file.

* Fix compiler warnings.
2019-05-28 00:16:01 +02:00
moneyl
110bd0921a Add StyleBox overrides to ProgressBar (#818)
* Add StyleBox overrides to ProgressBar

The overrides are StyleBoxFlat instead of StyleBox as StyleBox does not expose or possess a color property. _getBackground and _getForeground were also changed to return StyleBoxFlat instead of StyleBox to keep things simple.

* Change ProgressBar _getBackground and _getForeground back to StyleBox

* Change ProgressBar style box overrides from StyleBoxFlat to StyleBox
2019-05-25 01:41:39 +02:00
Acruid
61aba8fc50 Create Entities Without Prototypes (#815)
* Retrofitted ComponentManager_Test to use DependencyCollection.

* Renamed ComponentManager_Test to ComponentManager_Tests to follow naming conventions.

* Added component add/remove/delete events to IComponentManager.
Removed IEntity dependency from ComponentManager.

* Entities can now be spawned without a prototype.

* Removed unused function.

* CreateEntity now actually works with a null prototype ID. The other spawn functions should work as well.
Updated doc comments for IEntityManager.SpawnEntity().
2019-05-24 21:37:28 +02:00
Acruid
dc4cc71c72 Fixes game crashing because the player entity got deleted. (#814) 2019-05-24 17:03:13 +02:00
Acruid
322c706924 Allows you to use 0 (false) and 1 (true) as boolean arguments in the cvar concommand. (#817) 2019-05-24 16:59:17 +02:00
Acruid
8650143b8c ECS Events are now sent as reliable, and have their own category. (#816) 2019-05-24 16:57:45 +02:00
moneyl
b92ea9a2aa Remove GUI dependence on tscn files (#812)
* Remove unused options menu tscn

* Move SS14Window to pure C#

* Move SpriteView to pure C#

* Move EntitySpawnWindow and EntitySpawnItem to pure C#

* Removes using statements accidentally added by resharper

* Set EntitySpawnWindow default size to normal value

Note that in construction menu and storage menu this had to be done in the object initializer and didn't work if it was set in the Initialize function for the respective menus. For whatever reason setting it in the EntitySpawnWindow.Initialize works fine.
2019-05-24 16:57:13 +02:00
digitalis
1b38996905 Fixes incorrect null check in PredicateEntityQuery (#813) 2019-05-24 16:51:10 +02:00
Pieter-Jan Briers
e7a8e9b1aa Fix client side entity positions. (#811)
They were being interpolated to the origin.
2019-05-16 20:15:20 +02:00
Pieter-Jan Briers
a7d3b31ec4 Fix outline rendering. 2019-05-16 14:40:05 +02:00
Pieter-Jan Briers
10440648bc Remove IDisplayManager dependency from SS14Window 2019-05-16 14:27:51 +02:00
Pieter-Jan Briers
5226039b7c VV for PlayerManager. 2019-05-16 14:02:03 +02:00
Pieter-Jan Briers
3bad55a705 Move escape menu out of engine. 2019-05-14 15:19:27 +02:00
Pieter-Jan Briers
bb7288d26a ItemList only shows scrollbar when necessary. 2019-05-14 12:54:26 +02:00
Pieter-Jan Briers
b30c2155c7 Improve ItemList rendering to correctly handle margins. 2019-05-14 11:26:37 +02:00
Pieter-Jan Briers
70449b9ca2 Fix client not handling player state disconnects. 2019-05-14 11:25:36 +02:00
Pieter-Jan Briers
7323e454e4 Fix StyleBox.GetContentOffset(). 2019-05-14 11:18:26 +02:00
Pieter-Jan Briers
f7ccac2c11 Make Label align individual lines to center. 2019-05-14 01:19:01 +02:00
Pieter-Jan Briers
4d233ef6c2 Add [StringFormatMethod] to localization manager. 2019-05-14 00:22:52 +02:00
Pieter-Jan Briers
c10f7f2707 Document and clean up Control. 2019-05-13 19:06:57 +02:00
Pieter-Jan Briers
9db3473b7a Containers handle size flags better. 2019-05-13 14:51:50 +02:00
Pieter-Jan Briers
0b63dbd1f2 Move TileSpawnWindow to pure C#. 2019-05-13 09:15:03 +02:00
Pieter-Jan Briers
1403c14acb Fix MarginContainer layout. 2019-05-13 09:14:23 +02:00
Pieter-Jan Briers
ab8feee660 Add ItemList.ClearSelections() 2019-05-12 15:07:07 +02:00
Pieter-Jan Briers
e6417582c8 Fix OptionButton popup going under other controls. 2019-05-12 12:09:38 +02:00
Pieter-Jan Briers
977f51a9be Remove dead Godot references. 2019-05-12 11:56:10 +02:00
Pieter-Jan Briers
9977d64e2f Remove exception-catch tests from timers.
These tests were ensuring that exceptions were logged,
we decided these should bubble up instead.
2019-05-12 11:47:20 +02:00
Pieter-Jan Briers
2d6a529725 Make LocalizationManager fall back if not initialized.
This fixes unit tests.
2019-05-12 11:46:44 +02:00
Pieter-Jan Briers
ddbeccdb8c Some work supporting localization.
Far from complete, but a good start.
2019-05-11 23:59:48 +02:00
Pieter-Jan Briers
1fd6488362 Use Dns.GetHostEntryAsync.
I can't believe I missed this in the documentation.
2019-05-11 16:10:57 +02:00
Pieter-Jan Briers
f954bcb3e8 Switch to .NET Framework 4.7.2 2019-05-11 16:09:55 +02:00
Pieter-Jan Briers
17ebeac107 UI Scaling Support. (#809)
Not quite perfect, but quite usable.

Adds the ability to scale the UI. Scaling is controlled via a cvar,
and can be changed at runtime.
Fractional scaling is supported.

Some controls could be better (SpriteView, TextureRect),
but for now it's a good start.
2019-05-11 16:04:14 +02:00
Acruid
c4fb96b5e8 Tile Placement Improvements (#808)
* Tile Placement box actually uses the mouse snapgrid, not the players.

* Placement box only snaps to grids if cursor is over grid.
First tile of new grid is centered on cursor, instead of bottom left on cursor.

* Place square now sticks to the edge of a grid.
Cannot place tiles that would touch two grid Bounds.
2019-05-11 15:58:28 +02:00
Pieter-Jan Briers
2a9441a6da Remove redundant log. 2019-05-08 23:14:08 +02:00
Pieter-Jan Briers
55cf1c10a8 Do not catch async exceptions on debug.
Also renamed SS14SynchronizationContext to Robust*
2019-05-08 23:12:03 +02:00
Pieter-Jan Briers
967f144970 Do not catch timer timer exceptions on debug. 2019-05-08 23:11:38 +02:00
Pieter-Jan Briers
f548fd970e Do not catch Input exceptions in GameLoop on Debug. 2019-05-08 23:11:17 +02:00
Pieter-Jan Briers
5077b5ec4e Do not hide exceptions thrown in IoC service Dispose. 2019-05-08 22:59:45 +02:00
Pieter-Jan Briers
cd919302f8 Remove debug Console.WriteLine from SingleStreamLoader 2019-05-08 22:59:24 +02:00
Pieter-Jan Briers
f1c450e588 Make most tests parallel.
Now that IoC is thread local, this should be safe.
2019-05-08 22:33:46 +02:00
Pieter-Jan Briers
d6f288b667 Fix IoCManager_Test 2019-05-08 22:33:22 +02:00
Pieter-Jan Briers
6a9dac1b4e Fix GodotParserTest. 2019-05-08 22:33:15 +02:00
Pieter-Jan Briers
dec103ac1b Remove GameController.Mode
The difference between headless and Clyde is now handled by IoC.
2019-05-08 22:24:50 +02:00
Pieter-Jan Briers
d6a9343635 Make GameController created by IoC, remove GameControllerProxy. 2019-05-08 21:55:16 +02:00
Pieter-Jan Briers
dc6e186a26 Ensure Window Close does not fire from Dispose on Clyde. 2019-05-08 21:27:30 +02:00
Pieter-Jan Briers
4c02a2c059 Clean up GameController shutdown.
IoC is now cleared after the main loop finishes, not on Shutdown() call.
2019-05-08 21:27:02 +02:00
Pieter-Jan Briers
7d8ba30844 Don't include deleted components in GetAllComponents 2019-05-08 15:40:29 +02:00
Pieter-Jan Briers
1b4cbf58b8 Make all exceptions crash the game on debug. 2019-05-08 15:40:09 +02:00
Pieter-Jan Briers
6da21ab6c1 Clyde correct sRGB support.
This makes light stacking look less... awful.

Also minor cleanup.
2019-05-08 14:37:48 +02:00
Pieter-Jan Briers
0340cecd6d Clean up entity events some more. 2019-05-08 09:54:04 +02:00
Pieter-Jan Briers
878fade1bd Timers get cancellation support. 2019-05-08 09:48:57 +02:00
Pieter-Jan Briers
285f68b4dd Minor clean up of entity events. 2019-05-07 23:13:35 +02:00
Pieter-Jan Briers
afc2a747c8 Fix deleting entities that have containers. 2019-05-06 19:30:51 +02:00
Pieter-Jan Briers
3c9bcae474 Delete GodotWrapFont. 2019-05-06 16:44:34 +02:00
Pieter-Jan Briers
5c8986c075 Fix Texture.LoadFromImage not passing load params to Clyde. 2019-05-06 15:08:12 +02:00
Pieter-Jan Briers
454e5df939 Do not open tooltips for controls that have none. 2019-05-05 19:27:57 +02:00
Pieter-Jan Briers
c83ad3ab94 Map grid serialization fixes:
1. Actually makes grids stored row-major instead of column-major
2. Optimizations and cleanup.
2019-05-05 15:44:49 +02:00
Pieter-Jan Briers
1572d1fb3d Improve wording in the map format documentation file. 2019-05-05 15:44:11 +02:00
Pieter-Jan Briers
e032557c08 Fix Angle.Equals(object). 2019-05-05 15:43:59 +02:00
Pieter-Jan Briers
4979620486 Container improvements.
Make containers actually handle automatic removal of entities,
like say on unpartenting.
This was because a lot of content code was doing this manually,
and it broke, really badly.

They also emit events now that said content code can use instead.
2019-05-05 13:07:59 +02:00
Pieter-Jan Briers
3889066e9c Make parenting a transform to its current parent a no-op. 2019-05-05 13:05:31 +02:00
Pieter-Jan Briers
2c523115ab Fix compiler warning. 2019-05-05 11:48:51 +02:00
Pieter-Jan Briers
d62a6041ed Fix AppVeyor. 2019-05-05 11:26:14 +02:00
Pieter-Jan Briers
cde26f0567 Remove misc Godot references I missed. 2019-05-05 02:00:57 +02:00
Pieter-Jan Briers
cf2995437f Remove Godot support. (#805)
Let's be real, it's pretty damn broken already and will never be fixed.
2019-05-05 01:58:24 +02:00
810 changed files with 41402 additions and 31584 deletions

View File

@@ -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
View File

@@ -92,3 +92,4 @@ Dependencies/
__pycache__
.mypy_cache
MSBuild/Robust.Custom.targets

View File

@@ -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"

View File

@@ -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>

View File

@@ -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():

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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>

View File

@@ -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;
}
}
}

View File

@@ -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 });
}
}
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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 });
}
}
}
}

View File

@@ -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;
}
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -17,4 +17,7 @@
</PropertyGroup>
</Otherwise>
</Choose>
<PropertyGroup Condition="'$(FullRelease)' == 'True'">
<DefineConstants>$(DefineConstants);FULL_RELEASE</DefineConstants>
</PropertyGroup>
</Project>

View File

@@ -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) &quot;$(ScriptPath)&quot; $(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) &quot;$(ScriptPath)&quot; $(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) &quot;$(ScriptPath)&quot; $(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>

View File

@@ -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>

View File

@@ -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>

View 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
{
}
}

View 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
}
}

View 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
}
}

View 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
}
}

View File

@@ -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
}
}

View 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
}
}

View File

@@ -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,
}
}

View 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
}
}

View 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
}
}

View 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
{
}
}

View 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
}
}

View 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,
}
}

View 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,
}
}

View 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
}
}

View 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,
}
}

View 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
}
}

View File

@@ -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
}
}

View 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
}
}

View File

@@ -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
}
}

View File

@@ -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,
}
}

View File

@@ -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
}
}

View 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,
}
}

View File

@@ -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,
}
}

View File

@@ -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,
}
}

View 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,
}
}

View File

@@ -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,
}
}

View File

@@ -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,
}
}

View File

@@ -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,
}
}

View File

@@ -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,
}
}

File diff suppressed because it is too large Load Diff

View 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);
}
}

View 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)
{
}
}
}

View 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);
}
}

View 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];
}
}

View 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;
}
}

View 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;
}
}

View 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)

View 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
{
}
}

View File

@@ -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>

View File

@@ -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>

View 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.

View 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;
}
}

View 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;
}
}
}

View 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

Binary file not shown.

View File

@@ -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"

View File

@@ -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

View File

@@ -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" ]

View File

@@ -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"

View File

@@ -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" ]

View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -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 )

View File

@@ -0,0 +1,5 @@
kind model;
void fragment() {
COLOR = texture(TEXTURE, UV);
}

View File

@@ -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);
}

View File

@@ -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;
}

View 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;
}

View 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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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