Rewrite Inventory-System
This commit is contained in:
@@ -1,15 +1,101 @@
|
||||
var inventoryBrowser;
|
||||
var show = false;
|
||||
var trading = false;
|
||||
let screenRes = mp.game.graphics.getScreenResolution(0, 0);
|
||||
let rxC = 0.5;
|
||||
let ryC = 0.5;
|
||||
let rWidth = 0.4;
|
||||
let sX = (screenRes.X * 0.1 / 1000);
|
||||
let sY = (screenRes.Y * 0.1 / 1000);
|
||||
let eX = sX - 0.1;
|
||||
let eY = sY - 0.1;
|
||||
let sizeMul = 0.08;
|
||||
let yMul = 1.8
|
||||
|
||||
mp.events.add("showInventory", (show) => {
|
||||
if (show === true) {
|
||||
inventoryBrowser = mp.browsers.new('package://Gui/Inventory/inventory.html');
|
||||
mp.gui.chat.activate(false);
|
||||
mp.gui.cursor.show(true, true);
|
||||
} else {
|
||||
if (inventoryBrowser) {
|
||||
inventoryBrowser.destroy();
|
||||
mp.gui.chat.activate(true);
|
||||
mp.gui.cursor.show(false, false);
|
||||
var inventoryWeight;
|
||||
var items = [[]];
|
||||
|
||||
var slots = [20];
|
||||
|
||||
for (var s = 1; s <= slots.length; s++) {
|
||||
for (var slY = 0.35; slY <= 0.8; slY += 0.15) {
|
||||
for (var slX = 0.3775; slX <= 0.6655; slX += 0.082) {
|
||||
items[s] = { slX, slY };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mp.events.add("showInventory", (invWeight, itemArr) => {
|
||||
if (show === false) {
|
||||
mp.gui.chat.activate(false);
|
||||
mp.gui.cursor.show(true, true);
|
||||
inventoryWeight = invWeight;
|
||||
items = itemArr;
|
||||
show = true;
|
||||
} else {
|
||||
mp.gui.chat.activate(true);
|
||||
mp.gui.cursor.show(false, false);
|
||||
show = false;
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("render", () => {
|
||||
if (show === true) {
|
||||
var pos = mp.gui.cursor.position;
|
||||
mp.game.graphics.drawText("~r~X: " + pos[0] + " ~g~Y: " + pos[1], [0.5, 0.01], {
|
||||
font: 2,
|
||||
color: [255, 255, 255, 185],
|
||||
scale: [1, 1],
|
||||
outline: true,
|
||||
});
|
||||
|
||||
mp.game.graphics.drawRect(rxC, ryC, 0.45, 0.7, 255, 255, 255, 200); //Hintergrundbox
|
||||
|
||||
|
||||
|
||||
for (var y = ryC - (rWidth / 2) + 0.005; y < ryC + (rWidth / 2) * yMul + 0.01; y = y + sizeMul * yMul + 0.006) {
|
||||
for (var x = rxC - (rWidth / 2) + 0.0375; x < rxC + (rWidth / 2) + 0.01; x = x + sizeMul + 0.002) {
|
||||
|
||||
|
||||
mp.game.graphics.drawRect(x, y, sizeMul, sizeMul * yMul, 112, 128, 144, 254);
|
||||
mp.game.graphics.drawText(slot, [x - (sizeMul / 2) + 0.006, y - (sizeMul / 2) * yMul], {
|
||||
font: 7,
|
||||
color: [255, 69, 0, 254],
|
||||
scale: [0.3, 0.3],
|
||||
outline: true,
|
||||
});
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
//items[userItems.IndexOf(item)][0] = iItem.Name;
|
||||
//items[userItems.IndexOf(item)][1] = iItem.Description;
|
||||
//items[userItems.IndexOf(item)][2] = iItem.Gewicht.ToString();
|
||||
//items[userItems.IndexOf(item)][3] = item.Amount.ToString();
|
||||
//items[userItems.IndexOf(item)][4] = item.Slot.ToString();
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
mp.game.graphics.drawSprite("rp", "Mprpsymbol", slot[items[i][4]][0], slot[items[i][4]][1], rWidth - 0.1, rWidth - 0.1, 0, 255, 255, 255, 125);
|
||||
}
|
||||
|
||||
mp.game.graphics.drawText("Inventar ~g~(" + inventoryWeight + "/40000g)", [rxC, ryC - (rWidth / 1.20)], {
|
||||
font: 7,
|
||||
color: [112, 128, 144, 254],
|
||||
scale: [0.7, 0.7],
|
||||
outline: true,
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add('click', (x, y, upOrDown, leftOrRight, relativeX, relativeY, worldPosition, hitEntity) => {
|
||||
|
||||
|
||||
|
||||
//mp.gui.chat.push("Mouse X:" + x + " | Mouse Y:" + y); // Displays mouse position on click.
|
||||
|
||||
//if (upOrDown == "up")
|
||||
// mp.gui.chat.push("Mouse Clicked Up with " + leftOrRight + " button.");
|
||||
|
||||
//if (upOrDown == "down")
|
||||
// mp.gui.chat.push("Mouse Clicked Down with " + leftOrRight + " button.");
|
||||
});
|
||||
Reference in New Issue
Block a user