diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-07-11 17:52:00 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-07-11 17:52:00 +0100 |
commit | 024306ccab5f6d51f3fce269fb1984fd02f3bb02 (patch) | |
tree | 8d359495d72bf4e7295c7eab4cb220edc2d4b60c /src | |
parent | 0f3cba6fcea0ffd511dfe3275d57a5b9e69be5be (diff) | |
download | t2win-024306ccab5f6d51f3fce269fb1984fd02f3bb02.tar.gz t2win-024306ccab5f6d51f3fce269fb1984fd02f3bb02.zip |
add Floor, add DefaultToolPalettemain
Diffstat (limited to 'src')
41 files changed, 3418 insertions, 145 deletions
diff --git a/src/Plugins/Food/Burger/Burger.cpp b/src/Plugins/Food/Burger/Burger.cpp index 2e9f301..45b8965 100644 --- a/src/Plugins/Food/Burger/Burger.cpp +++ b/src/Plugins/Food/Burger/Burger.cpp @@ -65,8 +65,7 @@ CBurgerApp theApp; FoodPlugin *sFoodPlugin; FoodDef *sFoodDef; -#pragma comment(linker, "/export:ConstructProgramPlugin=_ConstructProgramPlugin@4") -extern "C" void *CALLBACK ConstructProgramPlugin(T2PluginSpecifier *inSpecifier) { +void *CALLBACK ConstructProgramPlugin(T2PluginSpecifier *inSpecifier) { if (!sFoodPlugin) { #line 88 sFoodPlugin = new FoodPlugin('TnPl', *inSpecifier); @@ -75,8 +74,7 @@ extern "C" void *CALLBACK ConstructProgramPlugin(T2PluginSpecifier *inSpecifier) return sFoodPlugin; } -#pragma comment(linker, "/export:ConstructTemplatePlugin=_ConstructTemplatePlugin@16") -extern "C" void *CALLBACK ConstructTemplatePlugin(T2PluginSpecifier *inSpecifier, CResFile *inResFile, T2WorldDef *inWorldDef, T2TenantPlugin *inPlugin) { +void *CALLBACK ConstructTemplatePlugin(T2PluginSpecifier *inSpecifier, CResFile *inResFile, T2WorldDef *inWorldDef, T2TenantPlugin *inPlugin) { if (!sFoodDef) { #line 101 sFoodDef = new FoodDef('TnDf', *inSpecifier, inResFile, inWorldDef, inPlugin); @@ -85,8 +83,7 @@ extern "C" void *CALLBACK ConstructTemplatePlugin(T2PluginSpecifier *inSpecifier return sFoodDef; } -#pragma comment(linker, "/export:DestructProgramPlugin=_DestructProgramPlugin@0") -extern "C" void *CALLBACK DestructProgramPlugin() { +void *CALLBACK DestructProgramPlugin() { delete sFoodPlugin; sFoodPlugin = NULL; @@ -96,11 +93,10 @@ extern "C" void *CALLBACK DestructProgramPlugin() { return NULL; } -#pragma comment(linker, "/export:GetAttr=_GetAttr@16") -extern "C" T2PluginSpecifier *CALLBACK GetAttr(T2PluginSpecifier *inSpecifier, CResFile *inResFile, T2WorldDef *inWorldDef, T2TenantPlugin *inPlugin) { -#line 120 +T2PluginSpecifier *CALLBACK GetAttr(T2PluginSpecifier *inSpecifier, CResFile *inResFile, T2WorldDef *inWorldDef, T2TenantPlugin *inPlugin) { +#line 76 T2PluginSpecifier *specifier = new T2PluginSpecifier; - specifier->mPluginName = "Burgar"; + specifier->mPluginName = "Floor Ver1.3"; specifier->mType = 'TnPl'; specifier->mAttrib = 0xFFFFFFFF; specifier->mGameLevel = 0; diff --git a/src/Plugins/Food/Burger/Burger.def b/src/Plugins/Food/Burger/Burger.def index c6ca96c..d8e0028 100644 --- a/src/Plugins/Food/Burger/Burger.def +++ b/src/Plugins/Food/Burger/Burger.def @@ -4,3 +4,7 @@ LIBRARY "Burger" DESCRIPTION 'Burger Windows Dynamic Link Library' EXPORTS + ConstructProgramPlugin + ConstructTemplatePlugin + DestructProgramPlugin + GetAttr diff --git a/src/Plugins/Food/Burger/Burger.dsp b/src/Plugins/Food/Burger/Burger.dsp index 4743baa..b7ed5a7 100644 --- a/src/Plugins/Food/Burger/Burger.dsp +++ b/src/Plugins/Food/Burger/Burger.dsp @@ -78,6 +78,7 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 ../../../T2DLL/Debug/T2DLL.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"..\..\Burger.t2p" /pdbtype:sept +# SUBTRACT LINK32 /map /nodefaultlib !ENDIF diff --git a/src/Plugins/Food/Burger/Burger.h b/src/Plugins/Food/Burger/Burger.h index eb21d60..6fe91a7 100644 --- a/src/Plugins/Food/Burger/Burger.h +++ b/src/Plugins/Food/Burger/Burger.h @@ -43,4 +43,4 @@ public: //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. -#endif // !defined(AFX_BURGER2_H__81154B54_BBFC_4E61_A2BC_BB53B98894B3__INCLUDED_) +#endif // !defined(AFX_BURGER_H__81154B54_BBFC_4E61_A2BC_BB53B98894B3__INCLUDED_) diff --git a/src/Plugins/Food/Burger/Resource.h b/src/Plugins/Food/Burger/Resource.h new file mode 100644 index 0000000..a09f2ba --- /dev/null +++ b/src/Plugins/Food/Burger/Resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by BURGER.RC +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS + +#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/src/Plugins/Lobby/Floor/Floor.clw b/src/Plugins/Lobby/Floor/Floor.clw new file mode 100644 index 0000000..363ad09 --- /dev/null +++ b/src/Plugins/Lobby/Floor/Floor.clw @@ -0,0 +1,16 @@ +; CLW file contains information for the MFC ClassWizard + +[General Info] +Version=1 +ClassCount=1 +Class1=CFloorApp +LastClass=CFloorApp +NewFileInclude2=#include "Floor.h" +ResourceCount=0 +NewFileInclude1=#include "stdafx.h" + +[CLS:CFloorApp] +Type=0 +HeaderFile=Floor.h +ImplementationFile=Floor.cpp +Filter=N diff --git a/src/Plugins/Lobby/Floor/Floor.cpp b/src/Plugins/Lobby/Floor/Floor.cpp index e5fc2a5..ab788c8 100644 --- a/src/Plugins/Lobby/Floor/Floor.cpp +++ b/src/Plugins/Lobby/Floor/Floor.cpp @@ -1,7 +1,104 @@ +// Floor.cpp : Defines the initialization routines for the DLL. +// + +#include "stdafx.h" #include "Floor.h" +#include "FloorDef.h" +#include "FloorPlugin.h" +#include "../../../T2DLL/T2PluginSpecifier.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif + +// +// Note! +// +// If this DLL is dynamically linked against the MFC +// DLLs, any functions exported from this DLL which +// call into MFC must have the AFX_MANAGE_STATE macro +// added at the very beginning of the function. +// +// For example: +// +// extern "C" BOOL PASCAL EXPORT ExportedFunction() +// { +// AFX_MANAGE_STATE(AfxGetStaticModuleState()); +// // normal function body here +// } +// +// It is very important that this macro appear in each +// function, prior to any calls into MFC. This means that +// it must appear as the first statement within the +// function, even before any object variable declarations +// as their constructors may generate calls into the MFC +// DLL. +// +// Please see MFC Technical Notes 33 and 58 for additional +// details. +// + +///////////////////////////////////////////////////////////////////////////// +// CFloorApp + +BEGIN_MESSAGE_MAP(CFloorApp, CWinApp) + //{{AFX_MSG_MAP(CFloorApp) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CFloorApp construction + +CFloorApp::CFloorApp() +{ +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CFloorApp object + +CFloorApp theApp; + +FloorPlugin *sFloorPlugin; +FloorDef *sFloorDef; + +void *CALLBACK ConstructProgramPlugin(T2PluginSpecifier *inSpecifier) { + if (!sFloorPlugin) { +#line 48 + sFloorPlugin = new FloorPlugin('TnPl', *inSpecifier); + } + + return sFloorPlugin; +} + +void *CALLBACK ConstructTemplatePlugin(T2PluginSpecifier *inSpecifier, CResFile *inResFile, T2WorldDef *inWorldDef, T2TenantPlugin *inPlugin) { + if (!sFloorDef) { +#line 55 + sFloorDef = new FloorDef('TnDf', *inSpecifier, inResFile, inWorldDef, inPlugin); + } + + return sFloorDef; +} + +void *CALLBACK DestructProgramPlugin() { + delete sFloorPlugin; + sFloorPlugin = NULL; + + delete sFloorDef; + sFloorDef = NULL; + + return NULL; +} + +T2PluginSpecifier *CALLBACK GetAttr(T2PluginSpecifier *inSpecifier, CResFile *inResFile, T2WorldDef *inWorldDef, T2TenantPlugin *inPlugin) { +#line 76 + T2PluginSpecifier *specifier = new T2PluginSpecifier; + specifier->mPluginName = "Burgar"; + specifier->mType = 'TnPl'; + specifier->mAttrib = 0xFFFFFFFF; + specifier->mGameLevel = 0; + return specifier; +} diff --git a/src/Plugins/Lobby/Floor/Floor.def b/src/Plugins/Lobby/Floor/Floor.def new file mode 100644 index 0000000..a24e3a1 --- /dev/null +++ b/src/Plugins/Lobby/Floor/Floor.def @@ -0,0 +1,10 @@ +; Floor.def : Declares the module parameters for the DLL. + +LIBRARY "Floor" +DESCRIPTION 'Floor Windows Dynamic Link Library' + +EXPORTS + ConstructProgramPlugin + ConstructTemplatePlugin + DestructProgramPlugin + GetAttr diff --git a/src/Plugins/Lobby/Floor/Floor.dsp b/src/Plugins/Lobby/Floor/Floor.dsp new file mode 100644 index 0000000..322c46a --- /dev/null +++ b/src/Plugins/Lobby/Floor/Floor.dsp @@ -0,0 +1,157 @@ +# Microsoft Developer Studio Project File - Name="Floor" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=Floor - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Floor.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Floor.mak" CFG="Floor - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Floor - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Floor - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Floor - Win32 Release" + +# PROP BASE Use_MFC 6 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 6 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_USRDLL" /Yu"stdafx.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" /d "_AFXDLL" +# ADD RSC /l 0x809 /d "NDEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 /nologo /subsystem:windows /dll /machine:I386 + +!ELSEIF "$(CFG)" == "Floor - Win32 Debug" + +# PROP BASE Use_MFC 6 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 6 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "Z:\Users\ash\src\t2-res\dx5\cdrom\sdk\inc" /I "Z:\Users\ash\src\t2-res\dxmedia51\DX51\dxmdev\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_USRDLL" /Yu"stdafx.h" /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" /d "_AFXDLL" +# ADD RSC /l 0x809 /d "_DEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 ../../../T2DLL/Debug/T2DLL.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"..\..\Floor.t2p" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "Floor - Win32 Release" +# Name "Floor - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\Floor.cpp +# End Source File +# Begin Source File + +SOURCE=.\FloorDef.cpp +# End Source File +# Begin Source File + +SOURCE=.\FloorPlugin.cpp +# End Source File +# Begin Source File + +SOURCE=.\Floor.def +# End Source File +# Begin Source File + +SOURCE=.\Floor.rc + +!IF "$(CFG)" == "Floor - Win32 Release" + +!ELSEIF "$(CFG)" == "Floor - Win32 Debug" + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\Floor.h +# End Source File +# Begin Source File + +SOURCE=.\FloorDef.h +# End Source File +# Begin Source File + +SOURCE=.\FloorPlugin.h +# End Source File +# Begin Source File + +SOURCE=.\Resource.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\res\Floor.rc2 +# End Source File +# End Group +# End Target +# End Project diff --git a/src/Plugins/Lobby/Floor/Floor.h b/src/Plugins/Lobby/Floor/Floor.h index 1a6ec0f..ec27269 100644 --- a/src/Plugins/Lobby/Floor/Floor.h +++ b/src/Plugins/Lobby/Floor/Floor.h @@ -1,5 +1,46 @@ +// Floor.h : main header file for the FLOOR DLL +// + +#if !defined(AFX_FLOOR_H__81154B54_BBFC_4E61_A2BC_BB53B98894B3__INCLUDED_) +#define AFX_FLOOR_H__81154B54_BBFC_4E61_A2BC_BB53B98894B3__INCLUDED_ + +#if _MSC_VER >= 1000 #pragma once -#include "common.h" +#endif // _MSC_VER >= 1000 + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "../../../common.h" +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CFloorApp +// See Floor.cpp for the implementation of this class +// + +class CFloorApp : public CWinApp +{ +public: + CFloorApp(); -class Floor { +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CFloorApp) + //}}AFX_VIRTUAL + + //{{AFX_MSG(CFloorApp) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() }; + + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_FLOOR_H__81154B54_BBFC_4E61_A2BC_BB53B98894B3__INCLUDED_) diff --git a/src/Plugins/Lobby/Floor/Floor.rc b/src/Plugins/Lobby/Floor/Floor.rc new file mode 100644 index 0000000..1781a41 --- /dev/null +++ b/src/Plugins/Lobby/Floor/Floor.rc @@ -0,0 +1,150 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +128 ATTR "res\\ATTR128_1.bin" + +128 DESC "res\\DESC128_1.txt" + +100 OBJMAP "res\\OBJMAP100_1.txt" + +1000 OBJMAP "res\\OBJMAP1000_1.txt" + +1001 OBJMAP "res\\OBJMAP1001_1.txt" + +1002 OBJMAP "res\\OBJMAP1002_1.txt" + +1003 OBJMAP "res\\OBJMAP1003_1.txt" + +1 TNDF "res\\TNDF1_1.bin" + +100 BITMAP "res\\BITMAP100_1.bmp" + +1000 BITMAP "res\\BITMAP1000_1.bmp" + +1001 BITMAP "res\\BITMAP1001_1.bmp" + +1002 BITMAP "res\\BITMAP1002_1.bmp" + +1003 BITMAP "res\\BITMAP1003_1.bmp" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" + "#ifdef _WIN32\r\n" + "LANGUAGE 9, 1\r\n" + "#pragma code_page(1252)\r\n" + "#endif\r\n" + "#include ""res\\Floor.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""afxres.rc"" // Standard components\r\n" + "#endif" + "\0" +END + +///////////////////////////////////////////////////////////////////////////// +#endif // APSTUDIO_INVOKED + + + + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE 9, 1 +#pragma code_page(1252) +#endif + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "Floor DLL\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "Floor\0" + VALUE "LegalCopyright", "Copyright (C) 1997\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename","Floor.DLL\0" + VALUE "ProductName", "Floor Dynamic Link Library\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE 9, 1 +#pragma code_page(1252) +#endif +#include "res\\Floor.rc2" // non-Microsoft Visual C++ edited resources +#include "afxres.rc" // Standard components +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/src/Plugins/Lobby/Floor/FloorDef.cpp b/src/Plugins/Lobby/Floor/FloorDef.cpp index e537523..029485b 100644 --- a/src/Plugins/Lobby/Floor/FloorDef.cpp +++ b/src/Plugins/Lobby/Floor/FloorDef.cpp @@ -1,7 +1,818 @@ +#include "StdAfx.h" #include "FloorDef.h" +#include "../../../T2DLL/T2BitImage.h" +#include "../../../T2DLL/T2CrossEquipArray.h" +#include "../../../T2DLL/T2FInfoAreaIterator.h" +#include "../../../T2DLL/T2FInfoPtIterator.h" +#include "../../../T2DLL/T2FloorInfo.h" +#include "../../../T2DLL/T2ImageObj.h" +#include "../../../T2DLL/T2Mover.h" +#include "../../../T2DLL/T2PaletteAnime.h" +#include "../../../T2DLL/T2People.h" +#include "../../../T2DLL/T2Request.h" +#include "../../../T2DLL/T2RouteNavigator.h" +#include "../../../T2DLL/T2Tenant.h" +#include "../../../T2DLL/T2ToolWindow.h" +#include "../../../T2DLL/T2TowerMessage.h" +#include "../../../T2DLL/T2WorldDef.h" +#include "../../../T2DLL/UT2Coordinate.h" +#include "../../../T2TowerDoc.h" +#include "../../../T2TowerMainView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif + +static BOOL DoMerges(T2Tenant *&ioFloor, T2TowerDoc *inDoc); +static void MergeFloor(T2Tenant *inFloorA, T2Tenant *inFloorB, T2TowerDoc *inDoc); +static void ReplaceMoverIDForFloors(const RECT &inRect, unsigned int inOldID, unsigned int inNewID, T2FloorInfo *inFloorInfo); +static void ReplaceFloorIDForMovers(T2CrossEquipArray *inMoverIDArray, unsigned int inOldID, unsigned int inNewID, T2FloorInfo *inFloorInfo); + +/*virtual*/ unsigned int FloorDef::IdleProc(T2HaveOutViewObject *inObject, T2TowerDoc *inDoc) { + unsigned int result = 0; + + T2Tenant *floor = (T2Tenant *) inObject; + int status = floor->GetStatus(); + if (status == kTenantStatus1) { + T2Tenant *floorMerge = floor; + + CRect area; + floorMerge->GetEquipArea(area); + + if (DoMerges(floorMerge, inDoc)) { + inDoc->GetMainView()->InvalUnitRect(area); + } else { + floor->SetStatus(kTenantStatus10); + result = 2; + inDoc->GetRouteNavi()->FloorAdded(floorMerge, false); + } + + BuildFinish(inDoc, floor); + } + + return result; +} + +FloorDef::FloorDef(DWORD inType, T2PluginSpecifier &inSpecifier, CResFile *inResFile, T2WorldDef *inWorldDef, T2TenantPlugin *inPlugin) + : T2TenantDef(inType, inSpecifier, inResFile, inWorldDef, inPlugin) +{ +} + +/*virtual*/ FloorDef::~FloorDef() { +} + +/*virtual*/ T2InfoDialog *FloorDef::ShowInfoDialog(T2TowerDoc *doc, T2Equip *equip) { + return NULL; +} + +/*virtual*/ void FloorDef::DrawProc(T2HaveOutViewObject *inObject, const RECT &inRect, T2TowerDoc *inDoc) const { +#pragma var_order(var14, width, var1C, var20, theTenant, theFloor, isExcludeRoofAndFloor, var30, floorArea, var44, var48, var4C, rect5, pattern, visibleRFloor, rect6, height, var88, id, var90, fInfoAreaIter) + T2Tenant *theFloor = (T2Tenant *) inObject; + + CRect visibleFloor = inRect; + visibleFloor = theFloor->mArea; + + T2FInfoAreaIterator fInfoAreaIter(*inDoc->GetFloorInfo(), theFloor->mArea); + T2Tenant *theTenant; + + while (fInfoAreaIter.NextTenant(theTenant)) { + if (theTenant->GetEquipID() == theFloor->GetEquipID()) { + RECT rect2 = theFloor->mArea; + fInfoAreaIter.GetTenantRect(rect2); + + RECT rect3; + if (IntersectRect(&rect3, &rect2, &inRect)) { + visibleFloor = rect2; + break; + } + } + } + + int height = theFloor->mArea.bottom - theFloor->mArea.top; + int width = visibleFloor.left - theFloor->mArea.left; + + CRect floorArea = theFloor->mArea; + int id; + int pattern; + BOOL isExcludeRoofAndFloor; + + if (inDoc->mViewMode != kOutView) { + id = 100; + if (theFloor->mValiation == 0) + pattern = 100; + else + pattern = height * 100 + 1000; + + isExcludeRoofAndFloor = false; + } else { + id = 101; + pattern = + (inDoc->GetWorldDef()->GetOutViewKind() + 1) * 10000 + + theFloor->mValiation * 1000 + + height * 100; + + if (theFloor->IsFire()) + pattern += 2; + else if (inDoc->GetPaletteAnime()->IsSnow()) + pattern += 1; + + isExcludeRoofAndFloor = true; + } + + CRect rect5, rect6; + + int var14; + int var44; + T2BitImage *var48; + + if (inDoc->mViewMode != kOutView) { + var44 = mImageObj->FindObject(id, pattern); + var48 = mImageObj->GetObjectImage(var44, rect5); + var14 = rect5.Width() / 8; + } else { + var14 = 0; + } + + int var4C = mImageObj->FindObject(id, pattern + 100000); + T2BitImage *var30 = mImageObj->GetObjectImage(var4C, rect6); + int var88 = rect6.Width() / 8; + + int var90; + if (inDoc->mViewMode != kOutView) { + var90 = var14 + ((floorArea.left + var14 - 7) % 8) - 7; + var90 = min(var90, visibleFloor.right - floorArea.left); + } else { + var90 = 0; + } + + int var20 = visibleFloor.right - floorArea.left - var90; + int var1C = floorArea.left + var90; + + if (var90 > width) { + CRect src = rect5; + src.right = src.left + var90 * 8; + src.left += width * 8; + + CRect dst = visibleFloor; + dst.right = min(dst.left + var90 - width, visibleFloor.right); + visibleFloor.left = dst.right; + + UT2Coordinate::UnitToQD(dst, inDoc->GetZoomLevel(), isExcludeRoofAndFloor); + var48->CopyImage(*inDoc->GetImage(), src, dst); + + width = 0; + } + + if (var20 > 0) { + if (width > 0) + width -= var90; + + width += var1C % var88; + width %= var88; + + CRect dstUnitRect, srcRect, dstRect; + if ((width + visibleFloor.Width()) <= var88) { + dstUnitRect = visibleFloor; + + srcRect = rect6; + srcRect.left += width * 8; + srcRect.right = srcRect.left + visibleFloor.Width() * 8; + + UT2Coordinate::UnitToQD(dstUnitRect, dstRect, inDoc->GetZoomLevel(), isExcludeRoofAndFloor); + var30->CopyImage(*inDoc->GetImage(), srcRect, dstRect); + } else { + if (width > 0) { + dstUnitRect = visibleFloor; + dstUnitRect.right = dstUnitRect.left + (var88 - width); + + srcRect = rect6; + srcRect.left += width * 8; + + UT2Coordinate::UnitToQD(dstUnitRect, dstRect, inDoc->GetZoomLevel(), isExcludeRoofAndFloor); + var30->CopyImage(*inDoc->GetImage(), srcRect, dstRect); + + visibleFloor.left = dstUnitRect.right; + } + + while ((visibleFloor.left + var88) <= visibleFloor.right) { + dstUnitRect = visibleFloor; + dstUnitRect.right = dstUnitRect.left + var88; + + srcRect = rect6; + + UT2Coordinate::UnitToQD(dstUnitRect, dstRect, inDoc->GetZoomLevel(), isExcludeRoofAndFloor); + var30->CopyImage(*inDoc->GetImage(), srcRect, dstRect); + + visibleFloor.left = dstUnitRect.right; + } + + if (visibleFloor.left < visibleFloor.right) { + dstUnitRect = visibleFloor; + + srcRect = rect6; + srcRect.right = srcRect.left + dstUnitRect.Width() * 8; + + UT2Coordinate::UnitToQD(dstUnitRect, dstRect, inDoc->GetZoomLevel(), isExcludeRoofAndFloor); + var30->CopyImage(*inDoc->GetImage(), srcRect, dstRect); + + visibleFloor.left = dstUnitRect.right; + } + } + } +} + +/*virtual*/ AREACHECKCODE FloorDef::AreaCheck(T2TowerDoc *inDoc, RECT &ioRect, unsigned int inInfo, BOOL inShowError) { + AREACHECKCODE result = AreaCheckCode_1; + + if (!(inInfo & kAreaCheckFlag10000)) { + if (GetCategory() != 100 && ioRect.top < inDoc->mWorldDef->mTopFloorLine) { + if (inShowError) { + // EN: Only Final item can be placed on the top floor of building. + inDoc->GetTowerMessage()->BuildErr(68, NULL); + } + result = AreaCheckCode_0; + } + + if (result == AreaCheckCode_1 && ioRect.bottom > inDoc->mWorldDef->mBottomFloorLine) { + if (inShowError) { + // EN: Can not place items beyond the edges of the floor below. + inDoc->GetTowerMessage()->BuildErr(2, NULL); + } + return AreaCheckCode_0; + } + } + + if (result == AreaCheckCode_1) { + inInfo &= 0xFF; + if (ioRect.bottom == inDoc->GetWorldDef()->mGroundLine) { + if (inInfo == 0) { + if (inShowError) { + // EN: Only the lobby item can be placed on the first floor. + inDoc->GetTowerMessage()->BuildErr(15, NULL); + } + return AreaCheckCode_0; + } + } else { + if (inInfo == 1) { + if (inShowError) { + // EN: The lobby item can be only placed on the first floor. + inDoc->GetTowerMessage()->BuildErr(16, NULL); + } + return AreaCheckCode_0; + } + } + + if (inInfo != 3) { +#line 289 + _ASSERT(inDoc != NULL && inDoc->GetWorldDef() != NULL); + if (ioRect.bottom < inDoc->GetWorldDef()->mTopFloorLine) { + if (inShowError) { + // EN: Can not place items here. + inDoc->GetTowerMessage()->BuildErr(8, NULL); + } + return AreaCheckCode_0; + } + } + + if (inInfo == 0) { + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); + if (ioRect.bottom <= theFloorInfo->GetGroundLine()) { + for (int h = ioRect.left; h < ioRect.right; h++) { + unsigned int theTenantID = theFloorInfo->GetTenantID(ioRect.bottom, h); + if (theTenantID == 0) { + if (inShowError) { + RECT area; + theFloorInfo->GetFloorArea(area); + area.top = ioRect.bottom; + area.bottom = ioRect.bottom + 1; + + T2FInfoAreaIterator iterator(*theFloorInfo, area); + T2Tenant *theTenant; + if (iterator.NextTenant(theTenant)) { + // EN: Can not place items beyond the edges of the floor below. + inDoc->GetTowerMessage()->BuildErr(2, NULL); + } else { + // EN: There is no floor below. + inDoc->GetTowerMessage()->BuildErr(4, NULL); + } + } + return AreaCheckCode_0; + } else { + T2Tenant *theTenant = theFloorInfo->GetTenant(theTenantID); + if (theTenant && T2EquipDef::IsSetAttribute(kTenantAttr40000)) { + if (inShowError) { + // EN: Can not place this item above the sky bridge. + inDoc->GetTowerMessage()->BuildErr(13, NULL); + } + return AreaCheckCode_0; + } + } + } + } else { + BOOL flag = false; + if (inDoc->GetWorldDef()->m17C == 1 || inDoc->GetWorldDef()->m17C == 2) { + for (int v = ioRect.top; v < ioRect.bottom; v++) { + if (theFloorInfo->GetTenantID(v, ioRect.left - 1) || theFloorInfo->GetTenantID(v, ioRect.right)) { + flag = true; + break; + } + } + + if (!flag) { + for (int h = ioRect.left; h < ioRect.right; h++) { + if (theFloorInfo->GetTenantID(ioRect.top - 1, h)) { + flag = true; + break; + } + } + } + } else { + flag = true; + for (int h = ioRect.left; h < ioRect.right; h++) { + if (!theFloorInfo->GetTenantID(ioRect.top - 1, h)) { + flag = false; + break; + } + } + } + + if (!flag) { + if (inShowError) { + // EN: Can not place items beyond the edges of the floor above. + inDoc->GetTowerMessage()->BuildErr(3, NULL); + } + return AreaCheckCode_0; + } + } + } + + RECT area; + inDoc->GetFloorInfo()->GetFloorArea(area); + + int minimumX = (inInfo != 1) ? (ioRect.left - 9) : area.left; + minimumX = max(minimumX, area.left); + + int maximumX = (inInfo != 1) ? (ioRect.right + 8) : (area.right - 1); + maximumX = min(maximumX, area.right - 1); + + int y = ioRect.bottom - 1; + int x; + + for (x = ioRect.left - 1; x >= minimumX; x--) { + if (inDoc->GetFloorInfo()->GetTenant(y, x)) + break; + } + + if (x >= minimumX) + ioRect.left = x + 1; + + for (x = ioRect.right; x <= maximumX; x++) { + if (inDoc->GetFloorInfo()->GetTenant(y, x)) + break; + } + + if (x <= maximumX) + ioRect.right = x; + + result = AreaCheckCode_1; + } + + return result; +} + +/*virtual*/ int FloorDef::RequierToolIcon(T2ToolWindow *window) { + window->AddIcon(mStr48, 0, 1, kToolOption1, NULL, 0, 1, NULL); + return 0; +} + +/*virtual*/ CURSORTYPE FloorDef::QueryCursor(T2TowerDoc *inDoc, POINT inPt, CString &outSpriteName, RECT &outRect, POINT &outPt, + int inZoomLevel, unsigned int inValiation, int i) { + int height; + + if (inValiation == 0) { + outSpriteName = "Csr"; + height = mHeight; + } else { + char buf[20]; + height = inDoc->GetWorldDef()->GetLobbyHeight(); + wsprintfA(buf, "LCsr%d%d", 1, height); + outSpriteName = buf; + } + + inPt.x -= ((UT2Coordinate::UnitHSize(inZoomLevel) * mWidth) / 2) - (UT2Coordinate::UnitHSize(inZoomLevel) / 2); + inPt.y -= ((UT2Coordinate::UnitVSize(inZoomLevel) * height) / 2) - (UT2Coordinate::UnitVSize(inZoomLevel) / 2); + + UT2Coordinate::QDToUnit(inPt, inZoomLevel); + SetRect(&outRect, inPt.x, inPt.y, inPt.x + mWidth, inPt.y + height); + + outPt.x = outRect.left; + outPt.y = outRect.top; + UT2Coordinate::UnitToQD(outRect, inZoomLevel); + + return CursorType_0; +} + +static BOOL DoMerges(T2Tenant *&ioFloor, T2TowerDoc *inDoc) { +#pragma var_order(leftFloor, rightFloor, flag10, floorInfo, area, pt, result) + BOOL result = false; + + BOOL flag10 = (ioFloor->GetEquipID() == 1000); + T2FloorInfo *floorInfo = inDoc->mFloorInfo; + + RECT area; + ioFloor->GetEquipArea(area); + + POINT pt; + pt.y = area.top; + pt.x = area.left - 1; + + T2Tenant *leftFloor = floorInfo->GetFloor(pt.y, pt.x); + if (leftFloor && leftFloor->IsBuildFinish()) { + if (!flag10) { + MergeFloor(ioFloor, leftFloor, inDoc); + ioFloor = leftFloor; + } else { + ioFloor->SetStatus(kTenantStatus10); + inDoc->GetRouteNavi()->FloorAdded(ioFloor, false); + MergeFloor(leftFloor, ioFloor, inDoc); + } + result = true; + } + + pt.x = area.right; + + T2Tenant *rightFloor = floorInfo->GetFloor(pt.y, pt.x); + if (rightFloor && rightFloor->IsBuildFinish()) { + if (!result) { + if (!flag10) { + MergeFloor(ioFloor, rightFloor, inDoc); + ioFloor = rightFloor; + } else { + ioFloor->SetStatus(kTenantStatus10); + inDoc->GetRouteNavi()->FloorAdded(ioFloor, false); + MergeFloor(rightFloor, ioFloor, inDoc); + } + } else { + if (ioFloor->IsMoverAvailable() || flag10) { + MergeFloor(rightFloor, ioFloor, inDoc); + } else { + MergeFloor(ioFloor, rightFloor, inDoc); + } + } + result = true; + } + + return result; +} + +static void MergeFloor(T2Tenant *inFloorA, T2Tenant *inFloorB, T2TowerDoc *inDoc) { +#pragma var_order(floorIDA, flagC, ceArrayB, floorInfo, ceArrayA, pt, areaA, isFloorB, areaB, isFinishA, floorIDB, isFloorA) + T2FloorInfo *floorInfo = inDoc->mFloorInfo; +#line 481 + _ASSERT(floorInfo != NULL); + + BOOL isFloorA = inFloorA->IsFloor(); + if (!isFloorA) { + unsigned int floorID = inFloorA->GetFloorID(-1); + if (floorID != 0) + inFloorA = floorInfo->GetTenant(floorID); + } + + BOOL isFloorB = inFloorB->IsFloor(); + if (!isFloorB) { + unsigned int floorID = inFloorB->GetFloorID(-1); + if (floorID != 0) + inFloorB = floorInfo->GetTenant(floorID); + } + + BOOL isFinishA = inFloorA->IsBuildFinish(); + BOOL flagC = isFinishA && inFloorA->IsMoverAvailable(); + + RECT areaA, areaB; + inFloorA->GetEquipArea(areaA); + inFloorB->GetEquipArea(areaB); + + unsigned int floorIDA = inFloorA->GetEquipID(); + unsigned int floorIDB = inFloorB->GetEquipID(); + + T2CrossEquipArray *ceArrayA = inFloorA->GetCEArray(); + T2CrossEquipArray *ceArrayB = inFloorB->GetCEArray(); + + ReplaceMoverIDForFloors(areaA, floorIDA, floorIDB, floorInfo); + ReplaceFloorIDForMovers(ceArrayA, floorIDA, floorIDB, floorInfo); + + inFloorB->UnionFloorPeople(inFloorA); + + POINT pt; + pt.x = (areaA.left < areaB.left) ? (areaB.left - 1) : (areaA.left - 1); + pt.y = areaA.bottom - 1; + + ceArrayB->Union(ceArrayA); + floorInfo->ReplaceFloorID(areaA, floorIDA, floorIDB); + + UnionRect(&areaB, &areaB, &areaA); + inFloorB->SetEquipArea(areaB); + + if (isFinishA) + inDoc->GetRouteNavi()->FloorRemoved(inFloorA, flagC); + + inFloorA->SetUsed(false); + floorInfo->UpdeteRequestByUnionFloor(inFloorB, pt); +} + +static void ReplaceMoverIDForFloors(const RECT &inRect, unsigned int inOldID, unsigned int inNewID, T2FloorInfo *inFloorInfo) { + T2FInfoAreaIterator iterator(*inFloorInfo, inRect); + T2Tenant *theTenant; + + while (iterator.NextTenant(theTenant)) { + if (theTenant && !theTenant->IsFloor()) { + T2CrossEquipArray *theFloorCEArray = theTenant->GetCEArray(); + if (theFloorCEArray) + theFloorCEArray->ReplaceID(inOldID, inNewID); + } + } +} + +static void ReplaceFloorIDForMovers(T2CrossEquipArray *inMoverIDArray, unsigned int inOldID, unsigned int inNewID, T2FloorInfo *inFloorInfo) { + LArrayIterator iterator(*inMoverIDArray); + unsigned int theMoverID; + + while (iterator.Next(&theMoverID)) { + T2Mover *theMover = inFloorInfo->GetMover(theMoverID); + if (theMover) { + T2CrossEquipArray *theMoverCEArray = theMover->GetCEArray(); + if (theMoverCEArray) + theMoverCEArray->ReplaceID(inOldID, inNewID); + } + } +} + +/*virtual*/ void FloorDef::BuildFinish(T2TowerDoc *inDoc, T2Equip *inEquip) { + T2EquipDef::BuildFinish(inDoc, inEquip); + + CRect floorArea; + inEquip->GetEquipArea(floorArea); + + CRect aboveArea(floorArea.left, floorArea.top - 1, floorArea.right, floorArea.top); + T2FInfoAreaIterator iter(*inDoc->GetFloorInfo(), aboveArea); + + T2Tenant *theTenant = NULL; + while (iter.NextTenant(theTenant)) { + if (theTenant->IsSetAttribute(kTenantAttr40000)) { + theTenant->GetEquipDef()->OptionProc(inDoc, theTenant, NULL); + break; + } + } +} + +static PROCCODE x154C0(T2TowerDoc *inDoc, T2HaveOutViewObject *inObject, POINT inPt, RECT &outRect); + +/*virtual*/ PROCCODE FloorDef::DoDestructProc(T2TowerDoc *inDoc, T2HaveOutViewObject *inObject, POINT inPt, RECT &outRect) { + T2Tenant *theFloor = (T2Tenant *) inObject; + + POINT unitPt = inPt; + UT2Coordinate::QDToUnit(unitPt, inDoc->GetZoomLevel()); + + if (unitPt.y < (inDoc->GetFloorInfo()->GetGroundLine() - 1)) { + if (!inDoc->GetFloorInfo()->GetTenant(unitPt.y + 1, unitPt.x)) + return x154C0(inDoc, theFloor, unitPt, outRect); + } + + PROCCODE result = ProcCode_1; + int buildErr = 0; + + CRect equipArea; + theFloor->GetEquipArea(equipArea); + + // bug??? + if (!theFloor->GetCEArray() && theFloor->GetCEArray()->GetCount()) { + result = ProcCode_2; + // EN: This floor can not be removed because transit systems are connected. + buildErr = 22; + } + + if (result == ProcCode_1) { + T2FInfoAreaIterator iter(*inDoc->GetFloorInfo(), equipArea); + T2Mover *theMover; + + while (result == ProcCode_1 && iter.NextMover(theMover)) { + CRect moverArea, intersect; + theMover->CalcBodyArea(moverArea); + if (intersect.IntersectRect(equipArea, moverArea)) { + result = ProcCode_2; + // EN: This floor can not be removed because transit systems are connected. + buildErr = 22; + } + } + } + + if (theFloor->GetFirstPeople()) { + result = ProcCode_2; + // EN: Can not remove the floor because there are people here. + buildErr = 73; + } + + if (result == ProcCode_1) { + T2FInfoAreaIterator iter(*inDoc->GetFloorInfo(), equipArea); + T2Tenant *tenant; + + while (iter.NextTenant(tenant) && tenant) { + if (!tenant->IsFloor()) { + result = ProcCode_2; + // EN: This floor can not be removed because there is already a tenant on it. + buildErr = 21; + break; + } + } + } + + if (result == ProcCode_1) { + BOOL isAbove = equipArea.bottom <= inDoc->GetFloorInfo()->GetGroundLine(); + if (isAbove) { + CRect aboveArea(equipArea.left, equipArea.top - 1, equipArea.right, equipArea.top); + T2FInfoAreaIterator iter(*inDoc->GetFloorInfo(), aboveArea); + T2Tenant *tenant = NULL; + + if (iter.NextTenant(tenant) && tenant) { + result = ProcCode_2; + // EN: Floor can only be removed if it is the top floor of the building. + buildErr = 19; + } + } + + BOOL isBelow = equipArea.bottom >= inDoc->GetFloorInfo()->GetGroundLine(); + if (isBelow) { + CRect undergroundArea(equipArea.left, equipArea.bottom, equipArea.right, equipArea.bottom + 1); + T2FInfoAreaIterator iter(*inDoc->GetFloorInfo(), undergroundArea); + T2Tenant *tenant = NULL; + + if (iter.NextTenant(tenant) && tenant) { + result = ProcCode_2; + // EN: Floor can only be removed if it is the lowest floor of the building. + buildErr = 20; + } + } + } + + if (buildErr != 0) + inDoc->GetTowerMessage()->BuildErr(buildErr, NULL); + + if (result == ProcCode_1) + result = ProcCode_0; + + return result; +} + +static PROCCODE x154C0(T2TowerDoc *inDoc, T2HaveOutViewObject *inObject, POINT inPt, RECT &outRect) { +#pragma var_order(crossEquipArrayIterator, lastID, theFloor, result, theMoverID, theIterR, theFloorID, theUpRequest, theFloorInfo, tenant, requestIterator, removedArea, iterator3, rightTenant, ceIterator, theFloorDef, rightArea, leftArea, leftTenant, floorArea, theRequest, theIterL, pt, theRightFloor, theRightFloorID, theCEArray, theDnRequest) + PROCCODE result = ProcCode_1; + + T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); + T2Tenant *theFloor = (T2Tenant *) inObject; + FloorDef *theFloorDef = (FloorDef *) theFloor->GetEquipDef(); + unsigned int theFloorID = theFloor->GetEquipID(); + + CRect floorArea; + theFloor->GetEquipArea(floorArea); + outRect = floorArea; + + CRect removedArea(0, 0, 0, 0); + POINT pt; + pt.x = inPt.x; + pt.y = inPt.y + 1; + + T2FInfoPtIterator theIterL(*theFloorInfo, inPt); + T2FInfoPtIterator theIterR(*theFloorInfo, pt); + T2Tenant *leftTenant = NULL; + T2Tenant *rightTenant = NULL; + + if (theIterL.LeftTenant(leftTenant) && theIterR.RightTenant(rightTenant)) { + CRect theLeftArea, theRightArea; + leftTenant->GetEquipArea(theLeftArea); + rightTenant->GetEquipArea(theRightArea); + removedArea = CRect(theLeftArea.left, floorArea.top, theRightArea.right, floorArea.bottom); + } + + T2CrossEquipArray *theCEArray = theFloor->GetCEArray(); + LArrayIterator ceIterator(*theCEArray); + unsigned int theMoverID; + + while (ceIterator.Next(&theMoverID)) { + T2Mover *mover = theFloorInfo->GetMover(theMoverID); + if (mover) { + CRect moverArea, intersect; + mover->GetEquipArea(moverArea); +#line 634 + _ASSERT(!intersect.IntersectRect(&removedArea, &moverArea)); + } + } + + T2Request *theDnRequest = NULL; + T2Request *theUpRequest = NULL; + T2Request *theRequest; + T2FInfoAreaIterator requestIterator(*theFloorInfo, removedArea); + + while (requestIterator.NextRequest(theRequest)) { + POINT head = theRequest->GetHeadPosition(); +#line 646 + _ASSERT(!removedArea.PtInRect(head)); + + CRect requestArea; + theRequest->CalcArea(requestArea); + + if (theRequest->GetUpDown() == ERequestUpDown_1) + theDnRequest = theRequest; + else + theUpRequest = theRequest; + + theFloorInfo->RemoveRequestID(theRequest->GetUpDown(), requestArea); + } + + CRect leftArea(floorArea.left, floorArea.top, removedArea.left, floorArea.bottom); + CRect rightArea(removedArea.right, floorArea.top, floorArea.right, floorArea.bottom); +#line 659 + _ASSERT(!leftArea.IsRectEmpty() && !rightArea.IsRectEmpty()); + + T2Tenant *theRightFloor = theFloorInfo->FindUnusedTenant(); +#line 663 + _ASSERT(theRightFloor != NULL); + + theRightFloor->InitTenant(theFloorDef, rightArea, theFloor->GetValiation()); + theRightFloor->SetStatus(kTenantStatus10); + unsigned int theRightFloorID = theRightFloor->GetEquipID(); + + theFloor->SetEquipArea(leftArea); + + unsigned int lastID = 0; + LArrayIterator crossEquipArrayIterator(*theCEArray); + + while (crossEquipArrayIterator.Next(&theMoverID)) { + T2Mover *mover = theFloorInfo->GetMover(theMoverID); + if (mover) { + CRect moverArea, intersect; + mover->GetEquipArea(moverArea); + if (intersect.IntersectRect(rightArea, moverArea)) { + T2CrossEquipArray *moverCEArray = mover->GetCEArray(); + if (moverCEArray) { + moverCEArray->ReplaceID(theFloorID, theRightFloorID); + theFloor->RemoveCEID(theMoverID); + theRightFloor->InsertCEID(lastID, theMoverID); + lastID = theMoverID; + } + } + } + } + + T2FInfoAreaIterator iterator3(*theFloorInfo, rightArea); + T2Tenant *tenant; + + while (iterator3.NextTenant(tenant)) { + if (!tenant->IsFloor()) { + T2CrossEquipArray *tenantCEArray = tenant->GetCEArray(); + if (tenantCEArray) + tenantCEArray->ReplaceID(theFloorID, theRightFloorID); + } + } + + if (theFloor->IsTherePeople()) { + int centerH = (removedArea.left + removedArea.right) / 2; + + T2People *thePeople = theFloor->mFirstPeople; + T2People *theNextPeople = NULL; + for (; thePeople; thePeople = theNextPeople) { + theNextPeople = (T2People *) thePeople->mNext; + + POINT curPt = thePeople->GetCurPosition(); + if (curPt.x < centerH) { + if (curPt.x > (leftArea.right - 2)) + thePeople->MoveHTo(leftArea.right - 2); + } else { + theFloor->Leave(thePeople); + theRightFloor->Enter(thePeople); + } + + thePeople->SetStatus(kStatus2); + } + } + + theFloorInfo->FillTenantID(removedArea, 0); + theFloorInfo->ReplaceFloorID(rightArea, theFloorID, theRightFloorID); + + if (theDnRequest) + theDnRequest->SetDrawWidth(theFloorInfo->FillRequestID(theDnRequest->GetHeadPosition(), ERequestUpDown_1, theDnRequest->GetRequestID())); + if (theUpRequest) + theUpRequest->SetDrawWidth(theFloorInfo->FillRequestID(theUpRequest->GetHeadPosition(), ERequestUpDown_0, theUpRequest->GetRequestID())); + + inDoc->GetRouteNavi()->FloorAdded(theRightFloor, true); + return ProcCode_2; +} + +/*virtual*/ PROCCODE FloorDef::DrawHitMask(T2TowerDoc *doc, T2HaveOutViewObject *object) { + RECT rect; + ((T2Tenant *) object)->GetEquipArea(rect); + UT2Coordinate::UnitToQD(rect, doc->GetZoomLevel()); + doc->GetImage()->FillRect(rect, 1); + return ProcCode_1; +} diff --git a/src/Plugins/Lobby/Floor/FloorDef.h b/src/Plugins/Lobby/Floor/FloorDef.h index dca8270..fde0986 100644 --- a/src/Plugins/Lobby/Floor/FloorDef.h +++ b/src/Plugins/Lobby/Floor/FloorDef.h @@ -1,5 +1,20 @@ #pragma once -#include "common.h" +#include "../../../common.h" +#include "../../../T2DLL/T2TenantDef.h" -class FloorDef { +class FloorDef : public T2TenantDef { +public: + FloorDef(DWORD inType, T2PluginSpecifier &inSpecifier, CResFile *inResFile, T2WorldDef *inWorldDef, T2TenantPlugin *inPlugin); + virtual ~FloorDef(); + virtual void BuildFinish(T2TowerDoc *inDoc, T2Equip *inEquip); + virtual T2InfoDialog *ShowInfoDialog(T2TowerDoc *doc, T2Equip *equip); + virtual unsigned int IdleProc(T2HaveOutViewObject *inObject, T2TowerDoc *inDoc); + virtual void DrawProc(T2HaveOutViewObject *inObject, const RECT &inRect, T2TowerDoc *inDoc) const; + virtual AREACHECKCODE AreaCheck(T2TowerDoc *inDoc, RECT &ioRect, unsigned int inInfo, BOOL inShowError); + virtual int RequierToolIcon(T2ToolWindow *window); + virtual CURSORTYPE + QueryCursor(T2TowerDoc *inDoc, POINT inPt, CString &outSpriteName, RECT &outRect, POINT &outPt, int inZoomLevel, + unsigned int inValiation, int i); + virtual PROCCODE DoDestructProc(T2TowerDoc *inDoc, T2HaveOutViewObject *inObject, POINT inPt, RECT &outRect); + virtual PROCCODE DrawHitMask(T2TowerDoc *doc, T2HaveOutViewObject *object); }; diff --git a/src/Plugins/Lobby/Floor/FloorPlugin.cpp b/src/Plugins/Lobby/Floor/FloorPlugin.cpp index e43b2d3..b77c284 100644 --- a/src/Plugins/Lobby/Floor/FloorPlugin.cpp +++ b/src/Plugins/Lobby/Floor/FloorPlugin.cpp @@ -1,3 +1,4 @@ +#include "StdAfx.h" #include "FloorPlugin.h" #ifdef _DEBUG @@ -5,3 +6,8 @@ #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif + +FloorPlugin::FloorPlugin(DWORD inType, T2PluginSpecifier &inSpecifier) + : T2TenantPlugin(inType, inSpecifier) +{ +} diff --git a/src/Plugins/Lobby/Floor/FloorPlugin.h b/src/Plugins/Lobby/Floor/FloorPlugin.h index a57a05f..2a7d723 100644 --- a/src/Plugins/Lobby/Floor/FloorPlugin.h +++ b/src/Plugins/Lobby/Floor/FloorPlugin.h @@ -1,5 +1,8 @@ #pragma once -#include "common.h" +#include "../../../common.h" +#include "../../../T2DLL/T2TenantPlugin.h" -class FloorPlugin { +class FloorPlugin : public T2TenantPlugin { +public: + FloorPlugin(DWORD inType, T2PluginSpecifier &inSpecifier); }; diff --git a/src/Plugins/Lobby/Floor/Resource.h b/src/Plugins/Lobby/Floor/Resource.h new file mode 100644 index 0000000..8d2cbf7 --- /dev/null +++ b/src/Plugins/Lobby/Floor/Resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by FLOOR.RC +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS + +#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/src/Plugins/Lobby/Floor/StdAfx.cpp b/src/Plugins/Lobby/Floor/StdAfx.cpp new file mode 100644 index 0000000..65ad23f --- /dev/null +++ b/src/Plugins/Lobby/Floor/StdAfx.cpp @@ -0,0 +1,6 @@ +// stdafx.cpp : source file that includes just the standard includes +// Floor.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + diff --git a/src/Plugins/Lobby/Floor/StdAfx.h b/src/Plugins/Lobby/Floor/StdAfx.h new file mode 100644 index 0000000..9fc556e --- /dev/null +++ b/src/Plugins/Lobby/Floor/StdAfx.h @@ -0,0 +1,41 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__AF935A55_9E17_4611_818A_EF6A4343861E__INCLUDED_) +#define AFX_STDAFX_H__AF935A55_9E17_4611_818A_EF6A4343861E__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include <afxwin.h> // MFC core and standard components +#include <afxext.h> // MFC extensions + +#ifndef _AFX_NO_OLE_SUPPORT +#include <afxole.h> // MFC OLE classes +#include <afxodlgs.h> // MFC OLE dialog classes +#include <afxdisp.h> // MFC OLE automation classes +#endif // _AFX_NO_OLE_SUPPORT + + +#ifndef _AFX_NO_DB_SUPPORT +#include <afxdb.h> // MFC ODBC database classes +#endif // _AFX_NO_DB_SUPPORT + +#ifndef _AFX_NO_DAO_SUPPORT +#include <afxdao.h> // MFC DAO database classes +#endif // _AFX_NO_DAO_SUPPORT + +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include <afxcmn.h> // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__AF935A55_9E17_4611_818A_EF6A4343861E__INCLUDED_) diff --git a/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.clw b/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.clw new file mode 100644 index 0000000..4ce1b5c --- /dev/null +++ b/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.clw @@ -0,0 +1,16 @@ +; CLW file contains information for the MFC ClassWizard + +[General Info] +Version=1 +ClassCount=1 +Class1=CDefaultToolPaletteApp +LastClass=CDefaultToolPaletteApp +NewFileInclude2=#include "DefaultToolPalette.h" +ResourceCount=0 +NewFileInclude1=#include "stdafx.h" + +[CLS:CDefaultToolPaletteApp] +Type=0 +HeaderFile=DefaultToolPalette.h +ImplementationFile=DefaultToolPalette.cpp +Filter=N diff --git a/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.cpp b/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.cpp index 6076d35..4f654e3 100644 --- a/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.cpp +++ b/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.cpp @@ -1,7 +1,242 @@ +// DefaultToolPalette.cpp : Defines the initialization routines for the DLL. +// + +#include "stdafx.h" + +#define ATOI_KLUDGE +#include "../../../T2DLL/UT2Utils.h" +#include "../../../T2DLL/T2PaletteAnimeDef.h" +#include "../../../T2DLL/LAttachment.h" +#include "../../../T2DLL/LAttachable.h" +#include "../../../T2DLL/CLink.h" +#include "../../../T2DLL/LArray.h" +#include "../../../T2DLL/LBroadcaster.h" +#include "../../../T2DLL/LListener.h" +#include "../../../T2DLL/T2BitImage.h" +#include "../../../T2DLL/T2ImageObj.h" +#include "../../../T2DLL/T2SpriteObj.h" +#include "../../../T2DLL/Wave.h" +#include "../../../T2DLL/T2SoundPlayer.h" +#include "../../../T2DLL/T2Archive.h" +#include "../../../T2DLL/T2FireWork.h" +#include "../../../T2DLL/T2DlgItemButtonBase.h" +#include "../../../T2DLL/T2DlgItemIButton.h" +#include "../../../T2DLL/T2DlgItemOK.h" +#include "../../../T2DLL/T2DlgItemCANCEL.h" +#include "../../../T2DLL/T2DlgItemTButton.h" +#include "../../../T2DLL/T2DlgItemICheck.h" +#include "../../../T2DLL/T2DlgItemCheck.h" +#include "../../../T2DLL/T2DlgItemScr.h" +#include "../../../T2DLL/T2DlgItemHScr.h" +#include "../../../T2DLL/T2DlgItemVScr.h" +#include "../../../T2DLL/T2DlgItemBox.h" +#include "../../../T2DLL/T2DlgItemText.h" +#include "../../../T2DLL/T2DlgItemGageBase.h" +#include "../../../T2DLL/T2DlgItemStressGage.h" +#include "../../../T2DLL/T2DlgItemPPLEvalGage.h" +#include "../../../T2DLL/T2DlgItemBelongGage.h" +#include "../../../T2DLL/T2DlgItemCustomerGage.h" +#include "../../../T2DLL/T2DlgItemProfitsGage.h" +#include "../../../T2DLL/T2DlgItemImageTable.h" +#include "../../../T2DLL/T2DlgItemImage.h" +#include "../../../T2DLL/CToggleButtonDisabled.h" +#include "../../../T2DLL/T2VerticalTable.h" +#include "../../../T2DLL/T2MovieTable.h" +#include "../../../T2DLL/T2GuestroomTable.h" +#include "../../../T2DLL/T2HallEventTable.h" +#include "../../../T2DLL/CTokenizer.h" +#include "../../../T2DLL/T2Dialog.h" +#include "../../../T2DLL/T2TowerMessage.h" +#include "../../../T2DLL/T2DateTime.h" +#include "../../../T2DLL/T2PluginSpecifier.h" +#include "../../../T2DLL/CResFile.h" +#include "../../../T2DLL/CPlugin.h" +#include "../../../T2DLL/CFilePlugin.h" +#include "../../../T2DLL/CFilePluginList.h" +#include "../../../T2DLL/CFilePluginDB.h" +#include "../../../T2DLL/CResourcePlugin.h" +#include "../../../T2DLL/T2SubPlugin.h" +#include "../../../T2DLL/T2AdvertiseTable.h" +#include "../../../T2DLL/T2AdvertisePlugin.h" +#include "../../../T2DLL/T2HallEventPlugin.h" +#include "../../../T2DLL/T2MoviePlugin.h" +#include "../../../T2DLL/T2EquipInfoDialog.h" +#include "../../../T2DLL/T2TenantInfoDialog.h" +#include "../../../T2DLL/T2Object.h" +#include "../../../T2DLL/T2DrawableObject.h" +#include "../../../T2DLL/T2ObjectArray.h" +#include "../../../T2DLL/CDefRsrcPlugin.h" +#include "../../../T2DLL/T2TemplatePlugin.h" +#include "../../../T2DLL/T2HaveOutViewObject.h" +#include "../../../T2DLL/T2TemplatePluginList.h" +#include "../../../T2DLL/CProgramPlugin.h" +#include "../../../T2DLL/T2TemplatePluginDB.h" +#include "../../../T2DLL/T2ToolPlugin.h" +#include "../../../T2DLL/T2EquipPlugin.h" +#include "../../../T2DLL/T2TenantPlugin.h" +#include "../../../T2DLL/T2MoverPlugin.h" +#include "../../../T2DLL/T2OuterObjPlugin.h" +#include "../../../T2DLL/UT2Coordinate.h" +#include "../../../T2DLL/T2PeoplePtrList.h" +#include "../../../T2DLL/T2ToolDef.h" +#include "../../../T2DLL/T2EquipDef.h" +#include "../../../T2DLL/T2TenantDef.h" +#include "../../../T2DLL/T2MoverDef.h" +#include "../../../T2DLL/T2OuterObjDef.h" +#include "../../../T2DLL/T2SilhouetteDef.h" +#include "../../../T2DLL/T2MatterDef.h" +#include "../../../T2DLL/T2PeopleDef.h" +#include "../../../T2DLL/T2Pool.h" +#include "../../../T2DLL/T2PlaceParamDef.h" +#include "../../../T2DLL/T2TenantMemberTableDef.h" +#include "../../../T2DLL/T2TenantMemberDef.h" +#include "../../../T2DLL/T2PeopleTypeArray.h" +#include "../../../T2DLL/T2PeopleTimeZoneList.h" +#include "../../../T2DLL/T2PeopleDemandList.h" +#include "../../../T2DLL/T2PeopleType.h" +#include "../../../T2DLL/T2Equip.h" +#include "../../../T2DLL/T2Tenant.h" +#include "../../../T2DLL/T2OutObj.h" +#include "../../../T2DLL/T2Matter.h" +#include "../../../T2DLL/T2People.h" +#include "../../../T2DLL/T2PeopleArray.h" +#include "../../../T2DLL/T2PeopleArrayList.h" +#include "../../../T2DLL/T2Request.h" +#include "../../../T2DLL/T2Mover.h" +#include "../../../T2DLL/T2RegistedTenantDB.h" +#include "../../../T2DLL/T2OuterObjList.h" +#include "../../../T2DLL/T2RequestIDArray.h" +#include "../../../T2DLL/T2RequestArray.h" +#include "../../../T2DLL/T2RequestArrayList.h" +#include "../../../T2DLL/T2MoverModule.h" +#include "../../../T2DLL/T2MoverModuleList.h" +#include "../../../T2DLL/T2StairModule.h" +#include "../../../T2DLL/T2StairModuleList.h" +#include "../../../T2DLL/T2ElevatorModule.h" +#include "../../../T2DLL/T2ElvModuleList.h" +#include "../../../T2DLL/T2CrossEquipArray.h" +#include "../../../T2DLL/T2TenantCEArray.h" +#include "../../../T2DLL/T2RouteCEArray.h" +#include "../../../T2DLL/T2FloorCEArray.h" +#include "../../../T2DLL/T2MoverCEArray.h" +#include "../../../T2DLL/T2TenantArray.h" +#include "../../../T2DLL/T2TenantArrayList.h" +#include "../../../T2DLL/T2MoverArray.h" +#include "../../../T2DLL/T2MoverArrayList.h" +#include "../../../T2DLL/T2PeopleLinkIterator.h" +#include "../../../T2DLL/T2UnitInfo.h" +#include "../../../T2DLL/T2FloorInfo.h" +#include "../../../T2DLL/T2FInfoAreaIterator.h" +#include "../../../T2DLL/T2FInfoPtIterator.h" +#include "../../../T2DLL/UT2BkgndInfo.h" +#include "../../../T2DLL/T2EquipPtrList.h" +#include "../../../T2DLL/T2FloorPtrList.h" +#include "../../../T2DLL/T2RoutingTableElem.h" +#include "../../../T2DLL/T2MoverRoutingTable.h" +#include "../../../T2DLL/T2RoutingTable.h" +#include "../../../T2DLL/T2RouteNavigator.h" +#include "../../../T2DLL/T2WorldPlugin.h" +#include "../../../T2DLL/T2WorldDef.h" +#include "../../../T2DLL/T2TrafficInfo.h" +#include "../../../T2DLL/T2NameList.h" +#include "../../../T2DLL/T2PeopleLoader.h" +#include "../../../T2DLL/T2MsgWindowCallback.h" +#include "../../../T2DLL/T2Settlement.h" +#include "../../../T2DLL/T2Name.h" +#include "../../../T2DLL/T2EventItem.h" +#include "../../../T2DLL/T2Maru_Reggae.h" +#include "../../../T2DLL/T2RegistedTenantIterator.h" +#include "../../../T2DLL/T2OptionPlugin.h" +#include "../../../T2DLL/T2OptionPluginList.h" +#include "../../../T2DLL/T2ToolWindow.h" +#include "../../../T2DLL/T2ToolCallback.h" +#include "../../../T2DLL/T2TowerEvent.h" +#include "../../../T2DLL/T2MetroRailway.h" +#include "../../../T2DLL/T2PaletteAnime.h" +#include "../../../T2DLL/T2StewardDialog.h" +#include "../../../T2DLL/T2ClassFactory.h" + #include "DefaultToolPalette.h" +#include "ToolPalette.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif + +// +// Note! +// +// If this DLL is dynamically linked against the MFC +// DLLs, any functions exported from this DLL which +// call into MFC must have the AFX_MANAGE_STATE macro +// added at the very beginning of the function. +// +// For example: +// +// extern "C" BOOL PASCAL EXPORT ExportedFunction() +// { +// AFX_MANAGE_STATE(AfxGetStaticModuleState()); +// // normal function body here +// } +// +// It is very important that this macro appear in each +// function, prior to any calls into MFC. This means that +// it must appear as the first statement within the +// function, even before any object variable declarations +// as their constructors may generate calls into the MFC +// DLL. +// +// Please see MFC Technical Notes 33 and 58 for additional +// details. +// + +///////////////////////////////////////////////////////////////////////////// +// CDefaultToolPaletteApp + +BEGIN_MESSAGE_MAP(CDefaultToolPaletteApp, CWinApp) + //{{AFX_MSG_MAP(CDefaultToolPaletteApp) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CDefaultToolPaletteApp construction + +CDefaultToolPaletteApp::CDefaultToolPaletteApp() +{ +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CDefaultToolPaletteApp object + +CDefaultToolPaletteApp theApp; + +ToolPalette *sToolPalette; + +void *CALLBACK ConstructProgramPlugin(T2PluginSpecifier *inSpecifier) { + if (!sToolPalette) { +#line 47 + sToolPalette = new ToolPalette; + } + + return sToolPalette; +} + +void *CALLBACK DestructProgramPlugin() { + sToolPalette = NULL; + return NULL; +} + +T2PluginSpecifier *GetAttr(T2PluginSpecifier *inSpecifier, CResFile *inResFile, T2WorldDef *inWorldDef, T2TenantPlugin *inPlugin) { +#line 59 + T2PluginSpecifier *specifier = new T2PluginSpecifier; + specifier->mPluginName = "Default Tool palette"; + specifier->mType = 'TOPL'; + specifier->mID = 1000; + specifier->mAttrib = 0xFFFFFFFF; + specifier->mGameLevel = 0; + return specifier; +} diff --git a/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.def b/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.def new file mode 100644 index 0000000..7164b21 --- /dev/null +++ b/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.def @@ -0,0 +1,9 @@ +; DefaultToolPalette.def : Declares the module parameters for the DLL. + +LIBRARY "DEFAULTTOOLPALETTE" +DESCRIPTION 'DEFAULTTOOLPALETTE Windows Dynamic Link Library' + +EXPORTS + ConstructProgramPlugin + DestructProgramPlugin + GetAttr diff --git a/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.dsp b/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.dsp new file mode 100644 index 0000000..c110573 --- /dev/null +++ b/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.dsp @@ -0,0 +1,157 @@ +# Microsoft Developer Studio Project File - Name="DefaultToolPalette" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=DefaultToolPalette - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "DefaultToolPalette.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "DefaultToolPalette.mak" CFG="DefaultToolPalette - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "DefaultToolPalette - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "DefaultToolPalette - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "DefaultToolPalette - Win32 Release" + +# PROP BASE Use_MFC 6 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 6 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_USRDLL" /Yu"stdafx.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" /d "_AFXDLL" +# ADD RSC /l 0x809 /d "NDEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 /nologo /subsystem:windows /dll /machine:I386 + +!ELSEIF "$(CFG)" == "DefaultToolPalette - Win32 Debug" + +# PROP BASE Use_MFC 6 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 6 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "Z:\Users\ash\src\t2-res\dx5\cdrom\sdk\inc" /I "Z:\Users\ash\src\t2-res\dxmedia51\DX51\dxmdev\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_USRDLL" /Yu"stdafx.h" /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" /d "_AFXDLL" +# ADD RSC /l 0x809 /d "_DEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 ../../../T2DLL/Debug/T2DLL.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"..\..\DefaultToolPalette.t2p" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "DefaultToolPalette - Win32 Release" +# Name "DefaultToolPalette - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\DefaultToolPalette.cpp +# End Source File +# Begin Source File + +SOURCE=.\ToolPalette.cpp +# End Source File +# Begin Source File + +SOURCE=.\ToolPaletteItem.cpp +# End Source File +# Begin Source File + +SOURCE=.\DefaultToolPalette.def +# End Source File +# Begin Source File + +SOURCE=.\DefaultToolPalette.rc + +!IF "$(CFG)" == "DefaultToolPalette - Win32 Release" + +!ELSEIF "$(CFG)" == "DefaultToolPalette - Win32 Debug" + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\DefaultToolPalette.h +# End Source File +# Begin Source File + +SOURCE=.\ToolPalette.h +# End Source File +# Begin Source File + +SOURCE=.\ToolPaletteItem.h +# End Source File +# Begin Source File + +SOURCE=.\Resource.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\res\DefaultToolPalette.rc2 +# End Source File +# End Group +# End Target +# End Project diff --git a/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.h b/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.h index e45dd5d..cb431ec 100644 --- a/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.h +++ b/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.h @@ -1,5 +1,45 @@ +// DefaultToolPalette.h : main header file for the DEFAULTTOOLPALETTE DLL +// + +#if !defined(AFX_DEFAULTTOOLPALETTE_H__81154B54_BBFC_4E61_A2BC_BB53B98894B3__INCLUDED_) +#define AFX_DEFAULTTOOLPALETTE_H__81154B54_BBFC_4E61_A2BC_BB53B98894B3__INCLUDED_ + +#if _MSC_VER >= 1000 #pragma once -#include "common.h" +#endif // _MSC_VER >= 1000 + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CDefaultToolPaletteApp +// See DefaultToolPalette.cpp for the implementation of this class +// + +class CDefaultToolPaletteApp : public CWinApp +{ +public: + CDefaultToolPaletteApp(); -class DefaultToolPalette { +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CDefaultToolPaletteApp) + //}}AFX_VIRTUAL + + //{{AFX_MSG(CDefaultToolPaletteApp) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() }; + + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_DEFAULTTOOLPALETTE_H__81154B54_BBFC_4E61_A2BC_BB53B98894B3__INCLUDED_) diff --git a/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.rc b/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.rc new file mode 100644 index 0000000..306f829 --- /dev/null +++ b/src/Plugins/ToolPalette/DefaultToolPalette/DefaultToolPalette.rc @@ -0,0 +1,132 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +128 ATTR "res\\ATTR128_1.txt" + +128 DESC "res\\DESC128_1.txt" + +1000 OBJMAP "res\\OBJMAP1000_1.txt" + +1000 BITMAP "res\\BITMAP1000_1.bmp" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" + "#ifdef _WIN32\r\n" + "LANGUAGE 9, 1\r\n" + "#pragma code_page(1252)\r\n" + "#endif\r\n" + "#include ""res\\DefaultToolPalette.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""afxres.rc"" // Standard components\r\n" + "#endif" + "\0" +END + +///////////////////////////////////////////////////////////////////////////// +#endif // APSTUDIO_INVOKED + + + + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE 9, 1 +#pragma code_page(1252) +#endif + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "DefaultToolPalette DLL\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "DefaultToolPalette\0" + VALUE "LegalCopyright", "Copyright (C) 1997\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename","DefaultToolPalette.DLL\0" + VALUE "ProductName", "DefaultToolPalette Dynamic Link Library\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE 9, 1 +#pragma code_page(1252) +#endif +#include "res\\DefaultToolPalette.rc2" // non-Microsoft Visual C++ edited resources +#include "afxres.rc" // Standard components +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/src/Plugins/ToolPalette/DefaultToolPalette/Resource.h b/src/Plugins/ToolPalette/DefaultToolPalette/Resource.h new file mode 100644 index 0000000..bc66dbf --- /dev/null +++ b/src/Plugins/ToolPalette/DefaultToolPalette/Resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by DEFAULTTOOLPALETTE.RC +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS + +#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/src/Plugins/ToolPalette/DefaultToolPalette/StdAfx.cpp b/src/Plugins/ToolPalette/DefaultToolPalette/StdAfx.cpp new file mode 100644 index 0000000..ef55339 --- /dev/null +++ b/src/Plugins/ToolPalette/DefaultToolPalette/StdAfx.cpp @@ -0,0 +1,6 @@ +// stdafx.cpp : source file that includes just the standard includes +// DefaultToolPalette.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + diff --git a/src/Plugins/ToolPalette/DefaultToolPalette/StdAfx.h b/src/Plugins/ToolPalette/DefaultToolPalette/StdAfx.h new file mode 100644 index 0000000..8eacd17 --- /dev/null +++ b/src/Plugins/ToolPalette/DefaultToolPalette/StdAfx.h @@ -0,0 +1,40 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__AF935A55_9E17_4611_818A_EF6A4343861E__INCLUDED_) +#define AFX_STDAFX_H__AF935A55_9E17_4611_818A_EF6A4343861E__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include <afxwin.h> // MFC core and standard components +#include <afxext.h> // MFC extensions + +#ifndef _AFX_NO_OLE_SUPPORT +#include <afxole.h> // MFC OLE classes +#include <afxodlgs.h> // MFC OLE dialog classes +#include <afxdisp.h> // MFC OLE automation classes +#endif // _AFX_NO_OLE_SUPPORT + + +#ifndef _AFX_NO_DB_SUPPORT +#include <afxdb.h> // MFC ODBC database classes +#endif // _AFX_NO_DB_SUPPORT + +#ifndef _AFX_NO_DAO_SUPPORT +#include <afxdao.h> // MFC DAO database classes +#endif // _AFX_NO_DAO_SUPPORT + +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include <afxcmn.h> // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__AF935A55_9E17_4611_818A_EF6A4343861E__INCLUDED_) diff --git a/src/Plugins/ToolPalette/DefaultToolPalette/ToolPalette.cpp b/src/Plugins/ToolPalette/DefaultToolPalette/ToolPalette.cpp index f290c82..53c032b 100644 --- a/src/Plugins/ToolPalette/DefaultToolPalette/ToolPalette.cpp +++ b/src/Plugins/ToolPalette/DefaultToolPalette/ToolPalette.cpp @@ -1,7 +1,860 @@ +#include "StdAfx.h" #include "ToolPalette.h" +#include "ToolPaletteItem.h" +#include "../../../T2DLL/T2BitImage.h" +#include "../../../T2DLL/T2ImageObj.h" +#include "../../../T2DLL/T2PaletteAnimeDef.h" +#include "../../../T2DLL/T2ToolDef.h" +#include "../../../T2DLL/T2ToolHelpWnd.h" +#include "../../../T2DLL/T2WorldDef.h" +#include "../../../T2TowerDoc.h" -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif +ToolPalette::ToolPalette() { + mSize130.cx = 26; + mSize130.cy = 26; + + mSize138.cx = 76; + mSize138.cy = 13; + + m140 = 16; + m144 = 3; + m148 = 4; + m124 = 0; + + mImageObj = NULL; + mImage = NULL; + mToolHelpWnd = NULL; + + _184 = -1; +} + +/*virtual*/ ToolPalette::~ToolPalette() { + int i; + + for (i = 0; i < kNumCommand; i++) + delete mCommands[i]; + + delete mCategoryTitle; + for (i = 0; i < kNumCategory; i++) + delete mCategories[i]; + delete mCategoryScroll; + + delete mToolTitle; + for (i = 0; i < kNumTool; i++) + delete mTools[i]; + delete mToolScroll; + + if (mImageObj) + delete mImageObj; + if (mImage) + delete mImage; + + POSITION pos = mHistoryList.GetHeadPosition(); + while (pos) + delete mHistoryList.GetNext(pos); +} + +/*virtual*/ void ToolPalette::ItemCallbackDown(ToolPaletteItem *inItem) { + if (inItem->GetMode() != kTPIMode1) + return; + + T2ToolIconItem *icon = inItem->GetIcon(); + if (icon->mEnableCount > 0) + return; + if (icon->m30 == 0) + return; + + T2ToolIconItem *changeIcon = ChangeIconItem(icon); + if (changeIcon && changeIcon->mToolCallback) { + T2ToolCallback *theToolCallback = changeIcon->mToolCallback; + theToolCallback->toolCallback_vf00(this, changeIcon); + } + + T2ToolCallback *theToolCallback = icon->mToolCallback; + if (theToolCallback) + theToolCallback->toolCallback_vf00(this, icon); + + mClickedItem = icon; + m15C = (T2ToolDef *) GetIconPlugin(mSel); + ShowHelpWindow(); +} + +/*virtual*/ void ToolPalette::ItemCallbackUp(ToolPaletteItem *inItem) { + if (mTimerID) + KillTimer(mTimerID); + + HideHelpWindow(); + + if (inItem->GetMode() != kTPIMode1) + return; + + T2ToolIconItem *icon = inItem->GetIcon(); + if (icon->mEnableCount > 0) + return; + if (icon->m30 == 0) + return; + + int i; + if (icon->m18) { + icon->m24 = false; + + switch (icon->mOption) { + case kToolOption0: + for (i = 0; i < kNumCommand; i++) + mCommands[i]->InvalidateRect(NULL); + break; + + case kToolOption4: + for (i = 0; i < kNumCategory; i++) + mCategories[i]->InvalidateRect(NULL); + break; + + case kToolOption1: + case kToolOption2: + case kToolOption3: + for (i = 0; i < kNumTool; i++) + mTools[i]->InvalidateRect(NULL); + break; + } + + T2ToolCallback *theToolCallback = icon->mToolCallback; + if (theToolCallback) + theToolCallback->toolCallback_vf00(this, icon); + } +} + +T2ToolIconItem *ToolPalette::ChangeIconItem(T2ToolIconItem *inItem) { + T2ToolIconItem *result = NULL; + + if (inItem->m18 != 0) { + inItem->m24 = true; + + int i; + switch (inItem->mOption) { + case kToolOption0: + for (i = 0; i < kNumCommand; i++) + mCommands[i]->InvalidateRect(NULL); + break; + case kToolOption4: + for (i = 0; i < kNumCategory; i++) + mCategories[i]->InvalidateRect(NULL); + break; + case kToolOption1: + case kToolOption2: + case kToolOption3: + for (i = 0; i < kNumTool; i++) + mTools[i]->InvalidateRect(NULL); + break; + } + } else { + T2ToolIconItem *oldItem = GetItem(mSel); + ToolHistoryItem *history; + + switch (inItem->mOption) { + case kToolOption0: + mSel = inItem->mID; + Updated(); + break; + + case kToolOption4: { + POSITION pos = mToolIconList->GetHeadPosition(); + T2ToolIconItem *lowItem = NULL; + T2ToolIconItem *theItem; + while (pos) { + theItem = mToolIconList->GetNext(pos); + if (theItem->mOption == kToolOption1 || theItem->mOption == kToolOption2 || theItem->mOption == kToolOption3) { + if (((T2ToolDef *) theItem->mPlugin)->mCategoryNo == inItem->mValiation) { + if (lowItem) { + if (lowItem->mToolDef) { + if (theItem->mToolDef) { + if (theItem->mToolDef->GetSortKey() < lowItem->mToolDef->GetSortKey()) + lowItem = theItem; + } + } else { + lowItem = theItem; + } + } else { + lowItem = theItem; + } + } + } + } + +#line 330 + _ASSERT(lowItem != NULL); + + theItem = lowItem; + mSel = theItem->mID; + history = GetToolHistory(((T2ToolDef *) GetIconPlugin(mSel))->mCategoryNo); + + int theScrollPos = 0; + if (history->_C != -1) { + mSel = history->_C; + theScrollPos = history->_8; + } else { + history->_C = mSel; + history->_8 = theScrollPos; + } + + _184 = mSel; + mToolScroll->SetScrollPos(theScrollPos); + Updated(); + break; + } + + case kToolOption1: + case kToolOption2: + case kToolOption3: + mSel = inItem->mID; + history = GetToolHistory(((T2ToolDef *) GetIconPlugin(mSel))->mCategoryNo); + history->_8 = mToolScroll->GetScrollPos(); + history->_C = mSel; + Updated(); + break; + } + } + + return result; +} + +/*virtual*/ T2ToolIconItem *ToolPalette::EnableIcon(unsigned short inMask) { + T2ToolIconItem *icon = T2ToolWindow::EnableIcon(inMask); + if (icon) { + ChangeIconItem(icon); + ListUpdated(); + } + return icon; +} + +/*virtual*/ int ToolPalette::OnCreateProc(LPCREATESTRUCT lpCreateStruct) { +#pragma var_order(windowRect, y, rect2, x2, y2, i, clientRect, y3, rect1, x) + int i; + + mImageObj = new T2ImageObj; + mImage = new T2BitImage(mModule, 1000, true); + mImageObj->AddObject(mModule, 1000, mImage); + + for (i = 0; i < kNumCommand; i++) + mCommands[i] = new ToolPaletteItem(mDocument, kTPIMode1); + + mCategoryTitle = new ToolPaletteItem(mDocument, kTPIMode0); + for (i = 0; i < kNumCategory; i++) + mCategories[i] = new ToolPaletteItem(mDocument, kTPIMode1); + mCategoryScroll = new ToolPaletteItem(mDocument, kTPIMode2); + + mToolTitle = new ToolPaletteItem(mDocument, kTPIMode0); + for (i = 0; i < kNumTool; i++) + mTools[i] = new ToolPaletteItem(mDocument, kTPIMode1); + mToolScroll = new ToolPaletteItem(mDocument, kTPIMode2); + + mWndClass = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW | CS_NOCLOSE, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH)); + + CRect rect1, rect2; + int x = 0, y = 0, x2, y2, y3; + m14C[kToolHelpMode0] = y + 5; + + for (i = 0; i < kNumCommand; i++) { + x2 = (mSize130.cx - 1) * x + 3; + y2 = (mSize130.cy - 1) * y + 5; + rect1.SetRect(x2, y2, x2 + mSize130.cx, y2 + mSize130.cy); + rect2.UnionRect(rect2, rect1); + mCommands[i]->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect1, this, i + 1000); + + x++; + if (x >= 3) { + x = 0; + y++; + } + } + + x2 = 3; + y = 3; + y2 += mSize130.cy + 4; + rect1.SetRect(x2, y2, x2 + mSize130.cx * 3 - 2, y2 + m140 + 2); + rect2.UnionRect(rect2, rect1); + mCategoryTitle->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect1, this, 1100); + + y2 += m140 + 2; + m14C[kToolHelpMode1] = y2; + + x = 0; + y = 0; + + for (i = 0; i < kNumCategory; i++) { + x2 = (mSize130.cx - 1) * x + 3; + y3 = y2 + (mSize130.cy - 1) * y; + rect1.SetRect(x2, y3, x2 + mSize130.cx, y3 + mSize130.cy); + rect2.UnionRect(rect2, rect1); + mCategories[i]->Create(mWndClass, "", WS_CHILD, rect1, this, i + 1200); + + y++; + if (y >= 3) { + y = 0; + x++; + } + } + y = 3; + + y2 += (mSize130.cy - 1) * y; + x2 = 3; + rect1.SetRect(x2, y2, x2 + mSize138.cx, y2 + mSize138.cy); + rect2.UnionRect(rect2, rect1); + mCategoryScroll->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect1, this, 1300); + + y = m140; + y2 += mSize138.cy + 6; + rect1.SetRect(x2, y2, x2 + mSize130.cx * 3 - 2, y2 + y + 2); + rect2.UnionRect(rect2, rect1); + mToolTitle->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect1, this, 1400); + + y2 += y + 2; + m14C[kToolHelpMode2] = y2; + + x = 0; + y = 0; + + for (i = 0; i < kNumTool; i++) { + x2 = (mSize130.cx - 1) * x + 3; + y3 = y2 + (mSize130.cy - 1) * y; + rect1.SetRect(x2, y3, x2 + mSize130.cx, y3 + mSize130.cy); + rect2.UnionRect(rect2, rect1); + mTools[i]->Create(mWndClass, "", WS_CHILD, rect1, this, i + 1500); + + y++; + if (y >= 4) { + y = 0; + x++; + } + } + y = 4; + + y2 += (mSize130.cy - 1) * y; + x2 = 3; + rect1.SetRect(x2, y2, x2 + mSize138.cx, y2 + mSize138.cy); + rect2.UnionRect(rect2, rect1); + mToolScroll->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect1, this, 1600); + + CRect windowRect; + GetWindowRect(windowRect); + + CRect clientRect; + GetClientRect(clientRect); + + SetWindowPos( + NULL, + 0, + 0, + rect2.Width() + (windowRect.Width() - clientRect.Width()) + 6, + rect2.Height() + (windowRect.Height() - clientRect.Height()) + 11, + SWP_NOMOVE | SWP_NOZORDER + ); + + m124 = true; + ListUpdated(); + Updated(); + + return 0; +} + +/*virtual*/ BOOL ToolPalette::OnEraseBkgndProc(CDC *pDC) { + int saved = pDC->SaveDC(); + pDC->SelectPalette(mWorldDef->GetPalette(), false); + pDC->RealizePalette(); + + CBrush backBrush; + backBrush.CreateStockObject(LTGRAY_BRUSH); + + CRect rect1; + GetClientRect(rect1); + pDC->FillRect(rect1, &backBrush); + + CPen pen1; + pen1.CreatePen(PS_SOLID, 0, PALETTEINDEX(T2PaletteAnimeDef::GetCommonColor(0))); + + CPen pen2; + pen2.CreatePen(PS_SOLID, 0, PALETTEINDEX(T2PaletteAnimeDef::GetCommonColor(3))); + + CRect rect2, rect3; + GetClientRect(rect2); + + pDC->SelectObject(pen1); + pDC->MoveTo(rect2.right - 1, rect2.top); + pDC->LineTo(rect2.left, rect2.top); + pDC->LineTo(rect2.left, rect2.bottom); + + pDC->SelectObject(pen2); + pDC->MoveTo(rect2.right - 1, rect2.top + 1); + pDC->LineTo(rect2.right - 1, rect2.bottom - 1); + pDC->LineTo(rect2.left, rect2.bottom - 1); + + mCategoryTitle->GetWindowRect(rect2); + ScreenToClient(rect2); + + mCategoryScroll->GetWindowRect(rect3); + ScreenToClient(rect3); + + pDC->SelectObject(pen2); + pDC->MoveTo(rect3.right, rect2.top - 1); + pDC->LineTo(rect2.left - 1, rect2.top - 1); + pDC->LineTo(rect2.left - 1, rect3.bottom + 1); + + pDC->SelectObject(pen1); + pDC->MoveTo(rect3.right, rect2.top); + pDC->LineTo(rect3.right, rect3.bottom); + pDC->LineTo(rect3.left - 1, rect3.bottom); + + mToolTitle->GetWindowRect(rect2); + ScreenToClient(rect2); + + mToolScroll->GetWindowRect(rect3); + ScreenToClient(rect3); + + pDC->SelectObject(pen2); + pDC->MoveTo(rect3.right, rect2.top - 1); + pDC->LineTo(rect2.left - 1, rect2.top - 1); + pDC->LineTo(rect2.left - 1, rect3.bottom + 1); + + pDC->SelectObject(pen1); + pDC->MoveTo(rect3.right, rect2.top); + pDC->LineTo(rect3.right, rect3.bottom); + pDC->LineTo(rect3.left - 1, rect3.bottom); + + pDC->RestoreDC(saved); + return true; +} + +/*virtual*/ void ToolPalette::OnSizeProc(UINT nType, int cx, int cy) { +} + +/*virtual*/ void ToolPalette::Updated() { + if (!m124) + return; + + T2ToolDef *thePlugin; + T2ToolIconItem *icon; + int theCategoryNo; + POSITION pos; + + int theOption = GetIconOption(mSel); + BYTE isChange = 0; + + switch (theOption) { + case kToolOption1: + case kToolOption2: + case kToolOption3: + thePlugin = (T2ToolDef *) GetIconPlugin(mSel); +#line 596 + _ASSERT(thePlugin != NULL); + + theCategoryNo = thePlugin->mCategoryNo; + pos = mToolIconList->GetHeadPosition(); + while (pos) { + icon = mToolIconList->GetNext(pos); + switch (icon->mOption) { + case kToolOption4: + if (icon->mValiation == theCategoryNo) { + if (!icon->m24) { + icon->m24 = true; + isChange |= 1; + } + } else { + if (icon->m24) { + icon->m24 = false; + isChange |= 1; + } + } + break; + + case kToolOption1: + case kToolOption2: + case kToolOption3: + if (icon->mID == mSel) { + ToolHistoryItem *history = GetToolHistory(((T2ToolDef *) GetIconPlugin(mSel))->mCategoryNo); + if (history->_C == -1) { + history->_C = mSel; + history->_8 = 0; + } + if (!icon->m24) { + icon->m24 = true; + isChange |= 2; + } + + mCategoryTitle->SetText(thePlugin->mCategoryName); + mToolTitle->SetText(*thePlugin->mToolName[icon->mValiation]); + } else { + if (icon->m24) { + icon->m24 = false; + isChange |= 2; + } + } + break; + + case kToolOption0: + if (icon->m24) { + icon->m24 = false; + isChange |= 4; + } + break; + } + } + + if (isChange & 1) { + for (int i = 0; i < kNumCategory; i++) + mCategories[i]->InvalidateRect(NULL); + ChangeCategory(theCategoryNo); + } + if (isChange & 2) { + for (int i = 0; i < kNumTool; i++) + mTools[i]->InvalidateRect(NULL); + } + if (isChange & 4) { + for (int i = 0; i < kNumCommand; i++) + mCommands[i]->InvalidateRect(NULL); + } + + mDocument->SetCursorType(kCursorDefault, false); + break; + + case kToolOption0: + pos = mToolIconList->GetHeadPosition(); + while (pos) { + icon = mToolIconList->GetNext(pos); + switch (icon->mOption) { + case kToolOption1: + case kToolOption2: + case kToolOption3: + if (icon->m24) { + icon->m24 = false; + isChange |= 1; + } + break; + + case kToolOption4: + if (icon->m24) { + icon->m24 = false; + isChange |= 2; + } + break; + + case kToolOption0: + if (icon->mID == mSel) { + if (!icon->m24) { + icon->m24 = true; + isChange |= 4; + } + } else { + if (icon->m24) { + icon->m24 = false; + isChange |= 4; + } + } + break; + } + } + + if (isChange & 1) { + for (int i = 0; i < kNumCategory; i++) + mCategories[i]->InvalidateRect(NULL); + ChangeCategory(); + } + if (isChange & 2) { + for (int i = 0; i < kNumTool; i++) + mTools[i]->InvalidateRect(NULL); + } + + if (isChange && 4) { + for (int i = 0; i < kNumCommand; i++) + mCommands[i]->InvalidateRect(NULL); + } + if (isChange) { + mCategoryTitle->SetText(""); + mToolTitle->SetText(""); + } + + mDocument->SetCursorType(mSel, false); + break; + } + + if (isChange) { + mCategoryTitle->InvalidateRect(NULL); + mToolTitle->InvalidateRect(NULL); + } +} + +/*virtual*/ void ToolPalette::ListUpdated() { + if (!m124) + return; + + UpdateCommand(); + UpdateCategory(); + UpdateTool(); +} + +void ToolPalette::UpdateScroll(ToolPaletteItem *inItem) { + if (inItem == mCategoryScroll) + UpdateCategory(); + + if (inItem == mToolScroll) { + UpdateTool(); + if (_184 != -1) { + ToolHistoryItem *history = GetToolHistory(((T2ToolDef *) GetIconPlugin(_184))->mCategoryNo); + history->_8 = mToolScroll->GetScrollPos(); + } + } +} + +static const char *commandNames[] = { + "ToolDestruct", + "ToolFinger", + "ToolInfo", + "ToolZoom", + "ToolHand", + "ToolMic", + "ToolRoot" +}; + +void ToolPalette::UpdateCommand() { + BOOL valid = true; + int i; + + for (i = 0; i < kNumCommand; i++) { + if (GetID(commandNames[i], 0) == -1) { + valid = false; + break; + } + } + + if (valid) { + for (i = 0; i < kNumCommand; i++) + mCommands[i]->SetIcon(GetItem(commandNames[i], 0)); + } +} + +void ToolPalette::UpdateCategory() { + int baseIndex = mCategoryScroll->GetScrollPos() * m144; + int currIndex = 0; + int numIcons = 0; + CList<T2ToolIconItem *, T2ToolIconItem *> iconList; + + POSITION pos = mToolIconList->GetHeadPosition(); + while (pos) { + T2ToolIconItem *icon = mToolIconList->GetNext(pos); + if (icon->mOption == kToolOption4) { + BOOL added = false; + if (icon->mToolDef) { + POSITION pos2 = iconList.GetHeadPosition(); + while (pos2) { + POSITION prevPos2 = pos2; + T2ToolIconItem *icon2 = iconList.GetNext(pos2); + if (icon2->mToolDef && icon2->mToolDef->GetSortKey() > icon->mToolDef->GetSortKey()) { + iconList.InsertBefore(prevPos2, icon); + added = true; + break; + } + } + } + + if (!added) + iconList.AddTail(icon); + } + } + + pos = iconList.GetHeadPosition(); + while (pos) { + T2ToolIconItem *icon = iconList.GetNext(pos); + if (currIndex >= baseIndex && numIcons < kNumCategory) { + mCategories[numIcons]->SetIcon(icon); + mCategories[numIcons]->ShowWindow(SW_SHOW); + numIcons++; + } + currIndex++; + } + + for (; numIcons < kNumCategory; numIcons++) + mCategories[numIcons]->ShowWindow(SW_HIDE); + + currIndex = ((currIndex + m144 - 1) / m144) - 3; + if (currIndex < 0) + currIndex = 0; + mCategoryScroll->SetScrollRange(currIndex); +} + +void ToolPalette::UpdateTool() { + T2ToolIconItem *icon; + POSITION pos = mToolIconList->GetHeadPosition(); + + while (pos) { + icon = mToolIconList->GetNext(pos); + if (icon->mOption == kToolOption4 && icon->m24) { + ChangeCategory(icon->mValiation); + break; + } + } +} + +void ToolPalette::ChangeCategory(int inCategory) { + if (!m124) + return; + + int baseIndex = mToolScroll->GetScrollPos() * m148; + int currIndex = 0; + int numIcons = 0; + CList<T2ToolIconItem *, T2ToolIconItem *> iconList; + + POSITION pos = mToolIconList->GetHeadPosition(); + while (pos) { + T2ToolIconItem *icon = mToolIconList->GetNext(pos); + if (icon->mOption == kToolOption1 || icon->mOption == kToolOption2 || icon->mOption == kToolOption3) { + if (((T2ToolDef *) icon->mPlugin)->mCategoryNo == inCategory) { + BOOL added = false; + if (icon->mToolDef) { + POSITION pos2 = iconList.GetHeadPosition(); + while (pos2) { + POSITION prevPos2 = pos2; + T2ToolIconItem *icon2 = iconList.GetNext(pos2); + if (icon2->mToolDef && icon2->mToolDef->GetSortKey() > icon->mToolDef->GetSortKey()) { + iconList.InsertBefore(prevPos2, icon); + added = true; + break; + } + } + } + + if (!added) + iconList.AddTail(icon); + } + } + } + + pos = iconList.GetHeadPosition(); + while (pos) { + T2ToolIconItem *icon = iconList.GetNext(pos); + if (currIndex >= baseIndex && numIcons < kNumTool) { + mTools[numIcons]->SetIcon(icon); + mTools[numIcons]->ShowWindow(SW_SHOW); + numIcons++; + } + currIndex++; + } + + for (; numIcons < kNumTool; numIcons++) + mTools[numIcons]->ShowWindow(SW_HIDE); + + currIndex = ((currIndex + m148 - 1) / m148) - 3; + if (currIndex < 0) + currIndex = 0; + mToolScroll->SetScrollRange(currIndex); +} + +void ToolPalette::ChangeCategory() { + if (!m124) + return; + + for (int i = 0; i < kNumTool; i++) + mTools[i]->ShowWindow(SW_HIDE); + mToolScroll->SetScrollRange(0); +} + +/*virtual*/ void ToolPalette::RedrawButton() { + if (!m124) + return; + + int i; + for (i = 0; i < kNumCategory; i++) + mCategories[i]->InvalidateRect(NULL); + for (i = 0; i < kNumTool; i++) + mTools[i]->InvalidateRect(NULL); + for (i = 0; i < kNumCommand; i++) + mCommands[i]->InvalidateRect(NULL); +} + +void ToolPalette::ShowHelpWindow() { + HideHelpWindow(); + + int mode; + switch (mClickedItem->mOption) { + case kToolOption0: + mode = kToolHelpMode0; + break; + case kToolOption4: + mode = kToolHelpMode1; + break; + default: + mode = kToolHelpMode2; + break; + } + + RECT rect; + GetWindowRect(&rect); + + mToolHelpPt.y = GetSystemMetrics(SM_CYSMSIZE); + mToolHelpPt.y += rect.top; + mToolHelpPt.x = rect.right + 8; + mToolHelpPt.y += m14C[mode]; + + CString text; + mToolHelpValiation = mClickedItem->mValiation; + mToolHelpMode = mode; + + switch (mode) { + case kToolHelpMode0: + mToolHelpStr2 = mClickedItem->m2C; + break; + case kToolHelpMode1: + mToolHelpStr1 = m15C->mCategoryName; + mToolHelpStr2 = m15C->mCategoryCommentString; + break; + case kToolHelpMode2: + mToolHelpDef = m15C; + break; + } + + mToolHelpWnd = new T2ToolHelpWnd; + StartTimer(500); +} + +void ToolPalette::HideHelpWindow() { + if (mToolHelpWnd) { + mToolHelpWnd->CloseToolHelp(); + mToolHelpWnd = NULL; + } + StopTimer(); +} + +/*virtual*/ void ToolPalette::OnTimerProc(UINT nIDEvent) { + mToolHelpWnd->OpenToolHelp(mToolHelpPt, mToolHelpMode, mToolHelpStr1, mToolHelpStr2, mToolHelpDef, mToolHelpValiation); + StopTimer(); +} + +ToolHistoryItem *ToolPalette::GetToolHistory(int inID) { + ToolHistoryItem *history; + POSITION pos = mHistoryList.GetHeadPosition(); + while (pos) { + history = mHistoryList.GetNext(pos); + if (history->_4 == inID) + return history; + } + + history = new ToolHistoryItem; + history->_4 = inID; + mHistoryList.AddTail(history); + return history; +} + + +ToolHistoryItem::ToolHistoryItem() { + _4 = -1; + _8 = 0; + _C = -1; +} + +/*virtual*/ ToolHistoryItem::~ToolHistoryItem() { +} + + + +ToolHistoryList::ToolHistoryList() { +} + +/*virtual*/ ToolHistoryList::~ToolHistoryList() { +} diff --git a/src/Plugins/ToolPalette/DefaultToolPalette/ToolPalette.h b/src/Plugins/ToolPalette/DefaultToolPalette/ToolPalette.h index 70ecbcc..c36f8dd 100644 --- a/src/Plugins/ToolPalette/DefaultToolPalette/ToolPalette.h +++ b/src/Plugins/ToolPalette/DefaultToolPalette/ToolPalette.h @@ -1,5 +1,86 @@ #pragma once -#include "common.h" +#include "../../../common.h" +#include "../../../T2DLL/T2ToolWindow.h" -class ToolPalette { +class ToolPaletteItem; + +class AFX_CLASS_EXPORT ToolHistoryItem { +public: + ToolHistoryItem(); + virtual ~ToolHistoryItem(); + + int _4; + int _8; + int _C; +}; + +class AFX_CLASS_EXPORT ToolHistoryList : public CList<ToolHistoryItem *, ToolHistoryItem *> { +public: + ToolHistoryList(); + virtual ~ToolHistoryList(); +}; + +class AFX_CLASS_EXPORT ToolPalette : public T2ToolWindow { +public: + ToolPalette(); + virtual ~ToolPalette(); + T2ToolIconItem *ChangeIconItem(T2ToolIconItem *inItem); + virtual T2ToolIconItem *EnableIcon(unsigned short inMask); + virtual int OnCreateProc(LPCREATESTRUCT lpCreateStruct); + virtual BOOL OnEraseBkgndProc(CDC *pDC); + virtual void OnSizeProc(UINT nType, int cx, int cy); + void UpdateScroll(ToolPaletteItem *inItem); + void UpdateCommand(); + void UpdateCategory(); + void UpdateTool(); + virtual void OnTimerProc(UINT nIDEvent); + virtual void RedrawButton(); + virtual void ItemCallbackDown(ToolPaletteItem *inItem); + virtual void ItemCallbackUp(ToolPaletteItem *inItem); + + enum { + kNumCommand = 7, + kNumCategory = 9, + kNumTool = 12 + }; + + T2ImageObj *mImageObj; + BOOL m124; + T2BitImage *mImage; + CString mWndClass; + CSize mSize130; + CSize mSize138; + int m140; + int m144; + int m148; + int m14C[3]; + T2ToolIconItem *mClickedItem; + T2ToolDef *m15C; + POINT mToolHelpPt; + ToolHistoryList mHistoryList; + int _184; + ToolPaletteItem *mCommands[kNumCommand]; + ToolPaletteItem *mCategoryTitle; + ToolPaletteItem *mCategories[kNumCategory]; + ToolPaletteItem *mCategoryScroll; + ToolPaletteItem *mToolTitle; + ToolPaletteItem *mTools[kNumTool]; + ToolPaletteItem *mToolScroll; + T2ToolHelpWnd *mToolHelpWnd; + CString mToolHelpStr1; + CString mToolHelpStr2; + T2ToolDef *mToolHelpDef; + int mToolHelpValiation; + int mToolHelpMode; + +protected: + virtual void Updated(); + virtual void ListUpdated(); + ToolHistoryItem *GetToolHistory(int inID); + +private: + void ChangeCategory(int inCategory); + void ChangeCategory(); + void ShowHelpWindow(); + void HideHelpWindow(); }; diff --git a/src/Plugins/ToolPalette/DefaultToolPalette/ToolPaletteItem.cpp b/src/Plugins/ToolPalette/DefaultToolPalette/ToolPaletteItem.cpp index ad675b8..f4993fc 100644 --- a/src/Plugins/ToolPalette/DefaultToolPalette/ToolPaletteItem.cpp +++ b/src/Plugins/ToolPalette/DefaultToolPalette/ToolPaletteItem.cpp @@ -1,7 +1,269 @@ +#include "StdAfx.h" +#include "ToolPalette.h" #include "ToolPaletteItem.h" +#include "../../../T2DLL/T2ImageObj.h" +#include "../../../T2DLL/T2ToolWindow.h" +#include "../../../T2DLL/T2WorldDef.h" +#include "../../../T2TowerDoc.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif + +ToolPaletteItem::ToolPaletteItem() { +} + +ToolPaletteItem::ToolPaletteItem(T2TowerDoc *inDoc, int inMode) { + ToolPaletteItem(); + + mIcon = NULL; + mMode = inMode; + mDocument = inDoc; + mPalette = inDoc->mWorldDef->GetPalette(); + mStatus = 0; + mScrollPos = 0; + mScrollRange = 0; + mOption = 0; + + if (inMode == kTPIMode2) + mStatus = 22; +} + +/*virtual*/ ToolPaletteItem::~ToolPaletteItem() { +} + +BEGIN_MESSAGE_MAP(ToolPaletteItem, CWnd) + //{{AFX_MSG_MAP(ToolPaletteItem) + ON_WM_ERASEBKGND() + ON_WM_LBUTTONDOWN() + ON_WM_LBUTTONUP() + ON_WM_MOUSEMOVE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +/*virtual*/ int ToolPaletteItem::GetScrollPos() { + return mScrollPos; +} + +/*virtual*/ void ToolPaletteItem::SetScrollRange(int inRange) { + if (mScrollRange != inRange) { + mScrollRange = inRange; + SetScrollStatus(false, false); + if (mScrollPos > mScrollRange) + mScrollPos = mScrollRange; + + ((ToolPalette *) GetParent())->ItemCallbackDown(this); + } +} + +/*virtual*/ void ToolPaletteItem::SetScrollPos(int inPos) { + if (mScrollPos != inPos) + mScrollPos = inPos; +} + +void ToolPaletteItem::SetScrollStatus(BOOL inLeftPressed, BOOL inRightPressed) { + int theStatusL = inLeftPressed ? 1 : 0; + int theStatusR = inRightPressed ? 1 : 0; + if (mScrollPos == 0) + theStatusL = 2; + if (mScrollPos == mScrollRange) + theStatusR = 2; + mStatus = theStatusL * 10 + theStatusR; + InvalidateRect(NULL); +} + +/*virtual*/ void ToolPaletteItem::SetStatus(int inStatus) { + mStatus = inStatus; + InvalidateRect(NULL); +} + +/*virtual*/ int ToolPaletteItem::GetOption() { + return mOption; +} + +/*virtual*/ void ToolPaletteItem::SetOption(int inOption) { + mOption = inOption; +} + +/*virtual*/ void ToolPaletteItem::SetIcon(T2ToolIconItem *inItem) { + mIcon = inItem; + InvalidateRect(NULL); +} + +/*virtual*/ void ToolPaletteItem::SetText(const char *inText) { + SetWindowText(inText); +} + +/*virtual*/ int ToolPaletteItem::GetMode() { + return mMode; +} + +/*virtual*/ T2ToolIconItem *ToolPaletteItem::GetIcon() { + return mIcon; +} + +BOOL ToolPaletteItem::OnEraseBkgnd(CDC *pDC) { + CRect clientRect; + GetClientRect(clientRect); + + int save = pDC->SaveDC(); + pDC->SelectPalette(mPalette, false); + pDC->RealizePalette(); + + CBrush brush; + CPen pen; + CFont font; + + if (mMode == kTPIMode1 && mIcon->mName != "") { + int pattern = mIcon->mValiation * 10; + if (mIcon->m30) { + if (mIcon->mEnableCount > 0) + pattern += 2; + else + pattern += mIcon->m24 ? 1 : 0; + } else { + pattern += 2; + } + + int index = mDocument->mWorldDef->m1D0->FindObject(mIcon->mName, pattern); + if (index < 0) { + if (mIcon->m30) { + if (mIcon->mEnableCount > 0) { + pattern -= 2; + index = mDocument->mWorldDef->m1D0->FindObject(mIcon->mName, pattern); + } + } else { + pattern -= 2; + index = mDocument->mWorldDef->m1D0->FindObject(mIcon->mName, pattern); + } + } + +#line 172 + _ASSERT(index >= 0); + + mDocument->mWorldDef->m1D0->DrawObject(pDC, index, clientRect); + + } else if (mMode == kTPIMode0) { + brush.CreateSolidBrush(PALETTERGB(255, 255, 255)); + pen.CreateStockObject(BLACK_PEN); + + pDC->SelectObject(brush); + pDC->SelectObject(pen); + pDC->Rectangle(clientRect); + + CString text; + GetWindowText(text); + + int currWidth, width; + currWidth = width = clientRect.Width(); + + unsigned int textLen = strlen(text); + if (textLen > 8) + currWidth /= textLen; + else + currWidth = 7; + + currWidth = -currWidth; + + CRect theRect; + BOOL isWidthFinish = false; + while (!isWidthFinish) { + theRect = clientRect; + theRect.top += 1; + theRect.left += 1; + theRect.bottom -= 1; + theRect.right -= 1; + + font.CreateFont(-15, currWidth, 0, 0, FW_DONTCARE, false, false, false, DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, DRAFT_QUALITY, FIXED_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E"); + pDC->SelectObject(font); + pDC->SetTextColor(RGB(0, 0, 0)); + pDC->SetBkMode(TRANSPARENT); + pDC->DrawText(text, theRect, DT_CENTER | DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX); + if (width >= theRect.Width()) + isWidthFinish = true; + else + currWidth++; + } + + int textWidth = theRect.Width(); + int textHeight = theRect.Height(); + + TEXTMETRIC textMetric; + pDC->GetTextMetrics(&textMetric); + + CPoint textCenterPt = clientRect.CenterPoint(); + theRect.top = textCenterPt.y - textHeight / 2; + theRect.bottom = theRect.top + textHeight; + theRect.left = textCenterPt.x - textWidth / 2; + theRect.right = theRect.left + textWidth; + + pDC->DrawText(text, theRect, DT_CENTER | DT_WORDBREAK | DT_NOPREFIX); + } else if (mMode == kTPIMode2) { + T2ImageObj *theImageObj = ((ToolPalette *) GetParent())->mImageObj; + int index = theImageObj->FindObject("ScrollButton", mStatus); + theImageObj->DrawObject(pDC, index, clientRect); + } else { + brush.CreateSolidBrush(PALETTERGB(255, 255, 255)); + pen.CreateStockObject(BLACK_PEN); + + pDC->SelectObject(brush); + pDC->SelectObject(pen); + pDC->Rectangle(clientRect); + } + + pDC->RestoreDC(save); + return true; +} + +void ToolPaletteItem::OnLButtonDown(UINT nFlags, CPoint point) { + SetCapture(); + + switch (mMode) { + case kTPIMode1: + ((ToolPalette *) GetParent())->ItemCallbackDown(this); + break; + case kTPIMode2: + if (point.x < 38) + SetScrollStatus(true, false); + else + SetScrollStatus(false, true); + break; + } +} + +void ToolPaletteItem::OnLButtonUp(UINT nFlags, CPoint point) { + if (mMode == kTPIMode1) + ((ToolPalette *) GetParent())->ItemCallbackUp(this); + + if (mMode == kTPIMode2) { + BOOL changed = false; + if (point.x < 38) { + if (mScrollPos != 0) { + mScrollPos--; + changed = true; + } + } else { + if (mScrollPos < mScrollRange) { + mScrollPos++; + changed = true; + } + } + + if (changed) + ((ToolPalette *) GetParent())->UpdateScroll(this); + + SetScrollStatus(false, false); + } + + if (::GetCapture() == m_hWnd) + ReleaseCapture(); +} + +void ToolPaletteItem::OnMouseMove(UINT nFlags, CPoint point) { + CWinApp *app = AfxGetApp(); + HCURSOR cursorH = app->LoadStandardCursor(IDC_ARROW); + if (cursorH) + SetCursor(cursorH); +} diff --git a/src/Plugins/ToolPalette/DefaultToolPalette/ToolPaletteItem.h b/src/Plugins/ToolPalette/DefaultToolPalette/ToolPaletteItem.h index bee9108..b119b17 100644 --- a/src/Plugins/ToolPalette/DefaultToolPalette/ToolPaletteItem.h +++ b/src/Plugins/ToolPalette/DefaultToolPalette/ToolPaletteItem.h @@ -1,5 +1,50 @@ #pragma once -#include "common.h" +#include "../../../common.h" -class ToolPaletteItem { +enum { + kTPIMode0 = 0, + kTPIMode1 = 1, + kTPIMode2 = 2 +}; + +class AFX_CLASS_EXPORT ToolPaletteItem : public CWnd { +protected: + ToolPaletteItem(); +public: + ToolPaletteItem(T2TowerDoc *inDoc, int inMode); + virtual ~ToolPaletteItem(); + + virtual void SetIcon(T2ToolIconItem *inItem); + virtual void SetText(const char *inText); + virtual void SetScrollRange(int inRange); + virtual void SetScrollPos(int inPos); + virtual void SetStatus(int inStatus); + virtual int GetOption(); + virtual void SetOption(int inOption); + virtual int GetScrollPos(); + virtual int GetMode(); + virtual T2ToolIconItem *GetIcon(); + + int mMode; + T2TowerDoc *mDocument; + CPalette *mPalette; + T2ToolIconItem *mIcon; + int mStatus; + int mOption; + int mScrollPos; + int mScrollRange; + + //{{AFX_VIRTUAL(ToolPaletteItem) + //}}AFX_VIRTUAL + +protected: + void SetScrollStatus(BOOL inLeftPressed, BOOL inRightPressed); + + //{{AFX_MSG(ToolPaletteItem) + afx_msg BOOL OnEraseBkgnd(CDC *pDC); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() }; @@ -15,6 +15,18 @@ Package=<4> ############################################################################### +Project: "Floor"=.\Plugins\Lobby\Floor\Floor.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + Project: "T2"=.\T2.DSP - Package Owner=<4> Package=<5> diff --git a/src/T2DLL/CLink.h b/src/T2DLL/CLink.h index 1049b40..5e9d025 100644 --- a/src/T2DLL/CLink.h +++ b/src/T2DLL/CLink.h @@ -17,13 +17,8 @@ public: void SetNext(CLink* l) { mNext = l; } void SetPrev(CLink* l) { mPrev = l; } -protected: CLink *mNext; CLink *mPrev; - - friend class CLinkIterator; - friend class DbgPeopleView; - friend class T2PeopleLinkIterator; }; class AFX_CLASS_EXPORT CLinkIterator { diff --git a/src/T2DLL/T2DLL.DSP b/src/T2DLL/T2DLL.DSP index 69b46d8..aa54e41 100644 --- a/src/T2DLL/T2DLL.DSP +++ b/src/T2DLL/T2DLL.DSP @@ -67,7 +67,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /Yu"stdafx.h" /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "Z:\Users\ash\src\t2-res\dx5\cdrom\sdk\inc" /I "Z:\Users\ash\src\t2-res\dxmedia51\DX51\dxmdev\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_USRDLL" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "Z:\Users\ash\src\t2-res\dx5\cdrom\sdk\inc" /I "Z:\Users\ash\src\t2-res\dxmedia51\DX51\dxmdev\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_USRDLL" /D "HACKS" /Yu"stdafx.h" /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" /d "_AFXDLL" @@ -77,7 +77,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ole32.lib winmm.lib strmiids.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept /libpath:"Z:\Users\ash\src\t2-res\dx5\cdrom\sdk\lib" /libpath:"Z:\Users\ash\src\t2-res\dxmedia51\DX51\dxmdev\lib" +# ADD LINK32 ole32.lib winmm.lib strmiids.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"../T2DLL.dll" /pdbtype:sept /libpath:"Z:\Users\ash\src\t2-res\dx5\cdrom\sdk\lib" /libpath:"Z:\Users\ash\src\t2-res\dxmedia51\DX51\dxmdev\lib" !ENDIF diff --git a/src/T2DLL/T2EquipDef.h b/src/T2DLL/T2EquipDef.h index 93f2290..cf09e52 100644 --- a/src/T2DLL/T2EquipDef.h +++ b/src/T2DLL/T2EquipDef.h @@ -3,6 +3,12 @@ #include "../common.h" #include "T2ToolDef.h" +enum { + kAreaCheckFlag100 = 0x100, + kAreaCheckFlag1000 = 0x1000, + kAreaCheckFlag10000 = 0x10000, +}; + class AFX_CLASS_EXPORT T2EquipDef : public T2ToolDef { public: T2EquipDef(DWORD type, T2PluginSpecifier& specifier, CResFile* resFile, T2WorldDef* worldDef, T2EquipPlugin* plugin); diff --git a/src/T2DLL/T2Tenant.h b/src/T2DLL/T2Tenant.h index 1336aa1..c9c881a 100644 --- a/src/T2DLL/T2Tenant.h +++ b/src/T2DLL/T2Tenant.h @@ -203,6 +203,26 @@ public: int GetReserveCount() const; void CancelReserve(); + T2People *mFirstPeople; + T2People *m64; + int mMerchandiseCount; + int mMerchandise[4]; + int mResideDay; + int mKindIndex; + int mMark; + BOOL mIsBind; + int mPeopleEstimate; + int mEstimate; + unsigned int mRelatedTenantID; + int mReserveCount; + int mBelongCount; + int mCustomerCount; + int mWorkCount; + int mTotalCustomer; + T2PeoplePtrList *mBelongList; + T2EquipPtrList *mRelatedTenantList; + unsigned int mTenantNumber; + protected: virtual void LoadSelf(T2Archive& inArchive, T2TowerDoc* inDoc); virtual void SaveSelf(T2Archive& inArchive); @@ -223,29 +243,6 @@ protected: BOOL CollectEmployeeFromPool(T2TowerDoc* inDoc, T2TenantMemberTableDef* inTable); unsigned int CheckRouteFromPool(T2TowerDoc* inDoc, unsigned int inScore) const; int GetConsumptionPower() const { return 0; } - - friend class T2EquipDef; - friend class T2TenantArray; - - T2People *mFirstPeople; - T2People *m64; - int mMerchandiseCount; - int mMerchandise[4]; - int mResideDay; - int mKindIndex; - int mMark; - BOOL mIsBind; - int mPeopleEstimate; - int mEstimate; - unsigned int mRelatedTenantID; - int mReserveCount; - int mBelongCount; - int mCustomerCount; - int mWorkCount; - int mTotalCustomer; - T2PeoplePtrList *mBelongList; - T2EquipPtrList *mRelatedTenantList; - unsigned int mTenantNumber; }; inline /*virtual*/ void T2Tenant::ClearDrawMode() { diff --git a/src/T2DLL/T2ToolCallback.h b/src/T2DLL/T2ToolCallback.h index 2472215..c60adc9 100644 --- a/src/T2DLL/T2ToolCallback.h +++ b/src/T2DLL/T2ToolCallback.h @@ -4,6 +4,6 @@ class AFX_CLASS_EXPORT T2ToolCallback { public: - virtual void toolCallback_vf00(int unkParam1, T2ToolIconItem *inItem) = 0; + virtual void toolCallback_vf00(T2ToolWindow *inToolWindow, T2ToolIconItem *inItem) = 0; }; #endif diff --git a/src/T2DLL/T2WorldDef.h b/src/T2DLL/T2WorldDef.h index 8352cf3..96fbdad 100644 --- a/src/T2DLL/T2WorldDef.h +++ b/src/T2DLL/T2WorldDef.h @@ -101,6 +101,71 @@ public: T2BlackOut* GetBlackOut(); BOOL IsBlackOut(); + int mWorldType; + int mGroundLine; + int mLobbyHeight; + int _5C; + POINT mInitPos; + int mTopFloorLine; + int mBottomFloorLine; + int m70; // starting level + int m74; // starting month + int _78; + int _7C; + int _80; + int mNumOfGradeDef; + GradeDef mGradeDef[8]; + int m148[5]; + char m15C[20]; + unsigned int mMinimumLevelForDust; + unsigned int mMinimumLevelForToilet; + unsigned int mToiletDenomi; + int m17C; + int mBGVUnit; + int mBGHUnit; + int mSkyVSize; + int mSkyHSize; + POINT m190; // crane size + T2WordDefArray *mWordDefArray; + T2BitImage *mSkyOffscreen; + T2BitImage *m1A0; + T2BitImage *m1A4[2]; + T2BitImage *m1AC; + T2BitImage *m1B0; + T2BitImage *m1B4; + T2BitImage *m1B8; + T2BitImage *m1BC; + T2BitImage *m1C0; + T2BitImage *m1C4; + T2BitImage *m1C8; + T2BitImage *m1CC; + T2ImageObj *m1D0; + T2PoolDef *mPoolDef; + int _1D8; + int _1DC; + int _1E0; + int _1E4; + int _1E8; + int _1EC; + int _1F0; + T2BitImage *mImage; + int mHeight; + int mWidth; + RECT mBuildArea; + int _210; + BOOL _214; + int mOutViewKind; + T2PaletteAnimeDef *mPaletteAnimeDef; + T2SeasonParamDef *mSeasonParamDef; + T2ColdTableDef *mColdTableDef; + int m228; + int mCashAmount[8]; + int mInitialFunds; + int mMoneyNumerator; + int mMoneyDenominator; + CString mMoneyUnit; + T2TowerEvent *mTowerEvent; + protected: virtual void DrawClock(T2MWControl* inControl, T2DateTime& inDateTime); virtual void DrawCalendar(T2MWControl* inControl, T2DateTime& inDateTime, T2TowerDoc* inDoc); @@ -143,87 +208,6 @@ protected: T2PoolDef* MakePoolDef(); T2SeasonParamDef* MakeSeasonParamDef(); T2ColdTableDef* MakeColdTableDef(); - - friend class T2FloorInfo; - friend class T2MainWindow; - friend class T2Maru_Reggae; - friend class T2MetroRailway; - friend class T2OutDecoration; - friend class T2OuterObjDef; - friend class T2People; - friend class T2SantaClaus; - friend class T2TenantDef; - friend class T2Terrorist; - friend class T2ToolDef; - friend class T2ToolWindow; - friend class T2TowerDoc; - friend class T2WorldPlugin; - friend class T2VisitVIP; - - int mWorldType; - int mGroundLine; - int mLobbyHeight; - int _5C; - POINT mInitPos; - int mTopFloorLine; - int mBottomFloorLine; - int m70; // starting level - int m74; // starting month - int _78; - int _7C; - int _80; - int mNumOfGradeDef; - GradeDef mGradeDef[8]; - int m148[5]; - char m15C[20]; - unsigned int mMinimumLevelForDust; - unsigned int mMinimumLevelForToilet; - unsigned int mToiletDenomi; - int m17C; - int mBGVUnit; - int mBGHUnit; - int mSkyVSize; - int mSkyHSize; - POINT m190; // crane size - T2WordDefArray *mWordDefArray; - T2BitImage *mSkyOffscreen; - T2BitImage *m1A0; - T2BitImage *m1A4[2]; - T2BitImage *m1AC; - T2BitImage *m1B0; - T2BitImage *m1B4; - T2BitImage *m1B8; - T2BitImage *m1BC; - T2BitImage *m1C0; - T2BitImage *m1C4; - T2BitImage *m1C8; - T2BitImage *m1CC; - T2ImageObj *m1D0; - T2PoolDef *mPoolDef; - int _1D8; - int _1DC; - int _1E0; - int _1E4; - int _1E8; - int _1EC; - int _1F0; - T2BitImage *mImage; - int mHeight; - int mWidth; - RECT mBuildArea; - int _210; - BOOL _214; - int mOutViewKind; - T2PaletteAnimeDef *mPaletteAnimeDef; - T2SeasonParamDef *mSeasonParamDef; - T2ColdTableDef *mColdTableDef; - int m228; - int mCashAmount[8]; - int mInitialFunds; - int mMoneyNumerator; - int mMoneyDenominator; - CString mMoneyUnit; - T2TowerEvent *mTowerEvent; }; inline /*virtual*/ int T2WorldDef::ExchangeMoney(int v) const { diff --git a/src/T2TowerDoc.cpp b/src/T2TowerDoc.cpp index 0bbb0f7..ab16b26 100644 --- a/src/T2TowerDoc.cpp +++ b/src/T2TowerDoc.cpp @@ -2529,9 +2529,9 @@ void T2TowerDoc::CalcCraneUpdateRect(RECT &ioRect) { this, rect2, valiation | - (!m1A0->IsFloor() ? 0x10000 : 0) | - ((inMode == 1) ? 0x1000 : 0) | - ((inMode == 2) ? 0x100 : 0), + (!m1A0->IsFloor() ? kAreaCheckFlag10000 : 0) | + ((inMode == 1) ? kAreaCheckFlag1000 : 0) | + ((inMode == 2) ? kAreaCheckFlag100 : 0), inShowError ) == AreaCheckCode_1; } @@ -4191,7 +4191,7 @@ void T2TowerDoc::OnUpdateHideToolWindow(CCmdUI *pCmdUI) { return NULL; } -/*virtual*/ void T2TowerDoc::toolCallback_vf00(int unkParam1, T2ToolIconItem *inItem) { +/*virtual*/ void T2TowerDoc::toolCallback_vf00(T2ToolWindow *inToolWindow, T2ToolIconItem *inItem) { if (inItem->mName == "ToolRoot") { if (inItem->m24) towerDoc_vf194(); diff --git a/src/T2TowerDoc.h b/src/T2TowerDoc.h index cbdbb37..b7df5a1 100644 --- a/src/T2TowerDoc.h +++ b/src/T2TowerDoc.h @@ -282,7 +282,7 @@ public: virtual BOOL towerDoc_vf2BC(const char *inPath); // 2C0 virtual BOOL towerDoc_vf2C0(const char *inPath); - virtual void toolCallback_vf00(int unkParam1, T2ToolIconItem *inItem); + virtual void toolCallback_vf00(T2ToolWindow *inToolWindow, T2ToolIconItem *inItem); void x429A9A(BOOL inPause); void x429B01(BOOL inPause); diff --git a/src/common.h b/src/common.h index 88f98b8..f34e9f3 100644 --- a/src/common.h +++ b/src/common.h @@ -186,6 +186,7 @@ class T2ToolDefDB; class T2ToolDefList; class T2ToolIconItem; class T2ToolIconList; +class T2ToolHelpWnd; class T2ToolPlugin; class T2ToolWindow; class T2TowerDoc; |