Skip to content

Commit

Permalink
feat: tops, torsos, etc. closes #94 closes #93 (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuyk committed Jul 3, 2024
1 parent a0a0d5b commit 7858169
Show file tree
Hide file tree
Showing 16 changed files with 10,703 additions and 9 deletions.
16 changes: 16 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## Version 42

### Code Changes

- Added near perfect Torso, Top, and Undershirt data for 99% of tops
- Added helper functions in shared clothing script to help obtain clothing data
- Fixed bug where local objects were not being destroyed
- Fixed bug where disabled plugins were copying files
- Fixed bug where previous files were not cleaned up properly

### Docs Changes

- N/A

---

## Version 41

### Code Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "stuyk",
"type": "module",
"version": "41",
"version": "42",
"scripts": {
"dev": "nodemon -x pnpm start",
"dev:linux": "nodemon -x pnpm start:linux",
Expand Down
9 changes: 8 additions & 1 deletion scripts/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ const assetPackContent = `type = 'asset-pack'\r\nclient-files = [ '*' ]`;

const assetPacks = [`./resources/images`, `./resources/sounds`, './resources/fonts'];

const foldersToClean = [`./resources/core`, `./resources/webview`, ...assetPacks];
const foldersToClean = [
`./resources/core`,
`./resources/webview`,
`./webview/public/images`,
`./webview/public/sounds`,
`./webview/public/fonts`,
...assetPacks,
];

const initialCommands = [
`node ./scripts/webview.js`,
Expand Down
13 changes: 12 additions & 1 deletion scripts/copyFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ const filesToCopy = {
},
};

const disabledPlugins = glob.sync('src/plugins/**/.disable').map((x) => {
const splitPath = x.split('/');
return splitPath[splitPath.length - 2];
});

console.log(disabledPlugins);

/**
* Changes html tags to rml tags
*
Expand Down Expand Up @@ -72,7 +79,11 @@ function getPluginName(splitPath) {
function copyFiles() {
const folders = Object.keys(filesToCopy);
for (let folder of folders) {
const files = glob.sync(folder);
const files = glob.sync(folder).filter((x) => {
const index = disabledPlugins.findIndex((disabledPlugin) => x.includes(disabledPlugin));
return index === -1;
});

const { destination, keyword } = filesToCopy[folder];

for (let file of files) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/client/controllers/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function draw() {
}

try {
objectsDrawn[object.uid].destroy;
objectsDrawn[object.uid].destroy();
} catch (err) {}

delete objectsDrawn[object.uid];
Expand All @@ -35,7 +35,7 @@ function draw() {
true,
false,
false,
50
50,
);

objectsDrawn[object.uid].frozen = true;
Expand Down
33 changes: 31 additions & 2 deletions src/main/client/screen/pedOnScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export async function usePedOnScreen(refPed: number, position: keyof typeof PAUS
previousHudColor = new alt.RGBA(r, g, b, a);
native.replaceHudColourWithRgba(117, 0, 0, 0, 0);

const previousClothes = {};
const previousProps = {};

function tick() {
native.setMouseCursorVisible(false);

Expand All @@ -50,18 +53,44 @@ export async function usePedOnScreen(refPed: number, position: keyof typeof PAUS
return;
}

for (let i = 0; i < 11; i++) {
for (let i = 0; i <= 11; i++) {
const drawable = native.getPedDrawableVariation(refPed, i);
const texture = native.getPedTextureVariation(refPed, i);
const palette = native.getPedPaletteVariation(refPed, i);

if (
previousClothes[i] &&
previousClothes[i].drawable === drawable &&
previousClothes[i].texture === texture
) {
continue;
}

previousClothes[i] = {
texture,
drawable,
};

native.setPedComponentVariation(ped, i, drawable, texture, palette);
}

const props = [0, 1, 2, 6, 7];
for (let prop of props) {
const drawable = native.getPedPropIndex(refPed, prop, 0);
const texture = native.getPedPropTextureIndex(refPed, prop);
native.setPedPropIndex(ped, prop, drawable, texture, true, false);

if (
previousProps[prop] &&
previousProps[prop].drawable === drawable &&
previousProps[prop].texture === texture
) {
continue;
}
previousProps[prop] = {
texture,
drawable,
};
native.setPedPropIndex(ped, prop, drawable, texture, true, 0);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/client/system/screenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ const ClothingCameras = {
},
// 11
[CLOTHING_IDS.TOP]: {
fov: 50,
fov: 60,
rotation: {
x: 0,
y: 0,
z: -165,
},
zPos: 0.03,
zPos: 0.05,
},
};

Expand Down
57 changes: 57 additions & 0 deletions src/main/shared/data/clothing.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import { FemaleTops } from './femaleTops.js';
import { FemaleTorsos } from './femaleTorsos.js';
import { FemaleUndershirtCategories } from './femaleUndershirtCategories.js';
import { MaleTops } from './maleTops.js';
import { MaleTorsos } from './maleTorsos.js';
import { MaleUndershirtCategories } from './maleUndershirtCategories.js';

const DefaultList = {
Male: {
clothes: {
Expand Down Expand Up @@ -1403,3 +1410,53 @@ export function getCategory(
): { clothes: { [key: string]: number }; props: { [key: string]: number } } | undefined {
return ClothingList[category];
}

/**
* Get all tops for a given model
*
* @export
* @param {('male' | 'female')} type
* @return
*/
export function getTops(type: 'male' | 'female') {
return type === 'male' ? MaleTops : FemaleTops;
}

/**
* Get torsos from a given top torsos list
*
* @export
* @param {('male' | 'female')} type
* @param {number[]} values
* @return
*/
export function getTorsos(type: 'male' | 'female', values: number[]) {
let torsos: { dlc: string; drawable: number }[] = [];

if (type === 'male') {
for (let value of values) {
torsos = torsos.concat(MaleTorsos[value]);
}
} else {
for (let value of values) {
torsos = torsos.concat(FemaleTorsos[value]);
}
}

return torsos;
}

/**
* Get all undershirts for a given category, and player model type
*
* @export
* @param {('male' | 'female')} type
* @param {('empty' | 'monster' | 'none' | 'open' | 'partial' | 'vest')} category
* @return
*/
export function getUndershirts(
type: 'male' | 'female',
category: 'empty' | 'monster' | 'none' | 'open' | 'partial' | 'vest',
) {
return type === 'male' ? MaleUndershirtCategories[category] : FemaleUndershirtCategories[category];
}
Loading

0 comments on commit 7858169

Please sign in to comment.