diff --git a/Utils/MapEdit/Core.cpp b/Utils/MapEdit/Core.cpp index b7fb1dc2e..fd3d56546 100644 --- a/Utils/MapEdit/Core.cpp +++ b/Utils/MapEdit/Core.cpp @@ -33,8 +33,6 @@ #include -//GString IconzFileName="Iconz.bmp"; - /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ @@ -82,8 +80,10 @@ int Width,Height; // Create Tile Layers AddLayer(LAYER_TYPE_TILE,LAYER_SUBTYPE_ACTION, Width, Height); +#ifdef _DEBUG AddLayer(LAYER_TYPE_ACTOR,LAYER_SUBTYPE_NONE, Width, Height); - + AddLayer(LAYER_TYPE_ITEM,LAYER_SUBTYPE_NONE, Width, Height); +#endif for (int i=0; iInitSubView(this); @@ -91,6 +91,9 @@ int Width,Height; ActiveLayer=FindLayer(LAYER_TYPE_TILE,LAYER_SUBTYPE_ACTION); +#ifdef _DEBUG + ActiveLayer=FindLayer(LAYER_TYPE_ACTOR,LAYER_SUBTYPE_NONE); +#endif CurrentLayer=Layer[ActiveLayer]; return(TRUE); } @@ -252,7 +255,7 @@ CLayer *ThisLayer; ThisLayer->Render(this,ThisCam,Is3dFlag); if (GridFlag) ThisLayer->RenderGrid(this,ThisCam,i==ActiveLayer); } - if (i!=EndLayer) ThisLayer=Layer[i+1]; + if (iRenderCursor(this,ThisCam,Is3dFlag); @@ -678,21 +681,6 @@ Vector3 &ThisCam=GetCam(); ThisCam=DefaultCamPos; UpdateView(); } -/*****************************************************************************/ -void CCore::GetExecPath(GString &Path) -{ -#ifndef _DEBUG -// Get application path -char ExeFilename[2048]; -GFName Exe; - GetModuleFileName(GetModuleHandle(NULL),ExeFilename,2048); - Exe=ExeFilename; - Exe.File(0); - Exe.Ext(0); - Path=Exe.FullName(); -#endif -} - /*****************************************************************************/ /*** GUI *********************************************************************/ diff --git a/Utils/MapEdit/Core.h b/Utils/MapEdit/Core.h index 0abbfe343..ade45bbd3 100644 --- a/Utils/MapEdit/Core.h +++ b/Utils/MapEdit/Core.h @@ -116,7 +116,6 @@ public: void ResetView(); CElemBank *GetIconBank() {return(IconBank);} - void GetExecPath(GString &Path); private: CMapEditView *CurrentView; diff --git a/Utils/MapEdit/Elem.cpp b/Utils/MapEdit/Elem.cpp index cd97a4fef..bdcb373bb 100644 --- a/Utils/MapEdit/Elem.cpp +++ b/Utils/MapEdit/Elem.cpp @@ -64,9 +64,10 @@ CElem::CElem(int Width,int Height) UnitWidth=ElemWidth/UnitSize; UnitHeight=ElemHeight/UnitSize; ElemID=-1; - ElemRGB=(u8*)malloc(ElemWidth*ElemHeight*3); - memset(ElemRGB,0,ElemWidth*ElemHeight*3); - +int AW=AlignSize(ElemWidth); +int AH=AlignSize(ElemHeight); + ElemRGB=(u8*)MemAlloc(AW*AH*3); + memset(ElemRGB,0,AW*AH*3); Type=ElemType2d; TexXOfs=0; TexYOfs=0; @@ -138,7 +139,7 @@ GFName Path=Filename; /*****************************************************************************/ void CElem::CleanUp() { - free(ElemRGB); + MemFree(ElemRGB); } /*****************************************************************************/ @@ -162,8 +163,16 @@ sTriFace &Tri1=TriList[ListSize+1]; CTexCache &TexCache=Core->GetTexCache(); sTex &ThisTex=TexCache.GetTex(TexID); -float dU=1.0/((float)ThisTex.TexWidth/(float)ElemWidth); -float dV=1.0/((float)ThisTex.TexHeight/(float)ElemHeight); +int CountW=ThisTex.OldW/ElemWidth; +int CountH=ThisTex.OldH/ElemHeight; +float dU=ThisTex.ScaleU/(float)CountW; +float dV=ThisTex.ScaleV/(float)CountH; + + dU=(1.0f/CountW); + dV=(1.0f/CountH); + +// dU=ThisTex.ScaleU; +// dV=ThisTex.ScaleV; float u0=(TexXOfs*dU); float u1=u0+dU; @@ -222,7 +231,7 @@ int ListSize=TriList.size(); if (TexID<0 || TexID>=TexCount) { CString mexstr; - mexstr.Format("Invalid TexId\n Wanted %i/%i for %s\nThis is gonna hurt!",TexID,TexCount-1,ThisNode.Name); + mexstr.Format("Invalid TexId\n Wanted %i only have %i Id's for %s\nThis is gonna hurt!\n Dont ask me about this error, ask Kev.\n This MUST be fixed.",TexID,TexCount-1,ThisNode.Name); AfxMessageBox(mexstr,MB_OK | MB_ICONEXCLAMATION); TexID=0; } @@ -298,22 +307,27 @@ float X1=Ofs.x+UnitWidth; float Y0=Ofs.y; float Y1=Ofs.y+UnitHeight; float Z=Ofs.z; +sTex &Tex=TexCache.GetTex(ElemID); +float u0=0; +float u1=1.0f;//Tex.ScaleU; +float v0=0; +float v1=1.0f;//Tex.ScaleU; List=glGenLists(1); glNewList(List,GL_COMPILE); - glBindTexture(GL_TEXTURE_2D, TexCache.GetTexGLId(ElemID)); + glBindTexture(GL_TEXTURE_2D, Tex.TexID); glBegin (GL_QUADS); - glTexCoord2f(0.0f,0.0f); + glTexCoord2f(u0,v0); glVertex3f(X0,Y0,Z); - glTexCoord2f(1.0f,0.0f); + glTexCoord2f(u1,v0); glVertex3f(X1,Y0,Z); - glTexCoord2f(1.0f,1.0f); + glTexCoord2f(u1,v1); glVertex3f(X1,Y1,Z); - glTexCoord2f(0.0f,1.0f); + glTexCoord2f(u0,v1); glVertex3f(X0,Y1,Z); glEnd(); glEndList(); @@ -343,17 +357,8 @@ float ScaleU,ScaleV; glBegin (GL_TRIANGLES); LastMat=ThisMat; sTex &Tex=TexCache.GetTex(ThisMat); - int AW=TexCache.AlignSize(Tex.TexWidth); - int AH=TexCache.AlignSize(Tex.TexHeight); - if (AW!=Tex.TexWidth || AH!=Tex.TexHeight) - { - ScaleU=(float)Tex.TexWidth/(float)AW; - ScaleV=(float)Tex.TexHeight/(float)AH; - } - else - { - ScaleU=ScaleV=1; - } + ScaleU=Tex.ScaleU; + ScaleV=Tex.ScaleV; } for (int p=0; p<3; p++) @@ -488,7 +493,7 @@ float H=UnitHeight; glClearColor(1,0,1,1 ); // glClearColor(1,1,1,1 ); glPushAttrib(GL_VIEWPORT_BIT); - glViewport(0,0,RGBData.Width,RGBData.Height); + glViewport(0,0,RGBData.TexW,RGBData.TexH); glMatrixMode(GL_PROJECTION); glPushMatrix(); @@ -515,7 +520,7 @@ float H=UnitHeight; glPopMatrix(); glPopAttrib(); - glReadPixels(0,0,RGBData.Width,RGBData.Height,GL_RGB, GL_UNSIGNED_BYTE,RGBData.RGB); + glReadPixels(0,0,RGBData.TexW,RGBData.TexH,GL_RGB, GL_UNSIGNED_BYTE,RGBData.RGB); glClearColor(0,0,0,1 ); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen } @@ -528,10 +533,14 @@ sRGBData RGBData; char TexName[256]; sprintf(TexName,"_2dPc_%s_%03d",Filename,ID); - ElemRGB=(u8*)malloc(ElemWidth*ElemHeight*3); +int AW=AlignSize(ElemWidth); +int AH=AlignSize(ElemHeight); + ElemRGB=(u8*)MemAlloc(AW*AH*3); - RGBData.Width=ElemWidth; - RGBData.Height=ElemHeight; + RGBData.TexW=AlignSize(ElemWidth); + RGBData.TexH=AlignSize(ElemHeight); + RGBData.ScaleU=1.0f; + RGBData.ScaleV=1.0f; RGBData.RGB=ElemRGB; RenderElem4Texture(RGBData); ElemID=TexCache.ProcessTexture(TexName,&RGBData); @@ -553,16 +562,16 @@ char Filename[256]; bool CElem::CheckHasData(sRGBData &RGBData) { u8 *Src=RGBData.RGB; -int Size=RGBData.Width*RGBData.Height; +int Size=RGBData.TexW*RGBData.TexH; - for (int i=0; i ElemList; bool Loaded; @@ -153,7 +154,7 @@ virtual ~CElemBank(); virtual void Load(CFile *File,int Version); virtual void Save(CFile *File); - void AddSet(const char *Filename); + int AddSet(const char *Filename); void LoadAllSets(CCore *Core); void LoadNewSet(CCore *Core); void ReloadAllSets(); diff --git a/Utils/MapEdit/GUILayerItem.cpp b/Utils/MapEdit/GUILayerItem.cpp index a840bee0f..98563ed6f 100644 --- a/Utils/MapEdit/GUILayerItem.cpp +++ b/Utils/MapEdit/GUILayerItem.cpp @@ -5,6 +5,9 @@ #include "mapedit.h" #include "GUILayerItem.h" +#include "MapEditDoc.h" +#include "MainFrm.h" + #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE @@ -28,16 +31,25 @@ void CGUILayerItem::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CGUILayerItem) - // NOTE: the ClassWizard will add DDX and DDV calls here + DDX_Control(pDX, IDC_LEVEL_ITEM_LIST, m_LevelList); + DDX_Control(pDX, IDC_ITEM_LIST, m_List); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CGUILayerItem, CDialog) //{{AFX_MSG_MAP(CGUILayerItem) - // NOTE: the ClassWizard will add message map macros here + ON_BN_CLICKED(IDC_ITEM_DELETE, OnItemDelete) + ON_CBN_SELCHANGE(IDC_LEVEL_ITEM_LIST, OnSelchangeLevelItemList) + ON_CBN_SELCHANGE(IDC_ITEM_LIST, OnSelchangeItemList) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CGUILayerItem message handlers + + +void CGUILayerItem::OnSelchangeItemList() {theApp.GetCurrent()->Command(CmdMsg_ThingListSelect,m_List.GetCurSel());} +void CGUILayerItem::OnSelchangeLevelItemList() {theApp.GetCurrent()->Command(CmdMsg_ThingLevelSelect,m_LevelList.GetCurSel());} +void CGUILayerItem::OnItemDelete() {theApp.GetCurrent()->Command(CmdMsg_ThingListDelete,m_List.GetCurSel());} + diff --git a/Utils/MapEdit/GUILayerItem.h b/Utils/MapEdit/GUILayerItem.h index 69630bd43..b12d586fc 100644 --- a/Utils/MapEdit/GUILayerItem.h +++ b/Utils/MapEdit/GUILayerItem.h @@ -19,7 +19,8 @@ public: // Dialog Data //{{AFX_DATA(CGUILayerItem) enum { IDD = IDD_LAYER_ITEM }; - // NOTE: the ClassWizard will add data members here + CComboBox m_LevelList; + CComboBox m_List; //}}AFX_DATA @@ -35,7 +36,9 @@ protected: // Generated message map functions //{{AFX_MSG(CGUILayerItem) - // NOTE: the ClassWizard will add member functions here + afx_msg void OnItemDelete(); + afx_msg void OnSelchangeLevelItemList(); + afx_msg void OnSelchangeItemList(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; diff --git a/Utils/MapEdit/LayerCollision.cpp b/Utils/MapEdit/LayerCollision.cpp index 5a59bf179..1e5c4bb1e 100644 --- a/Utils/MapEdit/LayerCollision.cpp +++ b/Utils/MapEdit/LayerCollision.cpp @@ -45,7 +45,7 @@ GString Filename; TileBank=new CTileBank; SubView=TileBank; - Core->GetExecPath(Filename); + GetExecPath(Filename); Filename+=theApp.GetConfigStr("FileLocation","Collision"); TileBank->AddSet(Filename); } diff --git a/Utils/MapEdit/LayerItem.cpp b/Utils/MapEdit/LayerItem.cpp index 469febba6..2396e3abc 100644 --- a/Utils/MapEdit/LayerItem.cpp +++ b/Utils/MapEdit/LayerItem.cpp @@ -45,20 +45,19 @@ void CLayerItem::InitSubView(CCore *Core) void CLayerItem::GUIInit(CCore *Core) { // GUI.DisableCallback(true); -// Core->GUIAdd(GUI,IDD_LAYER_Item); + Core->GUIAdd(GUI,IDD_LAYER_ITEM); // GUI.DisableCallback(false); } /*****************************************************************************/ void CLayerItem::GUIKill(CCore *Core) { -// Core->GUIRemove(GUI,IDD_LAYER_Item); + Core->GUIRemove(GUI,IDD_LAYER_ITEM); } /*****************************************************************************/ void CLayerItem::GUIUpdate(CCore *Core) { -/* int i,ListSize; CComboBox &List=GUI.m_List; @@ -71,24 +70,20 @@ CComboBox &List=GUI.m_List; } List.SetCurSel(CurrentDefThing); - GUIThingUpdate(); -*/ +// GUIThingUpdate(); } /*****************************************************************************/ void CLayerItem::GUIThingDefClear() { -/* CComboBox &List=GUI.m_List; CurrentDefThing=-1; List.SetCurSel(CurrentDefThing); -*/ } /*****************************************************************************/ void CLayerItem::GUIThingUpdate() { -/* int i,ListSize; CComboBox &List=GUI.m_LevelList; // Setup ThingList @@ -102,73 +97,11 @@ CComboBox &List=GUI.m_LevelList; } 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); -*/ -} - -/*****************************************************************************/ -void CLayerItem::GUIThingPointUpdate() -{ -/* -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; iGetSetCount(); if (Gfx) { - ThingBank->AddSet(Gfx); + char Filename[512]; + GFName::makeabsolute(ExecPath,Gfx,Filename); + ThisDef.ElemID=ThingBank->AddSet(Filename); } else { @@ -214,9 +219,13 @@ void CLayerThing::RenderThing(CCore *Core,Vector3 &ThisCam,sLayerThing &ThisThin { float ZoomW=Core->GetZoomW(); float ZoomH=Core->GetZoomH(); -float ScrOfsX=(ZoomW/2); -float ScrOfsY=(ZoomH/2); Vector3 &Scale=Core->GetScaleVector(); +Vector3 ScrOfs(ZoomW/2,ZoomH/2,0); + + if (Render3d) + { + ScrOfs.z=-4.0f; + } if (ThingBank->NeedLoad()) ThingBank->LoadAllSets(Core); @@ -227,7 +236,7 @@ Vector3 &Scale=Core->GetScaleVector(); glScalef(Scale.x,Scale.y,Scale.z); glTranslatef(-ThisCam.x,ThisCam.y,0); // Set scroll offset - glTranslatef(-ScrOfsX,ScrOfsY,0); // Bring to top left corner + glTranslatef(-ScrOfs.x,ScrOfs.y,0); // Bring to top left corner int ListSize=ThisThing.XY.size(); for (int i=0;iRenderElem(ThisThing.ElemID,0,0,Render3d); + glTranslatef(0,0,-ScrOfs.z); + glDisable(GL_DEPTH_TEST); } glPopMatrix(); } @@ -257,14 +270,11 @@ int ListSize=ThisThing.XY.size(); /*****************************************************************************/ void CLayerThing::GUIInit(CCore *Core) { -// Core->GUIAdd(GUIToolBar,IDD_TOOLBAR); - } /*****************************************************************************/ void CLayerThing::GUIKill(CCore *Core) { -// Core->GUIRemove(GUIToolBar,IDD_TOOLBAR); } /*****************************************************************************/ diff --git a/Utils/MapEdit/MapEdit.clw b/Utils/MapEdit/MapEdit.clw index 3ce2d6ba1..4e6e82754 100644 --- a/Utils/MapEdit/MapEdit.clw +++ b/Utils/MapEdit/MapEdit.clw @@ -2,13 +2,13 @@ [General Info] Version=1 -LastClass=CGUINewMap +LastClass=CGUILayerItem LastTemplate=CDialog NewFileInclude1=#include "stdafx.h" NewFileInclude2=#include "mapedit.h" LastPage=0 -ClassCount=19 +ClassCount=20 Class1=CChildFrame Class2=CGLEnabledView Class3=CGUIAddLayer @@ -28,25 +28,27 @@ Class16=CAboutDlg Class17=CMapEditDoc Class18=CMapEditView -ResourceCount=17 -Resource1=IDR_TOOLBAR (English (U.S.)) +ResourceCount=18 +Resource1=IDD_ABOUTBOX (English (U.S.)) Resource2=IDR_MAPEDITYPE (English (U.S.)) -Resource3=IDD_NEWMAP -Resource4=IDD_TOOLBAR -Resource5=IDD_LAYER_COLLISION -Resource6=IDD_RESIZE -Resource7=IDD_ABOUTBOX (English (U.S.)) +Resource3=IDD_LAYER_COLLISION +Resource4=IDD_MULTIBAR (English (U.S.)) +Resource5=IDD_LAYER_LIST +Resource6=IDD_ADDLAYER +Resource7=IDR_TOOLBAR (English (U.S.)) Resource8=xxxx -Resource9=IDD_TILEBANK -Resource10=IDD_LAYER_SHADE -Resource11=IDD_ADDLAYER -Resource12=IDD_MULTIBAR (English (U.S.)) -Resource13=IDD_ELEMLIST -Resource14=IDD_LAYER_LIST +Resource9=IDD_LAYER_SHADE +Resource10=IDD_LAYER_ACTOR +Resource11=IDD_TOOLBAR +Resource12=IDD_RESIZE +Resource13=IDR_MAINFRAME (English (U.S.)) +Resource14=IDD_NEWMAP Resource15=IDD_LAYER_ACTOR2 -Resource16=IDR_MAINFRAME (English (U.S.)) Class19=CGUILayerActor -Resource17=IDD_LAYER_ACTOR +Resource16=IDD_TILEBANK +Resource17=IDD_ELEMLIST +Class20=CGUILayerItem +Resource18=IDD_LAYER_ITEM [CLS:CChildFrame] Type=0 @@ -98,7 +100,7 @@ HeaderFile=GUINewMap.h ImplementationFile=GUINewMap.cpp Filter=D VirtualFilter=dWC -LastObject=IDC_MAPSIZE_HEIGHT +LastObject=CGUINewMap [CLS:CGUIResize] Type=0 @@ -213,7 +215,7 @@ Control7=IDC_MAPSIZE_WARNING,static,1342308352 Type=1 Class=CGUITileBank ControlCount=3 -Control1=IDD_TILEBANK_UPDATE,button,1342242816 +Control1=IDD_TILEBANK_UPDATE,button,1476460544 Control2=IDD_TILEBANK_LOAD,button,1342242816 Control3=IDD_TILEBANK_DELETE,button,1342242816 @@ -390,9 +392,18 @@ Control6=IDC_LAYERCOLLISION_WATER,button,1342242816 Control7=IDC_LAYERCOLLISION_SOLID,button,1342242816 Control8=IDC_LAYERCOLLISION_DEATH,button,1342242816 +[CLS:CGUILayerActor] +Type=0 +HeaderFile=GUILayerActor.h +ImplementationFile=GUILayerActor.cpp +BaseClass=CDialog +Filter=D +VirtualFilter=dWC +LastObject=IDC_ACTOR_POS_LIST + [DLG:IDD_LAYER_ACTOR] Type=1 -Class=CGUILayerActor +Class=? ControlCount=22 Control1=IDC_LEVEL_ACTOR_LIST,combobox,1344339971 Control2=IDC_ACTOR_POS_LIST,listbox,1352728833 @@ -417,12 +428,21 @@ Control20=IDC_LAYER_ACTOR_GROUP,button,1342177287 Control21=IDC_ACTOR_LIST,combobox,1344339971 Control22=IDC_ACTOR_DELETE,button,1342242816 -[CLS:CGUILayerActor] +[DLG:IDD_LAYER_ITEM] +Type=1 +Class=CGUILayerItem +ControlCount=4 +Control1=IDC_LEVEL_ITEM_LIST,combobox,1344339971 +Control2=IDC_LAYER_ACTOR_GROUP,button,1342177287 +Control3=IDC_ITEM_LIST,combobox,1344339971 +Control4=IDC_ITEM_DELETE,button,1342242816 + +[CLS:CGUILayerItem] Type=0 -HeaderFile=GUILayerActor.h -ImplementationFile=GUILayerActor.cpp +HeaderFile=GUILayerItem.h +ImplementationFile=GUILayerItem.cpp BaseClass=CDialog Filter=D VirtualFilter=dWC -LastObject=CGUILayerActor +LastObject=IDC_ITEM_LIST diff --git a/Utils/MapEdit/MapEdit.dsp b/Utils/MapEdit/MapEdit.dsp index 2f975f658..9a3e0537d 100644 --- a/Utils/MapEdit/MapEdit.dsp +++ b/Utils/MapEdit/MapEdit.dsp @@ -80,12 +80,6 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept # ADD LINK32 opengl32.lib glu32.lib glib.lib ginlib.lib maths.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\libs\ginlib\debug\\" /libpath:"..\libs\glib\debug\\" /libpath:"..\libs\maths\debug\\" -# Begin Special Build Tool -ProjDir=. -TargetDir=.\Debug -SOURCE="$(InputPath)" -PostBuild_Cmds=if not exist $(TargetDir)\collision.bmp copy $(ProjDir)\res\collision.bmp $(TargetDir)\collision.bmp if not exist $(TargetDir)\iconz.bmp copy $(ProjDir)\res\iconz.bmp $(TargetDir)\iconz.bmp copy $(ProjDir)\res\iconz.bmp $(TargetDir)\iconz.bmp -# End Special Build Tool !ENDIF @@ -407,6 +401,14 @@ SOURCE=.\GUILayerCollision.h # End Source File # Begin Source File +SOURCE=.\GUILayerItem.cpp +# End Source File +# Begin Source File + +SOURCE=.\GUILayerItem.h +# End Source File +# Begin Source File + SOURCE=.\GUILayerList.cpp # End Source File # Begin Source File diff --git a/Utils/MapEdit/MapEdit.rc b/Utils/MapEdit/MapEdit.rc index 6e6677d1d..7023df876 100644 --- a/Utils/MapEdit/MapEdit.rc +++ b/Utils/MapEdit/MapEdit.rc @@ -515,7 +515,7 @@ IDD_TILEBANK DIALOG DISCARDABLE 0, 0, 156, 26 STYLE WS_CHILD FONT 8, "MS Sans Serif" BEGIN - PUSHBUTTON "Update",IDD_TILEBANK_UPDATE,95,5,50,15 + PUSHBUTTON "Update",IDD_TILEBANK_UPDATE,95,5,50,15,WS_DISABLED PUSHBUTTON "Load",IDD_TILEBANK_LOAD,5,5,45,15 PUSHBUTTON "Delete",IDD_TILEBANK_DELETE,50,5,45,15 END @@ -630,6 +630,18 @@ BEGIN PUSHBUTTON "Delete Actor",IDC_ACTOR_DELETE,5,40,75,15 END +IDD_LAYER_ITEM DIALOG DISCARDABLE 0, 0, 156, 66 +STYLE WS_CHILD +FONT 8, "MS Sans Serif" +BEGIN + COMBOBOX IDC_LEVEL_ITEM_LIST,5,25,145,185,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + GROUPBOX "",IDC_LAYER_ACTOR_GROUP,0,20,155,40 + COMBOBOX IDC_ITEM_LIST,5,5,145,185,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + PUSHBUTTON "Delete Item",IDC_ITEM_DELETE,5,40,75,15 +END + ///////////////////////////////////////////////////////////////////////////// // @@ -718,6 +730,14 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 249 END + + IDD_LAYER_ITEM, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 149 + TOPMARGIN, 7 + BOTTOMMARGIN, 59 + END END #endif // APSTUDIO_INVOKED diff --git a/Utils/MapEdit/TexCache.cpp b/Utils/MapEdit/TexCache.cpp index 03f5d7b75..7b58a3b24 100644 --- a/Utils/MapEdit/TexCache.cpp +++ b/Utils/MapEdit/TexCache.cpp @@ -41,7 +41,7 @@ GFName FName=Filename; RGBData=&ThisRGB; LoadTex(NewTex,RGBData); FreeBMP(ThisRGB); - NewTex.Loaded=TRUE; + NewTex.Loaded=true; } else { @@ -57,19 +57,66 @@ GFName FName=Filename; /**************************************************************************************/ /**************************************************************************************/ /**************************************************************************************/ -const int TexAlignTable[]={1,2,4,8,16,32,64,128,256}; -const int TexAlignTableSize=sizeof(TexAlignTable)/sizeof(int); -int CTexCache::AlignSize(int Size) +void CTexCache::CreateAlignTex(Frame &ThisFrame,sRGBData &RGBData) { - for (int i=0;iTexAlignTable[i] && SizeWidth; -int TexHeight=TexData->Height; -int AlignWidth=AlignSize(TexWidth); -int AlignHeight=AlignSize(TexHeight); u8 *Src,*Dst; // create RGB & alpha texture & ensuse texture is correct size for GL + Buffer=(u8*)MemAlloc(RGBData->TexW*RGBData->TexH*4); + ASSERT(Buffer); - Buffer=(u8*)malloc(AlignWidth*AlignHeight*4); - Src=TexData->RGB; - Dst=&Buffer[0]; + Src=RGBData->RGB; + Dst=Buffer; - for (int Y=0; YTexH; Y++) { - for (int X=0; XTexW; X++) { u8 R,G,B,A; @@ -142,24 +183,32 @@ u8 *Src,*Dst; *Dst++=B; *Dst++=A; } - Dst+=(AlignWidth-TexWidth)*4; } - ThisTex.TexWidth=TexWidth; - ThisTex.TexHeight=TexHeight; - - ThisTex.ScaleU=(float)TexWidth/(float)AlignWidth; - ThisTex.ScaleV=(float)TexHeight/(float)AlignHeight; - + ThisTex.OldW=RGBData->OldW; + ThisTex.OldH=RGBData->OldH; + ThisTex.TexW=RGBData->TexW; + ThisTex.TexH=RGBData->TexH; + ThisTex.ScaleU=RGBData->ScaleU; + ThisTex.ScaleV=RGBData->ScaleV; +int Err; glGenTextures(1, &ThisTex.TexID); + Err=glGetError();ASSERT(Err==0); glBindTexture(GL_TEXTURE_2D, ThisTex.TexID); - glTexImage2D(GL_TEXTURE_2D, 0, 4, AlignWidth, AlignHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, &Buffer[0]); + Err=glGetError();ASSERT(Err==0); + glTexImage2D(GL_TEXTURE_2D, 0, 4, RGBData->TexW, RGBData->TexH, 0, GL_RGBA, GL_UNSIGNED_BYTE, Buffer); + Err=glGetError();ASSERT(Err==0); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + Err=glGetError();ASSERT(Err==0); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); + Err=glGetError();ASSERT(Err==0); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP); + Err=glGetError();ASSERT(Err==0); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP); + Err=glGetError();ASSERT(Err==0); glBindTexture(GL_TEXTURE_2D, 0); - free(Buffer); + Err=glGetError();ASSERT(Err==0); + MemFree(Buffer); } /**************************************************************************************/ diff --git a/Utils/MapEdit/TexCache.h b/Utils/MapEdit/TexCache.h index 46fc6faa5..b51e64b72 100644 --- a/Utils/MapEdit/TexCache.h +++ b/Utils/MapEdit/TexCache.h @@ -15,8 +15,9 @@ struct sRGBData { - int Width; - int Height; + int OldW,OldH; + int TexW,TexH; + float ScaleU,ScaleV; u8 *RGB; }; @@ -25,7 +26,8 @@ struct sTex GString Filename; GString Name; GLuint TexID; - int TexWidth,TexHeight; + int OldW,OldH; + int TexW,TexH; float ScaleU,ScaleV; // For wrong size textures bool Loaded; @@ -37,6 +39,7 @@ const RGBQUAD BlankRGB={255,0,255}; /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ +class Frame; class CTexCache { public: @@ -47,10 +50,10 @@ public: void Purge(); bool LoadBMP(const char *Filename,sRGBData &RGBData); + void CreateAlignTex(Frame &ThisFrame,sRGBData &RGBData); void FreeBMP(sRGBData &RGBData); void FixBMP(sRGBData &RGBData); bool IsSizeOk(int Size); - int AlignSize(int Size); void LoadTex(sTex &ThisTex,sRGBData *TexData); diff --git a/Utils/MapEdit/resource.h b/Utils/MapEdit/resource.h index c5b2140df..11dfa1790 100644 --- a/Utils/MapEdit/resource.h +++ b/Utils/MapEdit/resource.h @@ -19,6 +19,7 @@ #define IDD_LAYER_COLLISION 177 #define IDD_ELEMLIST 178 #define IDD_LAYER_ACTOR 179 +#define IDD_LAYER_ITEM 180 #define IDC_TOOLBAR_COMBO 1018 #define IDC_LAYERLIST_LIST 1019 #define IDD_TILEBANK_UPDATE 1029 @@ -67,7 +68,6 @@ #define IDC_LAYERCOLLISION_DEATH 1088 #define IDC_LAYERSHADE_EDITB3 1089 #define IDC_ACTOR_LIST 1089 -#define IDC_ACTOR_NEW 1090 #define IDC_ACTOR_DELETE 1091 #define IDC_ACTOR_SPEED_SPIN 1092 #define IDC_ACTOR_PLAYER 1094 @@ -75,6 +75,9 @@ #define IDC_ACTOR_TURNRATE_TEXT 1097 #define IDC_ACTOR_TURNRATE 1098 #define IDC_ACTOR_TURNRATE_SPIN 1099 +#define IDC_ITEM_DELETE 1100 +#define IDC_ITEM_LIST 1101 +#define IDC_LEVEL_ITEM_LIST 1102 #define IDC_ACTOR_HEALTH_TEXT 1112 #define IDC_ACTOR_HEALTH 1113 #define IDC_ACTOR_HEALTH_SPIN 1114 @@ -106,7 +109,7 @@ #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 180 #define _APS_NEXT_COMMAND_VALUE 32800 -#define _APS_NEXT_CONTROL_VALUE 1097 +#define _APS_NEXT_CONTROL_VALUE 1103 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/Utils/MapEdit/utils.cpp b/Utils/MapEdit/utils.cpp index 9043535e5..0b66ad8fc 100644 --- a/Utils/MapEdit/utils.cpp +++ b/Utils/MapEdit/utils.cpp @@ -13,6 +13,7 @@ #include #include +#include #include "Utils.H" @@ -30,6 +31,18 @@ char szBuf[256]; } } +/**************************************************************************************/ +const int TexAlignTable[]={1,2,4,8,16,32,64,128,256}; +const int TexAlignTableSize=sizeof(TexAlignTable)/sizeof(int); +int AlignSize(int Size) +{ + for (int i=0;iTexAlignTable[i] && Size