- Reorder the pages , the non graphical START_PAGE should be allways the first page to be loaded because it initializes txtsetup.sif

- Apply the selected language to the installed OS
- Get the list of languages from txtsetup.sif, it will allow us to not include explicitly excluded languages
- Various formatting fixes
- Add a default language setting to txtsetup.sif

svn path=/trunk/; revision=31418
This commit is contained in:
Marc Piulachs 2007-12-23 20:29:52 +00:00
parent 2fa730f845
commit 8d4251bd66
7 changed files with 220 additions and 88 deletions

View file

@ -545,13 +545,14 @@ CheckUnattendedSetup(VOID)
static PAGE_NUMBER static PAGE_NUMBER
LanguagePage(PINPUT_RECORD Ir) LanguagePage(PINPUT_RECORD Ir)
{ {
/* Initialize the computer settings list */
if (LanguageList == NULL) if (LanguageList == NULL)
{ {
LanguageList = MUICreateLanguageList(); LanguageList = CreateLanguageList(SetupInf);
if (LanguageList == NULL) if (LanguageList == NULL)
{ {
PopupError("Setup failed to initialize available translations", NULL, NULL, POPUP_WAIT_NONE); PopupError("Setup failed to initialize available translations", NULL, NULL, POPUP_WAIT_NONE);
return START_PAGE; return INTRO_PAGE;
} }
} }
@ -585,11 +586,12 @@ LanguagePage(PINPUT_RECORD Ir)
} }
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */ else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{ {
MUISelectLanguage((ULONG)LanguageList->CurrentEntry->UserData); MUISelectLanguage((PWCHAR)LanguageList->CurrentEntry->UserData);
return START_PAGE; return INTRO_PAGE;
} }
} }
return START_PAGE;
return INTRO_PAGE;
} }
@ -695,7 +697,20 @@ SetupStartPage(PINPUT_RECORD Ir)
CheckUnattendedSetup(); CheckUnattendedSetup();
return INTRO_PAGE; if (IsUnattendedSetup)
{
//TODO
//read options from inf
ComputerList = CreateComputerTypeList(SetupInf);
DisplayList = CreateDisplayDriverList(SetupInf);
KeyboardList = CreateKeyboardDriverList(SetupInf);
LayoutList = CreateKeyboardLayoutList(SetupInf);
LanguageList = CreateLanguageList(SetupInf);
return INSTALL_INTRO_PAGE;
}
return LANGUAGE_PAGE;
} }
@ -709,17 +724,6 @@ IntroPage(PINPUT_RECORD Ir)
{ {
MUIDisplayPage(START_PAGE); MUIDisplayPage(START_PAGE);
if (IsUnattendedSetup)
{
//TODO
//read options from inf
ComputerList = CreateComputerTypeList(SetupInf);
DisplayList = CreateDisplayDriverList(SetupInf);
KeyboardList = CreateKeyboardDriverList(SetupInf);
LayoutList = CreateKeyboardLayoutList(SetupInf);
return INSTALL_INTRO_PAGE;
}
while (TRUE) while (TRUE)
{ {
CONSOLE_ConInKey(Ir); CONSOLE_ConInKey(Ir);
@ -3044,7 +3048,7 @@ RegistryPage(PINPUT_RECORD Ir)
/* Update keyboard layout settings */ /* Update keyboard layout settings */
CONSOLE_SetStatusText(" Updating keyboard layout settings..."); CONSOLE_SetStatusText(" Updating keyboard layout settings...");
if (!ProcessKeyboardLayoutRegistry(LayoutList)) if (!ProcessKeyboardLayoutRegistry(LanguageList))
{ {
MUIDisplayError(ERROR_UPDATE_KBSETTINGS, Ir, POPUP_WAIT_ENTER); MUIDisplayError(ERROR_UPDATE_KBSETTINGS, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE; return QUIT_PAGE;
@ -3411,26 +3415,23 @@ RunUSetup(VOID)
/* Hide the cursor */ /* Hide the cursor */
CONSOLE_SetCursorType(TRUE, FALSE); CONSOLE_SetCursorType(TRUE, FALSE);
Page = LANGUAGE_PAGE; Page = START_PAGE;
while (Page != REBOOT_PAGE) while (Page != REBOOT_PAGE)
{ {
CONSOLE_ClearScreen(); CONSOLE_ClearScreen();
CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup "); CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
CONSOLE_Flush(); CONSOLE_Flush();
switch (Page) switch (Page)
{ {
/* Language page */
case LANGUAGE_PAGE:
Page = LanguagePage(&Ir);
break;
/* Start page */ /* Start page */
case START_PAGE: case START_PAGE:
Page = SetupStartPage(&Ir); Page = SetupStartPage(&Ir);
break; break;
/* Language page */
case LANGUAGE_PAGE:
Page = LanguagePage(&Ir);
break;
/* License page */ /* License page */
case LICENSE_PAGE: case LICENSE_PAGE:
Page = LicensePage(&Ir); Page = LicensePage(&Ir);

View file

@ -1,3 +1,29 @@
/*
* ReactOS kernel
* Copyright (C) 2008 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup
* FILE: subsys/system/usetup/mui.c
* PURPOSE: Text-mode setup
* PROGRAMMER:
*/
#include "usetup.h" #include "usetup.h"
#include "errorcode.h" #include "errorcode.h"
#include "mui.h" #include "mui.h"
@ -12,52 +38,72 @@
#include "lang/sv-SE.h" #include "lang/sv-SE.h"
#include "lang/uk-UA.h" #include "lang/uk-UA.h"
/* The current selected language , by default en-us for now */
static PWCHAR SelectedLanguageId = L"00000409";
static MUI_LANGUAGE LanguageList[] = static MUI_LANGUAGE LanguageList[] =
{ {
{ {
"English", L"00000409", /* The Language ID */
enUSPages L"00000409", /* Default Keyboard Layout for this language */
L"English", /* Language Name , not used just to make things easier when updating this file */
enUSPages /* Translated strings */
}, },
{ {
"French", L"0000040C",
L"0000040C",
L"French",
frFRPages frFRPages
}, },
{ {
"German", L"00000407",
L"00000407",
L"German",
deDEPages deDEPages
}, },
{ {
"Greek", L"00000408",
L"00000408",
L"Greek",
elGRPages elGRPages
}, },
{ {
"Italian", L"00000410",
L"00000410",
L"Italian",
itITPages itITPages
}, },
{ {
"Russian", L"00000419",
L"00000419",
L"Russian",
ruRUPages ruRUPages
}, },
{ {
"Spanish", L"0000040A",
L"0000040A",
L"Spanish",
esESPages esESPages
}, },
{ {
"Swedish", L"0000041D",
L"0000041D",
L"Swedish",
svSEPages svSEPages
}, },
{ {
"Ukrainian", L"00000422",
L"00000422",
L"Ukrainian",
ukUAPages ukUAPages
}, },
{ {
NULL,
NULL, NULL,
NULL NULL
} }
}; };
static ULONG SelectedLanguage = 0;
extern extern
VOID VOID
PopupError(PCHAR Text, PopupError(PCHAR Text,
@ -65,62 +111,58 @@ PopupError(PCHAR Text,
PINPUT_RECORD Ir, PINPUT_RECORD Ir,
ULONG WaitEvent); ULONG WaitEvent);
PGENERIC_LIST
MUICreateLanguageList()
{
PGENERIC_LIST List;
ULONG Index;
List = CreateGenericList();
if (List == NULL)
{
return NULL;
}
Index = 0;
do
{
AppendGenericListEntry(List, LanguageList[Index].LanguageDescriptor, (PVOID)Index, (Index == 0 ? TRUE : FALSE));
Index++;
}while(LanguageList[Index].MuiPages && LanguageList[Index].LanguageDescriptor);
return List;
}
BOOLEAN BOOLEAN
MUISelectLanguage(ULONG LanguageIndex) MUISelectLanguage(PWCHAR LanguageID)
{ {
SelectedLanguage = LanguageIndex; if (LanguageID == NULL)
return FALSE;
SelectedLanguageId = LanguageID;
return TRUE; return TRUE;
} }
static static
MUI_ENTRY * MUI_ENTRY *
findMUIEntriesOfPage(ULONG PageNumber, MUI_PAGE * Pages) FindMUIEntriesOfPage (ULONG PageNumber)
{ {
ULONG Index = 0; ULONG muiIndex = 0;
ULONG lngIndex = 0;
MUI_PAGE * Pages = NULL;
do do
{ {
if (Pages[Index].Number == PageNumber) /* First we search the language list till we find current selected language messages */
if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
{ {
return Pages[Index].MuiEntry; /* Get all available pages for this language */
Pages = LanguageList[lngIndex].MuiPages;
do
{
/* Get page messages */
if (Pages[muiIndex].Number == PageNumber)
return Pages[muiIndex].MuiEntry;
muiIndex++;
} }
Index++; while (Pages[muiIndex].MuiEntry != NULL);
}while(Pages[Index].MuiEntry != NULL); }
lngIndex++;
}
while (LanguageList[lngIndex].MuiPages != NULL);
return NULL; return NULL;
} }
VOID VOID
MUIDisplayPage(ULONG pg) MUIDisplayPage(ULONG page)
{ {
MUI_ENTRY * entry; MUI_ENTRY * entry;
int index; int index;
int flags; int flags;
entry = findMUIEntriesOfPage(pg, LanguageList[SelectedLanguage].MuiPages); entry = FindMUIEntriesOfPage (page);
if (!entry) if (!entry)
{ {
PopupError("Error: Failed to find translated page", PopupError("Error: Failed to find translated page",
@ -152,7 +194,8 @@ MUIDisplayPage(ULONG pg)
break; break;
} }
index++; index++;
}while(entry[index].Buffer != NULL); }
while (entry[index].Buffer != NULL);
} }
VOID VOID
@ -173,3 +216,5 @@ MUIDisplayError(ULONG ErrorNum, PINPUT_RECORD Ir, ULONG WaitEvent)
Ir, Ir,
WaitEvent); WaitEvent);
} }
/* EOF */

View file

@ -17,7 +17,9 @@ typedef struct
typedef struct typedef struct
{ {
CHAR * LanguageDescriptor; PWCHAR LanguageID;
PWCHAR LanguageKeyboardLayoutID;
PWCHAR LanguageDescriptor;
MUI_PAGE * MuiPages; MUI_PAGE * MuiPages;
}MUI_LANGUAGE; }MUI_LANGUAGE;
@ -26,14 +28,17 @@ typedef struct
#define TEXT_UNDERLINE 2 #define TEXT_UNDERLINE 2
#define TEXT_STATUS 4 #define TEXT_STATUS 4
#define TEXT_ALIGN_DEFAULT 5
#define TEXT_ALIGN_RIGHT 6
#define TEXT_ALIGN_LEFT 7
#define TEXT_ALIGN_CENTER 8
VOID VOID
MUIDisplayPage(ULONG PageNumber); MUIDisplayPage(ULONG PageNumber);
PGENERIC_LIST
MUICreateLanguageList();
BOOLEAN BOOLEAN
MUISelectLanguage(ULONG LanguageIndex); //MUISelectLanguage(ULONG LanguageIndex);
MUISelectLanguage(PWCHAR LanguageID);
#endif #endif

View file

@ -655,6 +655,65 @@ CreateKeyboardDriverList(HINF InfFile)
return List; return List;
} }
PGENERIC_LIST
CreateLanguageList(HINF InfFile)
{
CHAR Buffer[128];
PGENERIC_LIST List;
INFCONTEXT Context;
PWCHAR KeyName;
PWCHAR KeyValue;
PWCHAR UserData;
WCHAR DefaultLanguage[20];
/* Get default language id */
if (!SetupFindFirstLineW (InfFile, L"NLS", L"DefaultLanguage", &Context))
return NULL;
if (!INF_GetData (&Context, NULL, &KeyValue))
return NULL;
wcscpy(DefaultLanguage, KeyValue);
List = CreateGenericList();
if (List == NULL)
return NULL;
if (!SetupFindFirstLineW (InfFile, L"Language", NULL, &Context))
{
DestroyGenericList(List, FALSE);
return NULL;
}
do
{
if (!INF_GetData (&Context, &KeyName, &KeyValue))
{
/* FIXME: Handle error! */
DPRINT("INF_GetData() failed\n");
break;
}
UserData = (WCHAR*) RtlAllocateHeap(ProcessHeap,
0,
(wcslen(KeyName) + 1) * sizeof(WCHAR));
if (UserData == NULL)
{
/* FIXME: Handle error! */
}
wcscpy(UserData, KeyName);
sprintf(Buffer, "%S", KeyValue);
AppendGenericListEntry(List,
Buffer,
UserData,
_wcsicmp(KeyName, DefaultLanguage) ? FALSE : TRUE);
}
while (SetupFindNextLine(&Context, &Context));
return List;
}
PGENERIC_LIST PGENERIC_LIST
CreateKeyboardLayoutList(HINF InfFile) CreateKeyboardLayoutList(HINF InfFile)

View file

@ -48,6 +48,9 @@ CreateKeyboardDriverList(HINF InfFile);
PGENERIC_LIST PGENERIC_LIST
CreateKeyboardLayoutList(HINF InfFile); CreateKeyboardLayoutList(HINF InfFile);
PGENERIC_LIST
CreateLanguageList(HINF InfFile);
BOOLEAN BOOLEAN
ProcessKeyboardLayoutRegistry(PGENERIC_LIST List); ProcessKeyboardLayoutRegistry(PGENERIC_LIST List);

View file

@ -82,8 +82,8 @@ extern BOOLEAN IsUnattendedSetup;
typedef enum _PAGE_NUMBER typedef enum _PAGE_NUMBER
{ {
LANGUAGE_PAGE = 0,
START_PAGE, START_PAGE,
LANGUAGE_PAGE,
INTRO_PAGE, INTRO_PAGE,
LICENSE_PAGE, LICENSE_PAGE,
INSTALL_INTRO_PAGE, INSTALL_INTRO_PAGE,

View file

@ -58,6 +58,7 @@ AnsiCodepage = c_1252.nls
OemCodepage = c_437.nls OemCodepage = c_437.nls
UnicodeCasetable = l_intl.nls UnicodeCasetable = l_intl.nls
DefaultLayout = 00000409 DefaultLayout = 00000409
DefaultLanguage = 00000409
[Computer] [Computer]
pci_up = "Standard-PC" pci_up = "Standard-PC"
@ -89,10 +90,6 @@ vbe_1024x768x8 = "VESA Display (1024x768x8)",,VBE,1024,768,8
vbe_1024x768x16 = "VESA Display (1024x768x16)",,VBE,1024,768,16 vbe_1024x768x16 = "VESA Display (1024x768x16)",,VBE,1024,768,16
vbe_1024x768x32 = "VESA Display (1024x768x32)",,VBE,1024,768,32 vbe_1024x768x32 = "VESA Display (1024x768x32)",,VBE,1024,768,32
[Map.Display] [Map.Display]
;<id> = <pnp id string> ;<id> = <pnp id string>
vga = "VGA Display" vga = "VGA Display"
@ -101,6 +98,28 @@ vbe = "VBE Display"
[Keyboard] [Keyboard]
Default = "XT-, AT- or extended keyboard (83-105 keys)" Default = "XT-, AT- or extended keyboard (83-105 keys)"
[Language]
;00000403 = "Catalan"
;00000406 = "Danish"
;00000813 = "Dutch"
00000409 = "English"
;0000040B = "Finnish"
0000040C = "French"
00000407 = "German"
;00000408 = "Greek"
;0000040D = "Hebrew"
;0000040E = "Hungarian"
00000410 = "Italian"
;00000411 = "Japanese"
;00000414 = "Norwegian"
;00000415 = "Polish"
;00000816 = "Portuguese"
;00000419 = "Russian"
;0000041B = "Slovak"
0000040A = "Spanish"
00000422 = "Ukrainian"
[KeyboardLayout] [KeyboardLayout]
00040402 = "Bulgarian BDS 5237-1978" 00040402 = "Bulgarian BDS 5237-1978"
00020402 = "Bulgarian phonetic classic" 00020402 = "Bulgarian phonetic classic"