internal void <> m__0() { string s = this.$this.tutorTag + "-" + this.plantDef.defName; if (TutorSystem.AllowAction(s)) { bool flag = true; for (int i = 0; i < this.$this.settables.Count; i++) { this.$this.settables[i].SetPlantDefToGrow(this.plantDef); if (flag && this.plantDef.plant.interferesWithRoof) { foreach (IntVec3 c in this.$this.settables[i].Cells) { if (c.Roofed(this.$this.settables[i].Map)) { Messages.Message("MessagePlantIncompatibleWithRoof".Translate(new object[] { Find.ActiveLanguageWorker.Pluralize(this.plantDef.LabelCap, -1) }), MessageTypeDefOf.CautionInput, false); flag = false; break; } } } } PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.SetGrowingZonePlant, KnowledgeAmount.Total); this.$this.WarnAsAppropriate(this.plantDef); TutorSystem.Notify_Event(s); } }
public override void PostOpen() { base.PostOpen(); Find.GameInitData.ChooseRandomStartingTile(); LessonAutoActivator.TeachOpportunity(ConceptDefOf.WorldCameraMovement, OpportunityType.Important); TutorSystem.Notify_Event("PageStart-SelectLandingSite"); }
public virtual void DesignateMultiCell(IEnumerable <IntVec3> cells) { if (!TutorSystem.TutorialMode || TutorSystem.AllowAction(new EventPack(TutorTagDesignate, cells))) { bool somethingSucceeded = false; bool flag = false; foreach (IntVec3 cell in cells) { if (CanDesignateCell(cell).Accepted) { DesignateSingleCell(cell); somethingSucceeded = true; if (!flag) { flag = ShowWarningForCell(cell); } } } Finalize(somethingSucceeded); if (TutorSystem.TutorialMode) { TutorSystem.Notify_Event(new EventPack(TutorTagDesignate, cells)); } } }
private void RandomizeCurPawn() { if (!TutorSystem.AllowAction("RandomizePawn")) { return; } int num = 0; while (true) { this.curPawn = StartingPawnUtility.RandomizeInPlace(this.curPawn); num++; if (num > 15) { break; } if (StartingPawnUtility.WorkTypeRequirementsSatisfied()) { goto Block_3; } } return; Block_3: TutorSystem.Notify_Event("RandomizePawn"); }
public virtual void DesignateMultiCell(IEnumerable <IntVec3> cells) { if (TutorSystem.TutorialMode && !TutorSystem.AllowAction(new EventPack(this.TutorTagDesignate, cells))) { return; } bool somethingSucceeded = false; bool flag = false; foreach (IntVec3 current in cells) { if (this.CanDesignateCell(current).Accepted) { this.DesignateSingleCell(current); somethingSucceeded = true; if (!flag) { flag = this.ShowWarningForCell(current); } } } this.Finalize(somethingSucceeded); if (TutorSystem.TutorialMode) { TutorSystem.Notify_Event(new EventPack(this.TutorTagDesignate, cells)); } }
public override void ProcessInput(Event ev) { base.ProcessInput(ev); List <FloatMenuOption> list = new List <FloatMenuOption>(); if (settables == null) { settables = new List <IPlantToGrowSettable>(); } if (!settables.Contains(settable)) { settables.Add(settable); } tmpAvailablePlants.Clear(); foreach (ThingDef item in PlantUtility.ValidPlantTypesForGrowers(settables)) { if (IsPlantAvailable(item, settable.Map)) { tmpAvailablePlants.Add(item); } } tmpAvailablePlants.SortBy((ThingDef x) => 0f - GetPlantListPriority(x), (ThingDef x) => x.label); for (int i = 0; i < tmpAvailablePlants.Count; i++) { ThingDef plantDef = tmpAvailablePlants[i]; string text = plantDef.LabelCap; if (plantDef.plant.sowMinSkill > 0) { text = text + (string)(" (" + "MinSkill".Translate() + ": ") + plantDef.plant.sowMinSkill + ")"; } list.Add(new FloatMenuOption(text, delegate { string s = tutorTag + "-" + plantDef.defName; if (TutorSystem.AllowAction(s)) { bool flag = true; for (int j = 0; j < settables.Count; j++) { settables[j].SetPlantDefToGrow(plantDef); if (flag && plantDef.plant.interferesWithRoof) { foreach (IntVec3 cell in settables[j].Cells) { if (cell.Roofed(settables[j].Map)) { Messages.Message("MessagePlantIncompatibleWithRoof".Translate(Find.ActiveLanguageWorker.Pluralize(plantDef.LabelCap)), MessageTypeDefOf.CautionInput, historical: false); flag = false; break; } } } } PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.SetGrowingZonePlant, KnowledgeAmount.Total); WarnAsAppropriate(plantDef); TutorSystem.Notify_Event(s); } }, plantDef, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, plantDef))); } Find.WindowStack.Add(new FloatMenu(list)); }
public GizmoResult DoGUI_Logic(bool mouseIsOver, bool commandIsTriggered) { if (commandIsTriggered) { if (gizmo.disabled) { if (!gizmo.disabledReason.NullOrEmpty()) { Messages.Message(gizmo.disabledReason, MessageTypeDefOf.RejectInput); } return(new GizmoResult(GizmoState.Mouseover, null)); } if (!TutorSystem.AllowAction(gizmo.TutorTagSelect)) { return(new GizmoResult(GizmoState.Mouseover, null)); } TutorSystem.Notify_Event(gizmo.TutorTagSelect); return(new GizmoResult(GizmoState.Interacted, Event.current)); } if (mouseIsOver) { return(new GizmoResult(GizmoState.Mouseover, null)); } return(new GizmoResult(GizmoState.Clear, null)); }
public override void PostOpen() { base.PostOpen(); TutorSystem.Notify_Event("PageStart-ConfigureStartingPawns"); // Set initial Cards PopulateCards(); }
public void ProcessInputEvents() { if (this.CheckSelectedDesignatorValid()) { if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { if (this.selectedDesignator.DraggableDimensions == 0) { Designator designator = this.selectedDesignator; AcceptanceReport acceptanceReport = this.selectedDesignator.CanDesignateCell(UI.MouseCell()); if (acceptanceReport.Accepted) { designator.DesignateSingleCell(UI.MouseCell()); designator.Finalize(true); } else { Messages.Message(acceptanceReport.Reason, MessageTypeDefOf.SilentInput); this.selectedDesignator.Finalize(false); } } else { this.dragger.StartDrag(); } Event.current.Use(); } if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { goto IL_00ec; } if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape) { goto IL_00ec; } goto IL_0121; } return; IL_00ec: SoundDefOf.CancelMode.PlayOneShotOnCamera(null); this.Deselect(); this.dragger.EndDrag(); Event.current.Use(); TutorSystem.Notify_Event("ClearDesignatorSelection"); goto IL_0121; IL_0121: if (Event.current.type == EventType.MouseUp && Event.current.button == 0 && this.dragger.Dragging) { this.selectedDesignator.DesignateMultiCell(this.dragger.DragCells); this.dragger.EndDrag(); Event.current.Use(); } }
private void RandomizeCurPawn() { if (!TutorSystem.AllowAction("RandomizePawn")) { return; } do { this.curPawn = StartingPawnUtility.RandomizeInPlace(this.curPawn); }while (!StartingPawnUtility.WorkTypeRequirementsSatisfied()); TutorSystem.Notify_Event("RandomizePawn"); }
public static bool Prefix() { Find.MusicManagerPlay.disabled = true; Find.WindowStack.Notify_GameStartDialogOpened(); LongEventHandler.ExecuteWhenFinished(() => { Find.MusicManagerPlay.disabled = false; Find.WindowStack.Notify_GameStartDialogClosed(); Find.TickManager.CurTimeSpeed = TimeSpeed.Normal; TutorSystem.Notify_Event("GameStartDialogClosed"); }); return(false); }
public override void ProcessInput(Event ev) { base.ProcessInput(ev); List <FloatMenuOption> list = new List <FloatMenuOption>(); if (this.settables == null) { this.settables = new List <IPlantToGrowSettable>(); } if (!this.settables.Contains(this.settable)) { this.settables.Add(this.settable); } foreach (ThingDef current in GenPlant.ValidPlantTypesForGrowers(this.settables)) { if (this.IsPlantAvailable(current)) { ThingDef localPlantDef = current; string text = current.LabelCap; if (current.plant.sowMinSkill > 0) { string text2 = text; text = string.Concat(new object[] { text2, " (", "MinSkill".Translate(), ": ", current.plant.sowMinSkill, ")" }); } list.Add(new FloatMenuOption(text, delegate { string s = this.tutorTag + "-" + localPlantDef.defName; if (!TutorSystem.AllowAction(s)) { return; } for (int i = 0; i < this.settables.Count; i++) { this.settables[i].SetPlantDefToGrow(localPlantDef); } PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.SetGrowingZonePlant, KnowledgeAmount.Total); this.WarnAsAppropriate(localPlantDef); TutorSystem.Notify_Event(s); }, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, localPlantDef), null)); } } Find.WindowStack.Add(new FloatMenu(list)); }
protected override void DoNext() { if (next != null) { Find.WindowStack.Add(this.next); } if (nextAct != null) { ESStartingItems.LoadESItemsToScenario(); nextAct(); } TutorSystem.Notify_Event("PageClosed"); TutorSystem.Notify_Event("GoToNextPage"); Close(true); }
public static void EnqueueRange(IEnumerable <ResearchNode> nodes, bool add) { TutorSystem.Notify_Event("StartResearchProject"); // clear current Queue if not adding if (!add) { _instance._queue.Clear(); Find.ResearchManager.currentProj = null; } // sorting by depth ensures prereqs are met - cost is just a bonus thingy. foreach (var node in nodes.OrderBy(node => node.X).ThenBy(node => node.Research.CostApparent)) { Enqueue(node, true); } }
public void ProcessInputEvents() { if (!CheckSelectedDesignatorValid()) { return; } if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { if (selectedDesignator.DraggableDimensions == 0) { Designator designator = selectedDesignator; AcceptanceReport acceptanceReport = selectedDesignator.CanDesignateCell(UI.MouseCell()); if (acceptanceReport.Accepted) { designator.DesignateSingleCell(UI.MouseCell()); designator.Finalize(somethingSucceeded: true); } else { Messages.Message(acceptanceReport.Reason, MessageTypeDefOf.SilentInput, historical: false); selectedDesignator.Finalize(somethingSucceeded: false); } } else { dragger.StartDrag(); } Event.current.Use(); } if ((Event.current.type == EventType.MouseDown && Event.current.button == 1) || KeyBindingDefOf.Cancel.KeyDownEvent) { SoundDefOf.CancelMode.PlayOneShotOnCamera(); Deselect(); dragger.EndDrag(); Event.current.Use(); TutorSystem.Notify_Event("ClearDesignatorSelection"); } if (Event.current.type == EventType.MouseUp && Event.current.button == 0 && dragger.Dragging) { selectedDesignator.DesignateMultiCell(dragger.DragCells); dragger.EndDrag(); Event.current.Use(); } }
// Performs the logic from the Page.DoNext() method in the base Page class instead of calling the override // in Page_ConfigureStartingPawns. We want to prevent the missing required work type dialog from appearing // in the context of the configure pawns page. We're adding our own version here. public void DoNextInBasePage() { if (OriginalPage != null) { Page next = OriginalPage.next; Action nextAction = OriginalPage.nextAct; if (next != null) { Verse.Find.WindowStack.Add(next); } if (nextAction != null) { nextAction(); } TutorSystem.Notify_Event("PageClosed"); TutorSystem.Notify_Event("GoToNextPage"); OriginalPage.Close(true); } }
public static FloatMenuOption RecipeFloatMenuOption(Building_WorkTable SelTable, RecipeDef recipe) { return(new FloatMenuOption(recipe.LabelCap, delegate { if (!SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col))) { Bill.CreateNoPawnsWithSkillDialog(recipe); } Bill bill2 = recipe.MakeNewBill(); SelTable.billStack.AddBill(bill2); if (recipe.conceptLearned != null) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total); } if (TutorSystem.TutorialMode) { TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap.Resolve()); } }, recipe.UIIconThing, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe))); }
public override void ProcessInput(Event ev) { base.ProcessInput(ev); List <FloatMenuOption> list = new List <FloatMenuOption>(); if (this.settables == null) { this.settables = new List <IPrisonerToSacrificeSettable>(); } if (!this.settables.Contains(this.settable)) { this.settables.Add(this.settable); } Map map = Find.VisibleMap; foreach (Pawn current in map.mapPawns.PrisonersOfColonySpawned) { if (!current.Dead) { string text = current.LabelCap; List <FloatMenuOption> arg_121_0 = list; Func <Rect, bool> extraPartOnGUI = (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, localPlantDef); arg_121_0.Add(new FloatMenuOption(text, delegate { string s = this.tutorTag + "-" + localPlantDef.defName; if (!TutorSystem.AllowAction(s)) { return; } for (int i = 0; i < this.settables.Count; i++) { this.settables[i].SetPlantDefToGrow(localPlantDef); } PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.SetGrowingZonePlant, KnowledgeAmount.Total); this.WarnAsAppropriate(localPlantDef); TutorSystem.Notify_Event(s); }, MenuOptionPriority.Default, null, null, 29f, extraPartOnGUI, null)); } } Find.WindowStack.Add(new FloatMenu(list)); }
protected override void FillTab() { PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed); Rect rect = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f); Func <List <FloatMenuOption> > recipeOptionsMaker = delegate { List <FloatMenuOption> list = new List <FloatMenuOption>(); for (int i = 0; i < SelTable.def.AllRecipes.Count; i++) { if (SelTable.def.AllRecipes[i].AvailableNow) { RecipeDef recipe = SelTable.def.AllRecipes[i]; list.Add(new FloatMenuOption(recipe.LabelCap, delegate { if (!SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col))) { Bill.CreateNoPawnsWithSkillDialog(recipe); } Bill bill = recipe.MakeNewBill(); SelTable.billStack.AddBill(bill); if (recipe.conceptLearned != null) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total); } if (TutorSystem.TutorialMode) { TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap); } }, MenuOptionPriority.Default, null, null, 29f, (Rect r) => Widgets.InfoCardButton(r.x + 5f, r.y + (r.height - 24f) / 2f, recipe), null)); } } if (!list.Any()) { list.Add(new FloatMenuOption("NoneBrackets".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } return(list); }; mouseoverBill = SelTable.billStack.DoListing(rect, recipeOptionsMaker, ref scrollPosition, ref viewHeight); }
public override void DesignateSingleCell(IntVec3 c) { if (DebugSettings.godMode || entDef.GetStatValueAbstract(StatDefOf.WorkToBuild, stuffDef) == 0f) { if (entDef is TerrainDef) { base.Map.terrainGrid.SetTerrain(c, (TerrainDef)entDef); } else { Thing thing = ThingMaker.MakeThing((ThingDef)entDef, stuffDef); thing.SetFactionDirect(Faction.OfPlayer); GenSpawn.Spawn(thing, c, base.Map, placingRot); } } else { GenSpawn.WipeExistingThings(c, placingRot, entDef.blueprintDef, base.Map, DestroyMode.Deconstruct); GenConstruct.PlaceBlueprintForBuild(entDef, c, base.Map, placingRot, Faction.OfPlayer, stuffDef); } MoteMaker.ThrowMetaPuffs(GenAdj.OccupiedRect(c, placingRot, entDef.Size), base.Map); ThingDef thingDef = entDef as ThingDef; if (thingDef != null && thingDef.IsOrbitalTradeBeacon) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BuildOrbitalTradeBeacon, KnowledgeAmount.Total); } if (TutorSystem.TutorialMode) { TutorSystem.Notify_Event(new EventPack(base.TutorTagDesignate, c)); } if (entDef.PlaceWorkers != null) { for (int i = 0; i < entDef.PlaceWorkers.Count; i++) { entDef.PlaceWorkers[i].PostPlace(base.Map, entDef, c, placingRot); } } }
public virtual bool DoGUI(Rect rect, bool colonistOrdering, FloatMenu floatMenu) { Rect rect2 = rect; rect2.height--; bool flag = !Disabled && Mouse.IsOver(rect2); bool flag2 = false; Text.Font = CurrentFont; Rect rect3 = rect; rect3.xMin += 4f; rect3.xMax = rect.x + 27f; rect3.yMin += 4f; rect3.yMax = rect.y + 27f; if (flag) { rect3.x += 4f; } Rect rect4 = rect; rect4.xMin += HorizontalMargin; rect4.xMax -= HorizontalMargin; rect4.xMax -= 4f; rect4.xMax -= extraPartWidth + IconOffset; rect4.x += IconOffset; if (flag) { rect4.x += 4f; } Rect rect5 = default(Rect); if (extraPartWidth != 0f) { float num = Mathf.Min(Text.CalcSize(Label).x, rect4.width - 4f); rect5 = new Rect(rect4.xMin + num, rect4.yMin, extraPartWidth, 30f); flag2 = Mouse.IsOver(rect5); } if (!Disabled) { MouseoverSounds.DoRegion(rect2); } Color color = GUI.color; if (Disabled) { GUI.color = ColorBGDisabled * color; } else if (flag && !flag2) { GUI.color = ColorBGActiveMouseover * color; } else { GUI.color = ColorBGActive * color; } GUI.DrawTexture(rect, BaseContent.WhiteTex); GUI.color = ((!Disabled) ? ColorTextActive : ColorTextDisabled) * color; if (sizeMode == FloatMenuSizeMode.Tiny) { rect4.y += 1f; } Widgets.DrawAtlas(rect, TexUI.FloatMenuOptionBG); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(rect4, Label); Text.Anchor = TextAnchor.UpperLeft; GUI.color = iconColor; if (shownItem != null || drawPlaceHolderIcon) { Widgets.DefIcon(rect3, shownItem, null, 1f, drawPlaceHolderIcon); } else if ((bool)itemIcon) { GUI.DrawTexture(rect3, itemIcon); } GUI.color = color; if (extraPartOnGUI != null) { bool num2 = extraPartOnGUI(rect5); GUI.color = color; if (num2) { return(true); } } if (flag && mouseoverGuiAction != null) { mouseoverGuiAction(); } if (tutorTag != null) { UIHighlighter.HighlightOpportunity(rect, tutorTag); } if (Widgets.ButtonInvisible(rect2)) { if (tutorTag != null && !TutorSystem.AllowAction(tutorTag)) { return(false); } Chosen(colonistOrdering, floatMenu); if (tutorTag != null) { TutorSystem.Notify_Event(tutorTag); } return(true); } return(false); }
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)); }
public override void ProcessInput(Event ev) { base.ProcessInput(ev); List <FloatMenuOption> list = new List <FloatMenuOption>(); if (this.settables == null) { this.settables = new List <IPlantToGrowSettable>(); } if (!this.settables.Contains(this.settable)) { this.settables.Add(this.settable); } Command_SetPlantToGrow.tmpAvailablePlants.Clear(); foreach (ThingDef current in PlantUtility.ValidPlantTypesForGrowers(this.settables)) { if (this.IsPlantAvailable(current, this.settable.Map)) { Command_SetPlantToGrow.tmpAvailablePlants.Add(current); } } Command_SetPlantToGrow.tmpAvailablePlants.SortBy((ThingDef x) => - this.GetPlantListPriority(x), (ThingDef x) => x.label); for (int i = 0; i < Command_SetPlantToGrow.tmpAvailablePlants.Count; i++) { ThingDef plantDef = Command_SetPlantToGrow.tmpAvailablePlants[i]; string text = plantDef.LabelCap; if (plantDef.plant.sowMinSkill > 0) { string text2 = text; text = string.Concat(new object[] { text2, " (", "MinSkill".Translate(), ": ", plantDef.plant.sowMinSkill, ")" }); } list.Add(new FloatMenuOption(text, delegate { string s = this.tutorTag + "-" + plantDef.defName; if (!TutorSystem.AllowAction(s)) { return; } bool flag = true; for (int j = 0; j < this.settables.Count; j++) { this.settables[j].SetPlantDefToGrow(plantDef); if (flag && plantDef.plant.interferesWithRoof) { foreach (IntVec3 current2 in this.settables[j].Cells) { if (current2.Roofed(this.settables[j].Map)) { Messages.Message("MessagePlantIncompatibleWithRoof".Translate(Find.ActiveLanguageWorker.Pluralize(plantDef.LabelCap, -1)), MessageTypeDefOf.CautionInput, false); flag = false; break; } } } } PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.SetGrowingZonePlant, KnowledgeAmount.Total); this.WarnAsAppropriate(plantDef); TutorSystem.Notify_Event(s); }, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, plantDef), null)); } Find.WindowStack.Add(new FloatMenu(list)); }
void DrawDisplayArea(Rect rect) { Widgets.DrawMenuSection(rect); if (SelectedHelpDef == null) { return; } Text.Font = GameFont.Medium; Text.WordWrap = false; float titleWidth = Text.CalcSize(SelectedHelpDef.LabelCap).x; var titleRect = new Rect(rect.xMin + WindowMargin, rect.yMin + WindowMargin, titleWidth, 60f); if (SelectedHelpDef.keyDef is ResearchProjectDef) { var research = SelectedHelpDef.keyDef as ResearchProjectDef; var researchRect = new Rect(rect.xMin + WindowMargin, rect.yMin + WindowMargin + 5f, 90f, 50f); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; if (research.IsFinished) { Widgets.DrawMenuSection(researchRect); Widgets.Label(researchRect, ResourceBank.String.Finished); } else if (research == Find.ResearchManager.currentProj) { Widgets.DrawMenuSection(researchRect); Widgets.Label(researchRect, ResourceBank.String.InProgress); } else if (!research.CanStartNow) { Widgets.DrawMenuSection(researchRect); Widgets.Label(researchRect, ResourceBank.String.Locked); } else if (Widgets.ButtonText(researchRect, ResourceBank.String.Research, true, false, true)) { SoundDef.Named("ResearchStart").PlayOneShotOnCamera(null); Find.ResearchManager.currentProj = research; TutorSystem.Notify_Event("StartResearchProject"); } titleRect.x += 100f; } else if ( (SelectedHelpDef.keyDef != null) && (SelectedHelpDef.keyDef.IconTexture() != null) ) { var iconRect = new Rect(titleRect.xMin + WindowMargin, rect.yMin + WindowMargin, 60f - 2 * WindowMargin, 60f - 2 * WindowMargin); titleRect.x += 60f; SelectedHelpDef.keyDef.DrawColouredIcon(iconRect); } Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(titleRect, SelectedHelpDef.LabelCap); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; Text.WordWrap = true; Rect outRect = rect.ContractedBy(WindowMargin); outRect.yMin += 60f; Rect viewRect = outRect; viewRect.width -= 16f; viewRect.height = ContentHeight; GUI.BeginGroup(outRect); Widgets.BeginScrollView(outRect.AtZero(), ref DisplayScrollPos, viewRect.AtZero()); Vector2 cur = Vector2.zero; HelpDetailSectionHelper.DrawText(ref cur, viewRect.width, SelectedHelpDef.description); cur.y += ParagraphMargin; foreach (HelpDetailSection section in SelectedHelpDef.HelpDetailSections) { section.Draw(ref cur, viewRect.width, this); } ContentHeight = cur.y; Widgets.EndScrollView(); GUI.EndGroup(); }
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)); } }
//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)); }
public override void PostOpen() { base.PostOpen(); TutorSystem.Notify_Event("PageStart-ConfigureStartingPawns"); }
public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth) { Text.Font = GameFont.Tiny; Rect rect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f); 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.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)); } GizmoResult result; if (Event.current.button == 1) { result = new GizmoResult(GizmoState.OpenedFloatMenu, Event.current); } else { if (!TutorSystem.AllowAction(this.TutorTagSelect)) { return(new GizmoResult(GizmoState.Mouseover, null)); } 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 void PostOpen() { base.PostOpen(); TutorSystem.Notify_Event("PageStart-CreateWorldParams"); }