mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 10:31:16 +00:00
Move MFC supporting functions to minimfc (#77)
This commit is contained in:
parent
0e2ea5edc4
commit
d68142a8f2
@ -1,6 +1,7 @@
|
|||||||
#include "detectdx5.h"
|
#include "detectdx5.h"
|
||||||
|
|
||||||
#ifdef MINIWIN
|
#ifdef MINIWIN
|
||||||
|
#include "minimfc.h"
|
||||||
#include "miniwin_ddraw.h"
|
#include "miniwin_ddraw.h"
|
||||||
#include "miniwin_dinput.h"
|
#include "miniwin_dinput.h"
|
||||||
#else
|
#else
|
||||||
|
|||||||
@ -2,6 +2,85 @@
|
|||||||
|
|
||||||
#include "miniwin.h"
|
#include "miniwin.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// --- Defines and Macros ---
|
||||||
|
|
||||||
|
// Remove WinAPI stuff
|
||||||
|
#define BEGIN_MESSAGE_MAP(class_name, base_class_name)
|
||||||
|
#define DECLARE_MESSAGE_MAP()
|
||||||
|
#ifndef __cdecl
|
||||||
|
#define __cdecl
|
||||||
|
#endif
|
||||||
|
#define END_MESSAGE_MAP()
|
||||||
|
#define ON_COMMAND(id, func)
|
||||||
|
#define ON_LBN_SELCHANGE(id, func)
|
||||||
|
#define ON_WM_DESTROY()
|
||||||
|
#define ON_WM_PAINT()
|
||||||
|
#define ON_WM_QUERYDRAGICON()
|
||||||
|
#define ON_WM_SYSCOMMAND()
|
||||||
|
|
||||||
|
#define FAILED(hr) (((HRESULT) (hr)) < 0)
|
||||||
|
#define InterlockedIncrement(x) __sync_add_and_fetch(x, 1)
|
||||||
|
#define INVALID_HANDLE ((HANDLE) -1)
|
||||||
|
#define INVALID_HANDLE_VALUE ((HANDLE) -1)
|
||||||
|
#define HKEY_LOCAL_MACHINE ((HKEY) 0x80000002)
|
||||||
|
#define LOWORD(l) ((WORD) (((DWORD_PTR) (l)) & 0xffff))
|
||||||
|
#define MAKEINTRESOURCE(i) (reinterpret_cast<LPCTSTR>((ULONG_PTR) ((WORD) (i))))
|
||||||
|
|
||||||
|
#define ICON_BIG 1
|
||||||
|
#define ICON_SMALL 0
|
||||||
|
|
||||||
|
#define KEY_READ 0x20019
|
||||||
|
#define KEY_WRITE 0x20006
|
||||||
|
|
||||||
|
#define LB_ADDSTRING 0x180
|
||||||
|
#define LB_GETCURSEL 0x0188
|
||||||
|
#define LB_SETCURSEL 0x185
|
||||||
|
|
||||||
|
#define MF_SEPARATOR 0x80000000
|
||||||
|
#define MF_STRING 0x00000000
|
||||||
|
|
||||||
|
#define SM_CXICON 11
|
||||||
|
#define SM_CYICON 12
|
||||||
|
|
||||||
|
#define WM_ICONERASEBKGND 0x0027
|
||||||
|
#define WM_SETICON 0x804
|
||||||
|
|
||||||
|
#define ERROR_SUCCESS 0
|
||||||
|
#define GENERIC_READ 0x80000000L
|
||||||
|
#define OPEN_EXISTING 3
|
||||||
|
#define REG_SZ 1
|
||||||
|
#define RT_GROUP_ICON 0x00000007
|
||||||
|
#define SW_RESTORE 9
|
||||||
|
|
||||||
|
// --- Typedefs ---
|
||||||
|
typedef char CHAR;
|
||||||
|
typedef BYTE* LPBYTE;
|
||||||
|
typedef char* LPTSTR;
|
||||||
|
typedef const char* LPCTSTR;
|
||||||
|
typedef intptr_t INT_PTR, *PINT_PTR;
|
||||||
|
typedef uintptr_t UINT_PTR, *PUINT_PTR;
|
||||||
|
typedef intptr_t LONG_PTR, *PLONG_PTR;
|
||||||
|
typedef uintptr_t ULONG_PTR, *PULONG_PTR;
|
||||||
|
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
|
||||||
|
typedef UINT_PTR WPARAM;
|
||||||
|
typedef LONG_PTR LPARAM, LRESULT;
|
||||||
|
typedef HKEY* PHKEY;
|
||||||
|
typedef BITMAPINFO* LPBITMAPINFO;
|
||||||
|
typedef GUID REFIID;
|
||||||
|
|
||||||
|
// --- Structs ---
|
||||||
|
struct OSVERSIONINFOA {
|
||||||
|
DWORD dwOSVersionInfoSize;
|
||||||
|
DWORD dwMajorVersion;
|
||||||
|
DWORD dwBuildNumber;
|
||||||
|
DWORD dwPlatformId;
|
||||||
|
};
|
||||||
|
typedef struct IUnknown* LPUNKNOWN;
|
||||||
|
|
||||||
struct CWnd {
|
struct CWnd {
|
||||||
void* m_hWnd;
|
void* m_hWnd;
|
||||||
void EnableWindow(bool bEnable) {}
|
void EnableWindow(bool bEnable) {}
|
||||||
@ -56,10 +135,181 @@ struct CWinApp {
|
|||||||
virtual int ExitInstance();
|
virtual int ExitInstance();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MEMORYSTATUS {
|
||||||
|
DWORD dwLength;
|
||||||
|
DWORD dwTotalPhys;
|
||||||
|
};
|
||||||
|
|
||||||
struct CCommandLineInfo {
|
struct CCommandLineInfo {
|
||||||
virtual void ParseParam(LPCSTR pszParam, BOOL bFlag, BOOL bLast) {}
|
virtual void ParseParam(LPCSTR pszParam, BOOL bFlag, BOOL bLast) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// --- Classs ---
|
||||||
|
class CString {
|
||||||
|
public:
|
||||||
|
CString(const char* str = "") : m_str(str) {}
|
||||||
|
void LoadString(int str) {}
|
||||||
|
operator const char*() const { return m_str; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
const char* m_str;
|
||||||
|
};
|
||||||
|
|
||||||
|
// --- Functions ---
|
||||||
|
inline WINBOOL WINAPI SetForegroundWindow(HWND hWnd)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline BOOL ShowWindow(HWND hWnd, int nCmdShow)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline BOOL SetWindowPos(HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL GetWindowRect(HWND hDlg, struct RECT* Rect);
|
||||||
|
|
||||||
|
inline BOOL GetClientRect(LPRECT lpRect)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline BOOL IsIconic()
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int GetSystemMetrics(int nIndex)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline BOOL GetVersionEx(OSVERSIONINFOA* version)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalMemoryStatus(MEMORYSTATUS* memory_status);
|
||||||
|
|
||||||
|
inline BOOL DrawIcon(HDC hdc, int x, int y, HICON hIcon)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool AppendMenu(void* menu, UINT uFlags, UINT_PTR uIDNewItem, LPCTSTR lpszNewItem)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline LSTATUS RegOpenKeyEx(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
|
||||||
|
{
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline LSTATUS RegQueryValueEx(
|
||||||
|
HKEY hKey,
|
||||||
|
LPCSTR lpValueName,
|
||||||
|
LPDWORD lpReserved,
|
||||||
|
LPDWORD lpType,
|
||||||
|
BYTE* lpData,
|
||||||
|
LPDWORD lpcbData
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline LSTATUS RegCloseKey(HKEY hKey)
|
||||||
|
{
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline LSTATUS RegSetValueEx(
|
||||||
|
HKEY hKey,
|
||||||
|
LPCSTR lpValueName,
|
||||||
|
DWORD Reserved,
|
||||||
|
DWORD dwType,
|
||||||
|
const BYTE* lpData,
|
||||||
|
DWORD cbData
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline LSTATUS RegCreateKeyEx(
|
||||||
|
HKEY hKey,
|
||||||
|
LPCSTR lpSubKey,
|
||||||
|
DWORD Reserved,
|
||||||
|
const char* lpClass,
|
||||||
|
DWORD dwOptions,
|
||||||
|
REGSAM samDesired,
|
||||||
|
void* lpSecurityAttributes,
|
||||||
|
PHKEY phkResult,
|
||||||
|
LPDWORD lpdwDisposition
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputDebugString(const char* lpOutputString);
|
||||||
|
|
||||||
|
inline void* GetProcAddress(HMODULE module, const char* name)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int miniwin_stricmp(const char* str1, const char* str2);
|
||||||
|
#define _stricmp miniwin_stricmp
|
||||||
|
|
||||||
|
inline HICON LoadIcon(HINSTANCE hInstance, LPCSTR lpIconName)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int lstrcmpi(LPCSTR lpString1, LPCSTR lpString2)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline HINSTANCE AfxFindResourceHandle(LPCTSTR lpszResourceName, int lpszResourceType)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline HMODULE LoadLibrary(const char* name)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int FreeLibrary(void* hModule)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline HMENU GetSystemMenu(HWND hWnd, bool bRevert)
|
||||||
|
{
|
||||||
|
assert(false && "Needs implementation");
|
||||||
|
return reinterpret_cast<HMENU>(0x1234);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline HWND WINAPI FindWindow(LPCSTR lpClassName, LPCSTR lpWindowName)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline LRESULT SendMessage(UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline LRESULT SendMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
inline BOOL IsDlgButtonChecked(int nIDButton)
|
inline BOOL IsDlgButtonChecked(int nIDButton)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <SDL3/SDL_main.h>
|
#include <SDL3/SDL_main.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
char* afxCurrentAppName;
|
char* afxCurrentAppName;
|
||||||
AFX_MODULE_STATE g_CustomModuleState;
|
AFX_MODULE_STATE g_CustomModuleState;
|
||||||
@ -97,3 +98,57 @@ void AfxMessageBox(const char* message)
|
|||||||
{
|
{
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, message, NULL);
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, message, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::vector<std::pair<SDL_Window*, HWND>> sdl_hwnd_mapping;
|
||||||
|
|
||||||
|
SDL_Window* miniwin_GetSdlWindow(HWND hWnd)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < sdl_hwnd_mapping.size(); i++) {
|
||||||
|
if (sdl_hwnd_mapping[i].second == hWnd) {
|
||||||
|
return sdl_hwnd_mapping[i].first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL GetWindowRect(HWND hWnd, RECT* Rect)
|
||||||
|
{
|
||||||
|
int x, y, w, h;
|
||||||
|
if (!Rect) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
SDL_Window* window = miniwin_GetSdlWindow(hWnd);
|
||||||
|
if (window == NULL) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unregistered HWND %p", hWnd);
|
||||||
|
Rect->left = 0;
|
||||||
|
Rect->top = 0;
|
||||||
|
Rect->right = 640;
|
||||||
|
Rect->bottom = 480;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
SDL_GetWindowPosition(window, &x, &y);
|
||||||
|
SDL_GetWindowSize(window, &w, &h);
|
||||||
|
|
||||||
|
Rect->right = x;
|
||||||
|
Rect->top = y;
|
||||||
|
Rect->left = w + x;
|
||||||
|
Rect->bottom = h + y;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputDebugString(const char* lpOutputString)
|
||||||
|
{
|
||||||
|
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "%s", lpOutputString);
|
||||||
|
}
|
||||||
|
|
||||||
|
int miniwin_stricmp(const char* str1, const char* str2)
|
||||||
|
{
|
||||||
|
return SDL_strcasecmp(str1, str2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalMemoryStatus(MEMORYSTATUS* memory_status)
|
||||||
|
{
|
||||||
|
memory_status->dwLength = sizeof(*memory_status);
|
||||||
|
memory_status->dwTotalPhys = 1024 * SDL_GetSystemRAM();
|
||||||
|
}
|
||||||
|
|||||||
@ -1,16 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// --- Defines and Macros ---
|
// --- Defines and Macros ---
|
||||||
#define RASTERCAPS 0x00000000
|
|
||||||
#define RC_PALETTE 0x00000000
|
|
||||||
#define SIZEPALETTE 256
|
|
||||||
#define MAKE_HRESULT(sev, fac, code) \
|
#define MAKE_HRESULT(sev, fac, code) \
|
||||||
((HRESULT) (((uint32_t) (sev) << 31) | ((uint32_t) (fac) << 16) | ((uint32_t) (code))))
|
((HRESULT) (((uint32_t) (sev) << 31) | ((uint32_t) (fac) << 16) | ((uint32_t) (code))))
|
||||||
|
|
||||||
@ -19,31 +13,10 @@
|
|||||||
const GUID GuidName = {l, w1, w2, b1 + b2 + b3 + b4 + b5 + b6 + b7 + b8}
|
const GUID GuidName = {l, w1, w2, b1 + b2 + b3 + b4 + b5 + b6 + b7 + b8}
|
||||||
|
|
||||||
// Remove WinAPI stuff
|
// Remove WinAPI stuff
|
||||||
#define BEGIN_MESSAGE_MAP(class_name, base_class_name)
|
|
||||||
#define DECLARE_MESSAGE_MAP()
|
|
||||||
#define CALLBACK
|
#define CALLBACK
|
||||||
#ifndef __cdecl
|
|
||||||
#define __cdecl
|
|
||||||
#endif
|
|
||||||
#define FAR
|
#define FAR
|
||||||
#define END_MESSAGE_MAP()
|
|
||||||
#define ON_COMMAND(id, func)
|
|
||||||
#define ON_LBN_SELCHANGE(id, func)
|
|
||||||
#define ON_WM_DESTROY()
|
|
||||||
#define ON_WM_PAINT()
|
|
||||||
#define ON_WM_QUERYDRAGICON()
|
|
||||||
#define ON_WM_SYSCOMMAND()
|
|
||||||
#define WINAPI
|
#define WINAPI
|
||||||
|
|
||||||
#define FAILED(hr) (((HRESULT) (hr)) < 0)
|
|
||||||
#define InterlockedIncrement(x) __sync_add_and_fetch(x, 1)
|
|
||||||
#define INVALID_HANDLE ((HANDLE) -1)
|
|
||||||
#define INVALID_HANDLE_VALUE ((HANDLE) -1)
|
|
||||||
#define HKEY_LOCAL_MACHINE ((HKEY) 0x80000002)
|
|
||||||
#define GWL_STYLE (-16)
|
|
||||||
#define HWND_NOTOPMOST (HWND) - 2
|
#define HWND_NOTOPMOST (HWND) - 2
|
||||||
#define LOWORD(l) ((WORD) (((DWORD_PTR) (l)) & 0xffff))
|
|
||||||
#define MAKEINTRESOURCE(i) (reinterpret_cast<LPCTSTR>((ULONG_PTR) ((WORD) (i))))
|
|
||||||
#define RGB(r, g, b) ((r) | ((g) << 8) | ((b) << 16))
|
#define RGB(r, g, b) ((r) | ((g) << 8) | ((b) << 16))
|
||||||
#define S_OK ((HRESULT) 0)
|
#define S_OK ((HRESULT) 0)
|
||||||
#define E_NOINTERFACE (0x80004002)
|
#define E_NOINTERFACE (0x80004002)
|
||||||
@ -51,30 +24,12 @@
|
|||||||
#define TRUE 1
|
#define TRUE 1
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
|
|
||||||
#define ICON_BIG 1
|
|
||||||
#define ICON_SMALL 0
|
|
||||||
|
|
||||||
#define KEY_READ 0x20019
|
|
||||||
#define KEY_WRITE 0x20006
|
|
||||||
|
|
||||||
#define LB_ADDSTRING 0x180
|
|
||||||
#define LB_GETCURSEL 0x0188
|
|
||||||
#define LB_SETCURSEL 0x185
|
|
||||||
|
|
||||||
#define MF_SEPARATOR 0x80000000
|
|
||||||
#define MF_STRING 0x00000000
|
|
||||||
|
|
||||||
#define SM_CXICON 11
|
|
||||||
#define SM_CYICON 12
|
|
||||||
|
|
||||||
#define SWP_NOACTIVATE 0x0010
|
#define SWP_NOACTIVATE 0x0010
|
||||||
#define SWP_NOMOVE 0x0002
|
#define SWP_NOMOVE 0x0002
|
||||||
#define SWP_NOSIZE 0x0004
|
#define SWP_NOSIZE 0x0004
|
||||||
#define SWP_NOZORDER 0x0001
|
#define SWP_NOZORDER 0x0001
|
||||||
|
|
||||||
#define WM_CLOSE 0x0010
|
#define WM_CLOSE 0x0010
|
||||||
#define WM_ICONERASEBKGND 0x0027
|
|
||||||
#define WM_SETICON 0x804
|
|
||||||
#define WM_QUIT 0x0012
|
#define WM_QUIT 0x0012
|
||||||
#define WM_TIMER 0x0113
|
#define WM_TIMER 0x0113
|
||||||
|
|
||||||
@ -84,30 +39,27 @@
|
|||||||
#define WS_SYSMENU 0x00080000L
|
#define WS_SYSMENU 0x00080000L
|
||||||
#define WS_THICKFRAME 0x00040000L
|
#define WS_THICKFRAME 0x00040000L
|
||||||
|
|
||||||
|
#define GWL_STYLE (-16)
|
||||||
|
#define GWL_EXSTYLE -20
|
||||||
|
|
||||||
#define ANSI_CHARSET 0
|
#define ANSI_CHARSET 0
|
||||||
#define BI_RGB 0
|
#define BI_RGB 0
|
||||||
#define CLIP_DEFAULT_PRECIS 0
|
#define CLIP_DEFAULT_PRECIS 0
|
||||||
#define DEFAULT_QUALITY 0
|
#define DEFAULT_QUALITY 0
|
||||||
#define ERROR_SUCCESS 0
|
|
||||||
#define ETO_OPAQUE 0x0002
|
#define ETO_OPAQUE 0x0002
|
||||||
#define FF_DONTCARE 0x00000000
|
#define FF_DONTCARE 0x00000000
|
||||||
|
#define RASTERCAPS 0x00000000
|
||||||
|
#define RC_PALETTE 0x00000000
|
||||||
|
#define SIZEPALETTE 256
|
||||||
#define FW_NORMAL 400
|
#define FW_NORMAL 400
|
||||||
#define GENERIC_READ 0x80000000L
|
|
||||||
#define GWL_EXSTYLE -20
|
|
||||||
#define OPAQUE 2
|
#define OPAQUE 2
|
||||||
#define OPEN_EXISTING 3
|
|
||||||
#define OUT_DEFAULT_PRECIS 0
|
#define OUT_DEFAULT_PRECIS 0
|
||||||
#define RDW_FRAME 0x0400
|
#define RDW_FRAME 0x0400
|
||||||
#define REG_SZ 1
|
|
||||||
#define RT_GROUP_ICON 0x00000007
|
|
||||||
#define SRCCOPY 0x00CC0020
|
#define SRCCOPY 0x00CC0020
|
||||||
#define SW_RESTORE 9
|
|
||||||
#define VARIABLE_PITCH 2
|
#define VARIABLE_PITCH 2
|
||||||
|
|
||||||
// --- Typedefs ---
|
// --- Typedefs ---
|
||||||
typedef char CHAR;
|
|
||||||
typedef uint8_t BYTE, byte;
|
typedef uint8_t BYTE, byte;
|
||||||
typedef BYTE* LPBYTE;
|
|
||||||
typedef int32_t LONG;
|
typedef int32_t LONG;
|
||||||
typedef uint32_t ULONG, DWORD;
|
typedef uint32_t ULONG, DWORD;
|
||||||
typedef DWORD* LPDWORD;
|
typedef DWORD* LPDWORD;
|
||||||
@ -117,22 +69,12 @@ typedef unsigned short WORD;
|
|||||||
typedef long* LPLONG;
|
typedef long* LPLONG;
|
||||||
typedef void* LPVOID;
|
typedef void* LPVOID;
|
||||||
typedef char* LPSTR;
|
typedef char* LPSTR;
|
||||||
typedef char* LPTSTR;
|
|
||||||
typedef const char* LPCTSTR;
|
|
||||||
typedef const char* LPCSTR;
|
typedef const char* LPCSTR;
|
||||||
typedef intptr_t INT_PTR, *PINT_PTR;
|
|
||||||
typedef uintptr_t UINT_PTR, *PUINT_PTR;
|
|
||||||
typedef intptr_t LONG_PTR, *PLONG_PTR;
|
|
||||||
typedef uintptr_t ULONG_PTR, *PULONG_PTR;
|
|
||||||
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
|
|
||||||
typedef UINT_PTR WPARAM;
|
|
||||||
typedef LONG_PTR LPARAM, LRESULT;
|
|
||||||
typedef void* HANDLE;
|
typedef void* HANDLE;
|
||||||
typedef HANDLE HMENU, HICON, HFONT;
|
typedef HANDLE HMENU, HICON, HFONT;
|
||||||
typedef struct HINSTANCE__* HINSTANCE;
|
typedef struct HINSTANCE__* HINSTANCE;
|
||||||
typedef HANDLE HWND, HMODULE, HDC, HPALETTE, HFILE, HCURSOR;
|
typedef HANDLE HWND, HMODULE, HDC, HPALETTE, HFILE, HCURSOR;
|
||||||
typedef LONG HRESULT, LSTATUS, HKEY, REGSAM;
|
typedef LONG HRESULT, LSTATUS, HKEY, REGSAM;
|
||||||
typedef HKEY* PHKEY;
|
|
||||||
|
|
||||||
// --- Structs ---
|
// --- Structs ---
|
||||||
struct tagPOINT {
|
struct tagPOINT {
|
||||||
@ -146,14 +88,13 @@ struct SIZE {
|
|||||||
LONG cy;
|
LONG cy;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tagRECT {
|
struct RECT {
|
||||||
LONG left;
|
LONG left;
|
||||||
LONG top;
|
LONG top;
|
||||||
LONG right;
|
LONG right;
|
||||||
LONG bottom;
|
LONG bottom;
|
||||||
};
|
};
|
||||||
typedef tagRECT RECT;
|
typedef RECT* LPRECT;
|
||||||
typedef tagRECT* LPRECT;
|
|
||||||
|
|
||||||
struct BITMAPINFOHEADER {
|
struct BITMAPINFOHEADER {
|
||||||
DWORD biSize;
|
DWORD biSize;
|
||||||
@ -185,7 +126,6 @@ struct BITMAPINFO {
|
|||||||
BITMAPINFOHEADER bmiHeader;
|
BITMAPINFOHEADER bmiHeader;
|
||||||
RGBQUAD bmiColors[1];
|
RGBQUAD bmiColors[1];
|
||||||
};
|
};
|
||||||
typedef BITMAPINFO* LPBITMAPINFO;
|
|
||||||
|
|
||||||
struct PALETTEENTRY {
|
struct PALETTEENTRY {
|
||||||
BYTE peRed;
|
BYTE peRed;
|
||||||
@ -201,7 +141,6 @@ struct GUID {
|
|||||||
int m_data3;
|
int m_data3;
|
||||||
int m_data4;
|
int m_data4;
|
||||||
};
|
};
|
||||||
typedef GUID REFIID;
|
|
||||||
typedef GUID* LPGUID;
|
typedef GUID* LPGUID;
|
||||||
|
|
||||||
struct IUnknown {
|
struct IUnknown {
|
||||||
@ -214,8 +153,6 @@ struct IUnknown {
|
|||||||
private:
|
private:
|
||||||
int m_refCount;
|
int m_refCount;
|
||||||
};
|
};
|
||||||
typedef struct IUnknown* LPUNKNOWN;
|
|
||||||
|
|
||||||
struct LOGPALETTE {
|
struct LOGPALETTE {
|
||||||
WORD palVersion;
|
WORD palVersion;
|
||||||
WORD palNumEntries;
|
WORD palNumEntries;
|
||||||
@ -223,79 +160,16 @@ struct LOGPALETTE {
|
|||||||
};
|
};
|
||||||
typedef LOGPALETTE* LPLOGPALETTE;
|
typedef LOGPALETTE* LPLOGPALETTE;
|
||||||
|
|
||||||
struct MEMORYSTATUS {
|
|
||||||
DWORD dwLength;
|
|
||||||
DWORD dwTotalPhys;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct OSVERSIONINFOA {
|
|
||||||
DWORD dwOSVersionInfoSize;
|
|
||||||
DWORD dwMajorVersion;
|
|
||||||
DWORD dwBuildNumber;
|
|
||||||
DWORD dwPlatformId;
|
|
||||||
};
|
|
||||||
|
|
||||||
// --- Classs ---
|
|
||||||
class CString {
|
|
||||||
public:
|
|
||||||
CString(const char* str = "") : m_str(str) {}
|
|
||||||
void LoadString(int str) {}
|
|
||||||
operator const char*() const { return m_str; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
const char* m_str;
|
|
||||||
};
|
|
||||||
|
|
||||||
// --- Functions ---
|
|
||||||
inline WINBOOL WINAPI SetForegroundWindow(HWND hWnd)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BOOL ShowWindow(HWND hWnd, int nCmdShow)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BOOL SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
|
inline BOOL SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BOOL SetWindowPos(HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL GetWindowRect(HWND hDlg, struct tagRECT* Rect);
|
|
||||||
|
|
||||||
inline BOOL GetClientRect(LPRECT lpRect)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BOOL IsIconic()
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int GetSystemMetrics(int nIndex)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline UINT WINAPI GetSystemPaletteEntries(HDC hdc, UINT iStart, UINT cEntries, LPPALETTEENTRY pPalEntries)
|
inline UINT WINAPI GetSystemPaletteEntries(HDC hdc, UINT iStart, UINT cEntries, LPPALETTEENTRY pPalEntries)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BOOL GetVersionEx(OSVERSIONINFOA* version)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobalMemoryStatus(MEMORYSTATUS* memory_status);
|
|
||||||
|
|
||||||
inline HDC WINAPI GetDC(HWND hWnd)
|
inline HDC WINAPI GetDC(HWND hWnd)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@ -331,11 +205,6 @@ inline int SetTextColor(HDC hdc, int color)
|
|||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BOOL DrawIcon(HDC hdc, int x, int y, HICON hIcon)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline static BOOL GetTextExtentPoint(HDC hdc, LPCSTR lpString, int c, SIZE* psizl)
|
inline static BOOL GetTextExtentPoint(HDC hdc, LPCSTR lpString, int c, SIZE* psizl)
|
||||||
{
|
{
|
||||||
if (psizl) {
|
if (psizl) {
|
||||||
@ -380,11 +249,6 @@ inline int GetTextExtentPoint32(HDC hdc, LPCSTR str, int len, SIZE* out)
|
|||||||
return GetTextExtentPoint(hdc, str, len, out);
|
return GetTextExtentPoint(hdc, str, len, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool AppendMenu(void* menu, UINT uFlags, UINT_PTR uIDNewItem, LPCTSTR lpszNewItem)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline HMENU GetMenu(HWND hWnd)
|
inline HMENU GetMenu(HWND hWnd)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -395,62 +259,6 @@ inline int DrawMenuBar(void* hWnd)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline LSTATUS RegOpenKeyEx(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
|
|
||||||
{
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline LSTATUS RegQueryValueEx(
|
|
||||||
HKEY hKey,
|
|
||||||
LPCSTR lpValueName,
|
|
||||||
LPDWORD lpReserved,
|
|
||||||
LPDWORD lpType,
|
|
||||||
BYTE* lpData,
|
|
||||||
LPDWORD lpcbData
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline LSTATUS RegCloseKey(HKEY hKey)
|
|
||||||
{
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline LSTATUS RegSetValueEx(
|
|
||||||
HKEY hKey,
|
|
||||||
LPCSTR lpValueName,
|
|
||||||
DWORD Reserved,
|
|
||||||
DWORD dwType,
|
|
||||||
const BYTE* lpData,
|
|
||||||
DWORD cbData
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline LSTATUS RegCreateKeyEx(
|
|
||||||
HKEY hKey,
|
|
||||||
LPCSTR lpSubKey,
|
|
||||||
DWORD Reserved,
|
|
||||||
const char* lpClass,
|
|
||||||
DWORD dwOptions,
|
|
||||||
REGSAM samDesired,
|
|
||||||
void* lpSecurityAttributes,
|
|
||||||
PHKEY phkResult,
|
|
||||||
LPDWORD lpdwDisposition
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputDebugString(const char* lpOutputString);
|
|
||||||
|
|
||||||
inline void* GetProcAddress(HMODULE module, const char* name)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline static int StretchDIBits(
|
inline static int StretchDIBits(
|
||||||
void* hdc,
|
void* hdc,
|
||||||
int xDest,
|
int xDest,
|
||||||
@ -485,19 +293,11 @@ inline int DeleteObject(void*)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int miniwin_stricmp(const char* str1, const char* str2);
|
|
||||||
#define _stricmp miniwin_stricmp
|
|
||||||
|
|
||||||
inline BOOL AdjustWindowRectEx(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle)
|
inline BOOL AdjustWindowRectEx(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline HICON LoadIcon(HINSTANCE hInstance, LPCSTR lpIconName)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int SetRect(RECT* rc, int left, int top, int right, int bottom)
|
inline int SetRect(RECT* rc, int left, int top, int right, int bottom)
|
||||||
{
|
{
|
||||||
rc->left = left;
|
rc->left = left;
|
||||||
@ -507,49 +307,8 @@ inline int SetRect(RECT* rc, int left, int top, int right, int bottom)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int lstrcmpi(LPCSTR lpString1, LPCSTR lpString2)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline HINSTANCE AfxFindResourceHandle(LPCTSTR lpszResourceName, int lpszResourceType)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline HMODULE LoadLibrary(const char* name)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int FreeLibrary(void* hModule)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline HMENU GetSystemMenu(HWND hWnd, bool bRevert)
|
|
||||||
{
|
|
||||||
assert(false && "Needs implementation");
|
|
||||||
return reinterpret_cast<HMENU>(0x1234);
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID WINAPI Sleep(DWORD dwMilliseconds);
|
VOID WINAPI Sleep(DWORD dwMilliseconds);
|
||||||
|
|
||||||
inline HWND WINAPI FindWindow(LPCSTR lpClassName, LPCSTR lpWindowName)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline LRESULT SendMessage(UINT Msg, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline LRESULT SendMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline HPALETTE CreatePalette(LPLOGPALETTE lpLogPalette)
|
inline HPALETTE CreatePalette(LPLOGPALETTE lpLogPalette)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@ -25,61 +25,7 @@ HRESULT IUnknown::QueryInterface(const GUID& riid, void** ppvObject)
|
|||||||
return E_NOINTERFACE;
|
return E_NOINTERFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<std::pair<SDL_Window*, HWND>> sdl_hwnd_mapping;
|
|
||||||
|
|
||||||
SDL_Window* miniwin_GetSdlWindow(HWND hWnd)
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < sdl_hwnd_mapping.size(); i++) {
|
|
||||||
if (sdl_hwnd_mapping[i].second == hWnd) {
|
|
||||||
return sdl_hwnd_mapping[i].first;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputDebugString(const char* lpOutputString)
|
|
||||||
{
|
|
||||||
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "%s", lpOutputString);
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID WINAPI Sleep(DWORD dwMilliseconds)
|
VOID WINAPI Sleep(DWORD dwMilliseconds)
|
||||||
{
|
{
|
||||||
SDL_Delay(dwMilliseconds);
|
SDL_Delay(dwMilliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL GetWindowRect(HWND hWnd, tagRECT* Rect)
|
|
||||||
{
|
|
||||||
int x, y, w, h;
|
|
||||||
if (!Rect) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
SDL_Window* window = miniwin_GetSdlWindow(hWnd);
|
|
||||||
if (window == NULL) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unregistered HWND %p", hWnd);
|
|
||||||
Rect->left = 0;
|
|
||||||
Rect->top = 0;
|
|
||||||
Rect->right = 640;
|
|
||||||
Rect->bottom = 480;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
SDL_GetWindowPosition(window, &x, &y);
|
|
||||||
SDL_GetWindowSize(window, &w, &h);
|
|
||||||
|
|
||||||
Rect->right = x;
|
|
||||||
Rect->top = y;
|
|
||||||
Rect->left = w + x;
|
|
||||||
Rect->bottom = h + y;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int miniwin_stricmp(const char* str1, const char* str2)
|
|
||||||
{
|
|
||||||
return SDL_strcasecmp(str1, str2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlobalMemoryStatus(MEMORYSTATUS* memory_status)
|
|
||||||
{
|
|
||||||
memory_status->dwLength = sizeof(*memory_status);
|
|
||||||
memory_status->dwTotalPhys = 1024 * SDL_GetSystemRAM();
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user