Set up GitHub action for nanomap generation

This commit is contained in:
ShadowLarkens
2020-09-25 03:00:14 -07:00
parent f0a70de1e1
commit cf9b39b4a9
8 changed files with 79 additions and 94 deletions

35
.github/workflows/render_nanomaps.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
# GitHub action to autorender nanomaps outside the game
# This kills off the awful verb we have that takes a full 50 seconds and hangs the whole server
# The file names and locations are VERY important here
# DO NOT EDIT THIS UNLESS YOU KNOW WHAT YOU ARE DOING
# -aa
name: 'Render Nanomaps'
on:
push:
branches: master
paths:
- 'maps/**'
jobs:
generate_maps:
name: 'Generate NanoMaps'
runs-on: ubuntu-18.04
steps:
- name: 'Update Branch'
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: 'Generate Maps'
run: './tools/github-actions/nanomap-renderer-invoker.sh'
- name: 'Commit Maps'
run: |
git config --local user.email "action@github.com"
git config --local user.name "NanoMap Generation"
git pull origin master
git commit -m "NanoMap Auto-Update (`date`)" -a || true
- name: 'Push Maps'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -8,6 +8,8 @@ Going to make a Pull Request? Make sure you read the [CONTRIBUTING.md](.github/C
VOREStation is a fork of the Polaris code branch, itself a fork of the Baystation12 code branch, for the game Space Station 13. VOREStation is a fork of the Polaris code branch, itself a fork of the Baystation12 code branch, for the game Space Station 13.
![Render Nanomaps](https://github.com/VOREStation/VOREStation/workflows/Render%20Nanomaps/badge.svg)
--- ---
### LICENSE ### LICENSE

View File

@@ -181,7 +181,6 @@ var/list/admin_verbs_server = list(
/datum/admins/proc/toggle_space_ninja, /datum/admins/proc/toggle_space_ninja,
/client/proc/toggle_random_events, /client/proc/toggle_random_events,
/client/proc/check_customitem_activity, /client/proc/check_customitem_activity,
/client/proc/nanomapgen_DumpImage,
/client/proc/modify_server_news, /client/proc/modify_server_news,
/client/proc/recipe_dump, /client/proc/recipe_dump,
/client/proc/panicbunker, /client/proc/panicbunker,

View File

@@ -1,92 +0,0 @@
// This file is a modified version of https://raw2.github.com/Baystation12/OldCode-BS12/master/code/TakePicture.dm
#define NANOMAP_ICON_SIZE 4
#define NANOMAP_MAX_ICON_DIMENSION 1200
#define NANOMAP_TILES_PER_IMAGE (NANOMAP_MAX_ICON_DIMENSION / NANOMAP_ICON_SIZE)
#define NANOMAP_TERMINALERR 5
#define NANOMAP_INPROGRESS 2
#define NANOMAP_BADOUTPUT 2
#define NANOMAP_SUCCESS 1
#define NANOMAP_WATCHDOGSUCCESS 4
#define NANOMAP_WATCHDOGTERMINATE 3
//Call these procs to dump your world to a series of image files (!!)
//NOTE: Does not explicitly support non 32x32 icons or stuff with large pixel_* values, so don't blame me if it doesn't work perfectly
/client/proc/nanomapgen_DumpImage()
set name = "Generate NanoUI Map"
set category = "Server"
if(holder)
nanomapgen_DumpTile(1, 1, text2num(input(usr,"Enter the Z level to generate")))
/client/proc/nanomapgen_DumpTile(var/startX = 1, var/startY = 1, var/currentZ = 1, var/endX = -1, var/endY = -1)
if (endX < 0 || endX > world.maxx)
endX = world.maxx
if (endY < 0 || endY > world.maxy)
endY = world.maxy
if (currentZ < 0 || currentZ > world.maxz)
to_chat(usr, "NanoMapGen: <B>ERROR: currentZ ([currentZ]) must be between 1 and [world.maxz]</B>")
sleep(3)
return NANOMAP_TERMINALERR
if (startX > endX)
to_chat(usr, "NanoMapGen: <B>ERROR: startX ([startX]) cannot be greater than endX ([endX])</B>")
sleep(3)
return NANOMAP_TERMINALERR
if (startY > endX)
to_chat(usr, "NanoMapGen: <B>ERROR: startY ([startY]) cannot be greater than endY ([endY])</B>")
sleep(3)
return NANOMAP_TERMINALERR
var/icon/Tile = icon('icons/_nanomaps/mapbase1200.png')
if (Tile.Width() != NANOMAP_MAX_ICON_DIMENSION || Tile.Height() != NANOMAP_MAX_ICON_DIMENSION)
to_world_log("NanoMapGen: <B>ERROR: BASE IMAGE DIMENSIONS ARE NOT [NANOMAP_MAX_ICON_DIMENSION]x[NANOMAP_MAX_ICON_DIMENSION]</B>")
sleep(3)
return NANOMAP_TERMINALERR
Tile.Scale((endX - startX + 1) * NANOMAP_ICON_SIZE, (endY - startY + 1) * NANOMAP_ICON_SIZE) // VOREStation Edit - Scale image to actual size mapped.
to_world_log("NanoMapGen: <B>GENERATE MAP ([startX],[startY],[currentZ]) to ([endX],[endY],[currentZ])</B>")
to_chat(usr, "NanoMapGen: <B>GENERATE MAP ([startX],[startY],[currentZ]) to ([endX],[endY],[currentZ])</B>")
var/count = 0;
for(var/WorldX = startX, WorldX <= endX, WorldX++)
for(var/WorldY = startY, WorldY <= endY, WorldY++)
var/atom/Turf = locate(WorldX, WorldY, currentZ)
var/icon/TurfIcon = new(Turf.icon, Turf.icon_state)
TurfIcon.Scale(NANOMAP_ICON_SIZE, NANOMAP_ICON_SIZE)
Tile.Blend(TurfIcon, ICON_OVERLAY, ((WorldX - 1) * NANOMAP_ICON_SIZE), ((WorldY - 1) * NANOMAP_ICON_SIZE))
count++
if (count % 8000 == 0)
to_world_log("NanoMapGen: <B>[count] tiles done</B>")
sleep(1)
var/mapFilename = "nanomap_z[currentZ]-new.png"
to_world_log("NanoMapGen: <B>sending [mapFilename] to client</B>")
usr << browse(Tile, "window=picture;file=[mapFilename];display=0")
to_world_log("NanoMapGen: <B>Done.</B>")
to_chat(usr, "NanoMapGen: <B>Done. File [mapFilename] uploaded to your cache.</B>")
if (Tile.Width() != NANOMAP_MAX_ICON_DIMENSION || Tile.Height() != NANOMAP_MAX_ICON_DIMENSION)
return NANOMAP_BADOUTPUT
return NANOMAP_SUCCESS

View File

@@ -0,0 +1,7 @@
# GitHub Actions Scripts
This folder contains all the script and tools required for GitHub actions. If you add something to this directory, **PLEASE** document it in here
- `nanomap-renderer` - A linux application to render NanoMap images of the ingame maps automatically. Based off of SpacemanDMM (Modified source [here](https://github.com/AffectedArc07/ParaSpacemanDMM), original source [here](https://github.com/Spacemaniac/SpacemanDMM))
- `nanomap-renderer-invoker.sh` - A script which invokes the render tool and clones the maps to the correct directory
- `doc-generator` - A linux application to generate documentation of game code automatically. Based off of SpacemanDMM (Modified source [here](https://github.com/AffectedArc07/ParaSpacemanDMM), original source [here](https://github.com/Spacemaniac/SpacemanDMM))

Binary file not shown.

View File

@@ -0,0 +1,35 @@
#!/bin/bash
# Generate maps
map_files=(
"./maps/tether/tether-01-surface1.dmm"
"./maps/tether/tether-02-surface2.dmm"
"./maps/tether/tether-03-surface3.dmm"
"./maps/tether/tether-04-transit.dmm"
"./maps/tether/tether-05-station1.dmm"
"./maps/tether/tether-06-station2.dmm"
"./maps/tether/tether-07-station3.dmm"
"./maps/tether/tether-08-mining.dmm"
"./maps/tether/tether-09-solars.dmm"
"./maps/offmap_vr/talon/talon1.dmm"
"./maps/offmap_vr/talon/talon2.dmm"
)
tools/github-actions/nanomap-renderer minimap -w 2240 -h 2240 "${map_files[@]}"
# Move and rename files so the game understands them
cd "data/nanomaps"
mv "talon1_nanomap_z1.png" "tether_nanomap_z13.png"
mv "talon2_nanomap_z1.png" "tether_nanomap_z14.png"
mv "tether-01-surface1_nanomap_z1.png" "tether_nanomap_z1.png"
mv "tether-02-surface2_nanomap_z1.png" "tether_nanomap_z2.png"
mv "tether-03-surface3_nanomap_z1.png" "tether_nanomap_z3.png"
mv "tether-04-transit_nanomap_z1.png" "tether_nanomap_z4.png"
mv "tether-05-station1_nanomap_z1.png" "tether_nanomap_z5.png"
mv "tether-06-station2_nanomap_z1.png" "tether_nanomap_z6.png"
mv "tether-07-station3_nanomap_z1.png" "tether_nanomap_z7.png"
mv "tether-08-mining_nanomap_z1.png" "tether_nanomap_z8.png"
mv "tether-09-solars_nanomap_z1.png" "tether_nanomap_z9.png"
cd "../../"
cp data/nanomaps/* "icons/_nanomaps/"

View File

@@ -3555,7 +3555,6 @@
#include "code\modules\tgs\includes.dm" #include "code\modules\tgs\includes.dm"
#include "code\modules\tgui\external.dm" #include "code\modules\tgui\external.dm"
#include "code\modules\tgui\modal.dm" #include "code\modules\tgui\modal.dm"
#include "code\modules\tgui\nanomapgen.dm"
#include "code\modules\tgui\states.dm" #include "code\modules\tgui\states.dm"
#include "code\modules\tgui\tgui.dm" #include "code\modules\tgui\tgui.dm"
#include "code\modules\tgui\tgui_window.dm" #include "code\modules\tgui\tgui_window.dm"