- Add debugging macros support to CmLib (to use, set the CmlibTraceLevel debugging...
[reactos.git] / reactos / base / setup / usetup / mui.c
1 #include "usetup.h"
2 #include "mui.h"
3
4 #include "lang/en-US.h"
5 #include "lang/de-DE.h"
6
7 static MUI_LANGUAGE LanguageList[] =
8 {
9 {
10 "English (USA)",
11 enUSPages
12 },
13 {
14 "German",
15 deDEPages
16 },
17 {
18 NULL,
19 NULL
20 }
21 };
22
23 static ULONG SelectedLanguage = 0;
24
25 extern
26 VOID
27 PopupError(PCHAR Text,
28 PCHAR Status,
29 PINPUT_RECORD Ir,
30 ULONG WaitEvent);
31
32
33 PGENERIC_LIST
34 MUICreateLanguageList()
35 {
36 PGENERIC_LIST List;
37 ULONG Index;
38
39 List = CreateGenericList();
40 if (List == NULL)
41 {
42 return NULL;
43 }
44
45 Index = 0;
46
47 do
48 {
49 AppendGenericListEntry(List, LanguageList[Index].LanguageDescriptor, (PVOID)Index, (Index == 0 ? TRUE : FALSE));
50 Index++;
51 }while(LanguageList[Index].MuiPages && LanguageList[Index].LanguageDescriptor);
52
53 return List;
54 }
55
56 BOOLEAN
57 MUISelectLanguage(ULONG LanguageIndex)
58 {
59 SelectedLanguage = LanguageIndex;
60 return TRUE;
61 }
62
63
64 static
65 MUI_ENTRY *
66 findMUIEntriesOfPage(ULONG PageNumber, MUI_PAGE * Pages)
67 {
68 ULONG Index = 0;
69 do
70 {
71 if (Pages[Index].Number == PageNumber)
72 {
73 return Pages[Index].MuiEntry;
74 }
75 Index++;
76 }while(Pages[Index].MuiEntry != NULL);
77 return NULL;
78 }
79
80 VOID
81 MUIDisplayPage(ULONG pg)
82 {
83 MUI_ENTRY * entry;
84 int index;
85 int flags;
86
87 entry = findMUIEntriesOfPage(pg, LanguageList[SelectedLanguage].MuiPages);
88 if (!entry)
89 {
90 PopupError("Error: Failed to find translated page",
91 NULL,
92 NULL,
93 POPUP_WAIT_NONE);
94 return;
95 }
96
97 index = 0;
98 do
99 {
100 flags = entry[index].Flags;
101 switch(flags)
102 {
103 case TEXT_NORMAL:
104 CONSOLE_SetTextXY(entry[index].X, entry[index].Y, entry[index].Buffer);
105 break;
106 case TEXT_HIGHLIGHT:
107 CONSOLE_SetHighlightedTextXY(entry[index].X, entry[index].Y, entry[index].Buffer);
108 break;
109 case TEXT_UNDERLINE:
110 CONSOLE_SetUnderlinedTextXY(entry[index].X, entry[index].Y, entry[index].Buffer);
111 break;
112 case TEXT_STATUS:
113 CONSOLE_SetStatusText(entry[index].Buffer);
114 break;
115 default:
116 break;
117 }
118 index++;
119 }while(entry[index].Buffer != NULL);
120 }