mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-26 14:56:39 +00:00 
			
		
		
		
	Issue #297: Make the stats review dialog show correct values for attributes/skills/health/magicka/fatigue
This commit is contained in:
		
							parent
							
								
									6014a90002
								
							
						
					
					
						commit
						e1ee45a6d6
					
				
					 7 changed files with 81 additions and 13 deletions
				
			
		|  | @ -122,6 +122,56 @@ CharacterCreation::CharacterCreation(WindowManager* _wm) | |||
|     mCreationStage = CSE_NotStarted; | ||||
| } | ||||
| 
 | ||||
| void CharacterCreation::setValue (const std::string& id, const MWMechanics::Stat<int>& value) | ||||
| { | ||||
|     if (mReviewDialog) | ||||
|     { | ||||
|        static const char *ids[] = | ||||
|         { | ||||
|             "AttribVal1", "AttribVal2", "AttribVal3", "AttribVal4", "AttribVal5", | ||||
|             "AttribVal6", "AttribVal7", "AttribVal8", | ||||
|             0 | ||||
|         }; | ||||
| 
 | ||||
|         for (int i=0; ids[i]; ++i) | ||||
|         { | ||||
|             if (ids[i]==id) | ||||
|                 mReviewDialog->setAttribute(ESM::Attribute::AttributeID(i), value); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void CharacterCreation::setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value) | ||||
| { | ||||
|     if (mReviewDialog) | ||||
|     { | ||||
|         if (id == "HBar") | ||||
|         { | ||||
|             mReviewDialog->setHealth (value); | ||||
|         } | ||||
|         else if (id == "MBar") | ||||
|         { | ||||
|             mReviewDialog->setMagicka (value); | ||||
|         } | ||||
|         else if (id == "FBar") | ||||
|         { | ||||
|             mReviewDialog->setFatigue (value); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void CharacterCreation::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value) | ||||
| { | ||||
|     if (mReviewDialog) | ||||
|         mReviewDialog->setSkillValue(parSkill, value); | ||||
| } | ||||
| 
 | ||||
| void CharacterCreation::configureSkills (const SkillList& major, const SkillList& minor) | ||||
| { | ||||
|     if (mReviewDialog) | ||||
|         mReviewDialog->configureSkills(major, minor); | ||||
| } | ||||
| 
 | ||||
| void CharacterCreation::spawnDialog(const char id) | ||||
| { | ||||
|     switch (id) | ||||
|  | @ -208,20 +258,22 @@ void CharacterCreation::spawnDialog(const char id) | |||
|             mReviewDialog->setFatigue(mPlayerFatigue); | ||||
| 
 | ||||
|             { | ||||
|                 std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> >::iterator end = mPlayerAttributes.end(); | ||||
|                 for (std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> >::iterator it = mPlayerAttributes.begin(); it != end; ++it) | ||||
|                 std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > attributes = mWM->getPlayerAttributeValues(); | ||||
|                 for (std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> >::iterator it = attributes.begin(); | ||||
|                     it != attributes.end(); ++it) | ||||
|                 { | ||||
|                     mReviewDialog->setAttribute(it->first, it->second); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             { | ||||
|                 std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> >::iterator end = mPlayerSkillValues.end(); | ||||
|                 for (std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> >::iterator it = mPlayerSkillValues.begin(); it != end; ++it) | ||||
|                 std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > skills = mWM->getPlayerSkillValues(); | ||||
|                 for (std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> >::iterator it = skills.begin(); | ||||
|                     it != skills.end(); ++it) | ||||
|                 { | ||||
|                     mReviewDialog->setSkillValue(it->first, it->second); | ||||
|                 } | ||||
|                 mReviewDialog->configureSkills(mPlayerMajorSkills, mPlayerMinorSkills); | ||||
|                 mReviewDialog->configureSkills(mWM->getPlayerMajorSkills(), mWM->getPlayerMinorSkills()); | ||||
|             } | ||||
| 
 | ||||
|             mReviewDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone); | ||||
|  |  | |||
|  | @ -42,6 +42,11 @@ namespace MWGui | |||
| 
 | ||||
|     void setPlayerFatigue (const MWMechanics::DynamicStat<int>& value); | ||||
| 
 | ||||
|     void setValue (const std::string& id, const MWMechanics::Stat<int>& value); | ||||
|     void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value); | ||||
|     void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value); | ||||
|     void configureSkills (const SkillList& major, const SkillList& minor); | ||||
| 
 | ||||
|     private: | ||||
|     //Dialogs
 | ||||
|     TextInputDialog* mNameDialog; | ||||
|  | @ -61,9 +66,6 @@ namespace MWGui | |||
|     std::string mPlayerRaceId; | ||||
|     std::string mPlayerBirthSignId; | ||||
|     ESM::Class mPlayerClass; | ||||
|     std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > mPlayerAttributes; | ||||
|     SkillList mPlayerMajorSkills, mPlayerMinorSkills; | ||||
|     std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > mPlayerSkillValues; | ||||
|     MWMechanics::DynamicStat<int> mPlayerHealth; | ||||
|     MWMechanics::DynamicStat<int> mPlayerMagicka; | ||||
|     MWMechanics::DynamicStat<int> mPlayerFatigue; | ||||
|  |  | |||
|  | @ -241,10 +241,10 @@ void PickClassDialog::updateStats() | |||
| 
 | ||||
|     for (int i = 0; i < 5; ++i) | ||||
|     { | ||||
|         majorSkill[i]->setSkillNumber(klass->data.skills[i][0]); | ||||
|         minorSkill[i]->setSkillNumber(klass->data.skills[i][1]); | ||||
|         ToolTips::createSkillToolTip(majorSkill[i], klass->data.skills[i][0]); | ||||
|         ToolTips::createSkillToolTip(minorSkill[i], klass->data.skills[i][1]); | ||||
|         minorSkill[i]->setSkillNumber(klass->data.skills[i][0]); | ||||
|         majorSkill[i]->setSkillNumber(klass->data.skills[i][1]); | ||||
|         ToolTips::createSkillToolTip(minorSkill[i], klass->data.skills[i][0]); | ||||
|         ToolTips::createSkillToolTip(majorSkill[i], klass->data.skills[i][1]); | ||||
|     } | ||||
| 
 | ||||
|     classImage->setImageTexture(std::string("textures\\levelup\\") + currentClassId + ".dds"); | ||||
|  | @ -518,7 +518,7 @@ std::vector<ESM::Skill::SkillEnum> CreateClassDialog::getMinorSkills() const | |||
|     std::vector<ESM::Skill::SkillEnum> v; | ||||
|     for(int i=0; i < 5; i++) | ||||
|     { | ||||
|         v.push_back(majorSkill[i]->getSkillId()); | ||||
|         v.push_back(minorSkill[i]->getSkillId()); | ||||
|     } | ||||
|     return v; | ||||
| } | ||||
|  |  | |||
|  | @ -211,6 +211,7 @@ void ReviewDialog::setSkillValue(ESM::Skill::SkillEnum skillId, const MWMechanic | |||
|         widget->setCaption(text); | ||||
|         widget->_setWidgetState(state); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void ReviewDialog::configureSkills(const std::vector<int>& major, const std::vector<int>& minor) | ||||
|  | @ -230,6 +231,8 @@ void ReviewDialog::configureSkills(const std::vector<int>& major, const std::vec | |||
|         if (skillSet.find(skill) == skillSet.end()) | ||||
|             miscSkills.push_back(skill); | ||||
|     } | ||||
| 
 | ||||
|     updateSkillArea(); | ||||
| } | ||||
| 
 | ||||
| void ReviewDialog::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) | ||||
|  |  | |||
|  | @ -255,6 +255,8 @@ void StatsWindow::configureSkills (const std::vector<int>& major, const std::vec | |||
|         if (skillSet.find(skill) == skillSet.end()) | ||||
|             miscSkills.push_back(skill); | ||||
|     } | ||||
| 
 | ||||
|     updateSkillArea(); | ||||
| } | ||||
| 
 | ||||
| void StatsWindow::onFrame () | ||||
|  |  | |||
|  | @ -302,6 +302,7 @@ void WindowManager::updateVisible() | |||
| void WindowManager::setValue (const std::string& id, const MWMechanics::Stat<int>& value) | ||||
| { | ||||
|     mStatsWindow->setValue (id, value); | ||||
|     mCharGen->setValue(id, value); | ||||
| 
 | ||||
|     static const char *ids[] = | ||||
|     { | ||||
|  | @ -332,6 +333,7 @@ void WindowManager::setValue (const std::string& id, const MWMechanics::Stat<int | |||
| void WindowManager::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value) | ||||
| { | ||||
|     mStatsWindow->setValue(parSkill, value); | ||||
|     mCharGen->setValue(parSkill, value); | ||||
|     playerSkillValues[parSkill] = value; | ||||
| } | ||||
| 
 | ||||
|  | @ -339,6 +341,7 @@ void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicS | |||
| { | ||||
|     mStatsWindow->setValue (id, value); | ||||
|     hud->setValue (id, value); | ||||
|     mCharGen->setValue(id, value); | ||||
|     if (id == "HBar") | ||||
|     { | ||||
|         playerHealth = value; | ||||
|  | @ -391,6 +394,7 @@ void WindowManager::setPlayerClass (const ESM::Class &class_) | |||
| void WindowManager::configureSkills (const SkillList& major, const SkillList& minor) | ||||
| { | ||||
|     mStatsWindow->configureSkills (major, minor); | ||||
|     mCharGen->configureSkills(major, minor); | ||||
|     playerMajorSkills = major; | ||||
|     playerMinorSkills = minor; | ||||
| } | ||||
|  |  | |||
|  | @ -211,6 +211,11 @@ namespace MWGui | |||
| 
 | ||||
|     void onFrame (float frameDuration); | ||||
| 
 | ||||
|     std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > getPlayerSkillValues() { return playerSkillValues; } | ||||
|     std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > getPlayerAttributeValues() { return playerAttributes; } | ||||
|     SkillList getPlayerMinorSkills() { return playerMinorSkills; } | ||||
|     SkillList getPlayerMajorSkills() { return playerMajorSkills; } | ||||
| 
 | ||||
|     /**
 | ||||
|      * Fetches a GMST string from the store, if there is no setting with the given | ||||
|      * ID or it is not a string the default string is returned. | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue