Skip to content

Commit 49a3bb1

Browse files
committed
Add project files.
1 parent c8fcdfe commit 49a3bb1

File tree

11 files changed

+372
-0
lines changed

11 files changed

+372
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "Everest"]
2+
path = Everest
3+
url = https://github.com/EverestAPI/Everest.git

Everest

Submodule Everest added at f9ed76c

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2018 Everest Team
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

RainbowMod.sln

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25420.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RainbowMod", "RainbowMod\RainbowMod.csproj", "{8CBA6958-CD94-44B4-970B-5FC3DBE6B019}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Celeste.Mod.mm", "Everest\Celeste.Mod.mm\Celeste.Mod.mm.csproj", "{D5D0239D-FF95-4897-9484-1898AB7E82F5}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{8CBA6958-CD94-44B4-970B-5FC3DBE6B019}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{8CBA6958-CD94-44B4-970B-5FC3DBE6B019}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{8CBA6958-CD94-44B4-970B-5FC3DBE6B019}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{8CBA6958-CD94-44B4-970B-5FC3DBE6B019}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{D5D0239D-FF95-4897-9484-1898AB7E82F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{D5D0239D-FF95-4897-9484-1898AB7E82F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{D5D0239D-FF95-4897-9484-1898AB7E82F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{D5D0239D-FF95-4897-9484-1898AB7E82F5}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
EndGlobal
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# NOTES:
2+
# The # Symbol at the start of a line counts as a Comment. To include in dialog, use a \#
3+
# The . Symbol will cause a pause unless escaped with \. (ex: Mr. Oshiro has a pause, Mr\. Oshiro does not)
4+
# Newlines automatically create a Page Break, unless there is an {n} command on the previous line
5+
# Commands: Anything inside of curly braces {...} is a command and should not be translated.
6+
7+
# Inline Text Commands:
8+
# {~}wavy text{/~}
9+
# {!}impact text{/!}
10+
# {>> x}changes speed at which characters are displayed{>>}
11+
# {# 000000}this text is black{#} (uses HEX color values)
12+
# {+MENU_BEGIN} inserts the dialog from the MENU_BEGIN value (in English, "CLIMB")
13+
# {n} creates a newline, without a page break
14+
# {0.5} creates a 0.5 second pause
15+
# {big}this text is large{/big}
16+
17+
# Gameplay Control Commands (should never change)
18+
# {trigger x} this triggers an in-game event
19+
# {anchor} controls the visual position of the textbox in-game
20+
21+
# Rainbow Module Options
22+
MODOPTIONS_RAINBOWMODULE_TITLE= Fabeline
23+
MODOPTIONS_RAINBOWMODULE_ENABLED= Enabled
24+
MODOPTIONS_RAINBOWMODULE_SPEED= Speed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("RainbowMod")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("RainbowMod")]
13+
[assembly: AssemblyCopyright("Copyright © 2018")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("8cba6958-cd94-44b4-970b-5fc3dbe6b019")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

RainbowMod/RainbowMod.csproj

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{8CBA6958-CD94-44B4-970B-5FC3DBE6B019}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Celeste.Mod.Rainbow</RootNamespace>
11+
<AssemblyName>RainbowMod</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<OutputPath Condition=" '$(TravisCore)' == 'true' ">Artifact\</OutputPath>
15+
<NuGetPackageImportStamp>
16+
</NuGetPackageImportStamp>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<DebugSymbols>true</DebugSymbols>
20+
<OutputPath Condition=" '$(TravisCore)' == '' ">bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
23+
<DebugType>full</DebugType>
24+
<PlatformTarget>AnyCPU</PlatformTarget>
25+
<ErrorReport>prompt</ErrorReport>
26+
<WarningLevel>4</WarningLevel>
27+
</PropertyGroup>
28+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
29+
<OutputPath Condition=" '$(TravisCore)' == '' ">bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
32+
<Optimize>true</Optimize>
33+
<DebugType Condition=" '$(TravisCore)' == '' ">pdbonly</DebugType>
34+
<PlatformTarget>AnyCPU</PlatformTarget>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
</PropertyGroup>
38+
<ItemGroup>
39+
<Reference Include="Celeste">
40+
<HintPath>..\Everest\lib-stripped\Celeste.exe</HintPath>
41+
<Private>False</Private>
42+
</Reference>
43+
<Reference Include="FNA">
44+
<HintPath>..\Everest\lib-stripped\FNA.dll</HintPath>
45+
<Private>False</Private>
46+
</Reference>
47+
<Reference Include="MonoMod">
48+
<HintPath>..\Everest\lib\MonoMod.exe</HintPath>
49+
<Private>False</Private>
50+
</Reference>
51+
<Reference Include="Steamworks.NET">
52+
<HintPath>..\Everest\lib-stripped\Steamworks.NET.dll</HintPath>
53+
<Private>False</Private>
54+
</Reference>
55+
<Reference Include="System" />
56+
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
57+
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
58+
<Private>False</Private>
59+
</Reference>
60+
<Reference Include="System.Xml" />
61+
<Reference Include="YamlDotNet">
62+
<HintPath>..\Everest\lib\YamlDotNet.dll</HintPath>
63+
<Private>False</Private>
64+
</Reference>
65+
</ItemGroup>
66+
<ItemGroup>
67+
<Compile Include="RainbowModuleSettings.cs" />
68+
<Compile Include="RainbowModule.cs" />
69+
<Compile Include="Properties\AssemblyInfo.cs" />
70+
</ItemGroup>
71+
<ItemGroup>
72+
<ProjectReference Include="..\Everest\Celeste.Mod.mm\Celeste.Mod.mm.csproj">
73+
<Project>{d5d0239d-ff95-4897-9484-1898ab7e82f5}</Project>
74+
<Name>Celeste.Mod.mm</Name>
75+
<Private>False</Private>
76+
</ProjectReference>
77+
</ItemGroup>
78+
<ItemGroup>
79+
<None Include="metadata.yaml">
80+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
81+
</None>
82+
<None Include="packages.config" />
83+
</ItemGroup>
84+
<ItemGroup>
85+
<EmbeddedResource Include="Content\Dialog\English.txt">
86+
<LogicalName>Content\Dialog\English.txt</LogicalName>
87+
</EmbeddedResource>
88+
</ItemGroup>
89+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
90+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
91+
<PropertyGroup>
92+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
93+
</PropertyGroup>
94+
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.6.1\build\Microsoft.Net.Compilers.props'))" />
95+
</Target>
96+
</Project>

RainbowMod/RainbowModule.cs

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
using Celeste.Mod;
2+
using Microsoft.Xna.Framework;
3+
using MonoMod.Detour;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Reflection;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
11+
namespace Celeste.Mod.Rainbow {
12+
public class RainbowModule : EverestModule {
13+
14+
public static RainbowModule Instance;
15+
16+
public override Type SettingsType => typeof(RainbowModuleSettings);
17+
public static RainbowModuleSettings Settings => (RainbowModuleSettings) Instance._Settings;
18+
19+
// The methods we want to hook.
20+
private readonly static MethodInfo m_GetHairColor = typeof(PlayerHair).GetMethod("GetHairColor", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
21+
private readonly static MethodInfo m_GetTrailColor = typeof(Player).GetMethod("GetTrailColor", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
22+
23+
private static int trailIndex = 0;
24+
25+
public RainbowModule() {
26+
Instance = this;
27+
}
28+
29+
public override void Load() {
30+
// Runtime hooks are quite different from static patches.
31+
Type t_RainbowModule = GetType();
32+
// [trampoline] = [method we want to hook] .Detour< [signature] >( [replacement method] );
33+
orig_GetHairColor = m_GetHairColor.Detour<d_GetHairColor>(t_RainbowModule.GetMethod("GetHairColor"));
34+
orig_GetTrailColor = m_GetTrailColor.Detour<d_GetTrailColor>(t_RainbowModule.GetMethod("GetTrailColor"));
35+
}
36+
37+
public override void Unload() {
38+
// Let's just hope that nothing else detoured this, as this is depth-based...
39+
RuntimeDetour.Undetour(m_GetHairColor);
40+
RuntimeDetour.Undetour(m_GetTrailColor);
41+
}
42+
43+
// The delegate tells MonoMod.Detour / RuntimeDetour about the method signature.
44+
// Instance (non-static) methods must become static, which means we add "this" as the first argument.
45+
public delegate Color d_GetHairColor(PlayerHair self, int index);
46+
// A field containing the trampoline to the original method.
47+
// You don't need to care about how RuntimeDetour handles this behind the scenes.
48+
public static d_GetHairColor orig_GetHairColor;
49+
public static Color GetHairColor(PlayerHair self, int index) {
50+
Color colorOrig = orig_GetHairColor(self, index);
51+
if (!Settings.Enabled || self.GetSprite().Mode == PlayerSpriteMode.Badeline)
52+
return colorOrig;
53+
54+
float wave = self.GetWave() * 60f;
55+
wave *= Settings.SpeedFactor;
56+
Color colorRainbow = ColorFromHSV((index / (float) self.GetSprite().HairCount) * 180f + wave, 0.6f, 0.6f);
57+
return new Color(
58+
(colorOrig.R / 255f) * 0.3f + (colorRainbow.R / 255f) * 0.7f,
59+
(colorOrig.G / 255f) * 0.3f + (colorRainbow.G / 255f) * 0.7f,
60+
(colorOrig.B / 255f) * 0.3f + (colorRainbow.B / 255f) * 0.7f,
61+
colorOrig.A
62+
);
63+
}
64+
65+
public delegate Color d_GetTrailColor(Player self, bool wasDashB);
66+
public static d_GetTrailColor orig_GetTrailColor;
67+
public static Color GetTrailColor(Player self, bool wasDashB) {
68+
if (!Settings.Enabled || self.Sprite.Mode == PlayerSpriteMode.Badeline || self.Hair == null)
69+
return orig_GetTrailColor(self, wasDashB);
70+
71+
return self.Hair.GetHairColor((trailIndex++) % self.Hair.GetSprite().HairCount);
72+
}
73+
74+
// Conversion algorithms found randomly on the net - best source for HSV <-> RGB ever:tm:
75+
76+
private static void ColorToHSV(Color c, out float h, out float s, out float v) {
77+
float r = c.R / 255f;
78+
float g = c.G / 255f;
79+
float b = c.B / 255f;
80+
float min, max, delta;
81+
min = Math.Min(Math.Min(r, g), b);
82+
max = Math.Max(Math.Max(r, g), b);
83+
v = max;
84+
delta = max - min;
85+
if (max != 0) {
86+
s = delta / max;
87+
88+
if (r == max)
89+
h = (g - b) / delta;
90+
else if (g == max)
91+
h = 2 + (b - r) / delta;
92+
else
93+
h = 4 + (r - g) / delta;
94+
h *= 60f;
95+
if (h < 0)
96+
h += 360f;
97+
} else {
98+
s = 0f;
99+
h = 0f;
100+
}
101+
}
102+
103+
private static Color ColorFromHSV(float hue, float saturation, float value) {
104+
int hi = (int) (Math.Floor(hue / 60f)) % 6;
105+
float f = hue / 60f - (float) Math.Floor(hue / 60f);
106+
107+
value = value * 255;
108+
int v = (int) (value);
109+
int p = (int) (value * (1 - saturation));
110+
int q = (int) (value * (1 - f * saturation));
111+
int t = (int) (value * (1 - (1 - f) * saturation));
112+
113+
if (hi == 0)
114+
return new Color(255, v, t, p);
115+
else if (hi == 1)
116+
return new Color(255, q, v, p);
117+
else if (hi == 2)
118+
return new Color(255, p, v, t);
119+
else if (hi == 3)
120+
return new Color(255, p, q, v);
121+
else if (hi == 4)
122+
return new Color(255, t, p, v);
123+
else
124+
return new Color(255, v, p, q);
125+
}
126+
127+
}
128+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using FMOD.Studio;
2+
using Microsoft.Xna.Framework;
3+
using Monocle;
4+
using System;
5+
using System.Collections;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
using YamlDotNet.Serialization;
11+
12+
namespace Celeste.Mod.Rainbow {
13+
public class RainbowModuleSettings : EverestModuleSettings {
14+
15+
public bool Enabled { get; set; } = false;
16+
17+
[SettingRange(0, 20)]
18+
public int Speed { get; set; } = 10;
19+
[YamlIgnore]
20+
[SettingIgnore]
21+
public float SpeedFactor => Speed / 20f;
22+
23+
}
24+
}

RainbowMod/metadata.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Name: RainbowMod
2+
Version: 1.0.0
3+
DLL: RainbowMod.dll
4+
Dependencies:
5+
- Name: Everest
6+
Version: 1.0.0

0 commit comments

Comments
 (0)