Skip to content

Commit

Permalink
Display minis size to help to choose a proxy #181
Browse files Browse the repository at this point in the history
  • Loading branch information
rafdulaf committed Sep 20, 2023
1 parent c987ef3 commit 682e9c1
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Conan/data/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@
"sculptor": { "name": "Viktor Dragosani", "link": "https://www.facebook.com/search/top?q=viktor%20dragosani" },
"paint": { "name": "madcollector", "link": "https://the-overlord.com/index.php?/profile/5567-madcollector/"},
"type": "animal",
"size": { "base": { "type": "circle", "diameter": 35 }, "height": 25 },
"origins": ["stretchgoal"],
"forum": "https://the-overlord.com/index.php?/topic/3413-peinture-montrez-moi-vos-balthus-et-slasher/"
},
Expand Down Expand Up @@ -954,6 +955,7 @@
"sculptor": { "name": "Viktor Dragosani", "link": "https://www.facebook.com/search/top?q=viktor%20dragosani" },
"paint": { "name": "Dahkon", "link": "https://the-overlord.com/index.php?/profile/44-dahkon/"},
"type": "monster",
"size": { "base": { "type": "free", "width": 55, "height": 45 }, "height": 25 },
"origins": ["dragon"],
"forum": "https://the-overlord.com/index.php?/topic/611-peinture-montrez-moi-vos-dragons/"
},
Expand Down
Binary file added Conan/encyclopedia/models/img/shape_monster.webp
Binary file not shown.
Binary file added Conan/encyclopedia/models/img/shape_regular.webp
Binary file not shown.
2 changes: 2 additions & 0 deletions Conan/encyclopedia/models/lang/models.en.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ EncyclopediaModels._i18n = {
'fromAnd': "<br/>and",
'model': "miniature",
'models': "miniatures",
'size': "Size:",
'sizeSeparator': "or",
'sculptedBy': "Sculpted by: ",
'sculptorUnknown': "(The sculptor name is not sure)",
'paintedBy': "Painted by: ",
Expand Down
2 changes: 2 additions & 0 deletions Conan/encyclopedia/models/lang/models.fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ EncyclopediaModels._i18n = {
'fromAnd': "<br/>et",
'model': "figurine",
'models': "figurines",
'size': "Taille :",
'sizeSeparator': "ou",
'sculptedBy': "Sculpté par : ",
'sculptorUnknown': "(Le nom du sculpteur n'est pas certain)",
'paintedBy': "Peint par : ",
Expand Down
2 changes: 2 additions & 0 deletions Conan/encyclopedia/models/lang/models.it.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ EncyclopediaModels._i18n = {
'fromAnd': "<br/>e",
'model': "miniatura",
'models': "miniature",
'size': "Taglia:",
'sizeSeparator': "o",
'sculptedBy': "Scolpito da: ",
'sculptorUnknown': "(Il nome dello scultore non è sicuro)",
'paintedBy': "Dipinta da: ",
Expand Down
3 changes: 2 additions & 1 deletion Conan/encyclopedia/models/models.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
}

.modeldetails .heroes,
.modeldetails .tiles {
.modeldetails .tiles,
.modeldetails .sizes {
line-height: 20px;
margin: 10px 0;
}
Expand Down
98 changes: 97 additions & 1 deletion Conan/encyclopedia/models/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,63 @@ var EncyclopediaModels = {

onHide: function() {
},

openModel: function(id) {
function deepEqual(object1, object2) {
const keys1 = Object.keys(object1);
const keys2 = Object.keys(object2);

if (keys1.length !== keys2.length) {
return false;
}

for (const key of keys1) {
const val1 = object1[key];
const val2 = object2[key];
const areObjects = isObject(val1) && isObject(val2);
if (areObjects && !deepEqual(val1, val2) ||
!areObjects && val1 !== val2) {
return false;
}
}

return true;
}
function isObject(object) {
return object != null && typeof object === 'object';
}
function reduceSize(as) {
if (as.length < 2)
{
// 0 or 1 element
return as;
}
else
{
var diff = [];

for (let a = 0; a < as.length; a++)
{
var alreadyExists = false;
for (let b = 0; b < diff.length; b++)
{
if (deepEqual(diff[b], as[a]))
{
alreadyExists = true;
continue;
}
}
if (!alreadyExists)
{
diff.push(as[a]);
}
}

// All the same
return diff;
}
}

var models = EncyclopediaModels._findModelsById(id);

var originsCount = {};
Expand All @@ -377,6 +432,7 @@ var EncyclopediaModels = {
var modelImages = [];
var painters = [];
var sculptors = [];
var sizes = [];
for (var i in models)
{
var model = models[i];
Expand All @@ -398,6 +454,45 @@ var EncyclopediaModels = {
{
sculptors.push(model.sculptor);
}

sizes.push(model.size);
}

sizes = reduceSize(sizes);
var sizeCode = "";
if (sizes.length > 1 || (sizes.length == 1 && sizes[0] != null))
{
sizeCode = "<div class='sizes'>" + EncyclopediaModels._i18n.size + " ";
for (var s in sizes)
{
if (s != 0) sizeCode += " " + EncyclopediaModels._i18n.sizeSeparator + " ";

var size = sizes[s];
if (size == null)
{
continue;
}

var code = [];
if (size.base)
{
if (size.base.type == "circle")
{
code.push("⌀ " + size.base.diameter + " mm");
}
else if (size.base.type == "free")
{
code.push("⌀ " + size.base.width + " mm x " + size.base.height + " mm");
}
}
if (size.height)
{
code.push("↕️ " + size.height + " mm");
}

sizeCode += code.join(" ");
}
sizeCode += "</div>";
}

var photos = "<div class='photos'>";
Expand Down Expand Up @@ -480,6 +575,7 @@ var EncyclopediaModels = {
+ heroes
+ tiles
+ tokens
+ sizeCode
+ sculptor
+ painter
+ photos
Expand Down

0 comments on commit 682e9c1

Please sign in to comment.