mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-04 09:18:38 +00:00
GUI: U32: Use game-list filters with u32
- Add a contains utility function to ustr - setFilter uses U32String and U32Tokenizers - Make consequent changes in launcher to allow sending u32strings
This commit is contained in:
parent
56911beea2
commit
2ca907b4a2
@ -229,6 +229,29 @@ bool U32String::contains(value_type x) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool U32String::contains(const U32String &otherString) const {
|
||||
if (empty() || otherString.empty() || _size < otherString.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int size = 0;
|
||||
U32String::const_iterator itr = otherString.begin();
|
||||
|
||||
for (U32String::const_iterator itr2 = begin(); itr != otherString.end() && itr2 != end(); itr2++) {
|
||||
if (*itr == *itr2) {
|
||||
itr++;
|
||||
size++;
|
||||
if (size == otherString.size())
|
||||
return true;
|
||||
} else {
|
||||
size = 0;
|
||||
itr = otherString.begin();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void U32String::insertChar(value_type c, uint32 p) {
|
||||
assert(p <= _size);
|
||||
|
||||
|
@ -150,6 +150,11 @@ public:
|
||||
|
||||
bool contains(value_type x) const;
|
||||
|
||||
/**
|
||||
* Checks if a given string is present in the internal string or not.
|
||||
*/
|
||||
bool contains(const U32String &otherString) const;
|
||||
|
||||
inline const value_type *c_str() const { return _str; }
|
||||
inline uint32 size() const { return _size; }
|
||||
|
||||
|
@ -323,7 +323,7 @@ void LauncherDialog::updateListing() {
|
||||
|
||||
// Update the filter settings, those are lost when "setList"
|
||||
// is called.
|
||||
_list->setFilter(Common::convertFromU32String(_searchWidget->getEditString()));
|
||||
_list->setFilter(_searchWidget->getEditString());
|
||||
}
|
||||
|
||||
void LauncherDialog::addGame() {
|
||||
@ -673,12 +673,12 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
|
||||
break;
|
||||
case kSearchCmd:
|
||||
// Update the active search filter.
|
||||
_list->setFilter(Common::convertFromU32String(_searchWidget->getEditString()));
|
||||
_list->setFilter(_searchWidget->getEditString());
|
||||
break;
|
||||
case kSearchClearCmd:
|
||||
// Reset the active search filter, thus showing all games again
|
||||
_searchWidget->setEditString(Common::U32String(""));
|
||||
_list->setFilter("");
|
||||
_list->setFilter(Common::U32String(""));
|
||||
break;
|
||||
default:
|
||||
Dialog::handleCommand(sender, cmd, data);
|
||||
|
@ -730,12 +730,12 @@ void ListWidget::reflowLayout() {
|
||||
}
|
||||
}
|
||||
|
||||
void ListWidget::setFilter(const String &filter, bool redraw) {
|
||||
void ListWidget::setFilter(const U32String &filter, bool redraw) {
|
||||
// FIXME: This method does not deal correctly with edit mode!
|
||||
// Until we fix that, let's make sure it isn't called while editing takes place
|
||||
assert(!_editMode);
|
||||
|
||||
String filt = filter;
|
||||
U32String filt = filter;
|
||||
filt.toLowercase();
|
||||
|
||||
if (_filter == filt) // Filter was not changed
|
||||
@ -751,15 +751,15 @@ void ListWidget::setFilter(const String &filter, bool redraw) {
|
||||
// Restrict the list to everything which contains all words in _filter
|
||||
// as substrings, ignoring case.
|
||||
|
||||
Common::StringTokenizer tok(_filter);
|
||||
String tmp;
|
||||
Common::U32StringTokenizer tok(_filter);
|
||||
U32String tmp;
|
||||
int n = 0;
|
||||
|
||||
_list.clear();
|
||||
_listIndex.clear();
|
||||
|
||||
for (U32StringArray::iterator i = _dataList.begin(); i != _dataList.end(); ++i, ++n) {
|
||||
tmp = Common::convertFromU32String(*i);
|
||||
tmp = *i;
|
||||
tmp.toLowercase();
|
||||
bool matches = true;
|
||||
tok.reset();
|
||||
|
@ -81,7 +81,7 @@ protected:
|
||||
int _bottomPadding;
|
||||
int _scrollBarWidth;
|
||||
|
||||
String _filter;
|
||||
U32String _filter;
|
||||
bool _quickSelect;
|
||||
bool _dictionarySelect;
|
||||
|
||||
@ -128,7 +128,7 @@ public:
|
||||
void startEditMode() override;
|
||||
void endEditMode() override;
|
||||
|
||||
void setFilter(const String &filter, bool redraw = true);
|
||||
void setFilter(const U32String &filter, bool redraw = true);
|
||||
|
||||
void handleTickle() override;
|
||||
void handleMouseDown(int x, int y, int button, int clickCount) override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user