angus.wood Posted October 21, 2014 Share Posted October 21, 2014 I'd like to "shut away" all the settings for Unigine once we ship, but one thing I can't seem to figure out is how to disable the menu that comes up when the ESC key is pressed. Is there a way in UnigineScript to do so? Link to comment
manuel.gysin Posted October 21, 2014 Share Posted October 21, 2014 We deactivated it in data/core/scripts/system/system.h: #ifndef _RUN_MODE_CLIENT // show/hide main window if(engine.console.getActivity() == 0 && engine.gui.getMouseGrab() == 0 && engine.gui.getPermanentFocus() == NULL && engine.app.clearKeyState(APP_KEY_ESC)) { if(enabled == 0) show(); else hide(); } #endif Link to comment
ulf.schroeter Posted October 21, 2014 Share Posted October 21, 2014 Should also be possible without modifying core scripts. We used something like this in our world script int init() { .... engine.gui.setKeyPressCallback( "keyPressCallback" ); .... return 1; } ..... int keyPressCallback( int key ) { if( key == APP_KEY_ESC ) { engine.app.clearKeyState( key ); return 1; } else { return 0; } } 1 Link to comment
angus.wood Posted October 22, 2014 Author Share Posted October 22, 2014 Thank you both, that's excellent. Edit: this is the code we ended up using. /** * Capture and swallow the escape keypress so that the system menu cannot * be displayed **/ int keypress_callback(int keycode) { // Don't run if the editor is loaded if (engine.editor.isLoaded() == 1) { return 0; } if (keycode == APP_KEY_ESC) { // Allow <ESC> to release the cursor if we have grabbed it. if (engine.app.getMouseGrab() == 1 ) { return 0; }else{ engine.app.clearKeyState(keycode); return 1; } } return 0; } Link to comment
binstream Posted October 25, 2014 Share Posted October 25, 2014 There is a method for that in UNIGINE 2: engine.system.call("systemSetToggle",-1); Link to comment
joseph.howell Posted June 14, 2016 Share Posted June 14, 2016 You can also just #define MENU_USER in your unigine.cpp script file, before the include to system.h. #define MENU_USER ...#include <core/scripts/system/system.h>... This will keep the dialog from popping up at all. Note that the dialog also pops up with the Windows key. So just suppressing the ESC key doesn't cut it. Link to comment
Recommended Posts