@@ -16,6 +16,7 @@ public partial class Form1 : Form
1616 BoostSetData boostSet = new BoostSetData ( ) ;
1717 List < SetGroup > setGroups ;
1818 List < BoostType > boostTypes ;
19+ List < Salvage > salvage ;
1920 List < int > craftingCost ;
2021
2122 public Form1 ( )
@@ -24,6 +25,7 @@ public Form1()
2425 config = JsonConvert . DeserializeObject < Config > ( LoadConfig ( "Config" , Properties . Resources . Config ) ) ;
2526 setGroups = JsonConvert . DeserializeObject < List < SetGroup > > ( LoadConfig ( "SetGroups" , Properties . Resources . SetGroups ) ) ;
2627 boostTypes = JsonConvert . DeserializeObject < List < BoostType > > ( LoadConfig ( "BoostTypes" , Properties . Resources . BoostTypes ) ) ;
28+ salvage = JsonConvert . DeserializeObject < List < Salvage > > ( LoadConfig ( "Salvage" , Properties . Resources . Salvage ) ) ;
2729 craftingCost = JsonConvert . DeserializeObject < List < int > > ( LoadConfig ( "CraftingCost" , Properties . Resources . CraftingCost ) ) ;
2830 foreach ( SetGroup group in setGroups ) setGroupName . Items . Add ( group ) ;
2931 foreach ( BoostType boostType in boostTypes ) boostTypeList . Items . Add ( boostType ) ;
@@ -128,7 +130,7 @@ private void createDataFiles_Click(object sender, EventArgs e)
128130 Directory . CreateDirectory ( config . data + "Texts/English/Powers" ) ;
129131
130132 File . WriteAllText ( config . data + "Defs/Account/Product_Catalog.def" , boostSet . GetProductCatalog ( ) ) ;
131- File . WriteAllText ( config . data + "Defs/Invention/Recipes.recipe" , boostSet . GetDropRecipe ( craftingCost ) ) ;
133+ File . WriteAllText ( config . data + "Defs/Invention/Recipes.recipe" , boostSet . GetDropRecipe ( craftingCost , salvage ) ) ;
132134 File . WriteAllText ( config . data + "Defs/Invention/Merits.recipe" , boostSet . GetMeritsRecipe ( ) ) ;
133135 File . WriteAllText ( config . data + "Defs/Invention/Store.recipe" , boostSet . GetStoreRecipe ( ) ) ;
134136 File . WriteAllText ( config . data + "texts/English/Bases/Recipes.ms" , boostSet . DumpCache ( ) ) ;
@@ -238,6 +240,7 @@ private void boostLetter_TextChanged(object sender, EventArgs e)
238240 if ( boost . aspects != null ) foreach ( BoostType type in boost . aspects ) boostAspectList . Items . Add ( type ) ;
239241 boostDescription . Text = boost . description ;
240242 boostLetter . TextChanged += boostLetter_TextChanged ;
243+ UpdateSalvageTree ( boost ) ;
241244 }
242245
243246 private void UpdateAspectList ( )
@@ -260,14 +263,14 @@ private void UpdateAspectList()
260263
261264 private void boostAddAspect_Click ( object sender , EventArgs e )
262265 {
263- if ( ( boostTypeList . SelectedItem != null ) && ( ! boostAspectList . Items . Contains ( boostTypeList . SelectedItem ) ) && ( boostAspectList . Items . Count < 4 ) )
266+ if ( ! String . IsNullOrEmpty ( boostLetter . Text ) && ( boostTypeList . SelectedItem != null ) && ( ! boostAspectList . Items . Contains ( boostTypeList . SelectedItem ) ) && ( boostAspectList . Items . Count < 4 ) )
264267 {
265268 boostAspectList . Items . Add ( boostTypeList . SelectedItem ) ;
266269 UpdateAspectList ( ) ;
267270 }
268271 }
269272
270- private void boostAddNew_Click ( object sender , EventArgs e )
273+ private void boostSave_Click ( object sender , EventArgs e )
271274 {
272275 Boost boost = new Boost ( ) ;
273276 if ( ! string . IsNullOrEmpty ( boostLetter . Text ) )
@@ -276,18 +279,25 @@ private void boostAddNew_Click(object sender, EventArgs e)
276279
277280 boost . letter = boostLetter . Text . ToUpper ( ) ;
278281 boost . name = boostName . Text . Trim ( ) ;
279- boost . displayName = boostDisplayName . Text . Trim ( ) ;
280- boost . description = boostDescription . Text . Trim ( ) ;
281- boost . shortHelp = boostShortHelp . Text . Trim ( ) ;
282- boost . aspects = new List < BoostType > ( ) ;
282+ boost . displayName = boostDisplayName . Text . Trim ( ) ;
283+ boost . description = boostDescription . Text . Trim ( ) ;
284+ boost . shortHelp = boostShortHelp . Text . Trim ( ) ;
285+ boost . aspects = new List < BoostType > ( ) ;
283286 foreach ( BoostType type in boostAspectList . Items ) boost . aspects . Add ( type ) ;
284287
288+ boost . salvage = new List < string > ( ) ;
289+ foreach ( TreeNode level in salvageTree . Nodes )
290+ {
291+ foreach ( TreeNode salvage in level . Nodes ) boost . salvage . Add ( salvage . Name ) ;
292+ }
293+
285294 // Rebuild the Enhancements list to keep it sorted and prevent duplicate letters.
286295 foreach ( Boost b in boostList . Items ) if ( ! b . letter . Equals ( boost . letter ) ) sortableList . Add ( b ) ;
287296 sortableList . Add ( boost ) ;
288297 sortableList = sortableList . OrderBy ( b => b . letter ) . ToList ( ) ;
289298 boostList . Items . Clear ( ) ;
290299 foreach ( Boost b in sortableList ) boostList . Items . Add ( b ) ;
300+ tabs . SelectTab ( tabSet ) ;
291301 }
292302 }
293303
@@ -380,5 +390,99 @@ private void setIconName_TextChanged(object sender, EventArgs e)
380390 {
381391 if ( File . Exists ( config . images + setIconName . Text . Trim ( ) + ".png" ) ) UpdateBoostSet ( ) ;
382392 }
393+
394+ private void boostList_MouseDoubleClick ( object sender , MouseEventArgs e )
395+ {
396+ if ( boostList . SelectedItem != null )
397+ {
398+ Boost boost = ( Boost ) boostList . SelectedItem ;
399+ boostLetter . Text = boost . letter ;
400+ tabs . SelectTab ( tabBoosts ) ;
401+ }
402+ }
403+
404+ private void tabs_Selected ( object sender , TabControlEventArgs e )
405+ {
406+ // Enhancement and Recipes tab share some controls.
407+ if ( tabs . SelectedIndex >= 1 && tabs . SelectedIndex <= 2 )
408+ {
409+ boostName . Parent = tabs . TabPages [ tabs . SelectedIndex ] ;
410+ boostNameLabel . Parent = tabs . TabPages [ tabs . SelectedIndex ] ;
411+ boostLetter . Parent = tabs . TabPages [ tabs . SelectedIndex ] ;
412+ boostLetterLabel . Parent = tabs . TabPages [ tabs . SelectedIndex ] ;
413+ boostSave . Parent = tabs . TabPages [ tabs . SelectedIndex ] ;
414+ }
415+ }
416+
417+ private void UpdateSalvageList ( TreeNode node )
418+ {
419+ if ( node . Parent == null )
420+ {
421+ salvageList . Items . Clear ( ) ;
422+ foreach ( Salvage s in salvage )
423+ {
424+ if ( node . Index == ( int ) s . level && ! node . Nodes . ContainsKey ( s . name ) ) salvageList . Items . Add ( s ) ;
425+ }
426+ }
427+ else
428+ {
429+ UpdateSalvageList ( node . Parent ) ;
430+ }
431+ }
432+
433+ private void AddSalvageToTree ( Salvage s , TreeNode node )
434+ {
435+ TreeNode n = new TreeNode ( s . displayName ) ;
436+ n . Name = s . name ;
437+ if ( s . rarity > Salvage . Rarity . Common ) n . BackColor = ( s . rarity == Salvage . Rarity . Uncommon ) ? Color . Yellow : Color . Orange ;
438+ node . Nodes . Add ( n ) ;
439+ UpdateSalvageList ( node ) ;
440+ node . Expand ( ) ;
441+ }
442+
443+ private void UpdateSalvageTree ( Boost boost )
444+ {
445+ List < TreeNode > lvlNodes = new List < TreeNode > ( ) ;
446+ lvlNodes . Add ( new TreeNode ( "Low Level (10-25)" ) ) ;
447+ lvlNodes . Add ( new TreeNode ( "Mid Level (26-40)" ) ) ;
448+ lvlNodes . Add ( new TreeNode ( "High Level (41-50)" ) ) ;
449+
450+ if ( boost . salvage != null )
451+ {
452+ foreach ( string sid in boost . salvage )
453+ {
454+ Salvage s = salvage . Find ( x => x . name . Equals ( sid ) ) ;
455+ AddSalvageToTree ( s , lvlNodes [ ( int ) s . level ] ) ;
456+ }
457+ }
458+
459+ salvageTree . Nodes . Clear ( ) ;
460+ foreach ( TreeNode node in lvlNodes ) salvageTree . Nodes . Add ( node ) ;
461+ salvageList . Items . Clear ( ) ;
462+ }
463+
464+ private void salvageTree_KeyDown ( object sender , KeyEventArgs e )
465+ {
466+ TreeView tree = ( TreeView ) sender ;
467+ if ( e . KeyCode == Keys . Delete && tree . SelectedNode . Parent != null )
468+ {
469+ tree . SelectedNode . Remove ( ) ;
470+ UpdateSalvageList ( tree . SelectedNode ) ;
471+ }
472+ }
473+
474+ private void salvageTree_NodeMouseClick ( object sender , TreeNodeMouseClickEventArgs e )
475+ {
476+ UpdateSalvageList ( e . Node ) ;
477+ }
478+
479+ private void salvageAdd_Click ( object sender , EventArgs e )
480+ {
481+ if ( ! String . IsNullOrEmpty ( boostLetter . Text ) && salvageList . SelectedItem != null )
482+ {
483+ Salvage s = ( Salvage ) salvageList . SelectedItem ;
484+ AddSalvageToTree ( s , salvageTree . Nodes [ ( int ) s . level ] ) ;
485+ }
486+ }
383487 }
384488}
0 commit comments