Added reasons to assertions
This commit is contained in:
@ -40,7 +40,7 @@ void UICanvas::rebufferShaderParameters() {
|
||||
break;
|
||||
|
||||
default:
|
||||
assertUnreachable();
|
||||
assertUnreachable("UICanvas::rebufferShaderParameters: Unknown draw type");
|
||||
}
|
||||
|
||||
this->shaderBuffer.buffer(&data);
|
||||
|
@ -25,7 +25,7 @@ UIComponentDimensional * UIComponent::getParentDimensional() {
|
||||
auto parent = this->transform->getParent();
|
||||
if(parent == nullptr) return nullptr;
|
||||
auto dimensional = parent->item->getComponent<UIComponentDimensional>();
|
||||
assertNotNull(dimensional);
|
||||
assertNotNull(dimensional, "UIComponent::getParentDimensional: Parent must have a UIComponentDimensional");
|
||||
return dimensional;
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ void UIComponent::updateAlignment() {
|
||||
auto dimensional = this->getParentDimensional();
|
||||
auto translate = this->transform->getLocalPosition();
|
||||
|
||||
assertNotNull(dimensional);
|
||||
assertNotNull(dimensional, "UIComponent::updateAlignment: Parent must have a UIComponentDimensional");
|
||||
|
||||
parentInnerWidth = dimensional->getContentWidth();
|
||||
parentInnerHeight = dimensional->getContentHeight();
|
||||
@ -89,8 +89,8 @@ void UIComponent::calculateDimensions(
|
||||
float_t innerSize,
|
||||
glm::vec2 alignment
|
||||
) {
|
||||
assertNotNull(position);
|
||||
assertNotNull(size);
|
||||
assertNotNull(position, "UIComponent::calculateDimensions: Position cannot be null");
|
||||
assertNotNull(size, "UIComponent::calculateDimensions: Size cannot be null");
|
||||
|
||||
switch(align) {
|
||||
case UI_COMPONENT_ALIGN_STRETCH: {
|
||||
@ -157,7 +157,7 @@ void UIComponent::calculateDimensions(
|
||||
}
|
||||
|
||||
default:
|
||||
assertUnreachable();
|
||||
assertUnreachable("UIComponent::calculateDimensions: Unknown alignment");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -170,7 +170,7 @@ UICanvas * UIComponent::getCanvas() {
|
||||
if(canvas != nullptr) return canvas;
|
||||
parent = parent->getParent();
|
||||
}
|
||||
assertUnreachable();
|
||||
assertUnreachable("UIComponent::getCanvas: No canvas found");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,8 @@ std::vector<SceneItemComponent*> UISimpleMenu::getDependencies() {
|
||||
void UISimpleMenu::onStart() {
|
||||
if(canvas == nullptr) canvas = getScene()->findComponent<UICanvas>();
|
||||
|
||||
assertNotNull(this->menu);
|
||||
assertNotNull(this->canvas);
|
||||
assertNotNull(this->menu, "UISimpleMenu::onStart: Menu cannot be null");
|
||||
assertNotNull(this->canvas, "UISimpleMenu::onStart: Canvas cannot be null");
|
||||
menuItems = this->item->findChildren<UISimpleMenuItem>();
|
||||
|
||||
auto updateSimpleMenuPos = [&](int32_t x, int32_t y) {
|
||||
@ -59,7 +59,7 @@ void UISimpleMenu::onStart() {
|
||||
}, menu->eventItemSelected);
|
||||
|
||||
useEvent([&](float_t d){
|
||||
assertNotNull(canvas->camera);
|
||||
assertNotNull(canvas->camera, "UISimpleMenu::onStart: Camera cannot be null");
|
||||
if(!this->menu->active) return;
|
||||
|
||||
// Mouse in screen space.
|
||||
@ -121,7 +121,7 @@ void UISimpleMenu::onStart() {
|
||||
}
|
||||
|
||||
default: {
|
||||
assertUnreachable();
|
||||
assertUnreachable("UISimpleMenu::onStart: Draw type not implemented");
|
||||
}
|
||||
}
|
||||
}, getScene()->eventSceneUnpausedUpdate);
|
||||
|
@ -72,7 +72,7 @@ std::vector<struct ShaderPassItem> UILabel::getUIRenderPasses() {
|
||||
break;
|
||||
|
||||
default:
|
||||
assertUnreachable();
|
||||
assertUnreachable("UILabel::getUIRenderPasses: Texture slot not implemented");
|
||||
}
|
||||
|
||||
item.textureSlots[it->second] = &it->first->texture;
|
||||
@ -119,7 +119,7 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
||||
return;
|
||||
}
|
||||
|
||||
assertTrue(newTexts.size() <= FONT_SHADER_PARTS_MAX);
|
||||
assertTrue(newTexts.size() <= FONT_SHADER_PARTS_MAX, "UILabel::rebufferQuads: Too many parts (not supported)");
|
||||
|
||||
int32_t nextTexture = 0;
|
||||
glm::vec2 position(0, 0);
|
||||
@ -161,17 +161,17 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
||||
realText.style = text.style;
|
||||
|
||||
// Lock the font
|
||||
assertNotNull(text.style.font);
|
||||
assertNotNull(text.style.font, "UILabel::rebufferQuads: Font cannot be null");
|
||||
realText.lockId = text.style.font->lock(TrueTypeFaceTextureStyle{
|
||||
text.style.size,
|
||||
text.style.style
|
||||
});
|
||||
assertTrue(realText.lockId != -1);
|
||||
assertTrue(realText.lockId != -1, "UILabel::rebufferQuads: Failed to lock font");
|
||||
realText.texture = text.style.font->getTexture(realText.lockId);
|
||||
|
||||
// Map texture
|
||||
if(textureMap.find(realText.texture) == textureMap.end()) {
|
||||
assertTrue(nextTexture < FONT_SHADER_TEXTURE_MAX);
|
||||
assertTrue(nextTexture < FONT_SHADER_TEXTURE_MAX, "UILabel::rebufferQuads: Too many textures (not supported)");
|
||||
textureMap[realText.texture] = nextTexture++;
|
||||
}
|
||||
|
||||
@ -252,10 +252,10 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
||||
}
|
||||
|
||||
// Validate characters
|
||||
assertTrue(ch >= TRUE_TYPE_CHAR_BEGIN && ch < TRUE_TYPE_CHAR_END);
|
||||
assertTrue(ch != '\r');
|
||||
assertTrue(ch != '\t');
|
||||
assertTrue(ch != '\n');
|
||||
assertTrue(ch >= TRUE_TYPE_CHAR_BEGIN && ch < TRUE_TYPE_CHAR_END, "UILabel::rebufferQuads: Character out of range");
|
||||
assertTrue(ch != '\r', "UILabel::rebufferQuads: Character cannot be a carriage return");
|
||||
assertTrue(ch != '\t', "UILabel::rebufferQuads: Character cannot be a tab");
|
||||
assertTrue(ch != '\n', "UILabel::rebufferQuads: Character cannot be a newline");
|
||||
|
||||
// Get font data.
|
||||
auto charInfo = realText.texture->getCharacterData(ch);
|
||||
@ -357,7 +357,7 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
||||
);
|
||||
|
||||
if(hasDecorations) {
|
||||
assertTrue(vertices.size() == decorations.size());
|
||||
assertTrue(vertices.size() == decorations.size(), "UILabel::rebufferQuads: Decoration count mismatch");
|
||||
this->meshDecorations.createBuffers(
|
||||
QUAD_VERTICE_COUNT * decorations.size(),
|
||||
QUAD_INDICE_COUNT * decorations.size()
|
||||
@ -408,8 +408,8 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
||||
// Finally, release the old locks
|
||||
itText = textsBuffered.begin();
|
||||
while(itText != textsBuffered.end()) {
|
||||
assertTrue(itText->lockId != -1);
|
||||
assertNotNull(itText->style.font);
|
||||
assertTrue(itText->lockId != -1, "UILabel::rebufferQuads: Lock ID cannot be -1");
|
||||
assertNotNull(itText->style.font, "UILabel::rebufferQuads: Font cannot be null");
|
||||
itText->style.font->unlock(itText->lockId);
|
||||
++itText;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ void UIRichTextLabel::onStart() {
|
||||
bufferTexts.push_back(text);
|
||||
} else if(child.nodeType == XML_NODE_TYPE_ELEMENT) {
|
||||
auto node = child.child;
|
||||
assertTrue(node->node == "font");
|
||||
assertTrue(node->node == "font", "UIRichTextLabel::onStart: Unknown node type '" + node->node + "'");
|
||||
|
||||
struct UILabelStyle style;
|
||||
if(node->attributes.contains("font")) {
|
||||
|
Reference in New Issue
Block a user