2026-01-29 19:37:40 +01:00
|
|
|
using System;
|
2026-02-14 14:35:29 +01:00
|
|
|
using System.Collections.Generic;
|
2026-02-16 21:48:59 +01:00
|
|
|
using FNAF_Clone.Map;
|
2026-02-14 14:35:29 +01:00
|
|
|
using GlobalClassLib;
|
2026-01-26 09:39:17 +01:00
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using MonoGameLibrary;
|
|
|
|
|
using MonoGameLibrary.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace FNAF_Clone.GUI;
|
|
|
|
|
|
|
|
|
|
public class UIManager {
|
|
|
|
|
|
|
|
|
|
public static class ScreenTypes {
|
|
|
|
|
public const string OFFICE = "office";
|
|
|
|
|
public const string CAMERAS = "monitor";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Screen officeScreen = new(ScreenTypes.OFFICE);
|
|
|
|
|
private static Screen monitorScreen = new(ScreenTypes.CAMERAS);
|
|
|
|
|
|
|
|
|
|
private static TextureAtlas testAtlas;
|
|
|
|
|
private static TextureAtlas officeAtlas;
|
|
|
|
|
private static TextureAtlas monitorAtlas;
|
|
|
|
|
public static int GlobalPixelMultiplier{ get; private set; }
|
|
|
|
|
|
2026-02-16 21:48:59 +01:00
|
|
|
private Dictionary<(int, int), UIElement> doorElements = new();
|
2026-01-26 09:39:17 +01:00
|
|
|
public static void InitUI() {
|
|
|
|
|
GlobalPixelMultiplier = Core.graphicsDevice.Viewport.Height / 360;
|
|
|
|
|
|
|
|
|
|
testAtlas = TextureAtlas.FromFile(Core.content, "images/testBlocks-definition.xml");
|
|
|
|
|
officeAtlas = TextureAtlas.FromFile(Core.content, "images/office-definition.xml");
|
|
|
|
|
monitorAtlas = TextureAtlas.FromFile(Core.content, "images/monitor-definition.xml");
|
|
|
|
|
|
|
|
|
|
Screen.AddScreens([officeScreen, monitorScreen]);
|
|
|
|
|
Screen.SetScreen(ScreenTypes.OFFICE);
|
|
|
|
|
|
2026-01-29 19:37:40 +01:00
|
|
|
|
|
|
|
|
officeScreen.AddElement("office_left", new UIElement([officeAtlas[3], officeAtlas[0]], Point.Zero));
|
|
|
|
|
officeScreen.AddElement("office_centre", new UIElement([officeAtlas[4], officeAtlas[1]], new Point(200, 0)));
|
|
|
|
|
officeScreen.AddElement("office_right", new UIElement([officeAtlas[5], officeAtlas[2]], new Point(440, 0)));
|
|
|
|
|
|
2026-01-26 09:39:17 +01:00
|
|
|
// officeScreen.AddElement("test",
|
|
|
|
|
// new UIElement(testAtlas[0], Point.Zero)
|
|
|
|
|
// {Pressable = true, OnMousePress = () => Console.WriteLine("Pressed!")}
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
monitorScreen.AddElement("screen", new UIElement(monitorAtlas[0], Point.Zero));
|
2026-01-29 19:37:40 +01:00
|
|
|
monitorScreen.AddElement("view-frame", new UIElement(monitorAtlas[1], new Point(62, 55)));
|
|
|
|
|
monitorScreen.AddElement("map-frame", new UIElement(monitorAtlas[2], new Point(334, 135)));
|
|
|
|
|
monitorScreen.AddElement("map", new UIElement(monitorAtlas[3], new Point(334, 135)));
|
|
|
|
|
|
2026-02-14 14:35:29 +01:00
|
|
|
for (int i = 0; i < 5; i++){ // NOTE: this loop does y in reverse, y labels are inverted to match server
|
2026-01-29 19:37:40 +01:00
|
|
|
for (int j = 0; j < 5; j++){
|
|
|
|
|
int i1 = i;
|
|
|
|
|
int j1 = j;
|
2026-02-14 14:35:29 +01:00
|
|
|
Point point1 = new Point(336 + (32 * i), 144 + (32 * j));
|
|
|
|
|
Point point2 = new Point(367 + (32 * i), 175 + (32 * j));
|
2026-02-16 21:48:59 +01:00
|
|
|
monitorScreen.AddElement($"room{MapTileProjection.CoordsToId(i, 4 - j)}", new UIElement(point1, point2)
|
2026-02-21 18:42:44 +01:00
|
|
|
{Pressable = true, OnMousePress = (() => CommandManager.SendChangeCamera(MapTileProjection.CoordsToId(i1, 4 - j1)))});
|
2026-02-16 21:48:59 +01:00
|
|
|
//
|
|
|
|
|
// if (doorPositions.ContainsKey((i, j))){
|
|
|
|
|
// monitorScreen.AddElement("door"+doorPositions[(i, j)], new UIElement([monitorAtlas[5], monitorAtlas[6]], point1));
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SpawnDoors(TileConnectorProjection[] doors) {
|
|
|
|
|
foreach (var door in doors){
|
|
|
|
|
if(door.Type != ConnectorType.DOOR_REMOTE) continue;
|
|
|
|
|
|
|
|
|
|
(int x, int y) dpos = (Math.Abs(door.Tiles.tile1.GridPosition.x - door.Tiles.tile2.GridPosition.x), Math.Abs(door.Tiles.tile1.GridPosition.y - door.Tiles.tile2.GridPosition.y));
|
|
|
|
|
|
|
|
|
|
if (dpos.y == 1){
|
|
|
|
|
int targetId = door.Tiles.tile1.GridPosition.y > door.Tiles.tile2.GridPosition.y ? door.Tiles.tile1.Id : door.Tiles.tile2.Id;
|
|
|
|
|
UIElement tile = monitorScreen["room"+targetId];
|
2026-02-21 18:42:44 +01:00
|
|
|
|
2026-02-16 21:48:59 +01:00
|
|
|
monitorScreen.AddElement("door"+targetId+"-"+(targetId == door.Tiles.tile1.Id ? door.Tiles.tile2.Id : door.Tiles.tile1.Id), new UIElement([monitorAtlas[5], monitorAtlas[6]], tile.Bounds.Item1));
|
2026-01-29 19:37:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
2026-02-21 18:42:44 +01:00
|
|
|
|
|
|
|
|
monitorScreen.AddElement("p1-office-door-left", new UIElement([monitorAtlas[7], monitorAtlas[8]], new Point(400, 272)));
|
|
|
|
|
monitorScreen.AddElement("p1-office-door-centre", new UIElement([monitorAtlas[9], monitorAtlas[10]], new Point(400, 272)));
|
|
|
|
|
monitorScreen.AddElement("p1-office-door-right", new UIElement([monitorAtlas[11], monitorAtlas[12]], new Point(400, 272)));
|
|
|
|
|
monitorScreen.AddElement("p2-office-door-right", new UIElement([monitorAtlas[13], monitorAtlas[14]], new Point(400, 144)));
|
|
|
|
|
monitorScreen.AddElement("p2-office-door-centre", new UIElement([monitorAtlas[15], monitorAtlas[16]], new Point(400, 144)));
|
|
|
|
|
monitorScreen.AddElement("p2-office-door-left", new UIElement([monitorAtlas[17], monitorAtlas[18]], new Point(400, 144)));
|
|
|
|
|
|
2026-01-26 09:39:17 +01:00
|
|
|
}
|
|
|
|
|
|
2026-02-21 18:42:44 +01:00
|
|
|
public static void ChangeDoorState(Direction dir, bool state) { // TODO: make this also change for p2
|
|
|
|
|
int stateInt = state ? 1 : 0;
|
|
|
|
|
|
2026-02-14 14:35:29 +01:00
|
|
|
switch ((int)dir){
|
2026-01-26 09:39:17 +01:00
|
|
|
case 0:
|
2026-02-21 18:42:44 +01:00
|
|
|
officeScreen["office_left"].SetTexture(stateInt);
|
|
|
|
|
monitorScreen["p1-office-door-left"].SetTexture(stateInt);
|
2026-01-26 09:39:17 +01:00
|
|
|
break;
|
|
|
|
|
case 1:
|
2026-02-21 18:42:44 +01:00
|
|
|
officeScreen["office_centre"].SetTexture(stateInt);
|
|
|
|
|
monitorScreen["p1-office-door-centre"].SetTexture(stateInt);
|
2026-01-26 09:39:17 +01:00
|
|
|
break;
|
|
|
|
|
case 2:
|
2026-02-21 18:42:44 +01:00
|
|
|
officeScreen["office_right"].SetTexture(stateInt);
|
|
|
|
|
monitorScreen["p1-office-door-right"].SetTexture(stateInt);
|
2026-01-26 09:39:17 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-21 18:42:44 +01:00
|
|
|
|
|
|
|
|
public static void ChangeRemoteDoorState((int, int) id, bool state) {
|
|
|
|
|
monitorScreen["door"+Math.Max(id.Item1, id.Item2)+"-"+Math.Min(id.Item1, id.Item2)].SetTexture(state ? 1 : 0);
|
|
|
|
|
}
|
2026-01-26 09:39:17 +01:00
|
|
|
|
|
|
|
|
public static void ChangeMonitorState(bool state) {
|
|
|
|
|
Screen.SetScreen(state ? ScreenTypes.CAMERAS : ScreenTypes.OFFICE);
|
|
|
|
|
}
|
2026-01-29 19:37:40 +01:00
|
|
|
|
|
|
|
|
|
2026-01-26 09:39:17 +01:00
|
|
|
}
|