Проблема здесь в том, что я не уверен, как определить элементы типов объектов в перечислении, потому что считаю, что вы не можете динамически заполнять перечисление в C++? Альтернативно, есть ли какой-то другой подход, которого мне не хватает?
Мой класс Placeable имеет следующее:
Код: Выделить всё
class Placeable {
private:
std::vector objtypes;
};
Код: Выделить всё
class World {
private:
enum CursorState {
Select, // This is the default state
// Array of elements in objtypes goes here
};
CursorState cursorState;
};
Код: Выделить всё
if (this->mouse->IsButtonReleased(0) && this->popupType != button.type) {
this->popupType = button.type;
// Update cursor state depending on button press
switch (button.type) {
case 1:
cursorState = ;
// Run corresponding effects and log change of state
break;
default:
cursorState = Select,
}
}
Подробнее здесь: https://stackoverflow.com/questions/785 ... -enum-in-c
Мобильная версия