Skip to content

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
bin/
obj/
obj/
.vs/
Icon Sources/
Copy link
Collaborator

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

Copy link
Author

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. :)

*.user
12 changes: 12 additions & 0 deletions Cards/sample_food.jsont
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
}
17 changes: 17 additions & 0 deletions Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,28 @@
using System;
using System.Collections;
using UnityEngine;
using CommonModNS;

namespace ExampleModNS
{
public class ExampleMod : Mod
{
public static ExampleMod instance;
public static void Log(string msg) => instance.Logger.Log(msg);
public static void LogError(string msg) => instance.Logger.LogError(msg);

private void Awake()
{
instance = this;
//WorldManagerPatches.LoadSaveRound += WM_OnLoad;
//WorldManagerPatches.GetSaveRound += WM_OnSave;
//WorldManagerPatches.StartNewRound += WM_OnNewGame;
//WorldManagerPatches.Play += WM_OnPlay;
//WorldManagerPatches.Update += WM_OnUpdate;
//WorldManagerPatches.ApplyPatches(Harmony);
//Harmony.PatchAll();
}

public override void Ready()
{
Logger.Log("Ready!");
Expand Down
11 changes: 10 additions & 1 deletion Mod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@
<AssemblyName>ExampleMod</AssemblyName>
<TargetFramework>netstandard2.1</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Nullable>warnings</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\stacklands-common\ConfigEntryBool.cs" Link="Common\ConfigEntryBool.cs" />
<Compile Include="..\stacklands-common\ConfigEntryHelper.cs" Link="Common\ConfigEntryHelper.cs" />
<Compile Include="..\stacklands-common\ConfigFreeText.cs" Link="Common\ConfigFreeText.cs" />
<Compile Include="..\stacklands-common\ConfigToggledEnum.cs" Link="Common\ConfigToggledEnum.cs" />
<Compile Include="..\stacklands-common\Instances.cs" Link="Common\Instances.cs" />
<Compile Include="..\stacklands-common\WorldManagerPatches.cs" Link="Common\WorldManagerPatches.cs" />
</ItemGroup>

<ItemGroup>
<Reference Include="0Harmony">
<HintPath>$(stacklands)/Stacklands_Data/Managed/0Harmony.dll</HintPath>
Expand Down
25 changes: 25 additions & 0 deletions Mod.sln
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
32 changes: 25 additions & 7 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from genericpath import isfile
import os
import shutil
import subprocess
Expand All @@ -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)
Expand All @@ -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"))
Expand All @@ -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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The 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")
1 change: 1 addition & 0 deletions localization.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Term Notes English
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if including a localization file is a good choice

  • People going through the tutorial could be confused by it, as the tutorial tells them to download a completely different file
  • I assume most people would use a tool like Google Sheets to edit their localization files instead of a code/text editor
  • Even if the above assumption is incorrect, it's easy enough to create manually thanks to the localization guide

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm old school. I edit the file in visual studio directly.