Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Windows/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,33 @@ internal static void RefreshLists() {
Instance?.listBoxEntries.Refresh();
}

internal static void ImportManualSave(string content) {
if (Instance == null || string.IsNullOrWhiteSpace(content)) return;

try {
var context = ToNLogContext.Instance ?? new ToNLogContext();
string dateKey = ToNLogContext.Instance?.DateKey ?? DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
DateTime now = DateTime.Now;

Instance.AddLogEntry(dateKey, content, now, context);

var collection = SaveData[dateKey];
if (collection != null) {
if (!Instance.listBoxKeys.Items.Contains(collection)) {
int idx = SaveData.Collection.IndexOf(collection);
if (idx < 0) idx = Instance.listBoxKeys.Items.Count;
Instance.listBoxKeys.Items.Insert(Math.Min(Math.Max(idx, 0), Instance.listBoxKeys.Items.Count), collection);
}
Instance.listBoxKeys.SelectedItem = collection;
Instance.UpdateEntries();
}

Instance.Export(null, true);
} catch (Exception ex) {
Logger.Error(ex);
}
}

private void UpdateEntries() {
listBoxEntries.Items.Clear();
if (JustCopiedIndex > -1) SetJustCopied(-1);
Expand Down
22 changes: 20 additions & 2 deletions Windows/SettingsWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions Windows/SettingsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -802,5 +802,34 @@ private void BindControlsRecursive(Control.ControlCollection controls) {
}
}
#endregion

#region ManualImport
private void btnManualImport_Click(object sender, EventArgs e) {
// Temporary hard-coded localization
string title = LANG.S("SETTINGS.MANUALIMPORT.TITLE") ?? "Manual Import Save Code";
var edit = EditWindow.Show(string.Empty, title, this);
if (!edit.Accept) return;

string input = (edit.Text).Trim();
if (string.IsNullOrEmpty(input)) {
MessageBox.Show(LANG.S("SETTINGS.MANUALIMPORT.EMPTY") ?? "Please paste the text that contains the save code.",
title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}

if (input.Length < 1000) {
MessageBox.Show(LANG.S("SETTINGS.MANUALIMPORT.INVALID") ?? "No valid save data was found.",
title, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}

MainWindow.ImportManualSave(input);

MessageBox.Show(LANG.S("SETTINGS.MANUALIMPORT.SUCCESS") ?? "Imported successfully.",
title, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
#endregion
}
}