A nicer inventory

This commit is contained in:
jordan4ibanez 2023-11-20 04:34:28 -05:00
parent 3c2d087a66
commit 8da9e4ce87
4 changed files with 54 additions and 4 deletions

View File

@ -14,8 +14,10 @@ do
local BackGround = formSpec.Background
local BGColor = formSpec.BGColor
local List = formSpec.List
local ListColors = formSpec.ListColors
local color = utility.color
local colorScalar = utility.colorScalar
local colorRGB = utility.colorRGB
local playerInventory = generate(__TS__New(
FormSpec,
{
@ -26,7 +28,17 @@ do
{
bgColor = colorScalar(85),
fullScreen = "both",
fullScreenbgColor = colorScalar(0, 30)
fullScreenbgColor = colorScalar(0, 40)
}
),
__TS__New(
ListColors,
{
slotBGHover = colorScalar(70),
slotBGNormal = colorScalar(55),
slotBorder = colorScalar(0),
toolTipBGColor = colorRGB(123, 104, 238),
toolTipFontColor = colorScalar(100)
}
),
__TS__New(
@ -44,7 +56,7 @@ do
{
location = "current_player",
listName = "craftpreview",
position = create(9, 2.25),
position = create(9, 2.375),
size = create(1, 1),
startingIndex = 0
}

View File

@ -3,21 +3,34 @@ namespace player {
export const INVENTORY_SIZE = vector.create2d(9,4)
const create = vector.create2d
const generate = formSpec.generate
const FormSpec = formSpec.FormSpec
const BackGround = formSpec.Background
const BGColor = formSpec.BGColor
const List = formSpec.List
const ListColors = formSpec.ListColors
const color = utility.color
const colorScalar = utility.colorScalar
const colorRGB = utility.colorRGB
const playerInventory: string = generate(new FormSpec({
size: create(12,12),
elements: [
//! Nice background colors.
new BGColor({
bgColor: colorScalar(85),
fullScreen: "both",
fullScreenbgColor: colorScalar(0,30)
fullScreenbgColor: colorScalar(0,40)
}),
//! Make these lists look nice as well.
new ListColors({
slotBGHover: colorScalar(70),
slotBGNormal: colorScalar(55),
slotBorder: colorScalar(0),
toolTipBGColor: colorRGB(123,104,238),
toolTipFontColor: colorScalar(100)
}),
//! Craft area.
new List({
@ -39,7 +52,7 @@ namespace player {
listName: "craftpreview",
position: create(
9,
2.25
2.375
),
size: create(
1,

View File

@ -123,6 +123,17 @@ do
end
return newColor
end
--- Like the color() function, but can take in raw (0-255) rgba elements.
--
-- @param r Red channel. (0-255)
-- @param g Green channel. (0-255)
-- @param b Blue channel. (0-255)
-- @param a Alpha channel. (0-255)
-- @returns Color string in hex.
function utility.colorRGB(r, g, b, a)
a = a and a / 2.55 or a
return utility.color(r / 2.55, g / 2.55, b / 2.55, a)
end
function utility.colorScalar(s, a)
local newColor = "#"
local hex = hexValues[lockChannel(s)]

View File

@ -130,6 +130,20 @@ namespace utility {
return newColor
}
/**
* Like the color() function, but can take in raw (0-255) rgba elements.
* @param r Red channel. (0-255)
* @param g Green channel. (0-255)
* @param b Blue channel. (0-255)
* @param a Alpha channel. (0-255)
* @returns Color string in hex.
*/
export function colorRGB(r: number, g: number, b: number, a?: number): string {
// Get everything to 0-100 range
a = (a) ? a / 2.55 : a
return color(r / 2.55, g / 2.55, b / 2.55, a)
}
export function colorScalar(s: number, a?: number): string {
let newColor = "#"
const hex = hexValues[lockChannel(s)]