Esempio n. 1
0
 public UserDetail GetUserById(int id)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var entity =
             ctx
             .UsersInfo
             .Single(e => e.UserID == id);
         List <GameListItem> gameList = new List <GameListItem>();
         foreach (var game in entity.JoiningTables)
         {
             var gameListItem = new GameListItem()
             {
                 GameID   = game.Game.GameID,
                 GameName = game.Game.GameName
             };
             gameList.Add(gameListItem);
         }
         return
             (new UserDetail
         {
             UserID = entity.UserID,
             Name = entity.Name,
             GamerTag = entity.GamerTag,
             Email = entity.Email,
             Age = entity.Age,
             PlatformType = entity.PlatformTypes,
             Genres = entity.GenreType,
             JoiningTables = entity.JoiningTables
         });
     }
 }
Esempio n. 2
0
    public void OnMatchList(bool success, string extendedInfo, List <MatchInfoSnapshot> matchList)
    {
        statusText.text = "";
        if (matchList == null)
        {
            statusText.text = "Failed to fetch games.";
            return;
        }

        foreach (MatchInfoSnapshot match in matchList)
        {
            GameObject gameListItemGO = Instantiate(gameListItemPrefab);
            gameListItemGO.transform.SetParent(gameListTransform);

            GameListItem gameListItem = gameListItemGO.GetComponent <GameListItem>();
            if (gameListItem != null)
            {
                gameListItem.Setup(match, JoinRoom);
            }

            gameList.Add(gameListItemGO);
        }

        if (gameList.Count == 0)
        {
            statusText.text = "No Games available.";
        }
    }
Esempio n. 3
0
        public GameListItem GetTopGame()
        {
            using (var ctx = new ApplicationDbContext())
            {
                var games = ctx.Games;
                if (games.Count() == 0)
                {
                    return(null);
                }
                var orderedGames = games.OrderByDescending(m => m.AnticipationValue);

                Game game = orderedGames.First();

                GameListItem gameItem = new GameListItem()
                {
                    Id          = game.Id,
                    PosterUrl   = game.PosterUrl,
                    Title       = game.Title,
                    Description = game.Description,
                    DevStudio   = game.DevStudio,
                    ReleaseDate = game.ReleaseDate
                };

                return(gameItem);
            }
        }
    private void populateGamesList()
    {
        // For the gamelist we use a scrollable area containing a separate prefab button for each Game Room
        // Buttons are clickable to join the games
        List <Room> rooms = sfs.RoomManager.GetRoomList();

        foreach (Room room in rooms)
        {
            // Show only game rooms
            // Also password protected Rooms are skipped, to make this example simpler
            // (protection would require an interface element to input the password)
            if (!room.IsGame || room.IsHidden || room.IsPasswordProtected)
            {
                continue;
            }

            int roomId = room.Id;

            GameObject   newListItem = Instantiate(gameListItem) as GameObject;
            GameListItem roomItem    = newListItem.GetComponent <GameListItem>();
            roomItem.nameLabel.text = room.Name;
            roomItem.roomId         = roomId;

            roomItem.button.onClick.AddListener(() => OnGameItemClick(roomId));

            newListItem.transform.SetParent(gameListContent, false);
        }
    }
Esempio n. 5
0
        public ScraperGamePicker()
        {
            this.InitializeComponent();

            this.ShowCloseButton = false;
            btnSelect.IsEnabled  = false;

            // get the mainwindow
            mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();


            int GameId   = mw.InspGame.gameId;
            int systemId = mw.InspGame.systemId;

            // check for pcecd games
            if (systemId == 18)
            {
                systemId = 7;
            }


            string sysName = GSystem.GetSystemName(systemId);

            this.Title = "Fuzzy Search Results for " + sysName;
            this.Refresh();

            ScraperSearch gs = new ScraperSearch();
            // get a list of all games for this platform - higest match first
            //List<SearchOrdering> games = gs.ShowPlatformGames(systemId, row.Game);

            GamesLibraryModel row = new GamesLibraryModel();

            row.ID   = mw.InspGame.gameId;
            row.Game = mw.InspGame.gameName;

            List <SearchOrdering> games = gs.ShowPlatformGamesBySub(systemId, row);

            List <GameListItem> g = new List <GameListItem>();

            foreach (var gam in games)
            {
                if (gam.Matches == 0 || gam.Game.GDBTitle == "")
                {
                    continue;
                }
                GameListItem gli = new GameListItem();
                gli.GamesDBId = gam.Game.gid;
                gli.GameName  = gam.Game.GDBTitle;
                //gli.Matches = gam.Matches;
                int wordcount = row.Game.Split(' ').Length;
                gli.Percentage = Convert.ToInt32((Convert.ToDouble(gam.Matches) / Convert.ToDouble(wordcount)) * 100);
                gli.Platform   = gam.Game.GDBPlatformName;
                g.Add(gli);
            }
            // make sure list is ordered descending
            g.OrderByDescending(a => a.Matches);

            dgReturnedGames.ItemsSource = g;
        }
Esempio n. 6
0
        private void RefreshMapListView()
        {
            mapCollection.Clear();

            GameListItem gameListItem = (GameListItem)uiGameComboBox.SelectedItem;

            if (gameListItem == null)
            {
                return;
            }

            String engine = "goldsrc";

            //String engine = (game.Engine == Demo.EngineEnum.Source ? "source" : "goldsrc");

            // add all the "built in" maps listed in the game config
            foreach (KeyValuePair <UInt32, String> map in gameListItem.Game.Maps)
            {
                mapCollection.Add(new MapListItem(true, map.Value, String.Format("{0}", map.Key), ""));
            }

            // enumerate all folders in maps\\*engine*\\*game folder* and assume they are checksums
            String path = Config.ProgramDataPath + String.Format("\\maps\\{0}\\{1}", engine, gameListItem.Game.Folder);

            if (!Directory.Exists(path))
            {
                return;
            }

            foreach (String directory in Directory.GetDirectories(path))
            {
                String checksum = directory.Remove(0, directory.LastIndexOf('\\') + 1);

                try
                {
                    Convert.ToUInt32(checksum);
                }
                catch
                {
                    continue;
                }

                // enumerate all *.bsp files
                foreach (String bspFile in Directory.GetFiles(directory, "*.bsp"))
                {
                    String wadFiles = "";

                    // enumerate all *.wad files
                    foreach (String wadFile in Directory.GetFiles(directory, "*.wad"))
                    {
                        wadFiles += System.IO.Path.GetFileName(wadFile) + ";";
                    }

                    mapCollection.Add(new MapListItem(false, System.IO.Path.GetFileName(bspFile), checksum, wadFiles));
                }
            }
        }
Esempio n. 7
0
    void Start()
    {
        //GameCatalog.Instance.games
        _gamesListItemTemplate.gameObject.SetActive(false);

        foreach (GameData gam in GameCatalog.Instance.games)
        {
            GameListItem nuItem = GameObject.Instantiate(_gamesListItemTemplate.gameObject).GetComponent <GameListItem>();
            nuItem.game = gam;
            nuItem.gameObject.SetActive(true);
            nuItem.text = gam.title;
            nuItem.transform.SetParent(_gameListScrollRect.content, false);
        }
    }
            public static GameListItem Deserialize(HazelBinaryReader reader)
            {
                var msg = new GameListItem();

                msg.adress     = reader.ReadInt32();
                msg.port       = reader.ReadUInt16();
                msg.code       = reader.ReadInt32();
                msg.name       = reader.ReadString();
                msg.players    = reader.ReadByte();
                msg.age        = reader.ReadPackedInt32();
                msg.mapid      = reader.ReadByte();
                msg.imposters  = reader.ReadByte();
                msg.maxplayers = reader.ReadByte();
                return(msg);
            }
Esempio n. 9
0
        public bool UpdateGame(GameListItem model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Games
                    .Single(e => e.Id == model.Id);
                entity.GameName    = model.GameName;
                entity.Description = model.Description;
                entity.ReleaseDate = model.ReleaseDate;

                return(ctx.SaveChanges() == 1);
            }
        }
Esempio n. 10
0
        public IHttpActionResult Put(GameListItem model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateGameService();

            if (!service.UpdateGame(model))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Esempio n. 11
0
        private void uiRemoveButton_Click(object sender, RoutedEventArgs e)
        {
            // get selected game
            GameListItem gameListItem = (GameListItem)uiGameComboBox.SelectedItem;

            if (gameListItem == null)
            {
                Common.Message(this, "Select a game first.");
                return;
            }

            // get selected map
            MapListItem map = (MapListItem)uiMapListView.SelectedItem;

            if (map == null)
            {
                Common.Message(this, "Select a map first.");
                return;
            }

            // make sure map isn't built-in
            if (map.BuiltIn)
            {
                return;
            }

            // confirmation window
            if (Common.Message(this, "Are you sure you want to remove the select map from the map pool? The corresponding BSP file and any associated WAD files will be deleted.", null, MessageWindow.Flags.YesNo) != MessageWindow.Result.Yes)
            {
                return;
            }

            // delete the checksum folder and all contents
            //String engine = (game.Engine == Demo.EngineEnum.Source ? "source" : "goldsrc");
            String engine         = "goldsrc";
            String checksumFolder = Config.ProgramDataPath + String.Format("\\maps\\{0}\\{1}\\{2}", engine, gameListItem.Game.Folder, map.Checksum);

            Directory.Delete(checksumFolder, true);

            // update UI
            RefreshMapListView();
        }
Esempio n. 12
0
    public void RefreshLobbyContent(LobbyData lobbyData)
    {
        for (int i = 0, numGames = activeGamesList.Count; i < numGames; ++i)
        {
            GameObject.Destroy(activeGamesList[i].gameObject);
        }
        activeGamesList.Clear();

        currentLobbyData = lobbyData;
        for (int i = 0, numGames = currentLobbyData.ActiveGames.Count; i < numGames; ++i)
        {
            GameDataSimple gameData = currentLobbyData.ActiveGames[i];
            if (!gameData.isFinished)
            {
                GameObject gameListItemObj = GameObject.Instantiate(
                    Resources.Load <GameObject>("GameListItem"), GameListPanel);
                GameListItem listItem = gameListItemObj.GetComponent <GameListItem>();
                listItem.Initialize(gameData, OnJoinGame);
                activeGamesList.Add(listItem);
            }
        }
    }
Esempio n. 13
0
        public static GetGameListV2Response Deserialize(HazelBinaryReader reader)
        {
            var msg = new GetGameListV2Response();

            var size = reader.ReadInt16();
            var type = reader.ReadByte();
            var body = new HazelBinaryReader(reader.ReadBytes(size));

            msg.games = new List <GameListItem>();

            while (body.HasBytesLeft())
            {
                var itemsize   = body.ReadInt16();
                var itemtype   = body.ReadByte();
                var itemBody   = body.ReadBytes(itemsize);
                var itemreader = new HazelBinaryReader(itemBody);

                msg.games.Add(GameListItem.Deserialize(itemreader));
            }

            return(msg);
        }
Esempio n. 14
0
    public override void SetItem(GameObject widget, Game item, Action <Game, int> action, Server.TokenAndId tai)
    {
        GameListItem litem = widget.GetComponent <GameListItem>();

        if (item.users.Count >= 1)
        {
            User u = Server.GetUser(tai, item.users[0]);
            litem.firstPlayerName.text = u.login + "(" + u.GetRankString() + ")";
        }
        else
        {
            litem.firstPlayerName.text = "Available";
        }

        if (item.users.Count >= 2)
        {
            User u = Server.GetUser(tai, item.users[1]);
            litem.secondPlayerName.text = u.login + "(" + u.GetRankString() + ")";
        }
        else
        {
            litem.secondPlayerName.text = "Available";
        }

        Settings settings = Settings.Load(item.settings);


        litem.timeControlLabel.text = settings.GetTimeControl();

        /*
         * litem.komiLabel.text = settings.komi+"";
         *
         * Stone stone1 = Stone.BLACK;
         * Stone stone2 = Stone.WHITE;
         *
         * if(settings.firstPlayer == 0){
         *  stone1 = Stone.BLACK;
         *  stone2 = Stone.WHITE;
         * }
         *
         * if (settings.firstPlayer == 1)
         * {
         *  stone1 = Stone.WHITE;
         *  stone2 = Stone.BLACK;
         * }
         *
         * if (settings.firstPlayer == 9)
         * {
         *  stone1 = Stone.UNKNOWN;
         *  stone2 = Stone.UNKNOWN;
         * }
         * */

        //litem.firstPlayerStoneSprite.spriteName = BoardStateParser.GetSprite(stone1);
        //litem.secondPlayerStoneSprite.spriteName = BoardStateParser.GetSprite(stone2);

        litem.joinButton.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                           delegate
        {
            action(item, 0);
        }
                                                           )));

        litem.leaveButton.onClick.Add(new EventDelegate(new EventDelegate.Callback(
                                                            delegate
        {
            action(item, 1);
        }
                                                            )));

        litem.backgroundSprite.spriteName = getGameBackground(item.status);

        litem.joinButton.isEnabled  = false;
        litem.leaveButton.isEnabled = false;

        if (item.status.Equals("open"))
        {
            if (!item.users.Contains(me))
            {
                litem.joinButton.isEnabled = true;
            }
            else
            {
                litem.leaveButton.isEnabled = true;
            }
        }
        else
        {
            litem.joinButton.isEnabled = true;
            if (!item.users.Contains(me))
            {
                litem.joinLabel.text = "Observe";
            }
            else
            {
                litem.joinLabel.text = "Join";
            }
        }

        if (item.title.Equals("go"))
        {
            litem.gameTypeLabel.text = "Go";
        }

        if (item.title.Equals("one-color-go"))
        {
            litem.gameTypeLabel.text = "One color Go";
        }

        if (item.title.Equals("blind-go"))
        {
            litem.gameTypeLabel.text = "Blind Go";
        }

        if (item.title.Equals("hidden-move-go"))
        {
            litem.gameTypeLabel.text = "Hidden move Go";
        }

        int size = settings.size;

        litem.gameTypeLabel.text += "\n" + size + "*" + size;

        if (settings.GetHandi())
        {
            litem.handicapLabel.text = "Yes";
        }
        else
        {
            litem.handicapLabel.text = "No";
        }
    }
Esempio n. 15
0
 public void update(GameListItem item)
 {
     this.Players = item.Players;
 }
Esempio n. 16
0
 public void updateGames(List<GameContainer> gameList)
 {
     this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (DispatcherOperationCallback)delegate(object arg)
     {
         this.GameList.Items.Clear();
         foreach (GameContainer gameContainer in gameList)
         {
             if (gameContainer.actualPlayer != 0 && gameContainer.actualPlayer != gameContainer.maxPlayer)
             {
                 GameListItem game = new GameListItem();
                 //game.ID = gameContainer.ID;
                 game.Name = gameContainer.gameName;
                 game.Creator = gameContainer.owner;
                 game.Players = gameContainer.actualPlayer + "/" + gameContainer.maxPlayer;
                 GameList.Items.Add(game);
                 Games.Add(game);
             }
       	}				
         return null;
     }, null);
 }
Esempio n. 17
0
        private void uiAddButton_Click(object sender, RoutedEventArgs e)
        {
            // get selected game
            GameListItem gameListItem = (GameListItem)uiGameComboBox.SelectedItem;

            if (gameListItem == null)
            {
                Common.Message(this, "Select a game first.");
                return;
            }

            // open file dialog
            System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();

            dialog.Title            = "Add Map";
            dialog.Filter           = "BSP files (*.bsp)|*.bsp";
            dialog.RestoreDirectory = true;

            if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            String mapFileName = System.IO.Path.GetFileName(dialog.FileName);

            // calculate checksum
            UInt32 checksum = 0;

            try
            {
                checksum = HalfLifeMapChecksum.Calculate(dialog.FileName);
            }
            catch (Exception ex)
            {
                Common.Message(this, String.Format("Error calculate map checksum for map \"{0}\"", mapFileName), ex, MessageWindow.Flags.Error);
                return;
            }

            // see if map is built-in
            if (gameListItem.Game.BuiltInMapExists(checksum, System.IO.Path.GetFileNameWithoutExtension(mapFileName)))
            {
                Common.Message(this, String.Format("The map \"{0}\" with the checksum \"{1}\" is a built-in map. It does not need to be added to the map pool.", mapFileName, checksum));
                return;
            }

            // see if the game map folder already exists
            //String engine = (game.Engine == Demo.EngineEnum.Source ? "source" : "goldsrc");
            String engine        = "goldsrc";
            String gameMapFolder = Config.ProgramDataPath + String.Format("\\maps\\{0}\\{1}", engine, gameListItem.Game.Folder);

            if (!Directory.Exists(gameMapFolder))
            {
                Directory.CreateDirectory(gameMapFolder);
            }

            // see if the checksum folder already exists
            String checksumFolder = gameMapFolder + "\\" + String.Format("{0}", checksum);

            if (!Directory.Exists(checksumFolder))
            {
                Directory.CreateDirectory(checksumFolder);
            }

            // see if the map already exists
            String mapFullPath = checksumFolder + "\\" + mapFileName;

            if (File.Exists(mapFullPath))
            {
                Common.Message(this, String.Format("The map \"{0}\" with the checksum \"{1}\" already exists.", mapFileName, checksum));
                return;
            }

            // copy the map over
            File.Copy(dialog.FileName, mapFullPath);

            // update UI and inform the user of success
            RefreshMapListView();
            Common.Message(this, String.Format("Successfully added the map \"{0}\" with the checksum \"{1}\" to the map pool.", mapFileName, checksum));
        }