Skip to content

Commit

Permalink
Overlay Right,Left
Browse files Browse the repository at this point in the history
  • Loading branch information
OhMyGuus committed Dec 30, 2020
1 parent 48c7ebb commit 29c9213
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/renderer/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface AvatarProps {
muted?: boolean;
connectionState?: 'disconnected' | 'novoice' | 'connected';
socketConfig?: SocketConfig;
showborder?: boolean;
}

const Avatar: React.FC<AvatarProps> = function ({
Expand All @@ -73,12 +74,13 @@ const Avatar: React.FC<AvatarProps> = function ({
size,
connectionState,
socketConfig,
showborder
}: AvatarProps) {
const status = isAlive ? 'alive' : 'dead';
let image = players[status][player.colorId];
if (!image) image = players[status][0];
const classes = useStyles({
borderColor: talking ? borderColor : 'transparent',
borderColor: talking ? borderColor : showborder === true? '#ccbdcc' : 'transparent',
size,
});

Expand Down
41 changes: 35 additions & 6 deletions src/renderer/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ export default function Overlay(): JSX.Element {
</p>
);
const playersCSS: React.CSSProperties = {};
const playerCSS: React.CSSProperties = { textAlign: 'center' };

let playerList: Player[] = [];
if (gameState.players && gameState.gameState != GameState.MENU)
playerList = relevantPlayers;
Expand All @@ -184,21 +186,30 @@ export default function Overlay(): JSX.Element {
baseCSS['position'] = 'absolute';
baseCSS['bottom'] = '0px';
baseCSS['backgroundColor'] = 'rgba(0, 0, 0, 0.35)';
baseCSS['width'] = 'auto';
baseCSS['width'] = undefined;

playersCSS['justifyContent'] = 'left';
playersCSS['alignItems'] = 'left';
} else if (settings.overlayPosition == 'right' || settings.overlayPosition == 'left') {
baseCSS['marginLeft'] = settings.overlayPosition == 'right'? 'auto' : undefined;
baseCSS['marginRight'] = settings.overlayPosition == 'left'? 'auto' : undefined;
baseCSS['marginTop'] = '400px';
baseCSS['width'] = '300px';
baseCSS['backgroundColor'] = '';
playerCSS['width'] = '100%';
}
topArea = <></>;
if (
(settings.compactOverlay || gameState.gameState == GameState.TASKS) &&
(settings.compactOverlay ) &&
playerList
) {
playerList = talkingPlayers;
baseCSS['backgroundColor'] = 'rgba(0, 0, 0, 0)';
}
}

let isOnSide =
settings.overlayPosition == 'right' || settings.overlayPosition == 'left';
let playerArea: JSX.Element = <></>;
if (playerList) {
playerArea = (
Expand All @@ -211,13 +222,30 @@ export default function Overlay(): JSX.Element {
const name = settings.compactOverlay ? (
''
) : (
<span>
<span
style={{
float: isOnSide
? (settings.overlayPosition as Property.Float)
: 'none',
paddingTop: isOnSide ? '40px' : '',
fontWeight: 'bold',
paddingLeft: settings.overlayPosition == 'left'? '5px' : ''
}}
>
<small>{player.name}</small>
</span>
);
return (
<div key={player.id} style={{ width: '60px', textAlign: 'center' }}>
<div style={{ paddingLeft: '5px' }}>
<div key={player.id} style={playerCSS}>
<div
style={{
paddingLeft: '5px',
width: isOnSide ? '80px' : '60px',
float: isOnSide
? (settings.overlayPosition as Property.Float)
: 'none',
}}
>
<Avatar
key={player.id}
player={player}
Expand All @@ -226,10 +254,11 @@ export default function Overlay(): JSX.Element {
otherTalking[player.id] ||
(player.isLocal && talking)
}
showborder={isOnSide}
borderColor={connected ? '#2ecc71' : '#c0392b'}
isAlive={
(!player.isLocal && !otherDead[player.id]) ||
(player.isLocal && !player.isDead)
(player.isLocal && !player.isDead)
}
size={50}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ body {
flex-direction: row;
justify-content: center;
align-items: center;
width: '100%';
width: 100%;
flex-wrap: wrap;
white-space: nowrap;
overflow: hidden;
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,9 @@ const Settings: React.FC<SettingsProps> = function ({
>
<option value="top">Top Center</option>
<option value="bottom_left">Bottom Left</option>
<option value="right">Right</option>
<option value="left">Left</option>

</TextField>
</>
)}
Expand Down

0 comments on commit 29c9213

Please sign in to comment.