diff --git a/Assets/Scripts/Game/UserInterface/SkillsRollout.cs b/Assets/Scripts/Game/UserInterface/SkillsRollout.cs index 1b776a8846..fe57ae5f82 100644 --- a/Assets/Scripts/Game/UserInterface/SkillsRollout.cs +++ b/Assets/Scripts/Game/UserInterface/SkillsRollout.cs @@ -147,6 +147,11 @@ public void Reroll() } public void SetClassSkills(DFCareer dfClass) + { + SetClassSkills(dfClass, true); + } + + public void SetClassSkills(DFCareer dfClass, bool doReroll = true) { // Set primary, major, minor skills from class template primarySkills[0] = dfClass.PrimarySkill1; @@ -163,7 +168,8 @@ public void SetClassSkills(DFCareer dfClass) minorSkills[5] = dfClass.MinorSkill6; UpdateSkillLabels(); - Reroll(); + if (doReroll) + Reroll(); } #endregion diff --git a/Assets/Scripts/Game/UserInterfaceWindows/CreateCharAddBonusSkills.cs b/Assets/Scripts/Game/UserInterfaceWindows/CreateCharAddBonusSkills.cs index af3c13af7f..146e2ed34f 100644 --- a/Assets/Scripts/Game/UserInterfaceWindows/CreateCharAddBonusSkills.cs +++ b/Assets/Scripts/Game/UserInterfaceWindows/CreateCharAddBonusSkills.cs @@ -33,15 +33,8 @@ public class CreateCharAddBonusSkills : DaggerfallPopupWindow const int strYouMustDistributeYourBonusPoints = 14; Texture2D nativeTexture; - DFCareer dfClass; SkillsRollout skillsRollout; - public DFCareer DFClass - { - get { return dfClass; } - set { SetClass(value); } - } - public DaggerfallSkills StartingSkills { get { return skillsRollout.StartingSkills; } @@ -63,6 +56,23 @@ public CreateCharAddBonusSkills(IUserInterfaceManager uiManager) { } + public void SetCharacterDocument(CharacterDocument characterDocument, bool isRestored) + { + Setup(); + if (isRestored) // Restore points previously set by user. + { + skillsRollout.SetClassSkills(characterDocument.career, false); + skillsRollout.StartingSkills = characterDocument.startingSkills; + skillsRollout.WorkingSkills = characterDocument.workingSkills; + skillsRollout.SkillBonuses = BiogFile.GetSkillEffects(characterDocument.biographyEffects); + } + else + { + skillsRollout.SetClassSkills(characterDocument.career); + skillsRollout.SkillBonuses = BiogFile.GetSkillEffects(characterDocument.biographyEffects); + } + } + protected override void Setup() { if (IsSetup) @@ -98,17 +108,13 @@ public override void Draw() base.Draw(); } - #region Private Methods - - void SetClass(DFCareer dfClass) + public void SetBonusSkillPoints(int primary, int major, int minor) { - Setup(); - this.dfClass = dfClass; - skillsRollout.SetClassSkills(dfClass); + skillsRollout.PrimarySkillBonusPoints = primary; + skillsRollout.MajorSkillBonusPoints = major; + skillsRollout.MinorSkillBonusPoints = minor; } - #endregion - #region Event Handlers void OkButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) diff --git a/Assets/Scripts/Game/UserInterfaceWindows/CreateCharFaceSelect.cs b/Assets/Scripts/Game/UserInterfaceWindows/CreateCharFaceSelect.cs index 496f65b1ca..5bf73e6b60 100644 --- a/Assets/Scripts/Game/UserInterfaceWindows/CreateCharFaceSelect.cs +++ b/Assets/Scripts/Game/UserInterfaceWindows/CreateCharFaceSelect.cs @@ -64,6 +64,7 @@ protected override void Setup() public void SetFaceTextures(RaceTemplate raceTemplate, Genders raceGender) { + facePicker.FaceIndex = 0; facePicker.SetFaceTextures(raceTemplate, raceGender); } diff --git a/Assets/Scripts/Game/UserInterfaceWindows/CreateCharSummary.cs b/Assets/Scripts/Game/UserInterfaceWindows/CreateCharSummary.cs index 3765db7af6..6443bf0380 100644 --- a/Assets/Scripts/Game/UserInterfaceWindows/CreateCharSummary.cs +++ b/Assets/Scripts/Game/UserInterfaceWindows/CreateCharSummary.cs @@ -48,6 +48,13 @@ public CharacterDocument CharacterDocument set { SetCharacterSheet(value); } } + public DaggerfallSkills StartingSkills => skillsRollout.StartingSkills; + public DaggerfallSkills WorkingSkills => skillsRollout.WorkingSkills; + public DaggerfallStats StartingStats => statsRollout.StartingStats; + public DaggerfallStats WorkingStats => statsRollout.WorkingStats; + public Tuple BonusSkillPoints => new Tuple(skillsRollout.PrimarySkillBonusPoints, skillsRollout.MajorSkillBonusPoints, skillsRollout.MinorSkillBonusPoints); + public int FaceIndex => facePicker.FaceIndex; + public CreateCharSummary(IUserInterfaceManager uiManager) : base(uiManager) { diff --git a/Assets/Scripts/Game/UserInterfaceWindows/DaggerfallStartNewGameWizard.cs b/Assets/Scripts/Game/UserInterfaceWindows/DaggerfallStartNewGameWizard.cs index 114ef85ef5..8e9baabec0 100644 --- a/Assets/Scripts/Game/UserInterfaceWindows/DaggerfallStartNewGameWizard.cs +++ b/Assets/Scripts/Game/UserInterfaceWindows/DaggerfallStartNewGameWizard.cs @@ -53,6 +53,8 @@ public class StartNewGameWizard : DaggerfallBaseWindow CreateCharReflexSelect createCharReflexSelectWindow; CreateCharSummary createCharSummaryWindow; + bool skillsNeedReroll; + WizardStages WizardStage { get { return wizardStage; } @@ -179,6 +181,7 @@ void SetChooseBioWindow() createCharChooseBioWindow.OnClose += CreateCharChooseBioWindow_OnClose; wizardStage = WizardStages.SelectBiographyMethod; + skillsNeedReroll = true; uiManager.PushWindow(createCharChooseBioWindow); } @@ -248,16 +251,9 @@ void SetAddBonusSkillsWindow() { createCharAddBonusSkillsWindow = new CreateCharAddBonusSkills(uiManager); createCharAddBonusSkillsWindow.OnClose += AddBonusSkillsWindow_OnClose; - createCharAddBonusSkillsWindow.DFClass = characterDocument.career; - createCharAddBonusSkillsWindow.SkillBonuses = BiogFile.GetSkillEffects(characterDocument.biographyEffects); - } - - // Update class if player changes class selection - if (createCharAddBonusSkillsWindow.DFClass != characterDocument.career) - { - createCharAddBonusSkillsWindow.DFClass = characterDocument.career; } + createCharAddBonusSkillsWindow.SetCharacterDocument(characterDocument, !skillsNeedReroll); wizardStage = WizardStages.AddBonusSkills; uiManager.PushWindow(createCharAddBonusSkillsWindow); } @@ -514,8 +510,8 @@ void AddBonusStatsWindow_OnClose() { if (!createCharAddBonusStatsWindow.Cancelled) { - characterDocument.startingStats = createCharAddBonusStatsWindow.StartingStats; - characterDocument.workingStats = createCharAddBonusStatsWindow.WorkingStats; + characterDocument.startingStats.Copy(createCharAddBonusStatsWindow.StartingStats); + characterDocument.workingStats.Copy(createCharAddBonusStatsWindow.WorkingStats); SetAddBonusSkillsWindow(); } else @@ -528,12 +524,16 @@ void AddBonusSkillsWindow_OnClose() { if (!createCharAddBonusSkillsWindow.Cancelled) { - characterDocument.startingSkills = createCharAddBonusSkillsWindow.StartingSkills; - characterDocument.workingSkills = createCharAddBonusSkillsWindow.WorkingSkills; + characterDocument.startingSkills.Copy(createCharAddBonusSkillsWindow.StartingSkills); + characterDocument.workingSkills.Copy(createCharAddBonusSkillsWindow.WorkingSkills); SetSelectReflexesWindow(); + skillsNeedReroll = false; } else { + // Copy current stats to bonus stats window. + createCharAddBonusStatsWindow.StartingStats.Copy(characterDocument.startingStats); + createCharAddBonusStatsWindow.WorkingStats.Copy(characterDocument.workingStats); SetAddBonusStatsWindow(); } } @@ -565,6 +565,14 @@ void SummaryWindow_OnClose() } else { + // Copy skill and stat changes back to previous screens. + characterDocument.startingSkills.Copy(createCharSummaryWindow.StartingSkills); + characterDocument.workingSkills.Copy(createCharSummaryWindow.WorkingSkills); + characterDocument.startingStats.Copy(createCharSummaryWindow.StartingStats); + characterDocument.workingStats.Copy(createCharSummaryWindow.WorkingStats); + var bonusSkillPoints = createCharSummaryWindow.BonusSkillPoints; + createCharAddBonusSkillsWindow.SetBonusSkillPoints(bonusSkillPoints.Item1, bonusSkillPoints.Item2, bonusSkillPoints.Item3); + characterDocument.faceIndex = createCharSummaryWindow.FaceIndex; SetSelectReflexesWindow(); } }