diff --git a/src/gui/state_manager.cpp b/src/gui/state_manager.cpp index 0183a90e2..d12930654 100644 --- a/src/gui/state_manager.cpp +++ b/src/gui/state_manager.cpp @@ -92,7 +92,7 @@ namespace StateManager w2->addLabel("MiniBjorn"); GUIEngine::ModelViewWidget* w3 = dynamic_cast - (GUIEngine::getCurrentScreen()->getWidget("modelview")); + (GUIEngine::getCurrentScreen()->getWidget("modelview")); assert( w3 != NULL ); @@ -125,6 +125,9 @@ namespace StateManager (GUIEngine::getCurrentScreen()->getWidget("difficulty")); assert( w != NULL ); w->setSelection(user_config->getDefaultDifficulty()); + + // TODO - if user arrived to this screen by pressing esc from teh enxt, the behaviour below might be incorrect + // it would be better to restore previously set settings. race_manager->setDifficulty( (RaceManager::Difficulty)user_config->getDefaultDifficulty() ); } else if(name == "difficulty") diff --git a/src/gui/widget.cpp b/src/gui/widget.cpp index bfa371e72..92583e34c 100644 --- a/src/gui/widget.cpp +++ b/src/gui/widget.cpp @@ -985,7 +985,10 @@ void ModelViewWidget::add() { rect widget_size = rect(x, y, x + w, y + h); stringw message = m_properties[PROP_TEXT].c_str(); - m_element = GUIEngine::getGUIEnv()->addMeshViewer(widget_size, NULL, ++id_counter); + + + IGUIMeshViewer* mesh_view = GUIEngine::getGUIEnv()->addMeshViewer(widget_size, NULL, ++id_counter); + m_element = mesh_view; id = m_element->getID(); m_element->setTabOrder(id); @@ -995,6 +998,12 @@ void ModelViewWidget::add() void ModelViewWidget::setModel(SAnimatedMesh* mesh) { ((IGUIMeshViewer*)m_element)->setMesh( mesh ); + + video::SMaterial mat = mesh->getMeshBuffer(0)->getMaterial(); //mesh_view->getMaterial(); + mat.setFlag(EMF_LIGHTING , false); + //mat.setFlag(EMF_GOURAUD_SHADING, false); + //mat.setFlag(EMF_NORMALIZE_NORMALS, true); + ((IGUIMeshViewer*)m_element)->setMaterial(mat); } #if 0 diff --git a/src/input/input_manager.cpp b/src/input/input_manager.cpp index a3e6e6f12..810c27337 100644 --- a/src/input/input_manager.cpp +++ b/src/input/input_manager.cpp @@ -300,12 +300,10 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2, // menu navigation. TODO : enable navigation with gamepads if(!StateManager::isGameState()) { + irr::SEvent::SKeyInput evt; + if(type == Input::IT_KEYBOARD) { - irr::SEvent::SKeyInput evt; - - // std::cout << id0 << std::endl; - if(id0 == SDLK_RETURN) evt.Key = irr::KEY_RETURN; else if(id0 == SDLK_UP) @@ -318,15 +316,37 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2, evt.Key = irr::KEY_LEFT; else return; // only those keys are accepted in menus for now. - - evt.PressedDown = value > MAX_VALUE/2; - - irr::SEvent wrapper; - wrapper.KeyInput = evt; - wrapper.EventType = EET_KEY_INPUT_EVENT; - - GUIEngine::getDevice()->postEventFromUser(wrapper); } + else // allow menu navigation with gamepads and other devices too + { + int player; + PlayerAction action; + + const bool action_found = m_device_manager->mapInputToPlayerAndAction( type, id0, id1, id2, value, &player, &action ); + if(!action_found) return; + + if(action == PA_FIRE || action == PA_NITRO) + evt.Key = irr::KEY_RETURN; + else if(action == PA_ACCEL) + evt.Key = irr::KEY_UP; + else if(action == PA_BRAKE) + evt.Key = irr::KEY_DOWN; + else if(action == PA_RIGHT) + evt.Key = irr::KEY_RIGHT; + else if(action == PA_LEFT) + evt.Key = irr::KEY_LEFT; + else + return; // only those bindings are accepted in menus for now. + } + + // send event to irrLicht + evt.PressedDown = value > MAX_VALUE/2; + + irr::SEvent wrapper; + wrapper.KeyInput = evt; + wrapper.EventType = EET_KEY_INPUT_EVENT; + + GUIEngine::getDevice()->postEventFromUser(wrapper); } // in-game event handling