From a1432b5be4d3b2c1a45198695cf8103096711ae3 Mon Sep 17 00:00:00 2001 From: thmsn <9084377+thmsndk@users.noreply.github.com> Date: Wed, 22 Nov 2023 22:22:42 +0000 Subject: [PATCH 1/4] show a list of possible imagesets instead of redirecting to pack_1a on admin --- admin.py | 7 ++- utility/htmls/imagesets/select-imageset.html | 35 ++++++++++++ utility/htmls/imagesets/selector.html | 58 ++++++++++++++++++++ 3 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 utility/htmls/imagesets/select-imageset.html create mode 100644 utility/htmls/imagesets/selector.html diff --git a/admin.py b/admin.py index 86c0b23..6beea66 100644 --- a/admin.py +++ b/admin.py @@ -101,7 +101,10 @@ class MapEditor(webapp.RequestHandler): class Selector(webapp.RequestHandler): #NOTICE: << Publicly available at /communityselector! >> [10/10/16] @ndb.toplevel def get(self,name): - if not name: self.redirect("/admin/selector/pack_1a"); return + if not name: + whtml(self,"utility/htmls/imagesets/select-imageset.html",domain=gdi(self),imagesets=imagesets) + return + # TODO: Render alist of image sets that you can choose instead of redirecting name=name.split("/")[0] file=imagesets[name]["file"] size=imagesets[name]["size"] @@ -110,7 +113,7 @@ class Selector(webapp.RequestHandler): #NOTICE: << Publicly available at /commun xs=[]; ys=[] for i in xrange(width/size): xs.append(i) for j in xrange(height/size): ys.append(j) - whtml(self,"utility/htmls/selector.html",domain=gdi(self),name=name,file=file,size=size,width=width,height=height,xs=xs,ys=ys,scale=3) + whtml(self,"utility/htmls/imagesets/selector.html",domain=gdi(self),name=name,file=file,size=size,width=width,height=height,xs=xs,ys=ys,scale=3) def post(self,name): self.get(name) class PhotoUpload(blobstore_handlers.BlobstoreUploadHandler): diff --git a/utility/htmls/imagesets/select-imageset.html b/utility/htmls/imagesets/select-imageset.html new file mode 100644 index 0000000..e95655e --- /dev/null +++ b/utility/htmls/imagesets/select-imageset.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + diff --git a/utility/htmls/imagesets/selector.html b/utility/htmls/imagesets/selector.html new file mode 100644 index 0000000..9e3ecc9 --- /dev/null +++ b/utility/htmls/imagesets/selector.html @@ -0,0 +1,58 @@ + + + + + + + + + + + + +
+
+
2
+
4
+
6
+
Alert
+
+
8
+
10
+
12
+
14
+
+
+
+ {% for y in ys %} +
+ {% for x in xs%} +
+
+ +
+
+ {% endfor %} +
+ {% endfor %} +
+ + \ No newline at end of file From 5df3c956391bf32ea5bdb01fa581f12bd6007316 Mon Sep 17 00:00:00 2001 From: thmsn <9084377+thmsndk@users.noreply.github.com> Date: Thu, 23 Nov 2023 00:32:40 +0000 Subject: [PATCH 2/4] visualize if sprite is mapped or used hovering shows title with details --- admin.py | 2 +- utility/htmls/imagesets/selector.html | 151 ++++++++++++++++++++++---- utility/htmls/selector.html | 58 ---------- 3 files changed, 128 insertions(+), 83 deletions(-) delete mode 100644 utility/htmls/selector.html diff --git a/admin.py b/admin.py index 6beea66..8124664 100644 --- a/admin.py +++ b/admin.py @@ -104,7 +104,7 @@ class Selector(webapp.RequestHandler): #NOTICE: << Publicly available at /commun if not name: whtml(self,"utility/htmls/imagesets/select-imageset.html",domain=gdi(self),imagesets=imagesets) return - # TODO: Render alist of image sets that you can choose instead of redirecting + name=name.split("/")[0] file=imagesets[name]["file"] size=imagesets[name]["size"] diff --git a/utility/htmls/imagesets/selector.html b/utility/htmls/imagesets/selector.html index 9e3ecc9..c73ced8 100644 --- a/utility/htmls/imagesets/selector.html +++ b/utility/htmls/imagesets/selector.html @@ -4,26 +4,119 @@ - - + + + @@ -40,19 +133,29 @@
14
-
+
{% for y in ys %} -
- {% for x in xs%} -
-
- -
-
- {% endfor %} +
+ {% for x in xs%} +
+
+ +
+ {% endfor %} +
{% endfor %}
- \ No newline at end of file + diff --git a/utility/htmls/selector.html b/utility/htmls/selector.html deleted file mode 100644 index 9e3ecc9..0000000 --- a/utility/htmls/selector.html +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - -
-
-
2
-
4
-
6
-
Alert
-
-
8
-
10
-
12
-
14
-
-
-
- {% for y in ys %} -
- {% for x in xs%} -
-
- -
-
- {% endfor %} -
- {% endfor %} -
- - \ No newline at end of file From 3758596a873c7efeb9cbdceff73fdd306f5e0733 Mon Sep 17 00:00:00 2001 From: thmsn <9084377+thmsndk@users.noreply.github.com> Date: Thu, 23 Nov 2023 01:44:09 +0000 Subject: [PATCH 3/4] prevent crash when looking up skins of sprite by x,y --- utility/htmls/imagesets/selector.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utility/htmls/imagesets/selector.html b/utility/htmls/imagesets/selector.html index c73ced8..a5d3447 100644 --- a/utility/htmls/imagesets/selector.html +++ b/utility/htmls/imagesets/selector.html @@ -76,7 +76,7 @@ for (const element of sprites) { const x = element.dataset.x; const y = element.dataset.y; - const skins = itemset_skins[x][y] ?? []; + const skins = itemset_skins[x] && itemset_skins[x][y] ? itemset_skins[x][y] : []; let hasPosition = false; let hasItem = false; From c1f67881c83231eebf5027d1ce9bb225f2898d37 Mon Sep 17 00:00:00 2001 From: thmsn <9084377+thmsndk@users.noreply.github.com> Date: Thu, 23 Nov 2023 02:04:39 +0000 Subject: [PATCH 4/4] also indicate conditions and skills in the spritesheet --- utility/htmls/imagesets/selector.html | 51 +++++++++++++++++++++------ 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/utility/htmls/imagesets/selector.html b/utility/htmls/imagesets/selector.html index a5d3447..6ecae67 100644 --- a/utility/htmls/imagesets/selector.html +++ b/utility/htmls/imagesets/selector.html @@ -25,7 +25,9 @@ border-color: yellow; } - .has-item { + .has-item, + .has-condition, + .has-skill { border-color: red; } @@ -35,19 +37,26 @@ // TODO: prepare / show a little items.py snippet for easy copy paste? const current_itemset = "{{name}}"; - const itemsBySkin = {}; - for (const itemKey in G.items) { - const item = G.items[itemKey]; - if (!item.skin) continue; - item.id = itemKey; + function mapBySkin(dictionary) { + const bySkin = {}; + for (const key in dictionary) { + const value = dictionary[key]; + if (!value.skin) continue; + value.id = key; - if (!itemsBySkin[item.skin]) { - itemsBySkin[item.skin] = []; + if (!bySkin[value.skin]) { + bySkin[value.skin] = []; + } + + bySkin[value.skin].push(value); } - - itemsBySkin[item.skin].push(item); + return bySkin; } + const itemsBySkin = mapBySkin(G.items); + const conditionsBySkin = mapBySkin(G.conditions); + const skillsBySkin = mapBySkin(G.skills); + // lookup table to look up skin name in G.positions by x,y coordinates const skinByXY = {}; for (const skin in G.positions) { @@ -80,6 +89,8 @@ let hasPosition = false; let hasItem = false; + let hasCondition = false; + let hasSkill = false; let title = [`${x},${y}`]; for (const skin of skins) { const position = G.positions[skin]; @@ -95,6 +106,18 @@ hasItem = true; } + const conditions = conditionsBySkin[skin] ?? []; + for (const item of conditions) { + title.push(`G.conditions.${item.id} = ${item.name}`); + hasCondition = true; + } + + const skills = skillsBySkin[skin] ?? []; + for (const item of skills) { + title.push(`G.skills.${item.id} = ${item.name}`); + hasSkill = true; + } + title.push(""); } @@ -106,6 +129,14 @@ $(element).addClass("has-item"); } + if (hasCondition) { + $(element).addClass("has-condition"); + } + + if (hasSkill) { + $(element).addClass("has-skill"); + } + $(element).attr("title", title.join("\n")); }