philip.atha Posted May 3, 2014 Share Posted May 3, 2014 Is there a mechanism for saving the parameters input into an editor window? Seems trivial and I looked into how it was done for the Materials and Properties dialogs but those only save engine values directly. Link to comment
philip.atha Posted May 3, 2014 Author Share Posted May 3, 2014 Ah nvm, I get it, engine.config class. Clever. I guess a quick follow up is, how do you save the window position? Evidently getPositionX(), and getPositionY() mean something entirely different. Link to comment
azagniy Posted May 8, 2014 Share Posted May 8, 2014 Hi Philip. Can you specify your problem case? What type of saving do you mean? It can be engine "save/restore" or your custom editor plugin window or your game with HUD or something else. For all this cases exists different solutions. Link to comment
ivan.cuevas Posted May 8, 2014 Share Posted May 8, 2014 I personally use functions engine.config for the apllication/game or %UNIGINE_DIR%\data\core\editor\editor_config.h functions for Unigine Editor plugins. //... int width = configGet("camera_width",window.getWidth()); int height = configGet("camera_height",window.getHeight()); int position_x = configGet("camera_position_x",window.getPositionX()); int position_y = configGet("camera_position_y",window.getPositionY()); //... Link to comment
azagniy Posted May 12, 2014 Share Posted May 12, 2014 The "configGet" and "configSet" functions declared in the "data/core/editor/editor_config.h" works with a "editor_config.cfg" file. All parameters saves in to the config file at editor shutdown only. This is a best way to save your any parameters when you working as a editor plugin. If your code works as world logic and no depends from editor, then best way to save yours parameters is a using engine.config functions. This config always work when engine are started, and saves to a "engine_config.cfg" file at engine shutdown. But you can always write yours config implementation and use custom config files.For example, you can see as sample a data storage implementation for a "Game framework" in the "data/framework/game/game_data.h" file. Link to comment
philip.atha Posted August 12, 2014 Author Share Posted August 12, 2014 I have to bring this up again since whatever solution I had, I lost and the current approach doesnt work. So what I'm trying to do is simply get my window position and save it to the config file so when the editor is reloaded, I don't have to move a particular window out of view. I can save the window width and height, but window.getPositionX() and getPositionY() always return values of zero. If I try to manually set a position, the UI is offset within its parent control resulting in a black box where the window would be. I don't understand the relationship, I'm assuming its like this: GUI Interface <- I think I want to move this? WidgetWindow <- Not this? Widget A Widget B Link to comment
silent Posted August 12, 2014 Share Posted August 12, 2014 Hi Philip, Could you please provide simple test scene and short description of what you want to achieve (what window position you want to save and restore later)? This scene will surely help us to get to the root of your issue faster. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
philip.atha Posted August 12, 2014 Author Share Posted August 12, 2014 It's very simple. All I want the editor to do is remember the last screen position of the UI window when editor_reload is called. init() { editorWindow(window); width = int(configGet("WINDOW::width",width)); height = int(configGet("WINDOW::height",height)); int position_x = window.getPositionX()); int position_y = window.getPositionY()); lastTab = int(configGet("WINDOW::lastTab", lastTab)); log.message("" + width + "\n"); log.message("" + height + "\n"); log.message("" + position_x + "\n"); <-Returns zero log.message("" + position_y + "\n"); <-Returns zero DECLARE_WINDOW_INIT(MYWINDOW) } Link to comment
unclebob Posted August 14, 2014 Share Posted August 14, 2014 Hey Philip, You just need to save window position to config as you did with its size. Try to use this code sample (I'm assuming you have initialized window instance somewhere): int init() { window.setWidth(configGet("window_width",0)); window.setHeight(configGet("window_height",0)); int position_x = configGet("window_position_x",128); int position_y = configGet("window_position_y",128); window.setPosition(position_x,position_y); return 1; } int shutdown() { configSet("window_width",window.getWidth()); configSet("window_height",window.getHeight()); configSet("window_position_x",window.getPositionX()); configSet("window_position_y",window.getPositionY()); return 1; } Another solution is to store your parameters in system script though it have other pros & cons. Link to comment
Recommended Posts