- implement displaying and showing language dialog

- rename all translated entries in de-DE.h because gcc doesnt understand the scope of static
- add basic language dialog - feel free to improve design, layout etc

svn path=/trunk/; revision=31200
This commit is contained in:
Johannes Anderwald 2007-12-13 16:15:43 +00:00
parent 1d0205fba7
commit 3f301b6835
6 changed files with 191 additions and 60 deletions

View file

@ -73,7 +73,7 @@ static PGENERIC_LIST ComputerList = NULL;
static PGENERIC_LIST DisplayList = NULL; static PGENERIC_LIST DisplayList = NULL;
static PGENERIC_LIST KeyboardList = NULL; static PGENERIC_LIST KeyboardList = NULL;
static PGENERIC_LIST LayoutList = NULL; static PGENERIC_LIST LayoutList = NULL;
static PGENERIC_LIST LanguageList = NULL;
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
@ -550,6 +550,56 @@ CheckUnattendedSetup(VOID)
DPRINT("Running unattended setup\n"); DPRINT("Running unattended setup\n");
} }
static PAGE_NUMBER
LanguagePage(PINPUT_RECORD Ir)
{
if (LanguageList == NULL)
{
LanguageList = MUICreateLanguageList();
if (LanguageList == NULL)
{
PopupError("Setup failed to initialize available translations", NULL, NULL, POPUP_WAIT_NONE);
return START_PAGE;
}
}
DrawGenericList(LanguageList,
7,
15,
xScreen - 10,
yScreen - 10);
MUIDisplayPage(LANGUAGE_PAGE);
while(TRUE)
{
CONSOLE_ConInKey(Ir);
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
{
ScrollDownGenericList (LanguageList);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
{
ScrollUpGenericList (LanguageList);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
{
if (ConfirmQuit(Ir) == TRUE)
return QUIT_PAGE;
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
MUISelectLanguage((ULONG)LanguageList->CurrentEntry->UserData);
return START_PAGE;
}
}
return START_PAGE;
}
/* /*
* Start page * Start page
@ -3425,6 +3475,12 @@ QuitPage(PINPUT_RECORD Ir)
LayoutList = NULL; LayoutList = NULL;
} }
if (LanguageList != NULL)
{
DestroyGenericList(LanguageList, FALSE);
LanguageList = NULL;
}
CONSOLE_SetStatusText(" ENTER = Reboot computer"); CONSOLE_SetStatusText(" ENTER = Reboot computer");
while(TRUE) while(TRUE)
@ -3509,7 +3565,7 @@ RunUSetup(VOID)
/* Hide the cursor */ /* Hide the cursor */
CONSOLE_SetCursorType(TRUE, FALSE); CONSOLE_SetCursorType(TRUE, FALSE);
Page = START_PAGE; Page = LANGUAGE_PAGE;
while (Page != REBOOT_PAGE) while (Page != REBOOT_PAGE)
{ {
CONSOLE_ClearScreen(); CONSOLE_ClearScreen();
@ -3520,6 +3576,10 @@ RunUSetup(VOID)
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);

View file

@ -1,7 +1,7 @@
#ifndef LANG_DE_DE_H__ #ifndef LANG_DE_DE_H__
#define LANG_DE_DE_H__ #define LANG_DE_DE_H__
static MUI_ENTRY WelcomePageEntries[] = static MUI_ENTRY deDEWelcomePageEntries[] =
{ {
{ {
6, 6,
@ -71,7 +71,7 @@ static MUI_ENTRY WelcomePageEntries[] =
} }
}; };
static MUI_ENTRY IntroPageEntries[] = static MUI_ENTRY deDEIntroPageEntries[] =
{ {
{ {
4, 4,
@ -165,7 +165,7 @@ static MUI_ENTRY IntroPageEntries[] =
} }
}; };
static MUI_ENTRY LicensePageEntries[] = static MUI_ENTRY deDELicensePageEntries[] =
{ {
{ {
6, 6,
@ -283,7 +283,7 @@ static MUI_ENTRY LicensePageEntries[] =
} }
}; };
static MUI_ENTRY DevicePageEntries[] = static MUI_ENTRY deDEDevicePageEntries[] =
{ {
{ {
6, 6,
@ -370,7 +370,7 @@ static MUI_ENTRY DevicePageEntries[] =
} }
}; };
static MUI_ENTRY RepairPageEntries[] = static MUI_ENTRY deDERepairPageEntries[] =
{ {
{ {
6, 6,
@ -427,7 +427,7 @@ static MUI_ENTRY RepairPageEntries[] =
0 0
} }
}; };
static MUI_ENTRY ComputerPageEntries[] = static MUI_ENTRY deDEComputerPageEntries[] =
{ {
{ {
6, 6,
@ -473,7 +473,7 @@ static MUI_ENTRY ComputerPageEntries[] =
} }
}; };
static MUI_ENTRY FlushPageEntries[] = static MUI_ENTRY deDEFlushPageEntries[] =
{ {
{ {
10, 10,
@ -507,7 +507,7 @@ static MUI_ENTRY FlushPageEntries[] =
} }
}; };
static MUI_ENTRY QuitPageEntries[] = static MUI_ENTRY deDEQuitPageEntries[] =
{ {
{ {
10, 10,
@ -547,7 +547,7 @@ static MUI_ENTRY QuitPageEntries[] =
} }
}; };
static MUI_ENTRY DisplayPageEntries[] = static MUI_ENTRY deDEDisplayPageEntries[] =
{ {
{ {
6, 6,
@ -592,7 +592,7 @@ static MUI_ENTRY DisplayPageEntries[] =
} }
}; };
static MUI_ENTRY SuccessPageEntries[] = static MUI_ENTRY deDESuccessPageEntries[] =
{ {
{ {
10, 10,
@ -632,7 +632,7 @@ static MUI_ENTRY SuccessPageEntries[] =
} }
}; };
static MUI_ENTRY BootPageEntries[] = static MUI_ENTRY deDEBootPageEntries[] =
{ {
{ {
6, 6,
@ -677,47 +677,47 @@ MUI_PAGE deDEPages[] =
{ {
{ {
START_PAGE, START_PAGE,
WelcomePageEntries deDEWelcomePageEntries
}, },
{ {
INTRO_PAGE, INTRO_PAGE,
IntroPageEntries deDEIntroPageEntries
}, },
{ {
LICENSE_PAGE, LICENSE_PAGE,
LicensePageEntries deDELicensePageEntries
}, },
{ {
DEVICE_SETTINGS_PAGE, DEVICE_SETTINGS_PAGE,
DevicePageEntries deDEDevicePageEntries
}, },
{ {
REPAIR_INTRO_PAGE, REPAIR_INTRO_PAGE,
RepairPageEntries deDERepairPageEntries
}, },
{ {
COMPUTER_SETTINGS_PAGE, COMPUTER_SETTINGS_PAGE,
ComputerPageEntries deDEComputerPageEntries
}, },
{ {
DISPLAY_SETTINGS_PAGE, DISPLAY_SETTINGS_PAGE,
DisplayPageEntries deDEDisplayPageEntries
}, },
{ {
FLUSH_PAGE, FLUSH_PAGE,
FlushPageEntries deDEFlushPageEntries
}, },
{ {
QUIT_PAGE, QUIT_PAGE,
QuitPageEntries deDEQuitPageEntries
}, },
{ {
SUCCESS_PAGE, SUCCESS_PAGE,
SuccessPageEntries deDESuccessPageEntries
}, },
{ {
BOOT_LOADER_FLOPPY_PAGE, BOOT_LOADER_FLOPPY_PAGE,
BootPageEntries deDEBootPageEntries
}, },
{ {
-1, -1,

View file

@ -1,7 +1,30 @@
#ifndef LANG_EN_US_H__ #ifndef LANG_EN_US_H__
#define LANG_EN_US_H__ #define LANG_EN_US_H__
static MUI_ENTRY WelcomePageEntries[] = // do not translate these
static MUI_ENTRY LanguagePageEntries[] =
{
{
6,
8,
"Select your language:",
TEXT_NORMAL
},
{
0,
0,
" ENTER = Continue F3 = Quit",
TEXT_STATUS
},
{
0,
0,
NULL,
0
}
};
static MUI_ENTRY enUSWelcomePageEntries[] =
{ {
{ {
6, 6,
@ -71,7 +94,7 @@ static MUI_ENTRY WelcomePageEntries[] =
} }
}; };
static MUI_ENTRY IntroPageEntries[] = static MUI_ENTRY enUSIntroPageEntries[] =
{ {
{ {
4, 4,
@ -165,7 +188,7 @@ static MUI_ENTRY IntroPageEntries[] =
} }
}; };
static MUI_ENTRY LicensePageEntries[] = static MUI_ENTRY enUSLicensePageEntries[] =
{ {
{ {
6, 6,
@ -283,7 +306,7 @@ static MUI_ENTRY LicensePageEntries[] =
} }
}; };
static MUI_ENTRY DevicePageEntries[] = static MUI_ENTRY enUSDevicePageEntries[] =
{ {
{ {
6, 6,
@ -370,7 +393,7 @@ static MUI_ENTRY DevicePageEntries[] =
} }
}; };
static MUI_ENTRY RepairPageEntries[] = static MUI_ENTRY enUSRepairPageEntries[] =
{ {
{ {
6, 6,
@ -427,7 +450,7 @@ static MUI_ENTRY RepairPageEntries[] =
0 0
} }
}; };
static MUI_ENTRY ComputerPageEntries[] = static MUI_ENTRY enUSComputerPageEntries[] =
{ {
{ {
6, 6,
@ -473,7 +496,7 @@ static MUI_ENTRY ComputerPageEntries[] =
} }
}; };
static MUI_ENTRY FlushPageEntries[] = static MUI_ENTRY enUSFlushPageEntries[] =
{ {
{ {
10, 10,
@ -507,7 +530,7 @@ static MUI_ENTRY FlushPageEntries[] =
} }
}; };
static MUI_ENTRY QuitPageEntries[] = static MUI_ENTRY enUSQuitPageEntries[] =
{ {
{ {
10, 10,
@ -547,7 +570,7 @@ static MUI_ENTRY QuitPageEntries[] =
} }
}; };
static MUI_ENTRY DisplayPageEntries[] = static MUI_ENTRY enUSDisplayPageEntries[] =
{ {
{ {
6, 6,
@ -592,7 +615,7 @@ static MUI_ENTRY DisplayPageEntries[] =
} }
}; };
static MUI_ENTRY SuccessPageEntries[] = static MUI_ENTRY enUSSuccessPageEntries[] =
{ {
{ {
10, 10,
@ -632,7 +655,7 @@ static MUI_ENTRY SuccessPageEntries[] =
} }
}; };
static MUI_ENTRY BootPageEntries[] = static MUI_ENTRY enUSBootPageEntries[] =
{ {
{ {
6, 6,
@ -675,49 +698,53 @@ static MUI_ENTRY BootPageEntries[] =
MUI_PAGE enUSPages[] = MUI_PAGE enUSPages[] =
{ {
{
LANGUAGE_PAGE,
LanguagePageEntries
},
{ {
START_PAGE, START_PAGE,
WelcomePageEntries enUSWelcomePageEntries
}, },
{ {
INTRO_PAGE, INTRO_PAGE,
IntroPageEntries enUSIntroPageEntries
}, },
{ {
LICENSE_PAGE, LICENSE_PAGE,
LicensePageEntries enUSLicensePageEntries
}, },
{ {
DEVICE_SETTINGS_PAGE, DEVICE_SETTINGS_PAGE,
DevicePageEntries enUSDevicePageEntries
}, },
{ {
REPAIR_INTRO_PAGE, REPAIR_INTRO_PAGE,
RepairPageEntries enUSRepairPageEntries
}, },
{ {
COMPUTER_SETTINGS_PAGE, COMPUTER_SETTINGS_PAGE,
ComputerPageEntries enUSComputerPageEntries
}, },
{ {
DISPLAY_SETTINGS_PAGE, DISPLAY_SETTINGS_PAGE,
DisplayPageEntries enUSDisplayPageEntries
}, },
{ {
FLUSH_PAGE, FLUSH_PAGE,
FlushPageEntries enUSFlushPageEntries
}, },
{ {
QUIT_PAGE, QUIT_PAGE,
QuitPageEntries enUSQuitPageEntries
}, },
{ {
SUCCESS_PAGE, SUCCESS_PAGE,
SuccessPageEntries enUSSuccessPageEntries
}, },
{ {
BOOT_LOADER_FLOPPY_PAGE, BOOT_LOADER_FLOPPY_PAGE,
BootPageEntries enUSBootPageEntries
}, },
{ {
-1, -1,

View file

@ -2,20 +2,25 @@
#include "mui.h" #include "mui.h"
#include "lang/en-US.h" #include "lang/en-US.h"
#include "lang/de-DE.h"
static MUI_LANGUAGE lang[] = static MUI_LANGUAGE LanguageList[] =
{ {
{ {
"English (USA)", "English (USA)",
enUSPages enUSPages
}, },
{
"German",
deDEPages
},
{ {
NULL, NULL,
NULL NULL
} }
}; };
static unsigned sel_lang = 0; static ULONG SelectedLanguage = 0;
extern extern
VOID VOID
@ -25,29 +30,61 @@ PopupError(PCHAR Text,
ULONG WaitEvent); ULONG WaitEvent);
static PGENERIC_LIST
MUI_ENTRY * MUICreateLanguageList()
findMUIEntriesOfPage(int pg, MUI_PAGE * pages)
{ {
int index = 0; PGENERIC_LIST List;
ULONG Index;
List = CreateGenericList();
if (List == NULL)
{
return NULL;
}
Index = 0;
do do
{ {
if (pages[index].Number == pg) 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)
{
SelectedLanguage = LanguageIndex;
return TRUE;
}
static
MUI_ENTRY *
findMUIEntriesOfPage(ULONG PageNumber, MUI_PAGE * Pages)
{
ULONG Index = 0;
do
{
if (Pages[Index].Number == PageNumber)
{ {
return pages[index].MuiEntry; return Pages[Index].MuiEntry;
} }
index++; Index++;
}while(pages[index].MuiEntry != NULL); }while(Pages[Index].MuiEntry != NULL);
return NULL; return NULL;
} }
void MUIDisplayPage(int pg) VOID
MUIDisplayPage(ULONG pg)
{ {
MUI_ENTRY * entry; MUI_ENTRY * entry;
int index; int index;
int flags; int flags;
entry = findMUIEntriesOfPage(pg, lang[sel_lang].MuiPages); entry = findMUIEntriesOfPage(pg, LanguageList[SelectedLanguage].MuiPages);
if (!entry) if (!entry)
{ {
PopupError("Error: Failed to find translated page", PopupError("Error: Failed to find translated page",

View file

@ -27,8 +27,14 @@ typedef struct
#define TEXT_UNDERLINE 2 #define TEXT_UNDERLINE 2
#define TEXT_STATUS 4 #define TEXT_STATUS 4
VOID
MUIDisplayPage(ULONG PageNumber);
void MUIDisplayPage(int pg); PGENERIC_LIST
MUICreateLanguageList();
BOOLEAN
MUISelectLanguage(ULONG LanguageIndex);
#endif #endif

View file

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