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

[Fight For Style] Ajout d'un Show Room et la création de vetement sous forme d'item. #128

Open
wants to merge 1 commit into
base: oss
Choose a base branch
from
Open
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
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 @@ -3468,6 +3468,32 @@ QBShared.Items = {
['description'] = 'Pas content ! Pas content !',
['illustrator'] = '.Poulpito'
},
['ffs_crafted_outfit_m'] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

il n'y a pas les nouvelles images ? on peut les mettre dans le dossier soz-core/public/images/items en png

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pas de nouvelle image à ce moment, je suis pas très bon avec Mid Journey, mais je peux essayer ça

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image ajouté
image

['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.

3 changes: 2 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 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 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
Loading