GUI separated from Application.cpp

This commit is contained in:
MusicalProgrammer
2019-11-04 23:57:31 -05:00
parent 1fe59aa9ff
commit aa11f5f120
26 changed files with 674 additions and 542 deletions

View File

@@ -24,6 +24,7 @@
#include "PropertyWindow.h"
#include <commctrl.h>
#include "StringFunctions.h"
#include "GuiRoot.h"
#include "GUDButtonListener.h"
#include "ModeSelectionListener.h"
@@ -53,27 +54,11 @@ PartInstance* Application::makePart()
return part;
}
TextButtonInstance* Application::makeTextButton()
{
TextButtonInstance* part = new TextButtonInstance();
return part;
}
ImageButtonInstance* Application::makeImageButton(G3D::TextureRef newImage = NULL, G3D::TextureRef overImage = NULL, G3D::TextureRef downImage = NULL, G3D::TextureRef disableImage = NULL)
{
ImageButtonInstance* part = new ImageButtonInstance(newImage,overImage, downImage, disableImage);
// instances.push_back(part);
// instances_2D.push_back(part);
return part;
}
Application::Application(HWND parentWindow) : _message(""), _messageTime(0) { //: GApp(settings,window) {
Application::Application(HWND parentWindow) { //: GApp(settings,window) {
std::string tempPath = ((std::string)getenv("temp")) + "/"+g_PlaceholderName;
CreateDirectory(tempPath.c_str(), NULL);
_message = tempPath;
_messageTime = System::time();
_hWndMain = parentWindow;
HMODULE hThisInstance = GetModuleHandle(NULL);
@@ -167,342 +152,6 @@ void Application::deleteInstance()
g_usableApp->_propWindow->ClearProperties();
}
void Application::initGUI()
{
TextButtonInstance* button = makeTextButton();
button->boxBegin = Vector2(0, -24);
button->boxEnd = Vector2(80, 0);
button->floatBottom = true;
button->setParent(_dataModel->getGuiRoot());
button->font = fntlighttrek;
button->textColor = Color3(0,255,255);
button->textOutlineColor = Color4::clear();
button->title = "Hopper";
button->fontLocationRelativeTo = Vector2(10, 3);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(0, -48);
button->boxEnd = Vector2(80, -24);
button->floatBottom = true;
button->setParent(_dataModel->getGuiRoot());
button->font = fntlighttrek;
button->textColor = Color3(0,255,255);
button->textOutlineColor = Color4::clear();
button->title = "Controller";
button->fontLocationRelativeTo = Vector2(10, 3);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(0, -72);
button->boxEnd = Vector2(80, -48);
button->floatBottom = true;
button->setParent(_dataModel->getGuiRoot());
button->font = fntlighttrek;
button->textColor = Color3(0,255,255);
button->textOutlineColor = Color4::clear();
button->title = "Color";
button->fontLocationRelativeTo = Vector2(10, 3);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(0, -96);
button->boxEnd = Vector2(80, -72);
button->floatBottom = true;
button->setParent(_dataModel->getGuiRoot());
button->font = fntlighttrek;
button->textColor = Color3(0,255,255);
button->textOutlineColor = Color4::clear();
button->title = "Surface";
button->fontLocationRelativeTo = Vector2(10, 3);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(0, -120);
button->boxEnd = Vector2(80, -96);
button->floatBottom = true;
button->setParent(_dataModel->getGuiRoot());
button->font = fntlighttrek;
button->textColor = Color3(0,255,255);
button->boxOutlineColor = Color3(0,255,255);
button->title = "Model";
button->fontLocationRelativeTo = Vector2(10, 3);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(0, 0);
button->boxEnd = Vector2(125, 25);
button->setParent(_dataModel->getGuiRoot());
button->font = fntlighttrek;
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->title = "File";
button->textSize = 16;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(125, 0);
button->boxEnd = Vector2(250, 25);
button->setParent(_dataModel->getGuiRoot());
button->font = fntlighttrek;
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->title = "Edit";
button->textSize = 16;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(250, 0);
button->boxEnd = Vector2(375, 25);
button->setParent(_dataModel->getGuiRoot());
button->font = fntlighttrek;
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->title = "View";
button->textSize = 16;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(375, 0);
button->boxEnd = Vector2(500, 25);
button->setParent(_dataModel->getGuiRoot());
button->font = fntlighttrek;
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->title = "Insert";
button->textSize = 16;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(500, 0);
button->boxEnd = Vector2(625, 25);
button->setParent(_dataModel->getGuiRoot());
button->font = fntlighttrek;
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->title = "Format";
button->textSize = 16;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(0,215);
button->boxEnd = Vector2(80,235);
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textSize = 12;
button->title = "Group";
button->name = "Group";
button->setAllColorsSame();
button->textColorDis = Color3(0.8F,0.8F,0.8F);
button->font = fntlighttrek;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setParent(_dataModel->getGuiRoot());
button = makeTextButton();
button->boxBegin = Vector2(0,240);
button->boxEnd = Vector2(80,260);
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textSize = 12;
button->title = "UnGroup";
button->name = "UnGroup";
button->setAllColorsSame();
button->textColorDis = Color3(0.8F,0.8F,0.8F);
button->font = fntlighttrek;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setParent(_dataModel->getGuiRoot());
button = makeTextButton();
button->boxBegin = Vector2(0,265);
button->boxEnd = Vector2(80,285);
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textSize = 12;
button->title = "Duplicate";
button->setAllColorsSame();
button->textColorDis = Color3(0.8F,0.8F,0.8F);
button->font = fntlighttrek;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setParent(_dataModel->getGuiRoot());
button->name = "Duplicate";
button->setButtonListener(new GUDButtonListener());
ImageButtonInstance* instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/Run.png")),
Texture::fromFile(GetFileInPath("/content/images/Run_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/Run_dn.png")));
instance->name = "go";
instance->size = Vector2(65,65);
instance->position = Vector2(6.5, 25);
instance->setParent(_dataModel->getGuiRoot());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/ArrowTool.png")),
Texture::fromFile(GetFileInPath("/content/images/ArrowTool_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/ArrowTool_dn.png")),
Texture::fromFile(GetFileInPath("/content/images/ArrowTool_ds.png")));
instance->size = Vector2(50,50);
instance->position = Vector2(15, 90);
instance->setParent(_dataModel->getGuiRoot());
instance->name = "Cursor";
instance->setButtonListener(new ModeSelectionListener());
instance = makeImageButton(Texture::fromFile(GetFileInPath("/content/images/ScaleTool.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ovr.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_dn.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ds.png")));
instance->size = Vector2(40,40);
instance->position = Vector2(0, 140);
instance->setParent(_dataModel->getGuiRoot());
instance->name = "Resize";
instance->setButtonListener(new ModeSelectionListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/MoveTool.png")),
Texture::fromFile(GetFileInPath("/content/images/MoveTool_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/MoveTool_dn.png")),
Texture::fromFile(GetFileInPath("/content/images/MoveTool_ds.png")));
instance->size = Vector2(40,40);
instance->position = Vector2(40, 140);
instance->setParent(_dataModel->getGuiRoot());
instance->name = "Arrows";
instance->setButtonListener(new ModeSelectionListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate.png")),
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate_ovr.png")),
NULL,
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate_ds.png")));
instance->size = Vector2(30,30);
instance->position = Vector2(10, 175);
instance->setParent(_dataModel->getGuiRoot());
instance->name = "Rotate";
instance->setButtonListener(new RotateButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt.png")),
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt_ovr.png")),
NULL,
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt_ds.png")));
instance->size = Vector2(30,30);
instance->position = Vector2(40, 175);
instance->setParent(_dataModel->getGuiRoot());
instance->name = "Tilt";
instance->setButtonListener(new RotateButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/Delete.png")),
Texture::fromFile(GetFileInPath("/content/images/Delete_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/Delete_dn.png")),
Texture::fromFile(GetFileInPath("/content/images/Delete_ds.png")));
instance->size = Vector2(40,46);
instance->position = Vector2(20, 284);
instance->setParent(_dataModel->getGuiRoot());
instance->name = "Delete";
instance->setButtonListener(new DeleteListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraZoomIn.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraZoomIn_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraZoomIn_dn.png")));
instance->size = Vector2(34,25);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-77, -90);
instance->setParent(_dataModel->getGuiRoot());
instance->name = "ZoomIn";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraZoomOut.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraZoomOut_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraZoomOut_dn.png")));
instance->size = Vector2(34,26);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-77, -31);
instance->setParent(_dataModel->getGuiRoot());
instance->name = "ZoomOut";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraPanLeft.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraPanLeft_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraPanLeft_dn.png")));
instance->size = Vector2(34,34);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-110, -50);
instance->setParent(_dataModel->getGuiRoot());
instance->name = "PanLeft";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraPanRight.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraPanRight_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraPanRight_dn.png")));
instance->size = Vector2(34,34);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-45, -50);
instance->setParent(_dataModel->getGuiRoot());
instance->name = "PanRight";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraCenter.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraCenter_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraCenter_dn.png")));
instance->size = Vector2(34,20);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-77, -60);
instance->setParent(_dataModel->getGuiRoot());
instance->name = "CenterCam";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraTiltUp.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraTiltUp_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraTiltUp_dn.png")));
instance->size = Vector2(24,24);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-105, -75);
instance->setParent(_dataModel->getGuiRoot());
instance->name = "TiltUp";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraTiltDown.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraTiltDown_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraTiltDown_dn.png")));
instance->size = Vector2(24,24);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-40, -75);
instance->setParent(_dataModel->getGuiRoot());
instance->name = "TiltDown";
instance->setButtonListener(new CameraButtonListener());
}
void Application::onInit() {
// Called before Application::run() beings
@@ -510,10 +159,10 @@ void Application::onInit() {
_dataModel = new DataModelInstance();
_dataModel->setParent(NULL);
_dataModel->name = "undefined";
_dataModel->font = fntdominant;
_dataModel->font = g_fntdominant;
g_dataModel = _dataModel;
initGUI();
//initGUI();
#ifdef LEGACY_LOAD_G3DFUN_LEVEL
PartInstance* test = makePart();
@@ -648,39 +297,7 @@ void Application::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
Instance * obj6 = _dataModel->getGuiRoot()->findFirstChild("Delete");
Instance * obj = _dataModel->getGuiRoot()->findFirstChild("Duplicate");
Instance * obj2 = _dataModel->getGuiRoot()->findFirstChild("Group");
Instance * obj3 = _dataModel->getGuiRoot()->findFirstChild("UnGroup");
Instance * obj4 = _dataModel->getGuiRoot()->findFirstChild("Rotate");
Instance * obj5 = _dataModel->getGuiRoot()->findFirstChild("Tilt");
if(obj != NULL && obj2 != NULL && obj3 != NULL && obj4 !=NULL && obj5 != NULL && obj6 != NULL)
{
BaseButtonInstance* button = (BaseButtonInstance*)obj;
BaseButtonInstance* button2 = (BaseButtonInstance*)obj2;
BaseButtonInstance* button3 = (BaseButtonInstance*)obj3;
BaseButtonInstance* button4 = (BaseButtonInstance*)obj4;
BaseButtonInstance* button5 = (BaseButtonInstance*)obj5;
BaseButtonInstance* button6 = (BaseButtonInstance*)obj6;
button->disabled = true;
button2->disabled = true;
button3->disabled = true;
button4->disabled = true;
button5->disabled = true;
button6->disabled = true;
for(size_t i = 0; i < g_selectedInstances.size(); i++)
if(g_selectedInstances.at(i)->canDelete)
{
button->disabled = false;
button2->disabled = false;
button3->disabled = false;
button4->disabled = false;
button5->disabled = false;
button6->disabled = false;
break;
}
}
_dataModel->getGuiRoot()->update();
if(_dataModel->name != _title)
{
@@ -730,9 +347,7 @@ void Application::onUserInput(UserInput* ui) {
*/
if(GetHoldKeyState(VK_F8))
{
_messageTime = System::time();
_message = "FOV Set to 10";
_dataModel->getGuiRoot()->setDebugMessage("FOV Set to 10", System::time());
}
//}
@@ -810,19 +425,15 @@ void Application::makeFlag(Vector3 &vec, RenderDevice* &rd)
//I know how i will approach this now
}
void Application::setMode(int mode)
{
_mode = mode;
}
int Application::getMode()
{
return _mode;
}
void Application::drawButtons(RenderDevice* rd)
{
rd->pushState();
rd->beforePrimitive();
_dataModel->getGuiRoot()->render(rd);
rd->afterPrimitive();
rd->popState();
}
void Application::drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters lighting, Vector3 size, Vector3 pos, CoordinateFrame c)
{
@@ -986,7 +597,7 @@ void Application::onGraphics(RenderDevice* rd) {
{
Vector3 size = part->getSize();
Vector3 pos = part->getPosition();
drawOutline(Vector3(0+size.x/2, 0+size.y/2, 0+size.z/2) ,Vector3(0-size.x/2,0-size.y/2,0-size.z/2), rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x/2, pos.y/2, pos.z/2), part->getCFrameRenderBased());
drawOutline(Vector3(0+size.x/2, 0+size.y/2, 0+size.z/2) ,Vector3(0-size.x/2,0-size.y/2,0-size.z/2), rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x, pos.y, pos.z), part->getCFrameRenderBased());
}
}
}
@@ -1009,33 +620,7 @@ void Application::onGraphics(RenderDevice* rd) {
sky->renderLensFlare(renderDevice, lighting);
}
renderDevice->push2D();
if(System::time() - 3 < _messageTime)
{
fntdominant->draw2D(rd, _message, Vector2((rd->getWidth()/2)-(fntdominant->get2DStringBounds(_message, 20).x/2),(rd->getHeight()/2)-(fntdominant->get2DStringBounds(_message, 20).y/2)), 20, Color3::yellow(), Color3::black());
}
//TODO--Move these to their own instance
std::stringstream stream;
stream << std::fixed << std::setprecision(1) << _dataModel->getLevel()->timer;
fntdominant->draw2D(rd, "Timer: " + stream.str(), Vector2(rd->getWidth() - 120, 25), 20, Color3::fromARGB(0x81C518), Color3::black());
fntdominant->draw2D(rd, "Score: " + Convert(_dataModel->getLevel()->score), Vector2(rd->getWidth() - 120, 50), 20, Color3::fromARGB(0x81C518), Color3::black());
//GUI Boxes
Draw::box(G3D::Box(Vector3(0,25,0),Vector3(80,355,0)),rd,Color4(0.6F,0.6F,0.6F,0.4F), Color4(0,0,0,0));
Draw::box(G3D::Box(Vector3(rd->getWidth() - 120,rd->getHeight() - 120,0),Vector3(rd->getWidth(),rd->getHeight(),0)),rd,Color4(0.6F,0.6F,0.6F,0.4F), Color4(0,0,0,0));
//Camera menu title
fntlighttrek->draw2D(rd, "CameraMenu", Vector2(rd->getWidth()-(fntlighttrek->get2DStringBounds("CameraMenu", 14).x+1),rd->getHeight() - 120), 14, Color3::white(), Color4(0.5F,0.5F,0.5F,0.5F));
//Tools menu
Draw::box(G3D::Box(Vector3(5, 210,0),Vector3(75, 210,0)),rd,Color4(0.6F,0.6F,0.6F,0.4F), Color4(0.6F,0.6F,0.6F,0.4F));
fntlighttrek->draw2D(rd,"MENU", Vector2(10,332), 14, Color3::white(), Color4(0.5F,0.5F,0.5F,0.5F));
drawButtons(rd);
_dataModel->drawMessage(rd);
_dataModel->getGuiRoot()->renderGUI(renderDevice);
rd->pushState();
rd->beforePrimitive();
@@ -1110,19 +695,9 @@ void Application::onMouseLeftPressed(HWND hwnd,int x,int y)
std::cout << "Click: " << x << "," << y << std::endl;
bool onGUI = false;
std::vector<Instance*> instances_2D = _dataModel->getGuiRoot()->getAllChildren();
for(size_t i = 0; i < instances_2D.size(); i++)
{
if(BaseButtonInstance* button = dynamic_cast<BaseButtonInstance*>(instances_2D.at(i)))
{
if(button->mouseInButton(x,y, renderDevice))
{
onGUI = true;
break;
}
}
}
bool onGUI = _dataModel->getGuiRoot()->mouseInGUI(renderDevice, x, y);
if(!onGUI)
{
testRay = cameraController.getCamera()->worldRay(_dataModel->mousex, _dataModel->mousey, renderDevice->getViewport());
@@ -1159,7 +734,7 @@ void Application::onMouseLeftPressed(HWND hwnd,int x,int y)
g_selectedInstances.clear();
g_selectedInstances.push_back(test);
}
_propWindow->UpdateSelected(test);
selectInstance(test, _propWindow);
//_message = "Dragging = true.";
//_messageTime = System::time();
//_dragging = true;
@@ -1168,34 +743,32 @@ void Application::onMouseLeftPressed(HWND hwnd,int x,int y)
}
}
if(!objFound)
{
g_selectedInstances.clear();
g_selectedInstances.push_back(_dataModel);
_propWindow->UpdateSelected(_dataModel);
}
selectInstance(_dataModel,_propWindow);
}
}
void Application::onMouseLeftUp(int x,int y)
void Application::selectInstance(Instance* selectedInstance, PropertyWindow* propWindow)
{
g_selectedInstances.clear();
g_selectedInstances.push_back(selectedInstance);
propWindow->UpdateSelected(selectedInstance);
}
G3D::RenderDevice* Application::getRenderDevice()
{
return renderDevice;
}
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;
//_message = "Dragging = false.";
//_messageTime = System::time();
std::vector<Instance*> instances_2D = _dataModel->getGuiRoot()->getAllChildren();
//std::vector<Instance*> instances = _dataModel->getWorkspace()->getAllChildren();
for(size_t i = 0; i < instances_2D.size(); i++)
{
if(BaseButtonInstance* button = dynamic_cast<BaseButtonInstance*>(instances_2D[i]))
{
if(button->mouseInButton(x, y, renderDevice))
{
button->onMouseClick();
}
}
}
}
void Application::onMouseRightPressed(int x,int y)
{
}
@@ -1243,8 +816,6 @@ void Application::run() {
cursorOvr = Texture::fromFile(GetFileInPath("/content/images/DragCursor.png"));
Globals::surface = Texture::fromFile(GetFileInPath("/content/images/surfacebr.png"));
Globals::surfaceId = Globals::surface->getOpenGLID();
fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt"));
fntlighttrek = GFont::fromFile(GetFileInPath("/content/font/lighttrek.fnt"));
cameraSound = GetFileInPath("/content/sounds/SWITCH3.wav");
clickSound = GetFileInPath("/content/sounds/switch.wav");
dingSound = GetFileInPath("/content/sounds/electronicpingshort.wav");

View File

@@ -4,6 +4,7 @@
#include "TextButtonInstance.h"
#include "ImageButtonInstance.h"
#include "CameraController.h"
//#include "GuiRoot.h"
class TextButtonInstance;
class ImageButtonInstance;
@@ -28,8 +29,6 @@ class Application { // : public GApp {
void drawButtons(RenderDevice* rd);
void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters lighting, Vector3 size, Vector3 pos, CoordinateFrame c);
void makeFlag(Vector3 &vec, RenderDevice* &rd);
TextButtonInstance* makeTextButton();
ImageButtonInstance* makeImageButton(G3D::TextureRef newImage, G3D::TextureRef overImage, G3D::TextureRef downImage, G3D::TextureRef disableImage);
std::vector<Instance*> getSelection();
void deleteInstance();
void run();
@@ -39,19 +38,22 @@ class Application { // : public GApp {
void onKeyPressed(int key);
void onKeyUp(int key);
void onMouseLeftPressed(HWND hwnd,int x, int y);
void onMouseLeftUp(int x, int y);
void onMouseLeftUp(RenderDevice* renderDevice, int x, int y);
void onMouseRightPressed(int x, int y);
void onMouseRightUp(int x, int y);
void onMouseMoved(int x, int y);
void onMouseWheel(int x, int y, short delta);
int getMode();
CameraController cameraController;
RenderDevice* renderDevice;
UserInput* userInput;
PropertyWindow* _propWindow;
void generateShadowMap(const CoordinateFrame& lightViewMatrix) const;
RenderDevice* getRenderDevice();
void selectInstance(Instance* selectedInstance,PropertyWindow* propWindow);
void setMode(int mode);
private:
void initGUI();
RenderDevice* renderDevice;
//void initGUI();
HWND _hWndMain;
SkyRef sky;
bool quit;
@@ -63,8 +65,6 @@ class Application { // : public GApp {
HWND _buttonTest;
HWND _hwndRenderer;
DataModelInstance* _dataModel;
std::string _message;
G3D::RealTime _messageTime;
G3D::TextureRef shadowMap;
std::string _title;
bool _dragging;

View File

@@ -1,3 +1,4 @@
#include "BaseButtonInstance.h"
#include "ButtonListener.h"

View File

@@ -1,20 +1,21 @@
#pragma once
//#include "Application.h"
#include "BaseButtonInstance.h"
//#include "BaseButtonInstance.h"
class BaseButtonInstance;
class ButtonListener
{
public:
ButtonListener();
~ButtonListener(void);
virtual void onButton1MouseClick(BaseButtonInstance*);
//virtual void onMouseOver(); //TODO
//virtual void onMouseOut(); //TODO
//virtual void onButton1MouseDown(); //TODO
//virtual void onButton1MouseUp(); //TODO
//virtual void onButton2MouseClick(); //TODO
//virtual void onButton2MouseDown(); //TODO
//virtual void onButton2MouseUp(); //TODO
//What to do now...
public:
ButtonListener();
~ButtonListener(void);
virtual void onButton1MouseClick(BaseButtonInstance*);
//virtual void onMouseOver(); //TODO
//virtual void onMouseOut(); //TODO
//virtual void onButton1MouseDown(); //TODO
//virtual void onButton1MouseUp(); //TODO
//virtual void onButton2MouseClick(); //TODO
//virtual void onButton2MouseDown(); //TODO
//virtual void onButton2MouseUp(); //TODO
//What to do now...
};

View File

@@ -1,3 +1,4 @@
#pragma once
#include "ButtonListener.h"
class CameraButtonListener : public ButtonListener {

View File

@@ -1,4 +1,5 @@
#include <string>
#include "GuiRoot.h"
#include "DataModelInstance.h"
#include <fstream>
#include <iostream>
@@ -13,7 +14,7 @@ DataModelInstance::DataModelInstance(void)
{
Instance::Instance();
workspace = new WorkspaceInstance();
guiRoot = new Instance();
guiRoot = new GuiRoot();
level = new LevelInstance();
//children.push_back(workspace);
//children.push_back(level);
@@ -540,7 +541,7 @@ void DataModelInstance::setMousePos(Vector2 pos)
mousex=pos.x;
mousey=pos.y;
}
Instance* DataModelInstance::getGuiRoot()
GuiRoot* DataModelInstance::getGuiRoot()
{
return guiRoot;
}

View File

@@ -3,6 +3,9 @@
#include "LevelInstance.h"
#include "PartInstance.h"
#include "rapidxml/rapidxml.hpp"
#include "GuiRoot.h"
class GuiRoot;
class DataModelInstance :
public Instance
@@ -22,12 +25,12 @@ public:
WorkspaceInstance* workspace;
LevelInstance * level;
LevelInstance * getLevel();
Instance* guiRoot;
GuiRoot* guiRoot;
std::string message;
std::string _loadedFileName;
bool showMessage;
G3D::GFontRef font;
Instance* getGuiRoot();
GuiRoot* getGuiRoot();
float mousex;
float mousey;
Vector2 getMousePos();

View File

@@ -1,3 +1,4 @@
#pragma once
#include <string>
void OnError(int err, std::string msg = "");

View File

@@ -1,8 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "G3DTest", "G3DTest.vcproj", "{6C4D6EEF-B1D1-456A-B850-92CAB17124BE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "graphics3D", "..\..\..\..\SDK\VisualC\VS2005\g3d-src-6_10\source\graphics3D.vcproj", "{FD379372-8DB2-4C2C-A4D8-4694BAA94640}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GLG3D", "..\..\..\..\SDK\VisualC\VS2005\g3d-src-6_10\source\GLG3D.vcproj", "{EF60D11E-36A7-43EB-B198-DD3906DCFDBF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -13,6 +17,14 @@ Global
{6C4D6EEF-B1D1-456A-B850-92CAB17124BE}.Debug|Win32.Build.0 = Debug|Win32
{6C4D6EEF-B1D1-456A-B850-92CAB17124BE}.Release|Win32.ActiveCfg = Release|Win32
{6C4D6EEF-B1D1-456A-B850-92CAB17124BE}.Release|Win32.Build.0 = Release|Win32
{FD379372-8DB2-4C2C-A4D8-4694BAA94640}.Debug|Win32.ActiveCfg = Debug|Win32
{FD379372-8DB2-4C2C-A4D8-4694BAA94640}.Debug|Win32.Build.0 = Debug|Win32
{FD379372-8DB2-4C2C-A4D8-4694BAA94640}.Release|Win32.ActiveCfg = Release|Win32
{FD379372-8DB2-4C2C-A4D8-4694BAA94640}.Release|Win32.Build.0 = Release|Win32
{EF60D11E-36A7-43EB-B198-DD3906DCFDBF}.Debug|Win32.ActiveCfg = Debug|Win32
{EF60D11E-36A7-43EB-B198-DD3906DCFDBF}.Debug|Win32.Build.0 = Debug|Win32
{EF60D11E-36A7-43EB-B198-DD3906DCFDBF}.Release|Win32.ActiveCfg = Release|Win32
{EF60D11E-36A7-43EB-B198-DD3906DCFDBF}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -270,6 +270,10 @@
RelativePath=".\GroupInstance.cpp"
>
</File>
<File
RelativePath=".\GuiRoot.cpp"
>
</File>
<File
RelativePath=".\IEBrowser.cpp"
>
@@ -306,6 +310,10 @@
RelativePath=".\PropertyWindow.cpp"
>
</File>
<File
RelativePath=".\StringFunctions.cpp"
>
</File>
<File
RelativePath=".\WindowFunctions.cpp"
>
@@ -419,6 +427,10 @@
RelativePath=".\Globals.h"
>
</File>
<File
RelativePath=".\GuiRoot.h"
>
</File>
<File
RelativePath=".\IEBrowser.h"
>

View File

@@ -1,3 +1,4 @@
#pragma once
#include "ButtonListener.h"
class GUDButtonListener : public ButtonListener {

View File

@@ -17,8 +17,8 @@ bool running = false;
G3D::TextureRef Globals::surface;
POINT Globals::mousepoint;
GFontRef fntdominant = NULL;
GFontRef fntlighttrek = NULL;
GFontRef g_fntdominant = NULL;
GFontRef g_fntlighttrek = NULL;
Globals::Globals(void){}

View File

@@ -28,8 +28,8 @@ extern bool running;
extern DataModelInstance* g_dataModel;
extern Application* g_usableApp;
extern GFontRef fntdominant;
extern GFontRef fntlighttrek;
extern GFontRef g_fntdominant;
extern GFontRef g_fntlighttrek;
extern std::string cameraSound;
extern std::string clickSound;

485
GuiRoot.cpp Normal file
View File

@@ -0,0 +1,485 @@
#include <iomanip>
#include <sstream>
#include "G3DAll.h"
#include "BaseButtonInstance.h"
#include "TextButtonInstance.h"
#include "ImageButtonInstance.h"
#include "GuiRoot.h"
#include "Globals.h"
#include "StringFunctions.h"
#include "GUDButtonListener.h"
#include "ModeSelectionListener.h"
#include "RotateButtonListener.h"
#include "CameraButtonListener.h"
#include "DeleteListener.h"
#include "ImageButtonInstance.h"
ImageButtonInstance* GuiRoot::makeImageButton(G3D::TextureRef newImage = NULL, G3D::TextureRef overImage = NULL, G3D::TextureRef downImage = NULL, G3D::TextureRef disableImage = NULL)
{
ImageButtonInstance* part = new ImageButtonInstance(newImage,overImage, downImage, disableImage);
// instances.push_back(part);
// instances_2D.push_back(part);
return part;
}
TextButtonInstance* GuiRoot::makeTextButton()
{
TextButtonInstance* part = new TextButtonInstance();
return part;
}
GuiRoot::GuiRoot() : _message(""), _messageTime(0)
{
g_fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt"));
g_fntlighttrek = GFont::fromFile(GetFileInPath("/content/font/lighttrek.fnt"));
TextButtonInstance* button = makeTextButton();
button->boxBegin = Vector2(0, -24);
button->boxEnd = Vector2(80, 0);
button->floatBottom = true;
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3(0,255,255);
button->textOutlineColor = Color4::clear();
button->title = "Hopper";
button->fontLocationRelativeTo = Vector2(10, 3);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(0, -48);
button->boxEnd = Vector2(80, -24);
button->floatBottom = true;
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3(0,255,255);
button->textOutlineColor = Color4::clear();
button->title = "Controller";
button->fontLocationRelativeTo = Vector2(10, 3);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(0, -72);
button->boxEnd = Vector2(80, -48);
button->floatBottom = true;
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3(0,255,255);
button->textOutlineColor = Color4::clear();
button->title = "Color";
button->fontLocationRelativeTo = Vector2(10, 3);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(0, -96);
button->boxEnd = Vector2(80, -72);
button->floatBottom = true;
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3(0,255,255);
button->textOutlineColor = Color4::clear();
button->title = "Surface";
button->fontLocationRelativeTo = Vector2(10, 3);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(0, -120);
button->boxEnd = Vector2(80, -96);
button->floatBottom = true;
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3(0,255,255);
button->boxOutlineColor = Color3(0,255,255);
button->title = "Model";
button->fontLocationRelativeTo = Vector2(10, 3);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(0, 0);
button->boxEnd = Vector2(125, 25);
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->title = "File";
button->textSize = 16;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(125, 0);
button->boxEnd = Vector2(250, 25);
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->title = "Edit";
button->textSize = 16;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(250, 0);
button->boxEnd = Vector2(375, 25);
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->title = "View";
button->textSize = 16;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(375, 0);
button->boxEnd = Vector2(500, 25);
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->title = "Insert";
button->textSize = 16;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(500, 0);
button->boxEnd = Vector2(625, 25);
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->title = "Format";
button->textSize = 16;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button = makeTextButton();
button->boxBegin = Vector2(0,215);
button->boxEnd = Vector2(80,235);
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textSize = 12;
button->title = "Group";
button->name = "Group";
button->setAllColorsSame();
button->textColorDis = Color3(0.8F,0.8F,0.8F);
button->font = g_fntlighttrek;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setParent(this);
button = makeTextButton();
button->boxBegin = Vector2(0,240);
button->boxEnd = Vector2(80,260);
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textSize = 12;
button->title = "UnGroup";
button->name = "UnGroup";
button->setAllColorsSame();
button->textColorDis = Color3(0.8F,0.8F,0.8F);
button->font = g_fntlighttrek;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setParent(this);
button = makeTextButton();
button->boxBegin = Vector2(0,265);
button->boxEnd = Vector2(80,285);
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textSize = 12;
button->title = "Duplicate";
button->setAllColorsSame();
button->textColorDis = Color3(0.8F,0.8F,0.8F);
button->font = g_fntlighttrek;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setParent(this);
button->name = "Duplicate";
button->setButtonListener(new GUDButtonListener());
ImageButtonInstance* instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/Run.png")),
Texture::fromFile(GetFileInPath("/content/images/Run_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/Run_dn.png")));
instance->name = "go";
instance->size = Vector2(65,65);
instance->position = Vector2(6.5, 25);
instance->setParent(this);
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/ArrowTool.png")),
Texture::fromFile(GetFileInPath("/content/images/ArrowTool_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/ArrowTool_dn.png")),
Texture::fromFile(GetFileInPath("/content/images/ArrowTool_ds.png")));
instance->size = Vector2(50,50);
instance->position = Vector2(15, 90);
instance->setParent(this);
instance->name = "Cursor";
instance->setButtonListener(new ModeSelectionListener());
instance = makeImageButton(Texture::fromFile(GetFileInPath("/content/images/ScaleTool.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ovr.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_dn.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ds.png")));
instance->size = Vector2(40,40);
instance->position = Vector2(0, 140);
instance->setParent(this);
instance->name = "Resize";
instance->setButtonListener(new ModeSelectionListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/MoveTool.png")),
Texture::fromFile(GetFileInPath("/content/images/MoveTool_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/MoveTool_dn.png")),
Texture::fromFile(GetFileInPath("/content/images/MoveTool_ds.png")));
instance->size = Vector2(40,40);
instance->position = Vector2(40, 140);
instance->setParent(this);
instance->name = "Arrows";
instance->setButtonListener(new ModeSelectionListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate.png")),
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate_ovr.png")),
NULL,
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate_ds.png")));
instance->size = Vector2(30,30);
instance->position = Vector2(10, 175);
instance->setParent(this);
instance->name = "Rotate";
instance->setButtonListener(new RotateButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt.png")),
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt_ovr.png")),
NULL,
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt_ds.png")));
instance->size = Vector2(30,30);
instance->position = Vector2(40, 175);
instance->setParent(this);
instance->name = "Tilt";
instance->setButtonListener(new RotateButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/Delete.png")),
Texture::fromFile(GetFileInPath("/content/images/Delete_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/Delete_dn.png")),
Texture::fromFile(GetFileInPath("/content/images/Delete_ds.png")));
instance->size = Vector2(40,46);
instance->position = Vector2(20, 284);
instance->setParent(this);
instance->name = "Delete";
instance->setButtonListener(new DeleteListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraZoomIn.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraZoomIn_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraZoomIn_dn.png")));
instance->size = Vector2(34,25);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-77, -90);
instance->setParent(this);
instance->name = "ZoomIn";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraZoomOut.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraZoomOut_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraZoomOut_dn.png")));
instance->size = Vector2(34,26);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-77, -31);
instance->setParent(this);
instance->name = "ZoomOut";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraPanLeft.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraPanLeft_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraPanLeft_dn.png")));
instance->size = Vector2(34,34);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-110, -50);
instance->setParent(this);
instance->name = "PanLeft";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraPanRight.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraPanRight_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraPanRight_dn.png")));
instance->size = Vector2(34,34);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-45, -50);
instance->setParent(this);
instance->name = "PanRight";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraCenter.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraCenter_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraCenter_dn.png")));
instance->size = Vector2(34,20);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-77, -60);
instance->setParent(this);
instance->name = "CenterCam";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraTiltUp.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraTiltUp_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraTiltUp_dn.png")));
instance->size = Vector2(24,24);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-105, -75);
instance->setParent(this);
instance->name = "TiltUp";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraTiltDown.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraTiltDown_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraTiltDown_dn.png")));
instance->size = Vector2(24,24);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-40, -75);
instance->setParent(this);
instance->name = "TiltDown";
instance->setButtonListener(new CameraButtonListener());
}
void GuiRoot::drawButtons(RenderDevice* rd)
{
rd->pushState();
rd->beforePrimitive();
this->render(rd);
rd->afterPrimitive();
rd->popState();
}
void GuiRoot::setDebugMessage(std::string msg, G3D::RealTime msgTime)
{
_messageTime = msgTime;
_message = msg;
}
//void GuiRoot::render(G3D::RenderDevice* renderDevice) {}
void GuiRoot::renderGUI(G3D::RenderDevice* rd)
{
//TODO--Move these to their own instance
std::stringstream stream;
stream << std::fixed << std::setprecision(1) << g_dataModel->getLevel()->timer;
g_fntdominant->draw2D(rd, "Timer: " + stream.str(), Vector2(rd->getWidth() - 120, 25), 20, Color3::fromARGB(0x81C518), Color3::black());
g_fntdominant->draw2D(rd, "Score: " + Convert(g_dataModel->getLevel()->score), Vector2(rd->getWidth() - 120, 50), 20, Color3::fromARGB(0x81C518), Color3::black());
//GUI Boxes
Draw::box(G3D::Box(Vector3(0,25,0),Vector3(80,355,0)),rd,Color4(0.6F,0.6F,0.6F,0.4F), Color4(0,0,0,0));
Draw::box(G3D::Box(Vector3(rd->getWidth() - 120,rd->getHeight() - 120,0),Vector3(rd->getWidth(),rd->getHeight(),0)),rd,Color4(0.6F,0.6F,0.6F,0.4F), Color4(0,0,0,0));
//Camera menu title
g_fntlighttrek->draw2D(rd, "CameraMenu", Vector2(rd->getWidth()-(g_fntlighttrek->get2DStringBounds("CameraMenu", 14).x+1),rd->getHeight() - 120), 14, Color3::white(), Color4(0.5F,0.5F,0.5F,0.5F));
//Tools menu
Draw::box(G3D::Box(Vector3(5, 210,0),Vector3(75, 210,0)),rd,Color4(0.6F,0.6F,0.6F,0.4F), Color4(0.6F,0.6F,0.6F,0.4F));
g_fntlighttrek->draw2D(rd,"MENU", Vector2(10,332), 14, Color3::white(), Color4(0.5F,0.5F,0.5F,0.5F));
drawButtons(rd);
if(System::time() - 3 < _messageTime)
{
g_fntdominant->draw2D(rd, _message, Vector2((rd->getWidth()/2)-(g_fntdominant->get2DStringBounds(_message, 20).x/2),(rd->getHeight()/2)-(g_fntdominant->get2DStringBounds(_message, 20).y/2)), 20, Color3::yellow(), Color3::black());
}
g_dataModel->drawMessage(rd);
render(rd);
}
bool GuiRoot::mouseInGUI(G3D::RenderDevice* renderDevice,int x,int y)
{
std::vector<Instance*> instances_2D = g_dataModel->getGuiRoot()->getAllChildren();
for(size_t i = 0; i < instances_2D.size(); i++)
{
if(BaseButtonInstance* button = dynamic_cast<BaseButtonInstance*>(instances_2D.at(i)))
{
if(button->mouseInButton(x,y, renderDevice))
{
return true;
}
}
}
return false;
}
void GuiRoot::update()
{
Instance * obj6 = this->findFirstChild("Delete");
Instance * obj = this->findFirstChild("Duplicate");
Instance * obj2 = this->findFirstChild("Group");
Instance * obj3 = this->findFirstChild("UnGroup");
Instance * obj4 = this->findFirstChild("Rotate");
Instance * obj5 = this->findFirstChild("Tilt");
if(obj != NULL && obj2 != NULL && obj3 != NULL && obj4 !=NULL && obj5 != NULL && obj6 != NULL)
{
BaseButtonInstance* button = (BaseButtonInstance*)obj;
BaseButtonInstance* button2 = (BaseButtonInstance*)obj2;
BaseButtonInstance* button3 = (BaseButtonInstance*)obj3;
BaseButtonInstance* button4 = (BaseButtonInstance*)obj4;
BaseButtonInstance* button5 = (BaseButtonInstance*)obj5;
BaseButtonInstance* button6 = (BaseButtonInstance*)obj6;
button->disabled = true;
button2->disabled = true;
button3->disabled = true;
button4->disabled = true;
button5->disabled = true;
button6->disabled = true;
for(size_t i = 0; i < g_selectedInstances.size(); i++)
if(g_selectedInstances.at(i)->canDelete)
{
button->disabled = false;
button2->disabled = false;
button3->disabled = false;
button4->disabled = false;
button5->disabled = false;
button6->disabled = false;
break;
}
}
}
void GuiRoot::onMouseLeftUp(G3D::RenderDevice* renderDevice, int x,int y)
{
std::vector<Instance*> instances_2D = this->getAllChildren();
for(size_t i = 0; i < instances_2D.size(); i++)
{
if(BaseButtonInstance* button = dynamic_cast<BaseButtonInstance*>(instances_2D[i]))
{
if(button->mouseInButton(x, y, renderDevice))
{
button->onMouseClick();
}
}
}
}

23
GuiRoot.h Normal file
View File

@@ -0,0 +1,23 @@
#pragma once
#include "Instance.h"
class ImageButtonInstance;
class TextButtonInstance;
class GuiRoot : public Instance
{
public:
GuiRoot();
TextButtonInstance* makeTextButton();
void drawButtons(RenderDevice* rd);
ImageButtonInstance* makeImageButton(G3D::TextureRef newImage, G3D::TextureRef overImage, G3D::TextureRef downImage, G3D::TextureRef disableImage);
void renderGUI(G3D::RenderDevice* rd);
void setDebugMessage(std::string msg, G3D::RealTime msgTime);
void update();
bool mouseInGUI(G3D::RenderDevice* renderDevice,int x,int y);
void onMouseLeftUp(G3D::RenderDevice* renderDevice, int x,int y);
private:
std::string _message;
G3D::RealTime _messageTime;
};

View File

@@ -39,7 +39,9 @@ void Instance::render(RenderDevice* rd)
glDisableClientState(GL_NORMAL_ARRAY);
}
void Instance::update()
{
}
PROPGRIDITEM Instance::createPGI(LPSTR catalog, LPSTR propName, LPSTR propDesc, LPARAM curVal, INT type)
{

View File

@@ -11,6 +11,7 @@ public:
virtual ~Instance(void);
std::string name;
virtual void render(RenderDevice*);
virtual void update();
std::vector<Instance*> children; // All children.
std::string getClassName();
Instance* findFirstChild(std::string);

View File

@@ -20,9 +20,9 @@ void ModeSelectionListener::onButton1MouseClick(BaseButtonInstance* button)
button->selected = true;
if(button->name == "Cursor")
mode = CURSOR;
g_usableApp->setMode(CURSOR);
else if(button->name == "Resize")
mode = RESIZE;
g_usableApp->setMode(RESIZE);
else if(button->name == "Arrows")
mode = ARROWS;
g_usableApp->setMode(ARROWS);
}

View File

@@ -1,3 +1,4 @@
#pragma once
#include "ButtonListener.h"
#define CURSOR 0

View File

@@ -5,6 +5,7 @@
#include "PropertyWindow.h"
#include "Globals.h"
#include "strsafe.h"
#include "Application.h"
/*typedef struct typPRGP {
Instance* instance; // Declare member types
@@ -177,7 +178,7 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
CHAR ListItem[256];
SendMessage((HWND) lParam, (UINT) CB_GETLBTEXT, (WPARAM) ItemIndex, (LPARAM) ListItem);
propWind->ClearProperties();
propWind->UpdateSelected(children.at(ItemIndex));
g_usableApp->selectInstance(children.at(ItemIndex),propWind);
}
}
break;
@@ -212,7 +213,7 @@ void PropertyWindow::refreshExplorer(Instance* selectedInstance)
SendMessage(_explorerComboBox,CB_RESETCONTENT,0,0);
parent = NULL;
children.clear();
g_selectedInstances.clear();
//g_selectedInstances.clear();
//for (unsigned int i=0;i<g_selectedInstances.size();i++) {
children.push_back(selectedInstance);
SendMessage(_explorerComboBox, CB_ADDSTRING, 0, (LPARAM)selectedInstance->name.c_str());
@@ -233,7 +234,7 @@ void PropertyWindow::refreshExplorer(Instance* selectedInstance)
children.push_back(selectedChildren.at(z));
SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)selectedChildren.at(z)->name.c_str());
}
g_selectedInstances.push_back(selectedInstance);
//g_usableApp->selectInstance(selectedInstance, this);
SendMessage(_explorerComboBox,CB_SETCURSEL,0,(LPARAM)0);
//}
}
@@ -346,20 +347,23 @@ void PropertyWindow::UpdateSelected(Instance * instance)
{
PropGrid_ResetContent(_propGrid);
prop = instance->getProperties();
selectedInstance = instance;
for(size_t i = 0; i < prop.size(); i++)
if (selectedInstance != instance)
{
::PROPGRIDITEM item = prop.at(i);
PropGrid_AddItem(_propGrid, &item);
//PRGP propgp;
//propgp.instance = instance;
//propgp.prop = prop.at(i);
}
PropGrid_ExpandAllCatalogs(_propGrid);
//SetWindowLongPtr(_propGrid,GWL_USERDATA,(LONG)this);
selectedInstance = instance;
for(size_t i = 0; i < prop.size(); i++)
{
::PROPGRIDITEM item = prop.at(i);
PropGrid_AddItem(_propGrid, &item);
//PRGP propgp;
//propgp.instance = instance;
//propgp.prop = prop.at(i);
}
PropGrid_ExpandAllCatalogs(_propGrid);
//SetWindowLongPtr(_propGrid,GWL_USERDATA,(LONG)this);
refreshExplorer(instance);
_resize();
refreshExplorer(instance);
_resize();
}
}
void PropertyWindow::ClearProperties()

View File

@@ -1,5 +1,6 @@
#pragma once
#include "Instance.h"
class PropertyWindow {
public:
PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstance);

View File

@@ -1,3 +1,4 @@
#include "BaseButtonInstance.h"
#include "RotateButtonListener.h"
#include "Globals.h"
#include "AudioPlayer.h"

View File

@@ -1,3 +1,4 @@
#pragma once
#include "ButtonListener.h"
class RotateButtonListener : public ButtonListener {

34
StringFunctions.cpp Normal file
View File

@@ -0,0 +1,34 @@
#include <G3DAll.h>
#include <sstream>
#include "ErrorFunctions.h"
#include "StringFunctions.h"
#include <windows.h>
std::string Convert (float number)
{
std::ostringstream buff;
buff<<number;
return buff.str();
}
std::string ExePath() {
char buffer[MAX_PATH];
GetModuleFileName( NULL, buffer, MAX_PATH );
std::string::size_type pos = std::string( buffer ).find_last_of( "\\/" );
return std::string( buffer ).substr( 0, pos);
}
std::string GetFileInPath(std::string file)
{
std::string name = ExePath() + file;
struct stat buf;
if (stat(name.c_str(), &buf) != -1)
{
return name;
}
else
OnError(202, " \r\nFile not found: " + name);
return NULL;
}

View File

@@ -1,31 +1,6 @@
#pragma once
#include <string>
#include <sstream>
#include "ErrorFunctions.h"
std::string Convert (float number){
std::ostringstream buff;
buff<<number;
return buff.str();
}
std::string ExePath() {
char buffer[MAX_PATH];
GetModuleFileName( NULL, buffer, MAX_PATH );
std::string::size_type pos = std::string( buffer ).find_last_of( "\\/" );
return std::string( buffer ).substr( 0, pos);
}
std::string GetFileInPath(std::string file)
{
std::string name = ExePath() + file;
struct stat buf;
if (stat(name.c_str(), &buf) != -1)
{
return name;
}
else
OnError(202, " \r\nFile not found: " + name);
return NULL;
}
std::string Convert (float number);
std::string ExePath();
std::string GetFileInPath(std::string file);

View File

@@ -121,7 +121,7 @@ LRESULT CALLBACK G3DProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
app->onMouseLeftPressed(hwnd,LOWORD(lParam),HIWORD(lParam));
break;
case WM_LBUTTONUP:
app->onMouseLeftUp(LOWORD(lParam),HIWORD(lParam));
app->onMouseLeftUp(app->getRenderDevice(),LOWORD(lParam),HIWORD(lParam));
break;
case WM_RBUTTONDOWN:
app->onMouseRightPressed(LOWORD(lParam),HIWORD(lParam));
@@ -155,7 +155,7 @@ LRESULT CALLBACK G3DProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
case WM_SIZE:
{
app->onGraphics(app->renderDevice);
app->onGraphics(app->getRenderDevice());
}
break;
default: