using System;
using System.Collections.Generic;
using System.Text;
using CMEngine;
using MTV3D65;
namespace CMGame
{
/// Author(s): Naveen Nattam
/// Date: 01/24/06
///
/// Updates texture on Reactor/Condenser Monitor to refelec their current status
///
/// TESTING LOG
/// 02/07/2006 - Naveen Nattam - Tested succesfully in game
/// ----------------------------------------------
/// CHANGE LOG
/// - -
public class TemperatureScreen
{
#region Private Variables
///
/// Mesh that our screen is part of
///
private Mesh screenMesh;
///
/// Render Surface that will generate texture to be applied to screen
///
private TVRenderSurface reactorSurface, condenserSurface;
///
/// ids for font settings
///
private int mFontID, mFontColorRed, mFontColorGreen, mFontColorBlue;
///
/// List of textures for three parts of screen
///
private List condenserTextures, reactorTextures, screenTextures;
///
/// Group number of Reactor Section of the Screen on the Mesh
///
private const int reactorGroup = 1;
///
/// Group Number of the Condenser Section of the Screen on the Mesh
///
private const int condenserGroup = 2;
///
/// Group number of the Top of the Screen on the Mesh
///
private const int top = 3;
///
/// Vents for Reactor and Condenser to pull temperature status from
///
private Vent reactorVent, condenserVent;
#endregion
/// Author(s): Naveen Nattam
/// Date: 01/24/06
///
/// Consturctor. Creates Render Surfaces and sets font settings.
///
/// Mesh that screen is part of
/// Vent object of Reactor
/// Vent Object of Condenser
public TemperatureScreen(Mesh mesh, Vent reactorVent, Vent condenserVent)
{
screenMesh = mesh;
this.reactorVent = reactorVent;
this.condenserVent = condenserVent;
CreateTextures();
mFontID = TVSingletons.Screen2DText.NormalFont_Create("temperatureScreen", "", 45, false, false, false);
mFontColorRed = TVSingletons.Globals.RGBA256(255, 0, 0, 255);
mFontColorGreen = TVSingletons.Globals.RGBA256(0, 255, 0, 255);
mFontColorBlue = TVSingletons.Globals.RGBA256(106, 166, 209, 255);
reactorSurface = TVSingletons.Scene.CreateRenderSurface(1024, 1024, false, CONST_TV_RENDERSURFACEFORMAT.TV_TEXTUREFORMAT_DEFAULT);
condenserSurface = TVSingletons.Scene.CreateRenderSurface(1024, 1024, false, CONST_TV_RENDERSURFACEFORMAT.TV_TEXTUREFORMAT_DEFAULT);
}
/// Author(s): Naveen Nattam
/// Date: 01/24/06
///
/// Creates texture sets for screen
///
public void CreateTextures()
{
condenserTextures = new List();
reactorTextures = new List();
screenTextures = new List();
string folderName = "catalyst_screen\\";
condenserTextures.Add(CreateTexture(folderName + "condenser_green2.dds"));
condenserTextures.Add(CreateTexture(folderName + "condenser_red2.dds"));
reactorTextures.Add(CreateTexture(folderName + "reactor_green2.dds"));
reactorTextures.Add(CreateTexture(folderName + "reactor_red2.dds"));
screenTextures.Add(CreateTexture(folderName + "top.dds"));
}
/// Author(s): Naveen Nattam
/// Date: 01/24/06
///
/// returns an int from the texture created
///
/// path of texture file
/// id for texture
public int CreateTexture(string path)
{
return ResourceCache.CreateTexture(path, TextureType.Normal);
}
/// Author(s): Naveen Nattam
/// Date: 01/24/06
///
/// Updates the screen based on reactor/condenser vents status
///
public void Update()
{
if (reactorVent.CheckTemperature())
RenderSurface(ref reactorSurface, reactorVent, reactorTextures[0], 640, 430, mFontColorGreen, true);
else
RenderSurface(ref reactorSurface, reactorVent, reactorTextures[1], 640, 430, mFontColorRed, true);
screenMesh.SetTexture(reactorSurface.GetTexture(), reactorGroup);
if (condenserVent.CheckTemperature())
RenderSurface(ref condenserSurface, condenserVent, condenserTextures[0], 260, 430, mFontColorGreen, false);
else
RenderSurface(ref condenserSurface, condenserVent, condenserTextures[1], 260, 430, mFontColorRed, false);
screenMesh.SetTexture(condenserSurface.GetTexture(), condenserGroup);
screenMesh.SetTexture(screenTextures[0], top);
}
/// Author(s): Naveen Nattam
/// Date: 01/24/06
///
/// Updates the Render Surface that will be draw on the screen
///
/// Render Surface to update
/// vent object to get status of
/// id of background texture
///
///
///
///
public void RenderSurface(ref TVRenderSurface surface, Vent ventToCheck, int backgroundTexture, int screenX, int screenY, int color, bool drawPressure)
{
surface.StartRender();
//render background
TVSingletons.Screen2DImmediate.Action_Begin2D();
TVSingletons.Screen2DImmediate.Draw_Texture(backgroundTexture, 0, 0, 1024, 1024);
TVSingletons.Screen2DImmediate.Action_End2D();
//render pressure
TVSingletons.Screen2DText.Action_BeginText();
TVSingletons.Screen2DText.NormalFont_DrawText(ventToCheck.CurrentTemperature.ToString(), screenX, screenY, color, mFontID);
if (drawPressure)
{
//TVSingletons.Screen2DText.NormalFont_DrawText("5700", screenX, screenY + 100, mFontColorBlue, mFontID);
TVSingletons.Screen2DText.NormalFont_DrawText("5700", screenX - 8, screenY + 240, mFontColorBlue, mFontID);
}
TVSingletons.Screen2DText.Action_EndText();
surface.EndRender();
}
}
}