mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
remoteMap stone/steel furnace scaling, inserter rotations
This commit is contained in:
1 parent
e6d734d4eb
commit
3499411290
3 files changed
+59
-29
No files matched your search
@@ -15,8 +15,8 @@ export var entityDrawRules = {
|
|||||||
"accumulator": {
|
"accumulator": {
|
||||||
spritesheet: spritesheetJson.frames["images/factorio/entity/accumulator/accumulator.png"],
|
spritesheet: spritesheetJson.frames["images/factorio/entity/accumulator/accumulator.png"],
|
||||||
sizeInTiles: {
|
sizeInTiles: {
|
||||||
x:4,
|
x:3.5,
|
||||||
y:4,
|
y:3.5,
|
||||||
},
|
},
|
||||||
positionOffset: {
|
positionOffset: {
|
||||||
x:-1,
|
x:-1,
|
||||||
@@ -45,6 +45,28 @@ export var entityDrawRules = {
|
|||||||
y:-1,
|
y:-1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"stone-furnace": {
|
||||||
|
spritesheet: spritesheetJson.frames["images/factorio/entity/stone-furnace/stone-furnace.png"],
|
||||||
|
sizeInTiles: {
|
||||||
|
x:3,
|
||||||
|
y:2.2,
|
||||||
|
},
|
||||||
|
positionOffset: {
|
||||||
|
x:-0.9,
|
||||||
|
y:-1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"steel-furnace": {
|
||||||
|
spritesheet: spritesheetJson.frames["images/factorio/entity/steel-furnace/steel-furnace.png"],
|
||||||
|
sizeInTiles: {
|
||||||
|
x:2.5,
|
||||||
|
y:2.5,
|
||||||
|
},
|
||||||
|
positionOffset: {
|
||||||
|
x:-1.2,
|
||||||
|
y:-1.1,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
let template3x3entity = {
|
let template3x3entity = {
|
||||||
sizeInTiles: {
|
sizeInTiles: {
|
||||||
@@ -101,22 +123,7 @@ for(let i = 1; i <= 3; i++){
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 2 tile entities
|
|
||||||
[{name: "stone-furnace", ref:"images/factorio/entity/stone-furnace/stone-furnace.png"},
|
|
||||||
{name: "steel-furnace", ref:"images/factorio/entity/steel-furnace/steel-furnace.png"}
|
|
||||||
].forEach(ent => {
|
|
||||||
entityDrawRules[ent.name] = {
|
|
||||||
spritesheet: spritesheetJson.frames[ent.ref],
|
|
||||||
sizeInTiles: {
|
|
||||||
x:2.5,
|
|
||||||
y:2.5,
|
|
||||||
},
|
|
||||||
positionOffset: {
|
|
||||||
x:-1,
|
|
||||||
y:-1,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
});
|
|
||||||
["transport-belt", "fast-transport-belt", "express-transport-belt"].forEach(name => {
|
["transport-belt", "fast-transport-belt", "express-transport-belt"].forEach(name => {
|
||||||
entityDrawRules[name] = {
|
entityDrawRules[name] = {
|
||||||
rotOffset: 270,
|
rotOffset: 270,
|
||||||
@@ -129,6 +136,11 @@ for(let i = 1; i <= 3; i++){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
["inserter", "fast-inserter", "stack-inserter", "filter-inserter"].forEach(inserter => {
|
||||||
|
entityDrawRules[inserter] = {
|
||||||
|
rotOffset:90,
|
||||||
|
}
|
||||||
|
});
|
||||||
entityDrawRules["oil-refinery"] = {
|
entityDrawRules["oil-refinery"] = {
|
||||||
spritesheet: spritesheetJson.frames["images/factorio/entity/oil-refinery/oil-refinery.png.0"],
|
spritesheet: spritesheetJson.frames["images/factorio/entity/oil-refinery/oil-refinery.png.0"],
|
||||||
sizeInTiles: {
|
sizeInTiles: {
|
||||||
|
|||||||
+8
-9
@@ -405,7 +405,7 @@ function drawEntity(entity, dontCache){
|
|||||||
if(entity.entity && entity.entity.name && typeof entity.entity.name == "string"){
|
if(entity.entity && entity.entity.name && typeof entity.entity.name == "string"){
|
||||||
let name = entity.entity.name;
|
let name = entity.entity.name;
|
||||||
if(!entityImages[name]){
|
if(!entityImages[name]){
|
||||||
console.log("Downloading image")
|
console.log("Downloading image "+name);
|
||||||
// download the entityImages and add stuff to queue
|
// download the entityImages and add stuff to queue
|
||||||
entityImages[name] = {
|
entityImages[name] = {
|
||||||
img: new Image(),
|
img: new Image(),
|
||||||
@@ -418,14 +418,13 @@ function drawEntity(entity, dontCache){
|
|||||||
let image, sprWidth, sprHeight, offLeft, offTop
|
let image, sprWidth, sprHeight, offLeft, offTop
|
||||||
let rotation = 0;
|
let rotation = 0;
|
||||||
// check hardcoded entity draw rules for specifics (otherwise draw icon as 1x1 entity with rotation if specified)
|
// check hardcoded entity draw rules for specifics (otherwise draw icon as 1x1 entity with rotation if specified)
|
||||||
if(entityDrawRules[name]){
|
if(entityDrawRules[name] && entityDrawRules[name].positionOffset){
|
||||||
let rules = entityDrawRules[name]
|
let rules = entityDrawRules[name]
|
||||||
// console.log(entityDrawRules[name])
|
var offsetX = rules.positionOffset.x;
|
||||||
var offsetX = entityDrawRules[name].positionOffset.x;
|
var offsetY = rules.positionOffset.y;
|
||||||
var offsetY = entityDrawRules[name].positionOffset.y;
|
|
||||||
var size = {
|
var size = {
|
||||||
x: remoteMapConfig.tileSize * entityDrawRules[name].sizeInTiles.x,
|
x: remoteMapConfig.tileSize * rules.sizeInTiles.x,
|
||||||
y: remoteMapConfig.tileSize * entityDrawRules[name].sizeInTiles.y,
|
y: remoteMapConfig.tileSize * rules.sizeInTiles.y,
|
||||||
};
|
};
|
||||||
if(rules.spritesheet && Array.isArray(rules.spritesheet)){
|
if(rules.spritesheet && Array.isArray(rules.spritesheet)){
|
||||||
let dir = Number(entity.entity.rot);
|
let dir = Number(entity.entity.rot);
|
||||||
@@ -465,7 +464,7 @@ function drawEntity(entity, dontCache){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!image) image = entityImages[name].img;
|
if(!image) image = entityImages[name].img;
|
||||||
drawImageWithRotation(ctx, image, xPos, yPos, size.x, size.y, rotation, sprWidth, sprHeight, offLeft, offTop);
|
drawImageWithRotation(ctx, image, xPos, yPos, size.x, size.y, rotation%360, sprWidth, sprHeight, offLeft, offTop);
|
||||||
//console.log("Drawing "+name+" at X: "+xPos+", Y: "+yPos+" with with rotation "+rotation);
|
//console.log("Drawing "+name+" at X: "+xPos+", Y: "+yPos+" with with rotation "+rotation);
|
||||||
} else {
|
} else {
|
||||||
// we are waiting for the image to load, push the task to our queue. It will be processed once the image loads.
|
// we are waiting for the image to load, push the task to our queue. It will be processed once the image loads.
|
||||||
@@ -484,7 +483,7 @@ function drawEntity(entity, dontCache){
|
|||||||
entityImages[name].queue.push(entity);
|
entityImages[name].queue.push(entity);
|
||||||
entityImages[name].img.onload = imageLoaded()
|
entityImages[name].img.onload = imageLoaded()
|
||||||
|
|
||||||
if(entityDrawRules[name]){
|
if(entityDrawRules[name] && entityDrawRules[name].spritesheet){
|
||||||
imageLoaded();
|
imageLoaded();
|
||||||
} else entityImages[name].img.src = getImageFromName(name);
|
} else entityImages[name].img.src = getImageFromName(name);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ export class itemSelector {
|
|||||||
// direction selector
|
// direction selector
|
||||||
HTML += "<div id='directionSelector'>";
|
HTML += "<div id='directionSelector'>";
|
||||||
HTML += "<h2>Direction: </h2>";
|
HTML += "<h2>Direction: </h2>";
|
||||||
|
HTML += "<h2 id='directionDisplay'>"+this.directionToCardinal(0)+"</h2>"
|
||||||
HTML += "<p>Press R to rotate</p>";
|
HTML += "<p>Press R to rotate</p>";
|
||||||
HTML += "<p id='directionDisplay'>0</p>"
|
|
||||||
HTML += "</div>";
|
HTML += "</div>";
|
||||||
|
|
||||||
// write styles
|
// write styles
|
||||||
@@ -53,10 +53,29 @@ export class itemSelector {
|
|||||||
// handle direction keyboard event
|
// handle direction keyboard event
|
||||||
Mousetrap.bind('r', ()=>this.rotate());
|
Mousetrap.bind('r', ()=>this.rotate());
|
||||||
}
|
}
|
||||||
|
directionToCardinal(dir){
|
||||||
|
if(dir == 0){
|
||||||
|
return "north";
|
||||||
|
} else if(dir == 1){
|
||||||
|
return "north-east";
|
||||||
|
} else if(dir == 2){
|
||||||
|
return "east";
|
||||||
|
} else if(dir == 3){
|
||||||
|
return "south-east";
|
||||||
|
} else if(dir == 4){
|
||||||
|
return "south";
|
||||||
|
} else if(dir == 5){
|
||||||
|
return "south-west";
|
||||||
|
} else if(dir == 6){
|
||||||
|
return "west";
|
||||||
|
} else if(dir == 7){
|
||||||
|
return "north-west";
|
||||||
|
}
|
||||||
|
}
|
||||||
rotate(){
|
rotate(){
|
||||||
this.direction = (this.direction + 2) % 8;
|
this.direction = (this.direction + 2) % 8;
|
||||||
// update display
|
// update display
|
||||||
document.querySelector("#directionDisplay").innerHTML = this.direction;
|
document.querySelector("#directionDisplay").innerHTML = this.directionToCardinal(this.direction);
|
||||||
}
|
}
|
||||||
getItem(){
|
getItem(){
|
||||||
let name = document.querySelector(this.containerSelector+" > .itemSelector > select").value;
|
let name = document.querySelector(this.containerSelector+" > .itemSelector > select").value;
|
||||||
|
|||||||
Reference in new issue
Block a user