Skip to content

Commit

Permalink
FFS show Room rebased
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamXZE committed Feb 22, 2024
1 parent 92b5633 commit 8bfc186
Show file tree
Hide file tree
Showing 32 changed files with 8,944 additions and 40 deletions.
26 changes: 26 additions & 0 deletions resources/[qb]/qb-core/shared/items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3289,6 +3289,32 @@ QBShared.Items = {
['description'] = 'Pas content ! Pas content !',
['illustrator'] = '.Poulpito'
},
['ffs_crafted_outfit_m'] = {
['name'] = 'ffs_crafted_outfit_m',
['label'] = 'Tenue Sur-mesure',
['weight'] = 1000,
['type'] = 'item_outfit',
['unique'] = false,
['useable'] = true,
['shouldClose'] = true,
['combinable'] = nil,
['itemExtraLabel'] = 'Homme',
['description'] = 'Tenue réalisée spécialement pour: ',
['illustrator'] = '.Crash'
},
['ffs_crafted_outfit_f'] = {
['name'] = 'ffs_crafted_outfit_f',
['label'] = 'Tenue Sur-mesure',
['weight'] = 1000,
['type'] = 'item_outfit',
['unique'] = false,
['useable'] = true,
['shouldClose'] = true,
['combinable'] = nil,
['itemExtraLabel'] = 'Femme',
['description'] = 'Tenue réalisée spécialement pour: ',
['illustrator'] = '.Crash'
},
-- Vehicle Tools
['repairkit'] = {
['name'] = 'repairkit',
Expand Down
58 changes: 58 additions & 0 deletions resources/[soz]/soz-core/data/FightForStyleShowRoom/conversion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Executed with `yarn build-showroom`
const csvtojson = require('csvtojson');
const fs = require('fs');

async function run() {
const showRoomListJSON = await csvtojson().fromFile('./data/FightForStyleShowRoom/showRoomList.csv');

const ShowRoomFreeElement = {
mp_m_freemode_01: {
Components: {},
Props: {},
},
mp_f_freemode_01: {
Components: {},
Props: {},
},
};

const showRoomClothesList = {
mp_m_freemode_01: {
Components: {},
Props: {},
},
mp_f_freemode_01: {
Components: {},
Props: {},
},
};

for (const cloth of showRoomListJSON) {
const clothDrawable = parseInt(cloth.Drawable);
showRoomClothesList[cloth.Model][cloth.Type][cloth.Index] ||= {};
ShowRoomFreeElement[cloth.Model][cloth.Type][cloth.Index] ||= [];
if (cloth['UseDrawable'] == 'TRUE') {
const clothConfig = [];
for (let i = 0; i <= 25; i++) {
if (cloth['Texture' + i] == 'TRUE') clothConfig.push(i);
}
showRoomClothesList[cloth.Model][cloth.Type][cloth.Index][clothDrawable] = clothConfig;
}
if (cloth['Free'] == 'TRUE') ShowRoomFreeElement[cloth.Model][cloth.Type][cloth.Index].push(clothDrawable);
}

let string = `export const ShowRoomFreeElement = ${JSON.stringify(
ShowRoomFreeElement,
(k, v) => (Array.isArray(v) ? JSON.stringify(v) : v),
4
).replace(/"\[[^"\]]*]"/g, r => JSON.stringify(JSON.parse(r)).substr(1).slice(0, -1))};\n\n`;
string += `export const ffsClothConfig = ${JSON.stringify(
showRoomClothesList,
(k, v) => (Array.isArray(v) ? JSON.stringify(v) : v),
4
).replace(/"\[[^"\]]*]"/g, r => JSON.stringify(JSON.parse(r)).substr(1).slice(0, -1))};\n\n`;

fs.writeFileSync('./src/shared/FightForStyleShowRoom/ffsClothConfig.ts', string);
}

run();
4,074 changes: 4,074 additions & 0 deletions resources/[soz]/soz-core/data/FightForStyleShowRoom/showRoomList.csv

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion resources/[soz]/soz-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"dev-module": "webpack --config webpack.config.watch.js --watch --mode development",
"dev-nui": "webpack-dev-server --config webpack.config.dev_server.js --mode development --hot",
"dev": "concurrently \"yarn run dev-module\" \"yarn run dev-nui\"",
"lint": "tsc -p tsconfig.json --noEmit"
"lint": "tsc -p tsconfig.json --noEmit",
"build-showroom": "node data/FightForStyleShowRoom/conversion.js"
},
"prisma": {
"seed": "ts-node --transpile-only prisma/seed.ts"
Expand All @@ -26,6 +27,7 @@
"chokidar": "^3.5.3",
"concurrently": "^7.2.2",
"css-loader": "^6.7.1",
"csvtojson": "^2.0.10",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
Expand Down
Binary file not shown.
Binary file not shown.
86 changes: 65 additions & 21 deletions resources/[soz]/soz-core/src/client/clothing/clothing.service.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,43 @@
import { Inject, Injectable } from '../../core/decorators/injectable';
import { Component, KeepHairWithMask, Outfit, OutfitItem, Prop } from '../../shared/cloth';
import { Component, ComponentEnum, FfsComponent, KeepHairWithMask, Outfit, OutfitItem, Prop } from '../../shared/cloth';
import { ffsClothConfig } from '../../shared/FightForStyleShowRoom/ffsClothConfig';
import { PlayerService } from '../player/player.service';

@Injectable()
export class ClothingService {
@Inject(PlayerService)
public playerService: PlayerService;

public applyComponent(component: Component, outfitItem: OutfitItem) {
public applyComponentToPed(pedId: number, component: Component, outfitItem: OutfitItem) {
SetPedComponentVariation(
PlayerPedId(),
pedId,
Number(component),
Number(outfitItem.Drawable),
Number(outfitItem.Texture),
Number(outfitItem.Palette)
);
}

public applyComponent(component: Component, outfitItem: OutfitItem) {
this.applyComponentToPed(PlayerPedId(), component, outfitItem);
}

public displayHairWithMask(maskDrawable: number): boolean {
return maskDrawable < 103 || KeepHairWithMask[maskDrawable];
}

public applyProp(prop: Prop, outfitItem: OutfitItem) {
public applyPropToPed(pedId: number, prop: Prop, outfitItem: OutfitItem) {
if (outfitItem.Clear) {
ClearPedProp(PlayerPedId(), Number(prop));
ClearPedProp(pedId, Number(prop));
} else {
SetPedPropIndex(PlayerPedId(), Number(prop), outfitItem.Drawable || 0, outfitItem.Texture || 0, true);
SetPedPropIndex(pedId, Number(prop), outfitItem.Drawable || 0, outfitItem.Texture || 0, true);
}
}

public applyProp(prop: Prop, outfitItem: OutfitItem) {
this.applyPropToPed(PlayerPedId(), prop, outfitItem);
}

public applyOutfit(outfit: Outfit) {
for (const [componentIndex, component] of Object.entries(outfit.Components)) {
this.applyComponent(Number(componentIndex), component);
Expand All @@ -48,12 +57,33 @@ export class ClothingService {
}

public getClothSet(): Outfit {
return this.getClothSetForComponentAndProp(Component, Prop, PlayerPedId());
}

public getMaxOptions() {
return this.getMaxOptionsForComponentAndProp(Component, Prop, PlayerPedId());
}

public getFfsClothSet(pedId: number): Outfit {
const ffsClothSet = this.getClothSetForComponentAndProp(FfsComponent, Prop, pedId);
for (const propIndex in ffsClothSet.Props) {
ffsClothSet.Props[propIndex].Drawable = Math.max(ffsClothSet.Props[propIndex].Drawable, 0);
}

return ffsClothSet;
}

public getFfsOptions(model: string) {
return ffsClothConfig[model];
}

private getClothSetForComponentAndProp(component: ComponentEnum, prop: ComponentEnum, pedId: number): Outfit {
const components: Outfit['Components'] = {};

for (const componentIndex of Object.keys(Component).filter(key => !isNaN(Number(key)))) {
for (const componentIndex of Object.keys(component).filter(key => !isNaN(Number(key)))) {
const componentId = Number(componentIndex);
const drawableId = GetPedDrawableVariation(PlayerPedId(), componentId);
const textureId = GetPedTextureVariation(PlayerPedId(), componentId);
const drawableId = GetPedDrawableVariation(pedId, componentId);
const textureId = GetPedTextureVariation(pedId, componentId);

components[componentIndex] = {
Drawable: drawableId,
Expand All @@ -63,10 +93,10 @@ export class ClothingService {
}

const props: Outfit['Props'] = {};
for (const propIndex of Object.values(Prop).filter(key => !isNaN(Number(key)))) {
for (const propIndex of Object.values(prop).filter(key => !isNaN(Number(key)))) {
const propId = Number(propIndex);
const drawableId = GetPedPropIndex(PlayerPedId(), propId);
const textureId = GetPedPropTextureIndex(PlayerPedId(), propId);
const drawableId = GetPedPropIndex(pedId, propId);
const textureId = GetPedPropTextureIndex(pedId, propId);

props[propIndex] = {
Drawable: drawableId,
Expand All @@ -80,24 +110,38 @@ export class ClothingService {
};
}

public getMaxOptions() {
public getMaxOptionsForComponentAndProp(component: ComponentEnum, prop: ComponentEnum, pedId: number) {
const maxOptions = [];
for (const componentIndex of Object.values(Component).filter(key => !isNaN(Number(key)) && key !== '7')) {
for (const componentIndex of Object.values(component).filter(key => !isNaN(Number(key)) && key !== '7')) {
const componentId = Number(componentIndex);
const maxDrawable = GetNumberOfPedDrawableVariations(PlayerPedId(), componentId);
maxOptions.push({
const maxDrawable = GetNumberOfPedDrawableVariations(pedId, componentId);
const maxOptionObject = {
componentIndex: componentIndex,
maxDrawables: maxDrawable,
});
maxTextures: 0,
};
for (let drawableIndex = 0; drawableIndex < maxDrawable; drawableIndex++) {
const maxTextureForDrawable = GetNumberOfPedTextureVariations(pedId, componentId, drawableIndex);
maxOptionObject.maxTextures = Math.max(maxTextureForDrawable, maxOptionObject.maxTextures);
}

maxOptions.push(maxOptionObject);
}

for (const propIndex of Object.values(Prop).filter(key => !isNaN(Number(key)))) {
for (const propIndex of Object.values(prop).filter(key => !isNaN(Number(key)))) {
const propId = Number(propIndex);
const maxDrawable = GetNumberOfPedPropDrawableVariations(PlayerPedId(), propId);
maxOptions.push({
const maxDrawable = GetNumberOfPedPropDrawableVariations(pedId, propId);
const maxOptionObject = {
propIndex: propIndex,
maxDrawables: maxDrawable,
});
maxTextures: 0,
};

for (let drawableIndex = 0; drawableIndex < maxDrawable; drawableIndex++) {
const maxTextureForDrawable = GetNumberOfPedPropTextureVariations(pedId, propId, drawableIndex);
maxOptionObject.maxTextures = Math.max(maxTextureForDrawable, maxOptionObject.maxTextures);
}
maxOptions.push(maxOptionObject);
}

return maxOptions;
Expand Down
2 changes: 2 additions & 0 deletions resources/[soz]/soz-core/src/client/job/ffs/ffs.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { FightForStyleCraftProvider } from './ffs.craft.provider';
import { FightForStyleHarvestProvider } from './ffs.harvest.provider';
import { FightForStyleProvider } from './ffs.provider';
import { FightForStyleRestockProvider } from './ffs.restock.provider';
import { FightForStylShowRoomProvider } from './ffs.showroom.provider';

@Module({
providers: [
FightForStyleHarvestProvider,
FightForStyleCraftProvider,
FightForStyleRestockProvider,
FightForStyleProvider,
FightForStylShowRoomProvider,
],
})
export class FightForStyleModule {}
Loading

0 comments on commit 8bfc186

Please sign in to comment.