Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/modules/ui/UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,21 @@ void UI::renderImage (Texture* texture, int x, int y, int w, int h, int16_t angl
{
if (!texture || !texture->isValid())
return;
_frontend->setColor(color);
_frontend->renderImage(texture, x, y, w, h, angle, color[3]);
_frontend->resetColor();

if (w == -1)
w = texture->getWidth();
if (h == -1)
h = texture->getHeight();

_frontend->getTrimmed(texture, x, y, w, h);

const TextureRect& r = texture->getSourceRect();
const SDL_Rect srcRect { r.x, r.y, r.w, r.h };
const ImColor imcolor(color[0], color[1], color[2], color[3]);
const ImVec2 uvmin(srcRect.x / (float)texture->getFullWidth(), srcRect.y / (float)texture->getFullHeight());
const ImVec2 uvmax((srcRect.x + srcRect.w) / (float)texture->getFullWidth(), (srcRect.y + srcRect.h) / (float)texture->getFullHeight());
const ImTextureID texId = (ImTextureID)_frontend->getTextureData(texture);
ImGui::GetWindowDrawList()->AddImage(texId, ImVec2(x, y), ImVec2(x + w, y + h), uvmin, uvmax, imcolor);
}

void UI::update (uint32_t deltaTime)
Expand Down
5 changes: 3 additions & 2 deletions src/modules/ui/nodes/IUINodeMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ void IUINodeMap::onWindowResize ()

void IUINodeMap::render (int x, int y) const
{
renderFilledRect(getRenderX(), getRenderY(), getRenderWidth(), getRenderHeight(), colorBlack);
if (_map.isActive())
// renderFilledRect(getRenderX(), getRenderY(), getRenderWidth(), getRenderHeight(), colorBlack);
if (_map.isActive()) {
_map.render();
}
UINode::render(0, 0);

if (_map.isStarted())
Expand Down
12 changes: 6 additions & 6 deletions src/modules/ui/nodes/UINode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,22 +394,22 @@ bool UINode::renderDebug (int x, int y, int textY, bool& focusHandled) const
void UINode::renderRect (int x, int y, int w, int h, const Color& color) const
{
const float alpha = fequals(_alpha, 1.0f) ? color[3] : _alpha;
const Color alphaColor = { color[0], color[1], color[2], alpha };
_frontend->renderRect(x, y, w, h, alphaColor);
const ImVec4 alphaColor = { color[0], color[1], color[2], alpha };
ImGui::GetWindowDrawList()->AddRect(ImVec2(x, y), ImVec2(x + w, y + h), ImColor(alphaColor));
}

void UINode::renderFilledRect (int x, int y, int w, int h, const Color& color) const
{
const float alpha = fequals(_alpha, 1.0f) ? color[3] : _alpha;
const Color alphaColor = { color[0], color[1], color[2], alpha };
_frontend->renderFilledRect(x, y, w, h, alphaColor);
const ImVec4 alphaColor = { color[0], color[1], color[2], alpha };
ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(x, y), ImVec2(x + w, y + h), ImColor(alphaColor));
}

void UINode::renderLine (int x1, int y1, int x2, int y2, const Color& color) const
{
const float alpha = fequals(_alpha, 1.0f) ? color[3] : _alpha;
const Color alphaColor = { color[0], color[1], color[2], alpha };
_frontend->renderLine(x1, y1, x2, y2, alphaColor);
const ImVec4 alphaColor = { color[0], color[1], color[2], alpha };
ImGui::GetWindowDrawList()->AddLine(ImVec2(x1, y1), ImVec2(x2, y2), ImColor(alphaColor));
}

void UINode::renderImage (const TexturePtr& texture, int x, int y, int w, int h, float alpha) const
Expand Down