public void InsertAfter(PuzzleItem item, int slot) { if (DeleteAtEnd) { if (PuzzleItems.Count >= gridSize) { if (OverloadDumpSite != null) { OverloadDumpSite.InsertBefore(PuzzleItems[gridSize - 1], 0); } PuzzleItems.Remove(PuzzleItems[gridSize - 1]); } if (PuzzleItems.Count >= gridSize) { try { PuzzleItems.RemoveAt(gridSize); foreach (PuzzleItem anItem in aListOfSelectedItems) { if (!PuzzleItems.Contains(anItem)) { aListOfSelectedItems.Remove(anItem); } } } catch { /*happens when window is resized (sometimes)*/ } } } PuzzleItems.Insert(slot + 1, item); Invalidate(); }
} // end of function ClearThumbnail #endregion #region filters public static void LoadFilters() { List<PuzzleItem> allPuzzleItems = new List<PuzzleItem>(); string[] filePaths = Directory.GetFiles(itemDirectory, "*.bee"); string[] temp; foreach (string path in filePaths) { string[] filecontents = File.ReadAllLines(path); string[][] individualItemDefinitions = Global.FindSubValues(filecontents, "Item"); foreach (string[] definition in individualItemDefinitions) { PuzzleItem aPuzzleItem = new PuzzleItem(definition); foreach (string f in aPuzzleItem.Filters) { List<string> filter; Filters.TryGetValue(f, out filter); if (filter == null) { filter = new List<string>(); Filters.Add(f, filter); } if (!filter.Contains(aPuzzleItem.TypeName)) filter.Add(aPuzzleItem.TypeName); } } } // next }
protected override void OnMouseDown(MouseEventArgs e) { PuzzleItem aPuzzleItem = getItemAt(new Point(e.X, e.Y)); if (aPuzzleItem == null) { if (UnSelectItems()) { Invalidate(); } } else { //if (!Control_Press) // UnSelectItems(); if (aListOfSelectedItems.Contains(aPuzzleItem)) { //aListOfSelectedItems.Remove(aPuzzleItem); //Invalidate(); } else { UnSelectItems(); AddToSelected(aPuzzleItem); Invalidate(); } } base.OnMouseDown(e); }
private void panelItemHolderPalette_MouseMove(object sender, MouseEventArgs e) { PuzzleItem aPuzzleItem = panelItemHolderPalette.GetSelectedItem(); if (aPuzzleItem != null) { if (e.Button == MouseButtons.Left) { MarkAsSender(panelItemHolderPalette); aPuzzleItem = aPuzzleItem.Clone(); DoDragDrop(aPuzzleItem, DragDropEffects.Move); } } int x = e.X, y = e.Y; aPuzzleItem = panelItemHolderPalette.getItemAt(new Point(x, y)); if (aPuzzleItem != null) { if (aPuzzleItem != oldpitem) { //toolTip1.Show(aPuzzleItem.Name_ToolTip, panelItemHolderPalette, new Point(paletteSelectedItemLabel.Left - panelItemHolderPalette.Left, paletteSelectedItemLabel.Top - panelItemHolderPalette.Top + 32), 2000); toolTip1.Show(aPuzzleItem.Name_ToolTip, panelItemHolderPalette, new Point(paletteSelectedItemLabel.Left - panelItemHolderPalette.Left - 9, paletteSelectedItemLabel.Top - panelItemHolderPalette.Top + 32 + 40), 2000); oldpitem = aPuzzleItem; } } else { toolTip1.RemoveAll(); oldpitem = null; } panelItemHolderBucket_Focus(); }
private void panelItemHolderBucket_MouseMove(object sender, MouseEventArgs e) { //PuzzleItem aPuzzleItem = sender as PuzzleItem; PuzzleItem aPuzzleItem = panelItemHolderBucket.GetSelectedItem(); if (aPuzzleItem != null) { if (e.Button == MouseButtons.Left) { MarkAsSender(panelItemHolderBucket); aPuzzleItem = aPuzzleItem.Clone(); DoDragDrop(aPuzzleItem, DragDropEffects.Copy); } } int x = e.X, y = e.Y; aPuzzleItem = panelItemHolderBucket.getItemAt(new Point(x, y)); if (aPuzzleItem != null) { if (aPuzzleItem != oldpitem) { //toolTip1.Show(aPuzzleItem.Name_ToolTip, panelItemHolderBucket, new Point(0, panelItemHolderBucket.Height-4), 2000); toolTip1.Show(aPuzzleItem.Name_ToolTip, panelItemHolderBucket, new Point(0, panelItemHolderBucket.GridLength * 65 + 10), 2000); oldpitem = aPuzzleItem; } } else { toolTip1.RemoveAll(); oldpitem = null; } }
public void ShowItem(Point aPoint, PuzzleItem aPuzzleItem) { Show(); panelItemHolder_Visual1.PuzzleItems.Clear(); panelItemHolder_Visual1.RemoveAllFromSelected(); this.Location = aPoint; PuzzleItem aPuzzleItem2 = aPuzzleItem.Clone(); aPuzzleItem2.SubcatagoryIndex = 0; for (int i = 0; i <= aPuzzleItem.SubcatagoryIndexMax; i++) { panelItemHolder_Visual1.PuzzleItems.Add(aPuzzleItem2.Clone()); aPuzzleItem2.ToggleSubcatagory(); } panelItemHolder_Visual1.AddToSelected(aPuzzleItem.SubcatagoryIndex); panelItemHolder_Visual1.Width = 337 - (4 - aPuzzleItem.SubcatagoryIndexMax) * 64; UpdateProperties(aPuzzleItem2); }
private void panelItemHolderBucket_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right && panelItemHolderBucket.getItemAt(e.Location) == _itemForContextMenu) { PuzzleItem aPuzzleItem = panelItemHolderBucket.getItemAt(e.Location); aCustomContextMenu.ShowItem(MousePosition, aPuzzleItem, panelItemHolderBucket.getOffsetOnPoint(e.Location)); } }
private void panelItemHolderRecentlyUsed_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { PuzzleItem aPuzzleItem = panelItemHolderRecentlyUsed.getItemAt(e.Location); aCustomContextMenu.ShowItem(MousePosition, aPuzzleItem, panelItemHolderRecentlyUsed.getOffsetOnPoint(e.Location)); } }
private void panelItemHolderPalette_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { PuzzleItem aPuzzleItem = panelItemHolderPalette.getItemAt(e.Location); Point aPoint = panelItemHolderPalette.getOffsetOnPoint(e.Location); aCustomContextMenu.ShowItem(MousePosition, aPuzzleItem, new Point(aPoint.X + 6, aPoint.Y + 6), true); } }
//private string name; public override bool Equals(object obj) { if (obj.GetType() != typeof(PuzzleItem)) { return(false); } PuzzleItem temp = (PuzzleItem)obj; return(temp.style == style && TypeName == temp.TypeName && temp.subcatagoryIndex == subcatagoryIndex); }
public void ShowItem(Point aPoint, PuzzleItem aPuzzleItem, Point Offset, bool ShouldChangeActualItem) { if (aPuzzleItem != null) { if (!ShouldChangeActualItem) { aPuzzleItem = aPuzzleItem.Clone(); ThePuzzleItem = null; } else { ThePuzzleItem = aPuzzleItem; } ShowItem(aPoint, aPuzzleItem); aPoint = MousePosition; aPoint.X = aPoint.X - Offset.X - (aPuzzleItem.SubcatagoryIndex * 65); aPoint.Y = aPoint.Y - Offset.Y; if (aPoint.X < 0) { aPoint.X = 0; } if (aPoint.Y < 0) { aPoint.Y = 0; } //check to make sure it will appear on screen int screenHeight = Screen.FromControl(this).Bounds.Height; int screenWidth = Screen.FromControl(this).Bounds.Width; //MessageBox.Show(this.Location.X + " " + this.Location.Y); this.TopMost = false; Point aMousePoint = System.Windows.Forms.Cursor.Position; if (aPoint.X + Width > screenWidth || aPoint.X + Width < 0) { aPoint.X = screenWidth - Width; this.TopMost = true; } if (aPoint.Y + Height > screenHeight || aPoint.Y + Height < 0) { aPoint.Y = screenHeight - Height; this.TopMost = true; } aMousePoint = new Point(aPoint.X + Offset.X + aPuzzleItem.SubcatagoryIndex * 66, aPoint.Y + Offset.Y); System.Windows.Forms.Cursor.Position = aMousePoint; Location = aPoint; } }
private void panelItemHolderRecentlyUsed_DragDrop(object sender, DragEventArgs e) { if (!e.Data.GetDataPresent(typeof(PuzzleItem))) { return; } if (lastClickedPanel.Equals(panelItemHolderRecentlyUsed)) { panelItemHolderRecentlyUsed.RemoveItem(panelItemHolderRecentlyUsed.GetSelectedItem()); } PuzzleItem aPuzzleItem = (PuzzleItem)e.Data.GetData(typeof(PuzzleItem)); panelItemHolderRecentlyUsed.InsertBefore(aPuzzleItem, 0); panelItemHolderRecentlyUsed.RemoveAllFromSelected(); panelItemHolderRecentlyUsed.AddToSelected(aPuzzleItem); }
private void panelItemHolderRecentlyUsed_MouseMove(object sender, MouseEventArgs e) { PuzzleItem aPuzzleItem = panelItemHolderRecentlyUsed.GetSelectedItem(); if (aPuzzleItem != null) { if (e.Button == MouseButtons.Left) { MarkAsSender(panelItemHolderRecentlyUsed); aPuzzleItem = aPuzzleItem.Clone(); DoDragDrop(aPuzzleItem, DragDropEffects.Copy); } } panelItemHolderBucket_Focus(); }
private void panelItemHolderPalette_DragDrop(object sender, DragEventArgs e) { //todoFIXED: stop panel crash when something other than a PuzzleItem is dropped here if (!e.Data.GetDataPresent(typeof(PuzzleItem))) { return; } //todoFIXED: get them to drop into the right spot.... problem is that when something is dropped on the origin for the panel, it isn't the origin in the e variable //looks like the origin is 8,30...no idea why, maybe its different for other operating systems, or settings. //panelItemHolderPalette.getItemAt(new Point(e.X, e.Y)); Point aPoint = new Point(e.X - this.Location.X - panelItemHolderPalette.Location.X - 8, e.Y - this.Location.Y - panelItemHolderPalette.Location.Y - 30); //if (lastClickedPanel!=null&&lastClickedPanel.Equals(panelItemHolderPalette)) PuzzleItem aPuzzleItem = (PuzzleItem)e.Data.GetData(typeof(PuzzleItem)); int numcheck = panelItemHolderPalette.GetNumberOfItems(); if (lastClickedPanel.Equals(panelItemHolderPalette)) { panelItemHolderPalette.RemoveItem(panelItemHolderPalette.GetSelectedItem()); //special case if the palette is full, this caused the last item to bump off //if the panel was full //if (numcheck >= 32) //{ // //but now has less // if (panelItemHolderPalette.GetNumberOfItems() == 31) // { // //then grab the first item from the recently used bucket and toss it back in here // panelItemHolderPalette.InsertAfter(panelItemHolderRecentlyUsed.getItemNumber(0), 30); // panelItemHolderRecentlyUsed.RemoveItemNumber(0); // } //} } panelItemHolderPalette.DropItemOnPoint(aPuzzleItem, aPoint); panelItemHolderPalette.RemoveAllFromSelected(); panelItemHolderPalette.AddToSelected(aPuzzleItem); paletteSelectedItemLabel.Text = panelItemHolderPalette.GetSelectedItemName(); //Graphics gr = panelItemHolderPalette.CreateGraphics(); //Pen aPen = new Pen(Color.Blue); //gr.DrawLine(aPen, new Point(e.X, e.Y), new Point(e.X, e.Y-20)); }
private void UpdateProperties(PuzzleItem aPuzzleItem) { string NA = "N/A"; if (aPuzzleItem != null && panelItemHolder_Visual1.GetSelectedItem() != null) { label5.Text = aPuzzleItem.TypeName; label6.Text = aPuzzleItem.Name_ToolTip; label7.Text = aPuzzleItem.Author; itemDescriptionTextBox.Text = aPuzzleItem.Description; if (CurrentStyle != null) { label11.Text = CurrentStyle.Name; label12.Text = CurrentStyle.Author; styleDescriptionTextBox.Text = CurrentStyle.Comment; } else { label11.Text = NA; label12.Text = NA; styleDescriptionTextBox.Text = NA; } //label11.Text = } else { label5.Text = NA; label6.Text = NA; label7.Text = NA; itemDescriptionTextBox.Text = NA; if (CurrentStyle != null) { label11.Text = CurrentStyle.Name; label12.Text = CurrentStyle.Author; styleDescriptionTextBox.Text = CurrentStyle.Comment; } else { label11.Text = NA; label12.Text = NA; styleDescriptionTextBox.Text = NA; } } itemDescriptionTextBox.Select(0, 0); styleDescriptionTextBox.Select(0, 0); }
public void DropItemOnPoint(PuzzleItem aPuzzleItem, Point aPoint) { //todoFIXED: make this precise int i = getItemSlotBetween(aPoint); //if (i >= GetSelectedItemIndex()) // i--; if (i >= 0) { InsertBefore(aPuzzleItem, i); } else { InsertAfter(aPuzzleItem, PuzzleItems.Count - 1); } dragging_insert_slot = -2; }
/// <summary> /// Creates a new PuzzleItem based off of a given item definition, and a specified subcatagory /// but using the existing image /// </summary> /// <param name="itemDefinition">Item definitions can be taken directly from the /scripts/editoritems.txt</param> /// <param name="subcatagory"></param> /// <param name="image"></param> public PuzzleItem(PuzzleItem p) { this.fileName = p.fileName; this.TypeName = p.TypeName; this.Author = p.Author; this.Description = p.Description; // This object is shared with the original item this.ItemDefinition = p.ItemDefinition; // shallow clone // The subitems need to be different objects so we can change the image in a copy. // But the objects inside the subitem are the same objects until we change them. this.SubItems = new ArrayList(); foreach (SubItem s in p.SubItems) { this.SubItems.Add(s.Clone()); } this.subcatagoryIndex = p.subcatagoryIndex; }
public static void PopulateWithAllItems(PanelItemHolder holder) { string[] filePaths = Directory.GetFiles(itemDirectory, "*.bee"); string[] temp; foreach (string path in filePaths) { if (path.EndsWith(individualItemExtension)) { temp = path.Split('\\'); PuzzleItem aPuzzleItem = new PuzzleItem(temp[temp.Length - 1].Replace(individualItemExtension, "")); //get each subcatagory for (int i = 0; i <= aPuzzleItem.SubcatagoryIndexMax; i++) { holder.InsertBefore(aPuzzleItem.Clone(), 0); aPuzzleItem.ToggleSubcatagory(); } } } }
public void ShowItem(Point aPoint, PuzzleItem aPuzzleItem, Point Offset, bool ShouldChangeActualItem) { if (aPuzzleItem != null) { if (!ShouldChangeActualItem) { aPuzzleItem = aPuzzleItem.Clone(); ThePuzzleItem = null; } else ThePuzzleItem = aPuzzleItem; ShowItem(aPoint, aPuzzleItem); aPoint = MousePosition; aPoint.X = aPoint.X - Offset.X - (aPuzzleItem.SubcatagoryIndex * 65); aPoint.Y = aPoint.Y - Offset.Y; if (aPoint.X < 0) aPoint.X = 0; if (aPoint.Y < 0) aPoint.Y = 0; //check to make sure it will appear on screen int screenHeight = Screen.FromControl(this).Bounds.Height; int screenWidth = Screen.FromControl(this).Bounds.Width; //MessageBox.Show(this.Location.X + " " + this.Location.Y); this.TopMost = false; Point aMousePoint = System.Windows.Forms.Cursor.Position; if (aPoint.X + Width > screenWidth || aPoint.X + Width<0) { aPoint.X = screenWidth - Width; this.TopMost = true; } if (aPoint.Y + Height > screenHeight || aPoint.Y + Height<0) { aPoint.Y = screenHeight - Height; this.TopMost = true; } aMousePoint = new Point(aPoint.X + Offset.X + aPuzzleItem.SubcatagoryIndex * 66, aPoint.Y + Offset.Y); System.Windows.Forms.Cursor.Position = aMousePoint; Location = aPoint; } }
public void InsertBefore(PuzzleItem item, int slot) { if (slot >= 32) { if (OverloadDumpSite != null) { OverloadDumpSite.InsertBefore(item, 0); } } else { if (DeleteAtEnd) { if (PuzzleItems.Count >= gridSize) { if (OverloadDumpSite != null) { OverloadDumpSite.InsertBefore(PuzzleItems[gridSize - 1], 0); } PuzzleItems.Remove(PuzzleItems[gridSize - 1]); } if (PuzzleItems.Count >= gridSize) { try { PuzzleItems.RemoveAt(gridSize); foreach (PuzzleItem anItem in aListOfSelectedItems) { if (!PuzzleItems.Contains(anItem)) { aListOfSelectedItems.Remove(anItem); } } } catch { /*happens when window is resized (sometimes... and things break) */ } } } PuzzleItems.Insert(slot, item);//todo: fix crash when Item dragged too deep onto the palette } Invalidate(); }
private void panelItemHolderBucket_MouseDown(object sender, MouseEventArgs e) { _itemForContextMenu = panelItemHolderBucket.getItemAt(e.Location); }
/// <summary> /// Removes the given PuzzleItem from the holders list of selected items /// </summary> /// <param name="value"></param> public virtual void RemoveFromSelected(PuzzleItem value) { aListOfSelectedItems.Remove(value); }/// <summary>
/// <summary> /// Adds the given PuzzleItem to the holders list of selected items /// </summary> /// <param name="value"></param> public virtual void AddToSelected(PuzzleItem value) { aListOfSelectedItems.Insert(0, value); }
private void UpdateProperties(PuzzleItem aPuzzleItem) { string NA = "N/A"; if (aPuzzleItem != null && panelItemHolder_Visual1.GetSelectedItem() != null) { label5.Text = aPuzzleItem.TypeName; label6.Text = aPuzzleItem.Name_ToolTip; label7.Text = aPuzzleItem.Author; itemDescriptionTextBox.Text = aPuzzleItem.Description; if (CurrentStyle != null) { label11.Text = CurrentStyle.Name; label12.Text = CurrentStyle.Author; styleDescriptionTextBox.Text = CurrentStyle.Comment; } else { label11.Text = NA; label12.Text = NA; styleDescriptionTextBox.Text = NA; } //label11.Text = } else { label5.Text = NA; label6.Text = NA; label7.Text = NA; itemDescriptionTextBox.Text = NA; if (CurrentStyle != null) { label11.Text = CurrentStyle.Name; label12.Text = CurrentStyle.Author; styleDescriptionTextBox.Text = CurrentStyle.Comment; } else { label11.Text = NA; label12.Text = NA; styleDescriptionTextBox.Text = NA; } } itemDescriptionTextBox.Select(0,0); styleDescriptionTextBox.Select(0,0); }
/// <summary> /// removes the designated item from the palette if it exists /// </summary> /// <param name="aPuzzleItem"></param> public void RemoveItem(PuzzleItem aPuzzleItem) { PuzzleItems.Remove(aPuzzleItem); aListOfSelectedItems.Remove(aPuzzleItem);//dont think this is nessesary Invalidate(); }
public void InsertBefore(PuzzleItem item, int slot) { if (slot >= 32) { if (OverloadDumpSite != null) { OverloadDumpSite.InsertBefore(item, 0); } } else { if (DeleteAtEnd) { if (PuzzleItems.Count >= gridSize) { if (OverloadDumpSite != null) { OverloadDumpSite.InsertBefore(PuzzleItems[gridSize - 1], 0); } PuzzleItems.Remove(PuzzleItems[gridSize - 1]); } if (PuzzleItems.Count >= gridSize) { try { PuzzleItems.RemoveAt(gridSize); foreach (PuzzleItem anItem in aListOfSelectedItems) { if (!PuzzleItems.Contains(anItem)) aListOfSelectedItems.Remove(anItem); } } catch { /*happens when window is resized (sometimes... and things break) */} } } PuzzleItems.Insert(slot, item);//todo: fix crash when Item dragged too deep onto the palette } Invalidate(); }
public override void RemoveFromSelected(PuzzleItem value) { HoldOffOnPainting = true; base.RemoveFromSelected(value); HoldOffOnPainting = false; }
public override void AddToSelected(PuzzleItem value) { HoldOffOnPainting = true; base.AddToSelected(value); HoldOffOnPainting = false; }
public void ShowItem(Point aPoint, PuzzleItem aPuzzleItem, Point Offset) { ShowItem(aPoint, aPuzzleItem, Offset, false); }
public string[] BuildEditorItems(List <PuzzleItem> ListOfAllItems, string StyleName) { ArrayList editorItems = new ArrayList(); string[] results; // All the items that aren't in the palette have to be done FIRST // unless we are going to remove the palette entry for (int i = 0; i < ListOfAllItems.Count; i++) { PuzzleItem aPuzzleItem = ListOfAllItems[i]; if (aPuzzleItem != null) { //check for duplicates with all previously printed items bool itemHasBeenSeen = false; for (int j = 0; j < i; j++) { if ((ListOfAllItems[j]).TypeName == aPuzzleItem.TypeName) { itemHasBeenSeen = true; break; } } //check to make sure it also wasn't on the palette if (!itemHasBeenSeen) { for (int j = 0; j < PuzzleItems.Count; j++) { if ((PuzzleItems[j]).TypeName == aPuzzleItem.TypeName) { itemHasBeenSeen = true; break; } } } //only do this if the item hasn't been used before if (!itemHasBeenSeen) { results = aPuzzleItem.GetDefinition(); editorItems.Add(results); } } } // Now do the items in the Palette for (int i = 0; i < PuzzleItems.Count; i++) { //for each item, add it PuzzleItem aPuzzleItem = PuzzleItems[i]; if (aPuzzleItem != null) { //check for duplicates with all previously printed items bool itemHasBeenSeen = false; for (int j = 0; j < i; j++) { if ((PuzzleItems[j]).TypeName == aPuzzleItem.TypeName) { itemHasBeenSeen = true; break; } } //only do this if the item hasn't been used before if (!itemHasBeenSeen) { //get all later instances of this object and combine them into one item entry ArrayList activeSubItems = new ArrayList(); ArrayList subItemLocations = new ArrayList(); for (int j = 0; j < PuzzleItems.Count; j++)//this should probably be int j = i but I'm not going to try that just yet { if ((PuzzleItems[j]).TypeName == aPuzzleItem.TypeName) { activeSubItems.Add((PuzzleItems[j]).SubcatagoryIndex); subItemLocations.Add(j); } } results = aPuzzleItem.GetDefinition((int[])activeSubItems.ToArray(typeof(int)), (int[])subItemLocations.ToArray(typeof(int))); editorItems.Add(results); } } } //insert the vbsp style definition //find the style then grab its definition and insert into the editorItems at the beginning foreach (object style in Global.ListOfStyles) { if (((VBSPStyle)style).Name == StyleName) { editorItems.Insert(0, ((VBSPStyle)style).WholeDefinition); break; } } //collapse all entries into one string[] ArrayList returnValue = new ArrayList(); string[] temp; int tabsDeep = 0; for (int i = 0; i < editorItems.Count; i++) { temp = (string[])editorItems[i]; for (int j = 0; j < temp.Length; j++) { if (temp[j].Trim() == "}") { tabsDeep--; } string tttemp = ""; for (int k = 0; k < tabsDeep; k++) { tttemp += "\t"; } tttemp += temp[j]; returnValue.Add(tttemp); if (temp[j].Trim() == "{") { tabsDeep++; } } } returnValue.Add("}"); //iterate through and find subdefinitions with palette positions not on the palette int indexOfPaletteOpening = -1; int indexOfPaletteEnding = -1; for (int i = 0; i < returnValue.Count; i++) { string line = (string)returnValue[i]; if (line.Trim() == "\"Palette\"") { indexOfPaletteOpening = i; } else if (line.Contains(Global.NotOnPaletteEntry)) { //found an entry to take out indexOfPaletteEnding = -1; for (int j = 0; indexOfPaletteEnding == -1; j++) { if (((string)returnValue[i + j]).Trim().StartsWith("}")) { indexOfPaletteEnding = i + j; } } //now we have the beginning and ending points... either clear this data out or comment it out... I'll comment for now for (int j = indexOfPaletteOpening; j <= indexOfPaletteEnding; j++) { returnValue[j] = ((string)returnValue[j]).Insert(0, "//"); //inserting comments } i = indexOfPaletteEnding; //new place to continue searching (saves a little time) } } return((string[])returnValue.ToArray(typeof(string))); }
public static void LoadItemStyles() { // Item collections can define new styles based on base styles from the .style files // So go through each item collection and create the new styles string[] filePaths = Directory.GetFiles(Global.ItemDirectory, "*.beec"); foreach (string path in filePaths) { string[] filecontents = File.ReadAllLines(path); //Parse the definition for style info ArrayList styleDefinition = new ArrayList(); bool stylish = false; foreach (string line in filecontents) { if (line.Contains("@EndStyle")) { stylish = false; break;//take out the break if you want the whole file to be parsed for styleinfo } if (stylish) styleDefinition.Add(line); if (line.Contains("@Style")) stylish = true; } string[] StyleDefinition = (string[])styleDefinition.ToArray(typeof(string)); //take out the comments for (int i = 0; i < StyleDefinition.Length; i++) { if (StyleDefinition[i].Trim().StartsWith("//")) StyleDefinition[i] = StyleDefinition[i].Trim().Substring(2, StyleDefinition[i].Trim().Length - 2); } //find specific details from the style string styleName = Global.FindValue(StyleDefinition, "Style"); string baseStyleName = Global.FindValue(StyleDefinition, "Base"); string author = Global.FindValue(StyleDefinition, "Author"); string comment = Global.FindValue(StyleDefinition, "Comment"); if (styleName == null) { if (baseStyleName != null) styleName = baseStyleName; else styleName = "Clean"; } // if it's a new style... VBSPStyle thisStyle = GetStyle(styleName); if (thisStyle == null && baseStyleName != styleName) { // ...based on an existing style... VBSPStyle baseStyle = GetStyle(baseStyleName); if (baseStyle != null) { // ...then add it. thisStyle = new VBSPStyle(baseStyle.WholeDefinition); thisStyle.Name = styleName; thisStyle.Author = author; thisStyle.Comment = comment; thisStyle.Base = baseStyleName; ListOfStyles.Add(thisStyle); } } if (thisStyle == null) continue; /* // make a list of the styles available for each item type ItemTypeStyles = new Dictionary<string, List<string>>(); foreach (string s in filecontents) { string line = s.Trim(); //make sure this whole line is long enough to even have a property this long if (line.Length >= 10) { if (line.Substring(1, 5).Equals("Type\"")) { string typeName = line.Substring(4 + 2).Trim(); if (!ItemTypeStyles.ContainsKey(typeName)) ItemTypeStyles.Add(typeName, new List<string>()); ItemTypeStyles[typeName].Add(typeName); } } } */ string[][] individualItemDefinitions = Global.FindSubValues(filecontents, "Item"); foreach (string[] definition in individualItemDefinitions) { PuzzleItem aPuzzleItem = new PuzzleItem(definition); aPuzzleItem.style = thisStyle; thisStyle.BaseItems.Add(aPuzzleItem); //don't need subcategories yet } } // next }
public void InsertAfter(PuzzleItem item, int slot) { if (DeleteAtEnd) { if (PuzzleItems.Count >= gridSize) { if (OverloadDumpSite != null) { OverloadDumpSite.InsertBefore(PuzzleItems[gridSize - 1], 0); } PuzzleItems.Remove(PuzzleItems[gridSize - 1]); } if (PuzzleItems.Count >= gridSize) { try { PuzzleItems.RemoveAt(gridSize); foreach (PuzzleItem anItem in aListOfSelectedItems) { if (!PuzzleItems.Contains(anItem)) aListOfSelectedItems.Remove(anItem); } } catch { /*happens when window is resized (sometimes)*/} } } PuzzleItems.Insert(slot + 1, item); Invalidate(); }
public PuzzleItem getItemNumber(int value) { PuzzleItem aPuzzleItem = PuzzleItems[value]; return(aPuzzleItem.Clone()); }
public void DropItemOnPoint(PuzzleItem aPuzzleItem, Point aPoint) { //todoFIXED: make this precise int i = getItemSlotBetween(aPoint); //if (i >= GetSelectedItemIndex()) // i--; if (i >= 0) InsertBefore(aPuzzleItem, i); else InsertAfter(aPuzzleItem, PuzzleItems.Count - 1); dragging_insert_slot = -2; }