diff --git a/.gitignore b/.gitignore index 8de655f..ac08bdc 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,5 @@ log.txt G3DTest.suo G3DTest.suo stderr.txt +desktop.ini +main.cpp diff --git a/BaseButtonInstance.cpp b/BaseButtonInstance.cpp index 99dfa46..55e54ca 100644 --- a/BaseButtonInstance.cpp +++ b/BaseButtonInstance.cpp @@ -1,15 +1,12 @@ #include "BaseButtonInstance.h" #include "Globals.h" -bool floatBottom = false; -bool floatRight = false; -bool floatCenter = false; -bool disabled = false; -bool selected = false; + ButtonListener* listener = NULL; BaseButtonInstance::BaseButtonInstance(void) { + Instance::Instance(); listener = NULL; } diff --git a/BaseButtonInstance.h b/BaseButtonInstance.h index 6322426..abb0784 100644 --- a/BaseButtonInstance.h +++ b/BaseButtonInstance.h @@ -16,7 +16,7 @@ public: bool floatBottom; bool floatRight; bool floatCenter; - bool disabled; + volatile bool disabled; bool selected; protected: bool mouseInArea(float, float, float, float, float, float); diff --git a/BrowserCallHandler.cpp b/BrowserCallHandler.cpp new file mode 100644 index 0000000..25162df --- /dev/null +++ b/BrowserCallHandler.cpp @@ -0,0 +1,9 @@ +#include "BrowserCallHandler.h" + +BrowserCallHandler::BrowserCallHandler(void) +{ +} + +BrowserCallHandler::~BrowserCallHandler(void) +{ +} diff --git a/BrowserCallHandler.h b/BrowserCallHandler.h new file mode 100644 index 0000000..f411102 --- /dev/null +++ b/BrowserCallHandler.h @@ -0,0 +1,8 @@ +#pragma once +#include +class BrowserCallHandler : IDocHostUIHandler +{ +public: + BrowserCallHandler(void); + ~BrowserCallHandler(void); +}; diff --git a/CameraController.cpp b/CameraController.cpp index a7c78bf..567f089 100644 --- a/CameraController.cpp +++ b/CameraController.cpp @@ -196,11 +196,17 @@ void CameraController::update(Demo* demo) } if(rightButtonHolding) { + Globals::useMousePoint = true; + Globals::mousepoint = oldDesktopMouse; POINT mouse; GetCursorPos(&mouse); pan(&frame,(mouse.x-oldDesktopMouse.x)/100.f,(mouse.y-oldDesktopMouse.y)/100.f); SetCursorPos(oldDesktopMouse.x,oldDesktopMouse.y); } + else + { + Globals::useMousePoint = false; + } if(GetHoldKeyState(VK_RSHIFT) || GetHoldKeyState(VK_LSHIFT)) { moveRate = 1; diff --git a/CameraController.h b/CameraController.h index 8fd23a3..c6c6ccb 100644 --- a/CameraController.h +++ b/CameraController.h @@ -2,6 +2,7 @@ #include #include "Instance.h" +#include "Globals.h" #include #define CAM_ZOOM_MIN 0.1f diff --git a/DataModelInstance.cpp b/DataModelInstance.cpp index 1c77b78..4cba7db 100644 --- a/DataModelInstance.cpp +++ b/DataModelInstance.cpp @@ -1,18 +1,12 @@ #include "DataModelInstance.h" -WorkspaceInstance* workspace; -Instance* guiRoot; -float mousex; -float mousey; -bool mouseButton1Down; -std::string message; -bool showMessage; -G3D::GFontRef font; + DataModelInstance::DataModelInstance(void) { + Instance::Instance(); workspace = new WorkspaceInstance(); guiRoot = new Instance(); children.push_back(workspace); diff --git a/DataModelInstance.h b/DataModelInstance.h index 2283d50..ac614d4 100644 --- a/DataModelInstance.h +++ b/DataModelInstance.h @@ -11,8 +11,12 @@ public: void setMessage(std::string); void clearMessage(); void drawMessage(RenderDevice*); - GFontRef font; WorkspaceInstance* getWorkspace(); + WorkspaceInstance* workspace; + Instance* guiRoot; + std::string message; + bool showMessage; + G3D::GFontRef font; Instance* getGuiRoot(); float mousex; float mousey; diff --git a/Demo.h b/Demo.h index a449294..e6fef08 100644 --- a/Demo.h +++ b/Demo.h @@ -1,10 +1,12 @@ #pragma once #include #include "CameraController.h" +#include "PropertyWindow.h" -class Demo : public GApp { +class Demo { // : public GApp { public: - Demo(const GAppSettings& settings,Win32Window* wind); + Demo(const GAppSettings& settings,HWND parentWindow); + void Boop(); virtual ~Demo() {} virtual void exitApplication(); virtual void onInit(); @@ -15,22 +17,42 @@ class Demo : public GApp { virtual void onUserInput(UserInput* ui); virtual void onCleanup(); - Instance* getSelection(); + std::vector getSelection(); + void run(); void QuitApp(); + void resizeWithParent(HWND parentWindow); + void onCreate(HWND parentWindow); void onKeyPressed(int key); void onKeyUp(int key); - void onMouseLeftPressed(int x, int y); + void onMouseLeftPressed(HWND hwnd,int x, int y); void onMouseLeftUp(int x, int y); void onMouseRightPressed(int x, int y); void onMouseRightUp(int x, int y); void onMouseMoved(int x, int y); void onMouseWheel(int x, int y, short delta); + CameraController cameraController; + RenderDevice* renderDevice; + UserInput* userInput; + PropertyWindow* _propWindow; private: void initGUI(); - HWND hWndMain; + HWND _hWndMain; SkyRef sky; bool quit; + bool mouseOnScreen; bool rightButtonHolding; void main(); + GWindow* _window; + HWND _hwndToolbox; + HWND _buttonTest; + HWND _hwndRenderer; + + protected: + Stopwatch m_graphicsWatch; + Stopwatch m_logicWatch; + Stopwatch m_networkWatch; + Stopwatch m_userInputWatch; + Stopwatch m_simulationWatch; + Stopwatch m_waitWatch; }; diff --git a/Dialogs.aps b/Dialogs.aps index f9d2af7..a88f5a0 100644 Binary files a/Dialogs.aps and b/Dialogs.aps differ diff --git a/Dialogs.rc b/Dialogs.rc index 9763a82..a8414b4 100644 --- a/Dialogs.rc +++ b/Dialogs.rc @@ -7,7 +7,7 @@ // // Generated from the TEXTINCLUDE 2 resource. // -#include "afxres.h" +#include "windows.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -34,7 +34,7 @@ END 2 TEXTINCLUDE BEGIN - "#include ""afxres.h""\r\n" + "#include ""windows.h""\r\n" "\0" END @@ -46,37 +46,6 @@ END #endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_TOOLBOX DIALOGEX 0, 0, 398, 64 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CONTROL "",IDC_TOOLBOX_BROWSER, - "{A8F8E829-06DA-11D2-8D70-00A0C98B28E2}",WS_TABSTOP,0,0,398,64 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog Info -// - -IDD_TOOLBOX DLGINIT -BEGIN - IDC_TOOLBOX_BROWSER, 0x376, 76, 0 -0x0000, 0x0000, 0xb293, 0x0000, 0x0048, 0x0000, 0x0003, 0x0008, 0xf20b, -0x4757, 0x0020, 0x0000, 0x005f, 0x0065, 0x0078, 0x0074, 0x0065, 0x006e, -0x0074, 0x0078, 0x3db4, 0x0000, 0x0003, 0x0008, 0xf20a, 0x4757, 0xffe0, -0xffff, 0x005f, 0x0065, 0x0078, 0x0074, 0x0065, 0x006e, 0x0074, 0x0079, -0x0ac0, 0x0000, - 0 -END - #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// @@ -90,40 +59,6 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_CAN #pragma code_page(1252) #endif //_WIN32 -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUT_DIALOG DIALOGEX 0, 0, 226, 151 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDOK,169,130,50,14 - PUSHBUTTON "Cancel",IDCANCEL,112,130,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_ABOUT_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 219 - TOPMARGIN, 7 - BOTTOMMARGIN, 144 - END -END -#endif // APSTUDIO_INVOKED - - ///////////////////////////////////////////////////////////////////////////// // // Icon @@ -132,6 +67,13 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. IDI_ICON1 ICON "icon1.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDB_BITMAP1 BITMAP "Parts.bmp" #endif // English (Canada) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/Enum.h b/Enum.h new file mode 100644 index 0000000..4e70d15 --- /dev/null +++ b/Enum.h @@ -0,0 +1,9 @@ +namespace Enum +{ + namespace SurfaceType + { + enum Value { + Smooth, Bumps, Welds, Glue + }; + } +} \ No newline at end of file diff --git a/Enums.h b/Enums.h new file mode 100644 index 0000000..68d7f23 --- /dev/null +++ b/Enums.h @@ -0,0 +1,14 @@ +#ifndef ENUM_H +#define ENUM_H +static enum BinType {GameTool, Grab, Clone, Hammer}; +static enum ControllerType {None, KeyboardRight, KeyboardLeft, Joypad1, Joypad2, Chase, Flee}; +//static enum JointType {UNK0, WeldJoint, SnapJoint, UNK3, Rotate, RotateP, RotateV, GlueJoint, UNK8, UNK9, None}; +static enum ActionType {Nothing, Pause, Lose, Draw, Win}; +static enum AffectType {NoChange, Increase, Decrease}; +static enum InputType {NoInput, LeftTread, RightTread, Steer, Throtle, UpDown, Action1, Action2, Action3, Action4, Action5, Constant, Sin}; +//static enum SurfaceConstraint {None, Hinge, SteppingMotor, Motor}; +static enum SurfaceType{Smooth, Snaps, Inlets, Glue, Weld, Hinge, Motor, Bumps}; +static enum SoundType {NoSound, Boing, Bomb, Break, Click, Clock, Slingshot, Page, Ping, Snap, Splat, Step, StepOn, Swoosh, Victory}; +static enum PartType {Ball, Block, Cylinder}; +static enum KeywordFilterType {Include, Exclude}; +#endif diff --git a/G3DTest.aps b/G3DTest.aps new file mode 100644 index 0000000..c8dcb23 Binary files /dev/null and b/G3DTest.aps differ diff --git a/G3DTest.vcproj b/G3DTest.vcproj index 1829c62..f234481 100644 --- a/G3DTest.vcproj +++ b/G3DTest.vcproj @@ -21,6 +21,7 @@ ConfigurationType="1" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops" UseOfMFC="0" + UseOfATL="0" ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="2" > @@ -73,6 +74,7 @@ /> + + + + @@ -243,11 +255,19 @@ > + + + + + + + + + + @@ -311,6 +343,14 @@ RelativePath=".\AudioPlayer.h" > + + + + @@ -323,10 +363,30 @@ RelativePath=".\Demo.h" > + + + + + + + + + + @@ -335,6 +395,10 @@ RelativePath=".\win32Defines.h" > + + @@ -372,10 +436,18 @@ Name="Resource Files" Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" > + + + + diff --git a/Globals.cpp b/Globals.cpp index 3cc0e67..5d7ca78 100644 --- a/Globals.cpp +++ b/Globals.cpp @@ -5,7 +5,14 @@ int const Globals::gen = 0; int const Globals::major = 0; int const Globals::minor = 4; int const Globals::patch = 2; +int Globals::surfaceId = 2; +bool Globals::showMouse = true; +bool Globals::useMousePoint = false; +const std::string Globals::PlaceholderName = "Dynamica"; +std::vector g_selectedInstances = std::vector(); +G3D::TextureRef Globals::surface; +POINT Globals::mousepoint; Globals::Globals(void){} Globals::~Globals(void){} diff --git a/Globals.h b/Globals.h index 8c6e277..8aed8fa 100644 --- a/Globals.h +++ b/Globals.h @@ -1,5 +1,6 @@ #pragma once #include "DataModelInstance.h" +#include class Globals { @@ -7,8 +8,16 @@ public: Globals(void); ~Globals(void); static DataModelInstance* dataModel; + static bool showMouse; + static POINT mousepoint; + static bool useMousePoint; static const int gen; static const int major; static const int minor; static const int patch; -}; \ No newline at end of file + static G3D::TextureRef surface; + static int surfaceId; + static const std::string PlaceholderName; +}; + +extern std::vector g_selectedInstances; \ No newline at end of file diff --git a/IEBrowser.cpp b/IEBrowser.cpp new file mode 100644 index 0000000..9e6b557 --- /dev/null +++ b/IEBrowser.cpp @@ -0,0 +1,68 @@ +#ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN +#endif + +#include + +#include "IEBrowser.h" +#include "Globals.h" +#include "ax.h" + +void IEBrowser::Boop(char* test) +{ +} + +IEBrowser::IEBrowser(HWND attachHWnd) { + MSG messages; + while (PeekMessage (&messages, NULL, 0, 0,PM_REMOVE)) + { + if (IsDialogMessage(hwnd, &messages) == 0) + { + TranslateMessage(&messages); + DispatchMessage(&messages); + } + } + hwnd = attachHWnd; + spDocument = 0; + webBrowser = 0; + SendMessage(hwnd,AX_INPLACE,1,0); + SendMessage(hwnd,AX_QUERYINTERFACE,(WPARAM)&IID_IWebBrowser2,(LPARAM)&webBrowser); +} + +IEBrowser::~IEBrowser(void) { + if (webBrowser) + { + webBrowser->Release(); + } +} + +bool IEBrowser::navigateSyncURL(wchar_t* url) +{ + MSG messages; + if (webBrowser) + { + webBrowser->Navigate(url,0,0,0,0); + for (int i=1;i<1000;i++) + { + while (PeekMessage (&messages, NULL, 0, 0,PM_REMOVE)) + { + if (IsDialogMessage(hwnd, &messages) == 0) + { + TranslateMessage(&messages); + DispatchMessage(&messages); + } + } + Sleep(30); + HRESULT hresult = webBrowser->get_Document(&spDocument); + if (&spDocument!=0) + { + return true; + } + } + } + else + { + MessageBox(NULL,"Cannot read IWebBrowser2...",(Globals::PlaceholderName+" Crash").c_str(),MB_OK); + } + return false; +} \ No newline at end of file diff --git a/IEBrowser.h b/IEBrowser.h new file mode 100644 index 0000000..4ee5587 --- /dev/null +++ b/IEBrowser.h @@ -0,0 +1,17 @@ +//#include "WindowFunctions.h" +#pragma once +#include +#include +//#include + +class IEBrowser { + public: + IEBrowser(HWND attachHWnd); + ~IEBrowser(void); + bool navigateSyncURL(wchar_t* url); + void Boop(char* test); + private: + IWebBrowser2* webBrowser; + HWND hwnd; + IDispatch* spDocument; +}; diff --git a/IEDispatcher.cpp b/IEDispatcher.cpp new file mode 100644 index 0000000..10330f6 --- /dev/null +++ b/IEDispatcher.cpp @@ -0,0 +1,40 @@ +#include "IEDispatcher.h" + +IEDispatcher::IEDispatcher(void) +{ +} + +IEDispatcher::~IEDispatcher(void) +{ +} + +HRESULT STDMETHODCALLTYPE IEDispatcher::QueryInterface(const IID &riid, void **ppvObject) +{ + return NULL; +} +ULONG STDMETHODCALLTYPE IEDispatcher::AddRef() +{ + return NULL; +} +ULONG STDMETHODCALLTYPE IEDispatcher::Release() +{ + return NULL; +} +HRESULT STDMETHODCALLTYPE IEDispatcher::GetTypeInfoCount(UINT *pctinfo) +{ + return NULL; +} +HRESULT STDMETHODCALLTYPE IEDispatcher::GetTypeInfo(UINT, LCID, ITypeInfo **) +{ + return NULL; +} +HRESULT STDMETHODCALLTYPE IEDispatcher::GetIDsOfNames(const IID &, LPOLESTR *, UINT, LCID, DISPID *) +{ + return NULL; +} +HRESULT STDMETHODCALLTYPE IEDispatcher::Invoke(DISPID, const IID &, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *) + +{ + return NULL; +} + \ No newline at end of file diff --git a/IEDispatcher.h b/IEDispatcher.h new file mode 100644 index 0000000..9cc1e41 --- /dev/null +++ b/IEDispatcher.h @@ -0,0 +1,17 @@ +#pragma once +#include "oaidl.h" + +class IEDispatcher : public IDispatch +{ +public: + IEDispatcher(void); + ~IEDispatcher(void); + HRESULT STDMETHODCALLTYPE IEDispatcher::QueryInterface(const IID &riid, void **ppvObject); + ULONG STDMETHODCALLTYPE IEDispatcher::AddRef(); + ULONG STDMETHODCALLTYPE IEDispatcher::Release(); + HRESULT STDMETHODCALLTYPE IEDispatcher::GetTypeInfoCount(UINT *pctinfo); + HRESULT STDMETHODCALLTYPE IEDispatcher::GetTypeInfo(UINT, LCID, ITypeInfo **); + HRESULT STDMETHODCALLTYPE IEDispatcher::GetIDsOfNames(const IID &, LPOLESTR *, UINT, LCID, DISPID *); + HRESULT STDMETHODCALLTYPE IEDispatcher::Invoke(DISPID, const IID &, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *); + +}; diff --git a/ImageButtonInstance.cpp b/ImageButtonInstance.cpp index 7ee3b11..e0fc785 100644 --- a/ImageButtonInstance.cpp +++ b/ImageButtonInstance.cpp @@ -1,17 +1,8 @@ #include "ImageButtonInstance.h" -G3D::TextureRef image = NULL; -int openGLID = 0; -G3D::TextureRef image_ovr = NULL; -int openGLID_ovr = 0; -G3D::TextureRef image_dn = NULL; -int openGLID_dn = 0; -G3D::TextureRef image_ds = NULL; -int openGLID_ds = 0; -Vector2 size; -Vector2 position; + ImageButtonInstance::ImageButtonInstance(G3D::TextureRef newImage, G3D::TextureRef overImage = NULL, G3D::TextureRef downImage = NULL, G3D::TextureRef disableImage = NULL) { - + BaseButtonInstance::BaseButtonInstance(); image = newImage; openGLID = image->getOpenGLID(); image_ovr = overImage; @@ -94,7 +85,7 @@ void ImageButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouse positionRelative = Vector2(rd->getWidth() + position.x, position.y); } int renderimage = openGLID; - if(selected == true && !image_dn.isNull()) + if(selected == true && !image_dn.isNull() && !disabled) { renderimage = openGLID_dn; } diff --git a/Instance.cpp b/Instance.cpp index 3872eba..7cc363d 100644 --- a/Instance.cpp +++ b/Instance.cpp @@ -2,18 +2,25 @@ #include #include "Instance.h" -std::string name; -Instance* parent = NULL; -std::vector children; -static std::string className = "BaseInstance"; Instance::Instance(void) { parent = NULL; name = "Default Game Instance"; className = "BaseInstance"; + listicon = 0; } +Instance::Instance(const Instance &oinst) +{ + + name = oinst.name; + className = oinst.className; + //setParent(oinst.parent); +} + + + void Instance::render(RenderDevice* rd) { for(size_t i = 0; i < children.size(); i++) @@ -22,6 +29,45 @@ void Instance::render(RenderDevice* rd) } } + + +PROPGRIDITEM Instance::createPGI(LPSTR catalog, LPSTR propName, LPSTR propDesc, LPARAM curVal, INT type) +{ + PROPGRIDITEM pItem; + PropGrid_ItemInit(pItem); + pItem.lpszCatalog=catalog; + pItem.lpszPropName=propName; + pItem.lpszPropDesc=propDesc; + pItem.lpCurValue=curVal; + pItem.iItemType=type; + return pItem; +} + +void Instance::PropUpdate(LPPROPGRIDITEM &item) +{ + if(strcmp(item->lpszPropName, "Name") == 0) + { + name = (LPSTR)item->lpCurValue; + } +} + +std::vector Instance::getProperties() +{ + std::vector properties; + + + properties.push_back(createPGI( + "Properties", + "Name", + "The name of this instance", + (LPARAM)name.c_str(), + PIT_EDIT + )); + return properties; +} + + + Instance::~Instance(void) { for(size_t i = 0; i < children.size(); i++) @@ -92,14 +138,15 @@ void Instance::removeChild(Instance* oldChild) Instance* Instance::findFirstChild(std::string name) { - Instance* child = NULL; for(size_t i = 0; i < children.size(); i++) { - if(children.at(i)->name == name) + if(children.at(i)->name.compare(name) == 0) { - child = children.at(i); - break; + return children.at(i); } } - return child; + return NULL; } + + + diff --git a/Instance.h b/Instance.h index f379d63..07231a1 100644 --- a/Instance.h +++ b/Instance.h @@ -1,23 +1,31 @@ -#include -#pragma once +#pragma once +#include +#include "propertyGrid.h" class Instance { public: Instance(void); + Instance(const Instance&); virtual ~Instance(void); std::string name; virtual void render(RenderDevice*); std::vector children; // All children. std::string getClassName(); - Instance* findFirstChild(std::string); + virtual Instance* findFirstChild(std::string); std::vector getChildren(); std::vector getAllChildren(); void setParent(Instance*); void addChild(Instance*); void removeChild(Instance*); Instance* getParent(); + virtual Instance* clone() const { return new Instance(*this); } + virtual std::vector getProperties(); + virtual void PropUpdate(LPPROPGRIDITEM &pItem); + int listicon; protected: std::string className; Instance* parent; // Another pointer. + PROPGRIDITEM createPGI(LPSTR catalog, LPSTR propName, LPSTR propDesc, LPARAM curVal, INT type); + }; diff --git a/Parts.bmp b/Parts.bmp new file mode 100644 index 0000000..bab00c9 Binary files /dev/null and b/Parts.bmp differ diff --git a/PhysicalInstance.cpp b/PhysicalInstance.cpp index ff0ae8c..c8734f3 100644 --- a/PhysicalInstance.cpp +++ b/PhysicalInstance.cpp @@ -1,30 +1,48 @@ #include "PhysicalInstance.h" -bool canCollide = true; -bool anchored = false; -Vector3 size; -Vector3 position; -Vector3 velocity; -Vector3 rotVelocity; -GLfloat vertecies[96]; -CoordinateFrame cFrame; -Color3 color; -bool changed = true; -Box itemBox = Box(); +#include "Globals.h" PhysicalInstance::PhysicalInstance(void) { - name = "Default PhysicalInstance"; + Instance::Instance(); + name = "Default PhysicalInstance"; className = "Part"; canCollide = true; anchored = true; size = Vector3(2,1,4); - position = Vector3(0,0,0); - cFrame = CoordinateFrame(position); + setCFrame(CoordinateFrame(Vector3(0,0,0))); color = Color3::gray(); velocity = Vector3(0,0,0); rotVelocity = Vector3(0,0,0); + top = Enum::SurfaceType::Smooth; + front = Enum::SurfaceType::Smooth; + right = Enum::SurfaceType::Smooth; + back = Enum::SurfaceType::Smooth; + left = Enum::SurfaceType::Smooth; + bottom = Enum::SurfaceType::Smooth; } + +PhysicalInstance::PhysicalInstance(const PhysicalInstance &oinst) +{ + Instance::Instance(oinst); + //name = oinst.name; + //className = "Part"; + canCollide = oinst.canCollide; + setParent(oinst.parent); + anchored = oinst.anchored; + size = oinst.size; + setCFrame(oinst.cFrame); + color = oinst.color; + velocity = oinst.velocity; + rotVelocity = oinst.rotVelocity; + top = oinst.top; + front = oinst.front; + right = oinst.right; + back = oinst.back; + left = oinst.left; + bottom = oinst.bottom; +} + void PhysicalInstance::setSize(Vector3 newSize) { int minsize = 1; @@ -114,22 +132,74 @@ Box PhysicalInstance::getBox() return itemBox; } +bool PhysicalInstance::collides(Box box) +{ + return CollisionDetection::fixedSolidBoxIntersectsFixedSolidBox(getBox(), box); +} + void PhysicalInstance::render(RenderDevice* rd) { if(changed) Box box = getBox(); + glColor(color); - glBegin(GL_QUADS); + /*glEnable( GL_TEXTURE_2D ); + glEnable(GL_BLEND);// you enable blending function + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture( GL_TEXTURE_2D, Globals::surfaceId); + glBegin(GL_QUADS);*/ for(int i = 0; i < 96; i+=16) { + double add = 0.8; + Enum::SurfaceType::Value face; + if(i == 0)//Back + face = back; + else if(i == 16)//Right + face = right; + else if(i == 32)//Front + face = front; + else if(i == 48)//Top + face = top; + else if(i == 64)//Left + face = left; + else if(i == 80)//Bottom + face = bottom; + + /*if(face == Snaps) + add = 0.0; + else if(face == Inlets) + add = 0.2;*/ + Vector3 v0 = Vector3(vertecies[i], vertecies[i+1], vertecies[i+2]), v1 = Vector3(vertecies[i+3], vertecies[i+4], vertecies[i+5]), v3 = Vector3(vertecies[i+9], vertecies[i+10], vertecies[i+11]); - glNormal3fv((v1 - v0).cross(v3 - v0).direction()); + /*glNormal3fv((v1 - v0).cross(v3 - v0).direction()); + glTexCoord2f(0.0F,0.0F); glVertex3fv(v0); + glTexCoord2f(1.0F,0.0F); glVertex3fv(v1); + glTexCoord2f(1.0F,0.25F); glVertex3f(vertecies[i+6], vertecies[i+7], vertecies[i+8]); + glTexCoord2f(0.0F,0.25F); + glVertex3fv(v3);*/ + + glEnable( GL_TEXTURE_2D ); + glEnable(GL_BLEND);// you enable blending function + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture( GL_TEXTURE_2D, Globals::surfaceId); + glBegin( GL_QUADS ); + glNormal3fv((v1 - v0).cross(v3 - v0).direction()); + glTexCoord2d(0.0,0.0+add); + glVertex3fv(v0); + glTexCoord2d( 1.0,0.0+add); + glVertex3fv(v1); + glTexCoord2d(1.0,0.2+add); + glVertex3f(vertecies[i+6], vertecies[i+7], vertecies[i+8]); + glTexCoord2d( 0.0,0.2+add); glVertex3fv(v3); + glEnd(); + glDisable( GL_TEXTURE_2D ); } - glEnd(); + /*glEnd(); + glDisable(GL_TEXTURE_2D);*/ glColor(Color3::white()); if(!children.empty()) { @@ -144,7 +214,106 @@ void PhysicalInstance::render(RenderDevice* rd) PhysicalInstance::~PhysicalInstance(void) { } +char pto[512]; +char pto2[512]; +#include +void PhysicalInstance::PropUpdate(LPPROPGRIDITEM &item) +{ + if(strcmp(item->lpszPropName, "Color3") == 0) + { + color = Color3(GetRValue(item->lpCurValue)/255.0F,GetGValue(item->lpCurValue)/255.0F,GetBValue(item->lpCurValue)/255.0F); + } + else if(strcmp(item->lpszPropName, "Offset") == 0) + { + std::string str = (LPTSTR)item->lpCurValue; + std::vector vect; + std::stringstream ss(str); + float i; + while (ss >> i) + { + vect.push_back(i); + if (ss.peek() == ',') + ss.ignore(); + } + + if(vect.size() != 3) + { + sprintf(pto, "%g, %g, %g", cFrame.translation.x, cFrame.translation.y, cFrame.translation.z, "what"); + LPCSTR str = LPCSTR(pto); + item->lpCurValue = (LPARAM)str; + MessageBox(NULL, "NO","NO", MB_OK); + } + else + { + Vector3 pos(vect.at(0),vect.at(1),vect.at(2)); + setPosition(pos); + } + } + + else if(strcmp(item->lpszPropName, "Size") == 0) + { + std::string str = (LPTSTR)item->lpCurValue; + std::vector vect; + std::stringstream ss(str); + float i; + + while (ss >> i) + { + vect.push_back(i); + + if (ss.peek() == ',') + ss.ignore(); + } + + if(vect.size() != 3) + { + sprintf(pto, "%g, %g, %g", cFrame.translation.x, cFrame.translation.y, cFrame.translation.z, "what"); + LPCSTR str = LPCSTR(pto); + item->lpCurValue = (LPARAM)str; + MessageBox(NULL, "NO","NO", MB_OK); + } + else + { + Vector3 size(vect.at(0),vect.at(1),vect.at(2)); + setSize(size); + } + } + + else Instance::PropUpdate(item); +} + +std::vector PhysicalInstance::getProperties() +{ + std::vector properties = Instance::getProperties(); + + + properties.push_back(createPGI( + "Properties", + "Color3", + "The color of the selected part", + RGB((color.r*255),(color.g*255),(color.b*255)), + PIT_COLOR + )); + + sprintf(pto, "%g, %g, %g", cFrame.translation.x, cFrame.translation.y, cFrame.translation.z); + properties.push_back(createPGI( + "Item", + "Offset", + "The position of the object in the workspace", + (LPARAM)pto, + PIT_EDIT + )); + sprintf(pto2, "%g, %g, %g", size.x, size.y, size.z); + properties.push_back(createPGI( + "Item", + "Size", + "The position of the object in the workspace", + (LPARAM)pto2, + PIT_EDIT + )); + return properties; +} diff --git a/PhysicalInstance.h b/PhysicalInstance.h index 8731067..70d89b2 100644 --- a/PhysicalInstance.h +++ b/PhysicalInstance.h @@ -1,15 +1,23 @@ #pragma once #include "instance.h" +#include "Enum.h" class PhysicalInstance : public Instance { public: PhysicalInstance(void); + PhysicalInstance(const PhysicalInstance &oinst); + Instance* clone() const { return new PhysicalInstance(*this); } ~PhysicalInstance(void); virtual void render(RenderDevice*); Vector3 velocity; - Vector3 rotvelocity; + Enum::SurfaceType::Value top; + Enum::SurfaceType::Value front; + Enum::SurfaceType::Value right; + Enum::SurfaceType::Value back; + Enum::SurfaceType::Value left; + Enum::SurfaceType::Value bottom; CoordinateFrame cFrame; Color3 color; Vector3 getPosition(); @@ -17,10 +25,20 @@ public: CoordinateFrame getCFrame(); void setCFrame(CoordinateFrame); Box getBox(); + Box getScaledBox(); CoordinateFrame getCFrameRenderBased(); Vector3 getSize(); void setSize(Vector3); + bool canCollide; + bool anchored; + Vector3 rotVelocity; + bool collides(Box); + virtual std::vector getProperties(); + virtual void PropUpdate(LPPROPGRIDITEM &pItem); private: Vector3 position; Vector3 size; + GLfloat vertecies[96]; + bool changed; + Box itemBox; }; diff --git a/PropertyWindow.cpp b/PropertyWindow.cpp new file mode 100644 index 0000000..cd7b2e6 --- /dev/null +++ b/PropertyWindow.cpp @@ -0,0 +1,226 @@ +#define _WINSOCKAPI_ +#include +#include "WindowFunctions.h" +#include "resource.h" +#include "PropertyWindow.h" +#include "Globals.h" +/*typedef struct typPRGP { + Instance* instance; // Declare member types + Property ∝ +} PRGP;*/ + +std::vector prop; +std::vector children; +Instance* selectedInstance; + + +LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + PropertyWindow *propWind = (PropertyWindow *)GetWindowLongPtr(hwnd, GWL_USERDATA); + if (propWind==NULL) + { + return DefWindowProc(hwnd, msg, wParam, lParam); + } + switch(msg) + { + case WM_CLOSE: + { + ShowWindow(hwnd, SW_HIDE); + } + break; + case WM_MEASUREITEM: + { + LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam; + if (lpmis->itemHeight < 18) + lpmis->itemHeight = 18; + } + break; + case WM_SIZE: + { + propWind->onResize(); + } + break; + case WM_COMMAND: + { + if(HIWORD(wParam) == CBN_SELCHANGE) + { + int ItemIndex = SendMessage((HWND) lParam, (UINT) CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0); + CHAR ListItem[256]; + SendMessage((HWND) lParam, (UINT) CB_GETLBTEXT, (WPARAM) ItemIndex, (LPARAM) ListItem); + if(ItemIndex != 0) + { + propWind->ClearProperties(); + while(g_selectedInstances.size() != 0) + g_selectedInstances.erase(g_selectedInstances.begin()); + g_selectedInstances.push_back(children.at(ItemIndex-1)); + propWind->SetProperties(children.at(ItemIndex-1)); + } + } + } + break; + case WM_NOTIFY: + { + switch(((LPNMHDR)lParam)->code) + { + case PGN_PROPERTYCHANGE: + { + if (IDC_PROPERTYGRID==wParam) { + LPNMHDR pnm = (LPNMHDR)lParam; + LPNMPROPGRID lpnmp = (LPNMPROPGRID)pnm; + LPPROPGRIDITEM item = PropGrid_GetItemData(pnm->hwndFrom,lpnmp->iIndex); + selectedInstance->PropUpdate(item); + } + } + break; + } + //MessageBox(NULL,"Test","Test",0); + } + break; + default: + return DefWindowProc(hwnd, msg, wParam, lParam); + } + return 0; +} + +void PropertyWindow::refreshExplorer() +{ + SendMessage(_explorerComboBox,CB_RESETCONTENT,0,0); + for (unsigned int i=0;iname.c_str()); + children = g_selectedInstances[i]->getChildren(); + for(size_t z = 0; z < children.size(); z++) + { + SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)children.at(z)->name.c_str()); + } + SendMessage(_explorerComboBox,CB_SETCURSEL,0,(LPARAM)0); + } +} + +bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance) { + if (!createWindowClass("propHWND",PropProc,hThisInstance)) + return false; + + _hwndProp = CreateWindowEx( + WS_EX_TOOLWINDOW, + "propHWND", + "PropertyGrid", + WS_VISIBLE | WS_POPUPWINDOW | WS_THICKFRAME | WS_CAPTION, + CW_USEDEFAULT, + CW_USEDEFAULT, + 300, + 660, + NULL, // parent + NULL, // menu + hThisInstance, + NULL + ); + + _explorerComboBox = CreateWindowEx( + NULL, + "COMBOBOX", + "Combo", + WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST, + 0, + 0, + 0, + 0, + _hwndProp, // parent + NULL, // menu + hThisInstance, + NULL + ); + SendMessage(_explorerComboBox, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); + + _propGrid = New_PropertyGrid(_hwndProp,IDC_PROPERTYGRID); + + /*PROPGRIDITEM pItem; + PropGrid_ItemInit(pItem); + + pItem.lpszCatalog="Test"; + pItem.lpszPropName="Offset"; + pItem.lpszzCmbItems="What"; + pItem.lpszPropDesc="Description"; + pItem.lpCurValue=(LPARAM)"0, 0, 0"; + + pItem.iItemType=PIT_EDIT; + + PROPGRIDITEM pItem2; + PropGrid_ItemInit(pItem2); + + pItem2.lpszCatalog="Test"; + pItem2.lpszPropName="s"; + pItem2.lpszzCmbItems="itemlist\0itemlist2\0itemlist3"; + pItem2.lpszPropDesc=""; + pItem2.lpCurValue=0; + + pItem2.iItemType=PIT_COMBO; + + /*PROPGRIDITEM FauxExplorerItem; + PropGrid_ItemInit(FauxExplorerItem); + FauxExplorerItem.lpszCatalog="Test"; + FauxExplorerItem.lpszPropName = "Editable Combo Field"; + FauxExplorerItem.lpszzCmbItems = "Test1\0Test2\0Test3"; + FauxExplorerItem.lpszPropDesc = "Press F4 to view drop down."; + FauxExplorerItem.iItemType = PIT_EDITCOMBO; + FauxExplorerItem.lpCurValue = 1; + PropGrid_AddItem(_propGrid, &FauxExplorerItem);*/ + + PropGrid_Enable(_propGrid,true); + ShowWindow(_propGrid,SW_SHOW); +// PropGrid_AddItem(_propGrid,&pItem); +// PropGrid_AddItem(_propGrid,&pItem2); + PropGrid_SetItemHeight(_propGrid,20); + PropGrid_ShowToolTips(_propGrid,TRUE); + PropGrid_ShowPropertyDescriptions(_propGrid,TRUE); + PropGrid_ExpandAllCatalogs(_propGrid); + + + SetWindowLongPtr(_hwndProp,GWL_USERDATA,(LONG)this); + + refreshExplorer(); + _resize(); + + return true; +} + +PropertyWindow::PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstance) { + onCreate(x, y, sx, sy, hThisInstance); +} + +void PropertyWindow::onResize() +{ + _resize(); +} + +void PropertyWindow::_resize() +{ + RECT rect; + GetClientRect(_hwndProp,&rect); + SetWindowPos(_propGrid, NULL, 0, 20, rect.right, rect.bottom-20, SWP_NOZORDER | SWP_NOACTIVATE); + SetWindowPos(_explorerComboBox, NULL, 0, 0, rect.right, 400, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); +} + +void PropertyWindow::SetProperties(Instance * instance) +{ + PropGrid_ResetContent(_propGrid); + prop = instance->getProperties(); + selectedInstance = instance; + for(size_t i = 0; i < prop.size(); i++) + { + ::PROPGRIDITEM item = prop.at(i); + PropGrid_AddItem(_propGrid, &item); + //PRGP propgp; + //propgp.instance = instance; + //propgp.prop = prop.at(i); + } + PropGrid_ExpandAllCatalogs(_propGrid); + //SetWindowLongPtr(_propGrid,GWL_USERDATA,(LONG)this); + + refreshExplorer(); + _resize(); +} + +void PropertyWindow::ClearProperties() +{ + PropGrid_ResetContent(_propGrid); +} \ No newline at end of file diff --git a/PropertyWindow.h b/PropertyWindow.h new file mode 100644 index 0000000..3479589 --- /dev/null +++ b/PropertyWindow.h @@ -0,0 +1,16 @@ +#pragma once +#include "Instance.h" +class PropertyWindow { +public: + PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstance); + bool onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance); + void SetProperties(Instance *); + void ClearProperties(); + void onResize(); + void refreshExplorer(); + HWND _hwndProp; +private: + HWND _propGrid; + HWND _explorerComboBox; + void _resize(); +}; \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..5f81869 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# ROBLOX 2005 Recreation Project +## Why are we doing this? +ROBLOX in 2005 was a different game, based around minigames with win and lose conditions rather than a 3D building game. Since this build of the client is presumed lost despite having around 100 users, we have to recreate it. We are using era-appropriate tools for this as well (Visual Studio 2005 and 2005-era compilers), as well as G3D 6.10, the era-appropriate version of the Graphics3D graphics library used by ROBLOX to this day. + +## Features +Equivalent to known features of 05 as it stood in October 2005 with the 'Morgan McGuire builds' + +## Credits +- Morgan McGuire, creator of G3D - his old pre-2006 website for the only existing colour pictures of 2005 era roblox on the internet, as well as a couple of helpful emails. He assisted roblox development in the 2004-2006 timeframe. +- David Baszucki and Erik Cassel (1967-2013, RIP) - for creating roblox diff --git a/SDL.dll b/SDL.dll index 6e77db7..376722b 100644 Binary files a/SDL.dll and b/SDL.dll differ diff --git a/TextButtonInstance.cpp b/TextButtonInstance.cpp index 523c918..6c8cfd1 100644 --- a/TextButtonInstance.cpp +++ b/TextButtonInstance.cpp @@ -1,28 +1,9 @@ #include "TextButtonInstance.h" -Vector2 boxBegin; -Vector2 boxEnd; -Vector2 fontLocationRelativeTo; -Color4 textColor; -Color4 textOutlineColor; -Color4 boxColor; -Color4 boxOutlineColor; -Color4 textColorOvr; -Color4 textOutlineColorOvr; -Color4 boxColorOvr; -Color4 boxOutlineColorOvr; -Color4 textColorDn; -Color4 textOutlineColorDn; -Color4 boxColorDn; -Color4 boxOutlineColorDn; -bool centeredWithinBox; -std::string title; -G3D::GFontRef* font; -int textSize; -bool visible; TextButtonInstance::TextButtonInstance(void) { + BaseButtonInstance::BaseButtonInstance(); boxBegin = Vector2(0,0); boxEnd = Vector2(0,0); fontLocationRelativeTo = Vector2(0,0); diff --git a/WindowFunctions.cpp b/WindowFunctions.cpp new file mode 100644 index 0000000..4593dcd --- /dev/null +++ b/WindowFunctions.cpp @@ -0,0 +1,32 @@ + +#include "WindowFunctions.h" +#include +#include + +using namespace std; + +bool createWindowClass(const char* name,WNDPROC proc,HMODULE hInstance) +{ + WNDCLASSEX wc; + wc.cbSize = sizeof(WNDCLASSEX); + wc.style = 0; + wc.lpfnWndProc = proc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH)(COLOR_WINDOW); + wc.lpszMenuName = NULL; + wc.lpszClassName = name; + wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); + if (!RegisterClassEx (&wc)) + { + stringstream errMsg; + errMsg<<"Failed to register " << name; + MessageBox(NULL, errMsg.str().c_str(),"Dynamica Crash", MB_OK); + return false; + } + return true; +} + diff --git a/WindowFunctions.h b/WindowFunctions.h new file mode 100644 index 0000000..9b3aeb7 --- /dev/null +++ b/WindowFunctions.h @@ -0,0 +1,4 @@ +#pragma once +#include + +bool createWindowClass(const char* name,WNDPROC proc,HMODULE hInstance); \ No newline at end of file diff --git a/WorkspaceInstance.cpp b/WorkspaceInstance.cpp index 09a1c50..2f4d463 100644 --- a/WorkspaceInstance.cpp +++ b/WorkspaceInstance.cpp @@ -1,10 +1,11 @@ #include "WorkspaceInstance.h" -float timer = 60.0F; -int score = 0; + WorkspaceInstance::WorkspaceInstance(void) { - className = "Workspace"; + Instance::Instance(); + name = "Instance"; + className = "Level"; timer = 60.0F; score = 0; } diff --git a/WorkspaceInstance.h b/WorkspaceInstance.h index fdb4b78..26a5bc4 100644 --- a/WorkspaceInstance.h +++ b/WorkspaceInstance.h @@ -9,4 +9,5 @@ public: int score; WorkspaceInstance(void); ~WorkspaceInstance(void); + }; diff --git a/ax.cpp b/ax.cpp new file mode 100644 index 0000000..f636501 --- /dev/null +++ b/ax.cpp @@ -0,0 +1,639 @@ +// AX.CPP +#include +#include +#include +#include +#include "ax.h" + + +#pragma warning (disable: 4311) +#pragma warning (disable: 4312) +#pragma warning (disable: 4244) +#pragma warning (disable: 4800) + + +// AXClientSite class +// ------- Implement member functions +AXClientSite :: AXClientSite() + { + refNum = 0; + CalledCanInPlace = 0; + InPlace = 0; + } + +AXClientSite :: ~AXClientSite() + { + } + + +// IUnknown methods +STDMETHODIMP AXClientSite :: QueryInterface(REFIID iid,void**ppvObject) + { + *ppvObject = 0; + if (iid == IID_IOleClientSite) + *ppvObject = (IOleClientSite*)this; + if (iid == IID_IUnknown) + *ppvObject = this; + if (iid == IID_IAdviseSink) + *ppvObject = (IAdviseSink*)this; + if (iid == IID_IDispatch) + *ppvObject = (IDispatch*)this; + if (ExternalPlace == false) + { + if (iid == IID_IOleInPlaceSite) + *ppvObject = (IOleInPlaceSite*)this; + if (iid == IID_IOleInPlaceFrame) + *ppvObject = (IOleInPlaceFrame*)this; + if (iid == IID_IOleInPlaceUIWindow) + *ppvObject = (IOleInPlaceUIWindow*)this; + } + + //* Log Call + if (*ppvObject) + { + AddRef(); + return S_OK; + } + return E_NOINTERFACE; + } + +STDMETHODIMP_(ULONG) AXClientSite :: AddRef() + { + refNum++; + return refNum; + } + +STDMETHODIMP_(ULONG) AXClientSite :: Release() + { + refNum--; + return refNum; + } + + +// IOleClientSite methods +STDMETHODIMP AXClientSite :: SaveObject() + { + return S_OK; + } + +STDMETHODIMP AXClientSite :: GetMoniker(DWORD dwA,DWORD dwW,IMoniker**pm) + { + *pm = 0; + return E_NOTIMPL; + } + +STDMETHODIMP AXClientSite :: GetContainer(IOleContainer**pc) + { + *pc = 0; + return E_FAIL; + } + +STDMETHODIMP AXClientSite :: ShowObject() + { + return S_OK; + } + +STDMETHODIMP AXClientSite :: OnShowWindow(BOOL f) + { + InvalidateRect(Window, 0, TRUE); + InvalidateRect(Parent, 0, TRUE); + return S_OK; + } + +STDMETHODIMP AXClientSite :: RequestNewObjectLayout() + { + return S_OK; + } + +STDMETHODIMP_(void) AXClientSite :: OnViewChange(DWORD dwAspect,LONG lIndex) + { + } + +STDMETHODIMP_(void) AXClientSite :: OnRename(IMoniker * pmk) + { + } + +STDMETHODIMP_(void) AXClientSite :: OnSave() + { + } + +STDMETHODIMP_(void) AXClientSite :: OnClose() + { + } + + + // IOleInPlaceSite methods +STDMETHODIMP AXClientSite :: GetWindow(HWND *p) + { + *p = Window; + return S_OK; + } + +STDMETHODIMP AXClientSite :: ContextSensitiveHelp(BOOL) + { + return E_NOTIMPL; + } + + +STDMETHODIMP AXClientSite :: CanInPlaceActivate() + { + if (InPlace) + { + CalledCanInPlace = true; + return S_OK; + } + return S_FALSE; + } + +STDMETHODIMP AXClientSite :: OnInPlaceActivate() + { + return S_OK; + } + +STDMETHODIMP AXClientSite :: OnUIActivate() + { + return S_OK; + } + +STDMETHODIMP AXClientSite :: GetWindowContext(IOleInPlaceFrame** ppFrame,IOleInPlaceUIWindow **ppDoc,LPRECT r1,LPRECT r2,LPOLEINPLACEFRAMEINFO o) + { + *ppFrame = (IOleInPlaceFrame*)this; + AddRef(); + + *ppDoc = NULL; + GetClientRect(Window,r1); + GetClientRect(Window,r2); + o->cb = sizeof(OLEINPLACEFRAMEINFO); + o->fMDIApp = false; + o->hwndFrame = Parent; + o->haccel = 0; + o->cAccelEntries = 0; + + return S_OK; + } + +STDMETHODIMP AXClientSite :: Scroll(SIZE s) + { + return E_NOTIMPL; + } + +STDMETHODIMP AXClientSite :: OnUIDeactivate(int) + { + return S_OK; + } + +STDMETHODIMP AXClientSite :: OnInPlaceDeactivate() + { + return S_OK; + } + +STDMETHODIMP AXClientSite :: DiscardUndoState() + { + return S_OK; + } + +STDMETHODIMP AXClientSite :: DeactivateAndUndo() + { + return S_OK; + } + +STDMETHODIMP AXClientSite :: OnPosRectChange(LPCRECT) + { + return S_OK; + } + + +// IOleInPlaceFrame methods + STDMETHODIMP AXClientSite :: GetBorder(LPRECT l) + { + GetClientRect(Window,l); + return S_OK; + } + +STDMETHODIMP AXClientSite :: RequestBorderSpace(LPCBORDERWIDTHS b) + { + //return S_OK; + return E_NOTIMPL; + } + +STDMETHODIMP AXClientSite :: SetBorderSpace(LPCBORDERWIDTHS b) + { + return S_OK; + } + +STDMETHODIMP AXClientSite :: SetActiveObject(IOleInPlaceActiveObject*pV,LPCOLESTR s) + { + ax->Pao = pV; + return S_OK; + } + + +STDMETHODIMP AXClientSite :: SetStatusText(LPCOLESTR t) + { + return E_NOTIMPL; + } + +STDMETHODIMP AXClientSite :: EnableModeless(BOOL f) + { + return E_NOTIMPL; + } + +STDMETHODIMP AXClientSite :: TranslateAccelerator(LPMSG,WORD) + { + return E_NOTIMPL; + } + + +// IDispatch Methods +HRESULT _stdcall AXClientSite :: GetTypeInfoCount( + unsigned int * pctinfo) {return E_NOTIMPL;} + +HRESULT _stdcall AXClientSite :: GetTypeInfo( + unsigned int iTInfo, + LCID lcid, + ITypeInfo FAR* FAR* ppTInfo) {return E_NOTIMPL;} + +HRESULT _stdcall AXClientSite :: GetIDsOfNames( + REFIID riid, + OLECHAR FAR* FAR*, + unsigned int cNames, + LCID lcid, + DISPID FAR* ) {return E_NOTIMPL;} + + +// Other Methods +void AX :: Init(char* cls) + { + wchar_t x[1000] = {0}; + MultiByteToWideChar(CP_ACP,0,cls,-1,x,1000); + CLSIDFromString(x,&clsid); + iid = (IID*)&IID_IOleObject; + OleObject = 0; + Storage = 0; + View = 0; + Data = 0; + Unk = 0; + Pao = 0; + AdviseToken = 0; + memset(DAdviseToken,0,sizeof(DAdviseToken)); + Site.ax = this; + } + +AX :: AX(char* cls) + { + Init(cls); + } + + + +void AX :: Clean() + { + if (Site.InPlace == true) + { + Site.InPlace = false; + IOleInPlaceObject* iib = 0; + if (OleObject) + OleObject->QueryInterface(IID_IOleInPlaceObject,(void**)&iib); + if (iib) + { + iib->UIDeactivate(); + iib->InPlaceDeactivate(); + iib->Release(); + } + } + + if (AdviseToken && OleObject) + { + OleObject->Unadvise(AdviseToken); + AdviseToken = 0; + } + if (Data) + { + for(int i = 0 ; i < 100 ; i++) + if (DAdviseToken[i]) + Data->DUnadvise(DAdviseToken[i]); + memset(DAdviseToken,0,sizeof(DAdviseToken)); + } + + + if (Pao) Pao->Release(); + if (Unk) Unk->Release(); + if (Data) Data->Release(); + if (View) View->Release(); + if (Storage) Storage->Release(); + if (OleObject) OleObject->Release(); + Unk = 0; + Data = 0; + View = 0; + Storage = 0; + OleObject = 0; + + } + +AX :: ~AX() + { + Clean(); + } + +CLSID AX :: GetCLSID() + { + return clsid; + } + +HRESULT _stdcall AXClientSite :: InsertMenus(HMENU h,LPOLEMENUGROUPWIDTHS x) + { +/* AX * t = (AX*)ax; + if (t->AddMenu) + { + x->width[0] = 0; + x->width[2] = 0; + x->width[4] = 0; + //InsertMenu(h,0,MF_BYPOSITION | MF_POPUP,(int)Menu,"test"); + return S_OK; + } +*/ + return E_NOTIMPL; + } +HRESULT _stdcall AXClientSite :: SetMenu(HMENU h,HOLEMENU hO,HWND hw) + { + AX * t = (AX*)ax; +/* if (t->AddMenu) + { + if (!h && !hO) + { + //::SetMenu(Window,Menu); + //DrawMenuBar(Window); + ::SetMenu(Parent,Menu); + DrawMenuBar(Parent); + return S_OK; + } + + //::SetMenu(Window,h); + //DrawMenuBar(Window); + + //HMENU hm = GetMenu(Parent); + //AppendMenu(hm,MF_POPUP | MF_MENUBREAK,(int)h,0); + //::SetMenu(Parent,hm); + ::SetMenu(Parent,h); + DrawMenuBar(Parent); + + //hOleWindow = hw; + //OleSetMenuDescriptor(hO,Window,hw,0,0); + OleSetMenuDescriptor(hO,Parent,hw,0,0); + + return S_OK; + } +*/ + return E_NOTIMPL; + } + +HRESULT _stdcall AXClientSite :: RemoveMenus(HMENU h) + { + AX * t = (AX*)ax; + if (t->AddMenu) + { + if (!h) + return S_OK; + + int c = GetMenuItemCount(h); + for (int i = c ; i >= 0 ; i--) + { + HMENU hh = GetSubMenu(h,i); + if (hh == Menu) + RemoveMenu(h,i,MF_BYPOSITION); + } + if (h == Menu) + DestroyMenu(h); + + //DrawMenuBar(Window); + DrawMenuBar(Parent); + return S_OK; + } + return E_NOTIMPL; + } + + +HRESULT _stdcall AXClientSite :: Invoke( + DISPID dispIdMember, + REFIID riid, + LCID lcid, + WORD wFlags, + DISPPARAMS FAR* pDispParams, + VARIANT FAR* pVarResult, + EXCEPINFO FAR* pExcepInfo, + unsigned int FAR* puArgErr) + { + return E_NOTIMPL; + } + + +void _stdcall AXClientSite :: OnDataChange(FORMATETC *pFormatEtc,STGMEDIUM *pStgmed) + { + // Notify our app that a change is being requested + return; + } + + + + + + + + +// Window Procedure for AX control +LRESULT CALLBACK AXWndProc(HWND hh,UINT mm,WPARAM ww,LPARAM ll) + { + if (mm == WM_CREATE) + { + char tit[1000] = {0}; + HRESULT hr; + + GetWindowTextA(hh,tit,1000); + + AX* ax; + ax = new AX(tit); + + SetWindowLong(hh,GWL_USERDATA,(LONG)ax); + ax->Site.Window = hh; + ax->Site.Parent = GetParent(hh); + + hr = StgCreateDocfile(0,STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_DIRECT | STGM_CREATE,0,&ax->Storage); + ax->Site.Window = hh; + + REFIID rid = *ax->iid; + hr = OleCreate(ax->GetCLSID(),rid,OLERENDER_DRAW,0,&ax->Site,ax->Storage,(void**)&ax->OleObject); + + + + if (!ax->OleObject) + { + delete ax; + SetWindowLong(hh,GWL_USERDATA,0); + return -1; + } + + hr = OleSetContainedObject(ax->OleObject, TRUE); + hr = ax->OleObject->Advise(&ax->Site,&ax->AdviseToken); + hr = ax->OleObject->QueryInterface(IID_IViewObject,(void**)&ax->View); + hr = ax->OleObject->QueryInterface(IID_IDataObject,(void**)&ax->Data); + if (ax->View) + hr = ax->View->SetAdvise(DVASPECT_CONTENT,0,&ax->Site); + + + + return 0; + } + + + + if (mm == WM_DESTROY) + { + AX* ax = (AX*)GetWindowLong(hh,GWL_USERDATA); + if (!ax) + return 0; + ax->Clean(); + return true; + } + + if (mm == AX_SETDATAADVISE) + { + AX* ax = (AX*)GetWindowLong(hh,GWL_USERDATA); + if (!ax) + return 0; + + // 1.Enum available FORMATETC structures + // 2.Set Data Advise specified to index ww + if (!ax->Data) + return 0; + + IEnumFORMATETC* ief = 0; + int i = 0; + + FORMATETC fe; + ax->Data->EnumFormatEtc((LPARAM)ll,&ief); + if (!ief) + return 0; + for(;;) + { + HRESULT hr = ief->Next(1,&fe,0); + if (hr != S_OK) + break; + if (ww == i) + break; + i++; + } + ief->Release(); + if (ww == -1) + return i; + + if (ax->Data) + ax->Data->DAdvise(&fe,0,&ax->Site,&ax->DAdviseToken[ww]); + + return true; + } + + if (mm == AX_GETAXINTERFACE) + { + AX* ax = (AX*)GetWindowLong(hh,GWL_USERDATA); + return (LONG)ax; + } + + if (mm == AX_QUERYINTERFACE) + { + char* p = (char*)ww; + AX* ax = (AX*)GetWindowLong(hh,GWL_USERDATA); + if (!ax) + return 0; + return ax->OleObject->QueryInterface((REFIID)*p,(void**)ll); + } + + if (mm == WM_LBUTTONDBLCLK) + { + PostMessage(hh,AX_INPLACE,1,0); + return 0; + } + + + if (mm == AX_INPLACE) + { + AX* ax = (AX*)GetWindowLong(hh,GWL_USERDATA); + if (!ax) + return 0; + if (!ax->OleObject) + return 0; + RECT rect; + HRESULT hr; + ::GetClientRect(hh,&rect); + + if (ax->Site.InPlace == false && ww == 1) // Activate In Place + { + ax->Site.InPlace = true; + ax->Site.ExternalPlace = ll; + hr = ax->OleObject->DoVerb(OLEIVERB_INPLACEACTIVATE,0,&ax->Site,0,hh,&rect); + InvalidateRect(hh,0,true); + return 1; + } + + if (ax->Site.InPlace == true && ww == 0) // Deactivate + { + ax->Site.InPlace = false; + + IOleInPlaceObject* iib; + ax->OleObject->QueryInterface(IID_IOleInPlaceObject,(void**)&iib); + if (iib) + { + iib->UIDeactivate(); + iib->InPlaceDeactivate(); + iib->Release(); + InvalidateRect(hh,0,true); + return 1; + } + } + return 0; + } + + if (mm == WM_SIZE) + { + AX* ax = (AX*)GetWindowLong(hh,GWL_USERDATA); + if (!ax) + return 0; + if (!ax->OleObject) + return 0; + + DefWindowProc(hh,mm,ww,ll); + + if (ax->Site.InPlace == true) + { + SendMessage(hh,AX_INPLACE,0,0); + InvalidateRect(hh,0,true); + SendMessage(hh,AX_INPLACE,1,0); + } + + IOleInPlaceObject* pl; + ax->OleObject->QueryInterface(IID_IOleInPlaceObject,(void**)&pl); + if (!pl) + return 0; + RECT r; + GetClientRect(ax->Site.Window,&r); + pl->SetObjectRects(&r,&r); + pl->Release(); + return 0; + } + + return DefWindowProc(hh,mm,ww,ll); + } + +// Registration function +ATOM AXRegister() + { + WNDCLASSEXA wC = {0}; + + wC.cbSize = sizeof(wC); + wC.style = CS_GLOBALCLASS | CS_DBLCLKS; + wC.lpfnWndProc = AXWndProc; + wC.cbWndExtra = 4; + wC.hInstance = GetModuleHandle(0); + wC.lpszClassName = "AX"; + return RegisterClassExA(&wC); + } + diff --git a/ax.h b/ax.h new file mode 100644 index 0000000..e935a9b --- /dev/null +++ b/ax.h @@ -0,0 +1,142 @@ +// AX.H + +// messages +#define AX_QUERYINTERFACE (WM_USER + 1) +#define AX_INPLACE (WM_USER + 2) +#define AX_GETAXINTERFACE (WM_USER + 3) +#define AX_CONNECTOBJECT (WM_USER + 4) +#define AX_DISCONNECTOBJECT (WM_USER + 5) +#define AX_SETDATAADVISE (WM_USER + 6) +#define AX_DOVERB (WM_USER + 7) + + +// Registration function +ATOM AXRegister(); + + +// Class AXClientSide +class AXClientSite : + public IOleClientSite, + public IDispatch, + public IAdviseSink, + public IOleInPlaceSite, + public IOleInPlaceFrame + { + protected: + + int refNum; + + public: + + + HWND Window; + HWND Parent; + HMENU Menu; + bool InPlace; + bool ExternalPlace; + bool CalledCanInPlace; + + class AX* ax; + + // MyClientSite Methods + AXClientSite(); + virtual ~AXClientSite(); + STDMETHODIMP_(void) OnDataChange2(FORMATETC*); + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID iid,void**ppvObject); + STDMETHODIMP_(ULONG) AddRef(); + STDMETHODIMP_(ULONG) Release(); + + // IOleClientSite methods + STDMETHODIMP SaveObject(); + STDMETHODIMP GetMoniker(DWORD dwA,DWORD dwW,IMoniker**pm); + STDMETHODIMP GetContainer(IOleContainer**pc); + STDMETHODIMP ShowObject(); + STDMETHODIMP OnShowWindow(BOOL f); + STDMETHODIMP RequestNewObjectLayout(); + + // IAdviseSink methods + STDMETHODIMP_(void) OnDataChange(FORMATETC *pFormatEtc,STGMEDIUM *pStgmed); + + STDMETHODIMP_(void) OnViewChange(DWORD dwAspect,LONG lIndex); + STDMETHODIMP_(void) OnRename(IMoniker * pmk); + STDMETHODIMP_(void) OnSave(); + STDMETHODIMP_(void) OnClose(); + + // IOleInPlaceSite methods + STDMETHODIMP GetWindow(HWND *p); + STDMETHODIMP ContextSensitiveHelp(BOOL); + STDMETHODIMP CanInPlaceActivate(); + STDMETHODIMP OnInPlaceActivate(); + STDMETHODIMP OnUIActivate(); + STDMETHODIMP GetWindowContext(IOleInPlaceFrame** ppFrame,IOleInPlaceUIWindow **ppDoc,LPRECT r1,LPRECT r2,LPOLEINPLACEFRAMEINFO o); + STDMETHODIMP Scroll(SIZE s); + STDMETHODIMP OnUIDeactivate(int); + STDMETHODIMP OnInPlaceDeactivate(); + STDMETHODIMP DiscardUndoState(); + STDMETHODIMP DeactivateAndUndo(); + STDMETHODIMP OnPosRectChange(LPCRECT); + + // IOleInPlaceFrame methods + STDMETHODIMP GetBorder(LPRECT l); + STDMETHODIMP RequestBorderSpace(LPCBORDERWIDTHS); + STDMETHODIMP SetBorderSpace(LPCBORDERWIDTHS w); + STDMETHODIMP SetActiveObject(IOleInPlaceActiveObject*pV,LPCOLESTR s); + STDMETHODIMP InsertMenus(HMENU h,LPOLEMENUGROUPWIDTHS x); + STDMETHODIMP SetMenu(HMENU h,HOLEMENU hO,HWND hw); + STDMETHODIMP RemoveMenus(HMENU h); + STDMETHODIMP SetStatusText(LPCOLESTR t); + STDMETHODIMP EnableModeless(BOOL f); + STDMETHODIMP TranslateAccelerator(LPMSG,WORD); + + + // IDispatch Methods + HRESULT _stdcall GetTypeInfoCount(unsigned int * pctinfo); + HRESULT _stdcall GetTypeInfo(unsigned int iTInfo,LCID lcid,ITypeInfo FAR* FAR* ppTInfo); + HRESULT _stdcall GetIDsOfNames(REFIID riid,OLECHAR FAR* FAR*,unsigned int cNames,LCID lcid,DISPID FAR* ); + HRESULT _stdcall Invoke(DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS FAR* pDispParams,VARIANT FAR* pVarResult,EXCEPINFO FAR* pExcepInfo,unsigned int FAR* puArgErr); + + // IOleControlSite Methods + }; + + + + +// Class AX +class AX + { + public: + + AX(char* clsid); + CLSID GetCLSID(); + ~AX(); + + + void Init(char* clsid); + void Clean(); + + AXClientSite Site; + IID* iid; + IOleObject* OleObject; + IStorage* Storage; + IViewObject* View; + IDataObject* Data; + IUnknown* Unk; + IOleInPlaceActiveObject* Pao; + //AX_CONNECTSTRUCT* tcs; + bool AddMenu; + DWORD AdviseToken; + DWORD DAdviseToken[100]; + + + + + private: + + CLSID clsid; + + + }; + + diff --git a/content/images/surface.png b/content/images/surface.png new file mode 100644 index 0000000..1be30dc Binary files /dev/null and b/content/images/surface.png differ diff --git a/content/images/surfacebr.png b/content/images/surfacebr.png new file mode 100644 index 0000000..6c41c96 Binary files /dev/null and b/content/images/surfacebr.png differ diff --git a/main.cpp b/main.cpp index 6c710b2..80fad74 100644 --- a/main.cpp +++ b/main.cpp @@ -11,9 +11,12 @@ @author Morgan McGuire, matrix@graphics3d.com */ +// TODO: Move toolbar buttons with resized window. + #define _WIN32_WINNT 0x0400 #include +#include #include #include "Instance.h" #include "resource.h" @@ -26,70 +29,120 @@ #include "Globals.h" #include "Demo.h" #include "win32Defines.h" +#include "WindowFunctions.h" #include - - +#include +#include +#include +#include +#include "ax.h" +#include +#include "IEBrowser.h" +#include "PropertyWindow.h" +#include #if G3D_VER < 61000 #error Requires G3D 6.10 #endif HWND hwnd; +DEFINE_GUID(CLSID_G3d, 0xB323F8E0L, 0x2E68, 0x11D0, 0x90, 0xEA, 0x00, 0xAA, 0x00, 0x60, 0xF8, 0x6F); +HRESULT hresult; +OLECHAR dat = ((OLECHAR)"SayHello"); +OLECHAR * szMember = &dat; +DISPID dispid; +DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; +EXCEPINFO excepinfo; +UINT nArgErr; + static std::string title = ""; static DataModelInstance* dataModel; GFontRef fntdominant = NULL; GFontRef fntlighttrek = NULL; Ray testRay; -static bool democ = true; static std::string message = ""; static G3D::RealTime messageTime = 0; static std::string tempPath = ""; -static G3D::RealTime inputTime = 0; -static int FPSVal[8] = {10, 20, 30, 60, 120, 240, INT_MAX,1}; -static int index = 2; static std::string cameraSound = ""; static std::string clickSound = ""; static std::string dingSound = ""; -static G3D::TextureRef go = NULL; -static G3D::TextureRef go_ovr = NULL; -static G3D::TextureRef go_dn = NULL; -VARAreaRef varStatic = NULL; -//static float dataModel->mousex = 0; -//static float dataModel->mousey = 0; static int cursorid = 0; static G3D::TextureRef cursor = NULL; -//static bool dataModel->mouseButton1Down = false; static bool running = true; static bool mouseMovedBeginMotion = false; -static bool showMouse = true; -//Controller -static bool forwards = false; -static bool backwards = false; -static bool left = false; -static bool right = false; -static bool centerCam = false; -static bool panRight = false; -static bool panLeft = false; -static bool tiltUp = false; static const int CURSOR = 0; static const int ARROWS = 1; static const int RESIZE = 2; static POINT oldGlobalMouse; - static int mode = CURSOR; bool dragging = false; -Vector3 cameraPos = Vector3(0,2,10); Vector2 oldMouse = Vector2(0,0); float moveRate = 0.5; -Instance* selectedInstance = NULL; +static const std::string PlaceholderName = "HyperCube"; Demo *usableApp = NULL; -Demo::Demo(const GAppSettings& settings,Win32Window* window) : GApp(settings,window) { - varStatic = VARArea::create(1024 * 1024); - hWndMain = window->hwnd(); +Demo::Demo(const GAppSettings& settings,HWND parentWindow) { //: GApp(settings,window) { + _hWndMain = parentWindow; + + HMODULE hThisInstance = GetModuleHandle(NULL); + + _hwndToolbox = CreateWindowEx( + WS_EX_ACCEPTFILES, + "AX", + "{8856F961-340A-11D0-A96B-00C04FD705A2}", + WS_CHILD | WS_VISIBLE, + 0, + 560, + 800, + 60, + _hWndMain, // parent + NULL, // menu + hThisInstance, + NULL + ); + + _hwndRenderer = CreateWindowEx( + WS_EX_ACCEPTFILES, + "G3DWindow", + "3D", + WS_CHILD, + CW_USEDEFAULT, + CW_USEDEFAULT, + 1, + 1, + _hWndMain, // parent + NULL, // menu + hThisInstance, + NULL + ); + + Win32Window* window = Win32Window::create(settings.window,_hwndRenderer); + ShowWindow(_hwndRenderer, SW_SHOW); + ShowWindow(_hWndMain, SW_SHOW); + quit=false; rightButtonHolding=false; + mouseOnScreen=false; + // GApp replacement + renderDevice = new RenderDevice(); + if (window != NULL) { + renderDevice->init(window, NULL); + } + else + { + MessageBox(NULL,"Window not found!","Error",MB_OK); + return; + } + + _window = renderDevice->window(); + _window->makeCurrent(); + + SetWindowLongPtr(_hWndMain,GWL_USERDATA,(LONG)this); + SetWindowLongPtr(_hwndRenderer,GWL_USERDATA,(LONG)this); + _propWindow = new PropertyWindow(0, 0, 200, 640, hThisInstance); + IEBrowser* webBrowser = new IEBrowser(_hwndToolbox); + //webBrowser->navigateSyncURL(L"http://scottbeebiwan.tk/g3d/toolbox/"); } void clearInstances() @@ -101,9 +154,10 @@ void OnError(int err, std::string msg = "") { //usableApp->window()->setInputCaptureCount(0); //usableApp->window()->setMouseVisible(true); - std::string emsg = "An unexpected error has occured and DUOM 5 has to quit. We're sorry!" + msg; - clearInstances(); - MessageBox(NULL, emsg.c_str(),"Dynamica Crash", MB_OK); + std::string emsg = "An unexpected error has occured and "+PlaceholderName+" has to quit. We're sorry!" + msg; + std::string title = PlaceholderName+"Crash"; + //clearInstances(); + MessageBox(NULL, emsg.c_str(), title.c_str(), MB_OK); exit(err); } @@ -168,8 +222,8 @@ void CameraButtonListener::onButton1MouseClick(BaseButtonInstance* button) { AudioPlayer::playSound(cameraSound); CoordinateFrame frame = usableApp->cameraController.getCamera()->getCoordinateFrame(); - if(button->name == "CenterCam") - usableApp->cameraController.centerCamera(selectedInstance); + if(button->name == "CenterCam" && g_selectedInstances.size() > 0) + usableApp->cameraController.centerCamera(g_selectedInstances.at(0)); else if(button->name == "ZoomIn") usableApp->cameraController.Zoom(1); else if(button->name == "ZoomOut") @@ -191,15 +245,30 @@ public: void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button) { - if(selectedInstance != NULL) + if(g_selectedInstances.size() > 0) { AudioPlayer::playSound(dingSound); if(button->name == "Duplicate") { + std::vector newinst; + for(size_t i = 0; i < g_selectedInstances.size(); i++) + { + if(g_selectedInstances.at(i) != dataModel->getWorkspace()) + { + Instance* tempinst = g_selectedInstances.at(i); + + Instance* clonedInstance = g_selectedInstances.at(i)->clone(); + newinst.push_back(tempinst); + } + /*tempinst->setPosition(Vector3(tempPos.x, tempPos.y + tempSize.y, tempPos.z)); + usableApp->cameraController.centerCamera(g_selectedInstances.at(0));*/ + } + g_selectedInstances = newinst; + if(g_selectedInstances.size() > 0) + usableApp->_propWindow->SetProperties(newinst.at(0)); } } - } class RotateButtonListener : public ButtonListener { @@ -209,12 +278,12 @@ public: void RotateButtonListener::onButton1MouseClick(BaseButtonInstance* button) { - if(selectedInstance != NULL) + if(g_selectedInstances.size() > 0) { + Instance* selectedInstance = g_selectedInstances.at(0); AudioPlayer::playSound(clickSound); - if(selectedInstance->getClassName() == "Part") + if(PhysicalInstance* part = dynamic_cast(selectedInstance)) { - PhysicalInstance* part = (PhysicalInstance*) selectedInstance; if(button->name == "Tilt") part->setCFrame(part->getCFrame()*Matrix3::fromEulerAnglesXYZ(0,0,toRadians(90))); else if(button->name == "Rotate") @@ -227,14 +296,29 @@ void RotateButtonListener::onButton1MouseClick(BaseButtonInstance* button) void deleteInstance() { - if(selectedInstance != NULL) + if(g_selectedInstances.size() > 0) { - if(selectedInstance->getParent() != NULL) - selectedInstance->getParent()->removeChild(selectedInstance); - delete selectedInstance; - selectedInstance = NULL; - AudioPlayer::playSound(GetFileInPath("/content/sounds/pageturn.wav")); + size_t undeletable = 0; + while(g_selectedInstances.size() > undeletable) + { + if(g_selectedInstances.at(0) != dataModel && g_selectedInstances.at(0) != dataModel->getWorkspace()) + { + AudioPlayer::playSound(GetFileInPath("/content/sounds/pageturn.wav")); + Instance* selectedInstance = g_selectedInstances.at(0); + if(selectedInstance->getParent() != NULL) + selectedInstance->getParent()->removeChild(selectedInstance); + delete selectedInstance; + selectedInstance = NULL; + g_selectedInstances.erase(g_selectedInstances.begin()); + } + else + { + undeletable++; + } + } } + if(g_selectedInstances.size() == 0) + usableApp->_propWindow->ClearProperties(); } @@ -452,14 +536,15 @@ void Demo::initGUI() button->name = "Duplicate"; button->setButtonListener(new GUDButtonListener()); - - ImageButtonInstance* instance = makeImageButton(go, go_ovr, go_dn); + ImageButtonInstance* instance = makeImageButton( + Texture::fromFile(GetFileInPath("/content/images/Run.png")), + Texture::fromFile(GetFileInPath("/content/images/Run_ovr.png")), + Texture::fromFile(GetFileInPath("/content/images/Run_dn.png"))); instance->name = "go"; instance->size = Vector2(65,65); instance->position = Vector2(6.5, 25); instance->setParent(dataModel->getGuiRoot()); - instance = makeImageButton( Texture::fromFile(GetFileInPath("/content/images/ArrowTool.png")), @@ -614,7 +699,7 @@ void Demo::initGUI() void Demo::onInit() { // Called before Demo::run() beings - cameraController.setFrame(cameraPos); + cameraController.setFrame(Vector3(0,2,10)); dataModel = new DataModelInstance(); dataModel->setParent(NULL); dataModel->name = "undefined"; @@ -629,7 +714,7 @@ void Demo::onInit() { test->color = Color3(0.2F,0.3F,1); test->setSize(Vector3(24,1,24)); test->setPosition(Vector3(0,0,0)); - test->setCFrame(test->getCFrame() * Matrix3::fromEulerAnglesXYZ(0,toRadians(40),toRadians(40))); + test->setCFrame(test->getCFrame() * Matrix3::fromEulerAnglesXYZ(0,toRadians(0),toRadians(0))); @@ -721,15 +806,6 @@ void Demo::onInit() { void Demo::onCleanup() { clearInstances(); - go->~Texture(); - go_ovr->~Texture(); - go_dn->~Texture(); - go_dn.~ReferenceCountedPointer(); - delete go_dn.pointer(); - go.~ReferenceCountedPointer(); - delete go.pointer(); - go_ovr.~ReferenceCountedPointer(); - delete go_ovr.pointer(); sky->~Sky(); } @@ -738,16 +814,8 @@ void Demo::onCleanup() { void Demo::onLogic() { // Add non-simulation game logic and AI code here - - Instance* obj = dataModel->getGuiRoot()->findFirstChild("Delete"); - if(obj != NULL) - { - ImageButtonInstance* button = (ImageButtonInstance*)obj; - if(selectedInstance == NULL) - button->disabled = true; - else - button->disabled = false; - } + + } @@ -763,16 +831,28 @@ void Demo::onNetwork() { // return pow(pow((double)vector1.x - (double)vector2.x, 2) + pow((double)vector1.y - (double)vector2.y, 2) + pow((double)vector1.z - (double)vector2.z, 2), 0.5); //} -Instance* Demo::getSelection() +std::vector Demo::getSelection() { - return selectedInstance; + return g_selectedInstances; } void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) { + + Instance* obj = dataModel->getGuiRoot()->findFirstChild("Delete"); + if(obj != NULL) + { + ImageButtonInstance* button = (ImageButtonInstance*)obj; + if(g_selectedInstances.size() <= 0 || g_selectedInstances.at(0) == dataModel->getWorkspace()) + button->disabled = true; + else + button->disabled = false; + } + + if(dataModel->name != title) { title = dataModel->name; std::string text = "Game \"" + title + "\""; - SetWindowText(hWndMain, text.c_str()); + SetWindowText(_hWndMain, text.c_str()); } @@ -796,8 +876,13 @@ bool IsHolding(int button) return (GetKeyState(button) >> 1)>0; } +BOOL GetKPBool(int VK) { + return (GetKeyState(VK) & 0x8000); +} + void Demo::onUserInput(UserInput* ui) { + /* if(GetHoldKeyState(VK_LCONTROL)) { if(GetHoldKeyState('D')) @@ -806,15 +891,17 @@ void Demo::onUserInput(UserInput* ui) { if(debugMode()) message = "Debug Mode Disabled"; else - message = "Debug Mode Enabled, Soon to be depricated"; + message = "Debug Mode Enabled"; setDebugMode(!debugMode()); } } - //if(ui->keyPressed(SDLK_F8)) - //{ - // messageTime = System::time(); - // message = "FPS has been locked at " + Convert(FPSVal[index]); - //setDesiredFrameRate(FPSVal[index]); + */ + if(GetHoldKeyState(VK_F8)) + { + messageTime = System::time(); + message = "FOV Set to 10"; + + } //} //dataModel->mousex = ui->getMouseX(); @@ -823,14 +910,15 @@ void Demo::onUserInput(UserInput* ui) { if (GetHoldKeyState(VK_LBUTTON)) { if (dragging) { - PhysicalInstance* part = (PhysicalInstance*) selectedInstance; + PhysicalInstance* part = NULL; + if(g_selectedInstances.size() > 0) + part = (PhysicalInstance*) g_selectedInstances.at(0); Ray dragRay = cameraController.getCamera()->worldRay(dataModel->mousex, dataModel->mousey, renderDevice->getViewport()); std::vector instances = dataModel->getWorkspace()->getAllChildren(); for(size_t i = 0; i < instances.size(); i++) { - if(instances.at(i)->getClassName() == "Part") + if(PhysicalInstance* moveTo = dynamic_cast(instances.at(i))) { - PhysicalInstance* moveTo = (PhysicalInstance*)instances.at(i); float __time = testRay.intersectionTime(moveTo->getBox()); float __nearest=std::numeric_limits::infinity(); if (__time != inf()) @@ -847,16 +935,21 @@ void Demo::onUserInput(UserInput* ui) { Sleep(10); } } - + // Camera KB Handling { + if (GetKPBool(VK_OEM_COMMA)) //Left + usableApp->cameraController.panLeft(); + else if (GetKPBool(VK_OEM_PERIOD)) // Right + usableApp->cameraController.panRight(); + else if (GetKPBool(0x49)) // Zoom In (I) + usableApp->cameraController.Zoom(1); + else if (GetKPBool(0x4F)) // Zoom Out (O) + usableApp->cameraController.Zoom(-1); + // } //readMouseGUIInput(); // Add other key handling here } - - - - void makeFlag(Vector3 &vec, RenderDevice* &rd) { @@ -997,7 +1090,7 @@ void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters void Demo::exitApplication() { //endApplet = true; - endProgram = true; + //endProgram = true; } @@ -1005,10 +1098,10 @@ void Demo::onGraphics(RenderDevice* rd) { G3D::uint8 num = 0; POINT mousepos; - bool mouseOnScreen = true; + mouseOnScreen = true; if (GetCursorPos(&mousepos)) { - if (ScreenToClient(hWndMain, &mousepos)) + if (ScreenToClient(_hWndMain, &mousepos)) { //mouseOnScreen = true; @@ -1016,20 +1109,25 @@ void Demo::onGraphics(RenderDevice* rd) { { mouseOnScreen = false; //ShowCursor(true); - window()->setMouseVisible(true); + _window->setMouseVisible(true); //rd->window()->setInputCaptureCount(0); } else { mouseOnScreen = true; //SetCursor(NULL); - window()->setMouseVisible(false); + _window->setMouseVisible(false); //rd->window()->setInputCaptureCount(1); } } } + if(Globals::useMousePoint) + { + mousepos = Globals::mousepoint; + ScreenToClient(_hWndMain, &mousepos); + } LightingParameters lighting(G3D::toSeconds(11, 00, 00, AM)); renderDevice->setProjectionAndCameraMatrix(*cameraController.getCamera()); @@ -1055,12 +1153,17 @@ void Demo::onGraphics(RenderDevice* rd) { dataModel->getWorkspace()->render(rd); rd->afterPrimitive(); - if(selectedInstance != NULL) + if(g_selectedInstances.size() > 0) { - PhysicalInstance* part = (PhysicalInstance*)selectedInstance; - Vector3 size = part->getSize(); - Vector3 pos = part->getPosition(); - drawOutline(Vector3(0+size.x/4, 0+size.y/4, 0+size.z/4) ,Vector3(0-size.x/4,0-size.y/4,0-size.z/4), rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x/2, pos.y/2, pos.z/2), part->getCFrameRenderBased()); + for(size_t i = 0; i < g_selectedInstances.size(); i++) + { + if(PhysicalInstance* part = dynamic_cast(g_selectedInstances.at(i))) + { + Vector3 size = part->getSize(); + Vector3 pos = part->getPosition(); + drawOutline(Vector3(0+size.x/4, 0+size.y/4, 0+size.z/4) ,Vector3(0-size.x/4,0-size.y/4,0-size.z/4), rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x/2, pos.y/2, pos.z/2), part->getCFrameRenderBased()); + } + } } @@ -1111,7 +1214,7 @@ void Demo::onGraphics(RenderDevice* rd) { rd->pushState(); rd->beforePrimitive(); - if(showMouse && mouseOnScreen) + if(Globals::showMouse && mouseOnScreen) { glEnable( GL_TEXTURE_2D ); glEnable(GL_BLEND);// you enable blending function @@ -1152,17 +1255,18 @@ void Demo::onKeyUp(int key) } -void Demo::onMouseLeftPressed(int x,int y) +void Demo::onMouseLeftPressed(HWND hwnd,int x,int y) { + SetFocus(hwnd); + std::cout << "Click: " << x << "," << y << std::endl; bool onGUI = false; std::vector instances_2D = dataModel->getGuiRoot()->getAllChildren(); for(size_t i = 0; i < instances_2D.size(); i++) { - if(instances_2D.at(i)->getClassName() == "TextButton" || instances_2D.at(i)->getClassName() == "ImageButton") + if(BaseButtonInstance* button = dynamic_cast(instances_2D.at(i))) { - BaseButtonInstance* button = (BaseButtonInstance*)instances_2D.at(i); if(button->mouseInButton(x,y, renderDevice)) { onGUI = true; @@ -1172,29 +1276,55 @@ void Demo::onMouseLeftPressed(int x,int y) } if(!onGUI) { - selectedInstance = NULL; testRay = cameraController.getCamera()->worldRay(dataModel->mousex, dataModel->mousey, renderDevice->getViewport()); float nearest=std::numeric_limits::infinity(); Vector3 camPos = cameraController.getCamera()->getCoordinateFrame().translation; std::vector instances = dataModel->getWorkspace()->getAllChildren(); - for(size_t i = 0; i < instances.size(); i++) + bool objFound = false; + for(size_t i = 0; i < instances.size(); i++) { - if(instances.at(i)->getClassName() == "Part") + if(PhysicalInstance* test = dynamic_cast(instances.at(i))) { - PhysicalInstance* test = (PhysicalInstance*)instances.at(i); float time = testRay.intersectionTime(test->getBox()); + if (time != inf()) { + objFound = true; if (nearest>time) { nearest=time; - selectedInstance = test; + bool found = false; + for(size_t i = 0; i < g_selectedInstances.size(); i++) + { + if(g_selectedInstances.at(i) == test) + { + found = true; + ShowWindow(_propWindow->_hwndProp, SW_SHOW); + SetActiveWindow(_propWindow->_hwndProp); + SetForegroundWindow(_propWindow->_hwndProp); + break; + } + } + if(!found) + {while(g_selectedInstances.size() > 0) + g_selectedInstances.erase(g_selectedInstances.begin()); + g_selectedInstances.push_back(test); + } + _propWindow->SetProperties(test); //message = "Dragging = true."; //messageTime = System::time(); //dragging = true; } } - } + } + } + if(!objFound) + { + while(g_selectedInstances.size() > 0) + g_selectedInstances.erase(g_selectedInstances.begin()); + g_selectedInstances.push_back(dataModel->getWorkspace()); + _propWindow->SetProperties(dataModel->getWorkspace()); + } } } @@ -1209,9 +1339,8 @@ void Demo::onMouseLeftUp(int x,int y) std::vector instances = dataModel->getWorkspace()->getAllChildren(); for(size_t i = 0; i < instances_2D.size(); i++) { - if(instances_2D.at(i)->getClassName() == "TextButton" || instances_2D.at(i)->getClassName() == "ImageButton") + if(BaseButtonInstance* button = dynamic_cast(instances_2D[i])) { - BaseButtonInstance* button = (BaseButtonInstance*)instances_2D.at(i); if(button->mouseInButton(x, y, renderDevice)) { button->onMouseClick(); @@ -1234,6 +1363,7 @@ void Demo::onMouseMoved(int x,int y) } void Demo::onMouseWheel(int x,int y,short delta) { + if (mouseOnScreen==true) if (cameraController.onMouseWheel(x, y, delta)) { AudioPlayer::playSound(cameraSound); @@ -1262,7 +1392,67 @@ App::~App() { } */ +void Boop() +{ + OnError(1, "Test"); +} + + LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + Demo *app = (Demo *)GetWindowLongPtr(hwnd, GWL_USERDATA); + if (app==NULL) + { + return DefWindowProc(hwnd, msg, wParam, lParam); + } + switch(msg) + { + case WM_KEYDOWN: + if ((HIWORD(lParam)&0x4000)==0) // single key press + { + app->onKeyPressed(wParam); + } + break; + case WM_KEYUP: + { + app->onKeyUp(wParam); + } + break; + case WM_MOUSEWHEEL: + app->onMouseWheel(LOWORD(lParam),HIWORD(lParam),HIWORD(wParam)); + break; + case WM_SIZE: + app->resizeWithParent(hwnd); + break; + default: + { + return DefWindowProc(hwnd, msg, wParam, lParam); + } + } + return 0; +} + +LRESULT CALLBACK ToolboxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + //Demo *app = (Demo *)GetWindowLongPtr(hwnd, GWL_USERDATA); + MessageBox(NULL, (LPCSTR)wParam, (LPCSTR)lParam, 1); + //if (app==NULL) + //{ + //return DefWindowProc(hwnd, msg, wParam, lParam); + //} + switch(msg) + { + case WM_SIZE: + break; + default: + { + return DefWindowProc(hwnd, msg, wParam, lParam); + } + } + return 0; +} + +LRESULT CALLBACK G3DProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { Demo *app = (Demo *)GetWindowLongPtr(hwnd, GWL_USERDATA); if (app==NULL) @@ -1277,22 +1467,8 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_DESTROY: app->QuitApp(); break; - case WM_KEYDOWN: - if ((HIWORD(lParam)&0x4000)==0) // single key press - { - app->onKeyPressed(wParam); - } - break; - case WM_KEYUP: - { - app->onKeyUp(wParam); - } - break; case WM_LBUTTONDOWN: - app->onMouseLeftPressed(LOWORD(lParam),HIWORD(lParam)); - break; - case WM_MOUSEMOVE: - app->onMouseMoved(LOWORD(lParam),HIWORD(lParam)); + app->onMouseLeftPressed(hwnd,LOWORD(lParam),HIWORD(lParam)); break; case WM_LBUTTONUP: app->onMouseLeftUp(LOWORD(lParam),HIWORD(lParam)); @@ -1303,16 +1479,11 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_RBUTTONUP: app->onMouseRightUp(LOWORD(lParam),HIWORD(lParam)); break; - case WM_MOUSEWHEEL: - app->onMouseWheel(LOWORD(lParam),HIWORD(lParam),HIWORD(wParam)); + case WM_MOUSEMOVE: + app->onMouseMoved(LOWORD(lParam),HIWORD(lParam)); break; case WM_SIZE: { - int viewWidth = LOWORD(lParam); - int viewHeight = HIWORD(lParam); - app->renderDevice->notifyResize(viewWidth,viewHeight); - Rect2D viewportRect = Rect2D::xywh(0,0,viewWidth,viewHeight); - app->renderDevice->setViewport(viewportRect); app->onGraphics(app->renderDevice); } break; @@ -1324,46 +1495,10 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return 0; } - -LRESULT CALLBACK ToolProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - //Demo *app = (Demo *)GetWindowLongPtr(hwnd, GWL_USERDATA); - switch(msg) - { - case WM_SIZE: - break; - default: - { - return DefWindowProc(hwnd, msg, wParam, lParam); - } - } - return 0; -} - -bool createWindowClass(const char* name,WNDPROC proc,HMODULE hInstance) -{ - WNDCLASSEX wc; - wc.cbSize = sizeof(WNDCLASSEX); - wc.style = 0; - wc.lpfnWndProc = proc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)(COLOR_WINDOW); - wc.lpszMenuName = NULL; - wc.lpszClassName = name; - wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); - if (!RegisterClassEx (&wc)) - return false; - return true; -} - -void Demo::main() { +void Demo::run() { usableApp = this; - setDebugMode(false); - debugController.setActive(false); + //setDebugMode(false); + //debugController.setActive(false); /* if (!createWindowClass("ToolWindowClass",ToolProc,GetModuleHandle(0))) { @@ -1378,13 +1513,12 @@ void Demo::main() { ShowWindow(propertyHWnd,SW_SHOW); */ - UpdateWindow(hWndMain); + UpdateWindow(_hWndMain); // Load objects here= - go = Texture::fromFile(GetFileInPath("/content/images/Run.png")); - go_ovr = Texture::fromFile(GetFileInPath("/content/images/Run_ovr.png")); - go_dn = Texture::fromFile(GetFileInPath("/content/images/Run_dn.png")); cursor = Texture::fromFile(GetFileInPath("/content/cursor2.png")); + Globals::surface = Texture::fromFile(GetFileInPath("/content/images/surfacebr.png")); + Globals::surfaceId = Globals::surface->getOpenGLID(); fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt")); fntlighttrek = GFont::fromFile(GetFileInPath("/content/font/lighttrek.fnt")); cameraSound = GetFileInPath("/content/sounds/SWITCH3.wav"); @@ -1402,13 +1536,13 @@ void Demo::main() { RealTime lastWaitTime=0; MSG messages; - RECT cRect; - GetClientRect(hWndMain,&cRect); - - renderDevice->notifyResize(cRect.right,cRect.bottom); - Rect2D viewportRect = Rect2D::xywh(0,0,cRect.right,cRect.bottom); - renderDevice->setViewport(viewportRect); + //RECT cRect; + //GetClientRect(_hWndMain,&cRect); + //renderDevice->notifyResize(cRect.right,cRect.bottom); + //Rect2D viewportRect = Rect2D::xywh(0,0,cRect.right,cRect.bottom); + //renderDevice->setViewport(viewportRect); //window()->setInputCaptureCount(1); + resizeWithParent(_hWndMain); while (!quit) { @@ -1419,7 +1553,7 @@ void Demo::main() { m_userInputWatch.tick(); onUserInput(userInput); - m_moduleManager->onUserInput(userInput); + //m_moduleManager->onUserInput(userInput); m_userInputWatch.tock(); m_simulationWatch.tick(); @@ -1449,14 +1583,14 @@ void Demo::main() { renderDevice->pushState(); onGraphics(renderDevice); renderDevice->popState(); - renderDebugInfo(); + //renderDebugInfo(); renderDevice->endFrame(); - debugText.clear(); + //debugText.clear(); m_graphicsWatch.tock(); while (PeekMessage (&messages, NULL, 0, 0,PM_REMOVE)) { - if (IsDialogMessage(hWndMain, &messages) == 0) + if (IsDialogMessage(_hWndMain, &messages) == 0) { TranslateMessage(&messages); DispatchMessage(&messages); @@ -1465,18 +1599,55 @@ void Demo::main() { } onCleanup(); } +void Demo::resizeWithParent(HWND parentWindow) +{ + RECT rect; + GetClientRect(parentWindow,&rect); + SetWindowPos(_hwndRenderer,NULL,0,0,rect.right,rect.bottom-60,SWP_NOMOVE); + SetWindowPos(_hwndToolbox,NULL,0,rect.bottom-60,rect.right,60,SWP_NOACTIVATE | SWP_SHOWWINDOW); + GetClientRect(_hwndRenderer,&rect); + int viewWidth=rect.right; + int viewHeight=rect.bottom; + renderDevice->notifyResize(viewWidth,viewHeight); + Rect2D viewportRect = Rect2D::xywh(0,0,viewWidth,viewHeight); + renderDevice->setViewport(viewportRect); + +} void Demo::QuitApp() { PostQuitMessage(0); quit=true; } +void Demo::onCreate(HWND parentWindow) +{ + //SetWindowLongPtr(hwndRenderer,GWL_USERDATA,(LONG)this); + //SetWindowLongPtr(hwndToolbox,GWL_USERDATA,(LONG)this); + //SetWindowLongPtr(hwndMain,GWL_USERDATA,(LONG)&demo); +} int main(int argc, char** argv) { try{ - tempPath = ((std::string)getenv("temp")) + "/Dynamica"; + hresult = OleInitialize(NULL); + if (!AXRegister()) + return 0; + + + INITCOMMONCONTROLSEX icc; +// WNDCLASSEX wcx; + + /* Initialize common controls. Also needed for MANIFEST's */ + + icc.dwSize = sizeof(icc); + icc.dwICC = ICC_WIN95_CLASSES/*|ICC_COOL_CLASSES|ICC_DATE_CLASSES| + ICC_PAGESCROLLER_CLASS|ICC_USEREX_CLASSES*/; + InitCommonControlsEx(&icc); + + tempPath = ((std::string)getenv("temp")) + "/"+PlaceholderName; CreateDirectory(tempPath.c_str(), NULL); - + + + message = tempPath; messageTime = System::time(); AudioPlayer::init(); @@ -1488,13 +1659,13 @@ int main(int argc, char** argv) { HMODULE hThisInstance = GetModuleHandle(NULL); if (!createWindowClass("mainHWND",WndProc,hThisInstance)) - { - MessageBox(NULL, "Failed to register mainHWND","Dynamica Crash", MB_OK); return false; - } + if (!createWindowClass("toolboxHWND",ToolboxProc,hThisInstance)) + return false; + if (!createWindowClass("G3DWindow",G3DProc,hThisInstance)) + return false; - - HWND hwndMain = CreateWindowEx( + HWND hwndMain = CreateWindowEx( WS_EX_ACCEPTFILES, "mainHWND", "Main test", @@ -1502,26 +1673,23 @@ int main(int argc, char** argv) { CW_USEDEFAULT, CW_USEDEFAULT, 800, - 600, + 660, NULL, // parent NULL, // menu hThisInstance, NULL ); - + if(hwndMain == NULL) { - MessageBox(NULL, "Failed to create HWND","Dynamica Crash", MB_OK); + MessageBox(NULL, "Failed to create HWND", (PlaceholderName + " Crash").c_str() , MB_OK); return 0; } SendMessage(hwndMain, WM_SETICON, ICON_BIG,(LPARAM)LoadImage(GetModuleHandle(NULL), (LPCSTR)MAKEINTRESOURCEW(IDI_ICON1), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE)); - ShowWindow(hwndMain, SW_SHOW); - Win32Window* win32Window = Win32Window::create(settings.window,hwndMain); - Demo demo = Demo(settings,win32Window); - - SetWindowLongPtr(hwndMain,GWL_USERDATA,(LONG)&demo); - demo.run(); + + Demo demo = Demo(settings,hwndMain); + demo.run(); } catch(...) { diff --git a/propertyGrid.cpp b/propertyGrid.cpp new file mode 100644 index 0000000..13f16b2 --- /dev/null +++ b/propertyGrid.cpp @@ -0,0 +1,4439 @@ +////////////////////////////////////////////////////////////////////////////// +/// +/// @file propertyGrid.c +/// +/// @brief A property grid control in Win32 SDK C. +/// +/// @author David MacDermot +/// +/// @par Comments: +/// This source is distributed in the hope that it will be useful, +/// but WITHOUT ANY WARRANTY; without even the implied warranty of +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +/// +/// @date 2-27-16 +/// +/// @todo +/// +/// @bug +/// +////////////////////////////////////////////////////////////////////////////// + +//DWM 1.1: Version 1.1 changes labelled thus. +//DWM 1.2: Version 1.2 changes labelled thus. +//DWM 1.3: Version 1.3 changes labelled thus. +//DWM 1.4: Version 1.4 changes labelled thus. +//DWM 1.5: Version 1.5 changes labelled thus. +//DWM 1.6: Version 1.6 changes labelled thus. +//DWM 1.7: Version 1.7 changes labelled thus. +//DWM 1.8: Version 1.8 changes labelled thus. +//DWM 1.9: Version 1.9 changes labelled thus. + +//DWM 1.9: Suppress POCC Warning "Argument x to 'sscanf' does not match the format string; +// expected 'unsigned char *' but found 'unsigned long'" +#ifdef __POCC__ +#pragma warn(disable:2234) +#endif + +#ifndef _WIN32_WINNT // Necessary for WM_MOUSEWHEEL support +#define _WIN32_WINNT 0x0500 +#endif + +// MSVC++ Support +#ifndef _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS +#endif + +#define WIN32_LEAN_AND_MEAN + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "propertyGrid.h" + +// Begin MSVC++ Support + +#ifdef _stprintf +#undef _stprintf +#endif + +#ifdef _UNICODE +#define _tmemcpy wmemcpy +#define _tmemmove wmemmove +#define _tmemset wmemset +#define _stprintf swprintf +#else +#define _tmemcpy memcpy +#define _tmemmove memmove +#define _tmemset memset +#define _stprintf _snprintf +#endif + +#define ToolTip_AddTool(hwnd,lpti) (BOOL)SNDMSG((hwnd),TTM_ADDTOOL,0,(LPARAM)(LPTOOLINFO)(lpti)) +#define ToolTip_EnumTools(hwnd,iTool,lpti) (BOOL)SNDMSG((hwnd),TTM_ENUMTOOLS,(WPARAM)(UINT)(iTool),(LPARAM)(LPTOOLINFO)(lpti)) +#define ToolTip_UpdateTipText(hwnd,lpti) (void)SNDMSG((hwnd),TTM_UPDATETIPTEXT,0,(LPARAM)(LPTOOLINFO)(lpti)) +#define ToolTip_NewToolRect(hwnd,lpti) (void)SNDMSG((hwnd),TTM_NEWTOOLRECT,0,(LPARAM)(LPTOOLINFO)(lpti)) + + +// End MSVC++ Support + +#define ID_LISTBOX 2000 ///