MonoGame.Forms - Create your Editor Environment!

MonoGame.RuntimeBuilder - out now!


The MonoGame.RuntimeBuilder builds your raw content asynchronously to the .XNB format during runtime.

This library is a part of the MonoGame.Forms project,
but it is fully usable without the MonoGame.Forms library!

sample


Hello Com,

The basic work on the RuntimeBuilder is done and depsite the fact that it is a part of the MonoGame.Forms familiy ( :sweat_smile: ), it don’t need to live in the MonoGame.Forms repo or library. It’s generally usable as a standalone library to build your own tool with runtime content builder functionality - hurray :tada:

Using the MonoGame.RuntimeBuilder is fairly easy:


// Creating the property.
private RuntimeBuilder _RuntimeBuilder { get; set; }

// Initialize the RuntimeBuilder.
_RuntimeBuilder = new RuntimeBuilder(
                Path.Combine(Application.StartupPath, "working"),           // working directory
                Path.Combine(Application.StartupPath, "working", "obj"),    // intermediate directory
                Path.Combine(Application.StartupPath, "Content"),           // output directory
                TargetPlatform.Windows,                                     // target platform
                GraphicsProfile.Reach,                                      // graphics profile
                true)                                                       // compress the content
            {
                Logger = new StringBuilderLogger()                          // logger
            };
            
// Pick Files & Build Content.
private async void ButtonPickFiles_Click(object sender, System.EventArgs e)
{
    if (openFileDialog.ShowDialog() == DialogResult.OK)
    {
        await _RuntimeBuilder.BuildContent(openFileDialog.FileNames);
    }
}

And… that’s it!

Read more on GitHub!

Of course it’s also available on nuget:

NuGet

Feel free to follow me:

Twitter Follow

I wish you a happy day! :smiley:

-Marcel | Sandbox Blizz


1 Like

:four_leaf_clover: Yesterday, Friday the 13th, was my lucky day (it has always been my lucky day) :four_leaf_clover:

I got 2 beta invites on this special day:

I’m telling you this mainly because of the GitHub thingy. As a result packages of all my libraries are also available on GitHub now!

These are the packages of MonoGame.Forms.
These are all packages currently available on my GitHub profile.

Have fun checking these out!

I wish you a nice and lucky weekend! :four_leaf_clover: :wink:

-Marcel


Follow me for the extra portion luck in your life:

Twitter Follow

( lol )

Cool, did you do it in a similar way to my friends post for XNA from way back when?

There are similarities as far as I can see, but I followed a different design philosophie. For example in MonoGame.Forms you will not work with a classical XNA/MonoGame Game.cs class. It’s a “game-class-independent-implementation” if you want to call it like that.

The core class is the GraphicsDeviceControl which inherits from a regular System.Windows.Forms.Control and has the following core purpose:

It also handles client resizing and user input by converting the pressed keys to the XNA/MonoGame equivalents.

The general idea was to extend the library functionality later by service classes so that users would have a nice and easy time to start their own editor projects.

So if the user wants to have an updateable render surface, then the only thing he needs to do is to inherit from MonoGameControl like this:

using Microsoft.Xna.Framework;
using MonoGame.Forms.Controls;

namespace nugetTest
{
    public class DrawTest : MonoGameControl
    {
        string WelcomeMessage = "Hello MonoGame.Forms!";

        protected override void Initialize()
        {
            base.Initialize();
        }

        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        protected override void Draw()
        {
            base.Draw();

            Editor.spriteBatch.Begin();

            Editor.spriteBatch.DrawString(Editor.Font, WelcomeMessage, new Vector2(
                (Editor.graphics.Viewport.Width / 2) - (Editor.Font.MeasureString(WelcomeMessage).X / 2),
                (Editor.graphics.Viewport.Height / 2) - (Editor.FontHeight / 2)),
                Color.White);

            Editor.spriteBatch.End();
        }
    }
}

"Editor" is the underlying GFXService class, which contains basic XNA/MonoGame functionality as well as helper classes like a RenderTargetManager which makes working with render targets easier (client resizing etc.). Generally you will find additional useful stuff to jumpstart your editor creation process. Fell free to take a look at the Wiki to discover more of them.

Have fun and a nice day :sunglasses:

-Marcel


1 Like

I recently updated the repo and the old MonoGame.Forms nuget and want to share some infos with you regarding this.

  1. The old MonoGame.Forms nuget package recently reached over 6000 downloads and got his last update mid 2018. Nevertheless I decided to completly unlist the old package from nuget. Why?

With version 2.0 I created new packages with a complete re-design of how MonoGame.Forms should work. Since then the old package was just listed as a reference and to have a stable alternative to the new packages.

Now, roughly one and a half year later, the old package still received ca ~8 downloads per day (~240 / month, ~2880 / year). I don’t know how many new users are in these numbers nor how often they downloaded the old package, but if it were only 2% of them, we would still have ~58 new users per year installing the old package. Yeah, this doesn’t sound much and it is probably not a big deal, but… every single user counts! :slight_smile:

So, I kinda “forcing” them now to download the new packages instead. They are containing the latest updates, features and improvements; there is really no need in using the old package anymore and I recommended using the new packages ever since.

There is only one disadvantage on my side: the overall download count of nuget packages on my nuget profile is now misleading because the 6000 downloads of the old MonoGame.Forms package got substracted. Well, i’m getting over it :smiley:

  1. I also updated the tutorial section of the Readme.md file to make it clearer and more obvious for beginners to start with MonoGame.Forms and better understandable to correctly use the library.

  2. I added an ImplementationDetails.md file to the repo, so that I can easily refere to it in case someone asks me about this topic (which happened a lot over the time).

That’s it!

Have a nice day.

:: Marcel


BTW: my old english teacher told me once, that ending a presentation with “that’s it” is unprofessional and stupid. Well, I guess I did something stupid here, but I don’t care :stuck_out_tongue:

1 Like

im still not able to use Mouse.GetState() in the Control with the latest source. When i console Mouse.GetState().LeftButton it always return in Released state, and i pressing it all time. FYI i am using attached my control in docksuite https://github.com/dockpanelsuite/dockpanelsuite

@BlizzCrafter i noticed when i change the monogame reference to the official release “v3.7.1.189” the Mouse.GetState() dont work. But when i change the reference back to the version your provide in your github, it actual worked! May i know what have u change from the source?

@11110

Yeah, changes are needed:

The original source is included:
https://github.com/sqrMin1/MonoGame.Forms/tree/master/Libs/MonoGame/_src/Windows

Just merge it with the MonoGame version you want to use and make your own specific changes.

And yes, it works with DockPanelSuit.

@BlizzCrafter

I have some weird behaviour when using Monogame.Forms: Created a small program and do some keyboard input in Update().
I noticed that it only registers keystrokes when the mouse has been hovered over the control once. After that, it works even when the mouse is outside.

I have set the following though:

AlwaysEnableKeyboardInput = true;
MouseHoverUpdatesOnly = false;

Shouldn’t it register keystrokes immediately? Is this intended? Do I miss something? I am stumped. :confused:

This is normal behavior.

Try to programmatically focus the specific control before doing keyboard input and tell me if this works / solves your problem.

I tried with control.SetFocus() and control.Select(), but to no avail. I also tried overriding OnLostFocus, no chance either. Is there any other way?

Ok, I found the problem; I need to push a small update to make your request possible.

Just to clearify: You want an option to enable the keyboard input right from the start of your application and without that the user needs to hover the mouse over a control beforehand, right?

Edit: try it with this patch (master): https://github.com/sqrMin1/MonoGame.Forms/commit/ef34d49f607bf47bb79d340c45bc6c2d44bbe496

Nugets will follow.

2 Likes

Yes, exactly! :smile:

Thank you very much! Works like a charm now.

Perfect.

Nugets updated acordingly.

Changed the Readme.md file of MonoGame.Forms to show a short description of the Mercury Particle Sandbox. It’s still possible to show the real Readme.md file of MonoGame.Forms by clicking on the respective link in the file.

This is what the Readme.md file now shows:

[start of file]

Mercury Particle Sandbox

The first application on Steam which uses the MonoGame.Forms library!

Visit Steam Store!

Click on the image to visit the Steam Store Page and read the full app description.

Following and adding it to your Wishlist is the best way to support the MonoGame.Forms library, the Mercury Particle Sandbox and me!

Thank you very much for your ongoing support!

:: Sandbox Blizz :sparkling_heart:

[screenshots]
[end of file]

This is a great project @BlizzCrafter thanks for continuing to support this! I’m working on a Level Editor for our game and it was extremely simple to plug in and get things up and running!

However, I’m having an issue I was hoping you could shed a light on. Most everything seems to be working fine, but for some reason I seem completely unable to load any Effect files. Is there a specific shader model that needs used or some special handling I missed somewhere? Whenever I attempt to load an effect file through the editor’s content manager it throws a SharpDX exception. Of course it’s the entirely useless “The parameter is incorrect” message so I’m not sure what the actual issue is, but it fails on loading instead of setting anything which I found interesting.

This has happened when trying to load the same shaders I use (and are working fine) in my game, and I’ve also tried to make an extremely simple shader to nail down the problem, but even as something as basic as the following still throws an exception:

float4 RedPixel(float2 coords: TEXCOORD0) : COLOR0
{
    return float4(1, 0, 0, 1);
}

technique CrazySimple
{
    pass P0
    {
        PixelShader = compile ps_4_0 RedPixel();
    }
}

My best guess is that there’s an issue somewhere because everything I have is building against MonoGame 3.7.1, but the only reference to MonoGame.Framework in my LevelEditor project is the included DLL from Forms. Is this possibly an issue from MGCB.exe being built against 3.7.1?

Also just to mention, Effects seem to be the only thing I’m having trouble with. Fonts, Models, etc all seem to be loading and working as expected.

Of course as soon as I posted my above question I found the issue. I needed to ensure the GraphicsProfile was set to HiDef instead of Reach. Feel free to ignore me!

Ah, thanks for your message! Nice, that you already found a solution.

Sometimes it’s also possible to resolve such errors when compiling the shader with a different target or feature level like ps_4_0_level_9_1.

Have a nice day :slight_smile:

MonoGame.Forms 2.4.0 Released

  • Added DX targets file to the DX nuspec.
  • Now importing the MonoGame.Content.Builder.targets and MonoGame.Common.props file and setting the MonoGamePlatform property in all MonoGame.Forms.target files (DX, GL).
  • Added MonoGame.Content.Builder content/libs/nuspecs/targets for DX and GL platform.
  • Added MonoGamePlatform property and importing MonoGame specific targets.
  • Correctly using the NativeLibs directory when including files.
  • Added MonoGame.Framework source code for the Windows platform to allow users to recompile it with custom modifications.
  • Updated post build events.
  • Register keystrokes immediately after setting AlwaysEnableKeyboardInput to true.
  • Always setting the KeyboardInput when the meta value changes.
  • Added additional NullReferenceException checks regarding the Editor service class.
  • It’s now possible to define custom clear options when using BeginAntialising, EndAntialising, BeginRenderTarget and EndRenderTarget (graphics.Clear(custom parameters)).
  • Changed the depth of the clear options to 1f as the default.
  • Added real disposing checks in all controls.

Thank you very much!

Cheers,
:: Marcel :sparkling_heart:

1 Like

Hey! I’ve followed the instructions, and tried a few times to get this to work. However I keep getting a large error thrown when trying to add the object to a windows form. Any help?