diff --git a/Blocks3D.vcproj b/Blocks3D.vcproj index e7315b6..9a11ef0 100644 --- a/Blocks3D.vcproj +++ b/Blocks3D.vcproj @@ -185,6 +185,7 @@ OutputFile="./Blocks3D-Debug.exe" LinkIncremental="2" SuppressStartupBanner="true" + AdditionalLibraryDirectories="" GenerateDebugInformation="true" ProgramDatabaseFile=".\Debug/Blocks3D.pdb" SubSystem="1" diff --git a/Parts.png b/Parts.png new file mode 100644 index 0000000..6a0cafe Binary files /dev/null and b/Parts.png differ diff --git a/content/sounds/clickfast.wav b/content/sounds/clickfast.wav new file mode 100644 index 0000000..08cbbf7 Binary files /dev/null and b/content/sounds/clickfast.wav differ diff --git a/content/sounds/flashbulb.wav b/content/sounds/flashbulb.wav new file mode 100644 index 0000000..5fa5536 Binary files /dev/null and b/content/sounds/flashbulb.wav differ diff --git a/src/include/DataModelV2/DataModelInstance.h b/src/include/DataModelV2/DataModelInstance.h index aceaf86..aba257d 100644 --- a/src/include/DataModelV2/DataModelInstance.h +++ b/src/include/DataModelV2/DataModelInstance.h @@ -27,7 +27,9 @@ public: void clearMessage(); bool debugGetOpen(); bool getOpen(); + bool getOpenModel(); bool load(const char* filename,bool clearObjects); + bool loadModel(const char* filename); bool readXMLFileStream(std::ifstream* file); void drawMessage(RenderDevice*); diff --git a/src/include/Enum.h b/src/include/Enum.h index 0643d95..62b009c 100644 --- a/src/include/Enum.h +++ b/src/include/Enum.h @@ -37,7 +37,7 @@ namespace Enum enum Value { NoSound = 0, Victory = 1, Boing = 2, Bomb = 3, Ping = 4, Break = 5, Splat = 6, Swoosh = 7, - Snap = 8, Page = 9 + Snap = 8, Page = 9, Click = 10, Clock = 11, Step = 12, StepOn = 13, }; } } \ No newline at end of file diff --git a/src/source/Application.cpp b/src/source/Application.cpp index 2d92505..838adcc 100644 --- a/src/source/Application.cpp +++ b/src/source/Application.cpp @@ -8,6 +8,7 @@ #include "DataModelV2/ImageButtonInstance.h" #include "DataModelV2/DataModelInstance.h" #include "DataModelV2/GuiRootInstance.h" +#include "DataModelV2/SoundService.h" #include "XplicitNgine/XplicitNgine.h" #include "CameraController.h" #include "AudioPlayer.h" @@ -512,7 +513,7 @@ void Application::onMouseWheel(int x,int y,short delta) if (mouseOnScreen==true) if (cameraController.onMouseWheel(x, y, delta)) { - AudioPlayer::playSound(cameraSound); + _dataModel->getSoundService()->playSound(_dataModel->getSoundService()->findFirstChild("Step")); } tool->onMouseScroll(mouse); } diff --git a/src/source/DataModelV2/DataModelInstance.cpp b/src/source/DataModelV2/DataModelInstance.cpp index 79f0c84..5c25dc1 100644 --- a/src/source/DataModelV2/DataModelInstance.cpp +++ b/src/source/DataModelV2/DataModelInstance.cpp @@ -471,7 +471,6 @@ bool DataModelInstance::scanXMLObject(xml_node<> * scanNode) { return false; } - } } /* @@ -515,6 +514,27 @@ bool DataModelInstance::load(const char* filename, bool clearObjects) } } +bool DataModelInstance::loadModel(const char* filename) +{ + ifstream levelFile(filename,ios::binary); + if (levelFile) + { + readXMLFileStream(&levelFile); + + //resetEngine(); + selectionService->clearSelection(); + selectionService->addSelected(this); + return true; + } + else + { + std::stringstream msg; + msg << "Failed to load file:" << std::endl << filename << std::endl << strerror(errno); + MessageBoxStr(msg.str()); + return false; + } +} + bool DataModelInstance::readXMLFileStream(std::ifstream* file) { file->seekg(0,file->end); @@ -573,7 +593,7 @@ bool DataModelInstance::getOpen() of.lpstrFile = szFile ; of.lpstrFile[0]='\0'; of.nMaxFile=500; - of.lpstrTitle="Hello"; + of.lpstrTitle="Open"; of.Flags = OFN_FILEMUSTEXIST; ShowCursor(TRUE); BOOL file = GetOpenFileName(&of); @@ -584,6 +604,30 @@ bool DataModelInstance::getOpen() } return true; } + +bool DataModelInstance::getOpenModel() +{ + _modY=0; + OPENFILENAME of; + ZeroMemory( &of , sizeof( of)); + of.lStructSize = sizeof(OPENFILENAME); + of.lpstrFilter = "Roblox Files\0*.rbxm;*.rbxl\0\0"; + char szFile[512]; + of.lpstrFile = szFile ; + of.lpstrFile[0]='\0'; + of.nMaxFile=500; + of.lpstrTitle="Open"; + of.Flags = OFN_FILEMUSTEXIST; + ShowCursor(TRUE); + BOOL file = GetOpenFileName(&of); + if (file) + { + _loadedFileName = of.lpstrFile; + loadModel(of.lpstrFile); + } + return true; +} + void DataModelInstance::setMessage(std::string msg) { message = msg; diff --git a/src/source/DataModelV2/GuiRootInstance.cpp b/src/source/DataModelV2/GuiRootInstance.cpp index 72bb220..a135de9 100644 --- a/src/source/DataModelV2/GuiRootInstance.cpp +++ b/src/source/DataModelV2/GuiRootInstance.cpp @@ -6,6 +6,7 @@ #include "DataModelV2/ImageButtonInstance.h" #include "DataModelV2/ToggleImageButtonInstance.h" #include "DataModelV2/GuiRootInstance.h" +#include "DataModelV2/SelectionService.h" #include "DataModelV2/ImageButtonInstance.h" #include "Globals.h" #include "StringFunctions.h" @@ -213,7 +214,7 @@ GuiRootInstance::GuiRootInstance() : _message(""), _messageTime(0) 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->textColor = Color3(0,1,1); button->boxColor = Color4::clear(); button->textSize = 12; button->title = "Group"; @@ -229,7 +230,7 @@ GuiRootInstance::GuiRootInstance() : _message(""), _messageTime(0) 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->textColor = Color3(0,1,1); button->boxColor = Color4::clear(); button->textSize = 12; button->title = "UnGroup"; @@ -245,7 +246,7 @@ GuiRootInstance::GuiRootInstance() : _message(""), _messageTime(0) 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->textColor = Color3(0,1,1); button->boxColor = Color4::clear(); button->textSize = 12; button->title = "Duplicate"; @@ -502,6 +503,9 @@ void GuiRootInstance::update() Instance * obj3 = this->findFirstChild("UnGroup"); Instance * obj4 = this->findFirstChild("Rotate"); Instance * obj5 = this->findFirstChild("Tilt"); + + SelectionService* getSelectionService = g_dataModel->getSelectionService(); + if(obj != NULL && obj2 != NULL && obj3 != NULL && obj4 !=NULL && obj5 != NULL && obj6 != NULL) { BaseButtonInstance* button = (BaseButtonInstance*)obj; @@ -516,15 +520,23 @@ void GuiRootInstance::update() button4->disabled = true; button5->disabled = true; button6->disabled = true; - for(size_t i = 0; i < g_dataModel->getSelectionService()->getSelection().size(); i++) - if(g_dataModel->getSelectionService()->getSelection()[i]->canDelete) + for(size_t i = 0; i < getSelectionService->getSelection().size(); i++) + if(getSelectionService->getSelection()[i]->canDelete) { button->disabled = false; - button2->disabled = false; - button3->disabled = false; button4->disabled = false; button5->disabled = false; button6->disabled = false; + + + if (getSelectionService->getSelection().size() > 1){ + button2->disabled = false; + } + + if (dynamic_cast(getSelectionService->getSelection()[i])){ + button3->disabled = false; + } + break; } } diff --git a/src/source/DataModelV2/PartInstance.cpp b/src/source/DataModelV2/PartInstance.cpp index 8463f2b..fce479e 100644 --- a/src/source/DataModelV2/PartInstance.cpp +++ b/src/source/DataModelV2/PartInstance.cpp @@ -495,6 +495,14 @@ static TCHAR* strSoundType(int option) return "Swoosh"; case Enum::Sound::Page: return "Page"; + case Enum::Sound::Click: + return "Click"; + case Enum::Sound::Clock: + return "Clock"; + case Enum::Sound::Step: + return "Step"; + case Enum::Sound::StepOn: + return "StepOn"; } return "NoSound"; } @@ -521,6 +529,14 @@ static Enum::Sound::Value EnumOnTouchSoundType(TCHAR* option) return Enum::Sound::Ping; if(strcmp("Snap", option) == 0) return Enum::Sound::Snap; + if(strcmp("Click", option) == 0) + return Enum::Sound::Click; + if(strcmp("Clock", option) == 0) + return Enum::Sound::Clock; + if(strcmp("Step", option) == 0) + return Enum::Sound::Step; + if(strcmp("StepOn", option) == 0) + return Enum::Sound::StepOn; return Enum::Sound::NoSound; } @@ -585,6 +601,18 @@ void PartInstance::onTouch() case Enum::Sound::Swoosh: sndService->playSound(sndService->findFirstChild("Swoosh")); break; + case Enum::Sound::Click: + sndService->playSound(sndService->findFirstChild("Click")); + break; + case Enum::Sound::Clock: + sndService->playSound(sndService->findFirstChild("Clock")); + break; + case Enum::Sound::Step: + sndService->playSound(sndService->findFirstChild("Step")); + break; + case Enum::Sound::StepOn: + sndService->playSound(sndService->findFirstChild("StepOn")); + break; } } @@ -728,7 +756,7 @@ std::vector PartInstance::getProperties() "What sound plays when touched", (LPARAM)strSoundType(OnTouchSound), PIT_COMBO, - TEXT("NoSound\0Victory\0Boing\0Break\0Snap\0Bomb\0Splat\0Page\0Ping\0Swoosh\0") + TEXT("NoSound\0Victory\0Boing\0Break\0Snap\0Bomb\0Splat\0Page\0Ping\0Swoosh\0Click\0Clock\0Step\0StepOn") )); sprintf_s(changeScoreTxt, "%d", changeScore); diff --git a/src/source/DataModelV2/SelectionService.cpp b/src/source/DataModelV2/SelectionService.cpp index 3c78abf..d4189be 100644 --- a/src/source/DataModelV2/SelectionService.cpp +++ b/src/source/DataModelV2/SelectionService.cpp @@ -86,17 +86,17 @@ void SelectionService::render(RenderDevice * rd) void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, Vector3 size, Vector3 pos, CoordinateFrame c) { Color3 outline = Color3::cyan();//Color3(0.098F,0.6F,1.0F); - float offsetSize = 0.05F; + float offsetSize = 0.1F; //X Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, from.y + offsetSize, from.z + offsetSize), Vector3(to.x + offsetSize, from.y - offsetSize, from.z - offsetSize))), rd, outline, Color4::clear()); Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, to.y + offsetSize, from.z + offsetSize), Vector3(to.x + offsetSize, to.y - offsetSize, from.z - offsetSize))), rd, outline, Color4::clear()); Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, to.y + offsetSize, to.z + offsetSize), Vector3(to.x + offsetSize, to.y - offsetSize, to.z - offsetSize))), rd, outline, Color4::clear()); Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, from.y + offsetSize, to.z + offsetSize), Vector3(to.x + offsetSize, from.y - offsetSize, to.z - offsetSize))), rd, outline, Color4::clear()); //Y - Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y - offsetSize + 0.1, from.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize - 0.1, from.z - offsetSize))), rd, outline, Color4::clear()); - Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y - offsetSize + 0.1, from.z + offsetSize), Vector3(to.x - offsetSize, to.y + offsetSize - 0.1, from.z - offsetSize))), rd, outline, Color4::clear()); - Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y - offsetSize + 0.1, to.z + offsetSize), Vector3(to.x - offsetSize, to.y + offsetSize-0.1, to.z - offsetSize))), rd, outline, Color4::clear()); - Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y - offsetSize + 0.1, to.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize - 0.1, to.z - offsetSize))), rd, outline, Color4::clear()); + Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y - offsetSize + 0.2, from.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize - 0.2, from.z - offsetSize))), rd, outline, Color4::clear()); + Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y - offsetSize + 0.2, from.z + offsetSize), Vector3(to.x - offsetSize, to.y + offsetSize - 0.2, from.z - offsetSize))), rd, outline, Color4::clear()); + Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y - offsetSize + 0.2, to.z + offsetSize), Vector3(to.x - offsetSize, to.y + offsetSize-0.1, to.z - offsetSize))), rd, outline, Color4::clear()); + Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y - offsetSize + 0.2, to.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize - 0.2, to.z - offsetSize))), rd, outline, Color4::clear()); //Z Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y + offsetSize, from.z - offsetSize), Vector3(from.x - offsetSize, from.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear()); diff --git a/src/source/DataModelV2/SoundService.cpp b/src/source/DataModelV2/SoundService.cpp index bd26307..7a6b3b8 100644 --- a/src/source/DataModelV2/SoundService.cpp +++ b/src/source/DataModelV2/SoundService.cpp @@ -67,6 +67,30 @@ SoundService::SoundService() stockSound->setName("Page"); stockSound->setSoundId("/content/sounds/pageturn.wav"); stockSound->setParent(this); + + // Click + stockSound = new SoundInstance(); + stockSound->setName("Click"); + stockSound->setSoundId("/content/sounds/switch.wav"); + stockSound->setParent(this); + + // Clock + stockSound = new SoundInstance(); + stockSound->setName("Clock"); + stockSound->setSoundId("/content/sounds/clickfast.wav"); + stockSound->setParent(this); + + // Step + stockSound = new SoundInstance(); + stockSound->setName("Step"); + stockSound->setSoundId("/content/sounds/SWITCH3.wav"); + stockSound->setParent(this); + + // StepOn + stockSound = new SoundInstance(); + stockSound->setName("StepOn"); + stockSound->setSoundId("/content/sounds/flashbulb.wav"); + stockSound->setParent(this); } SoundService::~SoundService(void) diff --git a/src/source/Listener/GUDButtonListener.cpp b/src/source/Listener/GUDButtonListener.cpp index b0b3413..53dbd0d 100644 --- a/src/source/Listener/GUDButtonListener.cpp +++ b/src/source/Listener/GUDButtonListener.cpp @@ -1,75 +1,88 @@ #include #include "Application.h" #include "Globals.h" -#include "AudioPlayer.h" #include "DataModelV2/SelectionService.h" #include "Listener/GUDButtonListener.h" +#include "DataModelV2/SoundService.h" void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button) { + SelectionService* selectionService = g_dataModel->getSelectionService(); + SoundService* soundService = g_dataModel->getSoundService(); + bool cont = false; - for(size_t i = 0; i < g_dataModel->getSelectionService()->getSelection().size(); i++) - if(g_dataModel->getSelectionService()->getSelection()[i]->canDelete) + for(size_t i = 0; i < selectionService->getSelection().size(); i++) + if(selectionService->getSelection()[i]->canDelete) { cont = true; break; } - if(cont) + + if (cont) { - AudioPlayer::playSound(dingSound); + if(button->disabled == false){ + soundService->playSound(soundService->findFirstChild("Ping")); + } + if(button->name == "Duplicate") { std::vector newinst; - for(size_t i = 0; i < g_dataModel->getSelectionService()->getSelection().size(); i++) + for(size_t i = 0; i < selectionService->getSelection().size(); i++) { - if(g_dataModel->getSelectionService()->getSelection()[i]->canDelete) + if(selectionService->getSelection()[i]->canDelete) { - Instance* tempinst = g_dataModel->getSelectionService()->getSelection()[i]; + Instance* tempinst = selectionService->getSelection()[i]; - Instance* clonedInstance = g_dataModel->getSelectionService()->getSelection()[i]->clone(); + Instance* clonedInstance = selectionService->getSelection()[i]->clone(); - newinst.push_back(tempinst); + if (clonedInstance->getClassName() == "PVInstance"){ + PartInstance* Part = dynamic_cast(clonedInstance); + Part->setPosition(Part->getPosition() + G3D::Vector3(0, Part->getSize().y, 0)); + } + + newinst.push_back(clonedInstance); } } - g_dataModel->getSelectionService()->clearSelection(); - g_dataModel->getSelectionService()->addSelected(newinst); + selectionService->clearSelection(); + selectionService->addSelected(newinst); } else if(button->name == "Group") { - GroupInstance * inst = new GroupInstance(); - inst->setParent(g_dataModel->getWorkspace()); - for(size_t i = 0; i < g_dataModel->getSelectionService()->getSelection().size(); i++) - { - if(g_dataModel->getSelectionService()->getSelection()[i]->canDelete) + if (selectionService->getSelection().size() > 1){ + GroupInstance * inst = new GroupInstance(); + inst->setParent(g_dataModel->getWorkspace()); + for(size_t i = 0; i < selectionService->getSelection().size(); i++) { - g_dataModel->getSelectionService()->getSelection()[i]->setParent(inst); - if(PartInstance* part = dynamic_cast(g_dataModel->getSelectionService()->getSelection()[i])) + if(selectionService->getSelection()[i]->canDelete) { - inst->primaryPart = part; + selectionService->getSelection()[i]->setParent(inst); + if(PartInstance* part = dynamic_cast(selectionService->getSelection()[i])) + { + inst->primaryPart = part; + } } } - } - g_dataModel->getSelectionService()->clearSelection(); - g_dataModel->getSelectionService()->addSelected(inst); + selectionService->clearSelection(); + selectionService->addSelected(inst); + } } else if(button->name == "UnGroup") { std::vector newinst; - for(size_t i = 0; i < g_dataModel->getSelectionService()->getSelection().size(); i++) + for(size_t i = 0; i < selectionService->getSelection().size(); i++) { - if(g_dataModel->getSelectionService()->getSelection()[i]->canDelete) + Instance* selection = selectionService->getSelection()[i]; + + if(GroupInstance* model = dynamic_cast(selection)) { - if(GroupInstance* model = dynamic_cast(g_dataModel->getSelectionService()->getSelection()[i])) - { - newinst = model->unGroup(); - model->setParent(NULL); - delete model; - model = NULL; - } + newinst = model->unGroup(); + model->setParent(NULL); + delete model; + model = NULL; } } - g_dataModel->getSelectionService()->clearSelection(); - g_dataModel->getSelectionService()->addSelected(newinst); + selectionService->clearSelection(); + selectionService->addSelected(newinst); } } } \ No newline at end of file diff --git a/src/source/Listener/MenuButtonListener.cpp b/src/source/Listener/MenuButtonListener.cpp index fbd6d67..9994f7e 100644 --- a/src/source/Listener/MenuButtonListener.cpp +++ b/src/source/Listener/MenuButtonListener.cpp @@ -49,4 +49,18 @@ void MenuButtonListener::onButton1MouseClick(BaseButtonInstance* button) break; } } + else if (button->name == "insert"){ + HMENU mainmenu = CreatePopupMenu(); + AppendMenu(mainmenu, MF_STRING, 104, "Model..."); + + POINT p; + GetCursorPos(&p); + int menuClick = TrackPopupMenu(mainmenu, TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, 0, Globals::mainHwnd, 0); + switch (menuClick) + { + case 104: + g_dataModel->getOpenModel(); + break; + } + } } \ No newline at end of file