Skip to content

Commit 74570e1

Browse files
committed
handle missing icon for widget
1 parent 9dfd321 commit 74570e1

6 files changed

+27
-13
lines changed

src/Core/RadialContext.cpp

+15-3
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,6 @@ void CRadialContext::RenderWidget()
541541
{
542542
if (this->QueuedItem == nullptr && !this->IsEditingWidget) { return; }
543543

544-
static Texture* icon = APIDefs->Textures.Get("ICON_GENERIC");
545-
546544
ImGuiStyle& style = ImGui::GetStyle();
547545

548546
float sz = 52.0f * NexusLink->Scaling;
@@ -597,6 +595,9 @@ void CRadialContext::RenderWidget()
597595
drawList->AddLine(circle[amtTotal - 1], circle[0], color, thickness);
598596
}
599597

598+
bool useFallback = this->QueuedItem->Icon.Type == EIconType::None || this->QueuedItem->Icon.Value.empty();
599+
Texture* icon = !useFallback ? this->QueuedItem->Icon.Texture : this->WidgetFallbackIcon;
600+
600601
if (icon)
601602
{
602603
ImVec2 iconSize = isHovered ? ImVec2(sz * 1.2f, sz * 1.2f) : ImVec2(sz, sz);
@@ -608,6 +609,7 @@ void CRadialContext::RenderWidget()
608609
float diff = (iconSize.x - sz) / 2.0f;
609610
iconPos = ImVec2(iconPos.x - diff, iconPos.y - diff);
610611
}
612+
611613
if (this->WidgetBase)
612614
{
613615
ImGui::SetCursorPos(iconPos);
@@ -619,7 +621,7 @@ void CRadialContext::RenderWidget()
619621
}
620622

621623
ImGui::SetCursorPos(iconPos);
622-
ImGui::Image(this->QueuedItem ? this->QueuedItem->Icon.Texture->Resource : icon->Resource, iconSize);
624+
ImGui::Image(icon->Resource, iconSize);
623625

624626
if (isEditing)
625627
{
@@ -644,6 +646,16 @@ void CRadialContext::RenderWidget()
644646
}
645647
}
646648
}
649+
else
650+
{
651+
if (!icon && !useFallback)
652+
{
653+
this->QueuedItem->Icon.Type = EIconType::None;
654+
this->QueuedItem->Icon.Value = {};
655+
}
656+
657+
this->WidgetFallbackIcon = APIDefs->Textures.GetOrCreateFromResource("ICON_RADIALWIDGET_FALLBACK", ICON_FALLBACK, SelfModule);
658+
}
647659
}
648660
ImGui::End();
649661
}

src/Core/RadialContext.h

+11-10
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
class CRadialContext
2424
{
2525
public:
26-
bool IsLeftClickHeld = false;
27-
bool IsRightClickHeld = false;
26+
bool IsLeftClickHeld = false;
27+
bool IsRightClickHeld = false;
2828

2929
///----------------------------------------------------------------------------------------------------
3030
/// ctor
@@ -64,19 +64,20 @@ class CRadialContext
6464
std::mutex Mutex;
6565
std::vector<CRadialMenu*> Radials;
6666
std::map<std::string, CRadialMenu*> RadialIBMap;
67-
CRadialMenu* ActiveRadial = nullptr;
67+
CRadialMenu* ActiveRadial = nullptr;
6868

6969
/* Queued Item */
7070
std::mutex QueuedItemMutex;
71-
bool IsCanceled = false;
72-
RadialItem* QueuedItem = nullptr;
73-
int QueuedElapsedTime = 0;
74-
Texture* WidgetBase = nullptr;
71+
bool IsCanceled = false;
72+
RadialItem* QueuedItem = nullptr;
73+
int QueuedElapsedTime = 0;
74+
Texture* WidgetBase = nullptr;
75+
Texture* WidgetFallbackIcon = nullptr;
7576

7677
/* Editor */
77-
CRadialMenu* EditingMenu = nullptr;
78-
RadialItem* EditingItem = nullptr;
79-
bool IsEditingWidget = false;
78+
CRadialMenu* EditingMenu = nullptr;
79+
RadialItem* EditingItem = nullptr;
80+
bool IsEditingWidget = false;
8081

8182
void RenderEditorTab();
8283
void RenderSettingsTab();

src/GW2-RadialMenus.rc

128 Bytes
Binary file not shown.
3.75 KB
Loading
2.59 KB
Loading

src/resource.h

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#define ICON_SIEGETURTLE 308
3737

3838
#define TEX_WIDGET_BASE 400
39+
#define ICON_FALLBACK 401
3940

4041
// Next default values for new objects
4142
//

0 commit comments

Comments
 (0)