port from perforce
This commit is contained in:
779
evoke-64k/bp10/ConfigFiles.cpp
Normal file
779
evoke-64k/bp10/ConfigFiles.cpp
Normal file
@@ -0,0 +1,779 @@
|
||||
#include "defines.h"
|
||||
#include "ConfigFiles.h"
|
||||
#include "globals.h"
|
||||
|
||||
#include "ShaderFactory.h"
|
||||
|
||||
#include "textinfo.h"
|
||||
#include "intrin.h"
|
||||
|
||||
HANDLE g_FileChangeNotification= NULL;
|
||||
static std::string g_strShaderData;
|
||||
|
||||
|
||||
void StopFileWatch()
|
||||
{
|
||||
if (g_FileChangeNotification != INVALID_HANDLE_VALUE && g_FileChangeNotification != NULL)
|
||||
{
|
||||
FindCloseChangeNotification(g_FileChangeNotification);
|
||||
}
|
||||
g_FileChangeNotification= NULL;
|
||||
}
|
||||
|
||||
void StartFileWatch()
|
||||
{
|
||||
StopFileWatch();
|
||||
std::string strPath= ".\\cfg\\";
|
||||
|
||||
g_FileChangeNotification= FindFirstChangeNotification(
|
||||
strPath.c_str(),
|
||||
FALSE,
|
||||
FILE_NOTIFY_CHANGE_LAST_WRITE );
|
||||
}
|
||||
|
||||
bool CheckFileWatch()
|
||||
{
|
||||
if (g_FileChangeNotification == INVALID_HANDLE_VALUE || g_FileChangeNotification == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD dwRet= WaitForSingleObject( g_FileChangeNotification, 1 );
|
||||
|
||||
if( WAIT_OBJECT_0 == dwRet )
|
||||
{
|
||||
FindNextChangeNotification( g_FileChangeNotification );
|
||||
ReadDataFromDisc();
|
||||
|
||||
// Shader neu compilieren
|
||||
PrepareShaders();
|
||||
|
||||
//Texte neu setzen
|
||||
CreateTextRenderJobs();
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int g_iCurSpriptLength;
|
||||
int g_iCurSpriptParams;
|
||||
|
||||
void ReadScriptTxt()
|
||||
{
|
||||
/*
|
||||
g_iCurSpriptLength= 0;
|
||||
g_iCurSpriptParams= 0;
|
||||
|
||||
FrameWork::TextFileReader tfrScript;
|
||||
tfrScript.read( "cfg/script.txt" );
|
||||
|
||||
//#ifdef SCRIPTEDITOR
|
||||
for( int i= 0; i < (int)tfrScript.getFileLines().size(); ++i )
|
||||
{
|
||||
std::string strAct= tfrScript.getFileLines()[ i ];
|
||||
std::string strCommandFull;
|
||||
if( FrameWork::StringHelper::splitAt( strAct, "=", strCommandFull ) )
|
||||
{
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << strAct;
|
||||
|
||||
if( strCommandFull == "SKIP" )
|
||||
{
|
||||
#ifdef SCRIPTEDITOR
|
||||
ss >> g_iSkipTicks;
|
||||
#endif
|
||||
}
|
||||
if( strCommandFull == "CLEAN" )
|
||||
{
|
||||
g_iCurSpriptLength= 0;
|
||||
g_iCurSpriptParams= 0;
|
||||
}
|
||||
else if( strCommandFull == "CSPEED" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= CSPEED;
|
||||
ss >> g_ScriptParamFloat[ g_iCurSpriptParams++ ];
|
||||
}
|
||||
else if( strCommandFull == "OSPEED" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= OSPEED;
|
||||
ss >> g_ScriptParamFloat[ g_iCurSpriptParams++ ];
|
||||
}
|
||||
else if( strCommandFull == "CTIME" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= CTIME;
|
||||
ss >> g_ScriptParamFloat[ g_iCurSpriptParams++ ];
|
||||
}
|
||||
else if( strCommandFull == "OTIME" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= OTIME;
|
||||
ss >> g_ScriptParamFloat[ g_iCurSpriptParams++ ];
|
||||
}
|
||||
else if( strCommandFull == "CAM" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= CAM;
|
||||
int iVal= 0;
|
||||
ss >> iVal;
|
||||
g_Script[ g_iCurSpriptLength++ ]= iVal;
|
||||
}
|
||||
else if( strCommandFull == "CAM" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= CAM;
|
||||
int iVal= 0;
|
||||
ss >> iVal;
|
||||
g_Script[ g_iCurSpriptLength++ ]= iVal;
|
||||
}
|
||||
else if( strCommandFull == "OBJ" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= OBJ;
|
||||
int iVal= 0;
|
||||
ss >> iVal;
|
||||
g_Script[ g_iCurSpriptLength++ ]= iVal;
|
||||
iVal= 0;
|
||||
ss >> iVal;
|
||||
g_Script[ g_iCurSpriptLength++ ]= iVal;
|
||||
}
|
||||
else if( strCommandFull == "TICK" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= TICK;
|
||||
int iVal= 0;
|
||||
ss >> iVal;
|
||||
g_Script[ g_iCurSpriptLength++ ]= iVal;
|
||||
}
|
||||
else if( strCommandFull == "QUIT" )
|
||||
{
|
||||
g_Script[ g_iCurSpriptLength++ ]= QUIT;
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
*/
|
||||
}
|
||||
|
||||
void ReadParamTxt()
|
||||
{
|
||||
/*
|
||||
FrameWork::TextFileReader tfrSong;
|
||||
tfrSong.read( "cfg/param.txt" );
|
||||
tfrSong.append( "cfg/port.txt" );
|
||||
tfrSong.append( "cfg/cam.txt" );
|
||||
// tfrSong.append( "cfg/script.txt" );
|
||||
|
||||
for( int i= 0; i < (int)tfrSong.getFileLines().size(); ++i )
|
||||
{
|
||||
std::string strAct= tfrSong.getFileLines()[ i ];
|
||||
std::string strCommandFull;
|
||||
if( FrameWork::StringHelper::splitAt( strAct, "=", strCommandFull ) )
|
||||
{
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << strAct;
|
||||
|
||||
#ifdef SINGLEEDITMODE
|
||||
if( strCommandFull == "PCUR" )
|
||||
{
|
||||
ss >> g_iCurrentPortrait;
|
||||
}
|
||||
else if( strCommandFull == "OCUR" )
|
||||
{
|
||||
ss >> g_iCurrentObject;
|
||||
}
|
||||
else if( strCommandFull == "OCOUNT" )
|
||||
{
|
||||
ss >> g_iCurrentObjectCount;
|
||||
}
|
||||
else if( strCommandFull == "CCUR" )
|
||||
{
|
||||
ss >> g_iCurrentCamera;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( strCommandFull.size() < 4 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int iFunc= strCommandFull[ strCommandFull.size() - 1 ] - '0';
|
||||
iFunc+= 10 * ( strCommandFull[ strCommandFull.size() - 2 ] - '0' );
|
||||
iFunc+= 100 * ( strCommandFull[ strCommandFull.size() - 3 ] - '0' );
|
||||
|
||||
std::string strCommand;
|
||||
strCommand= strCommandFull.substr( 0, strCommandFull.size() - 3 );
|
||||
if( strCommand == "BANK" )
|
||||
{
|
||||
for( int j= 0; j < 4; ++j )
|
||||
{
|
||||
float fVal= 0.0f;
|
||||
ss >> fVal;
|
||||
int iVal= (int)( fVal * 64.0f + 0.5f );
|
||||
fVal= (float)( iVal ) / 64.0f;
|
||||
SetParamValue( iFunc, j, fVal );
|
||||
}
|
||||
}
|
||||
else if( strCommand == "SIZE" )
|
||||
{
|
||||
ss >> g_ObjectData[ iFunc ].m_iSizeX;
|
||||
ss >> g_ObjectData[ iFunc ].m_iSizeY;
|
||||
}
|
||||
else if( strCommand == "BASE" )
|
||||
{
|
||||
ss >> g_ObjectData[ iFunc ].m_iBaseMeshType;
|
||||
ss >> g_ObjectData[ iFunc ].m_iBaseBank;
|
||||
}
|
||||
else if( strCommand == "OFFSET" )
|
||||
{
|
||||
ss >> g_ObjectData[ iFunc ].m_iOffsetFunc;
|
||||
ss >> g_ObjectData[ iFunc ].m_iOffsetBank;
|
||||
}
|
||||
else if( strCommand == "HEIGHT" )
|
||||
{
|
||||
ss >> g_ObjectData[ iFunc ].m_iHeightFunc;
|
||||
ss >> g_ObjectData[ iFunc ]. m_iHeightBank;
|
||||
}
|
||||
else if( strCommand == "MIX" )
|
||||
{
|
||||
ss >> g_ObjectData[ iFunc ].m_iMixFunc;
|
||||
ss >> g_ObjectData[ iFunc ].m_iMixBank;
|
||||
}
|
||||
else if( strCommand == "TRANS" )
|
||||
{
|
||||
ss >> g_ObjectData[ iFunc ].m_iTransformFunc;
|
||||
ss >> g_ObjectData[ iFunc ].m_iTransformBank;
|
||||
}
|
||||
else if( strCommand == "COLOR" )
|
||||
{
|
||||
float fR;
|
||||
float fG;
|
||||
float fB;
|
||||
float fA;
|
||||
ss >> fR;
|
||||
ss >> fG;
|
||||
ss >> fB;
|
||||
ss >> fA;
|
||||
fR= min( 255.0f, fR );
|
||||
fG= min( 255.0f, fG );
|
||||
fB= min( 255.0f, fB );
|
||||
fA= min( 255.0f, fA );
|
||||
|
||||
DWORD dwColor= ( (int)fR << 16 ) |
|
||||
( (int)fG << 8 ) |
|
||||
( (int)fB );
|
||||
|
||||
g_ObjectData[ iFunc ].m_dwColor= dwColor;
|
||||
}
|
||||
else if( strCommand == "PSCALE" )
|
||||
{
|
||||
ss >> g_PortraitData[ iFunc ].m_iScale;
|
||||
}
|
||||
else if( strCommand == "PPOS" )
|
||||
{
|
||||
ss >> g_PortraitData[ iFunc ].m_iPosX;
|
||||
ss >> g_PortraitData[ iFunc ].m_iPosY;
|
||||
ss >> g_PortraitData[ iFunc ].m_iTextPosX;
|
||||
ss >> g_PortraitData[ iFunc ].m_iTextPosY;
|
||||
}
|
||||
else if( strCommand == "PTEX" )
|
||||
{
|
||||
ss >> g_PortraitData[ iFunc ].m_iTextureID;
|
||||
}
|
||||
else if( strCommand == "PWORD" )
|
||||
{
|
||||
std::string strText( strAct );
|
||||
FrameWork::StringHelper::searchAndRreplace( "<br>", "\n", strText );
|
||||
strcpy_s( g_PortraitData[ iFunc ].m_pcText, strText.c_str() );
|
||||
}
|
||||
else if( strCommand == "PTICK" )
|
||||
{
|
||||
ss >> g_PortraitData[ iFunc ].m_iTicks;
|
||||
}
|
||||
else if( strCommand == "CTYPE" )
|
||||
{
|
||||
ss >> g_CameraData[ iFunc ].m_iType;
|
||||
ss >> g_CameraData[ iFunc ].m_iBaseBank;
|
||||
ss >> g_CameraData[ iFunc ].m_fFov;
|
||||
}
|
||||
else if( strCommand == "CCOLOR" )
|
||||
{
|
||||
float fR;
|
||||
float fG;
|
||||
float fB;
|
||||
float fA;
|
||||
ss >> fR;
|
||||
ss >> fG;
|
||||
ss >> fB;
|
||||
ss >> fA;
|
||||
fR= min( 255.0f, fR );
|
||||
fG= min( 255.0f, fG );
|
||||
fB= min( 255.0f, fB );
|
||||
|
||||
DWORD dwColor= ( (int)fR << 16 ) |
|
||||
( (int)fG << 8 ) |
|
||||
( (int)fB );
|
||||
|
||||
g_CameraData[ iFunc ].m_dwColor= dwColor;
|
||||
|
||||
fA= max( 1.0f, fA );
|
||||
g_CameraData[ iFunc ].m_fFog= 1.0f / fA;
|
||||
}
|
||||
|
||||
#ifdef SINGLEFUNCEDITOR
|
||||
if( strCommand == "DRAW" )
|
||||
{
|
||||
ss >> g_iCamFunc;
|
||||
ss >> g_iPaintFunc[ 0 ];
|
||||
ss >> g_iPaintFunc[ 1 ];
|
||||
}
|
||||
if( strCommand == "CAMREPEAT" )
|
||||
{
|
||||
ss >> g_iCamRepeat;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void ReadShader( char* pcTarget, const char* pcVarName, const char* pcFileName )
|
||||
{
|
||||
FrameWork::TextFileReader tfrShaderTxt;
|
||||
tfrShaderTxt.read( pcFileName );
|
||||
|
||||
//shorten the data?
|
||||
int iPos= 0;
|
||||
|
||||
for( int i= 0; i < (int)tfrShaderTxt.getFileLines().size(); ++i )
|
||||
{
|
||||
std::string strAct= tfrShaderTxt.getFileLines()[ i ];
|
||||
bool bNonWhiteFound= false;
|
||||
for( size_t j= 0; j < strAct.size(); ++j )
|
||||
{
|
||||
char c= strAct[ j ];
|
||||
if( c == ' ' && !bNonWhiteFound )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if( c == '\t' && !bNonWhiteFound )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bNonWhiteFound= true;
|
||||
if( c == '/' && strAct[ j + 1 ] == '/' )
|
||||
{
|
||||
break;
|
||||
}
|
||||
pcTarget[ iPos ]= c;
|
||||
iPos++;
|
||||
}
|
||||
|
||||
// better readability?
|
||||
pcTarget[ iPos ]= 13;
|
||||
iPos++;
|
||||
}
|
||||
pcTarget[ iPos ]= 0;
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "const char " << pcVarName << "[]=\n";
|
||||
ss << "\"";
|
||||
int iCount= 0;
|
||||
char cPrevious= 0;
|
||||
while( pcTarget[ iCount ] != 0 )
|
||||
{
|
||||
char c= pcTarget[ iCount ];
|
||||
if( c == 13 )
|
||||
{
|
||||
if( 13 != cPrevious && 10 != cPrevious )
|
||||
{
|
||||
ss << "\\n\"\n\"";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << c;
|
||||
}
|
||||
cPrevious= c;
|
||||
iCount++;
|
||||
}
|
||||
ss << "\";\n\n";
|
||||
g_strShaderData+= ss.str();
|
||||
}
|
||||
|
||||
void ReadShaders()
|
||||
{
|
||||
ReadShader( g_ShaderVSGeneral, "g_ShaderVSGeneral", "cfg/vsgeneral.txt" );
|
||||
ReadShader( g_ShaderPSPhong, "g_ShaderPSPhong", "cfg/psphong.txt" );
|
||||
ReadShader( g_ShaderPSRainbow, "g_ShaderPSRainbow", "cfg/psrainbow.txt" );
|
||||
ReadShader( g_ShaderPSTarmac, "g_ShaderPSTarmac", "cfg/pstarmac.txt" );
|
||||
ReadShader( g_ShaderPSWall, "g_ShaderPSWall", "cfg/pswall.txt" );
|
||||
ReadShader( g_ShaderPSGrass, "g_ShaderPSGrass", "cfg/psgrass.txt" );
|
||||
ReadShader( g_ShaderPSDepth, "g_ShaderPSDepth", "cfg/psdepth.txt" );
|
||||
ReadShader( g_ShaderPSText, "g_ShaderPSText", "cfg/pstext.txt" );
|
||||
|
||||
ReadShader( g_ShaderVSSky, "g_ShaderVSSky", "cfg/vssky.txt" );
|
||||
ReadShader( g_ShaderPSSky, "g_ShaderPSSky", "cfg/pssky.txt" );
|
||||
|
||||
ReadShader( g_ShaderVSFSQuad, "g_ShaderVSFSQuad", "cfg/vsfsquad.txt" );
|
||||
ReadShader( g_ShaderPSPSSM, "g_ShaderPSPSSM", "cfg/pspssm.txt" );
|
||||
ReadShader( g_ShaderPSAmbOcc, "g_ShaderPSAmbOcc", "cfg/psao.txt" );
|
||||
ReadShader( g_ShaderPSDOF, "g_ShaderPSDOF", "cfg/psdof.txt" );
|
||||
ReadShader( g_ShaderPSRay, "g_ShaderPSRay", "cfg/psray.txt" );
|
||||
ReadShader( g_ShaderPSBlur, "g_ShaderPSBlur", "cfg/psblur.txt" );
|
||||
}
|
||||
|
||||
void ReadTextInfos()
|
||||
{
|
||||
m_iTextCount= -1;
|
||||
int iCharPos= 0;
|
||||
STextInfo* pInfo= m_TextInfos;
|
||||
|
||||
FrameWork::TextFileReader tfr;
|
||||
tfr.read( "cfg/text.txt" );
|
||||
|
||||
for( int i= 0; i < (int)tfr.getFileLines().size(); ++i )
|
||||
{
|
||||
std::string strAct= tfr.getFileLines()[ i ];
|
||||
std::string strCommandFull;
|
||||
if( FrameWork::StringHelper::splitAt( strAct, "=", strCommandFull ) )
|
||||
{
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << strAct;
|
||||
|
||||
if( strCommandFull == "Text" )
|
||||
{
|
||||
if( m_iTextCount < m_iMaxTextCount )
|
||||
{
|
||||
m_iTextCount++;
|
||||
pInfo= m_TextInfos + m_iTextCount;
|
||||
}
|
||||
strcpy( m_pcTextData + iCharPos, strAct.c_str() );
|
||||
iCharPos+= strAct.size() + 1;
|
||||
|
||||
if( m_iTextCount == 0 )
|
||||
{
|
||||
pInfo->m_v3Pos.x= 0.0f;
|
||||
pInfo->m_v3Pos.y= 0.0f;
|
||||
pInfo->m_v3Pos.z= 0.0f;
|
||||
pInfo->m_v3Rot.x= 0.0f;
|
||||
pInfo->m_v3Rot.y= 0.0f;
|
||||
pInfo->m_v3Rot.z= 0.0f;
|
||||
pInfo->m_v3Scale.x= 1.0f;
|
||||
pInfo->m_v3Scale.y= 1.0f;
|
||||
pInfo->m_v3Scale.z= 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pInfo= m_TextInfos[ m_iTextCount - 1 ];
|
||||
}
|
||||
pInfo->m_v3Move.x= 0.0f;
|
||||
pInfo->m_v3Move.y= 0.0f;
|
||||
pInfo->m_v3Move.z= 0.0f;
|
||||
pInfo->m_iTimeStart= 0;
|
||||
pInfo->m_iTimeLength= 0;
|
||||
}
|
||||
else if( strCommandFull == "Pos" )
|
||||
{
|
||||
ss >> pInfo->m_v3Pos.x;
|
||||
ss >> pInfo->m_v3Pos.y;
|
||||
ss >> pInfo->m_v3Pos.z;
|
||||
}
|
||||
else if( strCommandFull == "Rot" )
|
||||
{
|
||||
ss >> pInfo->m_v3Rot.x;
|
||||
ss >> pInfo->m_v3Rot.y;
|
||||
ss >> pInfo->m_v3Rot.z;
|
||||
pInfo->m_v3Rot.x*= c_PI / 180.0f;
|
||||
pInfo->m_v3Rot.y*= c_PI / 180.0f;
|
||||
pInfo->m_v3Rot.z*= c_PI / 180.0f;
|
||||
}
|
||||
else if( strCommandFull == "Scale" )
|
||||
{
|
||||
ss >> pInfo->m_v3Scale.x;
|
||||
ss >> pInfo->m_v3Scale.y;
|
||||
ss >> pInfo->m_v3Scale.z;
|
||||
}
|
||||
else if( strCommandFull == "Move" )
|
||||
{
|
||||
ss >> pInfo->m_v3Move.x;
|
||||
ss >> pInfo->m_v3Move.y;
|
||||
ss >> pInfo->m_v3Move.z;
|
||||
}
|
||||
else if( strCommandFull == "Time" )
|
||||
{
|
||||
ss >> pInfo->m_iTimeStart;
|
||||
ss >> pInfo->m_iTimeLength;
|
||||
}
|
||||
}
|
||||
m_iTextCount++;
|
||||
}
|
||||
|
||||
|
||||
void ReadDataFromDisc()
|
||||
{
|
||||
ReadParamTxt();
|
||||
ReadScriptTxt();
|
||||
ReadShaders();
|
||||
ReadTextInfos();
|
||||
|
||||
/*static bool bWritten= false;
|
||||
if( bWritten )
|
||||
{
|
||||
return;
|
||||
}*/
|
||||
#ifdef CREATE_HEADER
|
||||
WriteHeader();
|
||||
#endif
|
||||
}
|
||||
|
||||
void WriteHeaderFunc()
|
||||
{
|
||||
/*std::ofstream ofs( "globaldata.h" );
|
||||
|
||||
ofs << "const float FloatParamBanks[ 4 * 512 ]=" << "\n";
|
||||
ofs << "{" << "\n";
|
||||
for( int i= 0; i < 4 * 512; ++i )
|
||||
{
|
||||
char pcSpecial[ 1024 ];
|
||||
sprintf_s(
|
||||
pcSpecial,
|
||||
1024,
|
||||
"%1.9ff,\n",
|
||||
FloatParamBanks[ i ] );
|
||||
ofs << pcSpecial;
|
||||
}
|
||||
ofs << "};" << "\n";
|
||||
ofs << "\n";
|
||||
|
||||
{
|
||||
int iBytes= sizeof( g_CameraData );
|
||||
ofs << "const unsigned char byteCameraData[ " << iBytes <<" ]=" << "\n";
|
||||
ofs << "{" << "\n";
|
||||
|
||||
int iLine= 0;
|
||||
for( int i= 0; i < iBytes; ++i )
|
||||
{
|
||||
ofs << (int)(((unsigned char*)g_CameraData)[ i ]) << ",";
|
||||
|
||||
iLine++;
|
||||
if( iLine == 8 )
|
||||
{
|
||||
ofs << "\n";
|
||||
iLine= 0;
|
||||
}
|
||||
}
|
||||
ofs << "\n" << "};" << "\n";
|
||||
ofs << "SCameraDescription* g_CameraData= (SCameraDescription*)byteCameraData;\n\n";
|
||||
}
|
||||
|
||||
{
|
||||
int iBytes= sizeof( g_ObjectData );
|
||||
ofs << "const unsigned char byteObjectData[ " << iBytes <<" ]=" << "\n";
|
||||
ofs << "{" << "\n";
|
||||
|
||||
int iLine= 0;
|
||||
for( int i= 0; i < iBytes; ++i )
|
||||
{
|
||||
ofs << (int)(((unsigned char*)g_ObjectData)[ i ]) << ",";
|
||||
|
||||
iLine++;
|
||||
if( iLine == 8 )
|
||||
{
|
||||
ofs << "\n";
|
||||
iLine= 0;
|
||||
}
|
||||
}
|
||||
ofs << "\n" << "};" << "\n";
|
||||
ofs << "SObjectDescription* g_ObjectData= (SObjectDescription*)byteObjectData;\n\n";
|
||||
}
|
||||
|
||||
{
|
||||
int iBytes= sizeof( g_PortraitData );
|
||||
ofs << "const unsigned char bytePortraitData[ " << iBytes <<" ]=" << "\n";
|
||||
ofs << "{" << "\n";
|
||||
|
||||
int iLine= 0;
|
||||
for( int i= 0; i < iBytes; ++i )
|
||||
{
|
||||
ofs << (int)(((unsigned char*)g_PortraitData)[ i ]) << ",";
|
||||
|
||||
iLine++;
|
||||
if( iLine == 8 )
|
||||
{
|
||||
ofs << "\n";
|
||||
iLine= 0;
|
||||
}
|
||||
}
|
||||
ofs << "\n" << "};" << "\n";
|
||||
ofs << "SPortraitDescription* g_PortraitData= (SPortraitDescription*)bytePortraitData;\n\n";
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
ofs << "const int g_iFuncCount= " << g_iFuncCountWrite << ";\n";
|
||||
ofs << "const int g_iFuncType[ g_iFuncCount ]=" << "\n";
|
||||
ofs << "{" << "\n";
|
||||
for( int i= 0; i < g_iFuncCountWrite; ++i )
|
||||
{
|
||||
ofs << g_iFuncType[ i ] << "," << "\n";
|
||||
}
|
||||
ofs << "};" << "\n";
|
||||
ofs << "\n";
|
||||
|
||||
ofs << "const DWORD g_dwFuncColor[ 32 ]=" << "\n";
|
||||
ofs << "{" << "\n";
|
||||
for( int i= 0; i < 32; ++i )
|
||||
{
|
||||
ofs << g_dwFuncColor[ i ] << "," << "\n";
|
||||
}
|
||||
ofs << "};" << "\n";
|
||||
ofs << "\n";
|
||||
|
||||
ofs << "const int g_iRanges[ 32 ]=" << "\n";
|
||||
ofs << "{" << "\n";
|
||||
for( int i= 0; i < 32; ++i )
|
||||
{
|
||||
ofs << g_iRanges[ i ] << "," << "\n";
|
||||
}
|
||||
|
||||
ofs << "};" << "\n";
|
||||
ofs << "\n";
|
||||
|
||||
ofs << "const int g_iDrawObj[ 16 ]=" << "\n";
|
||||
ofs << "{" << "\n";
|
||||
for( int i= 0; i < 16; ++i )
|
||||
{
|
||||
ofs << g_iDrawObj[ i ] << "," << "\n";
|
||||
}
|
||||
ofs << "};" << "\n";
|
||||
ofs << "\n";
|
||||
|
||||
ofs << "const float g_fParameter[ g_iParamCount * g_iFuncCount ]=" << "\n";
|
||||
ofs << "{" << "\n";
|
||||
for( int i= 0; i < g_iParamCount; ++i )
|
||||
{
|
||||
for( int j= 0; j < g_iFuncCountWrite; ++j )
|
||||
{
|
||||
char pcSpecial[ 1024 ];
|
||||
sprintf_s(
|
||||
pcSpecial,
|
||||
1024,
|
||||
"%1.9ff,\n",
|
||||
g_fParameter[ j + g_iFuncCount * i] );
|
||||
ofs << pcSpecial;
|
||||
}
|
||||
}
|
||||
ofs << "};" << "\n";
|
||||
ofs << "\n";
|
||||
*/
|
||||
}
|
||||
|
||||
void WriteHeaderScript()
|
||||
{
|
||||
/*
|
||||
std::ofstream ofs( "scriptdata.h" );
|
||||
ofs << "const int g_iScriptLength= " << g_iCurSpriptLength << ";\n";
|
||||
ofs << "const unsigned char g_Script[ g_iScriptLength ]=" << "\n";
|
||||
ofs << "{" << "\n";
|
||||
for( int i= 0; i < g_iCurSpriptLength; ++i )
|
||||
{
|
||||
ofs << (int)g_Script[ i ] << ",\n";
|
||||
}
|
||||
ofs << "};" << "\n";
|
||||
|
||||
ofs << "const float g_ScriptParamFloat[ " << g_iCurSpriptParams << " ]=" << "\n";
|
||||
ofs << "{" << "\n";
|
||||
for( int i= 0; i < g_iCurSpriptParams; ++i )
|
||||
{
|
||||
char pcSpecial[ 1024 ];
|
||||
sprintf_s(
|
||||
pcSpecial,
|
||||
1024,
|
||||
"%1.9ff,\n",
|
||||
g_ScriptParamFloat[ i ] );
|
||||
ofs << pcSpecial;
|
||||
}
|
||||
ofs << "};" << "\n";
|
||||
ofs << "\n";
|
||||
ofs << "\n";
|
||||
*/
|
||||
}
|
||||
|
||||
void WriterShaderInclude()
|
||||
{
|
||||
std::ofstream ofs( "shaderdata.h" );
|
||||
ofs << g_strShaderData;
|
||||
}
|
||||
|
||||
char m_pcTextData[]= { 64, 64, 0 };
|
||||
|
||||
void WriterTextInclude()
|
||||
{
|
||||
std::ofstream ofs( "textdata.h" );
|
||||
ofs << "int m_iTextCount= " << m_iTextCount <<";\n";
|
||||
ofs << "\n";
|
||||
ofs << "const char m_pcTextData[]=\n";
|
||||
ofs << "{\n";
|
||||
int iZeroCount= 0;
|
||||
for( int i= 0; i < 65536; ++i )
|
||||
{
|
||||
char pcSpecial[ 1024 ];
|
||||
sprintf_s(
|
||||
pcSpecial,
|
||||
1024,
|
||||
"\t%d,\n",
|
||||
(int)m_pcTextData[ i ] );
|
||||
ofs << pcSpecial;
|
||||
if( m_pcTextData[ i ] == 0 )
|
||||
{
|
||||
iZeroCount++;
|
||||
if( iZeroCount == m_iTextCount )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ofs << "};\n";
|
||||
ofs << "\n";
|
||||
|
||||
ofs << "const DWORD c_BinaryText[]= " << "\n";
|
||||
ofs << "{\n";
|
||||
|
||||
for( int i= 0; i < (int)m_iTextCount; ++i )
|
||||
{
|
||||
int dwords= m_iTextCount * sizeof( STextInfo ) / 4;
|
||||
if( dwords > 0 )
|
||||
{
|
||||
DWORD* pdwData= (DWORD*)&(m_TextInfos);
|
||||
for( int j= 0; j < dwords; ++j )
|
||||
{
|
||||
char pcSpecial[ 1024 ];
|
||||
sprintf_s( pcSpecial,
|
||||
1024,
|
||||
"\t%d,\n",
|
||||
pdwData[ j ] );
|
||||
ofs << pcSpecial;
|
||||
}
|
||||
}
|
||||
}
|
||||
ofs << "};\n";
|
||||
ofs << "\n";
|
||||
|
||||
ofs << "STextInfo* m_TextInfos= (STextInfo*)c_BinaryText;\n";
|
||||
ofs << "\n";
|
||||
}
|
||||
|
||||
void WriteHeader()
|
||||
{
|
||||
//#ifdef SINGLEEDITMODE
|
||||
WriteHeaderFunc();
|
||||
//#endif
|
||||
//#ifdef SCRIPTEDITOR
|
||||
WriteHeaderScript();
|
||||
//#endif
|
||||
WriterShaderInclude();
|
||||
WriterTextInclude();
|
||||
}
|
||||
Reference in New Issue
Block a user