17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-02 13:59:12 +01:00

fix(editor): signals move along their track again, and the editor finds the descriptions of the templates beside the game data

- a press on the mast of a selected signal grabbed the gizmo, whose up axis runs along the mast, and lifted the signal
  instead of moving it along the track; the gizmo gives way over a signal and while one is dragged
- dragged beside its track, off every track, the signal follows the nearest place of the track it stands by instead of
  staying put
- a drop away from any track, and a signal in a file the editor doesn't change, say so instead of doing nothing
- a template without a //$e description of its own takes it from editor/templates/<its path in the scenery folder>; the
  header scripts write there with --sidecar, leaving the templates alone, so a check of the game files by the store
  doesn't take the descriptions away (the descriptions written into the templates on 8.10 and 11.10 were gone, and with
  them every signal and drive the editor knew)
This commit is contained in:
maj00r
2026-10-18 02:08:19 +02:00
parent 52a762879c
commit 9474293af7
8 changed files with 85 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""Writes //$e descriptions into the switch drive templates (scenery/tory/napedy), so the editor places them with a switch.
usage: drive_headers.py <data root> [--write] [--zip <file>]
usage: drive_headers.py <data root> [--write] [--zip <file>] [--sidecar]
without --write it only reports what it would write; --zip packs the written templates with their scenery/ paths
"""
@@ -9,7 +9,7 @@ import os
import re
import sys
from editor_headers import body_lines, decode, load, options, pack, write
from editor_headers import body_lines, decode, load, options, pack, sidecar, write
FOLDER = 'scenery/tory/napedy'
PATTERN = re.compile(r'^(ele1?|mech[12]?)-rz([lp])-([lp])((?:_[a-z]+)*)\.inc$')
@@ -78,6 +78,8 @@ def main():
print('%d described, %d skipped' % (len(done), len(skipped)))
if writing:
write(data, FOLDER, 'drives', done)
if '--sidecar' in sys.argv:
sidecar(data, FOLDER, done)
if target:
pack(target, FOLDER, done)
return 0

View File

@@ -50,6 +50,23 @@ def options(argv, usage):
return argv[1], '--write' in argv, pack
def sidecar(data, folder, entries):
"""the descriptions next to the game data instead of in the templates: <data>/editor/templates/<the path of the
template in the scenery folder>, the lines without the marks, which the editor reads for a template without its own;
the templates stay as they are, so a check of the game files by the store doesn't take the descriptions away"""
root = os.path.join(data, 'editor', 'templates', os.path.relpath(folder, 'scenery'))
written = 0
for file, info in entries:
if info.get('header') is None:
continue
target = os.path.normpath(os.path.join(root, file))
os.makedirs(os.path.dirname(target), exist_ok=True) # NOSONAR
with open(target, 'w', encoding='utf-8', newline='\n') as out: # NOSONAR
out.write('\n'.join(info['header']) + '\n')
written += 1
print('%d descriptions written beside the data in %s' % (written, root))
def write(data, folder, name, entries):
backup = os.path.join(data, 'editor_backup')
os.makedirs(backup, exist_ok=True) # NOSONAR

View File

@@ -1,15 +1,16 @@
#!/usr/bin/env python3
"""Writes //$e descriptions into the signal templates of the scenery directory, so the editor can place them.
usage: signal_headers.py <data root> [--write]
without --write it only reports what it would write
usage: signal_headers.py <data root> [--write] [--sidecar]
without --write it only reports what it would write; --sidecar writes them beside the data, in editor/templates, the
templates left as they are
"""
import os
import re
import sys
from editor_headers import body_lines, decode, load, write
from editor_headers import body_lines, decode, load, sidecar, write
FAMILIES = [
(re.compile(r'^ss[dow]?\d'), 'main'),
@@ -200,6 +201,8 @@ def main():
if writing:
write(sys.argv[1], 'scenery', 'signals', done)
if '--sidecar' in sys.argv:
sidecar(sys.argv[1], 'scenery', done)
return 0

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""Writes //$e descriptions into the turntable templates of the scenery, so the editor places them as turntables.
usage: turntable_headers.py <data root> [--write] [--zip <file>]
usage: turntable_headers.py <data root> [--write] [--zip <file>] [--sidecar]
without --write it only reports what it would write; --zip packs every described turntable template with its scenery/ path
"""
@@ -9,7 +9,7 @@ import os
import re
import sys
from editor_headers import LINEMARK, body_lines, decode, load, options, pack, write
from editor_headers import LINEMARK, body_lines, decode, load, options, pack, sidecar, write
FOLDER = 'scenery'
ROTATION = re.compile(r'^event\s+\S*tor(\d+)rot\s+animation\s+\S+\s+\S+\s+rotate\s+\S+\s+\S+\s+\S+\s+(\S+)', re.I | re.M)
@@ -95,6 +95,8 @@ def main():
write(data, FOLDER, 'turntables', fresh)
if target:
pack(target, FOLDER, done)
if '--sidecar' in sys.argv:
sidecar(data, FOLDER, done)
return 0