-
Notifications
You must be signed in to change notification settings - Fork 5
Changes to build.py #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d5d454e
5ab2533
b6dddd5
03c3bf7
2938a19
f2e78a7
55afa97
2bfe9c9
c2f2c2a
99e319c
d93038f
efbae6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
bin/ | ||
obj/ | ||
obj/ | ||
.vs/ | ||
Icon Sources/ | ||
*.user |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"id": "[mod]_[name]", | ||
"nameTerm": "[mod]_[name]", | ||
"descriptionTerm": "[mod]_[name]_description", | ||
"icon": "[name].png", | ||
"value": 6, | ||
"type": "Food", | ||
"script": "Food", | ||
"_CanSpoil": false, | ||
"_FoodValue": 5, | ||
"_IsCookedFood": true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
| ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.7.34009.444 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mod", "Mod.csproj", "{EA19312D-028A-4EA2-BE2E-3BA011C67094}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{EA19312D-028A-4EA2-BE2E-3BA011C67094}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{EA19312D-028A-4EA2-BE2E-3BA011C67094}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{EA19312D-028A-4EA2-BE2E-3BA011C67094}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{EA19312D-028A-4EA2-BE2E-3BA011C67094}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {B2583325-9125-4EA6-BDCD-649E7979AE1B} | ||
EndGlobalSection | ||
EndGlobal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from genericpath import isfile | ||
import os | ||
import shutil | ||
import subprocess | ||
|
@@ -7,14 +8,14 @@ | |
import json | ||
|
||
# ----- CONFIGURE THESE ----- | ||
COMMON = ["CommonNS.tsv"] | ||
SYNC_FOLDERS = ["Blueprints", "Boosterpacks", "Cards", "Icons", "Sounds"] # folders to be synced, such as Cards, Blueprints, Icons, etc. | ||
COPY_FILES = ["manifest.json", "localization.tsv"] # individual files to copy, such as manifest.json, localization.tsv, etc. (the mod dll is copied automatically) | ||
COPY_FILES = ["manifest.json", "*.tsv", "../stacklands-commonmod/*.tsv", "workshop.txt", "icon.png"] # individual files to copy, such as manifest.json, localization.tsv, etc. (the mod dll is copied automatically) | ||
MODS_ROOT = Path(os.environ["userprofile"]) / Path("AppData/LocalLow/sokpop/Stacklands/Mods") # windows only, can be hardcoded with the below line instead | ||
# MODS_ROOT = Path("C:/Users/cyber/AppData/LocalLow/sokpop/Stacklands/Mods").resolve() | ||
|
||
MOD_BIN = Path("./bin/Debug/netstandard2.1").resolve() | ||
|
||
|
||
def sync_folder(src: Path, dst: Path): | ||
for file in dst.glob("**/*"): | ||
file_in_src = src / file.relative_to(dst) | ||
|
@@ -38,7 +39,7 @@ def sync_folder(src: Path, dst: Path): | |
if p.returncode != 0: | ||
print(stdout.decode()) | ||
exit(p.returncode) | ||
print(f"built in {time.time() - start_time:.2f}s") | ||
print(f"build started {time.strftime('%H:%M:%S', time.localtime(start_time))}, finished in {time.time() - start_time:.2f}s") | ||
|
||
# grab metadata | ||
found_csprojs = list(Path(".").glob("*.csproj")) | ||
|
@@ -51,19 +52,36 @@ def sync_folder(src: Path, dst: Path): | |
MOD_DLL = MOD_BIN / DLL_NAME | ||
MOD_PATH = MODS_ROOT / MOD_ID | ||
|
||
# check dll has unique name | ||
if DLL_NAME.lower() == "examplemod.dll": | ||
print("Did you forget to rename the DLL in the project settings?") | ||
exit(1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a warning is enough here, maybe link to https://modding.stacklands.co/en/latest/guides/tutorial.html#step-1-setting-up-the-template as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is why pull requests aren't requests. Not demands. At least put something there. |
||
|
||
# copy dll | ||
MOD_PATH.mkdir(exist_ok=True) | ||
shutil.copyfile(MOD_DLL, MOD_PATH / f"{DLL_NAME}") | ||
|
||
for file in COMMON: | ||
shutil.copyfile(f"../stacklands-common/{file}", f"./{file}") | ||
|
||
# copy files | ||
for file in COPY_FILES: | ||
try: | ||
shutil.copyfile(file, MOD_PATH / file) | ||
except FileNotFoundError: | ||
print(f"No such file: '{file}'") | ||
for f in Path(".").glob(file): | ||
try: | ||
shutil.copyfile(f, MOD_PATH / f) | ||
except FileNotFoundError: | ||
print(f"No such file: '{f}'") | ||
|
||
for file in COMMON: | ||
os.remove(f"./{file}") | ||
|
||
# copy folders | ||
print("syncing folders..") | ||
for folder in SYNC_FOLDERS: | ||
sync_folder(Path(folder), MOD_PATH / folder) | ||
|
||
# run bb.cmd | ||
if os.path.isfile("README.md"): | ||
if not os.path.isfile("README.bbcode") or os.path.getmtime('README.md') > os.path.getmtime('README.bbcode'): | ||
print("Updating bbcode file") | ||
subprocess.call("..\MarkdownToSteam.exe -i README.md -o README.bbcode") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Term Notes English | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if including a localization file is a good choice
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm old school. I edit the file in visual studio directly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like a personal thing, not something that should be in the template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .vs/ thing kills me every time. I had to fork the mod-template. :)