-
Notifications
You must be signed in to change notification settings - Fork 4
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 #748 from mafia-rust/feature/rework-mobile
Rework Mobile
- Loading branch information
Showing
49 changed files
with
571 additions
and
571 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
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
div.draggable { | ||
cursor: grab | ||
cursor: grab; | ||
touch-action: none; | ||
} | ||
|
||
div.draggable.dragged { | ||
|
77 changes: 0 additions & 77 deletions
77
client/src/components/gameModeSettings/EnabledModifiersDisplay.tsx
This file was deleted.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
client/src/components/gameModeSettings/EnabledModifiersSelector.tsx
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,78 @@ | ||
import React, { ReactElement, useCallback, useContext } from "react"; | ||
import { MODIFIERS, ModifierType } from "../../game/gameState.d"; | ||
import translate from "../../game/lang"; | ||
import StyledText from "../StyledText"; | ||
import { GameModeContext } from "./GameModesEditor"; | ||
import { Button } from "../Button"; | ||
|
||
export function EnabledModifiersSelector(props: Readonly<{ | ||
disabled: boolean, | ||
enabledModifiers?: ModifierType[], | ||
onChange?: (modifiers: ModifierType[]) => void, | ||
}>): ReactElement { | ||
let { enabledModifiers } = useContext(GameModeContext); | ||
enabledModifiers = props.enabledModifiers ?? enabledModifiers; | ||
|
||
return <div className="chat-menu-colors selector-section"> | ||
<h2>{translate("modifiers")}</h2> | ||
<EnabledModifiersDisplay | ||
disabled={props.disabled} | ||
modifiable={!props.disabled} | ||
enabledModifiers={enabledModifiers} | ||
onEnableModifiers={(modifiers: ModifierType[]) => { | ||
if (props.onChange) { | ||
props.onChange(enabledModifiers.concat(modifiers)) | ||
} | ||
}} | ||
onDisableModifiers={(modifiers: ModifierType[]) => { | ||
if (props.onChange) { | ||
props.onChange(enabledModifiers.filter(modifier => !modifiers.includes(modifier))) | ||
} | ||
}} | ||
/> | ||
</div> | ||
} | ||
|
||
type EnabledModifiersDisplayProps = { | ||
enabledModifiers: ModifierType[], | ||
} & ( | ||
{ | ||
modifiable: true, | ||
onDisableModifiers: (modifiers: ModifierType[]) => void, | ||
onEnableModifiers: (modifiers: ModifierType[]) => void, | ||
disabled?: boolean, | ||
} | | ||
{ | ||
modifiable?: false, | ||
} | ||
) | ||
|
||
export function EnabledModifiersDisplay(props: EnabledModifiersDisplayProps): ReactElement { | ||
const isEnabled = useCallback((modifier: ModifierType) => props.enabledModifiers.includes(modifier), [props.enabledModifiers]); | ||
|
||
const modifierTextElement = (modifier: ModifierType) => { | ||
|
||
return <StyledText | ||
noLinks={props.modifiable ?? false} | ||
className={!isEnabled(modifier) ? "keyword-disabled" : undefined} | ||
> | ||
{translate(modifier)} | ||
</StyledText> | ||
} | ||
|
||
return <div> | ||
{MODIFIERS.map((modifier, i) => | ||
props.modifiable | ||
? <Button key={modifier} | ||
disabled={props.disabled} | ||
onClick={() => (!isEnabled(modifier) ? props.onEnableModifiers : props.onDisableModifiers)([modifier])} | ||
> | ||
{modifierTextElement(modifier)} | ||
</Button> | ||
: <div key={modifier} className={"placard" + (!isEnabled(modifier) ? " disabled" : "")}> | ||
{modifierTextElement(modifier)} | ||
</div> | ||
|
||
)} | ||
</div> | ||
} |
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
Oops, something went wrong.