import React from "react"; import {IShortWeapon, IWeapon} from "../types/IUnit"; import {AccordionDetails, AccordionSummary} from "@mui/material"; import {withTheme} from "../core/api"; import {IconUrl} from "../core/api"; import {ExpandMore} from "@mui/icons-material"; import {IMod} from "../types/Imod"; import {Irace} from "../types/Irace"; import WeaponFull from "./WeaponFull"; import {StyledAccordion} from "../commons/StyledAccordion"; interface IWeaponProps { weapon: IShortWeapon, isDefault: Boolean, renderRequired: Boolean, mod: IMod, race: Irace, haveReinforceMenu: Boolean, } class Weapon extends React.Component { public static defaultProps = { isDefault: false, renderRequired: true, }; humanReadableName(unit: string) { const firstUpper = String(unit).charAt(0).toUpperCase() + String(unit).slice(1); return firstUpper.replaceAll('_', ' ').replace('.rgd', ''); } render() { const theme = (this.props as any).theme; const isDark = theme.palette.mode === 'dark'; const textColor = isDark ? '#dee2e6' : 'rgba(0, 0, 0, 0.85)'; const weapon = this.props.weapon return (
} aria-controls="panel1-content" id="panel1-header" sx={{color: textColor, '& .MuiAccordionSummary-content': { margin: '12px 0' }, '& .MuiAccordionSummary-content.Mui-expanded': { margin: '12px 0' }}} > {!this.props.isDefault && weapon.icon && !weapon.icon.endsWith("upgrade.png") ? : ( weapon.isMeleeWeapon ? : )}   {weapon.name ? weapon.name : this.humanReadableName(weapon.filename)} {this.props.isDefault && (default)}
); } } export default withTheme(Weapon);