potential fix for atree image misalignment
This commit is contained in:
parent
a009e07587
commit
9d5339b255
3 changed files with 13 additions and 11 deletions
24
js/atree.js
24
js/atree.js
|
@ -372,11 +372,11 @@ const atree_validate = new (class extends ComputeNode {
|
|||
const abil = node.ability;
|
||||
if (atree_state.get(abil.id).active) {
|
||||
atree_to_add.push([node, 'not reachable', false]);
|
||||
atree_state.get(abil.id).img.style.backgroundPosition = atlasBGPositionCalc([atreeNodeAtlasPositions[abil.display.icon], 2], [9, 3]);
|
||||
atree_state.get(abil.id).img.style.backgroundPosition = atlasBGPositionCalc([atreeNodeAtlasPositions[abil.display.icon], 2], atreeNodeAtlasSize);
|
||||
}
|
||||
else {
|
||||
atree_not_present.push(abil.id);
|
||||
atree_state.get(abil.id).img.style.backgroundPosition = atlasBGPositionCalc([atreeNodeAtlasPositions[abil.display.icon], 0], [9, 3]);
|
||||
atree_state.get(abil.id).img.style.backgroundPosition = atlasBGPositionCalc([atreeNodeAtlasPositions[abil.display.icon], 0], atreeNodeAtlasSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,7 +425,7 @@ const atree_validate = new (class extends ComputeNode {
|
|||
const node = atree_state.get(node_id);
|
||||
const [success, hard_error, reason] = abil_can_activate(node, atree_state, reachable, archetype_count, ap_left);
|
||||
if (success) {
|
||||
node.img.style.backgroundPosition = atlasBGPositionCalc([atreeNodeAtlasPositions[node.ability.display.icon], 1], [9, 3]);
|
||||
node.img.style.backgroundPosition = atlasBGPositionCalc([atreeNodeAtlasPositions[node.ability.display.icon], 1], atreeNodeAtlasSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -973,7 +973,7 @@ function render_AT(UI_elem, list_elem, tree) {
|
|||
const parent_id = parent_abil.id;
|
||||
|
||||
let connect_elem = document.createElement("div");
|
||||
connect_elem.style = "width: 112.5%; height: 112.5%; position: absolute; top: -5.55%; left: -5.55%; image-rendering: pixelated; background-image: url('../media/atree/connectors.png'); background-size: 1200% 400%;"
|
||||
connect_elem.style = "width: 112.5%; height: 112.5%; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); image-rendering: pixelated; background-image: url('../media/atree/connectors.png'); background-size: 1700% 500%;"
|
||||
// connect up
|
||||
for (let i = ability.display.row - 1; i > parent_abil.display.row; i--) {
|
||||
const coord = i + "," + ability.display.col;
|
||||
|
@ -1009,7 +1009,7 @@ function render_AT(UI_elem, list_elem, tree) {
|
|||
|
||||
// create node
|
||||
let node_elem = document.getElementById("atree-row-" + ability.display.row).children[ability.display.col];
|
||||
node_wrap.img = make_elem("div", [], {style: "width: 200%; height: 200%; position: absolute; top: -50%; left: -50%; image-rendering: pixelated; z-index: 1; background-image: url('../media/atree/icons.png'); background-size: 900% 300%;"})
|
||||
node_wrap.img = make_elem("div", [], {style: "width: 200%; height: 200%; position: absolute; top: -50%; left: -50%; image-rendering: pixelated; z-index: 1; background-image: url('../media/atree/icons.png'); background-size: 1700% 500%;"})
|
||||
node_elem.appendChild(node_wrap.img);
|
||||
|
||||
// create hitbox
|
||||
|
@ -1231,11 +1231,11 @@ function atree_set_state(node_wrapper, new_state) {
|
|||
}
|
||||
if (new_state) {
|
||||
node_wrapper.active = true;
|
||||
node_wrapper.img.style.backgroundPosition = atlasBGPositionCalc([atreeNodeAtlasPositions[icon], 2], [9, 3]);
|
||||
node_wrapper.img.style.backgroundPosition = atlasBGPositionCalc([atreeNodeAtlasPositions[icon], 2], atreeNodeAtlasSize);
|
||||
}
|
||||
else {
|
||||
node_wrapper.active = false;
|
||||
node_wrapper.img.style.backgroundPosition = atlasBGPositionCalc([atreeNodeAtlasPositions[icon], 1], [9, 3]);
|
||||
node_wrapper.img.style.backgroundPosition = atlasBGPositionCalc([atreeNodeAtlasPositions[icon], 1], atreeNodeAtlasSize);
|
||||
}
|
||||
let atree_connectors_map = node_wrapper.all_connectors_ref;
|
||||
for (const parent of node_wrapper.parents) {
|
||||
|
@ -1264,6 +1264,7 @@ const atreeConnectorAtlasPositions = {
|
|||
"1011": {"0000": [5, 2], "1011": [6, 2], "1010": [7, 2], "1001": [8, 2], "0011": [9, 2]},
|
||||
"1111": {"0000": [0, 3], "1111": [1, 3], "1110": [2, 3], "1101": [3, 3], "1100": [4, 3], "1011": [5, 3], "1010": [6, 3], "1001": [7, 3], "0111": [8, 3], "0110": [9, 3], "0101": [10, 3], "0011": [11, 3]}
|
||||
}
|
||||
const atreeConnectorAtlasSize = [17, 5]
|
||||
// just has the x position, y is based on state
|
||||
const atreeNodeAtlasPositions = {
|
||||
"node_0": 0,
|
||||
|
@ -1276,6 +1277,7 @@ const atreeNodeAtlasPositions = {
|
|||
"node_assassin": 7,
|
||||
"node_shaman": 8
|
||||
}
|
||||
const atreeNodeAtlasSize = [17, 5]
|
||||
function atlasBGPositionCalc(pos, atlasSize) {
|
||||
// https://css-tricks.com/focusing-background-image-precise-location-percentages/
|
||||
// p = (c + 0.5/z - 0.5) * z/(z - 1) + 0.5
|
||||
|
@ -1293,7 +1295,7 @@ function atree_render_connection(atree_connectors_map) {
|
|||
let connector_elem = connector_info.connector;
|
||||
set_connector_type(connector_info);
|
||||
connector_info.highlight = [0, 0, 0, 0];
|
||||
connector_elem.style.backgroundPosition = atlasBGPositionCalc(atreeConnectorAtlasPositions[connector_info.type]["0000"], [12, 4]);
|
||||
connector_elem.style.backgroundPosition = atlasBGPositionCalc(atreeConnectorAtlasPositions[connector_info.type]["0000"], atreeConnectorAtlasSize);
|
||||
let target_elem = document.getElementById("atree-row-" + i.split(",")[0]).children[i.split(",")[1]];
|
||||
if (target_elem.children.length != 0) {
|
||||
// janky special case...
|
||||
|
@ -1345,15 +1347,15 @@ function atree_set_edge(atree_connectors_map, parent, child, state) {
|
|||
for (let i = 0; i < 4; i++) {
|
||||
render += highlight_state[i] === 0 ? "0" : "1";
|
||||
}
|
||||
connector_elem.style.backgroundPosition = atlasBGPositionCalc(atreeConnectorAtlasPositions[ctype][render], [12, 4]);
|
||||
connector_elem.style.backgroundPosition = atlasBGPositionCalc(atreeConnectorAtlasPositions[ctype][render], atreeConnectorAtlasSize);
|
||||
continue;
|
||||
} else {
|
||||
// lol bad overloading, [0] is just the whole state
|
||||
highlight_state[0] += state_delta;
|
||||
if (highlight_state[0] > 0) {
|
||||
connector_elem.style.backgroundPosition = atlasBGPositionCalc(atreeConnectorAtlasPositions[ctype][ctype], [12, 4]);
|
||||
connector_elem.style.backgroundPosition = atlasBGPositionCalc(atreeConnectorAtlasPositions[ctype][ctype], atreeConnectorAtlasSize);
|
||||
} else {
|
||||
connector_elem.style.backgroundPosition = atlasBGPositionCalc(atreeConnectorAtlasPositions[ctype]["0000"], [12, 4]);
|
||||
connector_elem.style.backgroundPosition = atlasBGPositionCalc(atreeConnectorAtlasPositions[ctype]["0000"], atreeConnectorAtlasSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 4.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 9.8 KiB |
Loading…
Reference in a new issue