diff --git a/G3DTest.suo b/G3DTest.suo index e4a1d0d..8a37237 100644 Binary files a/G3DTest.suo and b/G3DTest.suo differ diff --git a/G3DTest.vcproj b/G3DTest.vcproj index f73501d..aeacc36 100644 --- a/G3DTest.vcproj +++ b/G3DTest.vcproj @@ -234,6 +234,10 @@ RelativePath=".\Dialogs.rc" > + + @@ -271,6 +275,10 @@ Name="Header Files" Filter="h;hpp;hxx;hm;inl" > + + diff --git a/ImageButtonInstance.cpp b/ImageButtonInstance.cpp new file mode 100644 index 0000000..8b16f19 --- /dev/null +++ b/ImageButtonInstance.cpp @@ -0,0 +1,21 @@ +#include "ImageButtonInstance.h" +G3D::TextureRef image = NULL; +int openGLID = 0; +G3D::TextureRef image_ovr = NULL; +int openGLID_ovr = 0; +G3D::TextureRef image_dn = NULL; +int openGLID_dn = 0; +ImageButtonInstance::ImageButtonInstance(G3D::TextureRef newImage = NULL, G3D::TextureRef overImage = NULL, G3D::TextureRef downImage = NULL) +{ + + image = newImage; + openGLID = image->getOpenGLID(); + image_ovr = overImage; + openGLID_ovr = image_ovr->getOpenGLID(); + image_dn = downImage; + openGLID_dn = image_dn->getOpenGLID(); +} + +ImageButtonInstance::~ImageButtonInstance(void) +{ +} diff --git a/ImageButtonInstance.h b/ImageButtonInstance.h new file mode 100644 index 0000000..139b2b3 --- /dev/null +++ b/ImageButtonInstance.h @@ -0,0 +1,10 @@ +#pragma once +#include "instance.h" + +class ImageButtonInstance : + public Instance +{ +public: + ImageButtonInstance(G3D::TextureRef,G3D::TextureRef,G3D::TextureRef); + ~ImageButtonInstance(void); +}; diff --git a/TextButtonInstance.cpp b/TextButtonInstance.cpp index b388b17..033429a 100644 --- a/TextButtonInstance.cpp +++ b/TextButtonInstance.cpp @@ -20,6 +20,7 @@ G3D::GFontRef* font; int textSize; bool floatBottom; bool floatRight; +bool floatCenter; bool visible; TextButtonInstance::TextButtonInstance(void) @@ -36,10 +37,12 @@ TextButtonInstance::TextButtonInstance(void) textSize = 12; floatBottom = false; floatRight = false; + floatCenter = false; visible = true; + className = "TextButtonInstance"; } TextButtonInstance::~TextButtonInstance(void) { -} +} \ No newline at end of file diff --git a/TextButtonInstance.h b/TextButtonInstance.h index 1ac5ed1..acdc068 100644 --- a/TextButtonInstance.h +++ b/TextButtonInstance.h @@ -28,5 +28,6 @@ public: bool floatBottom; bool floatRight; bool visible; + int textSize; }; diff --git a/main.cpp b/main.cpp index 033b35c..44d49da 100644 --- a/main.cpp +++ b/main.cpp @@ -120,17 +120,81 @@ TextButtonInstance* makeTextButton() return part; } + +void initGUI() +{ + TextButtonInstance* button = makeTextButton(); + button->boxBegin = Vector2(0, -24); + button->boxEnd = Vector2(80, 0); + button->floatBottom = true; + button->parent = dataModel; + button->font = fntlighttrek; + button->textColor = Color3(0,255,255); + button->textOutlineColor = Color4::clear(); + button->title = "Hopper"; + button->fontLocationRelativeTo = Vector2(10, 5); + + button = makeTextButton(); + button->boxBegin = Vector2(0, -48); + button->boxEnd = Vector2(80, -24); + button->floatBottom = true; + button->parent = dataModel; + button->font = fntlighttrek; + button->textColor = Color3(0,255,255); + button->textOutlineColor = Color4::clear(); + button->title = "Controller"; + button->fontLocationRelativeTo = Vector2(10, 5); + + button = makeTextButton(); + button->boxBegin = Vector2(0, -72); + button->boxEnd = Vector2(80, -48); + button->floatBottom = true; + button->parent = dataModel; + button->font = fntlighttrek; + button->textColor = Color3(0,255,255); + button->textOutlineColor = Color4::clear(); + button->title = "Color"; + button->fontLocationRelativeTo = Vector2(10, 5); + + button = makeTextButton(); + button->boxBegin = Vector2(0, -96); + button->boxEnd = Vector2(80, -72); + button->floatBottom = true; + button->parent = dataModel; + button->font = fntlighttrek; + button->textColor = Color3(0,255,255); + button->textOutlineColor = Color4::clear(); + button->title = "Surface"; + button->fontLocationRelativeTo = Vector2(10, 5); + + button = makeTextButton(); + button->boxBegin = Vector2(0, -120); + button->boxEnd = Vector2(80, -96); + button->floatBottom = true; + button->parent = dataModel; + button->font = fntlighttrek; + button->textColor = Color3(0,255,255); + button->textOutlineColor = Color4::clear(); + button->title = "Model"; + button->fontLocationRelativeTo = Vector2(10, 5); +} + void Demo::onInit() { // Called before Demo::run() beings + + dataModel = new Instance(); //dataModel->name = "undefined"; dataModel->parent = NULL; + initGUI(); + PhysicalInstance* test = makePart(); test->parent = dataModel; test->color = Color3(0.2F,0.3F,1); test->size = Vector3(24,1,24); + test = makePart(); @@ -208,7 +272,9 @@ void Demo::onInit() { + GApplet::onInit(); + } @@ -270,6 +336,7 @@ double getOSVersion() { } void Demo::onUserInput(UserInput* ui) { + if (ui->keyPressed(SDLK_ESCAPE)) { // Even when we aren't in debug mode, quit on escape. endApplet = true; @@ -393,6 +460,36 @@ bool mouseInArea(float point1x, float point1y, float point2x, float point2y) return false; } + +void drawButtons(RenderDevice* rd) +{ + for(size_t i = 0; i < instances_2D.size(); i++) + { + Instance* instance = instances_2D.at(i); + if(instance->className == "TextButtonInstance" && instance->parent == dataModel) + { + TextButtonInstance* tbi = (TextButtonInstance*)instance; + Vector3 point1; + Vector3 point2; + if(tbi->floatBottom) + { + point1 = Vector3(tbi->boxBegin.x, rd->getHeight() + tbi->boxBegin.y,0); + point2 = Vector3(tbi->boxEnd.x, rd->getHeight() + tbi->boxEnd.y,0); + + } + else + { + point1 = Vector3(tbi->boxBegin.x, tbi->boxBegin.y,0); + point2 = Vector3(tbi->boxEnd.x, tbi->boxEnd.y,0); + } + Draw::box(Box(point1, point2), rd, tbi->boxColor, tbi->boxOutlineColor); + Vector2 RelativeTo = Vector2(point1.x + tbi->fontLocationRelativeTo.x, point1.y + tbi->fontLocationRelativeTo.y); + tbi->font->draw2D(rd, tbi->title, RelativeTo, tbi->textSize, tbi->textColor, tbi->textOutlineColor); + + } + } +} + void Demo::onGraphics(RenderDevice* rd) { LightingParameters lighting(G3D::toSeconds(11, 00, 00, AM)); app->renderDevice->setProjectionAndCameraMatrix(app->debugCamera); @@ -412,7 +509,6 @@ void Demo::onGraphics(RenderDevice* rd) { app->renderDevice->setAmbientLightColor(Color3(1,1,1)); Draw::axes(CoordinateFrame(Vector3(0, 0, 0)), app->renderDevice); - Draw::sphere(G3D::Sphere(Vector3(0,0,0),3), rd, Color3::red(), Color4::clear()); //makeFlag(Vector3(1, 0.5, 0.5), rd); @@ -421,7 +517,6 @@ void Demo::onGraphics(RenderDevice* rd) { app->renderDevice->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor)); app->renderDevice->setAmbientLightColor(lighting.ambient); - //Draw::box(G3D::Box(Vector3(4.0/2,1.0/2,2.0/2),Vector3(0,0,0)), rd, Color3::gray(), Color4(0,0,0,0)); for(size_t i = 0; i < instances.size(); i++) { Instance* instance = instances.at(i); @@ -434,8 +529,7 @@ void Demo::onGraphics(RenderDevice* rd) { } } - //Draw::cylinder(G3D::Cylinder::Cylinder(Vector3(0,5,0),Vector3(0,10,0),1),app->renderDevice,Color4(0,0,1,0.5),Color4(0,0,0,0)); - + app->renderDevice->disableLighting(); @@ -460,14 +554,12 @@ void Demo::onGraphics(RenderDevice* rd) { fntdominant->draw2D(rd, "Timer: " + Convert(TIMERVAL), Vector2(rd->getWidth() - 120, 0+offset), 20, Color3::fromARGB(0x81C518), Color3::black()); fntdominant->draw2D(rd, "Score: " + Convert(SCOREVAL), Vector2(rd->getWidth() - 120, 25+offset), 20, Color3::fromARGB(0x81C518), Color3::black()); - //fntlighttrek->draw2D(rd, "Button: " + button, Vector2(10,30 + offset), 15, Color3::white(), Color3::black()); //GUI Boxes Draw::box(G3D::Box(Vector3(0,offset,0),Vector3(80,330+offset,0)),rd,Color4(0.6F,0.6F,0.6F,0.4F), Color4(0,0,0,0)); - Draw::box(G3D::Box(Vector3(0,rd->getHeight() - 120,0),Vector3(80,rd->getHeight(),0)),rd,Color4(0.6F,0.6F,0.6F,0.4F), Color4(0,0,0,0)); - + //Draw::box(G3D::Box(Vector3(0,rd->getHeight() - 120,0),Vector3(80,rd->getHeight(),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)); @@ -478,12 +570,13 @@ void Demo::onGraphics(RenderDevice* rd) { 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)); + /* fntlighttrek->draw2D(rd, "Model", Vector2(10,rd->getHeight() - (120 - spacing*0)), 12, Color3(0,255,255), Color4(0,0,0,0)); fntlighttrek->draw2D(rd, "Surface", Vector2(10,rd->getHeight() - (120 - spacing*1)), 12, Color3(0,255,255), Color4(0,0,0,0)); fntlighttrek->draw2D(rd, "Color", Vector2(10,rd->getHeight() - (120 - spacing*2)), 12, Color3(0,255,255), Color4(0,0,0,0)); fntlighttrek->draw2D(rd, "Controller", Vector2(10,rd->getHeight() - (120 - spacing*3)), 12, Color3(0,255,255), Color4(0,0,0,0)); fntlighttrek->draw2D(rd, "Hopper", Vector2(10,rd->getHeight() - (120 - spacing*4)), 12, Color3(0,255,255), Color4(0,0,0,0)); - + */ //Top menu fntlighttrek->draw2D(rd,"File", Vector2(10+0*sep,0), 16, Color3::white(), Color4(0.5F,0.5F,0.5F,0.5F)); @@ -561,6 +654,7 @@ void Demo::onGraphics(RenderDevice* rd) { rd->popState(); + drawButtons(rd); app->renderDevice->pop2D(); } @@ -605,9 +699,13 @@ int main(int argc, char** argv) { else settings.window.defaultIconFilename = GetFileInPath("/content/images/rico256c.png"); settings.window.resizable = true; - + settings.writeLicenseFile = false; + + //SDLWindow wind = SDLWindow(settings.window); App app = App(settings); //app.window()->setIcon(ExePath() + "/content/images/rico.png"); + messageTime = System::time(); + message = app.window()->getAPIName(); app.run(); return 0; } \ No newline at end of file