Example #1
0
    protected override IEnumerator OnShow(params object[] parameters)
    {
        yield return(base.OnShow(parameters));

        this.readOnly = false;
        if (parameters != null)
        {
            if (parameters.Length != 0)
            {
                this.category = (parameters[0] as string);
            }
            if (parameters.Length > 1)
            {
                string text = parameters[1] as string;
                if (text != null && text == "readonly")
                {
                    this.readOnly = true;
                }
            }
        }
        if (string.IsNullOrEmpty(this.category))
        {
            yield break;
        }
        ISessionService service = Services.GetService <ISessionService>();

        Diagnostics.Assert(service != null);
        this.Session = (service.Session as global::Session);
        if (this.Session == null)
        {
            yield break;
        }
        this.OptionDefinitions = new Dictionary <StaticString, OptionDefinition>();
        if (this.category == "Game")
        {
            using (IEnumerator <OptionDefinition> enumerator = Databases.GetDatabase <OptionDefinition>(true).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    OptionDefinition optionDefinition4 = enumerator.Current;
                    if (optionDefinition4.Category == this.category && !this.OptionDefinitions.ContainsKey(optionDefinition4.Name))
                    {
                        this.OptionDefinitions.Add(optionDefinition4.Name, optionDefinition4);
                    }
                }
                goto IL_249;
            }
        }
        if (this.category == "World")
        {
            foreach (OptionDefinition optionDefinition2 in Databases.GetDatabase <WorldGeneratorOptionDefinition>(true))
            {
                if (optionDefinition2.Category == this.category && !this.OptionDefinitions.ContainsKey(optionDefinition2.Name))
                {
                    this.OptionDefinitions.Add(optionDefinition2.Name, optionDefinition2);
                }
            }
            foreach (OptionDefinition optionDefinition3 in Databases.GetDatabase <OptionDefinition>(true))
            {
                if (optionDefinition3.Category == "Game" && !this.OptionDefinitions.ContainsKey(optionDefinition3.Name))
                {
                    this.OptionDefinitions.Add(optionDefinition3.Name, optionDefinition3);
                }
            }
        }
IL_249:
        if (this.OptionDefinitions != null)
        {
            this.filteredOptionDefinitions = from optionDefinition in this.OptionDefinitions.Values
                                             where optionDefinition.Category == this.category && optionDefinition.IsAdvanced
                                             select optionDefinition;
            this.BuildOptionValuesByNames();
            this.BuildSettingsBySubCategory();
            this.SettingsGroupsContainer.DestroyAllChildren();
            int num = 0;
            if (AgeUtils.HighDefinition && this.category == "Game")
            {
                int num2 = 1986;
                this.SettingsGroupsContainer.HorizontalSpacing = 9f;
                if (Screen.width < num2)
                {
                    this.SettingsGroupsContainer.HorizontalSpacing = -3f;
                    num2 -= 48;
                }
                float num3 = ((float)Screen.width - (float)num2) / 2f;
                this.SettingsGroupsContainer.HorizontalMargin = -this.SettingsGroupsContainer.X + num3;
            }
            else if (AgeUtils.HighDefinition)
            {
                this.SettingsGroupsContainer.HorizontalMargin  = 0f;
                this.SettingsGroupsContainer.HorizontalSpacing = 9f;
            }
            else if (!AgeUtils.HighDefinition && this.category == "Game")
            {
                int num4 = 1324;
                this.SettingsGroupsContainer.HorizontalSpacing = 6f;
                if (Screen.width < num4)
                {
                    this.SettingsGroupsContainer.HorizontalSpacing = -2f;
                    num4 -= 32;
                }
                float num5 = ((float)Screen.width - (float)num4) / 2f;
                this.SettingsGroupsContainer.HorizontalMargin = -this.SettingsGroupsContainer.X + num5;
            }
            else
            {
                this.SettingsGroupsContainer.HorizontalMargin  = 0f;
                this.SettingsGroupsContainer.HorizontalSpacing = 6f;
            }
            float num6 = this.SettingsGroupsContainer.HorizontalMargin;
            using (Dictionary <string, List <OptionDefinition> > .Enumerator enumerator4 = this.settingsBySubCategory.GetEnumerator())
            {
                while (enumerator4.MoveNext())
                {
                    KeyValuePair <string, List <OptionDefinition> > reference = enumerator4.Current;
                    string       text2        = "SettingsGroup" + reference.Key;
                    AgeTransform ageTransform = this.SettingsGroupsContainer.InstanciateChild(this.SettingsGroupPrefab, text2);
                    Diagnostics.Assert(ageTransform != null, "Failed to instanciate the {0} with prefab {1}", new object[]
                    {
                        text2,
                        this.SettingsGroupPrefab.name
                    });
                    ageTransform.X = num6;
                    num6          += ageTransform.Width + this.SettingsGroupsContainer.HorizontalSpacing;
                    this.setupAdvancedOptionsDelegate(ageTransform, reference, num);
                    num++;
                    if (num == 5)
                    {
                        AgeControlDropList[] componentsInChildren = ageTransform.GetComponentsInChildren <AgeControlDropList>(true);
                        for (int i = 0; i < componentsInChildren.Length; i++)
                        {
                            AgeTooltip[] componentsInChildren2 = componentsInChildren[i].GetComponentsInChildren <AgeTooltip>(true);
                            for (int j = 0; j < componentsInChildren2.Length; j++)
                            {
                                componentsInChildren2[j].AnchorMode = AgeTooltipAnchorMode.LEFT_CENTER;
                            }
                        }
                    }
                }
                goto IL_515;
            }
        }
        this.filteredOptionDefinitions = null;
        this.BuildOptionValuesByNames();
        this.BuildSettingsBySubCategory();
        this.SettingsGroupsContainer.DestroyAllChildren();
IL_515:
        this.AdvancedDataChanged = false;
        base.NeedRefresh         = true;
        this.RefreshButtons();
        yield break;
    }