Browse Source

almost finished support of new json formatting fo menus

merge-overlays-and-menus-with-optional-refactor
Pixdigit 6 years ago
parent
commit
22171323dd
  1. 8
      assets/templates/load.json
  2. 10
      assets/templates/pause.json
  3. 50
      assets/templates/world.json
  4. 6
      libs/menu/creator.py
  5. 2
      rm_unused.sh

8
assets/templates/load.json

@ -7,7 +7,7 @@
{
"box": "$box1",
"color": "$color",
"label": "Return",
"content": "Return",
"name": "return",
"position": {
"from": "TopLeft",
@ -26,7 +26,7 @@
{
"box": "$box1",
"color": "$color",
"label": "Previous",
"content": "Previous",
"name": "previous",
"position": {
"from": "TopLeft",
@ -45,7 +45,7 @@
{
"box": "$box1",
"color": "$color",
"label": "Load",
"content": "Load",
"name": "load",
"position": {
"from": "TopLeft",
@ -64,7 +64,7 @@
{
"box": "$box1",
"color": "$color",
"label": "Next",
"content": "Next",
"name": "next",
"position": {
"from": "TopLeft",

10
assets/templates/pause.json

@ -7,7 +7,7 @@
{
"box": "$box1",
"color": "$color",
"label": "Continue",
"content": "Continue",
"name": "continue",
"position": {
"from": "TopLeft",
@ -26,7 +26,7 @@
{
"box": "$box1",
"color": "$color",
"label": "Save Game",
"content": "Save Game",
"name": "save",
"position": {
"from": "BottomLeft",
@ -45,7 +45,7 @@
{
"box": "$box1",
"color": "$color",
"label": "Load Game",
"content": "Load Game",
"name": "load",
"position": {
"from": "BottomLeft",
@ -64,7 +64,7 @@
{
"box": "$box1",
"color": "$color",
"label": "Settings",
"content": "Settings",
"name": "settings",
"position": {
"from": "BottomLeft",
@ -83,7 +83,7 @@
{
"box": "$box1",
"color": "$color",
"label": "Exit",
"content": "Exit",
"name": "exit",
"position": {
"from": "BottomLeft",

50
assets/templates/world.json

@ -7,48 +7,42 @@
{
"box": "$box1",
"color": "$color",
"label": "Warp",
"content": "Warp",
"font_conf": "$standard_font",
"name": "warp",
"position": {
"from": "TopLeft",
"pos_rel_obj": "master_screen",
"to": "TopLeft",
"to": "TopMid",
"x_abs": 0,
"x_rel": "$half",
"y_abs": -20,
"y_rel": "$half",
"layer": 1
},
"size": "$size",
"typeface": "$typeface",
"width_to_hight_ratio": 8
},
{
"box": "$box1",
"color": "$color",
"label": "Return",
"content": "Return",
"font_conf": "$standard_font",
"name": "return",
"position": {
"from": "TopLeft",
"pos_rel_obj": "master_screen",
"to": "TopLeft",
"to": "TopMid",
"x_abs": 0,
"x_rel": "$half",
"y_abs": 20,
"y_rel": "$half",
"layer": 1
},
"size": "$size",
"typeface": "$typeface",
"width_to_hight_ratio": 8
}
],
"images": [
},
{
"box": "$box1",
"image": "$image1",
"klickable": true,
"label": "",
"content": "$image1",
"name": "world1",
"position": {
"from": "TopLeft",
@ -63,9 +57,7 @@
},
{
"box": "$box1",
"image": "$image2",
"klickable": true,
"label": "",
"content": "$image2",
"name": "world2",
"position": {
"from": "TopLeft",
@ -80,9 +72,7 @@
},
{
"box": "$box1",
"image": "$image3",
"klickable": true,
"label": "",
"content": "$image3",
"name": "world3",
"position": {
"from": "TopLeft",
@ -97,9 +87,7 @@
},
{
"box": "$box1",
"image": "$image4",
"klickable": true,
"label": "",
"content": "$image4",
"name": "world4",
"position": {
"from": "TopLeft",
@ -114,9 +102,7 @@
},
{
"box": "$box1",
"image": "$image5",
"klickable": true,
"label": "",
"content": "$image5",
"name": "world5",
"position": {
"from": "TopLeft",
@ -131,9 +117,7 @@
},
{
"box": "$box1",
"image": "$image6",
"klickable": true,
"label": "",
"content": "$image6",
"name": "world6",
"position": {
"from": "TopLeft",
@ -148,9 +132,7 @@
},
{
"box": "$box1",
"image": "$image7",
"klickable": true,
"label": "",
"content": "$image7",
"name": "world7",
"position": {
"from": "TopLeft",
@ -165,9 +147,7 @@
},
{
"box": "$box1",
"image": "$image8",
"klickable": true,
"label": "",
"content": "$image8",
"name": "world8",
"position": {
"from": "TopLeft",

6
libs/menu/creator.py

@ -281,16 +281,18 @@ class create_menu():
name = get_data(button_data, "name", str)
content = get_data(button_data, "content", str, default="")
box = get_data(button_data, "box", list)
ratio = get_data(button_data, "width_to_hight_ratio", float)
ratio = get_data(button_data, "width_to_hight_ratio", float, default=1)
pos_data = get_data(button_data, "position", dict, default=default_pos)
layer = pos_data["layer"]
if os.path.isfile(content):
if type(content) in [str, unicode] and os.path.isfile(content):
try:
content = pygame.image.load(content).convert()
except pygame.error:
print(("Could not load image file: " + content))
print(("Using filename as text.\n"))
elif type(content) == pygame.Surface:
content = content.convert()
else:
font_conf = get_data(button_data, "font_conf", default=default_font)

2
rm_unused.sh

@ -1,2 +1,2 @@
find . \( -name '*.pyo' -or -name '*.pyc' -or -name '*~' \) -delete
rm ./userdata/*
rm ./userdata/user_settings.json
Loading…
Cancel
Save