diff --git a/.gitmodules b/.gitmodules
index 49401077..e69de29b 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +0,0 @@
-[submodule "NoPipeline"]
- path = NoPipeline
- url = https://github.com/gnFur/NoPipeline.git
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a2ada739..d4f20c63 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,77 +1,148 @@
-# v 2.0.0.0-dev:
+# [Changelog](http://keepachangelog.com/en/1.0.0/):
+
+## [Unreleased]
+
+## [v2.0.0] - *27.08.2020*
+
+### Added:
+
+- Added `Rotate` method for `Vector2`.
+- Added half-pixel offset support for `VertexBatch`.
+- Added Pre and Post events to layers, scenes and scene manager.
+- Added `ZDepth` to all shape classes.
+- Added platform-specific projects for WindowsDX and DesktopGL.
+- Added `StuffResolver` class.
+- Added `HsvColor` class.
+- Added automatic content loaders.
+- Added sprite json mathematical expressions.
+- Added `CurrentPlatform` and `CurrentGraphicsBackend` to `GameMgr`.
+
+### Changed:
+
+- **BREAKING CHANGE:** Monogame version has been updated to 3.8.
+- Pipefoxe now supports netstandard2.0 and is fully crossplatform.
+- Renamed Pipefoxe to Monofoxe.Pipeline.
+- **BREAKING CHANGE:** `Input.ScrollWheelValue` now returns signed scroll speed value instead of only its sign.
+- **BREAKING CHANGE:** Reworked `Alarm` class and merged it with `AutoAlarm` and `Timer`.
+- Changed `IDrawable` interface to `Drawable` class.
+- `Entity.AddComponent` now returns the component class which was passed into it.
+- **BREAKING CHANGE:** `AssetInfo` has been renamed to `ResourceInfo`
+- **BREAKING CHANGE:** `ResourceInfoImporter` now imports `.npl` Content file instead of `.mgcb`.
+- Removed dependency on Windows-only `System.Drawing` for Monofoxe.Pipeline.
+- Changed the crossplatform project structure.
+- **BREAKING CHANGE:** `AlphaBlend.fx` is now baked into the library and doesn't have to be manually put into the Content directory.
+- Replaced offset_x/y with originX/Y in sprite jsons.
+- `Component.Destroy()` is now called when the component is removed from the entity.
+
+### Removed:
+
+- **BREAKING CHANGE:** Removed `AutoAlarm` and `Timer` classes.
+- **BREAKING CHANGE:** Removed `MousePosition` from `Input` class.
+- **BREAKING CHANGE:** Removed entity templates.
+- Removed all templates except Crossplatform, since there is no need in them anymore.
+
+### Fixed:
+
+- Fixed instantiated rectangle shape not being drawn properly.
+- Fixed entity methods crashing the game after creating new `Entity`.
+- Fixed crashes when `Scene`'s layer methods were called.
+- Fixed crashes when `SceneMgr`'s scene methods were called.
+- Fixed `Component.Initialized` never being set.
+- Fixed gamepad press/release not working correctly.
+- Fixed gamepad index not being used in input methods.
+- Fixed parsing multiplne text properties from Tiled maps.
+
+## [v2.0.0.0-dev+007] - *07.02.2020*
+
+## Fixed:
+
+- Fixed `VertexBatch.Effect` being reset every frame.
+- Fixed crashing when adding/removing components during component event.
+- Fixed `Text.Color` not being used.
-### IN THIS BUILD:
+
+
+## [v2.0.0.0-dev+006] - *07.01.2020*
+
+## Added:
+
+- Added `ZNearPlane` and `ZFarPlane` to the `Camera`.
+- Added projection matrix to the camera.
+- Added an option to set custom projection matrix to the Surface.
+
+### Changed:
+
+- Made `Camera` abstract class and added `Camera2D` class.
+- `Camera`'s `Position` and `Origin` are `Vector3` instead of `Vector2` now.
+- `Primitive2D` now uses array of vertices instead of a list.
+
+## Fixed:
+
+- Fixed circles not being drawn in some cases.
+- Fixed project templates.
+
+
+
+## [v2.0.0.0-dev+005] - 12.12.2019
+
+## Added:
+
+- Added `VertexBatch` class.
+- Added per-vertex z depth for sprites, surfaces and frames.
+
+## Changed:
+- Replaced `GraphicsMgr`'s internal `SpriteBatch` with `VertexBatch`
+- Moved graphics states from `GraphicsMgr` to `VertexBatch`.
+- Moved matrix stack from `GraphicsMgr` to `VertexBatch`.
+
+## Fixed:
+- Fixed `Origin` property not being used in `Surface`.
+
+
+
+## [v2.0.0.0-dev+004] - *01.12.2019*
-### FEATURES:
+## Added:
-- Documentation!
-- Added `ResourceHub` and `ResourceBox` instead of old loading systems.
-- Added `Angle` class for better angle management.
-- Added .NET Standard library template.
-- Nopipeline's NPL config supports adding references with environment variables.
- Monofoxe is now able to launch on Android.
- Added an ability to change entity update order.
- Added an all-in-one multiplatform project template.
- Added various item templates.
-- Added `VertexBatch` class.
-- Added per-vertex z depth for sprites, surfaces and frames.
-- Added `ZNearPlane` and `ZFarPlane` to the camera.
-- Added projection matrix to the camera.
-- Added an option to set custom projection matrix to the `Surface`.
-
-### CHANGES:
-
-- Camera implements `IDisposable` interface now.
-- `Alarm`, `AutoAlarm` and `Animation` use `EventHandler` instead of `Action` now.
-- Spritegroup cstemplates doesn't require quotes for variable values now.
-- Changed Draw methods in `Frame`, `Sprite` and `Surface` to use their properties by default instead of default struct values.
-- Moved `animation` argument in `Sprite.Draw` method after `position`.
-- Specifying origin in `Sprite.Draw()` isn't mandatory anymore.
-- `Frame`, `Sprite` and `Surface`'s `Rotation` field is `Angle` instead of `float` now.
-- `GameMath` doesn't contain angle-related methods anymore. They are moved to `Angle` instead.
-- All Monofoxe libraries are .NET Standard now.
-- Nopipeline is now embedded into Monofoxe.
-- All projects reference Monofoxe libraries from common place instead of raw per-project libraries.
-- Replaced static methods in `TimeKeeper` with static `Global` instance.
-- Removed drawing methods which work with raw x;y.
-- Project templates for VS2019 now have tags.
-- Bumped .NET Framework version to 4.7.2 for templates.
-- Entity methods which count components/entities have been removed.
-- Systems have been removed entirely.
+
+## Changed:
- Components now have their own events.
- Calling `base.%EventName%()` is now required in entities for EC to work.
-- Replaced GraphicsMgr's internal `SpriteBatch` with `VertexBatch`
-- Moved graphics states from `GraphicsMgr` to `VertexBatch`.
-- Moved matrix stack from `GraphicsMgr` to `VertexBatch`.
-- Made `Camera` abstract class and added `Camera2D` class.
-- `Camera`'s `Posision` and `Origin` are `Vector3` instead of `Vector2` now.
-- `Primitive2D` now uses array of vertices instead of a list.
-### FIXES:
+## Removed:
+
+- Entity methods which count components/entities.
+- Systems have been removed entirely.
+
+
+
+## [v2.0.0.0-dev+003] - *25.10.2019*
+
+### Changed:
+
+- Bumped .NET Framework version to 4.7.2 for templates.
+
+### Fixed:
-- Layer depth sorting now works properly.
-- `CameraMgr.Cameras` is a List instead of `IReadOnlyColection` now.
-- `KeepAspestRatio` canvas mode now scales canvas correctly.
-- Fixed memory leak in `Camera`.
-- Fixed `BasicTilemapSystem` not drawing the very last row and column of tiles.
-- Nopipeline now works with paths which contain spaces.
-- Angle difference formula now works properly.
-- Uninstaller now appears in Add\Remove Programs section.
- Fixed various project warnings.
-- Fixed `Origin` property not being used in `Surface`.
-- Fixed Text.Color not being used.
-# v 1.0.1.1
-### FIXES:
+## [v1.0.1.1] - *30.06.2019*
+
+### Fixed:
- Fixed `MapBuilder` crashing when some tilesets are ignored.
-# v1.0.1.0
-### FEATURES:
+## [v1.0.1.0] - *29.06.2019*
+
+### Added:
- Added Animation class.
- Added Easing class.
@@ -79,7 +150,7 @@
- Added a set of demos. See Monofoxe.Playground project.
- Added Windows DirectX templates.
-### CHANGES:
+### Changed:
- Moved Cameras from Monofoxe.Engine.Utils to Monofoxe.Engine namespace.
- Moved NumberExtensions and Vector2Extensions to Monofoxe.Engine namespace.
@@ -87,7 +158,7 @@
- Added GraphicsMgr.CurrentWorld.
- Renamed GraphicsMgr.CurrentTransformMatrix to GraphicsMgr.CurrentView.
-### FIXES:
+### Fixed:
- `AlphaBlend.fx` now works for DirectX.
- Content.mgcb now correctly builds for cross-platform projects.
@@ -104,7 +175,9 @@
- Fixed `ToggleFullScreen` not working properly with Canvas.
-# v1.0.0.0
+## [v1.0.0.0] - *26.06.2019*
+### Added
+- **It's alive!!!**
diff --git a/Common/Monofoxe.props b/Common/Monofoxe.props
deleted file mode 100644
index 0e3de9ca..00000000
--- a/Common/Monofoxe.props
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- $(MSBuildProgramFiles32)\Monofoxe Engine\
- v2-dev
-
-
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 00000000..b6af13ce
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/Docs/Contents.md b/Docs/Contents.md
index c0ec44f5..f501e4ab 100644
--- a/Docs/Contents.md
+++ b/Docs/Contents.md
@@ -8,12 +8,10 @@
-- [Introduction](Introduction.md) i
+- [Introduction](Introduction.md)
- [Setting things up](SettingThingsUp.md)
-- [Creating new project](CreatingNewProject.md)
-
- [Monofoxe basics](MonofoxeBasics.md)
- [Input](Input.md)
@@ -22,7 +20,6 @@
- [Entities](Entities/Entities.md)
- [Introduction to EC](Entities/IntroductionToEC.md)
- [Components](Entities/Components.md)
- - [Entity templates](Entities/EntityTemplates.md)
- Scene system
- [Layers](SceneSystem/Layers.md)
@@ -40,7 +37,7 @@
- [Sprite groups](Graphics/SpriteGroups.md) x
- Resources
- - [NoPipeline](Resources/NoPipeline.md)
+ - [Nopipeline](Resources/Nopipeline.md)
- [Adding resources](Resources/AddingResources)
- [Resource Hub](Resources/ResourceHub.md)
- [Resource Box](Resources/ResourceBox.md)
diff --git a/Docs/CreatingNewProject.md b/Docs/CreatingNewProject.md
deleted file mode 100644
index 8786aa6f..00000000
--- a/Docs/CreatingNewProject.md
+++ /dev/null
@@ -1,45 +0,0 @@
-# Creating new project
-
-We got everything set up and ready, now let's make some games! Wait, Windows projects? Crossplatform projects? And some of them are blank? What is all that!?
-
-![templates](Templates.png)
-
-Yes, it seems quite confusing. If you want a short answer - just pick **Monofoxe Cross Platform Desktop Project**, and you'll be good to go.
-
-
-
-## I don't want a short answer, give me everything!
-
-Basically, the main idea behind all this mess is - *each project type can only export to a single platform*. If you want to export to multiple platforms at the same time, you'll need a *shared project*. Shared project is just a container for the code which is shared between several projects in the solution. Its only purpose is to be connected to another platform-specific project.
-
-So, knowing that, we can divide projects into three categories:
-
-- ![](CrossplatformProject.png) Crossplatofrm project - standalone project which contains everything necessary to run a game. It already has Windows, OpenGL and Shared projects setup.
-
-- ![](SharedProject.png) Shared project - project which contains all the code and resources that should be shared between platforms. It is very much recommended to use it for big/crossplatform projects.
-
-- ![](WinOpenGLProjects.png) OpenGL\Windows projects - projects which are made specifically to go with Shared/Crossplatform projects. They doesn't contain any code or resources. The difference between them is that OpenGL can run on Windows and Linux, whereas Windows project runs on DirectX\Windows.
-
-- ![](LibraryProject.png) Library project - a project which compiles into a standalone library. Use it to separate your game into modules. Unlike shared project, libraries recompile only if their code has been changed, so you can use them to shorten the compile time. This is targeted more towards larger games with lots of code. Also note that library can't contain its own Content, but you can still use content from outside platforms projects or shared libraries though `ResourceHub` class.
-
-
-
-## You keep talking about crossplatform support, but you've got a crossplatform OpenGL project right there, what's all that shared nonsense is about?
-
-Don't look at me, it's all Monogame's fault.
-
-![](FoxeHiding.png)
-
-OpenGL project isn't that crossplatform if you actually look at it. It produces a single exe which can run on both Windows and Linux using some Mono magic. Monogame supports more platforms -- mobile, consoles, DirectX, all that good stuff. And it requires a setup with shared project.
-
-Currently Monofoxe supports only DesktopGL and DirectX desktop platforms...
-
-**But!**
-
-You can throw default Monogame projects into the mix and it should work! Most likely. Plus, there is an Android project template coming eventually, so stay tuned.
-
-
-
-## [<< Setting things up](SettingThingsUp.md) | [Monofoxe Basics >>](MonofoxeBasics.md)
-
-[<<< Contents](Contents.md)
\ No newline at end of file
diff --git a/Docs/CrossplatformProject.png b/Docs/CrossplatformProject.png
deleted file mode 100644
index 44490f65..00000000
Binary files a/Docs/CrossplatformProject.png and /dev/null differ
diff --git a/Docs/Entities/Components.md b/Docs/Entities/Components.md
index 235d4130..ede1ffa8 100644
--- a/Docs/Entities/Components.md
+++ b/Docs/Entities/Components.md
@@ -56,7 +56,7 @@ component.Owner.GetComponent();
-## [<< Introduction to EC](IntroductionToEC.md) | [Entity templates >>](EntityTemplates.md)
+## [<< Introduction to EC](IntroductionToEC.md) | [Layers >>](Layers.md)
[<<< Contents](../Contents.md)
diff --git a/Docs/Entities/EntityTemplates.md b/Docs/Entities/EntityTemplates.md
deleted file mode 100644
index f4c41ffb..00000000
--- a/Docs/Entities/EntityTemplates.md
+++ /dev/null
@@ -1,40 +0,0 @@
-# Entity templates
-
-If you are using inheritance, you can just add all your components in an entity's constructor. But what if you're going pure EC and using basic `Entity` class directly? Then you have no place to assemble your entity.
-
-This is why entity templates exist. `EntityTemplate` is a little factory class which creates entities on demand.
-
-Here's how you can create one:
-
-```C#
-using Monofoxe.Engine.EC;
-using Monofoxe.Engine.SceneSystem;
-
-public class TestTemplate : IEntityTemplate
-{
- public string Tag => "testEntity";
-
- public Entity Make(Layer layer)
- {
- var entity = new Entity(layer);
-
- var testComponent = new CTest();
- entity.AddComponent(testComponent);
-
- return entity;
- }
-}
-```
-
-To invoke template, you must call static method
-
-```C#
-Entity.CreateFromTemplate(Layer, "testEntity");
-```
-
-
-
-## [<< Components](Components.md) | [Layers >>](../SceneSystem/Layers.md)
-
-[<<< Contents](../Contents.md)
-
diff --git a/Docs/FMODAudio.md b/Docs/FMODAudio.md
index 74d3a1b0..539a7f64 100644
--- a/Docs/FMODAudio.md
+++ b/Docs/FMODAudio.md
@@ -8,7 +8,7 @@ But I have an alternative - FMOD.
I wrote a C# FMOD wrapper, which works on Windows, Linux and Android - you can check it out here:
-## [ChaiFoxes.FMODAudio](https://github.com/gnFur/ChaiFoxes.FMODAudio/)
+## [ChaiFoxes.FMODAudio](https://github.com/Martenfur/ChaiFoxes.FMODAudio/)
diff --git a/Docs/Introduction.md b/Docs/Introduction.md
index 52ff2e1b..2e68ed82 100644
--- a/Docs/Introduction.md
+++ b/Docs/Introduction.md
@@ -1,12 +1,8 @@
# Introduction
-Sup. I am Martenfur and I made a game engine. It's called Monofoxe!
-
-![]()
-
-You've probably read the readme already, so, in short, it's Game Maker Studio "as it should be". Lightweight, open-source, expandable, features foxes. What else can you ask for?
-
+Sup. I am Martenfur and I've reinvented the wheel.
+You've probably seen the readme already, so, in short, Monofoxe is Game Maker Studio "as it should be". Lightweight, open-source, expandable, features foxes. What else can you ask for?
## Too good to be true, eh?
@@ -14,8 +10,6 @@ Welp, it is. Even though liters of my blood and sweat went into this engine, I a
But if you're still determined to master my engine and acquire all the foxes, this is a good place to start:
-
-
## [Setting things up >>](SettingThingsUp.md)
[<<< Contents](Contents.md)
diff --git a/Docs/LibraryProject.png b/Docs/LibraryProject.png
deleted file mode 100644
index 61898a53..00000000
Binary files a/Docs/LibraryProject.png and /dev/null differ
diff --git a/Docs/MonofoxeBasics.md b/Docs/MonofoxeBasics.md
index 44cc7a3d..41f914f2 100644
--- a/Docs/MonofoxeBasics.md
+++ b/Docs/MonofoxeBasics.md
@@ -29,13 +29,11 @@ The only thing you should notice from it is that it creates an instance of `Game
By default it already has some simple logic. You can modify this class however you like.
-The `Content` folder contains all the game's resources in their original format. it also has a `.mgcb` ([Content Pipeline](http://www.monogame.net/documentation/?page=Pipeline)) and `.npl` ([NoPipeline](https://github.com/Martenfur/NoPipeline)) configs which tell how resources should be processed. Don't worry about those for now.
+The `Content` folder contains all the game's resources in their original format. it also has a `.mgcb` ([Content Pipeline](http://www.monogame.net/documentation/?page=Pipeline)) and `.npl` ([Nopipeline](https://github.com/Martenfur/Nopipeline)) configs which tell how resources should be processed. Don't worry about those for now.
-The last notable folder is `Resources`. It provides a way to load and reference your resources. More detailed explanation will be provided in Resources section.
-
-## [<< Creating new project](CreatingNewProject.md) | [Input >>](Input.md)
+## [<< Setting things up](SettingThingsUp.md) | [Input >>](Input.md)
[<<< Contents](Contents.md)
diff --git a/Docs/README.md b/Docs/README.md
index dea82a55..a2b5dd6c 100644
--- a/Docs/README.md
+++ b/Docs/README.md
@@ -8,7 +8,7 @@ You're expected to know:
- Basics of OOP.
- At least five different fox species.
-Docs will not describe each and every function of Monofoxe. For that you'll need to look in the source code - don't worry, it's all nice and documented in there. Main purpose of the docs is to tell you how and when to use main features of the engine.
+Docs will not describe each and every feature of Monofoxe. For that you'll need to look in the source code - don't worry, it's all nice and documented in there. Main purpose of the docs is to tell you how and when to use the main features of the engine.
A good place to start is the [Table of Contents](Contents.md).
diff --git a/Docs/Resources/AddingResources.md b/Docs/Resources/AddingResources.md
index 5989b7de..a7d46cc7 100644
--- a/Docs/Resources/AddingResources.md
+++ b/Docs/Resources/AddingResources.md
@@ -2,11 +2,12 @@
Now we know how resource management in Monofoxe works, but how to access resources in the game?
-By default, all the resources are loaded with classes in the `Resources` folder. These classes are purely optional and you can roll out your own loading system.
+All resources are loaded via `ResourceBox` classes. There are a couple of default resource boxes:
-The easiest one is `Sprites.Default` class. It's generated automatically as you add new sprites in the Explorer.
+- `SpriteGroupResourceBox` - Loads sprites from the sprite group.
+- `DirectoryResourceBox` - Loads all resources of a single type from a specified folder.
-With other resource types things are a bit less convenient. Let's look at the `Fonts` class.
+ You can make custom resource boxes like this:
```c#
namespace Resources
@@ -15,14 +16,10 @@ namespace Resources
{
private ContentManager _content;
- static readonly string Ascii = " !" + '"' + @"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
-
- public override string Name => "Fonts";
-
- public Fonts()
+ public Fonts() : base("Fonts")
{
_content = new ContentManager(GameMgr.Game.Services);
- _content.RootDirectory = AssetMgr.ContentDir + '/' + AssetMgr.FontsDir;
+ _content.RootDirectory = ResourceInfoMgr.ContentDir + "/Fonts";
}
public override void Load()
@@ -33,12 +30,11 @@ namespace Resources
}
Loaded = true;
- // Actual resources.
AddResource("Arial", new Font(_content.Load("Arial")));
var fontSprite = ResourceHub.GetResource("DefaultSprites", "Font");
- AddResource("FancyFont", new TextureFont(fontSprite, 1, 1, Ascii, false));
- // Actual resources.
+
+ AddResource("FancyFont", new TextureFont(fontSprite, 1, 1, TextureFont.Ascii, false));
}
public override void Unload()
@@ -53,16 +49,15 @@ namespace Resources
}
}
-
```
As you can see, it has `Load()` and `Unload()` methods. They are called by the `ResourceHub` class to load and unload the resources.
-To load another font, you should add a new entry in the class by hand. You can also notice the `AssetMgr` class being used. All it does is provide a bunch of shortcuts for commonly used names. Additionally, it has `GetAssetPaths()` method, which returns names of all the assets.
+To load another font, you should add a new entry in the class by hand. Additionally, you can use `ResourceInfoMgr.GetAssetPaths()` method, which returns names of all the assets in a specified path.
-## [<< NoPipeline](NoPipeline.md) | [Resource Hub >>](ResourceHub.md)
+## [<< Nopipeline](Nopipeline.md) | [Resource Hub >>](ResourceHub.md)
[<<< Contents](../Contents.md)
diff --git a/Docs/Resources/NoPipeline.md b/Docs/Resources/NoPipeline.md
index add47c76..8296bf99 100644
--- a/Docs/Resources/NoPipeline.md
+++ b/Docs/Resources/NoPipeline.md
@@ -1,19 +1,19 @@
-# NoPipeline
+# Nopipeline
By default, Monogame uses Pipeline Tool to manage and build resources. Usually you don't add resources directly -- you build them first at compilation, and then load built resources at runtime. It's an ok concept, but Pipeline Tool is a huge hassle to work with. It cannot track resources by itself, you have to open it and add resources by hand every time. Before proceeding, I recommend reading this [article](http://www.monogame.net/documentation/?page=Using_The_Pipeline_Tool) to learn how Pipeline Tool works...
-...and why we need NoPipeline!
+...and why we need Nopipeline!
![NoPipeline](NoPipeline.png)
-NoPipeline is an addon for Pipeline Tool, which generates and updates `.mgcb` config for you. You can safely add, delete and move around resource files right in the Explorer - NoPipeline will do the rest for you.
+NoPipeline is an addon for Pipeline Tool, which generates and updates `.mgcb` config for you. You can safely add, delete and move around resource files right in the Explorer - Nopipeline will do the rest for you.
Additionally, you can make resource files watch other files! Let's say, you got Tiled map project. It has one main `.tmx` file and a bunch of textures and tileset files. But Pipeline Tool has referenced only `.tmx` file, so if you
update only texture or only tileset, you have to either update the `.tmx` or do a manual rebuild, because Pipeline Tool doesn't know about files other than `.tmx`.
With NoPipeline you don't have to do any of that - just set `.tmx` file to watch textures and tilesets - and Pipeline Tool will detect and update everything by itself.
-## But how does NoPipeline know what resources go where?
+## But how does Nopipeline know what resources go where?
NoPipeline uses NPL config. It's used to generate MGCB config. Inside it looks like this:
@@ -108,9 +108,7 @@ will look like this: `Graphics/Default/*.png`.
Monofoxe projects have NPL config set up out of the box. It already has all the basic resource types, but you can add your own in there, if you'd like.
-For additional information, check out [NoPipeline repository](https://github.com/gnFur/NoPipeline).
-
-**NOTE:** NoPipeline is required for Monofoxe to work.
+For additional information, check out [Nopipeline repository](https://github.com/Martenfur/Nopipeline).
## | [Adding resources >>](AddingResources.md)
diff --git a/Docs/SceneSystem/Layers.md b/Docs/SceneSystem/Layers.md
index a0f78f45..4524e2e6 100644
--- a/Docs/SceneSystem/Layers.md
+++ b/Docs/SceneSystem/Layers.md
@@ -37,7 +37,7 @@ Additionally, there is a bunch of selection methods which search for certain ent
You also can move entities to different layers. To do that, assign their `Layer` field to a different layer.
-## [<< Systems](../Entities/Systems.md) | [Scenes >>](Scenes.md)
+## [<< Components](../Entities/Components.md) | [Scenes >>](Scenes.md)
[<<< Contents](../Contents.md)
diff --git a/Docs/SettingThingsUp.md b/Docs/SettingThingsUp.md
index 95d193f3..fb110584 100644
--- a/Docs/SettingThingsUp.md
+++ b/Docs/SettingThingsUp.md
@@ -4,8 +4,8 @@
Well, it is time to install Monofoxe. Currently Monofoxe only supports development on Windows and Visual Studio, but it should be technically possible to make it run on other operating systems and IDEs.
-- Download Visual Studio 2017 [here](https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2017-relnotes). You can use 2019 or 2015, but I recommend 2017, since 2019 is fairly new and not officially supported by Monogame yet.
-- After installing Visual Studio and .NET package, download and install [latest Monofoxe release](https://github.com/Martenfur/Monofoxe/releases/latest). The installer already comes with Monogame, so you don't need to worry about it.
+- Download Visual Studio 2017 [here](https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2017-relnotes). You can use 2019, but I recommend 2017, since 2019 is fairly new and not officially supported by Monogame yet.
+- After installing Visual Studio and .NET Core package, download and install [latest Monofoxe release](https://github.com/Martenfur/Monofoxe/releases/latest). The installer already comes with Monogame, so you don't need to worry about it.
And that's pretty much it! Now you can open Visual Studio and there you'll see Monofoxe project templates.
@@ -13,7 +13,7 @@ And that's pretty much it! Now you can open Visual Studio and there you'll see M
-## [<< Introduction](Introduction.md) | [Creating new project >>](CreatingNewProject.md)
+## [<< Introduction](Introduction.md) | [Monofoxe Basics >>](MonofoxeBasics.md)
[<<< Contents](Contents.md)
diff --git a/Docs/SharedProject.png b/Docs/SharedProject.png
deleted file mode 100644
index 0fa97663..00000000
Binary files a/Docs/SharedProject.png and /dev/null differ
diff --git a/Docs/WinOpenGLProjects.png b/Docs/WinOpenGLProjects.png
deleted file mode 100644
index e11b61ff..00000000
Binary files a/Docs/WinOpenGLProjects.png and /dev/null differ
diff --git a/Installer/Externals/MonoGameSetup.exe b/Installer/Externals/MonoGameSetup.exe
deleted file mode 100644
index eb85366f..00000000
Binary files a/Installer/Externals/MonoGameSetup.exe and /dev/null differ
diff --git a/Installer/Externals/Monofoxe.NoPipeline.targets b/Installer/Externals/Monofoxe.NoPipeline.targets
deleted file mode 100644
index a2c0bfa3..00000000
--- a/Installer/Externals/Monofoxe.NoPipeline.targets
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Installer/packInstaller.nsi b/Installer/packInstaller.nsi
index 3a7c82b0..7898d391 100644
--- a/Installer/packInstaller.nsi
+++ b/Installer/packInstaller.nsi
@@ -4,13 +4,11 @@
!define APPNAME "Monofoxe"
!define APPVERSION "v2-dev"
-!define NPL_APPNAME "NoPipeline"
!define INSTALLERVERSION "2.0.0.0-dev"
!define MUI_ICON "pics\icon.ico"
!define MUI_UNICON "pics\icon.ico"
-!define NOPIPELINEROOT "..\NoPipeline\NoPipeline\NoPipeline\bin\Release"
!define PROJECT_TEMPLATES_DIRECTORY "Templates\ProjectTemplates\Visual C#\${APPNAME} ${APPVERSION}"
!define ITEM_TEMPLATES_DIRECTORY "Templates\ItemTemplates\Visual C#\${APPNAME} ${APPVERSION}"
@@ -47,7 +45,6 @@ VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright © Chai Foxes"
; Request application privileges.
RequestExecutionLevel admin
-
; UI stuff.
!define MUI_HEADERIMAGE "pics\Monofoxe.bmp"
!define MUI_HEADERIMAGE_BITMAP "pics\Monofoxe.bmp"
@@ -55,53 +52,6 @@ RequestExecutionLevel admin
; UI stuff.
; Stuff to install.
-Section "Monofoxe" Monofoxe
- SectionIn RO
- RMDir /r '$INSTDIR'
- SetOutPath '$INSTDIR\lib'
- File /r '..\Monofoxe\bin\Release\*.dll'
- File /r '..\Monofoxe\bin\Release\*.xml'
-
- SetOutPath '$INSTDIR\lib\Pipeline'
- File /r '..\Monofoxe\bin\Pipeline\Release\*.dll'
-
- SetOutPath '$INSTDIR'
- WriteUninstaller "uninstall.exe"
-
- # NoPipeline.
- SetOutPath '$INSTDIR\NoPipeline'
- File /r "${NOPIPELINEROOT}\*.exe"
- File /r "${NOPIPELINEROOT}\*.dll"
- File /r "..\Common\Monofoxe.props"
-
- File /r "Externals\Monofoxe.NoPipeline.targets"
- # NoPipeline.
-
- # Registering the installation.
-
- WriteRegStr HKLM "${REGISTRY_DIRECTORY}" "DisplayName" "${APPNAME}"
- WriteRegStr HKLM "${REGISTRY_DIRECTORY}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
- WriteRegStr HKLM "${REGISTRY_DIRECTORY}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\""
- WriteRegStr HKLM "${REGISTRY_DIRECTORY}" "DisplayIcon" "$\"$INSTDIR\uninstall.exe$\""
- WriteRegStr HKLM "${REGISTRY_DIRECTORY}" "DisplayVersion" "${APPVERSION}"
-
-
- # Registering the installation.
-SectionEnd
-
-Section "MonoGame" Monogame
- SetOutPath '$INSTDIR'
- File "Externals\MonoGameSetup.exe"
- ExecWait "$INSTDIR\MonoGameSetup.exe"
- Delete "$INSTDIR\MonoGameSetup.exe"
-SectionEnd
-
-Section "Visual Studio 2015 Templates/" VS2015
- SetOutPath "$DOCUMENTS\Visual Studio 2015\${PROJECT_TEMPLATES_DIRECTORY}"
- File /r '..\Release\ProjectTemplates\*.zip'
- SetOutPath "$DOCUMENTS\Visual Studio 2015\${ITEM_TEMPLATES_DIRECTORY}"
- File /r '..\Release\ItemTemplates\*.zip'
-SectionEnd
Section "Visual Studio 2017 Templates/" VS2017
SetOutPath "$DOCUMENTS\Visual Studio 2017\${PROJECT_TEMPLATES_DIRECTORY}"
@@ -119,7 +69,6 @@ SectionEnd
!define OldMonofoxeInstallationDir '$PROGRAMFILES\Monofoxe\'
Section "Remove old versions." RemoveOldVersions
- RMDir /r "$DOCUMENTS\Visual Studio 2015\Templates\ProjectTemplates\Visual C#\Monofoxe"
RMDir /r "$DOCUMENTS\Visual Studio 2017\Templates\ProjectTemplates\Visual C#\Monofoxe"
RMDir /r "$DOCUMENTS\Visual Studio 2019\Templates\ProjectTemplates\Visual C#\Monofoxe"
Delete "${OldMonofoxeInstallationDir}\Uninstall.exe"
@@ -130,37 +79,17 @@ SectionEnd
; Component menu.
-LangString MonofoxeDesc ${LANG_ENGLISH} "Install ${APPNAME}!"
-LangString MonogameDesc ${LANG_ENGLISH} "Install MonoGame 3.7.1."
-LangString VS2015Desc ${LANG_ENGLISH} "Install project templates for Visual Studio 2015. Templates are required to create new projects."
LangString VS2017Desc ${LANG_ENGLISH} "Install project templates for Visual Studio 2017. Templates are required to create new projects."
LangString VS2019Desc ${LANG_ENGLISH} "Install project templates for Visual Studio 2019. Templates are required to create new projects."
LangString RemoveOldVersionsDesc ${LANG_ENGLISH} "Remove all previous Monofoxe versions."
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
- !insertmacro MUI_DESCRIPTION_TEXT ${Monofoxe} $(MonofoxeDesc)
- !insertmacro MUI_DESCRIPTION_TEXT ${Monogame} $(MonogameDesc)
- !insertmacro MUI_DESCRIPTION_TEXT ${VS2015} $(VS2015Desc)
!insertmacro MUI_DESCRIPTION_TEXT ${VS2017} $(VS2017Desc)
!insertmacro MUI_DESCRIPTION_TEXT ${VS2019} $(VS2019Desc)
!insertmacro MUI_DESCRIPTION_TEXT ${RemoveOldVersions} $(RemoveOldVersionsDesc)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
-Function checkMonogame
-IfFileExists `$PROGRAMFILES\MonoGame\v3.0\*.*` disable end
- disable:
- SectionSetFlags ${Monogame} $1
- end:
-FunctionEnd
-
-Function checkVS2015
-IfFileExists `$DOCUMENTS\Visual Studio 2015\Templates\ProjectTemplates\*.*` end disable
- disable:
- SectionSetFlags ${VS2015} $1
- end:
-FunctionEnd
-
Function checkVS2017
IfFileExists `$DOCUMENTS\Visual Studio 2017\Templates\ProjectTemplates\*.*` end disable
disable:
@@ -178,27 +107,8 @@ FunctionEnd
Function .onInit
IntOp $0 $0 | ${SF_RO}
- Call checkMonogame
- Call checkVS2015
Call checkVS2017
Call checkVS2019
IntOp $0 ${SF_SELECTED} | ${SF_RO}
FunctionEnd
-; Uninstaller Section
-
-Section "Uninstall"
- RMDir /r "$DOCUMENTS\Visual Studio 2015\${PROJECT_TEMPLATES_DIRECTORY}"
- RMDir /r "$DOCUMENTS\Visual Studio 2017\${PROJECT_TEMPLATES_DIRECTORY}"
- RMDir /r "$DOCUMENTS\Visual Studio 2019\${PROJECT_TEMPLATES_DIRECTORY}"
- RMDir /r "$DOCUMENTS\Visual Studio 2015\${ITEM_TEMPLATES_DIRECTORY}"
- RMDir /r "$DOCUMENTS\Visual Studio 2017\${ITEM_TEMPLATES_DIRECTORY}"
- RMDir /r "$DOCUMENTS\Visual Studio 2019\${ITEM_TEMPLATES_DIRECTORY}"
-
- Delete "$INSTDIR\Uninstall.exe"
- RMDir /r "$INSTDIR"
- DeleteRegKey HKLM "${REGISTRY_DIRECTORY}"
-SectionEnd
-
-
-
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Effects/Common.fxh b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Effects/Common.fxh
similarity index 100%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Effects/Common.fxh
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Effects/Common.fxh
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Effects/Grayscale.fx b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Effects/Grayscale.fx
similarity index 96%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Effects/Grayscale.fx
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Effects/Grayscale.fx
index 0601c9f0..895ea8b0 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/Content/Effects/Grayscale.fx
+++ b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Effects/Grayscale.fx
@@ -1,13 +1,13 @@
-#include "Common.fxh"
-
-sampler s0;
-
-float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
-{
- float4 color = tex2D(s0, input.TexCoords.xy);
- float s = (color.r + color.g + color.b) / 3.0 ;
- return float4(s, s, s, 1) * color.a;
-}
-
-TECHNIQUE(Technique1, PassThroughVertexFunction, PixelShaderFunction);
-
+#include "Common.fxh"
+
+sampler s0;
+
+float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
+{
+ float4 color = tex2D(s0, input.TexCoords.xy);
+ float s = (color.r + color.g + color.b) / 3.0 ;
+ return float4(s, s, s, 1) * color.a;
+}
+
+TECHNIQUE(Technique1, PassThroughVertexFunction, PixelShaderFunction);
+
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Effects/Seizure.fx b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Effects/Seizure.fx
similarity index 100%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Effects/Seizure.fx
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Effects/Seizure.fx
diff --git a/Templates/ProjectTemplates/Shared/Content/Fonts/Arial.spritefont b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Fonts/Arial.spritefont
similarity index 100%
rename from Templates/ProjectTemplates/Shared/Content/Fonts/Arial.spritefont
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Fonts/Arial.spritefont
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default.spritegroup b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default.spritegroup
new file mode 100644
index 00000000..0c63df0f
--- /dev/null
+++ b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default.spritegroup
@@ -0,0 +1,9 @@
+{
+ "atlasSize": 512,
+ "texturePadding": 1,
+ "rootDir": "/Default",
+ "singleTexturesWildcards":
+ [
+ "/Textures/*"
+ ]
+}
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Bot.json b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Bot.json
new file mode 100644
index 00000000..c56a82bf
--- /dev/null
+++ b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Bot.json
@@ -0,0 +1,6 @@
+{
+ "v": 1,
+ "h": 1,
+ "originX": "center",
+ "originY": "bottom"
+}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/bot.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Bot.png
similarity index 100%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/bot.png
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Bot.png
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/DebugSquare.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/DebugSquare.png
new file mode 100644
index 00000000..da2c1114
Binary files /dev/null and b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/DebugSquare.png differ
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Fire.json b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Fire.json
new file mode 100644
index 00000000..bc57ab96
--- /dev/null
+++ b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Fire.json
@@ -0,0 +1,6 @@
+{
+ "v": 1,
+ "h": 17,
+ "originX": "center",
+ "originY": "bottom"
+}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/fire.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Fire.png
similarity index 100%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/fire.png
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Fire.png
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Font.json b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Font.json
new file mode 100644
index 00000000..172dafe6
--- /dev/null
+++ b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Font.json
@@ -0,0 +1,6 @@
+{
+ "v": 5,
+ "h": 20,
+ "originX": 0,
+ "originY": 0
+}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/font.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Font.png
similarity index 100%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/font.png
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Font.png
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Monofoxe.json b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Monofoxe.json
new file mode 100644
index 00000000..86af8ec3
--- /dev/null
+++ b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Monofoxe.json
@@ -0,0 +1,6 @@
+{
+ "v": 1,
+ "h": 1,
+ "originX": "center",
+ "originY": "center"
+}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/monofoxe.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Monofoxe.png
similarity index 100%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/monofoxe.png
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Monofoxe.png
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Player.json b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Player.json
new file mode 100644
index 00000000..d2e6dc36
--- /dev/null
+++ b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Player.json
@@ -0,0 +1,6 @@
+{
+ "v": 1,
+ "h": 1,
+ "originX": "center + 2",
+ "originY": "bottom"
+}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/player.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Player.png
similarity index 100%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/player.png
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Player.png
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Test.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Test.png
new file mode 100644
index 00000000..d3b12a84
Binary files /dev/null and b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Test.png differ
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/Textures/autism_cat.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Textures/AutismCat.png
similarity index 100%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/Textures/autism_cat.png
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Graphics/Default/Textures/AutismCat.png
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Maps/Templates/Bot.tx b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Templates/Bot.tx
similarity index 100%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Maps/Templates/Bot.tx
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Templates/Bot.tx
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Maps/Templates/Player.tx b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Templates/Player.tx
similarity index 100%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Maps/Templates/Player.tx
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Templates/Player.tx
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Maps/Templates/TemplatesTileset/Templates.tsx b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Templates/TemplatesTileset/Templates.tsx
similarity index 100%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Maps/Templates/TemplatesTileset/Templates.tsx
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Templates/TemplatesTileset/Templates.tsx
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Maps/Templates/TemplatesTileset/bot.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Templates/TemplatesTileset/bot.png
similarity index 100%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Maps/Templates/TemplatesTileset/bot.png
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Templates/TemplatesTileset/bot.png
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Maps/Templates/TemplatesTileset/player.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Templates/TemplatesTileset/player.png
similarity index 100%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Maps/Templates/TemplatesTileset/player.png
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Templates/TemplatesTileset/player.png
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Maps/test.tmx b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Test.tmx
similarity index 99%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Maps/test.tmx
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Test.tmx
index 39934099..09882fa3 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/Content/Maps/test.tmx
+++ b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Test.tmx
@@ -1,5 +1,5 @@
-
+
@@ -524,7 +524,15 @@
-
+
+
+ * This is a sign.
+* That's about it.
+ Looole :D
+Test toast kek kok maslena.
+Yiss.
+
+
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Maps/Tilesets/grass.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Tilesets/grass.png
similarity index 100%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Maps/Tilesets/grass.png
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Tilesets/grass.png
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Maps/Tilesets/grass.tsx b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Tilesets/grass.tsx
similarity index 100%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Maps/Tilesets/grass.tsx
rename to Monofoxe.Playground/Monofoxe.Playground.Content/Content/Maps/Tilesets/grass.tsx
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/NormalMap.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/NormalMap.png
new file mode 100644
index 00000000..ce9ffb59
Binary files /dev/null and b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/NormalMap.png differ
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/NormalMap2.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/NormalMap2.png
new file mode 100644
index 00000000..b97b2c05
Binary files /dev/null and b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/NormalMap2.png differ
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/NormalMap3.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/NormalMap3.png
new file mode 100644
index 00000000..6b22e9df
Binary files /dev/null and b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/NormalMap3.png differ
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/body_u1_v1.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/body_u1_v1.png
new file mode 100644
index 00000000..de03222e
Binary files /dev/null and b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/body_u1_v1.png differ
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/body_u2_v1.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/body_u2_v1.png
new file mode 100644
index 00000000..fb82e618
Binary files /dev/null and b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/body_u2_v1.png differ
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/eyes_u2_v1.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/eyes_u2_v1.png
new file mode 100644
index 00000000..814f66eb
Binary files /dev/null and b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/eyes_u2_v1.png differ
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/head_u1_v1.png b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/head_u1_v1.png
new file mode 100644
index 00000000..f0e3633b
Binary files /dev/null and b/Monofoxe.Playground/Monofoxe.Playground.Content/Content/textures/head_u1_v1.png differ
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Content/Monofoxe.Playground.Content.csproj b/Monofoxe.Playground/Monofoxe.Playground.Content/Monofoxe.Playground.Content.csproj
new file mode 100644
index 00000000..5b7b974b
--- /dev/null
+++ b/Monofoxe.Playground/Monofoxe.Playground.Content/Monofoxe.Playground.Content.csproj
@@ -0,0 +1,19 @@
+
+
+ netstandard2.0
+ true
+ false
+ bin/
+
+
+
+ All
+
+
+ All
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Content/Content.mgcb b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Content/Content.mgcb
new file mode 100644
index 00000000..5b466b6c
--- /dev/null
+++ b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Content/Content.mgcb
@@ -0,0 +1,60 @@
+
+#----------------------------- Global Properties ----------------------------#
+
+/outputDir:bin/$(Platform)
+/intermediateDir:obj/$(Platform)
+/platform:Windows
+/config:
+/profile:Reach
+/compress:True
+
+#-------------------------------- References --------------------------------#
+
+/reference:../../Monofoxe.Playground.Content/bin/Monofoxe.Pipeline.dll
+
+#---------------------------------- Content ---------------------------------#
+
+#begin Content.npl
+/importer:ResourceInfoImporter
+/processor:PassThroughProcessor
+/build:Content.npl
+
+#begin ../../Monofoxe.Playground.Content/Content/Graphics/Default.spritegroup
+/importer:SpriteGroupImporter
+/processor:SpriteGroupProcessor
+/build:../../Monofoxe.Playground.Content/Content/Graphics/Default.spritegroup;Graphics/Default.spritegroup
+
+#begin ../../Monofoxe.Playground.Content/Content/Effects/Grayscale.fx
+/importer:EffectImporter
+/processor:EffectProcessor
+/build:../../Monofoxe.Playground.Content/Content/Effects/Grayscale.fx;Effects/Grayscale.fx
+
+#begin ../../Monofoxe.Playground.Content/Content/Effects/Seizure.fx
+/importer:EffectImporter
+/processor:EffectProcessor
+/build:../../Monofoxe.Playground.Content/Content/Effects/Seizure.fx;Effects/Seizure.fx
+
+#begin ../../Monofoxe.Playground.Content/Content/Maps/Test.tmx
+/importer:TiledMapImporter
+/processor:PassThroughProcessor
+/build:../../Monofoxe.Playground.Content/Content/Maps/Test.tmx;Maps/Test.tmx
+
+#begin ../../Monofoxe.Playground.Content/Content/Maps/Tilesets/grass.png
+/importer:TextureImporter
+/processor:TextureProcessor
+/build:../../Monofoxe.Playground.Content/Content/Maps/Tilesets/grass.png;Maps/Tilesets/grass.png
+
+#begin ../../Monofoxe.Playground.Content/Content/Maps/Templates/TemplatesTileset/bot.png
+/importer:TextureImporter
+/processor:TextureProcessor
+/build:../../Monofoxe.Playground.Content/Content/Maps/Templates/TemplatesTileset/bot.png;Maps/Templates/TemplatesTileset/bot.png
+
+#begin ../../Monofoxe.Playground.Content/Content/Maps/Templates/TemplatesTileset/player.png
+/importer:TextureImporter
+/processor:TextureProcessor
+/build:../../Monofoxe.Playground.Content/Content/Maps/Templates/TemplatesTileset/player.png;Maps/Templates/TemplatesTileset/player.png
+
+#begin ../../Monofoxe.Playground.Content/Content/Fonts/Arial.spritefont
+/importer:FontDescriptionImporter
+/processor:FontDescriptionProcessor
+/build:../../Monofoxe.Playground.Content/Content/Fonts/Arial.spritefont;Fonts/Arial.spritefont
\ No newline at end of file
diff --git a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Content/Content.npl b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Content/Content.npl
new file mode 100644
index 00000000..000b5469
--- /dev/null
+++ b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Content/Content.npl
@@ -0,0 +1,88 @@
+{
+ "root": "../../Monofoxe.Playground.Content/Content/",
+ "references":
+ [
+ "../../Monofoxe.Playground.Content/bin/Monofoxe.Pipeline.dll"
+ ],
+ "content":
+ {
+ "contentList":
+ {
+ "path": "$Content.npl",
+ "recursive": "False",
+ "action": "build",
+ "importer": "ResourceInfoImporter",
+ "processor": "PassThroughProcessor",
+ "watch":
+ [
+ "../../Monofoxe.Playground.Content/Content/*"
+ ]
+ },
+ "music":
+ {
+ "path": "Audio/Music/*.ogg",
+ "recursive": "True",
+ "action": "copy"
+ },
+ "sounds":
+ {
+ "path": "Audio/Sounds/*.wav",
+ "recursive": "True",
+ "action": "copy"
+ },
+ "defaultSpriteGroup":
+ {
+ "path": "Graphics/*.spritegroup",
+ "recursive": "True",
+ "action": "build",
+ "importer": "SpriteGroupImporter",
+ "processor": "SpriteGroupProcessor",
+ "watch":
+ [
+ "Default/*.png",
+ "Default/*.json"
+ ]
+ },
+ "effects":
+ {
+ "path": "Effects/*.fx",
+ "recursive": "True",
+ "action": "build",
+ "importer": "EffectImporter",
+ "processor": "EffectProcessor"
+ },
+ "tiledMaps":
+ {
+ "path": "Maps/*.tmx",
+ "recursive": "True",
+ "action": "build",
+ "importer": "TiledMapImporter",
+ "processor": "PassThroughProcessor",
+ "watch":
+ [
+ "Tilesets/*.tsx",
+ "Tilesets/*.png",
+ "Templates/*.tsx",
+ "Templates/*.tx",
+ "Templates/*.png"
+ ]
+ },
+ "tiledMapTextures":
+ {
+ "path": "Maps/*.png",
+ "recursive": "True",
+ "action": "build",
+ "importer": "TextureImporter",
+ "processor": "TextureProcessor"
+ },
+ "fonts":
+ {
+ "path": "Fonts/*.spritefont",
+ "recursive": "True",
+ "action": "build",
+ "importer": "FontDescriptionImporter",
+ "processor": "FontDescriptionProcessor"
+ }
+
+ }
+}
diff --git a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Icon.bmp b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Icon.bmp
index 907b6ede..a6b68305 100644
Binary files a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Icon.bmp and b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Icon.bmp differ
diff --git a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Icon.ico b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Icon.ico
index 4b8477a4..86aab077 100644
Binary files a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Icon.ico and b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Icon.ico differ
diff --git a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Monofoxe.Playground.DesktopGL.csproj b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Monofoxe.Playground.DesktopGL.csproj
index 50893e77..0882c0e0 100644
--- a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Monofoxe.Playground.DesktopGL.csproj
+++ b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Monofoxe.Playground.DesktopGL.csproj
@@ -1,130 +1,37 @@
-
-
-
-
- Debug
- AnyCPU
- 8.0.30703
- 2.0
- {058E861C-4B60-4410-A73B-4BCA5DC70EC2}
- WinExe
- Properties
- Monofoxe.Playground.DesktopGL
- Monofoxe.Playground.DesktopGL
- 512
- DesktopGL
- v4.6.1
-
-
-
- true
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- DEBUG;TRACE;LINUX
- full
- AnyCPU
- prompt
- false
- 4
-
-
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- TRACE;LINUX
- true
- pdbonly
- AnyCPU
- prompt
- false
- 4
-
-
- Icon.ico
-
-
- app.manifest
-
-
-
-
-
-
-
- $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\DesktopGL\MonoGame.Framework.dll
-
-
-
-
-
-
-
-
-
-
- x86\SDL2.dll
- PreserveNewest
-
-
- x64\SDL2.dll
- PreserveNewest
-
-
- x86\soft_oal.dll
- PreserveNewest
-
-
- x64\soft_oal.dll
- PreserveNewest
-
-
- x86\libSDL2-2.0.so.0
- PreserveNewest
-
-
- x64\libSDL2-2.0.so.0
- PreserveNewest
-
-
- x86\libopenal.so.1
- PreserveNewest
-
-
- x64\libopenal.so.1
- PreserveNewest
-
-
- libSDL2-2.0.0.dylib
- PreserveNewest
-
-
- libopenal.1.dylib
- PreserveNewest
-
-
- MonoGame.Framework.dll.config
- PreserveNewest
-
-
-
-
-
-
-
- {9a75ed71-2fdf-47e2-b9e9-1918eca10bc8}
- Monofoxe.Engine
-
-
- {21e56073-5e48-4346-9800-872264f5abb5}
- Monofoxe.Tiled
-
-
-
-
-
-
-
+
+
+ WinExe
+ netcoreapp3.1
+ false
+ false
+
+
+ app.manifest
+ Icon.ico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Monofoxe.props b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Monofoxe.props
deleted file mode 100644
index 0e3de9ca..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Monofoxe.props
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- $(MSBuildProgramFiles32)\Monofoxe Engine\
- v2-dev
-
-
diff --git a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Program.cs b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Program.cs
index 78a13901..86b3fa39 100644
--- a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Program.cs
+++ b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Program.cs
@@ -1,21 +1,14 @@
-using System;
-
-// NOTE: This project is dependent on Monofoxe solution.
-// You need to build all Monofoxe libraries in Debug mode first.
+using Monofoxe.Engine.DesktopGL;
+using System;
namespace Monofoxe.Playground.DesktopGL
{
- ///
- /// The main class.
- ///
public static class Program
{
- ///
- /// The main entry point for the application.
- ///
[STAThread]
static void Main()
{
+ MonofoxePlatform.Init();
using (var game = new Game1())
{
game.Run();
diff --git a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Properties/AssemblyInfo.cs b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Properties/AssemblyInfo.cs
deleted file mode 100644
index 29ec8da2..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Monofoxe.Playground.DesktopGL")]
-[assembly: AssemblyProduct("Monofoxe.Playground.DesktopGL")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyCopyright("Copyright © 2019")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("8b037a91-5af0-4132-8ca4-148e008e17a1")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/app.config b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/app.config
deleted file mode 100644
index 3dbff35f..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/app.config
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/app.manifest b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/app.manifest
index 7e81c664..a979b3c6 100644
--- a/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/app.manifest
+++ b/Monofoxe.Playground/Monofoxe.Playground.DesktopGL/app.manifest
@@ -36,6 +36,7 @@
true/pm
+ permonitorv2,permonitor
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Windows/Icon.ico b/Monofoxe.Playground/Monofoxe.Playground.Windows/Icon.ico
deleted file mode 100644
index 7d9dec18..00000000
Binary files a/Monofoxe.Playground/Monofoxe.Playground.Windows/Icon.ico and /dev/null differ
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Windows/Monofoxe.Playground.Windows.csproj b/Monofoxe.Playground/Monofoxe.Playground.Windows/Monofoxe.Playground.Windows.csproj
deleted file mode 100644
index c3b67330..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground.Windows/Monofoxe.Playground.Windows.csproj
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
-
-
- Debug
- x86
- 8.0.30703
- 2.0
- {5431EE33-D78F-4263-A4AE-61852A61386D}
- WinExe
- Properties
- Monofoxe.Playground.Windows
- Monofoxe.Playground.Windows
- 512
- Windows
- v4.6.1
-
-
-
- x86
- true
- full
- false
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- DEBUG;TRACE;WINDOWS
- prompt
- 4
-
-
- x86
- pdbonly
- true
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- TRACE;WINDOWS
- prompt
- 4
-
-
- Icon.ico
-
-
- app.manifest
-
-
-
-
-
-
-
- $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {9a75ed71-2fdf-47e2-b9e9-1918eca10bc8}
- Monofoxe.Engine
-
-
- {21e56073-5e48-4346-9800-872264f5abb5}
- Monofoxe.Tiled
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Windows/Monofoxe.props b/Monofoxe.Playground/Monofoxe.Playground.Windows/Monofoxe.props
deleted file mode 100644
index 0e3de9ca..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground.Windows/Monofoxe.props
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- $(MSBuildProgramFiles32)\Monofoxe Engine\
- v2-dev
-
-
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Windows/Program.cs b/Monofoxe.Playground/Monofoxe.Playground.Windows/Program.cs
deleted file mode 100644
index 6bed5b5a..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground.Windows/Program.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-
-namespace Monofoxe.Playground.Windows
-{
-#if WINDOWS || LINUX
- ///
- /// The main class.
- ///
- public static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- static void Main()
- {
- using(var game = new Game1())
- game.Run();
- }
- }
-#endif
-}
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Windows/Properties/AssemblyInfo.cs b/Monofoxe.Playground/Monofoxe.Playground.Windows/Properties/AssemblyInfo.cs
deleted file mode 100644
index 1b6706e2..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground.Windows/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Monofoxe.Playground.Windows")]
-[assembly: AssemblyProduct("Monofoxe.Playground.Windows")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyCopyright("Copyright © 2019")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("23428808-70d2-498e-b0d4-44a52a6201e1")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Windows/References/Monofoxe.Engine.xml b/Monofoxe.Playground/Monofoxe.Playground.Windows/References/Monofoxe.Engine.xml
deleted file mode 100644
index fcf3d463..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground.Windows/References/Monofoxe.Engine.xml
+++ /dev/null
@@ -1,2773 +0,0 @@
-
-
-
- Monofoxe.Engine
-
-
-
-
- Provides convenient asset paths and lists all content assets.
-
-
-
-
- Root directory of the game content.
-
-
-
-
- Root directory for graphics.
- NOTE: This directory is located inside ContentDir.
-
-
-
-
- Root directory for the audio.
- NOTE: This directory is located inside ContentDir.
-
-
-
-
- Root directory for shaders.
- NOTE: This directory is located inside ContentDir.
-
-
-
-
- Root directory for fonts.
- NOTE: This directory is located inside ContentDir.
-
-
-
-
- Root directory for entity templates.
- NOTE: This directory is located inside ContentDir.
-
-
-
-
- Root directory for maps.
- NOTE: This directory is located inside ContentDir.
-
-
-
-
- List of all game ssets.
-
-
-
-
- Returns list of asset paths matching input path.
- Empty string will return all asset paths.
-
-
-
-
- Combined enums from keyboard, gamepad and mouse.
- I really don't like the idea of 3 separate sets of functions for each input method.
-
- NOTE: Standard Xna.Input.Keys can be casted into Buttons.
-
-
-
-
- Canvas drawing modes for WindowMgr.
-
-
-
-
- Keeps aspect ration between screen and canvas,
- resulting in black bars.
-
-
-
-
- Scales canvas to fit them into screen.
-
-
-
-
- Canvas stays as is, without any transforming.
-
-
-
-
- Reads sprite group file.
-
-
-
-
- Draws text in specified coordinates.
-
-
-
-
- Draws text in specified coordinates.
-
-
-
-
- Draws text in specified coordinates with rotation, scale and origin.
-
-
-
-
- Draws text in specified coordinates with rotation, scale and origin.
-
-
-
-
- Drawable circle shape. Can be drawn by using static methods or be instantiated.
-
-
-
-
- Center point of a circle.
-
-
-
-
- If false, circle will be filled with solid color. If true, only outline will be drawn.
-
-
-
-
- Amount of vertices in one circle.
-
-
-
-
- Draws a circle.
-
-
-
-
- Draws a circle.
-
-
-
-
- Draws a circle.
-
-
-
-
- Draws a circle.
-
-
-
-
- Triangle primitive, which can accept any array of indices.
-
-
-
-
- Array of primitive indices. They tell primitive what vertices to draw in what order.
-
-
-
-
- Sets user-defined list of indices for a list of triangles.
-
-
-
-
- Anything that can be drawn.
-
-
-
-
- Drawable object's global position.
-
-
-
-
- Draws the object.
-
-
-
-
- Line primitive, which can accept any array of indices.
-
-
-
-
- Array of primitive indices. They tell primitive what vertices to draw in what order.
-
-
-
-
- Sets user-defined list of indices for a list of lines.
-
-
-
-
- Drawable thick line shape. Can be drawn by using static methods or be instantiated.
-
-
-
-
- First line point.
- NOTE: all line points treat position as an origin point;
-
-
-
-
- Second line point.
- NOTE: all line points treat position as an origin point;
-
-
-
-
- Line thickness.
-
-
-
-
- Draws a line with specified width.
-
-
-
-
- Draws a line with specified width and colors.
-
-
-
-
- Draws a line with specified width.
-
-
-
-
- Draws a line with specified width and colors.
-
-
-
-
- Base 2D primitive class. Can be used to create other types of primitives.
-
-
-
-
- List of all primitive's vertices.
- NOTE: all vertices treat position as an origin point;
-
-
-
-
- Graphics mode which will be used while drawing primitive.
-
-
-
-
- Frame texture.
- NOTE: Frame and be only a small part of a big texture.
-
-
-
-
- Offset of a texture region.
-
-
-
-
- Ratio between texture size and frame size.
-
-
-
-
- Sets texture for a primitive.
-
-
-
-
- Sets texture for a primitive.
-
-
-
-
- Returns an array of vertex indices which essentially determine how primitive will be drawn.
-
-
-
-
- Converts list of Monofoxe Vertex objects to Monogame's vertices.
-
-
-
-
- Drawable line shape. Can be drawn by using static methods or be instantiated.
- NOTE: The line has no width.
-
-
-
-
- First line point.
- NOTE: all line points treat position as an origin point;
-
-
-
-
- Second line point.
- NOTE: all line points treat position as an origin point;
-
-
-
-
- Draws a line.
-
-
-
-
- Draws a line with specified colors.
-
-
-
-
- Draws a line.
-
-
-
-
- Draws a line with specified colors.
-
-
-
-
- Center point of a rectangle.
-
-
-
-
- If false, circle will be filled with solid color. If true, only outline will be drawn.
-
-
-
-
- Draws a rectangle using instance properties.
-
-
-
-
- Draws a rectangle using top left and bottom right point.
-
-
-
-
- Draws a rectangle using top left and bottom right point with specified colors for each corner.
-
-
-
-
- Draws a rectangle using top left and bottom right point.
-
-
-
-
- Draws a rectangle using top left and bottom right point with specified colors for each corner.
-
-
-
-
- Draws a rectangle using center point and size.
-
-
-
-
- Draws a rectangle using center point and size with specified colors for each corner.
-
-
-
-
- Draws a rectangle using center point and size.
-
-
-
-
- Draws a rectangle using center point and size with specified colors for each corner.
-
-
-
-
- Drawable line strip primitive. Draws a bunch of connected lines. Can be looped.
- Pattern: 0 - 1 - 2 - 3
-
-
-
-
- If true, a line between first and last vertex will be drawn.
-
-
-
-
- Sets indices according to line strip pattern.
-
-
-
-
- Drawable mesh primitive. Draws a grid of triangles.
- Pattern:
- 0 - 1 - 2
- | / | / |
- 3 - 4 - 5
- | / | / |
- 6 - 7 - 8
-
-
-
-
- Mesh width in cells.
-
-
-
-
- Mesh height in cells.
-
-
-
-
- Sets indexes according to mesh pattern.
- NOTE: Make sure there's enough vertices for width and height of the mesh.
- NOTE: Use counter-clockwise culling.
-
-
-
-
- Drawable triangle strip primitive. Draws a strip of triangles.
- Pattern:
- 0 - 2 - 4
- \ / \ /
- 1 - 3
-
-
-
-
- Sets indices according to trianglestrip pattern.
- NOTE: Use counter-clockwise culling.
-
-
-
-
- Drawable triangle fan primitive.
- Draws a bunch of triangles, all of which begin at the first vertex.
- Pattern:
- 1 - 2
- | / |
- 0 - 3
- | \ |
- 5 - 4
-
-
-
-
- Sets indexes according to trianglefan pattern.
- NOTE: Use counter-clockwise culling.
-
-
-
-
- Drawable triangle shape. Can be drawn by using static methods or be instantiated.
-
-
-
-
- First triangle point.
- NOTE: all triangle points treat position as an origin point;
-
-
-
-
- Second triangle point.
- NOTE: all triangle points treat position as an origin point;
-
-
-
-
- Third triangle point.
- NOTE: all triangle points treat position as an origin point;
-
-
-
-
- If false, circle will be filled with solid color. If true, only outline will be drawn.
-
-
-
-
- Draws a triangle.
-
-
-
-
- Draws a triangle with specified colors.
-
-
-
-
- Draws a triangle.
-
-
-
-
- Draw a triangle with specified colors.
-
-
-
-
- Wrapper of SpriteFont.
-
-
-
-
- Returns a Dictionary of Glyphs for current font.
-
-
-
-
- Measures both width and height of text.
-
-
-
-
- Measures both width and height of text.
-
-
-
-
- Measures width of the text.
- NOTE: It is highly recommended to use MeasureString,
- since under the hood it is still just a MeasureString call.
-
-
-
-
- Measures width of the text.
- NOTE: It is highly recommended to use MeasureString,
- since under the hood it is still just a MeasureString call.
-
-
-
-
- Measures height of the text.
- NOTE: It is highly recommended to use MeasureString,
- since under the hood it is still just a MeasureString call.
-
-
-
-
- Measures height of the text.
- NOTE: It is highly recommended to use MeasureString,
- since under the hood it is still just a MeasureString call.
-
-
-
-
- Draws text. Not recommended to call on its own, use Text class instead.
-
-
-
-
- Drawable frame.
-
-
-
-
- Texture atlas where frame is stored.
-
-
-
-
- Position of the frame on the atlas.
-
-
-
-
- Width of the frame.
-
-
-
-
- Height of the frame.
-
-
-
-
- Frame's parent sprite.
-
-
-
-
- XNA's SpriteFont doesn't provide interface for itself,
- so we have to make our own.
-
-
-
-
- Drawable sprite.
-
-
-
-
- An array of sprite's frames.
-
-
-
-
- Sprite width. Can be accessed only if all sprite frames have the same size.
-
-
-
-
- Sprite height. Can be accessed only if all sprite frames have the same size.
-
-
-
-
- True, if size of every frame is identical.
-
-
-
-
- Amount of sprite's frames.
-
-
-
-
- Returns a frame with given index.
-
-
-
-
- Checks if all frames got identical sizes.
-
- Array of frames to check.
-
-
-
- Returns sprite frame based on an animation value from 0 to 1.
-
-
-
-
- Unused, because TextureFont can have multiple textures.
-
-
-
-
- Measures width and height of the text.
-
-
-
-
- Measures width and height of the text.
-
-
-
-
- Measures width of the text.
-
-
-
-
- Measures width of the text.
-
-
-
-
- Measures height of the text.
-
-
-
-
- Measures height of the text.
-
-
-
-
- Draws text. Not recommended to call on its own, use Text class instead.
-
-
-
-
- Default sprite batch used to draw sprites, text and surfaces.
-
-
-
-
- Currently enabled camera.
-
-
-
-
- Current transformation matrix. Used to offset, rotate and scale graphics.
-
-
-
-
- Current drawing color. Affects shapes, sprites, text and primitives.
-
-
-
-
- Amount of draw calls per frame.
-
-
-
-
- Current graphics mode. Tells, which type of graphics is being drawn right now.
-
-
-
-
- We can set surface targets inside another surfaces.
-
-
-
-
- Disables rendering for everything that's outside of rectangle.
- NOTE: To enable scissoring, enable scissor test in Rasterizer.
-
-
-
-
- Rasterizer state.
- NOTE: Do NOT modify object which you'll set. This will lead to errors and unexpected behaviour.
-
-
-
-
- Sampler state. Used for interpolation and texture wrappping.
- NOTE: Do NOT modify object which you'll set. This will lead to errors and unexpected behaviour.
-
-
-
-
- Blend state. Used for color blending.
- NOTE: Do NOT modify object which you'll set. This will lead to errors and unexpected behaviour.
-
-
-
-
- Current shader. Set to null to reset to the default shader.
-
-
-
-
- Default shader with proper alpha blending.
- Replaces BasicEffect. Applied, when CurrentEffect is null.
-
-
-
-
- Used for drawing cameras.
-
-
-
-
- Matrix for offsetting, scaling and rotating canvas contents.
-
-
-
-
- Used to load default shader.
-
-
-
-
- Initialization function for draw manager.
-
-
-
-
- Performs Draw events for all objects.
-
-
-
-
- Switches graphics mode.
-
- Call it before manually using sprite batches or vertex buffers.
-
-
-
-
- Adds vertices and indices to global vertex and index list.
- If current and suggested graphics modes are different, draws accumulated vertices first.
-
-
-
-
- Draws vertices from vertex buffer and empties it.
-
-
-
-
- Sets new transform matrix.
-
-
-
-
- Sets new transform matrix multiplied by current transform matrix.
-
-
-
-
- Resets to a previous transform matrix.
-
-
-
-
- Sets surface as a render target.
-
-
-
-
- Sets surface as a render target.
-
- Target surface.
- Surface transformation matrix.
-
-
-
- Resets render target to a previous surface.
-
-
-
-
- Every time we want to draw primitive of different type
- or switch texture, we need to empty vertex buffer
- and switch graphics mode.
-
-
-
-
- No mode set.
-
-
-
-
- Sprite batch.
-
-
-
-
- Text.
-
-
-
-
- Triangle list.
-
-
-
-
- Line list.
-
-
-
-
- Custom container for entity components.
- Basically just a dictionary of lists of components.
-
-
-
-
- Adds component to the container.
-
-
-
-
- Removes component from the container.
-
-
-
-
- Gets the component list associated with the specified key.
-
-
-
-
- Entity factory pool stores in instance of each entity factory.
-
-
-
-
- Pool of all factories in all assemblies. Sorted by their tags.
-
-
-
-
- Initialized template pool by creating an instance of each IEntityTemplateclass.
-
-
-
-
- Entity template interface. Used to create entity by tag.
-
-
-
-
- Identifying tag. Will be assigned to created entities.
-
- NOTE: All template tags should be unique!
-
-
-
-
- Creates an entity on a given layer.
-
-
-
-
- Basic system interface.
-
-
-
-
- Type of components, which are processed by this system.
-
-
-
-
- System priority. If priority is higher, system will be processed sooner.
-
-
-
-
- If system is enabled, it will invoke its Update and Draw methods.
-
-
-
-
- Stores data, which will be processed by corresponding systems.
-
-
-
-
- Owner of a component.
-
- NOTE: Component should ALWAYS have an owner.
-
-
-
-
- Tells if this component was initialized.
-
-
-
-
- If component is enabled, it will be processed by Create and Update methods.
-
-
-
-
- If component is visible, it will be processed by Draw method.
-
- NOTE: components are NOT visible by default!
-
-
-
-
- Component's assigned system. Will be null only if no systems exist for this component.
-
-
-
-
- Parent class of every in-game object.
- Can hold components, or implement its own logic.
-
-
-
-
- Unique tag for identifying entity.
- NOTE: Entity tags should be unique!
-
-
-
-
- Depth of Draw event. Objects with the lowest depth draw the last.
-
-
-
-
- Tells f object was destroyed.
-
-
-
-
- If false, Update and Destroy events won't be executed.
- NOTE: This also applies to entity's components.
-
-
-
-
- If false, Draw events won't be executed.
- NOTE: This also applies to entity's components.
-
-
-
-
- Layer that entity is currently on.
-
-
-
-
- Scene that entity is currently on.
-
-
-
-
- Component dictionary.
-
-
-
-
- Updates at a fixed rate, if entity is enabled.
-
-
-
-
- Updates every frame, if entity is enabled.
-
-
-
-
- Draw updates. Triggers only if entity is visible.
-
- NOTE: DO NOT put any significant logic into Draw.
- It may skip frames.
-
-
-
-
- Triggers right before destruction, if entity is enabled.
-
-
-
-
- Adds component to the entity.
-
-
-
-
- Returns component of given class.
-
-
-
-
- Returns component of given class.
-
-
-
-
- Retrieves component of given class, if it exists, and returns true. If it doesn't, returns false.
-
-
-
-
- Retrieves component of given class, if it exists, and returns true. If it doesn't, returns false.
-
-
-
-
- Returns all the components. All of them.
-
-
-
-
- Checks if an entity has the component of given type.
-
-
-
-
- Checks if an entity has the component of given type.
-
-
-
-
- Removes component from an entity and returns it.
-
-
-
-
- Removes component from an entity and returns it.
-
-
-
-
- Creates new entity from existing template.
-
-
-
-
- Destroys entity and all of its components.
-
-
-
-
- Methods for working with entities.
-
- NOTE: Methods should return all entities regardless of if they are enabled.
-
-
-
-
- Returns list of entities of certain type.
-
-
-
-
- Counts amount of entities of certain type.
-
-
-
-
- Checks if any instances of an entity exist.
-
-
-
-
- Finds first entity of given type.
-
-
-
- Due to ECS, there may be lots of objects with same type,
- but different component sets. They differ only by their tag.
- This is, why we need tag overloads.
-
- Returns list of entities with given tag.
-
-
-
-
- Counts amount of entities with given tag.
-
-
-
-
- Checks if given instance exists.
-
-
-
-
- Finds first entit with given tag.
-
-
-
-
- Returns list of entities, which have component - enabled or disabled - of given type.
-
-
-
-
- Counts amount of entities, which have component - enabled or disabled - of given type.
-
-
-
-
- Finds first entity, which has component - enabled or disabled - of given type.
-
-
-
-
- Returns list of components - enabled and disabled - of given type.
-
-
-
-
- Manages ECS systems.
-
-
-
-
- List of currently active systems.
-
-
-
-
- Updates at a fixed rate.
-
-
-
-
- Updates every frame.
-
-
-
-
- Draw updates.
-
- NOTE: DO NOT put any significant logic into Draw.
- It may skip frames.
-
-
-
-
- Creates an instance of each ISystem implementing class.
-
-
-
-
- Basic animation class. Can be used for sprite animation,
- UI animation, movement, and many more.
-
-
-
-
- Linear animation progress. Always goes up from 0 to 1.
- Not affected by easing and inversion.
-
-
-
-
- LinearProgress affected by easing and inversion.
-
-
-
-
- Animation speed.
-
-
-
-
- If true, animation will be looped and properly time-corrected.
-
-
-
-
- Tells if the animation is running.
-
-
-
-
- Current easing function, which is applied to animation.
- If null, animation will be linear.
-
-
-
-
- Current TimeKeeper. Can affect animation speed.
-
-
-
-
- If true, Progress will go from 1 to 0 insteasd of 0 to 1.
-
-
-
-
- Gets called, when animation ends or loops.
- Use this for more fine control over the animation.
-
-
-
-
- Updates the animation. Not the part of entity loop,
- you need to call it on your own.
-
- NOTE: If using in Draw method, keep in mind that each camera calls the event separately.
- You may want to restrict it only to the first camera.
-
-
-
-
- Starts the animation and resets LinearProgress to 0.
-
-
-
-
- Starts the animation, overrides Looping and resets LinearProgress to 0.
-
-
-
-
- Stops the animation and resets LinearProgress to 0.
-
-
-
-
- Resumes the animation from its current progress.
-
-
-
-
- Resumes the animation from its current progress and overrides Looping.
-
-
-
-
- Stops the animation without resetting current progress.
-
-
-
-
- Safe sorted dictionary. Makes possible to safely remove from and add items to the list during enumeration.
-
- NOTE: Sorting algorhitm is very basic and must be used only for small amounts (1-5) of new elements.
- DO NOT use this class for frequently updated collections with lots of elements.
- It also does not resort whole list every update, so be careful with changing item's sorting parameter on the fly.
- Good idea will be to re-add item back to the list.
-
-
-
-
- Safe list. Makes possible to safely remove from and add items to the list during enumeration.
-
-
-
-
- Clears out all items from the list.
-
-
-
-
- Removes old elements from the list and adds new ones.
-
-
-
-
- Safe sorted list. Makes possible to safely remove from and add items to the list during enumeration.
-
- NOTE: Sorting algorhitm is very basic and must be used only for small amounts (1-5) of new elements.
- DO NOT use this class for frequently updated collections with lots of elements.
- It also does not resort whole list every update, so be careful with changing item's sorting parameter on the fly.
- Good idea will be to re-add item back to the list.
-
-
-
-
- Clears out all items from the list.
-
-
-
-
- Removes old elements from the list and adds new ones.
-
-
-
-
- A set of cool whooshies for transition effects.
- Easings accept linear value from 0 to 1 and return smoothed out version.
- Can be used as static functions or instantiated.
-
- Port of this code: https://github.com/nicolausYes/easing-functions
-
- Help on easings and visualization: https://easings.net/en
-
-
-
-
- Current easing function.
-
-
-
-
- This constructor is used to create easings. You can create your own!
-
-
-
-
- Returns easing value for t.
- NOTE: t should be in range from 0 to 1.
-
-
-
-
- Returns easing value for t.
- NOTE: t should be in range from 0 to 1.
-
-
-
-
- I'm a sneaky foxe.
-
- Sneaked into your game.
-
- Stole your entities.
-
- Slept on your bad architechture.
-
-
-
-
- Basic tilemap class. Provides basic functionality,
- supports camera zooming.
-
-
-
-
- Tells how many tile rows and columns will be drawn outside of camera's bounds.
- May be useful for tiles larger than the grid.
-
-
-
-
- Returns tile without out-of-bounds check.
- WARNING: This method will throw an exception, if coordinates are out of bounds.
-
-
-
-
- Sets tile without out-of-bounds check.
- WARNING: This method will throw an exception, if coordinates are out of bounds.
-
-
-
-
- Tells if given coordinates are in bounds.
-
-
-
-
- System for basic tilemap. Based on Monofoxe.ECS.
- Draws tilemaps in camera's bounds.
-
-
-
-
- Tile interface.
-
-
-
-
- Tells, if given coodrinates are in tilemap's bounds.
-
-
-
-
- Returns tileset tile according to tile index,
- or null, if index is out of tileset's bounds.
-
-
-
-
- Counts down seconds. Needs to be updated manually.
-
-
-
-
- Tells how much time is left in seconds.
-
-
-
-
- Gets called in an update, if alarm is triggered.
-
-
-
-
- Tells, if alarm is running right now.
-
-
-
-
- Sets alarm to given time.
-
- Time in seconds.
-
-
-
- Resets alarm.
-
-
-
-
- Updates alarm. Returns true, if alarm is being triggered.
-
-
-
-
- Counts down seconds. Needs to be updated manually. Sets itself automatically after triggering.
-
-
-
-
- Updates alarm. Returns true, if alarm is being triggered.
-
-
-
-
- Contains useful math stuff.
-
-
-
-
- Calculates distance between two points.
-
-
-
-
- Calculates direction between two points in degrees.
-
-
-
-
- Calculates direction between two points in radians.
-
-
-
-
- Converts direction measured in degrees to unit Vector2.
-
-
-
-
- Converts direction measured in radians to unit Vector2.
-
-
-
-
- Calculates difference between two angles from -180 to 180;
-
-
-
-
- Calculates difference between two angles in radians from -pi to pi;
-
-
-
-
- Checks if a point lies within a rectangle.
-
-
-
-
- Checks if a point lies within a rectangle.
-
-
-
-
- Checks if a point lies within a triangle.
-
-
-
-
- Checks if two rectangles intersect.
-
-
-
-
- Checks if two rectangles intersect.
-
-
-
-
- Calculates on which side point is from a line.
- 1 - left
- -1 - right
- 0 - on the line
-
-
-
-
- Checks if two lines cross. Returns 1 if lines cross, 0 if not and 2 if lines overlap.
-
-
-
-
- Checks if two linew cross. Returns 1 if lines cross, 0 if not and 2 if lines overlap.
- Also calculates intersection point.
-
-
-
-
- Extends System.Random.
-
-
-
-
- Creates random generator with system time used as a seed.
-
-
-
-
- Creates random number generator with a specific seed.
-
-
-
-
- Returns a random number in range [0, Int32.MaxValue).
-
-
-
-
- Returns a random number in range [0, maxValue).
-
-
-
-
- Returns a random number in range [minValue, maxValue).
-
-
-
-
- Returns a random number in range [0.0, 1.0).
-
-
-
-
- Returns a random number in range [0.0, maxValue).
-
-
-
-
- Returns a random number in range [minValue, maxValue).
-
-
-
-
- Fills the elements of a specified array of bytes with random numbers.
-
-
-
-
- Returns a random element out of given arguments.
-
-
-
-
- Returns list of numbers from minValue to maxValue in random order.
-
-
-
-
- Stack-based state machine.
-
-
-
-
- All the available states. Excuted on each update.
-
-
-
-
- State enter events. Executed when machine enters a certain event.
-
-
-
-
- State exit events. Executed when machine exits a certain event.
-
-
-
-
- Stack of active states.
-
-
-
-
- Current state machine state.
-
-
-
-
- Previous state machine state.
-
-
-
-
- State machine owner.
-
-
-
-
- Updates state machine and executes current state method.
-
-
-
-
- Empties state stack, but keeps current state.
-
-
-
-
- Empties state stack and sets state to a new one without calling exit or enter events.
-
-
-
-
- Adds new state to a state machine.
-
-
-
-
- Removes existing state from a state machine.
-
-
-
-
- Pushes new state to a state machine.
-
- NOTE: State should already exist in the machine.
-
-
-
-
- Pops current active state from a machine.
-
-
-
-
- Replaces current state with a new state. Basically, pop and push together.
-
-
-
-
- Calls exit event for a state.
-
-
-
-
- Calls enter event for a state.
-
-
-
-
- Calculates elapsed time based on multiplier.
- Should be used for fps adjusting and slowing down\speeding up time.
-
-
-
-
- If more than one, time will speed up.
- If less than one, time will slow down.
-
-
-
-
- If more than one, time will speed up.
- If less than one, time will slow down.
-
-
-
-
- Returns elapsed time, multiplied by global time multiplier.
-
-
-
-
- Returns elapsed time, multiplied by global time multiplier.
-
- Use this for constant speeds.
-
-
-
-
- Returns elapsed time, multiplied by global time multiplier
- and time-corrected for acceleration.
-
- Use this for accelerating values.
-
-
-
-
- Returns elapsed time, multiplied by global time multiplier.
-
-
-
-
- Returns elapsed time, multiplied by global time multiplier
- and time-corrected for acceleration.
-
- Use this for accelerating values.
-
-
-
-
- Returns elapsed time, multiplied by global time multiplier.
-
- Use this for constant speeds.
-
-
-
-
- Returns elapsed time, multiplied by global time multiplier
- and time-corrected for acceleration.
-
- Use this for accelerating values.
-
-
-
-
- Returns elapsed time, multiplied by both
- global time multiplier and local time multiplier.
-
-
-
-
- Returns elapsed time, multiplied by both
- global time multiplier and local time multiplier.
-
-
-
-
- Returns elapsed time, multiplied by global time multiplier
- and time-corrected for acceleration.
-
- Use this for accelerating values.
-
-
-
-
- Returns elapsed time, multiplied by both
- global time multiplier and local time multiplier.
-
-
-
-
- Returns elapsed time, multiplied by global time multiplier,
- local time multiplier and time-corrected for acceleration.
-
- Use this for accelerating values.
-
-
-
-
- Returns elapsed time, multiplied by both
- global time multiplier and local time multiplier.
-
- Use this for constant speeds.
-
-
-
-
- Returns elapsed time, multiplied by global time multiplier,
- local time multiplier and time-corrected for acceleration.
-
- Use this for accelerating values.
-
-
-
-
- Counts seconds. Has to be updated manually.
-
-
-
-
- Tells how much time has passed in seconds.
-
-
-
-
- Timer won't update if it's disabled.
-
-
-
-
- Resets timer.
-
-
-
-
- Updates timer.
-
-
-
-
- Main Game class.
-
-
-
-
- Window manager. Can be used for screen and window stuff.
-
-
-
-
- Time in seconds, elapsed since game start.
-
-
-
-
- Time in seconds, elapsed since previous frame.
-
-
-
-
- After this point game will slow down instead of skipping frames.
-
-
-
-
- All game's assemblies, including ones from libraries.
-
-
-
-
- All of game's types.
-
-
-
-
- Performs update-related routines and calls Update events for entities and systems.
-
-
-
-
- Performs drawing-related routines and calls Draw events for entities and systems.
-
-
-
-
- Closes the game.
-
-
-
-
- Loads all assemblies and extracts types form them.
-
-
-
-
- Loads all referenced assemblies of an assembly.
-
-
-
-
- Cursor position on screen.
-
-
-
-
- Cursor position in the world. Depends on current camera.
-
-
-
-
- Scrollwheel value. Can be -1, 0 or 1.
-
-
-
-
- Stores all chars typed in previous step.
-
-
-
-
- Stores last pressed key in current step. If no keys were pressed, resets to Keys.None.
-
-
-
-
- Stores last pressed key. Doesn't reset.
-
-
-
-
- Stores last typed char. Doesn't reset.
-
-
-
-
- If pressure value is below deadzone, GamepadCheck() won't detect trigger press.
-
-
-
-
- Type of stick deadzone.
-
-
-
-
- Amount of gamepads which are proccessed by input.
- If you don't want to use gamepad input, set value to 0.
-
-
-
-
- Checks if mouse, keyboard or gamepad button is down.
-
- Button to check.
- Device index. Used for gamepad only.
-
-
-
- Checks if mouse, keyboard or gamepad button is pressed.
-
- Button to check.
- Device index. Used for gamepad only.
-
-
-
- Checks if mouse, keyboard or gamepad button is released.
-
- Button to check.
- Device index. Used for gamepad only.
-
-
-
- Clears mouse input.
-
-
-
-
- Checks if any keyboard key in down in current step.
-
-
-
-
- Checks if any keyboard key in pressed.
-
-
-
-
- Checks if any keyboard key in released.
-
-
-
-
- Clears keyboard input.
-
-
-
-
- Text input event. Occurs when any key is pressed.
- Works asynchroniously.
- Assigned to Window.TextInput of Game1 class.
-
-
-
-
- Checks if gamepad with given inex is connected.
-
-
-
-
- Returns vector of left thumb stick.
-
-
-
-
- Returns vector of right thumb stick.
-
-
-
-
- Returns value of pressure on left trigger.
- NOTE: If you don't need exact pressure value, use GamepadCheck* functions.
-
-
-
-
- Returns value of pressure on right trigger.
- NOTE: If you don't need exact pressure value, use GamepadCheck* functions.
-
-
-
-
- Sets vibration to the given gamepad.
-
-
-
-
- Clears gamepad input, including triggers and thumb sticks.
-
-
-
-
- Clears mouse, keyboard and gamepad input.
-
-
-
-
- A layer is a container for entities and components.
-
-
-
-
- Layer's parent scene.
-
-
-
-
- Layer's name. Used for searching.
- NOTE: All layers should have unique names!
-
-
-
-
- If false, layer won't be rendered.
-
-
-
-
- If true, layer won't be updated.
-
-
-
-
- Priority of a layer. Layers with highest priority are processed first.
-
-
-
-
- If true, entities and components will be sorted by their depth.
-
-
-
-
- If true, draws everything directly to the backbuffer instead of cameras.
-
-
-
-
- List of all layer's entities.
-
-
-
-
- All components, which belong to all entities on the layer.
-
-
-
-
- Disabled components.
-
-
-
-
- Shaders applied to the layer.
- NOTE: You should enable postprocessing in camera.
- NOTE: Shaders won't be applied, if layer is GUI.
-
-
-
-
- Sorts entites and components by depth, if depth sorting is enabled.
-
-
-
-
- Applies shaders to the camera surface.
-
-
-
-
- Returns list of entities of certain type.
-
-
-
-
- Counts amount of objects of certain type.
-
-
-
-
- Checks if any instances of an entity exist.
-
-
-
-
- Finds first entity of given type.
-
-
-
-
- Returns list of entities with given tag.
-
-
-
-
- Counts amount of entities with given tag.
-
-
-
-
- Checks if given instance exists.
-
-
-
-
- Finds first entity with given tag.
-
-
-
-
- Returns list of entities, which have component - enabled or disabled - of given type.
-
-
-
-
- Counts amount of entities, which have component - enabled or disabled - of given type.
-
-
-
-
- Finds first entity, which has component of given type.
-
-
-
-
- Returns list of all components on the layer - enabled and disabled - of given type.
-
-
-
-
- Container for layers.
-
-
-
-
- List of all scene's layers.
-
-
-
-
- If false, scene won't be rendered.
-
-
-
-
- If true, scene won't be updated.
-
-
-
-
- Priority of a scene. Scenes with highest priority are processed first.
-
-
-
-
- Creates new layer with given name.
-
-
-
-
- Destroys given layer.
-
-
-
-
- Destroys layer with given name.
-
-
-
-
- Returns layer with given name.
-
-
-
-
- Finds layer with given name. Returns true, if layer was found.
-
-
-
-
- Returns true, if there is a layer with given name.
-
-
-
-
- Returns list of objects of certain type.
-
-
-
-
- Counts amount of objects of certain type.
-
-
-
-
- Checks if any instances of an entity exist.
-
-
-
-
- Finds first entity of given type.
-
-
-
-
- Returns list of entities with given tag.
-
-
-
-
- Counts amount of entities with given tag.
-
-
-
-
- Checks if given instance exists.
-
-
-
-
- Finds first entity with given tag.
-
-
-
-
- Returns list of entities on a scene, which have component of given type.
-
-
-
-
- Counts amount of entities on a scene, which have component of given type.
-
-
-
-
- Finds first entity on a scene, which has component of given type.
-
-
-
-
- Returns list of all components on the scene - enabled and disabled - of given type.
-
-
-
-
- Manager of all scenes. Updates entities and components.
-
-
-
-
- List of all scenes.
-
-
-
-
- Current active scene.
-
-
-
-
- Current active layer.
-
-
-
-
- Counts time until next fixed update.
-
-
-
-
- Creates new scene with given name.
-
-
-
-
- Destroys given scene.
-
-
-
-
- Destroys scene with given name.
-
-
-
-
- Returns scene with given name.
-
-
-
-
- Finds scene with given name. Returns true, if scene was found.
-
-
-
-
- Returns true, if there is a scene with given name.
-
-
-
-
- Routine needed before updating entities.
-
-
-
-
- Routine needed after updating entities.
-
-
-
-
- Executes Fixed Update events.
-
-
-
-
- Executes Update events.
-
-
-
-
- Executes Draw events.
-
-
-
-
- Executes Draw GUI events.
-
-
-
-
- Extends basic C# number types.
-
-
-
-
- Returns true, if number is not zero.
-
-
-
-
- Returns true, if number is not zero.
-
-
-
-
- Returns true, if number is not zero.
-
-
-
-
- Returns true, if number is not zero.
-
-
-
-
- Returns true, if number is not zero.
-
-
-
-
- Returns true, if number is not zero.
-
-
-
-
- Returns true, if number is not zero.
-
-
-
-
- Returns true, if number is not zero.
-
-
-
-
- Returns true, if number is not zero.
-
-
-
-
- Returns true, if number is not zero.
-
-
-
-
- Returns true, if number is not zero.
-
-
-
-
- If true, returns one, otherwise - zero.
-
-
-
-
- Vector2 extensions.
-
-
-
-
- Rounds each vector's component.
-
-
-
-
- Rounds each vector's component down.
-
-
-
-
- Rounds each vector's component up.
-
-
-
-
- Returns vector with the same direction and length of 1.
- If original vector is (0;0), returns zero vector.
-
-
-
-
- Converts Vector2 to Vector3 with z axis of 0.
-
-
-
-
- Swaps X and Y places.
-
-
-
-
- Rotates vector by 90 degrees.
-
-
-
-
- Merging of GraphicsDeviveManager and WindowManager.
-
-
-
-
- Width of the screen.
-
-
-
-
- Height of the screen.
-
-
-
-
- Size of the screen.
-
-
-
-
- Window width.
-
-
-
-
- Window height.
-
-
-
-
- Tells how canvas will be drawn on the backbuffer.
-
-
-
-
- Window size.
-
-
-
-
- Window position.
-
-
-
-
- Title of the window.
-
-
-
-
- Allowing borders in window.
-
-
-
-
- Game window class.
- Most of its features are handled through WindowManager,
- but if you want something specific, use this.
-
-
-
-
- Centers game window on the screen.
-
-
-
-
- Game camera. Support positioning, rotating and scaling.
- NOTE: There always should be at least one camera,
- otherwise Draw events won't be triggered.
-
-
-
-
- Priority of a camera.
- Higher priority = earlier drawing.
-
-
-
-
- View coordinates.
- NOTE: They don't take into account offset and rotation.
-
-
-
-
- View size.
-
-
-
-
- Camera offset.
-
-
-
-
- View rotation. Measured in degrees.
-
-
-
-
- View zoom.
-
-
-
-
- Viewport coordinates. Sets where on screen view will be drawn.
-
-
-
-
- Viewport coordinates. Sets where on screen view will be drawn.
-
-
-
-
- Viewport scale.
-
-
-
-
- Viewport rotation.
- NOTE: Changing it will break mouse position!
-
-
-
-
- Camera surface. Everything will be drawn on it.
- NOTE: This reference can change to another surface!
-
-
-
-
- Background color for a view surface.
-
-
-
-
- If true, camera surface will be drawn automatically.
-
-
-
-
- If false, camera won't trigger any Draw events.
-
-
-
-
- If true, clears camera surface every step.
-
-
-
-
- Transformation matrix.
-
-
-
-
- Mode for filtering out certain layers.
-
-
-
-
- Shaders applied to the surface.
- NOTE: Last shader will be applied directly during drawing of the surface.
- If you draw it yourself, don't forget to apply last shader.
-
-
-
-
- Enables usage of shaders on camera surface and layers.
- NOTE: Additional surfaces will be created.
-
-
-
-
- Resizes the view.
-
-
-
-
- Removes camera from draw controller list and disposes surface.
-
-
-
-
- Updates camera's transform matrix.
-
-
-
-
- Returns mouse position relative to the camera.
-
-
-
-
- Returns true, if given layer is filtered out.
-
-
-
-
- Applies shaders to the camera surface.
-
-
-
-
- Manages camera priorities.
-
-
-
-
- List of all cameras.
-
-
-
-
- Removes camera from list and adds it again, taking in account its proirity.
-
-
-
-
- filtering modes for camera.
-
-
-
-
- Triggers rendering, if filter DOES contain layer.
-
-
-
-
- Triggers rendering, if filter DOES NOT contain layer.
-
-
-
-
- Renders all layers.
-
-
-
-
- Postprocessing modes for camera.
-
-
-
-
- No shaders will be applied.
-
-
-
-
- Enables applying shaders to the camera surface.
-
-
-
-
- Enables applying shaders to the camera surface
- AND individual layers.
-
-
-
-
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Windows/References/Monofoxe.Tiled.xml b/Monofoxe.Playground/Monofoxe.Playground.Windows/References/Monofoxe.Tiled.xml
deleted file mode 100644
index ebf02903..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground.Windows/References/Monofoxe.Tiled.xml
+++ /dev/null
@@ -1,195 +0,0 @@
-
-
-
- Monofoxe.Tiled
-
-
-
-
- Reads sprite group file.
-
-
-
-
- Factory interface for entities.
- Use it to convert Tiled object structs to actual entities.
-
-
-
-
- Identifying tag.
-
- NOTE: All factory tags should be unique!
-
-
-
-
- Creates entity from Tiled Object on a given layer.
-
-
-
-
- Basic map builder class. Creates a map from Tiled data structures.
- Can be extended.
-
-
-
-
- Builds map scene from Tiled map template.
-
- Building goes in four stages:
- - Building tilesets.
- - Building tile layers.
- - Building object layers.
- - Building image layers.
-
- Each of those stages can be overriden.
- Override this method if you want full control over the map loading.
-
-
-
-
- Unloads map scene.
-
-
-
-
- An array which tells which index corresponds to which tileset.
-
-
-
-
- Builds tilesets from Tiled templates.
- Called by Build().
-
-
-
-
- Creates tile lookup table to optimize tile matching for tilemaps.
-
-
-
-
- Builds tile layers from Tiled templates.
- Called by Build().
-
-
-
-
- Builds object layers from Tiled templates.
- Called by Build().
-
-
-
-
- Builds image layers from Tiled templates.
- Called by Build().
-
-
-
-
- Returns Tiled layer priority, which is stored in its properties.
- If no such property was found, returns 0.
-
-
-
-
- Stores an instance of each class which implements ITiledEntityFactory.
-
-
-
-
- Pool of all factories in all assemblies. Sorted by their tags.
-
-
-
-
- Creates pool of all factories.
-
-
-
-
- Makes entity from Tiled temmplate using factory pool.
-
-
-
-
- Tile flip flags are stored in the tile value itself as 3 highest bits.
- 100 - Horizontal flip.
- 010 - Vertical flip.
- 001 - Diagonal flip.
-
-
-
-
- Base tiled object.
-
-
-
-
- Used internally by Reader and Writer.
-
-
-
-
- TIled map tiles orientaion.
-
-
-
-
- Data structure for Tiled map.
-
-
-
-
- Tiled will treat this color as transparent.
- Ah, blast right from 1998.
-
-
-
-
- Diagonal flip is weird diagonal axis filp, which enables rotation.
-
- Graphical:
- 0 0 ' 0 0 0 0 ' 0 0
- 0 ' ' 0 0 ==> 0 ' 0 0 '
- ' 0 ' 0 0 ==> ' ' ' ' '
- 0 0 ' 0 0 ==> 0 0 0 0 '
- 0 ' ' ' 0 0 0 0 0 0
-
- Vertices:
- 0 1 => 0 2
- 2 3 => 1 3
-
- (90 deg rotation) + (-1 xscale)
-
-
-
-
- Spacing between tiles in tileset.
- Doesn't work with image collection tilesets.
-
-
-
-
- Padding of the first tile row\column.
-
-
-
-
- Amount of columns in tileset.
- Will be 0 in image collection tileset.
-
-
-
-
- Component for Tiled image layers.
-
-
-
-
- System for Tiled image layers. Just draws all images from components.
-
-
-
-
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Windows/app.config b/Monofoxe.Playground/Monofoxe.Playground.Windows/app.config
deleted file mode 100644
index 3dbff35f..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground.Windows/app.config
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/Content/Content.mgcb b/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/Content/Content.mgcb
new file mode 100644
index 00000000..6f845342
--- /dev/null
+++ b/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/Content/Content.mgcb
@@ -0,0 +1,60 @@
+
+#----------------------------- Global Properties ----------------------------#
+
+/outputDir:../../Monofoxe.Playground.Content/Content/bin/$(Platform)
+/intermediateDir:../../Monofoxe.Playground.Content/Content/obj/$(Platform)
+/platform:Windows
+/config:
+/profile:Reach
+/compress:True
+
+#-------------------------------- References --------------------------------#
+
+/reference:../../Monofoxe.Playground.Content/bin/Monofoxe.Pipeline.dll
+
+#---------------------------------- Content ---------------------------------#
+
+#begin ../../Monofoxe.Playground.Content/Content/Effects/Grayscale.fx
+/importer:EffectImporter
+/processor:EffectProcessor
+/build:../../Monofoxe.Playground.Content/Content/Effects/Grayscale.fx;Effects/Grayscale.fx
+
+#begin ../../Monofoxe.Playground.Content/Content/Effects/Seizure.fx
+/importer:EffectImporter
+/processor:EffectProcessor
+/build:../../Monofoxe.Playground.Content/Content/Effects/Seizure.fx;Effects/Seizure.fx
+
+#begin ../../Monofoxe.Playground.Content/Content/Fonts/Arial.spritefont
+/importer:FontDescriptionImporter
+/processor:FontDescriptionProcessor
+/build:../../Monofoxe.Playground.Content/Content/Fonts/Arial.spritefont;Fonts/Arial.spritefont
+
+#begin ../../Monofoxe.Playground.Content/Content/Graphics/Default.spritegroup
+/importer:SpriteGroupImporter
+/processor:SpriteGroupProcessor
+/build:../../Monofoxe.Playground.Content/Content/Graphics/Default.spritegroup;Graphics/Default.spritegroup
+
+#begin ../../Monofoxe.Playground.Content/Content/Maps/Test.tmx
+/importer:TiledMapImporter
+/processor:PassThroughProcessor
+/build:../../Monofoxe.Playground.Content/Content/Maps/Test.tmx;Maps/Test.tmx
+
+#begin Content.npl
+/importer:ResourceInfoImporter
+/processor:PassThroughProcessor
+/build:Content.npl
+
+#begin ../../Monofoxe.Playground.Content/Content/Maps/Tilesets/grass.png
+/importer:TextureImporter
+/processor:TextureProcessor
+/build:../../Monofoxe.Playground.Content/Content/Maps/Tilesets/grass.png;Maps/Tilesets/grass.png
+
+#begin ../../Monofoxe.Playground.Content/Content/Maps/Templates/TemplatesTileset/bot.png
+/importer:TextureImporter
+/processor:TextureProcessor
+/build:../../Monofoxe.Playground.Content/Content/Maps/Templates/TemplatesTileset/bot.png;Maps/Templates/TemplatesTileset/bot.png
+
+#begin ../../Monofoxe.Playground.Content/Content/Maps/Templates/TemplatesTileset/player.png
+/importer:TextureImporter
+/processor:TextureProcessor
+/build:../../Monofoxe.Playground.Content/Content/Maps/Templates/TemplatesTileset/player.png;Maps/Templates/TemplatesTileset/player.png
\ No newline at end of file
diff --git a/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/Content/Content.npl b/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/Content/Content.npl
new file mode 100644
index 00000000..000b5469
--- /dev/null
+++ b/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/Content/Content.npl
@@ -0,0 +1,88 @@
+{
+ "root": "../../Monofoxe.Playground.Content/Content/",
+ "references":
+ [
+ "../../Monofoxe.Playground.Content/bin/Monofoxe.Pipeline.dll"
+ ],
+ "content":
+ {
+ "contentList":
+ {
+ "path": "$Content.npl",
+ "recursive": "False",
+ "action": "build",
+ "importer": "ResourceInfoImporter",
+ "processor": "PassThroughProcessor",
+ "watch":
+ [
+ "../../Monofoxe.Playground.Content/Content/*"
+ ]
+ },
+ "music":
+ {
+ "path": "Audio/Music/*.ogg",
+ "recursive": "True",
+ "action": "copy"
+ },
+ "sounds":
+ {
+ "path": "Audio/Sounds/*.wav",
+ "recursive": "True",
+ "action": "copy"
+ },
+ "defaultSpriteGroup":
+ {
+ "path": "Graphics/*.spritegroup",
+ "recursive": "True",
+ "action": "build",
+ "importer": "SpriteGroupImporter",
+ "processor": "SpriteGroupProcessor",
+ "watch":
+ [
+ "Default/*.png",
+ "Default/*.json"
+ ]
+ },
+ "effects":
+ {
+ "path": "Effects/*.fx",
+ "recursive": "True",
+ "action": "build",
+ "importer": "EffectImporter",
+ "processor": "EffectProcessor"
+ },
+ "tiledMaps":
+ {
+ "path": "Maps/*.tmx",
+ "recursive": "True",
+ "action": "build",
+ "importer": "TiledMapImporter",
+ "processor": "PassThroughProcessor",
+ "watch":
+ [
+ "Tilesets/*.tsx",
+ "Tilesets/*.png",
+ "Templates/*.tsx",
+ "Templates/*.tx",
+ "Templates/*.png"
+ ]
+ },
+ "tiledMapTextures":
+ {
+ "path": "Maps/*.png",
+ "recursive": "True",
+ "action": "build",
+ "importer": "TextureImporter",
+ "processor": "TextureProcessor"
+ },
+ "fonts":
+ {
+ "path": "Fonts/*.spritefont",
+ "recursive": "True",
+ "action": "build",
+ "importer": "FontDescriptionImporter",
+ "processor": "FontDescriptionProcessor"
+ }
+
+ }
+}
diff --git a/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/Icon.ico b/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/Icon.ico
new file mode 100644
index 00000000..86aab077
Binary files /dev/null and b/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/Icon.ico differ
diff --git a/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/Monofoxe.Playground.WindowsDX.csproj b/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/Monofoxe.Playground.WindowsDX.csproj
new file mode 100644
index 00000000..1305f707
--- /dev/null
+++ b/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/Monofoxe.Playground.WindowsDX.csproj
@@ -0,0 +1,29 @@
+
+
+ WinExe
+ netcoreapp3.1
+ false
+ false
+ true
+
+
+ app.manifest
+ Icon.ico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/Program.cs b/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/Program.cs
new file mode 100644
index 00000000..30750c39
--- /dev/null
+++ b/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/Program.cs
@@ -0,0 +1,19 @@
+using System;
+using Monofoxe.Engine.WindowsDX;
+
+namespace Monofoxe.Playground.WindowsDX
+{
+ public static class Program
+ {
+ [STAThread]
+ static void Main()
+ {
+ MonofoxePlatform.Init();
+
+ using (var game = new Game1())
+ {
+ game.Run();
+ }
+ }
+ }
+}
diff --git a/Monofoxe.Playground/Monofoxe.Playground.Windows/app.manifest b/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/app.manifest
similarity index 92%
rename from Monofoxe.Playground/Monofoxe.Playground.Windows/app.manifest
rename to Monofoxe.Playground/Monofoxe.Playground.WindowsDX/app.manifest
index 62f63eb7..4417dada 100644
--- a/Monofoxe.Playground/Monofoxe.Playground.Windows/app.manifest
+++ b/Monofoxe.Playground/Monofoxe.Playground.WindowsDX/app.manifest
@@ -36,6 +36,7 @@
true/pm
+ permonitorv2,permonitor
diff --git a/Monofoxe.Playground/Monofoxe.Playground.sln b/Monofoxe.Playground/Monofoxe.Playground.sln
index 13b88aff..a9c47bc8 100644
--- a/Monofoxe.Playground/Monofoxe.Playground.sln
+++ b/Monofoxe.Playground/Monofoxe.Playground.sln
@@ -3,18 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29609.76
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Monofoxe.Playground", "Monofoxe.Playground\Monofoxe.Playground.shproj", "{A0CDBD0E-3A41-42B7-9425-A838BC2C7383}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monofoxe.Playground.DesktopGL", "Monofoxe.Playground.DesktopGL\Monofoxe.Playground.DesktopGL.csproj", "{058E861C-4B60-4410-A73B-4BCA5DC70EC2}"
- ProjectSection(ProjectDependencies) = postProject
- {D59079B2-CC07-4783-9C7F-05E78EBBC5FD} = {D59079B2-CC07-4783-9C7F-05E78EBBC5FD}
- EndProjectSection
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monofoxe.Playground.Windows", "Monofoxe.Playground.Windows\Monofoxe.Playground.Windows.csproj", "{5431EE33-D78F-4263-A4AE-61852A61386D}"
- ProjectSection(ProjectDependencies) = postProject
- {D59079B2-CC07-4783-9C7F-05E78EBBC5FD} = {D59079B2-CC07-4783-9C7F-05E78EBBC5FD}
- EndProjectSection
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monofoxe.Engine", "..\Monofoxe\Monofoxe.Engine\Monofoxe.Engine.csproj", "{9A75ED71-2FDF-47E2-B9E9-1918ECA10BC8}"
ProjectSection(ProjectDependencies) = postProject
{D59079B2-CC07-4783-9C7F-05E78EBBC5FD} = {D59079B2-CC07-4783-9C7F-05E78EBBC5FD}
@@ -25,7 +13,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monofoxe.Tiled", "..\Monofo
{D59079B2-CC07-4783-9C7F-05E78EBBC5FD} = {D59079B2-CC07-4783-9C7F-05E78EBBC5FD}
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pipefoxe", "..\Monofoxe\Pipefoxe\Pipefoxe.csproj", "{D59079B2-CC07-4783-9C7F-05E78EBBC5FD}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monofoxe.Pipeline", "..\Monofoxe\Monofoxe.Pipeline\Monofoxe.Pipeline.csproj", "{D59079B2-CC07-4783-9C7F-05E78EBBC5FD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Monofoxe", "Monofoxe", "{43BF570E-E7D7-45B5-8B04-E9C82D7C99A6}"
EndProject
@@ -34,12 +22,30 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\.editorconfig = ..\.editorconfig
EndProjectSection
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monofoxe.Playground.WindowsDX", "Monofoxe.Playground.WindowsDX\Monofoxe.Playground.WindowsDX.csproj", "{F0224987-E449-4253-BD1D-DC4DE0068AA2}"
+ ProjectSection(ProjectDependencies) = postProject
+ {ED8FE838-FAB5-4B39-A468-CF58B8126051} = {ED8FE838-FAB5-4B39-A468-CF58B8126051}
+ EndProjectSection
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monofoxe.Playground.DesktopGL", "Monofoxe.Playground.DesktopGL\Monofoxe.Playground.DesktopGL.csproj", "{80B93F45-097B-40D4-B44B-4EF981682372}"
+ ProjectSection(ProjectDependencies) = postProject
+ {ED8FE838-FAB5-4B39-A468-CF58B8126051} = {ED8FE838-FAB5-4B39-A468-CF58B8126051}
+ EndProjectSection
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monofoxe.Playground", "Monofoxe.Playground\Monofoxe.Playground.csproj", "{7A68CF7A-0D82-4B37-AC83-F543243F9287}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monofoxe.Playground.Content", "Monofoxe.Playground.Content\Monofoxe.Playground.Content.csproj", "{ED8FE838-FAB5-4B39-A468-CF58B8126051}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monofoxe.Engine.WindowsDX", "..\Monofoxe\Monofoxe.Engine.WindowsDX\Monofoxe.Engine.WindowsDX.csproj", "{40709027-342B-4157-A065-4FBD6F9523CA}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monofoxe.Engine.DesktopGL", "..\Monofoxe\Monofoxe.Engine.DesktopGL\Monofoxe.Engine.DesktopGL.csproj", "{B6E5E2A4-1368-4ECE-A6C0-C20865987165}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Platforms", "Platforms", "{8C31A55A-1F5B-4191-ADD1-6282EFE75EA8}"
+EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
- Monofoxe.Playground\Monofoxe.Playground.projitems*{058e861c-4b60-4410-a73b-4bca5dc70ec2}*SharedItemsImports = 4
- Monofoxe.Playground\Monofoxe.Playground.projitems*{5431ee33-d78f-4263-a4ae-61852a61386d}*SharedItemsImports = 4
- Monofoxe.Playground\Monofoxe.Playground.projitems*{a0cdbd0e-3a41-42b7-9425-a838bc2c7383}*SharedItemsImports = 13
- ..\Monofoxe\Monofoxe.Tiled.MapStructure\Monofoxe.Tiled.MapStructure.projitems*{d59079b2-cc07-4783-9c7f-05e78ebbc5fd}*SharedItemsImports = 4
+ ..\Monofoxe\Monofoxe.Tiled.MapStructure\Monofoxe.Tiled.MapStructure.projitems*{21e56073-5e48-4346-9800-872264f5abb5}*SharedItemsImports = 5
+ ..\Monofoxe\Monofoxe.Tiled.MapStructure\Monofoxe.Tiled.MapStructure.projitems*{d59079b2-cc07-4783-9c7f-05e78ebbc5fd}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -48,20 +54,6 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {058E861C-4B60-4410-A73B-4BCA5DC70EC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {058E861C-4B60-4410-A73B-4BCA5DC70EC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {058E861C-4B60-4410-A73B-4BCA5DC70EC2}.Debug|x86.ActiveCfg = Debug|Any CPU
- {058E861C-4B60-4410-A73B-4BCA5DC70EC2}.Debug|x86.Build.0 = Debug|Any CPU
- {058E861C-4B60-4410-A73B-4BCA5DC70EC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {058E861C-4B60-4410-A73B-4BCA5DC70EC2}.Release|Any CPU.Build.0 = Release|Any CPU
- {058E861C-4B60-4410-A73B-4BCA5DC70EC2}.Release|x86.ActiveCfg = Release|Any CPU
- {058E861C-4B60-4410-A73B-4BCA5DC70EC2}.Release|x86.Build.0 = Release|Any CPU
- {5431EE33-D78F-4263-A4AE-61852A61386D}.Debug|Any CPU.ActiveCfg = Debug|x86
- {5431EE33-D78F-4263-A4AE-61852A61386D}.Debug|x86.ActiveCfg = Debug|x86
- {5431EE33-D78F-4263-A4AE-61852A61386D}.Debug|x86.Build.0 = Debug|x86
- {5431EE33-D78F-4263-A4AE-61852A61386D}.Release|Any CPU.ActiveCfg = Release|x86
- {5431EE33-D78F-4263-A4AE-61852A61386D}.Release|x86.ActiveCfg = Release|x86
- {5431EE33-D78F-4263-A4AE-61852A61386D}.Release|x86.Build.0 = Release|x86
{9A75ED71-2FDF-47E2-B9E9-1918ECA10BC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A75ED71-2FDF-47E2-B9E9-1918ECA10BC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A75ED71-2FDF-47E2-B9E9-1918ECA10BC8}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -86,6 +78,54 @@ Global
{D59079B2-CC07-4783-9C7F-05E78EBBC5FD}.Release|Any CPU.Build.0 = Release|Any CPU
{D59079B2-CC07-4783-9C7F-05E78EBBC5FD}.Release|x86.ActiveCfg = Release|Any CPU
{D59079B2-CC07-4783-9C7F-05E78EBBC5FD}.Release|x86.Build.0 = Release|Any CPU
+ {F0224987-E449-4253-BD1D-DC4DE0068AA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F0224987-E449-4253-BD1D-DC4DE0068AA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F0224987-E449-4253-BD1D-DC4DE0068AA2}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {F0224987-E449-4253-BD1D-DC4DE0068AA2}.Debug|x86.Build.0 = Debug|Any CPU
+ {F0224987-E449-4253-BD1D-DC4DE0068AA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F0224987-E449-4253-BD1D-DC4DE0068AA2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F0224987-E449-4253-BD1D-DC4DE0068AA2}.Release|x86.ActiveCfg = Release|Any CPU
+ {F0224987-E449-4253-BD1D-DC4DE0068AA2}.Release|x86.Build.0 = Release|Any CPU
+ {80B93F45-097B-40D4-B44B-4EF981682372}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {80B93F45-097B-40D4-B44B-4EF981682372}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {80B93F45-097B-40D4-B44B-4EF981682372}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {80B93F45-097B-40D4-B44B-4EF981682372}.Debug|x86.Build.0 = Debug|Any CPU
+ {80B93F45-097B-40D4-B44B-4EF981682372}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {80B93F45-097B-40D4-B44B-4EF981682372}.Release|Any CPU.Build.0 = Release|Any CPU
+ {80B93F45-097B-40D4-B44B-4EF981682372}.Release|x86.ActiveCfg = Release|Any CPU
+ {80B93F45-097B-40D4-B44B-4EF981682372}.Release|x86.Build.0 = Release|Any CPU
+ {7A68CF7A-0D82-4B37-AC83-F543243F9287}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7A68CF7A-0D82-4B37-AC83-F543243F9287}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7A68CF7A-0D82-4B37-AC83-F543243F9287}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {7A68CF7A-0D82-4B37-AC83-F543243F9287}.Debug|x86.Build.0 = Debug|Any CPU
+ {7A68CF7A-0D82-4B37-AC83-F543243F9287}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7A68CF7A-0D82-4B37-AC83-F543243F9287}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7A68CF7A-0D82-4B37-AC83-F543243F9287}.Release|x86.ActiveCfg = Release|Any CPU
+ {7A68CF7A-0D82-4B37-AC83-F543243F9287}.Release|x86.Build.0 = Release|Any CPU
+ {ED8FE838-FAB5-4B39-A468-CF58B8126051}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {ED8FE838-FAB5-4B39-A468-CF58B8126051}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {ED8FE838-FAB5-4B39-A468-CF58B8126051}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {ED8FE838-FAB5-4B39-A468-CF58B8126051}.Debug|x86.Build.0 = Debug|Any CPU
+ {ED8FE838-FAB5-4B39-A468-CF58B8126051}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {ED8FE838-FAB5-4B39-A468-CF58B8126051}.Release|Any CPU.Build.0 = Release|Any CPU
+ {ED8FE838-FAB5-4B39-A468-CF58B8126051}.Release|x86.ActiveCfg = Release|Any CPU
+ {ED8FE838-FAB5-4B39-A468-CF58B8126051}.Release|x86.Build.0 = Release|Any CPU
+ {40709027-342B-4157-A065-4FBD6F9523CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {40709027-342B-4157-A065-4FBD6F9523CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {40709027-342B-4157-A065-4FBD6F9523CA}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {40709027-342B-4157-A065-4FBD6F9523CA}.Debug|x86.Build.0 = Debug|Any CPU
+ {40709027-342B-4157-A065-4FBD6F9523CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {40709027-342B-4157-A065-4FBD6F9523CA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {40709027-342B-4157-A065-4FBD6F9523CA}.Release|x86.ActiveCfg = Release|Any CPU
+ {40709027-342B-4157-A065-4FBD6F9523CA}.Release|x86.Build.0 = Release|Any CPU
+ {B6E5E2A4-1368-4ECE-A6C0-C20865987165}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B6E5E2A4-1368-4ECE-A6C0-C20865987165}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B6E5E2A4-1368-4ECE-A6C0-C20865987165}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {B6E5E2A4-1368-4ECE-A6C0-C20865987165}.Debug|x86.Build.0 = Debug|Any CPU
+ {B6E5E2A4-1368-4ECE-A6C0-C20865987165}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B6E5E2A4-1368-4ECE-A6C0-C20865987165}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B6E5E2A4-1368-4ECE-A6C0-C20865987165}.Release|x86.ActiveCfg = Release|Any CPU
+ {B6E5E2A4-1368-4ECE-A6C0-C20865987165}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -94,6 +134,9 @@ Global
{9A75ED71-2FDF-47E2-B9E9-1918ECA10BC8} = {43BF570E-E7D7-45B5-8B04-E9C82D7C99A6}
{21E56073-5E48-4346-9800-872264F5ABB5} = {43BF570E-E7D7-45B5-8B04-E9C82D7C99A6}
{D59079B2-CC07-4783-9C7F-05E78EBBC5FD} = {43BF570E-E7D7-45B5-8B04-E9C82D7C99A6}
+ {40709027-342B-4157-A065-4FBD6F9523CA} = {8C31A55A-1F5B-4191-ADD1-6282EFE75EA8}
+ {B6E5E2A4-1368-4ECE-A6C0-C20865987165} = {8C31A55A-1F5B-4191-ADD1-6282EFE75EA8}
+ {8C31A55A-1F5B-4191-ADD1-6282EFE75EA8} = {43BF570E-E7D7-45B5-8B04-E9C82D7C99A6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8F30E949-9CC7-45C9-894B-D8A613FD77BC}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Content.mgcb b/Monofoxe.Playground/Monofoxe.Playground/Content/Content.mgcb
deleted file mode 100644
index c36f6d76..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground/Content/Content.mgcb
+++ /dev/null
@@ -1,56 +0,0 @@
-
-#----------------------------- Global Properties ----------------------------#
-
-/outputDir:bin/$(Platform)
-/intermediateDir:obj/$(Platform)
-/config:
-/profile:Reach
-/compress:False
-
-#-------------------------------- References --------------------------------#
-
-/reference:../../../Monofoxe/bin/Pipeline/Debug/Pipefoxe.dll
-
-#---------------------------------- Content ---------------------------------#
-
-#begin Content.mgcb
-/importer:AssetInfoImporter
-/processor:PassThroughProcessor
-/build:Content.mgcb
-
-#begin Effects/AlphaBlend.fx
-/importer:EffectImporter
-/processor:EffectProcessor
-/build:Effects/AlphaBlend.fx
-
-#begin Fonts/Arial.spritefont
-/importer:FontDescriptionImporter
-/processor:FontDescriptionProcessor
-/build:Fonts/Arial.spritefont
-
-#begin Graphics/Default.spritegroup
-/importer:SpriteGroupImporter
-/processor:SpriteGroupProcessor
-/build:Graphics/Default.spritegroup
-
-#begin Effects/Grayscale.fx
-/importer:EffectImporter
-/processor:EffectProcessor
-/build:Effects/Grayscale.fx
-
-#begin Effects/Seizure.fx
-/importer:EffectImporter
-/processor:EffectProcessor
-/build:Effects/Seizure.fx
-
-#begin Maps/test.tmx
-/importer:TiledMapImporter
-/processor:TiledMapProcessor
-/build:Maps/test.tmx
-
-#begin Graphics/default.spritegroup
-/importer:SpriteGroupImporter
-/processor:SpriteGroupProcessor
-/build:Graphics/default.spritegroup
-
-
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Effects/AlphaBlend.fx b/Monofoxe.Playground/Monofoxe.Playground/Content/Effects/AlphaBlend.fx
deleted file mode 100644
index 21bdd529..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground/Content/Effects/AlphaBlend.fx
+++ /dev/null
@@ -1,102 +0,0 @@
-
-/*
-Base shader for drawing everything, when there are no other shaders applied.
-It's used by VertexBatch to apply proper transform matrix.
-
-NOTE: This shader is vital part of the engine.
-DO NOT modify it, unless you know, what you're doing and have good reasons to!
-*/
-
-float4x4 World;
-float4x4 View;
-float4x4 Projection;
-
-const sampler BaseSampler : register(s0);
-
-struct VertexShaderInput
-{
- float4 Position : POSITION0;
- float2 TexCoords : TEXCOORD0;
- float4 Color : COLOR0;
-};
-
-struct VertexShaderOutput
-{
- float4 Position : POSITION0;
- float2 TexCoords : TEXCOORD0;
- float4 Color : COLOR0;
-};
-
-
-VertexShaderOutput VS_Texture(VertexShaderInput input)
-{
- VertexShaderOutput output;
-
- float4 worldPosition = mul(input.Position, World);
- float4 viewPosition = mul(worldPosition, View);
- output.Position = mul(viewPosition, Projection);
- output.TexCoords = input.TexCoords;
- output.Color = input.Color;
-
- return output;
-}
-
-
-/*
-Premultiplying shader. Used for sufraces, regular sprites, textured primitives and texture fonts.
-*/
-float4 PS_TexturePremultiplied(VertexShaderOutput input) : COLOR0
-{
- float4 color = tex2D(BaseSampler, input.TexCoords.xy);
- return float4(color.r * input.Color.r, color.g * input.Color.g, color.b * input.Color.b, input.Color.a) * color.a;
-}
-
-/*
-Non-premultiplying shader.
-*/
-float4 PS_TextureNonPremultiplied(VertexShaderOutput input) : COLOR0
-{
- float4 color = tex2D(BaseSampler, input.TexCoords.xy);
- return color * input.Color;
-}
-
-/*
-Basic shader for primitives without texture.
-*/
-float4 PS_Basic(VertexShaderOutput input) : COLOR0
-{
- return input.Color;
-}
-
-/*
-Techniques are chosen by the engine automatically.
-*/
-
-#ifdef SM4
-
-#define TECHNIQUE(name, vsName, psName) \
- technique name \
- { \
- pass Pass1 \
- { \
- VertexShader = compile vs_4_0_level_9_1 vsName(); \
- PixelShader = compile ps_4_0_level_9_1 psName(); \
- } \
- }
-#else
-
-#define TECHNIQUE(name, vsName, psName) \
- technique name \
- { \
- pass Pass1 \
- { \
- VertexShader = compile vs_3_0 vsName(); \
- PixelShader = compile ps_3_0 psName(); \
- } \
- }
-#endif
-
-
-TECHNIQUE(Basic, VS_Texture, PS_Basic);
-TECHNIQUE(TexturePremultiplied, VS_Texture, PS_TexturePremultiplied);
-TECHNIQUE(TextureNonPremultiplied, VS_Texture, PS_TextureNonPremultiplied);
\ No newline at end of file
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/bot.json b/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/bot.json
deleted file mode 100644
index 0ced53d3..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/bot.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "v": 1,
- "h": 1,
- "offset_x": "center",
- "offset_y": "bottom",
-}
\ No newline at end of file
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/fire.json b/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/fire.json
deleted file mode 100644
index 9525ff66..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/fire.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "v": 1,
- "h": 17,
- "offset_x": "center",
- "offset_y": "bottom",
-}
\ No newline at end of file
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/font.json b/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/font.json
deleted file mode 100644
index f449ff86..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/font.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "v": 5,
- "h": 20,
- "offset_x": 0,
- "offset_y": 0,
-}
\ No newline at end of file
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/monofoxe.json b/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/monofoxe.json
deleted file mode 100644
index 977b44da..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/monofoxe.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- v: 1,
- h: 1,
- offset_x: "center",
- offset_y: "center",
-}
\ No newline at end of file
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/player.json b/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/player.json
deleted file mode 100644
index 0ced53d3..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Default/player.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "v": 1,
- "h": 1,
- "offset_x": "center",
- "offset_y": "bottom",
-}
\ No newline at end of file
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Template.cstemplate b/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Template.cstemplate
deleted file mode 100644
index c3722f56..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/Template.cstemplate
+++ /dev/null
@@ -1,55 +0,0 @@
-#class_prefix = public static Sprite ;
-#class_constructor = AddResource("", sprites[]);
-
-// Template tags:
-// - Name of output class.
-// - Name of current group.
-// - Name of each sprite.
-// - Hash name of each sprite.
-
-
-using Microsoft.Xna.Framework.Content;
-using Monofoxe.Engine;
-using Monofoxe.Engine.Drawing;
-using System.Collections.Generic;
-using Monofoxe.Engine.Resources;
-
-// NOTE: This class is automatically generated by
-// Monofoxe. See .cstemplate file.
-
-namespace Resources.Sprites
-{
- public class : ResourceBox
- {
- public override string Name => "Sprites";
-
- private ContentManager _content = new ContentManager(GameMgr.Game.Services);
-
- public override void Load()
- {
- if (Loaded)
- {
- return;
- }
- Loaded = true;
- var graphicsPath = AssetMgr.ContentDir + '/' + AssetMgr.GraphicsDir + "/";
- var sprites = _content.Load>(graphicsPath);
-
- #region Sprite constructors.
-
-
-
- #endregion Sprite constructors.
- }
-
- public override void Unload()
- {
- if (!Loaded)
- {
- return;
- }
- Loaded = false;
- _content.Unload();
- }
- }
-}
\ No newline at end of file
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/default.spritegroup b/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/default.spritegroup
deleted file mode 100644
index a75251a4..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground/Content/Graphics/default.spritegroup
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "atlasSize": 512,
- "texturePadding": 1,
- "rootDir": "/Default",
- "classTemplatePath": "/../Template.cstemplate", // Relative to rootDir.
- "classOutputDir": "/../Resources/Sprites/", // Relative to content project file.
- "singleTexturesWildcards":
- [
- "/Textures/*"
- ],
-
- "debugMode": "false"
-}
\ No newline at end of file
diff --git a/Monofoxe.Playground/Monofoxe.Playground/ECDemo/Bot.cs b/Monofoxe.Playground/Monofoxe.Playground/ECDemo/Bot.cs
new file mode 100644
index 00000000..470aab2d
--- /dev/null
+++ b/Monofoxe.Playground/Monofoxe.Playground/ECDemo/Bot.cs
@@ -0,0 +1,39 @@
+using Microsoft.Xna.Framework;
+using Monofoxe.Engine.Drawing;
+using Monofoxe.Engine.EC;
+using Monofoxe.Engine.Resources;
+using Monofoxe.Engine.SceneSystem;
+using Monofoxe.Engine.Utils;
+
+namespace Monofoxe.Playground.ECDemo
+{
+ ///
+ /// Basic position component.
+ ///
+ public class Bot : Entity
+ {
+ public float TurningSpeed = 60;
+
+ private readonly ActorComponent _actor;
+
+ public Bot(Layer layer) : base(layer)
+ {
+ var botSprite = ResourceHub.GetResource("DefaultSprites", "Bot");
+
+ AddComponent(new PositionComponent(Vector2.Zero));
+ _actor = AddComponent(new ActorComponent(botSprite));
+
+ // It is recommended to reuse random objects.
+ TurningSpeed = ECDemoFactory.Random.Next(120, 240);
+
+ }
+
+
+ public override void Update()
+ {
+ base.Update();
+ _actor.Move = true;
+ _actor.Direction += TimeKeeper.Global.Time(TurningSpeed); // ni-ni-ni-ni-ni-ni-ni-ni-ni-ni-ni-ni-ni-ni
+ }
+ }
+}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/ECDemo/BotComponent.cs b/Monofoxe.Playground/Monofoxe.Playground/ECDemo/BotComponent.cs
deleted file mode 100644
index 60dafdac..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground/ECDemo/BotComponent.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using Monofoxe.Engine.EC;
-using Monofoxe.Engine.Utils;
-
-namespace Monofoxe.Playground.ECDemo
-{
- ///
- /// Basic position component.
- ///
- public class BotComponent : Component
- {
- public float TurningSpeed = 60;
-
- public BotComponent()
- {
-
- }
-
- public override void Initialize()
- {
- }
-
- public override void FixedUpdate()
- {
- }
-
- public override void Update()
- {
- var actor = Owner.GetComponent();
- actor.Move = true;
- actor.Direction += TimeKeeper.Global.Time(TurningSpeed); // ni-ni-ni-ni-ni-ni-ni-ni-ni-ni-ni-ni-ni-ni
- }
-
- public override void Draw()
- {
- }
-
-
- public override void Destroy()
- {
- }
- }
-}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/ECDemo/BotTemplate.cs b/Monofoxe.Playground/Monofoxe.Playground/ECDemo/BotTemplate.cs
deleted file mode 100644
index dbdcdf0a..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground/ECDemo/BotTemplate.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using Microsoft.Xna.Framework;
-using Monofoxe.Engine.Drawing;
-using Monofoxe.Engine.EC;
-using Monofoxe.Engine.Resources;
-using Monofoxe.Engine.SceneSystem;
-
-namespace Monofoxe.Playground.ECDemo
-{
- public class BotTemplate : IEntityTemplate
- {
- public string Tag => "Bot";
-
- Sprite _botSprite;
-
- public Entity Make(Layer layer)
- {
- // Bot is a pure EC entity. This means, that it uses
- // non-derived Entity class with no logic in it.
- // But that poses a problem - where to assemble the entity?
- // For this purpose, entity templates exist.
- // You can assemble your entity here and then create it using
- // Entity.CreateFromTemplate(layer, "Bot");
- //
- // Though, entity templates are not required. You can assemble new entities
- // anywhere you like. You can even add new components and remove existing
- // at any time.
-
- _botSprite = ResourceHub.GetResource("DefaultSprites", "Bot");
-
- var entity = new Entity(layer);
-
- entity.AddComponent(new PositionComponent(Vector2.Zero));
- entity.AddComponent(new ActorComponent(_botSprite));
-
- var bot = new BotComponent();
-
- // It is recommended to reuse random objects.
- bot.TurningSpeed = ECDemoFactory.Random.Next(120, 240);
-
- entity.AddComponent(bot);
-
- return entity;
- }
- }
-}
-
diff --git a/Monofoxe.Playground/Monofoxe.Playground/ECDemo/ECDemo.cs b/Monofoxe.Playground/Monofoxe.Playground/ECDemo/ECDemo.cs
index d432b453..2951940b 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/ECDemo/ECDemo.cs
+++ b/Monofoxe.Playground/Monofoxe.Playground/ECDemo/ECDemo.cs
@@ -22,7 +22,7 @@ public override void Update()
if (Input.CheckButtonPress(ToggleVisibilityButton))
{
// This will turn off Draw events for bot's entity and all of its components.
- foreach (Entity bot in Layer.GetEntityListByComponent())
+ foreach (var bot in Layer.GetEntityList())
{
bot.Visible = !bot.Visible;
}
@@ -31,7 +31,7 @@ public override void Update()
if (Input.CheckButtonPress(ToggleEnabledButton))
{
// This will turn off Update events for bot's entity and all of its components.
- foreach(Entity bot in Layer.GetEntityListByComponent())
+ foreach(var bot in Layer.GetEntityList())
{
bot.Enabled = !bot.Enabled;
}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/ECDemo/ECDemoFactory.cs b/Monofoxe.Playground/Monofoxe.Playground/ECDemo/ECDemoFactory.cs
index c86f1c72..e1ee58bf 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/ECDemo/ECDemoFactory.cs
+++ b/Monofoxe.Playground/Monofoxe.Playground/ECDemo/ECDemoFactory.cs
@@ -24,7 +24,7 @@ public override void CreateScene()
for(var i = 0; i < 20; i += 1)
{
- var bot = Entity.CreateFromTemplate(layer, "Bot");
+ var bot = new Bot(layer);
var position = bot.GetComponent();
position.Position = new Vector2(Random.Next(100, 700), Random.Next(100, 500));
}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/ECDemo/Player.cs b/Monofoxe.Playground/Monofoxe.Playground/ECDemo/Player.cs
index 1257c3e0..09c43af1 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/ECDemo/Player.cs
+++ b/Monofoxe.Playground/Monofoxe.Playground/ECDemo/Player.cs
@@ -14,21 +14,24 @@ public class Player : Entity
public const Buttons LeftButton = Buttons.A;
public const Buttons RightButton = Buttons.D;
- Sprite _playerSprite;
+ private Sprite _playerSprite;
// The player uses hybrid EC - it's a derived entity with components inside.
// You also can ditch components entirely and only use entities.
- // I recommend useng hybrid entities in places, where EC is not entirely needed.
- // For example, if you know that this entity's code will not be reused anywhere else.
+ // I recommend using hybrid entities in places,
+ // where you know that this entity's code will not be reused anywhere else.
+
+ private ActorComponent _actor;
+ private PositionComponent _position;
public Player(Layer layer, Vector2 position) : base(layer)
{
_playerSprite = ResourceHub.GetResource("DefaultSprites", "Player");
// You can add components right in the constructor.
- AddComponent(new PositionComponent(position));
- AddComponent(new ActorComponent(_playerSprite));
+ _position = AddComponent(new PositionComponent(position));
+ _actor = AddComponent(new ActorComponent(_playerSprite));
}
public override void FixedUpdate()
@@ -46,24 +49,22 @@ public override void Update()
Input.CheckButton(DownButton).ToInt() - Input.CheckButton(UpButton).ToInt()
);
- // Telling our actor component to move in a specific direction.
- var actor = GetComponent();
- actor.Move = movement != Vector2.Zero;
- actor.Direction = movement.ToAngle();
+ // Telling our actor component to move in a specific direction.
+ _actor.Move = movement != Vector2.Zero;
+ _actor.Direction = movement.ToAngle();
}
public override void Draw()
{
base.Draw();
- var position = GetComponent();
// Layers and scenes have methods for searching entities/components.
- foreach(BotComponent bot in Layer.GetComponentList())
+ foreach(var bot in Layer.GetEntityList())
{
- var botPosition = bot.Owner.GetComponent();
+ var botPosition = bot.GetComponent();
- LineShape.Draw(position.Position, botPosition.Position, Color.Transparent, Color.White * 0.2f);
+ LineShape.Draw(_position.Position, botPosition.Position, Color.Transparent, Color.White * 0.2f);
}
}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Game1.cs b/Monofoxe.Playground/Monofoxe.Playground/Game1.cs
index ff1f3d29..fa2792ed 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/Game1.cs
+++ b/Monofoxe.Playground/Monofoxe.Playground/Game1.cs
@@ -2,9 +2,11 @@
using Monofoxe.Engine;
using Monofoxe.Tiled;
using Monofoxe.Engine.Drawing;
-using Resources;
using Monofoxe.Engine.Resources;
using Microsoft.Xna.Framework.Graphics;
+using Monofoxe.Tiled.MapStructure;
+using Monofoxe.Resources;
+using Monofoxe.Playground.Resources;
namespace Monofoxe.Playground
{
@@ -15,14 +17,13 @@ public class Game1 : Game
{
public Game1()
{
- Content.RootDirectory = AssetMgr.ContentDir;
+ Content.RootDirectory = ResourceInfoMgr.ContentDir;
GameMgr.Init(this);
-#if !ANDROID
- Window.TextInput += Input.TextInput;
-#else
- GameMgr.WindowManager.SetFullScreen(true); // Has to be exactly here, apparently.
-#endif
+ if (GameMgr.CurrentPlatform == Platform.Android)
+ {
+ GameMgr.WindowManager.SetFullScreen(true); // Has to be exactly here, apparently.
+ }
}
///
@@ -54,12 +55,14 @@ protected override void LoadContent()
{
GraphicsMgr.Init(GraphicsDevice);
- new Resources.Sprites.Default();
+ new SpriteGroupResourceBox("DefaultSprites", "Graphics/Default");
+ new DirectoryResourceBox("Effects", "Effects");
+ new DirectoryResourceBox("Maps", "Maps");
+
new Fonts();
- new Maps();
- new Effects();
}
+
///
/// UnloadContent will be called once per game and is the place to unload
/// game-specific content.
@@ -77,7 +80,7 @@ protected override void UnloadContent()
protected override void Update(GameTime gameTime)
{
GameMgr.Update(gameTime);
-
+
base.Update(gameTime);
}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/GameController.cs b/Monofoxe.Playground/Monofoxe.Playground/GameController.cs
index beea8454..177c3b9c 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/GameController.cs
+++ b/Monofoxe.Playground/Monofoxe.Playground/GameController.cs
@@ -1,13 +1,12 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Monofoxe.Engine;
+using Monofoxe.Engine.Cameras;
using Monofoxe.Engine.Drawing;
using Monofoxe.Engine.EC;
using Monofoxe.Engine.SceneSystem;
-using Monofoxe.Engine.Cameras;
-using Resources.Sprites;
using Monofoxe.Playground.Interface;
-using Monofoxe.Engine.Resources;
+using System.Diagnostics;
namespace Monofoxe.Playground
{
@@ -20,6 +19,8 @@ public class GameController : Entity
public static RasterizerState DefaultRasterizer;
public static RasterizerState WireframeRasterizer;
+ private Stopwatch _stopwatch = new Stopwatch();
+
public GameController() : base(SceneMgr.GetScene("default")["default"])
{
GameMgr.MaxGameSpeed = 60;
@@ -35,7 +36,7 @@ public GameController() : base(SceneMgr.GetScene("default")["default"])
GraphicsMgr.VertexBatch.SamplerState = SamplerState.PointWrap; // Will make textures repeat without interpolation.
-
+
DefaultRasterizer = new RasterizerState();
DefaultRasterizer.CullMode = CullMode.CullCounterClockwiseFace;
DefaultRasterizer.FillMode = FillMode.Solid;
@@ -47,10 +48,10 @@ public GameController() : base(SceneMgr.GetScene("default")["default"])
WireframeRasterizer.MultiSampleAntiAlias = false;
GraphicsMgr.VertexBatch.RasterizerState = DefaultRasterizer;
-
+
_guiLayer = Scene.CreateLayer("gui");
_guiLayer.IsGUI = true;
-
+
var cameraController = new CameraController(_guiLayer, MainCamera);
@@ -60,18 +61,29 @@ public GameController() : base(SceneMgr.GetScene("default")["default"])
// Enabling applying postprocessing effects to separate layers.
// Note that this will create an additional surface.
MainCamera.PostprocessingMode = PostprocessingMode.CameraAndLayers;
+
+ SceneMgr.OnPreDraw += OnPreDraw; // You can do the same for individual layers or scenes.
+ SceneMgr.OnPostDraw += OnPostDraw;
}
- public override void Update()
+
+ private void OnPreDraw() =>
+ _stopwatch.Start();
+
+ private void OnPostDraw()
{
- base.Update();
+ _stopwatch.Stop();
+ GameMgr.WindowManager.WindowTitle = "Rendering time: " + _stopwatch.Elapsed;
+ _stopwatch.Reset();
}
- public override void Draw()
+ public override void Destroy()
{
- base.Draw();
- }
+ base.Destroy();
+ SceneMgr.OnPreDraw -= OnPreDraw;
+ SceneMgr.OnPostDraw -= OnPostDraw;
+ }
}
-}
\ No newline at end of file
+}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/GraphicsDemo/ShapeDemo.cs b/Monofoxe.Playground/Monofoxe.Playground/GraphicsDemo/ShapeDemo.cs
index 0efc62fa..0461767a 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/GraphicsDemo/ShapeDemo.cs
+++ b/Monofoxe.Playground/Monofoxe.Playground/GraphicsDemo/ShapeDemo.cs
@@ -1,7 +1,10 @@
using Microsoft.Xna.Framework;
+using Monofoxe.Engine;
using Monofoxe.Engine.Drawing;
using Monofoxe.Engine.EC;
using Monofoxe.Engine.SceneSystem;
+using Monofoxe.Engine.Utils;
+using System.Diagnostics;
namespace Monofoxe.Playground.GraphicsDemo
{
@@ -9,8 +12,7 @@ public class ShapeDemo : Entity
{
Color _mainColor = Color.White;
- Color _secondaryColor = Color.Violet;
-
+ HsvColor _secondaryColor = new HsvColor(new Color(34, 65, 250));
TriangleShape _triangle;
public ShapeDemo(Layer layer) : base(layer)
@@ -27,6 +29,13 @@ public override void Draw()
{
base.Draw();
+ _secondaryColor.H += TimeKeeper.Global.Time(360 / 4f);
+ if (_secondaryColor.H >= 360f)
+ {
+ _secondaryColor.H -= 360;
+ }
+ Debug.WriteLine(_secondaryColor.H);
+
// This code shows how to draw shapes using static methods and instanced objects.
var startingPosition = new Vector2(100, 100);
@@ -37,7 +46,7 @@ public override void Draw()
GraphicsMgr.CurrentColor = _mainColor; // Setting current color. It's active for all shapes and sprites.
CircleShape.Draw(position, 24, false); // Filled circle.
- GraphicsMgr.CurrentColor = _secondaryColor;
+ GraphicsMgr.CurrentColor = _secondaryColor.ToColor();
CircleShape.Draw(position, 32, true); // Outline.
@@ -49,7 +58,7 @@ public override void Draw()
GraphicsMgr.CurrentColor = _mainColor;
CircleShape.Draw(position, 24, false);
- GraphicsMgr.CurrentColor = _secondaryColor;
+ GraphicsMgr.CurrentColor = _secondaryColor.ToColor();
CircleShape.Draw(position, 32, true);
CircleShape.CircleVerticesCount = 32;
@@ -78,7 +87,7 @@ public override void Draw()
_mainColor,
_mainColor,
_mainColor,
- _secondaryColor
+ _secondaryColor.ToColor()
);
RectangleShape.DrawBySize(
@@ -86,7 +95,7 @@ public override void Draw()
Vector2.One * 64,
true,
_mainColor,
- _secondaryColor,
+ _secondaryColor.ToColor(),
_mainColor,
_mainColor
);
diff --git a/Monofoxe.Playground/Monofoxe.Playground/GraphicsDemo/SpriteDemo.cs b/Monofoxe.Playground/Monofoxe.Playground/GraphicsDemo/SpriteDemo.cs
index 4b053201..1a103cb7 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/GraphicsDemo/SpriteDemo.cs
+++ b/Monofoxe.Playground/Monofoxe.Playground/GraphicsDemo/SpriteDemo.cs
@@ -1,19 +1,16 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Monofoxe.Engine.EC;
-using Monofoxe.Engine.Drawing;
-using Monofoxe.Engine.Utils;
-using Monofoxe.Engine;
-using Monofoxe.Engine.SceneSystem;
-using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
-using Resources.Sprites;
+using Monofoxe.Engine;
+using Monofoxe.Engine.Drawing;
+using Monofoxe.Engine.EC;
using Monofoxe.Engine.Resources;
+using Monofoxe.Engine.SceneSystem;
+using Monofoxe.Engine.Utils;
+using System;
namespace Monofoxe.Playground.GraphicsDemo
{
- public class SpriteDemo : Entity
+ public class SpriteDemo : Entity
{
Color _mainColor = Color.White;
@@ -33,7 +30,7 @@ public class SpriteDemo : Entity
public SpriteDemo(Layer layer) : base(layer)
{
- _monofoxeSprite = ResourceHub.GetResource("DefaultSprites", "Monofoxe");
+ _monofoxeSprite = ResourceHub.GetResource("DefaultSprites", "Test");
_fireSprite = ResourceHub.GetResource("DefaultSprites", "Fire");
_batch = new SpriteBatch(GraphicsMgr.Device);
diff --git a/Monofoxe.Playground/Monofoxe.Playground/InputDemo/InputDemo.cs b/Monofoxe.Playground/Monofoxe.Playground/InputDemo/InputDemo.cs
index 85212830..cd4cc649 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/InputDemo/InputDemo.cs
+++ b/Monofoxe.Playground/Monofoxe.Playground/InputDemo/InputDemo.cs
@@ -1,20 +1,15 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Monofoxe.Engine.EC;
-using Monofoxe.Engine.Drawing;
-using Monofoxe.Engine.Utils;
+using Microsoft.Xna.Framework;
using Monofoxe.Engine;
+using Monofoxe.Engine.Drawing;
+using Monofoxe.Engine.EC;
+using Monofoxe.Engine.Resources;
using Monofoxe.Engine.SceneSystem;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-using Resources.Sprites;
+using System.Text;
using System.Text.RegularExpressions;
-using Monofoxe.Engine.Resources;
namespace Monofoxe.Playground.InputDemo
{
- public class InputDemo : Entity
+ public class InputDemo : Entity
{
Color _mainColor = Color.White;
@@ -81,10 +76,6 @@ public override void Draw()
GraphicsMgr.CurrentColor = _mainColor;
- // This position accounts for current camera transform matrix.
- // Visually it will be at the pointer's position when camera will move.
- CircleShape.Draw(Input.MousePosition, 4, false);
-
// This position only accounts for screen transformation.
// When the camera will move, it will offset.
CircleShape.Draw(Input.ScreenMousePosition, 8, true);
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Interface/SceneSwitcher.cs b/Monofoxe.Playground/Monofoxe.Playground/Interface/SceneSwitcher.cs
index 79e1b4ef..9908f93f 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/Interface/SceneSwitcher.cs
+++ b/Monofoxe.Playground/Monofoxe.Playground/Interface/SceneSwitcher.cs
@@ -20,7 +20,6 @@ public class SceneSwitcher : Entity
{
public List Factories = new List
{
- new VertexBatchTestFactory(),
new ShapeDemoFactory(),
new PrimitiveDemoFactory(),
new SpriteDemoFactory(),
@@ -29,6 +28,7 @@ public class SceneSwitcher : Entity
new SceneSystemDemoFactory(),
new UtilsDemoFactory(),
new TiledDemoFactory(),
+ new VertexBatchTestFactory(),
};
public int CurrentSceneID {get; private set;} = 0;
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Monofoxe.Playground.csproj b/Monofoxe.Playground/Monofoxe.Playground/Monofoxe.Playground.csproj
new file mode 100644
index 00000000..9c4575dd
--- /dev/null
+++ b/Monofoxe.Playground/Monofoxe.Playground/Monofoxe.Playground.csproj
@@ -0,0 +1,15 @@
+
+
+
+ netstandard2.0
+
+
+
+ All
+
+
+
+
+
+
+
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Monofoxe.Playground.projitems b/Monofoxe.Playground/Monofoxe.Playground/Monofoxe.Playground.projitems
deleted file mode 100644
index 6c2e7cfe..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground/Monofoxe.Playground.projitems
+++ /dev/null
@@ -1,71 +0,0 @@
-
-
-
- $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
- true
- 189e1936-4c52-4fe3-b8f5-e5ecaa0630da
-
-
- Monofoxe.Playground
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Monofoxe.Playground.shproj b/Monofoxe.Playground/Monofoxe.Playground/Monofoxe.Playground.shproj
deleted file mode 100644
index e577cd06..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground/Monofoxe.Playground.shproj
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
- a0cdbd0e-3a41-42b7-9425-a838bc2c7383
-
-
-
-
-
-
-
-
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Resources/Effects.cs b/Monofoxe.Playground/Monofoxe.Playground/Resources/Effects.cs
deleted file mode 100644
index 3f32ef03..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground/Resources/Effects.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using Microsoft.Xna.Framework.Content;
-using Microsoft.Xna.Framework.Graphics;
-using Monofoxe.Engine;
-using Monofoxe.Engine.Resources;
-
-namespace Resources
-{
- public class Effects : ResourceBox
- {
- private static ContentManager _content;
-
- public override string Name => "Effects";
-
- public override void Load()
- {
- if (Loaded)
- {
- return;
- }
- Loaded = true;
- _content = new ContentManager(GameMgr.Game.Services);
- _content.RootDirectory = AssetMgr.ContentDir + '/' + AssetMgr.EffectsDir;
-
- // This is not generated automatically. Sadly, you'll have to add those by hand.
- AddResource("Grayscale", _content.Load("Grayscale"));
- AddResource("Seizure", _content.Load("Seizure"));
- }
-
- public override void Unload()
- {
- if (!Loaded)
- {
- return;
- }
- Loaded = false;
- _content.Unload();
- }
-
- }
-}
\ No newline at end of file
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Resources/Fonts.cs b/Monofoxe.Playground/Monofoxe.Playground/Resources/Fonts.cs
index 391b0030..aba1f34a 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/Resources/Fonts.cs
+++ b/Monofoxe.Playground/Monofoxe.Playground/Resources/Fonts.cs
@@ -4,20 +4,16 @@
using Monofoxe.Engine.Drawing;
using Monofoxe.Engine.Resources;
-namespace Resources
+namespace Monofoxe.Playground.Resources
{
public class Fonts : ResourceBox
{
private ContentManager _content;
- static readonly string Ascii = " !" + '"' + @"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
-
- public override string Name => "Fonts";
-
- public Fonts()
+ public Fonts() : base("Fonts")
{
_content = new ContentManager(GameMgr.Game.Services);
- _content.RootDirectory = AssetMgr.ContentDir + '/' + AssetMgr.FontsDir;
+ _content.RootDirectory = ResourceInfoMgr.ContentDir + "/Fonts";
}
public override void Load()
@@ -32,7 +28,7 @@ public override void Load()
var fontSprite = ResourceHub.GetResource("DefaultSprites", "Font");
- AddResource("FancyFont", new TextureFont(fontSprite, 1, 1, Ascii, false));
+ AddResource("FancyFont", new TextureFont(fontSprite, 1, 1, TextureFont.Ascii, false));
}
public override void Unload()
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Resources/Maps.cs b/Monofoxe.Playground/Monofoxe.Playground/Resources/Maps.cs
deleted file mode 100644
index 9360b3cf..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground/Resources/Maps.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using Microsoft.Xna.Framework.Content;
-using Monofoxe.Engine;
-using Monofoxe.Engine.Resources;
-using Monofoxe.Tiled.MapStructure;
-
-
-namespace Resources
-{
- public class Maps : ResourceBox
- {
- private static ContentManager _content;
-
- public override string Name => "Maps";
-
- public override void Load()
- {
- if (Loaded)
- {
- return;
- }
- Loaded = true;
-
- _content = new ContentManager(GameMgr.Game.Services);
- _content.RootDirectory = AssetMgr.ContentDir + '/' + AssetMgr.MapsDir;
-
- AddResource("Test", _content.Load("test"));
- }
-
- public override void Unload()
- {
- if (!Loaded)
- {
- return;
- }
- _content.Unload();
- }
-
- }
-}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Resources/Sprites/Default.cs b/Monofoxe.Playground/Monofoxe.Playground/Resources/Sprites/Default.cs
deleted file mode 100644
index a0305e5f..00000000
--- a/Monofoxe.Playground/Monofoxe.Playground/Resources/Sprites/Default.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-// Template tags:
-// Default - Name of output class.
-// Default - Name of current group.
-// - Name of each sprite.
-// - Hash name of each sprite.
-
-
-using Microsoft.Xna.Framework.Content;
-using Monofoxe.Engine;
-using Monofoxe.Engine.Drawing;
-using System.Collections.Generic;
-using Monofoxe.Engine.Resources;
-
-// NOTE: This class is automatically generated by
-// Monofoxe. See .cstemplate file.
-
-namespace Resources.Sprites
-{
- public class Default : ResourceBox
- {
- public override string Name => "DefaultSprites";
-
- private ContentManager _content = new ContentManager(GameMgr.Game.Services);
-
- public override void Load()
- {
- if (Loaded)
- {
- return;
- }
- Loaded = true;
- var graphicsPath = AssetMgr.ContentDir + '/' + AssetMgr.GraphicsDir + "/Default";
- var sprites = _content.Load>(graphicsPath);
-
- #region Sprite constructors.
-
- AddResource("Monofoxe", sprites["monofoxe"]);
- AddResource("Fire", sprites["fire"]);
- AddResource("Bot", sprites["bot"]);
- AddResource("Player", sprites["player"]);
- AddResource("Font", sprites["font"]);
- AddResource("AutismCat", sprites["Textures/autism_cat"]);
-
- #endregion Sprite constructors.
- }
-
- public override void Unload()
- {
- if (!Loaded)
- {
- return;
- }
- Loaded = false;
- _content.Unload();
- }
- }
-}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/SceneSystemDemo/SceneSystemDemo.cs b/Monofoxe.Playground/Monofoxe.Playground/SceneSystemDemo/SceneSystemDemo.cs
index a23e2cf0..4d4a7529 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/SceneSystemDemo/SceneSystemDemo.cs
+++ b/Monofoxe.Playground/Monofoxe.Playground/SceneSystemDemo/SceneSystemDemo.cs
@@ -1,17 +1,10 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Monofoxe.Engine.EC;
-using Monofoxe.Engine.Drawing;
-using Monofoxe.Engine.Utils;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
using Monofoxe.Engine;
+using Monofoxe.Engine.EC;
+using Monofoxe.Engine.Resources;
using Monofoxe.Engine.SceneSystem;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-using Resources.Sprites;
-using System.Text.RegularExpressions;
using Monofoxe.Playground.ECDemo;
-using Monofoxe.Engine.Resources;
namespace Monofoxe.Playground.SceneSystemDemo
{
@@ -29,15 +22,15 @@ public SceneSystemDemo(Layer layer) : base(layer)
// Creating new scene.
_testScene = SceneMgr.CreateScene("SceneDemoDummy");
var mainLayer = _testScene.CreateLayer("main");
- var backgroungLayer = _testScene.CreateLayer("background");
+ var backgroundLayer = _testScene.CreateLayer("background");
// Update and Draw events will be executed for this layer first.
// This can be counter-intuitive, but this will put the layer on the back.
// Because it is being drawn first, everything else will be drawn on top of it.
- backgroungLayer.Priority = 999;
+ backgroundLayer.Priority = 999;
// Applying a shader to the thingy.
- backgroungLayer.PostprocessorEffects.Add(ResourceHub.GetResource("Effects", "Seizure"));
+ backgroundLayer.PostprocessorEffects.Add(ResourceHub.GetResource("Effects", "Seizure"));
// See ECDemo to learn how those work.
@@ -46,7 +39,7 @@ public SceneSystemDemo(Layer layer) : base(layer)
// Player will not draw lines to these bots, because they are on a different layer.
for (var i = 0; i < 10; i += 1)
{
- var bot = CreateFromTemplate(backgroungLayer, "Bot");
+ var bot = new Bot(backgroundLayer);
var position = bot.GetComponent();
position.Position = new Vector2(ECDemoFactory.Random.Next(100, 700), ECDemoFactory.Random.Next(100, 500));
}
@@ -54,7 +47,7 @@ public SceneSystemDemo(Layer layer) : base(layer)
// Player will draw lines to these bots, because they are on the same layer.
for (var i = 0; i < 5; i += 1)
{
- var bot = CreateFromTemplate(mainLayer, "Bot");
+ var bot = new Bot(mainLayer);
var position = bot.GetComponent();
position.Position = new Vector2(ECDemoFactory.Random.Next(100, 700), ECDemoFactory.Random.Next(100, 500));
}
@@ -68,7 +61,7 @@ public override void Update()
if (Input.CheckButtonPress(ToggleVisibilityButton))
{
// This will turn off Draw events for bot's entity and all of its components.
- foreach (Entity bot in _testScene["background"].GetEntityListByComponent())
+ foreach (var bot in _testScene["background"].GetEntityList())
{
bot.Visible = !bot.Visible;
}
@@ -77,7 +70,7 @@ public override void Update()
if (Input.CheckButtonPress(ToggleEnabledButton))
{
// This will turn off Update events for bot's entity and all of its components.
- foreach (Entity bot in _testScene["background"].GetEntityListByComponent())
+ foreach (var bot in _testScene["background"].GetEntityList())
{
bot.Enabled = !bot.Enabled;
}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/TiledDemo/Factories/BotFactory.cs b/Monofoxe.Playground/Monofoxe.Playground/TiledDemo/Factories/BotFactory.cs
index 53d88ab5..b61b9d0c 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/TiledDemo/Factories/BotFactory.cs
+++ b/Monofoxe.Playground/Monofoxe.Playground/TiledDemo/Factories/BotFactory.cs
@@ -15,7 +15,7 @@ public Entity Make(TiledObject obj, Layer layer, MapBuilder map)
{
var tile = (TiledTileObject)obj;
- var entity = Entity.CreateFromTemplate(layer, "Bot");
+ var entity = new Bot(layer);
var position = entity.GetComponent();
position.StartingPosition = tile.Position;
position.Position = tile.Position;
diff --git a/Monofoxe.Playground/Monofoxe.Playground/UtilsDemo/UtilsDemo.cs b/Monofoxe.Playground/Monofoxe.Playground/UtilsDemo/UtilsDemo.cs
index 45ee1444..e77af6d3 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/UtilsDemo/UtilsDemo.cs
+++ b/Monofoxe.Playground/Monofoxe.Playground/UtilsDemo/UtilsDemo.cs
@@ -1,17 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Monofoxe.Engine.EC;
-using Monofoxe.Engine.Drawing;
-using Monofoxe.Engine.Utils;
-using Monofoxe.Engine;
-using Monofoxe.Engine.SceneSystem;
-using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
-using Resources.Sprites;
-using System.Text.RegularExpressions;
using Monofoxe.Engine.Cameras;
+using Monofoxe.Engine.Drawing;
+using Monofoxe.Engine.EC;
using Monofoxe.Engine.Resources;
+using Monofoxe.Engine.SceneSystem;
+using Monofoxe.Engine.Utils;
namespace Monofoxe.Playground.UtilsDemo
{
@@ -36,7 +30,7 @@ public class UtilsDemo : Entity
TimeKeeper _slowTimeKeeper;
- AutoAlarm _autoAlarm;
+ Alarm _autoAlarm;
Alarm _slowAlarm;
@@ -89,12 +83,13 @@ public UtilsDemo(Layer layer) : base(layer)
// Slowing down time for this time keeper.
_slowTimeKeeper.TimeMultiplier = 0.5f;
- _autoAlarm = new AutoAlarm(_alarmPeriod);
- _slowAlarm = new Alarm();
+ _autoAlarm = new Alarm(_alarmPeriod, OnTriggerAction.Loop);
+ _autoAlarm.Start();
+ _slowAlarm = new Alarm(_alarmPeriod);
// This alarm will now use custom TimeKeeper, which is 2 times
// slower than global TimeKeeper.
_slowAlarm.TimeKeeper = _slowTimeKeeper;
- _slowAlarm.Set(_alarmPeriod);
+ _slowAlarm.Start();
_slowAlarm.TriggerEvent += AlarmTrigger;
// Alarms.
@@ -145,15 +140,15 @@ public void FireAnimationEnd(Animation animation)
public void AlarmTrigger(Alarm alarm)
{
// This is actually a bad practice.
- // Alarm doesn't take into account leftover time
+ // Alarm in OnTriggerAction.Stop mode doesn't take into account leftover time
// and will reset counter to 0. This will introduce errors,
// which will add up over time. If you need to set Alarm
- // right after it triggers, use AutoAlarm.
+ // right after it triggers, use OnTriggerAction.Loop.
//
- // This demo shows comparison of Alarm and AutoAlarm.
- // You will notice that circles start blinking out of sync
+ // This demo shows comparison of Stop and Loop modes.
+ // You will notice that circles will start blinking out of sync
// over time.
- alarm.Set(_alarmPeriod);
+ alarm.Start();
_slowAlarmSwitch = !_slowAlarmSwitch;
}
@@ -254,12 +249,17 @@ public override void Draw()
_fireSprite.Draw(position, _fireAnimation.Progress, Vector2.Zero, Vector2.One, Angle.Right, Color.White);
+ GraphicsMgr.CurrentColor = Color.SeaGreen;
position += Vector2.UnitX * spacing;
CircleShape.Draw(position, 8, _autoAlarmSwitch);
+
+ GraphicsMgr.CurrentColor = Color.Sienna;
position += Vector2.UnitX * 32;
CircleShape.Draw(position, 8, _slowAlarmSwitch);
+
+ GraphicsMgr.CurrentColor = Color.Thistle;
position += Vector2.UnitX * 32;
CircleShape.Draw(position, 8, _counterSwitch);
diff --git a/Monofoxe/Monofoxe.Engine.DesktopGL/AlphaBlendEffectLoaderDesktopGL.cs b/Monofoxe/Monofoxe.Engine.DesktopGL/AlphaBlendEffectLoaderDesktopGL.cs
new file mode 100644
index 00000000..85981408
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine.DesktopGL/AlphaBlendEffectLoaderDesktopGL.cs
@@ -0,0 +1,12 @@
+using System.Reflection;
+
+namespace Monofoxe.Engine.DesktopGL
+{
+ public class AlphaBlendEffectLoaderDesktopGl: AlphaBlendEffectLoader
+ {
+ protected override string _effectName => "Monofoxe.Engine.DesktopGL.AlphaBlend_gl.mgfxo";
+
+ protected override Assembly _assembly => Assembly.GetAssembly(typeof(AlphaBlendEffectLoaderDesktopGl));
+
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine.DesktopGL/Monofoxe.Engine.DesktopGL.csproj b/Monofoxe/Monofoxe.Engine.DesktopGL/Monofoxe.Engine.DesktopGL.csproj
new file mode 100644
index 00000000..b51ff4f7
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine.DesktopGL/Monofoxe.Engine.DesktopGL.csproj
@@ -0,0 +1,24 @@
+
+
+
+ netstandard2.0
+ false
+ true
+ ..\bin\$(Configuration)\
+ ..\bin\$(Configuration)\$(AssemblyName).xml
+ 1701;1702;1591
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Monofoxe/Monofoxe.Engine.DesktopGL/MonofoxePlatform.cs b/Monofoxe/Monofoxe.Engine.DesktopGL/MonofoxePlatform.cs
new file mode 100644
index 00000000..52c47fb3
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine.DesktopGL/MonofoxePlatform.cs
@@ -0,0 +1,32 @@
+using System;
+
+namespace Monofoxe.Engine.DesktopGL
+{
+ public static class MonofoxePlatform
+ {
+ public static void Init()
+ {
+ if (Environment.OSVersion.Platform == PlatformID.Win32NT)
+ {
+ GameMgr.CurrentPlatform = Platform.Windows;
+ }
+ else if (Environment.OSVersion.Platform == PlatformID.Unix)
+ {
+ GameMgr.CurrentPlatform = Platform.Linux;
+ }
+ else if (Environment.OSVersion.Platform == PlatformID.MacOSX)
+ {
+ GameMgr.CurrentPlatform = Platform.MacOS;
+ }
+ else
+ {
+ GameMgr.CurrentPlatform = Platform.Other;
+ }
+
+ GameMgr.CurrentGraphicsBackend = GraphicsBackend.OpenGL;
+
+ StuffResolver.AddStuffAs(new AlphaBlendEffectLoaderDesktopGl());
+ StuffResolver.AddStuffAs(new TextInputBinderDesktopGL());
+ }
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine.DesktopGL/TextInputBInderDesktopGL.cs b/Monofoxe/Monofoxe.Engine.DesktopGL/TextInputBInderDesktopGL.cs
new file mode 100644
index 00000000..d62ba3ae
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine.DesktopGL/TextInputBInderDesktopGL.cs
@@ -0,0 +1,11 @@
+
+namespace Monofoxe.Engine.DesktopGL
+{
+ public class TextInputBinderDesktopGL : ITextInputBinder
+ {
+ public void Init()
+ {
+ GameMgr.Game.Window.TextInput += Input.TextInput;
+ }
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine.WindowsDX/AlphaBlendEffectLoaderWindowsDX.cs b/Monofoxe/Monofoxe.Engine.WindowsDX/AlphaBlendEffectLoaderWindowsDX.cs
new file mode 100644
index 00000000..d72c73da
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine.WindowsDX/AlphaBlendEffectLoaderWindowsDX.cs
@@ -0,0 +1,11 @@
+using System.Reflection;
+
+namespace Monofoxe.Engine.WindowsDX
+{
+ public class AlphaBlendEffectLoaderWindowsDX : AlphaBlendEffectLoader
+ {
+ protected override string _effectName => "Monofoxe.Engine.WindowsDX.AlphaBlend_dx.mgfxo";
+
+ protected override Assembly _assembly => Assembly.GetAssembly(typeof(AlphaBlendEffectLoaderWindowsDX));
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine.WindowsDX/Monofoxe.Engine.WindowsDX.csproj b/Monofoxe/Monofoxe.Engine.WindowsDX/Monofoxe.Engine.WindowsDX.csproj
new file mode 100644
index 00000000..3b68c9a0
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine.WindowsDX/Monofoxe.Engine.WindowsDX.csproj
@@ -0,0 +1,29 @@
+
+
+
+ netcoreapp3.1
+ false
+ true
+ ..\bin\$(Configuration)\
+ ..\bin\$(Configuration)\$(AssemblyName).xml
+ 1701;1702;1591
+ true
+
+
+
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
diff --git a/Monofoxe/Monofoxe.Engine.WindowsDX/MonofoxePlatform.cs b/Monofoxe/Monofoxe.Engine.WindowsDX/MonofoxePlatform.cs
new file mode 100644
index 00000000..ae70e944
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine.WindowsDX/MonofoxePlatform.cs
@@ -0,0 +1,14 @@
+namespace Monofoxe.Engine.WindowsDX
+{
+ public static class MonofoxePlatform
+ {
+ public static void Init()
+ {
+ GameMgr.CurrentPlatform = Platform.Windows;
+ GameMgr.CurrentGraphicsBackend = GraphicsBackend.DirectX;
+
+ StuffResolver.AddStuffAs(new AlphaBlendEffectLoaderWindowsDX());
+ StuffResolver.AddStuffAs(new TextInputBinderWindowsDX());
+ }
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine.WindowsDX/TextInputBInderWindowsDX.cs b/Monofoxe/Monofoxe.Engine.WindowsDX/TextInputBInderWindowsDX.cs
new file mode 100644
index 00000000..e2e1870c
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine.WindowsDX/TextInputBInderWindowsDX.cs
@@ -0,0 +1,11 @@
+
+namespace Monofoxe.Engine.WindowsDX
+{
+ public class TextInputBinderWindowsDX : ITextInputBinder
+ {
+ public void Init()
+ {
+ GameMgr.Game.Window.TextInput += Input.TextInput;
+ }
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine/AlphaBlendEffectLoader.cs b/Monofoxe/Monofoxe.Engine/AlphaBlendEffectLoader.cs
new file mode 100644
index 00000000..3384f63c
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine/AlphaBlendEffectLoader.cs
@@ -0,0 +1,54 @@
+using Microsoft.Xna.Framework.Graphics;
+using Monofoxe.Engine.Drawing;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using System.Text;
+
+namespace Monofoxe.Engine
+{
+ public interface IAlphaBlendEffectLoader
+ {
+ Effect Load();
+ }
+
+ public abstract class AlphaBlendEffectLoader : IAlphaBlendEffectLoader
+ {
+ protected abstract string _effectName { get; }
+ protected abstract Assembly _assembly { get; }
+
+ private readonly object _lock = new object();
+
+ public byte[] Bytecode
+ {
+ get
+ {
+ if (_bytecode == null)
+ {
+ lock (_lock)
+ {
+ if (_bytecode != null)
+ {
+ return _bytecode;
+ }
+
+ var stream = _assembly.GetManifestResourceStream(_effectName);
+ using (var ms = new MemoryStream())
+ {
+ stream.CopyTo(ms);
+ _bytecode = ms.ToArray();
+ }
+ }
+ }
+
+ return _bytecode;
+ }
+ }
+ private volatile byte[] _bytecode;
+
+
+ public Effect Load() =>
+ new Effect(GraphicsMgr.Device, Bytecode);
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine/AssetMgr.cs b/Monofoxe/Monofoxe.Engine/AssetMgr.cs
deleted file mode 100644
index ca08779e..00000000
--- a/Monofoxe/Monofoxe.Engine/AssetMgr.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-using System.Collections.Generic;
-
-namespace Monofoxe.Engine
-{
- ///
- /// Provides convenient asset paths and lists all content assets.
- ///
- public static class AssetMgr
- {
- ///
- /// Root directory of the game content.
- ///
- public static string ContentDir = "Content";
-
- ///
- /// Root directory for graphics.
- /// NOTE: This directory is located inside ContentDir.
- ///
- public static string GraphicsDir = "Graphics";
-
- ///
- /// Root directory for the audio.
- /// NOTE: This directory is located inside ContentDir.
- ///
- public static string AudioDir = "Audio";
-
- ///
- /// Root directory for shaders.
- /// NOTE: This directory is located inside ContentDir.
- ///
- public static string EffectsDir = "Effects";
-
- ///
- /// Root directory for fonts.
- /// NOTE: This directory is located inside ContentDir.
- ///
- public static string FontsDir = "Fonts";
-
- ///
- /// Root directory for entity templates.
- /// NOTE: This directory is located inside ContentDir.
- ///
- public static string EntityTemplatesDir = "Entities";
-
- ///
- /// Root directory for maps.
- /// NOTE: This directory is located inside ContentDir.
- ///
- public static string MapsDir = "Maps";
-
-
- ///
- /// List of all game ssets.
- ///
- private static string[] _assetPaths;
-
-
-
- internal static void Init() =>
- _assetPaths = GameMgr.Game.Content.Load(ContentDir); // Maybe make new content instance?
-
-
-
- ///
- /// Returns list of asset paths matching input path.
- /// Empty string will return all asset paths.
- ///
- public static string[] GetAssetPaths(string path = "")
- {
- path = path.Replace('\\', '/');
-
- if (path != "")
- {
- var list = new List();
-
- if (!path.EndsWith("/"))
- {
- path += '/';
- }
- foreach(string info in _assetPaths)
- {
- if (info.StartsWith(path))
- {
- list.Add(info);
- }
- }
-
- return list.ToArray();
- }
- else
- {
- var assetPathsCopy = new string[_assetPaths.Length];
- _assetPaths.CopyTo(assetPathsCopy, 0);
- return assetPathsCopy;
- }
- }
-
- }
-}
diff --git a/Monofoxe/Monofoxe.Engine/Cameras/Camera.cs b/Monofoxe/Monofoxe.Engine/Cameras/Camera.cs
index f969eeee..9b8537d6 100644
--- a/Monofoxe/Monofoxe.Engine/Cameras/Camera.cs
+++ b/Monofoxe/Monofoxe.Engine/Cameras/Camera.cs
@@ -297,13 +297,13 @@ private void ApplyPostprocessing()
if (sufraceChooser)
{
Surface.SetTarget(Surface);
- GraphicsMgr.Device.Clear(Color.TransparentBlack);
+ GraphicsMgr.Device.Clear(Color.Transparent);
_postprocessorBuffer.Draw(Vector2.Zero);
}
else
{
Surface.SetTarget(_postprocessorBuffer);
- GraphicsMgr.Device.Clear(Color.TransparentBlack);
+ GraphicsMgr.Device.Clear(Color.Transparent);
Surface.Draw(Vector2.Zero);
}
diff --git a/Monofoxe/Monofoxe.Engine/ColorExtensions.cs b/Monofoxe/Monofoxe.Engine/ColorExtensions.cs
new file mode 100644
index 00000000..a0addc36
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine/ColorExtensions.cs
@@ -0,0 +1,67 @@
+using Microsoft.Xna.Framework;
+using System;
+
+namespace Monofoxe.Engine
+{
+ ///
+ /// extensions
+ ///
+ public static class ColorExtensions
+ {
+
+ ///
+ /// Return the HsvColor equivalent of a given color
+ ///
+ /// The color that will be converted
+ /// equivalent of the color
+ public static HsvColor ToHsvColor(this Color color)
+ {
+ float hue = 0;
+ float saturation = 0;
+ float value = 0;
+ float r, g, b;
+
+ r = color.R / 255f;
+ g = color.G / 255f;
+ b = color.B / 255f;
+
+ float max = Math.Max(Math.Max(r, g), b);
+ float min = Math.Min(Math.Min(r, g), b);
+
+ float delta = max - min;
+
+
+ // This is why nobody likes switch, when we will be able to do something like this in an idiomatic way.
+ if (delta != 0)
+ {
+ if (max == r)
+ {
+ if (g >= b)
+ {
+ hue = 60 * ((g - b) / delta);
+ }
+ else
+ {
+ hue = (60 * ((g - b) / delta)) + 360;
+ }
+ }
+ else if (max == g)
+ {
+ hue = 60 * ((b - r) / delta) + 120;
+ }
+ else if (max == b)
+ {
+ hue = 60 * ((r - g) / delta) + 240;
+ }
+ }
+
+ saturation = max == 0 ? 0 : delta / max;
+
+ value = max;
+
+ return new HsvColor(hue, saturation, value, color.A);
+ }
+
+
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine/ContentReaders/SpriteGroupReader.cs b/Monofoxe/Monofoxe.Engine/ContentReaders/SpriteGroupReader.cs
index e5ca4cc9..d71f1d33 100644
--- a/Monofoxe/Monofoxe.Engine/ContentReaders/SpriteGroupReader.cs
+++ b/Monofoxe/Monofoxe.Engine/ContentReaders/SpriteGroupReader.cs
@@ -1,5 +1,7 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Diagnostics;
+using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
@@ -12,6 +14,7 @@ namespace Monofoxe.Engine.ContentReaders
///
internal class SpriteGroupReader : ContentTypeReader>
{
+
protected override Dictionary Read(ContentReader input, Dictionary existingInstance)
{
var texturesCount = input.ReadInt32();
@@ -21,7 +24,19 @@ protected override Dictionary Read(ContentReader input, Dictiona
// Reading textures.
for(var i = 0; i < texturesCount; i += 1)
{
- textures[i] = input.ReadObject();
+ var w = input.ReadInt32();
+ var h = input.ReadInt32();
+ var texture = new Texture2D(GameMgr.Game.GraphicsDevice, w, h, false, SurfaceFormat.Color);
+
+ var pixels = new Color[w * h];
+
+ for(var k = 0; k < pixels.Length; k += 1)
+ {
+ pixels[k] = input.ReadColor();
+ }
+ texture.SetData(pixels);
+
+ textures[i] = texture;
}
Debug.WriteLine(input.AssetName + ": " + textures.Length + " textures loaded!");
diff --git a/Monofoxe/Monofoxe.Engine/Drawing/CircleShape.cs b/Monofoxe/Monofoxe.Engine/Drawing/CircleShape.cs
index 74aeceae..0dfd8155 100644
--- a/Monofoxe/Monofoxe.Engine/Drawing/CircleShape.cs
+++ b/Monofoxe/Monofoxe.Engine/Drawing/CircleShape.cs
@@ -7,12 +7,8 @@ namespace Monofoxe.Engine.Drawing
///
/// Drawable circle shape. Can be drawn by using static methods or be instantiated.
///
- public class CircleShape : IDrawable
+ public class CircleShape : Drawable
{
- ///
- /// Center point of a circle.
- ///
- public Vector2 Position {get; set;}
public float Radius = 1;
@@ -23,13 +19,15 @@ public class CircleShape : IDrawable
public Color Color = Color.White;
+ public float ZDepth = 0;
+
static CircleShape()
{
CircleVerticesCount = 16;
}
- public void Draw() =>
- Draw(Position, Radius, IsOutline, Color);
+ public override void Draw() =>
+ Draw(Position, Radius, IsOutline, Color, ZDepth);
@@ -78,7 +76,7 @@ public static void Draw(Vector2 p, float r, bool isOutline) =>
///
/// Draws a circle.
///
- public static void Draw(Vector2 p, float r, bool isOutline, Color color)
+ public static void Draw(Vector2 p, float r, bool isOutline, Color color, float zDepth = 0)
{
for(var i = 0; i < _circleVerticesCount; i += 1)
@@ -86,7 +84,7 @@ public static void Draw(Vector2 p, float r, bool isOutline, Color color)
_circleVertices[i].Position = new Vector3(
p.X + r * _circleVectors[i].X,
p.Y + r * _circleVectors[i].Y,
- 0
+ zDepth
);
_circleVertices[i].Color = color;
}
diff --git a/Monofoxe/Monofoxe.Engine/Drawing/IDrawable.cs b/Monofoxe/Monofoxe.Engine/Drawing/Drawable.cs
similarity index 74%
rename from Monofoxe/Monofoxe.Engine/Drawing/IDrawable.cs
rename to Monofoxe/Monofoxe.Engine/Drawing/Drawable.cs
index be7ee1c5..c2ca5e4f 100644
--- a/Monofoxe/Monofoxe.Engine/Drawing/IDrawable.cs
+++ b/Monofoxe/Monofoxe.Engine/Drawing/Drawable.cs
@@ -1,20 +1,20 @@
-using Microsoft.Xna.Framework;
-
-namespace Monofoxe.Engine.Drawing
-{
- ///
- /// Anything that can be drawn.
- ///
- public interface IDrawable
- {
- ///
- /// Drawable object's global position.
- ///
- Vector2 Position {get; set;}
-
- ///
- /// Draws the object.
- ///
- void Draw();
- }
-}
+using Microsoft.Xna.Framework;
+
+namespace Monofoxe.Engine.Drawing
+{
+ ///
+ /// Anything that can be drawn.
+ ///
+ public abstract class Drawable
+ {
+ ///
+ /// Drawable object's global position.
+ ///
+ public Vector2 Position;
+
+ ///
+ /// Draws the object.
+ ///
+ public abstract void Draw();
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine/Drawing/Frame.cs b/Monofoxe/Monofoxe.Engine/Drawing/Frame.cs
index 91a3abde..efef8f26 100644
--- a/Monofoxe/Monofoxe.Engine/Drawing/Frame.cs
+++ b/Monofoxe/Monofoxe.Engine/Drawing/Frame.cs
@@ -8,7 +8,7 @@ namespace Monofoxe.Engine.Drawing
///
/// Drawable frame.
///
- public class Frame : IDrawable, ICloneable
+ public class Frame : Drawable, ICloneable
{
///
/// Texture atlas where frame is stored.
@@ -30,9 +30,7 @@ public class Frame : IDrawable, ICloneable
///
public float Height => TexturePosition.Height;
-
- public Vector2 Position {get; set;}
public Vector2 Scale = Vector2.One;
@@ -69,7 +67,7 @@ public Frame(Texture2D texture, RectangleF texturePosition, Vector2 origin)
Origin = origin;
}
- public void Draw() =>
+ public override void Draw() =>
Draw(Position, Origin, Scale, Rotation, Color, ZDepth);
diff --git a/Monofoxe/Monofoxe.Engine/Drawing/GraphicsMgr.cs b/Monofoxe/Monofoxe.Engine/Drawing/GraphicsMgr.cs
index 47b85980..e31b71af 100644
--- a/Monofoxe/Monofoxe.Engine/Drawing/GraphicsMgr.cs
+++ b/Monofoxe/Monofoxe.Engine/Drawing/GraphicsMgr.cs
@@ -143,8 +143,6 @@ public static void Update(GameTime gameTime)
camera.ConstructProjectionMatrix()
);
- Input.MousePosition = camera.GetRelativeMousePosition();
-
if (camera.ClearBackground)
{
Device.Clear(camera.BackgroundColor);
@@ -172,7 +170,6 @@ public static void Update(GameTime gameTime)
)
);
VertexBatch.PushViewMatrix(CanvasMatrix);
- Input.MousePosition = Input.ScreenMousePosition;
// Resetting camera, transform matrix and mouse position
@@ -180,7 +177,7 @@ public static void Update(GameTime gameTime)
var oldEffect = VertexBatch.Effect;
VertexBatch.Effect = null;
- Device.Clear(Color.TransparentBlack);
+ Device.Clear(Color.Transparent);
// We don't need in-game rasterizer to apply to camera surfaces.
var oldRasterizerState = VertexBatch.RasterizerState;
@@ -235,4 +232,4 @@ public static void Update(GameTime gameTime)
}
}
-}
\ No newline at end of file
+}
diff --git a/Monofoxe/Monofoxe.Engine/Drawing/LineShape.cs b/Monofoxe/Monofoxe.Engine/Drawing/LineShape.cs
index 0fea9190..654152a5 100644
--- a/Monofoxe/Monofoxe.Engine/Drawing/LineShape.cs
+++ b/Monofoxe/Monofoxe.Engine/Drawing/LineShape.cs
@@ -8,10 +8,8 @@ namespace Monofoxe.Engine.Drawing
/// Drawable line shape. Can be drawn by using static methods or be instantiated.
/// NOTE: The line has no width.
///
- public class LineShape : IDrawable
+ public class LineShape : Drawable
{
- public Vector2 Position {get; set;}
-
///
/// First line point.
/// NOTE: all line points treat position as an origin point;
@@ -26,12 +24,14 @@ public class LineShape : IDrawable
public Color Color = Color.White;
+ public float ZDepth = 0;
+
private static VertexPositionColorTexture[] _lineVertices = new VertexPositionColorTexture[2];
private static short[] _lineIndices = { 0, 1 };
- public void Draw() =>
- Draw(Point1 + Position, Point2 + Position, Color, Color);
+ public override void Draw() =>
+ Draw(Point1 + Position, Point2 + Position, Color, Color, ZDepth);
///
@@ -43,11 +43,11 @@ public static void Draw(Vector2 p1, Vector2 p2) =>
///
/// Draws a line with specified colors.
///
- public static void Draw(Vector2 p1, Vector2 p2, Color c1, Color c2)
+ public static void Draw(Vector2 p1, Vector2 p2, Color c1, Color c2, float zDepth = 0)
{
- _lineVertices[0].Position = p1.ToVector3();
+ _lineVertices[0].Position = new Vector3(p1, zDepth);
_lineVertices[0].Color = c1;
- _lineVertices[1].Position = p2.ToVector3();
+ _lineVertices[1].Position = new Vector3(p2, zDepth);
_lineVertices[1].Color = c2;
GraphicsMgr.VertexBatch.Texture = null;
diff --git a/Monofoxe/Monofoxe.Engine/Drawing/Primitive2D.cs b/Monofoxe/Monofoxe.Engine/Drawing/Primitive2D.cs
index 76fc504f..b2e7bc64 100644
--- a/Monofoxe/Monofoxe.Engine/Drawing/Primitive2D.cs
+++ b/Monofoxe/Monofoxe.Engine/Drawing/Primitive2D.cs
@@ -8,10 +8,8 @@ namespace Monofoxe.Engine.Drawing
///
/// Base 2D primitive class. Can be used to create other types of primitives.
///
- public abstract class Primitive2D : IDrawable
+ public abstract class Primitive2D : Drawable
{
- public Vector2 Position {get; set;}
-
///
/// List of all primitive's vertices.
/// NOTE: all vertices treat position as an origin point;
@@ -105,7 +103,7 @@ protected VertexPositionColorTexture[] GetConvertedVertices()
}
- public void Draw()
+ public override void Draw()
{
GraphicsMgr.VertexBatch.Texture = _texture;
GraphicsMgr.VertexBatch.AddPrimitive(_primitiveType, GetConvertedVertices(), GetIndices());
diff --git a/Monofoxe/Monofoxe.Engine/Drawing/RectangleShape.cs b/Monofoxe/Monofoxe.Engine/Drawing/RectangleShape.cs
index ca034603..2dea3356 100644
--- a/Monofoxe/Monofoxe.Engine/Drawing/RectangleShape.cs
+++ b/Monofoxe/Monofoxe.Engine/Drawing/RectangleShape.cs
@@ -3,13 +3,8 @@
namespace Monofoxe.Engine.Drawing
{
- public class RectangleShape : IDrawable
+ public class RectangleShape : Drawable
{
- ///
- /// Center point of a rectangle.
- ///
- public Vector2 Position {get; set;}
-
public Vector2 Size = Vector2.One;
///
@@ -19,15 +14,18 @@ public class RectangleShape : IDrawable
public Color Color = Color.White;
+ public float ZDepth = 0;
+
///
/// Draws a rectangle using instance properties.
///
- public void Draw()
+ public override void Draw()
{
Draw(
- Position - Size / 2, Position - Size / 2,
+ Position - Size / 2, Position + Size / 2,
IsOutline,
- Color, Color, Color, Color
+ Color, Color, Color, Color,
+ ZDepth
);
}
@@ -54,16 +52,17 @@ public static void Draw(
Color c1,
Color c2,
Color c3,
- Color c4
+ Color c4,
+ float zDepth = 0
)
{
- _rectangleVertices[0].Position = new Vector3(p1.X, p1.Y, 0);
+ _rectangleVertices[0].Position = new Vector3(p1.X, p1.Y, zDepth);
_rectangleVertices[0].Color = c1;
- _rectangleVertices[1].Position = new Vector3(p2.X, p1.Y, 0);
+ _rectangleVertices[1].Position = new Vector3(p2.X, p1.Y, zDepth);
_rectangleVertices[1].Color = c2;
- _rectangleVertices[2].Position = new Vector3(p2.X, p2.Y, 0);
+ _rectangleVertices[2].Position = new Vector3(p2.X, p2.Y, zDepth);
_rectangleVertices[2].Color = c3;
- _rectangleVertices[3].Position = new Vector3(p1.X, p2.Y, 0);
+ _rectangleVertices[3].Position = new Vector3(p1.X, p2.Y, zDepth);
_rectangleVertices[3].Color = c4;
GraphicsMgr.VertexBatch.Texture = null;
diff --git a/Monofoxe/Monofoxe.Engine/Drawing/Sprite.cs b/Monofoxe/Monofoxe.Engine/Drawing/Sprite.cs
index 2f37a567..bf664468 100644
--- a/Monofoxe/Monofoxe.Engine/Drawing/Sprite.cs
+++ b/Monofoxe/Monofoxe.Engine/Drawing/Sprite.cs
@@ -9,7 +9,7 @@ namespace Monofoxe.Engine.Drawing
///
/// Drawable sprite.
///
- public class Sprite : IDrawable, ICloneable
+ public class Sprite : Drawable, ICloneable
{
///
/// An array of sprite's frames.
@@ -46,8 +46,7 @@ public float Height
}
}
- public Vector2 Position {get; set;}
-
+
public Vector2 Scale = Vector2.One;
public Vector2 Origin;
@@ -139,7 +138,7 @@ private Frame GetFrame(double animation) =>
_frames[Math.Max(0, Math.Min(_frames.Length - 1, (int)(animation * _frames.Length)))];
- public void Draw() =>
+ public override void Draw() =>
GetFrame(Animation).Draw(Position, Origin, Scale, Rotation, Color, ZDepth);
// Vectors.
diff --git a/Monofoxe/Monofoxe.Engine/Drawing/Surface.cs b/Monofoxe/Monofoxe.Engine/Drawing/Surface.cs
index b3d7eb9d..6eb704d4 100644
--- a/Monofoxe/Monofoxe.Engine/Drawing/Surface.cs
+++ b/Monofoxe/Monofoxe.Engine/Drawing/Surface.cs
@@ -6,10 +6,8 @@
namespace Monofoxe.Engine.Drawing
{
- public class Surface : IDrawable, IDisposable
+ public class Surface : Drawable, IDisposable
{
- public Vector2 Position {get; set;}
-
public Vector2 Scale = Vector2.One;
public Vector2 Origin;
@@ -81,7 +79,7 @@ private RenderTarget2D CreateRenderTarget(int w, int h)
}
- public void Draw() =>
+ public override void Draw() =>
Draw(Position, Origin, Scale, Rotation, Color, ZDepth);
diff --git a/Monofoxe/Monofoxe.Engine/Drawing/Text.cs b/Monofoxe/Monofoxe.Engine/Drawing/Text.cs
index 131b32ea..7f10f37c 100644
--- a/Monofoxe/Monofoxe.Engine/Drawing/Text.cs
+++ b/Monofoxe/Monofoxe.Engine/Drawing/Text.cs
@@ -4,10 +4,8 @@
namespace Monofoxe.Engine.Drawing
{
- public class Text : IDrawable
+ public class Text : Drawable
{
- public Vector2 Position {get; set;}
-
public Vector2 Scale;
public Vector2 Origin;
@@ -37,7 +35,7 @@ public Text(string str, Vector2 position, Vector2 scale, Vector2 origin, Angle r
// Text.
- public void Draw()
+ public override void Draw()
{
var oldColor = GraphicsMgr.CurrentColor;
GraphicsMgr.CurrentColor = Color;
diff --git a/Monofoxe/Monofoxe.Engine/Drawing/TextureFont.cs b/Monofoxe/Monofoxe.Engine/Drawing/TextureFont.cs
index b9c6e82a..f8e6ca60 100644
--- a/Monofoxe/Monofoxe.Engine/Drawing/TextureFont.cs
+++ b/Monofoxe/Monofoxe.Engine/Drawing/TextureFont.cs
@@ -9,6 +9,8 @@ namespace Monofoxe.Engine.Drawing
{
public class TextureFont : IFont
{
+ public const string Ascii = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
+
///
/// Unused, because TextureFont can have multiple textures.
///
diff --git a/Monofoxe/Monofoxe.Engine/Drawing/ThickLineShape.cs b/Monofoxe/Monofoxe.Engine/Drawing/ThickLineShape.cs
index 2cc2708e..1f3c61db 100644
--- a/Monofoxe/Monofoxe.Engine/Drawing/ThickLineShape.cs
+++ b/Monofoxe/Monofoxe.Engine/Drawing/ThickLineShape.cs
@@ -8,10 +8,8 @@ namespace Monofoxe.Engine.Drawing
///
/// Drawable thick line shape. Can be drawn by using static methods or be instantiated.
///
- public class ThickLineShape : IDrawable
+ public class ThickLineShape : Drawable
{
- public Vector2 Position {get; set;}
-
///
/// First line point.
/// NOTE: all line points treat position as an origin point;
@@ -31,8 +29,10 @@ public class ThickLineShape : IDrawable
public Color Color = Color.White;
- public void Draw() =>
- Draw(Point1 + Position, Point2 + Position, Thickness, Color, Color);
+ public float ZDepth = 0;
+
+ public override void Draw() =>
+ Draw(Point1 + Position, Point2 + Position, Thickness, Color, Color, ZDepth);
private static VertexPositionColorTexture[] _thickLineVertices = new VertexPositionColorTexture[4];
@@ -48,20 +48,20 @@ public static void Draw(Vector2 pt1, Vector2 pt2, float thickness) =>
///
/// Draws a line with specified width and colors.
///
- public static void Draw(Vector2 pt1, Vector2 pt2, float thickness, Color c1, Color c2)
+ public static void Draw(Vector2 pt1, Vector2 pt2, float thickness, Color c1, Color c2, float zDepth = 0)
{
var normal = (pt2 - pt1).Rotate90();
normal = normal.GetSafeNormalize(); // The result is a unit vector rotated by 90 degrees.
normal *= thickness / 2;
- _thickLineVertices[0].Position = (pt1 - normal).ToVector3();
+ _thickLineVertices[0].Position = new Vector3(pt1 - normal, zDepth);
_thickLineVertices[0].Color = c1;
- _thickLineVertices[1].Position = (pt1 + normal).ToVector3();
+ _thickLineVertices[1].Position = new Vector3(pt1 + normal, zDepth);
_thickLineVertices[1].Color = c1;
- _thickLineVertices[2].Position = (pt2 + normal).ToVector3();
+ _thickLineVertices[2].Position = new Vector3(pt2 + normal, zDepth);
_thickLineVertices[2].Color = c2;
- _thickLineVertices[3].Position = (pt2 - normal).ToVector3();
+ _thickLineVertices[3].Position = new Vector3(pt2 - normal, zDepth);
_thickLineVertices[3].Color = c2;
diff --git a/Monofoxe/Monofoxe.Engine/Drawing/TriangleShape.cs b/Monofoxe/Monofoxe.Engine/Drawing/TriangleShape.cs
index d659205a..555c4434 100644
--- a/Monofoxe/Monofoxe.Engine/Drawing/TriangleShape.cs
+++ b/Monofoxe/Monofoxe.Engine/Drawing/TriangleShape.cs
@@ -7,10 +7,8 @@ namespace Monofoxe.Engine.Drawing
///
/// Drawable triangle shape. Can be drawn by using static methods or be instantiated.
///
- public class TriangleShape : IDrawable
+ public class TriangleShape : Drawable
{
- public Vector2 Position {get; set;}
-
///
/// First triangle point.
/// NOTE: all triangle points treat position as an origin point;
@@ -36,9 +34,10 @@ public class TriangleShape : IDrawable
public Color Color = Color.White;
+ public float ZDepth = 0;
- public void Draw() =>
- Draw(Point1 + Position, Point2 + Position, Point3 + Position, IsOutline, Color, Color, Color);
+ public override void Draw() =>
+ Draw(Point1 + Position, Point2 + Position, Point3 + Position, IsOutline, Color, Color, Color, ZDepth);
@@ -57,13 +56,13 @@ public static void Draw(Vector2 p1, Vector2 p2, Vector2 p3, bool isOutline) =>
///
/// Draws a triangle with specified colors.
///
- public static void Draw(Vector2 p1, Vector2 p2, Vector2 p3, bool isOutline, Color c1, Color c2, Color c3)
+ public static void Draw(Vector2 p1, Vector2 p2, Vector2 p3, bool isOutline, Color c1, Color c2, Color c3, float zDepth = 0)
{
- _triangleVertices[0].Position = new Vector3(p1.X, p1.Y, 0);
+ _triangleVertices[0].Position = new Vector3(p1.X, p1.Y, zDepth);
_triangleVertices[0].Color = c1;
- _triangleVertices[1].Position = new Vector3(p2.X, p2.Y, 0);
+ _triangleVertices[1].Position = new Vector3(p2.X, p2.Y, zDepth);
_triangleVertices[1].Color = c2;
- _triangleVertices[2].Position = new Vector3(p3.X, p3.Y, 0);
+ _triangleVertices[2].Position = new Vector3(p3.X, p3.Y, zDepth);
_triangleVertices[2].Color = c3;
GraphicsMgr.VertexBatch.Texture = null;
diff --git a/Monofoxe/Monofoxe.Engine/Drawing/VertexBatch.cs b/Monofoxe/Monofoxe.Engine/Drawing/VertexBatch.cs
index 56dfafc0..d898ccf8 100644
--- a/Monofoxe/Monofoxe.Engine/Drawing/VertexBatch.cs
+++ b/Monofoxe/Monofoxe.Engine/Drawing/VertexBatch.cs
@@ -140,7 +140,7 @@ public Rectangle ScissorRectangle
public GraphicsDevice GraphicsDevice { get; private set; }
public bool NeedsFlush => _vertexPoolCount > 0 && _indexPoolCount > 0;
-
+
private short[] _indexPool;
private int _indexPoolCount = 0;
private const int _indexPoolCapacity = short.MaxValue * 8;
@@ -151,7 +151,7 @@ public Rectangle ScissorRectangle
private EffectPass _defaultEffectPass;
- public Matrix World
+ public Matrix World
{
get => _world;
set
@@ -178,7 +178,7 @@ public Matrix View
}
}
Matrix _view;
-
+
public Matrix Projection
{
get => _projection;
@@ -195,15 +195,21 @@ public Matrix Projection
- private Stack _worldStack = new Stack();
public bool WorldStackEmpty => _worldStack.Count == 0;
+ private Stack _worldStack = new Stack();
- private Stack _viewStack = new Stack();
public bool ViewStackEmpty => _viewStack.Count == 0;
+ private Stack _viewStack = new Stack();
- private Stack _projectionStack = new Stack();
public bool ProjectionStackEmpty => _projectionStack.Count == 0;
+ private Stack _projectionStack = new Stack();
+ ///
+ /// Pixel offset is necessary for proper 2D rendering.
+ /// If true, offsets x and y by -0.5.
+ /// Should be true for OpenGL and false for DirectX.
+ ///
+ public static bool UsesHalfPixelOffset = false;
PrimitiveType _primitiveType = PrimitiveType.TriangleList;
@@ -249,13 +255,6 @@ public Effect DefaultEffect
/// Replaces BasicEffect. Applied, when CurrentEffect and DefaulrEffect are null.
///
private static Effect _alphaBlendEffect;
- private static string _alphaBlendName = "AlphaBlend";
-
- ///
- /// Used to load default shader.
- ///
- private static ContentManager _content;
-
public VertexBatch(
GraphicsDevice graphicsDevice,
@@ -271,31 +270,35 @@ public VertexBatch(
_samplerState = samplerState ?? SamplerState.LinearClamp;
_depthStencilState = depthStencilState ?? DepthStencilState.None;
_rasterizerState = rasterizerState ?? RasterizerState.CullCounterClockwise;
-
+
_indexPool = new short[_indexPoolCapacity];
_vertexPool = new VertexPositionColorTexture[_vertexPoolCapacity];
if (_alphaBlendEffect == null)
{
- _content = new ContentManager(GameMgr.Game.Services);
- _content.RootDirectory = AssetMgr.ContentDir + '/' + AssetMgr.EffectsDir;
- _alphaBlendEffect = _content.Load(_alphaBlendName);
+ _alphaBlendEffect = StuffResolver.GetStuff().Load();
}
DefaultEffect = _alphaBlendEffect;
- //_defaultEffectPass = _defaultEffect.CurrentTechnique.Passes[0];
}
void ApplyDefaultShader()
{
-
- // The default shader is used for the transfrm matrix.
+
+ // The default shader is used for the transform matrix.
_defaultEffect.Parameters["World"].SetValue(_world);
_defaultEffect.Parameters["View"].SetValue(_view);
- _defaultEffect.Parameters["Projection"].SetValue(_projection);
+ if (UsesHalfPixelOffset)
+ {
+ _defaultEffect.Parameters["Projection"].SetValue(Matrix.CreateTranslation(-0.5f, -0.5f, 0) * _projection);
+ }
+ else
+ {
+ _defaultEffect.Parameters["Projection"].SetValue(_projection);
+ }
// We can use vertex shader from the default effect if the custom effect doesn't have one.
// Pixel shader get completely overwritten by the custom effect, though.
@@ -614,7 +617,7 @@ Vector4 zDepth
destRectangle.X,
destRectangle.Y,
-origin.X,
- -origin.Y,
+ -origin.Y,
destRectangle.Width,
destRectangle.Height,
(float)Math.Sin(rotation),
diff --git a/Monofoxe/Monofoxe.Engine/EC/Entity.cs b/Monofoxe/Monofoxe.Engine/EC/Entity.cs
index 69fb87d9..79e7dd8b 100644
--- a/Monofoxe/Monofoxe.Engine/EC/Entity.cs
+++ b/Monofoxe/Monofoxe.Engine/EC/Entity.cs
@@ -166,7 +166,7 @@ public virtual void Destroy()
///
/// Adds component to the entity.
///
- public void AddComponent(Component component)
+ public T AddComponent(T component) where T : Component
{
if (component.Owner != null)
{
@@ -176,9 +176,11 @@ public void AddComponent(Component component)
_componentList.Add(component);
component.Owner = this;
component.Initialize();
+ component.Initialized = true;
+
+ return component; // Doing a passthrough for nicer syntax.
}
-
-
+
///
/// Returns component of given class.
@@ -255,6 +257,7 @@ public Component RemoveComponent(Type type)
{
if (_componentDictionary.TryGetValue(type, out Component component))
{
+ component.Destroy();
_componentDictionary.Remove(type);
_componentList.Remove(component);
component.Owner = null;
@@ -267,19 +270,6 @@ public Component RemoveComponent(Type type)
- ///
- /// Creates new entity from existing template.
- ///
- public static Entity CreateFromTemplate(Layer layer, string tag)
- {
- if (EntityTemplatePool.TemplatePool.TryGetValue(tag, out IEntityTemplate factory))
- {
- return factory.Make(layer);
- }
- return null;
- }
-
-
///
/// Destroys entity and all of its components.
///
diff --git a/Monofoxe/Monofoxe.Engine/EC/EntityTemplatePool.cs b/Monofoxe/Monofoxe.Engine/EC/EntityTemplatePool.cs
deleted file mode 100644
index 544991ec..00000000
--- a/Monofoxe/Monofoxe.Engine/EC/EntityTemplatePool.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace Monofoxe.Engine.EC
-{
- ///
- /// Entity factory pool stores in instance of each entity factory.
- ///
- static class EntityTemplatePool
- {
- ///
- /// Pool of all factories in all assemblies. Sorted by their tags.
- ///
- public static Dictionary TemplatePool;
-
- ///
- /// Initialized template pool by creating an instance of each IEntityTemplateclass.
- ///
- public static void InitTemplatePool()
- {
- TemplatePool = new Dictionary(StringComparer.OrdinalIgnoreCase);
-
- // Creating an instance of each.
- foreach(var type in GameMgr.Types)
- {
- if (typeof(IEntityTemplate).IsAssignableFrom(type.Value) && !type.Value.IsInterface)
- {
- var newTemplate = (IEntityTemplate)Activator.CreateInstance(type.Value);
- TemplatePool.Add(newTemplate.Tag, newTemplate);
- }
- }
- }
- }
-}
diff --git a/Monofoxe/Monofoxe.Engine/EC/IEntityTemplate.cs b/Monofoxe/Monofoxe.Engine/EC/IEntityTemplate.cs
deleted file mode 100644
index d9e0140c..00000000
--- a/Monofoxe/Monofoxe.Engine/EC/IEntityTemplate.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using Monofoxe.Engine.SceneSystem;
-
-namespace Monofoxe.Engine.EC
-{
- ///
- /// Entity template interface. Used to create entity by tag.
- ///
- public interface IEntityTemplate
- {
- ///
- /// Identifying tag.
- ///
- /// NOTE: All template tags should be unique!
- ///
- string Tag {get;}
-
- ///
- /// Creates an entity on a given layer.
- ///
- Entity Make(Layer layer);
- }
-}
diff --git a/Monofoxe/Monofoxe.Engine/GameMgr.cs b/Monofoxe/Monofoxe.Engine/GameMgr.cs
index 7cef3b6d..09da2d1c 100644
--- a/Monofoxe/Monofoxe.Engine/GameMgr.cs
+++ b/Monofoxe/Monofoxe.Engine/GameMgr.cs
@@ -1,39 +1,46 @@
-using System;
+using Microsoft.Xna.Framework;
+using Monofoxe.Engine.Drawing;
+using Monofoxe.Engine.SceneSystem;
+using System;
using System.Collections.Generic;
using System.Reflection;
-using Microsoft.Xna.Framework;
-using Monofoxe.Engine.EC;
-using Monofoxe.Engine.SceneSystem;
-using Monofoxe.Engine.Drawing;
+using System.Runtime.CompilerServices;
+
+[assembly: InternalsVisibleTo("Monofoxe.Engine.WindowsDX")]
+[assembly: InternalsVisibleTo("Monofoxe.Engine.DesktopGL")]
namespace Monofoxe.Engine
{
+
public static class GameMgr
{
-
+ public static Platform CurrentPlatform { get; internal set; } = Platform.Other;
+ public static GraphicsBackend CurrentGraphicsBackend { get; internal set; } = GraphicsBackend.Other;
+
+
///
/// Main Game class.
///
- public static Game Game;
-
+ public static Game Game { get; private set; }
+
///
/// Window manager. Can be used for screen and window stuff.
///
- public static WindowMgr WindowManager;
+ public static WindowMgr WindowManager { get; private set; }
///
/// Time in seconds, elapsed since game start.
///
- public static double ElapsedTimeTotal {get; private set;}
+ public static double ElapsedTimeTotal { get; private set; }
///
/// Time in seconds, elapsed since previous frame.
///
- public static double ElapsedTime {get; private set;}
+ public static double ElapsedTime { get; private set; }
+
-
public static double FixedUpdateRate = 0.5; // Seconds.
-
-
+
+
public static double MaxGameSpeed
{
get => (int)(1.0 / Game.TargetElapsedTime.TotalSeconds);
@@ -46,11 +53,11 @@ public static double MaxGameSpeed
}
}
}
-
+
///
/// After this point game will slow down instead of skipping frames.
///
- public static double MinGameSpeed
+ public static double MinGameSpeed
{
get => _minGameSpeed;
@@ -72,38 +79,40 @@ public static double MinGameSpeed
///
/// All game's assemblies, including ones from libraries.
///
- public static Dictionary Assemblies;
-
+ public static Dictionary Assemblies { get; private set; }
+
///
/// All of game's types.
///
- public static Dictionary Types;
-
- public static int Fps {get; private set;}
+ public static Dictionary Types { get; private set; }
+
+ public static int Fps { get; private set; }
private static int _fpsCount;
private static double _fpsAddition;
-
+
public static void Init(Game game)
{
Game = game;
Game.IsMouseVisible = true;
-
+
+ var keyboardBind = StuffResolver.GetStuff();
+ keyboardBind?.Init();
+
+
Input.MaxGamepadCount = 2;
-
+
WindowManager = new WindowMgr(game);
LoadAssembliesAndTypes(game.GetType().Assembly);
-
- AssetMgr.Init();
+
+ ResourceInfoMgr.Init();
var defScene = SceneMgr.CreateScene("default");
defScene.CreateLayer("default");
-
- EntityTemplatePool.InitTemplatePool();
}
-
+
///
/// Performs update-related routines and calls Update events for entities and systems.
///
@@ -121,7 +130,7 @@ public static void Update(GameTime gameTime)
ElapsedTime = 1.0 / MinGameSpeed;
}
// Elapsed time counters.
-
+
Input.Update();
SceneMgr.PreUpdateRoutine();
@@ -131,7 +140,7 @@ public static void Update(GameTime gameTime)
}
-
+
///
/// Performs drawing-related routines and calls Draw events for entities and systems.
///
@@ -149,19 +158,19 @@ public static void Draw(GameTime gameTime)
GraphicsMgr.Update(gameTime);
}
-
+
///
/// Closes the game.
///
- public static void ExitGame() =>
+ public static void ExitGame() =>
Game.Exit();
-
+
#region Assembly loading.
-
+
///
/// Loads all assemblies and extracts types form them.
///
@@ -170,7 +179,7 @@ private static void LoadAssembliesAndTypes(Assembly entryAssembly)
// Loading all assemblies.
Assemblies = new Dictionary();
- foreach(var asm in AppDomain.CurrentDomain.GetAssemblies())
+ foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
{
Assemblies.Add(asm.FullName, asm);
}
@@ -182,9 +191,9 @@ private static void LoadAssembliesAndTypes(Assembly entryAssembly)
// Extracting all types from assemblies.
Types = new Dictionary();
- foreach(var asm in Assemblies)
+ foreach (var asm in Assemblies)
{
- foreach(var type in asm.Value.GetTypes())
+ foreach (var type in asm.Value.GetTypes())
{
if (!Types.ContainsKey(type.FullName))
{
@@ -194,7 +203,7 @@ private static void LoadAssembliesAndTypes(Assembly entryAssembly)
}
// Extracting all types from assemblies.
}
-
+
///
/// Loads all referenced assemblies of an assembly.
///
@@ -205,13 +214,13 @@ private static void LoadAllReferencedAssemblies(Assembly assembly, int level)
return;
}
- foreach(var refAssembly in assembly.GetReferencedAssemblies())
+ foreach (var refAssembly in assembly.GetReferencedAssemblies())
{
if (!Assemblies.ContainsKey(refAssembly.FullName))
{
var asm = Assembly.Load(refAssembly);
Assemblies.Add(refAssembly.FullName, asm);
-
+
LoadAllReferencedAssemblies(asm, level + 1);
}
}
diff --git a/Monofoxe/Monofoxe.Engine/GraphicsBackend.cs b/Monofoxe/Monofoxe.Engine/GraphicsBackend.cs
new file mode 100644
index 00000000..75384289
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine/GraphicsBackend.cs
@@ -0,0 +1,10 @@
+
+namespace Monofoxe.Engine
+{
+ public enum GraphicsBackend
+ {
+ DirectX,
+ OpenGL,
+ Other
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine/HsvColor.cs b/Monofoxe/Monofoxe.Engine/HsvColor.cs
new file mode 100644
index 00000000..988b79b8
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine/HsvColor.cs
@@ -0,0 +1,94 @@
+using Microsoft.Xna.Framework;
+
+namespace Monofoxe.Engine
+{
+ public struct HsvColor
+ {
+ public float H
+ {
+ get => _h;
+ set => _h = MathHelper.Clamp(value, 0, 360);
+ }
+ public float _h;
+
+ public float S
+ {
+ get => _s;
+ set => _s = MathHelper.Clamp(value, 0, 1);
+ }
+ public float _s;
+
+ public float V
+ {
+ get => _v;
+ set => _v = MathHelper.Clamp(value, 0, 1);
+ }
+ public float _v;
+
+ public float A
+ {
+ get => _a;
+ set => _a = MathHelper.Clamp(value, 0, 1);
+ }
+ public float _a;
+
+
+ public HsvColor(Color color)
+ {
+ var hsv = color.ToHsvColor();
+ _h = hsv.H;
+ _s = hsv.S;
+ _v = hsv.V;
+ _a = hsv.A;
+ }
+
+
+ public HsvColor(float h, float s, float v, float a = 1f)
+ {
+ _h = MathHelper.Clamp(h, 0, 360);
+ _s = MathHelper.Clamp(s, 0, 1);
+ _v = MathHelper.Clamp(v, 0, 1);
+ _a = MathHelper.Clamp(a, 0, 1);
+ }
+
+
+ ///
+ /// Creates a color from the HSV color model.
+ ///
+ /// Return the in RGB
+ public Color ToColor()
+ {
+
+ if (S == 0)
+ {
+ return new Color(V, V, V, A);
+ }
+ if (V == 0)
+ {
+ return Color.Black;
+ }
+ float HS = (H / 60) % 6;
+ int HSI = (int)HS;
+ float f = HS - HSI;
+ float p = V * (1 - S);
+ float q = V * (1 - (f * S));
+ float t = V * (1 - ((1 - f) * S));
+ switch (HSI)
+ {
+ case 0:
+ return new Color(V, t, p, A);
+ case 1:
+ return new Color(q, V, t, A);
+ case 2:
+ return new Color(p, V, t, A);
+ case 3:
+ return new Color(p, q, V, A);
+ case 4:
+ return new Color(t, p, V, A);
+ case 5:
+ return new Color(V, p, q, A);
+ }
+ return Color.Black; // Keeps the compiler happy.
+ }
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine/ITextInputBinder.cs b/Monofoxe/Monofoxe.Engine/ITextInputBinder.cs
new file mode 100644
index 00000000..ead808d8
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine/ITextInputBinder.cs
@@ -0,0 +1,10 @@
+namespace Monofoxe.Engine
+{
+ ///
+ /// Binds Input.TextInput to the platform-specific text input provider.
+ ///
+ public interface ITextInputBinder
+ {
+ void Init();
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine/Input.cs b/Monofoxe/Monofoxe.Engine/Input.cs
index af0347c2..be1b5aa3 100644
--- a/Monofoxe/Monofoxe.Engine/Input.cs
+++ b/Monofoxe/Monofoxe.Engine/Input.cs
@@ -11,26 +11,20 @@ namespace Monofoxe.Engine
public static class Input
{
#region Mouse.
-
+
///
/// Cursor position on screen.
///
- public static Vector2 ScreenMousePosition {get; private set;} = Vector2.Zero;
-
- ///
- /// Cursor position in the world. Depends on current camera.
- ///
- public static Vector2 MousePosition {get; internal set;} = Vector2.Zero;
+ public static Vector2 ScreenMousePosition { get; private set; } = Vector2.Zero;
+ private static List _mouseButtons = new List();
+ private static List _oldMouseButtons = new List();
- private static List _mouseButtons = new List(),
- _previousMouseButtons = new List();
-
///
/// Scrollwheel value. Can be -1, 0 or 1.
///
- public static int MouseWheelValue {get; private set;}
+ public static int MouseWheelValue { get; private set; }
private static int _mouseWheelAdditionPrev;
#endregion Mouse.
@@ -41,30 +35,30 @@ public static class Input
///
/// Stores all chars typed in previous step.
///
- public static string KeyboardString {get; private set;}
-
+ public static string KeyboardString { get; private set; }
+
///
/// Stores last pressed key in current step. If no keys were pressed, resets to Keys.None.
///
- public static Keys KeyboardKey {get; private set;} = Keys.None;
+ public static Keys KeyboardKey { get; private set; } = Keys.None;
///
/// Stores last pressed key. Doesn't reset.
///
- public static Keys KeyboardLastKey {get; private set;} = Keys.None;
+ public static Keys KeyboardLastKey { get; private set; } = Keys.None;
///
/// Stores last typed char. Doesn't reset.
///
- public static char KeyboardLastChar {get; private set;} = ' ';
+ public static char KeyboardLastChar { get; private set; } = ' ';
private static StringBuilder _keyboardBuffer = new StringBuilder();
- private static Keys _keyboardLastKeyBuffer = Keys.None;
+ private static Keys _keyboardLastKeyBuffer = Keys.None;
private static List _currentKeys = new List();
- private static List _previousKeys = new List();
+ private static List _oldKeys = new List();
#endregion Keyboard.
-
+
#region Gamepad.
@@ -72,7 +66,7 @@ public static class Input
/// If pressure value is below deadzone, GamepadCheck() won't detect trigger press.
///
public static double GamepadTriggersDeadzone = 0.5;
-
+
///
/// Type of stick deadzone.
///
@@ -94,14 +88,14 @@ public static int MaxGamepadCount
}
}
- private static List[] _gamepadButtons = new List[_maxGamepadCount],
- _previousGamepadButtons = new List[_maxGamepadCount];
+ private static List[] _gamepadButtons = new List[_maxGamepadCount];
+ private static List[] _oldGamepadButtons = new List[_maxGamepadCount];
- private static GamePadState[] _gamepadState = new GamePadState[_maxGamepadCount],
- _previousGamepadState = new GamePadState[_maxGamepadCount];
+ private static GamePadState[] _gamepadState = new GamePadState[_maxGamepadCount];
+ private static GamePadState[] _oldGamepadState = new GamePadState[_maxGamepadCount];
#endregion Gamepad.
-
+
private const int _keyboardMaxCode = 1000;
private const int _mouseMaxCode = 2000;
@@ -120,14 +114,14 @@ internal static void Update()
#region Mouse.
MouseState mouseState = Mouse.GetState();
-
+
var m = Matrix.Invert(GraphicsMgr.CanvasMatrix);
var buffer = Vector3.Transform(new Vector3(mouseState.X, mouseState.Y, 0), m);
ScreenMousePosition = new Vector2(buffer.X, buffer.Y);
-
- _previousMouseButtons = _mouseButtons;
+
+ _oldMouseButtons = _mouseButtons;
_mouseButtons = new List();
-
+
if (mouseState.LeftButton == ButtonState.Pressed)
{
_mouseButtons.Add(Buttons.MouseLeft);
@@ -148,7 +142,7 @@ internal static void Update()
sign of scroll value delta (raw delta has some big weird value and depends on fps).
Thank you, XNA devs. You've made me write even more code! ^0^
*/
- MouseWheelValue = Math.Sign(_mouseWheelAdditionPrev - mouseState.ScrollWheelValue);
+ MouseWheelValue = _mouseWheelAdditionPrev - mouseState.ScrollWheelValue;
_mouseWheelAdditionPrev = mouseState.ScrollWheelValue;
#endregion Mouse.
@@ -167,11 +161,11 @@ sign of scroll value delta (raw delta has some big weird value and depends on fp
KeyboardLastKey = _keyboardLastKeyBuffer;
- _previousKeys.Clear();
- _previousKeys.AddRange(_currentKeys);
+ _oldKeys.Clear();
+ _oldKeys.AddRange(_currentKeys);
_currentKeys.Clear();
_currentKeys.AddRange(Keyboard.GetState().GetPressedKeys());
-
+
if (_currentKeys.Count > 0)
{
KeyboardKey = _currentKeys[_currentKeys.Count - 1];
@@ -184,18 +178,18 @@ sign of scroll value delta (raw delta has some big weird value and depends on fp
#endregion Keyboard.
-
+
#region Gamepad.
- for(var i = 0; i < MaxGamepadCount; i += 1)
+ for (var i = 0; i < MaxGamepadCount; i += 1)
{
- _previousGamepadState[i] = _gamepadState[i];
-
- _gamepadState[i] = GamePad.GetState(i,GamepadDeadzoneType);
+ _oldGamepadState[i] = _gamepadState[i];
+
+ _gamepadState[i] = GamePad.GetState(i, GamepadDeadzoneType);
- _previousGamepadButtons[i] = _gamepadButtons[i];
+ _oldGamepadButtons[i] = _gamepadButtons[i];
_gamepadButtons[i] = new List();
-
+
// AW YISS
if (_gamepadState[i].DPad.Left == ButtonState.Pressed)
@@ -214,7 +208,7 @@ sign of scroll value delta (raw delta has some big weird value and depends on fp
{
_gamepadButtons[i].Add(Buttons.GamepadDown);
}
-
+
if (_gamepadState[i].Buttons.A == ButtonState.Pressed)
{
_gamepadButtons[i].Add(Buttons.GamepadA);
@@ -231,7 +225,7 @@ sign of scroll value delta (raw delta has some big weird value and depends on fp
{
_gamepadButtons[i].Add(Buttons.GamepadY);
}
-
+
if (_gamepadState[i].Buttons.LeftShoulder == ButtonState.Pressed)
{
_gamepadButtons[i].Add(Buttons.GamepadLB);
@@ -240,7 +234,7 @@ sign of scroll value delta (raw delta has some big weird value and depends on fp
{
_gamepadButtons[i].Add(Buttons.GamepadRB);
}
-
+
if (_gamepadState[i].Triggers.Left > GamepadTriggersDeadzone)
{
_gamepadButtons[i].Add(Buttons.GamepadLT);
@@ -270,7 +264,7 @@ sign of scroll value delta (raw delta has some big weird value and depends on fp
}
#endregion Gamepad.
-
+
}
@@ -285,12 +279,9 @@ public static bool CheckButton(Buttons button, int index = 0)
{
var buttonCode = (int)button;
- var result =
- index < _gamepadButtons.Length && !_gamepadCleared && _gamepadButtons[0].Contains(button)
+ return index < _gamepadButtons.Length && !_gamepadCleared && _gamepadButtons[index].Contains(button)
|| buttonCode < _keyboardMaxCode && !_keyboardCleared && _currentKeys.Contains((Keys)button)
- || buttonCode < _mouseMaxCode && !_mouseCleared && _mouseButtons.Contains(button);
-
- return result;
+ || buttonCode < _mouseMaxCode && !_mouseCleared && _mouseButtons.Contains(button);
}
@@ -303,12 +294,9 @@ public static bool CheckButtonPress(Buttons button, int index = 0)
{
var buttonCode = (int)button;
- var result =
- index < _gamepadButtons.Length && !_gamepadCleared && _gamepadButtons[0].Contains(button) && _previousGamepadButtons[0].Contains(button)
- || buttonCode < _keyboardMaxCode && !_keyboardCleared && _currentKeys.Contains((Keys)button) && !_previousKeys.Contains((Keys)button)
- || buttonCode < _mouseMaxCode && !_mouseCleared && _mouseButtons.Contains(button) && !_previousMouseButtons.Contains(button);
-
- return result;
+ return index < _gamepadButtons.Length && !_gamepadCleared && _gamepadButtons[index].Contains(button) && !_oldGamepadButtons[index].Contains(button)
+ || buttonCode < _keyboardMaxCode && !_keyboardCleared && _currentKeys.Contains((Keys)button) && !_oldKeys.Contains((Keys)button)
+ || buttonCode < _mouseMaxCode && !_mouseCleared && _mouseButtons.Contains(button) && !_oldMouseButtons.Contains(button);
}
@@ -321,16 +309,13 @@ public static bool CheckButtonRelease(Buttons button, int index = 0)
{
var buttonCode = (int)button;
- var result =
- index < _gamepadButtons.Length && !_gamepadCleared && !_gamepadButtons[0].Contains(button) && _previousGamepadButtons[0].Contains(button)
- || buttonCode < _keyboardMaxCode && !_keyboardCleared && !_currentKeys.Contains((Keys)button) && _previousKeys.Contains((Keys)button)
- || buttonCode < _mouseMaxCode && !_mouseCleared && !_mouseButtons.Contains(button) && _previousMouseButtons.Contains(button);
-
- return result;
+ return index < _gamepadButtons.Length && !_gamepadCleared && !_gamepadButtons[index].Contains(button) && _oldGamepadButtons[index].Contains(button)
+ || buttonCode < _keyboardMaxCode && !_keyboardCleared && !_currentKeys.Contains((Keys)button) && _oldKeys.Contains((Keys)button)
+ || buttonCode < _mouseMaxCode && !_mouseCleared && !_mouseButtons.Contains(button) && _oldMouseButtons.Contains(button);
}
#endregion Button checks.
-
+
#region Mouse.
@@ -340,7 +325,7 @@ public static bool CheckButtonRelease(Buttons button, int index = 0)
///
public static void ClearMouseInput() =>
_mouseCleared = true;
-
+
#endregion Mouse.
@@ -350,22 +335,22 @@ public static void ClearMouseInput() =>
///
/// Checks if any keyboard key in down in current step.
///
- public static bool KeyboardCheckAnyKey() =>
+ public static bool KeyboardCheckAnyKey() =>
!_keyboardCleared && _currentKeys.Count > 0;
-
+
///
/// Checks if any keyboard key in pressed.
///
- public static bool KeyboardCheckAnyKeyPress() =>
- !_keyboardCleared && _currentKeys.Count > 0 && _previousKeys.Count == 0;
+ public static bool KeyboardCheckAnyKeyPress() =>
+ !_keyboardCleared && _currentKeys.Count > 0 && _oldKeys.Count == 0;
///
/// Checks if any keyboard key in released.
///
- public static bool KeyboardCheckAnyKeyRelease() =>
- !_keyboardCleared && _currentKeys.Count == 0 && _previousKeys.Count > 0;
+ public static bool KeyboardCheckAnyKeyRelease() =>
+ !_keyboardCleared && _currentKeys.Count == 0 && _oldKeys.Count > 0;
///
@@ -396,18 +381,22 @@ internal static void GamepadInit()
{
// Creating a bunch of dummy objects just to get rid of null ref exception.
_gamepadButtons = new List[_maxGamepadCount];
- for(var i = 0; i < _gamepadButtons.Length; i += 1)
+ for (var i = 0; i < _gamepadButtons.Length; i += 1)
{
_gamepadButtons[i] = new List();
}
- _previousGamepadButtons = _gamepadButtons;
+ _oldGamepadButtons = new List[_maxGamepadCount];
+ for (var i = 0; i < _oldGamepadButtons.Length; i += 1)
+ {
+ _oldGamepadButtons[i] = new List();
+ }
_gamepadState = new GamePadState[_maxGamepadCount];
- for(var i = 0; i < _gamepadState.Length; i += 1)
+ for (var i = 0; i < _gamepadState.Length; i += 1)
{
_gamepadState[i] = new GamePadState();
}
- _previousGamepadState = _gamepadState;
+ _oldGamepadState = _gamepadState;
}
@@ -436,7 +425,7 @@ public static Vector2 GamepadGetLeftStick(int index)
return Vector2.Zero;
}
-
+
///
/// Returns vector of right thumb stick.
///
@@ -449,7 +438,7 @@ public static Vector2 GamepadGetRightStick(int index)
return Vector2.Zero;
}
-
+
///
/// Returns value of pressure on left trigger.
/// NOTE: If you don't need exact pressure value, use GamepadCheck* functions.
@@ -480,18 +469,18 @@ public static float GamepadGetRightTrigger(int index)
///
/// Sets vibration to the given gamepad.
///
- public static void GamepadSetVibration(int index, float leftMotor, float rightMotor) =>
+ public static void GamepadSetVibration(int index, float leftMotor, float rightMotor) =>
GamePad.SetVibration(index, leftMotor, rightMotor);
-
+
///
/// Clears gamepad input, including triggers and thumb sticks.
///
public static void ClearGamepadInput() =>
_gamepadCleared = true;
-
+
#endregion Gamepad.
-
+
///
/// Clears mouse, keyboard and gamepad input.
diff --git a/Monofoxe/Monofoxe.Engine/Monofoxe.Engine.csproj b/Monofoxe/Monofoxe.Engine/Monofoxe.Engine.csproj
index 74870e35..7204bd4f 100644
--- a/Monofoxe/Monofoxe.Engine/Monofoxe.Engine.csproj
+++ b/Monofoxe/Monofoxe.Engine/Monofoxe.Engine.csproj
@@ -1,41 +1,23 @@
-
- netstandard2.0
- false
- 2.0.0-dev
- Martenfur
- Chai Foxes
- Monofoxe Engine
- A Monogame-based game engine with extremely high fox concenration.
- https://github.com/Martenfur/Monofoxe/
- https://github.com/Martenfur/Monofoxe/
-
-
+
+ netstandard2.0
+ false
+ true
+ ..\bin\$(Configuration)\
+ ..\bin\$(Configuration)\$(AssemblyName).xml
+ 1701;1702;1591
+ true
+
-
- ..\bin\Debug\
- ..\bin\Debug\Monofoxe.Engine.xml
- 1701;1702;1591
- true
-
-
-
- ..\bin\Release\
- ..\bin\Release\Monofoxe.Engine.xml
- true
-
-
-
-
- NU1701
-
-
-
-
-
- PreserveNewest
-
-
+
+
+ All
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
diff --git a/Monofoxe/Monofoxe.Engine/Platform.cs b/Monofoxe/Monofoxe.Engine/Platform.cs
new file mode 100644
index 00000000..153f6be3
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine/Platform.cs
@@ -0,0 +1,16 @@
+
+namespace Monofoxe.Engine
+{
+ public enum Platform
+ {
+ Windows,
+ Linux,
+ MacOS,
+ Android,
+ iOS, // stinky
+ Xbox,
+ PlayStation,
+ Switch,
+ Other
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine/ResourceInfoMgr.cs b/Monofoxe/Monofoxe.Engine/ResourceInfoMgr.cs
new file mode 100644
index 00000000..cf99e356
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine/ResourceInfoMgr.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+
+namespace Monofoxe.Engine
+{
+ ///
+ /// Provides convenient resource paths and lists all content assets.
+ ///
+ public static class ResourceInfoMgr
+ {
+ ///
+ /// Root directory of the game content.
+ ///
+ public static string ContentDir = "Content";
+
+
+ ///
+ /// List of all game ssets.
+ ///
+ private static string[] _assetPaths;
+
+
+
+ internal static void Init()
+ {
+ try
+ {
+ _assetPaths = GameMgr.Game.Content.Load("Content");
+ }
+ catch(Exception) { }
+ }
+
+
+
+ ///
+ /// Returns list of resource paths matching input path.
+ /// Empty string will return all asset paths.
+ ///
+ public static string[] GetResourcePaths(string path = "")
+ {
+ if (_assetPaths == null)
+ {
+ return null;
+ }
+ path = path.Replace('\\', '/');
+
+ if (path != "")
+ {
+ var list = new List();
+
+ if (!path.EndsWith("/"))
+ {
+ path += '/';
+ }
+ foreach(var info in _assetPaths)
+ {
+ if (info.StartsWith(path))
+ {
+ list.Add(info);
+ }
+ }
+
+ return list.ToArray();
+ }
+ else
+ {
+ var assetPathsCopy = new string[_assetPaths.Length];
+ _assetPaths.CopyTo(assetPathsCopy, 0);
+ return assetPathsCopy;
+ }
+ }
+
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine/Resources/DirectoryResourceBox.cs b/Monofoxe/Monofoxe.Engine/Resources/DirectoryResourceBox.cs
new file mode 100644
index 00000000..02fb08b4
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine/Resources/DirectoryResourceBox.cs
@@ -0,0 +1,63 @@
+using Microsoft.Xna.Framework.Content;
+using Monofoxe.Engine;
+using Monofoxe.Engine.Resources;
+using System;
+using System.Diagnostics;
+using System.IO;
+
+namespace Monofoxe.Resources
+{
+ ///
+ /// Loads all content from a specified directory.
+ /// NOTE: All content files in the directory should be
+ /// of the same type!!!
+ ///
+ public class DirectoryResourceBox : ResourceBox
+ {
+ private static ContentManager _content;
+
+ private readonly string _resourceDir;
+
+ public DirectoryResourceBox(string name, string resourceDir) : base(name)
+ {
+ _resourceDir = resourceDir;
+ }
+
+ public override void Load()
+ {
+ if (Loaded)
+ {
+ return;
+ }
+ Loaded = true;
+
+ _content = new ContentManager(GameMgr.Game.Services);
+ _content.RootDirectory = ResourceInfoMgr.ContentDir;
+
+ // TODO: Add Recursive flag to GetResourcePaths.
+ var paths = ResourceInfoMgr.GetResourcePaths(_resourceDir);
+
+ foreach (var path in paths)
+ {
+ try
+ {
+ AddResource(Path.GetFileNameWithoutExtension(path), _content.Load(path));
+ }
+ catch (InvalidCastException)
+ {
+ Debug.WriteLine("Failed to load " + path + ". It has different type.");
+ }
+ }
+ }
+
+ public override void Unload()
+ {
+ if (!Loaded)
+ {
+ return;
+ }
+ _content.Unload();
+ }
+
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine/Resources/ResourceBox.cs b/Monofoxe/Monofoxe.Engine/Resources/ResourceBox.cs
index 8edc2814..a61e888c 100644
--- a/Monofoxe/Monofoxe.Engine/Resources/ResourceBox.cs
+++ b/Monofoxe/Monofoxe.Engine/Resources/ResourceBox.cs
@@ -14,11 +14,12 @@ public abstract class ResourceBox : IResourceBox, IEnumerable
public bool Loaded {get; protected set;}
- public abstract string Name {get;}
+ public readonly string Name;
- public ResourceBox()
+ public ResourceBox(string name)
{
- ResourceHub.AddResourceBox(Name, this);
+ Name = name;
+ ResourceHub.AddResourceBox(name, this);
}
///
@@ -47,10 +48,10 @@ public bool ContainsResource(string key) =>
_resources.ContainsKey(key);
- protected void AddResource(string key, T resource) =>
+ public void AddResource(string key, T resource) =>
_resources.Add(key, resource);
- protected void RemoveResource(string key) =>
+ public void RemoveResource(string key) =>
_resources.Remove(key);
diff --git a/Monofoxe/Monofoxe.Engine/Resources/SpriteGroupResourceBox.cs b/Monofoxe/Monofoxe.Engine/Resources/SpriteGroupResourceBox.cs
new file mode 100644
index 00000000..f90776fa
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine/Resources/SpriteGroupResourceBox.cs
@@ -0,0 +1,53 @@
+using Microsoft.Xna.Framework.Content;
+using Monofoxe.Engine;
+using Monofoxe.Engine.Drawing;
+using Monofoxe.Engine.Resources;
+using System.Collections.Generic;
+using System.IO;
+
+namespace Monofoxe.Resources
+{
+ public class SpriteGroupResourceBox : ResourceBox
+ {
+
+ private ContentManager _content = new ContentManager(GameMgr.Game.Services);
+
+ private readonly string _resourcePath;
+
+ public SpriteGroupResourceBox(string name, string spriteGroupPath) : base(name)
+ {
+ _resourcePath = spriteGroupPath;
+ }
+
+ public override void Load()
+ {
+ if (Loaded)
+ {
+ return;
+ }
+ Loaded = true;
+ var graphicsPath = Path.Combine(ResourceInfoMgr.ContentDir, _resourcePath);
+ var sprites = _content.Load>(graphicsPath);
+
+ foreach (var spritePair in sprites)
+ {
+ try
+ {
+ AddResource(Path.GetFileNameWithoutExtension(spritePair.Key), spritePair.Value);
+ }
+ catch { }
+ }
+
+ }
+
+ public override void Unload()
+ {
+ if (!Loaded)
+ {
+ return;
+ }
+ Loaded = false;
+ _content.Unload();
+ }
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine/SceneSystem/Layer.cs b/Monofoxe/Monofoxe.Engine/SceneSystem/Layer.cs
index f7afd5aa..da8f0c16 100644
--- a/Monofoxe/Monofoxe.Engine/SceneSystem/Layer.cs
+++ b/Monofoxe/Monofoxe.Engine/SceneSystem/Layer.cs
@@ -10,6 +10,8 @@
namespace Monofoxe.Engine.SceneSystem
{
+ public delegate void LayerEventDelegate(Layer layer);
+
///
/// A layer is a container for entities and components.
///
@@ -32,7 +34,7 @@ public class Layer : IEntityMethods
public bool Visible = true;
///
- /// If true, layer won't be updated.
+ /// If false, layer won't be updated.
///
public bool Enabled = true;
@@ -103,7 +105,6 @@ public bool DepthSorting
///
public List PostprocessorEffects {get; private set;} = new List();
-
internal Layer(string name, int priority, Scene scene)
{
Name = name;
@@ -123,11 +124,11 @@ internal Layer(string name, int priority, Scene scene)
public List GetEntityList() where T : Entity
{
var entities = new List();
- foreach (var entity in _entities)
+ for (var i = 0; i < _entities.Count; i += 1)
{
- if (entity is T)
+ if (_entities[i] is T)
{
- entities.Add((T)entity);
+ entities.Add((T)_entities[i]);
}
}
return entities;
@@ -138,9 +139,9 @@ public List GetEntityList() where T : Entity
///
public bool EntityExists() where T : Entity
{
- foreach(var entity in _entities)
+ for (var i = 0; i < _entities.Count; i += 1)
{
- if (entity is T)
+ if (_entities[i] is T)
{
return true;
}
@@ -153,11 +154,11 @@ public bool EntityExists() where T : Entity
///
public T FindEntity() where T : Entity
{
- foreach(var entity in _entities)
+ for (var i = 0; i < _entities.Count; i += 1)
{
- if (entity is T)
+ if (_entities[i] is T)
{
- return (T)entity;
+ return (T)_entities[i];
}
}
return null;
@@ -262,9 +263,35 @@ public void ReorderEntityToBottom(Entity entity)
#region Events.
-
+
+ ///
+ /// Triggers every frame before all entities perform Update.
+ ///
+ public event LayerEventDelegate OnPreUpdate;
+ ///
+ /// Triggers every frame after all entities perform Update.
+ ///
+ public event LayerEventDelegate OnPostUpdate;
+ ///
+ /// Triggers every frame before all entities perform FixedUpdate.
+ ///
+ public event LayerEventDelegate OnPreFixedUpdate;
+ ///
+ /// Triggers every frame after all entities perform FixedUpdate.
+ ///
+ public event LayerEventDelegate OnPostFixedUpdate;
+ ///
+ /// Triggers every frame before all entities perform Draw.
+ ///
+ public event LayerEventDelegate OnPreDraw;
+ ///
+ /// Triggers every frame after all entities perform Draw.
+ ///
+ public event LayerEventDelegate OnPostDraw;
+
internal void FixedUpdate()
{
+ OnPreFixedUpdate?.Invoke(this);
foreach (var entity in _entities)
{
if (entity.Enabled && !entity.Destroyed)
@@ -272,10 +299,12 @@ internal void FixedUpdate()
entity.FixedUpdate();
}
}
+ OnPostFixedUpdate?.Invoke(this);
}
internal void Update()
{
+ OnPreUpdate?.Invoke(this);
foreach (var entity in _entities)
{
if (entity.Enabled && !entity.Destroyed)
@@ -283,6 +312,7 @@ internal void Update()
entity.Update();
}
}
+ OnPostUpdate?.Invoke(this);
}
internal void Draw()
@@ -295,9 +325,11 @@ internal void Draw()
if (hasPostprocessing)
{
Surface.SetTarget(GraphicsMgr.CurrentCamera._postprocessorLayerBuffer, GraphicsMgr.VertexBatch.View);
- GraphicsMgr.Device.Clear(Color.TransparentBlack);
+ GraphicsMgr.Device.Clear(Color.Transparent);
}
+
+ OnPreDraw?.Invoke(this);
foreach (var entity in _depthSortedEntities)
{
if (entity.Visible && !entity.Destroyed)
@@ -305,6 +337,7 @@ internal void Draw()
entity.Draw();
}
}
+ OnPostDraw?.Invoke(this);
if (hasPostprocessing)
{
@@ -322,6 +355,8 @@ internal void Draw()
internal void DrawGUI()
{
+ // There is no need for separate DrawGUI events because layer can execute either Draw or DrawGUI once per frame.
+ OnPreDraw?.Invoke(this);
foreach (var entity in _depthSortedEntities)
{
if (entity.Visible && !entity.Destroyed)
@@ -329,6 +364,7 @@ internal void DrawGUI()
entity.Draw();
}
}
+ OnPostDraw?.Invoke(this);
}
#endregion Events.
@@ -397,13 +433,13 @@ private void ApplyPostprocessing()
if (sufraceChooser)
{
Surface.SetTarget(camera._postprocessorLayerBuffer);
- GraphicsMgr.Device.Clear(Color.TransparentBlack);
+ GraphicsMgr.Device.Clear(Color.Transparent);
camera._postprocessorBuffer.Draw(Vector2.Zero, Vector2.Zero, Vector2.One, Angle.Right, Color.White);
}
else
{
Surface.SetTarget(camera._postprocessorBuffer);
- GraphicsMgr.Device.Clear(Color.TransparentBlack);
+ GraphicsMgr.Device.Clear(Color.Transparent);
camera._postprocessorLayerBuffer.Draw(Vector2.Zero, Vector2.Zero, Vector2.One, Angle.Right, Color.White);
}
diff --git a/Monofoxe/Monofoxe.Engine/SceneSystem/Scene.cs b/Monofoxe/Monofoxe.Engine/SceneSystem/Scene.cs
index b3b767a5..5303c24d 100644
--- a/Monofoxe/Monofoxe.Engine/SceneSystem/Scene.cs
+++ b/Monofoxe/Monofoxe.Engine/SceneSystem/Scene.cs
@@ -9,6 +9,8 @@
namespace Monofoxe.Engine.SceneSystem
{
+ public delegate void SceneEventDelegate(Scene scene);
+
///
/// Container for layers.
///
@@ -28,7 +30,7 @@ public class Scene : IEntityMethods
public bool Visible = true;
///
- /// If true, scene won't be updated.
+ /// If false, scene won't be updated.
///
public bool Enabled = true;
@@ -61,9 +63,9 @@ public Scene(string name) =>
internal void Destroy()
{
- foreach (var layer in _layers)
+ for (var i = 0; i < _layers.Count; i += 1)
{
- DestroyLayer(layer);
+ DestroyLayer(_layers[i]);
}
_layers.Clear(); // Also removes newly added layers from the list.
}
@@ -125,11 +127,11 @@ public Layer this[string name]
{
get
{
- foreach (var layer in _layers)
+ for (var i = 0; i < _layers.Count; i += 1)
{
- if (string.Equals(layer.Name, name, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(_layers[i].Name, name, StringComparison.OrdinalIgnoreCase))
{
- return layer;
+ return _layers[i];
}
}
return null;
@@ -141,11 +143,11 @@ public Layer this[string name]
///
public bool TryGetLayer(string name, out Layer layer)
{
- foreach (var l in _layers)
+ for (var i = 0; i < _layers.Count; i += 1)
{
- if (string.Equals(l.Name, name, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(_layers[i].Name, name, StringComparison.OrdinalIgnoreCase))
{
- layer = l;
+ layer = _layers[i];
return true;
}
}
@@ -160,9 +162,9 @@ public bool TryGetLayer(string name, out Layer layer)
///
public bool HasLayer(string name)
{
- foreach (var layer in _layers)
+ for (var i = 0; i < _layers.Count; i += 1)
{
- if (string.Equals(layer.Name, name, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(_layers[i].Name, name, StringComparison.OrdinalIgnoreCase))
{
return true;
}
@@ -183,9 +185,9 @@ public List GetEntityList() where T : Entity
{
var entities = new List();
- foreach (var layer in _layers)
+ for (var i = 0; i < _layers.Count; i += 1)
{
- entities.AddRange(layer.GetEntityList());
+ entities.AddRange(_layers[i].GetEntityList());
}
return entities;
}
@@ -196,9 +198,9 @@ public List GetEntityList() where T : Entity
///
public bool EntityExists() where T : Entity
{
- foreach (var layer in _layers)
+ for (var i = 0; i < _layers.Count; i += 1)
{
- if (layer.EntityExists())
+ if (_layers[i].EntityExists())
{
return true;
}
@@ -212,9 +214,9 @@ public bool EntityExists() where T : Entity
///
public T FindEntity() where T : Entity
{
- foreach (var layer in _layers)
+ for (var i = 0; i < _layers.Count; i += 1)
{
- var entity = layer.FindEntity();
+ var entity = _layers[i].FindEntity();
if (entity != null)
{
return entity;
@@ -230,9 +232,9 @@ public T FindEntity() where T : Entity
public List GetEntityListByComponent() where T : Component
{
var list = new List();
- foreach (var layer in _layers)
+ for (var i = 0; i < _layers.Count; i += 1)
{
- list.AddRange(layer.GetEntityListByComponent());
+ list.AddRange(_layers[i].GetEntityListByComponent());
}
return list;
}
@@ -243,9 +245,9 @@ public List GetEntityListByComponent() where T : Component
///
public Entity FindEntityByComponent() where T : Component
{
- foreach (var layer in _layers)
+ for (var i = 0; i < _layers.Count; i += 1)
{
- var entity = layer.FindEntityByComponent();
+ var entity = _layers[i].FindEntityByComponent();
if (entity != null)
{
return entity;
@@ -262,9 +264,9 @@ public Entity FindEntityByComponent() where T : Component
public List GetComponentList() where T : Component
{
var list = new List();
- foreach (var layer in _layers)
+ for (var i = 0; i < _layers.Count; i += 1)
{
- list.AddRange(layer.GetComponentList());
+ list.AddRange(_layers[i].GetComponentList());
}
return list;
}
@@ -274,9 +276,44 @@ public List GetComponentList() where T : Component
#region Events.
+
+ ///
+ /// Triggers every frame before all layers perform Update.
+ ///
+ public event SceneEventDelegate OnPreUpdate;
+ ///
+ /// Triggers every frame after all layers perform Update.
+ ///
+ public event SceneEventDelegate OnPostUpdate;
+ ///
+ /// Triggers every frame before all layers perform FixedUpdate.
+ ///
+ public event SceneEventDelegate OnPreFixedUpdate;
+ ///
+ /// Triggers every frame after all layers perform FixedUpdate.
+ ///
+ public event SceneEventDelegate OnPostFixedUpdate;
+ ///
+ /// Triggers every frame before all non-GUI layers perform Draw.
+ ///
+ public event SceneEventDelegate OnPreDraw;
+ ///
+ /// Triggers every frame after all non-GUI layers perform Draw.
+ ///
+ public event SceneEventDelegate OnPostDraw;
+ ///
+ /// Triggers every frame before all GUI layers perform Draw.
+ ///
+ public event SceneEventDelegate OnPreDrawGUI;
+ ///
+ /// Triggers every frame after all GUI layers perform Draw.
+ ///
+ public event SceneEventDelegate OnPostDrawGUI;
+
internal void FixedUpdate()
{
+ OnPreFixedUpdate?.Invoke(this);
foreach (var layer in _layers)
{
if (layer.Enabled)
@@ -286,10 +323,12 @@ internal void FixedUpdate()
layer.FixedUpdate();
}
}
+ OnPostFixedUpdate?.Invoke(this);
}
internal void Update()
{
+ OnPreUpdate?.Invoke(this);
foreach (var layer in _layers)
{
if (layer.Enabled)
@@ -299,11 +338,13 @@ internal void Update()
layer.Update();
}
}
+ OnPostUpdate?.Invoke(this);
}
internal void Draw()
{
+ OnPreDraw?.Invoke(this);
foreach (var layer in _layers)
{
if (
@@ -317,10 +358,12 @@ internal void Draw()
layer.Draw();
}
}
+ OnPostDraw?.Invoke(this);
}
internal void DrawGUI()
{
+ OnPreDrawGUI?.Invoke(this);
foreach (var layer in _layers)
{
if (layer.Visible && layer.IsGUI)
@@ -330,6 +373,7 @@ internal void DrawGUI()
layer.DrawGUI();
}
}
+ OnPostDrawGUI?.Invoke(this);
}
#endregion Events.
diff --git a/Monofoxe/Monofoxe.Engine/SceneSystem/SceneMgr.cs b/Monofoxe/Monofoxe.Engine/SceneSystem/SceneMgr.cs
index d24d8d88..38bf920c 100644
--- a/Monofoxe/Monofoxe.Engine/SceneSystem/SceneMgr.cs
+++ b/Monofoxe/Monofoxe.Engine/SceneSystem/SceneMgr.cs
@@ -9,6 +9,8 @@
namespace Monofoxe.Engine.SceneSystem
{
+ public delegate void SceneMgrEventDelegate();
+
///
/// Manager of all scenes. Updates entities and components.
///
@@ -73,11 +75,11 @@ public static void DestroyScene(string name)
///
public static Scene GetScene(string name)
{
- foreach(var scene in _scenes)
+ for (var i = 0; i < _scenes.Count; i += 1)
{
- if (string.Equals(scene.Name, name, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(_scenes[i].Name, name, StringComparison.OrdinalIgnoreCase))
{
- return scene;
+ return _scenes[i];
}
}
return null;
@@ -88,11 +90,11 @@ public static Scene GetScene(string name)
///
public static bool TryGetScene(string name, out Scene scene)
{
- foreach(var s in _scenes)
+ for (var i = 0; i < _scenes.Count; i += 1)
{
- if (string.Equals(s.Name, name, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(_scenes[i].Name, name, StringComparison.OrdinalIgnoreCase))
{
- scene = s;
+ scene = _scenes[i];
return true;
}
}
@@ -105,9 +107,9 @@ public static bool TryGetScene(string name, out Scene scene)
///
public static bool HasScene(string name)
{
- foreach(var scene in _scenes)
+ for(var i = 0; i < _scenes.Count; i += 1)
{
- if (string.Equals(scene.Name, name, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(_scenes[i].Name, name, StringComparison.OrdinalIgnoreCase))
{
return true;
}
@@ -153,6 +155,40 @@ internal static void PostUpdateRoutine()
#region Events.
+ ///
+ /// Triggers every frame before all scenes perform Update.
+ ///
+ public static event SceneMgrEventDelegate OnPreUpdate;
+ ///
+ /// Triggers every frame after all scenes perform Update.
+ ///
+ public static event SceneMgrEventDelegate OnPostUpdate;
+ ///
+ /// Triggers every frame before all scenes perform FixedUpdate.
+ ///
+ public static event SceneMgrEventDelegate OnPreFixedUpdate;
+ ///
+ /// Triggers every frame after all scenes perform FixedUpdate.
+ ///
+ public static event SceneMgrEventDelegate OnPostFixedUpdate;
+ ///
+ /// Triggers every frame before all non-GUI layers perform Draw.
+ ///
+ public static event SceneMgrEventDelegate OnPreDraw;
+ ///
+ /// Triggers every frame after all non-GUI layers perform Draw.
+ ///
+ public static event SceneMgrEventDelegate OnPostDraw;
+ ///
+ /// Triggers every frame before all GUI layers perform Draw.
+ ///
+ public static event SceneMgrEventDelegate OnPreDrawGUI;
+ ///
+ /// Triggers every frame after all GUI layers perform Draw.
+ ///
+ public static event SceneMgrEventDelegate OnPostDrawGUI;
+
+
///
/// Executes Fixed Update events.
///
@@ -167,6 +203,7 @@ internal static void CallFixedUpdateEvents(GameTime gameTime)
TimeKeeper._elapsedTime = GameMgr.FixedUpdateRate;
+ OnPreFixedUpdate?.Invoke();
foreach(var scene in Scenes)
{
if (scene.Enabled)
@@ -176,19 +213,20 @@ internal static void CallFixedUpdateEvents(GameTime gameTime)
scene.FixedUpdate();
}
}
+ OnPostFixedUpdate?.Invoke();
}
}
-
///
/// Executes Update events.
///
internal static void CallUpdateEvents(GameTime gameTime)
{
TimeKeeper._elapsedTime = GameMgr.ElapsedTime;
-
- foreach(var scene in Scenes)
+
+ OnPreUpdate?.Invoke();
+ foreach (var scene in Scenes)
{
if (scene.Enabled)
{
@@ -197,7 +235,7 @@ internal static void CallUpdateEvents(GameTime gameTime)
scene.Update();
}
}
-
+ OnPostUpdate?.Invoke();
}
@@ -206,7 +244,8 @@ internal static void CallUpdateEvents(GameTime gameTime)
///
internal static void CallDrawEvents()
{
- foreach(var scene in Scenes)
+ OnPreDraw?.Invoke();
+ foreach (var scene in Scenes)
{
if (scene.Visible)
{
@@ -215,16 +254,17 @@ internal static void CallDrawEvents()
scene.Draw();
}
}
+ OnPostDraw?.Invoke();
}
-
///
/// Executes Draw GUI events.
///
internal static void CallDrawGUIEvents()
{
- foreach(var scene in Scenes)
+ OnPreDrawGUI?.Invoke();
+ foreach (var scene in Scenes)
{
if (scene.Visible)
{
@@ -233,6 +273,7 @@ internal static void CallDrawGUIEvents()
scene.DrawGUI();
}
}
+ OnPostDrawGUI?.Invoke();
}
#endregion Events.
diff --git a/Monofoxe/Monofoxe.Engine/StuffResolver.cs b/Monofoxe/Monofoxe.Engine/StuffResolver.cs
new file mode 100644
index 00000000..c8e9d49e
--- /dev/null
+++ b/Monofoxe/Monofoxe.Engine/StuffResolver.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+
+namespace Monofoxe.Engine
+{
+ ///
+ /// Contains (usually platform-specific) stuff.
+ ///
+ public static class StuffResolver
+ {
+ private static Dictionary _stuff = new Dictionary();
+
+
+ public static void AddStuffAs(object stuff)
+ {
+ var type = typeof(T);
+ if (!type.IsInterface)
+ {
+ throw new Exception("Provided type " + type + " has to be an interface!");
+ }
+ foreach (var i in stuff.GetType().GetInterfaces())
+ {
+ if (type == i)
+ {
+ _stuff.Add(type, stuff);
+ return;
+ }
+ }
+ throw new Exception("Object should implement interface " + type + "!");
+ }
+
+ public static T GetStuff() =>
+ (T)_stuff[typeof(T)];
+
+ public static bool StuffExists() =>
+ _stuff.ContainsKey(typeof(T));
+ }
+}
diff --git a/Monofoxe/Monofoxe.Engine/Utils/Alarm.cs b/Monofoxe/Monofoxe.Engine/Utils/Alarm.cs
index 32edec0b..79c89184 100644
--- a/Monofoxe/Monofoxe.Engine/Utils/Alarm.cs
+++ b/Monofoxe/Monofoxe.Engine/Utils/Alarm.cs
@@ -1,68 +1,110 @@
-using System;
-
+
namespace Monofoxe.Engine.Utils
{
public delegate void AlarmDelegate(Alarm caller);
+ public enum OnTriggerAction
+ {
+ ///
+ /// On reaching trigger time,
+ /// alarm resets itself to 0, triggers OnTrigger event and stops.
+ ///
+ Stop,
+
+ ///
+ /// On reaching trigger time,
+ /// alarm resets itself to 0, triggers OnTrigger event and continues counting.
+ /// In this mode, alarm takes into account leftover counter delta to make
+ /// repeated counting precise.
+ ///
+ Loop,
+
+ ///
+ /// Alarm never triggers.
+ ///
+ None,
+ }
+
///
/// Counts down seconds. Needs to be updated manually.
///
- public class Alarm : Timer
+ public class Alarm
{
///
- /// Tells how much time is left in seconds.
+ /// Tells how much time has passed in seconds.
+ ///
+ public double Counter { get; private set; } = 0;
+
+ ///
+ /// If alarm's counter reaches this value and it's not in
+ /// OnTriggerAction.None mode, alarm will call OnTrigger event.
+ ///
+ public double TriggerTime;
+
+ ///
+ /// Alarm won't update if it's paused.
///
- public new double Counter;
+ public bool Paused = false;
+
+ public TimeKeeper TimeKeeper = TimeKeeper.Global;
///
- /// Gets called in an update, if alarm is triggered.
+ /// Gets called if the alarm is triggered.
///
public event AlarmDelegate TriggerEvent;
///
- /// Tells, if alarm is running right now.
+ /// Tells, if alarm is running.
///
- public bool Running => Counter > 0;
+ public bool Running {get; private set;}
+
+ public OnTriggerAction OnTriggerAction;
- public Alarm() : base() {}
- public Alarm(TimeKeeper timeKeeper) : base(timeKeeper) {}
-
+ public Alarm(double time, OnTriggerAction onTriggerAction = OnTriggerAction.Stop)
+ {
+ TriggerTime = time;
+ OnTriggerAction = onTriggerAction;
+ }
- ///
- /// Sets alarm to given time.
- ///
- /// Time in seconds.
- public void Set(double time)
+
+ public void Start()
{
- Enabled = true;
- Counter = time;
+ Running = true;
+ Counter = 0;
}
-
-
-
- ///
- /// Resets alarm.
- ///
- public override void Reset()
+
+
+ public void Stop()
{
- Enabled = false;
+ Running = false;
Counter = 0;
}
-
///
- /// Updates alarm. Returns true, if alarm is being triggered.
+ /// Updates alarm. Returns true, if alarm was triggered.
///
- public new virtual bool Update()
+ public bool Update()
{
- if (Enabled && Counter > 0)
+ if (!Paused && Running)
{
- Counter -= TimeKeeper.Time();
+ Counter += TimeKeeper.Time();
- if (Counter <= 0)
+ if (
+ OnTriggerAction != OnTriggerAction.None
+ && Counter >= TriggerTime
+ )
{
+ if (OnTriggerAction == OnTriggerAction.Stop)
+ {
+ Running = false;
+ Counter = 0;
+ }
+ if (OnTriggerAction == OnTriggerAction.Loop)
+ {
+ Counter -= TriggerTime; // Necessary for correct timing.
+ }
TriggerEvent?.Invoke(this);
return true;
}
diff --git a/Monofoxe/Monofoxe.Engine/Utils/Angle.cs b/Monofoxe/Monofoxe.Engine/Utils/Angle.cs
index ac3ab899..4e38bb44 100644
--- a/Monofoxe/Monofoxe.Engine/Utils/Angle.cs
+++ b/Monofoxe/Monofoxe.Engine/Utils/Angle.cs
@@ -209,17 +209,8 @@ public override bool Equals(object obj)
#endregion Operators.
- public override int GetHashCode()
- {
- // No idea, lul.
- var hashCode = 129319411;
- hashCode = hashCode * -1521134295 + Degrees.GetHashCode();
- hashCode = hashCode * -1521134295 + Radians.GetHashCode();
- hashCode = hashCode * -1521134295 + DegreesF.GetHashCode();
- hashCode = hashCode * -1521134295 + RadiansF.GetHashCode();
- hashCode = hashCode * -1521134295 + _degrees.GetHashCode();
- return hashCode;
- }
+ public override int GetHashCode() =>
+ _degrees.GetHashCode();
public override string ToString() =>
_degrees.ToString();
diff --git a/Monofoxe/Monofoxe.Engine/Utils/AutoAlarm.cs b/Monofoxe/Monofoxe.Engine/Utils/AutoAlarm.cs
deleted file mode 100644
index 84f8b323..00000000
--- a/Monofoxe/Monofoxe.Engine/Utils/AutoAlarm.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-
-namespace Monofoxe.Engine.Utils
-{
- ///
- /// Counts down seconds. Needs to be updated manually. Sets itself automatically after triggering.
- ///
- public class AutoAlarm : Alarm
- {
- public double Time;
-
- public AutoAlarm(double time)
- {
- Time = time;
- Set(Time);
- }
-
- public AutoAlarm(double time, TimeKeeper timeKeeper) : base(timeKeeper)
- {
- Time = time;
- Set(Time);
- }
-
-
- ///
- /// Updates alarm. Returns true, if alarm is being triggered.
- ///
- public override bool Update()
- {
- if (base.Update())
- {
- Counter += Time;
- return true;
- }
- return false;
- }
- }
-}
diff --git a/Monofoxe/Monofoxe.Engine/Utils/Foxe.cs b/Monofoxe/Monofoxe.Engine/Utils/Foxe.cs
index a2a65fbc..57ba7be6 100644
--- a/Monofoxe/Monofoxe.Engine/Utils/Foxe.cs
+++ b/Monofoxe/Monofoxe.Engine/Utils/Foxe.cs
@@ -27,11 +27,11 @@ public sealed class Foxe : Entity
private Foxe(Layer layer) : base(layer)
{
- _stealAlarm = new Alarm();
+ _stealAlarm = new Alarm(_rng.NextDouble(_minStealTime, _maxStealTime));
_rng = new RandomExt();
- _stealAlarm.Set(_rng.NextDouble(_minStealTime, _maxStealTime));
+ _stealAlarm.Start();
}
public override void Update()
@@ -49,7 +49,8 @@ public override void Update()
chosenEntity.Layer = Layer;
}
- _stealAlarm.Set(_rng.NextDouble(_minStealTime, _maxStealTime));
+ _stealAlarm.TriggerTime = _rng.NextDouble(_minStealTime, _maxStealTime);
+ _stealAlarm.Start();
}
}
diff --git a/Monofoxe/Monofoxe.Engine/Utils/Timer.cs b/Monofoxe/Monofoxe.Engine/Utils/Timer.cs
deleted file mode 100644
index e8e667b4..00000000
--- a/Monofoxe/Monofoxe.Engine/Utils/Timer.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-
-namespace Monofoxe.Engine.Utils
-{
- ///
- /// Counts seconds. Has to be updated manually.
- ///
- public class Timer
- {
- ///
- /// Tells how much time has passed in seconds.
- ///
- public virtual double Counter {get; protected set;} = 0;
-
- ///
- /// Timer won't update if it's disabled.
- ///
- public bool Enabled = true;
-
- public TimeKeeper TimeKeeper = TimeKeeper.Global;
-
- public Timer() {}
- public Timer(TimeKeeper timeKeeper) =>
- TimeKeeper = timeKeeper;
-
-
- ///
- /// Resets timer.
- ///
- public virtual void Reset()
- {
- Enabled = false;
- Counter = 0;
- }
-
-
-
- ///
- /// Updates timer.
- ///
- public virtual void Update()
- {
- if (Enabled)
- {
- Counter += TimeKeeper.Time();
- }
- }
-
- }
-}
diff --git a/Monofoxe/Monofoxe.Engine/Vector2Extensions.cs b/Monofoxe/Monofoxe.Engine/Vector2Extensions.cs
index a010eb2f..66f29334 100644
--- a/Monofoxe/Monofoxe.Engine/Vector2Extensions.cs
+++ b/Monofoxe/Monofoxe.Engine/Vector2Extensions.cs
@@ -70,5 +70,30 @@ public static Vector2 Swap(this Vector2 v) =>
public static Vector2 Rotate90(this Vector2 v) =>
new Vector2(v.Y, -v.X);
+ ///
+ /// Rotates vector by the given angle.
+ ///
+ public static Vector2 Rotate(this Vector2 v, Angle angle)
+ {
+ var e = angle.ToVector2();
+
+ return new Vector2(
+ v.X * e.X - v.Y * e.Y,
+ v.X * e.Y + v.Y * e.X
+ );
+ }
+
+ ///
+ /// Rotates vector by the given direction vector.
+ /// NOTE: Rotation vector should be unit vector.
+ ///
+ public static Vector2 Rotate(this Vector2 v, Vector2 rotationVector)
+ {
+ return new Vector2(
+ v.X * rotationVector.X - v.Y * rotationVector.Y,
+ v.X * rotationVector.Y + v.Y * rotationVector.X
+ );
+ }
+
}
}
diff --git a/Monofoxe/Pipefoxe/Logger.cs b/Monofoxe/Monofoxe.Pipeline/Logger.cs
similarity index 93%
rename from Monofoxe/Pipefoxe/Logger.cs
rename to Monofoxe/Monofoxe.Pipeline/Logger.cs
index bd8d1d93..919cf0b2 100644
--- a/Monofoxe/Pipefoxe/Logger.cs
+++ b/Monofoxe/Monofoxe.Pipeline/Logger.cs
@@ -1,56 +1,56 @@
-using System;
-using System.IO;
-
-namespace Pipefoxe
-{
- ///
- /// Simple logger class. Writes info into a log file.
- /// Used for debugging.
- ///
- public static class Logger
- {
- #if DEBUG
- public static bool EnableLogging = true;
- #else
- public static bool EnableLogging = false;
- #endif
-
- private static string _filePath;
-
- ///
- /// Initializes log file.
- ///
- public static void Init(string fileName)
- {
- if (EnableLogging)
- {
- _filePath = Environment.CurrentDirectory + "/" + fileName;
- File.WriteAllText(_filePath, "");
- }
- }
-
- ///
- /// Writes a message and a new line into a log file.
- ///
- public static void LogLine(string message)
- {
- if (EnableLogging)
- {
- File.AppendAllText(_filePath, message + Environment.NewLine);
- }
- }
-
-
- ///
- /// Writes a message into a log file.
- ///
- public static void Log(string message)
- {
- if (EnableLogging)
- {
- File.AppendAllText(_filePath, message);
- }
- }
-
- }
-}
+using System;
+using System.IO;
+
+namespace Monofoxe.Pipeline
+{
+ ///
+ /// Simple logger class. Writes info into a log file.
+ /// Used for debugging.
+ ///
+ public static class Logger
+ {
+ #if DEBUG
+ public static bool EnableLogging = true;
+ #else
+ public static bool EnableLogging = false;
+ #endif
+
+ private static string _filePath;
+
+ ///
+ /// Initializes log file.
+ ///
+ public static void Init(string fileName)
+ {
+ if (EnableLogging)
+ {
+ _filePath = Environment.CurrentDirectory + "/" + fileName;
+ File.WriteAllText(_filePath, "");
+ }
+ }
+
+ ///
+ /// Writes a message and a new line into a log file.
+ ///
+ public static void LogLine(string message)
+ {
+ if (EnableLogging)
+ {
+ File.AppendAllText(_filePath, message + Environment.NewLine);
+ }
+ }
+
+
+ ///
+ /// Writes a message into a log file.
+ ///
+ public static void Log(string message)
+ {
+ if (EnableLogging)
+ {
+ File.AppendAllText(_filePath, message);
+ }
+ }
+
+ }
+}
diff --git a/Monofoxe/Monofoxe.Pipeline/Monofoxe.Pipeline.csproj b/Monofoxe/Monofoxe.Pipeline/Monofoxe.Pipeline.csproj
new file mode 100644
index 00000000..2a84b10b
--- /dev/null
+++ b/Monofoxe/Monofoxe.Pipeline/Monofoxe.Pipeline.csproj
@@ -0,0 +1,21 @@
+
+
+ netstandard2.0
+ false
+ true
+ ..\bin\$(Configuration)\
+ NU5100
+
+
+
+
+
+ All
+
+
+ All
+
+
+
+
+
\ No newline at end of file
diff --git a/Monofoxe/Monofoxe.Pipeline/ResourceInfo/ResourceInfoImporter.cs b/Monofoxe/Monofoxe.Pipeline/ResourceInfo/ResourceInfoImporter.cs
new file mode 100644
index 00000000..60cac071
--- /dev/null
+++ b/Monofoxe/Monofoxe.Pipeline/ResourceInfo/ResourceInfoImporter.cs
@@ -0,0 +1,62 @@
+using System.Collections.Generic;
+using System.IO;
+using Microsoft.Xna.Framework.Content.Pipeline;
+
+// Inspired by:
+// https://github.com/Ragath/MonoGame.AssetInfo
+
+
+namespace Monofoxe.Pipeline.ResourceInfo
+{
+ ///
+ /// Asset info importer. Reads .mcgb file and extracts all asset paths.
+ ///
+ [ContentImporter(".npl", DisplayName = "Resource Info Importer - Monofoxe", DefaultProcessor = "PassThroughProcessor")]
+ public class ResourceInfoImporter : ContentImporter
+ {
+ private const string _buildTag = "/build:";
+ private const string _copyTag = "/copy:";
+
+ public override string[] Import(string filename, ContentImporterContext context)
+ {
+ // Since 3.8, pipeline cannot import its own mgcb files as resources,
+ // so we have to reference npl config instead and swap it for mgcb.
+ filename = Path.ChangeExtension(filename, ".mgcb");
+
+ var lines = File.ReadAllLines(filename);
+
+ var resources = new List();
+
+ for(var i = 0; i < lines.Length; i += 1)
+ {
+ if (lines[i].StartsWith(_buildTag))
+ {
+ var resourcePath = Dereference(lines[i].Remove(0, _buildTag.Length));
+
+ resourcePath = Path.Combine(Path.GetDirectoryName(resourcePath), Path.GetFileNameWithoutExtension(resourcePath));
+
+ resources.Add(resourcePath.Replace('\\', '/'));
+ continue;
+ }
+ if (lines[i].StartsWith(_copyTag))
+ {
+ var resourcePath = Dereference(lines[i].Remove(0, _copyTag.Length));
+
+ // If resource is being copied, we'll need to leave its extension.
+ resources.Add(resourcePath.Replace('\\', '/'));
+ }
+ }
+
+ return resources.ToArray();
+ }
+
+ private string Dereference(string path)
+ {
+ if (path.Contains(";"))
+ {
+ return path.Split(';')[1];
+ }
+ return path;
+ }
+ }
+}
diff --git a/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/BinaryOperationNode.cs b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/BinaryOperationNode.cs
new file mode 100644
index 00000000..e23f3582
--- /dev/null
+++ b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/BinaryOperationNode.cs
@@ -0,0 +1,30 @@
+using System;
+
+namespace Monofoxe.Pipeline.SpriteGroup.AST
+{
+ class BinaryOperationNode : Node
+ {
+
+ public BinaryOperationNode(Node lhs, Node rhs, Func op)
+ {
+ _lhs = lhs;
+ _rhs = rhs;
+ _op = op;
+ }
+
+ Node _lhs;
+ Node _rhs;
+ Func _op;
+
+ public override int Eval()
+ {
+
+ var lhsVal = _lhs.Eval();
+ var rhsVal = _rhs.Eval();
+
+ var result = _op(lhsVal, rhsVal);
+ return result;
+ }
+ }
+}
+
diff --git a/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/Node.cs b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/Node.cs
new file mode 100644
index 00000000..211ff5a8
--- /dev/null
+++ b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/Node.cs
@@ -0,0 +1,8 @@
+namespace Monofoxe.Pipeline.SpriteGroup.AST
+{
+ abstract class Node
+ {
+ public abstract int Eval();
+ }
+}
+
diff --git a/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/NumberNode.cs b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/NumberNode.cs
new file mode 100644
index 00000000..7576cdb6
--- /dev/null
+++ b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/NumberNode.cs
@@ -0,0 +1,18 @@
+namespace Monofoxe.Pipeline.SpriteGroup.AST
+{
+ class NumberNode : Node
+ {
+ public NumberNode(int number)
+ {
+ _number = number;
+ }
+
+ int _number;
+
+ public override int Eval()
+ {
+ return _number;
+ }
+ }
+}
+
diff --git a/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/SpriteGroupMathTokenizer.cs b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/SpriteGroupMathTokenizer.cs
new file mode 100644
index 00000000..4b923f62
--- /dev/null
+++ b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/SpriteGroupMathTokenizer.cs
@@ -0,0 +1,139 @@
+using System.IO;
+using System.Text;
+
+namespace Monofoxe.Pipeline.SpriteGroup.AST
+{
+ ///
+ /// This class just goes char by char parsing the text
+ /// works alongside to parse an expresion
+ ///
+ // based on https://medium.com/@toptensoftware/writing-a-simple-math-expression-engine-in-c-d414de18d4ce
+ public class SpriteGroupMathTokenizer
+ {
+ public enum Token
+ {
+ Sum = '+',
+ Sub = '-',
+ Mul = '*',
+ Div = '/',
+ OpenParenthesis = '(',
+ CloseParenthesis = ')',
+ Number = 0,
+ ConstantTop = 1,
+ ConstantBottom = 2,
+ ConstantLeft = 3,
+ ConstantRight = 4,
+ ConstantCenter = 5,
+ EOF = -1
+ }
+
+ public Token CurrentToken { get; private set; }
+
+ public int Number { get; private set; }
+
+ TextReader _textReader;
+ char _currentChar;
+ StringBuilder _builder;
+ string _text;
+ public SpriteGroupMathTokenizer(string text)
+ {
+ _builder = new StringBuilder(text);
+ _builder.Replace("center", "c")
+ .Replace("top", "t")
+ .Replace("bottom", "b")
+ .Replace("left", "l")
+ .Replace("right", "r");
+
+ _text = _builder.ToString();
+ _textReader = new StringReader(_text);
+ _builder.Clear();
+ NextChar();
+ NextToken();
+ }
+ ///
+ /// This methods gets the next token, this also gets numeric values if it results being a number
+ ///
+ public void NextToken()
+ {
+ while (char.IsWhiteSpace(_currentChar))
+ {
+ NextChar();
+ }
+ switch (_currentChar)
+ {
+ case '\0':
+ CurrentToken = Token.EOF;
+ return;
+
+ case '+':
+ NextChar();
+ CurrentToken = Token.Sum;
+ return;
+
+ case '-':
+ NextChar();
+ CurrentToken = Token.Sub;
+ return;
+ case '*':
+ NextChar();
+ CurrentToken = Token.Mul;
+ return;
+
+ case '/':
+ NextChar();
+ CurrentToken = Token.Div;
+ return;
+ case 't':
+ NextChar();
+ CurrentToken = Token.ConstantTop;
+ return;
+
+ case 'b':
+ NextChar();
+ CurrentToken = Token.ConstantBottom;
+ return;
+ case 'r':
+ NextChar();
+ CurrentToken = Token.ConstantRight;
+ return;
+
+ case 'l':
+ NextChar();
+ CurrentToken = Token.ConstantLeft;
+ return;
+ case 'c':
+ NextChar();
+ CurrentToken = Token.ConstantCenter;
+ return;
+ case '(':
+ NextChar();
+ CurrentToken = Token.OpenParenthesis;
+ return;
+
+ case ')':
+ NextChar();
+ CurrentToken = Token.CloseParenthesis;
+ return;
+ }
+ if (char.IsDigit(_currentChar))
+ {
+ while (char.IsDigit(_currentChar))
+ {
+ _builder.Append(_currentChar);
+ NextChar();
+ }
+ Number = int.Parse(_builder.ToString());
+ CurrentToken = Token.Number;
+ _builder.Clear();
+ return;
+ }
+ }
+ void NextChar()
+ {
+ int ch = _textReader.Read();
+ _currentChar = ch < 0 ? '\0' : (char)ch;
+ }
+
+ }
+
+}
diff --git a/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/TokenNotExpectedException.cs b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/TokenNotExpectedException.cs
new file mode 100644
index 00000000..a6e4bcfc
--- /dev/null
+++ b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/TokenNotExpectedException.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Runtime.Serialization;
+
+namespace Monofoxe.Pipeline.SpriteGroup.AST
+{
+ [Serializable]
+ internal class TokenNotExpectedException : Exception
+ {
+ public TokenNotExpectedException()
+ {
+ }
+
+ public TokenNotExpectedException(string message) : base(message)
+ {
+ }
+
+ public TokenNotExpectedException(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+
+ protected TokenNotExpectedException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
+ }
+}
diff --git a/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/UnaryOperationNode.cs b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/UnaryOperationNode.cs
new file mode 100644
index 00000000..fc031c63
--- /dev/null
+++ b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/AST/UnaryOperationNode.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace Monofoxe.Pipeline.SpriteGroup.AST
+{
+ class UnaryOperationNode : Node
+ {
+ public UnaryOperationNode(Node num, Func op)
+ {
+ _num = num;
+ _op = op;
+ }
+ Node _num;
+ Func _op;
+
+ public override int Eval()
+ {
+ int num = _num.Eval();
+
+ return _op(num);
+ }
+ }
+}
diff --git a/Monofoxe/Monofoxe.Pipeline/SpriteGroup/Bmp.cs b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/Bmp.cs
new file mode 100644
index 00000000..ef6c1f11
--- /dev/null
+++ b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/Bmp.cs
@@ -0,0 +1,151 @@
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
+using StbImageSharp;
+using System.IO;
+
+namespace Monofoxe.Pipeline.SpriteGroup
+{
+ public class Bmp
+ {
+ private Color[] _pixels;
+
+ public readonly int Width;
+ public readonly int Height;
+
+ public Bmp(string filePath)
+ {
+ using (var stream = File.OpenRead(filePath))
+ {
+ var image = ImageResult.FromStream(stream, ColorComponents.RedGreenBlueAlpha);
+ var data = image.Data;
+ Width = image.Width;
+ Height = image.Height;
+
+ _pixels = new Color[Width * Height];
+ for (var i = 0; i < data.Length / 4; i += 1)
+ {
+ var alpha = data[i * 4 + 3];
+ if (alpha != 0)
+ {
+ _pixels[i] = new Color(data[i * 4], data[i * 4 + 1], data[i * 4 + 2], alpha);
+ }
+ else
+ {
+ _pixels[i] = Color.Transparent; // XNA zeroes pixels with 0 alpha.
+ }
+ }
+ }
+ }
+
+
+ public Bmp(int width, int height)
+ {
+ Width = width;
+ Height = height;
+
+ _pixels = new Color[Width * Height];
+ }
+
+
+ ///
+ /// Draws given bitmap on a current one.
+ ///
+ public void Draw(Bmp bmp, int x, int y)
+ {
+ for (var yy = 0; yy < bmp.Height; yy += 1)
+ {
+ for (var xx = 0; xx < bmp.Width; xx += 1)
+ {
+ DrawPixel(bmp.GetPixel(xx, yy, new Rectangle(0, 0, Width, Height)), x + xx, y + yy);
+ }
+ }
+ }
+
+
+ ///
+ /// Draws given bitmap on a current one.
+ ///
+ public void Draw(Bmp bmp, int x, int y, Rectangle srcRectangle, int padding = 0)
+ {
+ for (var yy = -padding; yy < srcRectangle.Height + padding; yy += 1)
+ {
+ for (var xx = -padding; xx < srcRectangle.Width + padding; xx += 1)
+ {
+ DrawPixel(
+ bmp.GetPixel(
+ xx + srcRectangle.X,
+ yy + srcRectangle.Y,
+ srcRectangle
+ ),
+ x + xx,
+ y + yy
+ );
+ }
+ }
+ }
+
+
+ public void Write(ContentWriter writer)
+ {
+ writer.Write(Width);
+ writer.Write(Height);
+ for(var i = 0; i < _pixels.Length; i += 1)
+ {
+ writer.Write(_pixels[i]);
+ }
+ }
+
+
+ private Color GetPixelUnchecked(int x, int y) =>
+ _pixels[Width * y + x];
+
+
+ private Color GetPixel(int x, int y, Rectangle bounds)
+ {
+ if (x < bounds.X)
+ {
+ x = bounds.X;
+ }
+ if (y < bounds.Y)
+ {
+ y = bounds.Y;
+ }
+ if (x >= bounds.X + bounds.Width)
+ {
+ x = bounds.X + bounds.Width - 1;
+ }
+ if (y >= bounds.Y + bounds.Height)
+ {
+ y = bounds.Y + bounds.Height - 1;
+ }
+
+ if (x < 0)
+ {
+ x = 0;
+ }
+ if (y < 0)
+ {
+ y = 0;
+ }
+ if (x >= Width)
+ {
+ x = Width - 1;
+ }
+ if (y >= Height)
+ {
+ y = Height - 1;
+ }
+
+ return GetPixelUnchecked(x, y);
+ }
+
+ private void DrawPixel(Color pixel, int x, int y)
+ {
+ if (x < 0 || y < 0 || x >= Width || y >= Height)
+ {
+ return;
+ }
+ _pixels[Width * y + x] = pixel;
+ }
+ }
+}
diff --git a/Monofoxe/Pipefoxe/SpriteGroup/Frame.cs b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/Frame.cs
similarity index 54%
rename from Monofoxe/Pipefoxe/SpriteGroup/Frame.cs
rename to Monofoxe/Monofoxe.Pipeline/SpriteGroup/Frame.cs
index e36f9ec1..b95ad27a 100644
--- a/Monofoxe/Pipefoxe/SpriteGroup/Frame.cs
+++ b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/Frame.cs
@@ -1,10 +1,11 @@
-using System.Drawing;
-
-namespace Pipefoxe.SpriteGroup
-{
- public class Frame
- {
- public Rectangle TexturePos;
- public int TextureIndex;
- }
-}
+
+using Microsoft.Xna.Framework;
+
+namespace Monofoxe.Pipeline.SpriteGroup
+{
+ public class Frame
+ {
+ public Rectangle TexturePos;
+ public int TextureIndex;
+ }
+}
diff --git a/Monofoxe/Pipefoxe/SpriteGroup/RawSprite.cs b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/RawSprite.cs
similarity index 71%
rename from Monofoxe/Pipefoxe/SpriteGroup/RawSprite.cs
rename to Monofoxe/Monofoxe.Pipeline/SpriteGroup/RawSprite.cs
index 10056707..07d26ab5 100644
--- a/Monofoxe/Pipefoxe/SpriteGroup/RawSprite.cs
+++ b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/RawSprite.cs
@@ -1,20 +1,20 @@
-using System.Collections.Generic;
-using System.Drawing;
-
-namespace Pipefoxe.SpriteGroup
-{
- public class RawSprite
- {
- public string Name = "NONE";
- public int FramesH = 1;
- public int FramesV = 1;
- public Point Offset = new Point(0, 0);
- public Image RawTexture;
- public List Frames = new List ();
-
- ///
- /// Tells how many frames were already rendered to the atlas.
- ///
- public int RenderedFrames = 0;
- }
-}
+using Microsoft.Xna.Framework;
+using System.Collections.Generic;
+
+namespace Monofoxe.Pipeline.SpriteGroup
+{
+ public class RawSprite
+ {
+ public string Name = "NONE";
+ public int FramesH = 1;
+ public int FramesV = 1;
+ public Point Offset = new Point(0, 0);
+ public Bmp RawTexture;
+ public List Frames = new List ();
+
+ ///
+ /// Tells how many frames were already rendered to the atlas.
+ ///
+ public int RenderedFrames = 0;
+ }
+}
diff --git a/Monofoxe/Pipefoxe/SpriteGroup/SpriteGroupData.cs b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/SpriteGroupData.cs
similarity index 74%
rename from Monofoxe/Pipefoxe/SpriteGroup/SpriteGroupData.cs
rename to Monofoxe/Monofoxe.Pipeline/SpriteGroup/SpriteGroupData.cs
index 505a6473..82dad0f0 100644
--- a/Monofoxe/Pipefoxe/SpriteGroup/SpriteGroupData.cs
+++ b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/SpriteGroupData.cs
@@ -1,37 +1,30 @@
-using System.Collections.Generic;
-
-namespace Pipefoxe.SpriteGroup
-{
- public class SpriteGroupData
- {
- ///
- /// Size of a single texture atlas. Should be power of 2.
- ///
- public int AtlasSize;
-
- ///
- /// Space between textures on atlas. Will be filled with border pixels.
- ///
- public int TexturePadding;
-
- ///
- /// Full path to source sprites.
- ///
- public string RootDir;
-
- ///
- /// Name of sprite group. Equals to file name.
- ///
- public string GroupName;
-
- public string ClassTemplatePath;
-
- ///
- /// Class files will be stored in this directory.
- ///
- public string ClassOutputDir;
-
- public List Sprites = new List();
- public List SingleTextures = new List();
- }
-}
+using System.Collections.Generic;
+
+namespace Monofoxe.Pipeline.SpriteGroup
+{
+ public class SpriteGroupData
+ {
+ ///
+ /// Size of a single texture atlas. Should be power of 2.
+ ///
+ public int AtlasSize;
+
+ ///
+ /// Space between textures on atlas. Will be filled with border pixels.
+ ///
+ public int TexturePadding;
+
+ ///
+ /// Full path to source sprites.
+ ///
+ public string RootDir;
+
+ ///
+ /// Name of sprite group. Equals to file name.
+ ///
+ public string GroupName;
+
+ public List Sprites = new List();
+ public List SingleTextures = new List();
+ }
+}
diff --git a/Monofoxe/Pipefoxe/SpriteGroup/SpriteGroupImporter.cs b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/SpriteGroupImporter.cs
similarity index 62%
rename from Monofoxe/Pipefoxe/SpriteGroup/SpriteGroupImporter.cs
rename to Monofoxe/Monofoxe.Pipeline/SpriteGroup/SpriteGroupImporter.cs
index 71fea1fa..05c1d074 100644
--- a/Monofoxe/Pipefoxe/SpriteGroup/SpriteGroupImporter.cs
+++ b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/SpriteGroupImporter.cs
@@ -1,226 +1,198 @@
-using System;
-using System.Drawing;
-using System.IO;
-using System.Text.RegularExpressions;
-using Microsoft.Xna.Framework.Content.Pipeline;
-using Newtonsoft.Json.Linq;
-
-/*
- * FUTURE NOTE:
- * To create Pipeline Extension project,
- * choose C# Class Library template,
- * then reference Monogame for Desktop GL
- * and get Monogame.Framework.Content.Pipeline
- * from NuGet.
- *
- * To add library to pipeline project, reference
- * dll with project name.
- */
-namespace Pipefoxe.SpriteGroup
-{
-
- ///
- /// Sprite group importer. Parses json config, and loads textures,
- /// which will be passed to AtlasProcessor.
- ///
- [ContentImporter(".spritegroup", DefaultProcessor = "SpriteGroupProcessor",
- DisplayName = "Sprite Group Importer - Monofoxe")]
- public class SpriteGroupImporter : ContentImporter
- {
- /*
- * Offset keywords are used to quickly set
- * sprite offsets to center or any side, without
- * knowing actual sprite size.
- */
- const string keywordCenter = "center";
- const string keywordTop = "top";
- const string keywordBottom = "bottom";
- const string keywordLeft = "left";
- const string keywordRight = "right";
-
-
- public override SpriteGroupData Import(string filename, ContentImporterContext context)
- {
- var groupData = new SpriteGroupData();
-
- string[] textureRegex;
-
- #region Parsing config.
-
- try
- {
- var json = File.ReadAllText(filename);
- JToken configData = JObject.Parse(json);
-
- groupData.AtlasSize = int.Parse(configData["atlasSize"].ToString());
- groupData.TexturePadding = int.Parse(configData["texturePadding"].ToString());
- groupData.RootDir = Path.GetDirectoryName(filename) + '/' + configData["rootDir"].ToString();
- groupData.GroupName = Path.GetFileNameWithoutExtension(filename);
- groupData.ClassTemplatePath = configData["classTemplatePath"].ToString();
- groupData.ClassOutputDir = configData["classOutputDir"].ToString();
-
- SpriteGroupWriter.DebugMode = bool.Parse(configData["debugMode"].ToString());
- SpriteGroupWriter.DebugDir = Environment.CurrentDirectory + "/" + groupData.GroupName + "_dbg";
-
- var textureWildcards = (JArray)configData["singleTexturesWildcards"];
-
- textureRegex = new string[textureWildcards.Count];
- for(var i = 0; i < textureWildcards.Count; i += 1)
- {
- textureRegex[i] = WildCardToRegular(textureWildcards[i].ToString());
- }
- }
- catch(Exception)
- {
- throw new InvalidContentException("Incorrect JSON format!");
- }
-
- #endregion Parsing config.
-
-
- ImportTextures(groupData.RootDir, "", groupData, textureRegex);
-
- return groupData;
-
- }
-
-
-
- ///
- /// Recursively looks into root dir and loads textures.
- ///
- /// Full path to directory.
- /// Full path minus root.
- /// SpriteGroupData object.
- /// Regex filter. Determines if texture is part of atlas or single.
- private void ImportTextures(string dirPath, string dirName, SpriteGroupData groupData, string[] textureRegex)
- {
- var dirInfo = new DirectoryInfo(dirPath);
-
- foreach(var file in dirInfo.GetFiles("*.png"))
- {
- var spr = new RawSprite();
- spr.Name = dirName + Path.GetFileNameWithoutExtension(file.Name);
- spr.RawTexture = Image.FromFile(file.FullName);
-
- var configPath = Path.ChangeExtension(file.FullName, ".json");
-
-
- #region Reading config.
- /*
- * Just reading sprite jsons.
- * If you want to add more parameters, begin from here.
- */
- if (File.Exists(configPath))
- {
- try
- {
- var conf = File.ReadAllText(configPath);
- JToken confData = JObject.Parse(conf);
-
- spr.FramesH = int.Parse(confData["h"].ToString());
- spr.FramesV = int.Parse(confData["v"].ToString());
-
- if (spr.FramesH < 1 || spr.FramesV < 1) // Frame amount cannot be lesser than 1.
- {
- throw new Exception();
- }
-
- var xOffsetRaw = confData["offset_x"].ToString().ToLower();
- var yOffsetRaw = confData["offset_y"].ToString().ToLower();
-
- int xOffset, yOffset;
-
- // Hey, look, switch is being useful for once! :000
-
- // Parsing offset keywords.
- switch(xOffsetRaw)
- {
- case keywordCenter:
- xOffset = spr.RawTexture.Width / spr.FramesH / 2;
- break;
- case keywordLeft:
- xOffset = 0;
- break;
- case keywordRight:
- xOffset = spr.RawTexture.Width / spr.FramesH;
- break;
- default:
- xOffset = int.Parse(xOffsetRaw);
- break;
- }
-
- switch(yOffsetRaw)
- {
- case keywordCenter:
- yOffset = spr.RawTexture.Height / spr.FramesV / 2;
- break;
- case keywordTop:
- yOffset = 0;
- break;
- case keywordBottom:
- yOffset = spr.RawTexture.Height / spr.FramesV;
- break;
- default:
- yOffset = int.Parse(yOffsetRaw);
- break;
- }
- // Parsing offset keywords.
-
- spr.Offset = new Point(xOffset, yOffset);
-
- }
- catch(Exception)
- {
- throw new Exception("Error while pasring sprite JSON for file: " + file.Name);
- }
- }
- #endregion Reading config.
-
-
- if (PathMatchesRegex('/' + dirName + '/' + file.Name, textureRegex)) // Separating atlas sprites from single textures.
- {
- groupData.SingleTextures.Add(spr);
- }
- else
- {
- groupData.Sprites.Add(spr);
- }
- }
-
-
- // Recursively repeating for all subdirectories.
- foreach(var dir in dirInfo.GetDirectories())
- {
- ImportTextures(dir.FullName, dirName + dir.Name + '/', groupData, textureRegex);
- }
- // Recursively repeating for all subdirectories.
-
- }
-
-
-
- private string WildCardToRegular(string value) =>
- "^" + Regex.Escape(value).Replace("\\*", ".*") + "$";
-
-
-
- ///
- /// Checks if path matches regex filter.
- ///
- private bool PathMatchesRegex(string path, string[] regexArray)
- {
- var safePath = path.Replace('\\', '/'); // Just to not mess with regex and wildcards.
-
- foreach(var regex in regexArray)
- {
- if (Regex.IsMatch(safePath, regex, RegexOptions.IgnoreCase))
- {
- return true;
- }
- }
- return false;
- }
-
- }
-}
+using System;
+using System.IO;
+using System.Text.RegularExpressions;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Content.Pipeline;
+using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
+using Newtonsoft.Json.Linq;
+using StbImageSharp;
+
+/*
+ * FUTURE NOTE:
+ * To create Pipeline Extension project,
+ * choose C# Class Library template,
+ * then reference Monogame for Desktop GL
+ * and get Monogame.Framework.Content.Pipeline
+ * from NuGet.
+ *
+ * To add library to pipeline project, reference
+ * dll with project name.
+ */
+namespace Monofoxe.Pipeline.SpriteGroup
+{
+
+ ///
+ /// Sprite group importer. Parses json config, and loads textures,
+ /// which will be passed to AtlasProcessor.
+ ///
+ [ContentImporter(".spritegroup", DefaultProcessor = "SpriteGroupProcessor",
+ DisplayName = "Sprite Group Importer - Monofoxe")]
+ public class SpriteGroupImporter : ContentImporter
+ {
+
+ public override SpriteGroupData Import(string filename, ContentImporterContext context)
+ {
+ var groupData = new SpriteGroupData();
+
+ string[] textureRegex;
+
+ #region Parsing config.
+
+ try
+ {
+ var json = File.ReadAllText(filename);
+ JToken configData = JObject.Parse(json);
+
+ groupData.AtlasSize = int.Parse(configData["atlasSize"].ToString());
+ groupData.TexturePadding = int.Parse(configData["texturePadding"].ToString());
+ groupData.RootDir = Path.GetDirectoryName(filename) + '/' + configData["rootDir"].ToString();
+ groupData.GroupName = Path.GetFileNameWithoutExtension(filename);
+
+ var textureWildcards = (JArray)configData["singleTexturesWildcards"];
+
+ textureRegex = new string[textureWildcards.Count];
+ for (var i = 0; i < textureWildcards.Count; i += 1)
+ {
+ textureRegex[i] = WildCardToRegular(textureWildcards[i].ToString());
+ }
+ }
+ catch (Exception)
+ {
+ throw new InvalidContentException("Incorrect JSON format!");
+ }
+
+ #endregion Parsing config.
+
+
+ ImportTextures(groupData.RootDir, "", groupData, textureRegex);
+
+ return groupData;
+
+ }
+
+
+
+ ///
+ /// Recursively looks into root dir and loads textures.
+ ///
+ /// Full path to directory.
+ /// Full path minus root.
+ /// SpriteGroupData object.
+ /// Regex filter. Determines if texture is part of atlas or single.
+ private void ImportTextures(string dirPath, string dirName, SpriteGroupData groupData, string[] textureRegex)
+ {
+ var dirInfo = new DirectoryInfo(dirPath);
+
+ foreach (var file in dirInfo.GetFiles("*.png"))
+ {
+ var spr = new RawSprite();
+ spr.Name = dirName + Path.GetFileNameWithoutExtension(file.Name);
+
+ spr.RawTexture = new Bmp(file.FullName);
+
+ var configPath = Path.ChangeExtension(file.FullName, ".json");
+
+
+ #region Reading config.
+ /*
+ * Just reading sprite jsons.
+ * If you want to add more parameters, begin from here.
+ */
+ if (File.Exists(configPath))
+ {
+ try
+ {
+ var conf = File.ReadAllText(configPath);
+ JToken confData = JObject.Parse(conf);
+
+ spr.FramesH = int.Parse(confData["h"].ToString());
+ spr.FramesV = int.Parse(confData["v"].ToString());
+
+ if (spr.FramesH < 1 || spr.FramesV < 1) // Frame amount cannot be lesser than 1.
+ {
+ throw new Exception();
+ }
+
+
+ var originXKeyword = "originX";
+ var originYKeyword = "originY";
+
+ if (confData[originXKeyword] == null)
+ {
+ originXKeyword = "offset_x";
+ }
+ if (confData[originYKeyword] == null)
+ {
+ originYKeyword = "offset_y";
+ }
+
+ var xOffsetRaw = confData[originXKeyword].ToString().ToLower();
+ var yOffsetRaw = confData[originYKeyword].ToString().ToLower();
+
+ var center = new Point(spr.RawTexture.Width / spr.FramesH / 2, spr.RawTexture.Height / spr.FramesV / 2);
+
+ spr.Offset = SpriteGroupMathParser.Parse(
+ xOffsetRaw,
+ yOffsetRaw,
+ 0,
+ spr.RawTexture.Width / spr.FramesH,
+ 0,
+ spr.RawTexture.Height / spr.FramesV,
+ center
+ );
+
+ }
+ catch (Exception e)
+ {
+ throw new Exception("Error while pasring sprite JSON for file: " + file.Name + " | " + e.Message + " | " + e.StackTrace);
+ }
+ }
+ #endregion Reading config.
+
+
+ if (PathMatchesRegex('/' + dirName + '/' + file.Name, textureRegex)) // Separating atlas sprites from single textures.
+ {
+ groupData.SingleTextures.Add(spr);
+ }
+ else
+ {
+ groupData.Sprites.Add(spr);
+ }
+ }
+
+
+ // Recursively repeating for all subdirectories.
+ foreach (var dir in dirInfo.GetDirectories())
+ {
+ ImportTextures(dir.FullName, dirName + dir.Name + '/', groupData, textureRegex);
+ }
+ // Recursively repeating for all subdirectories.
+
+ }
+
+
+
+ private string WildCardToRegular(string value) =>
+ "^" + Regex.Escape(value).Replace("\\*", ".*") + "$";
+
+
+
+ ///
+ /// Checks if path matches regex filter.
+ ///
+ private bool PathMatchesRegex(string path, string[] regexArray)
+ {
+ var safePath = path.Replace('\\', '/'); // Just to not mess with regex and wildcards.
+
+ foreach (var regex in regexArray)
+ {
+ if (Regex.IsMatch(safePath, regex, RegexOptions.IgnoreCase))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ }
+}
diff --git a/Monofoxe/Monofoxe.Pipeline/SpriteGroup/SpriteGroupMathParser.cs b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/SpriteGroupMathParser.cs
new file mode 100644
index 00000000..65496330
--- /dev/null
+++ b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/SpriteGroupMathParser.cs
@@ -0,0 +1,229 @@
+using Microsoft.Xna.Framework;
+using Monofoxe.Pipeline.SpriteGroup.AST;
+using System;
+using static Monofoxe.Pipeline.SpriteGroup.AST.SpriteGroupMathTokenizer;
+
+namespace Monofoxe.Pipeline.SpriteGroup
+{
+ ///
+ /// This class parses the expresion and returns the number that corresponds to it
+ /// Might be slow since it uses recursion to parse the expresion
+ /// Not benchmarked yet
+ ///
+ // Based on the code by Brad Robinson in this Medium Article https://medium.com/@toptensoftware/writing-a-simple-math-expression-engine-in-c-d414de18d4ce
+ public static class SpriteGroupMathParser
+ {
+
+ private static SpriteGroupMathTokenizer _tokenizer;
+ private static int ConstantLeft;
+ private static int ConstantRight;
+ private static int ConstantTop;
+ private static int ConstantBottom;
+ private static int ConstantCenter;
+
+ ///
+ /// Parses the offset and resolves the math expressions
+ ///
+ /// first string to parse
+ /// second string to parse
+ /// value of the "Left" keyword constant
+ /// value of the "Right" keyword constant
+ /// value of the "Top" keyword constant
+ /// value of the "Bottom" keyword constant
+ /// value of the component"Center" keyword constant
+ /// A point with the parsed X and Y positions
+ public static Point Parse(
+ string textX,
+ string textY,
+ int constantLeft,
+ int constantRight,
+ int constantTop,
+ int constantBottom,
+ Point constantCenter
+ )
+ {
+ Point res = new Point();
+ ConstantBottom = constantBottom;
+ ConstantLeft = constantLeft;
+ ConstantRight = constantRight;
+ ConstantTop = constantTop;
+ ConstantCenter = constantCenter.X;
+
+ _tokenizer = new SpriteGroupMathTokenizer(textX);
+ var expr1 = ParseAddSubstract();
+ res.X = expr1.Eval();
+ if (_tokenizer.CurrentToken != Token.EOF)
+ {
+ throw new TokenNotExpectedException("Unexpected characters at end of expression");
+ }
+
+ ConstantCenter = constantCenter.Y;
+ _tokenizer = new SpriteGroupMathTokenizer(textY);
+ var expr2 = ParseAddSubstract();
+ res.Y = expr2.Eval();
+ if (_tokenizer.CurrentToken != Token.EOF)
+ {
+ throw new TokenNotExpectedException("Unexpected characters at end of expression");
+ }
+ return res;
+ }
+
+ ///
+ /// Handles Unary expresions, this let us negate expresions (even be redundant like 10 + +1)
+ /// It reuses the and to handle it
+ ///
+ /// The Unary expresion reduced
+ private static Node ParseUnary()
+ {
+ switch (_tokenizer.CurrentToken)
+ {
+ case Token.Sum:
+ {
+ _tokenizer.NextToken();
+ return ParseUnary();
+ }
+ case Token.Sub:
+ {
+ _tokenizer.NextToken();
+
+ Node rhs = ParseUnary(); // recursive methods are fun, this let us be as redundant as we want
+
+ return new UnaryOperationNode(rhs, a => -a);
+ }
+ }
+ return ParseLeaf();
+ }
+
+ ///
+ /// Handles sums and substraction, it follows PEMDAS by asking if their left hand side and right hand side are multiplication
+ ///
+ ///
+ private static Node ParseAddSubstract()
+ {
+ Node lhs = ParseMultiplyDivide();
+
+ while (true)
+ {
+ Func op = null;
+ switch (_tokenizer.CurrentToken)
+ {
+ case Token.Sum:
+ {
+ op = (a, b) => a + b;
+ break;
+ }
+ case Token.Sub:
+ {
+ op = (a, b) => a - b;
+ break;
+ }
+ }
+ if (op == null)
+ {
+ return lhs;
+ }
+ _tokenizer.NextToken();
+
+ Node rhs = ParseMultiplyDivide();
+ lhs = new BinaryOperationNode(lhs, rhs, op);
+ }
+
+ }
+
+ ///
+ /// Resolves Multiplication and division in PEMDAS order, let resolve negatives and such expresions
+ ///
+ ///
+ private static Node ParseMultiplyDivide()
+ {
+ Node lhs = ParseUnary();
+
+ while (true)
+ {
+ Func op = null;
+ switch (_tokenizer.CurrentToken)
+ {
+ case Token.Mul:
+ {
+ op = (a, b) => a * b;
+ break;
+ }
+ case Token.Div:
+ {
+ op = (a, b) => a / b;
+ break;
+ }
+ }
+ if (op == null)
+ {
+ return lhs;
+ }
+ _tokenizer.NextToken();
+
+ Node rhs = ParseUnary();
+ lhs = new BinaryOperationNode(lhs, rhs, op);
+ }
+ }
+
+ ///
+ /// This recognize our terminal elements, like number and constants, also reduce parenthesis expresions
+ ///
+ /// Terminal element
+ private static Node ParseLeaf()
+ {
+ switch (_tokenizer.CurrentToken)
+ {
+ case Token.Number:
+ {
+ _tokenizer.NextToken();
+ return new NumberNode(_tokenizer.Number);
+ }
+ case Token.OpenParenthesis:
+ {
+ _tokenizer.NextToken();
+ Node node = ParseAddSubstract();
+
+ if (_tokenizer.CurrentToken != Token.CloseParenthesis)
+ {
+ throw new Exception("Missing Close Parenthesis");
+ }
+ _tokenizer.NextToken();
+
+ return node;
+ }
+ case Token.ConstantBottom:
+ {
+ _tokenizer.NextToken();
+ return new NumberNode(ConstantBottom);
+ }
+ case Token.ConstantTop:
+ {
+ _tokenizer.NextToken();
+ return new NumberNode(ConstantTop);
+ }
+ case Token.ConstantRight:
+ {
+ _tokenizer.NextToken();
+ return new NumberNode(ConstantRight);
+ }
+ case Token.ConstantLeft:
+ {
+ _tokenizer.NextToken();
+ return new NumberNode(ConstantLeft);
+ }
+ case Token.ConstantCenter:
+ {
+ _tokenizer.NextToken();
+ return new NumberNode(ConstantCenter);
+ }
+ default:
+ {
+ throw new TokenNotExpectedException($"Unexpected token: {_tokenizer.CurrentToken}");
+ }
+ }
+ }
+
+ }
+
+}
+
diff --git a/Monofoxe/Pipefoxe/SpriteGroup/SpriteGroupProcessor.cs b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/SpriteGroupProcessor.cs
similarity index 70%
rename from Monofoxe/Pipefoxe/SpriteGroup/SpriteGroupProcessor.cs
rename to Monofoxe/Monofoxe.Pipeline/SpriteGroup/SpriteGroupProcessor.cs
index 8a0d5038..d05043fb 100644
--- a/Monofoxe/Pipefoxe/SpriteGroup/SpriteGroupProcessor.cs
+++ b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/SpriteGroupProcessor.cs
@@ -1,93 +1,82 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Linq;
-using Microsoft.Xna.Framework.Content.Pipeline;
-
-namespace Pipefoxe.SpriteGroup
-{
- [ContentProcessor(DisplayName = "Sprite Group Processor - Monofoxe")]
- public class SpriteGroupProcessor : ContentProcessor, List)>
- {
- public override (List, List) Process(SpriteGroupData groupData, ContentProcessorContext context)
- {
- // Packing sprites into texture atlases.
- var atlasResult = TexturePacker.PackTextures(groupData.Sprites, groupData.AtlasSize, groupData.TexturePadding, groupData.GroupName);
- List sprites = atlasResult.spriteInfo;
- List atlases = atlasResult.atlases;
- // Packing sprites into texture atlases.
-
- var singleTextureResult = ProcessSingleTextures(atlases.Count, groupData.SingleTextures);
- // Now atlas sprites and singles got same format and we can merge them into one texture\sprite list.
- sprites = sprites.Concat(singleTextureResult.spriteInfo).ToList();
- atlases = atlases.Concat(singleTextureResult.textures).ToList();
-
- ClassGenerator.Generate(
- groupData.RootDir + '/' + groupData.ClassTemplatePath,
- Environment.CurrentDirectory + groupData.ClassOutputDir,
- sprites,
- groupData.GroupName
- );
-
- return (sprites, atlases);
- }
-
-
-
- ///
- /// Single textures can also be spritesheets.
- /// Function generates frame arrays for input sprites according to sheet data
- /// and splits frames into single textures.
- ///
- /// We already got atlases, so we need to index new textures with that in mind.
- ///
- ///
- private (List spriteInfo, List textures)
- ProcessSingleTextures(int startingIndex, List sprites)
- {
- var textures = new List();
- var spriteInfo = new List();
-
- var textureIndex = startingIndex;
-
- // Input sprites got no frames.
- foreach(var sprite in sprites)
- {
- int frameW = sprite.RawTexture.Width / sprite.FramesH;
- int frameH = sprite.RawTexture.Height / sprite.FramesV;
-
- for(var frameId = 0; frameId < sprite.FramesH * sprite.FramesV; frameId += 1)
- {
- var frame = new Frame();
- frame.TextureIndex = textureIndex;
- frame.TexturePos = new Rectangle(0, 0, frameW, frameH);
-
- // Calculating texture coordinates out of frame index.
- int x = (frameId % sprite.FramesH) * frame.TexturePos.Width;
- int y = (frameId / sprite.FramesH) * frame.TexturePos.Height;
-
- var texture = new Bitmap(frameW, frameH);
- var graphics = Graphics.FromImage(texture);
- graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
-
- // These are single texture sprites. This means that each frame has to be separate texture.
- graphics.DrawImage(
- sprite.RawTexture,
- frame.TexturePos,
- new Rectangle(x, y, frameW, frameH),
- GraphicsUnit.Pixel
- );
-
- graphics.Dispose();
-
- textureIndex += 1;
- sprite.Frames.Add(frame);
- textures.Add(texture);
- }
- spriteInfo.Add(sprite);
- }
-
- return (spriteInfo, textures);
- }
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Content.Pipeline;
+
+namespace Monofoxe.Pipeline.SpriteGroup
+{
+ [ContentProcessor(DisplayName = "Sprite Group Processor - Monofoxe")]
+ public class SpriteGroupProcessor : ContentProcessor, List)>
+ {
+ public override (List, List) Process(SpriteGroupData groupData, ContentProcessorContext context)
+ {
+ // Packing sprites into texture atlases.
+ var atlasResult = TexturePacker.PackTextures(groupData.Sprites, groupData.AtlasSize, groupData.TexturePadding, groupData.GroupName);
+ List sprites = atlasResult.spriteInfo;
+ List atlases = atlasResult.atlases;
+ // Packing sprites into texture atlases.
+
+ var singleTextureResult = ProcessSingleTextures(atlases.Count, groupData.SingleTextures);
+ // Now atlas sprites and singles got same format and we can merge them into one texture\sprite list.
+ sprites = sprites.Concat(singleTextureResult.spriteInfo).ToList();
+ atlases = atlases.Concat(singleTextureResult.textures).ToList();
+
+ return (sprites, atlases);
+ }
+
+
+
+ ///
+ /// Single textures can also be spritesheets.
+ /// Function generates frame arrays for input sprites according to sheet data
+ /// and splits frames into single textures.
+ ///
+ /// We already got atlases, so we need to index new textures with that in mind.
+ ///
+ ///
+ private (List spriteInfo, List textures)
+ ProcessSingleTextures(int startingIndex, List sprites)
+ {
+ var textures = new List();
+ var spriteInfo = new List();
+
+ var textureIndex = startingIndex;
+
+ // Input sprites got no frames.
+ foreach(var sprite in sprites)
+ {
+ int frameW = sprite.RawTexture.Width / sprite.FramesH;
+ int frameH = sprite.RawTexture.Height / sprite.FramesV;
+
+ for(var frameId = 0; frameId < sprite.FramesH * sprite.FramesV; frameId += 1)
+ {
+ var frame = new Frame();
+ frame.TextureIndex = textureIndex;
+ frame.TexturePos = new Rectangle(0, 0, frameW, frameH);
+
+ // Calculating texture coordinates out of frame index.
+ int x = (frameId % sprite.FramesH) * frame.TexturePos.Width;
+ int y = (frameId / sprite.FramesH) * frame.TexturePos.Height;
+
+ var texture = new Bmp(frameW, frameH);
+
+ // These are single texture sprites. This means that each frame has to be separate texture.
+ texture.Draw(
+ sprite.RawTexture,
+ 0, 0,
+ new Rectangle(x, y, frameW, frameH)
+ );
+
+
+ textureIndex += 1;
+ sprite.Frames.Add(frame);
+ textures.Add(texture);
+ }
+ spriteInfo.Add(sprite);
+ }
+
+ return (spriteInfo, textures);
+ }
+ }
+}
diff --git a/Monofoxe/Pipefoxe/SpriteGroup/SpriteGroupWriter.cs b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/SpriteGroupWriter.cs
similarity index 52%
rename from Monofoxe/Pipefoxe/SpriteGroup/SpriteGroupWriter.cs
rename to Monofoxe/Monofoxe.Pipeline/SpriteGroup/SpriteGroupWriter.cs
index 33ed04dd..417ec34b 100644
--- a/Monofoxe/Pipefoxe/SpriteGroup/SpriteGroupWriter.cs
+++ b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/SpriteGroupWriter.cs
@@ -1,147 +1,95 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.IO;
-using System.Text;
-using Microsoft.Xna.Framework.Content.Pipeline;
-using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
-using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
-
-namespace Pipefoxe.SpriteGroup
-{
- ///
- /// Atlas writer. Gets sprite data from processor and writes it into a file.
- ///
- [ContentTypeWriter]
- public class SpriteGroupWriter : ContentTypeWriter<(List, List)>
- {
- public static bool DebugMode = false;
- public static string DebugDir = "";
-
-
- protected override void Write(ContentWriter output, (List, List) value)
- {
- /*
- * File structure:
- * - Textures count (int)
- *
- * For each texture:
- * - Texture (TextureContent)
- *
- * - Sprites count (int)
- *
- * For each sprite:
- * - Sprite name (string)
- * - Origin x (int)
- * - Origin y (int)
- * - Width (int)
- * - Height (int)
- * - Amount of frames (int)
- *
- * For each frame:
- * - Texture id (int)
- * - Texture x (int)
- * - Texture y (int)
- *
- * So, in other words, file is divided into two sections:
- * array of textures and array of sprites.
- */
-
- var sprites = value.Item1;
- var bitmaps = value.Item2;
-
- if (DebugMode)
- {
- DumpDebugData(sprites, bitmaps);
- }
-
- // Writing textures.
- output.Write(bitmaps.Count);
-
- var tempFilePath = Environment.CurrentDirectory + "/temp.temp";
- // There is no easy way to convert Bitmap to TextureContent, as I'm aware.
- // So, we need to save Bitmap as a file and then import it using TextureImporter.
- // ¯\_(ツ)_/¯
- foreach(var bitmap in bitmaps)
- {
- bitmap.Save(tempFilePath);
- var textureImporter = new TextureImporter();
- var texture = textureImporter.Import(tempFilePath, null);
- output.WriteObject(texture);
- }
- File.Delete(tempFilePath);
- // Writing textures.
-
-
- // Writing sprites.
- output.Write(sprites.Count);
- foreach(var sprite in sprites)
- {
- output.Write(sprite.Name);
-
- output.Write(sprite.Offset.X);
- output.Write(sprite.Offset.Y);
-
- output.Write(sprite.Frames[0].TexturePos.Width);
- output.Write(sprite.Frames[0].TexturePos.Height);
-
- output.Write(sprite.Frames.Count);
-
- foreach(var frame in sprite.Frames)
- {
- output.Write(frame.TextureIndex);
- output.Write(frame.TexturePos.X);
- output.Write(frame.TexturePos.Y);
- }
- }
- // Writing sprites.
- }
-
-
-
- public override string GetRuntimeType(TargetPlatform targetPlatform) =>
- typeof (Tuple, List>).AssemblyQualifiedName;
-
-
-
- public override string GetRuntimeReader(TargetPlatform targetPlatform) =>
- "Monofoxe.Engine.ContentReaders.SpriteGroupReader, Monofoxe.Engine";
-
-
-
- private void DumpDebugData(List sprites, List bitmaps)
- {
- if (Directory.Exists(DebugDir))
- {
- Directory.Delete(DebugDir, true);
- }
- Directory.CreateDirectory(DebugDir);
-
- // Dumping textures.
- var index = 0;
- foreach(var bitmap in bitmaps)
- {
- bitmap.Save(DebugDir + "/texture_" + index + ".png");
- index += 1;
- }
- // Dumping textures.
-
- var spriteInfo = new StringBuilder();
-
- foreach(var sprite in sprites)
- {
- spriteInfo.Append(sprite.Name);
- spriteInfo.Append(" " + sprite.FramesH + 'x' + sprite.FramesV);
- spriteInfo.Append(" offset:" + sprite.Offset);
- spriteInfo.Append(Environment.NewLine);
- foreach(var frame in sprite.Frames)
- {
- spriteInfo.Append("\t" + frame.TextureIndex + Environment.NewLine);
- spriteInfo.Append("\t" + frame.TexturePos + Environment.NewLine);
- }
- }
- spriteInfo.Append(Environment.NewLine);
- File.WriteAllText(DebugDir + "/sprite_info.txt", spriteInfo.ToString());
- }
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.IO;
+using System.Text;
+using Microsoft.Xna.Framework.Content.Pipeline;
+using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
+using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
+
+namespace Monofoxe.Pipeline.SpriteGroup
+{
+ ///
+ /// Atlas writer. Gets sprite data from processor and writes it into a file.
+ ///
+ [ContentTypeWriter]
+ public class SpriteGroupWriter : ContentTypeWriter<(List, List)>
+ {
+
+ protected override void Write(ContentWriter output, (List, List) value)
+ {
+ /*
+ * File structure:
+ * - Textures count (int)
+ *
+ * For each texture:
+ * - Texture (TextureContent)
+ *
+ * - Sprites count (int)
+ *
+ * For each sprite:
+ * - Sprite name (string)
+ * - Origin x (int)
+ * - Origin y (int)
+ * - Width (int)
+ * - Height (int)
+ * - Amount of frames (int)
+ *
+ * For each frame:
+ * - Texture id (int)
+ * - Texture x (int)
+ * - Texture y (int)
+ *
+ * So, in other words, file is divided into two sections:
+ * array of textures and array of sprites.
+ */
+
+ var sprites = value.Item1;
+ var bitmaps = value.Item2;
+
+ // Writing textures.
+ output.Write(bitmaps.Count);
+
+ foreach(var bitmap in bitmaps)
+ {
+ bitmap.Write(output);
+ }
+ // Writing textures.
+
+
+ // Writing sprites.
+ output.Write(sprites.Count);
+ foreach(var sprite in sprites)
+ {
+ output.Write(sprite.Name);
+
+ output.Write(sprite.Offset.X);
+ output.Write(sprite.Offset.Y);
+
+ output.Write(sprite.Frames[0].TexturePos.Width);
+ output.Write(sprite.Frames[0].TexturePos.Height);
+
+ output.Write(sprite.Frames.Count);
+
+ foreach(var frame in sprite.Frames)
+ {
+ output.Write(frame.TextureIndex);
+ output.Write(frame.TexturePos.X);
+ output.Write(frame.TexturePos.Y);
+ }
+ }
+ // Writing sprites.
+ }
+
+
+
+ public override string GetRuntimeType(TargetPlatform targetPlatform) =>
+ typeof (Tuple, List>).AssemblyQualifiedName;
+
+
+
+ public override string GetRuntimeReader(TargetPlatform targetPlatform) =>
+ "Monofoxe.Engine.ContentReaders.SpriteGroupReader, Monofoxe.Engine";
+
+ }
+}
diff --git a/Monofoxe/Pipefoxe/SpriteGroup/TextureGrid.cs b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/TextureGrid.cs
similarity index 94%
rename from Monofoxe/Pipefoxe/SpriteGroup/TextureGrid.cs
rename to Monofoxe/Monofoxe.Pipeline/SpriteGroup/TextureGrid.cs
index 1f97a146..4fcd8645 100644
--- a/Monofoxe/Pipefoxe/SpriteGroup/TextureGrid.cs
+++ b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/TextureGrid.cs
@@ -1,124 +1,124 @@
-using System.Collections.Generic;
-
-namespace Pipefoxe.SpriteGroup
-{
- ///
- /// Grid with cells which can have different sizes.
- /// Each cell stores bool.
- ///
- public class TextureGrid
- {
- ///
- /// Horizontal cell coordinates.
- ///
- private List _cellsH;
-
- ///
- /// Vertical cell coordinates.
- ///
- private List _cellsV;
-
- public int Width {get => _cellsH.Count - 1;}
- public int Height {get => _cellsV.Count - 1;}
-
- ///
- /// Actual grid.
- ///
- private List> _cells;
-
- public TextureGrid(int size)
- {
- // Creating one big cell with given size and value of False.
- _cellsH = new List(new int[]{0, size});
- _cellsV = new List(new int[]{0, size});
-
- _cells = new List>();
- _cells.Add(new List());
- _cells[0].Add(false);
- }
-
- public bool this[int y, int x]
- {
- get => _cells[y][x];
- set => _cells[y][x] = value;
- }
-
- public int GetCellX(int index) =>
- _cellsH[index];
-
- public int GetCellY(int index) =>
- _cellsV[index];
-
- public int GetCellW(int index) =>
- _cellsH[index + 1] - _cellsH[index];
-
- public int GetCellH(int index) =>
- _cellsV[index + 1] - _cellsV[index];
-
- ///
- /// Splits cell column into two at given coordinate.
- ///
- public void SplitH(int newColumn)
- {
- /*
- * 0 1 6 0 1 4 6
- * |o|o| ==> |o|n|o|
- * |o|o| ==> |o|n|o|
- */
-
- int index = 0;
- for(var i = 1; i < _cellsH.Count; i += 1)
- {
- if (newColumn == _cellsH[i]) // If there is already such row, no need to add it second time.
- {
- return;
- }
-
- if (newColumn < _cellsH[i])
- {
- _cellsH.Insert(i, newColumn);
- index = i;
- break;
- }
- }
-
- foreach(List row in _cells)
- {
- row.Insert(index - 1, row[index - 1]);
- }
-
- }
-
- ///
- /// Splits cell row into two at given coordinate.
- ///
- public void SplitV(int newColumn)
- {
- /*
- * 0 |o|o| ==> 0 |o|o|
- * 6 |o|o| ==> 4 |n|n|
- * 6 |o|o|
- */
-
- int index = 0;
- for(var i = 1; i < _cellsV.Count; i += 1)
- {
- if (newColumn == _cellsV[i]) // If there is already such row, no need to add it second time.
- {
- return;
- }
-
- if (newColumn < _cellsV[i])
- {
- _cellsV.Insert(i, newColumn);
- index = i;
- break;
- }
- }
-
- var buffer = new List(_cells[index - 1]);
- _cells.Insert(index - 1, buffer);
- }
-
- }
-}
+using System.Collections.Generic;
+
+namespace Monofoxe.Pipeline.SpriteGroup
+{
+ ///
+ /// Grid with cells which can have different sizes.
+ /// Each cell stores bool.
+ ///
+ public class TextureGrid
+ {
+ ///
+ /// Horizontal cell coordinates.
+ ///
+ private List _cellsH;
+
+ ///
+ /// Vertical cell coordinates.
+ ///
+ private List _cellsV;
+
+ public int Width {get => _cellsH.Count - 1;}
+ public int Height {get => _cellsV.Count - 1;}
+
+ ///
+ /// Actual grid.
+ ///
+ private List> _cells;
+
+ public TextureGrid(int size)
+ {
+ // Creating one big cell with given size and value of False.
+ _cellsH = new List(new int[]{0, size});
+ _cellsV = new List(new int[]{0, size});
+
+ _cells = new List>();
+ _cells.Add(new List());
+ _cells[0].Add(false);
+ }
+
+ public bool this[int y, int x]
+ {
+ get => _cells[y][x];
+ set => _cells[y][x] = value;
+ }
+
+ public int GetCellX(int index) =>
+ _cellsH[index];
+
+ public int GetCellY(int index) =>
+ _cellsV[index];
+
+ public int GetCellW(int index) =>
+ _cellsH[index + 1] - _cellsH[index];
+
+ public int GetCellH(int index) =>
+ _cellsV[index + 1] - _cellsV[index];
+
+ ///
+ /// Splits cell column into two at given coordinate.
+ ///
+ public void SplitH(int newColumn)
+ {
+ /*
+ * 0 1 6 0 1 4 6
+ * |o|o| ==> |o|n|o|
+ * |o|o| ==> |o|n|o|
+ */
+
+ int index = 0;
+ for(var i = 1; i < _cellsH.Count; i += 1)
+ {
+ if (newColumn == _cellsH[i]) // If there is already such row, no need to add it second time.
+ {
+ return;
+ }
+
+ if (newColumn < _cellsH[i])
+ {
+ _cellsH.Insert(i, newColumn);
+ index = i;
+ break;
+ }
+ }
+
+ foreach(List row in _cells)
+ {
+ row.Insert(index - 1, row[index - 1]);
+ }
+
+ }
+
+ ///
+ /// Splits cell row into two at given coordinate.
+ ///
+ public void SplitV(int newColumn)
+ {
+ /*
+ * 0 |o|o| ==> 0 |o|o|
+ * 6 |o|o| ==> 4 |n|n|
+ * 6 |o|o|
+ */
+
+ int index = 0;
+ for(var i = 1; i < _cellsV.Count; i += 1)
+ {
+ if (newColumn == _cellsV[i]) // If there is already such row, no need to add it second time.
+ {
+ return;
+ }
+
+ if (newColumn < _cellsV[i])
+ {
+ _cellsV.Insert(i, newColumn);
+ index = i;
+ break;
+ }
+ }
+
+ var buffer = new List(_cells[index - 1]);
+ _cells.Insert(index - 1, buffer);
+ }
+
+ }
+}
diff --git a/Monofoxe/Pipefoxe/SpriteGroup/TexturePacker.cs b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/TexturePacker.cs
similarity index 68%
rename from Monofoxe/Pipefoxe/SpriteGroup/TexturePacker.cs
rename to Monofoxe/Monofoxe.Pipeline/SpriteGroup/TexturePacker.cs
index 2f6c898e..9032369f 100644
--- a/Monofoxe/Pipefoxe/SpriteGroup/TexturePacker.cs
+++ b/Monofoxe/Monofoxe.Pipeline/SpriteGroup/TexturePacker.cs
@@ -1,300 +1,247 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Linq;
-
-namespace Pipefoxe.SpriteGroup
-{
- ///
- /// Packs set of spritesheets into texture atlasses.
- ///
- static class TexturePacker
- {
- public static (List spriteInfo, List atlases)
- PackTextures(List textures, int textureSize, int padding, string groupName)
- {
- List sprites = Pack(textures, textureSize, padding);
- List atlases = AssembleAtlases(sprites, textureSize, padding);
-
- return (sprites, atlases);
- }
-
-
-
- ///
- /// Calculates sprite positions for texture atlases.
- /// Basic algorhitm:
- /// In the beginning we have 1x1 grid and list of sprites sorted by height.
- /// We take biggest sprite and try to fit it into each free cell of a grid.
- /// If sprite fits, we place it into this cell and split grid at the right
- /// and bottom bound of placed sprite.
- ///
- private static List Pack(List textures, int atlasSize, int padding)
- {
- // Checking for textures larger than atlas size.
- foreach(var texture in textures)
- {
- if (texture.RawTexture.Width / texture.FramesH > atlasSize || texture.RawTexture.Height / texture.FramesV > atlasSize)
- {
- throw new Exception("Cannot pack " + texture.Name + "! It's too big for " + atlasSize + "x" + atlasSize + " atlas!");
- }
- }
- // Checking for textures larger than atlas size.
-
- // Sorting textures by height.
- List sortedSprites = textures.OrderByDescending(o => o.RawTexture.Height / o.FramesV).ToList();
-
- var textureIndex = 0;
-
- var packedSprites = new List();
- while(sortedSprites.Count > 0)
- {
- var packedFrames = new List ();
-
- var grid = new TextureGrid(atlasSize);
-
- // We need to copy list, because sortedTextures has to be changed during enumeration.
- var sortedTexturesCopy = new List(sortedSprites);
-
- foreach(var sprite in sortedTexturesCopy)
- {
- var spriteFrameSize = new Rectangle(
- 0,
- 0,
- sprite.RawTexture.Width / sprite.FramesH,
- sprite.RawTexture.Height / sprite.FramesV
- );
-
- // Sprite consists out of multiple frames. Each should be placed separately.
- for(var frameId = 0; frameId < sprite.FramesH * sprite.FramesV; frameId += 1)
- {
- var placed = false; // Tells if texture has been placed.
-
- var frame = new Frame();
- frame.TextureIndex = textureIndex;
- frame.TexturePos = spriteFrameSize;
-
- for(var y = 0; y < grid.Height; y += 1)
- {
- for(var x = 0; x < grid.Width; x += 1)
- {
- int rightBound = grid.GetCellX(x) + frame.TexturePos.Width + padding;
- int bottomBound = grid.GetCellY(y) + frame.TexturePos.Height + padding;
-
- frame.TexturePos.X = grid.GetCellX(x) + padding;
- frame.TexturePos.Y = grid.GetCellY(y) + padding;
-
- if (!grid[y, x]
- && !CheckOverlap(frame, packedFrames, padding)
- && rightBound <= atlasSize - padding
- && bottomBound <= atlasSize - padding
- )
- {
- packedFrames.Add(frame);
- sprite.Frames.Add(frame);
-
- // This means that we've packed all frames in sprite.
- if (sprite.Frames.Count == sprite.FramesH * sprite.FramesV)
- {
- packedSprites.Add(sprite);
- sortedSprites.Remove(sprite);
- }
-
- grid.SplitH(rightBound + padding);
- grid.SplitV(bottomBound + padding);
-
- // In case frame takes more than one cell.
- for(var fillY = y; fillY < grid.Height; fillY += 1)
- {
- if (grid.GetCellY(fillY) >= bottomBound + padding)
- {
- break;
- }
- for(var fillX = x; fillX < grid.Width; fillX += 1)
- {
- if (grid.GetCellX(fillX) >= rightBound + padding)
- {
- break;
- }
- grid[fillY, fillX] = true;
- }
- }
- // In case frame takes more than one cell.
-
- placed = true;
- break;
- }
- }
- if (placed)
- {
- break;
- }
- }
-
- if (!placed) // No need to check rest of the frames if we cannot fit current one.
- {
- break;
- }
- }
- }
-
- textureIndex += 1;
-
- }
-
-
- return packedSprites;
- }
-
-
-
- ///
- /// Generates atlas textures out of sprite info.
- ///
- private static List AssembleAtlases(List sprites, int textureSize, int padding)
- {
- var atlases = new List();
- var atlasIndex = 0;
-
- // List of unrendered sprites. When all sprite's frames are rendered, it will be removed from list.
- var spritesEnum = new List(sprites);
-
- while(spritesEnum.Count > 0)
- {
- var atlasBmp = new Bitmap(textureSize, textureSize);
- var graphics = Graphics.FromImage(atlasBmp);
- graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
-
- var spritesCopy = new List(spritesEnum);
-
- foreach(var sprite in spritesCopy)
- {
- for(var i = sprite.RenderedFrames; i < sprite.FramesV * sprite.FramesH; i += 1)
- {
- var frame = sprite.Frames[i];
-
- if (frame.TextureIndex == atlasIndex) // Each frame may be on different atlas.
- {
- sprite.RenderedFrames += 1;
-
- if (sprite.RenderedFrames == sprite.FramesH * sprite.FramesV)
- {
- spritesEnum.Remove(sprite);
- }
-
- int x = (i % sprite.FramesH) * frame.TexturePos.Width;
- int y = (i / sprite.FramesH) * frame.TexturePos.Height;
-
- graphics.DrawImage(
- sprite.RawTexture,
- frame.TexturePos,
- new Rectangle(
- x,
- y,
- frame.TexturePos.Width,
- frame.TexturePos.Height
- ),
- GraphicsUnit.Pixel
- );
-
- #region Padding.
- /*
- * Drawing padding lines around the texture turned out to be harder than I thought.
- * Let's just pretend it's all pretty and readable.
- */
-
- Rectangle[] srcRects =
- {
- new Rectangle(x, y, 1, frame.TexturePos.Height),
- new Rectangle(x + frame.TexturePos.Width - 1, y, 1, frame.TexturePos.Height),
- new Rectangle(x, y, frame.TexturePos.Width, 1),
- new Rectangle(x, y + frame.TexturePos.Height - 1, frame.TexturePos.Width, 1),
- };
- Rectangle[] destRects =
- {
- new Rectangle(frame.TexturePos.X - 1, frame.TexturePos.Y, 1, frame.TexturePos.Height),
- new Rectangle(frame.TexturePos.X + frame.TexturePos.Width, frame.TexturePos.Y, 1, frame.TexturePos.Height),
- new Rectangle(frame.TexturePos.X, frame.TexturePos.Y - 1, frame.TexturePos.Width, 1),
- new Rectangle(frame.TexturePos.X, frame.TexturePos.Y + frame.TexturePos.Height, frame.TexturePos.Width, 1),
- };
-
- for(var side = 0; side < 4; side += 1) // 4 sides, 4 lines.
- {
- // DrawImage draws 2 pixels of source texture instead of 1 if scaled, for some reason.
- // So we have to draw a ton of lines without scaling.
- for(var l = 0; l < padding; l += 1)
- {
- var destRect = destRects[side];
-
- int lAdd = l * ((side % 2) * 2 - 1);
-
- if (side < 2)
- {
- destRect.X += lAdd;
- }
- else
- {
- destRect.Y += lAdd;
- }
-
- graphics.DrawImage(
- sprite.RawTexture,
- destRect,
- srcRects[side],
- GraphicsUnit.Pixel
- );
- }
- }
-
- #endregion Padding.
- }
- }
- }
-
- atlases.Add(atlasBmp);
- graphics.Dispose();
- atlasIndex += 1;
- }
- return atlases;
- }
-
-
-
- ///
- /// Checks if one texture overlaps with the rest.
- ///
- private static bool CheckOverlap(Frame frame, List frames, int padding)
- {
- var paddingOffset = new Size(padding, padding);
- foreach(var secondFrame in frames)
- {
- if (
- RectangleInRectangle(
- frame.TexturePos.Location - paddingOffset,
- frame.TexturePos.Location + frame.TexturePos.Size + paddingOffset,
- secondFrame.TexturePos.Location - paddingOffset,
- secondFrame.TexturePos.Location + secondFrame.TexturePos.Size + paddingOffset
- )
- )
- {
- return true;
- }
- }
- return false;
- }
-
-
-
- ///
- /// Checks if two rectangles intersect.
- ///
- private static bool RectangleInRectangle(Point rect1Pt1, Point rect1Pt2, Point rect2Pt1, Point rect2Pt2) =>
- rect1Pt1.X < rect2Pt2.X && rect1Pt2.X > rect2Pt1.X && rect1Pt1.Y < rect2Pt2.Y && rect1Pt2.Y > rect2Pt1.Y;
-
-
-
- private static bool IsPow2(int x) =>
- (x & (x - 1)) == 0;
-
- }
-}
+using Microsoft.Xna.Framework;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Monofoxe.Pipeline.SpriteGroup
+{
+ ///
+ /// Packs set of spritesheets into texture atlasses.
+ ///
+ static class TexturePacker
+ {
+ public static (List spriteInfo, List atlases)
+ PackTextures(List textures, int textureSize, int padding, string groupName)
+ {
+ List sprites = Pack(textures, textureSize, padding);
+ List atlases = AssembleAtlases(sprites, textureSize, padding);
+
+ return (sprites, atlases);
+ }
+
+
+
+ ///
+ /// Calculates sprite positions for texture atlases.
+ /// Basic algorhitm:
+ /// In the beginning we have 1x1 grid and list of sprites sorted by height.
+ /// We take biggest sprite and try to fit it into each free cell of a grid.
+ /// If sprite fits, we place it into this cell and split grid at the right
+ /// and bottom bound of placed sprite.
+ ///
+ private static List Pack(List textures, int atlasSize, int padding)
+ {
+ // Checking for textures larger than atlas size.
+ foreach(var texture in textures)
+ {
+ if (texture.RawTexture.Width / texture.FramesH > atlasSize || texture.RawTexture.Height / texture.FramesV > atlasSize)
+ {
+ throw new Exception("Cannot pack " + texture.Name + "! It's too big for " + atlasSize + "x" + atlasSize + " atlas!");
+ }
+ }
+ // Checking for textures larger than atlas size.
+
+ // Sorting textures by height.
+ List sortedSprites = textures.OrderByDescending(o => o.RawTexture.Height / o.FramesV).ToList();
+
+ var textureIndex = 0;
+
+ var packedSprites = new List();
+ while(sortedSprites.Count > 0)
+ {
+ var packedFrames = new List ();
+
+ var grid = new TextureGrid(atlasSize);
+
+ // We need to copy list, because sortedTextures has to be changed during enumeration.
+ var sortedTexturesCopy = new List(sortedSprites);
+
+ foreach(var sprite in sortedTexturesCopy)
+ {
+ var spriteFrameSize = new Rectangle(
+ 0,
+ 0,
+ sprite.RawTexture.Width / sprite.FramesH,
+ sprite.RawTexture.Height / sprite.FramesV
+ );
+
+ // Sprite consists out of multiple frames. Each should be placed separately.
+ for(var frameId = 0; frameId < sprite.FramesH * sprite.FramesV; frameId += 1)
+ {
+ var placed = false; // Tells if texture has been placed.
+
+ var frame = new Frame();
+ frame.TextureIndex = textureIndex;
+ frame.TexturePos = spriteFrameSize;
+
+ for(var y = 0; y < grid.Height; y += 1)
+ {
+ for(var x = 0; x < grid.Width; x += 1)
+ {
+ int rightBound = grid.GetCellX(x) + frame.TexturePos.Width + padding;
+ int bottomBound = grid.GetCellY(y) + frame.TexturePos.Height + padding;
+
+ frame.TexturePos.X = grid.GetCellX(x) + padding;
+ frame.TexturePos.Y = grid.GetCellY(y) + padding;
+
+ if (!grid[y, x]
+ && !CheckOverlap(frame, packedFrames, padding)
+ && rightBound <= atlasSize - padding
+ && bottomBound <= atlasSize - padding
+ )
+ {
+ packedFrames.Add(frame);
+ sprite.Frames.Add(frame);
+
+ // This means that we've packed all frames in sprite.
+ if (sprite.Frames.Count == sprite.FramesH * sprite.FramesV)
+ {
+ packedSprites.Add(sprite);
+ sortedSprites.Remove(sprite);
+ }
+
+ grid.SplitH(rightBound + padding);
+ grid.SplitV(bottomBound + padding);
+
+ // In case frame takes more than one cell.
+ for(var fillY = y; fillY < grid.Height; fillY += 1)
+ {
+ if (grid.GetCellY(fillY) >= bottomBound + padding)
+ {
+ break;
+ }
+ for(var fillX = x; fillX < grid.Width; fillX += 1)
+ {
+ if (grid.GetCellX(fillX) >= rightBound + padding)
+ {
+ break;
+ }
+ grid[fillY, fillX] = true;
+ }
+ }
+ // In case frame takes more than one cell.
+
+ placed = true;
+ break;
+ }
+ }
+ if (placed)
+ {
+ break;
+ }
+ }
+
+ if (!placed) // No need to check rest of the frames if we cannot fit current one.
+ {
+ break;
+ }
+ }
+ }
+
+ textureIndex += 1;
+
+ }
+
+
+ return packedSprites;
+ }
+
+
+
+ ///
+ /// Generates atlas textures out of sprite info.
+ ///
+ private static List AssembleAtlases(List sprites, int textureSize, int padding)
+ {
+ var atlases = new List();
+ var atlasIndex = 0;
+
+ // List of unrendered sprites. When all sprite's frames are rendered, it will be removed from list.
+ var spritesEnum = new List(sprites);
+
+ while(spritesEnum.Count > 0)
+ {
+ var atlasBmp = new Bmp(textureSize, textureSize);
+
+ var spritesCopy = new List(spritesEnum);
+
+ foreach(var sprite in spritesCopy)
+ {
+ for(var i = sprite.RenderedFrames; i < sprite.FramesV * sprite.FramesH; i += 1)
+ {
+ var frame = sprite.Frames[i];
+
+ if (frame.TextureIndex == atlasIndex) // Each frame may be on different atlas.
+ {
+ sprite.RenderedFrames += 1;
+
+ if (sprite.RenderedFrames == sprite.FramesH * sprite.FramesV)
+ {
+ spritesEnum.Remove(sprite);
+ }
+
+ var frameX = (i % sprite.FramesH) * frame.TexturePos.Width;
+ var frameY = (i / sprite.FramesH) * frame.TexturePos.Height;
+
+ atlasBmp.Draw(
+ sprite.RawTexture,
+ frame.TexturePos.X,
+ frame.TexturePos.Y,
+ new Rectangle(
+ frameX,
+ frameY,
+ frame.TexturePos.Width,
+ frame.TexturePos.Height
+ ),
+ padding
+ );
+ }
+ }
+ }
+
+ atlases.Add(atlasBmp);
+ atlasIndex += 1;
+ }
+ return atlases;
+ }
+
+
+
+ ///
+ /// Checks if one texture overlaps with the rest.
+ ///
+ private static bool CheckOverlap(Frame frame, List frames, int padding)
+ {
+ var paddingOffset = new Point(padding, padding);
+ foreach(var secondFrame in frames)
+ {
+ if (
+ RectangleInRectangle(
+ frame.TexturePos.Location - paddingOffset,
+ frame.TexturePos.Location + frame.TexturePos.Size + paddingOffset,
+ secondFrame.TexturePos.Location - paddingOffset,
+ secondFrame.TexturePos.Location + secondFrame.TexturePos.Size + paddingOffset
+ )
+ )
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+
+ ///
+ /// Checks if two rectangles intersect.
+ ///
+ private static bool RectangleInRectangle(Point rect1Pt1, Point rect1Pt2, Point rect2Pt1, Point rect2Pt2) =>
+ rect1Pt1.X < rect2Pt2.X && rect1Pt2.X > rect2Pt1.X && rect1Pt1.Y < rect2Pt2.Y && rect1Pt2.Y > rect2Pt1.Y;
+
+
+
+ private static bool IsPow2(int x) =>
+ (x & (x - 1)) == 0;
+
+ }
+}
diff --git a/Monofoxe/Pipefoxe/Tiled/LayerParser.cs b/Monofoxe/Monofoxe.Pipeline/Tiled/LayerParser.cs
similarity index 96%
rename from Monofoxe/Pipefoxe/Tiled/LayerParser.cs
rename to Monofoxe/Monofoxe.Pipeline/Tiled/LayerParser.cs
index 0e8d2815..6e36413b 100644
--- a/Monofoxe/Pipefoxe/Tiled/LayerParser.cs
+++ b/Monofoxe/Monofoxe.Pipeline/Tiled/LayerParser.cs
@@ -1,481 +1,481 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Xml;
-using Microsoft.Xna.Framework;
-using Monofoxe.Tiled.MapStructure;
-using Monofoxe.Tiled.MapStructure.Objects;
-using System.IO;
-
-namespace Pipefoxe.Tiled
-{
- static class LayerParser
- {
- static List _tileLayers;
- static List _objectLayers;
- static List _imageLayers;
-
-
-
- public static void Parse(XmlNode mapXml, TiledMap map)
- {
- _tileLayers = new List();
- _objectLayers = new List();
- _imageLayers = new List();
-
- ParseGroup(mapXml);
-
- map.TileLayers = _tileLayers.ToArray();
- map.ObjectLayers = _objectLayers.ToArray();
- map.ImageLayers = _imageLayers.ToArray();
- }
-
- static void ParseGroup(XmlNode groupXml)
- {
- var groups = groupXml.SelectNodes("group");
- foreach(XmlNode group in groups)
- {
- ParseGroup(group);
- }
-
- var tileLayers = groupXml.SelectNodes("layer");
- foreach(XmlNode layer in tileLayers)
- {
- _tileLayers.Add(ParseTileLayer(layer));
- }
-
- var objectLayers = groupXml.SelectNodes("objectgroup");
- foreach(XmlNode layer in objectLayers)
- {
- _objectLayers.Add(ParseObjectLayer(layer));
- }
-
- var imageLayers = groupXml.SelectNodes("imagelayer");
- foreach(XmlNode layer in imageLayers)
- {
- var parsedLayer = ParseImageLayer(layer);
- if (parsedLayer != null)
- {
- _imageLayers.Add(parsedLayer);
- }
- }
- }
-
-
- static void ParseBaseLayer(XmlNode layerXml, TiledMapLayer layer)
- {
- layer.ID = int.Parse(layerXml.Attributes["id"].Value);
- layer.Name = layerXml.Attributes["name"].Value;
- layer.Opacity = XmlHelper.GetXmlFloatSafe(layerXml, "opacity");
- layer.Visible = XmlHelper.GetXmlBoolSafe(layerXml, "visible");
- layer.Offset = new Vector2(
- XmlHelper.GetXmlFloatSafe(layerXml, "offsetx"),
- XmlHelper.GetXmlFloatSafe(layerXml, "offsety")
- );
- layer.Properties = XmlHelper.GetProperties(layerXml);
- }
-
-
- static TiledMapTileLayer ParseTileLayer(XmlNode layerXml)
- {
- var layer = new TiledMapTileLayer();
-
- ParseBaseLayer(layerXml, layer);
-
- layer.Width = int.Parse(layerXml.Attributes["width"].Value);
- layer.Height = int.Parse(layerXml.Attributes["height"].Value);
-
-
- if (layerXml["data"].Attributes["encoding"].Value != "csv")
- {
- throw new NotSupportedException("Error while parsing layer " + layer.Name + ". Only CSV encoding is supported.");
- }
-
- // Parsing csv tile values.
- var tilemapValuesStr = layerXml["data"].InnerText.Split(',');
- var tilemapValues = new uint[tilemapValuesStr.Length];
-
- for(var i = 0; i < tilemapValues.Length; i += 1)
- {
- tilemapValues[i] = uint.Parse(tilemapValuesStr[i]);
- }
- // Parsing csv tile values.
-
- // Initing tile array.
- /*
- * Pipeline cannot work with 2-dimensional arrays,
- * so we're stuck arrays of arrays.
- */
- var tiles = new TiledMapTile[layer.Width][];
- for(var x = 0; x < layer.Width; x += 1)
- {
- tiles[x] = new TiledMapTile[layer.Height];
- }
- // Initing tile array.
-
- // Filling tilemap with tiles.
- for(var y = 0; y < layer.Height; y += 1)
- {
- for(var x = 0; x < layer.Width; x += 1)
- {
- tiles[x][y] = new TiledMapTile();
- var tilemapValue = tilemapValues[y * layer.Width + x];
-
- // Tile flip flags are stored in the tile value itself as 3 highest bits.
- tiles[x][y].FlipHor = ((tilemapValue & (uint)FlipFlags.FlipHor) != 0);
- tiles[x][y].FlipVer = ((tilemapValue & (uint)FlipFlags.FlipVer) != 0);
- tiles[x][y].FlipDiag = ((tilemapValue & (uint)FlipFlags.FlipDiag) != 0);
- tiles[x][y].GID = (int)(tilemapValue & (~(uint)FlipFlags.All));
- }
- }
- // Filling tilemap with tiles.
-
- layer.Tiles = tiles;
-
- return layer;
- }
-
-
-
- public static TiledMapObjectLayer ParseObjectLayer(XmlNode layerXml, bool parseBase = true)
- {
- var layer = new TiledMapObjectLayer();
-
- if (parseBase) // This is done for tiles, which have objects. Their objectgroup doesn't need any base layer stuff.
- {
- ParseBaseLayer(layerXml, layer);
- }
-
- if (layerXml.Attributes["color"] != null)
- {
- layer.Color = XmlHelper.StringToColor(layerXml.Attributes["color"].Value);
- }
-
- if (XmlHelper.GetXmlStringSafe(layerXml, "draworder") == "index")
- {
- layer.DrawingOrder = TiledMapObjectDrawingOrder.Manual;
- }
- else
- {
- layer.DrawingOrder = TiledMapObjectDrawingOrder.TopDown;
- }
-
- // Parsing objects.
- var objectsXml = layerXml.SelectNodes("object");
- var objects = new List();
-
- foreach(XmlNode obj in objectsXml)
- {
- objects.Add(ParseObject(obj));
- }
-
- layer.Objects = objects.ToArray();
- // Parsing objects.
-
- return layer;
- }
-
- static TiledObject ParseObject(XmlNode node)
- {
-
- var oldRoot = TiledMapImporter.CurrentRootDir;
-
- TiledObject obj = null;
-
- // If there is a template, we need to merge it with object.
- if (node.Attributes["template"] != null)
- {
- var templatePath = TiledMapImporter.CurrentRootDir + node.Attributes["template"].Value;
- node = MergeWithTemplate(node, templatePath);
- TiledMapImporter.CurrentRootDir = Path.GetDirectoryName(templatePath);
- }
-
- // Determining object type.
- var baseObj = ParseBaseObject(node);
-
- // Yes, this is horrible. But there's no better way, as far, as I know.
-
- if (node.Attributes["gid"] != null)
- {
- obj = ParseTileObject(node, baseObj);
- }
-
- if (node["point"] != null)
- {
- obj = ParsePointObject(baseObj);
- }
-
- if (node["polygon"] != null || node["polyline"] != null)
- {
- obj = ParsePolygonObject(node, baseObj);
- }
-
- if (node["ellipse"] != null)
- {
- obj = ParseEllipseObject(baseObj);
- }
-
- if (node["text"] != null)
- {
- obj = ParseTextObject(node, baseObj);
- }
-
- if (obj == null)
- {
- obj = ParseRectangleObject(baseObj);
- }
-
- TiledMapImporter.CurrentRootDir = oldRoot;
- return obj;
- // Determining object type.
- }
-
-
-
- ///
- /// Parses basic object properties, common to all object types.
- ///
- static TiledObject ParseBaseObject(XmlNode node)
- {
- var obj = new TiledObject();
-
- obj.Name = XmlHelper.GetXmlStringSafe(node, "name");
- obj.Type = XmlHelper.GetXmlStringSafe(node, "type");
- obj.ID = int.Parse(node.Attributes["id"].Value);
- obj.Position = new Vector2(
- XmlHelper.GetXmlFloatSafe(node, "x"),
- XmlHelper.GetXmlFloatSafe(node, "y")
- );
- obj.Size = new Vector2(
- XmlHelper.GetXmlFloatSafe(node, "width"),
- XmlHelper.GetXmlFloatSafe(node, "height")
- );
- obj.Rotation = XmlHelper.GetXmlFloatSafe(node, "rotation");
- obj.Visible = XmlHelper.GetXmlBoolSafe(node, "visible");
-
- obj.Properties = XmlHelper.GetProperties(node);
-
- return obj;
- }
-
-
- static TiledRectangleObject ParseRectangleObject(TiledObject baseObj) =>
- new TiledRectangleObject(baseObj);
-
- static TiledEllipseObject ParseEllipseObject(TiledObject baseObj) =>
- new TiledEllipseObject(baseObj);
-
- static TiledPointObject ParsePointObject(TiledObject baseObj) =>
- new TiledPointObject(baseObj);
-
- static TiledTileObject ParseTileObject(XmlNode node, TiledObject baseObj)
- {
- var obj = new TiledTileObject(baseObj);
-
- uint firstGID = 0;
-
-
- if (node["tileset"] != null && node["tileset"].Attributes["source"] != null)
- {
- // GetFullPath gets rid of stuff like // and /../
- var src = Path.GetFullPath(TiledMapImporter.CurrentRootDir + '/' + node["tileset"].Attributes["source"].Value);
- TilesetParser.ExternalTilesetsFirstGID.TryGetValue(src, out firstGID);
- }
-
- // For some reason, gid field is counted from 1, but other tile ids are counted from 0.
- var gid = uint.Parse(node.Attributes["gid"].Value) + firstGID - 1;
-
- obj.FlipHor = ((gid & (uint)FlipFlags.FlipHor) != 0);
- obj.FlipVer = ((gid & (uint)FlipFlags.FlipVer) != 0);
- obj.GID = (int)(gid & (~(uint)FlipFlags.All));
-
- return obj;
- }
-
- static TiledTextObject ParseTextObject(XmlNode node, TiledObject baseObj)
- {
- var textXml = node["text"];
- var obj = new TiledTextObject(baseObj);
- obj.Text = textXml.InnerText;
- if (textXml.Attributes["color"] != null)
- {
- obj.Color = XmlHelper.StringToColor(textXml.Attributes["color"].Value);
- }
- obj.WordWrap = XmlHelper.GetXmlBoolSafe(textXml, "color", false);
-
- obj.HorAlign = (TiledTextAlign)XmlHelper.GetXmlEnumSafe(
- textXml,
- "halign",
- TiledTextAlign.Left
- );
- obj.VerAlign = (TiledTextAlign)XmlHelper.GetXmlEnumSafe(
- textXml,
- "valign",
- TiledTextAlign.Left
- );
-
- obj.Font = XmlHelper.GetXmlStringSafe(textXml, "fontfamily");
- obj.FontSize = XmlHelper.GetXmlIntSafe(textXml, "pixelsize");
- obj.Underlined = XmlHelper.GetXmlBoolSafe(textXml, "underline");
- obj.StrikedOut = XmlHelper.GetXmlBoolSafe(textXml, "strikeout");
-
- return obj;
- }
-
- static TiledPolygonObject ParsePolygonObject(XmlNode node, TiledObject baseObj)
- {
- var obj = new TiledPolygonObject(baseObj);
- XmlNode polyXml;
-
- if (node["polygon"] != null)
- {
- polyXml = node["polygon"];
- obj.Closed = true;
- }
- else
- {
- polyXml = node["polyline"];
- obj.Closed = false;
- }
-
- var pointStrings = polyXml.Attributes["points"].Value.Split(' ');
-
- var points = new Vector2[pointStrings.Length];
-
- for(var i = 0; i < points.Length; i += 1)
- {
- var vecStr = pointStrings[i].Split(',');
- points[i] = new Vector2(
- float.Parse(vecStr[0], CultureInfo.InvariantCulture),
- float.Parse(vecStr[1], CultureInfo.InvariantCulture)
- );
- }
- obj.Points = points;
-
- return obj;
- }
-
- ///
- /// Some objects are referencing templates,
- /// and can override some parameters.
- ///
- /// Method merges object and template, overriding existing template parameters.
- ///
- static XmlNode MergeWithTemplate(XmlNode node, string templatePath)
- {
- // Loading template.
- var doc = new XmlDocument();
- XmlNode template;
- try
- {
- doc.Load(templatePath);
- template = doc["template"]["object"];
- foreach(XmlNode neighbourNode in doc["template"])
- {
- if (template != neighbourNode)
- {
- template.AppendChild(neighbourNode);
- }
- }
- }
- catch(Exception e)
- {
- throw new Exception("Error loading object template! " + e.StackTrace + Environment.NewLine + e.Message);
- }
- // Loading template.
-
-
- /*
- * So, now we need to read the template and take attributes,
- * which are not present in current object.
- */
-
- var owner = node.OwnerDocument;
-
- foreach(XmlAttribute attribute in template.Attributes)
- {
- if (node.Attributes[attribute.Name] == null)
- {
- var newAttr = owner.CreateAttribute(attribute.Name);
- newAttr.Value = attribute.Value;
- node.Attributes.Append(newAttr);
- }
- }
- node.Attributes.RemoveNamedItem("template");
- foreach(XmlNode child in template.ChildNodes)
- {
- if (node[child.Name] == null)
- {
- var newChild = owner.CreateElement(child.Name);
- newChild.InnerText = child.InnerText;
- newChild.InnerXml = child.InnerXml;
- foreach(XmlAttribute attribute in template[child.Name].Attributes)
- {
- var newAttr = owner.CreateAttribute(attribute.Name);
- newAttr.Value = attribute.Value;
- newChild.Attributes.Append(newAttr);
- }
- node.AppendChild(newChild);
- }
- }
-
- // Merging object properties with template's.
- if (template["properties"] != null)
- {
- // This is done because properties with default values aren't copied into object.
- foreach(XmlNode templateProperty in template["properties"].ChildNodes)
- {
- var nodeExists = false;
-
- foreach(XmlNode nodeProperty in node["properties"].ChildNodes)
- {
- if (nodeProperty.Attributes["name"].Value == templateProperty.Attributes["name"].Value)
- {
- nodeExists = true;
- break;
- }
- }
-
- if (!nodeExists)
- {
- var clonedProperty = owner.ImportNode(templateProperty, true);
- node["properties"].AppendChild(clonedProperty);
- }
- }
- }
- // Merging object properties with template's.
-
- return node;
- }
-
-
-
- static TiledMapImageLayer ParseImageLayer(XmlNode layerXml)
- {
- var imageXml = layerXml["image"];
- if (imageXml == null)
- {
- return null; // Without image, layer is empty, so we won't need it.
- }
-
- var layer = new TiledMapImageLayer();
-
- ParseBaseLayer(layerXml, layer);
-
- layer.TexturePath = XmlHelper.GetXmlStringSafe(imageXml, "source");
-
- if (layer.TexturePath == "")
- {
- return null; // Same thing. No path == no image.
- }
-
- if (imageXml.Attributes["trans"] != null)
- {
- layer.TransparentColor = XmlHelper.StringToColor(imageXml.Attributes["trans"].Value);
- }
-
- return layer;
- }
-
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Xml;
+using Microsoft.Xna.Framework;
+using Monofoxe.Tiled.MapStructure;
+using Monofoxe.Tiled.MapStructure.Objects;
+using System.IO;
+
+namespace Monofoxe.Pipeline.Tiled
+{
+ static class LayerParser
+ {
+ static List _tileLayers;
+ static List _objectLayers;
+ static List _imageLayers;
+
+
+
+ public static void Parse(XmlNode mapXml, TiledMap map)
+ {
+ _tileLayers = new List();
+ _objectLayers = new List();
+ _imageLayers = new List();
+
+ ParseGroup(mapXml);
+
+ map.TileLayers = _tileLayers.ToArray();
+ map.ObjectLayers = _objectLayers.ToArray();
+ map.ImageLayers = _imageLayers.ToArray();
+ }
+
+ static void ParseGroup(XmlNode groupXml)
+ {
+ var groups = groupXml.SelectNodes("group");
+ foreach(XmlNode group in groups)
+ {
+ ParseGroup(group);
+ }
+
+ var tileLayers = groupXml.SelectNodes("layer");
+ foreach(XmlNode layer in tileLayers)
+ {
+ _tileLayers.Add(ParseTileLayer(layer));
+ }
+
+ var objectLayers = groupXml.SelectNodes("objectgroup");
+ foreach(XmlNode layer in objectLayers)
+ {
+ _objectLayers.Add(ParseObjectLayer(layer));
+ }
+
+ var imageLayers = groupXml.SelectNodes("imagelayer");
+ foreach(XmlNode layer in imageLayers)
+ {
+ var parsedLayer = ParseImageLayer(layer);
+ if (parsedLayer != null)
+ {
+ _imageLayers.Add(parsedLayer);
+ }
+ }
+ }
+
+
+ static void ParseBaseLayer(XmlNode layerXml, TiledMapLayer layer)
+ {
+ layer.ID = int.Parse(layerXml.Attributes["id"].Value);
+ layer.Name = layerXml.Attributes["name"].Value;
+ layer.Opacity = XmlHelper.GetXmlFloatSafe(layerXml, "opacity");
+ layer.Visible = XmlHelper.GetXmlBoolSafe(layerXml, "visible");
+ layer.Offset = new Vector2(
+ XmlHelper.GetXmlFloatSafe(layerXml, "offsetx"),
+ XmlHelper.GetXmlFloatSafe(layerXml, "offsety")
+ );
+ layer.Properties = XmlHelper.GetProperties(layerXml);
+ }
+
+
+ static TiledMapTileLayer ParseTileLayer(XmlNode layerXml)
+ {
+ var layer = new TiledMapTileLayer();
+
+ ParseBaseLayer(layerXml, layer);
+
+ layer.Width = int.Parse(layerXml.Attributes["width"].Value);
+ layer.Height = int.Parse(layerXml.Attributes["height"].Value);
+
+
+ if (layerXml["data"].Attributes["encoding"].Value != "csv")
+ {
+ throw new NotSupportedException("Error while parsing layer " + layer.Name + ". Only CSV encoding is supported.");
+ }
+
+ // Parsing csv tile values.
+ var tilemapValuesStr = layerXml["data"].InnerText.Split(',');
+ var tilemapValues = new uint[tilemapValuesStr.Length];
+
+ for(var i = 0; i < tilemapValues.Length; i += 1)
+ {
+ tilemapValues[i] = uint.Parse(tilemapValuesStr[i]);
+ }
+ // Parsing csv tile values.
+
+ // Initing tile array.
+ /*
+ * Pipeline cannot work with 2-dimensional arrays,
+ * so we're stuck arrays of arrays.
+ */
+ var tiles = new TiledMapTile[layer.Width][];
+ for(var x = 0; x < layer.Width; x += 1)
+ {
+ tiles[x] = new TiledMapTile[layer.Height];
+ }
+ // Initing tile array.
+
+ // Filling tilemap with tiles.
+ for(var y = 0; y < layer.Height; y += 1)
+ {
+ for(var x = 0; x < layer.Width; x += 1)
+ {
+ tiles[x][y] = new TiledMapTile();
+ var tilemapValue = tilemapValues[y * layer.Width + x];
+
+ // Tile flip flags are stored in the tile value itself as 3 highest bits.
+ tiles[x][y].FlipHor = ((tilemapValue & (uint)FlipFlags.FlipHor) != 0);
+ tiles[x][y].FlipVer = ((tilemapValue & (uint)FlipFlags.FlipVer) != 0);
+ tiles[x][y].FlipDiag = ((tilemapValue & (uint)FlipFlags.FlipDiag) != 0);
+ tiles[x][y].GID = (int)(tilemapValue & (~(uint)FlipFlags.All));
+ }
+ }
+ // Filling tilemap with tiles.
+
+ layer.Tiles = tiles;
+
+ return layer;
+ }
+
+
+
+ public static TiledMapObjectLayer ParseObjectLayer(XmlNode layerXml, bool parseBase = true)
+ {
+ var layer = new TiledMapObjectLayer();
+
+ if (parseBase) // This is done for tiles, which have objects. Their objectgroup doesn't need any base layer stuff.
+ {
+ ParseBaseLayer(layerXml, layer);
+ }
+
+ if (layerXml.Attributes["color"] != null)
+ {
+ layer.Color = XmlHelper.StringToColor(layerXml.Attributes["color"].Value);
+ }
+
+ if (XmlHelper.GetXmlStringSafe(layerXml, "draworder") == "index")
+ {
+ layer.DrawingOrder = TiledMapObjectDrawingOrder.Manual;
+ }
+ else
+ {
+ layer.DrawingOrder = TiledMapObjectDrawingOrder.TopDown;
+ }
+
+ // Parsing objects.
+ var objectsXml = layerXml.SelectNodes("object");
+ var objects = new List();
+
+ foreach(XmlNode obj in objectsXml)
+ {
+ objects.Add(ParseObject(obj));
+ }
+
+ layer.Objects = objects.ToArray();
+ // Parsing objects.
+
+ return layer;
+ }
+
+ static TiledObject ParseObject(XmlNode node)
+ {
+
+ var oldRoot = TiledMapImporter.CurrentRootDir;
+
+ TiledObject obj = null;
+
+ // If there is a template, we need to merge it with object.
+ if (node.Attributes["template"] != null)
+ {
+ var templatePath = TiledMapImporter.CurrentRootDir + node.Attributes["template"].Value;
+ node = MergeWithTemplate(node, templatePath);
+ TiledMapImporter.CurrentRootDir = Path.GetDirectoryName(templatePath);
+ }
+
+ // Determining object type.
+ var baseObj = ParseBaseObject(node);
+
+ // Yes, this is horrible. But there's no better way, as far, as I know.
+
+ if (node.Attributes["gid"] != null)
+ {
+ obj = ParseTileObject(node, baseObj);
+ }
+
+ if (node["point"] != null)
+ {
+ obj = ParsePointObject(baseObj);
+ }
+
+ if (node["polygon"] != null || node["polyline"] != null)
+ {
+ obj = ParsePolygonObject(node, baseObj);
+ }
+
+ if (node["ellipse"] != null)
+ {
+ obj = ParseEllipseObject(baseObj);
+ }
+
+ if (node["text"] != null)
+ {
+ obj = ParseTextObject(node, baseObj);
+ }
+
+ if (obj == null)
+ {
+ obj = ParseRectangleObject(baseObj);
+ }
+
+ TiledMapImporter.CurrentRootDir = oldRoot;
+ return obj;
+ // Determining object type.
+ }
+
+
+
+ ///
+ /// Parses basic object properties, common to all object types.
+ ///
+ static TiledObject ParseBaseObject(XmlNode node)
+ {
+ var obj = new TiledObject();
+
+ obj.Name = XmlHelper.GetXmlStringSafe(node, "name");
+ obj.Type = XmlHelper.GetXmlStringSafe(node, "type");
+ obj.ID = int.Parse(node.Attributes["id"].Value);
+ obj.Position = new Vector2(
+ XmlHelper.GetXmlFloatSafe(node, "x"),
+ XmlHelper.GetXmlFloatSafe(node, "y")
+ );
+ obj.Size = new Vector2(
+ XmlHelper.GetXmlFloatSafe(node, "width"),
+ XmlHelper.GetXmlFloatSafe(node, "height")
+ );
+ obj.Rotation = XmlHelper.GetXmlFloatSafe(node, "rotation");
+ obj.Visible = XmlHelper.GetXmlBoolSafe(node, "visible");
+
+ obj.Properties = XmlHelper.GetProperties(node);
+
+ return obj;
+ }
+
+
+ static TiledRectangleObject ParseRectangleObject(TiledObject baseObj) =>
+ new TiledRectangleObject(baseObj);
+
+ static TiledEllipseObject ParseEllipseObject(TiledObject baseObj) =>
+ new TiledEllipseObject(baseObj);
+
+ static TiledPointObject ParsePointObject(TiledObject baseObj) =>
+ new TiledPointObject(baseObj);
+
+ static TiledTileObject ParseTileObject(XmlNode node, TiledObject baseObj)
+ {
+ var obj = new TiledTileObject(baseObj);
+
+ uint firstGID = 0;
+
+
+ if (node["tileset"] != null && node["tileset"].Attributes["source"] != null)
+ {
+ // GetFullPath gets rid of stuff like // and /../
+ var src = Path.GetFullPath(TiledMapImporter.CurrentRootDir + '/' + node["tileset"].Attributes["source"].Value);
+ TilesetParser.ExternalTilesetsFirstGID.TryGetValue(src, out firstGID);
+ }
+
+ // For some reason, gid field is counted from 1, but other tile ids are counted from 0.
+ var gid = uint.Parse(node.Attributes["gid"].Value) + firstGID - 1;
+
+ obj.FlipHor = ((gid & (uint)FlipFlags.FlipHor) != 0);
+ obj.FlipVer = ((gid & (uint)FlipFlags.FlipVer) != 0);
+ obj.GID = (int)(gid & (~(uint)FlipFlags.All));
+
+ return obj;
+ }
+
+ static TiledTextObject ParseTextObject(XmlNode node, TiledObject baseObj)
+ {
+ var textXml = node["text"];
+ var obj = new TiledTextObject(baseObj);
+ obj.Text = textXml.InnerText;
+ if (textXml.Attributes["color"] != null)
+ {
+ obj.Color = XmlHelper.StringToColor(textXml.Attributes["color"].Value);
+ }
+ obj.WordWrap = XmlHelper.GetXmlBoolSafe(textXml, "color", false);
+
+ obj.HorAlign = (TiledTextAlign)XmlHelper.GetXmlEnumSafe(
+ textXml,
+ "halign",
+ TiledTextAlign.Left
+ );
+ obj.VerAlign = (TiledTextAlign)XmlHelper.GetXmlEnumSafe(
+ textXml,
+ "valign",
+ TiledTextAlign.Left
+ );
+
+ obj.Font = XmlHelper.GetXmlStringSafe(textXml, "fontfamily");
+ obj.FontSize = XmlHelper.GetXmlIntSafe(textXml, "pixelsize");
+ obj.Underlined = XmlHelper.GetXmlBoolSafe(textXml, "underline");
+ obj.StrikedOut = XmlHelper.GetXmlBoolSafe(textXml, "strikeout");
+
+ return obj;
+ }
+
+ static TiledPolygonObject ParsePolygonObject(XmlNode node, TiledObject baseObj)
+ {
+ var obj = new TiledPolygonObject(baseObj);
+ XmlNode polyXml;
+
+ if (node["polygon"] != null)
+ {
+ polyXml = node["polygon"];
+ obj.Closed = true;
+ }
+ else
+ {
+ polyXml = node["polyline"];
+ obj.Closed = false;
+ }
+
+ var pointStrings = polyXml.Attributes["points"].Value.Split(' ');
+
+ var points = new Vector2[pointStrings.Length];
+
+ for(var i = 0; i < points.Length; i += 1)
+ {
+ var vecStr = pointStrings[i].Split(',');
+ points[i] = new Vector2(
+ float.Parse(vecStr[0], CultureInfo.InvariantCulture),
+ float.Parse(vecStr[1], CultureInfo.InvariantCulture)
+ );
+ }
+ obj.Points = points;
+
+ return obj;
+ }
+
+ ///
+ /// Some objects are referencing templates,
+ /// and can override some parameters.
+ ///
+ /// Method merges object and template, overriding existing template parameters.
+ ///
+ static XmlNode MergeWithTemplate(XmlNode node, string templatePath)
+ {
+ // Loading template.
+ var doc = new XmlDocument();
+ XmlNode template;
+ try
+ {
+ doc.Load(templatePath);
+ template = doc["template"]["object"];
+ foreach(XmlNode neighbourNode in doc["template"])
+ {
+ if (template != neighbourNode)
+ {
+ template.AppendChild(neighbourNode);
+ }
+ }
+ }
+ catch(Exception e)
+ {
+ throw new Exception("Error loading object template! " + e.StackTrace + Environment.NewLine + e.Message);
+ }
+ // Loading template.
+
+
+ /*
+ * So, now we need to read the template and take attributes,
+ * which are not present in current object.
+ */
+
+ var owner = node.OwnerDocument;
+
+ foreach(XmlAttribute attribute in template.Attributes)
+ {
+ if (node.Attributes[attribute.Name] == null)
+ {
+ var newAttr = owner.CreateAttribute(attribute.Name);
+ newAttr.Value = attribute.Value;
+ node.Attributes.Append(newAttr);
+ }
+ }
+ node.Attributes.RemoveNamedItem("template");
+ foreach(XmlNode child in template.ChildNodes)
+ {
+ if (node[child.Name] == null)
+ {
+ var newChild = owner.CreateElement(child.Name);
+ newChild.InnerText = child.InnerText;
+ newChild.InnerXml = child.InnerXml;
+ foreach(XmlAttribute attribute in template[child.Name].Attributes)
+ {
+ var newAttr = owner.CreateAttribute(attribute.Name);
+ newAttr.Value = attribute.Value;
+ newChild.Attributes.Append(newAttr);
+ }
+ node.AppendChild(newChild);
+ }
+ }
+
+ // Merging object properties with template's.
+ if (template["properties"] != null)
+ {
+ // This is done because properties with default values aren't copied into object.
+ foreach(XmlNode templateProperty in template["properties"].ChildNodes)
+ {
+ var nodeExists = false;
+
+ foreach(XmlNode nodeProperty in node["properties"].ChildNodes)
+ {
+ if (nodeProperty.Attributes["name"].Value == templateProperty.Attributes["name"].Value)
+ {
+ nodeExists = true;
+ break;
+ }
+ }
+
+ if (!nodeExists)
+ {
+ var clonedProperty = owner.ImportNode(templateProperty, true);
+ node["properties"].AppendChild(clonedProperty);
+ }
+ }
+ }
+ // Merging object properties with template's.
+
+ return node;
+ }
+
+
+
+ static TiledMapImageLayer ParseImageLayer(XmlNode layerXml)
+ {
+ var imageXml = layerXml["image"];
+ if (imageXml == null)
+ {
+ return null; // Without image, layer is empty, so we won't need it.
+ }
+
+ var layer = new TiledMapImageLayer();
+
+ ParseBaseLayer(layerXml, layer);
+
+ layer.TexturePath = XmlHelper.GetXmlStringSafe(imageXml, "source");
+
+ if (layer.TexturePath == "")
+ {
+ return null; // Same thing. No path == no image.
+ }
+
+ if (imageXml.Attributes["trans"] != null)
+ {
+ layer.TransparentColor = XmlHelper.StringToColor(imageXml.Attributes["trans"].Value);
+ }
+
+ return layer;
+ }
+
+ }
+}
diff --git a/Monofoxe/Pipefoxe/Tiled/MapParser.cs b/Monofoxe/Monofoxe.Pipeline/Tiled/MapParser.cs
similarity index 92%
rename from Monofoxe/Pipefoxe/Tiled/MapParser.cs
rename to Monofoxe/Monofoxe.Pipeline/Tiled/MapParser.cs
index 3ecf6604..0e651c2c 100644
--- a/Monofoxe/Pipefoxe/Tiled/MapParser.cs
+++ b/Monofoxe/Monofoxe.Pipeline/Tiled/MapParser.cs
@@ -1,53 +1,52 @@
-using System;
-using System.Xml;
-using Monofoxe.Tiled.MapStructure;
-
-namespace Pipefoxe.Tiled
-{
- static class MapParser
- {
- public static TiledMap Parse(XmlDocument xml)
- {
- Logger.Init("map.log");
- Logger.Log("foxes");
-
- var map = new TiledMap();
- var mapXml = xml["map"];
- var mapAttributes = xml["map"].Attributes;
-
- if (mapAttributes["infinite"].Value == "1")
- {
- throw new Exception("Infinite maps are not supported yet!");
- }
-
- // Properties.
- map.Width = int.Parse(mapAttributes["width"].Value);
- map.Height = int.Parse(mapAttributes["height"].Value);
- map.TileWidth = int.Parse(mapAttributes["tilewidth"].Value);
- map.TileHeight = int.Parse(mapAttributes["tileheight"].Value);
-
- Enum.TryParse(mapAttributes["renderorder"].Value.Replace("-", ""), true, out map.RenderOrder);
- Enum.TryParse(mapAttributes["orientation"].Value, true, out map.Orientation);
-
- if (mapAttributes["staggeraxis"] != null)
- {
- Enum.TryParse(mapAttributes["staggeraxis"].Value, true, out map.StaggerAxis);
- }
- if (mapAttributes["staggerindex"] != null)
- {
- Enum.TryParse(mapAttributes["staggerindex"].Value, true, out map.StaggerIndex);
- }
-
- map.HexSideLength = XmlHelper.GetXmlIntSafe(mapXml, "hexsidelength");
- // Properties.
-
-
- // Tilesets and layers.
- map.Tilesets = TilesetParser.Parse(mapXml.SelectNodes("tileset"));
- LayerParser.Parse(mapXml, map);
- // Tilesets and layers.
-
- return map;
- }
- }
-}
+using System;
+using System.Xml;
+using Monofoxe.Tiled.MapStructure;
+
+namespace Monofoxe.Pipeline.Tiled
+{
+ static class MapParser
+ {
+ public static TiledMap Parse(XmlDocument xml)
+ {
+ Logger.Log("foxes");
+
+ var map = new TiledMap();
+ var mapXml = xml["map"];
+ var mapAttributes = xml["map"].Attributes;
+
+ if (mapAttributes["infinite"].Value == "1")
+ {
+ throw new Exception("Infinite maps are not supported yet!");
+ }
+
+ // Properties.
+ map.Width = int.Parse(mapAttributes["width"].Value);
+ map.Height = int.Parse(mapAttributes["height"].Value);
+ map.TileWidth = int.Parse(mapAttributes["tilewidth"].Value);
+ map.TileHeight = int.Parse(mapAttributes["tileheight"].Value);
+
+ Enum.TryParse(mapAttributes["renderorder"].Value.Replace("-", ""), true, out map.RenderOrder);
+ Enum.TryParse(mapAttributes["orientation"].Value, true, out map.Orientation);
+
+ if (mapAttributes["staggeraxis"] != null)
+ {
+ Enum.TryParse(mapAttributes["staggeraxis"].Value, true, out map.StaggerAxis);
+ }
+ if (mapAttributes["staggerindex"] != null)
+ {
+ Enum.TryParse(mapAttributes["staggerindex"].Value, true, out map.StaggerIndex);
+ }
+
+ map.HexSideLength = XmlHelper.GetXmlIntSafe(mapXml, "hexsidelength");
+ // Properties.
+
+
+ // Tilesets and layers.
+ map.Tilesets = TilesetParser.Parse(mapXml.SelectNodes("tileset"));
+ LayerParser.Parse(mapXml, map);
+ // Tilesets and layers.
+
+ return map;
+ }
+ }
+}
diff --git a/Monofoxe/Pipefoxe/Tiled/TiledMapImporter.cs b/Monofoxe/Monofoxe.Pipeline/Tiled/TiledMapImporter.cs
similarity index 78%
rename from Monofoxe/Pipefoxe/Tiled/TiledMapImporter.cs
rename to Monofoxe/Monofoxe.Pipeline/Tiled/TiledMapImporter.cs
index 7a051fb6..e62497a0 100644
--- a/Monofoxe/Pipefoxe/Tiled/TiledMapImporter.cs
+++ b/Monofoxe/Monofoxe.Pipeline/Tiled/TiledMapImporter.cs
@@ -1,41 +1,44 @@
-using System.IO;
-using System.Xml;
-using Microsoft.Xna.Framework.Content.Pipeline;
-using Monofoxe.Tiled.MapStructure;
-
-namespace Pipefoxe.Tiled
-{
- [ContentImporter(".tmx", DefaultProcessor = "TiledMapProcessor",
- DisplayName = "Tiled Map Importer - Monofoxe")]
- public class TiledMapImporter : ContentImporter
- {
- ///
- /// Directory of the .tmx file.
- ///
- public static string TmxRootDir;
-
- ///
- /// Current root directory.
- ///
- public static string CurrentRootDir;
-
-
- public override TiledMap Import(string filename, ContentImporterContext context)
- {
- TmxRootDir = Path.GetDirectoryName(filename) + '/';
- CurrentRootDir = TmxRootDir;
-
- try
- {
- var xml = new XmlDocument();
- xml.Load(filename);
-
- return MapParser.Parse(xml);
- }
- catch(System.Exception e)
- {
- throw new System.Exception("Failed to import the map! " + e.Message + " " + e.StackTrace);
- }
- }
- }
-}
+using System.IO;
+using System.Xml;
+using Microsoft.Xna.Framework.Content.Pipeline;
+using Monofoxe.Tiled.MapStructure;
+
+namespace Monofoxe.Pipeline.Tiled
+{
+ [ContentImporter(".tmx", DefaultProcessor = "PassThroughProcessor",
+ DisplayName = "Tiled Map Importer - Monofoxe")]
+ public class TiledMapImporter : ContentImporter
+ {
+ ///
+ /// Directory of the .tmx file.
+ ///
+ public static string TmxRootDir;
+ public static string TmxFilename;
+
+ ///
+ /// Current root directory.
+ ///
+ public static string CurrentRootDir;
+
+
+ public override TiledMap Import(string filename, ContentImporterContext context)
+ {
+ Logger.Init("map.log");
+ TmxRootDir = Path.GetDirectoryName(filename) + '/';
+ TmxFilename = filename;
+ CurrentRootDir = TmxRootDir;
+ Logger.LogLine("ROOT:" + TmxRootDir);
+ try
+ {
+ var xml = new XmlDocument();
+ xml.Load(filename);
+
+ return MapParser.Parse(xml);
+ }
+ catch(System.Exception e)
+ {
+ throw new System.Exception("Failed to import the map! " + e.Message + " " + e.StackTrace);
+ }
+ }
+ }
+}
diff --git a/Monofoxe/Pipefoxe/Tiled/TiledMapWriter.cs b/Monofoxe/Monofoxe.Pipeline/Tiled/TiledMapWriter.cs
similarity index 91%
rename from Monofoxe/Pipefoxe/Tiled/TiledMapWriter.cs
rename to Monofoxe/Monofoxe.Pipeline/Tiled/TiledMapWriter.cs
index 307bad15..96fb6eaa 100644
--- a/Monofoxe/Pipefoxe/Tiled/TiledMapWriter.cs
+++ b/Monofoxe/Monofoxe.Pipeline/Tiled/TiledMapWriter.cs
@@ -1,308 +1,311 @@
-using Microsoft.Xna.Framework.Content.Pipeline;
-using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
-using Monofoxe.Tiled.MapStructure;
-using Monofoxe.Tiled.MapStructure.Objects;
-
-namespace Pipefoxe.Tiled
-{
- [ContentTypeWriter]
- public class TiledMapWriter : ContentTypeWriter
- {
- protected override void Write(ContentWriter output, TiledMap map)
- {
- try
- {
- output.WriteObject(map.BackgroundColor);
- output.Write(map.Width);
- output.Write(map.Height);
- output.Write(map.TileWidth);
- output.Write(map.TileHeight);
-
- output.Write((byte)map.RenderOrder);
- output.Write((byte)map.Orientation);
-
- output.Write((byte)map.StaggerAxis);
- output.Write((byte)map.StaggerIndex);
-
- output.Write(map.HexSideLength);
-
- WriteTilesets(output, map.Tilesets);
- WriteTileLayers(output, map.TileLayers);
- WriteObjectLayers(output, map.ObjectLayers);
- WriteImageLayers(output, map.ImageLayers);
-
- output.WriteObject(map.Properties);
- }
- catch(System.Exception e)
- {
- throw new System.Exception("Failed to write the map! " + e.Message + " " + e.StackTrace);
- }
- }
-
- #region Tilesets.
-
- void WriteTilesets(ContentWriter output, TiledMapTileset[] tilesets)
- {
- output.Write(tilesets.Length);
- foreach(var tileset in tilesets)
- {
- output.Write(tileset.Name);
- output.WriteObject(tileset.TexturePaths);
-
- if (
- tileset.Properties.ContainsKey(TilesetParser.IgnoreTilesetTextureFlag)
- && bool.Parse(tileset.Properties[TilesetParser.IgnoreTilesetTextureFlag])
- )
- {
- output.Write(false);
- }
- else
- {
- output.Write(true);
- output.Write(tileset.TexturePaths.Length);
- for(var i = 0; i < tileset.TexturePaths.Length; i += 1)
- {
- var externalReference = TiledMapProcessor.TextureReferences[tileset.TexturePaths[i]];
- output.WriteExternalReference(externalReference);
- }
- }
-
- output.Write(tileset.FirstGID);
- output.Write(tileset.TileWidth);
- output.Write(tileset.TileHeight);
- output.Write(tileset.Spacing);
- output.Write(tileset.Margin);
- output.Write(tileset.TileCount);
- output.Write(tileset.Columns);
-
- output.Write(tileset.Offset);
-
- foreach(var tile in tileset.Tiles)
- {
- WriteTilesetTile(output, tile);
- }
-
- output.WriteObject(tileset.BackgroundColor);
- output.WriteObject(tileset.Properties);
- }
- }
-
-
- void WriteTilesetTile(ContentWriter output, TiledMapTilesetTile tile)
- {
- output.Write(tile.GID);
- output.Write(tile.TextureID);
- output.WriteObject(tile.TexturePosition);
-
- output.Write((byte)tile.ObjectsDrawingOrder);
-
- if (tile.Objects != null)
- {
- output.Write(tile.Objects.Length);
- foreach(var obj in tile.Objects)
- {
- WriteObject(output, obj);
- }
- }
- else
- {
- output.Write(0);
- }
-
-
- output.WriteObject(tile.Properties);
- }
-
-
- #endregion Tilesets.
-
-
- void WriteLayer(ContentWriter output, TiledMapLayer layer)
- {
- output.Write(layer.Name);
- output.Write(layer.ID);
- output.Write(layer.Visible);
- output.Write(layer.Opacity);
- output.Write(layer.Offset);
-
- output.WriteObject(layer.Properties);
- }
-
-
- #region Tiles.
-
- void WriteTileLayers(ContentWriter output, TiledMapTileLayer[] layers)
- {
- output.Write(layers.Length);
- foreach(var layer in layers)
- {
- WriteLayer(output, layer);
- output.Write(layer.Width);
- output.Write(layer.Height);
-
- for(var y = 0; y < layer.Height; y += 1)
- {
- for(var x = 0; x < layer.Width; x += 1)
- {
- WriteTile(output, layer.Tiles[x][y]);
- }
- }
- }
- }
-
-
-
- void WriteTile(ContentWriter output, TiledMapTile tile)
- {
- output.Write(tile.GID);
- output.Write(tile.FlipHor);
- output.Write(tile.FlipVer);
- output.Write(tile.FlipDiag);
- }
-
- #endregion Tiles.
-
-
-
- #region Objects.
-
- void WriteObjectLayers(ContentWriter output, TiledMapObjectLayer[] layers)
- {
- output.Write(layers.Length);
- foreach(var layer in layers)
- {
- WriteLayer(output, layer);
- output.Write((byte)layer.DrawingOrder);
- output.Write(layer.Color);
-
- output.Write(layer.Objects.Length);
- foreach(var obj in layer.Objects)
- {
- WriteObject(output, obj);
- }
- }
- }
-
- void WriteObject(ContentWriter output, TiledObject obj)
- {
- WriteBaseObject(output, obj);
- if (obj is TiledTileObject)
- {
- WriteTileObject(output, (TiledTileObject)obj);
- return;
- }
-
- if (obj is TiledPointObject)
- {
- WritePointObject(output);
- return;
- }
-
- if (obj is TiledPolygonObject)
- {
- WritePolygonObject(output, (TiledPolygonObject)obj);
- return;
- }
-
- if (obj is TiledEllipseObject)
- {
- WriteEllipseObject(output);
- return;
- }
-
- if (obj is TiledTextObject)
- {
- WriteTextObject(output, (TiledTextObject)obj);
- return;
- }
-
- if (obj is TiledRectangleObject)
- {
- WriteRectangleObject(output);
- }
- }
-
-
- void WriteBaseObject(ContentWriter output, TiledObject obj)
- {
- output.Write(obj.Name);
- output.Write(obj.Type);
- output.Write(obj.ID);
- output.Write(obj.Position);
- output.Write(obj.Size);
- output.Write(obj.Rotation);
- output.Write(obj.Visible);
- output.WriteObject(obj.Properties);
- }
-
- void WriteTileObject(ContentWriter output, TiledTileObject obj)
- {
- output.Write((byte)TiledObjectType.Tile);
- output.Write(obj.GID);
- output.Write(obj.FlipHor);
- output.Write(obj.FlipVer);
- }
-
- void WritePointObject(ContentWriter output) =>
- output.Write((byte)TiledObjectType.Point);
-
- void WritePolygonObject(ContentWriter output, TiledPolygonObject obj)
- {
- output.Write((byte)TiledObjectType.Polygon);
- output.Write(obj.Closed);
- output.WriteObject(obj.Points);
- }
-
- void WriteEllipseObject(ContentWriter output) =>
- output.Write((byte)TiledObjectType.Ellipse);
-
- void WriteTextObject(ContentWriter output, TiledTextObject obj)
- {
- output.Write((byte)TiledObjectType.Text);
- output.Write(obj.Text);
- output.Write(obj.Color);
- output.Write(obj.WordWrap);
- output.Write((byte)obj.HorAlign);
- output.Write((byte)obj.VerAlign);
- output.Write(obj.Font);
- output.Write(obj.FontSize);
- output.Write(obj.Underlined);
- output.Write(obj.StrikedOut);
- }
-
- void WriteRectangleObject(ContentWriter output) =>
- output.Write((byte)TiledObjectType.Rectangle);
-
- #endregion Objects.
-
-
-
- #region Images.
-
- void WriteImageLayers(ContentWriter output, TiledMapImageLayer[] layers)
- {
- output.Write(layers.Length);
- foreach(var layer in layers)
- {
- WriteLayer(output, layer);
-
- output.Write(layer.TexturePath);
- var externalReference = TiledMapProcessor.TextureReferences[layer.TexturePath];
- output.WriteExternalReference(externalReference);
- output.Write(layer.TransparentColor);
- }
- }
-
- #endregion Images.
-
-
- public override string GetRuntimeType(TargetPlatform targetPlatform) =>
- "Monofoxe.Tiled.MapStructure.TiledMap, Monofoxe.Tiled";
-
-
-
- public override string GetRuntimeReader(TargetPlatform targetPlatform) =>
- "Monofoxe.Tiled.ContentReaders.TiledMapReader, Monofoxe.Tiled";
- }
-}
-
+using Microsoft.Xna.Framework.Content.Pipeline;
+using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
+using Monofoxe.Tiled.MapStructure;
+using Monofoxe.Tiled.MapStructure.Objects;
+using System.IO;
+
+namespace Monofoxe.Pipeline.Tiled
+{
+ [ContentTypeWriter]
+ public class TiledMapWriter : ContentTypeWriter
+ {
+ protected override void Write(ContentWriter output, TiledMap map)
+ {
+ try
+ {
+ output.WriteObject(map.BackgroundColor);
+ output.Write(map.Width);
+ output.Write(map.Height);
+ output.Write(map.TileWidth);
+ output.Write(map.TileHeight);
+
+ output.Write((byte)map.RenderOrder);
+ output.Write((byte)map.Orientation);
+
+ output.Write((byte)map.StaggerAxis);
+ output.Write((byte)map.StaggerIndex);
+
+ output.Write(map.HexSideLength);
+
+ WriteTilesets(output, map.Tilesets);
+ WriteTileLayers(output, map.TileLayers);
+ WriteObjectLayers(output, map.ObjectLayers);
+ WriteImageLayers(output, map.ImageLayers);
+
+ output.WriteObject(map.Properties);
+ }
+ catch(System.Exception e)
+ {
+ throw new System.Exception("Failed to write the map! " + e.Message + " " + e.StackTrace);
+ }
+ }
+
+ #region Tilesets.
+
+ void WriteTilesets(ContentWriter output, TiledMapTileset[] tilesets)
+ {
+ output.Write(tilesets.Length);
+ foreach(var tileset in tilesets)
+ {
+ output.Write(tileset.Name);
+ output.WriteObject(tileset.TexturePaths);
+
+ if (
+ tileset.Properties.ContainsKey(TilesetParser.IgnoreTilesetTextureFlag)
+ && bool.Parse(tileset.Properties[TilesetParser.IgnoreTilesetTextureFlag])
+ )
+ {
+ output.Write(false);
+ }
+ else
+ {
+ output.Write(true);
+ output.Write(tileset.TexturePaths.Length);
+ for(var i = 0; i < tileset.TexturePaths.Length; i += 1)
+ {
+ var texturePath = tileset.TexturePaths[i];
+ var contentPath = Path.Combine(Path.GetDirectoryName(texturePath), Path.GetFileNameWithoutExtension(texturePath));
+ output.Write(contentPath);
+ }
+ }
+
+ output.Write(tileset.FirstGID);
+ output.Write(tileset.TileWidth);
+ output.Write(tileset.TileHeight);
+ output.Write(tileset.Spacing);
+ output.Write(tileset.Margin);
+ output.Write(tileset.TileCount);
+ output.Write(tileset.Columns);
+
+ output.Write(tileset.Offset);
+
+ foreach(var tile in tileset.Tiles)
+ {
+ WriteTilesetTile(output, tile);
+ }
+
+ output.WriteObject(tileset.BackgroundColor);
+ output.WriteObject(tileset.Properties);
+ }
+ }
+
+
+ void WriteTilesetTile(ContentWriter output, TiledMapTilesetTile tile)
+ {
+ output.Write(tile.GID);
+ output.Write(tile.TextureID);
+ output.WriteObject(tile.TexturePosition);
+
+ output.Write((byte)tile.ObjectsDrawingOrder);
+
+ if (tile.Objects != null)
+ {
+ output.Write(tile.Objects.Length);
+ foreach(var obj in tile.Objects)
+ {
+ WriteObject(output, obj);
+ }
+ }
+ else
+ {
+ output.Write(0);
+ }
+
+
+ output.WriteObject(tile.Properties);
+ }
+
+
+ #endregion Tilesets.
+
+
+ void WriteLayer(ContentWriter output, TiledMapLayer layer)
+ {
+ output.Write(layer.Name);
+ output.Write(layer.ID);
+ output.Write(layer.Visible);
+ output.Write(layer.Opacity);
+ output.Write(layer.Offset);
+
+ output.WriteObject(layer.Properties);
+ }
+
+
+ #region Tiles.
+
+ void WriteTileLayers(ContentWriter output, TiledMapTileLayer[] layers)
+ {
+ output.Write(layers.Length);
+ foreach(var layer in layers)
+ {
+ WriteLayer(output, layer);
+ output.Write(layer.Width);
+ output.Write(layer.Height);
+
+ for(var y = 0; y < layer.Height; y += 1)
+ {
+ for(var x = 0; x < layer.Width; x += 1)
+ {
+ WriteTile(output, layer.Tiles[x][y]);
+ }
+ }
+ }
+ }
+
+
+
+ void WriteTile(ContentWriter output, TiledMapTile tile)
+ {
+ output.Write(tile.GID);
+ output.Write(tile.FlipHor);
+ output.Write(tile.FlipVer);
+ output.Write(tile.FlipDiag);
+ }
+
+ #endregion Tiles.
+
+
+
+ #region Objects.
+
+ void WriteObjectLayers(ContentWriter output, TiledMapObjectLayer[] layers)
+ {
+ output.Write(layers.Length);
+ foreach(var layer in layers)
+ {
+ WriteLayer(output, layer);
+ output.Write((byte)layer.DrawingOrder);
+ output.Write(layer.Color);
+
+ output.Write(layer.Objects.Length);
+ foreach(var obj in layer.Objects)
+ {
+ WriteObject(output, obj);
+ }
+ }
+ }
+
+ void WriteObject(ContentWriter output, TiledObject obj)
+ {
+ WriteBaseObject(output, obj);
+ if (obj is TiledTileObject)
+ {
+ WriteTileObject(output, (TiledTileObject)obj);
+ return;
+ }
+
+ if (obj is TiledPointObject)
+ {
+ WritePointObject(output);
+ return;
+ }
+
+ if (obj is TiledPolygonObject)
+ {
+ WritePolygonObject(output, (TiledPolygonObject)obj);
+ return;
+ }
+
+ if (obj is TiledEllipseObject)
+ {
+ WriteEllipseObject(output);
+ return;
+ }
+
+ if (obj is TiledTextObject)
+ {
+ WriteTextObject(output, (TiledTextObject)obj);
+ return;
+ }
+
+ if (obj is TiledRectangleObject)
+ {
+ WriteRectangleObject(output);
+ }
+ }
+
+
+ void WriteBaseObject(ContentWriter output, TiledObject obj)
+ {
+ output.Write(obj.Name);
+ output.Write(obj.Type);
+ output.Write(obj.ID);
+ output.Write(obj.Position);
+ output.Write(obj.Size);
+ output.Write(obj.Rotation);
+ output.Write(obj.Visible);
+ output.WriteObject(obj.Properties);
+ }
+
+ void WriteTileObject(ContentWriter output, TiledTileObject obj)
+ {
+ output.Write((byte)TiledObjectType.Tile);
+ output.Write(obj.GID);
+ output.Write(obj.FlipHor);
+ output.Write(obj.FlipVer);
+ }
+
+ void WritePointObject(ContentWriter output) =>
+ output.Write((byte)TiledObjectType.Point);
+
+ void WritePolygonObject(ContentWriter output, TiledPolygonObject obj)
+ {
+ output.Write((byte)TiledObjectType.Polygon);
+ output.Write(obj.Closed);
+ output.WriteObject(obj.Points);
+ }
+
+ void WriteEllipseObject(ContentWriter output) =>
+ output.Write((byte)TiledObjectType.Ellipse);
+
+ void WriteTextObject(ContentWriter output, TiledTextObject obj)
+ {
+ output.Write((byte)TiledObjectType.Text);
+ output.Write(obj.Text);
+ output.Write(obj.Color);
+ output.Write(obj.WordWrap);
+ output.Write((byte)obj.HorAlign);
+ output.Write((byte)obj.VerAlign);
+ output.Write(obj.Font);
+ output.Write(obj.FontSize);
+ output.Write(obj.Underlined);
+ output.Write(obj.StrikedOut);
+ }
+
+ void WriteRectangleObject(ContentWriter output) =>
+ output.Write((byte)TiledObjectType.Rectangle);
+
+ #endregion Objects.
+
+
+
+ #region Images.
+
+ void WriteImageLayers(ContentWriter output, TiledMapImageLayer[] layers)
+ {
+ output.Write(layers.Length);
+ foreach(var layer in layers)
+ {
+ WriteLayer(output, layer);
+
+ output.Write(layer.TexturePath);
+
+ var contentPath = Path.Combine(Path.GetDirectoryName(layer.TexturePath), Path.GetFileNameWithoutExtension(layer.TexturePath));
+ output.Write(contentPath);
+ output.Write(layer.TransparentColor);
+ }
+ }
+
+ #endregion Images.
+
+
+ public override string GetRuntimeType(TargetPlatform targetPlatform) =>
+ "Monofoxe.Tiled.MapStructure.TiledMap, Monofoxe.Tiled";
+
+
+
+ public override string GetRuntimeReader(TargetPlatform targetPlatform) =>
+ "Monofoxe.Tiled.ContentReaders.TiledMapReader, Monofoxe.Tiled";
+ }
+}
+
diff --git a/Monofoxe/Pipefoxe/Tiled/TilesetParser.cs b/Monofoxe/Monofoxe.Pipeline/Tiled/TilesetParser.cs
similarity index 96%
rename from Monofoxe/Pipefoxe/Tiled/TilesetParser.cs
rename to Monofoxe/Monofoxe.Pipeline/Tiled/TilesetParser.cs
index 253a86f3..b08040be 100644
--- a/Monofoxe/Pipefoxe/Tiled/TilesetParser.cs
+++ b/Monofoxe/Monofoxe.Pipeline/Tiled/TilesetParser.cs
@@ -1,249 +1,249 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Xml;
-using Microsoft.Xna.Framework;
-using Monofoxe.Tiled.MapStructure;
-using Monofoxe.Tiled.MapStructure.Objects;
-using System.IO;
-
-namespace Pipefoxe.Tiled
-{
-
- static class TilesetParser
- {
- ///
- /// Tells pipeline, that this tileset won't be used in the game completely.
- /// If this tileset property is set to "true", tileset won't be loaded into final map.
- ///
- public const string IgnoreTilesetFlag = "__ignoreTileset";
-
- ///
- /// Tells pipeline, that this tileset won't need Tiled texture.
- /// If this tileset property is set to "true", game won't require tileset texture during
- /// map loading.
- /// NOTE: You should still provide the texture to the tileset on your own, if you want to use it in game with default tilesets.
- ///
- public const string IgnoreTilesetTextureFlag = "__ignoreTilesetTexture";
-
-
- public static Dictionary ExternalTilesetsFirstGID = new Dictionary();
-
-
- public static TiledMapTileset[] Parse(XmlNodeList nodes)
- {
- ExternalTilesetsFirstGID.Clear();
- var tilesets = new List();
-
- foreach(XmlNode tilesetXml in nodes)
- {
- var tileset = ParseTileset(tilesetXml);
- if (tileset != null)
- {
- tilesets.Add(tileset);
- }
- }
- return tilesets.ToArray();
- }
-
-
-
- static TiledMapTileset ParseTileset(XmlNode tilesetXml)
- {
- var tileset = new TiledMapTileset();
- tileset.FirstGID = int.Parse(tilesetXml.Attributes["firstgid"].Value);
-
- var tilesetDir = "";
-
- if (tilesetXml.Attributes["source"] != null)
- {
-
- ExternalTilesetsFirstGID.Add(
- Path.GetFullPath(TiledMapImporter.CurrentRootDir + '/' + tilesetXml.Attributes["source"].Value),
- (uint)tileset.FirstGID
- );
-
- // If there is "source" field, that means, tileset is external.
- var doc = new XmlDocument();
- try
- {
- // Paths in tileset file are relative to that file, so root dir needs to be swapped.
- TiledMapImporter.CurrentRootDir = TiledMapImporter.TmxRootDir + Path.GetDirectoryName(tilesetXml.Attributes["source"].Value) + "/";
-
- doc.Load(TiledMapImporter.CurrentRootDir + "/" + Path.GetFileName(tilesetXml.Attributes["source"].Value));
- tilesetDir = Path.GetDirectoryName(tilesetXml.Attributes["source"].Value) + '/';
- tilesetXml = doc["tileset"]; // Swapping to actual tileset.
- }
- catch(Exception e)
- {
- throw new Exception("Error loading external tileset! " + e.Message + " " + e.StackTrace);
- }
- }
- tileset.Properties = XmlHelper.GetProperties(tilesetXml);
-
- // This means, that tileset won't be used in the game and should be ignored.
- if (
- tileset.Properties.ContainsKey(IgnoreTilesetFlag)
- && bool.Parse(tileset.Properties[IgnoreTilesetFlag])
- )
- {
- TiledMapImporter.CurrentRootDir = TiledMapImporter.TmxRootDir;
- return null;
- }
-
- Logger.Log("Parsing tileset " + tilesetXml.Attributes["name"].Value);
-
- #region Main fields.
-
- tileset.Name = tilesetXml.Attributes["name"].Value;
- tileset.TileWidth = int.Parse(tilesetXml.Attributes["tilewidth"].Value);
- tileset.TileHeight = int.Parse(tilesetXml.Attributes["tileheight"].Value);
- tileset.TileCount = int.Parse(tilesetXml.Attributes["tilecount"].Value);
- tileset.Columns = int.Parse(tilesetXml.Attributes["columns"].Value);
-
- tileset.Margin = XmlHelper.GetXmlIntSafe(tilesetXml, "margin");
- tileset.Spacing = XmlHelper.GetXmlIntSafe(tilesetXml, "spacing");
-
- if (tilesetXml.Attributes["backgroundcolor"] != null)
- {
- tileset.BackgroundColor = XmlHelper.StringToColor(tilesetXml.Attributes["backgroundcolor"].Value);
- }
-
- if (tilesetXml["tileoffset"] != null)
- {
- tileset.Offset = new Vector2(
- float.Parse(tilesetXml["tileoffset"].Attributes["x"].Value, CultureInfo.InvariantCulture),
- float.Parse(tilesetXml["tileoffset"].Attributes["y"].Value, CultureInfo.InvariantCulture)
- );
- }
-
- #endregion Main fields.
-
-
- // Turning tile xml into usable dictionary.
- var tiles = new Dictionary(); // List won't suit, because some tile ids may be skipped.
- foreach(XmlNode tileXml in tilesetXml.SelectNodes("tile"))
- {
- tiles.Add(int.Parse(tileXml.Attributes["id"].Value), tileXml);
- }
- // Turning tile xml into usable dictionary.
-
- /*
- * It is very problematic to load Texture2D without
- * GraphicsDevice, so textures are imported later as external references.
- * At this stage map will just remember their
- * relative paths, and will pick textures up later.
- */
-
- tileset.Tiles = new TiledMapTilesetTile[tileset.TileCount];
-
- if (tilesetXml["image"] != null)
- {
- /*
- * NOTE: Single image tilesets can still have
- * tags with properties.
- */
- // Single-image tileset.
- var texturePaths = new string[1];
-
- texturePaths[0] = tilesetDir + tilesetXml["image"].Attributes["source"].Value;
- tileset.TexturePaths = texturePaths;
-
- var currentID = 0;
- for(var y = 0; y < tileset.Height; y += 1)
- {
- for(var x = 0; x < tileset.Width; x += 1)
- {
- var tile = new TiledMapTilesetTile();
- //tile.Tileset = tileset; // Assigning tileset here is useless - loopback link will be lost during serialization.
- tile.GID = tileset.FirstGID + currentID;
- tile.TextureID = 0;
- tile.TexturePosition = new Rectangle(
- tileset.Margin + x * (tileset.TileWidth + tileset.Spacing),
- tileset.Margin + y * (tileset.TileHeight + tileset.Spacing),
- tileset.TileWidth,
- tileset.TileHeight
- );
-
- if (tiles.ContainsKey(currentID))
- {
- ReadTileObjects(tiles[currentID], ref tile);
- tile.Properties = XmlHelper.GetProperties(tiles[currentID]);
- }
- else
- {
- tile.Objects = new TiledObject[0];
- tile.Properties = new Dictionary();
- }
- tileset.Tiles[currentID] = tile;
- currentID += 1;
- }
- }
- // Single-image tileset.
- }
- else
- {
- // Image collection tileset.
- var texturePaths = new List();
-
- var currentID = 0;
- foreach(var nodePair in tiles)
- {
- var tile = new TiledMapTilesetTile();
- //tile.Tileset = tileset;
- tile.GID = tileset.FirstGID + nodePair.Key;
-
- var texturePath = tilesetDir + nodePair.Value["image"].Attributes["source"].Value;
- if (texturePaths.Contains(texturePath))
- {
- // Avoiding duplicates.
- tile.TextureID = texturePaths.IndexOf(texturePath);
- }
- else
- {
- tile.TextureID = texturePaths.Count;
- texturePaths.Add(texturePath);
- }
-
- tile.TexturePosition = new Rectangle(
- 0, 0,
- int.Parse(nodePair.Value["image"].Attributes["width"].Value),
- int.Parse(nodePair.Value["image"].Attributes["height"].Value)
- );
-
- ReadTileObjects(nodePair.Value, ref tile);
-
- tile.Properties = XmlHelper.GetProperties(nodePair.Value);
-
- tileset.Tiles[currentID] = tile;
- currentID += 1;
- }
- tileset.TexturePaths = texturePaths.ToArray();
-
-
- // Image collection tileset.
- }
-
- TiledMapImporter.CurrentRootDir = TiledMapImporter.TmxRootDir;
-
-
- return tileset;
- }
-
-
- static void ReadTileObjects(XmlNode node, ref TiledMapTilesetTile tile)
- {
- if (node["objectgroup"] != null)
- {
- var layer = LayerParser.ParseObjectLayer(node["objectgroup"], false);
- tile.ObjectsDrawingOrder = layer.DrawingOrder;
- tile.Objects = layer.Objects;
- return;
- }
- tile.ObjectsDrawingOrder = TiledMapObjectDrawingOrder.TopDown;
- tile.Objects = new TiledObject[]{};
- }
-
-
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Xml;
+using Microsoft.Xna.Framework;
+using Monofoxe.Tiled.MapStructure;
+using Monofoxe.Tiled.MapStructure.Objects;
+using System.IO;
+
+namespace Monofoxe.Pipeline.Tiled
+{
+
+ static class TilesetParser
+ {
+ ///
+ /// Tells pipeline, that this tileset won't be used in the game completely.
+ /// If this tileset property is set to "true", tileset won't be loaded into final map.
+ ///
+ public const string IgnoreTilesetFlag = "__ignoreTileset";
+
+ ///
+ /// Tells pipeline, that this tileset won't need Tiled texture.
+ /// If this tileset property is set to "true", game won't require tileset texture during
+ /// map loading.
+ /// NOTE: You should still provide the texture to the tileset on your own, if you want to use it in game with default tilesets.
+ ///
+ public const string IgnoreTilesetTextureFlag = "__ignoreTilesetTexture";
+
+
+ public static Dictionary ExternalTilesetsFirstGID = new Dictionary();
+
+
+ public static TiledMapTileset[] Parse(XmlNodeList nodes)
+ {
+ ExternalTilesetsFirstGID.Clear();
+ var tilesets = new List();
+
+ foreach(XmlNode tilesetXml in nodes)
+ {
+ var tileset = ParseTileset(tilesetXml);
+ if (tileset != null)
+ {
+ tilesets.Add(tileset);
+ }
+ }
+ return tilesets.ToArray();
+ }
+
+
+
+ static TiledMapTileset ParseTileset(XmlNode tilesetXml)
+ {
+ var tileset = new TiledMapTileset();
+ tileset.FirstGID = int.Parse(tilesetXml.Attributes["firstgid"].Value);
+
+ var tilesetDir = "";
+
+ if (tilesetXml.Attributes["source"] != null)
+ {
+
+ ExternalTilesetsFirstGID.Add(
+ Path.GetFullPath(TiledMapImporter.CurrentRootDir + '/' + tilesetXml.Attributes["source"].Value),
+ (uint)tileset.FirstGID
+ );
+
+ // If there is "source" field, that means, tileset is external.
+ var doc = new XmlDocument();
+ try
+ {
+ // Paths in tileset file are relative to that file, so root dir needs to be swapped.
+ TiledMapImporter.CurrentRootDir = TiledMapImporter.TmxRootDir + Path.GetDirectoryName(tilesetXml.Attributes["source"].Value) + "/";
+
+ doc.Load(TiledMapImporter.CurrentRootDir + "/" + Path.GetFileName(tilesetXml.Attributes["source"].Value));
+ tilesetDir = Path.GetDirectoryName(tilesetXml.Attributes["source"].Value) + '/';
+ tilesetXml = doc["tileset"]; // Swapping to actual tileset.
+ }
+ catch(Exception e)
+ {
+ throw new Exception("Error loading external tileset! " + e.Message + " " + e.StackTrace);
+ }
+ }
+ tileset.Properties = XmlHelper.GetProperties(tilesetXml);
+
+ // This means, that tileset won't be used in the game and should be ignored.
+ if (
+ tileset.Properties.ContainsKey(IgnoreTilesetFlag)
+ && bool.Parse(tileset.Properties[IgnoreTilesetFlag])
+ )
+ {
+ TiledMapImporter.CurrentRootDir = TiledMapImporter.TmxRootDir;
+ return null;
+ }
+
+ Logger.Log("Parsing tileset " + tilesetXml.Attributes["name"].Value);
+
+ #region Main fields.
+
+ tileset.Name = tilesetXml.Attributes["name"].Value;
+ tileset.TileWidth = int.Parse(tilesetXml.Attributes["tilewidth"].Value);
+ tileset.TileHeight = int.Parse(tilesetXml.Attributes["tileheight"].Value);
+ tileset.TileCount = int.Parse(tilesetXml.Attributes["tilecount"].Value);
+ tileset.Columns = int.Parse(tilesetXml.Attributes["columns"].Value);
+
+ tileset.Margin = XmlHelper.GetXmlIntSafe(tilesetXml, "margin");
+ tileset.Spacing = XmlHelper.GetXmlIntSafe(tilesetXml, "spacing");
+
+ if (tilesetXml.Attributes["backgroundcolor"] != null)
+ {
+ tileset.BackgroundColor = XmlHelper.StringToColor(tilesetXml.Attributes["backgroundcolor"].Value);
+ }
+
+ if (tilesetXml["tileoffset"] != null)
+ {
+ tileset.Offset = new Vector2(
+ float.Parse(tilesetXml["tileoffset"].Attributes["x"].Value, CultureInfo.InvariantCulture),
+ float.Parse(tilesetXml["tileoffset"].Attributes["y"].Value, CultureInfo.InvariantCulture)
+ );
+ }
+
+ #endregion Main fields.
+
+
+ // Turning tile xml into usable dictionary.
+ var tiles = new Dictionary(); // List won't suit, because some tile ids may be skipped.
+ foreach(XmlNode tileXml in tilesetXml.SelectNodes("tile"))
+ {
+ tiles.Add(int.Parse(tileXml.Attributes["id"].Value), tileXml);
+ }
+ // Turning tile xml into usable dictionary.
+
+ /*
+ * It is very problematic to load Texture2D without
+ * GraphicsDevice, so textures are imported later as external references.
+ * At this stage map will just remember their
+ * relative paths, and will pick textures up later.
+ */
+
+ tileset.Tiles = new TiledMapTilesetTile[tileset.TileCount];
+
+ if (tilesetXml["image"] != null)
+ {
+ /*
+ * NOTE: Single image tilesets can still have
+ * tags with properties.
+ */
+ // Single-image tileset.
+ var texturePaths = new string[1];
+
+ texturePaths[0] = tilesetDir + tilesetXml["image"].Attributes["source"].Value;
+ tileset.TexturePaths = texturePaths;
+
+ var currentID = 0;
+ for(var y = 0; y < tileset.Height; y += 1)
+ {
+ for(var x = 0; x < tileset.Width; x += 1)
+ {
+ var tile = new TiledMapTilesetTile();
+ //tile.Tileset = tileset; // Assigning tileset here is useless - loopback link will be lost during serialization.
+ tile.GID = tileset.FirstGID + currentID;
+ tile.TextureID = 0;
+ tile.TexturePosition = new Rectangle(
+ tileset.Margin + x * (tileset.TileWidth + tileset.Spacing),
+ tileset.Margin + y * (tileset.TileHeight + tileset.Spacing),
+ tileset.TileWidth,
+ tileset.TileHeight
+ );
+
+ if (tiles.ContainsKey(currentID))
+ {
+ ReadTileObjects(tiles[currentID], ref tile);
+ tile.Properties = XmlHelper.GetProperties(tiles[currentID]);
+ }
+ else
+ {
+ tile.Objects = new TiledObject[0];
+ tile.Properties = new Dictionary();
+ }
+ tileset.Tiles[currentID] = tile;
+ currentID += 1;
+ }
+ }
+ // Single-image tileset.
+ }
+ else
+ {
+ // Image collection tileset.
+ var texturePaths = new List();
+
+ var currentID = 0;
+ foreach(var nodePair in tiles)
+ {
+ var tile = new TiledMapTilesetTile();
+ //tile.Tileset = tileset;
+ tile.GID = tileset.FirstGID + nodePair.Key;
+
+ var texturePath = tilesetDir + nodePair.Value["image"].Attributes["source"].Value;
+ if (texturePaths.Contains(texturePath))
+ {
+ // Avoiding duplicates.
+ tile.TextureID = texturePaths.IndexOf(texturePath);
+ }
+ else
+ {
+ tile.TextureID = texturePaths.Count;
+ texturePaths.Add(texturePath);
+ }
+
+ tile.TexturePosition = new Rectangle(
+ 0, 0,
+ int.Parse(nodePair.Value["image"].Attributes["width"].Value),
+ int.Parse(nodePair.Value["image"].Attributes["height"].Value)
+ );
+
+ ReadTileObjects(nodePair.Value, ref tile);
+
+ tile.Properties = XmlHelper.GetProperties(nodePair.Value);
+
+ tileset.Tiles[currentID] = tile;
+ currentID += 1;
+ }
+ tileset.TexturePaths = texturePaths.ToArray();
+
+
+ // Image collection tileset.
+ }
+
+ TiledMapImporter.CurrentRootDir = TiledMapImporter.TmxRootDir;
+
+
+ return tileset;
+ }
+
+
+ static void ReadTileObjects(XmlNode node, ref TiledMapTilesetTile tile)
+ {
+ if (node["objectgroup"] != null)
+ {
+ var layer = LayerParser.ParseObjectLayer(node["objectgroup"], false);
+ tile.ObjectsDrawingOrder = layer.DrawingOrder;
+ tile.Objects = layer.Objects;
+ return;
+ }
+ tile.ObjectsDrawingOrder = TiledMapObjectDrawingOrder.TopDown;
+ tile.Objects = new TiledObject[]{};
+ }
+
+
+ }
+}
diff --git a/Monofoxe/Pipefoxe/Tiled/XmlHelper.cs b/Monofoxe/Monofoxe.Pipeline/Tiled/XmlHelper.cs
similarity index 82%
rename from Monofoxe/Pipefoxe/Tiled/XmlHelper.cs
rename to Monofoxe/Monofoxe.Pipeline/Tiled/XmlHelper.cs
index c7227424..3484216f 100644
--- a/Monofoxe/Pipefoxe/Tiled/XmlHelper.cs
+++ b/Monofoxe/Monofoxe.Pipeline/Tiled/XmlHelper.cs
@@ -1,112 +1,119 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Xml;
-using Microsoft.Xna.Framework;
-
-namespace Pipefoxe.Tiled
-{
- static class XmlHelper
- {
- ///
- /// Returns properties from xml node.
- ///
- public static Dictionary GetProperties(XmlNode node)
- {
- var dictionary = new Dictionary();
-
- if (node["properties"] != null)
- {
- try
- {
- var nodeList = node["properties"].SelectNodes("property");
- foreach(XmlNode propertyXml in nodeList)
- {
- dictionary.Add(propertyXml.Attributes["name"].Value, propertyXml.Attributes["value"].Value);
- }
- }
- catch(Exception e)
- {
- throw new Exception("Error while parsing properties!" + e.StackTrace);
- }
- }
-
- return dictionary;
- }
-
- public static string GetXmlStringSafe(XmlNode node, string attribute)
- {
- if (node.Attributes[attribute] != null)
- {
- return node.Attributes[attribute].Value;
- }
- return "";
- }
-
- public static int GetXmlIntSafe(XmlNode node, string attribute)
- {
- if (node.Attributes[attribute] != null)
- {
- return int.Parse(node.Attributes[attribute].Value);
- }
- return 0;
- }
-
- public static float GetXmlFloatSafe(XmlNode node, string attribute)
- {
- if (node.Attributes[attribute] != null)
- {
- return float.Parse(node.Attributes[attribute].Value, CultureInfo.InvariantCulture);
- }
- return 0f;
- }
-
- public static bool GetXmlBoolSafe(XmlNode node, string attribute, bool defaultValue = true)
- {
- if (node.Attributes[attribute] != null)
- {
- return node.Attributes[attribute].Value == "1"
- || string.Equals(node.Attributes[attribute].Value, "true", StringComparison.OrdinalIgnoreCase);
- }
- return defaultValue;
- }
-
- public static object GetXmlEnumSafe(XmlNode node, string attribute, T defaultValue)
- {
- if (node.Attributes[attribute] != null)
- {
- return Enum.Parse(typeof(T), node.Attributes[attribute].Value, true);
- }
- return defaultValue;
- }
-
-
-
- ///
- /// Converts string in hex format #RRGGBB or #AARRGGBB to Color.
- ///
- public static Color StringToColor(string colorStr)
- {
- colorStr = colorStr.Replace("#", "");
-
- var channels = new byte[colorStr.Length / 2];
-
- for(var i = 0; i < channels.Length; i += 1)
- {
- channels[i] = Convert.ToByte(colorStr.Substring(i * 2, 2), 16);
- }
-
- if (channels.Length == 3)
- {
- // #RRGGBB
- return new Color(channels[0], channels[1], channels[2]);
- }
- else
- {
- // #AARRGGBB
- return new Color(channels[1], channels[2], channels[3], channels[0]);
- }
- }
-
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Xml;
+using Microsoft.Xna.Framework;
+
+namespace Monofoxe.Pipeline.Tiled
+{
+ static class XmlHelper
+ {
+ ///
+ /// Returns properties from xml node.
+ ///
+ public static Dictionary GetProperties(XmlNode node)
+ {
+ var dictionary = new Dictionary();
+
+ if (node["properties"] != null)
+ {
+ try
+ {
+ var nodeList = node["properties"].SelectNodes("property");
+ foreach (XmlNode propertyXml in nodeList)
+ {
+ if (propertyXml.Attributes["value"] != null)
+ {
+ dictionary.Add(propertyXml.Attributes["name"].Value, propertyXml.Attributes["value"].Value);
+ }
+ else
+ {
+ dictionary.Add(propertyXml.Attributes["name"].Value, propertyXml.InnerText);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new Exception("Error while parsing properties!" + e.StackTrace);
+ }
+ }
+
+ return dictionary;
+ }
+
+ public static string GetXmlStringSafe(XmlNode node, string attribute)
+ {
+ if (node.Attributes[attribute] != null)
+ {
+ return node.Attributes[attribute].Value;
+ }
+ return "";
+ }
+
+ public static int GetXmlIntSafe(XmlNode node, string attribute)
+ {
+ if (node.Attributes[attribute] != null)
+ {
+ return int.Parse(node.Attributes[attribute].Value);
+ }
+ return 0;
+ }
+
+ public static float GetXmlFloatSafe(XmlNode node, string attribute)
+ {
+ if (node.Attributes[attribute] != null)
+ {
+ return float.Parse(node.Attributes[attribute].Value, CultureInfo.InvariantCulture);
+ }
+ return 0f;
+ }
+
+ public static bool GetXmlBoolSafe(XmlNode node, string attribute, bool defaultValue = true)
+ {
+ if (node.Attributes[attribute] != null)
+ {
+ return node.Attributes[attribute].Value == "1"
+ || string.Equals(node.Attributes[attribute].Value, "true", StringComparison.OrdinalIgnoreCase);
+ }
+ return defaultValue;
+ }
+
+ public static object GetXmlEnumSafe(XmlNode node, string attribute, T defaultValue)
+ {
+ if (node.Attributes[attribute] != null)
+ {
+ return Enum.Parse(typeof(T), node.Attributes[attribute].Value, true);
+ }
+ return defaultValue;
+ }
+
+
+
+ ///
+ /// Converts string in hex format #RRGGBB or #AARRGGBB to Color.
+ ///
+ public static Color StringToColor(string colorStr)
+ {
+ colorStr = colorStr.Replace("#", "");
+
+ var channels = new byte[colorStr.Length / 2];
+
+ for (var i = 0; i < channels.Length; i += 1)
+ {
+ channels[i] = Convert.ToByte(colorStr.Substring(i * 2, 2), 16);
+ }
+
+ if (channels.Length == 3)
+ {
+ // #RRGGBB
+ return new Color(channels[0], channels[1], channels[2]);
+ }
+ else
+ {
+ // #AARRGGBB
+ return new Color(channels[1], channels[2], channels[3], channels[0]);
+ }
+ }
+
+ }
+}
diff --git a/Monofoxe/Pipefoxe/app.config b/Monofoxe/Monofoxe.Pipeline/app.config
similarity index 97%
rename from Monofoxe/Pipefoxe/app.config
rename to Monofoxe/Monofoxe.Pipeline/app.config
index be61cd6d..1f254e9a 100644
--- a/Monofoxe/Pipefoxe/app.config
+++ b/Monofoxe/Monofoxe.Pipeline/app.config
@@ -1,11 +1,11 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Monofoxe/Monofoxe.Tests/AngleTests.cs b/Monofoxe/Monofoxe.Tests/AngleTests.cs
index ec92b28c..a6cedba3 100644
--- a/Monofoxe/Monofoxe.Tests/AngleTests.cs
+++ b/Monofoxe/Monofoxe.Tests/AngleTests.cs
@@ -1,4 +1,4 @@
-using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework;
using Monofoxe.Engine.Utils;
using Moq;
using NUnit.Framework;
@@ -159,7 +159,7 @@ public void Lerp_InterpolateAngles_ReturnsCorrectResult()
var degrees2 = It.IsAny();
var a1 = new Angle(degrees1);
var a2 = new Angle(degrees2);
- var value = It.IsInRange(0, 1, Range.Inclusive);
+ var value = It.IsInRange(0, 1, Moq.Range.Inclusive);
var result = Angle.Lerp(a1, a2, value);
@@ -198,4 +198,4 @@ public void Lerp_InterpolateNegativeAngles_ReturnsCorrectResult1()
}
}
-}
\ No newline at end of file
+}
diff --git a/Monofoxe/Monofoxe.Tests/Monofoxe.Tests.csproj b/Monofoxe/Monofoxe.Tests/Monofoxe.Tests.csproj
index 4739f66a..b09adc56 100644
--- a/Monofoxe/Monofoxe.Tests/Monofoxe.Tests.csproj
+++ b/Monofoxe/Monofoxe.Tests/Monofoxe.Tests.csproj
@@ -1,8 +1,8 @@
-
+
- netcoreapp2.0
+ netcoreapp3.1
false
@@ -17,12 +17,9 @@
-
+
-
- $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\DesktopGL\MonoGame.Framework.dll
-
+
-
\ No newline at end of file
diff --git a/Monofoxe/Monofoxe.Tiled/ContentReaders/TiledMapReader.cs b/Monofoxe/Monofoxe.Tiled/ContentReaders/TiledMapReader.cs
index 2a675d81..ddb356d2 100644
--- a/Monofoxe/Monofoxe.Tiled/ContentReaders/TiledMapReader.cs
+++ b/Monofoxe/Monofoxe.Tiled/ContentReaders/TiledMapReader.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
@@ -68,7 +69,8 @@ void ReadTilesets(ContentReader input, TiledMap map)
tilesets[i].Textures = new Texture2D[texturesCount];
for(var k = 0; k < texturesCount; k += 1)
{
- tilesets[i].Textures[k] = input.ReadExternalReference();
+ var path = Path.Combine(Path.GetDirectoryName(input.AssetName), input.ReadString());
+ tilesets[i].Textures[k] = input.ContentManager.Load(path);
}
}
@@ -336,8 +338,8 @@ void ReadImageLayers(ContentReader input, TiledMap map)
var layer = new TiledMapImageLayer();
ReadLayer(input, layer);
- layer.TexturePath = input.ReadString();
- layer.Texture = input.ReadExternalReference();
+ layer.TexturePath = Path.Combine(Path.GetDirectoryName(input.AssetName), input.ReadString());
+ layer.Texture = input.ContentManager.Load(input.ReadString());
layer.TransparentColor = input.ReadColor();
layers[i] = layer;
diff --git a/Monofoxe/Monofoxe.Tiled/Monofoxe.Tiled.csproj b/Monofoxe/Monofoxe.Tiled/Monofoxe.Tiled.csproj
index 80a40261..236931f7 100644
--- a/Monofoxe/Monofoxe.Tiled/Monofoxe.Tiled.csproj
+++ b/Monofoxe/Monofoxe.Tiled/Monofoxe.Tiled.csproj
@@ -1,34 +1,26 @@
-
+
-
- netstandard2.0
- false
- 2.0.0-dev
- Martenfur
- Chai Foxes
- Monofoxe Tiled
- Tiled Map Editor integration for Monofoxe.
- https://github.com/Martenfur/Monofoxe/
- https://github.com/Martenfur/Monofoxe/
-
-
+
+ netstandard2.0
+ false
+ Tiled Map Editor integration for Monofoxe.
+ false
+ true
+ ..\bin\$(Configuration)\
+ ..\bin\$(Configuration)\$(AssemblyName).xml
+ 1701;1702;1591
+
-
- ..\bin\Debug\
- DEBUG;TRACE
- ..\bin\Debug\Monofoxe.Tiled.xml
- 1701;1702;1591
-
+
+
+
-
- ..\bin\Release\
- ..\bin\Release\Monofoxe.Tiled.xml
-
+
+
+ All
+
+
-
-
-
-
-
+
diff --git a/Monofoxe/Monofoxe.sln b/Monofoxe/Monofoxe.sln
index 4d65aebd..1afa0d45 100644
--- a/Monofoxe/Monofoxe.sln
+++ b/Monofoxe/Monofoxe.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pipefoxe", "Pipefoxe\Pipefoxe.csproj", "{D59079B2-CC07-4783-9C7F-05E78EBBC5FD}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monofoxe.Pipeline", "Monofoxe.Pipeline\Monofoxe.Pipeline.csproj", "{D59079B2-CC07-4783-9C7F-05E78EBBC5FD}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Monofoxe.Tiled.MapStructure", "Monofoxe.Tiled.MapStructure\Monofoxe.Tiled.MapStructure.shproj", "{785E8147-0E69-45DF-92F7-B4F315739D0C}"
EndProject
@@ -18,10 +18,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\.editorconfig = ..\.editorconfig
EndProjectSection
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monofoxe.Engine.WindowsDX", "Monofoxe.Engine.WindowsDX\Monofoxe.Engine.WindowsDX.csproj", "{A1593C65-09C3-4294-A153-A43509D989AA}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monofoxe.Engine.DesktopGL", "Monofoxe.Engine.DesktopGL\Monofoxe.Engine.DesktopGL.csproj", "{491EFCE4-315C-40AB-AC26-28F7A6190E9A}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Platforms", "Platforms", "{B86C69D3-FFCE-488F-891F-6EAAAD2513FD}"
+EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Monofoxe.Tiled.MapStructure\Monofoxe.Tiled.MapStructure.projitems*{785e8147-0e69-45df-92f7-b4f315739d0c}*SharedItemsImports = 13
- Monofoxe.Tiled.MapStructure\Monofoxe.Tiled.MapStructure.projitems*{d59079b2-cc07-4783-9c7f-05e78ebbc5fd}*SharedItemsImports = 4
+ Monofoxe.Tiled.MapStructure\Monofoxe.Tiled.MapStructure.projitems*{d59079b2-cc07-4783-9c7f-05e78ebbc5fd}*SharedItemsImports = 5
+ Monofoxe.Tiled.MapStructure\Monofoxe.Tiled.MapStructure.projitems*{e615232a-8edd-43bb-84d0-3ba376aca7e6}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -44,10 +51,22 @@ Global
{799409E8-B82F-4DBF-BBDE-B9EF253B2404}.Debug|Any CPU.Build.0 = Debug|Any CPU
{799409E8-B82F-4DBF-BBDE-B9EF253B2404}.Release|Any CPU.ActiveCfg = Release|Any CPU
{799409E8-B82F-4DBF-BBDE-B9EF253B2404}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A1593C65-09C3-4294-A153-A43509D989AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A1593C65-09C3-4294-A153-A43509D989AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A1593C65-09C3-4294-A153-A43509D989AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A1593C65-09C3-4294-A153-A43509D989AA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {491EFCE4-315C-40AB-AC26-28F7A6190E9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {491EFCE4-315C-40AB-AC26-28F7A6190E9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {491EFCE4-315C-40AB-AC26-28F7A6190E9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {491EFCE4-315C-40AB-AC26-28F7A6190E9A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {A1593C65-09C3-4294-A153-A43509D989AA} = {B86C69D3-FFCE-488F-891F-6EAAAD2513FD}
+ {491EFCE4-315C-40AB-AC26-28F7A6190E9A} = {B86C69D3-FFCE-488F-891F-6EAAAD2513FD}
+ EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B5534B27-AF0B-4FD7-80A1-0E7BCBFC9C46}
EndGlobalSection
diff --git a/Monofoxe/Pipefoxe/AssetInfo/AssetInfoImporter.cs b/Monofoxe/Pipefoxe/AssetInfo/AssetInfoImporter.cs
deleted file mode 100644
index 3e69ef76..00000000
--- a/Monofoxe/Pipefoxe/AssetInfo/AssetInfoImporter.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System.Collections.Generic;
-using System.IO;
-using Microsoft.Xna.Framework.Content.Pipeline;
-
-// Inspired by:
-// https://github.com/Ragath/MonoGame.AssetInfo
-
-
-namespace Pipefoxe.AssetInfo
-{
- ///
- /// Asset info importer. Reads .mcgb file and extracts all asset paths.
- ///
- [ContentImporter(".mgcb", DisplayName = "Asset Info Importer - Monofoxe", DefaultProcessor = "PassThroughProcessor")]
- public class AssetInfoImporter : ContentImporter
- {
- const string _beginTag = "#begin ";
- const string _copyTag = "/copy:";
-
- public override string[] Import(string filename, ContentImporterContext context)
- {
- var lines = File.ReadAllLines(filename);
-
- var assets = new List();
-
- for(var i = 0; i < lines.Length; i += 1)
- {
- if (lines[i].StartsWith(_beginTag))
- {
- var assetPath = lines[i].Remove(0, _beginTag.Length);
-
- // If asset is being copied, we'll need to leave its extension.
- if (i + 1 < lines.Length && !lines[i + 1].StartsWith(_copyTag))
- {
- assetPath = Path.GetDirectoryName(assetPath) + '/' + Path.GetFileNameWithoutExtension(assetPath);
- }
- assets.Add(assetPath);
- }
- }
-
- return assets.ToArray();
- }
- }
-}
diff --git a/Monofoxe/Pipefoxe/Pipefoxe.csproj b/Monofoxe/Pipefoxe/Pipefoxe.csproj
deleted file mode 100644
index d1dafdc5..00000000
--- a/Monofoxe/Pipefoxe/Pipefoxe.csproj
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {D59079B2-CC07-4783-9C7F-05E78EBBC5FD}
- Library
- Properties
- Pipefoxe
- Pipefoxe
- v4.6.1
- 512
-
-
-
-
-
- true
- full
- false
- ..\bin\Pipeline\Debug\
- DEBUG;TRACE
- prompt
- 4
- 1591
-
-
- pdbonly
- true
- ..\bin\Pipeline\Release\
- TRACE
- prompt
- 4
-
-
-
- ..\packages\MonoGame.Framework.Portable.3.7.1.189\lib\portable-net45+win8+wpa81\MonoGame.Framework.dll
-
-
- ..\packages\MonoGame.Framework.Content.Pipeline.Portable.3.6.0.1625\lib\portable-net45+win8+wpa81\MonoGame.Framework.Content.Pipeline.dll
-
-
- ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll
-
-
-
-
-
- ..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Drawing.dll
-
-
-
-
- ..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Monofoxe/Pipefoxe/Properties/AssemblyInfo.cs b/Monofoxe/Pipefoxe/Properties/AssemblyInfo.cs
deleted file mode 100644
index 5279d740..00000000
--- a/Monofoxe/Pipefoxe/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Pipefoxe")]
-[assembly: AssemblyDescription("Monogame Pipeline extension library for Monofoxe Engine.")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Chai Foxes")]
-[assembly: AssemblyProduct("Pipefoxe")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("d59079b2-cc07-4783-9c7f-05e78ebbc5fd")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.0.0.0")]
-[assembly: AssemblyFileVersion("2.0.0.0")]
diff --git a/Monofoxe/Pipefoxe/SpriteGroup/ClassGenerator.cs b/Monofoxe/Pipefoxe/SpriteGroup/ClassGenerator.cs
deleted file mode 100644
index 6d1aa2e8..00000000
--- a/Monofoxe/Pipefoxe/SpriteGroup/ClassGenerator.cs
+++ /dev/null
@@ -1,237 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-
-namespace Pipefoxe.SpriteGroup
-{
- ///
- /// Generates class file from a template.
- ///
- public static class ClassGenerator
- {
- private static char _variableKeychar = '#';
-
- ///
- /// Used when file name begins with a char, not allowed in variable names.
- ///
- private static string _paddingStr = "S";
-
-
-
- public static void Generate(string templatePath, string outPath, List sprites, string groupName)
- {
- string[] lines = File.ReadAllLines(templatePath);
-
- var customVariableNames = new List();
- var customVariableValues = new List();
-
- var codeTemplate = new StringBuilder();
-
- var parseVariables = true;
-
- #region Extracting custom variables.
-
- foreach(string l in lines)
- {
- if (parseVariables)
- {
- // Parsing variables.
- if (l.Length > 0 && l[0] == _variableKeychar)
- {
- //. - At least one char. ? - non-greedy, \s* - optional space
- Match nameMatch = Regex.Match(l, _variableKeychar + @"(.+?)\s*=");
- var valueMatch = l.Remove(0, nameMatch.Value.Length).TrimStart();//Regex.Match(l, @"(.+?)", RegexOptions.IgnoreCase);
-
- if (nameMatch.Success)
- {
- customVariableNames.Add(nameMatch.Value.Substring(1,nameMatch.Value.Length - 2).Replace(" ", ""));
- customVariableValues.Add(valueMatch);
- }
- else
- {
- throw new Exception("ERROR: Cannot parse variable. Aborting class generating.");
- }
- }
-
- if (l.Length > 0 && l[0] != _variableKeychar)
- {
- parseVariables = false;
- }
- // Parsing variables.
- }
-
- if (!parseVariables) // Not using else, because in first if parseValues may change.
- {
- // Copying rest of the code.
- codeTemplate.Append(l + Environment.NewLine);
- // Copying rest of the code.
- }
-
- }
-
- #endregion Extracting custom variables.
-
-
- var code = new StringBuilder();
- code.Append(codeTemplate);
-
-
- #region Resolving name conflicts.
-
- /*
- * Some sprites may have identical names, but different paths.
- * Even though this is bad practice, generator
- * allows this and resolves name conflicts.
- */
-
- var spriteNames = new List();
- var spriteOccurences = new Dictionary();
- for(var i = 0; i < sprites.Count; i += 1)
- {
- var name = ToCamelCase(Path.GetFileName(sprites[i].Name));
- if (spriteOccurences.ContainsKey(name))
- {
- spriteNames.Add(name + '_' + spriteOccurences[name]);
- spriteOccurences[name] += 1;
- }
- else
- {
- spriteOccurences.Add(name, 1);
- spriteNames.Add(name);
- }
- }
-
- #endregion Resolving name conflicts.
-
-
- #region Assembling variables from templates.
-
- var completeVariableValues = new List();
-
-
- for(var k = 0; k < customVariableValues.Count; k += 1)
- {
- completeVariableValues.Add(new StringBuilder());
-
- if (sprites.Count > 0)
- {
- var lastSprite = sprites.Last();
-
- var i = 0;
- foreach(var sprite in sprites)
- {
- var v = customVariableValues[k]
- .Replace("", spriteNames[i])
- .Replace("", '"' + sprite.Name + '"');
- i += 1;
-
- completeVariableValues[k].Append(v);
-
- if (sprite != lastSprite)
- {
- completeVariableValues[k].AppendLine();
- }
- }
- }
- }
-
-
- #endregion Assembling variables from templates.
-
-
- var camelGroupName = ToCamelCase(groupName);
- var className = camelGroupName;
- code = code.Replace("", camelGroupName).Replace("", className);
-
- for(var i = 0; i < customVariableNames.Count; i += 1)
- {
- code = code.Replace('<' + customVariableNames[i] + '>', completeVariableValues[i].ToString());
- }
-
- // Now tabs are all messed up. Fixing this just to make code look pretteh.
- FixTabulation(code);
-
- File.WriteAllText(outPath + '/' + className + ".cs", code.ToString());
- }
-
-
-
- ///
- /// Fixes tabs in code.
- ///
- private static void FixTabulation(StringBuilder str)
- {
- var buffer = str.ToString().Replace("\t", ""); // Removing all tabs from code.
- str.Clear();
- str.Append(buffer);
-
- var bracketCount = 0;
-
- var strPtr = 0;
- for(var i = 0; i < buffer.Length - 1; i += 1)
- {
- if (buffer[i] == '{')
- {
- bracketCount += 1;
- }
- if (buffer[i + 1] == '}')
- {
- bracketCount -= 1;
- }
- if (buffer[i] == '\n')
- {
- str.Insert(strPtr + 1, "\t", bracketCount);
- strPtr += bracketCount;
- }
- strPtr += 1;
- }
- }
-
-
-
- ///
- /// Converts regular string to compiler-accepted CamelCase variable name.
- /// some_stuff => SomeStuff
- ///
- public static string ToCamelCase(string str)
- {
- // Removing prohibited symbols from string.
- var rgx = new Regex("[^a-zA-Z0-9 _]");
- str = rgx.Replace(str, "");
-
- if (str.Length == 0)
- {
- return "";
- }
- // Removing prohibited symbols from string.
-
- var words = str.Split(new char[]{'_', ' '});
- var upper = new StringBuilder();
-
- if (char.IsDigit(str[0])) // Variable name cannot begin with a digit.
- {
- upper.Append(_paddingStr);
- }
- if (str[0] == '_') // For variables which begin with underscore.
- {
- upper.Append('_');
- }
-
- // Making each word begin with an uppercase letter.
- foreach(var word in words)
- {
- if (word.Length > 0)
- {
- upper.Append(char.ToUpper(word[0]) + word.Substring(1, word.Length - 1));
- }
- }
- // Making each word begin with an uppercase letter.
-
- return upper.ToString();
- }
-
- }
-}
diff --git a/Monofoxe/Pipefoxe/Tiled/TiledMapProcessor.cs b/Monofoxe/Pipefoxe/Tiled/TiledMapProcessor.cs
deleted file mode 100644
index 5fb3c804..00000000
--- a/Monofoxe/Pipefoxe/Tiled/TiledMapProcessor.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using System.Collections.Generic;
-using Microsoft.Xna.Framework.Content.Pipeline;
-using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
-using Monofoxe.Tiled.MapStructure;
-
-namespace Pipefoxe.Tiled
-{
- ///
- /// Loads and builds external references to textures.
- ///
- [ContentProcessor(DisplayName = "Tiled Map Processor - Monofoxe")]
- public class TiledMapProcessor : ContentProcessor
- {
- public static Dictionary> TextureReferences;
-
- public override TiledMap Process(TiledMap map, ContentProcessorContext context)
- {
- try
- {
- LoadTextureReferences(map, context);
- }
- catch(System.Exception e)
- {
- throw new System.Exception("Failed to process the map! " + e.Message + " " + e.StackTrace);
- }
- return map;
- }
-
- public void LoadTextureReferences(TiledMap map, ContentProcessorContext context)
- {
- TextureReferences = new Dictionary>();
- foreach(var tileset in map.Tilesets)
- {
- if (
- tileset.Properties.ContainsKey(TilesetParser.IgnoreTilesetTextureFlag)
- && bool.Parse(tileset.Properties[TilesetParser.IgnoreTilesetTextureFlag])
- )
- {
- continue; // Skip texture, if we won't need it.
- }
- foreach(var path in tileset.TexturePaths)
- {
- if (TextureReferences.ContainsKey(path))
- {
- continue;
- }
- var assetReference = new ExternalReference(TiledMapImporter.TmxRootDir + "/" + path);
- TextureReferences.Add(path, context.BuildAsset(assetReference, "", null, "", ""));
- }
- }
-
- foreach(var imageLayer in map.ImageLayers)
- {
- if (TextureReferences.ContainsKey(imageLayer.TexturePath))
- {
- continue;
- }
- var asserReference = new ExternalReference(TiledMapImporter.TmxRootDir + "/" + imageLayer.TexturePath);
- TextureReferences.Add(imageLayer.TexturePath, context.BuildAsset(asserReference, "", null, "", ""));
- }
-
- }
-
- }
-}
diff --git a/Monofoxe/Pipefoxe/packages.config b/Monofoxe/Pipefoxe/packages.config
deleted file mode 100644
index 8c976a7c..00000000
--- a/Monofoxe/Pipefoxe/packages.config
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Monofoxe/Monofoxe.Engine/AlphaBlend.fx b/Monofoxe/Resources/AlphaBlend.fx
similarity index 95%
rename from Monofoxe/Monofoxe.Engine/AlphaBlend.fx
rename to Monofoxe/Resources/AlphaBlend.fx
index c3cb6f0b..0aa14d57 100644
--- a/Monofoxe/Monofoxe.Engine/AlphaBlend.fx
+++ b/Monofoxe/Resources/AlphaBlend.fx
@@ -1,111 +1,111 @@
-
-/*
-Base shader for drawing everything, when there are no other shaders applied.
-Main reason for it is proper alpha blending for pretty much everything.
-
-NOTE: This shader is vital part of the engine.
-DO NOT modify it, unless you know, what you're doing and have good reasons!
-*/
-
-float4x4 World;
-float4x4 View;
-float4x4 Projection;
-float4 AmbientColor = float4(1, 1, 1, 1);
-
-uniform const texture BasicTexture;
-
-uniform const sampler BaseSampler : register(s0) = sampler_state
-{
- Texture = (BasicTexture);
-};
-
-struct VertexShaderInput
-{
- float4 Position : POSITION0;
- float2 TexCoords : TEXCOORD0;
- float4 Color : COLOR0;
-};
-
-struct VertexShaderOutput
-{
- float4 Position : POSITION0;
- float2 TexCoords : TEXCOORD0;
- float4 Color : COLOR0;
-};
-
-
-VertexShaderOutput VS_Texture(VertexShaderInput input)
-{
- VertexShaderOutput output;
-
- float4 worldPosition = mul(input.Position, World);
- float4 viewPosition = mul(worldPosition, View);
- output.Position = mul(viewPosition, Projection);
- output.TexCoords = input.TexCoords;
- output.Color = input.Color;
-
- return output;
-}
-
-
-/*
-Premultiplying shader. Used for sufraces, regular sprites, textured primitives and texture fonts.
-*/
-float4 PS_TexturePremultiplied(VertexShaderOutput input) : COLOR0
-{
- float4 color = tex2D(BaseSampler, input.TexCoords.xy);
- return float4(color.r * input.Color.r, color.g * input.Color.g, color.b * input.Color.b, input.Color.a) * color.a;
-}
-
-/*
-Non-premultiplying shader. Used for Monogame's spritefonts.
-*/
-float4 PS_TextureNonPremultiplied(VertexShaderOutput input) : COLOR0
-{
- float4 color = tex2D(BaseSampler, input.TexCoords.xy);
- return color * input.Color;
-}
-
-/*
-Basic shader for primitives without texture.
-*/
-float4 PS_Basic(VertexShaderOutput input) : COLOR0
-{
- return input.Color;
-}
-
-/*
-Techniques are chosen by the engine automatically.
-*/
-
-#ifdef SM4
-
-#define TECHNIQUE(name, vsName, psName) \
- technique name \
- { \
- pass Pass1 \
- { \
- VertexShader = compile vs_4_0_level_9_1 vsName(); \
- PixelShader = compile ps_4_0_level_9_1 psName(); \
- } \
- }
-
-
-#else
-
-#define TECHNIQUE(name, vsName, psName) \
- technique name \
- { \
- pass Pass1 \
- { \
- VertexShader = compile vs_3_0 vsName(); \
- PixelShader = compile ps_3_0 psName(); \
- } \
- }
-
-#endif
-
-
-TECHNIQUE(Basic, VS_Texture, PS_Basic);
-TECHNIQUE(TexturePremultiplied, VS_Texture, PS_TexturePremultiplied);
+
+/*
+Base shader for drawing everything, when there are no other shaders applied.
+Main reason for it is proper alpha blending for pretty much everything.
+
+NOTE: This shader is vital part of the engine.
+DO NOT modify it, unless you know, what you're doing and have good reasons!
+*/
+
+float4x4 World;
+float4x4 View;
+float4x4 Projection;
+float4 AmbientColor = float4(1, 1, 1, 1);
+
+uniform const texture BasicTexture;
+
+uniform const sampler BaseSampler : register(s0) = sampler_state
+{
+ Texture = (BasicTexture);
+};
+
+struct VertexShaderInput
+{
+ float4 Position : POSITION0;
+ float2 TexCoords : TEXCOORD0;
+ float4 Color : COLOR0;
+};
+
+struct VertexShaderOutput
+{
+ float4 Position : POSITION0;
+ float2 TexCoords : TEXCOORD0;
+ float4 Color : COLOR0;
+};
+
+
+VertexShaderOutput VS_Texture(VertexShaderInput input)
+{
+ VertexShaderOutput output;
+
+ float4 worldPosition = mul(input.Position, World);
+ float4 viewPosition = mul(worldPosition, View);
+ output.Position = mul(viewPosition, Projection);
+ output.TexCoords = input.TexCoords;
+ output.Color = input.Color;
+
+ return output;
+}
+
+
+/*
+Premultiplying shader. Used for sufraces, regular sprites, textured primitives and texture fonts.
+*/
+float4 PS_TexturePremultiplied(VertexShaderOutput input) : COLOR0
+{
+ float4 color = tex2D(BaseSampler, input.TexCoords.xy);
+ return float4(color.r * input.Color.r, color.g * input.Color.g, color.b * input.Color.b, input.Color.a) * color.a;
+}
+
+/*
+Non-premultiplying shader. Used for Monogame's spritefonts.
+*/
+float4 PS_TextureNonPremultiplied(VertexShaderOutput input) : COLOR0
+{
+ float4 color = tex2D(BaseSampler, input.TexCoords.xy);
+ return color * input.Color;
+}
+
+/*
+Basic shader for primitives without texture.
+*/
+float4 PS_Basic(VertexShaderOutput input) : COLOR0
+{
+ return input.Color;
+}
+
+/*
+Techniques are chosen by the engine automatically.
+*/
+
+#ifdef SM4
+
+#define TECHNIQUE(name, vsName, psName) \
+ technique name \
+ { \
+ pass Pass1 \
+ { \
+ VertexShader = compile vs_4_0_level_9_1 vsName(); \
+ PixelShader = compile ps_4_0_level_9_1 psName(); \
+ } \
+ }
+
+
+#else
+
+#define TECHNIQUE(name, vsName, psName) \
+ technique name \
+ { \
+ pass Pass1 \
+ { \
+ VertexShader = compile vs_3_0 vsName(); \
+ PixelShader = compile ps_3_0 psName(); \
+ } \
+ }
+
+#endif
+
+
+TECHNIQUE(Basic, VS_Texture, PS_Basic);
+TECHNIQUE(TexturePremultiplied, VS_Texture, PS_TexturePremultiplied);
TECHNIQUE(TextureNonPremultiplied, VS_Texture, PS_TextureNonPremultiplied);
\ No newline at end of file
diff --git a/Monofoxe/Resources/AlphaBlend_dx.mgfxo b/Monofoxe/Resources/AlphaBlend_dx.mgfxo
new file mode 100644
index 00000000..89fee239
Binary files /dev/null and b/Monofoxe/Resources/AlphaBlend_dx.mgfxo differ
diff --git a/Monofoxe/Resources/AlphaBlend_gl.mgfxo b/Monofoxe/Resources/AlphaBlend_gl.mgfxo
new file mode 100644
index 00000000..38674efe
Binary files /dev/null and b/Monofoxe/Resources/AlphaBlend_gl.mgfxo differ
diff --git a/NoPipeline b/NoPipeline
deleted file mode 160000
index 2ebfa388..00000000
--- a/NoPipeline
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 2ebfa38811d071d4101f692ed139a4bc6e36e3d7
diff --git a/Nuget.props b/Nuget.props
new file mode 100644
index 00000000..b5d690bd
--- /dev/null
+++ b/Nuget.props
@@ -0,0 +1,17 @@
+
+
+ $(MonofoxeVersion)
+ Martenfur
+ Chai Foxes
+ Monofoxe Engine
+ A Monogame-based game engine with extremely high fox concenration.
+ https://github.com/Martenfur/Monofoxe/
+ https://github.com/Martenfur/Monofoxe/
+ MPL-2.0
+ logo_nolabel_transparent.png
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PackRelease.ps1 b/PackRelease.ps1
index 313c6150..3a6ee60c 100644
--- a/PackRelease.ps1
+++ b/PackRelease.ps1
@@ -3,69 +3,48 @@
# and nsis.exe added to PATH.
# Maybe rewrite someday using this https://cakebuild.net.
-# Credit: https://alastaircrabtree.com/how-to-find-latest-version-of-msbuild-in-powershell/
-Function Find-MsBuild([int] $MaxVersion = 2019)
-{
- $agentPath = "$Env:programfiles (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe"
- $devPath = "$Env:programfiles (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe"
- $proPath = "$Env:programfiles (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe"
- $communityPath = "$Env:programfiles (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe"
- $communityPath2019 = "$Env:programfiles (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe"
- $fallback2015Path = "${Env:ProgramFiles(x86)}\MSBuild\14.0\Bin\MSBuild.exe"
- $fallbackPath = "C:\Windows\Microsoft.NET\Framework\v4.0.30319"
- $fallback2013Path = "${Env:ProgramFiles(x86)}\MSBuild\12.0\Bin\MSBuild.exe"
- if ((2017 -le $MaxVersion) -And (Test-Path $agentPath)) { return $agentPath }
- If ((2017 -le $MaxVersion) -And (Test-Path $devPath)) { return $devPath }
- If ((2017 -le $MaxVersion) -And (Test-Path $proPath)) { return $proPath }
- If ((2017 -le $MaxVersion) -And (Test-Path $communityPath)) { return $communityPath }
- If ((2019 -le $MaxVersion) -And (Test-Path $communityPath2019)) { return $communityPath2019 }
- If ((2015 -le $MaxVersion) -And (Test-Path $fallback2015Path)) { return $fallback2015Path }
- If ((2013 -le $MaxVersion) -And (Test-Path $fallback2013Path)) { return $fallback2013Path }
- If (Test-Path $fallbackPath) { return $fallbackPath }
-
- throw "Yikes - Unable to find msbuild"
-}
-$msbuild = Find-MsBuild
+[xml]$XmlDocument = Get-Content -Path "$PWD\Packages.props"
+$monofoxeVersion = $XmlDocument.Project.PropertyGroup.MonofoxeVersion
+$nopipelineVersion = $XmlDocument.Project.PropertyGroup.NopipelineVersion
$projectTemplatesPath = "$PWD\Templates\ProjectTemplates\";
$itemTemplatesPath = "$PWD\Templates\ItemTemplates\";
-Function Pack-Item-Template([string] $item)
+Function PackItemTemplate([string] $item)
{
"Packing $item..."
[IO.Compression.ZipFile]::CreateFromDirectory("$itemTemplatesPath$item", "$destItemTemplatesDir$item.zip")
}
-Function Assemble-Template([string] $platform)
+Function ReplaceParameters([string] $platform)
{
- "Assembling templates for $platform..."
- Copy-Item -path "$projectTemplatesPath$platform\" -Destination "$destProjectTemplatesDir" -Recurse -Container
- Copy-Item -path "$PWD/Common/*" -Destination "$destProjectTemplatesDir$platform" -Recurse -Container
+ "Assembling parameters for $platform..."
- Copy-Item -path "$destProjectTemplatesDir$platform\" -Destination "$destProjectTemplatesDir$crossplatform\" -Recurse -Container
+ $csprojPath = "$destProjectTemplatesDir\Crossplatform\$platform\$platform.csproj"
- [IO.Compression.ZipFile]::CreateFromDirectory("$destProjectTemplatesDir$platform", "$destProjectTemplatesDir$platform.zip")
+ if (Test-Path -Path $csprojPath)
+ {
+ (Get-Content -Path $csprojPath) -replace '\$\(MonofoxeVersion\)', $monofoxeVersion | Set-Content -Path $csprojPath
+ (Get-Content -Path $csprojPath) -replace '\$\(NopipelineVersion\)', $nopipelineVersion | Set-Content -Path $csprojPath
+ }
}
-
Add-Type -A System.IO.Compression.FileSystem
-$debug = $FALSE
-
-$srcLibDir = "$PWD\Monofoxe\bin\Release"
-
-$destCommonDir = "$PWD\Templates\CommonFiles"
$destReleaseDir = "$PWD\Release\"
$destProjectTemplatesDir = "$destReleaseDir\ProjectTemplates\"
$destItemTemplatesDir = "$destReleaseDir\ItemTemplates\"
$crossplatform = "Crossplatform"
+"Compiling shaders..."
+dotnet tool install -g dotnet-mgfxc
+mgfxc Monofoxe/Resources/AlphaBlend.fx Monofoxe/Resources/AlphaBlend_dx.mgfxo /Profile:DirectX_11
+mgfxc Monofoxe/Resources/AlphaBlend.fx Monofoxe/Resources/AlphaBlend_gl.mgfxo /Profile:OpenGL
-"Building solution $msbuild..."
-&$msbuild ("$PWD\Monofoxe\Monofoxe.sln" ,'/verbosity:q','/p:configuration=Release','/t:Clean,Build', '/p:NoWarn=1591')
-&$msbuild ("$PWD\NoPipeline\NoPipeline\NoPipeline.sln" ,'/verbosity:q','/p:configuration=Release','/t:Clean,Build')
+"Building solution..."
+dotnet build ("$PWD\Monofoxe\Monofoxe.sln" ,'/verbosity:q','/p:configuration=Release','/t:Clean,Build', '/p:NoWarn=1591')
"Cleaning output directory at $destReleaseDir..."
if (Test-Path "$destReleaseDir" -PathType Container)
@@ -77,20 +56,16 @@ New-Item -ItemType Directory -Force -Path "$destProjectTemplatesDir" > $null
New-Item -ItemType Directory -Force -Path "$destItemTemplatesDir" > $null
-
Copy-Item -path "$projectTemplatesPath$crossplatform\" -Destination "$destProjectTemplatesDir" -Recurse -Container
-Pack-Item-Template "Entity"
-Pack-Item-Template "Component"
-Pack-Item-Template "EntityTemplate"
-Pack-Item-Template "TiledEntityFactory"
-Pack-Item-Template "ResourceBox"
-
-Assemble-Template "GL"
-Assemble-Template "DX"
-Assemble-Template "MonofoxeDotnetStandardLibrary"
-Assemble-Template "Shared"
+PackItemTemplate "Entity"
+PackItemTemplate "Component"
+PackItemTemplate "TiledEntityFactory"
+ReplaceParameters "DX"
+ReplaceParameters "GL"
+ReplaceParameters "Library"
+ReplaceParameters "Content"
[IO.Compression.ZipFile]::CreateFromDirectory("$destProjectTemplatesDir$crossplatform", "$destProjectTemplatesDir$crossplatform.zip")
@@ -98,6 +73,8 @@ Assemble-Template "Shared"
"Making installer..."
&makensis Installer/packInstaller.nsi
+$debug = $FALSE
+
"Cleaning..."
if (!$debug)
{
@@ -106,6 +83,3 @@ if (!$debug)
}
Read-Host -Prompt "Done! Press Enter to exit"
-
-
-
diff --git a/Packages.props b/Packages.props
new file mode 100644
index 00000000..2a6cc4bc
--- /dev/null
+++ b/Packages.props
@@ -0,0 +1,6 @@
+
+
+ 2.0.0
+ 2.0.1
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index ab32e549..d441ba1d 100644
--- a/README.md
+++ b/README.md
@@ -6,11 +6,9 @@ Its main goal is to greatly simplify working with Monogame and to provide basic
enabling you to just *create a new project and make a damn game* without removing low-level access to the framework.
Monofoxe took a lot of inspiration from Game Maker, so it should be a bit familiar to some folks.
-**Current version: 2.0.0.0-dev** [View changelog](/CHANGELOG.md)
+[![nuget](https://badgen.net/nuget/v/Monofoxe.Engine?icon=nuget)](https://www.nuget.org/packages/Monofoxe.Engine) [View changelog](/CHANGELOG.md)
-[Download in-dev build (recommended)](https://github.com/Martenfur/Monofoxe/releases/)
-
-[Download last stable release](https://github.com/gnFur/Monofoxe/releases/latest)
+[Download last stable release](https://github.com/Martenfur/Monofoxe/releases/latest)
[**View Docs**](Docs/README.md)
@@ -27,11 +25,11 @@ Everything Monogame does, plus:
* Input management.
* Useful math for collisions and other game stuff.
* Timers, alarms, cameras, state machines, tilemaps, foxes!
-* FMOD audio support (As a standalone [library](https://github.com/gnFur/ChaiFoxes.FMODAudio/)).
+* FMOD audio support (As a standalone [library](https://github.com/Martenfur/ChaiFoxes.FMODAudio/)).
* Hybrid EC.
* Scene system (with layers!).
* Tiled maps support.
-* Enhanced resource management via [NoPipeline](https://github.com/Martenfur/NoPipeline).
+* Enhanced content management via [Nopipeline](https://github.com/Martenfur/Nopipeline).
Coming in the future:
@@ -51,18 +49,17 @@ Well, up to you. Currently I am developing Monofoxe alone, and can't really prov
# How do I use it?
-Download the Monofoxe installer from the [latest release](https://github.com/Martenfur/Monofoxe/releases/latest) or [in-dev build (recommended)](https://github.com/Martenfur/Monofoxe/releases/).
-Installer bundles Visual Studio 2015, 2017 and 2019 templates, [NoPipeline](https://github.com/Martenfur/NoPipeline) and Monogame 3.7.1 installation. If you don't want 3.7.1, Monofoxe is confirmed to work on 3.6 and 3.7. It most likely will work on Monogame dev build, but it constantly changes, so you never know.
+Download the Monofoxe installer from the [latest release](https://github.com/Martenfur/Monofoxe/releases/latest). Installer bundles Visual Studio 2017 and 2019 templates. Monofoxe is distributed via nugets, so templates aren't mandatory. It's also a good idea to install project templates for [Monogame](https://github.com/MonoGame/MonoGame/releases/latest).
Just install Monofoxe, create Monofoxe project and you're good to go.
**NOTE:** Due to VS2019 project search being completely broken, templates may not appear in the search right away. Instead of searching select "Monofoxe" in `Project Types`.
-You can also check out the [basic feature demos](Monofoxe.Playground/), [Demo game](https://bitbucket.org/gnFur/monofoxe.demo/) or the [Docs](Docs/README.md) (Currently not finished) to learn how to use Monofoxe.
+You can also check out the [basic feature demos](Monofoxe.Playground/) or the [Docs](Docs/README.md) to learn how to use Monofoxe.
-# I've suddenly started loving foxes and want to contribute!
+# I've suddenly started loving foxes and want to contribute
-That's the spirit. Check out if I need any help on my [Quire board](https://quire.io/w/Monofoxe/?board=Monofoxe). Stuff under `Open for taking` category is, well, open for taking. You can also contact me via email (`chaifoxes@gmail.com`), on [Twitter](https://twitter.com/ChaiFoxes) or on [Discord](https://discord.gg/SZ9Z5WR).
+That's the spirit. Check out if I need any help on my [Quire board](https://quire.io/w/Monofoxe/?board=Monofoxe). Stuff under `Open for taking` category is, well, open for taking. You can also contact me via email (`chaifoxes@gmail.com`), on [Twitter](https://twitter.com/ChaiFoxes) or on [Discord](https://discord.gg/F9tPYaD).
**Don't forget to check out Codestyle.cs before contributing!!!**
@@ -71,4 +68,4 @@ That's the spirit. Check out if I need any help on my [Quire board](https://quir
- [MirrorOfSun](https://github.com/MirrorOfSUn)
- [Shazan](https://bitbucket.org/%7B07c29368-d971-4ab1-8ec5-1a89d56bfa43%7D/)
-*don't forget to pet your foxes*
+*don't forget to pet your foxes*
\ No newline at end of file
diff --git a/Templates/ItemTemplates/EntityTemplate/EntityTemplate.cs b/Templates/ItemTemplates/EntityTemplate/EntityTemplate.cs
deleted file mode 100644
index fa2e3229..00000000
--- a/Templates/ItemTemplates/EntityTemplate/EntityTemplate.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using Microsoft.Xna.Framework;
-using Monofoxe.Engine;
-using Monofoxe.Engine.Drawing;
-using Monofoxe.Engine.EC;
-using Monofoxe.Engine.SceneSystem;
-using Monofoxe.Engine.Utils;
-using Monofoxe.Engine.Resources;
-using System;
-using System.Collections.Generic;
-
-namespace $rootnamespace$
-{
- public class $safeitemname$ : IEntityTemplate
- {
- public string Tag => "$itemname$";
-
- public Entity Make(Layer layer)
- {
-
-
- return null;
- }
- }
-}
\ No newline at end of file
diff --git a/Templates/ItemTemplates/EntityTemplate/EntityTemplate.vstemplate b/Templates/ItemTemplates/EntityTemplate/EntityTemplate.vstemplate
deleted file mode 100644
index a7b80a3d..00000000
--- a/Templates/ItemTemplates/EntityTemplate/EntityTemplate.vstemplate
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- Monofoxe Entity Template
- An entity template class for Monofoxe Engine.
- CSharp
- EntityTemplate.cs
- __TemplateIcon.png
- Monofoxe.EntityTemplate
- CSharp + SharedAssetsProject
-
-
-
- EntityTemplate.cs
-
-
\ No newline at end of file
diff --git a/Templates/ItemTemplates/EntityTemplate/__TemplateIcon.png b/Templates/ItemTemplates/EntityTemplate/__TemplateIcon.png
deleted file mode 100644
index d85201f9..00000000
Binary files a/Templates/ItemTemplates/EntityTemplate/__TemplateIcon.png and /dev/null differ
diff --git a/Templates/ItemTemplates/ResourceBox/ResourceBox.cs b/Templates/ItemTemplates/ResourceBox/ResourceBox.cs
deleted file mode 100644
index d330ba65..00000000
--- a/Templates/ItemTemplates/ResourceBox/ResourceBox.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using Microsoft.Xna.Framework.Content;
-using Microsoft.Xna.Framework.Graphics;
-using Monofoxe.Engine;
-using Monofoxe.Engine.Resources;
-using System;
-using System.Collections.Generic;
-
-namespace $rootnamespace$
-{
- public class $safeitemname$ : ResourceBox // Replace with your resource type.
- {
- private static ContentManager _content;
-
- public override string Name => "Effects";
-
- public override void Load()
- {
- if (Loaded)
- {
- return;
- }
- Loaded = true;
- _content = new ContentManager(GameMgr.Game.Services);
- _content.RootDirectory = AssetMgr.ContentDir + '/' + AssetMgr.EffectsDir;
-
- // Add your resources here.
- // Example:
- // AddResource("Test", _content.Load("test"));
- // You can access the resources via ResourceHub.GetResource<>();
-
- }
-
- public override void Unload()
- {
- if (!Loaded)
- {
- return;
- }
- Loaded = false;
- _content.Unload();
- }
-
- }
-}
\ No newline at end of file
diff --git a/Templates/ItemTemplates/ResourceBox/ResourceBox.vstemplate b/Templates/ItemTemplates/ResourceBox/ResourceBox.vstemplate
deleted file mode 100644
index 37bb1b97..00000000
--- a/Templates/ItemTemplates/ResourceBox/ResourceBox.vstemplate
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- Monofoxe Resource Box
- A resource box class for Monofoxe Engine. Used for loading resources.
- CSharp
- ResourceBox.cs
- __TemplateIcon.png
- Monofoxe.ResourceBox
- CSharp + SharedAssetsProject
-
-
-
- ResourceBox.cs
-
-
\ No newline at end of file
diff --git a/Templates/ItemTemplates/ResourceBox/__TemplateIcon.png b/Templates/ItemTemplates/ResourceBox/__TemplateIcon.png
deleted file mode 100644
index b752c423..00000000
Binary files a/Templates/ItemTemplates/ResourceBox/__TemplateIcon.png and /dev/null differ
diff --git a/Templates/ProjectTemplates/Crossplatform/Content/Content.csproj b/Templates/ProjectTemplates/Crossplatform/Content/Content.csproj
new file mode 100644
index 00000000..288a022a
--- /dev/null
+++ b/Templates/ProjectTemplates/Crossplatform/Content/Content.csproj
@@ -0,0 +1,18 @@
+
+
+ netstandard2.0
+ false
+ true
+ bin/
+
+
+
+
+
+ All
+
+
+ All
+
+
+
diff --git a/Templates/ProjectTemplates/Crossplatform/Content/Content.vstemplate b/Templates/ProjectTemplates/Crossplatform/Content/Content.vstemplate
new file mode 100644
index 00000000..b18924c7
--- /dev/null
+++ b/Templates/ProjectTemplates/Crossplatform/Content/Content.vstemplate
@@ -0,0 +1,55 @@
+
+
+ Monofoxe Pipeline Extension Library (.NET Standard)
+ .NET Standard library for Monofoxe games.
+ CSharp
+ 1
+
+
+ 43300
+ true
+ FoxeLib
+ true
+ Enabled
+ true
+ true
+ C#
+ Windows
+ Linux
+ Android
+ Library
+ Monofoxe
+ MonoGame
+
+
+
+
+
+ Default.spritegroup
+
+ Monofoxe.json
+ Monofoxe.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Arial.spritefont
+
+
+
+
+
+
diff --git a/Templates/ProjectTemplates/Crossplatform/Content/Content/Content.mgcb b/Templates/ProjectTemplates/Crossplatform/Content/Content/Content.mgcb
new file mode 100644
index 00000000..93ad71c4
--- /dev/null
+++ b/Templates/ProjectTemplates/Crossplatform/Content/Content/Content.mgcb
@@ -0,0 +1,15 @@
+
+#----------------------------- Global Properties ----------------------------#
+
+/outputDir:bin/$(Platform)
+/intermediateDir:obj/$(Platform)
+/config:
+/profile:Reach
+/compress:False
+
+#-------------------------------- References --------------------------------#
+
+#---------------------------------- Content ---------------------------------#
+
+
+
diff --git a/Templates/ProjectTemplates/Crossplatform/Content/Content/Content.npl b/Templates/ProjectTemplates/Crossplatform/Content/Content/Content.npl
new file mode 100644
index 00000000..19b7ae95
--- /dev/null
+++ b/Templates/ProjectTemplates/Crossplatform/Content/Content/Content.npl
@@ -0,0 +1,88 @@
+{
+ "root": "../../$ext_specifiedsolutionname$.Content/Content/",
+ "references":
+ [
+ "../../$ext_specifiedsolutionname$.Content/bin/Debug/*.dll"
+ ],
+ "content":
+ {
+ "contentList":
+ {
+ "path": "$Content.npl",
+ "recursive": "False",
+ "action": "build",
+ "importer": "ResourceInfoImporter",
+ "processor": "PassThroughProcessor",
+ "watch":
+ [
+ "../../Monofoxe.Playground.Content/Content/*"
+ ]
+ },
+ "music":
+ {
+ "path": "Audio/Music/*.ogg",
+ "recursive": "True",
+ "action": "copy"
+ },
+ "sounds":
+ {
+ "path": "Audio/Sounds/*.wav",
+ "recursive": "True",
+ "action": "copy"
+ },
+ "defaultSpriteGroup":
+ {
+ "path": "Graphics/*.spritegroup",
+ "recursive": "True",
+ "action": "build",
+ "importer": "SpriteGroupImporter",
+ "processor": "SpriteGroupProcessor",
+ "watch":
+ [
+ "Default/*.png",
+ "Default/*.json"
+ ]
+ },
+ "effects":
+ {
+ "path": "Effects/*.fx",
+ "recursive": "True",
+ "action": "build",
+ "importer": "EffectImporter",
+ "processor": "EffectProcessor"
+ },
+ "tiledMaps":
+ {
+ "path": "Maps/*.tmx",
+ "recursive": "True",
+ "action": "build",
+ "importer": "TiledMapImporter",
+ "processor": "PassThroughProcessor",
+ "watch":
+ [
+ "Tilesets/*.tsx",
+ "Tilesets/*.png",
+ "Templates/*.tsx",
+ "Templates/*.tx",
+ "Templates/*.png"
+ ]
+ },
+ "tiledMapTextures":
+ {
+ "path": "Maps/*.png",
+ "recursive": "True",
+ "action": "build",
+ "importer": "TextureImporter",
+ "processor": "TextureProcessor"
+ },
+ "fonts":
+ {
+ "path": "Fonts/*.spritefont",
+ "recursive": "True",
+ "action": "build",
+ "importer": "FontDescriptionImporter",
+ "processor": "FontDescriptionProcessor"
+ }
+
+ }
+}
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Fonts/Arial.spritefont b/Templates/ProjectTemplates/Crossplatform/Content/Content/Fonts/Arial.spritefont
similarity index 97%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Fonts/Arial.spritefont
rename to Templates/ProjectTemplates/Crossplatform/Content/Content/Fonts/Arial.spritefont
index dd4d67f4..7425f386 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/Content/Fonts/Arial.spritefont
+++ b/Templates/ProjectTemplates/Crossplatform/Content/Content/Fonts/Arial.spritefont
@@ -1,65 +1,65 @@
-
-
-
-
-
-
- Arial
-
-
- 12
-
-
- 0
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Ѐ
- ӿ
-
-
-
-
+
+
+
+
+
+
+ Arial
+
+
+ 12
+
+
+ 0
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Ѐ
+ ӿ
+
+
+
+
diff --git a/Templates/ProjectTemplates/Crossplatform/Content/Content/Graphics/Default.spritegroup b/Templates/ProjectTemplates/Crossplatform/Content/Content/Graphics/Default.spritegroup
new file mode 100644
index 00000000..46d07c88
--- /dev/null
+++ b/Templates/ProjectTemplates/Crossplatform/Content/Content/Graphics/Default.spritegroup
@@ -0,0 +1,11 @@
+{
+ "atlasSize": 512,
+ "texturePadding": 1,
+ "rootDir": "/Default",
+ "singleTexturesWildcards":
+ [
+ "/Textures/*"
+ ],
+
+ "debugMode": "false"
+}
\ No newline at end of file
diff --git a/Templates/ProjectTemplates/Crossplatform/Content/Content/Graphics/Default/Monofoxe.json b/Templates/ProjectTemplates/Crossplatform/Content/Content/Graphics/Default/Monofoxe.json
new file mode 100644
index 00000000..184ba72d
--- /dev/null
+++ b/Templates/ProjectTemplates/Crossplatform/Content/Content/Graphics/Default/Monofoxe.json
@@ -0,0 +1,6 @@
+{
+ "v": 1,
+ "h": 1,
+ "originX": "center",
+ "originY": "center"
+}
\ No newline at end of file
diff --git a/Templates/ProjectTemplates/Crossplatform/Content/Content/Graphics/Default/Monofoxe.png b/Templates/ProjectTemplates/Crossplatform/Content/Content/Graphics/Default/Monofoxe.png
new file mode 100644
index 00000000..b26e4089
Binary files /dev/null and b/Templates/ProjectTemplates/Crossplatform/Content/Content/Graphics/Default/Monofoxe.png differ
diff --git a/Templates/ProjectTemplates/Crossplatform/Crossplatform.vstemplate b/Templates/ProjectTemplates/Crossplatform/Crossplatform.vstemplate
index c5eb248e..034eb511 100644
--- a/Templates/ProjectTemplates/Crossplatform/Crossplatform.vstemplate
+++ b/Templates/ProjectTemplates/Crossplatform/Crossplatform.vstemplate
@@ -1,7 +1,7 @@
Monofoxe Crossplatform Project
- A Monofoxe game project for Windows, Mac and Linux. Includes Shared, DX and GL projects.
+ A Monofoxe game project for WindowsDX and DesktopGL. Supports Windows, Mac and Linux.
CSharp
1
@@ -22,11 +22,12 @@
OpenGL
Monofoxe
MonoGame
+
- Shared\Shared.vstemplate
+ Library\Library.vstemplate
GL\GL.vstemplate
@@ -34,6 +35,9 @@
DX\DX.vstemplate
+
+ Content\Content.vstemplate
+
diff --git a/Templates/ProjectTemplates/Crossplatform/DX/Content/Content.mgcb b/Templates/ProjectTemplates/Crossplatform/DX/Content/Content.mgcb
new file mode 100644
index 00000000..93ad71c4
--- /dev/null
+++ b/Templates/ProjectTemplates/Crossplatform/DX/Content/Content.mgcb
@@ -0,0 +1,15 @@
+
+#----------------------------- Global Properties ----------------------------#
+
+/outputDir:bin/$(Platform)
+/intermediateDir:obj/$(Platform)
+/config:
+/profile:Reach
+/compress:False
+
+#-------------------------------- References --------------------------------#
+
+#---------------------------------- Content ---------------------------------#
+
+
+
diff --git a/Monofoxe.Playground/Monofoxe.Playground/Content/Content.npl b/Templates/ProjectTemplates/Crossplatform/DX/Content/Content.npl
similarity index 57%
rename from Monofoxe.Playground/Monofoxe.Playground/Content/Content.npl
rename to Templates/ProjectTemplates/Crossplatform/DX/Content/Content.npl
index 63c27449..df2fc361 100644
--- a/Monofoxe.Playground/Monofoxe.Playground/Content/Content.npl
+++ b/Templates/ProjectTemplates/Crossplatform/DX/Content/Content.npl
@@ -1,76 +1,88 @@
-{
- "references":
- [
- "../../../Monofoxe/bin/Pipeline/Debug/Pipefoxe.dll"
- ],
- "content":
- {
- "contentList":
- {
- "path": "Content.mgcb",
- "recursive": "False",
- "action": "build",
- "importer": "AssetInfoImporter",
- "processor": "PassThroughProcessor",
- },
- "music":
- {
- "path": "Audio/Music/*.ogg",
- "recursive": "True",
- "action": "copy",
- },
- "sounds":
- {
- "path": "Audio/Sounds/*.wav",
- "recursive": "True",
- "action": "copy",
- },
- "defaultSpriteGroup":
- {
- "path": "Graphics/*.spritegroup",
- "recursive": "True",
- "action": "build",
- "importer": "SpriteGroupImporter",
- "processor": "SpriteGroupProcessor",
- "watch":
- [
- "Default/*.png",
- "Default/*.json",
- "*.cstemplate",
- ],
- },
- "effects":
- {
- "path": "Effects/*.fx",
- "recursive": "True",
- "action": "build",
- "importer": "EffectImporter",
- "processor": "EffectProcessor",
- },
- "tiledMaps":
- {
- "path": "Maps/*.tmx",
- "recursive": "True",
- "action": "build",
- "importer": "TiledMapImporter",
- "processor": "TiledMapProcessor",
- "watch":
- [
- "Tilesets/*.tsx",
- "Tilesets/*.png",
- "Templates/*.tsx",
- "Templates/*.tx",
- "Templates/*.png"
- ]
- },
- "fonts":
- {
- "path": "Fonts/*.spritefont",
- "recursive": "True",
- "action": "build",
- "importer": "FontDescriptionImporter",
- "processor": "FontDescriptionProcessor",
- },
-
- }
-}
\ No newline at end of file
+{
+ "root": "../../$ext_safeprojectname$.Content/Content/",
+ "references":
+ [
+ "../../$ext_safeprojectname$.Content/bin/*.dll"
+ ],
+ "content":
+ {
+ "contentList":
+ {
+ "path": "$Content.npl",
+ "recursive": "False",
+ "action": "build",
+ "importer": "ResourceInfoImporter",
+ "processor": "PassThroughProcessor",
+ "watch":
+ [
+ "../../Monofoxe.Playground.Content/Content/*"
+ ]
+ },
+ "music":
+ {
+ "path": "Audio/Music/*.ogg",
+ "recursive": "True",
+ "action": "copy"
+ },
+ "sounds":
+ {
+ "path": "Audio/Sounds/*.wav",
+ "recursive": "True",
+ "action": "copy"
+ },
+ "defaultSpriteGroup":
+ {
+ "path": "Graphics/*.spritegroup",
+ "recursive": "True",
+ "action": "build",
+ "importer": "SpriteGroupImporter",
+ "processor": "SpriteGroupProcessor",
+ "watch":
+ [
+ "Default/*.png",
+ "Default/*.json"
+ ]
+ },
+ "effects":
+ {
+ "path": "Effects/*.fx",
+ "recursive": "True",
+ "action": "build",
+ "importer": "EffectImporter",
+ "processor": "EffectProcessor"
+ },
+ "tiledMaps":
+ {
+ "path": "Maps/*.tmx",
+ "recursive": "True",
+ "action": "build",
+ "importer": "TiledMapImporter",
+ "processor": "PassThroughProcessor",
+ "watch":
+ [
+ "Tilesets/*.tsx",
+ "Tilesets/*.png",
+ "Templates/*.tsx",
+ "Templates/*.tx",
+ "Templates/*.png"
+ ]
+ },
+ "tiledMapTextures":
+ {
+ "path": "Maps/*.png",
+ "recursive": "True",
+ "action": "build",
+ "importer": "TextureImporter",
+ "processor": "TextureProcessor"
+ },
+ "fonts":
+ {
+ "path": "Fonts/*.spritefont",
+ "recursive": "True",
+ "action": "build",
+ "importer": "FontDescriptionImporter",
+ "processor": "FontDescriptionProcessor"
+ }
+
+ }
+}
diff --git a/Templates/ProjectTemplates/Crossplatform/DX/DX.csproj b/Templates/ProjectTemplates/Crossplatform/DX/DX.csproj
new file mode 100644
index 00000000..a0448a99
--- /dev/null
+++ b/Templates/ProjectTemplates/Crossplatform/DX/DX.csproj
@@ -0,0 +1,37 @@
+
+
+ WinExe
+ netcoreapp3.1
+ false
+ false
+ true
+
+
+ app.manifest
+ Icon.ico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Templates/ProjectTemplates/DX/DX.vstemplate b/Templates/ProjectTemplates/Crossplatform/DX/DX.vstemplate
similarity index 80%
rename from Templates/ProjectTemplates/DX/DX.vstemplate
rename to Templates/ProjectTemplates/Crossplatform/DX/DX.vstemplate
index 88907f27..ae570eb6 100644
--- a/Templates/ProjectTemplates/DX/DX.vstemplate
+++ b/Templates/ProjectTemplates/Crossplatform/DX/DX.vstemplate
@@ -12,8 +12,6 @@
true
Enabled
true
- __TemplateIcon.png
- __PreviewImage.png
true
C#
Windows
@@ -27,12 +25,10 @@
Icon.ico
Program.cs
app.manifest
- Monofoxe.props
-
-
- AssemblyInfo.cs
+
+ Content.mgcb
+ Content.npl
-
diff --git a/Templates/ProjectTemplates/Crossplatform/DX/Icon.ico b/Templates/ProjectTemplates/Crossplatform/DX/Icon.ico
new file mode 100644
index 00000000..86aab077
Binary files /dev/null and b/Templates/ProjectTemplates/Crossplatform/DX/Icon.ico differ
diff --git a/Templates/ProjectTemplates/Crossplatform/DX/Program.cs b/Templates/ProjectTemplates/Crossplatform/DX/Program.cs
new file mode 100644
index 00000000..6425d992
--- /dev/null
+++ b/Templates/ProjectTemplates/Crossplatform/DX/Program.cs
@@ -0,0 +1,19 @@
+using Monofoxe.Engine.WindowsDX;
+using System;
+
+namespace $safeprojectname$
+{
+ public static class Program
+ {
+ [STAThread]
+ static void Main()
+ {
+ MonofoxePlatform.Init();
+
+ using (var game = new Game1())
+ {
+ game.Run();
+ }
+ }
+ }
+}
diff --git a/Templates/ProjectTemplates/DX/app.manifest b/Templates/ProjectTemplates/Crossplatform/DX/app.manifest
similarity index 100%
rename from Templates/ProjectTemplates/DX/app.manifest
rename to Templates/ProjectTemplates/Crossplatform/DX/app.manifest
diff --git a/Templates/ProjectTemplates/Crossplatform/GL/Content/Content.mgcb b/Templates/ProjectTemplates/Crossplatform/GL/Content/Content.mgcb
new file mode 100644
index 00000000..93ad71c4
--- /dev/null
+++ b/Templates/ProjectTemplates/Crossplatform/GL/Content/Content.mgcb
@@ -0,0 +1,15 @@
+
+#----------------------------- Global Properties ----------------------------#
+
+/outputDir:bin/$(Platform)
+/intermediateDir:obj/$(Platform)
+/config:
+/profile:Reach
+/compress:False
+
+#-------------------------------- References --------------------------------#
+
+#---------------------------------- Content ---------------------------------#
+
+
+
diff --git a/Templates/ProjectTemplates/Crossplatform/GL/Content/Content.npl b/Templates/ProjectTemplates/Crossplatform/GL/Content/Content.npl
new file mode 100644
index 00000000..40021e24
--- /dev/null
+++ b/Templates/ProjectTemplates/Crossplatform/GL/Content/Content.npl
@@ -0,0 +1,88 @@
+{
+ "root": "../../$ext_specifiedsolutionname$.Content/Content/",
+ "references":
+ [
+ "../../$ext_specifiedsolutionname$.Content/bin/*.dll"
+ ],
+ "content":
+ {
+ "contentList":
+ {
+ "path": "$Content.npl",
+ "recursive": "False",
+ "action": "build",
+ "importer": "ResourceInfoImporter",
+ "processor": "PassThroughProcessor",
+ "watch":
+ [
+ "../../Monofoxe.Playground.Content/Content/*"
+ ]
+ },
+ "music":
+ {
+ "path": "Audio/Music/*.ogg",
+ "recursive": "True",
+ "action": "copy"
+ },
+ "sounds":
+ {
+ "path": "Audio/Sounds/*.wav",
+ "recursive": "True",
+ "action": "copy"
+ },
+ "defaultSpriteGroup":
+ {
+ "path": "Graphics/*.spritegroup",
+ "recursive": "True",
+ "action": "build",
+ "importer": "SpriteGroupImporter",
+ "processor": "SpriteGroupProcessor",
+ "watch":
+ [
+ "Default/*.png",
+ "Default/*.json"
+ ]
+ },
+ "effects":
+ {
+ "path": "Effects/*.fx",
+ "recursive": "True",
+ "action": "build",
+ "importer": "EffectImporter",
+ "processor": "EffectProcessor"
+ },
+ "tiledMaps":
+ {
+ "path": "Maps/*.tmx",
+ "recursive": "True",
+ "action": "build",
+ "importer": "TiledMapImporter",
+ "processor": "PassThroughProcessor",
+ "watch":
+ [
+ "Tilesets/*.tsx",
+ "Tilesets/*.png",
+ "Templates/*.tsx",
+ "Templates/*.tx",
+ "Templates/*.png"
+ ]
+ },
+ "tiledMapTextures":
+ {
+ "path": "Maps/*.png",
+ "recursive": "True",
+ "action": "build",
+ "importer": "TextureImporter",
+ "processor": "TextureProcessor"
+ },
+ "fonts":
+ {
+ "path": "Fonts/*.spritefont",
+ "recursive": "True",
+ "action": "build",
+ "importer": "FontDescriptionImporter",
+ "processor": "FontDescriptionProcessor"
+ }
+
+ }
+}
diff --git a/Templates/ProjectTemplates/Crossplatform/GL/GL.csproj b/Templates/ProjectTemplates/Crossplatform/GL/GL.csproj
new file mode 100644
index 00000000..88a020a6
--- /dev/null
+++ b/Templates/ProjectTemplates/Crossplatform/GL/GL.csproj
@@ -0,0 +1,44 @@
+
+
+ WinExe
+ netcoreapp3.1
+ false
+ false
+
+
+ app.manifest
+ Icon.ico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Templates/ProjectTemplates/GL/GL.vstemplate b/Templates/ProjectTemplates/Crossplatform/GL/GL.vstemplate
similarity index 81%
rename from Templates/ProjectTemplates/GL/GL.vstemplate
rename to Templates/ProjectTemplates/Crossplatform/GL/GL.vstemplate
index ee218a49..4a72acea 100644
--- a/Templates/ProjectTemplates/GL/GL.vstemplate
+++ b/Templates/ProjectTemplates/Crossplatform/GL/GL.vstemplate
@@ -12,8 +12,6 @@
true
Enabled
true
- __TemplateIcon.png
- __PreviewImage.png
true
C#
Windows
@@ -29,12 +27,10 @@
Icon.bmp
Program.cs
app.manifest
- Monofoxe.props
-
-
- AssemblyInfo.cs
+
+ Content.mgcb
+ Content.npl
-
diff --git a/Templates/ProjectTemplates/Crossplatform/GL/Icon.bmp b/Templates/ProjectTemplates/Crossplatform/GL/Icon.bmp
new file mode 100644
index 00000000..a6b68305
Binary files /dev/null and b/Templates/ProjectTemplates/Crossplatform/GL/Icon.bmp differ
diff --git a/Templates/ProjectTemplates/Crossplatform/GL/Icon.ico b/Templates/ProjectTemplates/Crossplatform/GL/Icon.ico
new file mode 100644
index 00000000..86aab077
Binary files /dev/null and b/Templates/ProjectTemplates/Crossplatform/GL/Icon.ico differ
diff --git a/Templates/ProjectTemplates/Crossplatform/GL/Program.cs b/Templates/ProjectTemplates/Crossplatform/GL/Program.cs
new file mode 100644
index 00000000..56b1bef3
--- /dev/null
+++ b/Templates/ProjectTemplates/Crossplatform/GL/Program.cs
@@ -0,0 +1,19 @@
+using Monofoxe.Engine.DesktopGL;
+using System;
+
+namespace $safeprojectname$
+{
+ public static class Program
+ {
+ [STAThread]
+ static void Main()
+ {
+ MonofoxePlatform.Init();
+
+ using (var game = new Game1())
+ {
+ game.Run();
+ }
+ }
+ }
+}
diff --git a/Templates/ProjectTemplates/GL/app.manifest b/Templates/ProjectTemplates/Crossplatform/GL/app.manifest
similarity index 100%
rename from Templates/ProjectTemplates/GL/app.manifest
rename to Templates/ProjectTemplates/Crossplatform/GL/app.manifest
diff --git a/Templates/ProjectTemplates/Crossplatform/Icon.bmp b/Templates/ProjectTemplates/Crossplatform/Icon.bmp
deleted file mode 100644
index c64a608b..00000000
Binary files a/Templates/ProjectTemplates/Crossplatform/Icon.bmp and /dev/null differ
diff --git a/Templates/ProjectTemplates/Crossplatform/Icon.ico b/Templates/ProjectTemplates/Crossplatform/Icon.ico
new file mode 100644
index 00000000..86aab077
Binary files /dev/null and b/Templates/ProjectTemplates/Crossplatform/Icon.ico differ
diff --git a/Templates/ProjectTemplates/Shared/Game1.cs b/Templates/ProjectTemplates/Crossplatform/Library/Game1.cs
similarity index 78%
rename from Templates/ProjectTemplates/Shared/Game1.cs
rename to Templates/ProjectTemplates/Crossplatform/Library/Game1.cs
index cdb05914..36f8ced3 100644
--- a/Templates/ProjectTemplates/Shared/Game1.cs
+++ b/Templates/ProjectTemplates/Crossplatform/Library/Game1.cs
@@ -2,8 +2,11 @@
using Monofoxe.Engine;
using Monofoxe.Tiled;
using Monofoxe.Engine.Drawing;
-using Resources;
using Monofoxe.Engine.Resources;
+using Microsoft.Xna.Framework.Graphics;
+using Monofoxe.Tiled.MapStructure;
+using Monofoxe.Resources;
+using $safeprojectname$.Resources;
namespace $safeprojectname$
{
@@ -14,14 +17,13 @@ public class Game1 : Game
{
public Game1()
{
- Content.RootDirectory = AssetMgr.ContentDir;
+ Content.RootDirectory = ResourceInfoMgr.ContentDir;
GameMgr.Init(this);
-#if !ANDROID
- Window.TextInput += Input.TextInput;
-#else
- GameMgr.WindowManager.SetFullScreen(true); // Has to be exactly here, apparently.
-#endif
+ if (GameMgr.CurrentPlatform == Platform.Android)
+ {
+ GameMgr.WindowManager.SetFullScreen(true); // Has to be exactly here, apparently.
+ }
}
@@ -47,10 +49,10 @@ protected override void LoadContent()
{
GraphicsMgr.Init(GraphicsDevice);
- new Resources.Sprites.Default();
+ new SpriteGroupResourceBox("DefaultSprites", "Graphics/Default");
+ new DirectoryResourceBox("Effects", "Effects");
+ new DirectoryResourceBox("Maps", "Maps");
new Fonts();
- new Maps();
- new Effects();
}
///
diff --git a/Templates/ProjectTemplates/Shared/GameController.cs b/Templates/ProjectTemplates/Crossplatform/Library/GameController.cs
similarity index 94%
rename from Templates/ProjectTemplates/Shared/GameController.cs
rename to Templates/ProjectTemplates/Crossplatform/Library/GameController.cs
index 48ae729c..73b83f39 100644
--- a/Templates/ProjectTemplates/Shared/GameController.cs
+++ b/Templates/ProjectTemplates/Crossplatform/Library/GameController.cs
@@ -12,14 +12,14 @@ namespace $safeprojectname$
public class GameController : Entity
{
public Camera2D Camera = new Camera2D(800, 600);
- Sprite _monofoxe;
+ private Sprite _monofoxe;
public GameController() : base(SceneMgr.GetScene("default")["default"])
{
GameMgr.MaxGameSpeed = 60;
GameMgr.MinGameSpeed = 60; // Fixing framerate on 60.
- Camera.BackgroundColor = new Color(30, 24, 24);
+ Camera.BackgroundColor = Color.White;
GameMgr.WindowManager.CanvasSize = Camera.Size;
GameMgr.WindowManager.Window.AllowUserResizing = false;
diff --git a/Templates/ProjectTemplates/Crossplatform/Library/Library.csproj b/Templates/ProjectTemplates/Crossplatform/Library/Library.csproj
new file mode 100644
index 00000000..761d5a48
--- /dev/null
+++ b/Templates/ProjectTemplates/Crossplatform/Library/Library.csproj
@@ -0,0 +1,15 @@
+
+
+
+ netstandard2.0
+
+
+
+
+ All
+
+
+
+
+
+
diff --git a/Templates/ProjectTemplates/MonofoxeDotnetStandardLibrary/MonofoxeDotnetStandardLibrary.vstemplate b/Templates/ProjectTemplates/Crossplatform/Library/Library.vstemplate
similarity index 70%
rename from Templates/ProjectTemplates/MonofoxeDotnetStandardLibrary/MonofoxeDotnetStandardLibrary.vstemplate
rename to Templates/ProjectTemplates/Crossplatform/Library/Library.vstemplate
index 323c5c41..5a601b26 100644
--- a/Templates/ProjectTemplates/MonofoxeDotnetStandardLibrary/MonofoxeDotnetStandardLibrary.vstemplate
+++ b/Templates/ProjectTemplates/Crossplatform/Library/Library.vstemplate
@@ -12,8 +12,6 @@
true
Enabled
true
- __TemplateIcon.png
- __PreviewImage.png
true
C#
Windows
@@ -24,8 +22,12 @@
MonoGame
-
- Monofoxe.props
+
+
+ Fonts.cs
+
+ Game1.cs
+ GameController.cs
diff --git a/Templates/ProjectTemplates/Shared/Resources/Fonts.cs b/Templates/ProjectTemplates/Crossplatform/Library/Resources/Fonts.cs
similarity index 72%
rename from Templates/ProjectTemplates/Shared/Resources/Fonts.cs
rename to Templates/ProjectTemplates/Crossplatform/Library/Resources/Fonts.cs
index 174c4216..73f78be8 100644
--- a/Templates/ProjectTemplates/Shared/Resources/Fonts.cs
+++ b/Templates/ProjectTemplates/Crossplatform/Library/Resources/Fonts.cs
@@ -4,20 +4,16 @@
using Monofoxe.Engine.Drawing;
using Monofoxe.Engine.Resources;
-namespace Resources
+namespace $safeprojectname$.Resources
{
public class Fonts : ResourceBox
{
private ContentManager _content;
- static readonly string Ascii = " !" + '"' + @"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
-
- public override string Name => "Fonts";
-
- public Fonts()
+ public Fonts() : base("Fonts")
{
_content = new ContentManager(GameMgr.Game.Services);
- _content.RootDirectory = AssetMgr.ContentDir + '/' + AssetMgr.FontsDir;
+ _content.RootDirectory = ResourceInfoMgr.ContentDir + "/Fonts";
}
public override void Load()
diff --git a/Templates/ProjectTemplates/Crossplatform/Monofoxe.props b/Templates/ProjectTemplates/Crossplatform/Monofoxe.props
deleted file mode 100644
index 0e3de9ca..00000000
--- a/Templates/ProjectTemplates/Crossplatform/Monofoxe.props
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- $(MSBuildProgramFiles32)\Monofoxe Engine\
- v2-dev
-
-
diff --git a/Templates/ProjectTemplates/Crossplatform/__PreviewImage.png b/Templates/ProjectTemplates/Crossplatform/__PreviewImage.png
index f2729eb3..48063e70 100644
Binary files a/Templates/ProjectTemplates/Crossplatform/__PreviewImage.png and b/Templates/ProjectTemplates/Crossplatform/__PreviewImage.png differ
diff --git a/Templates/ProjectTemplates/Crossplatform/__TemplateIcon.png b/Templates/ProjectTemplates/Crossplatform/__TemplateIcon.png
index be9ef30a..ef90da31 100644
Binary files a/Templates/ProjectTemplates/Crossplatform/__TemplateIcon.png and b/Templates/ProjectTemplates/Crossplatform/__TemplateIcon.png differ
diff --git a/Templates/ProjectTemplates/DX/DX.csproj b/Templates/ProjectTemplates/DX/DX.csproj
deleted file mode 100644
index 0ff20bc5..00000000
--- a/Templates/ProjectTemplates/DX/DX.csproj
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
-
-
-
-
- Debug
- x86
- 8.0.30703
- 2.0
- $guid1$
- WinExe
- Properties
- $safeprojectname$
- $safeprojectname$
- 512
- Windows
- v4.7.2
-
-
- x86
- true
- full
- false
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- DEBUG;TRACE;WINDOWS
- prompt
- 4
-
-
- x86
- pdbonly
- true
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- TRACE;WINDOWS
- prompt
- 4
-
-
- Icon.ico
-
-
- app.manifest
-
-
-
-
-
-
-
- $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll
-
-
- False
- $(MonofoxeInstallDirectory)\$(MonofoxeVersion)\lib\Monofoxe.Engine.dll
-
-
- False
- $(MonofoxeInstallDirectory)\$(MonofoxeVersion)\lib\Monofoxe.Tiled.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Templates/ProjectTemplates/DX/Icon.ico b/Templates/ProjectTemplates/DX/Icon.ico
deleted file mode 100644
index 036c4f68..00000000
Binary files a/Templates/ProjectTemplates/DX/Icon.ico and /dev/null differ
diff --git a/Templates/ProjectTemplates/DX/Program.cs b/Templates/ProjectTemplates/DX/Program.cs
deleted file mode 100644
index 69ed10b6..00000000
--- a/Templates/ProjectTemplates/DX/Program.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-// using YourSharedProjectNamespace;
-// Don't forget to reference it first!
-
-namespace $safeprojectname$
-{
-#if WINDOWS || LINUX
- ///
- /// The main class.
- ///
- public static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- static void Main()
- {
- using(var game = new Game1())
- game.Run();
- }
- }
-#endif
-}
diff --git a/Templates/ProjectTemplates/DX/Properties/AssemblyInfo.cs b/Templates/ProjectTemplates/DX/Properties/AssemblyInfo.cs
deleted file mode 100644
index a06ab0db..00000000
--- a/Templates/ProjectTemplates/DX/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("$projectname$")]
-[assembly: AssemblyProduct("$projectname$")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyCompany("$registeredorganization$")]
-[assembly: AssemblyCopyright("Copyright © $registeredorganization$ $year$")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("$guid2$")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Templates/ProjectTemplates/DX/__PreviewImage.png b/Templates/ProjectTemplates/DX/__PreviewImage.png
deleted file mode 100644
index f2729eb3..00000000
Binary files a/Templates/ProjectTemplates/DX/__PreviewImage.png and /dev/null differ
diff --git a/Templates/ProjectTemplates/DX/__TemplateIcon.png b/Templates/ProjectTemplates/DX/__TemplateIcon.png
deleted file mode 100644
index dea59956..00000000
Binary files a/Templates/ProjectTemplates/DX/__TemplateIcon.png and /dev/null differ
diff --git a/Templates/ProjectTemplates/GL/GL.csproj b/Templates/ProjectTemplates/GL/GL.csproj
deleted file mode 100644
index ba7facee..00000000
--- a/Templates/ProjectTemplates/GL/GL.csproj
+++ /dev/null
@@ -1,130 +0,0 @@
-
-
-
-
-
-
- Debug
- AnyCPU
- 8.0.30703
- 2.0
- {058E861C-4B60-4410-A73B-4BCA5DC70EC2}
- WinExe
- Properties
- $safeprojectname$
- $safeprojectname$
- 512
- DesktopGL
- v4.7.2
-
-
- true
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- DEBUG;TRACE;LINUX
- full
- AnyCPU
- prompt
- false
- 4
-
-
- bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\
- TRACE;LINUX
- true
- pdbonly
- AnyCPU
- prompt
- false
- 4
-
-
- Icon.ico
-
-
- app.manifest
-
-
-
-
-
-
-
- $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\DesktopGL\MonoGame.Framework.dll
-
-
- False
- $(MonofoxeInstallDirectory)\$(MonofoxeVersion)\lib\Monofoxe.Engine.dll
-
-
- False
- $(MonofoxeInstallDirectory)\$(MonofoxeVersion)\lib\Monofoxe.Tiled.dll
-
-
-
-
-
-
-
-
-
-
- x86\SDL2.dll
- PreserveNewest
-
-
- x64\SDL2.dll
- PreserveNewest
-
-
- x86\soft_oal.dll
- PreserveNewest
-
-
- x64\soft_oal.dll
- PreserveNewest
-
-
- x86\libSDL2-2.0.so.0
- PreserveNewest
-
-
- x64\libSDL2-2.0.so.0
- PreserveNewest
-
-
- x86\libopenal.so.1
- PreserveNewest
-
-
- x64\libopenal.so.1
- PreserveNewest
-
-
- libSDL2-2.0.0.dylib
- PreserveNewest
-
-
- libopenal.1.dylib
- PreserveNewest
-
-
- MonoGame.Framework.dll.config
- PreserveNewest
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Templates/ProjectTemplates/GL/Icon.bmp b/Templates/ProjectTemplates/GL/Icon.bmp
deleted file mode 100644
index c64a608b..00000000
Binary files a/Templates/ProjectTemplates/GL/Icon.bmp and /dev/null differ
diff --git a/Templates/ProjectTemplates/GL/Icon.ico b/Templates/ProjectTemplates/GL/Icon.ico
deleted file mode 100644
index 036c4f68..00000000
Binary files a/Templates/ProjectTemplates/GL/Icon.ico and /dev/null differ
diff --git a/Templates/ProjectTemplates/GL/Program.cs b/Templates/ProjectTemplates/GL/Program.cs
deleted file mode 100644
index 1a709c44..00000000
--- a/Templates/ProjectTemplates/GL/Program.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-// using YourSharedProjectNamespace;
-// Don't forget to reference it first!
-
-namespace $safeprojectname$
-{
- ///
- /// The main class.
- ///
- public static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- static void Main()
- {
- using (var game = new Game1())
- {
- game.Run();
- }
- }
- }
-}
diff --git a/Templates/ProjectTemplates/GL/Properties/AssemblyInfo.cs b/Templates/ProjectTemplates/GL/Properties/AssemblyInfo.cs
deleted file mode 100644
index a06ab0db..00000000
--- a/Templates/ProjectTemplates/GL/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("$projectname$")]
-[assembly: AssemblyProduct("$projectname$")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyCompany("$registeredorganization$")]
-[assembly: AssemblyCopyright("Copyright © $registeredorganization$ $year$")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("$guid2$")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Templates/ProjectTemplates/GL/__PreviewImage.png b/Templates/ProjectTemplates/GL/__PreviewImage.png
deleted file mode 100644
index f2729eb3..00000000
Binary files a/Templates/ProjectTemplates/GL/__PreviewImage.png and /dev/null differ
diff --git a/Templates/ProjectTemplates/GL/__TemplateIcon.png b/Templates/ProjectTemplates/GL/__TemplateIcon.png
deleted file mode 100644
index ef90da31..00000000
Binary files a/Templates/ProjectTemplates/GL/__TemplateIcon.png and /dev/null differ
diff --git a/Templates/ProjectTemplates/MonofoxeDotnetStandardLibrary/MonofoxeDotnetStandardLibrary.csproj b/Templates/ProjectTemplates/MonofoxeDotnetStandardLibrary/MonofoxeDotnetStandardLibrary.csproj
deleted file mode 100644
index 8a56abee..00000000
--- a/Templates/ProjectTemplates/MonofoxeDotnetStandardLibrary/MonofoxeDotnetStandardLibrary.csproj
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
- netstandard2.0
-
-
-
-
-
-
-
-
- $(MonofoxeInstallDirectory)\$(MonofoxeVersion)\lib\Monofoxe.Engine.dll
-
-
- $(MonofoxeInstallDirectory)\$(MonofoxeVersion)\lib\Monofoxe.Tiled.dll
-
-
-
-
diff --git a/Templates/ProjectTemplates/MonofoxeDotnetStandardLibrary/__PreviewImage.png b/Templates/ProjectTemplates/MonofoxeDotnetStandardLibrary/__PreviewImage.png
deleted file mode 100644
index f2729eb3..00000000
Binary files a/Templates/ProjectTemplates/MonofoxeDotnetStandardLibrary/__PreviewImage.png and /dev/null differ
diff --git a/Templates/ProjectTemplates/MonofoxeDotnetStandardLibrary/__TemplateIcon.png b/Templates/ProjectTemplates/MonofoxeDotnetStandardLibrary/__TemplateIcon.png
deleted file mode 100644
index f7b90455..00000000
Binary files a/Templates/ProjectTemplates/MonofoxeDotnetStandardLibrary/__TemplateIcon.png and /dev/null differ
diff --git a/Templates/ProjectTemplates/Shared/Content/Content.mgcb b/Templates/ProjectTemplates/Shared/Content/Content.mgcb
deleted file mode 100644
index 67842d61..00000000
--- a/Templates/ProjectTemplates/Shared/Content/Content.mgcb
+++ /dev/null
@@ -1,31 +0,0 @@
-
-#----------------------------- Global Properties ----------------------------#
-
-/outputDir:bin/$(Platform)
-/intermediateDir:obj/$(Platform)
-/config:
-/profile:Reach
-/compress:False
-
-#-------------------------------- References --------------------------------#
-
-/reference:C:/Program Files (x86)/Monofoxe Engine/v2-dev/lib/Pipeline/Pipefoxe.dll
-
-#---------------------------------- Content ---------------------------------#
-
-#begin Content.mgcb
-/importer:AssetInfoImporter
-/processor:PassThroughProcessor
-/build:Content.mgcb
-
-#begin Graphics/default.spritegroup
-/importer:SpriteGroupImporter
-/processor:SpriteGroupProcessor
-/build:Graphics/default.spritegroup
-
-#begin Fonts/Arial.spritefont
-/importer:FontDescriptionImporter
-/processor:FontDescriptionProcessor
-/build:Fonts/Arial.spritefont
-
-
diff --git a/Templates/ProjectTemplates/Shared/Content/Content.npl b/Templates/ProjectTemplates/Shared/Content/Content.npl
deleted file mode 100644
index c2b735e9..00000000
--- a/Templates/ProjectTemplates/Shared/Content/Content.npl
+++ /dev/null
@@ -1,67 +0,0 @@
-{
- "references":
- [
- "%PROGRAMFILES%/Monofoxe Engine/v2-dev/lib/Pipeline/Pipefoxe.dll",
- ],
- "content":
- {
- "contentList":
- {
- "path": "Content.mgcb",
- "recursive": "False",
- "action": "build",
- "importer": "AssetInfoImporter",
- "processor": "PassThroughProcessor",
- },
- "music":
- {
- "path": "Audio/Music/*.ogg",
- "recursive": "True",
- "action": "copy",
- },
- "sounds":
- {
- "path": "Audio/Sounds/*.wav",
- "recursive": "True",
- "action": "copy",
- },
- "defaultSpriteGroup":
- {
- "path": "Graphics/Default.spritegroup",
- "recursive": "True",
- "action": "build",
- "importer": "SpriteGroupImporter",
- "processor": "SpriteGroupProcessor",
- "watch":
- [
- "Default/*.png",
- "Default/*.json",
- ],
- },
- "effects":
- {
- "path": "Effects/*.fx",
- "recursive": "True",
- "action": "build",
- "importer": "EffectImporter",
- "processor": "EffectProcessor",
- },
- "tiledMaps":
- {
- "path": "Maps/*.tmx",
- "recursive": "True",
- "action": "build",
- "importer": "TiledMapImporter",
- "processor": "TiledMapProcessor",
- },
- "fonts":
- {
- "path": "Fonts/*.spritefont",
- "recursive": "True",
- "action": "build",
- "importer": "FontDescriptionImporter",
- "processor": "FontDescriptionProcessor",
- },
-
- }
-}
\ No newline at end of file
diff --git a/Templates/ProjectTemplates/Shared/Content/Effects/AlphaBlend.fx b/Templates/ProjectTemplates/Shared/Content/Effects/AlphaBlend.fx
deleted file mode 100644
index b3d1dfc7..00000000
--- a/Templates/ProjectTemplates/Shared/Content/Effects/AlphaBlend.fx
+++ /dev/null
@@ -1,102 +0,0 @@
-
-/*
-Base shader for drawing everything, when there are no other shaders applied.
-It's used by VertexBatch to apply proper transform matrix.
-
-NOTE: This shader is vital part of the engine.
-DO NOT modify it, unless you know, what you're doing and have good reasons to!
-*/
-
-float4x4 World;
-float4x4 View;
-float4x4 Projection;
-
-const sampler BaseSampler : register(s0);
-
-struct VertexShaderInput
-{
- float4 Position : POSITION0;
- float2 TexCoords : TEXCOORD0;
- float4 Color : COLOR0;
-};
-
-struct VertexShaderOutput
-{
- float4 Position : POSITION0;
- float2 TexCoords : TEXCOORD0;
- float4 Color : COLOR0;
-};
-
-
-VertexShaderOutput VS_Texture(VertexShaderInput input)
-{
- VertexShaderOutput output;
-
- float4 worldPosition = mul(input.Position, World);
- float4 viewPosition = mul(worldPosition, View);
- output.Position = mul(viewPosition, Projection);
- output.TexCoords = input.TexCoords;
- output.Color = input.Color;
-
- return output;
-}
-
-
-/*
-Premultiplying shader. Used for sufraces, regular sprites, textured primitives and texture fonts.
-*/
-float4 PS_TexturePremultiplied(VertexShaderOutput input) : COLOR0
-{
- float4 color = tex2D(BaseSampler, input.TexCoords.xy);
- return float4(color.r * input.Color.r, color.g * input.Color.g, color.b * input.Color.b, input.Color.a) * color.a;
-}
-
-/*
-Non-premultiplying shader.
-*/
-float4 PS_TextureNonPremultiplied(VertexShaderOutput input) : COLOR0
-{
- float4 color = tex2D(BaseSampler, input.TexCoords.xy);
- return color * input.Color;
-}
-
-/*
-Basic shader for primitives without texture.
-*/
-float4 PS_Basic(VertexShaderOutput input) : COLOR0
-{
- return input.Color;
-}
-
-/*
-Techniques are chosen by the engine automatically.
-*/
-
-#ifdef SM4
-
-#define TECHNIQUE(name, vsName, psName) \
- technique name \
- { \
- pass Pass1 \
- { \
- VertexShader = compile vs_4_0_level_9_1 vsName(); \
- PixelShader = compile ps_4_0_level_9_1 psName(); \
- } \
- }
-#else
-
-#define TECHNIQUE(name, vsName, psName) \
- technique name \
- { \
- pass Pass1 \
- { \
- VertexShader = compile vs_3_0 vsName(); \
- PixelShader = compile ps_3_0 psName(); \
- } \
- }
-#endif
-
-
-TECHNIQUE(Basic, VS_Texture, PS_Basic);
-TECHNIQUE(TexturePremultiplied, VS_Texture, PS_TexturePremultiplied);
-TECHNIQUE(TextureNonPremultiplied, VS_Texture, PS_TextureNonPremultiplied);
\ No newline at end of file
diff --git a/Templates/ProjectTemplates/Shared/Content/Graphics/Default/monofoxe.json b/Templates/ProjectTemplates/Shared/Content/Graphics/Default/monofoxe.json
deleted file mode 100644
index 12e97617..00000000
--- a/Templates/ProjectTemplates/Shared/Content/Graphics/Default/monofoxe.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- v: 1,
- h: 1,
- offset_x: "center",
- offset_y: "center",
-}
\ No newline at end of file
diff --git a/Templates/ProjectTemplates/Shared/Content/Graphics/Default/monofoxe.png b/Templates/ProjectTemplates/Shared/Content/Graphics/Default/monofoxe.png
deleted file mode 100644
index 01df2ed7..00000000
Binary files a/Templates/ProjectTemplates/Shared/Content/Graphics/Default/monofoxe.png and /dev/null differ
diff --git a/Templates/ProjectTemplates/Shared/Content/Graphics/Template.cstemplate b/Templates/ProjectTemplates/Shared/Content/Graphics/Template.cstemplate
deleted file mode 100644
index 4a9e788e..00000000
--- a/Templates/ProjectTemplates/Shared/Content/Graphics/Template.cstemplate
+++ /dev/null
@@ -1,55 +0,0 @@
-#class_prefix = public static Sprite ;
-#class_constructor = AddResource("", sprites[]);
-
-// Template tags:
-// - Name of output class.
-// - Name of current group.
-// - Name of each sprite.
-// - Hash name of each sprite.
-
-
-using Microsoft.Xna.Framework.Content;
-using Monofoxe.Engine;
-using Monofoxe.Engine.Drawing;
-using System.Collections.Generic;
-using Monofoxe.Engine.Resources;
-
-// NOTE: This class is automatically generated by
-// Monofoxe. See .cstemplate file.
-
-namespace Resources.Sprites
-{
- public class : ResourceBox
- {
- public override string Name => "Sprites";
-
- private ContentManager _content = new ContentManager(GameMgr.Game.Services);
-
- public override void Load()
- {
- if (Loaded)
- {
- return;
- }
- Loaded = true;
- var graphicsPath = AssetMgr.ContentDir + '/' + AssetMgr.GraphicsDir + "/";
- var sprites = _content.Load>(graphicsPath);
-
- #region Sprite constructors.
-
-
-
- #endregion Sprite constructors.
- }
-
- public override void Unload()
- {
- if (!Loaded)
- {
- return;
- }
- Loaded = false;
- _content.Unload();
- }
- }
-}
\ No newline at end of file
diff --git a/Templates/ProjectTemplates/Shared/Content/Graphics/default.spritegroup b/Templates/ProjectTemplates/Shared/Content/Graphics/default.spritegroup
deleted file mode 100644
index edc3a49d..00000000
--- a/Templates/ProjectTemplates/Shared/Content/Graphics/default.spritegroup
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "atlasSize": 512,
- "texturePadding": 1,
- "rootDir": "/Default",
- "classTemplatePath": "/../Template.cstemplate", // Relative to rootDir.
- "classOutputDir": "/../Resources/Sprites/", // Relative to content project file.
- "singleTexturesWildcards":
- [
- "/Textures/*"
- ],
-
- "debugMode": "false"
-}
\ No newline at end of file
diff --git a/Templates/ProjectTemplates/Shared/Resources/Effects.cs b/Templates/ProjectTemplates/Shared/Resources/Effects.cs
deleted file mode 100644
index d6b5910c..00000000
--- a/Templates/ProjectTemplates/Shared/Resources/Effects.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using Microsoft.Xna.Framework.Content;
-using Microsoft.Xna.Framework.Graphics;
-using Monofoxe.Engine;
-using Monofoxe.Engine.Resources;
-
-namespace Resources
-{
- public class Effects : ResourceBox
- {
- private static ContentManager _content;
-
- public override string Name => "Effects";
-
- public override void Load()
- {
- if (Loaded)
- {
- return;
- }
- Loaded = true;
- _content = new ContentManager(GameMgr.Game.Services);
- _content.RootDirectory = AssetMgr.ContentDir + '/' + AssetMgr.EffectsDir;
-
- // Add your resources here.
- // Example:
- // AddResource("Test", _content.Load("test"));
- // You can access the resources via ResourceHub.GetResource<>();
- }
-
- public override void Unload()
- {
- if (!Loaded)
- {
- return;
- }
- Loaded = false;
- _content.Unload();
- }
-
- }
-}
\ No newline at end of file
diff --git a/Templates/ProjectTemplates/Shared/Resources/Maps.cs b/Templates/ProjectTemplates/Shared/Resources/Maps.cs
deleted file mode 100644
index 5349169d..00000000
--- a/Templates/ProjectTemplates/Shared/Resources/Maps.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using Microsoft.Xna.Framework.Content;
-using Monofoxe.Engine;
-using Monofoxe.Engine.Resources;
-using Monofoxe.Tiled.MapStructure;
-
-
-namespace Resources
-{
- public class Maps : ResourceBox
- {
- private static ContentManager _content;
-
- public override string Name => "Maps";
-
- public override void Load()
- {
- if (Loaded)
- {
- return;
- }
- Loaded = true;
-
- _content = new ContentManager(GameMgr.Game.Services);
- _content.RootDirectory = AssetMgr.ContentDir + '/' + AssetMgr.MapsDir;
-
- // Add your resources here.
- // Example:
- // AddResource("Test", _content.Load("test"));
- // You can access the resources via ResourceHub.GetResource<>();
- }
-
- public override void Unload()
- {
- if (!Loaded)
- {
- return;
- }
- _content.Unload();
- }
-
- }
-}
diff --git a/Templates/ProjectTemplates/Shared/Resources/Sprites/Default.cs b/Templates/ProjectTemplates/Shared/Resources/Sprites/Default.cs
deleted file mode 100644
index 0dbfe991..00000000
--- a/Templates/ProjectTemplates/Shared/Resources/Sprites/Default.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-// Template tags:
-// Default - Name of output class.
-// Default - Name of current group.
-// - Name of each sprite.
-// - Hash name of each sprite.
-
-
-using Microsoft.Xna.Framework.Content;
-using Monofoxe.Engine;
-using Monofoxe.Engine.Drawing;
-using System.Collections.Generic;
-using Monofoxe.Engine.Resources;
-
-// NOTE: This class is automatically generated by
-// Monofoxe. See .cstemplate file.
-
-namespace Resources.Sprites
-{
- public class Default : ResourceBox
- {
- public override string Name => "DefaultSprites";
-
- private ContentManager _content = new ContentManager(GameMgr.Game.Services);
-
- public override void Load()
- {
- if (Loaded)
- {
- return;
- }
- Loaded = true;
- var graphicsPath = AssetMgr.ContentDir + '/' + AssetMgr.GraphicsDir + "/Default";
- var sprites = _content.Load>(graphicsPath);
-
- #region Sprite constructors.
-
- AddResource("Monofoxe", sprites["monofoxe"]);
-
- #endregion Sprite constructors.
- }
-
- public override void Unload()
- {
- if (!Loaded)
- {
- return;
- }
- Loaded = false;
- _content.Unload();
- }
- }
-}
diff --git a/Templates/ProjectTemplates/Shared/Shared.projitems b/Templates/ProjectTemplates/Shared/Shared.projitems
deleted file mode 100644
index 57422332..00000000
--- a/Templates/ProjectTemplates/Shared/Shared.projitems
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
- $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
- true
- $guid1$
-
-
- $safeprojectname$
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Templates/ProjectTemplates/Shared/Shared.shproj b/Templates/ProjectTemplates/Shared/Shared.shproj
deleted file mode 100644
index 75626747..00000000
--- a/Templates/ProjectTemplates/Shared/Shared.shproj
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
- a0cdbd0e-3a41-42b7-9425-a838bc2c7383
-
-
-
-
-
-
-
-
diff --git a/Templates/ProjectTemplates/Shared/Shared.vstemplate b/Templates/ProjectTemplates/Shared/Shared.vstemplate
deleted file mode 100644
index 5aada5c1..00000000
--- a/Templates/ProjectTemplates/Shared/Shared.vstemplate
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
- Monofoxe Shared Project
- A Monofoxe Shared Project. Used to share common code between platform-specific projects. Use it if you want to make a cross-platform game.
- CSharp
- 1000
-
-
- true
- false
- Foxe.Shared
- true
- Enabled
- __TemplateIcon.png
- __PreviewImage.png
- C#
- Windows
- Linux
- Android
- Shared
- Monofoxe
- MonoGame
-
-
-
-
- Shared.projitems
- Monofoxe.props
-
- Game1.cs
- GameController.cs
-
-
-
- Default.cs
-
- Effects.cs
- Fonts.cs
- Maps.cs
-
-
-
- Content.mgcb
- Content.npl
-
- Template.cstemplate
- default.spritegroup
-
- monofoxe.json
- monofoxe.png
-
-
-
-
- AlphaBlend.fx
-
-
-
-
-
-
-
-
-
-
-
-
-
- Arial.spritefont
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Templates/ProjectTemplates/Shared/__PreviewImage.png b/Templates/ProjectTemplates/Shared/__PreviewImage.png
deleted file mode 100644
index f2729eb3..00000000
Binary files a/Templates/ProjectTemplates/Shared/__PreviewImage.png and /dev/null differ
diff --git a/Templates/ProjectTemplates/Shared/__TemplateIcon.png b/Templates/ProjectTemplates/Shared/__TemplateIcon.png
deleted file mode 100644
index 62b595da..00000000
Binary files a/Templates/ProjectTemplates/Shared/__TemplateIcon.png and /dev/null differ
diff --git a/logo/banner.png b/logo/banner.png
index 2264816e..7a52c036 100644
Binary files a/logo/banner.png and b/logo/banner.png differ
diff --git a/logo/logo.png b/logo/logo.png
index b3bc395c..a6d3a2bd 100644
Binary files a/logo/logo.png and b/logo/logo.png differ
diff --git a/logo/logo_nolabel.png b/logo/logo_nolabel.png
index 7bca1da3..0c4b0616 100644
Binary files a/logo/logo_nolabel.png and b/logo/logo_nolabel.png differ
diff --git a/logo/logo_nolabel_transparent.png b/logo/logo_nolabel_transparent.png
new file mode 100644
index 00000000..134813c4
Binary files /dev/null and b/logo/logo_nolabel_transparent.png differ
diff --git a/logo/logo_transparent.png b/logo/logo_transparent.png
index 01df2ed7..b26e4089 100644
Binary files a/logo/logo_transparent.png and b/logo/logo_transparent.png differ