void GenerateList(string filter) { var children = new List <GameObject>(); foreach (Transform child in PlayerPanel.transform) { children.Add(child.gameObject); } children.ForEach(child => Destroy(child)); PlayerPanel.Enable(); IEnumerable <Player> filtered = users.Where(t => t.Username.ToLower().Contains(filter.ToLower())) .OrderByDescending(t => pinnedPlayers.Any(u => u.ObjectId.Equals(t.ObjectId))).ThenBy(t => t.Username); foreach (Player player in filtered) { // GameObject ListItem = Instantiate(Resources.Load("List Item")) as GameObject; dfPanel listItem = PlayerPanel.AddPrefab(ListItem) as dfPanel; // as UserListItem; listItem.Width = PlayerPanel.Width - PlayerPanel.FlowPadding.left - PlayerPanel.FlowPadding.right; listItem.Click += new MouseEventHandler(listItem_Click); ListItemExtras extras = listItem.GetComponent <ListItemExtras>(); extras.Player = player; dfLabel username = listItem.Find("Username Label").GetComponent <dfLabel>(); username.Text = player.Username; username.DisabledColor = new Color32(100, 100, 100, 255); dfSprite onlineSprite = listItem.Find("Online Sprite").GetComponent <dfSprite>(); if (player.IsOnline) { onlineSprite.SpriteName = "OUYA_O 24px"; } else { onlineSprite.SpriteName = "OUYA_A 24px"; } dfButton actionButton = listItem.Find("Action Button").GetComponent <dfButton>(); bool f = pinnedPlayers.Any(t => t.ObjectId.Equals(player.ObjectId)); if (f) { actionButton.Text = "Unpin"; // listItem.BackgroundColor = new Color32(200, 255, 200, 255); listItem.BackgroundColor = new Color32(255, 255, 255, 255); actionButton.Click += new MouseEventHandler(actionButtonUnpin_Click); } else { actionButton.Text = "Pin"; actionButton.Click += new MouseEventHandler(actionButtonPin_Click); } } }
private void Refresh() { _container = GetComponent <dfPanel>(); _sprite = _container.Find("Icon") as dfSprite; _label = _container.Find("Count") as dfLabel; _sprite.SpriteName = this.Icon; _label.Text = (this.Count > 1) ? Count.ToString() : ""; }
// Called by Unity just before any of the Update methods is called the first time. public void Start() { // Store the singleton instance for reference in static functions _instance = this; // Obtain a reference to the control instances attached to this object _panel = GetComponent<dfPanel>(); _name = _panel.Find<dfLabel>( "lblName" ); _info = _panel.Find<dfLabel>( "lblInfo" ); // We don't want the tooltip visible unless it is being used _panel.Hide(); // We don't want the tooltip to intercept mouse messages _panel.IsInteractive = false; _panel.IsEnabled = false; }
// Called by Unity just before any of the Update methods is called the first time. public void Start() { // Store the singleton instance for reference in static functions _instance = this; // Obtain a reference to the control instances attached to this object _panel = GetComponent <dfPanel>(); _name = _panel.Find <dfLabel>("lblName"); _info = _panel.Find <dfLabel>("lblInfo"); // We don't want the tooltip visible unless it is being used _panel.Hide(); // We don't want the tooltip to intercept mouse messages _panel.IsInteractive = false; _panel.IsEnabled = false; }
void OnEnable() { Container = GetComponent<dfPanel>(); if( Container == null ) { this.enabled = false; } NameLabel = Container.Find<dfLabel>( "Name" ); DescriptionLabel = Container.Find<dfLabel>( "Description" ); ProgressLabel = Container.Find<dfLabel>( "ProgressLabel" ); Icon = Container.Find<dfSprite>( "Icon" ); ProgressBar = Container.Find<dfProgressBar>( "ProgressBar" ); Container.BackgroundSprite = "frame-style6"; NameLabel.BackgroundSprite = null; ProgressBar.Opacity = 0.5f; }
void listItem_DoubleClick(dfControl control, dfMouseEventArgs mouseEvent) { if (currentlySelected != null) { currentlySelected.BackgroundColor = new Color32(255, 255, 255, 255); currentlySelected.Find("Selected Indicator").GetComponent <dfSprite>().Hide(); } dfPanel item = control as dfPanel; RoomData data = item.GetComponent <RoomData>(); data.Selected = true; item.BackgroundColor = new Color32(0, 0, 0, 255); currentlySelected = item; currentlySelected.Find("Selected Indicator").GetComponent <dfSprite>().Show(); UpdateInfoBox(); }
void listItem_DoubleClick(dfControl control, dfMouseEventArgs mouseEvent) { if (currentlySelected != null) { currentlySelected.BackgroundColor = new Color32(255, 255, 255, 255); currentlySelected.Find("Selected Indicator").GetComponent <dfSprite>().Hide(); } dfPanel item = control as dfPanel; RoomData data = item.GetComponent <RoomData>(); data.Selected = true; item.BackgroundColor = new Color32(0, 0, 0, 255); currentlySelected = item; currentlySelected.Find("Selected Indicator").GetComponent <dfSprite>().Show(); if (TestOK()) { if (data.Game.playerCount < data.Game.maxPlayers) { PhotonNetwork.JoinOrCreateRoom(data.Game.name, null, null); } } }
void GenerateList(string filter) { //Player current = Player.CurrentUser as Player; //current.Get<string>("email"); //IList<Player> players = null; //try //{ // players = current.Get<IList<Player>>("pinnedPlayers"); //} //catch (Exception e) //{ //} //if (players == null) //{ // print("players is null"); // players = new List<Player>() { users.LastOrDefault() }; //} //print("count " + players.Count); //players.Add(users.FirstOrDefault()); //current["pinnedPlayers"] = players; //current.SaveAsync(); //current.PinnedPlayers.FetchAllAsync().ContinueWith(t => //{ // if (current.PinnedPlayers != null) // { // foreach (Player p in current.PinnedPlayers) // { // print("Player: " + p.Username); // } // } // current.PinnedPlayers.Add(users.LastOrDefault()); // current.SaveAsync(); // print("Saving pinnedPlayers"); //}); var children = new List <GameObject>(); foreach (Transform child in UserPanel.transform) { children.Add(child.gameObject); } children.ForEach(child => Destroy(child)); UserPanel.Enable(); IEnumerable <Player> filtered = users.Where(t => t.Username.ToLower().Contains(filter.ToLower())).OrderByDescending(t => t.ObjectId.Equals(Player.CurrentUser.ObjectId)) .ThenByDescending(t => friendList.Contains(t.ObjectId)); foreach (Player player in filtered) { ParseObject friend = null; if (friends != null) { friend = friends.Where(t => ((Player)t[REQUEST_FROM]).ObjectId.Equals(player.ObjectId) || ((Player)t[REQUEST_TO]).ObjectId.Equals(player.ObjectId)).FirstOrDefault(); // friend = friends.FirstOrDefault(); // print("Friend: " + ((Player)friend[REQUEST_TO]).ObjectId); // print("Player: " + player.ObjectId); } // GameObject ListItem = Instantiate(Resources.Load("List Item")) as GameObject; dfPanel listItem = UserPanel.AddPrefab(ListItem) as dfPanel; // as UserListItem; listItem.Width = UserPanel.Width - UserPanel.FlowPadding.left - UserPanel.FlowPadding.right; ListItemExtras extras = listItem.GetComponent <ListItemExtras>(); extras.Player = player; extras.FriendRequest = friend; dfLabel username = listItem.Find("Username Label").GetComponent <dfLabel>(); username.Text = player.Username; username.DisabledColor = new Color32(100, 100, 100, 255); dfLabel email = listItem.Find("Email label").GetComponent <dfLabel>(); email.Text = player.Email; email.DisabledColor = new Color32(100, 100, 100, 255); dfSprite onlineSprite = listItem.Find("Online Sprite").GetComponent <dfSprite>(); if (player.IsOnline) { onlineSprite.SpriteName = "OUYA_O 24px"; } else { onlineSprite.SpriteName = "OUYA_A 24px"; } dfButton actionButton = listItem.Find("Action Button").GetComponent <dfButton>(); if (friend == null) { actionButton.Text = "Add"; actionButton.Click += new MouseEventHandler(actionClick_add); } else { string status = friend[STATUS] as string; Player from = friend[REQUEST_FROM] as Player; if (Player.CurrentUser.ObjectId.Equals(from.ObjectId)) { switch (status) { case S_ACCEPTED: actionButton.Text = "Remove"; actionButton.Click += new MouseEventHandler(actionClick_remove); listItem.BackgroundColor = new Color32(200, 255, 200, 255); break; case S_REJECTED: actionButton.Text = "Sorry"; break; case S_PENDING: actionButton.Text = "Pending"; actionButton.Disable(); break; } } else { switch (status) { case S_ACCEPTED: actionButton.Text = "Remove"; actionButton.Click += new MouseEventHandler(actionClick_remove); listItem.BackgroundColor = new Color32(200, 255, 200, 255); break; case S_REJECTED: actionButton.Text = "Rejected"; break; case S_PENDING: actionButton.Text = "Accept"; actionButton.Click += new MouseEventHandler(actionClick_accept); break; } } } if (player.Username.Equals(Player.CurrentUser.Username)) { actionButton.Hide(); } } }
private void Refresh() { _container = GetComponent<dfPanel>(); _sprite = _container.Find( "Icon" ) as dfSprite; _label = _container.Find( "Count" ) as dfLabel; _sprite.SpriteName = this.Icon; _label.Text = ( this.Count > 1 ) ? Count.ToString() : ""; }
void GenerateRoomList() { var children = new List <GameObject>(); foreach (Transform child in ActiveRoomsPanel.transform) { children.Add(child.gameObject); } children.ForEach(child => Destroy(child)); if (PhotonNetwork.connected) { int sel_idx = -1; if (currentlySelected != null) { sel_idx = currentlySelected.GetComponent <RoomData>().Index; } int idx = 0; if (PhotonNetwork.GetRoomList().Length == 0) { dfLabel label = ActiveRoomsPanel.AddControl <dfLabel>(); label.Padding = new RectOffset(10, 10, 10, 10); label.Text = "No games available"; label.Color = new Color32(200, 200, 200, 255); label.AutoSize = true; } else { foreach (RoomInfo game in PhotonNetwork.GetRoomList().OrderBy(t => Mathf.Abs((int)t.customProperties["level"] - Player.Level))) { dfPanel listItem = ActiveRoomsPanel.AddPrefab(ListItem) as dfPanel; // as UserListItem; listItem.Width = ActiveRoomsPanel.Width - ActiveRoomsPanel.FlowPadding.left - ActiveRoomsPanel.FlowPadding.right; listItem.Click += new MouseEventHandler(listItem_Click); listItem.DoubleClick += new MouseEventHandler(listItem_DoubleClick); RoomData data = listItem.GetComponent <RoomData>(); data.Game = game; data.Index = idx++; if (data.Index == sel_idx) { // print("They match!"); data.Selected = true; listItem.BackgroundColor = new Color32(0, 0, 0, 255); currentlySelected = listItem; currentlySelected.Find("Selected Indicator").GetComponent <dfSprite>().Show(); } dfLabel roomName = listItem.Find("Room Name").GetComponent <dfLabel>(); roomName.Text = string.Format("{0} ({1})", game.customProperties["name"].ToString(), game.customProperties["level"].ToString()); dfLabel mapName = listItem.Find("Map Type").GetComponent <dfLabel>(); mapName.Text = game.customProperties["map"].ToString(); dfLabel modeName = listItem.Find("Game Mode").GetComponent <dfLabel>(); modeName.Text = game.customProperties["mode"].ToString(); dfLabel numberPlayers = listItem.Find("Number Players").GetComponent <dfLabel>(); numberPlayers.Text = string.Format("{0}/{1}", game.playerCount, game.maxPlayers); if (game.playerCount < game.maxPlayers) { numberPlayers.Color = new Color32(0, 255, 0, 255); } else { numberPlayers.Color = new Color32(255, 0, 0, 255); } } } } }