Whatever The Fuck Man
This commit is contained in:
@@ -7,8 +7,9 @@ using namespace game::util;
|
||||
|
||||
namespace game::state::select
|
||||
{
|
||||
void Characters::update(Resources& resources, int& characterIndex)
|
||||
bool Characters::update(Resources& resources, int& characterIndex)
|
||||
{
|
||||
auto isRefreshed = false;
|
||||
auto& style = ImGui::GetStyle();
|
||||
auto viewport = ImGui::GetMainViewport();
|
||||
|
||||
@@ -27,6 +28,19 @@ namespace game::state::select
|
||||
{
|
||||
if (WIDGET_FX(ImGui::BeginTabItem("Characters")))
|
||||
{
|
||||
if (ImGui::BeginPopupContextWindow("characters-context", ImGuiPopupFlags_MouseButtonRight))
|
||||
{
|
||||
if (ImGui::MenuItem("Refresh"))
|
||||
{
|
||||
resources.characters_refresh();
|
||||
characterIndex = resources.characterPreviews.empty()
|
||||
? -1
|
||||
: std::clamp(characterIndex, 0, (int)resources.characterPreviews.size() - 1);
|
||||
isRefreshed = true;
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
auto cursorPos = ImGui::GetCursorPos();
|
||||
auto cursorStartX = ImGui::GetCursorPosX();
|
||||
|
||||
@@ -34,25 +48,26 @@ namespace game::state::select
|
||||
|
||||
for (int i = 0; i < (int)resources.characterPreviews.size(); i++)
|
||||
{
|
||||
auto& character = resources.characterPreviews[i];
|
||||
auto* character = resources.characterPreviews[i].root();
|
||||
if (!character) continue;
|
||||
ImGui::PushID(i);
|
||||
|
||||
ImGui::SetCursorPos(cursorPos);
|
||||
imgui::style::color_set(character.color);
|
||||
imgui::style::color_set(character->color);
|
||||
|
||||
auto isSelected = i == characterIndex;
|
||||
|
||||
if (isSelected) ImGui::PushStyleColor(ImGuiCol_FrameBg, ImGui::GetStyleColorVec4(ImGuiCol_FrameBgHovered));
|
||||
|
||||
if (character.portrait.is_valid())
|
||||
if (character->portrait.is_valid())
|
||||
{
|
||||
if (WIDGET_FX(ImGui::ImageButton(character.name.c_str(), character.portrait.id, buttonSize)))
|
||||
if (WIDGET_FX(ImGui::ImageButton(character->name.c_str(), character->portrait.texture.id, buttonSize)))
|
||||
characterIndex = i;
|
||||
}
|
||||
else if (WIDGET_FX(ImGui::Button(character.name.c_str(), buttonSize)))
|
||||
else if (WIDGET_FX(ImGui::Button(character->name.c_str(), buttonSize)))
|
||||
characterIndex = i;
|
||||
if (isSelected) ImGui::PopStyleColor();
|
||||
ImGui::SetItemTooltip("%s", character.name.c_str());
|
||||
ImGui::SetItemTooltip("%s", character->name.c_str());
|
||||
|
||||
auto increment = ImGui::GetItemRectSize().x + ImGui::GetStyle().ItemSpacing.x;
|
||||
cursorPos.x += increment;
|
||||
@@ -64,7 +79,7 @@ namespace game::state::select
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
imgui::style::color_set(resources.settings.color);
|
||||
imgui::style::color_set(resources.settings.root()->color);
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
@@ -78,5 +93,6 @@ namespace game::state::select
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
return isRefreshed;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user