Skip to content

Commit

Permalink
Add method to OutfitStore to check if layer uses "skin" coloring
Browse files Browse the repository at this point in the history
  • Loading branch information
AntumDeluge committed Jul 29, 2024
1 parent 8ad155e commit bc45b9b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
14 changes: 14 additions & 0 deletions src/js/stendhal/data/OutfitStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export class OutfitStore {
// layer names in draw order
private static readonly layers: string[] = ["body", "dress", "head", "mouth", "eyes", "mask", "hair", "hat", "detail"];
private static readonly layersLegacy: string[] = ["body", "dress", "head", "hair", "detail"];
// layers using skin coloring
private static readonly skinLayers: string[] = ["body", "head"];

private detailRearLayers: number[] = [];

Expand Down Expand Up @@ -84,6 +86,18 @@ export class OutfitStore {
return [...OutfitStore.layers];
}

/**
* Determines if a layer uses skin coloring.
*
* @param name {string}
* Layer name.
* @return {boolean}
* `true` if the layer is considered to be a "skin" layer.
*/
isSkinLayer(name: string): boolean {
return OutfitStore.skinLayers.indexOf(name) > -1;
}

/**
* Determines if hair should be drawn under a determinted hat index.
*
Expand Down
2 changes: 1 addition & 1 deletion src/js/stendhal/entity/RPEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ export class RPEntity extends ActiveEntity {
const filename = stendhal.paths.sprites + "/outfit/" + part + "/" + n + ".png";
let color: any;
if (this.outfit) {
if (part === "body" || part === "head") {
if (singletons.getOutfitStore().isSkinLayer(part)) {
color = this.outfit.getLayerColor("skin");
} else {
color = this.outfit.getLayerColor(part);
Expand Down
7 changes: 2 additions & 5 deletions src/js/stendhal/ui/dialog/outfit/OutfitDialog.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************
* (C) Copyright 2007-2023 - Faiumoni e. V. *
* (C) Copyright 2007-2024 - Faiumoni e. V. *
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
Expand Down Expand Up @@ -180,10 +180,7 @@ export class OutfitDialog extends DialogContentComponent {
initialColorValue(part: string) {
const colors = marauroa.me["outfit_colors"];
if (colors != null) {
let colorName = part;
if (part === "body" || part === "head") {
colorName = "skin";
}
const colorName = stendhal.data.outfit.isSkinLayer(part) ? "skin" : part;

let layer_color = colors[colorName + "_orig"];
if (layer_color === undefined) {
Expand Down

0 comments on commit bc45b9b

Please sign in to comment.