void MissingTexturesForm_Load(object sender, EventArgs e) { // Populate the list TextureList.Items.Clear(); foreach (var item in _missingTextures) { var listItem = new TextureListItem(item.Key, item.Value); TextureList.AddItemAndReselect(listItem); } }
/// <summary> /// The method to load the terrain information (icons and string) /// </summary> /// <param name="type1"></param> /// <param name="type2"></param> /// <param name="textureOrGrass">The path to either the textures or the grass</param> public void Initialize(string type1, string type2, string textureOrGrass) { string str = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Neverwinter Nights 2\\NWN2Toolset\\"); TwoDAColumn column = TwoDAManager.Instance.Get(type1).Columns[type2]; for (int j = 0; j < column.Count; j++) { if (column.IsPopulatedValue(j)) { Bitmap bitmap3 = null; string str1 = OEIShared.IO.ResourceManager.Instance.BaseDirectory + "/NWN2Toolset/" + textureOrGrass + "/" + column[j] + ".bmp"; string str2 = OEIShared.IO.ResourceManager.Instance.BaseDirectory + "/NWN2Toolset_X1/" + textureOrGrass + "/" + column[j] + ".bmp"; string str3 = OEIShared.IO.ResourceManager.Instance.BaseDirectory + "/NWN2Toolset_X2/" + textureOrGrass + "/" + column[j] + ".bmp"; string strToUse = Path.Combine(str + type1, column[j] + ".bmp"); if (!File.Exists(strToUse)) { strToUse = str3; } if (!File.Exists(strToUse)) { strToUse = str2; } if (!File.Exists(strToUse)) { strToUse = str1; } try { Bitmap bitmap4 = new Bitmap(strToUse); bitmap3 = bitmap4.Clone() as Bitmap; bitmap4.Dispose(); } catch (Exception) { MessageBox.Show("Error Terrain Icon Not Found"); } TextureListItem item2 = new TextureListItem(bitmap3, column[j], new TwoDAReference("terrainmaterials", "STR_REF", true, j)); list.ItemHeight = bitmap3.Height; list.Items.Add(item2); } } if (list.Items.Count > 0) { list.SelectedItem = list.Items[0]; } }
/// <summary> /// When the selection of the grass texture is changed /// It records the grass textures selected, and makes sure that only up to 3 grass textures can be selected at any one time /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GrassSelection(object sender, EventArgs e) { try { if (this.list.SelectedItems.Count > 3) { /* * We go through every item in the grass texture list and check whether it is contained in the * selected textures */ LinkedList <String> selectedTextures = new LinkedList <String>(this.selectedTextures); for (int i = 0; i < this.list.SelectedIndices.Count; i++) { // bool flag = false; TextureListItem item = this.list.Items[this.list.SelectedIndices[i]] as TextureListItem; /* * for (int j = 0; j < this.numSelected; j++) * { * if (this.selectedTextures[j] == item.ToString()) * { * flag = true; * break; * } * } */ if (!selectedTextures.Contains(item.ToString())) { this.list.SetSelected(this.list.SelectedIndices[i], false); } } } else { string str = ""; for (int k = 0; k < this.list.SelectedItems.Count; k++) { TextureListItem item2 = this.list.SelectedItems[k] as TextureListItem; str = str + item2.ToString() + ", "; this.selectedTextures[k] = item2.ToString(); } this.numSelected = this.list.SelectedItems.Count; } } catch (Exception ex) { Console.WriteLine(ex); } }
/// <summary> /// The method called when draw is invoked, here used to ensure that both the images and the text is properly formatted /// </summary> /// <param name="obj"></param> /// <param name="args1"></param> private void draw(object obj, DrawItemEventArgs args1) { args1.DrawBackground(); if (!CommonUtils.DesignMode) { TextureListItem item = this.list.Items[args1.Index] as TextureListItem; if (item.Image != null) { Rectangle imageRec = new Rectangle(args1.Bounds.Left + 2, args1.Bounds.Top + 2, 0x40, 0x40); args1.Graphics.DrawImage(item.Image, imageRec); } Rectangle stringRec = new Rectangle(args1.Bounds.Left + 0x44, args1.Bounds.Bottom - 0x10, args1.Bounds.Width - 0x45, args1.Bounds.Height); args1.Graphics.DrawString(item.Text, this.Font, SystemBrushes.WindowText, stringRec); args1.DrawFocusRectangle(); } }
/// <summary> /// The method to load the terrain information (icons and string) /// </summary> /// <param name="type1"></param> /// <param name="type2"></param> /// <param name="textureOrGrass">The path to either the textures or the grass</param> public void Initialize(string type1, string type2,string textureOrGrass) { string str = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Neverwinter Nights 2\\NWN2Toolset\\"); TwoDAColumn column = TwoDAManager.Instance.Get(type1).Columns[type2]; for (int j = 0; j < column.Count; j++) { if (column.IsPopulatedValue(j)) { Bitmap bitmap3 = null; string str1 = OEIShared.IO.ResourceManager.Instance.BaseDirectory + "/NWN2Toolset/" + textureOrGrass + "/" + column[j] + ".bmp"; string str2 = OEIShared.IO.ResourceManager.Instance.BaseDirectory + "/NWN2Toolset_X1/" + textureOrGrass + "/" + column[j] + ".bmp"; string str3 = OEIShared.IO.ResourceManager.Instance.BaseDirectory + "/NWN2Toolset_X2/" + textureOrGrass + "/" + column[j] + ".bmp"; string strToUse = Path.Combine(str + type1, column[j] + ".bmp"); if (!File.Exists(strToUse)) { strToUse = str3; } if (!File.Exists(strToUse)) { strToUse = str2; } if (!File.Exists(strToUse)) { strToUse = str1; } try { Bitmap bitmap4 = new Bitmap(strToUse); bitmap3 = bitmap4.Clone() as Bitmap; bitmap4.Dispose(); } catch (Exception) { MessageBox.Show("Error Terrain Icon Not Found"); } TextureListItem item2 = new TextureListItem(bitmap3, column[j], new TwoDAReference("terrainmaterials", "STR_REF", true, j)); list.ItemHeight = bitmap3.Height; list.Items.Add(item2); } } if (list.Items.Count > 0) { list.SelectedItem = list.Items[0]; } }
void MissingTexturesForm_Load(object sender, EventArgs e) { // Populate the list TextureList.Items.Clear(); foreach (var item in _missingTextures) { var listItem = new TextureListItem(item.Key, item.Value); TextureList.AddItemAndReselect(listItem); } }