92 lines
No EOL
3.9 KiB
C#
92 lines
No EOL
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using GlobalClassLib;
|
|
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; }
|
|
|
|
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);
|
|
|
|
|
|
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)));
|
|
|
|
// officeScreen.AddElement("test",
|
|
// new UIElement(testAtlas[0], Point.Zero)
|
|
// {Pressable = true, OnMousePress = () => Console.WriteLine("Pressed!")}
|
|
// );
|
|
|
|
monitorScreen.AddElement("screen", new UIElement(monitorAtlas[0], Point.Zero));
|
|
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)));
|
|
|
|
Dictionary<(int,int),string> doorPositions = new(){
|
|
{(0, 0),"2-5"},{ (1, 0), "2-4" }, { (1, 1), "2-3" }, { (3, 0), "2-2" }, { (3, 1), "2-1" }, { (4, 0), "2-0" }, // TODO: generate this dynamically from server map info
|
|
{(0, 3),"1-0"},{ (1, 3), "1-1" }, { (1, 2), "1-2" }, { (3, 3), "1-3" }, { (3, 2), "1-4" }, { (4, 3), "1-5" }
|
|
};
|
|
|
|
for (int i = 0; i < 5; i++){ // NOTE: this loop does y in reverse, y labels are inverted to match server
|
|
for (int j = 0; j < 5; j++){
|
|
int i1 = i;
|
|
int j1 = j;
|
|
Point point1 = new Point(336 + (32 * i), 144 + (32 * j));
|
|
Point point2 = new Point(367 + (32 * i), 175 + (32 * j));
|
|
monitorScreen.AddElement($"room{i}-{4 - j}", new UIElement(point1, point2)
|
|
{Pressable = true, OnMousePress = (() => CommandManager.SendChangeCamera(i1, 4 - j1))});
|
|
if (doorPositions.ContainsKey((i, j))){
|
|
monitorScreen.AddElement("door"+doorPositions[(i, j)], new UIElement([monitorAtlas[5], monitorAtlas[6]], point1));
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
public static void ChangeDoorState(Direction dir, bool state) {
|
|
switch ((int)dir){
|
|
case 0:
|
|
officeScreen["office_left"].SetTexture(state ? 1 : 0);
|
|
break;
|
|
case 1:
|
|
officeScreen["office_centre"].SetTexture(state ? 1 : 0);
|
|
break;
|
|
case 2:
|
|
officeScreen["office_right"].SetTexture(state ? 1 : 0);
|
|
break;
|
|
}
|
|
}
|
|
|
|
public static void ChangeMonitorState(bool state) {
|
|
Screen.SetScreen(state ? ScreenTypes.CAMERAS : ScreenTypes.OFFICE);
|
|
}
|
|
|
|
|
|
} |