Initial full mirror of c:\VWE (source + assets + toolchain + outputs) via Git LFS

Complete disaster-recovery snapshot: engine/game source, game data assets,
VC6 toolchain + DX SDKs, build outputs, deployed game, and _UNUSED archive.
Large binaries in Git LFS; text preserved byte-for-byte (core.autocrlf=false,
no eol attributes). See RECOVERY.md for the one-clone rebuild procedure.
This commit is contained in:
Cyd
2026-06-24 21:28:16 -05:00
commit 2b8ca921cb
66341 changed files with 7923174 additions and 0 deletions
@@ -0,0 +1,100 @@
// BackGroundProps.cpp : implementation file
//
#include "stdafx.h"
#include "imagegrinder.h"
#include "BackGroundProps.h"
#include <Compost\TexturePool.hpp>
/////////////////////////////////////////////////////////////////////////////
// CBackGroundProps dialog
CBackGroundProps::CBackGroundProps(CWnd* pParent /*=NULL*/)
: CDialog(CBackGroundProps::IDD, pParent)
{
//{{AFX_DATA_INIT(CBackGroundProps)
m_stretch = FALSE;
//}}AFX_DATA_INIT
}
void CBackGroundProps::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBackGroundProps)
DDX_Control(pDX, IDC_MATLIST, m_MatList);
DDX_Control(pDX, IDC_TEXTURELIST, m_TextureList);
DDX_Check(pDX, IDC_STRETCH, m_stretch);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBackGroundProps, CDialog)
//{{AFX_MSG_MAP(CBackGroundProps)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBackGroundProps message handlers
int CBackGroundProps::DoModal(Compost::Tool_Feature *fet)
{
feature_data=fet;
return CDialog::DoModal();
}
BOOL CBackGroundProps::OnInitDialog()
{
CDialog::OnInitDialog();
int i;
for( i=0;i<Compost::MaterialEntriesCount;i++)
{
if(!Compost::MaterialEntries[i].MatName) break;
int itm = m_MatList.AddString((char *)Compost::MaterialEntries[i].MatName);
m_MatList.SetItemData(itm, i);
}
m_MatList.SetCurSel(feature_data->GetMaterial());
Compost::Feature_Texture *FTexture;
Stuff::TableIteratorOf<Compost::Feature_Texture*, int> imageTableIterator(Compost::TexturePool::Instance->GetImageTable());
while(NULL!=(FTexture=imageTableIterator.ReadAndNext()))
{
int idx;
idx=m_TextureList.AddString((char *)(*(FTexture->GetName())));
m_TextureList.SetItemDataPtr(idx,FTexture);
}
int sel=-1;
for(i=0;i<m_TextureList.GetCount();i++)
{
if(m_TextureList.GetItemDataPtr(i)==feature_data->GetFeatureTexture())
sel=i;
}
if(sel!=-1)
m_TextureList.SetCurSel(sel);
else
m_TextureList.SetCurSel(0);
m_stretch=(feature_data->GetBlendMode()==Compost::Feature::Blend_Mode::StretchPaste);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CBackGroundProps::OnOK()
{
feature_data->SetFeatureTexture((Compost::Feature_Texture *)m_TextureList.GetItemDataPtr(m_TextureList.GetCurSel()));
feature_data->SetMaterial(m_MatList.GetCurSel());
Compost::TexturePool::Instance->Load(feature_data->GetFeatureTexture());
Compost::TexturePool::Instance->Load(feature_data->GetFeatureMask0());
Compost::TexturePool::Instance->Load(feature_data->GetFeatureMask1());
CDialog::OnOK();
}
@@ -0,0 +1,53 @@
#if !defined(AFX_BACKGROUNDPROPS_H__0602F021_2998_11D3_80AF_00104BCD3D41__INCLUDED_)
#define AFX_BACKGROUNDPROPS_H__0602F021_2998_11D3_80AF_00104BCD3D41__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// BackGroundProps.h : header file
//
#include<Compost\Compost.hpp>
/////////////////////////////////////////////////////////////////////////////
// CBackGroundProps dialog
class CBackGroundProps : public CDialog
{
// Construction
public:
CBackGroundProps(CWnd* pParent = NULL); // standard constructor
Compost::Tool_Feature *feature_data;
// Dialog Data
//{{AFX_DATA(CBackGroundProps)
enum { IDD = IDD_BACKGROUNDPROPS };
CComboBox m_MatList;
CComboBox m_TextureList;
BOOL m_stretch;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBackGroundProps)
public:
virtual int DoModal(Compost::Tool_Feature *fet);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CBackGroundProps)
virtual void OnOK();
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BACKGROUNDPROPS_H__0602F021_2998_11D3_80AF_00104BCD3D41__INCLUDED_)
@@ -0,0 +1,122 @@
// ChildFrm.cpp : implementation of the CChildFrame class
//
#include "stdafx.h"
#include "ImageGrinder.h"
#include "ChildFrm.h"
#include "ImageGrinderView.h"
#include "FeatureLibView.h"
/////////////////////////////////////////////////////////////////////////////
// CChildFrame
IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
//{{AFX_MSG_MAP(CChildFrame)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChildFrame construction/destruction
CChildFrame::CChildFrame()
{
// TODO: add member initialization code here
Initalized=false;
}
CChildFrame::~CChildFrame()
{
}
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CChildFrame diagnostics
#ifdef _DEBUG
void CChildFrame::AssertValid() const
{
CMDIChildWnd::AssertValid();
}
void CChildFrame::Dump(CDumpContext& dc) const
{
CMDIChildWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CChildFrame message handlers
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// CG: The following block was added by the Splitter Bar component.
/*
{
if (!m_wndSplitter.Create(this,
1, 2, // TODO: adjust the number of rows, columns
CSize(10, 10), // TODO: adjust the minimum pane size
pContext))
{
TRACE0("Failed to create splitter bar ");
return FALSE; // failed to create
}
return TRUE;
}
*/
{
if (!m_wndSplitter.CreateStatic(this,1,2) )
{
TRACE0("Failed to create splitter bar ");
return FALSE; // failed to create
}
m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CImageGrinderView),CSize(500,100), pContext);
m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CFeatureLibView),CSize(100,100), pContext);
AdjustSplitter();
Initalized=true;
return TRUE;
}
}
void CChildFrame::AdjustSplitter()
{
CFeatureLibView *view;
if(Initalized)
{
CRect rct;
GetClientRect(&rct);
view=(CFeatureLibView *)m_wndSplitter.GetPane(0,1);
m_wndSplitter.SetColumnInfo(1,view->GetMaxWidth(),10);
m_wndSplitter.SetColumnInfo(0,rct.Width()-(GetSystemMetrics(SM_CYSIZEFRAME)*2+view->GetMaxWidth()),10);
m_wndSplitter.RecalcLayout();
}
}
void CChildFrame::OnSize(UINT nType, int cx, int cy)
{
CMDIChildWnd::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
AdjustSplitter();
}
@@ -0,0 +1,62 @@
// ChildFrm.h : interface of the CChildFrame class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_CHILDFRM_H__1B275CE9_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_)
#define AFX_CHILDFRM_H__1B275CE9_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CLockedSplitter : public CSplitterWnd
{
public:
void OnMouseMove(UINT nFlags,CPoint point) {return;}
};
class CChildFrame : public CMDIChildWnd
{
DECLARE_DYNCREATE(CChildFrame)
public:
CChildFrame();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CChildFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
bool Initalized;
void AdjustSplitter();
virtual ~CChildFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
protected:
CLockedSplitter m_wndSplitter;
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
//{{AFX_MSG(CChildFrame)
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CHILDFRM_H__1B275CE9_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_)
@@ -0,0 +1,256 @@
// ColorProps.cpp : implementation file
//
#include "stdafx.h"
#include "imagegrinder.h"
#include "ColorProps.h"
#include "..\..\Libraries\ImageLib\Image.h"
extern CImageGrinderApp theApp;
#define COLSIZE 16
/////////////////////////////////////////////////////////////////////////////
// CColorProps dialog
CColorProps::CColorProps(CWnd* pParent /*=NULL*/)
: CDialog(CColorProps::IDD, pParent)
{
//{{AFX_DATA_INIT(CColorProps)
//}}AFX_DATA_INIT
}
void CColorProps::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CColorProps)
DDX_Control(pDX, IDC_WFIMG, m_wfimg);
DDX_Control(pDX, IDC_HLIMG, m_hlimg);
DDX_Control(pDX, IDC_GCIMG, m_gcimg);
DDX_Control(pDX, IDC_SELIMG, m_selimg);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CColorProps, CDialog)
//{{AFX_MSG_MAP(CColorProps)
ON_BN_CLICKED(IDC_GCMOD, OnGcmod)
ON_BN_CLICKED(IDC_HLMOD, OnHlmod)
ON_BN_CLICKED(IDC_SELMOD, OnSelmod)
ON_BN_CLICKED(IDC_WFMOD, OnWfmod)
ON_WM_HSCROLL()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CColorProps message handlers
void CColorProps::OnGcmod()
{
CColorDialog dlg;
if(dlg.DoModal()==IDOK)
{
Grid=dlg.GetColor();
UpdateBitmaps();
}
}
void CColorProps::OnHlmod()
{
CColorDialog dlg;
if(dlg.DoModal()==IDOK)
{
WireHL=dlg.GetColor();
UpdateBitmaps();
}
}
void CColorProps::OnSelmod()
{
CColorDialog dlg;
if(dlg.DoModal()==IDOK)
{
Selection=dlg.GetColor();
UpdateBitmaps();
}
}
void CColorProps::OnWfmod()
{
CColorDialog dlg;
if(dlg.DoModal()==IDOK)
{
Wire=dlg.GetColor();
UpdateBitmaps();
}
}
int CColorProps::DoModal()
{
return CDialog::DoModal();
}
void CColorProps::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
BOOL CColorProps::OnInitDialog()
{
CDialog::OnInitDialog();
CString AppName;
AppName.LoadString(AFX_IDS_APP_TITLE);
Selection=theApp.GetProfileInt(AppName,"SelectionColor",0x00ff00);
Grid=theApp.GetProfileInt(AppName,"GridColor",0xffff00);
Wire=theApp.GetProfileInt(AppName,"WireColor",0x7f6f7f);
WireHL=theApp.GetProfileInt(AppName,"WireHLColor",0xff7fff);
Box=theApp.GetProfileInt(AppName,"BoxColor",0xffffff);
CDC *dc=GetDC();
SelBmp.CreateCompatibleBitmap(dc,COLSIZE,COLSIZE);
GridBmp.CreateCompatibleBitmap(dc,COLSIZE,COLSIZE);
WireBmp.CreateCompatibleBitmap(dc,COLSIZE,COLSIZE);
WireHLBmp.CreateCompatibleBitmap(dc,COLSIZE,COLSIZE);
BoxBmp.CreateCompatibleBitmap(dc,COLSIZE,COLSIZE);
ReleaseDC(dc);
UpdateBitmaps();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CColorProps::OnOK()
{
CString AppName;
AppName.LoadString(AFX_IDS_APP_TITLE);
theApp.WriteProfileInt(AppName,"SelectionColor",Selection);
theApp.WriteProfileInt(AppName,"GridColor",Grid);
theApp.WriteProfileInt(AppName,"WireColor",Wire);
theApp.WriteProfileInt(AppName,"WireHLColor",WireHL);
theApp.WriteProfileInt(AppName,"BoxColor",Box);
CDialog::OnOK();
}
void CColorProps::UpdateBitmaps()
{
CPen pen;
CPoint pt;
pt.x=100;
pt.y=20;
Image img;
img.CreateBlank(COLSIZE,COLSIZE,ITYPE_RGB,24);
BITMAPINFO binf;
binf.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
binf.bmiHeader.biWidth=img.GetWidth();
binf.bmiHeader.biHeight=-img.GetHeight();
binf.bmiHeader.biPlanes=1;
binf.bmiHeader.biBitCount=img.GetBpp();
binf.bmiHeader.biCompression=BI_RGB;
binf.bmiHeader.biSizeImage=0;
binf.bmiHeader.biClrImportant=0;
CDC memdc,*dc=GetDC();
int res;
memdc.CreateCompatibleDC(dc);
memdc.SelectObject(SelBmp);
img.FillColor(ImgRGBColor(Selection));
res=SetDIBitsToDevice(memdc,0,0,
img.GetWidth(),img.GetHeight(),
0,0,0,img.GetHeight(),
img.Lock(),&binf,DIB_RGB_COLORS);
ASSERT(res!=0);
img.UnLock();
memdc.DeleteDC();
m_selimg.SetBitmap(SelBmp);
memdc.CreateCompatibleDC(dc);
memdc.SelectObject(GridBmp);
img.FillColor(ImgRGBColor(Grid));
res=SetDIBitsToDevice(memdc,0,0,
img.GetWidth(),img.GetHeight(),
0,0,0,img.GetHeight(),
img.Lock(),&binf,DIB_RGB_COLORS);
ASSERT(res!=0);
img.UnLock();
memdc.DeleteDC();
m_gcimg.SetBitmap(GridBmp);
memdc.CreateCompatibleDC(dc);
memdc.SelectObject(WireBmp);
img.FillColor(ImgRGBColor(Wire));
res=SetDIBitsToDevice(memdc,0,0,
img.GetWidth(),img.GetHeight(),
0,0,0,img.GetHeight(),
img.Lock(),&binf,DIB_RGB_COLORS);
ASSERT(res!=0);
img.UnLock();
memdc.DeleteDC();
m_wfimg.SetBitmap(WireBmp);
memdc.CreateCompatibleDC(dc);
memdc.SelectObject(WireHLBmp);
img.FillColor(ImgRGBColor(WireHL));
res=SetDIBitsToDevice(memdc,0,0,
img.GetWidth(),img.GetHeight(),
0,0,0,img.GetHeight(),
img.Lock(),&binf,DIB_RGB_COLORS);
ASSERT(res!=0);
img.UnLock();
memdc.DeleteDC();
m_hlimg.SetBitmap(WireHLBmp);
/*
pen.CreatePen(PS_SOLID,1,Grid);
dc->MoveTo(pt);
dc->LineTo(pt.x+50,pt.y);
pen.DeleteObject();
pt.y+=32;
pen.CreatePen(PS_SOLID,1,Selection);
dc->MoveTo(pt);
dc->LineTo(pt.x+50,pt.y);
pen.DeleteObject();
pt.y+=32;
pen.CreatePen(PS_SOLID,1,Wire);
dc->MoveTo(pt);
dc->LineTo(pt.x+50,pt.y);
pen.DeleteObject();
pt.y+=32;
pen.CreatePen(PS_SOLID,1,WireHL);
dc->MoveTo(pt);
dc->LineTo(pt.x+50,pt.y);
pen.DeleteObject();
pt.y+=32;
*/
ReleaseDC(dc);
}
void CColorProps::OnPaint()
{
CPaintDC dc(this); // device context for painting
//UpdateBitmaps();
// Do not call CDialog::OnPaint() for painting messages
}
@@ -0,0 +1,62 @@
#if !defined(AFX_COLORPROPS_H__6F8DDFA4_509E_11D3_8B36_00902712C9AE__INCLUDED_)
#define AFX_COLORPROPS_H__6F8DDFA4_509E_11D3_8B36_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ColorProps.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CColorProps dialog
class CColorProps : public CDialog
{
// Construction
public:
void UpdateBitmaps();
CColorProps(CWnd* pParent = NULL); // standard constructor
COLORREF Selection,Grid,Wire,WireHL,Box;
CBitmap SelBmp,GridBmp,WireBmp,WireHLBmp,BoxBmp;
// Dialog Data
//{{AFX_DATA(CColorProps)
enum { IDD = IDD_COLORPROPS };
CStatic m_wfimg;
CStatic m_hlimg;
CStatic m_gcimg;
CStatic m_selimg;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CColorProps)
public:
virtual int DoModal();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CColorProps)
afx_msg void OnGcmod();
afx_msg void OnHlmod();
afx_msg void OnSelmod();
afx_msg void OnWfmod();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
virtual BOOL OnInitDialog();
virtual void OnOK();
afx_msg void OnPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_COLORPROPS_H__6F8DDFA4_509E_11D3_8B36_00902712C9AE__INCLUDED_)
@@ -0,0 +1,48 @@
// ComposeInfo.cpp: implementation of the CComposeInfo class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "imagegrinder.h"
#include "ComposeInfo.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CComposeInfo::CComposeInfo()
{
//Segs=NULL;
MaxSeg=NumSeg=0;
}
CComposeInfo::~CComposeInfo()
{
/*
if(Segs)
delete Segs;
*/
}
void CComposeInfo::Init(int size)
{
ASSERT(size<1024);
/*
if(Segs)
delete Segs;
Segs=new GridSeg[size];
MaxSeg=size;
NumSeg=0;
*/
MaxSeg=1024;
NumSeg=0;
}
void CComposeInfo::AddSeg(GridSeg &seg)
{
ASSERT(Segs);
ASSERT(NumSeg<=MaxSeg);
Segs[NumSeg++]=seg;
}
@@ -0,0 +1,39 @@
// ComposeInfo.h: interface for the CComposeInfo class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_COMPOSEINFO_H__61B14DF8_21B4_4EF9_AFED_6E4A5936224B__INCLUDED_)
#define AFX_COMPOSEINFO_H__61B14DF8_21B4_4EF9_AFED_6E4A5936224B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CImageGrinderView;
class CImageGrinderDoc;
class GridSeg
{
public:
int row,col;
GridSeg(int r,int c) {row=r; col=c;}
GridSeg() {}
};
class CComposeInfo
{
public:
void AddSeg(GridSeg &);
void Init(int size);
CImageGrinderView* CurView;
CImageGrinderDoc* CurDoc;
GridSeg Segs[1024];
int NumSeg,MaxSeg;
CComposeInfo();
virtual ~CComposeInfo();
};
#endif // !defined(AFX_COMPOSEINFO_H__61B14DF8_21B4_4EF9_AFED_6E4A5936224B__INCLUDED_)
@@ -0,0 +1,102 @@
// DepthDiag.cpp : implementation file
//
#include "stdafx.h"
#include "imagegrinder.h"
#include "DepthDiag.h"
#include "imagegrinderDoc.h"
/////////////////////////////////////////////////////////////////////////////
// CDepthDiag dialog
CDepthDiag::CDepthDiag(CWnd* pParent /*=NULL*/)
: CDialog(CDepthDiag::IDD, pParent)
{
//{{AFX_DATA_INIT(CDepthDiag)
//}}AFX_DATA_INIT
}
void CDepthDiag::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDepthDiag)
DDX_Control(pDX, IDC_DLIST, m_DList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDepthDiag, CDialog)
//{{AFX_MSG_MAP(CDepthDiag)
ON_LBN_SELCHANGE(IDC_DLIST, OnSelchangeDlist)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDepthDiag message handlers
int CDepthDiag::DoModal(CImageGrinderDoc *Doc,CPoint &pnt)
{
int i,depth;
pDoc=Doc;
depth=pDoc->FGrid->ShootRay((unsigned short)pnt.x,(unsigned short)pnt.y);
SelCount=0;
for(i=depth-1;i>0;i--)
{
if(!pDoc->IsLocked(pDoc->FGrid->GetCollectedNr(i)))
SelectedFeature[SelCount++]=pDoc->FGrid->GetCollectedNr(i);
}
return CDialog::DoModal();
}
BOOL CDepthDiag::OnInitDialog()
{
CDialog::OnInitDialog();
int itm;
// TODO: Add extra initialization here
for(int i=0;i<SelCount;i++)
{
itm=m_DList.AddString((char *)(*SelectedFeature[i]->feature->GetName()));
m_DList.SetItemDataPtr(itm,(void *)SelectedFeature[i]);
if(SelectedFeature[i]->StatFlags&FIF_SELECTED)
m_DList.SetSel(itm,TRUE);
BackupSel[i]=*(SelectedFeature[i]);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDepthDiag::OnOK()
{
CDialog::OnOK();
}
void CDepthDiag::OnSelchangeDlist()
{
// TODO: Add your control notification handler code here
for(int i=0;i<m_DList.GetCount();i++)
{
if(m_DList.GetSel(i))
pDoc->AddSelection((Compost::FeatureInstance *)m_DList.GetItemDataPtr(i));
else
pDoc->SubSelection((Compost::FeatureInstance *)m_DList.GetItemDataPtr(i));
}
pDoc->UpdateAllViews(NULL);
}
void CDepthDiag::OnCancel()
{
// pDoc->SelectionCount=BackupCount;
for(int i=0;i<BackupCount;i++)
*(SelectedFeature[i])=BackupSel[i];
pDoc->UpdateAllViews(NULL);
CDialog::OnCancel();
}
@@ -0,0 +1,57 @@
#if !defined(AFX_DEPTHDIAG_H__E4619384_710A_46FA_8BE4_67EDCD914B6E__INCLUDED_)
#define AFX_DEPTHDIAG_H__E4619384_710A_46FA_8BE4_67EDCD914B6E__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DepthDiag.h : header file
//
#include <Compost\FeatureGrid.hpp>
#define MAXDEPSELECTION 1024
/////////////////////////////////////////////////////////////////////////////
// CDepthDiag dialog
class CImageGrinderDoc;
class CDepthDiag : public CDialog
{
// Construction
public:
CDepthDiag(CWnd* pParent = NULL); // standard constructor
Compost::FeatureInstance *SelectedFeature[MAXDEPSELECTION];
Compost::FeatureInstance BackupSel[MAXDEPSELECTION];
int SelCount,BackupCount;
CImageGrinderDoc *pDoc;
// Dialog Data
//{{AFX_DATA(CDepthDiag)
enum { IDD = IDD_DEPTHDIAG };
CListBox m_DList;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDepthDiag)
public:
virtual int DoModal(CImageGrinderDoc *Doc,CPoint &pnt);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CDepthDiag)
virtual BOOL OnInitDialog();
virtual void OnOK();
afx_msg void OnSelchangeDlist();
virtual void OnCancel();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DEPTHDIAG_H__E4619384_710A_46FA_8BE4_67EDCD914B6E__INCLUDED_)
@@ -0,0 +1,43 @@
// EditArea.cpp : implementation file
//
#include "stdafx.h"
#include "imagegrinder.h"
#include "EditArea.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEditArea dialog
CEditArea::CEditArea(CWnd* pParent /*=NULL*/)
: CDialog(CEditArea::IDD, pParent)
{
//{{AFX_DATA_INIT(CEditArea)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CEditArea::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEditArea)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEditArea, CDialog)
//{{AFX_MSG_MAP(CEditArea)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEditArea message handlers
@@ -0,0 +1,46 @@
#if !defined(AFX_EDITAREA_H__F320CFE6_E60E_41C6_9F3E_49C2DAC0BB59__INCLUDED_)
#define AFX_EDITAREA_H__F320CFE6_E60E_41C6_9F3E_49C2DAC0BB59__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// EditArea.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CEditArea dialog
class CEditArea : public CDialog
{
// Construction
public:
CEditArea(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CEditArea)
enum { IDD = IDD_EDITAREA };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CEditArea)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CEditArea)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_EDITAREA_H__F320CFE6_E60E_41C6_9F3E_49C2DAC0BB59__INCLUDED_)
@@ -0,0 +1,63 @@
// ExpAllOpts.cpp : implementation file
//
#include "stdafx.h"
#include "imagegrinder.h"
#include "ExpAllOpts.h"
/////////////////////////////////////////////////////////////////////////////
// CExpAllOpts dialog
CExpAllOpts::CExpAllOpts(CWnd* pParent /*=NULL*/)
: CDialog(CExpAllOpts::IDD, pParent)
{
//{{AFX_DATA_INIT(CExpAllOpts)
m_idata = FALSE;
m_mti = FALSE;
m_singletga = FALSE;
m_tgafiles = FALSE;
m_usedimagelist = FALSE;
m_Material = FALSE;
m_Fgd = FALSE;
m_IGData = FALSE;
m_SingleMat = FALSE;
//}}AFX_DATA_INIT
}
void CExpAllOpts::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CExpAllOpts)
DDX_Check(pDX, IDC_IMAGEDATA, m_idata);
DDX_Check(pDX, IDC_MTINDEX, m_mti);
DDX_Check(pDX, IDC_SINGLETGA, m_singletga);
DDX_Check(pDX, IDC_TGAFILES, m_tgafiles);
DDX_Check(pDX, IDC_USEDIMAGELIST, m_usedimagelist);
DDX_Check(pDX, IDC_MATERIAL, m_Material);
DDX_Check(pDX, IDC_FGD, m_Fgd);
DDX_Check(pDX, IDC_IGDATA, m_IGData);
DDX_Check(pDX, IDC_SINGLEMAT, m_SingleMat);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CExpAllOpts, CDialog)
//{{AFX_MSG_MAP(CExpAllOpts)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExpAllOpts message handlers
BOOL CExpAllOpts::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
@@ -0,0 +1,54 @@
#if !defined(AFX_EXPALLOPTS_H__8BD6596C_B3A6_11D3_8B36_00902712C9AE__INCLUDED_)
#define AFX_EXPALLOPTS_H__8BD6596C_B3A6_11D3_8B36_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ExpAllOpts.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CExpAllOpts dialog
class CExpAllOpts : public CDialog
{
// Construction
public:
CExpAllOpts(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CExpAllOpts)
enum { IDD = IDD_TOTALEXPORTOPTS };
BOOL m_idata;
BOOL m_mti;
BOOL m_singletga;
BOOL m_tgafiles;
BOOL m_usedimagelist;
BOOL m_Material;
BOOL m_Fgd;
BOOL m_IGData;
BOOL m_SingleMat;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CExpAllOpts)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CExpAllOpts)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_EXPALLOPTS_H__8BD6596C_B3A6_11D3_8B36_00902712C9AE__INCLUDED_)
@@ -0,0 +1,51 @@
// ExpOptions.cpp : implementation file
//
#include "stdafx.h"
#include "imagegrinder.h"
#include "ExpOptions.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExpOptions dialog
CExpOptions::CExpOptions(CWnd* pParent /*=NULL*/)
: CDialog(CExpOptions::IDD, pParent)
{
//{{AFX_DATA_INIT(CExpOptions)
m_BName = _T("");
m_savehires = FALSE;
//}}AFX_DATA_INIT
}
void CExpOptions::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CExpOptions)
DDX_Text(pDX, IDC_BASENAME, m_BName);
DDX_Check(pDX, IDC_SAVEHIRES, m_savehires);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CExpOptions, CDialog)
//{{AFX_MSG_MAP(CExpOptions)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExpOptions message handlers
void CExpOptions::OnCancel()
{
// TODO: Add extra cleanup here
// CDialog::OnCancel();
}
@@ -0,0 +1,47 @@
#if !defined(AFX_EXPOPTIONS_H__1D930A01_3932_11D3_80AF_00104BCD3D41__INCLUDED_)
#define AFX_EXPOPTIONS_H__1D930A01_3932_11D3_80AF_00104BCD3D41__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ExpOptions.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CExpOptions dialog
class CExpOptions : public CDialog
{
// Construction
public:
CExpOptions(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CExpOptions)
enum { IDD = IDD_EXPOPTIONS };
CString m_BName;
BOOL m_savehires;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CExpOptions)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CExpOptions)
virtual void OnCancel();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_EXPOPTIONS_H__1D930A01_3932_11D3_80AF_00104BCD3D41__INCLUDED_)
@@ -0,0 +1,564 @@
// FeatureLibDiag.cpp : implementation file
//
#include "stdafx.h"
#include "ImageGrinder.h"
#include "FeatureLibDiag.h"
#include "FeatureLibView.h"
#include "ImageGrinderDoc.h"
#include "FeatureProps.h"
#include "BackGroundProps.h"
#include <Compost\FeaturePool.hpp>
/////////////////////////////////////////////////////////////////////////////
// CFeatureLibDiag dialog
#define SPACEING 5
CFeatureLibDiag::CFeatureLibDiag(CWnd* pParent /*=NULL*/)
: CDialog(CFeatureLibDiag::IDD, pParent)
{
//{{AFX_DATA_INIT(CFeatureLibDiag)
//}}AFX_DATA_INIT
OwnerView=NULL;
CurSel=-1;
}
void CFeatureLibDiag::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFeatureLibDiag)
DDX_Control(pDX, IDC_BACKGROUND, m_BgdProps);
DDX_Control(pDX, IDC_DELETE, m_delbut);
DDX_Control(pDX, IDC_ADD, m_addbut);
DDX_Control(pDX, IDC_FEATURELIST, m_FeatureList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFeatureLibDiag, CDialog)
//{{AFX_MSG_MAP(CFeatureLibDiag)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_NOTIFY(NM_DBLCLK, IDC_FEATURELIST, OnDblclkFeaturelist)
ON_NOTIFY(NM_RCLICK, IDC_FEATURELIST, OnRclickFeaturelist)
ON_NOTIFY(NM_CLICK, IDC_FEATURELIST, OnLclickFeaturelist)
ON_NOTIFY(LVN_BEGINDRAG, IDC_FEATURELIST, OnBegindragFeaturelist)
ON_WM_MOUSEMOVE()
ON_LBN_SELCHANGE(IDC_FEATURELIST, OnSelchangeFeaturelist)
ON_LBN_KILLFOCUS(IDC_FEATURELIST, OnKillfocusFeaturelist)
ON_LBN_SETFOCUS(IDC_FEATURELIST, OnSetfocusFeaturelist)
ON_BN_CLICKED(IDC_BACKGROUND, OnBackground)
ON_LBN_DBLCLK(IDC_FEATURELIST, OnDblclkFeaturelist)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFeatureLibDiag message handlers
void CFeatureLibDiag::OnOK()
{
// TODO: Add extra validation here
// CDialog::OnOK();
}
void CFeatureLibDiag::OnCancel()
{
// TODO: Add extra cleanup here
// CDialog::OnCancel();
}
void CFeatureLibDiag::OnAdd()
{
CFeatureProps dlg;
Compost::Tool_Feature *TmpFet=new Compost::Tool_Feature;
Register_Pointer(TmpFet);
TmpFet->SetName((LPCSTR)MakeDefaultName());
CImageGrinderDoc* pDoc = (CImageGrinderDoc*)OwnerView->GetDocument();
ASSERT_VALID(pDoc);
if(dlg.DoModal(TmpFet,pDoc->FGrid->GetColumns()*pDoc->FGrid->GetGridSize(),pDoc->FGrid->GetRows()*pDoc->FGrid->GetGridSize())==IDOK)
{
pDoc->FPool->Add(TmpFet);
RefreshList();
}
else
{
Unregister_Pointer(TmpFet);
delete TmpFet;
}
}
int CFeatureLibDiag::DoModal()
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::DoModal();
}
CString CFeatureLibDiag::MakeDefaultName()
{
CImageGrinderDoc* pDoc = (CImageGrinderDoc*)OwnerView->GetDocument();
ASSERT_VALID(pDoc);
CString tmp("UnNamed");
return pDoc->MakeNameUnique(tmp);
}
void CFeatureLibDiag::OnDblclkFeaturelist(NMHDR* pNMHDR, LRESULT* pResult)
{
if(OwnerView==NULL) return;
CImageGrinderDoc* pDoc = (CImageGrinderDoc*)OwnerView->GetDocument();
ASSERT_VALID(pDoc);
int curSel = m_FeatureList.GetCurSel();
if(curSel>=0)
{
Compost::Tool_Feature *CurFet;
CurFet=(Compost::Tool_Feature *)m_FeatureList.GetItemData(curSel);
pDoc->AddFeature(CurFet);
pDoc->UpdateAllViews(OwnerView);
*pResult = 0;
}
}
void CFeatureLibDiag::RefreshList()
{
if(OwnerView==NULL) return;
CImageGrinderDoc* pDoc = (CImageGrinderDoc*)OwnerView->GetDocument();
ASSERT_VALID(pDoc);
if(pDoc->FPool==NULL || pDoc->FGrid==NULL) return;
Compost::Tool_Feature *FTexture;
Compost::Feature *Fet;
m_FeatureList.ResetContent();
int itmtot=pDoc->FPool->GetNumberOfFeatures();
for(int i=1;i<itmtot;i++)
{
Fet=pDoc->FPool->GetFeatureNumber(i);
CString feature_name((char *)(*(Fet->GetName())));
if(feature_name.GetLength()>0)
{
// feature_name=pDoc->MakeNameUnique(feature_name);
FTexture=(Compost::Tool_Feature *)Fet;
FTexture->SetName((const char *)(LPCSTR)feature_name);
int pos;
pos=m_FeatureList.AddString((LPCSTR)feature_name);
m_FeatureList.SetItemDataPtr(pos,FTexture);
}
}
SetSelection();
UpdateHLList();
// pDoc->FPool->SaveIndex();
}
void CFeatureLibDiag::SetView(CFeatureLibView *vwe)
{
OwnerView=vwe;
RefreshList();
}
void CFeatureLibDiag::ResizeVert(int cy)
{
CRect sze,brct,crct;
GetWindowRect(&sze);
SetWindowPos(NULL,0,0,sze.Width(),cy,SWP_NOMOVE|SWP_NOZORDER);
int bottom;
GetWindowRect(&sze);
bottom=sze.Height();
m_delbut.GetWindowRect(&brct);
ScreenToClient(brct);
bottom-=brct.Height()+SPACEING;
m_delbut.SetWindowPos(NULL,brct.left,bottom,0,0,SWP_NOSIZE|SWP_NOZORDER);
m_addbut.GetWindowRect(&brct);
ScreenToClient(brct);
bottom-=brct.Height()+SPACEING;
m_addbut.SetWindowPos(NULL,brct.left,bottom,0,0,SWP_NOSIZE|SWP_NOZORDER);
m_BgdProps.GetWindowRect(&crct);
ScreenToClient(crct);
m_FeatureList.GetWindowRect(&brct);
ScreenToClient(brct);
brct.top=SPACEING*2+crct.Height();
brct.bottom=bottom-SPACEING;
m_FeatureList.SetWindowPos(NULL,brct.left,brct.top,brct.Width(),brct.Height(),SWP_NOZORDER);
int thgt=crct.Height();
crct.top=SPACEING;
crct.bottom=crct.top+thgt;
m_BgdProps.SetWindowPos(NULL,crct.left,crct.top,crct.Width(),crct.Height(),SWP_NOZORDER);
}
void CFeatureLibDiag::ResizeHor(int cx)
{
CRect sze,brct;
GetWindowRect(&sze);
SetWindowPos(NULL,0,0,cx,sze.Height(),SWP_NOMOVE|SWP_NOZORDER);
GetClientRect(&sze);
m_delbut.GetWindowRect(&brct);
ScreenToClient(brct);
m_delbut.SetWindowPos(NULL,(sze.Width()-brct.Width())/2,brct.top,0,0,SWP_NOSIZE|SWP_NOZORDER);
m_addbut.GetWindowRect(&brct);
ScreenToClient(brct);
m_addbut.SetWindowPos(NULL,(sze.Width()-brct.Width())/2,brct.top,0,0,SWP_NOSIZE|SWP_NOZORDER);
m_BgdProps.GetWindowRect(&brct);
ScreenToClient(brct);
m_BgdProps.SetWindowPos(NULL,(sze.Width()-brct.Width())/2,brct.top,0,0,SWP_NOSIZE|SWP_NOZORDER);
m_FeatureList.GetWindowRect(&brct);
ScreenToClient(brct);
m_FeatureList.SetWindowPos(NULL,SPACEING,brct.top,sze.Width()-(SPACEING*2),brct.Height(),SWP_NOZORDER);
}
void CFeatureLibDiag::OnRclickFeaturelist(NMHDR* pNMHDR, LRESULT* pResult)
{
int nItem = m_FeatureList.RCPos;
m_FeatureList.SetCurSel(m_FeatureList.RCPos);
if(nItem==-1) return;
CFeatureProps dlg;
CImageGrinderDoc* pDoc = (CImageGrinderDoc*)OwnerView->GetDocument();
ASSERT_VALID(pDoc);
Compost::Tool_Feature *Fet=(Compost::Tool_Feature *)m_FeatureList.GetItemData(nItem);
if(dlg.DoModal(Fet,pDoc->FGrid->GetColumns()*pDoc->FGrid->GetGridSize(),pDoc->FGrid->GetRows()*pDoc->FGrid->GetGridSize())==IDOK)
{
Fet->SetName((LPCSTR)CString(*Fet->GetName()));
RefreshList();
if(OwnerView==NULL) return;
pDoc->FGrid->RedoFeaturePosition();
pDoc->SetDrawFlags();
pDoc->UpdateAllViews(OwnerView);
}
*pResult = 0;
}
void CFeatureLibDiag::OnLclickFeaturelist(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
}
void CFeatureLibDiag::OnBegindragFeaturelist(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
*pResult = 0;
}
void CFeatureLibDiag::OnMouseMove(UINT nFlags, CPoint point)
{
if(nFlags&MK_LBUTTON)
{
}
CDialog::OnMouseMove(nFlags, point);
}
void CFeatureLibDiag::OnSelchangeFeaturelist()
{
CImageGrinderDoc* pDoc = (CImageGrinderDoc*)OwnerView->GetDocument();
ASSERT_VALID(pDoc);
UpdateHLList();
int curSel = m_FeatureList.GetCurSel();
if(curSel>=0)
{
pDoc->CurSelFet=(Compost::Tool_Feature *)m_FeatureList.GetItemData(curSel);
}
else
{
pDoc->CurSelFet=NULL;
}
if(m_FeatureList.Reordered)
{
pDoc->FPool->Move(m_FeatureList.OldPos+1, m_FeatureList.NewPos+1);
pDoc->FGrid->RedoFeaturePosition();
pDoc->SetDrawFlags();
}
pDoc->UpdateAllViews(OwnerView);
}
void CFeatureLibDiag::OnKillfocusFeaturelist()
{
}
void CFeatureLibDiag::OnSetfocusFeaturelist()
{
}
BOOL CFeatureLibDiag::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
return CDialog::OnNotify(wParam, lParam, pResult);
}
void CFeatureLibDiag::OnBackground()
{
if(OwnerView==NULL) return;
CImageGrinderDoc* pDoc = (CImageGrinderDoc*)OwnerView->GetDocument();
ASSERT_VALID(pDoc);
CBackGroundProps dlg;
Compost::Tool_Feature *TmpFet = ((Compost::Tool_Feature *)pDoc->FPool->GetFeatureNumber(0));
if(dlg.DoModal((Compost::Tool_Feature *)pDoc->FPool->GetFeatureNumber(0))==IDOK)
{
if(OwnerView==NULL) return;
if(dlg.m_stretch)
{
TmpFet->SetBlendMode(Compost::Feature::Blend_Mode::StretchPaste);
TmpFet->SetFeatureMask0(TmpFet->GetFeatureTexture());
}
else
TmpFet->SetBlendMode(Compost::Feature::Blend_Mode::Paste);
pDoc->SetDrawFlags();
pDoc->UpdateAllViews(OwnerView);
}
}
void CFeatureLibDiag::InitBackGround()
{
if(OwnerView==NULL) return;
CImageGrinderDoc* pDoc = (CImageGrinderDoc*)OwnerView->GetDocument();
ASSERT_VALID(pDoc);
CBackGroundProps dlg;
Compost::Tool_Feature *TmpFet = new Compost::Tool_Feature;
Register_Pointer(TmpFet);
TmpFet->SetName((LPCSTR)"BackGround");
TmpFet->SetFeatureHeight(pDoc->FGrid->GetRows()*pDoc->FGrid->GetGridSize());
TmpFet->SetFeatureWidth(pDoc->FGrid->GetColumns()*pDoc->FGrid->GetGridSize());
dlg.DoModal(TmpFet);
if(dlg.m_stretch)
{
TmpFet->SetBlendMode(Compost::Feature::Blend_Mode::StretchPaste);
TmpFet->SetFeatureMask0(TmpFet->GetFeatureTexture());
}
else
{
TmpFet->SetBlendMode(Compost::Feature::Blend_Mode::Paste);
}
pDoc->FPool->Insert(TmpFet,0);
pDoc->SetDrawFlags();
pDoc->UpdateAllViews(OwnerView);
RefreshList();
}
void CFeatureLibDiag::SetSelection()
{
int j;
CImageGrinderDoc* pDoc = (CImageGrinderDoc*)OwnerView->GetDocument();
ASSERT_VALID(pDoc);
Compost::Tool_Feature *curfet;
for(j=0;j<m_FeatureList.GetCount();j++)
{
curfet=(Compost::Tool_Feature *)m_FeatureList.GetItemDataPtr(j);
if(pDoc->IsSelected(curfet))
{
m_FeatureList.SetSel(j,TRUE);
}
}
UpdateHLList();
}
void CFeatureLibDiag::UpdateHLList()
{
CImageGrinderDoc* pDoc = (CImageGrinderDoc*)OwnerView->GetDocument();
ASSERT_VALID(pDoc);
int *itm=new int[m_FeatureList.GetSelCount()];
m_FeatureList.GetSelItems(m_FeatureList.GetSelCount(),itm);
pDoc->ClearHL();
for(int i=0;i<m_FeatureList.GetSelCount();i++)
{
pDoc->AddHLFeature((Compost::Tool_Feature *)m_FeatureList.GetItemDataPtr(itm[i]));
}
delete itm;
}
void CFeatureLibDiag::OnDelete()
{
int i,selcount,*sel;
selcount=m_FeatureList.GetSelCount();
sel=new int[selcount];
m_FeatureList.GetSelItems(selcount,sel);
Compost::Tool_Feature *fet;
CImageGrinderDoc* pDoc = (CImageGrinderDoc*)OwnerView->GetDocument();
ASSERT_VALID(pDoc);
for(i=0;i<selcount;i++)
{
fet=(Compost::Tool_Feature *)m_FeatureList.GetItemDataPtr(sel[i]);
pDoc->RemoveFeature(fet);
}
delete sel;
pDoc->UpdateAllViews(NULL);
}
void CFeatureLibDiag::LoadFeatures(CString fname)
{
Stuff::FileStream fstream;
fstream.Open((char *)(LPCSTR)fname,Stuff::FileStream::ReadOnly);
CImageGrinderDoc* pDoc = (CImageGrinderDoc*)OwnerView->GetDocument();
ASSERT_VALID(pDoc);
int selcount,ver;
fstream>>ver;
fstream>>selcount;
for(int i=0;i<selcount;i++)
{
pDoc->FPool->Add(pDoc->FPool->LoadFeature(&fstream,ver));
}
// fstream.Close();
RefreshList();
}
void CFeatureLibDiag::SaveSelectedFeatures(CString str)
{
Stuff::FileStream fstream;
fstream.Open((char *)(LPCSTR)str,Stuff::FileStream::WriteOnly);
CImageGrinderDoc* pDoc = (CImageGrinderDoc*)OwnerView->GetDocument();
ASSERT_VALID(pDoc);
int selcount=m_FeatureList.GetSelCount(),ver=Compost::Current_Compost_Version;
fstream<<ver;
fstream<<selcount;
int *itm=new int[selcount];
m_FeatureList.GetSelItems(selcount,itm);
pDoc->ClearHL();
Stuff::MString *name = NULL;
for(int i=0;i<selcount;i++)
{
name = ((Compost::Tool_Feature *)m_FeatureList.GetItemDataPtr(itm[i]))->GetName();
if(name==NULL)
{
fstream << 0;
}
else
{
fstream << 1;
fstream << *name;
}
pDoc->FPool->SaveFeature(&fstream,((Compost::Tool_Feature *)m_FeatureList.GetItemDataPtr(itm[i])));
}
delete itm;
fstream.Close();
}
void CFeatureLibDiag::SelectUnsed()
{
int j;
CImageGrinderDoc* pDoc = (CImageGrinderDoc*)OwnerView->GetDocument();
ASSERT_VALID(pDoc);
Compost::Tool_Feature *curfet;
for(j=0;j<m_FeatureList.GetCount();j++)
{
curfet=(Compost::Tool_Feature *)m_FeatureList.GetItemDataPtr(j);
const Stuff::DynamicArrayOf<Compost::FeatureInstance*> *FList;
int count;
int CurFet;
Compost::Tool_Feature *feature = NULL;
Compost::Feature_Texture *fTexture = NULL;
curfet->StatFlags|=FIF_SELECTED;
m_FeatureList.SetSel(j,TRUE);
FList=pDoc->FGrid->GetUniqueFeatureInstances(count);
for(CurFet=0;CurFet<count;CurFet++)
{
if((*FList)[CurFet]->feature==curfet)
{
curfet->StatFlags&=~FIF_SELECTED;
m_FeatureList.SetSel(j,FALSE);
}
}
}
//UpdateHLList();
}
@@ -0,0 +1,78 @@
#if !defined(AFX_FEATURELIBDIAG_H__29974841_1810_11D3_A5F1_00902712C9AE__INCLUDED_)
#define AFX_FEATURELIBDIAG_H__29974841_1810_11D3_A5F1_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// FeatureLibDiag.h : header file
//
#include "ListBoxPro.h"
class CFeatureLibView;
/////////////////////////////////////////////////////////////////////////////
// CFeatureLibDiag dialog
class CFeatureLibDiag : public CDialog
{
// Construction
public:
void SaveSelectedFeatures(CString str);
void LoadFeatures(CString fname);
void SetSelection();
void InitBackGround();
void UpdateHLList();
void ResizeVert(int cy);
void ResizeHor(int cx);
void SetView(CFeatureLibView *vwe);
CFeatureLibView *OwnerView;
void RefreshList();
CString MakeDefaultName();
void SelectUnsed();
CFeatureLibDiag(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CFeatureLibDiag)
enum { IDD = IDD_FEATURELIBDIAG };
CButton m_BgdProps;
CButton m_delbut;
CButton m_addbut;
CListBoxPro m_FeatureList;
//}}AFX_DATA
int CurSel;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFeatureLibDiag)
public:
virtual int DoModal();
protected:
virtual void OnOK();
virtual void OnCancel();
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CFeatureLibDiag)
afx_msg void OnAdd();
afx_msg void OnDblclkFeaturelist(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnRclickFeaturelist(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnLclickFeaturelist(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnBegindragFeaturelist(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnSelchangeFeaturelist();
afx_msg void OnKillfocusFeaturelist();
afx_msg void OnSetfocusFeaturelist();
afx_msg void OnBackground();
afx_msg void OnDelete();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_FEATURELIBDIAG_H__29974841_1810_11D3_A5F1_00902712C9AE__INCLUDED_)
@@ -0,0 +1,61 @@
// FeatureLibFrame.cpp : implementation file
//
#include "stdafx.h"
#include "ImageGrinder.h"
#include "FeatureLibFrame.h"
#include "ImageGrinderDoc.h"
/////////////////////////////////////////////////////////////////////////////
// CFeatureLibFrame
IMPLEMENT_DYNCREATE(CFeatureLibFrame, CMDIChildWnd)
CFeatureLibFrame::CFeatureLibFrame()
{
}
CFeatureLibFrame::~CFeatureLibFrame()
{
}
BEGIN_MESSAGE_MAP(CFeatureLibFrame, CMDIChildWnd)
//{{AFX_MSG_MAP(CFeatureLibFrame)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFeatureLibFrame message handlers
void CFeatureLibFrame::Create(CMDIFrameWnd *Parent)
{
CMDIChildWnd::Create(NULL,"Feature Library",WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_CHILD,rectDefault,Parent);
CRect rct;
DiagPanel=new CFeatureLibDiag;
DiagPanel->Create(CFeatureLibDiag::IDD,this);
DiagPanel->GetWindowRect(&rct);
SetWindowPos(NULL,0,0,
rct.Width()+GetSystemMetrics(SM_CXSIZEFRAME)*2,
rct.Height()+GetSystemMetrics(SM_CXSIZEFRAME)+GetSystemMetrics(SM_CYCAPTION),
SWP_NOZORDER|SWP_NOMOVE);
DiagPanel->ShowWindow(SW_SHOW);
}
void CFeatureLibFrame::OnClose()
{
// TODO: Add your message handler code here and/or call default
//CMDIChildWnd::OnClose();
}
void CFeatureLibFrame::SetDocument(CImageGrinderDoc *igdoc)
{
CString str;
str.Format("Feature Library (%s)",igdoc->GetTitle());
SetWindowText(str);
//DiagPanel->SetDocument(igdoc);
}
@@ -0,0 +1,51 @@
#if !defined(AFX_FEATURELIBFRAME_H__29974842_1810_11D3_A5F1_00902712C9AE__INCLUDED_)
#define AFX_FEATURELIBFRAME_H__29974842_1810_11D3_A5F1_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// FeatureLibFrame.h : header file
//
#include "FeatureLibDiag.h"
class CImageGrinderDoc;
/////////////////////////////////////////////////////////////////////////////
// CFeatureLibFrame frame
class CFeatureLibFrame : public CMDIChildWnd
{
DECLARE_DYNCREATE(CFeatureLibFrame)
protected:
CFeatureLibDiag *DiagPanel;
// Attributes
public:
CFeatureLibFrame(); // protected constructor used by dynamic creation
// Operations
public:
void SetDocument(CImageGrinderDoc *igdoc);
void Create(CMDIFrameWnd *Parent=NULL);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFeatureLibFrame)
//}}AFX_VIRTUAL
// Implementation
protected:
virtual ~CFeatureLibFrame();
// Generated message map functions
//{{AFX_MSG(CFeatureLibFrame)
afx_msg void OnClose();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_FEATURELIBFRAME_H__29974842_1810_11D3_A5F1_00902712C9AE__INCLUDED_)
@@ -0,0 +1,155 @@
// FeatureLibView.cpp : implementation file
//
#include "stdafx.h"
#include "imagegrinder.h"
#include "FeatureLibView.h"
/////////////////////////////////////////////////////////////////////////////
// CFeatureLibView
IMPLEMENT_DYNCREATE(CFeatureLibView, CView)
CFeatureLibView::CFeatureLibView()
{
DiagPanel=NULL;
MaxWid=-1;
}
CFeatureLibView::~CFeatureLibView()
{
if(DiagPanel) delete DiagPanel;
}
BEGIN_MESSAGE_MAP(CFeatureLibView, CView)
//{{AFX_MSG_MAP(CFeatureLibView)
ON_WM_SIZE()
ON_COMMAND(ID_FILE_EXPORT_FEATUREFILE, OnFileExportFeaturefile)
ON_COMMAND(ID_FILE_IMPORT_FEATURES, OnFileImportFeatures)
ON_COMMAND(ID_EDIT_SELECTUNUSEDFEATURES, OnEditSelectunusedfeatures)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFeatureLibView drawing
void CFeatureLibView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
}
/////////////////////////////////////////////////////////////////////////////
// CFeatureLibView diagnostics
#ifdef _DEBUG
void CFeatureLibView::AssertValid() const
{
CView::AssertValid();
}
void CFeatureLibView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CFeatureLibView message handlers
BOOL CFeatureLibView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
// CMDIChildWnd::Create(NULL,"Feature Library",WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_CHILD,rectDefault,pParentWnd);
BOOL res;
res= CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
CRect rct;
DiagPanel=new CFeatureLibDiag;
res=DiagPanel->Create(CFeatureLibDiag::IDD,this);
ASSERT(res);
DiagPanel->GetWindowRect(&rct);
SetWindowPos(NULL,0,0,
rct.Width()+GetSystemMetrics(SM_CXSIZEFRAME)*2,
rct.Height()+GetSystemMetrics(SM_CXSIZEFRAME)+GetSystemMetrics(SM_CYCAPTION),
SWP_NOZORDER|SWP_NOMOVE);
DiagPanel->ShowWindow(SW_SHOW);
DiagPanel->SetView(this);
return res;
}
void CFeatureLibView::OnSize(UINT nType, int cx, int cy)
{
if(DiagPanel)
{
CRect sze;
DiagPanel->ResizeVert(cy);
DiagPanel->ResizeHor(cx);
if(MaxWid==-1)
{
CRect rct;
GetClientRect(rct);
DiagPanel->GetWindowRect(&rct);
MaxWid=rct.Width();
}
}
CView::OnSize(nType, cx, cy);
}
int CFeatureLibView::GetMaxWidth()
{
return MaxWid;
}
void CFeatureLibView::OnInitialUpdate()
{
CView::OnInitialUpdate();
ASSERT(DiagPanel);
DiagPanel->SetView(this);
}
void CFeatureLibView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
DiagPanel->RefreshList();
}
void CFeatureLibView::OnFileExportFeaturefile()
{
CFileDialog dlg(FALSE,"igf","List.igf",NULL,"Feature List (*.igf)|*.igf||",NULL);
if(dlg.DoModal()==IDOK)
{
DiagPanel->SaveSelectedFeatures(dlg.GetPathName());
}
}
void CFeatureLibView::OnFileImportFeatures()
{
CFileDialog dlg(TRUE,NULL,NULL,NULL,"Feature List (*.igf)|*.igf||",NULL);
if(dlg.DoModal()==IDOK)
{
DiagPanel->LoadFeatures(dlg.GetPathName());
}
}
void CFeatureLibView::OnEditSelectunusedfeatures()
{
DiagPanel->SelectUnsed();
}
@@ -0,0 +1,62 @@
#if !defined(AFX_FEATURELIBVIEW_H__859FBB41_1A9A_11D3_A5F1_00902712C9AE__INCLUDED_)
#define AFX_FEATURELIBVIEW_H__859FBB41_1A9A_11D3_A5F1_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// FeatureLibView.h : header file
//
#include "FeatureLibDiag.h"
/////////////////////////////////////////////////////////////////////////////
// CFeatureLibView view
class CFeatureLibView : public CView
{
protected:
CFeatureLibView(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(CFeatureLibView)
CFeatureLibDiag *DiagPanel;
// Attributes
public:
// Operations
public:
int GetMaxWidth();
int MaxWid;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFeatureLibView)
public:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
virtual void OnInitialUpdate();
protected:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
//}}AFX_VIRTUAL
// Implementation
protected:
virtual ~CFeatureLibView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
protected:
//{{AFX_MSG(CFeatureLibView)
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnFileExportFeaturefile();
afx_msg void OnFileImportFeatures();
afx_msg void OnEditSelectunusedfeatures();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_FEATURELIBVIEW_H__859FBB41_1A9A_11D3_A5F1_00902712C9AE__INCLUDED_)
@@ -0,0 +1,703 @@
// FeatureProps.cpp : implementation file
//
#include "stdafx.h"
#include "ImageGrinder.h"
#include "FeatureProps.h"
#include "..\..\Libraries\ImageLib\Image.h"
#include <Compost\TexturePool.hpp>
#include <Compost\FeatureGrid.hpp>
#include "ImageCache.h"
const char featureErrorMessages[][255] =
{
"No error.", // 0
"No feature texture set.",
"No mask 0 set.",
"No mask 1 set.",
"Feature texture not in 555 mode.",
"Feature texture not in 4444 mode.", // 5
"Mask 0 not in 1 mode.",
"Mask 1 not in 1 mode.",
"Mask 0 not in 555 mode.",
"Mask 0 not in 1.1 mode.",
"Mask 0 not in 1.MipMap mode.", // 10
"Mask 0 too big for 555_1 mode.",
"Mask 1 too big for 555_2 mode.",
"Mask 0 too small for 555_1_S mode.",
"Feature texture size not power of 2.",
"Mask 0 size not power of 2.", // 15
"Mask 1 size not power of 2.",
};
/////////////////////////////////////////////////////////////////////////////
// CFeatureProps dialog
CFeatureProps::CFeatureProps(CWnd* pParent /*=NULL*/)
: CDialog(CFeatureProps::IDD, pParent)
{
//{{AFX_DATA_INIT(CFeatureProps)
m_fname = _T("");
m_tname = _T("");
m_xoffset = 0;
m_zoffset = 0;
m_Mask0FlipHor = FALSE;
m_Mask0FlipVert = FALSE;
m_Mask1FlipHor = FALSE;
m_Mask1FlipVert = FALSE;
m_TextureFlipHor = FALSE;
m_TextureFlipVert = FALSE;
m_BlendMode = -1;
m_Stretch = FALSE;
//}}AFX_DATA_INIT
}
void CFeatureProps::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFeatureProps)
DDX_Control(pDX, IDC_MATLIST, m_MatList);
DDX_Control(pDX, IDC_MASK1PREVIEW, m_Mask1PreviewPane);
DDX_Control(pDX, IDC_MASK0PREVIEW, m_Mask0PreviewPane);
DDX_Control(pDX, IDC_PREVIEWFRAME, m_PreviewPane);
DDX_Control(pDX, IDC_HEIGHT, m_hcon);
DDX_Control(pDX, IDC_WIDTH, m_wcon);
DDX_Control(pDX, IDC_MASK1LIST, m_Mask1List);
DDX_Control(pDX, IDC_MASK0LIST, m_Mask0List);
DDX_Control(pDX, IDC_TEXTURELIST, m_TextureList);
DDX_Text(pDX, IDC_NAME, m_fname);
DDX_Text(pDX, IDC_XOFF, m_xoffset);
DDX_Text(pDX, IDC_ZOFF, m_zoffset);
DDX_Check(pDX, IDC_MASK0FLIPHOR, m_Mask0FlipHor);
DDX_Check(pDX, IDC_MASK0FLIPVERT, m_Mask0FlipVert);
DDX_Check(pDX, IDC_MASK1FLIPHOR, m_Mask1FlipHor);
DDX_Check(pDX, IDC_MASK1FLIPVERT, m_Mask1FlipVert);
DDX_Check(pDX, IDC_TEXTUREFLIPHOR, m_TextureFlipHor);
DDX_Check(pDX, IDC_TEXTUREFLIPVERT, m_TextureFlipVert);
DDX_CBIndex(pDX, IDC_BLENDMODE, m_BlendMode);
DDX_Check(pDX, IDC_STRETCH, m_Stretch);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFeatureProps, CDialog)
//{{AFX_MSG_MAP(CFeatureProps)
ON_CBN_SELCHANGE(IDC_MASK0LIST, OnSelchangeMask0list)
ON_CBN_SELCHANGE(IDC_MASK1LIST, OnSelchangeMask1list)
ON_CBN_SELCHANGE(IDC_TEXTURELIST, OnSelchangeTexturelist)
ON_CBN_SELCHANGE(IDC_BLENDMODE, OnSelchangeBlendmode)
ON_BN_CLICKED(IDC_STRETCH, OnStretch)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFeatureProps message handlers
int CFeatureProps::DoModal(Compost::Tool_Feature *fet,int maxX,int maxZ)
{
XLen=maxX;
YLen=maxZ;
fetptr=fet;
feature_data=*fetptr;
return CDialog::DoModal();
}
BOOL CFeatureProps::OnInitDialog()
{
CDialog::OnInitDialog();
//Fill ListBoxes;
for(int i=0;i<Compost::MaterialEntriesCount;i++)
{
if(!Compost::MaterialEntries[i].MatName) break;
int itm = m_MatList.AddString((char *)Compost::MaterialEntries[i].MatName);
m_MatList.SetItemData(itm, i);
}
m_MatList.SetCurSel(feature_data.GetMaterial());
m_Stretch = feature_data.IsStretched();
Compost::Feature_Texture *FTexture;
Stuff::TableIteratorOf<Compost::Feature_Texture*, int> imageTableIterator(Compost::TexturePool::Instance->GetImageTable());
int sel;
int idx;
CString texture_name,ttype,basename;
while(NULL!=(FTexture=imageTableIterator.ReadAndNext()))
{
basename=(char *)(*(FTexture->GetName()));
switch(FTexture->GetTextureMode())
{
case Compost::Feature_Texture::NoMode: ttype="None"; break;
case Compost::Feature_Texture::FTT_555: ttype="5"; break;
case Compost::Feature_Texture::FTT_4444: ttype="4";break;
case Compost::Feature_Texture::FTT_1: ttype="1";break;
case Compost::Feature_Texture::FTT_1_1 : ttype="11";break;
case Compost::Feature_Texture::FTT_1_M : ttype="1M";break;
}
texture_name.Format("%s-%s-%ix%i",basename,ttype,FTexture->width,FTexture->height);
if(FTexture->depth!=1)
{
idx=m_TextureList.AddString(texture_name);
m_TextureList.SetItemDataPtr(idx,FTexture);
}
if(FTexture->depth==1)
{
idx=m_Mask0List.AddString(texture_name);
m_Mask0List.SetItemDataPtr(idx,FTexture);
}
if(FTexture->depth==1)
{
idx=m_Mask1List.AddString(texture_name);
m_Mask1List.SetItemDataPtr(idx,FTexture);
}
}
m_Mask0List.InsertString(0,"none");
m_Mask1List.InsertString(0,"none");
sel=0;
for(i=0;i<m_TextureList.GetCount();i++)
{
FTexture=(Compost::Feature_Texture *)m_TextureList.GetItemDataPtr(i);
if(FTexture==feature_data.GetFeatureTexture())
sel=i;
}
m_TextureList.SetCurSel(sel);
if(feature_data.GetBlendMode()!=Compost::Feature::Blend_Mode::StretchMultiply)
{
sel=0;
for(i=0;i<m_Mask0List.GetCount();i++)
{
FTexture=(Compost::Feature_Texture *)m_Mask0List.GetItemDataPtr(i);
if(FTexture==feature_data.GetFeatureMask0())
sel=i;
}
m_Mask0List.SetCurSel(sel);
}
if(sel!=0)
{
sel=0;
for(i=0;i<m_Mask1List.GetCount();i++)
{
FTexture=(Compost::Feature_Texture *)m_Mask1List.GetItemDataPtr(i);
if(FTexture==feature_data.GetFeatureMask1())
sel=i;
}
}
m_Mask1List.SetCurSel(sel);
sel=0;
m_Mask1List.EnableWindow(m_Mask0List.GetCurSel()!=0);
m_fname=CString((const char *)(*(feature_data.GetName())));
// m_xoffset=feature_data.GetTextureXPos();
// m_zoffset=feature_data.GetTextureZPos();
int num;
CString tstr;
m_hcon.ResetContent();
for(num=8;num<=XLen;num<<=1)
{
tstr.Format("%i",num);
m_hcon.AddString(tstr);
}
m_wcon.ResetContent();
for(num=8;num<=YLen;num<<=1)
{
tstr.Format("%i",num);
m_wcon.AddString(tstr);
}
m_wcon.SetCurSel(Compost::GetPow(feature_data.GetFeatureWidth())-3);
m_hcon.SetCurSel(Compost::GetPow(feature_data.GetFeatureHeight())-3);
m_TextureFlipHor = (feature_data.GetFlipMode() & Compost::Feature::Flip_Mode::Texture_Horizontal_Flip) ? true:false;
m_TextureFlipVert = (feature_data.GetFlipMode() & Compost::Feature::Flip_Mode::Texture_Vertical_Flip) ? true:false;
m_Mask0FlipHor = (feature_data.GetFlipMode() & Compost::Feature::Flip_Mode::Mask0_Horizontal_Flip) ? true:false;
m_Mask0FlipVert = (feature_data.GetFlipMode() & Compost::Feature::Flip_Mode::Mask0_Vertical_Flip) ? true:false;
m_Mask1FlipHor = (feature_data.GetFlipMode() & Compost::Feature::Flip_Mode::Mask1_Horizontal_Flip) ? true:false;
m_Mask1FlipVert = (feature_data.GetFlipMode() & Compost::Feature::Flip_Mode::Mask1_Vertical_Flip) ? true:false;
switch(feature_data.GetBlendMode())
{
case Compost::Feature::Blend_Mode::Paste:
m_BlendMode=0;
m_Mask0List.EnableWindow(FALSE);
m_Mask1List.EnableWindow(FALSE);
break;
case Compost::Feature::Blend_Mode::Added:
m_BlendMode=1;
m_Mask0List.EnableWindow(FALSE);
m_Mask1List.EnableWindow(FALSE);
break;
case Compost::Feature::Blend_Mode::Multiply:
m_BlendMode=2;
m_Mask0List.EnableWindow(FALSE);
m_Mask1List.EnableWindow(FALSE);
break;
case Compost::Feature::Blend_Mode::Blend555_1:
m_BlendMode=3;
m_Mask0List.EnableWindow(TRUE);
m_Mask1List.EnableWindow(FALSE);
break;
case Compost::Feature::Blend_Mode::Blend555_2:
m_BlendMode=4;
m_Mask0List.EnableWindow(TRUE);
m_Mask1List.EnableWindow(TRUE);
break;
case Compost::Feature::Blend_Mode::Blend4444:
m_BlendMode=5;
m_Mask0List.EnableWindow(FALSE);
m_Mask1List.EnableWindow(FALSE);
break;
case Compost::Feature::Blend_Mode::StretchMultiply:
m_BlendMode=6;
feature_data.SetFeatureMask0(NULL);
m_Mask0List.EnableWindow(FALSE);
m_Mask1List.EnableWindow(FALSE);
break;
case Compost::Feature::Blend_Mode::Blend555_1_1:
m_BlendMode=7;
m_Mask0List.EnableWindow(TRUE);
m_Mask1List.EnableWindow(FALSE);
break;
case Compost::Feature::Blend_Mode::Blend555_1_S:
m_BlendMode=8;
m_Mask0List.EnableWindow(TRUE);
m_Mask1List.EnableWindow(FALSE);
break;
}
UpdateData(FALSE);
CRect rct;
CDC *pDC=GetDC();
m_PreviewPane.GetClientRect(&rct);
PrvBmp.CreateCompatibleBitmap(pDC,rct.Width(),rct.Height());
m_Mask0PreviewPane.GetClientRect(&rct);
M0Prv.CreateCompatibleBitmap(pDC,rct.Width(),rct.Height());
m_Mask1PreviewPane.GetClientRect(&rct);
M1Prv.CreateCompatibleBitmap(pDC,rct.Width(),rct.Height());
ReleaseDC(pDC);
UpdateMask0Pane();
UpdateMask1Pane();
UpdateTexturePane();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CFeatureProps::OnOK()
{
FillData();
int errorHandle = feature_data.IsValidFeature();
if(errorHandle==0)
{
*fetptr=feature_data;
CDialog::OnOK();
}
else
{
MessageBox(featureErrorMessages[errorHandle], "Something is wrong here", MB_ICONSTOP | MB_OK);
}
}
void CFeatureProps::OnSelchangeMask0list()
{
if(m_Mask0List.GetCurSel()==0)
{
m_Mask1List.SetCurSel(0);
m_Mask1List.EnableWindow(FALSE);
}
else
{
m_Mask1List.EnableWindow(TRUE);
}
UpdateMask0Pane();
}
void CFeatureProps::OnSelchangeMask1list()
{
UpdateMask1Pane();
}
void CFeatureProps::OnSelchangeTexturelist()
{
UpdateTexturePane();
}
void CFeatureProps::FillData()
{
// TODO: Add extra validation here
UpdateData(TRUE);
feature_data.SetName((LPCSTR)m_fname);
// feature_data.SetTextureXPos(m_xoffset & ~15);
// feature_data.SetTextureZPos(m_zoffset & ~15);
feature_data.SetStretchMode(m_Stretch ? 1 : 0);
if(!feature_data.IsStretched())
{
feature_data.SetFeatureWidth(1<<(m_wcon.GetCurSel()+3));
feature_data.SetFeatureHeight(1<<(m_hcon.GetCurSel()+3));
}
else
{
feature_data.SetFeatureWidth(XLen);
feature_data.SetFeatureHeight(YLen);
}
feature_data.SetFeatureTexture((Compost::Feature_Texture *)m_TextureList.GetItemDataPtr(m_TextureList.GetCurSel()));
Compost::Feature_Texture *cft = (Compost::Feature_Texture *)m_Mask0List.GetItemDataPtr(m_Mask0List.GetCurSel());
if((int)cft>0)
{
feature_data.SetFeatureMask0(cft);
}
cft = (Compost::Feature_Texture *)m_Mask1List.GetItemDataPtr(m_Mask1List.GetCurSel());
if((int)cft>0)
{
feature_data.SetFeatureMask1(cft);
}
if(m_TextureFlipHor)
{
feature_data.SetFlipMode(Compost::Feature::Flip_Mode::Texture_Horizontal_Flip);
}
else
{
feature_data.ClearFlipMode(Compost::Feature::Flip_Mode::Texture_Horizontal_Flip);
}
if(m_TextureFlipVert)
{
feature_data.SetFlipMode(Compost::Feature::Flip_Mode::Texture_Vertical_Flip);
}
else
{
feature_data.ClearFlipMode(Compost::Feature::Flip_Mode::Texture_Vertical_Flip);
}
if(m_Mask0FlipHor)
{
feature_data.SetFlipMode(Compost::Feature::Flip_Mode::Mask0_Horizontal_Flip);
}
else
{
feature_data.ClearFlipMode(Compost::Feature::Flip_Mode::Mask0_Horizontal_Flip);
}
if(m_Mask0FlipVert)
{
feature_data.SetFlipMode(Compost::Feature::Flip_Mode::Mask0_Vertical_Flip);
}
else
{
feature_data.ClearFlipMode(Compost::Feature::Flip_Mode::Mask0_Vertical_Flip);
}
if(m_Mask1FlipHor)
{
feature_data.SetFlipMode(Compost::Feature::Flip_Mode::Mask1_Horizontal_Flip);
}
else
{
feature_data.ClearFlipMode(Compost::Feature::Flip_Mode::Mask1_Horizontal_Flip);
}
if(m_Mask1FlipVert)
{
feature_data.SetFlipMode(Compost::Feature::Flip_Mode::Mask1_Vertical_Flip);
}
else
{
feature_data.ClearFlipMode(Compost::Feature::Flip_Mode::Mask1_Vertical_Flip);
}
switch(m_BlendMode)
{
case 0 :feature_data.SetBlendMode(Compost::Feature::Blend_Mode::Paste); break;
case 1 :feature_data.SetBlendMode(Compost::Feature::Blend_Mode::Added); break;
case 2 :feature_data.SetBlendMode(Compost::Feature::Blend_Mode::Multiply); break;
case 3 :feature_data.SetBlendMode(Compost::Feature::Blend_Mode::Blend555_1); break;
case 4 :feature_data.SetBlendMode(Compost::Feature::Blend_Mode::Blend555_2); break;
case 5 :feature_data.SetBlendMode(Compost::Feature::Blend_Mode::Blend4444); break;
case 6 :
{
feature_data.SetBlendMode(Compost::Feature::Blend_Mode::StretchMultiply);
feature_data.SetFeatureMask0((Compost::Feature_Texture *)m_TextureList.GetItemDataPtr(m_TextureList.GetCurSel()));
}
break;
case 7 :feature_data.SetBlendMode(Compost::Feature::Blend_Mode::Blend555_1_1); break;
case 8 :feature_data.SetBlendMode(Compost::Feature::Blend_Mode::Blend555_1_S); break;
}
Compost::TexturePool::Instance->Load(feature_data.GetFeatureTexture());
Compost::TexturePool::Instance->Load(feature_data.GetFeatureMask0());
Compost::TexturePool::Instance->Load(feature_data.GetFeatureMask1());
feature_data.SetMaterial(m_MatList.GetCurSel());
}
void CFeatureProps::UpdateTexturePane()
{
FillData();
if(feature_data.GetFeatureTexture()==NULL) return;
CDC *pDC=GetDC(),memDC;
memDC.CreateCompatibleDC(pDC);
memDC.SelectObject(&PrvBmp);
memDC.SetStretchBltMode(COLORONCOLOR);
CString str;
CString tpath(Compost::TexturePool::Instance->GetTexturePath());
str=(char *)*(((Compost::Feature_Texture *)(m_TextureList.GetItemDataPtr(m_TextureList.GetCurSel())))->GetName());
str=tpath+"\\"+str+".tga";
BITMAP bmp;
PrvBmp.GetBitmap(&bmp);
ImageChain *imgchn=CImageCache::Instance->GetChain(str);
Image *img=imgchn->GetPrvImage();
if(!img)
{
imgchn->BuildPrvImg(bmp.bmWidth+(4-bmp.bmWidth%4),bmp.bmHeight+(4-bmp.bmHeight%4));
img=imgchn->GetPrvImage();
}
BITMAPINFO binf;
binf.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
binf.bmiHeader.biWidth=img->GetWidth();
binf.bmiHeader.biHeight=-img->GetHeight();
binf.bmiHeader.biPlanes=1;
binf.bmiHeader.biBitCount=img->GetBpp();
binf.bmiHeader.biCompression=BI_RGB;
binf.bmiHeader.biSizeImage=0;
binf.bmiHeader.biClrImportant=0;
SetDIBitsToDevice(memDC,0,0,bmp.bmWidth,
bmp.bmHeight,0,0,0,img->GetHeight(),img->Lock(),
&binf,DIB_RGB_COLORS);
img->UnLock();
memDC.DeleteDC();
ReleaseDC(pDC);
m_PreviewPane.SetBitmap(PrvBmp);
}
void CFeatureProps::UpdateMask0Pane()
{
UpdateData(TRUE);
if(m_BlendMode==6) return;
FillData();
if(feature_data.GetFeatureMask0()==NULL) return;
CDC *pDC=GetDC(),memDC;
memDC.CreateCompatibleDC(pDC);
memDC.SelectObject(&M0Prv);
memDC.SetStretchBltMode(COLORONCOLOR);
BITMAP bmp;
M0Prv.GetBitmap(&bmp);
CString str;
CString tpath(Compost::TexturePool::Instance->GetTexturePath());
str=(char *)*(((Compost::Feature_Texture *)(m_Mask0List.GetItemDataPtr(m_Mask0List.GetCurSel())))->GetName());
str=tpath+"\\"+str+".tga";
ImageChain *imgchn=CImageCache::Instance->GetChain(str);
Image *img=imgchn->GetPrvImage();
if(!img)
{
imgchn->BuildPrvImg(bmp.bmWidth+(4-bmp.bmWidth%4),bmp.bmHeight+(4-bmp.bmHeight%4));
img=imgchn->GetPrvImage();
}
BITMAPINFO binf;
binf.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
binf.bmiHeader.biWidth=img->GetWidth();
binf.bmiHeader.biHeight=-img->GetHeight();
binf.bmiHeader.biPlanes=1;
binf.bmiHeader.biBitCount=img->GetBpp();
binf.bmiHeader.biCompression=BI_RGB;
binf.bmiHeader.biSizeImage=0;
binf.bmiHeader.biClrImportant=0;
SetDIBitsToDevice(memDC,0,0,bmp.bmWidth,
bmp.bmHeight,0,0,0,img->GetHeight(),img->Lock(),
&binf,DIB_RGB_COLORS);
img->UnLock();
memDC.DeleteDC();
ReleaseDC(pDC);
m_Mask0PreviewPane.SetBitmap(M0Prv);
}
void CFeatureProps::UpdateMask1Pane()
{
FillData();
if(feature_data.GetFeatureMask1()==NULL) return;
CDC *pDC=GetDC(),memDC;
memDC.CreateCompatibleDC(pDC);
memDC.SelectObject(&M1Prv);
memDC.SetStretchBltMode(COLORONCOLOR);
BITMAP bmp;
M1Prv.GetBitmap(&bmp);
CString str;
CString tpath(Compost::TexturePool::Instance->GetTexturePath());
str=(char *)*(((Compost::Feature_Texture *)(m_Mask1List.GetItemDataPtr(m_Mask1List.GetCurSel())))->GetName());
str=tpath+"\\"+str+".tga";
ImageChain *imgchn=CImageCache::Instance->GetChain(str);
Image *img=imgchn->GetPrvImage();
if(!img)
{
imgchn->BuildPrvImg(bmp.bmWidth+(4-bmp.bmWidth%4),bmp.bmHeight+(4-bmp.bmHeight%4));
img=imgchn->GetPrvImage();
}
BITMAPINFO binf;
binf.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
binf.bmiHeader.biWidth=img->GetWidth();
binf.bmiHeader.biHeight=-img->GetHeight();
binf.bmiHeader.biPlanes=1;
binf.bmiHeader.biBitCount=img->GetBpp();
binf.bmiHeader.biCompression=BI_RGB;
binf.bmiHeader.biSizeImage=0;
binf.bmiHeader.biClrImportant=0;
SetDIBitsToDevice(memDC,0,0,bmp.bmWidth,
bmp.bmHeight,0,0,0,img->GetHeight(),img->Lock(),
&binf,DIB_RGB_COLORS);
img->UnLock();
memDC.DeleteDC();
ReleaseDC(pDC);
m_Mask1PreviewPane.SetBitmap(M1Prv);
}
void CFeatureProps::OnSelchangeBlendmode()
{
UpdateData(TRUE);
switch(m_BlendMode)
{
case 0:
m_Mask0List.EnableWindow(FALSE);
m_Mask1List.EnableWindow(FALSE);
break;
case 1:
m_Mask0List.EnableWindow(FALSE);
m_Mask1List.EnableWindow(FALSE);
break;
case 2:
m_Mask0List.EnableWindow(FALSE);
m_Mask1List.EnableWindow(FALSE);
break;
case 3:
m_Mask0List.EnableWindow(TRUE);
m_Mask1List.EnableWindow(FALSE);
break;
case 4:
m_Mask0List.EnableWindow(TRUE);
m_Mask1List.EnableWindow(TRUE);
break;
case 5:
m_Mask0List.EnableWindow(FALSE);
m_Mask1List.EnableWindow(FALSE);
break;
case 6:
m_Mask0List.EnableWindow(FALSE);
m_Mask1List.EnableWindow(FALSE);
break;
case 7:
m_Mask0List.EnableWindow(TRUE);
m_Mask1List.EnableWindow(FALSE);
m_Mask0List.ResetContent();
Compost::Feature_Texture *FTexture;
Stuff::TableIteratorOf<Compost::Feature_Texture*, int> imageTableIterator(Compost::TexturePool::Instance->GetImageTable());
int sel,i;
int idx;
while(NULL!=(FTexture=imageTableIterator.ReadAndNext()))
{
if(FTexture->depth==1)
{
idx=m_Mask0List.AddString((char *)(*(FTexture->GetName())));
m_Mask0List.SetItemDataPtr(idx,FTexture);
}
}
m_Mask0List.InsertString(0,"none");
sel=0;
for(i=0;i<m_Mask0List.GetCount();i++)
{
FTexture=(Compost::Feature_Texture *)m_Mask0List.GetItemDataPtr(i);
if(FTexture==feature_data.GetFeatureMask0())
sel=i;
}
m_Mask0List.SetCurSel(sel);
break;
}
}
void CFeatureProps::OnStretch()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_wcon.EnableWindow(!m_Stretch);
m_hcon.EnableWindow(!m_Stretch);
}
@@ -0,0 +1,82 @@
#if !defined(AFX_FEATUREPROPS_H__29974843_1810_11D3_A5F1_00902712C9AE__INCLUDED_)
#define AFX_FEATUREPROPS_H__29974843_1810_11D3_A5F1_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// FeatureProps.h : header file
//
#include<Compost\Compost.hpp>
/////////////////////////////////////////////////////////////////////////////
// CFeatureProps dialog
class CFeatureProps : public CDialog
{
// Construction
public:
void FillData();
void UpdateTexturePane();
void UpdateMask0Pane();
void UpdateMask1Pane();
CFeatureProps(CWnd* pParent = NULL); // standard constructor
Compost::Tool_Feature feature_data,*fetptr;
int XLen,YLen;
CBitmap PrvBmp,M0Prv,M1Prv,HFPrv;
// Dialog Data
//{{AFX_DATA(CFeatureProps)
enum { IDD = IDD_FEATUREPROPS };
CComboBox m_MatList;
CStatic m_Mask1PreviewPane;
CStatic m_Mask0PreviewPane;
CStatic m_PreviewPane;
CComboBox m_hcon;
CComboBox m_wcon;
CComboBox m_Mask1List;
CComboBox m_Mask0List;
CComboBox m_TextureList;
CString m_fname;
CString m_tname;
int m_xoffset;
int m_zoffset;
BOOL m_Mask0FlipHor;
BOOL m_Mask0FlipVert;
BOOL m_Mask1FlipHor;
BOOL m_Mask1FlipVert;
BOOL m_TextureFlipHor;
BOOL m_TextureFlipVert;
int m_BlendMode;
BOOL m_Stretch;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFeatureProps)
public:
virtual int DoModal(Compost::Tool_Feature *fet,int maxX,int maxZ);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CFeatureProps)
virtual BOOL OnInitDialog();
virtual void OnOK();
afx_msg void OnSelchangeMask0list();
afx_msg void OnSelchangeMask1list();
afx_msg void OnSelchangeTexturelist();
afx_msg void OnSelchangeBlendmode();
afx_msg void OnStretch();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_FEATUREPROPS_H__29974843_1810_11D3_A5F1_00902712C9AE__INCLUDED_)
@@ -0,0 +1,39 @@
// GridOptions.cpp : implementation file
//
#include "stdafx.h"
#include "imagegrinder.h"
#include "GridOptions.h"
/////////////////////////////////////////////////////////////////////////////
// CGridOptions dialog
CGridOptions::CGridOptions(CWnd* pParent /*=NULL*/)
: CDialog(CGridOptions::IDD, pParent)
{
//{{AFX_DATA_INIT(CGridOptions)
m_PSpace = 0;
//}}AFX_DATA_INIT
}
void CGridOptions::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGridOptions)
DDX_Text(pDX, IDC_PIXELSPACE, m_PSpace);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGridOptions, CDialog)
//{{AFX_MSG_MAP(CGridOptions)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGridOptions message handlers
@@ -0,0 +1,46 @@
#if !defined(AFX_GRIDOPTIONS_H__5153E1E1_384F_11D3_80AF_00104BCD3D41__INCLUDED_)
#define AFX_GRIDOPTIONS_H__5153E1E1_384F_11D3_80AF_00104BCD3D41__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// GridOptions.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CGridOptions dialog
class CGridOptions : public CDialog
{
// Construction
public:
CGridOptions(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CGridOptions)
enum { IDD = IDD_GRIDOPTIONS };
UINT m_PSpace;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CGridOptions)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CGridOptions)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_GRIDOPTIONS_H__5153E1E1_384F_11D3_80AF_00104BCD3D41__INCLUDED_)
@@ -0,0 +1,22 @@
// HFFeature.cpp: implementation of the CHFFeature class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "imagegrinder.h"
#include "HFFeature.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CHFFeature::CHFFeature()
{
}
CHFFeature::~CHFFeature()
{
}
@@ -0,0 +1,23 @@
// HFFeature.h: interface for the CHFFeature class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_HFFEATURE_H__9526D081_6077_11D3_8B36_00902712C9AE__INCLUDED_)
#define AFX_HFFEATURE_H__9526D081_6077_11D3_8B36_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CHFFeature
{
private:
int XLoc,YLoc,XSize,YSize;
public:
CHFFeature();
virtual ~CHFFeature();
};
#endif // !defined(AFX_HFFEATURE_H__9526D081_6077_11D3_8B36_00902712C9AE__INCLUDED_)
@@ -0,0 +1,421 @@
// HFPreview.cpp : implementation file
//
#include "stdafx.h"
#include "imagegrinder.h"
#include "HFPreview.h"
#include "ImageGrinderView.h"
#include "UserValueDlg.h"
/////////////////////////////////////////////////////////////////////////////
// CHFPreview
IMPLEMENT_DYNCREATE(CHFPreview, CFrameWnd)
CHFPreview::CHFPreview()
{
Adjust=false;
}
CHFPreview::~CHFPreview()
{
}
BEGIN_MESSAGE_MAP(CHFPreview, CFrameWnd)
//{{AFX_MSG_MAP(CHFPreview)
ON_WM_PAINT()
ON_WM_CLOSE()
ON_WM_SIZE()
ON_WM_RBUTTONDOWN()
ON_WM_RBUTTONUP()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHFPreview message handlers
void CHFPreview::UpdateWindow()
{
CDC memDC,*hfDC;
hfDC=GetDC();
int res;
BITMAP bmp;
res=BackBuffer.GetBitmap(&bmp);
Verify(res);
BOOL bres;
bres=memDC.CreateCompatibleDC(hfDC);
Verify(bres);
memDC.SelectObject(&BackBuffer);
CRect hfrct;
GetClientRect(&hfrct);
hfDC->SetStretchBltMode(COLORONCOLOR);
bres=hfDC->StretchBlt(0,0,hfrct.Width(),hfrct.Height(),&memDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
Verify(bres);
memDC.DeleteDC();
hfDC->SelectObject(GetStockObject(NULL_BRUSH));
CImageGrinderDoc *pDoc;
pDoc=OwnerView->GetDocument();
CRect drct;
hfDC->SelectObject(&OwnerView->GridPen);
CPoint tpnt=pDoc->NewPlacePoint;
DataToScreen(&tpnt);
hfDC->Ellipse(tpnt.x-5,tpnt.y-5,tpnt.x+5,tpnt.y+5);
int x,y;
CPoint tmppnt;
for(y=0;y<pDoc->FGrid->GetColumns()*pDoc->FGrid->GetGridSize() ;y+=OwnerView->PixelSpace)
{
tmppnt.x=0;
tmppnt.y=y;
DataToScreen(&tmppnt);
hfDC->MoveTo(tmppnt);
tmppnt.x=pDoc->FGrid->GetRows()*pDoc->FGrid->GetGridSize();
tmppnt.y=y;
DataToScreen(&tmppnt);
hfDC->LineTo(tmppnt);
}
for(x=0;x<pDoc->FGrid->GetRows()*pDoc->FGrid->GetGridSize() ;x+=OwnerView->PixelSpace)
{
tmppnt.x=x;
tmppnt.y=0;
DataToScreen(&tmppnt);
hfDC->MoveTo(tmppnt);
tmppnt.x=x;
tmppnt.y=pDoc->FGrid->GetColumns()*pDoc->FGrid->GetGridSize();
DataToScreen(&tmppnt);
hfDC->LineTo(tmppnt);
}
const Stuff::DynamicArrayOf<Compost::FeatureInstance*> *FList;
int count;
int CurFet;
FList=pDoc->FGrid->GetUniqueFeatureInstances(count);
for(CurFet=0;CurFet<count;CurFet++)
{
hfDC->SelectObject(GetStockObject(NULL_BRUSH));
if(OwnerView->WireMode)
{
if(((Compost::Tool_Feature *)(*FList)[CurFet]->feature)->StatFlags&FF_HIGHLIGHTED)
hfDC->SelectObject(&OwnerView->WireHLPen);
else
hfDC->SelectObject(&OwnerView->WirePen);
drct.top=(*FList)[CurFet]->feature_z_pos;
drct.left=(*FList)[CurFet]->feature_x_pos;
drct.bottom=drct.top+(*FList)[CurFet]->feature->GetFeatureHeight()+1;
drct.right=drct.left+(*FList)[CurFet]->feature->GetFeatureWidth()+1;
DataToScreen(&drct);
hfDC->Rectangle(&drct);
}// end of wireframe mode
if((*FList)[CurFet]->StatFlags&FIF_SELECTED)
{
hfDC->SelectObject(&PenSelected);
hfDC->SelectObject(GetStockObject(NULL_BRUSH));
CPoint tl,tr,bl,br,ct;
bl.x=tl.x=(*FList)[CurFet]->feature_x_pos;
tr.y=tl.y=(*FList)[CurFet]->feature_z_pos;
tr.x=br.x=(*FList)[CurFet]->feature_x_pos+(*FList)[CurFet]->feature->GetFeatureWidth()+1;
bl.y=br.y=(*FList)[CurFet]->feature_z_pos+(*FList)[CurFet]->feature->GetFeatureHeight()+1;
ct.x=tl.x+(*FList)[CurFet]->feature->GetFeatureWidth()/2;
ct.y=tl.y+(*FList)[CurFet]->feature->GetFeatureHeight()/2;
// Draw Selected Box
CRect rct;
rct.SetRect(tl,br);
DataToScreen(&rct);
hfDC->Rectangle(&rct);
hfDC->SelectObject(&OwnerView->SolidSel);
rct.left=rct.top=-HANDLESIZE/2;
rct.right=rct.bottom=HANDLESIZE/2;
rct.OffsetRect(ct);
DataToScreen(&rct);
hfDC->Rectangle(&rct);
hfDC->SelectObject(&OwnerView->GreenBrush);
// Draw Streching handles
// rct.left=rct.top=-HANDLESIZE/2; rct.right=rct.bottom=HANDLESIZE/2;
rct.left=rct.top=0; rct.right=rct.bottom=HANDLESIZE;
rct.OffsetRect(tl);
DataToScreen(&rct);
hfDC->Rectangle(&rct);
rct.left=0;
rct.top=-HANDLESIZE;
rct.right=HANDLESIZE;
rct.bottom=0;
rct.OffsetRect(bl);
DataToScreen(&rct);
hfDC->Rectangle(&rct);
rct.left=rct.top=-HANDLESIZE; rct.right=rct.bottom=0;
rct.OffsetRect(br);
DataToScreen(&rct);
hfDC->Rectangle(&rct);
rct.left=-HANDLESIZE;
rct.top=0;
rct.right=0;
rct.bottom=HANDLESIZE;
rct.OffsetRect(tr);
DataToScreen(&rct);
hfDC->Rectangle(&rct);
rct.left=-HANDLESIZE/2;
rct.top=0;
rct.right=HANDLESIZE/2;
rct.bottom=HANDLESIZE;
rct.OffsetRect(tl.x+(tr.x-tl.x)/2,tl.y);
DataToScreen(&rct);
hfDC->Rectangle(&rct);
rct.left=-HANDLESIZE/2;
rct.top=-HANDLESIZE;
rct.right=HANDLESIZE/2;
rct.bottom=0;
rct.OffsetRect(bl.x+(br.x-bl.x)/2,bl.y);
DataToScreen(&rct);
hfDC->Rectangle(&rct);
rct.left=0;
rct.top=-HANDLESIZE/2;
rct.right=HANDLESIZE;
rct.bottom=HANDLESIZE/2;
rct.OffsetRect(tl.x,tl.y+(bl.y-tl.y)/2);
DataToScreen(&rct);
hfDC->Rectangle(&rct);
rct.left=-HANDLESIZE;
rct.top=-HANDLESIZE/2;
rct.right=0;
rct.bottom=HANDLESIZE/2;
rct.OffsetRect(tr.x,tl.y+(br.y-tr.y)/2);
DataToScreen(&rct);
hfDC->Rectangle(&rct);
} // end of idf selected
}// end of feature loop
/*
CRect rct;
for(int CurFet=0;CurFet<pDoc->SelectionCount;CurFet++)
{
hfDC->SelectObject(PenSelected);
hfDC->SelectObject(GetStockObject(NULL_BRUSH));
rct.left=(pDoc->SelectedFeature[CurFet]->feature_x_pos*hfrct.Width())/(pDoc->FGrid->GetColumns()*pDoc->FGrid->GetGridSize());
rct.top=(pDoc->SelectedFeature[CurFet]->feature_z_pos*hfrct.Height())/(pDoc->FGrid->GetRows()*pDoc->FGrid->GetGridSize());
rct.right=rct.left+(pDoc->SelectedFeature[CurFet]->feature->GetFeatureWidth()*hfrct.Width())/(pDoc->FGrid->GetColumns()*pDoc->FGrid->GetGridSize());
rct.bottom=rct.top+(pDoc->SelectedFeature[CurFet]->feature->GetFeatureHeight()*hfrct.Height())/(pDoc->FGrid->GetRows()*pDoc->FGrid->GetGridSize());
hfDC->Rectangle(&rct);
}
*/
ReleaseDC(hfDC);
}
void CHFPreview::OnPaint()
{
CPaintDC dc(this); // device context for painting
UpdateWindow();
// Do not call CFrameWnd::OnPaint() for painting messages
}
BOOL CHFPreview::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);;
}
void CHFPreview::Initalize(CImageGrinderView *view)
{
OwnerView=view;
CDC *hfDC,memDC;
LOGBRUSH lb;
lb.lbColor=0x00ff00;
lb.lbStyle=BS_SOLID;
PenSelected.CreatePen(PS_DOT,1,&lb);
hfDC=GetDC();
BOOL bres;
bres=BackBuffer.CreateCompatibleBitmap(hfDC,4,4);
Verify(bres);
memDC.CreateCompatibleDC(hfDC);
memDC.SelectObject(&BackBuffer);
memDC.BitBlt(0,0,4,4,NULL,0,0,BLACKNESS);
memDC.DeleteDC();
ReleaseDC(hfDC);
}
void CHFPreview::OnClose()
{
ShowWindow(SW_HIDE);
// CFrameWnd::OnClose();
}
void CHFPreview::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
BITMAP bmp;
BackBuffer.GetBitmap(&bmp);
int ph;
ph=((cx*bmp.bmHeight)/bmp.bmWidth)+GetSystemMetrics(SM_CYCAPTION);
if(Adjust==false)
{
if(cy!=ph)
{
Adjust=true;
SetWindowPos(NULL,0,0,cx,ph,SWP_NOMOVE|SWP_NOZORDER);
}
}
else
{
Adjust=false;
}
}
void CHFPreview::DataToScreen(CPoint *pnt)
{
CRect hfrct;
GetClientRect(&hfrct);
CImageGrinderDoc *pDoc;
pDoc=OwnerView->GetDocument();
pnt->x=(pnt->x*hfrct.Width())/(pDoc->FGrid->GetColumns()*pDoc->FGrid->GetGridSize());
pnt->y=(pnt->y*hfrct.Height())/(pDoc->FGrid->GetRows()*pDoc->FGrid->GetGridSize());
}
void CHFPreview::DataToScreen(CRect *rct)
{
CRect hfrct;
GetClientRect(&hfrct);
CImageGrinderDoc *pDoc;
pDoc=OwnerView->GetDocument();
rct->left=(rct->left*hfrct.Width())/(pDoc->FGrid->GetColumns()*pDoc->FGrid->GetGridSize());
rct->right=(rct->right*hfrct.Width())/(pDoc->FGrid->GetColumns()*pDoc->FGrid->GetGridSize());
rct->top=(rct->top*hfrct.Height())/(pDoc->FGrid->GetRows()*pDoc->FGrid->GetGridSize());
rct->bottom=(rct->bottom*hfrct.Height())/(pDoc->FGrid->GetRows()*pDoc->FGrid->GetGridSize());
}
void CHFPreview::ScreenToData(CPoint *pnt)
{
CRect hfrct;
GetClientRect(&hfrct);
CImageGrinderDoc *pDoc;
pDoc=OwnerView->GetDocument();
pnt->x=(pnt->x*(pDoc->FGrid->GetColumns()*pDoc->FGrid->GetGridSize()))/hfrct.Width();
pnt->y=(pnt->y*(pDoc->FGrid->GetRows()*pDoc->FGrid->GetGridSize()))/hfrct.Height();
}
void CHFPreview::ScreenToData(CRect *rct)
{
CRect hfrct;
GetClientRect(&hfrct);
CImageGrinderDoc *pDoc;
pDoc=OwnerView->GetDocument();
rct->left=(rct->left*(pDoc->FGrid->GetColumns()*pDoc->FGrid->GetGridSize()))/hfrct.Width();
rct->right=(rct->right*(pDoc->FGrid->GetColumns()*pDoc->FGrid->GetGridSize()))/hfrct.Width();
rct->top=(rct->top*(pDoc->FGrid->GetRows()*pDoc->FGrid->GetGridSize()))/hfrct.Height();
rct->bottom=(rct->bottom*(pDoc->FGrid->GetRows()*pDoc->FGrid->GetGridSize()))/hfrct.Height();
}
void CHFPreview::UpdateHF()
{
CImageGrinderDoc *pDoc;
pDoc=OwnerView->GetDocument();
CDC memDC,*hfDC;
hfDC=GetDC();
BackBuffer.DeleteObject();
BOOL bres;
bres=BackBuffer.CreateCompatibleBitmap(hfDC,pDoc->FinalHF.GetWidth(),pDoc->FinalHF.GetHeight());
Verify(bres);
memDC.CreateCompatibleDC(hfDC);
memDC.SelectObject(&BackBuffer);
BITMAPINFOHEADER bhd;
BITMAPINFO binf;
bhd.biSize=sizeof(BITMAPINFOHEADER);
bhd.biWidth=pDoc->FinalHF.GetWidth(); bhd.biHeight=-pDoc->FinalHF.GetHeight();
bhd.biPlanes=1;
bhd.biBitCount=pDoc->FinalHF.GetBpp();
bhd.biCompression=BI_RGB;
bhd.biSizeImage=0;
bhd.biClrImportant=0;
binf.bmiHeader=bhd;
BYTE *imgdat=(BYTE *)(pDoc->FinalHF.Lock());
SetDIBitsToDevice(memDC,0,0,pDoc->FinalHF.GetWidth(),
pDoc->FinalHF.GetHeight(),0,0,0,pDoc->FinalHF.GetWidth(),imgdat,
&binf,DIB_RGB_COLORS);
pDoc->FinalHF.UnLock();
memDC.DeleteDC();
ReleaseDC(hfDC);
UpdateWindow();
}
void CHFPreview::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CFrameWnd::OnRButtonDown(nFlags, point);
}
void CHFPreview::OnRButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CUserValueDlg dlg;
int tmp=128;
CImageGrinderDoc *pDoc;
pDoc=OwnerView->GetDocument();
CPoint tpnt=point;
ScreenToData(&tpnt);
Compost::FeatureInstance *fetint=pDoc->GetTopFeature(tpnt);
if(fetint)
{
Compost::Tool_Feature *fet=(Compost::Tool_Feature *)fetint->feature;
dlg.DoModal(this,&(fet->BlendVal));
}
CFrameWnd::OnRButtonUp(nFlags, point);
}
@@ -0,0 +1,64 @@
#if !defined(AFX_HFPREVIEW_H__FBE35A6C_DDA3_4F1F_A29B_19007BC5614D__INCLUDED_)
#define AFX_HFPREVIEW_H__FBE35A6C_DDA3_4F1F_A29B_19007BC5614D__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// HFPreview.h : header file
//
#include "..\..\Libraries\ImageLib\Image.h"
/////////////////////////////////////////////////////////////////////////////
// CHFPreview frame
class CImageGrinderView;
class CHFPreview : public CFrameWnd
{
DECLARE_DYNCREATE(CHFPreview)
protected:
// Attributes
public:
CHFPreview(); // protected constructor used by dynamic creation
virtual ~CHFPreview();
CBitmap BackBuffer;
CImageGrinderView *OwnerView;
CPen PenSelected;
// Operations
public:
void UpdateHF();
void DataToScreen(CPoint *pnt);
void DataToScreen(CRect *rct);
void ScreenToData(CPoint *pnt);
void ScreenToData(CRect *rct);
bool Adjust;
void Initalize(CImageGrinderView *);
void UpdateWindow();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CHFPreview)
public:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CHFPreview)
afx_msg void OnPaint();
afx_msg void OnClose();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_HFPREVIEW_H__FBE35A6C_DDA3_4F1F_A29B_19007BC5614D__INCLUDED_)
@@ -0,0 +1,192 @@
// HeightField.cpp: implementation of the HeightField class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "imagegrinder.h"
#include "HeightField.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
HeightField::HeightField()
{
}
void HeightField::HFBlendBlt(HeightField &img,RECT dst,RECT &src,HFBLENDMODE bmode,int UserVal)
{
int dr,db;
int xd,yd;
int ddx,ddy;
ddx=dst.right-dst.left;
ddy=dst.bottom-dst.top;
xd=src.right-src.left;
yd=src.bottom-src.top;
dst.right-=xpos;
dst.left-=xpos;
dst.bottom-=ypos;
dst.top-=ypos;
if(src.left>=(img.xpos+img.xlen) || src.top>=(img.ypos+img.ylen) ||
src.right<=img.xpos || src.bottom<img.ypos ) return;
//left clip
if(src.left<=img.xpos) //fix source move dest.
{ dst.left+=(img.xpos-src.left)*ddx/xd; src.left=0;}
else //fix destination move source
src.left-=img.xpos;
if(src.top<=img.ypos) //fix source move dest.
{ dst.top+=(img.ypos-src.top)*ddy/yd; src.top=0; }
else //fix destination move source
src.top-=img.ypos;
//right clip
if(src.right>(img.xpos+img.xlen))
{
dst.right-=(src.right-(img.xpos+img.xlen))*ddx/xd;
src.right=img.xlen;
}
else
src.right=img.xlen-((img.xlen+img.xpos)-src.right);
if(src.bottom>(img.ypos+img.ylen))
{
dst.bottom-=(src.bottom-(img.ypos+img.ylen))*ddy/yd;
src.bottom=img.ylen;
}
else
src.bottom=img.ylen-((img.ylen+img.ypos)-src.bottom);
if(dst.left<0) { src.left-=dst.left*img.xlen/ddx; dst.left=0; }
if(dst.top<0) { src.top-=dst.top*img.ylen/ddy; dst.top=0; }
if(dst.right>xlen) { src.right=src.left+(xlen-dst.left)*xd/ddx; dr=xlen;}
else {dr=dst.right; }
if(dst.bottom>ylen){ src.bottom=src.top+(ylen-dst.top)*yd/ddy; db=ylen; }
else {db=dst.bottom; }
dst.right=dr;
dst.bottom=db;
if(src.right<=0 || src.bottom<=0 ||
src.left>=img.xlen || src.top>=img.ylen) return;
BYTE *dptS=img.Lock(),*dptD=Lock();
if((dst.right-dst.left)==(src.right-src.left) && (dst.bottom-dst.top)==(src.bottom-src.top))
{//Pure Copy
int psizeS=(img.Bpp>>3),psizeD=(Bpp>>3);
int sp=img.GetPitch()-(src.right-src.left)*psizeS,dp=GetPitch()-(dst.right-dst.left)*psizeD;
int x,y;
ImgRGBColor srccol,dstcol;
RGBPixel *tptr;
BYTE *tdptS=dptS+(src.left+src.top*img.GetWidth())*psizeS,*tdptD=dptD+(dst.left+dst.top*GetWidth())*psizeD;
switch(bmode)
{
case HFB_COPY:
for(y=dst.top;y<dst.bottom;y++,tdptS+=sp,tdptD+=dp)
for(x=dst.left;x<dst.right;x++,tdptS+=psizeS,tdptD+=psizeD)
{
tptr=(RGBPixel *)(tdptS);
srccol.Set(*tptr,img.Mask);
tptr=(RGBPixel *)(tdptD);
tptr->Set(srccol,Mask);
}
break;
case HFB_ADD:
for(y=dst.top;y<dst.bottom;y++,tdptS+=sp,tdptD+=dp)
for(x=dst.left;x<dst.right;x++,tdptS+=psizeS,tdptD+=psizeD)
{
tptr=(RGBPixel *)(tdptS);
srccol.Set(*tptr,img.Mask);
tptr=(RGBPixel *)(tdptD);
dstcol.Set(*tptr,Mask);
dstcol+=srccol;
dstcol.Bound();
tptr->Set(dstcol,Mask);
}
break;
case HFB_SUBTRACT:
for(y=dst.top;y<dst.bottom;y++,tdptS+=sp,tdptD+=dp)
for(x=dst.left;x<dst.right;x++,tdptS+=psizeS,tdptD+=psizeD)
{
tptr=(RGBPixel *)(tdptS);
srccol.Set(*tptr,img.Mask);
tptr=(RGBPixel *)(tdptD);
dstcol.Set(*tptr,Mask);
dstcol.SetBounded(dstcol.r-srccol.r,dstcol.g-srccol.g,dstcol.b-srccol.b);
tptr->Set(dstcol,Mask);
}
break;
case HFB_BLEND:
for(y=dst.top;y<dst.bottom;y++,tdptS+=sp,tdptD+=dp)
for(x=dst.left;x<dst.right;x++,tdptS+=psizeS,tdptD+=psizeD)
{
tptr=(RGBPixel *)(tdptS);
srccol.Set(*tptr,img.Mask);
tptr=(RGBPixel *)(tdptD);
dstcol.Set(*tptr,Mask);
dstcol.SetBounded(dstcol.r+(((srccol.r)*UserVal)>>8),
dstcol.g+(((srccol.g)*UserVal)>>8),
dstcol.b+(((srccol.b)*UserVal)>>8));
tptr->Set(dstcol,Mask);
}
break;
case HFB_INVBLEND:
for(y=dst.top;y<dst.bottom;y++,tdptS+=sp,tdptD+=dp)
for(x=dst.left;x<dst.right;x++,tdptS+=psizeS,tdptD+=psizeD)
{
tptr=(RGBPixel *)(tdptS);
srccol.Set(*tptr,img.Mask);
tptr=(RGBPixel *)(tdptD);
dstcol.Set(*tptr,Mask);
dstcol.SetBounded( ((dstcol.r*(255-srccol.r))>>8)+(((srccol.r)*UserVal)>>8),
((dstcol.g*(255-srccol.g))>>8)+(((srccol.g)*UserVal)>>8),
((dstcol.b*(255-srccol.b))>>8)+(((srccol.b)*UserVal)>>8));
tptr->Set(dstcol,Mask);
}
break;
default:
GENFERR("Unimplemented Blend Mode");
}
}
else
{
GENFERR("Stretchy Blts not supported in HF's");
}
UnLock();
img.UnLock();
}
HeightField::~HeightField()
{
}
@@ -0,0 +1,26 @@
// HeightField.h: interface for the HeightField class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_HEIGHTFIELD_H__46D028E1_5A10_11D3_8B36_00902712C9AE__INCLUDED_)
#define AFX_HEIGHTFIELD_H__46D028E1_5A10_11D3_8B36_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <ImageLib\Image.h>
class HeightField : public Image
{
public:
int XLoc,YLoc,XSize,YSize;
enum HFBLENDMODE {HFB_COPY,HFB_ADD,HFB_SUBTRACT,HFB_BLEND,HFB_INVBLEND};
HeightField();
void HFBlendBlt(HeightField &img,RECT dst,RECT &src,HFBLENDMODE bmode,int UserVal=0);
virtual ~HeightField();
};
#endif // !defined(AFX_HEIGHTFIELD_H__46D028E1_5A10_11D3_8B36_00902712C9AE__INCLUDED_)
@@ -0,0 +1,305 @@
// ImageCache.cpp: implementation of the CImageCache class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "imagegrinder.h"
#include "ImageCache.h"
ImageChain::ImageChain()
{
HFImg=NULL;
PrvImg=NULL;
TNImg=NULL;
}
ImageChain::~ImageChain()
{
if(HFImg) delete HFImg;
if(PrvImg) delete PrvImg;
if(TNImg) delete TNImg;
}
void ImageChain::BuildHFImg(int nx,int ny)
{
if(HFImg) delete HFImg;
HFImg=new Image;
Image tmpimg;
tmpimg=OrgImg;
tmpimg.MakeGrayscalePalette();
tmpimg.MakeRGB24();
HFImg->CreateBlank(nx,ny,ITYPE_RGB,24);
HFImg->Blt(tmpimg,
CRect(0,0,HFImg->GetWidth(),HFImg->GetHeight()),
CRect(0,0,tmpimg.GetWidth(),tmpimg.GetHeight())
);
HFImg->MaskTo(RGBMask(0x0000ff,0x00ff00,0xff0000));
}
void ImageChain::BuildPrvImg(int nx,int ny)
{
if(PrvImg) delete PrvImg;
PrvImg=new Image;
Image tmpimg;
tmpimg=OrgImg;
tmpimg.MakeGrayscalePalette();
tmpimg.MakeRGB24();
PrvImg->CreateBlank(nx,ny,ITYPE_RGB,24);
PrvImg->Blt(tmpimg,
CRect(0,0,PrvImg->GetWidth(),PrvImg->GetHeight()),
CRect(0,0,tmpimg.GetWidth(),tmpimg.GetHeight())
);
PrvImg->MaskTo(RGBMask(0xff0000,0x00ff00,0x0000ff));
}
void ImageChain::BuildTNImg(int nx,int ny)
{
if(TNImg) delete TNImg;
TNImg=new Image;
Image tmpimg;
tmpimg=OrgImg;
tmpimg.MakeGrayscalePalette();
tmpimg.MakeRGB24();
TNImg->CreateBlank(nx,ny,ITYPE_RGB,24);
TNImg->Blt(tmpimg,
CRect(0,0,TNImg->GetWidth(),TNImg->GetHeight()),
CRect(0,0,tmpimg.GetWidth(),tmpimg.GetHeight())
);
TNImg->MaskTo(RGBMask(0xff0000,0x00ff00,0x0000ff));
}
Image *ImageChain::GetImage()
{
return &OrgImg;
}
Image *ImageChain::GetHFImage()
{
if(!HFImg) return NULL;
return HFImg;
}
Image *ImageChain::GetPrvImage()
{
if(!PrvImg) return NULL;
return PrvImg;
}
Image *ImageChain::GetTNImage()
{
if(!TNImg) return NULL;
return TNImg;
}
void ImageChain::LoadImg(CString str)
{
OrgImg.Load((char *)(LPCSTR)str);
}
void ImageChain::SaveChain(FILE *fl)
{
char tag[7]="IMGCHN";
char ver[4]="1.0";
char flag;
fwrite(tag,6,1,fl);
fwrite(ver,3,1,fl);
OrgImg.SaveTga(fl);
if(HFImg)
{
flag=1; fwrite(&flag,1,1,fl);
HFImg->SaveTga(fl);
}
else
{ flag=0; fwrite(&flag,1,1,fl); }
if(PrvImg)
{
flag=1; fwrite(&flag,1,1,fl);
PrvImg->SaveTga(fl);
}
else
{ flag=0; fwrite(&flag,1,1,fl); }
if(TNImg)
{
flag=1; fwrite(&flag,1,1,fl);
TNImg->SaveTga(fl);
}
else
{ flag=0; fwrite(&flag,1,1,fl); }
}
void ImageChain::LoadChain(FILE *fl)
{
char tag[7];
char ver[4];
char flag;
fread(tag,6,1,fl);
fread(ver,3,1,fl);
OrgImg.LoadTga(fl);
Image *img;
fread(&flag,1,1,fl);
if(flag)
{
img=new Image;
img->LoadTga(fl);
HFImg=img;
}
fread(&flag,1,1,fl);
if(flag)
{
img=new Image;
img->LoadTga(fl);
PrvImg=img;
}
fread(&flag,1,1,fl);
if(flag)
{
img=new Image;
img->LoadTga(fl);
TNImg=img;
}
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CImageCache *CImageCache::Instance=NULL;
CImageCache::CImageCache()
{
ImgTot=0;
}
CImageCache::~CImageCache()
{
Clear();
}
void CImageCache::Clear()
{
for(int i=0;i<ImgTot;i++) delete ISet[i];
ImgTot=0;
}
void CImageCache::InitInstance()
{
Instance=new CImageCache;
}
ImageChain *CImageCache::GetChain(CString &str)
{
int i;
for(i=0;i<ImgTot && str.CompareNoCase(ISet[i]->GetImage()->GetFileName());i++) ;
if(i<ImgTot)
return ISet[i];
else
{
ISet[ImgTot]=new ImageChain;
ISet[ImgTot]->LoadImg(str);
ImgTot++;
return ISet[ImgTot-1];
}
}
void CImageCache::SaveCache(CString fname)
{
FILE *fl;
fl=fopen(fname,"wb");
ASSERT(fl);
SaveCache(fl);
fclose(fl);
}
void CImageCache::LoadCache(CString fname)
{
FILE *fl;
fl=fopen(fname,"rb");
if(!fl) return; //never crash because of the Cache
LoadCache(fl);
fclose(fl);
}
void CImageCache::SaveCache(FILE *fl)
{
char tag[7]="IMGCHE";
char ver[4]="1.0";
fwrite(tag,6,1,fl);
fwrite(ver,3,1,fl);
fwrite(&ImgTot,4,1,fl);
for(int i=0;i<ImgTot;i++)
{
ISet[i]->SaveChain(fl);
}
}
void CImageCache::LoadCache(FILE *fl)
{
char tag[7];
char ver[4];
fread(tag,6,1,fl);
fread(ver,3,1,fl);
fread(&ImgTot,4,1,fl);
ImageChain *icn;
for(int i=0;i<ImgTot;i++)
{
icn=new ImageChain;
icn->LoadChain(fl);
ISet[i]=icn;
}
}
BOOL CImageCache::LoadNextImage(int x,int y)
{
for(int idx=0;idx<ImgTot;idx++)
{
if(ISet[idx]->GetPrvImage()==NULL)
{
ISet[idx]->BuildPrvImg(x,y);
return TRUE;
}
}
return FALSE;
}
@@ -0,0 +1,62 @@
// ImageCache.h: interface for the CImageCache class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_IMAGECACHE_H__46D028E9_5A10_11D3_8B36_00902712C9AE__INCLUDED_)
#define AFX_IMAGECACHE_H__46D028E9_5A10_11D3_8B36_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "..\..\Libraries\ImageLib\Image.h"
#define MAXIMAGES 1024
class ImageChain
{
protected:
Image OrgImg;
Image *HFImg;
Image *PrvImg;
Image *TNImg;
public:
ImageChain();
void LoadImg(CString str);
void BuildHFImg(int nx,int ny);
void BuildPrvImg(int nx,int ny);
void BuildTNImg(int nx,int ny);
Image *GetImage();
Image *GetHFImage();
Image *GetPrvImage();
Image *GetTNImage();
void SaveChain(FILE *fl);
void LoadChain(FILE *fl);
~ImageChain();
};
class CImageCache
{
protected:
ImageChain *ISet[MAXIMAGES];
int ImgTot;
public:
static void InitInstance();
ImageChain *GetChain(CString &str);
BOOL LoadNextImage(int x,int y);
void SaveCache(CString fname);
void LoadCache(CString fname);
void SaveCache(FILE *fl);
void LoadCache(FILE *fl);
void Clear();
CImageCache();
static CImageCache *Instance;
virtual ~CImageCache();
};
#endif // !defined(AFX_IMAGECACHE_H__46D028E9_5A10_11D3_8B36_00902712C9AE__INCLUDED_)
Binary file not shown.
@@ -0,0 +1,356 @@
// ImageGrinder.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "ImageGrinder.h"
#include "MainFrm.h"
#include "ChildFrm.h"
#include "ImageGrinderDoc.h"
#include "ImageGrinderView.h"
#include "ImageCache.h"
#include "TextureLibFrame.h"
#include <Compost\TexturePool.hpp>
#include <DLLPlatform\DLLPlatform.hpp>
#include <Process.h>
unsigned int TNTThreadID=0;
HANDLE HandleTNTThread;
CRITICAL_SECTION TNTCriticalSection;
HANDLE KillTNTEvent;
unsigned int __stdcall TNTThread(void *dat);
/////////////////////////////////////////////////////////////////////////////
// CImageGrinderApp
BEGIN_MESSAGE_MAP(CImageGrinderApp, CWinApp)
//{{AFX_MSG_MAP(CImageGrinderApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CImageGrinderApp construction
CImageGrinderApp::CImageGrinderApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CImageGrinderApp object
CImageGrinderApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CImageGrinderApp initialization
BOOL CImageGrinderApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Microsoft\\ArtTools"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_IMAGEGTYPE,
RUNTIME_CLASS(CImageGrinderDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CImageGrinderView));
AddDocTemplate(pDocTemplate);
InitGameOS(NULL, NULL, "StartGOS");
Stuff::InitializeClasses();
Stuff::ArmorLevel=1;
CImageCache::InitInstance();
#if defined(USE_TIME_ANALYSIS) && defined(TRACE_ENABLED)
long TraceLogSize = 1000000;
Stuff::TraceManager::Instance->CreateTraceLog(TraceLogSize, true);
#endif
Compost::TexturePool::Instance = new Compost::TexturePool;
Register_Pointer(Compost::TexturePool::Instance);
char tdir[MAX_PATH];
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// The main window has been initialized, so show and update it.
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
pMainFrame->Init();
GetCurrentDirectory(MAX_PATH,tdir);
OrgDir=tdir;
OrgDir+="\\";
CString sloc(OrgDir);
sloc+="ImageGrinder.ICH";
// CImageCache::Instance->LoadCache(sloc);
#if 1 // jcem
InitializeCriticalSection( &TNTCriticalSection );
KillTNTEvent=CreateEvent( NULL, false, false, NULL );
HandleTNTThread=(HANDLE)_beginthreadex( 0, 1024, TNTThread, (void* )pMainFrame, 0, &TNTThreadID );
#else // original
_beginthread(TNTThread,1024,(void* )pMainFrame);
#endif
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if(cmdInfo.m_nShellCommand!=CCommandLineInfo::FileNew)
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// CG: The following block was inserted by the 'Document Registration' component.
{
// Enable DDE Execute open
EnableShellOpen();
RegisterShellFileTypes(TRUE);
m_pMainWnd->DragAcceptFiles();
}
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CImageGrinderApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CImageGrinderApp message handlers
int CImageGrinderApp::ExitInstance()
{
Unregister_Pointer(Compost::TexturePool::Instance);
delete Compost::TexturePool::Instance;
// TODO: Add your specialized code here and/or call the base class
/*
CString sloc=GetProfileString("Settings","TexturePath","c:");
sloc+="\\";
*/
CString sloc(OrgDir);
sloc+="ImageGrinder.ICH";
// CImageCache::Instance->SaveCache(sloc);
Stuff::TerminateClasses();
ExitGameOS();
return CWinApp::ExitInstance();
}
void InitializeGameEngine()
{
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void DoGameLogic()
{
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void UpdateDisplay()
{
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void TerminateGameEngine()
{
//
//-------------------
// Turn off libraries
//-------------------
//
}
void
DumpScene(const char* name)
{
}
//
// Setup the GameOS structure
//
void __stdcall GetGameOSEnvironment( char* CommandLine )
{
CommandLine=CommandLine;
Environment.applicationName = "TCT";
Environment.screenWidth = 640;
Environment.screenHeight = 480;
Environment.fullScreen = FALSE;
Environment.bitDepth = 16;
Environment.debugLog = ""; //"DebugLog.txt";
Environment.spew = ""; //"GameOS*";
Environment.UpdateRenderers = NULL;
Environment.DoGameLogic = NULL;
Environment.InitializeGameEngine = NULL;
Environment.TerminateGameEngine = NULL;
Environment.Renderer = 0;
Environment.FullScreenDevice = 0;
Environment.AntiAlias = 0; // true/false - Enable full screen antialiasing
//
// Texture infomation
//
Environment.Texture_S_256 = 13;
Environment.Texture_S_128 = 12;
Environment.Texture_S_64 = 1;
Environment.Texture_S_32 = 1;
Environment.Texture_S_16 = 1;
Environment.Texture_K_256 = 1;
Environment.Texture_K_128 = 1;
Environment.Texture_K_64 = 1;
Environment.Texture_K_32 = 1;
Environment.Texture_K_16 = 1;
Environment.Texture_A_256 = 1;
Environment.Texture_A_128 = 1;
Environment.Texture_A_64 = 1;
Environment.Texture_A_32 = 1;
Environment.Texture_A_16 = 1;
}
BOOL CImageGrinderApp::OnIdle(LONG lCount)
{
/*
BOOL ret,ret2;
CMainFrame* pMainFrame = (CMainFrame*)m_pMainWnd;
ret=false;
if(pMainFrame)
ret=pMainFrame->OnIdle();
ret2=CWinApp::OnIdle(lCount);
return ret || ret2;
*/
return CWinApp::OnIdle(lCount);
}
unsigned int __stdcall TNTThread(void *dat)
{
CMainFrame* pMainFrame = (CMainFrame*)dat;
HANDLE EventHandles[2];
EventHandles[0]=KillTNTEvent;
//EventHandles[1]=TNTEvent;
while( WaitForMultipleObjects( 1, EventHandles, FALSE, 10) == WAIT_TIMEOUT )
// WAIT_OBJECT_0+1 // Kill event will always be checked first
{
//EnterCriticalSection( &TNTCriticalSection );
if (!pMainFrame->OnIdle())
break;
//LeaveCriticalSection( &TNTCriticalSection );
}
_endthreadex(0);
return 0;
}
void DestroyTNTThread()
{
if( HandleTNTThread )
{
SetEvent( KillTNTEvent );
WaitForSingleObject( HandleTNTThread, INFINITE );
CloseHandle( HandleTNTThread );
DeleteCriticalSection( &TNTCriticalSection );
CloseHandle( KillTNTEvent );
HandleTNTThread=0;
}
}
@@ -0,0 +1,389 @@
# Microsoft Developer Studio Project File - Name="ImageGrinder" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=ImageGrinder - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "ImageGrinder.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "ImageGrinder.mak" CFG="ImageGrinder - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "ImageGrinder - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "ImageGrinder - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE "ImageGrinder - Win32 Profile" (based on "Win32 (x86) Application")
!MESSAGE "ImageGrinder - Win32 Armor" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""$/GameLeapCode/mw4/Tools/ImageGrinder", RJKAAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "ImageGrinder - Win32 Release"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../../rel.bin"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /YX /FD /c
# ADD CPP /nologo /G6 /Zp4 /MD /W3 /Zi /O2 /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "TOOLBUILD" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
# ADD LINK32 Ws2_32.lib /nologo /subsystem:windows /debug /machine:I386
!ELSEIF "$(CFG)" == "ImageGrinder - Win32 Debug"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../../../dbg.bin"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /YX /FD /GZ /c
# ADD CPP /nologo /G6 /Zp4 /MDd /W3 /GR /ZI /Od /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /D "_ARMOR" /D "_DEBUG" /D "_MBCS" /D "MFC" /D "LAB_ONLY" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "TOOLBUILD" /FR /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 Ws2_32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
!ELSEIF "$(CFG)" == "ImageGrinder - Win32 Profile"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Profile"
# PROP BASE Intermediate_Dir "Profile"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../../pro.bin"
# PROP Intermediate_Dir "Profile"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G6 /Zp4 /MD /W3 /O2 /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /YX /FD /c
# ADD CPP /nologo /G6 /Zp4 /MD /W3 /Zi /Ox /Ot /Oa /Og /Oi /Gy /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /D "MFC" /D "NDEBUG" /D "LAB_ONLY" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "TOOLBUILD" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
# ADD LINK32 Ws2_32.lib /nologo /subsystem:windows /debug /machine:I386
!ELSEIF "$(CFG)" == "ImageGrinder - Win32 Armor"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "ImageGrinder___Win32_Armor"
# PROP BASE Intermediate_Dir "ImageGrinder___Win32_Armor"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../../arm.bin"
# PROP Intermediate_Dir "Armor"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G6 /Zp4 /MD /W3 /Zi /O2 /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "MFC" /YX /FD /c
# ADD CPP /nologo /G6 /Zp4 /MD /W3 /GR /Zi /Ox /Ot /Oa /Og /Oi /Gy /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /D "NDEBUG" /D "MFC" /D "_ARMOR" /D "LAB_ONLY" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "TOOLBUILD" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386
# ADD LINK32 Ws2_32.lib /nologo /subsystem:windows /pdb:"Armor/ImageGrinder.pdb" /debug /machine:I386
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "ImageGrinder - Win32 Release"
# Name "ImageGrinder - Win32 Debug"
# Name "ImageGrinder - Win32 Profile"
# Name "ImageGrinder - Win32 Armor"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\BackGroundProps.cpp
# End Source File
# Begin Source File
SOURCE=.\ChildFrm.cpp
# End Source File
# Begin Source File
SOURCE=.\ColorProps.cpp
# End Source File
# Begin Source File
SOURCE=.\ComposeInfo.cpp
# End Source File
# Begin Source File
SOURCE=.\DepthDiag.cpp
# End Source File
# Begin Source File
SOURCE=.\ExpAllOpts.cpp
# End Source File
# Begin Source File
SOURCE=.\FeatureLibDiag.cpp
# End Source File
# Begin Source File
SOURCE=.\FeatureLibFrame.cpp
# End Source File
# Begin Source File
SOURCE=.\FeatureLibView.cpp
# End Source File
# Begin Source File
SOURCE=.\FeatureProps.cpp
# End Source File
# Begin Source File
SOURCE=.\GridOptions.cpp
# End Source File
# Begin Source File
SOURCE=.\ImageCache.cpp
# End Source File
# Begin Source File
SOURCE=.\ImageGrinder.cpp
# End Source File
# Begin Source File
SOURCE=.\ImageGrinder.rc
# End Source File
# Begin Source File
SOURCE=.\ImageGrinderDoc.cpp
# End Source File
# Begin Source File
SOURCE=.\ImageGrinderView.cpp
# End Source File
# Begin Source File
SOURCE=.\ListBoxPro.cpp
# End Source File
# Begin Source File
SOURCE=.\MainFrm.cpp
# End Source File
# Begin Source File
SOURCE=.\ModifyPath.cpp
# End Source File
# Begin Source File
SOURCE=.\NewGridDlg.cpp
# End Source File
# Begin Source File
SOURCE=.\POutOpts.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# End Source File
# Begin Source File
SOURCE=.\TextureLibDiag.cpp
# End Source File
# Begin Source File
SOURCE=.\TextureLibFrame.cpp
# End Source File
# Begin Source File
SOURCE=.\UndoManager.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\BackGroundProps.h
# End Source File
# Begin Source File
SOURCE=.\ChildFrm.h
# End Source File
# Begin Source File
SOURCE=.\ColorProps.h
# End Source File
# Begin Source File
SOURCE=.\ComposeInfo.h
# End Source File
# Begin Source File
SOURCE=.\DepthDiag.h
# End Source File
# Begin Source File
SOURCE=.\ExpAllOpts.h
# End Source File
# Begin Source File
SOURCE=.\FeatureLibDiag.h
# End Source File
# Begin Source File
SOURCE=.\FeatureLibFrame.h
# End Source File
# Begin Source File
SOURCE=.\FeatureLibView.h
# End Source File
# Begin Source File
SOURCE=.\FeatureProps.h
# End Source File
# Begin Source File
SOURCE=.\GridOptions.h
# End Source File
# Begin Source File
SOURCE=.\ImageCache.h
# End Source File
# Begin Source File
SOURCE=.\ImageGrinder.h
# End Source File
# Begin Source File
SOURCE=.\ImageGrinderDoc.h
# End Source File
# Begin Source File
SOURCE=.\ImageGrinderView.h
# End Source File
# Begin Source File
SOURCE=.\ListBoxPro.h
# End Source File
# Begin Source File
SOURCE=.\MainFrm.h
# End Source File
# Begin Source File
SOURCE=.\ModifyPath.h
# End Source File
# Begin Source File
SOURCE=.\NewGridDlg.h
# End Source File
# Begin Source File
SOURCE=.\POutOpts.h
# End Source File
# Begin Source File
SOURCE=.\Resource.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# Begin Source File
SOURCE=.\TextureLibDiag.h
# End Source File
# Begin Source File
SOURCE=.\TextureLibFrame.h
# End Source File
# Begin Source File
SOURCE=.\UndoManager.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\res\bitmap1.bmp
# End Source File
# Begin Source File
SOURCE=.\res\icon1.ico
# End Source File
# Begin Source File
SOURCE=.\res\ImageGrinder.ico
# End Source File
# Begin Source File
SOURCE=.\res\ImageGrinder.rc2
# End Source File
# Begin Source File
SOURCE=.\res\ImageGrinderDoc.ico
# End Source File
# Begin Source File
SOURCE=.\res\Toolbar.bmp
# End Source File
# End Group
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# End Target
# End Project
@@ -0,0 +1,149 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "Compost"=..\..\Libraries\Compost\Compost.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "DLLPlatform"=..\..\..\CoreTech\Libraries\DLLPlatform\DLLPlatform.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "ElementRenderer"=..\..\Libraries\ElementRenderer\ElementRenderer.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "GameOS"=..\..\..\CoreTech\Libraries\GameOS\GameOS.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "ImageGrinder"=.\ImageGrinder.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name ImageLib
End Project Dependency
Begin Project Dependency
Project_Dep_Name GameOS
End Project Dependency
Begin Project Dependency
Project_Dep_Name Stuff
End Project Dependency
Begin Project Dependency
Project_Dep_Name DLLPlatform
End Project Dependency
Begin Project Dependency
Project_Dep_Name ElementRenderer
End Project Dependency
Begin Project Dependency
Project_Dep_Name MLR
End Project Dependency
Begin Project Dependency
Project_Dep_Name gosFX
End Project Dependency
Begin Project Dependency
Project_Dep_Name Compost
End Project Dependency
}}}
###############################################################################
Project: "ImageLib"=..\..\Libraries\ImageLib\ImageLib.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "MLR"=..\..\Libraries\MLR\MLR.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "Stuff"=..\..\Libraries\Stuff\Stuff.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "gosFX"=..\..\Libraries\gosFX\gosFX.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
@@ -0,0 +1,61 @@
// ImageGrinder.h : main header file for the IMAGEGRINDER application
//
#if !defined(AFX_IMAGEGRINDER_H__1B275CE3_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_)
#define AFX_IMAGEGRINDER_H__1B275CE3_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
#define FF_HIGHLIGHTED 1<<0
#define FIF_SELECTED 1<<0
#define FIF_HIDDEN 1<<1
#define FIF_LOCKED 1<<2
#define FIF_WSTEXTURE 1<<3
class CImageGrinderDoc;
extern CImageGrinderDoc *DocList[];
extern int DocCount;
/////////////////////////////////////////////////////////////////////////////
// CImageGrinderApp:
// See ImageGrinder.cpp for the implementation of this class
//
class CImageGrinderApp : public CWinApp
{
public:
CImageGrinderApp();
CString OrgDir;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CImageGrinderApp)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
virtual BOOL OnIdle(LONG lCount);
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CImageGrinderApp)
afx_msg void OnAppAbout();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_IMAGEGRINDER_H__1B275CE3_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_)
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,157 @@
// ImageGrinderDoc.h : interface of the CImageGrinderDoc class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_IMAGEGRINDERDOC_H__1B275CEB_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_)
#define AFX_IMAGEGRINDERDOC_H__1B275CEB_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_
#include <Compost\FeatureGrid.hpp>
#include "UndoManager.h"
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define MAXSELECTION 1024
#define HANDLESIZE 10
#define HF_NONE 0
#define HF_TOP 1<<0
#define HF_BOTTOM 1<<1
#define HF_LEFT 1<<2
#define HF_RIGHT 1<<3
class CImageGrinderDoc : public CDocument
{
protected: // create from serialization only
CImageGrinderDoc();
DECLARE_DYNCREATE(CImageGrinderDoc)
// Attributes
public:
Compost::FeatureGrid *FGrid;
Compost::FeaturePool *FPool;
Compost::Tool_Feature *CurSelFet;
UndoManager UndoMan;
bool *UpdateList,ManualUpdate;
CPoint NewPlacePoint;
// HeightField BaseHF,FinalHF;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CImageGrinderDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
virtual BOOL OnSaveDocument(LPCTSTR lpszPathName);
//}}AFX_VIRTUAL
// Implementation
public:
CString MapPath();
void SaveIGDataToGame();
void SaveToGame();
void SaveAs(LPCTSTR lpszPathName,int xoffset=0,int zoffset=0);
void SaveFgd(LPCTSTR lpszPathName,int xoffset=0,int zoffset=0);
void SaveText(LPCTSTR lpszPathName,int xoffset=0,int zoffset=0);
void OpenFgd(LPCTSTR lpszPathName);
void OpenText(LPCTSTR lpszPathName);
void CloseCurrent();
void PostLoadInit();
// void BuildHF();
// void LoadBaseHF();
// void LoadBaseHF(CString &str);
void RemoveFeature(Compost::Tool_Feature *fet);
void ClearSelection();
void UnLockAll();
bool IsHLFeature(Compost::FeatureInstance *fetint);
void CloneSelection();
CString MakeNameUnique(CString &str);
bool InList(CString &str);
void MakeSelectedUnique();
void MakeUnique(Compost::FeatureInstance *fetint);
Compost::FeatureInstance *Clone(Compost::FeatureInstance *fetint);
Compost::FeatureInstance *GetTopSelected(CPoint &pnt);
Compost::FeatureInstance *GetTopFeature(CPoint &pnt);
DWORD IsOnScaleHandle(CPoint &pnt,Compost::FeatureInstance *fetint);
bool IsOnSelectHandle(CPoint &pnt,Compost::FeatureInstance *fetint);
bool IsOnSelectHandle(CPoint &pnt);
bool InSelectedRegion(CPoint &pnt);
bool IsSelected(Compost::FeatureInstance *fetint);
bool IsSelected(Compost::Tool_Feature *fet);
void DeleteSelected();
void SetDrawFlags(Compost::Feature *fet);
void SetDrawFlags(Compost::FeatureInstance *fet);
void SetDrawFlags();
void SelectionByList(CPoint &pnt);
void NewSelection(CRect &pnt);
void AddSelection(CRect &pnt);
void SubSelection(CRect &pnt);
void NewSelection(CPoint &pnt);
void SavePosForUndo();
void AddSelection(CPoint &pnt);
void SubSelection(CPoint &pnt);
void NewSelection(Compost::FeatureInstance *fet);
void AddSelection(Compost::FeatureInstance *fet);
void SubSelection(Compost::FeatureInstance *fet);
void OffsetSelection(int x,int y);
void AddFeature(Compost::Feature *fet);
void AddFeature(Compost::Feature *fet,int x,int y);
void AddFeature(int x,int y) { if(CurSelFet) AddFeature(CurSelFet,x,y); }
virtual ~CImageGrinderDoc();
void ClearHL();
void AddHLFeature(Compost::Tool_Feature *fet);
void SubHLFeature(Compost::Tool_Feature *fet);
void LockSelection();
void LockFeature(Compost::FeatureInstance *fet);
void UnLockFeature(Compost::FeatureInstance *fet);
bool IsLocked(Compost::FeatureInstance *fet);
void MakeWorldSpaceTexture(Compost::FeatureInstance *fet);
void MakeLocalTexture(Compost::FeatureInstance *fet);
void MakeSelectionWorldSpaceTexture();
void MakeSelectionLocalTexture();
void SetFlagOnSelection(UINT flg);
void ClearFlagOnSelection(UINT flg);
void GroupSelection();
void UnGroupSelection();
int GetAvailableTag();
void SelectGroupMembers(Compost::FeatureInstance *fet);
void DeSelectGroupMembers(Compost::FeatureInstance *fet);
void ExportMaterialMap(CString &path);
void ExportSingleMaterialMap(CString &path);
int SnapMask;
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
public:
//{{AFX_MSG(CImageGrinderDoc)
afx_msg void OnFileExportTgafiles();
afx_msg void OnFileExportImagedata();
afx_msg void OnFileExportSingletga();
afx_msg void OnFileMergefeatures();
afx_msg void OnFileExportUsedimagelist();
afx_msg void OnFileExportMaterialmap();
afx_msg void OnFileExportSinglematerialmap();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_IMAGEGRINDERDOC_H__1B275CEB_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_)
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,165 @@
// ImageGrinderView.h : interface of the CImageGrinderView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_IMAGEGRINDERVIEW_H__1B275CED_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_)
#define AFX_IMAGEGRINDERVIEW_H__1B275CED_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "..\..\Libraries\ImageLib\Image.h"
#include "ImageGrinderDoc.h"
#include "ComposeInfo.h"
#include <afxmt.h>
class CImageGrinderView : public CView
{
protected: // create from serialization only
CImageGrinderView();
DECLARE_DYNCREATE(CImageGrinderView)
CBrush GreenBrush;
int ViewMode, ProcRunning;
// CHFPreview *PreviewWin;
CCriticalSection ProcLock;
SYSTEM_INFO sysinfo;
CComposeInfo *ProcInfo;
bool FirstMove;
Init();
// Attributes
public:
CImageGrinderDoc* GetDocument();
CPoint OldPointView,OldPointSel,ViewOrg,OrgPoint;
CPen PenSelected,SolidSel,GridPen,BoxPen,WirePen,WireHLPen;
Compost::FeatureInstance *HanFet;
int ViewScale;
DWORD HanFlag;
bool Grid,Helpers,WireMode,DragFlag,CanCopy;
int DragIn;
int PixelSpace;
CRect DragRect;
Image CompleteImage;
bool RenderLowRes;
// CBitMap ScreenBuf;
// CBitmap *ImageBuf;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CImageGrinderView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
virtual void OnInitialUpdate();
protected:
virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
// Implementation
public:
void DeletePens();
void CreatePens();
void ComposeList(CComposeInfo &);
void UpdatePPoint();
void DataToScreen(CPoint *pt);
void DataToScreen(CRect *rct);
void ScreenToData(CPoint *pt);
void ScreenToData(CRect *rct);
void ClearWindow();
void CenterBitmap();
void ComposeBackBuffer();
void ForceSingleProc();
void DetectProcs();
int ProcCount();
void UpdateWindow();
virtual ~CImageGrinderView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CImageGrinderView)
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg void OnEditAddfeature();
afx_msg void OnEditDeletefeature();
afx_msg void OnViewDepthview();
afx_msg void OnUpdateViewDepthview(CCmdUI* pCmdUI);
afx_msg void OnTestTest1();
afx_msg void OnTestXsnap1();
afx_msg void OnTestXsnap2();
afx_msg void OnTestXsnap8();
afx_msg void OnTestXsnap16();
afx_msg void OnTestXsnap4();
afx_msg void OnUpdateTestXsnap1(CCmdUI* pCmdUI);
afx_msg void OnUpdateTestXsnap16(CCmdUI* pCmdUI);
afx_msg void OnUpdateTestXsnap2(CCmdUI* pCmdUI);
afx_msg void OnUpdateTestXsnap4(CCmdUI* pCmdUI);
afx_msg void OnUpdateTestXsnap8(CCmdUI* pCmdUI);
afx_msg void OnViewGridoptions();
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnEditMakeunique();
afx_msg void OnViewGrid();
afx_msg void OnUpdateViewGrid(CCmdUI* pCmdUI);
afx_msg void OnViewHelpers();
afx_msg void OnUpdateViewHelpers(CCmdUI* pCmdUI);
afx_msg void OnViewWiremode();
afx_msg void OnUpdateViewWiremode(CCmdUI* pCmdUI);
afx_msg void OnViewColorproperties();
afx_msg void OnEditLockselection();
afx_msg void OnEditUnlockall();
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnEditUngroupselection();
afx_msg void OnEditGroupselection();
afx_msg void OnViewZoomin();
afx_msg void OnViewZoomout();
afx_msg void OnEditGlobaltextures();
afx_msg void OnEditLocaltextures();
afx_msg void OnFileExportPartialoutput();
afx_msg void OnFileExportMaptextureindex();
afx_msg void OnFileExportAll();
afx_msg void OnViewManualupdate();
afx_msg void OnUpdateViewManualupdate(CCmdUI* pCmdUI);
afx_msg void OnViewUpdate();
afx_msg void OnTestRenderlowres();
afx_msg void OnUpdateTestRenderlowres(CCmdUI* pCmdUI);
afx_msg void OnOptionsForcesingleproc();
afx_msg void OnUpdateOptionsForcesingleproc(CCmdUI* pCmdUI);
afx_msg void OnEditUndo();
afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI);
afx_msg void OnEditRedo();
afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in ImageGrinderView.cpp
inline CImageGrinderDoc* CImageGrinderView::GetDocument()
{ return (CImageGrinderDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_IMAGEGRINDERVIEW_H__1B275CED_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_)
@@ -0,0 +1,121 @@
// ListBoxPro.cpp : implementation file
//
#include "stdafx.h"
#include "imagegrinder.h"
#include "ListBoxPro.h"
/////////////////////////////////////////////////////////////////////////////
// CListBoxPro
CListBoxPro::CListBoxPro()
{
Reordered=false;
Selection=0;
}
CListBoxPro::~CListBoxPro()
{
}
BEGIN_MESSAGE_MAP(CListBoxPro, CListBox)
//{{AFX_MSG_MAP(CListBoxPro)
ON_WM_RBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDBLCLK()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CListBoxPro message handlers
void CListBoxPro::OnRButtonDown(UINT nFlags, CPoint point)
{
RCPos=-1;
NMHDR nmhdr;
nmhdr.hwndFrom=m_hWnd;
nmhdr.idFrom=GetDlgCtrlID();
nmhdr.code=NM_RCLICK;
UINT item;
BOOL outside;
item=ItemFromPoint(point,outside);
if(!outside)
{
RCPos=item;
}
GetParent()->SendMessage(WM_NOTIFY,GetDlgCtrlID(),(DWORD)&nmhdr);
CListBox::OnRButtonDown(nFlags, point);
}
void CListBoxPro::OnLButtonUp(UINT nFlags, CPoint point)
{
CListBox::OnLButtonUp(nFlags, point);
}
void CListBoxPro::OnLButtonDown(UINT nFlags, CPoint point)
{
NMHDR nmhdr;
nmhdr.hwndFrom=m_hWnd;
nmhdr.idFrom=GetDlgCtrlID();
nmhdr.code=NM_CLICK;
Reordered=false;
CListBox::OnLButtonDown(nFlags, point);
OldPos=Selection=GetCurSel();
GetParent()->SendMessage(WM_NOTIFY,GetDlgCtrlID(),(DWORD)&nmhdr);
}
void CListBoxPro::OnMouseMove(UINT nFlags, CPoint point)
{
CListBox::OnMouseMove(nFlags, point);
if(nFlags&MK_LBUTTON)
{
int newSel;
newSel=GetCurSel();
if(newSel!=Selection)
{
DWORD dat=GetItemData(Selection);
void *dpt=GetItemDataPtr(Selection);
CString str;
GetText(Selection,str);
DeleteString(Selection);
int pos=InsertString(newSel,str);
SetItemDataPtr(pos,dpt);
SetItemData(pos,dat);
NewPos=Selection=newSel;
SetCurSel(Selection);
Reordered=true;
}
}
}
BOOL CListBoxPro::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
void CListBoxPro::OnLButtonDblClk(UINT nFlags, CPoint point)
{
NMHDR nmhdr;
nmhdr.hwndFrom=m_hWnd;
nmhdr.idFrom=GetDlgCtrlID();
nmhdr.code=NM_DBLCLK;
GetParent()->SendMessage(WM_NOTIFY,GetDlgCtrlID(),(DWORD)&nmhdr);
// CListBox::OnLButtonDblClk(nFlags, point);
}
@@ -0,0 +1,53 @@
#if !defined(AFX_LISTBOXPRO_H__C6BF9A28_1F1B_11D3_A5F1_00902712C9AE__INCLUDED_)
#define AFX_LISTBOXPRO_H__C6BF9A28_1F1B_11D3_A5F1_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ListBoxPro.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CListBoxPro window
class CListBoxPro : public CListBox
{
// Construction
public:
CListBoxPro();
// Attributes
bool Reordered;
int OldPos,NewPos;
int RCPos;
// Operations
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CListBoxPro)
public:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
//}}AFX_VIRTUAL
// Implementation
virtual ~CListBoxPro();
// Generated message map functions
protected:
int Selection;
//{{AFX_MSG(CListBoxPro)
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_LISTBOXPRO_H__C6BF9A28_1F1B_11D3_A5F1_00902712C9AE__INCLUDED_)
@@ -0,0 +1,259 @@
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "ImageGrinder.h"
#include "MainFrm.h"
#include "TextureLibFrame.h"
#include "FeatureLibFrame.h"
#include <Compost\FeatureGrid.hpp>
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_TOOLS_CONVERTFGDTOIGDATA, OnToolsConvertfgdtoigdata)
ON_COMMAND(ID_TOOLS_EXPORTFGDIGDATA, OnToolsExportfgdigdata)
ON_COMMAND(ID_TOOLS_EXPORTALLIGDATAFILES, OnToolsExportalligdatafiles)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
TextLibWin=NULL;
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
void CMainFrame::Init()
{
gosASSERT(!TextLibWin);
TextLibWin=new CTextureLibFrame;
TextLibWin->Create(this);
TextLibWin->ShowWindow(SW_SHOW);
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CMDIFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
BOOL CMainFrame::OnIdle()
{
if (TextLibWin) {
return TextLibWin->OnIdle();
}
return FALSE;
}
void CMainFrame::OnToolsConvertfgdtoigdata()
{
CFileDialog dlg(TRUE,NULL,NULL,NULL,"Game Compost Files (*.fgd)|*.fgd||");
if(dlg.DoModal()==IDOK)
{
Compost::FeatureGrid *FGrid;
Compost::FeaturePool *FPool;
CString iname=dlg.GetPathName();
FPool = new Compost::FeaturePool();
Register_Pointer(FPool);
Check_Object(Stuff::FileStreamManager::Instance);
Stuff::FileStream *fstr=new Stuff::FileStream;
Register_Object(fstr);
fstr->Open(iname,Stuff::FileStream::ReadOnly);
FPool->LoadIndex(fstr);
FGrid = new Compost::FeatureGrid(fstr, FPool);
Register_Pointer(FGrid);
Unregister_Object(fstr);
delete fstr;
CString oname=dlg.GetFileName();
oname=oname.Left(oname.GetLength()-dlg.GetFileExt().GetLength());
oname+="IGData";
CFileDialog dlg2(FALSE,"IGData",oname,NULL,"Image Gringer files (*.IGData)|*.IGData||");
if(dlg2.DoModal()==IDOK)
{
oname=dlg2.GetPathName();
Stuff::NotationFile note_file(oname);
note_file.DeleteAllPages();
Stuff::Page *page=note_file.SetPage(NULL);
Check_Object(page);
page->SetEntry("!concatenate","no");
FPool->SaveIndex(&note_file);
FGrid->SaveGrid(&note_file);
note_file.Save();
}
Unregister_Pointer(FPool);
delete FPool;
Unregister_Pointer(FGrid);
delete FGrid;
}
}
void CMainFrame::OnToolsExportfgdigdata()
{
CFileDialog dlg(TRUE,NULL,NULL,NULL,"Image Gringer files (*.IGData)|*.IGData||");
if(dlg.DoModal()==IDOK)
{
ExportFGD(dlg.GetPathName());
}
}
void CMainFrame::OnToolsExportalligdatafiles()
{
WIN32_FIND_DATA file_data;
HANDLE file_find;
file_find=FindFirstFile("Content\\Maps\\*.*",&file_data);
if(file_find != INVALID_HANDLE_VALUE)
{
do
{
CString dir_name=file_data.cFileName;
if(file_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY &&
dir_name!="." && dir_name!=".." )
{
ExportFGD("Content\\Maps\\"+dir_name+"\\"+dir_name+".IgData");
}
}
while (FindNextFile(file_find,&file_data));
}
}
void CMainFrame::ExportFGD(CString &path)
{
Compost::FeatureGrid *FGrid;
Compost::FeaturePool *FPool;
CString iname=path;
FPool = new Compost::FeaturePool();
Register_Pointer(FPool);
Check_Object(Stuff::FileStreamManager::Instance);
Stuff::NotationFile note_file(iname);
FPool->LoadIndex(&note_file);
FGrid = new Compost::FeatureGrid(&note_file, FPool);
Register_Pointer(FGrid);
CString oname=path.Left(path.ReverseFind('.'))+".fgd";
Check_Object(Stuff::FileStreamManager::Instance);
Stuff::FileStream *fstr=new Stuff::FileStream;
Register_Object(fstr);
fstr->Open(oname,Stuff::FileStream::WriteOnly);
FPool->SaveIndex(fstr);
FGrid->SaveGrid(fstr,0,0);
Unregister_Object(fstr);
delete fstr;
Unregister_Pointer(FPool);
delete FPool;
Unregister_Pointer(FGrid);
delete FGrid;
}
void CMainFrame::OnClose()
{
// TODO: Add your message handler code here and/or call default
extern void DestroyTNTThread();
DestroyTNTThread();
if (TextLibWin) {
TextLibWin->DestroyWindow();
TextLibWin = NULL;
}
CMDIFrameWnd::OnClose();
}
@@ -0,0 +1,64 @@
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINFRM_H__1B275CE7_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_)
#define AFX_MAINFRM_H__1B275CE7_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CTextureLibFrame;
class CMainFrame : public CMDIFrameWnd
{
DECLARE_DYNAMIC(CMainFrame)
public:
CMainFrame();
// Attributes
public:
CTextureLibFrame *TextLibWin;
// Operations
public:
void Init();
BOOL OnIdle();
void ExportFGD(CString &path);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnToolsConvertfgdtoigdata();
afx_msg void OnToolsExportfgdigdata();
afx_msg void OnToolsExportalligdatafiles();
afx_msg void OnClose();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__1B275CE7_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_)
@@ -0,0 +1,129 @@
// ModifyPath.cpp : implementation file
//
#include "stdafx.h"
#include "ImageGrinder.h"
#include "ModifyPath.h"
/////////////////////////////////////////////////////////////////////////////
// CModifyPath dialog
CModifyPath::CModifyPath(CWnd* pParent /*=NULL*/)
: CDialog(CModifyPath::IDD, pParent)
{
//{{AFX_DATA_INIT(CModifyPath)
m_path = _T("");
//}}AFX_DATA_INIT
}
void CModifyPath::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CModifyPath)
DDX_Text(pDX, IDC_PATH, m_path);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CModifyPath, CDialog)
//{{AFX_MSG_MAP(CModifyPath)
ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
ON_EN_CHANGE(IDC_PATH, OnChangePath)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CModifyPath message handlers
void myILFree(LPITEMIDLIST pidl);
void myILFree(LPITEMIDLIST pidl)
{
LPMALLOC pMalloc;
if (pidl)
{
#ifdef DEBUG
UINT cbSize = ILGetSize(pidl);
VALIDATE_PIDL(pidl);
// Fill the memory with some bad value...
_fmemset(pidl, 0xE5, cbSize);
// If large enough try to save the call return address of who
// freed us in the 3-6 byte of the structure.
if (cbSize >= 6)
*((UINT*)((LPSTR)pidl + 2)) = *(((UINT*)&pidl) - 1);
#endif
SHGetMalloc(&pMalloc);
pMalloc->Free( pidl);
pMalloc->Release();
}
}
void CModifyPath::OnBrowse()
{
CString TexturePath;
char pname[MAX_PATH];
BROWSEINFO bi;
bi.hwndOwner =m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = NULL;
bi.lpszTitle = "Choose Texture Path...";
bi.ulFlags = BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = (LPARAM)this;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
if (SHGetPathFromIDList(pidl,pname))
{
TexturePath=pname;
}
if (bi.pidlRoot)
{
myILFree( const_cast< ITEMIDLIST* >( bi.pidlRoot ) );
}
m_path=TexturePath;
UpdateData(FALSE);
}
int CModifyPath::DoModal()
{
return CDialog::DoModal();
}
void CModifyPath::OnChangePath()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
}
void CModifyPath::OnOK()
{
// TODO: Add extra validation here
if(0xffffffff==GetFileAttributes( m_path ))
{
MessageBox("Invalid Path","Path Error",MB_ICONERROR|MB_OK);
}
else
CDialog::OnOK();
}
@@ -0,0 +1,50 @@
#if !defined(AFX_MODIFYPATH_H__BBF4C861_12AD_11D3_A5F1_00902712C9AE__INCLUDED_)
#define AFX_MODIFYPATH_H__BBF4C861_12AD_11D3_A5F1_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ModifyPath.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CModifyPath dialog
class CModifyPath : public CDialog
{
// Construction
public:
CModifyPath(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CModifyPath)
enum { IDD = IDD_MODPATH };
CString m_path;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CModifyPath)
public:
virtual int DoModal();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CModifyPath)
afx_msg void OnBrowse();
afx_msg void OnChangePath();
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MODIFYPATH_H__BBF4C861_12AD_11D3_A5F1_00902712C9AE__INCLUDED_)
@@ -0,0 +1,54 @@
// NewGridDlg.cpp : implementation file
//
#include "stdafx.h"
#include "imagegrinder.h"
#include "NewGridDlg.h"
/////////////////////////////////////////////////////////////////////////////
// CNewGridDlg dialog
CNewGridDlg::CNewGridDlg(CWnd* pParent /*=NULL*/)
: CDialog(CNewGridDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CNewGridDlg)
m_hires = FALSE;
m_XZones = 0;
m_YZones = 0;
//}}AFX_DATA_INIT
}
void CNewGridDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNewGridDlg)
DDX_Check(pDX, IDC_HIRES, m_hires);
DDX_CBIndex(pDX, IDC_XZONES, m_XZones);
DDX_CBIndex(pDX, IDC_YZONES, m_YZones);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNewGridDlg, CDialog)
//{{AFX_MSG_MAP(CNewGridDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNewGridDlg message handlers
BOOL CNewGridDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_XZones = 1;
m_YZones = 1;
m_hires=FALSE;
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
@@ -0,0 +1,48 @@
#if !defined(AFX_NEWGRIDDLG_H__866D6C90_2372_11D3_BD3E_00902712C9AE__INCLUDED_)
#define AFX_NEWGRIDDLG_H__866D6C90_2372_11D3_BD3E_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// NewGridDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CNewGridDlg dialog
class CNewGridDlg : public CDialog
{
// Construction
public:
CNewGridDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CNewGridDlg)
enum { IDD = IDD_NEWGRID };
BOOL m_hires;
int m_XZones;
int m_YZones;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CNewGridDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CNewGridDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_NEWGRIDDLG_H__866D6C90_2372_11D3_BD3E_00902712C9AE__INCLUDED_)
@@ -0,0 +1,40 @@
// POutOpts.cpp : implementation file
//
#include "stdafx.h"
#include "imagegrinder.h"
#include "POutOpts.h"
/////////////////////////////////////////////////////////////////////////////
// CPOutOpts dialog
CPOutOpts::CPOutOpts(CWnd* pParent /*=NULL*/)
: CDialog(CPOutOpts::IDD, pParent)
{
//{{AFX_DATA_INIT(CPOutOpts)
m_zcol = 0;
m_zrow = 0;
//}}AFX_DATA_INIT
}
void CPOutOpts::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPOutOpts)
DDX_Text(pDX, IDC_ZONECOL, m_zcol);
DDX_Text(pDX, IDC_ZONEROW, m_zrow);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPOutOpts, CDialog)
//{{AFX_MSG_MAP(CPOutOpts)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPOutOpts message handlers
@@ -0,0 +1,47 @@
#if !defined(AFX_POUTOPTS_H__04B2B2E1_9CDA_11D3_8B36_00902712C9AE__INCLUDED_)
#define AFX_POUTOPTS_H__04B2B2E1_9CDA_11D3_8B36_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// POutOpts.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CPOutOpts dialog
class CPOutOpts : public CDialog
{
// Construction
public:
CPOutOpts(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CPOutOpts)
enum { IDD = IDD_POUTOPTS };
UINT m_zcol;
UINT m_zrow;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPOutOpts)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CPOutOpts)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_POUTOPTS_H__04B2B2E1_9CDA_11D3_8B36_00902712C9AE__INCLUDED_)
@@ -0,0 +1,117 @@
========================================================================
MICROSOFT FOUNDATION CLASS LIBRARY : ImageGrinder
========================================================================
AppWizard has created this ImageGrinder application for you. This application
not only demonstrates the basics of using the Microsoft Foundation classes
but is also a starting point for writing your application.
This file contains a summary of what you will find in each of the files that
make up your ImageGrinder application.
ImageGrinder.dsp
This file (the project file) contains information at the project level and
is used to build a single project or subproject. Other users can share the
project (.dsp) file, but they should export the makefiles locally.
ImageGrinder.h
This is the main header file for the application. It includes other
project specific headers (including Resource.h) and declares the
CImageGrinderApp application class.
ImageGrinder.cpp
This is the main application source file that contains the application
class CImageGrinderApp.
ImageGrinder.rc
This is a listing of all of the Microsoft Windows resources that the
program uses. It includes the icons, bitmaps, and cursors that are stored
in the RES subdirectory. This file can be directly edited in Microsoft
Visual C++.
ImageGrinder.clw
This file contains information used by ClassWizard to edit existing
classes or add new classes. ClassWizard also uses this file to store
information needed to create and edit message maps and dialog data
maps and to create prototype member functions.
res\ImageGrinder.ico
This is an icon file, which is used as the application's icon. This
icon is included by the main resource file ImageGrinder.rc.
res\ImageGrinder.rc2
This file contains resources that are not edited by Microsoft
Visual C++. You should place all resources not editable by
the resource editor in this file.
/////////////////////////////////////////////////////////////////////////////
For the main frame window:
MainFrm.h, MainFrm.cpp
These files contain the frame class CMainFrame, which is derived from
CMDIFrameWnd and controls all MDI frame features.
res\Toolbar.bmp
This bitmap file is used to create tiled images for the toolbar.
The initial toolbar and status bar are constructed in the CMainFrame
class. Edit this toolbar bitmap using the resource editor, and
update the IDR_MAINFRAME TOOLBAR array in ImageGrinder.rc to add
toolbar buttons.
/////////////////////////////////////////////////////////////////////////////
For the child frame window:
ChildFrm.h, ChildFrm.cpp
These files define and implement the CChildFrame class, which
supports the child windows in an MDI application.
/////////////////////////////////////////////////////////////////////////////
AppWizard creates one document type and one view:
ImageGrinderDoc.h, ImageGrinderDoc.cpp - the document
These files contain your CImageGrinderDoc class. Edit these files to
add your special document data and to implement file saving and loading
(via CImageGrinderDoc::Serialize).
ImageGrinderView.h, ImageGrinderView.cpp - the view of the document
These files contain your CImageGrinderView class.
CImageGrinderView objects are used to view CImageGrinderDoc objects.
res\ImageGrinderDoc.ico
This is an icon file, which is used as the icon for MDI child windows
for the CImageGrinderDoc class. This icon is included by the main
resource file ImageGrinder.rc.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named ImageGrinder.pch and a precompiled types file named StdAfx.obj.
Resource.h
This is the standard header file, which defines new resource IDs.
Microsoft Visual C++ reads and updates this file.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
If your application uses MFC in a shared DLL, and your application is
in a language other than the operating system's current language, you
will need to copy the corresponding localized resources MFC42XXX.DLL
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory,
and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation.
For example, MFC42DEU.DLL contains resources translated to German.) If you
don't do this, some of the UI elements of your application will remain in the
language of the operating system.
/////////////////////////////////////////////////////////////////////////////
@@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// ImageGrinder.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
@@ -0,0 +1,28 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__1B275CE5_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_)
#define AFX_STDAFX_H__1B275CE5_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#define __exdisp_h__
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__1B275CE5_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_)
@@ -0,0 +1,844 @@
// TextureLibDiag.cpp : implementation file
//
#include "stdafx.h"
#include "ImageGrinder.h"
#include "TextureLibDiag.h"
#include "ModifyPath.h"
#include "ImageCache.h"
#include "ImageGrinderDoc.h"
#include <Compost\TexturePool.hpp>
#include "..\..\Libraries\ImageLib\Image.h"
#include <GameOS\ToolOS.hpp>
extern CImageGrinderApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CTextureLibDiag dialog
bool IsPowerOf2(int num);
CTextureLibDiag::CTextureLibDiag(CWnd* pParent /*=NULL*/)
: CDialog(CTextureLibDiag::IDD, pParent)
{
//{{AFX_DATA_INIT(CTextureLibDiag)
m_TexturePath = _T("");
m_TSpace = _T("");
//}}AFX_DATA_INIT
ImgTot=0;
for(int i=0;i<MAXTEXTURES;i++)
ImgLoaded[i]=false;
}
void CTextureLibDiag::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTextureLibDiag)
DDX_Control(pDX, IDC_TEXTURELIST, m_TextureList);
DDX_Text(pDX, IDC_TEXTPATH, m_TexturePath);
DDX_Text(pDX, IDC_TSPACE, m_TSpace);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTextureLibDiag, CDialog)
//{{AFX_MSG_MAP(CTextureLibDiag)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_NOTIFY(LVN_BEGINDRAG, IDC_TEXTURELIST, OnBegindragTexturelist)
ON_BN_CLICKED(IDC_CHANGEPATH, OnChangepath)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
ON_BN_CLICKED(IDC_ADD1BIT, OnAdd1bit)
ON_BN_CLICKED(IDC_ADDMIPMASK, OnAddmipmask)
ON_BN_CLICKED(IDC_UPDATE, OnUpdate)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTextureLibDiag message handlers
void CTextureLibDiag::OnOK()
{
// TODO: Add extra validation here
// CDialog::OnOK();
}
void CTextureLibDiag::OnCancel()
{
// TODO: Add extra cleanup here
// CDialog::OnCancel();
}
void CTextureLibDiag::OnAdd()
{
CFileDialog dlg(TRUE,NULL,NULL,OFN_ALLOWMULTISELECT,"Targa Images (*.tga)|*.tga||",NULL);
char *filebuf=new char[MAX_PATH*200];
filebuf[0]=0;
dlg.m_ofn.lpstrFile=filebuf;
dlg.m_ofn.nMaxFile=MAX_PATH*200;
if(dlg.DoModal()==IDOK)
{
POSITION pos;
pos=dlg.GetStartPosition();
CString fname,SPath;
while(pos!=NULL)
{
fname=dlg.GetNextPathName(pos);
Image img;
img.GetTgaInfo((char *)(LPCSTR)fname);
/* We now allow for special features to load now power-of-2 images
if(!IsPowerOf2(img.GetWidth()) || !IsPowerOf2(img.GetHeight()) )
{
MessageBox("Image Size Not Power of 2","Image Dim Error",MB_OK|MB_ICONERROR);
return;
}
*/
SPath=fname.Left(fname.ReverseFind('\\')+1);
fname=fname.Right(fname.GetLength()-(fname.ReverseFind('\\')+1));
if(NULL==CopyFile(SPath+fname,m_TexturePath+"\\"+fname,FALSE))
{ //Copy Failed
}
fname = fname.Left(fname.ReverseFind('.'));
Compost::Feature_Texture::TextureMode tmde;
if(img.GetIType()==ITYPE_INDEXED)
{
tmde = Compost::Feature_Texture::FTT_1;
}
else
{
if(img.HasAlpha())
tmde = Compost::Feature_Texture::FTT_4444;
else
tmde = Compost::Feature_Texture::FTT_555;
}
Compost::TexturePool::Instance->Add(
Stuff::MString((LPCSTR)fname),
img.GetWidth(),
img.GetHeight(),
tmde
);
}
delete filebuf;
}
RefreshList();
}
BOOL CTextureLibDiag::OnInitDialog()
{
CDialog::OnInitDialog();
CDC *pDC=GetDC(),memdc;
UnLoadedBmp.CreateCompatibleBitmap(pDC,PREVIEWSZE,PREVIEWSZE);
memdc.CreateCompatibleDC(pDC);
memdc.SelectObject(UnLoadedBmp);
BOOL res=memdc.BitBlt(0,0,PREVIEWSZE,PREVIEWSZE,NULL,0,0,WHITENESS);
Verify(res!=0);
memdc.DeleteDC();
ReleaseDC(pDC);
ImgLst.Create(PREVIEWSZE,PREVIEWSZE,ILC_COLOR24,16,16);
m_TextureList.SetImageList(&ImgLst,LVSIL_NORMAL);
CString AppName;
AppName.LoadString(AFX_IDS_APP_TITLE);
CString tpath;
tpath=theApp.GetProfileString("Settings","TexturePath","");
if(tpath.GetLength()==0)
{
OnChangepath();
}
else
{
m_TexturePath=tpath;
Compost::TexturePool::Instance->SetTexturePath(m_TexturePath);
Compost::TexturePool::Instance->LoadIndex();
RefreshList();
UpdateData(FALSE);
}
if(gos_DoesFileExist(m_TexturePath+"\\Material.txt"))
{
Stuff::NotationFile mat_file(m_TexturePath+"\\Material.txt");
Stuff::Page *page = mat_file.GetPage("Materials");
Check_Object(page);
Stuff::Page::NoteIterator *note_list=page->MakeNoteIterator();
note_list->First();
Stuff::Note *note;
Compost::MaterialEntriesCount = 0;
Stuff::RGBColor color;
DWORD mat_color;
while((note=note_list->ReadAndNext())!=NULL && Compost::MaterialEntriesCount<128)
{
Compost::MaterialEntries[Compost::MaterialEntriesCount].MatName=note->GetName();
note->GetEntry(&color);
Stuff::Scalar f;
f = color.red * 255.99f;
Clamp(f, 0.0f, 255.f);
mat_color = Stuff::Truncate_Float_To_Byte (f);
f = color.green * 255.99f;
Clamp(f, 0.0f, 255.f);
mat_color = (mat_color << 8) | Stuff::Truncate_Float_To_Byte (f);
f = color.blue * 255.99f;
Clamp(f, 0.0f, 255.f);
mat_color = (mat_color << 8) | Stuff::Truncate_Float_To_Byte (f);
Compost::MaterialEntries[Compost::MaterialEntriesCount].color = mat_color;
Compost::MaterialEntries[Compost::MaterialEntriesCount].darkEntryIndex = Compost::MaterialEntriesCount;
Compost::MaterialEntriesCount++;
}
page = mat_file.GetPage("Darkening");
Check_Object(page);
note_list=page->MakeNoteIterator();
note_list->First();
Stuff::MString name;
const char *dark_name;
while((note=note_list->ReadAndNext())!=NULL && Compost::MaterialEntriesCount<128)
{
name = note->GetName();
if(!strcmp(name, "darkfactor"))
{
note->GetEntry(&Compost::DarkFactor);
}
else
{
note->GetEntry(&dark_name);
for(int i=0;i<Compost::MaterialEntriesCount;i++)
{
if(name == Compost::MaterialEntries[i].MatName)
{
for(int j=0;j<Compost::MaterialEntriesCount;j++)
{
if(NULL==strcmp(dark_name, Compost::MaterialEntries[j].MatName))
{
Compost::MaterialEntries[i].darkEntryIndex = j;
break;
}
}
break;
}
}
}
}
}
else
{
Compost::MaterialEntriesCount=1;
Compost::MaterialEntries[0].MatName="none";
Compost::MaterialEntries[0].color = 0;
Compost::MaterialEntries[0].darkEntryIndex = 0;
}
// while(LoadNextImage());
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CTextureLibDiag::OnBegindragTexturelist(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
*pResult = 0;
}
void CTextureLibDiag::OnChangepath()
{
CModifyPath dlg;
dlg.m_path=m_TexturePath;
if(dlg.DoModal()==IDOK)
{
m_TexturePath=dlg.m_path;
CString AppName;
AppName.LoadString(AFX_IDS_APP_TITLE);
theApp.WriteProfileString("Settings","TexturePath",m_TexturePath);
Compost::TexturePool::Instance->SetTexturePath(m_TexturePath);
Compost::TexturePool::Instance->LoadIndex();
UpdateData(FALSE);
RefreshList();
}
}
void CTextureLibDiag::RefreshList()
{
Compost::Feature_Texture *FTexture;
int CurImg=0,DataTotal=0,SubTot;
m_TextureList.DeleteAllItems();
// Image img2,img;
// img.CreateBlank(PREVIEWSZE,PREVIEWSZE,ITYPE_RGB,24);
CString fname;
{
Stuff::TableIteratorOf<Compost::Feature_Texture*, int> imageTableIterator(Compost::TexturePool::Instance->GetImageTable());
while(NULL!=(FTexture=imageTableIterator.ReadAndNext()))
{
LVITEM itm;
fname=m_TexturePath;
fname+="\\";
fname+=(char *)(*(FTexture->GetName()));
fname+=".tga";
ZeroMemory(&itm,sizeof(LVITEM));
itm.mask=LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM;
itm.iItem=1;
itm.lParam=(long)FTexture;
itm.pszText=(char *)(*(FTexture->GetName()));
itm.iImage=GetIndex(fname);
SubTot=FTexture->width*FTexture->height;
if(FTexture->GetTextureMode() != Compost::Feature_Texture::TextureMode::FTT_1)
{ SubTot*=2; }
DataTotal+=SubTot;
CurImg++;
m_TextureList.InsertItem(&itm);
}
}
if(DataTotal<1000000)
m_TSpace.Format("%3.2f KB",DataTotal/1000.0);
else
m_TSpace.Format("%3.2f MB",DataTotal/1000000.0);
UpdateData(FALSE);
if(!Compost::TexturePool::Instance->SaveIndex(NULL))
{
MessageBox("Index file is Read only, Texture Lib Changes will not be saved","Texture Lib Error",MB_OK|MB_ICONHAND);
}
}
void
Compost::FetchTextureData(Compost::Feature_Texture *tex, int index, int type)
{
tex->data = NULL;
tex->handle = NULL;
return;
}
void
Compost::FetchTextureData(Compost::Feature_Texture *tex, const char *name, int type)
{
CString str(name);
str+=".Tga";
Image img, mip1, mip2;
img.LoadTga((char *)(LPCSTR)str);
switch(type & Compost::Feature_Texture::TextureTypeMask)
{
case Compost::Feature_Texture::TextureMode::FTT_555:
{
mip1.CreateBlank(img.GetWidth()/2,img.GetHeight()/2,ITYPE_RGB,32);
mip1.Blt(img,CRect(0,0,mip1.GetWidth(),mip1.GetHeight()),CRect(0,0,img.GetWidth(),img.GetHeight()));
// mip1.SaveTiff("c:\\mp1.Tif");
mip1.Pad(1);
mip2.CreateBlank(img.GetWidth()/4,img.GetHeight()/4,ITYPE_RGB,32);
mip2.Blt(img,CRect(0,0, mip2.GetWidth(), mip2.GetHeight()),CRect(0,0,img.GetWidth(),img.GetHeight()));
// mip2.SaveTiff("c:\\mp2.Tif");
mip2.Pad(1);
}
break;
case Compost::Feature_Texture::TextureMode::FTT_4444:
{
mip1.CreateBlank(img.GetWidth()/2,img.GetHeight()/2,ITYPE_RGB,32,RGBMask(0x00ff0000,0x0000ff00,0x000000ff,0xff000000));
mip1.Blt(img,CRect(0,0,mip1.GetWidth(),mip1.GetHeight()),CRect(0,0,img.GetWidth(),img.GetHeight()));
// mip1.SaveTiff("c:\\mp1.Tif");
mip1.Pad(1);
mip2.CreateBlank(img.GetWidth()/4,img.GetHeight()/4,ITYPE_RGB,32,RGBMask(0x00ff0000,0x0000ff00,0x000000ff,0xff000000));
mip2.Blt(img,CRect(0,0, mip2.GetWidth(), mip2.GetHeight()),CRect(0,0,img.GetWidth(),img.GetHeight()));
// mip2.SaveTiff("c:\\mp2.Tif");
mip2.Pad(1);
}
break;
case Compost::Feature_Texture::TextureMode::FTT_1_M:
{
mip1.CreateBlank(img.GetWidth()/2,img.GetHeight()/2,ITYPE_INDEXED, 8);
mip1.Blt(img,CRect(0,0,mip1.GetWidth(),mip1.GetHeight()),CRect(0,0,img.GetWidth(),img.GetHeight()));
mip1.MakeGrayscalePalette();
mip1.Pad(1);
// mip1.SaveGif("c:\\mp1.gif");
mip2.CreateBlank(img.GetWidth()/4,img.GetHeight()/4,ITYPE_INDEXED, 8);
mip2.Blt(img,CRect(0,0, mip2.GetWidth(), mip2.GetHeight()),CRect(0,0,img.GetWidth(),img.GetHeight()));
mip2.MakeGrayscalePalette();
mip2.Pad(1);
// mip2.SaveGif("c:\\mp2.gif");
}
break;
case Compost::Feature_Texture::TextureMode::FTT_1:
case Compost::Feature_Texture::TextureMode::FTT_1_1:
break;
}
if(type != Compost::Feature_Texture::TextureMode::FTT_1_1)
{
img.Pad(1);
}
switch(type & Compost::Feature_Texture::TextureTypeMask)
{
case Compost::Feature_Texture::TextureMode::FTT_555:
{
img.MakeRGB16(RGBMask(0x007C00,0x0003E0,0x00001f,0x00));
mip1.MakeRGB16(RGBMask(0x007C00,0x0003E0,0x00001f,0x00));
mip2.MakeRGB16(RGBMask(0x007C00,0x0003E0,0x00001f,0x00));
// img.MaskTo(RGBMask(0xff0000,0x00ff00,0x0000ff,0x00));
}
break;
case Compost::Feature_Texture::TextureMode::FTT_4444:
{
img.MakeRGB16(RGBMask(0xF000,0xF00,0xF0,0xF));
mip1.MakeRGB16(RGBMask(0xF000,0xF00,0xF0,0xF));
mip2.MakeRGB16(RGBMask(0xF000,0xF00,0xF0,0xF));
// img.MaskTo(RGBMask(0xff000000,0x00ff0000,0x0000ff00,0x000000ff));
}
break;
case Compost::Feature_Texture::TextureMode::FTT_1:
break;
case Compost::Feature_Texture::TextureMode::FTT_1_1:
break;
}
int dsize;
unsigned char *tdat = NULL;
switch(type & Compost::Feature_Texture::TextureTypeMask)
{
case Compost::Feature_Texture::TextureMode::FTT_555:
case Compost::Feature_Texture::TextureMode::FTT_4444:
case Compost::Feature_Texture::TextureMode::FTT_1_M:
{
int dsize1, dsize2;
dsize = (img.GetBpp()>>3)*img.GetWidth()*img.GetHeight();
dsize1 = (mip1.GetBpp()>>3)*mip1.GetWidth()*mip1.GetHeight();
dsize2 = (mip2.GetBpp()>>3)*mip2.GetWidth()*mip2.GetHeight();
tex->dataSize = dsize + dsize1 + dsize2;
tdat = new unsigned char[tex->dataSize];
CopyMemory(tdat, img.Lock() , dsize);
img.UnLock();
CopyMemory(tdat+dsize, mip1.Lock() , dsize1);
mip1.UnLock();
CopyMemory(tdat+dsize+dsize1, mip2.Lock() , dsize2);
mip2.UnLock();
}
break;
case Compost::Feature_Texture::TextureMode::FTT_1:
{
dsize = (img.GetBpp()>>3)*img.GetWidth()*img.GetHeight();
tex->dataSize = dsize;
tdat = new unsigned char[tex->dataSize];
CopyMemory(tdat, img.Lock() , dsize);
img.UnLock();
}
break;
case Compost::Feature_Texture::TextureMode::FTT_1_1:
{
dsize = (img.GetBpp()>>3)*(2+ (img.GetWidth()>>3))*(2+img.GetHeight());
tex->dataSize = dsize;
tdat = new unsigned char[tex->dataSize];
int i, j, k, mask=0;
unsigned char *imgptr = img.Lock();
unsigned char *tdatptr = tdat + (2+(img.GetWidth()>>3));
for(i=0;i<img.GetHeight();i++)
{
if(*imgptr > 0x80)
{
*tdatptr = 0xff;
}
else
{
*tdatptr = 0x00;
}
tdatptr++;
for(j=0;j<img.GetWidth();j+=8)
{
*tdatptr = 0;
mask = 1;
for(k=0;k<8;k++)
{
if(*imgptr>0x80)
{
*tdatptr |= mask;
}
mask <<= 1;
imgptr++;
}
tdatptr++;
}
if(*(imgptr-1) > 0x80)
{
*tdatptr = 0xff;
}
else
{
*tdatptr = 0x00;
}
tdatptr++;
}
img.UnLock();
CopyMemory(tdat, tdat + (2+(img.GetWidth()>>3)), (2+(img.GetWidth()>>3)));
CopyMemory(tdatptr, tdatptr - (2+(img.GetWidth()>>3)), (2+(img.GetWidth()>>3)));
}
break;
}
if(tex->data!=NULL)
{
delete [] tex->data;
}
tex->data = tdat;
tex->handle = NULL;
return;
}
void
Compost::DestroyTextureData(Compost::Feature_Texture *tex)
{
delete [] tex->data;
}
void CTextureLibDiag::OnDelete()
{
POSITION pos;
pos=m_TextureList.GetFirstSelectedItemPosition();
while(pos!=NULL)
{
int nItem = m_TextureList.GetNextSelectedItem(pos);
Compost::Feature_Texture *feature_Texture = (Compost::Feature_Texture *)m_TextureList.GetItemData(nItem);
bool used=false;
int i;
for(i=0;i<DocCount;i++)
{
used = (NULL != DocList[i]->FPool->IsUsed(feature_Texture)) ? true : false;
if(used==true)
{
break;
}
}
if(used==true)
{
MessageBox("Texture is currently in use and cannot be deleted\n Close Documment and try again","Delete Error",MB_OK|MB_ICONSTOP);
}
else
{
Compost::TexturePool::Instance->Remove(feature_Texture);
}
}
RefreshList();
}
int CTextureLibDiag::GetIndex(CString fname)
{
int i;
for(i=0;i<ImgTot;i++)
if(!fname.CompareNoCase(ImageName[i]))
return i;
return AddImage(fname);
}
bool CTextureLibDiag::LoadNextImage()
{
int nidx;
for(nidx=0;nidx<ImgTot && ImgLoaded[nidx];nidx++);
if(nidx>=ImgTot) return false;
CString fname=ImageName[nidx];
CDC *pDC=GetDC();
ImageChain *imgchn=CImageCache::Instance->GetChain(fname);
Image *img=imgchn->GetTNImage();
if(!img)
{
imgchn->BuildTNImg(PREVIEWSZE,PREVIEWSZE);
img=imgchn->GetTNImage();
}
CBitmap *bmp=new CBitmap;
bmp->CreateCompatibleBitmap(pDC,img->GetWidth(),img->GetHeight());
CDC memDC;
memDC.CreateCompatibleDC(pDC);
HBITMAP hBmpOld = (HBITMAP)SelectObject(memDC, *bmp);
BITMAPINFO binf;
ZeroMemory(&binf,sizeof(binf));
binf.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
binf.bmiHeader.biWidth=img->GetWidth();
binf.bmiHeader.biHeight=-img->GetHeight();
binf.bmiHeader.biPlanes=1;
binf.bmiHeader.biBitCount=img->GetBpp();
binf.bmiHeader.biCompression=BI_RGB;
int res;
res=SetDIBitsToDevice(memDC,0,0,img->GetWidth(),img->GetHeight(),0,0,0,img->GetHeight(),img->Lock(),&binf,DIB_RGB_COLORS);
img->UnLock();
if(res==0)
{
DWORD err;
err=GetLastError();
}
Verify(res!=0);
SelectObject(memDC, hBmpOld);
memDC.DeleteDC();
ImgLst.Replace(nidx,bmp,NULL);
ImgLoaded[nidx]=true;
ReleaseDC(pDC);
delete bmp;
m_TextureList.InvalidateRect(NULL);
return true;
}
int CTextureLibDiag::AddImage(CString fname)
{
int idx=ImgLst.Add(&UnLoadedBmp,(COLORREF)0);
ImageName[idx]=fname;
ImgLoaded[idx]=false;
ImgTot++;
return idx;
}
bool IsPowerOf2(int X)
{
return !( X & ( X - 1 ) );
}
void CTextureLibDiag::OnAdd1bit()
{
CFileDialog dlg(TRUE,NULL,NULL,OFN_ALLOWMULTISELECT,"Targa Images (*.tga)|*.tga||",NULL);
char *filebuf=new char[MAX_PATH*200];
filebuf[0]=0;
dlg.m_ofn.lpstrFile=filebuf;
dlg.m_ofn.nMaxFile=MAX_PATH*200;
if(dlg.DoModal()==IDOK)
{
POSITION pos;
pos=dlg.GetStartPosition();
CString fname,SPath;
while(pos!=NULL)
{
fname=dlg.GetNextPathName(pos);
Image img;
img.GetTgaInfo((char *)(LPCSTR)fname);
if(img.GetBpp()!=8)
{
MessageBox("Image is not 8 Bit","Image Depth Error",MB_OK|MB_ICONERROR);
return;
}
/* We now allow for special features to load now power-of-2 images
if(!IsPowerOf2(img.GetWidth()) || !IsPowerOf2(img.GetHeight()) )
{
MessageBox("Image Size Not Power of 2","Image Dim Error",MB_OK|MB_ICONERROR);
return;
}
*/
SPath=fname.Left(fname.ReverseFind('\\')+1);
fname=fname.Right(fname.GetLength()-(fname.ReverseFind('\\')+1));
if(NULL==CopyFile(SPath+fname,m_TexturePath+"\\"+fname,FALSE))
{ //Copy Failed
}
fname = fname.Left(fname.ReverseFind('.'));
Compost::Feature_Texture::TextureMode tmde;
if(img.GetIType()==ITYPE_INDEXED)
{
tmde = Compost::Feature_Texture::FTT_1_1;
}
else
{
MessageBox("Image is not 8 Bit","Image Depth Error",MB_OK|MB_ICONERROR);
return;
}
Compost::TexturePool::Instance->Add(
Stuff::MString((LPCSTR)fname),
img.GetWidth(),
img.GetHeight(),
tmde
);
}
delete filebuf;
}
RefreshList();
}
void CTextureLibDiag::OnAddmipmask()
{
CFileDialog dlg(TRUE,NULL,NULL,OFN_ALLOWMULTISELECT,"Targa Images (*.tga)|*.tga||",NULL);
char *filebuf=new char[MAX_PATH*200];
filebuf[0]=0;
dlg.m_ofn.lpstrFile=filebuf;
dlg.m_ofn.nMaxFile=MAX_PATH*200;
if(dlg.DoModal()==IDOK)
{
POSITION pos;
pos=dlg.GetStartPosition();
CString fname,SPath;
while(pos!=NULL)
{
fname=dlg.GetNextPathName(pos);
Image img;
img.GetTgaInfo((char *)(LPCSTR)fname);
if(img.GetBpp()!=8)
{
MessageBox("Image is not 8 Bit","Image Depth Error",MB_OK|MB_ICONERROR);
return;
}
/* We now allow for special features to load now power-of-2 images
if(!IsPowerOf2(img.GetWidth()) || !IsPowerOf2(img.GetHeight()) )
{
MessageBox("Image Size Not Power of 2","Image Dim Error",MB_OK|MB_ICONERROR);
return;
}
*/
SPath=fname.Left(fname.ReverseFind('\\')+1);
fname=fname.Right(fname.GetLength()-(fname.ReverseFind('\\')+1));
if(NULL==CopyFile(SPath+fname,m_TexturePath+"\\"+fname,FALSE))
{ //Copy Failed
}
fname = fname.Left(fname.ReverseFind('.'));
Compost::Feature_Texture::TextureMode tmde;
if(img.GetIType()==ITYPE_INDEXED)
{
tmde = Compost::Feature_Texture::FTT_1_M;
}
else
{
MessageBox("Image is not 8 Bit","Image Depth Error",MB_OK|MB_ICONERROR);
return;
}
Compost::TexturePool::Instance->Add(
Stuff::MString((LPCSTR)fname),
img.GetWidth(),
img.GetHeight(),
tmde
);
}
delete filebuf;
}
RefreshList();
}
void CTextureLibDiag::OnUpdate()
{
POSITION pos;
pos=m_TextureList.GetFirstSelectedItemPosition();
while(pos!=NULL)
{
int nItem = m_TextureList.GetNextSelectedItem(pos);
Compost::Feature_Texture *feature_Texture = (Compost::Feature_Texture *)m_TextureList.GetItemData(nItem);
feature_Texture->SetLoadedOff();
Compost::TexturePool::Instance->Load(feature_Texture);
}
for(int i=0;i<DocCount;i++)
{
DocList[i]->SetDrawFlags();
DocList[i]->UpdateAllViews(NULL);
}
RefreshList();
}
BOOL CTextureLibDiag::OnIdle()
{
return LoadNextImage();
}
@@ -0,0 +1,67 @@
#if !defined(AFX_TEXTURELIBDIAG_H__1B275D1F_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_)
#define AFX_TEXTURELIBDIAG_H__1B275D1F_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// TextureLibDiag.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CTextureLibDiag dialog
#define MAXTEXTURES 2048
#define PREVIEWSZE 32
class CTextureLibDiag : public CDialog
{
// Construction
public:
BOOL OnIdle();
void RefreshList();
CTextureLibDiag(CWnd* pParent = NULL); // standard constructor
CImageList ImgLst;
CBitmap UnLoadedBmp;
CString ImageName[MAXTEXTURES];
bool ImgLoaded[MAXTEXTURES];
int ImgTot;
int AddImage(CString fname);
int GetIndex(CString fname);
bool LoadNextImage();
// Dialog Data
//{{AFX_DATA(CTextureLibDiag)
enum { IDD = IDD_TLDIALOG };
CListCtrl m_TextureList;
CString m_TexturePath;
CString m_TSpace;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTextureLibDiag)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CTextureLibDiag)
virtual void OnOK();
virtual void OnCancel();
afx_msg void OnAdd();
virtual BOOL OnInitDialog();
afx_msg void OnBegindragTexturelist(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnChangepath();
afx_msg void OnDelete();
afx_msg void OnAdd1bit();
afx_msg void OnAddmipmask();
afx_msg void OnUpdate();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TEXTURELIBDIAG_H__1B275D1F_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_)
@@ -0,0 +1,61 @@
// TextureLibFrame.cpp : implementation file
//
#include "stdafx.h"
#include "ImageGrinder.h"
#include "TextureLibFrame.h"
/////////////////////////////////////////////////////////////////////////////
// CTextureLibFrame
IMPLEMENT_DYNCREATE(CTextureLibFrame, CMDIChildWnd)
CTextureLibFrame::CTextureLibFrame()
{
DiagPanel=NULL;
}
CTextureLibFrame::~CTextureLibFrame()
{
if(DiagPanel) delete DiagPanel;
}
BEGIN_MESSAGE_MAP(CTextureLibFrame, CMDIChildWnd)
//{{AFX_MSG_MAP(CTextureLibFrame)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTextureLibFrame message handlers
void CTextureLibFrame::Create(CMDIFrameWnd *Parent)
{
// CMDIChildWnd::Create(NULL,"Texture Library",WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_CHILD,rectDefault,Parent);
CMDIChildWnd::Create(NULL,"Texture Library",WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_CHILD,rectDefault,Parent);
DiagPanel=new CTextureLibDiag;
DiagPanel->Create(CTextureLibDiag::IDD,this);
CRect rct;
DiagPanel->GetWindowRect(&rct);
SetWindowPos(NULL,0,0,
rct.Width()+GetSystemMetrics(SM_CXSIZEFRAME)*2,
rct.Height()+GetSystemMetrics(SM_CXSIZEFRAME)+GetSystemMetrics(SM_CYCAPTION),
SWP_NOZORDER|SWP_NOMOVE);
DiagPanel->ShowWindow(SW_SHOW);
}
void CTextureLibFrame::OnClose()
{
// TODO: Add your message handler code here and/or call default
// CMDIChildWnd::OnClose();
}
BOOL CTextureLibFrame::OnIdle()
{
if(DiagPanel) return DiagPanel->OnIdle();
return FALSE;
}
@@ -0,0 +1,49 @@
#if !defined(AFX_TEXTURELIBFRAME_H__1B275D20_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_)
#define AFX_TEXTURELIBFRAME_H__1B275D20_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// TextureLibFrame.h : header file
//
#include "TextureLibDiag.h"
/////////////////////////////////////////////////////////////////////////////
// CTextureLibFrame frame
class CTextureLibFrame : public CMDIChildWnd
{
DECLARE_DYNCREATE(CTextureLibFrame)
protected:
CTextureLibDiag *DiagPanel;
// Attributes
public:
CTextureLibFrame(); // protected constructor used by dynamic creation
// Operations
public:
BOOL OnIdle();
void Create(CMDIFrameWnd *Parent=NULL);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTextureLibFrame)
//}}AFX_VIRTUAL
// Implementation
protected:
virtual ~CTextureLibFrame();
// Generated message map functions
//{{AFX_MSG(CTextureLibFrame)
afx_msg void OnClose();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TEXTURELIBFRAME_H__1B275D20_0C5E_11D3_A5F1_00902712C9AE__INCLUDED_)
@@ -0,0 +1,167 @@
// UndoManager.cpp: implementation of the UndoManager class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ImageGrinder.h"
#include "ImageGrinderDoc.h"
#include "UndoManager.h"
#include <Compost\FeatureGrid.hpp>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Undo Command
void UndoCommand::Attach(UndoCommand *cmd)
{
if(Next)
Next->Attach(cmd);
else
Next=cmd;
}
void UndoCommand::ExecuteUndo(UndoCommand **revcom)
{
if(Next) Next->ExecuteUndo(revcom);
}
/*
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Rename
void RenameCommand::ExecuteUndo(UndoCommand **revcom)
{
UndoCommand::ExecuteUndo(revcom);
UndoCommand *com=new RenameCommand(Object);
Object->SetName(OldName);
if(*revcom==NULL) *revcom=com; else (*revcom)->Attach(com);
}
*/
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Move
void MoveCommand::ExecuteUndo(UndoCommand **revcom)
{
UndoCommand::ExecuteUndo(revcom);
UndoCommand *com=new MoveCommand(Object,Parent);
Parent->SetDrawFlags(Object);
Object->feature_x_pos=xpos;
Object->feature_z_pos=zpos;
Parent->SetDrawFlags(Object);
if(*revcom==NULL) *revcom=com; else (*revcom)->Attach(com);
}
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> AddCommand
void AddCommand::ExecuteUndo(UndoCommand **revcom)
{
UndoCommand::ExecuteUndo(revcom);
UndoCommand *com=new DeleteCommand(Object,Parent);
Parent->SetDrawFlags(Object);
Parent->FGrid->Remove(Object);
if(*revcom==NULL) *revcom=com; else (*revcom)->Attach(com);
}
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DeleteCommand
void DeleteCommand::ExecuteUndo(UndoCommand **revcom)
{
UndoCommand::ExecuteUndo(revcom);
Compost::FeatureInstance *newfet;
//!!! This corrupts the Stack;
newfet=Parent->FGrid->Add(Fet,XPos,ZPos);
Object=newfet;
UndoCommand *com=new AddCommand(Object,Parent);
if(*revcom==NULL) *revcom=com; else (*revcom)->Attach(com);
}
/*
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> GroupCommand
void GroupCommand::ExecuteUndo(UndoCommand **revcom)
{
UndoCommand::ExecuteUndo(revcom);
UndoCommand *com=new GroupCommand(Object);
Object->GetParent()->RemoveObject(Object);
Parent->AddObject(Object);
if(*revcom==NULL) *revcom=com; else (*revcom)->Attach(com);
}
*/
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Command Stack
CommandStack::CommandStack()
{
CommandCount=0;
CommandMax=COMMAND_MAX;
}
void CommandStack::RemoveBottomCommand()
{
Verify(CommandCount>=1);
delete Commands[0];
for(int i=1;i<CommandCount;i++) Commands[i-1]=Commands[i];
CommandCount--;
}
void CommandStack::PushCommand(UndoCommand *cmd)
{
Verify(cmd!=NULL);
if(CommandCount>=(CommandMax-1))
RemoveBottomCommand();
Commands[CommandCount++]=cmd;
}
UndoCommand *CommandStack::Pop()
{
if(CommandCount>0)
{
CommandCount--;
return Commands[CommandCount];
}
return NULL;
}
UndoCommand *CommandStack::PopAndExecute()
{
if(CommandCount>0)
{
CommandCount--;
UndoCommand *revcom=NULL;
Commands[CommandCount]->ExecuteUndo(&revcom);
delete Commands[CommandCount];
return revcom;
}
return NULL;
}
void CommandStack::Clear()
{
while(CommandCount)
{
UndoCommand *com=Pop();
com->Discard();
delete com;
}
}
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Undo Manger
UndoManager::~UndoManager()
{
}
void UndoManager::Undo()
{
RedoStack.PushCommand(UndoStack.PopAndExecute());
}
void UndoManager::Redo()
{
UndoStack.PushCommand(RedoStack.PopAndExecute());
}
void UndoManager::AddCommand(UndoCommand *cmd)
{
RedoStack.Clear();
UndoStack.PushCommand(cmd);
}
@@ -0,0 +1,128 @@
// UndoManager.h: interface for the UndoManager class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_UNDOMANAGER_H__8D4EFECB_204F_4BE0_8952_13AB4341E301__INCLUDED_)
#define AFX_UNDOMANAGER_H__8D4EFECB_204F_4BE0_8952_13AB4341E301__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <Compost\FeatureGrid.hpp>
class CImageGrinderDoc;
using namespace Compost;
#define COMMAND_MAX 256
class UndoCommand
{
protected:
FeatureInstance *Object;
UndoCommand *Next;
public:
virtual void ExecuteUndo(UndoCommand **revcom);
virtual void Discard() { }
void Attach(UndoCommand *cmd);
UndoCommand(FeatureInstance *obj) {Verify(obj); Object=obj; Next=NULL; }
virtual ~UndoCommand() {}
};
/*
class RenameCommand:public UndoCommand
{
protected:
CString OldName;
public:
void ExecuteUndo(UndoCommand **revcom);
RenameCommand(FeatureInstance *obj):UndoCommand(obj)
{OldName=obj->GetName(); }
virtual ~RenameCommand() {}
};
*/
class MoveCommand:public UndoCommand
{
protected:
CImageGrinderDoc *Parent;
int xpos,zpos;
public:
void ExecuteUndo(UndoCommand **revcom);
MoveCommand(FeatureInstance *obj,CImageGrinderDoc *par):UndoCommand(obj)
{ Parent=par; xpos=obj->feature_x_pos; zpos=obj->feature_z_pos;}
virtual ~MoveCommand() {}
};
class AddCommand:public UndoCommand
{
protected:
CImageGrinderDoc *Parent;
public:
void ExecuteUndo(UndoCommand **revcom);
AddCommand(FeatureInstance *obj,CImageGrinderDoc *par):UndoCommand(obj)
{ Parent=par; Verify(Parent);}
virtual ~AddCommand() { }
};
class DeleteCommand:public UndoCommand
{
protected:
CImageGrinderDoc *Parent;
Compost::Feature *Fet;
int XPos,ZPos;
public:
void ExecuteUndo(UndoCommand **revcom);
void Discard() {}
DeleteCommand(FeatureInstance *obj,CImageGrinderDoc *par):UndoCommand(obj)
{Parent=par; Fet=obj->feature; XPos=obj->feature_x_pos; ZPos=obj->feature_z_pos; Verify(Parent); }
virtual ~DeleteCommand() { }
};
/*
class GroupCommand:public UndoCommand
{
protected:
GUIObjectList *Parent;
public:
void ExecuteUndo(UndoCommand **revcom);
GroupCommand(FeatureInstance *obj):UndoCommand(obj)
{Parent=obj->GetParent(); Verify(Parent);}
virtual ~GroupCommand() { }
};
*/
class CommandStack
{
protected:
UndoCommand *Commands[COMMAND_MAX];
int CommandMax;
int CommandCount;
void RemoveBottomCommand();
public:
int Depth() {return CommandCount;}
void PushCommand(UndoCommand *cmd);
UndoCommand *Pop();
UndoCommand *PopAndExecute();
void Clear();
CommandStack();
virtual ~CommandStack() { Clear();}
};
class UndoManager
{
protected:
CommandStack UndoStack,RedoStack;
public:
void Clear() {UndoStack.Clear(); RedoStack.Clear();}
void AddCommand(UndoCommand *cmd);
bool CanUndo() {return (UndoStack.Depth()>0);}
bool CanRedo() {return (RedoStack.Depth()>0);}
void Undo();
void Redo();
UndoManager() {}
virtual ~UndoManager();
};
#endif // !defined(AFX_UNDOMANAGER_H__8D4EFECB_204F_4BE0_8952_13AB4341E301__INCLUDED_)
@@ -0,0 +1,77 @@
// UserValueDlg.cpp : implementation file
//
#include "stdafx.h"
#include "imagegrinder.h"
#include "UserValueDlg.h"
#include "ImageGrinderView.h"
/////////////////////////////////////////////////////////////////////////////
// CUserValueDlg dialog
CUserValueDlg::CUserValueDlg(CWnd* pParent /*=NULL*/)
: CDialog(CUserValueDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CUserValueDlg)
//}}AFX_DATA_INIT
IVal=NULL;
}
void CUserValueDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUserValueDlg)
DDX_Control(pDX, IDC_USERVAL, m_ValSli);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUserValueDlg, CDialog)
//{{AFX_MSG_MAP(CUserValueDlg)
ON_WM_VSCROLL()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUserValueDlg message handlers
void CUserValueDlg::OnOK()
{
CDialog::OnOK();
}
void CUserValueDlg::OnCancel()
{
// CDialog::OnCancel();
}
void CUserValueDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if(IVal)
*IVal=m_ValSli.GetPos();
Owner->OwnerView->UpdateHF();
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
int CUserValueDlg::DoModal(CHFPreview *wnd,int *ipt)
{
IVal=ipt;
Owner=wnd;
return CDialog::DoModal();
}
BOOL CUserValueDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_ValSli.SetRange(0,255);
if(IVal)
m_ValSli.SetPos(*IVal);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
@@ -0,0 +1,54 @@
#if !defined(AFX_USERVALUEDLG_H__46D028E7_5A10_11D3_8B36_00902712C9AE__INCLUDED_)
#define AFX_USERVALUEDLG_H__46D028E7_5A10_11D3_8B36_00902712C9AE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// UserValueDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CUserValueDlg dialog
#include "HFPreview.h"
class CUserValueDlg : public CDialog
{
// Construction
public:
CUserValueDlg(CWnd* pParent = NULL); // standard constructor
CHFPreview *Owner;
int *IVal;
// Dialog Data
//{{AFX_DATA(CUserValueDlg)
enum { IDD = IDD_USERVALUE };
CSliderCtrl m_ValSli;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CUserValueDlg)
public:
virtual int DoModal(CHFPreview *wnd,int *ipt);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CUserValueDlg)
virtual void OnOK();
virtual void OnCancel();
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_USERVALUEDLG_H__46D028E7_5A10_11D3_8B36_00902712C9AE__INCLUDED_)
Binary file not shown.
@@ -0,0 +1,13 @@
//
// IMAGEGRINDER.RC2 - resources Microsoft Visual C++ does not edit directly
//
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...
/////////////////////////////////////////////////////////////////////////////
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,150 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by ImageGrinder.rc
//
#define IDD_ABOUTBOX 100
#define CG_IDD_PROGRESS 103
#define CG_IDS_PROGRESS_CAPTION 104
#define IDR_MAINFRAME 128
#define IDR_IMAGEGTYPE 129
#define IDD_TLDIALOG 130
#define IDI_TESTICON 131
#define IDD_MODPATH 132
#define IDD_FEATURELIBDIAG 133
#define IDD_FEATUREPROPS 134
#define IDD_NEWGRID 136
#define IDD_BACKGROUNDPROPS 137
#define IDD_GRIDOPTIONS 138
#define IDD_EXPOPTIONS 139
#define IDD_DEPTHDIAG 141
#define IDD_COLORPROPS 142
#define IDD_USERVALUE 143
#define IDD_POUTOPTS 144
#define IDD_TOTALEXPORTOPTS 145
#define IDB_BITMAP1 147
#define IDD_DIALOG1 148
#define IDC_TEXTURELIST 1000
#define IDC_ADD 1001
#define IDC_MASK0LIST 1001
#define IDC_DELETE 1002
#define IDC_MASK1LIST 1002
#define IDC_TSPACE 1003
#define CG_IDC_PROGDLG_PROGRESS 1003
#define IDC_HFDATALIST 1003
#define IDC_TEXTPATH 1004
#define CG_IDC_PROGDLG_PERCENT 1004
#define IDC_CHANGEPATH 1005
#define IDC_PATH 1007
#define IDC_BROWSE 1008
#define IDC_NAME 1015
#define IDC_WIDTH 1016
#define IDC_HEIGHT 1021
#define IDC_XOFF 1022
#define IDC_ZOFF 1023
#define IDC_TEXTUREFLIPHOR 1025
#define IDC_TEXTUREFLIPVERT 1026
#define IDC_MASK0FLIPHOR 1027
#define IDC_MASK0FLIPVERT 1028
#define IDC_MASK1FLIPHOR 1029
#define IDC_MASK1FLIPVERT 1030
#define IDC_BLENDMODE 1031
#define IDC_FEATURELIST 1032
#define IDC_GSIZE 1033
#define IDC_BACKGROUND 1036
#define IDC_PIXELSPACE 1037
#define IDC_ZSIZE 1038
#define IDC_BASENAME 1039
#define IDC_PREVIEWFRAME 1040
#define IDC_MASK0PREVIEW 1041
#define IDC_SAVEHIRES 1042
#define IDC_MASK1PREVIEW 1042
#define IDC_DLIST 1043
#define IDC_HFPREVIEW 1043
#define IDC_HIRES 1044
#define IDC_GCMOD 1045
#define IDC_SELMOD 1046
#define IDC_WFMOD 1047
#define IDC_GCIMG 1051
#define IDC_HLMOD 1052
#define IDC_SELIMG 1053
#define IDC_WFIMG 1054
#define IDC_HLIMG 1055
#define IDC_HFBLEND 1056
#define IDC_USERVAL 1057
#define IDC_ADD1BIT 1058
#define IDC_ZONEROW 1060
#define IDC_ZONECOL 1061
#define IDC_STRETCH 1065
#define IDC_TGAFILES 1066
#define IDC_IMAGEDATA 1067
#define IDC_SINGLETGA 1068
#define IDC_USEDIMAGELIST 1069
#define IDC_MTINDEX 1071
#define IDC_ADDMIPMASK 1072
#define IDC_XZONES 1073
#define IDC_YZONES 1074
#define IDC_MATLIST 1075
#define IDC_UPDATE 1076
#define IDC_MATERIAL 1078
#define IDC_FGD 1079
#define IDC_IGDATA 1080
#define IDC_MAPNAME 1080
#define IDC_SINGLEMAT 1081
#define ID_OPTIONS_SETTEXTUREPATH 32771
#define ID_EDIT_ADDFEATURE 32773
#define ID_EDIT_DELETEFEATURE 32774
#define ID_VIEW_DEPTHVIEW 32777
#define ID_VIEW_LOADHEIGHTFIELD 32779
#define ID_FILE_EXPORT_TGAFILES 32780
#define ID_VIEW_HEIGHTFIELDVIEW 32781
#define ID_TEST_TEST1 32783
#define ID_TEST_XSNAP_1 32784
#define ID_TEST_XSNAP_2 32785
#define ID_TEST_XSNAP_4 32786
#define ID_TEST_XSNAP_8 32787
#define ID_TEST_XSNAP_16 32788
#define ID_FILE_EXPORT_IMAGEDATA 32789
#define ID_VIEW_GRIDOPTIONS 32790
#define ID_FILE_EXPORT_SINGLETGA 32791
#define ID_EDIT_MAKEUNIQUE 32792
#define ID_VIEW_WIREMODE 32793
#define ID_VIEW_HELPERS 32794
#define ID_VIEW_GRID 32795
#define ID_VIEW_COLORPROPERTIES 32796
#define ID_EDIT_LOCKSELECTION 32798
#define ID_EDIT_UNLOCKALL 32799
#define ID_EDIT_GROUPSELECTION 32802
#define ID_EDIT_UNGROUPSELECTION 32803
#define ID_FILE_MERGEFEATURES 32806
#define ID_VIEW_ZOOMIN 32807
#define ID_VIEW_ZOOMOUT 32808
#define ID_EDIT_GLOBALTEXTURES 32811
#define ID_EDIT_LOCALTEXTURES 32812
#define ID_FILE_EXPORT_USEDIMAGELIST 32816
#define ID_FILE_EXPORT_PARTIALOUTPUT 32817
#define ID_FILE_EXPORT_ALL 32819
#define ID_FILE_EXPORT_MAPTEXTUREINDEX 32820
#define ID_VIEW_MANUALUPDATE 32821
#define ID_VIEW_UPDATE 32822
#define ID_TEST_RENDERLOWRES 32823
#define ID_FILE_EXPORT_FEATUREFILE 32824
#define ID_FILE_IMPORT_FEATURES 32826
#define ID_FILE_EXPORT_MATERIALMAP 32827
#define ID_OPTIONS_FORCESINGLEPROC 32828
#define ID_TOOLS_CONVERTFGDTOIGDATA 32831
#define ID_FILE_EXPORT_SINGLEMATERIALMAP 32832
#define ID_EDIT_SELECTUNUSEDFEATURES 32833
#define ID_TOOLS_EXPORTFGDIGDATA 32834
#define ID_TOOLS_EXPORTALLIGDATAFILES 32835
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 149
#define _APS_NEXT_COMMAND_VALUE 32836
#define _APS_NEXT_CONTROL_VALUE 1081
#define _APS_NEXT_SYMED_VALUE 105
#endif
#endif