diff --git a/Application.cpp b/Application.cpp index 4c90e99..a1e1de4 100644 --- a/Application.cpp +++ b/Application.cpp @@ -32,11 +32,9 @@ #include "RotateButtonListener.h" #define LEGACY_LOAD_G3DFUN_LEVEL Ray testRay; -static int cursorid = 0; -static int cursorOvrid = 0; -static int currentcursorid = 0; -static G3D::TextureRef cursor = NULL; -static G3D::TextureRef cursorOvr = NULL; +//static int cursorid = 0; +//static int cursorOvrid = 0; +//static int currentcursorid = 0; static bool mouseMovedBeginMotion = false; static POINT oldGlobalMouse; Vector2 oldMouse = Vector2(0,0); @@ -181,7 +179,7 @@ void Application::deleteInstance() void Application::onInit() { - + tool = new Tool(); // Called before Application::run() beings cameraController.setFrame(Vector3(0,2,10)); _dataModel = new DataModelInstance(); @@ -440,14 +438,14 @@ void Application::onUserInput(UserInput* ui) { //_dataModel->mousex = ui->getMouseX(); //_dataModel->mousey = ui->getMouseY(); - _dataModel->mouseButton1Down = (GetKeyState(VK_LBUTTON) & 0x100) != 0; + mouse.setMouseDown((GetKeyState(VK_LBUTTON) & 0x100) != 0); if (GetHoldKeyState(VK_LBUTTON)) { if (_dragging) { PartInstance* part = NULL; if(g_selectedInstances.size() > 0) part = (PartInstance*) g_selectedInstances.at(0); - Ray dragRay = cameraController.getCamera()->worldRay(_dataModel->mousex, _dataModel->mousey, renderDevice->getViewport()); + Ray dragRay = cameraController.getCamera()->worldRay(mouse.x, mouse.y, renderDevice->getViewport()); std::vector instances = _dataModel->getWorkspace()->getAllChildren(); for(size_t i = 0; i < instances.size(); i++) { @@ -735,7 +733,7 @@ void Application::onGraphics(RenderDevice* rd) { } } */ - glBindTexture( GL_TEXTURE_2D, currentcursorid); + glBindTexture( GL_TEXTURE_2D, tool->getCursorId()); glBegin( GL_QUADS ); @@ -767,10 +765,11 @@ void Application::onKeyPressed(int key) { _dataModel->getOpen(); } + tool->onKeyDown(key); } void Application::onKeyUp(int key) { - + tool->onKeyUp(key); } void Application::onMouseLeftPressed(HWND hwnd,int x,int y) @@ -779,14 +778,16 @@ void Application::onMouseLeftPressed(HWND hwnd,int x,int y) //std::cout << "Click: " << x << "," << y << std::endl; - + + bool onGUI = _dataModel->getGuiRoot()->mouseInGUI(renderDevice, x, y); if(!onGUI) { + tool->onButton1MouseDown(mouse); Instance * selectedInstance = NULL; - testRay = cameraController.getCamera()->worldRay(_dataModel->mousex, _dataModel->mousey, renderDevice->getViewport()); + testRay = cameraController.getCamera()->worldRay(mouse.x, mouse.y, renderDevice->getViewport()); float nearest=std::numeric_limits::infinity(); Vector3 camPos = cameraController.getCamera()->getCoordinateFrame().translation; std::vector instances = _dataModel->getWorkspace()->getAllChildren(); @@ -868,6 +869,7 @@ void Application::onMouseLeftUp(G3D::RenderDevice* renderDevice, int x, int y) //std::cout << "Release: " << x << "," << y << std::endl; _dataModel->getGuiRoot()->onMouseLeftUp(renderDevice, x, y); _dragging = false; + tool->onButton1MouseUp(mouse); //_message = "Dragging = false."; //_messageTime = System::time(); @@ -875,15 +877,20 @@ void Application::onMouseLeftUp(G3D::RenderDevice* renderDevice, int x, int y) void Application::onMouseRightPressed(int x,int y) { + tool->onButton2MouseDown(mouse); } void Application::onMouseRightUp(int x,int y) { + tool->onButton2MouseUp(mouse); } void Application::onMouseMoved(int x,int y) { - oldMouse = _dataModel->getMousePos(); - _dataModel->mousex = x; - _dataModel->mousey = y; + oldMouse = Vector2(mouse.x, mouse.y); + mouse.x = x; + mouse.y = y; + tool->onMouseMoved(mouse); + //_dataModel->mousex = x; + //_dataModel->mousey = y; } void Application::onMouseWheel(int x,int y,short delta) @@ -893,6 +900,7 @@ void Application::onMouseWheel(int x,int y,short delta) { AudioPlayer::playSound(cameraSound); } + tool->onMouseScroll(mouse); } void Application::run() { @@ -916,17 +924,13 @@ void Application::run() { UpdateWindow(_hWndMain); // Load objects here= - cursor = Texture::fromFile(GetFileInPath("/content/images/ArrowCursor.png")); - cursorOvr = Texture::fromFile(GetFileInPath("/content/images/DragCursor.png")); + Globals::surface = Texture::fromFile(GetFileInPath("/content/images/surfacebr.png")); Globals::surfaceId = Globals::surface->getOpenGLID(); cameraSound = GetFileInPath("/content/sounds/SWITCH3.wav"); clickSound = GetFileInPath("/content/sounds/switch.wav"); dingSound = GetFileInPath("/content/sounds/electronicpingshort.wav"); sky = Sky::create(NULL, ExePath() + "/content/sky/"); - cursorid = cursor->openGLID(); - currentcursorid = cursorid; - cursorOvrid = cursorOvr->openGLID(); RealTime now=0, lastTime=0; double simTimeRate = 1.0f; float fps=30.0f; diff --git a/Application.h b/Application.h index 2584550..3e08059 100644 --- a/Application.h +++ b/Application.h @@ -5,6 +5,8 @@ #include "ImageButtonInstance.h" #include "CameraController.h" #include "IEBrowser.h" +#include "Mouse.h" +#include "Tool.h" //#include "GuiRoot.h" class TextButtonInstance; @@ -54,6 +56,8 @@ class Application { // : public GApp { RenderDevice* getRenderDevice(); void selectInstance(Instance* selectedInstance,PropertyWindow* propWindow); void setMode(int mode); + Mouse mouse; + Tool * tool; private: RenderDevice* renderDevice; //void initGUI(); diff --git a/BaseButtonInstance.cpp b/BaseButtonInstance.cpp index 8c92859..2df06ef 100644 --- a/BaseButtonInstance.cpp +++ b/BaseButtonInstance.cpp @@ -1,5 +1,6 @@ #include "BaseButtonInstance.h" #include "Globals.h" +#include "Application.h" ButtonListener* listener = NULL; @@ -13,8 +14,8 @@ BaseButtonInstance::BaseButtonInstance(void) void BaseButtonInstance::render(RenderDevice* rd) { DataModelInstance* dataModel = g_dataModel; - Vector2 pos = Vector2(dataModel->mousex,dataModel->mousey); - drawObj(rd, pos, dataModel->mouseButton1Down); + Vector2 pos = Vector2(g_usableApp->mouse.x,g_usableApp->mouse.y); + drawObj(rd, pos, g_usableApp->mouse.isMouseDown()); Instance::render(rd); } diff --git a/DataModelInstance.cpp b/DataModelInstance.cpp index 2c9fca2..5364ff6 100644 --- a/DataModelInstance.cpp +++ b/DataModelInstance.cpp @@ -20,9 +20,9 @@ DataModelInstance::DataModelInstance(void) //children.push_back(workspace); //children.push_back(level); className = "dataModel"; - mousex = 0; - mousey = 0; - mouseButton1Down = false; + //mousex = 0; + //mousey = 0; + //mouseButton1Down = false; showMessage = false; canDelete = false; _modY=0; @@ -586,7 +586,7 @@ WorkspaceInstance* DataModelInstance::getWorkspace() { return workspace; } -Vector2 DataModelInstance::getMousePos() +/*Vector2 DataModelInstance::getMousePos() { return Vector2(mousex,mousey); } @@ -599,7 +599,7 @@ void DataModelInstance::setMousePos(Vector2 pos) { mousex=pos.x; mousey=pos.y; -} +}*/ GuiRoot* DataModelInstance::getGuiRoot() { return guiRoot; diff --git a/DataModelInstance.h b/DataModelInstance.h index 7afa538..c143a05 100644 --- a/DataModelInstance.h +++ b/DataModelInstance.h @@ -28,12 +28,12 @@ public: bool showMessage; G3D::GFontRef font; GuiRoot* getGuiRoot(); - float mousex; - float mousey; - Vector2 getMousePos(); - void setMousePos(int x,int y); - void setMousePos(Vector2 pos); - bool mouseButton1Down; + //float mousex; + //float mousey; + //Vector2 getMousePos(); + //void setMousePos(int x,int y); + //void setMousePos(Vector2 pos); + //bool mouseButton1Down; PartInstance* makePart(); void clearLevel(); void toggleRun(); diff --git a/G3DTest.vcproj b/G3DTest.vcproj index cd1ef4d..dbc0833 100644 --- a/G3DTest.vcproj +++ b/G3DTest.vcproj @@ -290,6 +290,10 @@ /> + + @@ -302,10 +306,6 @@ RelativePath=".\StringFunctions.cpp" > - - @@ -398,6 +398,14 @@ > + + + + + + @@ -495,10 +507,6 @@ RelativePath=".\ToggleImageButtonInstance.h" > - - @@ -583,6 +591,14 @@ > + + + + postRenderStack; @@ -31,7 +32,8 @@ extern Application* g_usableApp; extern GFontRef g_fntdominant; extern GFontRef g_fntlighttrek; +extern COLORREF g_acrCustClr[16]; //Will be dynamic later extern std::string cameraSound; extern std::string clickSound; extern std::string dingSound; -const std::string g_PlaceholderName = "HyperCube"; \ No newline at end of file +const std::string g_PlaceholderName = "Dygysphere"; \ No newline at end of file diff --git a/IEBrowser.cpp b/IEBrowser.cpp index b560aea..5bf843c 100644 --- a/IEBrowser.cpp +++ b/IEBrowser.cpp @@ -4,7 +4,7 @@ #include - +#include #include "IEBrowser.h" #include "Globals.h" #pragma once @@ -28,7 +28,9 @@ HRESULT IEBrowser::doExternal(std::wstring funcName, } else if (funcName==L"ToggleHopperBin") { - MessageBox(NULL, "BOOP", "Boopity boop",MB_OK); + pVarResult->vt = VT_INT; + pVarResult->intVal = 5; + //MessageBox(NULL, "BOOP", "Boopity boop",MB_OK); } else if (funcName==L"SetController") { @@ -51,10 +53,41 @@ HRESULT IEBrowser::doExternal(std::wstring funcName, AudioPlayer::playSound(dingSound); return S_OK; } - else + else if(funcName==L"SetColor") { - return E_NOTIMPL; + + return S_OK; } + else if(funcName==L"ChooseColor") + { + CHOOSECOLOR color; + + DWORD rgbCurrent; //Will be dynamic later + ZeroMemory(&color, sizeof(CHOOSECOLOR)); + color.lStructSize = sizeof(color); + color.hwndOwner = hwnd; + color.lpCustColors = (LPDWORD) g_acrCustClr; + color.rgbResult = rgbCurrent; + color.Flags = CC_FULLOPEN | CC_RGBINIT; + if(ChooseColorA((LPCHOOSECOLOR)&color)) + { + //DWORD dwR = GetRValue(color.rgbResult); + //DWORD dwG = GetGValue(color.rgbResult); + //DWORD dwB = GetBValue(color.rgbResult); + //wchar_t * str = L"Test"; + //swprintf_s(str, 16, L"#%02X%02X%02X", dwR, dwG, dwB); + pVarResult->vt = VT_UI4; + pVarResult->ulVal = color.rgbResult; + } + else + { + DWORD error = CommDlgExtendedError(); + std::cout << error; + pVarResult->vt = VT_NULL; + } + return S_OK; + } + return E_NOTIMPL; } IEBrowser::IEBrowser(HWND attachHWnd) { diff --git a/Mouse.cpp b/Mouse.cpp new file mode 100644 index 0000000..4b9cd8a --- /dev/null +++ b/Mouse.cpp @@ -0,0 +1,31 @@ +#include "Mouse.h" +Mouse::Mouse(){ + x = y = 0; +} +Mouse::~Mouse(){} + + +Instance * Mouse::getTarget() +{ + return NULL; +} +Vector3 Mouse::getPosition() +{ + return Vector3(); + //Not implemented +} +bool Mouse::isMouseOnScreen() +{ + //hm + return true; +} + +bool Mouse::isMouseDown() +{ + return mouseDown; +} + +void Mouse::setMouseDown(bool bval) +{ + mouseDown = bval; +} \ No newline at end of file diff --git a/Mouse.h b/Mouse.h new file mode 100644 index 0000000..83a1c4c --- /dev/null +++ b/Mouse.h @@ -0,0 +1,18 @@ +#pragma once +#include "PartInstance.h" +#pragma once + +class Mouse +{ +public: + Mouse(void); + ~Mouse(void); + int x, y; + Instance * getTarget(); + Vector3 getPosition(); + bool isMouseOnScreen(); + bool isMouseDown(); + void setMouseDown(bool mouseDown); +private: + bool mouseDown; +}; diff --git a/Tool.cpp b/Tool.cpp index 7459701..169b92b 100644 --- a/Tool.cpp +++ b/Tool.cpp @@ -2,8 +2,34 @@ Tool::Tool(void) { + cursorRef = Texture::fromFile(GetFileInPath("/content/images/ArrowCursor.png")); + cursorId = cursorRef->openGLID(); } Tool::~Tool(void) { } + +void Tool::onButton1MouseDown(Mouse mouse){} +void Tool::onButton2MouseDown(Mouse mouse){} +void Tool::onButton3MouseDown(Mouse mouse){} +void Tool::onButton1MouseUp(Mouse mouse){} +void Tool::onButton2MouseUp(Mouse mouse){} +void Tool::onButton3MouseUp(Mouse mouse){} +void Tool::onMouseMoved(Mouse mouse){} +void Tool::onSelect(Mouse mouse){} +void Tool::onDeselect(Mouse mouse){} +void Tool::onMouseScroll(Mouse mouse){} +void Tool::onKeyDown(char key){} +void Tool::onKeyUp(char key){} +void Tool::setCursor(std::string) +{ +} +int Tool::getCursorId() +{ + return cursorId; +} +void Tool::setCursorId(int id) +{ + cursorId = id; +} \ No newline at end of file diff --git a/Tool.h b/Tool.h index 2336dbe..bd1868b 100644 --- a/Tool.h +++ b/Tool.h @@ -1,17 +1,34 @@ #pragma once - +#include +#pragma once +#include "Mouse.h" +#pragma once +#include "Globals.h" +#pragma once +#include "StringFunctions.h" +#pragma once class Tool { public: Tool(void); ~Tool(void); - void OnButton1MouseDown(); - void OnButton2MouseDown(); - void OnButton3MouseDown(); - void OnButton1MouseUp(); - void OnButton2MouseUp(); - void OnButton3MouseUp(); - void OnMouseScroll(); - void OnKeyDown(); - void OnKeyUp(); + void onButton1MouseDown(Mouse); //yes + void onButton2MouseDown(Mouse); //yes + void onButton3MouseDown(Mouse); + void onButton1MouseUp(Mouse);//yes + void onButton2MouseUp(Mouse);//yes + void onButton3MouseUp(Mouse); + void onMouseMoved(Mouse);//yes + void onSelect(Mouse);//For later + void onDeselect(Mouse);//For later + void onMouseScroll(Mouse);//Kinda + void onKeyDown(char);//yes + void onKeyUp(char);//yes + void setCursor(std::string); + void setCursorId(int);//yes + int getCursorId();//yes +private: + int cursorId; + G3D::TextureRef cursorRef; + std::string cursorString; }; diff --git a/content/page/color.html b/content/page/color.html index 8858292..acdb23f 100644 Binary files a/content/page/color.html and b/content/page/color.html differ diff --git a/content/page/hopper.html b/content/page/hopper.html index 1abc863..f20c4a0 100644 --- a/content/page/hopper.html +++ b/content/page/hopper.html @@ -22,7 +22,7 @@ } - +