import InputHelper from '../../inputhelper';

export default function inventory(globalData: IGlobalData) {

    
    var inv;
    var showInventory;

    //SCREEN STUFF
    const { x: screenX, y: screenY } = mp.game.graphics.getScreenActiveResolution(0, 0);
    let rxC = 0.5; //Breitenpositionierung des Inventars auf Screen-(C)enter
    let ryC = 0.4; //Höhenpositionierung des Inventars auf Screen-(C)enter
    let aspectRatioFactor = screenX / screenY; //Höhenmultiplikator (damit Quadrate anstatt Rechtecke der einzelnen Slots entstehen)
    let sizeMulx = 0.08; //Größenmultiplikator (GUI Skalierung)
    let sizeMuly = sizeMulx * aspectRatioFactor; //Größenmultiplikator (GUI Skalierung)
    let rWidth = 0.4;

    class inventory {
        slots: slot[];
        slotId: number;
        weight: number;
        slotAmount: number = 20;

        constructor() {
            this.slots[0] = new slot([0.3375, 0.205])
            this.slots[1] = new slot([0.4195, 0.205])
            this.slots[2] = new slot([0.5015, 0.205])
            this.slots[3] = new slot([0.5835, 0.205])
            this.slots[4] = new slot([0.6655, 0.205])
            this.slots[5] = new slot([0.3375, 0.355])
            this.slots[6] = new slot([0.4195, 0.355])
            this.slots[7] = new slot([0.5015, 0.355])
            this.slots[8] = new slot([0.5835, 0.355])
            this.slots[9] = new slot([0.6655, 0.355])
            this.slots[10] = new slot([0.3375, 0.505])
            this.slots[11] = new slot([0.4195, 0.505])
            this.slots[12] = new slot([0.5015, 0.505])
            this.slots[13] = new slot([0.5835, 0.505])
            this.slots[14] = new slot([0.6655, 0.505])
            this.slots[15] = new slot([0.3375, 0.655])
            this.slots[16] = new slot([0.4195, 0.655])
            this.slots[17] = new slot([0.5015, 0.655])
            this.slots[18] = new slot([0.5835, 0.655])
            this.slots[19] = new slot([0.6655, 0.655])
        }

        drawInventoryBackGround() {
            mp.game.graphics.set2dLayer(1); // LAYER 1          
            mp.game.graphics.drawRect(rxC, ryC, 0.45, 0.7, 255, 255, 255, 200); //INVENTARHINTERGRUND    

            mp.game.graphics.set2dLayer(2); // LAYER 2

            //INVENTARÜBERSCHRIFT
            mp.game.graphics.drawText("Inventar ~g~" + this.weight + "/40000g", [rxC, ryC - (rWidth / 1.20)], {
                font: 7,
                color: [112, 128, 144, 254],
                scale: [0.7, 0.7],
                outline: true,
                centre: false
            });
        }
    }

    class slot {
        id: number;
        x: number;
        y: number;
        position: [number, number];
        item: inventoryItem;

        constructor(position) {
            
        }
    }

    class inventoryItem {
        id: number;
        name: string;
        description: string;
        sprite: number;
        weight: number;
    }

    mp.events.add("openInventory", (itemArray) => {
        var inv = new inventory();
        showInventory = true;
    });

    mp.events.add("render", () => {
        if (showInventory) {

        }
    });

    function initInventory(slots) {

        
    }

    
}