Skip to content

Commit

Permalink
An update to AnimView from Todd. Thanks for you hard work!
Browse files Browse the repository at this point in the history
  • Loading branch information
Lego3 committed Oct 25, 2011
1 parent 41c8b34 commit 3ba9506
Show file tree
Hide file tree
Showing 13 changed files with 187,621 additions and 132 deletions.
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
* text=auto !eol
AnimView/CMakeLists.txt -text
AnimView/VSPR-0.xml -text
AnimView/tinystr.cpp -text
AnimView/tinystr.h -text
AnimView/tinyxml.cpp -text
AnimView/tinyxml.h -text
AnimView/tinyxmlerror.cpp -text
AnimView/tinyxmlparser.cpp -text
CorsixTH/Bitmap/aux_ui.dat -text svneol=unset#unset
CorsixTH/Bitmap/aux_ui.spec -text
CorsixTH/Bitmap/aux_ui.tab -text
Expand Down
6 changes: 6 additions & 0 deletions AnimView/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ SET(animview_source_files
frmSprites.cpp
rnc.cpp
th.cpp
tinystr.cpp
tinyxml.cpp
tinyxmlerror.cpp
tinyxmlparser.cpp
app.h
backdrop.h
frmMain.h
frmSprites.h
th.h
tinystr.h
tinyxml.h
)

# Declaration of the executable
Expand Down
181,414 changes: 181,414 additions & 0 deletions AnimView/VSPR-0.xml

Large diffs are not rendered by default.

184 changes: 109 additions & 75 deletions AnimView/frmMain.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions AnimView/frmMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class frmMain : public wxFrame
bool m_bDrawCoordinates;

wxButton* m_btnPlayPause;
wxButton* m_btnExport;
wxTextCtrl* m_txtTHPath;
wxTextCtrl* m_txtAnimIndex;
wxTextCtrl* m_txtAnimCount;
Expand Down
325 changes: 271 additions & 54 deletions AnimView/th.cpp

Large diffs are not rendered by default.

19 changes: 16 additions & 3 deletions AnimView/th.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ SOFTWARE.
#include <wx/file.h>
#include <wx/image.h>
#include <wx/txtstrm.h>
#include "tinyxml.h"
#ifdef _MSC_VER
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
Expand Down Expand Up @@ -174,26 +175,34 @@ class THAnimations
bool loadSpriteFile(wxString sFilename) {return _loadArray(m_pChunks, m_iChunkCount, sFilename);}
bool loadPaletteFile(wxString sFilename);
bool loadGhostFile(wxString sFilename, int iIndex);
bool loadXMLFile(TiXmlDocument* xmlDocument);

void writeElementData(wxString aPath, wxTextOutputStream *outputLog, wxTextOutputStream *outputXml, size_t iAnimation, size_t iFrame, const THLayerMask* pMask, wxSize& size);
void writeElementData(wxString aPath, wxTextOutputStream *outputLog, wxTextOutputStream *outputXml,
size_t iAnimation, size_t iFrame, const THLayerMask* pMask, wxSize& size, int* iListIndex);
void writeTableDataHeader(wxTextOutputStream *outputLog);

size_t markDuplicates();

size_t getAnimationCount();
size_t getSpriteCount();
size_t getFrameCount(size_t iAnimation);
uint16_t getUnknownField(size_t iAnimation);
uint16_t getUnknownField(size_t iAnimation) {return m_pAnims[iAnimation].unknown; }
uint16_t getFrameField(size_t iAnimation) {return m_pAnims[iAnimation].frame; }
//uint32_t getListIndexField(size_t iFrame) {return m_pFrames[iFrame].list_index; }
//uint8_t getFrameWidthField(size_t iFrame) {return m_pFrames[iFrame].width; }
//uint8_t getFrameHeightField(size_t iFrame) {return m_pFrames[iFrame].height; }
th_frame_t* getFrameStruct(size_t iAnimation, size_t iFrame);
bool isAnimationDuplicate(size_t iAnimation);
bool doesAnimationIncludeFrame(size_t iAnimation, size_t iFrame);
uint16_t getFrameFlags(size_t iAnimation, size_t iFrame);
void getAnimationMask(size_t iAnimation, THLayerMask& mskLayers);
void setSpritePath(wxString aPath);

Bitmap* getSpriteBitmap(size_t iSprite, bool bComplex = false);
th_colour_t* getPalette() {return m_pColours;}

void setGhost(int iFile, int iIndex);
void drawFrame(wxImage& imgCanvas, size_t iAnimation, size_t iFrame, const THLayerMask* pMask, wxSize& size, int iXOffset = 0, int iYOffset = 0);
void copySpriteToCanvas(wxString spriteFile, int iSpriteIndex, wxImage& imgCanvas, int iX, int iY, int iFlags = 0);

static unsigned char* Decompress(unsigned char* pData, size_t& iLength);
protected:
Expand Down Expand Up @@ -233,6 +242,8 @@ class THAnimations
th_element_t* m_pElements;
th_sprite_t* m_pSprites;
Bitmap* m_pSpriteBitmaps;
wxImage* m_pSpriteImages;
uint8_t* m_pSpriteScaleFactors;
uint8_t* m_pChunks;
th_colour_t* m_pColours;
unsigned char* m_pGhostMaps;
Expand All @@ -244,4 +255,6 @@ class THAnimations
size_t m_iSpriteCount;
size_t m_iChunkCount;
size_t m_iColourCount;
bool m_bXmlLoaded;
wxString m_sSpritePath;
};
111 changes: 111 additions & 0 deletions AnimView/tinystr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
www.sourceforge.net/projects/tinyxml
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/


#ifndef TIXML_USE_STL

#include "tinystr.h"

// Error value for find primitive
const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1);


// Null rep.
TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };


void TiXmlString::reserve (size_type cap)
{
if (cap > capacity())
{
TiXmlString tmp;
tmp.init(length(), cap);
memcpy(tmp.start(), data(), length());
swap(tmp);
}
}


TiXmlString& TiXmlString::assign(const char* str, size_type len)
{
size_type cap = capacity();
if (len > cap || cap > 3*(len + 8))
{
TiXmlString tmp;
tmp.init(len);
memcpy(tmp.start(), str, len);
swap(tmp);
}
else
{
memmove(start(), str, len);
set_size(len);
}
return *this;
}


TiXmlString& TiXmlString::append(const char* str, size_type len)
{
size_type newsize = length() + len;
if (newsize > capacity())
{
reserve (newsize + capacity());
}
memmove(finish(), str, len);
set_size(newsize);
return *this;
}


TiXmlString operator + (const TiXmlString & a, const TiXmlString & b)
{
TiXmlString tmp;
tmp.reserve(a.length() + b.length());
tmp += a;
tmp += b;
return tmp;
}

TiXmlString operator + (const TiXmlString & a, const char* b)
{
TiXmlString tmp;
TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) );
tmp.reserve(a.length() + b_len);
tmp += a;
tmp.append(b, b_len);
return tmp;
}

TiXmlString operator + (const char* a, const TiXmlString & b)
{
TiXmlString tmp;
TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) );
tmp.reserve(a_len + b.length());
tmp.append(a, a_len);
tmp += b;
return tmp;
}


#endif // TIXML_USE_STL
Loading

0 comments on commit 3ba9506

Please sign in to comment.