summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2SilhouettePane.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2DLL/T2SilhouettePane.cpp')
-rw-r--r--src/T2DLL/T2SilhouettePane.cpp84
1 files changed, 74 insertions, 10 deletions
diff --git a/src/T2DLL/T2SilhouettePane.cpp b/src/T2DLL/T2SilhouettePane.cpp
index e38e5ef..7e48810 100644
--- a/src/T2DLL/T2SilhouettePane.cpp
+++ b/src/T2DLL/T2SilhouettePane.cpp
@@ -1,25 +1,89 @@
+#include "T2BitImage.h"
+#include "T2People.h"
#include "T2SilhouettePane.h"
+#include "UT2Coordinate.h"
+#include <MINMAX.H>
-int T2SilhouettePane::GetSilhouetteType() const {
+T2SilhouettePane::T2SilhouettePane(T2TowerDoc* towerDoc, T2ImageObj* imageObj, CPalette* palette)
+ : T2DlgItem(towerDoc, imageObj, palette)
+{
+ mPeople = NULL;
+ mHasCustomColor = false;
+ mA0 = 0;
+ mSilhouetteType = 0;
+ m8C = 0;
+ m90 = 0;
}
-void T2SilhouettePane::SetCustomColor(const int&) {
+/*virtual*/ T2SilhouettePane::~T2SilhouettePane() {
}
-T2SilhouettePane::T2SilhouettePane(T2TowerDoc*, T2ImageObj*, CPalette*) {
-}
+/*virtual*/ void T2SilhouettePane::DrawSelf(CDC* dc) {
+ CRect clientRect;
+ GetClientRect(clientRect);
-/*virtual*/ T2SilhouettePane::~T2SilhouettePane() {
-}
+ if (mPeople && !clientRect.IsRectEmpty()) {
+ dc->FillRect(clientRect, CBrush::FromHandle((HBRUSH) GetStockObject(WHITE_BRUSH)));
+
+ clientRect.DeflateRect(2, 2);
+
+ int origColor = mPeople->mColor;
+ if (mHasCustomColor)
+ mPeople->mColor = mCustomColor;
+
+ CRect imageRect(0, 0, mPeople->GetWidth() * 8, 36);
+ T2BitImage *image = new T2BitImage(imageRect);
+ image->Clear(0);
+ mPeople->Draw(image, imageRect);
+
+ CRect rect3 = imageRect;
+ rect3.top += UT2Coordinate::CalcRoofThick(0);
+ rect3.bottom -= UT2Coordinate::CalcFloorThick(0);
-/*virtual*/ void T2SilhouettePane::DrawSelf(CDC*) {
+ float ratio = min(float(clientRect.Width()) / float(rect3.Width()), float(clientRect.Height()) / float(rect3.Height()));
+ if (ratio < 1.0)
+ ratio = 1.0f;
+
+ CRect rect4(0, 0, rect3.Width() * ratio, rect3.Height() * ratio);
+ rect4.OffsetRect(
+ clientRect.left + (clientRect.Width() - rect4.Width()) / 2,
+ clientRect.top + (clientRect.Height() - rect4.Height()) / 2
+ );
+
+ StretchDIBits(
+ dc->m_hDC,
+ rect4.left, rect4.top,
+ rect4.Width(), rect4.Height(),
+ rect3.left, rect3.bottom + 1,
+ rect3.Width(), -rect3.Height(),
+ image->mData, (BITMAPINFO *) &image->mBitmap,
+ DIB_PAL_COLORS, SRCCOPY);
+
+ delete image;
+
+ mPeople->mColor = origColor;
+ }
}
-/*virtual*/ int T2SilhouettePane::OnT2DlgItemEraseBkgnd(CDC*) {
+/*virtual*/ BOOL T2SilhouettePane::OnT2DlgItemEraseBkgnd(CDC* dc) {
+ int save = dc->SaveDC();
+ dc->SelectPalette(mPalette, false);
+ dc->RealizePalette();
+
+ if (!mPeople)
+ return false;
+
+ DrawSelf(dc);
+ dc->RestoreDC(save);
+
+ return true;
}
-/*virtual*/ int T2SilhouettePane::OnCreate(CREATESTRUCTA*) {
+/*virtual*/ BOOL T2SilhouettePane::OnCreate(CREATESTRUCT* cs) {
+ return T2DlgItem::OnCreate(cs);
}
-void T2SilhouettePane::SetPeople(T2People*) {
+void T2SilhouettePane::SetPeople(T2People* people) {
+ mPeople = people;
+ InvalidateRect(NULL);
}