This commit is contained in:
parent
e2bc92802a
commit
d2dd4ffd27
20 changed files with 330 additions and 152 deletions
|
@ -33,7 +33,10 @@ CCore::CCore()
|
|||
CurrentMousePos=CPoint(0,0);
|
||||
ActiveLayer=0;
|
||||
MapCam=Vec(0,0,0);
|
||||
MapCamOfs=Vec(-15,10,0);
|
||||
TileCam=Vec(0,0,0);
|
||||
TileCamOfs=Vec(-15,10,0);
|
||||
|
||||
Is3dFlag=TRUE;
|
||||
}
|
||||
|
||||
|
@ -65,10 +68,10 @@ void CCore::New()
|
|||
{
|
||||
// Create Gfx Layers
|
||||
// Name Width Height SizeDiv ViewDiv 3d? Resizable?
|
||||
Layer.push_back(new CLayerTile( "Back", 32, 32, 1.0f, 4.0f, FALSE, FALSE));
|
||||
Layer.push_back(new CLayerTile( "Back", 32, 32, 4.0f, 4.0f, FALSE, FALSE));
|
||||
Layer.push_back(new CLayerTile( "Mid", TileLayerDefaultWidth, TileLayerDefaultHeight, 2.0f, 2.0f, FALSE, TRUE));
|
||||
Layer.push_back(new CLayerTile( "Action", TileLayerDefaultWidth, TileLayerDefaultHeight, 1.0f, 1.0f, TRUE, TRUE));
|
||||
Layer.push_back(new CLayerTile( "Fore", TileLayerDefaultWidth, TileLayerDefaultHeight, 0.5f, 0.5f, FALSE, TRUE));
|
||||
// Layer.push_back(new CLayerTile( "Fore", TileLayerDefaultWidth, TileLayerDefaultHeight, 0.5f, 0.5f, FALSE, TRUE));
|
||||
|
||||
ActiveLayer=LAYER_ACTION;
|
||||
MapCam=Vec(0,0,0);
|
||||
|
@ -113,6 +116,7 @@ int LayerCount;
|
|||
}
|
||||
TileBank.Load(File,Version);
|
||||
Init();
|
||||
MapCam=Vec(0,0,0);
|
||||
|
||||
}
|
||||
|
||||
|
@ -175,10 +179,10 @@ int ListSize=Layer.size();
|
|||
for (int i=0;i<ListSize;i++)
|
||||
{
|
||||
Layer[i]->Render(this,ThisCam,Is3dFlag);
|
||||
if (GridFlag) Layer[i]->RenderGrid(this,ThisCam,i==ActiveLayer);
|
||||
}
|
||||
|
||||
Layer[ActiveLayer]->RenderCursor(this,ThisCam,Is3dFlag);
|
||||
if (GridFlag) Layer[ActiveLayer]->RenderGrid(this,ThisCam);
|
||||
|
||||
// Get Cursor Pos
|
||||
LastCursorPos=CursorPos;
|
||||
|
@ -294,9 +298,18 @@ Vec &ThisCam=GetCam();
|
|||
|
||||
Ofs.x*=XS;
|
||||
Ofs.y*=YS;
|
||||
|
||||
/* if (nFlags & MK_CONTROL)
|
||||
{ // Move Ofs
|
||||
Vec &CamOfs=GetCamOfs();
|
||||
Ofs.y=-Ofs.y;
|
||||
CamOfs+=Ofs;
|
||||
UpdateView(View);
|
||||
}
|
||||
else
|
||||
*/ {
|
||||
UpdateView(View,Ofs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // Mouse still moved, so need to redraw windows, to get CursorPos (And pos render)
|
||||
View->Invalidate();
|
||||
|
@ -349,23 +362,21 @@ int ListSize=Layer.size();
|
|||
for (int i=0; i<ListSize; i++)
|
||||
{
|
||||
List->ListBox.AddString(Layer[i]->GetName());
|
||||
// List->ListBox.SetCheck(i,Layer[i]->IsVisible());
|
||||
}
|
||||
// Now sets checks (silly MSoft bug!!)
|
||||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
List->ListBox.SetCheck(i,Layer[i]->IsVisible());
|
||||
}
|
||||
|
||||
List->ListBox.SetCurSel(ActiveLayer);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
void CCore::SetActiveLayer(int i)
|
||||
void CCore::SetLayer(int Layer)
|
||||
{
|
||||
// UpdateParamBar(NULL,ParamViewFlag);
|
||||
ActiveLayer=Layer;
|
||||
}
|
||||
*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Grid ********************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -467,6 +478,16 @@ Vec &CCore::GetCam()
|
|||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
Vec &CCore::GetCamOfs()
|
||||
{
|
||||
if (TileViewFlag)
|
||||
return(TileCamOfs);
|
||||
else
|
||||
return(MapCamOfs);
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::UpdateGUI(CMapEditView *View)
|
||||
{
|
||||
|
@ -517,20 +538,40 @@ void CCore::Toggle2d3d(CMapEditView *View)
|
|||
{
|
||||
Is3dFlag=!Is3dFlag;
|
||||
UpdateView(View);
|
||||
|
||||
Export();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::Export()
|
||||
|
||||
Vec CCore::OffsetCam(Vec &Cam,float DivVal)
|
||||
{
|
||||
Vec ThisCam;
|
||||
|
||||
ThisCam=Cam/DivVal;
|
||||
ThisCam.z=Cam.z;
|
||||
ThisCam+=GetCamOfs();
|
||||
|
||||
return(ThisCam);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::ExportAGB(char *Filename)
|
||||
{
|
||||
int LayerCount=Layer.size();
|
||||
CExportAGB Exp("c:/temp/test.c");
|
||||
char ExportName[256];
|
||||
|
||||
SetFileExt(Filename,ExportName,"C");
|
||||
|
||||
CExportAGB Exp(ExportName);
|
||||
|
||||
for (int i=0;i<LayerCount;i++)
|
||||
{
|
||||
Layer[i]->Export(Exp);
|
||||
}
|
||||
Exp.ExportAll(this);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CCore::ExportPSX(char *Filename)
|
||||
{
|
||||
|
||||
}
|
|
@ -39,7 +39,8 @@ public:
|
|||
void Render(CMapEditView *View,BOOL ForceRender=FALSE);
|
||||
void RenderLayers(CMapEditView *View);
|
||||
void RenderTileView(CMapEditView *View);
|
||||
void Export();
|
||||
void ExportAGB(char *Filename);
|
||||
void ExportPSX(char *Filename);
|
||||
|
||||
|
||||
// Control
|
||||
|
@ -66,6 +67,7 @@ public:
|
|||
void UpdateParamBar();
|
||||
|
||||
// Layers
|
||||
void SetLayer(int Layer);
|
||||
void UpdateLayerGUI(CMapEditView *View);
|
||||
// void SetActiveLayer(int Layer);
|
||||
// int GetActiveLayer() {return(ActiveLayer);}
|
||||
|
@ -84,6 +86,8 @@ public:
|
|||
void UpdateView(CMapEditView *View,Vec Ofs=Vec(0,0,0));
|
||||
|
||||
Vec &GetCam();
|
||||
Vec &GetCamOfs();
|
||||
Vec OffsetCam(Vec &Cam,float DivVal);
|
||||
void SetCursorPos(CPoint &Pos) {CursorPos=Pos;}
|
||||
CPoint &GetCursorPos() {return(CursorPos);}
|
||||
|
||||
|
@ -98,6 +102,7 @@ private:
|
|||
CPoint CurrentMousePos,LastMousePos;
|
||||
CPoint CursorPos,LastCursorPos;
|
||||
Vec MapCam,TileCam;
|
||||
Vec MapCamOfs,TileCamOfs;
|
||||
|
||||
std::vector<CLayer*> Layer;
|
||||
int ActiveLayer;
|
||||
|
@ -106,6 +111,7 @@ private:
|
|||
|
||||
CTexCache TexCache;
|
||||
|
||||
|
||||
BOOL TileViewFlag;
|
||||
BOOL GridFlag;
|
||||
BOOL Is3dFlag;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
/*****************************************************************************/
|
||||
CExport::CExport(char *Filename)
|
||||
{
|
||||
_splitpath(Filename,0,0,Name,0);
|
||||
_splitpath(Filename,Drive,Path,Name,Ext);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -30,28 +30,42 @@ CExport::~CExport()
|
|||
void CExport::ExportAll(CCore *Core)
|
||||
{
|
||||
ExportTiles(Core);
|
||||
|
||||
}
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
void CExport::ExportTileMap(char *LayerName,CMap &Map)
|
||||
{
|
||||
int Width=Map.GetWidth();
|
||||
int Height=Map.GetHeight();
|
||||
|
||||
ExportTileMapStart(LayerName,Width,Height);
|
||||
for (int Y=0; Y<Height; Y++)
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
void CExport::ExportLayerTile(char *LayerName,CMap &Map)
|
||||
{
|
||||
for (int X=0; X<Width; X++)
|
||||
int MapWidth=Map.GetWidth();
|
||||
int MapHeight=Map.GetHeight();
|
||||
int MinWidth=GetMinLayerTileWidth();
|
||||
int MinHeight=GetMinLayerTileHeight();
|
||||
|
||||
int ExpWidth=max(MapWidth,MinWidth);
|
||||
int ExpHeight=max(MapHeight,MinHeight);
|
||||
|
||||
sMapElem BlankElem={0,0,0};
|
||||
|
||||
ExportLayerTileStart(LayerName,ExpWidth,ExpHeight);
|
||||
for (int Y=0; Y<ExpHeight; Y++)
|
||||
{
|
||||
for (int X=0; X<ExpWidth; X++)
|
||||
{
|
||||
if (X<MapWidth && Y<MapHeight)
|
||||
{
|
||||
sMapElem &ThisElem=Map.Get(X,Y);
|
||||
int Idx=AddTileToList(ThisElem);
|
||||
ExportTileMap(ThisElem,Idx);
|
||||
ExportLayerTile(ThisElem,Idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExportLayerTile(BlankElem,0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
ExportTileMapEnd(LayerName);
|
||||
ExportLayerTileEnd(LayerName);
|
||||
|
||||
}
|
||||
|
||||
|
@ -113,7 +127,7 @@ int ListSize=UsedTileList.size(),i;
|
|||
ParseTile(ThisTile);
|
||||
}
|
||||
CreateTilePalette();
|
||||
ExportTileStart();
|
||||
ExportTileStart(ListSize);
|
||||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
sMapElem &ThisElem=UsedTileList[i];
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
CExport(char *Filename);
|
||||
~CExport();
|
||||
|
||||
void ExportTileMap(char *LayerName,CMap &Map);
|
||||
void ExportLayerTile(char *LayerName,CMap &Map);
|
||||
void ExportAll(CCore *Core);
|
||||
|
||||
void PrintTileList();
|
||||
|
@ -36,11 +36,13 @@ protected:
|
|||
void ExportTiles(CCore *Core);
|
||||
void ExportPalette(CCore *Core);
|
||||
|
||||
virtual void ExportTileMapStart(char *LayerName,int Width,int Height)=0;
|
||||
virtual void ExportTileMap(sMapElem &Elem,int NewIdx)=0;
|
||||
virtual void ExportTileMapEnd(char *LayerName)=0;
|
||||
virtual void ExportLayerTileStart(char *LayerName,int Width,int Height)=0;
|
||||
virtual void ExportLayerTile(sMapElem &Elem,int NewIdx)=0;
|
||||
virtual void ExportLayerTileEnd(char *LayerName)=0;
|
||||
virtual int GetMinLayerTileWidth()=0;
|
||||
virtual int GetMinLayerTileHeight()=0;
|
||||
|
||||
virtual void ExportTileStart()=0;
|
||||
virtual void ExportTileStart(int TileCount)=0;
|
||||
virtual void ParseTile(CTile &ThisTile)=0;
|
||||
virtual void CreateTilePalette()=0;
|
||||
virtual void ExportTile(CTile &ThisTile)=0;
|
||||
|
@ -51,7 +53,7 @@ virtual void ExportPalette()=0;
|
|||
virtual void ExportPaletteEnd()=0;
|
||||
|
||||
|
||||
char Name[256];
|
||||
char Drive[_MAX_DRIVE],Path[_MAX_DIR],Name[_MAX_FNAME],Ext[_MAX_EXT];
|
||||
FILE *File;
|
||||
int Count;
|
||||
std::vector<sMapElem> UsedTileList;
|
||||
|
|
|
@ -43,7 +43,7 @@ virtual int GetType()=0;
|
|||
virtual float GetLayerZPosDiv() {return(ZPosDiv);}
|
||||
|
||||
virtual void Render(CCore *Core,Vec &CamPos,BOOL Is3d)=0;
|
||||
virtual void RenderGrid(CCore *Core,Vec &CamPos)=0;
|
||||
virtual void RenderGrid(CCore *Core,Vec &CamPos,BOOL Active)=0;
|
||||
|
||||
virtual void FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos)=0;
|
||||
virtual void RenderCursor(CCore *Core,Vec &CamPos,BOOL Is3d)=0;
|
||||
|
|
|
@ -63,6 +63,13 @@ void CLayerTile::Load(CFile *File,float Version)
|
|||
File->Read(&VisibleFlag,sizeof(BOOL));
|
||||
File->Read(&Mode,sizeof(MouseMode));
|
||||
Map.Load(File,Version);
|
||||
|
||||
TRACE1("%s ",Name);
|
||||
TRACE1("Div:%g ",ZPosDiv);
|
||||
TRACE1("Size:%g ",MapSizeDiv);
|
||||
TRACE1("%i\n",VisibleFlag);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -93,8 +100,7 @@ void CLayerTile::Resize(int Width,int Height)
|
|||
/*****************************************************************************/
|
||||
void CLayerTile::Render(CCore *Core,Vec &CamPos,BOOL Is3d)
|
||||
{
|
||||
float XYDiv=GetLayerZPosDiv();
|
||||
Vec ThisCam=CamPos/XYDiv;
|
||||
Vec ThisCam=Core->OffsetCam(CamPos,GetLayerZPosDiv());
|
||||
|
||||
if (Is3d && Render3dFlag)
|
||||
{
|
||||
|
@ -112,7 +118,8 @@ Vec ThisCam=CamPos/XYDiv;
|
|||
void CLayerTile::RenderCursorPaint(CCore *Core,Vec &CamPos,BOOL Is3d)
|
||||
{
|
||||
CTileBank &TileBank=Core->GetTileBank();
|
||||
Vec ThisCam=CamPos;
|
||||
//Vec ThisCam=CamPos;
|
||||
Vec ThisCam=Core->OffsetCam(CamPos,GetLayerZPosDiv());
|
||||
CPoint &CursPos=Core->GetCursorPos();
|
||||
CMap &Brush=TileBank.GetActiveBrush();
|
||||
|
||||
|
@ -142,8 +149,6 @@ int Height=ThisMap.GetHeight();
|
|||
|
||||
if (Alpha<1)
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Alpha Blend Style
|
||||
glColor4f(0.5,0.5,0.5,Alpha);
|
||||
}
|
||||
else
|
||||
|
@ -168,30 +173,30 @@ int Height=ThisMap.GetHeight();
|
|||
}
|
||||
}
|
||||
}
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayerTile::RenderGrid(CCore *Core,Vec &CamPos)
|
||||
void CLayerTile::RenderGrid(CCore *Core,Vec &CamPos,BOOL Active)
|
||||
{
|
||||
float XYDiv=GetLayerZPosDiv();
|
||||
int Width=Map.GetWidth();
|
||||
int Height=Map.GetHeight();
|
||||
float StartX=CamPos.x/XYDiv;
|
||||
float StartY=CamPos.y/XYDiv;
|
||||
Vec ThisCam=Core->OffsetCam(CamPos,GetLayerZPosDiv());
|
||||
float OverVal=0.5;
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(StartX,StartY,CamPos.z);
|
||||
glTranslatef(ThisCam.x,ThisCam.y,ThisCam.z);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
#ifdef UseLighting
|
||||
glNormal3f( 1,1,1);
|
||||
#endif
|
||||
if (Active)
|
||||
glColor3ub(255,255,255);
|
||||
else
|
||||
glColor3ub(127,127,127);
|
||||
|
||||
for (int YLoop=0; YLoop<Height+1; YLoop++)
|
||||
{
|
||||
|
@ -218,11 +223,9 @@ int HitCount;
|
|||
int TileID=0;
|
||||
CPoint &CursorPos=Core->GetCursorPos();
|
||||
|
||||
float XYDiv=GetLayerZPosDiv();
|
||||
int Width=Map.GetWidth();
|
||||
int Height=Map.GetHeight();
|
||||
float StartX=CamPos.x/XYDiv;
|
||||
float StartY=CamPos.y/XYDiv;
|
||||
Vec ThisCam=Core->OffsetCam(CamPos,GetLayerZPosDiv());
|
||||
|
||||
|
||||
glGetIntegerv(GL_VIEWPORT, Viewport);
|
||||
|
@ -240,7 +243,7 @@ float StartY=CamPos.y/XYDiv;
|
|||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(StartX,StartY,CamPos.z);
|
||||
glTranslatef(ThisCam.x,ThisCam.y,ThisCam.z);
|
||||
|
||||
for (int YLoop=0; YLoop<Height; YLoop++)
|
||||
{
|
||||
|
@ -483,12 +486,10 @@ BOOL CLayerTile::Paint(CMap &Blk,CPoint &CursorPos)
|
|||
Map.Set(CursorPos.x,CursorPos.y,Blk);
|
||||
|
||||
return(TRUE);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayerTile::Export(CExport &Exp)
|
||||
{
|
||||
Exp.ExportTileMap(Name,Map);
|
||||
Exp.ExportLayerTile(Name,Map);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
int GetType() {return(LAYER_TYPE_TILE);}
|
||||
|
||||
void Render(CCore *Core,Vec &CamPos,BOOL Is3d);
|
||||
void RenderGrid(CCore *Core,Vec &CamPos);
|
||||
void RenderGrid(CCore *Core,Vec &CamPos,BOOL Active);
|
||||
|
||||
void FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos);
|
||||
void RenderCursor(CCore *Core,Vec &CamPos,BOOL Is3d);
|
||||
|
|
|
@ -18,21 +18,21 @@ Class6=CMapEditDoc
|
|||
Class7=CMapEditView
|
||||
|
||||
ResourceCount=10
|
||||
Resource1=IDD_ABOUTBOX (English (U.S.))
|
||||
Resource1=IDR_MAINFRAME (English (U.S.))
|
||||
Resource2=IDD_MULTIBAR (English (U.S.))
|
||||
Resource3=IDD_GFXTOOLBAR
|
||||
Resource4=IDD_DIALOGBAR (English (U.S.))
|
||||
Resource5=IDR_MAPEDITYPE (English (U.S.))
|
||||
Resource5=IDD_LAYER_LIST_DIALOG
|
||||
Class8=CMultiBar
|
||||
Resource6=IDD_MAPSIZE
|
||||
Resource7=IDD_TILESET_DIALOG
|
||||
Resource6=IDD_ABOUTBOX (English (U.S.))
|
||||
Resource7=IDR_MAPEDITYPE (English (U.S.))
|
||||
Class9=CLayerList
|
||||
Class10=CTileSetDlg
|
||||
Resource8=IDR_MAINFRAME (English (U.S.))
|
||||
Resource8=IDD_TILESET_DIALOG
|
||||
Class11=CGfxToolBar
|
||||
Resource9=IDD_LAYER_LIST_DIALOG
|
||||
Resource9=IDR_TOOLBAR (English (U.S.))
|
||||
Class12=CMapSizeDlg
|
||||
Resource10=IDR_TOOLBAR (English (U.S.))
|
||||
Resource10=IDD_MAPSIZE
|
||||
|
||||
[CLS:CChildFrame]
|
||||
Type=0
|
||||
|
@ -72,7 +72,9 @@ Type=0
|
|||
BaseClass=CDocument
|
||||
HeaderFile=MapEditDoc.h
|
||||
ImplementationFile=MapEditDoc.cpp
|
||||
LastObject=ID_MIRRORX
|
||||
LastObject=CMapEditDoc
|
||||
Filter=N
|
||||
VirtualFilter=DC
|
||||
|
||||
[CLS:CMapEditView]
|
||||
Type=0
|
||||
|
@ -120,28 +122,30 @@ Command2=ID_FILE_OPEN
|
|||
Command3=ID_FILE_CLOSE
|
||||
Command4=ID_FILE_SAVE
|
||||
Command5=ID_FILE_SAVE_AS
|
||||
Command6=ID_FILE_MRU_FILE1
|
||||
Command7=ID_APP_EXIT
|
||||
Command8=ID_EDIT_UNDO
|
||||
Command9=ID_EDIT_CUT
|
||||
Command10=ID_EDIT_COPY
|
||||
Command11=ID_EDIT_PASTE
|
||||
Command12=ID_VIEW_TOOLBAR
|
||||
Command13=ID_VIEW_STATUS_BAR
|
||||
Command14=ID_MAP_SETSIZE
|
||||
Command15=ID_TOGGLE_GRID
|
||||
Command16=ID_MIRRORX
|
||||
Command17=ID_MIRRORY
|
||||
Command18=ID_ACTIVEBRUSH_LEFT
|
||||
Command19=ID_ACTIVEBRUSH_RIGHT
|
||||
Command20=ID_TOGGLE_TILEVIEW
|
||||
Command21=ID_2D_3D_TOGGLE
|
||||
Command22=ID_WINDOW_NEW
|
||||
Command23=ID_WINDOW_CASCADE
|
||||
Command24=ID_WINDOW_TILE_HORZ
|
||||
Command25=ID_WINDOW_ARRANGE
|
||||
Command26=ID_APP_ABOUT
|
||||
CommandCount=26
|
||||
Command6=ID_EXPORT_AGB
|
||||
Command7=ID_EXPORT_PSX
|
||||
Command8=ID_FILE_MRU_FILE1
|
||||
Command9=ID_APP_EXIT
|
||||
Command10=ID_EDIT_UNDO
|
||||
Command11=ID_EDIT_CUT
|
||||
Command12=ID_EDIT_COPY
|
||||
Command13=ID_EDIT_PASTE
|
||||
Command14=ID_VIEW_TOOLBAR
|
||||
Command15=ID_VIEW_STATUS_BAR
|
||||
Command16=ID_MAP_SETSIZE
|
||||
Command17=ID_TOGGLE_GRID
|
||||
Command18=ID_MIRRORX
|
||||
Command19=ID_MIRRORY
|
||||
Command20=ID_ACTIVEBRUSH_LEFT
|
||||
Command21=ID_ACTIVEBRUSH_RIGHT
|
||||
Command22=ID_TOGGLE_TILEVIEW
|
||||
Command23=ID_2D_3D_TOGGLE
|
||||
Command24=ID_WINDOW_NEW
|
||||
Command25=ID_WINDOW_CASCADE
|
||||
Command26=ID_WINDOW_TILE_HORZ
|
||||
Command27=ID_WINDOW_ARRANGE
|
||||
Command28=ID_APP_ABOUT
|
||||
CommandCount=28
|
||||
|
||||
[ACL:IDR_MAINFRAME (English (U.S.))]
|
||||
Type=1
|
||||
|
@ -202,7 +206,7 @@ ControlCount=0
|
|||
Type=1
|
||||
Class=CLayerList
|
||||
ControlCount=1
|
||||
Control1=IDC_LAYER_LIST,listbox,1352728915
|
||||
Control1=IDC_LAYER_LIST,listbox,1352728913
|
||||
|
||||
[CLS:CLayerList]
|
||||
Type=0
|
||||
|
|
|
@ -136,27 +136,6 @@ SOURCE=.\Quantize.cpp
|
|||
# Begin Source File
|
||||
|
||||
SOURCE=.\Quantize.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "TestLevels"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\agbtypes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\temp\test.c
|
||||
|
||||
!IF "$(CFG)" == "MapEdit - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "MapEdit - Win32 Debug"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
|
|
@ -95,6 +95,9 @@ BEGIN
|
|||
MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE
|
||||
MENUITEM "Save &As...", ID_FILE_SAVE_AS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Export AGB", ID_EXPORT_AGB
|
||||
MENUITEM "Export PSX", ID_EXPORT_PSX
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_APP_EXIT
|
||||
|
@ -454,7 +457,7 @@ IDD_LAYER_LIST_DIALOG DIALOG DISCARDABLE 0, 0, 155, 94
|
|||
STYLE WS_CHILD | WS_BORDER
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LISTBOX IDC_LAYER_LIST,5,5,145,85,LBS_SORT | LBS_OWNERDRAWFIXED |
|
||||
LISTBOX IDC_LAYER_LIST,5,5,145,85,LBS_OWNERDRAWFIXED |
|
||||
LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
|
||||
WS_TABSTOP
|
||||
END
|
||||
|
|
|
@ -21,6 +21,8 @@ IMPLEMENT_DYNCREATE(CMapEditDoc, CDocument)
|
|||
BEGIN_MESSAGE_MAP(CMapEditDoc, CDocument)
|
||||
//{{AFX_MSG_MAP(CMapEditDoc)
|
||||
ON_UPDATE_COMMAND_UI(ID_INDICATOR_CURSORXY, OnStatusCursorXY)
|
||||
ON_COMMAND(ID_EXPORT_AGB, OnExportAgb)
|
||||
ON_COMMAND(ID_EXPORT_PSX, OnExportPsx)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
@ -186,6 +188,36 @@ void CMapEditDoc::SetMode(int NewMode)
|
|||
theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o)
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
void CMapEditDoc::SetLayer(int Layer)
|
||||
{
|
||||
Core.SetLayer(Layer);
|
||||
theApp.GetMainWnd()->SetFocus(); // Put control back to Window :o)
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
/*********************************************************************************/
|
||||
/*********************************************************************************/
|
||||
void CMapEditDoc::OnExportAgb()
|
||||
{
|
||||
char BASED_CODE AGBFilter[]= "AGB Data Type (*.c)|*.c|All Files (*.*)|*.*||";
|
||||
CFileDialog Dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,AGBFilter);
|
||||
|
||||
if (Dlg.DoModal()!=IDOK) return;
|
||||
|
||||
char Filename[256];
|
||||
sprintf(Filename,"%s",Dlg.GetPathName());
|
||||
|
||||
|
||||
Core.ExportAGB(Filename);
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
void CMapEditDoc::OnExportPsx()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*********************************************************************************/
|
||||
/*** Tilebank Functions **********************************************************/
|
||||
/*********************************************************************************/
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
void TileBankSet();
|
||||
|
||||
void SetMode(int NewMode);
|
||||
void SetLayer(int Layer);
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
@ -71,6 +72,8 @@ protected:
|
|||
protected:
|
||||
//{{AFX_MSG(CMapEditDoc)
|
||||
afx_msg void OnStatusCursorXY(CCmdUI *pCmdUI);
|
||||
afx_msg void OnExportAgb();
|
||||
afx_msg void OnExportPsx();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
|
|
|
@ -82,9 +82,8 @@ void CMapEditView::OnCreateGL()
|
|||
glEnable(GL_COLOR_MATERIAL); // Enable Material Coloring
|
||||
#endif
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
|
||||
// glDisable(GL_BLEND); // Enable Alpha Channel
|
||||
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Alpha Blend Style
|
||||
|
||||
glEnable(GL_BLEND); // Enable Alpha Channel
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Alpha Blend Style
|
||||
}
|
||||
|
||||
|
||||
|
@ -99,6 +98,7 @@ void CMapEditView::OnDrawGL()
|
|||
void CMapEditView::OnSizeGL(int cx, int cy)
|
||||
{
|
||||
glViewport(0,0,cx,cy);
|
||||
|
||||
// update the camera
|
||||
glPushMatrix();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
|
@ -114,6 +114,20 @@ void CMapEditView::SetupPersMatrix()
|
|||
{
|
||||
gluPerspective(40.0,m_dAspectRatio,0.1f, 100.0f);
|
||||
glTranslatef(0.0f,0.0f,-4.f);
|
||||
|
||||
// GLint viewport[4];
|
||||
|
||||
// glGetIntegerv( GL_VIEWPORT, viewport );
|
||||
// glMatrixMode( GL_PROJECTION );
|
||||
// glLoadIdentity();
|
||||
// glOrtho( 0.0f, viewport[2]-viewport[0],viewport[3]-viewport[1], 0.0f, 0.1f, 100.0f);
|
||||
// glOrtho( 0.0f, +30,+20, 0, 0.1f, 100.0f);
|
||||
// glTranslatef(0.0f,0.0f,-0.f);
|
||||
|
||||
// glMatrixMode( GL_MODELVIEW );
|
||||
// glLoadIdentity();
|
||||
// glTranslatef( 0.375, 0.375, 0.0 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -107,13 +107,39 @@ void CTexCache::FreeBMP(sRGBData &RGBData)
|
|||
/**************************************************************************************/
|
||||
void CTexCache::LoadTex(sTex &ThisTex,sRGBData *TexData)
|
||||
{
|
||||
ThisTex.Width=TexData->Width;
|
||||
ThisTex.Height=TexData->Height;
|
||||
std::vector<u8> Buffer;
|
||||
int Width=TexData->Width;
|
||||
int Height=TexData->Height;
|
||||
int Size=Width*Height;
|
||||
// create RGB & alpha texture
|
||||
Buffer.resize(Size*4);
|
||||
u8 *RgbPtr=TexData->RGB;
|
||||
|
||||
for (int i=0;i<Size;i++)
|
||||
{
|
||||
u8 R=*RgbPtr++;
|
||||
u8 G=*RgbPtr++;
|
||||
u8 B=*RgbPtr++;
|
||||
u8 A=255;
|
||||
if ((R==BlankRGB.rgbRed && G==BlankRGB.rgbGreen && B==BlankRGB.rgbBlue)) // Create alpha for transparent pixels (flagged with PINK!!)
|
||||
{
|
||||
A=0;
|
||||
}
|
||||
|
||||
Buffer[(i*4)+0]=R;
|
||||
Buffer[(i*4)+1]=G;
|
||||
Buffer[(i*4)+2]=B;
|
||||
Buffer[(i*4)+3]=A;
|
||||
}
|
||||
|
||||
|
||||
ThisTex.Width=Width;
|
||||
ThisTex.Height=Height;
|
||||
|
||||
glGenTextures(1, &ThisTex.TexID);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, ThisTex.TexID);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, TexData->Width, TexData->Height, 0, GL_RGB, GL_UNSIGNED_BYTE, TexData->RGB);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 4, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &Buffer[0]);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
|
|
@ -29,6 +29,8 @@ struct sTex
|
|||
int Width,Height;
|
||||
};
|
||||
|
||||
const RGBQUAD BlankRGB={255,0,255};
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -322,12 +322,67 @@ void CTileSet::Load(CCore *Core)
|
|||
/*****************************************************************************/
|
||||
void CTileSet::Load2d(CCore *Core)
|
||||
{
|
||||
char Filename[_MAX_PATH];
|
||||
CTexCache &TexCache=Core->GetTexCache();
|
||||
sRGBData ThisBmp;
|
||||
sRGBData NewTex;
|
||||
|
||||
// _makepath( Filename, Drive, Path, Name, Ext);
|
||||
_makepath( Filename, Drive, Path, Name, Ext);
|
||||
TexCache.LoadBMP(Filename,ThisBmp);
|
||||
|
||||
Tile.push_back(CTile()); // Insert Blank
|
||||
int Width=ThisBmp.Width/16;
|
||||
int Height=ThisBmp.Height/16;
|
||||
u8 Buffer[16*16*3];
|
||||
|
||||
Tile.push_back(CTile(Core,this,0,0));
|
||||
|
||||
NewTex.Width=16;
|
||||
NewTex.Height=16;
|
||||
NewTex.RGB=Buffer;
|
||||
|
||||
TRACE2("Load 2d TileBank (%i,%i)\n",Width,Height);
|
||||
Tile.push_back(CTile(0)); // Insert Blank
|
||||
|
||||
for (int Y=0; Y<Height; Y++)
|
||||
{
|
||||
for (int X=0; X<Width; X++)
|
||||
{
|
||||
BOOL Data=Create16x16Tile(ThisBmp,Buffer,X,(Height-1)-Y);
|
||||
if (Data)
|
||||
{ // Not Blank
|
||||
char Name[256];
|
||||
sprintf(Name,"_2d_%s%i",GetName(),X+(Y*Width));
|
||||
int TexID=TexCache.ProcessTexture(Name,GetPath(),0,&NewTex);
|
||||
Tile.push_back(CTile(Core,this,TexID));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
TexCache.FreeBMP(ThisBmp);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
BOOL CTileSet::Create16x16Tile(sRGBData &Src,u8 *Dst,int XOfs,int YOfs)
|
||||
{
|
||||
BOOL Data=FALSE;
|
||||
|
||||
for (int Y=0; Y<16; Y++)
|
||||
{
|
||||
for (int X=0; X<16; X++)
|
||||
{
|
||||
u8 *SrcPtr=(u8*)&Src.RGB[((((YOfs*16)+Y)*Src.Width)+(X+(XOfs*16)))*3];
|
||||
u8 R=SrcPtr[0];
|
||||
u8 G=SrcPtr[1];
|
||||
u8 B=SrcPtr[2];
|
||||
|
||||
if (R!=BlankRGB.rgbRed || G!=BlankRGB.rgbGreen || B!=BlankRGB.rgbBlue) Data=TRUE;
|
||||
|
||||
*Dst++=R;
|
||||
*Dst++=G;
|
||||
*Dst++=B;
|
||||
}
|
||||
}
|
||||
return(Data);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -342,7 +397,7 @@ CScene Scene;
|
|||
CNode &ThisNode=Scene.GetSceneNode(0);
|
||||
int ChildCount=ThisNode.GetPruneChildCount();
|
||||
|
||||
Tile.push_back(CTile()); // Insert Blank
|
||||
Tile.push_back(CTile(0)); // Insert Blank
|
||||
for (int Child=0; Child<ChildCount; Child++)
|
||||
{
|
||||
Tile.push_back(CTile(Core,this,Scene,ThisNode.PruneChildList[Child]));
|
||||
|
@ -394,8 +449,6 @@ int SelFlag;
|
|||
|
||||
if (SelFlag)
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBegin(GL_QUADS);
|
||||
#ifdef UseLighting
|
||||
glNormal3f( 1,1,1);
|
||||
|
@ -419,8 +472,6 @@ int SelFlag;
|
|||
}
|
||||
|
||||
glEnd();
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
}
|
||||
|
||||
TileID++;
|
||||
|
@ -453,9 +504,6 @@ int MaxTile=Tile.size();
|
|||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
||||
for (int Y=Start.y; Y<=End.y; Y++)
|
||||
{
|
||||
|
@ -476,8 +524,6 @@ int MaxTile=Tile.size();
|
|||
}
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -111,6 +111,7 @@ public:
|
|||
void RenderGrid(Vec &CamPos);
|
||||
|
||||
private:
|
||||
BOOL Create16x16Tile(sRGBData &Src,u8 *Dst,int XOfs,int YOfs);
|
||||
|
||||
char Drive[_MAX_DRIVE],Path[_MAX_DIR],Name[_MAX_FNAME],Ext[_MAX_EXT];
|
||||
int SetNumber;
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
#define ID_ACTIVEBRUSH_RIGHT 32791
|
||||
#define ID_MAP_SETSIZE 32792
|
||||
#define ID_2D_3D_TOGGLE 32794
|
||||
#define ID_EXPORT_AGB 32795
|
||||
#define ID_EXPORT_PSX 32796
|
||||
#define ID_INDICATOR_CURSORXY 59142
|
||||
|
||||
// Next default values for new objects
|
||||
|
@ -52,7 +54,7 @@
|
|||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_3D_CONTROLS 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 168
|
||||
#define _APS_NEXT_COMMAND_VALUE 32795
|
||||
#define _APS_NEXT_COMMAND_VALUE 32797
|
||||
#define _APS_NEXT_CONTROL_VALUE 1042
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
|
|
|
@ -298,18 +298,18 @@ int PaletteSize,ImageSize;
|
|||
if (Pal) fwrite(Pal,sizeof(RGBQUAD),256,File);
|
||||
|
||||
fwrite(Image,ImageSize,1,File);
|
||||
/*
|
||||
for (int Y=0;Y<Height;Y++)
|
||||
{
|
||||
for (int X=0;X<Width;X++)
|
||||
{
|
||||
TRACE1("%02d ",*Image++);
|
||||
|
||||
}
|
||||
TRACE0("\n");
|
||||
}
|
||||
*/
|
||||
fclose(File);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**************************************************************************************/
|
||||
void SetFileExt(char *InName,char *OutName,char *Ext)
|
||||
{
|
||||
char Drive[_MAX_DRIVE];
|
||||
char Path[_MAX_DIR];
|
||||
char Name[_MAX_FNAME];
|
||||
|
||||
_splitpath(InName,Drive,Path,Name,0);
|
||||
sprintf(OutName,"%s%s%s.%s",Drive,Path,Name,Ext);
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ void SaveBmp(char *Filename,int Width,int Height,RGBQUAD *Pal,u8 *Image);
|
|||
|
||||
void BGR2RGB(int W,int H,u8 *Data);
|
||||
|
||||
void SetFileExt(char *InName,char *OutName,char *Ext);
|
||||
|
||||
|
||||
|
||||
/**************************************************************************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue