Merge pull request #44 from Vulpovile/tools-and-ui
Merge Tools and UI into master
This commit is contained in:
141
Application.cpp
141
Application.cpp
@@ -30,13 +30,11 @@
|
||||
#include "DeleteListener.h"
|
||||
#include "CameraButtonListener.h"
|
||||
#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;
|
||||
//#define LEGACY_LOAD_G3DFUN_LEVEL
|
||||
//Ray testRay;
|
||||
//static int cursorid = 0;
|
||||
//static int cursorOvrid = 0;
|
||||
//static int currentcursorid = 0;
|
||||
static bool mouseMovedBeginMotion = false;
|
||||
static POINT oldGlobalMouse;
|
||||
Vector2 oldMouse = Vector2(0,0);
|
||||
@@ -163,8 +161,7 @@ void Application::deleteInstance()
|
||||
{
|
||||
AudioPlayer::playSound(GetFileInPath("/content/sounds/pageturn.wav"));
|
||||
Instance* selectedInstance = g_selectedInstances.at(0);
|
||||
if(selectedInstance->getParent() != NULL)
|
||||
selectedInstance->getParent()->removeChild(selectedInstance);
|
||||
selectedInstance->setParent(NULL);
|
||||
delete selectedInstance;
|
||||
selectedInstance = NULL;
|
||||
g_selectedInstances.erase(g_selectedInstances.begin());
|
||||
@@ -181,7 +178,7 @@ void Application::deleteInstance()
|
||||
|
||||
|
||||
void Application::onInit() {
|
||||
|
||||
tool = new Tool();
|
||||
// Called before Application::run() beings
|
||||
cameraController.setFrame(Vector3(0,2,10));
|
||||
_dataModel = new DataModelInstance();
|
||||
@@ -417,7 +414,11 @@ bool IsHolding(int button)
|
||||
*/
|
||||
|
||||
void Application::onUserInput(UserInput* ui) {
|
||||
|
||||
if(mouseMoveState)
|
||||
{
|
||||
mouseMoveState = false;
|
||||
tool->onMouseMoved(mouse);
|
||||
}
|
||||
/*
|
||||
if(GetHoldKeyState(VK_LCONTROL))
|
||||
{
|
||||
@@ -440,14 +441,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) {
|
||||
/* 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<Instance*> instances = _dataModel->getWorkspace()->getAllChildren();
|
||||
for(size_t i = 0; i < instances.size(); i++)
|
||||
{
|
||||
@@ -468,7 +469,7 @@ void Application::onUserInput(UserInput* ui) {
|
||||
}
|
||||
}
|
||||
Sleep(10);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
// Camera KB Handling {
|
||||
if (GetKPBool(VK_OEM_COMMA)) //Left
|
||||
@@ -485,6 +486,18 @@ void Application::onUserInput(UserInput* ui) {
|
||||
// Add other key handling here
|
||||
}
|
||||
|
||||
void Application::changeTool(Tool * newTool)
|
||||
{
|
||||
tool->onDeselect(mouse);
|
||||
delete tool;
|
||||
if(newTool != NULL)
|
||||
tool = newTool;
|
||||
else
|
||||
tool = new Tool(); //Nulltool
|
||||
tool->onSelect(mouse);
|
||||
|
||||
}
|
||||
|
||||
void Application::makeFlag(Vector3 &vec, RenderDevice* &rd)
|
||||
{
|
||||
|
||||
@@ -662,6 +675,11 @@ void Application::onGraphics(RenderDevice* rd) {
|
||||
|
||||
renderDevice->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor, true, true));
|
||||
renderDevice->setAmbientLightColor(lighting.ambient);
|
||||
|
||||
//renderDevice->setBlendFunc(RenderDevice::BLEND_ONE, RenderDevice::BLEND_ONE);
|
||||
|
||||
|
||||
|
||||
renderDevice->setShininess(70);
|
||||
renderDevice->setSpecularCoefficient(Color3(0.1F, 0.1F, 0.1F));
|
||||
|
||||
@@ -674,6 +692,7 @@ void Application::onGraphics(RenderDevice* rd) {
|
||||
//glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, lightSpecular);
|
||||
//glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 70);
|
||||
|
||||
|
||||
rd->beforePrimitive();
|
||||
CoordinateFrame forDraw = rd->getObjectToWorldMatrix();
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
@@ -689,6 +708,10 @@ void Application::onGraphics(RenderDevice* rd) {
|
||||
rd->setObjectToWorldMatrix(forDraw);
|
||||
rd->afterPrimitive();
|
||||
|
||||
|
||||
|
||||
|
||||
Draw::sphere(G3D::Sphere(mouse.getPosition(), 1), rd, Color3::cyan(), Color4::clear());
|
||||
if(g_selectedInstances.size() > 0)
|
||||
{
|
||||
for(size_t i = 0; i < g_selectedInstances.size(); i++)
|
||||
@@ -747,7 +770,7 @@ void Application::onGraphics(RenderDevice* rd) {
|
||||
}
|
||||
}
|
||||
*/
|
||||
glBindTexture( GL_TEXTURE_2D, currentcursorid);
|
||||
glBindTexture( GL_TEXTURE_2D, tool->getCursorId());
|
||||
|
||||
|
||||
glBegin( GL_QUADS );
|
||||
@@ -779,10 +802,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)
|
||||
@@ -791,69 +815,14 @@ 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)
|
||||
{
|
||||
Instance * selectedInstance = NULL;
|
||||
testRay = cameraController.getCamera()->worldRay(_dataModel->mousex, _dataModel->mousey, renderDevice->getViewport());
|
||||
float nearest=std::numeric_limits<float>::infinity();
|
||||
Vector3 camPos = cameraController.getCamera()->getCoordinateFrame().translation;
|
||||
std::vector<Instance*> instances = _dataModel->getWorkspace()->getAllChildren();
|
||||
bool objFound = false;
|
||||
for(size_t i = 0; i < instances.size(); i++)
|
||||
{
|
||||
if(PartInstance* test = dynamic_cast<PartInstance*>(instances.at(i)))
|
||||
{
|
||||
float time = testRay.intersectionTime(test->getBox());
|
||||
|
||||
if (time != inf())
|
||||
{
|
||||
objFound = true;
|
||||
if (nearest>time)
|
||||
{
|
||||
nearest=time;
|
||||
//bool found = false;
|
||||
selectedInstance = test;
|
||||
/*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)
|
||||
{
|
||||
selectedInstance = test;
|
||||
//if(!GetHoldKeyState(VK_RCONTROL) && !GetHoldKeyState(VK_LCONTROL))
|
||||
//g_selectedInstances.clear();
|
||||
//if(std::find(g_selectedInstances.begin(), g_selectedInstances.end(),test)==g_selectedInstances.end())
|
||||
//g_selectedInstances.push_back(test);
|
||||
}
|
||||
//selectInstance(test, _propWindow);
|
||||
//_message = "Dragging = true.";
|
||||
//_messageTime = System::time();
|
||||
//_dragging = true;*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!objFound)
|
||||
selectInstance(_dataModel,_propWindow);
|
||||
else
|
||||
{
|
||||
while(selectedInstance->getParent() != g_dataModel->getWorkspace())
|
||||
{
|
||||
selectedInstance = selectedInstance->getParent();
|
||||
}
|
||||
selectInstance(selectedInstance, _propWindow);
|
||||
}
|
||||
tool->onButton1MouseDown(mouse);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -880,6 +849,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();
|
||||
|
||||
@@ -887,15 +857,23 @@ 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.oldx = mouse.x;
|
||||
mouse.oldy = mouse.y;
|
||||
mouse.x = x;
|
||||
mouse.y = y;
|
||||
//tool->onMouseMoved(mouse);
|
||||
mouseMoveState = true;
|
||||
//_dataModel->mousex = x;
|
||||
//_dataModel->mousey = y;
|
||||
|
||||
}
|
||||
void Application::onMouseWheel(int x,int y,short delta)
|
||||
@@ -905,6 +883,7 @@ void Application::onMouseWheel(int x,int y,short delta)
|
||||
{
|
||||
AudioPlayer::playSound(cameraSound);
|
||||
}
|
||||
tool->onMouseScroll(mouse);
|
||||
}
|
||||
|
||||
void Application::run() {
|
||||
@@ -928,17 +907,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;
|
||||
|
||||
@@ -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,7 +56,12 @@ class Application { // : public GApp {
|
||||
RenderDevice* getRenderDevice();
|
||||
void selectInstance(Instance* selectedInstance,PropertyWindow* propWindow);
|
||||
void setMode(int mode);
|
||||
|
||||
Tool * tool;
|
||||
void changeTool(Tool *);
|
||||
Mouse mouse;
|
||||
private:
|
||||
bool mouseMoveState;
|
||||
RenderDevice* renderDevice;
|
||||
//void initGUI();
|
||||
HWND _hWndMain;
|
||||
|
||||
82
ArrowTool.cpp
Normal file
82
ArrowTool.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
#include "ArrowTool.h"
|
||||
#include "Application.h"
|
||||
|
||||
ArrowTool::ArrowTool(void)
|
||||
{
|
||||
lctrlDown = false;
|
||||
rctrlDown = false;
|
||||
dragging = false;
|
||||
mouseDown = false;
|
||||
}
|
||||
|
||||
ArrowTool::~ArrowTool(void)
|
||||
{
|
||||
}
|
||||
|
||||
void ArrowTool::onButton1MouseDown(Mouse mouse)
|
||||
{
|
||||
mouseDownStartx = mouse.x;
|
||||
mouseDownStarty = mouse.y;
|
||||
mouseDown = true;
|
||||
if(!lctrlDown && !rctrlDown)
|
||||
g_selectedInstances.clear();
|
||||
PartInstance * target = mouse.getTarget();
|
||||
if(target != NULL && std::find(g_selectedInstances.begin(), g_selectedInstances.end(), target) == g_selectedInstances.end())
|
||||
g_selectedInstances.push_back(target);
|
||||
if(g_selectedInstances.size() == 0)
|
||||
g_selectedInstances.push_back(g_dataModel);
|
||||
g_usableApp->_propWindow->UpdateSelected(g_selectedInstances[0]);
|
||||
}
|
||||
void ArrowTool::onButton1MouseUp(Mouse mouse)
|
||||
{
|
||||
if(dragging)
|
||||
this->setCursor(GetFileInPath("/content/images/ArrowCursor.png"));
|
||||
mouseDown = false;
|
||||
dragging = false;
|
||||
}
|
||||
|
||||
void ArrowTool::onMouseMoved(Mouse mouse)
|
||||
{
|
||||
if(mouseDown)
|
||||
{
|
||||
if(!dragging)
|
||||
{
|
||||
if(abs(mouse.x-mouseDownStartx) > 5 || abs(mouse.y-mouseDownStarty) > 5)
|
||||
{
|
||||
this->setCursor(GetFileInPath("/content/images/GrabRotateCursor.png"));
|
||||
dragging = true;
|
||||
}
|
||||
else return;
|
||||
}
|
||||
for(size_t i = 0; i < g_selectedInstances.size(); i++) //This will later decide primary and move all parts according to primary
|
||||
{
|
||||
if(PartInstance * part = dynamic_cast<PartInstance *>(g_selectedInstances[i]))
|
||||
{
|
||||
part->setPosition(mouse.getPosition(g_selectedInstances));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
PartInstance * target = mouse.getTarget();
|
||||
if(target == NULL)
|
||||
this->setCursor(GetFileInPath("/content/images/ArrowCursor.png"));
|
||||
else this->setCursor(GetFileInPath("/content/images/DragCursor.png"));
|
||||
}
|
||||
void ArrowTool::onSelect(Mouse mouse)
|
||||
{
|
||||
this->setCursor(GetFileInPath("/content/images/ArrowCursor.png"));
|
||||
}
|
||||
|
||||
void ArrowTool::onKeyDown(int key)
|
||||
{
|
||||
if(key == VK_CONTROL)
|
||||
{
|
||||
lctrlDown = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ArrowTool::onKeyUp(int key)
|
||||
{
|
||||
if(key == VK_CONTROL)
|
||||
lctrlDown = false;
|
||||
}
|
||||
23
ArrowTool.h
Normal file
23
ArrowTool.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include "tool.h"
|
||||
|
||||
class ArrowTool :
|
||||
public Tool
|
||||
{
|
||||
public:
|
||||
ArrowTool(void); //OnSelect?
|
||||
~ArrowTool(void); //OnDeselect?
|
||||
virtual void onButton1MouseDown(Mouse);
|
||||
virtual void onButton1MouseUp(Mouse);
|
||||
virtual void onMouseMoved(Mouse mouse);
|
||||
virtual void onSelect(Mouse mouse);
|
||||
virtual void onKeyDown(int key);
|
||||
virtual void onKeyUp(int key);
|
||||
private:
|
||||
bool lctrlDown;
|
||||
bool rctrlDown;
|
||||
int mouseDownStartx;
|
||||
int mouseDownStarty;
|
||||
bool dragging;
|
||||
bool mouseDown;
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "BaseButtonInstance.h"
|
||||
#include "Globals.h"
|
||||
#include "Application.h"
|
||||
|
||||
|
||||
ButtonListener* listener = NULL;
|
||||
@@ -13,14 +14,18 @@ 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);
|
||||
}
|
||||
|
||||
BaseButtonInstance::~BaseButtonInstance(void)
|
||||
{
|
||||
delete listener;
|
||||
if(listener != NULL && listener->doDelete)
|
||||
{
|
||||
delete listener;
|
||||
listener = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void BaseButtonInstance::setButtonListener(ButtonListener* buttonListener)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
ButtonListener::ButtonListener()
|
||||
{
|
||||
doDelete = true;
|
||||
}
|
||||
|
||||
ButtonListener::~ButtonListener(void)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
//#include "Application.h"
|
||||
//#include "BaseButtonInstance.h"
|
||||
#include "BaseButtonInstance.h"
|
||||
|
||||
class BaseButtonInstance;
|
||||
|
||||
@@ -10,6 +10,7 @@ class ButtonListener
|
||||
ButtonListener();
|
||||
~ButtonListener(void);
|
||||
virtual void onButton1MouseClick(BaseButtonInstance*);
|
||||
bool doDelete;
|
||||
//virtual void onMouseOver(); //TODO
|
||||
//virtual void onMouseOut(); //TODO
|
||||
//virtual void onButton1MouseDown(); //TODO
|
||||
|
||||
@@ -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;
|
||||
@@ -452,6 +452,7 @@ bool DataModelInstance::load(const char* filename, bool clearObjects)
|
||||
std::stringstream msg;
|
||||
msg << "Failed to load file:" << std::endl << filename << std::endl << strerror(errno);
|
||||
MessageBoxStr(msg.str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,7 +587,7 @@ WorkspaceInstance* DataModelInstance::getWorkspace()
|
||||
{
|
||||
return workspace;
|
||||
}
|
||||
Vector2 DataModelInstance::getMousePos()
|
||||
/*Vector2 DataModelInstance::getMousePos()
|
||||
{
|
||||
return Vector2(mousex,mousey);
|
||||
}
|
||||
@@ -599,7 +600,7 @@ void DataModelInstance::setMousePos(Vector2 pos)
|
||||
{
|
||||
mousex=pos.x;
|
||||
mousey=pos.y;
|
||||
}
|
||||
}*/
|
||||
GuiRoot* DataModelInstance::getGuiRoot()
|
||||
{
|
||||
return guiRoot;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -170,7 +170,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Advapi32.lib UxTheme.lib Comctl32.lib Comdlg32.lib Shell32.lib Urlmon.lib"
|
||||
AdditionalDependencies="Advapi32.lib UxTheme.lib Comctl32.lib Comdlg32.lib Shell32.lib Urlmon.lib ole32.lib oleaut32.lib uuid.lib"
|
||||
OutputFile="./G3DTest-Debug.exe"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="true"
|
||||
@@ -290,6 +290,10 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Mouse.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\propertyGrid.cpp"
|
||||
>
|
||||
@@ -303,7 +307,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ToggleImageButtonInstance.cpp"
|
||||
RelativePath=".\TextureHandler.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@@ -353,6 +357,10 @@
|
||||
RelativePath=".\TextButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ToggleImageButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\WorkspaceInstance.cpp"
|
||||
>
|
||||
@@ -389,6 +397,22 @@
|
||||
RelativePath=".\RotateButtonListener.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ToolbarListener.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Tools"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\ArrowTool.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Tool.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
@@ -447,6 +471,10 @@
|
||||
RelativePath=".\LevelInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Mouse.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\propertyGrid.h"
|
||||
>
|
||||
@@ -483,6 +511,10 @@
|
||||
RelativePath=".\StringFunctions.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TextureHandler.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ToggleImageButtonInstance.h"
|
||||
>
|
||||
@@ -566,6 +598,22 @@
|
||||
RelativePath=".\ModeSelectionListener.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ToolbarListener.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Tools"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\ArrowTool.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Tool.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
||||
@@ -28,4 +28,6 @@ std::string cameraSound="";
|
||||
std::string clickSound="";
|
||||
std::string dingSound="";
|
||||
|
||||
Application *g_usableApp = NULL;
|
||||
Application *g_usableApp = NULL;
|
||||
|
||||
COLORREF g_acrCustClr[16] = {RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255)};
|
||||
@@ -20,6 +20,7 @@ public:
|
||||
static G3D::TextureRef surface;
|
||||
static int surfaceId;
|
||||
static const std::string g_PlaceholderName;
|
||||
static COLORREF g_acrCustClr[16]; //Will be dynamic later
|
||||
};
|
||||
|
||||
extern std::vector<Instance*> 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";
|
||||
const std::string g_PlaceholderName = "Dygysphere";
|
||||
21
GuiRoot.cpp
21
GuiRoot.cpp
@@ -15,6 +15,7 @@
|
||||
#include "RotateButtonListener.h"
|
||||
#include "CameraButtonListener.h"
|
||||
#include "DeleteListener.h"
|
||||
#include "ToolbarListener.h"
|
||||
|
||||
#include "ImageButtonInstance.h"
|
||||
|
||||
@@ -31,9 +32,11 @@ TextButtonInstance* GuiRoot::makeTextButton()
|
||||
TextButtonInstance* part = new TextButtonInstance();
|
||||
return part;
|
||||
}
|
||||
|
||||
ToolbarListener * toolbar;
|
||||
GuiRoot::GuiRoot() : _message(""), _messageTime(0)
|
||||
{
|
||||
toolbar = new ToolbarListener();
|
||||
toolbar->doDelete = false;
|
||||
g_fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt"));
|
||||
g_fntlighttrek = GFont::fromFile(GetFileInPath("/content/font/lighttrek.fnt"));
|
||||
|
||||
@@ -51,6 +54,8 @@ GuiRoot::GuiRoot() : _message(""), _messageTime(0)
|
||||
button->setAllColorsSame();
|
||||
button->boxOutlineColorOvr = Color3(0,255,255);
|
||||
button->boxColorDn = Color4(button->boxColor.r,button->boxColor.g,button->boxColor.b, 0.2F);
|
||||
button->setButtonListener(toolbar);
|
||||
toolbar->addButtonRef(button);
|
||||
|
||||
|
||||
button = makeTextButton();
|
||||
@@ -66,7 +71,8 @@ GuiRoot::GuiRoot() : _message(""), _messageTime(0)
|
||||
button->setAllColorsSame();
|
||||
button->boxOutlineColorOvr = Color3(0,255,255);
|
||||
button->boxColorDn = Color4(button->boxColor.r,button->boxColor.g,button->boxColor.b, 0.2F);
|
||||
|
||||
button->setButtonListener(toolbar);
|
||||
toolbar->addButtonRef(button);
|
||||
|
||||
button = makeTextButton();
|
||||
button->boxBegin = Vector2(0, -72);
|
||||
@@ -81,6 +87,8 @@ GuiRoot::GuiRoot() : _message(""), _messageTime(0)
|
||||
button->setAllColorsSame();
|
||||
button->boxOutlineColorOvr = Color3(0,255,255);
|
||||
button->boxColorDn = Color4(button->boxColor.r,button->boxColor.g,button->boxColor.b, 0.2F);
|
||||
button->setButtonListener(toolbar);
|
||||
toolbar->addButtonRef(button);
|
||||
|
||||
button = makeTextButton();
|
||||
button->boxBegin = Vector2(0, -96);
|
||||
@@ -95,6 +103,8 @@ GuiRoot::GuiRoot() : _message(""), _messageTime(0)
|
||||
button->setAllColorsSame();
|
||||
button->boxOutlineColorOvr = Color3(0,255,255);
|
||||
button->boxColorDn = Color4(button->boxColor.r,button->boxColor.g,button->boxColor.b, 0.2F);
|
||||
button->setButtonListener(toolbar);
|
||||
toolbar->addButtonRef(button);
|
||||
|
||||
button = makeTextButton();
|
||||
button->boxBegin = Vector2(0, -120);
|
||||
@@ -109,6 +119,8 @@ GuiRoot::GuiRoot() : _message(""), _messageTime(0)
|
||||
button->setAllColorsSame();
|
||||
button->boxOutlineColorOvr = Color3(0,255,255);
|
||||
button->boxColorDn = Color4(button->boxColor.r,button->boxColor.g,button->boxColor.b, 0.2F);
|
||||
button->setButtonListener(toolbar);
|
||||
toolbar->addButtonRef(button);
|
||||
|
||||
//Top bar
|
||||
button = makeTextButton();
|
||||
@@ -503,6 +515,11 @@ void GuiRoot::update()
|
||||
}
|
||||
}
|
||||
|
||||
GuiRoot::~GuiRoot()
|
||||
{
|
||||
delete toolbar;
|
||||
}
|
||||
|
||||
void GuiRoot::onMouseLeftUp(G3D::RenderDevice* renderDevice, int x,int y)
|
||||
{
|
||||
std::vector<Instance*> instances_2D = this->getAllChildren();
|
||||
|
||||
@@ -9,6 +9,7 @@ class GuiRoot : public Instance
|
||||
{
|
||||
public:
|
||||
GuiRoot();
|
||||
GuiRoot::~GuiRoot();
|
||||
TextButtonInstance* makeTextButton();
|
||||
void drawButtons(RenderDevice* rd);
|
||||
ImageButtonInstance* makeImageButton(G3D::TextureRef newImage, G3D::TextureRef overImage, G3D::TextureRef downImage, G3D::TextureRef disableImage);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <Commdlg.h>
|
||||
#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) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Instance.h"
|
||||
#include "ModeSelectionListener.h"
|
||||
#include "Application.h"
|
||||
#include "ArrowTool.h"
|
||||
|
||||
void ModeSelectionListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||
{
|
||||
@@ -20,7 +21,7 @@ void ModeSelectionListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||
|
||||
button->selected = true;
|
||||
if(button->name == "Cursor")
|
||||
g_usableApp->setMode(CURSOR);
|
||||
g_usableApp->changeTool(new ArrowTool());
|
||||
else if(button->name == "Resize")
|
||||
g_usableApp->setMode(RESIZE);
|
||||
else if(button->name == "Arrows")
|
||||
|
||||
116
Mouse.cpp
Normal file
116
Mouse.cpp
Normal file
@@ -0,0 +1,116 @@
|
||||
#include "Mouse.h"
|
||||
#include "Application.h"
|
||||
#include "Globals.h"
|
||||
#include <algorithm>
|
||||
|
||||
Mouse::Mouse(){
|
||||
x = y = 0;
|
||||
}
|
||||
Mouse::~Mouse(){}
|
||||
|
||||
PartInstance * selectedInstance = NULL;
|
||||
Ray testRay;
|
||||
float nearest=std::numeric_limits<float>::infinity();
|
||||
void eprt(PartInstance * instance)
|
||||
{
|
||||
float time = testRay.intersectionTime(instance->getBox());
|
||||
if (time != inf())
|
||||
{
|
||||
if (nearest>time)
|
||||
{
|
||||
nearest=time;
|
||||
selectedInstance = instance;
|
||||
//This is where dead code below was
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PartInstance * Mouse::getTarget()
|
||||
{
|
||||
selectedInstance = NULL;
|
||||
testRay = g_usableApp->cameraController.getCamera()->worldRay(x, y, g_usableApp->getRenderDevice()->getViewport());
|
||||
nearest=std::numeric_limits<float>::infinity();
|
||||
//Vector3 camPos = g_usableApp->cameraController.getCamera()->getCoordinateFrame().translation;
|
||||
for_each (g_dataModel->getWorkspace()->partObjects.begin(), g_dataModel->getWorkspace()->partObjects.end(), eprt);
|
||||
return selectedInstance;
|
||||
}
|
||||
|
||||
|
||||
double getVectorDistance(Vector3 vector1, Vector3 vector2)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
MousePoint Mouse::getPositionAndPart(std::vector<Instance *> ignore)
|
||||
{
|
||||
testRay = g_usableApp->cameraController.getCamera()->worldRay(x, y, g_usableApp->getRenderDevice()->getViewport());
|
||||
PartInstance * currPart = NULL;
|
||||
Vector3 pos = testRay.closestPoint(Vector3(0,0,0));
|
||||
nearest=std::numeric_limits<float>::infinity();
|
||||
for(size_t i = 0; i < g_dataModel->getWorkspace()->partObjects.size(); i++)
|
||||
{
|
||||
PartInstance * p = g_dataModel->getWorkspace()->partObjects[i];
|
||||
if(std::find(ignore.begin(), ignore.end(), p) != ignore.end())
|
||||
continue;
|
||||
float newdistance = testRay.intersectionTime(p->getBox()); //testRay.distance(inter);
|
||||
if(G3D::isFinite(newdistance))
|
||||
{
|
||||
if(nearest > abs(newdistance))
|
||||
{
|
||||
nearest = newdistance;
|
||||
pos = testRay.origin+(testRay.direction*nearest);
|
||||
currPart = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
return MousePoint(pos, currPart);
|
||||
}
|
||||
|
||||
Vector3 Mouse::getPosition(std::vector<Instance *> ignore)
|
||||
{
|
||||
return getPositionAndPart(ignore).position;
|
||||
}
|
||||
|
||||
bool Mouse::isMouseOnScreen()
|
||||
{
|
||||
//hm
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Mouse::isMouseDown()
|
||||
{
|
||||
return mouseDown;
|
||||
}
|
||||
|
||||
void Mouse::setMouseDown(bool bval)
|
||||
{
|
||||
mouseDown = bval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//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)
|
||||
{
|
||||
selectedInstance = test;
|
||||
//if(!GetHoldKeyState(VK_RCONTROL) && !GetHoldKeyState(VK_LCONTROL))
|
||||
//g_selectedInstances.clear();
|
||||
//if(std::find(g_selectedInstances.begin(), g_selectedInstances.end(),test)==g_selectedInstances.end())
|
||||
//g_selectedInstances.push_back(test);
|
||||
}
|
||||
//selectInstance(test, _propWindow);
|
||||
//_message = "Dragging = true.";
|
||||
//_messageTime = System::time();
|
||||
//_dragging = true;*/
|
||||
|
||||
32
Mouse.h
Normal file
32
Mouse.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#include "PartInstance.h"
|
||||
#pragma once
|
||||
#include "WorkspaceInstance.h"
|
||||
|
||||
struct MousePoint{
|
||||
Vector3 position;
|
||||
PartInstance * target;
|
||||
MousePoint(Vector3 pos, PartInstance * targ)
|
||||
{
|
||||
position = pos;
|
||||
target = targ;
|
||||
}
|
||||
};
|
||||
|
||||
#pragma once
|
||||
class Mouse
|
||||
{
|
||||
public:
|
||||
Mouse();
|
||||
~Mouse(void);
|
||||
int x, y;
|
||||
int oldx, oldy;
|
||||
PartInstance * getTarget();
|
||||
MousePoint getPositionAndPart(std::vector<Instance *> ignore = std::vector<Instance *>());
|
||||
Vector3 getPosition(std::vector<Instance *> ignore = std::vector<Instance *>());
|
||||
bool isMouseOnScreen();
|
||||
bool isMouseDown();
|
||||
void setMouseDown(bool mouseDown);
|
||||
private:
|
||||
bool mouseDown;
|
||||
};
|
||||
@@ -76,19 +76,20 @@ void PartInstance::postRender(RenderDevice *rd)
|
||||
}
|
||||
}
|
||||
|
||||
void PartInstance::setParent(Instance* parent)
|
||||
void PartInstance::setParent(Instance* prnt)
|
||||
{
|
||||
Instance * cparent = this->parent;
|
||||
Instance * cparent = getParent();
|
||||
while(cparent != NULL)
|
||||
{
|
||||
if(WorkspaceInstance* workspace = dynamic_cast<WorkspaceInstance*>(parent))
|
||||
if(WorkspaceInstance* workspace = dynamic_cast<WorkspaceInstance*>(cparent))
|
||||
{
|
||||
std::cout << "Removed from partarray " << std::endl;
|
||||
workspace->partObjects.erase(std::remove(workspace->partObjects.begin(), workspace->partObjects.end(), this), workspace->partObjects.end());
|
||||
break;
|
||||
}
|
||||
cparent = cparent->getParent();
|
||||
}
|
||||
Instance::setParent(parent);
|
||||
Instance::setParent(prnt);
|
||||
while(parent != NULL)
|
||||
{
|
||||
if(WorkspaceInstance* workspace = dynamic_cast<WorkspaceInstance*>(parent))
|
||||
@@ -205,8 +206,27 @@ void PartInstance::setCFrame(CoordinateFrame coordinateFrame)
|
||||
// Can probably be deleted
|
||||
CoordinateFrame PartInstance::getCFrameRenderBased()
|
||||
{
|
||||
return CoordinateFrame(getCFrame().rotation,Vector3(getCFrame().translation.x, getCFrame().translation.y, getCFrame().translation.z));
|
||||
return cFrame;//CoordinateFrame(getCFrame().rotation,Vector3(getCFrame().translation.x, getCFrame().translation.y, getCFrame().translation.z));
|
||||
}
|
||||
|
||||
bool PartInstance::collides(PartInstance * part)
|
||||
{
|
||||
if(shape == Enum::Shape::Block)
|
||||
{
|
||||
if(part->shape == Enum::Shape::Block)
|
||||
return G3D::CollisionDetection::fixedSolidBoxIntersectsFixedSolidBox(getBox(), part->getBox());
|
||||
else
|
||||
return G3D::CollisionDetection::fixedSolidSphereIntersectsFixedSolidBox(part->getSphere(), getBox());
|
||||
}
|
||||
else
|
||||
{
|
||||
if(part->shape == Enum::Shape::Block)
|
||||
return G3D::CollisionDetection::fixedSolidSphereIntersectsFixedSolidBox(getSphere(), part->getBox());
|
||||
else
|
||||
return G3D::CollisionDetection::fixedSolidSphereIntersectsFixedSolidSphere(getSphere(), part->getSphere());
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NEW_BOX_RENDER
|
||||
Box PartInstance::getBox()
|
||||
{
|
||||
@@ -215,6 +235,13 @@ Box PartInstance::getBox()
|
||||
itemBox = c.toWorldSpace(box);
|
||||
return itemBox;
|
||||
}
|
||||
Sphere PartInstance::getSphere()
|
||||
{
|
||||
Sphere sphere = Sphere(Vector3(0,0,0), size.y/2);
|
||||
CoordinateFrame c = getCFrameRenderBased();
|
||||
//itemBox = c.toWorldSpace(Sphere);
|
||||
return sphere;//itemBox;
|
||||
}
|
||||
#else
|
||||
Box PartInstance::getBox()
|
||||
{
|
||||
@@ -966,6 +993,7 @@ static TCHAR* enumStr(int shape)
|
||||
case Enum::Shape::Cylinder:
|
||||
return "Cylinder";
|
||||
}
|
||||
return "Block";
|
||||
}
|
||||
|
||||
void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
|
||||
|
||||
@@ -31,10 +31,12 @@ public:
|
||||
void setParent(Instance* parent);
|
||||
void setPosition(Vector3);
|
||||
void setVelocity(Vector3);
|
||||
bool collides(PartInstance * part);
|
||||
void setRotVelocity(Vector3);
|
||||
CoordinateFrame getCFrame();
|
||||
void setCFrame(CoordinateFrame);
|
||||
Box getBox();
|
||||
Sphere getSphere();
|
||||
Box getScaledBox();
|
||||
CoordinateFrame getCFrameRenderBased();
|
||||
Vector3 getSize();
|
||||
|
||||
12
TextureHandler.cpp
Normal file
12
TextureHandler.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "TextureHandler.h"
|
||||
|
||||
TextureHandler::TextureHandler(void)
|
||||
{
|
||||
}
|
||||
|
||||
TextureHandler::~TextureHandler(void)
|
||||
{
|
||||
}
|
||||
std::map<std::string, G3D::TextureRef> TextureHandler::volTex = std::map<std::string, G3D::TextureRef>();
|
||||
std::map<std::string, G3D::RealTime> TextureHandler::volExp = std::map<std::string, G3D::RealTime>();
|
||||
std::map<std::string, G3D::TextureRef> TextureHandler::permTex = std::map<std::string, G3D::TextureRef>();
|
||||
87
TextureHandler.h
Normal file
87
TextureHandler.h
Normal file
@@ -0,0 +1,87 @@
|
||||
#pragma once
|
||||
#include <G3DAll.h>
|
||||
#include <map>
|
||||
class TextureHandler
|
||||
{
|
||||
public:
|
||||
TextureHandler(void);
|
||||
~TextureHandler(void);
|
||||
static int getTextureVolatile(std::string str)
|
||||
{
|
||||
if(!volTex[str].isNull())
|
||||
{
|
||||
volExp[str] = G3D::System::time();
|
||||
return volTex[str]->openGLID();
|
||||
}
|
||||
else
|
||||
{
|
||||
G3D::TextureRef tex = G3D::Texture::fromFile(str);
|
||||
volExp[str] = G3D::System::time();
|
||||
volTex[str] = tex;
|
||||
return tex->openGLID();
|
||||
}
|
||||
}
|
||||
static int getTexturePermanent(std::string str)
|
||||
{
|
||||
if(!permTex[str].isNull())
|
||||
{
|
||||
return permTex[str]->openGLID();
|
||||
}
|
||||
else
|
||||
{
|
||||
G3D::TextureRef tex = G3D::Texture::fromFile(str);
|
||||
permTex[str] = tex;
|
||||
return tex->openGLID();
|
||||
}
|
||||
}
|
||||
static void flushVolatile()
|
||||
{
|
||||
std::map<std::string, G3D::RealTime>::iterator it;
|
||||
for (it=volExp.begin(); it!=volExp.end(); ++it)
|
||||
{
|
||||
if(it->second < G3D::System::time() - 3)
|
||||
{
|
||||
volTex[it->first]->~Texture();
|
||||
volTex.erase(it->first);
|
||||
volExp.erase(it->first);
|
||||
//it->second->~ReferenceCountedPointer();
|
||||
}
|
||||
}
|
||||
}
|
||||
static void dispose()
|
||||
{
|
||||
std::map<std::string, G3D::TextureRef>::iterator it;
|
||||
for (it=volTex.begin(); it!=volTex.end(); ++it)
|
||||
{
|
||||
it->second->~Texture();
|
||||
//it->second->~ReferenceCountedPointer();
|
||||
}
|
||||
for (it=permTex.begin(); it!=permTex.end(); ++it)
|
||||
{
|
||||
it->second->~Texture();
|
||||
//it->second->~ReferenceCountedPointer();
|
||||
}
|
||||
permTex.clear();
|
||||
volTex.clear();
|
||||
}
|
||||
|
||||
static void remove(std::string str)
|
||||
{
|
||||
if(!volTex[str].isNull())
|
||||
{
|
||||
volTex[str]->~Texture();
|
||||
//volTex[str]->~ReferenceCountedPointer();
|
||||
volTex.erase(str);
|
||||
}
|
||||
if(!permTex[str].isNull())
|
||||
{
|
||||
permTex[str]->~Texture();
|
||||
//permTex[str]->~ReferenceCountedPointer();
|
||||
permTex.erase(str);
|
||||
}
|
||||
}
|
||||
private:
|
||||
static std::map<std::string, G3D::TextureRef> volTex;
|
||||
static std::map<std::string, G3D::RealTime> volExp;
|
||||
static std::map<std::string, G3D::TextureRef> permTex;
|
||||
};
|
||||
32
Tool.cpp
Normal file
32
Tool.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "Tool.h"
|
||||
|
||||
Tool::Tool(void)
|
||||
{
|
||||
cursorString = GetFileInPath("/content/images/ArrowFarCursor.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(int key){}
|
||||
void Tool::onKeyUp(int key){}
|
||||
void Tool::setCursor(std::string str)
|
||||
{
|
||||
cursorString = str;
|
||||
}
|
||||
int Tool::getCursorId()
|
||||
{
|
||||
return TextureHandler::getTexturePermanent(cursorString);
|
||||
}
|
||||
34
Tool.h
Normal file
34
Tool.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include "TextureHandler.h"
|
||||
#pragma once
|
||||
#include <G3DAll.h>
|
||||
#pragma once
|
||||
#include "Mouse.h"
|
||||
#pragma once
|
||||
#include "Globals.h"
|
||||
#pragma once
|
||||
#include "StringFunctions.h"
|
||||
#pragma once
|
||||
class Tool
|
||||
{
|
||||
public:
|
||||
Tool(void);
|
||||
~Tool(void);
|
||||
virtual void onButton1MouseDown(Mouse); //yes
|
||||
virtual void onButton2MouseDown(Mouse); //yes
|
||||
virtual void onButton3MouseDown(Mouse); //no
|
||||
virtual void onButton1MouseUp(Mouse);//yes
|
||||
virtual void onButton2MouseUp(Mouse);//yes
|
||||
virtual void onButton3MouseUp(Mouse); //no
|
||||
virtual void onMouseMoved(Mouse);//yes
|
||||
virtual void onSelect(Mouse);//yes
|
||||
virtual void onDeselect(Mouse);//yes
|
||||
virtual void onMouseScroll(Mouse);//Kinda
|
||||
virtual void onKeyDown(int);//yes
|
||||
virtual void onKeyUp(int);//yes
|
||||
virtual int getCursorId();//yes
|
||||
protected:
|
||||
virtual void setCursor(std::string);
|
||||
private:
|
||||
std::string cursorString;
|
||||
};
|
||||
23
ToolbarListener.cpp
Normal file
23
ToolbarListener.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "ToolbarListener.h"
|
||||
#include "Globals.h"
|
||||
#include "StringFunctions.h"
|
||||
#include "Application.h"
|
||||
|
||||
void ToolbarListener::onButton1MouseClick(BaseButtonInstance* btn)
|
||||
{
|
||||
if(TextButtonInstance* button = dynamic_cast<TextButtonInstance*>(btn))
|
||||
{
|
||||
for(size_t i = 0; i < btns.size(); i++)
|
||||
btns[i]->selected = false;
|
||||
button->selected = true;
|
||||
if(button->title == "Model") g_usableApp->navigateToolbox("http://androdome.com/res/ClientToolbox.php");
|
||||
else if(button->title == "Surface") g_usableApp->navigateToolbox(GetFileInPath("/content/page/surface.html"));
|
||||
else if(button->title == "Color") g_usableApp->navigateToolbox(GetFileInPath("/content/page/color.html"));
|
||||
else if(button->title == "Controller") g_usableApp->navigateToolbox(GetFileInPath("/content/page/controller.html"));
|
||||
else if(button->title == "Hopper") g_usableApp->navigateToolbox(GetFileInPath("/content/page/hopper.html"));
|
||||
}
|
||||
}
|
||||
void ToolbarListener::addButtonRef(BaseButtonInstance* button)
|
||||
{
|
||||
btns.push_back(button);
|
||||
}
|
||||
13
ToolbarListener.h
Normal file
13
ToolbarListener.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "buttonlistener.h"
|
||||
#pragma once
|
||||
#include <G3DAll.h>
|
||||
|
||||
class ToolbarListener : public ButtonListener
|
||||
{
|
||||
public:
|
||||
void onButton1MouseClick(BaseButtonInstance* button);
|
||||
void addButtonRef(BaseButtonInstance* button);
|
||||
private:
|
||||
std::vector<BaseButtonInstance*> btns;
|
||||
};
|
||||
BIN
content/images/ArrowFarCursor.png
Normal file
BIN
content/images/ArrowFarCursor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
@@ -22,25 +22,25 @@
|
||||
}
|
||||
</style>
|
||||
<body style="background-color: ButtonFace; margin: 0; padding: 5px; overflow: hidden; border:0;">
|
||||
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onclick="window.external.ToggleHopperBin(0)">
|
||||
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onmouseout="toolOut(this)" onclick="alert(window.external.ToggleHopperBin(0))">
|
||||
<img src="../images/GameTool.png" />
|
||||
</span>
|
||||
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onclick="window.external.ToggleHopperBin(1)">
|
||||
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onmouseout="toolOut(this)" onclick="window.external.ToggleHopperBin(1)">
|
||||
<img src="../images/Grab.png" />
|
||||
</span>
|
||||
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onclick="window.external.ToggleHopperBin(2)">
|
||||
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onmouseout="toolOut(this)" onclick="window.external.ToggleHopperBin(2)">
|
||||
<img src="../images/Clone.png" />
|
||||
</span>
|
||||
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onclick="window.external.ToggleHopperBin(3)">
|
||||
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onmouseout="toolOut(this)" onclick="window.external.ToggleHopperBin(3)">
|
||||
<img src="../images/Hammer.png" />
|
||||
</span>
|
||||
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onclick="window.external.ToggleHopperBin(4)">
|
||||
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onmouseout="toolOut(this)" onclick="window.external.ToggleHopperBin(4)">
|
||||
<img src="../images/Slingshot.png" />
|
||||
</span>
|
||||
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onclick="window.external.ToggleHopperBin(5)">
|
||||
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onmouseout="toolOut(this)" onclick="window.external.ToggleHopperBin(5)">
|
||||
<img src="../images/Rocket.png" />
|
||||
</span>
|
||||
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onclick="window.external.ToggleHopperBin(6)">
|
||||
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onmouseout="toolOut(this)" onclick="window.external.ToggleHopperBin(6)">
|
||||
<img src="../images/Laser.png" />
|
||||
</span>
|
||||
</body>
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
}
|
||||
</script>
|
||||
<body style="background-color: ButtonFace; margin: 0; padding: 5px; overflow: hidden; border:0;">
|
||||
<img src="../images/FlatTool.png" onclick="window.external.SetSurface(0)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
|
||||
<img src="../images/BumpTool.png" onclick="window.external.SetSurface(1)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
|
||||
<img src="../images/HingeTool.png" onclick="window.external.SetSurface(2)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
|
||||
<img src="../images/LeftMotorTool.png" onclick="window.external.SetSurface(3)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
|
||||
<img src="../images/LeftMotorFastTool.png" onclick="window.external.SetSurface(4)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
|
||||
<img src="../images/RightMotorTool.png" onclick="window.external.SetSurface(5)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
|
||||
<img src="../images/RightMotorFastTool.png" onclick="window.external.SetSurface(6)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
|
||||
<img src="../images/FlatTool.png" onmouseout="toolOut(this)" onclick="window.external.SetSurface(0)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
|
||||
<img src="../images/BumpTool.png" onmouseout="toolOut(this)" onclick="window.external.SetSurface(1)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
|
||||
<img src="../images/HingeTool.png" onmouseout="toolOut(this)" onclick="window.external.SetSurface(2)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
|
||||
<img src="../images/LeftMotorTool.png" onmouseout="toolOut(this)" onclick="window.external.SetSurface(3)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
|
||||
<img src="../images/LeftMotorFastTool.png" onmouseout="toolOut(this)" onclick="window.external.SetSurface(4)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
|
||||
<img src="../images/RightMotorTool.png" onmouseout="toolOut(this)" onclick="window.external.SetSurface(5)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
|
||||
<img src="../images/RightMotorFastTool.png" onmouseout="toolOut(this)" onclick="window.external.SetSurface(6)" onmousedown="toolOvr(this)" onmouseup="toolOut(this)"/>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user