removed pixel map
This commit is contained in:
parent
b86641c538
commit
a069737efc
8
package-lock.json
generated
8
package-lock.json
generated
@ -42,7 +42,7 @@
|
||||
"ts-node": "^10.9.2",
|
||||
"ts-patch": "^3.1.2",
|
||||
"typescript": "^5.4.2",
|
||||
"vite": "^5.2.9",
|
||||
"vite": "^5.2.10",
|
||||
"vite-plugin-eslint": "^1.8.1",
|
||||
"vitest": "^1.2.0"
|
||||
}
|
||||
@ -10192,9 +10192,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "5.2.9",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.2.9.tgz",
|
||||
"integrity": "sha512-uOQWfuZBlc6Y3W/DTuQ1Sr+oIXWvqljLvS881SVmAj00d5RdgShLcuXWxseWPd4HXwiYBFW/vXHfKFeqj9uQnw==",
|
||||
"version": "5.2.10",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.2.10.tgz",
|
||||
"integrity": "sha512-PAzgUZbP7msvQvqdSD+ErD5qGnSFiGOoWmV5yAKUEI0kdhjbH6nMWVyZQC/hSc4aXwc0oJ9aEdIiF9Oje0JFCw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"esbuild": "^0.20.1",
|
||||
|
@ -50,7 +50,7 @@
|
||||
"ts-node": "^10.9.2",
|
||||
"ts-patch": "^3.1.2",
|
||||
"typescript": "^5.4.2",
|
||||
"vite": "^5.2.9",
|
||||
"vite": "^5.2.10",
|
||||
"vite-plugin-eslint": "^1.8.1",
|
||||
"vitest": "^1.2.0"
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import {
|
||||
addMapSection,
|
||||
addWidget,
|
||||
addWidgetToSection,
|
||||
getPixelMap,
|
||||
getSections,
|
||||
getWidgets,
|
||||
} from 'src/redux/slices/minimapSlice';
|
||||
@ -27,8 +26,7 @@ const Prototype3 = () => {
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
// get the pixel map and sections that were just made
|
||||
const pixelMap = useAppSelector(getPixelMap);
|
||||
// get the sections that were just made
|
||||
const sections = useAppSelector(getSections);
|
||||
const widgets = useAppSelector(getWidgets);
|
||||
const mousePosition = useMousePosition();
|
||||
@ -106,7 +104,6 @@ const Prototype3 = () => {
|
||||
const { widgetToDeploy, sectionID } = assimilator({
|
||||
// find if there is room for us to put the widget down (returns null if there is not room)
|
||||
possibleWidgets: possibleWidgets,
|
||||
pixelMap,
|
||||
sections,
|
||||
widgets,
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { Widget } from 'src/types/modalities';
|
||||
import type { Cell, Section, LinkedSectionWidget } from 'src/types/support-types';
|
||||
import type { Section, LinkedSectionWidget } from 'src/types/support-types';
|
||||
|
||||
|
||||
function doesOverlap(x1:number,y1:number,w1:number,h1:number,x2:number,y2:number,w2:number,h2:number){
|
||||
@ -16,7 +16,6 @@ function doesOverlap(x1:number,y1:number,w1:number,h1:number,x2:number,y2:number
|
||||
type AssimilatorProps = {
|
||||
// define expected input here and it's type (number, string, etc.)
|
||||
possibleWidgets: Widget[];
|
||||
pixelMap: Cell[][];
|
||||
sections: Section[];
|
||||
widgets: Widget[];
|
||||
};
|
||||
@ -26,7 +25,7 @@ type AssimilatorProps = {
|
||||
* @param ???
|
||||
* @returns ???
|
||||
*/
|
||||
const assimilator = ({ possibleWidgets, pixelMap, sections, widgets }: AssimilatorProps) => {
|
||||
const assimilator = ({ possibleWidgets, sections, widgets }: AssimilatorProps) => {
|
||||
|
||||
let widgetToDeploy: Widget | null = null; //will return null if we cannot find a space
|
||||
let sectionID: LinkedSectionWidget = {widgetID:'none', sectionID:'none'};
|
||||
|
@ -2,20 +2,14 @@ import { createSlice } from '@reduxjs/toolkit';
|
||||
import type { PayloadAction } from '@reduxjs/toolkit';
|
||||
import type { Widget } from '../../types/modalities';
|
||||
import type { Message } from 'src/types/schema-types';
|
||||
import type { Cell, LinkedSectionWidget, Section } from 'src/types/support-types';
|
||||
import type { LinkedSectionWidget, Section } from 'src/types/support-types';
|
||||
|
||||
const defaultCell: Cell = {
|
||||
widgetIDs: [],
|
||||
priority: 0,
|
||||
type: 'free',
|
||||
};
|
||||
|
||||
type InitialState = {
|
||||
visualComplexity: number;
|
||||
audioComplexity: number;
|
||||
widgets: Widget[];
|
||||
messages: Message[];
|
||||
pixelMap: Cell[][];
|
||||
sections: Section[];
|
||||
/* ADD MORE AS NEEDED... */
|
||||
};
|
||||
@ -25,7 +19,6 @@ const initialState: InitialState = {
|
||||
audioComplexity: 0,
|
||||
widgets: [],
|
||||
messages: [],
|
||||
pixelMap: new Array(1920).fill(new Array(1080).fill(defaultCell)),
|
||||
sections: [],
|
||||
};
|
||||
|
||||
@ -34,50 +27,11 @@ export const minimapSlice = createSlice({
|
||||
initialState,
|
||||
// reducers are used to update the state
|
||||
reducers: {
|
||||
/* initializeMap: (state) => {
|
||||
//given a location on the grid (top-left to bottom-right), make those pixels the given section
|
||||
const defaultCell: Cell = {
|
||||
widgetIDs: [],
|
||||
priority: 0,
|
||||
type: 'free',
|
||||
};
|
||||
state.pixelMap = new Array(1080)
|
||||
.fill(new Array(1920).fill(defaultCell))
|
||||
console.log(state.pixelMap);
|
||||
}, */
|
||||
addMapSection: (state, action) => {
|
||||
const section = action.payload;
|
||||
|
||||
const tempCell: Cell = {
|
||||
widgetIDs: [],
|
||||
priority: section.priority,
|
||||
type: section.type,
|
||||
};
|
||||
|
||||
for (let col = section.x; col < section.x + section.w; col++) {
|
||||
//add the specified cell to the pixel map to create section region
|
||||
for (let row = section.y; row < section.y + section.h; row++) {
|
||||
state.pixelMap[row][col] = tempCell;
|
||||
}
|
||||
}
|
||||
state.sections.push(section); //add it to our sections as well
|
||||
state.sections.push(action.payload); //add it to our sections as well
|
||||
},
|
||||
addWidget: (state, action: PayloadAction<Widget>) => {
|
||||
state.widgets.push(action.payload); //add to the widgets
|
||||
for (
|
||||
let x = action.payload.x;
|
||||
x < action.payload.x + action.payload.w;
|
||||
x++
|
||||
) {
|
||||
//add the widgetID to the cells it is filling
|
||||
for (
|
||||
let y = action.payload.y;
|
||||
y < action.payload.y + action.payload.h;
|
||||
y++
|
||||
) {
|
||||
state.pixelMap[x][y].widgetIDs.push(action.payload.id);
|
||||
}
|
||||
}
|
||||
},
|
||||
removeWidget: (state, action: PayloadAction<string>) => {
|
||||
state.widgets = state.widgets.filter(
|
||||
@ -136,7 +90,6 @@ export const minimapSlice = createSlice({
|
||||
// selectors are used to access parts of the state within components
|
||||
selectors: {
|
||||
getSections: (state) => state.sections,
|
||||
getPixelMap: (state) => state.pixelMap,
|
||||
getWidgets: (state) => state.widgets,
|
||||
// find a single widget by id
|
||||
getWidgetById: (state, id: string) =>
|
||||
@ -162,7 +115,6 @@ export const {
|
||||
|
||||
export const {
|
||||
getSections,
|
||||
getPixelMap,
|
||||
getWidgets,
|
||||
getWidgetById,
|
||||
getMessages,
|
||||
|
Loading…
Reference in New Issue
Block a user