mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-21 12:53:56 +01:00
loaders
This commit is contained in:
1 parent
11088ee3dc
commit
75f91467ab
4 files changed
+26
-50
No files matched your search
@@ -45,7 +45,9 @@ export function Lighting({ hasPbr }: Props) {
|
|||||||
const wrapper = useRef<Group>(null);
|
const wrapper = useRef<Group>(null);
|
||||||
|
|
||||||
const highGraphics = TankopediaPersistent.use((state) => state.highGraphics);
|
const highGraphics = TankopediaPersistent.use((state) => state.highGraphics);
|
||||||
const requestedDisplay = Tankopedia.use((state) => state.requestedDisplay);
|
const requestedDisplay = Tankopedia.use(
|
||||||
|
(state) => state.loaders.display.requested,
|
||||||
|
);
|
||||||
const revealed = Tankopedia.use((state) => state.revealed);
|
const revealed = Tankopedia.use((state) => state.revealed);
|
||||||
const skinPending = Tankopedia.use(
|
const skinPending = Tankopedia.use(
|
||||||
(state) =>
|
(state) =>
|
||||||
@@ -64,6 +66,7 @@ export function Lighting({ hasPbr }: Props) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Tankopedia.mutate((draft) => {
|
Tankopedia.mutate((draft) => {
|
||||||
|
draft.showControls = true;
|
||||||
draft.revealed = true;
|
draft.revealed = true;
|
||||||
draft.loaders.model.loaded = true;
|
draft.loaders.model.loaded = true;
|
||||||
});
|
});
|
||||||
@@ -200,8 +203,10 @@ function Animator({
|
|||||||
wrapper,
|
wrapper,
|
||||||
hasPbr,
|
hasPbr,
|
||||||
}: AnimatorProps) {
|
}: AnimatorProps) {
|
||||||
const requestedDisplay = Tankopedia.use((state) => state.requestedDisplay);
|
const requestedDisplay = Tankopedia.use(
|
||||||
const display = Tankopedia.use((state) => state.display);
|
(state) => state.loaders.display.requested,
|
||||||
|
);
|
||||||
|
const display = Tankopedia.use((state) => state.loaders.display.loaded);
|
||||||
|
|
||||||
const factor =
|
const factor =
|
||||||
!hasPbr && display !== TankopediaDisplay.StaticArmor ? NON_PBR_FACTOR : 1;
|
!hasPbr && display !== TankopediaDisplay.StaticArmor ? NON_PBR_FACTOR : 1;
|
||||||
@@ -248,9 +253,12 @@ function Animator({
|
|||||||
|
|
||||||
invalidate();
|
invalidate();
|
||||||
|
|
||||||
if (x >= 1 && Tankopedia.state.display !== requestedDisplay) {
|
if (
|
||||||
|
x >= 1 &&
|
||||||
|
Tankopedia.state.loaders.display.loaded !== requestedDisplay
|
||||||
|
) {
|
||||||
Tankopedia.mutate((draft) => {
|
Tankopedia.mutate((draft) => {
|
||||||
draft.display = requestedDisplay;
|
draft.loaders.display.loaded = requestedDisplay;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,47 +1,16 @@
|
|||||||
import { uniqueGuns } from "@blitzkit/core";
|
|
||||||
import { useState } from "react";
|
|
||||||
import { DuelModule, useDuel } from "../../hooks/useDuel";
|
|
||||||
import { useEquipment } from "../../hooks/useEquipment";
|
|
||||||
import { useFullScreen } from "../../hooks/useFullScreen";
|
|
||||||
import { useFullscreenAvailability } from "../../hooks/useFullscreenAvailability";
|
|
||||||
import { useStrings } from "../../hooks/useStrings";
|
|
||||||
import { useUnwrapper } from "../../hooks/useUnwrapper";
|
|
||||||
import { Tankopedia } from "../../stores/tankopedia";
|
import { Tankopedia } from "../../stores/tankopedia";
|
||||||
import { TankopediaPersistent } from "../../stores/tankopediaPersistent";
|
|
||||||
import { TankopediaDisplay } from "../../stores/tankopediaPersistent/constants";
|
import { TankopediaDisplay } from "../../stores/tankopediaPersistent/constants";
|
||||||
import { SegmentedControl } from "../SegmentedControl";
|
import { SegmentedControl } from "../SegmentedControl";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
export function TankopediaOptions() {
|
export function TankopediaOptions() {
|
||||||
const strings = useStrings();
|
const requestedDisplay = Tankopedia.use(
|
||||||
const unwrap = useUnwrapper();
|
(state) => state.loaders.display.requested,
|
||||||
|
|
||||||
const hasCustomShell = Tankopedia.use(
|
|
||||||
(state) => state.customShell !== undefined,
|
|
||||||
);
|
);
|
||||||
const requestedDisplay = Tankopedia.use((state) => state.requestedDisplay);
|
const isVisible = Tankopedia.use((state) => state.showControls);
|
||||||
const isFullScreen = useFullScreen();
|
|
||||||
const advancedHighlighting = TankopediaPersistent.use(
|
|
||||||
(state) => state.advancedHighlighting,
|
|
||||||
);
|
|
||||||
const fullScreenAvailable = useFullscreenAvailability(true);
|
|
||||||
const protagonistTank = useDuel("protagonist", DuelModule.Tank);
|
|
||||||
const antagonistGun = useDuel("antagonist", DuelModule.Gun);
|
|
||||||
const antagonistShell = useDuel("antagonist", DuelModule.Shell);
|
|
||||||
const [antagonistSelectorOpen, setAntagonistSelectorOpen] = useState(false);
|
|
||||||
const antagonistTank = useDuel("antagonist", DuelModule.Tank);
|
|
||||||
const hasCalibratedShells = useEquipment("protagonist", 103);
|
|
||||||
const [tab, setTab] = useState("search");
|
|
||||||
const hasEnhancedArmor = useEquipment("protagonist", 110);
|
|
||||||
const antagonistUniqueGuns = uniqueGuns(antagonistTank.turrets);
|
|
||||||
const revealed = Tankopedia.use((state) => state.revealed);
|
|
||||||
const disturbed = Tankopedia.use((state) => state.disturbed);
|
|
||||||
const highGraphics = TankopediaPersistent.use((state) => state.highGraphics);
|
|
||||||
const modelRequested = Tankopedia.use((state) => state.modelRequested);
|
|
||||||
const equalize = Tankopedia.use((state) => state.environment.equalize);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.options} data-visible={revealed}>
|
<div className={styles.options} data-visible={isVisible}>
|
||||||
{/* <div className={styles.controls}>
|
{/* <div className={styles.controls}>
|
||||||
{disturbed && (
|
{disturbed && (
|
||||||
<>
|
<>
|
||||||
@@ -140,11 +109,11 @@ export function TankopediaOptions() {
|
|||||||
)}
|
)}
|
||||||
</div> */}
|
</div> */}
|
||||||
|
|
||||||
<div gap="3" align="center" mt="2">
|
<div>
|
||||||
<SegmentedControl
|
<SegmentedControl
|
||||||
onValueChange={(value) => {
|
onValueChange={(value) => {
|
||||||
Tankopedia.mutate((draft) => {
|
Tankopedia.mutate((draft) => {
|
||||||
draft.requestedDisplay = Number(value);
|
draft.loaders.display.requested = Number(value);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
value={`${requestedDisplay}`}
|
value={`${requestedDisplay}`}
|
||||||
|
|||||||
@@ -18,10 +18,8 @@ export function TankopediaSkinSwitcher() {
|
|||||||
const tank = useDuel("protagonist", DuelModule.Tank);
|
const tank = useDuel("protagonist", DuelModule.Tank);
|
||||||
|
|
||||||
const skin = Tankopedia.use((state) => state.loaders.skin.requested);
|
const skin = Tankopedia.use((state) => state.loaders.skin.requested);
|
||||||
const requestedDisplay = Tankopedia.use(
|
const showControls = Tankopedia.use((state) => state.showControls);
|
||||||
(state) => state.loaders.display.requested,
|
const display = Tankopedia.use((state) => state.loaders.display.loaded);
|
||||||
);
|
|
||||||
const revealed = Tankopedia.use((state) => state.revealed);
|
|
||||||
|
|
||||||
const skins = uniqBy(
|
const skins = uniqBy(
|
||||||
Object.values(camouflageDefinitions.camouflages).filter(
|
Object.values(camouflageDefinitions.camouflages).filter(
|
||||||
@@ -37,11 +35,10 @@ export function TankopediaSkinSwitcher() {
|
|||||||
skins.filter((camouflage) => camouflage.attachment),
|
skins.filter((camouflage) => camouflage.attachment),
|
||||||
].filter((group) => group.length > 0);
|
].filter((group) => group.length > 0);
|
||||||
|
|
||||||
|
const isVisible = showControls && display === TankopediaDisplay.Model;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div className={styles["skin-switcher"]} data-visible={isVisible}>
|
||||||
className={styles["skin-switcher"]}
|
|
||||||
data-visible={revealed && requestedDisplay === TankopediaDisplay.Model}
|
|
||||||
>
|
|
||||||
{groups.map((group, index) => (
|
{groups.map((group, index) => (
|
||||||
<div className={styles.group} key={index}>
|
<div className={styles.group} key={index}>
|
||||||
{group.map((camouflage) => {
|
{group.map((camouflage) => {
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ type HighlightArmor = {
|
|||||||
interface Tankopedia {
|
interface Tankopedia {
|
||||||
disturbed: boolean;
|
disturbed: boolean;
|
||||||
revealed: boolean;
|
revealed: boolean;
|
||||||
|
showControls: boolean;
|
||||||
|
|
||||||
protagonist: TankState;
|
protagonist: TankState;
|
||||||
antagonist: TankState;
|
antagonist: TankState;
|
||||||
@@ -129,6 +130,7 @@ export const Tankopedia = new Soapstone<Tankopedia, [TankDefinition]>(
|
|||||||
(tank) => ({
|
(tank) => ({
|
||||||
disturbed: false,
|
disturbed: false,
|
||||||
revealed: false,
|
revealed: false,
|
||||||
|
showControls: false,
|
||||||
|
|
||||||
protagonist: createTankState(tank),
|
protagonist: createTankState(tank),
|
||||||
antagonist: createTankState(tank),
|
antagonist: createTankState(tank),
|
||||||
|
|||||||
Reference in new issue
Block a user