├── .gitattributes
├── .gitignore
├── CelesteExtractor.sln
├── CelesteExtractor
├── App.config
├── Atlas.cs
├── Celeste.cs
├── CelesteExtractor.csproj
├── GraphicsDeviceService.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── ServiceContainer.cs
├── VirtualTexture.cs
└── XNA
│ ├── Microsoft.Xna.Framework.Game.dll
│ ├── Microsoft.Xna.Framework.GamerServices.dll
│ ├── Microsoft.Xna.Framework.Graphics.dll
│ └── Microsoft.Xna.Framework.dll
├── LICENSE
├── README.md
└── normal04.png
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | project.fragment.lock.json
46 | artifacts/
47 |
48 | *_i.c
49 | *_p.c
50 | *_i.h
51 | *.ilk
52 | *.meta
53 | *.obj
54 | *.pch
55 | *.pdb
56 | *.pgc
57 | *.pgd
58 | *.rsp
59 | *.sbr
60 | *.tlb
61 | *.tli
62 | *.tlh
63 | *.tmp
64 | *.tmp_proj
65 | *.log
66 | *.vspscc
67 | *.vssscc
68 | .builds
69 | *.pidb
70 | *.svclog
71 | *.scc
72 |
73 | # Chutzpah Test files
74 | _Chutzpah*
75 |
76 | # Visual C++ cache files
77 | ipch/
78 | *.aps
79 | *.ncb
80 | *.opendb
81 | *.opensdf
82 | *.sdf
83 | *.cachefile
84 | *.VC.db
85 | *.VC.VC.opendb
86 |
87 | # Visual Studio profiler
88 | *.psess
89 | *.vsp
90 | *.vspx
91 | *.sap
92 |
93 | # TFS 2012 Local Workspace
94 | $tf/
95 |
96 | # Guidance Automation Toolkit
97 | *.gpState
98 |
99 | # ReSharper is a .NET coding add-in
100 | _ReSharper*/
101 | *.[Rr]e[Ss]harper
102 | *.DotSettings.user
103 |
104 | # JustCode is a .NET coding add-in
105 | .JustCode
106 |
107 | # TeamCity is a build add-in
108 | _TeamCity*
109 |
110 | # DotCover is a Code Coverage Tool
111 | *.dotCover
112 |
113 | # NCrunch
114 | _NCrunch_*
115 | .*crunch*.local.xml
116 | nCrunchTemp_*
117 |
118 | # MightyMoose
119 | *.mm.*
120 | AutoTest.Net/
121 |
122 | # Web workbench (sass)
123 | .sass-cache/
124 |
125 | # Installshield output folder
126 | [Ee]xpress/
127 |
128 | # DocProject is a documentation generator add-in
129 | DocProject/buildhelp/
130 | DocProject/Help/*.HxT
131 | DocProject/Help/*.HxC
132 | DocProject/Help/*.hhc
133 | DocProject/Help/*.hhk
134 | DocProject/Help/*.hhp
135 | DocProject/Help/Html2
136 | DocProject/Help/html
137 |
138 | # Click-Once directory
139 | publish/
140 |
141 | # Publish Web Output
142 | *.[Pp]ublish.xml
143 | *.azurePubxml
144 | # TODO: Comment the next line if you want to checkin your web deploy settings
145 | # but database connection strings (with potential passwords) will be unencrypted
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
150 | # checkin your Azure Web App publish settings, but sensitive information contained
151 | # in these scripts will be unencrypted
152 | PublishScripts/
153 |
154 | # NuGet Packages
155 | *.nupkg
156 | # The packages folder can be ignored because of Package Restore
157 | **/packages/*
158 | # except build/, which is used as an MSBuild target.
159 | !**/packages/build/
160 | # Uncomment if necessary however generally it will be regenerated when needed
161 | #!**/packages/repositories.config
162 | # NuGet v3's project.json files produces more ignoreable files
163 | *.nuget.props
164 | *.nuget.targets
165 |
166 | # Microsoft Azure Build Output
167 | csx/
168 | *.build.csdef
169 |
170 | # Microsoft Azure Emulator
171 | ecf/
172 | rcf/
173 |
174 | # Windows Store app package directories and files
175 | AppPackages/
176 | BundleArtifacts/
177 | Package.StoreAssociation.xml
178 | _pkginfo.txt
179 |
180 | # Visual Studio cache files
181 | # files ending in .cache can be ignored
182 | *.[Cc]ache
183 | # but keep track of directories ending in .cache
184 | !*.[Cc]ache/
185 |
186 | # Others
187 | ClientBin/
188 | ~$*
189 | *~
190 | *.dbmdl
191 | *.dbproj.schemaview
192 | *.jfm
193 | *.pfx
194 | *.publishsettings
195 | node_modules/
196 | orleans.codegen.cs
197 |
198 | # Since there are multiple workflows, uncomment next line to ignore bower_components
199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
200 | #bower_components/
201 |
202 | # RIA/Silverlight projects
203 | Generated_Code/
204 |
205 | # Backup & report files from converting an old project file
206 | # to a newer Visual Studio version. Backup files are not needed,
207 | # because we have git ;-)
208 | _UpgradeReport_Files/
209 | Backup*/
210 | UpgradeLog*.XML
211 | UpgradeLog*.htm
212 |
213 | # SQL Server files
214 | *.mdf
215 | *.ldf
216 |
217 | # Business Intelligence projects
218 | *.rdl.data
219 | *.bim.layout
220 | *.bim_*.settings
221 |
222 | # Microsoft Fakes
223 | FakesAssemblies/
224 |
225 | # GhostDoc plugin setting file
226 | *.GhostDoc.xml
227 |
228 | # Node.js Tools for Visual Studio
229 | .ntvs_analysis.dat
230 |
231 | # Visual Studio 6 build log
232 | *.plg
233 |
234 | # Visual Studio 6 workspace options file
235 | *.opt
236 |
237 | # Visual Studio LightSwitch build output
238 | **/*.HTMLClient/GeneratedArtifacts
239 | **/*.DesktopClient/GeneratedArtifacts
240 | **/*.DesktopClient/ModelManifest.xml
241 | **/*.Server/GeneratedArtifacts
242 | **/*.Server/ModelManifest.xml
243 | _Pvt_Extensions
244 |
245 | # Paket dependency manager
246 | .paket/paket.exe
247 | paket-files/
248 |
249 | # FAKE - F# Make
250 | .fake/
251 |
252 | # JetBrains Rider
253 | .idea/
254 | *.sln.iml
255 |
256 | # CodeRush
257 | .cr/
258 |
259 | # Python Tools for Visual Studio (PTVS)
260 | __pycache__/
261 | *.pyc
--------------------------------------------------------------------------------
/CelesteExtractor.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27703.2026
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CelesteExtractor", "CelesteExtractor\CelesteExtractor.csproj", "{F0D38431-9510-4842-BA27-8640C6CC8664}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {F0D38431-9510-4842-BA27-8640C6CC8664}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {F0D38431-9510-4842-BA27-8640C6CC8664}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {F0D38431-9510-4842-BA27-8640C6CC8664}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {F0D38431-9510-4842-BA27-8640C6CC8664}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {60830A3F-18AB-418F-BF66-29B895877322}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/CelesteExtractor/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CelesteExtractor/Atlas.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace MyMonocle
9 | {
10 | using Celeste = CelesteExtractor.Celeste.Celeste;
11 | class Atlas
12 | {
13 |
14 | public List Sources;
15 |
16 | public enum AtlasDataFormat
17 | {
18 | TexturePacker_Sparrow,
19 | CrunchXml,
20 | CrunchBinary,
21 | CrunchXmlOrBinary,
22 | CrunchBinaryNoAtlas,
23 | Packer,
24 | PackerNoAtlas
25 | }
26 | public static Atlas FromAtlas(string path, Atlas.AtlasDataFormat format)
27 | {
28 | Atlas atlas = new Atlas();
29 | atlas.Sources = new List();
30 | Atlas.ReadAtlasData(atlas, path, format);
31 | return atlas;
32 | }
33 | private static void ReadAtlasData(Atlas atlas, string path, Atlas.AtlasDataFormat format)
34 | {
35 | switch (format)
36 | {
37 | case Atlas.AtlasDataFormat.TexturePacker_Sparrow:
38 | case Atlas.AtlasDataFormat.CrunchXml:
39 | case Atlas.AtlasDataFormat.CrunchBinary:
40 | case Atlas.AtlasDataFormat.CrunchXmlOrBinary:
41 | case Atlas.AtlasDataFormat.CrunchBinaryNoAtlas:
42 | // Celeste never use these types.
43 | throw new NotImplementedException();
44 | break;
45 | case Atlas.AtlasDataFormat.Packer:
46 | goto IL_521;
47 | case Atlas.AtlasDataFormat.PackerNoAtlas:
48 | goto IL_67A;
49 | default:
50 | throw new NotImplementedException();
51 | IL_521:
52 | using (FileStream fileStream3 = File.OpenRead(Path.Combine(Celeste.ContentDirectory, path + ".meta")))
53 | {
54 | BinaryReader binaryReader3 = new BinaryReader(fileStream3);
55 | binaryReader3.ReadInt32();
56 | binaryReader3.ReadString();
57 | binaryReader3.ReadInt32();
58 | short num9 = binaryReader3.ReadInt16();
59 | for (int m = 0; m < (int)num9; m++)
60 | {
61 | string str3 = binaryReader3.ReadString();
62 | VirtualTexture virtualTexture5 = new VirtualTexture(Path.Combine(Path.GetDirectoryName(path), str3 + ".data"));
63 | atlas.Sources.Add(virtualTexture5);
64 | short num10 = binaryReader3.ReadInt16();
65 | for (int n = 0; n < (int)num10; n++)
66 | {
67 | string text5 = binaryReader3.ReadString().Replace('\\', '/');
68 | short x2 = binaryReader3.ReadInt16();
69 | short y2 = binaryReader3.ReadInt16();
70 | short width3 = binaryReader3.ReadInt16();
71 | short height3 = binaryReader3.ReadInt16();
72 | short num11 = binaryReader3.ReadInt16();
73 | short num12 = binaryReader3.ReadInt16();
74 | short width4 = binaryReader3.ReadInt16();
75 | short height4 = binaryReader3.ReadInt16();
76 | }
77 | }
78 | return;
79 | }
80 | IL_67A:
81 | using (FileStream fileStream4 = File.OpenRead(Path.Combine(Celeste.ContentDirectory, path + ".meta")))
82 | {
83 | BinaryReader binaryReader4 = new BinaryReader(fileStream4);
84 | binaryReader4.ReadInt32();
85 | binaryReader4.ReadString();
86 | binaryReader4.ReadInt32();
87 | short num13 = binaryReader4.ReadInt16();
88 | for (int num14 = 0; num14 < (int)num13; num14++)
89 | {
90 | string path5 = binaryReader4.ReadString();
91 | string path6 = Path.Combine(Path.GetDirectoryName(path), path5);
92 | short num15 = binaryReader4.ReadInt16();
93 | for (int num16 = 0; num16 < (int)num15; num16++)
94 | {
95 | string text6 = binaryReader4.ReadString().Replace('\\', '/');
96 | binaryReader4.ReadInt16();
97 | binaryReader4.ReadInt16();
98 | binaryReader4.ReadInt16();
99 | binaryReader4.ReadInt16();
100 | short num17 = binaryReader4.ReadInt16();
101 | short num18 = binaryReader4.ReadInt16();
102 | short frameWidth2 = binaryReader4.ReadInt16();
103 | short frameHeight2 = binaryReader4.ReadInt16();
104 | VirtualTexture virtualTexture6 = new VirtualTexture(Path.Combine(path6, text6 + ".data"));
105 | atlas.Sources.Add(virtualTexture6);
106 | }
107 | }
108 | return;
109 | }
110 | }
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/CelesteExtractor/Celeste.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.Xna.Framework;
7 | using Microsoft.Xna.Framework.Graphics;
8 | using Microsoft.Xna.Framework.Content;
9 | using WinFormsGraphicsDevice;
10 | using System.Windows.Forms;
11 |
12 | namespace CelesteExtractor
13 | {
14 | namespace Celeste
15 | {
16 | ///
17 | ///
18 | /// Similar to the Game class in original assembly.
19 | ///
20 | ///
21 | class Celeste
22 | {
23 | public static string ContentDirectory { get; set; }
24 | public static string RootDirectory { get; set; }
25 |
26 | private static GraphicsDevice _graphicsDevice = null;
27 |
28 | private static ContentManager _content = null;
29 |
30 | ///
31 | /// This property is a bit hacking to get a GraphicsDevice.
32 | ///
33 | /// Extracting textures in Celeste (or in XNA) needs to construct Texture2D objects
34 | /// which requires a valid GraphicsDevice.
35 | ///
36 | /// Since it is a command-line app, in order to get the GraphicsDevice,
37 | /// I have to create an invisible form to acquire a handle and get the device.
38 | ///
39 | private static void Initialize()
40 | {
41 | Form form = new Form(); // Invisible form to get a valid GraphicsDevice.
42 | GraphicsDeviceService gds = GraphicsDeviceService.AddRef(form.Handle, form.ClientSize.Width, form.ClientSize.Height);
43 | ServiceContainer services = new ServiceContainer();
44 | services.AddService(gds);
45 | _content = new ContentManager(services, "Content");
46 | IGraphicsDeviceService graphicsDeviceService = services.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService;
47 | _graphicsDevice = graphicsDeviceService.GraphicsDevice;
48 | }
49 |
50 |
51 | public static GraphicsDevice graphicsDevice
52 | {
53 | get
54 | {
55 | if (_graphicsDevice == null)
56 | {
57 | Initialize();
58 | }
59 | return _graphicsDevice;
60 | }
61 | }
62 |
63 | public static ContentManager Content
64 | {
65 | get
66 | {
67 | if(_content == null)
68 | {
69 | Initialize();
70 | }
71 | return _content;
72 | }
73 | }
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/CelesteExtractor/CelesteExtractor.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {F0D38431-9510-4842-BA27-8640C6CC8664}
8 | Exe
9 | CelesteExtractor
10 | CelesteExtractor
11 | v4.6.1
12 | 512
13 | true
14 | publish\
15 | true
16 | Disk
17 | false
18 | Foreground
19 | 7
20 | Days
21 | false
22 | false
23 | true
24 | 0
25 | 1.0.0.%2a
26 | false
27 | false
28 | true
29 |
30 |
31 | AnyCPU
32 | true
33 | full
34 | false
35 | bin\Debug\
36 | DEBUG;TRACE
37 | prompt
38 | 4
39 | true
40 |
41 |
42 | AnyCPU
43 | pdbonly
44 | true
45 | bin\Release\
46 | TRACE
47 | prompt
48 | 4
49 | true
50 |
51 |
52 | CelesteExtractor.Extrator
53 |
54 |
55 |
56 | False
57 | XNA\Microsoft.Xna.Framework.dll
58 |
59 |
60 | False
61 | XNA\Microsoft.Xna.Framework.Game.dll
62 |
63 |
64 | False
65 | XNA\Microsoft.Xna.Framework.GamerServices.dll
66 |
67 |
68 | False
69 | XNA\Microsoft.Xna.Framework.Graphics.dll
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 | False
100 | Microsoft .NET Framework 4.6.1 %28x86 和 x64%29
101 | true
102 |
103 |
104 | False
105 | .NET Framework 3.5 SP1
106 | false
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/CelesteExtractor/GraphicsDeviceService.cs:
--------------------------------------------------------------------------------
1 | #region File Description
2 | //-----------------------------------------------------------------------------
3 | // GraphicsDeviceService.cs
4 | //
5 | // Microsoft XNA Community Game Platform
6 | // Copyright (C) Microsoft Corporation. All rights reserved.
7 | //-----------------------------------------------------------------------------
8 | #endregion
9 |
10 | #region Using Statements
11 | using System;
12 | using System.Threading;
13 | using Microsoft.Xna.Framework.Graphics;
14 | #endregion
15 |
16 | // The IGraphicsDeviceService interface requires a DeviceCreated event, but we
17 | // always just create the device inside our constructor, so we have no place to
18 | // raise that event. The C# compiler warns us that the event is never used, but
19 | // we don't care so we just disable this warning.
20 | #pragma warning disable 67
21 |
22 | namespace WinFormsGraphicsDevice
23 | {
24 | ///
25 | /// Helper class responsible for creating and managing the GraphicsDevice.
26 | /// All GraphicsDeviceControl instances share the same GraphicsDeviceService,
27 | /// so even though there can be many controls, there will only ever be a single
28 | /// underlying GraphicsDevice. This implements the standard IGraphicsDeviceService
29 | /// interface, which provides notification events for when the device is reset
30 | /// or disposed.
31 | ///
32 | class GraphicsDeviceService : IGraphicsDeviceService
33 | {
34 | #region Fields
35 |
36 |
37 | // Singleton device service instance.
38 | static GraphicsDeviceService singletonInstance;
39 |
40 |
41 | // Keep track of how many controls are sharing the singletonInstance.
42 | static int referenceCount;
43 |
44 |
45 | #endregion
46 |
47 |
48 | ///
49 | /// Constructor is private, because this is a singleton class:
50 | /// client controls should use the public AddRef method instead.
51 | ///
52 | GraphicsDeviceService(IntPtr windowHandle, int width, int height)
53 | {
54 | parameters = new PresentationParameters();
55 |
56 | parameters.BackBufferWidth = Math.Max(width, 1);
57 | parameters.BackBufferHeight = Math.Max(height, 1);
58 | parameters.BackBufferFormat = SurfaceFormat.Color;
59 | parameters.DepthStencilFormat = DepthFormat.Depth24;
60 | parameters.DeviceWindowHandle = windowHandle;
61 | parameters.PresentationInterval = PresentInterval.Immediate;
62 | parameters.IsFullScreen = false;
63 |
64 | // In order to support texture2D larger than 2048 * 2048,
65 | // we have to use HiDef, not Reach.
66 | graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter,
67 | GraphicsProfile.HiDef,
68 | parameters);
69 | }
70 |
71 |
72 | ///
73 | /// Gets a reference to the singleton instance.
74 | ///
75 | public static GraphicsDeviceService AddRef(IntPtr windowHandle,
76 | int width, int height)
77 | {
78 | // Increment the "how many controls sharing the device" reference count.
79 | if (Interlocked.Increment(ref referenceCount) == 1)
80 | {
81 | // If this is the first control to start using the
82 | // device, we must create the singleton instance.
83 | singletonInstance = new GraphicsDeviceService(windowHandle,
84 | width, height);
85 | }
86 |
87 | return singletonInstance;
88 | }
89 |
90 |
91 | ///
92 | /// Releases a reference to the singleton instance.
93 | ///
94 | public void Release(bool disposing)
95 | {
96 | // Decrement the "how many controls sharing the device" reference count.
97 | if (Interlocked.Decrement(ref referenceCount) == 0)
98 | {
99 | // If this is the last control to finish using the
100 | // device, we should dispose the singleton instance.
101 | if (disposing)
102 | {
103 | if (DeviceDisposing != null)
104 | DeviceDisposing(this, EventArgs.Empty);
105 |
106 | graphicsDevice.Dispose();
107 | }
108 |
109 | graphicsDevice = null;
110 | }
111 | }
112 |
113 |
114 | ///
115 | /// Resets the graphics device to whichever is bigger out of the specified
116 | /// resolution or its current size. This behavior means the device will
117 | /// demand-grow to the largest of all its GraphicsDeviceControl clients.
118 | ///
119 | public void ResetDevice(int width, int height)
120 | {
121 | if (DeviceResetting != null)
122 | DeviceResetting(this, EventArgs.Empty);
123 |
124 | parameters.BackBufferWidth = Math.Max(parameters.BackBufferWidth, width);
125 | parameters.BackBufferHeight = Math.Max(parameters.BackBufferHeight, height);
126 |
127 | graphicsDevice.Reset(parameters);
128 |
129 | if (DeviceReset != null)
130 | DeviceReset(this, EventArgs.Empty);
131 | }
132 |
133 |
134 | ///
135 | /// Gets the current graphics device.
136 | ///
137 | public GraphicsDevice GraphicsDevice
138 | {
139 | get { return graphicsDevice; }
140 | }
141 |
142 | GraphicsDevice graphicsDevice;
143 |
144 |
145 | // Store the current device settings.
146 | PresentationParameters parameters;
147 |
148 |
149 | // IGraphicsDeviceService events.
150 | public event EventHandler DeviceCreated;
151 | public event EventHandler DeviceDisposing;
152 | public event EventHandler DeviceReset;
153 | public event EventHandler DeviceResetting;
154 | }
155 | }
156 |
--------------------------------------------------------------------------------
/CelesteExtractor/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.Xna.Framework;
7 | using Microsoft.Xna.Framework.Graphics;
8 | using Microsoft.Xna.Framework.Content;
9 | using WinFormsGraphicsDevice;
10 | using System.Windows.Forms;
11 | using MyMonocle;
12 | using System.IO;
13 |
14 | namespace CelesteExtractor
15 | {
16 | class Extrator
17 | {
18 | private static string _output_dir = @"I:\Temps\Images\Celeste2";
19 |
20 | struct AtlasInfo
21 | {
22 | public string Path { get;private set; }
23 | public Atlas.AtlasDataFormat Format { get;private set; }
24 | public AtlasInfo(string path, Atlas.AtlasDataFormat format)
25 | {
26 | this.Path = path;
27 | this.Format = format;
28 | }
29 | }
30 |
31 | private static readonly Dictionary _components = new Dictionary {
32 | // OVR
33 | { "Overworld", new AtlasInfo(Path.Combine("Graphics", "Atlases", "Overworld"), Atlas.AtlasDataFormat.PackerNoAtlas)},
34 | // GFX
35 | { "GamePlay", new AtlasInfo(Path.Combine("Graphics", "Atlases", "Gameplay"), Atlas.AtlasDataFormat.Packer)},
36 | { "Openning", new AtlasInfo(Path.Combine("Graphics", "Atlases", "Opening"), Atlas.AtlasDataFormat.PackerNoAtlas)},
37 | { "Gui", new AtlasInfo(Path.Combine("Graphics", "Atlases", "Gui"), Atlas.AtlasDataFormat.Packer)},
38 | { "Misc", new AtlasInfo(Path.Combine("Graphics", "Atlases", "Misc"), Atlas.AtlasDataFormat.PackerNoAtlas)},
39 | { "Portraits", new AtlasInfo(Path.Combine("Graphics", "Atlases", "Portraits"), Atlas.AtlasDataFormat.PackerNoAtlas)},
40 | // MTN
41 | { "FileSelect", new AtlasInfo(Path.Combine("Graphics", "Atlases", "FileSelect"), Atlas.AtlasDataFormat.Packer)},
42 | { "Journal", new AtlasInfo(Path.Combine("Graphics", "Atlases", "Journal"), Atlas.AtlasDataFormat.Packer)},
43 | { "Mountains", new AtlasInfo(Path.Combine("Graphics", "Atlases", "Mountain"), Atlas.AtlasDataFormat.PackerNoAtlas) },
44 | { "CheckPoints", new AtlasInfo(Path.Combine("Graphics", "Atlases", "Checkpoints"), Atlas.AtlasDataFormat.PackerNoAtlas)},
45 | // CS10_Ending
46 | { "Farewell", new AtlasInfo(Path.Combine("Graphics", "Atlases", "Farewell"), Atlas.AtlasDataFormat.PackerNoAtlas) },
47 | // WaveDash
48 | { "WaveDash", new AtlasInfo(Path.Combine("Graphics", "Atlases", "WaveDashing"), Atlas.AtlasDataFormat.Packer) },
49 | // From my guessing
50 | { "CelestialResort", new AtlasInfo(Path.Combine("Graphics", "Atlases", "CelestialResort"), Atlas.AtlasDataFormat.PackerNoAtlas)},
51 | { "Core", new AtlasInfo(Path.Combine("Graphics", "Atlases", "Core"), Atlas.AtlasDataFormat.PackerNoAtlas)},
52 | { "Cliffside", new AtlasInfo(Path.Combine("Graphics", "Atlases", "Cliffside"), Atlas.AtlasDataFormat.PackerNoAtlas)},
53 | { "ForsakenCity", new AtlasInfo(Path.Combine("Graphics", "Atlases", "ForsakenCity"), Atlas.AtlasDataFormat.PackerNoAtlas)},
54 | { "MirrorTemple", new AtlasInfo(Path.Combine("Graphics", "Atlases", "MirrorTemple"), Atlas.AtlasDataFormat.PackerNoAtlas)},
55 | { "OldSite", new AtlasInfo(Path.Combine("Graphics", "Atlases", "OldSite"), Atlas.AtlasDataFormat.PackerNoAtlas)},
56 | { "SummitEnd", new AtlasInfo(Path.Combine("Graphics", "Atlases", "SummitEnd"), Atlas.AtlasDataFormat.PackerNoAtlas)},
57 | { "SummitIntro", new AtlasInfo(Path.Combine("Graphics", "Atlases", "SummitIntro"), Atlas.AtlasDataFormat.PackerNoAtlas)},
58 | { "TheFall", new AtlasInfo(Path.Combine("Graphics", "Atlases", "TheFall"), Atlas.AtlasDataFormat.PackerNoAtlas)},
59 | };
60 |
61 | private static void _extract(string type)
62 | {
63 | Console.WriteLine("Start to extract {0}", type);
64 | AtlasInfo info = _components[type];
65 | Atlas atlas = Atlas.FromAtlas(info.Path, info.Format);
66 | foreach (VirtualTexture texture in atlas.Sources)
67 | {
68 | Console.WriteLine("Writing {0} to specified output directory...", Path.GetFileName(texture.Path));
69 | texture.SaveAsPng(Path.Combine(_output_dir, texture.Path) + ".png");
70 | }
71 | }
72 |
73 | static void WaitExit()
74 | {
75 | Console.WriteLine("Press any key to exit...");
76 | Console.ReadKey();
77 | }
78 |
79 | static void Main(string[] args)
80 | {
81 | if(args.Length != 2)
82 | {
83 | Console.WriteLine("Celeste Extractor : Extracting all atlas in Celeste.");
84 | Console.WriteLine("Usage: CelesteExtractor [ContentDirectory] [OutputDirectory]");
85 | WaitExit();
86 | return;
87 | }
88 | else
89 | {
90 | if (!Directory.Exists(args[0]))
91 | {
92 | Console.WriteLine("Content directory doesn't exist!");
93 | WaitExit();
94 | return;
95 | }
96 | else
97 | {
98 | Celeste.Celeste.ContentDirectory = args[0];
99 | }
100 | _output_dir = args[1];
101 | }
102 | foreach(string type in _components.Keys)
103 | {
104 | try
105 | {
106 | _extract(type);
107 | }
108 | catch (DirectoryNotFoundException)
109 | {
110 | Console.WriteLine("Directory not found. Please check the input directory!");
111 | WaitExit();
112 | return;
113 | }
114 | }
115 | Console.WriteLine("Done!");
116 | WaitExit();
117 | return;
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/CelesteExtractor/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("CelesteExtractor")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("CelesteExtractor")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("f0d38431-9510-4842-ba27-8640c6cc8664")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/CelesteExtractor/ServiceContainer.cs:
--------------------------------------------------------------------------------
1 | #region File Description
2 | //-----------------------------------------------------------------------------
3 | // ServiceContainer.cs
4 | //
5 | // Microsoft XNA Community Game Platform
6 | // Copyright (C) Microsoft Corporation. All rights reserved.
7 | //-----------------------------------------------------------------------------
8 | #endregion
9 |
10 | #region Using Statements
11 | using System;
12 | using System.Collections.Generic;
13 | #endregion
14 |
15 | namespace WinFormsGraphicsDevice
16 | {
17 | ///
18 | /// Container class implements the IServiceProvider interface. This is used
19 | /// to pass shared services between different components, for instance the
20 | /// ContentManager uses it to locate the IGraphicsDeviceService implementation.
21 | ///
22 | public class ServiceContainer : IServiceProvider
23 | {
24 | Dictionary services = new Dictionary();
25 |
26 |
27 | ///
28 | /// Adds a new service to the collection.
29 | ///
30 | public void AddService(T service)
31 | {
32 | services.Add(typeof(T), service);
33 | }
34 |
35 |
36 | ///
37 | /// Looks up the specified service.
38 | ///
39 | public object GetService(Type serviceType)
40 | {
41 | object service;
42 |
43 | services.TryGetValue(serviceType, out service);
44 |
45 | return service;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/CelesteExtractor/VirtualTexture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Microsoft.Xna.Framework;
8 | using Microsoft.Xna.Framework.Graphics;
9 |
10 |
11 | namespace MyMonocle
12 | {
13 | using Celeste = CelesteExtractor.Celeste.Celeste;
14 |
15 | public class VirtualTexture
16 | {
17 | ///
18 | ///
19 | /// The length here is to keep the same with original assembly
20 | ///
21 | ///
22 | internal static readonly byte[] buffer = new byte[67108864];
23 |
24 | internal static readonly byte[] bytes = new byte[524288];
25 |
26 | public string Path { get; private set; }
27 |
28 | public Texture2D Texture { get; private set; }
29 |
30 | internal VirtualTexture(string path)
31 | {
32 | this.Path = path;
33 | this.Reload();
34 | }
35 |
36 | public void SaveAsPng(string path)
37 | {
38 | Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path));
39 | using (FileStream fileStream = File.OpenWrite(path))
40 | {
41 | this.Texture.SaveAsPng(fileStream, this.Texture.Width, this.Texture.Height);
42 | }
43 | }
44 |
45 | internal unsafe void Reload()
46 | {
47 | /*
48 | *
49 | * I remove some irrelevant codes in original assembly here.
50 | *
51 | */
52 | string extension = System.IO.Path.GetExtension(this.Path);
53 | if (extension == ".data")
54 | {
55 | using (FileStream fileStream = File.OpenRead(System.IO.Path.Combine(Celeste.ContentDirectory, this.Path)))
56 | {
57 | fileStream.Read(VirtualTexture.bytes, 0, 524288);
58 | int num = 0;
59 | int num2 = BitConverter.ToInt32(VirtualTexture.bytes, num);
60 | int num3 = BitConverter.ToInt32(VirtualTexture.bytes, num + 4);
61 | bool flag = VirtualTexture.bytes[num + 8] == 1;
62 | num += 9;
63 | int num4 = num2 * num3 * 4;
64 | int j = 0;
65 | try
66 | {
67 | byte[] array3 = VirtualTexture.bytes;
68 | fixed (byte* ptr2 = &array3[0])
69 | {
70 | byte[] array4 = VirtualTexture.buffer;
71 | fixed (byte* ptr3 = &array4[0])
72 | {
73 | while (j < num4)
74 | {
75 | int num5 = (int)(ptr2[num] * 4);
76 | if (flag)
77 | {
78 | byte b = ptr2[num + 1];
79 | if (b > 0)
80 | {
81 | ptr3[j] = ptr2[num + 4];
82 | ptr3[j + 1] = ptr2[num + 3];
83 | ptr3[j + 2] = ptr2[num + 2];
84 | ptr3[j + 3] = b;
85 | num += 5;
86 | }
87 | else
88 | {
89 | ptr3[j] = 0;
90 | ptr3[j + 1] = 0;
91 | ptr3[j + 2] = 0;
92 | ptr3[j + 3] = 0;
93 | num += 2;
94 | }
95 | }
96 | else
97 | {
98 | ptr3[j] = ptr2[num + 3];
99 | ptr3[j + 1] = ptr2[num + 2];
100 | ptr3[j + 2] = ptr2[num + 1];
101 | ptr3[j + 3] = byte.MaxValue;
102 | num += 4;
103 | }
104 | if (num5 > 4)
105 | {
106 | int k = j + 4;
107 | int num6 = j + num5;
108 | while (k < num6)
109 | {
110 | ptr3[k] = ptr3[j];
111 | ptr3[k + 1] = ptr3[j + 1];
112 | ptr3[k + 2] = ptr3[j + 2];
113 | ptr3[k + 3] = ptr3[j + 3];
114 | k += 4;
115 | }
116 | }
117 | j += num5;
118 | if (num > 524256)
119 | {
120 | int num7 = 524288 - num;
121 | for (int l = 0; l < num7; l++)
122 | {
123 | ptr2[l] = ptr2[num + l];
124 | }
125 | fileStream.Read(VirtualTexture.bytes, num7, 524288 - num7);
126 | num = 0;
127 | }
128 | }
129 | }
130 | }
131 | }
132 | finally
133 | {
134 | byte[] array3 = null;
135 | byte[] array4 = null;
136 | }
137 | this.Texture = new Texture2D(Celeste.graphicsDevice, num2, num3);
138 | this.Texture.SetData(VirtualTexture.buffer, 0, num4);
139 | }
140 | }
141 | else if (extension == ".png")
142 | {
143 | using (FileStream fileStream2 = File.OpenRead(System.IO.Path.Combine(Celeste.ContentDirectory, this.Path)))
144 | {
145 | this.Texture = Texture2D.FromStream(Celeste.graphicsDevice, fileStream2);
146 | }
147 | int num8 = this.Texture.Width * this.Texture.Height;
148 | Color[] array5 = new Color[num8];
149 | this.Texture.GetData(array5, 0, num8);
150 | Color[] array2 = array5;
151 | fixed (Color* ptr4 = &array2[0])
152 | {
153 | for (int m = 0; m < num8; m++)
154 | {
155 | ptr4[m].R = (byte)((float)ptr4[m].R * ((float)ptr4[m].A / 255f));
156 | ptr4[m].G = (byte)((float)ptr4[m].G * ((float)ptr4[m].A / 255f));
157 | ptr4[m].B = (byte)((float)ptr4[m].B * ((float)ptr4[m].A / 255f));
158 | }
159 | array2 = null;
160 | this.Texture.SetData(array5, 0, num8);
161 | }
162 | }
163 | else if (extension == ".xnb")
164 | {
165 | string assetName = this.Path.Replace(".xnb", "");
166 | this.Texture = Celeste.Content.Load(assetName);
167 | }
168 | else
169 | {
170 | using (FileStream fileStream3 = File.OpenRead(System.IO.Path.Combine(Celeste.ContentDirectory, this.Path)))
171 | {
172 | this.Texture = Texture2D.FromStream(Celeste.graphicsDevice, fileStream3);
173 | }
174 | }
175 | }
176 |
177 | }
178 | }
179 |
--------------------------------------------------------------------------------
/CelesteExtractor/XNA/Microsoft.Xna.Framework.Game.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wtdcode/CelesteExtractor/b5d96d95d454a922cdd607ba2ebb4dcffbce07f1/CelesteExtractor/XNA/Microsoft.Xna.Framework.Game.dll
--------------------------------------------------------------------------------
/CelesteExtractor/XNA/Microsoft.Xna.Framework.GamerServices.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wtdcode/CelesteExtractor/b5d96d95d454a922cdd607ba2ebb4dcffbce07f1/CelesteExtractor/XNA/Microsoft.Xna.Framework.GamerServices.dll
--------------------------------------------------------------------------------
/CelesteExtractor/XNA/Microsoft.Xna.Framework.Graphics.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wtdcode/CelesteExtractor/b5d96d95d454a922cdd607ba2ebb4dcffbce07f1/CelesteExtractor/XNA/Microsoft.Xna.Framework.Graphics.dll
--------------------------------------------------------------------------------
/CelesteExtractor/XNA/Microsoft.Xna.Framework.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wtdcode/CelesteExtractor/b5d96d95d454a922cdd607ba2ebb4dcffbce07f1/CelesteExtractor/XNA/Microsoft.Xna.Framework.dll
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2 | Version 2, December 2004
3 |
4 | Copyright (C) 2004 Sam Hocevar
5 |
6 | Everyone is permitted to copy and distribute verbatim or modified
7 | copies of this license document, and changing it is allowed as long
8 | as the name is changed.
9 |
10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12 |
13 | 0. You just DO WHAT THE FUCK YOU WANT TO.
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CelesteExtractor
2 |
3 | ## Introduction
4 |
5 | It is a tool to extract all atlas in Celeste.
6 |
7 | ## Download
8 |
9 | Binary release can be found in [here](https://github.com/wtdcode/CelesteExtractor/releases).
10 |
11 | ## Usage
12 |
13 | ```batch
14 | CelesteExtractor.exe [ContentDirectory] [OutputDirectory]
15 | ```
16 |
17 | Pay attention to **ContentDirectory**. For example, if you have Celeste installed in `C:\Celeste`, the ContentDirectory should be `C:\Celeste\Content`.
18 |
19 | If the output directory doesn't exist, it will create it for you.
20 |
21 | ## Audio
22 |
23 | Looking for audio resources? See [this](https://www.fmod.com/download#demos).
24 |
25 | ## Issue
26 |
27 | If you encounter any problem, please post an issue with any relevant information. I will check it as soon as possible.
28 |
29 | ## License
30 |
31 | 
32 |
33 | ```
34 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
35 | Version 2, December 2004
36 |
37 | Copyright (C) 2004 Sam Hocevar
38 |
39 | Everyone is permitted to copy and distribute verbatim or modified
40 | copies of this license document, and changing it is allowed as long
41 | as the name is changed.
42 |
43 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
44 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
45 |
46 | 0. You just DO WHAT THE FUCK YOU WANT TO.
47 | ```
48 |
49 | Feel free to do anything about the codes.
50 |
51 | ## Celeste
52 |
53 | 
54 |
55 | Enjoy the game :p.
56 |
--------------------------------------------------------------------------------
/normal04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wtdcode/CelesteExtractor/b5d96d95d454a922cdd607ba2ebb4dcffbce07f1/normal04.png
--------------------------------------------------------------------------------