mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-23 06:44:38 +01:00
Fix scrolling text
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "../common.h"
|
||||
#include "../config/Config.h"
|
||||
#include "../core/String.hpp"
|
||||
#include "../drawing/Drawing.h"
|
||||
#include "../interface/Viewport.h"
|
||||
#include "../localisation/Formatting.h"
|
||||
@@ -23,81 +24,6 @@
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
class CodepointView
|
||||
{
|
||||
private:
|
||||
std::string_view _str;
|
||||
|
||||
public:
|
||||
class iterator
|
||||
{
|
||||
private:
|
||||
std::string_view _str;
|
||||
size_t _index;
|
||||
|
||||
public:
|
||||
iterator(std::string_view str, size_t index)
|
||||
: _str(str)
|
||||
, _index(index)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(const iterator& rhs) const
|
||||
{
|
||||
return _index == rhs._index;
|
||||
}
|
||||
bool operator!=(const iterator& rhs) const
|
||||
{
|
||||
return _index != rhs._index;
|
||||
}
|
||||
const char32_t operator*() const
|
||||
{
|
||||
return utf8_get_next(&_str[_index], nullptr);
|
||||
}
|
||||
iterator& operator++()
|
||||
{
|
||||
if (_index < _str.size())
|
||||
{
|
||||
const utf8* nextch;
|
||||
utf8_get_next(&_str[_index], &nextch);
|
||||
_index = nextch - _str.data();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
iterator operator++(int)
|
||||
{
|
||||
auto result = *this;
|
||||
if (_index < _str.size())
|
||||
{
|
||||
const utf8* nextch;
|
||||
utf8_get_next(&_str[_index], &nextch);
|
||||
_index = nextch - _str.data();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t GetIndex() const
|
||||
{
|
||||
return _index;
|
||||
}
|
||||
};
|
||||
|
||||
CodepointView(std::string_view str)
|
||||
: _str(str)
|
||||
{
|
||||
}
|
||||
|
||||
iterator begin() const
|
||||
{
|
||||
return iterator(_str, 0);
|
||||
}
|
||||
|
||||
iterator end() const
|
||||
{
|
||||
return iterator(_str, _str.size());
|
||||
}
|
||||
};
|
||||
|
||||
enum : uint32_t
|
||||
{
|
||||
TEXT_DRAW_FLAG_INSET = 1 << 0,
|
||||
|
||||
Reference in New Issue
Block a user