mirror of https://github.com/OpenRCT2/OpenRCT2.git
Close #12427: Refactor OBJECT_TYPE to use strong enum
This commit is contained in:
parent
dc93cacbee
commit
7648feeba2
|
@ -188,7 +188,7 @@ static bool window_editor_bottom_toolbar_check_object_selection()
|
||||||
if (w != nullptr)
|
if (w != nullptr)
|
||||||
{
|
{
|
||||||
// Click tab with missing object
|
// Click tab with missing object
|
||||||
window_event_mouse_up_call(w, WC_EDITOR_OBJECT_SELECTION__WIDX_TAB_1 + missingObjectType);
|
window_event_mouse_up_call(w, WC_EDITOR_OBJECT_SELECTION__WIDX_TAB_1 + EnumValue(missingObjectType));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,7 +212,7 @@ static constexpr const int32_t window_editor_object_selection_animation_divisor[
|
||||||
|
|
||||||
static void window_editor_object_set_page(rct_window* w, int32_t page);
|
static void window_editor_object_set_page(rct_window* w, int32_t page);
|
||||||
static void window_editor_object_selection_set_pressed_tab(rct_window* w);
|
static void window_editor_object_selection_set_pressed_tab(rct_window* w);
|
||||||
static int32_t get_object_from_object_selection(uint8_t object_type, int32_t y);
|
static int32_t get_object_from_object_selection(ObjectType object_type, int32_t y);
|
||||||
static void window_editor_object_selection_manage_tracks();
|
static void window_editor_object_selection_manage_tracks();
|
||||||
static void editor_load_selected_objects();
|
static void editor_load_selected_objects();
|
||||||
static bool filter_selected(uint8_t objectFlags);
|
static bool filter_selected(uint8_t objectFlags);
|
||||||
|
@ -295,7 +295,7 @@ static void visible_list_refresh(rct_window* w)
|
||||||
{
|
{
|
||||||
uint8_t selectionFlags = _objectSelectionFlags[i];
|
uint8_t selectionFlags = _objectSelectionFlags[i];
|
||||||
const ObjectRepositoryItem* item = &items[i];
|
const ObjectRepositoryItem* item = &items[i];
|
||||||
uint8_t objectType = item->ObjectEntry.GetType();
|
ObjectType objectType = item->ObjectEntry.GetType();
|
||||||
if (objectType == get_selected_object_type(w) && !(selectionFlags & OBJECT_SELECTION_FLAG_6) && filter_source(item)
|
if (objectType == get_selected_object_type(w) && !(selectionFlags & OBJECT_SELECTION_FLAG_6) && filter_source(item)
|
||||||
&& filter_string(item) && filter_chunks(item) && filter_selected(selectionFlags))
|
&& filter_string(item) && filter_chunks(item) && filter_selected(selectionFlags))
|
||||||
{
|
{
|
||||||
|
@ -999,8 +999,8 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf
|
||||||
{
|
{
|
||||||
auto screenPos = w->windowPos + ScreenCoordsXY{ 3, w->height - 13 };
|
auto screenPos = w->windowPos + ScreenCoordsXY{ 3, w->height - 13 };
|
||||||
|
|
||||||
int32_t numSelected = _numSelectedObjectsForType[get_selected_object_type(w)];
|
int32_t numSelected = _numSelectedObjectsForType[EnumValue(get_selected_object_type(w))];
|
||||||
int32_t totalSelectable = object_entry_group_counts[get_selected_object_type(w)];
|
int32_t totalSelectable = object_entry_group_counts[EnumValue(get_selected_object_type(w))];
|
||||||
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
|
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
|
||||||
totalSelectable = 4;
|
totalSelectable = 4;
|
||||||
|
|
||||||
|
@ -1256,7 +1256,7 @@ static void window_editor_object_selection_set_pressed_tab(rct_window* w)
|
||||||
*
|
*
|
||||||
* rct2: 0x006AA703
|
* rct2: 0x006AA703
|
||||||
*/
|
*/
|
||||||
static int32_t get_object_from_object_selection(uint8_t object_type, int32_t y)
|
static int32_t get_object_from_object_selection(ObjectType object_type, int32_t y)
|
||||||
{
|
{
|
||||||
int32_t listItemIndex = y / SCROLLABLE_ROW_HEIGHT;
|
int32_t listItemIndex = y / SCROLLABLE_ROW_HEIGHT;
|
||||||
if (listItemIndex < 0 || static_cast<size_t>(listItemIndex) >= _listItems.size())
|
if (listItemIndex < 0 || static_cast<size_t>(listItemIndex) >= _listItems.size())
|
||||||
|
@ -1502,7 +1502,7 @@ static bool filter_chunks(const ObjectRepositoryItem* item)
|
||||||
case ObjectType::Music:
|
case ObjectType::Music:
|
||||||
case ObjectType::Count:
|
case ObjectType::Count:
|
||||||
case ObjectType::None:
|
case ObjectType::None:
|
||||||
//This function works only with ObjectType::Ride.
|
// This function works only with ObjectType::Ride.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1522,8 +1522,8 @@ static void filter_update_counts()
|
||||||
const ObjectRepositoryItem* item = &items[i];
|
const ObjectRepositoryItem* item = &items[i];
|
||||||
if (filter_source(item) && filter_string(item) && filter_chunks(item) && filter_selected(selectionFlags[i]))
|
if (filter_source(item) && filter_string(item) && filter_chunks(item) && filter_selected(selectionFlags[i]))
|
||||||
{
|
{
|
||||||
uint8_t objectType = item->ObjectEntry.GetType();
|
ObjectType objectType = item->ObjectEntry.GetType();
|
||||||
_filter_object_counts[objectType]++;
|
_filter_object_counts[EnumValue(objectType)]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
#define _EDITOR_H_
|
#define _EDITOR_H_
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "object/Object.h"
|
||||||
#include <src/openrct2/object/Object.h>
|
|
||||||
|
|
||||||
namespace Editor
|
namespace Editor
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,7 +42,7 @@ enum class ObjectType : uint8_t
|
||||||
Music,
|
Music,
|
||||||
|
|
||||||
Count,
|
Count,
|
||||||
None=255
|
None = 255
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OBJECT_SELECTION_FLAGS
|
enum OBJECT_SELECTION_FLAGS
|
||||||
|
|
|
@ -474,7 +474,7 @@ private:
|
||||||
case ObjectType::Music:
|
case ObjectType::Music:
|
||||||
case ObjectType::Count:
|
case ObjectType::Count:
|
||||||
case ObjectType::None:
|
case ObjectType::None:
|
||||||
//This switch handles only ObjectType for sceneries.
|
// This switch handles only ObjectType for sceneries.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,7 @@ protected:
|
||||||
case ObjectType::Music:
|
case ObjectType::Music:
|
||||||
case ObjectType::Count:
|
case ObjectType::Count:
|
||||||
case ObjectType::None:
|
case ObjectType::None:
|
||||||
//Switch processes only ObjectType::Ride and ObjectType::SceneryGroup
|
// Switch processes only ObjectType::Ride and ObjectType::SceneryGroup
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ protected:
|
||||||
case ObjectType::Music:
|
case ObjectType::Music:
|
||||||
case ObjectType::Count:
|
case ObjectType::Count:
|
||||||
case ObjectType::None:
|
case ObjectType::None:
|
||||||
//Switch processes only ObjectType::Ride and ObjectType::SceneryGroup
|
// Switch processes only ObjectType::Ride and ObjectType::SceneryGroup
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
|
|
|
@ -560,7 +560,7 @@ private:
|
||||||
case ObjectType::Music:
|
case ObjectType::Music:
|
||||||
case ObjectType::Count:
|
case ObjectType::Count:
|
||||||
case ObjectType::None:
|
case ObjectType::None:
|
||||||
//This switch processes only ObjectTypes valid for scenery
|
// This switch processes only ObjectTypes valid for scenery
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2999,7 +2999,7 @@ private:
|
||||||
case ObjectType::Music:
|
case ObjectType::Music:
|
||||||
case ObjectType::Count:
|
case ObjectType::Count:
|
||||||
case ObjectType::None:
|
case ObjectType::None:
|
||||||
//This switch processes only ObjectType for for Entries
|
// This switch processes only ObjectType for for Entries
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -785,7 +785,7 @@ static void track_design_mirror_scenery(TrackDesign* td6)
|
||||||
case ObjectType::Music:
|
case ObjectType::Music:
|
||||||
case ObjectType::Count:
|
case ObjectType::Count:
|
||||||
case ObjectType::None:
|
case ObjectType::None:
|
||||||
//This switch processes only ObjectType for Scenery items.
|
// This switch processes only ObjectType for Scenery items.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -900,7 +900,8 @@ static bool TrackDesignPlaceSceneryElementGetEntry(
|
||||||
}
|
}
|
||||||
|
|
||||||
entry_index = 0;
|
entry_index = 0;
|
||||||
for (PathSurfaceEntry* path = get_path_surface_entry(0); entry_index < object_entry_group_counts[ObjectType::Paths];
|
for (PathSurfaceEntry* path = get_path_surface_entry(0);
|
||||||
|
entry_index < object_entry_group_counts[EnumValue(ObjectType::Paths)];
|
||||||
path = get_path_surface_entry(entry_index), entry_index++)
|
path = get_path_surface_entry(entry_index), entry_index++)
|
||||||
{
|
{
|
||||||
if (path == nullptr)
|
if (path == nullptr)
|
||||||
|
@ -987,7 +988,7 @@ static bool TrackDesignPlaceSceneryElementGetPlaceZ(const TrackDesignSceneryElem
|
||||||
_trackDesignPlaceSceneryZ = z;
|
_trackDesignPlaceSceneryZ = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t entry_type;
|
ObjectType entry_type;
|
||||||
ObjectEntryIndex entry_index;
|
ObjectEntryIndex entry_index;
|
||||||
TrackDesignPlaceSceneryElementGetEntry(entry_type, entry_index, scenery);
|
TrackDesignPlaceSceneryElementGetEntry(entry_type, entry_index, scenery);
|
||||||
|
|
||||||
|
@ -1904,7 +1905,7 @@ static bool track_design_place_preview(TrackDesign* td6, money32* cost, Ride** o
|
||||||
*outRide = nullptr;
|
*outRide = nullptr;
|
||||||
*flags = 0;
|
*flags = 0;
|
||||||
|
|
||||||
uint8_t entry_type;
|
ObjectType entry_type;
|
||||||
ObjectEntryIndex entry_index;
|
ObjectEntryIndex entry_index;
|
||||||
if (!find_object_in_entry_group(&td6->vehicle_object, &entry_type, &entry_index))
|
if (!find_object_in_entry_group(&td6->vehicle_object, &entry_type, &entry_index))
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,11 +90,11 @@ namespace OpenRCT2::Scripting
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case ObjectType::Ride:
|
case ObjectType::Ride:
|
||||||
return GetObjectAsDukValue(ctx, std::make_shared<ScRideObject>(EnumValue(type), index));
|
return GetObjectAsDukValue(ctx, std::make_shared<ScRideObject>(type, index));
|
||||||
case ObjectType::SmallScenery:
|
case ObjectType::SmallScenery:
|
||||||
return GetObjectAsDukValue(ctx, std::make_shared<ScSmallSceneryObject>(EnumValue(type), index));
|
return GetObjectAsDukValue(ctx, std::make_shared<ScSmallSceneryObject>(type, index));
|
||||||
default:
|
default:
|
||||||
return GetObjectAsDukValue(ctx, std::make_shared<ScObject>(EnumValue(type), index));
|
return GetObjectAsDukValue(ctx, std::make_shared<ScObject>(type, index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ namespace OpenRCT2::Scripting
|
||||||
auto type = ScObject::StringToObjectType(typez);
|
auto type = ScObject::StringToObjectType(typez);
|
||||||
if (type)
|
if (type)
|
||||||
{
|
{
|
||||||
auto count = object_entry_group_counts[*type];
|
auto count = object_entry_group_counts[EnumValue(*type)];
|
||||||
for (int32_t i = 0; i < count; i++)
|
for (int32_t i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
auto obj = objManager.GetLoadedObject(*type, i);
|
auto obj = objManager.GetLoadedObject(*type, i);
|
||||||
|
|
|
@ -26,11 +26,11 @@ namespace OpenRCT2::Scripting
|
||||||
class ScObject
|
class ScObject
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
uint8_t _type{};
|
ObjectType _type{};
|
||||||
int32_t _index{};
|
int32_t _index{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScObject(uint8_t type, int32_t index)
|
ScObject(ObjectType type, int32_t index)
|
||||||
: _type(type)
|
: _type(type)
|
||||||
, _index(index)
|
, _index(index)
|
||||||
{
|
{
|
||||||
|
@ -71,7 +71,7 @@ namespace OpenRCT2::Scripting
|
||||||
private:
|
private:
|
||||||
std::string type_get() const
|
std::string type_get() const
|
||||||
{
|
{
|
||||||
return std::string(ObjectTypeToString(_type));
|
return std::string(ObjectTypeToString(EnumValue(_type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t index_get() const
|
int32_t index_get() const
|
||||||
|
@ -641,7 +641,7 @@ namespace OpenRCT2::Scripting
|
||||||
class ScRideObject : public ScObject
|
class ScRideObject : public ScObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScRideObject(uint8_t type, int32_t index)
|
ScRideObject(ObjectType type, int32_t index)
|
||||||
: ScObject(type, index)
|
: ScObject(type, index)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -922,7 +922,7 @@ namespace OpenRCT2::Scripting
|
||||||
class ScSmallSceneryObject : public ScObject
|
class ScSmallSceneryObject : public ScObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScSmallSceneryObject(uint8_t type, int32_t index)
|
ScSmallSceneryObject(ObjectType type, int32_t index)
|
||||||
: ScObject(type, index)
|
: ScObject(type, index)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@ namespace OpenRCT2::Scripting
|
||||||
auto rideObject = GetContext()->GetObjectManager().GetLoadedObject(ObjectType::Ride, ride->subtype);
|
auto rideObject = GetContext()->GetObjectManager().GetLoadedObject(ObjectType::Ride, ride->subtype);
|
||||||
if (rideObject != nullptr)
|
if (rideObject != nullptr)
|
||||||
{
|
{
|
||||||
return std::make_shared<ScRideObject>(EnumValue(ObjectType::Ride), ride->subtype);
|
return std::make_shared<ScRideObject>(ObjectType::Ride, ride->subtype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
Loading…
Reference in New Issue