diff options
Diffstat (limited to 'src/T2OpenSelectDlg.cpp')
-rw-r--r-- | src/T2OpenSelectDlg.cpp | 165 |
1 files changed, 165 insertions, 0 deletions
diff --git a/src/T2OpenSelectDlg.cpp b/src/T2OpenSelectDlg.cpp index 1a86321..e0e2d99 100644 --- a/src/T2OpenSelectDlg.cpp +++ b/src/T2OpenSelectDlg.cpp @@ -1,2 +1,167 @@ +#include "Bitmap.h" +#include "GlobalFunc.h" +#include "T2.h" +#include "T2BitImage.h" +#include "T2DLL.h" +#include "T2ImageObj.h" #include "T2OpenSelectDlg.h" +#include "T2TowerDoc.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +static CWnd *unknownWindow; + +T2OpenSelectDlg::T2OpenSelectDlg(T2TowerDoc *inDoc) { + mTowerDoc = inDoc; + +#line 29 + mBitmap = new Bitmap; + mBitmap->LoadFile("T2S.dat"); + + mDeleteOnClose = true; +} + +/*virtual*/ T2OpenSelectDlg::~T2OpenSelectDlg() { + delete mBitmap; + + if (mImageObj) + delete mImageObj; + if (mImage) + delete mImage; + + free(mPal1); + free(mPal2); +} + +void T2OpenSelectDlg::Setup() { + CBitmap theBitmap; + CBrush theBrush; + + HRSRC resource = FindResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(174), "PALETTE"); + HGLOBAL theHandle = LoadResource(AfxGetApp()->m_hInstance, resource); + void *resData = LockResource(theHandle); + + LOGPALETTE *theLogPalette = ConvACTPalette((ACTPALETTEENTRY *) resData); + mPalette2.CreatePalette(theLogPalette); + + int i; + + mPal1 = (short *) malloc(sizeof(short) * 256); + for (i = 0; i < 256; i++) + mPal1[i] = i; + + mPal2 = (short *) malloc(sizeof(short) * 256); + for (i = 0; i < 256; i++) { + int r = theLogPalette->palPalEntry[i].peRed; + int g = theLogPalette->palPalEntry[i].peGreen; + int b = theLogPalette->palPalEntry[i].peBlue; + int index = mPalette2.GetNearestPaletteIndex(RGB(r, g, b)); + + if (theLogPalette->palPalEntry[index].peRed == 1 && theLogPalette->palPalEntry[index].peGreen == 1 && theLogPalette->palPalEntry[index].peBlue == 1) + index = 255; + + mPal2[i] = index; + } + + free(theLogPalette); + + theBitmap.LoadBitmap(170); + theBrush.CreatePatternBrush(&theBitmap); +} + +int T2OpenSelectDlg::ShowOpenSelectDialog() { + Setup(); + + CRect rect; + GetDesktopWindow()->GetWindowRect(rect); + + HINSTANCE instance = AfxGetInstanceHandle(); + + T2DLGTEMPLATE tmpl; + tmpl.pt = rect.CenterPoint(); + tmpl.moduleHandle = instance; + tmpl.resID = 1000; + + T2TowerDoc *theDoc = NULL; + +#line 137 + mImageObj = new T2ImageObj; + mImage = new T2BitImage(instance, 172, true); + mImageObj->AddObject(instance, 172, mImage); + + Realize(this, &tmpl, theDoc, mImageObj, &mPalette2, true, NULL, 0, false); + + if (gT2App->mStrE0 != "") { + PostMessage(WM_COMMAND, 103); + } else { + ShowWindow(SW_SHOW); + SetActiveWindow(); + } + + return 0; +} + +/*virtual*/ void T2OpenSelectDlg::ListenToMessage(unsigned int msg, void *data) { +} + +/*virtual*/ BOOL T2OpenSelectDlg::OnT2DialogCommand(WPARAM inWParam, LPARAM inLParam) { + BOOL result = true; + WORD code = HIWORD(inWParam); + WORD id = LOWORD(inWParam); + + if (id == 101 && code == 0) { + ShowWindow(SW_HIDE); + mTowerDoc->LoadsWorldPlugin(); + DoClose(id); + } else if (id == 102 && code == 0) { + ShowWindow(SW_HIDE); + T2_APP->OnCmdOpen(); + DoClose(id); + } else if (id == 100 && code == 0) { + PostQuitMessage(0); + DoClose(id); + } else if (id == 103 && code == 0) { + GetCurrentT2TowerDoc()->SetPathName(gT2App->mStrE0); + GetCurrentT2TowerDoc()->OnOpenDocument(gT2App->mStrE0); + gT2App->mStrE0 = ""; + DoClose(id); + } + + return result; +} + +/*virtual*/ BOOL T2OpenSelectDlg::OnT2EraseBkgnd(CDC *pDC) { +#pragma var_order(paletteH, result, dc, hdc, palette) + unknownWindow = GetActiveWindow(); + + SetFocus(); + SetActiveWindow(); + + BOOL result = true; + + CPaintDC dc(this); + HDC hdc = dc; + HPALETTE paletteH = mBitmap->CreatePalette(); + CPalette palette; + + SelectPalette(dc, paletteH, false); + RealizePalette(dc); + + mBitmap->Draw(hdc, 0, 0); + + SelectPalette(hdc, palette, false); + DeleteObject(paletteH); + + return result; +} + +/*virtual*/ void T2OpenSelectDlg::vfF4() { + OnClose(); +} + +/*virtual*/ void T2OpenSelectDlg::vfF8(int unk1, int unk2) { +} |