Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | 26x 26x 26x 26x 1x 26x 26x | import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import type { SceneMapData, VariableMapData } from "lib/compiler/compileData";
import type { UsageData } from "lib/compiler/romUsage";
import isEqual from "lodash/isEqual";
import type { DebuggerScriptContext } from "shared/lib/debugger/types";
export interface DebuggerState {
initialized: boolean;
variableSymbols: string[];
variableDataBySymbol: Record<string, VariableMapData>;
gbvmScripts: Record<string, string>;
sceneMap: Record<string, SceneMapData>;
vramPreview: string;
variablesData: number[];
scriptContexts: DebuggerScriptContext[];
currentSceneSymbol: string;
isPaused: boolean;
isLogOpen: boolean;
usageData: UsageData | null;
}
export const initialState: DebuggerState = {
initialized: false,
variableSymbols: [],
variableDataBySymbol: {},
gbvmScripts: {},
sceneMap: {},
vramPreview: "",
variablesData: [],
scriptContexts: [],
currentSceneSymbol: "",
isPaused: true,
isLogOpen: false,
usageData: null,
};
const debuggerSlice = createSlice({
name: "debug",
initialState,
reducers: {
disconnect: (state) => {
state.initialized = false;
state.isPaused = false;
},
setSymbols: (
state,
action: PayloadAction<{
variableDataBySymbol: Record<string, VariableMapData>;
sceneMap: Record<string, SceneMapData>;
gbvmScripts: Record<string, string>;
}>,
) => {
state.variableDataBySymbol = action.payload.variableDataBySymbol;
state.sceneMap = action.payload.sceneMap;
state.gbvmScripts = action.payload.gbvmScripts;
state.variableSymbols = Object.keys(state.variableDataBySymbol);
state.initialized = true;
},
setRAMData: (
state,
action: PayloadAction<{
vramPreview: string;
variablesData: number[];
scriptContexts: DebuggerScriptContext[];
currentSceneSymbol: string;
isPaused: boolean;
}>,
) => {
Iif (!state.isPaused && action.payload.isPaused) {
// Debugger became paused, close build log
state.isLogOpen = false;
}
state.isPaused = action.payload.isPaused;
state.vramPreview = action.payload.vramPreview;
Iif (!isEqual(state.variablesData, action.payload.variablesData)) {
state.variablesData = action.payload.variablesData;
}
Iif (!isEqual(state.scriptContexts, action.payload.scriptContexts)) {
state.scriptContexts = action.payload.scriptContexts;
}
state.currentSceneSymbol = action.payload.currentSceneSymbol;
},
setIsLogOpen: (state, action: PayloadAction<boolean>) => {
state.isLogOpen = action.payload;
},
setUsageData: (state, action: PayloadAction<UsageData>) => {
state.usageData = action.payload;
},
},
});
export const { actions } = debuggerSlice;
export default debuggerSlice.reducer;
|