1
0
Fork 0

Compare commits

...

3 Commits

Author SHA1 Message Date
Finn Willard 3a42340db3 Add: Hotkey to focus industry directory filter box
Co-authored-by: Tyler Trahan <tyler@tylertrahan.com>
2023-12-19 11:23:37 -05:00
Finn Willard 7d3ae4a058 Add: Hotkey to focus town directory filter box
Co-authored-by: Tyler Trahan <tyler@tylertrahan.com>
2023-12-19 11:23:37 -05:00
Tyler Trahan e8d2ebb016
Fix: Add missing includes to timers from script implementation files (#11604) 2023-12-19 14:09:46 +00:00
5 changed files with 52 additions and 4 deletions

View File

@ -44,6 +44,7 @@
#include "stringfilter_type.h"
#include "timer/timer.h"
#include "timer/timer_window.h"
#include "hotkeys.h"
#include "table/strings.h"
@ -1299,7 +1300,10 @@ static bool CDECL CargoFilter(const Industry * const *industry, const std::pair<
static GUIIndustryList::FilterFunction * const _filter_funcs[] = { &CargoFilter };
/** Enum referring to the Hotkeys in the industry directory window */
enum IndustryDirectoryHotkeys {
IDHK_FOCUS_FILTER_BOX, ///< Focus the filter box
};
/**
* The list of industries.
*/
@ -1864,6 +1868,23 @@ public:
break;
}
}
EventState OnHotkey(int hotkey) override
{
switch (hotkey) {
case IDHK_FOCUS_FILTER_BOX:
this->SetFocusedWidget(WID_ID_FILTER);
SetFocusedWindow(this); // The user has asked to give focus to the text box, so make sure this window is focused.
break;
default:
return ES_NOT_HANDLED;
}
return ES_HANDLED;
}
static inline HotkeyList hotkeys {"industrydirectory", {
Hotkey('F', "focus_filter_box", IDHK_FOCUS_FILTER_BOX),
}};
};
Listing IndustryDirectoryWindow::last_sorting = {false, 0};
@ -1893,7 +1914,8 @@ static WindowDesc _industry_directory_desc(__FILE__, __LINE__,
WDP_AUTO, "list_industries", 428, 190,
WC_INDUSTRY_DIRECTORY, WC_NONE,
0,
std::begin(_nested_industry_directory_widgets), std::end(_nested_industry_directory_widgets)
std::begin(_nested_industry_directory_widgets), std::end(_nested_industry_directory_widgets),
&IndustryDirectoryWindow::hotkeys
);
void ShowIndustryDirectory()

View File

@ -15,6 +15,7 @@
#include "../../strings_func.h"
#include "../../station_cmd.h"
#include "../../waypoint_cmd.h"
#include "../../timer/timer_game_calendar.h"
#include "table/strings.h"
#include "../../safeguards.h"

View File

@ -11,7 +11,7 @@
#define SCRIPT_DATE_HPP
#include "script_object.hpp"
#include "timer/timer_game_calendar.h"
#include "../../timer/timer_game_calendar.h"
/**
* Class that handles all date related (calculation) functions.

View File

@ -18,6 +18,7 @@
#include "../../engine_func.h"
#include "../../articulated_vehicles.h"
#include "../../engine_cmd.h"
#include "../../timer/timer_game_calendar.h"
#include "table/strings.h"
#include "../../safeguards.h"

View File

@ -38,6 +38,7 @@
#include "timer/timer_game_calendar.h"
#include "timer/timer_window.h"
#include "zoom_func.h"
#include "hotkeys.h"
#include "widgets/town_widget.h"
@ -694,6 +695,11 @@ static const NWidgetPart _nested_town_directory_widgets[] = {
EndContainer(),
};
/** Enum referring to the Hotkeys in the town directory window */
enum TownDirectoryHotkeys {
TDHK_FOCUS_FILTER_BOX, ///< Focus the filter box
};
/** Town directory window class. */
struct TownDirectoryWindow : public Window {
private:
@ -1006,6 +1012,23 @@ public:
this->towns.ForceResort();
}
}
EventState OnHotkey(int hotkey) override
{
switch (hotkey) {
case TDHK_FOCUS_FILTER_BOX:
this->SetFocusedWidget(WID_TD_FILTER);
SetFocusedWindow(this); // The user has asked to give focus to the text box, so make sure this window is focused.
break;
default:
return ES_NOT_HANDLED;
}
return ES_HANDLED;
}
static inline HotkeyList hotkeys {"towndirectory", {
Hotkey('F', "focus_filter_box", TDHK_FOCUS_FILTER_BOX),
}};
};
Listing TownDirectoryWindow::last_sorting = {false, 0};
@ -1029,7 +1052,8 @@ static WindowDesc _town_directory_desc(__FILE__, __LINE__,
WDP_AUTO, "list_towns", 208, 202,
WC_TOWN_DIRECTORY, WC_NONE,
0,
std::begin(_nested_town_directory_widgets), std::end(_nested_town_directory_widgets)
std::begin(_nested_town_directory_widgets), std::end(_nested_town_directory_widgets),
&TownDirectoryWindow::hotkeys
);
void ShowTownDirectory()