public void AppsMenuWin_Loaded(object sender, RoutedEventArgs e) { gridMain.Margin = new Thickness(this.Left - this.Width, gridMain.Margin.Top, gridMain.Margin.Right, gridMain.Margin.Bottom); foreach (string file in Directory.GetFiles(Environment.GetEnvironmentVariable("appdata") + @"\Microsoft\Windows\Start Menu\Programs", "*.lnk", SearchOption.AllDirectories)) { try { ImageSource icn; icn = winutils.GetIcon(file); if (icn == null) { break; } LBItem itm = new LBItem { FileIcon = icn, FileName = System.IO.Path.GetFileNameWithoutExtension(file), FullPath = file }; this.DataContext = itm; appsList.Items.Add(itm); } catch { MessageBox.Show("Error while adding " + file + "to the list.", "error", MessageBoxButton.OK, MessageBoxImage.Error); } } var sb = new Storyboard(); var ta = new ThicknessAnimation(); ta.BeginTime = new TimeSpan(0); ta.SetValue(Storyboard.TargetNameProperty, "gridMain"); Storyboard.SetTargetProperty(ta, new PropertyPath(MarginProperty)); ta.From = new Thickness(gridMain.Margin.Left, gridMain.Margin.Top, gridMain.Margin.Right, gridMain.Margin.Bottom); ta.To = new Thickness(this.Left + 8, gridMain.Margin.Top, gridMain.Margin.Right, gridMain.Margin.Bottom); ta.Duration = new Duration(TimeSpan.FromSeconds(1)); sb.Children.Add(ta); sb.Begin(this); }
private void AddItem(string aName, object aObj, int aImageIndex) { LBItem listItem = fSkillsList.Items.Add(aName, aObj); listItem.Color = Colors.Gold; listItem.ImageIndex = aImageIndex; }
private void Pack_ItemSelect(object sender, MouseButton button, LBItem item) { if (button == MouseButton.mbRight) { Item itm = (Item)item.Data; UseInvItem(itm); UpdateEquipmentLists(); } }
private void appsList_MouseDoubleClick(object sender, MouseButtonEventArgs e) { LBItem item = ((FrameworkElement)e.OriginalSource).DataContext as LBItem; if (item != null) { System.Diagnostics.Process.Start(item.FullPath); } }
private void OnConversationSelect(object sender, MouseButton button, LBItem item) { fTextBox.Lines.Clear(); int idx = fConversations.SelIndex; SentientBrain colBrain = (SentientBrain)fCollocutor.Brain; fCurTopic = colBrain.GetTopic(GlobalVars.nwrGame.Player, idx, null, ""); ShowTopic(fCurTopic, true); }
private void OnDisciplineSelect(object sender, MouseButton button, LBItem item) { if (button == MouseButton.mbRight) { TeachItem ti = (TeachItem)item.Data; if (ti.Price <= GlobalVars.nwrGame.Player.Money) { GlobalVars.nwrGame.Player.TeachDiscipline(fCollocutor, ti.Index, ti.CurLev); UpdateView(); } } }
private void UpdateKeyList() { fKeyList.Items.Clear(); for (var ua = UserAction.uaFirst; ua <= UserAction.uaLast; ua++) { UserActionRec uAct = StaticData.dbUserActions[(int)ua]; LBItem item = fKeyList.Items.Add(BaseLocale.GetStr(uAct.NameRes), null); string s = BaseMainWindow.HotKeyToText(uAct.HotKey); item.SubItems.Add(s, null); } }
private void AddCandidate(NWCreature aCreature) { int hPrice = (int)aCreature.HirePrice; LBItem item = fMercenariesList.Items.Add(aCreature.Name, aCreature); item.SubItems.Add(Convert.ToString(hPrice), null); if (GlobalVars.nwrGame.Player.Money >= hPrice && CanRecruit()) { item.Color = Colors.Gold; } else { item.Color = Colors.Red; } }
private void OnMercenarySelect(object sender, MouseButton button, LBItem item) { fMercenaryPropsList.Items.Clear(); if (item != null) { NWCreature merc = (NWCreature)item.Data; LBItemList items = fMercenaryPropsList.Items; StringList props = merc.Props; for (int i = 0; i < props.Count; i++) { items.Add(props[i], null); } } }
private void Knowledges_Select(object sender, MouseButton button, LBItem item) { fText.Lines.BeginUpdate(); if (item.Data == null) { fText.Lines.Text = ""; } else { MemoryEntry K = (MemoryEntry)item.Data; string desc = K.Desc.Replace("|", AuxUtils.CRLF); fText.Lines.Clear(); fText.Lines.Add(K.Name); fText.Lines.Add(""); fText.Lines.Add(desc); } fText.Lines.EndUpdate(); }
public static void AddListItem(ListBox aList, string aName, Item aItem, bool aIcons) { LBItem listItem = aList.Items.Add(aName, aItem); if (aItem != null) { var ikRec = StaticData.dbItemKinds[(int)aItem.Kind]; listItem.Color = ikRec.Color; if (!aIcons) { listItem.ImageIndex = (int)aItem.Symbol; } else { listItem.ImageIndex = aItem.ImageIndex; } } }
private void OnItemDraw(object sender, BaseScreen screen, int itemIndex, ExtRect itemRect) { ListBox box = (ListBox)sender; if (box.Options.Contains(LBOptions.lboIcons) && GlobalVars.nwrWin.InventoryOnlyIcons) { LBItem listItem = box.Items.GetItem(itemIndex); Item item = (Item)listItem.Data; if (item != null && item.Countable && item.Count > 1) { int tx = itemRect.Left + 2 + box.IconWidth - 1 - box.Font.GetTextWidth("+"); int ty = itemRect.Top + (box.ItemHeight - box.IconHeight) / 2; screen.SetTextColor(Colors.Lime, true); screen.DrawText(tx, ty, "+", 0); } } }
public override void Pulse() { if (!sw.IsRunning) { sw.Start(); } else if (sw.Elapsed.TotalMilliseconds < 5000) // throttle to run max every 5s { // time hasn't passed yet, so return return; } // return early if we cant' or shouldn;t use an item if (StyxWoW.Me.IsActuallyInCombat || StyxWoW.Me.Mounted || StyxWoW.Me.IsDead || StyxWoW.Me.IsGhost //|| Styx.CommonBot.LootTargeting.LootMobs // currently broken in the api, used to delay tidying up until everything is looted ) { return; } foreach (WoWItem item in ObjectManager.GetObjectsOfType <WoWItem>()) // iterate over every item { if (item != null && item.BagSlot != -1) // check if item exists and is in bag { if (this._items.Contains(Convert.ToInt32(item.Entry))) // look for item in collection { LBItem _item = _items[Convert.ToInt32(item.Entry)]; // get LBItem Obj for found Item if (item.StackCount >= _item.StackSize) // check against supplied stack count { this.processItem(item, _item); // process the item } } } } StyxWoW.SleepForLagDuration(); sw.Reset(); sw.Start(); }
private static LBItemCollection parseItemsStructure(IEnumerable<XElement> items, LBItemCollection collection) { foreach (XElement item in items) // process all items { int id = Int32.Parse(item.Attribute("id").Value); // parse id attribute int stack = Int32.Parse(item.Attribute("stack").Value); // parse stack attribute bool sleep = Boolean.Parse(item.Attribute("sleep").Value); // parse sleep attribute string action = item.Attribute("action").Value; // parse action attribute LBItem tempItem = new LBItem(id, stack, sleep, action); // generate new LBItem object // check if element is an override, then throw it out if (collection.Contains(tempItem.ItemId)) { collection.Remove(tempItem.ItemId); } collection.Add(tempItem); // add object to collection } return collection; }
private void Out_ItemSelect(object sender, MouseButton button, LBItem item) { if (button == MouseButton.mbRight) { if (fMode != IWMODE_GROUND) { GlobalVars.nwrWin.ShowText(GlobalVars.nwrWin, BaseLocale.GetStr(RS.rs_UseWarning)); } else { Item itm = (Item)item.Data; if (itm.EquipmentKind == BodypartType.bp_None) { UseInvItem(itm); } else { TakeInvItem(itm, false); } UpdateEquipmentLists(); } } }
private void processItem(WoWItem wowItem, LBItem tbItem) { // LBItem holds the action to use, switch to the right method switch (lbItem.Action) { case "use": Logging.Write(LogLevel.Normal, Colors.DarkRed, "[{0} {1}]: Using {2} we have {3}", this.Name, this.Version, wowItem.Name, wowItem.StackCount); ItemInteraction.UseItem(wowItem, tbItem.NeedsSleep); break; case "drop": Logging.Write(LogLevel.Normal, Colors.DarkRed, "[{0} {1}]: Dropping {2}", this.Name, this.Version, wowItem.Name); ItemInteraction.DropItem(wowItem); break; case "keep": // dummy action, does nothing as nothing is exactly what is meant break; default: Logging.Write(LogLevel.Normal, Colors.DarkRed, "[{0} {1}]: Trying to process \"{2}\" but Action \"{3}\" is unknown", this.Name, this.Version, wowItem.Name, tbItem.Action); break; } }
private void OnSkillsSelect(object Sender, MouseButton Button, LBItem Item) { if (Button == MouseButton.mbRight) { int idx = (int)Item.Data; switch (fMode) { case SWM_SKILLS: { SkillID sk = (SkillID)(idx); if (sk != SkillID.Sk_Alchemy) { if (sk != SkillID.Sk_Ironworking) { if (sk != SkillID.Sk_Spellcasting) { Hide(); GlobalVars.nwrGame.DoPlayerAction(CreatureAction.caSkillUse, idx); } else { Mode = SWM_SPELLS; } } else { string ts = GlobalVars.nwrGame.Player.Craft.CheckSmithyTools(); if (ts.CompareTo("") != 0) { GlobalVars.nwrWin.ShowText(GlobalVars.nwrWin, BaseLocale.Format(RS.rs_NoInstruments, new object[] { ts })); } else { Hide(); GlobalVars.nwrWin.ShowSmithyWin(); } } } else { Hide(); GlobalVars.nwrWin.ShowAlchemyWin(); } break; } case SWM_SPELLS: Hide(); GlobalVars.nwrGame.DoPlayerAction(CreatureAction.caSpellUse, idx); break; case SWM_TILES: Hide(); GlobalVars.nwrWin.TargetData.Ext.SetParam(EffectParams.ep_TileID, idx); GlobalVars.nwrWin.UseTarget(); break; case SWM_LANDS: Hide(); GlobalVars.nwrWin.TargetData.Ext.SetParam(EffectParams.ep_Land, idx); GlobalVars.nwrWin.UseTarget(); break; case SWM_SCROLLS: Hide(); GlobalVars.nwrWin.TargetData.Ext.SetParam(EffectParams.ep_ScrollID, idx); GlobalVars.nwrWin.UseTarget(); break; case SWM_GODS: Hide(); GlobalVars.nwrWin.TargetData.Ext.SetParam(EffectParams.ep_GodID, idx); GlobalVars.nwrWin.UseTarget(); break; } } }
private void OnServiceSelect(object sender, MouseButton button, LBItem item) { NWCreature p = GlobalVars.nwrGame.Player; Service serv = ((Service)item.Data); string qst = BaseLocale.GetStr(StaticData.dbDialogServices[(int)serv].QuestionRes); switch (serv) { case Service.ds_Teach: if (!fCollocutor.CanTeach(p)) { Message = qst; Message = BaseLocale.GetStr(RS.rs_NothingToTeach); } else { GlobalVars.nwrWin.ShowTeachWin(fCollocutor); } break; case Service.ds_Trade: if (!fCollocutor.IsTrader && !fCollocutor.Mercenary) { Message = qst; Message = BaseLocale.GetStr(RS.rs_NotTrader); } else { GlobalVars.nwrWin.ShowInventory(fCollocutor); } break; case Service.ds_Exchange: if (!fCollocutor.Mercenary) { Message = qst; Message = BaseLocale.GetStr(RS.rs_NothingExchange); } else { GlobalVars.nwrWin.ShowExchangeWin(fCollocutor); } break; case Service.ds_Recruit: if (fCollocutor.Mercenary) { Message = qst; Message = BaseLocale.GetStr(RS.rs_AlreadyHired); } else { if (fCollocutor.CLSID_Renamed == GlobalVars.cid_Guardsman) { Message = qst; Message = BaseLocale.GetStr(RS.rs_DoNotHired); } else { GlobalVars.nwrWin.ShowRecruit(fCollocutor); } } break; } }
private void UpdateView() { fPackList.Items.Clear(); fIngredientsList.Items.Clear(); fResList.Items.Clear(); EntityList items = GlobalVars.nwrGame.Player.Items; MaterialKind mat = MaterialKind.mk_None; int num = items.Count; for (int i = 0; i < num; i++) { Item item = (Item)items.GetItem(i); mat = item.Entry.Material; if (mat != MaterialKind.mk_None && fIngredients.FindByGUID(item.UID_Renamed) == null) { AddListItem(fPackList, GetItemFullName(item), item, true); } } int num2 = fIngredients.Count; for (int i = 0; i < num2; i++) { Item item = (Item)fIngredients.GetItem(i); AddListItem(fIngredientsList, GetItemFullName(item), item, true); } float sum = 0F; int res = GlobalVars.nwrGame.Player.Craft.CheckForgeIngredients(fIngredients, ref sum, ref mat); if (res != Craft.RC_Ok) { if (res == Craft.RC_DifferentMetals) { fResList.Items.Add(BaseLocale.GetStr(RS.rs_DifferentMetals), null); } } else { ItemEntry iEntry = (ItemEntry)GlobalVars.nwrDB.GetEntry(GlobalVars.iid_Ingot); var ikRec = StaticData.dbItemKinds[(int)iEntry.ItmKind]; if (iEntry.Material == mat) { LBItem listItem = fResList.Items.Add(BaseLocale.GetStr(RS.rs_MeltInIngot), null); listItem.ImageIndex = iEntry.ImageIndex; listItem.Color = ikRec.Color; } int num3 = GlobalVars.dbWeapon.Count; for (int i = 0; i < num3; i++) { iEntry = ((ItemEntry)GlobalVars.nwrDB.GetEntry(GlobalVars.dbWeapon[i])); if (iEntry.Material == mat && iEntry.Weight <= sum && !iEntry.Unique && !iEntry.Meta) { LBItem listItem = fResList.Items.Add(GetItemFullName(iEntry), iEntry); listItem.ImageIndex = iEntry.ImageIndex; listItem.Color = ikRec.Color; } } } }
private void Rebuild() { DataTable issues = new DataTable(); issues.Columns.Add("Issue"); issues.Columns.Add("Tag"); issues.Columns.Add("Count"); issues.Columns.Add("Type"); issues.Columns["Type"].DataType = typeof(int); issues.Columns.Add("Data"); issues.Columns["Data"].DataType = typeof(object); // list of errors foreach (var key in _errsByCodeAndTag.Keys) { LBItem lbi = new LBItem(); lbi.type = ERR; lbi.key = key; lbi.data = _errsByCodeAndTag[key]; lbi.disp = string.Format("{0} Tag: {1} :x({2})", key.Item1, key.Item2, _errsByCodeAndTag[key].Count); DataRow row = issues.NewRow(); row["Issue"] = key.Item1; row["Tag"] = key.Item2; row["Count"] = _errsByCodeAndTag[key].Count; row["Type"] = ERR; row["Data"] = _errsByCodeAndTag[key]; issues.Rows.Add(row); // listBox1.Items.Add(lbi); } // list of issues foreach (var iss in _issByCode.Keys) { LBItem lbi = new LBItem(); lbi.type = ISS; lbi.key = iss; lbi.data = _issByCode[iss]; lbi.disp = string.Format("{0} :x({1})", iss, _issByCode[iss].Count); DataRow row = issues.NewRow(); row["Issue"] = iss; row["Tag"] = ""; row["Count"] = _issByCode[iss].Count; row["Type"] = ISS; row["Data"] = _issByCode[iss]; issues.Rows.Add(row); // listBox1.Items.Add(lbi); } // list of unknowns foreach (var key in _unkByTag.Keys) { //LBItem lbi = new LBItem(); //lbi.key = key; //lbi.type = UNK; //lbi.data = _unkByTag[key]; //lbi.disp = string.Format("Invalid tag {0} :x({1})", key, _unkByTag[key].Count); if (_mysettings.IgnoreCustom && key.StartsWith("_")) { continue; } DataRow row = issues.NewRow(); row["Issue"] = "Unknown tag"; row["Tag"] = key; row["Count"] = _unkByTag[key].Count; row["Type"] = UNK; row["Data"] = _unkByTag[key]; issues.Rows.Add(row); // listBox1.Items.Add(lbi); } dataGridView1.SuspendLayout(); dataGridView1.DataSource = issues; dataGridView1.Columns["Type"].Visible = false; dataGridView1.Columns["Data"].Visible = false; dataGridView1.Columns["Count"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.ResumeLayout(); }
private void processItem(WoWItem wowItem, LBItem tbItem) { // LBItem holds the action to use, switch to the right method switch (lbItem.Action) { case "use": Logging.Write(LogLevel.Normal, Colors.DarkRed, "[{0} {1}]: Using {2} we have {3}", this.Name, this.Version, wowItem.Name, wowItem.StackCount); ItemInteraction.UseItem(wowItem, tbItem.NeedsSleep); break; case "drop": Logging.Write(LogLevel.Normal, Colors.DarkRed, "[{0} {1}]: Dropping {2}", this.Name, this.Version, wowItem.Name); ItemInteraction.DropItem(wowItem); break; case "keep": // dummy action, does nothing as nothing is exactly what is meant break; default: Logging.Write(LogLevel.Normal, Colors.DarkRed, "[{0} {1}]: Trying to process \"{2}\" but Action \"{3}\" is unknown", this.Name, this.Version, wowItem.Name, tbItem.Action); break; } }
private void OnFormationSelect(object sender, MouseButton button, LBItem item) { GlobalVars.nwrGame.Player.PartyFormation = (PartyFormation)(item.AbsoluteIndex); }
private void OnLangSelect(object sender, MouseButton button, LBItem item) { GlobalVars.nwrWin.Language = item.Text; }
private void UpdateView() { fDisciplinesList.Items.BeginUpdate(); fDisciplinesList.Items.Clear(); NWCreature clt = fCollocutor; Player p = GlobalVars.nwrGame.Player; for (int i = 0; i < StaticData.dbTeachable.Length; i++) { int id = StaticData.dbTeachable[i].Id; bool res = false; TeachableKind kind = StaticData.dbTeachable[i].Kind; string s = ""; int imageIndex = -1; int curLev = 0; switch (kind) { case TeachableKind.Ability: AbilityRec abRec = StaticData.dbAbilities[id]; AbilityID ab = (AbilityID)id; if (clt.GetAbility(ab) > 0) { s = BaseLocale.GetStr(abRec.Name); imageIndex = -1; curLev = p.GetAbility(ab); res = (curLev < clt.GetAbility(ab)); } break; case TeachableKind.Skill: SkillRec skRec = StaticData.dbSkills[id]; SkillID sk = (SkillID)id; if (clt.GetSkill(sk) >= 0) { s = BaseLocale.GetStr(skRec.Name); imageIndex = skRec.ImageIndex; curLev = p.GetSkill(sk); res = (curLev < clt.GetSkill(sk)); } break; } int price = (int)GlobalVars.nwrGame.GetTeachablePrice(i, curLev); if (res) { string st = " ( " + Convert.ToString(curLev) + " -> " + Convert.ToString(curLev + 1) + " )"; LBItem listItem = fDisciplinesList.Items.Add(s + st, new TeachItem(i, curLev, price)); if (price > p.Money) { listItem.Color = Colors.Red; } else { listItem.Color = Colors.Gold; } listItem.ImageIndex = imageIndex; listItem.SubItems.Add(Convert.ToString(price), null); } } fDisciplinesList.Items.EndUpdate(); }