Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
doom committed Oct 9, 2023
1 parent 5dd3940 commit af44982
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
15 changes: 8 additions & 7 deletions code/controllers/subsystem/minimap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ SUBSYSTEM_DEF(minimaps)
// current svg
var/datum/svg_overlay/current_svg = new

var/action_queue_change = 0

/datum/tacmap/New(atom/source, minimap_type)
allowed_flags = minimap_type
owner = source
Expand Down Expand Up @@ -642,6 +644,7 @@ SUBSYSTEM_DEF(minimaps)
if(current_svg)
data["svgData"] = current_svg.svg_data

data["actionQueueChange"] = action_queue_change
data["mapRef"] = map_holder.map_ref
data["toolbarColorSelection"] = toolbar_color_selection
data["toolbarUpdatedSelection"] = toolbar_updated_selection
Expand Down Expand Up @@ -696,6 +699,7 @@ SUBSYSTEM_DEF(minimaps)

/datum/tacmap/ui_close(mob/user)
. = ..()
action_queue_change = 0
updated_canvas = FALSE
toolbar_color_selection = "black"
toolbar_updated_selection = "black"
Expand Down Expand Up @@ -729,26 +733,23 @@ SUBSYSTEM_DEF(minimaps)
// forces state change, this will export the svg.
toolbar_updated_selection = "export"
updated_canvas = TRUE
action_queue_change += 1
. = TRUE

if ("clearCanvas")
if(toolbar_updated_selection == "clear")
toolbar_updated_selection = toolbar_color_selection
return
toolbar_updated_selection = "clear"
action_queue_change += 1
. = TRUE

if ("undoChange")
if(toolbar_updated_selection == "undo")
toolbar_updated_selection = toolbar_color_selection
return
toolbar_updated_selection = "undo"
action_queue_change += 1
. = TRUE

if ("selectColor")

toolbar_color_selection = params["color"]
toolbar_updated_selection = toolbar_color_selection
action_queue_change += 1
. = TRUE

if ("selectAnnouncement")
Expand Down
7 changes: 4 additions & 3 deletions tgui/packages/tgui/interfaces/CanvasLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class CanvasLayer extends Component {
// using this.state prevents unpredictable behavior
this.state = {
selection: this.props.selection,
action: this.props.actionQueueChange,
};

// needs to be of type png of jpg
Expand Down Expand Up @@ -135,7 +136,6 @@ export class CanvasLayer extends Component {
if (line.length === 0) {
return;
}
const prevColor = line[0][4];

this.ctx.clearRect(
0,
Expand All @@ -161,7 +161,8 @@ export class CanvasLayer extends Component {
this.ctx.stroke();
});
});
this.setState({ selection: prevColor });

this.setState({ selection: this.props.prevColor });
return;
}

Expand All @@ -175,7 +176,7 @@ export class CanvasLayer extends Component {
};

componentDidUpdate(prevProps) {
if (prevProps.selection !== this.props.selection) {
if (prevProps.actionQueueChange !== this.props.actionQueueChange) {
this.handleSelectionChange();
}
}
Expand Down
17 changes: 9 additions & 8 deletions tgui/packages/tgui/interfaces/TacticalMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ interface TacMapProps {
canViewCanvas: number;
newCanvasFlatImage: string;
oldCanvasFlatImage: string;
actionQueueChange: number;
exportedColor: string;
currentMapName: string;
mapRef: any;
currentMenu: string;
Expand Down Expand Up @@ -166,14 +168,11 @@ const DrawMapPanel = (props, context) => {
data.exportedTacMapImage = image;
};

const handleColorSelection = () => {
if (
colors[data.toolbarUpdatedSelection] !== null &&
colors[data.toolbarUpdatedSelection] !== undefined
) {
return colors[data.toolbarUpdatedSelection];
const handleColorSelection = (dataSelection) => {
if (colors[dataSelection] !== null && colors[dataSelection] !== undefined) {
return colors[dataSelection];
} else {
return data.toolbarUpdatedSelection;
return dataSelection;
}
};

Expand Down Expand Up @@ -262,8 +261,10 @@ const DrawMapPanel = (props, context) => {
</Section>
<Section>
<CanvasLayer
selection={handleColorSelection()}
selection={handleColorSelection(data.toolbarUpdatedSelection)}
actionQueueChange={data.actionQueueChange}
imageSrc={data.newCanvasFlatImage}
prevColor={handleColorSelection(data.toolbarColorSelection)}
onImageExport={handleTacMapExport}
/>
</Section>
Expand Down

0 comments on commit af44982

Please sign in to comment.