//================================================================================ public MainForm() { InitializeComponent(); aWaitMessages = new string[] { "Finding the mirror recipe.", "Searching 50% of buffs.", "Solving P vs NP TY GL HF problem.", "Studying Alkaizers playlist.", "Making the new Diablo-like game.", "Sustaining T16 maps.", "Porting PoE to HTML5." }; //app start: CajApp.start(this); //ggpk path: String s = CajApp.config.read(CajConfig.keyGGPKPath); if (s != "") { txtGgpkPath.Text = s; } //make good options: makeGoodTrack.Maximum = 6; makeGoodTrack.Value = CajApp.config.readInt(CajConfig.keyMakeGoodValue, 2); //wait label. must have: lblWait.Visible = false; generateNewWaitMessage(); }
//================================================================================ void LstResSelectedIndexChanged(object sender, EventArgs e) { if (lstRes.SelectedIndex == -1) { txtValue.Text = ""; mnuFile.Enabled = false; txtStatusLabel.Text = "Found: " + foundItems.ToString(); } else { string selName = lstRes.SelectedItem.ToString(); string key = keyPrefix + selName; if (selName.ToLowerInvariant().EndsWith(".dds", StringComparison.InvariantCulture)) { setTxtValueText("[brotli texture]"); } else { setTxtValueText(CajApp.getValueOfNode(key)); } txtValue.SelectionStart = 0; txtValue.ScrollToCaret(); mnuFile.Enabled = true; txtStatusLabel.Text = "Found: " + foundItems.ToString() + ". Selected: " + lstRes.SelectedItem.ToString(); txtStatusLabel.Text = lstRes.SelectedItem.ToString(); } }
//================================================================================ private void startQuery() { string s = txtQuery.Text; if (!mnuQueryRegExp.Checked) { s = s.Trim(); s = s.Replace("/", "\\"); s = s.ToLower(System.Globalization.CultureInfo.InvariantCulture); } if (s == "") { return; } txtValue.Text = ""; foundItems = 0; txtStatusLabel.Text = "in process, please wait..."; lstRes.Items.Clear(); mnuFile.Enabled = false; mnuQueryExportAll.Enabled = false; lastQuery = s; lstRes.BeginUpdate(); CajApp.searchInGgpk(s, mnuQueryRegExp.Checked, onQueryFoundItem); lstRes.EndUpdate(); txtStatusLabel.Text = "Found: " + foundItems.ToString(); if (foundItems > 0) { mnuQueryExportAll.Enabled = true; } }
//================================================================================ void onLoadDirConfirm(string s) { if (s != "") { CajApp.loadDir(s); } }
//================================================================================ public void createHotkey(string switchHotkey) { //RegisterHotKey() notes: //prevents key press in current target app. //doesn't work if PoE was run by admin and this app wasn't. //requires windows handle. removeHotkey(); if (switchHotkey == "") { return; } try { registeredHotkey = (int)Enum.Parse(typeof(Keys), switchHotkey); if (registeredHotkey > 0) { bool isOk = RegisterHotKey(this.Handle, switchHotkeyId, 0, registeredHotkey); lastRegisteredHotkey = switchHotkey; CajApp.trace("hotkey set: " + registeredHotkey.ToString() + " " + ((Keys)registeredHotkey).ToString() + ", " + isOk.ToString()); } else { CajApp.trace("no hotkey: " + registeredHotkey.ToString() + " " + switchHotkey); } } catch (Exception ex) { CajApp.trace("createHotkey hotkey (" + switchHotkey + ") ex: " + ex.Message); } }
//================================================================================ private void lstResults_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) { if (e == null) { Debug.WriteLine("RetrieveVirtualItemEventArgs is null"); e.Item = new ListViewItem("?"); return; } if (e.ItemIndex < 0 || e.ItemIndex >= aResults.Count) { Debug.WriteLine("incorrect ItemIndex = " + e.ItemIndex); e.Item = new ListViewItem("?"); return; } try { var res = aResults[e.ItemIndex]; e.Item = new ListViewItem(res); } catch (Exception ex) { Debug.WriteLine(ex); e.Item = new ListViewItem("?"); CajApp.addLog("search: " + ex.Message); } }
//================================================================================ private void ExportAllFoundFilesToolStripMenuItemClick(object sender, EventArgs e) { if (foundItems == 0) { return; } if (lastQuery == "") { return; } if (foundItems > 1000) { string text = "Do you really want to export " + foundItems.ToString() + " files?\r\nIt can be slow."; const string caption = "Export All"; if (MessageBox.Show(text, caption, MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } } exportDlg.FileName = "backup"; if (exportDlg.ShowDialog() == DialogResult.OK) { CajApp.exportAll(lastQuery, mnuQueryRegExp.Checked, exportDlg.FileName); txtStatusLabel.Text = "Saved: " + foundItems.ToString(); } }
//================================================================================ private void hideSafe() { stopThread(thSearch); stopThread(thDdsConvert); CajApp.stopExportAllThread(); this.Hide(); }
//================================================================================ private void ButOkClick(object sender, EventArgs e) { int type = 0; string text = ""; if (optAll.Checked) { type = CajApp.NULL_TYPE_ALL; text = ""; } else if (optAllExcept.Checked) { type = CajApp.NULL_TYPE_ALL_EXCEPT; text = txtList.Text; } else if (optOnly.Checked) { type = CajApp.NULL_TYPE_ONLY; text = txtList.Text; } int numKeepEmitters = CajApp.config.readInt(CajConfig.keyKeepEmitters, 0); this.Hide(); CajApp.nullEffectsButtonAction(type, text, numKeepEmitters); }
//================================================================================ private ListViewItem getItemView(string item) { if (aParticleFilePaths == null) { Debug.WriteLine("getItemView.aTabCheckResults == null"); return(defaultCheckListItem); } var res = new string[2]; string sEmitters; var node = CajApp.getNode(item); if (node != null) { //getting cache value, it's fast: int iEmitters = CajApp.recordsChanger.getEmittersNumber(node); sEmitters = iEmitters.ToString(); } else { Debug.WriteLine("getItemView.node == null: " + item + ", " + aParticleFilePaths.Count); sEmitters = "?"; } res[0] = sEmitters; res[1] = item; return(new ListViewItem(res)); }
//================================================================================ void ButOkClick(object sender, EventArgs e) { int type = 0; string text = ""; if (optAll.Checked) { type = CajApp.NULL_TYPE_ALL; text = ""; } else if (optAllExcept.Checked) { type = CajApp.NULL_TYPE_ALL_EXCEPT; text = txtList.Text; } else if (optOnly.Checked) { type = CajApp.NULL_TYPE_ONLY; text = txtList.Text; } int numKeepEmitters = 0; String s = CajApp.config.read(CajConfig.keyKeepEmitters); if (s != "") { numKeepEmitters = int.Parse(s); } CajApp.nullEffects(type, text, numKeepEmitters); this.Hide(); }
//================================================================================ private void onLoadDirConfirm(string s) { if (s != "") { CajApp.loadDirButtonAction(s); } }
//================================================================================ void MainFormResize(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Minimized) { CajApp.trace("minimized"); //removeHotkey(); //no. } }
//================================================================================ private void closeForm() { isWorking = false; CajApp.onExit(); //anyway don't abort alive writing threads to prevent .ggpk corrupting. //don't use tasks, check DevNotes. //use volatile flag to stop thread loops, it's safe. }
//================================================================================ private void ButSavePetsClick(object sender, EventArgs e) { if (saveBackupDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string savePath = saveBackupDlg.FileName; CajApp.saveParticlesBackupButtonAction(savePath); } }
//================================================================================ void butLoadBackupClick(object sender, EventArgs e) { if (loadBackupDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string loadPath = loadBackupDlg.FileName; CajApp.loadBackup(loadPath); } }
//================================================================================ void OptAllExceptCheckedChanged(object sender, EventArgs e) { if (optAllExcept.Checked) { onMethodChange(); loadList(CajApp.getAppPath() + CajApp.effectsListFileAllExcept); } }
private static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainForm frm = CajApp.start(); Application.Run(frm); }
//================================================================================ void ButSaveMiscClick(object sender, EventArgs e) { if (saveBackupDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string savePath = saveBackupDlg.FileName; CajApp.saveMisc(savePath); } }
//================================================================================ void OptOnlyCheckedChanged(object sender, EventArgs e) { if (optOnly.Checked) { onMethodChange(); loadList(CajApp.getAppPath() + CajApp.effectsListFileOnly); } }
//================================================================================ void ButOpenGgpkClick(object sender, EventArgs e) { butOpenGgpk.Enabled = false; txtLog.Focus(); enableActions(false); CajApp.openGgpk(onOpenedGgpk); CajApp.config.write(CajConfig.keyGGPKPath, txtGgpkPath.Text); }
//================================================================================ void loadList(string filePath) { try { txtList.Text = System.IO.File.ReadAllText(filePath); //lblLog.Text = CajApp.getCurrentTimeFormat() + ". loaded list."; //debug. } catch (Exception ex) { lblLog.Text = CajApp.getCurrentTimeFormat() + ". Error loading list: " + ex.Message; txtList.Text = ""; } }
//================================================================================ private void searchThread() { CajApp.searchInGgpk(lastQuery, isLastQueryRegExp, onQueryFoundItem); aResults.Sort(); Invoke(new Action(() => { updateUiResults(); })); }
//================================================================================ private void LstCheckListDoubleClick(object sender, EventArgs e) { string name; if (!vlstCheckList.getFirstSelectedItem(out name)) { return; } CajApp.showSearchInGgpkForm(name); }
//================================================================================ void NotifyIcon1MouseDoubleClick(object sender, MouseEventArgs e) { /* * //show overlay: * this.WindowState = FormWindowState.Normal; * onMin(); * this.Show(); */ //options: CajApp.showOptions(); }
//================================================================================ public void onFirstLaunch() { string poeFolder = CajFuns.findPoeFolder(); if (poeFolder != "") { txtPoeFolder.Text = poeFolder; CajApp.onOptionsChange(poeFolder, cbHotkey.Text); } txtPoeFolder.Focus(); //select it, so user can notice and correct it. }
//======================================== private void Awake() { instance = this; CameraAspectKeeper cameraController = FindObjectOfType <CameraAspectKeeper>(); if (cameraController != null) { cameraController.setResizeListener(this.onResize); } }
//================================================================================ private void openGgpk(bool isFromDisk) { mnuDontOpen.Enabled = false; butOpenGgpk.Enabled = false; txtLog.Focus(); enableActions(false); CajApp.openGgpk(isFromDisk, onOpenedGgpk); CajApp.config.write(CajConfig.keyGGPKPath, txtGgpkPath.Text); }
//================================================================================ private void onFilterQueryEnd() { if (aParticleFilePaths == null) { Debug.WriteLine("onFilterQueryEnd.updateCheckList == null"); } else { CajApp.addLog("records found: " + aParticleFilePaths.Count); vlstCheckList.onQueryStart(); vlstCheckList.onQueryEnd(aParticleFilePaths); } }
//================================================================================ public void removeHotkey() { if (registeredHotkey == 0) { return; } try { UnregisterHotKey(this.Handle, switchHotkeyId); } catch (Exception ex) { CajApp.trace("removeHotkey hotkey ex: " + ex.Message); } }