Ejemplo n.º 1
0
        protected void SetGameInfo(GroupSumGameInfo gameInfo)
        {
            comboBoxGame.Active       = 3;
            entryGameDescription.Text = gameInfo.GameDescription;

            spinButtonGroupSumFirstRoundSeconds.Value = gameInfo.FirstRoundSeconds;
            spinButtonGroupSumRoundSeconds.Value      = gameInfo.RoundSeconds;
            spinButtonGroupSumRangeStart.Value        = gameInfo.RangeStart;
            spinButtonGroupSumRangeEnd.Value          = gameInfo.RangeEnd;
            checkButtonGroupSumNumericFeedback.Active = gameInfo.ShowNumericFeedback;
            checkbuttonGroupSumPreviousInput.Active   = gameInfo.UsePreviousRoundInput;
        }
Ejemplo n.º 2
0
    protected virtual void OnButtonOpenGamesFileClicked(object sender, System.EventArgs e)
    {
        var openDialog = new FileChooserDialog("Open Games File", this, FileChooserAction.Open,
            "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);

        openDialog.SetCurrentFolder(Nexus.Settings.Default.GamesFileDirectory);

        try
        {
            if (openDialog.Run() == (int)ResponseType.Accept)
            {
                gameStore.Clear();

                // Parse games file
                var document = System.Xml.Linq.XDocument.Load(openDialog.Filename);

                foreach (var gameElement in document.Descendants("game"))
                {
                    var gameName = ((string)gameElement.Attribute("name")).ToLower();
                    IGameInfo gameInfo = null;

                    switch (gameName)
                    {
                        case "flatland":
                            gameInfo = new FlatlandGameInfo(gameElement);
                            break;

                        case "pixel":
                            gameInfo = new PixelGameInfo(gameElement);
                            break;

                        case "group sum":
                            gameInfo = new GroupSumGameInfo(gameElement);
                            break;

                        case "forager":
                            gameInfo = new ForagerGameInfo(gameElement);
                            break;

                        default:
                            logger.WarnFormat("Unrecognized game \"{0}\"", gameName);
                            break;
                    }

                    if (gameInfo != null)
                    {
                        gameInfo.GameDescription = (string)gameElement.Attribute("description");
                        gameStore.AppendValues(false, gameInfo.GameName, gameInfo.GameDescription, gameInfo);
                    }
                }

                Nexus.Settings.Default.GamesFileDirectory = System.IO.Path.GetDirectoryName(openDialog.Filename);
            }
        }
        catch(Exception ex)
        {
            logger.Error("OnButtonOpenGamesFileClicked", ex);
            ShowErrorDialog(ex);
        }
        finally
        {
            openDialog.Destroy();
        }
    }
Ejemplo n.º 3
0
        protected void SetGameInfo(GroupSumGameInfo gameInfo)
        {
            comboBoxGame.Active = 3;
              entryGameDescription.Text = gameInfo.GameDescription;

              spinButtonGroupSumFirstRoundSeconds.Value = gameInfo.FirstRoundSeconds;
              spinButtonGroupSumRoundSeconds.Value = gameInfo.RoundSeconds;
              spinButtonGroupSumRangeStart.Value = gameInfo.RangeStart;
              spinButtonGroupSumRangeEnd.Value = gameInfo.RangeEnd;
              checkButtonGroupSumNumericFeedback.Active = gameInfo.ShowNumericFeedback;
              checkbuttonGroupSumPreviousInput.Active = gameInfo.UsePreviousRoundInput;
        }
Ejemplo n.º 4
0
        public IGameInfo GetGameInfo()
        {
            IGameInfo gameInfo = null;

            switch (comboBoxGame.Active)
            {
            case 1:
                var pixelInfo = new PixelGameInfo()
                {
                    MaxSize      = spinButtonPixelMaxSize.ValueAsInt,
                    InitialState = comboBoxPixelInitialState.ActiveText,
                    PlayerSort   = comboBoxPixelPlayerSort.ActiveText
                };

                foreach (var point in pixelGrid.EnabledPixels)
                {
                    if ((point.X < pixelInfo.MaxSize) &&
                        (point.Y < pixelInfo.MaxSize))
                    {
                        pixelInfo.FixedPixels.Add(point);
                    }
                }

                gameInfo = pixelInfo;
                break;

            case 2:
                var flatlandInfo = new FlatlandGameInfo()
                {
                    Tiles = checkBoxFlatlandCustomBoardSize.Active ?
                            spinButtonFlatlandBoardSize.ValueAsInt : (int?)null,

                    CollisionBehavior = comboBoxFlatlandCollisionBehavior.ActiveText,
                    GameType          = comboBoxFlatlandGameType.ActiveText
                };

                // Add teams
                flatlandTeamStore.Foreach(delegate(TreeModel model, TreePath path, TreeIter iter)
                {
                    flatlandInfo.Teams.Add(new FlatlandTeamInfo()
                    {
                        TeamIndex       = (int)model.GetValue(iter, 0),
                        ThemeName       = (string)model.GetValue(iter, 1),
                        Kind            = (string)model.GetValue(iter, 2),
                        MoveSeconds     = (int)model.GetValue(iter, 3),
                        WrappedMovement = (bool)model.GetValue(iter, 4),
                        ScoringSystem   = (string)model.GetValue(iter, 5)
                    });

                    return(false);
                });

                flatlandInfo.FixedTiles.AddRange(flatlandFixedTiles);

                gameInfo = flatlandInfo;
                break;

            case 3:
                gameInfo = new GroupSumGameInfo()
                {
                    FirstRoundSeconds     = spinButtonGroupSumFirstRoundSeconds.ValueAsInt,
                    RoundSeconds          = spinButtonGroupSumRoundSeconds.ValueAsInt,
                    RangeStart            = spinButtonGroupSumRangeStart.ValueAsInt,
                    RangeEnd              = spinButtonGroupSumRangeEnd.ValueAsInt,
                    ShowNumericFeedback   = checkButtonGroupSumNumericFeedback.Active,
                    UsePreviousRoundInput = checkbuttonGroupSumPreviousInput.Active
                };
                break;

            case 4:
                var foragerInfo = new ForagerGameInfo()
                {
                    Plots       = spinButtonForagerPlots.ValueAsInt,
                    TravelTime  = spinButtonForagerTravelTime.ValueAsInt,
                    FoodRate    = spinButtonForagerFoodRate.ValueAsInt,
                    GameSeconds = spinButtonForagerGameMinutes.ValueAsInt * 60,
                };

                foreach (var plotProbabilities in foragerProbabilities)
                {
                    foragerInfo.PlotProbabilities.Add(plotProbabilities.ToList());
                }

                foragerInfo.ProbabilityShiftTimes.AddRange(foragerProbabilityShiftTimes.ToList());

                gameInfo = foragerInfo;
                break;
            }

            if (gameInfo != null)
            {
                gameInfo.GameDescription = entryGameDescription.Text;
            }

            return(gameInfo);
        }
Ejemplo n.º 5
0
        public IGameInfo GetGameInfo()
        {
            IGameInfo gameInfo = null;

              switch (comboBoxGame.Active)
              {
            case 1:
              var pixelInfo = new PixelGameInfo()
              {
            MaxSize = spinButtonPixelMaxSize.ValueAsInt,
            InitialState = comboBoxPixelInitialState.ActiveText,
            PlayerSort = comboBoxPixelPlayerSort.ActiveText
              };

              foreach (var point in pixelGrid.EnabledPixels)
              {
            if ((point.X < pixelInfo.MaxSize) &&
              (point.Y < pixelInfo.MaxSize))
            {
              pixelInfo.FixedPixels.Add(point);
            }
              }

              gameInfo = pixelInfo;
              break;

            case 2:
              var flatlandInfo = new FlatlandGameInfo()
              {
            Tiles = checkBoxFlatlandCustomBoardSize.Active ?
              spinButtonFlatlandBoardSize.ValueAsInt : (int?)null,

            CollisionBehavior = comboBoxFlatlandCollisionBehavior.ActiveText,
            GameType = comboBoxFlatlandGameType.ActiveText
              };

              // Add teams
              flatlandTeamStore.Foreach(delegate(TreeModel model, TreePath path, TreeIter iter)
              {
            flatlandInfo.Teams.Add(new FlatlandTeamInfo()
            {
              TeamIndex = (int)model.GetValue(iter, 0),
              ThemeName = (string)model.GetValue(iter, 1),
              Kind = (string)model.GetValue(iter, 2),
              MoveSeconds = (int)model.GetValue(iter, 3),
              WrappedMovement = (bool)model.GetValue(iter, 4),
              ScoringSystem = (string)model.GetValue(iter, 5)
            });

            return (false);
              });

              flatlandInfo.FixedTiles.AddRange(flatlandFixedTiles);

              gameInfo = flatlandInfo;
              break;

            case 3:
              gameInfo = new GroupSumGameInfo()
              {
            FirstRoundSeconds = spinButtonGroupSumFirstRoundSeconds.ValueAsInt,
            RoundSeconds = spinButtonGroupSumRoundSeconds.ValueAsInt,
            RangeStart = spinButtonGroupSumRangeStart.ValueAsInt,
            RangeEnd = spinButtonGroupSumRangeEnd.ValueAsInt,
            ShowNumericFeedback = checkButtonGroupSumNumericFeedback.Active,
            UsePreviousRoundInput = checkbuttonGroupSumPreviousInput.Active
              };
              break;

            case 4:
              var foragerInfo = new ForagerGameInfo()
              {
            Plots = spinButtonForagerPlots.ValueAsInt,
            TravelTime = spinButtonForagerTravelTime.ValueAsInt,
            FoodRate = spinButtonForagerFoodRate.ValueAsInt,
            GameSeconds = spinButtonForagerGameMinutes.ValueAsInt * 60,
              };

              foreach (var plotProbabilities in foragerProbabilities)
              {
            foragerInfo.PlotProbabilities.Add(plotProbabilities.ToList());
              }

              foragerInfo.ProbabilityShiftTimes.AddRange(foragerProbabilityShiftTimes.ToList());

              gameInfo = foragerInfo;
              break;
              }

              if (gameInfo != null)
              {
            gameInfo.GameDescription = entryGameDescription.Text;
              }

              return (gameInfo);
        }