summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2MoviePlugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2DLL/T2MoviePlugin.cpp')
-rw-r--r--src/T2DLL/T2MoviePlugin.cpp260
1 files changed, 246 insertions, 14 deletions
diff --git a/src/T2DLL/T2MoviePlugin.cpp b/src/T2DLL/T2MoviePlugin.cpp
index 2d9250d..213e849 100644
--- a/src/T2DLL/T2MoviePlugin.cpp
+++ b/src/T2DLL/T2MoviePlugin.cpp
@@ -1,58 +1,290 @@
+#include "CResFile.h"
+#include "T2Archive.h"
+#include "T2BitImage.h"
+#include "T2DateTime.h"
+#include "T2GlobalData.h"
+#include "T2ImageObj.h"
#include "T2MoviePlugin.h"
-T2MoviePlugin::T2MoviePlugin(unsigned long, T2PluginSpecifier&) {
+T2MoviePlugin::T2MoviePlugin(DWORD inType, T2PluginSpecifier& inSpecifier)
+ : T2SubPlugin(inType, inSpecifier)
+{
+ mInfo.mCC_0 = 0;
+ mInfo.mCC_1 = 0;
+ mInfo.mCC_2 = 0;
+ mInfo.mCC_3 = 0;
+ mInfo.mCC_4 = 0;
+ mInfo.mCC_5 = 0;
+ mE4 = "";
+ _E8 = 0;
+ mEC = "";
+ mF0 = "";
+ mF4 = "";
+ mBindTime = 0;
+ mFC = 0;
+ m100 = "";
+ mNOPersonsR = -1;
+ mNOPersonsF = -1;
+ mAttribute = 0;
+ mRemakeCount = 1;
+ m104 = 0;
+ m108 = 0;
+ m10C = 0;
+ m110 = 0;
+ mNamingScheme = 0;
+ m11C = 0;
+ m118 = 0;
+ mCustomTitleCount = 0;
+ mCustomTitles = NULL;
+ mResID = 0;
+ mNewNOPersonsR = -1;
+ mNewNOPersonsF = -1;
}
/*virtual*/ T2MoviePlugin::~T2MoviePlugin() {
+ if (mCustomTitles)
+ delete[] mCustomTitles;
}
-/*virtual*/ void T2MoviePlugin::LoadRsrcFromStream(CResFile&) {
+/*virtual*/ void T2MoviePlugin::LoadRsrcFromStream(CResFile& inResFile) {
+ T2SubPlugin::LoadRsrcFromStream(inResFile);
+
+ inResFile >> mResID;
+ inResFile >> mInfo.mCC_0;
+ inResFile >> mInfo.mCC_1;
+ inResFile >> mInfo.mCC_2;
+ inResFile >> mInfo.mCC_3;
+ inResFile >> mInfo.mCC_4;
+ inResFile >> mInfo.mCC_5;
+ mInfo.mCC_5 = 0;
+ mInfo.mCC_4 = 0;
+ inResFile >> mEC;
+ inResFile >> mF0;
+ inResFile >> mF4;
+ inResFile >> mBindTime;
+ inResFile >> mFC;
+ inResFile >> m100;
+
+ unsigned short us;
+ inResFile >> us;
+ mDupCustomerTableDefRes = us;
+
+ inResFile >> m104;
+ inResFile >> m108;
+ inResFile >> m10C;
+ inResFile >> m110;
+ inResFile >> mNamingScheme;
+ inResFile >> mCustomTitleCount;
+
+ mCustomTitles = new CString[mCustomTitleCount];
+ for (int i = 0; i < mCustomTitleCount; i++)
+ inResFile >> mCustomTitles[i];
+
+ inResFile >> m118;
+ inResFile >> m11C;
+ inResFile >> mE4;
}
-/*virtual*/ void T2MoviePlugin::GlobalData(T2GlobalData*) {
+/*virtual*/ void T2MoviePlugin::GlobalData(T2GlobalData* inGlobalData) {
+ inGlobalData->RegistMovie(GetID(), 0);
+ inGlobalData->GetMovieParam(GetID());
}
-int T2MoviePlugin::GetMovieLifePhase(T2DateTime*, int) {
+int T2MoviePlugin::GetMovieLifePhase(T2DateTime* inDateTime, int inStartDay) {
+ if (mTieup)
+ return IsTieupFinish() ? 4 : 1;
+ if (mAttribute & 0x8000)
+ return 4;
+
+ int diff = (inDateTime->CalcTotalDays() - inStartDay) % mInfo.mCC_5;
+ if (diff < mInfo.mCC_1)
+ return 0;
+ if (diff < mInfo.mCC_2)
+ return 1;
+ if (diff < mInfo.mCC_3)
+ return 2;
+
+ return 4;
}
void T2MoviePlugin::UnfoldPluginSelf() {
+ if (mResID) {
+ mImage = new T2BitImage(mSpecifier.mPath, mResID, true);
+#line 132
+ _ASSERT(mImage->mBitmap.header.biHeight == 32);
+ _ASSERT(mImage->mBitmap.header.biWidth == 24);
+
+ mImageObj = new T2ImageObj;
+ mImageObj->AddObject("SCRE", -1, *mImage, NULL, true, false);
+ }
+
+ mInfo.mCC_2 += mInfo.mCC_1;
+ mInfo.mCC_3 += mInfo.mCC_2;
+ mInfo.mCC_4 += mInfo.mCC_3;
+ mInfo.mCC_5 += mInfo.mCC_4;
}
void T2MoviePlugin::ReMake() {
+ if (mNOPersonsR != -1) {
+ if (mNOPersonsR >= m10C && mNOPersonsF == -1) {
+ mAttribute |= 2;
+ mNOPersonsF = mNOPersonsR;
+ }
+
+ if (mNOPersonsR >= m110) {
+ mAttribute |= 1;
+ mNOPersonsR = -1;
+ mRemakeCount++;
+ } else {
+ mAttribute |= 0x8000;
+ }
+ }
}
-void T2MoviePlugin::GetTitle(CString&, int) {
+void T2MoviePlugin::GetTitle(CString& outStr, int inNum) {
+ CString work;
+
+ outStr = mTitle;
+
+ if ((mAttribute & 1) && inNum == 1) {
+ int var = (mRemakeCount - 1) % 3;
+ switch (mNamingScheme) {
+ case 0:
+ work.Format("%d", mRemakeCount);
+ outStr += work;
+ break;
+
+ case 2:
+ switch (var) {
+ case 1:
+ // "続・" - Continued
+ outStr = "\x91\xB1\x81\x45";
+ break;
+ case 2:
+ // "新・" - New
+ outStr = "\x90\x56\x81\x45";
+ break;
+ default:
+ outStr = "";
+ break;
+ }
+ outStr += mTitle;
+ break;
+
+ case 1:
+ switch (var) {
+ case 1:
+ outStr += "PART\x85\xA0";
+ break;
+ case 2:
+ outStr += "PART\x85\xA1";
+ break;
+ }
+ break;
+
+ case 3:
+ var = (mRemakeCount - 1) % (mCustomTitleCount + 1);
+ if (var > 0) {
+ outStr = mCustomTitles[var - 1];
+ outStr += mTitle;
+ }
+ break;
+
+ case 4:
+ var = (mRemakeCount - 1) % (mCustomTitleCount + 1);
+ if (var > 0)
+ outStr += mCustomTitles[var - 1];
+ break;
+ }
+ }
}
int T2MoviePlugin::GetNOPersonsR() {
+ return mNOPersonsR;
}
-void T2MoviePlugin::SetNOPersonsR(int) {
+void T2MoviePlugin::SetNOPersonsR(int inNum) {
+ mNewNOPersonsR = inNum;
}
int T2MoviePlugin::GetNOPersonsF() {
+ return mNOPersonsF;
}
-void T2MoviePlugin::SetNOPersonsF(int) {
+void T2MoviePlugin::SetNOPersonsF(int inNum) {
+ mNewNOPersonsF = inNum;
}
-int T2MoviePlugin::IsFamousFilm() {
+BOOL T2MoviePlugin::IsFamousFilm() {
+ return (mAttribute & 2) || (mInfo.mCC_0 == 2);
}
-int T2MoviePlugin::IsRoadshowFilm() {
+BOOL T2MoviePlugin::IsRoadshowFilm() {
+ return (mInfo.mCC_0 == 0);
}
-void T2MoviePlugin::ChkReMake(int) {
+void T2MoviePlugin::ChkReMake(int inNum) {
+ if (mNewNOPersonsR > 0)
+ mNOPersonsR = mNewNOPersonsR;
+ mNewNOPersonsR = -1;
+
+ if (mNewNOPersonsF > 0)
+ mNOPersonsF = mNewNOPersonsF;
+ mNewNOPersonsF = -1;
+
+ if (mNOPersonsR != -1 && (inNum % mInfo.mCC_5) == 0 && (inNum / mInfo.mCC_5) != 0)
+ ReMake();
}
-/*static*/ void T2MoviePlugin::sDummyRead(T2Archive&) {
+/*static*/ void T2MoviePlugin::sDummyRead(T2Archive& inArchive) {
+ unsigned char tmp;
+ unsigned int i, len;
+
+ inArchive >> len;
+ for (i = 0; i < len; i++)
+ inArchive >> tmp;
}
-void T2MoviePlugin::Read(T2Archive&) {
+void T2MoviePlugin::Read(T2Archive& inArchive) {
+ short s;
+ unsigned int ui;
+
+ inArchive >> ui;
+
+ inArchive >> s;
+ mNOPersonsR = s;
+ inArchive >> s;
+ mNOPersonsF = s;
+ inArchive >> s;
+ mAttribute = s;
+ inArchive >> s;
+ mRemakeCount = s;
+ inArchive >> s;
+ mNewNOPersonsR = s;
+ inArchive >> s;
+ mNewNOPersonsF = s;
}
-void T2MoviePlugin::Write(T2Archive&) {
+void T2MoviePlugin::Write(T2Archive& inArchive) {
+ unsigned int ui = 0xC;
+ inArchive << ui;
+
+ inArchive << (short) mNOPersonsR;
+ inArchive << (short) mNOPersonsF;
+ inArchive << (short) mAttribute;
+ inArchive << (short) mRemakeCount;
+ inArchive << (short) mNewNOPersonsR;
+ inArchive << (short) mNewNOPersonsF;
}
-/*virtual*/ unsigned long T2MoviePlugin::LoadSelf() {
+/*virtual*/ DWORD T2MoviePlugin::LoadSelf() {
+ DWORD result = 0;
+ CResFile resFile;
+
+ if (resFile.OpenResource(mSpecifier.mPath, 128, 'MODF'))
+ LoadRsrcFromStream(resFile);
+ else
+ result = 0xFFFFFFFF;
+
+ return result;
}