コード例 #1
0
 public UISection(UITabPage parent, GameConfigSectionDescriptor sectionDescriptor, Point origin)
 {
     _parent     = parent;
     _origin     = origin;
     _UIElements = new List <UICommandElement>();
     AddSection(sectionDescriptor);
 }
コード例 #2
0
        public void OnAddNewSectionButtonAcceptPress()
        {
            string tittle       = _windowAddNewSection.GetTittle();
            int    sectionIndex = _windowAddNewSection.GetSectionIndex();

            GameConfigSectionDescriptor newSection = _gameConfigDB.AddNewSection(tittle, sectionIndex);

            AddNewSection(newSection, sectionIndex);

            UIUtils.ShutDownWindow(ref _windowAddNewSection);
        }
コード例 #3
0
        public void RemoveSection(int sectionIndex)
        {
            UIUtils.ShutDownWindowSafe(ref _windowPrompt);
            GameConfigSectionDescriptor sectionToDelete = _gameConfigDB.GetSection(sectionIndex);

            _windowPrompt = new WindowPrompt("Are you sure to delete section \"" + sectionToDelete._tittle + "\" and all its content ?");
            _windowPrompt.SetExternalData(sectionIndex);
            _windowPrompt.OnAcceptEvent += OnRemoveSectionAccept;
            _windowPrompt.OnCancelEvent += OnClosePrompt;
            MoveWindowToWindowPos(_windowPrompt);
            _windowPrompt.Show();
        }
コード例 #4
0
        public void AddNewSection(GameConfigSectionDescriptor sectionDescriptor)
        {
            Point newSectionOriginPoint = UISection.DEFAULT_ORIGIN_POINT;

            if (_uiSections.Count > 0)
            {
                newSectionOriginPoint = _uiSections[_uiSections.Count - 1].GetNextPosition();
            }

            UISection newSection = new UISection(this, sectionDescriptor, newSectionOriginPoint);

            _uiSections.Add(newSection);
            RefreshCanvas();
        }
コード例 #5
0
        private void AddSection(GameConfigSectionDescriptor sectionDescriptor)
        {
            Pango.FontDescription fontDescription = Pango.FontDescription.FromString(UIUtils.SECTION_FONT);
            _label      = new Gtk.Label();
            _label.Text = sectionDescriptor._tittle;
            _label.ModifyFont(fontDescription);
            _label.Show();
            _parent.GetCanvas().Add(_label);

            foreach (GameConfigButtonDescriptor buttonDescriptor in sectionDescriptor._buttons)
            {
                AddButton(buttonDescriptor);
            }

            Dispose();
        }
コード例 #6
0
    public GameConfigSectionDescriptor AddNewSection(string tittle, int previousSectionIndex)
    {
        GameConfigSectionDescriptor newSection = new GameConfigSectionDescriptor();

        newSection._tittle  = tittle;
        newSection._buttons = new List <GameConfigButtonDescriptor>();

        if (previousSectionIndex < _sections.Count - 1)
        {
            _sections.Insert(previousSectionIndex + 1, newSection);
        }
        else
        {
            _sections.Add(newSection);
        }

        return(newSection);
    }
コード例 #7
0
        public void AddNewSection(GameConfigSectionDescriptor sectionDescriptor, int previousSectionIndex)
        {
            Point newSectionOriginPoint = UISection.DEFAULT_ORIGIN_POINT;

            if (_uiSections.Count > 0)
            {
                newSectionOriginPoint = _uiSections[previousSectionIndex].GetNextPosition();
            }

            UISection newSection = new UISection(this, sectionDescriptor, newSectionOriginPoint);

            if (previousSectionIndex < _uiSections.Count - 1)
            {
                _uiSections.Insert(previousSectionIndex + 1, newSection);
            }
            else
            {
                _uiSections.Add(newSection);
            }
            RefreshCanvas();
        }
コード例 #8
0
    public FileOperationResult Load()
    {
        try
        {
            XmlReader reader = XmlReader.Create(_descriptorFile);
            while (reader.Read())
            {
                // Only detect start elements.
                if (reader.IsStartElement())
                {
                    // Get element name and switch on it.
                    switch (reader.Name)
                    {
                    case "commands":
                    {
                        _gameConfigDB = new GameConfigDB();

                        string attribute = reader["name"];
                        Config.AssertResource(attribute);
                        _gameConfigDB.SetName(attribute);

                        attribute = reader["creationDate"];
                        Config.AssertResource(attribute);
                        _gameConfigDB.SetCreationDate(Int32.Parse(attribute));
                    }

                    break;

                    case "section":
                    {
                        if (_currentGameConfigSectionDescriptor != null)
                        {
                            _gameConfigDB.AddSection(_currentGameConfigSectionDescriptor);
                            _currentGameConfigSectionDescriptor = null;
                        }
                        _currentGameConfigSectionDescriptor = new GameConfigSectionDescriptor();
                        string attribute = reader["tittle"];
                        Config.AssertResource(attribute);
                        _currentGameConfigSectionDescriptor._tittle = Utils.DecodeHTML(attribute);
                    }
                    break;

                    case "command":
                    {
                        _currentGameConfigButtonDescriptor = new GameConfigButtonDescriptor();
                        string attribute = reader["type"];
                        Config.AssertResource(attribute);

                        GameConfigButtonDescriptor.Etype type = Utils.static_cast <GameConfigButtonDescriptor.Etype>(Int32.Parse(attribute));
                        _currentGameConfigButtonDescriptor._type = type;

                        attribute = reader["tittle"];
                        Config.AssertResource(attribute);
                        _currentGameConfigButtonDescriptor._tittle = Utils.DecodeHTML(attribute);

                        if (type == GameConfigButtonDescriptor.Etype.MultiCommand)
                        {
                            _currentGameConfigButtonDescriptor._commandList = new List <GameConfigCommandDescriptor>();
                        }
                        else
                        {
                            attribute = reader["command"];
                            Config.AssertResource(attribute);
                            _currentGameConfigButtonDescriptor._command = Utils.DecodeHTML(attribute);
                        }

                        if (type == GameConfigButtonDescriptor.Etype.FixedArgument ||
                            type == GameConfigButtonDescriptor.Etype.ExposedArgument)
                        {
                            attribute = reader["arguments"];
                            Config.AssertResource(attribute);
                            _currentGameConfigButtonDescriptor._arguments = Utils.DecodeHTML(attribute);
                        }

                        _currentGameConfigSectionDescriptor._buttons.Add(_currentGameConfigButtonDescriptor);
                    }
                    break;

                    case "command_sequence":
                    {
                        GameConfigCommandDescriptor commandDescriptor = new GameConfigCommandDescriptor();
                        string attribute = reader["command"];
                        Config.AssertResource(attribute);
                        commandDescriptor._command = Utils.DecodeHTML(attribute);

                        attribute = reader["arguments"];
                        Config.AssertResource(attribute);
                        commandDescriptor._arguments = Utils.DecodeHTML(attribute);

                        _currentGameConfigButtonDescriptor._commandList.Add(commandDescriptor);
                    }
                    break;
                    }
                }
            }

            if (_currentGameConfigSectionDescriptor != null)
            {
                _gameConfigDB.AddSection(_currentGameConfigSectionDescriptor);
                _currentGameConfigSectionDescriptor = null;
            }
            reader.Close();

            return(new FileOperationResult(true));
        }
        catch (System.Exception ex)
        {
            return(new FileOperationResult(false, ex.Message));
        }
    }
コード例 #9
0
 public void AddSection(GameConfigSectionDescriptor sectionDescriptor)
 {
     _sections.Add(sectionDescriptor);
 }