Beispiel #1
0
    QuickButton PullButton()
    {
        QuickButton button = null;

        if (cache_buttons_.Count > 0)
        {
            button = cache_buttons_.Pop();
        }
        else
        {
            var obj = GameObject.Instantiate(template_button.gameObject);
            button = obj.AddComponent <QuickButton>();
            button.transform.SetParent(transform);
            var rt = button.transform as RectTransform;
            if (width == 0 || height == 0)
            {
                width  = rt.sizeDelta.x;
                height = rt.sizeDelta.y;
            }

            rt.localScale = Vector3.one;
            rt.anchorMax  = new Vector2(1, 0);
            rt.anchorMin  = rt.anchorMax;
            rt.pivot      = Vector2.one;
        }
        return(button);
    }
Beispiel #2
0
    void PushButton(QuickButton button)
    {
        button.name = "unused";
        button.gameObject.SetActive(false);
        var rt = button.transform as RectTransform;

        rt.anchoredPosition = new Vector2(0, 0);
        cache_buttons_.Push(button);
    }
Beispiel #3
0
        private void Grid_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            var dependencyObject = e.OriginalSource as DependencyObject;
            var target           = dependencyObject.FindParent <QuadrantExpandingButton>();

            if (target == null)
            {
                QuickButton.CollapseAll();
            }
        }
Beispiel #4
0
        public void SwitchToQuickButtonConfiguration(string key, bool expand = false)
        {
            if (quickButtonConfigurations.ContainsKey(key))
            {
                // set active configuration
                activeQuickButtonItems = quickButtonConfigurations[key];

                // invalidate binding
                OnPropertyChanged("QuickButtonConfiguration");

                // expand if needed
                if (expand)
                {
                    QuickButton.ExpandRootButton();
                }
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // Magic number 15 is reflected from Unity's EditorGUI.cs
            // "internal static float indent" property
            position.xMin += EditorGUI.indentLevel * 15;

            if (GUI.Button(position, label))
            {
                QuickButton button = GetObjectForProperty(property) as QuickButton;
                if (button == null)
                {
                    Debug.LogError("Unable to resolve QuickButton from property " + property.propertyPath);
                    return;
                }

                object target = GetObjectForProperty(property, -1) ??
                                property.serializedObject.targetObject;

                button.Invoke(target);
            }
        }
Beispiel #6
0
        internal static void InjectDropInvButton()
        {
            var invManager = UIInventoryManager.Instance.gameObject.ChildPath("InventoryWindow/UnlitContent/StuffBar");

            if (_dropButton.IsAlive())
            {
                return;
            }
            var craftButton = invManager.Child("Craft").Component <UIMultiSpriteImageButton>();

            craftButton.transform.localPosition += new Vector3(0, 25, 0);
            craftButton.transform.localScale     = new Vector3(0.82f, 0.82f, 0.82f);

            _dropButton = new QuickButton(craftButton.transform.parent, "DropButton", craftButton.gameObject, false)
            {
                LocalScale    = craftButton.transform.localScale,
                LocalPosition = craftButton.transform.localPosition.Plus(y: -50f),
                Caption       = "Drop Items"
            };
            _dropButton.ButtonComponent.Label.multiLine   = false;
            _dropButton.ButtonComponent.Label.shrinkToFit = true;
            _dropButton.Click += x => DropInventory();
        }
Beispiel #7
0
        public static void Initialize()
        {
            //Note that the game will destroy the UI when you go to the main menu, so we'll have to rebuild it.
            //The best way to check if we need to initialize everything seem to be the following, though it's strange messy.
            if (IsInitialized)
            {
                return;
            }

            //This is the 'Customize UI' button that lets you customize the UI.
            _customizeButton = new QuickButton(UIPartyPortraitBar.Instance.transform.parent)
            {
                Caption       = "Customize UI",
                Name          = "CustomizeUI",
                LocalPosition = new Vector3(903.5f, 76.2f, 0f),
                LocalScale    = new Vector3(0.7f, 0.7f, 1f)
            };

            _customizeButton.Click += x => {
                SaveLayout(IEModOptions.Layout);
                ShowInterface(!IsInterfaceVisible);
            };

            DefaultActionBarAtlas =
                Attack.Child(0).Component <UISprite>().atlas.spriteMaterial.mainTexture;

            //these may break in future version changes, but I doubt they'll break much.
            //since changing them will probably break some of the developer's code as well
            //to fix them, dump the UICamera hierarchy to file and see which names changed.
            //using Child(string) also tells you which names are broken because it throws an exception if it can't find something,
            //instead of silently returning null and letting you figure out where the problem came from.
            if (DefaultLayout == null)
            {
                DefaultLayout = new IEModOptions.LayoutOptions();
                SaveLayout(DefaultLayout);
            }



            // turning off BB-version label in the upper right corner, cause it's annoying when you want to move portraits there
            UiCamera.Child("BBVersion").gameObject.SetActive(false);

            // UIAnchors on the ActionBarWindow that prevent it from being moved... (it's related to the partybar somehow?)
            // HUD -> Bottom -> ActionBarWindow -> destroy 3 UIAnchors
            foreach (var comp in ActionBarWindow.Components <UIAnchor>())
            {
                GameUtilities.DestroyComponent(comp);
            }

            var component = ConsoleWindow.Component <UIAnchor>();

            if (component)
            {
                GameUtilities.DestroyComponent(component);
            }

            // disable the minimize buttons for the log and the actionbar
            Bottom.Child("ConsoleMinimize").SetActive(false);
            Bottom.Child("ActionBarMinimize").gameObject.SetActive(false);

            // this UIPanel used to hide the clock when it was moved from far away from its original position
            // HUD -> Bottom -> ActionBarWindow -> ActionBarExpandedAnchor -> UIPanel
            ActionBarWindow.Component <UIPanel>().clipping = UIDrawCall.Clipping.None;

            // detaches the "GAME PAUSED" and "SLOW MO" from the Clock panel, to which it was attached for some reason...
            var gamePausedAnchors = UiCamera.Child("GamePaused").Components <UIAnchor>();

            gamePausedAnchors[0].widgetContainer = Hud.Component <UIPanel>().widgets[0];
            gamePausedAnchors[1].DisableY        = true;
            var slowMoAnchors = UiCamera.Child("GameSpeed").Components <UIAnchor>();

            slowMoAnchors[0].widgetContainer = Hud.Component <UIPanel>().widgets[0];
            slowMoAnchors[1].DisableY        = true;
            PartyBar.AddChild(new GameObject("IsInitialized"));
        }