Game settings / launcher


(Cotaks) #1

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:


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)


[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:


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)


Blend:
game_laucher.blend (679 KB)

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

Have fun with it,
Cotax


Cotaks resources
(Cotaks) #2

Fixed a very tiny/small/noobie mistake/bug in the load settings script at #1 post.

Changed

parser.read(logic.expandPath('//settings/') + "settings.ini")

Into

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. :wink:


(Asdfghjkl) #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.


(Cotaks) #4

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.


(Noé Araújo) #5

Perfect, good job man!


(alf0) #6

this is nice work man


(joelgomes1994) #7

Nice work!
I’m developing a launcher and configuration utility for BGE as well, but it runs as standalone (coded entirely in Python) and runs blenderplayer through command line, with the desired settings. It supports custom icon (on Windows), splash screen and most of the video settings on BGE. The user don’t need to configure the game to suport the launcher, only need to configure the launcher to run the game. But I didn’t released it (in this forum), as I think it should be a bit more mature for use. It’s available to download on Github, though.
See how it works at:


(Cotaks) #8

Perfect, good job man!

this is nice work man

Nice work!

Thanks!

I’m developing a launcher and configuration utility for BGE as well, but it runs as standalone (coded entirely in Python) and runs blenderplayer through command line, with the desired settings. It supports custom icon (on Windows), splash screen and most of the video settings on BGE. The user don’t need to configure the game to suport the launcher, only need to configure the launcher to run the game. But I didn’t released it (in this forum), as I think it should be a bit more mature for use. It’s available to download on Github, though.
See how it works at:

  1. great to so more people creating launchers.
  2. why in python? and not in C? if you make a standalone you should have made it in C.
  3. ‘The user don’t need to configure the game to suport the launcher, only need to configure the launcher to run the game’ so how does blender load the settings, if you only adjust the launcher, blender needs to get the data someway.
  4. why promote your stuff in my topic?, make your own.

(joelgomes1994) #9
  1. I do use Pyinstaller, which freezes Python scripts and Python binaries into a executable.
  2. As I said, it runs blenderplayer through command line… Run in the command line “blenderplayer -h” and you’ll see command line arguments to use (e.g: “blenderplayer.exe -w 800 600 blendfile.blend” will run blendfile.blend in blenderplayer in windowed mode in 800x600).
  3. I’m sorry, I didn’t wanted to promote my project, only show it to you… As I said, my project isn’t in a mature state, so I didn’t made any official annoucement. If you want, I can delete my post, only ask me.

(ThePajlok) #10

I wanna make turn on and turn off this option in your launcher but how?



(Cotaks) #11

I’m sorry, I didn’t wanted to promote my project, only show it to you… As I said, my project isn’t in a mature state, so I didn’t made any official annoucement. If you want, I can delete my post, only ask me.

Not needed i’m not tat bad haha, it’s about " It’s available to download on Github, though." makes it a promotion, i don’t care if people use yours or mine, i really don’t. But i just don’t like people to promote their own stuff in an other persons topic without asking.

Run in the command line

Ah sorry, my bad, didn’t pay enough attention xD

I wanna make turn on and turn off this option in your launcher but how?

You need to point me into the right direction, seems i cant find that option.


(ThePajlok) #12

This option is in Texture tap in UPBGE when you select “Environment Map” then “Realtime” and as in my screenshot :wink:


(Cotaks) #13

Sorry, i am not giving support to UPbge, simply because i don’t work with it, but you should be able to mouse over it and read out it’s python command, or make a new thread for it.


(ThePajlok) #14

Okay, thanks!


(gibran) #15

Thanks for quick support
yahoo mail login


(gibran) #16

Perfect, good job man!