3 * Copyright (C) 2008 ReactOS Team
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.
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.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS text-mode setup
22 * FILE: base/setup/usetup/mui.c
23 * PURPOSE: Text-mode setup
28 #include "muilanguages.h"
35 FindLanguageIndex(VOID
)
39 if (SelectedLanguageId
== NULL
)
41 /* Default to en-US */
43 // SelectedLanguageId = L"00000409";
46 while (ResourceList
[lngIndex
].MuiPages
!= NULL
)
48 if (_wcsicmp(ResourceList
[lngIndex
].LanguageID
, SelectedLanguageId
) == 0)
67 while (ResourceList
[lngIndex
].MuiPages
!= NULL
)
69 if (_wcsicmp(ResourceList
[lngIndex
].LanguageID
, LanguageId
) == 0)
87 const MUI_PAGE
* Pages
= NULL
;
89 lngIndex
= max(FindLanguageIndex(), 0);
90 Pages
= ResourceList
[lngIndex
].MuiPages
;
92 while (Pages
[muiIndex
].MuiEntry
!= NULL
)
94 if (Pages
[muiIndex
].Number
== PageNumber
)
95 return Pages
[muiIndex
].MuiEntry
;
105 FindMUIErrorEntries(VOID
)
107 ULONG lngIndex
= max(FindLanguageIndex(), 0);
108 return ResourceList
[lngIndex
].MuiErrors
;
113 FindMUIStringEntries(VOID
)
115 ULONG lngIndex
= max(FindLanguageIndex(), 0);
116 return ResourceList
[lngIndex
].MuiStrings
;
124 const MUI_ENTRY
* entry
;
127 entry
= FindMUIEntriesOfPage(page
);
130 PopupError("Error: Failed to find translated page",
138 while (entry
[index
].Buffer
!= NULL
)
140 CONSOLE_ClearStyledText(entry
[index
].X
,
143 strlen(entry
[index
].Buffer
));
152 const MUI_ENTRY
* entry
;
155 entry
= FindMUIEntriesOfPage(page
);
158 PopupError("Error: Failed to find translated page",
166 while (entry
[index
].Buffer
!= NULL
)
168 CONSOLE_SetStyledText(entry
[index
].X
,
171 entry
[index
].Buffer
);
180 OUT PINPUT_RECORD Ir
,
184 const MUI_ERROR
* entry
;
188 if (ErrorNum
>= ERROR_LAST_ERROR_CODE
)
190 PopupError("Invalid error number provided",
191 "Press ENTER to continue",
198 entry
= FindMUIErrorEntries();
201 PopupError("Error: Failed to find translated error message",
208 va_start(ap
, WaitEvent
);
209 vsprintf(Buffer
, entry
[ErrorNum
].ErrorText
, ap
);
213 entry
[ErrorNum
].ErrorStatus
,
223 const MUI_STRING
* entry
;
226 entry
= FindMUIStringEntries();
229 for (i
= 0; entry
[i
].Number
!= 0; i
++)
231 if (entry
[i
].Number
== Number
)
233 return entry
[i
].String
;
238 sprintf(szErr
, "Error: failed find string id %lu for language index %lu\n", Number
, FindLanguageIndex());
249 SetConsoleCodePage(VOID
)
256 while (ResourceList
[lngIndex
].MuiPages
!= NULL
)
258 if (_wcsicmp(ResourceList
[lngIndex
].LanguageID
, SelectedLanguageId
) == 0)
260 wCodePage
= (UINT
) wcstoul(ResourceList
[lngIndex
].OEMCPage
, NULL
, 10);
261 SetConsoleOutputCP(wCodePage
);
268 wCodePage
= (UINT
)wcstoul(MUIGetOEMCodePage(SelectedLanguageId
), NULL
, 10);
269 SetConsoleOutputCP(wCodePage
);