mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: replace std::vector + duplicate preventing include with std::set
This commit is contained in:
parent
07860e67e2
commit
80d8c01814
|
@ -213,9 +213,9 @@ static std::string KeycodeToString(uint16 keycode)
|
||||||
std::string SaveKeycodes(const Hotkey *hotkey)
|
std::string SaveKeycodes(const Hotkey *hotkey)
|
||||||
{
|
{
|
||||||
std::string str;
|
std::string str;
|
||||||
for (uint i = 0; i < hotkey->keycodes.size(); i++) {
|
for (auto keycode : hotkey->keycodes) {
|
||||||
if (i > 0) str += ",";
|
if (!str.empty()) str += ",";
|
||||||
str += KeycodeToString(hotkey->keycodes[i]);
|
str += KeycodeToString(keycode);
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ Hotkey::Hotkey(const uint16 *default_keycodes, const char *name, int num) :
|
||||||
*/
|
*/
|
||||||
void Hotkey::AddKeycode(uint16 keycode)
|
void Hotkey::AddKeycode(uint16 keycode)
|
||||||
{
|
{
|
||||||
include(this->keycodes, keycode);
|
this->keycodes.insert(keycode);
|
||||||
}
|
}
|
||||||
|
|
||||||
HotkeyList::HotkeyList(const char *ini_group, Hotkey *items, GlobalHotkeyHandlerFunc global_hotkey_handler) :
|
HotkeyList::HotkeyList(const char *ini_group, Hotkey *items, GlobalHotkeyHandlerFunc global_hotkey_handler) :
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#ifndef HOTKEYS_H
|
#ifndef HOTKEYS_H
|
||||||
#define HOTKEYS_H
|
#define HOTKEYS_H
|
||||||
|
|
||||||
#include "core/smallvec_type.hpp"
|
|
||||||
#include "gfx_type.h"
|
#include "gfx_type.h"
|
||||||
#include "window_type.h"
|
#include "window_type.h"
|
||||||
#include "string_type.h"
|
#include "string_type.h"
|
||||||
|
@ -27,7 +26,7 @@ struct Hotkey {
|
||||||
|
|
||||||
const char *name;
|
const char *name;
|
||||||
int num;
|
int num;
|
||||||
std::vector<uint16> keycodes;
|
std::set<uint16> keycodes;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define HOTKEY_LIST_END Hotkey((uint16)0, nullptr, -1)
|
#define HOTKEY_LIST_END Hotkey((uint16)0, nullptr, -1)
|
||||||
|
|
Loading…
Reference in New Issue