Exemple #1
0
        protected void OnImportCommandsButtonPress(object sender, EventArgs e)
        {
            Gtk.FileChooserDialog fileChooser = new Gtk.FileChooserDialog
                                                    ("Choose files"
                                                    , this
                                                    , FileChooserAction.Open
                                                    , "Select"
                                                    , ResponseType.Accept
                                                    , "Cancel"
                                                    , ResponseType.Close);

            Gtk.FileFilter xmlFileFilter = new Gtk.FileFilter();
            xmlFileFilter.AddPattern("*.xml");
            fileChooser.AddFilter(xmlFileFilter);

            int response = fileChooser.Run();

            if (response == Utils.static_cast <int>(ResponseType.Close))
            {
                UIUtils.ShutDownWindow(ref fileChooser);
            }
            else if (response == Utils.static_cast <int>(ResponseType.Accept))
            {
                string fullPath = fileChooser.Filename;
                UIUtils.ShutDownWindow(ref fileChooser);

                GameConfigDescriptorLoader loader = new GameConfigDescriptorLoader(fullPath);
                FileOperationResult        fileOperationResult = loader.Load();

                if (fileOperationResult.IsSuccess())
                {
                    GameConfigDB sourceConfigDB = loader.GetConfig();

                    UITabPage    currentTabPage = GetCurrentTabPage();
                    GameConfigDB targetConfigDB = currentTabPage.GetGameConfig();

                    foreach (GameConfigSectionDescriptor sectionDescriptor in sourceConfigDB.GetSections())
                    {
                        targetConfigDB.AddSection(sectionDescriptor);
                        currentTabPage.AddNewSection(sectionDescriptor);
                    }

                    currentTabPage.RefreshCanvas();
                }
                else
                {
                    UIUtils.ShutDownWindowSafe(ref _windowPrompt);
                    _windowPrompt = new WindowPrompt(fileOperationResult.GetResult());
                    _windowPrompt.OnAcceptEvent += OnAlertAccept;
                    _windowPrompt.SetCancelVisible(false);
                    _windowPrompt.Show();
                    MainApp.GetInstance().MoveWindowToMousePos(_windowPrompt);
                }
            }
        }
Exemple #2
0
        private void OnDeleteTabAccept(UITabPage tabPage)
        {
            int pages = notebook1.NPages;

            for (int i = 0; i < pages; ++i)
            {
                Widget    currentPage    = notebook1.GetNthPage(i);
                UITabPage currentTabPage = Utils.static_cast <UITabPage>(currentPage.Data["UITabPage"]);
                if (currentTabPage == tabPage)
                {
                    notebook1.RemovePage(i);
                    if (i > 0)
                    {
                        notebook1.Page = i - 1;
                    }

                    GamesConfigLoader gamesConfigLoader = MainApp.GetInstance().GetConfig().GetGameConfig();
                    gamesConfigLoader.DeleteGameConfig(currentTabPage.GetGameConfig());
                    return;
                }
            }
        }
Exemple #3
0
        protected void OnExportCommandsButtonPress(object sender, EventArgs e)
        {
            Gtk.FileChooserDialog fileChooser = new Gtk.FileChooserDialog
                                                    ("Choose files"
                                                    , this
                                                    , FileChooserAction.SelectFolder
                                                    , "Select"
                                                    , ResponseType.Accept
                                                    , "Cancel"
                                                    , ResponseType.Close);
            int response = fileChooser.Run();

            if (response == Utils.static_cast <int>(ResponseType.Close))
            {
                UIUtils.ShutDownWindow(ref fileChooser);
            }
            else if (response == Utils.static_cast <int>(ResponseType.Accept))
            {
                string fullPath = fileChooser.Filename + "/exported_commands.xml";
                UIUtils.ShutDownWindow(ref fileChooser);
                UITabPage currentTabPage = GetCurrentTabPage();
                currentTabPage.GetGameConfig();

                GamesConfigLoader   gamesLoader         = MainApp.GetInstance().GetConfig().GetGameConfig();
                FileOperationResult fileOperationResult = gamesLoader.Export(fullPath, currentTabPage.GetGameConfig());

                if (!fileOperationResult.IsSuccess())
                {
                    UIUtils.ShutDownWindowSafe(ref _windowPrompt);
                    _windowPrompt = new WindowPrompt(fileOperationResult.GetResult());
                    _windowPrompt.OnAcceptEvent += OnAlertAccept;
                    _windowPrompt.SetCancelVisible(false);
                    _windowPrompt.Show();
                    MainApp.GetInstance().MoveWindowToMousePos(_windowPrompt);
                }
            }
        }