summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2MovieParamArray.cpp
blob: 787301da327d6e563c4e577f604e244aef0503d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "T2Archive.h"
#include "T2MovieParamArray.h"

// unknown name
struct MovieParam {
    DWORD code;
    int value;
};

T2MovieParamArray::T2MovieParamArray()
    : LArray(sizeof(MovieParam))
{
}

/*virtual*/ T2MovieParamArray::~T2MovieParamArray() {
}

BOOL T2MovieParamArray::Regist(DWORD inCode, int inValue) {
    LArrayIterator iterator(*this);
    MovieParam entry;

    while (iterator.Next(&entry)) {
        if (entry.code == inCode)
            return false;
    }

    entry.code = inCode;
    entry.value = inValue;
    InsertItemsAt(1, mItemCount + 1, &entry);
    return true;
}

int T2MovieParamArray::GetParam(DWORD inCode) {
    LArrayIterator iterator(*this);
    MovieParam entry;

    while (iterator.Next(&entry)) {
        if (entry.code == inCode)
            return entry.value;
    }

    return 0;
}

/*static*/ T2MovieParamArray* T2MovieParamArray::ReadMovieParamArray(T2Archive& inArchive) {
    T2MovieParamArray *theArray = NULL;

    DWORD code;
    inArchive >> code;

    if (code == 'mvPA')
        theArray = new T2MovieParamArray;

    if (theArray)
        theArray->Read(inArchive);

    return theArray;
}

/*static*/ void T2MovieParamArray::WriteMovieParamArray(T2MovieParamArray* inArray, T2Archive& inArchive) {
    DWORD code;

    if (!inArray) {
        code = 'xmPA';
        inArchive << code;
    } else {
        code = 'mvPA';
        inArchive << code;
        inArray->Write(inArchive);
    }
}

/*virtual*/ void T2MovieParamArray::Read(T2Archive& inArchive) {
    inArchive >> mItemSize;
    inArchive >> mItemCount;
    inArchive.Read(mBuffer, mItemSize * mItemCount);
}

/*virtual*/ void T2MovieParamArray::Write(T2Archive& inArchive) {
    inArchive << mItemSize;
    inArchive << mItemCount;
    inArchive.Write(mBuffer, mItemSize * mItemCount);
}