mirror of
https://github.com/reactos/reactos.git
synced 2024-09-06 02:37:06 +00:00
- add a dialog to allow users to change the card backs
- highlights a few drawing bugs in ros svn path=/trunk/; revision=28129
This commit is contained in:
parent
85d3e8b1d1
commit
4c9ad2ec8a
|
@ -263,7 +263,7 @@ HPALETTE MakePaletteFromCols(COLORREF cols[], int nNumColours)
|
||||||
lp = (LOGPALETTE *)HeapAlloc(
|
lp = (LOGPALETTE *)HeapAlloc(
|
||||||
GetProcessHeap(), 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * nNumColours);
|
GetProcessHeap(), 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * nNumColours);
|
||||||
|
|
||||||
lp->palNumEntries = nNumColours;
|
lp->palNumEntries = (WORD)nNumColours;
|
||||||
lp->palVersion = 0x300;
|
lp->palVersion = 0x300;
|
||||||
|
|
||||||
//copy the colours into the logical palette format
|
//copy the colours into the logical palette format
|
||||||
|
|
|
@ -334,7 +334,7 @@ int CardButton::OnLButtonUp(HWND hwnd, int x, int y)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _countof(array) (sizeof(array)/sizeof(array[0]))
|
//#define _countof(array) (sizeof(array)/sizeof(array[0]))
|
||||||
|
|
||||||
CardButton *CardWindow::CreateButton(int id, TCHAR *szText, UINT uStyle, bool fVisible, int x, int y, int width, int height)
|
CardButton *CardWindow::CreateButton(int id, TCHAR *szText, UINT uStyle, bool fVisible, int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
|
|
|
@ -735,6 +735,11 @@ void CardWindow::SetBackCardIdx(UINT uBackIdx)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UINT CardWindow::GetBackCardIdx()
|
||||||
|
{
|
||||||
|
return nBackCardIdx;
|
||||||
|
}
|
||||||
|
|
||||||
void CardWindow::PaintCardRgn(HDC hdc, int dx, int dy, int width, int height, int sx, int sy)
|
void CardWindow::PaintCardRgn(HDC hdc, int dx, int dy, int width, int height, int sx, int sy)
|
||||||
{
|
{
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
void SetBackColor(COLORREF cr);
|
void SetBackColor(COLORREF cr);
|
||||||
COLORREF GetBackColor();
|
COLORREF GetBackColor();
|
||||||
void SetBackCardIdx(UINT uBackIdx);
|
void SetBackCardIdx(UINT uBackIdx);
|
||||||
|
UINT GetBackCardIdx();
|
||||||
void SetBackImage(HBITMAP hBitmap);
|
void SetBackImage(HBITMAP hBitmap);
|
||||||
|
|
||||||
void EmptyStacks(void);
|
void EmptyStacks(void);
|
||||||
|
|
|
@ -29,6 +29,20 @@ BEGIN
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
|
IDD_CARDBACK DIALOGEX 6, 6, 221, 96
|
||||||
|
CAPTION "Select Card Back"
|
||||||
|
FONT 8, "MS Shell Dlg"
|
||||||
|
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_SHELLFONT
|
||||||
|
BEGIN
|
||||||
|
CONTROL "", IDC_CARDBACK1, "Static", SS_NOTIFY, 4, 7, 50, 61
|
||||||
|
CONTROL "", IDC_CARDBACK2, "Static", SS_NOTIFY, 58, 7, 50, 61
|
||||||
|
CONTROL "", IDC_CARDBACK3, "Static", SS_NOTIFY, 112, 7, 50, 61
|
||||||
|
CONTROL "", IDC_CARDBACK4, "Static", SS_NOTIFY, 166, 7, 50, 61
|
||||||
|
DEFPUSHBUTTON "OK", IDOK, 104, 77, 54, 13
|
||||||
|
PUSHBUTTON "Cancel", IDCANCEL, 162, 77, 54, 13
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
/* Strings */
|
/* Strings */
|
||||||
|
|
||||||
STRINGTABLE
|
STRINGTABLE
|
||||||
|
@ -48,7 +62,7 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "&Deal\tF2", IDM_GAME_NEW
|
MENUITEM "&Deal\tF2", IDM_GAME_NEW
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "De&ck...", IDM_GAME_DECK, GRAYED
|
MENUITEM "De&ck...", IDM_GAME_DECK
|
||||||
MENUITEM "&Options...", IDM_GAME_OPTIONS
|
MENUITEM "&Options...", IDM_GAME_OPTIONS
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "&Exit", IDM_GAME_EXIT
|
MENUITEM "&Exit", IDM_GAME_EXIT
|
||||||
|
|
|
@ -20,6 +20,11 @@
|
||||||
#define IDC_OPT_DRAWTHREE 1202
|
#define IDC_OPT_DRAWTHREE 1202
|
||||||
#define IDC_OPT_SHOWTIME 1203
|
#define IDC_OPT_SHOWTIME 1203
|
||||||
#define IDC_OPT_STATUSBAR 1204
|
#define IDC_OPT_STATUSBAR 1204
|
||||||
|
#define IDD_CARDBACK 1250
|
||||||
|
#define IDC_CARDBACK1 1251
|
||||||
|
#define IDC_CARDBACK2 1252
|
||||||
|
#define IDC_CARDBACK3 1253
|
||||||
|
#define IDC_CARDBACK4 1254
|
||||||
|
|
||||||
/* Strings */
|
/* Strings */
|
||||||
#define IDS_SOL_NAME 1300
|
#define IDS_SOL_NAME 1300
|
||||||
|
|
|
@ -23,6 +23,15 @@ DWORD dwOptions = 8;
|
||||||
|
|
||||||
CardWindow SolWnd;
|
CardWindow SolWnd;
|
||||||
|
|
||||||
|
typedef struct _CardBack
|
||||||
|
{
|
||||||
|
HWND hSelf;
|
||||||
|
WNDPROC hOldProc;
|
||||||
|
INT hdcNum;
|
||||||
|
INT imgNum;
|
||||||
|
BOOL bSelected;
|
||||||
|
} CARDBACK, *PCARDBACK;
|
||||||
|
|
||||||
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
|
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
void MakePath(TCHAR *szDest, UINT nDestLen, const TCHAR *szExt)
|
void MakePath(TCHAR *szDest, UINT nDestLen, const TCHAR *szExt)
|
||||||
|
@ -38,10 +47,11 @@ VOID LoadSettings(VOID)
|
||||||
{
|
{
|
||||||
DWORD dwDisposition;
|
DWORD dwDisposition;
|
||||||
DWORD dwSize;
|
DWORD dwSize;
|
||||||
|
DWORD dwBack;
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
|
|
||||||
if (RegCreateKeyEx(HKEY_CURRENT_USER,
|
if (RegCreateKeyEx(HKEY_CURRENT_USER,
|
||||||
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Solitaire"),
|
_T("Software\\ReactOS\\Solitaire"),
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
REG_OPTION_NON_VOLATILE,
|
REG_OPTION_NON_VOLATILE,
|
||||||
|
@ -59,16 +69,26 @@ VOID LoadSettings(VOID)
|
||||||
(LPBYTE)&dwOptions,
|
(LPBYTE)&dwOptions,
|
||||||
&dwSize);
|
&dwSize);
|
||||||
|
|
||||||
|
dwSize = sizeof(DWORD);
|
||||||
|
RegQueryValueEx(hKey,
|
||||||
|
_T("Back"),
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
(LPBYTE)&dwBack,
|
||||||
|
&dwSize);
|
||||||
|
SolWnd.SetBackCardIdx(dwBack);
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID SaveSettings(VOID)
|
VOID SaveSettings(VOID)
|
||||||
{
|
{
|
||||||
DWORD dwDisposition;
|
DWORD dwDisposition;
|
||||||
|
DWORD dwBack;
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
|
|
||||||
if (RegCreateKeyEx(HKEY_CURRENT_USER,
|
if (RegCreateKeyEx(HKEY_CURRENT_USER,
|
||||||
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Solitaire"),
|
_T("Software\\ReactOS\\Solitaire"),
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
REG_OPTION_NON_VOLATILE,
|
REG_OPTION_NON_VOLATILE,
|
||||||
|
@ -85,6 +105,14 @@ VOID SaveSettings(VOID)
|
||||||
(CONST BYTE *)&dwOptions,
|
(CONST BYTE *)&dwOptions,
|
||||||
sizeof(DWORD));
|
sizeof(DWORD));
|
||||||
|
|
||||||
|
dwBack = SolWnd.GetBackCardIdx();
|
||||||
|
RegSetValueEx(hKey,
|
||||||
|
_T("Back"),
|
||||||
|
0,
|
||||||
|
REG_DWORD,
|
||||||
|
(CONST BYTE *)&dwBack,
|
||||||
|
sizeof(DWORD));
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,13 +166,13 @@ int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, PSTR szCmdLine, int iCmdSh
|
||||||
hwnd = CreateWindow(szAppName, // window class name
|
hwnd = CreateWindow(szAppName, // window class name
|
||||||
szAppName, // window caption
|
szAppName, // window caption
|
||||||
WS_OVERLAPPEDWINDOW
|
WS_OVERLAPPEDWINDOW
|
||||||
,//|WS_CLIPCHILDREN, // window style
|
,//|WS_CLIPCHILDREN, // window style
|
||||||
CW_USEDEFAULT, // initial x position
|
CW_USEDEFAULT, // initial x position
|
||||||
CW_USEDEFAULT, // initial y position
|
CW_USEDEFAULT, // initial y position
|
||||||
CW_USEDEFAULT, // initial x size
|
600, // initial x size
|
||||||
CW_USEDEFAULT, // initial y size
|
450, // initial y size
|
||||||
NULL, // parent window handle
|
NULL, // parent window handle
|
||||||
NULL, // use window class menu
|
NULL, // use window class menu
|
||||||
hInst, // program instance handle
|
hInst, // program instance handle
|
||||||
NULL); // creation parameters
|
NULL); // creation parameters
|
||||||
|
|
||||||
|
@ -211,6 +239,176 @@ VOID ShowGameOptionsDlg(HWND hwnd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LRESULT CALLBACK
|
||||||
|
CardImageWndProc(HWND hwnd,
|
||||||
|
UINT msg,
|
||||||
|
WPARAM wParam,
|
||||||
|
LPARAM lParam)
|
||||||
|
{
|
||||||
|
PCARDBACK pCardBack = (PCARDBACK)GetWindowLongPtr(hwnd,
|
||||||
|
GWL_USERDATA);
|
||||||
|
static WNDPROC hOldProc = NULL;
|
||||||
|
|
||||||
|
if (!hOldProc && pCardBack)
|
||||||
|
hOldProc = pCardBack->hOldProc;
|
||||||
|
|
||||||
|
switch (msg)
|
||||||
|
{
|
||||||
|
case WM_PAINT:
|
||||||
|
{
|
||||||
|
HDC hdc;
|
||||||
|
PAINTSTRUCT ps;
|
||||||
|
HPEN hPen, hOldPen;
|
||||||
|
HBRUSH hBrush, hOldBrush;
|
||||||
|
RECT rc;
|
||||||
|
|
||||||
|
hdc = BeginPaint(hwnd, &ps);
|
||||||
|
|
||||||
|
if (pCardBack->bSelected)
|
||||||
|
{
|
||||||
|
hPen = CreatePen(PS_SOLID, 2, RGB(0,0,0));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DWORD Face = GetSysColor(COLOR_3DFACE);
|
||||||
|
hPen = CreatePen(PS_SOLID, 2, Face);
|
||||||
|
}
|
||||||
|
|
||||||
|
GetClientRect(hwnd, &rc);
|
||||||
|
hBrush = (HBRUSH)GetStockObject(NULL_BRUSH);
|
||||||
|
hOldPen = (HPEN)SelectObject(hdc, hPen);
|
||||||
|
hOldBrush = (HBRUSH)SelectObject(hdc, hBrush);
|
||||||
|
|
||||||
|
Rectangle(hdc,
|
||||||
|
rc.left+1,
|
||||||
|
rc.top+1,
|
||||||
|
rc.right,
|
||||||
|
rc.bottom);
|
||||||
|
|
||||||
|
BitBlt(hdc,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
__cardwidth,
|
||||||
|
__cardheight,
|
||||||
|
__hdcCardBitmaps,
|
||||||
|
pCardBack->hdcNum * __cardwidth,
|
||||||
|
0,
|
||||||
|
SRCCOPY);
|
||||||
|
|
||||||
|
SelectObject(hdc, hOldPen);
|
||||||
|
SelectObject(hdc, hOldBrush);
|
||||||
|
|
||||||
|
EndPaint(hwnd, &ps);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WM_LBUTTONDOWN:
|
||||||
|
pCardBack->bSelected = pCardBack->bSelected ? FALSE : TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CallWindowProc(hOldProc,
|
||||||
|
hwnd,
|
||||||
|
msg,
|
||||||
|
wParam,
|
||||||
|
lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL CALLBACK CardBackDlgProc(HWND hDlg,
|
||||||
|
UINT uMsg,
|
||||||
|
WPARAM wParam,
|
||||||
|
LPARAM lParam)
|
||||||
|
{
|
||||||
|
static PCARDBACK pCardBacks = NULL;
|
||||||
|
|
||||||
|
switch (uMsg)
|
||||||
|
{
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
{
|
||||||
|
INT i, c;
|
||||||
|
SIZE_T size = sizeof(CARDBACK) * NUM_CARDBACKS;
|
||||||
|
|
||||||
|
pCardBacks = (PCARDBACK)HeapAlloc(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
size);
|
||||||
|
|
||||||
|
for (i = 0, c = CARDBACK_START; c <= CARDBACK_END; i++, c++)
|
||||||
|
{
|
||||||
|
pCardBacks[i].hSelf = GetDlgItem(hDlg, c);
|
||||||
|
pCardBacks[i].bSelected = FALSE;
|
||||||
|
pCardBacks[i].hdcNum = CARDBACK_RES_START + i;
|
||||||
|
pCardBacks[i].imgNum = i + 1;
|
||||||
|
pCardBacks[i].hOldProc = (WNDPROC)SetWindowLongPtr(pCardBacks[i].hSelf,
|
||||||
|
GWLP_WNDPROC,
|
||||||
|
(LONG_PTR)CardImageWndProc);
|
||||||
|
|
||||||
|
SetWindowLongPtr(pCardBacks[i].hSelf,
|
||||||
|
GWL_USERDATA,
|
||||||
|
(LONG_PTR)&pCardBacks[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WM_COMMAND:
|
||||||
|
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||||
|
{
|
||||||
|
INT i, num = 0;
|
||||||
|
for (i = 0; i < NUM_CARDBACKS; i++)
|
||||||
|
{
|
||||||
|
if (pCardBacks[i].bSelected)
|
||||||
|
{
|
||||||
|
num = pCardBacks[i].imgNum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EndDialog(hDlg, LOWORD(wParam) == IDOK ? num : FALSE);
|
||||||
|
HeapFree(GetProcessHeap(), 0, pCardBacks);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HIWORD(wParam) == STN_CLICKED)
|
||||||
|
{
|
||||||
|
INT i;
|
||||||
|
RECT rc;
|
||||||
|
for (i = 0; i < NUM_CARDBACKS; i++)
|
||||||
|
{
|
||||||
|
if (pCardBacks[i].hSelf == (HWND)lParam)
|
||||||
|
{
|
||||||
|
pCardBacks[i].bSelected = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pCardBacks[i].bSelected = FALSE;
|
||||||
|
|
||||||
|
GetClientRect(pCardBacks[i].hSelf, &rc);
|
||||||
|
InvalidateRect(pCardBacks[i].hSelf, &rc, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID ShowDeckOptionsDlg(HWND hwnd)
|
||||||
|
{
|
||||||
|
INT cardBack;
|
||||||
|
|
||||||
|
if ((cardBack = DialogBox(hInstance,
|
||||||
|
MAKEINTRESOURCE(IDD_CARDBACK),
|
||||||
|
hwnd,
|
||||||
|
CardBackDlgProc)))
|
||||||
|
{
|
||||||
|
SolWnd.SetBackCardIdx(CARDBACK_RES_START + (cardBack - 1));
|
||||||
|
SolWnd.Redraw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
@ -272,7 +470,7 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case IDM_GAME_DECK:
|
case IDM_GAME_DECK:
|
||||||
//ShowDeckOptionsDlg(hwnd);
|
ShowDeckOptionsDlg(hwnd);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case IDM_GAME_OPTIONS:
|
case IDM_GAME_OPTIONS:
|
||||||
|
|
|
@ -6,6 +6,10 @@ extern TCHAR szAppName[];
|
||||||
extern bool fGameStarted;
|
extern bool fGameStarted;
|
||||||
|
|
||||||
#define OPTION_THREE_CARDS 8
|
#define OPTION_THREE_CARDS 8
|
||||||
|
#define CARDBACK_START IDC_CARDBACK1
|
||||||
|
#define CARDBACK_END IDC_CARDBACK4
|
||||||
|
#define NUM_CARDBACKS (CARDBACK_END - CARDBACK_START + 1)
|
||||||
|
#define CARDBACK_RES_START 53
|
||||||
|
|
||||||
extern DWORD dwOptions;
|
extern DWORD dwOptions;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue