| 1061 | } |
| 1062 | |
| 1063 | void buttonCycleSprites(button_t* my) |
| 1064 | { |
| 1065 | SDL_Rect pos; |
| 1066 | char tmp[4]; |
| 1067 | Entity* entity = nullptr; |
| 1068 | Entity* lastEntity = nullptr; |
| 1069 | bool entityWasSelected = false; |
| 1070 | for ( node_t* node = map.entities->first; node != nullptr; node = node->next ) |
| 1071 | { |
| 1072 | entity = (Entity*)node->element; |
| 1073 | pos.x = entity->x * (TEXTURESIZE / 16) - camx; |
| 1074 | pos.y = entity->y * (TEXTURESIZE / 16) - camy; |
| 1075 | if ( (omousex / TEXTURESIZE) * 32 == pos.x && (omousey / TEXTURESIZE) * 32 == pos.y ) |
| 1076 | { |
| 1077 | // set lastEntity to each entity on the tile. |
| 1078 | lastEntity = entity; |
| 1079 | } |
| 1080 | } |
| 1081 | |
| 1082 | if ( lastEntity != nullptr ) |
| 1083 | { |
| 1084 | if ( selectedEntity[0] ) |
| 1085 | { |
| 1086 | entityWasSelected = true; |
| 1087 | } |
| 1088 | |
| 1089 | selectedEntity[0] = nullptr; |
| 1090 | lastSelectedEntity[0] = nullptr; |
| 1091 | |
| 1092 | // create new entity on the list, copying and removing the previous last one. |
| 1093 | entity = newEntity(lastEntity->sprite, 0, map.entities, nullptr); |
| 1094 | setSpriteAttributes(entity, lastEntity, lastEntity); |
| 1095 | list_RemoveNode(lastEntity->mynode); |
| 1096 | |
| 1097 | if ( entityWasSelected ) |
| 1098 | { |
| 1099 | selectedEntity[0] = entity; |
| 1100 | lastSelectedEntity[0] = selectedEntity[0]; |
| 1101 | } |
| 1102 | } |
| 1103 | } |
| 1104 | |
| 1105 | void buttonSelectAll(button_t* my) |
| 1106 | { |
no test coverage detected