private void PasteButton_Click(object sender, EventArgs e) { try { var oldLevels = ActiveUpgrades.Upgrades; string text = null; FormsUtils.StaExecute(() => { text = Clipboard.GetText(); }); var levels = JsonConvert.DeserializeObject <List <UpgradeLevel> >(text); if (oldLevels.Count > 0) { var result = MessageBox.Show("This operation will overwrite existing upgrade levels. Continue?", "Warning", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } } ActiveUpgrades.Upgrades = levels; UpdateFile(); Render(); } catch { MessageBox.Show("The clipboard did not contain valid upgrade data. Try paste it somewhere else and make sure it's at least valid JSON.", "Hey!"); } }
private void glTFImportButton_Click(object sender, EventArgs e) { var dialog = new OpenFileDialog(); dialog.Title = "Select a glTF/glb file."; FormsUtils.StaExecute(() => { dialog.ShowDialog(); }); if (dialog.FileName == null) { return; } var importer = new GLTFImporter(); importer.Process(dialog.FileName); var anims = importer.Animations; var animC = Content.Content.Get().AvatarAnimations as AvatarAnimationProvider; foreach (var anim in anims) { animC.Runtime.Add(anim.Name + "-runtime.anim", ulong.MaxValue - (ulong)(RuntimeID++), anim); } RefreshAllList(); }
private void CopyButton_Click(object sender, EventArgs e) { var levels = ActiveUpgrades.Upgrades; var text = JsonConvert.SerializeObject(levels, Formatting.Indented); FormsUtils.StaExecute(() => { Clipboard.SetText(text); }); }
public void StartWithOBJM() { var dialog = new OpenFileDialog(); dialog.Filter = "OBJM Data|*.bin"; dialog.Title = "Select Object Module File."; FormsUtils.StaExecute(() => { dialog.ShowDialog(); }); if (dialog.FileName == "") { return; } var stream = dialog.OpenFile(); var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN); io.ReadUInt32(); //pad var version = io.ReadUInt32(); var MjbO = io.ReadUInt32(); var compressionCode = io.ReadByte(); if (compressionCode != 1) { throw new Exception("hey what!!"); } var iop = new IffFieldEncode(io); var table = new List <ushort>(); while (io.HasMore) { var value = iop.ReadUInt16(); if (value == 0) { break; } table.Add(value); } Io = iop; BasePosition = Io.MarkStream(); RenderFields(); }
private void ImportGLTFButton_Click(object sender, EventArgs e) { var dialog = new OpenFileDialog(); dialog.Filter = "glTF Binary Package|*.glb|glTF Separate/Embedded|*.gltf"; dialog.Title = "Select a glTF/glb file."; FormsUtils.StaExecute(() => { dialog.ShowDialog(); }); if (dialog.FileName == "") { return; } var importer = new GLTFImporter(); importer.Process(dialog.FileName); var anims = importer.Animations; // add to runtime ClearScene(); var animC = Content.Content.Get().AvatarAnimations as AvatarAnimationProvider; foreach (var anim in anims) { animC.Runtime.Add(anim.Name + "-runtime.anim", ulong.MaxValue - (RuntimeID++), anim); SceneAnimations.Add(new AvatarToolAnimation(anim, anim.Name + "-runtime")); } var generator = new AppearanceGenerator(); foreach (var mesh in importer.Meshes) { generator.GenerateAppearanceTSO(new List <ImportMeshGroup>() { mesh }, mesh.Name + "-runtime", true); SceneMeshes.Add(new AvatarToolRuntimeMesh(false, mesh.Name + "-runtime", mesh)); } SetImportMode(true, Path.GetFileName(dialog.FileName)); RefreshSceneAnims(); RefreshSceneMeshes(); }
private void ExportGLTFButton_Click(object sender, EventArgs e) { var dialog = new SaveFileDialog(); dialog.Title = "Save the scene as a glTF/glb file."; dialog.Filter = "glTF Binary Package|*.glb|glTF Separate|*.gltf"; dialog.DefaultExt = "glb"; dialog.AddExtension = true; FormsUtils.StaExecute(() => { dialog.ShowDialog(); }); Content.Content.Get().Changes.BlockingResMod(new ResAction(() => { var interactive = Animator.Renderer; var ava = (VMAvatar)interactive.TargetOBJ.BaseObject; var exp = new GLTFExporter(); ava.Avatar.Skeleton = ava.Avatar.BaseSkeleton.Clone(); ava.Avatar.ReloadSkeleton(); var scn = exp.SceneGroup(ava.Avatar.Bindings.Select(x => x.Mesh).ToList(), SceneAnimations.Select(x => x.Anim).ToList(), ava.Avatar.Bindings.Select(x => x.Texture?.Get(GameFacade.GraphicsDevice)).ToList(), ava.Avatar.BaseSkeleton); if (dialog.FileName == "") { return; } if (dialog.FileName.EndsWith(".gltf")) { scn.SaveGLTF(dialog.FileName); } else { scn.SaveGLB(dialog.FileName); } })); SetImportMode(false, Path.GetFileName(dialog.FileName)); }
private void SaveButton_Click(object sender, EventArgs e) { var dialog = new SaveFileDialog(); dialog.Title = "Save the format as a json file."; dialog.Filter = "JSON file format|*.json"; dialog.DefaultExt = "json"; dialog.AddExtension = true; FormsUtils.StaExecute(() => { dialog.ShowDialog(); }); var save = new GuessedFormat() { RepeatBase = RepeatBaseNum, Fields = Fields }; var json = JsonConvert.SerializeObject(save); File.WriteAllText(dialog.FileName, json); }
private void LoadButton_Click(object sender, EventArgs e) { var dialog = new OpenFileDialog(); dialog.Filter = "JSON file format|*.json"; dialog.Title = "Select a JSON file."; FormsUtils.StaExecute(() => { dialog.ShowDialog(); }); if (dialog.FileName == "") { return; } var json = File.ReadAllText(dialog.FileName); var save = JsonConvert.DeserializeObject <GuessedFormat>(json); Fields = save.Fields; RepeatBaseNum = save.RepeatBase; RenderFields(); }