From d2e0b29051809639af36a3acee57e546fc153e98 Mon Sep 17 00:00:00 2001 From: andreja6 Date: Wed, 24 Oct 2018 20:34:14 -0700 Subject: [PATCH] Changed icon --- DataModelInstance.cpp | 60 +++++++++++++++++++++++++++++++++ DataModelInstance.h | 7 ++++ WorkspaceInstance.cpp | 6 ++-- WorkspaceInstance.h | 2 -- content/images/ArrowCursor.png | Bin 0 -> 2065 bytes main.cpp | 44 +++++++++++++++++------- 6 files changed, 101 insertions(+), 18 deletions(-) create mode 100644 content/images/ArrowCursor.png diff --git a/DataModelInstance.cpp b/DataModelInstance.cpp index 8d8ba72..087dd23 100644 --- a/DataModelInstance.cpp +++ b/DataModelInstance.cpp @@ -16,6 +16,10 @@ DataModelInstance::DataModelInstance(void) mouseButton1Down = false; showMessage = false; canDelete = false; + winMessage = "You Won!"; + loseMessage = "You Lost. Try Again"; + timer = 60.0F; + score = 0; } DataModelInstance::~DataModelInstance(void) @@ -69,3 +73,59 @@ Instance* DataModelInstance::getGuiRoot() { return guiRoot; } + +char timerTxt[12]; +char scoreTxt[12]; +std::vector DataModelInstance::getProperties() +{ + std::vector properties = Instance::getProperties(); + + + + properties.push_back(createPGI("Messages", + "WinMessage", + "The message that shows when the player wins.", + (LPARAM)winMessage.c_str(), + PIT_EDIT)); + properties.push_back(createPGI("Messages", + "LoseMessage", + "The message that shows when the player loses.", + (LPARAM)loseMessage.c_str(), + PIT_EDIT)); + + + sprintf(timerTxt, "%g", timer); + sprintf(scoreTxt, "%d", score); + properties.push_back(createPGI("Gameplay", + "InitialTimerValue", + "The ammount of time in seconds the player has to complete this level.\r\n\r\nPut 0 if time is limitless.", + (LPARAM)timerTxt, + PIT_EDIT)); + properties.push_back(createPGI("Gameplay", + "InitialScoreValue", + "The ammount of points the player starts with.", + (LPARAM)scoreTxt, + PIT_EDIT)); + return properties; +} +void DataModelInstance::PropUpdate(LPPROPGRIDITEM &pItem) +{ + if(strcmp(pItem->lpszPropName, "InitialTimerValue") == 0) + { + timer = atoi((LPSTR)pItem->lpCurValue); + } + if(strcmp(pItem->lpszPropName, "InitialScoreValue") == 0) + { + score = atof((LPSTR)pItem->lpCurValue); + } + if(strcmp(pItem->lpszPropName, "LoseMessage") == 0) + { + loseMessage = (LPSTR)pItem->lpCurValue; + } + if(strcmp(pItem->lpszPropName, "WinMessage") == 0) + { + winMessage = (LPSTR)pItem->lpCurValue; + } + else + Instance::PropUpdate(pItem); +} \ No newline at end of file diff --git a/DataModelInstance.h b/DataModelInstance.h index ac614d4..879f732 100644 --- a/DataModelInstance.h +++ b/DataModelInstance.h @@ -24,4 +24,11 @@ public: void setMousePos(int x,int y); void setMousePos(Vector2 pos); bool mouseButton1Down; + + float timer; + int score; + virtual std::vector getProperties(); + std::string winMessage; + std::string loseMessage; + virtual void PropUpdate(LPPROPGRIDITEM &pItem); }; diff --git a/WorkspaceInstance.cpp b/WorkspaceInstance.cpp index 8c62729..47fceec 100644 --- a/WorkspaceInstance.cpp +++ b/WorkspaceInstance.cpp @@ -4,10 +4,8 @@ WorkspaceInstance::WorkspaceInstance(void) { GroupInstance::GroupInstance(); - name = "Instance"; - className = "Level"; - timer = 60.0F; - score = 0; + name = "Workspace"; + className = "Workspace"; canDelete = false; } diff --git a/WorkspaceInstance.h b/WorkspaceInstance.h index 1dc0517..9ca7899 100644 --- a/WorkspaceInstance.h +++ b/WorkspaceInstance.h @@ -5,8 +5,6 @@ class WorkspaceInstance : public GroupInstance { public: - float timer; - int score; WorkspaceInstance(void); ~WorkspaceInstance(void); }; diff --git a/content/images/ArrowCursor.png b/content/images/ArrowCursor.png new file mode 100644 index 0000000000000000000000000000000000000000..85c463983a935de602927cec0f490c630091476c GIT binary patch literal 2065 zcmb7F_g4~%A4LU8d61Q>Ov91p1_48`oG2<7jt1ty)Wi~#a8(*A4M);LUy8F{D&^ii z%_Pm$%l90)%G{cxoN2l1%li|)_niB==iGDdFQ0Qi=MztHw1r9^kp=(&P&=Zvvq&lb zai64Uau0kf5s6+1;X;VjbwBTrfNM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eA!@8%+=eVqLz>euw`{V;;OMyqbUp)0TXDoXj{=r=NIX) zj|GSG=gSRO84N}xy+=)3N9TIy-&OuysSarde~T7m8aHfG8&tuc8hL!Fm`vh?%{T-D zp_Z!mQc_7&Bsu1p9JkU_{Gz$pLq?`C!+GCg$YnJA)b;7OQjhup@~jh5b58=H{@x35 zG{S*o3p<_gJ;p1V69F*9+qL#$~QQxm>kwIC#2%*q8}C<0RY4%Rq+oRF$V zRXZVZ{l^0Jj0my(3Ed4{4>48D05Fe|HMY0!HZ14St>x33ICW&wp)X5IOBxvqt%(Zw zfA82RJ(JZoFpyumD3h;(P6MKIBaxiJAY{8RuI$V)V>*5*JgB{sEYV3<_FXF|EPT(J z?HmbP$n7_Y+$=BkdhN-Z3}X06ji;M@_B^JNbbxrLviFJNU~6Bs8XfbjstN^b`_vpI zoe}pW5#Pg4Ntr5!(AYq67PZx^ua^dka3*cl>gVU4ZKPOKq;rS6_3y-`D=RBAv!p5| zD+?&rMkrM80bZ=7bxr|Qp$_MF|Fwpuj;&T^G%)vtE_}x5aaY>V=%_(C))6}0-9&J6 z%TS*ju491)BPjTJvybjG@mp3QphWCP1auhm6MDtMBF5O*SO>T_hJ64j^l9e?5D0`7 z%LH=Kxl6&}2c_L1=r=C^B*^Jj=jXQ`ZX9KtxV5{<6kR;j(}r2p&hUKaYd=9lB+ng4 zPu^;1Xz)bKX+1L0^wIyVt+6p01)HkNtRhB-^3*F*iEJJ*_Q$=4>|ixiTLC6qzxw3T zyFYqn-IUM@1Rw7sti!*u`Glx%oL}1?0I1*V4dR>S q<`0=zq$Rw3C}ir(uw3|3_t^kLt~x+Zmf0!#!2mmgqjjkzE%tx=TfQLx literal 0 HcmV?d00001 diff --git a/main.cpp b/main.cpp index c808215..18389da 100644 --- a/main.cpp +++ b/main.cpp @@ -68,7 +68,10 @@ static std::string cameraSound = ""; static std::string clickSound = ""; static std::string dingSound = ""; static int cursorid = 0; +static int cursorOvrid = 0; +static int currentcursorid = 0; static G3D::TextureRef cursor = NULL; +static G3D::TextureRef cursorOvr = NULL; static bool running = true; static bool mouseMovedBeginMotion = false; static const int CURSOR = 0; @@ -1234,9 +1237,9 @@ void Demo::onGraphics(RenderDevice* rd) { //TODO--Move these to their own instance std::stringstream stream; - stream << std::fixed << std::setprecision(1) << dataModel->getWorkspace()->timer; + stream << std::fixed << std::setprecision(1) << dataModel->timer; fntdominant->draw2D(rd, "Timer: " + stream.str(), Vector2(rd->getWidth() - 120, 25), 20, Color3::fromARGB(0x81C518), Color3::black()); - fntdominant->draw2D(rd, "Score: " + Convert(dataModel->getWorkspace()->score), Vector2(rd->getWidth() - 120, 50), 20, Color3::fromARGB(0x81C518), Color3::black()); + fntdominant->draw2D(rd, "Score: " + Convert(dataModel->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)); @@ -1262,19 +1265,34 @@ void Demo::onGraphics(RenderDevice* rd) { glEnable(GL_BLEND);// you enable blending function glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + std::vector instances = dataModel->getWorkspace()->getAllChildren(); + for(size_t i = 0; i < instances.size(); i++) + { + if(PartInstance* test = dynamic_cast(instances.at(i))) + { + float time = cameraController.getCamera()->worldRay(dataModel->mousex, dataModel->mousey, renderDevice->getViewport()).intersectionTime(test->getBox()); + //float time = testRay.intersectionTime(test->getBox()); + if (time != inf()) + { + currentcursorid = cursorOvrid; + break; + } + else currentcursorid = cursorid; + } + } - glBindTexture( GL_TEXTURE_2D, cursorid); + glBindTexture( GL_TEXTURE_2D, currentcursorid); glBegin( GL_QUADS ); glTexCoord2d(0.0,0.0); - glVertex2f(mousepos.x-40, mousepos.y-40); + glVertex2f(mousepos.x-64, mousepos.y-64); glTexCoord2d( 1.0,0.0 ); - glVertex2f(mousepos.x+40, mousepos.y-40); + glVertex2f(mousepos.x+64, mousepos.y-64); glTexCoord2d(1.0,1.0 ); - glVertex2f(mousepos.x+40, mousepos.y+40 ); + glVertex2f(mousepos.x+64, mousepos.y+64 ); glTexCoord2d( 0.0,1.0 ); - glVertex2f( mousepos.x-40, mousepos.y+40 ); + glVertex2f( mousepos.x-64, mousepos.y+64 ); glEnd(); glDisable( GL_TEXTURE_2D ); @@ -1367,8 +1385,8 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y) { while(g_selectedInstances.size() > 0) g_selectedInstances.erase(g_selectedInstances.begin()); - g_selectedInstances.push_back(dataModel->getWorkspace()); - _propWindow->SetProperties(dataModel->getWorkspace()); + g_selectedInstances.push_back(dataModel); + _propWindow->SetProperties(dataModel); } } @@ -1381,7 +1399,7 @@ void Demo::onMouseLeftUp(int x,int y) //message = "Dragging = false."; //messageTime = System::time(); std::vector instances_2D = dataModel->getGuiRoot()->getAllChildren(); - std::vector instances = dataModel->getWorkspace()->getAllChildren(); + //std::vector instances = dataModel->getWorkspace()->getAllChildren(); for(size_t i = 0; i < instances_2D.size(); i++) { if(BaseButtonInstance* button = dynamic_cast(instances_2D[i])) @@ -1582,7 +1600,8 @@ void Demo::run() { UpdateWindow(_hWndMain); // Load objects here= - cursor = Texture::fromFile(GetFileInPath("/content/cursor2.png")); + 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(); fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt")); @@ -1592,7 +1611,8 @@ void Demo::run() { 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;