This commit is contained in:
Daveo 2000-11-15 21:22:40 +00:00
parent acd5ab37c0
commit 7ac13dc8b8
17 changed files with 599 additions and 275 deletions

View File

@ -19,7 +19,6 @@
#include "Layer.h"
#include "LayerTile.h"
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
@ -35,11 +34,6 @@ CCore::CCore()
TileCam=Vec(0,0,0);
Is3dFlag=TRUE;
CurrentTileBank=0;
MouseTileL.Bank=0; MouseTileL.Tile=1;
MouseTileR.Bank=0; MouseTileR.Tile=1;
}
/*****************************************************************************/
@ -48,6 +42,20 @@ CCore::~CCore()
for (int i=0; i<LAYER_TYPE_MAX; i++) if (Layers[i]) delete Layers[i];
}
/*****************************************************************************/
void CCore::Init()
{
CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd();
CMultiBar *ParamBar=Frm->GetParamBar();
ParamBar->RemoveAll();
// Add default parram bar items
ParamBar->Add(Frm->GetLayerList(),IDD_LAYER_LIST_DIALOG,TRUE,TRUE);
ParamBar->Add(Frm->GetTileSetDlg(),IDD_TILESET_DIALOG,TRUE,TRUE);
Layers[ActiveLayer]->InitGUI(this);
ParamBar->Update();
}
/*****************************************************************************/
void CCore::NewMap()
{
@ -60,12 +68,10 @@ void CCore::NewMap()
ActiveLayer=LAYER_TYPE_ACTION;
MapCam=Vec(0,0,0);
TileCam=Vec(0,0,0);
TileBank.AddTileSet("c:/temp/3/test.gin");
// TileBank.AddTileSet("c:/temp/3/test.gin");
// TileBank.AddTileSet("c:/temp/4/4.gin");
// TileBank.AddTileSet("c:/temp/slope/slope.gin");
// TileBank.AddTileSet("c:/temp/2/2.gin");
// TileBank.AddTileSet("c:/temp/1/1.gin");
TileBank.AddTileSet("c:/temp/4/4.gin");
TileBank.AddTileSet("c:/temp/5/5.gin");
Init();
}
/*****************************************************************************/
@ -105,6 +111,7 @@ Vec &ThisCam=GetCam();
if (GridFlag) Layers[ActiveLayer]->RenderGrid(this,ThisCam);
// Get Cursor Pos
LastCursorPos=CursorPos;
Layers[ActiveLayer]->FindCursorPos(this,View,GetCam(),CurrentMousePos);
}
@ -121,13 +128,31 @@ Vec &ThisCam=GetCam();
/*****************************************************************************/
/*** Control *****************************************************************/
/*****************************************************************************/
void CCore::SetMode(int NewMode)
{
BOOL RedrawFlag=FALSE;
RedrawFlag=Layers[ActiveLayer]->SetMode(NewMode);
//if (RedrawFlag) View->Invalidate();
}
/*****************************************************************************/
void CCore::LButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag)
{
BOOL RedrawFlag=FALSE;
if (TileViewFlag)
TileBank.LButtonControl(this,View,nFlags,point,DownFlag);
{
RedrawFlag=TileBank.TileSelectL();
}
else
;
{
RedrawFlag=Layers[ActiveLayer]->LButtonControl(this,View,nFlags,CursorPos,DownFlag);
}
if (RedrawFlag) View->Invalidate();
}
/*****************************************************************************/
@ -139,11 +164,18 @@ void CCore::MButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL Do
/*****************************************************************************/
void CCore::RButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag)
{
if (TileViewFlag)
TileBank.RButtonControl(this,View,nFlags,point,DownFlag);
else
;
BOOL RedrawFlag=FALSE;
if (TileViewFlag)
{
RedrawFlag=TileBank.TileSelectR();
}
else
{
RedrawFlag=Layers[ActiveLayer]->RButtonControl(this,View,nFlags,CursorPos,DownFlag);
}
if (RedrawFlag) View->Invalidate();
}
/*****************************************************************************/
@ -190,10 +222,12 @@ Vec &ThisCam=GetCam();
else
{ // Mouse still moved, so need to redraw windows, to get CursorPos (And pos render)
View->Invalidate();
Layers[ActiveLayer]->MouseMove(this,View,nFlags,CursorPos);
}
}
/*****************************************************************************/
/*** Layers ******************************************************************/
/*****************************************************************************/
@ -203,29 +237,6 @@ CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd();
CToolBar *ToolBar=Frm->GetToolBar();
CMultiBar *ParamBar=Frm->GetParamBar();
// ParamBar->ReCalc();
//CCheckListBox *Dlg=(CCheckListBox *)ParamBar->GetDlgItem(IDC_PARAMBAR_LAYER_LIST);
/*
ParamViewFlag=ViewFlag;
if (ParamViewFlag)
{
ParamBar->m_ListBox.ResetContent();
// Dlg->ResetContent();
for (int i=0;i<LAYER_TYPE_MAX;i++)
{
CLayer *ThisLayer=GetLayer(i);
ParamBar->m_ListBox.AddString(ThisLayer->GetName());
// Dlg->AddString(ThisLayer->GetName());
}
ParamBar->m_ListBox.SetCurSel(ActiveLayer);
// Dlg->SetCurSel(ActiveLayer);
}
*/
// ToolBar->GetToolBarCtrl().PressButton(ID_TOOLBAR_PARAMBAR,ParamViewFlag);
// Frm->ShowControlBar(ParamBar, ParamViewFlag, FALSE);
// ParamBar->ShowWindow(SW_SHOW);
// if (View) UpdateView(View);
}
/*****************************************************************************/
@ -255,36 +266,36 @@ void CCore::UpdateTileView(CMapEditView *View,BOOL Toggle)
{
CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd();
CToolBar *ToolBar=Frm->GetToolBar();
CMultiBar *ParamBar=Frm->GetParamBar();
if (Toggle)
{
TileViewFlag=!TileViewFlag;
if (TileViewFlag)
TileBank.InitGUI(this);
else
Layers[ActiveLayer]->InitGUI(this);
}
if (Toggle) TileViewFlag=!TileViewFlag;
ParamBar->RemoveAll();
ToolBar->GetToolBarCtrl().PressButton(ID_TOOLBAR_TILEPALETTE,TileViewFlag);
UpdateView(View);
}
/*****************************************************************************/
void CCore::ReloadTileBank()
void CCore::TileBankLoad(char *Filename)
{
TileBank.AddTileSet(Filename);
TileBank.UpdateGUI(this,TileViewFlag);
UpdateView(NULL);
}
/*****************************************************************************/
void CCore::TileBankReload()
{
TileBank.Reload();
TexCache.Purge();
UpdateView(NULL);
}
/*****************************************************************************/
void CCore::ChangeTileBank()
void CCore::TileBankSet()
{
CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd();
CTileSetDlg *TileSetDlg=(CTileSetDlg*)Frm->GetDialog(IDD_TILESET_DIALOG);
CurrentTileBank=TileSetDlg->TileSetList.GetCurSel();
TileBank.SetCurrent(TileSetDlg->TileSetList.GetCurSel());
}
/*****************************************************************************/
@ -305,10 +316,8 @@ void CCore::UpdateAll(CMapEditView *View)
UpdateView(View);
UpdateGrid(View);
if (TileViewFlag)
TileBank.UpdateGUI(this);
else
Layers[ActiveLayer]->UpdateGUI(this);
TileBank.UpdateGUI(this,TileViewFlag);
Layers[ActiveLayer]->UpdateGUI(this);
}

View File

@ -14,7 +14,6 @@
#include "TileSet.h"
/*****************************************************************************/
class CMapEditView;
class CCore
@ -31,6 +30,7 @@ public:
void RenderTileView(CMapEditView *View);
// Control
void SetMode(int NewMode);
void LButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
void MButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
void RButtonControl(CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
@ -40,14 +40,11 @@ public:
// TileBank
void UpdateTileView(CMapEditView *View,BOOL Toggle=FALSE);
CTileBank &GetTileBank() {return(TileBank);}
CTile GetTile(int Bank,int TileNo) {return(TileBank.GetTile(Bank,TileNo));}
void ReloadTileBank();
void ChangeTileBank();
int GetCurrentTileBank() {return(CurrentTileBank);}
void SetCurrentTileBank(int Bnk) {CurrentTileBank=Bnk;}
sMapElem &GetMouseTileL() {return(MouseTileL);}
sMapElem &GetMouseTileR() {return(MouseTileR);}
void TileBankLoad(char *Filename);
void TileBankReload();
void TileBankSet();
// Param Bar
void UpdateParamBar(CMapEditView *View,BOOL ViewFlag);
@ -81,13 +78,13 @@ private:
int ActiveLayer;
CTileBank TileBank;
CTexCache TexCache;
int CurrentTileBank;
sMapElem MouseTileL,MouseTileR;
BOOL TileViewFlag;
BOOL GridFlag;
BOOL Is3dFlag;
};

View File

@ -49,7 +49,16 @@ virtual void FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &
virtual void InitGUI(CCore *Core)=0;
virtual void UpdateGUI(CCore *Core)=0;
// Functions
virtual BOOL SetMode(int NewMode)=0;
virtual BOOL InitMode()=0;
virtual BOOL ExitMode()=0;
virtual BOOL LButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &CursorPos,BOOL DownFlag)=0;
virtual BOOL RButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &CursorPos,BOOL DownFlag)=0;
virtual BOOL MouseMove(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &CursorPos)=0;
protected:
char Name[256];
BOOL Render3dFlag;
float ZPosDiv;

View File

@ -28,9 +28,11 @@
CLayerTile::CLayerTile(char *_Name,int Width,int Height,float ZDiv,BOOL Is3d)
{
SetName(_Name);
Map.SetSize(Width,Height);
Map.SetSize(Width,Height,TRUE);
ZPosDiv=ZDiv;
Render3dFlag=Is3d;
Mode=MouseModePaint;
Flag=MouseFlagNone;
}
/*****************************************************************************/
@ -81,7 +83,7 @@ CTexCache &TexCache=Core->GetTexCache();
for (int XLoop=0; XLoop<MapW; XLoop++)
{
sMapElem &ThisElem=Map.GetTile(XLoop,YLoop);
CTile &ThisTile=Core->GetTile(ThisElem.Bank,ThisElem.Tile);
CTile &ThisTile=Core->GetTile(ThisElem.Set,ThisElem.Tile);
glLoadIdentity(); // Slow way, but good to go for the mo
glTranslatef(StartX+XLoop,StartY-YLoop,CamPos.z);
@ -114,11 +116,14 @@ CTexCache &TexCache=Core->GetTexCache();
for (int XLoop=0; XLoop<MapW; XLoop++)
{
sMapElem &ThisElem=Map.GetTile(XLoop,YLoop);
CTile &ThisTile=Core->GetTile(ThisElem.Bank,ThisElem.Tile);
if (ThisElem.Tile)
{ // Render Non Zero Tiles
CTile &ThisTile=Core->GetTile(ThisElem.Set,ThisElem.Tile);
glLoadIdentity(); // Slow way, but good to go for the mo
glTranslatef(StartX+XLoop,StartY-YLoop,CamPos.z);
ThisTile.Render();
glLoadIdentity(); // Slow way, but good to go for the mo
glTranslatef(StartX+XLoop,StartY-YLoop,CamPos.z);
ThisTile.Render();
}
}
}
@ -232,11 +237,160 @@ void CLayerTile::InitGUI(CCore *Core)
CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd();
CMultiBar *ParamBar=Frm->GetParamBar();
ParamBar->RemoveAll();
ParamBar->Update();
ParamBar->Add(Frm->GetGfxToolBar(),IDD_GFXTOOLBAR,TRUE);
}
/*****************************************************************************/
void CLayerTile::UpdateGUI(CCore *Core)
{
}
}
/*****************************************************************************/
/*** Functions ***************************************************************/
/*****************************************************************************/
BOOL CLayerTile::SetMode(int NewMode)
{
BOOL Ret=FALSE;
// Clean up last mode
Ret|=ExitMode();
Mode=(MouseMode)NewMode;
Ret|=InitMode();
return(Ret);
}
/*****************************************************************************/
BOOL CLayerTile::InitMode()
{
switch(Mode)
{
case MouseModeNone:
break;
case MouseModePaint:
break;
case MouseModeSelect:
break;
case MouseModeBlockSelect:
break;
case MouseModePicker:
break;
default:
break;
}
return(FALSE);
}
/*****************************************************************************/
BOOL CLayerTile::ExitMode()
{
switch(Mode)
{
case MouseModeNone:
break;
case MouseModePaint:
break;
case MouseModeSelect:
break;
case MouseModeBlockSelect:
break;
case MouseModePicker:
break;
default:
break;
}
return(FALSE);
}
/*****************************************************************************/
BOOL CLayerTile::LButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &CursorPos,BOOL DownFlag)
{
BOOL Ret=FALSE;
CTileBank &TileBank=Core->GetTileBank();
switch(Mode)
{
case MouseModeNone:
break;
case MouseModePaint:
if (DownFlag)
Ret=Paint(TileBank.GetLTile(),CursorPos);
break;
case MouseModeSelect:
break;
case MouseModeBlockSelect:
break;
case MouseModePicker:
break;
default:
break;
}
return(Ret);
}
/*****************************************************************************/
BOOL CLayerTile::RButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &CursorPos,BOOL DownFlag)
{
BOOL Ret=FALSE;
CTileBank &TileBank=Core->GetTileBank();
switch(Mode)
{
case MouseModeNone:
break;
case MouseModePaint:
if (DownFlag)
Ret=Paint(TileBank.GetRTile(),CursorPos);
break;
case MouseModeSelect:
break;
case MouseModeBlockSelect:
break;
case MouseModePicker:
break;
default:
break;
}
return(Ret);
}
/*****************************************************************************/
BOOL CLayerTile::MouseMove(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &CursorPos)
{
BOOL Ret=FALSE;
CTileBank &TileBank=Core->GetTileBank();
switch(Mode)
{
case MouseModeNone:
break;
case MouseModePaint:
if (nFlags & MK_LBUTTON)
Ret=Paint(TileBank.GetLTile(),CursorPos);
else
if (nFlags & MK_RBUTTON)
Ret=Paint(TileBank.GetRTile(),CursorPos);
break;
case MouseModeSelect:
break;
case MouseModeBlockSelect:
break;
case MouseModePicker:
break;
default:
break;
}
return(Ret);
}
/*****************************************************************************/
BOOL CLayerTile::Paint(sMapElem &Tile,CPoint &CursorPos)
{
if (CursorPos.y==-1 || CursorPos.y==-1) return(FALSE); // Off Map?
if (Tile.Set==-1 || Tile.Tile==-1) return(FALSE); // Invalid tile?
Map.SetTile(CursorPos.x,CursorPos.y,Tile);
return(TRUE);
}

View File

@ -7,11 +7,13 @@
#include "Layer.h"
/*****************************************************************************/
/*****************************************************************************/
enum TileLayerEnum
{
TileLayerDefaultWidth=20,
TileLayerDefaultHeight=12,
TileLayerDefaultWidth=30,
TileLayerDefaultHeight=20,
};
/*****************************************************************************/
@ -21,6 +23,23 @@ class CLayerTile : public CLayer
{
public:
enum MouseMode
{
MouseModeNone=0,
MouseModePaint,
MouseModeSelect,
MouseModeBlockSelect,
MouseModePicker,
MouseModeMirrorX,
MouseModeMirrorY,
};
enum MouseFlag
{
MouseFlagNone=1<<0,
MouseFlagMirrorX=1<<1,
MouseFlagMirrorY=1<<2,
};
CLayerTile(char *_Name,int Width,int Height,float ZDiv,BOOL Is3d); // New Layer
CLayerTile(char *_Name); // Load Layer
~CLayerTile();
@ -32,12 +51,24 @@ public:
void InitGUI(CCore *Core);
void UpdateGUI(CCore *Core);
// Functions
BOOL SetMode(int NewMode);
BOOL InitMode();
BOOL ExitMode();
BOOL LButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
BOOL RButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
BOOL MouseMove(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &point);
protected:
void Render2d(CCore *Core,Vec &CamPos);
void Render3d(CCore *Core,Vec &CamPos);
BOOL Paint(sMapElem &Blk,CPoint &CursorPos);
CMap Map;
MouseMode Mode;
BOOL Flag;
};

View File

@ -67,9 +67,6 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
ParamBar.SetWindowText("Param");
DockControlBar(&ParamBar);
ParamBar.Add(LayerList,IDD_LAYER_LIST_DIALOG,TRUE,TRUE); // Add default parram bar item
// ToolBar (plus extra code for extra controls!!)
if (!ToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !ToolBar.LoadToolBar(IDR_MAINFRAME))
{

View File

@ -8,6 +8,7 @@
#include "MultiBar.h"
#include "LayerList.h"
#include "TileSetDlg.h"
#include "GfxToolBar.h"
#if _MSC_VER > 1000
#pragma once
@ -39,7 +40,7 @@ public:
CMultiBar *GetParamBar() {return(&ParamBar);}
CDialog &GetLayerList() {return(LayerList);}
CDialog &GetTileSetDlg() {return(TileSetDlg);}
CDialog &GetGfxToolBar() {return(GfxToolBar);}
// Operations
public:
@ -65,7 +66,7 @@ protected: // control bar embedded members
// Sub Dialogs
CLayerList LayerList;
CTileSetDlg TileSetDlg;
CGfxToolBar GfxToolBar;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)

View File

@ -13,19 +13,7 @@
/*****************************************************************************/
int CMap::GetWidth()
{
return(Map.size());
}
/*****************************************************************************/
int CMap::GetHeight()
{
return(Map[0].size());
}
/*****************************************************************************/
void CMap::SetSize(int Width,int Height)
void CMap::SetSize(int Width,int Height,BOOL Clear)
{
Map.resize(Width);
for (int i=0;i<Width;i++)
@ -33,12 +21,16 @@ void CMap::SetSize(int Width,int Height)
Map[i].resize(Height);
}
for (int Y=0;Y<Height;Y++)
for (int X=0;X<Width;X++)
{
Map[X][Y].Bank=0;
Map[X][Y].Tile=(X+Y)%9;
}
if (Clear)
{
for (int Y=0;Y<Height;Y++)
for (int X=0;X<Width;X++)
{
Map[X][Y].Set=0;
// Map[X][Y].Tile=(X+Y)%9;
Map[X][Y].Tile=0;
}
}
}
@ -52,6 +44,28 @@ void CMap::SetHeight(int Height)
{
}
/*****************************************************************************/
void CMap::Clear()
{
int Width=GetWidth();
for (int i=0;i<Width;i++)
{
Map[i].clear();
}
Map.clear();
}
/*****************************************************************************/
sMapElem &CMap::GetTile(int X,int Y)
{
return(Map[X][Y]);
}
/*****************************************************************************/
void CMap::SetTile(int X,int Y,sMapElem &New)
{
Map[X][Y]=New;
}

View File

@ -9,7 +9,7 @@
struct sMapElem
{
int Bank;
int Set;
int Tile;
int Flags;
};
@ -21,14 +21,16 @@ public:
CMap(){};
~CMap(){};
int GetWidth();
int GetHeight();
int GetWidth() {return(Map.size());}
int GetHeight() {return(Map[0].size());}
void SetSize(int Width,int Height);
void SetSize(int Width,int Height,BOOL Clear=FALSE);
void SetWidth(int Width);
void SetHeight(int Height);
void Clear();
sMapElem &GetTile(int X,int Y) {return(Map[X][Y]);}
sMapElem &GetTile(int X,int Y);
void SetTile(int X,int Y,sMapElem &New);
protected:
std::vector< std::vector<sMapElem> > Map;

View File

@ -8,7 +8,7 @@ NewFileInclude1=#include "stdafx.h"
NewFileInclude2=#include "mapedit.h"
LastPage=0
ClassCount=10
ClassCount=11
Class1=CChildFrame
Class2=CGLEnabledView
Class3=CMainFrame
@ -17,18 +17,20 @@ Class5=CAboutDlg
Class6=CMapEditDoc
Class7=CMapEditView
ResourceCount=8
Resource1=IDR_TOOLBAR (English (U.S.))
ResourceCount=9
Resource1=IDD_MULTIBAR (English (U.S.))
Resource2=IDR_MAPEDITYPE (English (U.S.))
Resource3=IDR_MAINFRAME (English (U.S.))
Resource3=IDD_TILESET_DIALOG
Resource4=IDD_DIALOGBAR (English (U.S.))
Resource5=IDD_ABOUTBOX (English (U.S.))
Resource5=IDR_TOOLBAR (English (U.S.))
Class8=CMultiBar
Resource6=IDD_LAYER_LIST_DIALOG
Resource7=IDD_MULTIBAR (English (U.S.))
Resource6=IDD_ABOUTBOX (English (U.S.))
Resource7=IDR_MAINFRAME (English (U.S.))
Class9=CLayerList
Class10=CTileSetDlg
Resource8=IDD_TILESET_DIALOG
Resource8=IDD_LAYER_LIST_DIALOG
Class11=CGfxToolBar
Resource9=IDD_GFXTOOLBAR
[CLS:CChildFrame]
Type=0
@ -205,9 +207,10 @@ LastObject=CLayerList
[DLG:IDD_TILESET_DIALOG]
Type=1
Class=CTileSetDlg
ControlCount=2
ControlCount=3
Control1=IDC_TILESETDLG_COMBO,combobox,1342242819
Control2=IDC_TILESETDLG_BTN_UPDATE,button,1342242816
Control3=IDC_TILESETDLG_BTN_LOAD,button,1342242816
[CLS:CTileSetDlg]
Type=0
@ -216,5 +219,24 @@ ImplementationFile=TileSetDlg.cpp
BaseClass=CDialog
Filter=D
VirtualFilter=dWC
LastObject=IDC_TILESETDLG_COMBO
LastObject=IDC_TILESETDLG_BTN_LOAD
[CLS:CGfxToolBar]
Type=0
HeaderFile=GfxToolBar.h
ImplementationFile=GfxToolBar.cpp
BaseClass=CDialog
Filter=D
LastObject=IDD_GFXTOOLBAR_MIRRORX
VirtualFilter=dWC
[DLG:IDD_GFXTOOLBAR]
Type=1
Class=CGfxToolBar
ControlCount=5
Control1=IDD_GFXTOOLBAR_PAINT,button,1342242816
Control2=IDD_GFXTOOLBAR_SELECT,button,1342242816
Control3=IDD_GFXTOOLBAR_PICKER,button,1342242816
Control4=IDD_GFXTOOLBAR_MIRRORX,button,1342242816
Control5=IDD_GFXTOOLBAR_MIRRORY,button,1342242816

View File

@ -243,6 +243,14 @@ SOURCE=.\StdAfx.h
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\res\ico00001.ico
# End Source File
# Begin Source File
SOURCE=.\res\icon1.ico
# End Source File
# Begin Source File
SOURCE=.\res\MapEdit.ico
# End Source File
# Begin Source File
@ -255,6 +263,30 @@ SOURCE=.\res\MapEditDoc.ico
# End Source File
# Begin Source File
SOURCE=.\res\mirrorx.ico
# End Source File
# Begin Source File
SOURCE=.\res\mirrory.ico
# End Source File
# Begin Source File
SOURCE=.\res\paint.ico
# End Source File
# Begin Source File
SOURCE=.\res\paint1.ico
# End Source File
# Begin Source File
SOURCE=.\res\paint2.ico
# End Source File
# Begin Source File
SOURCE=.\res\picker.ico
# End Source File
# Begin Source File
SOURCE=.\res\Toolbar.bmp
# End Source File
# End Group
@ -263,6 +295,14 @@ SOURCE=.\res\Toolbar.bmp
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\GfxToolBar.cpp
# End Source File
# Begin Source File
SOURCE=.\GfxToolBar.h
# End Source File
# Begin Source File
SOURCE=.\LayerList.cpp
# End Source File
# Begin Source File

View File

@ -408,6 +408,19 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_PAINT ICON DISCARDABLE "res\\paint.ico"
IDI_SELECT ICON DISCARDABLE "res\\paint1.ico"
IDI_PICKER ICON DISCARDABLE "res\\picker.ico"
IDI_MIRRORX ICON DISCARDABLE "res\\mirrorx.ico"
IDI_MIRRORY ICON DISCARDABLE "res\\mirrory.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
@ -428,7 +441,19 @@ FONT 8, "MS Sans Serif"
BEGIN
COMBOBOX IDC_TILESETDLG_COMBO,7,7,138,322,CBS_DROPDOWNLIST |
WS_TABSTOP
PUSHBUTTON "Update",IDC_TILESETDLG_BTN_UPDATE,5,25,140,15
PUSHBUTTON "Update",IDC_TILESETDLG_BTN_UPDATE,80,25,65,15
PUSHBUTTON "Load",IDC_TILESETDLG_BTN_LOAD,5,25,70,15
END
IDD_GFXTOOLBAR DIALOG DISCARDABLE 0, 0, 156, 26
STYLE WS_CHILD
FONT 8, "MS Sans Serif"
BEGIN
PUSHBUTTON "P",IDD_GFXTOOLBAR_PAINT,5,5,15,15
PUSHBUTTON "S",IDD_GFXTOOLBAR_SELECT,20,5,15,15
PUSHBUTTON "Pk",IDD_GFXTOOLBAR_PICKER,35,5,15,15
PUSHBUTTON "X",IDD_GFXTOOLBAR_MIRRORX,50,5,15,15
PUSHBUTTON "Y",IDD_GFXTOOLBAR_MIRRORY,65,5,15,15
END
@ -455,6 +480,14 @@ BEGIN
TOPMARGIN, 7
BOTTOMMARGIN, 39
END
IDD_GFXTOOLBAR, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 149
TOPMARGIN, 7
BOTTOMMARGIN, 19
END
END
#endif // APSTUDIO_INVOKED

View File

@ -148,7 +148,7 @@ void CMapEditDoc::MouseWheel(CMapEditView *View,UINT nFlags, short zDelta, CPoin
/*********************************************************************************/
void CMapEditDoc::MouseMove(CMapEditView *View,UINT nFlags, CPoint &point)
{
Core.MouseMove(View,nFlags,point);
Core.MouseMove(View,nFlags,point);
}
/*********************************************************************************/
@ -165,16 +165,39 @@ void CMapEditDoc::ToggleGrid(CMapEditView *View)
}
/*********************************************************************************/
void CMapEditDoc::ReloadTileBank()
void CMapEditDoc::SetMode(int NewMode)
{
Core.ReloadTileBank();
Core.SetMode(NewMode);
}
/*********************************************************************************/
/*** Tilebank Functions **********************************************************/
/*********************************************************************************/
void CMapEditDoc::TileBankLoad()
{
char BASED_CODE GinFilter[]= "Gin Files (*.Gin)|*.gin|All Files (*.*)|*.*||";
CFileDialog Dlg(TRUE,"Gin",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,GinFilter);
if (Dlg.DoModal()!=IDOK) return;
char Filename[256];
sprintf(Filename,"%s",Dlg.GetPathName());
Core.TileBankLoad(Filename);
UpdateAllViews(NULL);
}
/*********************************************************************************/
void CMapEditDoc::TileBankReload()
{
Core.TileBankReload();
UpdateAllViews(NULL);
}
/*********************************************************************************/
void CMapEditDoc::TileBankChange()
void CMapEditDoc::TileBankSet()
{
Core.ChangeTileBank();
Core.TileBankSet();
UpdateAllViews(NULL);
}

View File

@ -32,8 +32,11 @@ public:
void ToggleTileView(CMapEditView *View);
void ToggleGrid(CMapEditView *View);
void ReloadTileBank();
void TileBankChange();
void TileBankLoad();
void TileBankReload();
void TileBankSet();
void SetMode(int NewMode);
// Operations
public:

View File

@ -37,6 +37,15 @@ const float TileBrowserY1=1+TileBrowserGap/2;
CTileBank::CTileBank()
{
LoadFlag=FALSE;
CurrentSet=0;
LTile.Set=-1;
RTile.Set=-1;
AddTileSet("c:/temp/rockp/rockp.gin");
LTile.Set=0;
LTile.Tile=1;
RTile.Set=0;
RTile.Tile=2;
}
/*****************************************************************************/
@ -87,107 +96,75 @@ CTile &CTileBank::GetTile(int Bank,int Tile)
/*****************************************************************************/
void CTileBank::RenderSet(CCore *Core,Vec &CamPos,BOOL Is3d)
{
int CurrentBank=Core->GetCurrentTileBank();
sMapElem &LSelTile=Core->GetMouseTileL();
sMapElem &RSelTile=Core->GetMouseTileR();
int LTile=-1,RTile=-1;
int LT=LTile.Tile;
int RT=RTile.Tile;
if (LSelTile.Bank==CurrentBank || LSelTile.Tile==0) LTile=LSelTile.Tile;
if (RSelTile.Bank==CurrentBank || RSelTile.Tile==0) RTile=RSelTile.Tile;
if (LTile.Set!=CurrentSet) LT=-1;
if (RTile.Set!=CurrentSet) RT=-1;
if (!TileSet.size()) return; // No tiles, return
if (Is3d)
{
glEnable(GL_DEPTH_TEST);
TileSet[CurrentBank].Render3d(Core,CamPos,CursPos,LTile,RTile);
TileSet[CurrentSet].Render3d(CamPos,LT,RT,CursorPos,Core->IsGridOn());
glDisable(GL_DEPTH_TEST);
}
else
{
TileSet[CurrentBank].Render2d(Core,CamPos,CursPos,LTile,RTile);
TileSet[CurrentSet].Render2d(CamPos,LT,RT,CursorPos,Core->IsGridOn());
}
}
/*****************************************************************************/
void CTileBank::FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos)
{
int CurrentBank=Core->GetCurrentTileBank();
if (!TileSet.size()) return; // No tiles, return
CursPos=TileSet[CurrentBank].FindCursorPos(Core,View,CamPos,MousePos);
}
/*****************************************************************************/
void CTileBank::LButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag)
{
if (!DownFlag) return;
sMapElem &SelTile= Core->GetMouseTileL();
sMapElem &OtherSelTile= Core->GetMouseTileR();
int CurrentBank= Core->GetCurrentTileBank();
if (CursPos==-1) return;
if (CurrentBank==OtherSelTile.Bank && OtherSelTile.Tile==CursPos)
{ // Dont assign if same as other mouse
}
else
{
SelTile.Bank=CurrentBank;
SelTile.Tile=CursPos;
if (SelTile.Tile==0) SelTile.Bank=0; // Always make zero tile, bank 0 (dunno why, just seems handy)
View->Invalidate();
}
}
/*****************************************************************************/
void CTileBank::RButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag)
{
if (!DownFlag) return;
sMapElem &SelTile= Core->GetMouseTileR();
sMapElem &OtherSelTile= Core->GetMouseTileL();
int CurrentBank= Core->GetCurrentTileBank();
if (CursPos==-1) return;
if (CurrentBank==OtherSelTile.Bank && OtherSelTile.Tile==CursPos)
{ // Dont assign if same as other mouse
}
else
{
SelTile.Bank=CurrentBank;
SelTile.Tile=CursPos;
View->Invalidate();
}
CursorPos=TileSet[CurrentSet].FindCursorPos(Core,View,CamPos,MousePos);
}
/*****************************************************************************/
/*** Gui *********************************************************************/
/*****************************************************************************/
void CTileBank::InitGUI(CCore *Core)
{
CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd();
CMultiBar *ParamBar=Frm->GetParamBar();
ParamBar->RemoveAll();
ParamBar->Add(Frm->GetTileSetDlg(),IDD_TILESET_DIALOG,TRUE);
ParamBar->Update();
UpdateGUI(Core);
}
/*****************************************************************************/
void CTileBank::UpdateGUI(CCore *Core)
void CTileBank::UpdateGUI(CCore *Core,BOOL IsTileView)
{
CMainFrame *Frm=(CMainFrame*)AfxGetApp()->GetMainWnd();
CTileSetDlg *TileSetDlg=(CTileSetDlg*)Frm->GetDialog(IDD_TILESET_DIALOG);
int ListSize=TileSet.size();
TRACE1("%i\n",TileSetDlg->TileSetList.GetCurSel());
TileSetDlg->TileSetList.ResetContent();
for (int i=0; i<ListSize; i++)
if (ListSize)
{
TileSetDlg->TileSetList.AddString(TileSet[i].GetName());
for (int i=0; i<ListSize; i++)
{
TileSetDlg->TileSetList.AddString(TileSet[i].GetName());
}
TileSetDlg->TileSetList.SetCurSel(CurrentSet);
// IsTileView=TRUE;
}
TileSetDlg->TileSetList.SetCurSel(Core->GetCurrentTileBank());
else
{
IsTileView=FALSE;
}
TileSetDlg->TileSetList.EnableWindow(IsTileView);
}
/*****************************************************************************/
/*** Functions ***************************************************************/
/*****************************************************************************/
BOOL CTileBank::TileSelect(sMapElem &ThisTile,sMapElem &OtherTile)
{
if (CursorPos==-1) return(FALSE);
if (CurrentSet==OtherTile.Set && OtherTile.Tile==CursorPos)
{ // Dont assign if same as other Tile
return(FALSE);
}
ThisTile.Set=CurrentSet;
ThisTile.Tile=CursorPos;
if (ThisTile.Tile==0) ThisTile.Set=0; // Always make zero tile, bank 0 (dunno why, just seems handy)
return(TRUE);
}
/*****************************************************************************/
@ -202,10 +179,10 @@ char Dir[_MAX_DIR];
char Fname[_MAX_FNAME];
char Ext[_MAX_EXT];
_splitpath(_Filename,Drive,Dir,Fname,Ext);
sprintf(Path,"%s%s",Drive,Dir);
sprintf(Name,"%s",Fname);
Loaded=FALSE;
_splitpath(_Filename,Drive,Dir,Fname,Ext);
sprintf(Path,"%s%s",Drive,Dir);
sprintf(Name,"%s",Fname);
Loaded=FALSE;
}
/*****************************************************************************/
@ -222,7 +199,6 @@ void CTileSet::Load(CCore *Core)
{
CScene Scene;
char Filename[256+64];
CTile NewTile;
sprintf(Filename,"%s%s.%s",Path,Name,"Gin");
Scene.Load(Filename);
@ -230,13 +206,10 @@ CTile NewTile;
CNode &ThisNode=Scene.GetSceneNode(0);
int ChildCount=ThisNode.GetPruneChildCount();
NewTile.CreateBlank(Core,this);
Tile.push_back(NewTile);
Tile.push_back(CTile()); // Insert Blank
for (int Child=0; Child<ChildCount; Child++)
{
NewTile.Load(Core,this,Scene,ThisNode.PruneChildList[Child]);
Tile.push_back(NewTile);
Tile.push_back(CTile(Core,this,Scene,ThisNode.PruneChildList[Child]));
}
Loaded=TRUE;
@ -257,17 +230,15 @@ int ListSize=Tile.size();
}
/*****************************************************************************/
void CTileSet::Render2d(CCore *Core,Vec &CamPos,int CursorPos,int LTile,int RTile)
void CTileSet::Render2d(Vec &CamPos,int LTile,int RTile,int CursorPos,BOOL GridFlag)
{
}
/*****************************************************************************/
void CTileSet::Render3d(CCore *Core,Vec &CamPos,int CursorPos,int LTile,int RTile)
void CTileSet::Render3d(Vec &CamPos,int LTile,int RTile,int CursorPos,BOOL GridFlag)
{
int ListSize=Tile.size();
CTexCache &TexCache=Core->GetTexCache();
int TileID=0;
BOOL GridFlag=Core->IsGridOn();
glMatrixMode(GL_MODELVIEW);
@ -280,61 +251,63 @@ BOOL GridFlag=Core->IsGridOn();
glLoadIdentity();
glTranslatef(CamPos.x+XPos*(1+TileBrowserGap),CamPos.y-YPos*(1+TileBrowserGap),CamPos.z);
RenderMisc(TileID==LTile,TileID==RTile,GridFlag,TileID==CursorPos);
RenderMisc(TileID==LTile,TileID==RTile,TileID==CursorPos,GridFlag);
glColor3f(0.5,0.5,0.5);
ThisTile.Render();
TileID++;
}
}
/*****************************************************************************/
void CTileSet::RenderMisc(BOOL LSelFlag,BOOL RSelFlag, BOOL GridFlag,BOOL CursorFlag)
void CTileSet::RenderMisc(BOOL LTileFlag,BOOL RTileFlag,BOOL CursorFlag,BOOL GridFlag)
{
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_2D);
if (LSelFlag || RSelFlag || CursorFlag)
{ // Show selected tile
glBegin(GL_QUADS);
glNormal3f( 1,1,1);
if (LSelFlag)
glColor3ub(255,0,0);
else
if (RSelFlag)
glColor3ub(0,0,255);
else
glColor3ub(255,255,0);
if (LTileFlag || RTileFlag || CursorFlag)
{
glBegin(GL_QUADS);
glNormal3f( 1,1,1);
BuildGLQuad(TileBrowserX0,TileBrowserX1,TileBrowserY0,TileBrowserY1,0);
glEnd();
}
else
if (GridFlag)
glColor3ub(255,255,0);
if (LTileFlag)
{
glBegin(GL_LINES);
glNormal3f( 1,1,1);
glColor3ub(255,255,255);
glVertex3f( TileBrowserX0,TileBrowserY0,0);
glVertex3f( TileBrowserX1,TileBrowserY0,0);
glVertex3f( TileBrowserX0,TileBrowserY1,0);
glVertex3f( TileBrowserX1,TileBrowserY1,0);
glVertex3f( TileBrowserX0,TileBrowserY0,0);
glVertex3f( TileBrowserX0,TileBrowserY1,0);
glVertex3f( TileBrowserX1,TileBrowserY0,0);
glVertex3f( TileBrowserX1,TileBrowserY1,0);
glEnd();
glColor3ub(255,0,0);
}
if (RTileFlag)
{
glColor3ub(0,0,255);
}
BuildGLQuad(TileBrowserX0,TileBrowserX1,TileBrowserY0,TileBrowserY1,0);
glEnd();
}
glEnable(GL_TEXTURE_2D);
if (GridFlag)
{
glBegin(GL_LINES);
glNormal3f( 1,1,1);
glColor3ub(255,255,255);
glVertex3f( TileBrowserX0,TileBrowserY0,0);
glVertex3f( TileBrowserX1,TileBrowserY0,0);
glVertex3f( TileBrowserX0,TileBrowserY1,0);
glVertex3f( TileBrowserX1,TileBrowserY1,0);
glVertex3f( TileBrowserX0,TileBrowserY0,0);
glVertex3f( TileBrowserX0,TileBrowserY1,0);
glVertex3f( TileBrowserX1,TileBrowserY0,0);
glVertex3f( TileBrowserX1,TileBrowserY1,0);
glEnd();
}
glEnable(GL_TEXTURE_2D);
}
/*****************************************************************************/

View File

@ -32,27 +32,35 @@ public:
CTileBank();
~CTileBank();
void AddTileSet(char *Filename);
int NeedLoad() {return(LoadFlag);}
void Reload();
void LoadTileSets(CCore *Core);
CTile &GetTile(int Bank,int Tile);
void AddTileSet(char *Filename);
int NeedLoad() {return(LoadFlag);}
void Reload();
void LoadTileSets(CCore *Core);
CTile &GetTile(int Bank,int Tile);
void SetCurrent(int Set) {CurrentSet=Set;}
void RenderSet(CCore *Core,Vec &CamPos,BOOL Is3d);
void FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos);
sMapElem &GetLTile() {return(LTile);}
sMapElem &GetRTile() {return(RTile);}
void LButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
void RButtonControl(CCore *Core,CMapEditView *View,UINT nFlags, CPoint &point,BOOL DownFlag);
void RenderSet(CCore *Core,Vec &CamPos,BOOL Is3d);
void FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos);
void InitGUI(CCore *Core);
void UpdateGUI(CCore *Core);
void UpdateGUI(CCore *Core,BOOL IsTileView);
// Functions
BOOL TileSelectL() {return(TileSelect(LTile,RTile));}
BOOL TileSelectR() {return(TileSelect(RTile,LTile));}
private:
BOOL TileSelect(sMapElem &ThisTile,sMapElem &OtherTile);
std::vector<CTileSet> TileSet;
BOOL LoadFlag;
int CursPos;
int CurrentSet;
sMapElem LTile,RTile;
BOOL LoadFlag;
int CursorPos;
};
/*****************************************************************************/
@ -68,12 +76,13 @@ public:
char *GetName() {return(Name);}
CTile &GetTile(int No) {return(Tile[No]);}
void Purge();
void Render2d(CCore *Core,Vec &CamPos,int CursorPos,int LTile,int RTile);
void Render3d(CCore *Core,Vec &CamPos,int CursorPos,int LTile,int RTile);
void RenderMisc(BOOL LSelFlag,BOOL RSelFlag, BOOL GridFlag,BOOL CursorFlag);
int FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos);
void Render2d(Vec &CamPos,int LTile,int RTile,int CursorPos,BOOL GridFlag);
void Render3d(Vec &CamPos,int LTile,int RTile,int CursorPos,BOOL GridFlag);
private:
void RenderMisc(BOOL LTileFlag,BOOL RTileFlag,BOOL CursorFlag,BOOL GridFlag);
char Path[256],Name[256];
std::vector<CTile> Tile;
BOOL Loaded;

View File

@ -5,20 +5,27 @@
#define IDD_ABOUTBOX 100
#define IDD_PARAMBAR 103
#define IDD_MULTIBAR 103
#define IDD_TILETOOLBAR 104
#define IDR_MAINFRAME 128
#define IDR_TOOLBAR 128
#define IDR_MAPEDITYPE 129
#define IDD_TRASHHEAP 142
#define IDD_LAYER_LIST_DIALOG 147
#define IDD_TILESET_DIALOG 148
#define IDC_PARAMBAR_LAYER_LIST 1011
#define IDC_TILETOOLBAR_COMBO 1013
#define IDD_GFXTOOLBAR 151
#define IDI_PAINT 152
#define IDI_SELECT 153
#define IDI_PICKER 154
#define IDI_MIRRORX 155
#define IDI_MIRRORY 156
#define IDC_TOOLBAR_COMBO 1018
#define IDC_LIST1 1019
#define IDC_LAYER_LIST 1019
#define IDC_TILESETDLG_BTN_UPDATE 1029
#define IDC_TILESETDLG_COMBO 1030
#define IDD_GFXTOOLBAR_PAINT 1031
#define IDC_TILESETDLG_BTN_LOAD 1031
#define IDD_GFXTOOLBAR_SELECT 1032
#define IDD_GFXTOOLBAR_PICKER 1033
#define IDD_GFXTOOLBAR_MIRRORX 1034
#define IDD_GFXTOOLBAR_MIRRORY 1035
#define ID_TOOLBAR_LAYERBAR 32773
#define ID_TOOLBAR_TILEPALETTE 32774
#define ID_TOOLBAR_COMBO 32777
@ -31,9 +38,9 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 151
#define _APS_NEXT_RESOURCE_VALUE 163
#define _APS_NEXT_COMMAND_VALUE 32785
#define _APS_NEXT_CONTROL_VALUE 1031
#define _APS_NEXT_CONTROL_VALUE 1032
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif