kinda add RunService

This commit is contained in:
Modnark
2023-03-30 14:45:56 -04:00
parent 0b8847cd8e
commit fcab9a8871
9 changed files with 89 additions and 11 deletions

View File

@@ -509,6 +509,10 @@
/> />
</FileConfiguration> </FileConfiguration>
</File> </File>
<File
RelativePath=".\src\source\DataModelV2\RunServiceInstance.cpp"
>
</File>
<File <File
RelativePath=".\src\source\DataModelV2\SelectionService.cpp" RelativePath=".\src\source\DataModelV2\SelectionService.cpp"
> >
@@ -902,6 +906,10 @@
RelativePath=".\src\include\DataModelV2\PVInstance.h" RelativePath=".\src\include\DataModelV2\PVInstance.h"
> >
</File> </File>
<File
RelativePath=".\src\include\DataModelV2\RunServiceInstance.h"
>
</File>
<File <File
RelativePath=".\src\include\DataModelV2\SelectionService.h" RelativePath=".\src\include\DataModelV2\SelectionService.h"
> >

View File

@@ -10,6 +10,7 @@
#include "XplicitNgine/XplicitNgine.h" #include "XplicitNgine/XplicitNgine.h"
#include "SoundService.h" #include "SoundService.h"
#include "LightingInstance.h" #include "LightingInstance.h"
#include "RunServiceInstance.h"
// Libraries // Libraries
#include "rapidxml/rapidxml.hpp" #include "rapidxml/rapidxml.hpp"
@@ -38,6 +39,7 @@ public:
ThumbnailGeneratorInstance* getThumbnailGenerator(); ThumbnailGeneratorInstance* getThumbnailGenerator();
SoundService* getSoundService(); SoundService* getSoundService();
LightingInstance* getLighting(); LightingInstance* getLighting();
RunService* getRunService();
std::string message; std::string message;
std::string _loadedFileName; std::string _loadedFileName;
@@ -47,7 +49,7 @@ public:
SelectionService* getSelectionService(); SelectionService* getSelectionService();
PartInstance* makePart(); PartInstance* makePart();
void clearLevel(); void clearLevel();
void toggleRun(); void toggleRun(bool doRun);
bool isRunning(); bool isRunning();
void resetEngine(); void resetEngine();
#if _DEBUG #if _DEBUG
@@ -72,6 +74,8 @@ private:
XplicitNgine* xplicitNgine; XplicitNgine* xplicitNgine;
SoundService* soundService; SoundService* soundService;
LightingInstance* lightingInstance; LightingInstance* lightingInstance;
RunService* runService;
bool running; bool running;
}; };

View File

@@ -0,0 +1,14 @@
#pragma once
#include "Instance.h"
class RunService :
public Instance
{
public:
RunService(void);
~RunService(void);
void run();
void pause();
void reset();
};

View File

@@ -12,3 +12,4 @@ public:
void zoomToExtents(); void zoomToExtents();
std::vector<PartInstance *> partObjects; std::vector<PartInstance *> partObjects;
}; };

View File

@@ -192,6 +192,8 @@ void Application::onInit() {
tool = new Tool(); tool = new Tool();
// Called before Application::run() beings // Called before Application::run() beings
cameraController.setFrame(Vector3(0,2,10)); cameraController.setFrame(Vector3(0,2,10));
cameraController.Zoom(-1);
_dataModel = new DataModelInstance(); _dataModel = new DataModelInstance();
_dataModel->setParent(NULL); _dataModel->setParent(NULL);
_dataModel->setName("undefined"); _dataModel->setName("undefined");

View File

@@ -25,7 +25,10 @@ DataModelInstance::DataModelInstance(void)
workspace = new WorkspaceInstance(); workspace = new WorkspaceInstance();
guiRoot = new GuiRootInstance(); guiRoot = new GuiRootInstance();
level = new LevelInstance(); level = new LevelInstance();
thumbnailGenerator = new ThumbnailGeneratorInstance(); runService = new RunService();
//thumbnailGenerator = new ThumbnailGeneratorInstance();
soundService = new SoundService(); soundService = new SoundService();
lightingInstance = new LightingInstance(); lightingInstance = new LightingInstance();
@@ -67,9 +70,10 @@ XplicitNgine * DataModelInstance::getEngine()
return xplicitNgine; return xplicitNgine;
} }
void DataModelInstance::toggleRun() // Please use RunService->run(); & RunService->pause(); instead
void DataModelInstance::toggleRun(bool doRun)
{ {
running = !running; running = doRun;
//if(!running) //if(!running)
//resetEngine(); //resetEngine();
} }
@@ -90,7 +94,6 @@ void DataModelInstance::modXMLLevel(float modY)
_modY += modY; _modY += modY;
clearLevel(); clearLevel();
debugGetOpen(); debugGetOpen();
} }
#endif #endif
@@ -642,6 +645,7 @@ void DataModelInstance::drawMessage(RenderDevice* rd)
} }
} }
// Instance getters
WorkspaceInstance* DataModelInstance::getWorkspace() WorkspaceInstance* DataModelInstance::getWorkspace()
{ {
return workspace; return workspace;
@@ -675,4 +679,9 @@ SoundService* DataModelInstance::getSoundService()
LightingInstance* DataModelInstance::getLighting() LightingInstance* DataModelInstance::getLighting()
{ {
return lightingInstance; return lightingInstance;
}
RunService* DataModelInstance::getRunService()
{
return runService;
} }

View File

@@ -183,26 +183,26 @@ void LevelInstance::winCondition()
{ {
DataModelInstance* DataModel = (DataModelInstance*)getParent(); //If level parent gets changed to something other than Datamodel it could cause nasty data corruption bugs DataModelInstance* DataModel = (DataModelInstance*)getParent(); //If level parent gets changed to something other than Datamodel it could cause nasty data corruption bugs
DataModel->setMessage(winMessage); DataModel->setMessage(winMessage);
DataModel->toggleRun(); DataModel->getRunService()->pause();
} }
void LevelInstance::loseCondition() void LevelInstance::loseCondition()
{ {
DataModelInstance* DataModel = (DataModelInstance*)getParent(); DataModelInstance* DataModel = (DataModelInstance*)getParent();
DataModel->setMessage(loseMessage); DataModel->setMessage(loseMessage);
DataModel->toggleRun(); DataModel->getRunService()->pause();
} }
void LevelInstance::pauseCondition() void LevelInstance::pauseCondition()
{ {
DataModelInstance* DataModel = (DataModelInstance*)getParent(); DataModelInstance* DataModel = (DataModelInstance*)getParent();
DataModel->toggleRun(); DataModel->getRunService()->pause();
} }
void LevelInstance::drawCondition() void LevelInstance::drawCondition()
{ {
DataModelInstance* DataModel = (DataModelInstance*)getParent(); DataModelInstance* DataModel = (DataModelInstance*)getParent();
DataModel->toggleRun(); DataModel->getRunService()->pause();
} }
void LevelInstance::Step(SimTime sdt) void LevelInstance::Step(SimTime sdt)

View File

@@ -0,0 +1,36 @@
#include "DataModelV2/RunServiceInstance.h"
#include "DataModelV2/ToggleImageButtonInstance.h"
#include "Globals.h"
RunService::RunService()
{
// Run Service, not RunService, because Roblox themselves did it. Why? IDK!
name = "Run Service";
className = "RunService";
canDelete = false;
}
RunService::~RunService(void)
{
}
void RunService::run()
{
// Tell GUI that we are running
Instance* go = g_dataModel->getGuiRoot()->findFirstChild("go");
g_dataModel->toggleRun(true);
((ToggleImageButtonInstance*)go)->checked = true;
}
void RunService::pause()
{
// Tell GUI that we paused
Instance* go = g_dataModel->getGuiRoot()->findFirstChild("go");
g_dataModel->toggleRun(false);
((ToggleImageButtonInstance*)go)->checked = false;
}
void RunService::reset()
{
// Can't really implement right now
}

View File

@@ -6,8 +6,12 @@ void MenuButtonListener::onButton1MouseClick(BaseButtonInstance* button)
{ {
if(button->name == "go") if(button->name == "go")
{ {
g_dataModel->toggleRun(); bool isRunning = g_dataModel->isRunning();
((ToggleImageButtonInstance*)button)->checked = g_dataModel->isRunning(); if(isRunning)
g_dataModel->getRunService()->pause();
else
g_dataModel->getRunService()->run();
//((ToggleImageButtonInstance*)button)->checked = !isRunning;
} }
else if(button->name == "file") else if(button->name == "file")
{ {