-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #332 from Shebuka/separate_floors
Add Ground Zero map and improvements
- Loading branch information
Showing
10 changed files
with
4,057 additions
and
3,972 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) } | ||
|