protected virtual void DrawAnimalsCanGrazeNowSelection() { DrawEntryHeader("Animals", backgroundColor: ColorFromFilterSubjectThingDef("Animals Can Graze Now")); var rect = ListingStandard.GetRect(DefaultElementHeight); var tmpCheckState = _userData.ChosenAnimalsCanGrazeNowState; Widgets.CheckBoxLabeledMulti(rect, "Animals Can Graze Now:", ref tmpCheckState); _userData.ChosenAnimalsCanGrazeNowState = tmpCheckState; }
protected virtual void DrawCoastalSelection() { DrawEntryHeader("Coastal Tile", false, backgroundColor: ColorFromFilterSubjectThingDef("Coastal Tiles")); var rect = ListingStandard.GetRect(DefaultElementHeight); var tmpCheckState = _userData.ChosenCoastalTileState; Widgets.CheckBoxLabeledMulti(rect, "Is Coastal Tile:", ref tmpCheckState); _userData.ChosenCoastalTileState = tmpCheckState; }
protected virtual void DrawRoadTypesSelection() { DrawEntryHeader("Road Types", backgroundColor: ColorFromFilterSubjectThingDef("Roads")); var roadDefs = _userData.RoadDefs; var selectedRoadDefs = _userData.SelectedRoadDefs; // Reset button: reset all entries to Off state if (ListingStandard.ButtonText("Reset All")) { foreach (var roadDefEntry in selectedRoadDefs) { roadDefEntry.Value.State = MultiCheckboxState.Partial; } } var scrollViewHeight = selectedRoadDefs.Count * DefaultElementHeight; var inLs = ListingStandard.BeginScrollView(5 * DefaultElementHeight, scrollViewHeight, ref _scrollPosRoadSelection); // display road elements foreach (var roadDef in roadDefs) { ThreeStateItem threeStateItem; if (!selectedRoadDefs.TryGetValue(roadDef, out threeStateItem)) { Log.Error( $"[PrepareLanding] [DrawRoadTypesSelection] an item in RoadDefs is not in SelectedRoadDefs: {roadDef.LabelCap}"); continue; } // save temporary state as it might change in CheckBoxLabeledMulti var tmpState = threeStateItem.State; var itemRect = inLs.GetRect(DefaultElementHeight); Widgets.CheckBoxLabeledMulti(itemRect, roadDef.LabelCap, ref tmpState); // if the state changed, update the item with the new state // ReSharper disable once RedundantCheckBeforeAssignment if (tmpState != threeStateItem.State) { threeStateItem.State = tmpState; } if (!string.IsNullOrEmpty(roadDef.description)) { TooltipHandler.TipRegion(itemRect, roadDef.description); } } ListingStandard.EndScrollView(inLs); }
private void DrawRoadTypesSelection() { DrawEntryHeader("PLMWTT_RoadTypes".Translate(), backgroundColor: ColorFromFilterType(typeof(TileFilterRoads))); var roadDefs = _gameData.DefData.RoadDefs; var selectedRoadDefs = _gameData.UserData.SelectedRoadDefs; /* * Buttons */ var numButtons = 4; if (_gameData.UserData.Options.ViewPartialOffNoSelect) { numButtons += 1; } var buttonsRect = ListingStandard.GetRect(DefaultElementHeight).SplitRectWidthEvenly(numButtons); if (buttonsRect.Count != numButtons) { Log.ErrorOnce($"[PrepareLanding] DrawRoadTypesSelection: couldn't get the right number of buttons: {numButtons}", 0x1239cafe); return; } // Reset button: reset the container if (Widgets.ButtonTextToolTip(buttonsRect[0], "PLMW_Reset".Translate(), "PLMWTT_ButtonResetTooltip".Translate())) { selectedRoadDefs.Reset(roadDefs, nameof(_gameData.UserData.SelectedRoadDefs)); } // all roads if (Widgets.ButtonTextToolTip(buttonsRect[1], "PLMW_All".Translate(), "PLMWTT_ButtonAllTooltip".Translate())) { selectedRoadDefs.All(); } // no roads if (Widgets.ButtonTextToolTip(buttonsRect[2], "PLMW_None".Translate(), "PLMWTT_ButtonNoneTooltip".Translate())) { selectedRoadDefs.None(); } // boolean filtering type if (Widgets.ButtonTextToolTipColor(buttonsRect[3], selectedRoadDefs.FilterBooleanState.ToStringHuman(), "PLMWTT_ORANDTooltip".Translate(), selectedRoadDefs.FilterBooleanState.Color())) { selectedRoadDefs.FilterBooleanState = selectedRoadDefs.FilterBooleanState.Next(); } if (_gameData.UserData.Options.ViewPartialOffNoSelect) { var color = selectedRoadDefs.OffPartialNoSelect ? Color.green : Color.red; if (Widgets.ButtonTextToolTipColor(buttonsRect[4], $"{"PLMWTT_SelectedShort".Translate()} {selectedRoadDefs.OffPartialNoSelect}", "PLMWTT_OffPartialTooltip".Translate(), color)) { selectedRoadDefs.OffPartialNoSelect = !selectedRoadDefs.OffPartialNoSelect; } } /* * ScrollView */ var scrollViewHeight = selectedRoadDefs.Count * DefaultElementHeight; var inLs = ListingStandard.BeginScrollView(5 * DefaultElementHeight, scrollViewHeight, ref _scrollPosRoadSelection, DefaultScrollableViewShrinkWidth); // display road elements foreach (var roadDef in roadDefs) { if (!selectedRoadDefs.TryGetValue(roadDef, out var threeStateItem)) { Log.Error( $"[PrepareLanding] [DrawRoadTypesSelection] an item in RoadDefs is not in SelectedRoadDefs: {roadDef.LabelCap}"); continue; } // save temporary state as it might change in CheckBoxLabeledMulti var tmpState = threeStateItem.State; var itemRect = inLs.GetRect(DefaultElementHeight); Widgets.CheckBoxLabeledMulti(itemRect, roadDef.LabelCap, ref tmpState); // if the state changed, update the item with the new state // ReSharper disable once RedundantCheckBeforeAssignment if (tmpState != threeStateItem.State) { threeStateItem.State = tmpState; } if (!string.IsNullOrEmpty(roadDef.description)) { TooltipHandler.TipRegion(itemRect, roadDef.description); } } ListingStandard.EndScrollView(inLs); }
private void DrawCoastalSelection() { DrawEntryHeader("PLMWTT_CoastalTiles".Translate(), false, backgroundColor: ColorFromFilterType(typeof(TileFilterCoastalTiles))); // coastal tiles (sea) var rect = ListingStandard.GetRect(DefaultElementHeight); var tmpCheckState = _gameData.UserData.ChosenCoastalTileState; Widgets.CheckBoxLabeledMulti(rect, $"{"PLMWTT_IsCoastalTileOcean".Translate()}:", ref tmpCheckState); _gameData.UserData.ChosenCoastalTileState = tmpCheckState; ListingStandard.Gap(6f); /* * Coastal rotation */ var filterCoastalRotation = _gameData.UserData.CoastalRotation.Use; ListingStandard.CheckboxLabeled("PLMWTT_UseCoastalRoation".Translate(), ref filterCoastalRotation, "PLMWTT_UseCoastalRoationTooltip".Translate()); _gameData.UserData.CoastalRotation.Use = filterCoastalRotation; // "Select" button if (ListingStandard.ButtonText("PLMWTT_SelectCoastRotation".Translate())) { var floatMenuOptions = new List <FloatMenuOption>(); // loop through all meaningful rotations foreach (var currentRotation in TileFilterCoastRotation.PossibleRotations) { // clicking on the floating menu saves the selected rotation void ActionClick() { _gameData.UserData.CoastalRotation.Selected = currentRotation.AsInt; } // tool-tip when hovering above the rotation name on the floating menu void MouseOverAction() { var mousePos = Event.current.mousePosition; rect = new Rect(mousePos.x, mousePos.y, DefaultElementHeight, DefaultElementHeight); TooltipHandler.TipRegion(rect, ("HasCoast" + currentRotation).Translate()); } //create the floating menu var menuOption = new FloatMenuOption(currentRotation.ToStringHuman(), ActionClick, MenuOptionPriority.Default, MouseOverAction); // add it to the list of floating menu options floatMenuOptions.Add(menuOption); } // create the floating menu var floatMenu = new FloatMenu(floatMenuOptions, "PLMWTT_SelectCoastRotation".Translate()); // add it to the window stack to display it Find.WindowStack.Add(floatMenu); } var rightLabel = _gameData.UserData.CoastalRotation.Use /*&& _gameData.UserData.CoastalRotation.Selected != Rot4.Invalid*/ ? ("HasCoast" + _gameData.UserData.CoastalRotation.Selected).Translate().CapitalizeFirst() : "PLMW_None".Translate(); ListingStandard.LabelDouble($"{"PLMWTT_SelectedCoastRotation".Translate()}:", rightLabel); /* * coastal tiles (lake) */ ListingStandard.Gap(6f); rect = ListingStandard.GetRect(DefaultElementHeight); TooltipHandler.TipRegion(rect, "PLMWTT_IsCoastalTileLakeTooltip".Translate()); tmpCheckState = _gameData.UserData.ChosenCoastalLakeTileState; Widgets.CheckBoxLabeledMulti(rect, $"{"PLMWTT_IsCoastalTileLake".Translate()}:", ref tmpCheckState); _gameData.UserData.ChosenCoastalLakeTileState = tmpCheckState; }