- Reorder the pages , the non graphical START_PAGE should be allways the first page...
authorMarc Piulachs <marc.piulachs@live.com>
Sun, 23 Dec 2007 20:29:52 +0000 (20:29 +0000)
committerMarc Piulachs <marc.piulachs@live.com>
Sun, 23 Dec 2007 20:29:52 +0000 (20:29 +0000)
- 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

reactos/base/setup/usetup/interface/usetup.c
reactos/base/setup/usetup/mui.c
reactos/base/setup/usetup/mui.h
reactos/base/setup/usetup/settings.c
reactos/base/setup/usetup/settings.h
reactos/base/setup/usetup/usetup.h
reactos/boot/bootdata/txtsetup.sif

index ac14659..17f9f58 100644 (file)
@@ -545,13 +545,14 @@ CheckUnattendedSetup(VOID)
 static PAGE_NUMBER
 LanguagePage(PINPUT_RECORD Ir)
 {
+  /* Initialize the computer settings list */
   if (LanguageList == NULL)
     {
-      LanguageList = MUICreateLanguageList();
+      LanguageList = CreateLanguageList(SetupInf);
       if (LanguageList == NULL)
         {
            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 */
        {
-      MUISelectLanguage((ULONG)LanguageList->CurrentEntry->UserData);
-         return START_PAGE;
+      MUISelectLanguage((PWCHAR)LanguageList->CurrentEntry->UserData);
+         return INTRO_PAGE;
        }
     }
-  return START_PAGE;
+
+  return INTRO_PAGE;
 }
 
 
@@ -695,7 +697,20 @@ SetupStartPage(PINPUT_RECORD Ir)
 
   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);
 
-  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)
     {
       CONSOLE_ConInKey(Ir);
@@ -3044,7 +3048,7 @@ RegistryPage(PINPUT_RECORD Ir)
 
   /* Update keyboard layout settings */
   CONSOLE_SetStatusText("   Updating keyboard layout settings...");
-  if (!ProcessKeyboardLayoutRegistry(LayoutList))
+  if (!ProcessKeyboardLayoutRegistry(LanguageList))
     {
       MUIDisplayError(ERROR_UPDATE_KBSETTINGS, Ir, POPUP_WAIT_ENTER);
       return QUIT_PAGE;
@@ -3411,26 +3415,23 @@ RunUSetup(VOID)
   /* Hide the cursor */
   CONSOLE_SetCursorType(TRUE, FALSE);
 
-  Page = LANGUAGE_PAGE;
+  Page = START_PAGE;
   while (Page != REBOOT_PAGE)
     {
       CONSOLE_ClearScreen();
-
       CONSOLE_SetUnderlinedTextXY(4, 3, " ReactOS " KERNEL_VERSION_STR " Setup ");
-
       CONSOLE_Flush();
 
       switch (Page)
        {
-      /* Language page */
-      case LANGUAGE_PAGE:
-        Page = LanguagePage(&Ir);
-        break;
          /* Start page */
          case START_PAGE:
            Page = SetupStartPage(&Ir);
            break;
-
+      /* Language page */
+      case LANGUAGE_PAGE:
+        Page = LanguagePage(&Ir);
+        break;
          /* License page */
          case LICENSE_PAGE:
            Page = LicensePage(&Ir);
index 5591b89..4ac1438 100644 (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 "errorcode.h"
 #include "mui.h"
 #include "lang/sv-SE.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[] =
 {
     {
-        "English",
-        enUSPages
+        L"00000409",    /* The Language ID */
+        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
     },
     {
-        "German",
+        L"00000407",
+        L"00000407",
+        L"German",
         deDEPages
     },
     {
-        "Greek",
+        L"00000408",
+        L"00000408",
+        L"Greek",
         elGRPages
     },
     {
-        "Italian",
+        L"00000410",
+        L"00000410",
+        L"Italian",
         itITPages
     },
     {
-        "Russian",
+        L"00000419",
+        L"00000419",
+        L"Russian",
         ruRUPages
     },
     {
-        "Spanish",
+        L"0000040A",
+        L"0000040A",
+        L"Spanish",
         esESPages
     },
     {
-        "Swedish",
+        L"0000041D",
+        L"0000041D",
+        L"Swedish",
         svSEPages
     },
     {
-        "Ukrainian",
+        L"00000422",
+        L"00000422",
+        L"Ukrainian",
         ukUAPages
     },
     {
+        NULL,
         NULL,
         NULL
     }
 };
 
-static ULONG SelectedLanguage = 0;
-
 extern
 VOID
 PopupError(PCHAR Text,
@@ -65,62 +111,58 @@ PopupError(PCHAR Text,
           PINPUT_RECORD Ir,
           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
-MUISelectLanguage(ULONG LanguageIndex)
+MUISelectLanguage(PWCHAR LanguageID)
 {
-    SelectedLanguage = LanguageIndex;
+    if (LanguageID == NULL)
+        return FALSE;
+
+    SelectedLanguageId = LanguageID;
     return TRUE;
 }
 
-
 static
 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
     {
-        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++;
+            }
+            while (Pages[muiIndex].MuiEntry != NULL);
         }
-        Index++;
-    }while(Pages[Index].MuiEntry != NULL);
+
+        lngIndex++;
+    }
+    while (LanguageList[lngIndex].MuiPages != NULL);
+
     return NULL;
 }
 
 VOID
-MUIDisplayPage(ULONG pg)
+MUIDisplayPage(ULONG page)
 {
     MUI_ENTRY * entry;
     int index;
     int flags;
 
-    entry = findMUIEntriesOfPage(pg, LanguageList[SelectedLanguage].MuiPages);
+    entry = FindMUIEntriesOfPage (page);
     if (!entry)
     {
         PopupError("Error: Failed to find translated page",
@@ -152,7 +194,8 @@ MUIDisplayPage(ULONG pg)
                 break;
         }
         index++;
-    }while(entry[index].Buffer != NULL);
+    }
+    while (entry[index].Buffer != NULL);
 }
 
 VOID
@@ -173,3 +216,5 @@ MUIDisplayError(ULONG ErrorNum, PINPUT_RECORD Ir, ULONG WaitEvent)
                Ir,
                WaitEvent);
 }
+
+/* EOF */
index be255ea..1c90291 100644 (file)
@@ -17,23 +17,28 @@ typedef struct
 
 typedef struct
 {
-    CHAR * LanguageDescriptor;
+    PWCHAR LanguageID;
+    PWCHAR LanguageKeyboardLayoutID;
+    PWCHAR LanguageDescriptor;
     MUI_PAGE * MuiPages;
 }MUI_LANGUAGE;
 
-#define TEXT_NORMAL 0
-#define TEXT_HIGHLIGHT 1
-#define TEXT_UNDERLINE 2
-#define TEXT_STATUS 4
+#define TEXT_NORMAL            0
+#define TEXT_HIGHLIGHT         1
+#define TEXT_UNDERLINE         2
+#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
 MUIDisplayPage(ULONG PageNumber);
 
-PGENERIC_LIST
-MUICreateLanguageList();
-
 BOOLEAN
-MUISelectLanguage(ULONG LanguageIndex);
+//MUISelectLanguage(ULONG LanguageIndex);
+MUISelectLanguage(PWCHAR LanguageID);
 
 
 #endif
index b78ad23..5915c96 100644 (file)
@@ -655,6 +655,65 @@ CreateKeyboardDriverList(HINF InfFile)
   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
 CreateKeyboardLayoutList(HINF InfFile)
index 5fa0441..d71afb0 100644 (file)
@@ -48,6 +48,9 @@ CreateKeyboardDriverList(HINF InfFile);
 PGENERIC_LIST
 CreateKeyboardLayoutList(HINF InfFile);
 
+PGENERIC_LIST 
+CreateLanguageList(HINF InfFile); 
+
 BOOLEAN
 ProcessKeyboardLayoutRegistry(PGENERIC_LIST List);
 
index f0cad20..a8371f7 100644 (file)
@@ -82,8 +82,8 @@ extern BOOLEAN IsUnattendedSetup;
 
 typedef enum _PAGE_NUMBER
 {
-  LANGUAGE_PAGE = 0,
   START_PAGE,
+  LANGUAGE_PAGE,
   INTRO_PAGE,
   LICENSE_PAGE,
   INSTALL_INTRO_PAGE,
index 16975f1..5dd74d2 100644 (file)
@@ -58,6 +58,7 @@ AnsiCodepage     = c_1252.nls
 OemCodepage      = c_437.nls
 UnicodeCasetable = l_intl.nls
 DefaultLayout    = 00000409
+DefaultLanguage  = 00000409
 
 [Computer]
 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_1024x768x32 = "VESA Display (1024x768x32)",,VBE,1024,768,32
 
-
-
-
-
 [Map.Display]
 ;<id> = <pnp id string>
 vga = "VGA Display"
@@ -101,6 +98,28 @@ vbe = "VBE Display"
 [Keyboard]
 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]
 00040402 = "Bulgarian BDS 5237-1978"
 00020402 = "Bulgarian phonetic classic"