farben ändern im tuning system
This commit is contained in:
@@ -10,12 +10,18 @@ const UIMenuItem = NativeUI.UIMenuItem;
|
||||
const BadgeStyle = NativeUI.BadgeStyle;
|
||||
const Point = NativeUI.Point;
|
||||
|
||||
import vehicleColors from './colors';
|
||||
import game from '..';
|
||||
|
||||
export default function tuning(globalData: IGlobalData) {
|
||||
var keyBound = false;
|
||||
|
||||
var currentPrimaryColor: number;
|
||||
var currentSecondaryColor: number;
|
||||
|
||||
const disableInput = [75, 278, 279, 280, 281, 23, 59, 60, 71, 72, 74];
|
||||
|
||||
const carModTypes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 22, 25, 27, 28, 33, 34, 35, 38, 39, 40, 41, 42, 43, 44, 46, 48, 69];
|
||||
const carModTypes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 22, -1, 25, 27, 28, 33, 34, 35, 38, 39, 40, 41, 42, 43, 44, 46, 48, 69];
|
||||
|
||||
const carModSlotName = [
|
||||
{ Slot: 0, Name: "Spoiler" },
|
||||
@@ -37,6 +43,7 @@ export default function tuning(globalData: IGlobalData) {
|
||||
{ Slot: 18, Name: "Turbo" },
|
||||
{ Slot: 22, Name: "Licht" },
|
||||
{ Slot: 23, Name: "Reifen" },
|
||||
{ Slot: -1, Name: "Lackierung" },
|
||||
{ Slot: 25, Name: "Nummernschildhalter" },
|
||||
{ Slot: 27, Name: "Innenausstatung" },
|
||||
{ Slot: 28, Name: "Wackelkopf" },
|
||||
@@ -169,9 +176,30 @@ export default function tuning(globalData: IGlobalData) {
|
||||
|
||||
carModTypes.forEach((modType) => {
|
||||
|
||||
var mod = null;
|
||||
|
||||
if (modType === 22) { // Lichter
|
||||
var hlColor = localVehicle.getVariable("headlightColor");
|
||||
if (typeof hlColor !== "number" || isNaN(hlColor) || hlColor < 0 || hlColor === 255) {
|
||||
mod = -1;
|
||||
} else if (hlColor === 13) mod = 0;
|
||||
else mod = hlColor + 1;
|
||||
} else if (modType === 18) { // Turbo
|
||||
var toggle = localVehicle.isToggleModOn(modType);
|
||||
mod = toggle ? 0 : -1;
|
||||
} else if (modType == -1) { // Lackierungen
|
||||
var colorItem = new UIMenuItem("Lackierungen");
|
||||
var colorMenu = getColorMenu();
|
||||
|
||||
mainMenu.AddItem(colorItem);
|
||||
mainMenu.BindMenuToItem(colorMenu, colorItem);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var num = localVehicle.getNumMods(modType);
|
||||
|
||||
if (num === 0 && modType !== 18 && modType !== 22) return;
|
||||
if (num === 0 && modType !== 18 && modType !== 22 && modType !== -1) return;
|
||||
|
||||
var modName = localVehicle.getModSlotName(modType) || "nix gefunden";
|
||||
modName = mp.game.ui.getLabelText(modName);
|
||||
@@ -186,26 +214,21 @@ export default function tuning(globalData: IGlobalData) {
|
||||
}
|
||||
}
|
||||
|
||||
var modMenu = new Menu(modName, carName, new Point(50, 50), null, null);
|
||||
if (mod === null) {
|
||||
mod = localVehicle.getMod(modType);
|
||||
}
|
||||
|
||||
var modNum = localVehicle.getNumMods(modType);
|
||||
if (modType === 18) modNum = 1;
|
||||
if (modType === 22) modNum = 14;
|
||||
|
||||
var mod = localVehicle.getMod(modType);
|
||||
|
||||
if (modType === 22) {
|
||||
var hlColor = localVehicle.getVariable("headlightColor");
|
||||
if (typeof hlColor !== "number" || isNaN(hlColor) || hlColor < 0 || hlColor === 255) {
|
||||
mod = -1;
|
||||
} else if (hlColor === 13) mod = 0;
|
||||
else mod = hlColor + 1;
|
||||
}
|
||||
var modMenu = new Menu(modName, carName, new Point(50, 50), null, null);
|
||||
|
||||
if (modType === 18) {
|
||||
var toggle = localVehicle.isToggleModOn(modType);
|
||||
mod = toggle ? 0 : -1;
|
||||
}
|
||||
modMenu.Visible = false;
|
||||
|
||||
var menuItem = new UIMenuItem(modName);
|
||||
mainMenu.AddItem(menuItem);
|
||||
mainMenu.BindMenuToItem(modMenu, menuItem);
|
||||
|
||||
currentMod[modType] = mod;
|
||||
|
||||
@@ -260,12 +283,6 @@ export default function tuning(globalData: IGlobalData) {
|
||||
}
|
||||
localVehicle.setMod(modType, currentMod[modType]);
|
||||
});
|
||||
|
||||
modMenu.Visible = false;
|
||||
|
||||
var menuItem = new UIMenuItem(modName);
|
||||
mainMenu.AddItem(menuItem);
|
||||
mainMenu.BindMenuToItem(modMenu, menuItem);
|
||||
});
|
||||
|
||||
mainMenu.Visible = true;
|
||||
@@ -315,6 +332,9 @@ export default function tuning(globalData: IGlobalData) {
|
||||
case 2:
|
||||
realModName = "Rennbremsen";
|
||||
break;
|
||||
case 3:
|
||||
realModName = "Wettkampfbremsen";
|
||||
break;
|
||||
}
|
||||
} else if (slot === 13) {
|
||||
switch (mod) {
|
||||
@@ -414,4 +434,104 @@ export default function tuning(globalData: IGlobalData) {
|
||||
mp.game.invoke("0xE41033B25D003A07", vehicle.handle, color);
|
||||
}
|
||||
}
|
||||
|
||||
function getColorMenu(): NativeUI.Menu {
|
||||
var currentColors = mp.players.local.vehicle.getColours(0, 0);
|
||||
|
||||
currentPrimaryColor = currentColors.colorPrimary;
|
||||
currentSecondaryColor = currentColors.colorSecondary;
|
||||
|
||||
mp.gui.chat.push("color1: " + currentPrimaryColor + ", color2: " + currentSecondaryColor);
|
||||
|
||||
var primaryColor = getSingleColorMenu("Primärfarbe", currentPrimaryColor, primaryColorSelect, primaryColorChange);
|
||||
var secondaryColor = getSingleColorMenu("Sekundärfarbe", currentSecondaryColor, secondaryColorSelect, secondaryColorChange);
|
||||
|
||||
var menu = new Menu("Lackierungen", "Ändere die Farbe deines Fahrzeugs", new Point(50, 50));
|
||||
|
||||
var primaryColorItem = new UIMenuItem("Primärfarbe");
|
||||
var secondaryColorItem = new UIMenuItem("Sekundärfarbe");
|
||||
|
||||
secondaryColor.MenuClose.on(() => {
|
||||
mp.players.local.vehicle.setColours(currentPrimaryColor, currentSecondaryColor);
|
||||
});
|
||||
|
||||
primaryColor.MenuClose.on(() => {
|
||||
mp.players.local.vehicle.setColours(currentPrimaryColor, currentSecondaryColor);
|
||||
});
|
||||
|
||||
menu.AddItem(primaryColorItem);
|
||||
menu.AddItem(secondaryColorItem);
|
||||
|
||||
menu.BindMenuToItem(primaryColor, primaryColorItem);
|
||||
menu.BindMenuToItem(secondaryColor, secondaryColorItem);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
function getSingleColorMenu(title: string, currentColor: number, onSelect: (color: number) => void, onChange: (color: number) => void): NativeUI.Menu {
|
||||
var menu = new Menu(title, "Ändere die Farbe deines Fahrzeugs", new Point(50, 50));
|
||||
|
||||
var colorCategories = Object.keys(vehicleColors);
|
||||
|
||||
var currentColorItem: NativeUI.UIMenuItem = null;
|
||||
|
||||
colorCategories.forEach(category => {
|
||||
var categoryItem = new UIMenuItem(category);
|
||||
menu.AddItem(categoryItem);
|
||||
|
||||
var categoryMenu = new Menu(category, "Ändere die Farbe deines Fahrzeugs", new Point(50, 50));
|
||||
|
||||
var categoryColors = Object.keys(vehicleColors[category]);
|
||||
categoryColors.forEach(categoryColor => {
|
||||
var color = vehicleColors[category][categoryColor];
|
||||
|
||||
var colorItem = new UIMenuItem(cleanColorName);
|
||||
colorItem.Data = color;
|
||||
|
||||
if (color === currentColor) {
|
||||
colorItem.SetRightBadge(BadgeStyle.Car);
|
||||
currentColorItem = colorItem;
|
||||
}
|
||||
|
||||
categoryMenu.AddItem(colorItem);
|
||||
});
|
||||
|
||||
menu.BindMenuToItem(categoryMenu, categoryItem);
|
||||
|
||||
categoryMenu.IndexChange.on((index, item: NativeUI.UIMenuItem) => {
|
||||
onChange(<number>item.Data);
|
||||
});
|
||||
|
||||
categoryMenu.ItemSelect.on((item: NativeUI.UIMenuItem, index: number) => {
|
||||
currentColorItem.SetRightBadge(BadgeStyle.None);
|
||||
|
||||
item.SetRightBadge(BadgeStyle.Car);
|
||||
currentColorItem = item;
|
||||
|
||||
onSelect(<number>item.Data);
|
||||
});
|
||||
});
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
function primaryColorChange(color: number) {
|
||||
mp.players.local.vehicle.setColours(color, currentSecondaryColor);
|
||||
}
|
||||
|
||||
function primaryColorSelect(color: number) {
|
||||
currentPrimaryColor = color;
|
||||
|
||||
mp.events.callRemote("CLIENT:TuningManager_SetVehicleColor", true, color);
|
||||
}
|
||||
|
||||
function secondaryColorChange(color: number) {
|
||||
mp.players.local.vehicle.setColours(currentPrimaryColor, color);
|
||||
}
|
||||
|
||||
function secondaryColorSelect(color: number) {
|
||||
currentSecondaryColor = color;
|
||||
|
||||
mp.events.callRemote("CLIENT:TuningManager_SetVehicleColor", false, color);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user