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
98 changes: 97 additions & 1 deletion src/components/bottombar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#endif
#include <format>
#include <util.h>
#include <renderer.h>

using namespace ImGui;

Expand Down Expand Up @@ -78,9 +79,104 @@ const void RenderBottomNavBar(const char* identifier, float xPos, std::function<

const float buttonPos = GetCursorPosY();

SetCursorPosX(xPos + GetCursorPosX() + GetContentRegionAvail().x - FooterContainerWidth);
SetCursorPosX(xPos + GetCursorPosX() + GetContentRegionAvail().x - FooterContainerWidth - ScaleX(55));
SetCursorPosY(GetCursorPosY() + ScaleY(10));

// ── Language button ────────────────────────────────────────────────
Image((ImTextureID)(intptr_t)languageIconTexture, ImVec2(ScaleX(30), ScaleY(30)));

static bool isLangButtonHovered = false;
float langTooltipAlpha = EaseInOutFloat(std::format("##LangTooltipAlpha{}", identifier).c_str(), 0.f, 1.f, isLangButtonHovered, 0.3f);

if (langTooltipAlpha != 0.f) {
SetMouseCursor(ImGuiMouseCursor_Hand);
PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f);
PushStyleColor(ImGuiCol_Border, ImVec4(0.18f, 0.184f, 0.192f, 1.0f));
PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(ScaleX(10), ScaleY(10)));
PushStyleVar(ImGuiStyleVar_WindowRounding, 6);
PushStyleVar(ImGuiStyleVar_Alpha, langTooltipAlpha);
PushStyleColor(ImGuiCol_PopupBg, ImVec4(0.098f, 0.102f, 0.11f, 1.0f));
SetTooltip("%s", Locale::Get("tooltipLanguage"));
PopStyleVar(4);
PopStyleColor(3);
}

if (IsItemClicked())
OpenPopup("##LangPopup");

isLangButtonHovered = IsItemHovered() || (IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) && IsMouseDown(ImGuiMouseButton_Left));

// ── Language popup ─────────────────────────────────────────────────
{
ImGuiIO& io = GetIO();
ImFont* vietItemFont = (io.Fonts->Fonts.Size > 2) ? io.Fonts->Fonts[2] : nullptr;
ImFont* dropdownFont = (io.Fonts->Fonts.Size > 3) ? io.Fonts->Fonts[3] : nullptr;

const auto& langs = Locale::GetAvailableLanguages();
const std::string& currentLangId = Locale::GetCurrentLanguageId();

const float popupWidth = ScaleX(400);
const float popupHeight = ScaleY(500);
float anim = EaseInOutFloat("##LangPopupAnim", 0.f, 1.f, IsPopupOpen("##LangPopup"), 0.35f);

const float popupBtnY = viewport->Size.y - BottomNavBarHeight;
float popupY = popupBtnY - popupHeight + ScaleY(6) * (1.f - anim);
SetNextWindowPos({ viewport->Size.x - popupWidth - ScaleX(50), popupY });
SetNextWindowSize({ popupWidth, popupHeight });
SetNextWindowBgAlpha(anim);

PushStyleColor(ImGuiCol_PopupBg, ImVec4(0.098f, 0.102f, 0.11f, 1.0f));
PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
PushStyleColor(ImGuiCol_Header, ImVec4(0.15f, 0.155f, 0.165f, 1.0f));
PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(0.22f, 0.225f, 0.235f, 1.0f));
PushStyleColor(ImGuiCol_Border, ImVec4(0.18f, 0.184f, 0.192f, 1.0f));
PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(ScaleX(10), ScaleY(10)));
PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(ScaleX(8), ScaleY(6)));
PushStyleVar(ImGuiStyleVar_PopupRounding, ScaleX(6));

if (dropdownFont)
PushFont(dropdownFont);

if (BeginPopup("##LangPopup", ImGuiWindowFlags_NoMove)) {
if (!::IsWindowFocused())
CloseCurrentPopup();
PushStyleVar(ImGuiStyleVar_Alpha, anim);
for (const auto& lang : langs) {
bool isSelected = (lang.id == currentLangId);
bool useVietFont = (lang.id == "vietnamese") && (vietItemFont != nullptr);
if (useVietFont) {
if (dropdownFont)
PopFont();
PushFont(vietItemFont);
}
if (Selectable(lang.displayName.c_str(), isSelected, 0, ImVec2(popupWidth, 0))) {
Locale::SetLanguage(lang.id);
RequestFontRebuild();
CloseCurrentPopup();
}
if (isSelected)
SetItemDefaultFocus();
if (useVietFont) {
PopFont();
if (dropdownFont)
PushFont(dropdownFont);
}
}
PopStyleVar();
EndPopup();
}

if (dropdownFont)
PopFont();

PopStyleVar(3);
PopStyleColor(5);
}

SameLine(0, ScaleX(25));
SetCursorPosY(GetCursorPosY() - ScaleY(15));

Image((ImTextureID)(intptr_t)discordIconTexture, ImVec2(ScaleX(30), ScaleY(30)));

static bool isDiscordButtonHovered = false;
Expand Down
4 changes: 4 additions & 0 deletions src/components/titlebar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,14 @@ bool RenderTitleBarComponent(std::shared_ptr<RouterNav> router)
if (isLangButtonHovered)
PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.f, 1.f, 1.f, 0.06f));

/* Commented out — language icon moved to bottom bar (bottombar.cc)
BeginChild("##LangButton", { langButtonDimensions.x, langButtonDimensions.y }, false, ImGuiWindowFlags_NoScrollbar);
{
SetCursorPos({ (langButtonDimensions.x - ScaleX(20)) * 0.5f, ScaleY(12) });
Image((ImTextureID)(intptr_t)languageIconTexture, { ScaleX(20), ScaleY(20) });
}
EndChild();
*/

ImVec2 langBtnMin = GetItemRectMin();
ImVec2 langBtnMax = GetItemRectMax();
Expand All @@ -137,6 +139,7 @@ bool RenderTitleBarComponent(std::shared_ptr<RouterNav> router)

isLangButtonHovered = IsItemHovered();

/*Migrate to BottomBar
ImGuiIO& io = GetIO();
ImFont* vietItemFont = (io.Fonts->Fonts.Size > 2) ? io.Fonts->Fonts[2] : nullptr;
ImFont* dropdownFont = (io.Fonts->Fonts.Size > 3) ? io.Fonts->Fonts[3] : nullptr;
Expand Down Expand Up @@ -198,6 +201,7 @@ bool RenderTitleBarComponent(std::shared_ptr<RouterNav> router)
PopStyleVar(3);
PopStyleColor(4);

*/
SetCursorPos({ viewport->Size.x - closeButtonDimensions.x, 0 });

PushStyleVar(ImGuiStyleVar_ChildRounding, 0);
Expand Down
3 changes: 2 additions & 1 deletion src/locales/brazilian.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Entrar no servidor Discord",
"tooltipGithub": "Ver código-fonte"
"tooltipGithub": "Ver código-fonte",
"tooltipLanguage": "Mudar Idioma"
}
3 changes: 2 additions & 1 deletion src/locales/bulgarian.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Присъединете се към Discord сървъра",
"tooltipGithub": "Вижте изходния код"
"tooltipGithub": "Вижте изходния код",
"tooltipLanguage": "Смяна на език"
}
3 changes: 2 additions & 1 deletion src/locales/danish.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Tilmeld Discord-serveren",
"tooltipGithub": "Se kildekode"
"tooltipGithub": "Se kildekode",
"tooltipLanguage": "Skift Sprog"
}
3 changes: 2 additions & 1 deletion src/locales/dutch.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Discord-server joinen",
"tooltipGithub": "Broncode bekijken"
"tooltipGithub": "Broncode bekijken",
"tooltipLanguage": "Taal Wijzigen"
}
3 changes: 2 additions & 1 deletion src/locales/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Join Discord Server",
"tooltipGithub": "View Source Code"
"tooltipGithub": "View Source Code",
"tooltipLanguage": "Change Language"
}
3 changes: 2 additions & 1 deletion src/locales/french.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Rejoindre le serveur Discord",
"tooltipGithub": "Voir le code source"
"tooltipGithub": "Voir le code source",
"tooltipLanguage": "Changer de Langue"
}
3 changes: 2 additions & 1 deletion src/locales/german.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Discord-Server beitreten",
"tooltipGithub": "Quellcode ansehen"
"tooltipGithub": "Quellcode ansehen",
"tooltipLanguage": "Sprache Ändern"
}
3 changes: 2 additions & 1 deletion src/locales/hungarian.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Csatlakozás a Discord-szerverhez",
"tooltipGithub": "Forráskód megtekintése"
"tooltipGithub": "Forráskód megtekintése",
"tooltipLanguage": "Nyelv Váltása"
}
3 changes: 2 additions & 1 deletion src/locales/indonesian.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Bergabung dengan Server Discord",
"tooltipGithub": "Lihat Kode Sumber"
"tooltipGithub": "Lihat Kode Sumber",
"tooltipLanguage": "Ganti Bahasa"
}
3 changes: 2 additions & 1 deletion src/locales/italian.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Unisciti al server Discord",
"tooltipGithub": "Vedi il codice sorgente"
"tooltipGithub": "Vedi il codice sorgente",
"tooltipLanguage": "Cambia Lingua"
}
3 changes: 2 additions & 1 deletion src/locales/japanese.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Discord サーバーに参加",
"tooltipGithub": "ソースコードを見る"
"tooltipGithub": "ソースコードを見る",
"tooltipLanguage": "言語を変更"
}
3 changes: 2 additions & 1 deletion src/locales/koreana.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Discord 서버 참가",
"tooltipGithub": "소스 코드 보기"
"tooltipGithub": "소스 코드 보기",
"tooltipLanguage": "언어 변경"
}
3 changes: 2 additions & 1 deletion src/locales/latam.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Unirse al servidor de Discord",
"tooltipGithub": "Ver código fuente"
"tooltipGithub": "Ver código fuente",
"tooltipLanguage": "Cambiar Idioma"
}
3 changes: 2 additions & 1 deletion src/locales/polish.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Dołącz do serwera Discord",
"tooltipGithub": "Zobacz kod źródłowy"
"tooltipGithub": "Zobacz kod źródłowy",
"tooltipLanguage": "Zmień Język"
}
3 changes: 2 additions & 1 deletion src/locales/russian.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Присоединиться к Discord",
"tooltipGithub": "Посмотреть исходный код"
"tooltipGithub": "Посмотреть исходный код",
"tooltipLanguage": "Сменить Язык"
}
3 changes: 2 additions & 1 deletion src/locales/schinese.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "加入 Discord 服务器",
"tooltipGithub": "查看源代码"
"tooltipGithub": "查看源代码",
"tooltipLanguage": "修改语言"
}
3 changes: 2 additions & 1 deletion src/locales/spanish.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Unirse al servidor de Discord",
"tooltipGithub": "Ver código fuente"
"tooltipGithub": "Ver código fuente",
"tooltipLanguage": "Cambiar Idioma"
}
3 changes: 2 additions & 1 deletion src/locales/swedish.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Gå med i Discord-servern",
"tooltipGithub": "Visa källkod"
"tooltipGithub": "Visa källkod",
"tooltipLanguage": "Ändra Språk"
}
3 changes: 2 additions & 1 deletion src/locales/tchinese.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "加入 Discord 伺服器",
"tooltipGithub": "檢視原始碼"
"tooltipGithub": "檢視原始碼",
"tooltipLanguage": "修改語言"
}
3 changes: 2 additions & 1 deletion src/locales/turkish.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Discord Sunucusuna Katıl",
"tooltipGithub": "Kaynak Kodunu Görüntüle"
"tooltipGithub": "Kaynak Kodunu Görüntüle",
"tooltipLanguage": "Dili Değiştir"
}
3 changes: 2 additions & 1 deletion src/locales/ukrainian.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Приєднатися до Discord",
"tooltipGithub": "Переглянути вихідний код"
"tooltipGithub": "Переглянути вихідний код",
"tooltipLanguage": "Змінити Мову"
}
3 changes: 2 additions & 1 deletion src/locales/vietnamese.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"titlebarTitle": "Steam Homebrew",

"tooltipDiscord": "Tham gia máy chủ Discord",
"tooltipGithub": "Xem mã nguồn"
"tooltipGithub": "Xem mã nguồn",
"tooltipLanguage": "Đổi Ngôn Ngữ"
}