Browse Source

- added getSize() function for TextModule, TextLayer
- fixed displaying LE_NO_ERROR messages with popup window

Patrick-Christopher Mattulat 3 years ago
parent
commit
3006d837f0

+ 3 - 2
LynarMoon/engine/Error/ErrorHandler.cpp

@@ -2,7 +2,7 @@
  * author:            Patrick-Christopher Mattulat
  * dev-tools:         JetBrains CLion
  * created:           19.08.2018
- * last updated:      23.08.2018
+ * last updated:      18.10.2018
  */
 
 #include <SDL.h>
@@ -11,6 +11,7 @@
 #include "../Global.h"
 #include "ErrorMessage.h"
 #include "ErrorList.h"
+#include "ErrorCodes.h"
 
 //////////////////////////////////////////////////
 //////////////////////////////////////////////////
@@ -83,7 +84,7 @@ void ErrorHandler::output(int errorCode, const std::string& title, const std::st
   {
     this->writeToLogFile(errorCode, title, message);
 
-    if(buildMode == BUILD_DEBUG) {
+    if(buildMode == BUILD_DEBUG && errorCode != LE_NO_ERROR) {
       MessageBox::display(SDL_MESSAGEBOX_ERROR, title, message);
     }
   }

+ 2 - 1
LynarMoon/engine/LynarMoon.h

@@ -2,7 +2,7 @@
  * author:            Patrick-Christopher Mattulat
  * dev-tools:         JetBrains CLion
  * created:           10.08.2018
- * last updated:      27.09.2018
+ * last updated:      18.10.2018
  */
 
 #ifndef LYNARMOON_H
@@ -273,6 +273,7 @@ class LynarMoon
         _ColorValue_d getColor(uint32_t);
         LynarMath::_Vec2_d getDirection(uint32_t, uint32_t);
         LynarMath::_Point_d getPosition(uint32_t);
+        LynarMath::_Point_d getSize(uint32_t);
         double getSizeFactor(uint32_t);
         uint32_t getZindex(uint32_t);
         bool isVisible(uint32_t);

+ 7 - 1
LynarMoon/engine/Module/Text/TextModule.cpp

@@ -2,7 +2,7 @@
  * author:            Patrick-Christopher Mattulat
  * dev-tools:         JetBrains CLion
  * created:           28.08.2018
- * last updated:      12.09.2018
+ * last updated:      18.10.2018
  */
 
 #include "TextModule.h"
@@ -134,6 +134,12 @@ TextRendererInfo TextModule::getRendererInfo()
   return this->rendererInfo;
 }
 
+LynarMath::_Point_d TextModule::getSize()
+{
+  LynarMath::_Rectangle_d renderingArea = this->rendererInfo.texture->getRenderingArea();
+  return {renderingArea.w, renderingArea.h};
+}
+
 double TextModule::getSizeFactor()
 {
   return this->rendererInfo.texture.get()->getSizeFactor();

+ 2 - 1
LynarMoon/engine/Module/Text/TextModule.h

@@ -2,7 +2,7 @@
  * author:            Patrick-Christopher Mattulat
  * dev-tools:         JetBrains CLion
  * created:           28.08.2018
- * last updated:      03.09.2018
+ * last updated:      18.10.2018
  */
 
 #ifndef TEXTMODULE_H
@@ -55,6 +55,7 @@ class TextModule : IdentifiedObject
     uint8_t getModule();
     LynarMath::_Point_d getPosition();
     TextRendererInfo getRendererInfo();
+    LynarMath::_Point_d getSize();
     double getSizeFactor();
     ZindexInfo getZindex();
     bool isVisible();

+ 17 - 1
LynarMoon/engine/ModuleLayer/TextLayer.cpp

@@ -2,7 +2,7 @@
  * author:            Patrick-Christopher Mattulat
  * dev-tools:         JetBrains CLion
  * created:           28.08.2018
- * last updated:      29.08.2018
+ * last updated:      18.10.2018
  */
 
 #include "../LynarMoon.h"
@@ -218,6 +218,22 @@ LynarMath::_Point_d LynarMoon::TextLayer::getPosition(uint32_t id)
   return position;
 }
 
+LynarMath::_Point_d LynarMoon::TextLayer::getSize(uint32_t id)
+{
+  std::shared_ptr<TextModule> text = this->TextList.get()->getElement(id);
+  std::string functionName = "TextLayer::getSize()";
+  LynarMath::_Point_d size = {0.0f, 0.0f};
+
+  if(text != nullptr) {
+    size = text.get()->getSize();
+  }
+  else {
+    this->errorHandler->output(LE_ID_NOEXIST, this->objectName, functionName + std::string(ERROR_ADD_ID_STR) + std::to_string(id));
+  }
+
+  return size;
+}
+
 double LynarMoon::TextLayer::getSizeFactor(uint32_t id)
 {
   std::shared_ptr<TextModule> text = this->TextList.get()->getElement(id);