瀏覽代碼

Threat level texts are now stored in separate config file.

DjWarmonger 14 年之前
父節點
當前提交
f96b394b01
共有 4 個文件被更改,包括 41 次插入13 次删除
  1. 14 0
      config/threatlevel.txt
  2. 9 0
      lib/CGeneralTextHandler.cpp
  3. 1 0
      lib/CGeneralTextHandler.h
  4. 17 13
      lib/CObjectHandler.cpp

+ 14 - 0
config/threatlevel.txt

@@ -0,0 +1,14 @@
+
+Threat: 
+Effortless
+Very Weak
+Weak
+A bit weaker
+Equal
+A bit stronger
+Strong
+Very Strong
+Challenging
+Overpowering
+Deadly
+Impossible

+ 9 - 0
lib/CGeneralTextHandler.cpp

@@ -533,6 +533,15 @@ void CGeneralTextHandler::load()
 			}
 		} while (nameBuf.size());
 	}
+
+	std::ifstream ifs(DATA_DIR "/config/threatlevel.txt", std::ios::in | std::ios::binary);
+	getline(ifs, buf); //skip 1st line
+	for (int i = 0; i < 13; ++i)
+	{
+		getline(ifs, buf);
+		threat.push_back(buf);
+		tlog1 << buf << "\n";
+	}
 }
 
 

+ 1 - 0
lib/CGeneralTextHandler.h

@@ -68,6 +68,7 @@ public:
 	std::vector <std::vector <std::vector <std::string> > >  quests; //[quest][type][index]
 	//type: quest, progress, complete, rollover, log OR time limit //index: 0-2 seer hut, 3-5 border guard
 	std::vector<std::string> seerNames;
+	std::vector<std::string> threat; //power rating for neutral stacks
 
 	//sec skills
 	std::vector <std::string>  skillName;

+ 17 - 13
lib/CObjectHandler.cpp

@@ -2825,20 +2825,24 @@ const std::string & CGCreature::getHoverText() const
 
 	if(const CGHeroInstance *selHero = cb->getSelectedHero(cb->getCurrentPlayer()))
 	{
-		hoverName += "\n\n Threat: ";
+		std::vector<std::string> * texts = &VLC->generaltexth->threat;
+		hoverName += "\n\n ";
+		hoverName += (*texts)[0];
+		int choice;
 		float ratio = ((float)getArmyStrength() / selHero->getTotalStrength());
-		if (ratio < 0.1) hoverName += "Effortless";
-		else if (ratio < 0.25) hoverName += "Very Weak";
-		else if (ratio < 0.6) hoverName += "Weak";
-		else if (ratio < 0.9) hoverName += "A bit weaker";
-		else if (ratio < 1.1) hoverName += "Equal";
-		else if (ratio < 1.3) hoverName += "A bit stronger";
-		else if (ratio < 1.8) hoverName += "Strong";
-		else if (ratio < 2.5) hoverName += "Very Strong";
-		else if (ratio < 4) hoverName += "Challenging";
-		else if (ratio < 8) hoverName += "Overpowering";
-		else if (ratio < 20) hoverName += "Deadly";
-		else hoverName += "Impossible";
+		if (ratio < 0.1) choice = 1;
+		else if (ratio < 0.25) choice = 2;
+		else if (ratio < 0.6) choice = 3;
+		else if (ratio < 0.9) choice = 4;
+		else if (ratio < 1.1) choice = 5;
+		else if (ratio < 1.3) choice = 6;
+		else if (ratio < 1.8) choice = 7;
+		else if (ratio < 2.5) choice = 8;
+		else if (ratio < 4) choice = 9;
+		else if (ratio < 8) choice = 10;
+		else if (ratio < 20) choice = 11;
+		else choice = 12;
+		hoverName += (*texts)[choice];
 	}
 	return hoverName;
 }