Rev 1393 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using BauzoidNET.graphics.sprite;
namespace SpriteEditor
.file
{
public class Document
{
public class SpriteElement
{
private Bitmap mBitmap
= null;
private Sprite mSprite
= null;
public SpriteElement
(string filename
)
{
mBitmap
= new Bitmap
(filename
);
mSprite
= new Sprite
(MainForm
.getApp().getGraphics(), filename
);
}
public void Init
()
{
mSprite
.init();
}
public void Exit
()
{
mSprite
.dispose();
mSprite
= null;
mBitmap
.Dispose();
mBitmap
= null;
}
}
private bool mIsDirty
= false;
private String mFilename
= null;
//private List<LevelElement> mLevelElements = new List<LevelElement>();
private List
<SpriteElement
> mSpriteElements
= new List
<SpriteElement
>();
private Sprite mSprite
= null;
public Document
()
{
}
public bool NewDocument
(string[] textureFiles
)
{
if (textureFiles
.Length == 0)
return false;
mIsDirty
= false;
ClearSpriteElements
();
for (int i
= 0; i
< textureFiles
.Length; i
++)
{
SpriteElement e
= new SpriteElement
(textureFiles
[i
]);
e
.Init();
mSpriteElements
.Add(e
);
}
// stitch together the textures into one, create default regions for each
// minimize texture sizes by detecting and removing transparent rectangular area along texture border
// determine optimal layout (sorting by height)
// create texture large enough to contain sprites
// copy texture data into destination texture
// create regions
return true;
}
public bool LoadDocument
(String filename
)
{
mFilename
= filename
;
ClearSpriteElements
();
mIsDirty
= false;
return false;
}
public bool SaveDocument
()
{
mIsDirty
= false;
return false;
}
public bool SaveDocument
(String filename
)
{
mFilename
= filename
;
return SaveDocument
();
}
public void RemoveSpriteElement
(int i
)
{
SpriteElement e
= mSpriteElements
[i
];
mSpriteElements
.RemoveAt(i
);
e
.Exit();
}
public void ClearSpriteElements
()
{
while (mSpriteElements
.Count > 0)
{
RemoveSpriteElement
(0);
}
}
public void SetDirty
(bool dirty
)
{
mIsDirty
= dirty
;
}
public bool IsDirty
()
{
return mIsDirty
;
}
public String GetFilename
()
{
return mFilename
;
}
public void SetFilename
(String filename
)
{
mFilename
= filename
;
}
public bool IsFilenameSet
()
{
return (mFilename
!= null);
}
}
}