Browse Source

- added moveInDirection() function for ModelModule, ModelLayer
- fixed BUILD_DEBUG output dependencies

Patrick-Christopher Mattulat 3 years ago
parent
commit
de4769a3b0

+ 1 - 1
LynarMoon/engine/Error/ErrorHandler.cpp

@@ -65,7 +65,7 @@ void ErrorHandler::output(int errorCode, const std::string& title)
   {
     this->writeToLogFile(errorCode, title, errorMessage.message);
 
-    if(buildMode == BUILD_DEBUG) {
+    if(buildMode == BUILD_DEBUG && errorCode != LE_NO_ERROR) {
       MessageBox::display(SDL_MESSAGEBOX_ERROR, title, errorMessage.message);
     }
   }

+ 1 - 1
LynarMoon/engine/Global.h

@@ -31,7 +31,7 @@
 
 #define LYNAR_MOON_VERSION_STR            "1.5.0"
 #define RELEASE_DATE                      "01.09.2018"
-#define BUILD_MODE                        BUILD_RELEASE_LOG
+#define BUILD_MODE                        BUILD_DEBUG
 #define LOG_DURATION_OF_VALIDITY          200
 
 #endif

+ 2 - 1
LynarMoon/engine/LynarMoon.h

@@ -2,7 +2,7 @@
  * author:            Patrick-Christopher Mattulat
  * dev-tools:         JetBrains CLion
  * created:           10.08.2018
- * last updated:      18.10.2018
+ * last updated:      19.10.2018
  */
 
 #ifndef LYNARMOON_H
@@ -134,6 +134,7 @@ class LynarMoon
         bool isVisible(uint32_t);
         int makeTextureVisible(uint32_t, uint32_t, bool);
         int makeVisible(uint32_t, bool);
+        int moveInDirection(uint32_t, uint32_t);
         int remove(uint32_t);
         int removeClone(uint32_t, uint32_t);
         int removeDirection(uint32_t, uint32_t);

+ 19 - 1
LynarMoon/engine/Module/Model/ModelModule.cpp

@@ -2,7 +2,7 @@
  * author:            Patrick-Christopher Mattulat
  * dev-tools:         JetBrains CLion
  * created:           29.08.2018
- * last updated:      12.09.2018
+ * last updated:      19.10.2018
  */
 
 #include "ModelModule.h"
@@ -466,6 +466,24 @@ void ModelModule::makeVisible(bool visible)
   this->rendererInfo.visible = visible;
 }
 
+int ModelModule::moveInDirection(uint32_t idDirection, double timestep)
+{
+  int result = LE_NO_ERROR;
+  std::shared_ptr<Direction> d = this->directionList.getElement(idDirection);
+  LynarMath::_Point_d position = this->getPosition();
+
+  if(d != nullptr) {
+    position.x += d.get()->get().x * timestep;
+    position.y += d.get()->get().y * timestep;
+    this->setPosition(position);
+  }
+  else {
+    result = LE_ID_NOEXIST;
+  }
+
+  return result;
+}
+
 int ModelModule::removeClone(uint32_t idClone)
 {
   return this->rendererInfo.cloneList.removeElement(idClone);

+ 2 - 1
LynarMoon/engine/Module/Model/ModelModule.h

@@ -2,7 +2,7 @@
  * author:            Patrick-Christopher Mattulat
  * dev-tools:         JetBrains CLion
  * created:           29.08.2018
- * last updated:      12.09.2018
+ * last updated:      19.10.2018
  */
 
 #ifndef MODULEMODEL_H
@@ -71,6 +71,7 @@ class ModelModule : IdentifiedObject
     bool isVisible();
     int makeTextureVisible(uint32_t, bool);
     void makeVisible(bool);
+    int moveInDirection(uint32_t, double);
     int removeClone(uint32_t);
     int removeDirection(uint32_t);
     int removeTexturePartialArea(uint32_t, uint32_t);

+ 22 - 1
LynarMoon/engine/ModuleLayer/ModelLayer.cpp

@@ -2,7 +2,7 @@
  * author:            Patrick-Christopher Mattulat
  * dev-tools:         JetBrains CLion
  * created:           29.08.2018
- * last updated:      11.09.2018
+ * last updated:      19.10.2018
  */
 
 #include "../LynarMoon.h"
@@ -553,6 +553,27 @@ int LynarMoon::ModelLayer::makeVisible(uint32_t id, bool visible)
   return result;
 }
 
+int LynarMoon::ModelLayer::moveInDirection(uint32_t id, uint32_t idDirection)
+{
+  std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);
+  std::string functionName = "ModelLayer::moveInDirection()";
+  int result;
+
+  if(model != nullptr) {
+    result = model.get()->moveInDirection(idDirection, this->parent->getTimestep());
+
+    if(result) {
+      this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(idDirection));
+    }
+  }
+  else {
+    result = LE_ID_NOEXIST;
+    this->errorHandler->output(result, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
+  }
+
+  return result;
+}
+
 int LynarMoon::ModelLayer::remove(uint32_t id)
 {
   std::shared_ptr<ModelModule> model = this->ModelList.get()->getElement(id);