1
0
mirror of https://github.com/teoxoy/factorio-blueprint-editor.git synced 2025-01-16 02:33:23 +02:00

don't load sample bp by default

This commit is contained in:
Teoxoy 2018-09-30 21:26:20 +02:00
parent 72653b796c
commit 9ee34bff4d
3 changed files with 17 additions and 8 deletions

View File

@ -10,6 +10,8 @@ A [Factorio](https://www.factorio.com) blueprint editor and renderer webapp
You can find the working website here: https://teoxoy.github.io/factorio-blueprint-editor
Sample blueprint: https://teoxoy.github.io/factorio-blueprint-editor/?source=https://pastebin.com/uc4n81GP
Example link that uses url query parameters: https://teoxoy.github.io/factorio-blueprint-editor/?lightTheme&keybinds:rotate=t,pippete=p&index=1&source=https://pastebin.com/Xp9u7NaA
# Contributing

View File

@ -14,7 +14,6 @@ import keyboardJS from 'keyboardjs'
import { Book } from './factorio-data/book'
import BPString from './factorio-data/BPString'
import sampleBP from './sample-blueprint'
import util from './util'
import { InventoryContainer } from './containers/inventory'
@ -107,7 +106,7 @@ if (params.includes('lightTheme')) {
G.UIColors.secondary = 0xCCCCCC
}
let bpSource = sampleBP
let bpSource: string
let bpIndex = 0
for (const p of params) {
if (p.includes('source')) {
@ -166,7 +165,7 @@ G.app.stage.addChild(G.toolbarContainer)
const infoContainer = new InfoContainer()
G.app.stage.addChild(infoContainer)
Promise.all([util.findBPString(bpSource)]
Promise.all([bpSource ? util.findBPString(bpSource) : undefined]
.concat([
[ entitySpritesheetPNG, entitySpritesheetJSON ],
[ iconSpritesheetPNG, iconSpritesheetJSON ],
@ -180,14 +179,24 @@ Promise.all([util.findBPString(bpSource)]
tempCanvas.width = util.nearestPowerOf2(image.width)
tempCanvas.height = util.nearestPowerOf2(image.height)
tempCanvas.getContext('2d').drawImage(image, 0, 0)
return new PIXI.Spritesheet(PIXI.BaseTexture.fromCanvas(tempCanvas), data[1]).parse(resolve)
const baseTexture = PIXI.BaseTexture.fromCanvas(tempCanvas)
new PIXI.Spritesheet(baseTexture, data[1]).parse(() =>
G.app.renderer.plugins.prepare.upload(baseTexture, resolve)
)
}
image.onerror = reject
})
)))
.then(data => {
loadBp(data[0], false).then(() => {
if (!bpSource) {
G.bp = new Blueprint()
G.BPC.initBP()
finishSetup()
} else {
loadBp(data[0], false).then(finishSetup)
}
function finishSetup() {
G.BPC.centerViewport()
G.BPC.updateCursorPosition({
x: G.app.screen.width / 2,
@ -195,7 +204,7 @@ Promise.all([util.findBPString(bpSource)]
})
G.app.renderer.view.style.display = 'block'
setTimeout(() => doorbellButton.classList.remove('closed'), 30000)
})
}
})
.catch(error => console.error(error))

File diff suppressed because one or more lines are too long