diff --git a/SuperScriptViewer/DecoratorCore.py b/SuperScriptViewer/DecoratorCore.py index c4c27f7..24ddda8 100644 --- a/SuperScriptViewer/DecoratorCore.py +++ b/SuperScriptViewer/DecoratorCore.py @@ -44,7 +44,7 @@ def run(): def initDecorateDb(db): cur = db.cursor() cur.execute("CREATE TABLE graph([graph] INTEGER, [graph_name] TEXT, [width] INTEGER, [height] INTEGER, [index] INTEGER, [belong_to] TEXT);") - cur.execute("CREATE TABLE info([target] INTEGER, [attach_bb] INTEGER, [is_setting] INTEGER, [field] TEXT, [data] TEXT);") + cur.execute("CREATE TABLE info([target] INTEGER, [attach_bb] INTEGER, [is_setting] INTEGER, [name] TEXT, [field] TEXT, [data] TEXT);") cur.execute("CREATE TABLE block([belong_to_graph] INETGER, [thisobj] INTEGER, [name] TEXT, [assist_text] TEXT, [pin-ptarget] TEXT, [pin-pin] TEXT, [pin-pout] TEXT, [pin-bin] TEXT, [pin-bout] TEXT, [x] REAL, [y] REAL, [width] REAL, [height] REAL, [expandable] INTEGER);") cur.execute("CREATE TABLE cell([belong_to_graph] INETGER, [thisobj] INTEGER, [name] TEXT, [assist_text] TEXT, [x] REAL, [y] REAL, [type] INTEGER);") @@ -673,33 +673,38 @@ def buildInfo(exDb, deDb): # declare tiny storage for convenient query tinyStorageKey = 0 - tineStorageBB = 0 - tineStorageSetting = 0 + tinyStorageBB = -1 + tinyStorageSetting = 0 + tinyStorageName = "" # export local data (including proto bb internal data) exInfoCur.execute("SELECT * FROM pData;") for i in exInfoCur.fetchall(): - attachBB = 0 + attachBB = -1 isSetting = 0 + infoName = "" if i[2] == tinyStorageKey: - attachBB = tineStorageBB - isSetting = tineStorageSetting + attachBB = tinyStorageBB + isSetting = tinyStorageSetting + infotName = tinyStorageName else: # clear storage first - tineStorageBB = 0 - tineStorageSetting = 0 + tinyStorageBB = -1 + tinyStorageSetting = 0 + tinyStorageName = "" # query correspond pLocal - exQueryCur.execute("SELECT [belong_to], [is_setting] FROM pLocal WHERE [thisobj] = ?", (i[2], )) + exQueryCur.execute("SELECT [belong_to], [is_setting], [name] FROM pLocal WHERE [thisobj] = ?", (i[2], )) plocalCache = exQueryCur.fetchone() if plocalCache is not None: # add setting config - tineStorageSetting = isSetting = plocalCache[1] + tinyStorageSetting = isSetting = plocalCache[1] + tinyStorageName = infoName = plocalCache[2] # query bb again - exQueryCur.execute("SELECT [thisobj] FROM behavior WHERE ( [thisobj] = ? AND [type] = 0)", (plocalCache[0], )) + exQueryCur.execute("SELECT [thisobj] FROM behavior WHERE ([thisobj] = ? AND [type] = 0)", (plocalCache[0], )) behaviorCache = exQueryCur.fetchone() if behaviorCache is not None: - tineStorageBB = attachBB = behaviorCache[0] + tinyStorageBB = attachBB = behaviorCache[0] - deCur.execute("INSERT INTO info VALUES (?, ?, ?, ?, ?)", (i[2], attachBB, isSetting, i[0], i[1])) \ No newline at end of file + deCur.execute("INSERT INTO info VALUES (?, ?, ?, ?, ?, ?)", (i[2], attachBB, isSetting, infoName, i[0], i[1])) \ No newline at end of file diff --git a/SuperScriptViewer/ServerCore.py b/SuperScriptViewer/ServerCore.py index 997ff70..b5e3a95 100644 --- a/SuperScriptViewer/ServerCore.py +++ b/SuperScriptViewer/ServerCore.py @@ -192,18 +192,36 @@ def viewerHandle(scriptPath): def actionHandle(scriptPath): cache = request.form['operation'] if cache == "info": - return infoHandle(request.form['target']) + return infoHandle(request.form['target'], request.form['tag']) elif cache == "move": return moveHandle(request.form['target']) else: abort(400) -def infoHandle(target): +def infoHandle(target, tag): cur = get_db().cursor() - cur.execute("SELECT [field], [data] FROM info WHERE [target] == ?", (target, )) + data = {} + existedSet = set() + if tag == 0: + # call from cell + cur.execute("SELECT * FROM info WHERE [target] == ?", (target, )) + elif tag == 1: + # call from bb + cur.execute("SELECT * FROM info WHERE [attach_bb] == ?", (target, )) + else: + return [] + # get data for i in cur.fetchall(): - data[i[0]] = i[1] + if i[0] in existedSet: + data[i[0]]['data'].append((i[4], i[5])) + else: + existedSet.add(i[0]) + data[i[0]] = { + 'name': i[3], + 'is_setting': True if i[2] != 0 else False, + 'data': [] + } return data diff --git a/SuperScriptViewer/static/viewer.css b/SuperScriptViewer/static/viewer.css index 58aab0e..9662eec 100644 --- a/SuperScriptViewer/static/viewer.css +++ b/SuperScriptViewer/static/viewer.css @@ -85,11 +85,29 @@ text.link-delay { color: black; } -pre { +/* property list*/ + +pre.propertyItem { border: 1px solid black; border-radius: 2px; padding: 5px; margin: 5px; background: #3f3f3f; color: white; +} + +code.propertyItem { + border: 1px solid black; + border-radius: 2px; + padding: 5px; + margin: 5px; + background: gray; + color: white; +} + +div.propertyItem { + margin: 5px; + border: 1px solid gray; + border-radius: 2px; + padding: 5px; } \ No newline at end of file diff --git a/SuperScriptViewer/static/viewer.js b/SuperScriptViewer/static/viewer.js index 50df6bd..7317fb9 100644 --- a/SuperScriptViewer/static/viewer.js +++ b/SuperScriptViewer/static/viewer.js @@ -96,7 +96,9 @@ function highlightLink(target) { event.stopPropagation(); } -function queryInfo(obj) { +// type = 0: call from cell +// type = 1: call from bb +function queryInfo(type, obj) { // confirm user enable this function if (!currentSettings["properties"]) return; @@ -104,16 +106,29 @@ function queryInfo(obj) { $.post(window.location, { operation: "info", + tag: type, target: obj }, function (data, status) { - //set id - $("#sidepanel-properties-id").text(obj); - //set data $("#sidepanel-properties-container").empty() for (var key in data) { - $("#sidepanel-properties-container").append("
" + key + ":
" + data[key] + "") + $("#sidepanel-properties-container").append(""); + + var box = $("#sidepanel-properties-container div:last-child"); + if (data[key]["is_setting"]) + $(box).append("
S
"); + + $(box).find("p b").text(data[key]["name"]); + $(box).find("p i").text("(" + key + ")"); + + for (var i = 0; i < data[key]['data'].length; i++) { + $(box).append("") + $(box).find("p:last-child").text(data[key]['data'][0]) + $(box).find("pre:last-child").text(data[key]['data'][1]) + } } }); } diff --git a/SuperScriptViewer/templates/viewer.html b/SuperScriptViewer/templates/viewer.html index 449bd04..13b1e5e 100644 --- a/SuperScriptViewer/templates/viewer.html +++ b/SuperScriptViewer/templates/viewer.html @@ -31,7 +31,7 @@
Properties of ---