Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

I got it to work! First, thank you so much for you help Yal! Your help has cleared up a bunch and made it so I could figure this out. It took a bit to try and understand how the menus work, and I still don't get it all, but for those interested in getting the mouse to work, here's what I did:

First, in the init_input script I added:

#macro input_MA 9
#macro input_MB 10
#macro INPUT_MAX 11
global.input_key[input_MA] = mb_left
global.input_key[input_MB] = mb_right

Then in the function get_keys script I added and changed a couple lines:

p_a = ((p_a + 1)*(k_a + k_ma))
p_b = ((p_b + 1)*(k_b + k_mb))
k_ma = mouse_check_button(global.input_key[input_MA])
k_mb = mouse_check_button(global.input_key[input_MB])

Then I found pretty much everywhere that k_a was and made it (k_a||k_ma). And the same thing with k_b,  I changed them to (k_b||k_mb).

This was to allow for the mouse button to work as the 'A' or the 'B' button, while still keeping the regular 'A' and 'B' button working. So you can use either the mouse or the keyboard.

The part that I had trouble with was figuring out which menu box the mouse was in. What I ended up doing was looping through the options to see if the mouse was hovering over an option. Than looping through the options and checking if the mouse was in each rectangle until it found the right one. It's on the more expensive end, it requires a few loops, but it does seem to work, and I haven't noticed any issues.

So, here's what I put, right near the end of ggui_menu_handler (just above the closing }):

for(c = 0; c < ggui_frames;c++){
     //check to see if the mouse is hovering over an option
     if(mouse_x > ggui_frame_l[c] && mouse_x < ggui_frame_l[c] + ggui_frame_w[c]){
     if(mouse_y > ggui_frame_t[c] && mouse_y < ggui_frame_t[c] + ggui_frame_h[c]){
          //the mouse is hovering over an option, so loop through the options to find out which one we are over
          for(var d = 0; d < menu_w; d++){
          for(var e = 0; e < menu_h; e++){
               frame = menu_frame[d, e];
               //here we are checking to see if the mouse overlaps with the rectangle created by the menu option
               if point_in_rectangle(
                 mouse_x, 
                 mouse_y,
                 lerp(ggui_frame_l[frame],ggui_frame_l[frame] + ggui_frame_w[frame],menu_reg_l[d, e]),
                 lerp(ggui_frame_t[frame],ggui_frame_t[frame] + ggui_frame_h[frame],menu_reg_t[d, e]),
                 lerp(ggui_frame_l[frame],ggui_frame_l[frame] + ggui_frame_w[frame],menu_reg_r[d, e]),
                 lerp(ggui_frame_t[frame],ggui_frame_t[frame] + ggui_frame_h[frame],menu_reg_b[d, e])
               )
               {
                    menuvalue_x = d;
                    menuvalue_y = e;
                    break;//End when we find the first option that matches
               }
          }
          }
     }
     }
}


If anyone has a way to refine this and make it less slow and costly, I'd love to hear it. If what I have put above is unclear, let me know. But, this is what I did, and the mouse seems to be working well.