Esempio n. 1
0
        public override void Initialize(HandlerData handlerData, UserGameInfo game, GameProfile profile)
        {
            base.Initialize(handlerData, game, profile);

            gamepadTimer.Enabled = true;
            UpdatePlayers();
        }
Esempio n. 2
0
        /// <summary>
        /// Backups a file at the specified path for later retrieval
        /// </summary>
        /// <param name="game"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public BackupFile BackupFile(HandlerData game, string path)
        {
            string appData     = GameManager.GetAppDataPath();
            string gamePath    = Path.Combine(appData, game.GameID);
            string destination = Path.Combine(gamePath, Path.GetFileName(path));

            if (!File.Exists(path))
            {
                if (File.Exists(destination))
                {
                    // we f****d up and the backup exists? maybe, so restore
                    File.Copy(destination, path);
                }
            }
            else
            {
                if (File.Exists(destination))
                {
                    File.Delete(destination);
                }
                File.Copy(path, destination);
            }

            BackupFile bkp = new BackupFile(path, destination);

            backupFiles.Add(bkp);

            return(bkp);
        }
Esempio n. 3
0
        /// <summary>
        /// Begins a game session for backup
        /// </summary>
        /// <param name="game"></param>
        public void BeginBackup(HandlerData game)
        {
            string appData  = GameManager.GetAppDataPath();
            string gamePath = Path.Combine(appData, game.GameID);

            Directory.CreateDirectory(gamePath);

            backupFiles = new List <BackupFile>();
        }
Esempio n. 4
0
        private void Initialize(GameHandlerMetadata metadata, string jsCode)
        {
            this.handlerMetadata = metadata;

            jsEngine = new HandlerDataEngine(metadata, jsCode);

            string handlerStr = jsEngine.Initialize();

            handlerData = JsonConvert.DeserializeObject <HandlerData>(handlerStr);

            // content manager is shared withing the same game
            content = new ContentManager(metadata, handlerData);
        }
Esempio n. 5
0
        public override void Initialize(HandlerData handlerData, UserGameInfo game, GameProfile profile)
        {
            base.Initialize(handlerData, game, profile);

            this.Controls.Clear();
            canProceed = false;

            int maxPlayers = handlerData.MaxPlayers;
            int half       = (int)Math.Round(maxPlayers / 2.0);
            int width      = Size.Width / half;
            int height     = Size.Height / 2;
            int player     = 2;

            top = new List <Button>();
            bot = new List <Button>();

            int left = Math.Max(half - 1, 1);

            width = Size.Width / left;
            for (int i = 0; i < left; i++)
            {
                Button btn = MkButton();
                btn.Text = player.ToString();
                player++;

                btn.SetBounds(i * width, 0, width, height);

                top.Add(btn);
                this.Controls.Add(btn);
            }

            half  = maxPlayers - half;
            width = Size.Width / half;
            for (int i = 0; i < half; i++)
            {
                Button btn = MkButton();
                btn.Text = player.ToString();
                player++;

                btn.SetBounds(i * width, height, width, height);

                bot.Add(btn);
                this.Controls.Add(btn);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Do a backup revert
        /// </summary>
        /// <param name="game"></param>
        public void ExecuteBackup(HandlerData game)
        {
            // we didnt backup anything
            if (backupFiles == null)
            {
                return;
            }

            string appData  = GameManager.GetAppDataPath();
            string gamePath = Path.Combine(appData, game.GameID);

            for (int i = 0; i < backupFiles.Count; i++)
            {
                BackupFile bkp = backupFiles[i];
                if (File.Exists(bkp.BackupPath))
                {
                    File.Delete(bkp.Source);
                    File.Move(bkp.BackupPath, bkp.Source);
                }
            }
        }
Esempio n. 7
0
        public void InitializeDefault(HandlerData game)
        {
            if (playerData == null)
            {
                playerData = new List <PlayerInfo>();
            }

            if (screens == null)
            {
                screens = new List <UserScreen>();
            }

            if (options == null)
            {
                options = new Dictionary <string, object>();

                foreach (var opt in game.Options)
                {
                    options.Add(opt.Key, opt.Value);
                }
            }
        }
        public override void Initialize(HandlerData handlerData, UserGameInfo game, GameProfile profile)
        {
            base.Initialize(handlerData, game, profile);

            this.Controls.Clear();

            int wid = 200;

            list      = new ControlListBox();
            list.Size = this.Size;

            List <GameOption>           options = handlerData.Options;
            Dictionary <string, object> vals    = profile.Options;

            for (int j = 0; j < options.Count; j++)
            {
                GameOption opt = options[j];
                if (opt.Hidden)
                {
                    continue;
                }

                object val;
                if (!vals.TryGetValue(opt.Key, out val))
                {
                    continue;
                }

                CoolListControl cool = new CoolListControl(false);
                cool.Title       = opt.Name;
                cool.Details     = opt.Description;
                cool.Width       = list.Width;
                cool.TitleFont   = nameFont;
                cool.DetailsFont = detailsFont;

                list.Controls.Add(cool);

                // Check the value type and add a control for it
                if (opt.Value is Enum || opt.IsCollection())
                {
                    ComboBox box    = new ComboBox();
                    int      border = 10;

                    object value;
                    object defaultValue;
                    IList  values;
                    if (opt.Value is Enum)
                    {
                        value        = (Enum)val;
                        values       = Enum.GetValues(value.GetType());
                        defaultValue = opt.DefaultValue;
                    }
                    else
                    {
                        values       = opt.GetCollection();
                        value        = values[0];
                        defaultValue = opt.DefaultValue;
                    }

                    for (int i = 0; i < values.Count; i++)
                    {
                        box.Items.Add(values[i]);
                    }

                    if (defaultValue != null)
                    {
                        box.SelectedIndex = box.Items.IndexOf(defaultValue);
                        if (box.SelectedIndex == -1)
                        {
                            box.SelectedIndex = box.Items.IndexOf(value);
                        }
                    }
                    else
                    {
                        box.SelectedIndex = box.Items.IndexOf(value);
                    }

                    box.Width         = wid;
                    box.Height        = 40;
                    box.Left          = cool.Width - box.Width - border;
                    box.Top           = (cool.Height / 2) - (box.Height / 2);
                    box.Anchor        = AnchorStyles.Right;
                    box.DropDownStyle = ComboBoxStyle.DropDownList;
                    cool.Controls.Add(box);

                    box.Tag = opt;
                    box.SelectedValueChanged += box_SelectedValueChanged;
                    ChangeOption(box.Tag, box.SelectedItem);
                }
                else if (opt.Value is bool)
                {
                    SizeableCheckbox box = new SizeableCheckbox();
                    int border           = 10;

                    box.Checked = (bool)val;
                    box.Width   = 40;
                    box.Height  = 40;
                    box.Left    = cool.Width - box.Width - border;
                    box.Top     = (cool.Height / 2) - (box.Height / 2);
                    box.Anchor  = AnchorStyles.Right;
                    cool.Controls.Add(box);

                    box.Tag             = opt;
                    box.CheckedChanged += box_CheckedChanged;
                    ChangeOption(box.Tag, box.Checked);
                }
                else if (opt.Value is int || opt.Value is double)
                {
                    NumericUpDown num    = new NumericUpDown();
                    int           border = 10;

                    int value = (int)(double)val;
                    if (value < num.Minimum)
                    {
                        num.Minimum = value;
                    }

                    num.Value = value;

                    num.Width  = wid;
                    num.Height = 40;
                    num.Left   = cool.Width - num.Width - border;
                    num.Top    = (cool.Height / 2) - (num.Height / 2);
                    num.Anchor = AnchorStyles.Right;
                    cool.Controls.Add(num);

                    num.Tag           = opt;
                    num.ValueChanged += num_ValueChanged;
                    ChangeOption(num.Tag, num.Value);
                }
                else if (opt.Value is GameOptionValue)
                {
                    ComboBox box    = new ComboBox();
                    int      border = 10;

                    GameOptionValue value = (GameOptionValue)val;
                    PropertyInfo[]  props = value.GetType().GetProperties(BindingFlags.Public | BindingFlags.Static);

                    for (int i = 0; i < props.Length; i++)
                    {
                        PropertyInfo prop = props[i];
                        box.Items.Add(prop.GetValue(null, null));
                    }
                    box.SelectedIndex = box.Items.IndexOf(value);

                    box.Width  = wid;
                    box.Height = 40;
                    box.Left   = cool.Width - box.Width - border;
                    box.Top    = (cool.Height / 2) - (box.Height / 2);
                    box.Anchor = AnchorStyles.Right;
                    //box.DropDownStyle = ComboBoxStyle.DropDownList;
                    cool.Controls.Add(box);

                    box.Tag = opt;
                    box.SelectedValueChanged += box_SelectedValueChanged;
                    ChangeOption(box.Tag, box.SelectedItem);
                }
            }

            this.Controls.Add(list);
            list.UpdateSizes();
            CanPlayUpdated(true, false);
        }
Esempio n. 9
0
        public static string GetTempFolder(HandlerData game)
        {
            string appData = GetAppDataPath();

            return(Path.Combine(appData, "Temp", game.GameID));
        }
Esempio n. 10
0
 public virtual void Initialize(HandlerData handlerData, UserGameInfo game, GameProfile profile)
 {
     this.handlerData = handlerData;
     this.profile     = profile;
     this.game        = game;
 }
Esempio n. 11
0
        public string GempTempFolder(HandlerData game)
        {
            string appData = GetAppDataPath();

            return(Path.Combine(appData, game.GUID));
        }
Esempio n. 12
0
 public GenericGameHandler MakeHandler(HandlerData game)
 {
     return((GenericGameHandler)Activator.CreateInstance(game.HandlerType));
 }
Esempio n. 13
0
 public abstract bool Initialize(GameHandler handler, HandlerData handlerData, UserGameInfo game, GameProfile profile);