I hate the linker
This commit is contained in:
@@ -167,6 +167,7 @@ void Application::deleteInstance()
|
|||||||
g_usableApp->_propWindow->ClearProperties();
|
g_usableApp->_propWindow->ClearProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Application::onInit() {
|
void Application::onInit() {
|
||||||
|
|
||||||
// Called before Application::run() beings
|
// Called before Application::run() beings
|
||||||
@@ -284,13 +285,21 @@ void Application::onCleanup() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
double grav = 0.32666666666666666666666666666667;
|
||||||
|
void Application::onLogic() {
|
||||||
|
//PhysicsStart
|
||||||
|
|
||||||
void Application::onLogic() {
|
for(size_t i = 0; i < this->_dataModel->getWorkspace()->physicalObjects.size(); i++)
|
||||||
// Add non-simulation game logic and AI code here
|
{
|
||||||
|
if(PartInstance* collider = dynamic_cast<PartInstance*>(this->_dataModel->getWorkspace()->physicalObjects.at(i)))
|
||||||
|
{
|
||||||
|
if(!collider->anchored)
|
||||||
|
{
|
||||||
|
collider->setPosition(collider->getPosition()+collider->getVelocity());
|
||||||
|
collider->setVelocity(Vector3(collider->getVelocity().x,collider->getVelocity().y-grav,collider->getVelocity().z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -310,7 +319,7 @@ std::vector<Instance*> Application::getSelection()
|
|||||||
}
|
}
|
||||||
void Application::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
void Application::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
||||||
|
|
||||||
|
onLogic();
|
||||||
|
|
||||||
_dataModel->getGuiRoot()->update();
|
_dataModel->getGuiRoot()->update();
|
||||||
|
|
||||||
|
|||||||
@@ -30,9 +30,19 @@ DataModelInstance::DataModelInstance(void)
|
|||||||
level->setParent(this);
|
level->setParent(this);
|
||||||
_loadedFileName="..//skooter.rbxm";
|
_loadedFileName="..//skooter.rbxm";
|
||||||
listicon = 5;
|
listicon = 5;
|
||||||
|
running = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataModelInstance::toggleRun()
|
||||||
|
{
|
||||||
|
running = !running;
|
||||||
|
}
|
||||||
|
bool DataModelInstance::isRunning()
|
||||||
|
{
|
||||||
|
return running;
|
||||||
|
}
|
||||||
|
|
||||||
DataModelInstance::~DataModelInstance(void)
|
DataModelInstance::~DataModelInstance(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ public:
|
|||||||
bool mouseButton1Down;
|
bool mouseButton1Down;
|
||||||
PartInstance* makePart();
|
PartInstance* makePart();
|
||||||
void clearLevel();
|
void clearLevel();
|
||||||
|
void toggleRun();
|
||||||
|
bool isRunning();
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
void modXMLLevel(float modY);
|
void modXMLLevel(float modY);
|
||||||
#endif
|
#endif
|
||||||
@@ -51,4 +53,5 @@ private:
|
|||||||
WorkspaceInstance* workspace;
|
WorkspaceInstance* workspace;
|
||||||
LevelInstance * level;
|
LevelInstance * level;
|
||||||
GuiRoot* guiRoot;
|
GuiRoot* guiRoot;
|
||||||
|
bool running;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -250,10 +250,6 @@
|
|||||||
RelativePath=".\BrowserCallHandler.cpp"
|
RelativePath=".\BrowserCallHandler.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\ButtonListener.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\CameraController.cpp"
|
RelativePath=".\CameraController.cpp"
|
||||||
>
|
>
|
||||||
@@ -266,14 +262,6 @@
|
|||||||
RelativePath=".\Globals.cpp"
|
RelativePath=".\Globals.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\GroupInstance.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\GuiRoot.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\IEBrowser.cpp"
|
RelativePath=".\IEBrowser.cpp"
|
||||||
>
|
>
|
||||||
@@ -314,6 +302,10 @@
|
|||||||
RelativePath=".\StringFunctions.cpp"
|
RelativePath=".\StringFunctions.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\ToggleImageButtonInstance.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\WindowFunctions.cpp"
|
RelativePath=".\WindowFunctions.cpp"
|
||||||
>
|
>
|
||||||
@@ -329,6 +321,14 @@
|
|||||||
RelativePath=".\DataModelInstance.cpp"
|
RelativePath=".\DataModelInstance.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\GroupInstance.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\GuiRoot.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\ImageButtonInstance.cpp"
|
RelativePath=".\ImageButtonInstance.cpp"
|
||||||
>
|
>
|
||||||
@@ -361,6 +361,10 @@
|
|||||||
<Filter
|
<Filter
|
||||||
Name="Listeners"
|
Name="Listeners"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\ButtonListener.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\CameraButtonListener.cpp"
|
RelativePath=".\CameraButtonListener.cpp"
|
||||||
>
|
>
|
||||||
@@ -373,6 +377,10 @@
|
|||||||
RelativePath=".\GUDButtonListener.cpp"
|
RelativePath=".\GUDButtonListener.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\MenuButtonListener.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\ModeSelectionListener.cpp"
|
RelativePath=".\ModeSelectionListener.cpp"
|
||||||
>
|
>
|
||||||
@@ -427,10 +435,6 @@
|
|||||||
RelativePath=".\Globals.h"
|
RelativePath=".\Globals.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\GuiRoot.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\IEBrowser.h"
|
RelativePath=".\IEBrowser.h"
|
||||||
>
|
>
|
||||||
@@ -479,6 +483,10 @@
|
|||||||
RelativePath=".\StringFunctions.h"
|
RelativePath=".\StringFunctions.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\ToggleImageButtonInstance.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\win32Defines.h"
|
RelativePath=".\win32Defines.h"
|
||||||
>
|
>
|
||||||
@@ -502,6 +510,10 @@
|
|||||||
RelativePath=".\GroupInstance.h"
|
RelativePath=".\GroupInstance.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\GuiRoot.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\ImageButtonInstance.h"
|
RelativePath=".\ImageButtonInstance.h"
|
||||||
>
|
>
|
||||||
@@ -546,6 +558,10 @@
|
|||||||
RelativePath=".\GUDButtonListener.h"
|
RelativePath=".\GUDButtonListener.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\MenuButtonListener.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\ModeSelectionListener.h"
|
RelativePath=".\ModeSelectionListener.h"
|
||||||
>
|
>
|
||||||
|
|||||||
12
GuiRoot.cpp
12
GuiRoot.cpp
@@ -4,12 +4,14 @@
|
|||||||
#include "BaseButtonInstance.h"
|
#include "BaseButtonInstance.h"
|
||||||
#include "TextButtonInstance.h"
|
#include "TextButtonInstance.h"
|
||||||
#include "ImageButtonInstance.h"
|
#include "ImageButtonInstance.h"
|
||||||
|
#include "ToggleImageButtonInstance.h"
|
||||||
#include "GuiRoot.h"
|
#include "GuiRoot.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "StringFunctions.h"
|
#include "StringFunctions.h"
|
||||||
|
|
||||||
#include "GUDButtonListener.h"
|
#include "GUDButtonListener.h"
|
||||||
#include "ModeSelectionListener.h"
|
#include "ModeSelectionListener.h"
|
||||||
|
#include "MenuButtonListener.h"
|
||||||
#include "RotateButtonListener.h"
|
#include "RotateButtonListener.h"
|
||||||
#include "CameraButtonListener.h"
|
#include "CameraButtonListener.h"
|
||||||
#include "DeleteListener.h"
|
#include "DeleteListener.h"
|
||||||
@@ -210,10 +212,16 @@ GuiRoot::GuiRoot() : _message(""), _messageTime(0)
|
|||||||
button->name = "Duplicate";
|
button->name = "Duplicate";
|
||||||
button->setButtonListener(new GUDButtonListener());
|
button->setButtonListener(new GUDButtonListener());
|
||||||
|
|
||||||
ImageButtonInstance* instance = makeImageButton(
|
ImageButtonInstance* instance = new ToggleImageButtonInstance(
|
||||||
Texture::fromFile(GetFileInPath("/content/images/Run.png")),
|
Texture::fromFile(GetFileInPath("/content/images/Run.png")),
|
||||||
Texture::fromFile(GetFileInPath("/content/images/Run_ovr.png")),
|
Texture::fromFile(GetFileInPath("/content/images/Run_ovr.png")),
|
||||||
Texture::fromFile(GetFileInPath("/content/images/Run_dn.png")));
|
Texture::fromFile(GetFileInPath("/content/images/Run_dn.png")),
|
||||||
|
NULL,
|
||||||
|
Texture::fromFile(GetFileInPath("/content/images/Stop.png")),
|
||||||
|
Texture::fromFile(GetFileInPath("/content/images/Stop_ovr.png")),
|
||||||
|
Texture::fromFile(GetFileInPath("/content/images/Stop_dn.png"))
|
||||||
|
);
|
||||||
|
instance->setButtonListener(new MenuButtonListener());
|
||||||
instance->name = "go";
|
instance->name = "go";
|
||||||
instance->size = Vector2(65,65);
|
instance->size = Vector2(65,65);
|
||||||
instance->position = Vector2(6.5, 25);
|
instance->position = Vector2(6.5, 25);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public:
|
|||||||
Instance* findFirstChild(std::string);
|
Instance* findFirstChild(std::string);
|
||||||
std::vector<Instance* > getChildren();
|
std::vector<Instance* > getChildren();
|
||||||
std::vector<Instance* > getAllChildren();
|
std::vector<Instance* > getAllChildren();
|
||||||
void setParent(Instance*);
|
virtual void setParent(Instance*);
|
||||||
void setName(std::string newName);
|
void setName(std::string newName);
|
||||||
void addChild(Instance*);
|
void addChild(Instance*);
|
||||||
void removeChild(Instance*);
|
void removeChild(Instance*);
|
||||||
|
|||||||
11
MenuButtonListener.cpp
Normal file
11
MenuButtonListener.cpp
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include "MenuButtonListener.h"
|
||||||
|
#include "toggleimagebuttoninstance.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
void onButton1MouseClick(BaseButtonInstance* button)
|
||||||
|
{
|
||||||
|
if(button->name == "go")
|
||||||
|
{
|
||||||
|
g_dataModel->toggleRun();
|
||||||
|
((ToggleImageButtonInstance*)button)->checked = g_dataModel->isRunning();
|
||||||
|
}
|
||||||
|
}
|
||||||
8
MenuButtonListener.h
Normal file
8
MenuButtonListener.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "buttonlistener.h"
|
||||||
|
class MenuButtonListener :
|
||||||
|
public ButtonListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void onButton1MouseClick(BaseButtonInstance*);
|
||||||
|
};
|
||||||
@@ -11,7 +11,7 @@ PartInstance::PartInstance(void) : _bevelSize(0.07f), _parseVert(0), _debugTimer
|
|||||||
name = "Unnamed PVItem";
|
name = "Unnamed PVItem";
|
||||||
className = "Part";
|
className = "Part";
|
||||||
canCollide = true;
|
canCollide = true;
|
||||||
anchored = true;
|
anchored = false;
|
||||||
size = Vector3(2,1,4);
|
size = Vector3(2,1,4);
|
||||||
setCFrame(CoordinateFrame(Vector3(0,0,0)));
|
setCFrame(CoordinateFrame(Vector3(0,0,0)));
|
||||||
color = Color3::gray();
|
color = Color3::gray();
|
||||||
@@ -26,6 +26,25 @@ PartInstance::PartInstance(void) : _bevelSize(0.07f), _parseVert(0), _debugTimer
|
|||||||
shape = Enum::Shape::Block;
|
shape = Enum::Shape::Block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Vector3 PartInstance::getVelocity()
|
||||||
|
{
|
||||||
|
return velocity;
|
||||||
|
}
|
||||||
|
Vector3 PartInstance::getRotVelocity()
|
||||||
|
{
|
||||||
|
return rotVelocity;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PartInstance::setVelocity(Vector3 v)
|
||||||
|
{
|
||||||
|
velocity = v;
|
||||||
|
}
|
||||||
|
void PartInstance::setRotVelocity(Vector3 v)
|
||||||
|
{
|
||||||
|
rotVelocity = v;
|
||||||
|
}
|
||||||
|
|
||||||
void PartInstance::postRender(RenderDevice *rd)
|
void PartInstance::postRender(RenderDevice *rd)
|
||||||
{
|
{
|
||||||
if(!nameShown)
|
if(!nameShown)
|
||||||
@@ -57,6 +76,30 @@ void PartInstance::postRender(RenderDevice *rd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PartInstance::setParent(Instance* parent)
|
||||||
|
{
|
||||||
|
Instance * cparent = this->parent;
|
||||||
|
while(cparent != NULL)
|
||||||
|
{
|
||||||
|
if(WorkspaceInstance* workspace = dynamic_cast<WorkspaceInstance*>(parent))
|
||||||
|
{
|
||||||
|
workspace->physicalObjects.erase(std::remove(workspace->physicalObjects.begin(), workspace->physicalObjects.end(), this), workspace->physicalObjects.end());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cparent = cparent->getParent();
|
||||||
|
}
|
||||||
|
Instance::setParent(parent);
|
||||||
|
while(parent != NULL)
|
||||||
|
{
|
||||||
|
if(WorkspaceInstance* workspace = dynamic_cast<WorkspaceInstance*>(parent))
|
||||||
|
{
|
||||||
|
workspace->physicalObjects.push_back(this);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
parent = parent->getParent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PartInstance::PartInstance(const PartInstance &oinst) : _bevelSize(0.07f), _parseVert(0), _debugTimer(0)
|
PartInstance::PartInstance(const PartInstance &oinst) : _bevelSize(0.07f), _parseVert(0), _debugTimer(0)
|
||||||
{
|
{
|
||||||
PVInstance::PVInstance(oinst);
|
PVInstance::PVInstance(oinst);
|
||||||
@@ -1048,6 +1091,11 @@ void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
|
|||||||
color = Color3(GetRValue(item->lpCurValue)/255.0F,GetGValue(item->lpCurValue)/255.0F,GetBValue(item->lpCurValue)/255.0F);
|
color = Color3(GetRValue(item->lpCurValue)/255.0F,GetGValue(item->lpCurValue)/255.0F,GetBValue(item->lpCurValue)/255.0F);
|
||||||
changed=true;
|
changed=true;
|
||||||
}
|
}
|
||||||
|
if(strcmp(item->lpszPropName, "Anchored") == 0)
|
||||||
|
{
|
||||||
|
anchored=(bool)item->lpCurValue;
|
||||||
|
changed=true;
|
||||||
|
}
|
||||||
else if(strcmp(item->lpszPropName, "Offset") == 0)
|
else if(strcmp(item->lpszPropName, "Offset") == 0)
|
||||||
{
|
{
|
||||||
std::string str = (LPTSTR)item->lpCurValue;
|
std::string str = (LPTSTR)item->lpCurValue;
|
||||||
@@ -1127,8 +1175,13 @@ std::vector<PROPGRIDITEM> PartInstance::getProperties()
|
|||||||
RGB((color.r*255),(color.g*255),(color.b*255)),
|
RGB((color.r*255),(color.g*255),(color.b*255)),
|
||||||
PIT_COLOR
|
PIT_COLOR
|
||||||
));
|
));
|
||||||
|
properties.push_back(createPGI(
|
||||||
sprintf_s(pto, "%g, %g, %g", cFrame.translation.x, cFrame.translation.y, cFrame.translation.z);
|
"Item",
|
||||||
|
"Anchored",
|
||||||
|
"Whether the block can move or not",
|
||||||
|
(LPARAM)anchored,
|
||||||
|
PIT_CHECK
|
||||||
|
));
|
||||||
properties.push_back(createPGI(
|
properties.push_back(createPGI(
|
||||||
"Item",
|
"Item",
|
||||||
"Offset",
|
"Offset",
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ public:
|
|||||||
virtual void PartInstance::postRender(RenderDevice* rd);
|
virtual void PartInstance::postRender(RenderDevice* rd);
|
||||||
~PartInstance(void);
|
~PartInstance(void);
|
||||||
virtual void render(RenderDevice*);
|
virtual void render(RenderDevice*);
|
||||||
Vector3 velocity;
|
|
||||||
Enum::SurfaceType::Value top;
|
Enum::SurfaceType::Value top;
|
||||||
Enum::SurfaceType::Value front;
|
Enum::SurfaceType::Value front;
|
||||||
Enum::SurfaceType::Value right;
|
Enum::SurfaceType::Value right;
|
||||||
@@ -27,7 +26,12 @@ public:
|
|||||||
CoordinateFrame cFrame;
|
CoordinateFrame cFrame;
|
||||||
Color3 color;
|
Color3 color;
|
||||||
Vector3 getPosition();
|
Vector3 getPosition();
|
||||||
|
Vector3 getVelocity();
|
||||||
|
Vector3 getRotVelocity();
|
||||||
|
void setParent(Instance* parent);
|
||||||
void setPosition(Vector3);
|
void setPosition(Vector3);
|
||||||
|
void setVelocity(Vector3);
|
||||||
|
void setRotVelocity(Vector3);
|
||||||
CoordinateFrame getCFrame();
|
CoordinateFrame getCFrame();
|
||||||
void setCFrame(CoordinateFrame);
|
void setCFrame(CoordinateFrame);
|
||||||
Box getBox();
|
Box getBox();
|
||||||
@@ -38,7 +42,6 @@ public:
|
|||||||
void setShape(Enum::Shape::Value shape);
|
void setShape(Enum::Shape::Value shape);
|
||||||
bool canCollide;
|
bool canCollide;
|
||||||
bool anchored;
|
bool anchored;
|
||||||
Vector3 rotVelocity;
|
|
||||||
bool collides(Box);
|
bool collides(Box);
|
||||||
virtual std::vector<PROPGRIDITEM> getProperties();
|
virtual std::vector<PROPGRIDITEM> getProperties();
|
||||||
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
||||||
@@ -61,6 +64,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
Vector3 position;
|
Vector3 position;
|
||||||
Vector3 size;
|
Vector3 size;
|
||||||
|
Vector3 velocity;
|
||||||
|
Vector3 rotVelocity;
|
||||||
float _bevelSize;
|
float _bevelSize;
|
||||||
int _parseVert;
|
int _parseVert;
|
||||||
int _debugTimer;
|
int _debugTimer;
|
||||||
|
|||||||
113
ToggleImageButtonInstance.cpp
Normal file
113
ToggleImageButtonInstance.cpp
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
#include "ToggleImageButtonInstance.h"
|
||||||
|
|
||||||
|
ToggleImageButtonInstance::ToggleImageButtonInstance(G3D::TextureRef newImage,
|
||||||
|
G3D::TextureRef overImage,
|
||||||
|
G3D::TextureRef downImage,
|
||||||
|
G3D::TextureRef disableImage,
|
||||||
|
G3D::TextureRef newImage2,
|
||||||
|
G3D::TextureRef overImage2,
|
||||||
|
G3D::TextureRef downImage2,
|
||||||
|
G3D::TextureRef disableImage2) : ImageButtonInstance(newImage, overImage, downImage, disableImage)
|
||||||
|
{
|
||||||
|
image2 = newImage2;
|
||||||
|
openGLID2 = image2->getOpenGLID();
|
||||||
|
image_ovr2 = overImage2;
|
||||||
|
if(!image_ovr2.isNull())
|
||||||
|
openGLID2_ovr = image_ovr2->getOpenGLID();
|
||||||
|
image_dn2 = downImage2;
|
||||||
|
if(!image_dn2.isNull())
|
||||||
|
openGLID2_dn = image_dn2->getOpenGLID();
|
||||||
|
image_ds2 = disableImage2;
|
||||||
|
if(!image_ds2.isNull())
|
||||||
|
openGLID2_ds = image_ds2->getOpenGLID();
|
||||||
|
checked = false;
|
||||||
|
className = "ToggleImageButton";
|
||||||
|
}
|
||||||
|
|
||||||
|
ToggleImageButtonInstance::~ToggleImageButtonInstance(void)
|
||||||
|
{
|
||||||
|
//Delete everything on destruction
|
||||||
|
image2.~ReferenceCountedPointer();
|
||||||
|
delete image2.getPointer();
|
||||||
|
image_ovr2.~ReferenceCountedPointer();
|
||||||
|
delete image_ovr2.getPointer();
|
||||||
|
image_ds2.~ReferenceCountedPointer();
|
||||||
|
delete image_ds2.getPointer();
|
||||||
|
image_dn2.~ReferenceCountedPointer();
|
||||||
|
delete image_dn2.getPointer();
|
||||||
|
image = NULL;
|
||||||
|
image_ovr = NULL;
|
||||||
|
image_ds = NULL;
|
||||||
|
image_dn = NULL;
|
||||||
|
delete listener;
|
||||||
|
listener = NULL;
|
||||||
|
selected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ToggleImageButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseDown)
|
||||||
|
{
|
||||||
|
bool drawDisabledBox = false;
|
||||||
|
Vector2 positionRelative = position;
|
||||||
|
if(floatRight && floatBottom)
|
||||||
|
{
|
||||||
|
positionRelative = Vector2(rd->getWidth() + position.x, rd->getHeight() + position.y);
|
||||||
|
}
|
||||||
|
else if(floatBottom)
|
||||||
|
{
|
||||||
|
positionRelative = Vector2(position.x, rd->getHeight() + position.y);
|
||||||
|
}
|
||||||
|
else if(floatRight)
|
||||||
|
{
|
||||||
|
positionRelative = Vector2(rd->getWidth() + position.x, position.y);
|
||||||
|
}
|
||||||
|
int renderimage = openGLID;
|
||||||
|
|
||||||
|
{
|
||||||
|
if(selected == true && !image_dn.isNull() && !disabled)
|
||||||
|
{
|
||||||
|
renderimage = openGLID_dn;
|
||||||
|
}
|
||||||
|
else if(disabled)
|
||||||
|
{
|
||||||
|
if(!image_ds.isNull())
|
||||||
|
renderimage = openGLID_ds;
|
||||||
|
else
|
||||||
|
drawDisabledBox = true;
|
||||||
|
}
|
||||||
|
else if(mouseInArea(positionRelative.x, positionRelative.y, positionRelative.x + size.x, positionRelative.y + size.y, mousePos.x, mousePos.y))
|
||||||
|
{
|
||||||
|
if(mouseDown && !image_dn.isNull())
|
||||||
|
{
|
||||||
|
renderimage = openGLID_dn;
|
||||||
|
}
|
||||||
|
else if(!image_ovr.isNull())
|
||||||
|
{
|
||||||
|
renderimage = openGLID_ovr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
glEnable( GL_TEXTURE_2D );
|
||||||
|
glEnable(GL_BLEND);// you enable blending function
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glBindTexture( GL_TEXTURE_2D, renderimage);
|
||||||
|
glBegin( GL_QUADS );
|
||||||
|
glTexCoord2d(0.0,0.0);
|
||||||
|
glVertex2f( positionRelative.x, positionRelative.y );
|
||||||
|
glTexCoord2d( 1.0,0.0 );
|
||||||
|
glVertex2f( positionRelative.x + size.x, positionRelative.y );
|
||||||
|
glTexCoord2d( 1.0,1.0 );
|
||||||
|
glVertex2f( positionRelative.x + size.x, positionRelative.y + size.y );
|
||||||
|
glTexCoord2d( 0.0,1.0 );
|
||||||
|
glVertex2f( positionRelative.x, positionRelative.y + size.y );
|
||||||
|
glEnd();
|
||||||
|
glDisable( GL_TEXTURE_2D );
|
||||||
|
|
||||||
|
if(drawDisabledBox)
|
||||||
|
{
|
||||||
|
Draw::box(Box(Vector3(positionRelative.x, positionRelative.y, 0), Vector3(positionRelative.x+size.x, positionRelative.y+size.y, 0)), rd, Color4(0.7F,0.7F,0.7F,0.3F), Color4::clear());
|
||||||
|
}
|
||||||
|
}
|
||||||
29
ToggleImageButtonInstance.h
Normal file
29
ToggleImageButtonInstance.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "imagebuttoninstance.h"
|
||||||
|
|
||||||
|
|
||||||
|
class ToggleImageButtonInstance : public ImageButtonInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//ImageButtonInstance(G3D::TextureRef);
|
||||||
|
//ImageButtonInstance(G3D::TextureRef,G3D::TextureRef);
|
||||||
|
//ImageButtonInstance(G3D::TextureRef,G3D::TextureRef,G3D::TextureRef);
|
||||||
|
ToggleImageButtonInstance(G3D::TextureRef newImage,G3D::TextureRef overImage = NULL,
|
||||||
|
G3D::TextureRef downImage = NULL,
|
||||||
|
G3D::TextureRef disableImage = NULL,
|
||||||
|
G3D::TextureRef newImage2 = NULL,
|
||||||
|
G3D::TextureRef overImage2 = NULL,
|
||||||
|
G3D::TextureRef downImage2 = NULL,
|
||||||
|
G3D::TextureRef disableImage2 = NULL);
|
||||||
|
~ToggleImageButtonInstance(void);
|
||||||
|
void drawObj(RenderDevice*, Vector2, bool);
|
||||||
|
bool checked;
|
||||||
|
G3D::TextureRef image2;
|
||||||
|
int openGLID2;
|
||||||
|
G3D::TextureRef image_ovr2;
|
||||||
|
int openGLID2_ovr;
|
||||||
|
G3D::TextureRef image_dn2;
|
||||||
|
int openGLID2_dn;
|
||||||
|
G3D::TextureRef image_ds2;
|
||||||
|
int openGLID2_ds;
|
||||||
|
};
|
||||||
@@ -7,4 +7,5 @@ class WorkspaceInstance :
|
|||||||
public:
|
public:
|
||||||
WorkspaceInstance(void);
|
WorkspaceInstance(void);
|
||||||
~WorkspaceInstance(void);
|
~WorkspaceInstance(void);
|
||||||
|
std::vector<PVInstance *> physicalObjects;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user