2016-05-04 19:24:41 +02:00
|
|
|
/*****************************************************************************
|
2020-07-21 15:04:34 +02:00
|
|
|
* Copyright (c) 2014-2020 OpenRCT2 developers
|
2016-05-04 19:24:41 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2016-05-04 19:24:41 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2016-05-04 19:24:41 +02:00
|
|
|
*****************************************************************************/
|
2014-10-07 20:39:52 +02:00
|
|
|
|
2017-10-16 00:13:22 +02:00
|
|
|
#include <limits>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2-ui/interface/Dropdown.h>
|
|
|
|
#include <openrct2-ui/interface/Viewport.h>
|
|
|
|
#include <openrct2-ui/interface/Widget.h>
|
2017-08-12 23:06:12 +02:00
|
|
|
#include <openrct2-ui/windows/Window.h>
|
2017-09-06 16:09:35 +02:00
|
|
|
#include <openrct2/Context.h>
|
2017-11-30 18:17:06 +01:00
|
|
|
#include <openrct2/Game.h>
|
2017-12-12 14:52:57 +01:00
|
|
|
#include <openrct2/Input.h>
|
2019-03-16 21:45:52 +01:00
|
|
|
#include <openrct2/actions/StaffFireAction.hpp>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2/actions/StaffSetColourAction.hpp>
|
|
|
|
#include <openrct2/config/Config.h>
|
|
|
|
#include <openrct2/drawing/Drawing.h>
|
2018-01-06 18:32:25 +01:00
|
|
|
#include <openrct2/localisation/Localisation.h>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2/management/Finance.h>
|
2017-10-13 10:06:36 +02:00
|
|
|
#include <openrct2/peep/Staff.h>
|
2017-09-18 17:05:28 +02:00
|
|
|
#include <openrct2/sprites.h>
|
2017-12-13 13:02:24 +01:00
|
|
|
#include <openrct2/util/Util.h>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2/windows/Intent.h>
|
2018-01-11 10:59:26 +01:00
|
|
|
#include <openrct2/world/Footpath.h>
|
2018-03-19 23:28:40 +01:00
|
|
|
#include <openrct2/world/Park.h>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2/world/Sprite.h>
|
2020-03-28 13:12:53 +01:00
|
|
|
#include <vector>
|
2014-10-07 20:39:52 +02:00
|
|
|
|
2018-05-16 20:41:29 +02:00
|
|
|
// clang-format off
|
2014-10-07 20:39:52 +02:00
|
|
|
enum {
|
2017-06-06 23:24:18 +02:00
|
|
|
WINDOW_STAFF_LIST_TAB_HANDYMEN,
|
|
|
|
WINDOW_STAFF_LIST_TAB_MECHANICS,
|
|
|
|
WINDOW_STAFF_LIST_TAB_SECURITY,
|
|
|
|
WINDOW_STAFF_LIST_TAB_ENTERTAINERS
|
2017-08-02 00:20:32 +02:00
|
|
|
};
|
2014-10-07 20:39:52 +02:00
|
|
|
|
2020-03-28 13:12:53 +01:00
|
|
|
static std::vector<uint16_t> StaffList;
|
2017-08-06 14:41:13 +02:00
|
|
|
static bool _quick_fire_mode = false;
|
2015-06-10 18:17:42 +02:00
|
|
|
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_staff_list_close(rct_window *w);
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_staff_list_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_staff_list_resize(rct_window *w);
|
2017-07-03 23:09:46 +02:00
|
|
|
static void window_staff_list_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct_widget* widget);
|
2018-06-20 17:28:51 +02:00
|
|
|
static void window_staff_list_dropdown(rct_window *w, rct_widgetindex widgetIndex, int32_t dropdownIndex);
|
2014-10-07 20:39:52 +02:00
|
|
|
static void window_staff_list_update(rct_window *w);
|
2020-02-29 03:43:29 +01:00
|
|
|
static void window_staff_list_tooldown(rct_window *w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords);
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_staff_list_toolabort(rct_window *w, rct_widgetindex widgetIndex);
|
2018-06-20 17:28:51 +02:00
|
|
|
static void window_staff_list_scrollgetsize(rct_window *w, int32_t scrollIndex, int32_t *width, int32_t *height);
|
2020-02-29 03:43:29 +01:00
|
|
|
static void window_staff_list_scrollmousedown(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
|
|
|
static void window_staff_list_scrollmouseover(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_staff_list_invalidate(rct_window *w);
|
|
|
|
static void window_staff_list_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
2018-06-20 17:28:51 +02:00
|
|
|
static void window_staff_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int32_t scrollIndex);
|
2015-07-10 02:39:16 +02:00
|
|
|
|
|
|
|
static rct_window_event_list window_staff_list_events = {
|
2017-06-06 23:24:18 +02:00
|
|
|
window_staff_list_close,
|
|
|
|
window_staff_list_mouseup,
|
|
|
|
window_staff_list_resize,
|
|
|
|
window_staff_list_mousedown,
|
|
|
|
window_staff_list_dropdown,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_staff_list_update,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_staff_list_tooldown,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_staff_list_toolabort,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_staff_list_scrollgetsize,
|
|
|
|
window_staff_list_scrollmousedown,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_staff_list_scrollmouseover,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2018-08-04 16:24:24 +02:00
|
|
|
nullptr,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_staff_list_invalidate,
|
|
|
|
window_staff_list_paint,
|
|
|
|
window_staff_list_scrollpaint,
|
2014-10-07 20:39:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum WINDOW_STAFF_LIST_WIDGET_IDX {
|
2017-06-06 23:24:18 +02:00
|
|
|
WIDX_STAFF_LIST_BACKGROUND,
|
|
|
|
WIDX_STAFF_LIST_TITLE,
|
|
|
|
WIDX_STAFF_LIST_CLOSE,
|
|
|
|
WIDX_STAFF_LIST_TAB_CONTENT_PANEL,
|
|
|
|
WIDX_STAFF_LIST_HANDYMEN_TAB,
|
|
|
|
WIDX_STAFF_LIST_MECHANICS_TAB,
|
|
|
|
WIDX_STAFF_LIST_SECURITY_TAB,
|
|
|
|
WIDX_STAFF_LIST_ENTERTAINERS_TAB,
|
|
|
|
WIDX_STAFF_LIST_LIST,
|
|
|
|
WIDX_STAFF_LIST_UNIFORM_COLOUR_PICKER,
|
|
|
|
WIDX_STAFF_LIST_HIRE_BUTTON,
|
|
|
|
WIDX_STAFF_LIST_QUICK_FIRE,
|
|
|
|
WIDX_STAFF_LIST_SHOW_PATROL_AREA_BUTTON,
|
|
|
|
WIDX_STAFF_LIST_MAP,
|
2014-10-07 20:39:52 +02:00
|
|
|
};
|
|
|
|
|
2020-05-05 22:26:14 +02:00
|
|
|
static constexpr const rct_string_id WINDOW_TITLE = STR_STAFF;
|
2020-05-09 17:05:01 +02:00
|
|
|
static constexpr const int32_t WW = 320;
|
|
|
|
static constexpr const int32_t WH = 270;
|
2019-10-24 05:38:13 +02:00
|
|
|
constexpr int32_t MAX_WW = 500;
|
|
|
|
constexpr int32_t MAX_WH = 450;
|
2016-01-09 11:32:28 +01:00
|
|
|
|
2014-10-07 20:39:52 +02:00
|
|
|
static rct_widget window_staff_list_widgets[] = {
|
2020-05-09 16:44:21 +02:00
|
|
|
WINDOW_SHIM(WINDOW_TITLE, WW, WH),
|
2020-08-29 04:31:31 +02:00
|
|
|
MakeWidget({ 0, 43}, { WW, WH - 43}, WWT_RESIZE, WindowColour::Secondary ), // tab content panel
|
|
|
|
MakeTab ({ 3, 17}, STR_STAFF_HANDYMEN_TAB_TIP ), // handymen tab
|
|
|
|
MakeTab ({ 34, 17}, STR_STAFF_MECHANICS_TAB_TIP ), // mechanics tab
|
|
|
|
MakeTab ({ 65, 17}, STR_STAFF_SECURITY_TAB_TIP ), // security guards tab
|
|
|
|
MakeTab ({ 96, 17}, STR_STAFF_ENTERTAINERS_TAB_TIP), // entertainers tab
|
|
|
|
MakeWidget({ 3, 72}, {WW - 6, 195}, WWT_SCROLL, WindowColour::Secondary, SCROLL_VERTICAL ), // staff list
|
|
|
|
MakeWidget({130, 58}, { 12, 12}, WWT_COLOURBTN, WindowColour::Secondary, STR_NONE, STR_UNIFORM_COLOUR_TIP ), // uniform colour picker
|
|
|
|
MakeWidget({165, 17}, { 145, 13}, WWT_BUTTON, WindowColour::Primary , STR_NONE, STR_HIRE_STAFF_TIP ), // hire button
|
|
|
|
MakeWidget({243, 46}, { 24, 24}, WWT_FLATBTN, WindowColour::Secondary, SPR_DEMOLISH, STR_QUICK_FIRE_STAFF ), // quick fire staff
|
|
|
|
MakeWidget({267, 46}, { 24, 24}, WWT_FLATBTN, WindowColour::Secondary, SPR_PATROL_BTN, STR_SHOW_PATROL_AREA_TIP ), // show staff patrol area tool
|
|
|
|
MakeWidget({291, 46}, { 24, 24}, WWT_FLATBTN, WindowColour::Secondary, SPR_MAP, STR_SHOW_STAFF_ON_MAP_TIP ), // show staff on map button
|
2017-06-06 23:24:18 +02:00
|
|
|
{ WIDGETS_END },
|
2014-10-07 20:39:52 +02:00
|
|
|
};
|
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
static int32_t _windowStaffListHighlightedIndex;
|
|
|
|
static int32_t _windowStaffListSelectedTab = WINDOW_STAFF_LIST_TAB_HANDYMEN;
|
2014-10-07 20:39:52 +02:00
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
static uint8_t window_staff_list_get_random_entertainer_costume();
|
2017-01-24 13:48:46 +01:00
|
|
|
|
2018-02-14 09:42:26 +01:00
|
|
|
struct staff_naming_convention
|
2016-07-14 14:07:49 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_string_id plural;
|
|
|
|
rct_string_id singular;
|
|
|
|
rct_string_id action_hire;
|
2018-02-14 09:42:26 +01:00
|
|
|
};
|
2016-07-14 14:07:49 +02:00
|
|
|
|
2018-01-11 14:50:31 +01:00
|
|
|
static constexpr const staff_naming_convention StaffNamingConvention[] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
{ STR_HANDYMAN_PLURAL, STR_HANDYMAN_SINGULAR, STR_HIRE_HANDYMAN },
|
|
|
|
{ STR_MECHANIC_PLURAL, STR_MECHANIC_SINGULAR, STR_HIRE_MECHANIC },
|
|
|
|
{ STR_SECURITY_GUARD_PLURAL, STR_SECURITY_GUARD_SINGULAR, STR_HIRE_SECURITY_GUARD },
|
|
|
|
{ STR_ENTERTAINER_PLURAL, STR_ENTERTAINER_SINGULAR, STR_HIRE_ENTERTAINER },
|
2016-07-14 14:07:49 +02:00
|
|
|
};
|
2018-05-16 20:41:29 +02:00
|
|
|
// clang-format on
|
2016-07-14 14:07:49 +02:00
|
|
|
|
2014-10-07 20:39:52 +02:00
|
|
|
/*
|
2018-06-22 23:21:44 +02:00
|
|
|
* rct2: 0x006BD3CC
|
|
|
|
**/
|
|
|
|
rct_window* window_staff_list_open()
|
2014-10-07 20:39:52 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_window* window;
|
|
|
|
|
|
|
|
// Check if window is already open
|
|
|
|
window = window_bring_to_front_by_class(WC_STAFF_LIST);
|
2017-08-15 10:07:44 +02:00
|
|
|
if (window != nullptr)
|
2017-08-12 23:06:12 +02:00
|
|
|
return window;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
window = window_create_auto_pos(WW, WH, &window_staff_list_events, WC_STAFF_LIST, WF_10 | WF_RESIZABLE);
|
|
|
|
window->widgets = window_staff_list_widgets;
|
2018-06-22 23:21:44 +02:00
|
|
|
window->enabled_widgets = (1 << WIDX_STAFF_LIST_CLOSE) | (1 << WIDX_STAFF_LIST_HANDYMEN_TAB)
|
|
|
|
| (1 << WIDX_STAFF_LIST_MECHANICS_TAB) | (1 << WIDX_STAFF_LIST_SECURITY_TAB) | (1 << WIDX_STAFF_LIST_ENTERTAINERS_TAB)
|
|
|
|
| (1 << WIDX_STAFF_LIST_HIRE_BUTTON) | (1 << WIDX_STAFF_LIST_UNIFORM_COLOUR_PICKER)
|
|
|
|
| (1 << WIDX_STAFF_LIST_SHOW_PATROL_AREA_BUTTON) | (1 << WIDX_STAFF_LIST_MAP) | (1 << WIDX_STAFF_LIST_QUICK_FIRE);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
window_init_scroll_widgets(window);
|
|
|
|
_windowStaffListHighlightedIndex = -1;
|
|
|
|
window->list_information_type = 0;
|
|
|
|
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_UNIFORM_COLOUR_PICKER].type = WWT_EMPTY;
|
|
|
|
window->min_width = WW;
|
|
|
|
window->min_height = WH;
|
|
|
|
window->max_width = MAX_WW;
|
|
|
|
window->max_height = MAX_WH;
|
|
|
|
_quick_fire_mode = false;
|
2017-08-12 23:06:12 +02:00
|
|
|
|
2020-03-28 13:12:53 +01:00
|
|
|
WindowStaffListRefresh();
|
2017-08-12 23:06:12 +02:00
|
|
|
return window;
|
2014-10-07 20:39:52 +02:00
|
|
|
}
|
|
|
|
|
2020-03-28 13:12:53 +01:00
|
|
|
void WindowStaffListRefresh()
|
|
|
|
{
|
|
|
|
auto w = window_find_by_class(WC_STAFF_LIST);
|
|
|
|
if (w == nullptr)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
StaffList.clear();
|
2020-06-10 18:54:34 +02:00
|
|
|
|
2020-06-17 22:42:40 +02:00
|
|
|
for (auto peep : EntityList<Staff>(EntityListId::Peep))
|
2020-03-28 13:12:53 +01:00
|
|
|
{
|
|
|
|
sprite_set_flashing(peep, false);
|
2020-08-17 00:25:32 +02:00
|
|
|
if (static_cast<uint8_t>(peep->AssignedStaffType) != _windowStaffListSelectedTab)
|
2020-03-28 13:12:53 +01:00
|
|
|
continue;
|
|
|
|
sprite_set_flashing(peep, true);
|
|
|
|
|
2020-06-10 18:54:34 +02:00
|
|
|
StaffList.push_back(peep->sprite_index);
|
2020-03-28 13:12:53 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 02:22:50 +02:00
|
|
|
std::sort(StaffList.begin(), StaffList.end(), [](const uint16_t a, const uint16_t b) { return peep_compare(a, b) < 0; });
|
2020-03-28 13:12:53 +01:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_staff_list_cancel_tools(rct_window* w)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
if (input_test_flag(INPUT_FLAG_TOOL_ACTIVE))
|
|
|
|
if (w->classification == gCurrentToolWidget.window_classification && w->number == gCurrentToolWidget.window_number)
|
|
|
|
tool_cancel();
|
2014-10-07 20:39:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2018-06-22 23:21:44 +02:00
|
|
|
* rct2: 0x006BD9B1
|
|
|
|
**/
|
|
|
|
void window_staff_list_close(rct_window* w)
|
2015-07-10 02:39:16 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
window_staff_list_cancel_tools(w);
|
2014-10-07 20:39:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x006BD94C
|
|
|
|
*/
|
|
|
|
static void window_staff_list_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
2014-10-07 20:39:52 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (widgetIndex)
|
2017-06-06 23:24:18 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
case WIDX_STAFF_LIST_CLOSE:
|
|
|
|
window_close(w);
|
|
|
|
break;
|
|
|
|
case WIDX_STAFF_LIST_HIRE_BUTTON:
|
2017-06-06 23:24:18 +02:00
|
|
|
{
|
2020-08-17 00:25:32 +02:00
|
|
|
StaffType staffType = static_cast<StaffType>(_windowStaffListSelectedTab);
|
2019-03-11 16:53:03 +01:00
|
|
|
ENTERTAINER_COSTUME costume = ENTERTAINER_COSTUME_COUNT;
|
2020-08-17 00:25:32 +02:00
|
|
|
if (staffType == StaffType::Entertainer)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2019-03-11 16:53:03 +01:00
|
|
|
costume = static_cast<ENTERTAINER_COSTUME>(window_staff_list_get_random_entertainer_costume());
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
2019-03-11 16:53:03 +01:00
|
|
|
staff_hire_new_member(staffType, costume);
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2018-06-22 23:21:44 +02:00
|
|
|
case WIDX_STAFF_LIST_SHOW_PATROL_AREA_BUTTON:
|
|
|
|
if (!tool_set(w, WIDX_STAFF_LIST_SHOW_PATROL_AREA_BUTTON, TOOL_CROSSHAIR))
|
|
|
|
{
|
|
|
|
show_gridlines();
|
|
|
|
gStaffDrawPatrolAreas = _windowStaffListSelectedTab | 0x8000;
|
|
|
|
gfx_invalidate_screen();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WIDX_STAFF_LIST_MAP:
|
|
|
|
context_open_window(WC_MAP);
|
|
|
|
break;
|
|
|
|
case WIDX_STAFF_LIST_QUICK_FIRE:
|
|
|
|
_quick_fire_mode ^= 1;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-10-07 20:39:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x006BDD5D
|
|
|
|
*/
|
|
|
|
static void window_staff_list_resize(rct_window* w)
|
2014-10-07 20:39:52 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->min_width = WW;
|
|
|
|
w->min_height = WH;
|
2018-06-22 23:21:44 +02:00
|
|
|
if (w->width < w->min_width)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->width = w->min_width;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2018-06-22 23:21:44 +02:00
|
|
|
if (w->height < w->min_height)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->height = w->min_height;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-10-07 20:39:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x006BD971
|
|
|
|
*/
|
|
|
|
static void window_staff_list_mousedown(rct_window* w, rct_widgetindex widgetIndex, rct_widget* widget)
|
2014-10-07 20:39:52 +02:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int16_t newSelectedTab;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_STAFF_LIST_HANDYMEN_TAB:
|
|
|
|
case WIDX_STAFF_LIST_MECHANICS_TAB:
|
|
|
|
case WIDX_STAFF_LIST_SECURITY_TAB:
|
|
|
|
case WIDX_STAFF_LIST_ENTERTAINERS_TAB:
|
|
|
|
newSelectedTab = widgetIndex - WIDX_STAFF_LIST_HANDYMEN_TAB;
|
|
|
|
if (_windowStaffListSelectedTab == newSelectedTab)
|
|
|
|
break;
|
2018-08-13 14:05:52 +02:00
|
|
|
|
2020-04-18 13:32:48 +02:00
|
|
|
_windowStaffListSelectedTab = static_cast<uint8_t>(newSelectedTab);
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2018-06-22 23:21:44 +02:00
|
|
|
w->scrolls[0].v_top = 0;
|
|
|
|
window_staff_list_cancel_tools(w);
|
|
|
|
break;
|
|
|
|
case WIDX_STAFF_LIST_UNIFORM_COLOUR_PICKER:
|
2020-08-17 00:25:32 +02:00
|
|
|
window_dropdown_show_colour(
|
|
|
|
w, widget, w->colours[1], staff_get_colour(static_cast<StaffType>(_windowStaffListSelectedTab)));
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
|
|
|
}
|
2014-10-07 20:39:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x006BD9A6
|
|
|
|
*/
|
|
|
|
static void window_staff_list_dropdown(rct_window* w, rct_widgetindex widgetIndex, int32_t dropdownIndex)
|
2014-10-07 20:39:52 +02:00
|
|
|
{
|
2018-03-16 13:56:15 +01:00
|
|
|
if (widgetIndex == WIDX_STAFF_LIST_UNIFORM_COLOUR_PICKER && dropdownIndex != -1)
|
|
|
|
{
|
2020-08-17 00:25:32 +02:00
|
|
|
auto action = StaffSetColourAction(static_cast<StaffType>(_windowStaffListSelectedTab), dropdownIndex);
|
2018-03-16 13:56:15 +01:00
|
|
|
GameActions::Execute(&action);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-10-07 20:39:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x006BDCEA
|
|
|
|
*/
|
|
|
|
void window_staff_list_update(rct_window* w)
|
2014-10-07 20:39:52 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->list_information_type++;
|
2018-06-22 23:21:44 +02:00
|
|
|
if (w->list_information_type >= 24)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->list_information_type = 0;
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
widget_invalidate(w, WIDX_STAFF_LIST_HANDYMEN_TAB + _windowStaffListSelectedTab);
|
|
|
|
|
|
|
|
// Enable highlighting of these staff members in map window
|
2018-06-22 23:21:44 +02:00
|
|
|
if (window_find_by_class(WC_MAP) != nullptr)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
gWindowMapFlashingFlags |= (1 << 2);
|
2020-06-17 22:42:40 +02:00
|
|
|
for (auto peep : EntityList<Staff>(EntityListId::Peep))
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2020-01-19 18:02:43 +01:00
|
|
|
sprite_set_flashing(peep, false);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-08-17 00:25:32 +02:00
|
|
|
if (static_cast<uint8_t>(peep->AssignedStaffType) == _windowStaffListSelectedTab)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2020-01-19 18:02:43 +01:00
|
|
|
sprite_set_flashing(peep, true);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-28 13:12:53 +01:00
|
|
|
|
|
|
|
// Note this may be slow if number of staff increases a large amount.
|
|
|
|
// See GuestList for fix (more intents) if required.
|
|
|
|
WindowStaffListRefresh();
|
2014-10-07 20:39:52 +02:00
|
|
|
}
|
|
|
|
|
2015-07-10 02:39:16 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006BD990
|
|
|
|
*/
|
2020-02-29 03:43:29 +01:00
|
|
|
static void window_staff_list_tooldown(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
|
2015-07-10 02:39:16 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
if (widgetIndex == WIDX_STAFF_LIST_SHOW_PATROL_AREA_BUTTON)
|
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t selectedPeepType = _windowStaffListSelectedTab;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t direction;
|
2018-11-01 13:53:50 +01:00
|
|
|
TileElement* tileElement;
|
2020-01-13 02:20:29 +01:00
|
|
|
auto footpathCoords = footpath_get_coordinates_from_pos(screenCoords, &direction, &tileElement);
|
2019-12-31 09:01:17 +01:00
|
|
|
if (footpathCoords.isNull())
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
|
|
|
|
2020-08-17 00:25:32 +02:00
|
|
|
bool isPatrolAreaSet = staff_is_patrol_area_set_for_type(static_cast<StaffType>(selectedPeepType), footpathCoords);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-06-10 18:54:34 +02:00
|
|
|
Peep* closestPeep = nullptr;
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t closestPeepDistance = std::numeric_limits<int32_t>::max();
|
2020-06-10 18:54:34 +02:00
|
|
|
|
2020-06-17 22:42:40 +02:00
|
|
|
for (auto peep : EntityList<Staff>(EntityListId::Peep))
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2020-08-17 00:25:32 +02:00
|
|
|
if (static_cast<uint8_t>(peep->AssignedStaffType) != selectedPeepType)
|
2017-06-06 23:24:18 +02:00
|
|
|
continue;
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
if (isPatrolAreaSet)
|
|
|
|
{
|
2020-09-02 17:48:40 +02:00
|
|
|
if (gStaffModes[peep->StaffId] != StaffMode::Patrol)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
continue;
|
|
|
|
}
|
2020-03-07 23:07:47 +01:00
|
|
|
if (!peep->AsStaff()->IsLocationInPatrol(footpathCoords))
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
if (peep->x == LOCATION_NULL)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-10-21 14:13:08 +02:00
|
|
|
int32_t distance = abs(footpathCoords.x - peep->x) + abs(footpathCoords.y - peep->y);
|
2018-06-22 23:21:44 +02:00
|
|
|
if (distance < closestPeepDistance)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
closestPeepDistance = distance;
|
|
|
|
closestPeep = peep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
if (closestPeep != nullptr)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
tool_cancel();
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_window* staffWindow = window_staff_open(closestPeep);
|
2017-06-06 23:24:18 +02:00
|
|
|
window_event_dropdown_call(staffWindow, WC_PEEP__WIDX_PATROL, 0);
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-21 21:16:27 +02:00
|
|
|
Formatter::Common().Add<rct_string_id>(StaffNamingConvention[selectedPeepType].plural);
|
2017-09-06 16:09:35 +02:00
|
|
|
context_show_error(STR_NO_THING_IN_PARK_YET, STR_NONE);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
2015-07-10 02:39:16 +02:00
|
|
|
}
|
|
|
|
|
2014-10-07 20:39:52 +02:00
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x006BD99B
|
|
|
|
*/
|
|
|
|
void window_staff_list_toolabort(rct_window* w, rct_widgetindex widgetIndex)
|
2015-07-10 02:39:16 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
if (widgetIndex == WIDX_STAFF_LIST_SHOW_PATROL_AREA_BUTTON)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
hide_gridlines();
|
|
|
|
tool_cancel();
|
|
|
|
gStaffDrawPatrolAreas = 0xFFFF;
|
|
|
|
gfx_invalidate_screen();
|
|
|
|
}
|
2014-10-07 20:39:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x006BDBE6
|
|
|
|
*/
|
|
|
|
void window_staff_list_scrollgetsize(rct_window* w, int32_t scrollIndex, int32_t* width, int32_t* height)
|
2015-05-26 20:28:37 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
if (_windowStaffListHighlightedIndex != -1)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
_windowStaffListHighlightedIndex = -1;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2020-03-28 13:12:53 +01:00
|
|
|
*height = static_cast<int16_t>(StaffList.size()) * SCROLLABLE_ROW_HEIGHT;
|
|
|
|
auto i = *height - window_staff_list_widgets[WIDX_STAFF_LIST_LIST].bottom
|
|
|
|
+ window_staff_list_widgets[WIDX_STAFF_LIST_LIST].top + 21;
|
2017-06-06 23:24:18 +02:00
|
|
|
if (i < 0)
|
|
|
|
i = 0;
|
2018-06-22 23:21:44 +02:00
|
|
|
if (i < w->scrolls[0].v_top)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->scrolls[0].v_top = i;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2020-06-25 03:44:00 +02:00
|
|
|
*width = w->widgets[WIDX_STAFF_LIST_LIST].width() - 15;
|
2014-10-07 20:39:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x006BDC9A
|
|
|
|
*/
|
2020-02-29 03:43:29 +01:00
|
|
|
void window_staff_list_scrollmousedown(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
2015-07-10 02:39:16 +02:00
|
|
|
{
|
2020-03-28 13:12:53 +01:00
|
|
|
int32_t i = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
|
|
|
for (auto spriteIndex : StaffList)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
|
|
|
if (i == 0)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
if (_quick_fire_mode)
|
2019-03-16 21:45:52 +01:00
|
|
|
{
|
|
|
|
auto staffFireAction = StaffFireAction(spriteIndex);
|
|
|
|
GameActions::Execute(&staffFireAction);
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
else
|
2017-10-06 23:21:00 +02:00
|
|
|
{
|
2020-07-26 18:42:02 +02:00
|
|
|
auto peep = GetEntity<Staff>(spriteIndex);
|
|
|
|
if (peep != nullptr)
|
|
|
|
{
|
|
|
|
auto intent = Intent(WC_PEEP);
|
|
|
|
intent.putExtra(INTENT_EXTRA_PEEP, peep);
|
|
|
|
context_open_intent(&intent);
|
|
|
|
}
|
2017-10-06 23:21:00 +02:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
i--;
|
|
|
|
}
|
2014-10-07 20:39:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x006BDC6B
|
|
|
|
*/
|
2020-02-29 03:43:29 +01:00
|
|
|
void window_staff_list_scrollmouseover(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
2015-07-10 02:39:16 +02:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t i;
|
2014-10-07 20:39:52 +02:00
|
|
|
|
2019-11-14 12:40:40 +01:00
|
|
|
i = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
2018-06-22 23:21:44 +02:00
|
|
|
if (i != _windowStaffListHighlightedIndex)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
_windowStaffListHighlightedIndex = i;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2014-10-07 20:39:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x006BD477
|
|
|
|
*/
|
|
|
|
void window_staff_list_invalidate(rct_window* w)
|
2014-10-07 20:39:52 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
int32_t pressed_widgets = w->pressed_widgets
|
|
|
|
& ~((1LL << WIDX_STAFF_LIST_HANDYMEN_TAB) | (1LL << WIDX_STAFF_LIST_MECHANICS_TAB)
|
|
|
|
| (1LL << WIDX_STAFF_LIST_SECURITY_TAB) | (1LL << WIDX_STAFF_LIST_ENTERTAINERS_TAB));
|
2018-06-20 17:28:51 +02:00
|
|
|
uint8_t tabIndex = _windowStaffListSelectedTab;
|
|
|
|
uint8_t widgetIndex = tabIndex + WIDX_STAFF_LIST_HANDYMEN_TAB;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
w->pressed_widgets = pressed_widgets | (1ULL << widgetIndex);
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_HIRE_BUTTON].text = StaffNamingConvention[tabIndex].action_hire;
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_UNIFORM_COLOUR_PICKER].type = WWT_EMPTY;
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
if (tabIndex < 3)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_UNIFORM_COLOUR_PICKER].type = WWT_COLOURBTN;
|
2020-08-17 00:25:32 +02:00
|
|
|
auto spriteIdPalette = SPRITE_ID_PALETTE_COLOUR_1(
|
|
|
|
static_cast<uint32_t>(staff_get_colour(static_cast<StaffType>(tabIndex))));
|
2020-04-18 13:32:48 +02:00
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_UNIFORM_COLOUR_PICKER].image = spriteIdPalette | IMAGE_TYPE_TRANSPARENT
|
|
|
|
| SPR_PALETTE_BTN;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
if (_quick_fire_mode)
|
|
|
|
w->pressed_widgets |= (1ULL << WIDX_STAFF_LIST_QUICK_FIRE);
|
|
|
|
else
|
|
|
|
w->pressed_widgets &= ~(1ULL << WIDX_STAFF_LIST_QUICK_FIRE);
|
|
|
|
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_BACKGROUND].right = w->width - 1;
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_BACKGROUND].bottom = w->height - 1;
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_TAB_CONTENT_PANEL].right = w->width - 1;
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_TAB_CONTENT_PANEL].bottom = w->height - 1;
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_TITLE].right = w->width - 2;
|
2020-05-05 22:31:04 +02:00
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_CLOSE].left = w->width - 2 - 11;
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_CLOSE].right = w->width - 2 - 11 + 10;
|
2017-06-06 23:24:18 +02:00
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_LIST].right = w->width - 4;
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_LIST].bottom = w->height - 15;
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_QUICK_FIRE].left = w->width - 77;
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_QUICK_FIRE].right = w->width - 54;
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_SHOW_PATROL_AREA_BUTTON].left = w->width - 53;
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_SHOW_PATROL_AREA_BUTTON].right = w->width - 30;
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_MAP].left = w->width - 29;
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_MAP].right = w->width - 6;
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_HIRE_BUTTON].left = w->width - 155;
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_HIRE_BUTTON].right = w->width - 11;
|
2014-10-07 20:39:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x006BD533
|
|
|
|
*/
|
|
|
|
void window_staff_list_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
2015-07-10 02:39:16 +02:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t i;
|
|
|
|
uint8_t selectedTab;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Widgets
|
|
|
|
window_draw_widgets(w, dpi);
|
|
|
|
|
|
|
|
selectedTab = _windowStaffListSelectedTab;
|
|
|
|
|
|
|
|
// Handymen tab image
|
|
|
|
i = (selectedTab == 0 ? (w->list_information_type & ~3) : 0);
|
|
|
|
i += g_peep_animation_entries[PEEP_SPRITE_TYPE_HANDYMAN].sprite_animation->base_image + 1;
|
2017-07-20 20:56:29 +02:00
|
|
|
i |= SPRITE_ID_PALETTE_COLOUR_1(gStaffHandymanColour);
|
2017-06-06 23:24:18 +02:00
|
|
|
gfx_draw_sprite(
|
2018-07-21 13:51:54 +02:00
|
|
|
dpi, i,
|
2020-06-24 17:48:17 +02:00
|
|
|
w->windowPos
|
|
|
|
+ ScreenCoordsXY{ (window_staff_list_widgets[WIDX_STAFF_LIST_HANDYMEN_TAB].left
|
|
|
|
+ window_staff_list_widgets[WIDX_STAFF_LIST_HANDYMEN_TAB].right)
|
|
|
|
/ 2,
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_HANDYMEN_TAB].bottom - 6 },
|
|
|
|
0);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Mechanic tab image
|
|
|
|
i = (selectedTab == 1 ? (w->list_information_type & ~3) : 0);
|
|
|
|
i += g_peep_animation_entries[PEEP_SPRITE_TYPE_MECHANIC].sprite_animation->base_image + 1;
|
2017-07-20 20:56:29 +02:00
|
|
|
i |= SPRITE_ID_PALETTE_COLOUR_1(gStaffMechanicColour);
|
2017-06-06 23:24:18 +02:00
|
|
|
gfx_draw_sprite(
|
2018-07-21 13:51:54 +02:00
|
|
|
dpi, i,
|
2020-06-24 17:48:17 +02:00
|
|
|
w->windowPos
|
|
|
|
+ ScreenCoordsXY{ (window_staff_list_widgets[WIDX_STAFF_LIST_MECHANICS_TAB].left
|
|
|
|
+ window_staff_list_widgets[WIDX_STAFF_LIST_MECHANICS_TAB].right)
|
|
|
|
/ 2,
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_MECHANICS_TAB].bottom - 6 },
|
|
|
|
0);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Security tab image
|
|
|
|
i = (selectedTab == 2 ? (w->list_information_type & ~3) : 0);
|
|
|
|
i += g_peep_animation_entries[PEEP_SPRITE_TYPE_SECURITY].sprite_animation->base_image + 1;
|
2017-07-20 20:56:29 +02:00
|
|
|
i |= SPRITE_ID_PALETTE_COLOUR_1(gStaffSecurityColour);
|
2017-06-06 23:24:18 +02:00
|
|
|
gfx_draw_sprite(
|
2018-07-21 13:51:54 +02:00
|
|
|
dpi, i,
|
2020-06-24 17:48:17 +02:00
|
|
|
w->windowPos
|
|
|
|
+ ScreenCoordsXY{ (window_staff_list_widgets[WIDX_STAFF_LIST_SECURITY_TAB].left
|
|
|
|
+ window_staff_list_widgets[WIDX_STAFF_LIST_SECURITY_TAB].right)
|
|
|
|
/ 2,
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_SECURITY_TAB].bottom - 6 },
|
|
|
|
0);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
rct_drawpixelinfo sprite_dpi;
|
|
|
|
if (clip_drawpixelinfo(
|
2020-07-02 19:06:28 +02:00
|
|
|
&sprite_dpi, dpi,
|
|
|
|
w->windowPos
|
|
|
|
+ ScreenCoordsXY{ window_staff_list_widgets[WIDX_STAFF_LIST_ENTERTAINERS_TAB].left + 1,
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_ENTERTAINERS_TAB].top + 1 },
|
2018-06-22 23:21:44 +02:00
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_ENTERTAINERS_TAB].right
|
|
|
|
- window_staff_list_widgets[WIDX_STAFF_LIST_ENTERTAINERS_TAB].left - 1,
|
|
|
|
window_staff_list_widgets[WIDX_STAFF_LIST_ENTERTAINERS_TAB].bottom
|
|
|
|
- window_staff_list_widgets[WIDX_STAFF_LIST_ENTERTAINERS_TAB].top - 1))
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Entertainers tab image
|
|
|
|
i = (selectedTab == 3 ? (w->list_information_type & ~3) : 0);
|
|
|
|
i += g_peep_animation_entries[PEEP_SPRITE_TYPE_ENTERTAINER_ELEPHANT].sprite_animation->base_image + 1;
|
2020-06-24 17:48:17 +02:00
|
|
|
gfx_draw_sprite(&sprite_dpi, i, { 0x0F, 0x17 }, 0);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
if (!(gParkFlags & PARK_FLAGS_NO_MONEY))
|
|
|
|
{
|
2020-04-21 21:16:27 +02:00
|
|
|
Formatter::Common().Add<money32>(gStaffWageTable[selectedTab]);
|
2020-03-01 20:32:35 +01:00
|
|
|
gfx_draw_string_left(
|
2020-06-20 21:09:45 +02:00
|
|
|
dpi, STR_COST_PER_MONTH, gCommonFormatArgs, COLOUR_BLACK, w->windowPos + ScreenCoordsXY{ w->width - 155, 0x20 });
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
if (selectedTab < 3)
|
|
|
|
{
|
|
|
|
gfx_draw_string_left(
|
2020-06-20 21:09:45 +02:00
|
|
|
dpi, STR_UNIFORM_COLOUR, w, COLOUR_BLACK,
|
|
|
|
w->windowPos + ScreenCoordsXY{ 6, window_staff_list_widgets[WIDX_STAFF_LIST_UNIFORM_COLOUR_PICKER].top + 1 });
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t staffTypeStringId = StaffNamingConvention[selectedTab].plural;
|
2017-06-06 23:24:18 +02:00
|
|
|
// If the number of staff for a given type is 1, we use the singular forms of the names
|
2020-03-28 13:12:53 +01:00
|
|
|
if (StaffList.size() == 1)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
staffTypeStringId = StaffNamingConvention[selectedTab].singular;
|
|
|
|
}
|
|
|
|
|
2020-04-21 21:16:27 +02:00
|
|
|
auto ft = Formatter::Common();
|
|
|
|
ft.Add<uint16_t>(StaffList.size());
|
|
|
|
ft.Add<rct_string_id>(staffTypeStringId);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
gfx_draw_string_left(
|
2020-06-20 21:09:45 +02:00
|
|
|
dpi, STR_STAFF_LIST_COUNTER, gCommonFormatArgs, COLOUR_BLACK,
|
|
|
|
w->windowPos + ScreenCoordsXY{ 4, window_staff_list_widgets[WIDX_STAFF_LIST_LIST].bottom + 2 });
|
2014-10-07 20:39:52 +02:00
|
|
|
}
|
|
|
|
|
2016-07-28 23:21:01 +02:00
|
|
|
/** rct2: 0x00992A08 */
|
2018-06-20 17:28:51 +02:00
|
|
|
static constexpr const uint32_t staffOrderBaseSprites[] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
SPR_STAFF_ORDERS_SWEEPING,
|
|
|
|
SPR_STAFF_ORDERS_INSPECT_RIDES,
|
|
|
|
0,
|
|
|
|
0,
|
2016-07-28 23:21:01 +02:00
|
|
|
};
|
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
static constexpr const uint32_t staffCostumeSprites[] = {
|
2018-06-22 23:21:44 +02:00
|
|
|
SPR_STAFF_COSTUME_PANDA, SPR_STAFF_COSTUME_TIGER, SPR_STAFF_COSTUME_ELEPHANT, SPR_STAFF_COSTUME_ROMAN,
|
|
|
|
SPR_STAFF_COSTUME_GORILLA, SPR_STAFF_COSTUME_SNOWMAN, SPR_STAFF_COSTUME_KNIGHT, SPR_STAFF_COSTUME_ASTRONAUT,
|
|
|
|
SPR_STAFF_COSTUME_BANDIT, SPR_STAFF_COSTUME_SHERIFF, SPR_STAFF_COSTUME_PIRATE,
|
2016-07-28 23:21:01 +02:00
|
|
|
};
|
|
|
|
|
2014-10-07 20:39:52 +02:00
|
|
|
/**
|
2018-06-22 23:21:44 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x006BD785
|
|
|
|
*/
|
|
|
|
void window_staff_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex)
|
2014-10-07 20:39:52 +02:00
|
|
|
{
|
2020-07-16 03:34:57 +02:00
|
|
|
auto dpiCoords = ScreenCoordsXY{ dpi->x, dpi->y };
|
|
|
|
gfx_fill_rect(
|
|
|
|
dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi->width - 1, dpi->height - 1 } }, ColourMapA[w->colours[1]].mid_light);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-06-02 13:06:38 +02:00
|
|
|
// How much space do we have for the name and action columns? (Discount scroll area and icons.)
|
2020-06-25 03:44:00 +02:00
|
|
|
const int32_t nonIconSpace = w->widgets[WIDX_STAFF_LIST_LIST].width() - 15 - 68;
|
2018-08-13 14:05:52 +02:00
|
|
|
const int32_t nameColumnSize = nonIconSpace * 0.42;
|
|
|
|
const int32_t actionColumnSize = nonIconSpace * 0.58;
|
|
|
|
const int32_t actionOffset = w->widgets[WIDX_STAFF_LIST_LIST].right - actionColumnSize - 15;
|
2018-06-02 13:06:38 +02:00
|
|
|
|
2020-03-29 23:00:28 +02:00
|
|
|
auto y = 0;
|
|
|
|
auto i = 0;
|
|
|
|
for (auto spriteIndex : StaffList)
|
2018-06-02 13:06:38 +02:00
|
|
|
{
|
2020-03-29 23:00:28 +02:00
|
|
|
if (y > dpi->y + dpi->height)
|
2018-06-02 13:06:38 +02:00
|
|
|
{
|
2020-03-29 23:00:28 +02:00
|
|
|
break;
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-03-29 23:00:28 +02:00
|
|
|
if (y + 11 >= dpi->y)
|
|
|
|
{
|
2020-07-26 18:42:02 +02:00
|
|
|
auto peep = GetEntity<Staff>(spriteIndex);
|
|
|
|
if (peep == nullptr)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2020-03-29 23:00:28 +02:00
|
|
|
int32_t format = (_quick_fire_mode ? STR_RED_STRINGID : STR_BLACK_STRING);
|
|
|
|
|
|
|
|
if (i == _windowStaffListHighlightedIndex)
|
2018-06-02 13:06:38 +02:00
|
|
|
{
|
2020-03-29 23:00:28 +02:00
|
|
|
gfx_filter_rect(dpi, 0, y, 800, y + (SCROLLABLE_ROW_HEIGHT - 1), PALETTE_DARKEN_1);
|
|
|
|
format = (_quick_fire_mode ? STR_LIGHTPINK_STRINGID : STR_WINDOW_COLOUR_2_STRINGID);
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-06-23 15:52:08 +02:00
|
|
|
auto ft = Formatter::Common();
|
|
|
|
peep->FormatNameTo(ft);
|
2020-05-18 00:30:58 +02:00
|
|
|
gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { 0, y }, nameColumnSize);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-06-23 15:52:08 +02:00
|
|
|
ft = Formatter::Common();
|
|
|
|
peep->FormatActionTo(ft);
|
2020-05-18 00:30:58 +02:00
|
|
|
gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { actionOffset, y }, actionColumnSize);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-03-29 23:00:28 +02:00
|
|
|
// True if a patrol path is set for the worker
|
2020-09-02 17:48:40 +02:00
|
|
|
if (gStaffModes[peep->StaffId] == StaffMode::Patrol)
|
2020-03-29 23:00:28 +02:00
|
|
|
{
|
2020-06-24 17:48:17 +02:00
|
|
|
gfx_draw_sprite(dpi, SPR_STAFF_PATROL_PATH, { nameColumnSize + 5, y }, 0);
|
2020-03-29 23:00:28 +02:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-03-29 23:00:28 +02:00
|
|
|
auto staffOrderIcon_x = nameColumnSize + 20;
|
2020-08-17 00:25:32 +02:00
|
|
|
if (peep->AssignedStaffType != StaffType::Entertainer)
|
2020-03-29 23:00:28 +02:00
|
|
|
{
|
2020-05-31 23:00:23 +02:00
|
|
|
auto staffOrders = peep->StaffOrders;
|
2020-03-29 23:00:28 +02:00
|
|
|
auto staffOrderSprite = staffOrderBaseSprites[_windowStaffListSelectedTab];
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-03-29 23:00:28 +02:00
|
|
|
while (staffOrders != 0)
|
2018-06-02 13:06:38 +02:00
|
|
|
{
|
2020-03-29 23:00:28 +02:00
|
|
|
if (staffOrders & 1)
|
2018-06-02 13:06:38 +02:00
|
|
|
{
|
2020-06-24 17:48:17 +02:00
|
|
|
gfx_draw_sprite(dpi, staffOrderSprite, { staffOrderIcon_x, y }, 0);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2020-03-29 23:00:28 +02:00
|
|
|
staffOrders = staffOrders >> 1;
|
|
|
|
staffOrderIcon_x += 9;
|
|
|
|
// TODO: Remove sprite ID addition
|
|
|
|
staffOrderSprite++;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
2020-03-29 23:00:28 +02:00
|
|
|
else
|
|
|
|
{
|
2020-06-24 17:48:17 +02:00
|
|
|
gfx_draw_sprite(dpi, staffCostumeSprites[peep->SpriteType - 4], { staffOrderIcon_x, y }, 0);
|
2020-03-29 23:00:28 +02:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2020-03-29 23:00:28 +02:00
|
|
|
|
|
|
|
y += SCROLLABLE_ROW_HEIGHT;
|
|
|
|
i++;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-05-12 16:13:30 +02:00
|
|
|
}
|
2017-01-24 13:48:46 +01:00
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
static uint8_t window_staff_list_get_random_entertainer_costume()
|
2017-01-24 13:48:46 +01:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
uint8_t result = ENTERTAINER_COSTUME_PANDA;
|
|
|
|
uint8_t costumeList[ENTERTAINER_COSTUME_COUNT];
|
|
|
|
int32_t numCostumes = staff_get_available_entertainer_costume_list(costumeList);
|
2017-06-06 23:24:18 +02:00
|
|
|
if (numCostumes > 0)
|
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t index = util_rand() % numCostumes;
|
2017-06-06 23:24:18 +02:00
|
|
|
result = costumeList[index];
|
|
|
|
}
|
|
|
|
return result;
|
2017-01-24 13:48:46 +01:00
|
|
|
}
|