Beispiel #1
0
 private void OpenCfg(string filePath)
 {
     if (this.InvokeRequired)
     {
         this.Invoke((MethodInvoker)delegate { OpenCfg(filePath); });
         return;
     }
     try
     {
         using (var s = new FileStream(filePath, FileMode.Open, FileAccess.Read))
         {
             if (s.Length > 1024) throw new InvalidDataException
                     ("File size is too big, impossible to be Touhou Game Config file.");
             using (var reader = new BinaryReader(s))
             {
                 byte[] data = reader.ReadBytes((int)s.Length);
                 if (th15.isDataValid(data))
                 {
                     selectedGame = thGame.th15; CfgToUI(th15, data);
                 }
                 else if (th143.isDataValid(data))
                 {
                     selectedGame = thGame.th143; CfgToUI(th143, data);
                 }
                 else if (th14.isDataValid(data))
                 {
                     selectedGame = thGame.th14; CfgToUI(th14, data);
                 }
                 else if (th13.isDataValid(data))
                 {
                     selectedGame = thGame.th13; CfgToUI(th13, data);
                 }
                 else if (th128.isDataValid(data))
                 {
                     selectedGame = thGame.th128; CfgToUI(th128, data);
                 }
                 else if (th125.isDataValid(data))
                 {
                     selectedGame = thGame.th125; CfgToUI(th125, data);
                 }
                 else if (th12.isDataValid(data))
                 {
                     selectedGame = thGame.th12; CfgToUI(th12, data);
                 }
                 else if (th11.isDataValid(data))
                 {
                     selectedGame = thGame.th11; CfgToUI(th11, data);
                 }
                 else if (th10.isDataValid(data))
                 {
                     selectedGame = thGame.th10; CfgToUI(th10, data);
                 }
                 else if (th095.isDataValid(data))
                 {
                     selectedGame = thGame.th095; CfgToUI(th095, data);
                 }
                 else if (th09.isDataValid(data))
                 {
                     selectedGame = thGame.th09; CfgToUI(th09, data);
                 }
                 else if (th08.isDataValid(data))
                 {
                     selectedGame = thGame.th08; CfgToUI(th08, data);
                 }
                 else if (th07.isDataValid(data))
                 {
                     selectedGame = thGame.th07; CfgToUI(th07, data);
                 }
                 else if (th06.isDataValid(data))
                 {
                     selectedGame = thGame.th06; CfgToUI(th06, data);
                 }
                 else
                 {
                     throw new InvalidDataException
                         ("ThDanConfig can't recognize the data of this file!\n"
                         + "Only cfg files from TH06 to TH15 are supported now. ");
                 }
             }
         }
         openedFile = filePath;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\n\n" + filePath,
             "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #2
0
 private byte[] defCfgOf(thGame game)
 {
     switch (game)
     {
         case thGame.th06:
             return Properties.Resources.def_th06_cfg;
         case thGame.th07:
             return Properties.Resources.def_th07_cfg;
         case thGame.th08:
             return Properties.Resources.def_th08_cfg;
         case thGame.th09:
             return Properties.Resources.def_th09_cfg;
         case thGame.th095:
             return Properties.Resources.def_th095_cfg;
         case thGame.th10:
             return Properties.Resources.def_th10_cfg;
         case thGame.th11:
             return Properties.Resources.def_th11_cfg;
         case thGame.th12:
             return Properties.Resources.def_th12_cfg;
         case thGame.th125:
             return Properties.Resources.def_th125_cfg;
         case thGame.th128:
             return Properties.Resources.def_th128_cfg;
         case thGame.th13:
             return Properties.Resources.def_th13_cfg;
         case thGame.th14:
             return Properties.Resources.def_th14_cfg;
         case thGame.th143:
             return Properties.Resources.def_th143_cfg;
         case thGame.th15:
             return Properties.Resources.def_th15_cfg;
     }
     throw new NotImplementedException();
 }