| 285 | { |
| 286 | // Language cycling lives in the Ctrl+` dev panel's Game tab (kLangRotation |
| 287 | // list + setters), not on F11/F12 here. |
| 288 | return Display::DoKeyDown(nChar, nRepCnt, nFlags); |
| 289 | } |
| 290 | |
| 291 | Control* DisplayMain::OnCreateCtrl(int type, int idc, const ParamEntry& cls) |
| 292 | { |
| 293 | switch (idc) |
| 294 | { |
| 295 | case IDC_MAIN_VERSION: |
| 296 | { |
| 297 | CStatic* text = new CStatic(this, idc, cls); |
| 298 | text->SetText(_version); |
| 299 | return text; |
| 300 | } |
| 301 | case IDC_MAIN_DATE: |
| 302 | { |
| 303 | CStatic* text = new CStatic(this, idc, cls); |
| 304 | #if defined _WIN32 |
| 305 | HANDLE hf = |
| 306 | ::CreateFile("bin\\generic.bin", GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); |
| 307 | FILETIME info, infoLocal; |
| 308 | ::GetFileTime(hf, nullptr, nullptr, &info); |
| 309 | ::CloseHandle(hf); |
| 310 | ::FileTimeToLocalFileTime(&info, &infoLocal); |
| 311 | WORD date, time; |
| 312 | ::FileTimeToDosDateTime(&infoLocal, &date, &time); |
| 313 | int day = date & 0x1f; |
| 314 | int month = (date >> 5) & 0x0f; |
| 315 | int year = (date >> 9) + 1980; |
| 316 | |
| 317 | char buffer[256]; |
| 318 | snprintf(buffer, sizeof(buffer), "%d/%d/%d", month, day, year); |
| 319 | text->SetText(buffer); |
| 320 | #else |
| 321 | struct stat st; |
| 322 | if (stat("bin/generic.bin", &st) == 0) |
| 323 | { |
| 324 | struct tm* tm = localtime(&st.st_mtime); |
| 325 | if (tm) |
| 326 | { |
| 327 | char buffer[256]; |
| 328 | snprintf(buffer, sizeof(buffer), "%d/%d/%d", tm->tm_mon + 1, tm->tm_mday, tm->tm_year + 1900); |
| 329 | text->SetText(buffer); |
| 330 | } |
| 331 | } |
| 332 | #endif |
| 333 | |
| 334 | return text; |
| 335 | } |
| 336 | default: |
| 337 | { |
| 338 | Control* ctrl = Display::OnCreateCtrl(type, idc, cls); |
| 339 | if (idc == IDC_MAIN_PLAYER) |
| 340 | SetMainPlayerControlText(ctrl); |
| 341 | return ctrl; |
| 342 | } |
| 343 | } |
nothing calls this directly
no test coverage detected