mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-23 18:13:08 +00:00
base64
This commit is contained in:
@@ -48,27 +48,6 @@ export class territoryPatternsModal extends LitElement {
|
||||
this.updatePreview();
|
||||
});
|
||||
|
||||
for (const [key, p] of Object.entries(territoryPatterns.patterns)) {
|
||||
if (!p.pattern && p.patternBase64) {
|
||||
const bytes = Uint8Array.from(atob(p.patternBase64), (c) =>
|
||||
c.charCodeAt(0),
|
||||
);
|
||||
const bits = Array.from(bytes).flatMap((byte) =>
|
||||
[...Array(8)].map((_, i) => (byte >> (7 - i)) & 1),
|
||||
);
|
||||
const pattern: number[][] = [];
|
||||
for (let y = 0; y < p.tileHeight; y++) {
|
||||
const row: number[] = [];
|
||||
for (let x = 0; x < p.tileWidth; x++) {
|
||||
const index = y * p.tileWidth + x;
|
||||
row.push(bits[index] ?? 0);
|
||||
}
|
||||
pattern.push(row);
|
||||
}
|
||||
p.pattern = pattern;
|
||||
}
|
||||
}
|
||||
|
||||
this.setLockedPatterns(["evan"], {
|
||||
evan: "This pattern is locked because it is restricted.",
|
||||
});
|
||||
@@ -133,8 +112,8 @@ export class territoryPatternsModal extends LitElement {
|
||||
"
|
||||
>
|
||||
${(() => {
|
||||
const cellCountX = pattern.tileWidth;
|
||||
const cellCountY = pattern.tileHeight;
|
||||
const cellCountX = pattern.tileWidth ?? 1;
|
||||
const cellCountY = pattern.tileHeight ?? 1;
|
||||
const cellSize = Math.floor(
|
||||
this.buttonWidth / Math.max(cellCountX, cellCountY),
|
||||
);
|
||||
@@ -200,8 +179,8 @@ export class territoryPatternsModal extends LitElement {
|
||||
|
||||
const fixedHeight = 48;
|
||||
const fixedWidth = 48;
|
||||
const cellCountX = pattern.tileWidth;
|
||||
const cellCountY = pattern.tileHeight;
|
||||
const cellCountX = pattern.tileWidth ?? 1;
|
||||
const cellCountY = pattern.tileHeight ?? 1;
|
||||
|
||||
const cellSize = Math.min(
|
||||
fixedHeight / cellCountY,
|
||||
|
||||
Reference in New Issue
Block a user