@@ -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}
0 commit comments