// free the "T" key, claimed by vanilla in 1.0. This is only done once and in the interest of not breaking player habits
 private void OverrideVanillaKeyIfNeeded()
 {
     if (!VanillaKeyOverridenSetting)
     {
         var keyDef = KeyBindingDefOf.ToggleBeautyDisplay;
         if (keyDef.MainKey == KeyCode.T)
         {
             KeyBindingData kbd;
             if (KeyPrefs.KeyPrefsData.keyPrefs.TryGetValue(keyDef, out kbd))
             {
                 kbd.keyBindingA = KeyCode.None;
                 KeyPrefs.Save();
                 VanillaKeyOverridenSetting.Value = true;
                 HugsLibController.SettingsManager.SaveChanges();
                 Logger.Message("Cleared 'toggle beauty display' key binding");
             }
         }
     }
 }
コード例 #2
0
ファイル: Dialog_KeyBindings.cs プロジェクト: potsh/RimWorld
        public override void DoWindowContents(Rect inRect)
        {
            Vector2 vector    = new Vector2(120f, 40f);
            float   y         = vector.y;
            float   num       = 600f;
            float   num2      = (inRect.width - num) / 2f;
            Rect    position  = new Rect(num2 + inRect.x, inRect.y, num, inRect.height - (y + 10f)).ContractedBy(10f);
            Rect    position2 = new Rect(position.x, position.y + position.height + 10f, position.width, y);

            GUI.BeginGroup(position);
            Rect rect = new Rect(0f, 0f, position.width, 40f);

            Text.Font = GameFont.Medium;
            GenUI.SetLabelAlign(TextAnchor.MiddleCenter);
            Widgets.Label(rect, "KeyboardConfig".Translate());
            GenUI.ResetLabelAlign();
            Text.Font = GameFont.Small;
            Rect outRect = new Rect(0f, rect.height, position.width, position.height - rect.height);
            Rect rect2   = new Rect(0f, 0f, outRect.width - 16f, contentHeight);

            Widgets.BeginScrollView(outRect, ref scrollPosition, rect2);
            float curY = 0f;
            KeyBindingCategoryDef keyBindingCategoryDef = null;

            keyBindingsWorkingList.Clear();
            keyBindingsWorkingList.AddRange(DefDatabase <KeyBindingDef> .AllDefs);
            keyBindingsWorkingList.SortBy((KeyBindingDef x) => x.category.index, (KeyBindingDef x) => x.index);
            for (int i = 0; i < keyBindingsWorkingList.Count; i++)
            {
                KeyBindingDef keyBindingDef = keyBindingsWorkingList[i];
                if (keyBindingCategoryDef != keyBindingDef.category)
                {
                    bool skipDrawing = curY - scrollPosition.y + 40f < 0f || curY - scrollPosition.y > outRect.height;
                    keyBindingCategoryDef = keyBindingDef.category;
                    DrawCategoryEntry(keyBindingCategoryDef, rect2.width, ref curY, skipDrawing);
                }
                bool skipDrawing2 = curY - scrollPosition.y + 34f < 0f || curY - scrollPosition.y > outRect.height;
                DrawKeyEntry(keyBindingDef, rect2, ref curY, skipDrawing2);
            }
            Widgets.EndScrollView();
            GUI.EndGroup();
            GUI.BeginGroup(position2);
            int   num3  = 3;
            float num4  = vector.x * (float)num3 + 10f * (float)(num3 - 1);
            float num5  = (position2.width - num4) / 2f;
            float num6  = vector.x + 10f;
            Rect  rect3 = new Rect(num5, 0f, vector.x, vector.y);
            Rect  rect4 = new Rect(num5 + num6, 0f, vector.x, vector.y);
            Rect  rect5 = new Rect(num5 + num6 * 2f, 0f, vector.x, vector.y);

            if (Widgets.ButtonText(rect3, "ResetButton".Translate()))
            {
                keyPrefsData.ResetToDefaults();
                keyPrefsData.ErrorCheck();
                SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                Event.current.Use();
            }
            if (Widgets.ButtonText(rect4, "CancelButton".Translate()))
            {
                Close();
                Event.current.Use();
            }
            if (Widgets.ButtonText(rect5, "OK".Translate()))
            {
                KeyPrefs.KeyPrefsData = keyPrefsData;
                KeyPrefs.Save();
                Close();
                keyPrefsData.ErrorCheck();
                Event.current.Use();
            }
            GUI.EndGroup();
        }
コード例 #3
0
        public override void DoWindowContents(Rect inRect)
        {
            Vector2 vector    = new Vector2(120f, 40f);
            float   y         = vector.y;
            float   num       = 600f;
            float   num2      = (float)((inRect.width - num) / 2.0);
            Rect    position  = new Rect(num2 + inRect.x, inRect.y, num, (float)(inRect.height - (y + 10.0))).ContractedBy(10f);
            Rect    position2 = new Rect(position.x, (float)(position.y + position.height + 10.0), position.width, y);

            GUI.BeginGroup(position);
            Rect rect = new Rect(0f, 0f, position.width, 40f);

            Text.Font = GameFont.Medium;
            GenUI.SetLabelAlign(TextAnchor.MiddleCenter);
            Widgets.Label(rect, "KeyboardConfig".Translate());
            GenUI.ResetLabelAlign();
            Text.Font = GameFont.Small;
            Rect outRect = new Rect(0f, rect.height, position.width, position.height - rect.height);
            Rect rect2   = new Rect(0f, 0f, (float)(outRect.width - 16.0), this.contentHeight);

            Widgets.BeginScrollView(outRect, ref this.scrollPosition, rect2, true);
            float num3 = 0f;
            KeyBindingCategoryDef keyBindingCategoryDef = null;

            Dialog_KeyBindings.keyBindingsWorkingList.Clear();
            Dialog_KeyBindings.keyBindingsWorkingList.AddRange(DefDatabase <KeyBindingDef> .AllDefs);
            Dialog_KeyBindings.keyBindingsWorkingList.SortBy((KeyBindingDef x) => x.category.index, (KeyBindingDef x) => x.index);
            for (int i = 0; i < Dialog_KeyBindings.keyBindingsWorkingList.Count; i++)
            {
                KeyBindingDef keyBindingDef = Dialog_KeyBindings.keyBindingsWorkingList[i];
                if (keyBindingCategoryDef != keyBindingDef.category)
                {
                    bool skipDrawing = num3 - this.scrollPosition.y + 40.0 < 0.0 || num3 - this.scrollPosition.y > outRect.height;
                    keyBindingCategoryDef = keyBindingDef.category;
                    this.DrawCategoryEntry(keyBindingCategoryDef, rect2.width, ref num3, skipDrawing);
                }
                bool skipDrawing2 = num3 - this.scrollPosition.y + 34.0 < 0.0 || num3 - this.scrollPosition.y > outRect.height;
                this.DrawKeyEntry(keyBindingDef, rect2, ref num3, skipDrawing2);
            }
            Widgets.EndScrollView();
            GUI.EndGroup();
            GUI.BeginGroup(position2);
            int   num4  = 3;
            float num5  = (float)(vector.x * (float)num4 + 10.0 * (float)(num4 - 1));
            float num6  = (float)((position2.width - num5) / 2.0);
            float num7  = (float)(vector.x + 10.0);
            Rect  rect3 = new Rect(num6, 0f, vector.x, vector.y);
            Rect  rect4 = new Rect(num6 + num7, 0f, vector.x, vector.y);
            Rect  rect5 = new Rect((float)(num6 + num7 * 2.0), 0f, vector.x, vector.y);

            if (Widgets.ButtonText(rect3, "ResetButton".Translate(), true, false, true))
            {
                this.keyPrefsData.ResetToDefaults();
                this.keyPrefsData.ErrorCheck();
                SoundDefOf.TickLow.PlayOneShotOnCamera(null);
                Event.current.Use();
            }
            if (Widgets.ButtonText(rect4, "CancelButton".Translate(), true, false, true))
            {
                this.Close(true);
                Event.current.Use();
            }
            if (Widgets.ButtonText(rect5, "OK".Translate(), true, false, true))
            {
                KeyPrefs.KeyPrefsData = this.keyPrefsData;
                KeyPrefs.Save();
                this.Close(true);
                this.keyPrefsData.ErrorCheck();
                Event.current.Use();
            }
            GUI.EndGroup();
        }