OpenRCT2/src/openrct2-ui/windows/StaffFirePrompt.cpp

138 lines
3.6 KiB
C++
Raw Normal View History

/*****************************************************************************
* Copyright (c) 2014-2019 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
2018-06-22 23:21:44 +02:00
#include <openrct2-ui/interface/Widget.h>
2017-09-12 21:27:54 +02:00
#include <openrct2-ui/windows/Window.h>
2017-11-30 18:17:06 +01:00
#include <openrct2/Game.h>
2019-03-16 22:07:50 +01:00
#include <openrct2/actions/StaffFireAction.hpp>
2018-06-22 23:21:44 +02:00
#include <openrct2/drawing/Drawing.h>
#include <openrct2/interface/Colour.h>
2018-01-06 18:32:25 +01:00
#include <openrct2/localisation/Localisation.h>
2018-03-19 23:28:40 +01:00
#include <openrct2/world/Sprite.h>
#define WW 200
#define WH 100
// clang-format off
enum WINDOW_STAFF_FIRE_WIDGET_IDX {
WIDX_BACKGROUND,
WIDX_TITLE,
WIDX_CLOSE,
WIDX_YES,
WIDX_CANCEL
};
// 0x9AFB4C
static rct_widget window_staff_fire_widgets[] = {
{ WWT_FRAME, 0, 0, WW - 1, 0, WH - 1, STR_NONE, STR_NONE },
{ WWT_CAPTION, 0, 1, WW - 2, 1, 14, STR_SACK_STAFF, STR_WINDOW_TITLE_TIP },
{ WWT_CLOSEBOX, 0, WW-13, WW - 3, 2, 13, STR_CLOSE_X_WHITE, STR_CLOSE_WINDOW_TIP },
{ WWT_BUTTON, 0, 10, 94, WH - 20, WH - 9, STR_YES, STR_NONE },
{ WWT_BUTTON, 0, WW - 95, WW - 11, WH - 20, WH - 9, STR_SAVE_PROMPT_CANCEL, STR_NONE },
{ WIDGETS_END }
};
2017-05-01 15:41:45 +02:00
static void window_staff_fire_mouseup(rct_window *w, rct_widgetindex widgetIndex);
static void window_staff_fire_paint(rct_window *w, rct_drawpixelinfo *dpi);
//0x9A3F7C
static rct_window_event_list window_staff_fire_events = {
2017-08-15 10:07:44 +02:00
nullptr,
window_staff_fire_mouseup,
2017-08-15 10:07:44 +02:00
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
window_staff_fire_paint,
2017-08-15 10:07:44 +02:00
nullptr
};
//clang-format on
/** Based off of rct2: 0x6C0A77 */
2019-02-28 20:28:58 +01:00
rct_window* window_staff_fire_prompt_open(Peep* peep)
{
2017-09-10 11:02:16 +02:00
rct_window * w;
// Check if the confirm window already exists.
2017-09-10 11:02:16 +02:00
w = window_bring_to_front_by_number(WC_FIRE_PROMPT, peep->sprite_index);
if (w != nullptr) {
return w;
}
2017-09-10 11:02:16 +02:00
w = window_create_centred(WW, WH, &window_staff_fire_events, WC_FIRE_PROMPT, WF_TRANSPARENT);
w->widgets = window_staff_fire_widgets;
w->enabled_widgets |= (1 << WIDX_CLOSE) | (1 << WIDX_YES) | (1 << WIDX_CANCEL);
window_init_scroll_widgets(w);
w->number = peep->sprite_index;
2017-09-10 11:02:16 +02:00
return w;
}
/**
*
* rct2: 0x006C0B40
*/
2017-05-01 15:41:45 +02:00
static void window_staff_fire_mouseup(rct_window *w, rct_widgetindex widgetIndex)
{
switch (widgetIndex){
case WIDX_YES:
{
auto staffFireAction = StaffFireAction(w->number);
GameActions::Execute(&staffFireAction);
break;
}
case WIDX_CANCEL:
case WIDX_CLOSE:
window_close(w);
}
}
/**
*
* rct2: 0x006C0AF2
*/
static void window_staff_fire_paint(rct_window *w, rct_drawpixelinfo *dpi)
{
window_draw_widgets(w, dpi);
2019-02-28 20:28:58 +01:00
Peep* peep = &get_sprite(w->number)->peep;
2015-10-20 20:16:30 +02:00
set_format_arg(0, rct_string_id, peep->name_string_idx);
set_format_arg(2, uint32_t, peep->id);
2015-10-20 20:16:30 +02:00
int32_t x = w->x + WW / 2;
int32_t y = w->y + (WH / 2) - 3;
2015-10-20 20:16:30 +02:00
gfx_draw_string_centred_wrapped(dpi, gCommonFormatArgs, x, y, WW - 4, STR_FIRE_STAFF_ID, COLOUR_BLACK);
2014-10-08 13:39:50 +02:00
}