Apos.Gui
0.10.1
See the version list below for details.
dotnet add package Apos.Gui --version 0.10.1
NuGet\Install-Package Apos.Gui -Version 0.10.1
<PackageReference Include="Apos.Gui" Version="0.10.1" />
paket add Apos.Gui --version 0.10.1
#r "nuget: Apos.Gui, 0.10.1"
// Install Apos.Gui as a Cake Addin #addin nuget:?package=Apos.Gui&version=0.10.1 // Install Apos.Gui as a Cake Tool #tool nuget:?package=Apos.Gui&version=0.10.1
Apos.Gui
UI library for MonoGame.
Documentation
Build
NuGet
Features
- Mouse, Keyboard, Gamepad, Touchscreen
- UI scaling
Showcase
<img src="Images/Showcase.gif" alt="Apos GUI Loop" width="800" height="480" />
Usage samples
First, find a font ttf file to use (Call it FontFile.ttf), put it in a subfolder called "Fonts" in your content folder. Add it to the MonoGame content pipeline and select copy in "Build Action" instead of ~build~.
In your game's LoadContent()
, get the Helper classes ready:
protected override void LoadContent() {
InputHelper.Game = this;
GuiHelper.Window = Window;
GuiHelper.Scale = 1f;
GuiHelper.Font = DynamicSpriteFont.FromTtf(File.ReadAllBytes(Content.RootDirectory + "/Fonts/FontFile.ttf"), 30);
GuiHelper.FontSize = 30;
}
You can create a simple UI with the following code:
ComponentFocus focus;
Action<Component> grabFocus = (Component c) => {
focus.Focus = c;
}
var screen = new ScreenPanel();
screen.Layout = new LayoutVerticalCenter();
var p = new Panel();
p.Layout = new LayoutVerticalCenter();
p.AddHoverCondition(Default.ConditionHoverMouse);
p.AddAction(Default.IsScrolled, Default.ScrollVertically);
p.Add(Default.CreateButton("Fun"), (Component c) => {
Console.WriteLine("This is fun.");
return true;
});
p.Add(Default.CreateButton("Quit"), (Component c) => {
Console.WriteLine("Quitting the game.");
Exit();
return true;
});
screen.Add(p);
focus = new ComponentFocus(screen, Default.ConditionPreviousFocus, Default.ConditionNextFocus);
The above code will create 2 buttons, "Fun" and "Quit". You can use your mouse to interact with them, your keyboard, or a gamepad.
In your Update(GameTime gameTime)
, call the following functions:
protected override void Update(GameTime gametime) {
//Call UpdateSetup at the start.
InputHelper.UpdateSetup();
GuiHelper.UpdateSetup();
focus.UpdateSetup();
focus.UpdateInput();
focus.Update();
//Call Update at the end.
InputHelper.Update();
}
In your Draw(GameTime gameTime)
, call:
protected override void Draw(GameTime gameTime) {
GraphicsDevice.Clear(Color.Black);
focus.Draw(spritebatch);
base.Draw(gameTime);
}
Working usage code can be found in the AposGameStarter project. Look into menu.cs.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Apos.Input (>= 0.5.1)
- Optional (>= 4.0.0)
- SpriteFontPlus.MonoGame (>= 0.7.0.22)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.1.0 | 108 | 10/14/2024 |
2.0.3 | 427 | 2/6/2024 |
2.0.2 | 267 | 2/6/2024 |
2.0.1 | 314 | 1/29/2024 |
2.0.0 | 846 | 4/24/2023 |
1.0.12 | 712 | 4/11/2023 |
1.0.11 | 1,136 | 3/28/2022 |
1.0.10 | 1,008 | 2/7/2022 |
1.0.9 | 956 | 2/4/2022 |
1.0.8 | 1,092 | 1/29/2022 |
1.0.7 | 904 | 1/29/2022 |
1.0.6-alpha | 690 | 1/28/2022 |
0.16.2 | 1,172 | 11/28/2020 |
0.16.1 | 1,053 | 11/28/2020 |
0.16.0 | 1,105 | 11/28/2020 |
0.15.0 | 1,028 | 10/20/2020 |
0.14.3 | 1,037 | 10/2/2020 |
0.14.2 | 1,103 | 9/6/2020 |
0.14.1 | 1,239 | 5/25/2020 |
0.14.0 | 1,033 | 5/25/2020 |
0.13.0 | 1,044 | 5/25/2020 |
0.12.2 | 1,034 | 3/22/2020 |
0.12.1 | 1,186 | 1/12/2020 |
0.11.5 | 1,057 | 1/12/2020 |
0.11.4 | 1,047 | 1/5/2020 |
0.11.1 | 1,060 | 11/24/2019 |
0.10.1 | 1,024 | 9/25/2019 |
0.10.0 | 1,085 | 9/18/2019 |
0.9.14 | 1,109 | 3/7/2019 |
0.9.13 | 1,158 | 3/5/2019 |
0.9.12 | 1,100 | 3/5/2019 |
0.9.11 | 1,132 | 2/23/2019 |
0.9.10 | 1,164 | 2/21/2019 |
0.9.8 | 1,128 | 2/19/2019 |
0.9.7 | 1,180 | 2/18/2019 |
0.9.5 | 1,234 | 2/6/2019 |
0.9.1 | 1,158 | 2/4/2019 |
0.9.0 | 1,167 | 2/1/2019 |