Oprava spawnování monster, optimalizace v CommandProcessor a EventProcessor. Přesunutí některých tříd do vlastních namespaců, pročištění kódu, úpravy formátování, odstranění nepoužívaných souborů a zakomentovaného kódu
This commit is contained in:
parent
e5d746d597
commit
243f071a43
62 changed files with 873 additions and 1217 deletions
|
|
@ -1,5 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.VisualBasic.CompilerServices;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using MonoGameLibrary.Input;
|
||||
|
|
@ -9,36 +9,36 @@ namespace ONDClient.GUI;
|
|||
|
||||
public class Screen {
|
||||
|
||||
public static Dictionary<string, Screen> Screens = new();
|
||||
private static Dictionary<string, Screen> screens = new();
|
||||
public static Screen CurrentScreen{ get; private set; } = Empty;
|
||||
public static Screen OverlayScreen{ get; private set; } = Empty;
|
||||
|
||||
public static void AddScreens(Screen[] screens) {
|
||||
foreach (var screen in screens){
|
||||
Screens.Add(screen.Label, screen);
|
||||
public static void AddScreens(Screen[] screensToAdd) {
|
||||
foreach (var screen in screensToAdd){
|
||||
Screen.screens.Add(screen.Label, screen);
|
||||
}
|
||||
}
|
||||
public static void AddScreen(string id, Screen screen, bool activate = false) {
|
||||
Screens.Add(id, screen);
|
||||
screens.Add(id, screen);
|
||||
if (activate) SetScreen(id);
|
||||
}
|
||||
|
||||
public static void SetScreen(string id) {
|
||||
if (CurrentScreen.temporary){
|
||||
Screens.Remove(CurrentScreen.Label);
|
||||
screens.Remove(CurrentScreen.Label);
|
||||
}
|
||||
|
||||
CurrentScreen.Active = false;
|
||||
CurrentScreen = Screens[id];
|
||||
CurrentScreen = screens[id];
|
||||
CurrentScreen.Active = true;
|
||||
}
|
||||
|
||||
public static void RemoveScreen(string id) {
|
||||
Screens.Remove(id);
|
||||
screens.Remove(id);
|
||||
}
|
||||
|
||||
public static void UpdateAll() {
|
||||
foreach (var screen in Screens.Values){
|
||||
foreach (var screen in screens.Values){
|
||||
if (!screen.Active) continue;
|
||||
screen.Update();
|
||||
}
|
||||
|
|
@ -47,11 +47,11 @@ public class Screen {
|
|||
|
||||
public static void SetOverlayScreen(string id) {
|
||||
if (OverlayScreen.temporary){
|
||||
Screens.Remove(OverlayScreen.Label);
|
||||
screens.Remove(OverlayScreen.Label);
|
||||
}
|
||||
|
||||
OverlayScreen.Active = false;
|
||||
OverlayScreen = Screens[id];
|
||||
OverlayScreen = screens[id];
|
||||
OverlayScreen.Active = true;
|
||||
}
|
||||
|
||||
|
|
@ -63,6 +63,8 @@ public class Screen {
|
|||
CurrentScreen.Draw(spriteBatch);
|
||||
OverlayScreen.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
public static Screen[] GetAllScreens() => screens.Values.ToArray();
|
||||
|
||||
|
||||
|
||||
|
|
@ -117,15 +119,6 @@ public class Screen {
|
|||
temporaryElements.ForEach(RemoveElement);
|
||||
temporaryElements.Clear();
|
||||
}
|
||||
|
||||
public void SetActive(bool active) {
|
||||
Active = active;
|
||||
if (Active == active) return;
|
||||
foreach (var keyValuePair in elements){
|
||||
keyValuePair.Value.Active = Active;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ProcessMouseInput(MouseState mouseState) {
|
||||
if (!Active){
|
||||
|
|
@ -135,19 +128,19 @@ public class Screen {
|
|||
if (!element.Pressable) continue;
|
||||
|
||||
if (element.IsWithinBounds(mouseState.Position)){
|
||||
element.OnMousePress(); // TODO: differentiate between press, hold and release events
|
||||
element.OnMousePress();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Update() {
|
||||
private void Update() {
|
||||
foreach (var element in elements.Values){
|
||||
if (!element.Active) continue;
|
||||
element.Update();
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch) {
|
||||
private void Draw(SpriteBatch spriteBatch) {
|
||||
foreach (var val in elementsInDrawOrder){
|
||||
val.Draw(spriteBatch);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue