private void DrawKitsUI(BasePlayer player) { float aspect = core.GetAspect(player.userID); var kitsList = Kits?.Call("GetAvailableKitList", player) as List <object[]>; var elements = new CuiElementContainer(); if (kitsList != null && kitsList.Count > 0) { float realSpacing = buttonSpacing; float buttonWidth = realSpacing / kitsList.Count; if (buttonWidth > maxButtonWidth) { realSpacing = maxButtonWidth * kitsList.Count; buttonWidth = maxButtonWidth; } float buttonWidthSpace = 1f - realSpacing; float nearButtonSpace = buttonWidthSpace / (kitsList.Count + 1f); elements.Add(new CuiPanel { Image = { Color = Config.Get <string>("BackroungPanelColor") }, RectTransform = { AnchorMin = "0 " + (0.5f - (buttonWidth / 2 + 0.05) * (aspect / 2)), AnchorMax = "1 " + (0.5f + (buttonWidth / 2 + 0.05) * (aspect / 2)) }, CursorEnabled = true }, "Overlay", MAIN_UI_NAME); for (int i = 0; i < kitsList.Count; ++i) { elements.Add(new CuiElement { Parent = MAIN_UI_NAME, Components = { new CuiRawImageComponent() { Png = KitsPng.ContainsKey((string)kitsList[i][1]) ? (string)KitsPng[(string)kitsList[i][1]] : "http://bafthcn.kmu.ac.ir/Images/UserUpload/Image/SH/radio.png", Sprite = "assets/content/textures/generic/fulltransparent.tga", Color = (bool)kitsList[i][0] ? "1 1 1 1" : "1 1 1 0.5" }, new CuiRectTransformComponent { AnchorMin = (nearButtonSpace + i * nearButtonSpace + i * buttonWidth) + " 0.05", AnchorMax = (nearButtonSpace + i * nearButtonSpace + i * buttonWidth + buttonWidth) + " 0.95" } } }); elements.Add(new CuiButton { Button = { Command = "TryToGetKit " + ((string)kitsList[i][1]).ToLower(), Color = "0 0 0 0" //(bool)kitsList[i][0] ? Config.Get<string>("ButtonKitReadyColor") : Config.Get<string>("ButtonKitOnCDColor") }, RectTransform = { AnchorMin = (nearButtonSpace + i * nearButtonSpace + i * buttonWidth) + " 0.05", AnchorMax = (nearButtonSpace + i * nearButtonSpace + i * buttonWidth + buttonWidth) + " 0.95" }, Text = { Text = "" } }, MAIN_UI_NAME); } } CuiHelper.AddUi(player, elements); playerIDs.Add(player.UserIDString); }