1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

- fullscreen config option will take effect immediately

- fixed bug with highlightable buttons
- added several missing spells sounds
This commit is contained in:
Ivan Savenko 2012-02-24 20:41:14 +00:00
parent e7603a1fee
commit 2018fc09a4
3 changed files with 45 additions and 15 deletions

View File

@ -79,7 +79,7 @@ static bool setResolution = false; //set by event handling thread after resoluti
static bool ermInteractiveMode = false; //structurize when time is right
void processCommand(const std::string &message);
static void setScreenRes(int w, int h, int bpp, bool fullscreen);
static void setScreenRes(int w, int h, int bpp, bool fullscreen, bool resetVideo=true);
void dispose();
void playIntro();
static void listenForEvents();
@ -574,7 +574,7 @@ void dispose()
delete logfile;
}
static void setScreenRes(int w, int h, int bpp, bool fullscreen)
static void setScreenRes(int w, int h, int bpp, bool fullscreen, bool resetVideo)
{
// VCMI will only work with 2, 3 or 4 bytes per pixel
vstd::amax(bpp, 16);
@ -595,10 +595,13 @@ static void setScreenRes(int w, int h, int bpp, bool fullscreen)
tlog2 << "Warning: SDL says that " << bpp << "bpp is wrong and suggests " << suggestedBpp << std::endl;
}
//For some reason changing fullscreen via config window checkbox result in SDL_Quit event
if (resetVideo)
{
if(screen) //screen has been already initialized
SDL_QuitSubSystem(SDL_INIT_VIDEO);
SDL_InitSubSystem(SDL_INIT_VIDEO);
}
if((screen = SDL_SetVideoMode(w, h, suggestedBpp, SDL_SWSURFACE|(fullscreen?SDL_FULLSCREEN:0))) == NULL)
{
@ -643,8 +646,20 @@ static void setScreenRes(int w, int h, int bpp, bool fullscreen)
setResolution = true;
}
static void fullScreenChanged(const JsonNode &newState)
{
boost::unique_lock<boost::recursive_mutex> lock(*LOCPLINT->pim);
const JsonNode& video = settings["video"];
const JsonNode& res = video["screenRes"];
setScreenRes(res["width"].Float(), res["height"].Float(), video["bitsPerPixel"].Float(), newState.Bool(), false);
GH.totalRedraw();
}
static void listenForEvents()
{
SettingsListener resChanged = settings.listen["video"]["fullscreen"];
resChanged(fullScreenChanged);
while(1) //main SDL events loop
{
SDL_Event *ev = new SDL_Event();
@ -673,12 +688,8 @@ static void listenForEvents()
}
else if(LOCPLINT && ev->type == SDL_KEYDOWN && ev->key.keysym.sym==SDLK_F4)
{
boost::unique_lock<boost::recursive_mutex> lock(*LOCPLINT->pim);
bool full = !(screen->flags&SDL_FULLSCREEN);
const JsonNode& video = settings["video"];
const JsonNode& res = video["screenRes"];
setScreenRes(res["width"].Float(), res["height"].Float(), video["bitsPerPixel"].Float(), full);
GH.totalRedraw();
Settings full = settings.write["video"]["fullscreen"];
full->Bool() = !full->Bool();
delete ev;
continue;
}

View File

@ -426,10 +426,12 @@ void CHighlightableButton::clickLeft(tribool down, bool previousState)
setState(PRESSED);
}
if(previousState && down == false && getState() == PRESSED)
if(previousState)//mouse up
{
//if(!onlyOn || !isHighlighted())
if(down == false && getState() == PRESSED)
select(!selected);
else
setState(selected?HIGHLIGHTED:NORMAL);
}
}

View File

@ -74,11 +74,19 @@
"soundfile": "PROTECTE.wav",
"name": "protection from earth"
},
{
"id": 34,
"soundfile": "ANIMDEAD.wav",
},
{
"id": 35,
"soundfile": "DISPELL.wav",
"name": "dispell"
},
{
"id": 39,
"soundfile": "ANIMDEAD.wav",
},
{
"id": 41,
"soundfile": "BLESS.wav",
@ -159,11 +167,20 @@
"soundfile": "FRENZY.wav",
"name": "frenzy"
},
{
"id": 60,
"soundfile": "HYPNOTIZ.wav",
"name": "forgetfulness"
},
{
"id": 61,
"soundfile": "FORGET.wav",
"name": "forgetfulness"
},
{
"id": 62,
"soundfile": "BLIND.wav",
},
{
"id": 70,
"soundfile": "PARALYZE.wav",