Merge pull request #123 from KeyboardCombination/develop

GUD improvements (nobody merged this despite approval?)
This commit is contained in:
starfrost
2023-08-15 22:58:48 +01:00
committed by GitHub
14 changed files with 190 additions and 51 deletions

View File

@@ -185,6 +185,7 @@
OutputFile="./Blocks3D-Debug.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories=""
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/Blocks3D.pdb"
SubSystem="1"

BIN
Parts.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Binary file not shown.

View File

@@ -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*);

View File

@@ -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,
};
}
}

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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<GroupInstance*>(getSelectionService->getSelection()[i])){
button3->disabled = false;
}
break;
}
}

View File

@@ -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<PROPGRIDITEM> 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);

View File

@@ -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());

View File

@@ -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)

View File

@@ -1,75 +1,88 @@
#include <G3DAll.h>
#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<Instance*> 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<PartInstance*>(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<PartInstance*>(g_dataModel->getSelectionService()->getSelection()[i]))
if(selectionService->getSelection()[i]->canDelete)
{
inst->primaryPart = part;
selectionService->getSelection()[i]->setParent(inst);
if(PartInstance* part = dynamic_cast<PartInstance*>(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<Instance*> 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<GroupInstance*>(selection))
{
if(GroupInstance* model = dynamic_cast<GroupInstance*>(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);
}
}
}

View File

@@ -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;
}
}
}