public State(ToolResource r)
            {
                ActionName    = r.ActionName;
                FirePointX    = r.FirePointX;
                FirePointY    = r.FirePointY;
                FireVectorX   = r.FireVectorX;
                FireVectorY   = r.FireVectorY;
                AngleAttached = r.AngleAttached;

                Locked = new bool[r.Count];
                Links  = new string[r.Count][];
                for (int i = 0; i < r.Count; i++)
                {
                    Locked[i] = r.SpriteLockedOnCycle[i];
                    Links[i]  = new string[r[i].Count];
                    for (int j = 0; j < r[i].Count; j++)
                    {
                        Links[i][j] = r[i][j].Link;
                    }
                }

                BackColor    = r.BackColor;
                PointBoundsX = r.PointBoundsX;
                PointBoundsY = r.PointBoundsY;
                PixelPerfect = r.PixelPerfect;
                Transparency = r.Transparency;
            }
Example #2
0
        public async Task <IEnumerable <ToolResource> > Get()
        {
            var list = new List <ToolResource>();

            await foreach (var tool in this.storageManager.Get())
            {
                var resource = new ToolResource {
                    Name = tool.Name
                };
                list.Add(resource);
                resource.ReadMe = await this.storageManager.GetReadMe(resource.Name);
            }

            return(list);
        }
        public ToolControl(string path)
        {
            InitializeComponent();

            FirePointXNumeric.FixMouseWheel();
            FirePointYNumeric.FixMouseWheel();
            FireVectorXNumeric.FixMouseWheel();
            FireVectorYNumeric.FixMouseWheel();

            MenuTabs = new ToolStripMenuItem[] {
                new ToolStripMenuItem("Link sprite", null, LinkSpriteMenuItem_Click, Keys.Control | Keys.I),
                new ToolStripMenuItem("Unlink sprite", null, UnlinkSpriteMenuItem_Click, Keys.Control | Keys.U),
                new ToolStripMenuItem("Create part", null, CreatePartMenuItem_Click, Keys.Control | Keys.A),
                new ToolStripMenuItem("Remove part", null, RemovePartMenuItem_Click, Keys.Control | Keys.D),
                new ToolStripMenuItem("Adjust fire vector", null, AdjustFireVectorMenuItem_Click, Keys.Control | Keys.F),
                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),
            };

            GLSurface.MakeCurrent();

            LoadedResource      = new ToolResource(path);
            Story               = new StoryItem <State>(new State(LoadedResource));
            Story.ValueChanged += Story_ValueChanged;
            ResourcePath        = path;
            ResourceName        = Path.GetFileName(path);

            ActionTextBox.TextChanged       += (object sender, EventArgs e) => SyncTextBoxValue(sender, LoadedResource.ActionName, v => LoadedResource.ActionName = v);
            FirePointXNumeric.ValueChanged  += (object sender, EventArgs e) => SyncNumericValue(sender, LoadedResource.FirePointX, v => LoadedResource.FirePointX = v);
            FirePointYNumeric.ValueChanged  += (object sender, EventArgs e) => SyncNumericValue(sender, LoadedResource.FirePointY, v => LoadedResource.FirePointY = v);
            FireVectorXNumeric.ValueChanged += (object sender, EventArgs e) => SyncNumericValue(sender, LoadedResource.FireVectorX, v => LoadedResource.FireVectorX = v);
            FireVectorYNumeric.ValueChanged += (object sender, EventArgs e) => SyncNumericValue(sender, LoadedResource.FireVectorY, v => LoadedResource.FireVectorY = v);
            AttachedCheckBox.CheckedChanged += (object sender, EventArgs e) => SyncCheckBoxValue(sender, LoadedResource.AngleAttached, v => LoadedResource.AngleAttached = v);

            PartsListBox.SelectedIndexChanged += (object sender, EventArgs e) => RestoreChanges(false);
            PartsListBox.ItemCheck            += (object sender, ItemCheckEventArgs e) => SyncCheckedValue(sender, e, LoadedResource.SpriteLockedOnCycle);

            GetTab("Pixel perfect").Checked       = LoadedResource.PixelPerfect;
            GetTab("Toggle transparency").Checked = LoadedResource.Transparency;
            RestoreChanges();

            GLFrameTimer.Start();
        }