mirror of https://github.com/OpenRCT2/OpenRCT2.git
Implement game action for park set research funding
This commit is contained in:
parent
16a7e21ffa
commit
5a803d2551
|
@ -410,7 +410,10 @@ public:
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case INTENT_ACTION_UPDATE_RESEARCH:
|
||||
window_invalidate_by_class(WC_FINANCES);
|
||||
window_invalidate_by_class(WC_RESEARCH);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#pragma endregion
|
||||
|
||||
#include <openrct2/actions/ParkSetLoanAction.hpp>
|
||||
#include <openrct2/actions/ParkSetResearchFundingAction.hpp>
|
||||
#include <openrct2/config/Config.h>
|
||||
#include <openrct2/core/Math.hpp>
|
||||
#include <openrct2-ui/windows/Window.h>
|
||||
|
@ -1265,8 +1266,6 @@ static void window_finances_marketing_paint(rct_window *w, rct_drawpixelinfo *dp
|
|||
*/
|
||||
static void window_finances_research_mouseup(rct_window *w, rct_widgetindex widgetIndex)
|
||||
{
|
||||
sint32 activeResearchTypes;
|
||||
|
||||
switch (widgetIndex) {
|
||||
case WIDX_CLOSE:
|
||||
window_close(w);
|
||||
|
@ -1286,10 +1285,14 @@ static void window_finances_research_mouseup(rct_window *w, rct_widgetindex widg
|
|||
case WIDX_WATER_RIDES:
|
||||
case WIDX_SHOPS_AND_STALLS:
|
||||
case WIDX_SCENERY_AND_THEMING:
|
||||
activeResearchTypes = gResearchPriorities;
|
||||
activeResearchTypes ^= 1ULL << (widgetIndex - WIDX_TRANSPORT_RIDES);
|
||||
research_set_priority(activeResearchTypes);
|
||||
break;
|
||||
{
|
||||
auto activeResearchTypes = gResearchPriorities;
|
||||
activeResearchTypes ^= 1ULL << (widgetIndex - WIDX_TRANSPORT_RIDES);
|
||||
|
||||
auto gameAction = ParkSetResearchFundingAction(activeResearchTypes, gResearchFundingLevel);
|
||||
GameActions::Execute(&gameAction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1335,7 +1338,8 @@ static void window_finances_research_dropdown(rct_window *w, rct_widgetindex wid
|
|||
if (widgetIndex != WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON || dropdownIndex == -1)
|
||||
return;
|
||||
|
||||
research_set_funding(dropdownIndex);
|
||||
auto gameAction = ParkSetResearchFundingAction(gResearchPriorities, dropdownIndex);
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <openrct2-ui/windows/Window.h>
|
||||
|
||||
#include <openrct2/actions/ParkSetResearchFundingAction.hpp>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/localisation/Localisation.h>
|
||||
#include <openrct2-ui/interface/Widget.h>
|
||||
|
@ -412,8 +413,6 @@ void window_research_development_page_paint(rct_window *w, rct_drawpixelinfo *dp
|
|||
*/
|
||||
static void window_research_funding_mouseup(rct_window *w, rct_widgetindex widgetIndex)
|
||||
{
|
||||
sint32 activeResearchTypes;
|
||||
|
||||
switch (widgetIndex) {
|
||||
case WIDX_CLOSE:
|
||||
window_close(w);
|
||||
|
@ -429,10 +428,13 @@ static void window_research_funding_mouseup(rct_window *w, rct_widgetindex widge
|
|||
case WIDX_WATER_RIDES:
|
||||
case WIDX_SHOPS_AND_STALLS:
|
||||
case WIDX_SCENERY_AND_THEMING:
|
||||
activeResearchTypes = gResearchPriorities;
|
||||
activeResearchTypes ^= 1 << (widgetIndex - WIDX_TRANSPORT_RIDES);
|
||||
research_set_priority(activeResearchTypes);
|
||||
break;
|
||||
{
|
||||
auto activeResearchTypes = gResearchPriorities;
|
||||
activeResearchTypes ^= 1 << (widgetIndex - WIDX_TRANSPORT_RIDES);
|
||||
auto gameAction = ParkSetResearchFundingAction(activeResearchTypes, gResearchFundingLevel);
|
||||
GameActions::Execute(&gameAction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -478,8 +480,8 @@ static void window_research_funding_dropdown(rct_window *w, rct_widgetindex widg
|
|||
if (widgetIndex != WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON || dropdownIndex == -1)
|
||||
return;
|
||||
|
||||
research_set_funding(dropdownIndex);
|
||||
window_invalidate(w);
|
||||
auto gameAction = ParkSetResearchFundingAction(gResearchPriorities, dropdownIndex);
|
||||
GameActions::Execute(&gameAction);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1734,7 +1734,7 @@ GAME_COMMAND_POINTER * new_game_command_table[GAME_COMMAND_COUNT] = {
|
|||
game_command_place_large_scenery,
|
||||
game_command_remove_large_scenery,
|
||||
nullptr,
|
||||
game_command_set_research_funding,
|
||||
nullptr,
|
||||
game_command_place_track_design,
|
||||
game_command_start_campaign,
|
||||
game_command_place_maze_design,
|
||||
|
|
|
@ -73,7 +73,7 @@ enum GAME_COMMAND
|
|||
GAME_COMMAND_PLACE_LARGE_SCENERY,
|
||||
GAME_COMMAND_REMOVE_LARGE_SCENERY,
|
||||
GAME_COMMAND_SET_CURRENT_LOAN, // GA
|
||||
GAME_COMMAND_SET_RESEARCH_FUNDING,
|
||||
GAME_COMMAND_SET_RESEARCH_FUNDING, // GA
|
||||
GAME_COMMAND_PLACE_TRACK_DESIGN,
|
||||
GAME_COMMAND_START_MARKETING_CAMPAIGN,
|
||||
GAME_COMMAND_PLACE_MAZE_DESIGN,
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "GameAction.h"
|
||||
#include "GuestSetNameAction.hpp"
|
||||
#include "ParkSetLoanAction.hpp"
|
||||
#include "ParkSetResearchFundingAction.hpp"
|
||||
#include "PlaceParkEntranceAction.hpp"
|
||||
#include "SetParkEntranceFeeAction.hpp"
|
||||
#include "StaffSetNameAction.hpp"
|
||||
|
@ -33,6 +34,7 @@ namespace GameActions
|
|||
{
|
||||
Register<SetParkEntranceFeeAction>();
|
||||
Register<ParkSetLoanAction>();
|
||||
Register<ParkSetResearchFundingAction>();
|
||||
Register<PlaceParkEntranceAction>();
|
||||
Register<RideCreateAction>();
|
||||
Register<RideSetStatusAction>();
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
#pragma region Copyright (c) 2014-2018 OpenRCT2 Developers
|
||||
/*****************************************************************************
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
|
||||
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* A full copy of the GNU General Public License can be found in licence.txt
|
||||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Context.h"
|
||||
#include "../core/MemoryStream.h"
|
||||
#include "../localisation/StringIds.h"
|
||||
#include "../management/Research.h"
|
||||
#include "../ui/UiContext.h"
|
||||
#include "../ui/WindowManager.h"
|
||||
#include "../windows/Intent.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
struct ParkSetResearchFundingAction : public GameActionBase<GAME_COMMAND_SET_RESEARCH_FUNDING, GameActionResult>
|
||||
{
|
||||
private:
|
||||
// TODO change to std::optional when C++17
|
||||
uint32 _priorities;
|
||||
uint8 _fundingAmount;
|
||||
|
||||
public:
|
||||
ParkSetResearchFundingAction() {}
|
||||
ParkSetResearchFundingAction(uint32 priorities, uint8 fundingAmount)
|
||||
: _priorities(priorities),
|
||||
_fundingAmount(fundingAmount)
|
||||
{
|
||||
}
|
||||
|
||||
uint16 GetActionFlags() const override
|
||||
{
|
||||
return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED;
|
||||
}
|
||||
|
||||
void Serialise(DataSerialiser& stream) override
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
stream << _priorities << _fundingAmount;
|
||||
}
|
||||
|
||||
GameActionResult::Ptr Query() const override
|
||||
{
|
||||
if (_fundingAmount >= RESEARCH_FUNDING_COUNT)
|
||||
{
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
|
||||
}
|
||||
return std::make_unique<GameActionResult>();
|
||||
}
|
||||
|
||||
GameActionResult::Ptr Execute() const override
|
||||
{
|
||||
gResearchPriorities = _priorities;
|
||||
gResearchFundingLevel = _fundingAmount;
|
||||
|
||||
auto windowManager = GetContext()->GetUiContext()->GetWindowManager();
|
||||
windowManager->BroadcastIntent(Intent(INTENT_ACTION_UPDATE_RESEARCH));
|
||||
return std::make_unique<GameActionResult>();
|
||||
}
|
||||
};
|
|
@ -15,6 +15,7 @@
|
|||
#pragma endregion
|
||||
|
||||
#include <algorithm>
|
||||
#include "../actions/ParkSetResearchFundingAction.hpp"
|
||||
#include "../config/Config.h"
|
||||
#include "../core/Guard.hpp"
|
||||
#include "../core/Util.hpp"
|
||||
|
@ -161,7 +162,8 @@ static void research_next_design()
|
|||
gResearchProgressStage = RESEARCH_STAGE_FINISHED_ALL;
|
||||
research_invalidate_related_windows();
|
||||
// Reset funding to 0 if no more rides.
|
||||
research_set_funding(0);
|
||||
auto gameAction = ParkSetResearchFundingAction(gResearchPriorities, 0);
|
||||
GameActions::Execute(&gameAction);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -605,52 +607,6 @@ void research_populate_list_researched()
|
|||
}
|
||||
}
|
||||
|
||||
void research_set_funding(sint32 amount)
|
||||
{
|
||||
game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, amount, GAME_COMMAND_SET_RESEARCH_FUNDING, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
void research_set_priority(sint32 activeCategories)
|
||||
{
|
||||
game_do_command(0, (1 << 8) | GAME_COMMAND_FLAG_APPLY, 0, activeCategories, GAME_COMMAND_SET_RESEARCH_FUNDING, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00684A7F
|
||||
*/
|
||||
void game_command_set_research_funding(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp)
|
||||
{
|
||||
sint32 setPriorities = (*ebx & (1 << 8)) != 0;
|
||||
uint32 fundingAmount = *edx;
|
||||
sint32 activeCategories = *edx;
|
||||
|
||||
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_RESEARCH;
|
||||
if (*ebx & GAME_COMMAND_FLAG_APPLY)
|
||||
{
|
||||
if (!setPriorities)
|
||||
{
|
||||
if (fundingAmount >= Util::CountOf(_researchRate))
|
||||
{
|
||||
*ebx = MONEY32_UNDEFINED;
|
||||
log_warning("Invalid research rate %d", fundingAmount);
|
||||
return;
|
||||
}
|
||||
gResearchFundingLevel = fundingAmount;
|
||||
}
|
||||
else
|
||||
{
|
||||
gResearchPriorities = activeCategories;
|
||||
}
|
||||
|
||||
window_invalidate_by_class(WC_FINANCES);
|
||||
window_invalidate_by_class(WC_RESEARCH);
|
||||
}
|
||||
|
||||
*ebx = 0;
|
||||
}
|
||||
|
||||
void research_insert_ride_entry(uint8 entryIndex, bool researched)
|
||||
{
|
||||
rct_ride_entry * rideEntry = get_ride_entry(entryIndex);
|
||||
|
|
|
@ -115,9 +115,6 @@ void research_populate_list_random();
|
|||
void research_populate_list_researched();
|
||||
void research_process_random_items();
|
||||
|
||||
void research_set_funding(sint32 amount);
|
||||
void research_set_priority(sint32 activeCategories);
|
||||
void game_command_set_research_funding(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp);
|
||||
void research_finish_item(rct_research_item * researchItem);
|
||||
void research_insert(sint32 researched, sint32 rawValue, uint8 category);
|
||||
void research_remove(rct_research_item * researchItem);
|
||||
|
|
|
@ -99,4 +99,5 @@ enum
|
|||
INTENT_ACTION_UPDATE_DATE,
|
||||
INTENT_ACTION_UPDATE_CASH,
|
||||
INTENT_ACTION_UPDATE_BANNER,
|
||||
INTENT_ACTION_UPDATE_RESEARCH,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue