예제 #1
0
        public KeyBindingsPage()
        {
            StyleSheet.Load("/ui/generalhud/tabmenu/tttmenu/pages/KeyBindingsPage/KeyBindingsPage.scss");

            Add.TranslationLabel(new TranslationData("MENU.KEYBINDINGS.RESTRICTION"));
            Add.Label("");

            TranslationTabContainer translationTabContainer = Add.TranslationTabContainer();

            Panel movementPanel = new();

            movementPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.MOVEMENT.FORWARD", InputButton.Forward));
            movementPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.MOVEMENT.BACK", InputButton.Back));
            movementPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.MOVEMENT.LEFT", InputButton.Left));
            movementPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.MOVEMENT.RIGHT", InputButton.Right));
            movementPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.MOVEMENT.JUMP", InputButton.Jump));
            movementPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.MOVEMENT.CROUCH", InputButton.Duck));
            movementPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.MOVEMENT.SPRINT", InputButton.Run));

            translationTabContainer.AddTab(movementPanel, new TranslationData("MENU.KEYBINDINGS.MOVEMENT.TITLE"));

            Panel weaponsPanel = new();

            weaponsPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.WEAPONS.FIRE", InputButton.Attack1));
            weaponsPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.WEAPONS.RELOAD", InputButton.Reload));
            weaponsPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.WEAPONS.DROP_WEAPON", InputButton.Drop));
            weaponsPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.WEAPONS.DROP_AMMO", InputButton.Run, InputButton.Drop));

            translationTabContainer.AddTab(weaponsPanel, new TranslationData("MENU.KEYBINDINGS.WEAPONS.TITLE"));

            Panel actionsPanel = new();

            actionsPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.ACTIONS.USE", InputButton.Use));
            actionsPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.ACTIONS.FLASHLIGHT", InputButton.Flashlight));

            translationTabContainer.AddTab(actionsPanel, new TranslationData("MENU.KEYBINDINGS.ACTIONS.TITLE"));

            Panel communicationsPanel = new();

            communicationsPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.COMMUNICATION.VOICECHAT", InputButton.Voice));
            communicationsPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.COMMUNICATION.TEAMVOICECHAT", InputButton.Walk));
            communicationsPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.COMMUNICATION.TEAMTEXTCHAT", InputButton.Score));

            translationTabContainer.AddTab(communicationsPanel, new TranslationData("MENU.KEYBINDINGS.COMMUNICATION.TITLE"));

            Panel menusPanel = new();

            menusPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.MENUS.MENU", InputButton.Score));
            menusPanel.AddChild(new BindingPanel("MENU.KEYBINDINGS.MENUS.QUICKSHOP", InputButton.View));

            translationTabContainer.AddTab(menusPanel, new TranslationData("MENU.KEYBINDINGS.MENUS.TITLE"));
        }
예제 #2
0
        public static void CreateSettings(TranslationTabContainer tabContainer, Settings.Settings settings, Type settingsType = null)
        {
            settingsType ??= settings.GetType();

            Type baseSettingsType = typeof(Settings.Settings);

            if (settingsType != baseSettingsType)
            {
                CreateSettings(tabContainer, settings, settingsType.BaseType);
            }

            PropertyInfo[] properties = settingsType.GetProperties();
            string         nsp        = typeof(Settings.Categories.Round).Namespace;

            foreach (PropertyInfo propertyInfo in properties)
            {
                if (propertyInfo.DeclaringType.BaseType != baseSettingsType && settingsType != baseSettingsType || !propertyInfo.PropertyType.Namespace.Equals(nsp))
                {
                    continue;
                }

                string categoryName   = propertyInfo.Name;
                object propertyObject = propertyInfo.GetValue(settings);

                if (propertyObject == null)
                {
                    continue;
                }

                Panel tab = new();
                tab.AddClass("root");

                foreach (PropertyInfo subPropertyInfo in propertyInfo.PropertyType.GetProperties())
                {
                    foreach (object attribute in subPropertyInfo.GetCustomAttributes())
                    {
                        if (attribute is not SettingAttribute settingAttribute)
                        {
                            continue;
                        }

                        string propertyName = subPropertyInfo.Name;

                        switch (settingAttribute)
                        {
                        case SwitchSettingAttribute:
                            CreateSwitchSetting(tab, settings, categoryName, propertyName, propertyObject);

                            break;

                        case InputSettingAttribute:
                            CreateInputSetting(tab, settings, categoryName, propertyName, propertyObject);

                            break;

                        case DropdownSettingAttribute:
                            CreateDropdownSetting(tab, settings, categoryName, propertyName, propertyObject, propertyInfo, subPropertyInfo);

                            break;
                        }

                        break;
                    }

                    tab.Add.LineBreak();
                }

                tabContainer.AddTab(tab, new TranslationData($"MENU.SETTINGS.TABS.{categoryName.ToUpper()}.TITLE"));
            }
        }