mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Move Pause Toggle into the GameAction framework
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
#include <openrct2/ParkImporter.h>
|
||||
#include <openrct2/actions/ClearAction.hpp>
|
||||
#include <openrct2/actions/PauseToggleAction.hpp>
|
||||
#include <openrct2/audio/audio.h>
|
||||
#include <openrct2/config/Config.h>
|
||||
#include <openrct2/interface/Chat.h>
|
||||
@@ -337,7 +338,8 @@ static void window_top_toolbar_mouseup(rct_window* w, rct_widgetindex widgetInde
|
||||
case WIDX_PAUSE:
|
||||
if (network_get_mode() != NETWORK_MODE_CLIENT)
|
||||
{
|
||||
game_do_command(0, 1, 0, 0, GAME_COMMAND_TOGGLE_PAUSE, 0, 0);
|
||||
auto pauseToggleAction = PauseToggleAction();
|
||||
GameActions::Execute(&pauseToggleAction);
|
||||
}
|
||||
break;
|
||||
case WIDX_ZOOM_OUT:
|
||||
|
||||
@@ -881,20 +881,6 @@ bool game_is_not_paused()
|
||||
return gGamePaused == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00667C15
|
||||
*/
|
||||
void game_pause_toggle(
|
||||
[[maybe_unused]] int32_t* eax, int32_t* ebx, [[maybe_unused]] int32_t* ecx, [[maybe_unused]] int32_t* edx,
|
||||
[[maybe_unused]] int32_t* esi, [[maybe_unused]] int32_t* edi, [[maybe_unused]] int32_t* ebp)
|
||||
{
|
||||
if (*ebx & GAME_COMMAND_FLAG_APPLY)
|
||||
pause_toggle();
|
||||
|
||||
*ebx = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0066DB5F
|
||||
@@ -1456,7 +1442,7 @@ void game_load_or_quit_no_save_prompt()
|
||||
GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT] = {
|
||||
nullptr,
|
||||
nullptr,
|
||||
game_pause_toggle,
|
||||
nullptr,
|
||||
game_command_place_track,
|
||||
game_command_remove_track,
|
||||
game_load_or_quit,
|
||||
|
||||
@@ -20,7 +20,7 @@ enum GAME_COMMAND
|
||||
{
|
||||
GAME_COMMAND_SET_RIDE_APPEARANCE, // GA
|
||||
GAME_COMMAND_SET_LAND_HEIGHT, // GA
|
||||
GAME_COMMAND_TOGGLE_PAUSE,
|
||||
GAME_COMMAND_TOGGLE_PAUSE, // GA
|
||||
GAME_COMMAND_PLACE_TRACK,
|
||||
GAME_COMMAND_REMOVE_TRACK,
|
||||
GAME_COMMAND_LOAD_OR_QUIT,
|
||||
@@ -176,7 +176,6 @@ void game_log_multiplayer_command(int command, const int* eax, const int* ebx, c
|
||||
void game_load_or_quit_no_save_prompt();
|
||||
void load_from_sv6(const char* path);
|
||||
void game_load_init();
|
||||
void game_pause_toggle(int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp);
|
||||
void pause_toggle();
|
||||
bool game_is_paused();
|
||||
bool game_is_not_paused();
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "ParkSetLoanAction.hpp"
|
||||
#include "ParkSetNameAction.hpp"
|
||||
#include "ParkSetResearchFundingAction.hpp"
|
||||
#include "PauseToggleAction.hpp"
|
||||
#include "PlaceParkEntranceAction.hpp"
|
||||
#include "PlacePeepSpawnAction.hpp"
|
||||
#include "RideCreateAction.hpp"
|
||||
@@ -73,5 +74,6 @@ namespace GameActions
|
||||
Register<LargeSceneryRemoveAction>();
|
||||
Register<LandSetHeightAction>();
|
||||
Register<ClearAction>();
|
||||
Register<PauseToggleAction>();
|
||||
}
|
||||
} // namespace GameActions
|
||||
|
||||
35
src/openrct2/actions/PauseToggleAction.hpp
Normal file
35
src/openrct2/actions/PauseToggleAction.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2018 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.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "GameAction.h"
|
||||
|
||||
|
||||
DEFINE_GAME_ACTION(PauseToggleAction, GAME_COMMAND_TOGGLE_PAUSE, GameActionResult)
|
||||
{
|
||||
public:
|
||||
PauseToggleAction(){}
|
||||
|
||||
uint16_t GetActionFlags() const override
|
||||
{
|
||||
return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED;
|
||||
}
|
||||
|
||||
GameActionResult::Ptr Query() const override
|
||||
{
|
||||
return std::make_unique<GameActionResult>();
|
||||
}
|
||||
|
||||
GameActionResult::Ptr Execute() const override
|
||||
{
|
||||
pause_toggle();
|
||||
return std::make_unique<GameActionResult>();
|
||||
}
|
||||
};
|
||||
@@ -42,6 +42,7 @@ static int32_t _pickup_peep_old_x = LOCATION_NULL;
|
||||
# include "../ParkImporter.h"
|
||||
# include "../Version.h"
|
||||
# include "../actions/GameAction.h"
|
||||
# include "../actions/PauseToggleAction.hpp"
|
||||
# include "../config/Config.h"
|
||||
# include "../core/Console.hpp"
|
||||
# include "../core/FileStream.hpp"
|
||||
@@ -622,7 +623,8 @@ bool Network::BeginServer(uint16_t port, const char* address)
|
||||
|
||||
if (gConfigNetwork.pause_server_if_no_clients)
|
||||
{
|
||||
game_do_command(0, 1, 0, 0, GAME_COMMAND_TOGGLE_PAUSE, 0, 0);
|
||||
auto pauseToggleAction = PauseToggleAction();
|
||||
GameActions::Execute(&pauseToggleAction);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1986,7 +1988,8 @@ void Network::AddClient(std::unique_ptr<ITcpSocket>&& socket)
|
||||
{
|
||||
if (gConfigNetwork.pause_server_if_no_clients && game_is_paused())
|
||||
{
|
||||
game_do_command(0, 1, 0, 0, GAME_COMMAND_TOGGLE_PAUSE, 0, 0);
|
||||
auto pauseToggleAction = PauseToggleAction();
|
||||
GameActions::Execute(&pauseToggleAction);
|
||||
}
|
||||
|
||||
// Log connection info.
|
||||
@@ -2044,7 +2047,8 @@ void Network::RemoveClient(std::unique_ptr<NetworkConnection>& connection)
|
||||
client_connection_list.remove(connection);
|
||||
if (gConfigNetwork.pause_server_if_no_clients && game_is_not_paused() && client_connection_list.size() == 0)
|
||||
{
|
||||
game_do_command(0, 1, 0, 0, GAME_COMMAND_TOGGLE_PAUSE, 0, 0);
|
||||
auto pauseToggleAction = PauseToggleAction();
|
||||
GameActions::Execute(&pauseToggleAction);
|
||||
}
|
||||
Server_Send_PLAYERLIST();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user