Skip to content

Commit

Permalink
Merge pull request #332 from Shebuka/separate_floors
Browse files Browse the repository at this point in the history
Add Ground Zero map and improvements
  • Loading branch information
thaddeus authored Jan 10, 2024
2 parents 79e666c + 90f027b commit 98516d2
Show file tree
Hide file tree
Showing 10 changed files with 4,057 additions and 3,972 deletions.
1,169 changes: 609 additions & 560 deletions maps/Customs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
336 changes: 336 additions & 0 deletions maps/GroundZero.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
485 changes: 245 additions & 240 deletions maps/Interchange.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
863 changes: 435 additions & 428 deletions maps/Lighthouse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
974 changes: 262 additions & 712 deletions maps/Reserve.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
913 changes: 474 additions & 439 deletions maps/Shoreline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2,304 changes: 1,155 additions & 1,149 deletions maps/StreetsOfTarkov.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
894 changes: 450 additions & 444 deletions maps/Woods.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions maps/replace_style_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import os
import xml.etree.ElementTree as ET


def replace_style(svg_path, new_style_path, output_path, overwrite):
# Parse the SVG file
tree = ET.parse(svg_path)
root = tree.getroot()

# Find the style element with id="style_common"
style_common = root.find(".//*[@id='style_common']")

if style_common is not None:
# Read the content of the new style file
with open(new_style_path, 'r') as new_style_file:
new_style_content = new_style_file.read()

# Update the content of style_common with the new style content
style_common.text = new_style_content

if overwrite:
# Save the modified SVG to the original file
tree.write(svg_path)
print(f'Successfully replaced style in {svg_path}.')
else:
# Save the modified SVG to a new file
tree.write(output_path)
print(f'Successfully replaced style in {svg_path} and saved to {output_path}')
else:
print(f'Style with id="style_common" not found in {svg_path}.')


def process_svg_files(overwrite):
# Get the directory of the script
script_directory = os.path.dirname(os.path.realpath(__file__))

ET.register_namespace("", "http://www.w3.org/2000/svg")
ET.register_namespace("xlink", "http://www.w3.org/1999/xlink")

# Loop over all files in the script directory
for filename in os.listdir(script_directory):
if filename.endswith(".svg"):
svg_path = os.path.join(script_directory, filename)

# Assume new_style.css is in the same directory as the script
new_style_path = os.path.join(script_directory, 'style_common.css')

if overwrite:
# Process the SVG file and overwrite the original
replace_style(svg_path, new_style_path, None, True)
else:
# Assume output files should have "_modified" appended to the original name
output_path = os.path.join(script_directory, f'{os.path.splitext(filename)[0]}_modified.svg')

# Process the SVG file and save to a new file
replace_style(svg_path, new_style_path, output_path, False)


if __name__ == "__main__":
# Ask the user whether to overwrite original files
user_input = input("Do you want to overwrite the original files? (yes/no): ").lower()
overwrite = user_input == 'yes'

# Process SVG files based on user choice
process_svg_files(overwrite)
26 changes: 26 additions & 0 deletions maps/style_common.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

.trees { fill:#144043 }
.cement { fill:#c6c2c2 }
.land { fill:#1f5054 }
.rock { fill:#dcd5b6 }
.water { fill:#4a6b96 }
.wood { fill:#593700 }
.tarmac { fill:#768089 }
.gravel { fill:#946d3e }
.building { fill:#1a2632 }
.floor { fill:#70777f }
.locked { fill:#37414c }
.map_border { fill:none;stroke:#000;stroke-width:2 }
.fence { fill:none;stroke:#c4e3c3;stroke-width:1 }
.road_tarmac { fill:none;stroke:#888 }
.road_gravel { fill:none;stroke:#946d3e }
.road_small { stroke-width:5 }
.road_medium { stroke-width:8 }
.road_large { stroke-width:12 }
.railroad { fill:none;stroke:#914833;stroke-dasharray:6;stroke-width:3 }
.powerline { fill:none;stroke:#ffce00;stroke-width:2;stroke-miterlimit:10;stroke-dasharray:6,6 }
.danger { fill:red;fill-opacity:.4;stroke:red;stroke-dasharray:4,2;stroke-width:2 }
.task { fill:#000 }
.stairs { fill:#FFD700 }
.shadow { filter:drop-shadow(0 0 2px #000) }

0 comments on commit 98516d2

Please sign in to comment.