diff --git a/PhysicalInstance.cpp b/PhysicalInstance.cpp index a550e80..d776366 100644 --- a/PhysicalInstance.cpp +++ b/PhysicalInstance.cpp @@ -212,7 +212,8 @@ void PhysicalInstance::render(RenderDevice* rd) PhysicalInstance::~PhysicalInstance(void) { } - +char pto[512]; +#include void PhysicalInstance::PropUpdate(LPPROPGRIDITEM &item) { @@ -220,8 +221,36 @@ void PhysicalInstance::PropUpdate(LPPROPGRIDITEM &item) { name = (LPTSTR)item->lpCurValue; } + 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); + } + } } -char pto[512]; + std::vector PhysicalInstance::getProperties() { std::vector properties; @@ -239,7 +268,6 @@ std::vector PhysicalInstance::getProperties() sprintf(pto, "%g, %g, %g", cFrame.translation.x, cFrame.translation.y, cFrame.translation.z, "what"); LPCSTR str = LPCSTR(pto); - std::cout << str << std::endl; properties.push_back(createPGI( "Item", "Offset", diff --git a/PropertyWindow.cpp b/PropertyWindow.cpp index 966f50b..0bd5591 100644 --- a/PropertyWindow.cpp +++ b/PropertyWindow.cpp @@ -20,6 +20,11 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } switch(msg) { + case WM_CLOSE: + { + ShowWindow(hwnd, SW_HIDE); + } + break; case WM_SIZE: { propWind->onResize(); @@ -56,7 +61,7 @@ bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstanc _hwndProp = CreateWindowEx( WS_EX_TOOLWINDOW, "propHWND", - "Prop Test", + "PropertyGrid", WS_VISIBLE | WS_POPUPWINDOW | WS_THICKFRAME | WS_CAPTION, CW_USEDEFAULT, CW_USEDEFAULT, diff --git a/PropertyWindow.h b/PropertyWindow.h index 48005db..cc99db2 100644 --- a/PropertyWindow.h +++ b/PropertyWindow.h @@ -6,8 +6,9 @@ public: bool onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance); void SetProperties(Instance *); void onResize(); + + HWND _hwndProp; private: HWND _propGrid; - HWND _hwndProp; void _redraw(); }; \ No newline at end of file diff --git a/main.cpp b/main.cpp index f143590..694ab5e 100644 --- a/main.cpp +++ b/main.cpp @@ -1258,8 +1258,6 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y) } if(!onGUI) { - while(selectedInstances.size() > 0) - selectedInstances.erase(selectedInstances.begin()); testRay = cameraController.getCamera()->worldRay(dataModel->mousex, dataModel->mousey, renderDevice->getViewport()); float nearest=std::numeric_limits::infinity(); Vector3 camPos = cameraController.getCamera()->getCoordinateFrame().translation; @@ -1274,9 +1272,23 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y) if (nearest>time) { nearest=time; - while(selectedInstances.size() > 0) + bool found = false; + for(size_t i = 0; i < selectedInstances.size(); i++) + { + if(selectedInstances.at(i) == test) + { + found = true; + ShowWindow(_propWindow->_hwndProp, SW_SHOW); + SetActiveWindow(_propWindow->_hwndProp); + SetForegroundWindow(_propWindow->_hwndProp); + break; + } + } + if(!found) + {while(selectedInstances.size() > 0) selectedInstances.erase(selectedInstances.begin()); selectedInstances.push_back(test); + } _propWindow->SetProperties(test); //message = "Dragging = true."; //messageTime = System::time();