Skip to content

Commit

Permalink
Merge pull request #840 from Interkarma/customclasscreator
Browse files Browse the repository at this point in the history
Merging customclasscreator to master
  • Loading branch information
Interkarma committed Aug 12, 2018
2 parents 905454b + f03080c commit cfaffc1
Show file tree
Hide file tree
Showing 10 changed files with 1,950 additions and 15 deletions.
25 changes: 23 additions & 2 deletions Assets/Scripts/Game/UserInterface/StatsRollout.cs
Expand Up @@ -48,6 +48,7 @@ public class StatsRollout : Panel
Panel[] statPanels = new Panel[DaggerfallStats.Count];
TextLabel[] statLabels = new TextLabel[DaggerfallStats.Count];
bool characterSheetPositioning = false;
bool freeEdit = false;

public DaggerfallStats StartingStats
{
Expand All @@ -67,11 +68,16 @@ public int BonusPool
set { SetStats(startingStats, workingStats, value); }
}

public StatsRollout(bool onCharacterSheet = false)
public StatsRollout(bool onCharacterSheet = false, bool freeEdit = false)
: base()
{
if (onCharacterSheet)
characterSheetPositioning = true;
if (freeEdit)
{
this.freeEdit = true;
modifiedStatTextColor = DaggerfallUI.DaggerfallDefaultTextColor;
}

// Add stat panels and labels
font = DaggerfallUI.DefaultFont;
Expand Down Expand Up @@ -217,6 +223,10 @@ void SelectStat(int index)
void StatButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
{
SelectStat((int)sender.Tag);
if (freeEdit)
{
DaggerfallUI.Instance.PlayOneShot(SoundClips.ButtonClick);
}
}

void Spinner_OnUpButtonClicked()
Expand All @@ -234,15 +244,22 @@ void Spinner_OnUpButtonClicked()
spinner.Value = bonusPool;
UpdateStatLabels();
RaiseOnStatChanged();
if (freeEdit)
{
DaggerfallUI.Instance.PlayOneShot(SoundClips.ButtonClick);
}
}

void Spinner_OnDownButtonClicked()
{
const int minFreeEditValue = 10;

// Get working stat value
int workingValue = workingStats.GetPermanentStatValue(selectedStat);

// Working value cannot reduce below starting value or minWorkingValue
if (workingValue == startingStats.GetPermanentStatValue(selectedStat) || workingValue == minWorkingValue)
if ((freeEdit && workingValue == minFreeEditValue) ||
(!freeEdit && (workingValue == startingStats.GetPermanentStatValue(selectedStat) || workingValue == minWorkingValue)))
return;

// Remove a point from working stat and assign to pool
Expand All @@ -251,6 +268,10 @@ void Spinner_OnDownButtonClicked()
spinner.Value = bonusPool;
UpdateStatLabels();
RaiseOnStatChanged();
if (freeEdit)
{
DaggerfallUI.Instance.PlayOneShot(SoundClips.ButtonClick);
}
}

#endregion
Expand Down
32 changes: 21 additions & 11 deletions Assets/Scripts/Game/UserInterfaceWindows/CreateCharClassSelect.cs
Expand Up @@ -57,25 +57,35 @@ protected override void Setup()
listBox.AddItem(classFile.Career.Name);
}
}
// Last option is for creating custom classes
listBox.AddItem("Custom");

OnItemPicked += DaggerfallClassSelectWindow_OnItemPicked;
}

void DaggerfallClassSelectWindow_OnItemPicked(int index, string className)
{
selectedClass = classList[index];
if (index == classList.Count) // "Custom" option selected
{
selectedClass = null;
CloseWindow();
}
else
{
selectedClass = classList[index];

TextFile.Token[] textTokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(startClassDescriptionID + index);
DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
messageBox.SetTextTokens(textTokens);
messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
Button noButton = messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
noButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick);
messageBox.OnButtonClick += ConfirmClassPopup_OnButtonClick;
uiManager.PushWindow(messageBox);
TextFile.Token[] textTokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(startClassDescriptionID + index);
DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
messageBox.SetTextTokens(textTokens);
messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
Button noButton = messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
noButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick);
messageBox.OnButtonClick += ConfirmClassPopup_OnButtonClick;
uiManager.PushWindow(messageBox);

AudioClip clip = DaggerfallUnity.Instance.SoundReader.GetAudioClip(SoundClips.SelectClassDrums);
DaggerfallUI.Instance.AudioSource.PlayOneShot(clip);
AudioClip clip = DaggerfallUnity.Instance.SoundReader.GetAudioClip(SoundClips.SelectClassDrums);
DaggerfallUI.Instance.AudioSource.PlayOneShot(clip);
}
}

void ConfirmClassPopup_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
Expand Down

0 comments on commit cfaffc1

Please sign in to comment.