refactor stuff
This commit is contained in:
parent
5d38af340e
commit
63bf9b15ff
|
@ -41,7 +41,7 @@ export function toggleGrid() {
|
||||||
|
|
||||||
export function togglePixelNotify() {
|
export function togglePixelNotify() {
|
||||||
return {
|
return {
|
||||||
type: 'TOGGLE_PIXEL_NOTIFY',
|
type: 'TOGGLE_PXL_NOTIFY',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,10 +106,9 @@ export function toggleOpenMenu() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setAllowSettingPixel(allowSettingPixel) {
|
export function requestPlaceTimeout() {
|
||||||
return {
|
return {
|
||||||
type: 'ALLOW_SETTING_PIXEL',
|
type: 'REQ_PLACE_TIMEOUT',
|
||||||
allowSettingPixel,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,27 +178,19 @@ export function moveDirection([vx, vy]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function moveNorth() {
|
export function moveNorth() {
|
||||||
return (dispatch) => {
|
return moveDirection([0, -1]);
|
||||||
dispatch(moveDirection([0, -1]));
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function moveWest() {
|
export function moveWest() {
|
||||||
return (dispatch) => {
|
return moveDirection([-1, 0]);
|
||||||
dispatch(moveDirection([-1, 0]));
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function moveSouth() {
|
export function moveSouth() {
|
||||||
return (dispatch) => {
|
return moveDirection([0, 1]);
|
||||||
dispatch(moveDirection([0, 1]));
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function moveEast() {
|
export function moveEast() {
|
||||||
return (dispatch) => {
|
return moveDirection([1, 0]);
|
||||||
dispatch(moveDirection([1, 0]));
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setScale(scale, zoompoint) {
|
export function setScale(scale, zoompoint) {
|
||||||
|
@ -322,9 +313,17 @@ export function receiveChatMessage(
|
||||||
* check socket/packets/PixelReturn.js for args
|
* check socket/packets/PixelReturn.js for args
|
||||||
*/
|
*/
|
||||||
export function storeReceivePixelReturn(args) {
|
export function storeReceivePixelReturn(args) {
|
||||||
args.type = 'REC_PIXEL_RETURN';
|
args.type = 'REC_PXL_RETURN';
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
export function requestPlacePixels(i, j, pixels) {
|
||||||
|
return {
|
||||||
|
type: 'REQ_PLACE_PXLS',
|
||||||
|
i,
|
||||||
|
j,
|
||||||
|
pixels,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function logoutUser(
|
export function logoutUser(
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -119,7 +119,7 @@ export default (store) => (next) => (action) => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'REC_PIXEL_RETURN': {
|
case 'REC_PXL_RETURN': {
|
||||||
switch (action.retCode) {
|
switch (action.retCode) {
|
||||||
case 0: {
|
case 0: {
|
||||||
// successfully placed pixel
|
// successfully placed pixel
|
||||||
|
|
|
@ -10,7 +10,7 @@ export default (store) => (next) => (action) => {
|
||||||
const ret = next(action);
|
const ret = next(action);
|
||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'REC_PIXEL_RETURN': {
|
case 'REC_PXL_RETURN': {
|
||||||
const renderer = getRenderer();
|
const renderer = getRenderer();
|
||||||
const {
|
const {
|
||||||
retCode,
|
retCode,
|
||||||
|
|
|
@ -95,7 +95,7 @@ export default (store) => (next) => (action) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'TOGGLE_GRID':
|
case 'TOGGLE_GRID':
|
||||||
case 'ALLOW_SETTING_PIXEL': {
|
case 'ALLOW_SETTING_PXL': {
|
||||||
const renderer = getRenderer();
|
const renderer = getRenderer();
|
||||||
renderer.forceNextSubrender = true;
|
renderer.forceNextSubrender = true;
|
||||||
break;
|
break;
|
||||||
|
@ -114,7 +114,7 @@ export default (store) => (next) => (action) => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'REC_PIXEL_RETURN': {
|
case 'REC_PXL_RETURN': {
|
||||||
const renderer = getRenderer();
|
const renderer = getRenderer();
|
||||||
renderer.forceNextSubrender = true;
|
renderer.forceNextSubrender = true;
|
||||||
const { coolDownSeconds } = action;
|
const { coolDownSeconds } = action;
|
||||||
|
|
|
@ -24,6 +24,14 @@ export default (store) => (next) => (action) => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'REQ_PLACE_PXLS': {
|
||||||
|
const {
|
||||||
|
i, j, pixels,
|
||||||
|
} = action;
|
||||||
|
SocketClient.requestPlacePixels(i, j, pixels);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// nothing
|
// nothing
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default function gui(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'TOGGLE_PIXEL_NOTIFY': {
|
case 'TOGGLE_PXL_NOTIFY': {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
showPixelNotify: !state.showPixelNotify,
|
showPixelNotify: !state.showPixelNotify,
|
||||||
|
|
|
@ -24,7 +24,7 @@ export default function ranks(
|
||||||
action,
|
action,
|
||||||
) {
|
) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'REC_PIXEL_RETURN': {
|
case 'REC_PXL_RETURN': {
|
||||||
const {
|
const {
|
||||||
rankedPxlCnt,
|
rankedPxlCnt,
|
||||||
} = action;
|
} = action;
|
||||||
|
|
|
@ -40,15 +40,21 @@ export default function user(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'ALLOW_SETTING_PIXEL': {
|
case 'REQ_PLACE_TIMEOUT': {
|
||||||
const { allowSettingPixel } = action;
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
allowSettingPixel,
|
allowSettingPixel: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'REC_PIXEL_RETURN': {
|
case 'REQ_PLACE_PXLS': {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
allowSettingPixel: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'REC_PXL_RETURN': {
|
||||||
const {
|
const {
|
||||||
wait: duration,
|
wait: duration,
|
||||||
} = action;
|
} = action;
|
||||||
|
|
|
@ -9,14 +9,14 @@
|
||||||
* */
|
* */
|
||||||
import { t } from 'ttag';
|
import { t } from 'ttag';
|
||||||
import {
|
import {
|
||||||
setAllowSettingPixel,
|
requestPlaceTimeout,
|
||||||
pAlert,
|
pAlert,
|
||||||
storeReceivePixelReturn,
|
storeReceivePixelReturn,
|
||||||
|
requestPlacePixels,
|
||||||
} from '../store/actions';
|
} from '../store/actions';
|
||||||
import {
|
import {
|
||||||
notify,
|
notify,
|
||||||
} from '../store/actions/thunks';
|
} from '../store/actions/thunks';
|
||||||
import SocketClient from '../socket/SocketClient';
|
|
||||||
|
|
||||||
let pixelTimeout = null;
|
let pixelTimeout = null;
|
||||||
/*
|
/*
|
||||||
|
@ -49,7 +49,7 @@ function requestFromQueue(store) {
|
||||||
pixelTimeout = setTimeout(() => {
|
pixelTimeout = setTimeout(() => {
|
||||||
pixelQueue = [];
|
pixelQueue = [];
|
||||||
pixelTimeout = null;
|
pixelTimeout = null;
|
||||||
store.dispatch(setAllowSettingPixel(true));
|
store.dispatch(requestPlaceTimeout());
|
||||||
store.dispatch(pAlert(
|
store.dispatch(pAlert(
|
||||||
t`Error :(`,
|
t`Error :(`,
|
||||||
t`Didn't get an answer from pixelplanet. Maybe try to refresh?`,
|
t`Didn't get an answer from pixelplanet. Maybe try to refresh?`,
|
||||||
|
@ -59,8 +59,7 @@ function requestFromQueue(store) {
|
||||||
|
|
||||||
lastRequestValues = pixelQueue.shift();
|
lastRequestValues = pixelQueue.shift();
|
||||||
const { i, j, pixels } = lastRequestValues;
|
const { i, j, pixels } = lastRequestValues;
|
||||||
SocketClient.requestPlacePixels(i, j, pixels);
|
store.dispatch(requestPlacePixels(i, j, pixels));
|
||||||
store.dispatch(setAllowSettingPixel(false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user