private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e) { int index = listBox1.SelectedIndex; string objIDStr; ushort objID; if (indexToObject.ContainsKey(index)) { objIDStr = indexToObject[index]; } else { objIDStr = "1"; // item box } objID = Convert.ToUInt16(objIDStr, 16); LevelObject trackObj = new LevelObject(); trackObj.objID = objID; trackObj.routeID = -1; MiscHacks misc = new MiscHacks(); trackObj.modelName = misc.returnModel(objID); trackObj.friendlyName = misc.returnName(objID); if (trackObj.modelName != "null") { FileBase objFB = new FileBase(); if (File.Exists(Properties.Settings.Default.curDir + "/objects/" + trackObj.modelName + ".bmd")) { objFB.Stream = new FileStream(Properties.Settings.Default.curDir + "/objects/" + trackObj.modelName + ".bmd", FileMode.Open); rofl.Items.Add(trackObj); rofl.Refresh(); Close(); } else { MessageBox.Show("File /objects/" + trackObj.modelName + ".bmd does not exist. Please add this file and it's dependencies before you can add this object."); Close(); return; } } else { rofl.Items.Add(trackObj); rofl.Refresh(); Close(); } }
private void button1_Click(object sender, EventArgs e) { // here we have to get the object's id from the textbox as a hex string // then we convert it to ushort (uint16) and then use that string value = textBox1.Text; ushort objectID = Convert.ToUInt16(value, 16); LevelObject trackObj = new LevelObject(); trackObj.objID = objectID; trackObj.routeID = -1; MiscHacks misc = new MiscHacks(); trackObj.modelName = misc.returnModel(objectID); trackObj.friendlyName = misc.returnName(objectID); if (trackObj.modelName != "null") { FileBase objFB = new FileBase(); if (File.Exists(Properties.Settings.Default.curDir + "/objects/" + trackObj.modelName + ".bmd")) { objFB.Stream = new FileStream(Properties.Settings.Default.curDir + "/objects/" + trackObj.modelName + ".bmd", FileMode.Open); rofl.Items.Add(trackObj); rofl.Refresh(); Close(); } else { MessageBox.Show("File /objects/" + trackObj.modelName + ".bmd does not exist. Please add this file and it's depencies before you can add this object."); Close(); return; } } else { rofl.Items.Add(trackObj); rofl.Refresh(); Close(); } }