コード例 #1
0
        public bool Initialize(UserGameInfo game, GameProfile profile)
        {
            this.userGame = game;
            this.profile  = profile;

            // see if we have any save game to backup
            gen = game.Game as GenericGameInfo;
            if (gen == null)
            {
                // you f****d up
                return(false);
            }

            if (gen.LockMouse)
            {
                _cursorModule = new CursorModule();
            }

            jsData = new Dictionary <string, string>();
            jsData.Add(Folder.Documents.ToString(), Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
            jsData.Add(Folder.MainGameFolder.ToString(), Path.GetDirectoryName(game.ExePath));
            jsData.Add(Folder.InstancedGameFolder.ToString(), Path.GetDirectoryName(game.ExePath));

            timerInterval = gen.HandlerInterval;

            Log.RegisterForLogCallback(this);

            return(true);
        }
コード例 #2
0
        public bool Initialize(UserGameInfo game, GameProfile profile)
        {
            this.userGame = game;
            this.profile = profile;

            // see if we have any save game to backup
            gen = game.Game as GenericGameInfo;
            if (gen == null)
            {
                // you f****d up
                return false;
            }

            engine = new Engine();
            engine.SetValue("Options", profile.Options);

            data = new Dictionary<string, string>();
            data.Add(NucleusFolderEnum.GameFolder.ToString(), Path.GetDirectoryName(game.ExePath));

            if (gen.SaveType == GenericGameSaveType.None)
            {
                return true;
            }

            string saveFile = ProcessPath(gen.SavePath);
            GameManager.Instance.BeginBackup(game.Game);
            GameManager.Instance.BackupFile(game.Game, saveFile);

            return true;
        }
コード例 #3
0
        public void Initialize(UserGameInfo game, GameProfile profile)
        {
            string documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string configFolder = Path.Combine(documents, @"My Games\Borderlands 2\WillowGame\SaveData");
            DirectoryInfo[] userDirs = new DirectoryInfo(configFolder).GetDirectories();

            for (int i = 0; i < userDirs.Length; i++)
            {
                DirectoryInfo user = userDirs[i];

                FileInfo[] saves = user.GetFiles("*.sav");
                for (int j = 0; j < saves.Length; j++)
                {
                    FileInfo save = saves[j];

                    BorderlandsSaveControl con = new BorderlandsSaveControl();
                    using (Stream s = save.OpenRead())
                    {
                        con.SaveFile = SaveFile.Deserialize(s, SaveFile.DeserializeSettings.None);
                    }

                    con.UserName = user.Name;
                    //con.SaveName = con.SaveFile.SaveGame.AppliedCustomizations;
                    this.flowLayoutPanel1.Controls.Add(con);
                }
            }
        }
コード例 #4
0
        public bool Initialize(UserGameInfo game, GameProfile profile)
        {
            this.userGame = game;
            this.profile  = profile;

            // see if we have any save game to backup
            gen = game.Game as GenericGameInfo;
            if (gen == null)
            {
                // you f****d up
                return(false);
            }

            engine = new Engine();
            engine.SetValue("Options", profile.Options);

            data = new Dictionary <string, string>();
            data.Add(NucleusFolderEnum.GameFolder.ToString(), Path.GetDirectoryName(game.ExePath));

            if (gen.SaveType == GenericGameSaveType.None)
            {
                return(true);
            }

            string saveFile = ProcessPath(gen.SavePath);

            GameManager.Instance.BeginBackup(game.Game);
            GameManager.Instance.BackupFile(game.Game, saveFile);

            return(true);
        }
コード例 #5
0
 public PresetsForm(UserGameInfo info, List<PlayerInfo> playas, Dictionary<string, GameOption> options)
 {
     this.info = info;
     this.players = playas;
     this.options = options;
     InitializeComponent();
 }
コード例 #6
0
ファイル: GameManager.cs プロジェクト: tsiryJL/nucleuscoop
 public int Compare(UserGameInfo x, UserGameInfo y)
 {
     if (x.Game == null || y.Game == null)
     {
         return(0);
     }
     return(x.Game.GameName.CompareTo(y.Game.GameName));
 }
コード例 #7
0
ファイル: GameManager.cs プロジェクト: tsiryJL/nucleuscoop
        /// <summary>
        /// Tries adding a game to the collection with the provided executable path
        /// </summary>
        /// <param name="exePath"></param>
        /// <returns></returns>
        public UserGameInfo TryAddGame(string exePath)
        {
            string lower    = exePath.ToLower();
            string fileName = Path.GetFileName(exePath).ToLower();
            string dir      = Path.GetDirectoryName(exePath);

            var possibilities = Games.Values.Where(c => c.ExecutableName.ToLower() == fileName);

            foreach (GenericGameInfo game in possibilities)
            {
                // check if the Context matches
                string[] context = game.ExecutableContext;
                bool     notAdd  = false;
                if (context != null)
                {
                    for (int j = 0; j < context.Length; j++)
                    {
                        string con = Path.Combine(dir, context[j]);
                        if (!File.Exists(con) &&
                            !Directory.Exists(con))
                        {
                            notAdd = true;
                            break;
                        }
                    }
                }

                if (notAdd)
                {
                    continue;
                }

                // search for the same exe on the user profile
                if (GameManager.Instance.User.Games.Any(c => c.ExePath.ToLower() == lower))
                {
                    continue;
                }

#if RELEASE
                if (game.Debug)
                {
                    continue;
                }
#endif

                LogManager.Log("Found game: {0}, full path: {1}", game.GameName, exePath);
                UserGameInfo uinfo = new UserGameInfo();
                uinfo.InitializeDefault(game, exePath);
                GameManager.Instance.User.Games.Add(uinfo);
                GameManager.Instance.SaveUserProfile();

                return(uinfo);
            }

            return(null);
        }
コード例 #8
0
ファイル: GameManager.cs プロジェクト: tsiryJL/nucleuscoop
        public UserGameInfo AddGame(GenericGameInfo game, string exePath)
        {
            UserGameInfo gInfo = new UserGameInfo();

            gInfo.InitializeDefault(game, exePath);
            user.Games.Add(gInfo);

            SaveUserProfile();

            return(gInfo);
        }
コード例 #9
0
        public bool Initialize(UserGameInfo game, GameProfile profile)
        {
            this.executablePlace = game.ExePath;
            this.profile = profile;
            this.userGame = game;

            // Let's search for the save file
            string documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string configFolder;

            if (game.Game.GUID == "E1CCA90A-7B48-4F3A-8F19-FD61B32A0F83")
            {
                // borderlands pre-sequel
                configFolder = Path.Combine(documents, @"My Games\Borderlands The Pre-Sequel\WillowGame\Config");
            }
            else
            {
                // borderlands 2
                configFolder = Path.Combine(documents, @"My Games\Borderlands 2\WillowGame\Config");
            }
            string willowEngine = Path.Combine(configFolder, "WillowEngine.ini");

            if (File.Exists(willowEngine))
            {
                saveFile = willowEngine;
            }
            else
            {
                MessageBox.Show("Could not find WillowEngine.ini file!");

                using (OpenFileDialog open = new OpenFileDialog())
                {
                    open.Filter = "WillowEngine.ini file|WillowEngine.ini";
                    if (open.ShowDialog() == DialogResult.OK)
                    {
                        saveFile = open.FileName;
                    }
                    else
                    {
                        return false;
                    }
                }
            }

            // backup the WillowEngine ini
            GameManager.Instance.StartBackup(game.Game);
            GameManager.Instance.BackupFile(game.Game, willowEngine);

            return true;
        }
コード例 #10
0
ファイル: GameManager.cs プロジェクト: Challak/nucleuscoop
        private void LoadUser()
        {
            string userProfile = GetUserProfilePath();

            if (File.Exists(userProfile))
            {
                try
                {
                    using (FileStream stream = new FileStream(userProfile, FileMode.Open))
                    {
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            string json = reader.ReadToEnd();
                            user = JsonConvert.DeserializeObject <UserProfile>(json);

                            if (user.Games == null)
                            {
                                // json doesn't save empty lists, and user didn't add any game
                                user.InitializeDefault();
                            }
                            else
                            {
                                // delete invalid games
                                for (int i = 0; i < user.Games.Count; i++)
                                {
                                    UserGameInfo gameInfo = user.Games[i];
                                    if (gameInfo.Game == null)
                                    {
                                        user.Games.RemoveAt(i);
                                        i--;
                                    }
                                }
                            }
                        }
                    }
                }
                catch
                {
                    makeDefaultUserFile();
                }
            }
            else
            {
                makeDefaultUserFile();
            }
        }
コード例 #11
0
        public override void Initialize(UserGameInfo game, GameProfile profile)
        {
            base.Initialize(game, profile);

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

            int maxPlayers = game.Game.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);
            }
        }
コード例 #12
0
ファイル: GameManager.cs プロジェクト: Challak/nucleuscoop
        /// <summary>
        /// Tries adding a game to the collection with the provided IGameInfo
        /// </summary>
        /// <param name="exePath"></param>
        /// <returns></returns>
        public UserGameInfo TryAddGame(string exePath, GenericGameInfo game)
        {
            string lower = exePath.ToLower();

            // search for the same exe on the user profile
            if (GameManager.Instance.User.Games.Any(c => c.ExePath.ToLower() == lower))
            {
                return(null);
            }

            LogManager.Log("Found game: {0}, full path: {1}", game.GameName, exePath);
            UserGameInfo uinfo = new UserGameInfo();

            uinfo.InitializeDefault(game, exePath);
            GameManager.Instance.User.Games.Add(uinfo);
            GameManager.Instance.SaveUserProfile();

            return(uinfo);
        }
コード例 #13
0
        public bool Initialize(UserGameInfo game, GameProfile profile)
        {
            this.userGame = game;
            this.profile  = profile;

            // see if we have any save game to backup
            gen = game.Game as GenericGameInfo;
            if (gen == null)
            {
                // you f****d up
                return(false);
            }

            data = new Dictionary <string, string>();
            data.Add(Folder.Documents.ToString(), Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
            data.Add(Folder.GameFolder.ToString(), Path.GetDirectoryName(game.ExePath));

            return(true);
        }
コード例 #14
0
        public void NewUserGame(UserGameInfo game)
        {
            if (noGamesPresent)
            {
                this.list_Games.Controls.Clear();
                noGamesPresent = false;
            }

            GameControl con = new GameControl();
            con.Game = game;
            con.Width = list_Games.Width;

            controls.Add(game, con);

            con.Text = game.Game.GameName;
            ThreadPool.QueueUserWorkItem(GetIcon, game);

            this.list_Games.Controls.Add(con);
        }
コード例 #15
0
        public bool Initialize(UserGameInfo game, GameProfile profile)
        {
            this.executablePlace = game.ExePath;
            this.profile = profile;
            this.userGame = game;

            delayTime = (int)((double)profile.Options["delay"] * 1000);

            // Let's search for the save file
            string documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string myGames = Path.Combine(documents, @"My Games\Borderlands The Pre-Sequel\WillowGame\Config");
            string willowEngine = Path.Combine(myGames, "WillowEngine.ini");

            if (File.Exists(willowEngine))
            {
                saveFile = willowEngine;
            }
            else
            {
                MessageBox.Show("Could not find WillowEngine.ini file!");

                using (OpenFileDialog open = new OpenFileDialog())
                {
                    open.Filter = "WillowEngine.ini file|WillowEngine.ini";
                    if (open.ShowDialog() == DialogResult.OK)
                    {
                        saveFile = open.FileName;
                    }
                    else
                    {
                        return false;
                    }
                }
            }

            // backup the WillowEngine ini
            GameManager.Instance.StartBackup(game.Game);
            GameManager.Instance.BackupFile(game.Game, willowEngine);

            return true;
        }
コード例 #16
0
        public void Initialize(UserGameInfo game, GameProfile profile)
        {
            this.profile = profile;

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

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

            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);
                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);
                this.Controls.Add(btn);
            }
        }
コード例 #17
0
ファイル: GameManager.cs プロジェクト: tsiryJL/nucleuscoop
        /// <summary>
        /// Tries adding a game to the collection with the provided IGameInfo
        /// </summary>
        /// <param name="exePath"></param>
        /// <returns></returns>
        public UserGameInfo TryAddGame(string exePath, GenericGameInfo game)
        {
            string lower = exePath.ToLower();

            // search for the same exe on the user profile
            if (GameManager.Instance.User.Games.Any(c => c.ExePath.ToLower() == lower))
            {
                DialogResult dialogResult = MessageBox.Show("This game's executable is already in your library. Do you wish to add it anyway?\n\nExecutable Path: " + exePath, "Already exists", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dialogResult == DialogResult.No)
                {
                    return(null);
                }
            }

            LogManager.Log("Found game: {0}, full path: {1}", game.GameName, exePath);
            UserGameInfo uinfo = new UserGameInfo();

            uinfo.InitializeDefault(game, exePath);
            GameManager.Instance.User.Games.Add(uinfo);
            GameManager.Instance.SaveUserProfile();

            return(uinfo);
        }
コード例 #18
0
        public void Initialize(UserGameInfo game, GameProfile profile)
        {
            this.profile = profile;

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

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

            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);
                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);
                this.Controls.Add(btn);
            }
        }
コード例 #19
0
        public bool Initialize(HandlerData handlerData, UserGameInfo game, GameProfile profile)
        {
            this.userGame = game;
            this.profile  = profile;

            // see if we have any save game to backup
            this.handlerData = handlerData;

            if (this.handlerData.LockMouse)
            {
                _cursorModule = new CursorModule();
            }

            jsData = new Dictionary <string, string>();
            jsData.Add(Folder.Documents.ToString(), Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
            jsData.Add(Folder.MainGameFolder.ToString(), Path.GetDirectoryName(game.ExePath));
            jsData.Add(Folder.InstancedGameFolder.ToString(), "");

            timerInterval = this.handlerData.HandlerInterval;

            Log.RegisterForLogCallback(this);

            return(true);
        }
コード例 #20
0
        /// <summary>
        /// Handles updating the game's image and info when the user selects a different game
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void list_Games_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!(list_Games.SelectedItem is UserGameInfo))
            {
                return;
            }

            ResetSteps();
            step = 0;
            UpdateStep();

            info = (UserGameInfo)list_Games.SelectedItem;
            gameInfo = gameManager.Games[info.GameGuid];

            // Remove game from library if not found
            if (!File.Exists(info.ExecutablePath))
            {
                MessageBox.Show("Game Executable not Found. Deleting game from your library. TO-DO: User might have game on a disconnected hard-drive. Handle that.");

                gameManager.User.Games.Remove(info);
                gameManager.UpdateUserProfile();

                info = null;
                gameInfo = null;

                list_Games.DataSource = null;
                list_Games.SelectedIndex = -1;
                list_Games.DataSource = gameManager.User.Games;

                if (list_Games.Items.Count > 0)
                {
                    list_Games.SelectedIndex = 0;
                }
                return;
            }

            label_GameName.Text = info.GameName;
            playerCount1.MaxPlayers = gameInfo.MaxPlayers;
            label_maxPlayas.Text = gameInfo.MaxPlayers.ToString();
            if (gameInfo.SupportsKeyboard)
            {
                pic_Keyboard.Image = Resources.keyboard;
            }
            else
            {
                pic_Keyboard.Image = Resources.no_keyboard;
            }


            monitorControl1.UpdatePlayerCount(playerCount1.Players, gameInfo, info);
            playerOptions1.UpdateItems(gameInfo);

            addSteps.Clear();
            if (gameInfo.Steps != null)
            {
                // Add custom steps the game might need
                int count = steps.Count;
                for (int i = 0; i < gameInfo.Steps.Length; i++)
                {
                    Control s = (Control)Activator.CreateInstance(gameInfo.Steps[i]);
                    s.Location = this.monitorControl1.Location;
                    s.Size = this.monitorControl1.Size;
                    s.Anchor = this.monitorControl1.Anchor;
                    borderPanel1.Controls.Add(s);
                    steps.Add(count + i, s);

                    addSteps.Add(s);
                }
            }
            else
            {
                // Delete any old files
                if (steps.Count > DefaultSteps)
                {
                    int count = steps.Count;
                    for (int i = DefaultSteps; i < count; i++)
                    {
                        borderPanel1.Controls.Remove(steps[i]);
                        steps.Remove(i);
                    }
                }
            }

            // Extract icon from game executable
            if (this.game_Box.Image != null)
            {
                this.game_Box.Image.Dispose();
            }
            using (Icon sysicon = Icon.ExtractAssociatedIcon(info.ExecutablePath))
            {
                using (MemoryStream str = new MemoryStream())
                {
                    sysicon.Save(str);
                    str.Position = 0;
                    game_Box.Image = Image.FromStream(str);
                }
            }
        }
コード例 #21
0
        public UserGameInfo AddGame(GameInfo game, string exePath)
        {
            UserGameInfo gInfo = new UserGameInfo();
            gInfo.InitializeDefault(game, exePath);
            user.Games.Add(gInfo);

            SaveUserProfile();

            return gInfo;
        }
コード例 #22
0
 public int Compare(UserGameInfo x, UserGameInfo y)
 {
     return x.Game.GameName.CompareTo(y.Game.GameName);
 }
コード例 #23
0
        /// <summary>
        /// Tries adding a game to the collection with the provided executable path
        /// </summary>
        /// <param name="exePath"></param>
        /// <returns></returns>
        public UserGameInfo TryAddGame(string exePath)
        {
            string lower = exePath.ToLower();
            string fileName = Path.GetFileName(exePath).ToLower();
            string dir = Path.GetDirectoryName(exePath);

            var possibilities = Games.Values.Where(c => c.ExecutableName == fileName);

            foreach (GameInfo game in possibilities)
            {
                // check if the Context matches
                string[] context = game.ExecutableContext.Split(';');
                bool notAdd = false;
                for (int j = 0; j < context.Length; j++)
                {
                    string con = Path.Combine(dir, context[j]);
                    if (!File.Exists(con) &&
                        !Directory.Exists(con))
                    {
                        notAdd = true;
                        break;
                    }
                }

                if (notAdd)
                {
                    continue;
                }

                // search for the same exe on the user profile
                if (GameManager.Instance.User.Games.Any(c => c.ExePath.ToLower() == lower))
                {
                    continue;
                }

                LogManager.Log("Found game: {0}, full path: {1}", game.GameName, exePath);
                UserGameInfo uinfo = new UserGameInfo();
                uinfo.InitializeDefault(game, exePath);
                GameManager.Instance.User.Games.Add(uinfo);
                GameManager.Instance.SaveUserProfile();

                return uinfo;
            }

            return null;
        }
コード例 #24
0
        public void Initialize(UserGameInfo game, GameProfile profile)
        {
            this.profile = profile;
            this.Controls.Clear();

            var options = game.Game.Options;
            var vals = profile.Options;
            foreach (var opt in options)
            {
                CoolListControl cool = new CoolListControl();
                cool.Text = opt.Value.Name;
                cool.Description = opt.Value.Description;
                cool.Width = this.Width;

                this.Controls.Add(cool);

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

                    box.Checked = (bool)vals[opt.Key];
                    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.AddControl(box, false);

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

                    num.Value = (int)vals[opt.Key];

                    num.Width = 150;
                    num.Height = 40;
                    num.Left = cool.Width - num.Width - border;
                    num.Top = (cool.Height / 2) - (num.Height / 2);
                    num.Anchor = AnchorStyles.Right;
                    cool.AddControl(num, false);

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

                    Enum value = (Enum)vals[opt.Key];
                    Array values = Enum.GetValues(value.GetType());
                    for (int i = 0; i < values.Length; i++)
                    {
                        box.Items.Add(((IList)values)[i]);
                    }
                    box.SelectedIndex = box.Items.IndexOf(value);

                    box.Width = 150;
                    box.Height = 40;
                    box.Left = cool.Width - box.Width - border;
                    box.Top = (cool.Height / 2) - (box.Height / 2);
                    box.Anchor = AnchorStyles.Right;
                    cool.AddControl(box, false);

                    box.Tag = opt;
                    box.SelectedValueChanged += box_SelectedValueChanged;
                }
            }

            UpdateSizes();
        }
コード例 #25
0
        private void btn_Add_Click(object sender, EventArgs e)
        {
            if (this.list_Games.CheckedItems != null &&
                this.list_Games.CheckedItems.Count > 0)
            {
                var selected = this.list_Games.CheckedItems;
                UserProfile user = gameManager.User;

                bool added = false;
                for (int i = 0; i < selected.Count; i++)
                {
                    var sel = selected[i];
                    string path = sel.Text;

                    // Search for that specific EXE on every of the users games
                    path = path.ToLower();
                    string fileName = Path.GetFileName(path);
                    bool repeats = false;
                    for (int j = 0; j < user.Games.Count; j++)
                    {
                        var game = user.Games[j];
                        if (game.ExecutablePath == path)
                        {
                            repeats = true;
                            MessageBox.Show("The game '" + fileName + "' is already on your library");
                            break;
                        }
                    }

                    // Now look if that game is split-screen supported
                    bool foundInfo = false;
                    string gameName = null;
                    string guid = null;
                    foreach (var gameInfo in gameManager.Games.Values)
                    {
                        string[] exec = gameInfo.ExecutableName.Split('|');

                        bool found = false;
                        for (int j = 0; j < exec.Length; j++)
                        {
                            string name = exec[j];
                            if (name == fileName)
                            {
                                gameName = gameInfo.GameName;
                                foundInfo = true;
                                guid = gameInfo.GUID;
                                found = true;
                                break;
                            }
                        }

                        if (found)
                        {
                            break;
                        }
                    }

                    if (foundInfo)
                    {
                        if (!repeats)
                        {
                            // add to library
                            UserGameInfo info = new UserGameInfo();
                            info.ExecutablePath = path;
                            info.GameName = gameName;
                            info.GameGuid = guid;
                            user.Games.Add(info);
                            added = true;
                        }
                    }
                    else
                    {
                        MessageBox.Show("The game '" + fileName + "' is not support for SplitScreen");
                    }
                }

                if (added)
                {
                    gameManager.UpdateUserProfile();
                }
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
コード例 #26
0
        public override void Initialize(UserGameInfo game, GameProfile profile)
        {
            base.Initialize(game, profile);

            this.Controls.Clear();

            int wid = 200;

            list = new ControlListBox();
            GameOption[] options             = game.Game.Options;
            Dictionary <string, object> vals = profile.Options;

            for (int j = 0; j < options.Length; j++)
            {
                GameOption opt = options[j];

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

                CoolListControl cool = new CoolListControl();
                cool.Text        = opt.Name;
                cool.Description = opt.Description;
                cool.Width       = this.Width;

                list.Controls.Add(cool);

                // Check the value type and add a control for it
                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.AddControl(box, false);

                    box.Tag             = opt;
                    box.CheckedChanged += box_CheckedChanged;
                }
                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.AddControl(num, false);

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

                    Enum  value  = (Enum)val;
                    Array values = Enum.GetValues(value.GetType());
                    for (int i = 0; i < values.Length; i++)
                    {
                        box.Items.Add(((IList)values)[i]);
                    }
                    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;
                    cool.AddControl(box, false);

                    box.Tag = opt;
                    box.SelectedValueChanged += box_SelectedValueChanged;
                }
                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;
                    cool.AddControl(box, false);

                    box.Tag = opt;
                    box.SelectedValueChanged += box_SelectedValueChanged;
                }
            }

            list.Size = this.Size;
            this.Controls.Add(list);

            list.UpdateSizes();
            OnCanPlayTrue(false);
        }
コード例 #27
0
        public void UpdatePlayerCount(int player, GameInfo info, UserGameInfo userGame)
        {
            this.info = info;
            this.userGameInfo = userGame;
            if (info == null)
            {
                return;
            }

            if (player != playerCount || reset)
            {
                // Clean players!
                playerCount = player;
                players.Clear();
                for (int i = 0; i < loaded_screens.Count; i++)
                {
                    var mscreen = loaded_screens[i];
                    for (int j = 0; j < mscreen.Controls.Count; j++)
                    {
                        Control con = mscreen.Controls[j];

                        if (con is PlayerControl)
                        {
                            mscreen.Controls.Remove(con);
                            j--;
                        }
                    }
                }

                // remake monitors
                MakeContextStrip();
                MakeMonitors();
            }

            for (int i = 0; i < screenStrip.Items.Count; i++)
            {
                var item = screenStrip.Items[i];
                item.Enabled = i < player;
            }

            if (reset)
            {
                if (info.NeedPositioning)
                {
                    if (posLabel != null && panel1.Controls.Contains(posLabel))
                    {
                        panel1.Controls.Remove(posLabel);
                    }
                }
                else
                {
                    panel1.Controls.Clear();

                    posLabel = new Label();
                    posLabel.Text = "The selected game does not support positioning";
                    posLabel.Width = 500;
                    posLabel.Font = this.Font;

                    panel1.Controls.Add(posLabel);
                }
            }
            reset = false;
        }
コード例 #28
0
        public override void Initialize(HandlerData handlerData, UserGameInfo game, GameProfile profile)
        {
            base.Initialize(handlerData, game, profile);

            Controls.Clear();

            // grab the CustomStep and extract what we have to show from it
            GameOption option = CustomStep.Option;

            if (option.IsCollection())
            {
                ControlListBox list = new ControlListBox();
                list.Size       = this.Size;
                list.AutoScroll = true;

                Controls.Add(list);

                collection = option.GetCollection();
                for (int i = 0; i < collection.Count; i++)
                {
                    object val = collection[i];

                    // TODO: make image options
                    if (!(val is IDictionary <string, JToken>))
                    {
                        continue;
                    }

                    CoolListControl control = new CoolListControl(true);
                    control.Anchor      = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
                    control.BackColor   = Color.FromArgb(30, 30, 30);
                    control.Size        = new Size(list.Width, 120);
                    control.Data        = val;
                    control.OnSelected += Control_OnSelected;

                    IDictionary <string, JToken> value = (IDictionary <string, JToken>)val;
                    string name = value["Name"].ToString();

                    control.Title       = name;
                    control.TitleFont   = nameFont;
                    control.DetailsFont = detailsFont;

                    string details = "";
                    JToken detailsObj;
                    if (value.TryGetValue("Details", out detailsObj))
                    {
                        details = detailsObj.ToString();

                        control.Details = details;
                    }

                    JToken imageUrlObj;
                    value.TryGetValue("ImageUrl", out imageUrlObj);
                    if (imageUrlObj != null)
                    {
                        string imageUrl = imageUrlObj.ToString();
                        if (!string.IsNullOrEmpty(imageUrl))
                        {
                            Image img = DataManager.Content.LoadImage(imageUrl);

                            PictureBox box = new PictureBox();
                            box.Anchor   = AnchorStyles.Top | AnchorStyles.Right;
                            box.Size     = new Size(140, 80);
                            box.Location = new Point(list.Width - box.Width - 10, 20);
                            box.SizeMode = PictureBoxSizeMode.Zoom;
                            box.Image    = img;
                            control.Controls.Add(box);
                        }
                    }

                    list.Controls.Add(control);
                }
            }
            else
            {
            }
        }
コード例 #29
0
        public void Initialize(UserGameInfo game, GameProfile profile)
        {
            this.profile = profile;
            this.Controls.Clear();

            var options = game.Game.Options;
            var vals    = profile.Options;

            foreach (var opt in options)
            {
                CoolListControl cool = new CoolListControl();
                cool.Text        = opt.Value.Name;
                cool.Description = opt.Value.Description;
                cool.Width       = this.Width;

                this.Controls.Add(cool);

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

                    box.Checked = (bool)vals[opt.Key];
                    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.AddControl(box, false);

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

                    num.Value = (int)vals[opt.Key];

                    num.Width  = 150;
                    num.Height = 40;
                    num.Left   = cool.Width - num.Width - border;
                    num.Top    = (cool.Height / 2) - (num.Height / 2);
                    num.Anchor = AnchorStyles.Right;
                    cool.AddControl(num, false);

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

                    Enum  value  = (Enum)vals[opt.Key];
                    Array values = Enum.GetValues(value.GetType());
                    for (int i = 0; i < values.Length; i++)
                    {
                        box.Items.Add(((IList)values)[i]);
                    }
                    box.SelectedIndex = box.Items.IndexOf(value);

                    box.Width  = 150;
                    box.Height = 40;
                    box.Left   = cool.Width - box.Width - border;
                    box.Top    = (cool.Height / 2) - (box.Height / 2);
                    box.Anchor = AnchorStyles.Right;
                    cool.AddControl(box, false);

                    box.Tag = opt;
                    box.SelectedValueChanged += box_SelectedValueChanged;
                }
            }

            UpdateSizes();
        }
コード例 #30
0
        private void list_Games_SelectedChanged(object arg1, Control arg2)
        {
            currentControl = (GameControl)arg1;
            currentGameInfo = currentControl.Game;
            if (currentGameInfo == null)
            {
                return;
            }

            if (!setSize)
            {
                this.Size = defaultSize;
                setSize = true;
            }

            panelGameName.Visible = true;
            label_StepTitle.Visible = true;
            StepPanel.Visible = true;
            btnBack.Visible = true;
            btnNext.Visible = true;

            currentGame = currentGameInfo.Game;

            btn_Play.Enabled = false;

            if (currentGame.Steps == null ||
                currentStepIndex == currentGame.Steps.Length)
            {
                // can play
                btn_Play.Enabled = true;

                // remove the current step if there's one
                KillCurrentStep();

                btnBack.Visible = false;
                btnNext.Visible = false;
            }

            currentProfile = new GameProfile();
            currentProfile.InitializeDefault(currentGame);

            this.label_GameTitle.Text = currentGame.GameName;
            this.pic_Game.Image = currentGameInfo.Icon;

            Type[] steps = currentGame.Steps;
            if (steps != null && steps.Length > 0)
            {
                GoToStep(0);
            }
        }
コード例 #31
0
 public virtual void Initialize(UserGameInfo game, GameProfile profile)
 {
     this.profile = profile;
     this.game    = game;
 }
コード例 #32
0
 public void UpdateSelectedGame(int players, GameInfo info, UserGameInfo uInfo)
 {
 }
コード例 #33
0
ファイル: MainForm.cs プロジェクト: Andy----/nucleuscoop
        public void ScanExes()
        {
            DriveInfo[] drives = DriveInfo.GetDrives();
            Stopwatch stop = new Stopwatch();

            for (int i = 0; i < drives.Length; i++)
            {
                DriveInfo d = drives[i];

                if (d.DriveFormat != "NTFS")
                {
                    continue;
                }

                LogManager.Log("> Searching drive {0} for game executables", d.Name);

                stop.Reset();
                stop.Start();

                Dictionary<ulong, FileNameAndParentFrn> mDict = new Dictionary<ulong, FileNameAndParentFrn>();
                MFTReader mft = new MFTReader();
                mft.Drive = d.RootDirectory.FullName;

                mft.EnumerateVolume(out mDict, new string[] { ".exe" });
                foreach (KeyValuePair<UInt64, FileNameAndParentFrn> entry in mDict)
                {
                    FileNameAndParentFrn file = (FileNameAndParentFrn)entry.Value;

                    string name = file.Name;
                    string lower = name.ToLower();

                    GameInfo game;
                    if (gameManager.GameInfos.TryGetValue(lower, out game))
                    {
                        string path = mft.GetFullPath(file);
                        LogManager.Log("Found game: {0}, full path: {1}", game.GameName, path);

                        UserGameInfo info = new UserGameInfo();
                        info.InitializeDefault(game, path);
                        gameManager.User.Games.Add(info);
                    }
                }

                stop.Stop();
                LogManager.Log("> Took {0} seconds to search drive {1}", stop.Elapsed.TotalSeconds.ToString("0.00"), d.Name);
            }

            gameManager.SaveUserProfile();
            gameManager.WaitSave();
        }
コード例 #34
0
ファイル: GameManager.cs プロジェクト: Flllexa/nucleuscoop
 public int Compare(UserGameInfo x, UserGameInfo y)
 {
     return(x.Game.GameName.CompareTo(y.Game.GameName));
 }
コード例 #35
0
        public void Initialize(UserGameInfo game, GameProfile profile)
        {
            this.profile = profile;
            profile.PlayerData.Clear();// reset profile

            playerFont = new Font("Segoe UI", 40);
            playerTextFont = new Font("Segoe UI", 18);

            RemoveFlicker();

            float playersWidth = this.Width * 0.5f;

            int playerCount = profile.PlayerCount;
            float playerWidth = (playersWidth * 0.9f) / (float)playerCount;
            float playerHeight = playerWidth * 0.5625f;
            float offset = (playersWidth * 0.1f) / (float)playerCount;
            playersArea = new RectangleF(50, 100, playersWidth, playerHeight);

            for (int i = 0; i < playerCount; i++)
            {
                Rectangle r = new Rectangle((int)(50 + ((playerWidth + offset) * i)), 100, (int)playerWidth, (int)playerHeight);
                PlayerInfo playa = new PlayerInfo();
                playa.editBounds = r;
                profile.PlayerData.Add(playa);
            }

            screens = ScreensUtil.AllScreens();
            Rectangle totalBounds = RectangleUtil.Union(ScreensUtil.AllScreensRec());

            // see if most screens are either vertical or horizontal
            int vertical = 0;
            int horizontal = 0;
            for (int i = 0; i < screens.Length; i++)
            {
                UserScreen s = screens[i];
                if (s.bounds.Width > s.bounds.Height)
                {
                    horizontal++;
                }
                else
                {
                    vertical++;
                }
            }


            if (horizontal > vertical)
            {
                // horizontal setup
                scale = (this.Width * 0.9f) / (float)totalBounds.Width;
            }
            else
            {
                // vertical setup
                scale = (this.Height * 0.6f) / (float)totalBounds.Height;
                //scale = (this.Width * 0.9f) / (float)totalBounds.Width;
            }

            totalBounds = new Rectangle(
                (int)(totalBounds.X * scale),
                (int)(totalBounds.Y * scale),
                (int)(totalBounds.Width * scale),
                (int)(totalBounds.Height * scale));
            int offsetViewsX = totalBounds.X;
            int offsetViewsY = totalBounds.Y;
            totalBounds = RectangleUtil.Center(totalBounds, new Rectangle(0, (int)(this.Height * 0.25f), this.Width, (int)(this.Height * 0.7f)));

            for (int i = 0; i < screens.Length; i++)
            {
                UserScreen screen = screens[i];

                Rectangle s = screen.bounds;
                int width = (int)(s.Width * scale);
                int height = (int)(s.Height * scale);
                int x = (int)(s.X * scale);
                int y = (int)(s.Y * scale);
                screen.bounds = new Rectangle(x + totalBounds.X - offsetViewsX, y + totalBounds.Y - offsetViewsY, width, height);
                screen.swapTypeRect = new Rectangle(screen.bounds.X, screen.bounds.Y, (int)(screen.bounds.Width * 0.1f), (int)(screen.bounds.Width * 0.1f));
            }
        }