|
|
using Microsoft.Xna.Framework;
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
|
|
|
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;
|
|
|
private ImFontPtr italicFont;
|
|
|
private ImGuiWindowBridgeEngine BridgeEngine;
|
|
|
public ImGuiWindowRenderer(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine engine)
|
|
|
{
|
|
|
this.font = font;
|
|
|
this.italicFont = italicFont;
|
|
|
this.BridgeEngine = engine;
|
|
|
}
|
|
|
|
|
|
private (Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index, Vector2 square)
|
|
|
getContractDetails(Entity entity) {
|
|
|
|
|
|
var name = GetComponent<NameAndDescriptionComponent>(entity).DisplayName;
|
|
|
var status = GetComponent<ContractStatusComponent>(entity).status;
|
|
|
var amount = GetComponent<BudgetLineComponent>(entity).amount;
|
|
|
var tree_delta = GetComponent<TreeDeltaComponent>(entity).deltaTreesName;
|
|
|
var image_index = GetComponent<ImageComponent>(entity).ImageIndex;
|
|
|
var description = "";
|
|
|
|
|
|
var square = GetComponent<AreaComponent>(entity).squares[0];
|
|
|
|
|
|
|
|
|
if (HasComponent<RelatedOrganizationComponent>(entity))
|
|
|
{
|
|
|
var related_organization = GetComponent<RelatedOrganizationComponent>(entity).Entity;
|
|
|
|
|
|
var name_component = GetComponent<NameAndDescriptionComponent>(related_organization);
|
|
|
name = name_component.DisplayName;
|
|
|
description = name_component.Description;
|
|
|
image_index = GetComponent<ImageComponent>(related_organization).ImageIndex;
|
|
|
}
|
|
|
|
|
|
return (entity, name, description, status, amount, tree_delta, image_index, square);
|
|
|
|
|
|
}
|
|
|
|
|
|
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>();
|
|
|
|
|
|
var contract_data = new List<(Entity, string, string, ContractStatus, decimal, string, int, Vector2)>();
|
|
|
|
|
|
foreach(var e in contracts)
|
|
|
{
|
|
|
contract_data.Add(getContractDetails(e));
|
|
|
}
|
|
|
|
|
|
ContractsWindow.Render(this.font, this.BridgeEngine, contract_data);
|
|
|
break;
|
|
|
case Window.Contract:
|
|
|
|
|
|
var data = getContractDetails(entity);
|
|
|
|
|
|
// var area_size = GetComponent<AreaComponent>(entity).squares.Length;
|
|
|
var area = GetComponent<AreaComponent>(entity).squares;
|
|
|
var area_size = GetComponent<AreaComponent>(entity).squares.Length;
|
|
|
|
|
|
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);
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|