mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
start of equipment ui
This commit is contained in:
1 parent
c45af8e156
commit
30fa18f0fd
12 files changed
+90
-19
No files matched your search
@@ -232,15 +232,15 @@ export class ServerAPI extends AbstractAPI {
|
|||||||
const equipment = Equipment.create();
|
const equipment = Equipment.create();
|
||||||
|
|
||||||
for (const item of this.metadata.group("EquipmentPresetEntity")) {
|
for (const item of this.metadata.group("EquipmentPresetEntity")) {
|
||||||
equipment.presets[item.name] = item.EquipmentPreset();
|
equipment.presets[item.id] = item.EquipmentPreset();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const item of this.metadata.group("EquipmentPricePresetEntity")) {
|
for (const item of this.metadata.group("EquipmentPricePresetEntity")) {
|
||||||
equipment.prices[item.name] = item.EquipmentPricePreset();
|
equipment.prices[item.id] = item.EquipmentPricePreset();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const item of this.metadata.group("EquipmentEntity")) {
|
for (const item of this.metadata.group("EquipmentEntity")) {
|
||||||
equipment.equipments[item.name] = item.BlitzStaticEquipment();
|
equipment.equipments[item.id] = item.BlitzStaticEquipment();
|
||||||
}
|
}
|
||||||
|
|
||||||
return equipment;
|
return equipment;
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
svg {
|
svg,
|
||||||
|
img {
|
||||||
width: 1em;
|
width: 1em;
|
||||||
height: 1em;
|
height: 1em;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
|
|
||||||
aspect-ratio: 1 / 1;
|
aspect-ratio: 1 / 1;
|
||||||
|
|
||||||
font-size: var(--font-size-regular);
|
font-size: var(--font-size-major);
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,38 @@
|
|||||||
gap: var(--space-3);
|
gap: var(--space-3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.equipment {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--space-3);
|
||||||
|
|
||||||
|
.row {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-3);
|
||||||
|
|
||||||
|
.slots {
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
.slot {
|
||||||
|
aspect-ratio: 1 / 1;
|
||||||
|
padding: var(--space-3);
|
||||||
|
|
||||||
|
font-size: var(--space-5);
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
border-top-right-radius: 0;
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
border-top-left-radius: 0;
|
||||||
|
border-bottom-left-radius: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.lines {
|
.lines {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -4,12 +4,15 @@ import type { StandardPrice } from "@protos/blitz_static_standard_price";
|
|||||||
import type { UpgradeLine } from "@protos/blitz_static_tank_upgrade_line";
|
import type { UpgradeLine } from "@protos/blitz_static_tank_upgrade_line";
|
||||||
import type { StageParameters } from "@protos/blitz_static_tank_upgrade_single_stage";
|
import type { StageParameters } from "@protos/blitz_static_tank_upgrade_single_stage";
|
||||||
import { DoubleArrowDownIcon, DoubleArrowUpIcon } from "@radix-ui/react-icons";
|
import { DoubleArrowDownIcon, DoubleArrowUpIcon } from "@radix-ui/react-icons";
|
||||||
|
import { chunk } from "lodash-es";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
|
import { equipmentColumns } from "../../config/equipment";
|
||||||
|
import { catImages } from "../../config/images";
|
||||||
import {
|
import {
|
||||||
alternativeLines,
|
alternativeLines,
|
||||||
isAlternativeLine,
|
isAlternativeLine,
|
||||||
originalLineName,
|
originalLineName,
|
||||||
} from "../../config/alternativeLines";
|
} from "../../config/modules";
|
||||||
import { useEquipment } from "../../hooks/useEquipment";
|
import { useEquipment } from "../../hooks/useEquipment";
|
||||||
import { useProtagonist } from "../../hooks/useProtagonist";
|
import { useProtagonist } from "../../hooks/useProtagonist";
|
||||||
import { useStrings } from "../../hooks/useStrings";
|
import { useStrings } from "../../hooks/useStrings";
|
||||||
@@ -39,12 +42,41 @@ function Equipment() {
|
|||||||
tank.tank!.equipment_preset_catalog_id,
|
tank.tank!.equipment_preset_catalog_id,
|
||||||
tank.tank!.equipment_price_preset_catalog_id,
|
tank.tank!.equipment_price_preset_catalog_id,
|
||||||
);
|
);
|
||||||
|
const equipmentState = Tankopedia.use((state) => state.protagonist.equipment);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.section}>
|
<div className={styles.section}>
|
||||||
<div className={styles.header}>
|
<div className={styles.header}>
|
||||||
<Heading size="4">{strings.tanks.loadout.equipment}</Heading>
|
<Heading size="4">{strings.tanks.loadout.equipment}</Heading>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.equipment}>
|
||||||
|
{chunk(equipment.preset.slots, equipmentColumns).map((chunk, index) => {
|
||||||
|
return (
|
||||||
|
<div key={index} className={styles.row}>
|
||||||
|
{chunk.map((slot, index) => {
|
||||||
|
return (
|
||||||
|
<div key={index} className={styles.slots}>
|
||||||
|
{slot.options_catalog_i_ds.map((id) => {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
color="gray"
|
||||||
|
variant="soft"
|
||||||
|
radius="1"
|
||||||
|
key={id}
|
||||||
|
className={styles.slot}
|
||||||
|
>
|
||||||
|
<img src={catImages.squareTransparent} />
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
export const equipmentColumns = 3;
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export const catImages = {
|
||||||
|
squareTransparent:
|
||||||
|
"https://icatcare.org/img/asset/aW1hZ2VzL2N1dG91dHMvYWRvYmVzdG9ja18zMTYzODM5NjkucG5n/adobestock_316383969.png?p=default&s=86bb641e805a56548c51f3385510026b",
|
||||||
|
};
|
||||||
File renamed without changes.
@@ -1,13 +1,10 @@
|
|||||||
|
import { api } from "../api/dynamic";
|
||||||
|
import { useAwait } from "./useAwait";
|
||||||
|
|
||||||
export function useEquipment(presetId: string, priceId: string) {
|
export function useEquipment(presetId: string, priceId: string) {
|
||||||
// const [, presetName] = presetId.split(".");
|
const equipment = useAwait(() => api.equipment(), "equipment");
|
||||||
// const [, priceName] = priceId.split(".");
|
const preset = equipment.presets[presetId];
|
||||||
// const preset = useAwait(
|
const price = equipment.prices[priceId];
|
||||||
// () => api.equipmentPreset(presetName),
|
|
||||||
// `equipment-preset-${presetName}`,
|
return { preset, price, equipment };
|
||||||
// );
|
|
||||||
// const price = useAwait(
|
|
||||||
// () => api.equipmentPrice(priceName),
|
|
||||||
// `equipment-price-${priceName}`,
|
|
||||||
// );
|
|
||||||
// return { preset, price };
|
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
isAlternativeLine,
|
isAlternativeLine,
|
||||||
originalLineName,
|
originalLineName,
|
||||||
} from "../config/alternativeLines";
|
} from "../config/modules";
|
||||||
|
|
||||||
function patch(stage0: StageParameters, stage1: StageParameters) {
|
function patch(stage0: StageParameters, stage1: StageParameters) {
|
||||||
if (stage1.number !== ++stage0.number) {
|
if (stage1.number !== ++stage0.number) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { Tank } from "@protos/tank";
|
import type { Tank } from "@protos/tank";
|
||||||
import { alternativeLines } from "../config/alternativeLines";
|
import { alternativeLines } from "../config/modules";
|
||||||
import { TerrainHardness, type TankState } from "./tankState";
|
import { TerrainHardness, type TankState } from "./tankState";
|
||||||
|
|
||||||
export function createTankState({ tank, id }: Tank) {
|
export function createTankState({ tank, id }: Tank) {
|
||||||
@@ -22,6 +22,8 @@ export function createTankState({ tank, id }: Tank) {
|
|||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
|
|
||||||
|
equipment: {},
|
||||||
|
|
||||||
upgrades,
|
upgrades,
|
||||||
alternates,
|
alternates,
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ export enum TerrainHardness {
|
|||||||
export interface TankState {
|
export interface TankState {
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
|
equipment: Record<number, number>;
|
||||||
|
|
||||||
upgrades: Record<string, number>;
|
upgrades: Record<string, number>;
|
||||||
alternates: Record<string, boolean>;
|
alternates: Record<string, boolean>;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user