/// <summary> /// Calls the ModHandler LoadState function /// </summary> private static void RestoreModList() { if (!ModsConfigHandler.StateIsSet(selectedState)) { Main.Log.Message("state not set"); SetStatus("Status_Message_Null".Translate()); } else { ModsConfigHandler.LoadState(selectedState); SetStatus("Status_Message_Restore".Translate()); } }
/// <summary> /// Draw The revert backup button /// </summary> /// <param name="rect">The rect to draw into</param> /// <returns>True if value changed(will always be false)</returns> private static bool DoRevertButtonDrawerContents(Rect rect) { if (Widgets.ButtonText(new Rect(rect.x, rect.y, rect.width, 30f), "Button_Revert_Text".Translate())) { ModsConfigHandler.RestoreBackup(); showRevertTick = Common.STATUS_DELAY_TICKS_SHORT; } string label = ""; if (showRevertTick > 0) { label = "Status_Message_Restored".Translate(); showRevertTick--; } Text.Anchor = TextAnchor.MiddleLeft; Text.Font = GameFont.Tiny; Widgets.Label(new Rect(rect.x, rect.y + 32f, rect.width, 18f), label); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; return(false); }
/// <summary> /// Add our own Initialization for HugsLib /// </summary> public override void Initialize() { ModsConfigHandler.BackupCurrent(); }
/// <summary> /// Add our own Initialization for HugsLib /// </summary> public override void Initialize() { ModsConfigHandler.BackupCurrent(); SettingsHandler.Update(); SteamSyncHandler.UpdateAllStates(); }
/// <summary> /// Draw the state names button and list /// </summary> /// <param name="rect">The rect to draw into</param> /// <returns>True if values changed</returns> internal static bool DoStateNamesDrawerContents(Rect rect) { if (StateNamesSetting.Value == null) { StateNamesSetting.Value = new StateNamesHandleType(); } Rect inRect = new Rect(rect.x - 18f, rect.y + 40f, rect.width, rect.height - 30); Listing_Standard listing_Standard = new Listing_Standard(inRect); for (int i = 0; i <= Globals.STATE_LIMIT - 1; i++) { string label = String.Format("{2}{0} {1}: ", "Settings_Label_State_Name".Translate(), i + 1, (ModsConfigHandler.StateIsSet(i)) ? null : "* "); string oldName = StateNamesSetting.Value.StateNames[i]; string newName = listing_Standard.TextEntryLabeled(label, oldName); listing_Standard.Gap(16f); if (newName != oldName) { StateNamesSetting.Value.StateNames[i] = newName; return(true); } } listing_Standard.End(); return(false); }
/// <summary> /// Fills the bottom left corner of the window /// </summary> /// <param name="rect">The rect to draw into</param> private static void DoBottomLeftWindowContents(Rect rect) { // Backup Button Rect BackupRect = new Rect((rect.xMin - 1) + BottomLeftContentOffset, rect.yMax - 37f, ButtonBigWidth, BottomHeight); TooltipHandler.TipRegion(BackupRect, "Button_Backup_Tooltip".Translate()); if (Widgets.ButtonText(BackupRect, "Button_Backup_Text".Translate())) { BackupModList(); } // '>>' Label Text.Anchor = TextAnchor.MiddleCenter; Rect toRect = new Rect(BackupRect.xMax + Padding, BackupRect.y, LabelWidth, BottomHeight); Widgets.Label(toRect, ">>"); // State button and Float menu Rect StateRect = new Rect(toRect.xMax + Padding, BackupRect.y, ButtonSmallWidth, BottomHeight); TooltipHandler.TipRegion(StateRect, "Button_State_Select_Tooltip".Translate()); if (Widgets.ButtonText(StateRect, string.Format("{0}{1}", selectedState.ToString(), (ModsConfigHandler.StateIsSet(selectedState)) ? null : "*"))) { List <FloatMenuOption> options = new List <FloatMenuOption>(); for (int i = 1; i <= Globals.STATE_LIMIT; i++) { //set a new variable here, otherwise the selected state and button text will change when int i next iterates int n = i; options.Add(new FloatMenuOption(GetStateName(i), (Action)(() => { selectedState = n; }), MenuOptionPriority.Default, (Action)null, (Thing)null, 0.0f, (Func <Rect, bool>)null, (WorldObject)null)); } options.Add(new FloatMenuOption("Edit Names...", (Action)(() => { Find.WindowStack.Add(new Dialogs.Dialog_EditNames()); }), MenuOptionPriority.Default, (Action)null, (Thing)null, 0f, null, null)); Find.WindowStack.Add((Window) new FloatMenu(options)); } // '<<' Label Rect fromRect = new Rect(StateRect.xMax + Padding, StateRect.y, LabelWidth, BottomHeight); Widgets.Label(fromRect, "<<"); // Restore Button Rect RestoreRect = new Rect(fromRect.xMax + Padding, StateRect.y, ButtonBigWidth, BottomHeight); TooltipHandler.TipRegion(RestoreRect, "Button_Restore_Tooltip".Translate()); if (Widgets.ButtonText(RestoreRect, "Button_Restore_Text".Translate())) { RestoreModList(); } // Undo Button Rect UndoRect = new Rect(RestoreRect.xMax + Padding, RestoreRect.y, ButtonSmallWidth, BottomHeight); TooltipHandler.TipRegion(UndoRect, "Button_Undo_Tooltip".Translate()); if (CustomWidgets.ButtonImage(UndoRect, Textures.Undo)) { if (ModsConfigHandler.CanUndo) { if (ModsConfigHandler.DoUndoAction()) { SetStatus("Status_Message_Undone".Translate()); } } } // Status Label UpdateStatus(); Text.Font = GameFont.Tiny; Rect StatusRect = new Rect(StateRect.x - 25f, StateRect.yMax - 58f, LabelStatusWidth, LabelStatusHeight); Widgets.Label(StatusRect, StatusMessage); //Reset text Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; }
/// <summary> /// Calls the ModHandler SaveState function /// </summary> private static void BackupModList() { ModsConfigHandler.SaveState(selectedState); SetStatus("Status_Message_Backup".Translate()); }
/// <summary> /// Gets the formated name of a state /// </summary> /// <param name="state">The state to get</param> /// <returns>The name of the state</returns> private static string GetStateName(int state) { return(String.Format("{0}. {1}{2}", state, ModsConfigHandler.GetStateNamePretty(state), (ModsConfigHandler.StateIsSet(state)) ? null : " [*]")); }
/// <summary> /// Add our own Initialization for HugsLib /// </summary> public override void Initialize() { InitDirectories(); ModsConfigHandler.BackupCurrent(); }