public SettingsGUI(MaidFiddler plugin) { this.plugin = plugin; InitializeComponent(); LoadLabels(); LoadComponents(); }
public static void ThrowErrorMessage(Exception e, string action, MaidFiddler plugin) { if (errorThrown) { return; } StringBuilder sb = new StringBuilder(); sb.AppendLine("=== Maid Fiddler DUMP ===").AppendLine(); sb.AppendLine($"Game version: {GameVersion}"); sb.AppendLine($"Mod version: {MaidFiddler.VERSION}"); sb.AppendLine($"Info: {action}"); sb.AppendLine($"Error message: {e}"); if (e.InnerException != null) { sb.Append($"Underlying exception: {e.InnerException}"); } bool dumpCreated; string filename = $"MaidFiddler_err_{GenerateFileName()}.txt"; try { using (TextWriter tw = new StreamWriter(File.Create(filename))) { tw.Write(sb.ToString()); dumpCreated = true; } } catch (Exception) { dumpCreated = false; } string dumpCreatedMsg = $"A log named {filename} was created.\nPlease, send this log to the developer with the description of what you attempted to do"; string dumpNotCreatedMsg = $"Failed to create a dump message. Send a screenshot of the following stack trace to the developer:\n==START==\n{sb}\n==END=="; string title = Translation.IsTranslated("ERROR_LOG_MESSAGE_TITLE") ? Translation.GetTranslation("ERROR_LOG_MESSAGE_TITLE") : "Oh noes!"; string text = Translation.IsTranslated("ERROR_LOG_MESSAGE") && (dumpCreated && Translation.IsTranslated("ERROR_LOG_CREATED") || !dumpCreated && Translation.IsTranslated("ERROR_LOG_NOT_CREATED")) ? $"{Translation.GetTranslation("ERROR_LOG_MESSAGE")}\n{(dumpCreated ? string.Format(Translation.GetTranslation("ERROR_LOG_CREATED"), filename) : string.Format(Translation.GetTranslation("ERROR_LOG_NOT_CREATED"), sb))}" : $"Oh no! An error has occured in Maid Fiddler!\n{(dumpCreated ? dumpCreatedMsg : dumpNotCreatedMsg)}"; MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Error); MaidFiddlerGUI guiLoc = plugin.Gui; plugin.Gui = null; guiLoc?.Close(true); errorThrown = true; }
public MaidFiddlerGUI(MaidFiddler plugin) { Plugin = plugin; InitializeComponent(); Font uiFont = new Font(FontFamily.GenericSansSerif, 8.25F); Font = uiFont; foreach (Control control in Controls) { control.Font = uiFont; } if (!plugin.CFGOpenOnStartup) { Opacity = 0.0; } Text = $"CM3D2 Maid Fiddler {MaidFiddler.VERSION}"; Translation.AddTranslationAction("TITLE_TEXT", s => Text = $"CM3D2 Maid Fiddler {MaidFiddler.VERSION} {s}"); try { Player = new PlayerInfo(this); removeValueLimit = false; Resources.InitThumbnail(); InitMenuText(); InitMaidInfoTab(); InitMaidStatsTab(); InitClassesTab(); InitWorkTab(); InitYotogiSkillTab(); InitMiscTab(); InitGameTab(); ControlsEnabled = false; Player.UpdateAll(); InitMaids(); playerValueUpdateQueue = new Dictionary <PlayerChangeType, Action>(); Shown += OnShown; FormClosing += OnFormClosing; VisibleChanged += OnVisibleChanged; listBox1.DrawMode = DrawMode.OwnerDrawFixed; listBox1.DrawItem += DrawListBox; listBox1.SelectedValueChanged += OnSelectedValueChanged; InitHookCallbacks(); Translation.ApplyTranslation(); } catch (Exception e) { FiddlerUtils.ThrowErrorMessage(e, "Failed to initalize core components", plugin); } }
public MaidFiddlerGUI(MaidFiddler plugin) { Plugin = plugin; InitializeComponent(); Font uiFont = new Font(FontFamily.GenericSansSerif, 8.25F); Font = uiFont; foreach (Control control in Controls) { control.Font = uiFont; } if(!plugin.CFGOpenOnStartup) Opacity = 0.0; Text = $"CM3D2 Maid Fiddler {MaidFiddler.VERSION}"; Translation.AddTranslationAction("TITLE_TEXT", s => Text = $"CM3D2 Maid Fiddler {MaidFiddler.VERSION} {s}"); try { Player = new PlayerInfo(this); removeValueLimit = false; Resources.InitThumbnail(); InitMenuText(); InitMaidInfoTab(); InitMaidStatsTab(); InitClassesTab(); InitWorkTab(); InitYotogiSkillTab(); InitMiscTab(); InitGameTab(); ControlsEnabled = false; Player.UpdateAll(); InitMaids(); playerValueUpdateQueue = new Dictionary<PlayerChangeType, Action>(); Shown += OnShown; FormClosing += OnFormClosing; VisibleChanged += OnVisibleChanged; listBox1.DrawMode = DrawMode.OwnerDrawFixed; listBox1.DrawItem += DrawListBox; listBox1.SelectedValueChanged += OnSelectedValueChanged; InitHookCallbacks(); Translation.ApplyTranslation(); } catch (Exception e) { FiddlerUtils.ThrowErrorMessage(e, "Failed to initalize core components", plugin); } }
public TranslationSelectionGUI(MaidFiddler plugin) { this.plugin = plugin; InitializeComponent(); Text = Translation.GetTranslation(Text); Translation.GetTranslation(label_prompt); Translation.GetTranslation(label_lang_name); Translation.GetTranslation(label_lang_version); Translation.GetTranslation(label_lang_author); Translation.GetTranslation(button_download_github); Translation.GetTranslation(button_download_url); Translation.GetTranslation(button_apply); Translation.GetTranslation(button_cancel); Translation.GetTranslation(button_open_translation_folder); listBox_translations.DisplayMember = "DisplayName"; listBox_translations.SelectedValueChanged += OnLanguageSelected; LoadTranslations(Translation.CurrentTranslationFile); }
public MaidComparer(MaidFiddler plugin) { this.plugin = plugin; }
public static void ThrowErrorMessage(Exception e, string action, MaidFiddler plugin) { if (errorThrown) return; StringBuilder sb = new StringBuilder(); sb.AppendLine("=== Maid Fiddler DUMP ===").AppendLine(); sb.AppendLine($"Game version: {GameVersion}"); sb.AppendLine($"Mod version: {MaidFiddler.VERSION}"); sb.AppendLine($"Info: {action}"); sb.AppendLine($"Error message: {e}"); if (e.InnerException != null) sb.Append($"Underlying exception: {e.InnerException}"); bool dumpCreated; string filename = $"MaidFiddler_err_{GenerateFileName()}.txt"; try { using (TextWriter tw = new StreamWriter(File.Create(filename))) { tw.Write(sb.ToString()); dumpCreated = true; } } catch (Exception) { dumpCreated = false; } string dumpCreatedMsg = $"A log named {filename} was created.\nPlease, send this log to the developer with the description of what you attempted to do"; string dumpNotCreatedMsg = $"Failed to create a dump message. Send a screenshot of the following stack trace to the developer:\n==START==\n{sb}\n==END=="; string title = Translation.IsTranslated("ERROR_LOG_MESSAGE_TITLE") ? Translation.GetTranslation("ERROR_LOG_MESSAGE_TITLE") : "Oh noes!"; string text = Translation.IsTranslated("ERROR_LOG_MESSAGE") && (dumpCreated && Translation.IsTranslated("ERROR_LOG_CREATED") || !dumpCreated && Translation.IsTranslated("ERROR_LOG_NOT_CREATED")) ? $"{Translation.GetTranslation("ERROR_LOG_MESSAGE")}\n{(dumpCreated ? string.Format(Translation.GetTranslation("ERROR_LOG_CREATED"), filename) : string.Format(Translation.GetTranslation("ERROR_LOG_NOT_CREATED"), sb))}" : $"Oh no! An error has occured in Maid Fiddler!\n{(dumpCreated ? dumpCreatedMsg : dumpNotCreatedMsg)}"; MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Error); MaidFiddlerGUI guiLoc = plugin.Gui; plugin.Gui = null; guiLoc?.Close(true); errorThrown = true; }