1
0
mirror of https://github.com/teoxoy/factorio-blueprint-editor.git synced 2025-02-05 13:05:07 +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 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 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 # Contributing

View File

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

File diff suppressed because one or more lines are too long