Skip to content

Commit 4372069

Browse files
committed
bug fixes and optimizations
1 parent 8214dc3 commit 4372069

File tree

6 files changed

+60
-60
lines changed

6 files changed

+60
-60
lines changed

src/script/public/Game/CellGenerator.js

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,35 +49,13 @@ function generateCell(index) {
4949
// configure cell size
5050
const ConfigureCellSize = (cell, xCell_Amount) => {
5151
// configure cell size
52-
if (xCell_Amount == 5) {
53-
cell.style.fontSize = "76px";
52+
const maxGridSize = "var(--max-cellGrid-size)";
5453

55-
} else if (xCell_Amount == 10) {
56-
cell.style.fontSize = "47px";
57-
58-
} else if (xCell_Amount == 15) {
59-
cell.style.fontSize = "24px";
60-
61-
} else if (xCell_Amount == 20) {
62-
cell.style.fontSize = "20.5px";
63-
64-
// KI specified Game Boards
65-
} else if (xCell_Amount == 3) {
66-
cell.style.fontSize = "100px";
67-
68-
} else if (xCell_Amount == 4) {
69-
cell.style.fontSize = "88px";
70-
71-
// Advanced Game Boards
72-
} else if (xCell_Amount == 25) {
73-
cell.style.fontSize = "13.5px";
74-
75-
} else if (xCell_Amount == 30) {
76-
cell.style.fontSize = "11px";
77-
78-
} else if (xCell_Amount == 40) {
79-
cell.style.fontSize = "var(--font-size-for-40x40-field)";
54+
if (xCell_Amount <= 25) {
55+
cell.style.fontSize = `calc((${maxGridSize} / ${xCell_Amount}) - 10px)`;
8056

57+
} else {
58+
cell.style.fontSize = `calc((${maxGridSize} / ${xCell_Amount}) - 5px)`;
8159
};
8260

8361
return cell;

src/script/public/Game/CreateGame.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ class NewLevel {
719719
for (const [pattern, index] of Object.entries(costumPatterns)) {
720720
console.log(pattern, index);
721721

722-
createPattern_preview(pattern, index[pattern]["structure"].map(i => Number(i)), costum_patterns_overview_from_level, "level");
722+
createPattern_preview(pattern, index[pattern]["structure"].map(i => Number(i)), costum_patterns_overview_from_level, "remove");
723723
};
724724
};
725725

@@ -743,7 +743,7 @@ class NewLevel {
743743
let y = costumField["y"];
744744
let name = costumField["name"];
745745

746-
createPattern_preview(name, [], costumFieldCurrentLevelGrid, "level", undefined, x, "scroll", undefined, y, "field");
746+
createPattern_preview(name, [], costumFieldCurrentLevelGrid, "remove", undefined, x, "scroll", undefined, y, "field");
747747
};
748748

749749
// init and start game with given game data
@@ -959,8 +959,6 @@ class NewLevel {
959959
};
960960
};
961961

962-
this.SaveInHistory("costumPatterns", this.CurrentSelectedSetting.costumPatterns);
963-
964962
console.log(this.CurrentSelectedSetting.costumPatterns);
965963
};
966964

@@ -983,8 +981,6 @@ class NewLevel {
983981
this.CurrentSelectedSetting.costumField = {};
984982
};
985983

986-
this.SaveInHistory("costumField", this.CurrentSelectedSetting.costumField);
987-
988984
console.log(this.CurrentSelectedSetting.costumField);
989985
};
990986

src/script/public/Game/CreateGameLibrary/UserCostumStuff.js

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const createCell = (x, index, grid, eventListener) => {
116116
};
117117

118118
// update cell. toggle its content
119-
const createField_updateCell = (i, parentGrid, fromPreview) => {
119+
const createField_updateCell = (i, parentGrid, fromPreview, cellClass = "cell") => {
120120
let userInfoClass = localStorage.getItem("userInfoClass");
121121
let userInfoColor = localStorage.getItem("userInfoColor");
122122
let UserIcon = localStorage.getItem("UserIcon");
@@ -126,15 +126,15 @@ const createField_updateCell = (i, parentGrid, fromPreview) => {
126126
// check if cell is empty or not
127127
if (cell.classList.contains("draw")) { // cell is full. empty it
128128
// reset cell
129-
cell.className = `cell ${fromPreview}`;
129+
cell.className = `${cellClass} ${fromPreview}`;
130130
cell.textContent = null;
131131
cell.style.color = "white";
132132

133133
} else { // cell is empty. draw on it
134134

135135
// user uses advaned skin
136136
if (userInfoClass != "empty") {
137-
cell.className = `cell ${fromPreview} ${userInfoClass}`;
137+
cell.className = `${cellClass} ${fromPreview} ${userInfoClass}`;
138138

139139
} else { // user uses normal color skin
140140

@@ -248,16 +248,23 @@ const Display_CostumPatterns = () => {
248248
// delete previous content
249249
costum_patterns_overview.textContent = null;
250250

251-
if (Object.keys(patterns).length <= 0) costum_patterns_overview.textContent = "No costum patterns are created yet.";
251+
if (patterns) {
252+
if (Object.keys(patterns).length <= 0) costum_patterns_overview.textContent = "No costum patterns are created yet.";
252253

253-
// creates pattern html element from an object
254-
Object.keys(patterns).forEach(pattName => {
255-
let pattStructure = patterns[pattName];
254+
// creates pattern html element from an object
255+
Object.keys(patterns).forEach(pattName => {
256+
let pattStructure = patterns[pattName];
256257

257-
createPattern_preview(pattName, pattStructure, costum_patterns_overview, "personal");
258-
});
258+
createPattern_preview(pattName, pattStructure, costum_patterns_overview, "personal");
259+
});
259260

260-
NewCreativeLevel.InitCostumPatterns(NewCreativeLevel.CurrentSelectedSetting.costumPatterns);
261+
NewCreativeLevel.InitCostumPatterns(NewCreativeLevel.CurrentSelectedSetting.costumPatterns);
262+
263+
} else {
264+
costum_patterns_overview.textContent = "No costum patterns are created yet.";
265+
266+
NewCreativeLevel.InitCostumPatterns({});
267+
};
261268
};
262269

263270
// displays all fields stored in localstorage in "own fields" tab container
@@ -267,18 +274,25 @@ const Display_CostumFields = () => {
267274
// delete previous content
268275
costum_field_overview.textContent = null;
269276

270-
if (Object.keys(fields).length <= 0) costum_field_overview.textContent = "No costum fields are created yet.";
277+
if (fields) {
278+
if (Object.keys(fields).length <= 0) costum_field_overview.textContent = "No costum fields are created yet.";
271279

272-
// creates pattern html element from an object
273-
Object.keys(fields).forEach(key => {
274-
let name = fields[key]["name"];
275-
let x = fields[key]["x"];
276-
let y = fields[key]["y"];
280+
// creates pattern html element from an object
281+
Object.keys(fields).forEach(key => {
282+
let name = fields[key]["name"];
283+
let x = fields[key]["x"];
284+
let y = fields[key]["y"];
277285

278-
createPattern_preview(name, [], costum_field_overview, "personal", undefined, x, "scroll", undefined, y, "field");
279-
});
286+
createPattern_preview(name, [], costum_field_overview, "personal", undefined, x, "scroll", undefined, y, "field");
287+
});
280288

281-
NewCreativeLevel.InitCostumField(NewCreativeLevel.CurrentSelectedSetting.costumField);
289+
NewCreativeLevel.InitCostumField(NewCreativeLevel.CurrentSelectedSetting.costumField);
290+
291+
} else {
292+
costum_field_overview.textContent = "No costum fields are created yet.";
293+
294+
NewCreativeLevel.InitCostumField({});
295+
};
282296
};
283297

284298
// create pattern preview element
@@ -308,7 +322,7 @@ const createPattern_preview = (patternName, patternStructure, parent, rights, sp
308322
createPattern_checkPatternInLevel(checkBox, patternName, patternStructure, gridType);
309323

310324
// create basic 5x5 grid
311-
createPattern_createGrid(patternStructure, gridRows, y, grid);
325+
createPattern_createGrid(patternStructure, gridRows, y, grid, rights);
312326

313327
// event listener
314328
createPattern_eventListener(pen, bin, checkBox, bin2, patternStructure, patternName, gridType, Number(gridRows), Number(y));
@@ -338,7 +352,14 @@ const createPattern_preview = (patternName, patternStructure, parent, rights, sp
338352
gridWrapper.setAttribute("right", "personal");
339353

340354
} else if (rights == "level") {
355+
341356
gridWrapper.setAttribute("right", "level");
357+
358+
} else if (rights == "remove") {
359+
360+
editItemsWrapper.appendChild(bin2);
361+
362+
gridWrapper.setAttribute("right", "remove");
342363
};
343364

344365
setTimeout(() => {
@@ -370,6 +391,7 @@ const createPattern_addAttributes = (gridWrapper, patternName, grid, title, head
370391
checkBox.style.fontSize = "larger";
371392
grid.style.gridTemplateColumns = `repeat(${gridRows}, 1fr)`;
372393
title.textContent = patternName;
394+
title.style.fontSize = "medium";
373395
};
374396

375397
// check if this pattern exists in the current creative level
@@ -395,11 +417,13 @@ const createPattern_checkPatternInLevel = (checkBox, patternName, patternStructu
395417
};
396418

397419
// create grid and grid pattern if exists to the grid
398-
const createPattern_createGrid = (patternStructure, gridRows, y, grid) => {
420+
const createPattern_createGrid = (patternStructure, gridRows, y, grid, rights) => {
421+
let cellClass = rights == "level" ? "miniCellMini" : "cell";
422+
399423
new Array(gridRows * y).fill("").forEach(i => {
400424
let cell = document.createElement("div");
401425
cell.classList.add("preview_cell");
402-
cell.classList.add("cell");
426+
cell.classList.add(cellClass);
403427

404428
grid.appendChild(cell);
405429
});
@@ -409,7 +433,7 @@ const createPattern_createGrid = (patternStructure, gridRows, y, grid) => {
409433
let index = parseInt(i);
410434

411435
// console.log(index, i, grid, grid.children[index]);
412-
createField_updateCell(index, grid, "preview_cell");
436+
createField_updateCell(index, grid, "preview_cell", cellClass);
413437
});
414438
};
415439

@@ -482,7 +506,7 @@ const createPattern_scrollgrid = (gridWrapper, grid, Yscroll, Xscroll) => {
482506
};
483507

484508
if (Xscroll === undefined) {
485-
gridWrapper.style.overflowX = "unset";
509+
gridWrapper.style.overflowX = "hidden";
486510
};
487511
};
488512

src/script/public/Game/Game.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ const ChangeGameBG = (bg1, bg2, reset) => {
629629

630630
// the normal card level in complex toe als have bg colors to make them more unique etc.
631631
const SetBGColorForCurrentField = (xy) => {
632-
if (localStorage.getItem("sett-ShowBGColor") == "true") {
632+
if (localStorage.getItem("sett-ShowBGColor") == "true" && !NewCreativeLevel) {
633633
switch (xy) {
634634
case 5:
635635
bgcolor1 = "#e9967a57";

src/script/public/Game/PlayerClocks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ function removeAccessToAnything() {
4545
globalChooseWinnerBtn.style.color = '#56565659';
4646
restartBtn.removeEventListener('click', restartGame);
4747
restartBtn.style.color = '#56565659';
48-
console.log("lol")
49-
// CloseOnlinePopUps(true);
48+
// console.log("lol")
49+
// CloseOnlinePopUps(true);
5050
GiveUpPopUp.style.display = "none";
5151

5252
// remove access to set

src/script/public/index.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
--max-cellGrid-size: 585px;
1818
--CreateLevel-ScrollContainerHeight-max: 650px;
1919
--max-responsive-scale: scale(1);
20+
--maxCellSize: 425%;
2021
}
2122

2223
.dark-mode {
@@ -7943,6 +7944,7 @@ p.createCostumField_yInput {
79437944
--max-cellGrid-size: 442.5px;
79447945
--CreateLevel-ScrollContainerHeight-max: 450px;
79457946
--max-responsive-scale: scale(0.75);
7947+
--maxCellSize: 325%;
79467948
}
79477949
.skinShop-SkinColors {
79487950
gap: 1em;

0 commit comments

Comments
 (0)