void CResourceCompilerHelper::GetEditorExecutable(SettingsManagerHelpers::CWCharBuffer wbuffer) { if (wbuffer.getSizeInElements() <= 0) { return; } g_pSettingsManager->GetRootPathUtf16(wbuffer); SettingsManagerHelpers::CFixedString<wchar_t, 1024> editorExe; editorExe = wbuffer.getPtr(); if (editorExe.length() <= 0) { MessageBoxA(NULL, "Can't Find the Editor.\nPlease, setup correct CryENGINE root path in the engine settings dialog", "Error", MB_ICONERROR | MB_OK); ResourceCompilerUI(0); g_pSettingsManager->GetRootPathUtf16(wbuffer); editorExe = wbuffer.getPtr(); if (editorExe.length() <= 0) { wbuffer[0] = 0; return; } } g_pSettingsManager->GetValueByRef("EDT_Prefer32Bit", wbuffer); if (wcscmp(wbuffer.getPtr(), L"true") == 0) { editorExe.appendAscii("/Bin32/Editor.exe"); } else { editorExe.appendAscii("/Bin64/Editor.exe"); } const size_t sizeToCopy = (editorExe.length() + 1) * sizeof(wbuffer[0]); if (sizeToCopy > wbuffer.getSizeInBytes()) { wbuffer[0] = 0; } else { memcpy(wbuffer.getPtr(), editorExe.c_str(), sizeToCopy); } }
tstring CResourceCompilerHelper::GetEditorExecutable() { tstring editorExe = g_pSettingsManager->GetRootPath(); if(editorExe.empty()) { MessageBox(NULL, _T("Can't Find the Material Editor.\nPlease, setup correct CryENGINE root path in the engine settings dialog"), _T("Error"), MB_ICONERROR | MB_OK); ResourceCompilerUI(0); editorExe = g_pSettingsManager->GetRootPath(); if(editorExe.empty()) return editorExe; } if (g_pSettingsManager->GetValue<tstring>(_T("EDT_Prefer32Bit"))==_T("true")) editorExe += _T("/Bin32/Editor.exe"); else editorExe += _T("/Bin64/Editor.exe"); return editorExe; }
void* CResourceCompilerHelper::CallEditor( void* pParent, const TCHAR * pWndName, const TCHAR * pFlag ) { HWND hWnd = ::FindWindow(NULL, pWndName); if(hWnd) return hWnd; else { tstring editorExecutable = GetEditorExecutable(); if (editorExecutable!=_T("")) { INT_PTR hIns = (INT_PTR)ShellExecute(NULL, _T("open"), editorExecutable.c_str(), pFlag, NULL, SW_SHOWNORMAL); if(hIns<=32) { MessageBox(0,_T("Editor.exe was not found.\n\nPlease verify CryENGINE root path."),_T("Error"),MB_ICONERROR|MB_OK); ResourceCompilerUI(pParent); editorExecutable = GetEditorExecutable(); ShellExecute(NULL, _T("open"), editorExecutable.c_str(), pFlag, NULL, SW_SHOWNORMAL); } } } return 0; }
bool CResourceCompilerHelper::CallEditor(void** pEditorWindow, void* hParent, const char* pWindowName, const char* pFlag) { HWND window = ::FindWindowA(NULL, pWindowName); if (window) { *pEditorWindow = window; return true; } else { *pEditorWindow = 0; wchar_t buffer[512] = { L'\0' }; GetEditorExecutable(SettingsManagerHelpers::CWCharBuffer(buffer, sizeof(buffer))); SettingsManagerHelpers::CFixedString<wchar_t, 256> wFlags; SettingsManagerHelpers::ConvertUtf8ToUtf16(pFlag, wFlags.getBuffer()); wFlags.setLength(wcslen(wFlags.c_str())); if (buffer[0] != '\0') { INT_PTR hIns = (INT_PTR)ShellExecuteW(NULL, L"open", buffer, wFlags.c_str(), NULL, SW_SHOWNORMAL); if(hIns > 32) { return true; } else { MessageBoxA(0,"Editor.exe was not found.\n\nPlease verify CryENGINE root path.","Error",MB_ICONERROR|MB_OK); ResourceCompilerUI(hParent); GetEditorExecutable(SettingsManagerHelpers::CWCharBuffer(buffer, sizeof(buffer))); ShellExecuteW(NULL, L"open", buffer, wFlags.c_str(), NULL, SW_SHOWNORMAL); } } } return false; }