summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2OuterObjDef.cpp
blob: e9f5cc06d6275aa75b7df50faff5f9b188824239 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "StdAfx.h"
#include "T2FloorInfo.h"
#include "T2ImageObj.h"
#include "T2InfoDialog.h"
#include "T2Message.h"
#include "T2OutObj.h"
#include "T2OuterObjDef.h"
#include "T2OuterObjList.h"
#include "../T2TowerDoc.h"
#include "T2WorldDef.h"
#include "UT2Coordinate.h"

T2OuterObjDef::T2OuterObjDef(DWORD type, T2PluginSpecifier& specifier, CResFile* resFile, T2WorldDef* worldDef, T2ToolPlugin* plugin)
    : T2ToolDef(type, specifier, resFile, worldDef, plugin)
{
    mValiationCount = 1;
}

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

/*virtual*/ CURSORTYPE T2OuterObjDef::QueryCursor(T2TowerDoc*, POINT inPt, CString& outStr, RECT& outRect, POINT& outPt, int factor, unsigned int, int) {
    outStr = "Csr";

    inPt.x -= ((mWidth * UT2Coordinate::UnitHSize(factor)) / 2 - UT2Coordinate::UnitHSize(factor) / 2);
    inPt.y -= ((mHeight * UT2Coordinate::UnitVSize(factor)) / 2 - UT2Coordinate::UnitVSize(factor) / 2);

    UT2Coordinate::QDToUnit(inPt, factor);

    SetRect(&outRect, inPt.x, inPt.y, inPt.x + mWidth, inPt.y + mHeight);
    outPt.x = outRect.left;
    outPt.y = outRect.top;
    UT2Coordinate::UnitToQD(outRect, factor, true);

    return CursorType_0;
}

/*virtual*/ void T2OuterObjDef::DrawProc(T2HaveOutViewObject* obj, const RECT& inRect, T2TowerDoc* inDoc) const {
    RECT rect = ((T2OutObj *) obj)->_3C;
    UT2Coordinate::UnitToQD(rect, inDoc->GetZoomLevel(), true);

    int objectID = mImageObj->FindObject("View");
    mImageObj->DrawObject(inDoc->GetImage(), objectID, rect, inDoc->GetZoomLevel());
}

/*virtual*/ AREACHECKCODE T2OuterObjDef::AreaCheck(T2TowerDoc* inDoc, RECT& rect, unsigned int arg1, int inShowError) {
    LArrayIterator iterator(*inDoc->mOuterObjList);
    T2OutObj *theOutObj;

    while (iterator.Next(&theOutObj)) {
        RECT intersect;
        if (IntersectRect(&intersect, &theOutObj->_3C, &rect)) {
            if (inShowError) {
                // "重ねて設置できません" - cannot be placed on top of each other
                (new T2Message)->ShowMessage("\x8F\x64\x82\xCB\x82\xC4\x90\xDD\x92\x75\x82\xC5\x82\xAB\x82\xDC\x82\xB9\x81\xF1");
            }
            return AreaCheckCode_0;
        }
    }

    for (int x = rect.left; x < rect.right; x++) {
        for (int y = rect.top; y < rect.bottom; y++) {
            if (!inDoc->mFloorInfo->GetTenant(y, x)) {
                if (inShowError) {
                    // "はみだして設置できません" - it cannot be installed as it protrudes
                    (new T2Message)->ShowMessage("\x82\xCD\x82\xDD\x82\xBE\x82\xB5\x82\xC4\x90\xDD\x92\x75\x82\xC5\x82\xAB\x82\xDC\x82\xB9\x82\xF1");
                }
                return AreaCheckCode_0;
            }
        }
    }

    if (rect.bottom > (inDoc->mWorldDef->mGroundLine - inDoc->mWorldDef->mLobbyHeight)) {
        if (inShowError) {
            // "ここには設置できません" - cannot be installed here
            (new T2Message)->ShowMessage("\x82\xB1\x82\xB1\x82\xC9\x82\xCD\x90\xDD\x92\x75\x82\xC5\x82\xAB\x82\xDC\x82\xB9\x82\xF1");
        }
        return AreaCheckCode_0;
    }

    return AreaCheckCode_1;
}

/*virtual*/ T2InfoDialog* T2OuterObjDef::ShowInfoDialog(T2TowerDoc* inDoc, T2OutObj* inOutObj) {
    CRect rect;
    AfxGetMainWnd()->GetWindowRect(rect);

    T2DLGTEMPLATE tmpl;
    tmpl.pt = rect.CenterPoint();
    tmpl.moduleHandle = mModuleHandle;
    tmpl.resID = GetInfoDialogID(inDoc, inOutObj);

    T2InfoDialog *dialog = ConstructInfoDialog(inOutObj);
    dialog->Realize(this, &tmpl, inDoc, mImageObj, NULL, true, NULL, 0, true);
    return dialog;
}

/*virtual*/ int T2OuterObjDef::GetInfoDialogID(T2TowerDoc*, const T2OutObj*) const {
    return 1000;
}

/*virtual*/ T2InfoDialog* T2OuterObjDef::ConstructInfoDialog(T2OutObj*) {
    return NULL;
}

/*virtual*/ PROCCODE T2OuterObjDef::DoDestructProc(T2TowerDoc* inDoc, T2HaveOutViewObject* inObj, POINT, RECT& outRect) {
    outRect = ((T2OutObj *) inObj)->_3C;
    return ((T2OutObj *) inObj)->Destruct(inDoc, outRect);
}