|
|
@ -36,14 +36,16 @@ struct Win32PlatformPrivate {
|
|
|
|
HDC hdc;
|
|
|
|
HDC hdc;
|
|
|
|
HGLRC hrc;
|
|
|
|
HGLRC hrc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char *appName;
|
|
|
|
int x, y;
|
|
|
|
int x, y;
|
|
|
|
int width, height;
|
|
|
|
int width, height;
|
|
|
|
int minWidth, minHeight;
|
|
|
|
int minWidth, minHeight;
|
|
|
|
bool maximized;
|
|
|
|
bool maximized;
|
|
|
|
} win32;
|
|
|
|
} win32;
|
|
|
|
|
|
|
|
|
|
|
|
void Platform::init()
|
|
|
|
void Platform::init(const char *appName)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
win32.appName = appName;
|
|
|
|
win32.instance = GetModuleHandle(NULL);
|
|
|
|
win32.instance = GetModuleHandle(NULL);
|
|
|
|
|
|
|
|
|
|
|
|
WNDCLASSA wc;
|
|
|
|
WNDCLASSA wc;
|
|
|
@ -56,7 +58,7 @@ void Platform::init()
|
|
|
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer
|
|
|
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer
|
|
|
|
wc.hbrBackground = NULL; // No Background Required For GL
|
|
|
|
wc.hbrBackground = NULL; // No Background Required For GL
|
|
|
|
wc.lpszMenuName = NULL; // We Don't Want A Menu
|
|
|
|
wc.lpszMenuName = NULL; // We Don't Want A Menu
|
|
|
|
wc.lpszClassName = "OTClient"; // Set The Class Name
|
|
|
|
wc.lpszClassName = win32.appName; // Set The Class Name
|
|
|
|
|
|
|
|
|
|
|
|
if(!RegisterClassA(&wc))
|
|
|
|
if(!RegisterClassA(&wc))
|
|
|
|
fatal("Failed to register the window class.");
|
|
|
|
fatal("Failed to register the window class.");
|
|
|
@ -70,7 +72,7 @@ void Platform::terminate()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(win32.instance) {
|
|
|
|
if(win32.instance) {
|
|
|
|
if(!UnregisterClassA("OTClient", win32.instance))
|
|
|
|
if(!UnregisterClassA(win32.appName, win32.instance))
|
|
|
|
error("Unregister class failed.");
|
|
|
|
error("Unregister class failed.");
|
|
|
|
|
|
|
|
|
|
|
|
win32.instance = NULL;
|
|
|
|
win32.instance = NULL;
|
|
|
@ -112,15 +114,15 @@ bool Platform::createWindow(int x, int y, int width, int height, int minWidth, i
|
|
|
|
//AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle);
|
|
|
|
//AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle);
|
|
|
|
|
|
|
|
|
|
|
|
win32.window = CreateWindowExA(dwExStyle, // Extended Style For The Window
|
|
|
|
win32.window = CreateWindowExA(dwExStyle, // Extended Style For The Window
|
|
|
|
"OTClient", // Class Name
|
|
|
|
win32.appName, // Class Name
|
|
|
|
"OTClient", // Window Title
|
|
|
|
win32.appName, // Window Title
|
|
|
|
dwStyle, // Required Window Style
|
|
|
|
dwStyle, // Required Window Style
|
|
|
|
x, // Window X Position
|
|
|
|
x, // Window X Position
|
|
|
|
y, // Window Y Position
|
|
|
|
y, // Window Y Position
|
|
|
|
width, // Calculate Window Width
|
|
|
|
width, // Calculate Window Width
|
|
|
|
height, // Calculate Window Height
|
|
|
|
height, // Calculate Window Height
|
|
|
|
NULL, // No Parent Window
|
|
|
|
NULL, // No Parent Window
|
|
|
|
NULL, // No Menu
|
|
|
|
NULL, // No Menu
|
|
|
|
win32.instance, // Instance
|
|
|
|
win32.instance, // Instance
|
|
|
|
NULL);
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
|
@ -294,10 +296,10 @@ bool Platform::isWindowMaximized()
|
|
|
|
return win32.maximized;
|
|
|
|
return win32.maximized;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char *Platform::getAppUserDir(const char *appName)
|
|
|
|
const char *Platform::getAppUserDir()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::stringstream sdir;
|
|
|
|
std::stringstream sdir;
|
|
|
|
sdir << PHYSFS_getUserDir() << "/." << appName << "/";
|
|
|
|
sdir << PHYSFS_getUserDir() << "/." << win32.appName << "/";
|
|
|
|
if((mkdir(sdir.str().c_str()) != 0) && (errno != EEXIST))
|
|
|
|
if((mkdir(sdir.str().c_str()) != 0) && (errno != EEXIST))
|
|
|
|
error("Couldn't create directory for saving configuration file. (%s)", sdir.str().c_str());
|
|
|
|
error("Couldn't create directory for saving configuration file. (%s)", sdir.str().c_str());
|
|
|
|
return sdir.str().c_str();
|
|
|
|
return sdir.str().c_str();
|
|
|
|