├── .editorconfig
├── .gitattributes
├── .github
├── CODEOWNERS
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ ├── build_and_test.yml
│ └── build_test_and_publish.yml
├── .gitignore
├── .gitmodules
├── Exomia.Framework.sln
├── Exomia.Framework.sln.DotSettings
├── LICENSE
├── README.md
├── examples
├── Exomia.Framework.BasicSetup
│ ├── Content
│ │ └── .gitkeep
│ ├── Exomia.Framework.BasicSetup.csproj
│ ├── MyGame.cs
│ └── Program.cs
├── Exomia.Framework.Example.Canvas
│ ├── Content
│ │ ├── logo1.jpg
│ │ └── logo2.png
│ ├── Exomia.Framework.Example.Canvas.csproj
│ ├── MyGame.cs
│ └── Program.cs
└── Exomia.Framework.Example.JumpAndRun
│ ├── Components
│ ├── BodyComponent.cs
│ ├── GravityComponent.cs
│ ├── InputComponent.cs
│ ├── PositionComponent.cs
│ └── VelocityComponent.cs
│ ├── Exomia.Framework.Example.JumpAndRun.csproj
│ ├── JumpAndRunGame.cs
│ ├── Map.cs
│ ├── Program.cs
│ ├── Renderer
│ └── MapRenderer.cs
│ ├── Scenes
│ └── GameScene.cs
│ ├── Systems
│ ├── CollisionSystem.cs
│ ├── InputSystem.cs
│ ├── PhysicSystem.cs
│ └── RenderSystem.cs
│ └── assets
│ └── maps
│ └── 001
│ ├── 001.json
│ └── map_001.png
├── icon.png
├── src
└── Exomia.Framework
│ ├── Activator.cs
│ ├── Audio
│ ├── AudioManager.cs
│ ├── IAudioManager.cs
│ └── LinkedSoundList.cs
│ ├── Buffers
│ ├── ArrayPool.cs
│ ├── CircularBuffer.cs
│ └── CircularBuffer2.cs
│ ├── Collections
│ ├── Heap.cs
│ └── LinkedList.cs
│ ├── Component.cs
│ ├── Components
│ ├── DebugComponent.cs
│ └── Model3DViewerComponent.cs
│ ├── Content
│ ├── ContentManager.cs
│ ├── ContentReadableAttribute.cs
│ ├── ContentReaderParameters.cs
│ ├── Exceptions
│ │ └── AssetNotFoundException.cs
│ ├── IContentManager.cs
│ ├── IContentReader.cs
│ ├── IContentReaderFactory.cs
│ ├── Loader
│ │ ├── IModelFileLoader.cs
│ │ ├── ObjFileLoader.cs
│ │ └── Parser
│ │ │ └── ObjParser
│ │ │ ├── FaceParser.cs
│ │ │ ├── IParser.cs
│ │ │ ├── NormalParser.cs
│ │ │ ├── TextureParser.cs
│ │ │ └── VertexParser.cs
│ └── Resolver
│ │ ├── ContentResolverAttribute.cs
│ │ ├── E0FileStreamContentResolver.cs
│ │ ├── E1FileStreamContentResolver.cs
│ │ ├── EmbeddedResource
│ │ ├── E0EmbeddedResourceStreamResolver.cs
│ │ ├── E1EmbeddedResourceStreamResolver.cs
│ │ ├── EmbeddedResourceStreamResolver.cs
│ │ └── IEmbeddedResourceResolver.cs
│ │ ├── FileStreamContentResolver.cs
│ │ └── IContentResolver.cs
│ ├── ContentSerialization
│ ├── CSExtensions.cs
│ ├── CSStreamReader.cs
│ ├── Compression
│ │ ├── CompressMode.cs
│ │ └── ContentCompressor.cs
│ ├── ContentSerializableAttribute.cs
│ ├── ContentSerializationContext.cs
│ ├── ContentSerializationReader.cs
│ ├── ContentSerializationWriter.cs
│ ├── ContentSerializer.cs
│ ├── Exceptions
│ │ ├── CSContextKeyException.cs
│ │ ├── CSReaderException.cs
│ │ ├── CSTypeException.cs
│ │ └── CSWriterException.cs
│ ├── IContentSerializationReader.cs
│ ├── IContentSerializationWriter.cs
│ ├── Readers
│ │ ├── ColorContentSerializationReader.cs
│ │ ├── RectangleContentSerializationReader.cs
│ │ ├── RectangleFContentSerializationReader.cs
│ │ ├── Vector2ContentSerializationReader.cs
│ │ └── Vector3ContentSerializationReader.cs
│ ├── Types
│ │ ├── ArrayType.cs
│ │ ├── DictionaryType.cs
│ │ ├── EnumType.cs
│ │ ├── IType.cs
│ │ ├── ListType.cs
│ │ ├── PrimitiveType.cs
│ │ └── StringType.cs
│ └── Writers
│ │ ├── ColorContentSerializationWriter.cs
│ │ ├── RectangleContentSerializationWriter.cs
│ │ ├── RectangleFContentSerializationWriter.cs
│ │ ├── Vector2ContentSerializationWriter.cs
│ │ └── Vector3ContentSerializationWriter.cs
│ ├── Convert.cs
│ ├── DrawableComparer.cs
│ ├── DrawableComponent.cs
│ ├── EventHandler.cs
│ ├── Exomia.Framework.csproj
│ ├── Exomia.Framework.snk
│ ├── Extensions
│ ├── DeconstructExtensions.cs
│ └── MD5Extension.cs
│ ├── Game
│ ├── Camera
│ │ ├── Camera3D.cs
│ │ ├── Controller
│ │ │ ├── RotationController.cs
│ │ │ └── TranslationKeyboardController.cs
│ │ ├── ICamera.cs
│ │ ├── ICameraComponent.cs
│ │ ├── IDisposableCameraComponent.cs
│ │ ├── IInitializableCameraComponent.cs
│ │ └── IUpdateableCameraComponent.cs
│ ├── Desktop
│ │ ├── GamePlatformWindows.cs
│ │ └── GameWindowWindows.cs
│ ├── DisplayType.cs
│ ├── Game.cs
│ ├── GameGraphicsParameters.cs
│ ├── GamePlatform.cs
│ ├── GameTime.cs
│ ├── IGameWindow.cs
│ ├── MultiSampleCount.cs
│ ├── RenderForm.Enums.cs
│ ├── RenderForm.Events.cs
│ ├── RenderForm.InputDevice.cs
│ ├── RenderForm.Utils.cs
│ └── RenderForm.cs
│ ├── Graphics
│ ├── BlendStates.cs
│ ├── Buffers
│ │ ├── ConstantBuffer.cs
│ │ ├── IndexBuffer.cs
│ │ └── VertexBuffer.cs
│ ├── Canvas.Arc.cs
│ ├── Canvas.Line.cs
│ ├── Canvas.Polygon.cs
│ ├── Canvas.Rectangle.cs
│ ├── Canvas.SpriteFont.cs
│ ├── Canvas.Structs.cs
│ ├── Canvas.Texture.cs
│ ├── Canvas.Triangle.cs
│ ├── Canvas.cs
│ ├── DepthStencilStates.cs
│ ├── GraphicsDevice.cs
│ ├── IGraphicsDevice.cs
│ ├── Model
│ │ ├── Material.cs
│ │ ├── Mesh.cs
│ │ ├── Obj.cs
│ │ └── ObjContentReader.cs
│ ├── RasterizerStates.cs
│ ├── SamplerStates.cs
│ ├── Shader
│ │ ├── Shader.cs
│ │ ├── ShaderContentReader.cs
│ │ └── ShaderFileLoader.cs
│ ├── SpriteBatch.Arc.cs
│ ├── SpriteBatch.Line.cs
│ ├── SpriteBatch.Polygon.cs
│ ├── SpriteBatch.Rectangle.cs
│ ├── SpriteBatch.SpriteFont.cs
│ ├── SpriteBatch.Structs.cs
│ ├── SpriteBatch.Texture.cs
│ ├── SpriteBatch.cs
│ ├── SpriteFont.ContentSerializationReader.cs
│ ├── SpriteFont.ContentSerializationWriter.cs
│ ├── SpriteFont.Glyph.cs
│ ├── SpriteFont.Kerning.cs
│ ├── SpriteFont.Methods.cs
│ ├── SpriteFont.cs
│ ├── SpriteFontContentReader.cs
│ ├── SpriteSort
│ │ ├── ISpriteSort.cs
│ │ ├── SpriteMergeSort.cs
│ │ └── SpriteSortAlgorithm.cs
│ ├── SpriteSortMode.cs
│ ├── Texture.cs
│ ├── TextureContentReader.cs
│ ├── TextureEffects.cs
│ ├── TextureHelper.cs
│ └── Textures.cs
│ ├── ICloneable.cs
│ ├── IComponent.cs
│ ├── IContentable.cs
│ ├── IDrawable.cs
│ ├── IInitializable.cs
│ ├── IRunable.cs
│ ├── IServiceRegistry.cs
│ ├── IUpdateable.cs
│ ├── Input
│ ├── IInputDevice.cs
│ ├── IInputHandler.cs
│ ├── InputState.cs
│ ├── Key.cs
│ ├── KeyEventHandler.cs
│ ├── KeyModifier.cs
│ ├── MouseButtons.cs
│ ├── MouseEventArgs.cs
│ ├── MouseEventHandler.cs
│ └── Raw
│ │ └── Device.cs
│ ├── Linq
│ ├── ForEach.cs
│ ├── MinMax.cs
│ └── Sum.cs
│ ├── Mathematics
│ ├── Arc2.cs
│ ├── Circle2.cs
│ ├── Extensions
│ │ ├── Numeric
│ │ │ └── NumericExtensions.cs
│ │ └── Vector
│ │ │ └── Vector2Extensions.cs
│ ├── Line2.cs
│ ├── Math2.Curves.cs
│ ├── Math2.MV.cs
│ ├── Math2.cs
│ ├── Random2.cs
│ └── Triangle2.cs
│ ├── Mem.cs
│ ├── Noise
│ ├── INoise.cs
│ ├── NoiseBase.cs
│ ├── NoiseFractalType.cs
│ ├── NoiseInterpolationType.cs
│ ├── PerlinNoise.cs
│ ├── SimplexNoise.cs
│ └── ValueNoise.cs
│ ├── Renderer.cs
│ ├── Resources
│ ├── Resources.cs
│ ├── fonts
│ │ └── arial
│ │ │ ├── arial_12px.e1
│ │ │ ├── arial_14px.e1
│ │ │ ├── arial_16px.e1
│ │ │ ├── arial_18px.e1
│ │ │ ├── arial_20px.e1
│ │ │ ├── arial_22px.e1
│ │ │ ├── arial_24px.e1
│ │ │ ├── arial_26px.e1
│ │ │ ├── arial_28px.e1
│ │ │ ├── arial_30px.e1
│ │ │ ├── arial_32px.e1
│ │ │ ├── arial_34px.e1
│ │ │ ├── arial_36px.e1
│ │ │ ├── arial_38px.e1
│ │ │ ├── arial_40px.e1
│ │ │ ├── arial_42px.e1
│ │ │ ├── arial_44px.e1
│ │ │ ├── arial_46px.e1
│ │ │ ├── arial_48px.e1
│ │ │ ├── arial_50px.e1
│ │ │ ├── arial_52px.e1
│ │ │ ├── arial_54px.e1
│ │ │ ├── arial_56px.e1
│ │ │ ├── arial_58px.e1
│ │ │ ├── arial_60px.e1
│ │ │ ├── arial_62px.e1
│ │ │ ├── arial_64px.e1
│ │ │ ├── arial_66px.e1
│ │ │ ├── arial_68px.e1
│ │ │ ├── arial_70px.e1
│ │ │ └── arial_72px.e1
│ └── shaders
│ │ ├── canvas.ehlsl
│ │ ├── position_color.ehlsl
│ │ ├── position_color_texture.ehlsl
│ │ └── position_normal_texture.ehlsl
│ ├── Scene
│ ├── Default
│ │ └── LoadingScene.cs
│ ├── IScene.cs
│ ├── ISceneInternal.cs
│ ├── ISceneManager.cs
│ ├── SceneBase.cs
│ ├── SceneManager.cs
│ ├── SceneState.cs
│ └── ShowSceneResult.cs
│ ├── ServiceRegistry.cs
│ ├── Tools
│ ├── Easings.cs
│ ├── Timer2.cs
│ └── Tween.cs
│ ├── UI
│ ├── Brushes
│ │ ├── BorderBrush.cs
│ │ ├── ChainBrush.cs
│ │ ├── IBrush.cs
│ │ ├── SolidColorBrush.cs
│ │ └── TextureBrush.cs
│ ├── Controls
│ │ ├── Button.cs
│ │ ├── Checkbox.cs
│ │ ├── Container.cs
│ │ ├── Control.cs
│ │ ├── Label.cs
│ │ ├── Progressbar.cs
│ │ └── Slider.cs
│ ├── IKeyListener.cs
│ ├── Margin.cs
│ ├── Padding.cs
│ ├── TextAlignment.cs
│ ├── UiConstants.cs
│ ├── UiManager.cs
│ └── UiMouseEventHandler.cs
│ ├── UpdateableComparer.cs
│ ├── VectorI2.cs
│ ├── VectorI3.cs
│ ├── Video
│ └── VideoPlayer.cs
│ ├── Win32
│ ├── ClassStyles.cs
│ ├── Kernel32.cs
│ ├── MSG.cs
│ ├── POINT.cs
│ ├── RECT.cs
│ ├── RawInput
│ │ ├── HIDUsage.cs
│ │ ├── HIDUsagePage.cs
│ │ ├── RAWINPUT.cs
│ │ ├── RAWINPUTDEVICE.cs
│ │ ├── RAWINPUTHEADER.cs
│ │ ├── RAWINPUTHID.cs
│ │ ├── RAWINPUTKEYBOARD.cs
│ │ ├── RAWINPUTMOUSE.cs
│ │ ├── RawInputDeviceFlags.cs
│ │ ├── RawKeyboardFlags.cs
│ │ ├── RawMouseButtons.cs
│ │ └── RawMouseFlags.cs
│ ├── SM.cs
│ ├── SetWindowPosFlags.cs
│ ├── Shell32.cs
│ ├── ShowWindowCommands.cs
│ ├── TME.cs
│ ├── TRACKMOUSEEVENT.cs
│ ├── User32.cs
│ ├── WLF.cs
│ ├── WM.cs
│ ├── WS.cs
│ ├── WSEX.cs
│ ├── WndClassEx.cs
│ └── WndProc.cs
│ ├── logo_x192_Hcn_icon.ico
│ └── samples.info
├── tests
└── L0
│ └── Exomia.Framework.Tests
│ ├── Collections
│ └── HeapTest.cs
│ └── Exomia.Framework.Tests.csproj
└── tools
└── Exomia.Framework.ContentManager
├── AboutForm.Designer.cs
├── AboutForm.cs
├── AboutForm.resx
├── Attributes
├── ChoicesAttribute.cs
└── FolderNameEditorTitleAttribute.cs
├── BuildAction.cs
├── Converters
├── ChoicesStringConverter.cs
└── ExporterImporterConverter.cs
├── CreateProjectForm.Designer.cs
├── CreateProjectForm.cs
├── CreateProjectForm.resx
├── Editor
├── ImageEditorForm.Designer.cs
├── ImageEditorForm.cs
├── ImageEditorForm.resx
├── JsonEditorForm.Designer.cs
├── JsonEditorForm.cs
└── JsonEditorForm.resx
├── Exomia.Framework.ContentManager.csproj
├── Extensions
├── ControlExtensions.cs
└── FileSystemExtensions.cs
├── Fonts
├── BMFont
│ ├── FontChar.cs
│ ├── FontCommon.cs
│ ├── FontFile.cs
│ ├── FontInfo.cs
│ ├── FontKerning.cs
│ ├── FontLoader.cs
│ └── FontPage.cs
└── FontDescription.cs
├── IO
├── Exporter.cs
├── Exporter
│ └── SpiteFontExporter.cs
├── ExporterAttribute.cs
├── ExporterContext.cs
├── IExporter.cs
├── IImporter.cs
├── Importer.cs
├── Importer
│ └── BMFontImporter.cs
├── ImporterAttribute.cs
├── ImporterContext.cs
└── ImporterExporterManager.cs
├── Json.cs
├── MainForm.Build.cs
├── MainForm.Core.cs
├── MainForm.Designer.cs
├── MainForm.Events.cs
├── MainForm.cs
├── MainForm.resx
├── Program.cs
├── ProjectFile.cs
├── Properties
├── Resources.Designer.cs
└── Resources.resx
├── PropertyGridItems
├── ContentPropertyGridItem.cs
├── Editor
│ └── FolderNameEditor.cs
├── FolderPropertyGridItem.cs
├── ItemPropertyGridItem.cs
├── PropertyGridItem.cs
└── Provider.cs
├── Resources
├── AddDocument_16x.png
├── AddFolder_16x.png
├── AddFont_16x.png
├── AddItem_16x.png
├── BuildSolution_16x.png
├── Cancel_16x.png
├── CleanData_16x.png
├── CloseDocumentGroup_16x.png
├── Copy_16x.png
├── Create_16x.png
├── Cut_16x.png
├── DeleteFolder_16x.png
├── DocumentCollection_16x.png
├── DocumentExclude_16x.png
├── Edit_16x.png
├── ExitFullScreen_16x.png
├── Exit_16x.png
├── Font_16x.png
├── NewFileCollection_16x.png
├── OpenProject_16x.png
├── Rename_16x.png
├── SaveAs_16x.png
├── Save_16x.png
├── StatusAlert_16x.png
├── StatusBlocked_16x.png
├── StatusCriticalError_16x.png
├── StatusHelp_16x.png
├── StatusInformation_16x.png
├── StatusInvalid_16x.png
├── StatusNo_16x.png
├── StatusNotStarted_16x.png
├── StatusOK_16x.png
├── StatusRun_16x.png
├── StatusStop_16x.png
├── StatusWarning_16x.png
└── logo_x192.png
├── StatusType.cs
└── tools
└── bmfont64.exe
/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.cs]
2 |
3 | # IDE0056: Use index operator
4 | csharp_style_prefer_index_operator = false:none
5 |
6 | # IDE0055: Fix formatting
7 | dotnet_diagnostic.IDE0055.severity = none
8 |
9 | # Default severity for analyzer diagnostics with category 'Style'
10 | dotnet_analyzer_diagnostic.category-Style.severity = none
11 |
--------------------------------------------------------------------------------
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # These owners will be the default owners for everything in the repo.
2 | @baetz-daniel
3 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [baetz-daniel]
2 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | name: Bug report
4 | about: Create a report to help us improve
5 |
6 | ---
7 |
8 | **Describe the bug**
9 | A clear and concise description of what the bug is.
10 |
11 | **To Reproduce**
12 | (If it’s long, please paste to https://ghostbin.com/ or sth. similar and insert the link here.)
13 |
14 | Steps to reproduce the behavior:
15 | ```csharp
16 | // Your calls to exomia/framework here
17 | ```
18 | **Any logs, error output, etc?**
19 | (If it’s long, please paste to https://ghostbin.com/ or sth. similar and insert the link here.)
20 |
21 | **Expected behavior**
22 | A clear and concise description of what you expected to happen.
23 |
24 | **Screenshots**
25 | If applicable, add screenshots to help explain your problem.
26 |
27 | **Information (please complete the following information):**
28 | - OS /architecture: [e.g. windows 10 /x64, windows XP /x86, ...]
29 | - IDE: [e.g. vs17, vs15, vscode, ...]
30 | - .NETFramework: [e.g. net471, ...]
31 | - Configuration/Platform: [e.g. Debug/x64, Release/AnyCPU, ...]
32 |
33 | **Additional context**
34 | Add any other context about the problem here.
35 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 |
5 | ---
6 |
7 | **Is your feature request related to a problem? Please describe.**
8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9 |
10 | **Describe the solution you'd like**
11 | A clear and concise description of what you want to happen.
12 |
13 | **Describe alternatives you've considered**
14 | A clear and concise description of any alternative solutions or features you've considered.
15 |
16 | **Additional context**
17 | Add any other context or screenshots about the feature request here.
18 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Description
2 |
3 | Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
4 |
5 | Fixes # (issue)
6 |
7 | ## Type of change
8 |
9 | Please delete options that are not relevant.
10 |
11 | - [ ] Bug fix (non-breaking change which fixes an issue)
12 | - [ ] New feature (non-breaking change which adds functionality)
13 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
14 | - [ ] This change requires a documentation update
15 |
16 | ## How Has This Been Tested?
17 |
18 | Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
19 |
20 | - [ ] Test A
21 | - [ ] Test B
22 |
23 | **Test Configuration**:
24 |
25 | - Firmware version:
26 | - Hardware:
27 | - Toolchain:
28 | - SDK:
29 |
30 | ## Checklist:
31 |
32 | - [ ] My code follows the style guidelines of this project
33 | - [ ] I have performed a self-review of my own code
34 | - [ ] I have commented my code, particularly in hard-to-understand areas
35 | - [ ] I have made corresponding changes to the documentation
36 | - [ ] My changes generate no new warnings
37 | - [ ] I have added tests that prove my fix is effective or that my feature works
38 | - [ ] New and existing unit tests pass locally with my changes
39 | - [ ] Any dependent changes have been merged and published in downstream modules
40 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "framework.wiki"]
2 | path = framework.wiki
3 | url = https://github.com/exomia/framework.wiki.git
4 |
--------------------------------------------------------------------------------
/Exomia.Framework.sln.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2018-2020, exomia
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | 1. Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | 2. Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | 3. Neither the name of the copyright holder nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/examples/Exomia.Framework.BasicSetup/Content/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/examples/Exomia.Framework.BasicSetup/Content/.gitkeep
--------------------------------------------------------------------------------
/examples/Exomia.Framework.BasicSetup/Program.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.BasicSetup
12 | {
13 | ///
14 | /// A program. This class cannot be inherited.
15 | ///
16 | sealed class Program
17 | {
18 | ///
19 | /// Main entry-point for this application.
20 | ///
21 | private static void Main()
22 | {
23 | using (MyGame game = new MyGame())
24 | {
25 | game.Run();
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/examples/Exomia.Framework.Example.Canvas/Content/logo1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/examples/Exomia.Framework.Example.Canvas/Content/logo1.jpg
--------------------------------------------------------------------------------
/examples/Exomia.Framework.Example.Canvas/Content/logo2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/examples/Exomia.Framework.Example.Canvas/Content/logo2.png
--------------------------------------------------------------------------------
/examples/Exomia.Framework.Example.Canvas/Program.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework.Example.Canvas
14 | {
15 | ///
16 | /// A program. This class cannot be inherited.
17 | ///
18 | sealed class Program
19 | {
20 | ///
21 | /// Main entry-point for this application.
22 | ///
23 | private static void Main()
24 | {
25 | using (MyGame game = new MyGame())
26 | {
27 | game.Run();
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/examples/Exomia.Framework.Example.JumpAndRun/Components/BodyComponent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.ECS.Attributes;
12 | using SharpDX;
13 |
14 | namespace Exomia.Framework.Example.JumpAndRun.Components
15 | {
16 | [EntityComponentConfiguration(PoolSize = 32)]
17 | sealed class BodyComponent
18 | {
19 | public RectangleF Body;
20 | public Vector2 Origin;
21 | }
22 | }
--------------------------------------------------------------------------------
/examples/Exomia.Framework.Example.JumpAndRun/Components/GravityComponent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.ECS.Attributes;
12 |
13 | namespace Exomia.Framework.Example.JumpAndRun.Components
14 | {
15 | [EntityComponentConfiguration(PoolSize = 32)]
16 | sealed class GravityComponent
17 | {
18 | public float Gravity;
19 | }
20 | }
--------------------------------------------------------------------------------
/examples/Exomia.Framework.Example.JumpAndRun/Components/InputComponent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.ECS.Attributes;
12 |
13 | namespace Exomia.Framework.Example.JumpAndRun.Components
14 | {
15 | [EntityComponentConfiguration(PoolSize = 8)]
16 | sealed class InputComponent
17 | {
18 | public bool Left { get; set; }
19 | public bool Right { get; set; }
20 | public bool Jump { get; set; }
21 | }
22 | }
--------------------------------------------------------------------------------
/examples/Exomia.Framework.Example.JumpAndRun/Components/PositionComponent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.ECS.Attributes;
12 | using SharpDX;
13 |
14 | namespace Exomia.Framework.Example.JumpAndRun.Components
15 | {
16 | [EntityComponentConfiguration(PoolSize = 32)]
17 | sealed class PositionComponent
18 | {
19 | public Vector2 Position;
20 | }
21 | }
--------------------------------------------------------------------------------
/examples/Exomia.Framework.Example.JumpAndRun/Components/VelocityComponent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using SharpDX;
12 |
13 | namespace Exomia.Framework.Example.JumpAndRun.Components
14 | {
15 | sealed class VelocityComponent
16 | {
17 | public Vector2 Velocity;
18 | }
19 | }
--------------------------------------------------------------------------------
/examples/Exomia.Framework.Example.JumpAndRun/Map.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Example.JumpAndRun
12 | {
13 | class Map
14 | {
15 | public string MapId { get; }
16 | public Texture Texture { get; set; }
17 | public Grid Grid { get; set; }
18 | public string[]? References { get; set; }
19 |
20 | public Map(string mapId)
21 | {
22 | MapId = mapId;
23 | }
24 | }
25 |
26 | readonly struct Texture
27 | {
28 | public readonly string Asset;
29 | public readonly int Columns;
30 | public readonly int Rows;
31 | public readonly int Width;
32 | public readonly int Height;
33 |
34 | public Texture(string asset, int columns, int rows, int width, int height)
35 | {
36 | Asset = asset;
37 | Columns = columns;
38 | Rows = rows;
39 | Width = width;
40 | Height = height;
41 | }
42 | }
43 |
44 | readonly struct Grid
45 | {
46 | public readonly int Columns;
47 | public readonly int Row;
48 | public readonly int Width;
49 | public readonly int Height;
50 | public readonly int[] Indices;
51 |
52 | public Grid(int columns, int row, int width, int height, int[] indices)
53 | {
54 | Columns = columns;
55 | Row = row;
56 | Width = width;
57 | Height = height;
58 | Indices = indices;
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/examples/Exomia.Framework.Example.JumpAndRun/Program.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Example.JumpAndRun
12 | {
13 | class Program
14 | {
15 | private static void Main(string[] args)
16 | {
17 | using (Game.Game g = new JumpAndRunGame())
18 | {
19 | g.Run();
20 | }
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/examples/Exomia.Framework.Example.JumpAndRun/Systems/InputSystem.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.ECS;
12 | using Exomia.ECS.Attributes;
13 | using Exomia.ECS.Systems;
14 | using Exomia.Framework.Example.JumpAndRun.Components;
15 | using Exomia.Framework.Game;
16 |
17 | namespace Exomia.Framework.Example.JumpAndRun.Systems
18 | {
19 | [EntitySystemConfiguration(
20 | nameof(InputSystem), EntitySystemType.Update, Before = new[] { nameof(PhysicSystem), nameof(CollisionSystem) })]
21 | sealed class InputSystem : EntitySystemBaseR2
22 | {
23 | ///
24 | public InputSystem(EntityManager manager)
25 | : base(manager) { }
26 |
27 | ///
28 | protected override void Tick(GameTime gameTime, Entity entity, InputComponent c1, VelocityComponent c2)
29 | {
30 | if (c1.Jump)
31 | {
32 | c1.Jump = false;
33 | c2.Velocity.Y -= 600;
34 | }
35 |
36 | if (c1.Left)
37 | {
38 | c2.Velocity.X = -60;
39 | }
40 |
41 | if (c1.Right)
42 | {
43 | c2.Velocity.X = +60;
44 | }
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/examples/Exomia.Framework.Example.JumpAndRun/Systems/PhysicSystem.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.ECS;
12 | using Exomia.ECS.Attributes;
13 | using Exomia.ECS.Systems;
14 | using Exomia.Framework.Example.JumpAndRun.Components;
15 | using Exomia.Framework.Game;
16 |
17 | namespace Exomia.Framework.Example.JumpAndRun.Systems
18 | {
19 | [EntitySystemConfiguration(nameof(PhysicSystem), EntitySystemType.Update)]
20 | sealed class PhysicSystem : EntitySystemBaseR3
21 | {
22 | ///
23 | public PhysicSystem(EntityManager manager)
24 | : base(manager) { }
25 |
26 | ///
27 | protected override void Tick(GameTime gameTime,
28 | Entity entity,
29 | PositionComponent c1,
30 | VelocityComponent c2,
31 | GravityComponent c3)
32 | {
33 | c2.Velocity.Y += c3.Gravity * gameTime.DeltaTimeS;
34 | c1.Position += c2.Velocity * gameTime.DeltaTimeS;
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/examples/Exomia.Framework.Example.JumpAndRun/Systems/RenderSystem.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.ECS;
12 | using Exomia.ECS.Attributes;
13 | using Exomia.ECS.Systems;
14 | using Exomia.Framework.Example.JumpAndRun.Components;
15 | using Exomia.Framework.Game;
16 | using Exomia.Framework.Graphics;
17 | using SharpDX;
18 |
19 | namespace Exomia.Framework.Example.JumpAndRun.Systems
20 | {
21 | [EntitySystemConfiguration(nameof(RenderSystem), EntitySystemType.Draw)]
22 | sealed class RenderSystem : EntitySystemBaseR2
23 | {
24 | private SpriteBatch _spriteBatch = null!;
25 |
26 | ///
27 | public RenderSystem(EntityManager manager)
28 | : base(manager) { }
29 |
30 | ///
31 | public override bool Begin()
32 | {
33 | _spriteBatch.Begin();
34 | return base.Begin();
35 | }
36 |
37 | ///
38 | public override void End()
39 | {
40 | _spriteBatch.End();
41 | }
42 |
43 | ///
44 | protected override void OnInitialize(IServiceRegistry registry)
45 | {
46 | _spriteBatch = new SpriteBatch(registry.GetService());
47 | }
48 |
49 | ///
50 | protected override void Tick(GameTime gameTime, Entity entity, PositionComponent c1, BodyComponent c2)
51 | {
52 | RectangleF r = c2.Body;
53 | r.X += c1.Position.X;
54 | r.Y += c1.Position.Y;
55 |
56 | _spriteBatch.DrawRectangle(r, Color.Red, 4, 0, c2.Origin, 1, 0);
57 | _spriteBatch.DrawCircle(c1.Position, 4, Color.White, 1, 1, 4, 0);
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/examples/Exomia.Framework.Example.JumpAndRun/assets/maps/001/001.json:
--------------------------------------------------------------------------------
1 | {
2 | "texture": {
3 | "file": "map_001.png",
4 | "columns": 3,
5 | "rows": 3,
6 | "width": 128,
7 | "height": 128
8 | },
9 | "references": [
10 | "002"
11 | ],
12 | "items": [
13 | {
14 | "name": "BlockStart",
15 | "index": 6
16 | },
17 | {
18 | "name": "BlockMiddle",
19 | "index": 7
20 |
21 | }, {
22 | "name": "BlockEnd",
23 | "index": 8
24 | }
25 | ],
26 | "grid": {
27 | "columns": 10,
28 | "rows": 2,
29 | "width": 32,
30 | "height": 32,
31 | "indices": [
32 | -1,
33 | -1,
34 | -1,
35 | -1,
36 | -1,
37 | -1,
38 | -1,
39 | -1,
40 | -1,
41 | -1,
42 | 6,
43 | 7,
44 | 7,
45 | 7,
46 | 7,
47 | 7,
48 | 7,
49 | 7,
50 | 7,
51 | 8
52 | ]
53 | }
54 | }
--------------------------------------------------------------------------------
/examples/Exomia.Framework.Example.JumpAndRun/assets/maps/001/map_001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/examples/Exomia.Framework.Example.JumpAndRun/assets/maps/001/map_001.png
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/icon.png
--------------------------------------------------------------------------------
/src/Exomia.Framework/Components/Model3DViewerComponent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using Exomia.Framework.Game;
13 |
14 | namespace Exomia.Framework.Components
15 | {
16 | ///
17 | /// A model 3 d viewer component. This class cannot be inherited.
18 | ///
19 | public sealed class Model3DViewerComponent : DrawableComponent
20 | {
21 | private readonly string _modelAsset;
22 |
23 | ///
24 | public Model3DViewerComponent(string modelAsset, string name)
25 | : base(name)
26 | {
27 | _modelAsset = modelAsset;
28 | }
29 |
30 | ///
31 | public override void Update(GameTime gameTime)
32 | {
33 | throw new NotImplementedException();
34 | }
35 |
36 | ///
37 | public override void Draw(GameTime gameTime)
38 | {
39 | throw new NotImplementedException();
40 | }
41 |
42 | ///
43 | protected override void OnLoadContent(IServiceRegistry registry) { }
44 | }
45 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/ContentReadableAttribute.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework.Content
14 | {
15 | ///
16 | /// used to mark a content readable class
17 | ///
18 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
19 | public sealed class ContentReadableAttribute : Attribute
20 | {
21 | internal IContentReader Reader { get; }
22 |
23 | ///
24 | /// Initializes a new instance of the class.
25 | ///
26 | ///
27 | /// the content reader type
28 | ///
29 | ///
30 | /// Thrown when a Type Load error condition occurs.
31 | public ContentReadableAttribute(Type reader)
32 | {
33 | Reader = System.Activator.CreateInstance(reader) as IContentReader ??
34 | throw new TypeLoadException(
35 | $"can not create an instance of {nameof(IContentReader)} from type: {reader.AssemblyQualifiedName}");
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/ContentReaderParameters.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.IO;
13 |
14 | namespace Exomia.Framework.Content
15 | {
16 | ///
17 | /// The content reader parameters.
18 | ///
19 | public struct ContentReaderParameters
20 | {
21 | ///
22 | /// Name of the asset currently loaded when using
23 | /// .
24 | ///
25 | public string AssetName { get; }
26 |
27 | ///
28 | /// Type of the asset currently loaded when using
29 | /// .
30 | ///
31 | public Type AssetType { get; }
32 |
33 | ///
34 | /// Stream of the asset to load.
35 | ///
36 | public Stream Stream { get; }
37 |
38 | ///
39 | /// This parameter is an out parameter for .
40 | /// Set to true to let the ContentManager close the stream once the reader is done.
41 | ///
42 | public bool KeepStreamOpen { get; set; }
43 |
44 | ///
45 | /// Initializes a new instance of the class.
46 | ///
47 | public ContentReaderParameters(string assetName, Type assetType, Stream stream, bool keepStreamOpen = false)
48 | {
49 | AssetName = assetName;
50 | AssetType = assetType;
51 | Stream = stream;
52 | KeepStreamOpen = keepStreamOpen;
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/Exceptions/AssetNotFoundException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework.Content.Exceptions
14 | {
15 | ///
16 | /// Thrown than an asset is not found.
17 | ///
18 | public class AssetNotFoundException : Exception
19 | {
20 | ///
21 | ///
22 | /// Initializes a new instance of the
23 | /// class.
24 | ///
25 | public AssetNotFoundException() { }
26 |
27 | ///
28 | ///
29 | /// Initializes a new instance of the class
30 | /// with the specified message.
31 | ///
32 | /// The exception message.
33 | public AssetNotFoundException(string message)
34 | : base(message) { }
35 |
36 | ///
37 | ///
38 | /// Initializes a new instance of the class
39 | /// with the specified message and inner
40 | /// exception.
41 | ///
42 | /// The exception message.
43 | /// The inner exception.
44 | public AssetNotFoundException(string message, Exception? innerException)
45 | : base(message, innerException) { }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/IContentReader.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Content
12 | {
13 | ///
14 | /// An interface to read content.
15 | ///
16 | public interface IContentReader
17 | {
18 | ///
19 | /// Reads the content of a particular data from a stream.
20 | ///
21 | /// The content manager.
22 | /// [in,out].
23 | ///
24 | /// The data decoded from the stream, or null if the kind of asset is not supported by this
25 | /// content reader.
26 | ///
27 | object? ReadContent(IContentManager contentManager, ref ContentReaderParameters parameters);
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/IContentReaderFactory.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework.Content
14 | {
15 | ///
16 | /// A factory to create when a specific type is requested from
17 | /// the .
18 | ///
19 | public interface IContentReaderFactory
20 | {
21 | ///
22 | /// Returns an instance of a for loading the specified type or
23 | /// null if not handled by this factory.
24 | ///
25 | /// The type.
26 | ///
27 | /// [out] An instance of a for loading the
28 | /// specified type.
29 | ///
30 | ///
31 | /// true if a is returned; false otherwise.
32 | ///
33 | bool TryCreate(Type type, out IContentReader reader);
34 | }
35 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/Loader/IModelFileLoader.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System.IO;
12 |
13 | namespace Exomia.Framework.Content.Loader
14 | {
15 | ///
16 | /// Interface for model file loader.
17 | ///
18 | /// Type of the model.
19 | interface IModelFileLoader
20 | {
21 | ///
22 | /// Loads the model from the given stream.
23 | ///
24 | /// The model file stream to load the model from.
25 | ///
26 | /// A TModel.
27 | ///
28 | TModel Load(Stream stream);
29 | }
30 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/Loader/Parser/ObjParser/FaceParser.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.Globalization;
13 | using Exomia.Framework.Graphics.Model;
14 |
15 | namespace Exomia.Framework.Content.Loader.Parser.ObjParser
16 | {
17 | ///
18 | /// A face parser.
19 | ///
20 | sealed class FaceParser : IParser
21 | {
22 | ///
23 | /// The keyword.
24 | ///
25 | internal const string KEYWORD = "f";
26 |
27 | private static readonly char[] s_splitChars = { ' ' };
28 | private static readonly char[] s_faceSplitChars = { '/' };
29 |
30 | ///
31 | public Obj.Face Parse(string value)
32 | {
33 | string[] vertices = value.Split(s_splitChars, StringSplitOptions.RemoveEmptyEntries);
34 |
35 | Obj.Face face = new Obj.Face(vertices.Length);
36 | for (int i = 0; i < face.Vertices.Length; i++)
37 | {
38 | string[] parts = vertices[i].Split(s_faceSplitChars, StringSplitOptions.None);
39 | face.Vertices[i] = new Obj.Face.Vertex(
40 | int.Parse(parts[0], CultureInfo.InvariantCulture.NumberFormat),
41 | parts.Length > 1 && parts[1].Length != 0
42 | ? int.Parse(parts[1], CultureInfo.InvariantCulture.NumberFormat)
43 | : 0,
44 | parts.Length > 2 && parts[2].Length != 0
45 | ? int.Parse(parts[2], CultureInfo.InvariantCulture.NumberFormat)
46 | : 0);
47 | }
48 | return face;
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/Loader/Parser/ObjParser/IParser.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Content.Loader.Parser.ObjParser
12 | {
13 | ///
14 | /// Interface for a parser.
15 | ///
16 | /// Generic type parameter.
17 | interface IParser where T : struct
18 | {
19 | ///
20 | /// Parses the value to the given type of T.
21 | ///
22 | /// The value.
23 | ///
24 | /// A T.
25 | ///
26 | T Parse(string value);
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/Loader/Parser/ObjParser/NormalParser.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.Globalization;
13 | using Exomia.Framework.Graphics.Model;
14 |
15 | namespace Exomia.Framework.Content.Loader.Parser.ObjParser
16 | {
17 | ///
18 | /// A normal parser.
19 | ///
20 | sealed class NormalParser : IParser
21 | {
22 | ///
23 | /// The keyword.
24 | ///
25 | internal const string KEYWORD = "vn";
26 |
27 | private static readonly char[] s_splitChars = { ' ' };
28 |
29 | ///
30 | public Obj.Normal Parse(string value)
31 | {
32 | string[] parts = value.Split(s_splitChars, StringSplitOptions.RemoveEmptyEntries);
33 | return new Obj.Normal(
34 | float.Parse(parts[0], CultureInfo.InvariantCulture.NumberFormat),
35 | float.Parse(parts[1], CultureInfo.InvariantCulture.NumberFormat),
36 | float.Parse(parts[2], CultureInfo.InvariantCulture.NumberFormat));
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/Loader/Parser/ObjParser/TextureParser.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.Globalization;
13 | using Exomia.Framework.Graphics.Model;
14 |
15 | namespace Exomia.Framework.Content.Loader.Parser.ObjParser
16 | {
17 | ///
18 | /// A normal parser.
19 | ///
20 | sealed class TextureParser : IParser
21 | {
22 | ///
23 | /// The keyword.
24 | ///
25 | internal const string KEYWORD = "vt";
26 |
27 | private static readonly char[] s_splitChars = { ' ' };
28 |
29 | ///
30 | public Obj.Texture Parse(string value)
31 | {
32 | string[] parts = value.Split(s_splitChars, StringSplitOptions.RemoveEmptyEntries);
33 | return new Obj.Texture(
34 | float.Parse(parts[0], CultureInfo.InvariantCulture.NumberFormat),
35 | parts.Length < 2
36 | ? 1.0f
37 | : float.Parse(parts[1], CultureInfo.InvariantCulture.NumberFormat),
38 | parts.Length < 3
39 | ? 1.0f
40 | : float.Parse(parts[2], CultureInfo.InvariantCulture.NumberFormat));
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/Loader/Parser/ObjParser/VertexParser.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.Globalization;
13 | using Exomia.Framework.Graphics.Model;
14 |
15 | namespace Exomia.Framework.Content.Loader.Parser.ObjParser
16 | {
17 | ///
18 | /// A vertex parser.
19 | ///
20 | sealed class VertexParser : IParser
21 | {
22 | ///
23 | /// The keyword.
24 | ///
25 | internal const string KEYWORD = "v";
26 |
27 | private static readonly char[] s_splitChars = { ' ' };
28 |
29 | ///
30 | public Obj.Vertex Parse(string value)
31 | {
32 | string[] parts = value.Split(s_splitChars, StringSplitOptions.RemoveEmptyEntries);
33 | return new Obj.Vertex(
34 | float.Parse(parts[0], CultureInfo.InvariantCulture.NumberFormat),
35 | float.Parse(parts[1], CultureInfo.InvariantCulture.NumberFormat),
36 | float.Parse(parts[2], CultureInfo.InvariantCulture.NumberFormat),
37 | parts.Length < 4
38 | ? 1.0f
39 | : float.Parse(parts[3], CultureInfo.InvariantCulture.NumberFormat));
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/Resolver/ContentResolverAttribute.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework.Content.Resolver
14 | {
15 | ///
16 | /// used to mark a content readable class.
17 | ///
18 | [AttributeUsage(AttributeTargets.Class)]
19 | public sealed class ContentResolverAttribute : Attribute
20 | {
21 | ///
22 | /// Gets the order.
23 | ///
24 | ///
25 | /// The order.
26 | ///
27 | internal int Order { get; }
28 |
29 | ///
30 | ///
31 | /// Initializes a new instance of the
32 | ///
33 | /// class.
34 | ///
35 | /// the order in which the resolvers should be gone through.
36 | public ContentResolverAttribute(int order)
37 | {
38 | Order = order;
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/Resolver/E0FileStreamContentResolver.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System.IO;
12 | using Exomia.Framework.ContentSerialization;
13 |
14 | namespace Exomia.Framework.Content.Resolver
15 | {
16 | ///
17 | /// A 0 file stream content resolver. This class cannot be inherited.
18 | ///
19 | [ContentResolver(int.MinValue + 1)]
20 | sealed class E0FileStreamContentResolver : IContentResolver
21 | {
22 | ///
23 | public bool Exists(string assetName)
24 | {
25 | return Path.GetExtension(assetName) == ContentSerializer.DEFAULT_EXTENSION && File.Exists(assetName);
26 | }
27 |
28 | ///
29 | public Stream Resolve(string assetName)
30 | {
31 | return new FileStream(assetName, FileMode.Open, FileAccess.Read);
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/Resolver/E1FileStreamContentResolver.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System.IO;
12 | using Exomia.Framework.ContentSerialization.Compression;
13 |
14 | namespace Exomia.Framework.Content.Resolver
15 | {
16 | ///
17 | /// A 1 file stream content resolver. This class cannot be inherited.
18 | ///
19 | [ContentResolver(int.MinValue)]
20 | sealed class E1FileStreamContentResolver : IContentResolver
21 | {
22 | ///
23 | public bool Exists(string assetName)
24 | {
25 | return Path.GetExtension(assetName) == ContentCompressor.DEFAULT_COMPRESSED_EXTENSION &&
26 | File.Exists(assetName);
27 | }
28 |
29 | ///
30 | public Stream? Resolve(string assetName)
31 | {
32 | using FileStream stream = new FileStream(assetName, FileMode.Open, FileAccess.Read);
33 | return ContentCompressor.DecompressStream(stream, out Stream stream2) ? stream2 : null;
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/Resolver/EmbeddedResource/E0EmbeddedResourceStreamResolver.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.IO;
13 | using System.Reflection;
14 | using Exomia.Framework.ContentSerialization;
15 |
16 | namespace Exomia.Framework.Content.Resolver.EmbeddedResource
17 | {
18 | ///
19 | /// A 0 embedded resource stream resolver.
20 | ///
21 | [ContentResolver(int.MinValue + 1)]
22 | class E0EmbeddedResourceStreamResolver : IEmbeddedResourceResolver
23 | {
24 | ///
25 | public bool Exists(Type assetType, string assetName, out Assembly assembly)
26 | {
27 | if (Path.GetExtension(assetName) == ContentSerializer.DEFAULT_EXTENSION)
28 | {
29 | return EmbeddedResourceStreamResolver.ExistsInternal(assetType, assetName, out assembly);
30 | }
31 |
32 | assembly = null!;
33 | return false;
34 | }
35 |
36 | ///
37 | public Stream? Resolve(Assembly assembly, string assetName)
38 | {
39 | return EmbeddedResourceStreamResolver.GetManifestResourceStreamInternal(assembly, assetName);
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/Resolver/EmbeddedResource/E1EmbeddedResourceStreamResolver.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.IO;
13 | using System.Reflection;
14 | using Exomia.Framework.ContentSerialization.Compression;
15 |
16 | namespace Exomia.Framework.Content.Resolver.EmbeddedResource
17 | {
18 | ///
19 | /// A 1 embedded resource stream resolver.
20 | ///
21 | [ContentResolver(int.MinValue)]
22 | class E1EmbeddedResourceStreamResolver : IEmbeddedResourceResolver
23 | {
24 | ///
25 | public bool Exists(Type assetType, string assetName, out Assembly assembly)
26 | {
27 | if (Path.GetExtension(assetName) == ContentCompressor.DEFAULT_COMPRESSED_EXTENSION)
28 | {
29 | return EmbeddedResourceStreamResolver.ExistsInternal(assetType, assetName, out assembly);
30 | }
31 |
32 | assembly = null!;
33 | return false;
34 | }
35 |
36 | ///
37 | public Stream? Resolve(Assembly assembly, string assetName)
38 | {
39 | using Stream stream = EmbeddedResourceStreamResolver.GetManifestResourceStreamInternal(assembly, assetName);
40 | return ContentCompressor.DecompressStream(stream, out Stream stream2) ? stream2 : null;
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/Resolver/EmbeddedResource/IEmbeddedResourceResolver.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.IO;
13 | using System.Reflection;
14 |
15 | namespace Exomia.Framework.Content.Resolver.EmbeddedResource
16 | {
17 | ///
18 | /// A embedded resource content resolver is in charge of resolve a embedded resource stream.
19 | ///
20 | public interface IEmbeddedResourceResolver
21 | {
22 | ///
23 | /// Checks if the specified asset name exists.
24 | ///
25 | /// Type of the asset.
26 | /// Name of the asset.
27 | /// [out] The assembly in which the resource exists.
28 | ///
29 | /// true if the specified asset name exists; false otherwise.
30 | ///
31 | bool Exists(Type assetType, string assetName, out Assembly assembly);
32 |
33 | ///
34 | /// Resolves the specified asset name to a stream.
35 | ///
36 | /// The assembly in which the resource exists.
37 | /// Name of the asset.
38 | ///
39 | /// The stream of the asset. This value can be null if this resolver was not able to locate the asset.
40 | ///
41 | Stream? Resolve(Assembly assembly, string assetName);
42 | }
43 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/Resolver/FileStreamContentResolver.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System.IO;
12 |
13 | namespace Exomia.Framework.Content.Resolver
14 | {
15 | ///
16 | /// A file stream content resolver. This class cannot be inherited.
17 | ///
18 | [ContentResolver(int.MaxValue)]
19 | sealed class FileStreamContentResolver : IContentResolver
20 | {
21 | ///
22 | public bool Exists(string assetName)
23 | {
24 | return File.Exists(assetName);
25 | }
26 |
27 | ///
28 | public Stream Resolve(string assetName)
29 | {
30 | return new FileStream(assetName, FileMode.Open, FileAccess.Read);
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Content/Resolver/IContentResolver.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System.IO;
12 |
13 | namespace Exomia.Framework.Content.Resolver
14 | {
15 | ///
16 | /// A content resolver is in charge of locating a stream from an asset name.
17 | ///
18 | public interface IContentResolver
19 | {
20 | ///
21 | /// Checks if the specified asset name exists.
22 | ///
23 | /// Name of the asset.
24 | ///
25 | /// true if the specified asset name exists; false otherwise.
26 | ///
27 | bool Exists(string assetName);
28 |
29 | ///
30 | /// Resolves the specified asset name to a stream.
31 | ///
32 | /// Name of the asset.
33 | ///
34 | /// The stream of the asset. This value can be null if this resolver was not able to locate the asset.
35 | ///
36 | Stream? Resolve(string assetName);
37 | }
38 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/Compression/CompressMode.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.ContentSerialization.Compression
12 | {
13 | ///
14 | /// Values that represent CompressMode.
15 | ///
16 | public enum CompressMode : byte
17 | {
18 | ///
19 | /// An enum constant representing the gzip option (default).
20 | ///
21 | Gzip = 1
22 | }
23 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/ContentSerializationReader.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.ContentSerialization
12 | {
13 | ///
14 | /// abstract implementation for an
15 | ///
16 | ///
17 | /// type to read.
18 | public abstract class ContentSerializationReader : IContentSerializationReader
19 | {
20 | ///
21 | public object Read(ContentSerializationContext context)
22 | {
23 | return ReadContext(context)!;
24 | }
25 |
26 | ///
27 | /// Returns a new created object from the context of type T.
28 | ///
29 | /// Context.
30 | ///
31 | /// new T.
32 | ///
33 | public abstract T ReadContext(ContentSerializationContext context);
34 | }
35 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/ContentSerializationWriter.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.ContentSerialization
12 | {
13 | ///
14 | /// abstract implementation for an
15 | ///
16 | ///
17 | /// type to write.
18 | public abstract class ContentSerializationWriter : IContentSerializationWriter
19 | {
20 | ///
21 | public void Write(ContentSerializationContext context, object obj)
22 | {
23 | WriteContext(context, (T)obj);
24 | }
25 |
26 | ///
27 | /// Write the object (of type T) information into the context.
28 | ///
29 | /// ref Context.
30 | /// Object.
31 | public abstract void WriteContext(ContentSerializationContext context, T obj);
32 | }
33 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/Exceptions/CSContextKeyException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework.ContentSerialization.Exceptions
14 | {
15 | ///
16 | /// Thrown than a context exception happen.
17 | ///
18 | public sealed class CSContextKeyException : ArgumentException
19 | {
20 | ///
21 | public CSContextKeyException() { }
22 |
23 | ///
24 | public CSContextKeyException(string message)
25 | : base(message) { }
26 |
27 | ///
28 | public CSContextKeyException(string message, string paramName)
29 | : base(message, paramName) { }
30 |
31 | ///
32 | public CSContextKeyException(string message, Exception innerException)
33 | : base(message, innerException) { }
34 |
35 | ///
36 | public CSContextKeyException(string message, string paramName, Exception innerException)
37 | : base(message, paramName, innerException) { }
38 | }
39 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/Exceptions/CSReaderException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework.ContentSerialization.Exceptions
14 | {
15 | ///
16 | /// Thrown than a reader exception happen.
17 | ///
18 | public sealed class CSReaderException : Exception
19 | {
20 | ///
21 | public CSReaderException() { }
22 |
23 | ///
24 | public CSReaderException(string message)
25 | : base(message) { }
26 |
27 | ///
28 | public CSReaderException(string message, Exception innerException)
29 | : base(message, innerException) { }
30 | }
31 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/Exceptions/CSTypeException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework.ContentSerialization.Exceptions
14 | {
15 | ///
16 | /// Thrown than a type is not found.
17 | ///
18 | public sealed class CSTypeException : Exception
19 | {
20 | ///
21 | public CSTypeException() { }
22 |
23 | ///
24 | public CSTypeException(string message)
25 | : base(message) { }
26 |
27 | ///
28 | public CSTypeException(string message, Exception innerException)
29 | : base(message, innerException) { }
30 | }
31 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/Exceptions/CSWriterException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework.ContentSerialization.Exceptions
14 | {
15 | ///
16 | /// Thrown than a writer exception happen.
17 | ///
18 | public sealed class CSWriterException : Exception
19 | {
20 | ///
21 | public CSWriterException() { }
22 |
23 | ///
24 | public CSWriterException(string message)
25 | : base(message) { }
26 |
27 | ///
28 | public CSWriterException(string message, Exception innerException)
29 | : base(message, innerException) { }
30 | }
31 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/IContentSerializationReader.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.ContentSerialization
12 | {
13 | ///
14 | /// An interface to handle content reading
15 | ///
16 | public interface IContentSerializationReader
17 | {
18 | ///
19 | /// Returns a new created object from the context
20 | ///
21 | /// Context
22 | /// new object
23 | object Read(ContentSerializationContext context);
24 | }
25 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/IContentSerializationWriter.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.ContentSerialization
12 | {
13 | ///
14 | /// An interface to handle content writing
15 | ///
16 | public interface IContentSerializationWriter
17 | {
18 | ///
19 | /// Write the object information into the context
20 | ///
21 | /// ref Context
22 | /// Object
23 | void Write(ContentSerializationContext context, object obj);
24 | }
25 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/Readers/ColorContentSerializationReader.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using SharpDX;
12 |
13 | namespace Exomia.Framework.ContentSerialization.Readers
14 | {
15 | sealed class ColorContentSerializationReader : ContentSerializationReader
16 | {
17 | ///
18 | public override Color ReadContext(ContentSerializationContext context)
19 | {
20 | return new Color
21 | {
22 | A = context.Get(nameof(Color.A)),
23 | R = context.Get(nameof(Color.R)),
24 | G = context.Get(nameof(Color.G)),
25 | B = context.Get(nameof(Color.B))
26 | };
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/Readers/RectangleContentSerializationReader.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using SharpDX;
12 |
13 | namespace Exomia.Framework.ContentSerialization.Readers
14 | {
15 | sealed class RectangleContentSerializationReader : ContentSerializationReader
16 | {
17 | ///
18 | public override Rectangle ReadContext(ContentSerializationContext context)
19 | {
20 | return new Rectangle
21 | {
22 | X = context.Get(nameof(Rectangle.X)),
23 | Y = context.Get(nameof(Rectangle.Y)),
24 | Width = context.Get(nameof(Rectangle.Width)),
25 | Height = context.Get(nameof(Rectangle.Height))
26 | };
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/Readers/RectangleFContentSerializationReader.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using SharpDX;
12 |
13 | namespace Exomia.Framework.ContentSerialization.Readers
14 | {
15 | sealed class RectangleFContentSerializationReader : ContentSerializationReader
16 | {
17 | ///
18 | public override RectangleF ReadContext(ContentSerializationContext context)
19 | {
20 | return new RectangleF
21 | {
22 | X = context.Get(nameof(RectangleF.X)),
23 | Y = context.Get(nameof(RectangleF.Y)),
24 | Width = context.Get(nameof(RectangleF.Width)),
25 | Height = context.Get(nameof(RectangleF.Height))
26 | };
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/Readers/Vector2ContentSerializationReader.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using SharpDX;
12 |
13 | namespace Exomia.Framework.ContentSerialization.Readers
14 | {
15 | sealed class Vector2ContentSerializationReader : ContentSerializationReader
16 | {
17 | ///
18 | public override Vector2 ReadContext(ContentSerializationContext context)
19 | {
20 | return new Vector2 { X = context.Get(nameof(Vector2.X)), Y = context.Get(nameof(Vector2.Y)) };
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/Readers/Vector3ContentSerializationReader.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using SharpDX;
12 |
13 | namespace Exomia.Framework.ContentSerialization.Readers
14 | {
15 | sealed class Vector3ContentSerializationReader : ContentSerializationReader
16 | {
17 | ///
18 | public override Vector3 ReadContext(ContentSerializationContext context)
19 | {
20 | return new Vector3
21 | {
22 | X = context.Get(nameof(Vector3.X)),
23 | Y = context.Get(nameof(Vector3.Y)),
24 | Z = context.Get(nameof(Vector3.Z))
25 | };
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/Writers/ColorContentSerializationWriter.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using SharpDX;
12 |
13 | namespace Exomia.Framework.ContentSerialization.Writers
14 | {
15 | sealed class ColorContentSerializationWriter : ContentSerializationWriter
16 | {
17 | ///
18 | public override void WriteContext(ContentSerializationContext context, Color obj)
19 | {
20 | context.Set(nameof(Color.A), obj.A);
21 | context.Set(nameof(Color.R), obj.R);
22 | context.Set(nameof(Color.G), obj.G);
23 | context.Set(nameof(Color.B), obj.B);
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/Writers/RectangleContentSerializationWriter.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using SharpDX;
12 |
13 | namespace Exomia.Framework.ContentSerialization.Writers
14 | {
15 | sealed class RectangleContentSerializationWriter : ContentSerializationWriter
16 | {
17 | ///
18 | public override void WriteContext(ContentSerializationContext context, Rectangle obj)
19 | {
20 | context.Set(nameof(Rectangle.X), obj.X);
21 | context.Set(nameof(Rectangle.Y), obj.Y);
22 | context.Set(nameof(Rectangle.Width), obj.Width);
23 | context.Set(nameof(Rectangle.Height), obj.Height);
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/Writers/RectangleFContentSerializationWriter.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using SharpDX;
12 |
13 | namespace Exomia.Framework.ContentSerialization.Writers
14 | {
15 | sealed class RectangleFContentSerializationWriter : ContentSerializationWriter
16 | {
17 | ///
18 | public override void WriteContext(ContentSerializationContext context, RectangleF obj)
19 | {
20 | context.Set(nameof(RectangleF.X), obj.X);
21 | context.Set(nameof(RectangleF.Y), obj.Y);
22 | context.Set(nameof(RectangleF.Width), obj.Width);
23 | context.Set(nameof(RectangleF.Height), obj.Height);
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/Writers/Vector2ContentSerializationWriter.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using SharpDX;
12 |
13 | namespace Exomia.Framework.ContentSerialization.Writers
14 | {
15 | sealed class Vector2ContentSerializationWriter : ContentSerializationWriter
16 | {
17 | ///
18 | public override void WriteContext(ContentSerializationContext context, Vector2 obj)
19 | {
20 | context.Set(nameof(Vector2.X), obj.X);
21 | context.Set(nameof(Vector2.Y), obj.Y);
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ContentSerialization/Writers/Vector3ContentSerializationWriter.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using SharpDX;
12 |
13 | namespace Exomia.Framework.ContentSerialization.Writers
14 | {
15 | sealed class Vector3ContentSerializationWriter : ContentSerializationWriter
16 | {
17 | ///
18 | public override void WriteContext(ContentSerializationContext context, Vector3 obj)
19 | {
20 | context.Set(nameof(Vector3.X), obj.X);
21 | context.Set(nameof(Vector3.Y), obj.Y);
22 | context.Set(nameof(Vector3.Z), obj.Z);
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/DrawableComparer.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System.Collections.Generic;
12 |
13 | namespace Exomia.Framework
14 | {
15 | ///
16 | /// A drawable comparer. This class cannot be inherited.
17 | ///
18 | sealed class DrawableComparer : IComparer
19 | {
20 | ///
21 | /// The default.
22 | ///
23 | public static readonly DrawableComparer Default = new DrawableComparer();
24 |
25 | ///
26 | public int Compare(IDrawable left, IDrawable right)
27 | {
28 | if (Equals(left, right))
29 | {
30 | return 0;
31 | }
32 |
33 | return left.DrawOrder < right.DrawOrder ? 1 : -1;
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Exomia.Framework.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Exomia.Framework.snk
--------------------------------------------------------------------------------
/src/Exomia.Framework/Extensions/DeconstructExtensions.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | #if NETSTANDARD2_0
12 | using System.Collections.Generic;
13 |
14 | namespace Exomia.Framework.Extensions
15 | {
16 | ///
17 | /// A deconstruct extensions.
18 | ///
19 | public static class DeconstructExtensions
20 | {
21 | ///
22 | /// A type deconstruct-or that extracts the individual members from this object.
23 | ///
24 | /// Type of the key.
25 | /// Type of the value.
26 | /// The kvp.
27 | /// [out] The key.
28 | /// [out] The value.
29 | public static void Deconstruct(this KeyValuePair kvp,
30 | out TKey key,
31 | out TValue value)
32 | {
33 | key = kvp.Key;
34 | value = kvp.Value;
35 | }
36 | }
37 | }
38 | #endif
--------------------------------------------------------------------------------
/src/Exomia.Framework/Extensions/MD5Extension.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System.Security.Cryptography;
12 | using System.Text;
13 |
14 | namespace Exomia.Framework.Extensions
15 | {
16 | ///
17 | /// md5 extension class
18 | ///
19 | public static class MD5Extension
20 | {
21 | ///
22 | /// Convert an object via the 'ToString' method into an md5-format string
23 | ///
24 | /// the object
25 | /// the format
26 | /// md5-format string
27 | public static string ToMD5(this object input, string format = "x2")
28 | {
29 | using (MD5 md5 = MD5.Create())
30 | {
31 | byte[] hash = md5.ComputeHash(Encoding.ASCII.GetBytes(input.ToString()));
32 |
33 | StringBuilder sb = new StringBuilder();
34 | int l = hash.Length;
35 | for (int i = 0; i < l; i++)
36 | {
37 | sb.Append(hash[i].ToString(format));
38 | }
39 | return sb.ToString();
40 | }
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Game/Camera/ICameraComponent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Game.Camera
12 | {
13 | ///
14 | /// Interface for camera component.
15 | ///
16 | public interface ICameraComponent
17 | {
18 | ///
19 | /// Gets the name.
20 | ///
21 | ///
22 | /// The name.
23 | ///
24 | string Name { get; }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Game/Camera/IDisposableCameraComponent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Game.Camera
12 | {
13 | ///
14 | /// Interface for disposable camera component.
15 | ///
16 | public interface IDisposableCameraComponent
17 | {
18 | ///
19 | /// Releases the unmanaged resources used by the Exomia.Framework.Graphics.Camera.ICameraController and optionally
20 | /// releases the managed resources.
21 | ///
22 | /// The camera.
23 | void Dispose(ICamera camera);
24 | }
25 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Game/Camera/IInitializableCameraComponent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Game.Camera
12 | {
13 | ///
14 | /// Interface for initializable camera component.
15 | ///
16 | public interface IInitializableCameraComponent
17 | {
18 | ///
19 | /// Initializes this object.
20 | ///
21 | /// The registry.
22 | /// The camera.
23 | void Initialize(IServiceRegistry registry, ICamera camera);
24 | }
25 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Game/Camera/IUpdateableCameraComponent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Game.Camera
12 | {
13 | ///
14 | /// Interface for updateable camera component.
15 | ///
16 | public interface IUpdateableCameraComponent
17 | {
18 | ///
19 | /// Updates this object.
20 | ///
21 | /// The game time.
22 | /// The camera.
23 | void Update(GameTime gameTime, ICamera camera);
24 | }
25 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Game/Desktop/GamePlatformWindows.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.Framework.Input;
12 |
13 | namespace Exomia.Framework.Game.Desktop
14 | {
15 | sealed class GamePlatformWindows : GamePlatform
16 | {
17 | ///
18 | public GamePlatformWindows(Game game, string title)
19 | : base(game, title) { }
20 |
21 | ///
22 | private protected override IGameWindow CreateGameWindow(Game game, string title)
23 | {
24 | GameWindowWindows gameWindow = new GameWindowWindows(title);
25 | game.Services.AddService(gameWindow.RenderForm);
26 | return gameWindow;
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Game/DisplayType.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Game
12 | {
13 | ///
14 | /// Values that represent DisplayType.
15 | ///
16 | public enum DisplayType
17 | {
18 | ///
19 | /// An enum constant representing the fullscreen option.
20 | ///
21 | Fullscreen = 1 << 0,
22 |
23 | ///
24 | /// An enum constant representing the window option.
25 | ///
26 | Window = 1 << 1,
27 |
28 | ///
29 | /// An enum constant representing the fullscreen window option.
30 | ///
31 | FullscreenWindow = 1 << 2,
32 | }
33 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Game/MultiSampleCount.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Game
12 | {
13 | ///
14 | /// MultiSampleCount enum.
15 | ///
16 | public enum MultiSampleCount
17 | {
18 | ///
19 | /// disabled
20 | ///
21 | None = 0,
22 |
23 | ///
24 | /// msaa x2
25 | ///
26 | MsaaX2 = 2,
27 |
28 | ///
29 | /// msaa x4
30 | ///
31 | MsaaX4 = 4,
32 |
33 | ///
34 | /// msaa x8
35 | ///
36 | MsaaX8 = 8
37 | }
38 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Game/RenderForm.Enums.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Game
12 | {
13 | public sealed partial class RenderForm
14 | {
15 | ///
16 | /// Values that represent FormWindowState.
17 | ///
18 | public enum FormWindowState
19 | {
20 | ///
21 | /// An enum constant representing the normal option.
22 | ///
23 | Normal,
24 |
25 | ///
26 | /// An enum constant representing the minimized option.
27 | ///
28 | Minimized,
29 |
30 | ///
31 | /// An enum constant representing the maximized option.
32 | ///
33 | Maximized
34 | }
35 |
36 | ///
37 | /// Values that represent FormBorderStyle.
38 | ///
39 | public enum FormBorderStyle
40 | {
41 | ///
42 | /// No frame.
43 | ///
44 | None,
45 |
46 | ///
47 | /// A frame whose size can not be changed.
48 | ///
49 | Fixed,
50 |
51 | ///
52 | /// A frame whose size can be changed.
53 | ///
54 | Sizable
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Game/RenderForm.Utils.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.Runtime.CompilerServices;
13 |
14 | namespace Exomia.Framework.Game
15 | {
16 | sealed partial class RenderForm
17 | {
18 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
19 | private static int LowWord(IntPtr number)
20 | {
21 | return (int)number.ToInt64() & 0x0000FFFF;
22 | }
23 |
24 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
25 | private static int HighWord(IntPtr number)
26 | {
27 | return (int)number.ToInt64() >> 16;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Graphics/Model/Material.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System.Runtime.InteropServices;
12 |
13 | namespace Exomia.Framework.Graphics.Model
14 | {
15 | ///
16 | /// A material.
17 | ///
18 | [StructLayout(LayoutKind.Sequential, Size = 16)]
19 | public readonly struct Material
20 | {
21 | ///
22 | /// The ambient.
23 | ///
24 | public readonly float Ambient;
25 |
26 | ///
27 | /// The diffuse.
28 | ///
29 | public readonly float Diffuse;
30 |
31 | ///
32 | /// The specular.
33 | ///
34 | public readonly float Specular;
35 |
36 | ///
37 | /// The shininess.
38 | ///
39 | public readonly float Shininess;
40 |
41 | ///
42 | /// Initializes a new instance of the class.
43 | ///
44 | /// The ambient.
45 | /// The diffuse.
46 | /// The specular.
47 | /// The shininess.
48 | public Material(float ambient, float diffuse, float specular, float shininess)
49 | {
50 | Ambient = ambient;
51 | Diffuse = diffuse;
52 | Specular = specular;
53 | Shininess = shininess;
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Graphics/Model/ObjContentReader.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.Framework.Content;
12 | using Exomia.Framework.Content.Loader;
13 |
14 | namespace Exomia.Framework.Graphics.Model
15 | {
16 | ///
17 | /// An object content reader. This class cannot be inherited.
18 | ///
19 | sealed class ObjContentReader : IContentReader
20 | {
21 | private static readonly IModelFileLoader s_objFileLoader;
22 |
23 | static ObjContentReader()
24 | {
25 | s_objFileLoader = new ObjFileLoader();
26 | }
27 |
28 | ///
29 | public object? ReadContent(IContentManager contentManager, ref ContentReaderParameters parameters)
30 | {
31 | return s_objFileLoader.Load(parameters.Stream);
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Graphics/Shader/ShaderContentReader.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.Framework.Content;
12 |
13 | namespace Exomia.Framework.Graphics.Shader
14 | {
15 | ///
16 | /// A shader content reader. This class cannot be inherited.
17 | ///
18 | sealed class ShaderContentReader : IContentReader
19 | {
20 | ///
21 | public object? ReadContent(IContentManager contentManager, ref ContentReaderParameters parameters)
22 | {
23 | IGraphicsDevice graphicsDevice =
24 | contentManager.ServiceRegistry.GetService();
25 | return ShaderFileLoader.FromStream(graphicsDevice, parameters.Stream);
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Graphics/SpriteBatch.Polygon.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using SharpDX;
12 |
13 | namespace Exomia.Framework.Graphics
14 | {
15 | public sealed partial class SpriteBatch
16 | {
17 | ///
18 | /// Draw polygon.
19 | ///
20 | /// The vertex.
21 | /// The color.
22 | /// The width of the line.
23 | /// The opacity.
24 | /// The depth of the layer.
25 | public void DrawPolygon(Vector2[] vertex, in Color color, float lineWidth, float opacity, float layerDepth)
26 | {
27 | if (vertex.Length > 1)
28 | {
29 | int l = vertex.Length - 1;
30 | for (int i = 0; i < l; i++)
31 | {
32 | DrawLine(vertex[i], vertex[i + 1], color, lineWidth, opacity, layerDepth);
33 | }
34 | DrawLine(vertex[l], vertex[0], color, lineWidth, opacity, layerDepth);
35 | }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Graphics/SpriteFont.Glyph.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.Framework.ContentSerialization;
12 | using SharpDX;
13 |
14 | namespace Exomia.Framework.Graphics
15 | {
16 | public sealed partial class SpriteFont
17 | {
18 | ///
19 | /// A glyph.
20 | ///
21 | [ContentSerializable(typeof(SpriteFontGlyphCR), typeof(SpriteFontGlyphCW))]
22 | public struct Glyph
23 | {
24 | ///
25 | /// The character.
26 | ///
27 | public int Character;
28 |
29 | ///
30 | /// The subrect.
31 | ///
32 | public Rectangle Subrect;
33 |
34 | ///
35 | /// The offset x coordinate.
36 | ///
37 | public int OffsetX;
38 |
39 | ///
40 | /// The offset y coordinate.
41 | ///
42 | public int OffsetY;
43 |
44 | ///
45 | /// The advance.
46 | ///
47 | public int XAdvance;
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Graphics/SpriteFont.Kerning.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.Framework.ContentSerialization;
12 |
13 | namespace Exomia.Framework.Graphics
14 | {
15 | public sealed partial class SpriteFont
16 | {
17 | ///
18 | /// A kerning.
19 | ///
20 | [ContentSerializable(typeof(SpriteFontKerningCR), typeof(SpriteFontKerningCW))]
21 | public struct Kerning
22 | {
23 | ///
24 | /// The first.
25 | ///
26 | public int First;
27 |
28 | ///
29 | /// The second.
30 | ///
31 | public int Second;
32 |
33 | ///
34 | /// The offset.
35 | ///
36 | public int Offset;
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Graphics/SpriteFontContentReader.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.IO;
13 | using Exomia.Framework.Content;
14 | using Exomia.Framework.ContentSerialization;
15 |
16 | namespace Exomia.Framework.Graphics
17 | {
18 | sealed class SpriteFontContentReader : IContentReader
19 | {
20 | ///
21 | public object? ReadContent(IContentManager contentManager, ref ContentReaderParameters parameters)
22 | {
23 | SpriteFont font = ContentSerializer.Read(parameters.Stream);
24 | if (font.ImageData.Length <= 0)
25 | {
26 | return null;
27 | }
28 |
29 | IGraphicsDevice graphicsDevice =
30 | contentManager.ServiceRegistry.GetService();
31 |
32 | try
33 | {
34 | using (MemoryStream ms = new MemoryStream(font.ImageData) { Position = 0 })
35 | {
36 | font.Texture = Texture.Load(graphicsDevice.Device, ms) ??
37 | throw new NullReferenceException($"{nameof(font.Texture)}");
38 | }
39 | }
40 | catch { return null; }
41 |
42 | return font;
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Graphics/SpriteSort/ISpriteSort.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework.Graphics.SpriteSort
14 | {
15 | interface ISpriteSort : IDisposable
16 | {
17 | ///
18 | /// sort a given array of into a given indirect index array
19 | ///
20 | ///
21 | ///
22 | ///
23 | ///
24 | void Sort(SpriteBatch.TextureInfo[] tInfo, int[] arr, int offset, int length);
25 |
26 | ///
27 | /// sort a given array of into a given indirect index array
28 | ///
29 | ///
30 | ///
31 | ///
32 | ///
33 | void SortBf(SpriteBatch.SpriteInfo[] sInfo, int[] arr, int offset, int length);
34 |
35 | ///
36 | /// sort a given array of into a given indirect index array
37 | ///
38 | ///
39 | ///
40 | ///
41 | ///
42 | void SortFb(SpriteBatch.SpriteInfo[] sInfo, int[] arr, int offset, int length);
43 | }
44 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Graphics/SpriteSort/SpriteSortAlgorithm.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Graphics.SpriteSort
12 | {
13 | ///
14 | /// SpriteSortAlgorithm
15 | ///
16 | public enum SpriteSortAlgorithm
17 | {
18 | ///
19 | /// MergeSort (default)
20 | ///
21 | MergeSort
22 | }
23 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Graphics/SpriteSortMode.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Graphics
12 | {
13 | ///
14 | /// Values that represent SpriteSortMode.
15 | ///
16 | public enum SpriteSortMode
17 | {
18 | ///
19 | /// An enum constant representing the deferred option.
20 | ///
21 | Deferred,
22 |
23 | ///
24 | /// An enum constant representing the texture option.
25 | ///
26 | Texture,
27 |
28 | ///
29 | /// An enum constant representing the back to front option.
30 | ///
31 | BackToFront,
32 |
33 | ///
34 | /// An enum constant representing the front to back option.
35 | ///
36 | FrontToBack
37 | }
38 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Graphics/TextureContentReader.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.Framework.Content;
12 |
13 | namespace Exomia.Framework.Graphics
14 | {
15 | ///
16 | /// A texture content reader. This class cannot be inherited.
17 | ///
18 | sealed class TextureContentReader : IContentReader
19 | {
20 | ///
21 | public object? ReadContent(IContentManager contentManager, ref ContentReaderParameters parameters)
22 | {
23 | IGraphicsDevice graphicsDevice =
24 | contentManager.ServiceRegistry.GetService();
25 | return Texture.Load(graphicsDevice.Device, parameters.Stream);
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Graphics/TextureEffects.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework.Graphics
14 | {
15 | ///
16 | /// Bitfield of flags for specifying TextureEffects.
17 | ///
18 | [Flags]
19 | public enum TextureEffects
20 | {
21 | ///
22 | /// A binary constant representing the none flag.
23 | ///
24 | None = 0b00,
25 |
26 | ///
27 | /// A binary constant representing the flip horizontally flag.
28 | ///
29 | FlipHorizontally = 0b01,
30 |
31 | ///
32 | /// A binary constant representing the flip vertically flag.
33 | ///
34 | FlipVertically = 0b10,
35 |
36 | ///
37 | /// A binary constant representing the flip both flag.
38 | ///
39 | FlipBoth = FlipHorizontally | FlipVertically
40 | }
41 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/ICloneable.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework
12 | {
13 | ///
14 | /// An interface to clone a object.
15 | ///
16 | /// Generic type parameter.
17 | public interface ICloneable
18 | {
19 | ///
20 | /// returns a deep copy of the object.
21 | ///
22 | ///
23 | /// a new deep copied object.
24 | ///
25 | T Clone();
26 | }
27 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/IComponent.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework
12 | {
13 | ///
14 | /// An interface to define a game component.
15 | ///
16 | public interface IComponent
17 | {
18 | ///
19 | /// the name of the component.
20 | ///
21 | ///
22 | /// The name.
23 | ///
24 | string Name { get; }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/IContentable.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework
12 | {
13 | ///
14 | /// An interface to load and unload content.
15 | ///
16 | public interface IContentable
17 | {
18 | ///
19 | /// Loads the content.
20 | ///
21 | /// The registry.
22 | void LoadContent(IServiceRegistry registry);
23 |
24 | ///
25 | /// Called when graphics resources need to be unloaded.
26 | ///
27 | /// The registry.
28 | void UnloadContent(IServiceRegistry registry);
29 | }
30 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/IInitializable.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework
12 | {
13 | ///
14 | /// An interface to initialize a game component.
15 | ///
16 | public interface IInitializable
17 | {
18 | ///
19 | /// This method is called when the component is added to the game.
20 | ///
21 | /// The registry.
22 | ///
23 | /// This method can be used for tasks like querying for services the component needs and
24 | /// setting up non-graphics resources.
25 | ///
26 | void Initialize(IServiceRegistry registry);
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/IRunable.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework
14 | {
15 | ///
16 | /// An interface to run an object.
17 | ///
18 | public interface IRunnable : IDisposable
19 | {
20 | ///
21 | /// return true if the object is running
22 | ///
23 | bool IsRunning { get; }
24 |
25 | ///
26 | /// starts the run
27 | ///
28 | void Run();
29 |
30 | ///
31 | /// shutdown the run
32 | ///
33 | void Shutdown();
34 | }
35 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/IUpdateable.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.Framework.Game;
12 |
13 | namespace Exomia.Framework
14 | {
15 | ///
16 | /// An interface to update a game component
17 | ///
18 | public interface IUpdateable
19 | {
20 | ///
21 | /// Occurs when the property changes.
22 | ///
23 | event EventHandler EnabledChanged;
24 |
25 | ///
26 | /// Occurs when the property changes.
27 | ///
28 | event EventHandler UpdateOrderChanged;
29 |
30 | ///
31 | /// Gets a value indicating whether the game component's Update method should be called.
32 | ///
33 | /// true if update is enabled; otherwise, false.
34 | bool Enabled { get; set; }
35 |
36 | ///
37 | /// Gets or sets the update order relative to other game components. Lower values are updated first.
38 | ///
39 | /// The update order.
40 | int UpdateOrder { get; set; }
41 |
42 | ///
43 | /// This method is called when this game component is updated.
44 | ///
45 | /// The current timing.
46 | void Update(GameTime gameTime);
47 | }
48 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Input/IInputHandler.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Input
12 | {
13 | ///
14 | /// Interface for raw input handler.
15 | ///
16 | public interface IInputHandler
17 | {
18 | ///
19 | /// Register the input events on the given input device.
20 | ///
21 | /// The device.
22 | void RegisterInput(IInputDevice device);
23 |
24 | ///
25 | /// Unregister the input events on the given input device.
26 | ///
27 | /// The device.
28 | void UnregisterInput(IInputDevice device);
29 | }
30 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Input/InputState.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Input
12 | {
13 | ///
14 | /// Values that represent EventAction.
15 | ///
16 | public enum EventAction
17 | {
18 | ///
19 | /// An enum constant representing the continue option.
20 | ///
21 | Continue = 0,
22 |
23 | ///
24 | /// An enum constant representing the stop propagation option.
25 | ///
26 | StopPropagation = 1,
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Input/KeyEventHandler.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.Framework.Win32;
12 |
13 | namespace Exomia.Framework.Input
14 | {
15 | ///
16 | /// Delegate for handling key events.
17 | ///
18 | /// The key value.
19 | /// The modifiers.
20 | ///
21 | /// An .
22 | ///
23 | public delegate EventAction KeyEventHandler(int keyValue, KeyModifier modifiers);
24 |
25 | ///
26 | /// Delegate for handling key press events.
27 | ///
28 | /// The key.
29 | ///
30 | /// An .
31 | ///
32 | public delegate EventAction KeyPressEventHandler(char key);
33 |
34 | ///
35 | /// Delegate for handling raw key events.
36 | ///
37 | /// The message.
38 | ///
39 | /// An .
40 | ///
41 | public delegate EventAction RawKeyEventHandler(in Message message);
42 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Input/KeyModifier.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework.Input
14 | {
15 | ///
16 | /// Values that represent KeyModifier.
17 | ///
18 | [Flags]
19 | public enum KeyModifier
20 | {
21 | ///
22 | /// An enum constant representing the shift option.
23 | ///
24 | Shift = 1,
25 |
26 | ///
27 | /// An enum constant representing the Alternate option.
28 | ///
29 | Alt = 2,
30 |
31 | ///
32 | /// An enum constant representing the control option.
33 | ///
34 | Control = 4
35 | }
36 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Input/MouseButtons.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework.Input
14 | {
15 | ///
16 | /// MouseButtons enum.
17 | ///
18 | [Flags]
19 | public enum MouseButtons
20 | {
21 | ///
22 | /// default
23 | ///
24 | None = 0,
25 |
26 | ///
27 | /// Left mouse button
28 | ///
29 | Left = 0x01,
30 |
31 | ///
32 | /// Middle mouse button
33 | ///
34 | Middle = 0x10,
35 |
36 | ///
37 | /// Right mouse button
38 | ///
39 | Right = 0x02,
40 |
41 | ///
42 | /// A binary constant representing the button 1 flag.
43 | ///
44 | XButton1 = 0x20,
45 |
46 | ///
47 | /// A binary constant representing the button 2 flag.
48 | ///
49 | XButton2 = 0x40
50 | }
51 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Input/MouseEventHandler.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Input
12 | {
13 | ///
14 | /// Delegate for handling mouse events.
15 | ///
16 | /// In mouse event information.
17 | ///
18 | /// An .
19 | ///
20 | public delegate EventAction MouseEventHandler(in MouseEventArgs mouseEventArgs);
21 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Input/Raw/Device.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.ComponentModel;
13 | using System.Runtime.InteropServices;
14 | using Exomia.Framework.Win32;
15 | using Exomia.Framework.Win32.RawInput;
16 |
17 | namespace Exomia.Framework.Input.Raw
18 | {
19 | ///
20 | /// Provides access to raw input methods.
21 | ///
22 | static class Device
23 | {
24 | ///
25 | /// Registers the device.
26 | ///
27 | /// The HID usage page.
28 | /// The HID usage.
29 | /// The raw input device flags.
30 | /// The window target.
31 | public static void RegisterDevice(HIDUsagePage hidUsagePage,
32 | HIDUsage hidUsage,
33 | RawInputDeviceFlags rawInputDeviceFlags,
34 | IntPtr hWndTarget)
35 | {
36 | RAWINPUTDEVICE[]? rawInputDevices = new RAWINPUTDEVICE[1];
37 | rawInputDevices[0].UsagePage = hidUsagePage;
38 | rawInputDevices[0].Usage = hidUsage;
39 | rawInputDevices[0].Flags = rawInputDeviceFlags;
40 | rawInputDevices[0].WindowHandle = hWndTarget;
41 |
42 | if (!User32.RegisterRawInputDevices(rawInputDevices, 1, Marshal.SizeOf()))
43 | {
44 | throw new Win32Exception(Kernel32.GetLastError(), $"{nameof(User32.RegisterRawInputDevices)} failed!");
45 | }
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Noise/NoiseFractalType.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Noise
12 | {
13 | ///
14 | /// Values that represent NoiseFractalType.
15 | ///
16 | public enum NoiseFractalType
17 | {
18 | ///
19 | /// An enum constant representing the none option.
20 | ///
21 | None,
22 |
23 | ///
24 | /// An enum constant representing the brownian motion option.
25 | ///
26 | BrownianMotion,
27 |
28 | ///
29 | /// An enum constant representing the billow option.
30 | ///
31 | Billow,
32 |
33 | ///
34 | /// An enum constant representing the rigid multi option.
35 | ///
36 | RigidMulti
37 | }
38 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Noise/NoiseInterpolationType.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Noise
12 | {
13 | ///
14 | /// Values that represent NoiseInterpolationType.
15 | ///
16 | public enum NoiseInterpolationType
17 | {
18 | ///
19 | /// An enum constant representing the linear option.
20 | ///
21 | Linear,
22 |
23 | ///
24 | /// An enum constant representing the hermite option.
25 | ///
26 | Hermite,
27 |
28 | ///
29 | /// An enum constant representing the quintic option.
30 | ///
31 | Quintic
32 | }
33 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_12px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_12px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_14px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_14px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_16px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_16px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_18px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_18px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_20px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_20px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_22px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_22px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_24px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_24px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_26px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_26px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_28px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_28px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_30px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_30px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_32px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_32px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_34px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_34px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_36px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_36px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_38px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_38px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_40px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_40px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_42px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_42px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_44px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_44px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_46px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_46px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_48px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_48px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_50px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_50px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_52px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_52px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_54px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_54px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_56px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_56px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_58px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_58px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_60px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_60px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_62px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_62px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_64px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_64px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_66px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_66px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_68px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_68px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_70px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_70px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/fonts/arial/arial_72px.e1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/Resources/fonts/arial/arial_72px.e1
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/shaders/position_color.ehlsl:
--------------------------------------------------------------------------------
1 | /** Shaderdefinition
2 | *
3 | * group DEFAULT
4 | * vs VSMain vs_5_0 OptimizationLevel3
5 | * ps PSMain ps_5_0 OptimizationLevel3
6 | */
7 |
8 | cbuffer PerFrame : register(b0)
9 | {
10 | float4x4 g_WorldViewProjectionMatrix;
11 | };
12 |
13 | struct VertexShaderInput
14 | {
15 | float4 Position : SV_POSITION0;
16 | float4 Color : COLOR0;
17 | };
18 |
19 | struct VertexShaderOutput
20 | {
21 | float4 Position : SV_POSITION0;
22 | float4 Color : COLOR0;
23 | };
24 |
25 | VertexShaderOutput VSMain(VertexShaderInput input)
26 | {
27 | VertexShaderOutput output = (VertexShaderOutput)0;
28 | output.Position = mul(input.Position, g_WorldViewProjectionMatrix);
29 | output.Color = input.Color / 255;
30 | return output;
31 | }
32 |
33 | float4 PSMain(VertexShaderOutput input) : SV_TARGET
34 | {
35 | return input.Color;
36 | }
37 |
--------------------------------------------------------------------------------
/src/Exomia.Framework/Resources/shaders/position_color_texture.ehlsl:
--------------------------------------------------------------------------------
1 | /** Shaderdefinition
2 | *
3 | * group DEFAULT
4 | * vs VSMain vs_5_0 OptimizationLevel3
5 | * ps PSMain ps_5_0 OptimizationLevel3
6 | */
7 |
8 | Texture2D g_Texture : register(t0);
9 | SamplerState g_Sampler : register(s0);
10 |
11 | cbuffer PerFrame : register(b0)
12 | {
13 | float4x4 g_WorldViewProjectionMatrix;
14 | };
15 |
16 | struct VertexShaderInput
17 | {
18 | float4 Position : SV_POSITION0;
19 | float4 Color : COLOR0;
20 | float2 TextureUV : TEXCOORD0;
21 | };
22 |
23 | struct VertexShaderOutput
24 | {
25 | float4 Position : SV_POSITION0;
26 | float4 Color : COLOR0;
27 | float2 TextureUV : TEXCOORD0;
28 | };
29 |
30 | VertexShaderOutput VSMain(VertexShaderInput input)
31 | {
32 | VertexShaderOutput output = (VertexShaderOutput)0;
33 | output.Position = mul(input.Position, g_WorldViewProjectionMatrix);
34 | output.Color = input.Color / 255;
35 | output.TextureUV = input.TextureUV;
36 | return output;
37 | }
38 |
39 | float4 PSMain(VertexShaderOutput input) : SV_TARGET
40 | {
41 | return g_Texture.Sample(g_Sampler, input.TextureUV) * input.Color;
42 | }
43 |
--------------------------------------------------------------------------------
/src/Exomia.Framework/Scene/ISceneInternal.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Scene
12 | {
13 | ///
14 | /// Interface for scene internal.
15 | ///
16 | interface ISceneInternal : IScene
17 | {
18 | ///
19 | /// Sets the manager for scene.
20 | ///
21 | ///
22 | /// The scene manager.
23 | ///
24 | ISceneManager SceneManager { set; }
25 |
26 | ///
27 | /// Is called than the scene is showed.
28 | ///
29 | /// coming from.
30 | /// payload.
31 | void Show(IScene? comingFrom, object[] payload);
32 |
33 | ///
34 | /// Is called than all ReferenceScenes are loaded.
35 | ///
36 | void ReferenceScenesLoaded();
37 | }
38 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Scene/SceneState.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Scene
12 | {
13 | ///
14 | /// Values that represent SceneState.
15 | ///
16 | public enum SceneState
17 | {
18 | ///
19 | /// An enum constant representing the none option.
20 | ///
21 | None,
22 |
23 | ///
24 | /// An enum constant representing the initializing option.
25 | ///
26 | Initializing,
27 |
28 | ///
29 | /// An enum constant representing the stand by option.
30 | ///
31 | StandBy,
32 |
33 | ///
34 | /// An enum constant representing the content loading option.
35 | ///
36 | ContentLoading,
37 |
38 | ///
39 | /// An enum constant representing the ready option.
40 | ///
41 | Ready,
42 |
43 | ///
44 | /// An enum constant representing the content unloading option.
45 | ///
46 | ContentUnloading,
47 |
48 | ///
49 | /// An enum constant representing the disposing option.
50 | ///
51 | Disposing
52 | }
53 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Scene/ShowSceneResult.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.Scene
12 | {
13 | ///
14 | /// Values that represent ShowSceneResult.
15 | ///
16 | public enum ShowSceneResult
17 | {
18 | ///
19 | /// An enum constant representing the no scene option.
20 | ///
21 | NoScene,
22 |
23 | ///
24 | /// An enum constant representing the not ready option.
25 | ///
26 | NotReady,
27 |
28 | ///
29 | /// An enum constant representing the success option.
30 | ///
31 | Success
32 | }
33 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/UI/Brushes/ChainBrush.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.Framework.Graphics;
12 | using SharpDX;
13 |
14 | namespace Exomia.Framework.UI.Brushes
15 | {
16 | ///
17 | /// A chain brush. This class cannot be inherited.
18 | ///
19 | public sealed class ChainBrush : IBrush
20 | {
21 | private readonly IBrush[] _brushChain;
22 |
23 | ///
24 | /// Initializes a new instance of the class.
25 | ///
26 | /// A variable-length parameters list containing arguments.
27 | public ChainBrush(params IBrush[] args)
28 | {
29 | _brushChain = args;
30 | }
31 |
32 | void IBrush.Render(Canvas canvas, in RectangleF region, float opacity)
33 | {
34 | for (int i = 0; i < _brushChain.Length; i++)
35 | {
36 | _brushChain[i].Render(canvas, in region, opacity);
37 | }
38 | }
39 |
40 | void IBrush.RenderClipped(Canvas canvas, in RectangleF region, in RectangleF visibleRegion, float opacity)
41 | {
42 | for (int i = 0; i < _brushChain.Length; i++)
43 | {
44 | _brushChain[i].RenderClipped(canvas, in region, in visibleRegion, opacity);
45 | }
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/UI/Brushes/IBrush.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.Framework.Graphics;
12 | using SharpDX;
13 |
14 | namespace Exomia.Framework.UI.Brushes
15 | {
16 | ///
17 | /// Interface for brush.
18 | ///
19 | public interface IBrush
20 | {
21 | ///
22 | /// Render the brush.
23 | ///
24 | /// The canvas.
25 | /// The region.
26 | /// The opacity.
27 | void Render(Canvas canvas, in RectangleF region, float opacity);
28 |
29 | ///
30 | /// Render the brush and clip to the visibleRegion.
31 | ///
32 | /// The canvas.
33 | /// The region.
34 | /// The visible region.
35 | /// The opacity.
36 | void RenderClipped(Canvas canvas, in RectangleF region, in RectangleF visibleRegion, float opacity);
37 | }
38 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/UI/Brushes/SolidColorBrush.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.Framework.Graphics;
12 | using SharpDX;
13 |
14 | namespace Exomia.Framework.UI.Brushes
15 | {
16 | ///
17 | /// A solid color brush. This class cannot be inherited.
18 | ///
19 | public sealed class SolidColorBrush : IBrush
20 | {
21 | private readonly Color _color;
22 | private readonly float _opacity;
23 |
24 | ///
25 | /// Initializes a new instance of the class.
26 | ///
27 | /// The color.
28 | /// (Optional) The opacity.
29 | public SolidColorBrush(Color color, float opacity = 1.0f)
30 | {
31 | _color = color;
32 | _opacity = opacity;
33 | }
34 |
35 | void IBrush.Render(Canvas canvas, in RectangleF region, float opacity)
36 | {
37 | canvas.DrawFillRectangle(region, _color, 0, Vector2.Zero, _opacity * opacity);
38 | }
39 |
40 | void IBrush.RenderClipped(Canvas canvas, in RectangleF region, in RectangleF visibleRegion, float opacity)
41 | {
42 | canvas.DrawFillRectangle(visibleRegion, _color, 0, Vector2.Zero, _opacity * opacity);
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/UI/Brushes/TextureBrush.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using Exomia.Framework.Graphics;
13 | using SharpDX;
14 |
15 | namespace Exomia.Framework.UI.Brushes
16 | {
17 | ///
18 | /// A texture brush. This class cannot be inherited.
19 | ///
20 | public sealed class TextureBrush : IBrush
21 | {
22 | private readonly Texture _texture;
23 |
24 | ///
25 | /// Initializes a new instance of the class.
26 | ///
27 | /// The texture.
28 | /// Thrown when one or more required arguments are null.
29 | public TextureBrush(Texture texture)
30 | {
31 | _texture = texture ?? throw new ArgumentNullException(nameof(texture));
32 | }
33 |
34 | void IBrush.Render(Canvas canvas, in RectangleF region, float opacity)
35 | {
36 | canvas.Draw(_texture, region, null, Color.White, 0, Vector2.Zero, opacity, TextureEffects.None);
37 | }
38 |
39 | void IBrush.RenderClipped(Canvas canvas, in RectangleF region, in RectangleF visibleRegion, float opacity)
40 | {
41 | canvas.Draw(
42 | _texture, visibleRegion,
43 | new Rectangle(
44 | 0, 0,
45 | (int)((_texture.Width / region.Width) * visibleRegion.Width),
46 | (int)((_texture.Height / region.Height) * visibleRegion.Height)),
47 | Color.White, 0, Vector2.Zero, opacity, TextureEffects.None);
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/UI/Controls/Button.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.Framework.Graphics;
12 | using Exomia.Framework.Input;
13 |
14 | namespace Exomia.Framework.UI.Controls
15 | {
16 | ///
17 | /// A button.
18 | ///
19 | public class Button : Label
20 | {
21 | ///
22 | /// Occurs when Mouse Down.
23 | ///
24 | public event UiMouseEventActionHandler? MouseClick;
25 |
26 | private bool _isMouseDown;
27 |
28 | ///
29 | public Button(SpriteFont font, string? text)
30 | : base(font, text) { }
31 |
32 | ///
33 | protected override void OnMouseDown(in MouseEventArgs e, ref EventAction eventAction)
34 | {
35 | if (!_isMouseDown)
36 | {
37 | _isMouseDown = true;
38 | }
39 | base.OnMouseDown(in e, ref eventAction);
40 | }
41 |
42 | ///
43 | protected override void OnMouseUp(in MouseEventArgs e, ref EventAction eventAction)
44 | {
45 | if (_isMouseDown)
46 | {
47 | _isMouseDown = false;
48 | MouseClick?.Invoke(this, in e, ref eventAction);
49 | }
50 | base.OnMouseUp(in e, ref eventAction);
51 | }
52 |
53 | ///
54 | protected override void OnMouseLeaved(in MouseEventArgs e)
55 | {
56 | _isMouseDown = false;
57 | base.OnMouseLeaved(in e);
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/UI/IKeyListener.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.Framework.Input;
12 |
13 | namespace Exomia.Framework.UI
14 | {
15 | ///
16 | /// Interface for key listener.
17 | ///
18 | public interface IKeyListener
19 | {
20 | ///
21 | /// Called than the control is focused and a key down event occurred.
22 | ///
23 | /// The key value.
24 | /// The modifiers.
25 | void KeyDown(int keyValue, KeyModifier modifiers);
26 |
27 | ///
28 | /// Called than the control is focused and a key press event occurred.
29 | ///
30 | /// The key.
31 | void KeyPress(char key);
32 |
33 | ///
34 | /// Called than the control is focused and a key up event occurred.
35 | ///
36 | /// The key value.
37 | /// The modifiers.
38 | void KeyUp(int keyValue, KeyModifier modifiers);
39 | }
40 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/UI/UiConstants.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.UI
12 | {
13 | static class UiConstants
14 | {
15 | internal const int TEXT_ALIGN_TOP = 0b0001_0000;
16 | internal const int TEXT_ALIGN_MIDDLE = 0b0010_0000;
17 | internal const int TEXT_ALIGN_BOTTOM = 0b0100_0000;
18 | internal const int TEXT_ALIGN_LEFT = 0b0000_0001;
19 | internal const int TEXT_ALIGN_CENTER = 0b0000_0010;
20 | internal const int TEXT_ALIGN_RIGHT = 0b0000_0100;
21 | }
22 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/UI/UiMouseEventHandler.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using Exomia.Framework.Input;
12 | using Exomia.Framework.UI.Controls;
13 |
14 | namespace Exomia.Framework.UI
15 | {
16 | ///
17 | /// Delegate for handling UiMouse events.
18 | ///
19 | /// The sender.
20 | /// In mouse event information.
21 | /// [in,out] The event action.
22 | public delegate void UiMouseEventActionHandler(Control sender, in MouseEventArgs e, ref EventAction eventAction);
23 |
24 | ///
25 | /// Delegate for handling UiMouse events.
26 | ///
27 | /// The sender.
28 | /// In mouse event information.
29 | public delegate void UiMouseEventHandler(Control sender, in MouseEventArgs e);
30 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/UpdateableComparer.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System.Collections.Generic;
12 |
13 | namespace Exomia.Framework
14 | {
15 | ///
16 | /// An updateable comparer. This class cannot be inherited.
17 | ///
18 | sealed class UpdateableComparer : IComparer
19 | {
20 | ///
21 | /// The default.
22 | ///
23 | public static readonly UpdateableComparer Default = new UpdateableComparer();
24 |
25 | ///
26 | public int Compare(IUpdateable left, IUpdateable right)
27 | {
28 | if (Equals(left, right))
29 | {
30 | return 0;
31 | }
32 |
33 | return left.UpdateOrder < right.UpdateOrder ? 1 : -1;
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/Kernel32.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.Runtime.InteropServices;
13 | using System.Security;
14 |
15 | namespace Exomia.Framework.Win32
16 | {
17 | static class Kernel32
18 | {
19 | [SuppressUnmanagedCodeSecurity]
20 | [DllImport("kernel32.dll", EntryPoint = "SetEvent")]
21 | internal static extern bool SetEvent(IntPtr hEvent);
22 |
23 | [SuppressUnmanagedCodeSecurity]
24 | [DllImport("kernel32.dll", EntryPoint = "GetLastError")]
25 | internal static extern int GetLastError();
26 |
27 | [SuppressUnmanagedCodeSecurity]
28 | [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
29 | internal static extern IntPtr GetModuleHandle(string lpModuleName);
30 | }
31 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/MSG.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.Runtime.InteropServices;
13 | using SharpDX;
14 |
15 | namespace Exomia.Framework.Win32
16 | {
17 | [StructLayout(LayoutKind.Sequential)]
18 | struct MSG
19 | {
20 | public IntPtr hWnd;
21 | public uint msg;
22 | public IntPtr wParam;
23 | public IntPtr lParam;
24 | public uint time;
25 | public Point pt;
26 | }
27 |
28 | ///
29 | /// A message.
30 | ///
31 | [StructLayout(LayoutKind.Sequential)]
32 | public struct Message
33 | {
34 | ///
35 | /// The window handle.
36 | ///
37 | public IntPtr hWnd;
38 |
39 | ///
40 | /// The message.
41 | ///
42 | public uint msg;
43 |
44 | ///
45 | /// The w parameter.
46 | ///
47 | public IntPtr wParam;
48 |
49 | ///
50 | /// The l parameter.
51 | ///
52 | public IntPtr lParam;
53 | }
54 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/POINT.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System.Runtime.InteropServices;
12 |
13 | namespace Exomia.Framework.Win32
14 | {
15 | [StructLayout(LayoutKind.Sequential)]
16 | struct POINT
17 | {
18 | public int X;
19 | public int Y;
20 | }
21 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/RECT.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System.Runtime.InteropServices;
12 |
13 | namespace Exomia.Framework.Win32
14 | {
15 | [StructLayout(LayoutKind.Sequential)]
16 | struct RECT
17 | {
18 | public POINT LeftTop;
19 | public POINT RightBottom;
20 |
21 | public RECT(int width, int height)
22 | {
23 | LeftTop.X = LeftTop.Y = 0;
24 | RightBottom.X = width;
25 | RightBottom.Y = height;
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/RawInput/RAWINPUT.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System.Runtime.InteropServices;
12 |
13 | namespace Exomia.Framework.Win32.RawInput
14 | {
15 | ///
16 | /// Contains the raw input from a device.
17 | ///
18 | [StructLayout(LayoutKind.Sequential)]
19 | struct RAWINPUT
20 | {
21 | ///
22 | /// The header.
23 | ///
24 | public RAWINPUTHEADER Header;
25 |
26 | ///
27 | /// The data.
28 | ///
29 | public Union Data;
30 |
31 | ///
32 | /// An union.
33 | ///
34 | [StructLayout(LayoutKind.Explicit)]
35 | public struct Union
36 | {
37 | ///
38 | /// Mouse raw input data.
39 | ///
40 | [FieldOffset(0)]
41 | public RAWINPUTMOUSE Mouse;
42 |
43 | ///
44 | /// Keyboard raw input data.
45 | ///
46 | [FieldOffset(0)]
47 | public RAWINPUTKEYBOARD Keyboard;
48 |
49 | ///
50 | /// HID raw input data.
51 | ///
52 | [FieldOffset(0)]
53 | public RAWINPUTHID HID;
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/RawInput/RAWINPUTDEVICE.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.Runtime.InteropServices;
13 |
14 | // ReSharper disable InconsistentNaming
15 | // ReSharper disable UnusedMember.Global
16 | // ReSharper disable IdentifierTypo
17 | namespace Exomia.Framework.Win32.RawInput
18 | {
19 | /// Value type for raw input devices.
20 | [StructLayout(LayoutKind.Sequential)]
21 | struct RAWINPUTDEVICE
22 | {
23 | /// Top level collection Usage page for the raw input device.
24 | public HIDUsagePage UsagePage;
25 |
26 | /// Top level collection Usage for the raw input device.
27 | public HIDUsage Usage;
28 |
29 | /// Mode flag that specifies how to interpret the information provided by UsagePage and Usage.
30 | public RawInputDeviceFlags Flags;
31 |
32 | /// Handle to the target device. If NULL, it follows the keyboard focus.
33 | public IntPtr WindowHandle;
34 | }
35 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/RawInput/RAWINPUTHEADER.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.Runtime.InteropServices;
13 |
14 | namespace Exomia.Framework.Win32.RawInput
15 | {
16 | ///
17 | /// Value type for a raw input header.
18 | ///
19 | [StructLayout(LayoutKind.Sequential)]
20 | struct RAWINPUTHEADER
21 | {
22 | /// Type of device the input is coming from.
23 | public int Type;
24 |
25 | /// Size of the packet of data.
26 | public int Size;
27 |
28 | /// Handle to the device sending the data.
29 | public IntPtr Device;
30 |
31 | /// wParam from the window message.
32 | public IntPtr wParam;
33 | }
34 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/RawInput/RAWINPUTHID.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.Runtime.InteropServices;
13 |
14 | namespace Exomia.Framework.Win32.RawInput
15 | {
16 | ///
17 | /// Value type for raw input from a HID.
18 | ///
19 | [StructLayout(LayoutKind.Sequential)]
20 | struct RAWINPUTHID
21 | {
22 | /// Size of the HID data in bytes.
23 | public int Size;
24 |
25 | /// Number of HID in Data.
26 | public int Count;
27 |
28 | /// Data for the HID.
29 | public IntPtr Data;
30 | }
31 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/RawInput/RAWINPUTKEYBOARD.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System.Runtime.InteropServices;
12 |
13 | namespace Exomia.Framework.Win32.RawInput
14 | {
15 | ///
16 | /// Value type for raw input from a keyboard.
17 | ///
18 | [StructLayout(LayoutKind.Sequential)]
19 | struct RAWINPUTKEYBOARD
20 | {
21 | /// Scan code for key depression.
22 | public ushort MakeCode;
23 |
24 | /// Scan code information.
25 | public RawKeyboardFlags Flags;
26 |
27 | /// Reserved.
28 | public ushort Reserved;
29 |
30 | /// Virtual key code.
31 | public ushort VKey;
32 |
33 | /// Corresponding window message.
34 | public uint Message;
35 |
36 | /// Extra information.
37 | public uint ExtraInformation;
38 | }
39 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/RawInput/RAWINPUTMOUSE.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System.Runtime.InteropServices;
12 |
13 | namespace Exomia.Framework.Win32.RawInput
14 | {
15 | ///
16 | /// Contains information about the state of the mouse.
17 | ///
18 | [StructLayout(LayoutKind.Explicit)]
19 | struct RAWINPUTMOUSE
20 | {
21 | ///
22 | /// The mouse state.
23 | ///
24 | [FieldOffset(0)]
25 | public RawMouseFlags Flags;
26 |
27 | ///
28 | /// Flags for the event.
29 | ///
30 | [FieldOffset(4)]
31 | public RawMouseButtons ButtonFlags;
32 |
33 | ///
34 | /// If the mouse wheel is moved, this will contain the delta amount.
35 | ///
36 | [FieldOffset(6)]
37 | public ushort ButtonData;
38 |
39 | ///
40 | /// Raw button data.
41 | ///
42 | [FieldOffset(8)]
43 | public uint RawButtons;
44 |
45 | ///
46 | /// The motion in the X direction. This is signed relative motion or
47 | /// absolute motion, depending on the value of usFlags.
48 | ///
49 | [FieldOffset(12)]
50 | public int LastX;
51 |
52 | ///
53 | /// The motion in the Y direction. This is signed relative motion or absolute motion,
54 | /// depending on the value of usFlags.
55 | ///
56 | [FieldOffset(16)]
57 | public int LastY;
58 |
59 | ///
60 | /// The device-specific additional information for the event.
61 | ///
62 | [FieldOffset(20)]
63 | public uint ExtraInformation;
64 | }
65 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/RawInput/RawKeyboardFlags.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | // ReSharper disable InconsistentNaming
14 | // ReSharper disable UnusedMember.Global
15 | // ReSharper disable IdentifierTypo
16 | namespace Exomia.Framework.Win32.RawInput
17 | {
18 | ///
19 | /// Enumeration containing flags for raw keyboard input.
20 | ///
21 | [Flags]
22 | enum RawKeyboardFlags : ushort
23 | {
24 | ///
25 | KeyMake = 0,
26 |
27 | ///
28 | KeyBreak = 1,
29 |
30 | ///
31 | KeyE0 = 2,
32 |
33 | ///
34 | KeyE1 = 4,
35 |
36 | ///
37 | TerminalServerSetLED = 8,
38 |
39 | ///
40 | TerminalServerShadow = 0x10,
41 |
42 | ///
43 | TerminalServerVKPACKET = 0x20
44 | }
45 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/RawInput/RawMouseButtons.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | // ReSharper disable InconsistentNaming
14 | // ReSharper disable UnusedMember.Global
15 | // ReSharper disable IdentifierTypo
16 | namespace Exomia.Framework.Win32.RawInput
17 | {
18 | ///
19 | /// Enumeration containing the button data for raw mouse input.
20 | ///
21 | [Flags]
22 | enum RawMouseButtons : ushort
23 | {
24 | /// No button.
25 | None = 0,
26 |
27 | /// Left (button 1) down.
28 | LeftDown = 0x0001,
29 |
30 | /// Left (button 1) up.
31 | LeftUp = 0x0002,
32 |
33 | /// Right (button 2) down.
34 | RightDown = 0x0004,
35 |
36 | /// Right (button 2) up.
37 | RightUp = 0x0008,
38 |
39 | /// Middle (button 3) down.
40 | MiddleDown = 0x0010,
41 |
42 | /// Middle (button 3) up.
43 | MiddleUp = 0x0020,
44 |
45 | /// Button 4 down.
46 | Button4Down = 0x0040,
47 |
48 | /// Button 4 up.
49 | Button4Up = 0x0080,
50 |
51 | /// Button 5 down.
52 | Button5Down = 0x0100,
53 |
54 | /// Button 5 up.
55 | Button5Up = 0x0200,
56 |
57 | /// Mouse wheel moved.
58 | MouseWheel = 0x0400
59 | }
60 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/RawInput/RawMouseFlags.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | // ReSharper disable InconsistentNaming
14 | // ReSharper disable UnusedMember.Global
15 | // ReSharper disable IdentifierTypo
16 | namespace Exomia.Framework.Win32.RawInput
17 | {
18 | ///
19 | /// Enumeration containing the flags for raw mouse data.
20 | ///
21 | [Flags]
22 | enum RawMouseFlags : ushort
23 | {
24 | /// Relative to the last position.
25 | MoveRelative = 0,
26 |
27 | /// Absolute positioning.
28 | MoveAbsolute = 1,
29 |
30 | /// Coordinate data is mapped to a virtual desktop.
31 | VirtualDesktop = 2,
32 |
33 | /// Attributes for the mouse have changed.
34 | AttributesChanged = 4
35 | }
36 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/Shell32.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.Runtime.InteropServices;
13 | using System.Security;
14 |
15 | namespace Exomia.Framework.Win32
16 | {
17 | static class Shell32
18 | {
19 | ///
20 | /// Extracts the icon.
21 | ///
22 | /// The instance.
23 | /// Filename of the executable file.
24 | /// Zero-based index of the icon.
25 | ///
26 | /// The extracted icon.
27 | ///
28 | [SuppressUnmanagedCodeSecurity]
29 | [DllImport("shell32.dll", CharSet = CharSet.Auto, BestFitMapping = false)]
30 | internal static extern IntPtr ExtractIcon(IntPtr hInst, string exeFileName, int iconIndex);
31 | }
32 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/TRACKMOUSEEVENT.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.Runtime.InteropServices;
13 |
14 | namespace Exomia.Framework.Win32
15 | {
16 | [StructLayout(LayoutKind.Sequential)]
17 | struct TRACKMOUSEEVENT
18 | {
19 | public int cbSize;
20 |
21 | [MarshalAs(UnmanagedType.U4)]
22 | public uint dwFlags;
23 |
24 | public IntPtr hWnd;
25 | public uint dwHoverTime;
26 |
27 | public TRACKMOUSEEVENT(uint dwFlags, IntPtr hWnd, uint dwHoverTime)
28 | {
29 | cbSize = Marshal.SizeOf();
30 | this.dwFlags = dwFlags;
31 | this.hWnd = hWnd;
32 | this.dwHoverTime = dwHoverTime;
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/WLF.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | // ReSharper disable UnusedMember.Global
12 | // ReSharper disable IdentifierTypo
13 |
14 | namespace Exomia.Framework.Win32
15 | {
16 | static class WLF
17 | {
18 | public const int GWL_EXSTYLE = -20;
19 | public const int GWLP_HINSTANCE = -6;
20 | public const int GWLP_HWNDPARENT = -8;
21 | public const int GWL_ID = -12;
22 | public const int GWL_STYLE = -16;
23 | public const int GWL_USERDATA = -21;
24 | public const int GWL_WNDPROC = -4;
25 | public const int DWLP_USER = 0x8;
26 | public const int DWLP_MSGRESULT = 0x0;
27 | public const int DWLP_DLGPROC = 0x4;
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/WndClassEx.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.Runtime.InteropServices;
13 |
14 | namespace Exomia.Framework.Win32
15 | {
16 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
17 | struct WndClassEx
18 | {
19 | [MarshalAs(UnmanagedType.U4)]
20 | public int cbSize;
21 |
22 | [MarshalAs(UnmanagedType.U4)]
23 | public ClassStyles style;
24 |
25 | public WndProc lpfnWndProc;
26 | public int cbClsExtra;
27 | public int cbWndExtra;
28 | public IntPtr hInstance;
29 | public IntPtr hIcon;
30 | public IntPtr hCursor;
31 | public IntPtr hbrBackground;
32 |
33 | [MarshalAs(UnmanagedType.LPStr)]
34 | public string lpszMenuName;
35 |
36 | [MarshalAs(UnmanagedType.LPStr)]
37 | public string lpszClassName;
38 |
39 | public IntPtr hIconSm;
40 | }
41 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/Win32/WndProc.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework.Win32
14 | {
15 | delegate IntPtr WndProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam);
16 | }
--------------------------------------------------------------------------------
/src/Exomia.Framework/logo_x192_Hcn_icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exomia/framework/7a4767b25fadffcacf9e524d9898bd6812a6c7e9/src/Exomia.Framework/logo_x192_Hcn_icon.ico
--------------------------------------------------------------------------------
/tests/L0/Exomia.Framework.Tests/Exomia.Framework.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1;
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/tools/Exomia.Framework.ContentManager/AboutForm.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.Reflection;
13 | using System.Windows.Forms;
14 |
15 | namespace Exomia.Framework.ContentManager
16 | {
17 | partial class AboutForm : Form
18 | {
19 | public AboutForm()
20 | {
21 | InitializeComponent();
22 | Load += OnLoad;
23 | }
24 |
25 | private void OnLoad(object sender, EventArgs e)
26 | {
27 | Assembly? assembly = Assembly.GetExecutingAssembly();
28 | Text = $"About {assembly.GetCustomAttribute().Title}";
29 | productNameLbl.Text = assembly.GetCustomAttribute().Product;
30 | versionLbl.Text = $"Version {assembly.GetName().Version}";
31 | copyrightLbl.Text = assembly.GetCustomAttribute().Copyright;
32 | companyLbl.Text = assembly.GetCustomAttribute().Company;
33 | descriptionTb.Text = assembly.GetCustomAttribute().Description;
34 | }
35 |
36 | private void okBtn_Click(object sender, EventArgs e)
37 | {
38 | DialogResult = DialogResult.OK;
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/tools/Exomia.Framework.ContentManager/Attributes/ChoicesAttribute.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework.ContentManager.Attributes
14 | {
15 | ///
16 | /// Attribute for choices. This class cannot be inherited.
17 | ///
18 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
19 | public sealed class ChoicesAttribute : Attribute
20 | {
21 | ///
22 | /// Gets the entries.
23 | ///
24 | ///
25 | /// The entries.
26 | ///
27 | public object[] Entries { get; }
28 |
29 | ///
30 | public ChoicesAttribute(params object[] entries)
31 | {
32 | Entries = entries;
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/tools/Exomia.Framework.ContentManager/Attributes/FolderNameEditorTitleAttribute.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 |
13 | namespace Exomia.Framework.ContentManager.Attributes
14 | {
15 | ///
16 | /// Attribute for folder name editor title.
17 | ///
18 | [AttributeUsage(AttributeTargets.Property)]
19 | public class FolderNameEditorTitleAttribute : Attribute
20 | {
21 | ///
22 | /// Gets the title.
23 | ///
24 | ///
25 | /// The title.
26 | ///
27 | public string Title { get; }
28 |
29 | ///
30 | public FolderNameEditorTitleAttribute(string title)
31 | {
32 | Title = title;
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/tools/Exomia.Framework.ContentManager/BuildAction.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | namespace Exomia.Framework.ContentManager
12 | {
13 | ///
14 | /// Values that represent BuildAction.
15 | ///
16 | public enum BuildAction
17 | {
18 | ///
19 | /// An enum constant representing the build option.
20 | ///
21 | Build,
22 |
23 | ///
24 | /// An enum constant representing the ignore option.
25 | ///
26 | Ignore
27 | }
28 | }
--------------------------------------------------------------------------------
/tools/Exomia.Framework.ContentManager/Converters/ChoicesStringConverter.cs:
--------------------------------------------------------------------------------
1 | #region License
2 |
3 | // Copyright (c) 2018-2020, exomia
4 | // All rights reserved.
5 | //
6 | // This source code is licensed under the BSD-style license found in the
7 | // LICENSE file in the root directory of this source tree.
8 |
9 | #endregion
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.ComponentModel;
14 | using Exomia.Framework.ContentManager.Attributes;
15 |
16 | namespace Exomia.Framework.ContentManager.Converters
17 | {
18 | ///
19 | /// The choices string converter.
20 | ///
21 | public sealed class ChoicesStringConverter : StringConverter
22 | {
23 | ///
24 | public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
25 | {
26 | return true;
27 | }
28 |
29 | ///
30 | public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
31 | {
32 | return true;
33 | }
34 |
35 | ///
36 | public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
37 | {
38 | foreach (Attribute propertyDescriptorAttribute in context.PropertyDescriptor.Attributes)
39 | {
40 | if (propertyDescriptorAttribute is ChoicesAttribute choices)
41 | {
42 | return new StandardValuesCollection(new List