void TextBox::SetTextStyle(const TextStyle& style) { _font_properties = TextManager->GetFontProperties(style.font); if (_font_properties == NULL) { IF_PRINT_WARNING(VIDEO_DEBUG) << "function failed because it was passed an invalid font name: " << style.font << endl; return; } _text_style = style; _ReformatText(); _initialized = true; }
void TextBox::SetDimensions(float w, float h) { if (w <= 0.0f || w > 1024.0f) { IF_PRINT_WARNING(VIDEO_DEBUG) << "invalid width argument: " << w << endl; return; } if (h <= 0.0f || h > 768.0f) { IF_PRINT_WARNING(VIDEO_DEBUG) << "invalid height argument: " << h << endl; return; } _width = w; _height = h; _ReformatText(); }
void TextBox::SetDisplayText(const ustring &text) { if(_initialized == false) { IF_PRINT_WARNING(VIDEO_DEBUG) << "function failed because the textbox was not initialized:\n" << _initialization_errors << std::endl; return; } // If the text hasn't changed, don't recompute the textbox. if (_text_save == text) return; _text_save = text; _ReformatText(); // Reset the timer since new text has been set _current_time = 0; // (3): Determine how much time the text will take to display depending on the display mode, speed, and size of the text _finished = false; switch(_mode) { case VIDEO_TEXT_INSTANT: _end_time = 0; // (4): Set finished to true only if the display mode is VIDEO_TEXT_INSTANT _finished = true; break; case VIDEO_TEXT_CHAR: // All three of these modes display one character at a time case VIDEO_TEXT_FADECHAR: case VIDEO_TEXT_REVEAL: // We desire the total number of milliseconds to render the string. // Display speed is in character per second, so cancel the character term and multiply by 1000 to get ms _end_time = static_cast<int32>(1000.0f * _num_chars / _display_speed); break; case VIDEO_TEXT_FADELINE: // Displays one line at a time // Instead of _num_chars in the other calculation, we use number of lines times CHARS_PER_LINE _end_time = static_cast<int32>(1000.0f * (_text.size() * CHARS_PER_LINE) / _display_speed); break; default: _end_time = 0; IF_PRINT_WARNING(VIDEO_DEBUG) << "unknown display mode was active: " << _mode << std::endl; break; }; } // void TextBox::SetDisplayText(const ustring& text)
void TextBox::SetTextAlignment(int32 xalign, int32 yalign) { _text_xalign = xalign; _text_yalign = yalign; _ReformatText(); }