Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiz nanomap #1402

Merged
merged 23 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion code/modules/asset_cache/assets/asset_nanomap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
// It REALLY doesnt matter too much if these arent up to date
// They are relatively big
assets = list(
"Cyberiad220_nanomap_z1.png" = 'icons/_nanomaps/Cyberiad220_nanomap_z1.png', // SS220 EDITS - OUR MAPS
"Cyberiad220_nanomap_z1.png" = 'icons/_nanomaps/Cyberiad220_nanomap_z1.png', // SS220 EDIT START - OUR MAPS
"Delta220_nanomap_z1.png" = 'icons/_nanomaps/Delta220_nanomap_z1.png',
"MetaStation220_nanomap_z1.png" = 'icons/_nanomaps/MetaStation220_nanomap_z1.png',
"Lavaland_nanomap_z1.png" = 'icons/_nanomaps/Lavaland_nanomap_z1.png', // SS220 EDIT END - OUR MAPS
"CereStation_nanomap_z1.png" = 'icons/_nanomaps/CereStation_nanomap_z1.png',
)
Binary file added icons/_nanomaps/Lavaland_nanomap_z1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions modular_ss220/camera_nanomap/code/camera.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/obj/machinery/camera
var/nanomap_png

/obj/machinery/camera/Initialize(mapload, should_add_to_cameranet)
. = ..()
if(z == level_name_to_num(MAIN_STATION))
nanomap_png = "[SSmapping.map_datum.technical_name]_nanomap_z1.png"
else if(z == level_name_to_num(MINING))
nanomap_png = "[MINING]_nanomap_z1.png"

/obj/machinery/computer/security
var/list/z_levels = list() // Assoc list, "z_level":"nanomap.png"
var/current_z_level_index

/obj/machinery/computer/security/ui_interact(mob/user, datum/tgui/ui = null)
// Update UI
ui = SStgui.try_update_ui(user, src, ui)
Expand Down Expand Up @@ -47,6 +61,7 @@
)
var/list/cameras = get_available_cameras()
data["cameras"] = list()
z_levels = list()
for(var/i in cameras)
var/obj/machinery/camera/C = cameras[i]
data["cameras"] += list(list(
Expand All @@ -56,10 +71,38 @@
z = C.z,
status = C.status
))
if("[C.z]" in z_levels || !C.nanomap_png)
continue
z_levels += list("[C.z]" = C.nanomap_png)
// Sort it by z levels
z_levels = sortAssoc(z_levels)
if(isnull(current_z_level_index))
current_z_level_index = clamp(z_levels.Find("[z]"), 1, length(z_levels))
else
current_z_level_index = clamp(current_z_level_index, 1, length(z_levels))
// On null, it uses map datum value
data["mapUrl"] = z_levels["[z_levels[current_z_level_index]]"] || null
// On null, it uses station's z level
data["selected_z_level"] = z_levels[current_z_level_index] || null
return data

/obj/machinery/computer/security/ui_static_data()
var/list/data = list()
data["mapRef"] = map_name
data["stationLevel"] = level_name_to_num(MAIN_STATION)
return data

/obj/machinery/computer/security/ui_act(action, params)
. = ..()
if(. && action == "switch_camera")
if(!active_camera)
return
current_z_level_index = z_levels.Find("[active_camera.z]")
return
if(.)
return

if(action == "switch_z_level")
var/z_dir = params["z_dir"]
current_z_level_index = clamp(current_z_level_index + z_dir, 1, length(z_levels))
return TRUE
17 changes: 16 additions & 1 deletion tgui/packages/tgui/components/NanoMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class NanoMap extends Component {
const { dragging, offsetX, offsetY, zoom = 1 } = this.state;
const { children } = this.props;

const mapUrl = config.map + '_nanomap_z1.png';
const mapUrl = this.props.mapUrl || config.map + '_nanomap_z1.png';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а у нас не своя случаем Nanomap220?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, и приписка 220 имеется на самой карте, а не на _nanomap.png

const mapSize = MAP_SIZE * zoom + 'px';
const newStyle = {
width: mapSize,
Expand Down Expand Up @@ -151,6 +151,7 @@ export class NanoMap extends Component {
<Box>{children}</Box>
</Box>
<NanoMapZoomer zoom={zoom} onZoom={this.handleZoom} onReset={this.handleReset} />
<NanoMapZSelector />
</Box>
);
}
Expand Down Expand Up @@ -280,3 +281,17 @@ class NanoButton extends Component {
}
}
NanoMap.NanoButton = NanoButton;

const NanoMapZSelector = (props, context) => {
const { act, data } = useBackend(context);
return (
<Box className="NanoMap__zchooser">
<Box>
<Button icon={'chevron-up'} tooltip={'Уровнем выше'} onClick={() => act('switch_z_level', { z_dir: 1 })} />
</Box>
<Box>
<Button icon={'chevron-down'} tooltip={'Уровнем ниже'} onClick={() => act('switch_z_level', { z_dir: -1 })} />
</Box>
</Box>
);
};
6 changes: 3 additions & 3 deletions tgui/packages/tgui/interfaces/CameraConsole220.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const CameraConsoleMapContent = (props, context) => {
const { act, data } = useBackend(context);
const cameras = selectCameras(data.cameras);
const [zoom, setZoom] = useLocalState(context, 'zoom', 1);
const { mapRef, activeCamera, stationLevel } = data;
const { mapRef, activeCamera, stationLevel, mapUrl, selected_z_level } = data;
const [prevCameraName, nextCameraName] = prevNextCamera(cameras, activeCamera);
return (
<Stack fill>
Expand All @@ -85,9 +85,9 @@ export const CameraConsoleMapContent = (props, context) => {
flex: '0 0 474px',
}}
>
<NanoMap onZoom={(v) => setZoom(v)}>
<NanoMap onZoom={(v) => setZoom(v)} mapUrl={mapUrl}>
{cameras
.filter((cam) => cam.z === stationLevel)
.filter((cam) => cam.z === (Number(selected_z_level) || stationLevel))
.map((cm) => (
<NanoMap.NanoButton
activeCamera={activeCamera}
Expand Down
11 changes: 11 additions & 0 deletions tgui/packages/tgui/styles/components/NanoMap.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ $background-color: rgba(0, 0, 0, 0.33) !default;
.NanoMap__button:hover {
background-color: greenyellow;
}

.NanoMap__zchooser {
z-index: 21;
background-color: $background-color;
position: absolute;
top: 60px;
left: 0;
padding: 0.5rem;
width: 3%;
}

// SS220 ADDITION - END

.NanoMap__zoomer {
Expand Down
244 changes: 122 additions & 122 deletions tgui/public/tgui-panel.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tgui/public/tgui.bundle.css

Large diffs are not rendered by default.

160 changes: 80 additions & 80 deletions tgui/public/tgui.bundle.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions tools/github-actions/nanomap-renderer-invoker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ set -e
tools/github-actions/nanomap-renderer minimap -w 2040 -h 2040 "./_maps/map_files220/stations/boxstation.dmm"
tools/github-actions/nanomap-renderer minimap -w 2040 -h 2040 "./_maps/map_files220/stations/deltastation.dmm"
tools/github-actions/nanomap-renderer minimap -w 2040 -h 2040 "./_maps/map_files220/stations/metastation.dmm"
tools/github-actions/nanomap-renderer minimap -w 2040 -h 2040 "./_maps/map_files220/generic/Lavaland.dmm"
# Move and rename files so the game understands them
cd "data/nanomaps"
mv "boxstation_nanomap_z1.png" "Cyberiad220_nanomap_z1.png"
mv "deltastation_nanomap_z1.png" "Delta220_nanomap_z1.png"
mv "metastation_nanomap_z1.png" "MetaStation220_nanomap_z1.png"
mv "Lavaland_z1.png" "Lavaland_nanomap_z1.png"
cd "../../"
cp "data/nanomaps/Cyberiad220_nanomap_z1.png" "icons/_nanomaps"
cp "data/nanomaps/Delta220_nanomap_z1.png" "icons/_nanomaps"
cp "data/nanomaps/MetaStation220_nanomap_z1.png" "icons/_nanomaps"
cp "data/nanomaps/Lavaland_nanomap_z1.png" "icons/_nanomaps"
Loading