Show More
Commit Description:
Small tweaks.
Commit Description:
Small tweaks.
File last commit:
Show/Diff file:
Action:
isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs
166 lines | 4.5 KiB | text/x-csharp | CSharpLexer
using System.Collections.Generic;
using Encompass;
using System.Linq;
using ImGuiNET;
using isometricparkfna.Messages;
using isometricparkfna.Components;
using isometricparkfna.UI;
namespace isometricparkfna.Engines {
[Sends(typeof(ToggleWindowMessage),
typeof(ToggleWindowTypeMessage),
typeof(ChangeContractStatusMessage),
typeof(SelectMessage),
typeof(JumpCameraMessage),
typeof(GameStateMessage),
typeof(GameStateMessage),
typeof(SetResolutionMessage),
typeof(SetFontMessage),
typeof(SetTrespassingPolicyMessage),
typeof(SpawnGameMessage))]
[Reads(typeof(VisibilityComponent),
typeof(WindowTypeComponent),
typeof(TrespassingPolicyComponent)
//, typeof(SelectedComponent)
)]
// [Writes(typeof(SelectedComponent))]
public class ImGuiWindowBridgeEngine : Engine
{
public List<ToggleWindowMessage> messages;
public List<ToggleWindowTypeMessage> typeMessages;
public List<ChangeContractStatusMessage> contractStatusMessages;
public List<SelectMessage> selectedMessages;
public List<JumpCameraMessage> jumpCameraMessages;
public List<GameStateMessage> gameStateMessages;
public List<SetResolutionMessage> resolutionMessages;
public List<SetFontMessage> fontMessages;
public List<SetTrespassingPolicyMessage> trespassingPolicyMessages;
public List<SpawnGameMessage> spawnGameMessages;
bool showBudget {get;}
bool showForest {get;}
bool showNews {get;}
bool showGrid {get;}
bool showTrees {get;}
public Dictionary<Window, bool> windowStatuses {get;}
public ImFontPtr font;
public ImFontPtr italicFont;
private DebugWindow debugWindow;
public ImGuiWindowBridgeEngine(DebugWindow debugWindow,
ImFontPtr font, ImFontPtr italicFont)
{
this.messages = new List<ToggleWindowMessage>();
this.typeMessages = new List<ToggleWindowTypeMessage>();
this.contractStatusMessages = new List<ChangeContractStatusMessage>();
this.selectedMessages = new List<SelectMessage>();
this.jumpCameraMessages = new List<JumpCameraMessage>();
this.gameStateMessages = new List<GameStateMessage>();
this.resolutionMessages = new List<SetResolutionMessage>();
this.fontMessages = new List<SetFontMessage>();
this.trespassingPolicyMessages = new List<SetTrespassingPolicyMessage>();
this.spawnGameMessages = new List<SpawnGameMessage>();
this.windowStatuses = new Dictionary<Window, bool>();
this.font = font;
this.italicFont = italicFont;
this.debugWindow = debugWindow;
//Prepopulate:
foreach(var type in System.Enum.GetValues(typeof(Window)))
{
windowStatuses.Add((Window)type, false);
}
}
public override void Update(double dt)
{
foreach(var message in this.messages)
{
SendMessage(message);
}
foreach(var message in this.typeMessages)
{
SendMessage(message);
}
foreach(var message in this.contractStatusMessages)
{
SendMessage(message);
}
foreach(var message in this.selectedMessages)
{
SendMessage(message);
// SetComponent<SelectedComponent>(message.Entity, new SelectedComponent { selected = true});
}
foreach(var message in this.jumpCameraMessages)
{
SendMessage(message);
}
foreach(var message in this.gameStateMessages)
{
SendMessage(message);
}
foreach(var message in this.resolutionMessages)
{
SendMessage(message);
}
foreach(var message in this.fontMessages)
{
this.font = debugWindow.addFont(message.fontName,
message.fontSize, false);
debugWindow.setMonoFont(this.font);
this.italicFont = debugWindow.addFont(message.fontName,
message.fontSize, true);
debugWindow.setItalicFont(this.italicFont);
SendMessage(message);
OptionsWindow.setFont(message.fontName,
message.fontSize);
}
foreach (var message in this.trespassingPolicyMessages)
{
SendMessage(message);
}
foreach (var message in this.spawnGameMessages)
{
SendMessage(message);
}
foreach(var entity in ReadEntities<WindowTypeComponent>())
{
var type = GetComponent<WindowTypeComponent>(entity).type;
var visibility = GetComponent<VisibilityComponent>(entity).visible;
windowStatuses[type] = visibility;
}
this.messages.Clear();
this.typeMessages.Clear();
this.contractStatusMessages.Clear();
this.selectedMessages.Clear();
this.jumpCameraMessages.Clear();
this.gameStateMessages.Clear();
this.resolutionMessages.Clear();
this.fontMessages.Clear();
this.trespassingPolicyMessages.Clear();
this.spawnGameMessages.Clear();
}
}
}