private void btnOpen_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Supported Formats|*.obj;"; ofd.Multiselect = true; if (ofd.ShowDialog() == DialogResult.OK) { foreach (var file in ofd.FileNames) { var thread = new Thread(() => { try { var result = CollisionLoader.CreateCollisionFromObject(this, file); this.Invoke((MethodInvoker) delegate { if (result.KclFie != null) { CollisionLoader.SaveKCL(result.KclFie, file, result.AttributeFile); } }); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } CollisionLoader.CloseConsole(this); }); thread.Start(); } } }
private void Replace(object sender, EventArgs args) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Supported Formats|*.obj"; if (ofd.ShowDialog() == DialogResult.OK) { var form = Runtime.MainForm; var thread = new Thread(() => { //Load runtime values to gui handler MaterialWindowSettings.GamePreset = Runtime.CollisionSettings.KCLGamePreset; MaterialWindowSettings.Platform = GetPlatform(); MaterialWindowSettings.UsePresetEditor = Runtime.CollisionSettings.KCLUsePresetEditor; var result = CollisionLoader.CreateCollisionFromObject(form, ofd.FileName); CollisionLoader.CloseConsole(form); if (result.KclFie == null) { return; } SaveMaterialWindowSettings(); form.Invoke((MethodInvoker) delegate { KclFile = result.KclFie; if (result.AttributeFile is MaterialAttributeBymlFile) { AttributeByml = ((MaterialAttributeBymlFile)result.AttributeFile).BymlFile; } ReloadData(); Renderer.UpdateVertexData(); SaveAttributeByml(true); }); }); thread.Start(); } }
public void CreateNew(object sender, EventArgs args) { bool isBigEndian = false; if (sender.ToString() == "KCL (Wii U)") { isBigEndian = true; } OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Supported Formats|*.obj"; if (ofd.ShowDialog() != DialogResult.OK) { return; } string path = Path.Combine(Runtime.ExecutableDir, "KclMaterialPresets"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } CollisionPresetData.LoadPresets(Directory.GetFiles("KclMaterialPresets")); var form = Runtime.MainForm; var thread = new Thread(() => { //Load runtime values to gui handler MaterialWindowSettings.GamePreset = Runtime.CollisionSettings.KCLGamePreset; MaterialWindowSettings.Platform = Runtime.CollisionSettings.KCLGamePreset; MaterialWindowSettings.UsePresetEditor = Runtime.CollisionSettings.KCLUsePresetEditor; var result = CollisionLoader.CreateCollisionFromObject(form, ofd.FileName); CollisionLoader.CloseConsole(form); if (result.KclFie == null) { return; } SaveMaterialWindowSettings(); form.Invoke((MethodInvoker) delegate { string name = Path.GetFileNameWithoutExtension(ofd.FileName); KCL kcl = new KCL(); kcl.KclFile = result.KclFie; if (result.AttributeFile is MaterialAttributeBymlFile) { kcl.AttributeByml = ((MaterialAttributeBymlFile)result.AttributeFile).BymlFile; } kcl.Text = name; kcl.IFileInfo = new IFileInfo(); kcl.FileName = name; kcl.Renderer = new KCLRendering(); kcl.ReloadData(); kcl.DrawableContainer = new DrawableContainer() { Name = kcl.FileName, Drawables = new List <AbstractGlDrawable>() { kcl.Renderer }, }; ObjectEditor editor = new ObjectEditor(kcl); editor.Text = name; LibraryGUI.CreateMdiWindow(editor); }); }); thread.Start(); }