1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00
Implemented #132 for Windows.
This commit is contained in:
Michał W. Urbańczyk 2009-11-28 17:21:54 +00:00
parent 0daac5f265
commit 4bfc161adc
2 changed files with 31 additions and 9 deletions

View File

@ -43,6 +43,7 @@
#include "../lib/VCMIDirs.h"
#include <cstdlib>
#include "../lib/NetPacks.h"
#include "SDL_syswm.h"
#if __MINGW32__
#undef main
@ -412,9 +413,6 @@ static void setScreenRes(int w, int h, int bpp, bool fullscreen)
SDL_QuitSubSystem(SDL_INIT_VIDEO);
SDL_InitSubSystem(SDL_INIT_VIDEO);
if((screen = SDL_SetVideoMode(w, h, suggestedBpp, SDL_SWSURFACE|(fullscreen?SDL_FULLSCREEN:0))) == NULL)
{
@ -431,6 +429,29 @@ static void setScreenRes(int w, int h, int bpp, bool fullscreen)
SDL_WM_SetCaption(NAME.c_str(),""); //set window title
SDL_ShowCursor(SDL_DISABLE);
#ifdef _WIN32
SDL_SysWMinfo wm;
SDL_VERSION(&wm.version);
int getwm = SDL_GetWMInfo(&wm);
if(getwm == 1)
{
int sw = GetSystemMetrics(SM_CXSCREEN),
sh = GetSystemMetrics(SM_CYSCREEN);
RECT curpos;
GetWindowRect(wm.window,&curpos);
int ourw = curpos.right - curpos.left,
ourh = curpos.bottom - curpos.top;
SetWindowPos(wm.window, 0, (sw - ourw)/2, (sh - ourh)/2, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
}
else
{
tlog3 << "Something went wrong, getwm=" << getwm << std::endl;
tlog3 << "SDL says: " << SDL_GetError() << std::endl;
tlog3 << "Window won't be centered.\n";
}
#endif
//TODO: centering game window on other platforms (or does the environment do their job correctly there?)
screenBuf = bufOnScreen ? screen : screen2;
}

View File

@ -126,16 +126,17 @@ void CGPreGame::run()
{
GH.handleEvents();
#ifdef _WIN32
CGI->videoh->open("ACREDIT.SMK");
#else
CGI->videoh->open("ACREDIT.SMK", true, false);
#endif
while(!terminate)
{
if (GH.listInt.size() == 0)
{
#ifdef _WIN32
CGI->videoh->open("ACREDIT.SMK");
#else
CGI->videoh->open("ACREDIT.SMK", true, false);
#endif
GH.pushInt(scrs[mainMenu]);
}
CGI->curh->draw1();
SDL_Flip(screen);