How do i create a rename button when i hit enter(solved)

Imiglikos

Member
After pressing the enter button and over the full screen options, my image changes to a windowed one ... when I press enter again, it returns to the full screen.

I would like the text to become windowed .. and when I press this option again the enter key will turn the text to full screen

Thank you for your help


obj_options

create

GML:
options=ds_list_create()
options[|0]=("Controlls")
options[|1]=("Sound")
options[|2]=("Fullscreen")
options[|3]=("Back")


selected=0




animation_speed=room_speed/2
for(var i=0; i<ds_list_size(options); i++) {
    animation[i]=0
}

step

GML:
if(keyboard_check_pressed(vk_down)) {
    selected++
    if(selected>=ds_list_size(options)) {
        selected=ds_list_size(options)-1
    }
    
}

if(keyboard_check_pressed(vk_up)) {
    selected--
    if(selected<0) {
        selected=0
    }
    
}



if(keyboard_check_pressed(vk_enter))  {
    if(selected=0) {
        room_goto(room_setup)
    } else if(selected=1) {
        room_goto(room_sound)
    } else if(selected=2) {
        
   window_set_fullscreen(!window_get_fullscreen());
 
     if (!window_get_fullscreen()) {
    window_set_size(obj_display.ideal_width, obj_display.ideal_height);
   }


    
    } else if(selected=3) {
        room_goto(room_game_menu)
    }
}

draw

GML:
draw_set_valign(1)
draw_set_halign(1)
draw_set_font(font_menu)

var line_height=ceil(string_height("M")*1.1)

for(var i=0; i<ds_list_size(options); i++) {
    if(i=selected) {
      
        animation[i]=clamp(animation[i]+(1/animation_speed),0,2)
    } else {
        animation[i]=clamp(animation[i]-(1/animation_speed),0,2)
    }
    var color=merge_colour(c_black,c_white,animation[i])
    var s=options[|i]
    draw_text_transformed_color(x,y+(line_height*i),s,1+animation[i]/4,1+animation[i]/4,0,color,color,color,color,1)
}
 

Xer0botXer0

Senpai
I guess you need to actually increase the variable selected when you press enter, then run the switch statement.

GML:
if selected < ds_list_size(options)

{

selected += 1;

}

else

{

selected = 0;

}
It looks like you have the rest of the code already.


Your post is talking about changing text, instead of making that enter button work though. You seem like you can code so I'm guessing it's something less obvious.
 

Imiglikos

Member
I guess you need to actually increase the variable selected when you press enter, then run the switch statement.

GML:
if selected < ds_list_size(options)

{

selected += 1;

}

else

{

selected = 0;

}
It looks like you have the rest of the code already.


Your post is talking about changing text, instead of making that enter button work though. You seem like you can code so I'm guessing it's something less obvious.

This is a ready-made solution that I once bought ... I modified a little ...
And exactly in the final version, what should it look like? the enter key works but I would like the option name to change with only one option where I change the screen display mode.
 

Xer0botXer0

Senpai
GML:
if(keyboard_check_pressed(vk_enter))  {
    if(selected=0) {
        room_goto(room_setup)
    } else if(selected=1) {
        room_goto(room_sound)
    } else if(selected=2) {
       
   window_set_fullscreen(!window_get_fullscreen());
   options[|2]=("Fullscreen");///added

     if (!window_get_fullscreen()) {
    window_set_size(obj_display.ideal_width, obj_display.ideal_height);
    options[|2]=("Windowed");///added

   }
Like that ?
 

Imiglikos

Member
GML:
if(keyboard_check_pressed(vk_enter))  {
    if(selected=0) {
        room_goto(room_setup)
    } else if(selected=1) {
        room_goto(room_sound)
    } else if(selected=2) {
      
   window_set_fullscreen(!window_get_fullscreen());
   options[|2]=("Fullscreen");///added

     if (!window_get_fullscreen()) {
    window_set_size(obj_display.ideal_width, obj_display.ideal_height);
    options[|2]=("Windowed");///added

   }
Like that ?

Thank you Xer0botXer0


Everything works fine now ..
 

Imiglikos

Member
GML:
if(keyboard_check_pressed(vk_enter))  {
    if(selected=0) {
        room_goto(room_setup)
    } else if(selected=1) {
        room_goto(room_sound)
    } else if(selected=2) {
      
   window_set_fullscreen(!window_get_fullscreen());
   options[|2]=("Fullscreen");///added

     if (!window_get_fullscreen()) {
    window_set_size(obj_display.ideal_width, obj_display.ideal_height);
    options[|2]=("Windowed");///added

   }
Like that ?
I have one more question about this topic ... When I enter the options room..and switch from full screen to windowed mode and exit the options menu and then enter the options mode again, instead of displaying the inscription windowed because this mode is enabled the full screen is displayed :)
 

Imiglikos

Member
I have one more question for this topic:

Currently, when I enter the options menu and select window mode with the enter button, it shows me the window mode inscription, and then when I exit the options menu and come back, this inscription disappears and the inscription "display" shows
The same situation is in the case when I choose the full screen mode, the inscription "full screen" will appear, but when I exit the options menu and come back again, this text disappears and the inscription "display" appears
I know that I have this text "display" defined in the event create..but how to make it work the way I described it ..

here my code


obj_options

create

GML:
options=ds_list_create()
options[|0]=("Controlls")
options[|1]=("Sound")
options[|2]=("Display")
options[|3]=("Back")


selected=0




animation_speed=room_speed/2
for(var i=0; i<ds_list_size(options); i++) {
    animation[i]=0
}
step

GML:
if(keyboard_check_pressed(vk_down)) {
    selected++
    if(selected>=ds_list_size(options)) {
        selected=ds_list_size(options)-1
    }
   
}

if(keyboard_check_pressed(vk_up)) {
    selected--
    if(selected<0) {
        selected=0
    }
   
}




       if(keyboard_check_pressed(vk_enter))  {
if(selected=0) {
room_goto(room_setup)
} else if(selected=1) {
room_goto(room_sound)
} else if(selected=2) {

window_set_fullscreen(!window_get_fullscreen());
options[|2]=("Fullscreen");

if (!window_get_fullscreen()) {
window_set_size(obj_display.ideal_width, obj_display.ideal_height);
options[|2]=("Windowed");

}
  



   
    } else if(selected=3) {
        room_goto(room_game_menu)
    }
}
 
Top