Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GlueView] Checkign in GView 2.0 progress.
- Loading branch information
Showing
172 changed files
with
36,828 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
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" /> | ||
</startup> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-1.2.1.0" newVersion="1.2.1.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
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,8 @@ | ||
<Application x:Class="FlatRedBallWpf.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
</Application> |
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,11 @@ | ||
using System.Windows; | ||
|
||
namespace FlatRedBallWpf | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} | ||
} |
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,27 @@ | ||
using FlatRedBall.Glue.SaveClasses; | ||
using FlatRedBall.Screens; | ||
using GlueView2.Patterns; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace GlueView2.AppState | ||
{ | ||
public class GlueViewState : Singleton<GlueViewState> | ||
{ | ||
public GlueProjectSave GlueProject | ||
{ | ||
get; set; | ||
} | ||
|
||
|
||
public Screen CurrentScreenRuntime | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
FRBDK/GlueView2/FlatRedBallWpf/Commands/CurrentScreenManager.cs
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,51 @@ | ||
using FlatRedBall.Screens; | ||
using GlueView2.IO; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace GlueView2.Commands | ||
{ | ||
public class CurrentScreenManager | ||
{ | ||
public Assembly CurrentAssembly | ||
{ | ||
get; | ||
private set; | ||
} | ||
|
||
FilePath projectRootFolder; | ||
|
||
public Screen CurrentScreen | ||
{ | ||
get; | ||
private set; | ||
} | ||
|
||
|
||
|
||
public void HandleLoadedAssembly (Assembly newAssembly, FilePath root) | ||
{ | ||
// todo - unload assembly? | ||
|
||
projectRootFolder = root; | ||
CurrentAssembly = newAssembly; | ||
} | ||
|
||
public void ShowScreen(string screenName) | ||
{ | ||
if(CurrentScreen != null) | ||
{ | ||
CurrentScreen.Destroy(); | ||
} | ||
|
||
CurrentScreen = (Screen)CurrentAssembly.CreateObject(screenName); | ||
|
||
FlatRedBall.IO.FileManager.RelativeDirectory = projectRootFolder.FullPath; | ||
CurrentScreen.Initialize(true); | ||
} | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
FRBDK/GlueView2/FlatRedBallWpf/Commands/GlueViewCommands.cs
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,70 @@ | ||
using FlatRedBall.Glue.SaveClasses; | ||
using FlatRedBall.IO; | ||
using FlatRedBall.Screens; | ||
using FlatRedBallWpf.ScriptLoading; | ||
using GlueView2.AppState; | ||
using GlueView2.IO; | ||
using GlueView2.Patterns; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace GlueView2.Commands | ||
{ | ||
public class GlueViewCommands : Singleton<GlueViewCommands> | ||
{ | ||
CurrentScreenManager currentScreenManager; | ||
public CurrentScreenManager CurrentScreenManager | ||
{ | ||
get | ||
{ | ||
if(currentScreenManager == null) | ||
{ | ||
currentScreenManager = new CurrentScreenManager(); | ||
} | ||
|
||
return currentScreenManager; | ||
} | ||
} | ||
|
||
ScriptLoadingLogic scriptLoadingLogic; | ||
public ScriptLoadingLogic ScriptLoadingLogic | ||
{ | ||
get | ||
{ | ||
if(scriptLoadingLogic == null) | ||
{ | ||
scriptLoadingLogic = new ScriptLoadingLogic(); | ||
} | ||
return scriptLoadingLogic; | ||
} | ||
} | ||
|
||
public GlueProjectSave GlueProject | ||
{ | ||
get; private set; | ||
} | ||
|
||
public void LoadProject(FilePath filePath) | ||
{ | ||
GlueViewState.Self.GlueProject = FileManager.XmlDeserialize<GlueProjectSave>(filePath.FullPath); | ||
|
||
|
||
var directory = filePath.GetDirectoryContainingThis(); | ||
|
||
var loadedGameAssembly = ScriptLoadingLogic.LoadProjectCode(directory.FullPath); | ||
|
||
CurrentScreenManager.HandleLoadedAssembly(loadedGameAssembly, directory); | ||
} | ||
|
||
public void ShowScreen(string screenName) | ||
{ | ||
|
||
CurrentScreenManager.ShowScreen(screenName); | ||
|
||
} | ||
} | ||
} |
Binary file not shown.
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,12 @@ | ||
<UserControl x:Class="FlatRedBallWpf.FlatRedBallControl" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:winforms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" d:DesignHeight="300" SnapsToDevicePixels="True" | ||
d:DesignWidth="300" | ||
mc:Ignorable="d"> | ||
<WindowsFormsHost> | ||
<winforms:Panel x:Name="GamePanel" /> | ||
</WindowsFormsHost> | ||
</UserControl> |
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,17 @@ | ||
using System; | ||
|
||
namespace FlatRedBallWpf | ||
{ | ||
public partial class FlatRedBallControl | ||
{ | ||
public FlatRedBallControl() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public IntPtr Handle | ||
{ | ||
get { return GamePanel.Handle; } | ||
} | ||
} | ||
} |
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,165 @@ | ||
using System; | ||
using System.Windows; | ||
using System.Windows.Forms; | ||
using System.Windows.Threading; | ||
using FlatRedBall; | ||
using FlatRedBall.Graphics; | ||
using FlatRedBall.Input; | ||
using FlatRedBall.Math; | ||
using Microsoft.Xna.Framework; | ||
using Microsoft.Xna.Framework.Graphics; | ||
|
||
namespace FlatRedBallWpf | ||
{ | ||
public class FlatRedBallGameBase : Game | ||
{ | ||
private FlatRedBallControl _frbControl; | ||
|
||
#region Constructors | ||
|
||
public FlatRedBallGameBase(FlatRedBallControl frbControl) | ||
{ | ||
this._frbControl = frbControl; | ||
|
||
// Get the starting size of the control and start listening | ||
// to its Resize events. | ||
_windowHandle = frbControl.Handle; | ||
RenderWidth = (Int32) frbControl.RenderSize.Width; | ||
RenderHeight = (Int32) frbControl.RenderSize.Height; | ||
frbControl.SizeChanged += XnaControlOnSizeChanged; | ||
|
||
// Create the graphics device manager and set the delegate for initializing the graphics device | ||
Graphics = new GraphicsDeviceManager(this); | ||
Graphics.PreferMultiSampling = true; | ||
|
||
Graphics.SynchronizeWithVerticalRetrace = true; | ||
Graphics.PreparingDeviceSettings += PreparingDeviceSettings; | ||
|
||
StartInitialization(); | ||
|
||
Content.RootDirectory = "Content"; | ||
} | ||
|
||
#endregion | ||
|
||
#region Methods | ||
|
||
protected override void Initialize() | ||
{ | ||
// Create a timer that will simulate the gameloop | ||
_timer = new DispatcherTimer(); | ||
_timer.Interval = TimeSpan.FromSeconds(1/60); | ||
_timer.Tick += TimerTick; | ||
_timer.Start(); | ||
|
||
// Create the graphics options and initialize FRB with them | ||
var graphicsOptions = new GraphicsOptions(this, Graphics); | ||
graphicsOptions.SuspendDeviceReset(); | ||
graphicsOptions.ResolutionWidth = RenderWidth; | ||
graphicsOptions.ResolutionHeight = RenderHeight; | ||
graphicsOptions.ResumeDeviceReset(); | ||
FlatRedBallServices.InitializeFlatRedBall(this, Graphics, graphicsOptions); | ||
FlatRedBall.Screens.ScreenManager.Start(typeof(FlatRedBallWpf.Screens.MainScreen)); | ||
|
||
if(false) | ||
{ | ||
// Don't run this because we want the game's camera setup to run | ||
// Put if(false) so that it doesn't get re-generated | ||
CameraSetup.SetupCamera(SpriteManager.Camera, this.Graphics); | ||
} | ||
GlobalContent.Initialize(); | ||
Mouse.ModifyMouseState += HandleModifyMouseState; | ||
|
||
FlatRedBall.Gui.GuiManager.Cursor.CustomIsActive = HandleCustomIsActive; | ||
|
||
base.Initialize(); | ||
} | ||
|
||
private void XnaControlOnSizeChanged(object sender, SizeChangedEventArgs e) | ||
{ | ||
// Get the new size | ||
var newWidth = (Int32) e.NewSize.Width; | ||
var newHeight = (Int32) e.NewSize.Height; | ||
|
||
// Update FRB | ||
FlatRedBallServices.GraphicsOptions.SetResolution(newWidth, newHeight); | ||
Rectangle displayRectangle = new Rectangle(0, 0, newWidth, newHeight); | ||
SpriteManager.Camera.DestinationRectangle = displayRectangle; | ||
|
||
|
||
double unitPerPixel = SpriteManager.Camera.OrthogonalHeight / | ||
SpriteManager.Cameras[0].DestinationRectangle.Height; | ||
|
||
SpriteManager.Camera.OrthogonalHeight = (float)(displayRectangle.Height * unitPerPixel); | ||
SpriteManager.Camera.OrthogonalWidth = (float)(displayRectangle.Width * unitPerPixel); | ||
|
||
|
||
SpriteManager.Camera.UsePixelCoordinates(); | ||
} | ||
|
||
private void StartInitialization() | ||
{ | ||
Initialize(); | ||
} | ||
|
||
private void PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e) | ||
{ | ||
PresentationParameters presentationParams = e.GraphicsDeviceInformation.PresentationParameters; | ||
|
||
presentationParams.BackBufferWidth = RenderWidth; | ||
presentationParams.BackBufferHeight = RenderHeight; | ||
presentationParams.DeviceWindowHandle = _windowHandle; | ||
presentationParams.RenderTargetUsage = RenderTargetUsage.PreserveContents; | ||
} | ||
|
||
private void TimerTick(object sender, EventArgs e) | ||
{ | ||
Tick(); | ||
} | ||
|
||
protected override void EndDraw() | ||
{ | ||
base.EndDraw(); | ||
|
||
GraphicsDevice.Present(); | ||
} | ||
|
||
private void HandleModifyMouseState(ref Microsoft.Xna.Framework.Input.MouseState mouseState) | ||
{ | ||
System.Drawing.Point point = Control.MousePosition; | ||
|
||
var screen = _frbControl.PointFromScreen(new System.Windows.Point(point.X, point.Y)); | ||
var newMouseState = new Microsoft.Xna.Framework.Input.MouseState( | ||
MathFunctions.RoundToInt(screen.X), | ||
MathFunctions.RoundToInt(screen.Y), | ||
mouseState.ScrollWheelValue, | ||
mouseState.LeftButton, | ||
mouseState.MiddleButton, | ||
mouseState.RightButton, | ||
mouseState.XButton1, | ||
mouseState.XButton2); | ||
mouseState = newMouseState; | ||
} | ||
|
||
|
||
private bool HandleCustomIsActive() | ||
{ | ||
return System.Windows.Application.Current.MainWindow.IsActive; | ||
} | ||
|
||
|
||
#endregion | ||
|
||
#region Fields | ||
|
||
protected readonly GraphicsDeviceManager Graphics; | ||
protected readonly Int32 RenderHeight; | ||
protected readonly Int32 RenderWidth; | ||
private readonly IntPtr _windowHandle; | ||
protected GraphicsDeviceManager GraphicsDeviceManager; | ||
protected Boolean IsRenderingPaused; | ||
private DispatcherTimer _timer; | ||
|
||
#endregion | ||
} | ||
} |
Oops, something went wrong.