import { sortBy } from 'common/collections'; import { capitalize, decodeHtmlEntities } from 'common/string'; import { Fragment } from 'inferno'; import { useBackend, useLocalState } from '../backend'; import { Box, Button, ByondUi, Flex, LabeledList, Section, Tabs, ColorBox } from '../components'; import { Window } from '../layouts'; export const AppearanceChanger = (props, context) => { const { act, config, data } = useBackend(context); const { name, specimen, gender, gender_id, hair_style, facial_hair_style, ear_style, tail_style, wing_style, markings, change_race, change_gender, change_eye_color, change_skin_tone, change_skin_color, change_hair_color, change_facial_hair_color, change_hair, change_facial_hair, mapRef, } = data; const { title } = config; const change_color = change_eye_color || change_skin_tone || change_skin_color || change_hair_color || change_facial_hair_color; let firstAccesibleTab = -1; if (change_race) { firstAccesibleTab = 0; } else if (change_gender) { firstAccesibleTab = 1; } else if (change_color) { firstAccesibleTab = 2; } else if (change_hair) { firstAccesibleTab = 4; } else if (change_facial_hair) { firstAccesibleTab = 5; } const [tabIndex, setTabIndex] = useLocalState(context, 'tabIndex', firstAccesibleTab); return (
{name} {specimen} {gender ? capitalize(gender) : 'Not Set'} {gender_id ? capitalize(gender_id) : 'Not Set'} {hair_style ? capitalize(hair_style) : 'Not Set'} {facial_hair_style ? capitalize(facial_hair_style) : 'Not Set'} {ear_style ? capitalize(ear_style) : 'Not Set'} {tail_style ? capitalize(tail_style) : 'Not Set'} {wing_style ? capitalize(wing_style) : 'Not Set'}
{change_race ? ( setTabIndex(0)}> Race ) : null} {change_gender ? ( setTabIndex(1)}> Gender & Sex ) : null} {change_color ? ( setTabIndex(2)}> Colors ) : null} {change_hair ? ( setTabIndex(3)}> Hair setTabIndex(5)}> Ear setTabIndex(6)}> Tail setTabIndex(7)}> Wing setTabIndex(8)}> Markings ) : null} {change_facial_hair ? ( setTabIndex(4)}> Facial Hair ) : null} {change_race && tabIndex === 0 ? : null} {change_gender && tabIndex === 1 ? : null} {change_color && tabIndex === 2 ? : null} {change_hair && tabIndex === 3 ? : null} {change_facial_hair && tabIndex === 4 ? : null} {change_hair && tabIndex === 5 ? : null} {change_hair && tabIndex === 6 ? : null} {change_hair && tabIndex === 7 ? : null} {change_hair && tabIndex === 8 ? : null}
); }; const AppearanceChangerSpecies = (props, context) => { const { act, data } = useBackend(context); const { species, specimen } = data; const sortedSpecies = sortBy((val) => val.specimen)(species || []); return (
{sortedSpecies.map((spec) => (
); }; const AppearanceChangerGender = (props, context) => { const { act, data } = useBackend(context); const { gender, gender_id, genders, id_genders } = data; return (
{genders.map((g) => (
); }; const AppearanceChangerColors = (props, context) => { const { act, data } = useBackend(context); const { change_eye_color, change_skin_tone, change_skin_color, change_hair_color, change_facial_hair_color, eye_color, skin_color, hair_color, facial_hair_color, ears_color, ears2_color, tail_color, tail2_color, wing_color, wing2_color, } = data; return (
{change_eye_color ? (
); }; const AppearanceChangerHair = (props, context) => { const { act, data } = useBackend(context); const { hair_style, hair_styles } = data; return (
{hair_styles.map((hair) => (
); }; const AppearanceChangerFacialHair = (props, context) => { const { act, data } = useBackend(context); const { facial_hair_style, facial_hair_styles } = data; return (
{facial_hair_styles.map((hair) => (
); }; const AppearanceChangerEars = (props, context) => { const { act, data } = useBackend(context); const { ear_style, ear_styles } = data; return (
); }; const AppearanceChangerTails = (props, context) => { const { act, data } = useBackend(context); const { tail_style, tail_styles } = data; return (
); }; const AppearanceChangerWings = (props, context) => { const { act, data } = useBackend(context); const { wing_style, wing_styles } = data; return (
); }; const AppearanceChangerMarkings = (props, context) => { const { act, data } = useBackend(context); const { markings } = data; return (
); };