4ac1438d30f4af7c3e3b686e858b24cc0e84b939
[reactos.git] / reactos / base / setup / usetup / mui.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2008 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /*
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS text-mode setup
22 * FILE: subsys/system/usetup/mui.c
23 * PURPOSE: Text-mode setup
24 * PROGRAMMER:
25 */
26
27 #include "usetup.h"
28 #include "errorcode.h"
29 #include "mui.h"
30
31 #include "lang/en-US.h"
32 #include "lang/de-DE.h"
33 #include "lang/el-GR.h"
34 #include "lang/es-ES.h"
35 #include "lang/fr-FR.h"
36 #include "lang/it-IT.h"
37 #include "lang/ru-RU.h"
38 #include "lang/sv-SE.h"
39 #include "lang/uk-UA.h"
40
41 /* The current selected language , by default en-us for now */
42 static PWCHAR SelectedLanguageId = L"00000409";
43
44 static MUI_LANGUAGE LanguageList[] =
45 {
46 {
47 L"00000409", /* The Language ID */
48 L"00000409", /* Default Keyboard Layout for this language */
49 L"English", /* Language Name , not used just to make things easier when updating this file */
50 enUSPages /* Translated strings */
51 },
52 {
53 L"0000040C",
54 L"0000040C",
55 L"French",
56 frFRPages
57 },
58 {
59 L"00000407",
60 L"00000407",
61 L"German",
62 deDEPages
63 },
64 {
65 L"00000408",
66 L"00000408",
67 L"Greek",
68 elGRPages
69 },
70 {
71 L"00000410",
72 L"00000410",
73 L"Italian",
74 itITPages
75 },
76 {
77 L"00000419",
78 L"00000419",
79 L"Russian",
80 ruRUPages
81 },
82 {
83 L"0000040A",
84 L"0000040A",
85 L"Spanish",
86 esESPages
87 },
88 {
89 L"0000041D",
90 L"0000041D",
91 L"Swedish",
92 svSEPages
93 },
94 {
95 L"00000422",
96 L"00000422",
97 L"Ukrainian",
98 ukUAPages
99 },
100 {
101 NULL,
102 NULL,
103 NULL
104 }
105 };
106
107 extern
108 VOID
109 PopupError(PCHAR Text,
110 PCHAR Status,
111 PINPUT_RECORD Ir,
112 ULONG WaitEvent);
113
114 BOOLEAN
115 MUISelectLanguage(PWCHAR LanguageID)
116 {
117 if (LanguageID == NULL)
118 return FALSE;
119
120 SelectedLanguageId = LanguageID;
121 return TRUE;
122 }
123
124 static
125 MUI_ENTRY *
126 FindMUIEntriesOfPage (ULONG PageNumber)
127 {
128 ULONG muiIndex = 0;
129 ULONG lngIndex = 0;
130 MUI_PAGE * Pages = NULL;
131
132 do
133 {
134 /* First we search the language list till we find current selected language messages */
135 if (_wcsicmp(LanguageList[lngIndex].LanguageID , SelectedLanguageId) == 0)
136 {
137 /* Get all available pages for this language */
138 Pages = LanguageList[lngIndex].MuiPages;
139
140 do
141 {
142 /* Get page messages */
143 if (Pages[muiIndex].Number == PageNumber)
144 return Pages[muiIndex].MuiEntry;
145
146 muiIndex++;
147 }
148 while (Pages[muiIndex].MuiEntry != NULL);
149 }
150
151 lngIndex++;
152 }
153 while (LanguageList[lngIndex].MuiPages != NULL);
154
155 return NULL;
156 }
157
158 VOID
159 MUIDisplayPage(ULONG page)
160 {
161 MUI_ENTRY * entry;
162 int index;
163 int flags;
164
165 entry = FindMUIEntriesOfPage (page);
166 if (!entry)
167 {
168 PopupError("Error: Failed to find translated page",
169 NULL,
170 NULL,
171 POPUP_WAIT_NONE);
172 return;
173 }
174
175 index = 0;
176 do
177 {
178 flags = entry[index].Flags;
179 switch(flags)
180 {
181 case TEXT_NORMAL:
182 CONSOLE_SetTextXY(entry[index].X, entry[index].Y, entry[index].Buffer);
183 break;
184 case TEXT_HIGHLIGHT:
185 CONSOLE_SetHighlightedTextXY(entry[index].X, entry[index].Y, entry[index].Buffer);
186 break;
187 case TEXT_UNDERLINE:
188 CONSOLE_SetUnderlinedTextXY(entry[index].X, entry[index].Y, entry[index].Buffer);
189 break;
190 case TEXT_STATUS:
191 CONSOLE_SetStatusText(entry[index].Buffer);
192 break;
193 default:
194 break;
195 }
196 index++;
197 }
198 while (entry[index].Buffer != NULL);
199 }
200
201 VOID
202 MUIDisplayError(ULONG ErrorNum, PINPUT_RECORD Ir, ULONG WaitEvent)
203 {
204 if (ErrorNum >= ERROR_LAST_ERROR_CODE)
205 {
206 PopupError("invalid error number provided",
207 "press enter to continue",
208 Ir,
209 POPUP_WAIT_ENTER);
210
211 return;
212 }
213
214 PopupError(enUSErrorEntries[ErrorNum].ErrorText,
215 enUSErrorEntries[ErrorNum].ErrorStatus,
216 Ir,
217 WaitEvent);
218 }
219
220 /* EOF */