diff --git a/resources/cards/edit/ui.xml b/resources/cards/edit/ui.xml
index 44e8fa3..f52de43 100644
--- a/resources/cards/edit/ui.xml
+++ b/resources/cards/edit/ui.xml
@@ -51,6 +51,11 @@
+
+
+
diff --git a/resources/cards/game/ui.xml b/resources/cards/game/ui.xml
index 11e44f8..048cada 100644
--- a/resources/cards/game/ui.xml
+++ b/resources/cards/game/ui.xml
@@ -9,11 +9,22 @@
+
+
+
+
+
+
diff --git a/resources/cards/setup/ui.xml b/resources/cards/setup/ui.xml
index 86fdc00..08b7904 100644
--- a/resources/cards/setup/ui.xml
+++ b/resources/cards/setup/ui.xml
@@ -15,6 +15,11 @@
start game
+
+
+
diff --git a/resources/guessing/game/ui.xml b/resources/guessing/game/ui.xml
index 4b9e8ec..873ae5b 100644
--- a/resources/guessing/game/ui.xml
+++ b/resources/guessing/game/ui.xml
@@ -20,7 +20,12 @@
Correct|Incorrect: 0|0
+
+
+
-
+
\ No newline at end of file
diff --git a/resources/guessing/setup/ui.xml b/resources/guessing/setup/ui.xml
index 29d42a2..9cddf13 100644
--- a/resources/guessing/setup/ui.xml
+++ b/resources/guessing/setup/ui.xml
@@ -30,6 +30,11 @@
Start!
+
+
+
diff --git a/src/game.rs b/src/game.rs
index 4135cc9..02f142a 100644
--- a/src/game.rs
+++ b/src/game.rs
@@ -1,3 +1,4 @@
+
use rand::Rng;
const VOWELS: usize = 5;
@@ -12,6 +13,12 @@ pub enum Kanas {
Katakana,
}
+impl Default for Kanas {
+ fn default() -> Self {
+ Kanas::Romaji
+ }
+}
+
impl std::fmt::Display for Kanas {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
@@ -25,7 +32,7 @@ impl std::fmt::Display for Kanas {
)
}
}
-
+#[derive(Default)]
pub struct Hieroglyph {
syllable: String,
row: usize,
diff --git a/src/main.rs b/src/main.rs
index fba4bc7..3e539ab 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,12 +1,31 @@
+mod db;
mod game;
mod ui;
mod widgets;
-mod db;
use crate::ui::menu::MenuScene;
-use gtk::{gio, glib, Application};
-use gtk::{prelude::*, ApplicationWindow};
+use gtk::glib::closure_local;
+use gtk::prelude::*;
+use gtk::{gio, glib, Application, Button};
+use ui::cards::edit::MemoryCardsEditScene;
+use ui::cards::game::MemoryCardsGameScene;
+use ui::cards::new::MemoryCardsNewScene;
+use ui::cards::setup::MemoryCardsSetupScene;
+use ui::guessing::game::GuessingScene;
+use ui::guessing::setup::GuessingSetupScene;
+
+enum AppWindow {
+ MenuScene = 1,
+
+ GuessingSetupScene = 2,
+ GuessingScene = 3,
+
+ MemoryCardsSetupScene = 4,
+ MemoryCardsEditScene = 5,
+ MemoryCardsGameScene = 6,
+ // MemoryCardsNewScene = 7,
+}
const APP_ID: &str = "org.foxarmy.learn-hieroglyph";
@@ -17,13 +36,152 @@ fn main() -> glib::ExitCode {
let app: Application = Application::builder().application_id(APP_ID).build();
- app.connect_activate(test_ui);
+ app.connect_activate(build_ui);
app.run()
}
-fn test_ui(app: &Application) {
- let window: ApplicationWindow = MenuScene::new(app).into();
-
- window.present();
+fn hide_all_windows(app: &Application) {
+ for window in app.windows() {
+ window.set_visible(false);
+ }
+}
+
+fn switch_to(app: &Application, win: AppWindow) {
+ hide_all_windows(app);
+ app.window_by_id(win as u32).unwrap().set_visible(true);
+}
+
+fn build_ui(app: &Application) {
+ let menu: MenuScene = MenuScene::new(app); // 1
+ let guessing_setup: GuessingSetupScene = GuessingSetupScene::new(app); // 2
+ let guessing_scene: GuessingScene = GuessingScene::new(app); // 3
+ let memory_cards_setup: MemoryCardsSetupScene = MemoryCardsSetupScene::new(app); // 4
+ let memory_cards_edit: MemoryCardsEditScene = MemoryCardsEditScene::new(app); // 5
+ let memory_cards_game: MemoryCardsGameScene = MemoryCardsGameScene::new(app); // 6
+ let _memory_cards_new: MemoryCardsNewScene = MemoryCardsNewScene::new(app); //7
+
+ menu.get_guessing_button().connect_closure(
+ "clicked",
+ false,
+ closure_local!(
+ @strong app => move |_b: &Button| {
+ switch_to(&app, AppWindow::GuessingSetupScene);
+ }
+ ),
+ );
+
+ menu.get_memory_cards_button().connect_closure(
+ "clicked",
+ false,
+ closure_local!(
+ @strong app => move |_b: &Button| {
+ switch_to(&app, AppWindow::MemoryCardsSetupScene);
+ }
+ ),
+ );
+
+ guessing_setup.get_start_button().connect_closure(
+ "clicked",
+ false,
+ closure_local!(
+ @strong app, @strong guessing_scene => move |_b: &Button| {
+ switch_to(&app, AppWindow::GuessingScene);
+ guessing_scene.read_settings();
+ guessing_scene.init();
+ }
+ ),
+ );
+
+ guessing_setup.get_back_button().connect_closure(
+ "clicked",
+ false,
+ closure_local!(
+ @strong app => move |_b: &Button| {
+ switch_to(&app, AppWindow::MenuScene);
+ }
+ ),
+ );
+
+
+ memory_cards_setup.get_edit_button().connect_closure(
+ "clicked",
+ false,
+ closure_local!(
+ @strong app => move |_b: &Button| {
+ switch_to(&app, AppWindow::MemoryCardsEditScene);
+ }
+ ),
+ );
+
+ memory_cards_setup.get_back_button().connect_closure(
+ "clicked",
+ false,
+ closure_local!(
+ @strong app => move |_b: &Button| {
+ switch_to(&app, AppWindow::MenuScene);
+ }
+ ),
+ );
+
+ memory_cards_setup.get_start_button().connect_closure(
+ "clicked",
+ false,
+ closure_local!(
+ @strong app, @strong memory_cards_game => move |_b: &Button| {
+ switch_to(&app, AppWindow::MemoryCardsGameScene);
+ memory_cards_game.update_card_list();
+ }
+ ),
+ );
+
+ memory_cards_edit.get_back_button().connect_closure(
+ "clicked",
+ false,
+ closure_local!(
+ @strong app => move |_b: &Button| {
+ switch_to(&app, AppWindow::MemoryCardsSetupScene);
+ }
+ ),
+ );
+
+ memory_cards_game.get_back_button().connect_closure(
+ "clicked",
+ false,
+ closure_local!(
+ @strong app => move |_b: &Button| {
+ switch_to(&app, AppWindow::MemoryCardsSetupScene);
+ }
+ ),
+ );
+
+
+ guessing_scene.get_back_button().connect_closure(
+ "clicked",
+ false,
+ closure_local!(
+ @strong app => move |_b: &Button| {
+ switch_to(&app, AppWindow::GuessingSetupScene);
+ }
+ ),
+ );
+
+
+
+
+ // memory_cards_edit.get_add_button().connect_closure(
+ // "clicked",
+ // false,
+ // closure_local!(
+ // @strong app => move |_b: &Button| {
+ // switch_to(&app, AppWindow::MemoryCardsNewScene);
+ // hide_all_windows(&app);
+ // app.window_by_id(7).unwrap().set_visible(true); // to memory card new scene
+ // }
+ // ),
+ // );
+
+
+
+ menu.present();
}
diff --git a/src/ui/cards/edit/imp.rs b/src/ui/cards/edit/imp.rs
index 7e0e2b7..5ec30a8 100644
--- a/src/ui/cards/edit/imp.rs
+++ b/src/ui/cards/edit/imp.rs
@@ -28,6 +28,8 @@ pub struct MemoryCardsEditScene {
pub cards_container: TemplateChild,
#[template_child]
pub cards_scrolled_window: TemplateChild,
+ #[template_child]
+ pub back_button: TemplateChild