Merge branch 'master' into jgrpp
Replace build and refit, and group collapse implementations Fix template creation build and refit # Conflicts: # Makefile.bundle.in # config.lib # src/animated_tile.cpp # src/blitter/32bpp_anim.hpp # src/blitter/32bpp_base.hpp # src/blitter/8bpp_base.hpp # src/blitter/null.hpp # src/build_vehicle_gui.cpp # src/command.cpp # src/command_func.h # src/console_gui.cpp # src/core/smallstack_type.hpp # src/date.cpp # src/debug.cpp # src/genworld_gui.cpp # src/ground_vehicle.hpp # src/group_gui.cpp # src/lang/korean.txt # src/linkgraph/linkgraph_gui.h # src/main_gui.cpp # src/misc_gui.cpp # src/network/core/game.h # src/network/core/packet.cpp # src/network/core/udp.cpp # src/network/core/udp.h # src/network/network_content.cpp # src/network/network_type.h # src/network/network_udp.cpp # src/newgrf_house.h # src/openttd.cpp # src/order_cmd.cpp # src/order_gui.cpp # src/os/unix/crashlog_unix.cpp # src/os/windows/crashlog_win.cpp # src/osk_gui.cpp # src/pathfinder/opf/opf_ship.cpp # src/rail_cmd.cpp # src/rail_gui.cpp # src/saveload/saveload.cpp # src/settings.cpp # src/settings_gui.cpp # src/smallmap_gui.h # src/station_base.h # src/station_cmd.cpp # src/table/gameopt_settings.ini # src/table/newgrf_debug_data.h # src/table/settings.ini # src/timetable_gui.cpp # src/toolbar_gui.cpp # src/train_gui.cpp # src/vehicle.cpp # src/vehicle_gui.cpp # src/vehiclelist.cpp # src/viewport.cpp # src/widgets/dropdown.cpp # src/window_gui.h
This commit is contained in:
@@ -24,7 +24,7 @@ char *_hotkeys_file;
|
||||
* List of all HotkeyLists.
|
||||
* This is a pointer to ensure initialisation order with the various static HotkeyList instances.
|
||||
*/
|
||||
static SmallVector<HotkeyList*, 16> *_hotkey_lists = NULL;
|
||||
static std::vector<HotkeyList*> *_hotkey_lists = NULL;
|
||||
|
||||
/** String representation of a keycode */
|
||||
struct KeycodeNames {
|
||||
@@ -205,7 +205,7 @@ const char *SaveKeycodes(const Hotkey *hotkey)
|
||||
{
|
||||
static char buf[128];
|
||||
buf[0] = '\0';
|
||||
for (uint i = 0; i < hotkey->keycodes.Length(); i++) {
|
||||
for (uint i = 0; i < hotkey->keycodes.size(); i++) {
|
||||
const char *str = KeycodeToString(hotkey->keycodes[i]);
|
||||
if (i > 0) strecat(buf, ",", lastof(buf));
|
||||
strecat(buf, str, lastof(buf));
|
||||
@@ -250,19 +250,19 @@ Hotkey::Hotkey(const uint16 *default_keycodes, const char *name, int num) :
|
||||
*/
|
||||
void Hotkey::AddKeycode(uint16 keycode)
|
||||
{
|
||||
this->keycodes.Include(keycode);
|
||||
include(this->keycodes, keycode);
|
||||
}
|
||||
|
||||
HotkeyList::HotkeyList(const char *ini_group, Hotkey *items, GlobalHotkeyHandlerFunc global_hotkey_handler) :
|
||||
global_hotkey_handler(global_hotkey_handler), ini_group(ini_group), items(items)
|
||||
{
|
||||
if (_hotkey_lists == NULL) _hotkey_lists = new SmallVector<HotkeyList*, 16>();
|
||||
*_hotkey_lists->Append() = this;
|
||||
if (_hotkey_lists == NULL) _hotkey_lists = new std::vector<HotkeyList*>();
|
||||
_hotkey_lists->push_back(this);
|
||||
}
|
||||
|
||||
HotkeyList::~HotkeyList()
|
||||
{
|
||||
_hotkey_lists->Erase(_hotkey_lists->Find(this));
|
||||
_hotkey_lists->erase(std::find(_hotkey_lists->begin(), _hotkey_lists->end(), this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -275,7 +275,7 @@ void HotkeyList::Load(IniFile *ini)
|
||||
for (Hotkey *hotkey = this->items; hotkey->name != NULL; ++hotkey) {
|
||||
IniItem *item = group->GetItem(hotkey->name, false);
|
||||
if (item != NULL) {
|
||||
hotkey->keycodes.Clear();
|
||||
hotkey->keycodes.clear();
|
||||
if (item->value != NULL) ParseHotkeys(hotkey, item->value);
|
||||
}
|
||||
}
|
||||
@@ -303,7 +303,9 @@ void HotkeyList::Save(IniFile *ini) const
|
||||
int HotkeyList::CheckMatch(uint16 keycode, bool global_only) const
|
||||
{
|
||||
for (const Hotkey *list = this->items; list->name != NULL; ++list) {
|
||||
if (list->keycodes.Contains(keycode | WKC_GLOBAL_HOTKEY) || (!global_only && list->keycodes.Contains(keycode))) {
|
||||
auto begin = list->keycodes.begin();
|
||||
auto end = list->keycodes.end();
|
||||
if (std::find(begin, end, keycode | WKC_GLOBAL_HOTKEY) != end || (!global_only && std::find(begin, end, keycode) != end)) {
|
||||
return list->num;
|
||||
}
|
||||
}
|
||||
@@ -316,11 +318,11 @@ static void SaveLoadHotkeys(bool save)
|
||||
IniFile *ini = new IniFile();
|
||||
ini->LoadFromDisk(_hotkeys_file, NO_DIRECTORY);
|
||||
|
||||
for (HotkeyList **list = _hotkey_lists->Begin(); list != _hotkey_lists->End(); ++list) {
|
||||
for (HotkeyList *list : *_hotkey_lists) {
|
||||
if (save) {
|
||||
(*list)->Save(ini);
|
||||
list->Save(ini);
|
||||
} else {
|
||||
(*list)->Load(ini);
|
||||
list->Load(ini);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,11 +345,11 @@ void SaveHotkeysToConfig()
|
||||
|
||||
void HandleGlobalHotkeys(WChar key, uint16 keycode)
|
||||
{
|
||||
for (HotkeyList **list = _hotkey_lists->Begin(); list != _hotkey_lists->End(); ++list) {
|
||||
if ((*list)->global_hotkey_handler == NULL) continue;
|
||||
for (HotkeyList *list : *_hotkey_lists) {
|
||||
if (list->global_hotkey_handler == NULL) continue;
|
||||
|
||||
int hotkey = (*list)->CheckMatch(keycode, true);
|
||||
if (hotkey >= 0 && ((*list)->global_hotkey_handler(hotkey) == ES_HANDLED)) return;
|
||||
int hotkey = list->CheckMatch(keycode, true);
|
||||
if (hotkey >= 0 && (list->global_hotkey_handler(hotkey) == ES_HANDLED)) return;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user