Exemplo n.º 1
0
    private void JoinSelectedGame()
    {
        IRuntimeService service = Services.GetService <IRuntimeService>();

        if (service != null)
        {
            RuntimeModuleConfigurationState gameSaveRuntimeConfigurationState = this.SelectedSessionLine.GameSaveRuntimeConfigurationState;
            switch (gameSaveRuntimeConfigurationState + 1)
            {
            case RuntimeModuleConfigurationState.Yellow:
                service.Runtime.FiniteStateMachine.PostStateChange(typeof(RuntimeState_Lobby), new object[]
                {
                    this.SelectedLobby.SteamIDLobby
                });
                break;

            case RuntimeModuleConfigurationState.Red:
            {
                IRuntimeModuleSubscriptionService service2 = Services.GetService <IRuntimeModuleSubscriptionService>();
                string[] array  = new string[0];
                string[] array2 = new string[0];
                if (service2 != null)
                {
                    service2.GetRuntimeModuleListState(this.SelectedLobby.RuntimeConfiguration, out array, out array2);
                }
                if (array.Length > 0)
                {
                    string text = AgeLocalizer.Instance.LocalizeString("%ConfirmDownloadModsBeforeActivation");
                    MessagePanel.Instance.Show(text.Replace("$NumberOfMods", array.Length.ToString()), "%Confirmation", MessagePanelButtons.OkCancel, new MessagePanel.EventHandler(this.OnConfirmOpenActivationPanel), MessagePanelType.IMPORTANT, new MessagePanelButton[0]);
                }
                else
                {
                    this.OnConfirmOpenActivationPanel(this, new MessagePanelResultEventArgs(MessagePanelResult.Ok));
                }
                break;
            }

            case (RuntimeModuleConfigurationState)3:
                this.OnConfirmOpenActivationPanel(this, new MessagePanelResultEventArgs(MessagePanelResult.Ok));
                break;
            }
        }
    }
Exemplo n.º 2
0
    private void OnSelectSaveLineCB(GameObject obj)
    {
        int num = int.Parse(obj.GetComponent <AgeControlToggle>().OnSwitchData);
        List <SaveLineSlot> children = this.LoadSaveContainer.GetChildren <SaveLineSlot>(true);

        for (int i = 0; i < children.Count; i++)
        {
            if (children[i].Index == num)
            {
                children[i].HighlightToggle.State      = true;
                this.GameSaveDescriptor                = children[i].GameSaveDescriptor;
                this.GameSaveRuntimeConfigurationState = children[i].GameSaveRuntimeConfigurationState;
                this.TextInputLabel.Text               = children[i].Title.Text;
            }
            else
            {
                children[i].HighlightToggle.State = false;
            }
        }
        this.RefreshButtons();
    }
Exemplo n.º 3
0
    private void OnLoadCB(GameObject obj)
    {
        if (this.GameSaveDescriptor != null)
        {
            Diagnostics.Log("Loading file '{0}'", new object[]
            {
                this.GameSaveDescriptor.SourceFileName
            });
            IRuntimeService service = Services.GetService <IRuntimeService>();
            if (service != null)
            {
                RuntimeModuleConfigurationState gameSaveRuntimeConfigurationState = this.GameSaveRuntimeConfigurationState;
                switch (gameSaveRuntimeConfigurationState + 1)
                {
                case RuntimeModuleConfigurationState.Yellow:
                {
                    LoadingScreen guiPanel = base.GuiService.GetGuiPanel <LoadingScreen>();
                    if (guiPanel != null)
                    {
                        guiPanel.Show(new object[]
                            {
                                this.GameSaveDescriptor
                            });
                    }
                    service.Runtime.FiniteStateMachine.PostStateChange(typeof(RuntimeState_Lobby), new object[]
                        {
                            this.GameSaveDescriptor
                        });
                    this.Hide(false);
                    break;
                }

                case RuntimeModuleConfigurationState.Red:
                {
                    IRuntimeModuleSubscriptionService service2 = Services.GetService <IRuntimeModuleSubscriptionService>();
                    string[] array  = new string[0];
                    string[] array2 = new string[0];
                    if (service2 != null)
                    {
                        service2.GetRuntimeModuleListState(this.GameSaveDescriptor.RuntimeModules, out array, out array2);
                    }
                    if (array.Length > 0)
                    {
                        string text = AgeLocalizer.Instance.LocalizeString("%ConfirmDownloadModsBeforeActivation");
                        MessagePanel.Instance.Show(text.Replace("$NumberOfMods", array.Length.ToString()), "%Confirmation", MessagePanelButtons.OkCancel, new MessagePanel.EventHandler(this.OnConfirmDownloadModulesBeforeActivation), MessagePanelType.IMPORTANT, new MessagePanelButton[0]);
                    }
                    else
                    {
                        this.Hide(false);
                        base.GuiService.Show(typeof(ActivateRuntimeModulesModalPanel), new object[]
                            {
                                this.GameSaveDescriptor.RuntimeModules,
                                this.GameSaveDescriptor,
                                this
                            });
                    }
                    break;
                }

                case (RuntimeModuleConfigurationState)3:
                    this.Hide(false);
                    base.GuiService.Show(typeof(ActivateRuntimeModulesModalPanel), new object[]
                    {
                        this.GameSaveDescriptor.RuntimeModules,
                        this.GameSaveDescriptor,
                        this
                    });
                    break;
                }
            }
        }
    }
Exemplo n.º 4
0
    private string GetWorkshopContentTooltip(ref bool runtimeCheck)
    {
        IRuntimeModuleSubscriptionService service = Services.GetService <IRuntimeModuleSubscriptionService>();

        string[] source  = null;
        string[] source2 = null;
        string   str     = string.Empty;

        if (service != null)
        {
            this.GameSaveRuntimeConfigurationState = service.GetRuntimeModuleListState(this.LobbyDescription.RuntimeConfiguration, out source, out source2);
        }
        RuntimeModuleConfigurationState gameSaveRuntimeConfigurationState = this.GameSaveRuntimeConfigurationState;

        if (gameSaveRuntimeConfigurationState != RuntimeModuleConfigurationState.Yellow)
        {
            if (gameSaveRuntimeConfigurationState == RuntimeModuleConfigurationState.Red)
            {
                runtimeCheck = true;
                str          = AgeLocalizer.Instance.LocalizeString("%MPSessionInvalidRuntimeModulesDescription") + "\n \n - ";
            }
        }
        else
        {
            runtimeCheck = true;
            str          = AgeLocalizer.Instance.LocalizeString("%MPSessionCanBeFixedRuntimeModulesDescription") + "\n \n - ";
        }
        IDatabase <RuntimeModule> database = Databases.GetDatabase <RuntimeModule>(true);
        List <string>             list     = new List <string>();
        int i   = 0;
        int num = this.LobbyDescription.RuntimeConfiguration.Length;

        while (i < num)
        {
            if (source.Contains(this.LobbyDescription.RuntimeConfiguration[i]) || source2.Contains(this.LobbyDescription.RuntimeConfiguration[i]))
            {
                if (this.LobbyDescription.RuntimeConfiguration[i].Contains(global::RuntimeManager.Folders.Workshop.Affix))
                {
                    string newValue = this.LobbyDescription.RuntimeConfiguration[i].Replace(global::RuntimeManager.Folders.Workshop.Affix, string.Empty);
                    list.Add(AgeLocalizer.Instance.LocalizeString("%MissingModuleTitle").Replace("$ModuleFolder", "Workshop").Replace("$ModuleName", newValue));
                }
                else if (this.LobbyDescription.RuntimeConfiguration[i].Contains(global::RuntimeManager.Folders.UGC.Affix))
                {
                    string newValue2 = this.LobbyDescription.RuntimeConfiguration[i].Replace(global::RuntimeManager.Folders.UGC.Affix, string.Empty);
                    list.Add(AgeLocalizer.Instance.LocalizeString("%MissingModuleTitle").Replace("$ModuleFolder", "UGC").Replace("$ModuleName", newValue2));
                }
                else
                {
                    list.Add(AgeLocalizer.Instance.LocalizeString("%MissingModuleTitle").Replace("$ModuleFolder", "Community").Replace("$ModuleName", this.LobbyDescription.RuntimeConfiguration[i]));
                }
            }
            else
            {
                RuntimeModule runtimeModule = database.FirstOrDefault((RuntimeModule module) => module.Name == this.LobbyDescription.RuntimeConfiguration[i]);
                if (runtimeModule != null)
                {
                    list.Add(AgeLocalizer.Instance.LocalizeString(runtimeModule.Title));
                }
            }
            i++;
        }
        return(str + string.Join("\n - ", list.ToArray()));
    }
Exemplo n.º 5
0
    public void RefreshContent()
    {
        if (this.LobbyDescription == null)
        {
            Diagnostics.LogError("Trying to refresh a GameSessionLine that doesn't have a LobbyDescription");
            return;
        }
        this.NameLabel.Text           = this.Name;
        this.PlayersLabel.Text        = this.PlayersCount.ToString();
        this.WorldTypeLabel.Text      = this.WorldType.ToString();
        this.DifficultyLabel.Text     = this.Difficulty;
        this.SpeedLabel.Text          = this.Speed;
        this.CustomFactionsLabel.Text = this.WithCustomFactions;
        this.TimersLabel.Text         = this.Timers;
        this.GameStateLabel.Text      = AgeLocalizer.Instance.LocalizeString("%JoinGameStatus" + this.GameState.ToString() + "Title");
        this.TurnLabel.Text           = this.Turn.ToString();
        bool            flag    = false;
        IRuntimeService service = Services.GetService <IRuntimeService>();

        if (service != null && service.Runtime != null && !string.IsNullOrEmpty(service.Runtime.HashKey) && !string.IsNullOrEmpty(this.LobbyDescription.Hash) && service.Runtime.HashKey == this.LobbyDescription.Hash)
        {
            flag = true;
        }
        string workshopContentTooltip = this.GetWorkshopContentTooltip(ref flag);

        if (this.LobbyDescription.Version != Amplitude.Unity.Framework.Application.Version)
        {
            this.AgeTransform.Enable = (Amplitude.Unity.Framework.Application.Version.Accessibility <= Accessibility.Internal);
            this.NameLabel.TintColor = this.ErrorColor;
            this.AgeTransform.StopSearchingForTooltips = true;
            this.AgeTransform.AgeTooltip.Content       = string.Format(AgeLocalizer.Instance.LocalizeString("%JoinGameVersionMismatchDescription"), Amplitude.Unity.Framework.Application.Version.ToString(), this.LobbyDescription.Version.ToString());
        }
        else if (this.LobbyDescription.HasFlag(MenuJoinGameScreen.LobbyDescription.LobbyFlag.RuntimeConfigurationMismatch))
        {
            this.AgeTransform.Enable = true;
            this.AgeTransform.StopSearchingForTooltips = true;
            RuntimeModuleConfigurationState gameSaveRuntimeConfigurationState = this.GameSaveRuntimeConfigurationState;
            if (gameSaveRuntimeConfigurationState != RuntimeModuleConfigurationState.Yellow)
            {
                if (gameSaveRuntimeConfigurationState == RuntimeModuleConfigurationState.Red)
                {
                    this.NameLabel.TintColor = this.ErrorColor;
                }
            }
            else
            {
                this.NameLabel.TintColor = this.WarningColor;
            }
            this.AgeTransform.AgeTooltip.Content = workshopContentTooltip;
        }
        else if (!flag)
        {
            this.AgeTransform.Enable = (Amplitude.Unity.Framework.Application.Version.Accessibility <= Accessibility.Internal);
            this.NameLabel.TintColor = this.WarningColor;
            this.AgeTransform.StopSearchingForTooltips = true;
            this.AgeTransform.AgeTooltip.Content       = "%JoinGameCheckSumMismatchDescription";
        }
        else
        {
            this.AgeTransform.Enable = true;
            this.NameLabel.TintColor = Color.white;
            this.AgeTransform.StopSearchingForTooltips = false;
            this.AgeTransform.AgeTooltip.Content       = string.Empty;
            this.RefreshDownloadableContentsTooltip();
            this.RefreshVictoryConditionTooltip();
            this.RefreshDLC13Tooltip();
        }
    }
Exemplo n.º 6
0
    private static void SteamMatchMaking_SteamLobbyDataUpdate(object sender, SteamLobbyDataUpdateEventArgs e)
    {
        PleaseWaitPanel.Instance.Hide(false);
        Diagnostics.Log("ELCP: LobbyDataUpdate, success? {0}, lobby {1}, expected {2}", new object[]
        {
            e.Message.m_bSuccess,
            e.Message.m_ulSteamIDLobby,
            ELCPUtilities.LobbyID
        });
        if (e.Message.m_bSuccess == 0 || ELCPUtilities.LobbyID != e.Message.m_ulSteamIDLobby)
        {
            return;
        }
        ISteamMatchMakingService service = Services.GetService <ISteamMatchMakingService>();

        Steamworks.SteamID steamID = new Steamworks.SteamID(ELCPUtilities.LobbyID);
        MenuJoinGameScreen.LobbyDescription lobbyDescription = new MenuJoinGameScreen.LobbyDescription(service, steamID);
        Diagnostics.Log("[Lobby] Flags: {0}, Lobby valid? {1}", new object[]
        {
            lobbyDescription.Flags,
            lobbyDescription.IsValid
        });
        service.SteamLobbyDataUpdate -= ELCPUtilities.SteamMatchMaking_SteamLobbyDataUpdate;
        ELCPUtilities.LobbyID         = 0UL;
        if (!lobbyDescription.IsValid)
        {
            return;
        }
        IRuntimeModuleSubscriptionService service2 = Services.GetService <IRuntimeModuleSubscriptionService>();

        if (service == null || service2 == null || !steamID.IsValid)
        {
            return;
        }
        string[] array  = new string[0];
        string[] array2 = new string[0];
        RuntimeModuleConfigurationState runtimeModuleListState = service2.GetRuntimeModuleListState(lobbyDescription.RuntimeConfiguration, out array, out array2);

        Diagnostics.Log("ELCP runtimeModuleConfigurationState {0} missingWorkshopItems {1} missingNonWorkshopItems {2} RuntimeConfiguration {3}", new object[]
        {
            runtimeModuleListState + 1,
            array.Length,
            array2.Length,
            (lobbyDescription.RuntimeConfiguration == null) ? -1 : lobbyDescription.RuntimeConfiguration.Length
        });
        switch (runtimeModuleListState + 1)
        {
        case RuntimeModuleConfigurationState.Yellow:
            Services.GetService <IRuntimeService>().Runtime.FiniteStateMachine.PostStateChange(typeof(RuntimeState_Lobby), new object[]
            {
                steamID
            });
            return;

        case RuntimeModuleConfigurationState.Red:
            ELCPUtilities.SelectedLobby = lobbyDescription;
            if (array.Length != 0)
            {
                string text = AgeLocalizer.Instance.LocalizeString("%ConfirmDownloadModsBeforeActivation");
                MessagePanel.Instance.Show(text.Replace("$NumberOfMods", array.Length.ToString()), "%Confirmation", MessagePanelButtons.OkCancel, new MessagePanel.EventHandler(ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel), MessagePanelType.IMPORTANT, new MessagePanelButton[0]);
                return;
            }
            ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel(Amplitude.Unity.Gui.GuiScreen.CurrentScreen, new MessagePanelResultEventArgs(MessagePanelResult.Ok));
            return;

        case (RuntimeModuleConfigurationState)3:
            ELCPUtilities.SelectedLobby = lobbyDescription;
            ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel(Amplitude.Unity.Gui.GuiScreen.CurrentScreen, new MessagePanelResultEventArgs(MessagePanelResult.Ok));
            return;

        default:
            return;
        }
    }
Exemplo n.º 7
0
    private static void SteamMatchMaking_CallbackRequestLobbyList(object sender, SteamMatchMakingRequestLobbyListEventArgs e)
    {
        PleaseWaitPanel.Instance.Hide(false);
        Diagnostics.Log("ELCP: Request Lobby List : " + e.Message.m_nLobbiesMatching + " result(s).");
        ISteamMatchMakingService service = Services.GetService <ISteamMatchMakingService>();

        Steamworks.SteamID steamID = new Steamworks.SteamID(ELCPUtilities.LobbyID);
        Diagnostics.Log("ELCP: looking for lobby: " + steamID.AccountID);
        int num = 0;

        while ((long)num < (long)((ulong)e.Message.m_nLobbiesMatching))
        {
            Steamworks.SteamID lobbyByIndex = service.SteamMatchMaking.GetLobbyByIndex(num);
            Diagnostics.Log(string.Concat(new object[]
            {
                "ELCP: lobbybyindex: ",
                lobbyByIndex.AccountID,
                " ",
                lobbyByIndex.IsValid.ToString()
            }));
            if (lobbyByIndex.IsValid && steamID.AccountID == lobbyByIndex.AccountID)
            {
                MenuJoinGameScreen.LobbyDescription lobbyDescription = new MenuJoinGameScreen.LobbyDescription(service, lobbyByIndex);
                Diagnostics.Log("[Lobby] Flags: {0}, Lobby valid? {1}", new object[]
                {
                    lobbyDescription.Flags,
                    lobbyDescription.IsValid
                });
                if (!lobbyDescription.IsValid)
                {
                    break;
                }
                IRuntimeModuleSubscriptionService service2 = Services.GetService <IRuntimeModuleSubscriptionService>();
                if (service == null || service2 == null || !steamID.IsValid)
                {
                    break;
                }
                string[] array  = new string[0];
                string[] array2 = new string[0];
                RuntimeModuleConfigurationState runtimeModuleListState = service2.GetRuntimeModuleListState(lobbyDescription.RuntimeConfiguration, out array, out array2);
                Diagnostics.Log("ELCP runtimeModuleConfigurationState {0} missingWorkshopItems {1} missingNonWorkshopItems {2} RuntimeConfiguration {3}", new object[]
                {
                    runtimeModuleListState + 1,
                    array.Length,
                    array2.Length,
                    (lobbyDescription.RuntimeConfiguration == null) ? -1 : lobbyDescription.RuntimeConfiguration.Length
                });
                switch (runtimeModuleListState + 1)
                {
                case RuntimeModuleConfigurationState.Yellow:
                    Services.GetService <IRuntimeService>().Runtime.FiniteStateMachine.PostStateChange(typeof(RuntimeState_Lobby), new object[]
                    {
                        steamID
                    });
                    goto IL_28B;

                case RuntimeModuleConfigurationState.Red:
                    ELCPUtilities.SelectedLobby = lobbyDescription;
                    if (array.Length != 0)
                    {
                        string text = AgeLocalizer.Instance.LocalizeString("%ConfirmDownloadModsBeforeActivation");
                        MessagePanel.Instance.Show(text.Replace("$NumberOfMods", array.Length.ToString()), "%Confirmation", MessagePanelButtons.OkCancel, new MessagePanel.EventHandler(ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel), MessagePanelType.IMPORTANT, new MessagePanelButton[0]);
                        goto IL_28B;
                    }
                    ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel(Amplitude.Unity.Gui.GuiScreen.CurrentScreen, new MessagePanelResultEventArgs(MessagePanelResult.Ok));
                    goto IL_28B;

                case (RuntimeModuleConfigurationState)3:
                    ELCPUtilities.SelectedLobby = lobbyDescription;
                    ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel(Amplitude.Unity.Gui.GuiScreen.CurrentScreen, new MessagePanelResultEventArgs(MessagePanelResult.Ok));
                    goto IL_28B;

                default:
                    goto IL_28B;
                }
            }
            else
            {
                num++;
            }
        }
IL_28B:
        service.SteamMatchMakingRequestLobbyList -= ELCPUtilities.SteamMatchMaking_CallbackRequestLobbyList;
        ELCPUtilities.LobbyID      = 0UL;
        ELCPUtilities.steamAPICall = 0UL;
    }