6 Commits
r289 ... r297

Author SHA1 Message Date
andreja6
421498e1fe Made parts deselectable 2018-10-23 15:15:08 -07:00
andreja6
8909ded488 Made window show on double click 2018-10-23 15:09:08 -07:00
andreja6
5114ceb4b7 Removed navigate for now, made char work 2018-10-23 14:11:28 -07:00
andreja6
1472b7d6a5 Made it use addresses 2018-10-23 13:43:56 -07:00
andreja6
52d2cbf5dd Removed useless class, properties work 2018-10-23 13:42:10 -07:00
andreja6
e4529a949a Kinda sorta works 2018-10-23 12:46:54 -07:00
10 changed files with 123 additions and 77 deletions

View File

@@ -176,7 +176,7 @@
SuppressStartupBanner="true" SuppressStartupBanner="true"
GenerateDebugInformation="true" GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/G3DTest.pdb" ProgramDatabaseFile=".\Debug/G3DTest.pdb"
SubSystem="2" SubSystem="1"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
@@ -290,10 +290,6 @@
/> />
</FileConfiguration> </FileConfiguration>
</File> </File>
<File
RelativePath=".\Property.cpp"
>
</File>
<File <File
RelativePath=".\propertyGrid.cpp" RelativePath=".\propertyGrid.cpp"
> >
@@ -407,10 +403,6 @@
RelativePath=".\PartType.h" RelativePath=".\PartType.h"
> >
</File> </File>
<File
RelativePath=".\Property.h"
>
</File>
<File <File
RelativePath=".\propertyGrid.h" RelativePath=".\propertyGrid.h"
> >

View File

@@ -41,26 +41,26 @@ PROPGRIDITEM Instance::createPGI(LPSTR catalog, LPSTR propName, LPSTR propDesc,
return pItem; return pItem;
} }
void Instance::PropUpdate(DWORD &addr, PROPGRIDITEM &pItem) void Instance::PropUpdate(LPPROPGRIDITEM &item)
{ {
if((DWORD)&name == addr) if(strcmp(item->lpszPropName, "Name") == 0)
{ {
name = pItem.lpCurValue; name = item->lpCurValue;
} }
} }
std::vector<Property> Instance::getProperties() std::vector<PROPGRIDITEM> Instance::getProperties()
{ {
std::vector<Property> properties; std::vector<PROPGRIDITEM> properties;
properties.push_back(Property(createPGI( properties.push_back(createPGI(
"Properties", "Properties",
"Name", "Name",
"The name of this instance", "The name of this instance",
(LPARAM)name.c_str(), (LPARAM)name.c_str(),
PIT_EDIT PIT_EDIT
), (DWORD)&name)); ));
return properties; return properties;
} }

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include <G3DAll.h> #include <G3DAll.h>
#include "Property.h" #include "propertyGrid.h"
class Instance class Instance
{ {
public: public:
@@ -20,8 +20,8 @@ public:
void removeChild(Instance*); void removeChild(Instance*);
Instance* getParent(); Instance* getParent();
virtual Instance* clone() const { return new Instance(*this); } virtual Instance* clone() const { return new Instance(*this); }
virtual std::vector<Property> getProperties(); virtual std::vector<PROPGRIDITEM> getProperties();
virtual void PropUpdate(DWORD &addr, PROPGRIDITEM &pItem); virtual void PropUpdate(LPPROPGRIDITEM &pItem);
protected: protected:
std::string className; std::string className;
Instance* parent; // Another pointer. Instance* parent; // Another pointer.

View File

@@ -212,37 +212,69 @@ void PhysicalInstance::render(RenderDevice* rd)
PhysicalInstance::~PhysicalInstance(void) PhysicalInstance::~PhysicalInstance(void)
{ {
} }
char pto[512];
#include <sstream>
void PhysicalInstance::PropUpdate(LPPROPGRIDITEM &item)
void PhysicalInstance::PropUpdate(DWORD &addr, PROPGRIDITEM &pItem)
{ {
if((DWORD)&name == addr) if(strcmp(item->lpszPropName, "Name") == 0)
{ {
name = pItem.lpCurValue; name = (LPTSTR)item->lpCurValue;
}
else if(strcmp(item->lpszPropName, "Offset") == 0)
{
std::string str = (LPTSTR)item->lpCurValue;
std::vector<float> 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);
}
} }
} }
std::vector<Property> PhysicalInstance::getProperties() std::vector<PROPGRIDITEM> PhysicalInstance::getProperties()
{ {
std::vector<Property> properties; std::vector<PROPGRIDITEM> properties;
properties.push_back(Property(createPGI( properties.push_back(createPGI(
"Properties", "Properties",
"Name", "Name",
"The name of this instance", "The name of this instance",
(LPARAM)name.c_str(), (LPARAM)name.c_str(),
PIT_EDIT PIT_EDIT
), (DWORD)&name)); ));
char pso[512];
properties.push_back(Property(createPGI(
sprintf(pto, "%g, %g, %g", cFrame.translation.x, cFrame.translation.y, cFrame.translation.z, "what");
LPCSTR str = LPCSTR(pto);
properties.push_back(createPGI(
"Item", "Item",
"Offset", "Offset",
"The position of the object in the workspace", "The position of the object in the workspace",
(LPARAM)"Coming soon", (LPARAM)str,
PIT_EDIT PIT_EDIT
), (DWORD)&name)); ));
return properties; return properties;
} }

View File

@@ -33,8 +33,8 @@ public:
bool anchored; bool anchored;
Vector3 rotVelocity; Vector3 rotVelocity;
bool collides(Box); bool collides(Box);
virtual std::vector<Property> getProperties(); virtual std::vector<PROPGRIDITEM> getProperties();
virtual void PropUpdate(DWORD &addr, PROPGRIDITEM &pItem); virtual void PropUpdate(LPPROPGRIDITEM &pItem);
private: private:
Vector3 position; Vector3 position;
Vector3 size; Vector3 size;

View File

@@ -1,15 +0,0 @@
#include "Property.h"
Property::Property(PROPGRIDITEM item, DWORD addr)
{
this->addr = addr;
this->item = item;
}
Property::~Property(void)
{
}

View File

@@ -1,11 +0,0 @@
#pragma once
#include <windows.h>
#include "propertyGrid.h"
class Property
{
public:
PROPGRIDITEM item;
DWORD addr;
Property(PROPGRIDITEM item, DWORD addr);
~Property(void);
};

View File

@@ -1,7 +1,6 @@
#define _WINSOCKAPI_ #define _WINSOCKAPI_
#include <windows.h> #include <windows.h>
#include "WindowFunctions.h" #include "WindowFunctions.h"
#include "Property.h"
#include "resource.h" #include "resource.h"
#include "PropertyWindow.h" #include "PropertyWindow.h"
@@ -10,7 +9,8 @@
Property &prop; Property &prop;
} PRGP;*/ } PRGP;*/
//std::vector<PRGP> propvec; std::vector<PROPGRIDITEM> prop;
Instance* selectedInstance;
LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
PropertyWindow *propWind = (PropertyWindow *)GetWindowLongPtr(hwnd, GWL_USERDATA); PropertyWindow *propWind = (PropertyWindow *)GetWindowLongPtr(hwnd, GWL_USERDATA);
@@ -20,13 +20,33 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
} }
switch(msg) switch(msg)
{ {
case WM_CLOSE:
{
ShowWindow(hwnd, SW_HIDE);
}
break;
case WM_SIZE: case WM_SIZE:
{ {
propWind->onResize(); propWind->onResize();
} }
case WM_NOTIFY:
MessageBox(NULL,"Test","Test",0);
break; 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; break;
default: default:
return DefWindowProc(hwnd, msg, wParam, lParam); return DefWindowProc(hwnd, msg, wParam, lParam);
@@ -41,7 +61,7 @@ bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstanc
_hwndProp = CreateWindowEx( _hwndProp = CreateWindowEx(
WS_EX_TOOLWINDOW, WS_EX_TOOLWINDOW,
"propHWND", "propHWND",
"Prop Test", "PropertyGrid",
WS_VISIBLE | WS_POPUPWINDOW | WS_THICKFRAME | WS_CAPTION, WS_VISIBLE | WS_POPUPWINDOW | WS_THICKFRAME | WS_CAPTION,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
@@ -55,7 +75,7 @@ bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstanc
_propGrid = New_PropertyGrid(_hwndProp,IDC_PROPERTYGRID); _propGrid = New_PropertyGrid(_hwndProp,IDC_PROPERTYGRID);
PROPGRIDITEM pItem; /*PROPGRIDITEM pItem;
PropGrid_ItemInit(pItem); PropGrid_ItemInit(pItem);
pItem.lpszCatalog="Test"; pItem.lpszCatalog="Test";
@@ -89,8 +109,8 @@ bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstanc
PropGrid_Enable(_propGrid,true); PropGrid_Enable(_propGrid,true);
ShowWindow(_propGrid,SW_SHOW); ShowWindow(_propGrid,SW_SHOW);
PropGrid_AddItem(_propGrid,&pItem); // PropGrid_AddItem(_propGrid,&pItem);
PropGrid_AddItem(_propGrid,&pItem2); // PropGrid_AddItem(_propGrid,&pItem2);
PropGrid_SetItemHeight(_propGrid,20); PropGrid_SetItemHeight(_propGrid,20);
PropGrid_ShowToolTips(_propGrid,TRUE); PropGrid_ShowToolTips(_propGrid,TRUE);
PropGrid_ShowPropertyDescriptions(_propGrid,TRUE); PropGrid_ShowPropertyDescriptions(_propGrid,TRUE);
@@ -121,11 +141,11 @@ void PropertyWindow::_redraw()
void PropertyWindow::SetProperties(Instance * instance) void PropertyWindow::SetProperties(Instance * instance)
{ {
PropGrid_ResetContent(_propGrid); PropGrid_ResetContent(_propGrid);
std::vector<Property> prop = instance->getProperties(); prop = instance->getProperties();
selectedInstance = instance;
for(size_t i = 0; i < prop.size(); i++) for(size_t i = 0; i < prop.size(); i++)
{ {
::PROPGRIDITEM item = prop.at(i).item; ::PROPGRIDITEM item = prop.at(i);
PropGrid_AddItem(_propGrid, &item); PropGrid_AddItem(_propGrid, &item);
//PRGP propgp; //PRGP propgp;
//propgp.instance = instance; //propgp.instance = instance;
@@ -134,4 +154,9 @@ void PropertyWindow::SetProperties(Instance * instance)
PropGrid_ExpandAllCatalogs(_propGrid); PropGrid_ExpandAllCatalogs(_propGrid);
SetWindowLongPtr(_propGrid,GWL_USERDATA,(LONG)this); SetWindowLongPtr(_propGrid,GWL_USERDATA,(LONG)this);
_redraw(); _redraw();
}
void PropertyWindow::ClearProperties()
{
PropGrid_ResetContent(_propGrid);
} }

View File

@@ -5,9 +5,11 @@ public:
PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstance); PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstance);
bool onCreate(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 SetProperties(Instance *);
void ClearProperties();
void onResize(); void onResize();
HWND _hwndProp;
private: private:
HWND _propGrid; HWND _propGrid;
HWND _hwndProp;
void _redraw(); void _redraw();
}; };

View File

@@ -143,7 +143,7 @@ Demo::Demo(const GAppSettings& settings,HWND parentWindow) { //: GApp(settings,w
SetWindowLongPtr(_hwndRenderer,GWL_USERDATA,(LONG)this); SetWindowLongPtr(_hwndRenderer,GWL_USERDATA,(LONG)this);
_propWindow = new PropertyWindow(0, 0, 200, 640, hThisInstance); _propWindow = new PropertyWindow(0, 0, 200, 640, hThisInstance);
IEBrowser* webBrowser = new IEBrowser(_hwndToolbox); IEBrowser* webBrowser = new IEBrowser(_hwndToolbox);
webBrowser->navigateSyncURL(L"http://scottbeebiwan.tk/g3d/toolbox/"); //webBrowser->navigateSyncURL(L"http://scottbeebiwan.tk/g3d/toolbox/");
} }
void clearInstances() void clearInstances()
@@ -1258,32 +1258,53 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y)
} }
if(!onGUI) if(!onGUI)
{ {
while(selectedInstances.size() > 0)
selectedInstances.erase(selectedInstances.begin());
testRay = cameraController.getCamera()->worldRay(dataModel->mousex, dataModel->mousey, renderDevice->getViewport()); testRay = cameraController.getCamera()->worldRay(dataModel->mousex, dataModel->mousey, renderDevice->getViewport());
float nearest=std::numeric_limits<float>::infinity(); float nearest=std::numeric_limits<float>::infinity();
Vector3 camPos = cameraController.getCamera()->getCoordinateFrame().translation; Vector3 camPos = cameraController.getCamera()->getCoordinateFrame().translation;
std::vector<Instance*> instances = dataModel->getWorkspace()->getAllChildren(); std::vector<Instance*> 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(PhysicalInstance* test = dynamic_cast<PhysicalInstance*>(instances.at(i))) if(PhysicalInstance* test = dynamic_cast<PhysicalInstance*>(instances.at(i)))
{ {
float time = testRay.intersectionTime(test->getBox()); float time = testRay.intersectionTime(test->getBox());
if (time != inf()) if (time != inf())
{ {
objFound = true;
if (nearest>time) if (nearest>time)
{ {
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.erase(selectedInstances.begin());
selectedInstances.push_back(test); selectedInstances.push_back(test);
}
_propWindow->SetProperties(test); _propWindow->SetProperties(test);
//message = "Dragging = true."; //message = "Dragging = true.";
//messageTime = System::time(); //messageTime = System::time();
//dragging = true; //dragging = true;
} }
} }
} }
}
if(!objFound)
{
while(selectedInstances.size() > 0)
selectedInstances.erase(selectedInstances.begin());
_propWindow->ClearProperties();
} }
} }
} }