コード例 #1
0
 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();
     }
 }
コード例 #2
0
        private void ShowSaveJsonObjectDialog <T>(T objectToSave)
        {
            SaveDialog.InitialDirectory = JsonFiles.JsonFilePaths[typeof(T).Name];

            SaveDialog.ShowDialog();

            if (SaveDialog.FileName != "")
            {
                JsonFiles.SaveAs <T>(SaveDialog.FileName, objectToSave);
            }
        }
コード例 #3
0
 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;
 }
コード例 #4
0
        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();
            }
        }
コード例 #5
0
        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));
            }
        }
コード例 #6
0
        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();
        }