mirror of https://github.com/odrling/Aegisub
98 lines
2.1 KiB
C++
98 lines
2.1 KiB
C++
// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle)
|
|
// All rights reserved but the aegisub project is allowed to use it.
|
|
|
|
// FexMovement.cpp: implementation of the FexMovement class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "StdAfx.h"
|
|
#include "stdio.h"
|
|
#ifdef WIN32
|
|
#include <conio.h>
|
|
#endif
|
|
#include <ctype.h>
|
|
#include <string.h>
|
|
#include <time.h>
|
|
#include <wchar.h>
|
|
//#include <mmsystem.h>
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
FexMovement::FexMovement()
|
|
{
|
|
FileName = 0;
|
|
}
|
|
|
|
FexMovement::~FexMovement()
|
|
{
|
|
if( FileName ) delete []FileName;
|
|
}
|
|
|
|
FEXTRACKER_API FexMovement* CreateMovement()
|
|
{
|
|
return new FexMovement();
|
|
}
|
|
|
|
#ifndef WIN32
|
|
FILE *_wfopen(const wchar_t *wname, const wchar_t *wmode)
|
|
{
|
|
size_t namelen = wcstombs(NULL, wname, 0) + 1;
|
|
char name[namelen];
|
|
wcstombs(name, wname, namelen);
|
|
|
|
size_t modelen = wcstombs(NULL, wmode, 0) + 1;
|
|
char mode[modelen];
|
|
wcstombs(mode, wmode, modelen);
|
|
|
|
return fopen(name, mode);
|
|
}
|
|
#endif
|
|
|
|
FEXTRACKER_API void LoadMovement( FexMovement* me, const wchar_t* Filename )
|
|
{
|
|
me->Frames.nVal = 0;
|
|
|
|
me->FileName = new wchar_t[ wcslen(Filename)+1 ];
|
|
wcscpy( me->FileName, Filename );
|
|
|
|
FILE *fi = _wfopen( Filename, L"rt" );
|
|
if( !fi ) return;
|
|
//int CurFeat = -1;
|
|
char Line[512];
|
|
while( !feof(fi) )
|
|
{
|
|
Line[0]=0;
|
|
fgets( Line, 510, fi );
|
|
if( !Line[0] ) break;
|
|
FexMovementFrame f;
|
|
int r = sscanf( Line, "(%f %f)(%f %f %f)(%f %f)",
|
|
&f.Pos.x, &f.Pos.y,
|
|
&f.Rot.x, &f.Rot.y, &f.Rot.z,
|
|
&f.Scale.x, &f.Scale.y );
|
|
if( r != 7 ) continue;
|
|
me->Frames.Add( f );
|
|
}
|
|
fclose( fi );
|
|
}
|
|
FEXTRACKER_API void SaveMovement( FexMovement* me, const wchar_t* Filename )
|
|
{
|
|
FILE *fi = _wfopen( Filename, L"wt" );
|
|
if( !fi ) return;
|
|
for( int i=0;i<me->Frames.size();i++ )
|
|
{
|
|
const FexMovementFrame f = me->Frames[i];
|
|
fprintf( fi, "(%f %f)(%f %f %f)(%f %f)\n",
|
|
f.Pos.x, f.Pos.y,
|
|
f.Rot.x, f.Rot.y, f.Rot.z,
|
|
f.Scale.x, f.Scale.y );
|
|
}
|
|
fclose( fi );
|
|
}
|
|
|
|
FEXTRACKER_API void DeleteMovement( FexMovement* delme )
|
|
{
|
|
delete delme;
|
|
}
|