806 lines
23 KiB
C++
806 lines
23 KiB
C++
/*=========================================================================
|
||
* _ProjApp.cpp : Main CPP project.
|
||
* This is a part of the CPA project.
|
||
*
|
||
* Version 1.0
|
||
* Creation date 09/09/96
|
||
* Revision date
|
||
*
|
||
* (c) Ubi Studios 1996
|
||
*=======================================================================*/
|
||
|
||
/* here are the directive you must respect when changing this file :
|
||
|
||
* === don't use malloc, but use memory module functions
|
||
* === absolutely no file handling in this file
|
||
* === always specify 'void' keyword for functions parameters and return value
|
||
* === take care of upper / lower case for #include and other filenames
|
||
* === NO C++ style comentary
|
||
* === NO ASSERT, use error module equivalent function
|
||
|
||
*/
|
||
|
||
#include "MainCPA.h"
|
||
#include "ITF.h"
|
||
#include "GAM.h"
|
||
#include "sif.h"
|
||
#include "snd.h"
|
||
#include "VDO.h"
|
||
|
||
#include "_projapp.hpp"
|
||
#include "_projid.h"
|
||
#include "_EditId.h"
|
||
|
||
#ifdef WIN32
|
||
|
||
/* One instance of application*/
|
||
_ProjectApp theApp;
|
||
|
||
#ifdef ACTIVE_EDITOR
|
||
/*
|
||
Keyboard config for application
|
||
*/
|
||
|
||
// add by jt 8/6/97
|
||
#include "ray.h"
|
||
// end jt 8/6/97
|
||
|
||
#define KA_APP_SWAP 1
|
||
#define KA_APP_RASTERS 2
|
||
#define KA_WD_DBACKWARD 3
|
||
#define KA_WD_DFORWARD 4
|
||
#define KA_WD_EBACKWARD 5
|
||
#define KA_WD_EFORWARD 6
|
||
|
||
#define KA_HED_HIERARCHY 7
|
||
#define KA_HED_ACTOR 8
|
||
#define KA_HED_GEOMETRY 9
|
||
#define KA_HED_PHYSICAL 10
|
||
#define KA_HED_IPO 11
|
||
#define KA_HED_LIGHT 12
|
||
#define KA_HED_SECTOR 13
|
||
#define KA_HED_WPWAYS 14
|
||
#define KA_HED_ZONE 15
|
||
#define KA_HED_ACTION 16
|
||
#define KA_HED_MATERIAL 17
|
||
#define KA_HED_MECHANIC 18
|
||
#define KA_HED_PARTICLE 19
|
||
|
||
#define KA_HED_UNDO 20
|
||
#define KA_HED_REDO 21
|
||
|
||
#define KA_APP_SWAPNOPREF 22
|
||
|
||
#define KA_APP_PAUSEENGINE 23
|
||
#define KA_APP_ONESTEPENGINE 24
|
||
#define KA_APP_FORCE3DVIEW 25
|
||
//CPA2 Corneliu Babiuc 06-05-98
|
||
#define KA_HED_SOUND 26
|
||
#define KA_APP_OPTIONS 27
|
||
#define KA_APP_SAVEALL 28
|
||
#define KA_APP_EXIT 29
|
||
#define KA_HED_IPT 30
|
||
//END CPA2 Corneliu Babiuc 20-05-98
|
||
#define KA_APP_REINIT 31
|
||
#define KA_APP_KEYBOARD 32
|
||
|
||
static tdstKeyboardActionDef gs_a_stAppKeys[] =
|
||
{
|
||
{"Swap between Editor and Engine", KA_APP_SWAP},
|
||
{"Swap to Editor without Preferences", KA_APP_SWAPNOPREF},
|
||
{"Activate Hierarchy Editor", KA_HED_HIERARCHY},
|
||
{"Activate Actor Editor", KA_HED_ACTOR},
|
||
{"Activate Geometric Object Editor", KA_HED_GEOMETRY},
|
||
{"Activate Physical Object Editor", KA_HED_PHYSICAL},
|
||
{"Activate IPO Editor", KA_HED_IPO},
|
||
{"Activate Light Editor", KA_HED_LIGHT},
|
||
{"Activate Sector Editor", KA_HED_SECTOR},
|
||
{"Activate Waypoints & Ways Editor", KA_HED_WPWAYS},
|
||
{"Activate Zone Editor", KA_HED_ZONE},
|
||
{"Activate Actions Editor", KA_HED_ACTION},
|
||
{"Activate Material Editor", KA_HED_MATERIAL},
|
||
{"Activate Mechanic Editor", KA_HED_MECHANIC},
|
||
{"Activate Particle Editor", KA_HED_PARTICLE},
|
||
{"Activate Sound Editor", KA_HED_SOUND},
|
||
{"Activate IPT Editor", KA_HED_IPT},
|
||
{"Save All", KA_APP_SAVEALL},
|
||
{"Reinit the map", KA_APP_REINIT},
|
||
{"Undo", KA_HED_UNDO},
|
||
{"Redo", KA_HED_REDO},
|
||
{"Options", KA_APP_OPTIONS},
|
||
{"Keyboard", KA_APP_KEYBOARD},
|
||
{"Exit", KA_APP_EXIT},
|
||
{"Pause Engine", KA_APP_PAUSEENGINE},
|
||
{"One Step Engine", KA_APP_ONESTEPENGINE},
|
||
{"Force 3D View", KA_APP_FORCE3DVIEW},
|
||
{NULL, 0}
|
||
};
|
||
|
||
|
||
|
||
#endif /* ACTIVE_EDITOR*/
|
||
|
||
BOOL bFocusLost=FALSE;
|
||
BOOL bManagingFocus=FALSE;
|
||
BOOL gbForce3DView=FALSE;
|
||
|
||
/*===========================================================================
|
||
/ Description: Inits
|
||
/ Creation date: 09 Sep 96
|
||
/ Author: CB
|
||
/---------------------------------------------------------------------------
|
||
/ Revision date:
|
||
/ Author:
|
||
/===========================================================================*/
|
||
BOOL _ProjectApp::InitApplication (void)
|
||
{
|
||
if (!fn_bInitApplication())
|
||
return FALSE;
|
||
|
||
GMT_fn_vInitFor3DOS();
|
||
SCR_fn_v_RdL0_Init();
|
||
|
||
fn_vInitEngineWhenInitApplication();
|
||
|
||
#ifdef ACTIVE_EDITOR
|
||
HIE_fn_vCreateMatrixStack();
|
||
|
||
/* Create keyboard config*/
|
||
mp_oAppKeyboard = new CPA_KeyActionConfiguration("CPAApp.ini", gs_a_stAppKeys);
|
||
mp_oAppKeyboard->mfn_vSetObjectName("Application");
|
||
m_csApplicationName = C_szMainFullName;
|
||
m_csApplicationVersion = C_szMainVersion;
|
||
#endif
|
||
|
||
return CPA_ProjectApp::InitApplication();
|
||
}
|
||
|
||
BOOL _ProjectApp::InitInstance (void)
|
||
{
|
||
return CPA_ProjectApp::InitInstance();
|
||
}
|
||
|
||
void _ProjectApp::ExitApplication (void)
|
||
{
|
||
#ifdef ACTIVE_EDITOR
|
||
/* Delete keyboard config*/
|
||
delete mp_oAppKeyboard;
|
||
|
||
/////////////////////////////////////////////////////////////
|
||
// BIDOUILLE : To force some functions to be in export.LIB
|
||
// FORCE LINK
|
||
/////////////////////////////////////////////////////////////
|
||
int a = -1;
|
||
if (++a)
|
||
{
|
||
// Bidouilles are here (the "a" is just here to avoid
|
||
// following code to be executed)
|
||
WP_tdhWayPoint hWayPoint = WP_fnh_WayPoint_Create();
|
||
WP_fnv_WayPoint_Destroy(hWayPoint);
|
||
|
||
CSplitFrame split;
|
||
DD_bSearchReference(NULL,NULL,0,NULL);
|
||
CPA_ToolDLLBase *p_oDLL;
|
||
DEV_SingleDevice3D oSgl3D(MD_ONEDEVICE);
|
||
|
||
p_oDLL->fn_vSetReceivingEvtEditorMessages();
|
||
p_oDLL->fn_vSetReceivingWindowMessages();
|
||
GEO_xGetCenterPointOfIndexedSphere(NULL,NULL,NULL);
|
||
|
||
g_oCoherenceManager.m_fn_vAddALink( NULL, NULL);
|
||
|
||
DNM_fn_vInitLinkTableOfMecMatCharacteristics();
|
||
|
||
SIF_fn_iGetSoundInfosCount();
|
||
|
||
RAY_vComputeAllSector(NULL);
|
||
|
||
SAI_fn_p_vGetTableValuePointerOf(NULL, SAI_eTypeXX);
|
||
|
||
GLI_xDraw3DLine16(NULL,NULL,NULL,NULL);
|
||
|
||
//ANNECY CT 20/02/98{
|
||
// fn_vFreeJustStructAnim( NULL );
|
||
//ENDANNECY CT}
|
||
|
||
#if defined(ACTIVE_AIDEBUG)
|
||
fn_pstSetValidBreakPoint( NULL, NULL, 0 );
|
||
#endif
|
||
|
||
}
|
||
///////////////// END BIDOUILLE /////////////////////////////
|
||
#endif
|
||
|
||
fn_vExitApplication();
|
||
|
||
CPA_ProjectApp::ExitApplication();
|
||
fn_vDesinitEngineWhenLeaveApplication();
|
||
|
||
}
|
||
|
||
//===========================================================================
|
||
// Description: To activate the given DLL
|
||
// Creation date: 13 Feb 97
|
||
// Author: MT
|
||
//---------------------------------------------------------------------------
|
||
// szDLLName Name of DLL to activate
|
||
// Return BOOL to indicate if dll has to be activated
|
||
//---------------------------------------------------------------------------
|
||
// Revision date:
|
||
// Author:
|
||
//===========================================================================
|
||
#ifdef ACTIVE_EDITOR
|
||
BOOL _ProjectApp::fn_bActivateDLL(char *szDLLName)
|
||
{
|
||
if ( M_bEditorsActive() )
|
||
{
|
||
CPA_DLLBase *p_oDLL = m_p_oMainWorld->GetObjectDLLWithName(szDLLName);
|
||
if ( p_oDLL ) // DLL founded
|
||
{
|
||
m_p_oMainWorld->fn_bActivateEditor(p_oDLL,NULL);
|
||
return TRUE;
|
||
}
|
||
else
|
||
{
|
||
p_oDLL = m_p_oMainWorld->GetToolDLLWithName(szDLLName);
|
||
if ( p_oDLL ) // DLL founded
|
||
{
|
||
m_p_oMainWorld->fn_bActivateEditor(p_oDLL,NULL);
|
||
return TRUE;
|
||
}
|
||
else // there's no DLL with that name!!
|
||
{
|
||
CString oCst;
|
||
oCst . Format ( "the DLL ' %s ' does not exist!" , szDLLName);
|
||
AfxMessageBox(oCst,MB_ICONEXCLAMATION | MB_OK);
|
||
}
|
||
}
|
||
}
|
||
return FALSE;
|
||
}
|
||
|
||
//===========================================================================
|
||
// Description: To update dynamic lights
|
||
// Creation date:
|
||
// Author:
|
||
//---------------------------------------------------------------------------
|
||
// Revision date:
|
||
// Author:
|
||
//===========================================================================
|
||
void _ProjectApp::fn_vUpdateDynamicLights (void)
|
||
{
|
||
m_p_oMainWorld->m_lNbDynamicLights = 0;
|
||
fn_vFindDynamicLights(gp_stDynamicWorld, &m_p_oMainWorld->m_lNbDynamicLights, m_p_oMainWorld->m_a_tdxhArrayOfDynamicLights);
|
||
}
|
||
|
||
void _ProjectApp::fn_vFindDynamicLights (HIE_tdxHandleToSuperObject hCharacter, long *lNbLights, GLI_tdxHandleToLight a_hLights[])
|
||
{
|
||
HIE_tdxHandleToSuperObject hChild;
|
||
long i;
|
||
|
||
if (!hCharacter)
|
||
return;
|
||
|
||
// character ?
|
||
if (HIE_fn_ulGetSuperObjectType(hCharacter) == HIE_C_ulActor)
|
||
{
|
||
// is there dynamic light ?
|
||
if ((M_GetEngineObject(hCharacter)->h_MSLight)&&(fn_ucMSLightGetOnOff(M_GetEngineObject(hCharacter)->h_MSLight)))
|
||
{
|
||
a_hLights[(*lNbLights)++] = fn_p_stMSLightGetLight(M_GetEngineObject(hCharacter)->h_MSLight);
|
||
}
|
||
}
|
||
|
||
// next level of dynamic hierarchy
|
||
HIE_M_ForEachChildOf(hCharacter, hChild, i)
|
||
{
|
||
fn_vFindDynamicLights(hChild, lNbLights, a_hLights);
|
||
}
|
||
}
|
||
|
||
#endif // ACTIVE_EDITOR
|
||
|
||
//===========================================================================
|
||
// Description: To treat application keys even if engine is running.
|
||
// Creation date: 17 Jul 96
|
||
// Author: CB
|
||
//---------------------------------------------------------------------------
|
||
// nChar Key to treat
|
||
// Return BOOL to indicate if key has been treated
|
||
//---------------------------------------------------------------------------
|
||
// Revision date:
|
||
// Author:
|
||
//===========================================================================
|
||
#ifdef ACTIVE_EDITOR
|
||
BOOL _ProjectApp::fn_bTreatAppKeyboard(UINT nChar)
|
||
{
|
||
CPA_EditorBase *p_oEditor;
|
||
BOOL bUp = FALSE;
|
||
BOOL bShint = FALSE;
|
||
|
||
if(nChar & 0x40000000)
|
||
{
|
||
nChar &= 0xbfffffff;
|
||
bShint = TRUE;
|
||
}
|
||
|
||
if (!M_bEditorsActive())
|
||
gbForce3DView = FALSE;
|
||
|
||
if(nChar & 0x80000000)
|
||
{
|
||
bUp = TRUE;
|
||
nChar &= 0x7FFFFFFF;
|
||
if(mp_oAppKeyboard->mfn_uwKeyToAction(nChar) == KA_APP_FORCE3DVIEW)
|
||
{
|
||
gbForce3DView = FALSE;
|
||
return TRUE;
|
||
}
|
||
}
|
||
if(gbForce3DView)
|
||
{
|
||
if(bUp)
|
||
M_GetMainDevice2()->GetDevice(0)->GetViewPort()->SendMessage(WM_KEYUP, nChar);
|
||
else
|
||
M_GetMainDevice2()->GetDevice(0)->GetViewPort()->SendMessage(WM_KEYDOWN, nChar);
|
||
return TRUE;
|
||
}
|
||
if(bUp)
|
||
return FALSE;
|
||
|
||
// In edit mode, transform key to action
|
||
switch(mp_oAppKeyboard->mfn_uwKeyToAction(nChar))
|
||
{
|
||
// To swap beetween edit and engine mode
|
||
case KA_APP_SWAP:
|
||
// if(M_GetMainWnd()->m_bEnableEditors)
|
||
// {
|
||
// if (!(M_GetMainDevice()->GetDevice(0)->IsFullScreen()))
|
||
M_GetMainWnd()->SendMessage(WM_COMMAND, CPA_IDCB_SWAPTOEDITORS, 0);
|
||
// }
|
||
return TRUE;
|
||
break;
|
||
|
||
case KA_APP_FORCE3DVIEW:
|
||
if (!M_bEditorsActive())
|
||
return TRUE;
|
||
gbForce3DView = TRUE;
|
||
return TRUE;
|
||
|
||
case KA_APP_PAUSEENGINE:
|
||
if (M_bEditorsActive())
|
||
return FALSE;
|
||
M_GetMainWnd()->SendMessage(WM_COMMAND, CPA_IDCB_PAUSEENGINE, 0);
|
||
return TRUE;
|
||
|
||
case KA_APP_ONESTEPENGINE:
|
||
if (M_bEditorsActive())
|
||
return FALSE;
|
||
M_GetMainWnd()->SendMessage(WM_COMMAND, CPA_IDCB_ONESTEPENGINE, 0);
|
||
return TRUE;
|
||
|
||
case KA_APP_SWAPNOPREF:
|
||
GetInterface()->fn_vUseUserPreferences(FALSE);
|
||
M_GetMainWnd()->SendMessage(WM_COMMAND, CPA_IDCB_SWAPTOEDITORS, 0);
|
||
return TRUE;
|
||
break;
|
||
// the next 4 are for walking through the datas and the editors
|
||
// in the reverse order they were edited or open
|
||
/* case KA_WD_DBACKWARD:
|
||
if (!M_bEditorsActive())
|
||
return FALSE;
|
||
m_oAppliWalkDataMgr.DBackward();
|
||
return TRUE;
|
||
break;
|
||
|
||
case KA_WD_DFORWARD:
|
||
if (!M_bEditorsActive())
|
||
return FALSE;
|
||
m_oAppliWalkDataMgr.DForward();
|
||
return TRUE;
|
||
break;
|
||
|
||
case KA_WD_EBACKWARD:
|
||
if (!M_bEditorsActive())
|
||
return FALSE;
|
||
m_oAppliWalkDataMgr.EBackward();
|
||
return TRUE;
|
||
break;
|
||
|
||
case KA_WD_EFORWARD:
|
||
if (!M_bEditorsActive())
|
||
return FALSE;
|
||
m_oAppliWalkDataMgr.EForward();
|
||
return TRUE;
|
||
break;*/
|
||
|
||
// undo/redo
|
||
case KA_HED_UNDO:
|
||
if(bShint)
|
||
return FALSE;
|
||
if (!M_bEditorsActive())
|
||
return FALSE;
|
||
if(M_GetEditManager()->CanUndo())
|
||
M_GetEditManager()->Undo();
|
||
GetInterface()->GetFrameBase()->fn_vInitGeneralDialogBarWithContext();
|
||
return TRUE;
|
||
break;
|
||
|
||
case KA_HED_REDO:
|
||
if(bShint)
|
||
return FALSE;
|
||
if (!M_bEditorsActive())
|
||
return FALSE;
|
||
if(M_GetEditManager()->CanRedo())
|
||
M_GetEditManager()->Redo();
|
||
GetInterface()->GetFrameBase()->fn_vInitGeneralDialogBarWithContext();
|
||
return TRUE;
|
||
break;
|
||
|
||
// and now, editors activation
|
||
case KA_HED_HIERARCHY:
|
||
if (!M_bEditorsActive())
|
||
return FALSE;
|
||
|
||
//ANNECY Shaitan Correction 03/02/98 {
|
||
p_oEditor = m_p_oMainWorld -> GetEditorByName("Hierarchy");
|
||
//ENDANNECY Shaitan Correction }
|
||
if(p_oEditor)
|
||
{
|
||
m_p_oMainWorld->fn_bActivateEditor(p_oEditor,NULL);
|
||
return TRUE;
|
||
}
|
||
return FALSE;
|
||
break;
|
||
|
||
case KA_HED_ACTOR:
|
||
return fn_bActivateDLL ( C_szDLLActorName );
|
||
break;
|
||
case KA_HED_GEOMETRY:
|
||
return fn_bActivateDLL ( C_szDLLGeometryName );
|
||
break;
|
||
case KA_HED_PHYSICAL:
|
||
return fn_bActivateDLL ( C_szDLLPhysicalObjectName );
|
||
break;
|
||
//ANNECY Shaitan NewInterface 24/03/98 {
|
||
case KA_HED_IPO:
|
||
return fn_bActivateDLL ( C_szDLLInstanciatedPhysicalObjectName );
|
||
break;
|
||
//ENDANNECY Shaitan NewInterface }
|
||
case KA_HED_LIGHT:
|
||
return fn_bActivateDLL ( C_szDLLLightName );
|
||
break;
|
||
case KA_HED_SECTOR:
|
||
return fn_bActivateDLL ( C_szDLLSectorName );
|
||
break;
|
||
case KA_HED_WPWAYS:
|
||
return fn_bActivateDLL ( C_szDLLWayPointName );
|
||
break;
|
||
case KA_HED_ZONE:
|
||
return fn_bActivateDLL ( C_szDLLZDxName );
|
||
break;
|
||
|
||
// tool editor activation
|
||
case KA_HED_ACTION:
|
||
return fn_bActivateDLL ( C_szDLLActionName );
|
||
break;
|
||
case KA_HED_MATERIAL:
|
||
return fn_bActivateDLL ( C_szDLLMaterialName );
|
||
break;
|
||
case KA_HED_MECHANIC:
|
||
return fn_bActivateDLL ( C_szDLLMecaName );
|
||
break;
|
||
//ANNECY Shaitan NewInterface 24/03/98 {
|
||
case KA_HED_PARTICLE:
|
||
return fn_bActivateDLL ( C_szDLLPartGenName );
|
||
break;
|
||
//ENDANNECY Shaitan NewInterface }
|
||
//CPA2 Corneliu Babiuc 06-05-98
|
||
case KA_HED_SOUND:
|
||
return fn_bActivateDLL ( C_szDLLSoundName );
|
||
case KA_HED_IPT:
|
||
return fn_bActivateDLL ( "IPTEditor" );
|
||
case KA_APP_OPTIONS:
|
||
GetInterface()->fn_vDoDialogOptions();
|
||
return TRUE;
|
||
case KA_APP_KEYBOARD:
|
||
{
|
||
A3d_KeyboardAllConfDlg oDialog;
|
||
|
||
oDialog.DoModal();
|
||
return TRUE;
|
||
}
|
||
case KA_APP_SAVEALL:
|
||
GetInterface()->GetFrameBase()->SendMessage(WM_COMMAND, CPA_IDM_SAVEALL);
|
||
return TRUE;
|
||
case KA_APP_REINIT:
|
||
GetInterface()->GetFrameBase()->SendMessage(WM_COMMAND, CPA_IDM_INITMAP);
|
||
return TRUE;
|
||
case KA_APP_EXIT:
|
||
M_GetMainWnd()->SendMessage(WM_COMMAND, CPA_ID_APP_EXIT);
|
||
return TRUE;
|
||
//END CPA2 Corneliu Babiuc 20-05-98
|
||
}
|
||
return FALSE;
|
||
}
|
||
#endif // ACTIVE_EDITOR
|
||
|
||
//===========================================================================
|
||
// Description: Get the project name and version.
|
||
// Creation date: 09 Sep 96
|
||
// Author: CB
|
||
//---------------------------------------------------------------------------
|
||
// Revision date:
|
||
// Author:
|
||
//===========================================================================
|
||
void _ProjectApp::fn_vUpdateFrameTitle(void)
|
||
{
|
||
#ifdef ACTIVE_EDITOR
|
||
sprintf(M_GetMainWnd()->m_szProjectName, "Rayman II - %s", __DATE__);
|
||
#endif
|
||
}
|
||
|
||
//===========================================================================
|
||
// Description: Create a thread for engine.
|
||
// Creation date: 11 Jun 96
|
||
// Author: CB
|
||
//---------------------------------------------------------------------------
|
||
// Return void
|
||
//---------------------------------------------------------------------------
|
||
// Revision date:
|
||
// Author:
|
||
//===========================================================================
|
||
UINT fn_uiPCEngineInterface(LPVOID pt)
|
||
{
|
||
UINT uiRes;
|
||
|
||
#ifdef ACTIVE_EDITOR
|
||
// Bidouille (je suis pouss<73> <20> ces extr<74>mit<69>s)
|
||
// Permet <20> la thread courante d'acc<63>der aux objets C++ de la thread
|
||
// interface.
|
||
AFX_MODULE_THREAD_STATE *pState = AfxGetModuleThreadState();
|
||
CHandleMap *pLast = pState->m_pmapHWND;
|
||
pState->m_pmapHWND = ((AFX_MODULE_THREAD_STATE*)pt)->m_pmapHWND;
|
||
#endif // ACTIVE_EDITOR
|
||
|
||
// Call main C engine loop
|
||
fn_vResetEngineFromPaused();
|
||
uiRes = fn_uiEngineMainLoop();
|
||
|
||
#ifdef ACTIVE_EDITOR
|
||
pState->m_pmapHWND = pLast;
|
||
#endif // ACTIVE_EDITOR
|
||
return uiRes;
|
||
}
|
||
|
||
//===========================================================================
|
||
// Description: Create a thread for engine.
|
||
// Creation date: 11 Jun 96
|
||
// Author: CB
|
||
//---------------------------------------------------------------------------
|
||
// Return void
|
||
//---------------------------------------------------------------------------
|
||
// Revision date:
|
||
// Author:
|
||
//===========================================================================
|
||
void _ProjectApp::fn_vCreateEngineThread(void)
|
||
{
|
||
// Task will be run at the first pain update of the directdraw surface.
|
||
// It will avoid some strange bug in some PCs.
|
||
// => So task ic created suspended
|
||
m_p_oEngineThread = AfxBeginThread
|
||
(fn_uiPCEngineInterface, (LPVOID)AfxGetModuleThreadState(), THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
|
||
}
|
||
|
||
//===========================================================================
|
||
// Description: When main window gains or loose windows focus.
|
||
// Creation date: 09 Sep 96
|
||
// Author: CB
|
||
//---------------------------------------------------------------------------
|
||
// Revision date:
|
||
// Author:
|
||
//===========================================================================
|
||
void _ProjectApp::fn_vWhenAppGainFocus(void)
|
||
{
|
||
if (!bManagingFocus && bFocusLost)
|
||
{
|
||
//SND
|
||
bManagingFocus=TRUE;
|
||
bFocusLost=FALSE;
|
||
SND_fn_vRestoreDriverSound();
|
||
bManagingFocus=FALSE;
|
||
|
||
#ifdef GAM_VIDEO
|
||
//AVI
|
||
VDO_fn_xResumeVideoAVI();
|
||
#endif
|
||
}
|
||
|
||
}
|
||
|
||
void _ProjectApp::fn_vWhenAppLooseFocus(void)
|
||
{
|
||
if (!bManagingFocus && !bFocusLost)
|
||
{
|
||
//AVI
|
||
#ifdef GAM_VIDEO
|
||
VDO_fn_xPauseVideoAVI();
|
||
#endif
|
||
|
||
//SND
|
||
bManagingFocus=TRUE;
|
||
bFocusLost=TRUE;
|
||
SND_fn_vReleaseDriverSound();
|
||
bManagingFocus=FALSE;
|
||
}
|
||
}
|
||
|
||
//===========================================================================
|
||
// Description: called when engine is about to start
|
||
// Creation date: 04 feb 97
|
||
// Author: FBF
|
||
//---------------------------------------------------------------------------
|
||
// Revision date:
|
||
// Author:
|
||
//===========================================================================
|
||
void _ProjectApp::fn_vBeforeEngineStarts(void)
|
||
{
|
||
// resume all sound
|
||
SND_fn_vResumeSound();
|
||
// TODO : Add your code here
|
||
}
|
||
|
||
//===========================================================================
|
||
// Description: called just after engine stops
|
||
// Creation date: 04 feb 97
|
||
// Author: FBF
|
||
//---------------------------------------------------------------------------
|
||
// Revision date:
|
||
// Author:
|
||
//===========================================================================
|
||
void _ProjectApp::fn_vAfterEngineStops(void)
|
||
{
|
||
// stop all sound
|
||
SND_fn_vPauseSound();
|
||
|
||
#if defined(ACTIVE_EDITOR)
|
||
fn_vKillAllAlways();
|
||
#endif /* ACTIVE_EDITOR */
|
||
}
|
||
|
||
|
||
//===========================================================================
|
||
// Description: Do a fatal error.
|
||
// Display a message box et exit application with code -1.
|
||
// Creation date: 25 Jun 96
|
||
// Author: CB
|
||
//---------------------------------------------------------------------------
|
||
// p_szError Error message
|
||
// Return void
|
||
//---------------------------------------------------------------------------
|
||
// Revision date:
|
||
// Author:
|
||
//===========================================================================
|
||
void _ProjectApp::fn_vDynaFatalError(char *p_szError)
|
||
{
|
||
char szTemp[512];
|
||
|
||
sprintf(szTemp, "%s says fatal error !\n\n%s", C_szMainFullName, p_szError);
|
||
AfxMessageBox((LPCTSTR) szTemp, MB_ICONEXCLAMATION | MB_OK);
|
||
if(m_p_oEngineThread)
|
||
::TerminateThread(m_p_oEngineThread->m_hThread, 255);
|
||
::ExitThread(255);
|
||
}
|
||
|
||
#else // WIN32 : other platform than WIN32
|
||
|
||
/*===========================================================================
|
||
/ Description: main function : project entrance for non WIN32 platform
|
||
/ Creation date: 13 January 1997
|
||
/ Author: VL
|
||
/---------------------------------------------------------------------------
|
||
/ argc number of args
|
||
/ argv array of args
|
||
/ return application exit code
|
||
/---------------------------------------------------------------------------
|
||
/ Revision date:
|
||
/ Author:
|
||
/===========================================================================*/
|
||
int main( int argc, char *argv[] )
|
||
{
|
||
/* initialize application*/
|
||
if (!fn_bInitApplication())
|
||
return -1;
|
||
/* create screen display*/
|
||
if (!fn_bCreateMainDisplayScreen())
|
||
return -1;
|
||
/* call engine loop*/
|
||
fn_uiEngineMainLoop();
|
||
/* exit application*/
|
||
fn_vExitApplication();
|
||
return 0;
|
||
}
|
||
|
||
|
||
/*===========================================================================
|
||
/ Description: initialize/create main viewport
|
||
/ Creation date: 13 January 1997
|
||
/ Author: VL
|
||
/---------------------------------------------------------------------------
|
||
/ Return TRUE if success
|
||
/---------------------------------------------------------------------------
|
||
/ Revision date:
|
||
/ Author:
|
||
/===========================================================================*/
|
||
GLD_tdhDevice g_hDeviceHandle;
|
||
GLD_tdhViewport g_hViewport;
|
||
|
||
BOOL fn_bCreateMainDisplayScreen( void )
|
||
{
|
||
/* variable for Device*/
|
||
GLD_tdstDeviceAttributes stDevAttrib;
|
||
/*GLD_tdhDevice hDeviceHandle; */
|
||
|
||
/* variable for ViewPort*/
|
||
GLD_tdstViewportAttributes stViewAttrib;
|
||
/*GLD_tdhViewport hViewport;*/
|
||
|
||
/* create device*/
|
||
stDevAttrib.dwFullScreenModeX = C_dwScreenWidth;
|
||
stDevAttrib.dwFullScreenModeY = C_dwScreenHeight;
|
||
stDevAttrib.dwFullScreenModeBpp = C_dwScreenDepth;
|
||
|
||
if (!GLD_bCreateDevice( &stDevAttrib, &g_hDeviceHandle ))
|
||
return FALSE;
|
||
|
||
/* create viewport*/
|
||
stViewAttrib.dwTopInPercent = 0;
|
||
stViewAttrib.dwBottomInPercent = 100;
|
||
stViewAttrib.dwLeftInPercent = 0;
|
||
stViewAttrib.dwRightInPercent = 100;
|
||
|
||
if (!GLD_bCreateViewport( g_hDeviceHandle, &stViewAttrib, &g_hViewport ))
|
||
return FALSE;
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
#endif /*WIN32*/
|
||
|
||
/*===========================================================================
|
||
/ Description: Initialize appliaction
|
||
/ Creation date: 13 January 1997
|
||
/ Author: VL
|
||
/---------------------------------------------------------------------------
|
||
/ Return state of initialization (TRUE = success, FALSE : error)
|
||
/---------------------------------------------------------------------------
|
||
/ Revision date:
|
||
/ Author:
|
||
/===========================================================================*/
|
||
BOOL fn_bInitApplication( void )
|
||
{
|
||
return TRUE;
|
||
}
|
||
|
||
/*===========================================================================
|
||
/ Description: called before application ends
|
||
/ Creation date: 13 January 1997
|
||
/ Author: VL
|
||
/---------------------------------------------------------------------------
|
||
/ Return void
|
||
/---------------------------------------------------------------------------
|
||
/ Revision date:
|
||
/ Author:
|
||
/===========================================================================*/
|
||
void fn_vExitApplication( void )
|
||
{
|
||
}
|
||
|
||
|
||
void _ProjectApp::fn_vReinitCurrentMap(void)
|
||
{
|
||
#if defined(ACTIVE_EDITOR)
|
||
fn_vReinitTheMap();
|
||
#endif /* ACTIVE_EDITOR */
|
||
}
|