private void listBox2_DoubleClick(object sender, EventArgs e) { if (listBox2.SelectedItem is LogicEditor.RequiementConditional) { var item = (listBox2.SelectedItem as LogicEditor.RequiementConditional); if (item.ItemIDs.Count < 2) { GoBackList.Add(entry); entry = item.ItemIDs[0]; WriteEntry(); return; } MiscSingleItemSelect Selector = new MiscSingleItemSelect { Text = "Go to item", Display = 6, ListContent = item.ItemIDs }; Selector.ShowDialog(); if (Selector.DialogResult != DialogResult.OK) { return; } GoBackList.Add(entry); entry = Selector.SelectedObject; WriteEntry(); } }
private void listBox1_DoubleClick(object sender, EventArgs e) { if (!(listBox1.SelectedItem is LogicObjects.LogicEntry)) { return; } LogicObjects.LogicEntry E = listBox1.SelectedItem as LogicObjects.LogicEntry; int CursorPos = textBox1.SelectionStart; int InsertLength = 0; if (listView1.SelectedItems.Count > 0) { if ((Control.ModifierKeys & Keys.Control) == Keys.Control) { InsertLength = E.DictionaryName.Count(); textBox1.Text = textBox1.Text.Insert(textBox1.SelectionStart, E.DictionaryName); } else { InsertLength = E.ID.ToString().Count(); textBox1.Text = textBox1.Text.Insert(textBox1.SelectionStart, E.ID.ToString()); } } textBox1.Focus(); textBox1.SelectionStart = CursorPos + InsertLength; textBox1.SelectionLength = 0; }
public static bool NotAreaAccess(LogicObjects.LogicEntry entry, List <LogicObjects.LogicEntry> Logic) { //Attempts to check if a fake item details area access. If the fake item can be unlocked with only real item entries it should represent access to an area //And shouldn't need to be unaquired for the pathfinder var Reqdef = new int[0]; var Condef = new int[0][]; foreach (var i in entry.Required ?? Reqdef) { var reqEntry = Logic[i]; if (reqEntry.IsFake || reqEntry.IsEntrance()) { return(false); } } foreach (var h in entry.Conditionals ?? Condef) { var RealEntry = true; foreach (var i in h) { var CondEntry = Logic[i]; if (CondEntry.IsFake || CondEntry.IsEntrance()) { RealEntry = false; } } if (RealEntry) { return(true); } } return(false); }
private void listBox1_DoubleClick(object sender, EventArgs e) { if (!(listBox1.SelectedItem is LogicObjects.ListItem)) { return; } SelectedObject = (listBox1.SelectedItem as LogicObjects.ListItem).LocationEntry; switch (Function) { case 0: // General Select this.DialogResult = DialogResult.OK; this.Close(); return; case 1: // What Unlocked This Tools.WhatUnlockedThis(SelectedObject); break; case 2: // Spoiler Log Lookup if (!(listBox1.SelectedItem is LogicObjects.ListItem)) { return; } var item = (listBox1.SelectedItem as LogicObjects.ListItem).LocationEntry; var itemLocation = item.GetItemsSpoilerLocation(UsedInstance.Logic); if (itemLocation == null) { MessageBox.Show($"{item.DictionaryName} Was not found in spoiler data"); } MessageBox.Show($"{item.ItemName??item.DictionaryName} is found at {itemLocation.LocationName ?? itemLocation.DictionaryName}", $"{ item.DictionaryName} Item Location: "); break; } }
public void WriteItems(LogicObjects.LogicEntry entry) { LBItemSelect.ItemHeight = Convert.ToInt32(LogicObjects.MainTrackerInstance.Options.FormFont.Size * 1.7); var UsedLogic = Instance.Logic; var options = Instance.Options; LBItemSelect.Items.Clear(); List <string> Duplicates = new List <string>(); for (var i = 0; i < UsedLogic.Count; i++) { var ItemName = UsedLogic[i].ProgressiveItemName(LogicObjects.MainTrackerInstance); UsedLogic[i].DisplayName = ItemName; if ((!UsedLogic[i].IsFake) && ((UsedLogic[i].GetItemsNewLocation(UsedLogic) == null && !UsedLogic[i].Aquired) || Instance.Options.IsMultiWorld || !options.RemoveObtainedItemsfromList) && (!UsedLogic[i].Unrandomized(2)) && !Duplicates.Contains(ItemName) && UsedLogic[i].ItemName != null && Utility.FilterSearch(UsedLogic[i], TXTSearch.Text, UsedLogic[i].DisplayName) && (entry.ItemSubType == UsedLogic[i].ItemSubType || (entry.IsEntrance() && UsedLogic[i].IsEntrance()) || entry.ItemSubType == "ALL")) { LBItemSelect.Items.Add(UsedLogic[i]); Duplicates.Add(ItemName); } } }
private bool CheckManualItem(object sender, EventArgs e) { var CheckedObject = ManualSelect[0]; LogicObjects.LogicEntry SelectedItem = new LogicObjects.LogicEntry { ID = -1 }; if (sender == LBItemSelect) { if (!(LBItemSelect.SelectedItem is LogicObjects.LogicEntry)) { return(false); } SelectedItem = LBItemSelect.SelectedItem as LogicObjects.LogicEntry; } CheckedObject.Checked = true; if (LogicObjects.MainTrackerInstance.Options.IsMultiWorld) { CheckedObject.PlayerData.ItemBelongedToPlayer = (int)numericUpDown1.Value; } if (SelectedItem.ID < 0) { CheckedObject.RandomizedItem = -1; return(true); } CheckedObject.RandomizedItem = SelectedItem.ID; if (!LogicObjects.MainTrackerInstance.Options.IsMultiWorld || CheckedObject.ItemBelongsToMe()) { Instance.Logic[SelectedItem.ID].Aquired = true; } LogicEditing.CheckEntrancePair(CheckedObject, Instance, true); return(true); }
//External Actions public void FilterRegularItem(LogicObjects.LogicEntry e) { if (e == null) { return; } var itemLocation = e.GetItemsNewLocation(LogicObjects.MainTrackerInstance.Logic); if (itemLocation == null) { return; } if (itemLocation.Checked && e.Aquired) { if ((ModifierKeys & Keys.Control) != Keys.Control) { MainInterfaceInstance.TXTCheckedSearch.Text = $"_{e.ItemName}"; } else { MainInterfaceInstance.TXTCheckedSearch.Text += (MainInterfaceInstance.TXTCheckedSearch.Text == "" ? "" : "|") + $"_{e.ItemName}"; } } else { if ((ModifierKeys & Keys.Control) != Keys.Control) { MainInterfaceInstance.TXTLocSearch.Text = $"_{e.ItemName}"; } else { MainInterfaceInstance.TXTLocSearch.Text += (MainInterfaceInstance.TXTLocSearch.Text == "" ? "" : "|") + $"_{e.ItemName}"; } } }
private void listBox1_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index < 0) { return; } e.DrawBackground(); Font F = e.Font; Brush brush = ((e.State & DrawItemState.Selected) == DrawItemState.Selected) ? Brushes.White : Brushes.Black; if (listBox1.Items[e.Index] is LogicObjects.LogicEntry) { LogicObjects.LogicEntry entry = listBox1.Items[e.Index] as LogicObjects.LogicEntry; if (entry.ItemUseable(Instance)) { F = new Font(F.FontFamily, F.Size, FontStyle.Bold); } var Printname = entry.DictionaryName; if (entry.ItemName != null && !string.IsNullOrWhiteSpace(entry.ItemName)) { Printname = entry.ItemName; } e.Graphics.DrawString(Printname, F, brush, e.Bounds, StringFormat.GenericDefault); } else { e.Graphics.DrawString("Error", e.Font, brush, e.Bounds, StringFormat.GenericDefault); } e.DrawFocusRectangle(); }
public static string ProgressiveItemName(this LogicObjects.LogicEntry entry, LogicObjects.TrackerInstance Instance) { if (entry.IsProgressiveItem(Instance) && Instance.Options.ProgressiveItems && Instance.IsMM()) { return((entry.SpoilerItem.Count() > 1) ? entry.SpoilerItem[1] : entry.ItemName ?? entry.DictionaryName); } return(entry.ItemName ?? entry.DictionaryName); }
private void listBox1_DoubleClick(object sender, EventArgs e) { if (listBox1.SelectedItem is LogicObjects.LogicEntry) { GoBackList.Add(entry); entry = listBox1.SelectedItem as LogicObjects.LogicEntry; WriteEntry(); } }
public static bool FakeItemStatusChange(this LogicObjects.LogicEntry entry) { if (entry.Aquired != entry.Available && entry.IsFake) { entry.Aquired = entry.Available; return(true); } return(false); }
private void button1_Click(object sender, EventArgs e) { if (!GoBackList.Any()) { return; } entry = GoBackList[GoBackList.Count() - 1]; GoBackList.RemoveAt(GoBackList.Count() - 1); WriteEntry(); }
public static List <LogicObjects.LogicEntry> ProgressiveItemSet(this LogicObjects.LogicEntry entry, LogicObjects.TrackerInstance Instance) { if (!Instance.Options.ProgressiveItems || !Instance.IsMM()) { return(null); } List <List <LogicObjects.LogicEntry> > ProgressiveItemSets = Utility.GetProgressiveItemSets(Instance); var set = ProgressiveItemSets.Find(x => x.Contains(entry)); return(set); }
public static int ProgressiveItemsAquired(this LogicObjects.LogicEntry entry, LogicObjects.TrackerInstance Instance, bool Unique = true) { var set = entry.ProgressiveItemSet(Instance).Where(x => x.LogicItemAquired()).ToList(); var setIDs = set.Select(x => x.ID); if (Unique) { return(set.Where(x => x.LogicItemAquired()).Count()); } return(Instance.Logic.Where(x => setIDs.Contains(x.RandomizedItem) && x.Checked).Count()); }
public static LogicObjects.LogicEntry PairedEntry(this LogicObjects.LogicEntry entry, LogicObjects.TrackerInstance Instance, bool RandomizedItem = false) { var Pairs = Instance.EntrancePairs; int ID = (RandomizedItem) ? entry.RandomizedItem : entry.ID; if (Pairs.ContainsKey(ID) && Pairs[ID] < Instance.Logic.Count) { return(Instance.Logic[Pairs[ID]]); } return(null); }
public static bool ItemBelongsToMe(this LogicObjects.LogicEntry entry) { if (!LogicObjects.MainTrackerInstance.Options.IsMultiWorld) { return(true); } if (entry.IsEntrance()) { return(true); } return(entry.PlayerData.ItemBelongedToPlayer == -1 || entry.PlayerData.ItemBelongedToPlayer == LogicObjects.MainTrackerInstance.Options.MyPlayerID); }
public static int ProgressiveItemsNeeded(this LogicObjects.LogicEntry entry, LogicObjects.TrackerInstance Instance, bool IndexValue = false) { var set = entry.ProgressiveItemSet(Instance); if (set == null) { return(0); } int offset = (IndexValue) ? 0 : 1; return(set.IndexOf(entry) + offset); }
public static bool UserCreatedFakeItem(this LogicObjects.LogicEntry entry, List <LogicObjects.LogicEntry> Logic) { int lastRealItem = -1; foreach (var i in Logic) { if (!i.IsFake) { lastRealItem = i.ID; } } return(entry.ID > lastRealItem); }
public static LogicObjects.LogicEntry RandomizedEntry(this LogicObjects.LogicEntry entry, LogicObjects.TrackerInstance Instance, bool ReturnJunkAsItem = false) { if (ReturnJunkAsItem && entry.HasRandomItem(false) && !entry.HasRandomItem(true)) { return(new LogicObjects.LogicEntry { ID = -1, DictionaryName = "Junk", DisplayName = "Junk", LocationName = "Junk", ItemName = "Junk" }); } if (!entry.HasRandomItem(true) || entry.RandomizedItem >= Instance.Logic.Count) { return(null); } return(Instance.Logic[entry.RandomizedItem]); }
public static LogicObjects.LogicEntry ClearRandomizedDungeonInThisArea(this LogicObjects.LogicEntry entry, LogicObjects.TrackerInstance Instance) { //Finds the area clear related to the dungeon that is randomized to the current area. //If woodfall entrance leads to snowhead and you pass this function woodfall clear it will return snowhead clear. if (!Instance.EntranceAreaDic.ContainsKey(entry.ID)) { return(null); } var templeEntrance = Instance.EntranceAreaDic[entry.ID]; //What is the dungeon entrance in this area var RandTempleEntrance = Instance.Logic[templeEntrance].RandomizedItem; //What dungeon does this areas dungeon entrance lead to var RandAreaClear = RandTempleEntrance < 0 ? -1 : Instance.EntranceAreaDic.FirstOrDefault(x => x.Value == RandTempleEntrance).Key; //What is the Area clear Value For That Dungeon var RandClearLogic = RandAreaClear == -1 ? null : Instance.Logic[RandAreaClear]; //Get the full logic data for the area clear that we want to check the availability of. return(RandClearLogic); }
public static bool Unrandomized(this LogicObjects.LogicEntry entry, int UnRand0Manual1Either2 = 0) { if (UnRand0Manual1Either2 == 0) { return(entry.RandomizedState() == 1); } if (UnRand0Manual1Either2 == 1) { return(entry.RandomizedState() == 2); } if (UnRand0Manual1Either2 == 2) { return(entry.RandomizedState() == 1 || entry.RandomizedState() == 2); } return(false); }
private bool MarkManualItem(object sender, EventArgs e) { var CheckedObject = ManualSelect[0]; LogicObjects.LogicEntry SelectedItem = new LogicObjects.LogicEntry { ID = -1 }; if (sender == LBItemSelect) { if (!(LBItemSelect.SelectedItem is LogicObjects.LogicEntry)) { return(false); } SelectedItem = LBItemSelect.SelectedItem as LogicObjects.LogicEntry; } CheckedObject.RandomizedItem = SelectedItem.ID; return(true); }
public static LogicObjects.ItemUnlockData FindRequirements(LogicObjects.LogicEntry Item, List <LogicObjects.LogicEntry> logic) { List <int> ImportantItems = new List <int>(); List <LogicObjects.PlaythroughItem> playthrough = new List <LogicObjects.PlaythroughItem>(); var LogicCopy = Utility.CloneLogicList(logic); foreach (var i in LogicCopy) { if (i.Unrandomized()) { i.IsFake = true; } } var ItemCopy = LogicCopy[Item.ID]; LogicEditing.ForceFreshCalculation(LogicCopy); foreach (var i in LogicCopy) { ImportantItems.Add(i.ID); if (i.IsFake) { i.SpoilerRandom = i.ID; } } PlaythroughGenerator.UnlockAllFake(LogicCopy, ImportantItems, 0, playthrough); List <int> UsedItems = new List <int>(); bool isAvailable = (LogicEditing.RequirementsMet(ItemCopy.Required, LogicCopy, UsedItems) && LogicEditing.CondtionalsMet(ItemCopy.Conditionals, LogicCopy, UsedItems)); if (!isAvailable) { return(new LogicObjects.ItemUnlockData()); } List <int> NeededItems = Tools.ResolveFakeToRealItems(new LogicObjects.PlaythroughItem { SphereNumber = 0, Check = ItemCopy, ItemsUsed = UsedItems }, playthrough, LogicCopy); List <int> FakeItems = Tools.FindAllFakeItems(new LogicObjects.PlaythroughItem { SphereNumber = 0, Check = ItemCopy, ItemsUsed = UsedItems }, playthrough, LogicCopy); NeededItems = NeededItems.Distinct().ToList(); return(new LogicObjects.ItemUnlockData { playthrough = playthrough, FakeItems = FakeItems, ResolvedRealItems = NeededItems, UsedItems = UsedItems }); }
public static void MarkAreaClearAsEntry(LogicObjects.TrackerInstance instance) { var EntAreaDict = instance.EntranceAreaDic; LogicObjects.LogicEntry Default = new LogicObjects.LogicEntry(); var WoodFallClear = instance.Logic.Find(x => x.DictionaryName == "Woodfall clear") ?? Default; var SnowheadClear = instance.Logic.Find(x => x.DictionaryName == "Snowhead clear") ?? Default; var GreatBayClear = instance.Logic.Find(x => x.DictionaryName == "Great Bay clear") ?? Default; var IkanaClear = instance.Logic.Find(x => x.DictionaryName == "Ikana clear") ?? Default; WoodFallClear.IsFake = false; SnowheadClear.IsFake = false; GreatBayClear.IsFake = false; IkanaClear.IsFake = false; //Set the area clear name to their defualt WoodFallClear.LocationName = "Defeat Odolwa"; WoodFallClear.ItemName = "Odolwas Remians"; SnowheadClear.LocationName = "Defeat Goht"; SnowheadClear.ItemName = "Gohts Remians"; GreatBayClear.LocationName = "Defeat Gyrog"; GreatBayClear.ItemName = "Gyrogs Remians"; IkanaClear.LocationName = "Defeat Twinmold"; IkanaClear.ItemName = "Twinmolds Remians"; //Find the name of the randomized area clear var newWoodfallLocation = (WoodFallClear.ClearRandomizedDungeonInThisArea(instance) ?? WoodFallClear).LocationName; var newWoodfallItem = (WoodFallClear.ClearRandomizedDungeonInThisArea(instance) ?? WoodFallClear).ItemName; var newSnowheadLocation = (SnowheadClear.ClearRandomizedDungeonInThisArea(instance) ?? SnowheadClear).LocationName; var newSnowheadItem = (SnowheadClear.ClearRandomizedDungeonInThisArea(instance) ?? SnowheadClear).ItemName; var newGreatBayLocation = (GreatBayClear.ClearRandomizedDungeonInThisArea(instance) ?? GreatBayClear).LocationName; var newGreatBayItem = (GreatBayClear.ClearRandomizedDungeonInThisArea(instance) ?? GreatBayClear).ItemName; var newIkanaLocation = (IkanaClear.ClearRandomizedDungeonInThisArea(instance) ?? IkanaClear).LocationName; var newIkanaItem = (IkanaClear.ClearRandomizedDungeonInThisArea(instance) ?? IkanaClear).ItemName; //Set the randomized area clear name to the original area clear WoodFallClear.LocationName = newWoodfallLocation; WoodFallClear.ItemName = newWoodfallItem; SnowheadClear.LocationName = newSnowheadLocation; SnowheadClear.ItemName = newSnowheadItem; GreatBayClear.LocationName = newGreatBayLocation; GreatBayClear.ItemName = newGreatBayItem; IkanaClear.LocationName = newIkanaLocation; IkanaClear.ItemName = newIkanaItem; }
private void BtnNewItem_Click(object sender, EventArgs e) { EditorInstance.UnsavedChanges = true; Tools.SaveState(EditorInstance); string name = Interaction.InputBox("Input New Item Name", "New Item", ""); if (name == "") { return; } GoBackList.Add(currentEntry.ID); LogicObjects.LogicEntry newEntry = new LogicObjects.LogicEntry { ID = EditorInstance.Logic.Count, DictionaryName = name, IsFake = true, Required = null, Conditionals = null, AvailableOn = 0, NeededBy = 0 }; EditorInstance.Logic.Add(newEntry); FormatForm(); nudIndex.Value = (EditorInstance.Logic.Count - 1); WriteCurentItem(EditorInstance.Logic.Count - 1); }
public static bool ItemUseable(this LogicObjects.LogicEntry entry, LogicObjects.TrackerInstance Instance, List <int> usedItems = null) { if (usedItems == null) { usedItems = new List <int>(); } var Set = entry.ProgressiveItemSet(Instance); if (Set == null) { return(NonProgressiveItemUseable()); } var AquiredSet = Set.Where(x => x.LogicItemAquired()).ToList(); var ItemsNeeded = entry.ProgressiveItemsNeeded(Instance); if (AquiredSet.Count() >= ItemsNeeded) { for (var i = 0; i < ItemsNeeded; i++) { usedItems.Add(AquiredSet[i].ID); } return(true); } return(false); bool NonProgressiveItemUseable() { if (entry.LogicItemAquired()) { usedItems.Add(entry.ID); return(true); } else { return(false); } } }
public static void WhatUnlockedThis() { var Requirements = Tools.FindRequirements(Tools.CurrentSelectedItem, LogicObjects.MainTrackerInstance.Logic).ResolvedRealItems; var FakeItems = Tools.FindRequirements(Tools.CurrentSelectedItem, LogicObjects.MainTrackerInstance.Logic).FakeItems; var Playthrough = Tools.FindRequirements(Tools.CurrentSelectedItem, LogicObjects.MainTrackerInstance.Logic).playthrough; var ItemsUsed = Tools.FindRequirements(Tools.CurrentSelectedItem, LogicObjects.MainTrackerInstance.Logic).UsedItems; string message = "Logic Entries used:\n"; if (Requirements.Count == 0) { MessageBox.Show("Nothing is needed to check this location.", Tools.CurrentSelectedItem.LocationName + " Was Unlocked with:"); return; } foreach (var i in ItemsUsed) { message = message + (LogicObjects.MainTrackerInstance.Logic[i].ItemName ?? LogicObjects.MainTrackerInstance.Logic[i].DictionaryName) + "\n"; } message = message + "\nReal items used:\n"; foreach (var i in Requirements) { message = message + LogicObjects.MainTrackerInstance.Logic[i].ItemName + "\n"; } message = message + "\nFake Items Breakdown:\n"; foreach (var i in FakeItems.OrderBy(x => LogicObjects.MainTrackerInstance.Logic[x].DictionaryName)) { var ItemInPlaythrough = Playthrough.Find(x => x.Check.ID == i) ?? new LogicObjects.PlaythroughItem { ItemsUsed = new List <int>() }; message = message + LogicObjects.MainTrackerInstance.Logic[i].DictionaryName + "\n"; message = message + WhatUnlockedThisDetailed(i, "", Playthrough, ItemInPlaythrough.ItemsUsed); } InformationDisplay Display = new InformationDisplay(); Display.Text = Tools.CurrentSelectedItem.LocationName + " Was Unlocked with:"; InformationDisplay.Playthrough = message.Split(new[] { "\n" }, StringSplitOptions.None).ToList(); Display.DebugFunction = 4; Display.Show(); Tools.CurrentSelectedItem = new LogicObjects.LogicEntry(); }
private void button2_Click(object sender, EventArgs e) { MiscSingleItemSelect Selector = new MiscSingleItemSelect { Text = "Go to item", ListContent = LogicObjects.MainTrackerInstance.Logic, Display = 6 }; Selector.ShowDialog(); if (Selector.DialogResult != DialogResult.OK) { return; } //GoBackList.Add(currentEntry.ID); try { GoBackList.Add(entry); entry = Selector.SelectedObject; WriteEntry(); } catch { } }
public bool NeedsDialogBox(LogicObjects.LogicEntry entry) { return(!(entry.Checked || entry.SpoilerRandom > -2 || entry.RandomizedItem > -2 || entry.RandomizedState() == 2)); }
public static bool EntranceConnectionValid(LogicObjects.LogicEntry x, LogicObjects.LogicEntry ExitToCheck, LogicObjects.TrackerInstance lt) { return(x.Available && !x.IsFake && !x.IsWarpSong() && (x.IsEntrance() || lt.Options.IncludeItemLocations)); }