Targeting console shows scan of target (#18212)

* a

* a

* aa

* :)

* cc

* f

---------

Co-authored-by: DreamySkrell <>
This commit is contained in:
DreamySkrell
2024-01-19 11:32:05 +00:00
committed by GitHub
co-authored by DreamySkrell <>
parent f29596dab8
commit ae01e80fbe
5 changed files with 160 additions and 89 deletions
@@ -77,6 +77,11 @@
else
selected_z = 0
data["selected_z"] = 0
var/obj/effect/entry_point = selected_entrypoint
if(istype(entry_point) && entry_point.z)
data["entry_point_map_image"] = SSholomap.minimaps_scan_base64[entry_point.z]
data["entry_point_x"] = entry_point.x
data["entry_point_y"] = entry_point.y
data["entry_points"] = copy_entrypoints(selected_z)
if(cannon)
data["cannon"] = get_gun_data(cannon);
@@ -0,0 +1,41 @@
################################
# Example Changelog File
#
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
#
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
# When it is, any changes listed below will disappear.
#
# Valid Prefixes:
# bugfix
# wip (For works in progress)
# tweak
# soundadd
# sounddel
# rscadd (general adding of nice things)
# rscdel (general deleting of nice things)
# imageadd
# imagedel
# maptweak
# spellcheck (typo fixes)
# experiment
# balance
# admin
# backend
# security
# refactor
#################################
# Your name.
author: DreamySkrell
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
delete-after: True
# Any changes you've made. See valid prefix list above.
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
# SCREW THIS UP AND IT WON'T WORK.
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
changes:
- rscadd: "Targeting console shows a scan of the area when selecting a entry point."
+11
View File
@@ -4,6 +4,7 @@ import { useBackend } from '../backend';
import { Button, Section, Box, LabeledList } from '../components';
import { Dropdown } from '../components/Dropdown';
import { Window } from '../layouts';
import { MinimapView } from './common/MinimapView';
type ShipGun = {
name: string;
@@ -24,6 +25,9 @@ export type GunneryData = {
mobile_platform: BooleanLike;
platform_directions: string[];
platform_direction: string;
entry_point_map_image: any; // base64 icon
entry_point_x: number;
entry_point_y: number;
};
type Targeting = {
@@ -107,6 +111,13 @@ export const GunneryWindow = (props, context) => {
''
)}
</Section>
<Section collapsing title="Scan">
{MinimapView({
map_image: data.entry_point_map_image,
x: data.entry_point_x,
y: data.entry_point_y,
})}
</Section>
<Section collapsing title="Weaponry Control">
<Dropdown
options={gun_names}
@@ -1,6 +1,7 @@
import { useBackend } from '../backend';
import { Button, Section, Box, LabeledList } from '../components';
import { Window } from '../layouts';
import { MinimapView } from './common/MinimapView';
export type ShuttleControlConsoleMultiExploreData = {
shuttle_status: string;
@@ -25,13 +26,6 @@ export const ShuttleControlConsoleMultiExplore = (props, context) => {
const { act, data } =
useBackend<ShuttleControlConsoleMultiExploreData>(context);
const map_size = 255;
const zoom_mod = 2.0;
const center_point_x = data.destination_x;
const center_point_y = data.destination_y;
const rand = Math.random() * 1.0;
return (
<Window resizable>
<Window.Content scrollable>
@@ -100,88 +94,11 @@ export const ShuttleControlConsoleMultiExplore = (props, context) => {
{data.destination_map_image ? (
<Section title="Scan">
<svg
height={'250px'}
width={'100%'}
viewBox={`0 0 ${map_size} ${map_size}`}
overflow={'hidden'}>
<g
transform={`translate(
${
(map_size * (zoom_mod - 1.0)) / -2 +
(255 / 2 - center_point_x)
}
${
(map_size * (zoom_mod - 1.0)) / -2 +
(255 / 2 - (map_size - center_point_y))
}
)`}>
<image
width={map_size * zoom_mod}
height={map_size * zoom_mod}
xlinkHref={`data:image/jpeg;base64,${data.destination_map_image}`}
/>
<polygon
points="3,0 0,3 -3,0 0,-3"
fill="#FF0000"
stroke="#FFFF00"
stroke-width="0.5"
transform={`translate(
${center_point_x * zoom_mod}
${(map_size - center_point_y) * zoom_mod}
)`}
/>
<circle
r={16}
cx={0}
cy={0}
fill="none"
stroke="#FF0000"
stroke-width="1"
transform={`translate(
${center_point_x * zoom_mod}
${(map_size - center_point_y) * zoom_mod}
)`}
/>
<rect
x={-24}
y={-24}
width={48}
height={48}
stroke="red"
stroke-width="1"
fill="none"
transform={`translate(
${center_point_x * zoom_mod}
${(map_size - center_point_y) * zoom_mod}
)`}
/>
<text
x="26"
y="-8"
text-anchor="left"
fill="red"
font-size="12"
transform={`translate(
${center_point_x * zoom_mod}
${(map_size - center_point_y) * zoom_mod}
)`}>
{data.destination_x}
</text>
<text
x="26"
y="8"
text-anchor="left"
fill="red"
font-size="12"
transform={`translate(
${center_point_x * zoom_mod}
${(map_size - center_point_y) * zoom_mod}
)`}>
{data.destination_y}
</text>
</g>
</svg>
{MinimapView({
map_image: data.destination_map_image,
x: data.destination_x,
y: data.destination_y,
})}
</Section>
) : (
''
@@ -0,0 +1,97 @@
import { NoticeBox } from 'tgui/components';
type MinimapViewProps = {
map_image: any; // base64 icon
x: number;
y: number;
};
export const MinimapView = (props: MinimapViewProps) => {
const map_size = 255;
const zoom_mod = 2.0;
const center_point_x = props.x;
const center_point_y = props.y;
return props.map_image ? (
<svg
height={'250px'}
width={'100%'}
viewBox={`0 0 ${map_size} ${map_size}`}
overflow={'hidden'}>
<g
transform={`translate(
${(map_size * (zoom_mod - 1.0)) / -2 + (255 / 2 - center_point_x)}
${
(map_size * (zoom_mod - 1.0)) / -2 +
(255 / 2 - (map_size - center_point_y))
}
)`}>
<image
width={map_size * zoom_mod}
height={map_size * zoom_mod}
xlinkHref={`data:image/jpeg;base64,${props.map_image}`}
/>
<polygon
points="3,0 0,3 -3,0 0,-3"
fill="#FF0000"
stroke="#FFFF00"
stroke-width="0.5"
transform={`translate(
${center_point_x * zoom_mod}
${(map_size - center_point_y) * zoom_mod}
)`}
/>
<circle
r={16}
cx={0}
cy={0}
fill="none"
stroke="#FF0000"
stroke-width="1"
transform={`translate(
${center_point_x * zoom_mod}
${(map_size - center_point_y) * zoom_mod}
)`}
/>
<rect
x={-24}
y={-24}
width={48}
height={48}
stroke="red"
stroke-width="1"
fill="none"
transform={`translate(
${center_point_x * zoom_mod}
${(map_size - center_point_y) * zoom_mod}
)`}
/>
<text
x="26"
y="-8"
text-anchor="left"
fill="red"
font-size="12"
transform={`translate(
${center_point_x * zoom_mod}
${(map_size - center_point_y) * zoom_mod}
)`}>
{props.x}
</text>
<text
x="26"
y="8"
text-anchor="left"
fill="red"
font-size="12"
transform={`translate(
${center_point_x * zoom_mod}
${(map_size - center_point_y) * zoom_mod}
)`}>
{props.y}
</text>
</g>
</svg>
) : (
<NoticeBox warning>No scan image available.</NoticeBox>
);
};