Skip to content

Commit 25b4ebf

Browse files
committed
Missing Linux file
1 parent 4f30af2 commit 25b4ebf

File tree

1 file changed

+123
-0
lines changed
  • BasicUI_MonoGame/BasicUI_MonoGame_Linux

1 file changed

+123
-0
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#region Using Statements
2+
using System;
3+
using System.Collections.Generic;
4+
using Microsoft.Xna.Framework;
5+
using Microsoft.Xna.Framework.Content;
6+
using Microsoft.Xna.Framework.Graphics;
7+
using Microsoft.Xna.Framework.Input;
8+
using Microsoft.Xna.Framework.Storage;
9+
using Microsoft.Xna.Framework.GamerServices;
10+
using EmptyKeys.UserInterface.Generated;
11+
using EmptyKeys.UserInterface;
12+
using EmptyKeys.UserInterface.Input;
13+
using EmptyKeys.UserInterface.Media;
14+
#endregion
15+
16+
namespace BasicUI_MonoGame_Linux
17+
{
18+
/// <summary>
19+
/// This is the main type for your game
20+
/// </summary>
21+
public class Game1 : Game
22+
{
23+
GraphicsDeviceManager graphics;
24+
25+
private int nativeScreenWidth;
26+
private int nativeScreenHeight;
27+
28+
private BasicUI basicUI;
29+
30+
public Game1()
31+
: base()
32+
{
33+
graphics = new GraphicsDeviceManager(this);
34+
Content.RootDirectory = "Content";
35+
graphics.PreparingDeviceSettings += graphics_PreparingDeviceSettings;
36+
}
37+
38+
private void graphics_PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
39+
{
40+
nativeScreenWidth = graphics.PreferredBackBufferWidth;
41+
nativeScreenHeight = graphics.PreferredBackBufferHeight;
42+
43+
graphics.PreferredBackBufferWidth = 1280;
44+
graphics.PreferredBackBufferHeight = 720;
45+
graphics.PreferMultiSampling = true;
46+
graphics.PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8;
47+
}
48+
49+
/// <summary>
50+
/// Allows the game to perform any initialization it needs to before starting to run.
51+
/// This is where it can query for any required services and load any non-graphic
52+
/// related content. Calling base.Initialize will enumerate through any components
53+
/// and initialize them as well.
54+
/// </summary>
55+
protected override void Initialize()
56+
{
57+
// TODO: Add your initialization logic here
58+
59+
base.Initialize();
60+
}
61+
62+
/// <summary>
63+
/// LoadContent will be called once per game and is the place to load
64+
/// all of your content.
65+
/// </summary>
66+
protected override void LoadContent()
67+
{
68+
this.IsMouseVisible = true;
69+
70+
FontManager.DefaultFont = Content.Load<SpriteFont>("Segoe_UI_10_Regular");
71+
Viewport viewport = GraphicsDevice.Viewport;
72+
basicUI = new BasicUI(viewport.Width, viewport.Height, this.GraphicsDevice, nativeScreenWidth, nativeScreenHeight);
73+
FontManager.Instance.LoadFonts(Content);
74+
ImageManager.Instance.LoadImages(Content);
75+
SoundManager.Instance.LoadSounds(Content);
76+
77+
RelayCommand command = new RelayCommand(new Action<object>(ExitEvent));
78+
79+
KeyBinding keyBinding = new KeyBinding(command, Keys.Escape, ModifierKeys.None);
80+
basicUI.InputBindings.Add(keyBinding);
81+
}
82+
83+
private void ExitEvent(object parameter)
84+
{
85+
Exit();
86+
}
87+
88+
/// <summary>
89+
/// UnloadContent will be called once per game and is the place to unload
90+
/// all content.
91+
/// </summary>
92+
protected override void UnloadContent()
93+
{
94+
// TODO: Unload any non ContentManager content here
95+
}
96+
97+
/// <summary>
98+
/// Allows the game to run logic such as updating the world,
99+
/// checking for collisions, gathering input, and playing audio.
100+
/// </summary>
101+
/// <param name="gameTime">Provides a snapshot of timing values.</param>
102+
protected override void Update(GameTime gameTime)
103+
{
104+
basicUI.UpdateInput(gameTime);
105+
basicUI.UpdateLayout(gameTime);
106+
107+
base.Update(gameTime);
108+
}
109+
110+
/// <summary>
111+
/// This is called when the game should draw itself.
112+
/// </summary>
113+
/// <param name="gameTime">Provides a snapshot of timing values.</param>
114+
protected override void Draw(GameTime gameTime)
115+
{
116+
GraphicsDevice.Clear(Color.CornflowerBlue);
117+
118+
basicUI.Draw(gameTime);
119+
120+
base.Draw(gameTime);
121+
}
122+
}
123+
}

0 commit comments

Comments
 (0)