Remove invalidate as it didn't fix issues on linux, other minor cleanup.

This commit is contained in:
UnknownShadow200 2015-10-21 06:15:49 +11:00
parent bc147bc295
commit e726a4aef8
27 changed files with 104 additions and 184 deletions

View File

@ -75,19 +75,19 @@ namespace ClassicalSharp {
format.Trimming = StringTrimming.None; format.Trimming = StringTrimming.None;
} }
public override void DrawRect( Color colour, int x, int y, int width, int height ) { public override void DrawRect( FastColour colour, int x, int y, int width, int height ) {
Brush brush = GetOrCreateBrush( colour ); Brush brush = GetOrCreateBrush( colour );
g.FillRectangle( brush, x, y, width, height ); g.FillRectangle( brush, x, y, width, height );
} }
public override void DrawRectBounds( Color colour, float lineWidth, int x, int y, int width, int height ) { public override void DrawRectBounds( FastColour colour, float lineWidth, int x, int y, int width, int height ) {
using( Pen pen = new Pen( colour, lineWidth ) ) { using( Pen pen = new Pen( colour, lineWidth ) ) {
pen.Alignment = PenAlignment.Inset; pen.Alignment = PenAlignment.Inset;
g.DrawRectangle( pen, x, y, width, height ); g.DrawRectangle( pen, x, y, width, height );
} }
} }
public override void DrawRoundedRect( Color colour, float radius, float x, float y, float width, float height ) { public override void DrawRoundedRect( FastColour colour, float radius, float x, float y, float width, float height ) {
GraphicsPath path = new GraphicsPath(); GraphicsPath path = new GraphicsPath();
float x1 = x, y1 = y, x2 = x + width, y2 = y + height; float x1 = x, y1 = y, x2 = x + width, y2 = y + height;
@ -107,11 +107,11 @@ namespace ClassicalSharp {
path.Dispose(); path.Dispose();
} }
public override void Clear( Color colour ) { public override void Clear( FastColour colour ) {
g.Clear( colour ); g.Clear( colour );
} }
public override void Clear( Color colour, int x, int y, int width, int height ) { public override void Clear( FastColour colour, int x, int y, int width, int height ) {
g.SmoothingMode = SmoothingMode.None; g.SmoothingMode = SmoothingMode.None;
Brush brush = GetOrCreateBrush( colour ); Brush brush = GetOrCreateBrush( colour );
g.FillRectangle( brush, x, y, width, height ); g.FillRectangle( brush, x, y, width, height );

View File

@ -26,21 +26,21 @@ namespace ClassicalSharp {
/// <summary> Draws a 2D flat rectangle of the specified dimensions at the /// <summary> Draws a 2D flat rectangle of the specified dimensions at the
/// specified coordinates in the currently bound bitmap. </summary> /// specified coordinates in the currently bound bitmap. </summary>
public abstract void DrawRect( Color colour, int x, int y, int width, int height ); public abstract void DrawRect( FastColour colour, int x, int y, int width, int height );
/// <summary> Draws the outline of a 2D flat rectangle of the specified dimensions /// <summary> Draws the outline of a 2D flat rectangle of the specified dimensions
/// at the specified coordinates in the currently bound bitmap. </summary> /// at the specified coordinates in the currently bound bitmap. </summary>
public abstract void DrawRectBounds( Color colour, float lineWidth, int x, int y, int width, int height ); public abstract void DrawRectBounds( FastColour colour, float lineWidth, int x, int y, int width, int height );
/// <summary> Draws a 2D rectangle with rounded borders of the specified dimensions /// <summary> Draws a 2D rectangle with rounded borders of the specified dimensions
/// at the specified coordinates in the currently bound bitmap. </summary> /// at the specified coordinates in the currently bound bitmap. </summary>
public abstract void DrawRoundedRect( Color colour, float radius, float x, float y, float width, float height ); public abstract void DrawRoundedRect( FastColour colour, float radius, float x, float y, float width, float height );
/// <summary> Clears the entire bound bitmap to the specified colour. </summary> /// <summary> Clears the entire bound bitmap to the specified colour. </summary>
public abstract void Clear( Color colour ); public abstract void Clear( FastColour colour );
/// <summary> Clears the entire bound bitmap to the specified colour. </summary> /// <summary> Clears the entire bound bitmap to the specified colour. </summary>
public abstract void Clear( Color colour, int x, int y, int width, int height ); public abstract void Clear( FastColour colour, int x, int y, int width, int height );
/// <summary> Disposes of any resources used by this class that are associated with the underlying bitmap. </summary> /// <summary> Disposes of any resources used by this class that are associated with the underlying bitmap. </summary>
public abstract void Dispose(); public abstract void Dispose();
@ -85,12 +85,11 @@ namespace ClassicalSharp {
} }
protected List<TextPart> parts = new List<TextPart>( 64 ); protected List<TextPart> parts = new List<TextPart>( 64 );
protected static Color white = Color.FromArgb( 255, 255, 255 );
protected struct TextPart { protected struct TextPart {
public string Text; public string Text;
public Color TextColour; public FastColour TextColour;
public TextPart( string text, Color col ) { public TextPart( string text, FastColour col ) {
Text = text; Text = text;
TextColour = col; TextColour = col;
} }
@ -100,7 +99,7 @@ namespace ClassicalSharp {
parts.Clear(); parts.Clear();
if( String.IsNullOrEmpty( value ) ) { if( String.IsNullOrEmpty( value ) ) {
} else if( value.IndexOf( '&' ) == -1 ) { } else if( value.IndexOf( '&' ) == -1 ) {
parts.Add( new TextPart( value, white ) ); parts.Add( new TextPart( value, FastColour.White ) );
} else { } else {
SplitText( value ); SplitText( value );
} }
@ -114,7 +113,7 @@ namespace ClassicalSharp {
if( partLength > 0 ) { if( partLength > 0 ) {
string part = value.Substring( i, partLength ); string part = value.Substring( i, partLength );
Color col = Color.FromArgb( FastColour col = new FastColour(
191 * ((code >> 2) & 1) + 64 * (code >> 3), 191 * ((code >> 2) & 1) + 64 * (code >> 3),
191 * ((code >> 1) & 1) + 64 * (code >> 3), 191 * ((code >> 1) & 1) + 64 * (code >> 3),
191 * ((code >> 0) & 1) + 64 * (code >> 3) ); 191 * ((code >> 0) & 1) + 64 * (code >> 3) );

View File

@ -26,7 +26,7 @@ namespace ClassicalSharp {
graphicsApi.Draw2DQuad( startX - 5, startY - 30 - 5, blocksPerRow * blockSize + 10, graphicsApi.Draw2DQuad( startX - 5, startY - 30 - 5, blocksPerRow * blockSize + 10,
rows * blockSize + 30 + 10, backCol ); rows * blockSize + 30 + 10, backCol );
graphicsApi.Texturing = true; graphicsApi.Texturing = true;
graphicsApi.BindTexture( game.TerrainAtlas.TexId ); graphicsApi.BindTexture( game.TerrainAtlas.TexId );
graphicsApi.BeginVbBatch( VertexFormat.Pos3fTex2fCol4b ); graphicsApi.BeginVbBatch( VertexFormat.Pos3fTex2fCol4b );
for( int i = 0; i < blocksTable.Length; i++ ) { for( int i = 0; i < blocksTable.Length; i++ ) {

View File

@ -14,7 +14,7 @@ namespace ClassicalSharp {
this.message = message; this.message = message;
titleFont = new Font( "Arial", 16, FontStyle.Bold ); titleFont = new Font( "Arial", 16, FontStyle.Bold );
messageFont = new Font( "Arial", 14, FontStyle.Regular ); messageFont = new Font( "Arial", 14, FontStyle.Regular );
} }
public override void Render( double delta ) { public override void Render( double delta ) {
graphicsApi.Texturing = true; graphicsApi.Texturing = true;

View File

@ -76,7 +76,7 @@ namespace ClassicalSharp {
public override bool HandlesKeyDown( Key key ) { public override bool HandlesKeyDown( Key key ) {
if( key == Key.Escape ) { if( key == Key.Escape ) {
game.SetNewScreen( new NormalScreen( game ) ); game.SetNewScreen( new NormalScreen( game ) );
} else if( key == Key.Left ) { } else if( key == Key.Left ) {
PageClick( false ); PageClick( false );
} else if( key == Key.Right ) { } else if( key == Key.Right ) {

View File

@ -24,7 +24,7 @@ namespace ClassicalSharp {
graphicsApi.Texturing = true; graphicsApi.Texturing = true;
fpsTextWidget.Render( delta ); fpsTextWidget.Render( delta );
if( game.activeScreen is NormalScreen ) { if( game.activeScreen is NormalScreen ) {
UpdateHackState( false ); UpdateHackState( false );
DrawPosition(); DrawPosition();
hackStatesWidget.Render( delta ); hackStatesWidget.Render( delta );
} }

View File

@ -19,7 +19,7 @@ namespace ClassicalSharp {
float progX, progY = 100f; float progX, progY = 100f;
int progWidth = 200, progHeight = 40; int progWidth = 200, progHeight = 40;
public override void Render( double delta ) { public override void Render( double delta ) {
graphicsApi.ClearColour( FastColour.Black ); graphicsApi.ClearColour( FastColour.Black );
graphicsApi.Texturing = true; graphicsApi.Texturing = true;
titleWidget.Render( delta ); titleWidget.Render( delta );
@ -39,9 +39,9 @@ namespace ClassicalSharp {
using( Bitmap bmp = IDrawer2D.CreatePow2Bitmap( size ) ) { using( Bitmap bmp = IDrawer2D.CreatePow2Bitmap( size ) ) {
using( IDrawer2D drawer = game.Drawer2D ) { using( IDrawer2D drawer = game.Drawer2D ) {
drawer.SetBitmap( bmp ); drawer.SetBitmap( bmp );
drawer.DrawRectBounds( Color.White, 3f, 0, 0, progWidth, progHeight ); drawer.DrawRectBounds( FastColour.White, 3f, 0, 0, progWidth, progHeight );
progressBoxTexture = drawer.Make2DTexture( bmp, size, (int)progX, (int)progY ); progressBoxTexture = drawer.Make2DTexture( bmp, size, (int)progX, (int)progY );
} }
} }
game.Events.MapLoading += MapLoading; game.Events.MapLoading += MapLoading;
} }

View File

@ -29,7 +29,7 @@ namespace ClassicalSharp {
g => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer; g => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer;
return env == null ? "(not active)" : env.CloudsSpeed.ToString(); }, return env == null ? "(not active)" : env.CloudsSpeed.ToString(); },
(g, v) => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer; (g, v) => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer;
if( env != null ) if( env != null )
env.CloudsSpeed = Single.Parse( v ); } ), env.CloudsSpeed = Single.Parse( v ); } ),
Make( -140, 50, "Clouds height", Anchor.Centre, OnWidgetClick, Make( -140, 50, "Clouds height", Anchor.Centre, OnWidgetClick,

View File

@ -75,8 +75,8 @@ namespace ClassicalSharp {
const string format = "&eFailed to change mapping \"{0}\". &c({1})"; const string format = "&eFailed to change mapping \"{0}\". &c({1})";
statusWidget.SetText( String.Format( format, descriptions[index], reason ) ); statusWidget.SetText( String.Format( format, descriptions[index], reason ) );
} else { } else {
const string format = "&eChanged mapping \"{0}\" from &7{1} &eto &7{2}&e."; const string format = "&eChanged mapping \"{0}\" from &7{1} &eto &7{2}&e.";
statusWidget.SetText( String.Format( format, descriptions[index], oldKey, key ) ); statusWidget.SetText( String.Format( format, descriptions[index], oldKey, key ) );
string text = descriptions[index] + " : " + keyNames[(int)key]; string text = descriptions[index] + " : " + keyNames[(int)key];
widget.SetText( text ); widget.SetText( text );
game.Keys[mapping] = key; game.Keys[mapping] = key;

View File

@ -23,7 +23,7 @@ namespace ClassicalSharp {
public override void Init() { public override void Init() {
base.Init(); base.Init();
buttons[buttons.Length - 1] = buttons[buttons.Length - 1] =
Make( 0, 5, "Back to menu", (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ); Make( 0, 5, "Back to menu", (g, w) => g.SetNewScreen( new PauseScreen( g ) ) );
} }
@ -45,7 +45,7 @@ namespace ClassicalSharp {
} else if( path.EndsWith( ".fcm" ) ) { } else if( path.EndsWith( ".fcm" ) ) {
mapFile = new MapFcm3(); mapFile = new MapFcm3();
} else if( path.EndsWith( ".cw" ) ) { } else if( path.EndsWith( ".cw" ) ) {
mapFile = new MapCw(); mapFile = new MapCw();
} }
try { try {

View File

@ -42,7 +42,7 @@ namespace ClassicalSharp {
if( key == Key.Escape ) { if( key == Key.Escape ) {
game.SetNewScreen( new NormalScreen( game ) ); game.SetNewScreen( new NormalScreen( game ) );
return true; return true;
} else if( (key == Key.Enter || key == Key.KeypadEnter) } else if( (key == Key.Enter || key == Key.KeypadEnter)
&& inputWidget != null ) { && inputWidget != null ) {
ChangeSetting(); ChangeSetting();
return true; return true;

View File

@ -7,7 +7,7 @@ namespace ClassicalSharp {
public abstract class MenuScreen : Screen { public abstract class MenuScreen : Screen {
public MenuScreen( Game game ) : base( game ) { public MenuScreen( Game game ) : base( game ) {
} }
protected ButtonWidget[] buttons; protected ButtonWidget[] buttons;
protected Font titleFont, regularFont; protected Font titleFont, regularFont;
@ -36,7 +36,7 @@ namespace ClassicalSharp {
for( int i = 0; i < buttons.Length; i++ ) { for( int i = 0; i < buttons.Length; i++ ) {
if( buttons[i] == null ) continue; if( buttons[i] == null ) continue;
buttons[i].OnResize( oldWidth, oldHeight, width, height ); buttons[i].OnResize( oldWidth, oldHeight, width, height );
} }
} }
public override bool HandlesAllInput { public override bool HandlesAllInput {
@ -61,7 +61,7 @@ namespace ClassicalSharp {
if( buttons[i] == null ) continue; if( buttons[i] == null ) continue;
buttons[i].Active = false; buttons[i].Active = false;
} }
for( int i = 0; i < buttons.Length; i++ ) { for( int i = 0; i < buttons.Length; i++ ) {
ButtonWidget widget = buttons[i]; ButtonWidget widget = buttons[i];
if( widget != null && widget.Bounds.Contains( mouseX, mouseY ) ) { if( widget != null && widget.Bounds.Contains( mouseX, mouseY ) ) {
@ -86,7 +86,7 @@ namespace ClassicalSharp {
return true; return true;
} }
protected virtual void WidgetSelected( ButtonWidget widget ) { protected virtual void WidgetSelected( ButtonWidget widget ) {
} }
} }
} }

View File

@ -29,11 +29,11 @@ namespace ClassicalSharp {
Make( 140, -50, "Mouse sensitivity", Anchor.Centre, OnWidgetClick, Make( 140, -50, "Mouse sensitivity", Anchor.Centre, OnWidgetClick,
g => g.MouseSensitivity.ToString(), g => g.MouseSensitivity.ToString(),
(g, v) => { g.MouseSensitivity = Int32.Parse( v ); (g, v) => { g.MouseSensitivity = Int32.Parse( v );
Options.Set( OptionsKey.Sensitivity, v ); } ), Options.Set( OptionsKey.Sensitivity, v ); } ),
Make( 140, 0, "Chat font size", Anchor.Centre, OnWidgetClick, Make( 140, 0, "Chat font size", Anchor.Centre, OnWidgetClick,
g => g.Chat.FontSize.ToString(), g => g.Chat.FontSize.ToString(),
(g, v) => { g.Chat.FontSize = Int32.Parse( v ); (g, v) => { g.Chat.FontSize = Int32.Parse( v );
Options.Set( OptionsKey.FontSize, v ); } ), Options.Set( OptionsKey.FontSize, v ); } ),
Make( 140, 50, "Key mappings", Anchor.Centre, Make( 140, 50, "Key mappings", Anchor.Centre,

View File

@ -91,8 +91,8 @@ namespace ClassicalSharp {
// NOTE: We don't immediately save here, because otherwise the 'saving...' // NOTE: We don't immediately save here, because otherwise the 'saving...'
// will not be rendered in time because saving is done on the main thread. // will not be rendered in time because saving is done on the main thread.
MakeDescWidget( "Saving.." ); MakeDescWidget( "Saving.." );
textPath = text; textPath = text;
} }
} }
string textPath; string textPath;

View File

@ -21,7 +21,7 @@ namespace ClassicalSharp {
public override void Init() { public override void Init() {
base.Init(); base.Init();
buttons[buttons.Length - 1] = buttons[buttons.Length - 1] =
Make( 0, 5, "Back to menu", (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ); Make( 0, 5, "Back to menu", (g, w) => g.SetNewScreen( new PauseScreen( g ) ) );
} }

View File

@ -114,9 +114,9 @@ namespace ClassicalSharp {
} }
protected void SortPlayerInfo() { protected void SortPlayerInfo() {
SortInfoList(); SortInfoList();
CalcMaxColumnHeight(); CalcMaxColumnHeight();
int y = game.Height / 2 - yHeight / 2; int y = game.Height / 2 - yHeight / 2;
int midCol = columns / 2; int midCol = columns / 2;
int centreX = game.Width / 2; int centreX = game.Width / 2;
@ -124,13 +124,13 @@ namespace ClassicalSharp {
if( columns % 2 != 0 ) { if( columns % 2 != 0 ) {
// For an odd number of columns, the middle column is centred. // For an odd number of columns, the middle column is centred.
offset = Utils.CeilDiv( GetColumnWidth( midCol ), 2 ); offset = Utils.CeilDiv( GetColumnWidth( midCol ), 2 );
} }
xMin = centreX - offset; xMin = centreX - offset;
for( int col = midCol - 1; col >= 0; col-- ) { for( int col = midCol - 1; col >= 0; col-- ) {
xMin -= GetColumnWidth( col ); xMin -= GetColumnWidth( col );
SetColumnPos( col, xMin, y ); SetColumnPos( col, xMin, y );
} }
xMax = centreX - offset; xMax = centreX - offset;
for( int col = midCol; col < columns; col++ ) { for( int col = midCol; col < columns; col++ ) {
SetColumnPos( col, xMax, y ); SetColumnPos( col, xMax, y );

View File

@ -301,8 +301,8 @@ namespace ClassicalSharp {
Graphics.SetMatrixMode( MatrixType.Modelview ); Graphics.SetMatrixMode( MatrixType.Modelview );
} }
protected override void OnResize( EventArgs e ) { protected override void OnResize( object sender, EventArgs e ) {
base.OnResize( e ); base.OnResize( sender, e );
Graphics.OnWindowResize( this ); Graphics.OnWindowResize( this );
UpdateProjection(); UpdateProjection();
if( activeScreen != null ) { if( activeScreen != null ) {

View File

@ -1,5 +1,5 @@
using System; using System;
using System.Drawing; using System.Drawing;
namespace ClassicalSharp { namespace ClassicalSharp {
@ -38,9 +38,9 @@ namespace ClassicalSharp {
} }
public FastColour( int argb ) { public FastColour( int argb ) {
A = (byte)( argb >> 24 ); A = (byte)(argb >> 24);
R = (byte)( argb >> 16 ); R = (byte)(argb >> 16);
G = (byte)( argb >> 8 ); G = (byte)(argb >> 8);
B = (byte)argb; B = (byte)argb;
} }
@ -53,14 +53,14 @@ namespace ClassicalSharp {
public static FastColour Scale( FastColour value, float t ) { public static FastColour Scale( FastColour value, float t ) {
FastColour result = value; FastColour result = value;
result.R = (byte)( value.R * t ); result.R = (byte)(value.R * t);
result.G = (byte)( value.G * t ); result.G = (byte)(value.G * t);
result.B = (byte)( value.B * t ); result.B = (byte)(value.B * t);
return result; return result;
} }
public static void GetShaded( FastColour normal, ref FastColour xSide, public static void GetShaded( FastColour normal, ref FastColour xSide,
ref FastColour zSide, ref FastColour yBottom ) { ref FastColour zSide, ref FastColour yBottom ) {
xSide = FastColour.Scale( normal, 0.6f ); xSide = FastColour.Scale( normal, 0.6f );
zSide = FastColour.Scale( normal, 0.8f ); zSide = FastColour.Scale( normal, 0.8f );
yBottom = FastColour.Scale( normal, 0.5f ); yBottom = FastColour.Scale( normal, 0.5f );

View File

@ -68,7 +68,7 @@ namespace Launcher2 {
MakeTextInputAt( Get( widgetIndex ), 270, -25, 5 ); MakeTextInputAt( Get( widgetIndex ), 270, -25, 5 );
MakeTextAt( inputFont, "../play/", -210, 55 ); MakeTextAt( inputFont, "../play/", -210, 55 );
MakeTextInputAt( "61f27b1f0a3dcb546b650b87a3e17436"/*Get( 3 )*/, 320, -20, 50 ); MakeTextInputAt( Get( 3 ), 320, -20, 50 );
MakeButtonAt( "Connect", 100, 30, 180, 5, ConnectToServer ); MakeButtonAt( "Connect", 100, 30, 180, 5, ConnectToServer );
MakeButtonAt( "Back", 70, 30, 195, 50, MakeButtonAt( "Back", 70, 30, 195, 50,

View File

@ -88,7 +88,6 @@ namespace Launcher2 {
Dirty = false; Dirty = false;
screen.Dirty = false; screen.Dirty = false;
screenGraphics.DrawImage( Framebuffer, 0, 0, Framebuffer.Width, Framebuffer.Height ); screenGraphics.DrawImage( Framebuffer, 0, 0, Framebuffer.Width, Framebuffer.Height );
Window.Invalidate();
} }
internal static FastColour clearColour = new FastColour( 30, 30, 30 ); internal static FastColour clearColour = new FastColour( 30, 30, 30 );

View File

@ -24,13 +24,13 @@ namespace Launcher2 {
} }
public static string Decode( string encoded, string key ) { public static string Decode( string encoded, string key ) {
if( String.IsNullOrEmpty( encoded ) || String.IsNullOrEmpty( key ) ) return null; if( String.IsNullOrEmpty( encoded ) || String.IsNullOrEmpty( key ) ) return "";
byte[] data; byte[] data;
try { try {
data = Convert.FromBase64String( encoded ); data = Convert.FromBase64String( encoded );
} catch( FormatException ) { } catch( FormatException ) {
return null; return "";
} }
try { try {
@ -40,7 +40,7 @@ namespace Launcher2 {
c[i] = (char)data[i]; c[i] = (char)data[i];
return new String( c ); return new String( c );
} catch { } catch {
if( encoded.Length > 64 || data.Length > 64 ) return null; if( encoded.Length > 64 || data.Length > 64 ) return "";
char[] c = new char[data.Length]; char[] c = new char[data.Length];
for( int i = 0; i < c.Length; i++ ) for( int i = 0; i < c.Length; i++ )

View File

@ -99,7 +99,6 @@ namespace OpenTK
glContext.MakeCurrent(WindowInfo); glContext.MakeCurrent(WindowInfo);
glContext.LoadAll(); glContext.LoadAll();
VSync = true; VSync = true;
//glWindow.WindowInfoChanged += delegate(object sender, EventArgs e) { OnWindowInfoChangedInternal(e); };
} catch (Exception e) { } catch (Exception e) {
Debug.Print(e.ToString()); Debug.Print(e.ToString());
base.Dispose(); base.Dispose();
@ -141,11 +140,11 @@ namespace OpenTK
/// <param name="e"> /// <param name="e">
/// The <see cref="System.ComponentModel.CancelEventArgs" /> for this event. /// The <see cref="System.ComponentModel.CancelEventArgs" /> for this event.
/// Set e.Cancel to true in order to stop the GameWindow from closing.</param> /// Set e.Cancel to true in order to stop the GameWindow from closing.</param>
protected override void OnClosing(System.ComponentModel.CancelEventArgs e) { protected override void OnClosing(object sender, System.ComponentModel.CancelEventArgs e) {
base.OnClosing(e); base.OnClosing(sender, e);
if (!e.Cancel) { if (!e.Cancel) {
isExiting = true; isExiting = true;
OnUnloadInternal(EventArgs.Empty); OnUnload(EventArgs.Empty);
} }
} }
@ -170,8 +169,8 @@ namespace OpenTK
EnsureUndisposed(); EnsureUndisposed();
try { try {
Visible = true; // Make sure the GameWindow is visible. Visible = true; // Make sure the GameWindow is visible.
OnLoadInternal(EventArgs.Empty); OnLoad(EventArgs.Empty);
OnResize(EventArgs.Empty); OnResize(null, EventArgs.Empty);
Debug.Print("Entering main loop."); Debug.Print("Entering main loop.");
render_watch.Start(); render_watch.Start();
@ -297,24 +296,11 @@ namespace OpenTK
if (RenderFrame != null) RenderFrame(this, e); if (RenderFrame != null) RenderFrame(this, e);
} }
/// <summary> Called when the WindowInfo for this GameWindow has changed.</summary> protected override void OnResize(object sender, EventArgs e) {
/// <param name="e">Not used.</param> base.OnResize(sender, e);
protected virtual void OnWindowInfoChanged(EventArgs e) { }
protected override void OnResize(EventArgs e) {
base.OnResize(e);
glContext.Update(base.WindowInfo); glContext.Update(base.WindowInfo);
} }
private void OnLoadInternal(EventArgs e) { OnLoad(e); }
private void OnRenderFrameInternal(FrameEventArgs e) { if (Exists && !isExiting) OnRenderFrame(e); } private void OnRenderFrameInternal(FrameEventArgs e) { if (Exists && !isExiting) OnRenderFrame(e); }
private void OnUnloadInternal(EventArgs e) { OnUnload(e); }
private void OnWindowInfoChangedInternal(EventArgs e) {
glContext.MakeCurrent(WindowInfo);
OnWindowInfoChanged(e);
}
} }
} }

View File

@ -92,9 +92,6 @@ namespace OpenTK {
/// <summary> Processes pending window events. </summary> /// <summary> Processes pending window events. </summary>
void ProcessEvents(); void ProcessEvents();
/// <summary> Causes the window to be immediately redrawn. </summary>
void Invalidate();
/// <summary> Transforms the specified point from screen to client coordinates. </summary> /// <summary> Transforms the specified point from screen to client coordinates. </summary>
/// <param name="point"> A <see cref="System.Drawing.Point"/> to transform. </param> /// <param name="point"> A <see cref="System.Drawing.Point"/> to transform. </param>
/// <returns> The point transformed to client coordinates. </returns> /// <returns> The point transformed to client coordinates. </returns>

View File

@ -123,11 +123,6 @@ namespace OpenTK {
ProcessEvents(false); ProcessEvents(false);
} }
/// <summary> Causes the window to be immediately redrawn. </summary>
public void Invalidate() {
implementation.Invalidate();
}
/// <summary> Gets or sets a <see cref="System.Drawing.Rectangle"/> structure that contains the external bounds of this window, in screen coordinates. /// <summary> Gets or sets a <see cref="System.Drawing.Rectangle"/> structure that contains the external bounds of this window, in screen coordinates.
/// External bounds include the title bar, borders and drawing area of the window. </summary> /// External bounds include the title bar, borders and drawing area of the window. </summary>
public Rectangle Bounds { public Rectangle Bounds {
@ -314,80 +309,71 @@ namespace OpenTK {
/// <summary> Called when the NativeWindow has closed. </summary> /// <summary> Called when the NativeWindow has closed. </summary>
/// <param name="e">Not used.</param> /// <param name="e">Not used.</param>
protected virtual void OnClosed(EventArgs e) { protected virtual void OnClosed(object sender, EventArgs e) {
if (Closed != null) Closed(this, e); if (Closed != null) Closed(this, e);
} }
/// <summary> Called when the NativeWindow is about to close. </summary> /// <summary> Called when the NativeWindow is about to close. </summary>
/// <param name="e"> The <see cref="System.ComponentModel.CancelEventArgs" /> for this event. /// <param name="e"> The <see cref="System.ComponentModel.CancelEventArgs" /> for this event.
/// Set e.Cancel to true in order to stop the NativeWindow from closing.</param> /// Set e.Cancel to true in order to stop the NativeWindow from closing.</param>
protected virtual void OnClosing(CancelEventArgs e) { protected virtual void OnClosing(object sender, CancelEventArgs e) {
if (Closing != null) Closing(this, e); if (Closing != null) Closing(this, e);
} }
/// <summary> Called when the NativeWindow is disposed. </summary> /// <summary> Called when the NativeWindow is disposed. </summary>
/// <param name="e">Not used.</param> protected virtual void OnDisposed(object sender, EventArgs e) {
protected virtual void OnDisposed(EventArgs e) {
if (Disposed != null) Disposed(this, e); if (Disposed != null) Disposed(this, e);
} }
/// <summary> Called when the <see cref="OpenTK.INativeWindow.Focused"/> property of the NativeWindow has changed. </summary> /// <summary> Called when the <see cref="OpenTK.INativeWindow.Focused"/> property of the NativeWindow has changed. </summary>
/// <param name="e">Not used.</param> protected virtual void OnFocusedChanged(object sender, EventArgs e) {
protected virtual void OnFocusedChanged(EventArgs e) {
if (FocusedChanged != null) FocusedChanged(this, e); if (FocusedChanged != null) FocusedChanged(this, e);
} }
/// <summary> Called when the <see cref="OpenTK.INativeWindow.Icon"/> property of the NativeWindow has changed. </summary> /// <summary> Called when the <see cref="OpenTK.INativeWindow.Icon"/> property of the NativeWindow has changed. </summary>
/// <param name="e">Not used.</param> protected virtual void OnIconChanged(object sender, EventArgs e) {
protected virtual void OnIconChanged(EventArgs e) {
if (IconChanged != null) IconChanged(this, e); if (IconChanged != null) IconChanged(this, e);
} }
/// <summary> Called when a character is typed. </summary> /// <summary> Called when a character is typed. </summary>
/// <param name="e">The <see cref="OpenTK.KeyPressEventArgs"/> for this event.</param> /// <param name="e">The <see cref="OpenTK.KeyPressEventArgs"/> for this event.</param>
protected virtual void OnKeyPress(KeyPressEventArgs e) { protected virtual void OnKeyPress(object sender, KeyPressEventArgs e) {
if (KeyPress != null) KeyPress(this, e); if (KeyPress != null) KeyPress(this, e);
} }
/// <summary> Called when the NativeWindow is moved. </summary> /// <summary> Called when the NativeWindow is moved. </summary>
/// <param name="e">Not used.</param> protected virtual void OnMove(object sender, EventArgs e) {
protected virtual void OnMove(EventArgs e) {
if (Move != null) Move(this, e); if (Move != null) Move(this, e);
} }
/// <summary> Called whenever the mouse cursor reenters the window <see cref="Bounds"/>. </summary> /// <summary> Called whenever the mouse cursor reenters the window <see cref="Bounds"/>. </summary>
/// <param name="e">Not used.</param> protected virtual void OnMouseEnter(object sender, EventArgs e) {
protected virtual void OnMouseEnter(EventArgs e) {
if (MouseEnter != null) MouseEnter(this, e); if (MouseEnter != null) MouseEnter(this, e);
} }
/// <summary> Called whenever the mouse cursor leaves the window <see cref="Bounds"/>. </summary> /// <summary> Called whenever the mouse cursor leaves the window <see cref="Bounds"/>. </summary>
/// <param name="e">Not used.</param> protected virtual void OnMouseLeave(object sender, EventArgs e) {
protected virtual void OnMouseLeave(EventArgs e) {
if (MouseLeave != null) MouseLeave(this, e); if (MouseLeave != null) MouseLeave(this, e);
} }
/// <summary> Called when the NativeWindow is resized. </summary> /// <summary> Called when the NativeWindow is resized. </summary>
/// <param name="e">Not used.</param> /// <param name="e">Not used.</param>
protected virtual void OnResize(EventArgs e) { protected virtual void OnResize(object sender, EventArgs e) {
if (Resize != null) Resize(this, e); if (Resize != null) Resize(this, e);
} }
/// <summary> Called when the <see cref="OpenTK.INativeWindow.Title"/> property of the NativeWindow has changed. </summary> /// <summary> Called when the <see cref="OpenTK.INativeWindow.Title"/> property of the NativeWindow has changed. </summary>
/// <param name="e">Not used.</param> protected virtual void OnTitleChanged(object sender, EventArgs e) {
protected virtual void OnTitleChanged(EventArgs e) {
if (TitleChanged != null) TitleChanged(this, e); if (TitleChanged != null) TitleChanged(this, e);
} }
/// <summary> Called when the <see cref="OpenTK.INativeWindow.Visible"/> property of the NativeWindow has changed. </summary> /// <summary> Called when the <see cref="OpenTK.INativeWindow.Visible"/> property of the NativeWindow has changed. </summary>
/// <param name="e">Not used.</param> protected virtual void OnVisibleChanged(object sender, EventArgs e) {
protected virtual void OnVisibleChanged(EventArgs e) {
if (VisibleChanged != null) VisibleChanged(this, e); if (VisibleChanged != null) VisibleChanged(this, e);
} }
/// <summary> Called when the WindowState of this NativeWindow has changed. </summary> /// <summary> Called when the WindowState of this NativeWindow has changed. </summary>
/// <param name="e">Not used.</param> protected virtual void OnWindowStateChanged(object sender, EventArgs e) {
protected virtual void OnWindowStateChanged(EventArgs e) {
if (WindowStateChanged != null) WindowStateChanged(this, e); if (WindowStateChanged != null) WindowStateChanged(this, e);
} }
@ -400,68 +386,44 @@ namespace OpenTK {
} }
private void OnClosedInternal(object sender, EventArgs e) { private void OnClosedInternal(object sender, EventArgs e) {
OnClosed(e); OnClosed(null, e);
Events = false; Events = false;
} }
private void OnClosingInternal(object sender, CancelEventArgs e) { OnClosing(e); }
private void OnDisposedInternal(object sender, EventArgs e) { OnDisposed(e); }
private void OnFocusedChangedInternal(object sender, EventArgs e) { OnFocusedChanged(e); }
private void OnIconChangedInternal(object sender, EventArgs e) { OnIconChanged(e); }
private void OnKeyPressInternal(object sender, KeyPressEventArgs e) { OnKeyPress(e); }
private void OnMouseEnterInternal(object sender, EventArgs e) { OnMouseEnter(e); }
private void OnMouseLeaveInternal(object sender, EventArgs e) { OnMouseLeave(e); }
private void OnMoveInternal(object sender, EventArgs e) { OnMove(e); }
private void OnResizeInternal(object sender, EventArgs e) { OnResize(e); }
private void OnTitleChangedInternal(object sender, EventArgs e) { OnTitleChanged(e); }
private void OnVisibleChangedInternal(object sender, EventArgs e) { OnVisibleChanged(e); }
private void OnWindowStateChangedInternal(object sender, EventArgs e) { OnWindowStateChanged(e); }
private bool Events { private bool Events {
set { set {
if (value) { if (value) {
if (events) { if (events) {
throw new InvalidOperationException("Event propagation is already enabled."); throw new InvalidOperationException("Event propagation is already enabled.");
} }
implementation.Closed += OnClosedInternal; implementation.Closed += OnClosed;
implementation.Closing += OnClosingInternal; implementation.Closing += OnClosing;
implementation.Disposed += OnDisposedInternal; implementation.Disposed += OnDisposed;
implementation.FocusedChanged += OnFocusedChangedInternal; implementation.FocusedChanged += OnFocusedChanged;
implementation.IconChanged += OnIconChangedInternal; implementation.IconChanged += OnIconChanged;
implementation.KeyPress += OnKeyPressInternal; implementation.KeyPress += OnKeyPress;
implementation.MouseEnter += OnMouseEnterInternal; implementation.MouseEnter += OnMouseEnter;
implementation.MouseLeave += OnMouseLeaveInternal; implementation.MouseLeave += OnMouseLeave;
implementation.Move += OnMoveInternal; implementation.Move += OnMove;
implementation.Resize += OnResizeInternal; implementation.Resize += OnResize;
implementation.TitleChanged += OnTitleChangedInternal; implementation.TitleChanged += OnTitleChanged;
implementation.VisibleChanged += OnVisibleChangedInternal; implementation.VisibleChanged += OnVisibleChanged;
implementation.WindowStateChanged += OnWindowStateChangedInternal; implementation.WindowStateChanged += OnWindowStateChanged;
events = true; events = true;
} else if (events) { } else if (events) {
implementation.Closed -= OnClosedInternal; implementation.Closed -= OnClosed;
implementation.Closing -= OnClosingInternal; implementation.Closing -= OnClosing;
implementation.Disposed -= OnDisposedInternal; implementation.Disposed -= OnDisposed;
implementation.FocusedChanged -= OnFocusedChangedInternal; implementation.FocusedChanged -= OnFocusedChanged;
implementation.IconChanged -= OnIconChangedInternal; implementation.IconChanged -= OnIconChanged;
implementation.KeyPress -= OnKeyPressInternal; implementation.KeyPress -= OnKeyPress;
implementation.MouseEnter -= OnMouseEnterInternal; implementation.MouseEnter -= OnMouseEnter;
implementation.MouseLeave -= OnMouseLeaveInternal; implementation.MouseLeave -= OnMouseLeave;
implementation.Move -= OnMoveInternal; implementation.Move -= OnMove;
implementation.Resize -= OnResizeInternal; implementation.Resize -= OnResize;
implementation.TitleChanged -= OnTitleChangedInternal; implementation.TitleChanged -= OnTitleChanged;
implementation.VisibleChanged -= OnVisibleChangedInternal; implementation.VisibleChanged -= OnVisibleChanged;
implementation.WindowStateChanged -= OnWindowStateChangedInternal; implementation.WindowStateChanged -= OnWindowStateChanged;
events = false; events = false;
} else { } else {
throw new InvalidOperationException("Event propagation is already disabled."); throw new InvalidOperationException("Event propagation is already disabled.");

View File

@ -650,10 +650,6 @@ namespace OpenTK.Platform.MacOS
{ {
Application.ProcessEvents(); Application.ProcessEvents();
} }
public void Invalidate() {
// TODO: what do we need to do here?
}
public Point PointToClient(Point point) public Point PointToClient(Point point)
{ {

View File

@ -714,9 +714,6 @@ namespace OpenTK.Platform.Windows
API.DispatchMessage(ref msg); API.DispatchMessage(ref msg);
} }
} }
public void Invalidate() {
}
public IWindowInfo WindowInfo { public IWindowInfo WindowInfo {
get { return child_window; } get { return child_window; }

View File

@ -432,22 +432,6 @@ namespace OpenTK.Platform.X11 {
} }
} }
public void Invalidate() {
XEvent xev = new XEvent();
xev.ExposeEvent.type = XEventName.Expose;
xev.ExposeEvent.display = window.Display;
xev.ExposeEvent.window = window.WindowHandle;
xev.ExposeEvent.x = 0;
xev.ExposeEvent.y = 0;
xev.ExposeEvent.width = client_rectangle.Width;
xev.ExposeEvent.height = client_rectangle.Height;
xev.ExposeEvent.count = 0;
API.XSendEvent(window.Display, window.WindowHandle, false,
EventMask.ExposureMask, ref xev);
API.XFlush(window.Display);
}
public Rectangle Bounds { public Rectangle Bounds {
get { return bounds; } get { return bounds; }
set { set {