private static void PrefixOnClick(UIPartActionButton __instance, ref PartModule ___partModule, ref BaseEvent ___evt)
 {
     if (__instance.IsModule && ___partModule != null && ___evt != null)
     {
         if (FieldModuleStore.CustomizedModuleBehaviours.TryGetValue(___partModule.moduleName, out var moduleCustomization) &&
             moduleCustomization.CustomizedMethods.ContainsKey(___evt.name))
         {
             PartModuleEvent.onPartModuleMethodCalling.Fire(___partModule, ___evt.name);
         }
     }
 }
        private void parseUIWindow()
        {
            UIPartActionWindow windowPrefab = UIPartActionController.Instance.windowPrefab;
            UIPartActionButton buttonPrefab = UIPartActionController.Instance.eventItemPrefab;

            if (windowPrefab == null || buttonPrefab == null)
            {
                return;
            }

            _lineColor        = windowPrefab.lineColor;
            _lineCornerRadius = windowPrefab.lineCornerRadius;
            _lineMaterial     = windowPrefab.lineMaterial;
            _lineWidth        = windowPrefab.lineWidth;

            Image Title = windowPrefab.titleBar.gameObject.GetComponent <Image>();

            TitleBackground = Title.sprite;
            TitleColor      = Title.color;

            UIMaterial = Title.material;

            Image Window = windowPrefab.GetComponentInChildren <Image>(true);

            WindowBackground = Window.sprite;
            WindowColor      = Window.color;

            Toggle pin = windowPrefab.togglePinned;

            Selectable pinSelect = pin.GetComponent <Selectable>();

            ToggleNormal     = pinSelect.image.sprite;
            ToggleHightlight = pinSelect.spriteState.highlightedSprite;
            ToggleActive     = pinSelect.spriteState.pressedSprite;
            ToggleInactive   = pinSelect.spriteState.disabledSprite;

            Image checkmark = pin.GetComponentsInChildren <Image>(true)[1];

            ToggleCheckmark = checkmark.sprite;

            Selectable button = buttonPrefab.button.GetComponent <Selectable>();

            ButtonNormal    = button.image.sprite;
            ButtonHighlight = button.spriteState.highlightedSprite;
            ButtonActive    = button.spriteState.pressedSprite;
            ButtonInactive  = button.spriteState.disabledSprite;
        }
示例#3
0
        public static UIPartActionScaleEdit CreateTemplate()
        {
            // Create the control
            GameObject            editGo = new GameObject("UIPartActionScaleEdit", SystemUtils.VersionTaggedType(typeof(UIPartActionScaleEdit)));
            UIPartActionScaleEdit edit   = editGo.GetTaggedComponent <UIPartActionScaleEdit>();

            editGo.SetActive(false);

            // TODO: since I don'type have access to EZE GUI, I'm copying out bits from other existing GUIs
            // if someone does have access, they could do this better although really it works pretty well.
            UIPartActionButton evtp            = UIPartActionController.Instance.eventItemPrefab;
            GameObject         srcTextGo       = evtp.transform.Find("Text").gameObject;
            GameObject         srcBackgroundGo = evtp.transform.Find("Background").gameObject;
            GameObject         srcButtonGo     = evtp.transform.Find("Btn").gameObject;

            UIPartActionFloatRange paFlt       = (UIPartActionFloatRange)UIPartActionController.Instance.fieldPrefabs.Find(cls => cls.GetType() == typeof(UIPartActionFloatRange));
            GameObject             srcSliderGo = paFlt.transform.Find("Slider").gameObject;


            // Start building our control
            GameObject backgroundGo = (GameObject)Instantiate(srcBackgroundGo);

            backgroundGo.transform.parent = editGo.transform;

            GameObject sliderGo = (GameObject)Instantiate(srcSliderGo);

            sliderGo.transform.parent     = editGo.transform;
            sliderGo.transform.localScale = new Vector3(0.65f, 1, 1);
            edit.slider = sliderGo.GetComponent <UIProgressSlider>();
            edit.slider.ignoreDefault = true;


            GameObject fieldNameGo = (GameObject)Instantiate(srcTextGo);

            fieldNameGo.transform.parent        = editGo.transform;
            fieldNameGo.transform.localPosition = new Vector3(40, -8, 0);
            edit.fieldName = fieldNameGo.GetComponent <SpriteText>();

            GameObject fieldValueGo = (GameObject)Instantiate(srcTextGo);

            fieldValueGo.transform.parent        = editGo.transform;
            fieldValueGo.transform.localPosition = new Vector3(110, -8, 0);
            edit.fieldValue = fieldValueGo.GetComponent <SpriteText>();


            GameObject incLargeDownGo = (GameObject)Instantiate(srcButtonGo);

            incLargeDownGo.transform.parent        = edit.transform;
            incLargeDownGo.transform.localScale    = new Vector3(0.45f, 1.1f, 1f);
            incLargeDownGo.transform.localPosition = new Vector3(11.5f, -9, 0); //>11
            edit.incLargeDown = incLargeDownGo.GetComponent <UIButton>();

            GameObject incLargeDownLabelGo = (GameObject)Instantiate(srcTextGo);

            incLargeDownLabelGo.transform.parent        = editGo.transform;
            incLargeDownLabelGo.transform.localPosition = new Vector3(5.5f, -7, 0); // <6
            edit.incLargeDownLabel      = incLargeDownLabelGo.GetComponent <SpriteText>();
            edit.incLargeDownLabel.Text = "<<";

            GameObject incLargeUpGo = (GameObject)Instantiate(srcButtonGo);

            incLargeUpGo.transform.parent        = edit.transform;
            incLargeUpGo.transform.localScale    = new Vector3(0.45f, 1.1f, 1f);
            incLargeUpGo.transform.localPosition = new Vector3(187.5f, -9, 0); // >187
            edit.incLargeUp = incLargeUpGo.GetComponent <UIButton>();

            GameObject incLargeUpLabelGo = (GameObject)Instantiate(srcTextGo);

            incLargeUpLabelGo.transform.parent        = editGo.transform;
            incLargeUpLabelGo.transform.localPosition = new Vector3(181.5f, -7, 0); //<182
            edit.incLargeUpLabel      = incLargeUpLabelGo.GetComponent <SpriteText>();
            edit.incLargeUpLabel.Text = ">>";
            return(edit);
        }