private void TraitFileSelectButton_Click(object sender, EventArgs e) { TraitReference.TraitDefinitions newDefs = ShowLoadJsonObjectDialog <TraitReference.TraitDefinitions>(); if (LoadDialog.FileName != "") { JsonFiles.JsonFilePaths[typeof(TraitReference.TraitDefinitions).Name] = LoadDialog.FileName; JsonFiles.LoadFilePaths(); } }
private void ShowSaveJsonObjectDialog <T>(T objectToSave) { SaveDialog.InitialDirectory = JsonFiles.JsonFilePaths[typeof(T).Name]; SaveDialog.ShowDialog(); if (SaveDialog.FileName != "") { JsonFiles.SaveAs <T>(SaveDialog.FileName, objectToSave); } }
public static void LoadTraitDefinitions() { if (JsonFiles.JsonFilePaths[typeof(TraitDefinitions).Name] == "") { definitions = JsonFiles.LoadFromCommonDirectory <TraitDefinitions>(TRAIT_FILE); } else { definitions = JsonFiles.LoadFrom <TraitDefinitions>(JsonFiles.JsonFilePaths[typeof(TraitDefinitions).Name]); } loaded = true; }
private void DirSelectButton_Click(object sender, EventArgs e) { Type jsonObjType = DirectoryButtonTypeMap[((Control)sender).Name]; String textBoxName = DirectoryButtonTextBoxMap[((Control)sender).Name]; FolderDialog.ShowDialog(); if (FolderDialog.SelectedPath != "") { JsonFiles.JsonFilePaths[jsonObjType.Name] = FolderDialog.SelectedPath; TabOptions.Controls[textBoxName].Text = FolderDialog.SelectedPath; JsonFiles.SaveFilePaths(); } }
private T ShowLoadJsonObjectDialog <T>() { LoadDialog.InitialDirectory = JsonFiles.JsonFilePaths[typeof(T).Name]; LoadDialog.ShowDialog(); if (LoadDialog.FileName != "") { return(JsonFiles.LoadFrom <T>(LoadDialog.FileName)); } else { return(default(T)); } }
public Form1() { InitializeComponent(); UnitTypeCombo.Items.AddRange(new String[] { CUnit.TYPE_LIGHT_INFANTRY, CUnit.TYPE_HEAVY_INFANTRY, CUnit.TYPE_LIGHT_CAVALRY, CUnit.TYPE_HEAVY_CAVALRY, CUnit.TYPE_SIEGE_WEAPON }); JsonFiles.LoadFilePaths(); UnitDirSelectText.Text = JsonFiles.JsonFilePaths["CUnit"]; CommanderDirSelectText.Text = JsonFiles.JsonFilePaths["CCommander"]; ArmyDirSelectText.Text = JsonFiles.JsonFilePaths["CArmy"]; BattleDirSelectText.Text = JsonFiles.JsonFilePaths["CBattle"]; TraitReference.LoadTraitDefinitions(); ClearAllArmyRows(); ClearAllTraitRows(); }