mirror of https://github.com/OpenRCT2/OpenRCT2.git
Use new identifier for default objects
This commit is contained in:
parent
58f099a644
commit
d8a7219c86
|
@ -683,7 +683,7 @@ static void window_editor_object_selection_scroll_mousedown(
|
|||
|
||||
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)
|
||||
{
|
||||
if (!window_editor_object_selection_select_object(0, 1, listItem->entry))
|
||||
if (!window_editor_object_selection_select_object(0, INPUT_FLAG_EDITOR_OBJECT_SELECT, listItem->entry))
|
||||
return;
|
||||
|
||||
// Close any other open windows such as options/colour schemes to prevent a crash.
|
||||
|
@ -695,15 +695,16 @@ static void window_editor_object_selection_scroll_mousedown(
|
|||
return;
|
||||
}
|
||||
|
||||
int32_t ebx = 6;
|
||||
int32_t flags = INPUT_FLAG_EDITOR_OBJECT_1 | INPUT_FLAG_EDITOR_OBJECT_SELECT_OBJECTS_IN_SCENERY_GROUP;
|
||||
// If already selected
|
||||
if (!(object_selection_flags & OBJECT_SELECTION_FLAG_SELECTED))
|
||||
ebx = 7;
|
||||
flags |= INPUT_FLAG_EDITOR_OBJECT_SELECT;
|
||||
|
||||
_maxObjectsWasHit = false;
|
||||
if (!window_editor_object_selection_select_object(0, ebx, listItem->entry))
|
||||
if (!window_editor_object_selection_select_object(0, flags, listItem->entry))
|
||||
{
|
||||
rct_string_id error_title = (ebx & 1) ? STR_UNABLE_TO_SELECT_THIS_OBJECT : STR_UNABLE_TO_DE_SELECT_THIS_OBJECT;
|
||||
rct_string_id error_title = (flags & INPUT_FLAG_EDITOR_OBJECT_SELECT) ? STR_UNABLE_TO_SELECT_THIS_OBJECT
|
||||
: STR_UNABLE_TO_DE_SELECT_THIS_OBJECT;
|
||||
|
||||
context_show_error(error_title, gGameCommandErrorText, {});
|
||||
return;
|
||||
|
|
|
@ -342,9 +342,13 @@ static void window_editor_object_selection_select_default_objects()
|
|||
{
|
||||
if (_numSelectedObjectsForType[0] == 0)
|
||||
{
|
||||
for (const auto& defaultSelectedObject : DefaultSelectedObjects)
|
||||
for (auto defaultSelectedObject : DefaultSelectedObjects)
|
||||
{
|
||||
window_editor_object_selection_select_object(0, 7, &defaultSelectedObject);
|
||||
window_editor_object_selection_select_object(
|
||||
0,
|
||||
INPUT_FLAG_EDITOR_OBJECT_SELECT | INPUT_FLAG_EDITOR_OBJECT_1
|
||||
| INPUT_FLAG_EDITOR_OBJECT_SELECT_OBJECTS_IN_SCENERY_GROUP,
|
||||
defaultSelectedObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -408,16 +412,15 @@ static void set_object_selection_error(uint8_t is_master_object, rct_string_id e
|
|||
*
|
||||
* rct2: 0x006AB54F
|
||||
*/
|
||||
int32_t window_editor_object_selection_select_object(uint8_t bh, int32_t flags, const rct_object_entry* entry)
|
||||
bool window_editor_object_selection_select_object(uint8_t isMasterObject, int32_t flags, const ObjectRepositoryItem* item)
|
||||
{
|
||||
int32_t numObjects = static_cast<int32_t>(object_repository_get_items_count());
|
||||
const ObjectRepositoryItem* item = object_repository_find_object_by_entry(entry);
|
||||
if (item == nullptr)
|
||||
{
|
||||
set_object_selection_error(bh, STR_OBJECT_SELECTION_ERR_OBJECT_DATA_NOT_FOUND);
|
||||
return 0;
|
||||
set_object_selection_error(isMasterObject, STR_OBJECT_SELECTION_ERR_OBJECT_DATA_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t numObjects = static_cast<int32_t>(object_repository_get_items_count());
|
||||
// Get repository item index
|
||||
int32_t index = -1;
|
||||
const ObjectRepositoryItem* items = object_repository_get_items();
|
||||
|
@ -430,39 +433,39 @@ int32_t window_editor_object_selection_select_object(uint8_t bh, int32_t flags,
|
|||
}
|
||||
|
||||
uint8_t* selectionFlags = &_objectSelectionFlags[index];
|
||||
if (!(flags & 1))
|
||||
if (!(flags & INPUT_FLAG_EDITOR_OBJECT_SELECT))
|
||||
{
|
||||
if (!(*selectionFlags & OBJECT_SELECTION_FLAG_SELECTED))
|
||||
{
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
else if (*selectionFlags & OBJECT_SELECTION_FLAG_IN_USE)
|
||||
{
|
||||
set_object_selection_error(bh, STR_OBJECT_SELECTION_ERR_CURRENTLY_IN_USE);
|
||||
return 0;
|
||||
set_object_selection_error(isMasterObject, STR_OBJECT_SELECTION_ERR_CURRENTLY_IN_USE);
|
||||
return false;
|
||||
}
|
||||
else if (*selectionFlags & OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED)
|
||||
{
|
||||
set_object_selection_error(bh, STR_OBJECT_SELECTION_ERR_ALWAYS_REQUIRED);
|
||||
return 0;
|
||||
set_object_selection_error(isMasterObject, STR_OBJECT_SELECTION_ERR_ALWAYS_REQUIRED);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t objectType = item->ObjectEntry.GetType();
|
||||
if (objectType == OBJECT_TYPE_SCENERY_GROUP && (flags & INPUT_FLAG_EDITOR_OBJECT_2))
|
||||
if (objectType == OBJECT_TYPE_SCENERY_GROUP && (flags & INPUT_FLAG_EDITOR_OBJECT_SELECT_OBJECTS_IN_SCENERY_GROUP))
|
||||
{
|
||||
for (const auto& sgEntry : item->SceneryGroupInfo.Entries)
|
||||
{
|
||||
window_editor_object_selection_select_object(++bh, flags, &sgEntry);
|
||||
window_editor_object_selection_select_object(++isMasterObject, flags, &sgEntry);
|
||||
}
|
||||
}
|
||||
|
||||
_numSelectedObjectsForType[objectType]--;
|
||||
*selectionFlags &= ~OBJECT_SELECTION_FLAG_SELECTED;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bh == 0)
|
||||
if (isMasterObject == 0)
|
||||
{
|
||||
if (flags & INPUT_FLAG_EDITOR_OBJECT_ALWAYS_REQUIRED)
|
||||
{
|
||||
|
@ -471,7 +474,7 @@ int32_t window_editor_object_selection_select_object(uint8_t bh, int32_t flags,
|
|||
}
|
||||
if (*selectionFlags & OBJECT_SELECTION_FLAG_SELECTED)
|
||||
{
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t objectType = item->ObjectEntry.GetType();
|
||||
|
@ -483,44 +486,57 @@ int32_t window_editor_object_selection_select_object(uint8_t bh, int32_t flags,
|
|||
|
||||
if (maxObjects <= _numSelectedObjectsForType[objectType])
|
||||
{
|
||||
set_object_selection_error(bh, STR_OBJECT_SELECTION_ERR_TOO_MANY_OF_TYPE_SELECTED);
|
||||
return 0;
|
||||
set_object_selection_error(isMasterObject, STR_OBJECT_SELECTION_ERR_TOO_MANY_OF_TYPE_SELECTED);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (objectType == OBJECT_TYPE_SCENERY_GROUP && (flags & INPUT_FLAG_EDITOR_OBJECT_2))
|
||||
if (objectType == OBJECT_TYPE_SCENERY_GROUP && (flags & INPUT_FLAG_EDITOR_OBJECT_SELECT_OBJECTS_IN_SCENERY_GROUP))
|
||||
{
|
||||
for (const auto& sgEntry : item->SceneryGroupInfo.Entries)
|
||||
{
|
||||
if (!window_editor_object_selection_select_object(++bh, flags, &sgEntry))
|
||||
if (!window_editor_object_selection_select_object(++isMasterObject, flags, &sgEntry))
|
||||
{
|
||||
_maxObjectsWasHit = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bh != 0 && !(flags & INPUT_FLAG_EDITOR_OBJECT_1))
|
||||
if (isMasterObject != 0 && !(flags & INPUT_FLAG_EDITOR_OBJECT_1))
|
||||
{
|
||||
char objectName[64];
|
||||
object_create_identifier_name(objectName, 64, &item->ObjectEntry);
|
||||
auto ft = Formatter::Common();
|
||||
ft.Add<const char*>(objectName);
|
||||
set_object_selection_error(bh, STR_OBJECT_SELECTION_ERR_SHOULD_SELECT_X_FIRST);
|
||||
return 0;
|
||||
set_object_selection_error(isMasterObject, STR_OBJECT_SELECTION_ERR_SHOULD_SELECT_X_FIRST);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (maxObjects <= _numSelectedObjectsForType[objectType])
|
||||
{
|
||||
set_object_selection_error(bh, STR_OBJECT_SELECTION_ERR_TOO_MANY_OF_TYPE_SELECTED);
|
||||
return 0;
|
||||
set_object_selection_error(isMasterObject, STR_OBJECT_SELECTION_ERR_TOO_MANY_OF_TYPE_SELECTED);
|
||||
return false;
|
||||
}
|
||||
|
||||
_numSelectedObjectsForType[objectType]++;
|
||||
|
||||
*selectionFlags |= OBJECT_SELECTION_FLAG_SELECTED;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool window_editor_object_selection_select_object(uint8_t isMasterObject, int32_t flags, std::string_view identifier)
|
||||
{
|
||||
auto& objectRepository = OpenRCT2::GetContext()->GetObjectRepository();
|
||||
const auto* item = objectRepository.FindObject(identifier);
|
||||
return window_editor_object_selection_select_object(isMasterObject, flags, item);
|
||||
}
|
||||
|
||||
bool window_editor_object_selection_select_object(uint8_t isMasterObject, int32_t flags, const rct_object_entry* entry)
|
||||
{
|
||||
const ObjectRepositoryItem* item = object_repository_find_object_by_entry(entry);
|
||||
return window_editor_object_selection_select_object(isMasterObject, flags, item);
|
||||
}
|
||||
|
||||
bool editor_check_object_group_at_least_one_selected(int32_t checkObjectType)
|
||||
{
|
||||
int32_t numObjects = static_cast<int32_t>(object_repository_get_items_count());
|
||||
|
|
|
@ -16,8 +16,9 @@
|
|||
|
||||
enum EDITOR_INPUT_FLAGS
|
||||
{
|
||||
INPUT_FLAG_EDITOR_OBJECT_SELECT = (1 << 0), // Set when you want to select an object, not set when you want to deselect it.
|
||||
INPUT_FLAG_EDITOR_OBJECT_1 = (1 << 1),
|
||||
INPUT_FLAG_EDITOR_OBJECT_2 = (1 << 2),
|
||||
INPUT_FLAG_EDITOR_OBJECT_SELECT_OBJECTS_IN_SCENERY_GROUP = (1 << 2),
|
||||
INPUT_FLAG_EDITOR_OBJECT_ALWAYS_REQUIRED = (1 << 3)
|
||||
};
|
||||
|
||||
|
@ -31,7 +32,9 @@ void unload_unselected_objects();
|
|||
void sub_6AB211();
|
||||
void reset_selected_object_count_and_size();
|
||||
void finish_object_selection();
|
||||
int32_t window_editor_object_selection_select_object(uint8_t bh, int32_t flags, const rct_object_entry* entry);
|
||||
bool window_editor_object_selection_select_object(uint8_t isMasterObject, int32_t flags, const ObjectRepositoryItem* item);
|
||||
bool window_editor_object_selection_select_object(uint8_t isMasterObject, int32_t flags, std::string_view identifier);
|
||||
bool window_editor_object_selection_select_object(uint8_t isMasterObject, int32_t flags, const rct_object_entry* entry);
|
||||
|
||||
/**
|
||||
* Removes all unused objects from the object selection.
|
||||
|
|
|
@ -11,41 +11,41 @@
|
|||
|
||||
#include "Object.h"
|
||||
|
||||
const rct_object_entry DefaultSelectedObjects[] = {
|
||||
const std::string_view DefaultSelectedObjects[] = {
|
||||
// An initial default selection
|
||||
{ 0x00000087, { "SCGTREES" } }, // Scenery: Trees
|
||||
{ 0x00000087, { "SCGSHRUB" } }, // Scenery: Shrubs and Ornaments
|
||||
{ 0x00000087, { "SCGGARDN" } }, // Scenery: Gardens
|
||||
{ 0x00000087, { "SCGFENCE" } }, // Scenery: Fences and Walls
|
||||
{ 0x00000087, { "SCGWALLS" } }, // Scenery: Walls and Roofs
|
||||
{ 0x00000087, { "SCGPATHX" } }, // Scenery: Signs and Items for Footpaths
|
||||
{ 0x00000085, { "TARMAC " } }, // Footpath: Tarmac
|
||||
{ 0x00000080, { "TWIST1 " } }, // Ride: Twist
|
||||
{ 0x00000080, { "PTCT1 " } }, // Ride: Wooden Roller Coaster (Wooden Roller Coaster Trains)
|
||||
{ 0x00000080, { "ZLDB " } }, // Ride: Junior Roller Coaster (Ladybird Trains)
|
||||
{ 0x00000080, { "LFB1 " } }, // Ride: Log Flume
|
||||
{ 0x00000080, { "VCR " } }, // Ride: Vintage Cars
|
||||
{ 0x00000080, { "MGR1 " } }, // Ride: Merry-Go-Round
|
||||
{ 0x00000080, { "TLT1 " } }, // Ride: Restroom
|
||||
{ 0x00000080, { "ATM1 " } }, // Ride: Cash Machine
|
||||
{ 0x00000080, { "FAID1 " } }, // Ride: First Aid Room
|
||||
{ 0x00000080, { "INFOK " } }, // Ride: Information Kiosk
|
||||
{ 0x00000080, { "DRNKS " } }, // Ride: Drinks Stall
|
||||
{ 0x00000080, { "CNDYF " } }, // Ride: Candyfloss Stall
|
||||
{ 0x00000080, { "BURGB " } }, // Ride: Burger Bar
|
||||
{ 0x00000080, { "BALLN " } }, // Ride: Balloon Stall
|
||||
{ 0x00000080, { "ARRT1 " } }, // Ride: Corkscrew Roller Coaster
|
||||
{ 0x00000080, { "RBOAT " } }, // Ride: Rowing Boats
|
||||
{ 0x00000088, { "PKENT1 " } }, // Park Entrance: Traditional Park Entrance
|
||||
{ 0x00000089, { "WTRCYAN " } }, // Water: Natural Water
|
||||
{ 0x00000085, { "TARMACB " } }, // Footpath: Brown Tarmac Footpath
|
||||
{ 0x00000085, { "PATHSPCE" } }, // Footpath: Space Style Footpath
|
||||
{ 0x00000085, { "PATHDIRT" } }, // Footpath: Dirt Footpath
|
||||
{ 0x00000085, { "PATHCRZY" } }, // Footpath: Crazy Paving Footpath
|
||||
{ 0x00000085, { "PATHASH " } }, // Footpath: Ash Footpath
|
||||
"rct2.scgtrees", // Scenery: Trees
|
||||
"rct2.scgshrub", // Scenery: Shrubs and Ornaments
|
||||
"rct2.scggardn", // Scenery: Gardens
|
||||
"rct2.scgfence", // Scenery: Fences and Walls
|
||||
"rct2.scgwalls", // Scenery: Walls and Roofs
|
||||
"rct2.scgpathx", // Scenery: Signs and Items for Footpaths
|
||||
"rct2.tarmac", // Footpath: Tarmac
|
||||
"rct2.twist1", // Ride: Twist
|
||||
"rct2.ptct1", // Ride: Wooden Roller Coaster (Wooden Roller Coaster Trains)
|
||||
"rct2.zldb", // Ride: Junior Roller Coaster (Ladybird Trains)
|
||||
"rct2.lfb1", // Ride: Log Flume
|
||||
"rct2.vcr", // Ride: Vintage Cars
|
||||
"rct2.mgr1", // Ride: Merry-Go-Round
|
||||
"rct2.tlt1", // Ride: Restroom
|
||||
"rct2.atm1", // Ride: Cash Machine
|
||||
"rct2.faid1", // Ride: First Aid Room
|
||||
"rct2.infok", // Ride: Information Kiosk
|
||||
"rct2.drnks", // Ride: Drinks Stall
|
||||
"rct2.cndyf", // Ride: Candyfloss Stall
|
||||
"rct2.burgb", // Ride: Burger Bar
|
||||
"rct2.balln", // Ride: Balloon Stall
|
||||
"rct2.arrt1", // Ride: Corkscrew Roller Coaster
|
||||
"rct2.rboat", // Ride: Rowing Boats
|
||||
"rct2.pkent1", // Park Entrance: Traditional Park Entrance
|
||||
"rct2.wtrcyan", // Water: Natural Water
|
||||
"rct2.tarmacb", // Footpath: Brown Tarmac Footpath
|
||||
"rct2.pathspce", // Footpath: Space Style Footpath
|
||||
"rct2.pathdirt", // Footpath: Dirt Footpath
|
||||
"rct2.pathcrzy", // Footpath: Crazy Paving Footpath
|
||||
"rct2.pathash", // Footpath: Ash Footpath
|
||||
|
||||
// The following are for all random map generation features to work out the box
|
||||
{ 0x00000087, { "SCGJUNGL" } }, // Jungle Theming
|
||||
{ 0x00000087, { "SCGSNOW " } }, // Snow and Ice Theming
|
||||
{ 0x00000087, { "SCGWATER" } } // Water Feature Theming
|
||||
"rct2.scgjungl", // Jungle Theming
|
||||
"rct2.scgsnow", // Snow and Ice Theming
|
||||
"rct2.scgwater", // Water Feature Theming
|
||||
};
|
||||
|
|
|
@ -11,4 +11,4 @@
|
|||
|
||||
#include "Object.h"
|
||||
|
||||
extern const rct_object_entry DefaultSelectedObjects[33];
|
||||
extern const std::string_view DefaultSelectedObjects[33];
|
||||
|
|
Loading…
Reference in New Issue