1511 lines
37 KiB
C++
1511 lines
37 KiB
C++
//-----------------------------------------------------------------------------------------------
|
|
//
|
|
// EditParameterDialog.cpp
|
|
// * 환경 값 편집 다이얼로그
|
|
//
|
|
//-----------------------------------------------------------------------------------------------
|
|
|
|
|
|
#include "stdafx.h"
|
|
#ifdef _EDIT_ENVIRONMENT_
|
|
|
|
|
|
|
|
#include "StdAfx.h"
|
|
#include <Stdio.h>
|
|
#include <commctrl.h>
|
|
#include "KTypes.h"
|
|
#include "Resource.h"
|
|
#include "EditParameterDialog.h"
|
|
#include "SGameSky.h"
|
|
#include "SGameWorld.h"
|
|
#include "SGameSystem.h"
|
|
|
|
extern SGameSystem * g_pCurrentGameSystem;
|
|
|
|
namespace
|
|
{
|
|
const char* aDesc[ CEditParameterDialog::CB_MAX ] =
|
|
{
|
|
"start",
|
|
"mid",
|
|
"end",
|
|
"fog",
|
|
"cloud",
|
|
"light_dff",
|
|
"light_spc",
|
|
"light_amb"
|
|
};
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
WinBitmap::SCreatePR::SCreatePR()
|
|
{
|
|
w = h =0 ;
|
|
bitCount = 32;
|
|
r = g = b = 255;
|
|
}
|
|
|
|
WinBitmap::SCreatePR::SCreatePR(int w_, int h_, BYTE bitCount_, BYTE r_, BYTE g_, BYTE b_)
|
|
{
|
|
w = w_;
|
|
h = h_;
|
|
r = r_;
|
|
g = g_;
|
|
b = b_;
|
|
bitCount = bitCount_;
|
|
}
|
|
|
|
|
|
int WinBitmap::create()
|
|
{
|
|
m_pRaster = NULL;
|
|
m_pPalette = NULL;
|
|
|
|
return 1;
|
|
}
|
|
|
|
int WinBitmap::loadMemory(BYTE* pMemBuf, int iSizeMemoryBuf)
|
|
{
|
|
if(pMemBuf == NULL)
|
|
return 0;
|
|
|
|
m_sBmpFileHeader = *(LPBITMAPFILEHEADER)pMemBuf;
|
|
iSizeMemoryBuf -= m_sBmpFileHeader.bfOffBits;
|
|
m_sBmpInfo = *(LPBITMAPINFO)(pMemBuf + sizeof(BITMAPFILEHEADER)); // BITMAPINFO 과 BITMAPINFOHEADER 구조체의 포인터를 초기화
|
|
m_sBmpInfoHeader = *(LPBITMAPINFOHEADER)(pMemBuf + sizeof(BITMAPFILEHEADER));
|
|
m_pRaster = (BYTE*)(pMemBuf + m_sBmpFileHeader.bfOffBits); // 비트맵의 컬러테이블의 포인터를 계산
|
|
m_bLoadOK = FALSE;
|
|
|
|
return 1;
|
|
}
|
|
|
|
int WinBitmap::loadFile(const char* pName)
|
|
{
|
|
if(pName == NULL)
|
|
return 0;
|
|
|
|
FILE* pFile = fopen(pName, "r"); // open file
|
|
if(pFile == NULL)
|
|
return -1;
|
|
|
|
int nPos = fseek(pFile, 0, SEEK_END); // move file pointer
|
|
if(nPos)
|
|
{
|
|
fclose(pFile);
|
|
return -2;
|
|
}
|
|
|
|
nPos = ftell(pFile); // get size
|
|
|
|
fseek(pFile, 0, SEEK_SET); // move to begin file pointer
|
|
|
|
m_pBuffer = new BYTE[nPos]; // nPos -> buffer Size
|
|
|
|
fread(m_pBuffer, sizeof(BYTE) * nPos, 1, pFile); // read file
|
|
|
|
fclose(pFile); // close file
|
|
|
|
loadMemory(m_pBuffer, nPos); // load memory
|
|
|
|
return 1;
|
|
}
|
|
|
|
int WinBitmap::load(const TCHAR* pName)
|
|
{
|
|
if(!pName)
|
|
return 0;
|
|
|
|
UINT dwStyle = LR_LOADFROMFILE;
|
|
HANDLE hde = ::LoadImage(NULL, pName, IMAGE_BITMAP, 0, 0, dwStyle);
|
|
if(hde)
|
|
{
|
|
m_bLoadOK = TRUE;
|
|
return 1;
|
|
}
|
|
|
|
m_bLoadOK = FALSE;
|
|
return 0;
|
|
}
|
|
|
|
int WinBitmap::destroy()
|
|
{
|
|
if(m_pBuffer)
|
|
{
|
|
delete [] m_pBuffer;
|
|
m_pBuffer = NULL;
|
|
}
|
|
|
|
m_bLoadOK = FALSE;
|
|
return 1;
|
|
}
|
|
|
|
bool WinBitmap::makeEmptyBitmap(SCreatePR* pPR)
|
|
{
|
|
if(pPR == NULL)
|
|
return false;
|
|
|
|
int nSize = (pPR->w * (pPR->bitCount / 8)) * pPR->h;
|
|
|
|
m_sBmpFileHeader.bfType = 19778;
|
|
m_sBmpFileHeader.bfSize = 0;
|
|
m_sBmpFileHeader.bfReserved1 = 0;
|
|
m_sBmpFileHeader.bfReserved2 = 0;
|
|
m_sBmpFileHeader.bfOffBits = 54;
|
|
|
|
m_sBmpInfoHeader.biSize = 40;
|
|
m_sBmpInfoHeader.biWidth = pPR->w;
|
|
m_sBmpInfoHeader.biHeight = pPR->h;
|
|
m_sBmpInfoHeader.biPlanes = 1;
|
|
m_sBmpInfoHeader.biBitCount = pPR->bitCount;
|
|
m_sBmpInfoHeader.biCompression = 0;
|
|
m_sBmpInfoHeader.biSizeImage = nSize;
|
|
m_sBmpInfoHeader.biXPelsPerMeter = 0;
|
|
m_sBmpInfoHeader.biYPelsPerMeter = 0;
|
|
m_sBmpInfoHeader.biClrUsed = 0;
|
|
m_sBmpInfoHeader.biClrImportant = 0;
|
|
|
|
m_sBmpInfo.bmiHeader.biSize = 40;
|
|
m_sBmpInfo.bmiHeader.biWidth = pPR->w;
|
|
m_sBmpInfo.bmiHeader.biHeight = pPR->w;
|
|
m_sBmpInfo.bmiHeader.biPlanes = 1;
|
|
m_sBmpInfo.bmiHeader.biBitCount = pPR->bitCount;
|
|
m_sBmpInfo.bmiHeader.biCompression = 0;
|
|
m_sBmpInfo.bmiHeader.biSizeImage = nSize;
|
|
m_sBmpInfo.bmiHeader.biXPelsPerMeter = 0;
|
|
m_sBmpInfo.bmiHeader.biYPelsPerMeter = 0;
|
|
m_sBmpInfo.bmiHeader.biClrUsed = 0;
|
|
m_sBmpInfo.bmiHeader.biClrImportant = 0;
|
|
|
|
m_pBuffer = new BYTE[nSize];
|
|
m_pRaster = m_pBuffer;
|
|
|
|
if(changeColor(pPR->r, pPR->g, pPR->b) == false)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
int WinBitmap::draw(HDC hdc, HWND hWnd, int x, int y, int w, int h, UINT uType)
|
|
{
|
|
if(hWnd<0)
|
|
return 0;
|
|
|
|
// Copy the bits from the in-memory device context to the on-
|
|
// screen device context to do the painting. Use the computed center
|
|
// point for the target offset.
|
|
if(uType == STRECH)
|
|
{
|
|
StretchDIBits(hdc, x, y, w, h,
|
|
0, 0, m_sBmpInfoHeader.biWidth,m_sBmpInfoHeader.biHeight,
|
|
(VOID*)m_pRaster, &m_sBmpInfo, DIB_RGB_COLORS, SRCCOPY);
|
|
}
|
|
else if(uType == COPY)
|
|
{
|
|
StretchDIBits(hdc,
|
|
x, y, w, h,
|
|
0, 0, m_sBmpInfoHeader.biWidth,m_sBmpInfoHeader.biHeight,
|
|
(VOID*)m_pRaster, &m_sBmpInfo, DIB_RGB_COLORS, SRCCOPY);
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
bool WinBitmap::changeColor(BYTE r, BYTE g, BYTE b)
|
|
{
|
|
int nBitCount = m_sBmpInfoHeader.biBitCount / 8;
|
|
int x,y;
|
|
for(y=0; y<m_sBmpInfoHeader.biHeight; y++)
|
|
{
|
|
for(x=0; x<m_sBmpInfoHeader.biWidth; x++)
|
|
{
|
|
int i = ((m_sBmpInfoHeader.biWidth * y) + x) * nBitCount;
|
|
m_pRaster[i ] = b;
|
|
m_pRaster[i+1] = g;
|
|
m_pRaster[i+2] = r;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
WinBitmap::WinBitmap()
|
|
{
|
|
m_bLoadOK = FALSE;
|
|
}
|
|
|
|
WinBitmap::~WinBitmap()
|
|
{
|
|
destroy();
|
|
}
|
|
|
|
HWNDIDS::HWNDIDS()
|
|
{
|
|
set(0, 0, 0, 0);
|
|
}
|
|
|
|
HWNDIDS::HWNDIDS(int id_e, HWND hWnd_e, int id_p, HWND hWnd_p)
|
|
{
|
|
set(id_e, hWnd_e, id_p, hWnd_p);
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
SColorBar::SColorBar(HWND _hParent, int* pEditCtrID, int* pProgressCtrID, int nCheckCtrID, WinBitmap::SCreatePR* pPR)
|
|
{
|
|
if( pEditCtrID && pProgressCtrID && _hParent && pPR )
|
|
{
|
|
hParent = _hParent;
|
|
|
|
hCheck.bCheck = FALSE;
|
|
hCheck.id = nCheckCtrID;
|
|
hCheck.hWnd = GetDlgItem(hParent, hCheck.id );
|
|
SendMessage( hCheck.hWnd, BM_SETCHECK, BST_UNCHECKED, 0 );
|
|
|
|
hIDControl[ R_CONTROL ].id_edit = pEditCtrID[ R_CONTROL ];
|
|
hIDControl[ G_CONTROL ].id_edit = pEditCtrID[ G_CONTROL ];
|
|
hIDControl[ B_CONTROL ].id_edit = pEditCtrID[ B_CONTROL ];
|
|
hIDControl[ R_CONTROL ].id_progress = pProgressCtrID[ R_CONTROL ];
|
|
hIDControl[ G_CONTROL ].id_progress = pProgressCtrID[ G_CONTROL ];
|
|
hIDControl[ B_CONTROL ].id_progress = pProgressCtrID[ B_CONTROL ];
|
|
|
|
hIDControl[ R_CONTROL ].hWnd_edit = GetDlgItem(hParent, hIDControl[ R_CONTROL ].id_edit );
|
|
hIDControl[ G_CONTROL ].hWnd_edit = GetDlgItem(hParent, hIDControl[ G_CONTROL ].id_edit );
|
|
hIDControl[ B_CONTROL ].hWnd_edit = GetDlgItem(hParent, hIDControl[ B_CONTROL ].id_edit );
|
|
hIDControl[ R_CONTROL ].hWnd_progress = GetDlgItem(hParent, hIDControl[ R_CONTROL ].id_progress);
|
|
hIDControl[ G_CONTROL ].hWnd_progress = GetDlgItem(hParent, hIDControl[ G_CONTROL ].id_progress);
|
|
hIDControl[ B_CONTROL ].hWnd_progress = GetDlgItem(hParent, hIDControl[ B_CONTROL ].id_progress);
|
|
|
|
colorBox.makeEmptyBitmap(pPR);
|
|
|
|
for(int x=0; x<MAX_CONTROL; x++)
|
|
{
|
|
SendMessage( hIDControl[ x ].hWnd_progress, TBM_SETRANGE, false, MAKELPARAM(0, 255) );
|
|
SendMessage( hIDControl[ x ].hWnd_progress, TBM_SETPOS, NULL, 0 );
|
|
SendMessage( hIDControl[ x ].hWnd_edit, WM_SETTEXT, 0, (LPARAM)L"0" );
|
|
}
|
|
}
|
|
}
|
|
|
|
SColorBar::~SColorBar()
|
|
{
|
|
|
|
}
|
|
|
|
void SColorBar::Paint(HDC hdc)
|
|
{
|
|
colorBox.draw(hdc,
|
|
hParent,
|
|
rtColor.left,
|
|
rtColor.top,
|
|
rtColor.right,
|
|
rtColor.bottom,
|
|
WinBitmap::STRECH);
|
|
}
|
|
|
|
void SColorBar::UpdateColorEdit(int id)
|
|
{
|
|
if( R_CONTROL > id || MAX_CONTROL <= id )
|
|
return ;
|
|
|
|
char str[128];
|
|
GetWindowText( hIDControl[ id ].hWnd_edit, str, 128 );
|
|
|
|
int nCost = atoi(str);
|
|
if( nCost < 0 )
|
|
{
|
|
nCost = 0;
|
|
sprintf(str, "%d", nCost);
|
|
SetWindowText( hIDControl[ id ].hWnd_edit, str );
|
|
}
|
|
if( nCost > 255 )
|
|
{
|
|
nCost = 255;
|
|
sprintf(str, "%d", nCost);
|
|
SetWindowText( hIDControl[ id ].hWnd_edit, str );
|
|
}
|
|
|
|
color[ R_COLORID + id ] = nCost;
|
|
|
|
SendMessage( hIDControl[ id ].hWnd_progress, TBM_SETPOS, 1, color[ R_COLORID + id ] );
|
|
|
|
colorBox.changeColor(color[ R_COLORID ], color[ G_COLORID ], color[ B_COLORID ]);
|
|
|
|
RECT rt;
|
|
SetRect(&rt, rtColor.left, rtColor.top, rtColor.left + rtColor.right, rtColor.top + rtColor.bottom);
|
|
::InvalidateRect(hParent, &rt, TRUE);
|
|
}
|
|
|
|
void SColorBar::UpdateColorProgress(int id)
|
|
{
|
|
if( R_CONTROL > id || MAX_CONTROL <= id )
|
|
return ;
|
|
|
|
if( hCheck.bCheck == TRUE )
|
|
{
|
|
LRESULT nPos = SendMessage( hIDControl[ id ].hWnd_progress, TBM_GETPOS, 0, 0 );
|
|
char str[64];
|
|
sprintf(str, "%d", nPos);
|
|
|
|
for(int x=R_COLORID; x<MAX_COLORID; x++)
|
|
{
|
|
LRESULT nPos = SendMessage( hIDControl[ id ].hWnd_progress, TBM_GETPOS, 0, 0 );
|
|
|
|
color[ x ] = (BYTE)nPos;
|
|
SendMessage( hIDControl[ x ].hWnd_edit, WM_SETTEXT, 0, (LPARAM)str );
|
|
}
|
|
}
|
|
else
|
|
{
|
|
LRESULT nPos = SendMessage( hIDControl[ id ].hWnd_progress, TBM_GETPOS, 0, 0 );
|
|
|
|
color[ R_COLORID + id ] = (BYTE)nPos;
|
|
char str[64];
|
|
sprintf(str, "%d", nPos);
|
|
SendMessage( hIDControl[ id ].hWnd_edit, WM_SETTEXT, 0, (LPARAM)str );
|
|
}
|
|
|
|
colorBox.changeColor(color[ R_COLORID ], color[ G_COLORID ], color[ B_COLORID ]);
|
|
|
|
RECT rt;
|
|
SetRect(&rt, rtColor.left, rtColor.top, rtColor.left + rtColor.right, rtColor.top + rtColor.bottom);
|
|
::InvalidateRect(hParent, &rt, TRUE);
|
|
}
|
|
|
|
BOOL SColorBar::ColorBarMessageProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
static COLORREF crTemp[16];
|
|
static COLORREF Color=RGB(0,0,255);
|
|
|
|
switch(message)
|
|
{
|
|
case WM_CREATE:
|
|
{
|
|
for (int i=0;i<16;i++)
|
|
{
|
|
crTemp[i]=RGB(255,255,255);
|
|
}
|
|
}
|
|
break;
|
|
case WM_COMMAND:
|
|
{
|
|
switch(HIWORD(wParam))
|
|
{
|
|
case EN_CHANGE:
|
|
{
|
|
WORD id = LOWORD(wParam);
|
|
for(int x = R_CONTROL; x < MAX_CONTROL; x++)
|
|
{
|
|
if( id != hIDControl[ x ].id_edit )
|
|
continue ;
|
|
|
|
UpdateColorEdit( x );
|
|
return TRUE;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
int id = LOWORD(wParam);
|
|
if( id == hCheck.id )
|
|
{
|
|
LRESULT nRe = SendMessage( (HWND)lParam, BM_GETCHECK, 0, 0);
|
|
if( nRe == BST_UNCHECKED )
|
|
hCheck.bCheck = FALSE;
|
|
else if( nRe == BST_CHECKED )
|
|
hCheck.bCheck = TRUE;
|
|
return TRUE;
|
|
}
|
|
}
|
|
break;
|
|
case WM_HSCROLL:
|
|
{
|
|
HWND hTWnd = (HWND)lParam;
|
|
for(int x = R_CONTROL; x < MAX_CONTROL; x++)
|
|
{
|
|
if( hTWnd != hIDControl[ x ].hWnd_progress )
|
|
continue ;
|
|
|
|
UpdateColorProgress( x );
|
|
return TRUE;
|
|
}
|
|
}
|
|
break;
|
|
case WM_LBUTTONDBLCLK:
|
|
case WM_NCLBUTTONDBLCLK:
|
|
{
|
|
POINT pt;
|
|
pt.x = LOWORD(lParam);
|
|
pt.y = HIWORD(lParam);
|
|
RECT rtCal;
|
|
SetRect(&rtCal, rtColor.left, rtColor.top, rtColor.left + rtColor.right, rtColor.top + rtColor.bottom);
|
|
if( PtInRect( &rtCal, pt ) )
|
|
{
|
|
memset(&COL, 0, sizeof(COL));
|
|
COL.lStructSize = sizeof(COL);
|
|
COL.hwndOwner = hParent;
|
|
COL.lpCustColors = crTemp;
|
|
if (ChooseColor(&COL)!=0)
|
|
{
|
|
Color=COL.rgbResult;
|
|
InvalidateRect(hParent, NULL, TRUE);
|
|
|
|
int b = (0x00FF0000 & Color) >> 16;
|
|
int g = (0x0000FF00 & Color) >> 8;
|
|
int r = (0x000000FF & Color);
|
|
|
|
char str[256];
|
|
sprintf(str, "%d", r);
|
|
SetWindowText( hIDControl[ 0 ].hWnd_edit, str );
|
|
UpdateColorEdit( 0 );
|
|
|
|
sprintf(str, "%d", g);
|
|
SetWindowText( hIDControl[ 1 ].hWnd_edit, str );
|
|
UpdateColorEdit( 1 );
|
|
|
|
sprintf(str, "%d", b);
|
|
SetWindowText( hIDControl[ 2 ].hWnd_edit, str );
|
|
UpdateColorEdit( 2 );
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
CEditParameterDialog& GetEditParameterDialog()
|
|
{
|
|
static CEditParameterDialog g_EditParameterDialog;
|
|
return g_EditParameterDialog;
|
|
}
|
|
|
|
CEditParameterDialog::CEditParameterDialog(void)
|
|
{
|
|
m_bInitData = false;
|
|
m_bApply = false;
|
|
}
|
|
|
|
CEditParameterDialog::~CEditParameterDialog(void)
|
|
{
|
|
Destroy();
|
|
m_bInitData = false;
|
|
}
|
|
|
|
void CEditParameterDialog::Create(HWND hWnd)
|
|
{
|
|
Init( hWnd );
|
|
|
|
if( 1 != LoadData() )
|
|
{
|
|
int k=0;
|
|
}
|
|
|
|
m_bInitData = true;
|
|
|
|
ApplyDataTool( APPLY_BOTH );
|
|
|
|
}
|
|
|
|
void CEditParameterDialog::Init(HWND hWnd)
|
|
{
|
|
m_hWndDialog = hWnd;
|
|
|
|
int wh = 60;
|
|
int py = 52;
|
|
int px = 57;
|
|
int gap = 10;
|
|
int count1 = 6;
|
|
|
|
WinBitmap::SCreatePR pr(wh, wh, 32, 0, 0, 0);
|
|
int aControlID[ 16 ][ 7 ] =
|
|
{
|
|
{ EDIT_R, EDIT_G, EDIT_B, SLIDER_R, SLIDER_G, SLIDER_B , CHECK_ALL_0 }, // sky start
|
|
{ EDIT_R2, EDIT_G2, EDIT_B2, SLIDER_R2, SLIDER_G2, SLIDER_B2, CHECK_ALL_1 }, // sky mid
|
|
{ EDIT_R3, EDIT_G3, EDIT_B3, SLIDER_R3, SLIDER_G3, SLIDER_B3, CHECK_ALL_2 }, // sky end
|
|
{ EDIT_R4, EDIT_G4, EDIT_B4, SLIDER_R4, SLIDER_G4, SLIDER_B4, CHECK_ALL_3 }, // fog
|
|
{ EDIT_R5, EDIT_G5, EDIT_B5, SLIDER_R5, SLIDER_G5, SLIDER_B5, CHECK_ALL_4 }, // cloud
|
|
{ EDIT_R6, EDIT_G6, EDIT_B6, SLIDER_R6, SLIDER_G6, SLIDER_B6, CHECK_ALL_10 }, // light diffuse
|
|
{ EDIT_R7, EDIT_G7, EDIT_B7, SLIDER_R7, SLIDER_G7, SLIDER_B7, CHECK_ALL_12 }, // light sepcular
|
|
{ EDIT_R8, EDIT_G8, EDIT_B8, SLIDER_R8, SLIDER_G8, SLIDER_B8, CHECK_ALL_14 }, // light ambient
|
|
{ EDIT_ER , EDIT_EG , EDIT_EB , SLIDER_ER , SLIDER_EG , SLIDER_EB, CHECK_ALL_5 }, // sky start
|
|
{ EDIT_ER2, EDIT_EG2, EDIT_EB2, SLIDER_ER2, SLIDER_EG2, SLIDER_EB2, CHECK_ALL_6 }, // sky mid
|
|
{ EDIT_ER3, EDIT_EG3, EDIT_EB3, SLIDER_ER3, SLIDER_EG3, SLIDER_EB3, CHECK_ALL_7 }, // sky end
|
|
{ EDIT_ER4, EDIT_EG4, EDIT_EB4, SLIDER_ER4, SLIDER_EG4, SLIDER_EB4, CHECK_ALL_8 }, // fog
|
|
{ EDIT_ER5, EDIT_EG5, EDIT_EB5, SLIDER_ER5, SLIDER_EG5, SLIDER_EB5, CHECK_ALL_9 }, // cloud
|
|
{ EDIT_ER6, EDIT_EG6, EDIT_EB6, SLIDER_ER6, SLIDER_EG6, SLIDER_EB6, CHECK_ALL_11 }, // light
|
|
{ EDIT_ER7, EDIT_EG7, EDIT_EB7, SLIDER_ER7, SLIDER_EG7, SLIDER_EB7, CHECK_ALL_13 }, // light diffuse
|
|
{ EDIT_ER8, EDIT_EG8, EDIT_EB8, SLIDER_ER8, SLIDER_EG8, SLIDER_EB8, CHECK_ALL_15 }, // light sepcular
|
|
};
|
|
|
|
int aPos[ 8 ] =
|
|
{ 52, 122, 192, 278, 317 + 65, 417 + 115, 592 + 15, 667 + 15 };
|
|
|
|
int nType = DATA_ORIGIN;
|
|
for(int x=0; x < 16; x++)
|
|
{
|
|
if( x == 8 )
|
|
{
|
|
nType = DATA_EDITING;
|
|
py = 52;
|
|
px = 457;
|
|
}
|
|
|
|
SColorBar* pCB = new SColorBar( hWnd, &aControlID[ x ][ 0 ], &aControlID[ x ][ 3 ], aControlID[ x ][ 6 ], &pr );
|
|
|
|
SetRect( &pCB->rtColor, px, aPos[ x % 8 ], wh, wh );
|
|
|
|
m_aParam[ nType ].vcColorCtrl.push_back( pCB );
|
|
}
|
|
|
|
int aSliderEditID[ 10 ][ 2 ] =
|
|
{
|
|
{ EDIT_FOG_START, SLIDER_FOG_START, },
|
|
{ EDIT_FOG_END, SLIDER_FOG_END }, // fog origin
|
|
{ EDIT_DRY, SLIDER_DRY, },
|
|
{ EDIT_WET, SLIDER_WET }, // sound origin
|
|
{ EDIT_SKYMID, SLIDER_SKYMID }, // sky mid height percent
|
|
{ EDIT_FOG_START_E, SLIDER_FOG_START_E, },
|
|
{ EDIT_FOG_END_E, SLIDER_FOG_END_E }, // fog editind
|
|
{ EDIT_DRY_E, SLIDER_DRY_E, },
|
|
{ EDIT_WET_E, SLIDER_WET_E }, // sound editind
|
|
{ EDIT_SKYMID_E, SLIDER_SKYMID_E }, // sky mid height percent
|
|
};
|
|
|
|
nType = DATA_ORIGIN;
|
|
for(int x=0; x < 10; x++)
|
|
{
|
|
if( x == 5 )
|
|
nType = DATA_EDITING;
|
|
|
|
HWNDIDS* pHW = new HWNDIDS(
|
|
aSliderEditID[ x ][ 0 ], GetDlgItem( hWnd, aSliderEditID[ x ][ 0 ] ),
|
|
aSliderEditID[ x ][ 1 ], GetDlgItem( hWnd, aSliderEditID[ x ][ 1 ] ) );
|
|
|
|
if ( x == 0 || x == 1 || x == 5 || x == 6 )
|
|
initCost( pHW, 0, 9000 );
|
|
else if( x == 4 || x == 9 )
|
|
initCost( pHW, 0, 1000 );
|
|
else
|
|
initCost( pHW, 0, 255 );
|
|
|
|
m_aParam[ nType ].vSilderEdit.push_back( pHW );
|
|
}
|
|
|
|
int aFogCtrl[2][2] =
|
|
{
|
|
{ CHECK_FOG_START, SE_START_FOG },
|
|
{ CHECK_FOG_END, SE_END_FOG }
|
|
};
|
|
for(int x=0; x < 2; x++)
|
|
{
|
|
HWND hWndCtrl = GetDlgItem(hWnd, aFogCtrl[x][0] );
|
|
if( hWndCtrl )
|
|
{
|
|
SendMessage( hWndCtrl, BM_SETCHECK, BST_CHECKED, 0 );
|
|
ShowFogModel( true, aFogCtrl[x][1] );
|
|
}
|
|
}
|
|
|
|
SGameWorld* pGameWorld = dynamicCast<SGameWorld*>(g_pCurrentGameSystem->GetGame());
|
|
if( pGameWorld == NULL )
|
|
return ;
|
|
|
|
pGameWorld->ShowFogModel( true );
|
|
}
|
|
|
|
void CEditParameterDialog::initCost(HWNDIDS* pIDSet, int min, int max)
|
|
{
|
|
if( pIDSet == NULL )
|
|
return ;
|
|
|
|
SendMessage( pIDSet->hWnd_progress, TBM_SETRANGE, false, MAKELPARAM(min, max) );
|
|
SendMessage( pIDSet->hWnd_progress, TBM_SETPOS, NULL, 0 );
|
|
SendMessage( pIDSet->hWnd_edit, WM_SETTEXT, 0, (LPARAM)L"0" );
|
|
}
|
|
|
|
void CEditParameterDialog::Destroy()
|
|
{
|
|
for(int y=0; y<DATA_MAX; y++)
|
|
{
|
|
for(int x=0; x<CB_MAX; x++)
|
|
{
|
|
SColorBar* p = m_aParam[ y ].vcColorCtrl[ x ];
|
|
SAFE_DELETE(p);
|
|
}
|
|
m_aParam[ y ].vcColorCtrl.clear();
|
|
|
|
for(int z=0; z<SE_MAX; z++)
|
|
{
|
|
HWNDIDS* p = m_aParam[ y ].vSilderEdit[ z ];
|
|
SAFE_DELETE(p);
|
|
}
|
|
m_aParam[ y ].vSilderEdit.clear();
|
|
}
|
|
m_bInitData = false;
|
|
|
|
SGameWorld* pGameWorld = dynamicCast<SGameWorld*>(g_pCurrentGameSystem->GetGame());
|
|
if( pGameWorld == NULL )
|
|
return ;
|
|
|
|
pGameWorld->ShowFogModel( false );
|
|
}
|
|
|
|
void CEditParameterDialog::Paint(HWND hWnd)
|
|
{
|
|
if( hWnd == NULL )
|
|
return ;
|
|
|
|
PAINTSTRUCT ps;
|
|
HDC hdc = ::BeginPaint(hWnd, &ps);
|
|
if( hdc == NULL )
|
|
return;
|
|
|
|
for(int y=0; y<DATA_MAX; y++)
|
|
{
|
|
for(int x=0; x<CB_MAX; x++)
|
|
{
|
|
SColorBar* p = m_aParam[ y ].vcColorCtrl[ x ];
|
|
p->Paint(hdc);
|
|
}
|
|
}
|
|
|
|
::EndPaint(hWnd, &ps);
|
|
}
|
|
|
|
void CEditParameterDialog::UpdateEdit(HWNDIDS* pIDSet)
|
|
{
|
|
if( pIDSet == NULL )
|
|
return ;
|
|
|
|
char str[128];
|
|
GetWindowText( pIDSet->hWnd_edit, str, 128 );
|
|
|
|
|
|
int nCost = atoi(str);
|
|
if( pIDSet->id_edit != EDIT_FOG_START &&
|
|
pIDSet->id_edit != EDIT_FOG_END &&
|
|
pIDSet->id_edit != EDIT_DRY &&
|
|
pIDSet->id_edit != EDIT_WET &&
|
|
pIDSet->id_edit != EDIT_SKYMID &&
|
|
pIDSet->id_edit != EDIT_FOG_START_E &&
|
|
pIDSet->id_edit != EDIT_FOG_END_E &&
|
|
pIDSet->id_edit != EDIT_DRY_E &&
|
|
pIDSet->id_edit != EDIT_WET_E &&
|
|
pIDSet->id_edit != EDIT_SKYMID_E
|
|
)
|
|
{
|
|
if( nCost > 255 )
|
|
{
|
|
nCost = 255;
|
|
sprintf(str, "%d", nCost);
|
|
SetWindowText( pIDSet->hWnd_edit, str );
|
|
}
|
|
}
|
|
|
|
if( nCost < 0 )
|
|
{
|
|
nCost = 0;
|
|
sprintf(str, "%d", nCost);
|
|
SetWindowText( pIDSet->hWnd_edit, str );
|
|
}
|
|
|
|
SendMessage(pIDSet->hWnd_progress, TBM_SETPOS, 1, nCost );
|
|
|
|
pIDSet->cost = nCost;
|
|
|
|
if( pIDSet->id_edit == EDIT_SKYMID || pIDSet->id_edit == EDIT_SKYMID_E )
|
|
{
|
|
int nCtrlID = EDIT_SKYMID_RESULT;
|
|
if( pIDSet->id_progress == SLIDER_SKYMID_E )
|
|
nCtrlID = EDIT_SKYMID_RESULT_E;
|
|
|
|
HWND hW = GetDlgItem(m_hWndDialog, nCtrlID);
|
|
if( hW )
|
|
{
|
|
float fPercent = (float)nCost / 1000.0f;
|
|
|
|
sprintf(str, "%.3f", fPercent);
|
|
SetWindowText(hW, str);
|
|
}
|
|
}
|
|
}
|
|
|
|
void CEditParameterDialog::UpdateProgress(HWNDIDS* pIDSet)
|
|
{
|
|
if( pIDSet == NULL )
|
|
return ;
|
|
|
|
LRESULT nPos = SendMessage( pIDSet->hWnd_progress, TBM_GETPOS, 0, 0 );
|
|
|
|
char str[64];
|
|
sprintf(str, "%d", nPos);
|
|
SendMessage( pIDSet->hWnd_edit, WM_SETTEXT, 0, (LPARAM)str );
|
|
|
|
pIDSet->cost = nPos;
|
|
|
|
if( pIDSet->id_progress == SLIDER_SKYMID || pIDSet->id_progress == SLIDER_SKYMID_E )
|
|
{
|
|
int nCtrlID = EDIT_SKYMID_RESULT;
|
|
if( pIDSet->id_progress == SLIDER_SKYMID_E )
|
|
nCtrlID = EDIT_SKYMID_RESULT_E;
|
|
|
|
HWND hW = GetDlgItem(m_hWndDialog, nCtrlID);
|
|
if( hW )
|
|
{
|
|
float fPercent = (float)nPos / 1000.0f;
|
|
|
|
char str[256];
|
|
sprintf(str, "%.3f", fPercent);
|
|
SetWindowText(hW, str);
|
|
}
|
|
}
|
|
}
|
|
|
|
void CEditParameterDialog::GetRGB(SColorBar* pColorBar, char* pBuffer)
|
|
{
|
|
if( pColorBar == NULL || pBuffer == NULL )
|
|
return ;
|
|
|
|
char sep[] = ("\t");
|
|
char* tokn = strtok(pBuffer, sep);
|
|
if(tokn == NULL)
|
|
return ;
|
|
|
|
pColorBar->color[SColorBar::R_COLORID] = atoi(tokn);
|
|
|
|
tokn = strtok(NULL, sep);
|
|
if(tokn == NULL)
|
|
return ;
|
|
|
|
pColorBar->color[SColorBar::G_COLORID] = atoi(tokn);
|
|
|
|
tokn = strtok(NULL, sep);
|
|
if(tokn == NULL)
|
|
return ;
|
|
|
|
pColorBar->color[SColorBar::B_COLORID] = atoi(tokn);
|
|
}
|
|
|
|
void CEditParameterDialog::GetFogInfo(HWNDIDS* pStart, HWNDIDS* pEnd, char* pBuffer)
|
|
{
|
|
if( pStart == NULL || pEnd == NULL || pBuffer == NULL )
|
|
return ;
|
|
|
|
char sep[] = ("\t");
|
|
char* tokn = strtok(pBuffer, sep);
|
|
if(tokn == NULL)
|
|
return ;
|
|
|
|
pStart->cost = atoi(tokn);
|
|
|
|
tokn = strtok(NULL, sep);
|
|
if(tokn == NULL)
|
|
return ;
|
|
|
|
pEnd->cost = atoi(tokn);
|
|
}
|
|
|
|
void CEditParameterDialog::GetSound(HWNDIDS* pDry, HWNDIDS* pWet, char* pBuffer)
|
|
{
|
|
if( pDry == NULL || pWet == NULL || pBuffer == NULL )
|
|
return ;
|
|
|
|
char sep[] = ("\t");
|
|
char* tokn = strtok(pBuffer, sep);
|
|
if(tokn == NULL)
|
|
return ;
|
|
|
|
pDry->cost = atoi(tokn);
|
|
|
|
tokn = strtok(NULL, sep);
|
|
if(tokn == NULL)
|
|
return ;
|
|
|
|
pWet->cost = atoi(tokn);
|
|
}
|
|
|
|
void CEditParameterDialog::GetPercent(HWNDIDS* pCtrl, char* pBuffer)
|
|
{
|
|
if( pCtrl == NULL || pBuffer == NULL )
|
|
return ;
|
|
|
|
char sep[] = ("\t");
|
|
char* tokn = strtok(pBuffer, sep);
|
|
if(tokn == NULL)
|
|
return ;
|
|
|
|
float fCost = atof(tokn);
|
|
pCtrl->cost = int(fCost * 1000.0f);
|
|
}
|
|
|
|
int CEditParameterDialog::LoadData()
|
|
{
|
|
FILE* ptr_file = fopen("environment_parameter.txt", "rt");
|
|
if(NULL == ptr_file)
|
|
return 0;
|
|
|
|
int nType = 0;
|
|
int nCount1 = 0;
|
|
int nCount2 = 0;
|
|
char buffer[256] = {0};
|
|
bool bLoop = TRUE;
|
|
char sep[] = ("\t");
|
|
while(bLoop)
|
|
{
|
|
fgets(buffer, 256, ptr_file);
|
|
char* tokn = strtok(buffer, sep);
|
|
if(tokn == NULL)
|
|
break;
|
|
|
|
if (tokn[0] == ('/') && tokn[1] == ('/'))
|
|
continue ;
|
|
else if(tokn[0] == EOF)
|
|
break ;
|
|
else if(strncmp(tokn, "**end**", strlen("**end**")) == 0)
|
|
{
|
|
break;
|
|
}
|
|
else if(tokn[0] == ('*') && tokn[1] == ('*'))
|
|
continue ;
|
|
else if(strncmp(tokn, "Origin Data", strlen("Origin Data")) == 0)
|
|
{
|
|
nType = DATA_ORIGIN;
|
|
}
|
|
else if(strncmp(tokn, "Editing Data", strlen("Editing Data")) == 0)
|
|
{
|
|
nType = DATA_EDITING;
|
|
}
|
|
else if(strncmp(tokn, "fog : Start End", strlen("fog : Start End")) == 0)
|
|
{
|
|
fgets(buffer, 256, ptr_file);
|
|
|
|
GetSound( m_aParam[ nType ].vSilderEdit[ SE_START_FOG ], m_aParam[ nType ].vSilderEdit[ SE_END_FOG ], buffer );
|
|
}
|
|
else if(strncmp(tokn, "sound : Dry Wet", strlen("sound : Dry Wet")) == 0)
|
|
{
|
|
fgets(buffer, 256, ptr_file);
|
|
|
|
GetSound( m_aParam[ nType ].vSilderEdit[ SE_DRY_SOUND_VLOUME ], m_aParam[ nType ].vSilderEdit[ SE_WET_SOUND_VLOUME ], buffer );
|
|
}
|
|
else if(strncmp(tokn, "Sky Mid Height Percent", strlen("Sky Mid Height Percent")) == 0)
|
|
{
|
|
fgets(buffer, 256, ptr_file);
|
|
|
|
GetPercent( m_aParam[ nType ].vSilderEdit[ SE_SKY_MID ], buffer );
|
|
}
|
|
|
|
bool bParsingColor = false;
|
|
for( int x=0; x<CB_MAX; x++ )
|
|
{
|
|
if( strncmp( tokn, aDesc[x], strlen(aDesc[x]) ) == 0 )
|
|
{
|
|
bParsingColor = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if( bParsingColor == true )
|
|
{
|
|
fgets(buffer, 256, ptr_file);
|
|
|
|
if ( nType == DATA_ORIGIN )
|
|
{
|
|
GetRGB( m_aParam[ nType ].vcColorCtrl[ nCount1 ], buffer );
|
|
nCount1++;
|
|
}
|
|
else if( nType == DATA_EDITING )
|
|
{
|
|
GetRGB( m_aParam[ nType ].vcColorCtrl[ nCount2 ], buffer );
|
|
nCount2++;
|
|
}
|
|
}
|
|
}
|
|
|
|
fclose(ptr_file);
|
|
return 1;
|
|
}
|
|
|
|
int CEditParameterDialog::SaveData()
|
|
{
|
|
FILE* ptr_file = fopen("environment_parameter.txt", "wt");
|
|
if(NULL == ptr_file)
|
|
return 0;
|
|
|
|
char buffer[1024] = {0};
|
|
|
|
fprintf(ptr_file, "**strat**\n");
|
|
|
|
fprintf(ptr_file, "//----------------------------------------------------------\n");
|
|
fprintf(ptr_file, "Origin Data\n");
|
|
fprintf(ptr_file, "Sky Color : RGB\n");
|
|
int x=0;
|
|
for(; x < CB_MAX; x++)
|
|
{
|
|
SColorBar* p = m_aParam[ DATA_ORIGIN ].vcColorCtrl[ x ];
|
|
|
|
fprintf(ptr_file, "%s\n", aDesc[x]);
|
|
fprintf(ptr_file, "%d\t%d\t%d\n\n",
|
|
p->color[ SColorBar::R_COLORID ],
|
|
p->color[ SColorBar::G_COLORID ],
|
|
p->color[ SColorBar::B_COLORID ] );
|
|
}
|
|
|
|
fprintf(ptr_file, "//----------------------------------------------------------\n");
|
|
fprintf(ptr_file, "fog : Start End\n");
|
|
fprintf(ptr_file, "%d\t%d\n\n",
|
|
m_aParam[ DATA_ORIGIN ].vSilderEdit[ SE_START_FOG ]->cost,
|
|
m_aParam[ DATA_ORIGIN ].vSilderEdit[ SE_END_FOG ]->cost );
|
|
|
|
|
|
fprintf(ptr_file, "//----------------------------------------------------------\n");
|
|
fprintf(ptr_file, "sound : Dry Wet\n");
|
|
fprintf(ptr_file, "%d\t%d\n\n",
|
|
m_aParam[ DATA_ORIGIN ].vSilderEdit[ SE_DRY_SOUND_VLOUME ]->cost,
|
|
m_aParam[ DATA_ORIGIN ].vSilderEdit[ SE_WET_SOUND_VLOUME ]->cost );
|
|
fprintf(ptr_file, "\n\n\n");
|
|
|
|
fprintf(ptr_file, "//----------------------------------------------------------\n");
|
|
fprintf(ptr_file, "Sky Mid Height Percent\n");
|
|
float fPercent = (float)m_aParam[ DATA_ORIGIN ].vSilderEdit[ SE_SKY_MID ]->cost / 1000.0f;
|
|
fprintf(ptr_file, "%.3f\n\n", fPercent);
|
|
|
|
|
|
fprintf(ptr_file, "//----------------------------------------------------------\n");
|
|
fprintf(ptr_file, "Editing Data\n");
|
|
fprintf(ptr_file, "Sky Color : RGB\n");
|
|
for(x=0; x < CB_MAX; x++)
|
|
{
|
|
SColorBar* p = m_aParam[ DATA_EDITING ].vcColorCtrl[ x ];
|
|
|
|
fprintf(ptr_file, "%s\n", aDesc[x]);
|
|
fprintf(ptr_file, "%d\t%d\t%d\n\n",
|
|
p->color[ SColorBar::R_COLORID ],
|
|
p->color[ SColorBar::G_COLORID ],
|
|
p->color[ SColorBar::B_COLORID ] );
|
|
}
|
|
|
|
fprintf(ptr_file, "//----------------------------------------------------------\n");
|
|
fprintf(ptr_file, "fog : Start End\n");
|
|
fprintf(ptr_file, "%d\t%d\n\n",
|
|
m_aParam[ DATA_EDITING ].vSilderEdit[ SE_START_FOG ]->cost,
|
|
m_aParam[ DATA_EDITING ].vSilderEdit[ SE_END_FOG ]->cost );
|
|
|
|
fprintf(ptr_file, "//----------------------------------------------------------\n");
|
|
fprintf(ptr_file, "sound : Dry Wet\n");
|
|
fprintf(ptr_file, "%d\t%d\n\n",
|
|
m_aParam[ DATA_EDITING ].vSilderEdit[ SE_DRY_SOUND_VLOUME ]->cost,
|
|
m_aParam[ DATA_EDITING ].vSilderEdit[ SE_WET_SOUND_VLOUME ]->cost );
|
|
|
|
fprintf(ptr_file, "//----------------------------------------------------------\n");
|
|
fprintf(ptr_file, "Sky Mid Height Percent\n");
|
|
fPercent = (float)m_aParam[ DATA_EDITING ].vSilderEdit[ SE_SKY_MID ]->cost / 1000.0f;
|
|
fprintf(ptr_file, "%.3f\n\n", fPercent);
|
|
|
|
fprintf(ptr_file, "**end**\n");
|
|
|
|
fclose(ptr_file);
|
|
return 1;
|
|
}
|
|
|
|
void CEditParameterDialog::ApplyDataTool(int nType)
|
|
{
|
|
if ( nType == APPLY_ORIGIN )
|
|
{
|
|
ApplyDataToolCore( APPLY_ORIGIN );
|
|
}
|
|
else if( nType == APPLY_EDITING )
|
|
{
|
|
ApplyDataToolCore( APPLY_EDITING );
|
|
}
|
|
else if( nType == APPLY_BOTH )
|
|
{
|
|
ApplyDataToolCore( APPLY_ORIGIN );
|
|
|
|
ApplyDataToolCore( APPLY_EDITING );
|
|
}
|
|
}
|
|
|
|
void CEditParameterDialog::ApplyDataToolCore(int nType)
|
|
{
|
|
if( nType < DATA_ORIGIN || nType >= DATA_MAX )
|
|
return ;
|
|
|
|
int x=0;
|
|
for(; x < CB_MAX; x++)
|
|
{
|
|
SColorBar* p = m_aParam[ nType ].vcColorCtrl[ x ];
|
|
|
|
int id = SColorBar::R_COLORID;
|
|
char str[256];
|
|
sprintf(str, "%d", p->color[ id ]);
|
|
SetWindowText( p->hIDControl[ id ].hWnd_edit, str );
|
|
p->UpdateColorEdit( id );
|
|
|
|
id = SColorBar::G_COLORID;
|
|
sprintf(str, "%d", p->color[ id ]);
|
|
SetWindowText( p->hIDControl[ id ].hWnd_edit, str );
|
|
p->UpdateColorEdit( id );
|
|
|
|
id = SColorBar::B_COLORID;
|
|
sprintf(str, "%d", p->color[ id ]);
|
|
SetWindowText( p->hIDControl[ id ].hWnd_edit, str );
|
|
p->UpdateColorEdit( id );
|
|
}
|
|
|
|
for(x=0; x < SE_MAX; x++)
|
|
{
|
|
HWNDIDS* p = m_aParam[ nType ].vSilderEdit[ x ];
|
|
|
|
char str[256];
|
|
sprintf(str, "%d", p->cost);
|
|
SetWindowText( p->hWnd_edit, str );
|
|
|
|
UpdateEdit( p );
|
|
}
|
|
}
|
|
|
|
void CEditParameterDialog::GetOriginDataEditing()
|
|
{
|
|
for(int x=0; x<CB_MAX; x++)
|
|
{
|
|
SColorBar* p = m_aParam[ DATA_ORIGIN ].vcColorCtrl[ x ];
|
|
SColorBar* p2 = m_aParam[ DATA_EDITING ].vcColorCtrl[ x ];
|
|
|
|
p2->color[ SColorBar::R_COLORID ] = p->color[ SColorBar::R_COLORID ];
|
|
p2->color[ SColorBar::G_COLORID ] = p->color[ SColorBar::G_COLORID ];
|
|
p2->color[ SColorBar::B_COLORID ] = p->color[ SColorBar::B_COLORID ];
|
|
}
|
|
|
|
for(int x=0; x<SE_MAX; x++)
|
|
{
|
|
HWNDIDS* p = m_aParam[ DATA_ORIGIN ].vSilderEdit[ x ];
|
|
HWNDIDS* p2 = m_aParam[ DATA_EDITING ].vSilderEdit[ x ];
|
|
|
|
p2->cost = p->cost;
|
|
}
|
|
|
|
ApplyDataToolCore( DATA_EDITING );
|
|
|
|
HWND hW = GetDlgItem(m_hWndDialog, EDIT_SKYMID_RESULT);
|
|
if( hW )
|
|
{
|
|
char str[256];
|
|
GetWindowText(hW, str, 256);
|
|
float fPercent = atof(str);
|
|
|
|
HWNDIDS* p = m_aParam[ DATA_EDITING ].vSilderEdit[ SE_SKY_MID ];
|
|
|
|
int nPos = (int)( fPercent * 1000.0f );
|
|
SendMessage( p->hWnd_progress, TBM_SETPOS, 1, nPos );
|
|
|
|
UpdateProgress( p );
|
|
}
|
|
}
|
|
|
|
BOOL CEditParameterDialog::ColorBarMessageProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
for(int y=0; y<DATA_MAX; y++)
|
|
{
|
|
for(int x=0; x<CB_MAX; x++)
|
|
{
|
|
SColorBar* p = m_aParam[ y ].vcColorCtrl[ x ];
|
|
if( p->ColorBarMessageProc(hDlg, message, wParam, lParam) == TRUE )
|
|
return TRUE;
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CEditParameterDialog::MessageProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
switch (message)
|
|
{
|
|
case WM_COMMAND:
|
|
{
|
|
switch(HIWORD(wParam))
|
|
{
|
|
case EN_CHANGE:
|
|
{
|
|
if( m_bInitData == false )
|
|
break;
|
|
|
|
WORD id = LOWORD(wParam);
|
|
|
|
for(int y=0; y<DATA_MAX; y++)
|
|
{
|
|
for(int x=0; x<CB_MAX; x++)
|
|
{
|
|
SColorBar* p = m_aParam[ y ].vcColorCtrl[ x ];
|
|
|
|
for(int z=0; z<SColorBar::MAX_CONTROL; z++)
|
|
{
|
|
if( id == p->hIDControl[ z ].id_edit )
|
|
{
|
|
UpdateEdit( &p->hIDControl[ z ] );
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
for(int y=0; y<DATA_MAX; y++)
|
|
{
|
|
for(int x=0; x<SE_MAX; x++)
|
|
{
|
|
HWNDIDS* p = m_aParam[ y ].vSilderEdit[ x ];
|
|
if( id == p->id_edit )
|
|
{
|
|
UpdateEdit( p );
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
case WM_HSCROLL:
|
|
{
|
|
if( m_bInitData == false )
|
|
break;
|
|
|
|
HWND hTWnd = (HWND)lParam;
|
|
|
|
for(int y=0; y<DATA_MAX; y++)
|
|
{
|
|
for(int x=0; x<SE_MAX; x++)
|
|
{
|
|
HWNDIDS* p = m_aParam[ y ].vSilderEdit[ x ];
|
|
if( hTWnd == p->hWnd_progress )
|
|
{
|
|
UpdateProgress( p );
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
void CEditParameterDialog::SetParam(HINSTANCE hInst, HWND hWnd)
|
|
{
|
|
m_hInst = hInst;
|
|
m_hWnd = hWnd;
|
|
}
|
|
|
|
void CEditParameterDialog::Show()
|
|
{
|
|
m_hEnvironmentEdit = CreateDialog(m_hInst, MAKEINTRESOURCE(IDD_DIALOG_ENVIRONMENT), m_hWnd, EditParameterDialogProc);
|
|
ShowWindow(m_hEnvironmentEdit, SW_SHOW);
|
|
}
|
|
|
|
void CEditParameterDialog::End()
|
|
{
|
|
Destroy();
|
|
|
|
DestroyWindow(m_hEnvironmentEdit);
|
|
m_hEnvironmentEdit = NULL;
|
|
|
|
SGameWorld* pGameWorld = dynamicCast<SGameWorld*>(g_pCurrentGameSystem->GetGame());
|
|
if( pGameWorld == NULL )
|
|
return ;
|
|
|
|
pGameWorld->SetApplyEnvironmentCost(false);
|
|
}
|
|
|
|
void CEditParameterDialog::GetGameEnvironmentParameter()
|
|
{
|
|
SGameWorld* pGameWorld = dynamicCast<SGameWorld*>(g_pCurrentGameSystem->GetGame());
|
|
if( pGameWorld == NULL )
|
|
return ;
|
|
|
|
SGameWorld::Environment_Info* pEInfo = pGameWorld->GetEditEnvironment();
|
|
if( pEInfo == NULL )
|
|
return ;
|
|
|
|
K3DColor color[ CB_MAX ];
|
|
color[ CB_SKY_START ] = pGameWorld->GetSkyColorStart();
|
|
color[ CB_SKY_MID ] = pGameWorld->GetSkyColorMid();
|
|
color[ CB_SKY_END ] = pGameWorld->GetSkyColorEnd();
|
|
color[ CB_FOG ] = pGameWorld->GetFogColor();
|
|
color[ CB_CLOUD ] = pGameWorld->GetCloudColor();
|
|
|
|
pGameWorld->CopyLightInfoTempLight();
|
|
color[ CB_LIGHT_DFF ] = pGameWorld->GetLightDiffuse();
|
|
color[ CB_LIGHT_SPC ] = pGameWorld->GetLightSpecular();
|
|
color[ CB_LIGHT_AMB ] = pGameWorld->GetLightAmbient();
|
|
|
|
for(int x=0; x < CB_MAX; x++)
|
|
{
|
|
SColorBar* p = m_aParam[ DATA_ORIGIN ].vcColorCtrl[ x ];
|
|
|
|
p->color[ SColorBar::R_COLORID ] = color[ x ].r * 255.0f;
|
|
p->color[ SColorBar::G_COLORID ] = color[ x ].g * 255.0f;
|
|
p->color[ SColorBar::B_COLORID ] = color[ x ].b * 255.0f;
|
|
}
|
|
|
|
float fFogStart = pGameWorld->GetFogStart();
|
|
float fFogEnd = pGameWorld->GetFogEnd();
|
|
float fDry = pGameWorld->GetDryVolume();
|
|
float fWet = pGameWorld->GetWetVolume();
|
|
float fPercent = pGameWorld->GetSkyMidHeightPercent();
|
|
|
|
m_aParam[ DATA_ORIGIN ].vSilderEdit[ SE_START_FOG ]->cost = (int)fFogStart;
|
|
m_aParam[ DATA_ORIGIN ].vSilderEdit[ SE_END_FOG ]->cost = (int)fFogEnd;
|
|
m_aParam[ DATA_ORIGIN ].vSilderEdit[ SE_DRY_SOUND_VLOUME ]->cost = (int)fDry;
|
|
m_aParam[ DATA_ORIGIN ].vSilderEdit[ SE_WET_SOUND_VLOUME ]->cost = (int)fWet;
|
|
|
|
ApplyDataToolCore( APPLY_ORIGIN );
|
|
|
|
HWND hW = GetDlgItem(m_hWndDialog, EDIT_SKYMID_RESULT);
|
|
if( hW )
|
|
{
|
|
char str[256];
|
|
sprintf(str, "%.3f", fPercent);
|
|
SetWindowText(hW, str);
|
|
|
|
HWNDIDS* p = m_aParam[ APPLY_ORIGIN ].vSilderEdit[ SE_SKY_MID ];
|
|
|
|
int nPos = (int)( fPercent * 1000.0f );
|
|
SendMessage( p->hWnd_progress, TBM_SETPOS, 1, nPos );
|
|
|
|
UpdateProgress( p );
|
|
}
|
|
}
|
|
|
|
void CEditParameterDialog::CopyGameEnvironmentParameter()
|
|
{
|
|
SGameWorld* pGameWorld = dynamicCast<SGameWorld*>(g_pCurrentGameSystem->GetGame());
|
|
if( pGameWorld == NULL )
|
|
return ;
|
|
pGameWorld->CopyEnvironmentInfo();
|
|
}
|
|
|
|
void CEditParameterDialog::SetGameEnvironmentParameter(int nType)
|
|
{
|
|
if( nType < DATA_ORIGIN || nType >= DATA_MAX )
|
|
return ;
|
|
|
|
SGameWorld* pGameWorld = dynamicCast<SGameWorld*>(g_pCurrentGameSystem->GetGame());
|
|
if( pGameWorld == NULL )
|
|
return ;
|
|
|
|
SGameWorld::Environment_Info* pEInfo = pGameWorld->GetEditEnvironment();
|
|
if( pEInfo == NULL )
|
|
return ;
|
|
|
|
KColor color[ CB_MAX ];
|
|
|
|
// 1.0 : 255 = rate : x
|
|
// rate = 1.0f * x / 255
|
|
|
|
|
|
for(int x=0; x < CB_MAX; x++)
|
|
{
|
|
SColorBar* p = m_aParam[ nType ].vcColorCtrl[ x ];
|
|
|
|
color[ x ].r = p->color[ SColorBar::R_COLORID ];
|
|
color[ x ].g = p->color[ SColorBar::G_COLORID ];
|
|
color[ x ].b = p->color[ SColorBar::B_COLORID ];
|
|
}
|
|
|
|
pEInfo->SetSkyColor ( K3DColor( color[ CB_SKY_START ] ), K3DColor( color[ CB_SKY_MID ] ), K3DColor( color[ CB_SKY_END ] ) );
|
|
pEInfo->SetFogColor ( color[ CB_FOG ] );
|
|
pEInfo->SetCloudColor( color[ CB_CLOUD ] );
|
|
|
|
pGameWorld->SetLightDiffuse ( color[ CB_LIGHT_DFF ] );
|
|
pGameWorld->SetLightSpecular( color[ CB_LIGHT_SPC ] );
|
|
pGameWorld->SetLightAmbient ( color[ CB_LIGHT_AMB ] );
|
|
|
|
float fFogStart = (float)m_aParam[ nType ].vSilderEdit[ SE_START_FOG ]->cost;
|
|
float fFogEnd = (float)m_aParam[ nType ].vSilderEdit[ SE_END_FOG ]->cost;
|
|
float fDry = (float)m_aParam[ nType ].vSilderEdit[ SE_DRY_SOUND_VLOUME ]->cost;
|
|
float fWet = (float)m_aParam[ nType ].vSilderEdit[ SE_WET_SOUND_VLOUME ]->cost;
|
|
|
|
pEInfo->SetLinearFogStartEnd( fFogStart, fFogEnd );
|
|
pEInfo->SetDryVolume( fDry );
|
|
pEInfo->SetWetVolume( fWet );
|
|
|
|
int nCtrlID = EDIT_SKYMID_RESULT;
|
|
if( nType == DATA_EDITING )
|
|
nCtrlID = EDIT_SKYMID_RESULT_E;
|
|
|
|
HWND hW = GetDlgItem(m_hWndDialog, nCtrlID);
|
|
if( hW )
|
|
{
|
|
char str[256];
|
|
GetWindowText(hW, str, 256);
|
|
float fPercent = atof(str);
|
|
pGameWorld->SetSkyMidHeightPercent( fPercent );
|
|
}
|
|
|
|
pGameWorld->SetApplyEnvironmentCost(true);
|
|
}
|
|
|
|
void CEditParameterDialog::ShowFogModel(bool bShow, int nFogType)
|
|
{
|
|
SGameWorld* pGameWorld = dynamicCast<SGameWorld*>(g_pCurrentGameSystem->GetGame());
|
|
if( pGameWorld == NULL )
|
|
return ;
|
|
|
|
if( nFogType == SE_START_FOG )
|
|
{
|
|
pGameWorld->ShowStartFogModel( bShow );
|
|
}
|
|
else if( nFogType == SE_END_FOG )
|
|
{
|
|
pGameWorld->ShowEndFogModel( bShow );
|
|
}
|
|
}
|
|
|
|
bool CEditParameterDialog::GetApplyFlag()
|
|
{
|
|
return m_bApply;
|
|
}
|
|
|
|
void CEditParameterDialog::SetApplyFlag(bool b)
|
|
{
|
|
m_bApply = b;
|
|
|
|
SGameWorld* pGameWorld = dynamicCast<SGameWorld*>(g_pCurrentGameSystem->GetGame());
|
|
if( pGameWorld == NULL )
|
|
return ;
|
|
|
|
pGameWorld->SetApplyEnvironmentCost( m_bApply );
|
|
|
|
HWND hWndApply = GetDlgItem(m_hWndDialog, BTN_APPLY_EDIT );
|
|
if( hWndApply )
|
|
{
|
|
if( m_bApply )
|
|
SetWindowText( hWndApply, "Apply" );
|
|
else
|
|
SetWindowText( hWndApply, "None" );
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
INT_PTR CALLBACK EditParameterDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
UNREFERENCED_PARAMETER(lParam);
|
|
|
|
if( GetEditParameterDialog().GetLoadedSataFlag() && GetEditParameterDialog().GetApplyFlag() )
|
|
{
|
|
bool bUpdateRealTime = false;
|
|
if( TRUE == GetEditParameterDialog().ColorBarMessageProc(hDlg, message, wParam, lParam) )
|
|
bUpdateRealTime = true;
|
|
if( TRUE == GetEditParameterDialog().MessageProc(hDlg, message, wParam, lParam) )
|
|
bUpdateRealTime = true;
|
|
|
|
if( bUpdateRealTime )
|
|
{
|
|
GetEditParameterDialog().SetGameEnvironmentParameter( CEditParameterDialog::DATA_EDITING );
|
|
}
|
|
}
|
|
|
|
switch (message)
|
|
{
|
|
case WM_INITDIALOG:
|
|
|
|
GetEditParameterDialog().Create(hDlg);
|
|
|
|
::InvalidateRect(hDlg, NULL, TRUE);
|
|
|
|
return (INT_PTR)TRUE;
|
|
|
|
case WM_COMMAND:
|
|
{
|
|
int id = LOWORD(wParam);
|
|
|
|
if (id == IDOK || id == IDCANCEL)
|
|
break;
|
|
|
|
switch(id)
|
|
{
|
|
case BTN_CLOSE:
|
|
{
|
|
ShowWindow( GetEditParameterDialog().GetEnvironmentEditHandle(), SW_HIDE);
|
|
|
|
GetEditParameterDialog().End();
|
|
|
|
return (INT_PTR)TRUE;
|
|
}
|
|
// case BTN_APPLY_ORIGIN:
|
|
// {
|
|
// GetEditParameterDialog().SetGameEnvironmentParameter( CEditParameterDialog::DATA_ORIGIN );
|
|
// } break;
|
|
case BTN_GET_ORIGIN:
|
|
{
|
|
GetEditParameterDialog().GetOriginDataEditing();
|
|
} break;
|
|
case BTN_APPLY_EDIT:
|
|
{
|
|
GetEditParameterDialog().SetApplyFlag( !GetEditParameterDialog().GetApplyFlag() );
|
|
// GetEditParameterDialog().SetGameEnvironmentParameter( CEditParameterDialog::DATA_EDITING );
|
|
} break;
|
|
case BTN_SAVE:
|
|
{
|
|
GetEditParameterDialog().SaveData();
|
|
} break;
|
|
case BTN_GET_GAME_PARAMETER:
|
|
{
|
|
GetEditParameterDialog().GetGameEnvironmentParameter();
|
|
GetEditParameterDialog().SetGameEnvironmentParameter( CEditParameterDialog::DATA_ORIGIN );
|
|
} break;
|
|
case BTN_COPY_GAME_PARAM:
|
|
{
|
|
GetEditParameterDialog().CopyGameEnvironmentParameter();
|
|
} break;
|
|
case CHECK_FOG_START:
|
|
case CHECK_FOG_END:
|
|
{
|
|
int nFogType = -1;
|
|
if ( id == CHECK_FOG_START )
|
|
nFogType = CEditParameterDialog::SE_START_FOG;
|
|
else if( id == CHECK_FOG_END )
|
|
nFogType = CEditParameterDialog::SE_END_FOG;
|
|
|
|
if( nFogType > -1 )
|
|
{
|
|
LRESULT nRe = SendMessage( (HWND)lParam, BM_GETCHECK, 0, 0);
|
|
if( nRe == BST_UNCHECKED )
|
|
GetEditParameterDialog().ShowFogModel( false, nFogType );
|
|
else if( nRe == BST_CHECKED )
|
|
GetEditParameterDialog().ShowFogModel( true, nFogType );
|
|
|
|
GetEditParameterDialog().SetGameEnvironmentParameter( CEditParameterDialog::DATA_EDITING );
|
|
}
|
|
} break;
|
|
}
|
|
}
|
|
break;
|
|
|
|
case WM_PAINT:
|
|
{
|
|
GetEditParameterDialog().Paint(hDlg);
|
|
}
|
|
break;
|
|
case WM_VSCROLL:
|
|
{
|
|
|
|
}
|
|
break;
|
|
|
|
case WM_LBUTTONDOWN:
|
|
{
|
|
int k=0;
|
|
}
|
|
break;
|
|
}
|
|
return (DefWindowProc(hDlg, message, wParam, lParam));
|
|
}
|
|
|
|
|
|
|
|
#endif _EDIT_ENVIRONMENT_ |