void SubSectionMenu::HandleEvent(Event* aEvent) { switch(aEvent->GetEventCode()) { case BUTTON_ACTION: { //If the scene isn't active, then we want to ignore all button action events if(ServiceLocator::GetSceneManager()->IsActiveScene(this) == false) { return; } //Get the button pointer from the event data Button* button = (Button*)aEvent->GetEventData(); int index = -1; //Determine the index of the button that was pressed const unsigned int buttonCount = WORLD_NUMBER_OF_SUBSECTIONS.x * WORLD_NUMBER_OF_SUBSECTIONS.y; for(unsigned int i = 0; i < buttonCount; i++) { if(button == m_Buttons[i]) { index = i; break; } } //Safety check the index if(index != -1) { //Check the coordinates for the uvec2 coordinates = uvec2(0,0); coordinates.x = (index % WORLD_NUMBER_OF_SUBSECTIONS.x); coordinates.y = ((index - coordinates.x) / WORLD_NUMBER_OF_SUBSECTIONS.x); //Set the filename, based on the button's coordinates stringstream ss; ss << "SubSection" << coordinates.x << "-" << coordinates.y << ".bin"; //Are we saving OR loading? if(m_SaveSubSection != nullptr) { m_SaveSubSection->Save(ss.str()); m_SaveSubSection = nullptr; } else if(m_LoadSubSection != nullptr) { m_LoadSubSection->Load(ss.str()); m_LoadSubSection = nullptr; } //We the save OR load operation is done, pop the sub-section menu ServiceLocator::GetSceneManager()->Pop(); } } break; case KEYBOARD_EVENT: { KeyEvent* keyEvent = (KeyEvent*)aEvent; if(keyEvent->GetKeyEventType() == KeyUp) { //If the escape key is pressed, pop the sub-section menu if(keyEvent->GetKeyCode() == KEY_CODE_ESCAPE) { ServiceLocator::GetSceneManager()->Pop(); } } } break; } }