mirror of https://github.com/OpenRCT2/OpenRCT2.git
Refactor staff window to class (#13819)
This commit is contained in:
parent
45fd8e8d05
commit
c9a07eaa84
|
@ -1096,7 +1096,7 @@ void window_staff_stats_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||||
if (!(gParkFlags & PARK_FLAGS_NO_MONEY))
|
if (!(gParkFlags & PARK_FLAGS_NO_MONEY))
|
||||||
{
|
{
|
||||||
auto ft = Formatter();
|
auto ft = Formatter();
|
||||||
ft.Add<money32>(gStaffWageTable[static_cast<uint8_t>(peep->AssignedStaffType)]);
|
ft.Add<money32>(GetStaffWage(peep->AssignedStaffType));
|
||||||
gfx_draw_string_left(dpi, STR_STAFF_STAT_WAGES, ft.Data(), COLOUR_BLACK, screenCoords);
|
gfx_draw_string_left(dpi, STR_STAFF_STAT_WAGES, ft.Data(), COLOUR_BLACK, screenCoords);
|
||||||
screenCoords.y += LIST_ROW_HEIGHT;
|
screenCoords.y += LIST_ROW_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1469,9 +1469,10 @@ void window_event_tool_update_call(rct_window* w, rct_widgetindex widgetIndex, c
|
||||||
|
|
||||||
void window_event_tool_down_call(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
|
void window_event_tool_down_call(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||||
{
|
{
|
||||||
if (w->event_handlers != nullptr)
|
if (w->event_handlers == nullptr)
|
||||||
if (w->event_handlers->tool_down != nullptr)
|
w->OnToolDown(widgetIndex, screenCoords);
|
||||||
w->event_handlers->tool_down(w, widgetIndex, screenCoords);
|
else if (w->event_handlers->tool_down != nullptr)
|
||||||
|
w->event_handlers->tool_down(w, widgetIndex, screenCoords);
|
||||||
}
|
}
|
||||||
|
|
||||||
void window_event_tool_drag_call(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
|
void window_event_tool_drag_call(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||||
|
@ -1490,9 +1491,10 @@ void window_event_tool_up_call(rct_window* w, rct_widgetindex widgetIndex, const
|
||||||
|
|
||||||
void window_event_tool_abort_call(rct_window* w, rct_widgetindex widgetIndex)
|
void window_event_tool_abort_call(rct_window* w, rct_widgetindex widgetIndex)
|
||||||
{
|
{
|
||||||
if (w->event_handlers != nullptr)
|
if (w->event_handlers == nullptr)
|
||||||
if (w->event_handlers->tool_abort != nullptr)
|
w->OnToolAbort(widgetIndex);
|
||||||
w->event_handlers->tool_abort(w, widgetIndex);
|
else if (w->event_handlers->tool_abort != nullptr)
|
||||||
|
w->event_handlers->tool_abort(w, widgetIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void window_event_unknown_0E_call(rct_window* w)
|
void window_event_unknown_0E_call(rct_window* w)
|
||||||
|
|
|
@ -684,6 +684,11 @@ void window_update_all();
|
||||||
|
|
||||||
void window_set_window_limit(int32_t value);
|
void window_set_window_limit(int32_t value);
|
||||||
|
|
||||||
|
rct_window* window_bring_to_front(rct_window* w);
|
||||||
|
rct_window* window_bring_to_front_by_class(rct_windowclass cls);
|
||||||
|
rct_window* window_bring_to_front_by_class_with_flags(rct_windowclass cls, uint16_t flags);
|
||||||
|
rct_window* window_bring_to_front_by_number(rct_windowclass cls, rct_windownumber number);
|
||||||
|
|
||||||
rct_window* WindowCreate(
|
rct_window* WindowCreate(
|
||||||
std::unique_ptr<rct_window>&& w, rct_windowclass cls, ScreenCoordsXY pos, int32_t width, int32_t height, uint32_t flags);
|
std::unique_ptr<rct_window>&& w, rct_windowclass cls, ScreenCoordsXY pos, int32_t width, int32_t height, uint32_t flags);
|
||||||
template<typename T, typename std::enable_if<std::is_base_of<rct_window, T>::value>::type* = nullptr>
|
template<typename T, typename std::enable_if<std::is_base_of<rct_window, T>::value>::type* = nullptr>
|
||||||
|
@ -696,6 +701,16 @@ T* WindowCreate(rct_windowclass cls, int32_t width, int32_t height, uint32_t fla
|
||||||
{
|
{
|
||||||
return static_cast<T*>(WindowCreate(std::make_unique<T>(), cls, {}, width, height, flags | WF_AUTO_POSITION));
|
return static_cast<T*>(WindowCreate(std::make_unique<T>(), cls, {}, width, height, flags | WF_AUTO_POSITION));
|
||||||
}
|
}
|
||||||
|
template<typename T, typename std::enable_if<std::is_base_of<rct_window, T>::value>::type* = nullptr>
|
||||||
|
T* WindowFocusOrCreate(rct_windowclass cls, int32_t width, int32_t height, uint32_t flags = 0)
|
||||||
|
{
|
||||||
|
auto* w = window_bring_to_front_by_class(cls);
|
||||||
|
if (w == nullptr)
|
||||||
|
{
|
||||||
|
w = WindowCreate<T>(cls, width, height, flags);
|
||||||
|
}
|
||||||
|
return static_cast<T*>(w);
|
||||||
|
}
|
||||||
|
|
||||||
rct_window* WindowCreate(
|
rct_window* WindowCreate(
|
||||||
const ScreenCoordsXY& pos, int32_t width, int32_t height, rct_window_event_list* event_handlers, rct_windowclass cls,
|
const ScreenCoordsXY& pos, int32_t width, int32_t height, rct_window_event_list* event_handlers, rct_windowclass cls,
|
||||||
|
@ -726,11 +741,6 @@ void WindowInitScrollWidgets(rct_window* w);
|
||||||
void window_update_scroll_widgets(rct_window* w);
|
void window_update_scroll_widgets(rct_window* w);
|
||||||
int32_t window_get_scroll_data_index(rct_window* w, rct_widgetindex widget_index);
|
int32_t window_get_scroll_data_index(rct_window* w, rct_widgetindex widget_index);
|
||||||
|
|
||||||
rct_window* window_bring_to_front(rct_window* w);
|
|
||||||
rct_window* window_bring_to_front_by_class(rct_windowclass cls);
|
|
||||||
rct_window* window_bring_to_front_by_class_with_flags(rct_windowclass cls, uint16_t flags);
|
|
||||||
rct_window* window_bring_to_front_by_number(rct_windowclass cls, rct_windownumber number);
|
|
||||||
|
|
||||||
void window_push_others_right(rct_window* w);
|
void window_push_others_right(rct_window* w);
|
||||||
void window_push_others_below(rct_window* w1);
|
void window_push_others_below(rct_window* w1);
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,12 @@ struct rct_window
|
||||||
virtual void OnScrollDraw(int32_t scrollIndex, rct_drawpixelinfo& dpi)
|
virtual void OnScrollDraw(int32_t scrollIndex, rct_drawpixelinfo& dpi)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
virtual void OnToolDown(rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual void OnToolAbort(rct_widgetindex widgetIndex)
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __WARN_SUGGEST_FINAL_METHODS__
|
#ifdef __WARN_SUGGEST_FINAL_METHODS__
|
||||||
|
|
|
@ -113,7 +113,7 @@ void finance_pay_wages()
|
||||||
|
|
||||||
for (auto peep : EntityList<Staff>(EntityListId::Peep))
|
for (auto peep : EntityList<Staff>(EntityListId::Peep))
|
||||||
{
|
{
|
||||||
finance_payment(gStaffWageTable[static_cast<uint8_t>(peep->AssignedStaffType)] / 4, ExpenditureType::Wages);
|
finance_payment(GetStaffWage(peep->AssignedStaffType) / 4, ExpenditureType::Wages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ void finance_update_daily_profit()
|
||||||
// Staff costs
|
// Staff costs
|
||||||
for (auto peep : EntityList<Staff>(EntityListId::Peep))
|
for (auto peep : EntityList<Staff>(EntityListId::Peep))
|
||||||
{
|
{
|
||||||
current_profit -= gStaffWageTable[static_cast<uint8_t>(peep->AssignedStaffType)];
|
current_profit -= GetStaffWage(peep->AssignedStaffType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Research costs
|
// Research costs
|
||||||
|
|
|
@ -44,18 +44,6 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
/**
|
|
||||||
* Monthly staff wages
|
|
||||||
*
|
|
||||||
* rct2: 0x00992A00
|
|
||||||
*/
|
|
||||||
const money32 gStaffWageTable[static_cast<uint8_t>(StaffType::Count)] = {
|
|
||||||
MONEY(50, 00), // Handyman
|
|
||||||
MONEY(80, 00), // Mechanic
|
|
||||||
MONEY(60, 00), // Security guard
|
|
||||||
MONEY(55, 00), // Entertainer
|
|
||||||
};
|
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
const rct_string_id StaffCostumeNames[] = {
|
const rct_string_id StaffCostumeNames[] = {
|
||||||
STR_STAFF_OPTION_COSTUME_PANDA,
|
STR_STAFF_OPTION_COSTUME_PANDA,
|
||||||
|
@ -2677,3 +2665,19 @@ void Staff::UpdateRideInspected(ride_id_t rideIndex)
|
||||||
| RIDE_INVALIDATE_RIDE_LIST;
|
| RIDE_INVALIDATE_RIDE_LIST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
money32 GetStaffWage(StaffType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case StaffType::Handyman:
|
||||||
|
return MONEY(50, 00);
|
||||||
|
case StaffType::Mechanic:
|
||||||
|
return MONEY(80, 00);
|
||||||
|
case StaffType::Security:
|
||||||
|
return MONEY(60, 00);
|
||||||
|
case StaffType::Entertainer:
|
||||||
|
return MONEY(55, 00);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -52,8 +52,6 @@ enum class EntertainerCostume : uint8_t
|
||||||
Count
|
Count
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const money32 gStaffWageTable[static_cast<uint8_t>(StaffType::Count)];
|
|
||||||
|
|
||||||
extern const rct_string_id StaffCostumeNames[static_cast<uint8_t>(EntertainerCostume::Count)];
|
extern const rct_string_id StaffCostumeNames[static_cast<uint8_t>(EntertainerCostume::Count)];
|
||||||
|
|
||||||
extern uint32_t gStaffPatrolAreas[(STAFF_MAX_COUNT + static_cast<uint8_t>(StaffType::Count)) * STAFF_PATROL_AREA_SIZE];
|
extern uint32_t gStaffPatrolAreas[(STAFF_MAX_COUNT + static_cast<uint8_t>(StaffType::Count)) * STAFF_PATROL_AREA_SIZE];
|
||||||
|
@ -75,6 +73,7 @@ bool staff_set_colour(StaffType staffType, colour_t value);
|
||||||
uint32_t staff_get_available_entertainer_costumes();
|
uint32_t staff_get_available_entertainer_costumes();
|
||||||
int32_t staff_get_available_entertainer_costume_list(EntertainerCostume* costumeList);
|
int32_t staff_get_available_entertainer_costume_list(EntertainerCostume* costumeList);
|
||||||
|
|
||||||
|
money32 GetStaffWage(StaffType type);
|
||||||
PeepSpriteType EntertainerCostumeToSprite(EntertainerCostume entertainerType);
|
PeepSpriteType EntertainerCostumeToSprite(EntertainerCostume entertainerType);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue