Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base files from previous repository.
- Loading branch information
1 parent
fe212a7
commit f2c2ac1
Showing
60 changed files
with
7,855 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Thumbs.db | ||
*.obj | ||
*.exe | ||
*.pdb | ||
*.user | ||
*.aps | ||
*.pch | ||
*.vspscc | ||
*_i.c | ||
*_p.c | ||
*.ncb | ||
*.suo | ||
*.sln.docstates | ||
*.tlb | ||
*.tlh | ||
*.bak | ||
*.cache | ||
*.ilk | ||
*.log | ||
[Bb]in | ||
[Dd]ebug*/ | ||
*.lib | ||
*.sbr | ||
obj/ | ||
[Rr]elease*/ | ||
_ReSharper*/ | ||
[Tt]est[Rr]esult* | ||
Built/ |
67 changes: 67 additions & 0 deletions
67
FimbulvetrEngine.Framework/FimbulvetrEngine.Framework.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(SolutionDir)\Vetr.PreSettings.targets" /> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{C8304924-8F55-48F1-A5F3-B434C3B4C556}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>FimbulvetrEngine.Framework</RootNamespace> | ||
<AssemblyName>FimbulvetrEngine.Framework</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<TargetFrameworkProfile /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="OpenTK, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\..\Dependencies\Vetr\OpenTK.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Game.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\FimbulvetrEngine\FimbulvetrEngine.csproj"> | ||
<Project>{7ff70cd4-9b36-41c8-881a-4d94fbe9bbc8}</Project> | ||
<Name>FimbulvetrEngine %28FimbulvetrEngine\FimbulvetrEngine%29</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="$(SolutionDir)\Vetr.PostSettings.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Xml.Linq; | ||
using FimbulvetrEngine.Content; | ||
using FimbulvetrEngine.Graphics; | ||
using FimbulvetrEngine.IO; | ||
using FimbulvetrEngine.Plugin; | ||
using OpenTK; | ||
using OpenTK.Graphics; | ||
|
||
namespace FimbulvetrEngine.Framework | ||
{ | ||
public class Game : GameWindow | ||
{ | ||
public static Game Instance { get; private set; } | ||
|
||
public Game() | ||
: base(800, 600, GraphicsMode.Default, "Fimbulvetr", GameWindowFlags.Default, DisplayDevice.Default, 2, 1, GraphicsContextFlags.Default) | ||
{ | ||
if (Instance != null) | ||
throw new Exception("This class can have only one instance, use Game.Instance."); | ||
|
||
if (Vetr.Instance == null) | ||
new Vetr(); | ||
|
||
Instance = this; | ||
Vetr.Instance.Window = this; | ||
} | ||
|
||
protected override void OnLoad(EventArgs e) | ||
{ | ||
ReadConfiguration(); | ||
Initialize(); | ||
LoadContent(); | ||
} | ||
|
||
protected override void OnUnload(EventArgs e) | ||
{ | ||
UnloadContent(); | ||
} | ||
|
||
protected override void OnClosing(CancelEventArgs e) | ||
{ | ||
// Ensures that we collect all objects | ||
ThreadBoundGC.Collect(); | ||
|
||
Shutdown(e); | ||
} | ||
|
||
protected virtual void ReadConfiguration() | ||
{ | ||
Vetr.Instance.ReadConfiguration(); | ||
PluginManager.Instance.LoadPlugins(); | ||
FileSystemManager.Instance.LoadAll(); | ||
|
||
ReadGameConfig(); | ||
} | ||
|
||
protected void ReadGameConfig() | ||
{ | ||
XElement window = Vetr.Instance.ConfiguartionRoot.Element("Window"); | ||
|
||
if (window != null) | ||
{ | ||
ClientSize = new Size(int.Parse((string)window.Attribute("Width") ?? "800"), int.Parse((string)window.Attribute("Height") ?? "600")); | ||
Title = (string)window.Attribute("Title") ?? "Ragnarök Online - Fimbulwinter Client"; | ||
|
||
// TODO: What should I do here? | ||
X = 100; | ||
Y = 100; | ||
} | ||
} | ||
|
||
protected virtual void Initialize() | ||
{ | ||
|
||
} | ||
|
||
protected virtual void LoadContent() | ||
{ | ||
|
||
} | ||
|
||
protected virtual void UnloadContent() | ||
{ | ||
|
||
} | ||
|
||
protected virtual void Shutdown(CancelEventArgs e) | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("FimbulvetrEngine.Framework")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("FimbulvetrEngine.Framework")] | ||
[assembly: AssemblyCopyright("Copyright © 2012")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("da2b0cd4-e1ff-40d3-8d90-cc4d460e0f71")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
using System.IO; | ||
using System.Threading; | ||
using FimbulvetrEngine.Content.Loaders; | ||
using FimbulvetrEngine.Graphics; | ||
using FimbulvetrEngine.IO; | ||
using QuickFont; | ||
|
||
namespace FimbulvetrEngine.Content | ||
{ | ||
public class ContentManager | ||
{ | ||
public static ContentManager Instance { get; private set; } | ||
|
||
public Dictionary<Type, IContentLoader> ContentLoaders { get; private set; } | ||
public Dictionary<string, WeakReference> Cache { get; private set; } | ||
|
||
public ContentManager() | ||
{ | ||
if (Instance != null) | ||
throw new Exception("Only one instance of ContentManager is allowed, use the Instance property."); | ||
|
||
ContentLoaders = new Dictionary<Type, IContentLoader>(); | ||
Cache = new Dictionary<string, WeakReference>(StringComparer.OrdinalIgnoreCase); | ||
|
||
RegisterDefaultLoaders(); | ||
|
||
Instance = this; | ||
} | ||
|
||
private void RegisterDefaultLoaders() | ||
{ | ||
RegisterLoader<Stream>(new StreamLoader()); | ||
RegisterLoader<String>(new StringLoader()); | ||
RegisterLoader<Texture2D>(new Texture2DLoader()); | ||
RegisterLoader<QFont>(new QFontLoader()); | ||
} | ||
|
||
public void RegisterLoader<T>(IContentLoader loader) | ||
{ | ||
if (!ContentLoaders.ContainsKey(typeof(T))) | ||
ContentLoaders.Add(typeof(T), loader); | ||
} | ||
|
||
public T Load<T>(string contentName, bool background = false) | ||
{ | ||
lock (Cache) | ||
{ | ||
WeakReference cached; | ||
|
||
if (Cache.TryGetValue(contentName, out cached) && cached.IsAlive) | ||
{ | ||
return (T)cached.Target; | ||
} | ||
} | ||
|
||
return LoadNewContent<T>(contentName, background); | ||
} | ||
|
||
private T LoadNewContent<T>(string contentName, bool background) | ||
{ | ||
if (!ContentLoaders.ContainsKey(typeof(T))) | ||
return default(T); | ||
|
||
return (T)ContentLoaders[typeof(T)].LoadContent(this, contentName, background); | ||
} | ||
|
||
public void CacheContent(string contentName, object value) | ||
{ | ||
lock (Cache) | ||
{ | ||
Cache[contentName] = new WeakReference(value); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.IO; | ||
|
||
namespace FimbulvetrEngine.Content | ||
{ | ||
public interface IContentLoader | ||
{ | ||
object LoadContent(ContentManager contentManager, string contentName, bool background); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using FimbulvetrEngine.IO; | ||
using QuickFont; | ||
|
||
namespace FimbulvetrEngine.Content.Loaders | ||
{ | ||
public class QFontLoader : IContentLoader | ||
{ | ||
public object LoadContent(ContentManager contentManager, string contentName, bool background) | ||
{ | ||
Stream stream = FileSystemManager.Instance.OpenStream(contentName); | ||
|
||
if (stream == null) | ||
return null; | ||
|
||
byte[] bytes = new byte[stream.Length]; | ||
stream.Read(bytes, 0, bytes.Length); | ||
stream.Close(); | ||
|
||
IntPtr unmanagedPointer = Marshal.AllocHGlobal(bytes.Length); | ||
Marshal.Copy(bytes, 0, unmanagedPointer, bytes.Length); | ||
|
||
// TODO: Turn this more flexibile, maybee transfer this code to some font manager | ||
QFont result = new QFont(unmanagedPointer, bytes.Length, 8, FontStyle.Regular, new QFontBuilderConfiguration(false)); | ||
|
||
Marshal.FreeHGlobal(unmanagedPointer); | ||
|
||
return result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.IO; | ||
using FimbulvetrEngine.IO; | ||
|
||
namespace FimbulvetrEngine.Content.Loaders | ||
{ | ||
public class StreamLoader : IContentLoader | ||
{ | ||
public object LoadContent(ContentManager contentManager, string contentName, bool background) | ||
{ | ||
Stream stream = FileSystemManager.Instance.OpenStream(contentName); | ||
|
||
if (stream == null) | ||
return null; | ||
|
||
return stream; | ||
} | ||
} | ||
} |
Oops, something went wrong.