kwabs22 commited on
Commit
edefa8c
·
1 Parent(s): f658ac0

Refactor Proto Assist accordion to absorb mess

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -346,20 +346,22 @@ def show_elements_json_input(json_input):
346
  # New developernotes field
347
  developernotes = gr.Textbox(label="developernotes", value=json.dumps(details.get('developernotes', [])), interactive=True)
348
  outputs.append(developernotes)
 
 
 
349
 
350
- print(outputs)
351
  def update_json(*current_values):
352
  updated_data = {"masterlocation1": {}}
353
  locations = [loc for loc in masterlocation1.keys() if loc != 'end']
354
  print(locations)
355
  for i, location in enumerate(locations):
356
  updated_data["masterlocation1"][location] = {
357
- "description": current_values[i*6],
358
- "events": json.loads(current_values[i*6 + 1]),
359
- "choices": json.loads(current_values[i*6 + 2]),
360
- "transitions": json.loads(current_values[i*6 + 3]),
361
- "media": json.loads(current_values[i*6 + 4]), # New media field
362
- "developernotes": json.loads(current_values[i*6 + 5])
363
  }
364
  updated_data["masterlocation1"]["end"] = masterlocation1["end"]
365
  return json.dumps(updated_data, indent=2)
@@ -1001,7 +1003,7 @@ Creating more diverse paths through the game""")
1001
  gr.HTML("Placeholder for clearing uploaded assets (public space and temporary persistence = sharing and space problems)")
1002
  with gr.Accordion("My Previous Quick Config Attempts", open=False):
1003
  for experimetal_config_name, experimetal_config in ExampleGameConfigs.items():
1004
- gr.Code(str(experimetal_config), label=experimetal_config_name)
1005
 
1006
  with gr.Tab("Test and Edit Config"):
1007
  gr.HTML("The main issue is frequent changes add more chances for bugs in how - manual and auto refer mainly to ensuring correct JSON format ")
 
346
  # New developernotes field
347
  developernotes = gr.Textbox(label="developernotes", value=json.dumps(details.get('developernotes', [])), interactive=True)
348
  outputs.append(developernotes)
349
+
350
+ #adding/removing a field means incrementing/decreasing the i+n to match the fields
351
+ num_current_unique_fields = 6
352
 
 
353
  def update_json(*current_values):
354
  updated_data = {"masterlocation1": {}}
355
  locations = [loc for loc in masterlocation1.keys() if loc != 'end']
356
  print(locations)
357
  for i, location in enumerate(locations):
358
  updated_data["masterlocation1"][location] = {
359
+ "description": current_values[i*num_current_unique_fields],
360
+ "events": json.loads(current_values[i*num_current_unique_fields + 1]),
361
+ "choices": json.loads(current_values[i*num_current_unique_fields + 2]),
362
+ "transitions": json.loads(current_values[i*num_current_unique_fields + 3]),
363
+ "media": json.loads(current_values[i*num_current_unique_fields + 4]), # New media field
364
+ "developernotes": json.loads(current_values[i*num_current_unique_fields + 5])
365
  }
366
  updated_data["masterlocation1"]["end"] = masterlocation1["end"]
367
  return json.dumps(updated_data, indent=2)
 
1003
  gr.HTML("Placeholder for clearing uploaded assets (public space and temporary persistence = sharing and space problems)")
1004
  with gr.Accordion("My Previous Quick Config Attempts", open=False):
1005
  for experimetal_config_name, experimetal_config in ExampleGameConfigs.items():
1006
+ gr.Code(json.dumps(experimetal_config, default=lambda o: o.__dict__, indent=2), label=experimetal_config_name) #str(experimetal_config)
1007
 
1008
  with gr.Tab("Test and Edit Config"):
1009
  gr.HTML("The main issue is frequent changes add more chances for bugs in how - manual and auto refer mainly to ensuring correct JSON format ")