Skip to content

Commit e132349

Browse files
committed
Finished AdvancedAppearanceDialog.
1 parent bc302b9 commit e132349

File tree

4 files changed

+69
-20
lines changed

4 files changed

+69
-20
lines changed

CP2077SaveEditor/Utils/TypeExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,5 +216,10 @@ public static void SetPath(this CharacterCustomizationAppearances.HashValueEntry
216216
{
217217
entry.Hash = HashGenerator.CalcFNV1A64(value);
218218
}
219+
220+
public static bool IsPathValid(this CharacterCustomizationAppearances.HashValueEntry entry, string value)
221+
{
222+
return pathHashes.Values.Contains(value);
223+
}
219224
}
220225
}

CP2077SaveEditor/Views/AdvancedAppearanceDialog.Designer.cs

Lines changed: 19 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CP2077SaveEditor/Views/AdvancedAppearanceDialog.cs

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ namespace CP2077SaveEditor
1515
public partial class AdvancedAppearanceDialog : Form
1616
{
1717
private Dictionary<string, HashValueEntry> options = new Dictionary<string, HashValueEntry>();
18-
private Form1 parent;
18+
public delegate void ApplyEvent();
19+
public ApplyEvent ChangesApplied;
1920

2021
public AdvancedAppearanceDialog()
2122
{
2223
InitializeComponent();
24+
25+
firstBox.TextChanged += inputBox_TextChanged;
26+
secondBox.TextChanged += inputBox_TextChanged;
27+
pathBox.TextChanged += inputBox_TextChanged;
2328
}
2429

2530
private void AdvancedAppearanceDialog_Load(object sender, EventArgs e)
2631
{
27-
parent = this.Owner as Form1;
2832
var container = Form1.activeSaveFile.GetAppearanceContainer();
2933

3034
foreach (var section in container.FirstSection.AppearanceSections)
@@ -64,6 +68,43 @@ private void optionsBox_SelectedIndexChanged(object sender, EventArgs e)
6468
secondBox.Text = entry.SecondString;
6569
pathBox.Text = entry.GetPath();
6670
}
71+
else
72+
{
73+
firstBox.Text = string.Empty;
74+
secondBox.Text = string.Empty;
75+
pathBox.Text = string.Empty;
76+
}
77+
78+
applyButton.Enabled = false;
79+
}
80+
81+
private void inputBox_TextChanged(object sender, EventArgs e)
82+
{
83+
applyButton.Enabled = true;
84+
}
85+
86+
private void applyButton_Click(object sender, EventArgs e)
87+
{
88+
if (optionsBox.SelectedItem is null)
89+
{
90+
MessageBox.Show("Error: No appearance entry selected.");
91+
return;
92+
}
93+
94+
HashValueEntry entry = options[(string)optionsBox.SelectedItem];
95+
96+
if (!entry.IsPathValid(pathBox.Text))
97+
{
98+
MessageBox.Show("Invalid path. Must be a valid path to a base game '.app' file.");
99+
return;
100+
}
101+
102+
entry.FirstString = firstBox.Text;
103+
entry.SecondString = secondBox.Text;
104+
entry.SetPath(pathBox.Text);
105+
106+
ChangesApplied();
107+
applyButton.Enabled = false;
67108
}
68109
}
69110
}

CP2077SaveEditor/Views/Form1.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ private void SwapTab(ModernButton tabButton, Panel tabPanel)
242242
activeTabPanel = tabPanel;
243243
}
244244

245-
private void RefreshAppearanceValues()
245+
public void RefreshAppearanceValues()
246246
{
247247
foreach (ModernValuePicker picker in appearanceOptionsPanel.Controls)
248248
{
@@ -1355,6 +1355,7 @@ private void PlayerStatChanged(object sender, EventArgs e)
13551355
private void advancedAppearanceButton_Click(object sender, EventArgs e)
13561356
{
13571357
var advancedDialog = new AdvancedAppearanceDialog();
1358+
advancedDialog.ChangesApplied += RefreshAppearanceValues;
13581359
advancedDialog.ShowDialog();
13591360
}
13601361
}

0 commit comments

Comments
 (0)