int KUiWndCheckBoxCommon::SelAnimate(int *pnSelResult) { int nResult = false; int nRetCode = false; char szUiTexFileName[MAX_PATH]; char szRoot[MAX_PATH]; int nSelAinmate = 0; IIniFile *pIni = NULL; pIni = g_Ui.GetIni(); KG_PROCESS_ERROR(pIni); g_GetRootPath(szRoot); KG_PROCESS_ERROR(szRoot[0] != '\0'); szUiTexFileName[0] = '\0'; pIni->GetString(m_szName, "Image", "", szUiTexFileName, sizeof(szUiTexFileName)); KG_PROCESS_ERROR(szUiTexFileName[0] != '\0'); strcat(szRoot, "\\"); strcat(szRoot, szUiTexFileName); strcpy(szUiTexFileName, szRoot); nSelAinmate = SELANIMATE::OnSelAnimate(szUiTexFileName, m_hWnd); KG_PROCESS_ERROR(nSelAinmate != -1); *pnSelResult = nSelAinmate; nResult = true; Exit0: return nResult; }
//--------------------------------------------------------------------------- // 函数: Open // 功能: 打开一个文件,准备读取 // 参数: FileName 文件名 // 返回: 成功返回TRUE,失败返回FALSE。 //--------------------------------------------------------------------------- BOOL KFile::Open(LPSTR FileName) { char PathName[MAXPATH]; // close prior file handle //if (m_hFile != INVALID_HANDLE_VALUE) // Close(); if (m_hFile != NULL) Close(); // get full path name g_GetFullPath(PathName, FileName); /*#ifndef WIN32 char *name_ptr = PathName; while(*name_ptr) { if(*name_ptr == '\\') *name_ptr = '/'; name_ptr++; } #endif // Open the file for read m_hFile = CreateFile( PathName, // pointer to name of the file with path GENERIC_READ, // access (read-write) mode FILE_SHARE_READ,// share mode NULL, // pointer to security attributes OPEN_EXISTING, // how to create FILE_ATTRIBUTE_NORMAL,// file attributes NULL); // template file*/ #ifndef WIN32 char *ptr = PathName; while(*ptr) { if(*ptr == '\\') *ptr = '/'; ptr++; } //open lower case file for linux char lcasePathName[MAXPATH]; char szRootPath[MAXPATH]; g_GetRootPath(szRootPath); strcpy(lcasePathName, PathName); if (memcmp(lcasePathName, szRootPath, strlen(szRootPath)) == 0) strlwr(lcasePathName + strlen(szRootPath)); else strlwr(lcasePathName); if (NULL == (m_hFile = fopen(lcasePathName, "rb"))) #endif m_hFile = fopen(PathName, "rb"); // check file handle //if (m_hFile == INVALID_HANDLE_VALUE) // return FALSE; if (m_hFile == NULL) { return FALSE; } return TRUE; }
int KUiFontManage::ReInitIni() { if (m_pFontIni) return true; char szPath[MAX_PATH] = ""; g_GetRootPath(szPath); strcat(szPath, "\\UI\\Scheme\\Elem\\Font.ini"); strcpy(m_szFontFileName, szPath); m_pFontIni = g_OpenIniFile(m_szFontFileName); return true; }
bool KLuaWrap::Init(std::string *pReserveGVar, size_t GVarCount, const char *PackagePath /*= NULL*/) { char path[MAX_PATH]; g_GetRootPath(path); if (PackagePath) { #ifdef WIN32 strcat(path, "\\"); #else strcat(path, "/"); #endif strcat(path, PackagePath); } else { #ifdef WIN32 strcat(path, "\\script\\"); #else strcat(path, "/script/"); #endif } strncpy(m_ScriptPackagePath, path, sizeof(m_ScriptPackagePath)); m_ScriptPackagePath[sizeof(m_ScriptPackagePath) - 1] = 0; _Exit(); m_L = lua_newstate(_Alloc_Fun, this); KS_CHECK_BOOL(m_L); KS_CHECK_BOOL(lua_checkstack(m_L, KD_N_BASE_CALL_STACK)); luaL_openlibs(m_L); if (pReserveGVar) { lua_tinker::table tReserveGVar(m_L); for (size_t c = 0; c < GVarCount; ++c) { tReserveGVar.set(c + 1, pReserveGVar[c].c_str()); } lua_tinker::set(m_L, "_RESERVE_G_VAR_", tReserveGVar); } else { lua_tinker::table tReserveGVar(m_L); lua_tinker::set(m_L, "_RESERVE_G_VAR_", tReserveGVar); } return true; KS_EXIT: return false; }
BOOL GetFilePathFromFullPath( LPTSTR pBuffer, size_t uSize, LPCTSTR pFullPath ) { _ASSERTE(NULL != pBuffer && NULL != pFullPath); KG_PROCESS_ERROR(NULL != pBuffer && NULL != pFullPath); { TCHAR rootPath[MAX_PATH] = _T(""); g_GetRootPath(rootPath);//里面没有检查Buffer长度的,直接用strcpy。 _ASSERTE(0 != _tcscmp(rootPath, _T(""))); return GetFilePathFromFullPathPrivate(pBuffer, uSize, pFullPath, rootPath); } Exit0: return FALSE; }
void KUiFontManage::OnFontManage(HWND hParent, BOOL bManage) { m_nCurrentItemNum = 0; m_hWnd = NULL; m_hListWnd = NULL; m_szFont[0] = 0; m_pFontIni = NULL; m_bSel = FALSE; m_bManage = bManage; char szPath[MAX_PATH] = ""; g_GetRootPath(szPath); strcat(szPath, "\\UI\\Scheme\\Elem\\Font.ini"); strcpy(m_szFontFileName, szPath); m_pFontIni = g_OpenIniFile(m_szFontFileName); KG_PROCESS_ERROR(hParent); ::DialogBox((HINSTANCE)g_hPluginInstance, MAKEINTRESOURCE(IDD_WndFontManage), hParent, (DLGPROC)DlgProc); Exit0: return; }
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; }