Add rotation hotkey for depot building window
This commit is contained in:
@@ -2058,8 +2058,8 @@ static WindowDesc _build_depot_desc(
|
||||
WDP_AUTO, nullptr, 0, 0,
|
||||
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_build_depot_widgets, lengthof(_nested_build_depot_widgets),
|
||||
&BuildRailDepotWindow::hotkeys // CityMania addition
|
||||
_nested_build_depot_widgets, lengthof(_nested_build_depot_widgets)
|
||||
,&BuildRailDepotWindow::hotkeys // CityMania addition
|
||||
);
|
||||
|
||||
static void ShowBuildTrainDepotPicker(Window *parent)
|
||||
|
||||
@@ -1005,6 +1005,13 @@ Window *ShowBuildRoadScenToolbar(RoadType roadtype)
|
||||
}
|
||||
|
||||
struct BuildRoadDepotWindow : public PickerWindowBase {
|
||||
/* CityMania code start */
|
||||
public:
|
||||
enum class Hotkey : int {
|
||||
ROTATE,
|
||||
};
|
||||
/* CityMania code end */
|
||||
|
||||
BuildRoadDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
|
||||
{
|
||||
this->CreateNestedTree();
|
||||
@@ -1062,6 +1069,33 @@ struct BuildRoadDepotWindow : public PickerWindowBase {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* CityMania code start */
|
||||
EventState OnHotkey(int hotkey) override
|
||||
{
|
||||
switch ((BuildRoadDepotWindow::Hotkey)hotkey) {
|
||||
/* Indicate to the OnClick that the action comes from a hotkey rather
|
||||
* then from a click and that the CTRL state should be ignored. */
|
||||
case BuildRoadDepotWindow::Hotkey::ROTATE:
|
||||
if (_road_depot_orientation < DIAGDIR_END) {
|
||||
this->RaiseWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
|
||||
_road_depot_orientation = ChangeDiagDir(_road_depot_orientation, DIAGDIRDIFF_90RIGHT);
|
||||
this->LowerWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
|
||||
} else {
|
||||
citymania::RotateAutodetection();
|
||||
}
|
||||
this->SetDirty();
|
||||
return ES_HANDLED;
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
|
||||
return ES_NOT_HANDLED;
|
||||
}
|
||||
|
||||
static HotkeyList hotkeys;
|
||||
/* CityMania code end */
|
||||
};
|
||||
|
||||
static const NWidgetPart _nested_build_road_depot_widgets[] = {
|
||||
@@ -1100,11 +1134,20 @@ static const NWidgetPart _nested_build_road_depot_widgets[] = {
|
||||
EndContainer(),
|
||||
};
|
||||
|
||||
/* CityMania code start */
|
||||
static Hotkey build_depot_hotkeys[] = {
|
||||
Hotkey(CM_WKC_MOUSE_MIDDLE, "rotate", (int)BuildRoadDepotWindow::Hotkey::ROTATE),
|
||||
HOTKEY_LIST_END
|
||||
};
|
||||
HotkeyList BuildRoadDepotWindow::hotkeys("cm_build_road_depot", build_depot_hotkeys);
|
||||
/* CityMania code end */
|
||||
|
||||
static WindowDesc _build_road_depot_desc(
|
||||
WDP_AUTO, nullptr, 0, 0,
|
||||
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_build_road_depot_widgets, lengthof(_nested_build_road_depot_widgets)
|
||||
,&BuildRoadDepotWindow::hotkeys // CityMania addition
|
||||
);
|
||||
|
||||
static void ShowRoadDepotPicker(Window *parent)
|
||||
|
||||
Reference in New Issue
Block a user