diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f79274..938b978 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ project(player) project(server) project(studio) -find_package(Qt6 REQUIRED COMPONENTS Core) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets OpenGLWidgets) find_package(Boost REQUIRED) qt_standard_project_setup() @@ -29,12 +29,15 @@ add_executable(server ) qt_add_executable(studio + src/client/studio/studiowindow.cpp + src/client/studio/studiowindow.hpp src/client/studio/main.cpp ) target_include_directories(engine PUBLIC src/include) target_link_libraries(engine PUBLIC ${BOOST_LIBRARIES}) -target_link_libraries(player PRIVATE Qt6::Core engine) -target_link_libraries(studio PRIVATE Qt6::Core engine) +set(QT6_LIBRARIES_INCL Qt6::Core Qt6::Gui Qt6::Widgets Qt6::OpenGLWidgets) +target_link_libraries(player PRIVATE ${QT6_LIBRARIES_INCL} engine) +target_link_libraries(studio PRIVATE ${QT6_LIBRARIES_INCL} engine) target_link_libraries(server PRIVATE engine) \ No newline at end of file diff --git a/src/client/studio/main.cpp b/src/client/studio/main.cpp index e5ecee2..079a180 100644 --- a/src/client/studio/main.cpp +++ b/src/client/studio/main.cpp @@ -1,6 +1,14 @@ #include -int main() +#include +#include "studiowindow.hpp" + +int main(int argc, char** argv) { - printf("Hello world!"); + QApplication a(argc, argv); + StudioWindow window = StudioWindow(); + + window.show(); + + return a.exec(); } \ No newline at end of file diff --git a/src/client/studio/studiowindow.cpp b/src/client/studio/studiowindow.cpp new file mode 100644 index 0000000..a64f80a --- /dev/null +++ b/src/client/studio/studiowindow.cpp @@ -0,0 +1,14 @@ +#include "studiowindow.hpp" + +StudioWindow::StudioWindow() +{ + setWindowTitle(QString("RBXNu Studio")); + setWindowIcon(QIcon(":/content/images/icon.png")); + + studio_graphic_timer.start(); +} + +void StudioWindow::closeEvent(QCloseEvent* event) +{ + +} \ No newline at end of file diff --git a/src/client/studio/studiowindow.hpp b/src/client/studio/studiowindow.hpp new file mode 100644 index 0000000..9237058 --- /dev/null +++ b/src/client/studio/studiowindow.hpp @@ -0,0 +1,16 @@ +#ifndef __CLIENT_STUDIO_STUDIOWINDOW_HPP__ +#define __CLIENT_STUDIO_STUDIOWINDOW_HPP__ + +#include +#include + +class StudioWindow : public QMainWindow +{ + Q_OBJECT +public: + StudioWindow(); +protected: + void closeEvent(QCloseEvent* event); +}; + +#endif \ No newline at end of file diff --git a/src/engine/app/v8/tree/Instance.cpp b/src/engine/app/v8/tree/Instance.cpp index 5bfbe1f..58a1ecf 100644 --- a/src/engine/app/v8/tree/Instance.cpp +++ b/src/engine/app/v8/tree/Instance.cpp @@ -1,4 +1,5 @@ #include +#include RBX::Instance::Instance() { @@ -37,9 +38,9 @@ bool RBX::Instance::askAddChild(RBX::Instance* instance) bool RBX::Instance::canAddChild(RBX::Instance* instance) { - if(instance->contains(this) || instance->parent == this) + if(instance->contains(this) || instance->m_parent == this) return false; - if(askAddC hild(instance)) + if(askAddChild(instance)) return true; return instance->askSetParent(this); } @@ -57,19 +58,22 @@ void RBX::Instance::setParent(RBX::Instance* newParent) { if(newParent != m_parent) { + char error_text[255]; if(this == newParent) { - throw std::runtime_error("Attempt to set %s as its own parent", m_name); + snprintf(error_text, 255, "Attempt to set %s as its own parent", m_name); + throw std::runtime_error(error_text); } if(isAncestorOf(newParent)) { - throw std::runtime_error("Attempt to set parent of %s to %s results in circular reference", newParent->getName(), m_name); + snprintf(error_text, 255, "Attempt to set parent of %s to %s results in circular reference", newParent->getName(), m_name); + throw std::runtime_error(error_text); } if(m_parent) { std::vector>* children = m_parent->getChildren(); - auto child_it = std::find(children->begin(), children->end(), this); + auto child_it = std::find(children->begin(), children->end(), (boost::shared_ptr)this); if(child_it != children->end()) children->erase(child_it); if(m_parent->numChildren() == 0) @@ -79,7 +83,7 @@ void RBX::Instance::setParent(RBX::Instance* newParent) } m_parent = newParent; - m_parent->children.push_back(this); + m_parent->m_children.push_back((boost::shared_ptr)this); newParent->onChildAdded(this); } } diff --git a/src/include/engine/app/v8/tree/Instance.hpp b/src/include/engine/app/v8/tree/Instance.hpp index d077d10..259efdf 100644 --- a/src/include/engine/app/v8/tree/Instance.hpp +++ b/src/include/engine/app/v8/tree/Instance.hpp @@ -16,7 +16,7 @@ namespace RBX bool m_archivable; public: Instance(); - Instance(char* name); + Instance(std::string name); bool contains(RBX::Instance* child); bool isAncestorOf(RBX::Instance* instance); @@ -29,12 +29,12 @@ namespace RBX void createChild(boost::shared_ptr* result, const RBX::Name *className); RBX::Instance* getParent() { return this->m_parent; }; - std::string getName() { return this->m_name }; + std::string getName() { return this->m_name; }; void setParent(RBX::Instance* newParent); void setName(std::string name); std::vector>* getChildren() { return &this->m_children; }; - int numChildren() { return this->m_children.size() }; + int numChildren() { return this->m_children.size(); }; void onChildAdded(RBX::Instance* childAdded);