Přidány základy uživatelského rozhraní a testovací textury. Aktualizovaná Monogame library pro podporu myši

This commit is contained in:
Perry 2026-01-15 19:56:50 +01:00
parent 4561e254d4
commit b968b12090
9 changed files with 184 additions and 11 deletions

View file

@ -1,27 +1,41 @@
using Microsoft.Xna.Framework;
using System;
using FNAF_Clone.GUI;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using MonoGameLibrary;
using MonoGameLibrary.Graphics;
using MonoGameLibrary.Input;
namespace FNAF_Clone;
public class GameMain() : Core("fnafkooo", 1920, 1080, false) {
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
public class GameMain() : Core("fnafkooo", 640, 360, false) {
// private GraphicsDeviceManager _graphics;
// private SpriteBatch _spriteBatch;
private Screen officeScreen = new(Screen.ScreenType.OFFICE);
private TextureAtlas testAtlas;
protected override void Initialize() {
Client.Connect("127.0.0.1", 9012);
CommandManager.InitInputListeners();
InputManager.AddListener(InputManager.MouseButton.LEFT, (() => Console.WriteLine("LMB pressed at: " + InputManager.MouseState.Position)), InputTiming.PRESS, new InputListenerHook(true));
base.Initialize();
}
protected override void LoadContent() {
_spriteBatch = new SpriteBatch(GraphicsDevice);
// spriteBatch = new SpriteBatch(GraphicsDevice);
testAtlas = TextureAtlas.FromFile(content, "images/testBlocks-definition.xml");
// TODO: use this.Content to load your game content here
Screen.AddScreen("office", officeScreen, true);
officeScreen.AddElement("test",
new UIElement(testAtlas[0], Point.Zero)
{Pressable = true, OnMousePress = () => Console.WriteLine("Pressed!")}
);
}
protected override void Update(GameTime gameTime) {
@ -39,9 +53,11 @@ public class GameMain() : Core("fnafkooo", 1920, 1080, false) {
protected override void Draw(GameTime gameTime) {
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
Screen.CurrentScreen.Draw(spriteBatch);
// TODO: Add your drawing code here
spriteBatch.End();
base.Draw(gameTime);
}
}