* 0x004CE523 * * @param caller @ * @param title @ * @param message @ * @param value @ * @param callingWidget @ */
| 71 | * @param callingWidget @<dx> |
| 72 | */ |
| 73 | void openTextInput(Ui::Window* caller, StringId title, StringId message, StringId value, int callingWidget, FormatArgumentsView valueArgs, uint32_t inputSize) |
| 74 | { |
| 75 | _title = title; |
| 76 | _message = message; |
| 77 | |
| 78 | _callingWindowType = caller->type; |
| 79 | _callingWindowNumber = caller->number; |
| 80 | _callingWidget = callingWidget; |
| 81 | |
| 82 | // Close any previous text input window |
| 83 | cancel(); |
| 84 | |
| 85 | auto window = WindowManager::createWindowCentred( |
| 86 | WindowType::textInput, |
| 87 | { 330, 90 }, |
| 88 | WindowFlags::stickToFront | WindowFlags::playSoundOnOpen, |
| 89 | getEvents()); |
| 90 | window->setWidgets(_widgets); |
| 91 | window->initScrollWidgets(); |
| 92 | |
| 93 | auto commonArgs = FormatArguments::common(); |
| 94 | std::memcpy(_formatArgs.data(), commonArgs.getBufferStart(), std::min(commonArgs.getCapacity(), _formatArgs.capacity())); |
| 95 | char temp[200] = {}; |
| 96 | StringManager::formatString(temp, value, valueArgs); |
| 97 | |
| 98 | inputSession = Ui::TextInput::InputSession(temp, inputSize); |
| 99 | inputSession.calculateTextOffset(window->widgets[Widx::input].width() - 2); |
| 100 | |
| 101 | caller = WindowManager::find(_callingWindowType, _callingWindowNumber); |
| 102 | |
| 103 | window->setColour(WindowColour::primary, caller->getColour(WindowColour::primary)); |
| 104 | window->setColour(WindowColour::secondary, caller->getColour(WindowColour::secondary)); |
| 105 | window->owner = caller->owner; |
| 106 | |
| 107 | if (caller->type == WindowType::titleMenu) |
| 108 | { |
| 109 | const InterfaceSkinObject* interface = ObjectManager::get<InterfaceSkinObject>(); |
| 110 | window->setColour(WindowColour::primary, interface->windowTitlebarColour); |
| 111 | window->setColour(WindowColour::secondary, interface->windowColour); |
| 112 | window->owner = CompanyId::null; |
| 113 | } |
| 114 | |
| 115 | if (caller->type == WindowType::timeToolbar) |
| 116 | { |
| 117 | const InterfaceSkinObject* interface = ObjectManager::get<InterfaceSkinObject>(); |
| 118 | window->setColour(WindowColour::secondary, interface->windowPlayerColor); |
| 119 | window->owner = CompanyManager::getControllingId(); |
| 120 | } |
| 121 | |
| 122 | // TODO: Get the correct type and provide getter/setter. |
| 123 | window->widgets[Widx::title].styleData = enumValue(Widgets::Caption::Style::whiteText); |
| 124 | if (window->owner != CompanyId::null) |
| 125 | { |
| 126 | window->flags |= WindowFlags::lighterFrame; |
| 127 | window->widgets[Widx::title].styleData = enumValue(Widgets::Caption::Style::colourText); |
| 128 | } |
| 129 | |
| 130 | // Focus the textbox element |
no test coverage detected