Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Tattoos): Added Tattoo Opacity #22

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions locale/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"REMOVETATTOO_TITLE": "Fjern Tatovering",
"ADDTATTOO_TITLE": "Tilføj Tatovering",
"TATTOO_TITLE": "Tatovering",
"TATTOO_OPACITY": "Gennemsigtighed",
"DLCOPT_TITLE": "DLC Indstillinger",
"ZONE_TITLE": "Zone",
"MENU_TITLE": "Menu",
Expand Down
1 change: 1 addition & 0 deletions locale/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"REMOVETATTOO_TITLE": "Tattoo entfernen",
"ADDTATTOO_TITLE": "Tattoo hinzufügen",
"TATTOO_TITLE": "Tattoo",
"TATTOO_OPACITY": "Deckkraft",
"DLCOPT_TITLE": "DLC Optionen",
"ZONE_TITLE": "Zone",
"MENU_TITLE": "Menü",
Expand Down
1 change: 1 addition & 0 deletions locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"REMOVETATTOO_TITLE": "Remove Tattoo",
"ADDTATTOO_TITLE": "Add Tattoo",
"TATTOO_TITLE": "Tattoo",
"TATTOO_OPACITY": "Opacity",
"DLCOPT_TITLE": "DLC Options",
"ZONE_TITLE": "Zone",
"MENU_TITLE": "Menu",
Expand Down
1 change: 1 addition & 0 deletions locale/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"REMOVETATTOO_TITLE": "Eliminar Tatuaje",
"ADDTATTOO_TITLE": "Añadir Tatuaje",
"TATTOO_TITLE": "Tatuaje",
"TATTOO_OPACITY": "Opacidad",
"DLCOPT_TITLE": "Opciones de DLC",
"ZONE_TITLE": "Zona",
"MENU_TITLE": "Menú",
Expand Down
1 change: 1 addition & 0 deletions locale/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"REMOVETATTOO_TITLE": "Enlever le tatouage",
"ADDTATTOO_TITLE": "Ajouter un tatouage",
"TATTOO_TITLE": "Tatouage",
"TATTOO_OPACITY": "Opacité",
"DLCOPT_TITLE": "Options DLC",
"ZONE_TITLE": "Zone",
"MENU_TITLE": "Menu",
Expand Down
1 change: 1 addition & 0 deletions locale/np.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"REMOVETATTOO_TITLE": "ट्याटु हटाउनुहोस्",
"ADDTATTOO_TITLE": "ट्याटु थप्नुहोस्",
"TATTOO_TITLE": "ट्याटु",
"TATTOO_OPACITY": "अपारदर्शिता",
"DLCOPT_TITLE": "DLC विकल्पहरू",
"ZONE_TITLE": "क्षेत्र",
"MENU_TITLE": "मेनु",
Expand Down
7 changes: 5 additions & 2 deletions src/client/appearance/setters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,14 @@ export function setPedTattoos(pedHandle: number, data: TTattoo[]) {
ClearPedDecorationsLeaveScars(pedHandle)

for (let i = 0; i < data.length; i++) {
const tattooData = data[i].tattoo
const tattooData = data[i].tattoo;
if (tattooData) {
const collection = GetHashKey(tattooData.dlc)
const tattoo = tattooData.hash
AddPedDecorationFromHashes(pedHandle, collection, tattoo)
const tattooOpacity = Math.round((tattooData.opacity || 0.1) * 10)
for (let j = 1; j < tattooOpacity; j++) {
AddPedDecorationFromHashes(pedHandle, collection, tattoo);
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/typings/tattoos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export type TTattooEntry = {
label: string
hash: number
zone: number
opacity: number
dlc?: string
}

Expand Down
35 changes: 32 additions & 3 deletions web/src/components/menu/Tattoos.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<script lang="ts">
import { APPEARANCE, TATTOOS, LOCALE } from '@stores/appearance';
import { Send } from '@enums/events';
import type { TDLCTattoo, TTattooEntry } from '@typings/apperance';
import Wrapper from '@components/micro/Wrapper.svelte';
import IconPlus from '@components/icons/IconPlus.svelte';
import Stepper from '@components/micro/Stepper.svelte';
import { slide } from 'svelte/transition';
import Dropdown from '@components/micro/Dropdown.svelte';
import Divider from '@components/micro/Divider.svelte';
import Slider from '@components/micro/Slider.svelte';
import IconCancel from '@components/icons/IconCancel.svelte';
import { randomID } from '@utils/misc';
import { SendEvent } from '@utils/eventsHandlers';

let deleteOptionIndex: number = null;

Expand Down Expand Up @@ -71,6 +70,7 @@
if (dlcWithTattoos !== -1) {
newTattoo.dlcIndex = dlcWithTattoos;
newTattoo.tattoo = options[0].dlcs[dlcWithTattoos].tattoos[0];
newTattoo.tattoo.opacity = 0.1
}

playerTattoos = [...playerTattoos, newTattoo];
Expand Down Expand Up @@ -128,6 +128,15 @@

TATTOOS.setPlayerTattoos(playerTattoos);
}

function changeOpacity(playerTattoosIndex: number, opacity: number) {
let playerTattoo = playerTattoos[playerTattoosIndex]

if (!playerTattoo) return;

playerTattoo.opacity = opacity
TATTOOS.setPlayerTattoos(playerTattoos);
}
</script>

{#each playerTattoos as { zoneIndex, dlcIndex, tattoo, id }, i (id)}
Expand Down Expand Up @@ -220,7 +229,7 @@

<div
transition:slide
class="flex flex-col items-center justify-center w-full"
class="flex flex-col items-center justify-center w-full mt-2"
>
<Dropdown
on:click={() => {
Expand Down Expand Up @@ -250,6 +259,26 @@
{/each}
</Dropdown>
</div>

<div
transition:slide
class="flex flex-col items-center justify-center w-full mt-2"
>
<span
class="opacity-75 w-full flex items-center justify-between gap-[0.5vh]"
>
<p>{$LOCALE.TATTOO_OPACITY}</p>
</span>
<Slider
bind:value={tattoo.opacity}
min={0.1}
max={1.0}
step={0.1}
on:change={({ detail: opacity }) => {
changeOpacity(i, opacity)
}}
/>
</div>
{/if}
</svelte:fragment>

Expand Down
2 changes: 2 additions & 0 deletions web/src/typings/apperance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export type TTattooEntry = {
label: string
hash: number
zone: number
opacity: number
dlc?: string
}

Expand All @@ -120,6 +121,7 @@ export type TTattoo = {
zoneIndex: number
dlcIndex: number
tattoo: TTattooEntry
opacity: number
id: number
}

Expand Down
1 change: 1 addition & 0 deletions web/src/utils/debug/debugLocale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default {
"REMOVETATTOO_TITLE": "Remove Tattoo",
"ADDTATTOO_TITLE": "Add Tattoo",
"TATTOO_TITLE": "Tattoo",
"TATTOO_OPACITY": "Opacity",
"DLCOPT_TITLE": "DLC Options",
"ZONE_TITLE": "Zone",
"MENU_TITLE": "Menu",
Expand Down
Loading