make auto-color accessible from settings

This commit is contained in:
HF 2024-02-05 23:21:17 +01:00
parent 304dc6acaa
commit 83684b83ca
5 changed files with 39 additions and 12 deletions

View File

@ -16,6 +16,7 @@ import templateLoader from '../ui/templateLoader';
import { import {
toggleOVEnabled, toggleOVEnabled,
toggleSmallPxls, toggleSmallPxls,
toggleRightShift,
setOvOpacity, setOvOpacity,
} from '../store/actions/templates'; } from '../store/actions/templates';
@ -27,11 +28,15 @@ const TemplateSettings = () => {
oVEnabled, oVEnabled,
oSmallPxls, oSmallPxls,
oOpacity, oOpacity,
oRightShift,
isOnMobile,
] = useSelector((state) => [ ] = useSelector((state) => [
state.templates.list, state.templates.list,
state.templates.ovEnabled, state.templates.ovEnabled,
state.templates.oSmallPxls, state.templates.oSmallPxls,
state.templates.oOpacity, state.templates.oOpacity,
state.templates.oRightShift,
state.user.isOnMobile,
], shallowEqual); ], shallowEqual);
const [editingIndices, setEditingIndices] = useState([]); const [editingIndices, setEditingIndices] = useState([]);
const close = useCallback(() => setShowAdd(false), []); const close = useCallback(() => setShowAdd(false), []);
@ -95,6 +100,18 @@ const TemplateSettings = () => {
<div className="modaldivider" /> <div className="modaldivider" />
</div> </div>
{(!isOnMobile) && (
<SettingsItem
title={t`Right-Shift Auto-Color`}
value={oRightShift}
onToggle={() => dispatch(toggleRightShift())}
>
{
t`Place pixels from overlay on right-shift, instead of history.`
}
</SettingsItem>
)}
{list.map(({ {list.map(({
enabled, imageId, canvasId, title, x, y, width, height, enabled, imageId, canvasId, title, x, y, width, height,
}, index) => (editingIndices.includes(index) ? ( }, index) => (editingIndices.includes(index) ? (

View File

@ -16,11 +16,9 @@ const PencilButton = () => {
const [ const [
holdPaint, holdPaint,
showMvmCtrls, showMvmCtrls,
easterEgg,
] = useSelector((state) => [ ] = useSelector((state) => [
state.gui.holdPaint, state.gui.holdPaint,
state.gui.showMvmCtrls, state.gui.showMvmCtrls,
state.gui.easterEgg,
], shallowEqual); ], shallowEqual);
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -35,12 +33,11 @@ const PencilButton = () => {
break; break;
} }
// eslint-disable-next-line no-fallthrough // eslint-disable-next-line no-fallthrough
case HOLD_PAINT.HISTORY: case HOLD_PAINT.HISTORY: {
if (easterEgg) { nextMode = HOLD_PAINT.OVERLAY;
nextMode = HOLD_PAINT.OVERLAY; dispatch(notify(t`Overlay Pencil ON`));
dispatch(notify(t`Overlay Pencil ON`)); break;
break; }
}
// eslint-disable-next-line no-fallthrough // eslint-disable-next-line no-fallthrough
default: default:
if (holdPaint) { if (holdPaint) {
@ -50,7 +47,7 @@ const PencilButton = () => {
} }
} }
dispatch(selectHoldPaint(nextMode)); dispatch(selectHoldPaint(nextMode));
}, [holdPaint, easterEgg, dispatch]); }, [holdPaint, dispatch]);
const onShortPress = useCallback(() => { const onShortPress = useCallback(() => {
let nextMode; let nextMode;

View File

@ -23,7 +23,7 @@ import {
import { HOLD_PAINT } from '../core/constants'; import { HOLD_PAINT } from '../core/constants';
import { notify } from '../store/actions/thunks'; import { notify } from '../store/actions/thunks';
const charKeys = ['g', 'h', 'x', 'm', 't', 'r', 'z', '+', '-']; const charKeys = ['g', 'h', 'x', 'm', 't', 'r', 'l', '+', '-'];
export function createKeyUpHandler(store) { export function createKeyUpHandler(store) {
return (event) => { return (event) => {
@ -153,7 +153,7 @@ export function createKeyDownHandler(store) {
if (event.location === KeyboardEvent.DOM_KEY_LOCATION_RIGHT) { if (event.location === KeyboardEvent.DOM_KEY_LOCATION_RIGHT) {
// right shift // right shift
store.dispatch(selectHoldPaint( store.dispatch(selectHoldPaint(
(store.getState().gui.easterEgg) (store.getState().templates.oRightShift)
? HOLD_PAINT.OVERLAY : HOLD_PAINT.HISTORY, ? HOLD_PAINT.OVERLAY : HOLD_PAINT.HISTORY,
true, true,
)); ));
@ -218,7 +218,7 @@ export function createKeyDownHandler(store) {
: t`Overlay OFF`)); : t`Overlay OFF`));
return; return;
} }
case 'z': case 'l':
store.dispatch(toggleEasterEgg()); store.dispatch(toggleEasterEgg());
store.dispatch(notify((store.getState().gui.easterEgg) store.dispatch(notify((store.getState().gui.easterEgg)
? t`Easter Egg ON` ? t`Easter Egg ON`

View File

@ -48,6 +48,12 @@ export function toggleSmallPxls() {
}; };
} }
export function toggleRightShift() {
return {
type: 's/TGL_RIGHTSHIFT',
};
}
export function setOvOpacity(opacity) { export function setOvOpacity(opacity) {
return { return {
type: 's/SET_O_OPACITY', type: 's/SET_O_OPACITY',

View File

@ -9,6 +9,7 @@ const initialState = {
mEnabled: false, mEnabled: false,
oOpacity: 40, oOpacity: 40,
oSmallPxls: true, oSmallPxls: true,
oRightShift: false,
/* /*
* [{ * [{
* enabled, * enabled,
@ -112,6 +113,12 @@ export default function templates(
oSmallPxls: !state.oSmallPxls, oSmallPxls: !state.oSmallPxls,
}; };
case 's/TGL_RIGHTSHIFT':
return {
...state,
oRightShift: !state.oRightShift,
};
case 's/SET_O_OPACITY': case 's/SET_O_OPACITY':
return { return {
...state, ...state,