Laserlicht 3 ماه پیش
والد
کامیت
2894297b36
4فایلهای تغییر یافته به همراه17 افزوده شده و 6 حذف شده
  1. 13 3
      client/windows/GUIClasses.cpp
  2. 1 0
      client/windows/GUIClasses.h
  3. 2 2
      config/gameConfig.json
  4. 1 1
      lib/texts/TextLocalizationContainer.cpp

+ 13 - 3
client/windows/GUIClasses.cpp

@@ -412,6 +412,13 @@ CLevelWindow::CLevelWindow(const CGHeroInstance * hero, PrimarySkill pskill, std
 
 	GAME->interface()->showingDialog->setBusy();
 
+	sortedSkills = skills;
+	std::sort(sortedSkills.begin(), sortedSkills.end(), [hero](auto a, auto b) {
+		if(hero->getSecSkillLevel(a) == hero->getSecSkillLevel(b))
+			return LIBRARY->skillh->getById(a)->getNameTranslated() < LIBRARY->skillh->getById(b)->getNameTranslated();
+		return hero->getSecSkillLevel(a) > hero->getSecSkillLevel(b);
+	});
+
 	createSkillBox();
 	if(skills.size() > 3)
 	{
@@ -456,7 +463,7 @@ std::vector<SecondarySkill> getSkillsToShow(const std::vector<SecondarySkill>& s
 {
 	std::vector<SecondarySkill> result;
 
-	int size = (int)skills.size();
+	int size = skills.size();
 	if (size == 0 || count <= 0) return result;
 
 	offset = offset % size; // ensure offset is within bounds
@@ -473,7 +480,7 @@ void CLevelWindow::createSkillBox()
 {
 	OBJECT_CONSTRUCTION;
 
-	std::vector<SecondarySkill> skillsToShow = skills.size() > 3 ? getSkillsToShow(skills, skillViewOffset, 3) : skills;
+	std::vector<SecondarySkill> skillsToShow = skills.size() > 3 ? getSkillsToShow(sortedSkills, skillViewOffset, 3) : sortedSkills;
 	if(!skillsToShow.empty())
 	{
 		std::vector<std::shared_ptr<CSelectableComponent>> comps;
@@ -495,7 +502,10 @@ void CLevelWindow::close()
 {
 	//FIXME: call callback if there was nothing to select?
 	if (box && box->selectedIndex() != -1)
-		cb(box->selectedIndex() + skillViewOffset);
+	{
+		auto it = std::find(skills.begin(), skills.end(), sortedSkills[(box->selectedIndex() + skillViewOffset) % skills.size()]);
+		cb(std::distance(skills.begin(), it));
+	}
 
 	GAME->interface()->showingDialog->setFree();
 

+ 1 - 0
client/windows/GUIClasses.h

@@ -157,6 +157,7 @@ class CLevelWindow : public CWindowObject
 	std::shared_ptr<CButton> buttonRight;
 
 	std::vector<SecondarySkill> skills;
+	std::vector<SecondarySkill> sortedSkills;
 	const CGHeroInstance * hero;
 
 	void selectionChanged(unsigned to);

+ 2 - 2
config/gameConfig.json

@@ -520,9 +520,9 @@
 			"specialtyCreatureGrowth" : 5,
 
 			/// Amount of advanced or expert skills selectable (if any)
-			"skillSelectionAmountUpgr" : 9991,
+			"skillSelectionAmountUpgr" : 1,
 			/// Amount of basic skills selectable (if fewer advanced or expert skills than expected they will also filled up with basic skills)
-			"skillSelectionAmount" : 9991
+			"skillSelectionAmount" : 1
 		},
 
 		"towns":

+ 1 - 1
lib/texts/TextLocalizationContainer.cpp

@@ -112,7 +112,7 @@ void TextLocalizationContainer::registerString(const std::string & identifierMod
 	assert(!identifierModContext.empty());
 	assert(!localizedStringModContext.empty());
 	assert(UID.get().find("..") == std::string::npos); // invalid identifier - there is section that was evaluated to empty string
-	//assert(stringsLocalizations.count(UID.get()) == 0 || boost::algorithm::starts_with(UID.get(), "map") || boost::algorithm::starts_with(UID.get(), "header")); // registering already registered string? FIXME: "header" is a workaround. VMAP needs proper integration in translation system
+	assert(stringsLocalizations.count(UID.get()) == 0 || boost::algorithm::starts_with(UID.get(), "map") || boost::algorithm::starts_with(UID.get(), "header")); // registering already registered string? FIXME: "header" is a workaround. VMAP needs proper integration in translation system
 
 	if(stringsLocalizations.count(UID.get()) > 0)
 	{