From c102fdc9d975e918bb596c3ad3ec3e7deb2c894e Mon Sep 17 00:00:00 2001 From: DOOM Date: Wed, 28 Jun 2023 03:54:16 -0400 Subject: [PATCH] progress --- code/controllers/subsystem/minimap.dm | 3 +++ tgui/packages/tgui/interfaces/CanvasLayer.js | 9 +++------ tgui/packages/tgui/interfaces/TacticalMap.tsx | 12 +++++++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/code/controllers/subsystem/minimap.dm b/code/controllers/subsystem/minimap.dm index 70d7e1d839e1..4ebb65766a04 100644 --- a/code/controllers/subsystem/minimap.dm +++ b/code/controllers/subsystem/minimap.dm @@ -517,6 +517,9 @@ SUBSYSTEM_DEF(minimaps) . = TRUE if ("selectAnnouncement") + toolbar_selection = "export" + to_chat(usr, SPAN_WARNING("params1 -> [params["image"]]")) + // params["image"] <- "should" be of type png returned from tgui . = TRUE diff --git a/tgui/packages/tgui/interfaces/CanvasLayer.js b/tgui/packages/tgui/interfaces/CanvasLayer.js index 8fb6bd20bd3f..1c01f519f7b0 100644 --- a/tgui/packages/tgui/interfaces/CanvasLayer.js +++ b/tgui/packages/tgui/interfaces/CanvasLayer.js @@ -6,6 +6,7 @@ export class CanvasLayer extends Component { super(props); this.canvasRef = createRef(); + // color selection // using this.state prevents unpredictable behavior this.state = { @@ -168,13 +169,9 @@ export class CanvasLayer extends Component { this.setState({ selection: prevColor }); return; } - // this has barely been tested, and might be unfunctional, also a better way to do this according to paul. + if (selection === 'export') { - const exportDrawnImage = new Image(); - exportDrawnImage.src = this.canvasRef.current.toDataURL(); - exportDrawnImage.onload = () => { - onImageExport(exportDrawnImage); - }; + this.props.onImageExport(this.canvasRef.current.toDataURL()); return; } diff --git a/tgui/packages/tgui/interfaces/TacticalMap.tsx b/tgui/packages/tgui/interfaces/TacticalMap.tsx index 8a8372e1005c..6f102128ab17 100644 --- a/tgui/packages/tgui/interfaces/TacticalMap.tsx +++ b/tgui/packages/tgui/interfaces/TacticalMap.tsx @@ -15,10 +15,16 @@ export const TacticalMap = (props, context) => { const { data, act } = useBackend(context); // maybe this is the right way of doing this, maybe not, idk. - const handleTacMapExport = (image: any) => { - data.exportedTacMapImage = image; + const handleTacMapExport = (image: string) => { + if (image === null || image === undefined){ + data.exportedTacMapImage = "not found"; + } + else { + data.exportedTacMapImage = image; + } }; + return ( @@ -32,7 +38,7 @@ export const TacticalMap = (props, context) => {
-