Skip to content

Commit

Permalink
Add about dialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
crlf0710 committed May 4, 2019
1 parent 75a77c9 commit 7914458
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 110 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
105 changes: 0 additions & 105 deletions res/CharlesMine.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions src/ui_apiw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;

Expand Down Expand Up @@ -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(())
Expand Down
74 changes: 74 additions & 0 deletions src/view_assets_catalog.rs
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 7914458

Please sign in to comment.