Changed: Improved formatting

This commit is contained in:
kervala 2016-11-20 17:15:56 +01:00
parent 2a90da11f4
commit 22aa75b6e8

View file

@ -21,7 +21,8 @@ static WNDPROC colorSwatchOriginalWndProc;
static HIMAGELIST hButtonImages = NULL; static HIMAGELIST hButtonImages = NULL;
static void LoadImages() { static void LoadImages()
{
if (hButtonImages) return; if (hButtonImages) return;
HBITMAP hBitmap, hMask; HBITMAP hBitmap, hMask;
hButtonImages = ImageList_Create(15, 14, ILC_MASK, 2, 0); // 17 is kluge to center square. -SA hButtonImages = ImageList_Create(15, 14, ILC_MASK, 2, 0); // 17 is kluge to center square. -SA
@ -35,7 +36,8 @@ static void LoadImages() {
ClassDesc* GetVertexPaintDesc(); ClassDesc* GetVertexPaintDesc();
class VertexPaintClassDesc:public ClassDesc { class VertexPaintClassDesc :public ClassDesc
{
public: public:
int IsPublic() { return 1; } int IsPublic() { return 1; }
void * Create(BOOL loading = FALSE) { return new VertexPaint(); } void * Create(BOOL loading = FALSE) { return new VertexPaint(); }
@ -49,8 +51,7 @@ class VertexPaintClassDesc:public ClassDesc {
static VertexPaintClassDesc VertexPaintDesc; static VertexPaintClassDesc VertexPaintDesc;
ClassDesc* GetVertexPaintDesc() { return &VertexPaintDesc; } ClassDesc* GetVertexPaintDesc() { return &VertexPaintDesc; }
static INT_PTR CALLBACK VertexPaintDlgProc( static INT_PTR CALLBACK VertexPaintDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
int numPoints; int numPoints;
VertexPaint *mod = (VertexPaint*)GetWindowLongPtr(hWnd, GWLP_USERDATA); VertexPaint *mod = (VertexPaint*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
@ -82,7 +83,8 @@ static INT_PTR CALLBACK VertexPaintDlgProc(
} }
} }
switch (msg) { switch (msg)
{
case WM_INITDIALOG: case WM_INITDIALOG:
LoadImages(); LoadImages();
mod = (VertexPaint*)lParam; mod = (VertexPaint*)lParam;
@ -159,7 +161,8 @@ static INT_PTR CALLBACK VertexPaintDlgProc(
break; break;
case WM_COMMAND: case WM_COMMAND:
switch(LOWORD(wParam)) { switch (LOWORD(wParam))
{
case IDC_PAINT: case IDC_PAINT:
mod->ActivatePaint(mod->iPaintButton->IsChecked()); mod->ActivatePaint(mod->iPaintButton->IsChecked());
break; break;
@ -206,19 +209,18 @@ static INT_PTR CALLBACK VertexPaintDlgProc(
} }
// Subclass procedure // Subclass procedure
LRESULT APIENTRY colorSwatchSubclassWndProc( LRESULT APIENTRY colorSwatchSubclassWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
HWND hwnd, {
UINT uMsg, switch (uMsg)
WPARAM wParam,
LPARAM lParam)
{ {
switch (uMsg) {
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
case WM_LBUTTONUP: case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK: { case WM_LBUTTONDBLCLK:
{
HWND hPanel = GetParent(hwnd); HWND hPanel = GetParent(hwnd);
LONG_PTR mod = GetWindowLongPtr(hPanel, GWLP_USERDATA); LONG_PTR mod = GetWindowLongPtr(hPanel, GWLP_USERDATA);
if (mod) { if (mod)
{
((VertexPaint*)mod)->PaletteButton(hwnd); ((VertexPaint*)mod)->PaletteButton(hwnd);
} }
} }
@ -242,7 +244,8 @@ ICustButton* VertexPaint::iPickButton = NULL;
IColorSwatch* VertexPaint::iColor = NULL; IColorSwatch* VertexPaint::iColor = NULL;
COLORREF VertexPaint::lastWeightColor = RGB(85, 85, 85); COLORREF VertexPaint::lastWeightColor = RGB(85, 85, 85);
COLORREF VertexPaint::lastPhaseColor = RGB(0, 0, 0); COLORREF VertexPaint::lastPhaseColor = RGB(0, 0, 0);
COLORREF VertexPaint::palColors[] = { COLORREF VertexPaint::palColors[] =
{
//RGB(32, 32, 32), RGB( 96,96,96), RGB( 160,160,160), RGB(224,224,224) }; //RGB(32, 32, 32), RGB( 96,96,96), RGB( 160,160,160), RGB(224,224,224) };
RGB(0, 0, 0), RGB(85,85,85), RGB(170,170,170), RGB(255,255,255), RGB(0, 0, 0), RGB(85,85,85), RGB(170,170,170), RGB(255,255,255),
RGB(42, 42, 42), RGB(127, 127, 127), RGB(212, 212, 212) }; RGB(42, 42, 42), RGB(127, 127, 127), RGB(212, 212, 212) };
@ -400,13 +403,9 @@ void VertexPaint::BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev )
this->ip = ip; this->ip = ip;
editMod = this; editMod = this;
if (!hParams) { if (!hParams)
hParams = ip->AddRollupPage( {
hInstance, hParams = ip->AddRollupPage(hInstance, MAKEINTRESOURCE(IDD_PANEL), VertexPaintDlgProc, GetString(IDS_PARAMS), (LPARAM)this);
MAKEINTRESOURCE(IDD_PANEL),
VertexPaintDlgProc,
GetString(IDS_PARAMS),
(LPARAM)this);
// Subclass the palette controls // Subclass the palette controls
hPaletteWnd[0] = GetDlgItem(hParams, IDC_PALETTE_1); hPaletteWnd[0] = GetDlgItem(hParams, IDC_PALETTE_1);
@ -418,7 +417,8 @@ void VertexPaint::BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev )
hPaletteWnd[6] = GetDlgItem(hParams, IDC_PALETTE_7); hPaletteWnd[6] = GetDlgItem(hParams, IDC_PALETTE_7);
int i; int i;
for (i=0; i<NUMPALETTES; i++) { for (i = 0; i < NUMPALETTES; i++)
{
colorSwatchOriginalWndProc = (WNDPROC)SetWindowLongPtr(hPaletteWnd[i], GWLP_WNDPROC, (LONG_PTR)colorSwatchSubclassWndProc); colorSwatchOriginalWndProc = (WNDPROC)SetWindowLongPtr(hPaletteWnd[i], GWLP_WNDPROC, (LONG_PTR)colorSwatchSubclassWndProc);
} }
@ -457,7 +457,8 @@ void VertexPaint::EndEditParams( IObjParam *ip, ULONG flags,Animatable *next)
ModContextList list; ModContextList list;
INodeTab nodes; INodeTab nodes;
ip->GetModContexts(list, nodes); ip->GetModContexts(list, nodes);
for (int i=0; i<list.Count(); i++) { for (int i = 0; i < list.Count(); i++)
{
VertexPaintData *vd = (VertexPaintData*)list[i]->localData; VertexPaintData *vd = (VertexPaintData*)list[i]->localData;
if (vd) vd->FreeCache(); if (vd) vd->FreeCache();
} }
@ -482,9 +483,7 @@ void VertexPaint::EndEditParams( IObjParam *ip, ULONG flags,Animatable *next)
//From ReferenceMaker //From ReferenceMaker
RefResult VertexPaint::NotifyRefChanged( RefResult VertexPaint::NotifyRefChanged(const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate)
Interval changeInt, RefTargetHandle hTarget,
PartID& partID, RefMessage message)
{ {
return REF_SUCCEED; return REF_SUCCEED;
} }
@ -531,8 +530,10 @@ IOResult VertexPaint::Load(ILoad *iload)
int version = 1; int version = 1;
Modifier::Load(iload); Modifier::Load(iload);
while (IO_OK==(res=iload->OpenChunk())) { while (IO_OK == (res = iload->OpenChunk()))
switch(iload->CurChunkID()) { {
switch (iload->CurChunkID())
{
case VERSION_CHUNKID: case VERSION_CHUNKID:
iload->Read(&version, sizeof(version), &nb); iload->Read(&version, sizeof(version), &nb);
break; break;
@ -573,7 +574,8 @@ IOResult VertexPaint::SaveLocalData(ISave *isave, LocalModData *ld)
isave->BeginChunk(COLORLIST_CHUNKID); isave->BeginChunk(COLORLIST_CHUNKID);
numColors = d->GetNumColors(); numColors = d->GetNumColors();
res = isave->Write(&numColors, sizeof(int), &nb); res = isave->Write(&numColors, sizeof(int), &nb);
for (int i=0; i<numColors ; i++) { for (int i = 0; i < numColors; i++)
{
col = d->GetColorData(i); col = d->GetColorData(i);
isave->Write(&col.color, sizeof(col.color), &nb); isave->Write(&col.color, sizeof(col.color), &nb);
} }
@ -582,7 +584,8 @@ IOResult VertexPaint::SaveLocalData(ISave *isave, LocalModData *ld)
return IO_OK; return IO_OK;
} }
IOResult VertexPaint::LoadLocalData(ILoad *iload, LocalModData **pld) { IOResult VertexPaint::LoadLocalData(ILoad *iload, LocalModData **pld)
{
VertexPaintData *d = new VertexPaintData; VertexPaintData *d = new VertexPaintData;
IOResult res; IOResult res;
ULONG nb; ULONG nb;
@ -592,8 +595,10 @@ IOResult VertexPaint::LoadLocalData(ILoad *iload, LocalModData **pld) {
*pld = d; *pld = d;
while (IO_OK==(res=iload->OpenChunk())) { while (IO_OK == (res = iload->OpenChunk()))
switch(iload->CurChunkID()) { {
switch (iload->CurChunkID())
{
case VERSION_CHUNKID: case VERSION_CHUNKID:
iload->Read(&version, sizeof(version), &nb); iload->Read(&version, sizeof(version), &nb);
break; break;
@ -601,7 +606,8 @@ IOResult VertexPaint::LoadLocalData(ILoad *iload, LocalModData **pld) {
{ {
iload->Read(&numColors, sizeof(int), &nb); iload->Read(&numColors, sizeof(int), &nb);
d->AllocColorData(numColors); d->AllocColorData(numColors);
for (int i=0; i<numColors; i++) { for (int i = 0; i < numColors; i++)
{
iload->Read(&col.color, sizeof(col.color), &nb); iload->Read(&col.color, sizeof(col.color), &nb);
d->SetColor(i, col); d->SetColor(i, col);
} }
@ -617,7 +623,8 @@ IOResult VertexPaint::LoadLocalData(ILoad *iload, LocalModData **pld) {
void VertexPaint::PaletteButton(HWND hWnd) void VertexPaint::PaletteButton(HWND hWnd)
{ {
IColorSwatch* iPal = GetIColorSwatch(hWnd); IColorSwatch* iPal = GetIColorSwatch(hWnd);
if (iPal && iColor) { if (iPal && iColor)
{
iColor->SetColor(iPal->GetColor(), TRUE); iColor->SetColor(iPal->GetColor(), TRUE);
} }
} }
@ -625,7 +632,8 @@ void VertexPaint::PaletteButton(HWND hWnd)
void VertexPaint::InitPalettes() void VertexPaint::InitPalettes()
{ {
IColorSwatch* c; IColorSwatch* c;
for (int i=0; i<NUMPALETTES; i++) { for (int i = 0; i < NUMPALETTES; i++)
{
c = GetIColorSwatch(hPaletteWnd[i]); c = GetIColorSwatch(hPaletteWnd[i]);
c->SetColor(palColors[i]); c->SetColor(palColors[i]);
ReleaseIColorSwatch(c); ReleaseIColorSwatch(c);
@ -635,7 +643,8 @@ void VertexPaint::InitPalettes()
void VertexPaint::SavePalettes() void VertexPaint::SavePalettes()
{ {
IColorSwatch* c; IColorSwatch* c;
for (int i=0; i<NUMPALETTES; i++) { for (int i = 0; i < NUMPALETTES; i++)
{
c = GetIColorSwatch(hPaletteWnd[i]); c = GetIColorSwatch(hPaletteWnd[i]);
palColors[i] = c->GetColor(); palColors[i] = c->GetColor();
ReleaseIColorSwatch(c); ReleaseIColorSwatch(c);
@ -1141,17 +1150,20 @@ LocalModData* VertexPaintData::Clone()
{ {
VertexPaintData* d = new VertexPaintData(); VertexPaintData* d = new VertexPaintData();
if (colordata) { if (colordata)
{
d->colordata = new ColorData[numColors]; d->colordata = new ColorData[numColors];
d->numColors = numColors; d->numColors = numColors;
for (int i=0; i<numColors; i++) { for (int i = 0; i < numColors; i++)
{
d->colordata[i] = colordata[i]; d->colordata[i] = colordata[i];
} }
} }
if (nverts) if (nverts)
{ {
d->nverts = new NVert[numnverts]; d->nverts = new NVert[numnverts];
for(int i = 0 ; i < numnverts ; i++ ) { for (int i = 0; i < numnverts; i++)
{
d->nverts[i] = nverts[i]; d->nverts[i] = nverts[i];
} }
@ -1159,7 +1171,8 @@ LocalModData* VertexPaintData::Clone()
if (nvcverts) if (nvcverts)
{ {
d->nvcverts = new NVert[numnvcverts]; d->nvcverts = new NVert[numnvcverts];
for(int i = 0 ; i < numnvcverts ; i++ ) { for (int i = 0; i < numnvcverts; i++)
{
d->nvcverts[i] = nvcverts[i]; d->nvcverts[i] = nvcverts[i];
} }
@ -1168,7 +1181,6 @@ LocalModData* VertexPaintData::Clone()
return d; return d;
} }
void VertexPaintData::SynchVerts(Mesh &m) void VertexPaintData::SynchVerts(Mesh &m)
{ {
if (mesh == NULL) if (mesh == NULL)