kopia lustrzana https://github.com/backface/turtlestitch
indicate empty categories in single-palette mode
rodzic
408070b360
commit
af68f7a78e
|
@ -68,6 +68,7 @@
|
|||
* gui, translations: removed old hidden "virtual keyboard" setting
|
||||
* gui: removed old hidden "project urls" setting
|
||||
* gui: removed hidden "cache inputs" setting (only used for debugging the evaluator)
|
||||
* gui, objects: indicate empty categories in single-palette mode
|
||||
|
||||
### 2021-11-14
|
||||
* locale: contextualize translations
|
||||
|
|
12
src/gui.js
12
src/gui.js
|
@ -1276,6 +1276,14 @@ IDE_Morph.prototype.createCategories = function () {
|
|||
if (cat.state) {
|
||||
cat.scrollIntoView();
|
||||
}
|
||||
|
||||
// indicate whether a category is empty of blocks to show
|
||||
// currently only supported in unified palette mode
|
||||
if (myself.currentSprite.emptyCategoriesCache[cat.category]) {
|
||||
cat.disable();
|
||||
} else {
|
||||
cat.enable();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1322,6 +1330,7 @@ IDE_Morph.prototype.createCategories = function () {
|
|||
true // has preview
|
||||
);
|
||||
|
||||
button.category = category;
|
||||
button.corner = 8;
|
||||
button.padding = 0;
|
||||
button.labelShadowOffset = new Point(-1, -1);
|
||||
|
@ -1358,6 +1367,7 @@ IDE_Morph.prototype.createCategories = function () {
|
|||
true // has preview
|
||||
);
|
||||
|
||||
button.category = category;
|
||||
button.corner = 8;
|
||||
button.padding = 0;
|
||||
button.labelShadowOffset = new Point(-1, -1);
|
||||
|
@ -2806,6 +2816,7 @@ IDE_Morph.prototype.selectSprite = function (sprite) {
|
|||
}
|
||||
this.currentSprite = sprite;
|
||||
this.scene.currentSprite = sprite;
|
||||
this.categories.refresh(); // indicate empty categories in unified palette
|
||||
this.createPalette();
|
||||
this.createSpriteBar();
|
||||
this.createSpriteEditor();
|
||||
|
@ -6256,6 +6267,7 @@ IDE_Morph.prototype.toggleStageSize = function (isSmall, forcedRatio) {
|
|||
|
||||
IDE_Morph.prototype.toggleUnifiedPalette = function () {
|
||||
this.setUnifiedPalette(!this.scene.unifiedPalette);
|
||||
this.categories.refresh(); // update empty categories in single palette mode
|
||||
};
|
||||
|
||||
IDE_Morph.prototype.setUnifiedPalette = function (bool) {
|
||||
|
|
|
@ -1870,6 +1870,7 @@ SpriteMorph.prototype.init = function (globals) {
|
|||
|
||||
this.primitivesCache = {}; // not to be serialized (!)
|
||||
this.paletteCache = {}; // not to be serialized (!)
|
||||
this.emptyCategoriesCache = {}; // not to be serialized;
|
||||
this.rotationOffset = ZERO; // not to be serialized (!)
|
||||
this.idx = 0; // not to be serialized (!) - used for de-serialization
|
||||
|
||||
|
@ -1935,6 +1936,7 @@ SpriteMorph.prototype.fullCopy = function (forClone) {
|
|||
c.freqPlayer = null;
|
||||
c.primitivesCache = {};
|
||||
c.paletteCache = {};
|
||||
c.emptyCategoriesCache = {};
|
||||
c.imageData = {};
|
||||
c.cachedColorDimensions = c.color[this.penColorModel]();
|
||||
arr = [];
|
||||
|
@ -3011,6 +3013,14 @@ SpriteMorph.prototype.freshPalette = function (category) {
|
|||
searchButton,
|
||||
makeButton;
|
||||
|
||||
function isEmptyCategory(blocks) {
|
||||
return blocks.filter(each =>
|
||||
each instanceof BlockMorph && !myself.isHidingBlock(each)
|
||||
).length === 0;
|
||||
}
|
||||
|
||||
this.emptyCategoriesCache = {};
|
||||
|
||||
palette.owner = this;
|
||||
palette.padding = unit / 2;
|
||||
palette.color = this.paletteColor;
|
||||
|
@ -3088,7 +3098,7 @@ SpriteMorph.prototype.freshPalette = function (category) {
|
|||
// In a Unified Palette custom blocks appear following each category,
|
||||
// but there is only 1 make a block button (at the end).
|
||||
showCategories = this.parentThatIsA(IDE_Morph).scene.showCategories;
|
||||
blocks = SpriteMorph.prototype.allCategories().reduce( // +++
|
||||
blocks = SpriteMorph.prototype.allCategories().reduce(
|
||||
(blocks, category) => {
|
||||
let header = [this.categoryText(category), '-'],
|
||||
primitives = this.getPrimitiveTemplates(category),
|
||||
|
@ -3103,6 +3113,11 @@ SpriteMorph.prototype.freshPalette = function (category) {
|
|||
each !== '-' && each !== '=');
|
||||
}
|
||||
|
||||
// update the empty categories cache
|
||||
if (isEmptyCategory(primitives) && isEmptyCategory(customs)) {
|
||||
this.emptyCategoriesCache[category] = true;
|
||||
}
|
||||
|
||||
return blocks.concat(
|
||||
showHeader ? header : [],
|
||||
primitives,
|
||||
|
@ -7772,6 +7787,7 @@ StageMorph.prototype.init = function (globals) {
|
|||
this.keysPressed = {}; // for handling keyboard events, do not persist
|
||||
this.primitivesCache = {}; // not to be serialized (!)
|
||||
this.paletteCache = {}; // not to be serialized (!)
|
||||
this.emptyCategoriesCache = {}; // not to be serialized (!)
|
||||
this.lastAnswer = ''; // last user input, do not persist
|
||||
this.activeSounds = []; // do not persist
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue