BOOL CFilePatchesDlg::SetFileStatusAsPatched(CString sPath) { for (int i=0; i<m_arFileStates.GetCount(); i++) { if (sPath.CompareNoCase(GetFullPath(i))==0) { m_arFileStates.SetAt(i, (DWORD)FPDLG_FILESTATE_PATCHED); SetStateText(i, FPDLG_FILESTATE_PATCHED); Invalidate(); return TRUE; } } return FALSE; }
void UIButton::LoadFromYamlNode(YamlNode * node, UIYamlLoader * loader) { UIControl::LoadFromYamlNode(node, loader); //int32 stateArray[] = {STATE_NORMAL, STATE_PRESSED_INSIDE, STATE_PRESSED_OUTSIDE, STATE_DISABLED, STATE_SELECTED, STATE_HOVER}; //String statePostfix[] = {"Normal", "PressedInside", "PressedOutside", "Disabled", "Selected", "Hover"}; for (int k = 0; k < STATE_COUNT; ++k) { YamlNode * stateSpriteNode = node->Get(Format("stateSprite%s", statePostfix[k].c_str())); if (stateSpriteNode) { YamlNode * spriteNode = stateSpriteNode->Get(0); YamlNode * frameNode = stateSpriteNode->Get(1); YamlNode * backgroundModificationNode = NULL; if(stateSpriteNode->GetCount() > 2) { backgroundModificationNode = stateSpriteNode->Get(2); } int32 frame = 0; if (frameNode)frame = frameNode->AsInt(); if (spriteNode) { SetStateSprite(stateArray[k], spriteNode->AsString(), frame); } if (backgroundModificationNode) { stateBacks[k]->SetModification(backgroundModificationNode->AsInt()); } } YamlNode * stateDrawTypeNode = node->Get(Format("stateDrawType%s", statePostfix[k].c_str())); if (stateDrawTypeNode) { UIControlBackground::eDrawType type = (UIControlBackground::eDrawType)loader->GetDrawTypeFromNode(stateDrawTypeNode); SetStateDrawType(stateArray[k],type); YamlNode * leftRightStretchCapNode = node->Get(Format("leftRightStretchCap%s", statePostfix[k].c_str())); YamlNode * topBottomStretchCapNode = node->Get(Format("topBottomStretchCap%s", statePostfix[k].c_str())); if(leftRightStretchCapNode) { float32 leftStretchCap = leftRightStretchCapNode->AsFloat(); GetActualBackground(stateArray[k])->SetLeftRightStretchCap(leftStretchCap); } if(topBottomStretchCapNode) { float32 topStretchCap = topBottomStretchCapNode->AsFloat(); GetActualBackground(stateArray[k])->SetTopBottomStretchCap(topStretchCap); } } else { SetStateDrawType(stateArray[k],UIControlBackground::DRAW_ALIGNED); } YamlNode * stateAlignNode = node->Get(Format("stateAlign%s", statePostfix[k].c_str())); if (stateAlignNode) { int32 align = loader->GetAlignFromYamlNode(stateAlignNode); SetStateAlign(stateArray[k],align); } YamlNode * stateFontNode = node->Get(Format("stateFont%s", statePostfix[k].c_str())); if (stateFontNode) { Font * font = loader->GetFontByName(stateFontNode->AsString()); if (font)SetStateFont(stateArray[k], font); } YamlNode * stateTextNode = node->Get(Format("stateText%s", statePostfix[k].c_str())); if (stateTextNode) { SetStateText(stateArray[k], LocalizedString(stateTextNode->AsWString())); } YamlNode * stateTextColorNode = node->Get(Format("stateTextcolor%s", statePostfix[k].c_str())); if (stateTextColorNode) { Vector4 c = stateTextColorNode->AsVector4(); SetStateFontColor(stateArray[k], Color(c.x, c.y, c.z, c.w)); } YamlNode * stateShadowColorNode = node->Get(Format("stateShadowcolor%s", statePostfix[k].c_str())); if (stateShadowColorNode) { Vector4 c = stateShadowColorNode->AsVector4(); SetStateShadowColor(stateArray[k], Color(c.x, c.y, c.z, c.w)); } YamlNode * stateShadowOffsetNode = node->Get(Format("stateShadowoffset%s", statePostfix[k].c_str())); if (stateShadowOffsetNode) { SetStateShadowOffset(stateArray[k], stateShadowOffsetNode->AsVector2()); } YamlNode * colorInheritNode = node->Get(Format("stateColorInherit%s", statePostfix[k].c_str())); if(colorInheritNode) { UIControlBackground::eColorInheritType type = (UIControlBackground::eColorInheritType)loader->GetColorInheritTypeFromNode(colorInheritNode); GetActualBackground(stateArray[k])->SetColorInheritType(type); } YamlNode * colorNode = node->Get(Format("stateColor%s", statePostfix[k].c_str())); if(colorNode) { Color color = loader->GetColorFromYamlNode(colorNode); GetActualBackground(stateArray[k])->SetColor(color); } } }
void UIButton::LoadFromYamlNode(YamlNode * node, UIYamlLoader * loader) { UIControl::LoadFromYamlNode(node, loader); //int32 stateArray[] = {STATE_NORMAL, STATE_PRESSED_INSIDE, STATE_PRESSED_OUTSIDE, STATE_DISABLED, STATE_SELECTED, STATE_HOVER}; //String statePostfix[] = {"Normal", "PressedInside", "PressedOutside", "Disabled", "Selected", "Hover"}; for (int k = 0; k < STATE_COUNT; ++k) { YamlNode * stateSpriteNode = node->Get(Format("stateSprite%s", statePostfix[k].c_str())); if (stateSpriteNode) { YamlNode * spriteNode = stateSpriteNode->Get(0); YamlNode * frameNode = stateSpriteNode->Get(1); int32 frame = 0; if (frameNode)frame = frameNode->AsInt(); if (spriteNode) { SetStateSprite(stateArray[k], spriteNode->AsString(), frame); } } YamlNode * stateDrawTypeNode = node->Get(Format("stateDrawType%s", statePostfix[k].c_str())); if (stateDrawTypeNode) { UIControlBackground::eDrawType type = (UIControlBackground::eDrawType)loader->GetDrawTypeFromNode(stateDrawTypeNode); SetStateDrawType(stateArray[k],type); YamlNode * leftRightStretchCapNode = node->Get(Format("leftRightStretchCap%s", statePostfix[k].c_str())); YamlNode * topBottomStretchCapNode = node->Get(Format("topBottomStretchCap%s", statePostfix[k].c_str())); if(leftRightStretchCapNode) { float32 leftStretchCap = leftRightStretchCapNode->AsFloat(); GetActualBackground(stateArray[k])->SetLeftRightStretchCap(leftStretchCap); } if(topBottomStretchCapNode) { float32 topStretchCap = topBottomStretchCapNode->AsFloat(); GetActualBackground(stateArray[k])->SetTopBottomStretchCap(topStretchCap); } } YamlNode * stateAlignNode = node->Get(Format("stateAlign%s", statePostfix[k].c_str())); if (stateAlignNode) { int32 align = loader->GetAlignFromYamlNode(stateAlignNode); SetStateAlign(stateArray[k],align); } YamlNode * stateFontNode = node->Get(Format("stateFont%s", statePostfix[k].c_str())); if (stateFontNode) { Font * font = loader->GetFontByName(stateFontNode->AsString()); if (font)SetStateFont(stateArray[k], font); } YamlNode * stateTextNode = node->Get(Format("stateText%s", statePostfix[k].c_str())); if (stateTextNode) { SetStateText(stateArray[k], LocalizedString(stateTextNode->AsWString())); } } for (int k = 0; k < STATE_COUNT; ++k) { YamlNode * colorInheritNode = node->Get("colorInherit"); UIControlBackground::eColorInheritType type = (UIControlBackground::eColorInheritType)loader->GetColorInheritTypeFromNode(colorInheritNode); if(colorInheritNode) { for(int32 i = 0; i < DRAW_STATE_COUNT; ++i) { if(stateBacks[i]) { stateBacks[i]->SetColorInheritType(type); } } } } }
BOOL CFilePatchesDlg::Init(GitPatch * pPatch, CPatchFilesDlgCallBack * pCallBack, CString sPath, CWnd * pParent) { if (!pCallBack || !pPatch) { m_cFileList.DeleteAllItems(); return FALSE; } m_arFileStates.RemoveAll(); m_pPatch = pPatch; m_pCallBack = pCallBack; m_sPath = sPath; if (m_sPath.IsEmpty()) { CString title(MAKEINTRESOURCE(IDS_DIFF_TITLE)); SetWindowText(title); } else { CRect rect; GetClientRect(&rect); SetTitleWithPath(rect.Width()); m_sPath.TrimRight(L'\\'); m_sPath += L'\\'; } SetWindowTheme(m_cFileList.GetSafeHwnd(), L"Explorer", nullptr); m_cFileList.SetExtendedStyle(LVS_EX_INFOTIP | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER); m_cFileList.DeleteAllItems(); int c = m_cFileList.GetHeaderCtrl()->GetItemCount() - 1; while (c>=0) m_cFileList.DeleteColumn(c--); m_cFileList.InsertColumn(0, CString(MAKEINTRESOURCE(IDS_PATH))); m_cFileList.InsertColumn(1, CString(MAKEINTRESOURCE(IDS_STATE))); m_cFileList.SetRedraw(false); for(int i=0; i<m_pPatch->GetNumberOfFiles(); i++) { CString sFile = CPathUtils::GetFileNameFromPath(m_pPatch->GetStrippedPath(i)); int state; if (m_sPath.IsEmpty()) state = 0; else { state = m_pPatch->GetFailedHunks(i); } if (m_pPatch->GetHasConflict(i)) state = FPDLG_FILESTATE_CONFLICT; if (state > 0) state = FPDLG_FILESTATE_ERROR; m_arFileStates.Add(state); CString sFileName = GetFullPath(i); sFileName = CPathUtils::GetFileNameFromPath(sFileName); m_cFileList.InsertItem(i, sFile, SYS_IMAGE_LIST().GetPathIconIndex(sFileName)); SetStateText(i, state); } int mincol = 0; int maxcol = m_cFileList.GetHeaderCtrl()->GetItemCount() - 1; int col; for (col = mincol; col <= maxcol; col++) { m_cFileList.SetColumnWidth(col,LVSCW_AUTOSIZE_USEHEADER); } m_cFileList.SetImageList(&SYS_IMAGE_LIST(), LVSIL_SMALL); m_cFileList.SetRedraw(true); RECT parentrect; pParent->GetWindowRect(&parentrect); RECT windowrect; GetWindowRect(&windowrect); int width = windowrect.right - windowrect.left; int height = windowrect.bottom - windowrect.top; windowrect.right = parentrect.left; windowrect.left = windowrect.right - width; windowrect.top = parentrect.top; windowrect.bottom = windowrect.top + height; auto hMonitor = MonitorFromRect(&windowrect, MONITOR_DEFAULTTONULL); if (hMonitor) SetWindowPos(nullptr, windowrect.left, windowrect.top, width, height, SWP_NOACTIVATE | SWP_NOZORDER); m_nWindowHeight = windowrect.bottom - windowrect.top; m_pMainFrame = pParent; return TRUE; }