123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 |
- # THIS IS A SOURCE CODE FILE FROM I'M NOT EVEN HUMAN THE GAME.
- # IT COULD BE USED IN A DIFFERENT PIECE OF SOFTWARE ( LIKE A
- # DIFFERENT GAME ), BUT IT WAS ORIGINALLY WRITTEN FOR I'M NOT
- # EVEN HUMAN THE GAME.
- # THE DEVELOPERS OF THE GAME ARE : (C) J.Y.AMIHUD, AYYZEE AND
- # OTHER CONTRIBUTORS. THIS AND OTHER FILES IN THIS GAME,
- # UNLESS SPECIFICALLY NOTED, COULD BE USED UNDER THE TERMS OF
- # GNU GENERAL PUBLIC LICENSE VERSION 3 OR ANY LATER VERSION.
- import os
- import json
- # GTK module ( Graphical interface
- import gi
- gi.require_version('Gtk', '3.0')
- from gi.repository import Gtk
- import cairo
- from modules import ui
- def layer(game):
- # Setting up a cairo layer
- surface = cairo.ImageSurface(cairo.FORMAT_ARGB32,
- game.current['w'],
- game.current['h'])
- layer = cairo.Context(surface)
- layer.set_antialias(cairo.ANTIALIAS_NONE)
-
- ui.color(game, layer, "#FFFFFF")
- ui.text(game, layer, "Settings",
- int(game.current["w"]/2), 5,
- align="center")
- def do():
- game.scene = "main_menu"
-
- ui.button(game, layer,
- 5,
- 5 ,
- int(game.current["w"] / 3 ) - 30 ,
- 13,
- menu="settings",
- string="< Back",
- func=do)
- # Setting up the scroller
- if "settings" not in game.scroll:
- game.scroll["settings"] = 0
- current_Y = 0
- layer.rectangle(4,20,
- game.current["w"]-10,
- game.current["h"]-25)
- layer.clip()
- <<<<<<< HEAD
- =======
- <<<<<<< HEAD
- >>>>>>> 4f59bf84d5c1dc67fcc03c78488f20af217ceab7
- # WORLD
- if "settings_world_active" not in game.current:
- game.current["settings_world_active"] = False
- wicon = "right"
- if game.current["settings_world_active"]:
- wicon = "down"
-
- def do():
- game.current["settings_world_active"] = not game.current["settings_world_active"]
- game.menus = {}
- <<<<<<< HEAD
- =======
- =======
- # World
- def do():
- print("world")
- >>>>>>> 4cee21d (made game red)
- >>>>>>> 4f59bf84d5c1dc67fcc03c78488f20af217ceab7
-
- ui.button(game, layer,
- 5,
- current_Y+25,
- int(game.current["w"]) - 11 ,
- 13,
- menu="settings",
- scroll="settings",
- <<<<<<< HEAD
- icon=wicon,
- string="World: "+game.worlds[game.settings["world"]]["title"],
- func=do)
- current_Y += 15
- # List of worlds
- if game.current["settings_world_active"]:
- for world in game.worlds:
- def do():
- game.settings["world"] = world
- game.current["settings_world_active"] = False
- game.menus = {}
- save_settings(game)
- wicon = "radio_false"
- if game.settings["world"] == world:
- wicon = "radio_true"
-
- ui.button(game, layer,
- 15,
- current_Y+25,
- int(game.current["w"]) - 36 ,
- 13,
- menu="settings",
- scroll="settings",
- icon=wicon,
- string=str(game.worlds[world]["title"]),
- =======
- <<<<<<< HEAD
- icon=wicon,
- =======
- >>>>>>> 4cee21d (made game red)
- string="World: I'm Not Even Human",
- func=do)
- current_Y += 15
- <<<<<<< HEAD
- # List of worlds
- if game.current["settings_world_active"]:
- for world in os.listdir(os.getcwd()+"/assets/worlds"):
- def do():
- print(world)
-
- ui.button(game, layer,
- 15,
- current_Y+25,
- int(game.current["w"]) - 37 ,
- 13,
- menu="settings",
- scroll="settings",
- icon="radio_false",
- string=str(world),
- >>>>>>> 4f59bf84d5c1dc67fcc03c78488f20af217ceab7
- func=do)
- # Editor
- def do():
- <<<<<<< HEAD
- game.settings["world"] = world
- game.current["settings_world_active"] = False
- game.menus = {}
- save_settings(game)
- game.scene = "editor"
- =======
- print("edit")
- >>>>>>> 4f59bf84d5c1dc67fcc03c78488f20af217ceab7
-
- ui.button(game, layer,
- game.current["w"]-19,
- current_Y+25,
- 13,
- 13,
- menu="settings",
- scroll="settings",
- icon="edit",
- func=do)
-
- current_Y += 15
- <<<<<<< HEAD
-
- # PIXELS PER PIXEL
-
- =======
- =======
- # Pixels Per Pixels
- ui.color(game, layer, "#FF0000")
- ui.text(game, layer, "Pixels size: ",
- 5,
- current_Y+28+game.scroll["settings"])
- def do():
- game.settings["pixels"] += 1
-
- ui.button(game, layer,
- game.current["w"]-75,
- current_Y+25,
- 13,
- 13,
- menu="settings",
- scroll="settings",
- string="+",
- func=do)
- ui.color(game, layer, "#FF0000")
- ui.text(game, layer, str(game.settings["pixels"]),
- game.current["w"]-50,
- current_Y+28+game.scroll["settings"])
-
- def do():
- game.settings["pixels"] -= 1
- if game.settings["pixels"] < 1:
- game.settings["pixels"] = 1
-
- ui.button(game, layer,
- game.current["w"]-19,
- current_Y+25,
- 13,
- 13,
- menu="settings",
- scroll="settings",
- string="-",
- func=do)
-
- current_Y += 15
- >>>>>>> 4cee21d (made game red)
-
- # PIXELS PER PIXEL
-
- >>>>>>> 4f59bf84d5c1dc67fcc03c78488f20af217ceab7
- ui.color(game, layer, "#00FF00")
- ui.text(game, layer, "Pixels size: ",
- 5,
- current_Y+28+game.scroll["settings"])
- def do():
- game.settings["pixels"] += 1
- <<<<<<< HEAD
- save_settings(game)
- =======
- >>>>>>> 4f59bf84d5c1dc67fcc03c78488f20af217ceab7
-
- ui.button(game, layer,
- game.current["w"]-75,
- current_Y+25,
- 13,
- 13,
- menu="settings",
- scroll="settings",
- string="+",
- func=do)
- ui.color(game, layer, "#00FF00")
- ui.text(game, layer, str(game.settings["pixels"]),
- game.current["w"]-50,
- current_Y+28+game.scroll["settings"])
-
- def do():
- game.settings["pixels"] -= 1
- if game.settings["pixels"] < 1:
- game.settings["pixels"] = 1
- <<<<<<< HEAD
- save_settings(game)
- =======
- >>>>>>> 4f59bf84d5c1dc67fcc03c78488f20af217ceab7
-
- ui.button(game, layer,
- game.current["w"]-19,
- current_Y+25,
- 13,
- 13,
- menu="settings",
- scroll="settings",
- string="-",
- func=do)
-
- current_Y += 15
- # FULLSCREEN
-
- ficon = "fullscreen"
- if game.settings["fullscreen"]:
- ficon = "unfullscreen"
-
- def do():
- game.settings["fullscreen"] = not game.settings["fullscreen"]
- <<<<<<< HEAD
- save_settings(game)
- =======
- >>>>>>> 4f59bf84d5c1dc67fcc03c78488f20af217ceab7
-
- ui.button(game, layer,
- 5,
- current_Y+25,
- <<<<<<< HEAD
- int(game.current["w"]/2) - 5,
- =======
- int(game.current["w"]/2) - 10,
- >>>>>>> 4f59bf84d5c1dc67fcc03c78488f20af217ceab7
- 13,
- menu="settings",
- scroll="settings",
- icon=ficon,
- string="Fullscreen",
- func=do)
- # TESTING MODE
- dicon = "false"
- if game.current["testing"]:
- dicon = "true"
-
- def do():
- game.current["testing"] = not game.current["testing"]
-
- ui.button(game, layer,
- <<<<<<< HEAD
- int(game.current["w"]/2) + 2,
- current_Y+25,
- int(game.current["w"]/2) - 8,
- =======
- int(game.current["w"]/2) + 4,
- current_Y+25,
- int(game.current["w"]/2) - 10,
- >>>>>>> 4f59bf84d5c1dc67fcc03c78488f20af217ceab7
- 13,
- menu="settings",
- scroll="settings",
- icon=dicon,
- string="Debug Mode",
- func=do)
-
- current_Y += 15
-
-
- ui.scroll_area(game, layer, "settings", 5,20,
- game.current["w"]-10,
- game.current["h"]-25,
- current_Y)
- # Navigating the menus
- ui.button_navigate(game, "settings")
-
-
- return surface
- def update_worlds(game):
- """This function updates the selection of playable worlds."""
- game.worlds = {}
- for world in os.listdir(os.getcwd()+"/assets/worlds"):
- try:
- with open("assets/worlds/"+world+"/world.json") as f:
- metadata = json.load(f)
- except:
- metadata = {"title":world}
- game.worlds[world] = metadata
- def get_settings_folder(folder="ineh/"):
- try:
- data_dir = os.environ["XDG_DATA_HOME"] + "/" + folder
- except:
- data_dir = os.path.expanduser("~/.local/share/"+folder)
- try:
- os.makedirs(data_dir)
- except:
- pass
- return data_dir
-
- def save_settings(game):
- """This function saves the settings"""
- with open(get_settings_folder()+"config.json", 'w') as f:
- json.dump(game.settings, f, indent=4, sort_keys=True)
- def load_settings(game):
- """This function loads settings, or creates the settings
- from defautls"""
- defaults = {
- "pixels":4, # How big are pixels on the screen
- "fullscreen":False, # Whether the games is fullscreen
- "world":"ImNotEvenHuman"} # What wold you are playing
- try:
- with open(get_settings_folder()+"config.json") as f:
- game.settings = json.load(f)
- except:
- game.settings = defaults
-
|