-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement ability to change cell color on grid maps
Co-authored-by: francisanthony17 <[email protected]>
- Loading branch information
1 parent
a5bd5ba
commit 17ca572
Showing
20 changed files
with
284 additions
and
70 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,17 +1,5 @@ | ||
import { createElement } from "react"; | ||
import { mapParsers } from "./map-parser"; | ||
import { RendererMap, RendererProps } from "./Renderer"; | ||
import { useUIState } from "slices/UIState"; | ||
|
||
export function JSONRenderer(props: RendererProps) { | ||
const [{ parameters }] = useUIState(); | ||
return createElement(renderers[parameters?.format], props); | ||
} | ||
|
||
const renderers: RendererMap = { | ||
json: JSONRenderer, | ||
}; | ||
import { mapParsers } from "./map-parser"; | ||
|
||
export function getParser(key = "") { | ||
return mapParsers[key]; | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
client/src/components/renderer/map-parser/grid/getGridSymbols.worker.ts
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,22 @@ | ||
import { chain } from "lodash"; | ||
import { ParseGridWorkerParameters } from "./parseGrid.worker"; | ||
|
||
export type GetGridSymbolsReturnType = { | ||
symbols: string[]; | ||
}; | ||
|
||
export type GetGridSymbolsParameters = Pick<ParseGridWorkerParameters, "map">; | ||
|
||
export function getGridSymbols({ | ||
map: m, | ||
}: GetGridSymbolsParameters): GetGridSymbolsReturnType { | ||
const lines = m.split(/\r?\n/); | ||
const [, , , , ...grid] = lines; | ||
return { | ||
symbols: chain(grid).join("").trim().split("").uniq().value(), | ||
}; | ||
} | ||
|
||
onmessage = ({ data }: MessageEvent<GetGridSymbolsParameters>) => { | ||
postMessage(getGridSymbols(data)); | ||
}; |
17 changes: 17 additions & 0 deletions
17
client/src/components/renderer/map-parser/grid/getGridSymbolsAsync.ts
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,17 @@ | ||
import { usingWorkerTask } from "workers/usingWorker"; | ||
import { | ||
GetGridSymbolsParameters, | ||
GetGridSymbolsReturnType, | ||
} from "./getGridSymbols.worker"; | ||
import getGridSymbolsUrl from "./getGridSymbols.worker.ts?worker&url"; | ||
|
||
export class GetGridSymbolsWorker extends Worker { | ||
constructor() { | ||
super(getGridSymbolsUrl, { type: "module" }); | ||
} | ||
} | ||
|
||
export const getGridSymbolsAsync = usingWorkerTask< | ||
GetGridSymbolsParameters, | ||
GetGridSymbolsReturnType | ||
>(GetGridSymbolsWorker); |
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
Oops, something went wrong.