浏览代码

- fullscreen config option will take effect immediately
- fixed bug with highlightable buttons
- added several missing spells sounds

Ivan Savenko 13 年之前
父节点
当前提交
2018fc09a4
共有 3 个文件被更改,包括 45 次插入15 次删除
  1. 23 12
      client/CMT.cpp
  2. 5 3
      client/UIFramework/CIntObjectClasses.cpp
  3. 17 0
      config/sp_sounds.json

+ 23 - 12
client/CMT.cpp

@@ -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;
 	}
 
-	if(screen) //screen has been already initialized
-		SDL_QuitSubSystem(SDL_INIT_VIDEO);
-
-	SDL_InitSubSystem(SDL_INIT_VIDEO);
+	//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;
 		}

+ 5 - 3
client/UIFramework/CIntObjectClasses.cpp

@@ -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())
-		select(!selected);
+		if(down == false && getState() == PRESSED)
+			select(!selected);
+		else
+			setState(selected?HIGHLIGHTED:NORMAL);
 	}
 }
 

+ 17 - 0
config/sp_sounds.json

@@ -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",