MCPcopy Create free account
hub / github.com/MyGUI/mygui / prepare

Method prepare

Tools/SkinEditor/Application.cpp:205–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203 }
204
205 void Application::prepare()
206 {
207 // устанавливаем локаль из переменной окружения
208 // без этого не будут открываться наши файлы
209 mLocale = ::setlocale(LC_ALL, "");
210 // erase everything after '_' to get language name
211 mLocale.erase(std::find(mLocale.begin(), mLocale.end(), '_'), mLocale.end());
212 if (mLocale == "ru")
213 mLocale = "Russian";
214 else if (mLocale == "en")
215 mLocale = "English";
216
217#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
218
219 // при дропе файл может быть запущен в любой дирректории
220 wchar_t buff[MAX_PATH];
221 ::GetModuleFileNameW(0, buff, MAX_PATH);
222
223 std::wstring dir = buff;
224 size_t pos = dir.find_last_of(L"\\/");
225 if (pos != dir.npos)
226 {
227 // устанавливаем правильную дирректорию
228 ::SetCurrentDirectoryW(dir.substr(0, pos + 1).c_str());
229 }
230
231 // имена могут содержать пробелы, необходимо
232 //склеивать и проверять файлы на существование
233 std::wifstream stream;
234 std::wstring tmp;
235 std::wstring delims = L" ";
236 std::wstring source = GetCommandLineW();
237 size_t start = source.find_first_not_of(delims);
238 while (start != source.npos)
239 {
240 size_t end = source.find_first_of(delims, start);
241 if (end != source.npos)
242 {
243 tmp += source.substr(start, end - start);
244
245 // имена могут быть в ковычках
246 if (tmp.size() > 2)
247 {
248 if ((tmp[0] == L'"') && (tmp[tmp.size() - 1] == L'"'))
249 {
250 tmp = tmp.substr(1, tmp.size() - 2);
251 }
252 }
253
254 #if MYGUI_COMPILER == MYGUI_COMPILER_MSVC && !defined(STLPORT)
255 stream.open(tmp.c_str());
256 #else
257 stream.open(MyGUI::UString(tmp).asUTF8_c_str());
258 #endif
259 if (stream.is_open())
260 {
261 if (tmp.size() > 4 && tmp.substr(tmp.size() - 4) != L".exe")
262 mParams.push_back(tmp);

Callers

nothing calls this directly

Calls 15

UStringFunction · 0.85
find_last_ofMethod · 0.80
substrMethod · 0.80
find_first_not_ofMethod · 0.80
find_first_ofMethod · 0.80
asUTF8_c_strMethod · 0.80
eraseMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected