[loc] update the processing of version numbers

* Now only use major.minor for version references
* Drop the use of LOC_FRAMEWORK_VERSION. We'll use custom handling if we ever need a framework change.
* Also update/fix some of the UI elements for persistent partition
* Also reposition the language selection menu when we don't have a large number of them
This commit is contained in:
Pete Batard 2018-07-15 01:01:39 +01:00
parent 1014b8008d
commit f9275e4780
6 changed files with 57 additions and 40 deletions

View File

@ -32,10 +32,6 @@
#define LOC_RIGHT_TO_LEFT 0x00000001
#define LOC_NEEDS_UPDATE 0x00000002
// The [v]ersion major from a translation must match this number or
// the translation will be ignored
#define LOC_FRAMEWORK_VERSION 1
#define MSG_RTF 0x10000000
#define MSG_MASK 0x0FFFFFFF

View File

@ -245,7 +245,7 @@ BOOL get_supported_locales(const char* filename)
loc_cmd *lcmd = NULL, *last_lcmd = NULL;
long end_of_block;
int version_line_nr = 0;
uint32_t loc_base_minor = -1, loc_base_micro = -1;
uint32_t loc_base_major = -1, loc_base_minor = -1;
fd = open_loc_file(filename);
if (fd == NULL)
@ -326,30 +326,23 @@ BOOL get_supported_locales(const char* filename)
case LC_VERSION:
if (version_line_nr != 0) {
luprintf("[v]ersion was already provided at line %d", version_line_nr);
} else if (lcmd->unum_size != 3) {
} else if (lcmd->unum_size != 2) {
luprint("[v]ersion format is invalid");
} else if (last_lcmd == NULL) {
luprint("[v]ersion cannot precede [l]ocale");
} else if (lcmd->unum[0] != LOC_FRAMEWORK_VERSION) {
// If the localization framework evolved in a manner that makes existing
// translations incompatible, we need to discard them.
luprint("[v]ersion is not compatible with this framework");
} else if (loc_base_minor == -1) {
} else if (loc_base_major == -1) {
// We use the first version from our loc file (usually en-US) as our base
// as it should always be the most up to date.
loc_base_major = lcmd->unum[0];
loc_base_minor = lcmd->unum[1];
loc_base_micro = lcmd->unum[2];
version_line_nr = loc_line_nr;
} else if (lcmd->unum[1] < loc_base_minor) {
luprintf("the version of this locale is incompatible with this version of " APPLICATION_NAME " and MUST be updated to at least v%d.%d.0",
LOC_FRAMEWORK_VERSION, loc_base_minor);
} else {
if (lcmd->unum[2] < loc_base_micro) {
if ((lcmd->unum[0] < loc_base_major) || ((lcmd->unum[0] == loc_base_major) && (lcmd->unum[1] < loc_base_minor))) {
last_lcmd->ctrl_id |= LOC_NEEDS_UPDATE;
luprintf("the version of this translation is older than the base one and may result in some messages not being properly translated.\n"
"If you are the translator, please update your translation with the changes that intervened between v%d.%d.%d and v%d.%d.%d.\n"
"If you are the translator, please update your translation with the changes that intervened between v%d.%d and v%d.%d.\n"
"See https://github.com/pbatard/rufus/blob/master/res/localization/ChangeLog.txt",
LOC_FRAMEWORK_VERSION, loc_base_minor, lcmd->unum[2], LOC_FRAMEWORK_VERSION, loc_base_minor, loc_base_micro);
lcmd->unum[0], lcmd->unum[1], loc_base_major, loc_base_minor);
}
version_line_nr = loc_line_nr;
}

View File

@ -105,7 +105,7 @@ BOOL advanced_mode_device, advanced_mode_format, allow_dual_uefi_bios, detect_fa
BOOL use_fake_units, preserve_timestamps = FALSE, fast_zeroing = FALSE;
BOOL zero_drive = FALSE, list_non_usb_removable_drives = FALSE, enable_file_indexing, large_drive = FALSE, write_as_image = FALSE;
float fScale = 1.0f;
int dialog_showing = 0, selection_default = BT_IMAGE, windows_to_go_selection = 0, persistence_unit_selection = 0;
int dialog_showing = 0, selection_default = BT_IMAGE, windows_to_go_selection = 0, persistence_unit_selection = -1;
int default_fs, fs, bt, pt, tt; // file system, boot type, partition type, target type
char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], temp_dir[MAX_PATH], sysnative_dir[MAX_PATH];
char embedded_sl_version_str[2][12] = { "?.??", "?.??" };
@ -730,6 +730,9 @@ static void EnableBootOptions(BOOL enable, BOOL remove_checkboxes)
actual_enable = FALSE;
EnableWindow(GetDlgItem(hMainDialog, IDC_IMAGE_OPTION), actual_enable);
EnableWindow(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SLIDER), actual_enable);
EnableWindow(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SIZE), actual_enable);
EnableWindow(GetDlgItem(hMainDialog, IDC_PERSISTENCE_UNITS), actual_enable);
EnableMBRBootOptions(actual_enable, remove_checkboxes);
EnableWindow(GetDlgItem(hMainDialog, IDC_LABEL), actual_enable);
@ -1590,11 +1593,6 @@ static void InitDialog(HWND hDlg)
IGNORE_RETVAL(ComboBox_SetItemData(hCtrl, ComboBox_AddStringU(hCtrl, lmprintf(MSG_117)), FALSE));
IGNORE_RETVAL(ComboBox_SetItemData(hCtrl, ComboBox_AddStringU(hCtrl, lmprintf(MSG_118)), TRUE));
// Fill up the Persistence Units dropdown
hCtrl = GetDlgItem(hMainDialog, IDC_PERSISTENCE_UNITS);
for (i = 0; i < 3; i++)
IGNORE_RETVAL(ComboBox_SetItemData(hCtrl, ComboBox_AddStringU(hCtrl, lmprintf(MSG_022 + i)), i));
// Fill up the MBR masqueraded disk IDs ("8 disks should be enough for anybody")
IGNORE_RETVAL(ComboBox_SetItemData(hDiskID, ComboBox_AddStringU(hDiskID, lmprintf(MSG_030, LEFT_TO_RIGHT_EMBEDDING "0x80" POP_DIRECTIONAL_FORMATTING)), 0x80));
for (i=1; i<=7; i++) {
@ -2057,7 +2055,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
pos *= 1024;
persistence_unit_selection = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_PERSISTENCE_UNITS));
// TODO: Use projected size. For now force the selected ISO to a 4 GB size
SetPersistenceSlider(pos, SelectedDrive.DiskSize - 4 * GB);
SetPersistenceSize(pos, SelectedDrive.DiskSize - 4 * GB);
break;
case IDC_NB_PASSES:
if (HIWORD(wParam) != CBN_SELCHANGE)

View File

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.2.1337"
CAPTION "Rufus 3.2.1338"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -392,8 +392,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,2,1337,0
PRODUCTVERSION 3,2,1337,0
FILEVERSION 3,2,1338,0
PRODUCTVERSION 3,2,1338,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -411,13 +411,13 @@ BEGIN
VALUE "Comments", "https://akeo.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.2.1337"
VALUE "FileVersion", "3.2.1338"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus-3.2.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.2.1337"
VALUE "ProductVersion", "3.2.1338"
END
END
BLOCK "VarFileInfo"

View File

@ -635,20 +635,41 @@ void ToggleAdvancedFormatOptions(BOOL enable)
InvalidateRect(hMainDialog, NULL, TRUE);
}
void SetPersistenceSlider(uint64_t pos, uint64_t max)
void SetPersistenceSize(uint64_t pos, uint64_t max)
{
char tmp[12];
int i;
IGNORE_RETVAL(ComboBox_SetCurSel(GetDlgItem(hMainDialog, IDC_PERSISTENCE_UNITS), persistence_unit_selection));
int i, proposed_unit_selection;
LONGLONG base_unit = MB;
HWND hCtrl;
// Reset the the Persistence Units dropdown
hCtrl = GetDlgItem(hMainDialog, IDC_PERSISTENCE_UNITS);
IGNORE_RETVAL(ComboBox_ResetContent(hCtrl));
for (i = 0; i < 3; i++) {
IGNORE_RETVAL(ComboBox_SetItemData(hCtrl, ComboBox_AddStringU(hCtrl, lmprintf(MSG_022 + i)), i));
// If we have more than 7 discrete positions, set this unit as our base
if (SelectedDrive.DiskSize > 7 * base_unit)
proposed_unit_selection = i;
base_unit *= 1024;
// Don't allow a base unit unless the drive is at least twice the size of that unit
if (SelectedDrive.DiskSize < 2 * base_unit)
break;
}
if (persistence_unit_selection < 0)
persistence_unit_selection = proposed_unit_selection;
IGNORE_RETVAL(ComboBox_SetCurSel(hCtrl, persistence_unit_selection));
pos /= MB;
max /= MB;
for (i = 0; i < persistence_unit_selection; i++) {
pos /= 1024;
max /= 1024;
}
SendMessage(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SLIDER), TBM_SETRANGEMIN, (WPARAM)FALSE, (LPARAM)0);
SendMessage(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SLIDER), TBM_SETRANGEMAX, (WPARAM)FALSE, (LPARAM)max);
SendMessage(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SLIDER), TBM_SETPOS, (WPARAM)TRUE, (LPARAM)pos);
hCtrl = GetDlgItem(hMainDialog, IDC_PERSISTENCE_SLIDER);
SendMessage(hCtrl, TBM_SETRANGEMIN, (WPARAM)FALSE, (LPARAM)0);
SendMessage(hCtrl, TBM_SETRANGEMAX, (WPARAM)FALSE, (LPARAM)max);
SendMessage(hCtrl, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)pos);
static_sprintf(tmp, "%ld", (LONG)pos);
SetWindowTextA(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SIZE), tmp);
}
@ -717,7 +738,7 @@ skip:
SetWindowTextU(GetDlgItem(hMainDialog, IDS_IMAGE_OPTION_TXT), lmprintf(MSG_199));
// TODO: Use projected size and reuse existing pos. For now force the selected ISO to a 4 GB size
uint64_t max_size = SelectedDrive.DiskSize - 4 * GB;
SetPersistenceSlider(max_size / 2, max_size);
SetPersistenceSize(max_size / 2, max_size);
}
// If you don't force a redraw here, all kind of bad UI artifacts happen...
InvalidateRect(hMainDialog, NULL, TRUE);
@ -1166,6 +1187,8 @@ void ShowLanguageMenu(RECT rcExclude)
{
TPMPARAMS tpm;
HMENU menu;
RECT rc;
LONG nb_items = 1, adjust = 0;
loc_cmd* lcmd = NULL;
char lang[256];
char *search = "()";
@ -1185,6 +1208,14 @@ void ShowLanguageMenu(RECT rcExclude)
static_strcpy(lang, lcmd->txt[1]);
}
InsertMenuU(menu, -1, MF_BYPOSITION | ((selected_locale == lcmd) ? MF_CHECKED : 0), UM_LANGUAGE_MENU_MAX++, lang);
nb_items++;
}
// Empirical adjust if we have a small enough number of languages to select
if (nb_items < 20) {
GetWindowRect(hMultiToolbar, &rc);
MapWindowPoints(NULL, hMainDialog, (POINT*)&rc, 2);
adjust = rc.top - (nb_items * ddh) / 2;
}
// Open the menu such that it doesn't overlap the specified rect
@ -1193,8 +1224,7 @@ void ShowLanguageMenu(RECT rcExclude)
TrackPopupMenuEx(menu, 0,
// In RTL languages, the menu should be placed at the bottom-right of the rect
right_to_left_mode ? rcExclude.right : rcExclude.left,
rcExclude.bottom, hMainDialog, &tpm);
rcExclude.bottom + adjust, hMainDialog, &tpm);
DestroyMenu(menu);
}

View File

@ -62,7 +62,7 @@ extern void GetFullWidth(HWND hDlg);
extern void PositionMainControls(HWND hDlg);
extern void AdjustForLowDPI(HWND hDlg);
extern void SetSectionHeaders(HWND hDlg);
extern void SetPersistenceSlider(uint64_t pos, uint64_t max);
extern void SetPersistenceSize(uint64_t pos, uint64_t max);
extern void ToggleAdvancedDeviceOptions(BOOL enable);
extern void ToggleAdvancedFormatOptions(BOOL enable);
extern void ToggleImageOption(uint8_t mask);