示例#1
0
        public new void Load(Project project)
        {
            currentProject = project;
            sheet = project.sheets["tiles"];

            hScrollBar.Enabled = true;
            hScrollBar.Minimum = 0;
            hScrollBar.Maximum = sheet.Cols * sheet.spriteWidth;
            hScrollBar.LargeChange = tilesPanel.Width;
            hScrollBar.SmallChange = sheet.spriteWidth;
            hScrollBar.ValueChanged += (sender, args) => {
                this.offsetX = hScrollBar.Value;
                tilesPanel.Invalidate();
            };
            vScrollBar.Enabled = true;
            vScrollBar.Minimum = 0;
            vScrollBar.Maximum = sheet.sheet.Height + sheet.spriteHeight;
            vScrollBar.LargeChange = tilesPanel.Height;
            vScrollBar.SmallChange = sheet.spriteHeight;
            vScrollBar.ValueChanged += (sender, args) => {
                this.offsetY = vScrollBar.Value;
                tilesPanel.Invalidate();
            };
            tilesPanel.Resize += (sender, args) => {
                hScrollBar.LargeChange = tilesPanel.Width;
                vScrollBar.LargeChange = tilesPanel.Height;
                hScrollBar.Enabled = hScrollBar.LargeChange <= hScrollBar.Maximum;
                vScrollBar.Enabled = vScrollBar.LargeChange <= vScrollBar.Maximum;
            };

            LoadObjects();

            tilePage.Invalidate();
        }
示例#2
0
 public AnimationSelector(SpriteSheet sheet, Project project)
 {
     InitializeComponent();
     spriteSelector.Image = sheet.sheet;
     spriteSelector.SpriteWidth = sheet.spriteWidth;
     spriteSelector.SpriteHeight = sheet.spriteHeight;
     selectedFrames = new Animation.Frame[1];
     selectedFrames[0] = new Animation.Frame(0, 1);
 }
示例#3
0
        public AnimationSelector(Animation.Group group, SpriteSheet sheet, Project project)
        {
            InitializeComponent();
            spriteSelector.Image = sheet.sheet;
            spriteSelector.SpriteWidth = sheet.spriteWidth;
            spriteSelector.SpriteHeight = sheet.spriteHeight;
            selectedFrames = group.frames.ToArray();

            //Must be set last because their events are already hooked up
            maxFramesNumUpDown.Value = group.frames.Count;
            spriteSelector.SelectedIndex = selectedFrames[0].sheetId;
            timeoutNumericUpDown.Value = selectedFrames[0].time;
        }
示例#4
0
 public Animation(string animationName, Project project)
 {
     this.project = project;
     Loader loader = project.loader;
     PropertyReader props = loader.GetPropertyReader().Select("animations/" + animationName + ".xml");
     foreach (PropertyReader animation in props.SelectAll("group")) {
         string groupName = animation.GetString("name");
         Group group = new Group();
         foreach (PropertyReader frame in animation.SelectAll("frame")) {
             int id = frame.GetInt("sheetid");
             int time = frame.GetInt("time");
             group.frames.Add(new Frame(id, time));
         }
         groups.Add(groupName, group);
     }
     this.sheet = project.sheets[props.GetString("sheet")];
 }
示例#5
0
 private void addbutton_Click(object sender, EventArgs e)
 {
     using (SpriteSheetDialog dialog = new SpriteSheetDialog()) {
         dialog.okButton.Click += (in_sender, in_args) => {
             if (dialog.nameTextBox.Text.Trim() == "") {
                 MessageBox.Show("Name cannot be empty");
             }
             else if (dialog.pictureBox.Image == null) {
                 MessageBox.Show("Image cannot be empty");
             }
             else if (!project.sheets.ContainsKey(dialog.nameTextBox.Text)) {
                 dialog.DialogResult = DialogResult.OK;
             }
             else {
                 MessageBox.Show(this, string.Format("A sprite named \"{0}\" already exists!", dialog.nameTextBox.Text));
             }
         };
         if (dialog.ShowDialog(this) == DialogResult.OK) {
             SpriteSheet sheet = new SpriteSheet(project);
             project.sheets.Add(dialog.nameTextBox.Text.Trim().ToLower(), sheet);
             sheet.sheet = (Bitmap)dialog.pictureBox.Image;
             sheet.spriteWidth = (int)dialog.widthNumericUpDown.Value;
             sheet.spriteHeight = (int)dialog.HeightNumericUpDown.Value;
             sheet.x = (int)dialog.xNumericUpDown.Value;
             sheet.y = (int)dialog.yNumericUpDown.Value;
             int index = listbox.SelectedIndex;
             LoadItems();
             listbox.SelectedIndex = index;
         }
     }
 }
示例#6
0
 public Gfx(int id, SpriteSheet sheet)
 {
     if (sheet == null) throw new ArgumentNullException("sheet");
     this.id = id;
     this.sheet = sheet;
 }
示例#7
0
 public Tile(SpriteSheet.Gfx gfx, bool passable)
 {
     this.gfx = gfx;
     this.passable = passable;
 }
示例#8
0
 public Animation(SpriteSheet sheet, Project project)
 {
     this.project = project;
     this.sheet = sheet;
 }