Fixed some string replacements and that FileErrorText bug.
ChangeUI now supports changing dialogs other than IDD_INST. git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@655 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
1b63e29528
commit
ef05d934d9
9 changed files with 174 additions and 65 deletions
|
@ -33,7 +33,7 @@ Select the directory to install %s in:
|
|||
Space available:
|
||||
Space required:
|
||||
Uninstalling from:
|
||||
Error opening file for writing: $\r$\n$\t"$0"$\r$\nHit abort to abort installation,$\r$\nretry to retry writing the file, or$\r$\nignore to skip this file
|
||||
Error opening file for writing: \r\n\t"$0"\r\nHit abort to abort installation,\r\nretry to retry writing the file, or\r\nignore to skip this file
|
||||
Can't write:
|
||||
Copy failed
|
||||
Copy to
|
||||
|
|
|
@ -34,7 +34,7 @@ S
|
|||
Espace disponible:
|
||||
Espace requis:
|
||||
Désinstallation depuis:
|
||||
Erreur lors de l'ouverture du fichier en écriture: $\r$\n$\t"$0"$\r$\nAppuyez sur Abandonner pour annuler l'installation,$\r$\nRéessayer pour réessayer l'écriture du fichier, ou$\r$\nIgnorer pour passer ce fichier
|
||||
Erreur lors de l'ouverture du fichier en écriture: \r\n\t"$0"\r\nAppuyez sur Abandonner pour annuler l'installation,\r\nRéessayer pour réessayer l'écriture du fichier, ou\r\nIgnorer pour passer ce fichier
|
||||
Impossible d'écrire:
|
||||
Echec de la copie
|
||||
Copier vers
|
||||
|
|
|
@ -33,7 +33,7 @@ W
|
|||
Vorhandener Speicher:
|
||||
Benötigter Speicher:
|
||||
Deinstallieren von:
|
||||
Fehler beim Öffnen der Datei: $\r$\n$\t"$0"$\r$\nKlicken Sie Abbruch, um die Installation abzubrechen,$\r$\nWiederholen, um das Schreiben der Datei erneut zu versuchen, oder$\r$\nIgnorieren, um die Datei zu überspringen
|
||||
Fehler beim Öffnen der Datei: \r\n\t"$0"\r\nKlicken Sie Abbruch, um die Installation abzubrechen,\r\nWiederholen, um das Schreiben der Datei erneut zu versuchen, oder\r\nIgnorieren, um die Datei zu überspringen
|
||||
Fehler beim Schreiben:
|
||||
Kopieren fehlgeschlagen
|
||||
Kopieren nach
|
||||
|
|
|
@ -304,7 +304,7 @@ void CEXEBuild::FillDefaultsIfNeeded(StringTable *table, NLF *nlf/*=0*/) {
|
|||
if (table->common.subcaptions[2]<0)
|
||||
table->common.subcaptions[2]=add_string_main(str(NLF_SUBCAPTION_DIR));
|
||||
if (table->installer.browse<0) table->installer.browse=add_string_main(str(NLF_BTN_BROWSE),0);
|
||||
if (table->installer.spaceavailable<0 && !no_space_texts) table->installer.spaceavailable=add_string_main(str(NLF_SPACE_REQ),0);
|
||||
if (table->installer.spaceavailable<0 && !no_space_texts) table->installer.spaceavailable=add_string_main(str(NLF_SPACE_AVAIL),0);
|
||||
}
|
||||
|
||||
if (table->installer.text >= 0
|
||||
|
@ -315,7 +315,7 @@ void CEXEBuild::FillDefaultsIfNeeded(StringTable *table, NLF *nlf/*=0*/) {
|
|||
{
|
||||
// Changed by Amir Szekely 22nd July 2002
|
||||
// Adds the ability to disable space texts
|
||||
if (table->installer.spacerequired<0 && !no_space_texts) table->installer.spacerequired=add_string_main(str(NLF_SPACE_AVAIL),0);
|
||||
if (table->installer.spacerequired<0 && !no_space_texts) table->installer.spacerequired=add_string_main(str(NLF_SPACE_REQ),0);
|
||||
if (table->installer.nextbutton<0) table->installer.nextbutton=add_string_main(str(NLF_BTN_NEXT),0);
|
||||
if (table->installer.installbutton<0) table->installer.installbutton=add_string_main(str(NLF_BTN_INSTALL),0);
|
||||
}
|
||||
|
@ -489,8 +489,8 @@ NLF::NLF(char *filename) {
|
|||
// Read strings
|
||||
for (int i = 0; i < NLF_STRINGS; i++) {
|
||||
buf[0] = SkipComments(f);
|
||||
fgets(buf+1, 1024, f);
|
||||
if (lstrlen(buf) == 1023) {
|
||||
fgets(buf+1, NSIS_MAX_STRLEN, f);
|
||||
if (lstrlen(buf) == NSIS_MAX_STRLEN-1) {
|
||||
wsprintf(buf, "String too long (string #%d)!", i);
|
||||
throw runtime_error(buf);
|
||||
}
|
||||
|
@ -498,14 +498,32 @@ NLF::NLF(char *filename) {
|
|||
buf[lstrlen(buf)-1] = 0;
|
||||
}
|
||||
m_szStrings[i] = new char[lstrlen(buf)+1];
|
||||
lstrcpy(m_szStrings[i], buf);
|
||||
for (char *out = m_szStrings[i], *in = buf; *in; in++, out++) {
|
||||
if (*in == '\\') {
|
||||
in++;
|
||||
switch (*in) {
|
||||
case 'n':
|
||||
*out = '\n';
|
||||
break;
|
||||
case 'r':
|
||||
*out = '\r';
|
||||
break;
|
||||
case 't':
|
||||
*out = '\t';
|
||||
break;
|
||||
default:
|
||||
*out++ = '\\';
|
||||
*out = *in;
|
||||
}
|
||||
}
|
||||
else *out = *in;
|
||||
}
|
||||
*out = 0;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
NLF::~NLF() {
|
||||
MessageBox(0, "destructor", "info", MB_OK);
|
||||
for (int i = 0; i < NLF_STRINGS; i++) {
|
||||
delete [] m_szStrings[i];
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ struct StringTable {
|
|||
#define NLF_DEF_NAME 20
|
||||
#define NLF_COMPLETED 21
|
||||
#define NLF_COMP_CUSTOM 22
|
||||
#define NLF_COMP_SUBTEXT1_NO_INST_TYPES 23
|
||||
#define NLF_COMP_SUBTEXT1 24
|
||||
#define NLF_COMP_SUBTEXT1 23
|
||||
#define NLF_COMP_SUBTEXT1_NO_INST_TYPES 24
|
||||
#define NLF_COMP_SUBTEXT2 25
|
||||
#define NLF_DIR_SUBTEXT 26
|
||||
#define NLF_SPACE_AVAIL 27
|
||||
|
|
|
@ -784,7 +784,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
|
|||
case TOK_INSTDIR:
|
||||
if (build_header.install_directory_ptr >= 0)
|
||||
{
|
||||
warning("InstallDir: specified multiple times. wasting space (%s:%d)",curfilename,linecnt);
|
||||
warning("%s: specified multiple times. wasting space (%s:%d)",line.gettoken_str(0),curfilename,linecnt);
|
||||
}
|
||||
build_header.install_directory_ptr = add_string_main(line.gettoken_str(1));
|
||||
SCRIPT_MSG("InstallDir: \"%s\"\n",line.gettoken_str(1));
|
||||
|
@ -793,7 +793,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
|
|||
{
|
||||
if (build_header.install_reg_key_ptr>= 0)
|
||||
{
|
||||
warning("InstallRegKey: specified multiple times, wasting space (%s:%d)",curfilename,linecnt);
|
||||
warning("%s: specified multiple times, wasting space (%s:%d)",line.gettoken_str(0),curfilename,linecnt);
|
||||
}
|
||||
int k=line.gettoken_enum(1,rootkeys[0]);
|
||||
if (k == -1) k=line.gettoken_enum(1,rootkeys[1]);
|
||||
|
@ -1035,60 +1035,118 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
|
|||
// Added by Amir Szekely 28th July 2002
|
||||
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
|
||||
case TOK_CHANGEUI:
|
||||
try {
|
||||
HINSTANCE hUIFile = LoadLibraryEx(line.gettoken_str(1), 0, LOAD_LIBRARY_AS_DATAFILE);
|
||||
try {
|
||||
int k=line.gettoken_enum(1, "all\0IDD_LICENSE\0IDD_DIR\0IDD_SELCOM\0IDD_INST\0IDD_INSTFILES\0IDD_UNINST\0");
|
||||
if (k<0) PRINTHELP();
|
||||
|
||||
HINSTANCE hUIFile = LoadLibraryEx(line.gettoken_str(2), 0, LOAD_LIBRARY_AS_DATAFILE);
|
||||
if (!hUIFile) {
|
||||
ERROR_MSG("Error: Can't find \"%s\"!\n", line.gettoken_str(1));
|
||||
return PS_ERROR;
|
||||
}
|
||||
HRSRC hUIRes = FindResource(hUIFile, MAKEINTRESOURCE(IDD_INST), RT_DIALOG);
|
||||
if (!hUIRes) {
|
||||
ERROR_MSG("Error: \"%s\" doesn't contain a dialog named IDD_INST (%u)!\n", line.gettoken_str(1), IDD_INST);
|
||||
return PS_ERROR;
|
||||
}
|
||||
HGLOBAL hUIMem = LoadResource(hUIFile, hUIRes);
|
||||
if (!hUIMem) {
|
||||
ERROR_MSG("Error: Can't load a dialog from \"%s\"!\n", line.gettoken_str(1));
|
||||
return PS_ERROR;
|
||||
}
|
||||
BYTE* pbUIData = (BYTE*)LockResource(hUIMem);
|
||||
if (!pbUIData) {
|
||||
ERROR_MSG("Error: Can't lock resource from \"%s\"!\n", line.gettoken_str(1));
|
||||
return PS_ERROR;
|
||||
}
|
||||
|
||||
CDialogTemplate UIDlg(pbUIData);
|
||||
|
||||
// Search for required items
|
||||
#define SEARCH(x) if (!UIDlg.GetItem(IDC_BACK)) {ERROR_MSG("Error: Can't find %s (%u) in the custom UI!\n", #x, x);return PS_ERROR;}
|
||||
SEARCH(IDC_BACK);
|
||||
SEARCH(IDC_CHILDRECT);
|
||||
SEARCH(IDC_VERSTR);
|
||||
SEARCH(IDOK);
|
||||
SEARCH(IDCANCEL);
|
||||
|
||||
// Search for bitmap holder (default for SetBrandingImage)
|
||||
DialogItemTemplate* dlgItem = 0;
|
||||
int i = 0;
|
||||
while (dlgItem = UIDlg.GetItemByIdx(i)) {
|
||||
if (IS_INTRESOURCE(dlgItem->szClass)) {
|
||||
if (dlgItem->szClass == MAKEINTRESOURCE(0x0082)) {
|
||||
if ((dlgItem->dwStyle & SS_BITMAP) == SS_BITMAP) {
|
||||
branding_image_found = true;
|
||||
branding_image_id = dlgItem->wId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
build_compressor_set=true;
|
||||
CResourceEditor re(header_data_new, exeheader_size_new);
|
||||
re.UpdateResource(RT_DIALOG, IDD_INST, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), pbUIData, UIDlg.GetSize());
|
||||
|
||||
// Search for required items
|
||||
#define SEARCH(x) if (!UIDlg.GetItem(x)) {ERROR_MSG("Error: Can't find %s (%u) in the custom UI!\n", #x, x);return 0;}
|
||||
|
||||
BYTE* dlg = 0;
|
||||
|
||||
if (k == 0 || k == 1) {
|
||||
dlg = get_dlg(hUIFile, IDD_LICENSE, line.gettoken_str(2));
|
||||
if (!dlg) return PS_ERROR;
|
||||
CDialogTemplate UIDlg(dlg);
|
||||
SEARCH(IDC_EDIT1);
|
||||
SEARCH(IDC_INTROTEXT);
|
||||
re.UpdateResource(RT_DIALOG, IDD_LICENSE, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, UIDlg.GetSize());
|
||||
}
|
||||
|
||||
if (k == 0 || k == 2) {
|
||||
dlg = get_dlg(hUIFile, IDD_DIR, line.gettoken_str(2));
|
||||
if (!dlg) return PS_ERROR;
|
||||
CDialogTemplate UIDlg(dlg);
|
||||
SEARCH(IDC_SELDIRTEXT);
|
||||
SEARCH(IDC_INTROTEXT);
|
||||
SEARCH(IDC_DIR);
|
||||
SEARCH(IDC_BROWSE);
|
||||
SEARCH(IDC_CHECK1);
|
||||
SEARCH(IDC_SPACEREQUIRED);
|
||||
SEARCH(IDC_SPACEAVAILABLE);
|
||||
re.UpdateResource(RT_DIALOG, IDD_DIR, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, UIDlg.GetSize());
|
||||
}
|
||||
|
||||
if (k == 0 || k == 3) {
|
||||
dlg = get_dlg(hUIFile, IDD_SELCOM, line.gettoken_str(2));
|
||||
if (!dlg) return PS_ERROR;
|
||||
CDialogTemplate UIDlg(dlg);
|
||||
SEARCH(IDC_SPACEREQUIRED);
|
||||
SEARCH(IDC_INTROTEXT);
|
||||
SEARCH(IDC_TEXT1);
|
||||
SEARCH(IDC_TEXT2);
|
||||
SEARCH(IDC_TREE1);
|
||||
SEARCH(IDC_COMBO1);
|
||||
re.UpdateResource(RT_DIALOG, IDD_SELCOM, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, UIDlg.GetSize());
|
||||
}
|
||||
|
||||
if (k == 0 || k == 4) {
|
||||
dlg = get_dlg(hUIFile, IDD_INST, line.gettoken_str(2));
|
||||
if (!dlg) return PS_ERROR;
|
||||
CDialogTemplate UIDlg(dlg);
|
||||
SEARCH(IDC_BACK);
|
||||
SEARCH(IDC_CHILDRECT);
|
||||
SEARCH(IDC_VERSTR);
|
||||
SEARCH(IDOK);
|
||||
SEARCH(IDCANCEL);
|
||||
|
||||
// Search for bitmap holder (default for SetBrandingImage)
|
||||
DialogItemTemplate* dlgItem = 0;
|
||||
int i = 0;
|
||||
while (dlgItem = UIDlg.GetItemByIdx(i)) {
|
||||
if (IS_INTRESOURCE(dlgItem->szClass)) {
|
||||
if (dlgItem->szClass == MAKEINTRESOURCE(0x0082)) {
|
||||
if ((dlgItem->dwStyle & SS_BITMAP) == SS_BITMAP) {
|
||||
branding_image_found = true;
|
||||
branding_image_id = dlgItem->wId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
re.UpdateResource(RT_DIALOG, IDD_INST, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, UIDlg.GetSize());
|
||||
}
|
||||
|
||||
if (k == 0 || k == 5) {
|
||||
dlg = get_dlg(hUIFile, IDD_INSTFILES, line.gettoken_str(2));
|
||||
if (!dlg) return PS_ERROR;
|
||||
CDialogTemplate UIDlg(dlg);
|
||||
SEARCH(IDC_LIST1);
|
||||
SEARCH(IDC_INTROTEXT);
|
||||
SEARCH(IDC_PROGRESS1);
|
||||
SEARCH(IDC_PROGRESS2);
|
||||
SEARCH(IDC_SHOWDETAILS);
|
||||
re.UpdateResource(RT_DIALOG, IDD_INSTFILES, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, UIDlg.GetSize());
|
||||
}
|
||||
|
||||
if (k == 0 || k == 6) {
|
||||
dlg = get_dlg(hUIFile, IDD_UNINST, line.gettoken_str(2));
|
||||
if (!dlg) return PS_ERROR;
|
||||
CDialogTemplate UIDlg(dlg);
|
||||
SEARCH(IDC_EDIT1);
|
||||
SEARCH(IDC_INTROTEXT);
|
||||
SEARCH(IDC_UNINSTFROM);
|
||||
re.UpdateResource(RT_DIALOG, IDD_UNINST, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, UIDlg.GetSize());
|
||||
}
|
||||
|
||||
free(header_data_new);
|
||||
header_data_new = re.Save((DWORD&)exeheader_size_new);
|
||||
|
||||
if (!FreeLibrary(hUIFile)) {
|
||||
ERROR_MSG("can't free library!\n");
|
||||
}
|
||||
|
||||
SCRIPT_MSG("ChangeUI: %s%s\n", line.gettoken_str(1), branding_image_found?" (branding image holder found)":"");
|
||||
}
|
||||
catch (exception& err) {
|
||||
|
@ -1259,16 +1317,24 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
|
|||
SCRIPT_MSG("LoadLanguageFile: %s\n", line.gettoken_str(1));
|
||||
try {
|
||||
NLF *newNLF = new NLF(line.gettoken_str(1));
|
||||
for (int i = 0; i < build_nlfs.size(); i++)
|
||||
int i;
|
||||
for (i = 0; i < build_nlfs.size(); i++)
|
||||
if (build_nlfs[i]->GetLang() == newNLF->GetLang()) {
|
||||
ERROR_MSG("Error: Can't add same language twice!\n");
|
||||
return PS_ERROR;
|
||||
}
|
||||
build_nlfs.push_back(newNLF);
|
||||
StringTable *table = (StringTable*)malloc(sizeof(StringTable));
|
||||
memset(table, -1, sizeof(StringTable));
|
||||
table->lang_id=table->ucommon.lang_id=table->installer.lang_id=table->uninstall.lang_id=newNLF->GetLang();
|
||||
string_tables.push_back(table);
|
||||
for (i = 0; i < string_tables.size(); i++) {
|
||||
if (newNLF->GetLang() == string_tables[i]->lang_id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i < string_tables.size()) {
|
||||
StringTable *table = (StringTable*)malloc(sizeof(StringTable));
|
||||
memset(table, -1, sizeof(StringTable));
|
||||
table->lang_id=table->ucommon.lang_id=table->installer.lang_id=table->uninstall.lang_id=newNLF->GetLang();
|
||||
string_tables.push_back(table);
|
||||
}
|
||||
}
|
||||
catch (exception &err) {
|
||||
ERROR_MSG("Error while loading language file: %s\n", err.what());
|
||||
|
|
|
@ -27,7 +27,7 @@ static tokenType tokenlist[TOK__LAST] =
|
|||
{TOK_CALL,"Call",1,0,"function_name | [:label_name]"},
|
||||
{TOK_CALLINSTDLL,"CallInstDLL",2,0,"dll_path_on_target.dll function"},
|
||||
{TOK_CAPTION,"Caption",1,1,"[/LANG=lang_id] installer_caption"},
|
||||
{TOK_CHANGEUI,"ChangeUI",1,0,"ui_file.exe"},
|
||||
{TOK_CHANGEUI,"ChangeUI",2,0,"(all|dlg_id) ui_file.exe"},
|
||||
{TOK_CLEARERRORS,"ClearErrors",0,0,""},
|
||||
{TOK_COMPTEXT,"ComponentText",0,4,"[/LANG=lang_id] [component_page_description] [component_subtext1] [component_subtext2]"},
|
||||
{TOK_GETDLLVERSION,"GetDLLVersion",3,0,"filename $(user_var: high output) $(user_var: low output)"},
|
||||
|
|
|
@ -11,7 +11,6 @@ int g_dopause=0;
|
|||
extern int g_display_errors;
|
||||
extern FILE *g_output;
|
||||
|
||||
|
||||
void dopause(void)
|
||||
{
|
||||
if (g_dopause)
|
||||
|
@ -290,3 +289,24 @@ int generate_unicons_offsets(unsigned char* exeHeader, unsigned char* uninstIcon
|
|||
return PIMAGE_RESOURCE_DATA_ENTRY(PRESOURCE_DIRECTORY(rdIcons->Entries[0].OffsetToDirectory + DWORD(rdRoot))->Entries[0].OffsetToData + DWORD(rdRoot))->OffsetToData + DWORD(rdRoot) - dwResourceSectionVA - DWORD(exeHeader);
|
||||
}
|
||||
#endif // NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||
|
||||
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
|
||||
BYTE* get_dlg(HINSTANCE hUIFile, WORD dlgId, char* filename) {
|
||||
HRSRC hUIRes = FindResource(hUIFile, MAKEINTRESOURCE(dlgId), RT_DIALOG);
|
||||
if (!hUIRes) {
|
||||
if (g_display_errors) fprintf(g_output, "Error: \"%s\" doesn't contain a dialog with the ID %u!\n", filename, dlgId);
|
||||
return 0;
|
||||
}
|
||||
HGLOBAL hUIMem = LoadResource(hUIFile, hUIRes);
|
||||
if (!hUIMem) {
|
||||
if (g_display_errors) fprintf(g_output, "Error: Can't load a dialog from \"%s\"!\n", filename);
|
||||
return 0;
|
||||
}
|
||||
BYTE* pbUIData = (BYTE*)LockResource(hUIMem);
|
||||
if (!pbUIData) {
|
||||
if (g_display_errors) fprintf(g_output, "Error: Can't lock resource from \"%s\"!\n", filename);
|
||||
return 0;
|
||||
}
|
||||
return pbUIData;
|
||||
}
|
||||
#endif //NSIS_CONFIG_VISIBLE_SUPPORT
|
|
@ -21,4 +21,9 @@ unsigned char* generate_uninstall_icon_data(char* filename);
|
|||
int generate_unicons_offsets(unsigned char* exeHeader, unsigned char* uninstIconData);
|
||||
#endif NSIS_CONFIG_UNINSTALL_SUPPORT
|
||||
|
||||
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
|
||||
// Returns dialog's raw data from a given loaded module
|
||||
BYTE* get_dlg(HINSTANCE hUIFile, WORD dlgId, char* filename);
|
||||
#endif
|
||||
|
||||
#endif //_UTIL_H_
|
Loading…
Add table
Add a link
Reference in a new issue