Added tuning menu
This commit is contained in:
@@ -4,12 +4,136 @@
|
|||||||
* @copyright (c) 2008 - 2018 Life of German
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var keyBound = false;
|
||||||
|
|
||||||
|
var carModTypes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 22, 23];
|
||||||
|
var modSlotName = [
|
||||||
|
{ Slot: 0, Name: "Spoiler" }, // 0
|
||||||
|
{ Slot: 1, Name: "Frontstoßstange"}, // 1
|
||||||
|
{ Slot: 2, Name: "Heckstoßstange"}, // 2
|
||||||
|
{ Slot: 3, Name: "Seitenschweller"}, // 3
|
||||||
|
{ Slot: 4, Name: "Auspuff"}, // 4
|
||||||
|
{ Slot: 5, Name: "Rahmen"}, // 5
|
||||||
|
{ Slot: 6, Name: "Kühlergrill"}, // 6
|
||||||
|
{ Slot: 7, Name: "Motorhaube"}, // 7
|
||||||
|
{ Slot: 8, Name: "Linker Kotflügel"}, // 8
|
||||||
|
{ Slot: 9, Name: "Rechter Kotflügel"}, // 9
|
||||||
|
{ Slot: 10, Name: "Dach"}, // 10
|
||||||
|
{ Slot: 11, Name: "Motor" }, // 11
|
||||||
|
{ Slot: 12, Name: "Bremsen"}, // 12
|
||||||
|
{ Slot: 13, Name: "Getriebe"}, // 13
|
||||||
|
{ Slot: 14, Name: "Hupe"}, // 14
|
||||||
|
{ Slot: 15, Name: "Federung"}, // 15
|
||||||
|
{ Slot: 18, Name: "Turbo"}, // 18
|
||||||
|
{ Slot: 22, Name: "Licht"}, // 22
|
||||||
|
{ Slot: 23, Name: "Reifen"} // 23
|
||||||
|
];
|
||||||
|
|
||||||
|
const NativeUI = require("nativeui");
|
||||||
|
const Menu = NativeUI.Menu;
|
||||||
|
const UIMenuItem = NativeUI.UIMenuItem;
|
||||||
|
const UIMenuListItem = NativeUI.UIMenuListItem;
|
||||||
|
const UIMenuCheckboxItem = NativeUI.UIMenuCheckboxItem;
|
||||||
|
const UIMenuSliderItem = NativeUI.UIMenuSliderItem;
|
||||||
|
const BadgeStyle = NativeUI.BadgeStyle;
|
||||||
|
const Point = NativeUI.Point;
|
||||||
|
const ItemsCollection = NativeUI.ItemsCollection;
|
||||||
|
const Color = NativeUI.Color;
|
||||||
|
const ListItem = NativeUI.ListItem;
|
||||||
|
|
||||||
mp.events.add('showTuningInfo', () => {
|
mp.events.add('showTuningInfo', () => {
|
||||||
mp.game.ui.setTextComponentFormat('STRING');
|
mp.game.ui.setTextComponentFormat('STRING');
|
||||||
mp.game.ui.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um dein Fahrzeug zu modifizieren');
|
mp.game.ui.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um dein Fahrzeug zu modifizieren');
|
||||||
mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1);
|
mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1);
|
||||||
|
|
||||||
|
mp.keys.bind(0x45, false, keyPressHandler);
|
||||||
|
keyBound = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add('hideTuningInfo', () => {
|
mp.events.add('hideTuningInfo', () => {
|
||||||
mp.game.ui.clearHelp(true);
|
mp.game.ui.clearHelp(true);
|
||||||
});
|
mp.gui.chat.show(true);
|
||||||
|
|
||||||
|
if (keyBound) {
|
||||||
|
mp.keys.unbind(0x45, false, keyPressHandler);
|
||||||
|
keyBound = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function keyPressHandler() {
|
||||||
|
mp.events.callRemote("startPlayerTuning");
|
||||||
|
}
|
||||||
|
|
||||||
|
mp.events.add("showTuningMenu", () => {
|
||||||
|
mp.events.call("hideTuningInfo");
|
||||||
|
//mp.gui.chat.show(false);
|
||||||
|
|
||||||
|
var localPlayer = mp.players.local;
|
||||||
|
var localVehicle = localPlayer.vehicle;
|
||||||
|
|
||||||
|
var mainMenu = new Menu("Fahrzeugwerkstatt", "Modifiziere dein Fahrzeug", new Point(50, 50));
|
||||||
|
|
||||||
|
carModTypes.forEach((modType) => {
|
||||||
|
if (localVehicle.getModSlotName(modType) !== "undefined") {
|
||||||
|
var slotName = getSlotName(modType);
|
||||||
|
|
||||||
|
var menuItem = new UIMenuItem(slotName);
|
||||||
|
menuItem.ModSlot = modType;
|
||||||
|
|
||||||
|
mainMenu.AddItem(menuItem);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mainMenu.Visible = true;
|
||||||
|
|
||||||
|
mainMenu.ItemSelect.on(item => {
|
||||||
|
var modSlot = getSlotId(item.Text);
|
||||||
|
|
||||||
|
var modNum = localVehicle.getNumMods(modSlot);
|
||||||
|
|
||||||
|
mp.gui.chat.push(`modSlot = ${modSlot} | modNum = ${modNum} item.Text = ${item.Text}`);
|
||||||
|
|
||||||
|
var modMenu = new Menu(item.Text, "Änderung: " + item.Text, new Point(50, 50));
|
||||||
|
|
||||||
|
for (var i = 0; i < modNum; i++) {
|
||||||
|
var modName = localVehicle.getModTextLabel(modSlot, i);
|
||||||
|
var realModName = mp.game.ui.getLabelText(modName)
|
||||||
|
var modItem = new UIMenuItem(realModName, "");
|
||||||
|
|
||||||
|
modMenu.AddItem(modItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
modMenu.IndexChange.on(index => {
|
||||||
|
mp.gui.chat.push(index.Text);
|
||||||
|
});
|
||||||
|
|
||||||
|
modMenu.MenuClose.on(() => {
|
||||||
|
mainMenu.Visible = true;
|
||||||
|
modMenu.Visible = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
mainMenu.Visible = false;
|
||||||
|
modMenu.Visible = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
function getSlotName(slot) {
|
||||||
|
var toReturn = "undefined";
|
||||||
|
|
||||||
|
modSlotName.forEach((name) => {
|
||||||
|
if (name.Slot === slot) toReturn = name.Name;
|
||||||
|
});
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSlotId(slotName) {
|
||||||
|
var toReturn = "undefined";
|
||||||
|
|
||||||
|
modSlotName.forEach((name) => {
|
||||||
|
if (name.Name === slotName) toReturn = name.Slot;
|
||||||
|
});
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
1
Client/nativeui/index.js
Normal file
1
Client/nativeui/index.js
Normal file
File diff suppressed because one or more lines are too long
@@ -20,22 +20,28 @@ namespace reallife_gamemode.Server.Managers
|
|||||||
|
|
||||||
ColShape colShape = NAPI.ColShape.CreateSphereColShape(pos1, 10, 0);
|
ColShape colShape = NAPI.ColShape.CreateSphereColShape(pos1, 10, 0);
|
||||||
|
|
||||||
colShape.OnEntityEnterColShape += ColShape_OnEntityEnterColShape;
|
colShape.OnEntityEnterColShape += (cs, c) =>
|
||||||
colShape.OnEntityExitColShape += ColShape_OnEntityExitColShape;
|
{
|
||||||
|
if(c.IsInVehicle)
|
||||||
|
{
|
||||||
|
c.TriggerEvent("showTuningInfo");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
colShape.OnEntityExitColShape += (cs, c) =>
|
||||||
|
{
|
||||||
|
c.TriggerEvent("hideTuningInfo");
|
||||||
|
};
|
||||||
|
|
||||||
tuningGarages.Add(colShape);
|
tuningGarages.Add(colShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ColShape_OnEntityExitColShape(ColShape colShape, Client client)
|
[RemoteEvent("startPlayerTuning")]
|
||||||
|
public void StartPlayerTuning(Client player)
|
||||||
{
|
{
|
||||||
NAPI.Util.ConsoleOutput("exit colshape");
|
if (!player.IsInVehicle) return;
|
||||||
client.TriggerEvent("hideTuningInfo");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ColShape_OnEntityEnterColShape(ColShape colShape, Client client)
|
player.TriggerEvent("showTuningMenu");
|
||||||
{
|
|
||||||
NAPI.Util.ConsoleOutput("enter colshape");
|
|
||||||
client.TriggerEvent("showTuningInfo");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user