* Creates the elements in an error window. * @param msg Language ID for the message to display. * @param wmsg Text string for the message to display. * @param palette Parent state palette. * @param color Color of the UI controls. * @param bg Background image. * @param bgColor Background color (-1 for Battlescape). */
| 75 | * @param bgColor Background color (-1 for Battlescape). |
| 76 | */ |
| 77 | void ErrorMessageState::create(const std::string &str, const std::wstring &wstr, SDL_Color *palette, Uint8 color, std::string bg, int bgColor) |
| 78 | { |
| 79 | _screen = false; |
| 80 | |
| 81 | // Create objects |
| 82 | _window = new Window(this, 256, 160, 32, 20, POPUP_BOTH); |
| 83 | _btnOk = new TextButton(120, 18, 100, 154); |
| 84 | _txtMessage = new Text(246, 80, 37, 50); |
| 85 | |
| 86 | // Set palette |
| 87 | setPalette(palette); |
| 88 | if (bgColor != -1) |
| 89 | setPalette(_game->getResourcePack()->getPalette("BACKPALS.DAT")->getColors(Palette::blockOffset(bgColor)), Palette::backPos, 16); |
| 90 | |
| 91 | add(_window); |
| 92 | add(_btnOk); |
| 93 | add(_txtMessage); |
| 94 | |
| 95 | centerAllSurfaces(); |
| 96 | |
| 97 | // Set up objects |
| 98 | _window->setColor(color); |
| 99 | _window->setBackground(_game->getResourcePack()->getSurface(bg)); |
| 100 | |
| 101 | _btnOk->setColor(color); |
| 102 | _btnOk->setText(tr("STR_OK")); |
| 103 | _btnOk->onMouseClick((ActionHandler)&ErrorMessageState::btnOkClick); |
| 104 | _btnOk->onKeyboardPress((ActionHandler)&ErrorMessageState::btnOkClick, Options::keyOk); |
| 105 | _btnOk->onKeyboardPress((ActionHandler)&ErrorMessageState::btnOkClick, Options::keyCancel); |
| 106 | |
| 107 | _txtMessage->setColor(color); |
| 108 | _txtMessage->setAlign(ALIGN_CENTER); |
| 109 | _txtMessage->setVerticalAlign(ALIGN_MIDDLE); |
| 110 | _txtMessage->setBig(); |
| 111 | _txtMessage->setWordWrap(true); |
| 112 | if (str.empty()) |
| 113 | _txtMessage->setText(wstr); |
| 114 | else |
| 115 | _txtMessage->setText(tr(str)); |
| 116 | |
| 117 | if (bgColor == -1) |
| 118 | { |
| 119 | _window->setHighContrast(true); |
| 120 | _btnOk->setHighContrast(true); |
| 121 | _txtMessage->setHighContrast(true); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Closes the window. |
nothing calls this directly
no test coverage detected