Merge branch 'master' into jgrpp
# Conflicts: # .github/workflows/ci-build.yml # .github/workflows/codeql.yml # .github/workflows/commit-checker.yml # .github/workflows/release-linux-legacy.yml # .github/workflows/release-linux.yml # .github/workflows/release-macos.yml # .github/workflows/release-windows-store.yml # .github/workflows/release-windows.yml # .github/workflows/upload-cdn.yml # .github/workflows/upload-gog.yml # .github/workflows/upload-steam.yml # src/console_cmds.cpp # src/core/math_func.hpp # src/fios.cpp # src/fios.h # src/intro_gui.cpp # src/network/network_server.cpp # src/openttd.cpp # src/settings.cpp # src/settings_gui.cpp # src/settings_internal.h # src/settings_table.cpp # src/settings_type.h # src/table/settings.h.preamble # src/table/settings/company_settings.ini # src/table/settings/currency_settings.ini # src/table/settings/difficulty_settings.ini # src/table/settings/economy_settings.ini # src/table/settings/game_settings.ini # src/table/settings/gui_settings.ini # src/table/settings/linkgraph_settings.ini # src/table/settings/locale_settings.ini # src/table/settings/misc_settings.ini # src/table/settings/multimedia_settings.ini # src/table/settings/network_private_settings.ini # src/table/settings/network_settings.ini # src/table/settings/news_display_settings.ini # src/table/settings/old_gameopt_settings.ini # src/table/settings/pathfinding_settings.ini # src/table/settings/script_settings.ini # src/table/settings/win32_settings.ini # src/table/settings/window_settings.ini # src/table/settings/world_settings.ini # src/viewport.cpp # src/viewport_func.h # src/window.cpp
This commit is contained in:
@@ -81,6 +81,10 @@
|
||||
* \li GSGoal::SetDestination
|
||||
* \li GSIndustry::GetProductionLevel
|
||||
* \li GSIndustry::SetProductionLevel
|
||||
* \li GSStoryPage::IsValidStoryPageElementType
|
||||
* \li GSStoryPage::IsValidStoryPageButtonColour
|
||||
* \li GSStoryPage::IsValidStoryPageButtonFlags
|
||||
* \li GSStoryPage::IsValidStoryPageButtonCursor
|
||||
*
|
||||
* API removals:
|
||||
* \li GSError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, that error is never returned anymore.
|
||||
|
@@ -37,6 +37,11 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
|
||||
return ::StoryPageElement::IsValidID(story_page_element_id);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptStoryPage::IsValidStoryPageElementType(StoryPageElementType type)
|
||||
{
|
||||
return type == SPET_TEXT || type == SPET_LOCATION || type == SPET_GOAL || type == SPET_BUTTON_PUSH || type == SPET_BUTTON_TILE || type == SPET_BUTTON_VEHICLE;
|
||||
}
|
||||
|
||||
/* static */ ScriptStoryPage::StoryPageID ScriptStoryPage::New(ScriptCompany::CompanyID company, Text *title)
|
||||
{
|
||||
CCountedPtr<Text> counter(title);
|
||||
@@ -66,6 +71,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
|
||||
|
||||
EnforceDeityMode(STORY_PAGE_ELEMENT_INVALID);
|
||||
EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, IsValidStoryPage(story_page_id));
|
||||
EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, IsValidStoryPageElementType(type));
|
||||
std::string encoded_text;
|
||||
if (StoryPageElementTypeRequiresText(btype)) {
|
||||
EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, text != nullptr);
|
||||
@@ -226,10 +232,32 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
|
||||
return ScriptObject::DoCommand(0, story_page_element_id, 0, CMD_REMOVE_STORY_PAGE_ELEMENT);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptStoryPage::IsValidStoryPageButtonColour(StoryPageButtonColour colour)
|
||||
{
|
||||
return ::IsValidColours((::Colours)colour);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptStoryPage::IsValidStoryPageButtonFlags(StoryPageButtonFlags flags)
|
||||
{
|
||||
/* Don't allow float left and right together */
|
||||
if ((flags & SPBF_FLOAT_LEFT) && (flags & SPBF_FLOAT_RIGHT)) return false;
|
||||
/* Don't allow undefined flags */
|
||||
if (flags & ~(SPBF_FLOAT_LEFT | SPBF_FLOAT_RIGHT)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptStoryPage::IsValidStoryPageButtonCursor(StoryPageButtonCursor cursor)
|
||||
{
|
||||
return ::IsValidStoryPageButtonCursor((::StoryPageButtonCursor)cursor);
|
||||
}
|
||||
|
||||
/* static */ ScriptStoryPage::StoryPageButtonFormatting ScriptStoryPage::MakePushButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags)
|
||||
{
|
||||
EnforcePrecondition(UINT32_MAX, IsValidStoryPageButtonColour(colour));
|
||||
EnforcePrecondition(UINT32_MAX, IsValidStoryPageButtonFlags(flags));
|
||||
|
||||
StoryPageButtonData data;
|
||||
data.SetColour((Colours)colour);
|
||||
data.SetColour((::Colours)colour);
|
||||
data.SetFlags((::StoryPageButtonFlags)flags);
|
||||
if (!data.ValidateColour()) return UINT32_MAX;
|
||||
if (!data.ValidateFlags()) return UINT32_MAX;
|
||||
@@ -238,8 +266,12 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
|
||||
|
||||
/* static */ ScriptStoryPage::StoryPageButtonFormatting ScriptStoryPage::MakeTileButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags, StoryPageButtonCursor cursor)
|
||||
{
|
||||
EnforcePrecondition(UINT32_MAX, IsValidStoryPageButtonColour(colour));
|
||||
EnforcePrecondition(UINT32_MAX, IsValidStoryPageButtonFlags(flags));
|
||||
EnforcePrecondition(UINT32_MAX, IsValidStoryPageButtonCursor(cursor));
|
||||
|
||||
StoryPageButtonData data;
|
||||
data.SetColour((Colours)colour);
|
||||
data.SetColour((::Colours)colour);
|
||||
data.SetFlags((::StoryPageButtonFlags)flags);
|
||||
data.SetCursor((::StoryPageButtonCursor)cursor);
|
||||
if (!data.ValidateColour()) return UINT32_MAX;
|
||||
@@ -250,8 +282,13 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
|
||||
|
||||
/* static */ ScriptStoryPage::StoryPageButtonFormatting ScriptStoryPage::MakeVehicleButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags, StoryPageButtonCursor cursor, ScriptVehicle::VehicleType vehtype)
|
||||
{
|
||||
EnforcePrecondition(UINT32_MAX, IsValidStoryPageButtonColour(colour));
|
||||
EnforcePrecondition(UINT32_MAX, IsValidStoryPageButtonFlags(flags));
|
||||
EnforcePrecondition(UINT32_MAX, IsValidStoryPageButtonCursor(cursor));
|
||||
EnforcePrecondition(UINT32_MAX, vehtype == ScriptVehicle::VT_INVALID || vehtype == ScriptVehicle::VT_RAIL || vehtype == ScriptVehicle::VT_ROAD || vehtype == ScriptVehicle::VT_WATER || vehtype == ScriptVehicle::VT_AIR);
|
||||
|
||||
StoryPageButtonData data;
|
||||
data.SetColour((Colours)colour);
|
||||
data.SetColour((::Colours)colour);
|
||||
data.SetFlags((::StoryPageButtonFlags)flags);
|
||||
data.SetCursor((::StoryPageButtonCursor)cursor);
|
||||
data.SetVehicleType((::VehicleType)vehtype);
|
||||
@@ -261,4 +298,3 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
|
||||
if (!data.ValidateVehicleType()) return UINT32_MAX;
|
||||
return data.referenced_id;
|
||||
}
|
||||
|
||||
|
@@ -146,7 +146,7 @@ public:
|
||||
* Colour codes usable for story page button elements.
|
||||
* Place a colour value in the lowest 8 bits of the \c reference parameter to the button.
|
||||
*/
|
||||
enum StoryPageButtonColour {
|
||||
enum StoryPageButtonColour : byte {
|
||||
SPBC_DARK_BLUE = ::COLOUR_DARK_BLUE,
|
||||
SPBC_PALE_GREEN = ::COLOUR_PALE_GREEN,
|
||||
SPBC_PINK = ::COLOUR_PINK,
|
||||
@@ -179,6 +179,13 @@ public:
|
||||
*/
|
||||
static bool IsValidStoryPageElement(StoryPageElementID story_page_element_id);
|
||||
|
||||
/**
|
||||
* Check whether this is a valid story page element type.
|
||||
* @param type The StoryPageElementType to check.
|
||||
* @return True if and only if this story page element type is valid.
|
||||
*/
|
||||
static bool IsValidStoryPageElementType(StoryPageElementType type);
|
||||
|
||||
/**
|
||||
* Create a new story page.
|
||||
* @param company The company to create the story page for, or ScriptCompany::COMPANY_INVALID for all.
|
||||
@@ -202,6 +209,7 @@ public:
|
||||
* @return The new StoryPageElementID, or STORY_PAGE_ELEMENT_INVALID if it failed.
|
||||
* @pre ScriptCompanyMode::IsDeity().
|
||||
* @pre IsValidStoryPage(story_page).
|
||||
* @pre IsValidStoryPageElementType(type).
|
||||
* @pre (type != SPET_TEXT && type != SPET_LOCATION) || (text != null && len(text) != 0).
|
||||
* @pre type != SPET_LOCATION || ScriptMap::IsValidTile(reference).
|
||||
* @pre type != SPET_GOAL || ScriptGoal::IsValidGoal(reference).
|
||||
@@ -312,11 +320,34 @@ public:
|
||||
*/
|
||||
static bool RemoveElement(StoryPageElementID story_page_element_id);
|
||||
|
||||
/**
|
||||
* Check whether this is a valid story page button colour.
|
||||
* @param colour The StoryPageButtonColour to check.
|
||||
* @return True if and only if this story page button colour is valid.
|
||||
*/
|
||||
static bool IsValidStoryPageButtonColour(StoryPageButtonColour colour);
|
||||
|
||||
/**
|
||||
* Check whether this is a valid story page button flag.
|
||||
* @param colour The StoryPageButtonFlags to check.
|
||||
* @return True if and only if this story page button flag is valid.
|
||||
*/
|
||||
static bool IsValidStoryPageButtonFlags(StoryPageButtonFlags flags);
|
||||
|
||||
/**
|
||||
* Check whether this is a valid story page button cursor.
|
||||
* @param colour The StoryPageButtonCursor to check.
|
||||
* @return True if and only if this story page button cursor is valid.
|
||||
*/
|
||||
static bool IsValidStoryPageButtonCursor(StoryPageButtonCursor cursor);
|
||||
|
||||
/**
|
||||
* Create a reference value for SPET_BUTTON_PUSH element parameters.
|
||||
* @param colour The colour for the face of the button.
|
||||
* @param flags The formatting and layout flags for the button.
|
||||
* @return A reference value usable with the #NewElement and #UpdateElement functions.
|
||||
* @pre IsValidStoryPageButtonColour(colour).
|
||||
* @pre IsValidStoryPageButtonFlags(flags).
|
||||
*/
|
||||
static StoryPageButtonFormatting MakePushButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags);
|
||||
|
||||
@@ -326,6 +357,9 @@ public:
|
||||
* @param flags The formatting and layout flags for the button.
|
||||
* @param cursor The mouse cursor to use when the player clicks the button and the game is ready for the player to select a tile.
|
||||
* @return A reference value usable with the #NewElement and #UpdateElement functions.
|
||||
* @pre IsValidStoryPageButtonColour(colour).
|
||||
* @pre IsValidStoryPageButtonFlags(flags).
|
||||
* @pre IsValidStoryPageButtonCursor(cursor).
|
||||
*/
|
||||
static StoryPageButtonFormatting MakeTileButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags, StoryPageButtonCursor cursor);
|
||||
|
||||
@@ -336,6 +370,10 @@ public:
|
||||
* @param cursor The mouse cursor to use when the player clicks the button and the game is ready for the player to select a vehicle.
|
||||
* @param vehtype The type of vehicle that will be selectable, or \c VT_INVALID to allow all types.
|
||||
* @return A reference value usable with the #NewElement and #UpdateElement functions.
|
||||
* @pre IsValidStoryPageButtonColour(colour).
|
||||
* @pre IsValidStoryPageButtonFlags(flags).
|
||||
* @pre IsValidStoryPageButtonCursor(cursor).
|
||||
* @pre vehtype == ScriptVehicle::VT_INVALID || vehtype == ScriptVehicle::VT_RAIL || vehtype == ScriptVehicle::VT_ROAD || vehtype == ScriptVehicle::VT_WATER || vehtype == ScriptVehicle::VT_AIR.
|
||||
*/
|
||||
static StoryPageButtonFormatting MakeVehicleButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags, StoryPageButtonCursor cursor, ScriptVehicle::VehicleType vehtype);
|
||||
};
|
||||
|
Reference in New Issue
Block a user