Show More
Commit Description:
Pull out input from FNAGame.
Commit Description:
Pull out input from FNAGame.
References:
File last commit:
Show/Diff file:
Action:
isometric-park-fna/Renderers/ImGuiWindowRenderer.cs
107 lines | 3.8 KiB | text/x-csharp | CSharpLexer
107 lines | 3.8 KiB | text/x-csharp | CSharpLexer
r194 | using Microsoft.Xna.Framework; | |||
using Microsoft.Xna.Framework.Graphics; | ||||
r303 | using System; | |||
r194 | using System.Collections.Generic; | |||
r270 | using System.Linq; | |||
r194 | ||||
using isometricparkfna.UI; | ||||
using isometricparkfna.Engines; | ||||
using isometricparkfna.Components; | ||||
using isometricparkfna.Messages; | ||||
using ImGuiNET; | ||||
using Encompass; | ||||
using SpriteFontPlus; | ||||
namespace isometricparkfna.Renderers | ||||
{ | ||||
public class ImGuiWindowRenderer : GeneralRenderer | ||||
{ | ||||
private ImFontPtr font; | ||||
r256 | private ImFontPtr italicFont; | |||
r194 | private ImGuiWindowBridgeEngine BridgeEngine; | |||
r256 | public ImGuiWindowRenderer(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine engine) | |||
r194 | { | |||
this.font = font; | ||||
r256 | this.italicFont = italicFont; | |||
r194 | this.BridgeEngine = engine; | |||
} | ||||
r291 | private (Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index, Vector2 square) | |||
r246 | getContractDetails(Entity entity) { | |||
r256 | var name = GetComponent<NameAndDescriptionComponent>(entity).DisplayName; | |||
r246 | var status = GetComponent<ContractStatusComponent>(entity).status; | |||
var amount = GetComponent<BudgetLineComponent>(entity).amount; | ||||
var tree_delta = GetComponent<TreeDeltaComponent>(entity).deltaTreesName; | ||||
r249 | var image_index = GetComponent<ImageComponent>(entity).ImageIndex; | |||
r256 | var description = ""; | |||
r254 | ||||
r291 | var square = GetComponent<AreaComponent>(entity).squares[0]; | |||
r254 | ||||
if (HasComponent<RelatedOrganizationComponent>(entity)) | ||||
{ | ||||
var related_organization = GetComponent<RelatedOrganizationComponent>(entity).Entity; | ||||
r256 | var name_component = GetComponent<NameAndDescriptionComponent>(related_organization); | |||
name = name_component.DisplayName; | ||||
description = name_component.Description; | ||||
r255 | image_index = GetComponent<ImageComponent>(related_organization).ImageIndex; | |||
r254 | } | |||
r291 | return (entity, name, description, status, amount, tree_delta, image_index, square); | |||
r246 | ||||
} | ||||
r194 | public override void Render() | |||
{ | ||||
foreach (ref readonly var entity in ReadEntities<WindowTypeComponent>()) | ||||
{ | ||||
var window_type = GetComponent<WindowTypeComponent>(entity).type; | ||||
var visible = GetComponent<VisibilityComponent>(entity).visible; | ||||
if (visible) | ||||
{ | ||||
switch (window_type) | ||||
{ | ||||
case Window.Contracts: | ||||
var contracts = ReadEntities<AreaComponent>(); | ||||
r291 | var contract_data = new List<(Entity, string, string, ContractStatus, decimal, string, int, Vector2)>(); | |||
r194 | ||||
foreach(var e in contracts) | ||||
{ | ||||
r246 | contract_data.Add(getContractDetails(e)); | |||
r194 | } | |||
r195 | ContractsWindow.Render(this.font, this.BridgeEngine, contract_data); | |||
r194 | break; | |||
r246 | case Window.Contract: | |||
var data = getContractDetails(entity); | ||||
r270 | // var area_size = GetComponent<AreaComponent>(entity).squares.Length; | |||
var area = GetComponent<AreaComponent>(entity).squares; | ||||
var area_size = GetComponent<AreaComponent>(entity).squares.Length; | ||||
r246 | ||||
r291 | ContractWindow.Render(this.font, this.italicFont, this.BridgeEngine, entity, data.name, data.description, data.status, data.amount, data.delta_trees, area_size, data.image_index, data.square); | |||
r246 | ||||
break; | ||||
r303 | case Window.MainMenu: | |||
MainMenu.Render(this.font, this.BridgeEngine); | ||||
r246 | ||||
r303 | break; | |||
r194 | default: | |||
break; | ||||
} | ||||
} | ||||
} | ||||
} | ||||
} | ||||
r270 | } | |||