|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Odecey Master Cheater Reputation: 1
Joined: 19 Apr 2007 Posts: 259 Location: Scandinavia
|
|
Back to top |
|
|
&Vage Grandmaster Cheater Supreme Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
|
Back to top |
|
|
Odecey Master Cheater Reputation: 1
Joined: 19 Apr 2007 Posts: 259 Location: Scandinavia
|
Posted: Sat Oct 10, 2009 8:48 pm Post subject: |
|
|
void:] wrote: | http://forum.cheatengine.org/viewforum.php?f=65 |
The project files are included in one of the downloads, in case you didn't notice. That said, I'd be more than happy to post the source in the post itself.
_________________
Never confuse activity with productivity. You can be busy without a purpose, but what's the point?- Rick Warren |
|
Back to top |
|
|
&Vage Grandmaster Cheater Supreme Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
|
Back to top |
|
|
Odecey Master Cheater Reputation: 1
Joined: 19 Apr 2007 Posts: 259 Location: Scandinavia
|
Posted: Sat Oct 10, 2009 8:56 pm Post subject: |
|
|
I was under the impression that this section could be used to release and discuss source code. If I am mistaken, I'm sure a moderator will be kind enough to move it.
_________________
Never confuse activity with productivity. You can be busy without a purpose, but what's the point?- Rick Warren |
|
Back to top |
|
|
&Vage Grandmaster Cheater Supreme Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
Posted: Sat Oct 10, 2009 9:02 pm Post subject: |
|
|
General programming
Forum for posting questions and answers about programming. Delphi, C, Java, Assembler, BF, Cobol, whatever...
Binaries
For those that just want to show of their programs, post your binaries here. (With or without sourcecode if you like)
|
|
Back to top |
|
|
Flyte Peanuts!!!! Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sat Oct 10, 2009 10:10 pm Post subject: |
|
|
ITT: void pretends he is a moderator.
Also, why do people insist on coding monoliths? Break up the mainform into more than one class or I will STAB YOU MULTIPLE TIMES SO YOU NEVER TOUCH A COMPILER AGAIN*.
* Not really, but I felt this was the most appropriate way to get my point across.
|
|
Back to top |
|
|
Odecey Master Cheater Reputation: 1
Joined: 19 Apr 2007 Posts: 259 Location: Scandinavia
|
Posted: Sun Oct 11, 2009 6:58 am Post subject: |
|
|
Athaem wrote: | ITT: void pretends he is a moderator.
Also, why do people insist on coding monoliths? Break up the mainform into more than one class or I will STAB YOU MULTIPLE TIMES SO YOU NEVER TOUCH A COMPILER AGAIN*.
* Not really, but I felt this was the most appropriate way to get my point across. |
Here you go:
Code: |
class SpritesheetPictureBox : System.Windows.Forms.PictureBox
{
#region Private variables
Dictionary<string, Bitmap> _sprites = new Dictionary<string, Bitmap>();
Dictionary<Point, string> _spriteGrid = new Dictionary<Point, string>();
Graphics surface;
Color _gridColor = Color.Red;
private SpriteFormat _spriteFormat = SpriteFormat.Cropped;
private int _cellHeight = 50;
private int _cellWidth = 50;
private int _gridRows = 5;
private int _gridColumns = 5;
#endregion
#region Constructors
public SpritesheetPictureBox()
{
surface = Graphics.FromHwnd(this.Handle);
}
#endregion
#region Properties
public int CellWidth { get { return _cellWidth; } set { _cellWidth = value; RefreshSheet(); } }
public int CellHeight { get { return _cellHeight; } set { _cellHeight = value; RefreshSheet(); } }
public int GridRows { get { return _gridRows; } set { _gridRows = value; RemoveRows(_gridRows - 1); RefreshSheet(); } }
public int GridColumns { get { return _gridColumns; } set { _gridColumns = value; RemoveColumns(_gridColumns - 1); RefreshSheet(); } }
public Color GridColor { get { return _gridColor; } set { _gridColor = value; RefreshSheet(); } }
public SpriteFormat CellSpriteFormat { get { return _spriteFormat; } set { _spriteFormat = value; RefreshSheet(); } }
public Dictionary<string, Bitmap> Sprites { get { return _sprites; } set { _sprites = value; RefreshSheet(); } }
public Dictionary<Point, string> SpriteGrid { get { return _spriteGrid; } set { _spriteGrid = value; RefreshSheet(); } }
#endregion
#region Methods
private void RemoveColumns(int maxColumnIndex)
{
List<Point> indexesToRemove = new List<Point>();
foreach (Point index in _spriteGrid.Keys)
if (index.Y > maxColumnIndex)
indexesToRemove.Add(index);
foreach (Point index in indexesToRemove)
_spriteGrid.Remove(index);
}
private void RemoveRows(int maxRowIndex)
{
List<Point> indexesToRemove = new List<Point>();
foreach (Point index in _spriteGrid.Keys)
if (index.X > maxRowIndex)
indexesToRemove.Add(index);
foreach (Point index in indexesToRemove)
_spriteGrid.Remove(index);
}
private void DrawGrid(Graphics surface, Color color, int rows, int columns, int width, int height)
{
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < columns; j++)
{
surface.DrawRectangle(new Pen(new SolidBrush(color), 1.0f), new Rectangle(i * width, j * height, width, height));
}
}
}
private void DrawSprites(Graphics surface)
{
for (int i = 0; i < _gridRows; i++)
{
for (int j = 0; j < _gridColumns; j++)
{
if (_spriteGrid.ContainsKey(new Point(i, j)))
{
if (_spriteFormat == SpriteFormat.Resized)
surface.DrawImage(_sprites[_spriteGrid[new Point(i, j)]], new Rectangle(_cellWidth * i, _cellHeight * j, _cellWidth, _cellHeight));
else
surface.DrawImage(_sprites[_spriteGrid[new Point(i, j)]], new Rectangle(_cellWidth * i, _cellHeight * j, _cellWidth, _cellHeight), new Rectangle(0, 0, (int)_cellWidth, (int)_cellHeight), GraphicsUnit.Pixel);
}
}
}
}
public void RefreshSheet()
{
this.Refresh();
this.OnPaint(null);
}
#endregion
#region Overrides
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pe)
{
DrawSprites(surface);
DrawGrid(surface, _gridColor, _gridRows, _gridColumns, _cellWidth, _cellHeight);
base.OnPaint(pe);
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
surface = Graphics.FromHwnd(this.Handle);
}
#endregion
#region Structs and Enums
public enum SpriteFormat
{
Cropped = 0,
Resized
}
#endregion
}
|
Satisfied?
_________________
Never confuse activity with productivity. You can be busy without a purpose, but what's the point?- Rick Warren |
|
Back to top |
|
|
hcavolsdsadgadsg I'm a spammer Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sun Oct 11, 2009 5:03 pm Post subject: |
|
|
Looks good, could make a tile atlas with it as well
Moving.
|
|
Back to top |
|
|
Odecey Master Cheater Reputation: 1
Joined: 19 Apr 2007 Posts: 259 Location: Scandinavia
|
Posted: Sun Oct 25, 2009 1:36 pm Post subject: |
|
|
I haven't really been working on this since I released it, but have tweaked it slightly. Info on what's new can be found in the original post.
Offtopic: Could anyone suggest a diffrent forum for discussion of programming(C# in particular)? It seems this forum's active userbase is slowly crawling towards zero.
_________________
Never confuse activity with productivity. You can be busy without a purpose, but what's the point?- Rick Warren |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|