Пример #1
0
STDMETHODIMP CBaseLib::Init(int nhWnd)
{
    InitLog();

    // TODO: Add your implementation code here
    typedef HRESULT (*fnGet3DEngineInterface)(void**);

    HRESULT hResult = E_FAIL;
    HRESULT hRetCode = E_FAIL;
    fnGet3DEngineInterface pfnGet3DEngineInterface; 

    g_SetRootPath(NULL);
    g_SetFindFileMode(TRUE);
    g_SetFilePath("");

    KGLOG_PROCESS_ERROR(nhWnd);
    m_hWnd = (HWND)nhWnd;

    // TODO: Add your implementation code here
    #ifdef _DEBUG   
        g_hModule = ::LoadLibraryA("KG3DEngineD.dll");
    #else
    g_hModule = ::LoadLibraryA("KG3DEngine.dll");
    #endif
    KGLOG_PROCESS_ERROR(g_hModule);

    pfnGet3DEngineInterface = (fnGet3DEngineInterface)GetProcAddress(g_hModule, "Get3DEngineInterface");
    KGLOG_PROCESS_ERROR(pfnGet3DEngineInterface);

    hRetCode = pfnGet3DEngineInterface((void**)&g_p3DEngine);
    KGLOG_PROCESS_ERROR(SUCCEEDED(hRetCode));
    KGLOG_PROCESS_ERROR(g_p3DEngine);

    IEKG3DEngineManager* pEngine = static_cast<IEKG3DEngineManager*>(g_p3DEngine);
    KGLOG_PROCESS_ERROR(pEngine);

    pEngine->GetGraphicsTool(&g_p3DTools);
    KGLOG_PROCESS_ERROR(g_p3DTools);

    hRetCode = g_p3DEngine->Init(0, KG3DENG_CLIENT | KG3DENG_RECORD, m_hWnd, m_hWnd);
    KGLOG_PROCESS_ERROR(SUCCEEDED(hRetCode));

    hResult = S_OK;
Exit0:
    return S_OK;
}
Пример #2
0
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	typedef HRESULT (*fnGet3DEngineInterface)(void**);
	fnGet3DEngineInterface pfnGet3DEngineInterface = NULL;
	g_hMod = NULL;
	HRESULT hr = E_FAIL;
	if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		//TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		//TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

	if(!m_wndProgressDialogBar.Create(this,IDD_PROGRESS_DIALOGBAR,
		CBRS_ALIGN_BOTTOM | CBRS_BOTTOM | CBRS_TOOLTIPS | CBRS_FLYBY,IDD_PROGRESS_DIALOGBAR))
	{
		//TRACE0("Failed to create toolbar\n");
		return -1;
	}
	
	if(!m_wndMasterlistDialogBar.Create(this,IDD_MASTERLIST_DIALOGBAR,
		CBRS_ALIGN_RIGHT | CBRS_RIGHT | CBRS_TOOLTIPS | CBRS_FLYBY,IDD_MASTERLIST_DIALOGBAR))
	{
		//TRACE0("Failed to create toolbar\n");
		return -1;
	}


	// TODO: Delete these three lines if you don't want the toolbar to be dockable
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);

	m_wndMasterlistDialogBar.EnableDocking(CBRS_ALIGN_RIGHT);
	DockControlBar(&m_wndMasterlistDialogBar); 

	m_wndProgressDialogBar.EnableDocking(CBRS_ALIGN_BOTTOM);
	DockControlBar(&m_wndProgressDialogBar); 
	

	g_bSlider = TRUE;
	KGLOG_PARAM LogParam = {"logs", "Record", KGLOG_OPTION_FILE, 65536};
	int nRetCode = KGLogInit(LogParam, NULL);

	g_SetRootPath();
	g_SetFilePath("");
	g_GetRootPath(g_szDefWorkDirectory);

	

	//SetCurrentDirectory();

#ifdef _DEBUG
	g_hMod = ::LoadLibraryA("KG3DEngineD.dll");
#else
	g_hMod = ::LoadLibraryA("KG3DEngine.dll");
#endif

    if (g_hMod == NULL)
		return -1;
	pfnGet3DEngineInterface = (fnGet3DEngineInterface)GetProcAddress(g_hMod, "Get3DEngineInterface");
	if (pfnGet3DEngineInterface == NULL)
		return -1;

	hr = pfnGet3DEngineInterface((void**)&g_p3DEngine);
	if (hr == E_FAIL)
		return -1;
	ASSERT(g_p3DEngine);
	IEKG3DEngineManager* pEngine = static_cast<IEKG3DEngineManager*>(g_p3DEngine);
	ASSERT(pEngine);
	pEngine->GetGraphicsTool(&g_p3DTools);
	ASSERT(g_p3DTools);
	hr = g_p3DEngine->Init(0,KG3DENG_CLIENT | KG3DENG_RECORD, m_hWnd, m_hWnd);
	if (hr == E_FAIL)
		return -1;
	//pEngine->SetAutoReloadTexture(TRUE);

	RecordOption recordOption;

	recordOption.Size.cx = 1024;
	recordOption.Size.cy = 768;
	recordOption.nAutoScale = FALSE;
	recordOption.FiterType = D3DTEXF_LINEAR;
	recordOption.fInterval = 41;
	recordOption.ImageType = D3DXIFF_JPG;
	recordOption.bKeep = FALSE;

	g_p3DEngine->SetRecordOption(&recordOption);
	return 0;
}
Пример #3
0
BOOL KSceneEditorApp::InitInstance()
{
    BOOL                        bResult             = false;
	BOOL                        bRetCode            = false;
	HRESULT                     hr                  = E_FAIL;
    char*                       pszRetCWD           = NULL;
    IRecorderFactory*           piRecorderFactory   = NULL;
    CMultiDocTemplate*          pDocTemplate        = NULL;
    MFCFramework::CMainFrame*   pMainFrame    = NULL;
    KGLOG_PARAM                 LogParam;
    char                        szCWD[MAX_PATH];
    CCommandLineInfo            cmdInfo;

    //使用Dummper
    m_hDummperModule = LoadLibrary(_T("dumper.dll"));

    pszRetCWD = getcwd(szCWD, sizeof(szCWD));
    KGLOG_PROCESS_ERROR(pszRetCWD);

	g_SetRootPath();

    g_SetFindFileMode(TRUE);
    g_SetFilePath("");
    g_LoadPackageFiles("config.ini", "PackFile");

	memset(&LogParam, 0, sizeof(LogParam));
	snprintf(LogParam.szPath,sizeof(LogParam.szPath),"%s\\logs",szCWD);
	LogParam.szPath[sizeof(LogParam.szPath) - 1] = '\0';

	strcpy(LogParam.szIdent, "SceneEditor");
	LogParam.nMaxLineEachFile = 65536;
	LogParam.Options = (KGLOG_OPTIONS)KGLOG_OPTION_FILE;

	bRetCode = KGLogInit(LogParam, NULL);
    KGLOG_PROCESS_ERROR(bRetCode);
    m_bLogInitFlag = true;

    bRetCode = KMemory::Initialize("SceneEditor.memory");
    KGLOG_PROCESS_ERROR(bRetCode);
    m_bMemoryInitFlag = true;

	g_cEditorDirectory.Load();

	{
		TCHAR AppDir[256] = {0};
		GetCurrentDirectory(256, AppDir);
		wsprintf(g_szDefWorkDirectory,"%s\\",AppDir);
		wsprintf(g_szDefExeDirectory,"%s\\",AppDir);
	}

	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

	// Change the registry key under which our settings are stored.
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	LoadStdProfileSettings(10);  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	
	pDocTemplate = new CMultiDocTemplate(
		IDR_SCENEETYPE,
		RUNTIME_CLASS(KSceneEditorDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(KSceneEditorView));
	pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP);
	AddDocTemplate(pDocTemplate);

	pDocTemplate = new CMultiDocTemplate(
		IDR_MESHETYPE,
		RUNTIME_CLASS(KSceneModelEditorDoc),
		RUNTIME_CLASS(KSceneModelEditorFrameWnd), // custom MDI child frame
		RUNTIME_CLASS(KSceneModelEditorView));
	pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP);
	AddDocTemplate(pDocTemplate);

	pDocTemplate = new CMultiDocTemplate(
		IDS_OBJECTTYPE,
		RUNTIME_CLASS(KSceneObjectEditorDoc),
		RUNTIME_CLASS(KSceneObjectEditorFrameWnd), // custom MDI child frame
		RUNTIME_CLASS(KSceneObjectEditorView));
	pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP);
	AddDocTemplate(pDocTemplate);

	pDocTemplate = new CMultiDocTemplate(
		IDR_SFXEDITOR,
		RUNTIME_CLASS(KSceneSFXEditorDoc),
		RUNTIME_CLASS(KSceneSFXEditorFrame), // custom MDI child frame
		RUNTIME_CLASS(KSceneSFXEditorView));
	pDocTemplate->SetContainerInfo(IDR_SFXEDITOR);
	AddDocTemplate(pDocTemplate);

	pDocTemplate = new CMultiDocTemplate(
		IDR_MODELTYPE,
		RUNTIME_CLASS(KSceneModelEditorDoc),
		RUNTIME_CLASS(KSceneModelEditorFrameWnd), // custom MDI child frame
		RUNTIME_CLASS(KSceneModelEditorView));
	pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP);
	AddDocTemplate(pDocTemplate);

	pDocTemplate = new CMultiDocTemplate(
		IDS_DATAFLOWFILE,
		RUNTIME_CLASS(KSceneDataFlowEditorDoc),
		RUNTIME_CLASS(KScneDataFlowEditorFrameWnd), // custom MDI child frame
		RUNTIME_CLASS(KSceneDataFlowEditorView));
	pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP);
	AddDocTemplate(pDocTemplate);

    pDocTemplate = new CMultiDocTemplate(
        IDR_PVSTYPE,
        RUNTIME_CLASS(KPvsEditorDoc),
        RUNTIME_CLASS(KPvsEditorFrame), // custom MDI child frame
        RUNTIME_CLASS(KPvsEditorView));
    pDocTemplate->SetContainerInfo(IDR_PVSTYPE);
    AddDocTemplate(pDocTemplate);

	pDocTemplate = new CMultiDocTemplate(
		IDR_MODELTYPE2,
		RUNTIME_CLASS(KSceneModelEditorDoc),
		RUNTIME_CLASS(KSceneModelEditorFrameWnd), // custom MDI child frame
		RUNTIME_CLASS(KSceneModelEditorView));
	pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP);
	AddDocTemplate(pDocTemplate);
	pDocTemplate = new CMultiDocTemplate(
		IDR_SPEEDTREETYPE,
		RUNTIME_CLASS(KSceneModelEditorDoc),
		RUNTIME_CLASS(KSceneModelEditorFrameWnd), // custom MDI child frame
		RUNTIME_CLASS(KSceneModelEditorView));
	pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP);
	AddDocTemplate(pDocTemplate);

	pDocTemplate = new CMultiDocTemplate(
		IDR_MODELTYPE3,
		RUNTIME_CLASS(KSceneModelEditorDoc),
		RUNTIME_CLASS(KSceneModelEditorFrameWnd), // custom MDI child frame
		RUNTIME_CLASS(KSceneModelEditorView));
	pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP);
	AddDocTemplate(pDocTemplate);

	// create main MDI Frame window
	pMainFrame = new MFCFramework::CMainFrame;
    bRetCode = pMainFrame->LoadFrame(IDR_SCENEETYPE);
    KGLOG_PROCESS_ERROR(bRetCode);

    m_pMainWnd = pMainFrame;


	//(by dengzhihui 2006年12月7日 15:48:16
	extern BYTE* g_SceneEditorKeyState;//键盘状态 
	ZeroMemory(g_SceneEditorKeyState,sizeof(BYTE)*256);
	//)

	// Parse command line for standard shell commands, DDE, file open
	
	ParseCommandLine(cmdInfo);

	// Dispatch commands specified on the command line
	//if (!ProcessShellCommand(cmdInfo))
	//	return FALSE;

	// The main window has been initialized, so show and update it.
	pMainFrame->ShowWindow(SW_MAXIMIZE); 
	pMainFrame->UpdateWindow();
    
    g_pEngineManager->GetUseSO3Logical(&g_bUseSO3Logical);
	if (g_bUseSO3Logical)
	{
        piRecorderFactory = CreateRecorderFactoryInterface(ermNormal);
        KGLOG_PROCESS_ERROR(piRecorderFactory);

        g_pSO3World = new KSO3World;
        KGLOG_PROCESS_ERROR(g_pSO3World);
        
        bRetCode = g_pSO3World->Init(piRecorderFactory);
        KGLOG_PROCESS_ERROR(bRetCode);
        m_bGameWorldOpenFlag = true;

        if (InitRepresent() && InitUI())
        {
            HWND hWnd = NULL;

            g_SetGameWorldUIHandler(&g_pUI->GetGameWorldUIHandler());
            g_SetGameWorldRepresentHandler(g_pRepresent->GetGameWorldRepresentHandler());
            g_pRepresentHandler = g_pRepresent->GetRepresentHandelr();

            g_pRepresent->GetRepresentHandelr()->AttachGameWorld(g_pSO3World, QuerySO3WorldClientInterface());
            g_pRepresent->GetRepresentHandelr()->Attach3DEngine(g_GetEngineIEInterface(), g_pEngineManager->Get3DModelTable(), g_pEngineManager->Get3DUI());
            g_pRepresent->GetRepresentHandelr()->AttachUI(g_pUI, &g_pUI->GetGameWorldUIHandler());

            g_pEngineManager->GetBaseWnd(&hWnd);
            g_pRepresent->GetRepresentHandelr()->InitHWND(hWnd);
            if (!g_pRepresent->Init())
            {
                ::MessageBox(NULL, "表现逻辑初始化失败!", NULL, 0);
            }
        }
	}

	//创建声音
	g_pSoundShell = Create3DSoundShell();
	if (!g_pSoundShell)
	{
		KGLogPrintf(KGLOG_WARNING, "声音创建失败.");
	}
	else
	{
		g_pSoundShell->Init(m_pMainWnd->GetSafeHwnd());
	}

	//在这里把需要使用sound的地方都统一设置上soundshell
	g_pEngineManager->SetSoundShell(g_pSoundShell);
	if (g_pRepresent)
	{
		g_pRepresent->SetSoundShell(g_pSoundShell);
	}

    bResult = true;
Exit0:
    if (!bResult)
    {
        if (m_bGameWorldOpenFlag)
        {
            g_pSO3World->UnInit();
            m_bGameWorldOpenFlag = false;
        }

        KG_DELETE(g_pSO3World);

        if (m_bMemoryInitFlag)
        {
            KMemory::Finalize();
            m_bMemoryInitFlag = false;
        }

        if (m_bLogInitFlag)
        {
            KGLogUnInit(NULL);
            m_bLogInitFlag = false;
        }
    }
    KG_COM_RELEASE(piRecorderFactory);
	return bResult;
}
Пример #4
0
int main(int argc, char *argv[])
{
	INT	nRet	= 0;
	INT	nLogInitFlag = FALSE;
	{
		QLOG_PARAM sLogParam;
		LPSTR       pszRetCWD    = NULL;
		CHAR        szCWD[MAX_PATH];

		pszRetCWD = getcwd(szCWD, sizeof(szCWD));

		memset(&sLogParam, 0, sizeof(sLogParam));
		snprintf(sLogParam.szPath, sizeof(sLogParam.szPath), "%s/log", szCWD);
		QStrCpyLen(sLogParam.szIdent, "roleserver", sizeof(sLogParam.szIdent));
		sLogParam.nMaxLineEachFile	= USHRT_MAX;
		sLogParam.Options = (QLOG_OPTIONS)(LOG_OPTION_FILE | LOG_OPTION_CONSOLE);

		QLogInit(sLogParam, NULL);

#ifndef _DEBUG
		//LogSetPriorityMask(KGLOG_UPTO(LOG_INFO));
#endif // _DEBUG

		nLogInitFlag = TRUE;
	}

#ifdef __unix
	// 允许产生coredump文件
	rlimit sLimit;
	sLimit.rlim_cur = -1;
	sLimit.rlim_max = -1;
	::setrlimit(RLIMIT_CORE, &sLimit);

	// 设置创建的新文件权限为(rw.r.r)
	umask(022);
#endif
	QLogPrintf(LOG_DEBUG, "%s", "9SKy Role Server");
	QLogPrintf(LOG_DEBUG, "%s", "BUILD " __TIME__ " " __DATE__);

	g_SetRootPath(NULL);
	g_SetFilePath("\\");

	nRet = g_cRoleSvc.Init();

#ifdef WIN32
	_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
	_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
	_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
	_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT);
	//_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
	//_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT);
	_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
	SetConsoleCtrlHandler(ConsoleHandlerRoutine, TRUE);
#endif // WIN32
	// the signal only has effect on Linux, windows just define it, do noting
	signal(SIGTERM, _SignalHandler);  // when terminal by kill, call OnQuitSignal
	signal(SIGINT,  _SignalHandler);  // when Ctrl+C, call OnQuitSignal

	if (nRet)
	{
		nRet = g_cRoleSvc.Start();
		//g_cRoleSvc.TestCase_Functionality();
	}
	g_cRoleSvc.Uninit();

	QLogPrintf(LOG_INFO, "RoleServer Closed.");

	if (nLogInitFlag)
		QLogUnInit(NULL);

	return nRet ? 0 : 1;
}