Results 1 to 4 of 4
  1. #1
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,235

    Game settings / launcher

    Hello,


    I have been creating a game launcher with settings that saves into an .ini setup.
    this version has check-boxes and lists to skip through.

    It wil save the settings, and load them as well, but it does not apply the settings, you need to make that in your game blend yourself (example in the screenshot and an adjusted script below).

    If i did not forget anything, "everything" is explained in the script.
    (It is python based, meaning python handles the buttons, etc)

    And here is a video to see it in action:


    preview.png

    settings file:
    make a text file and copy/paste these settings into it, and save it as settings.ini at the same location as the blend file
    (forum don't let me upload .ini files, Keep the settings as is, change it through the launcher)

    Code:
    [graphics]
    difficulty = Normal
    mipmap = 2
    af = 16
    lights = 10
    resolution = 1920x1200
    fullscreen = True
    vsync = False
    
    
    [filters]
    bloom = True
    dof = False
    fxaa = True
    ssao = False
    
    
    [launcher]
    difficulty_index = 1
    mipmap_index = 2
    af_index = 4
    lights_index = 9
    resolution_index = 20
    Load and set the settings in your game blend:
    Code:
    from configparser import ConfigParser
    from bge import logic, render
    
    
    def set_settings(cont):
        
        own = cont.owner
        
        parser = ConfigParser()
        parser.read(logic.expandPath('//') + "settings.ini")
        
        render.showMouse(False)  
        
        for section in parser:
            
            if section == 'graphics':
                
                
                render.setAnisotropicFiltering(parser.getint(secti  on, 'af'))
                render.setMipmapping(parser.getint(section, 'mipmap'))
                render.setFullScreen(parser.getboolean(section, 'fullscreen'))
                
                reso = parser.get(section, 'resolution').split('x')
                render.setWindowSize(int(reso[0]), int(reso[1]))
                                
                if parser.getboolean(section, 'vsync') == True:
                    render.VSYNC_ON
                else:
                    render.VSYNC_OFF 
                  
            elif section == 'filters':
                
                for filter in parser[section]:   
                    own[filter] = parser.getboolean(section, filter)
    Here is my working example on how to load the settings (only the open bricks and properties are needed)
    load_settings.png


    Blend:
    game_laucher.blend

    * Filters are not included, look in the resource section of the forum, lots of filters there *

    Have fun with it,
    Cotax
    Last edited by Cotaks; 20-May-17 at 07:29.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  2. #2
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,235
    Fixed a very tiny/small/noobie mistake/bug in the load settings script at #1 post.

    Changed
    Code:
    parser.read(logic.expandPath('//settings/') + "settings.ini")
    Into
    Code:
    parser.read(logic.expandPath('//') + "settings.ini")
    As i stated in #1 post, you should place the script in the same folder as the .blend file, but that would never work due to the script was looking for the settings a directory deeper.

    Sorry just noticed it, and you guys didn't complain so... it should be fine.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



  3. #3
    Hello Cotaks. You know me already from previus posts. My problem here is that I cant load the settings.ini in the game. I can change the settings and save them in the settings file. ini but I dont know how to load the file in the game.



  4. #4
    Member Cotaks's Avatar
    Join Date
    May 2012
    Location
    The Netherlands
    Posts
    1,235
    Originally Posted by Asdfghjkl View Post
    Hello Cotaks. You know me already from previus posts. My problem here is that I cant load the settings.ini in the game. I can change the settings and save them in the settings file. ini but I dont know how to load the file in the game.
    Create an empty in the blend where you want to load the settings.
    if you use filters, put a property for each filter on the empty (boolean).
    connect a property brick (if equal to the right property) - and - add custom filter, for each filter you use.

    now you have set the filters.

    now add always - python, connect it to the script (only have to run once)
    now you loading the settings.

    that's all there is to do to load the settings.

    #edit
    Added a screenshot with the right setup to load the settings.

    have fun with it.
    Last edited by Cotaks; 20-May-17 at 07:28.
    '- It's not working' then check your console like: this
    Did you know that you can make a complete game with the .blends that i share?



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •