-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from Benjythebee/add/overlayTextureManager
Working great! :) we just need to update docs, will add a new issue for it :)
- Loading branch information
Showing
15 changed files
with
739 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React from "react"; | ||
import styles from "../../pages/Appearance.module.css"; | ||
import cancel from '../../images/cancel.png'; | ||
import {SceneContext} from "../../context/SceneContext"; | ||
import CustomButton from "../custom-button"; | ||
import {combineURLs} from "../../library/load-utils"; | ||
import DecalItem from "./decalItem"; | ||
|
||
const DecalGridView = ({selectedTraitGroup,onBack})=>{ | ||
const {decalManager,characterManager} = React.useContext(SceneContext); | ||
const [selectedDecals, setSelectedDecals] = React.useState([]); | ||
|
||
const decals = selectedTraitGroup.getAllDecals(); | ||
React.useEffect(()=>{ | ||
const selected= Array.from(decalManager.applied.keys()) | ||
setSelectedDecals(selected.map((x)=>x)); | ||
},[]) | ||
|
||
|
||
return ( | ||
<div className={styles["selector-container-column"]}> | ||
<CustomButton | ||
theme="dark" | ||
text={"Back"} | ||
size={14} | ||
className={styles.buttonLeft} | ||
onClick={onBack} | ||
/> | ||
<div className={styles["selector-container"]} > | ||
<DecalItem key={"empty"} | ||
src={cancel} | ||
active={false} | ||
select={()=>{ | ||
decalManager.removeAllOverlayedTextures() | ||
setSelectedDecals([]); | ||
}} | ||
/> | ||
{decals.map((decal)=>{ | ||
const path = combineURLs(characterManager.manifestData.getTraitsDirectory(),decal.thumbnail); | ||
|
||
return ( | ||
<DecalItem | ||
key={decal.id} | ||
src={path} | ||
active={selectedDecals.includes(decal.id)} | ||
select={()=>{ | ||
if(selectedDecals.includes(decal.id)){ | ||
decalManager.removeOverlayTexture(decal.id).then(()=>{ | ||
setSelectedDecals(selectedDecals.filter((x)=>x!==decal.id)); | ||
}) | ||
|
||
}else{ | ||
decalManager.loadOverlayTexture(selectedTraitGroup,decal.id).then(()=>{ | ||
setSelectedDecals(selectedDecals.concat([decal.id])); | ||
}) | ||
} | ||
}} | ||
/> | ||
) | ||
})} | ||
</div> | ||
|
||
</div> | ||
) | ||
} | ||
|
||
|
||
export default DecalGridView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import styles from "../../pages/Appearance.module.css" | ||
import {TokenBox} from '../token-box'; | ||
|
||
const DecalItem = ({active,src,select})=>{ | ||
|
||
return ( | ||
<div | ||
className={`${styles["selectorButton"]}`} | ||
onClick={select} | ||
> | ||
<TokenBox | ||
size={56} | ||
icon={src||''} | ||
rarity={active ? "mythic" : "none"} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default DecalItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.