Compare commits

...

2 Commits

Author SHA1 Message Date
77583597b5 Updated to use new api and new weapon display 2026-09-08 18:26:28 +02:00
843bf30cae Reworked base weapon display 2026-09-08 18:26:17 +02:00
3 changed files with 61 additions and 17 deletions

16
app/components/float.tsx Normal file
View File

@@ -0,0 +1,16 @@
export function Float({ float }: { float: number }) {
return (
<>
<div className="w-full flex justify-center">
<div className="absolute mx-2 h-4 w-1 mt-1 rounded-xl bg-white" style={{left: `calc(${float}*100% - var(--spacing))`}}></div>
<div className="w-full h-2 flex my-2 px-2">
<div className="w-7/100 h-full rounded-l-xl bg-green-800"></div>
<div className="w-8/100 h-full bg-green-500"></div>
<div className="w-23/100 h-full bg-lime-400"></div>
<div className="w-7/100 h-full bg-orange-400"></div>
<div className="w-55/100 h-full rounded-r-xl bg-red-400"></div>
</div>
</div>
</>
);
}

View File

@@ -7,15 +7,15 @@ import { useNotification } from "~/hooks/notification";
export function Inventory({ side }: { side: "T" | "CT" }) { export function Inventory({ side }: { side: "T" | "CT" }) {
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [agent, setAgent] = useState({}); const [agent, setAgent] = useState({});
const [gloves, setGloves] = useState({ name: "", color: "", paint_index: 0 }); const [gloves, setGloves] = useState({ name: "", color: "", display: "", paint_index: 0, float: 0.0, pattern: 0 });
const [knife, setKnife] = useState({ name: "", color: "", paint_index: 0 }); const [knife, setKnife] = useState({ name: "", color: "", display: "", paint_index: 0, float: 0.0, pattern: 0 });
const [weapons, setWeapons] = useState([]); const [weapons, setWeapons] = useState([]);
const { notify } = useNotification(); const { notify } = useNotification();
useEffect(() => { useEffect(() => {
const fetch_weapons = async () => { const fetch_weapons = async () => {
let response = await fetch( let response = await fetch(
`${import.meta.env.VITE_BASE_API_URL}/knife?team=${side}`, `${import.meta.env.VITE_BASE_API_URL}/skin?team=${side}&category=Knives`,
{ credentials: "include" }, { credentials: "include" },
) )
.then((r) => r.json()) .then((r) => r.json())
@@ -31,10 +31,10 @@ export function Inventory({ side }: { side: "T" | "CT" }) {
); );
}); });
setKnife(response); setKnife(response[0]);
response = await fetch( response = await fetch(
`${import.meta.env.VITE_BASE_API_URL}/gloves?team=${side}`, `${import.meta.env.VITE_BASE_API_URL}/skin?team=${side}&category=Gloves`,
{ credentials: "include" }, { credentials: "include" },
) )
.then((r) => r.json()) .then((r) => r.json())
@@ -50,7 +50,7 @@ export function Inventory({ side }: { side: "T" | "CT" }) {
); );
}); });
setGloves(response) setGloves(response[0])
setLoading(false); setLoading(false);
}; };
@@ -100,11 +100,17 @@ export function Inventory({ side }: { side: "T" | "CT" }) {
weapon_id={knife["name"]} weapon_id={knife["name"]}
color={knife["color"]} color={knife["color"]}
paint_index={knife["paint_index"]} paint_index={knife["paint_index"]}
display={knife["display"]}
float={knife["float"]}
pattern={knife["pattern"]}
></Weapon> ></Weapon>
<Weapon <Weapon
weapon_id={gloves["name"]} weapon_id={gloves["name"]}
color={gloves["color"]} color={gloves["color"]}
paint_index={gloves["paint_index"]} paint_index={gloves["paint_index"]}
display={gloves["display"]}
float={gloves["float"]}
pattern={gloves["pattern"]}
></Weapon> ></Weapon>
<Weapon <Weapon
weapon_id={"agent-4730"} weapon_id={"agent-4730"}

View File

@@ -1,24 +1,46 @@
import { Button } from "@heroui/react"; import { Button, Surface, Typography } from "@heroui/react";
import { Float } from "./float";
export function Weapon({ export function Weapon({
weapon_id, weapon_id,
color, color,
display = "Weapon",
float = 0,
pattern = 0,
paint_index = 0, paint_index = 0,
}: { }: {
weapon_id: string; weapon_id: string;
color: string; color: string;
display?: string;
float?: number;
pattern?: number;
paint_index?: number; paint_index?: number;
}) { }) {
const acolor = `${color}64` const acolor = `${color}64`;
return ( return (
<Surface className="bg-mist-700">
<Button className="flex flex-col h-fit w-fit p-0 rounded-none bg-transparent gap-0 hover:bg-indigo-800 active:bg-indigo-900"> <Button className="flex flex-col h-fit w-fit p-0 rounded-none bg-transparent gap-0 hover:bg-indigo-800 active:bg-indigo-900">
<div className="bg-linear-to-b pointer-events-none" style={{background: `linear-gradient(to bottom, #1f2937, ${acolor})`}}> <div className="flex flex-col">
<div
className="bg-linear-to-b pointer-events-none"
style={{
background: `linear-gradient(to bottom, #1f2937, ${acolor})`,
}}
>
<img <img
src={`/skins/${weapon_id}_${paint_index}.png`} src={`/skins/${weapon_id}_${paint_index}.png`}
className="pointer-events-none" className="pointer-events-none"
/> />
</div> </div>
<div className={`h-1 w-full`} style={{background: `${color}`}}></div> <div
className={`h-1 w-full`}
style={{ background: `${color}` }}
></div>
<Typography.Heading level={6} className="px-2">{display}</Typography.Heading>
<Float float={float} />
<Typography.Paragraph className="px-2">Pattern: {pattern}</Typography.Paragraph>
</div>
</Button> </Button>
</Surface>
); );
} }