mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 19:13:07 +01:00
Merge pull request #16101 from ZehMatt/refactor/staff-ui-logic
Refactor some code into UI for Staff
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <openrct2/Input.h>
|
||||
#include <openrct2/actions/PeepPickupAction.h>
|
||||
#include <openrct2/actions/StaffSetCostumeAction.h>
|
||||
#include <openrct2/actions/StaffSetNameAction.h>
|
||||
#include <openrct2/actions/StaffSetOrdersAction.h>
|
||||
#include <openrct2/actions/StaffSetPatrolAreaAction.h>
|
||||
#include <openrct2/config/Config.h>
|
||||
@@ -1320,7 +1321,9 @@ void WindowStaffOverviewTextInput(rct_window* w, rct_widgetindex widgetIndex, ch
|
||||
|
||||
if (text == nullptr)
|
||||
return;
|
||||
staff_set_name(w->number, text);
|
||||
|
||||
auto gameAction = StaffSetNameAction(w->number, text);
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/Input.h>
|
||||
#include <openrct2/actions/StaffFireAction.h>
|
||||
#include <openrct2/actions/StaffHireNewAction.h>
|
||||
#include <openrct2/actions/StaffSetColourAction.h>
|
||||
#include <openrct2/config/Config.h>
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
@@ -137,7 +138,7 @@ public:
|
||||
{
|
||||
costume = GetRandomEntertainerCostume();
|
||||
}
|
||||
staff_hire_new_member(staffType, costume);
|
||||
HireNewMember(staffType, costume);
|
||||
break;
|
||||
}
|
||||
case WIDX_STAFF_LIST_SHOW_PATROL_AREA_BUTTON:
|
||||
@@ -498,6 +499,48 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Hires a new staff member of the given type.
|
||||
*/
|
||||
void HireNewMember(StaffType staffType, EntertainerCostume entertainerType)
|
||||
{
|
||||
bool autoPosition = gConfigGeneral.auto_staff_placement;
|
||||
if (gInputPlaceObjectModifier & PLACE_OBJECT_MODIFIER_SHIFT_Z)
|
||||
{
|
||||
autoPosition = autoPosition ^ 1;
|
||||
}
|
||||
|
||||
uint32_t staffOrders = 0;
|
||||
|
||||
if (staffType == StaffType::Handyman)
|
||||
{
|
||||
staffOrders = STAFF_ORDERS_SWEEPING | STAFF_ORDERS_WATER_FLOWERS | STAFF_ORDERS_EMPTY_BINS;
|
||||
if (gConfigGeneral.handymen_mow_default)
|
||||
{
|
||||
staffOrders |= STAFF_ORDERS_MOWING;
|
||||
}
|
||||
}
|
||||
else if (staffType == StaffType::Mechanic)
|
||||
{
|
||||
staffOrders = STAFF_ORDERS_INSPECT_RIDES | STAFF_ORDERS_FIX_RIDES;
|
||||
}
|
||||
|
||||
auto hireStaffAction = StaffHireNewAction(autoPosition, staffType, entertainerType, staffOrders);
|
||||
hireStaffAction.SetCallback([=](const GameAction*, const GameActions::Result* res) -> void {
|
||||
if (res->Error != GameActions::Status::Ok)
|
||||
return;
|
||||
|
||||
auto actionResult = res->GetData<StaffHireNewActionResult>();
|
||||
// Open window for new staff.
|
||||
auto* staff = GetEntity<Staff>(actionResult.StaffEntityId);
|
||||
auto intent = Intent(WC_PEEP);
|
||||
intent.putExtra(INTENT_EXTRA_PEEP, staff);
|
||||
context_open_intent(&intent);
|
||||
});
|
||||
|
||||
GameActions::Execute(&hireStaffAction);
|
||||
}
|
||||
|
||||
StaffType GetSelectedStaffType() const
|
||||
{
|
||||
return static_cast<StaffType>(_selectedTab);
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "RideSetNameAction.h"
|
||||
#include "RideSetStatusAction.h"
|
||||
#include "SetParkEntranceFeeAction.h"
|
||||
#include "StaffSetNameAction.h"
|
||||
#include "WallRemoveAction.h"
|
||||
|
||||
#pragma region PlaceParkEntranceAction
|
||||
@@ -118,15 +117,6 @@ void guest_set_name(uint16_t spriteIndex, const char* name)
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region StaffSetName
|
||||
|
||||
void staff_set_name(uint16_t spriteIndex, const char* name)
|
||||
{
|
||||
auto gameAction = StaffSetNameAction(spriteIndex, name);
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region MazeSetTrack
|
||||
money32 maze_set_track(
|
||||
uint16_t x, uint16_t y, uint16_t z, uint8_t flags, bool initialPlacement, uint8_t direction, ride_id_t rideIndex,
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "../Context.h"
|
||||
#include "../Game.h"
|
||||
#include "../Input.h"
|
||||
#include "../actions/StaffHireNewAction.h"
|
||||
#include "../actions/StaffSetOrdersAction.h"
|
||||
#include "../audio/audio.h"
|
||||
#include "../config/Config.h"
|
||||
@@ -91,49 +90,6 @@ void staff_reset_modes()
|
||||
staff_update_greyed_patrol_areas();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hires a new staff member of the given type.
|
||||
*/
|
||||
bool staff_hire_new_member(StaffType staffType, EntertainerCostume entertainerType)
|
||||
{
|
||||
bool autoPosition = gConfigGeneral.auto_staff_placement;
|
||||
if (gInputPlaceObjectModifier & PLACE_OBJECT_MODIFIER_SHIFT_Z)
|
||||
{
|
||||
autoPosition = autoPosition ^ 1;
|
||||
}
|
||||
|
||||
uint32_t staffOrders = 0;
|
||||
|
||||
if (staffType == StaffType::Handyman)
|
||||
{
|
||||
staffOrders = STAFF_ORDERS_SWEEPING | STAFF_ORDERS_WATER_FLOWERS | STAFF_ORDERS_EMPTY_BINS;
|
||||
if (gConfigGeneral.handymen_mow_default)
|
||||
{
|
||||
staffOrders |= STAFF_ORDERS_MOWING;
|
||||
}
|
||||
}
|
||||
else if (staffType == StaffType::Mechanic)
|
||||
{
|
||||
staffOrders = STAFF_ORDERS_INSPECT_RIDES | STAFF_ORDERS_FIX_RIDES;
|
||||
}
|
||||
|
||||
auto hireStaffAction = StaffHireNewAction(autoPosition, staffType, entertainerType, staffOrders);
|
||||
hireStaffAction.SetCallback([=](const GameAction*, const GameActions::Result* res) -> void {
|
||||
if (res->Error != GameActions::Status::Ok)
|
||||
return;
|
||||
|
||||
auto actionResult = res->GetData<StaffHireNewActionResult>();
|
||||
// Open window for new staff.
|
||||
auto* staff = GetEntity<Staff>(actionResult.StaffEntityId);
|
||||
auto intent = Intent(WC_PEEP);
|
||||
intent.putExtra(INTENT_EXTRA_PEEP, staff);
|
||||
context_open_intent(&intent);
|
||||
});
|
||||
|
||||
auto res = GameActions::Execute(&hireStaffAction);
|
||||
return res.Error == GameActions::Status::Ok;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006C0C3F
|
||||
|
||||
@@ -156,8 +156,6 @@ extern colour_t gStaffMechanicColour;
|
||||
extern colour_t gStaffSecurityColour;
|
||||
|
||||
void staff_reset_modes();
|
||||
void staff_set_name(uint16_t spriteIndex, const char* name);
|
||||
bool staff_hire_new_member(StaffType staffType, EntertainerCostume entertainerType);
|
||||
void staff_update_greyed_patrol_areas();
|
||||
bool staff_is_patrol_area_set_for_type(StaffType type, const CoordsXY& coords);
|
||||
colour_t staff_get_colour(StaffType staffType);
|
||||
|
||||
Reference in New Issue
Block a user