bool MkCheck::ExceptionForDebug(const wchar_t* expression, const wchar_t* message) { MkStr msg; msg.Reserve(1024); msg += L"EXPRESSION : "; msg += expression; msg += L"\nMESSAGE : "; msg += message; #if (MKDEF_CHECK_EXCEPTION_BREAK) int rlt = MessageBox(NULL, msg.GetPtr(), L"Oops!!! Break?", MB_YESNO); if (rlt == IDYES) { // break _CrtDbgBreak(); } else if (rlt == IDNO) #else int rlt = MessageBox(NULL, msg.GetPtr(), L"Oops!!!", MB_OK); if (rlt == IDOK) #endif { // log 기록 후 진행 MK_LOG_MGR.Msg(L"<Error> " + msg, true); } return true; // excute action }
bool ApResourceUnit::SetRowColumnType(eRowColumnType rcType) { if (rcType == m_RowColumnType) return true; MkStr ssPrefix; switch (rcType) { case eRCT_None: break; case eRCT_Light: ssPrefix = L"ResIndexLight_"; break; case eRCT_Dark: ssPrefix = L"ResIndexDark_"; break; } if (ssPrefix.Empty()) { if (m_SceneNode != NULL) { m_SceneNode->DeletePanel(L"Row"); m_SceneNode->DeletePanel(L"Column"); } m_RowColumnType = rcType; return true; } bool ok = (_AddImagePanelToLeftTop(L"Row", m_ImagePath, ssPrefix + MkStr(m_Type.GetRow()), -0.1f) && _AddImagePanelToRightBottom(L"Column", m_ImagePath, ssPrefix + MkStr(m_Type.GetColumn()), -0.1f)); if (ok) { m_RowColumnType = rcType; } return ok; }
void MkStaticResourceContainer::LoadTextNode(const MkDataNode* dataNode) { if (dataNode != NULL) { MkStr filePath; if (dataNode->GetData(L"TextNode", filePath, 0) && (!filePath.Empty())) { LoadTextNode(filePath); } } }
HWND MkWebBrowser::Open(const MkStr& pageUrl, int posX, int posY, int width, int height) { if (pageUrl.Empty()) return NULL; HRESULT hr; IWebBrowser2* pWebBrowser = NULL; VARIANT vtHeader2 = {0}; VARIANT vtTarget2 = {0}; VARIANT vtEmpty2 = {0}; vtHeader2.vt = VT_BSTR; vtHeader2.bstrVal = SysAllocString(L"Content-Type: application/x-www-form-urlencoded\r\n"); vtTarget2.vt = VT_BSTR; vtTarget2.bstrVal = SysAllocString(L"_top"); VariantInit(&vtEmpty2); CoInitialize(NULL); CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER, IID_IWebBrowser2, (void**)&pWebBrowser); pWebBrowser->put_Width((long)width); pWebBrowser->put_Height((long)height); pWebBrowser->put_Left((long)posX); pWebBrowser->put_Top((long)posY); pWebBrowser->put_MenuBar(VARIANT_FALSE); pWebBrowser->put_ToolBar(VARIANT_FALSE); pWebBrowser->put_AddressBar(VARIANT_FALSE); pWebBrowser->put_StatusBar(VARIANT_FALSE); BSTR cBuf = SysAllocString(pageUrl.GetPtr()); hr = pWebBrowser->Navigate(cBuf, &vtEmpty2, &vtTarget2, &vtEmpty2, &vtHeader2); SysFreeString(cBuf); SysFreeString(vtHeader2.bstrVal); SysFreeString(vtTarget2.bstrVal); HWND exh = NULL; if (SUCCEEDED(hr)) { pWebBrowser->put_Visible(VARIANT_TRUE); pWebBrowser->get_HWND((long*)&exh); } else { pWebBrowser->Quit(); } pWebBrowser->Release(); CoUninitialize(); return exh; }
bool MkSoundBuffer::SetUp(LPDIRECTSOUND directSound, const MkPathName& filePath) { if (directSound == NULL) return false; Clear(); do { MkStr ext = filePath.GetFileExtension(); ext.ToLower(); bool isWave = ext.Equals(0, L"wav"); bool isOgg = ext.Equals(0, L"ogg"); if ((!isWave) && (!isOgg)) break; // file data MkByteArray srcData; MK_CHECK(MkFileManager::GetFileData(filePath, srcData), L"음원 파일 로딩 실패 : " + filePath) break; if (srcData.Empty()) break; if (isWave) { if (!_CreateBufferFromWaveFile(directSound, srcData)) break; } else if (isOgg) { if (!_CreateBufferFromOggFile(directSound, srcData)) break; } else break; _UpdateInformation(); return true; } while (false); Clear(); return false; }
bool MkCheatMessage::ExcuteMsg(const MkStr& command, const MkArray<MkStr>& argument, MkStr& resultMsg) const { MkStr cmd = command; cmd.ToLower(); if ((cmd == L"q") && argument.Empty()) { MK_DEV_PANEL.__QuitApplication(); return true; } if ((cmd == L"cls") && argument.Empty()) { MK_DEV_PANEL.ClearLogWindow(); return true; } return false; }
// MkPrimitiveDataType ePrimitiveDataType MkPrimitiveDataType::GetEnum(const MkStr& tag) { if (!tag.Empty()) { switch (tag.GetAt(0)) { case L'b': { if (tag == m_TypeTag[ePDT_Bool]) return ePDT_Bool; } break; case L'i': { if (tag == m_TypeTag[ePDT_Int]) return ePDT_Int; else if (tag == m_TypeTag[ePDT_Int2]) return ePDT_Int2; } break; case L'u': { if (tag == m_TypeTag[ePDT_UnsignedInt]) return ePDT_UnsignedInt; } break; case L'f': { if (tag == m_TypeTag[ePDT_Float]) return ePDT_Float; } break; case L'v': { if (tag == m_TypeTag[ePDT_Vec3]) return ePDT_Vec3; else if (tag == m_TypeTag[ePDT_Vec2]) return ePDT_Vec2; } break; case L's': { if (tag == m_TypeTag[ePDT_Str]) return ePDT_Str; } break; } } return ePDT_Undefined; }
void MkCursorManager::SetUp(const MkDataNode* node) { if (node == NULL) return; MK_DEV_PANEL.MsgToLog(L"< Cursor >", false); for (unsigned int i=0; i<eMaxType; ++i) { const MkDataNode* childNode = node->GetChildNode(CURSOR_NAME[i]); if (childNode != NULL) { MkStr filePath; MK_CHECK(childNode->GetData(FILE_PATH_KEY, filePath, 0) && (!filePath.Empty()), L"MkCursorManager에 등록될 " + CURSOR_NAME[i].GetString() + L" 노드의 " + FILE_PATH_KEY.GetString() + L" 항목 오류") continue; MkInt2 hotspot; childNode->GetData(HOTSPOT_KEY, hotspot, 0); RegisterCursor(static_cast<eCursorType>(i), filePath, static_cast<unsigned int>(hotspot.x), static_cast<unsigned int>(hotspot.y)); } }
void MkCheckBoxControlNode::_SetCaption(const MkArray<MkHashStr>& textNode, const MkStr& caption) { if (textNode.Empty() || (!MK_STATIC_RES.TextNodeExist(textNode))) { RemoveChildNode(CaptionNodeName); m_CaptionString.Clear(); return; } // MkWindowTagNode 사용 MkWindowTagNode* node = NULL; if (ChildExist(CaptionNodeName)) { node = dynamic_cast<MkWindowTagNode*>(GetChildNode(CaptionNodeName)); } else { node = MkWindowTagNode::CreateChildNode(this, CaptionNodeName); if (node != NULL) { node->SetAlignmentPivotIsWindowRect(true); node->SetAlignmentPosition(eRAP_RMostCenter); node->SetAlignmentOffset(MkFloat2(node->GetLengthOfBetweenIconAndText(), 0.f)); } } if (node != NULL) { m_CaptionString = caption; if (caption.Empty()) { node->SetTextName(textNode); } else { node->SetTextName(textNode, caption); } } }
MkStr MkSystemEnvironment::GetCurrentSystemDate(void) const { wchar_t dateBuf[9]; _wstrdate_s(dateBuf, 9); MkStr tmpBuffer = dateBuf; // "월/일/연" -> "연.월.일" MkStr month, day, year; unsigned int pos = tmpBuffer.GetFirstBlock(0, L"/", month); pos = tmpBuffer.GetFirstBlock(pos, L"/", day); tmpBuffer.GetSubStr(MkArraySection(pos), year); MkStr result; result.Reserve(10); result += L"20"; result += year; result += L"."; result += month; result += L"."; result += day; return result; }
bool MkCheck::ExceptionForRelease(const char* function, long lineNum, const wchar_t* expression, const wchar_t* message) { MkStr funcBuf; funcBuf.ImportMultiByteString(std::string(function)); MkStr msg; msg.Reserve(1024); msg += L"FUNCTION : "; msg += funcBuf; msg += L" ("; msg += MkStr(lineNum); msg += L")\nEXPRESSION : "; msg += expression; msg += L"\nMESSAGE : "; msg += message; #if (MKDEF_CHECK_EXCEPTION_BREAK) int rlt = MessageBox(NULL, msg.GetPtr(), L"Oops!!! Break?", MB_YESNO); if (rlt == IDYES) { // crash log MK_LOG_MGR.CreateCrashPage(msg); // 강제예외 throw; } else if (rlt == IDNO) #else int rlt = MessageBox(NULL, msg.GetPtr(), L"Oops!!!", MB_OK); if (rlt == IDOK) #endif { // log 기록 후 진행 MK_LOG_MGR.Msg(L"<Error> " + msg, true); } return true; // excute action }
void MkSystemEnvironment::__PrintSystemInformationToLog(void) const { // 시스템 기본 정보 출력 MkStr buffer; buffer.Reserve(2048); buffer += L"< System environment >"; buffer += MkStr::CRLF; // application version buffer += L" - Application version : "; buffer += m_ApplicationVersion.ToString(); buffer += MkStr::CRLF; // minikey version buffer += L" - MiniKey version : "; buffer += m_MiniKeyVersion.ToString(); buffer += MkStr::CRLF; // build mode MkStr currMode; buffer += L" - Build mode : "; switch (m_BuildMode) { case eDebug: buffer += L"Debug"; break; case eRelease: buffer += L"Release"; break; case eShipping: buffer += L"Shipping"; break; } buffer += MkStr::CRLF; // user buffer += L" - User name : "; buffer += m_CurrentUserName; buffer += MkStr::CRLF; // OS buffer += L" - OS : Windows "; buffer += m_WindowsVersion; switch (m_ProcessorArchitecture) { case eEtcPA: buffer += L" (EtcPA)"; break; case eX86: buffer += L" (x86)"; break; case eX64: buffer += L" (x64)"; break; } buffer += MkStr::CRLF; // core buffer += L" - Cores : "; buffer += MkStr(m_NumberOfProcessors); buffer += MkStr::CRLF; // locale buffer += L" - Code page : "; buffer += MkStr(MkStr::GetCodePage()); buffer += MkStr::CRLF; // background resolution buffer += L" - Background resolution : "; buffer += m_BackgroundResolution.x; buffer += L" * "; buffer += m_BackgroundResolution.y; buffer += MkStr::CRLF; // module directory buffer += L" - Module directory :"; buffer += MkStr::CRLF; buffer += L" "; buffer += MkStr(MkPathName::GetModuleDirectory()); buffer += MkStr::CRLF; // root directory buffer += L" - Root directory :"; buffer += MkStr::CRLF; buffer += L" "; buffer += MkStr(MkPathName::GetRootDirectory()); buffer += MkStr::CRLF; // print to log MK_DEV_PANEL.MsgToLog(buffer, false); }
bool MkShaderEffect::SetUp(const MkHashStr& name, const MkPathName& filePath) { LPDIRECT3DDEVICE9 device = MK_DEVICE_MGR.GetDevice(); if (device == NULL) return false; // name m_Name = name; // effect setup LPD3DXBUFFER msg = NULL; bool ok = SUCCEEDED(D3DXCreateEffectFromFile(device, filePath, NULL, NULL, 0, NULL, &m_Effect, &msg)); if (ok) { // parameter 정보를 조사해 정의된 semantic이 존재하면 등록 D3DXEFFECT_DESC effectDesc; m_Effect->GetDesc(&effectDesc); for (unsigned int i=0; i<effectDesc.Parameters; ++i) { // param 정보 추출 D3DXHANDLE paramHandle = m_Effect->GetParameter(NULL, i); D3DXPARAMETER_DESC paramDesc; m_Effect->GetParameterDesc(paramHandle, ¶mDesc); // semantic key가 존재하면 진행 MkHashStr semanticKey; if (paramDesc.Semantic != NULL) { MkStr buffer; buffer.ImportMultiByteString(paramDesc.Semantic); semanticKey = buffer; } if (!semanticKey.Empty()) { // param name MkStr paramName; paramName.ImportMultiByteString(paramDesc.Name); // semantic eSemantic semantic = _GetSemantic(semanticKey); // 정의되지 않은 semantic 이면 무시 MK_CHECK(semantic != eS_None, m_Name.GetString() + L" effect의 " + paramName + L" param에 정의되지 않은 " + semanticKey.GetString() + L" semantic 적용. param 무시됨") continue; // param type eParamType paramType = _GetParamType(paramDesc); // param type이 일치하지 않는 semantic 이면 무시 MK_CHECK(paramType == SemanticParamType[semantic], m_Name.GetString() + L" effect의 " + paramName + L" param에 적용된 " + semanticKey.GetString() + L" semantic의 허용 type이 다름. param 무시됨") continue; // semantic 중복은 허용하지 않음 MK_CHECK(!m_SemanticParameters.Exist(semantic), m_Name.GetString() + L" effect의 " + paramName + L" param에 " + semanticKey.GetString() + L" semantic 중복 적용. param 무시됨") continue; // 등록 m_SemanticParameters.Create(semantic) = paramHandle; // annotation으로부터 default 값 읽음 _UpdateDefaultFromAnnotation(semantic, paramHandle); } } // 최초 technique을 default로 설정 if (effectDesc.Techniques > 0) { D3DXHANDLE techniqueHandle = m_Effect->GetTechnique(0); m_Effect->SetTechnique(techniqueHandle); } m_SemanticParameters.GetKeyList(m_OwnedSemanticList); }
bool MkCheatMessage::__ExcuteMsg(const MkStr& inputMsg, MkStr& resultMsg) const { if (inputMsg.Empty()) return false; MkStr msgCopy = inputMsg; MkStringTableForParser stringTable; stringTable.BuildStringTable(msgCopy); msgCopy.RemoveKeyword(MkStr::CR); bool result = false; // 라인별 분리 MkArray<MkStr> lines; unsigned int lineCount = msgCopy.Tokenize(lines, MkStr::LF); MK_INDEXING_LOOP(lines, i) { MkArray<MkStr> tokens; MkStr command; unsigned int tokenCount = lines[i].Tokenize(tokens); if (tokenCount > 0) // 유효문자가 존재하면 { bool success = false; if (DoAutoParsing(tokens[0])) { command = tokens[0]; MkArray<MkStr> argument; if (tokenCount > 1) // argument가 존재하면 { argument.Reserve(tokenCount - 1); for (unsigned int i=1; i<tokenCount; ++i) { MkHashStr currToken = tokens[i]; argument.PushBack(stringTable.Exist(currToken) ? stringTable.GetString(currToken) : tokens[i]); } } success = ExcuteMsg(command, argument, resultMsg); } else { MkStr lineMsg = tokens[0]; for (unsigned int i=1; i<tokenCount; ++i) { MkHashStr currToken = tokens[i]; lineMsg += MkStr::SPACE; lineMsg += stringTable.Exist(currToken) ? stringTable.GetString(currToken) : tokens[i]; } success = ExcuteLine(lineMsg, resultMsg); } if (success) { result = true; // 하나라도 성공하면 의미 있음 } else { resultMsg += MkStr::CRLF; resultMsg += L"> MkCheatMessage::\"" + lines[i] + L"\" 실행 실패"; } } }
bool MkWebBrowser::Open(HWND parent, const MkStr& pageUrl, int posX, int posY, int width, int height, bool show) { if ((m_Browser != NULL) || pageUrl.Empty()) return false; CoInitialize(NULL); HRESULT hr = CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER, IID_IWebBrowser2, (void**)&m_Browser); if (SUCCEEDED(hr) && (m_Browser != NULL)) { m_Browser->put_Width((long)width); m_Browser->put_Height((long)height); m_Browser->put_Left((long)posX); m_Browser->put_Top((long)posY); m_Browser->put_MenuBar(VARIANT_FALSE); m_Browser->put_ToolBar(VARIANT_FALSE); m_Browser->put_AddressBar(VARIANT_FALSE); m_Browser->put_StatusBar(VARIANT_FALSE); BSTR cBuf = SysAllocString(pageUrl.GetPtr()); VARIANT vtFlag2 = {0}; vtFlag2.vt = VT_I4; vtFlag2.lVal = navNoHistory | navNoReadFromCache | navNoWriteToCache; VARIANT vtTarget2 = {0}; vtTarget2.vt = VT_BSTR; vtTarget2.bstrVal = SysAllocString(L"_top"); VARIANT vtEmpty2 = {0}; VariantInit(&vtEmpty2); VARIANT vtHeader2 = {0}; vtHeader2.vt = VT_BSTR; vtHeader2.bstrVal = SysAllocString(L"Content-Type: application/x-www-form-urlencoded\r\n"); hr = m_Browser->Navigate(cBuf, &vtFlag2, &vtTarget2, &vtEmpty2, &vtHeader2); SysFreeString(cBuf); SysFreeString(vtHeader2.bstrVal); SysFreeString(vtTarget2.bstrVal); if (SUCCEEDED(hr)) { m_Browser->put_Visible((show) ? VARIANT_TRUE : VARIANT_FALSE); m_Browser->get_HWND((long*)&m_hWnd); if (parent != NULL) { m_StyleBackup = static_cast<DWORD>(::GetWindowLongPtr(m_hWnd, GWL_STYLE)); ::SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN); ::SetWindowPos(m_hWnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_DRAWFRAME); ::SetParent(m_hWnd, parent); } return true; } else { Close(); } } return false; }