Ejemplo n.º 1
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            GizmoResult result = base.GizmoOnGUI(topLeft, maxWidth);

            Designator_Dropdown.DrawExtraOptionsIcon(topLeft, this.GetWidth(maxWidth));
            return(result);
        }
Ejemplo n.º 2
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            defaultDesc = Tooltip;
            disabled    = ability.GizmoDisabled(out string reason);
            if (disabled)
            {
                DisableWithReason(reason.CapitalizeFirst());
            }
            GizmoResult result = base.GizmoOnGUI(topLeft, maxWidth);

            if (ability.CooldownTicksRemaining > 0)
            {
                float num  = Mathf.InverseLerp(ability.CooldownTicksTotal, 0f, ability.CooldownTicksRemaining);
                Rect  rect = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), 75f);
                Widgets.FillableBar(rect, Mathf.Clamp01(num), cooldownBarTex, null, doBorder: false);
                if (ability.CooldownTicksRemaining > 0)
                {
                    Text.Font   = GameFont.Tiny;
                    Text.Anchor = TextAnchor.UpperCenter;
                    Widgets.Label(rect, num.ToStringPercent("F0"));
                    Text.Anchor = TextAnchor.UpperLeft;
                }
            }
            if (result.State == GizmoState.Interacted && ability.CanCast)
            {
                return(result);
            }
            return(new GizmoResult(result.State));
        }
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            GizmoResult result = base.GizmoOnGUI(topLeft, maxWidth);

            if (VEF_ModCompatibilityCheck.enabled_rooloDualWield && verb.EquipmentSource != null && verb.EquipmentSource.def == pawn.equipment.Primary.def && !VEF_Comp_Pawn_RangedVerbs.ShouldUseSquadAttackGizmo())
            {
                try
                {
                    ((Action)(() =>
                    {
                        object[] parameters = new object[] { pawn.equipment, null };
                        bool hasOffHandEquipment = (bool)VEF_ReflectionData.MB_TryGetOffHandEquipment.Invoke(null, parameters);
                        ThingWithComps offHandThing = (ThingWithComps)parameters[1];
                        if (offHandThing != null && offHandThing.GetComp <CompEquippable>() != null && !offHandThing.GetComp <CompEquippable>().AllVerbs.NullOrEmpty())
                        {
                            GUI.color = offHandThing.DrawColor;
                            Material mat = (!this.disabled) ? null : TexUI.GrayscaleGUI;
                            Texture2D texture2D = offHandThing.def.uiIcon;
                            if (texture2D == null)
                            {
                                texture2D = BaseContent.BadTex;
                            }
                            Rect outerRect = new Rect(topLeft.x, topLeft.y + 10f, this.GetWidth(maxWidth), 75f);
                            Widgets.DrawTextureFitted(outerRect, texture2D, this.iconDrawScale * 0.85f, this.iconProportions, this.iconTexCoords, this.iconAngle, mat);
                            GUI.color = Color.white;
                        }
                    }))();
                }
                catch (TypeLoadException ex)
                {
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            GizmoResult result   = base.GizmoOnGUI(topLeft, maxWidth);
            Rect        drawRect = new Rect(topLeft.x + GetWidth(maxWidth) - 24f, topLeft.y, 24f, 24f);
            Texture2D   image    = (!ZoneHarvestableNow) ? Widgets.CheckboxOffTex : Widgets.CheckboxOnTex;

            GUI.DrawTexture(drawRect, image);
            return(result);
        }
        // Token: 0x06001B68 RID: 7016 RVA: 0x000A8A3C File Offset: 0x000A6C3C
        public override GizmoResult GizmoOnGUI(Vector2 loc, float maxWidth)
        {
            GizmoResult result   = base.GizmoOnGUI(loc, maxWidth);
            Rect        rect     = new Rect(loc.x, loc.y, this.GetWidth(maxWidth), 75f);
            Rect        position = new Rect(rect.x, rect.y, 24f, 24f);
            Texture2D   image    = this.isActive() ? Widgets.CheckboxOnTex : Widgets.CheckboxOffTex;

            GUI.DrawTexture(position, image);
            return(result);
        }
Ejemplo n.º 6
0
        public override GizmoResult GizmoOnGUI(Vector2 loc)
        {
            GizmoResult result   = base.GizmoOnGUI(loc);
            Rect        rect     = new Rect(loc.x, loc.y, this.Width, 75f);
            Rect        position = new Rect(rect.x + rect.width - 24f, rect.y, 24f, 24f);
            Texture2D   image    = (!this.isActive()) ? Widgets.CheckboxOffTex : Widgets.CheckboxOnTex;

            GUI.DrawTexture(position, image);
            return(result);
        }
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth, GizmoRenderParms parms)
        {
            GizmoResult result   = base.GizmoOnGUI(topLeft, maxWidth, parms);
            Rect        rect     = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);
            Rect        position = new Rect(rect.x, rect.y, 24f, 24f);
            Texture2D   image    = this.isActive() ? Widgets.CheckboxOnTex : Widgets.CheckboxOffTex;

            GUI.DrawTexture(position, image);
            return(result);
        }
Ejemplo n.º 8
0
        public override GizmoResult GizmoOnGUI(Vector2 loc, float maxWidth)
        {
            GizmoResult result   = base.GizmoOnGUI(loc, maxWidth);
            Rect        rect     = new Rect(loc.x, loc.y, GetWidth(maxWidth), 75f);
            Rect        position = new Rect(rect.x + rect.width - GenUI.SmallIconSize, rect.y, GenUI.SmallIconSize, GenUI.SmallIconSize);
            Texture2D   image    = ContentFinder <Texture2D> .Get("UI/Overlays/Arrow");

            GUI.DrawTexture(position, image);
            return(result);
        }
Ejemplo n.º 9
0
 public static void InterceptInteraction(ref GizmoResult __result, Command __instance)
 {
     if (__result.State == GizmoState.Interacted || __result.State == GizmoState.OpenedFloatMenu)
     {
         var designator = DesignatorContextMenuController.TryResolveCommandToDesignator(__instance);
         if (designator != null && DesignatorContextMenuController.TryProcessDesignatorInput(designator)) // return a blank interact event if we intercepted the input
         {
             __result = new GizmoResult(GizmoState.Clear, __result.InteractEvent);
         }
     }
 }
Ejemplo n.º 10
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            GizmoResult result   = base.GizmoOnGUI(topLeft, maxWidth);
            ThingDef    thingDef = entDef as ThingDef;

            if (thingDef != null && thingDef.MadeFromStuff)
            {
                Designator_Dropdown.DrawExtraOptionsIcon(topLeft, GetWidth(maxWidth));
            }
            return(result);
        }
Ejemplo n.º 11
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth, GizmoRenderParms parms)
        {
            GizmoResult result = base.GizmoOnGUI(topLeft, maxWidth, parms);

            float w    = GetWidth(maxWidth);
            Rect  rect = new Rect(topLeft.x + w / 2, topLeft.y, w / 2, Height / 2);

            Widgets.ThingIcon(rect, stuffDef);

            return(result);
        }
Ejemplo n.º 12
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            GizmoResult result = base.GizmoOnGUI(topLeft, maxWidth);

            //Custom render.
            float width = GetWidth(maxWidth);
            Rect pawnRect = new Rect(topLeft.x + 10f, topLeft.y, width - 40f, width - 20f);
            Vector2 PawnPortraitSize = new Vector2(width - 20f, width);

            GUI.DrawTexture(new Rect(pawnRect.x, pawnRect.y, PawnPortraitSize.x, PawnPortraitSize.y), PortraitsCache.Get(printer.PawnBeingCrafted(), PawnPortraitSize, default(Vector3), 1f));
            return result;
        }
Ejemplo n.º 13
0
        //public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        public static void Postfix(ref GizmoResult __result)
        {
            if (!Mod.settings.blueprintAnyStuff)
            {
                return;
            }

            if (__result.State == GizmoState.OpenedFloatMenu)
            {
                __result = new GizmoResult(GizmoState.Interacted, __result.InteractEvent);
            }
        }
            public override GizmoResult GizmoOnGUI(Vector2 loc, float maxWidth)
            {
                GizmoResult result = base.GizmoOnGUI(loc, maxWidth);

                // add plus sign in the top right of the gizmo texture
                if (MedicalSystemExpansion.WidgetPlusSign != null)
                {
                    Rect rect     = new Rect(loc.x, loc.y, this.GetWidth(maxWidth), 75f);
                    Rect position = new Rect(rect.x + rect.width - 24f, rect.y, 24f, 24f);
                    GUI.DrawTexture(position, MedicalSystemExpansion.WidgetPlusSign);
                }

                return(result);
            }
Ejemplo n.º 15
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft)
        {
            Rect gizmoRect = new Rect(topLeft.x, topLeft.y, this.Width, Height);

            Rect        designatorRect = new Rect(gizmoRect.x, gizmoRect.y, Height, Height);
            GizmoResult result         = this.DrawDesignator(designatorRect);

            GUI.DrawTexture(designatorRect, texPutInArrow);

            // Rect inventoryRect = new Rect(gizmoRect.x + designatorRect.width, gizmoRect.y, curWidth, Height);
            // Widgets.DrawWindowBackground(inventoryRect);
            // DrawSlots(inventoryRect);
            return(result);
        }
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            if (comp == null)
            {
                return(base.GizmoOnGUI(topLeft, maxWidth));
            }
            GizmoResult result = base.GizmoOnGUI(topLeft, maxWidth);

            Text.Font = GameFont.Tiny;
            Rect rect = new Rect(topLeft.x + 52f, topLeft.y + 5f, this.GetWidth(maxWidth) - 10f, 18f);

            Widgets.Label(rect, $"{comp.ammo}/{comp.Props.maxAmmo}");

            return(result);
        }
        public override GizmoResult GizmoOnGUI(Vector2 topLeft)
        {
            GizmoResult val = base.GizmoOnGUI(topLeft);

            if (ValidSubDesignators.Count <= 1)
            {
                return(val);
            }

            var subCategoryIndicatorRect = new Rect(topLeft.x + Width - 20f, topLeft.y + 4f, SubCategoryIndicatorSize.x,
                                                    SubCategoryIndicatorSize.y);

            GUI.DrawTexture(subCategoryIndicatorRect, SubCategoryIndicatorTexture);
            return(val);
        }
Ejemplo n.º 18
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            if (ability.pawn.health.hediffSet.HasHediff(DefDatabase <HediffDef> .GetNamed("PsychicDeafCentaur")))
            {
                Disable("Magnuassembly_Ability_MassPsychicDeafCentaur_DeafnessCantCast"
                        .Translate(FormattingTickTime(ability.pawn.health.hediffSet.GetFirstHediffOfDef(DefDatabase <HediffDef> .GetNamed("PsychicDeafCentaur"))
                                                      .TryGetComp <HediffComp_Disappears>().ticksToDisappear)));
            }
            else if (ability.pawn.Drafted)
            {
                disabled = false;
            }
            GizmoResult gizmoResult = base.GizmoOnGUI(topLeft, maxWidth);

            return(gizmoResult);
        }
Ejemplo n.º 19
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth, GizmoRenderParms parms)
        {
            GizmoResult res = base.GizmoOnGUI(topLeft, maxWidth, parms);

            GUI.color = offHandThing.DrawColor;
            Material  material = (!this.disabled) ? null : TexUI.GrayscaleGUI;
            Texture2D tex      = offHandThing.def.uiIcon;

            if (tex == null)
            {
                tex = BaseContent.BadTex;
            }
            Rect rect = new Rect(topLeft.x, topLeft.y + 10, this.GetWidth(maxWidth), 75f);

            Widgets.DrawTextureFitted(rect, tex, this.iconDrawScale * 0.85f, this.iconProportions, this.iconTexCoords, this.iconAngle, material);
            GUI.color = Color.white;
            return(res);
        }
Ejemplo n.º 20
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            AbilityDef def  = ability.def;
            Pawn       pawn = ability.pawn;

            disabled = false;
            if (def.EntropyGain > float.Epsilon)
            {
                Hediff hediff = pawn.health.hediffSet.hediffs.FirstOrDefault((Hediff h) => h.def == HediffDefOf.PsychicAmplifier);
                if (hediff == null || hediff.Severity < (float)def.level)
                {
                    DisableWithReason("CommandPsycastHigherLevelPsylinkRequired".Translate(def.level));
                }
                else if (pawn.psychicEntropy.WouldOverflowEntropy(def.EntropyGain + PsycastUtility.TotalEntropyFromQueuedPsycasts(pawn)))
                {
                    DisableWithReason("CommandPsycastWouldExceedEntropy".Translate(def.label));
                }
            }
            GizmoResult result = base.GizmoOnGUI(topLeft, maxWidth);
            float       num    = topLeft.y + 3f;
            float       num2   = ((def.EntropyGain > float.Epsilon) ? 15 : 0) + ((def.PsyfocusCost > float.Epsilon) ? 15 : 0);

            if (num2 > 0f)
            {
                GUI.DrawTexture(new Rect(topLeft.x + GetWidth(maxWidth) - 38f, num, 43f, num2), TexUI.GrayTextBG);
            }
            Text.Font = GameFont.Tiny;
            if (def.EntropyGain > float.Epsilon)
            {
                TaggedString taggedString = "NeuralHeatLetter".Translate() + ": " + def.EntropyGain.ToString();
                float        x            = Text.CalcSize(taggedString).x;
                Rect         rect         = new Rect(topLeft.x + GetWidth(maxWidth) - x - 2f, num, x, 18f);
                Widgets.Label(rect, taggedString);
                num += rect.height - 4f;
            }
            if (def.PsyfocusCost > float.Epsilon)
            {
                TaggedString taggedString2 = "PsyfocusLetter".Translate() + ": " + def.PsyfocusCost.ToStringPercent();
                float        x2            = Text.CalcSize(taggedString2).x;
                Widgets.Label(new Rect(topLeft.x + GetWidth(maxWidth) - x2 - 2f, num, x2, 18f), taggedString2);
            }
            return(result);
        }
Ejemplo n.º 21
0
        public override GizmoResult GizmoOnGUI(Vector2 loc, float maxWidth)
        {
            GizmoResult result   = base.GizmoOnGUI(loc, maxWidth);
            Rect        rect     = new Rect(loc.x, loc.y, GetWidth(maxWidth), 75f);
            Rect        position = new Rect(rect.x + rect.width - GenUI.SmallIconSize, rect.y, GenUI.SmallIconSize, GenUI.SmallIconSize);
            Texture2D   image    = ContentFinder <Texture2D> .Get("UI/Overlays/Arrow");

            // The arrow ordinarily points up. So let's render it upside down.
            Matrix4x4 old = GUI.matrix;

            GUI.matrix = Matrix4x4.identity;
            Vector2 vector = position.center;
            Vector2 center = GUIUtility.GUIToScreenPoint(vector);

            UI.RotateAroundPivot(180, center);
            GUI.DrawTexture(position, image);
            GUI.matrix = old;

            return(result);
        }
Ejemplo n.º 22
0
        // Token: 0x060043EB RID: 17387 RVA: 0x0016B798 File Offset: 0x00169998
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth, GizmoRenderParms parms)
        {
            Rect        rect   = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);
            GizmoResult result = base.GizmoOnGUI(topLeft, maxWidth, parms);

            if (this.comp.CooldownTicksRemaining > 0)
            {
                //	float num = Mathf.InverseLerp((float)this.comp.CooldownTicksTotal, 0f, (float)this.comp.CooldownTicksRemaining);
                float num  = Mathf.InverseLerp(0f, (float)this.comp.CooldownTicksTotal, (float)this.comp.CooldownTicksRemaining);
                var   math = (float)this.comp.CooldownTicksRemaining / (float)this.comp.CooldownTicksTotal;
                //	Widgets.FillableBar(rect, Mathf.Clamp01(num), Command_ApparelWargear.cooldownBarTex, null, false);
                AdeptusWidgets.VertFillableBar(rect, Mathf.Clamp01(num), AbilityButtons.FullTex, AbilityButtons.EmptyTex, false);

                /*
                 * if (this.comp.CooldownTicksRemaining > 0)
                 * {
                 *      Text.Font = GameFont.Tiny;
                 *      Text.Anchor = TextAnchor.UpperCenter;
                 * //	Widgets.Label(rect, num.ToStringPercent("F0"));
                 *      Widgets.Label(rect, this.comp.CooldownTicksRemaining.TicksToSeconds().ToString("F2"));
                 *      Text.Anchor = TextAnchor.UpperLeft;
                 * }
                 */
            }
            if (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    tip.text = tip.text + "AU_DISABLED".Translate() + ": " + disabledReason + "\n" + comp.CooldownTicksRemaining.ToStringSecondsFromTicks();
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (result.State == GizmoState.Interacted && this.comp.CanBeUsed)
            {
                return(result);
            }
            return(new GizmoResult(result.State));
        }
Ejemplo n.º 23
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            GizmoResult result;

            if (!this.caravan.Spawned)
            {
                result = new GizmoResult(GizmoState.Clear);
            }
            else
            {
                Rect rect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);
                Widgets.DrawWindowBackground(rect);
                GUI.BeginGroup(rect);
                Rect          rect2         = rect.AtZero();
                int?          ticksToArrive = (!this.caravan.pather.Moving) ? null : new int?(CaravanArrivalTimeEstimator.EstimatedTicksToArrive(this.caravan, true));
                StringBuilder stringBuilder = new StringBuilder();
                float         tilesPerDay   = TilesPerDayCalculator.ApproxTilesPerDay(this.caravan, stringBuilder);
                CaravanUIUtility.DrawCaravanInfo(new CaravanUIUtility.CaravanInfo(this.caravan.MassUsage, this.caravan.MassCapacity, this.caravan.MassCapacityExplanation, tilesPerDay, stringBuilder.ToString(), this.caravan.DaysWorthOfFood, this.caravan.forage.ForagedFoodPerDay, this.caravan.forage.ForagedFoodPerDayExplanation, this.caravan.Visibility, this.caravan.VisibilityExplanation), null, this.caravan.Tile, ticksToArrive, -9999f, rect2, true, null, true);
                GUI.EndGroup();
                GenUI.AbsorbClicksInRect(rect);
                result = new GizmoResult(GizmoState.Clear);
            }
            return(result);
        }
Ejemplo n.º 24
0
        public static void DrawGizmoGrid(IEnumerable <Gizmo> gizmos, float startX, out Gizmo mouseoverGizmo)
        {
            GizmoGridDrawer.gizmoGroups.Clear();
            foreach (Gizmo current in gizmos)
            {
                bool flag = false;
                for (int i = 0; i < GizmoGridDrawer.gizmoGroups.Count; i++)
                {
                    if (GizmoGridDrawer.gizmoGroups[i][0].GroupsWith(current))
                    {
                        flag = true;
                        GizmoGridDrawer.gizmoGroups[i].Add(current);
                        break;
                    }
                }
                if (!flag)
                {
                    List <Gizmo> list = new List <Gizmo>();
                    list.Add(current);
                    GizmoGridDrawer.gizmoGroups.Add(list);
                }
            }
            GizmoGridDrawer.firstGizmos.Clear();
            for (int j = 0; j < GizmoGridDrawer.gizmoGroups.Count; j++)
            {
                List <Gizmo> source = GizmoGridDrawer.gizmoGroups[j];
                Gizmo        gizmo  = source.FirstOrDefault((Gizmo opt) => !opt.disabled);
                if (gizmo == null)
                {
                    gizmo = source.FirstOrDefault <Gizmo>();
                }
                GizmoGridDrawer.firstGizmos.Add(gizmo);
            }
            Verse.GizmoGridDrawer.drawnHotKeys.Clear();
            float num = (float)(Screen.width - 140);

            Text.Font = GameFont.Tiny;
            Vector2 topLeft = new Vector2(startX, (float)(Screen.height - 35) - GizmoGridDrawer.GizmoSpacing.y - 75f);

            mouseoverGizmo = null;
            Gizmo interactedGiz = null;
            Event @event        = null;

            for (int k = 0; k < GizmoGridDrawer.firstGizmos.Count; k++)
            {
                Gizmo gizmo2 = GizmoGridDrawer.firstGizmos[k];
                if (gizmo2.Visible)
                {
                    if (topLeft.x + gizmo2.Width + GizmoGridDrawer.GizmoSpacing.x > num)
                    {
                        topLeft.x  = startX;
                        topLeft.y -= 75f + GizmoGridDrawer.GizmoSpacing.x;
                    }
                    GizmoGridDrawer.heightDrawnFrame = Time.frameCount;
                    GizmoGridDrawer.heightDrawn      = (float)Screen.height - topLeft.y;
                    GizmoResult gizmoResult = gizmo2.GizmoOnGUI(topLeft);
                    if (gizmoResult.State == GizmoState.Interacted)
                    {
                        @event        = gizmoResult.InteractEvent;
                        interactedGiz = gizmo2;
                    }
                    if (gizmoResult.State >= GizmoState.Mouseover)
                    {
                        mouseoverGizmo = gizmo2;
                    }
                    Rect rect = new Rect(topLeft.x, topLeft.y, gizmo2.Width, 75f + GizmoGridDrawer.GizmoSpacing.y);
                    rect = rect.ContractedBy(-12f);
                    GenUI.AbsorbClicksInRect(rect);
                    topLeft.x += gizmo2.Width + GizmoGridDrawer.GizmoSpacing.x;
                }
            }
            if (interactedGiz != null)
            {
                List <Gizmo> list2 = GizmoGridDrawer.gizmoGroups.First((List <Gizmo> group) => group.Contains(interactedGiz));
                for (int l = 0; l < list2.Count; l++)
                {
                    Gizmo gizmo3 = list2[l];
                    if (gizmo3 != interactedGiz && !gizmo3.disabled && gizmo3.InheritInteractionsFrom(interactedGiz))
                    {
                        gizmo3.ProcessInput(@event);
                    }
                }
                if (interactedGiz is Designator_Build)
                {
                    if (@event.button != 1 && GizmoGridDrawer.rightClickMaterialPreference != null && GizmoGridDrawer.rightClickMaterialPreference.Value)
                    {
                        Command command = interactedGiz as Command;
                        if (command != null && command.CurActivateSound != null)
                        {
                            command.CurActivateSound.PlayOneShotOnCamera();
                        }
                        Designator designator = interactedGiz as Designator;
                        if (designator != null)
                        {
                            DesignatorManager.Select(designator);
                        }
                    }
                    else
                    {
                        interactedGiz.ProcessInput(@event);
                    }
                }
                else
                {
                    interactedGiz.ProcessInput(@event);
                }
                Event.current.Use();
            }
        }
Ejemplo n.º 25
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            Text.Font = GameFont.Tiny;
            Rect rect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), GizmoSize);
            bool flag = false;

            if (Mouse.IsOver(rect))
            {
                flag = true;
                if (!this.disabled)
                {
                    GUI.color = GenUI.MouseoverColor;
                }
            }
            Texture2D badTex = this.icon;

            if (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }
            Material material = (!this.disabled) ? null : TexUI.GrayscaleGUI;

            GenUI.DrawTextureWithMaterial(rect, Command.BGTex, material, default(Rect));
            MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
            Rect outerRect = rect;

            outerRect.position += new Vector2(this.iconOffset.x * outerRect.size.x, this.iconOffset.y * outerRect.size.y);
            GUI.color           = this.IconDrawColor;
            Widgets.DrawTextureFitted(outerRect, badTex, this.iconDrawScale * 0.85f, this.iconProportions, this.iconTexCoords, this.iconAngle, material);
            GUI.color = Color.white;
            bool    flag2   = false;
            KeyCode keyCode = (this.hotKey != null) ? this.hotKey.MainKey : KeyCode.None;

            if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                Rect rect2 = new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f);
                Widgets.Label(rect2, keyCode.ToStringReadable());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (this.hotKey.KeyDownEvent)
                {
                    flag2 = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(rect, false))
            {
                flag2 = true;
            }
            string labelCap = this.LabelCap;

            if (!labelCap.NullOrEmpty())
            {
                float num   = Text.CalcHeight(labelCap, rect.width);
                Rect  rect3 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num);
                GUI.DrawTexture(rect3, TexUI.GrayTextBG);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect3, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.color = Color.white;
            if (this.DoTooltip)
            {
                TipSignal tip = this.Desc;
                if (this.disabled && !this.disabledReason.NullOrEmpty())
                {
                    string text = tip.text;
                    tip.text = string.Concat(new string[]
                    {
                        text,
                        "\n\n",
                        "DisabledCommand".Translate(),
                        ": ",
                        this.disabledReason
                    });
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (this.cannon.cooldownTicks > 0)
            {
                float percent = (float)this.cannon.cooldownTicks / (float)this.cannon.MaxTicks;
                SPExtended.VerticalFillableBar(rect, percent, FillableBar, ClearBar);
            }
            if (!this.HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, this.HighlightTag);
            }
            Text.Font = GameFont.Small;
            if (flag2)
            {
                if (this.disabled)
                {
                    if (!this.disabledReason.NullOrEmpty())
                    {
                        Messages.Message(this.disabledReason, MessageTypeDefOf.RejectInput, false);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(this.TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                var result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(this.TutorTagSelect);
                return(result);
            }
            if (flag)
            {
                return(new GizmoResult(GizmoState.Mouseover, null));
            }
            return(new GizmoResult(GizmoState.Clear, null));
        }
Ejemplo n.º 26
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            Rect rect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);
            bool flag = false;

            if (Mouse.IsOver(rect))
            {
                flag      = true;
                GUI.color = GenUI.MouseoverColor;
            }
            Texture2D badTex = LockUtility.GetData(parent).WantedState.locked ? lockTexture : unlockTexture;

            if (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }
            GUI.DrawTexture(rect, BGTex);
            GUI.DrawTexture(rect, badTex);
            MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
            bool    flag2   = false;
            KeyCode keyCode = (this.hotKey != null) ? hotKey.MainKey : KeyCode.None;

            if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                Rect rect2 = new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f);
                Widgets.Label(rect2, keyCode.ToStringReadable());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (hotKey.KeyDownEvent)
                {
                    flag2 = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(rect, false))
            {
                flag2 = true;
            }
            string labelCap = LabelCap;

            if (!labelCap.NullOrEmpty())
            {
                float num   = Text.CalcHeight(labelCap, rect.width);
                Rect  rect3 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num);
                GUI.DrawTexture(rect3, TexUI.GrayTextBG);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect3, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.color = Color.white;
            if (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    string text = tip.text;
                    tip.text = string.Concat(new string[]
                    {
                        text,
                        "\n\n",
                        "DisabledCommand".Translate(),
                        ": ",
                        disabledReason
                    });
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (!HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, HighlightTag);
            }
            if (flag2)
            {
                if (disabled)
                {
                    if (!disabledReason.NullOrEmpty())
                    {
                        Messages.Message(disabledReason, MessageTypeDefOf.RejectInput);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                GizmoResult result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(TutorTagSelect);
                return(result);
            }
            else
            {
                if (flag)
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                return(new GizmoResult(GizmoState.Clear, null));
            }
        }
Ejemplo n.º 27
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            this.disabled = false;
            HarpyComp harpyComp = this.pawn.TryGetComp <HarpyComp>();
            bool      flag      = harpyComp.cooldownTicks > 180f;

            if (flag)
            {
                this.DisableWithReason("Fly_Cooldown".Translate());
            }
            bool flag2 = this.pawn == null;

            if (flag2)
            {
                this.DisableWithReason("Fly_NoPawn".Translate());
            }
            bool flag3 = this.pawn.IsBurning();

            if (flag3)
            {
                this.DisableWithReason("Fly_OnFire".Translate());
            }
            bool dead = this.pawn.Dead;

            if (dead)
            {
                this.DisableWithReason("Fly_Dead".Translate());
            }
            bool inMentalState = this.pawn.InMentalState;

            if (inMentalState)
            {
                this.DisableWithReason("Fly_MentalState".Translate());
            }
            bool flag4 = this.pawn.Downed || this.pawn.stances.stunner.Stunned || !this.pawn.Awake();

            if (flag4)
            {
                this.DisableWithReason("Fly_Downed".Translate());
            }
            bool flag5 = !HarpyUtility.FlightCapabable(this.pawn);

            if (flag5)
            {
                this.DisableWithReason("Mech_Wings".Translate());
            }
            GizmoResult result = base.GizmoOnGUI(topLeft, maxWidth);
            bool        flag6  = harpyComp != null && harpyComp.cooldownTicks > 0f;

            if (flag6)
            {
                CompProperties_HarpyComp compProperties_HarpyComp = harpyComp.props as CompProperties_HarpyComp;
                float value = Mathf.InverseLerp(0f, compProperties_HarpyComp.cooldown * 60f, harpyComp.cooldownTicks);
                Rect  rect  = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);
                Widgets.FillableBar(rect, Mathf.Clamp01(value), Command_HarpyFly.cooldownBarTex, null, false);
                Text.Font   = GameFont.Tiny;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect, (harpyComp.cooldownTicks / 60f).ToStringByStyle(ToStringStyle.Integer, ToStringNumberSense.Absolute));
                Text.Anchor = TextAnchor.UpperLeft;
            }
            return(result);
        }
Ejemplo n.º 28
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft)
        {
            Rect rect = new Rect(topLeft.x, topLeft.y, this.Width, 75f);
            bool flag = false;

            if (Mouse.IsOver(rect))
            {
                flag      = true;
                GUI.color = GenUI.MouseoverColor;
            }
            Texture2D badTex = this.icon;

            if (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }

            GUI.DrawTexture(rect, Command.BGTex);
            MouseoverSounds.DoRegion(rect, SoundDefOf.MouseoverCommand);
            GUI.color = this.IconDrawColor;
            Widgets.DrawTextureFitted(new Rect(rect), badTex, this.iconDrawScale * 0.85f, this.iconProportions, this.iconTexCoords);
            GUI.color = Color.white;
            bool flag2   = false;
            Rect rectFil = new Rect(topLeft.x, topLeft.y, this.Width, this.Width);

            KeyCode keyCode = (this.hotKey != null) ? this.hotKey.MainKey : KeyCode.None;

            if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                Rect rect2 = new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f);
                Widgets.Label(rect2, keyCode.ToStringReadable());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (this.hotKey.KeyDownEvent)
                {
                    flag2 = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(rect, false))
            {
                flag2 = true;
            }
            string labelCap = this.LabelCap;

            if (!labelCap.NullOrEmpty())
            {
                float num = Text.CalcHeight(labelCap, rect.width);
                num -= 2f;
                Rect rect3 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num);
                GUI.DrawTexture(rect3, TexUI.GrayTextBG);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect3, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.color = Color.white;
            if (this.DoTooltip)
            {
                TipSignal tip = this.Desc;
                if (this.disabled && !this.disabledReason.NullOrEmpty())
                {
                    tip.text = tip.text + "\n\nDISABLED: " + this.disabledReason;
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (!this.HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, this.HighlightTag);
            }
            float x    = compPsyker.TicksToCast;
            float y    = compPsyker.TicksToCastMax;
            float fill = x / y;

            Widgets.FillableBar(rect, fill, FullTex, EmptyTex, false);
            if (flag2)
            {
                if (this.disabled)
                {
                    if (!this.disabledReason.NullOrEmpty())
                    {
                        Messages.Message(this.disabledReason, MessageSound.RejectInput);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(this.TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                GizmoResult result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(this.TutorTagSelect);
                return(result);
            }
            else
            {
                if (flag)
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                return(new GizmoResult(GizmoState.Clear, null));
            }
        }
        //public override bool GroupsWith(Gizmo other)
        //{
        //    if (other is Command_PawnAbility p && p.pawnAbility.Def.abilityClass == this.pawnAbility.Def.abilityClass)
        //        return true;
        //    return false;
        //}

        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            var rect        = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);
            var isMouseOver = false;

            if (Mouse.IsOver(rect))
            {
                isMouseOver = true;
                GUI.color   = GenUI.MouseoverColor;
            }
            var badTex = icon;

            if (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }

            GUI.DrawTexture(rect, BGTex);
            MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
            GUI.color = IconDrawColor;
            Widgets.DrawTextureFitted(new Rect(rect), badTex, iconDrawScale * 0.85f, iconProportions, iconTexCoords);
            GUI.color = Color.white;
            var isUsed = false;
            //Rect rectFil = new Rect(topLeft.x, topLeft.y, this.Width, this.Width);

            var keyCode = hotKey != null ? hotKey.MainKey : KeyCode.None;

            if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                var rect2 = new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f);
                Widgets.Label(rect2, keyCode.ToStringReadable());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (hotKey.KeyDownEvent)
                {
                    isUsed = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(rect, false))
            {
                isUsed = true;
            }
            var labelCap = LabelCap;

            if (!labelCap.NullOrEmpty())
            {
                var num = Text.CalcHeight(labelCap, rect.width);
                num -= 2f;
                var rect3 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num);
                GUI.DrawTexture(rect3, TexUI.GrayTextBG);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect3, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.color = Color.white;
            if (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    tip.text = tip.text + "\n" + StringsToTranslate.AU_DISABLED + ": " + disabledReason;
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (pawnAbility.CooldownTicksLeft != -1 && pawnAbility.CooldownTicksLeft < pawnAbility.MaxCastingTicks)
            {
                var math = curTicks / (float)pawnAbility.MaxCastingTicks;
                Widgets.FillableBar(rect, math, AbilityButtons.FullTex, AbilityButtons.EmptyTex, false);
            }
            if (!HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null ||
                                                !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, HighlightTag);
            }
            if (isUsed)
            {
                if (disabled)
                {
                    if (!disabledReason.NullOrEmpty())
                    {
                        Messages.Message(disabledReason, MessageTypeDefOf.RejectInput);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                var result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(TutorTagSelect);
                return(result);
            }
            if (isMouseOver)
            {
                return(new GizmoResult(GizmoState.Mouseover, null));
            }
            return(new GizmoResult(GizmoState.Clear, null));
        }
Ejemplo n.º 30
0
        //public override bool GroupsWith(Gizmo other)
        //{
        //    return other is Command_PawnAbility p && p.pawnAbility.Def.abilityClass == pawnAbility.Def.abilityClass;
        //}

        protected override GizmoResult GizmoOnGUIInt(Rect butRect, GizmoRenderParms parms)
        {
            // TODO: This is based off Command.GizmoOnGUI at version ~A17, so it's very outdated. Actually use parms and other modern features.
            var isMouseOver = false;

            if (Mouse.IsOver(butRect))
            {
                isMouseOver = true;
                GUI.color   = GenUI.MouseoverColor;
            }
            var badTex = icon ?? BaseContent.BadTex;

            GUI.DrawTexture(butRect, BGTex);
            MouseoverSounds.DoRegion(butRect, SoundDefOf.Mouseover_Command);
            GUI.color = IconDrawColor;
            Widgets.DrawTextureFitted(new Rect(butRect), badTex, iconDrawScale * 0.85f, iconProportions, iconTexCoords);
            GUI.color = Color.white;
            var isUsed = false;

            var keyCode = hotKey != null ? hotKey.MainKey : KeyCode.None;

            if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                var hotkeyRect = new Rect(butRect.x + 5f, butRect.y + 5f, butRect.width - 10f, 18f);
                Widgets.Label(hotkeyRect, keyCode.ToStringReadable());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (hotKey.KeyDownEvent)
                {
                    isUsed = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(butRect, false))
            {
                isUsed = true;
            }
            var labelCap = LabelCap;

            if (!labelCap.NullOrEmpty())
            {
                var labelHeight = Text.CalcHeight(labelCap, butRect.width) - 2f;
                var labelRect   = new Rect(butRect.x, butRect.yMax - labelHeight + 12f, butRect.width, labelHeight);
                GUI.DrawTexture(labelRect, TexUI.GrayTextBG);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(labelRect, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.color = Color.white;
            if (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    tip.text += "\n" + StringsToTranslate.AU_DISABLED + ": " + disabledReason;
                }
                TooltipHandler.TipRegion(butRect, tip);
            }
            if (pawnAbility.CooldownTicksLeft != -1 && pawnAbility.CooldownTicksLeft < pawnAbility.MaxCastingTicks)
            {
                var math = curTicks / (float)pawnAbility.MaxCastingTicks;
                Widgets.FillableBar(butRect, math, AbilityButtons.FullTex, AbilityButtons.EmptyTex, false);
            }
            if (!HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null ||
                                                !Find.WindowStack.FloatMenu.windowRect.Overlaps(butRect)))
            {
                UIHighlighter.HighlightOpportunity(butRect, HighlightTag);
            }
            if (isUsed)
            {
                if (disabled)
                {
                    if (!disabledReason.NullOrEmpty())
                    {
                        Messages.Message(disabledReason, MessageTypeDefOf.RejectInput);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                var result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(TutorTagSelect);
                return(result);
            }
            return(new GizmoResult(isMouseOver ? GizmoState.Mouseover : GizmoState.Clear, null));
        }