private void DrawFileButtons(SaveFile file, ref float width)
        {
            if (file.replay)
            {
                if (Widgets.ButtonText(new Rect(width, 0, 120, 40), "MpWatchReplay".Translate()))
                {
                    Close(false);
                    Replay.LoadReplay(file.file);
                }

                width += 120 + 10;
            }

            if (Widgets.ButtonText(new Rect(width, 0, 120, 40), "MpHostButton".Translate()))
            {
                Close(false);
                Find.WindowStack.Add(new HostWindow(file)
                {
                    returnToServerBrowser = true
                });
            }

            width += 120 + 10;

            if (Widgets.ButtonText(new Rect(width, 0, 120, 40), "Delete".Translate()))
            {
                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmDelete".Translate(file.displayName), () =>
                {
                    file.file.Delete();
                    ReloadFiles();
                }, true));
            }

            width += 120;
        }
        private static void ConfirmationCheckbox(Rect rect, string label, ref bool checkOn, bool disabled = false, Texture2D texChecked = null, Texture2D texUnchecked = null, bool placeCheckboxNearText = false)
        {
            TextAnchor anchor = Text.Anchor;

            Text.Anchor = TextAnchor.MiddleLeft;
            if (placeCheckboxNearText)
            {
                rect.width = Mathf.Min(rect.width, Text.CalcSize(label).x + 24f + 10f);
            }
            Widgets.Label(rect, label);
            if (!disabled && Widgets.ButtonInvisible(rect, true))
            {
                bool checkState = !checkOn;
                tmpState = false;
                if (checkState)
                {
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("DebugWriterConfirmation".Translate(), delegate()
                    {
                        tmpState = true;
                        SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null);
                    }));
                }
            }
            checkOn = tmpState;
            CheckboxDraw(rect.x + rect.width - 24f, rect.y, checkOn, disabled, 24f, null, null);
            Text.Anchor = anchor;
        }
Ejemplo n.º 3
0
        private Command FulfillRequestCommand(Caravan caravan)
        {
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandFulfillTradeOffer".Translate();
            command_Action.defaultDesc  = "CommandFulfillTradeOfferDesc".Translate();
            command_Action.icon         = TradeRequestComp.TradeCommandTex;
            command_Action.action       = delegate
            {
                if (!this.ActiveRequest)
                {
                    Log.Error("Attempted to fulfill an unavailable request", false);
                    return;
                }
                if (!CaravanInventoryUtility.HasThings(caravan, this.requestThingDef, this.requestCount, new Func <Thing, bool>(this.PlayerCanGive)))
                {
                    Messages.Message("CommandFulfillTradeOfferFailInsufficient".Translate(TradeRequestUtility.RequestedThingLabel(this.requestThingDef, this.requestCount)), MessageTypeDefOf.RejectInput, false);
                    return;
                }
                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("CommandFulfillTradeOfferConfirm".Translate(GenLabel.ThingLabel(this.requestThingDef, null, this.requestCount), GenThing.ThingsToCommaList(this.rewards, true, true, -1)), delegate
                {
                    this.Fulfill(caravan);
                }, false, null));
            };
            if (!CaravanInventoryUtility.HasThings(caravan, this.requestThingDef, this.requestCount, new Func <Thing, bool>(this.PlayerCanGive)))
            {
                command_Action.Disable("CommandFulfillTradeOfferFailInsufficient".Translate(TradeRequestUtility.RequestedThingLabel(this.requestThingDef, this.requestCount)));
            }
            return(command_Action);
        }
Ejemplo n.º 4
0
        private void DoScenarioListEntry(Rect rect, Scenario scen)
        {
            bool flag = this.curScen == scen;

            Widgets.DrawOptionBackground(rect, flag);
            MouseoverSounds.DoRegion(rect);
            Rect rect2 = rect.ContractedBy(4f);

            Text.Font = GameFont.Small;
            Rect rect3 = rect2;

            rect3.height = Text.CalcHeight(scen.name, rect3.width);
            Widgets.Label(rect3, scen.name);
            Text.Font = GameFont.Tiny;
            Rect rect4 = rect2;

            rect4.yMin = rect3.yMax;
            Widgets.Label(rect4, scen.GetSummary());
            if (scen.enabled)
            {
                WidgetRow widgetRow = new WidgetRow(rect.xMax, rect.y, UIDirection.LeftThenDown, 99999f, 4f);
                if (scen.Category == ScenarioCategory.CustomLocal && widgetRow.ButtonIcon(TexButton.DeleteX, "Delete".Translate(), new Color?(GenUI.SubtleMouseoverColor)))
                {
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmDelete".Translate(scen.File.Name), delegate
                    {
                        scen.File.Delete();
                        ScenarioLister.MarkDirty();
                    }, true, null));
                }
                if (scen.Category == ScenarioCategory.SteamWorkshop && widgetRow.ButtonIcon(TexButton.DeleteX, "Unsubscribe".Translate(), new Color?(GenUI.SubtleMouseoverColor)))
                {
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmUnsubscribe".Translate(scen.File.Name), delegate
                    {
                        scen.enabled = false;
                        if (this.curScen == scen)
                        {
                            this.curScen = null;
                            this.EnsureValidSelection();
                        }
                        Workshop.Unsubscribe(scen);
                    }, true, null));
                }
                if (scen.GetPublishedFileId() != PublishedFileId_t.Invalid)
                {
                    if (widgetRow.ButtonIcon(ContentSource.SteamWorkshop.GetIcon(), "WorkshopPage".Translate(), null))
                    {
                        SteamUtility.OpenWorkshopPage(scen.GetPublishedFileId());
                    }
                    if (scen.CanToUploadToWorkshop())
                    {
                        widgetRow.Icon(Page_SelectScenario.CanUploadIcon, "CanBeUpdatedOnWorkshop".Translate());
                    }
                }
                if (!flag && Widgets.ButtonInvisible(rect, false))
                {
                    this.curScen = scen;
                    SoundDefOf.Click.PlayOneShotOnCamera(null);
                }
            }
        }
        public static bool ConfigureStartingPawnsDoNextPrefix(Page_ConfigureStartingPawns __instance, Pawn ___curPawn)
        {
            MethodInfo runMe = AccessTools.Method(typeof(Page_ConfigureStartingPawns), "DoNext");

            List <Pawn> tmpList = new List <Pawn>(Find.GameInitData.startingPawnCount);

            tmpList.AddRange(Find.GameInitData.startingAndOptionalPawns.Take(Find.GameInitData.startingPawnCount));
            if (!tmpList.Contains(___curPawn))
            {
                Find.WindowStack.Add(
                    Dialog_MessageBox.CreateConfirmation(
                        text: "M4_HaveNotDraggedColonist".Translate(___curPawn.LabelCap),
                        confirmedAct: () => {
                    returnvalue = true;
                    runMe.Invoke(__instance, new object[] { });
                }
                        )
                    );
            }
            else
            {
                returnvalue = true;
            }
            tmpList.Clear();
            return(returnvalue);
        }
Ejemplo n.º 6
0
        private static float DrawColonyRow(Settlement settlement, float rowY, Rect fillRect)
        {
            GUI.color   = Color.white;
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleLeft;

            Rect   settlementRect     = new Rect(0f, rowY, fillRect.width * NameWidthProportion, RowHeight);
            Rect   settlementNameRect = new Rect(10f, rowY, settlementRect.width - 10, RowHeight);
            string settlementName     = settlement.Name;

            Widgets.Label(settlementNameRect, settlementName);

            float  buttonPadding        = (fillRect.width - settlementRect.xMax) * ButtonPaddingProportion;
            float  buttonWidth          = (fillRect.width - buttonPadding) - (settlementRect.width + buttonPadding);
            Rect   actionButtonRect     = new Rect(settlementRect.width + buttonPadding, rowY + (RowHeight - ButtonHeight) / 2, buttonWidth, ButtonHeight);
            string buttonText           = settlement.HasMap == true ? "FM.Unload" : "FM.Load";
            string translatedButtonText = buttonText.Translate();

            if (Widgets.ButtonText(actionButtonRect, translatedButtonText))
            {
                Action action = delegate
                {
                    if (buttonText == "FM.Load")
                    {
                        LongEventHandler.QueueLongEvent(delegate
                        {
                            PersistenceUtility.LoadMap(settlement.Name);
                        }, "LoadingLongEvent", doAsynchronously: true, exceptionHandler: null);
                    }
                    else
                    {
                        LongEventHandler.QueueLongEvent(delegate
                        {
                            PersistenceUtility.UnloadMap(settlement.Map, settlement.Name);
                        }, "SavingLongEvent", doAsynchronously: false, exceptionHandler: null);
                    }
                    Find.WindowStack.TryRemove(typeof(MainTabWindow_Colonies));
                };

                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("FM.actionConfirm".Translate() + buttonText.Translate().ToLower() + "?", action));
            }

            Rect rowRect = new Rect(0f, rowY, fillRect.width, RowHeight);

            if (Mouse.IsOver(rowRect))
            {
                GUI.DrawTexture(rowRect, TexUI.HighlightTex);
            }
            if (Widgets.ButtonInvisible(rowRect))
            {
                if (!Mouse.IsOver(actionButtonRect))
                {
                    Find.WindowStack.TryRemove(typeof(MainTabWindow_Colonies));
                    CameraJumper.TryJumpAndSelect(settlement);
                }
            }

            Text.Anchor = TextAnchor.UpperLeft;
            return(rowY);
        }
        private void CheckWarnRequiredWorkTypesDisabledForEveryone(Action nextAction)
        {
            IEnumerable <WorkTypeDef> enumerable = StartingPawnUtility.RequiredWorkTypesDisabledForEveryone();

            if (enumerable.Any <WorkTypeDef>())
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (WorkTypeDef current in enumerable)
                {
                    if (stringBuilder.Length > 0)
                    {
                        stringBuilder.AppendLine();
                    }
                    stringBuilder.Append("  - " + current.gerundLabel.CapitalizeFirst());
                }
                string text = "ConfirmRequiredWorkTypeDisabledForEveryone".Translate(new object[]
                {
                    stringBuilder.ToString()
                });
                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(text, nextAction, false, null));
            }
            else
            {
                nextAction();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Show DialogMenu for confirmation on leaving vehicles behind when forming caravan
        /// </summary>
        /// <param name="__instance"></param>
        /// <param name="___transferables"></param>
        /// <param name="___map"></param>
        /// <param name="___destinationTile"></param>
        /// <param name="__result"></param>
        public static bool ConfirmLeaveVehiclesOnReform(Dialog_FormCaravan __instance, ref List <TransferableOneWay> ___transferables, Map ___map, int ___destinationTile, ref bool __result)
        {
            if (___map.mapPawns.SpawnedPawnsInFaction(Faction.OfPlayer).HasVehicle())
            {
                List <Pawn> pawns          = TransferableUtility.GetPawnsFromTransferables(___transferables);
                List <Pawn> correctedPawns = pawns.Where(p => !(p is VehiclePawn)).ToList();
                string      vehicles       = "";
                foreach (Pawn pawn in pawns.Where(p => p is VehiclePawn))
                {
                    vehicles += pawn.LabelShort;
                }

                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("LeaveVehicleBehindCaravan".Translate(vehicles), delegate()
                {
                    if (!(bool)AccessTools.Method(typeof(Dialog_FormCaravan), "CheckForErrors").Invoke(__instance, new object[] { correctedPawns }))
                    {
                        return;
                    }
                    AccessTools.Method(typeof(Dialog_FormCaravan), "AddItemsFromTransferablesToRandomInventories").Invoke(__instance, new object[] { correctedPawns });
                    Caravan caravan = CaravanExitMapUtility.ExitMapAndCreateCaravan(correctedPawns, Faction.OfPlayer, __instance.CurrentTile, __instance.CurrentTile, ___destinationTile, false);
                    ___map.Parent.CheckRemoveMapNow();
                    TaggedString taggedString = "MessageReformedCaravan".Translate();
                    if (caravan.pather.Moving && caravan.pather.ArrivalAction != null)
                    {
                        taggedString += " " + "MessageFormedCaravan_Orders".Translate() + ": " + caravan.pather.ArrivalAction.Label + ".";
                    }
                    Messages.Message(taggedString, caravan, MessageTypeDefOf.TaskCompletion, false);
                }, false, null));
                __result = true;
                return(false);
            }
            return(true);
        }
Ejemplo n.º 9
0
        private Command FulfillRequestCommand(Caravan caravan)
        {
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandFulfillTradeOffer".Translate();
            command_Action.defaultDesc  = "CommandFulfillTradeOfferDesc".Translate();
            command_Action.icon         = TradeCommandTex;
            command_Action.action       = delegate
            {
                if (!ActiveRequest)
                {
                    Log.Error("Attempted to fulfill an unavailable request");
                }
                else if (!CaravanInventoryUtility.HasThings(caravan, requestThingDef, requestCount, PlayerCanGive))
                {
                    Messages.Message("CommandFulfillTradeOfferFailInsufficient".Translate(TradeRequestUtility.RequestedThingLabel(requestThingDef, requestCount)), MessageTypeDefOf.RejectInput, historical: false);
                }
                else
                {
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("CommandFulfillTradeOfferConfirm".Translate(GenLabel.ThingLabel(requestThingDef, null, requestCount), GenThing.ThingsToCommaList(rewards, useAnd: true)), delegate
                    {
                        Fulfill(caravan);
                    }));
                }
            };
            if (!CaravanInventoryUtility.HasThings(caravan, requestThingDef, requestCount, PlayerCanGive))
            {
                command_Action.Disable("CommandFulfillTradeOfferFailInsufficient".Translate(TradeRequestUtility.RequestedThingLabel(requestThingDef, requestCount)));
            }
            return(command_Action);
        }
Ejemplo n.º 10
0
        public static void TryAbandonOrBanishViaInterface(Thing t, Caravan caravan)
        {
            Pawn p = t as Pawn;

            if (p != null)
            {
                if (!caravan.PawnsListForReading.Any((Pawn x) => x != p && caravan.IsOwner(x)))
                {
                    Messages.Message("MessageCantBanishLastColonist".Translate(), caravan, MessageTypeDefOf.RejectInput, historical: false);
                }
                else
                {
                    PawnBanishUtility.ShowBanishPawnConfirmationDialog(p);
                }
            }
            else
            {
                Dialog_MessageBox window = Dialog_MessageBox.CreateConfirmation("ConfirmAbandonItemDialog".Translate(t.Label), delegate
                {
                    Pawn ownerOf = CaravanInventoryUtility.GetOwnerOf(caravan, t);
                    if (ownerOf == null)
                    {
                        Log.Error("Could not find owner of " + t);
                    }
                    else
                    {
                        ownerOf.inventory.innerContainer.Remove(t);
                        t.Destroy();
                        caravan.RecacheImmobilizedNow();
                        caravan.RecacheDaysWorthOfFood();
                    }
                }, destructive: true);
                Find.WindowStack.Add(window);
            }
        }
Ejemplo n.º 11
0
        public virtual void TryStartUseJob(Pawn pawn, LocalTargetInfo extraTarget)
        {
            if (pawn.CanReserveAndReach(parent, PathEndMode.Touch, Danger.Deadly) && CanBeUsedBy(pawn, out string _))
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (CompUseEffect comp in parent.GetComps <CompUseEffect>())
                {
                    TaggedString taggedString = comp.ConfirmMessage(pawn);
                    if (!taggedString.NullOrEmpty())
                    {
                        if (stringBuilder.Length != 0)
                        {
                            stringBuilder.AppendLine();
                        }
                        stringBuilder.AppendTagged(taggedString);
                    }
                }
                string str = stringBuilder.ToString();
                if (str.NullOrEmpty())
                {
                    StartJob();
                }
                else
                {
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(str, StartJob));
                }
            }
            void StartJob()
            {
                Job job = extraTarget.IsValid ? JobMaker.MakeJob(Props.useJob, parent, extraTarget) : JobMaker.MakeJob(Props.useJob, parent);

                pawn.jobs.TryTakeOrderedJob(job);
            }
        }
Ejemplo n.º 12
0
        internal static void DeleteLocal(ModMetaData mod, bool force = false)
        {
            if (force)
            {
                LongEventHandler.QueueLongEvent(() =>
                {
                    LongEventHandler.SetCurrentEventText(I18n.RemovingLocal(mod.Name));
                    if (TryRemoveLocalCopy(mod))
                    {
                        Messages.Message(I18n.RemoveLocalSucceeded(mod.Name),
                                         MessageTypeDefOf.NeutralEvent, false);
                    }
                    else
                    {
                        Messages.Message(I18n.RemoveLocalFailed(mod.Name),
                                         MessageTypeDefOf.RejectInput, false);
                    }

                    // remove this version either way, as it's likely to be borked.
                    ModButton_Installed.For(mod).Notify_VersionRemoved(mod);
                }, null, true, null);
                return;
            }
            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(
                                     I18n.ConfirmRemoveLocal(mod.Name), () => DeleteLocal(mod, true), true));
        }
Ejemplo n.º 13
0
        internal static void DeleteLocalCopies(IEnumerable <ModMetaData> mods)
        {
            string Target(string versionString)
            {
                try
                {
                    var version = VersionControl.VersionFromString(versionString);
                    return(version.Major + "." + version.Minor);
                }
                catch
                {
                    return(versionString);
                }
            }

            var modList = mods.Select(m => $"{m.Name} ({Target(m.TargetVersion)})").ToLineList();
            var dialog  = Dialog_MessageBox.CreateConfirmation(
                I18n.MassUnSubscribeConfirm(mods.Count(), modList),
                () =>
            {
                foreach (var mod in new List <ModMetaData>(mods))
                {
                    DeleteLocal(mod, true);
                }
            },
                true);

            Find.WindowStack.Add(dialog);
        }
Ejemplo n.º 14
0
        /*Delete Construction Site    */
        public static void DeleteConstructionSite(int tile)
        {
            var ConstructionSite =
                (RoadConstructionSite)Find.WorldObjects.WorldObjectOfDefAt(
                    DefDatabase <WorldObjectDef> .GetNamed("RoadConstructionSite"), tile);

            if (ConstructionSite == null)
            {
                return;
            }

            // Confirm construction site deletion if resources were already consumed
            var s = ConstructionSite.ResourcesAlreadyConsumed();

            if (!s.NullOrEmpty())
            {
                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(
                                         "RoadsOfTheRim_ConfirmDestroyResourcesAlreadyConsumed".Translate(s),
                                         delegate { DeleteConstructionSiteConfirmed(ConstructionSite); }));
            }
            else
            {
                DeleteConstructionSiteConfirmed(ConstructionSite);
            }
        }
Ejemplo n.º 15
0
 public static void Upload(ModMetaData mod)
 {
     if (!VersionControl.IsWellFormattedVersionString(mod.TargetVersion))
     {
         Messages.Message(I18n.NeedsWellFormattedTargetVersion, MessageTypeDefOf.RejectInput, false);
     }
     else
     {
         Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(I18n.ConfirmSteamWorkshopUpload, delegate
         {
             SoundDefOf.Tick_High.PlayOneShotOnCamera();
             Dialog_MessageBox dialog_MessageBox = Dialog_MessageBox.CreateConfirmation(
                 I18n.ConfirmContentAuthor, delegate
             {
                 SoundDefOf.Tick_High.PlayOneShotOnCamera();
                 AccessTools.Method(typeof(Verse.Steam.Workshop), "Upload")
                 .Invoke(null, new object[] { mod });
             }, true);
             dialog_MessageBox.buttonAText      = I18n.Yes;
             dialog_MessageBox.buttonBText      = I18n.No;
             dialog_MessageBox.interactionDelay = 6f;
             Find.WindowStack.Add(dialog_MessageBox);
         }, true));
     }
 }
Ejemplo n.º 16
0
 public void ShowStartConfirmation()
 {
     // Show the missing required work dialog if necessary.  Otherwise, just show the standard confirmation.
     if (State.MissingWorkTypes != null && State.MissingWorkTypes.Count > 0)
     {
         StringBuilder stringBuilder = new StringBuilder();
         foreach (string current in State.MissingWorkTypes)
         {
             if (stringBuilder.Length > 0)
             {
                 stringBuilder.AppendLine();
             }
             stringBuilder.Append("  - " + current.CapitalizeFirst());
         }
         string text = "ConfirmRequiredWorkTypeDisabledForEveryone".Translate(new object[] {
             stringBuilder.ToString()
         });
         Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(text, delegate {
             GameStarted();
         }, false, null));
     }
     else
     {
         Find.WindowStack.Add(new Dialog_Confirm("EdB.PC.Page.ConfirmStart".Translate(), delegate {
             GameStarted();
         }, false, null, true));
     }
 }
Ejemplo n.º 17
0
        public static void TryAbandonOrBanishViaInterface(TransferableImmutable t, Caravan caravan)
        {
            Pawn pawn = t.AnyThing as Pawn;

            if (pawn != null)
            {
                TryAbandonOrBanishViaInterface(pawn, caravan);
                return;
            }
            Dialog_MessageBox window = Dialog_MessageBox.CreateConfirmation("ConfirmAbandonItemDialog".Translate(t.LabelWithTotalStackCount), delegate
            {
                for (int i = 0; i < t.things.Count; i++)
                {
                    Thing thing  = t.things[i];
                    Pawn ownerOf = CaravanInventoryUtility.GetOwnerOf(caravan, thing);
                    if (ownerOf == null)
                    {
                        Log.Error("Could not find owner of " + thing);
                        return;
                    }
                    ownerOf.inventory.innerContainer.Remove(thing);
                    thing.Destroy();
                }
                caravan.RecacheImmobilizedNow();
                caravan.RecacheDaysWorthOfFood();
            }, destructive: true);

            Find.WindowStack.Add(window);
        }
        private void DoBottomButtons(Rect rect)
        {
            Rect rect2 = new Rect(rect.width / 2f - BottomButtonSize.x / 2f, rect.height - 55f, BottomButtonSize.x, BottomButtonSize.y);

            if (Widgets.ButtonText(rect2, autoLoot ? "LoadSelected".Translate() : "AcceptButton".Translate()))
            {
                if (CaravanMassUsage > CaravanMassCapacity && CaravanMassCapacity != 0f)
                {
                    if (CheckForErrors(TransferableUtility.GetPawnsFromTransferables(transferables)))
                    {
                        Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("TransportersCaravanWillBeImmobile".Translate(), delegate
                        {
                            if (TryAccept())
                            {
                                if (autoLoot)
                                {
                                    LoadInstantly();
                                }
                                SoundDefOf.Tick_High.PlayOneShotOnCamera();
                                Close(doCloseSound: false);
                            }
                        }));
                    }
                }
                else if (TryAccept())
                {
                    if (autoLoot)
                    {
                        LoadInstantly();
                    }
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    Close(doCloseSound: false);
                }
            }
            if (Widgets.ButtonText(new Rect(rect2.x - 10f - BottomButtonSize.x, rect2.y, BottomButtonSize.x, BottomButtonSize.y), "ResetButton".Translate()))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                CalculateAndRecacheTransferables();
            }
            if (Widgets.ButtonText(new Rect(rect2.xMax + 10f, rect2.y, BottomButtonSize.x, BottomButtonSize.y), "CancelButton".Translate()))
            {
                Close();
            }
            if (Prefs.DevMode)
            {
                float width = 200f;
                float num   = BottomButtonSize.y / 2f;
                if (!LoadingInProgressOrReadyToLaunch && Widgets.ButtonText(new Rect(0f, rect.height - 55f, width, num), "Dev: Load instantly") && DebugTryLoadInstantly())
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    Close(doCloseSound: false);
                }
                if (Widgets.ButtonText(new Rect(0f, rect.height - 55f + num, width, num), "Dev: Select everything"))
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                    SetToLoadEverything();
                }
            }
        }
Ejemplo n.º 19
0
 private void OpenDifficultyUnlockConfirmation()
 {
     Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmUnlockExtremeDifficulty".Translate(), delegate
     {
         Prefs.ExtremeDifficultyUnlocked = true;
         Prefs.Save();
     }, destructive: true));
 }
Ejemplo n.º 20
0
 public static void Save()
 {
     Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmUninstallZombieland".Translate(), () =>
     {
         Find.WindowStack.currentlyDrawnWindow.Close();
         Find.WindowStack.Add(new Dialog_Save());
     }, true, null));
 }
Ejemplo n.º 21
0
 // Asks for confirmation of deactiving Options buttons.
 static void CheckOptionsActive(string optionsString, bool optionsFlag)
 {
     if (optionsFlag != ToggleManager.IsActive(optionsString) && !ToggleManager.IsActive(optionsString))
     {
         Toggle toggle = ToggleManager.Toggles.Find(x => x.Label.Equals(optionsString));
         toggle.active = true;
         Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("DeactivateOptions".Translate(), delegate { toggle.active = false; }, true, null));
     }
 }
        public static void ShowBanishPawnConfirmationDialog(Pawn pawn)
        {
            Dialog_MessageBox window = Dialog_MessageBox.CreateConfirmation(PawnBanishUtility.GetBanishPawnDialogText(pawn), delegate
            {
                PawnBanishUtility.Banish(pawn, -1);
            }, true, null);

            Find.WindowStack.Add(window);
        }
Ejemplo n.º 23
0
 private void <DoConfigControls> m__1()
 {
     SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
     Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmContentAuthor".Translate(), delegate
     {
         SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
         Workshop.Upload(this.curScen);
     }, true, null));
 }
Ejemplo n.º 24
0
        public static void ShowBanishPawnConfirmationDialog(Pawn pawn)
        {
            Dialog_MessageBox window = Dialog_MessageBox.CreateConfirmation(GetBanishPawnDialogText(pawn), delegate
            {
                Banish(pawn);
            }, destructive: true);

            Find.WindowStack.Add(window);
        }
        private void DoBottomButtons(Rect rect)
        {
            Rect rect2 = new Rect(rect.width / 2f - this.BottomButtonSize.x / 2f, rect.height - BottomAreaHeight, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect2, "AcceptButton".Translate(), true, false, true))
            {
                if (this.CaravanMassUsage > this.CaravanMassCapacity && this.CaravanMassCapacity != 0f)
                {
                    if (this.CheckForErrors(TransferableUtility.GetPawnsFromTransferables(this.transferables)))
                    {
                        Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("TransportersCaravanWillBeImmobile".Translate(), delegate
                        {
                            if (this.TryAccept())
                            {
                                SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                                this.Close(false);
                            }
                        }, false, null));
                    }
                }
                else if (this.TryAccept())
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    this.Close(false);
                }
            }
            Rect rect3 = new Rect(rect2.x - 10f - this.BottomButtonSize.x, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect3, "ResetButton".Translate(), true, false, true))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                this.CalculateAndRecacheTransferables();
            }
            Rect rect4 = new Rect(rect2.xMax + 10f, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect4, "CancelButton".Translate(), true, false, true))
            {
                this.Close(true);
            }
            if (Prefs.DevMode)
            {
                float width = 200f;
                float num   = this.BottomButtonSize.y / 2f;
                Rect  rect5 = new Rect(0f, rect.height - BottomAreaHeight, width, num);
                if (Widgets.ButtonText(rect5, "Dev: Load instantly", true, false, true) && this.DebugTryLoadInstantly())
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    this.Close(false);
                }
                Rect rect6 = new Rect(0f, rect.height - BottomAreaHeight + num, width, num);
                if (Widgets.ButtonText(rect6, "Dev: Select everything", true, false, true))
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    this.SetToLoadEverything();
                }
            }
        }
Ejemplo n.º 26
0
 public static void Unsubscribe(ModMetaData mod)
 {
     Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(I18n.ConfirmUnsubscribe(mod.Name), delegate
     {
         mod.enabled = false;
         AccessTools.Method(typeof(Verse.Steam.Workshop), "Unsubscribe").Invoke(null, new object[] { mod });
         // TODO: check callback to remove mod from list.
     }, true));
 }
Ejemplo n.º 27
0
 public override void WriteSettings()
 {
     this.Settings.Apply();
     Settings.Write();
     if (this.Settings.RequireReboot)
     {
         Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("PRF.Settings.RequireReboot".Translate(), () => GenCommandLine.Restart()));
     }
 }
Ejemplo n.º 28
0
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            //Debug stuff
            if (Prefs.DevMode && DebugSettings.godMode)
            {
                {
                    Command_Action gizmo = new Command_Action();
                    gizmo.defaultLabel = "DEBUG: Set Energy to 100%";
                    gizmo.action       = () => energyNeed.CurLevelPercentage = 1.0f;
                    yield return(gizmo);
                }

                {
                    Command_Action gizmo = new Command_Action();
                    gizmo.defaultLabel = "DEBUG: Set Energy to 50%";
                    gizmo.action       = () => energyNeed.CurLevelPercentage = 0.5f;
                    yield return(gizmo);
                }

                {
                    Command_Action gizmo = new Command_Action();
                    gizmo.defaultLabel = "DEBUG: Set Energy to 20%";
                    gizmo.action       = () => energyNeed.CurLevelPercentage = 0.2f;
                    yield return(gizmo);
                }
            }

            //Add self detonation button to mechanical pawns.
            Pawn pawn = parent as Pawn;

            if (AndroidsModSettings.Instance.androidExplodesOnDeath && pawn != null && pawn.IsColonistPlayerControlled && pawn.def.HasModExtension <MechanicalPawnProperties>())
            {
                {
                    Command_Action gizmo = new Command_Action();
                    gizmo.defaultLabel = "AndroidGizmoSelfDetonationLabel".Translate();
                    gizmo.defaultDesc  = "AndroidGizmoSelfDetonationDescription".Translate();
                    gizmo.icon         = ContentFinder <Texture2D> .Get("UI/Commands/Detonate", true);

                    gizmo.action = delegate()
                    {
                        if (AndroidsModSettings.Instance.droidDetonationConfirmation)
                        {
                            Dialog_MessageBox dialog = Dialog_MessageBox.CreateConfirmation("AndroidSelfDetonationConfirmationDialogText".Translate(pawn.Name.ToStringFull), () => HealthUtility.AdjustSeverity(pawn, HediffDefOf.ChjOverheating, 1.1f), true, "AndroidGizmoSelfDetonationLabel".Translate());
                            Find.WindowStack.Add(dialog);
                        }
                        else
                        {
                            HealthUtility.AdjustSeverity(pawn, HediffDefOf.ChjOverheating, 1.1f);
                        }
                    };
                    yield return(gizmo);
                }
            }

            yield break;
        }
Ejemplo n.º 29
0
 protected override void OnDelete(string name)
 {
     Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(
                              "ConfirmDelete".Translate((NamedArgument)name), () =>
     {
         FactionColoniesMilitary.RemoveUnit(name);
         this.units.RemoveAll(unit => unit.name == name);
         Messages.Message("FCDeleted".Translate((NamedArgument)name), MessageTypeDefOf.PositiveEvent);
     }));
 }
 public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan, Settlement settlement)
 {
     return(CaravanArrivalActionUtility.GetFloatMenuOptions(() => CanAttack(caravan, settlement), () => new CaravanArrivalAction_AttackSettlement(settlement), "AttackSettlement".Translate(settlement.Label), caravan, settlement.Tile, settlement, settlement.Faction.AllyOrNeutralTo(Faction.OfPlayer) ? ((Action <Action>) delegate(Action action)
     {
         Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmAttackFriendlyFaction".Translate(settlement.LabelCap, settlement.Faction.Name), delegate
         {
             action();
         }));
     }) : null));
 }