SBSPSS/Utils/MapEdit/LayerActor.cpp

169 lines
5.4 KiB
C++
Raw Normal View History

2001-03-26 23:29:09 +02:00
/*******************/
/*** Layer Actor ***/
/*******************/
2001-03-26 17:22:59 +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-03-26 23:29:09 +02:00
#include "LayerActor.h"
2001-03-26 17:22:59 +02:00
#include "Utils.h"
#include "Export.h"
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-03-29 19:59:01 +02:00
CLayerActor::CLayerActor(sLayerDef &Def)
2001-03-26 17:22:59 +02:00
{
2001-03-29 19:59:01 +02:00
InitLayer(Def);
2001-03-26 17:22:59 +02:00
}
/*****************************************************************************/
2001-03-29 19:59:01 +02:00
void CLayerActor::InitLayer(sLayerDef &Def)
{
2001-03-31 17:40:20 +02:00
ThingBank=new CElemBank(-1,-1,false,CElem::CentreModeLR | CElem::CentreModeB);
2001-03-29 19:59:01 +02:00
CLayerThing::InitLayer(Def);
LoadThingScript(theApp.GetConfigStr("LayerScript","ActorScript"));
}
2001-03-26 17:22:59 +02:00
/*****************************************************************************/
2001-03-29 19:59:01 +02:00
void CLayerActor::InitSubView(CCore *Core)
2001-03-26 17:22:59 +02:00
{
}
2001-04-30 23:49:54 +02:00
/*****************************************************************************/
void CLayerActor::LoadDefThing(const char *Name,sLayerThing &ThisDef)
{
ThisDef.Data.Actor.ActorSpeed=ThingScript.GetInt(Name,"Speed");
ThisDef.Data.Actor.ActorTurnRate=ThingScript.GetInt(Name,"TurnRate");
ThisDef.Data.Actor.ActorHealth=ThingScript.GetInt(Name,"Health");
ThisDef.Data.Actor.ActorAttackStrength=ThingScript.GetInt(Name,"AttackStrength");
ThisDef.Data.Actor.ActorCollisionFlag=ThingScript.GetInt(Name,"Collision")==1;
}
/*****************************************************************************/
void CLayerActor::LoadOldThing(CFile *File,sLayerThing &ThisThing)
{
sLayerThingDataOLD OldThing;
File->Read(&OldThing,sizeof(sLayerThingDataOLD));
ThisThing.Data.Actor.ActorSpeed=OldThing.Speed;
ThisThing.Data.Actor.ActorTurnRate=OldThing.TurnRate;
ThisThing.Data.Actor.ActorHealth=OldThing.Health;
ThisThing.Data.Actor.ActorAttackStrength=OldThing.AttackStrength;
ThisThing.Data.Actor.ActorCollisionFlag=OldThing.CollisionFlag;
}
2001-03-26 17:22:59 +02:00
/*****************************************************************************/
2001-03-29 19:59:01 +02:00
/*** Gui *********************************************************************/
/*****************************************************************************/
void CLayerActor::GUIInit(CCore *Core)
2001-03-26 17:22:59 +02:00
{
2001-04-07 23:05:33 +02:00
GUIActor.DisableCallback(true);
Core->GUIAdd(GUIThing,IDD_LAYER_THING);
Core->GUIAdd(GUIThingPos,IDD_LAYER_THING_POS);
Core->GUIAdd(GUIActor,IDD_LAYER_ACTOR);
GUIActor.DisableCallback(false);
2001-04-09 16:56:05 +02:00
GUIActor.m_HealthSpin.SetRange(0,255);
GUIActor.m_AttackSpin.SetRange(0,255);
GUIActor.m_SpeedSpin.SetRange(0,255);
GUIActor.m_TurnRateSpin.SetRange(0,255);
2001-03-26 17:22:59 +02:00
}
/*****************************************************************************/
2001-03-29 19:59:01 +02:00
void CLayerActor::GUIKill(CCore *Core)
2001-03-26 17:22:59 +02:00
{
2001-04-07 23:05:33 +02:00
Core->GUIRemove(GUIThing,IDD_LAYER_THING);
Core->GUIRemove(GUIThingPos,IDD_LAYER_THING_POS);
Core->GUIRemove(GUIActor,IDD_LAYER_ACTOR);
2001-03-26 17:22:59 +02:00
}
/*****************************************************************************/
2001-03-29 19:59:01 +02:00
void CLayerActor::GUIUpdate(CCore *Core)
2001-03-26 17:22:59 +02:00
{
2001-03-29 19:59:01 +02:00
int i,ListSize;
2001-04-07 23:05:33 +02:00
CComboBox &List=GUIThing.m_DefList;
2001-03-26 17:22:59 +02:00
2001-03-29 19:59:01 +02:00
// Setup Def Actor List
ListSize=DefList.size();
List.ResetContent();
for (i=0; i<ListSize; i++)
2001-03-26 17:22:59 +02:00
{
2001-03-29 19:59:01 +02:00
List.AddString(DefList[i].Name);
2001-03-26 17:22:59 +02:00
}
2001-03-29 19:59:01 +02:00
List.SetCurSel(CurrentDefThing);
GUIThingUpdate();
2001-03-26 17:22:59 +02:00
}
/*****************************************************************************/
2001-03-29 19:59:01 +02:00
void CLayerActor::GUIThingDefClear()
2001-03-26 17:22:59 +02:00
{
2001-04-07 23:05:33 +02:00
CComboBox &List=GUIThing.m_DefList;
2001-03-29 19:59:01 +02:00
CurrentDefThing=-1;
List.SetCurSel(CurrentDefThing);
2001-03-26 17:22:59 +02:00
}
/*****************************************************************************/
2001-03-31 17:40:20 +02:00
void CLayerActor::GUIThingUpdate(bool OnlySel)
2001-03-26 17:22:59 +02:00
{
2001-04-07 23:05:33 +02:00
GUIThingUpdateList(GUIThing.m_List,false);
2001-03-29 19:59:01 +02:00
// Params
2001-04-07 23:05:33 +02:00
GUIActor.DisableCallback(true);
2001-03-29 19:59:01 +02:00
if (CurrentThing!=-1)
{
sLayerThing &ThisThing=ThingList[CurrentThing];
2001-04-30 23:49:54 +02:00
GUIActor.SetVal(GUIActor.m_Speed,ThisThing.Data.Actor.ActorSpeed);
GUIActor.SetVal(GUIActor.m_TurnRate,ThisThing.Data.Actor.ActorTurnRate);
GUIActor.SetVal(GUIActor.m_Health,ThisThing.Data.Actor.ActorHealth);
GUIActor.SetVal(GUIActor.m_Attack,ThisThing.Data.Actor.ActorAttackStrength);
GUIActor.m_Collision.SetCheck(ThisThing.Data.Actor.ActorCollisionFlag);
bool IsPlayer=ThingScript.GetInt(ThisThing.Name,"Player")==1;
GUIActor.m_Player.SetCheck(IsPlayer);
2001-03-29 19:59:01 +02:00
}
else
{
2001-04-07 23:05:33 +02:00
GUIActor.m_Speed.SetWindowText("");
GUIActor.m_TurnRate.SetWindowText("");
GUIActor.m_Health.SetWindowText("");
GUIActor.m_Attack.SetWindowText("");
GUIActor.m_Collision.SetCheck(false);
GUIActor.m_Player.SetCheck(false);
2001-03-29 19:59:01 +02:00
}
2001-04-07 23:05:33 +02:00
GUIActor.DisableCallback(false);
2001-03-26 17:22:59 +02:00
}
/*****************************************************************************/
2001-03-31 17:40:20 +02:00
void CLayerActor::GUIThingPointUpdate(bool OnlySel)
2001-03-26 17:22:59 +02:00
{
2001-04-07 23:05:33 +02:00
GUIThingPointUpdateList(GUIThingPos.m_List,OnlySel);
2001-03-26 17:22:59 +02:00
}
/*****************************************************************************/
2001-03-26 23:29:09 +02:00
void CLayerActor::GUIChanged(CCore *Core)
2001-03-26 17:22:59 +02:00
{
2001-03-29 19:59:01 +02:00
if (CurrentThing!=-1)
{
sLayerThing &ThisThing=ThingList[CurrentThing];
2001-04-30 23:49:54 +02:00
ThisThing.Data.Actor.ActorSpeed=GUIActor.GetVal(GUIActor.m_Speed);
ThisThing.Data.Actor.ActorTurnRate=GUIActor.GetVal(GUIActor.m_TurnRate);
ThisThing.Data.Actor.ActorHealth=GUIActor.GetVal(GUIActor.m_Health);
ThisThing.Data.Actor.ActorAttackStrength=GUIActor.GetVal(GUIActor.m_Attack);
ThisThing.Data.Actor.ActorCollisionFlag=GUIActor.m_Collision.GetCheck()!=0;
2001-03-29 19:59:01 +02:00
}
2001-03-26 17:22:59 +02:00
}