mirror of
https://github.com/isledecomp/LEGOIslandRebuilder.git
synced 2025-02-17 00:20:40 -05:00
added patch/music tabs
This commit is contained in:
parent
c3af9bf5b8
commit
28ee2c2336
7 changed files with 167 additions and 31 deletions
|
@ -43,6 +43,8 @@ add_executable(Rebuilder WIN32
|
|||
src/launcher.h
|
||||
src/patchgrid.cpp
|
||||
src/patchgrid.h
|
||||
src/tabs.cpp
|
||||
src/tabs.h
|
||||
src/window.cpp
|
||||
src/window.h
|
||||
)
|
||||
|
|
|
@ -36,7 +36,6 @@ CLinkStatic::CLinkStatic()
|
|||
|
||||
BOOL CLinkStatic::OnSetCursor(CWnd *pWnd, UINT nHitTest, UINT message)
|
||||
{
|
||||
|
||||
::SetCursor(m_hPointHand);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -49,7 +48,13 @@ HBRUSH CLinkStatic::CtlColor(CDC *pDC, UINT nCtlColor)
|
|||
return (HBRUSH) GetStockObject(NULL_BRUSH);
|
||||
}
|
||||
|
||||
BOOL CLinkStatic::OnEraseBkgnd(CDC*)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CLinkStatic, super)
|
||||
ON_WM_SETCURSOR()
|
||||
ON_WM_CTLCOLOR_REFLECT()
|
||||
ON_WM_ERASEBKGND()
|
||||
END_MESSAGE_MAP()
|
||||
|
|
|
@ -12,6 +12,8 @@ public:
|
|||
|
||||
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
|
||||
|
||||
afx_msg BOOL OnEraseBkgnd(CDC*);
|
||||
|
||||
private:
|
||||
HCURSOR m_hPointHand;
|
||||
|
||||
|
|
58
src/tabs.cpp
Normal file
58
src/tabs.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
#include "tabs.h"
|
||||
|
||||
void TabCtrl::CreateChildren()
|
||||
{
|
||||
// Create property grid
|
||||
m_cPatchGrid.Create(AfxRegisterWndClass(CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW), "Patch Grid", WS_CHILD | WS_VISIBLE, CRect(), this, ID_PATCHGRID);
|
||||
m_cPatchTitle.Create(CString(), WS_CHILD | WS_VISIBLE, CRect(), this, ID_PATCHTITLE);
|
||||
m_cPatchDesc.Create(CString(), WS_CHILD | WS_VISIBLE, CRect(), this, ID_PATCHDESC);
|
||||
|
||||
m_cMusicLink.Create("Coming back soon. If you need music replacement, download the old .NET version here.",
|
||||
WS_CHILD | SS_CENTER | SS_NOTIFY, CRect(), this, ID_MUSICLINK);
|
||||
}
|
||||
|
||||
HBRUSH TabCtrl::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
||||
{
|
||||
HBRUSH hbr = CWnd::OnCtlColor(pDC, pWnd, nCtlColor);
|
||||
|
||||
if (pWnd->GetDlgCtrlID() == ID_MUSICLINK
|
||||
|| pWnd->GetDlgCtrlID() == ID_PATCHTITLE
|
||||
|| pWnd->GetDlgCtrlID() == ID_PATCHDESC) {
|
||||
pDC->SetBkMode(TRANSPARENT);
|
||||
return (HBRUSH) GetStockObject(NULL_BRUSH);
|
||||
}
|
||||
|
||||
return hbr;
|
||||
}
|
||||
|
||||
LRESULT TabCtrl::OnGridSelChange(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HITEM hItem = (HITEM) wParam;
|
||||
|
||||
m_cPatchTitle.SetWindowText(m_cPatchGrid.GetItemText(hItem).c_str());
|
||||
m_cPatchDesc.SetWindowText(m_cPatchGrid.GetItemDescription(hItem));
|
||||
|
||||
CRect rect;
|
||||
m_cPatchTitle.GetWindowRect(&rect);
|
||||
ScreenToClient(&rect);
|
||||
InvalidateRect(&rect);
|
||||
UpdateWindow();
|
||||
|
||||
m_cPatchDesc.GetWindowRect(&rect);
|
||||
ScreenToClient(&rect);
|
||||
InvalidateRect(&rect);
|
||||
UpdateWindow();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TabCtrl::OnMusicLinkClick()
|
||||
{
|
||||
ShellExecute(NULL, _T("open"), _T("http://github.com/itsmattkc/LEGOIslandRebuilder/releases"), NULL, NULL, SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(TabCtrl, CTabCtrl)
|
||||
ON_WM_CTLCOLOR()
|
||||
ON_BN_CLICKED(ID_MUSICLINK, OnMusicLinkClick)
|
||||
ON_MESSAGE(WM_PG_SELECTIONCHANGED, OnGridSelChange)
|
||||
END_MESSAGE_MAP()
|
48
src/tabs.h
Normal file
48
src/tabs.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
#ifndef CREBUILDERTABS_H
|
||||
#define CREBUILDERTABS_H
|
||||
|
||||
#include <AFXCMN.H>
|
||||
#include <AFXWIN.H>
|
||||
#include <VECTOR>
|
||||
|
||||
#include "clinkstatic.h"
|
||||
#include "patchgrid.h"
|
||||
|
||||
class TabCtrl : public CTabCtrl
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
ID_PATCHGRID = 1000,
|
||||
ID_PATCHTITLE,
|
||||
ID_PATCHDESC,
|
||||
ID_MUSICLINK,
|
||||
ID_COUNT
|
||||
};
|
||||
|
||||
void CreateChildren();
|
||||
|
||||
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
|
||||
|
||||
afx_msg LRESULT OnGridSelChange(WPARAM, LPARAM);
|
||||
|
||||
afx_msg void OnSize(UINT type, int width, int height);
|
||||
|
||||
afx_msg void OnMusicLinkClick();
|
||||
|
||||
PatchGrid &GetPatchGrid() { return m_cPatchGrid; }
|
||||
CStatic &GetPatchTitle() { return m_cPatchTitle; }
|
||||
CStatic &GetPatchDesc() { return m_cPatchDesc; }
|
||||
CStatic &GetMusicLink() { return m_cMusicLink; }
|
||||
|
||||
private:
|
||||
PatchGrid m_cPatchGrid;
|
||||
CStatic m_cPatchTitle;
|
||||
CStatic m_cPatchDesc;
|
||||
|
||||
CLinkStatic m_cMusicLink;
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
};
|
||||
|
||||
#endif // CREBUILDERWINDOW_H
|
|
@ -22,7 +22,7 @@ CRebuilderWindow::CRebuilderWindow()
|
|||
// Register custom window class
|
||||
LPCTSTR wndclass = AfxRegisterWndClass(CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW,
|
||||
LoadCursor(NULL, IDC_ARROW),
|
||||
(HBRUSH) COLOR_WINDOW,
|
||||
GetSysColorBrush(COLOR_3DFACE),
|
||||
LoadIcon(AfxGetInstanceHandle(), "IDI_ICON1"));
|
||||
|
||||
const char *title = "LEGO Island Rebuilder";
|
||||
|
@ -37,18 +37,20 @@ CRebuilderWindow::CRebuilderWindow()
|
|||
// Create subtitle
|
||||
m_cTopLevelSubtitle.Create("by MattKC and Ramen2X", WS_CHILD | WS_VISIBLE | SS_CENTER | SS_NOTIFY, CRect(), this, ID_SUBTITLE);
|
||||
|
||||
// Create tab control
|
||||
m_cTabCtrl.Create(WS_CHILD | WS_VISIBLE, CRect(), this, ID_TABCTRL);
|
||||
m_cTabCtrl.CreateChildren();
|
||||
|
||||
// Initialize common TCITEM
|
||||
TCITEM tabItem;
|
||||
ZeroMemory(&tabItem, sizeof(tabItem));
|
||||
tabItem.mask |= TCIF_TEXT;
|
||||
tabItem.pszText = new TCHAR[100];
|
||||
|
||||
delete [] tabItem.pszText;
|
||||
tabItem.pszText = "Patches";
|
||||
m_cTabCtrl.InsertItem(TAB_PATCHES, &tabItem);
|
||||
|
||||
// Create property grid
|
||||
m_cPatchGrid.Create(AfxRegisterWndClass(CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW), "Patch Grid", WS_CHILD | WS_VISIBLE, CRect(), this, ID_PATCHGRID);
|
||||
m_cPatchTitle.Create(CString(), WS_CHILD | WS_VISIBLE, CRect(), this, ID_PATCHTITLE);
|
||||
m_cPatchDesc.Create(CString(), WS_CHILD | WS_VISIBLE, CRect(), this, ID_PATCHDESC);
|
||||
tabItem.pszText = "Music";
|
||||
m_cTabCtrl.InsertItem(TAB_MUSIC, &tabItem);
|
||||
|
||||
// Create run button
|
||||
m_cRunBtn.Create("Run", WS_CHILD | WS_VISIBLE, CRect(), this, ID_RUN);
|
||||
|
@ -67,12 +69,12 @@ CRebuilderWindow::CRebuilderWindow()
|
|||
|
||||
// Set column width
|
||||
RECT patchGridClientRect;
|
||||
m_cPatchGrid.GetClientRect(&patchGridClientRect);
|
||||
m_cPatchGrid.SetGutterWidth((patchGridClientRect.right - patchGridClientRect.left) / 2);
|
||||
m_cTabCtrl.GetPatchGrid().GetClientRect(&patchGridClientRect);
|
||||
m_cTabCtrl.GetPatchGrid().SetGutterWidth((patchGridClientRect.right - patchGridClientRect.left) / 2);
|
||||
|
||||
TCHAR configPath[MAX_PATH];
|
||||
if (GetConfigFilename(configPath)) {
|
||||
m_cPatchGrid.LoadConfiguration(configPath);
|
||||
m_cTabCtrl.GetPatchGrid().LoadConfiguration(configPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +97,7 @@ BOOL CRebuilderWindow::TrySaving()
|
|||
TCHAR configPath[MAX_PATH];
|
||||
|
||||
if (GetConfigFilename(configPath)) {
|
||||
if (m_cPatchGrid.SaveConfiguration(configPath)) {
|
||||
if (m_cTabCtrl.GetPatchGrid().SaveConfiguration(configPath)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
MessageBox("Failed to save configuration file.");
|
||||
|
@ -164,16 +166,31 @@ void CRebuilderWindow::OnSize(UINT type, int width, int height)
|
|||
m_cRunBtn.SetWindowPos(NULL, padding, btnY, btnWidth, btnHeight, 0);
|
||||
m_cKillBtn.SetWindowPos(NULL, padding, btnY, btnWidth, btnHeight, 0);
|
||||
|
||||
h = btnY - y - padding;
|
||||
m_cTabCtrl.SetWindowPos(NULL, padding, y, btnWidth, h, 0);
|
||||
|
||||
// Generate internal rect
|
||||
RECT inner;
|
||||
m_cTabCtrl.GetClientRect(&inner);
|
||||
m_cTabCtrl.AdjustRect(FALSE, &inner);
|
||||
|
||||
int w = inner.right - inner.left;
|
||||
|
||||
h = m_nFontHeight*4;
|
||||
int patchDescY = btnY - h;
|
||||
m_cPatchDesc.SetWindowPos(NULL, padding, patchDescY, btnWidth, h, 0);
|
||||
int patchDescY = inner.bottom - h;
|
||||
m_cTabCtrl.GetPatchDesc().SetWindowPos(NULL, inner.left, patchDescY, w, h, 0);
|
||||
|
||||
h = m_nFontHeight;
|
||||
patchDescY -= h;
|
||||
m_cPatchTitle.SetWindowPos(NULL, padding, patchDescY, btnWidth, h, 0);
|
||||
m_cTabCtrl.GetPatchTitle().SetWindowPos(NULL, inner.left, patchDescY, w, h, 0);
|
||||
|
||||
// Consume remaining space with patch grid
|
||||
m_cPatchGrid.SetWindowPos(NULL, padding, y, btnWidth, patchDescY - y - padding, 0);
|
||||
h = patchDescY - inner.top;
|
||||
m_cTabCtrl.GetPatchGrid().SetWindowPos(NULL, inner.left, inner.top, w, h, 0);
|
||||
|
||||
h = inner.bottom - inner.top;
|
||||
int musicLinkWidth = w/4*3;
|
||||
m_cTabCtrl.GetMusicLink().SetWindowPos(NULL, inner.left + w/2 - musicLinkWidth/2, inner.top + m_nFontHeight, musicLinkWidth, h, 0);
|
||||
}
|
||||
|
||||
void CRebuilderWindow::OnGetMinMaxInfo(MINMAXINFO *info)
|
||||
|
@ -185,13 +202,14 @@ void CRebuilderWindow::OnGetMinMaxInfo(MINMAXINFO *info)
|
|||
info->ptMinTrackSize.y = m_nFontHeight * minimumWindowHeight;
|
||||
}
|
||||
|
||||
LRESULT CRebuilderWindow::OnGridSelChange(WPARAM wParam, LPARAM lParam)
|
||||
void CRebuilderWindow::OnTabSelChange(NMHDR *pNMHDR, LRESULT *pResult)
|
||||
{
|
||||
HITEM hItem = (HITEM) wParam;
|
||||
int tab = m_cTabCtrl.GetCurSel();
|
||||
|
||||
m_cPatchTitle.SetWindowText(m_cPatchGrid.GetItemText(hItem).c_str());
|
||||
m_cPatchDesc.SetWindowText(m_cPatchGrid.GetItemDescription(hItem));
|
||||
return 0;
|
||||
m_cTabCtrl.GetPatchGrid().ShowWindow((tab == TAB_PATCHES) ? SW_SHOWNORMAL : SW_HIDE);
|
||||
m_cTabCtrl.GetPatchTitle().ShowWindow((tab == TAB_PATCHES) ? SW_SHOWNORMAL : SW_HIDE);
|
||||
m_cTabCtrl.GetPatchDesc().ShowWindow((tab == TAB_PATCHES) ? SW_SHOWNORMAL : SW_HIDE);
|
||||
m_cTabCtrl.GetMusicLink().ShowWindow((tab == TAB_MUSIC) ? SW_SHOWNORMAL : SW_HIDE);
|
||||
}
|
||||
|
||||
BOOL CRebuilderWindow::SetFont(HWND child, LPARAM font)
|
||||
|
@ -242,7 +260,7 @@ void CRebuilderWindow::SetGUIFonts()
|
|||
SetFont(m_cTopLevelTitle.GetSafeHwnd(), (LPARAM)bold);
|
||||
SetFont(m_cRunBtn.GetSafeHwnd(), (LPARAM)bold);
|
||||
SetFont(m_cKillBtn.GetSafeHwnd(), (LPARAM)bold);
|
||||
SetFont(m_cPatchTitle.GetSafeHwnd(), (LPARAM)bold);
|
||||
SetFont(m_cTabCtrl.GetPatchTitle().GetSafeHwnd(), (LPARAM)bold);
|
||||
|
||||
// Create link variant for subtitle
|
||||
lf.lfWeight = FW_NORMAL;
|
||||
|
@ -250,6 +268,7 @@ void CRebuilderWindow::SetGUIFonts()
|
|||
|
||||
HFONT link = CreateFontIndirect(&lf);
|
||||
SetFont(m_cTopLevelSubtitle.GetSafeHwnd(), (LPARAM)link);
|
||||
SetFont(m_cTabCtrl.GetMusicLink().GetSafeHwnd(), (LPARAM)link);
|
||||
|
||||
// While here, get height of font for layout purposes
|
||||
HDC hDC = ::GetDC(NULL);
|
||||
|
@ -278,5 +297,5 @@ BEGIN_MESSAGE_MAP(CRebuilderWindow, super)
|
|||
ON_BN_CLICKED(ID_RUN, OnRunClick)
|
||||
ON_BN_CLICKED(ID_KILL, OnKillClick)
|
||||
ON_BN_CLICKED(ID_SUBTITLE, OnSubtitleClick)
|
||||
ON_MESSAGE(WM_PG_SELECTIONCHANGED, OnGridSelChange)
|
||||
ON_NOTIFY(TCN_SELCHANGE, ID_TABCTRL, OnTabSelChange)
|
||||
END_MESSAGE_MAP()
|
||||
|
|
18
src/window.h
18
src/window.h
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "clinkstatic.h"
|
||||
#include "patchgrid.h"
|
||||
#include "tabs.h"
|
||||
|
||||
class CRebuilderWindow : public CFrameWnd
|
||||
{
|
||||
|
@ -25,7 +26,7 @@ public:
|
|||
|
||||
afx_msg void OnGetMinMaxInfo(MINMAXINFO *info);
|
||||
|
||||
afx_msg LRESULT OnGridSelChange(WPARAM, LPARAM);
|
||||
afx_msg void OnTabSelChange(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
|
||||
static BOOL CALLBACK SetFont(HWND child, LPARAM font);
|
||||
|
||||
|
@ -41,25 +42,26 @@ private:
|
|||
enum {
|
||||
ID_RUN = 1000,
|
||||
ID_KILL,
|
||||
ID_TABCTRL,
|
||||
ID_SUBTITLE,
|
||||
ID_PATCHGRID,
|
||||
ID_PATCHTITLE,
|
||||
ID_PATCHDESC,
|
||||
ID_COUNT
|
||||
};
|
||||
|
||||
enum Tab {
|
||||
TAB_PATCHES,
|
||||
TAB_MUSIC
|
||||
};
|
||||
|
||||
UINT m_nFontHeight;
|
||||
|
||||
CStatic m_cTopLevelTitle;
|
||||
CLinkStatic m_cTopLevelSubtitle;
|
||||
|
||||
TabCtrl m_cTabCtrl;
|
||||
|
||||
CButton m_cRunBtn;
|
||||
CButton m_cKillBtn;
|
||||
|
||||
PatchGrid m_cPatchGrid;
|
||||
CStatic m_cPatchTitle;
|
||||
CStatic m_cPatchDesc;
|
||||
|
||||
std::vector<HANDLE> m_lProcesses;
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
|
Loading…
Reference in a new issue