change canvas req: 0 = has to be registered; -1 = no requirements

make historical view start date canvas specific
This commit is contained in:
HF 2020-01-10 16:31:37 +01:00
parent 16ebfa9629
commit b326ffd9b5
5 changed files with 53 additions and 16 deletions

View File

@ -118,7 +118,7 @@ Notes:
Canvas specific configuartion like colors and cooldown is in `src/canvases.json` for all canvases.
The CanvasSize is expected to be a power of 4 (4096, 16384, 65536,...) and not smaller than 256.
bcd is base cooldown for unset pixels, pcd is cooldown for placing on top of others, cds is stacktime, req is the requirement to be allowed to set on canvas in total pixels placed. All the cooldown values are in ms.
bcd is base cooldown for unset pixels, pcd is cooldown for placing on top of others, cds is stacktime, req is the requirement to be allowed to set on canvas in total pixels placed (or -1 for no requirement or 0 for having to be registered). `sd` is the start-date of the canvas, its used to know the oldest available backup (see Backup & Historical View section). All the cooldown values are in ms.
If you want to add a new canvas, be sure that you additionally create `public/loading${canvasId}.png` and `public/assets3d/normal${canvasId}.jpg` and `public/assets3d/specular${canvasId}.jpg`, check out the existing ones to see what those files are for.
The default configuration values can be seen in `src/core/config.js` and for the canvases in `src/core/constats.js`
@ -206,6 +206,9 @@ If command is defined, it will be executed after every backup (just one command,
Alternatively you can run it with pm2, just like pixelplanet. An example ecosystem-backup.example.yml file will be located in the build directory.
Note:
- You do not have to run backups or historical view, it's optional.
### Historical view
![historicalview](promotion/historicalview.gif)

View File

@ -40,7 +40,8 @@
"bcd": 4000,
"pcd" : 7000,
"cds": 60000,
"req": 0
"req": -1,
"sd": "2020-01-08"
},
"1": {
"ident": "m",
@ -83,6 +84,7 @@
"bcd": 15000,
"pcd": 15000,
"cds": 900000,
"req": 8000
"req": 8000,
"sd": "2020-01-08"
}
}

View File

@ -79,6 +79,7 @@ class HistorySelect extends React.Component {
render() {
const {
setTime,
canvasStartDate,
} = this.props;
const {
submitting,
@ -91,7 +92,7 @@ class HistorySelect extends React.Component {
<input
type="date"
requiredPattern="\d{4}-\d{2}-\d{2}"
min="2020-01-08"
min={canvasStartDate}
max={max}
onChange={this.handleDateChange}
/>
@ -125,8 +126,9 @@ function mapDispatchToProps(dispatch) {
function mapStateToProps(state: State) {
const {
canvasId,
canvasStartDate,
} = state.canvas;
return { canvasId };
return { canvasId, canvasStartDate };
}
export default connect(mapStateToProps, mapDispatchToProps)(HistorySelect);

View File

@ -66,7 +66,7 @@ async function draw(
};
}
if (canvas.req) {
if (canvas.req !== -1) {
if (user.id === null) {
return {
errorTitle: 'Not Logged In',

View File

@ -26,6 +26,7 @@ export type CanvasState = {
canvasIdent: string,
canvasSize: number,
canvasMaxTiledZoom: number,
canvasStartDate: string,
palette: Palette,
chunks: Map<string, ChunkRGB>,
view: Cell,
@ -62,9 +63,22 @@ function getViewFromURL(canvases: Object) {
const canvasIdent = almost[0];
// will be null if not in DEFAULT_CANVASES
const canvasId = getIdFromObject(canvases, almost[0]);
const colors = (canvasId !== null)
? canvases[canvasId].colors : canvases[DEFAULT_CANVAS_ID].colors;
const canvasSize = (canvasId !== null) ? canvases[canvasId].size : 1024;
let colors;
let canvasSize;
let canvasStartDate;
if (canvasId == null) {
// if canvas informations are not available yet
// aka /api/me didn't load yet
colors = canvases[DEFAULT_CANVAS_ID].colors;
canvasSize = 1024;
canvasStartDate = null;
} else {
const canvas = canvases[canvasId];
colors = canvas.colors;
canvasSize = canvas.size;
canvasStartDate = canvas.sd;
}
const x = parseInt(almost[1], 10);
const y = parseInt(almost[2], 10);
@ -83,6 +97,7 @@ function getViewFromURL(canvases: Object) {
canvasId,
canvasIdent,
canvasSize,
canvasStartDate,
canvasMaxTiledZoom: getMaxTiledZoom(canvasSize),
palette: new Palette(colors, 0),
view: [x, y],
@ -95,6 +110,7 @@ function getViewFromURL(canvases: Object) {
canvasId: DEFAULT_CANVAS_ID,
canvasIdent: canvases[DEFAULT_CANVAS_ID].ident,
canvasSize: canvases[DEFAULT_CANVAS_ID].size,
canvasStartDate: null,
canvasMaxTiledZoom: getMaxTiledZoom(canvases[DEFAULT_CANVAS_ID].size),
palette: new Palette(canvases[DEFAULT_CANVAS_ID].colors, 0),
view: getGivenCoords(),
@ -344,15 +360,23 @@ export default function gui(
}
case 'SELECT_CANVAS': {
const { canvasId } = action;
let { canvasId } = action;
const { canvases, chunks } = state;
chunks.clear();
const canvas = canvases[canvasId];
const canvasIdent = canvas.ident;
const canvasSize = canvases[canvasId].size;
let canvas = canvases[canvasId];
if (!canvas) {
canvasId = DEFAULT_CANVAS_ID;
canvas = canvases[DEFAULT_CANVAS_ID];
}
const {
size: canvasSize,
sd: canvasStartDate,
ident: canvasIdent,
colors,
} = canvas;
const canvasMaxTiledZoom = getMaxTiledZoom(canvasSize);
const palette = new Palette(canvas.colors, 0);
const palette = new Palette(colors, 0);
const view = (canvasId === 0) ? getGivenCoords() : [0, 0];
chunks.clear();
return {
@ -360,6 +384,7 @@ export default function gui(
canvasId,
canvasIdent,
canvasSize,
canvasStartDate,
canvasMaxTiledZoom,
palette,
view,
@ -377,15 +402,20 @@ export default function gui(
canvasId = DEFAULT_CANVAS_ID;
canvasIdent = canvases[DEFAULT_CANVAS_ID].ident;
}
const canvasSize = canvases[canvasId].size;
const {
size: canvasSize,
sd: canvasStartDate,
colors,
} = canvases[canvasId];
const canvasMaxTiledZoom = getMaxTiledZoom(canvasSize);
const palette = new Palette(canvases[canvasId].colors, 0);
const palette = new Palette(colors, 0);
return {
...state,
canvasId,
canvasIdent,
canvasSize,
canvasStartDate,
canvasMaxTiledZoom,
palette,
canvases,