Skip to content

Commit

Permalink
add: Initialize empty project
Browse files Browse the repository at this point in the history
  • Loading branch information
WEGFan committed Dec 10, 2021
0 parents commit 501298f
Show file tree
Hide file tree
Showing 15 changed files with 675 additions and 0 deletions.
440 changes: 440 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

75 changes: 75 additions & 0 deletions Code/Trailine.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Celeste.Mod.Trailine</RootNamespace>
<AssemblyName>Trailine</AssemblyName>
<TargetFramework>net452</TargetFramework>
<LangVersion>9</LangVersion>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<AssemblyVersion>0.1.0.0</AssemblyVersion>
<Company>WEGFan</Company>
<PathMap>$(MSBuildProjectDirectory)=/WEGFan/Trailine/</PathMap>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<OutputPath>../DLL/</OutputPath>
<DebugType>full</DebugType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PlatformTarget>x86</PlatformTarget>
<Prefer32bit>true</Prefer32bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<OutputPath>../DLL/</OutputPath>
<DebugSymbols>true</DebugSymbols>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PlatformTarget>x86</PlatformTarget>
<Prefer32bit>true</Prefer32bit>
<DebugType>full</DebugType>
</PropertyGroup>

<!-- Game libs -->
<PropertyGroup>
<GameLibPath Condition="'$(GameLibPath)' == '' and Exists('lib-game/Celeste.exe')">lib-game</GameLibPath>
<GameLibPath Condition="'$(GameLibPath)' == '' and Exists('lib-game/stripped/Celeste.exe')">lib-game/stripped</GameLibPath>
</PropertyGroup>
<ItemGroup Condition="'$(GameLibPath)' != ''">
<Reference Include="$(GameLibPath)/Celeste.exe">
<Private>false</Private>
</Reference>
<Reference Include="$(GameLibPath)/MMHOOK_Celeste.dll">
<Private>false</Private>
</Reference>
<Reference Include="$(GameLibPath)/FNA.dll">
<Private>false</Private>
</Reference>
</ItemGroup>

<!-- Everest libs -->
<ItemGroup>
<PackageReference Include="Mono.Cecil" Version="0.11.4" PrivateAssets="all" ExcludeAssets="runtime" />
<PackageReference Include="MonoMod" Version="21.08.19.01" PrivateAssets="all" ExcludeAssets="runtime" />
<PackageReference Include="MonoMod.RuntimeDetour" Version="21.08.19.01" PrivateAssets="all" ExcludeAssets="runtime" />
<PackageReference Include="MonoMod.RuntimeDetour.HookGen" Version="21.08.19.01" PrivateAssets="all" ExcludeAssets="runtime" />
<PackageReference Include="MonoMod.Utils" Version="21.08.19.01" PrivateAssets="all" ExcludeAssets="runtime" />
<PackageReference Include="DotNetZip" Version="1.15.0" PrivateAssets="all" ExcludeAssets="runtime" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" PrivateAssets="all" ExcludeAssets="runtime" />
<PackageReference Include="YamlDotNet" Version="8.1.2" PrivateAssets="all" ExcludeAssets="runtime" />
<PackageReference Include="Jdenticon-net" Version="2.2.1" PrivateAssets="all" ExcludeAssets="runtime" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" PrivateAssets="all" ExcludeAssets="runtime" />
</ItemGroup>

<!-- Custom libs -->
<ItemGroup>
</ItemGroup>

<!-- Mono libs -->
<ItemGroup>
<Content Include="lib-mono/**/*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Link>%(Filename)%(Extension)</Link>
</Content>
<Content Remove="lib-mono/.gitkeep" />
</ItemGroup>
</Project>
35 changes: 35 additions & 0 deletions Code/TrailineModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;

namespace Celeste.Mod.Trailine {
public class TrailineModule : EverestModule {

public TrailineModule() {
Instance = this;
}

public static TrailineModule Instance { get; private set; }

public override Type SettingsType => typeof(TrailineSettings);

public static TrailineSettings Settings => Instance._Settings as TrailineSettings;

public static bool Loaded = false;

public override void Load() {
if (Loaded || !Settings.Enabled) {
return;
}

Loaded = true;
}

public override void Unload() {
if (!Loaded) {
return;
}

Loaded = false;
}

}
}
21 changes: 21 additions & 0 deletions Code/TrailineSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace Celeste.Mod.Trailine {

public class TrailineSettings : EverestModuleSettings {

public bool Enabled { get; set; } = true;

public void CreateEnabledEntry(TextMenu textMenu, bool inGame) {
TextMenu.Item item = new TextMenu.OnOff("Enabled", Enabled)
.Change(value => {
Enabled = value;
if (value) {
TrailineModule.Instance.Load();
} else {
TrailineModule.Instance.Unload();
}
});
textMenu.Add(item);
}

}
}
5 changes: 5 additions & 0 deletions Code/lib-game/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This folder contains necessary files from game (`Celeste 1.4.0.0 [Everest: 3070-azure-d793d]`) to compile this project.

The files in `stripped` folder are stripped game libs that only have method declarations, for being able to compile without having the game installed and preventing uploading actual files to the repo. These are made with [mono-cil-strip](https://github.com/mono/mono/tree/master/mcs/tools/cil-strip).

However you can still put the actual game libs in this folder for easier development, for example you can reference libs from this folder, so you can play with Celeste XNA while compiling with FNA.
Binary file added Code/lib-game/stripped/Celeste.exe
Binary file not shown.
Binary file added Code/lib-game/stripped/FNA.dll
Binary file not shown.
Binary file added Code/lib-game/stripped/MMHOOK_Celeste.dll
Binary file not shown.
Empty file added Code/lib-mono/.gitkeep
Empty file.
2 changes: 2 additions & 0 deletions Dialog/English.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Trailine_mod_name=Trailine
modname_Trailine={+Trailine_mod_name}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 WEGFan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Trailine
16 changes: 16 additions & 0 deletions Trailine.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Trailine", "Code\Trailine.csproj", "{09999BCE-A648-45AA-88D9-952822A45800}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{09999BCE-A648-45AA-88D9-952822A45800}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{09999BCE-A648-45AA-88D9-952822A45800}.Debug|Any CPU.Build.0 = Debug|Any CPU
{09999BCE-A648-45AA-88D9-952822A45800}.Release|Any CPU.ActiveCfg = Release|Any CPU
{09999BCE-A648-45AA-88D9-952822A45800}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
9 changes: 9 additions & 0 deletions everest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- Name: Trailine
Version: 0.1.0
Author: WEGFan
DLL: DLL/Trailine.dll
Dependencies:
- Name: Everest
Version: 1.3070.0
- Name: Celeste
Version: 1.4.0.0
50 changes: 50 additions & 0 deletions package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
import re
import subprocess
import sys
import zipfile
from itertools import chain
from pathlib import Path
import os
import yaml

# load mod name and version from everest.yaml
with open('everest.yaml', 'r', encoding='utf-8') as f:
mod_metadata = yaml.safe_load(f.read())

mod_name = mod_metadata[0]['Name']
mod_version = mod_metadata[0]['Version']

print(mod_name, mod_version)

# update AssemblyVersion in project file to match the mod version
with open('Code/Trailine.csproj', 'r+', encoding='utf-8') as f:
s = f.read()
f.seek(0)
f.truncate()

s = re.sub(r'^(\s+<AssemblyVersion>)(.*?)(</AssemblyVersion>)$',
f'\\g<1>{mod_version.split("-")[0]}.0\\g<3>',
s, flags=re.MULTILINE)

f.write(s)

# clean the output files
subprocess.run(['dotnet', 'clean'])

# build the project
process = subprocess.run(['dotnet', 'build', '--configuration', 'Release'])
if process.returncode != 0:
print('build failed')
sys.exit()

# package
file_list = ['DLL/**/*', 'Dialog/**/*', 'everest.yaml']

os.makedirs('dist', exist_ok=True)
with zipfile.ZipFile(f'dist/{mod_name}_v{mod_version}.zip', 'w', zipfile.ZIP_DEFLATED) as f:
for file in chain(*[Path('.').glob(i) for i in file_list]):
# correct the case in file name
file = file.resolve().relative_to(Path.cwd())
print(file)
f.write(file)

0 comments on commit 501298f

Please sign in to comment.