- added missing ProjectData.cs
- fixed OGL window size, swap crash when window is closed - closing the run loop when window closed
This commit is contained in:
parent
71bec46d54
commit
2961704067
@ -225,9 +225,13 @@ namespace ANX.Framework.Windows.GL3
|
|||||||
/// Swap the graphics buffers.
|
/// Swap the graphics buffers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Present()
|
public void Present()
|
||||||
|
{
|
||||||
|
if (WindowsGameWindow.Form != null &&
|
||||||
|
WindowsGameWindow.Form.IsDisposed == false)
|
||||||
{
|
{
|
||||||
nativeContext.SwapBuffers();
|
nativeContext.SwapBuffers();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public void DrawIndexedPrimitives(PrimitiveType primitiveType,
|
public void DrawIndexedPrimitives(PrimitiveType primitiveType,
|
||||||
|
@ -53,10 +53,13 @@ namespace ANX.Framework.Windows.GL3
|
|||||||
{
|
{
|
||||||
public class WindowsGameHost : GameHost
|
public class WindowsGameHost : GameHost
|
||||||
{
|
{
|
||||||
|
#region Private
|
||||||
private Game game;
|
private Game game;
|
||||||
private WindowsGameWindow gameWindow;
|
private WindowsGameWindow gameWindow;
|
||||||
private bool isQuitting;
|
private bool isQuitting;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public
|
||||||
public override GameWindow Window
|
public override GameWindow Window
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -64,16 +67,15 @@ namespace ANX.Framework.Windows.GL3
|
|||||||
return this.gameWindow;
|
return this.gameWindow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
public WindowsGameHost(Game setGame)
|
public WindowsGameHost(Game setGame)
|
||||||
: base(setGame)
|
: base(setGame)
|
||||||
{
|
{
|
||||||
isQuitting = false;
|
isQuitting = false;
|
||||||
game = setGame;
|
game = setGame;
|
||||||
gameWindow = new WindowsGameWindow();
|
gameWindow = new WindowsGameWindow();
|
||||||
//Mouse.WindowHandle = gameWindow.Handle;
|
|
||||||
//TouchPanel.WindowHandle = gameWindow.Handle;
|
|
||||||
//gameWindow.IsMouseVisible = game.IsMouseVisible;
|
|
||||||
gameWindow.Activated += delegate
|
gameWindow.Activated += delegate
|
||||||
{
|
{
|
||||||
OnActivated();
|
OnActivated();
|
||||||
@ -82,13 +84,17 @@ namespace ANX.Framework.Windows.GL3
|
|||||||
{
|
{
|
||||||
OnDeactivated();
|
OnDeactivated();
|
||||||
};
|
};
|
||||||
//gameWindow.Suspend += GameWindowSuspend;
|
WindowsGameWindow.Form.FormClosing += delegate
|
||||||
//gameWindow.Resume += GameWindowResume;
|
{
|
||||||
|
isQuitting = true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Run
|
||||||
public override void Run()
|
public override void Run()
|
||||||
{
|
{
|
||||||
gameWindow.Form.Show();
|
WindowsGameWindow.Form.Show();
|
||||||
while (isQuitting == false)
|
while (isQuitting == false)
|
||||||
{
|
{
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
@ -96,10 +102,13 @@ namespace ANX.Framework.Windows.GL3
|
|||||||
}
|
}
|
||||||
gameWindow.Close();
|
gameWindow.Close();
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Exit
|
||||||
public override void Exit()
|
public override void Exit()
|
||||||
{
|
{
|
||||||
isQuitting = true;
|
isQuitting = true;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ namespace ANX.Framework.Windows.GL3
|
|||||||
internal class WindowsGameWindow : ANX.Framework.GameWindow
|
internal class WindowsGameWindow : ANX.Framework.GameWindow
|
||||||
{
|
{
|
||||||
#region Public
|
#region Public
|
||||||
public Form Form
|
internal static Form Form
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
private set;
|
||||||
@ -76,6 +76,43 @@ namespace ANX.Framework.Windows.GL3
|
|||||||
return Form.WindowState == FormWindowState.Minimized;
|
return Form.WindowState == FormWindowState.Minimized;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region AllowUserResizing
|
||||||
|
public override bool AllowUserResizing
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Form.FormBorderStyle == FormBorderStyle.Sizable;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Form.FormBorderStyle = value ?
|
||||||
|
FormBorderStyle.Sizable :
|
||||||
|
FormBorderStyle.Fixed3D;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ClientBounds
|
||||||
|
public override Rectangle ClientBounds
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
System.Drawing.Rectangle rect = Form.ClientRectangle;
|
||||||
|
return new Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CurrentOrientation
|
||||||
|
public override DisplayOrientation CurrentOrientation
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return DisplayOrientation.Default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
@ -84,6 +121,9 @@ namespace ANX.Framework.Windows.GL3
|
|||||||
Form = new Form()
|
Form = new Form()
|
||||||
{
|
{
|
||||||
Text = "ANX Framework",
|
Text = "ANX Framework",
|
||||||
|
MaximizeBox = false,
|
||||||
|
FormBorderStyle = FormBorderStyle.Fixed3D,
|
||||||
|
ClientSize = new System.Drawing.Size(800, 600),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -100,46 +140,30 @@ namespace ANX.Framework.Windows.GL3
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region SetTitle
|
||||||
|
protected override void SetTitle(string title)
|
||||||
|
{
|
||||||
|
Form.Text = title;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public override void BeginScreenDeviceChange(bool willBeFullScreen)
|
public override void BeginScreenDeviceChange(bool willBeFullScreen)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void EndScreenDeviceChange(string screenDeviceName, int clientWidth, int clientHeight)
|
public override void EndScreenDeviceChange(string screenDeviceName,
|
||||||
|
int clientWidth, int clientHeight)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetTitle(string title)
|
public override string ScreenDeviceName
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool AllowUserResizing
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
set
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Rectangle ClientBounds
|
|
||||||
{
|
|
||||||
get { throw new NotImplementedException(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ScreenDeviceName
|
|
||||||
{
|
|
||||||
get { throw new NotImplementedException(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override DisplayOrientation CurrentOrientation
|
|
||||||
{
|
|
||||||
get { throw new NotImplementedException(); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
98
Tools/XNAToANXConverter/ProjectData.cs
Normal file
98
Tools/XNAToANXConverter/ProjectData.cs
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Xml;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace XNAToANXConverter
|
||||||
|
{
|
||||||
|
public static class ProjectData
|
||||||
|
{
|
||||||
|
private const string XnaBaseName = "Microsoft.Xna.Framework";
|
||||||
|
private const string AnxBaseName = "ANX.Framework";
|
||||||
|
|
||||||
|
#region Convert
|
||||||
|
public static void Convert(string sourceFilepath, string destinationFilepath)
|
||||||
|
{
|
||||||
|
string sourceFolderPath =
|
||||||
|
sourceFilepath.Replace(Path.GetFileName(sourceFilepath), "");
|
||||||
|
string destinationFolderPath =
|
||||||
|
destinationFilepath.Replace(Path.GetFileName(destinationFilepath), "");
|
||||||
|
|
||||||
|
if (Directory.Exists(destinationFolderPath) == false)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(destinationFolderPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
XDocument doc = XDocument.Load(sourceFilepath);
|
||||||
|
XElement root = doc.Root;
|
||||||
|
foreach (XElement propertyGroup in root.Elements())
|
||||||
|
{
|
||||||
|
if (propertyGroup.Name.LocalName != "ItemGroup")
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<XElement> elements = new List<XElement>(propertyGroup.Elements());
|
||||||
|
foreach (XElement item in elements)
|
||||||
|
{
|
||||||
|
if (item.Name.LocalName == "Reference")
|
||||||
|
{
|
||||||
|
#region Process Reference
|
||||||
|
string assemblyPath = item.Attribute("Include").Value;
|
||||||
|
if (assemblyPath.Contains(XnaBaseName))
|
||||||
|
{
|
||||||
|
item.Remove();
|
||||||
|
|
||||||
|
string anxPath = assemblyPath.Replace(XnaBaseName, AnxBaseName);
|
||||||
|
if (anxPath.Contains(", Version"))
|
||||||
|
{
|
||||||
|
anxPath = anxPath.Substring(0, anxPath.IndexOf(',')) + ".dll";
|
||||||
|
}
|
||||||
|
propertyGroup.Add(new XElement("Reference",
|
||||||
|
new XAttribute("Include", anxPath)));
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
else if (item.Name.LocalName == "Compile")
|
||||||
|
{
|
||||||
|
#region Process Compile
|
||||||
|
string codeFilepath = item.Attribute("Include").Value;
|
||||||
|
string absolutePath = Path.Combine(sourceFolderPath, codeFilepath);
|
||||||
|
string text = File.ReadAllText(absolutePath);
|
||||||
|
|
||||||
|
text = text.Replace(XnaBaseName, AnxBaseName);
|
||||||
|
|
||||||
|
string destCodeFolderPath = codeFilepath.Replace(
|
||||||
|
Path.GetFileName(codeFilepath), "");
|
||||||
|
|
||||||
|
destCodeFolderPath = Path.Combine(destinationFolderPath,
|
||||||
|
destCodeFolderPath);
|
||||||
|
if (Directory.Exists(destCodeFolderPath) == false)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(destCodeFolderPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
File.WriteAllText(Path.Combine(destinationFolderPath,
|
||||||
|
codeFilepath), text);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
else if (item.Name.LocalName == "BootstrapperPackage")
|
||||||
|
{
|
||||||
|
#region Process BootstrapperPackage
|
||||||
|
// Remove all bootstrapper tasks for XNA.
|
||||||
|
string includeName = item.Attribute("Include").Value;
|
||||||
|
if (includeName.Contains(XnaBaseName))
|
||||||
|
{
|
||||||
|
item.Remove();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
doc.Save(destinationFilepath);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user