├── .gitattributes
├── .gitignore
├── LICENSE.md
├── README.md
├── SceneNavi.sln
└── SceneNavi
├── ActorRendering
├── GameActor.cs
├── MIPS.cs
└── MIPSEvaluator.cs
├── AssemblyHelpers.cs
├── Bottled Fairy.ico
├── ColorPickerDialog.Designer.cs
├── ColorPickerDialog.cs
├── ColorPickerDialog.resx
├── Configuration.cs
├── Controls
├── CustomGLControl.cs
├── HScrollBarEx.cs
├── ListViewEx.cs
├── RichLabel.cs
├── TableLayoutPanelEx.cs
├── ToolStripHintMenuItem.cs
├── ToolStripRadioButtonMenuItem.cs
└── TreeViewEx.cs
├── Endian.cs
├── ExtensionMethods.cs
├── GUIHelpers.cs
├── HeaderCommands
├── Actors.cs
├── Collision.cs
├── EnvironmentSettings.cs
├── Generic.cs
├── IPickableObject.cs
├── IStoreable.cs
├── MeshHeader.cs
├── Objects.cs
├── Rooms.cs
├── SettingsSoundScene.cs
├── SpecialObjects.cs
└── Waypoints.cs
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── OpenGLHelpers
├── Camera.cs
├── DisplayList.cs
├── DisplayListEx.cs
├── FPSMonitor.cs
├── Initialization.cs
├── MiscDrawingHelpers.cs
├── ScreenWorldConversion.cs
├── StockObjects.cs
└── TextPrinter.cs
├── OpenTK.dll.config
├── Program.cs
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── ROMHandler
├── ActorTableEntry.cs
├── DMATableEntry.cs
├── EntranceTableEntry.cs
├── HeaderLoader.cs
├── ISceneTableEntry.cs
├── ObjectTableEntry.cs
├── ROMHandler.cs
├── SceneTableEntryMajora.cs
└── SceneTableEntryOcarina.cs
├── Resources
├── BgEmpty_Large.png
├── BgEmpty_Small.png
├── FragmentShader.glsl
└── VertexShader.glsl
├── SceneNavi.csproj
├── SimpleF3DEX2
├── CombinerEmulation
│ ├── ArbCombineManager.cs
│ ├── ArbCombineProgram.cs
│ ├── GLSLCombineManager.cs
│ ├── ICombinerManager.cs
│ └── KnownCombinerMuxes.cs
├── F3DEX2Interpreter.cs
├── General.cs
├── ImageHelper.cs
├── OtherModeL.cs
├── SimpleTriangle.cs
├── Texture.cs
├── TextureCache.cs
├── UnpackedCombinerMux.cs
└── Vertex.cs
├── StatusMessageHandler.cs
├── TableEditorForm.Designer.cs
├── TableEditorForm.cs
├── TableEditorForm.resx
├── TitleCardForm.Designer.cs
├── TitleCardForm.cs
├── TitleCardForm.resx
├── UpdateCheckDialog.Designer.cs
├── UpdateCheckDialog.cs
├── UpdateCheckDialog.resx
├── UpdateData
├── SceneNavi.txt
├── sn-update.htm
└── sn-update.rtf
├── VersionManagement.cs
├── XML
├── ActorDefinitions
│ ├── DL
│ │ └── Database.xml
│ ├── ZL
│ │ └── Database.xml
│ └── ZS
│ │ └── Database.xml
├── GameDataGeneric
│ ├── DL
│ │ ├── ActorNames.xml
│ │ ├── ObjectNames.xml
│ │ └── SongNames.xml
│ ├── ZL
│ │ ├── ActorNames.xml
│ │ ├── ObjectNames.xml
│ │ └── SongNames.xml
│ └── ZS
│ │ ├── ActorNames.xml
│ │ ├── ObjectNames.xml
│ │ └── SongNames.xml
└── GameDataSpecific
│ ├── CZLE0
│ ├── RoomNames.xml
│ ├── SceneNames.xml
│ └── StageDescriptions.xml
│ └── NZLEF
│ ├── RoomNames.xml
│ ├── SceneNames.xml
│ └── StageDescriptions.xml
├── XMLActorDefinitionReader.cs
├── XMLHashTableReader.cs
├── app.config
└── packages.config
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.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
262 | /Essgee/GeneratedBuildInformation.cs
263 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 xdaniel (Daniel R.) / DigitalZero Domain
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.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | SceneNavi
2 | =========
3 |
4 | A level editor for The Legend of Zelda: Ocarina of Time and Majora's Mask, written in C#.
5 |
6 | 
7 |
8 | Requirements
9 | ============
10 |
11 | * Visual Studio w/ NuGet package manager, ex. VS Community 2013
12 | * .NET Framework 4
13 | * NuGet packages for:
14 | * [OpenTK 1.1](http://www.opentk.com)
15 | * [Nini 1.1.0](http://nini.sourceforge.net/)
16 |
--------------------------------------------------------------------------------
/SceneNavi.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28010.2046
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SceneNavi", "SceneNavi\SceneNavi.csproj", "{09D70578-1C8E-4E6A-80D1-1F0E5F9155A2}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Debug|Mixed Platforms = Debug|Mixed Platforms
12 | Debug|x86 = Debug|x86
13 | Release|Any CPU = Release|Any CPU
14 | Release|Mixed Platforms = Release|Mixed Platforms
15 | Release|x86 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {09D70578-1C8E-4E6A-80D1-1F0E5F9155A2}.Debug|Any CPU.ActiveCfg = Debug|x86
19 | {09D70578-1C8E-4E6A-80D1-1F0E5F9155A2}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
20 | {09D70578-1C8E-4E6A-80D1-1F0E5F9155A2}.Debug|Mixed Platforms.Build.0 = Debug|x86
21 | {09D70578-1C8E-4E6A-80D1-1F0E5F9155A2}.Debug|x86.ActiveCfg = Debug|x86
22 | {09D70578-1C8E-4E6A-80D1-1F0E5F9155A2}.Debug|x86.Build.0 = Debug|x86
23 | {09D70578-1C8E-4E6A-80D1-1F0E5F9155A2}.Release|Any CPU.ActiveCfg = Release|x86
24 | {09D70578-1C8E-4E6A-80D1-1F0E5F9155A2}.Release|Mixed Platforms.ActiveCfg = Release|x86
25 | {09D70578-1C8E-4E6A-80D1-1F0E5F9155A2}.Release|Mixed Platforms.Build.0 = Release|x86
26 | {09D70578-1C8E-4E6A-80D1-1F0E5F9155A2}.Release|x86.ActiveCfg = Release|x86
27 | {09D70578-1C8E-4E6A-80D1-1F0E5F9155A2}.Release|x86.Build.0 = Release|x86
28 | EndGlobalSection
29 | GlobalSection(SolutionProperties) = preSolution
30 | HideSolutionNode = FALSE
31 | EndGlobalSection
32 | GlobalSection(ExtensibilityGlobals) = postSolution
33 | SolutionGuid = {8B548202-BF13-4584-99C0-DD3FE6EA185E}
34 | EndGlobalSection
35 | EndGlobal
36 |
--------------------------------------------------------------------------------
/SceneNavi/AssemblyHelpers.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SceneNavi
7 | {
8 | class AssemblyHelpers
9 | {
10 | public static DateTime RetrieveLinkerTimestamp()
11 | {
12 | string filePath = System.Reflection.Assembly.GetCallingAssembly().Location;
13 | const int c_PeHeaderOffset = 60;
14 | const int c_LinkerTimestampOffset = 8;
15 | byte[] b = new byte[2048];
16 | System.IO.Stream s = null;
17 |
18 | try
19 | {
20 | s = new System.IO.FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
21 | s.Read(b, 0, 2048);
22 | }
23 | finally
24 | {
25 | if (s != null)
26 | {
27 | s.Close();
28 | }
29 | }
30 |
31 | int i = System.BitConverter.ToInt32(b, c_PeHeaderOffset);
32 | int secondsSince1970 = System.BitConverter.ToInt32(b, i + c_LinkerTimestampOffset);
33 | DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0);
34 | dt = dt.AddSeconds(secondsSince1970);
35 | dt = dt.AddHours(TimeZone.CurrentTimeZone.GetUtcOffset(dt).Hours);
36 | return dt;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/SceneNavi/Bottled Fairy.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdanieldzd/SceneNavi/d0813a38e58c3ff6fec365f3951d12edd4320ea5/SceneNavi/Bottled Fairy.ico
--------------------------------------------------------------------------------
/SceneNavi/ColorPickerDialog.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
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 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/SceneNavi/Controls/CustomGLControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | using OpenTK;
7 | using OpenTK.Graphics;
8 | using OpenTK.Graphics.OpenGL;
9 |
10 | namespace SceneNavi.Controls
11 | {
12 | class CustomGLControl : GLControl
13 | {
14 | public CustomGLControl()
15 | : base(new GraphicsMode(GraphicsMode.Default.ColorFormat, GraphicsMode.Default.Depth, GraphicsMode.Default.Stencil, Configuration.AntiAliasingSamples))
16 | { }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/SceneNavi/Controls/HScrollBarEx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 |
7 | namespace SceneNavi.Controls
8 | {
9 | class HScrollBarEx : HScrollBar
10 | {
11 | protected int valSmallChange = 1;
12 | protected int valLargeChange = 1;
13 | protected int valViewable = 1;
14 | protected int valMax = 1;
15 |
16 | public int ValSmallChange
17 | {
18 | get { return valSmallChange; }
19 | set
20 | {
21 | valSmallChange = value;
22 | this.SmallChange = valSmallChange;
23 | }
24 | }
25 |
26 | public int ValLargeChange
27 | {
28 | get { return valLargeChange; }
29 | set { valLargeChange = value; }
30 | }
31 |
32 | public int ViewableCount
33 | {
34 | get { return valViewable; }
35 | set
36 | {
37 | valViewable = value;
38 | Recalc();
39 | }
40 | }
41 |
42 | public int MaximumCount
43 | {
44 | get { return valMax; }
45 | set
46 | {
47 | valMax = value;
48 | this.LargeChange = this.Height;
49 | Recalc();
50 | }
51 | }
52 |
53 | protected void Recalc()
54 | {
55 | this.Maximum = MaximumCount;
56 | this.LargeChange = ViewableCount;
57 | }
58 |
59 | protected override void WndProc(ref Message m)
60 | {
61 | if (m.Msg == 8469)
62 | {
63 | switch ((uint)m.WParam)
64 | {
65 | case 2: // page up
66 | if (this.Value - this.ValLargeChange > 0)
67 | {
68 | this.Value -= this.ValLargeChange;
69 | }
70 | else
71 | {
72 | this.Value = 0;
73 | }
74 | break;
75 |
76 | case 3: // page down
77 | if (this.Value + this.LargeChange + this.ValLargeChange < this.Maximum)
78 | {
79 | this.Value += this.ValLargeChange;
80 | }
81 | else
82 | {
83 | this.Value = this.Maximum - this.LargeChange;
84 | }
85 | break;
86 |
87 | default:
88 | base.WndProc(ref m);
89 | break;
90 | }
91 | }
92 | else
93 | {
94 | base.WndProc(ref m);
95 | }
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/SceneNavi/Controls/ListViewEx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Runtime.InteropServices;
7 |
8 | namespace SceneNavi.Controls
9 | {
10 | class ListViewEx : ListView
11 | {
12 | [StructLayout(LayoutKind.Sequential)]
13 | private struct NMHDR
14 | {
15 | public IntPtr hwndFrom;
16 | public uint idFrom;
17 | public uint code;
18 | }
19 |
20 | private const uint NM_CUSTOMDRAW = unchecked((uint)-12);
21 |
22 | public ListViewEx()
23 | : base()
24 | {
25 | this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
26 |
27 | }
28 |
29 | [DllImport("uxtheme.dll", CharSet = CharSet.Unicode)]
30 | public extern static int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList);
31 | protected override void OnHandleCreated(EventArgs e)
32 | {
33 | base.OnHandleCreated(e);
34 |
35 | if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 6)
36 | {
37 | SetWindowTheme(this.Handle, "explorer", null);
38 | }
39 | }
40 |
41 | protected override void WndProc(ref Message m)
42 | {
43 | if (m.Msg == 0x204E)
44 | {
45 | NMHDR hdr = (NMHDR)m.GetLParam(typeof(NMHDR));
46 | if (hdr.code == NM_CUSTOMDRAW)
47 | {
48 | m.Result = (IntPtr)0;
49 | return;
50 | }
51 | }
52 |
53 | base.WndProc(ref m);
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/SceneNavi/Controls/RichLabel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Runtime.InteropServices;
7 |
8 | namespace SceneNavi.Controls
9 | {
10 | class RichLabel : RichTextBox
11 | {
12 | [DllImport("user32.dll")]
13 | static extern bool HideCaret(IntPtr hWnd);
14 |
15 | public RichLabel()
16 | {
17 | //this.ReadOnly = true;
18 | //this.TabStop = false;
19 | //this.SetStyle(ControlStyles.Selectable, false);
20 | }
21 |
22 | protected override void OnEnter(EventArgs e)
23 | {
24 | //if (!DesignMode) this.Parent.SelectNextControl(this, true, true, true, true);
25 | base.OnEnter(e);
26 | }
27 |
28 | protected override void WndProc(ref Message m)
29 | {
30 | if (m.Msg < 0x201 || m.Msg > 0x20e || m.Msg == 0x20a) base.WndProc(ref m);
31 |
32 | HideCaret(this.Handle);
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/SceneNavi/Controls/TableLayoutPanelEx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.ComponentModel;
7 |
8 | namespace SceneNavi.Controls
9 | {
10 | public partial class TableLayoutPanelEx : TableLayoutPanel
11 | {
12 | public TableLayoutPanelEx()
13 | {
14 | this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/SceneNavi/Controls/ToolStripHintMenuItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Drawing;
7 |
8 | namespace SceneNavi.Controls
9 | {
10 | public class ToolStripHintMenuItem : ToolStripMenuItem
11 | {
12 | public event EventHandler Hint, Unhint;
13 |
14 | public override bool Selected
15 | {
16 | get
17 | {
18 | if (base.Selected) OnHint(EventArgs.Empty);
19 | else OnUnhint(EventArgs.Empty);
20 | return base.Selected;
21 | }
22 | }
23 |
24 | public string HelpText { get; set; }
25 |
26 | public ToolStripHintMenuItem() :
27 | base(null, null, (EventHandler)null)
28 | {
29 | Initialize();
30 | }
31 |
32 | public ToolStripHintMenuItem(string text)
33 | : base(text, null, (EventHandler)null)
34 | {
35 | Initialize();
36 | }
37 |
38 | public ToolStripHintMenuItem(Image image)
39 | : base(null, image, (EventHandler)null)
40 | {
41 | Initialize();
42 | }
43 |
44 | public ToolStripHintMenuItem(string text, Image image)
45 | : base(text, image, (EventHandler)null)
46 | {
47 | Initialize();
48 | }
49 |
50 | public ToolStripHintMenuItem(string text, Image image, EventHandler onClick)
51 | : base(text, image, onClick)
52 | {
53 | Initialize();
54 | }
55 |
56 | public ToolStripHintMenuItem(string text, Image image, EventHandler onClick, string name)
57 | : base(text, image, onClick, name)
58 | {
59 | Initialize();
60 | }
61 |
62 | public ToolStripHintMenuItem(string text, Image image, params ToolStripItem[] dropDownItems)
63 | : base(text, image, dropDownItems)
64 | {
65 | Initialize();
66 | }
67 |
68 | public ToolStripHintMenuItem(string text, Image image, EventHandler onClick, Keys shortcutKeys)
69 | : base(text, image, onClick)
70 | {
71 | Initialize();
72 | }
73 |
74 | private void Initialize()
75 | {
76 | HelpText = null;
77 | }
78 |
79 | protected virtual void OnHint(EventArgs e)
80 | {
81 | if (Hint != null) Hint(this, e);
82 | }
83 |
84 | protected virtual void OnUnhint(EventArgs e)
85 | {
86 | if (Unhint != null) Unhint(this, e);
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/SceneNavi/Controls/TreeViewEx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Runtime.InteropServices;
7 |
8 | namespace SceneNavi.Controls
9 | {
10 | public class TreeViewEx : TreeView
11 | {
12 | public TreeViewEx() : base() { }
13 |
14 | [DllImport("uxtheme.dll", CharSet = CharSet.Unicode)]
15 | public extern static int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList);
16 | protected override void OnHandleCreated(EventArgs e)
17 | {
18 | base.OnHandleCreated(e);
19 |
20 | if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 6)
21 | {
22 | SetWindowTheme(this.Handle, "explorer", null);
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/SceneNavi/Endian.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SceneNavi
7 | {
8 | public class Endian
9 | {
10 | static Endian()
11 | {
12 | _LittleEndian = BitConverter.IsLittleEndian;
13 | }
14 |
15 | public static short SwapInt16(short v)
16 | {
17 | return (short)(((v & 0xff) << 8) | ((v >> 8) & 0xff));
18 | }
19 |
20 | public static ushort SwapUInt16(ushort v)
21 | {
22 | return (ushort)(((v & 0xff) << 8) | ((v >> 8) & 0xff));
23 | }
24 |
25 | public static int SwapInt32(int v)
26 | {
27 | return (int)(((SwapInt16((short)v) & 0xffff) << 0x10) | (SwapInt16((short)(v >> 0x10)) & 0xffff));
28 | }
29 |
30 | public static uint SwapUInt32(uint v)
31 | {
32 | return (uint)(((SwapUInt16((ushort)v) & 0xffff) << 0x10) | (SwapUInt16((ushort)(v >> 0x10)) & 0xffff));
33 | }
34 |
35 | public static long SwapInt64(long v)
36 | {
37 | return (long)(((SwapInt32((int)v) & 0xffffffffL) << 0x20) | (SwapInt32((int)(v >> 0x20)) & 0xffffffffL));
38 | }
39 |
40 | public static ulong SwapUInt64(ulong v)
41 | {
42 | return (ulong)(((SwapUInt32((uint)v) & 0xffffffffL) << 0x20) | (SwapUInt32((uint)(v >> 0x20)) & 0xffffffffL));
43 | }
44 |
45 | public static bool IsBigEndian { get { return !_LittleEndian; } }
46 | public static bool IsLittleEndian { get { return _LittleEndian; } }
47 |
48 | private static readonly bool _LittleEndian;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/SceneNavi/ExtensionMethods.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Reflection;
6 | using System.Windows.Forms;
7 | using System.Drawing.Imaging;
8 | using System.ComponentModel;
9 | using System.Drawing;
10 |
11 | namespace SceneNavi
12 | {
13 | public static class ExtensionMethods
14 | {
15 | // http://stackoverflow.com/a/3588137
16 | public static void UIThread(this Control @this, Action code)
17 | {
18 | if (@this.InvokeRequired)
19 | {
20 | @this.BeginInvoke(code);
21 | }
22 | else
23 | {
24 | code.Invoke();
25 | }
26 | }
27 |
28 | public static void DoubleBuffered(this Control ctrl, bool setting)
29 | {
30 | Type ctrlType = ctrl.GetType();
31 | PropertyInfo pi = ctrlType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
32 | if (pi != null) pi.SetValue(ctrl, setting, null);
33 | }
34 |
35 | public static byte Scale(this byte val, byte min, byte max, byte minScale, byte maxScale)
36 | {
37 | return (byte)(minScale + (float)(val - min) / (max - min) * (maxScale - minScale));
38 | }
39 |
40 | public static float Scale(this float val, float min, float max, float minScale, float maxScale)
41 | {
42 | return (minScale + (float)(val - min) / (max - min) * (maxScale - minScale));
43 | }
44 |
45 | public static T Clamp(this T val, T min, T max) where T : IComparable
46 | {
47 | if (val.CompareTo(min) < 0) return min;
48 | else if (val.CompareTo(max) > 0) return max;
49 | else return val;
50 | }
51 |
52 | public static void Init(this T[] array, T defaultValue)
53 | {
54 | if (array == null)
55 | return;
56 |
57 | for (int i = 0; i < array.Length; i++)
58 | {
59 | array[i] = defaultValue;
60 | }
61 | }
62 |
63 | public static void Fill(this T[] array, T[] data)
64 | {
65 | if (array == null)
66 | return;
67 |
68 | for (int i = 0; i < array.Length; i += data.Length)
69 | {
70 | for (int j = 0; j < data.Length; j++)
71 | {
72 | try
73 | {
74 | array[i + j] = data[j];
75 | }
76 | catch
77 | {
78 | return;
79 | }
80 | }
81 | }
82 | }
83 |
84 | public static IEnumerable FlattenTree(this TreeView tv)
85 | {
86 | return FlattenTree(tv.Nodes);
87 | }
88 |
89 | public static IEnumerable FlattenTree(this TreeNodeCollection coll)
90 | {
91 | return coll.Cast().Concat(coll.Cast().SelectMany(x => FlattenTree(x.Nodes)));
92 | }
93 |
94 | public static IEnumerable FlattenHintMenu(this MenuStrip menu)
95 | {
96 | return FlattenMenu(menu.Items);
97 | }
98 |
99 | public static IEnumerable FlattenMenu(this ToolStripItemCollection coll)
100 | {
101 | return coll.OfType().Concat(coll.OfType().SelectMany(x => FlattenMenu(x.DropDownItems)));
102 | }
103 |
104 | public static void SetCommonImageFilter(this FileDialog fileDialog)
105 | {
106 | fileDialog.SetCommonImageFilter(null);
107 | }
108 |
109 | public static void SetCommonImageFilter(this FileDialog fileDialog, string defaultExtension)
110 | {
111 | List codecs = ImageCodecInfo.GetImageEncoders().ToList();
112 | string imageExtensions = string.Join(";", codecs.Select(ici => ici.FilenameExtension));
113 | List separateFilters = new List();
114 | foreach (ImageCodecInfo codec in codecs) separateFilters.Add(string.Format("{0} Files ({1})|{1}", codec.FormatDescription, codec.FilenameExtension.ToLowerInvariant()));
115 | fileDialog.Filter = string.Format("{0}|Image Files ({1})|{1}|All Files (*.*)|*.*", string.Join("|", separateFilters), imageExtensions.ToLowerInvariant());
116 | if (defaultExtension != null) fileDialog.FilterIndex = (codecs.IndexOf(codecs.FirstOrDefault(x => x.FormatDescription.ToLowerInvariant().Contains(defaultExtension.ToLowerInvariant()))) + 1);
117 | else fileDialog.FilterIndex = (codecs.Count + 1);
118 | }
119 |
120 | public static void SwapRGBAToBGRA(this byte[] buffer)
121 | {
122 | for (int i = 0; i < buffer.Length; i += 4)
123 | {
124 | byte red = buffer[i];
125 | buffer[i] = buffer[i + 2];
126 | buffer[i + 2] = red;
127 | }
128 | }
129 |
130 | public static string GetDescription(this Type objectType, string field)
131 | {
132 | PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(objectType)[field];
133 | if (propertyDescriptor == null) return field;
134 |
135 | AttributeCollection attributes = propertyDescriptor.Attributes;
136 | DescriptionAttribute description = (DescriptionAttribute)attributes[typeof(DescriptionAttribute)];
137 |
138 | if (description.Description == string.Empty) return field;
139 |
140 | return description.Description;
141 | }
142 |
143 | public static SizeF MeasureString(this string s, Font font, StringFormat strFormat)
144 | {
145 | SizeF result;
146 | using (var image = new Bitmap(1, 1))
147 | {
148 | using (var g = Graphics.FromImage(image))
149 | {
150 | result = g.MeasureString(s, font, int.MaxValue, strFormat);
151 | }
152 | }
153 |
154 | return result;
155 | }
156 | }
157 | }
158 |
--------------------------------------------------------------------------------
/SceneNavi/GUIHelpers.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Runtime.InteropServices;
7 | using System.Windows.Forms.Design;
8 |
9 | namespace SceneNavi
10 | {
11 | class GUIHelpers
12 | {
13 | ///
14 | /// Show a file save dialog
15 | ///
16 | /// File filters to use
17 | /// Default filter index (optional)
18 | /// Path to selected file
19 | public static string ShowSaveFileDialog(string filter, int filteridx = -1)
20 | {
21 | string sfile = string.Empty;
22 |
23 | SaveFileDialog sfd = new SaveFileDialog();
24 | sfd.Filter = filter;
25 | sfd.FilterIndex = filteridx;
26 | sfd.CheckPathExists = true;
27 |
28 | if (sfd.ShowDialog() == DialogResult.OK) sfile = sfd.FileName;
29 |
30 | return sfile;
31 | }
32 |
33 | public static string LoadLocalizedString(string libraryName, uint ident, string defaultText)
34 | {
35 | IntPtr libraryHandle = LoadLibrary(libraryName);
36 | if (libraryHandle != IntPtr.Zero)
37 | {
38 | StringBuilder sb = new StringBuilder(1024);
39 | int size = LoadString(libraryHandle, ident, sb, 1024);
40 | if (size > 0) return sb.ToString();
41 | }
42 | FreeLibrary(libraryHandle);
43 | return defaultText;
44 | }
45 |
46 | [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
47 | private static extern IntPtr LoadLibrary(string path);
48 | [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
49 | private static extern bool FreeLibrary(IntPtr hInst);
50 |
51 | [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
52 | private static extern IntPtr GetModuleHandle(string lpModuleName);
53 |
54 | [DllImport("user32.dll", CharSet = CharSet.Auto)]
55 | private static extern int LoadString(IntPtr hInstance, uint uID, StringBuilder lpBuffer, int nBufferMax);
56 |
57 | [System.Drawing.ToolboxBitmap(typeof(ToolStripButton))]
58 | [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.MenuStrip | ToolStripItemDesignerAvailability.ContextMenuStrip | ToolStripItemDesignerAvailability.StatusStrip)]
59 | public class ButtonStripItem : ToolStripButton
60 | {
61 | }
62 |
63 | [System.Drawing.ToolboxBitmap(typeof(ToolStripSeparator))]
64 | [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.MenuStrip | ToolStripItemDesignerAvailability.ContextMenuStrip | ToolStripItemDesignerAvailability.StatusStrip)]
65 | public class SeparatorStripItem : ToolStripSeparator
66 | {
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/SceneNavi/HeaderCommands/EnvironmentSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 |
7 | using OpenTK;
8 | using OpenTK.Graphics;
9 | using OpenTK.Graphics.OpenGL;
10 |
11 | namespace SceneNavi.HeaderCommands
12 | {
13 | public class EnvironmentSettings : Generic
14 | {
15 | public List EnvSettingList { get; set; }
16 |
17 | public EnvironmentSettings(Generic basecmd)
18 | : base(basecmd)
19 | {
20 | EnvSettingList = new List();
21 | for (int i = 0; i < GetCountGeneric(); i++) EnvSettingList.Add(new Entry(ROM, (uint)(GetAddressGeneric() + i * 22)));
22 | }
23 |
24 | public class Entry
25 | {
26 | public uint Address { get; set; }
27 |
28 | public Color AmbientLightColor { get; set; }
29 | public Vector4 Light1Direction { get; set; }
30 | public Color Light1Color { get; set; }
31 | public Vector4 Light2Direction { get; set; }
32 | public Color Light2Color { get; set; }
33 | public Color FogColor { get; set; }
34 | public ushort LightBlendRate { get; set; } // ???
35 | public ushort FogNear { get; set; } // 0 to 1000, max is 999?
36 | public short DrawDistance { get; set; } // ??? to 32767
37 |
38 | ROMHandler.ROMHandler ROM;
39 |
40 | public Entry() { }
41 |
42 | public Entry(ROMHandler.ROMHandler rom, uint adr)
43 | {
44 | ROM = rom;
45 | Address = adr;
46 |
47 | byte[] segdata = (byte[])ROM.SegmentMapping[(byte)(adr >> 24)];
48 | if (segdata == null) return;
49 |
50 | adr &= 0xFFFFFF;
51 |
52 | AmbientLightColor = Color.FromArgb(segdata[adr], segdata[adr + 1], segdata[adr + 2]);
53 | Light1Direction = new Vector4(((sbyte)segdata[adr + 3] / 255.0f), ((sbyte)segdata[adr + 4] / 255.0f), ((sbyte)segdata[adr + 5] / 255.0f), 0.0f);
54 | Light1Color = Color.FromArgb(segdata[adr + 6], segdata[adr + 7], segdata[adr + 8]);
55 | Light2Direction = new Vector4(((sbyte)segdata[adr + 9] / 255.0f), ((sbyte)segdata[adr + 10] / 255.0f), ((sbyte)segdata[adr + 11] / 255.0f), 0.0f);
56 | Light2Color = Color.FromArgb(segdata[adr + 12], segdata[adr + 13], segdata[adr + 14]);
57 | FogColor = Color.FromArgb(segdata[adr + 15], segdata[adr + 16], segdata[adr + 17]);
58 | LightBlendRate = (ushort)((Endian.SwapUInt16(BitConverter.ToUInt16(segdata, (int)(adr + 18))) & 0xFC00) >> 10);
59 | FogNear = (ushort)(Endian.SwapUInt16(BitConverter.ToUInt16(segdata, (int)(adr + 18))) & 0x03FF);
60 | DrawDistance = (short)Endian.SwapUInt16(BitConverter.ToUInt16(segdata, (int)(adr + 20)));
61 | }
62 |
63 | public void InitializeLighting()
64 | {
65 | // TODO make correct, look up in SDK docs, etc, etc!!!
66 |
67 | GL.PushMatrix();
68 | GL.LoadIdentity();
69 | GL.Light(LightName.Light0, LightParameter.Ambient, AmbientLightColor);
70 | GL.Light(LightName.Light1, LightParameter.Diffuse, Light1Color);
71 | GL.Light(LightName.Light1, LightParameter.Position, Light1Direction);
72 | GL.Light(LightName.Light2, LightParameter.Diffuse, Light2Color);
73 | GL.Light(LightName.Light2, LightParameter.Position, Light2Direction);
74 | GL.PopMatrix();
75 |
76 | GL.Enable(EnableCap.Light0);
77 | GL.Enable(EnableCap.Light1);
78 | GL.Enable(EnableCap.Light2);
79 | }
80 |
81 | public void InitializeFog(float scale)
82 | {
83 | GL.Fog(FogParameter.FogMode, (int)FogMode.Exp2);
84 | GL.Hint(HintTarget.FogHint, HintMode.Nicest);
85 | GL.Fog(FogParameter.FogColor, new float[] { FogColor.R / 255.0f, FogColor.G / 255.0f, FogColor.B / 255.0f });
86 | GL.Fog(FogParameter.FogDensity, 1.0f - (FogNear / 1000.0f));
87 | }
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/SceneNavi/HeaderCommands/Generic.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | using SceneNavi.ROMHandler;
7 |
8 | namespace SceneNavi.HeaderCommands
9 | {
10 | public class Generic
11 | {
12 | public HeaderLoader.CommandTypeIDs Command { get; private set; }
13 | public int Offset { get; private set; }
14 | public ulong Data { get; private set; }
15 | public IHeaderParent Parent { get; private set; }
16 |
17 | public string Description
18 | {
19 | get { return (string)HeaderLoader.CommandHumanNames[Command]; }
20 | }
21 |
22 | public string ByteString
23 | {
24 | get { return string.Format("0x{0:X8} 0x{1:X8}", (Data >> 32), (Data & 0xFFFFFFFF)); }
25 | }
26 |
27 | public ROMHandler.ROMHandler ROM { get; private set; }
28 | public bool InROM { get; private set; }
29 |
30 | public Generic(ROMHandler.ROMHandler rom, IHeaderParent parent, HeaderLoader.CommandTypeIDs cmdid)
31 | {
32 | ROM = rom;
33 | InROM = false;
34 | Command = cmdid;
35 | Offset = -1;
36 | Data = ulong.MaxValue;
37 | Parent = parent;
38 | }
39 |
40 | public Generic(Generic basecmd)
41 | {
42 | ROM = basecmd.ROM;
43 | InROM = basecmd.InROM;
44 | Command = basecmd.Command;
45 | Offset = basecmd.Offset;
46 | Data = basecmd.Data;
47 | Parent = basecmd.Parent;
48 | }
49 |
50 | public Generic(ROMHandler.ROMHandler rom, IHeaderParent parent, byte seg, ref int ofs)
51 | {
52 | ROM = rom;
53 | Command = (HeaderLoader.CommandTypeIDs)((byte[])rom.SegmentMapping[seg])[ofs];
54 | Offset = ofs;
55 | Data = Endian.SwapUInt64(BitConverter.ToUInt64(((byte[])rom.SegmentMapping[seg]), ofs));
56 | Parent = parent;
57 | ofs += 8;
58 |
59 | if (parent is HeaderCommands.Rooms.RoomInfoClass && (parent as HeaderCommands.Rooms.RoomInfoClass).Parent is SceneTableEntryOcarina)
60 | {
61 | ISceneTableEntry ste = ((parent as HeaderCommands.Rooms.RoomInfoClass).Parent as ISceneTableEntry);
62 | InROM = ste.IsInROM();
63 | }
64 | else if (parent is ISceneTableEntry)
65 | {
66 | InROM = (parent as ISceneTableEntry).IsInROM();
67 | }
68 | }
69 |
70 | public int GetCountGeneric()
71 | {
72 | return (int)((Data >> 48) & 0xFF);
73 | }
74 |
75 | public int GetAddressGeneric()
76 | {
77 | return (int)(Data & 0xFFFFFFFF);
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/SceneNavi/HeaderCommands/IPickableObject.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 |
7 | namespace SceneNavi.HeaderCommands
8 | {
9 | public enum PickableObjectRenderType
10 | {
11 | Normal, /* Standard */
12 | Selected, /* When selected */
13 | Picking, /* During picking */
14 | NoColor /* Color already specified */
15 | }
16 |
17 | public interface IPickableObject
18 | {
19 | Color PickColor { get; }
20 | bool IsMoveable { get; }
21 | OpenTK.Vector3d Position { get; set; }
22 | void Render(PickableObjectRenderType rendertype);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/SceneNavi/HeaderCommands/IStoreable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SceneNavi.HeaderCommands
7 | {
8 | interface IStoreable
9 | {
10 | void Store(byte[] databuf, int baseadr);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/SceneNavi/HeaderCommands/Objects.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SceneNavi.HeaderCommands
7 | {
8 | public class Objects : Generic, IStoreable
9 | {
10 | public List ObjectList { get; set; }
11 |
12 | public Objects(Generic basecmd)
13 | : base(basecmd)
14 | {
15 | ObjectList = new List();
16 | for (int i = 0; i < GetCountGeneric(); i++) ObjectList.Add(new Entry(ROM, (uint)(GetAddressGeneric() + i * 2)));
17 | }
18 |
19 | public void Store(byte[] databuf, int baseadr)
20 | {
21 | foreach (HeaderCommands.Objects.Entry obj in this.ObjectList)
22 | {
23 | byte[] objbytes = BitConverter.GetBytes(Endian.SwapUInt16(obj.Number));
24 | Buffer.BlockCopy(objbytes, 0, databuf, (int)(baseadr + (obj.Address & 0xFFFFFF)), objbytes.Length);
25 | }
26 | }
27 |
28 | public class Entry
29 | {
30 | public uint Address { get; set; }
31 | public ushort Number { get; set; }
32 | public string Name
33 | {
34 | get
35 | {
36 | return (Number < ROM.Objects.Count ? ROM.Objects[Number].Name : "(invalid?)");
37 | }
38 |
39 | set
40 | {
41 | if (value == null) return;
42 | int objidx = ROM.Objects.FindIndex(x => x.Name.ToLowerInvariant() == value.ToLowerInvariant());
43 | if (objidx != -1)
44 | Number = (ushort)objidx;
45 | else
46 | System.Media.SystemSounds.Hand.Play();
47 | }
48 | }
49 |
50 | ROMHandler.ROMHandler ROM;
51 |
52 | public Entry() { }
53 |
54 | public Entry(ROMHandler.ROMHandler rom, uint adr)
55 | {
56 | ROM = rom;
57 | Address = adr;
58 |
59 | byte[] segdata = (byte[])ROM.SegmentMapping[(byte)(adr >> 24)];
60 | if (segdata == null) return;
61 |
62 | Number = Endian.SwapUInt16(BitConverter.ToUInt16(segdata, (int)(adr & 0xFFFFFF)));
63 | }
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/SceneNavi/HeaderCommands/SettingsSoundScene.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ComponentModel;
6 |
7 | using SceneNavi.ROMHandler;
8 |
9 | namespace SceneNavi.HeaderCommands
10 | {
11 | public class SettingsSoundScene : Generic, IStoreable
12 | {
13 | // https://www.the-gcn.com/topic/2471-the-beginners-guide-to-music-antiqua-teasers/?p=40641
14 |
15 | //Just to complement this info, the yy above referred as "music playback" option stands for the scene's night bgm.
16 | //The night bgm uses a different audio type, that plays nature sounds.
17 | //A setting of 0x00 is found into scenes with the complete day-night cycle and will play the standard night noises.
18 | //The 0x13 setting is found in dungeons and indoors, so the music will be always playing, independent of the time of the day.
19 | //01 - Standard night [Kakariko]
20 | //02 - Distant storm [Graveyard]
21 | //03 - Howling wind and cawing [Ganon's Castle]
22 | //04 - Wind + night birds [Kokiri]
23 | //05, 08, 09, 0D, 0E, 10, 12 - Wind + crickets
24 | //06,0C - Wind
25 | //07 - Howling wind
26 | //0A - Tubed howling wind [Wasteland]
27 | //0B - Tubed howling wind [Colossus]
28 | //0F - Wind + birds
29 | //14, 16, 18, 19, 1B, 1E - silence
30 | //1C - Rain
31 | //17, 1A, 1D, 1F - high tubed wind + rain
32 |
33 | public byte Reverb { get; set; }
34 | public byte NightSfxID { get; set; }
35 | public byte TrackID { get; set; }
36 |
37 | public SettingsSoundScene(Generic basecmd)
38 | : base(basecmd)
39 | {
40 | Reverb = (byte)((this.Data >> 48) & 0xFF);
41 | NightSfxID = (byte)((this.Data >> 8) & 0xFF);
42 | TrackID = (byte)(this.Data & 0xFF);
43 | }
44 |
45 | public void Store(byte[] databuf, int baseadr)
46 | {
47 | databuf[(int)(baseadr + (this.Offset & 0xFFFFFF) + 1)] = Reverb;
48 | databuf[(int)(baseadr + (this.Offset & 0xFFFFFF) + 6)] = NightSfxID;
49 | databuf[(int)(baseadr + (this.Offset & 0xFFFFFF) + 7)] = TrackID;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/SceneNavi/HeaderCommands/SpecialObjects.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ComponentModel;
6 |
7 | using SceneNavi.ROMHandler;
8 |
9 | namespace SceneNavi.HeaderCommands
10 | {
11 | public class SpecialObjects : Generic, IStoreable
12 | {
13 | public class SpecialObjectTypes
14 | {
15 | public ushort ObjectNumber { get; private set; }
16 | public string Name { get; private set; }
17 |
18 | public SpecialObjectTypes(ushort number, string name)
19 | {
20 | ObjectNumber = number;
21 | Name = name;
22 | }
23 | }
24 |
25 | public static List Types = new List()
26 | {
27 | new SpecialObjectTypes(0x0002, "Field objects (0x02)"),
28 | new SpecialObjectTypes(0x0003, "Dungeon objects (0x03)")
29 | };
30 |
31 | public ushort SelectedSpecialObjects { get; set; }
32 |
33 | public SpecialObjects(Generic basecmd)
34 | : base(basecmd)
35 | {
36 | SelectedSpecialObjects = (ushort)(GetAddressGeneric() & 0xFFFF);
37 | }
38 |
39 | public void Store(byte[] databuf, int baseadr)
40 | {
41 | byte[] objbytes = BitConverter.GetBytes(Endian.SwapUInt16(this.SelectedSpecialObjects));
42 | Buffer.BlockCopy(objbytes, 0, databuf, (int)(baseadr + (this.Offset & 0xFFFFFF) + 6), objbytes.Length);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/SceneNavi/HeaderCommands/Waypoints.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ComponentModel;
6 |
7 | using OpenTK;
8 | using OpenTK.Graphics;
9 | using OpenTK.Graphics.OpenGL;
10 |
11 | using SceneNavi.OpenGLHelpers;
12 | using SceneNavi.ROMHandler;
13 |
14 | namespace SceneNavi.HeaderCommands
15 | {
16 | public class Waypoints : Generic, IStoreable
17 | {
18 | public List Paths { get; set; }
19 |
20 | public Waypoints(Generic basecmd)
21 | : base(basecmd)
22 | {
23 | Paths = new List();
24 |
25 | int i = 0;
26 | while (true)
27 | {
28 | PathHeader nph = new PathHeader(ROM, (uint)(GetAddressGeneric() + i * 8), i);
29 | if (nph.Points == null) break;
30 | Paths.Add(nph);
31 | i++;
32 | }
33 | }
34 |
35 | public void Store(byte[] databuf, int baseadr)
36 | {
37 | foreach (HeaderCommands.Waypoints.PathHeader path in this.Paths)
38 | {
39 | foreach (HeaderCommands.Waypoints.Waypoint wp in path.Points)
40 | {
41 | byte[] bytes = BitConverter.GetBytes(Endian.SwapInt16((short)wp.X));
42 | System.Buffer.BlockCopy(bytes, 0, databuf, (int)(baseadr + (wp.Address & 0xFFFFFF)), bytes.Length);
43 | bytes = BitConverter.GetBytes(Endian.SwapInt16((short)wp.Y));
44 | System.Buffer.BlockCopy(bytes, 0, databuf, (int)(baseadr + (wp.Address & 0xFFFFFF) + 2), bytes.Length);
45 | bytes = BitConverter.GetBytes(Endian.SwapInt16((short)wp.Z));
46 | System.Buffer.BlockCopy(bytes, 0, databuf, (int)(baseadr + (wp.Address & 0xFFFFFF) + 4), bytes.Length);
47 | }
48 | }
49 | }
50 |
51 | public class PathHeader
52 | {
53 | public uint Address { get; set; }
54 |
55 | public uint WaypointCount { get; private set; }
56 | public uint WaypointAddress { get; private set; }
57 |
58 | public List Points { get; private set; }
59 |
60 | public string Description
61 | {
62 | get
63 | {
64 | if (ROM == null)
65 | return "(None)";
66 | else
67 | return string.Format("Path #{0}: {1} waypoints", (PathNumber + 1), WaypointCount);
68 | }
69 | }
70 |
71 | int PathNumber;
72 |
73 | ROMHandler.ROMHandler ROM;
74 |
75 | public PathHeader() { }
76 |
77 | public PathHeader(ROMHandler.ROMHandler rom, uint adr, int number)
78 | {
79 | ROM = rom;
80 | Address = adr;
81 | PathNumber = number;
82 |
83 | byte[] segdata = (byte[])ROM.SegmentMapping[(byte)(adr >> 24)];
84 | if (segdata == null) return;
85 |
86 | WaypointCount = BitConverter.ToUInt32(segdata, (int)(adr & 0xFFFFFF));
87 | WaypointAddress = Endian.SwapUInt32(BitConverter.ToUInt32(segdata, (int)(adr & 0xFFFFFF) + 4));
88 |
89 | byte[] psegdata = (byte[])ROM.SegmentMapping[(byte)(WaypointAddress >> 24)];
90 | if (WaypointCount == 0 || WaypointCount > 0xFF || psegdata == null || (WaypointAddress & 0xFFFFFF) >= psegdata.Length) return;
91 |
92 | Points = new List();
93 | for (int i = 0; i < WaypointCount; i++)
94 | {
95 | Points.Add(new Waypoint(ROM, (uint)(WaypointAddress + (i * 6))));
96 | }
97 | }
98 | }
99 |
100 | public class Waypoint : IPickableObject
101 | {
102 | public uint Address { get; set; }
103 |
104 | [DisplayName("X position")]
105 | public double X { get; set; }
106 | [DisplayName("Y position")]
107 | public double Y { get; set; }
108 | [DisplayName("Z position")]
109 | public double Z { get; set; }
110 |
111 | [Browsable(false)]
112 | public Vector3d Position { get { return new Vector3d(X, Y, Z); } set { X = value.X; Y = value.Y; Z = value.Z; } }
113 |
114 | [Browsable(false)]
115 | public System.Drawing.Color PickColor { get { return System.Drawing.Color.FromArgb(this.GetHashCode() & 0xFFFFFF | (0xFF << 24)); } }
116 |
117 | [Browsable(false)]
118 | public bool IsMoveable { get { return true; } }
119 |
120 | ROMHandler.ROMHandler ROM;
121 |
122 | public Waypoint() { }
123 |
124 | public Waypoint(ROMHandler.ROMHandler rom, uint adr)
125 | {
126 | ROM = rom;
127 | Address = adr;
128 |
129 | byte[] segdata = (byte[])ROM.SegmentMapping[(byte)(adr >> 24)];
130 | if (segdata == null) return;
131 |
132 | X = (double)Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)(adr & 0xFFFFFF)));
133 | Y = (double)Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)(adr & 0xFFFFFF) + 2));
134 | Z = (double)Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)(adr & 0xFFFFFF) + 4));
135 | }
136 |
137 | public void Render(PickableObjectRenderType rendertype)
138 | {
139 | GL.PushAttrib(AttribMask.AllAttribBits);
140 |
141 | GL.PushMatrix();
142 | GL.Translate(X, Y, Z);
143 | GL.Scale(12.0, 12.0, 12.0);
144 |
145 | if (rendertype != PickableObjectRenderType.Picking)
146 | {
147 | GL.Color3(0.25, 0.5, 1.0);
148 | StockObjects.DownArrow.Render();
149 |
150 | if (rendertype == PickableObjectRenderType.Selected)
151 | {
152 | StockObjects.SimpleAxisMarker.Render();
153 | GL.Color3(1.0, 0.5, 0.0);
154 | }
155 | else
156 | GL.Color3(0.0, 0.0, 0.0);
157 |
158 | GL.LineWidth(4.0f);
159 | GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
160 | StockObjects.DownArrow.Render();
161 | }
162 | else
163 | {
164 | GL.Color3(PickColor);
165 | StockObjects.DownArrow.Render();
166 | }
167 |
168 | GL.PopMatrix();
169 | GL.PopAttrib();
170 | }
171 | }
172 | }
173 | }
174 |
--------------------------------------------------------------------------------
/SceneNavi/OpenGLHelpers/Camera.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 |
7 | using OpenTK;
8 | using OpenTK.Graphics;
9 | using OpenTK.Graphics.OpenGL;
10 |
11 | namespace SceneNavi.OpenGLHelpers
12 | {
13 | public class Camera
14 | {
15 | public double Sensitivity = 0.5;
16 | public double CameraCoeff = 0.05;
17 | public Vector3d Pos, Rot;
18 | public Vector2d MouseCoord, MouseCoordOld;
19 | public MouseButtons ButtonsDown;
20 |
21 | public Camera()
22 | {
23 | Reset();
24 | }
25 |
26 | public void Reset()
27 | {
28 | Pos = new Vector3d(0.0, 0.0, -15.0);
29 | Rot = new Vector3d(0.0, 0.0, 0.0);
30 | }
31 |
32 | public void MouseCenter(Vector2d NewMouseCoord)
33 | {
34 | MouseCoordOld = MouseCoord;
35 | MouseCoord = NewMouseCoord;
36 | }
37 |
38 | public void MouseMove(Vector2d NewMouseCoord)
39 | {
40 | bool Changed = false;
41 | double Dx = 0.0, Dy = 0.0;
42 |
43 | if (NewMouseCoord.X != MouseCoord.X)
44 | {
45 | Dx = (NewMouseCoord.X - MouseCoord.X) * Sensitivity;
46 | Changed = true;
47 | }
48 | if (NewMouseCoord.Y != MouseCoord.Y)
49 | {
50 | Dy = (NewMouseCoord.Y - MouseCoord.Y) * Sensitivity;
51 | Changed = true;
52 | }
53 |
54 | if (Changed)
55 | {
56 | if (MouseCoord.X < NewMouseCoord.X)
57 | {
58 | Rot.Y += (NewMouseCoord.X - MouseCoord.X) * 0.225;
59 | if (Rot.Y > 360.0) Rot.Y = 0.0;
60 | }
61 | else
62 | {
63 | Rot.Y -= (MouseCoord.X - NewMouseCoord.X) * 0.225;
64 | if (Rot.Y < -360.0) Rot.Y = 0.0;
65 | }
66 |
67 | if (MouseCoord.Y < NewMouseCoord.Y)
68 | {
69 | if (Rot.X >= 90.0)
70 | Rot.X = 90.0;
71 | else
72 | Rot.X += (Dy / Sensitivity) * 0.225;
73 | }
74 | else
75 | {
76 | if (Rot.X <= -90.0)
77 | Rot.X = -90.0;
78 | else
79 | Rot.X += (Dy / Sensitivity) * 0.225;
80 | }
81 |
82 | MouseCoordOld = MouseCoord;
83 | MouseCoord = NewMouseCoord;
84 | }
85 | }
86 |
87 | public void KeyUpdate(bool[] KeysDown)
88 | {
89 | double RotYRad = (Rot.Y / 180.0 * Math.PI);
90 | double RotXRad = (Rot.X / 180.0 * Math.PI);
91 |
92 | double Modifier = 2.0;
93 | if (KeysDown[(char)Keys.Space]) Modifier = 10.0;
94 | else if (KeysDown[(char)Keys.ShiftKey]) Modifier = 0.5;
95 |
96 | if (KeysDown[(char)Keys.W])
97 | {
98 | if (Rot.X >= 90.0 || Rot.X <= -90.0)
99 | {
100 | Pos.Y += Math.Sin(RotXRad) * CameraCoeff * 2.0 * Modifier;
101 | }
102 | else
103 | {
104 | Pos.X -= Math.Sin(RotYRad) * CameraCoeff * 2.0 * Modifier;
105 | Pos.Z += Math.Cos(RotYRad) * CameraCoeff * 2.0 * Modifier;
106 | Pos.Y += Math.Sin(RotXRad) * CameraCoeff * 2.0 * Modifier;
107 | }
108 | }
109 |
110 | if (KeysDown[(char)Keys.S])
111 | {
112 | if (Rot.X >= 90.0 || Rot.X <= -90.0)
113 | {
114 | Pos.Y -= Math.Sin(RotXRad) * CameraCoeff * 2.0 * Modifier;
115 | }
116 | else
117 | {
118 | Pos.X += Math.Sin(RotYRad) * CameraCoeff * 2.0 * Modifier;
119 | Pos.Z -= Math.Cos(RotYRad) * CameraCoeff * 2.0 * Modifier;
120 | Pos.Y -= Math.Sin(RotXRad) * CameraCoeff * 2.0 * Modifier;
121 | }
122 | }
123 |
124 | if (KeysDown[(char)Keys.A])
125 | {
126 | Pos.X += Math.Cos(RotYRad) * CameraCoeff * 2.0 * Modifier;
127 | Pos.Z += Math.Sin(RotYRad) * CameraCoeff * 2.0 * Modifier;
128 | }
129 |
130 | if (KeysDown[(char)Keys.D])
131 | {
132 | Pos.X -= Math.Cos(RotYRad) * CameraCoeff * 2.0 * Modifier;
133 | Pos.Z -= Math.Sin(RotYRad) * CameraCoeff * 2.0 * Modifier;
134 | }
135 | }
136 |
137 | public void Position()
138 | {
139 | GL.Rotate(Rot.X, 1.0, 0.0, 0.0);
140 | GL.Rotate(Rot.Y, 0.0, 1.0, 0.0);
141 | GL.Rotate(Rot.Z, 0.0, 0.0, 1.0);
142 | GL.Translate(Pos);
143 | }
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/SceneNavi/OpenGLHelpers/DisplayList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | using OpenTK;
7 | using OpenTK.Graphics;
8 | using OpenTK.Graphics.OpenGL;
9 |
10 | namespace SceneNavi.OpenGLHelpers
11 | {
12 | public class DisplayList : IDisposable
13 | {
14 | public class DisplayListException : Exception
15 | {
16 | public DisplayListException(string errorMessage) : base(errorMessage) { }
17 | public DisplayListException(string errorMessage, Exception innerEx) : base(errorMessage, innerEx) { }
18 | }
19 |
20 | int glid;
21 |
22 | public DisplayList()
23 | {
24 | Generate();
25 | }
26 |
27 | public DisplayList(ListMode listmode)
28 | {
29 | Generate();
30 | New(listmode);
31 | }
32 |
33 | public void Generate()
34 | {
35 | glid = GL.GenLists(1);
36 | }
37 |
38 | public void New(ListMode listmode)
39 | {
40 | if (!GL.IsList(glid)) Generate();
41 |
42 | GL.NewList(glid, listmode);
43 | }
44 |
45 | public void End()
46 | {
47 | GL.EndList();
48 | }
49 |
50 | public void Render()
51 | {
52 | if (!GL.IsList(glid)) throw new DisplayListException("Cannot render display list; no list generated");
53 |
54 | GL.CallList(glid);
55 | }
56 |
57 | public void Dispose()
58 | {
59 | if (GL.IsList(glid)) GL.DeleteLists(glid, 1);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/SceneNavi/OpenGLHelpers/DisplayListEx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ComponentModel;
6 |
7 | using OpenTK;
8 | using OpenTK.Graphics;
9 | using OpenTK.Graphics.OpenGL;
10 |
11 | namespace SceneNavi.OpenGLHelpers
12 | {
13 | public class DisplayListEx : DisplayList
14 | {
15 | internal class Triangle : HeaderCommands.IPickableObject
16 | {
17 | [Browsable(false)]
18 | public Vector3d Position { get { return Vector3d.Zero; } set { } }
19 |
20 | [Browsable(false)]
21 | public System.Drawing.Color PickColor { get { return System.Drawing.Color.FromArgb(this.GetHashCode() & 0xFFFFFF | (0xFF << 24)); } }
22 |
23 | [Browsable(false)]
24 | public bool IsMoveable { get { return false; } }
25 |
26 | public List Vertices { get; private set; }
27 | public SimpleF3DEX2.Vertex SelectedVertex { get; set; }
28 |
29 | public Triangle(params SimpleF3DEX2.Vertex[] verts)
30 | {
31 | Vertices = new List();
32 | Vertices.AddRange(verts);
33 | }
34 |
35 | public void Render(HeaderCommands.PickableObjectRenderType rendertype)
36 | {
37 | if (rendertype == HeaderCommands.PickableObjectRenderType.Picking)
38 | {
39 | GL.Color3(PickColor);
40 | GL.Begin(PrimitiveType.Triangles);
41 | foreach (SimpleF3DEX2.Vertex v in Vertices) GL.Vertex3(v.Position);
42 | GL.End();
43 | }
44 | else if (rendertype == HeaderCommands.PickableObjectRenderType.Normal)
45 | {
46 | GL.PushAttrib(AttribMask.AllAttribBits);
47 | GL.Disable(EnableCap.Texture2D);
48 | GL.Disable(EnableCap.Lighting);
49 | if (Initialization.SupportsFunction("glGenProgramsARB")) GL.Disable((EnableCap)All.FragmentProgram);
50 | if (Initialization.SupportsFunction("glCreateShader")) GL.UseProgram(0);
51 | GL.Disable(EnableCap.CullFace);
52 | GL.Enable(EnableCap.Blend);
53 | GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
54 | GL.DepthRange(0.0, 0.99995);
55 |
56 | /* White poly */
57 | GL.Color4(1.0, 1.0, 1.0, 0.25);
58 | GL.Begin(PrimitiveType.Triangles);
59 | foreach (SimpleF3DEX2.Vertex v in Vertices) GL.Vertex3(v.Position);
60 | GL.End();
61 | /* Black outlines */
62 | GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
63 | GL.LineWidth(2.0f);
64 | GL.Color4(Color4.Black);
65 | GL.Begin(PrimitiveType.Triangles);
66 | foreach (SimpleF3DEX2.Vertex v in Vertices) GL.Vertex3(v.Position);
67 | GL.End();
68 | /* Vertex points */
69 | GL.DepthRange(0.0, 0.999);
70 | GL.PointSize(25.0f);
71 | GL.Begin(PrimitiveType.Points);
72 | foreach (SimpleF3DEX2.Vertex v in Vertices)
73 | {
74 | if (SelectedVertex == v) GL.Color4(Color4.LimeGreen);
75 | else GL.Color4(Color4.Red);
76 |
77 | GL.Vertex3(v.Position);
78 | }
79 | GL.End();
80 |
81 | GL.PopAttrib();
82 | }
83 | }
84 | }
85 |
86 | internal List Triangles { get; private set; }
87 |
88 | public DisplayListEx()
89 | : base()
90 | {
91 | Triangles = new List();
92 | }
93 |
94 | public DisplayListEx(ListMode listmode)
95 | : base(listmode)
96 | {
97 | Triangles = new List();
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/SceneNavi/OpenGLHelpers/FPSMonitor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Diagnostics;
6 |
7 | namespace SceneNavi.OpenGLHelpers
8 | {
9 | // Adapted from http://www.daniweb.com/software-development/csharp/code/408351/xna-framework-get-frames-per-second#post1743620
10 | ///
11 | /// Stopwatch-based FPS counter
12 | ///
13 | public class FPSMonitor
14 | {
15 | public float Value { get; private set; }
16 | public TimeSpan Sample { get; set; }
17 |
18 | Stopwatch sw;
19 | int frames;
20 |
21 | public FPSMonitor()
22 | {
23 | Sample = TimeSpan.FromSeconds(1);
24 | Value = 0;
25 | frames = 0;
26 | sw = Stopwatch.StartNew();
27 | }
28 |
29 | public void Update()
30 | {
31 | frames++;
32 |
33 | if (sw.Elapsed > Sample)
34 | {
35 | Value = (float)(frames / sw.Elapsed.TotalSeconds);
36 |
37 | sw.Reset();
38 | sw.Start();
39 | frames = 0;
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/SceneNavi/OpenGLHelpers/Initialization.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 |
7 | using OpenTK;
8 | using OpenTK.Graphics;
9 | using OpenTK.Graphics.OpenGL;
10 |
11 | namespace SceneNavi.OpenGLHelpers
12 | {
13 | static class Initialization
14 | {
15 | public enum ProjectionTypes { Perspective, Orthographic };
16 |
17 | public static string RendererString
18 | {
19 | get { return GL.GetString(StringName.Renderer) ?? "[null]"; }
20 | }
21 |
22 | public static string VendorString
23 | {
24 | get { return GL.GetString(StringName.Vendor) ?? "[null]"; }
25 | }
26 |
27 | public static string VersionString
28 | {
29 | get { return GL.GetString(StringName.Version) ?? "[null]"; }
30 | }
31 |
32 | public static string ShadingLanguageVersionString
33 | {
34 | get
35 | {
36 | string str = GL.GetString(StringName.ShadingLanguageVersion);
37 | if (str == null || str == string.Empty) return "[unsupported]";
38 | else return str;
39 | }
40 | }
41 |
42 | public static string[] SupportedExtensions
43 | {
44 | get { return GL.GetString(StringName.Extensions).Split(new char[] { ' ' }) ?? new string[] { "[null]" }; }
45 | }
46 |
47 | public static bool VendorIsIntel
48 | {
49 | get { return VendorString.Contains("Intel"); }
50 | }
51 |
52 | public static bool SupportsFunction(string function)
53 | {
54 | return ((GraphicsContext.CurrentContext as IGraphicsContextInternal).GetAddress(function) != IntPtr.Zero);
55 | }
56 |
57 | public static void ActiveTextureChecked(TextureUnit unit)
58 | {
59 | if (SupportsFunction("glActiveTextureARB")) GL.Arb.ActiveTexture(unit);
60 | }
61 |
62 | public static void MultiTexCoord2Checked(TextureUnit unit, double s, double t)
63 | {
64 | if (SupportsFunction("glMultiTexCoord2dARB"))
65 | GL.Arb.MultiTexCoord2(unit, s, t);
66 | else
67 | GL.TexCoord2(s, t);
68 | }
69 |
70 | public static int GetInteger(GetPName name)
71 | {
72 | int outval;
73 | GL.GetInteger(name, out outval);
74 | return outval;
75 | }
76 |
77 | public static int MaxTextureUnits { get { int outval; GL.GetInteger(GetPName.MaxTextureUnits, out outval); return outval; } }
78 |
79 | public static List CheckForExtensions(string[] NeededExts)
80 | {
81 | List missing = new List();
82 | if (NeededExts != null) missing.AddRange(NeededExts.Where(x => !CheckForExtension(x)));
83 | return missing;
84 | }
85 |
86 | public static bool CheckForExtension(string NeededExt)
87 | {
88 | return SupportedExtensions.Contains(NeededExt);
89 | }
90 |
91 | public static void SetDefaults()
92 | {
93 | GL.ShadeModel(ShadingModel.Smooth);
94 | GL.Enable(EnableCap.PointSmooth);
95 | GL.Hint(HintTarget.PointSmoothHint, HintMode.Nicest);
96 |
97 | GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
98 |
99 | GL.ClearColor(System.Drawing.Color.LightBlue);
100 | GL.ClearDepth(5.0);
101 |
102 | GL.DepthFunc(DepthFunction.Lequal);
103 | GL.Enable(EnableCap.DepthTest);
104 | GL.DepthMask(true);
105 |
106 | GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
107 |
108 | GL.Light(LightName.Light0, LightParameter.Ambient, new float[] { 1.0f, 1.0f, 1.0f, 1.0f });
109 | GL.Light(LightName.Light0, LightParameter.Diffuse, new float[] { 1.0f, 1.0f, 1.0f, 1.0f });
110 | GL.Light(LightName.Light0, LightParameter.Specular, new float[] { 1.0f, 1.0f, 1.0f, 1.0f });
111 | GL.Light(LightName.Light0, LightParameter.Position, new float[] { 1.0f, 1.0f, 1.0f, 1.0f });
112 | GL.Enable(EnableCap.Light0);
113 |
114 | GL.Enable(EnableCap.Lighting);
115 | GL.Enable(EnableCap.Normalize);
116 |
117 | GL.Enable(EnableCap.CullFace);
118 | GL.CullFace(CullFaceMode.Back);
119 |
120 | GL.Enable(EnableCap.Blend);
121 | GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
122 | }
123 |
124 | public static void CreateViewportAndProjection(ProjectionTypes projectionType, Rectangle clientRectangle, float near, float far)
125 | {
126 | if (clientRectangle.Width <= 0 || clientRectangle.Height <= 0) return;
127 |
128 | GL.Viewport(0, 0, clientRectangle.Width, clientRectangle.Height);
129 |
130 | Matrix4 projectionMatrix = Matrix4.Identity;
131 |
132 | switch (projectionType)
133 | {
134 | case ProjectionTypes.Perspective:
135 | double aspect = clientRectangle.Width / (double)clientRectangle.Height;
136 | projectionMatrix = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver3, (float)aspect, near, far);
137 | break;
138 |
139 | case ProjectionTypes.Orthographic:
140 | projectionMatrix = Matrix4.CreateOrthographicOffCenter(clientRectangle.Left, clientRectangle.Right, clientRectangle.Bottom, clientRectangle.Top, near, far);
141 | break;
142 | }
143 |
144 | GL.MatrixMode(MatrixMode.Projection);
145 | GL.LoadIdentity();
146 | GL.MultMatrix(ref projectionMatrix);
147 |
148 | GL.MatrixMode(MatrixMode.Modelview);
149 | GL.LoadIdentity();
150 | }
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/SceneNavi/OpenGLHelpers/ScreenWorldConversion.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Drawing;
6 |
7 | using OpenTK;
8 | using OpenTK.Graphics;
9 | using OpenTK.Graphics.OpenGL;
10 |
11 | namespace SceneNavi.OpenGLHelpers
12 | {
13 | class ScreenWorldConversion
14 | {
15 | public static Vector3d WorldToScreen(Vector3d pos)
16 | {
17 | int[] viewport = new int[4];
18 | Matrix4d modelViewMatrix, projectionMatrix;
19 |
20 | GL.GetInteger(GetPName.Viewport, viewport);
21 | GL.GetDouble(GetPName.ModelviewMatrix, out modelViewMatrix);
22 | GL.GetDouble(GetPName.ProjectionMatrix, out projectionMatrix);
23 |
24 | return WorldToScreen(pos, modelViewMatrix, projectionMatrix, viewport);
25 | }
26 |
27 | public static Vector3d WorldToScreen(Vector3d pos, Matrix4d modelviewMatrix, Matrix4d projectionMatrix, int[] viewport)
28 | {
29 | Vector3d point;
30 | Project(ref pos, ref modelviewMatrix, ref projectionMatrix, viewport, out point);
31 | point.Y = (float)viewport[3] - point.Y;
32 |
33 | return point;
34 | }
35 |
36 | public static Vector3d ScreenToWorld(Vector2d pos)
37 | {
38 | int[] viewport = new int[4];
39 | Matrix4d modelViewMatrix, projectionMatrix;
40 |
41 | GL.GetInteger(GetPName.Viewport, viewport);
42 | GL.GetDouble(GetPName.ModelviewMatrix, out modelViewMatrix);
43 | GL.GetDouble(GetPName.ProjectionMatrix, out projectionMatrix);
44 |
45 | return ScreenToWorld(pos, modelViewMatrix, projectionMatrix, viewport);
46 | }
47 |
48 | public static Vector3d ScreenToWorld(Vector2d pos, Matrix4d modelviewMatrix, Matrix4d projectionMatrix, int[] viewport)
49 | {
50 | Vector3d win = Vector3d.Zero;
51 | win.X = pos.X;
52 | win.Y = (viewport[3] - pos.Y);
53 |
54 | double zz = WorldToScreen(Vector3d.Zero, modelviewMatrix, projectionMatrix, viewport).Z;
55 |
56 | float[] boxedZ = new float[1];
57 | GL.ReadPixels((int)pos.X, viewport[3] - (int)pos.Y, 1, 1, PixelFormat.DepthComponent, PixelType.Float, boxedZ);
58 | win.Z = boxedZ[0];
59 | win.Z = zz;
60 |
61 | System.Diagnostics.Debug.Print("{0}, {1}", win.Z, zz);
62 |
63 | return UnProject(win, modelviewMatrix, projectionMatrix, viewport);
64 | }
65 |
66 | private static Vector3d UnProject(Vector3d screen, Matrix4d modelviewMatrix, Matrix4d projectionMatrix, int[] viewport)
67 | {
68 | Vector4d pos = Vector4d.Zero;
69 | pos.X = ((screen.X - (double)viewport[0]) / (double)viewport[2]) * 2.0 - 1.0;
70 | pos.Y = ((screen.Y - (double)viewport[1]) / (double)viewport[3]) * 2.0 - 1.0;
71 | pos.Z = (2.0 * screen.Z) - 1.0;
72 | pos.W = 1.0;
73 |
74 | Vector4d pos2 = Vector4d.Transform(pos, Matrix4d.Invert(Matrix4d.Mult(modelviewMatrix, projectionMatrix)));
75 | return new Vector3d(pos2.X, pos2.Y, pos2.Z) / pos2.W;
76 | }
77 |
78 | private static bool Project(ref Vector3d world, ref Matrix4d modelviewMatrix, ref Matrix4d projectionMatrix, int[] viewport, out Vector3d screen)
79 | {
80 | Vector4d _in = new Vector4d(world, 1.0);
81 | Vector4d _out = new Vector4d();
82 |
83 | Vector4d.Transform(ref _in, ref modelviewMatrix, out _out);
84 | Vector4d.Transform(ref _out, ref projectionMatrix, out _in);
85 |
86 | if (_in.W == 0.0)
87 | {
88 | screen = Vector3d.Zero;
89 | return false;
90 | }
91 |
92 | _in.X /= _in.W;
93 | _in.Y /= _in.W;
94 | _in.Z /= _in.W;
95 |
96 | /* Map x, y and z to range 0-1 */
97 | _in.X = _in.X * 0.5 + 0.5;
98 | _in.Y = _in.Y * 0.5 + 0.5;
99 | _in.Z = _in.Z * 0.5 + 0.5;
100 |
101 | /* Map x,y to viewport */
102 | _in.X = _in.X * viewport[2] + viewport[0];
103 | _in.Y = _in.Y * viewport[3] + viewport[1];
104 |
105 | screen = new Vector3d(_in);
106 | return true;
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/SceneNavi/OpenGLHelpers/StockObjects.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | using OpenTK;
7 | using OpenTK.Graphics;
8 | using OpenTK.Graphics.OpenGL;
9 |
10 | namespace SceneNavi.OpenGLHelpers
11 | {
12 | static class StockObjects
13 | {
14 | public static DisplayList AxisMarker { get; private set; }
15 | public static DisplayList SimpleAxisMarker { get; private set; }
16 |
17 | public static DisplayList Cube { get; private set; }
18 | public static DisplayList ColoredCube { get; private set; }
19 | public static DisplayList Sphere { get; private set; }
20 | public static DisplayList DownArrow { get; private set; }
21 |
22 | public static DisplayList Slab { get; private set; }
23 | public static DisplayList ColoredSlab { get; private set; }
24 |
25 | public static DisplayList Door { get; private set; }
26 | public static DisplayList ColoredDoor { get; private set; }
27 |
28 | static StockObjects()
29 | {
30 | /* Axis marker */
31 | AxisMarker = new DisplayList(ListMode.Compile);
32 | GL.LineWidth(4.0f);
33 | GL.DepthRange(0.0, 0.99999);
34 |
35 | double radius = 12.0;
36 | GL.LineWidth(4.0f);
37 | GL.Begin(PrimitiveType.Lines);
38 | GL.Color3(1.0, 0.0, 0.0);
39 | GL.Vertex3(radius, 0.0, 0.0);
40 | GL.Vertex3(-radius, 0.0, 0.0);
41 | GL.Color3(0.0, 1.0, 0.0);
42 | GL.Vertex3(0.0, radius, 0.0);
43 | GL.Vertex3(0.0, -radius, 0.0);
44 | GL.End();
45 |
46 | GL.PushMatrix();
47 | GL.Rotate(90.0, 1.0, 0.0, 0.0);
48 | GL.Color3(0.0, 0.0, 1.0);
49 | MiscDrawingHelpers.RenderNotchCircle(radius / 2.0, 48);
50 | GL.PopMatrix();
51 |
52 | GL.DepthRange(0.0, 1.0);
53 | GL.LineWidth(1.0f);
54 | AxisMarker.End();
55 |
56 | /* Simple axis marker */
57 | SimpleAxisMarker = new DisplayList(ListMode.Compile);
58 | GL.LineWidth(4.0f);
59 | GL.DepthRange(0.0, 0.99999);
60 |
61 | GL.LineWidth(4.0f);
62 | GL.Begin(PrimitiveType.Lines);
63 | GL.Color3(1.0, 0.0, 0.0);
64 | GL.Vertex3(radius, 0.0, 0.0);
65 | GL.Vertex3(-radius, 0.0, 0.0);
66 | GL.Color3(0.0, 1.0, 0.0);
67 | GL.Vertex3(0.0, radius, 0.0);
68 | GL.Vertex3(0.0, -radius, 0.0);
69 | GL.Color3(0.0, 0.0, 1.0);
70 | GL.Vertex3(0.0, 0.0, radius);
71 | GL.Vertex3(0.0, 0.0, -radius);
72 | GL.End();
73 |
74 | GL.DepthRange(0.0, 1.0);
75 | GL.LineWidth(1.0f);
76 | SimpleAxisMarker.End();
77 |
78 | /* Simple cube */
79 | Cube = new DisplayList(ListMode.Compile);
80 | MiscDrawingHelpers.RenderCube(false);
81 | Cube.End();
82 |
83 | /* Colored cube */
84 | ColoredCube = new DisplayList(ListMode.Compile);
85 | MiscDrawingHelpers.RenderCube(true);
86 | ColoredCube.End();
87 |
88 | /* Sphere */
89 | Sphere = new DisplayList(ListMode.Compile);
90 | MiscDrawingHelpers.RenderSphere(Vector3d.Zero, 3.0, 12);
91 | Sphere.End();
92 |
93 | /* Down arrow */
94 | DownArrow = new DisplayList(ListMode.Compile);
95 | // Top
96 | GL.Begin(PrimitiveType.Quads);
97 | GL.Vertex3(1.0, 2.0, -1.0);
98 | GL.Vertex3(-1.0, 2.0, -1.0);
99 | GL.Vertex3(-1.0, 2.0, 1.0);
100 | GL.Vertex3(1.0, 2.0, 1.0);
101 | GL.End();
102 |
103 | GL.Begin(PrimitiveType.Triangles);
104 | // Left
105 | GL.Vertex3(-1.0, 2.0, 1.0);
106 | GL.Vertex3(-1.0, 2.0, -1.0);
107 | GL.Vertex3(0.0, 0.0, 0.0);
108 | // Right
109 | GL.Vertex3(1.0, 2.0, -1.0);
110 | GL.Vertex3(1.0, 2.0, 1.0);
111 | GL.Vertex3(0.0, 0.0, 0.0);
112 | // Front
113 | GL.Vertex3(1.0, 2.0, 1.0);
114 | GL.Vertex3(-1.0, 2.0, 1.0);
115 | GL.Vertex3(0.0, 0.0, 0.0);
116 | // Back
117 | GL.Vertex3(0.0, 0.0, 0.0);
118 | GL.Vertex3(-1.0, 2.0, -1.0);
119 | GL.Vertex3(1.0, 2.0, -1.0);
120 | GL.End();
121 | DownArrow.End();
122 |
123 | /* Simple slab (ex. boxes, chests) */
124 | Slab = new DisplayList(ListMode.Compile);
125 | MiscDrawingHelpers.RenderCube(new Vector3d(3.0, 2.0, 2.0), false);
126 | Slab.End();
127 |
128 | /* Colored slab */
129 | ColoredSlab = new DisplayList(ListMode.Compile);
130 | MiscDrawingHelpers.RenderCube(new Vector3d(3.0, 2.0, 2.0), true);
131 | ColoredSlab.End();
132 |
133 | /* Door */
134 | Door = new DisplayList(ListMode.Compile);
135 | MiscDrawingHelpers.RenderCube(new Vector3d(2.5, 4.5, 0.5), new Vector3d(0.0, 4.0, 0.0), false);
136 | Door.End();
137 |
138 | /* Colored door */
139 | ColoredDoor = new DisplayList(ListMode.Compile);
140 | MiscDrawingHelpers.RenderCube(new Vector3d(2.5, 4.5, 0.5), new Vector3d(0.0, 4.0, 0.0), true);
141 | ColoredDoor.End();
142 | }
143 |
144 | public static DisplayList GetDisplayList(string prop)
145 | {
146 | Type tp = typeof(StockObjects);
147 | System.Reflection.PropertyInfo propinfo = tp.GetProperty(prop, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
148 | if (propinfo == null) return null;
149 | return (propinfo.GetValue(null, null) as DisplayList);
150 | }
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/SceneNavi/OpenTK.dll.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/SceneNavi/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 | using System.Threading;
6 |
7 | namespace SceneNavi
8 | {
9 | static class Program
10 | {
11 | public static string AppNameVer = Application.ProductName + " " + VersionManagement.CreateVersionString(Application.ProductVersion);
12 |
13 | public static StatusMessageHandler Status = new StatusMessageHandler();
14 | public static bool IsHinting = false;
15 |
16 | /* Mutex & general app restart stuff from http://stackoverflow.com/a/9056664 */
17 |
18 | [STAThread]
19 | static void Main()
20 | {
21 | Mutex runOnce = null;
22 |
23 | if (Configuration.IsRestarting)
24 | {
25 | Configuration.IsRestarting = false;
26 | Thread.Sleep(3000);
27 | }
28 | #if !DEBUG
29 | try
30 | {
31 | #endif
32 | runOnce = new Mutex(true, "SOME_MUTEX_NAME");
33 |
34 | if (runOnce.WaitOne(TimeSpan.Zero))
35 | {
36 | Application.EnableVisualStyles();
37 | Application.SetCompatibleTextRenderingDefault(false);
38 | Application.Run(new MainForm());
39 | }
40 | #if !DEBUG
41 | }
42 | catch (Exception ex)
43 | {
44 | MessageBox.Show("Critical error occured: " + ex.GetType().FullName + " - " + ex.Message + "\nTarget site: " + ex.TargetSite, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
45 | }
46 | finally
47 | {
48 | if (null != runOnce)
49 | runOnce.Close();
50 | }
51 | #endif
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/SceneNavi/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // Allgemeine Informationen über eine Assembly werden über die folgenden
6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
7 | // die mit einer Assembly verknüpft sind.
8 | [assembly: AssemblyTitle("SceneNavi")]
9 | [assembly: AssemblyDescription("Scene/room actor editor for Zelda: Ocarina of Time")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("SceneNavi")]
13 | [assembly: AssemblyCopyright("Written 2013-2021 by xdaniel")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
19 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
20 | [assembly: ComVisible(false)]
21 |
22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
23 | [assembly: Guid("0275bdd3-cdad-4292-9a5b-b890958cde01")]
24 |
25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
26 | //
27 | // Hauptversion
28 | // Nebenversion
29 | // Buildnummer
30 | // Revision
31 | //
32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
33 | // übernehmen, indem Sie "*" eingeben:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.1.2816")]
36 | [assembly: AssemblyFileVersion("1.0.1.2816")]
37 |
--------------------------------------------------------------------------------
/SceneNavi/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Dieser Code wurde von einem Tool generiert.
4 | // Laufzeitversion:4.0.30319.42000
5 | //
6 | // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
7 | // der Code erneut generiert wird.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace SceneNavi.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
17 | ///
18 | // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
19 | // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
20 | // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
21 | // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SceneNavi.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
51 | /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
65 | ///
66 | internal static System.Drawing.Bitmap BgEmpty_Large {
67 | get {
68 | object obj = ResourceManager.GetObject("BgEmpty_Large", resourceCulture);
69 | return ((System.Drawing.Bitmap)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
75 | ///
76 | internal static System.Drawing.Bitmap BgEmpty_Small {
77 | get {
78 | object obj = ResourceManager.GetObject("BgEmpty_Small", resourceCulture);
79 | return ((System.Drawing.Bitmap)(obj));
80 | }
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/SceneNavi/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
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 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\BgEmpty_Large.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
125 | ..\Resources\BgEmpty_Small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
126 |
127 |
--------------------------------------------------------------------------------
/SceneNavi/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Dieser Code wurde von einem Tool generiert.
4 | // Laufzeitversion:4.0.30319.42000
5 | //
6 | // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
7 | // der Code erneut generiert wird.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace SceneNavi.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/SceneNavi/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SceneNavi/ROMHandler/ActorTableEntry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SceneNavi.ROMHandler
7 | {
8 | public class ActorTableEntry
9 | {
10 | public int Offset { get; private set; }
11 | public bool IsOffsetRelative { get; private set; }
12 |
13 | public uint StartAddress { get; private set; }
14 | public uint EndAddress { get; private set; }
15 | public uint RAMStartAddress { get; private set; }
16 | public uint RAMEndAddress { get; private set; }
17 | public uint Unknown1 { get; private set; }
18 | public uint ActorInfoRAMAddress { get; private set; }
19 | public uint ActorNameRAMAddress { get; private set; }
20 | public uint Unknown2 { get; private set; }
21 |
22 | public bool IsValid { get; private set; }
23 | public bool IsIncomplete { get; private set; }
24 | public bool IsComplete { get; private set; }
25 | public bool IsEmpty { get; private set; }
26 |
27 | public ushort ActorNumber { get; private set; }
28 | public byte ActorType { get; private set; }
29 | public ushort ObjectNumber { get; private set; }
30 |
31 | public string Name { get; private set; }
32 | public string Filename { get; private set; }
33 |
34 | ROMHandler ROM;
35 |
36 | public ActorTableEntry(ROMHandler rom, int ofs, bool isrel)
37 | {
38 | ROM = rom;
39 | Offset = ofs;
40 | IsOffsetRelative = isrel;
41 |
42 | StartAddress = Endian.SwapUInt32(BitConverter.ToUInt32(IsOffsetRelative ? rom.CodeData : rom.Data, ofs));
43 | EndAddress = Endian.SwapUInt32(BitConverter.ToUInt32(IsOffsetRelative ? rom.CodeData : rom.Data, ofs + 4));
44 | RAMStartAddress = Endian.SwapUInt32(BitConverter.ToUInt32(IsOffsetRelative ? rom.CodeData : rom.Data, ofs + 8));
45 | RAMEndAddress = Endian.SwapUInt32(BitConverter.ToUInt32(IsOffsetRelative ? rom.CodeData : rom.Data, ofs + 12));
46 | Unknown1 = Endian.SwapUInt32(BitConverter.ToUInt32(IsOffsetRelative ? rom.CodeData : rom.Data, ofs + 16));
47 | ActorInfoRAMAddress = Endian.SwapUInt32(BitConverter.ToUInt32(IsOffsetRelative ? rom.CodeData : rom.Data, ofs + 20));
48 | ActorNameRAMAddress = Endian.SwapUInt32(BitConverter.ToUInt32(IsOffsetRelative ? rom.CodeData : rom.Data, ofs + 24));
49 | Unknown2 = Endian.SwapUInt32(BitConverter.ToUInt32(IsOffsetRelative ? rom.CodeData : rom.Data, ofs + 28));
50 |
51 | IsValid =
52 | (ActorInfoRAMAddress >> 24 == 0x80) &&
53 | (((ActorNameRAMAddress >> 24 == 0x80) && (ActorNameRAMAddress - ROMHandler.CodeRAMAddress) < rom.CodeData.Length) || (ActorNameRAMAddress == 0));
54 |
55 | IsIncomplete = (StartAddress == 0 && EndAddress == 0 && RAMStartAddress == 0 && RAMEndAddress == 0);
56 |
57 | IsComplete =
58 | (StartAddress > rom.Code.VStart && StartAddress < rom.Size) &&
59 | (EndAddress > StartAddress && EndAddress > rom.Code.VStart && EndAddress < rom.Size) &&
60 | (RAMStartAddress >> 24 == 0x80) &&
61 | (RAMEndAddress > RAMStartAddress && RAMEndAddress >> 24 == 0x80) &&
62 | (ActorInfoRAMAddress >> 24 == 0x80) &&
63 | (((ActorNameRAMAddress >> 24 == 0x80) && (ActorNameRAMAddress - ROMHandler.CodeRAMAddress) < rom.CodeData.Length) || (ActorNameRAMAddress == 0));
64 |
65 | IsEmpty = (StartAddress == 0 && EndAddress == 0 && RAMStartAddress == 0 && RAMEndAddress == 0 && Unknown1 == 0 && ActorInfoRAMAddress == 0 && ActorNameRAMAddress == 0 && Unknown2 == 0);
66 |
67 | Name = Filename = "N/A";
68 |
69 | if (IsValid == true && IsEmpty == false)
70 | {
71 | if (ActorNameRAMAddress != 0)
72 | {
73 | string tmp = string.Empty;
74 | ROMHandler.GetTerminatedString(rom.CodeData, (int)(ActorNameRAMAddress - ROMHandler.CodeRAMAddress), out tmp);
75 | Name = tmp;
76 | }
77 | else
78 | Name = string.Format("RAM Start 0x{0:X}", RAMStartAddress);
79 |
80 | if (RAMStartAddress != 0 && RAMEndAddress != 0)
81 | {
82 | DMATableEntry dma = rom.Files.Find(x => x.PStart == StartAddress);
83 | if (dma != null)
84 | {
85 | Filename = dma.Name;
86 |
87 | byte[] tmp = new byte[dma.VEnd - dma.VStart];
88 | Array.Copy(rom.Data, dma.PStart, tmp, 0, dma.VEnd - dma.VStart);
89 |
90 | uint infoadr = (ActorInfoRAMAddress - RAMStartAddress);
91 | if (infoadr >= tmp.Length) return;
92 |
93 | ActorNumber = Endian.SwapUInt16(BitConverter.ToUInt16(tmp, (int)infoadr));
94 | ActorType = tmp[infoadr + 2];
95 | ObjectNumber = Endian.SwapUInt16(BitConverter.ToUInt16(tmp, (int)infoadr + 8));
96 | }
97 | else
98 | Filename = Name;
99 | }
100 | }
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/SceneNavi/ROMHandler/EntranceTableEntry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ComponentModel;
6 |
7 | namespace SceneNavi.ROMHandler
8 | {
9 | public class EntranceTableEntry
10 | {
11 | [ReadOnly(true)]
12 | public ushort Number { get; set; }
13 |
14 | [Browsable(false)]
15 | public int Offset { get; private set; }
16 | [Browsable(false)]
17 | public bool IsOffsetRelative { get; private set; }
18 |
19 | [DisplayName("Scene #"), Description("Scene number to load")]
20 | public byte SceneNumber { get; set; }
21 | [DisplayName("Entrance #"), Description("Entrance within scene to spawn at")]
22 | public byte EntranceNumber { get; set; }
23 | [DisplayName("Variable"), Description("Controls certain behaviors when transitioning, ex. stopping music")]
24 | public byte Variable { get; set; }
25 | [DisplayName("Fade"), Description("Animation used when transitioning")]
26 | public byte Fade { get; set; }
27 |
28 | [DisplayName("Scene Name")]
29 | public string SceneName
30 | {
31 | get
32 | {
33 | return (SceneNumber < ROM.Scenes.Count ? ROM.Scenes[SceneNumber].GetName() : "(invalid?)");
34 | }
35 |
36 | set
37 | {
38 | int scnidx = ROM.Scenes.FindIndex(x => x.GetName().ToLowerInvariant() == value.ToLowerInvariant());
39 | if (scnidx != -1)
40 | SceneNumber = (byte)scnidx;
41 | else
42 | System.Media.SystemSounds.Hand.Play();
43 | }
44 | }
45 |
46 | ROMHandler ROM;
47 |
48 | public EntranceTableEntry(ROMHandler rom, int ofs, bool isrel)
49 | {
50 | ROM = rom;
51 | Offset = ofs;
52 | IsOffsetRelative = isrel;
53 |
54 | SceneNumber = (IsOffsetRelative ? rom.CodeData : rom.Data)[ofs];
55 | EntranceNumber = (IsOffsetRelative ? rom.CodeData : rom.Data)[ofs + 1];
56 | Variable = (IsOffsetRelative ? rom.CodeData : rom.Data)[ofs + 2];
57 | Fade = (IsOffsetRelative ? rom.CodeData : rom.Data)[ofs + 3];
58 | }
59 |
60 | public void SaveTableEntry()
61 | {
62 | (IsOffsetRelative ? ROM.CodeData : ROM.Data)[Offset] = SceneNumber;
63 | (IsOffsetRelative ? ROM.CodeData : ROM.Data)[Offset + 1] = EntranceNumber;
64 | (IsOffsetRelative ? ROM.CodeData : ROM.Data)[Offset + 2] = Variable;
65 | (IsOffsetRelative ? ROM.CodeData : ROM.Data)[Offset + 3] = Fade;
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/SceneNavi/ROMHandler/ISceneTableEntry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SceneNavi.ROMHandler
7 | {
8 | public interface ISceneTableEntry : IHeaderParent
9 | {
10 | ushort GetNumber();
11 | void SetNumber(ushort number);
12 |
13 | string GetDMAFilename();
14 | string GetName();
15 |
16 | uint GetSceneStartAddress();
17 | uint GetSceneEndAddress();
18 |
19 | bool IsValid();
20 | bool IsAllZero();
21 |
22 | byte[] GetData();
23 | List GetSceneHeaders();
24 | bool IsInROM();
25 | bool IsNameExternal();
26 | HeaderLoader GetCurrentSceneHeader();
27 | void SetCurrentSceneHeader(HeaderLoader header);
28 |
29 | HeaderCommands.Actors GetActiveTransitionData();
30 | HeaderCommands.Actors GetActiveSpawnPointData();
31 | HeaderCommands.SpecialObjects GetActiveSpecialObjs();
32 | HeaderCommands.Waypoints GetActiveWaypoints();
33 | HeaderCommands.Collision GetActiveCollision();
34 | HeaderCommands.SettingsSoundScene GetActiveSettingsSoundScene();
35 | HeaderCommands.EnvironmentSettings GetActiveEnvSettings();
36 |
37 | void SaveTableEntry();
38 | void ReadScene(HeaderCommands.Rooms forcerooms = null);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/SceneNavi/ROMHandler/ObjectTableEntry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SceneNavi.ROMHandler
7 | {
8 | public class ObjectTableEntry
9 | {
10 | public int Offset { get; private set; }
11 | public bool IsOffsetRelative { get; private set; }
12 |
13 | public uint StartAddress { get; private set; }
14 | public uint EndAddress { get; private set; }
15 |
16 | public bool IsValid { get; private set; }
17 | public bool IsEmpty { get; private set; }
18 |
19 | public string Name { get; private set; }
20 | public DMATableEntry DMA { get; private set; }
21 |
22 | ROMHandler ROM;
23 |
24 | public ObjectTableEntry(ROMHandler rom, int ofs, bool isrel, ushort number = 0)
25 | {
26 | ROM = rom;
27 | Offset = ofs;
28 | IsOffsetRelative = isrel;
29 |
30 | StartAddress = Endian.SwapUInt32(BitConverter.ToUInt32(IsOffsetRelative ? rom.CodeData : rom.Data, ofs));
31 | EndAddress = Endian.SwapUInt32(BitConverter.ToUInt32(IsOffsetRelative ? rom.CodeData : rom.Data, ofs + 4));
32 |
33 | IsValid =
34 | ((StartAddress > rom.Code.VStart) &&
35 | (StartAddress < rom.Size) && (EndAddress < rom.Size) &&
36 | ((StartAddress & 0xF) == 0) && ((EndAddress & 0xF) == 0) &&
37 | (EndAddress > StartAddress));
38 |
39 | IsEmpty = (StartAddress == 0 && EndAddress == 0);
40 |
41 | Name = "N/A";
42 |
43 | if (IsValid == true && IsEmpty == false)
44 | {
45 | if ((Name = (ROM.XMLObjectNames.Names[number] as string)) == null)
46 | {
47 | DMA = rom.Files.Find(x => x.PStart == StartAddress);
48 | if (DMA != null)
49 | Name = DMA.Name;
50 | else
51 | Name = string.Format("S{0:X}_E{1:X}", StartAddress, EndAddress);
52 | }
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/SceneNavi/Resources/BgEmpty_Large.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdanieldzd/SceneNavi/d0813a38e58c3ff6fec365f3951d12edd4320ea5/SceneNavi/Resources/BgEmpty_Large.png
--------------------------------------------------------------------------------
/SceneNavi/Resources/BgEmpty_Small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdanieldzd/SceneNavi/d0813a38e58c3ff6fec365f3951d12edd4320ea5/SceneNavi/Resources/BgEmpty_Small.png
--------------------------------------------------------------------------------
/SceneNavi/Resources/VertexShader.glsl:
--------------------------------------------------------------------------------
1 | #version 120
2 |
3 | varying vec3 in_position;
4 | varying vec3 in_normal;
5 |
6 | void main(void)
7 | {
8 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
9 | gl_TexCoord[0] = gl_MultiTexCoord0;
10 | gl_TexCoord[1] = gl_MultiTexCoord1;
11 | gl_FrontColor = gl_Color;
12 |
13 | in_position = gl_Vertex.xyz;
14 | in_normal = gl_Normal;
15 | }
16 |
--------------------------------------------------------------------------------
/SceneNavi/SimpleF3DEX2/CombinerEmulation/ArbCombineManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | using OpenTK;
7 | using OpenTK.Graphics;
8 | using OpenTK.Graphics.OpenGL;
9 |
10 | namespace SceneNavi.SimpleF3DEX2.CombinerEmulation
11 | {
12 | internal class ArbCombineManager : ICombinerManager
13 | {
14 | readonly bool supported;
15 | List fragcache;
16 |
17 | public ArbCombineManager()
18 | {
19 | supported = (GraphicsContext.CurrentContext as IGraphicsContextInternal).GetAddress("glGenProgramsARB") != IntPtr.Zero;
20 | fragcache = new List();
21 |
22 | ResetFragmentCache();
23 | }
24 |
25 | public void BindCombiner(uint m0, uint m1, bool tex)
26 | {
27 | if (!supported) return;
28 |
29 | GL.Enable((EnableCap)All.FragmentProgram);
30 | foreach (ArbCombineProgram frag in fragcache)
31 | {
32 | if (frag.Mux0 == m0 && frag.Mux1 == m1 && frag.Textured == tex)
33 | {
34 | GL.Arb.BindProgram(AssemblyProgramTargetArb.FragmentProgram, frag.GLID);
35 | return;
36 | }
37 | }
38 |
39 | ArbCombineProgram newcached = new ArbCombineProgram(m0, m1, tex);
40 | fragcache.Add(newcached);
41 | }
42 |
43 | public void ResetFragmentCache()
44 | {
45 | if (!supported) return;
46 |
47 | if (fragcache != null)
48 | {
49 | foreach (ArbCombineProgram fc in fragcache) if (GL.Arb.IsProgram(fc.GLID)) { int glid = fc.GLID; GL.Arb.DeleteProgram(1, ref glid); }
50 | fragcache.Clear();
51 | }
52 |
53 | /*foreach (uint[] knownMux in KnownCombinerMuxes.Muxes)
54 | {
55 | BindCombiner(knownMux[0], knownMux[1], true);
56 | BindCombiner(knownMux[0], knownMux[1], false);
57 | }*/
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/SceneNavi/SimpleF3DEX2/CombinerEmulation/GLSLCombineManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO;
6 | using System.Reflection;
7 | using System.Windows.Forms;
8 |
9 | using OpenTK;
10 | using OpenTK.Graphics;
11 | using OpenTK.Graphics.OpenGL;
12 |
13 | namespace SceneNavi.SimpleF3DEX2.CombinerEmulation
14 | {
15 | // TODO: fix fragmentshader, general cleanup, etc!
16 |
17 | internal class GLSLCombineManager : ICombinerManager
18 | {
19 | readonly bool supported;
20 | readonly F3DEX2Interpreter F3DEX2;
21 |
22 | readonly int vertexObject, fragmentObject, program;
23 | readonly int locInputTexel0, locInputTexel1, locInputPrim, locInputPrimLODFrac, locInputEnv;
24 | readonly int locCombinerIsTwoCycleMode;
25 | readonly int[] locCombinerColorParams, locCombinerAlphaParams;
26 |
27 | public GLSLCombineManager(F3DEX2Interpreter f3dex2)
28 | {
29 | supported = (GraphicsContext.CurrentContext as IGraphicsContextInternal).GetAddress("glCreateShader") != IntPtr.Zero;
30 | F3DEX2 = f3dex2;
31 |
32 | if (supported)
33 | {
34 | var vs = ReadEmbeddedTextResource("VertexShader.glsl");
35 | var fs = ReadEmbeddedTextResource("FragmentShader.glsl");
36 |
37 | CreateShaders(vs, fs, ref vertexObject, ref fragmentObject, ref program);
38 |
39 | locInputTexel0 = GL.GetUniformLocation(program, "combinerInputTexel[0]");
40 | locInputTexel1 = GL.GetUniformLocation(program, "combinerInputTexel[1]");
41 | locInputPrim = GL.GetUniformLocation(program, "combinerInputPrimitive");
42 | locInputPrimLODFrac = GL.GetUniformLocation(program, "combinerInputPrimitiveLODFrac");
43 | locInputEnv = GL.GetUniformLocation(program, "combinerInputEnvironment");
44 | locCombinerIsTwoCycleMode = GL.GetUniformLocation(program, "combinerIsTwoCycleMode");
45 | locCombinerColorParams = new int[8];
46 | for (var i = 0; i < locCombinerColorParams.Length; i++) locCombinerColorParams[i] = GL.GetUniformLocation(program, $"combinerColorParam[{i}]");
47 | locCombinerAlphaParams = new int[8];
48 | for (var i = 0; i < locCombinerAlphaParams.Length; i++) locCombinerAlphaParams[i] = GL.GetUniformLocation(program, $"combinerAlphaParam[{i}]");
49 |
50 | GL.UseProgram(program);
51 |
52 | GL.Uniform1(locInputTexel0, 0);
53 | GL.Uniform1(locInputTexel1, 1);
54 | GL.Uniform4(locInputPrim, new Vector4(1.0f));
55 | GL.Uniform1(locInputPrimLODFrac, 0.5f);
56 | GL.Uniform4(locInputEnv, new Vector4(0.5f));
57 | GL.Uniform1(locCombinerIsTwoCycleMode, 1);
58 | }
59 | }
60 |
61 | public void BindCombiner(uint m0, uint m1, bool tex)
62 | {
63 | if (!supported || (m0 == 0 && m1 == 0)) return;
64 |
65 | GL.UseProgram(program);
66 |
67 | ConfigureColorCombiner((ulong)m0 << 32 | m1);
68 |
69 | GL.Uniform4(locInputPrim, new Vector4(F3DEX2.PrimColor.R, F3DEX2.PrimColor.G, F3DEX2.PrimColor.B, F3DEX2.PrimColor.A));
70 | GL.Uniform4(locInputEnv, new Vector4(F3DEX2.EnvColor.R, F3DEX2.EnvColor.G, F3DEX2.EnvColor.B, F3DEX2.EnvColor.A));
71 | }
72 |
73 | private void ConfigureColorCombiner(ulong mux)
74 | {
75 | mux &= 0x00FFFFFFFFFFFFFFFF;
76 |
77 | var a0 = (mux >> 52) & 0b1111;
78 | var c0 = (mux >> 48) & 0b11111;
79 | var Aa0 = (mux >> 43) & 0b111;
80 | var Ac0 = (mux >> 40) & 0b111;
81 | var a1 = (mux >> 37) & 0b1111;
82 | var c1 = (mux >> 32) & 0b11111;
83 | var b0 = (mux >> 28) & 0b1111;
84 | var b1 = (mux >> 24) & 0b1111;
85 | var Aa1 = (mux >> 21) & 0b111;
86 | var Ac1 = (mux >> 18) & 0b111;
87 | var d0 = (mux >> 15) & 0b111;
88 | var Ab0 = (mux >> 12) & 0b111;
89 | var Ad0 = (mux >> 9) & 0b111;
90 | var d1 = (mux >> 6) & 0b111;
91 | var Ab1 = (mux >> 3) & 0b111;
92 | var Ad1 = (mux >> 0) & 0b111;
93 |
94 | var colorParams = new[] { a0, b0, c0, d0, a1, b1, c1, d1 };
95 | var alphaParams = new[] { Aa0, Ab0, Ac0, Ad0, Aa1, Ab1, Ac1, Ad1 };
96 |
97 | for (var i = 0; i < colorParams.Length; i++) GL.Uniform1(locCombinerColorParams[i], (int)colorParams[i]);
98 | for (var i = 0; i < alphaParams.Length; i++) GL.Uniform1(locCombinerAlphaParams[i], (int)alphaParams[i]);
99 | }
100 |
101 | private string ReadEmbeddedTextResource(string name)
102 | {
103 | using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"{Application.ProductName}.Resources.{name}"))
104 | {
105 | using (var reader = new StreamReader(stream))
106 | {
107 | return reader.ReadToEnd();
108 | }
109 | }
110 | }
111 |
112 | // Modified from OpenTK examples \Source\Examples\OpenGL\2.x\SimpleGLSL.cs
113 | private void CreateShaders(string vs, string fs, ref int vertexObject, ref int fragmentObject, ref int program)
114 | {
115 | try
116 | {
117 | vertexObject = GL.CreateShader(ShaderType.VertexShader);
118 | fragmentObject = GL.CreateShader(ShaderType.FragmentShader);
119 |
120 | /* Compile vertex shader */
121 | GL.ShaderSource(vertexObject, vs);
122 | GL.CompileShader(vertexObject);
123 | GL.GetShaderInfoLog(vertexObject, out string info);
124 | GL.GetShader(vertexObject, ShaderParameter.CompileStatus, out int statusCode);
125 |
126 | if (statusCode != 1) throw new ApplicationException(info);
127 |
128 | /* Compile fragment shader */
129 | GL.ShaderSource(fragmentObject, fs);
130 | GL.CompileShader(fragmentObject);
131 | GL.GetShaderInfoLog(fragmentObject, out info);
132 | GL.GetShader(fragmentObject, ShaderParameter.CompileStatus, out statusCode);
133 |
134 | if (statusCode != 1) throw new ApplicationException(info);
135 |
136 | program = GL.CreateProgram();
137 | GL.AttachShader(program, fragmentObject);
138 | GL.AttachShader(program, vertexObject);
139 |
140 | GL.LinkProgram(program);
141 | GL.UseProgram(program);
142 | }
143 | catch (ApplicationException ae)
144 | {
145 | MessageBox.Show(ae.ToString());
146 | }
147 | }
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/SceneNavi/SimpleF3DEX2/CombinerEmulation/ICombinerManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace SceneNavi.SimpleF3DEX2.CombinerEmulation
8 | {
9 | interface ICombinerManager
10 | {
11 | void BindCombiner(uint m0, uint m1, bool tex);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/SceneNavi/SimpleF3DEX2/CombinerEmulation/KnownCombinerMuxes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SceneNavi.SimpleF3DEX2.CombinerEmulation
7 | {
8 | internal static class KnownCombinerMuxes
9 | {
10 | public static uint[][] Muxes = new uint[][]
11 | {
12 | new uint[] { 0x0011FFFF, 0xFFFFFC38 },
13 | new uint[] { 0x00127E03, 0xFFFFFDF8 },
14 | new uint[] { 0x00127E03, 0xFFFFF3F8 },
15 | new uint[] { 0x00127E03, 0xFFFFF7F8 },
16 | new uint[] { 0x00121603, 0xFF5BFFF8 },
17 | new uint[] { 0x00267E04, 0x1F0CFDFF },
18 | new uint[] { 0x0041FFFF, 0xFFFFFC38 },
19 | new uint[] { 0x00127E0C, 0xFFFFFDF8 },
20 | new uint[] { 0x00267E04, 0x1FFCFDF8 },
21 | new uint[] { 0x00262A04, 0x1F0C93FF },
22 | new uint[] { 0x00121803, 0xFF5BFFF8 },
23 | new uint[] { 0x00121803, 0xFF0FFFFF },
24 | new uint[] { 0x0041FFFF, 0xFFFFF638 },
25 | new uint[] { 0x0011FFFF, 0xFFFFF238 },
26 | new uint[] { 0x0041C7FF, 0xFFFFFE38 },
27 | new uint[] { 0x0041FFFF, 0xFFFFF838 },
28 | new uint[] { 0x00127E60, 0xFFFFF3F8 },
29 | new uint[] { 0x00272C04, 0x1F0C93FF },
30 | new uint[] { 0x0020AC04, 0xFF0F93FF },
31 | new uint[] { 0x0026A004, 0x1FFC93F8 },
32 | new uint[] { 0x00277E04, 0x1F0CF7FF },
33 | new uint[] { 0x0020FE04, 0xFF0FF7FF },
34 | new uint[] { 0x00272E04, 0x1F0C93FF },
35 | new uint[] { 0x00272C04, 0x1F1093FF },
36 | new uint[] { 0x0020A203, 0xFF13FFFF },
37 | new uint[] { 0x0011FE04, 0xFFFFF7F8 },
38 | new uint[] { 0x0020AC03, 0xFF0F93FF },
39 | new uint[] { 0x00272C03, 0x1F0C93FF },
40 | new uint[] { 0x0011FE04, 0xFF0FF3FF },
41 | new uint[] { 0x00119C04, 0xFFFFFFF8 },
42 | new uint[] { 0x00271204, 0x1F0CFFFF },
43 | new uint[] { 0x0011FE04, 0xFFFFF3F8 },
44 | new uint[] { 0x00272C80, 0x350CF37F },
45 | new uint[] { 0x00127EA0, 0xFFFFF3F8 },
46 | new uint[] { 0x001197FF, 0xFF5BFE38 },
47 | new uint[] { 0x00262A04, 0x1F5893F8 },
48 | new uint[] { 0x00FFFFFF, 0xFFFDFC38 },
49 | new uint[] { 0x00267E03, 0x1FFCFDF8 },
50 | new uint[] { 0x00127E05, 0xFFFFFDF8 },
51 | new uint[] { 0x00262A04, 0x1F1093FF },
52 | new uint[] { 0x00121A60, 0xFFFFFFF8 },
53 | new uint[] { 0x00127E60, 0xFF17F3FF },
54 | new uint[] { 0x0011FE04, 0xFF17F7FF },
55 | new uint[] { 0x00327FFF, 0xFF17FC3F },
56 | new uint[] { 0x0030FE04, 0x5FFEF3F8 },
57 | new uint[] { 0x00262A60, 0x1510937F },
58 | new uint[] { 0x0030FE04, 0x5FFEFDFE },
59 | new uint[] { 0x00177E60, 0x35FCFD7E },
60 | new uint[] { 0x0030EC04, 0x5FDAEDF6 },
61 | new uint[] { 0x00309604, 0x5FFEFFF8 },
62 | new uint[] { 0x003097FF, 0x5FFEFE38 },
63 | new uint[] { 0x00127E60, 0xF5FFF378 },
64 | new uint[] { 0x00121660, 0xF5FFFF78 },
65 | new uint[] { 0x00121603, 0xFFFFFFF8 },
66 | new uint[] { 0x00127E03, 0xFFFFFFFB },
67 | new uint[] { 0x00FFFFFF, 0xFF0CF23F },
68 | new uint[] { 0x00FF9A60, 0xFFFCFFF8 },
69 | new uint[] { 0x001197FF, 0xFFFFFE38 },
70 | new uint[] { 0x0030FFFF, 0x5F16F23F },
71 | new uint[] { 0x00272C04, 0x1F0C92FF },
72 | new uint[] { 0x00272C04, 0x150C92FF },
73 | new uint[] { 0x00FFFEA0, 0xFF14F3FF },
74 | new uint[] { 0x00177E60, 0x35FE7778 },
75 | new uint[] { 0x001FFE60, 0x35FE7378 },
76 | new uint[] { 0x00272C60, 0x150CE37F },
77 | };
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/SceneNavi/SimpleF3DEX2/OtherModeL.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SceneNavi.SimpleF3DEX2
7 | {
8 | public class OtherModeL
9 | {
10 | public static OtherModeL Empty = new OtherModeL(0);
11 |
12 | public uint Data { get; private set; }
13 |
14 | public bool AAEn { get { return (Data & (uint)General.OtherModeL.AA_EN) != 0; } }
15 | public bool ZCmp { get { return (Data & (uint)General.OtherModeL.Z_CMP) != 0; } }
16 | public bool ZUpd { get { return (Data & (uint)General.OtherModeL.Z_UPD) != 0; } }
17 | public bool ImRd { get { return (Data & (uint)General.OtherModeL.IM_RD) != 0; } }
18 | public bool ClrOnCvg { get { return (Data & (uint)General.OtherModeL.CLR_ON_CVG) != 0; } }
19 | public bool CvgDstWrap { get { return (Data & (uint)General.OtherModeL.CVG_DST_WRAP) != 0; } }
20 | public bool CvgDstFull { get { return (Data & (uint)General.OtherModeL.CVG_DST_FULL) != 0; } }
21 | public bool CvgDstSave { get { return (Data & (uint)General.OtherModeL.CVG_DST_SAVE) != 0; } }
22 | public bool ZModeInter { get { return (Data & (uint)General.OtherModeL.ZMODE_INTER) != 0; } }
23 | public bool ZModeXlu { get { return (Data & (uint)General.OtherModeL.ZMODE_XLU) != 0; } }
24 | public bool ZModeDec { get { return (Data & (uint)General.OtherModeL.ZMODE_DEC) != 0; } }
25 | public bool CvgXAlpha { get { return (Data & (uint)General.OtherModeL.CVG_X_ALPHA) != 0; } }
26 | public bool AlphaCvgSel { get { return (Data & (uint)General.OtherModeL.ALPHA_CVG_SEL) != 0; } }
27 | public bool ForceBl { get { return (Data & (uint)General.OtherModeL.FORCE_BL) != 0; } }
28 |
29 | public OtherModeL(uint data)
30 | {
31 | Data = data;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/SceneNavi/SimpleF3DEX2/SimpleTriangle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | using OpenTK;
7 | using OpenTK.Graphics;
8 | using OpenTK.Graphics.OpenGL;
9 |
10 | namespace SceneNavi.SimpleF3DEX2
11 | {
12 | public class SimpleTriangle
13 | {
14 | public Vector3d[] Vertices { get; private set; }
15 |
16 | public SimpleTriangle(Vector3d v1, Vector3d v2, Vector3d v3)
17 | {
18 | Vertices = new Vector3d[3];
19 | Vertices[0] = v1;
20 | Vertices[1] = v2;
21 | Vertices[2] = v3;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/SceneNavi/SimpleF3DEX2/Texture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SceneNavi.SimpleF3DEX2
7 | {
8 | internal class Texture
9 | {
10 | public uint Address { get; set; }
11 | public byte Format { get; set; }
12 | public uint CMS { get; set; }
13 | public uint CMT { get; set; }
14 | public int LineSize { get; set; }
15 | public int Palette { get; set; }
16 | public int ShiftS { get; set; }
17 | public int ShiftT { get; set; }
18 | public int MaskS { get; set; }
19 | public int MaskT { get; set; }
20 | public int Tile { get; set; }
21 | public int ULS { get; set; }
22 | public int ULT { get; set; }
23 | public int LRS { get; set; }
24 | public int LRT { get; set; }
25 |
26 | public int Width { get; set; }
27 | public int Height { get; set; }
28 | public int RealWidth { get; set; }
29 | public int RealHeight { get; set; }
30 |
31 | public float ScaleS { get; set; }
32 | public float ScaleT { get; set; }
33 | public float ShiftScaleS { get; set; }
34 | public float ShiftScaleT { get; set; }
35 |
36 | public int GLID { get; set; }
37 |
38 | public Texture()
39 | {
40 | ScaleS = ScaleT = 1.0f;
41 | ShiftScaleS = ShiftScaleT = 1.0f;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/SceneNavi/SimpleF3DEX2/TextureCache.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SceneNavi.SimpleF3DEX2
7 | {
8 | internal class TextureCache
9 | {
10 | public object Tag { get; set; }
11 | public byte Format { get; set; }
12 | public uint Address { get; set; }
13 | public int RealWidth { get; set; }
14 | public int RealHeight { get; set; }
15 | public int GLID { get; set; }
16 |
17 | public TextureCache(object tag, Texture tex, int glid)
18 | {
19 | Tag = tag;
20 | Format = tex.Format;
21 | Address = tex.Address;
22 | RealWidth = tex.RealWidth;
23 | RealHeight = tex.RealHeight;
24 | GLID = glid;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/SceneNavi/SimpleF3DEX2/UnpackedCombinerMux.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SceneNavi.SimpleF3DEX2
7 | {
8 | internal class UnpackedCombinerMux
9 | {
10 | public enum ComponentsC32 : byte
11 | {
12 | CCMUX_COMBINED = 0,
13 | CCMUX_TEXEL0 = 1,
14 | CCMUX_TEXEL1 = 2,
15 | CCMUX_PRIMITIVE = 3,
16 | CCMUX_SHADE = 4,
17 | CCMUX_ENVIRONMENT = 5,
18 | CCMUX_1 = 6,
19 | CCMUX_COMBINED_ALPHA = 7,
20 | CCMUX_TEXEL0_ALPHA = 8,
21 | CCMUX_TEXEL1_ALPHA = 9,
22 | CCMUX_PRIMITIVE_ALPHA = 10,
23 | CCMUX_SHADE_ALPHA = 11,
24 | CCMUX_ENV_ALPHA = 12,
25 | CCMUX_LOD_FRACTION = 13,
26 | CCMUX_PRIM_LOD_FRAC = 14,
27 | CCMUX_K5 = 15,
28 | CCMUX_0 = 31
29 | }
30 |
31 | public enum ComponentsC16 : byte
32 | {
33 | CCMUX_COMBINED = 0,
34 | CCMUX_TEXEL0 = 1,
35 | CCMUX_TEXEL1 = 2,
36 | CCMUX_PRIMITIVE = 3,
37 | CCMUX_SHADE = 4,
38 | CCMUX_ENVIRONMENT = 5,
39 | CCMUX_1 = 6,
40 | CCMUX_COMBINED_ALPHA = 7,
41 | CCMUX_TEXEL0_ALPHA = 8,
42 | CCMUX_TEXEL1_ALPHA = 9,
43 | CCMUX_PRIMITIVE_ALPHA = 10,
44 | CCMUX_SHADE_ALPHA = 11,
45 | CCMUX_ENV_ALPHA = 12,
46 | CCMUX_LOD_FRACTION = 13,
47 | CCMUX_PRIM_LOD_FRAC = 14,
48 | CCMUX_0 = 15
49 | }
50 |
51 | public enum ComponentsC8 : byte
52 | {
53 | CCMUX_COMBINED = 0,
54 | CCMUX_TEXEL0 = 1,
55 | CCMUX_TEXEL1 = 2,
56 | CCMUX_PRIMITIVE = 3,
57 | CCMUX_SHADE = 4,
58 | CCMUX_ENVIRONMENT = 5,
59 | CCMUX_1 = 6,
60 | CCMUX_0 = 7
61 | }
62 |
63 | public enum ComponentsA8 : byte
64 | {
65 | ACMUX_COMBINED = 0,
66 | ACMUX_TEXEL0 = 1,
67 | ACMUX_TEXEL1 = 2,
68 | ACMUX_PRIMITIVE = 3,
69 | ACMUX_SHADE = 4,
70 | ACMUX_ENVIRONMENT = 5,
71 | //ACMUX_PRIM_LOD_FRAC = 6, //TODO check
72 | ACMUX_1 = 6,
73 | ACMUX_0 = 7
74 | }
75 |
76 | public ComponentsC16[] cA { get; set; }
77 | public ComponentsC16[] cB { get; set; }
78 | public ComponentsC32[] cC { get; set; }
79 | public ComponentsC8[] cD { get; set; }
80 | public ComponentsA8[] aA { get; set; }
81 | public ComponentsA8[] aB { get; set; }
82 | public ComponentsA8[] aC { get; set; }
83 | public ComponentsA8[] aD { get; set; }
84 |
85 | public UnpackedCombinerMux(uint m0, uint m1)
86 | {
87 | cA = new ComponentsC16[2];
88 | cB = new ComponentsC16[2];
89 | cC = new ComponentsC32[2];
90 | cD = new ComponentsC8[2];
91 | aA = new ComponentsA8[2];
92 | aB = new ComponentsA8[2];
93 | aC = new ComponentsA8[2];
94 | aD = new ComponentsA8[2];
95 |
96 | cA[0] = (ComponentsC16)(byte)((m0 >> 20) & 0x0F);
97 | cB[0] = (ComponentsC16)(byte)((m1 >> 28) & 0x0F);
98 | cC[0] = (ComponentsC32)(byte)((m0 >> 15) & 0x1F);
99 | cD[0] = (ComponentsC8)(byte)((m1 >> 15) & 0x07);
100 |
101 | aA[0] = (ComponentsA8)(byte)((m0 >> 12) & 0x07);
102 | aB[0] = (ComponentsA8)(byte)((m1 >> 12) & 0x07);
103 | aC[0] = (ComponentsA8)(byte)((m0 >> 9) & 0x07);
104 | aD[0] = (ComponentsA8)(byte)((m1 >> 9) & 0x07);
105 |
106 | cA[1] = (ComponentsC16)(byte)((m0 >> 5) & 0x0F);
107 | cB[1] = (ComponentsC16)(byte)((m1 >> 24) & 0x0F);
108 | cC[1] = (ComponentsC32)(byte)((m0 >> 0) & 0x1F);
109 | cD[1] = (ComponentsC8)(byte)((m1 >> 6) & 0x07);
110 |
111 | aA[1] = (ComponentsA8)(byte)((m1 >> 21) & 0x07);
112 | aB[1] = (ComponentsA8)(byte)((m1 >> 3) & 0x07);
113 | aC[1] = (ComponentsA8)(byte)((m1 >> 18) & 0x07);
114 | aD[1] = (ComponentsA8)(byte)((m1 >> 0) & 0x07);
115 | }
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/SceneNavi/SimpleF3DEX2/Vertex.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ComponentModel;
6 |
7 | using OpenTK;
8 | using OpenTK.Graphics;
9 | using OpenTK.Graphics.OpenGL;
10 |
11 | namespace SceneNavi.SimpleF3DEX2
12 | {
13 | internal class Vertex : HeaderCommands.IPickableObject, HeaderCommands.IStoreable
14 | {
15 | ROMHandler.ROMHandler ROM;
16 |
17 | [Browsable(false)]
18 | public System.Drawing.Color PickColor { get { return System.Drawing.Color.FromArgb(this.GetHashCode() & 0xFFFFFF | (0xFF << 24)); } }
19 |
20 | [Browsable(false)]
21 | public bool IsMoveable { get { return false; } }
22 |
23 | public Vector3d Position { get; set; }
24 | public Vector2d TexCoord { get; set; }
25 | public byte[] Colors { get; set; }
26 | public sbyte[] Normals { get; set; }
27 |
28 | public uint Address { get; set; }
29 |
30 | public Vertex(ROMHandler.ROMHandler rom, byte[] raw, uint adr, Matrix4d mtx)
31 | {
32 | ROM = rom;
33 |
34 | Address = adr;
35 | adr &= 0xFFFFFF;
36 |
37 | Position = new Vector3d(
38 | (double)Endian.SwapInt16(BitConverter.ToInt16(raw, (int)adr)),
39 | (double)Endian.SwapInt16(BitConverter.ToInt16(raw, (int)(adr + 2))),
40 | (double)Endian.SwapInt16(BitConverter.ToInt16(raw, (int)(adr + 4))));
41 |
42 | Position = Vector3d.Transform(Position, mtx);
43 |
44 | TexCoord = new Vector2d(
45 | (float)(Endian.SwapInt16(BitConverter.ToInt16(raw, (int)(adr + 8)))) * General.Fixed2Float[5],
46 | (float)(Endian.SwapInt16(BitConverter.ToInt16(raw, (int)(adr + 10)))) * General.Fixed2Float[5]);
47 |
48 | TexCoord.Normalize();
49 |
50 | Colors = new byte[] { raw[adr + 12], raw[adr + 13], raw[adr + 14], raw[adr + 15] };
51 | Normals = new sbyte[] { (sbyte)raw[adr + 12], (sbyte)raw[adr + 13], (sbyte)raw[adr + 14] };
52 | }
53 |
54 | public void Store(byte[] databuf, int baseadr)
55 | {
56 | // KLUDGE! Write to ROM HERE, write to local room data for rendering in MainForm
57 |
58 | // (Colors only!)
59 | databuf[(int)(baseadr + (Address & 0xFFFFFF)) + 12] = Colors[0];
60 | databuf[(int)(baseadr + (Address & 0xFFFFFF)) + 13] = Colors[1];
61 | databuf[(int)(baseadr + (Address & 0xFFFFFF)) + 14] = Colors[2];
62 | databuf[(int)(baseadr + (Address & 0xFFFFFF)) + 15] = Colors[3];
63 | }
64 |
65 | public void Render(HeaderCommands.PickableObjectRenderType rendertype)
66 | {
67 | if (rendertype == HeaderCommands.PickableObjectRenderType.Picking)
68 | {
69 | GL.PushAttrib(AttribMask.AllAttribBits);
70 | GL.Disable(EnableCap.Texture2D);
71 | GL.Disable(EnableCap.Lighting);
72 | if (OpenGLHelpers.Initialization.SupportsFunction("glGenProgramsARB")) GL.Disable((EnableCap)All.FragmentProgram);
73 | GL.Disable(EnableCap.CullFace);
74 |
75 | GL.DepthRange(0.0, 0.999);
76 | GL.PointSize(50.0f);
77 | GL.Color3(PickColor);
78 | GL.Begin(PrimitiveType.Points);
79 | GL.Vertex3(Position);
80 | GL.End();
81 |
82 | GL.PopAttrib();
83 | }
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/SceneNavi/StatusMessageHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 |
7 | namespace SceneNavi
8 | {
9 | public class StatusMessageHandler
10 | {
11 | public delegate void MessageChangedEvent(object sender, MessageChangedEventArgs e);
12 | public class MessageChangedEventArgs : EventArgs
13 | {
14 | public string Message { get; set; }
15 | }
16 | public event MessageChangedEvent MessageChanged;
17 |
18 | string lastmsg;
19 | public string Message
20 | {
21 | get { return lastmsg; }
22 | set
23 | {
24 | lastmsg = value;
25 | var ev = MessageChanged;
26 | if (ev != null) ev(this, new MessageChangedEventArgs() { Message = lastmsg });
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/SceneNavi/TableEditorForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
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 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/SceneNavi/TitleCardForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace SceneNavi
2 | {
3 | partial class TitleCardForm
4 | {
5 | ///
6 | /// Erforderliche Designervariable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Verwendete Ressourcen bereinigen.
12 | ///
13 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Vom Windows Form-Designer generierter Code
24 |
25 | ///
26 | /// Erforderliche Methode für die Designerunterstützung.
27 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.btnClose = new System.Windows.Forms.Button();
32 | this.pbTitleCard = new System.Windows.Forms.PictureBox();
33 | this.btnExport = new System.Windows.Forms.Button();
34 | this.btnImport = new System.Windows.Forms.Button();
35 | this.sfdImage = new System.Windows.Forms.SaveFileDialog();
36 | this.ofdImage = new System.Windows.Forms.OpenFileDialog();
37 | ((System.ComponentModel.ISupportInitialize)(this.pbTitleCard)).BeginInit();
38 | this.SuspendLayout();
39 | //
40 | // btnClose
41 | //
42 | this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
43 | this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
44 | this.btnClose.Location = new System.Drawing.Point(307, 187);
45 | this.btnClose.Name = "btnClose";
46 | this.btnClose.Size = new System.Drawing.Size(85, 23);
47 | this.btnClose.TabIndex = 3;
48 | this.btnClose.Text = "&Close";
49 | this.btnClose.UseVisualStyleBackColor = true;
50 | //
51 | // pbTitleCard
52 | //
53 | this.pbTitleCard.BackgroundImage = global::SceneNavi.Properties.Resources.BgEmpty_Small;
54 | this.pbTitleCard.Location = new System.Drawing.Point(12, 12);
55 | this.pbTitleCard.Name = "pbTitleCard";
56 | this.pbTitleCard.Size = new System.Drawing.Size(288, 64);
57 | this.pbTitleCard.TabIndex = 4;
58 | this.pbTitleCard.TabStop = false;
59 | this.pbTitleCard.Paint += new System.Windows.Forms.PaintEventHandler(this.pbTitleCard_Paint);
60 | //
61 | // btnExport
62 | //
63 | this.btnExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
64 | this.btnExport.Location = new System.Drawing.Point(307, 12);
65 | this.btnExport.Name = "btnExport";
66 | this.btnExport.Size = new System.Drawing.Size(85, 23);
67 | this.btnExport.TabIndex = 5;
68 | this.btnExport.Text = "&Export";
69 | this.btnExport.UseVisualStyleBackColor = true;
70 | this.btnExport.Click += new System.EventHandler(this.btnExport_Click);
71 | //
72 | // btnImport
73 | //
74 | this.btnImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
75 | this.btnImport.Location = new System.Drawing.Point(307, 41);
76 | this.btnImport.Name = "btnImport";
77 | this.btnImport.Size = new System.Drawing.Size(85, 23);
78 | this.btnImport.TabIndex = 6;
79 | this.btnImport.Text = "&Import";
80 | this.btnImport.UseVisualStyleBackColor = true;
81 | this.btnImport.Click += new System.EventHandler(this.btnImport_Click);
82 | //
83 | // TitleCardForm
84 | //
85 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
86 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
87 | this.CancelButton = this.btnClose;
88 | this.ClientSize = new System.Drawing.Size(404, 222);
89 | this.Controls.Add(this.btnImport);
90 | this.Controls.Add(this.btnExport);
91 | this.Controls.Add(this.pbTitleCard);
92 | this.Controls.Add(this.btnClose);
93 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
94 | this.MaximizeBox = false;
95 | this.MinimizeBox = false;
96 | this.Name = "TitleCardForm";
97 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
98 | this.Text = "Title Card Editor";
99 | ((System.ComponentModel.ISupportInitialize)(this.pbTitleCard)).EndInit();
100 | this.ResumeLayout(false);
101 |
102 | }
103 |
104 | #endregion
105 |
106 | private System.Windows.Forms.Button btnClose;
107 | private System.Windows.Forms.PictureBox pbTitleCard;
108 | private System.Windows.Forms.Button btnExport;
109 | private System.Windows.Forms.Button btnImport;
110 | private System.Windows.Forms.SaveFileDialog sfdImage;
111 | private System.Windows.Forms.OpenFileDialog ofdImage;
112 | }
113 | }
--------------------------------------------------------------------------------
/SceneNavi/TitleCardForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using System.Drawing.Imaging;
10 |
11 | namespace SceneNavi
12 | {
13 | public partial class TitleCardForm : Form
14 | {
15 | const int titleCardWidth = 144;
16 | int titleCardHeight = 0;
17 |
18 | ROMHandler.ROMHandler ROM;
19 | ROMHandler.SceneTableEntryOcarina Scene;
20 |
21 | Bitmap output;
22 | Rectangle outputRect;
23 |
24 | public TitleCardForm(ROMHandler.ROMHandler rom, ROMHandler.SceneTableEntryOcarina ste)
25 | {
26 | InitializeComponent();
27 |
28 | ROM = rom;
29 | Scene = ste;
30 |
31 | ofdImage.SetCommonImageFilter("png");
32 | sfdImage.SetCommonImageFilter("png");
33 |
34 | ReadImageFromROM();
35 | }
36 |
37 | private void ReadImageFromROM()
38 | {
39 | titleCardHeight = (int)((Scene.LabelEndAddress - Scene.LabelStartAddress) / titleCardWidth);
40 |
41 | byte[] textureBuffer = new byte[titleCardWidth * titleCardHeight * 4];
42 | SimpleF3DEX2.ImageHelper.IA8(titleCardWidth, titleCardHeight, (titleCardWidth / 8), ROM.Data, (int)Scene.LabelStartAddress, ref textureBuffer);
43 | textureBuffer.SwapRGBAToBGRA();
44 |
45 | output = new Bitmap(titleCardWidth, titleCardHeight, PixelFormat.Format32bppArgb);
46 | outputRect = new Rectangle(0, 0, output.Width, output.Height);
47 | BitmapData bmpData = output.LockBits(outputRect, ImageLockMode.ReadWrite, output.PixelFormat);
48 | IntPtr ptr = bmpData.Scan0;
49 |
50 | System.Runtime.InteropServices.Marshal.Copy(textureBuffer, 0, ptr, textureBuffer.Length);
51 | output.UnlockBits(bmpData);
52 |
53 | pbTitleCard.ClientSize = new Size(titleCardWidth * 2, titleCardHeight * 2);
54 | }
55 |
56 | private void pbTitleCard_Paint(object sender, PaintEventArgs e)
57 | {
58 | e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
59 | e.Graphics.DrawImage(output, new Rectangle(outputRect.X, outputRect.Y, outputRect.Width * 2, outputRect.Height * 2), outputRect, GraphicsUnit.Pixel);
60 | }
61 |
62 | private void btnExport_Click(object sender, EventArgs e)
63 | {
64 | if (sfdImage.ShowDialog() == System.Windows.Forms.DialogResult.OK)
65 | {
66 | Bitmap temp = new Bitmap(output);
67 | temp.Save(sfdImage.FileName);
68 | temp.Dispose();
69 | }
70 | }
71 |
72 | private void btnImport_Click(object sender, EventArgs e)
73 | {
74 | if (ofdImage.ShowDialog() == System.Windows.Forms.DialogResult.OK)
75 | {
76 | Bitmap import = ImportImage(ofdImage.FileName);
77 | if (import != null)
78 | {
79 | output = import;
80 | pbTitleCard.Invalidate();
81 | }
82 | }
83 | }
84 |
85 | private Bitmap ImportImage(string fn)
86 | {
87 | Bitmap import = new Bitmap(fn);
88 |
89 | if (import.Width != titleCardWidth || import.Height != titleCardHeight)
90 | {
91 | MessageBox.Show("Selected image has wrong size; image cannot be used.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
92 | return null;
93 | }
94 |
95 | uint offset = Scene.LabelStartAddress;
96 |
97 | for (int y = 0; y < import.Height; y++)
98 | {
99 | for (int x = 0; x < import.Width; x++)
100 | {
101 | Color pixelColor = import.GetPixel(x, y);
102 | int intensity = (pixelColor.R + pixelColor.G + pixelColor.B) / 3;
103 |
104 | Color newColor = Color.FromArgb(pixelColor.A, intensity, intensity, intensity);
105 | import.SetPixel(x, y, newColor);
106 |
107 | byte packed = (byte)(((byte)intensity).Scale(0, 0xFF, 0, 0xF) << 4);
108 | packed |= (byte)(pixelColor.A.Scale(0, 0xFF, 0, 0xF));
109 | ROM.Data[offset] = packed;
110 |
111 | offset++;
112 | }
113 | }
114 |
115 | Bitmap temp = new Bitmap(import);
116 | import.Dispose();
117 |
118 | return temp;
119 | }
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/SceneNavi/TitleCardForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
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 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
124 | 119, 17
125 |
126 |
--------------------------------------------------------------------------------
/SceneNavi/UpdateCheckDialog.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace SceneNavi
2 | {
3 | partial class UpdateCheckDialog
4 | {
5 | ///
6 | /// Erforderliche Designervariable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Verwendete Ressourcen bereinigen.
12 | ///
13 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Vom Windows Form-Designer generierter Code
24 |
25 | ///
26 | /// Erforderliche Methode für die Designerunterstützung.
27 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.btnClose = new System.Windows.Forms.Button();
32 | this.lblStatus = new System.Windows.Forms.Label();
33 | this.btnDownload = new System.Windows.Forms.Button();
34 | this.rlblChangelog = new SceneNavi.Controls.RichLabel();
35 | this.SuspendLayout();
36 | //
37 | // btnClose
38 | //
39 | this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
40 | this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
41 | this.btnClose.Enabled = false;
42 | this.btnClose.Location = new System.Drawing.Point(607, 387);
43 | this.btnClose.Name = "btnClose";
44 | this.btnClose.Size = new System.Drawing.Size(75, 23);
45 | this.btnClose.TabIndex = 0;
46 | this.btnClose.Text = "&Close";
47 | this.btnClose.UseVisualStyleBackColor = true;
48 | //
49 | // lblStatus
50 | //
51 | this.lblStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
52 | this.lblStatus.AutoSize = true;
53 | this.lblStatus.Location = new System.Drawing.Point(12, 392);
54 | this.lblStatus.Name = "lblStatus";
55 | this.lblStatus.Size = new System.Drawing.Size(16, 13);
56 | this.lblStatus.TabIndex = 2;
57 | this.lblStatus.Text = "---";
58 | //
59 | // btnDownload
60 | //
61 | this.btnDownload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
62 | this.btnDownload.Enabled = false;
63 | this.btnDownload.Location = new System.Drawing.Point(526, 387);
64 | this.btnDownload.Name = "btnDownload";
65 | this.btnDownload.Size = new System.Drawing.Size(75, 23);
66 | this.btnDownload.TabIndex = 3;
67 | this.btnDownload.Text = "&Download";
68 | this.btnDownload.UseVisualStyleBackColor = true;
69 | this.btnDownload.Click += new System.EventHandler(this.btnDownload_Click);
70 | //
71 | // rlblChangelog
72 | //
73 | this.rlblChangelog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
74 | | System.Windows.Forms.AnchorStyles.Left)
75 | | System.Windows.Forms.AnchorStyles.Right)));
76 | this.rlblChangelog.BackColor = System.Drawing.SystemColors.Window;
77 | this.rlblChangelog.Cursor = System.Windows.Forms.Cursors.Arrow;
78 | this.rlblChangelog.Location = new System.Drawing.Point(12, 12);
79 | this.rlblChangelog.Name = "rlblChangelog";
80 | this.rlblChangelog.ReadOnly = true;
81 | this.rlblChangelog.ShortcutsEnabled = false;
82 | this.rlblChangelog.Size = new System.Drawing.Size(670, 369);
83 | this.rlblChangelog.TabIndex = 1;
84 | this.rlblChangelog.Text = "";
85 | //
86 | // UpdateCheckDialog
87 | //
88 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
89 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
90 | this.CancelButton = this.btnClose;
91 | this.ClientSize = new System.Drawing.Size(694, 422);
92 | this.Controls.Add(this.btnDownload);
93 | this.Controls.Add(this.lblStatus);
94 | this.Controls.Add(this.rlblChangelog);
95 | this.Controls.Add(this.btnClose);
96 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
97 | this.MaximizeBox = false;
98 | this.MinimizeBox = false;
99 | this.Name = "UpdateCheckDialog";
100 | this.ShowInTaskbar = false;
101 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
102 | this.Text = "Update Manager";
103 | this.ResumeLayout(false);
104 | this.PerformLayout();
105 |
106 | }
107 |
108 | #endregion
109 |
110 | private System.Windows.Forms.Button btnClose;
111 | private Controls.RichLabel rlblChangelog;
112 | private System.Windows.Forms.Label lblStatus;
113 | private System.Windows.Forms.Button btnDownload;
114 | }
115 | }
--------------------------------------------------------------------------------
/SceneNavi/UpdateCheckDialog.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using System.Net;
10 | using System.IO;
11 |
12 | namespace SceneNavi
13 | {
14 | public partial class UpdateCheckDialog : Form
15 | {
16 | enum updateTxtLines : int { NewVersionNumber = 0, UpdatePageUrl = 1, ReleaseNotesUrl = 2 };
17 |
18 | Version localVersion, remoteVersion;
19 | string updatePageUrl, releaseNotesUrl;
20 |
21 | bool IsRemoteVersionNewer
22 | {
23 | get { return (remoteVersion > localVersion); }
24 | }
25 |
26 | public UpdateCheckDialog()
27 | {
28 | InitializeComponent();
29 |
30 | localVersion = new Version(Application.ProductVersion);
31 | //localVersion = new Version(1, 0, 1, 6); //fake beta6
32 |
33 | System.Timers.Timer tmr = new System.Timers.Timer();
34 | tmr.Elapsed += new System.Timers.ElapsedEventHandler(tmr_Elapsed);
35 | tmr.Interval = 2.0;
36 | tmr.Start();
37 | }
38 |
39 | private void tmr_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
40 | {
41 | (sender as System.Timers.Timer).Stop();
42 |
43 | Cursor.Current = Cursors.WaitCursor;
44 | this.UIThread(() => lblStatus.Text = "Checking for version information...");
45 |
46 | string finalStatusMsg = string.Empty;
47 | try
48 | {
49 | if (VersionManagement.RemoteFileExists(Configuration.UpdateServer))
50 | {
51 | this.UIThread(() => lblStatus.Text = "Version information found; downloading...");
52 |
53 | string[] updateInformation = VersionManagement.DownloadTextFile(Configuration.UpdateServer);
54 |
55 | remoteVersion = new Version(updateInformation[(int)updateTxtLines.NewVersionNumber]);
56 | updatePageUrl = updateInformation[(int)updateTxtLines.UpdatePageUrl];
57 | if (updateInformation.Length >= 2) releaseNotesUrl = updateInformation[(int)updateTxtLines.ReleaseNotesUrl];
58 |
59 | this.UIThread(() => VersionManagement.DownloadRtfFile(releaseNotesUrl, rlblChangelog));
60 |
61 | if (IsRemoteVersionNewer)
62 | {
63 | this.UIThread(() => btnDownload.Enabled = true);
64 | finalStatusMsg = string.Format("New version {0} is available!", VersionManagement.CreateVersionString(remoteVersion));
65 | }
66 | else
67 | {
68 | finalStatusMsg = string.Format("You are already using the most recent version {0}.\n", VersionManagement.CreateVersionString(localVersion));
69 | }
70 | }
71 | else
72 | finalStatusMsg = "Version information file not found found; please contact a developer.";
73 | }
74 | catch (WebException wex)
75 | {
76 | /* Web access failed */
77 | MessageBox.Show(wex.ToString(), "Web Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
78 | }
79 | catch (System.ComponentModel.Win32Exception w32ex)
80 | {
81 | /* Win32 exception, ex. no browser found */
82 | if (w32ex.ErrorCode == -2147467259) MessageBox.Show(w32ex.Message, "Process Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
83 | }
84 | catch (Exception ex)
85 | {
86 | /* General failure */
87 | MessageBox.Show(ex.ToString(), "General Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
88 | }
89 |
90 | this.UIThread(() => lblStatus.Text = finalStatusMsg);
91 | Cursor.Current = DefaultCursor;
92 | this.UIThread(() => btnClose.Enabled = true);
93 | }
94 |
95 | private void btnDownload_Click(object sender, EventArgs e)
96 | {
97 | System.Diagnostics.Process.Start(updatePageUrl);
98 | this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/SceneNavi/UpdateCheckDialog.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
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 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/SceneNavi/UpdateData/SceneNavi.txt:
--------------------------------------------------------------------------------
1 | 1.0.1.2561
2 | http://magicstone.de/dzd/progupdates/sn-update.htm
3 | http://magicstone.de/dzd/progupdates/sn-update.rtf
4 |
--------------------------------------------------------------------------------
/SceneNavi/UpdateData/sn-update.rtf:
--------------------------------------------------------------------------------
1 | {\rtf1\ansi\ansicpg1252\deff0\deflang1031\deflangfe1031{\fonttbl{\f0\fswiss\fprq2\fcharset0 Calibri;}{\f1\fnil\fcharset2 Symbol;}}
2 | {\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\nowidctlpar\sl276\slmult1\lang2057\b\f0\fs28 v1.0 Beta 10a ("It Might Be Dead")\par
3 | \b0\fs21\par
4 | \pard{\pntext\f1\'B7\tab}{\*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\'B7}}\nowidctlpar\fi-360\li720\sl276\slmult1 Minor changes\par
5 | \pard\nowidctlpar\sl276\slmult1\b\fs28\par
6 | v1.0 Beta 10 ("Device Not Ready")\par
7 | \b0\fs21\par
8 | \pard{\pntext\f1\'B7\tab}{\*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\'B7}}\nowidctlpar\fi-360\li720\sl276\slmult1 Preliminary support for Majora's Mask\par
9 | {\pntext\f1\'B7\tab}Various other changes\par
10 | \pard\nowidctlpar\sl276\slmult1\b\fs28\par
11 | v1.0 Beta 9b ("Hotfix Redux?")\par
12 | \b0\fs21\par
13 | \pard{\pntext\f1\'B7\tab}{\*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\'B7}}\nowidctlpar\fi-360\li720\sl276\slmult1 Fixed generated GLSL shader code somewhat; should fix float conversion error during shader compilation\par
14 | {\pntext\f1\'B7\tab}Changed combiner emulation initialization; should now only try to initialize a combiner type when selected by user, not all on every startup\par
15 | \pard\nowidctlpar\sl276\slmult1\b\fs28\par
16 | v1.0 Beta 9a ("My First Hotfix")\par
17 | \b0\fs21\par
18 | \pard{\pntext\f1\'B7\tab}{\*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\'B7}}\nowidctlpar\fi-360\li720\sl276\slmult1 Added additional sanity checks to prevent potential EntryPointNotFoundException and NullReferenceException, especially on lower-end hardware\par
19 | {\pntext\f1\'B7\tab}Changed versioning code to allow for hotfixes\par
20 | \pard\nowidctlpar\sl276\slmult1\b\fs28\par
21 | v1.0 Beta 9 ("You've Got Shaders In My Fixed Functions!")\par
22 | \b0\fs21\par
23 | \pard{\pntext\f1\'B7\tab}{\*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\'B7}}\nowidctlpar\fi-360\li720\sl276\slmult1 Added new GLSL-based combiner emulation, still missing certain rendering details (ex. automatic texture-coordinate generation for reflections)\par
24 | {\pntext\f1\'B7\tab}Added support for anti-aliasing and mipmapping in renderer; can be toggled from menu\par
25 | {\pntext\f1\'B7\tab}Changed application configuration to use Nini library instead of .NET Properties.Settings\par
26 | {\pntext\f1\'B7\tab}Fixed various bugs; combiner inaccuracies, display list caching, Scene TreeView generation, mesh header types, etc.\par
27 | {\pntext\f1\'B7\tab}Added experimental help system, displays help string in status bar when hovering over menu items; still needs work\par
28 | {\pntext\f1\'B7\tab}Various other OpenGL-related changes and additions (ex. extension checks)\par
29 | {\pntext\f1\'B7\tab}Various minor GUI changes (ex. status bar appearance, Options menu arrangement)\par
30 | \pard\nowidctlpar\sl276\slmult1\par
31 | }
32 |
--------------------------------------------------------------------------------
/SceneNavi/XML/ActorDefinitions/DL/Database.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/SceneNavi/XML/ActorDefinitions/ZS/Database.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/SceneNavi/XML/GameDataGeneric/DL/ActorNames.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Link / Spawn point
4 |
5 |
--------------------------------------------------------------------------------
/SceneNavi/XML/GameDataGeneric/DL/ObjectNames.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
--------------------------------------------------------------------------------
/SceneNavi/XML/GameDataGeneric/ZL/ObjectNames.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Stalfos
4 | Deku Baba
5 | Various Deku Tree objects
6 | Gohma Larva
7 | Skulltula
8 | Treasure chest
9 | Torches
10 | Grass clump
11 | Keese
12 | Business Scrub
13 | Hint-giving Deku Scrub
14 | Crate
15 | Cuttable signpost
16 | Recovery Heart (GI)
17 | Gold Skulltula Token (GI)
18 | Mad Scrub
19 | Bombable boulder
20 | Time Block
21 | Gravestone
22 | Various Dodongo's Cavern objects
23 | Bomb Flower
24 | Bombable wall
25 | Various Hyrule Field objects
26 | Kaepora Gaebora
27 | Greenery
28 | Peahat
29 | Stalchild
30 | Blue Warp
31 |
32 |
--------------------------------------------------------------------------------
/SceneNavi/XML/GameDataGeneric/ZL/SongNames.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Nothing (1)
4 | Nothing (2)
5 | Overworld (1)
6 | Overworld (2)
7 | Overworld (3)
8 | Overworld (4)
9 | Overworld (5)
10 | Overworld (6)
11 | Overworld (7)
12 | Overworld (8)
13 | Overworld (9)
14 | Overworld (10)
15 | Overworld (11)
16 | Overworld (12)
17 | Overworld (13)
18 | Overworld (14)
19 | Overworld (15)
20 | Overworld (16)
21 | Overworld (17)
22 | Overworld (18)
23 | Overworld (19)
24 | Overworld (20)
25 | Overworld (21)
26 | Overworld (22)
27 | Dungeon
28 | Kakariko Village (Strings)
29 | An Enemy Is Near
30 | The Boss
31 | Deku Tree / Underground
32 | Market
33 | Introduction
34 | Inside My Home
35 | Link Falls
36 | The Boss Is Defeated
37 | I Have Found It!
38 | Ganondorf
39 | Power Up
40 | Minuet of Forest
41 | Jabu-Jabu's Belly
42 | Kakariko Village (Guitar)
43 | Fairy Fountain
44 | Zelda's Courtyard
45 | Fire Temple
46 | Opening the Chest
47 | Forest Temple
48 | Sneaking Through the Castle
49 | Ganon's Organ
50 | Lon Lon Ranch
51 | Goron City
52 | Hyrule Field
53 | Got the Stone
54 | Bolero of Fire
55 | Minuet of Forest
56 | Serenade of Water
57 | Requiem of Spirit
58 | Nocturne of Shadow
59 | The Mini-Boss
60 | Congratulations!
61 | Temple of Time
62 | Got Epona!
63 | Kokiri Forest
64 | Learned a Song
65 | Lost Woods
66 | Spirit Temple
67 | The Race Is On!
68 | Across the Finish Line
69 | Ingo Loses
70 | Gain a Medallion
71 | Saria's Song
72 | Epona's Song
73 | Zelda's Lullaby
74 | Sun Song
75 | Song of Time
76 | Song of Storms
77 | Navi's Flying Around
78 | Deku Tree's Words
79 | Inside the Windmill
80 | Flight of the Goddesses
81 | Games 'n' Fun
82 | Sheik's Harp
83 | Zora Domain
84 | And It's...
85 | Zelda in the Sky
86 | Time Travel
87 | Ganondorf!
88 | Shop 'Til You Drop
89 | Temple of Light
90 | Fairy Fountain
91 | Ice Cavern
92 | The Door of Time
93 | The Owl Speaks
94 | Shadow Temple
95 | Water Temple
96 | The Goddesses Depart
97 | The Sages Unite
98 | Gerudo Valley
99 | The Hag's Shop
100 | Kotake and Koume
101 | The Castle is Falling!
102 | Ganon's Castle
103 | Ganon Attacks
104 | Ganon's Transformation
105 | Zelda Plays Her Song
106 | The End (1)
107 | The End (2)
108 | The End (3)
109 | The End (4)
110 | Ganondorf Attacks
111 | Gotta Catch 'Em All
112 | Nothing
113 |
114 |
--------------------------------------------------------------------------------
/SceneNavi/XML/GameDataGeneric/ZS/ActorNames.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Link / Spawn point
4 |
5 |
--------------------------------------------------------------------------------
/SceneNavi/XML/GameDataGeneric/ZS/ObjectNames.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
--------------------------------------------------------------------------------
/SceneNavi/XML/GameDataSpecific/CZLE0/RoomNames.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
--------------------------------------------------------------------------------
/SceneNavi/XML/GameDataSpecific/CZLE0/SceneNames.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Inside the Deku Tree
4 | Dodongo's Cavern
5 | Inside Jabu-Jabu's Belly
6 | Forest Temple
7 | Fire Temple
8 | Water Temple
9 | Spirit Temple
10 | Shadow Temple
11 | Bottom of the Well
12 | Ice Cavern
13 | Ganon's Castle Tower
14 | Gerudo Training Grounds
15 | Thieves' Hideout
16 | Ganon's Castle
17 | Ganon's Castle Tower (Crumbling)
18 | Ganon's Castle (Crumbling)
19 | Treasure Chest Contest
20 | Inside the Deku Tree (Boss)
21 | Dodongo's Cavern (Boss)
22 | Inside Jabu-Jabu's Belly (Boss)
23 | Forest Temple (Boss)
24 | Fire Temple (Boss)
25 | Water Temple (Boss)
26 | Spirit Temple (Mid-Boss)
27 | Shadow Temple (Boss)
28 | Second-To-Last Boss Ganondorf
29 | Ganondorf, Death Scene
30 | Market Entrance (Day)
31 | Market Entrance (Night)
32 | Market Entrance (Adult)
33 | Back Alley (Day)
34 | Back Alley (Night)
35 | Market (Day)
36 | Market (Night)
37 | Market (Adult)
38 | Temple of Time (Outside, Day)
39 | Temple of Time (Outside, Night)
40 | Temple of Time (Outside, Adult)
41 | Know-it-all Brothers
42 | House of Twins
43 | Mido's House
44 | Saria's House
45 | Kakariko Village House
46 | Back Alley Village House
47 | Kakariko Bazaar
48 | Kokiri Shop
49 | Goron Shop
50 | Zora Shop
51 | Kakariko Potion Shop
52 | Market Potion Shop
53 | Bombchu Shop
54 | Happy Mask Shop
55 | Link's House
56 | Puppy Woman's House
57 | Stables
58 | Impa's House
59 | Lakeside Laboratory
60 | Carpenter's Tent
61 | Dampé's Hut
62 | Great Fairy Fountain
63 | Small Fairy Fountain
64 | Magic Fairy Fountain
65 | Grottos
66 | Grave (1)
67 | Grave (2)
68 | Royal Family's Tomb
69 | Shooting Gallery
70 | Temple of Time Inside
71 | Chamber of Sages
72 | Castle Courtyard (Day)
73 | Castle Courtyard (Night)
74 | Cutscene Map
75 | Dampé's Grave & Kakariko Windmill
76 | Fishing Pond
77 | Zelda's Courtyard
78 | Bombchu Bowling Alley
79 | Talon's House
80 | Lots'o Pots
81 | Granny's Potion Shop
82 | Final Battle against Ganon
83 | Skulltula House
84 | Hyrule Field
85 | Kakariko Village
86 | Kakariko Graveyard
87 | Zora's River
88 | Kokiri Forest
89 | Sacred Forest Meadow
90 | Lake Hylia
91 | Zora's Domain
92 | Zora's Fountain
93 | Gerudo Valley
94 | Lost Woods
95 | Desert Colossus
96 | Gerudo's Fortress
97 | Haunted Wasteland
98 | Hyrule Castle
99 | Death Mountain
100 | Death Mountain Crater
101 | Goron City
102 | Lon Lon Ranch
103 | Ganon's Tower (Outside)
104 |
105 |
--------------------------------------------------------------------------------
/SceneNavi/XML/GameDataSpecific/CZLE0/StageDescriptions.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
--------------------------------------------------------------------------------
/SceneNavi/XML/GameDataSpecific/NZLEF/RoomNames.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 3F-1F: Main hall
5 | 2F: Corridor before Compass
6 | 2F: Compass room
7 | B1F: Center room
8 | B1F: Room before Spike Roller
9 | B1F: Spike Roller room
10 | B1F: Gohma Larva (x8) room
11 | B1F: Gravestone hall
12 | B1F: Small Gold Skulltula room
13 | B2F: Room before boss
14 | 3F: Slingshot room
15 | B2F: Boss room (dummy)
16 |
17 |
--------------------------------------------------------------------------------
/SceneNavi/XML/GameDataSpecific/NZLEF/SceneNames.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Inside the Deku Tree
4 | Dodongo's Cavern
5 | Inside Jabu-Jabu's Belly
6 | Forest Temple
7 | Fire Temple
8 | Water Temple
9 | Spirit Temple
10 | Shadow Temple
11 | Bottom of the Well
12 | Ice Cavern
13 | Ganon's Castle Tower
14 | Gerudo Training Grounds
15 | Thieves' Hideout
16 | Ganon's Castle
17 | Ganon's Castle Tower (Crumbling)
18 | Ganon's Castle (Crumbling)
19 | Treasure Chest Contest
20 | Inside the Deku Tree (Boss)
21 | Dodongo's Cavern (Boss)
22 | Inside Jabu-Jabu's Belly (Boss)
23 | Forest Temple (Boss)
24 | Fire Temple (Boss)
25 | Water Temple (Boss)
26 | Spirit Temple (Mid-Boss)
27 | Shadow Temple (Boss)
28 | Second-To-Last Boss Ganondorf
29 | Ganondorf, Death Scene
30 | Market Entrance (Day)
31 | Market Entrance (Night)
32 | Market Entrance (Adult)
33 | Back Alley (Day)
34 | Back Alley (Night)
35 | Market (Day)
36 | Market (Night)
37 | Market (Adult)
38 | Temple of Time (Outside, Day)
39 | Temple of Time (Outside, Night)
40 | Temple of Time (Outside, Adult)
41 | Know-it-all Brothers
42 | House of Twins
43 | Mido's House
44 | Saria's House
45 | Kakariko Village House
46 | Back Alley Village House
47 | Kakariko Bazaar
48 | Kokiri Shop
49 | Goron Shop
50 | Zora Shop
51 | Kakariko Potion Shop
52 | Market Potion Shop
53 | Bombchu Shop
54 | Happy Mask Shop
55 | Link's House
56 | Puppy Woman's House
57 | Stables
58 | Impa's House
59 | Lakeside Laboratory
60 | Carpenter's Tent
61 | Dampé's Hut
62 | Great Fairy Fountain
63 | Small Fairy Fountain
64 | Magic Fairy Fountain
65 | Grottos
66 | Grave (1)
67 | Grave (2)
68 | Royal Family's Tomb
69 | Shooting Gallery
70 | Temple of Time Inside
71 | Chamber of Sages
72 | Castle Courtyard (Day)
73 | Castle Courtyard (Night)
74 | Cutscene Map
75 | Dampé's Grave & Kakariko Windmill
76 | Fishing Pond
77 | Zelda's Courtyard
78 | Bombchu Bowling Alley
79 | Talon's House
80 | Lots'o Pots
81 | Granny's Potion Shop
82 | Final Battle against Ganon
83 | Skulltula House
84 | Hyrule Field
85 | Kakariko Village
86 | Kakariko Graveyard
87 | Zora's River
88 | Kokiri Forest
89 | Sacred Forest Meadow
90 | Lake Hylia
91 | Zora's Domain
92 | Zora's Fountain
93 | Gerudo Valley
94 | Lost Woods
95 | Desert Colossus
96 | Gerudo's Fortress
97 | Haunted Wasteland
98 | Hyrule Castle
99 | Death Mountain
100 | Death Mountain Crater
101 | Goron City
102 | Lon Lon Ranch
103 | Ganon's Tower (Outside)
104 | Collision Testing Area
105 | Besitu / Treasure Chest Warp
106 | Depth Test
107 | Stalfos Middle Room
108 | Stalfos Boss Room
109 | Dark Link Testing Area
110 | Beta Castle Courtyard
111 | Action Testing Room
112 | Item Testing Room
113 |
114 |
--------------------------------------------------------------------------------
/SceneNavi/XML/GameDataSpecific/NZLEF/StageDescriptions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Normal Gameplay
4 | Normal Gameplay
5 | Normal Gameplay
6 | Cutscene: Meeting Ruto & Zora's Sapphire
7 | Normal Gameplay
8 | Normal Gameplay
9 | Normal Gameplay
10 | Normal Gameplay
11 | Normal Gameplay
12 | Normal Gameplay
13 | Normal Gameplay
14 | Cutscene: Learning Serenade of Water
15 | Normal Gameplay
16 | Normal Gameplay
17 | Normal Gameplay
18 | Normal Gameplay
19 | Normal Gameplay
20 | Normal Gameplay
21 | Normal Gameplay
22 | Normal Gameplay
23 | Normal Gameplay
24 | Normal Gameplay
25 | Normal Gameplay
26 | Normal Gameplay
27 | Normal Gameplay
28 | ??? 1
29 | ??? 2
30 | ??? 3
31 | ??? 4
32 | Normal Gameplay
33 | Normal Gameplay
34 | Normal Gameplay
35 | Normal Gameplay
36 | Normal Gameplay
37 | Normal Gameplay
38 | Normal Gameplay
39 | Normal Gameplay
40 | Normal Gameplay
41 | Normal Gameplay
42 | Normal Gameplay
43 | Normal Gameplay
44 | Normal Gameplay
45 | Normal Gameplay
46 | Normal Gameplay
47 | Normal Gameplay
48 | Normal Gameplay
49 | Normal Gameplay
50 | Normal Gameplay
51 | Normal Gameplay
52 | Normal Gameplay
53 | Normal Gameplay
54 | Normal Gameplay
55 | Normal Gameplay
56 | Normal Gameplay
57 | Normal Gameplay
58 | Normal Gameplay
59 | Normal Gameplay
60 | Normal Gameplay
61 | Cutscene: Meeting Navi
62 | Cutscene: Link's Nightmare
63 | Normal Gameplay
64 | Normal Gameplay
65 | Normal Gameplay
66 | Normal Gameplay
67 | Normal Gameplay
68 | Normal Gameplay
69 | Normal Gameplay
70 | Cutscene: Receiving Spin Attack
71 | Cutscene: Receiving double magic meter
72 | Cutscene: Receiving double defense
73 | Normal Gameplay
74 | Normal Gameplay
75 | Cutscene: Receiving Farore's Wind
76 | Cutscene: Receiving Din's Fire
77 | Cutscene: Receiving Nayru's Love
78 | Normal Gameplay
79 | Normal Gameplay
80 | Normal Gameplay
81 | Normal Gameplay
82 | Cutscene: ??? 1
83 | Cutscene: ??? 2
84 | Normal Gameplay
85 | Cutscene: ??? 1
86 | Cutscene: ??? 2
87 | Cutscene: ??? 3
88 |
89 |
90 |
--------------------------------------------------------------------------------
/SceneNavi/XMLHashTableReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO;
6 | using System.Xml.Linq;
7 | using System.Collections;
8 | using System.ComponentModel;
9 |
10 | namespace SceneNavi
11 | {
12 | public class XMLHashTableReader
13 | {
14 | public Hashtable Names { get; private set; }
15 | public Type KeyType { get; private set; }
16 | public Type ValueType { get; private set; }
17 |
18 | public XMLHashTableReader(string defdir, string fn)
19 | {
20 | Names = new Hashtable();
21 |
22 | string path = Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), defdir);
23 | if (!Directory.Exists(path)) return;
24 |
25 | string file = Path.Combine(path, fn);
26 | if (!File.Exists(file)) return;
27 |
28 | /* Load XDocument */
29 | XDocument xdoc = XDocument.Load(Path.Combine(path, fn));
30 |
31 | /* Fetch Key- and ValueType */
32 | KeyType = Type.GetType((string)xdoc.Root.Attribute("KeyType"));
33 | var keyconv = TypeDescriptor.GetConverter(KeyType);
34 |
35 | ValueType = Type.GetType((string)xdoc.Root.Attribute("ValueType"));
36 | var valconv = TypeDescriptor.GetConverter(ValueType);
37 |
38 | /* Parse elements */
39 | foreach (XElement element in xdoc.Root.Elements())
40 | {
41 | /* Convert values & add to list */
42 | Names.Add(keyconv.ConvertFrom(element.Attribute("Key").Value), valconv.ConvertFrom(element.Value));
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/SceneNavi/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/SceneNavi/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------