public Share() { this.Name = "Sharing"; this.Dock = DockStyle.Fill; Meth.HandleTheme(this); ImportLeveLArea = new FlowLayoutPanel(); ImportLeveLArea.Dock = DockStyle.Fill; ImportLeveLArea.AutoSize = true; ExportSelect = new Elem.Select(); ExportSelect.DoubleClick += (s, e) => ViewInfo(); foreach (dynamic lvl in GDTools.GetLevelList(null, null, true)) { ExportSelect.AddItem(lvl.Name); } ExportCompressed = new CheckBox(); ExportCompressed.Text = "Export compressed (.gmdc)"; ExportCompressed.AutoSize = true; RefreshDiv = new TableLayoutPanel(); RefreshDiv.AutoSize = true; RefreshDiv.Visible = false; RefreshDiv.Controls.Add(new Elem.Text("After importing all you want, make sure to refresh data in order to use the app further.")); RefreshDiv.Controls.Add(new Elem.But("Refresh", (s, e) => Program.MainForm.FullReload())); FlowLayoutPanel ExportControls = new FlowLayoutPanel(); ExportControls.AutoSize = true; ExportControls.Controls.Add(new Elem.But("Export", (s, e) => ExportLevel(), "Exports all the level(s) you've selected on the list")); ExportControls.Controls.Add(new Elem.But("View", (s, e) => ViewInfo(), "Shows info for the topmost level you've selected on the list.")); this.Controls.Add(ExportSelect); this.Controls.Add(ExportControls); this.Controls.Add(ExportCompressed); this.Controls.Add(new Elem.NewLine()); this.Controls.Add(new Elem.But("Help", (s, e) => Pages.SettingPage.ShowHelp("share"))); this.Controls.Add(new Elem.SectionBreak()); this.Controls.Add(new Elem.NewLine()); this.Controls.Add(new Elem.But("Import", (s, e) => OpenImport(), "Opens a file browsing dialog where you can select level(s) to add to imports.")); this.Controls.Add(RefreshDiv); this.Controls.Add(ImportLeveLArea); }
public void AddMerge(string _LevelName) { MergeList.AddItem(_LevelName); }
public Collabs() { this.Name = "Collab"; this.Dock = DockStyle.Fill; Meth.HandleTheme(this); TableLayoutPanel con = new TableLayoutPanel(); con.AutoSize = true; con.Visible = Settings.DevMode; MergeList = new Elem.Select(false); MergeBase = new Elem.Text("Base not selected"); FlowLayoutPanel MergeControls = new FlowLayoutPanel(); MergeControls.AutoSize = true; MergeControls.Controls.Add(new Elem.But("Set base", (s, e) => { Elem.ChooseForm Select = new Elem.ChooseForm("Select base source", new string[] { "Set base from file", "Set base from local levels", "Set base by ID" }); Select.Show(); Select.Finish += res => { if (res == 0) { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.InitialDirectory = "c:\\"; ofd.Filter = GDTools.Ext.Filter; ofd.FilterIndex = 1; ofd.RestoreDirectory = true; ofd.Multiselect = true; if (ofd.ShowDialog() == DialogResult.OK) { foreach (string file in ofd.FileNames) { Elem.MsgBox LoadInfo = new Elem.MsgBox("Loading..."); LoadInfo.Show(); AddBase(file); LoadInfo.Close(); LoadInfo.Dispose(); } } } } else if (res == 1) { Form Choose = new Form(); Choose.Text = "Double-click to select"; Choose.Size = new Size(400, 300); Meth.HandleTheme(Choose); Elem.Select ExportSelect = new Elem.Select(false); EventHandler Pick = (s, e) => { if (ExportSelect.SelectedItem == null) { return; } AddBase(((Elem.Select.SelectItem)ExportSelect.SelectedItem).Text); Choose.Close(); Choose.Dispose(); }; ExportSelect.DoubleClick += Pick; foreach (dynamic lvl in GDTools.GetLevelList()) { ExportSelect.AddItem(lvl.Name); } Choose.Controls.Add(ExportSelect); Choose.Show(); } else if (res == 2) { Elem.ChooseForm c = new Elem.ChooseForm("Type Level ID", new string[] { "IS-INPUT::INT", "::Add", "Cancel" }, "Type in level ID" ); c.Show(); c.FinishStr += resc => { if (resc != "") { Elem.MsgBox LoadInfo = new Elem.MsgBox("Loading..."); LoadInfo.Show(); string r = GDTools.RequestGDLevel(resc); if (r.StartsWith("-")) { MessageBox.Show($"Error: {GDTools.VerifyRequest(r)}", "Could not get level!"); } AddBase($"{resc} ({GDTools.GetRequestKey(r, "2")})"); LoadInfo.Dispose(); } }; } }; })); MergeControls.Controls.Add(new Elem.But("Add part(s)", (s, e) => { Elem.ChooseForm Select = new Elem.ChooseForm("Select part source", new string[] { "Add part(s) from file", "Add part(s) from local levels", "Add part(s) by ID" }); Select.Show(); Select.Finish += res => { if (res == 0) { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.InitialDirectory = "c:\\"; ofd.Filter = GDTools.Ext.Filter; ofd.FilterIndex = 1; ofd.RestoreDirectory = true; ofd.Multiselect = true; if (ofd.ShowDialog() == DialogResult.OK) { foreach (string file in ofd.FileNames) { Elem.MsgBox LoadInfo = new Elem.MsgBox("Loading..."); LoadInfo.Show(); AddMerge(file); LoadInfo.Close(); LoadInfo.Dispose(); } } } } else if (res == 1) { Form Choose = new Form(); Choose.Text = "Double-click to select"; Choose.Size = new Size(400, 300); Meth.HandleTheme(Choose); Elem.Select ExportSelect = new Elem.Select(); EventHandler Pick = (s, e) => { if (ExportSelect.SelectedItems[0] == null) { return; } foreach (Elem.Select.SelectItem x in ExportSelect.SelectedItems) { AddMerge(x.Text); } Choose.Close(); Choose.Dispose(); }; ExportSelect.DoubleClick += Pick; foreach (dynamic lvl in GDTools.GetLevelList()) { ExportSelect.AddItem(lvl.Name); } Choose.Controls.Add(new Elem.Div(new Control[] { ExportSelect, new Elem.But("Select", Pick) })); Choose.ShowDialog(Select); } else if (res == 2) { Elem.ChooseForm c = new Elem.ChooseForm("Type Level ID(s)", new string[] { "IS-INPUT-BIG::INS", "::Add", "Cancel" }, "Type in level ID(s) (Separated by spaces)" ); c.Show(); c.FinishStr += resc => { if (resc != "") { int i = 0; string[] rescs = resc.Split(" "); foreach (string ress in rescs) { i++; Elem.MsgBox LoadInfo = new Elem.MsgBox($"Loading ({i}/{rescs.Length})..."); LoadInfo.Show(); if (ress.Length < 3) { LoadInfo.Dispose(); continue; } string r = GDTools.RequestGDLevel(ress); if (r.StartsWith("-")) { MessageBox.Show($"Error with {ress}: {GDTools.VerifyRequest(r)}", "Could not get level!"); LoadInfo.Dispose(); continue; } AddMerge($"{ress} ({GDTools.GetRequestKey(r, "2")})"); LoadInfo.Dispose(); } } }; } }; })); MergeControls.Controls.Add(new Elem.But("Remove part", (s, e) => { if (MergeList.SelectedItem == null) { return; } MergeList.Items.Remove(MergeList.SelectedItem); })); MergeControls.Controls.Add(new Elem.But("Merge", (s, e) => { string err = MergeParts(); if (err.Length > 0) { MessageBox.Show(err, "Error merging"); } })); CheckBox UseReferenceToggle = new CheckBox(); UseReferenceToggle.Text = "Use reference objects"; UseReferenceToggle.AutoSize = true; UseReferenceToggle.Checked = UseReferenceObjects; UseReferenceToggle.Click += (s, e) => UseReferenceObjects = UseReferenceToggle.Checked; CheckBox MergeLinkToggle = new CheckBox(); MergeLinkToggle.Text = "Link part objects"; MergeLinkToggle.AutoSize = true; MergeLinkToggle.Click += (s, e) => MergeLink = MergeLinkToggle.Checked; CheckBox AutoReassignToggle = new CheckBox(); AutoReassignToggle.Text = "Reassign groups and colours"; AutoReassignToggle.AutoSize = true; AutoReassignToggle.Checked = AutoReassignGroups; AutoReassignToggle.Click += (s, e) => AutoReassignGroups = AutoReassignToggle.Checked; con.Controls.Add(new Elem.Text("Part merging")); con.Controls.Add(MergeList); con.Controls.Add(MergeBase); con.Controls.Add(MergeControls); con.Controls.Add(MergeLinkToggle); con.Controls.Add(AutoReassignToggle); con.Controls.Add(UseReferenceToggle); this.Controls.Add(con); if (!Settings.DevMode) { this.Controls.Add(new Elem.DevToolWarning((s, e) => { con.Visible = true; })); } }
public Backups() { this.Name = "Backups"; this.Dock = DockStyle.Fill; Meth.HandleTheme(this); EventHandler ViewBackup = (s, e) => { if (BackupSelect.SelectedItem != null) { Elem.Select.SelectItem backup = (Elem.Select.SelectItem)BackupSelect.SelectedItem; Form Info = new Form(); Info.Size = new Size(Meth._S(350), Meth._S(400)); Info.Text = $"Viewing {backup.Text}"; Info.Icon = new Icon(Settings.IconPath); Info.FormClosed += (s, e) => Info.Dispose(); Meth.HandleTheme(Info); Elem.Text Load = new Elem.Text("Loading..."); Info.Show(); Info.Controls.Add(Load); dynamic BackupInfo = GDTools.Backups.GetBackupInfo(backup.Text); string User = ""; Elem.Select Levels = new Elem.Select(false); Levels.DoubleClick += (s, e) => { if (Levels.SelectedItem != null) { Elem.Select.SelectItem lvl = (Elem.Select.SelectItem)Levels.SelectedItem; dynamic LevelInfo = GDTools.GetLevelInfo(lvl.Text, BackupInfo.Levels); string Info = ""; foreach (PropertyInfo i in LevelInfo.GetType().GetProperties()) { if (i.Name != "Name" && i.Name != "Creator" && i.Name != "Description") { Info += $"{i.Name.Replace("_", " ")}: {i.GetValue(LevelInfo)}\n"; } } MessageBox.Show(Info, $"Info for {lvl.Text}", MessageBoxButtons.OK, MessageBoxIcon.None); } }; foreach (PropertyInfo i in BackupInfo.User.Stats.GetType().GetProperties()) { User += $"{i.Name.Replace("_", " ")}: {i.GetValue(BackupInfo.User.Stats)}\r\n"; } foreach (dynamic lvl in BackupInfo.Levels) { Levels.AddItem(lvl.Name); } Info.Controls.Remove(Load); FlowLayoutPanel Contain = new FlowLayoutPanel(); Contain.Dock = DockStyle.Fill; Contain.AutoSize = true; Contain.Controls.Add(new Elem.Text(User)); Contain.Controls.Add(new Elem.BigNewLine()); Contain.Controls.Add(Levels); Contain.Controls.Add(new Elem.Text("Double-click to view level")); Info.Controls.Add(Contain); } }; GDTools.Backups.InitBackups(); BackupSelect = new Elem.Select(false); BackupSelect.DoubleClick += ViewBackup; BackupPath = new Elem.Text(); BackupsSize = new Elem.Text(); RefreshBackupList(); ContextMenuStrip CM = new ContextMenuStrip(); CM.Items.Add(new ToolStripMenuItem("View selected backup", null, ViewBackup)); BackupSelect.ContextMenuStrip = CM; this.Controls.Add(BackupSelect); this.Controls.Add(BackupsSize); this.Controls.Add(new Elem.Div(new Control[] { new Elem.But("View", ViewBackup, "This button shows info about the backup. (You can do the same by double-clicking a backup on the list)"), new Elem.But("Load", (s, e) => { Elem.ChooseForm BackupCurrent = new Elem.ChooseForm( "Backup current progress?", new string[] { "Yes", "No", "Cancel" }, "Would you like to backup your current GD progress before loading?" ); BackupCurrent.Show(); BackupCurrent.Finish += (s) => { if (s == 2) { return; } if (BackupSelect.SelectedItem != null) { if (s == 0) { GDTools.Backups.CreateNewBackup(); } GDTools.Backups.SwitchToBackup(((Elem.Select.SelectItem)BackupSelect.SelectedItem).Text); Program.MainForm.FullReload(); } }; }, "Switches your current GD progress to that of the backup. Asks you before switching if you'd like to save your current progress."), new Elem.But("Delete", (s, e) => { if (BackupSelect.SelectedItem != null) { Elem.ChooseForm Y = new Elem.ChooseForm("Are you sure?", new string[] { "Yes", "Cancel" }, "Are you sure you want to delete this backup?"); Y.Show(); Y.Finish += s => { if (s != 0) { return; } GDTools.Backups.DeleteBackup(((Elem.Select.SelectItem)BackupSelect.SelectedItem).Text); RefreshBackupList(); }; } }, "Deletes the selected backup permanently.") })); this.Controls.Add(new Elem.Div(new Control[] { new Elem.But("New", (s, e) => { GDTools.Backups.CreateNewBackup(); RefreshBackupList(); }, "Creates a new backup of your current GD progress."), new Elem.But("Import Backup", (s, e) => { Elem.ChooseForm FileOrFolder = new Elem.ChooseForm("Select backup type", new string[] { "Folder", $"Compressed file (.zip / .{GDTools.Ext.Backup})" }); FileOrFolder.Show(); FileOrFolder.Finish += (s) => { if (s == 0) { using (FolderBrowserDialog ofd = new FolderBrowserDialog()) { ofd.Description = "Select a backup folder"; if (ofd.ShowDialog() == DialogResult.OK) { GDTools.Backups.ImportBackup(ofd.SelectedPath); RefreshBackupList(); } } } else { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.InitialDirectory = "c:\\"; ofd.Filter = GDTools.Ext.BackupFilter; ofd.FilterIndex = 1; ofd.RestoreDirectory = true; ofd.Multiselect = true; if (ofd.ShowDialog() == DialogResult.OK) { foreach (string file in ofd.FileNames) { ImportBackup(file); } } } } }; }, "This button lets you import backups you've made before.") })); this.Controls.Add(new Elem.BigNewLine()); this.Controls.Add(BackupPath); this.Controls.Add(new Elem.Div(new Control[] { new Elem.But("Change Folder", (s, e) => { using (FolderBrowserDialog ofd = new FolderBrowserDialog()) { ofd.Description = "Select backup directory"; if (ofd.ShowDialog() == DialogResult.OK) { GDTools.Backups.SetBackupLocation(ofd.SelectedPath); RefreshBackupList(); } } }, "Change the folder where backups are saved. All backups are automatically moved to the new location."), new Elem.But("Open Folder", (s, e) => Process.Start("explorer.exe", GDTools._BackupDirectory), "Opens the backup folder in File Explorer."), new Elem.But("Refresh Folder", (s, e) => RefreshBackupList(), "Reloads the backup list.") })); this.Controls.Add(new Elem.BigNewLine()); this.Controls.Add(new Elem.But("Help", (s, e) => Pages.SettingPage.ShowHelp("backups"))); //this.Controls.Add(new Elem.BigNewLine()); //this.Controls.Add(new Elem.But("Link backups to Google Drive")); }