protected void RefreshGameList()
        {
            int selectedIndex = m_scenarioTable.SelectedRowIndex ?? -1;

            m_scenarioTable.Clear();
            Color?color = null;

            for (int index = 0; index < m_availableSaves.Count; index++)
            {
                var checkpoint = m_availableSaves[index].Item2;
                var name       = new StringBuilder(checkpoint.SessionName);
                var row        = new MyGuiControlTable.Row(m_availableSaves[index]);
                row.AddCell(new MyGuiControlTable.Cell(text: String.Empty, textColor: color, icon: GetIcon(m_availableSaves[index])));
                row.AddCell(new MyGuiControlTable.Cell(text: name, textColor: color, userData: name));
                m_scenarioTable.Add(row);

                // Select row with same world ID as we had before refresh.
                if (index == selectedIndex)
                {
                    m_selectedRow = index;
                    m_scenarioTable.SelectedRow = row;
                }
            }

            m_scenarioTable.SelectedRowIndex = m_selectedRow;
            m_scenarioTable.ScrollToSelection();
            FillRight();
        }
Example #2
0
        private void AddServerItem(GameServerItem server, string sessionName, StringBuilder gamemodeSB, StringBuilder gamemodeToolTipSB)
        {
            ulong modCount = server.GetGameTagByPrefixUlong(MyMultiplayer.ModCountTag);

            string        limit     = server.MaxPlayers.ToString();
            StringBuilder userCount = new StringBuilder(server.Players + "/" + limit);

            var viewDistance = server.GetGameTagByPrefix(MyMultiplayer.ViewDistanceTag);

            //TODO: refactor
            if (!String.IsNullOrEmpty(viewDistance) && server.AppID == 244850)
            {
                gamemodeToolTipSB.AppendLine();
                gamemodeToolTipSB.AppendFormat(MyTexts.Get(MySpaceTexts.JoinGame_GameTypeToolTip_ViewDistance).ToString(), viewDistance);
            }

            var row = new MyGuiControlTable.Row(server);

            row.AddCell(new MyGuiControlTable.Cell(text: m_textCache.Clear().Append(sessionName), userData: server.SteamID, toolTip: m_textCache.ToString()));
            row.AddCell(new MyGuiControlTable.Cell(text: gamemodeSB, toolTip: gamemodeToolTipSB.ToString()));
            row.AddCell(new MyGuiControlTable.Cell(text: m_textCache.Clear().Append(server.Name), toolTip: m_gameTypeToolTip.Clear().AppendLine(server.Name).Append(server.NetAdr.ToString()).ToString()));
            row.AddCell(new MyGuiControlTable.Cell(text: userCount, toolTip: userCount.ToString()));
            row.AddCell(new MyGuiControlTable.Cell(text: m_textCache.Clear().Append(server.Ping), toolTip: m_textCache.ToString()));
            row.AddCell(new MyGuiControlTable.Cell(text: m_textCache.Clear().Append(modCount == 0 ? "---" : modCount.ToString()), toolTip: MyTexts.GetString(MySpaceTexts.JoinGame_SelectServerToShowModList)));
            m_gamesTable.Add(row);

            var selectedRow = m_gamesTable.SelectedRow;

            m_gamesTable.Sort(false);

            m_gamesTable.SelectedRowIndex = m_gamesTable.FindRow(selectedRow);
        }
Example #3
0
        private Tuple <string, MyWorldInfo> FindSave(MyGuiControlTable.Row row)
        {
            string savePath = (string)row.UserData;
            var    entry    = m_availableSaves.Find((x) => x.Item1 == savePath);

            return(entry);
        }
Example #4
0
        private void RefreshMedicalRooms()
        {
            List <MyMedicalRoom> medicalRooms;

            GetAvailableMedicalRooms(MySession.LocalPlayerId, out medicalRooms);

            foreach (var medRoom in medicalRooms)
            {
                var row = new MyGuiControlTable.Row(medRoom);
                row.AddCell(new MyGuiControlTable.Cell(text: medRoom.CustomName));


                var ownerText = new StringBuilder();
                if (MySession.Static.Settings.EnableOxygen)
                {
                    ownerText.Append("O2 ");
                    ownerText.Append((medRoom.GetOxygenLevel() * 100).ToString("F0"));
                    ownerText.Append("% ");
                }
                ownerText.AppendStringBuilder(GetOwnerDisplayName(medRoom));

                row.AddCell(new MyGuiControlTable.Cell(text: ownerText));
                m_respawnsTable.Add(row);
            }
        }
Example #5
0
        private void MoveSelectedItem(MyGuiControlTable from, MyGuiControlTable to)
        {
            to.Add(from.SelectedRow);

            from.RemoveSelectedRow();
            m_selectedRow = from.SelectedRow;
        }
 private MyGuiControlTable.Row AddToList(MyGps ins)
 {
     var row = new MyGuiControlTable.Row(ins);
     var name = new StringBuilder(ins.Name);
     row.AddCell(new MyGuiControlTable.Cell(text: name, userData: ins, textColor: (ins.DiscardAt != null ? Color.Gray : (ins.ShowOnHud ? ITEM_SHOWN_COLOR : Color.White))));
     m_tableIns.Add(row);
     return row;
 }
Example #7
0
 private void AddRow(MyTerminalBlock block)
 {
     MyGuiControlTable.Row  row;
     MyGuiControlTable.Cell cell;
     row  = new MyGuiControlTable.Row(block);
     cell = new MyGuiControlTable.Cell(block.CustomName);
     row.AddCell(cell);
     m_selectedBlocks.Add(row);
 }
Example #8
0
        private void AddRespawnInSuit()
        {
            var row = new MyGuiControlTable.Row();

            row.AddCell(new MyGuiControlTable.Cell(text: MyTexts.GetString(MySpaceTexts.SpawnInSpaceSuit)));
            row.AddCell(new MyGuiControlTable.Cell(text: MyTexts.GetString(MySpaceTexts.ScreenMedicals_RespawnShipReady)));

            m_respawnsTable.Add(row);
        }
        private void AddMember(long playerId, string playerName, bool isLeader, MyMemberComparerEnum status, MyStringId textEnum, Color?color = null)
        {
            var row = new MyGuiControlTable.Row(new MyFactionMember(playerId, isLeader));

            row.AddCell(new MyGuiControlTable.Cell(text:    new StringBuilder(playerName),
                                                   toolTip: playerName,
                                                   userData: playerId, textColor: color));
            row.AddCell(new MyGuiControlTable.Cell(text: MyTexts.Get(textEnum), userData: status, textColor: color));
            m_tableMembers.Add(row);
        }
Example #10
0
        private void PopulateOwnedCubeGrids(HashSet <CubeGridInfo> gridInfoList)
        {
            float scrollBarValue = m_shipsData.ScrollBar.Value;

            m_shipsData.Clear();
            foreach (var gridInfo in gridInfoList)
            {
                UserData data;
                MyGuiControlTable.Row  row;
                MyGuiControlTable.Cell nameCell, controlCell, distanceCell, statusCell, accessCell;

                data.GridEntityId = gridInfo.EntityId;
                if (gridInfo.Status == MyCubeGridConnectionStatus.Connected || gridInfo.Status == MyCubeGridConnectionStatus.PhysicallyConnected || gridInfo.Status == MyCubeGridConnectionStatus.Me)
                {
                    StringBuilder minDistance = new StringBuilder();
                    if (gridInfo.Status == MyCubeGridConnectionStatus.Connected)
                    {
                        minDistance = gridInfo.AppendedDistance.Append(" m");
                    }

                    data.IsSelectable = true;
                    nameCell          = new MyGuiControlTable.Cell(new StringBuilder(gridInfo.Name), textColor: Color.White);
                    controlCell       = CreateControlCell(gridInfo, true);
                    distanceCell      = new MyGuiControlTable.Cell(minDistance, userData: gridInfo.Distance, textColor: Color.White);
                    statusCell        = CreateStatusIcons(gridInfo, true);
                    accessCell        = CreateTerminalCell(gridInfo, true);
                }

                else
                {
                    data.IsSelectable = false;
                    nameCell          = new MyGuiControlTable.Cell(new StringBuilder(gridInfo.Name), textColor: Color.Gray);
                    controlCell       = CreateControlCell(gridInfo, false);
                    distanceCell      = new MyGuiControlTable.Cell(new StringBuilder("Not Available"), userData: float.MaxValue, textColor: Color.Gray);
                    statusCell        = CreateStatusIcons(gridInfo, true);
                    accessCell        = CreateTerminalCell(gridInfo, false);
                }

                row = new MyGuiControlTable.Row(data);
                row.AddCell(nameCell);
                row.AddCell(controlCell);
                row.AddCell(distanceCell);
                row.AddCell(statusCell);
                row.AddCell(accessCell);
                m_shipsData.Add(row);
                m_shipsData.SortByColumn(m_columnToSort, MyGuiControlTable.SortStateEnum.Ascending, false);
            }
            m_shipsData.ScrollBar.ChangeValue(scrollBarValue);
        }
Example #11
0
        private void AddMod(bool active, StringBuilder title, StringBuilder toolTip, StringBuilder modState, MyGuiHighlightTexture?icon, MyObjectBuilder_Checkpoint.ModItem mod, Color?textColor = null)
        {
            var row = new MyGuiControlTable.Row(mod);

            row.AddCell(new MyGuiControlTable.Cell(text: String.Empty, toolTip: modState.ToString(), icon: icon));
            row.AddCell(new MyGuiControlTable.Cell(text: title, toolTip: toolTip.ToString(), textColor: textColor));

            if (active)
            {
                m_modsTableEnabled.Insert(0, row);
            }
            else
            {
                m_modsTableDisabled.Insert(0, row);
            }
        }
        protected void AddPlayer(ulong userId)
        {
            //string playerName = SteamAPI.Instance.Friends.GetPersonaName(userId);
            string playerName = MyMultiplayer.Static.GetMemberName(userId);

            if (String.IsNullOrEmpty(playerName))
            {
                return;
            }

            var row = new MyGuiControlTable.Row(userData: userId);

            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(playerName), userData: playerName));

            var playerId = Sync.Players.TryGetIdentityId(userId);
            var faction  = MySession.Static.Factions.GetPlayerFaction(playerId);

            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(faction != null ? faction.Tag : "")));
            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(faction != null ? faction.Name : "")));

            // cell with/without mute checkbox
            MyGuiControlTable.Cell cell = new MyGuiControlTable.Cell(text: new StringBuilder(""));
            row.AddCell(cell);

            if (MyPerGameSettings.EnableMutePlayer && userId != Sync.MyId)
            {
                MyGuiControlCheckbox check = new MyGuiControlCheckbox(toolTip: "", visualStyle: MyGuiControlCheckboxStyleEnum.Muted);
                check.IsChecked         = MySandboxGame.Config.MutedPlayers.Contains(userId);
                check.IsCheckedChanged += IsMuteCheckedChanged;
                check.UserData          = userId;
                cell.Control            = check;

                m_playersTable.Controls.Add(check);
            }

            // cell with admin marker
            StringBuilder  adminString = new StringBuilder();
            MyPromoteLevel userLevel   = MySession.Static.GetUserPromoteLevel(userId);

            for (int i = 0; i < (int)userLevel; i++)
            {
                adminString.Append("*");
            }

            row.AddCell(new MyGuiControlTable.Cell(adminString));
            m_playersTable.Add(row);
        }
        private void AddFaction(IMyFaction faction, Color?color = null, MyGuiHighlightTexture?icon = null, String iconToolTip = null)
        {
            System.Diagnostics.Debug.Assert(m_tableFactions != null);
            if (m_tableFactions == null)
            {
                return;
            }

            var row  = new MyGuiControlTable.Row(faction);
            var tag  = new StringBuilder(faction.Tag);
            var name = new StringBuilder(faction.Name);

            row.AddCell(new MyGuiControlTable.Cell(text: tag, userData: tag, textColor: color));
            row.AddCell(new MyGuiControlTable.Cell(text: name, userData: name, textColor: color, toolTip: faction.Name));
            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(), icon: icon, toolTip: iconToolTip));
            m_tableFactions.Add(row);
        }
Example #14
0
        void RefreshMedicalRooms(List <MyMedicalRoomInfo> medicalRooms)
        {
            m_respawnsTable.Clear();

            foreach (var medRoom in medicalRooms)
            {
                var row = new MyGuiControlTable.Row(medRoom);
                row.AddCell(new MyGuiControlTable.Cell(text: medRoom.MedicalRoomName));


                var ownerText = new StringBuilder();
                if (MySession.Static.Settings.EnableOxygen)
                {
                    ownerText.Append("O2 ");
                    ownerText.Append((medRoom.OxygenLevel * 100).ToString("F0"));
                    ownerText.Append("% ");
                }
                ownerText.AppendStringBuilder(GetOwnerDisplayName(medRoom.OwnerId));

                row.AddCell(new MyGuiControlTable.Cell(text: ownerText));
                m_respawnsTable.Add(row);
            }


            if (MySession.Static.CreativeMode)
            {
                AddRespawnInSuit();
            }
            else
            if ((MySession.Static.Settings.EnableRespawnShips && !MySession.Static.Settings.Scenario))
            {
                RefreshSpawnShips();
                AddRespawnInSuit();
            }

            if (m_respawnsTable.RowsCount > 0)
            {
                m_respawnsTable.SelectedRowIndex = 0;
                OnTableItemSelected(null, new MyGuiControlTable.EventArgs());
                m_noRespawnText.Visible = false;
            }
            else
            {
                m_noRespawnText.Visible = true;
            }
        }
Example #15
0
        private void AddPlayer(ulong userId)
        {
            //string playerName = SteamAPI.Instance.Friends.GetPersonaName(userId);
            string playerName = MyMultiplayer.Static.GetMemberName(userId);

            if (String.IsNullOrEmpty(playerName))
            {
                return;
            }

            bool isAdmin = MyMultiplayer.Static.IsAdmin(userId);

            var row = new MyGuiControlTable.Row(userData: userId);

            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(playerName), userData: playerName));
            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(isAdmin ? GAME_OWNER_MARKER : "")));
            m_playersTable.Add(row);
        }
Example #16
0
        protected void AddPlayer(ulong userId)
        {
            //string playerName = SteamAPI.Instance.Friends.GetPersonaName(userId);
            string playerName = MyMultiplayer.Static.GetMemberName(userId);

            if (String.IsNullOrEmpty(playerName))
            {
                return;
            }

            bool isAdmin        = MyMultiplayer.Static.IsAdmin(userId);
            bool hasAdminRights = MySession.Static.HasPlayerAdminRights(userId);

            var row = new MyGuiControlTable.Row(userData: userId);

            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(playerName), userData: playerName));

            var playerId = Sync.Players.TryGetIdentityId(userId);
            var faction  = MySession.Static.Factions.GetPlayerFaction(playerId);

            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(faction != null ? faction.Tag : "")));
            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(faction != null ? faction.Name : "")));

            // cell with/without mute checkbox
            MyGuiControlTable.Cell cell = new MyGuiControlTable.Cell(text: new StringBuilder(""));
            row.AddCell(cell);

            if (MyPerGameSettings.EnableMutePlayer && userId != Sync.MyId)
            {
                MyGuiControlCheckbox check = new MyGuiControlCheckbox(toolTip: "", visualStyle: MyGuiControlCheckboxStyleEnum.Muted);
                check.IsChecked         = MySandboxGame.Config.MutedPlayers.Contains(userId);
                check.IsCheckedChanged += IsMuteCheckedChanged;
                check.UserData          = userId;
                cell.Control            = check;

                m_playersTable.Controls.Add(check);
            }

            // cell with admin marker
            string adminString = isAdmin ? GAME_OWNER_MARKER : (hasAdminRights ? GAME_MASTER_MARKER : String.Empty);

            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(adminString)));
            m_playersTable.Add(row);
        }
Example #17
0
        private void RefreshSpawnShips()
        {
            var respawnShips = MyDefinitionManager.Static.GetRespawnShipDefinitions();

            foreach (var pair in respawnShips)
            {
                var respawnShip = pair.Value;
                var row         = new MyGuiControlTable.Row(respawnShip);

                //Add description or name?
                row.AddCell(new MyGuiControlTable.Cell(text: respawnShip.DisplayNameText));

                var respawnTimeCell = new MyGuiControlTable.Cell(String.Empty);
                AddShipRespawnInfo(respawnShip, respawnTimeCell.Text);
                row.AddCell(respawnTimeCell);

                m_respawnsTable.Add(row);
            }
        }
Example #18
0
        private void OnTableItemSelected(MyGuiControlTable sender, MyGuiControlTable.EventArgs eventArgs)
        {
            m_selectedRow   = sender.SelectedRow;
            m_selectedTable = sender;

            if (sender == m_modsTableEnabled)
            {
                m_modsTableDisabled.SelectedRowIndex = null;
            }

            if (sender == m_modsTableDisabled)
            {
                m_modsTableEnabled.SelectedRowIndex = null;
            }

            if (MyInput.Static.IsAnyCtrlKeyPressed())
            {
                OnTableItemConfirmedOrDoubleClick(sender, eventArgs);
            }
        }
Example #19
0
        /// <summary>
        /// Opens the dialog to add a subtype id to the given table
        /// </summary>
        /// <param name="table">Table to add item to</param>
        /// <param name="addAction">Action, which should add the id to the settings file</param>
        private void OpenEnterIdDialog(MyGuiControlTable table, Action <string> addAction)
        {
            MyGuiScreenDialogText inputBox = new MyGuiScreenDialogText();

            inputBox.OnConfirmed += delegate(string text)
            {
                if (Regex.Match(text, ILLEGAL_XML).Success)
                {
                    MyPluginGuiHelper.DisplayError("The entered subtype id contains invalid characters (& < >).", "Error, invalid character");
                    return;
                }

                var row = new MyGuiControlTable.Row(text);
                row.AddCell(new MyGuiControlTable.Cell(text));

                table.Add(row);
                addAction(text);
            };
            MyGuiSandbox.AddScreen(inputBox);
        }
        private void RefreshGameList()
        {
            int selectedIndex = m_scenarioTable.SelectedRowIndex ?? -1;

            m_scenarioTable.Clear();
            AddHeaders();

            for (int index = 0; index < m_availableSaves.Count; index++)
            {
                var checkpoint = m_availableSaves[index].Item2;
                var name       = new StringBuilder(checkpoint.SessionName);

                var row = new MyGuiControlTable.Row(m_availableSaves[index]);
                if (m_availableSaves[index].Item1 == WORKSHOP_PATH_TAG)
                {
                    row.AddCell(new MyGuiControlTable.Cell(text: String.Empty, icon: MyGuiConstants.TEXTURE_ICON_MODS_WORKSHOP));
                }
                else if (m_availableSaves[index].Item2.ScenarioEditMode == true)
                {
                    row.AddCell(new MyGuiControlTable.Cell(text: String.Empty, icon: MyGuiConstants.TEXTURE_ICON_MODS_LOCAL));
                }
                else
                {
                    row.AddCell(new MyGuiControlTable.Cell(text: String.Empty, icon: MyGuiConstants.TEXTURE_ICON_BLUEPRINTS_LOCAL));
                }

                row.AddCell(new MyGuiControlTable.Cell(text: name, userData: name));
                m_scenarioTable.Add(row);

                // Select row with same world ID as we had before refresh.
                if (index == selectedIndex)
                {
                    m_selectedRow = index;
                    m_scenarioTable.SelectedRow = row;
                }
            }

            m_scenarioTable.SelectedRowIndex = m_selectedRow;
            m_scenarioTable.ScrollToSelection();
            FillRight();
        }
Example #21
0
        /// <summary>
        /// Loads the global settings and reflects them in gui
        /// </summary>
        private void LoadSettings()
        {
            foreach (var moon in MySettings.Static.Settings.MoonDefinitions)
            {
                var row = new MyGuiControlTable.Row(moon);
                row.AddCell(new MyGuiControlTable.Cell(moon));

                m_moonDefsTable.Add(row);
            }
            foreach (var gasGiant in MySettings.Static.Settings.GasGiantDefinitions)
            {
                var row = new MyGuiControlTable.Row(gasGiant);
                row.AddCell(new MyGuiControlTable.Cell(gasGiant));

                m_gasGiantsDefsTable.Add(row);
            }
            foreach (var sun in MySettings.Static.Settings.SunDefinitions)
            {
                var row = new MyGuiControlTable.Row(sun);
                row.AddCell(new MyGuiControlTable.Cell(sun));

                m_sunDefsTable.Add(row);
            }
            foreach (var mandatory in MySettings.Static.Settings.MandatoryPlanetDefinitions)
            {
                var row = new MyGuiControlTable.Row(mandatory);
                row.AddCell(new MyGuiControlTable.Cell(mandatory));

                m_mandatoryDefsTable.Add(row);
            }
            foreach (var blacklisted in MySettings.Static.Settings.BlacklistedPlanetDefinitions)
            {
                var row = new MyGuiControlTable.Row(blacklisted);
                row.AddCell(new MyGuiControlTable.Cell(blacklisted));

                m_blacklistDefsTable.Add(row);
            }
            m_planetNameBox.SetText(new StringBuilder(MySettings.Static.Settings.PlanetNameFormat));
            m_moonNameBox.SetText(new StringBuilder(MySettings.Static.Settings.MoonNameFormat));
            m_beltNameBox.SetText(new StringBuilder(MySettings.Static.Settings.BeltNameFormat));
        }
Example #22
0
        private void RefreshGameList()
        {
            m_worldsTable.Clear();
            AddHeaders();

            if (m_subscribedWorlds != null)
            {
                for (int i = 0; i < m_subscribedWorlds.Count; ++i)
                {
                    var world   = m_subscribedWorlds[i];
                    var row     = new MyGuiControlTable.Row(world);
                    var titleSB = new StringBuilder(world.Title);
                    row.AddCell(new MyGuiControlTable.Cell(text: titleSB.ToString(),
                                                           userData: titleSB));
                    row.AddCell(new MyGuiControlTable.Cell());
                    m_worldsTable.Add(row);
                }
            }

            m_worldsTable.SelectedRowIndex = null;
        }
        static void RefreshMedicalRoomsResponse_Implementation(List <MyMedicalRoomInfo> medicalRooms)
        {
            foreach (var medRoom in medicalRooms)
            {
                var row = new MyGuiControlTable.Row(medRoom);
                row.AddCell(new MyGuiControlTable.Cell(text: medRoom.MedicalRoomName));


                var ownerText = new StringBuilder();
                if (MySession.Static.Settings.EnableOxygen)
                {
                    ownerText.Append("O2 ");
                    ownerText.Append((medRoom.OxygenLevel * 100).ToString("F0"));
                    ownerText.Append("% ");
                }
                ownerText.AppendStringBuilder(GetOwnerDisplayName(medRoom.OwnerId));

                row.AddCell(new MyGuiControlTable.Cell(text: ownerText));
                MyGuiScreenMedicals.Static.m_respawnsTable.Add(row);
            }
        }
        private void RefreshGameList()
        {
            string selectedWorldId = null;

            {
                var selectedRow = m_scenarioTable.SelectedRow;
                if (selectedRow != null)
                {
                    selectedWorldId = (string)selectedRow.UserData;
                }
            }

            m_scenarioTable.Clear();
            AddHeaders();

            for (int index = 0; index < m_availableSaves.Count; index++)
            {
                var checkpoint = m_availableSaves[index].Item2;
                var name       = new StringBuilder(checkpoint.SessionName);

                var row = new MyGuiControlTable.Row(m_availableSaves[index].Item1);
                row.AddCell(new MyGuiControlTable.Cell(text: String.Empty, icon: MyGuiConstants.TEXTURE_ICON_MODS_LOCAL));
                row.AddCell(new MyGuiControlTable.Cell(text: name,
                                                       userData: name));
                m_scenarioTable.Add(row);

                // Select row with same world ID as we had before refresh.
                if (index == 0)//selectedWorldId != null && checkpoint.WorldID == selectedWorldId)
                {
                    m_selectedRow = index;
                    m_scenarioTable.SelectedRow = row;
                }
            }
            m_scenarioTable.SetColumnComparison(1, (a, b) => ((StringBuilder)a.UserData).CompareToIgnoreCase((StringBuilder)b.UserData));
            m_scenarioTable.SortByColumn(1);

            m_scenarioTable.SelectedRowIndex = m_selectedRow;
            m_scenarioTable.ScrollToSelection();
            FillRight();
        }
        private void RefreshRightSideButtons(MyGuiControlTable.Row selected)
        {
            m_buttonPromote.Enabled    = false;
            m_buttonKick.Enabled       = false;
            m_buttonAcceptJoin.Enabled = false;
            m_buttonDemote.Enabled     = false;

            if (selected != null)
            {
                var data = (MyFactionMember)selected.UserData;
                m_selectedUserId = data.PlayerId;
                var identity = Sync.Players.TryGetIdentity(data.PlayerId);
                m_selectedUserName = identity.DisplayName;

                if (m_selectedUserId != MySession.LocalPlayerId)
                {
                    if (m_userIsFounder && m_userFaction.IsLeader(m_selectedUserId))
                    {
                        m_buttonKick.Enabled   = true;
                        m_buttonDemote.Enabled = true;
                    }
                    else if (m_userIsFounder && m_userFaction.IsMember(m_selectedUserId))
                    {
                        m_buttonKick.Enabled    = true;
                        m_buttonPromote.Enabled = true;
                    }
                    else if (m_userIsLeader &&
                             m_userFaction.IsMember(m_selectedUserId) &&
                             !m_userFaction.IsLeader(m_selectedUserId) &&
                             !m_userFaction.IsFounder(m_selectedUserId))
                    {
                        m_buttonKick.Enabled = true;
                    }
                    else if ((m_userIsLeader || m_userIsFounder) && m_userFaction.JoinRequests.ContainsKey(m_selectedUserId))
                    {
                        m_buttonAcceptJoin.Enabled = true;
                    }
                }
            }
        }
        protected void RefreshGameList(bool tutorials = false)
        {
            int selectedIndex = m_scenarioTable.SelectedRowIndex ?? -1;

            m_scenarioTable.Clear();
            Color?color = null;

            for (int index = 0; index < m_availableSaves.Count; index++)
            {
                var checkpoint = m_availableSaves[index].Item2;
                var name       = new StringBuilder(checkpoint.SessionName);
                if (tutorials)
                {
                    if (MyTutorialHelper.IsUnlocked(checkpoint.SessionName) || MyFakes.DEVELOPMENT_PRESET)
                    {
                        color = null;
                    }
                    else
                    {
                        color = Color.Gray;
                    }
                }
                var row = new MyGuiControlTable.Row(m_availableSaves[index]);
                row.AddCell(new MyGuiControlTable.Cell(text: String.Empty, textColor: color, icon: GetIcon(m_availableSaves[index])));
                row.AddCell(new MyGuiControlTable.Cell(text: name, textColor: color, userData: name));
                m_scenarioTable.Add(row);

                // Select row with same world ID as we had before refresh.
                if (index == selectedIndex)
                {
                    m_selectedRow = index;
                    m_scenarioTable.SelectedRow = row;
                }
            }

            m_scenarioTable.SelectedRowIndex = m_selectedRow;
            m_scenarioTable.ScrollToSelection();
            FillRight();
        }
Example #27
0
        private void RefreshGameList()
        {
            string selectedWorldSavePath = null;

            {
                var selectedRow = m_sessionsTable.SelectedRow;
                if (selectedRow != null)
                {
                    selectedWorldSavePath = (string)selectedRow.UserData;
                }
            }

            m_sessionsTable.Clear();
            AddHeaders();

            for (int index = 0; index < m_availableSaves.Count; index++)
            {
                var checkpoint = m_availableSaves[index].Item2;
                var name       = new StringBuilder(checkpoint.SessionName);

                var row = new MyGuiControlTable.Row(m_availableSaves[index].Item1);
                row.AddCell(new MyGuiControlTable.Cell(text: name,
                                                       userData: name));
                row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(checkpoint.LastLoadTime.ToString()),
                                                       userData: checkpoint.LastLoadTime));
                m_sessionsTable.Add(row);

                // Select row with same world ID as we had before refresh.
                if (selectedWorldSavePath != null && m_availableSaves[index].Item1 == selectedWorldSavePath)
                {
                    m_selectedRow = index;
                }
            }

            m_sessionsTable.SelectedRowIndex = m_selectedRow;
            m_sessionsTable.ScrollToSelection();
        }
        private static void UpdatePlayerList(MyGuiControlTable table)
        {
            MyPlayer selectedRowPlayer = table.SelectedRow != null ? table.SelectedRow.UserData as MyPlayer : null;

            table.Clear();

            var onlinePlayers = Sync.Players.GetOnlinePlayers();

            foreach (var player in onlinePlayers)
            {
                var name = player.DisplayName;
                var row  = new MyGuiControlTable.Row(player);
                row.AddCell(new MyGuiControlTable.Cell(text: name));
                if (Sync.ServerId == player.Id.SteamId)
                {
                    row.AddCell(new MyGuiControlTable.Cell(text: "SERVER"));
                }
                else
                {
                    if (m_readyPlayers.Contains(player.Id.SteamId))
                    {
                        row.AddCell(new MyGuiControlTable.Cell(text: "ready"));
                    }
                    else
                    {
                        row.AddCell(new MyGuiControlTable.Cell(text: ""));
                    }
                }
                table.Add(row);

                if (player == selectedRowPlayer)
                {
                    table.SelectedRow = row;
                }
            }
        }
        private void RefreshTableMembers()
        {
            m_tableMembers.Clear();

            foreach (var entry in m_selectedFaction.Members)
            {
                var member = entry.Value;

                var identity = Sync.Players.TryGetIdentity(member.PlayerId);
                System.Diagnostics.Debug.Assert(identity != null, "Faction member is not known identity!");
                if (identity == null)
                {
                    continue;
                }

                var   row        = new MyGuiControlTable.Row(member);
                var   compare    = MyMemberComparerEnum.Member;
                var   statusEnum = MySpaceTexts.Member;
                Color?txtColor   = null;

                if (m_selectedFaction.IsFounder(member.PlayerId))
                {
                    compare    = MyMemberComparerEnum.Founder;
                    statusEnum = MySpaceTexts.Founder;
                }
                else if (m_selectedFaction.IsLeader(member.PlayerId))
                {
                    compare    = MyMemberComparerEnum.Leader;
                    statusEnum = MySpaceTexts.Leader;
                }
                else if (m_selectedFaction.JoinRequests.ContainsKey(member.PlayerId))
                {
                    txtColor   = COLOR_CUSTOM_GREY;
                    compare    = MyMemberComparerEnum.Applicant;
                    statusEnum = MySpaceTexts.Applicant;
                }

                row.AddCell(new MyGuiControlTable.Cell(text:    new StringBuilder(identity.DisplayName),
                                                       toolTip: identity.DisplayName,
                                                       userData: entry, textColor: txtColor));
                row.AddCell(new MyGuiControlTable.Cell(text: MyTexts.Get(statusEnum), userData: compare, textColor: txtColor));
                m_tableMembers.Add(row);
            }

            foreach (var entry in m_selectedFaction.JoinRequests)
            {
                var request = entry.Value;
                var row     = new MyGuiControlTable.Row(request);

                var identity = Sync.Players.TryGetIdentity(request.PlayerId);
                System.Diagnostics.Debug.Assert(identity != null, "Player is not in allplayers list!");
                if (identity != null)
                {
                    row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(identity.DisplayName),
                                                           toolTip: identity.DisplayName,
                                                           userData: entry, textColor: COLOR_CUSTOM_GREY));

                    row.AddCell(new MyGuiControlTable.Cell(text: MyTexts.Get(MySpaceTexts.Applicant),
                                                           userData: MyMemberComparerEnum.Applicant,
                                                           textColor: COLOR_CUSTOM_GREY));
                    m_tableMembers.Add(row);
                }
            }
        }
 protected Tuple <string, MyWorldInfo> FindSave(MyGuiControlTable.Row row)
 {
     return((Tuple <string, MyWorldInfo>)(row.UserData));
 }