Fixed visual glitch
This commit is contained in:
parent
aa53dd4b30
commit
5eacd1a630
|
@ -7,7 +7,7 @@ It contains the definition of routes and views for the application.
|
||||||
import mysql.connector
|
import mysql.connector
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from item import Item, production_names, to_json
|
from item import Item, production_names, to_json, units
|
||||||
from flask import Flask, render_template, request, session
|
from flask import Flask, render_template, request, session
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@ -31,7 +31,11 @@ def make_tree_view(item):
|
||||||
output += "<input type='submit' value='<' />"
|
output += "<input type='submit' value='<' />"
|
||||||
output += "</form>"
|
output += "</form>"
|
||||||
|
|
||||||
output += f"{item.amount} {item.name}"
|
unit = item.made_in
|
||||||
|
if unit not in units:
|
||||||
|
unit = "default"
|
||||||
|
|
||||||
|
output += units[unit].format(item.name, item.amount)
|
||||||
|
|
||||||
if needs_form:
|
if needs_form:
|
||||||
output += "<form method='POST' class='right'>"
|
output += "<form method='POST' class='right'>"
|
||||||
|
@ -42,7 +46,7 @@ def make_tree_view(item):
|
||||||
|
|
||||||
output += "</span>"
|
output += "</span>"
|
||||||
|
|
||||||
if item.made_in != "natural":
|
if item.made_in in production_names:
|
||||||
output += "<ul><li><code>"
|
output += "<ul><li><code>"
|
||||||
if production_names.get(item.made_in) != None:
|
if production_names.get(item.made_in) != None:
|
||||||
output += f"{production_names[item.made_in]}"
|
output += f"{production_names[item.made_in]}"
|
||||||
|
@ -53,7 +57,8 @@ def make_tree_view(item):
|
||||||
output += " can be found naturally."
|
output += " can be found naturally."
|
||||||
|
|
||||||
output += item.get_formatted()
|
output += item.get_formatted()
|
||||||
if item.made_in != "natural":
|
print(item.get_formatted())
|
||||||
|
if item.made_in in production_names:
|
||||||
output += "</li></ul>"
|
output += "</li></ul>"
|
||||||
output += "</li></ul>"
|
output += "</li></ul>"
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,16 @@ import mysql.connector
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
units = {
|
||||||
|
"default" : "{0} x{1}",
|
||||||
|
"fluid" : "{0} {1}mB"
|
||||||
|
}
|
||||||
|
|
||||||
production_names = {
|
production_names = {
|
||||||
"craftingtable" : "Crafting",
|
"craftingtable" : "Crafting",
|
||||||
"furnace" : "Smelting",
|
"furnace" : "Smelting",
|
||||||
"stonecutter" : "Stonecutting"
|
"filling" : "Filling",
|
||||||
|
"brewingstation" : "Brewing"
|
||||||
}
|
}
|
||||||
|
|
||||||
class Item(object):
|
class Item(object):
|
||||||
|
@ -85,7 +91,7 @@ class Item(object):
|
||||||
recipe = self.possibilities[self.choice]
|
recipe = self.possibilities[self.choice]
|
||||||
self.made_in = recipe["via"]
|
self.made_in = recipe["via"]
|
||||||
self.components = []
|
self.components = []
|
||||||
if self.made_in == "natural":
|
if self.made_in not in production_names:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.creates = recipe["amount"]
|
self.creates = recipe["amount"]
|
||||||
|
@ -111,7 +117,11 @@ class Item(object):
|
||||||
output += "<input type='submit' value='<' />"
|
output += "<input type='submit' value='<' />"
|
||||||
output += "</form>"
|
output += "</form>"
|
||||||
|
|
||||||
output += f"{component.amount} {component.name}"
|
unit = component.made_in
|
||||||
|
if component.made_in not in units:
|
||||||
|
unit = "default"
|
||||||
|
|
||||||
|
output += units[unit].format(component.name, component.amount)
|
||||||
|
|
||||||
if needs_form:
|
if needs_form:
|
||||||
output += "<form method='POST' class='right'>"
|
output += "<form method='POST' class='right'>"
|
||||||
|
@ -121,16 +131,16 @@ class Item(object):
|
||||||
output += "</form>"
|
output += "</form>"
|
||||||
output += "</span>"
|
output += "</span>"
|
||||||
|
|
||||||
if component.made_in != "natural":
|
if component.made_in in production_names:
|
||||||
output += "<ul><li><code>"
|
output += "<ul><li><code>"
|
||||||
if production_names.get(component.made_in) != None:
|
if component.made_in in production_names:
|
||||||
output += f"{production_names[component.made_in]}"
|
output += f"{production_names[component.made_in]}"
|
||||||
else:
|
else:
|
||||||
output += "???"
|
output += "???"
|
||||||
output += "</code>"
|
output += "</code>"
|
||||||
|
|
||||||
output += component.get_formatted()
|
output += component.get_formatted()
|
||||||
if component.made_in != "natural":
|
if component.made_in in production_names:
|
||||||
output += "</li></ul>"
|
output += "</li></ul>"
|
||||||
output += "</li>"
|
output += "</li>"
|
||||||
output += "</ul>"
|
output += "</ul>"
|
||||||
|
|
Loading…
Reference in a new issue