Add toggle for fusion palette swaps

pull/16/head
Flashfyre 2024-03-05 21:54:26 -05:00
parent 9ee254a18a
commit 50b9bf10a7
3 changed files with 22 additions and 11 deletions

View File

@ -98,6 +98,7 @@ export default class BattleScene extends Phaser.Scene {
public enableTutorials: boolean = true;
public windowType: integer = 1;
public experimentalSprites: boolean = false;
public fusionPaletteSwaps: boolean = true;
public enableTouchControls: boolean = false;
public enableVibration: boolean = false;
public finalWave: integer = 200;

View File

@ -1,3 +1,4 @@
import BattleScene from "../battle-scene";
import Pokemon from "../field/pokemon";
import Trainer from "../field/trainer";
import FieldSpritePipeline from "./field-sprite";
@ -335,8 +336,6 @@ export default class SpritePipeline extends FieldSpritePipeline {
const teraColor = data['teraColor'] as integer[] ?? [ 0, 0, 0 ];
const hasShadow = data['hasShadow'] as boolean;
const ignoreOverride = data['ignoreOverride'] as boolean;
const spriteColors = (ignoreOverride && data['spriteColorsBase']) || data['spriteColors'] || [] as number[][];
const fusionSpriteColors = (ignoreOverride && data['fusionSpriteColorsBase']) || data['fusionSpriteColors'] || [] as number[][];
const isEntityObj = sprite.parentContainer instanceof Pokemon || sprite.parentContainer instanceof Trainer;
const field = isEntityObj ? sprite.parentContainer.parentContainer : sprite.parentContainer;
@ -362,16 +361,21 @@ export default class SpritePipeline extends FieldSpritePipeline {
this.set1f('yOffset', sprite.height - sprite.frame.height * (isEntityObj ? sprite.parentContainer.scale : sprite.scale));
this.set4fv('tone', tone);
this.bindTexture(this.game.textures.get('tera').source[0].glTexture, 1);
const emptyColors = [ 0, 0, 0, 0 ];
const flatSpriteColors: integer[] = [];
const flatFusionSpriteColors: integer[] = [];
for (let c = 0; c < 32; c++) {
flatSpriteColors.splice(flatSpriteColors.length, 0, c < spriteColors.length ? spriteColors[c] : emptyColors);
flatFusionSpriteColors.splice(flatFusionSpriteColors.length, 0, c < fusionSpriteColors.length ? fusionSpriteColors[c] : emptyColors);
}
if ((gameObject.scene as BattleScene).fusionPaletteSwaps) {
const spriteColors = (ignoreOverride && data['spriteColorsBase']) || data['spriteColors'] || [] as number[][];
const fusionSpriteColors = (ignoreOverride && data['fusionSpriteColorsBase']) || data['fusionSpriteColors'] || [] as number[][];
this.set4iv(`spriteColors`, flatSpriteColors.flat());
this.set4iv(`fusionSpriteColors`, flatFusionSpriteColors.flat());
const emptyColors = [ 0, 0, 0, 0 ];
const flatSpriteColors: integer[] = [];
const flatFusionSpriteColors: integer[] = [];
for (let c = 0; c < 32; c++) {
flatSpriteColors.splice(flatSpriteColors.length, 0, c < spriteColors.length ? spriteColors[c] : emptyColors);
flatFusionSpriteColors.splice(flatFusionSpriteColors.length, 0, c < fusionSpriteColors.length ? fusionSpriteColors[c] : emptyColors);
}
this.set4iv(`spriteColors`, flatSpriteColors.flat());
this.set4iv(`fusionSpriteColors`, flatFusionSpriteColors.flat());
}
}
batchQuad(gameObject: Phaser.GameObjects.GameObject, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number,

View File

@ -12,6 +12,7 @@ export enum Setting {
Window_Type = "WINDOW_TYPE",
Tutorials = "TUTORIALS",
Sprite_Set = "SPRITE_SET",
Fusion_Palette_Swaps = "FUSION_PALETTE_SWAPS",
Player_Gender = "PLAYER_GENDER",
Touch_Controls = "TOUCH_CONTROLS",
Vibration = "VIBRATION"
@ -35,6 +36,7 @@ export const settingOptions: SettingOptions = {
[Setting.Window_Type]: new Array(4).fill(null).map((_, i) => (i + 1).toString()),
[Setting.Tutorials]: [ 'Off', 'On' ],
[Setting.Sprite_Set]: [ 'Consistent', 'Prioritize Animation' ],
[Setting.Fusion_Palette_Swaps]: [ 'Off', 'On' ],
[Setting.Player_Gender]: [ 'Boy', 'Girl' ],
[Setting.Touch_Controls]: [ 'Auto', 'Disabled' ],
[Setting.Vibration]: [ 'Auto', 'Disabled' ]
@ -50,6 +52,7 @@ export const settingDefaults: SettingDefaults = {
[Setting.Window_Type]: 0,
[Setting.Tutorials]: 1,
[Setting.Sprite_Set]: 0,
[Setting.Fusion_Palette_Swaps]: 1,
[Setting.Player_Gender]: 0,
[Setting.Touch_Controls]: 0,
[Setting.Vibration]: 0
@ -89,6 +92,9 @@ export function setSetting(scene: BattleScene, setting: Setting, value: integer)
if (value)
scene.initExpSprites();
break;
case Setting.Fusion_Palette_Swaps:
scene.fusionPaletteSwaps = !!value;
break;
case Setting.Player_Gender:
if (scene.gameData) {
const female = settingOptions[setting][value] === 'Girl';