This commit is contained in:
Daveo 2001-03-31 15:40:20 +00:00
parent 337d6965ba
commit 9f1e03e8fc
10 changed files with 153 additions and 115 deletions

View File

@ -105,7 +105,8 @@ GFName Path=Filename;
/*****************************************************************************/
// 2d Elem (From Bmp File)
CElem::CElem(CCore *Core,const char *Filename,int TexID,int XOfs,int YOfs,int Width,int Height,bool Centre)
// 0,0 1,0 1,1 0,1
CElem::CElem(CCore *Core,const char *Filename,int TexID,int XOfs,int YOfs,int Width,int Height,int CentreMode)
{
CTexCache &TexCache=Core->GetTexCache();
GFName Path=Filename;
@ -119,10 +120,32 @@ GFName Path=Filename;
TexXOfs=XOfs;
TexYOfs=YOfs;
Ofs.Zero();
if (Centre)
if (CentreMode & CentreModeL)
{
Ofs.x=0.5-UnitWidth/2;
Ofs.y=-1.0f;
// Nothing to do, already there
}
if (CentreMode & CentreModeR)
{
Ofs.x-=UnitWidth;
}
if (CentreMode & CentreModeT)
{
Ofs.y-=UnitHeight;
}
if (CentreMode & CentreModeB)
{
// Nothing to do, already there
}
if (CentreMode & CentreModeLR)
{
Ofs.x-=(UnitWidth-1.0f)/2;
}
if (CentreMode & CentreModeTB)
{
Ofs.y-=(UnitHeight-1.0f)/2;
}
Build2dElem(Core,Path.File(),TexID);
@ -580,7 +603,7 @@ int Size=RGBData.TexW*RGBData.TexH;
/*** Elem Set ****************************************************************/
/*****************************************************************************/
/*****************************************************************************/
CElemSet::CElemSet(const char *_Filename,int Idx,int Width,int Height,bool CreateBlank,bool Centre)
CElemSet::CElemSet(const char *_Filename,int Idx,int Width,int Height,bool CreateBlank,int Centre)
{
GFName FName=_Filename;
@ -589,7 +612,7 @@ GFName FName=_Filename;
MaxWidth=Width;
MaxHeight=Height;
CentreFlag=Centre;
CentreMode=Centre;
Loaded=FALSE;
SetNumber=Idx;
@ -648,7 +671,7 @@ int Width,Height;
{
for (int X=0; X<Width; X++)
{
ElemList.push_back(CElem(Core,Filename,TexID,X,Y,MaxWidth,MaxHeight,CentreFlag));
ElemList.push_back(CElem(Core,Filename,TexID,X,Y,MaxWidth,MaxHeight,CentreMode));
}
}
ElemBrowserWidth=Width;
@ -707,12 +730,12 @@ int ListSize=ElemList.size();
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
CElemBank::CElemBank(int W,int H,bool Blank,bool Centre)
CElemBank::CElemBank(int W,int H,bool Blank,int Centre)
{
MaxWidth=W;
MaxHeight=H;
BlankFlag=Blank;
CentreFlag=Centre;
CentreMode=Centre;
LoadFlag=false;
CurrentSet=0;
@ -810,7 +833,7 @@ GString SavePath;
int CElemBank::AddSet(const char *Filename)
{
int ListSize=SetList.size();
CElemSet NewSet(Filename,ListSize,MaxWidth,MaxHeight,BlankFlag,CentreFlag);
CElemSet NewSet(Filename,ListSize,MaxWidth,MaxHeight,BlankFlag,CentreMode);
int Idx=SetList.Add(NewSet);
if (SetList.size()!=ListSize) LoadFlag=TRUE;

View File

@ -39,13 +39,22 @@ public:
ElemType3d,
ElemTypeMax
};
enum CentreMode
{
CentreModeL =1<<0,
CentreModeR =1<<1,
CentreModeLR=1<<2,
CentreModeT =1<<3,
CentreModeB =1<<4,
CentreModeTB=1<<5,
};
enum
{
UnitSize=16,
};
CElem(int Width,int Height); // Blank (2d)
CElem(CCore *Core,const char *Filename,int TexId,int XOfs,int YOfs,int Width,int Height,bool Centre); // 2d elem
CElem(CCore *Core,const char *Filename,int TexId,int XOfs,int YOfs,int Width,int Height,int CentreMode=0); // 2d elem
CElem(CCore *Core,const char *Filename,CScene &ThisScene,int Node); // 3d elem
void CleanUp();
@ -105,7 +114,7 @@ public:
DEF_ELEMBROWSWEWIDTH=8,
};
CElemSet(const char *_Filename,int Idx,int MaxWidth,int MaxHeight,bool CreateBlank,bool Centre);
CElemSet(const char *_Filename,int Idx,int MaxWidth,int MaxHeight,bool CreateBlank,int Centre=0);
~CElemSet();
void CleanUp();
@ -136,7 +145,7 @@ private:
int SetNumber;
int MaxWidth,MaxHeight;
int BmpW,BmpH;
bool CentreFlag;
int CentreMode;
CList<CElem> ElemList;
bool Loaded;
int ElemBrowserWidth;
@ -147,7 +156,7 @@ class CElemBank : public CLayer
{
public:
// Local
CElemBank(int MaxWidth,int MaxHeight,bool Blank,bool Centre);
CElemBank(int MaxWidth,int MaxHeight,bool Blank,int Centre=0);
virtual ~CElemBank();
void CleanUp();
@ -200,7 +209,8 @@ protected:
int CursorPos;
int MaxWidth,MaxHeight;
bool BlankFlag,CentreFlag;
bool BlankFlag;
int CentreMode;
CGUIElemList GUIElemList;

View File

@ -30,6 +30,7 @@ CLayerActor::CLayerActor(sLayerDef &Def)
/*****************************************************************************/
void CLayerActor::InitLayer(sLayerDef &Def)
{
ThingBank=new CElemBank(-1,-1,false,CElem::CentreModeLR | CElem::CentreModeB);
CLayerThing::InitLayer(Def);
LoadThingScript(theApp.GetConfigStr("LayerScript","ActorScript"));
}
@ -82,21 +83,9 @@ CComboBox &List=GUI.m_List;
}
/*****************************************************************************/
void CLayerActor::GUIThingUpdate()
void CLayerActor::GUIThingUpdate(bool OnlySel)
{
int i,ListSize;
CComboBox &List=GUI.m_LevelList;
// Setup ThingList
ListSize=ThingList.size();
TRACE1("%i\n",ListSize);
List.ResetContent();
for (i=0; i<ListSize; i++)
{
List.AddString(ThingList[i].Name);
}
List.SetCurSel(CurrentThing);
GUIThingPointUpdate();
GUIThingUpdateList(GUI.m_LevelList,false);
// Params
GUI.DisableCallback(true);
if (CurrentThing!=-1)
@ -122,28 +111,9 @@ CComboBox &List=GUI.m_LevelList;
}
/*****************************************************************************/
void CLayerActor::GUIThingPointUpdate()
void CLayerActor::GUIThingPointUpdate(bool OnlySel)
{
int i,ListSize;
sLayerThing &ThisThing=ThingList[CurrentThing];
CListBox &List=GUI.m_PosList;
List.ResetContent();
if (CurrentThing==-1)
{
}
else
{
// Setup ThingPointList
ListSize=ThisThing.XY.size();
for (i=0; i<ListSize; i++)
{
CString Str;
Str.Format("%i: %i, %i",i,ThisThing.XY[i].x,ThisThing.XY[i].y);
List.AddString(Str);
}
List.SetCurSel(CurrentThingPoint);
}
GUIThingPointUpdateList(GUI.m_PosList,OnlySel);
}
/*****************************************************************************/

View File

@ -28,8 +28,8 @@ public:
bool GUIReady();
void GUIThingDefClear();
void GUIThingUpdate();
void GUIThingPointUpdate();
void GUIThingUpdate(bool OnlySel=false);
void GUIThingPointUpdate(bool OnlySel=false);
void ExportThing(CExport &Exp,sLayerThing &ThisThing);

View File

@ -30,8 +30,11 @@ CLayerItem::CLayerItem(sLayerDef &Def)
/*****************************************************************************/
void CLayerItem::InitLayer(sLayerDef &Def)
{
ThingBank=new CElemBank(-1,-1,false,CElem::CentreModeLR || CElem::CentreModeTB);
CLayerThing::InitLayer(Def);
LoadThingScript(theApp.GetConfigStr("LayerScript","ItemScript"));
DrawPoints=false;
}
/*****************************************************************************/
@ -82,10 +85,17 @@ CComboBox &List=GUI.m_List;
}
/*****************************************************************************/
void CLayerItem::GUIThingUpdate()
void CLayerItem::GUIThingUpdate(bool OnlySel)
{
int i,ListSize;
CComboBox &List=GUI.m_LevelList;
if (OnlySel)
{
List.SetCurSel(CurrentThing);
return;
}
// Setup ThingList
ListSize=ThingList.size();
TRACE1("%i\n",ListSize);

View File

@ -28,7 +28,7 @@ public:
bool GUIReady();
void GUIThingDefClear();
void GUIThingUpdate();
void GUIThingUpdate(bool OnlySel=false);
void ExportThing(CExport &Exp,sLayerThing &ThisThing);

View File

@ -30,6 +30,7 @@ CLayerPlatform::CLayerPlatform(sLayerDef &Def)
/*****************************************************************************/
void CLayerPlatform::InitLayer(sLayerDef &Def)
{
ThingBank=new CElemBank(-1,-1,false,0);
CLayerThing::InitLayer(Def);
LoadThingScript(theApp.GetConfigStr("LayerScript","PlatformScript"));
}
@ -86,49 +87,13 @@ CComboBox &List=GUI.m_List;
}
/*****************************************************************************/
void CLayerPlatform::GUIThingUpdate()
void CLayerPlatform::GUIThingUpdate(bool OnlySel)
{
/*
int i,ListSize;
CComboBox &List=GUI.m_LevelList;
// Setup ThingList
ListSize=ThingList.size();
TRACE1("%i\n",ListSize);
List.ResetContent();
for (i=0; i<ListSize; i++)
{
List.AddString(ThingList[i].Name);
}
List.SetCurSel(CurrentThing);
GUIThingPointUpdate();
// Params
GUI.DisableCallback(true);
if (CurrentThing!=-1)
{
sLayerThing &ThisThing=ThingList[CurrentThing];
GUI.SetVal(GUI.m_Speed,ThisThing.Data.Speed);
GUI.SetVal(GUI.m_TurnRate,ThisThing.Data.TurnRate);
GUI.SetVal(GUI.m_Health,ThisThing.Data.Health);
GUI.SetVal(GUI.m_Attack,ThisThing.Data.AttackStrength);
GUI.m_Collision.SetCheck(ThisThing.Data.CollisionFlag);
GUI.m_Player.SetCheck(ThisThing.Data.PlayerFlag);
}
else
{
GUI.m_Speed.SetWindowText("");
GUI.m_TurnRate.SetWindowText("");
GUI.m_Health.SetWindowText("");
GUI.m_Attack.SetWindowText("");
GUI.m_Collision.SetCheck(false);
GUI.m_Player.SetCheck(false);
}
GUI.DisableCallback(false);
*/
// CLayerThing::GUIThingUpdateList(GUI.
}
/*****************************************************************************/
void CLayerPlatform::GUIThingPointUpdate()
void CLayerPlatform::GUIThingPointUpdate(bool OnlySel)
{
/*
int i,ListSize;

View File

@ -28,8 +28,8 @@ public:
bool GUIReady();
void GUIThingDefClear();
void GUIThingUpdate();
void GUIThingPointUpdate();
void GUIThingUpdate(bool OnlySel=false);
void GUIThingPointUpdate(bool OnlySel=false);
void ExportThing(CExport &Exp,sLayerThing &ThisThing);

View File

@ -40,13 +40,12 @@ void CLayerThing::InitLayer(sLayerDef &Def)
{
CLayer::InitLayer(Def);
Mode=MouseModeNormal;
ThingBank=new CElemBank(-1,-1,false,true);
Cursor.XY.resize(1);
Cursor.ElemID=-1;
CurrentDefThing=-1;
CurrentThing=-1;
CurrentThingPoint=0;
DrawPoints=true;
}
/*****************************************************************************/
@ -244,20 +243,28 @@ int ListSize=ThisThing.XY.size();
// Render Thing
glPushMatrix();
glTranslatef(ThisThing.XY[i].x,-ThisThing.XY[i].y,0); // Set Pos
if (Selected)
glColor4f(1,1,1,1); // Set default Color
else
glColor4f(1,1,1,0.5);
Core->RenderNumber(i);
if (i==0)
{
glColor4f(1,1,1,1); // Set default Color
glEnable(GL_DEPTH_TEST);
glTranslatef(0,0,ScrOfs.z);
ThingBank->RenderElem(ThisThing.ElemID,0,0,Render3d);
glTranslatef(0,0,-ScrOfs.z);
glDisable(GL_DEPTH_TEST);
glTranslatef(0,0,-ScrOfs.z);
if (Selected)
glColor4f(1,1,0,0.8f);
else
glColor4f(1,1,0,0.5f);
if (DrawPoints) Core->RenderNumber(i);
}
else
{
if (Selected)
glColor4f(1,1,1,1); // Set default Color
else
glColor4f(1,1,1,0.5);
if (DrawPoints) Core->RenderNumber(i);
}
glPopMatrix();
}
@ -287,6 +294,47 @@ void CLayerThing::GUIChanged(CCore *Core)
{
}
/*****************************************************************************/
void CLayerThing::GUIThingUpdateList(CComboBox &List,bool OnlySel)
{
int i,ListSize;
if (!OnlySel)
{
// Setup ThingList
ListSize=ThingList.size();
List.ResetContent();
for (i=0; i<ListSize; i++)
{
List.AddString(ThingList[i].Name);
}
}
List.SetCurSel(CurrentThing);
}
/*****************************************************************************/
void CLayerThing::GUIThingPointUpdateList(CListBox &List,bool OnlySel)
{
int i,ListSize;
if (!OnlySel)
{
// Setup ThingPointList
List.ResetContent();
if (CurrentThing==-1) return;
sLayerThing &ThisThing=ThingList[CurrentThing];
ListSize=ThisThing.XY.size();
for (i=0; i<ListSize; i++)
{
CString Str;
Str.Format("%i: %i, %i",i,ThisThing.XY[i].x,ThisThing.XY[i].y);
List.AddString(Str);
}
}
List.SetCurSel(CurrentThingPoint);
}
/*****************************************************************************/
/*** Functions ***************************************************************/
/*****************************************************************************/
@ -299,16 +347,12 @@ bool Ret=false;
{
case MouseModeNormal:
SelectThing(CursorPos);
GUIThingUpdate();
break;
case MouseModeNew:
AddThing(CursorPos);
GUIThingDefClear();
GUIThingUpdate();
break;
case MouseModePoints:
AddThingPoint(CursorPos);
GUIThingPointUpdate();
break;
default:
break;
@ -320,7 +364,6 @@ bool Ret=false;
/*****************************************************************************/
bool CLayerThing::RButtonControl(CCore *Core,UINT nFlags, CPoint &CursorPos,bool DownFlag)
{
if (!DownFlag) return(false);
Cancel();
return(true);
}
@ -335,7 +378,6 @@ bool Ret=false;
if (nFlags & MK_LBUTTON) // Drag
{
UpdatePos(CursorPos,CurrentThing,CurrentThingPoint,(nFlags & MK_CONTROL)!=0);
GUIThingPointUpdate();
Ret=true;
}
else
@ -361,6 +403,7 @@ void CLayerThing::Cancel()
CurrentThingPoint=0;
GUIThingDefClear();
GUIThingUpdate();
GUIThingPointUpdate();
break;
default:
break;
@ -376,7 +419,6 @@ bool Ret=false;
{
case CmdMsg_ThingListDelete:
DeleteThing();
GUIThingUpdate();
break;
case CmdMsg_ThingListSelect:
CurrentDefThing=Param0;
@ -385,7 +427,6 @@ bool Ret=false;
break;
case CmdMsg_ThingLevelSelect:
SelectThing(Param0);
GUIThingUpdate();
break;
case CmdMsg_ThingPosSelect:
CurrentThingPoint=Param0;
@ -479,12 +520,14 @@ void CLayerThing::AddThing(CPoint &Pos)
CurrentThing=SelectThing(Pos);
if (CurrentThing!=-1) return;
CurrentThing=ThingList.size();
ThingList.resize(CurrentThing+1);
sLayerThing &ThisThing=ThingList[CurrentThing];
ThisThing=Cursor;
SelectThing(CurrentThing);
GUIThingDefClear();
}
/*****************************************************************************/
@ -511,6 +554,8 @@ int CLayerThing::SelectThing(int Idx)
{
Mode=MouseModeNormal;
}
GUIThingUpdate();
GUIThingPointUpdate();
}
return(CurrentThing);
}
@ -522,6 +567,7 @@ void CLayerThing::DeleteThing()
ThingList.erase(CurrentThing);
CurrentThing--;
GUIThingUpdate();
}
@ -557,15 +603,22 @@ int StartIdx=0;
/*****************************************************************************/
void CLayerThing::AddThingPoint(CPoint &Pos)
{
TRACE1("ADDTHINGPOINT %i\n",CurrentThingPoint);
if (Pos.x==-1 || Pos.y==-1) return; // Off Map?
CurrentThingPoint=SelectThingPoint(Pos);
if (CurrentThingPoint!=-1) return;
if (CurrentThingPoint!=-1)
{
GUIThingPointUpdate(true);
return;
}
sLayerThing &ThisThing=ThingList[CurrentThing];
CurrentThingPoint=ThisThing.XY.size();
ThisThing.XY.resize(CurrentThingPoint+1);
ThisThing.XY[CurrentThingPoint]=Pos;
TRACE0("Add Point\n");
GUIThingPointUpdate();
}
/*****************************************************************************/
@ -585,6 +638,8 @@ sLayerThing &ThisThing=ThingList[Thing];
CPoint dPos=Pos-ThisThing.XY[PosIdx];
int StartIdx=PosIdx,EndIdx=ThisThing.XY.size();
if (!dPos.x && !dPos.y) return;
if (!Recurs)
{
StartIdx=PosIdx;
@ -595,6 +650,8 @@ int StartIdx=PosIdx,EndIdx=ThisThing.XY.size();
{
ThisThing.XY[i]+=dPos;
}
GUIThingPointUpdate();
}
/*****************************************************************************/

View File

@ -64,8 +64,10 @@ virtual void GUIUpdate(CCore *Core);
virtual void GUIChanged(CCore *Core);
virtual void GUIThingDefClear(){};
virtual void GUIThingUpdate(){};
virtual void GUIThingPointUpdate(){};
virtual void GUIThingUpdate(bool OnlySel=false){};
virtual void GUIThingUpdateList(CComboBox &List,bool OnlySel=false);
virtual void GUIThingPointUpdate(bool OnlySel=false){};
virtual void GUIThingPointUpdateList(CListBox &List,bool OnlySel=false);
virtual void Load(CFile *File,int Version);
virtual void LoadThing(CFile *File,int Version,sLayerThing &ThisThing);
@ -112,6 +114,7 @@ virtual void SetCursor(const char *Name);
int CurrentThing,CurrentThingPoint;
MouseMode Mode;
sLayerThing Cursor;
bool DrawPoints;
};
/*****************************************************************************/