Beatmup
Beatmup::Scene::SceneIntegrityError Class Reference

#include <scene.h>

Inheritance diagram for Beatmup::Scene::SceneIntegrityError:
Beatmup::Exception

Public Member Functions

 SceneIntegrityError (const std::string reason, const Scene &scene)
 
- Public Member Functions inherited from Beatmup::Exception
virtual const char * what () const NOEXCEPT override
 

Private Member Functions

std::string getSceneLog (const Scene &scene, const std::string prefix, int recursionLeft=100) const
 

Additional Inherited Members

- Protected Member Functions inherited from Beatmup::Exception
 Exception (const char *message)
 
template<typename ... Args>
 Exception (const char *message, const Args &... args)
 

Detailed Description

Definition at line 52 of file scene.h.

Constructor & Destructor Documentation

◆ SceneIntegrityError()

Scene::SceneIntegrityError::SceneIntegrityError ( const std::string  reason,
const Scene scene 
)

Definition at line 91 of file scene.cpp.

91  :
92  Exception( (std::string(reason) + "\n" + getSceneLog(scene, "")).c_str() )
93 {}
Exception(const char *message)
Definition: exception.h:41
std::string getSceneLog(const Scene &scene, const std::string prefix, int recursionLeft=100) const
Definition: scene.cpp:30
return $pool getJavaReference & scene(index)

Member Function Documentation

◆ getSceneLog()

std::string Scene::SceneIntegrityError::getSceneLog ( const Scene scene,
const std::string  prefix,
int  recursionLeft = 100 
) const
private

Definition at line 30 of file scene.cpp.

30  {
31  std::string log = prefix + "Scene has " + std::to_string(scene.getLayerCount()) + " layers\n";
32  const int N = scene.getLayerCount();
33  for (int i = 0; i < N; i++) {
34  Layer& layer = scene.getLayer(i);
35  log += prefix + "\t" + layer.getName() + " [";
36  switch (layer.getType()) {
38  log += "bitmap";
39  BitmapLayer& casted = layer.castTo<BitmapLayer&>();
40  if (!casted.getBitmap())
41  log += ", no bitmap";
42  else
43  log += ", " + casted.getBitmap()->toString();
44  }
45  break;
46 
48  log += "masked bitmap";
49  MaskedBitmapLayer& casted = layer.castTo<MaskedBitmapLayer&>();
50  if (!casted.getBitmap())
51  log += ", no bitmap";
52  else
53  log += ", bitmap " + casted.getBitmap()->toString();
54  if (!casted.getMask())
55  log += ", no mask";
56  else
57  log += ", mask " + casted.getMask()->toString();
58  }
59  break;
60 
62  log += "bitmap";
63  BitmapLayer& casted = layer.castTo<BitmapLayer&>();
64  if (!casted.getBitmap())
65  log += ", no content";
66  else
67  log += ", " + casted.getBitmap()->toString();
68  }
69  break;
70 
72  log += "shader";
73  break;
74 
76  log += "scene";
77  break;
78  }
79  if (layer.isPhantom())
80  log += ", phantom";
81  log += "]\n";
83  if (recursionLeft > 0)
84  log += getSceneLog(scene, prefix + "\t", recursionLeft - 1);
85  }
86  }
87  return log;
88 }
@ SceneLayer
layer containing a scene
@ MaskedBitmapLayer
layer displaying a bitmap with mask
@ ShadedBitmapLayer
layer displaying a bitmap through a custom fragment shader
@ BitmapLayer
layer displaying a bitmap
@ ShapedBitmapLayer
layer displaying a bitmap within a shape
Type getType() const
Definition: scene.h:92
const std::string & getName() const
Definition: scene.h:94
bool isPhantom() const
Returns true if the layer is ignored when searching a layer by point.
Definition: scene.h:119
LayerType & castTo() const
Definition: scene.h:132
std::string to_string(Beatmup::NNets::ActivationFunction function)
Beatmup::Scene::Layer * layer

The documentation for this class was generated from the following files: