From e8bed0c7211a1e26a1983e19b539434ed652c258 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 3 Nov 2015 12:37:50 +1100 Subject: [PATCH] Use bigger resolutions by default depending on current resolution. --- ClassicalSharp/Game/Game.cs | 5 ++-- ClassicalSharp/Network/NetworkProcessor.cs | 1 + ClassicalSharp/Program.cs | 27 ++++++++++++++++++---- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs index 963426b5b..414379873 100644 --- a/ClassicalSharp/Game/Game.cs +++ b/ClassicalSharp/Game/Game.cs @@ -381,8 +381,9 @@ namespace ClassicalSharp { !(Inventory.CanPlace[block] && Inventory.CanDelete[block]))); } - public Game( string username, string mppass, string skinServer, string defaultTexPack, bool nullContext ) - : base( 640, 480, GraphicsMode.Default, Program.AppName, nullContext, 0, DisplayDevice.Default ) { + public Game( string username, string mppass, string skinServer, string defaultTexPack, + bool nullContext, int width, int height ) + : base( width, height, GraphicsMode.Default, Program.AppName, nullContext, 0, DisplayDevice.Default ) { Username = username; Mppass = mppass; this.skinServer = skinServer; diff --git a/ClassicalSharp/Network/NetworkProcessor.cs b/ClassicalSharp/Network/NetworkProcessor.cs index 03d78b783..77929e511 100644 --- a/ClassicalSharp/Network/NetworkProcessor.cs +++ b/ClassicalSharp/Network/NetworkProcessor.cs @@ -108,6 +108,7 @@ namespace ClassicalSharp { while( reader.size > 0 ) { byte opcode = reader.buffer[0]; + Console.WriteLine( (PacketId)opcode ); // Fix for older D3 servers which wrote one byte too many for HackControl packets. if( opcode == 0xFF && lastOpcode == PacketId.CpeHackControl ) { reader.Remove( 1 ); diff --git a/ClassicalSharp/Program.cs b/ClassicalSharp/Program.cs index cb0330be4..f39adac19 100644 --- a/ClassicalSharp/Program.cs +++ b/ClassicalSharp/Program.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Net; +using OpenTK; namespace ClassicalSharp { @@ -21,22 +22,37 @@ namespace ClassicalSharp { #if !USE_DX nullContext = false; #endif + int width, height; + SelectResolution( out width, out height ); if( args.Length == 0 || args.Length == 1 ) { const string skinServer = "http://s3.amazonaws.com/MinecraftSkins/"; string pack = args.Length >= 1 ? args[0] : "default.zip"; - using( Game game = new Game( "LocalPlayer", null, skinServer, pack, nullContext ) ) { + + using( Game game = new Game( "LocalPlayer", null, skinServer, + pack, nullContext, width, height ) ) game.Run(); - } } else if( args.Length < 4 ) { Utils.LogDebug( "ClassicalSharp.exe is only the raw client. You must either use the launcher or" + " provide command line arguments to start the client." ); } else { - RunMultiplayer( args, nullContext ); + RunMultiplayer( args, nullContext, width, height ); } } - static void RunMultiplayer( string[] args, bool nullContext ) { + static void SelectResolution( out int width, out int height ) { + DisplayDevice device = DisplayDevice.Default; + width = 640; height = 480; + + if( device.Width >= 1024 && device.Height >= 768 ) { + width = 800; height = 600; + } + if( device.Width >= 1920 && device.Height >= 1080 ) { + width = 1024; height = 768; + } + } + + static void RunMultiplayer( string[] args, bool nullContext, int width, int height ) { IPAddress ip = null; if( !IPAddress.TryParse( args[2], out ip ) ) { Utils.LogDebug( "Invalid IP \"" + args[2] + '"' ); @@ -52,7 +68,8 @@ namespace ClassicalSharp { string skinServer = args.Length >= 5 ? args[4] : "http://s3.amazonaws.com/MinecraftSkins/"; string pack = args.Length >= 6 ? args[5] : "default.zip"; - using( Game game = new Game( args[0], args[1], skinServer, pack, nullContext ) ) { + using( Game game = new Game( args[0], args[1], skinServer, pack, + nullContext, width, height ) ) { game.IPAddress = ip; game.Port = port; game.Run();