Add rayman2 source files
This commit is contained in:
208
Rayman_X/cpa/tempgrp/Tut/Src/DllCom.cpp
Normal file
208
Rayman_X/cpa/tempgrp/Tut/Src/DllCom.cpp
Normal file
@@ -0,0 +1,208 @@
|
||||
//*****************************************************************************
|
||||
//* DllCom.cpp *
|
||||
//*****************************************************************************
|
||||
//* *
|
||||
//* This file contains the communication functions for the TUT dll *
|
||||
//* *
|
||||
//*****************************************************************************
|
||||
//* Author : Alexis Vaisse *
|
||||
//*****************************************************************************
|
||||
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "afxdllx.h"
|
||||
|
||||
#include "ACP_Base.h"
|
||||
#include "ITF.h"
|
||||
#include "..\..\..\Main\Inc\_EditID.h"
|
||||
|
||||
#include "TUT.h"
|
||||
#include "TutInter.hpp"
|
||||
#include "..\TutLib\Inc\Tut_Mngr.hpp"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Global variables
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static char * gs_p_szCPAVersion = C_szCPAVersion;
|
||||
static AFX_EXTENSION_MODULE NEAR extensionDLL = { NULL, NULL };
|
||||
|
||||
#ifdef DLL_ONLY_ONE_INSTANCE
|
||||
static TUT_Interface * gs_p_oTUT_Interface = NULL;
|
||||
#endif
|
||||
|
||||
static CList<CPA_DLLBase*,CPA_DLLBase*> g_oListOfInstances;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// functions that are present in all DLL :
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// fn_p_szGetCPAVersion : Get current CPA version
|
||||
//-----------------------------------------------------------------------------
|
||||
extern "C" char __declspec(dllexport) *fn_p_szGetCPAVersion(void)
|
||||
{
|
||||
return gs_p_szCPAVersion;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// fn_p_stGetDLLIdentity : Get type of this DLL
|
||||
//-----------------------------------------------------------------------------
|
||||
extern "C" tdstDLLIdentity __declspec (dllexport) * fn_p_stGetDLLIdentity (void)
|
||||
{
|
||||
g_stTUT_Identity . eType = TOOL_DLL;
|
||||
g_stTUT_Identity . csName = C_szDLLTutorialName;
|
||||
g_stTUT_Identity . hModule = NULL;
|
||||
g_stTUT_Identity . p_oListOfInstances = & g_oListOfInstances;
|
||||
|
||||
return & g_stTUT_Identity;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// fn_vInitDll : DLL init function
|
||||
//-----------------------------------------------------------------------------
|
||||
extern "C" void __declspec(dllexport) fn_vInitDll (void)
|
||||
{
|
||||
new CDynLinkLibrary (extensionDLL);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// DllMain : DLL entry point
|
||||
//-----------------------------------------------------------------------------
|
||||
extern "C" int __stdcall DllMain (HINSTANCE hInstance , DWORD dwReason , LPVOID lpReserved)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
if (! AfxInitExtensionModule (extensionDLL , hInstance)) return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// fn_p_oGetDLL : Get the DLL
|
||||
//-----------------------------------------------------------------------------
|
||||
extern "C" CPA_DLLBase __declspec(dllexport) * fn_p_oGetDLL (long lKey)
|
||||
{
|
||||
#ifdef DLL_ONLY_ONE_INSTANCE
|
||||
|
||||
switch(lKey)
|
||||
{
|
||||
case 0: // the game world
|
||||
if (gs_p_oTUT_Interface == NULL)
|
||||
{
|
||||
gs_p_oTUT_Interface = new TUT_Interface ();
|
||||
ASSERT(gs_p_oTUT_Interface != NULL);
|
||||
}
|
||||
return gs_p_oTUT_Interface;
|
||||
break;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#else //DLL_ONLY_ONE_INSTANCE
|
||||
|
||||
switch(lKey)
|
||||
{
|
||||
case 0: // the game world
|
||||
return new TUT_Interface ();
|
||||
break;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif //DLL_ONLY_ONE_INSTANCE
|
||||
}
|
||||
|
||||
#undef DLL_ONLY_ONE_INSTANCE
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// fn_vRegisterControl : Register a control
|
||||
//-----------------------------------------------------------------------------
|
||||
void __declspec(dllexport) fn_vRegisterControl (HWND _hWnd , const CString _csName , TUT_tdeControlType _eType)
|
||||
{
|
||||
TUT_g_oTutorialManager . m_fn_vRegisterWnd (_hWnd , _csName , (TUT_tdeWndType) _eType);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// fn_bUnregisterControl : Unregister a control
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL __declspec(dllexport) fn_bUnregisterControl (HWND _hWnd)
|
||||
{
|
||||
return TUT_g_oTutorialManager . m_fn_bUnregisterWnd (_hWnd);
|
||||
}
|
||||
|
||||
/*****************************************************************************\
|
||||
* SpyGetMsgProc
|
||||
*
|
||||
* The Get Message hook function.
|
||||
*
|
||||
\*****************************************************************************/
|
||||
LRESULT CALLBACK SpyGetMsgProc(INT hc, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PMSG pmsg;
|
||||
|
||||
pmsg = (PMSG)lParam;
|
||||
|
||||
if (hc >= 0 && pmsg && pmsg->hwnd)
|
||||
{
|
||||
return TUT_g_oTutorialManager . m_fn_bHookMsgProc(pmsg->hwnd, pmsg->message, pmsg->wParam, pmsg->lParam);
|
||||
}
|
||||
|
||||
//
|
||||
// Note that CallNextHookEx ignores the first parameter (hhook) so
|
||||
// it is acceptable (barely) to pass in a NULL.
|
||||
//
|
||||
return CallNextHookEx(NULL, hc, wParam, lParam);
|
||||
}
|
||||
|
||||
/*****************************************************************************\
|
||||
* SpyGetMsgProc
|
||||
*
|
||||
* The Get Message hook function.
|
||||
*
|
||||
\*****************************************************************************/
|
||||
LRESULT CALLBACK SpyGetWndProc(INT hc, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PCWPSTRUCT pcwps;
|
||||
|
||||
pcwps = (PCWPSTRUCT)lParam;
|
||||
|
||||
if (hc >= 0 && pcwps && pcwps->hwnd)
|
||||
{
|
||||
return TUT_g_oTutorialManager . m_fn_bHookWndProc(pcwps->hwnd, pcwps->message, pcwps->wParam, pcwps->lParam);
|
||||
}
|
||||
|
||||
//
|
||||
// Note that CallNextHookEx ignores the first parameter (hhook) so
|
||||
// it is acceptable (barely) to pass in a NULL.
|
||||
//
|
||||
return CallNextHookEx(NULL, hc, wParam, lParam);
|
||||
}
|
||||
|
||||
/*****************************************************************************\
|
||||
* SpyGetMsgProc
|
||||
*
|
||||
* The Get Message hook function.
|
||||
*
|
||||
\*****************************************************************************/
|
||||
LRESULT CALLBACK SpyGetWndProcRet(INT hc, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PCWPRETSTRUCT pcwpret;
|
||||
|
||||
pcwpret = (PCWPRETSTRUCT)lParam;
|
||||
|
||||
if (hc >= 0 && pcwpret && pcwpret->hwnd)
|
||||
{
|
||||
return TUT_g_oTutorialManager . m_fn_bHookWndProcRet(pcwpret->hwnd, pcwpret->message, pcwpret->wParam, pcwpret->lParam);
|
||||
}
|
||||
|
||||
//
|
||||
// Note that CallNextHookEx ignores the first parameter (hhook) so
|
||||
// it is acceptable (barely) to pass in a NULL.
|
||||
//
|
||||
return CallNextHookEx(NULL, hc, wParam, lParam);
|
||||
}
|
15
Rayman_X/cpa/tempgrp/Tut/Src/TUT.def
Normal file
15
Rayman_X/cpa/tempgrp/Tut/Src/TUT.def
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
LIBRARY
|
||||
EXPORTS
|
||||
fn_p_szGetCPAVersion
|
||||
fn_p_stGetDLLIdentity
|
||||
fn_p_oGetDLL
|
||||
fn_vInitDll
|
||||
fn_vRegisterControl
|
||||
fn_bUnregisterControl
|
||||
SpyGetMsgProc
|
||||
SpyGetWndProc
|
||||
SpyGetWndProcRet
|
||||
SECTIONS
|
||||
.data READ WRITE
|
282
Rayman_X/cpa/tempgrp/Tut/Src/TutInter.cpp
Normal file
282
Rayman_X/cpa/tempgrp/Tut/Src/TutInter.cpp
Normal file
@@ -0,0 +1,282 @@
|
||||
//*****************************************************************************
|
||||
//* TutInter.cpp *
|
||||
//*****************************************************************************
|
||||
//* *
|
||||
//* This file contains the definition of the TUT_Interface class, *
|
||||
//* the interface of the TUT dll. *
|
||||
//* *
|
||||
//*****************************************************************************
|
||||
//* Author : Alexis Vaisse *
|
||||
//*****************************************************************************
|
||||
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "ACP_Base.h"
|
||||
#include "ITF.h"
|
||||
|
||||
#include "TUT.h"
|
||||
#include "TutInter.hpp"
|
||||
#include "DlgInput.hpp"
|
||||
#include "..\TutLib\Inc\Tut_Mngr.hpp"
|
||||
|
||||
|
||||
tdstDLLIdentity g_stTUT_Identity;
|
||||
|
||||
#define C_uiTUTPopupRun 10
|
||||
#define C_uiTUTPopupAutoRun 11
|
||||
#define C_uiTUTPopupBackGround 12
|
||||
#define C_uiTUTPopupSet 14
|
||||
#define C_uiTUTPopupRecord 15
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class TUT_Interface - Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
TUT_Interface::TUT_Interface ()
|
||||
{
|
||||
m_p_stDLLIdentity = & g_stTUT_Identity;
|
||||
|
||||
m_stBaseDLLDefinition . bCanOutputIn3DView = FALSE;
|
||||
m_stBaseDLLDefinition . bCanBeRefreshedByEngine = FALSE;
|
||||
|
||||
SetEditorInfo ("Tutorial", "Alexis Vaisse", "V 2.0.0 (not updated)", "", "");
|
||||
|
||||
m_bAutoRun = FALSE;
|
||||
m_bBackGroundActive = FALSE;
|
||||
m_csScriptFileName = "Test.tut";
|
||||
m_csScriptPathName = "x:\\Cpa\\Exe\\Main";
|
||||
m_bScriptRecursive = FALSE;
|
||||
m_bRecording = FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class TUT_Interface - fn_vConstruct
|
||||
//-----------------------------------------------------------------------------
|
||||
void TUT_Interface::fn_vConstruct (void)
|
||||
{
|
||||
fn_vSetReceivingWindowMessages (TRUE);
|
||||
m_fn_vLoadPreferences ();
|
||||
|
||||
TUT_g_oTutorialManager . m_fn_vSetBackGroundActive (m_bBackGroundActive) ;
|
||||
if (m_bAutoRun && ! m_csScriptFileName . IsEmpty() ) TUT_g_oTutorialManager . m_fn_vLaunchScript (m_csScriptFileName);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class TUT_Interface - OnQueryAction
|
||||
//-----------------------------------------------------------------------------
|
||||
long TUT_Interface::OnQueryAction (CPA_EditorBase * _pCallingEditor , WPARAM _wParam , LPARAM _lParam)
|
||||
{
|
||||
switch (_wParam)
|
||||
{
|
||||
case TUT_C_lQueryRegisterControl :
|
||||
{
|
||||
|
||||
TUT_tdstQueryWindowStructure * p_stQueryStructure = (TUT_tdstQueryWindowStructure *) _lParam;
|
||||
TUT_g_oTutorialManager . m_fn_vRegisterWnd (p_stQueryStructure -> hHandleOfControl ,
|
||||
p_stQueryStructure -> csNameOfControl ,
|
||||
(TUT_tdeWndType) p_stQueryStructure -> eTypeOfControl);
|
||||
break;
|
||||
}
|
||||
case TUT_C_lQueryUnregisterControl :
|
||||
{
|
||||
TUT_g_oTutorialManager . m_fn_bUnregisterWnd ((HWND) _lParam);
|
||||
break;
|
||||
}
|
||||
|
||||
case TUT_C_lQueryRegisterMenu :
|
||||
{
|
||||
TUT_tdstQueryMenuStructure * p_stQueryStructure = (TUT_tdstQueryMenuStructure *) _lParam;
|
||||
TUT_g_oTutorialManager . m_fn_vRegisterMenu (p_stQueryStructure -> hHandleOfWindow ,
|
||||
p_stQueryStructure -> hHandleOfMenu ,
|
||||
p_stQueryStructure -> iX ,
|
||||
p_stQueryStructure -> iY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class TUT_Interface - _OnKeyDown
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL TUT_Interface::_OnKeyDown (UINT nChar , UINT nRepCnt , UINT nFlags)
|
||||
{
|
||||
/*
|
||||
// Alt+T -> lauch the script
|
||||
if (nChar == 'T' && (nFlags & 0x2000) != 0)
|
||||
TUT_g_oTutorialManager . m_fn_vLaunchScript ("Test.tut");
|
||||
*/
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class TUT_Interface - fn_bDefineSubMenu
|
||||
// Add an entry in the editor menu
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL TUT_Interface::fn_bDefineSubMenu (EDT_SubMenu * _p_oEDTSubMenu)
|
||||
{
|
||||
if (_p_oEDTSubMenu -> GetSubMenuType () == C_SubMenuTool)
|
||||
{
|
||||
EDT_SubMenu *p_oSubMenu = _p_oEDTSubMenu -> fn_p_oGetNewSubMenu("Tutorial");
|
||||
CString csEntry = "Run File";
|
||||
|
||||
if (! m_csScriptFileName . IsEmpty()) csEntry += " : \"" + m_csScriptFileName + "\"";
|
||||
|
||||
p_oSubMenu -> AddAnEntry (this , (char*)(LPCTSTR)csEntry , C_uiTUTPopupRun , FALSE , ! TUT_g_oTutorialManager . m_fn_bIsRunning());
|
||||
p_oSubMenu -> AddASeparator ();
|
||||
p_oSubMenu -> AddAnEntry (this , "AutoRun" , C_uiTUTPopupAutoRun , m_bAutoRun);
|
||||
p_oSubMenu -> AddAnEntry (this , "Choose Main File" , C_uiTUTPopupSet);
|
||||
p_oSubMenu -> AddAnEntry (this , "Active On BackGround" , C_uiTUTPopupBackGround , m_bBackGroundActive);
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Script recording
|
||||
p_oSubMenu -> AddAnEntry (this , m_bRecording ? "Stop recording" : "Start recording" , C_uiTUTPopupRecord);
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
_p_oEDTSubMenu -> AddASubMenu (p_oSubMenu);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class TUT_Interface - _OnSubMenuCommand
|
||||
// Called when the user selects an entry in the menu
|
||||
//-----------------------------------------------------------------------------
|
||||
void TUT_Interface::_OnSubMenuCommand (EDT_SubMenu * _p_oEDTSubMenu , UINT uiMsgID)
|
||||
{
|
||||
if (_p_oEDTSubMenu -> GetSubMenuType () == C_SubMenuTool)
|
||||
{
|
||||
if (uiMsgID == C_uiTUTPopupRun)
|
||||
{
|
||||
CDialogInput *p_oDlg = new CDialogInput ("File Name" , m_csScriptPathName, m_csScriptFileName, m_bScriptRecursive);
|
||||
|
||||
if (p_oDlg && p_oDlg -> DoModal () == IDOK)
|
||||
{
|
||||
m_csScriptFileName = p_oDlg -> m_fn_csGetEditText ();
|
||||
m_csScriptPathName = p_oDlg -> m_fn_csGetPath();
|
||||
m_bScriptRecursive = p_oDlg -> m_fn_bGetRecurse();
|
||||
m_fn_vWritePreferences ();
|
||||
if (! m_csScriptFileName . IsEmpty()) TUT_g_oTutorialManager . m_fn_vLaunchScript (m_csScriptFileName);
|
||||
}
|
||||
if (p_oDlg) delete p_oDlg;
|
||||
}
|
||||
else if (uiMsgID == C_uiTUTPopupAutoRun)
|
||||
{
|
||||
m_bAutoRun = ! m_bAutoRun;
|
||||
m_fn_vWritePreferences ();
|
||||
}
|
||||
else if (uiMsgID == C_uiTUTPopupBackGround)
|
||||
{
|
||||
m_bBackGroundActive = ! m_bBackGroundActive;
|
||||
TUT_g_oTutorialManager . m_fn_vSetBackGroundActive (m_bBackGroundActive) ;
|
||||
m_fn_vWritePreferences ();
|
||||
}
|
||||
else if (uiMsgID == C_uiTUTPopupSet)
|
||||
{
|
||||
CDialogInput *p_oDlg = new CDialogInput ("File Name" , m_csScriptFileName);
|
||||
|
||||
if (p_oDlg && p_oDlg -> DoModal () == IDOK)
|
||||
{
|
||||
m_csScriptFileName = p_oDlg -> m_fn_csGetEditText ();
|
||||
m_fn_vWritePreferences ();
|
||||
}
|
||||
if (p_oDlg) delete p_oDlg;
|
||||
}
|
||||
else if (uiMsgID == C_uiTUTPopupRecord)
|
||||
{
|
||||
m_fn_vStartStopRecord ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class TUT_Interface - m_fn_vLoadPreferences
|
||||
// Load preferences from a .INI file
|
||||
//-----------------------------------------------------------------------------
|
||||
void TUT_Interface::m_fn_vLoadPreferences (void)
|
||||
{
|
||||
CString csFileName = M_GetMainApp()->m_csEditorDataPath + "Tools\\Tut\\Tut.ini";
|
||||
char *p_szFileName = (char*)(LPCSTR)csFileName;
|
||||
char szDimension[256];
|
||||
|
||||
// AutoRun Mode
|
||||
GetPrivateProfileString ("Preference" , "AutoRun" , "FALSE" , szDimension , 256 , (char*)(LPCSTR)p_szFileName);
|
||||
m_bAutoRun = !strcmpi( szDimension, "TRUE" );
|
||||
|
||||
// Main Script File
|
||||
GetPrivateProfileString ("Preference" , "Script File" , "" , szDimension , 256 , (char*)(LPCSTR)p_szFileName);
|
||||
m_csScriptFileName = szDimension;
|
||||
|
||||
// Main Path Name
|
||||
GetPrivateProfileString ("Preference" , "Path Name" , "" , szDimension , 256 , (char*)(LPCSTR)p_szFileName);
|
||||
m_csScriptPathName = szDimension;
|
||||
|
||||
// Recursive Read
|
||||
GetPrivateProfileString ("Preference" , "Recursive Read" , "FALSE" , szDimension , 256 , (char*)(LPCSTR)p_szFileName);
|
||||
m_bScriptRecursive = !strcmpi( szDimension, "TRUE" );
|
||||
|
||||
// Main BackGround Active Mode
|
||||
GetPrivateProfileString ("Preference" , "BackGround Active" , "FALSE" , szDimension , 256 , (char*)(LPCSTR)p_szFileName);
|
||||
m_bBackGroundActive = !strcmpi( szDimension, "TRUE" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class TUT_Interface - m_fn_vWritePreferences
|
||||
// Save preferences on a .INI file
|
||||
//-----------------------------------------------------------------------------
|
||||
void TUT_Interface::m_fn_vWritePreferences (void)
|
||||
{
|
||||
CString csFileName;
|
||||
|
||||
csFileName = M_GetMainApp()->m_csEditorDataPath + "Tools\\Tut\\Tut.ini";
|
||||
|
||||
char *p_szFileName = (char*)(LPCSTR)csFileName;
|
||||
|
||||
// AutoRun Mode
|
||||
WritePrivateProfileString ("Preference" , "AutoRun" , m_bAutoRun ? "TRUE" : "FALSE" , p_szFileName);
|
||||
|
||||
// Main Script File
|
||||
WritePrivateProfileString ("Preference" , "Script File" , m_csScriptFileName , p_szFileName);
|
||||
|
||||
// Main Path Name
|
||||
WritePrivateProfileString ("Preference" , "Path Name" , m_csScriptPathName , p_szFileName);
|
||||
|
||||
// Recursive Read
|
||||
WritePrivateProfileString ("Preference" , "Recursive Read" , m_bScriptRecursive ? "TRUE" : "FALSE" , p_szFileName);
|
||||
|
||||
// Main BackGround Active Mode
|
||||
WritePrivateProfileString ("Preference" , "BackGround Active" , m_bBackGroundActive ? "TRUE" : "FALSE" , p_szFileName);
|
||||
|
||||
// write on file
|
||||
WritePrivateProfileString (NULL , NULL , NULL , p_szFileName);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class TUT_Interface - m_fn_vStartStopRecord
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void TUT_Interface::m_fn_vStartStopRecord (void)
|
||||
{
|
||||
m_bRecording = !m_bRecording;
|
||||
|
||||
if (m_bRecording)
|
||||
{
|
||||
// Start recording
|
||||
TUT_g_oTutorialManager . m_fn_vStartRecord (GetDLLIdentity () -> hModule , M_GetMainApp() -> m_nThreadID);
|
||||
}
|
||||
else
|
||||
{
|
||||
CFileDialog oDlg (FALSE, "*.tut" , NULL , OFN_EXPLORER | OFN_HIDEREADONLY | OFN_NOREADONLYRETURN | OFN_OVERWRITEPROMPT | OFN_SHOWHELP , NULL , NULL );
|
||||
|
||||
if (oDlg . DoModal() == IDOK)
|
||||
{
|
||||
// stop and save recording
|
||||
TUT_g_oTutorialManager . m_fn_vStopRecord (GetDLLIdentity () -> hModule , M_GetMainApp() -> m_nThreadID , oDlg . GetPathName ());
|
||||
}
|
||||
else
|
||||
{
|
||||
// stop and not save recording
|
||||
TUT_g_oTutorialManager . m_fn_vStopRecord (GetDLLIdentity () -> hModule , M_GetMainApp() -> m_nThreadID , NULL);
|
||||
}
|
||||
}
|
||||
}
|
314
Rayman_X/cpa/tempgrp/Tut/Src/dlginput.cpp
Normal file
314
Rayman_X/cpa/tempgrp/Tut/Src/dlginput.cpp
Normal file
@@ -0,0 +1,314 @@
|
||||
// dlginput.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include <direct.h>
|
||||
#include <shlobj.h>
|
||||
#include "ACP_Base.h"
|
||||
#include "ITF.h"
|
||||
|
||||
#include "dlginput.hpp"
|
||||
|
||||
#include "TUT.h"
|
||||
#include "..\Main\Inc\_EditID.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDialogInput dialog
|
||||
#define M_DeleteOnEnd( string, charact )\
|
||||
{\
|
||||
if( string . GetLength() )\
|
||||
{\
|
||||
string . MakeReverse();\
|
||||
while( string[0] == charact ) string = string . Mid( 1 );\
|
||||
string . MakeReverse();\
|
||||
}\
|
||||
}
|
||||
|
||||
CDialogInput::CDialogInput(const CString _csStaticText, const CString _csPathText /*=""*/,
|
||||
const CString _csFileText /*=""*/, BOOL _bRecursive /*=FALSE*/, CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CDialogInput::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CDialogInput)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_csStaticText = _csStaticText;
|
||||
m_csPathText = _csPathText;
|
||||
m_csFileText = _csFileText;
|
||||
m_bRecursive = _bRecursive;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CDialogInput::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CDialogInput)
|
||||
// NOTE: the ClassWizard will add DDX and DDV calls here
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDialogInput, CDialog)
|
||||
//{{AFX_MSG_MAP(CDialogInput)
|
||||
ON_WM_DRAWITEM()
|
||||
ON_WM_DESTROY()
|
||||
ON_WM_CANCELMODE()
|
||||
ON_BN_CLICKED(IDC_BUTTON_READ, OnBtRead)
|
||||
ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnBtBrowse)
|
||||
ON_LBN_SELCHANGE(IDC_LIST_FILE, OnSelChange)
|
||||
ON_LBN_DBLCLK(IDC_LIST_FILE, OnDoubleClick)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDialogInput message handlers
|
||||
|
||||
void CDialogInput::OnOK()
|
||||
{
|
||||
// TODO: Add extra validation here
|
||||
GetDlgItem( IDC_EDIT_TEXT ) -> GetWindowText( m_csEditText );
|
||||
if( m_csEditText . GetLength() )
|
||||
{
|
||||
GetDlgItem( IDC_EDIT_PATH ) -> GetWindowText( m_csPathText );
|
||||
m_bRecursive = ((CButton*) GetDlgItem( IDC_CHECK_RECURSIVE )) -> GetCheck();
|
||||
CDialog::OnOK();
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CDialogInput::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
GetDlgItem( IDC_EDIT_TEXT ) -> SetWindowText( m_csFileText );
|
||||
GetDlgItem( IDC_EDIT_PATH ) -> SetWindowText( m_csPathText );
|
||||
GetDlgItem( IDC_STATIC_TEXT ) -> SetWindowText( m_csStaticText );
|
||||
((CButton*) GetDlgItem( IDC_CHECK_RECURSIVE )) -> SetCheck( m_bRecursive );
|
||||
GetDlgItem( IDC_EDIT_TEXT ) -> SetFocus();
|
||||
if( m_csPathText . GetLength() )
|
||||
m_fn_vFillList();
|
||||
//
|
||||
TUT_M_vGetTutDll();
|
||||
TUT_M_vRegisterControlID( IDC_EDIT_TEXT, "TUT_INPUT_TEXT", TUT_e_TextEdit );
|
||||
TUT_M_vRegisterControlID( IDOK, "TUT_INPUT_OK", TUT_e_Button );
|
||||
TUT_M_vRegisterControlID( IDCANCEL, "TUT_INPUT_CANCEL", TUT_e_Button );
|
||||
TUT_M_vRegisterControlID( IDC_BUTTON_READ, "TUT_INPUT_READ", TUT_e_Button );
|
||||
TUT_M_vRegisterControlID( IDC_BUTTON_BROWSE,"TUT_INPUT_BROWSE", TUT_e_Button );
|
||||
TUT_M_vRegisterControlID( IDC_LIST_FILE, "TUT_INPUT_LIST", TUT_e_ListBox );
|
||||
TUT_M_vRegisterControlID( IDC_EDIT_PATH, "TUT_INPUT_PATH", TUT_e_TextEdit );
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CDialogInput::OnDestroy()
|
||||
{
|
||||
TUT_M_vGetTutDll();
|
||||
TUT_M_vUnregisterControlID( IDC_EDIT_TEXT );
|
||||
TUT_M_vUnregisterControlID( IDOK );
|
||||
TUT_M_vUnregisterControlID( IDCANCEL );
|
||||
TUT_M_vUnregisterControlID( IDC_BUTTON_READ );
|
||||
TUT_M_vUnregisterControlID( IDC_BUTTON_BROWSE );
|
||||
TUT_M_vUnregisterControlID( IDC_LIST_FILE );
|
||||
TUT_M_vUnregisterControlID( IDC_EDIT_PATH );
|
||||
|
||||
CDialog::OnDestroy();
|
||||
}
|
||||
|
||||
void CDialogInput::OnBtBrowse()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
BROWSEINFO bi;
|
||||
LPSTR lpBuffer = (LPSTR)malloc(_MAX_PATH);
|
||||
LPITEMIDLIST pidlBrowse; // PIDL selected by user
|
||||
|
||||
|
||||
// Fill in the BROWSEINFO structure.
|
||||
bi.hwndOwner = m_hWnd;
|
||||
bi.pidlRoot = NULL;
|
||||
bi.pszDisplayName = lpBuffer;
|
||||
bi.lpszTitle = "Choose a Path";
|
||||
bi.ulFlags = 0;
|
||||
bi.lpfn = NULL;
|
||||
bi.lParam = 0;
|
||||
|
||||
// Browse for a folder and return its PIDL.
|
||||
pidlBrowse = SHBrowseForFolder(&bi);
|
||||
if (pidlBrowse != NULL)
|
||||
{
|
||||
if (SHGetPathFromIDList(pidlBrowse, lpBuffer))
|
||||
{
|
||||
GetDlgItem( IDC_EDIT_PATH ) -> SetWindowText( lpBuffer );
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up.
|
||||
free(lpBuffer);
|
||||
|
||||
}
|
||||
|
||||
void CDialogInput::OnBtRead()
|
||||
{
|
||||
m_fn_vFillList();
|
||||
}
|
||||
|
||||
void CDialogInput::OnSelChange()
|
||||
{
|
||||
CListBox *pLB = (CListBox*) GetDlgItem( IDC_LIST_FILE );
|
||||
int iIndex = pLB -> GetCurSel();
|
||||
|
||||
if( iIndex != LB_ERR )
|
||||
{
|
||||
CString csText;
|
||||
CString csPath;
|
||||
|
||||
GetDlgItem( IDC_EDIT_PATH ) -> GetWindowText( csPath );
|
||||
|
||||
M_DeleteOnEnd( csPath, '\\' )
|
||||
|
||||
pLB -> GetText( iIndex, csText );
|
||||
if( csText [0] == '\\' )
|
||||
{
|
||||
GetDlgItem( IDC_EDIT_TEXT ) -> SetWindowText( csPath + csText + ".tut" );
|
||||
}
|
||||
else
|
||||
{
|
||||
GetDlgItem( IDC_EDIT_TEXT ) -> SetWindowText( csPath + "\\" + csText + ".tut" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CDialogInput::OnDoubleClick()
|
||||
{
|
||||
CListBox *pLB = (CListBox*) GetDlgItem( IDC_LIST_FILE );
|
||||
int iIndex = pLB -> GetCurSel();
|
||||
|
||||
if( iIndex != LB_ERR )
|
||||
OnOK();
|
||||
}
|
||||
|
||||
void CDialogInput::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDIS)
|
||||
{
|
||||
if ( (nIDCtl == IDC_LIST_FILE) &&
|
||||
(GetDlgItem( IDC_LIST_FILE )->IsWindowEnabled() ) &&
|
||||
(lpDIS->itemID != LB_ERR) )
|
||||
{
|
||||
CDC *pDC = CDC::FromHandle( lpDIS->hDC );
|
||||
CString csText , csPath;
|
||||
CListBox *pLB = (CListBox*) GetDlgItem( IDC_LIST_FILE );
|
||||
BOOL bSelected = (lpDIS->itemState & ODS_SELECTED );
|
||||
int iPos;
|
||||
CSize oSize;
|
||||
|
||||
pLB -> GetText(lpDIS->itemID, csText ) ;
|
||||
iPos = csText . ReverseFind( '\\' );
|
||||
if( iPos != -1 )
|
||||
{
|
||||
iPos++;
|
||||
csPath = csText . Left( iPos );
|
||||
oSize = pDC -> GetTextExtent( csPath );
|
||||
|
||||
pDC->FillSolidRect( &lpDIS->rcItem, GetSysColor( COLOR_WINDOW ));
|
||||
pDC->SetBkMode( TRANSPARENT);
|
||||
|
||||
pDC->SetTextColor( RGB(0, 0, 255) );
|
||||
lpDIS->rcItem.left += 1;
|
||||
pDC->DrawText( csPath , &lpDIS->rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER );
|
||||
|
||||
lpDIS->rcItem.left += oSize . cx;
|
||||
pDC->SetTextColor( RGB(255, 0, 0) );
|
||||
pDC->DrawText( csText . Mid( iPos ) , &lpDIS->rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER );
|
||||
|
||||
lpDIS->rcItem.left -= oSize . cx;
|
||||
lpDIS->rcItem.left -= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
lpDIS->rcItem.left += 1;
|
||||
|
||||
pDC->SetTextColor( RGB(255, 0, 0) );
|
||||
pDC->DrawText( csText , &lpDIS->rcItem, DT_SINGLELINE | DT_LEFT | DT_VCENTER );
|
||||
|
||||
lpDIS->rcItem.left -= 1;
|
||||
}
|
||||
if (bSelected)
|
||||
pDC->InvertRect( &lpDIS->rcItem );
|
||||
}
|
||||
else
|
||||
CDialog::OnDrawItem(nIDCtl, lpDIS);
|
||||
}
|
||||
|
||||
void CDialogInput::m_fn_vFillList()
|
||||
{
|
||||
CListBox *pLB = (CListBox*) GetDlgItem( IDC_LIST_FILE );
|
||||
|
||||
pLB -> ResetContent();
|
||||
|
||||
// get path
|
||||
CString csPath;
|
||||
BOOL bRecursive;
|
||||
|
||||
GetDlgItem( IDC_EDIT_PATH ) -> GetWindowText( csPath );
|
||||
bRecursive = ((CButton*) GetDlgItem( IDC_CHECK_RECURSIVE )) -> GetCheck();
|
||||
|
||||
M_DeleteOnEnd( csPath, '\\' )
|
||||
|
||||
if( ! csPath . IsEmpty() )
|
||||
m_fn_vRecurFillList( csPath , "" , bRecursive );
|
||||
else
|
||||
MessageBox( "The Path is empty" , "Error" , MB_OK + MB_ICONERROR );
|
||||
}
|
||||
|
||||
void CDialogInput::m_fn_vRecurFillList( const CString _csBeginPathName , const CString _csCurrentPathName, BOOL _bRecursive )
|
||||
{
|
||||
WIN32_FIND_DATA stWFD; // structure for searching file
|
||||
HANDLE hFD;
|
||||
BOOL bContinue; // handle for searching file
|
||||
CListBox *pLB = (CListBox*) GetDlgItem( IDC_LIST_FILE );
|
||||
|
||||
// search for files
|
||||
hFD = FindFirstFile( _csBeginPathName + _csCurrentPathName + "\\*.tut", &stWFD );
|
||||
bContinue = ( hFD != INVALID_HANDLE_VALUE );
|
||||
while( bContinue )
|
||||
{
|
||||
if ( !(stWFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
|
||||
{
|
||||
CString csFileName;
|
||||
|
||||
if( _csCurrentPathName . GetLength() )
|
||||
csFileName = _csCurrentPathName + "\\" + stWFD.cFileName;
|
||||
else
|
||||
csFileName = stWFD.cFileName;
|
||||
|
||||
pLB -> AddString( csFileName . Left( csFileName . GetLength() - 4 ) );
|
||||
}
|
||||
bContinue = FindNextFile( hFD, &stWFD);
|
||||
}
|
||||
|
||||
// close FindData handle
|
||||
FindClose(hFD);
|
||||
|
||||
// search for directory
|
||||
if( _bRecursive )
|
||||
{
|
||||
hFD = FindFirstFile( _csBeginPathName + _csCurrentPathName + "\\*", &stWFD );
|
||||
bContinue = ( hFD != INVALID_HANDLE_VALUE );
|
||||
while( bContinue )
|
||||
{
|
||||
if ((stWFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (stWFD.cFileName[0] != '.') )
|
||||
{
|
||||
// appel recursif
|
||||
m_fn_vRecurFillList( _csBeginPathName , _csCurrentPathName + "\\" + stWFD.cFileName, TRUE );
|
||||
}
|
||||
bContinue = FindNextFile( hFD, &stWFD);
|
||||
}
|
||||
|
||||
// close FindData handle
|
||||
FindClose(hFD);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user