public void moveSelBaseDown()
        {
            int length = LGameBases.Count - 1;

            if (length > 0 && selectedGameBase != null)

            {
                List <GameBases> backupList = new List <GameBases>();
                foreach (GameBases gb in LGameBases)
                {
                    backupList.Add(gb);
                }
                int selBaseID = 0;
                foreach (GameBases gb in backupList)
                {
                    if (gb.Name == SelectedGameBase.Name && gb.KeyHash == SelectedGameBase.KeyHash && gb.Region == SelectedGameBase.Region && gb.Tid == SelectedGameBase.Tid)
                    {
                        break;
                    }
                    selBaseID++;
                }
                if (selBaseID == length)
                {
                }
                else
                {
                    GameBases SavedBase = backupList[selBaseID + 1];
                    backupList[selBaseID + 1] = selectedGameBase;
                    backupList[selBaseID]     = SavedBase;
                }
                LGameBases = backupList;
            }
        }
 public NonCustomBaseFrame(GameBases Base, GameConsoles console, bool existing, BaseContainerFrame bcf)
 {
     InitializeComponent();
     mvm       = (MainViewModel)FindResource("mvm");
     bc        = bcf;
     this.Base = Base;
     ex        = existing;
     consoles  = console;
     createConfig(Base, console);
     checkStuff(mvm.getInfoOfBase(Base));
 }
 public void RemoveSelectedGameBase()
 {
     if (SelectedGameBase == null)
     {
         throw new GameBaseException("The GameBase that you want to delete has to be selected first");
     }
     else
     {
         LGameBases.Remove(SelectedGameBase);
         SelectedGameBase = null;
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 处理命令
        /// </summary>
        /// <param name="gameInput"></param>
        public async Task DealCommand(GameInput gameInput)
        {
            var game = RunningGames.Where(p => p.GroupInfo.Id == gameInput.GroupInfo.Id);

            var command = gameInput.Command;
            var group   = gameInput.GroupInfo;

            //如果是执行的话
            foreach (var item in game)
            {
                //如果匹配
                if (command.StartsWith(item.CommandStart))
                {
                    if (command.Equals(item.CmmandDestory))
                    {
                        await gameInput.ReplyGroup("群{0}, 停止游戏{1}".Format(item.GroupInfo.Name, item.Name));

                        item.Dispose();
                        RunningGames.Remove(item);
                        return;
                    }
                    else
                    {
                        await item.DealCommand(gameInput);

                        return;
                    }
                }
            }
            //匹配创建
            var gameBase = GameBases.Where(p => command.StartsWith(p.CreateCommand)).FirstOrDefault();

            if (gameBase != null)
            {
                var exist = game.Where(p => command.Equals(p.CommandStart)).FirstOrDefault();
                if (exist != null)
                {
                    await gameInput.ReplyGroup("群{0},已经创建了游戏{1}".Format(group.Name, exist.Name));

                    return;
                }
                else
                {
                    IGame createGame = gameBase.Create(new GameCommand(command, gameInput, null), group);
                    RunningGames.Add(createGame);
                    await gameInput.ReplyGroup("群{0},创建了游戏{1}".Format(group.Name, createGame.Name));

                    return;
                }
            }
        }
 public void AddBaseToList()
 {
     if (String.IsNullOrWhiteSpace(TempBase.Name))
     {
         throw new GameBaseException($"A BaseName with no value is not valid!");
     }
     if (String.IsNullOrWhiteSpace(TempBase.Tid))
     {
         throw new GameBaseException($"A TitleID with no value is not valid!");
     }
     if (String.IsNullOrWhiteSpace(NonHashedKey))
     {
         throw new GameBaseException($"A TitleKey with no value is not valid!");
     }
     TempBase.KeyHash = NonHashedKey.ToLower().GetHashCode();
     NonHashedKey     = string.Empty;
     LGameBases.Add(TempBase);
     TempBase = new GameBases();
 }
 public CustomBaseFrame(GameBases Base, GameConsoles console, bool existing)
 {
     InitializeComponent();
     tbCode.Text          = "Code Folder not found";
     tbCode.Foreground    = new SolidColorBrush(Color.FromRgb(205, 50, 50));
     tbContent.Text       = "Content Folder not found";
     tbContent.Foreground = new SolidColorBrush(Color.FromRgb(205, 50, 50));
     tbMeta.Text          = "Meta Folder not found";
     tbMeta.Foreground    = new SolidColorBrush(Color.FromRgb(205, 50, 50));
     mvm   = (MainViewModel)FindResource("mvm");
     bases = Base;
     mvm.isCkeySet();
     this.existing = existing;
     this.console  = console;
     mvm.SetCBASE(this);
     if (mvm.Ckeys)
     {
         CK.Visibility  = Visibility.Hidden;
         path.IsEnabled = true;
     }
 }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            tbCode.Text          = "Code Folder not found";
            tbCode.Foreground    = new SolidColorBrush(Color.FromRgb(205, 50, 50));
            tbContent.Text       = "Content Folder not found";
            tbContent.Foreground = new SolidColorBrush(Color.FromRgb(205, 50, 50));
            tbMeta.Text          = "Meta Folder not found";
            tbMeta.Foreground    = new SolidColorBrush(Color.FromRgb(205, 50, 50));
            mvm.BaseDownloaded   = false;
            mvm.CBasePath        = null;
            //warning if using custom bases program may crash
            Custom_Message cm = new Custom_Message("Information", "If using Custom Bases there will be a chance that the program crashes if adding a wrong base (example: a normal wiiu game instead of a nds vc game).\nA custom base is containing either the code/content/meta folders or Installable files (*.h3, *.app, ...)\nIf you add a wrong base, we will not assist you fixing it, other than telling you to use another base.\nIf you agree to this please hit continue");

            try {
                cm.Owner = mvm.mw;
            }
            catch (Exception)
            {
            }
            cm.ShowDialog();

            if (mvm.choosefolder)
            {
                mvm.choosefolder = false;        //get folder
                using (var dialog = new CommonOpenFileDialog())
                {
                    dialog.IsFolderPicker = true;
                    CommonFileDialogResult result = dialog.ShowDialog();
                    if (result == CommonFileDialogResult.Ok)
                    {
                        try
                        {
                            if (mvm.DirectoryIsEmpty(dialog.FileName))
                            {
                                Custom_Message cm1 = new Custom_Message("Issue", "The Folder is Empty. Please choose another Folder.");
                                try
                                {
                                    cm.Owner = mvm.mw;
                                }
                                catch (Exception)
                                {
                                }
                                cm1.ShowDialog();
                            }
                            else
                            {
                                if (Directory.GetDirectories(dialog.FileName).Length > 3)
                                {
                                    Custom_Message cm1 = new Custom_Message("Issue", "This Folder has too many subfolders. Please choose another folder");
                                    try
                                    {
                                        cm.Owner = mvm.mw;
                                    }
                                    catch (Exception)
                                    {
                                    }
                                    cm1.ShowDialog();
                                }
                                else
                                {
                                    if (Directory.GetDirectories(dialog.FileName).Length > 0)
                                    {
                                        //Code Content Meta
                                        if (Directory.Exists(System.IO.Path.Combine(dialog.FileName, "content")) && Directory.Exists(System.IO.Path.Combine(dialog.FileName, "code")) && Directory.Exists(System.IO.Path.Combine(dialog.FileName, "meta")))
                                        {
                                            //create new Game Config
                                            mvm.GameConfiguration.Console   = console;
                                            mvm.GameConfiguration.CBasePath = dialog.FileName;
                                            GameBases gb = new GameBases();
                                            gb.Name   = "Custom";
                                            gb.Region = Regions.EU;
                                            gb.Path   = mvm.GameConfiguration.CBasePath;
                                            bar.Text  = gb.Path;
                                            mvm.GameConfiguration.BaseRom = gb;
                                            tbCode.Text          = "Code Folder exists";
                                            tbCode.Foreground    = new SolidColorBrush(Color.FromRgb(50, 205, 50));
                                            tbContent.Text       = "Content Folder exists";
                                            tbContent.Foreground = new SolidColorBrush(Color.FromRgb(50, 205, 50));
                                            tbMeta.Text          = "Meta Folder exists";
                                            tbMeta.Foreground    = new SolidColorBrush(Color.FromRgb(50, 205, 50));
                                            mvm.BaseDownloaded   = true;
                                        }
                                        else
                                        {
                                            Custom_Message cm1 = new Custom_Message("Issue", "This folder is not in the \"loadiine\" format");
                                            try
                                            {
                                                cm.Owner = mvm.mw;
                                            }
                                            catch (Exception)
                                            {
                                            }
                                            cm1.ShowDialog();
                                        }
                                    }
                                    else
                                    {
                                        //WUP
                                        if (Directory.GetFiles(dialog.FileName, "*.app").Length > 0 && Directory.GetFiles(dialog.FileName, "*.h3").Length > 0 && File.Exists(System.IO.Path.Combine(dialog.FileName, "title.tmd")) && File.Exists(System.IO.Path.Combine(dialog.FileName, "title.tik")))
                                        {
                                            if (mvm.CBaseConvertInfo())
                                            {
                                                //Convert to LOADIINE => save under bases/custom or custom_x path => create new config
                                                string path = Injection.ExtractBase(dialog.FileName, console);
                                                mvm.GameConfiguration           = new GameConfig();
                                                mvm.GameConfiguration.Console   = console;
                                                mvm.GameConfiguration.CBasePath = path;
                                                GameBases gb = new GameBases();
                                                gb.Name       = "Custom";
                                                gb.Region     = Regions.EU;
                                                gb.Path       = mvm.GameConfiguration.CBasePath;
                                                mvm.CBasePath = mvm.GameConfiguration.CBasePath;
                                                mvm.GameConfiguration.BaseRom = gb;
                                                tbCode.Text          = "Code Folder exists";
                                                tbCode.Foreground    = new SolidColorBrush(Color.FromRgb(50, 205, 50));
                                                tbContent.Text       = "Content Folder exists";
                                                tbContent.Foreground = new SolidColorBrush(Color.FromRgb(50, 205, 50));
                                                tbMeta.Text          = "Meta Folder exists";
                                                tbMeta.Foreground    = new SolidColorBrush(Color.FromRgb(50, 205, 50));
                                                mvm.BaseDownloaded   = true;
                                            }
                                        }
                                        else
                                        {
                                            Custom_Message cm1 = new Custom_Message("Issue", "This Folder does not contain needed NUS files");
                                            try
                                            {
                                                cm.Owner = mvm.mw;
                                            }
                                            catch (Exception)
                                            {
                                            }
                                            cm1.ShowDialog();
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
        }
 private void createConfig(GameBases Base, GameConsoles console)
 {
     mvm.GameConfiguration.BaseRom = Base;
     mvm.GameConfiguration.Console = console;
 }