Advertisement
hnOsmium0001

JsonUI Example 2

Oct 11th, 2019
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 5.86 KB | None | 0 0
  1. {
  2.   "start": [
  3.     { "window": "Primary" },
  4.     { "window": "WindowDock" }
  5.   ],
  6.   "windows": {
  7.     "Primary": {
  8.       "parent": "default:fixed_window",
  9.       "body": [
  10.         {
  11.           "type": "default:window_root",
  12.           "prop:layoutFunc": {
  13.             "function": "default:flow/vertical"
  14.           },
  15.           "prop:children": [
  16.             {
  17.               "type": "default:button/text",
  18.               "prop:text": "Window 1 - Paragraphs",
  19.               "events": {
  20.                 "onClick": [{
  21.                   "function": "default:add_window",
  22.                   "param:window": "Window1"
  23.                 }]
  24.               }
  25.             },
  26.             {
  27.               "type": "default:button/text",
  28.               "prop:text": "Window 2 - Images",
  29.               "events": {
  30.                 "onClick": [{
  31.                   "function": "default:add_window",
  32.                   "param:window": "Window2"
  33.                 }]
  34.               }
  35.             },
  36.             {
  37.               "type": "default:button/text",
  38.               "prop:text": "Window 3 - Scrolling list",
  39.               "events": {
  40.                 "onClick": [{
  41.                   "function": "default:add_window",
  42.                   "param:window": "Window3"
  43.                 }]
  44.               }
  45.             },
  46.             {
  47.               "type": "default:button/text",
  48.               "prop:text": "Window 4 - Inventory",
  49.               "events": {
  50.                 "onClick": [{
  51.                   "function": "default:add_window",
  52.                   "param:window": "Window4"
  53.                 }]
  54.               }
  55.             }
  56.           ]
  57.         }
  58.       ],
  59.       "properties": {
  60.        "position": ["default:centralize_x", "default:centralize_y"],
  61.        "dimensions": ["C2/3Width", "C3/5Height"]
  62.       }
  63.     },
  64.     "WindowDock": {
  65.       "parent": "default:window_dock",
  66.       "properties": {
  67.         "position": ["default:centralize_x", "default:align_bottom_y"],
  68.         "dimensions": "inherit"
  69.       }
  70.     },
  71.     "Window1": {
  72.       "parent": "default:dockable_window",
  73.       "properties": {
  74.         "position": ["default:centralize_x", "default:align_bottom_y"],
  75.         "dimensions": ["Literal200", "Literal200"],
  76.         "dock": "WindowDock"
  77.       },
  78.       "body": [
  79.         {
  80.           "type": "default:window_root",
  81.           "prop:children": [
  82.             {
  83.               "type": "default:paragraph",
  84.               "prop:lines": [
  85.                 "This is the first line of a paragraph",
  86.                 "Second line",
  87.                 "",
  88.                 "Finishing sentence"
  89.               ],
  90.               "prop:textAlign": "left",
  91.               "prop:dimensions": ["default:100%", "default:100%"]
  92.             }
  93.           ]
  94.         }
  95.       ]
  96.     },
  97.     "Window2": {
  98.       "parent": "default:dockable_window",
  99.       "properties": {
  100.         "position": ["default:centralize_x", "default:align_bottom_y"],
  101.         "dimensions": ["Literal200", "Literal200"],
  102.         "dock": "WindowDock"
  103.       },
  104.       "body": [
  105.         {
  106.           "type": "default:window_root",
  107.           "prop:children": [
  108.             {
  109.               "type": "default:image",
  110.               "prop:resLoc": "jsonuiexample:textures/gui/haha.png"
  111.             }
  112.           ]
  113.         }
  114.       ]
  115.     },
  116.     "Window3": {
  117.       "parent": "default:dockable_window",
  118.       "properties": {
  119.         "position": ["default:centralize_x", "default:align_bottom_y"],
  120.         "dimensions": ["Literal200", "Literal200"],
  121.         "dock": "WindowDock"
  122.       },
  123.       "body": [
  124.         {
  125.           "type": "default:window_root",
  126.           "prop:children": [
  127.             {
  128.               "type": "default:list_view",
  129.               "prop:id": "ScrollingList",
  130.               "prop:width": "default:100%",
  131.               "prop:height": "default:100%",
  132.               "prop:scrollBarPos": "inside",
  133.               "prop:scrollBarStyle": "vanilla",
  134.               "prop:children": [
  135.               ],
  136.               // Add elements using function, avoid copying the same line 64 times
  137.               "events": {
  138.                 "onCreated": [{
  139.                   "function": "default:repeat",
  140.                   "param:times": 64,
  141.                   "param:execute": {
  142.                     "function": "default:add_child_to",
  143.                     "param:target": ["Window3", "ScrollingList"],
  144.                     "param:childVal": {
  145.                       "function": "default:create_widget",
  146.                       "param:type": "default:text_label",
  147.                       "param:props": {
  148.                         "prop:text": "Entry"
  149.                       }
  150.                     }
  151.                   }
  152.                 }]
  153.               }
  154.             }
  155.           ]
  156.         }
  157.       ]
  158.     },
  159.     "Window4": {
  160.       "parent": "default:dockable_window",
  161.       "properties": {
  162.         "position": ["default:centralize_x", "default:align_bottom_y"],
  163.         "dimensions": ["Literal200", "Literal200"],
  164.         "dock": "WindowDock"
  165.       },
  166.       "body": [
  167.         {
  168.           "type": "default:window_root",
  169.           "prop:children": [
  170.             {
  171.               "type": "default:inventory_panel",
  172.               "prop:inventory": { "function": "default:player_inventory" },
  173.               "prop:setup": [
  174.                 { "width": 9, "height": 3 },
  175.                 { "margin-vertical": 20 },
  176.                 { "width": 9, "height": 1}
  177.               ]
  178.             }
  179.           ]
  180.         }
  181.       ]
  182.     }
  183.   },
  184.   "functions": {
  185.     "C2/3Width": {
  186.       "function": "default:calculate",
  187.       "param:expr": ["*", "$SCREEN_WIDTH", ["/", 2, 3]],
  188.       "param:return": "int"
  189.     },
  190.     "C3/5Height": {
  191.       "function": "default:calculate",
  192.       "param:expr": ["*", "$SCREEN_HEIGHT", ["/", 3, 5]],
  193.       "param:return": "int"
  194.     },
  195.     "Literal200": {
  196.       "function": "default:literal",
  197.       "param:val": 200
  198.     }
  199.   }
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement