add hyperlink to GitHub in the homepage for easier access to the project

This commit is contained in:
scawful
2025-04-16 19:06:01 -04:00
parent fa68ba9167
commit e7f976fcf0
3 changed files with 51 additions and 41 deletions

View File

@@ -51,29 +51,6 @@ std::string GetEditorName(EditorType type) {
} // namespace
void EditorManager::DrawRomSelector() {
absl::Status status;
SameLine((GetWindowWidth() / 2) - 100);
if (current_rom_ && current_rom_->is_loaded()) {
SetNextItemWidth(GetWindowWidth() / 6);
if (BeginCombo("##ROMSelector", current_rom_->short_name().c_str())) {
for (const auto &rom : roms_) {
if (MenuItem(rom->short_name().c_str())) {
status = SetCurrentRom(rom.get());
}
}
EndCombo();
}
if (!status.ok()) {
std::string error_message = status.message().data();
throw std::runtime_error(error_message);
}
} else {
Text("No ROM loaded");
}
}
constexpr const char *kOverworldEditorName = ICON_MD_LAYERS " Overworld Editor";
constexpr const char *kGraphicsEditorName = ICON_MD_PHOTO " Graphics Editor";
constexpr const char *kPaletteEditorName = ICON_MD_PALETTE " Palette Editor";
@@ -351,12 +328,17 @@ absl::Status EditorManager::Update() {
void EditorManager::DrawHomepage() {
TextWrapped("Welcome to the Yet Another Zelda3 Editor (yaze)!");
TextWrapped(
"This editor is designed to be a comprehensive tool for editing the "
"Legend of Zelda: A Link to the Past.");
"Comprehensive tool for editing the Legend of Zelda: A Link to the "
"Past.");
TextWrapped(
"The editor is still in development, so please report any bugs or issues "
"you encounter.");
// Hyperlink to github
if (gui::ClickableText("https://github.com/scawful/yaze")) {
gui::OpenUrl("https://github.com/scawful/yaze");
}
if (!current_rom_) {
TextWrapped("No ROM loaded.");
if (gui::ClickableText("Open a ROM")) {
@@ -410,6 +392,29 @@ void EditorManager::DrawHomepage() {
}
}
void EditorManager::DrawRomSelector() {
absl::Status status;
SameLine((GetWindowWidth() / 2) - 100);
if (current_rom_ && current_rom_->is_loaded()) {
SetNextItemWidth(GetWindowWidth() / 6);
if (BeginCombo("##ROMSelector", current_rom_->short_name().c_str())) {
for (const auto &rom : roms_) {
if (MenuItem(rom->short_name().c_str())) {
status = SetCurrentRom(rom.get());
}
}
EndCombo();
}
if (!status.ok()) {
std::string error_message = status.message().data();
throw std::runtime_error(error_message);
}
} else {
Text("No ROM loaded");
}
}
void EditorManager::DrawMenuBar() {
static bool show_display_settings = false;
static bool save_as_menu = false;
@@ -545,9 +550,6 @@ absl::Status EditorManager::LoadRom() {
manager.Save();
RETURN_IF_ERROR(LoadAssets());
// Show ROM info popup after loading
popup_manager_->Show("ROM Information");
return absl::OkStatus();
}

View File

@@ -192,35 +192,36 @@ void Paragraph(const std::string& text) {
bool ClickableText(const std::string& text) {
ImGui::BeginGroup();
ImGui::PushID(text.c_str());
// Calculate text size
ImVec2 text_size = ImGui::CalcTextSize(text.c_str());
// Get cursor position for hover detection
ImVec2 pos = ImGui::GetCursorScreenPos();
ImRect bb(pos, ImVec2(pos.x + text_size.x, pos.y + text_size.y));
// Add item
const ImGuiID id = ImGui::GetID(text.c_str());
bool result = false;
if (ImGui::ItemAdd(bb, id)) {
bool hovered = ImGui::IsItemHovered();
bool clicked = ImGui::IsItemClicked();
// Render text with appropriate color
ImVec4 color = hovered ? ImGui::GetStyleColorVec4(ImGuiCol_Text)
: ImGui::GetStyleColorVec4(ImGuiCol_TextLink);
ImGui::GetWindowDrawList()->AddText(pos, ImGui::ColorConvertFloat4ToU32(color), text.c_str());
: ImGui::GetStyleColorVec4(ImGuiCol_TextLink);
ImGui::GetWindowDrawList()->AddText(
pos, ImGui::ColorConvertFloat4ToU32(color), text.c_str());
result = clicked;
}
ImGui::PopID();
// Advance cursor past the text
ImGui::Dummy(text_size);
ImGui::EndGroup();
return result;
}
@@ -249,9 +250,9 @@ void ItemLabel(absl::string_view title, ItemLabelFlags flags) {
ImGui::ItemSize(textRect);
if (ImGui::ItemAdd(
textRect, window->GetID(title.data(), title.data() + title.size()))) {
ImGui::RenderTextEllipsis(
ImGui::GetWindowDrawList(), textRect.Min, textRect.Max, textRect.Max.x,
textRect.Max.x, title.data(), title.data() + title.size(), &textSize);
ImGui::RenderTextEllipsis(ImGui::GetWindowDrawList(), textRect.Min,
textRect.Max, textRect.Max.x, title.data(),
title.data() + title.size(), &textSize);
if (textRect.GetWidth() < textSize.x && ImGui::IsItemHovered())
ImGui::SetTooltip("%.*s", (int)title.size(), title.data());
@@ -414,5 +415,10 @@ void DrawMenu(Menu& menu) {
}
}
bool OpenUrl(const std::string& url) {
// Open the url in the default browser
return system(("open " + url).c_str()) == 0;
}
} // namespace gui
} // namespace yaze

View File

@@ -91,6 +91,8 @@ static Menu kMainMenu;
constexpr std::string kSeparator = "-";
IMGUI_API bool OpenUrl(const std::string &url);
} // namespace gui
} // namespace yaze