Vladimir_spb
Member
Help me how to change the window mode in the menu?
Here I do not understand how to write correctly.
GML:
#macro MAIN 0
#macro SETTINGS 1
global.dsm_settings = ds_map_create();
#macro set global.dsm_settings
ds_map_add(set, "sound", [5, [0, 10]]);
ds_map_add(set, "music" , [5, [0, 10]]);
ds_map_add(set, "window mode" , [0, ["Window", "Fullscreen"]]);
ds_map_add(set, "window size" , [1, ["x2", "x3", "x4"]]);
//Главное. Submenu 0.
menu[MAIN][0] = "Start Game";
menu[MAIN][1] = "Settings";
menu[MAIN][2] = "Exit";
//Submenu 1.
menu[SETTINGS][0] = ["Sound ", "sound"];
menu[SETTINGS][1] = ["Music ", "music"];
menu[SETTINGS][2] = ["Window mode ", "window mode"];
menu[SETTINGS][3] = ["Window size ", "window size"];
menu[SETTINGS][4] = "Back";
index = 0;
sub_menu= 0;
menu_size = 0;
Here I do not understand how to write correctly.
GML:
//Window mode.
case 2:
change_menu(_h_move, "window mode");
var _window_mode = global.dsm_settings[? "window mode"];;
if (_window_mode = "Fullscreen") {
window_set_fullscreen(true);
}else{
window_set_fullscreen(false);
}
GML:
#region function change_menu
function change_menu(_move, _key) {
///@desc change the ds map key entry by the move value passed
///@move real which way to move the selection
///@key string ds_map key for this selection
//get the allowed limits for this selection
//get map array
var _map_arr = set[? _key];
//get the limits array
var _limits_arr = _map_arr[1];
if (is_real(_limits_arr[0])) {
var _min = _limits_arr[0];
var _max = _limits_arr[1];
} else {
var _min = 0;
var _max = array_length(_limits_arr) - 1;
}
_map_arr[@ 0] = clamp(_move + _map_arr[0], _min, _max);
}
#endregion