Merge branch 'master' of github.com:project64/project64 into wx_3.0

This commit is contained in:
Julio C. Rocha 2015-11-11 00:30:23 -08:00
commit ea949c438d
6 changed files with 47 additions and 250 deletions

View File

@ -82,13 +82,12 @@ bool CFile::Open(const char * lpszFileName, uint32_t nOpenFlags)
ULONG dwCreateFlag = 0;
if (nOpenFlags & modeCreate)
{
if (nOpenFlags & modeNoTruncate)
dwCreateFlag = OPEN_ALWAYS;
else
dwCreateFlag = CREATE_ALWAYS;
dwCreateFlag = nOpenFlags & modeNoTruncate == 0 ? OPEN_ALWAYS : CREATE_ALWAYS;
}
else
{
dwCreateFlag = OPEN_EXISTING;
}
// attempt file creation
HANDLE hFile = ::CreateFile(lpszFileName, dwAccess, dwShareMode, &sa, dwCreateFlag, FILE_ATTRIBUTE_NORMAL, NULL);
@ -140,19 +139,15 @@ bool CFile::Flush()
return ::FlushFileBuffers(m_hFile) != 0;
}
bool CFile::Write(const void* lpBuf, size_t nCount)
bool CFile::Write(const void* lpBuf, uint32_t nCount)
{
if (nCount == 0)
{
return true; // avoid Win32 "null-write" option
}
if (nCount > ULONG_MAX)
{
nCount = ULONG_MAX; /* Or should we loop WriteFile() every 2 GB? */
}
DWORD nWritten = 0;
if (!::WriteFile(m_hFile, lpBuf, (DWORD)nCount, &nWritten, NULL))
ULONG nWritten = 0;
if (!::WriteFile(m_hFile, lpBuf, nCount, &nWritten, NULL))
{
return false;
}
@ -165,23 +160,19 @@ bool CFile::Write(const void* lpBuf, size_t nCount)
return true;
}
size_t CFile::Read(void* lpBuf, size_t nCount)
uint32_t CFile::Read(void* lpBuf, uint32_t nCount)
{
if (nCount == 0)
{
return 0; // avoid Win32 "null-read"
}
if (nCount > ULONG_MAX)
{
nCount = ULONG_MAX; /* Or should we loop ReadFile() every 2 GB? */
}
DWORD dwRead = 0;
if (!::ReadFile(m_hFile, lpBuf, (DWORD)nCount, &dwRead, NULL))
if (!::ReadFile(m_hFile, lpBuf, nCount, &dwRead, NULL))
{
return 0;
}
return (dwRead);
return (uint32_t)dwRead;
}
long CFile::Seek(long lOff, SeekPosition nFrom)

View File

@ -40,8 +40,8 @@ public:
virtual bool SetLength(uint32_t dwNewLen) = 0;
virtual uint32_t GetLength() const = 0;
virtual size_t Read(void* lpBuf, size_t nCount) = 0;
virtual bool Write(const void* lpBuf, size_t nCount) = 0;
virtual uint32_t Read(void* lpBuf, uint32_t nCount) = 0;
virtual bool Write(const void* lpBuf, uint32_t nCount) = 0;
virtual bool Flush() = 0;
virtual bool Close() = 0;
@ -78,8 +78,8 @@ public:
virtual bool SetLength(uint32_t dwNewLen);
virtual uint32_t GetLength() const;
virtual size_t Read(void* lpBuf, size_t nCount);
virtual bool Write(const void* lpBuf, size_t nCount);
virtual uint32_t Read(void* lpBuf, uint32_t nCount);
virtual bool Write(const void* lpBuf, uint32_t nCount);
virtual bool Flush();
virtual bool Close();

View File

@ -120,7 +120,7 @@ void CLog::LogArgs(const char * Message, va_list & args )
void CLog::Log( const char * Message )
{
if (!m_hLogFile.IsOpen()) { return; }
m_hLogFile.Write(Message, strlen(Message)*sizeof(TCHAR));
m_hLogFile.Write(Message,(uint32_t)strlen(Message)*sizeof(TCHAR));
if (m_FlushOnWrite)
{
m_hLogFile.Flush();
@ -145,13 +145,13 @@ void CLog::Log( const char * Message )
m_hLogFile.Seek((end - m_MaxFileSize) + m_FileChangeSize,CFile::begin);
// Find next end of line
size_t NextEnter = 0, dwRead = 0;
uint32_t NextEnter = 0, dwRead = 0;
do
{
BYTE Data[300];
size_t dwRead;
uint32_t dwRead;
dwRead = m_hLogFile.Read(Data, sizeof(Data));
dwRead = m_hLogFile.Read(Data,sizeof(Data));
if (dwRead == 0)
{
break;
@ -170,9 +170,8 @@ void CLog::Log( const char * Message )
} while(dwRead != 0);
// copy content of log to the new file
size_t ReadPos = (end - m_MaxFileSize) + m_FileChangeSize + NextEnter;
uint32_t WritePos = 0;
size_t SizeToRead;
uint32_t ReadPos = (end - m_MaxFileSize) + m_FileChangeSize + NextEnter;
uint32_t SizeToRead, WritePos = 0;
do
{
enum { fIS_MvSize = 0x5000 };
@ -183,8 +182,8 @@ void CLog::Log( const char * Message )
m_hLogFile.Seek(ReadPos,CFile::begin);
size_t dwRead;
dwRead = m_hLogFile.Read(Data, SizeToRead);
uint32_t dwRead;
dwRead = m_hLogFile.Read(Data,SizeToRead);
m_hLogFile.Seek(WritePos,CFile::begin);

View File

@ -15,8 +15,8 @@ class CLog
bool m_FlushOnWrite;
stdstr m_FileName;
bool m_TruncateFileLog;
size_t m_MaxFileSize;
size_t m_FileChangeSize;
uint32_t m_MaxFileSize;
uint32_t m_FileChangeSize;
public:
CLog ( void );
@ -29,10 +29,10 @@ public:
bool Empty ( void );
void Close ( void );
inline void SetMaxFileSize(size_t Size)
{
m_MaxFileSize = Size;
m_FileChangeSize = (size_t)(Size * 0.1);
inline void SetMaxFileSize ( uint32_t Size )
{
m_MaxFileSize = Size;
m_FileChangeSize = (uint32_t)(Size * 0.1);
}
inline void SetTruncateFile( bool Truncate ) { m_TruncateFileLog = Truncate; }
inline void SetFlush ( bool Always ) { m_FlushOnWrite = Always; }

View File

@ -20,130 +20,15 @@ void CLanguageSelector::Select ( void )
DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_Lang_Select),NULL,(DLGPROC)LangSelectProc, (LPARAM)this);
}
static WNDPROC pfnWndLangSelectOkProc = NULL;
static HBITMAP hOkButton = NULL;
DWORD CALLBACK LangSelectOkProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
{
static bool m_fPressed = false;
static HBITMAP hOkButtonDown = NULL;
switch (uMsg)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
if (BeginPaint(hWnd,&ps))
{
if (m_fPressed)
{
if (hOkButtonDown == NULL)
{
hOkButtonDown = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_LANG_OK_DOWN));
}
if (hOkButtonDown)
{
RECT rcClient;
GetClientRect(hWnd, &rcClient);
BITMAP bmTL1;
GetObject(hOkButtonDown, sizeof(BITMAP), &bmTL1);
HDC memdc = CreateCompatibleDC(ps.hdc);
HGDIOBJ save = SelectObject(memdc, hOkButtonDown);
BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY);
SelectObject(memdc, save);
DeleteDC(memdc);
}
}
else
{
if (hOkButton)
{
RECT rcClient;
GetClientRect(hWnd, &rcClient);
BITMAP bmTL1;
GetObject(hOkButton, sizeof(BITMAP), &bmTL1);
HDC memdc = CreateCompatibleDC(ps.hdc);
HGDIOBJ save = SelectObject(memdc, hOkButton);
BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY);
SelectObject(memdc, save);
DeleteDC(memdc);
}
}
EndPaint(hWnd,&ps);
}
}
break;
case WM_MOUSEMOVE:
if (::GetCapture() == hWnd)
{
POINT ptCursor = { ((int)(short)LOWORD(lParam)), ((int)(short)HIWORD(lParam)) };
ClientToScreen(hWnd, &ptCursor);
RECT rect;
GetWindowRect(hWnd, &rect);
bool uPressed = ::PtInRect(&rect, ptCursor)==TRUE;
if ( m_fPressed != uPressed )
{
m_fPressed = uPressed;
::InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);
}
}
break;
case WM_LBUTTONDOWN:
{
LRESULT lRet = 0;
lRet = DefWindowProc(hWnd, uMsg, wParam, lParam);
SetCapture(hWnd);
if ( ::GetCapture()==hWnd )
{
m_fPressed = true;
if (m_fPressed)
{
::InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);
}
}
return lRet;
}
break;
case WM_LBUTTONUP:
{
LRESULT lRet = 0;
lRet = DefWindowProc(hWnd, uMsg, wParam, lParam);
if ( ::GetCapture() == hWnd )
{
::ReleaseCapture();
if ( m_fPressed )
{
::SendMessage(GetParent(hWnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hWnd), BN_CLICKED), (LPARAM)hWnd);
}
}
m_fPressed = false;
return lRet;
}
break;
}
return CallWindowProc(pfnWndLangSelectOkProc, hWnd, uMsg, wParam, lParam);
}
LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static HBITMAP hbmpBackgroundTop = NULL;
static HBITMAP hbmpBackgroundBottom = NULL;
static HBITMAP hbmpBackgroundMiddle = NULL;
static HFONT hTextFont = NULL;
static CLanguageSelector * lngClass;
switch (uMsg)
{
case WM_INITDIALOG:
SetWindowPos(hDlg,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOREPOSITION|SWP_NOSIZE);
{
lngClass = (CLanguageSelector *)lParam;
@ -167,47 +52,11 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_SETCURSEL,0,0);
}
enum { ROUND_EDGE = 15 };
DWORD dwStyle = GetWindowLong(hDlg, GWL_STYLE);
dwStyle &= ~(WS_CAPTION|WS_SIZEBOX);
SetWindowLong(hDlg, GWL_STYLE, dwStyle);
// Use the size of the image
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_TOP));
hbmpBackgroundBottom = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_BOTTOM));
hbmpBackgroundMiddle = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_MIDDLE));
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_LOGO));
BITMAP bmTL;
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL);
if (hbmpBackgroundTop)
{
// int iHeight = bmTL.bmHeight;
int iWidth = bmTL.bmWidth;
RECT rect;
GetWindowRect(hDlg, &rect);
rect.left -= rect.left;
rect.bottom -= rect.top;
rect.top -= rect.top;
// Tweaked
HRGN hWindowRegion= CreateRoundRectRgn
(
rect.left,
rect.top,
rect.left+iWidth+GetSystemMetrics(SM_CXEDGE)-1,
rect.bottom+GetSystemMetrics(SM_CYEDGE)-1,
ROUND_EDGE,
ROUND_EDGE
);
if (hWindowRegion)
{
SetWindowRgn(hDlg, hWindowRegion, TRUE);
DeleteObject(hWindowRegion);
}
}
hTextFont = ::CreateFont
(
18,
@ -227,35 +76,6 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
);
SendDlgItemMessage(hDlg,IDC_SELECT_LANG,WM_SETFONT,(WPARAM)hTextFont,TRUE);
}
hOkButton = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_LANG_OK));
pfnWndLangSelectOkProc = (WNDPROC)::GetWindowLongPtr(GetDlgItem(hDlg,IDOK), GWLP_WNDPROC);
::SetWindowLongPtr(GetDlgItem(hDlg,IDOK), GWLP_WNDPROC,(LONG_PTR)LangSelectOkProc);
break;
case WM_NCHITTEST:
{
int xPos = LOWORD(lParam);
int yPos = HIWORD(lParam);
RECT client, a;
GetClientRect(hDlg,&a);
GetClientRect(hDlg,&client);
ClientToScreen(hDlg,(LPPOINT)&client);
client.right += client.left;
client.bottom += client.top;
int nCaption = GetSystemMetrics(SM_CYCAPTION)*4;
LRESULT lResult = HTCLIENT;
//check caption
if (xPos <= client.right && xPos >= client.left &&
(yPos >= client.top+ 0)&& (yPos <= client.top + 0+nCaption))
{
lResult = HTCAPTION;
}
SetWindowLong(hDlg, DWLP_MSGRESULT, lResult);
return TRUE;
}
break;
case WM_CTLCOLORSTATIC:
{
@ -265,6 +85,22 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH));
}
break;
case WM_ERASEBKGND:
{
HPEN outline;
HBRUSH fill;
RECT rect;
outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF);
fill = CreateSolidBrush(0x00FFFFFF);
SelectObject((HDC)wParam, outline);
SelectObject((HDC)wParam, fill);
GetClientRect(hDlg, &rect);
Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom);
}
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
@ -276,8 +112,6 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
BITMAP bmTL_top, bmTL_bottom, bmTL_Middle;
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top);
GetObject(hbmpBackgroundBottom, sizeof(BITMAP), &bmTL_bottom);
GetObject(hbmpBackgroundMiddle, sizeof(BITMAP), &bmTL_Middle);
HDC memdc = CreateCompatibleDC(ps.hdc);
HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop);
@ -285,25 +119,6 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
SelectObject(memdc, save);
DeleteDC(memdc);
memdc = CreateCompatibleDC(ps.hdc);
save = SelectObject(memdc, hbmpBackgroundMiddle);
for (int x = bmTL_top.bmHeight; x < rcClient.bottom; x += bmTL_Middle.bmHeight)
{
//BitBlt(ps.hdc, 0, bmTL_top.bmHeight, bmTL_Middle.bmWidth, rcClient.bottom - (bmTL_bottom.bmHeight + bmTL_top.bmHeight), memdc, 0, 0, SRCCOPY);
BitBlt(ps.hdc, 0, x, bmTL_Middle.bmWidth, bmTL_Middle.bmHeight, memdc, 0, 0, SRCCOPY);
}
SelectObject(memdc, save);
DeleteDC(memdc);
BITMAP ;
memdc = CreateCompatibleDC(ps.hdc);
save = SelectObject(memdc, hbmpBackgroundBottom);
BitBlt(ps.hdc, 0, rcClient.bottom - bmTL_bottom.bmHeight, bmTL_bottom.bmWidth, bmTL_bottom.bmHeight, memdc, 0, 0, SRCCOPY);
SelectObject(memdc, save);
DeleteDC(memdc);
BITMAP ;
EndPaint(hDlg,&ps);
}
}
@ -316,14 +131,6 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
{
DeleteObject(hbmpBackgroundTop);
}
if (hbmpBackgroundBottom)
{
DeleteObject(hbmpBackgroundBottom);
}
if (hbmpBackgroundMiddle)
{
DeleteObject(hbmpBackgroundMiddle);
}
if (hTextFont)
{

View File

@ -492,9 +492,9 @@ BEGIN
PUSHBUTTON "Close",IDCANCEL,154,110,50,14
END
IDD_Lang_Select DIALOGEX 0, 0, 237, 111
STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Welcome to"
IDD_Lang_Select DIALOGEX 0, 0, 233, 120
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION
CAPTION "Project64"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,90,99,50,12