Skip to content

Commit

Permalink
editor: add about menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
barsoosayque committed Dec 1, 2024
1 parent 5010ddc commit 8e6679e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
3 changes: 3 additions & 0 deletions crates/opensi-editor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition.workspace = true
license.workspace = true
version.workspace = true
rust-version.workspace = true
description = "Open-source editor for the popular TV game"
homepage = "opensi.github.io/opensi-editor"
repository = "https://github.com/opensi/opensi-editor"

[dependencies]
opensi-core = { version = "*", path = "../opensi-core" }
Expand Down
46 changes: 45 additions & 1 deletion crates/opensi-editor/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod round_tab;
mod theme_tab;
mod workarea;

use itertools::Itertools;
use opensi_core::prelude::*;

use crate::app::file_dialogs::LoadingPackageReceiver;
Expand Down Expand Up @@ -78,6 +79,42 @@ impl eframe::App for EditorApp {
});
});

let authors_modal =
egui_modal::Modal::new(ctx, "authors-modal").with_close_on_outside_click(true);
authors_modal.show(|ui| {
authors_modal.title(ui, "🎓 OpenSI Editor");
authors_modal.frame(ui, |ui| {
ui.horizontal(|ui| {
ui.strong("Авторы:");
let authors = env!("CARGO_PKG_AUTHORS").split(":").join(", ");
ui.label(authors);
});

ui.horizontal(|ui| {
ui.strong("Версия:");
let version = env!("CARGO_PKG_VERSION");
ui.code(format!("v{version}"));
});

ui.horizontal(|ui| {
ui.strong("Репозиторий:");
let url = env!("CARGO_PKG_REPOSITORY");
let short_url = url.trim_start_matches("https://github.com/");
ui.hyperlink_to(format!(" {short_url}"), url);
});

ui.separator();

ui.horizontal(|ui| {
ui.weak("Сделано с помощью");
ui.hyperlink_to("egui", "https://github.com/emilk/egui");
});
});
authors_modal.buttons(ui, |ui| {
authors_modal.button(ui, "Закрыть");
});
});

egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
egui::menu::bar(ui, |ui| {
egui::widgets::global_theme_preference_switch(ui);
Expand Down Expand Up @@ -120,12 +157,19 @@ impl eframe::App for EditorApp {
});
if let PackageState::Active { .. } = self.package_state {
ui.menu_button("Пак", |ui| {
if ui.button("❌Закрыть").clicked() {
if ui.button("❌ Закрыть").clicked() {
self.package_state = PackageState::None;
ui.close_menu();
}
});
}

ui.menu_button("Справка", |ui| {
if ui.button("💬 Авторы").clicked() {
authors_modal.open();
ui.close_menu();
}
});
});
});

Expand Down
2 changes: 2 additions & 0 deletions crates/opensi-editor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ async fn main() -> eframe::Result {
eframe::icon_data::from_png_bytes(&include_bytes!("../assets/icon-256.png")[..])
.expect("Failed to load icon"),
),
centered: true,
persist_window: true,
..Default::default()
};
eframe::run_native(
Expand Down

0 comments on commit 8e6679e

Please sign in to comment.