• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows url_open messes up window resolution

J

Janar

Guest
Hi

This is my first post in the GMS2 forums and even though I went through forum guidelines and links for new members I'm sorry if there's any formatting issues.
I've been using GMS2 for nearly 6 months and never ran into a problem which I couldn't solve by myself by using google search (which mostly guided me here, GMS2 reddit or YouTube) or tutorials. Sadly I've now run into a simple problem which I can't seem to find a solution for.

What I want to do in GMS2:
Add a Twitter button into my game and add functionality to it so that if it is pressed that would open my Twitter account url in web browser. To do that I'm using a HTML5 function "url_open" which I want to use for my Windows platform game (that itself feels controversial, but according to my searches it should work).

The problems:
  1. The function itself works and if the area is clicked the url is opened in the browser, but if I return to the game the window resolution is slightly smaller that it should be (1864x1049 instead of 1920x1080) and the game should be in full screen, but its not even reaching to the borders of the screen (check the pictures below).
  2. If the screen is scaled up to 150% (in Windows display settings) the resolution after returning to the game is even a bit smaller (1841x1036).
  3. What is even stranger is that at some occasions I cannot reproduce the problem, but about 4 out of 5 times i can.
  4. What should also be noted is that window_set_size() is not capable of resizing the window to match the display size (I've added show_debug_message to the code and it gets stuck in a loop)
  5. Running the game in Debug mode sometimes opens the game already with the problem which is described in #1

Screenshot 1 - before pressing the button
screenshot 1 - game on fullscreen.png

Screenshot 2 - returning to the game after I've clicked on the button with "open_url" function:
screenshot 2 - game not in full resolution after clicking on link.png

Remarks:
  • At first I thought that there was a problem with the screen resolution identifier/changer functionality which I mostly created for the game after PixelatedPope's tutorials, but I tried "open_url" functions in a new blank project and get exactly the same results.
  • I'm using point_in_rectangle and mouse_check_button_pressed functions to create the clickable area of the button, because in the end result the text should be clickable in the game (twitter url which displayed as a string and acting like a hyperlink would in a web browser)

Steps to reproduce the problem (in a new blank project):
  1. Create a new project. Set a room size to 1920x1080
  2. Go to Game options > Windows > Graphics and tick "Start fullscreen" option
  3. Create a new object and drag the object into the room
  4. In the STEP event of the object add the following code:
    GML:
    user_display_width = display_get_width();
    user_display_height = display_get_height();
    user_window_w = window_get_width();
    user_window_h = window_get_height();
    
    
    if (user_window_w != user_display_width or user_window_h != user_display_height){
        if (user_window_w != 0 and user_window_h != 0){ // additional condition, so that it would not try to resize the window if the game window is not active (i've noticed that in that case window gets 0x0 parameters
            window_set_size(user_display_width, user_display_height); // set the window to size of the display, if for some reason it's not already the same
            alarm[0] = 1;
            show_debug_message("User display size: " + string(user_window_w) + "x" + string(user_window_h) + ". Changed window size to: " + string(user_display_width) + "x" + string(user_display_height));
        }
        
    }
    
    // this is not actually used, because the game is still in full screen mode after the resolution changes
    is_it_fullscreen = window_get_fullscreen();
    
    if (is_it_fullscreen == false){
        
        window_set_fullscreen(true);
        show_debug_message("Window set to fullscreen");
        
    }
    
    // the area of the button and the click event
    if (point_in_rectangle(mouse_x, mouse_y, 300, 300, 700, 350)){
        
        if(mouse_check_button_pressed(mb_left)){
            
            url_open("https://twitter.com");
            
        }
        
    }
  5. In the DRAW event of the object add the following code:
    Code:
    draw_set_color(c_white);
    draw_text(0 + 20, 0 + 20, "display_w: " + string(user_display_width));
    draw_text(0 + 20, 0 + 40, "display_h: " + string(user_display_height));
    
    draw_text(0 + 20, 0 + 80, "window_w: " + string(user_window_w));
    draw_text(0 + 20, 0 + 100, "window_h: " + string(user_window_h));
    
    draw_text(0 + 20, 0 + 140, "is_it_fullscreen: " + string(is_it_fullscreen));
    
    
    draw_text(300, 280, "Click on white box to go to http://www.twitter.com");
    draw_rectangle_color(300, 300, 700, 350, c_white, c_white, c_white, c_white, true);
  6. Optional: in the Alarm0 event of the object add the following code:
    Code:
    window_center(); // center the window 1 step later than changing the size of the window
    show_debug_message("Window centered");
    
    alarm[0]=1;
  7. Run the game and click on the box that has white borders. It should open up the main page of Twitter
  8. Go back into the game and check if the window size is any different than it was before (check the parameters that are drawn on the left top part of the screen)

Any help would be appreciated
 
J

Janar

Guest
Has anyone else experienced this issue? Could someone try to reproduce the issue try to make sure if it is my local issue or something wider?
I also tried creating separate object with sprite and put "url_open" in left pressed event. It ended up with the same issue.
 
J

Janar

Guest
Well, I'm still stuck with this issue and haven't found a workaround. The same problem is still there after the last GMS2 update.

Does anyone else use social media links in their GMS2 made Windows game (which when clicked in game, open the url in a web browser)?
Maybe there's a better solution for it and someone could share their knowledge with me
 
I'm able to reproduce the issue in GMS 2.2.5

Uncheck "Start Fullscreen" should fix the issue
(no need for this since you're already doing it manually)
 
J

Janar

Guest
@Pineapple Lake , thank you very much for testing it out and giving your feedback.
I unchecked "Start fullscreen" option and got it working. Clicking on the in-game object opens url in a browser (using url_open function) and now leaves the game screen in correct size when I return to it.

So, it seems to be a workaround. However it has a small trade-off for those who want their game to start in fullscreen.
The game now starts in windowed mode and must be forced to go fullscreen mode through code (I had put that part of code there earlier, but it started working now after I unchecked the "start fullscreen" option).
This results with a flicker when the game is starting up (when the game changes windowed mode to full screen mode).

I'm not sure if it is enough to make any conclusions, but it looks like a GMS2 bug. What to do with it next?
 
Top