mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-11 02:43:58 +02:00
Invoke vsproject.py automatically and make newelement.py a bit more friendly
This commit is contained in:
@@ -234,3 +234,6 @@ std::vector<SimTool*> GetTools()
|
|||||||
|
|
||||||
generateElements(os.listdir("src/simulation/elements"), "generated/ElementClasses.cpp", "generated/ElementClasses.h")
|
generateElements(os.listdir("src/simulation/elements"), "generated/ElementClasses.cpp", "generated/ElementClasses.h")
|
||||||
generateTools(os.listdir("src/simulation/simtools"), "generated/ToolClasses.cpp", "generated/ToolClasses.h")
|
generateTools(os.listdir("src/simulation/simtools"), "generated/ToolClasses.cpp", "generated/ToolClasses.h")
|
||||||
|
|
||||||
|
with open("vsproject.py") as f:
|
||||||
|
exec(compile(f.read(), "vsproject.py", 'exec'))
|
||||||
|
@@ -3,9 +3,13 @@ import re
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
sys.exit('needs an element name as an argument')
|
name = input('element name: ')
|
||||||
|
else:
|
||||||
|
name = sys.argv[1]
|
||||||
|
|
||||||
|
if re.search('[^A-Z0-9-]', name):
|
||||||
|
sys.exit('element names should only contain uppercase letters, numbers and hyphens (you can change the Name property of the element to whatever later though, which is what shows up in menus)')
|
||||||
|
|
||||||
name = sys.argv[1].upper()
|
|
||||||
path = 'src/simulation/elements/' + name + '.cpp'
|
path = 'src/simulation/elements/' + name + '.cpp'
|
||||||
|
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
@@ -23,6 +27,7 @@ with open('generated/ElementClasses.h', 'r') as classes:
|
|||||||
|
|
||||||
with open(path, 'w') as elem:
|
with open(path, 'w') as elem:
|
||||||
elem.write(r"""#include "simulation/ElementCommon.h"
|
elem.write(r"""#include "simulation/ElementCommon.h"
|
||||||
|
|
||||||
//#TPT-Directive ElementClass Element_{0} PT_{0} {1}
|
//#TPT-Directive ElementClass Element_{0} PT_{0} {1}
|
||||||
Element_{0}::Element_{0}()
|
Element_{0}::Element_{0}()
|
||||||
{{
|
{{
|
||||||
|
@@ -15,8 +15,7 @@ for root, subdirs, files in os.walk('src'):
|
|||||||
source_dirs.add(os.path.dirname(file))
|
source_dirs.add(os.path.dirname(file))
|
||||||
|
|
||||||
sln = open('The-Powder-Toy.sln', 'w')
|
sln = open('The-Powder-Toy.sln', 'w')
|
||||||
sln.write(r"""
|
sln.write(r"""Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio 2013
|
# Visual Studio 2013
|
||||||
VisualStudioVersion = 12.0.40629.0
|
VisualStudioVersion = 12.0.40629.0
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Reference in New Issue
Block a user