private void DisableRule(cLootItemRule ruleToDisable) { bool disabled = false; List <iLootRule> remove = new List <iLootRule>(); foreach (iLootRule req in ruleToDisable.IntRules) { if (req.GetRuleType() == eLootRuleType.DisabledRule) { disabled = disabled || ((DisabledRule)req).b; remove.Add(req); } } foreach (iLootRule req in remove) { ruleToDisable.IntRules.Remove(req); } if (!disabled) { ruleToDisable.IntRules.Add(new DisabledRule(true)); } SetCurrentRule(ruleToDisable, CurrentRuleNum); FileChanged = true; }
private void updateMaterialRule(cLootItemRule r, int mat, int w) { LongValKeyLE r1 = new LongValKeyLE(mat, IntValueKey.Material); LongValKeyGE r2 = new LongValKeyGE(mat, IntValueKey.Material); DoubleValKeyGE r3 = new DoubleValKeyGE(Convert.ToDouble(w), DoubleValueKey.SalvageWorkmanship); r.IntRules = new List <iLootRule>(new iLootRule[] { r1, r2, r3 }); }
void SetCurrentRule(cLootItemRule cr, int crn) { Working = true; CurrentRule = cr; CurrentRuleNum = crn; if (cr == null) { groupRule.Visible = false; if (lstRules.SelectedIndex >= 0) { lstRules.SelectedIndex = -1; } } else { lstRules.SelectedIndex = -1; lstRules.SelectedIndex = crn; groupRule.Visible = true; txtRuleName.Text = cr.name; cmbAction.Items.Clear(); cmbAction.Items.AddRange(eLootActionTool.FriendlyNames().ToArray()); txtKeepCount.Visible = false; switch (cr.act) { case eLootAction.Keep: cmbAction.SelectedIndex = 0; break; case eLootAction.Salvage: cmbAction.SelectedIndex = 1; break; case eLootAction.Sell: cmbAction.SelectedIndex = 2; break; case eLootAction.Read: cmbAction.SelectedIndex = 3; break; case eLootAction.KeepUpTo: cmbAction.SelectedIndex = 4; txtKeepCount.Visible = true; txtKeepCount.Text = cr.LootActionData.ToString(); break; } SetCurrentReq(null, 0); lstRequirements.Items.Clear(); foreach (iLootRule newlr in cr.IntRules) { lstRequirements.Items.Add(newlr.DisplayString()); } } Working = false; }
private void cmdNewRule_Click(object sender, EventArgs e) { FileChanged = true; cLootItemRule lr = new cLootItemRule(); lr.name = "New Rule"; lr.act = eLootAction.Keep; AddRuleToList(lr, CtrlPressed); }
private void cmdNewRule_Click(object sender, EventArgs e) { FileChanged = true; cLootItemRule lr = new cLootItemRule(); lr.name = "New Rule"; lr.act = eLootAction.Keep; LootRules.Rules.Add(lr); lstRules.Items.Add(lr.name); SetCurrentRule(lr, LootRules.Rules.Count - 1); }
private void addMaterialRule(int mat, int work, string name) { cLootItemRule r = new cLootItemRule(); r.name = name; r.act = eLootAction.Salvage; updateMaterialRule(r, mat, work); LootRules.Rules.Add(r); lstRules.Items.Add(r.name); FileChanged = true; }
private void cmdCloneRule_Click(object sender, EventArgs e) { if (CurrentRule != null) { cLootItemRule lr = new cLootItemRule(); lr.name = CurrentRule.name; lr.act = CurrentRule.act; foreach (iLootRule r in CurrentRule.IntRules) { lr.IntRules.Add((iLootRule)r.Clone()); } AddRuleToList(lr, CtrlPressed); } }
private void cmdCloneRule_Click(object sender, EventArgs e) { if (CurrentRule != null) { cLootItemRule lr = new cLootItemRule(); lr.name = CurrentRule.name; lr.act = CurrentRule.act; foreach (iLootRule r in CurrentRule.IntRules) { lr.IntRules.Add((iLootRule)r.Clone()); } LootRules.Rules.Add(lr); lstRules.Items.Add(lr.name); SetCurrentRule(lr, LootRules.Rules.Count - 1); } }
private void AddRuleToList(cLootItemRule lr, bool addRuleAfterCurrentSelectedRule) { if (addRuleAfterCurrentSelectedRule && lstRules.SelectedIndex != -1) { // This method inserts the new loot rule after the currently selected loot rule in our ListView LootRules.Rules.Insert(lstRules.SelectedIndex + 1, lr); lstRules.Items.Insert(lstRules.SelectedIndex + 1, lr.name); SetCurrentRule(lr, lstRules.SelectedIndex + 1); } else { // This is the standard method LootRules.Rules.Add(lr); lstRules.Items.Add(lr.name); SetCurrentRule(lr, LootRules.Rules.Count - 1); } }
private void cmdNewRule_Click(object sender, EventArgs e) { FileChanged = true; cLootItemRule lr = new cLootItemRule(); lr.name = "New Rule"; lr.act = eLootAction.Keep; // Mag-nus changed if (CtrlPressed) { addRuleToList(lr, true); } else { addRuleToList(lr); // Standard method } }
private void lstRules_SelectedIndexChanged(object sender, EventArgs e) { if (Working) { return; } if (lstRules.SelectedIndex >= 0) { cLootItemRule selectedRule = LootRules.Rules[lstRules.SelectedIndex]; SetCurrentRule(LootRules.Rules[lstRules.SelectedIndex], lstRules.SelectedIndex); if (Form.ModifierKeys == Keys.Control) { DisableRule(selectedRule); } } else { SetCurrentRule(null, 0); } }
private void cmdCloneRule_Click(object sender, EventArgs e) { if (CurrentRule != null) { cLootItemRule lr = new cLootItemRule(); lr.name = CurrentRule.name; lr.act = CurrentRule.act; foreach (iLootRule r in CurrentRule.IntRules) { lr.IntRules.Add((iLootRule)r.Clone()); } // Mag-nus changed if (CtrlPressed) { addRuleToList(lr, true); } else { addRuleToList(lr); // Standard method } } }
private void toolStripButton2_Click(object sender, EventArgs e) { try { string t = Clipboard.GetText(); if (!String.IsNullOrEmpty(t)) { MemoryStream m = new MemoryStream(Encoding.ASCII.GetBytes(t)); cLootItemRule lr = new cLootItemRule(); bool ruleIsNew = true; if (CtrlPressed && CurrentRule != null) { //MessageBox.Show("replacing current rule"); lr = CurrentRule; ruleIsNew = false; } lr.Read(new StreamReader(m), LootRules.UTLFileVersion); if (ruleIsNew) { addRuleToList(lr); } else { lstRules.Items[CurrentRuleNum] = lr.name; } lstRules.Invalidate(); lstRequirements.Invalidate(); FileChanged = true; } } catch (Exception ex) { } }
void PasteRuleFromClipboard(bool checkhash) { try { string raw_t = Clipboard.GetText(); //Split it up if (string.IsNullOrEmpty(raw_t)) { MessageBox.Show("Invalid rule format in clipboard."); return; } string[] split_raw_t = raw_t.Split('#'); if (split_raw_t.Length < 2) { MessageBox.Show("Invalid rule format in clipboard."); return; } string t_proposed_hash = split_raw_t[0]; string t = string.Join("#", split_raw_t, 1, split_raw_t.Length - 1); //Verify hash System.Security.Cryptography.SHA256Managed c = new System.Security.Cryptography.SHA256Managed(); System.Text.UTF8Encoding e = new UTF8Encoding(); byte[] rep = e.GetBytes(t); string hashstr = Convert.ToBase64String(c.ComputeHash(rep)); if (checkhash) { if (!string.Equals(hashstr, t_proposed_hash, StringComparison.Ordinal)) { MessageBox.Show("Invalid rule format in clipboard."); return; } } if (!String.IsNullOrEmpty(t)) { MemoryStream m = new MemoryStream(Encoding.ASCII.GetBytes(t)); cLootItemRule lr = new cLootItemRule(); bool ruleIsNew = true; if (CtrlPressed && CurrentRule != null) { ruleIsNew = false; } lr.Read(new StreamReader(m), LootRules.UTLFileVersion); if (ruleIsNew) { AddRuleToList(lr); } else { int oldind = CurrentRuleNum; AddRuleToList(lr, true); DeleteRule(oldind); } lstRules.Invalidate(); lstRequirements.Invalidate(); FileChanged = true; } } catch { } }
private void updateMaterialRule(cLootItemRule r, int mat, int w) { LongValKeyLE r1 = new LongValKeyLE(mat, IntValueKey.Material); LongValKeyGE r2 = new LongValKeyGE(mat, IntValueKey.Material); DoubleValKeyGE r3 = new DoubleValKeyGE(Convert.ToDouble(w), DoubleValueKey.SalvageWorkmanship); r.IntRules = new List<iLootRule>(new iLootRule[] { r1, r2, r3 }); }
private void AddRuleToList(cLootItemRule lr) { AddRuleToList(lr, false); }
private void addMaterialRule(int mat, int work, string name) { cLootItemRule r = new cLootItemRule(); r.name = name; r.act = eLootAction.Salvage; updateMaterialRule(r, mat, work); LootRules.Rules.Add(r); lstRules.Items.Add(r.name); FileChanged = true; }
private void cmdNewRule_Click(object sender, EventArgs e) { FileChanged = true; cLootItemRule lr = new cLootItemRule(); lr.name = "New Rule"; lr.act = eLootAction.Keep; // Mag-nus changed if (CtrlPressed) addRuleToList(lr, true); else addRuleToList(lr); // Standard method }
private void cmdCloneRule_Click(object sender, EventArgs e) { if (CurrentRule != null) { cLootItemRule lr = new cLootItemRule(); lr.name = CurrentRule.name; lr.act = CurrentRule.act; foreach (iLootRule r in CurrentRule.IntRules) { lr.IntRules.Add((iLootRule)r.Clone()); } // Mag-nus changed if (CtrlPressed) addRuleToList(lr, true); else addRuleToList(lr); // Standard method } }
void SetCurrentRule(cLootItemRule cr, int crn) { Working = true; CurrentRule = cr; CurrentRuleNum = crn; if (cr == null) { groupRule.Visible = false; if (lstRules.SelectedIndex >= 0) lstRules.SelectedIndex = -1; } else { lstRules.SelectedIndex = -1; lstRules.SelectedIndex = crn; groupRule.Visible = true; txtRuleName.Text = cr.name; cmbAction.Items.Clear(); cmbAction.Items.AddRange(eLootActionTool.FriendlyNames().ToArray()); txtKeepCount.Visible = false; switch (cr.act) { case eLootAction.Keep: cmbAction.SelectedIndex = 0; break; case eLootAction.Salvage: cmbAction.SelectedIndex = 1; break; case eLootAction.Sell: cmbAction.SelectedIndex = 2; break; case eLootAction.Read: cmbAction.SelectedIndex = 3; break; case eLootAction.KeepUpTo: cmbAction.SelectedIndex = 4; txtKeepCount.Visible = true; txtKeepCount.Text = cr.LootActionData.ToString(); break; } SetCurrentReq(null, 0); lstRequirements.Items.Clear(); foreach (iLootRule newlr in cr.IntRules) { lstRequirements.Items.Add(newlr.DisplayString()); } } Working = false; }
// Mag-nus changed //private void addRuleToList(cLootItemRule lr) private void addRuleToList(cLootItemRule lr, bool addRuleAfterCurrentSelectedRule = false) { if (addRuleAfterCurrentSelectedRule && lstRules.SelectedIndex != -1) { // This method inserts the new loot rule after the currently selected loot rule in our ListView LootRules.Rules.Insert(lstRules.SelectedIndex + 1, lr); lstRules.Items.Insert(lstRules.SelectedIndex + 1, lr.name); SetCurrentRule(lr, lstRules.SelectedIndex + 1); } else { // This is the standard method LootRules.Rules.Add(lr); lstRules.Items.Add(lr.name); SetCurrentRule(lr, LootRules.Rules.Count - 1); } }
private void toolStripButton2_Click(object sender, EventArgs e) { try { string t = Clipboard.GetText(); if (!String.IsNullOrEmpty(t)) { MemoryStream m = new MemoryStream(Encoding.ASCII.GetBytes(t)); cLootItemRule lr = new cLootItemRule(); bool ruleIsNew = true; if (CtrlPressed && CurrentRule != null) { //MessageBox.Show("replacing current rule"); lr = CurrentRule; ruleIsNew = false; } lr.Read(new StreamReader(m), LootRules.UTLFileVersion); if (ruleIsNew) { addRuleToList(lr); } else { lstRules.Items[CurrentRuleNum] = lr.name; } lstRules.Invalidate(); lstRequirements.Invalidate(); FileChanged = true; } } catch (Exception ex) { } }