SBSPSS/Utils/MapEdit/LayerFX.cpp

217 lines
5.7 KiB
C++
Raw Normal View History

2001-04-07 23:05:33 +02:00
/****************/
/*** Layer FX ***/
/****************/
2001-04-06 21:03:58 +02:00
#include "stdafx.h"
#include <Vector3.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include "GLEnabledView.h"
#include "MapEdit.h"
#include "MapEditDoc.h"
#include "MapEditView.h"
#include "MainFrm.h"
#include "Core.h"
#include "LayerThing.h"
2001-04-07 23:05:33 +02:00
#include "LayerFX.h"
2001-04-06 21:03:58 +02:00
#include "Utils.h"
#include "Export.h"
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-04-07 23:05:33 +02:00
CLayerFX::CLayerFX(sLayerDef &Def)
2001-04-06 21:03:58 +02:00
{
InitLayer(Def);
}
/*****************************************************************************/
2001-04-07 23:05:33 +02:00
void CLayerFX::InitLayer(sLayerDef &Def)
2001-04-06 21:03:58 +02:00
{
ThingBank=new CElemBank(-1,-1,false,CElem::CentreModeLR | CElem::CentreModeB);
CLayerThing::InitLayer(Def);
2001-04-07 23:05:33 +02:00
LoadThingScript(theApp.GetConfigStr("LayerScript","FXScript"));
2001-04-06 21:03:58 +02:00
}
/*****************************************************************************/
2001-04-07 23:05:33 +02:00
void CLayerFX::InitSubView(CCore *Core)
2001-04-06 21:03:58 +02:00
{
}
2001-04-30 23:49:54 +02:00
/*****************************************************************************/
void CLayerFX::LoadDefThing(const char *Name,sLayerThing &ThisDef)
{
}
/*****************************************************************************/
void CLayerFX::LoadOldThing(CFile *File,sLayerThing &ThisThing)
{
sLayerThingDataOLD OldThing;
File->Read(&OldThing,sizeof(sLayerThingDataOLD));
ThisThing.Data.FX.FXSpeed=OldThing.Speed;
ThisThing.Data.FX.FXWidth=OldThing.Width;
ThisThing.Data.FX.FXHeight=OldThing.Height;
}
2001-04-07 23:05:33 +02:00
/*****************************************************************************/
void CLayerFX::RenderThing(CCore *Core,Vector3 &ThisCam,sLayerThing &ThisThing,bool Render3d,bool Selected)
{
float ZoomW=Core->GetZoomW();
float ZoomH=Core->GetZoomH();
Vector3 &Scale=Core->GetScaleVector();
Vector3 ScrOfs(ZoomW/2,ZoomH/2,0);
float Col=0.8f,A=0.8f;
glColor4f(1,1,1,0.8f);
if (Selected)
{
Col=1.0f;
A=0.8f;
glColor4f(1,1,1,1.0f); // For number
}
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glScalef(Scale.x,Scale.y,Scale.z);
glTranslatef(-ThisCam.x,ThisCam.y,0); // Set scroll offset
glTranslatef(-ScrOfs.x,ScrOfs.y,0); // Bring to top left corner
glTranslatef(ThisThing.XY[0].x,-ThisThing.XY[0].y,0); // Set Pos
Core->RenderNumber(0);
glEnable(GL_DEPTH_TEST);
2001-04-30 23:49:54 +02:00
float W=(ThisThing.Data.FX.FXWidth);
float H=-(ThisThing.Data.FX.FXHeight);
2001-04-07 23:05:33 +02:00
// Draw Box
glBegin (GL_QUADS);
glColor4f(0,0,Col-0.25f,A);
glVertex3f(0,0+1,0);
glVertex3f(W,0+1,0);
glVertex3f(W,H+1,0);
glVertex3f(0,H+1,0);
glEnd();
// Draw OutLine
glBegin(GL_LINES);
glColor4f(Col,Col,Col,A);
glVertex3f( 0,0+1,0);
glVertex3f( W,0+1,0);
glVertex3f( W,0+1,0);
glVertex3f( W,H+1,0);
glVertex3f( W,H+1,0);
glVertex3f( 0,H+1,0);
glVertex3f( 0,H+1,0);
glVertex3f( 0,0+1,0);
glEnd();
glDisable(GL_DEPTH_TEST);
glPopMatrix();
}
2001-04-06 21:03:58 +02:00
/*****************************************************************************/
/*** Gui *********************************************************************/
/*****************************************************************************/
2001-04-07 23:05:33 +02:00
void CLayerFX::GUIInit(CCore *Core)
2001-04-06 21:03:58 +02:00
{
2001-04-07 23:05:33 +02:00
GUIFX.DisableCallback(true);
2001-04-06 21:03:58 +02:00
Core->GUIAdd(GUIThing,IDD_LAYER_THING);
2001-04-07 23:05:33 +02:00
Core->GUIAdd(GUIFX,IDD_LAYER_FX);
GUIFX.DisableCallback(false);
2001-04-09 16:56:05 +02:00
GUIFX.m_WidthSpin.SetRange(1,255);
GUIFX.m_HeightSpin.SetRange(1,255);
GUIFX.m_SpeedSpin.SetRange(0,255);
2001-04-06 21:03:58 +02:00
}
/*****************************************************************************/
2001-04-07 23:05:33 +02:00
void CLayerFX::GUIKill(CCore *Core)
2001-04-06 21:03:58 +02:00
{
Core->GUIRemove(GUIThing,IDD_LAYER_THING);
2001-04-07 23:05:33 +02:00
Core->GUIRemove(GUIFX,IDD_LAYER_FX);
2001-04-06 21:03:58 +02:00
}
/*****************************************************************************/
2001-04-07 23:05:33 +02:00
void CLayerFX::GUIUpdate(CCore *Core)
2001-04-06 21:03:58 +02:00
{
int i,ListSize;
CComboBox &List=GUIThing.m_DefList;
2001-04-07 23:05:33 +02:00
// Setup Def FX List
2001-04-06 21:03:58 +02:00
ListSize=DefList.size();
List.ResetContent();
for (i=0; i<ListSize; i++)
{
List.AddString(DefList[i].Name);
}
List.SetCurSel(CurrentDefThing);
GUIThingUpdate();
}
/*****************************************************************************/
2001-04-07 23:05:33 +02:00
void CLayerFX::GUIThingDefClear()
2001-04-06 21:03:58 +02:00
{
CComboBox &List=GUIThing.m_DefList;
CurrentDefThing=-1;
List.SetCurSel(CurrentDefThing);
}
/*****************************************************************************/
2001-04-07 23:05:33 +02:00
void CLayerFX::GUIThingUpdate(bool OnlySel)
2001-04-06 21:03:58 +02:00
{
GUIThingUpdateList(GUIThing.m_List,false);
// Params
2001-04-07 23:05:33 +02:00
GUIFX.DisableCallback(true);
2001-04-06 21:03:58 +02:00
if (CurrentThing!=-1)
{
sLayerThing &ThisThing=ThingList[CurrentThing];
2001-04-30 23:49:54 +02:00
GUIFX.SetVal(GUIFX.m_Speed,ThisThing.Data.FX.FXSpeed);
GUIFX.SetVal(GUIFX.m_Width,ThisThing.Data.FX.FXWidth);
GUIFX.SetVal(GUIFX.m_Height,ThisThing.Data.FX.FXHeight);
2001-04-06 21:03:58 +02:00
}
else
{
2001-04-07 23:05:33 +02:00
GUIFX.m_Speed.SetWindowText("");
GUIFX.m_Width.SetWindowText("");
GUIFX.m_Height.SetWindowText("");
2001-04-06 21:03:58 +02:00
}
2001-04-07 23:05:33 +02:00
GUIFX.DisableCallback(false);
2001-04-06 21:03:58 +02:00
}
/*****************************************************************************/
2001-04-07 23:05:33 +02:00
void CLayerFX::GUIThingPointUpdate(bool OnlySel)
2001-04-06 21:03:58 +02:00
{
}
/*****************************************************************************/
2001-04-07 23:05:33 +02:00
void CLayerFX::GUIChanged(CCore *Core)
2001-04-06 21:03:58 +02:00
{
if (CurrentThing!=-1)
{
sLayerThing &ThisThing=ThingList[CurrentThing];
2001-04-30 23:49:54 +02:00
ThisThing.Data.FX.FXSpeed=GUIFX.GetVal(GUIFX.m_Speed);
ThisThing.Data.FX.FXWidth=GUIFX.GetVal(GUIFX.m_Width);
ThisThing.Data.FX.FXHeight=GUIFX.GetVal(GUIFX.m_Height);
2001-04-06 21:03:58 +02:00
}
}
/*****************************************************************************/
2001-04-07 23:05:33 +02:00
void CLayerFX::SetThingParams(sLayerThing &Thing)
2001-04-06 21:03:58 +02:00
{
2001-04-07 23:05:33 +02:00
Thing.Data.WaypointCount=1;
2001-04-30 23:49:54 +02:00
if (Thing.Data.FX.FXWidth<1) Thing.Data.FX.FXWidth=1;
if (Thing.Data.FX.FXHeight<1) Thing.Data.FX.FXHeight=1;
2001-04-07 23:05:33 +02:00
}