Skip to content

Commit

Permalink
[Interface/AppWindow] Added the ScriptSystem to the application
Browse files Browse the repository at this point in the history
- Removed unneeded per-frame instructions

- Removed window closing on escape press
  • Loading branch information
Razakhel committed Jun 1, 2024
1 parent 1670a3e commit ca1571b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 41 deletions.
24 changes: 12 additions & 12 deletions assets/translations/english.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</message>
<message>
<location filename="../../src/RaZor/Interface/Component/AppComponents.cpp" line="104"/>
<location filename="../../src/RaZor/Interface/AppWindow.cpp" line="401"/>
<location filename="../../src/RaZor/Interface/AppWindow.cpp" line="404"/>
<source>Failed to import mesh</source>
<translation>Failed to import mesh</translation>
</message>
Expand Down Expand Up @@ -333,42 +333,42 @@
<translation>Ready</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="79"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="71"/>
<source>Unexpected empty field</source>
<translation>Unexpected empty field</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="103"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="95"/>
<source>Failed to load cubemap: </source>
<translation>Failed to load cubemap: </translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="156"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="148"/>
<source>None</source>
<translation>None</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="157"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="149"/>
<source>Error</source>
<translation>Error</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="158"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="150"/>
<source>Warning</source>
<translation>Warning</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="159"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="151"/>
<source>Info</source>
<translation>Info</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="161"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="153"/>
<source>Debug</source>
<translation>Debug</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="163"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="155"/>
<source>All</source>
<translation>All</translation>
</message>
Expand Down Expand Up @@ -448,12 +448,12 @@
<translation>Quit RaZor</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="63"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="55"/>
<source>&amp;Entities</source>
<translation>&amp;Entities</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="65"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="57"/>
<source>&amp;Components</source>
<translation>&amp;Components</translation>
</message>
Expand Down Expand Up @@ -483,7 +483,7 @@
<translation>&amp;Physics system settings...</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="67"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="59"/>
<source>C&amp;onsole</source>
<translation>C&amp;onsole</translation>
</message>
Expand Down
24 changes: 12 additions & 12 deletions assets/translations/french.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</message>
<message>
<location filename="../../src/RaZor/Interface/Component/AppComponents.cpp" line="104"/>
<location filename="../../src/RaZor/Interface/AppWindow.cpp" line="401"/>
<location filename="../../src/RaZor/Interface/AppWindow.cpp" line="404"/>
<source>Failed to import mesh</source>
<translation>Échec de l&apos;import du maillage</translation>
</message>
Expand Down Expand Up @@ -333,42 +333,42 @@
<translation>Prêt</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="79"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="71"/>
<source>Unexpected empty field</source>
<translation>Champ vide inattendu</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="103"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="95"/>
<source>Failed to load cubemap: </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="156"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="148"/>
<source>None</source>
<translation>Aucun</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="157"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="149"/>
<source>Error</source>
<translation>Erreur</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="158"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="150"/>
<source>Warning</source>
<translation>Avertissement</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="159"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="151"/>
<source>Info</source>
<translation>Info</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="161"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="153"/>
<source>Debug</source>
<translation>Débogage</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="163"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="155"/>
<source>All</source>
<translation>Tout</translation>
</message>
Expand Down Expand Up @@ -448,12 +448,12 @@
<translation>Quitter RaZor</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="63"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="55"/>
<source>&amp;Entities</source>
<translation>&amp;Entités</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="65"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="57"/>
<source>&amp;Components</source>
<translation>&amp;Composants</translation>
</message>
Expand Down Expand Up @@ -483,7 +483,7 @@
<translation>Paramètres du système &amp;physique...</translation>
</message>
<message>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="67"/>
<location filename="../../src/RaZor/Interface/MainWindow.cpp" line="59"/>
<source>C&amp;onsole</source>
<translation>C&amp;onsole</translation>
</message>
Expand Down
3 changes: 0 additions & 3 deletions include/RaZor/Interface/MainWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ class MainWindow final : public QMainWindow {

~MainWindow() override = default;

protected:
void keyPressEvent(QKeyEvent* event) override;

private:
void setupActions();

Expand Down
13 changes: 7 additions & 6 deletions src/RaZor/Interface/AppWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <RaZ/Render/Light.hpp>
#include <RaZ/Render/MeshRenderer.hpp>
#include <RaZ/Render/RenderSystem.hpp>
#include <RaZ/Script/ScriptSystem.hpp>
#include <RaZ/Utils/Logger.hpp>

#if defined(RAZOR_COMPILER_MSVC)
Expand Down Expand Up @@ -58,6 +59,7 @@ void AppWindow::initialize() {

Raz::Renderer::initialize();
world.addSystem<Raz::RenderSystem>(windowSize.width(), windowSize.height());
Raz::Renderer::clearColor(0.15f, 0.15f, 0.15f, 1.f);

m_cameraEntity = &addEntity("Camera");
m_cameraComp = &m_cameraEntity->addComponent<Raz::Camera>(windowSize.width(), windowSize.height());
Expand Down Expand Up @@ -125,7 +127,7 @@ void AppWindow::initialize() {
m_parentWindow->m_audioSystemSettings.audioDevices->setCurrentText(audioSystem.recoverCurrentDevice().c_str());

connect(m_parentWindow->m_audioSystemSettings.audioDevices, &QComboBox::currentTextChanged, [this, &audioSystem] (const QString& deviceName) {
audioSystem.openDevice(deviceName.toStdString().c_str());
audioSystem.openDevice(deviceName.toStdString());

// Since the audio device has changed, every Sound object must be recreated
for (std::pair<const QString, Raz::Entity*>& entityPair : m_entities) {
Expand All @@ -135,6 +137,10 @@ void AppWindow::initialize() {
entity.getComponent<Raz::Sound>().init();
}
});

// Scripting

world.addSystem<Raz::ScriptSystem>();
}

void AppWindow::render() {
Expand All @@ -143,9 +149,6 @@ void AppWindow::render() {

processActions();

Raz::Renderer::clearColor(0.15f, 0.15f, 0.15f, 1.f);
Raz::Renderer::clear(Raz::MaskType::COLOR | Raz::MaskType::DEPTH | Raz::MaskType::STENCIL);

m_application.runOnce();

// Not making the context current with MSVC in Debug mode results in one "QOpenGLContext::swapBuffers() called without
Expand Down Expand Up @@ -430,13 +433,11 @@ void AppWindow::processActions() {

if (m_movingForward) {
m_cameraTrans->move(Raz::Vec3f(0.f, 0.f, -moveVal));

m_cameraComp->setOrthographicBound(m_cameraComp->getOrthographicBound() - moveVal / 10.f);
}

if (m_movingBackward) {
m_cameraTrans->move(Raz::Vec3f(0.f, 0.f, moveVal));

m_cameraComp->setOrthographicBound(m_cameraComp->getOrthographicBound() + moveVal / 10.f);
}

Expand Down
8 changes: 0 additions & 8 deletions src/RaZor/Interface/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ void MainWindow::initializeApplication() {
m_appWindow.initialize();
}

void MainWindow::keyPressEvent(QKeyEvent* event) {
switch (event->key()) {
case Qt::Key_Escape:
QMainWindow::close();
break;
}
}

void MainWindow::setupActions() {
// File menu

Expand Down

0 comments on commit ca1571b

Please sign in to comment.