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:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user