Skip to content

Commit

Permalink
Misc bug fixes
Browse files Browse the repository at this point in the history
* fix some weird data coming from factorio-blueprint
* exclude curved rail; it's a special snowflake that will need a lot
  of work to handle properly
* fix broken/dead references in index.html
* prevent uncaught exceptions around mouse events
* eslint fixes
* version bump

refs camerongillette#16
  • Loading branch information
ryepup committed Dec 2, 2017
1 parent 55f1bf6 commit 76fea93
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
5 changes: 2 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Factorio</title>
<link rel="shortcut icon" href="icons/atomic-bomb.png">
<link rel="shortcut icon" href="vendor/factorio/icons/atomic-bomb.png">
<link rel="stylesheet" href="css/style.css">
</head>

Expand Down Expand Up @@ -40,8 +40,7 @@

<script src="https://unpkg.com/[email protected]/dist/tinyemitter.js"></script>
<script src="vendor/factorio-blueprint.min.js"></script>
<script src="vendor/pako.js"></script>
<script src="vendor/base64.js"></script>

<script src="js/view.js"></script>
<script src="js/viewmodel.js"></script>
<script src="js/script.js"></script>
Expand Down
9 changes: 5 additions & 4 deletions js/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ window.FBE = window.FBE || {};
grid.addEventListener('mousedown', function (evt) {
isDrawing = evt.button == 0;
isClearing = evt.button == 2;
var point = getPointFromTile(evt.target);
tileMouseOver(point, evt);
var point = getPointFromNode(evt.target);
if (point) { tileMouseOver(point, evt); }
});
grid.addEventListener('mouseup', function () {
isDrawing = isClearing = false;
Expand Down Expand Up @@ -68,8 +68,9 @@ window.FBE = window.FBE || {};
getTileFromPoint(event.point).innerHTML = '';
}

function getPointFromTile(tile) {
var coords = tile.dataset.point.split(':');
function getPointFromNode(node) {
if (!node.dataset.point) { return null; }
var coords = node.dataset.point.split(':');
return {
x: coords[0],
y: coords[1]
Expand Down
12 changes: 9 additions & 3 deletions js/viewmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ window.FBE = window.FBE || {};

function loadEntity(placeables, entity) {
var items = placeables
.filter(function (p) { return p.name === entity.name; }),
.filter(function (p) { return p.name === entity.name; }),
item;

if (items.length === 2) {
Expand Down Expand Up @@ -157,7 +157,12 @@ window.FBE = window.FBE || {};
},
rawEntities[name],
// fix bad data in factorio-blueprint
name === 'steam_turbine' && {width: 5, height: 3}
name === 'steam_turbine' && { width: 5, height: 3 },
name === 'boiler' && { width: 3, height: 2 },
// fix spots where height/width are swapped
name === 'pump' && { width: 2, height: 1 },
name === 'decider_combinator' && { width: 2, height: 1 },
name === 'arithmetic_combinator' && { width: 2, height: 1 }
);
})
.filter(isPlaceable)
Expand All @@ -166,7 +171,8 @@ window.FBE = window.FBE || {};
}

function isPlaceable(entity) {
return (entity.type === "item" && entity.width);
return (entity.type === "item" && entity.width)
&& entity.name !== 'curved_rail'; // curved rail is strange
// TODO: support tiles
// || entity.type === "tile"
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "factorio_blueprint_editor",
"version": "1.0.0",
"version": "1.1.0",
"description": "Online Editor for Elxeno's Factorio Blueprint Editor",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "./node_modules/.bin/eslint js/**/*.js"
"lint": "eslint js/**/*.js"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 76fea93

Please sign in to comment.