void State_MainMenu::OnCreate(){ GUI_Manager* gui = m_stateMgr->GetContext()->m_guiManager; gui->LoadInterface(StateType::MainMenu, "MainMenu.interface", "MainMenu"); gui->GetInterface(StateType::MainMenu, "MainMenu")->SetPosition(sf::Vector2f(250.f, 168.f)); EventManager* eMgr = m_stateMgr->GetContext()->m_eventManager; eMgr->AddCallback(StateType::MainMenu, "MainMenu_Play", &State_MainMenu::Play, this); eMgr->AddCallback(StateType::MainMenu, "MainMenu_Quit", &State_MainMenu::Quit, this); }
void State_Console::OnCreate() { SetTrancendent(true); SetTransparent(true); m_console.Add("get_player", [this](std::vector<std::string> l) -> std::string{ if(l[0] == "make"){ /* Character* player = (Character*)GetStateManager().GetContext().GetEntityManager()->Find("Player"); if(player){ if(l[1] == "jump"){ player->Jump(); return "character jumped!"; } else if(l[1] == "attack"){ player->Attack(); return "character attacked!"; } }else{ return "player not found"; } */ } return "get_player: invalid parameters"; }, 2, 2, "make 'jump' 'attack'"); EventManager* evMgr = GetStateManager().GetContext().GetEventManager(); evMgr->AddCallback(StateType::Console, "Key_Tilde", &State_Console::Close, this); evMgr->AddCallback(StateType::Console, "Text_Entered", &Console::HandleTextInput, &m_console); evMgr->AddCallback(StateType::Console, "Key_Return", &Console::ValidateInput, &m_console); evMgr->AddCallback(StateType::Console, "Key_Backspace", &Console::Backspace, &m_console); evMgr->AddCallback(StateType::Console, "Key_Up", &Console::CycleInputUp, &m_console); evMgr->AddCallback(StateType::Console, "Key_Down", &Console::CycleInputDown, &m_console); evMgr->AddCallback(StateType::Console, "Key_Left", &Console::MoveCursorLeft, &m_console); evMgr->AddCallback(StateType::Console, "Key_Right", &Console::MoveCursorRight, &m_console); evMgr->AddCallback(StateType::Console, "Key_PageUp", &Console::ScrollOutputUp, &m_console); evMgr->AddCallback(StateType::Console, "Key_PageDown", &Console::ScrollOutputDown, &m_console); //evMgr->AddCallback(StateType::Console, "Key_Shift", &State_Console::OpenFull, this); }