diff --git a/Cargo.lock b/Cargo.lock index eec7026..187a37b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,7 +11,7 @@ dependencies = [ [[package]] name = "apiw" version = "0.1.0" -source = "git+https://github.com/crlf0710/apiw-rs#59becb9314adc5d1d6e89bb56c4f145699da6cc4" +source = "git+https://github.com/crlf0710/apiw-rs#875e3b94b0ac04498de39af425a5a1922c860d9e" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -355,7 +355,7 @@ dependencies = [ [[package]] name = "resw" version = "0.1.0" -source = "git+https://github.com/crlf0710/resw-rs#ba34ee675e241acc5f17341075b2d9ddd2b720c7" +source = "git+https://github.com/crlf0710/resw-rs#c80783065be608e7191e3a8b1cb1ab0669449a62" dependencies = [ "embed-resource 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/build.rs b/build.rs index 9090de7..f090e7f 100644 --- a/build.rs +++ b/build.rs @@ -196,6 +196,62 @@ fn compile_resource() { ) .build(), ) + .resource( + catalog::IDD_ABOUTBOX, + resource::Dialog::from_builder() + .system_menu() + .caption(MultiLangText::from("About").lang(lang::LANG_CHS, "关于")) + .font( + "Tahoma", + FontSize::pt(9), + FontWeight::default(), + FontItalic::default(), + FontCharset::default(), + ) + .lang_specific_font( + lang::LANG_CHS, + "SimSun", + FontSize::pt(9), + FontWeight::default(), + FontItalic::default(), + FontCharset::default(), + ) + .style(dialog::DialogStyle::MODAL_FRAME) + .rect(Rect::new(22, 17, 186, 60)) + .control( + catalog::IDC_MYICON, + dialog::Control::from_template(dialog::ControlTemplate::ICON) + .image_id(catalog::IDI_CHARLESMINE) + .rect(Rect::new(14, 9, 21, 21)), + ) + .control( + catalog::IDC_TEXT1, + dialog::Control::from_template(dialog::ControlTemplate::LTEXT) + .text( + MultiLangText::from("CharlesMine 1.0") + .lang(lang::LANG_CHS, "钻石扫雷 1.0"), + ) + .rect(Rect::new(49, 10, 119, 8)) + .style(dialog::StaticControlStyle::NO_PREFIX), + ) + .control( + catalog::IDC_TEXT2, + dialog::Control::from_template(dialog::ControlTemplate::LTEXT) + .text( + MultiLangText::from("CrLF0710 Home-made") + .lang(lang::LANG_CHS, "CrLF0710 制作"), + ) + .rect(Rect::new(49, 20, 119, 8)), + ) + .control( + predefined_id::OK, + dialog::Control::from_template(dialog::ControlTemplate::DEFPUSHBUTTON) + .text(MultiLangText::from("OK")) + .rect(Rect::new(75, 32, 36, 15)) + .style(dialog::WindowStyle::GROUP), + ) + .build(), + ) .compile() .expect("Failed to compile resource"); } diff --git a/res/CharlesMine.rc b/res/CharlesMine.rc index b92b100..8a936d4 100644 --- a/res/CharlesMine.rc +++ b/res/CharlesMine.rc @@ -6,28 +6,6 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -// Icon - -IDI_CHARLESMINE ICON "../res/CharlesMine.ico" - -// Accelerator - -IDC_CHARLESMINE ACCELERATORS -BEGIN - "/", IDM_HELP_ABOUT, ASCII, ALT, NOINVERT - "?", IDM_HELP_ABOUT, ASCII, ALT, NOINVERT - VK_F2, IDM_FILE_NEW, VIRTKEY, NOINVERT - VK_F8, IDM_ADVANCED_RESTART, VIRTKEY, NOINVERT - VK_F12, IDM_ADVANCED_RECORD_STOP, VIRTKEY, NOINVERT - VK_F5, IDM_ADVANCED_LOADMAP, VIRTKEY, NOINVERT - VK_F6, IDM_ADVANCED_SAVEMAP, VIRTKEY, NOINVERT -END - -// Bitmap - -IDB_BLOCKS BITMAP "..\\res\\Blocks.bmp" -IDB_BUTTON BITMAP "..\\res\\Button.bmp" -IDB_DIGIT BITMAP "..\\res\\Digit.bmp" // Dialog @@ -84,47 +62,6 @@ BEGIN LTEXT "",IDC_EXTRA3,92,35,76,8,NOT WS_GROUP END -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US - -// Menu - -IDC_CHARLESMINE MENU -BEGIN - POPUP "&Game" - BEGIN - MENUITEM "&New\tF2", IDM_FILE_NEW - MENUITEM SEPARATOR - MENUITEM "&Beginner", IDM_FILE_GAME_EASY - MENUITEM "&Intermediate", IDM_FILE_GAME_MEDIUM - MENUITEM "&Expert", IDM_FILE_GAME_HARD - MENUITEM "&Custom...", IDM_FILE_GAME_CUSTOM - MENUITEM SEPARATOR - MENUITEM "&Marks (?)", IDM_FILE_MARK - MENUITEM SEPARATOR - MENUITEM "Best &Times...", IDM_FILE_HERO_LIST - MENUITEM SEPARATOR - MENUITEM "E&xit", IDM_FILE_EXIT - END - POPUP "&Advanced" - BEGIN - MENUITEM "&Load Game\tF5", IDM_ADVANCED_LOADMAP - MENUITEM "&Save Game\tF6", IDM_ADVANCED_SAVEMAP - MENUITEM SEPARATOR - MENUITEM "&Restart Game\tF8", IDM_ADVANCED_RESTART - MENUITEM SEPARATOR - MENUITEM "Start R&ecording", IDM_ADVANCED_RECORD_RECORD - MENUITEM "Start &Playback", IDM_ADVANCED_RECORD_PLAY - MENUITEM "S&top Recording/Playback\tF12", IDM_ADVANCED_RECORD_STOP - MENUITEM SEPARATOR - MENUITEM "Zoom 1x" IDM_ADVANCED_ZOOM_1x - MENUITEM "Zoom 2x" IDM_ADVANCED_ZOOM_2x - MENUITEM "Zoom 3x" IDM_ADVANCED_ZOOM_3x - END - POPUP "&Help" - BEGIN - MENUITEM "&About CharlesMine...", IDM_HELP_ABOUT - END -END // String Table @@ -181,48 +118,6 @@ BEGIN IDS_FILE_RECORD_RESTART "本局失败!要重新开始一局并重新录像么?" END -LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED - -// Menu - -IDC_CHARLESMINE MENU -BEGIN - POPUP "游戏(&G)" - BEGIN - MENUITEM "开局(&N)\tF2", IDM_FILE_NEW - MENUITEM SEPARATOR - MENUITEM "初级(&B)", IDM_FILE_GAME_EASY - MENUITEM "中级(&I)", IDM_FILE_GAME_MEDIUM - MENUITEM "高级(&E)", IDM_FILE_GAME_HARD - MENUITEM "自定义(&C)...", IDM_FILE_GAME_CUSTOM - MENUITEM SEPARATOR - MENUITEM "标记(?)(&M)", IDM_FILE_MARK - MENUITEM SEPARATOR - MENUITEM "扫雷英雄榜(&T)...", IDM_FILE_HERO_LIST - MENUITEM SEPARATOR - MENUITEM "退出(&X)", IDM_FILE_EXIT - END - POPUP "高级(&A)" - BEGIN - MENUITEM "加载雷局(&L)\tF5", IDM_ADVANCED_LOADMAP - MENUITEM "保存雷局(&S)\tF6", IDM_ADVANCED_SAVEMAP - MENUITEM SEPARATOR - MENUITEM "重新开始本局(&R)\tF8", IDM_ADVANCED_RESTART - MENUITEM SEPARATOR - MENUITEM "开始录像(&E)", IDM_ADVANCED_RECORD_RECORD - MENUITEM "开始回放(&P)", IDM_ADVANCED_RECORD_PLAY - MENUITEM "停止(&T)\tF12", IDM_ADVANCED_RECORD_STOP - MENUITEM SEPARATOR - MENUITEM "缩放 1x" IDM_ADVANCED_ZOOM_1x - MENUITEM "缩放 2x" IDM_ADVANCED_ZOOM_2x - MENUITEM "缩放 3x" IDM_ADVANCED_ZOOM_3x - END - POPUP "帮助(&H)" - BEGIN - MENUITEM "关于 钻石扫雷(&A)...", IDM_HELP_ABOUT - END -END - // String Table STRINGTABLE diff --git a/src/ui_apiw.rs b/src/ui_apiw.rs index 11e131c..7db3a54 100644 --- a/src/ui_apiw.rs +++ b/src/ui_apiw.rs @@ -48,9 +48,9 @@ impl Ui { use apiw::full_windows_api::um::winnls::SetThreadUILanguage; use apiw::full_windows_api::um::winnt::MAKELANGID; - unsafe { - SetThreadUILanguage(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); - } + //unsafe { + // SetThreadUILanguage(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); + //} Self::create_main_window()?; @@ -345,6 +345,12 @@ impl Ui { Ok(()) })?; } + resources::IDM_HELP_ABOUT => { + use apiw::windows_subsystem::dialog::DialogBuilder; + + DialogBuilder::new_from_resource_id(resources::IDD_ABOUTBOX as _) + .invoke()?; + } _ => {} } Ok(()) diff --git a/src/view_assets_catalog.rs b/src/view_assets_catalog.rs new file mode 100644 index 0000000..5482e19 --- /dev/null +++ b/src/view_assets_catalog.rs @@ -0,0 +1,74 @@ +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +pub const IDC_MYICON: isize = 2; +pub const IDD_CHARLESMINE_DIALOG: isize = 102; +pub const IDS_APP_TITLE: isize = 103; +pub const IDI_CHARLESMINE: isize = 107; +pub const IDC_CHARLESMINE: isize = 109; +pub const IDC_TEXT1: isize = 112; +pub const IDC_TEXT2: isize = 113; +pub const IDC_TEXT3: isize = 114; +pub const IDC_TEXT4: isize = 115; +pub const IDC_EDIT1: isize = 116; +pub const IDC_EDIT2: isize = 117; +pub const IDC_EDIT3: isize = 118; +pub const IDC_EDIT4: isize = 119; +pub const IDC_BUTTON1: isize = 120; +pub const IDC_BUTTON2: isize = 121; +pub const IDC_EXTRA1: isize = 122; +pub const IDC_EXTRA2: isize = 123; +pub const IDC_EXTRA3: isize = 124; +pub const IDR_MAINFRAME: isize = 128; +pub const IDB_BLOCKS: isize = 129; +pub const IDB_BUTTON: isize = 130; +pub const IDB_DIGIT: isize = 131; +pub const IDM_FILE_NEW: isize = 151; +pub const IDM_FILE_GAME_EASY: isize = 152; +pub const IDM_FILE_GAME_MEDIUM: isize = 153; +pub const IDM_FILE_GAME_HARD: isize = 154; +pub const IDM_FILE_GAME_CUSTOM: isize = 155; +pub const IDM_FILE_MARK: isize = 156; +pub const IDM_FILE_HERO_LIST: isize = 157; +pub const IDM_FILE_EXIT: isize = 158; +pub const IDM_ADVANCED_LOADMAP: isize = 161; +pub const IDM_ADVANCED_SAVEMAP: isize = 162; +pub const IDM_ADVANCED_RESTART: isize = 163; +pub const IDM_ADVANCED_RECORD_RECORD: isize = 164; +pub const IDM_ADVANCED_RECORD_PLAY: isize = 166; +pub const IDM_ADVANCED_RECORD_STOP: isize = 167; +pub const IDM_ADVANCED_ZOOM_1x: isize = 170; +pub const IDM_ADVANCED_ZOOM_2x: isize = 171; +pub const IDM_ADVANCED_ZOOM_3x: isize = 172; +pub const IDM_HELP_ABOUT: isize = 199; +pub const IDD_ABOUTBOX: isize = 201; +pub const IDD_CUSTOM_GAME: isize = 202; +pub const IDD_HERO_NAME: isize = 203; +pub const IDD_HERO_LIST: isize = 204; +pub const IDS_ABOUTTEXT: isize = 241; +pub const IDS_ABOUTTEXT1: isize = 242; +pub const IDS_ABOUTTEXT2: isize = 243; +pub const IDS_ABOUTTEXT3: isize = 244; +pub const IDS_CUSTOMGAME: isize = 251; +pub const IDS_CUSTOMGAME_HEIGHT: isize = 252; +pub const IDS_CUSTOMGAME_WIDTH: isize = 253; +pub const IDS_CUSTOMGAME_MINE: isize = 254; +pub const IDS_HERO_NAME: isize = 261; +pub const IDS_HERO_NAME_TEXT1: isize = 262; +pub const IDS_HERO_NAME_TEXT2: isize = 263; +pub const IDS_HERO_NAME_TEXT3: isize = 264; +pub const IDS_HERO_LIST: isize = 271; +pub const IDS_HERO_LIST_TEXT1: isize = 272; +pub const IDS_HERO_LIST_TEXT2: isize = 273; +pub const IDS_HERO_LIST_TEXT3: isize = 274; +pub const IDS_HERO_LIST_BUTTON: isize = 275; +pub const IDS_FILE_FILTER: isize = 281; +pub const IDS_REPLAY_FILTER: isize = 282; +pub const IDS_FILE_SAVE_ERROR: isize = 283; +pub const IDS_FILE_LOAD_ERROR: isize = 284; +pub const IDS_FILE_RECORD_FINISH: isize = 285; +pub const IDS_FILE_PLAYBACK_FINISH: isize = 286; +pub const IDS_APP_TITLE_RECORD: isize = 287; +pub const IDS_FILE_RECORD_START: isize = 288; +pub const IDS_FILE_RECORD_RESTART: isize = 289; +pub const IDC_STATIC: isize = -1;