public OutfitControl(string path) { InitializeComponent(); RagdollNodeNumeric.FixMouseWheel(); MenuTabs = new ToolStripMenuItem[] { new ToolStripMenuItem("Link ragdoll", null, LinkRagdollMenuItem_Click, Keys.Control | Keys.I), new ToolStripMenuItem("Link sprite", null, LinkSpriteMenuItem_Click, Keys.Control | Keys.Shift | Keys.I), new ToolStripMenuItem("Create node", null, CreateNodeMenuItem_Click, Keys.Control | Keys.A), new ToolStripMenuItem("Remove node", null, RemoveNodeMenuItem_Click, Keys.Control | Keys.D), new ToolStripMenuItem("Move node up", null, MoveNodeUpMenuItem_Click, Keys.Control | Keys.Up), new ToolStripMenuItem("Move node down", null, MoveNodeDownMenuItem_Click, Keys.Control | Keys.Down), new ToolStripMenuItem("Toggle grid", null, ToggleGridMenuItem_Click, Keys.Control | Keys.G), new ToolStripMenuItem("Toggle transparency", null, ToggleTransparencyMenuItem_Click, Keys.Control | Keys.H), new ToolStripMenuItem("Pixel perfect", null, PixelPerfectMenuItem_Click, Keys.Control | Keys.P), new ToolStripMenuItem("Background color", null, BackColorMenuItem_Click, Keys.Control | Keys.L), new ToolStripMenuItem("Reset position", null, ResetPositionMenuItem_Click, Keys.Control | Keys.R), }; for (int i = 3; i <= 5; i++) { MenuTabs[i].Enabled = false; } GLSurface.MakeCurrent(); LoadedResource = new OutfitResource(path); RagdollLinkTextBox.Text = LoadedResource.Ragdoll.Link; Story = new StoryItem <StoryState>(new StoryState(LoadedResource)); Story.ValueChanged += Story_ValueChanged; LoadedResource.Ragdoll.Reload(); RagdollLinkTextBox.Subresource = LoadedResource.Ragdoll; LoadedResource.Ragdoll.Resource?.Clothe(LoadedResource); ResourcePath = path; ResourceName = Path.GetFileName(path); GetTab("Toggle grid").Checked = LoadedResource.GridEnabled; GetTab("Toggle transparency").Checked = LoadedResource.Transparency; GetTab("Pixel perfect").Checked = LoadedResource.PixelPerfect; NodesListBox.BeginUpdate(); while (NodesListBox.Items.Count < LoadedResource.Count) { NodesListBox.Items.Add("Node: " + NodesListBox.Items.Count); } while (NodesListBox.Items.Count > LoadedResource.Count) { NodesListBox.Items.RemoveAt(NodesListBox.Items.Count - 1); } NodesListBox.EndUpdate(); GLSurface.BackColor = Color.FromArgb(LoadedResource.BackColor); ClotheTypeComboBox.Items.AddRange(Enum.GetNames(typeof(OutfitResource.Node.Clothe))); UpdateRedactor(); GLFrameTimer.Start(); }
public void ToResource(OutfitResource r) { r.Count = Links.Length; for (int i = 0; i < r.Count; i++) { r[i].Sprite.Link = Links[i]; r[i].RagdollNode = Nodes[i]; r[i].ClotheType = (OutfitResource.Node.Clothe)Types[i]; } r.BackColor = BackColor; r.PointBoundsX = PointBoundsX; r.PointBoundsY = PointBoundsY; r.PixelPerfect = PixelPerfect; r.GridEnabled = GridEnabled; r.Transparency = Transparency; r.Ragdoll.Link = Ragdoll; }
public StoryState(OutfitResource r) { Links = new string[r.Count]; Nodes = new int[r.Count]; Types = new int[r.Count]; for (int i = 0; i < r.Count; i++) { Links[i] = r[i].Sprite.Link; Nodes[i] = r[i].RagdollNode; Types[i] = (int)r[i].ClotheType; } BackColor = r.BackColor; PointBoundsX = r.PointBoundsX; PointBoundsY = r.PointBoundsY; PixelPerfect = r.PixelPerfect; GridEnabled = r.GridEnabled; Transparency = r.Transparency; Ragdoll = r.Ragdoll.Link; }
private void CompileOutfits() { LogQueue.Put("Compiling outfits..."); int id = 0; var CompiledOutfits = new Compiled.Outfit[EntitiesIDTable.LastID + 1]; var OutfitNodes = new List <Compiled.Outfit.Node>(); foreach (var e in OutfitsIDTable.Items) { int dist = id; while (id < e.ID) { CompiledOutfits[id++] = new Compiled.Outfit(); } dist = id - dist; if (dist > 0) { LogQueue.Put("IDs skipped: " + dist); } LogQueue.Put("Compiling [" + e.Path + "]..."); OutfitResource res = null; try { res = new OutfitResource(e.Path); } catch { LogQueue.Put("Outfit [" + e.Path + "] not found. ID skipped."); CompiledOutfits[id++] = new Compiled.Outfit(); continue; } CompiledOutfits[id].FirstNode = OutfitNodes.Count; CompiledOutfits[id].NodesCount = res.Nodes.Count; foreach (var node in res.Nodes) { var cnode = new Compiled.Outfit.Node(); cnode.SpriteID = SpritesIDTable[node.Sprite.Link]; cnode.RagdollNodeIndex = node.RagdollNode; cnode.ClotheType = (int)node.ClotheType; OutfitNodes.Add(cnode); } LogQueue.Put("Outfit [" + e.Path + "] compiled with id [" + id + "]."); id++; } LogQueue.Put("Outfits compiled."); Directory.CreateDirectory("../Compilation"); using (var w = new BinaryWriter(File.Create("../Compilation/Outfits"))) { w.Write(OutfitNodes.Count); foreach (var n in OutfitNodes) { w.Write(n); } w.Write(CompiledOutfits.Length); foreach (var o in CompiledOutfits) { w.Write(o); } } }