| 1155 | } |
| 1156 | |
| 1157 | void Push2Control::Poll() |
| 1158 | { |
| 1159 | if (mPendingSpawnPitch != -1) |
| 1160 | { |
| 1161 | int padNum = mPendingSpawnPitch - 36; |
| 1162 | int gridX = padNum % 8; |
| 1163 | int gridY = padNum / 8; |
| 1164 | int gridIndex = gridX + (7 - gridY) * 8; |
| 1165 | IDrawableModule* existingModule = mModuleGrid[gridIndex]; |
| 1166 | ofVec2f newModulePos; |
| 1167 | if (existingModule != nullptr) |
| 1168 | { |
| 1169 | ofRectangle existingModuleRect = existingModule->GetRect(); |
| 1170 | newModulePos = ofVec2f(existingModuleRect.getMinX(), existingModuleRect.getMaxY() + 40); |
| 1171 | } |
| 1172 | else |
| 1173 | { |
| 1174 | newModulePos = ofVec2f(ofMap(gridX, 0, 7, mModuleGridRect.getMinX(), mModuleGridRect.getMaxX()), ofMap(gridY, 7, 0, mModuleGridRect.getMinY(), mModuleGridRect.getMaxY())); |
| 1175 | } |
| 1176 | |
| 1177 | for (int i = 0; i < mSpawnLists.GetDropdowns().size(); ++i) |
| 1178 | { |
| 1179 | if (mSpawnLists.GetDropdowns()[i]->GetList()->GetValue() != -1) |
| 1180 | { |
| 1181 | IDrawableModule* module = mSpawnLists.GetDropdowns()[i]->Spawn(mSpawnLists.GetDropdowns()[i]->GetList()->GetValue()); |
| 1182 | module->SetPosition(newModulePos.x, newModulePos.y); |
| 1183 | mSpawnLists.GetDropdowns()[i]->GetList()->SetValue(-1, gTime); |
| 1184 | mScreenDisplayMode = ScreenDisplayMode::kNormal; |
| 1185 | SetDisplayModule(module, true); |
| 1186 | |
| 1187 | if (existingModule != nullptr && existingModule->GetPatchCableSource() != nullptr) |
| 1188 | { |
| 1189 | IClickable* insertTarget = existingModule->GetPatchCableSource()->GetTarget(); |
| 1190 | |
| 1191 | existingModule->GetPatchCableSource()->FindValidTargets(); |
| 1192 | if (existingModule->GetPatchCableSource()->IsValidTarget(module)) |
| 1193 | existingModule->SetTarget(module); |
| 1194 | |
| 1195 | if (module->GetPatchCableSource()) |
| 1196 | { |
| 1197 | module->GetPatchCableSource()->FindValidTargets(); |
| 1198 | if (insertTarget != nullptr && module->GetPatchCableSource()->IsValidTarget(insertTarget)) |
| 1199 | module->SetTarget(insertTarget); |
| 1200 | } |
| 1201 | } |
| 1202 | break; |
| 1203 | } |
| 1204 | } |
| 1205 | |
| 1206 | mPendingSpawnPitch = -1; |
| 1207 | } |
| 1208 | |
| 1209 | bool controlsChanged = false; |
| 1210 | if (mDisplayModule != nullptr && mDisplayModule->HasPush2OverrideControls()) |
| 1211 | { |
| 1212 | std::vector<IUIControl*> desiredControls; |
| 1213 | mDisplayModule->GetPush2OverrideControls(desiredControls); |
| 1214 | if (desiredControls.size() != mDisplayedControls.size()) |
nothing calls this directly
no test coverage detected