diff --git a/src/components/GlyphTooltip.vue b/src/components/GlyphTooltip.vue index c874c1eb9..fab91e9a0 100644 --- a/src/components/GlyphTooltip.vue +++ b/src/components/GlyphTooltip.vue @@ -98,7 +98,7 @@ export default { }, descriptionStyle() { const color = GlyphAppearanceHandler.getRarityColor(this.strength); - const cursedColor = player.options.lightGlyphs ? "white" : "black"; + const cursedColor = GlyphAppearanceHandler.isLightBG ? "white" : "black"; return { color: this.type === "cursed" ? cursedColor : color, animation: this.type === "reality" ? "a-reality-glyph-name-cycle 10s infinite" : undefined @@ -167,7 +167,7 @@ export default { const isCursed = this.type === "cursed"; const isReality = this.type === "reality"; - let color = Theme.current().isDark() ? this.rarityInfo.darkColor : this.rarityInfo.lightColor; + let color = GlyphAppearanceHandler.getRarityColor(this.strength); if (isCursed) color = this.textColor; if (this.type === "companion") color = GlyphAppearanceHandler.getBorderColor(this.type); return { diff --git a/src/components/GlyphTooltipEffect.vue b/src/components/GlyphTooltipEffect.vue index 1d81b653f..6da659bc2 100644 --- a/src/components/GlyphTooltipEffect.vue +++ b/src/components/GlyphTooltipEffect.vue @@ -76,7 +76,7 @@ export default { .replace("\n", "
") .replace("]", "") .replace( - "[", `` diff --git a/src/components/modals/GlyphShowcasePanelEntry.vue b/src/components/modals/GlyphShowcasePanelEntry.vue index 0f15dd432..0a9489084 100644 --- a/src/components/modals/GlyphShowcasePanelEntry.vue +++ b/src/components/modals/GlyphShowcasePanelEntry.vue @@ -80,9 +80,10 @@ export default { }; }, rarityStyle() { + // Rarity is handled differently here than usual because this is in contrast with the theme BG, not the glyph BG const color = CosmeticGlyphTypes[this.glyph.type].ignoreRarityColor ? GlyphAppearanceHandler.getBorderColor(this.type) - : GlyphAppearanceHandler.getRarityColor(this.glyph.strength); + : getRarity(this.glyph.strength)[Theme.current().isDark() ? "darkColor" : "lightColor"]; return { color, "font-weight": "bold" diff --git a/src/components/modals/options/glyph-appearance/GlyphCustomizationSlidingWindow.vue b/src/components/modals/options/glyph-appearance/GlyphCustomizationSlidingWindow.vue index 284ed28ba..241d188c0 100644 --- a/src/components/modals/options/glyph-appearance/GlyphCustomizationSlidingWindow.vue +++ b/src/components/modals/options/glyph-appearance/GlyphCustomizationSlidingWindow.vue @@ -68,7 +68,7 @@ export default { this.isActive = player.reality.glyphs.cosmetics.active; } if (this.type === "reality" && !this.isSymbol) this.realityColor = GlyphAppearanceHandler.realityColor; - this.darkKeySwap = !player.options.lightGlyphs; + this.darkKeySwap = player.options.glyphBG; }, select(option) { if (!this.isSingleGlyph && !this.isActive) return; diff --git a/src/components/modals/options/glyph-appearance/GlyphDisplayOptionsModal.vue b/src/components/modals/options/glyph-appearance/GlyphDisplayOptionsModal.vue index 1c750962d..ca2ba951e 100644 --- a/src/components/modals/options/glyph-appearance/GlyphDisplayOptionsModal.vue +++ b/src/components/modals/options/glyph-appearance/GlyphDisplayOptionsModal.vue @@ -19,7 +19,7 @@ export default { return { newGlyphs: false, glyphEffectDots: false, - lightGlyphs: false, + glyphBG: 0, glyphInfoType: 0, showGlyphInfoByDefault: false, }; @@ -28,6 +28,18 @@ export default { infoLabel() { return GlyphInfo.labels[this.glyphInfoType]; }, + glyphBGStr() { + switch (this.glyphBG) { + case GLYPH_BG_SETTING.AUTO: + return "AUTO"; + case GLYPH_BG_SETTING.LIGHT: + return "Light"; + case GLYPH_BG_SETTING.DARK: + return "Dark"; + default: + throw new Error("Unrecognized Glyph BG setting"); + } + } }, watch: { newGlyphs(newValue) { @@ -38,10 +50,6 @@ export default { player.options.showHintText.glyphEffectDots = newValue; EventHub.dispatch(GAME_EVENT.GLYPH_VISUAL_CHANGE); }, - lightGlyphs(newValue) { - player.options.lightGlyphs = newValue; - EventHub.dispatch(GAME_EVENT.GLYPH_VISUAL_CHANGE); - }, showGlyphInfoByDefault(newValue) { player.options.showHintText.showGlyphInfoByDefault = newValue; EventHub.dispatch(GAME_EVENT.GLYPH_VISUAL_CHANGE); @@ -52,7 +60,7 @@ export default { const options = player.options; this.newGlyphs = options.showNewGlyphIcon; this.glyphEffectDots = options.showHintText.glyphEffectDots; - this.lightGlyphs = options.lightGlyphs; + this.glyphBG = player.options.glyphBG; this.glyphInfoType = options.showHintText.glyphInfoType; this.showGlyphInfoByDefault = options.showHintText.showGlyphInfoByDefault; }, @@ -62,6 +70,10 @@ export default { "background-color": "var(--color-disabled)", }; }, + cycleBG() { + player.options.glyphBG = (player.options.glyphBG + 1) % Object.keys(GLYPH_BG_SETTING).length; + EventHub.dispatch(GAME_EVENT.GLYPH_VISUAL_CHANGE); + }, }, }; @@ -80,10 +92,12 @@ export default { v-model="glyphEffectDots" text="Always show Glyph effect dots:" /> - + diff --git a/src/core/constants.js b/src/core/constants.js index b02baac0d..9a14df040 100644 --- a/src/core/constants.js +++ b/src/core/constants.js @@ -226,7 +226,8 @@ window.TS171_MULTIPLIER = 1.25; // Used as drag and drop data type window.GLYPH_MIME_TYPE = "text/x-ivark-glyph"; -// These need to be in descending order for searching over them to work trivially +// These need to be in descending order for searching over them to work trivially, and all need to be hex codes +// in order for reality glyph color parsing to work properly in the cosmetic handler window.GlyphRarities = [ { minStrength: 3.5, @@ -266,11 +267,17 @@ window.GlyphRarities = [ }, { minStrength: 1, name: "Common", - darkColor: "white", - lightColor: "black" + darkColor: "#ffffff", + lightColor: "#000000" }, ]; +window.GLYPH_BG_SETTING = { + AUTO: 0, + LIGHT: 1, + DARK: 2, +}; + window.GLYPH_TYPES = [ "power", "infinity", diff --git a/src/core/glyphs/glyph-cosmetics.js b/src/core/glyphs/glyph-cosmetics.js index 624a6d9c8..2e9bf60fa 100644 --- a/src/core/glyphs/glyph-cosmetics.js +++ b/src/core/glyphs/glyph-cosmetics.js @@ -26,7 +26,7 @@ class CosmeticGlyphType { get defaultColor() { const color = this.id === "reality" ? GlyphAppearanceHandler.realityColor : this._defaultColor; - const isNormallyDark = !player.options.lightGlyphs; + const isNormallyDark = !GlyphAppearanceHandler.isLightBG; return { border: color, bg: (isNormallyDark === (this.id === "cursed")) ? "white" : "black", @@ -153,14 +153,25 @@ export const GlyphAppearanceHandler = { return ShopPurchaseData.singleCosmeticSet + player.records.fullGameCompletions; }, + // Returns true for "light" BG glyphs and false for "dark" BG glyphs + get isLightBG() { + switch (player.options.glyphBG) { + case GLYPH_BG_SETTING.AUTO: + return !Theme.current().isDark(); + case GLYPH_BG_SETTING.LIGHT: + return true; + case GLYPH_BG_SETTING.DARK: + return false; + default: + throw new Error("Unrecognized Glyph BG setting"); + } + }, getBorderColor(type) { - if (type === "cursed" && !CosmeticGlyphTypes.cursed.currentColor.str) - return player.options.lightGlyphs ? "white" : "black"; + if (type === "cursed" && !CosmeticGlyphTypes.cursed.currentColor.str) return this.isLightBG ? "white" : "black"; return CosmeticGlyphTypes[type].currentColor.border; }, getRarityColor(strength) { - const isDarkBG = !player.options.lightGlyphs; - return getRarity(strength)[isDarkBG ? "darkColor" : "lightColor"]; + return getRarity(strength)[this.isLightBG ? "lightColor" : "darkColor"]; }, getColorProps(colorStr) { // This condition is a bit odd - this specifically selects out the hybrid custom colors which have both a BG color @@ -168,7 +179,7 @@ export const GlyphAppearanceHandler = { if (colorStr?.charAt(1) !== "#") { return { border: colorStr, - bg: player.options.lightGlyphs ? "white" : "black", + bg: this.isLightBG ? "white" : "black", }; } return { @@ -178,7 +189,7 @@ export const GlyphAppearanceHandler = { }, // Only used to ensure readable glyph tooltips getBaseColor(isInverted) { - const isNormallyDark = !player.options.lightGlyphs; + const isNormallyDark = !this.isLightBG; if (isInverted) return isNormallyDark ? "white" : "black"; return isNormallyDark ? "black" : "white"; }, diff --git a/src/core/player.js b/src/core/player.js index 4a110d5fe..9e4544ddd 100644 --- a/src/core/player.js +++ b/src/core/player.js @@ -801,7 +801,7 @@ window.player = { ignoreGlyphEffects: false, ignoreGlyphLevel: false, ignoreGlyphRarity: false, - lightGlyphs: false, + glyphBG: GLYPH_BG_SETTING.AUTO, showHintText: { showPercentage: true, achievements: true, diff --git a/src/core/storage/migrations.js b/src/core/storage/migrations.js index b72e4863d..824d0e67f 100644 --- a/src/core/storage/migrations.js +++ b/src/core/storage/migrations.js @@ -345,6 +345,10 @@ GameStorage.migrations = { }; const allGlyphs = player.reality.glyphs.active.concat(player.reality.glyphs.inventory); for (const glyph of allGlyphs) glyph.effects = updateBitmask(glyph.effects); + + // Glyph light/dark formatting was refactored as well; these values are in reference to the GLYPH_BG_SETTING enum + player.options.glyphBG = player.options.lightGlyphs ? 1 : 2; + delete player.options.lightGlyphs; }, },