diff --git a/ClassicalSharp/2D/Screens/BlockSelectScreen.cs b/ClassicalSharp/2D/Screens/BlockSelectScreen.cs
index 147b3afb4..f0e733a80 100644
--- a/ClassicalSharp/2D/Screens/BlockSelectScreen.cs
+++ b/ClassicalSharp/2D/Screens/BlockSelectScreen.cs
@@ -66,8 +66,8 @@ namespace ClassicalSharp {
}
public override void OnResize( int oldWidth, int oldHeight, int width, int height ) {
- blockSize = (int)(50 * Utils.GuiScale( game.Width, game.Height ));
- selBlockExpand = (float)(25 * Utils.GuiScale( game.Width, game.Height ));
+ blockSize = (int)(50 * Math.Sqrt(game.GuiScale()));
+ selBlockExpand = (float)(25 * Math.Sqrt(game.GuiScale()));
startX = game.Width / 2 - (blockSize * blocksPerRow) / 2;
startY = game.Height / 2 - (rows * blockSize) / 2;
@@ -76,14 +76,14 @@ namespace ClassicalSharp {
}
public override void Init() {
- blockSize = (int)(50 * Utils.GuiScale( game.Width, game.Height ));
- selBlockExpand = (float)(25 * Utils.GuiScale( game.Width, game.Height ));
+ blockSize = (int)(50 * Math.Sqrt(game.GuiScale()));
+ selBlockExpand = (float)(25 * Math.Sqrt(game.GuiScale()));
game.Events.BlockPermissionsChanged += BlockPermissionsChanged;
- RecreateBlockTexturess();
+ RecreateBlockTextures();
}
void BlockPermissionsChanged( object sender, EventArgs e ) {
- RecreateBlockTexturess();
+ RecreateBlockTextures();
if( selectedIndex >= blocksTable.Length ) {
selectedIndex = blocksTable.Length - 1;
}
@@ -142,7 +142,7 @@ namespace ClassicalSharp {
blockInfoTexture = game.Drawer2D.MakeTextTexture( ref args, x, y );
}
- void RecreateBlockTexturess() {
+ void RecreateBlockTextures() {
int blocksCount = 0;
for( int tile = 1; tile < BlockInfo.BlocksCount; tile++ ) {
if( game.Inventory.CanPlace[tile] || game.Inventory.CanDelete[tile] )
diff --git a/ClassicalSharp/2D/Screens/ChatScreen.cs b/ClassicalSharp/2D/Screens/ChatScreen.cs
index 7f46e53be..f4b584114 100644
--- a/ClassicalSharp/2D/Screens/ChatScreen.cs
+++ b/ClassicalSharp/2D/Screens/ChatScreen.cs
@@ -79,12 +79,14 @@ namespace ClassicalSharp {
Font chatFont, chatInputFont, chatUnderlineFont, announcementFont;
public override void Init() {
- int fontSize = game.Chat.FontSize;//(int)(14 * Utils.GuiScale( game.Width, game.Height ));
+ int fontSize = (int)(14 * game.GuiScale());
+ Utils.Clamp( ref fontSize, 8, 40 );
+
chatFont = new Font( "Arial", fontSize );
chatInputFont = new Font( "Arial", fontSize, FontStyle.Bold );
chatUnderlineFont = new Font( "Arial", fontSize, FontStyle.Underline );
announcementFont = new Font( "Arial", 14 );
- blockSize = (int)(40 * Utils.GuiScale( game.Width, game.Height ));
+ blockSize = (int)(40 * game.GuiScale());
textInput = new TextInputWidget( game, chatFont, chatInputFont );
textInput.YOffset = blockSize + 5;
@@ -176,7 +178,7 @@ namespace ClassicalSharp {
public override void OnResize( int oldWidth, int oldHeight, int width, int height ) {
announcementTex.X1 += (width - oldWidth) / 2;
announcementTex.Y1 += (height - oldHeight) / 2;
- blockSize = (int)(40 * Utils.GuiScale( game.Width, game.Height ));
+ blockSize = (int)(40 * game.GuiScale());
textInput.YOffset = blockSize + 5;
bottomRight.YOffset = blockSize * 3 / 2;
diff --git a/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs
index f7d8833f9..f21cf9165 100644
--- a/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs
+++ b/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs
@@ -38,10 +38,10 @@ namespace ClassicalSharp {
(g, v) => { g.MouseSensitivity = Int32.Parse( v );
Options.Set( OptionsKey.Sensitivity, v ); } ),
- Make( 140, -50, "Chat font size", Anchor.Centre, OnWidgetClick,
- g => g.Chat.FontSize.ToString(),
- (g, v) => { g.Chat.FontSize = Int32.Parse( v );
- Options.Set( OptionsKey.FontSize, v );
+ Make( 140, -50, "Hud scale", Anchor.Centre, OnWidgetClick,
+ g => g.HudScale.ToString(),
+ (g, v) => { g.HudScale = Single.Parse( v );
+ Options.Set( OptionsKey.HudScale, v );
g.RefreshHud();
} ),
@@ -95,7 +95,7 @@ namespace ClassicalSharp {
new IntegerValidator( 16, 4096 ),
new IntegerValidator( 1, 100 ),
- new IntegerValidator( 6, 30 ),
+ new RealValidator( 0.5f, 2f ),
new IntegerValidator( 1, 30 ),
new BooleanValidator(),
diff --git a/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs b/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs
index c93ff8723..8ab8f4ba0 100644
--- a/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs
+++ b/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs
@@ -29,8 +29,8 @@ namespace ClassicalSharp {
static FastColour outlineCol = new FastColour( 169, 143, 192 );
static FastColour selCol = new FastColour( 213, 200, 223 );
public override void Init() {
- blockSize = (int)(38 * Utils.GuiScale( game.Width, game.Height ));
- borderSize = (int)(3 * Utils.GuiScale( game.Width, game.Height ));
+ blockSize = (int)(38 * game.GuiScale());
+ borderSize = (int)(3 * game.GuiScale());
int width = blockSize * hotbarCount;
X = game.Width / 2 - width / 2;
Y = game.Height - blockSize;
diff --git a/ClassicalSharp/Game/ChatLog.cs b/ClassicalSharp/Game/ChatLog.cs
index 00f2d8502..634400dc2 100644
--- a/ClassicalSharp/Game/ChatLog.cs
+++ b/ClassicalSharp/Game/ChatLog.cs
@@ -22,8 +22,6 @@ namespace ClassicalSharp {
/// List of chat messages sent by the user to the server.
public List InputLog = new List();
- public int FontSize = 12;
-
public void Send( string text, bool partial ) {
text = text.TrimEnd( trimChars );
if( String.IsNullOrEmpty( text ) ) return;
diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs
index 824aaff5e..fd9e445b1 100644
--- a/ClassicalSharp/Game/Game.cs
+++ b/ClassicalSharp/Game/Game.cs
@@ -71,6 +71,7 @@ namespace ClassicalSharp {
public int MouseSensitivity = 30;
public int ChatLines = 12;
public bool HideGui = false, ShowFPS = true;
+ internal float HudScale = 1f;
public Animations Animations;
internal int CloudsTextureId, RainTextureId, SnowTextureId;
@@ -79,6 +80,11 @@ namespace ClassicalSharp {
internal List WarningScreens = new List();
internal AcceptedUrls AcceptedUrls = new AcceptedUrls();
+ public float GuiScale() {
+ float scaleX = Width / 640f, scaleY = Height / 480f;
+ return Math.Min( scaleX, scaleY ) * HudScale;
+ }
+
string defTexturePack = "default.zip";
public string DefaultTexturePack {
get {
@@ -117,7 +123,7 @@ namespace ClassicalSharp {
ViewDistance = Options.GetInt( OptionsKey.ViewDist, 16, 4096, 512 );
InputHandler = new InputHandler( this );
Chat = new ChatLog( this );
- Chat.FontSize = Options.GetInt( OptionsKey.FontSize, 6, 30, 12 );
+ HudScale = Options.GetFloat( OptionsKey.HudScale, 0.5f, 2f, 1 );
defaultIb = Graphics.MakeDefaultIb();
MouseSensitivity = Options.GetInt( OptionsKey.Sensitivity, 1, 100, 30 );
BlockInfo = new BlockInfo();
@@ -303,8 +309,10 @@ namespace ClassicalSharp {
}
string timestamp = DateTime.Now.ToString( "dd-MM-yyyy-HH-mm-ss" );
- string path = Path.Combine( "screenshots", "screenshot_" + timestamp + ".png" );
+ string file = "screenshot_" + timestamp + ".png";
+ string path = Path.Combine( "screenshots", file );
Graphics.TakeScreenshot( path, ClientSize );
+ Chat.Add( "&eTaken screenshot as: " + file );
screenshotRequested = false;
}
diff --git a/ClassicalSharp/Program.cs b/ClassicalSharp/Program.cs
index 245b4a475..3179edcab 100644
--- a/ClassicalSharp/Program.cs
+++ b/ClassicalSharp/Program.cs
@@ -44,10 +44,10 @@ namespace ClassicalSharp {
width = 640; height = 480;
if( device.Width >= 1024 && device.Height >= 768 ) {
- width = 800; height = 600;
+ //width = 800; height = 600;
}
if( device.Width >= 1920 && device.Height >= 1080 ) {
- width = 1600; height = 900;
+ //width = 1600; height = 900;
}
}
diff --git a/ClassicalSharp/Utils/Options.cs b/ClassicalSharp/Utils/Options.cs
index 2d99bd199..5dedb0dfd 100644
--- a/ClassicalSharp/Utils/Options.cs
+++ b/ClassicalSharp/Utils/Options.cs
@@ -8,7 +8,7 @@ namespace ClassicalSharp {
public static class OptionsKey {
public const string ViewDist = "viewdist";
- public const string FontSize = "chatfontsize";
+ public const string HudScale = "chatscale";
public const string Sensitivity = "mousesensitivity";
public const string Speed = "speedmultiplier";
public const string ChatLines = "chatlines";
@@ -53,6 +53,17 @@ namespace ClassicalSharp {
return valueBool;
}
+ public static float GetFloat( string key, float min, float max, float defValue ) {
+ string value;
+ float valueFloat = 0;
+ if( !OptionsSet.TryGetValue( key, out value ) || String.IsNullOrEmpty( value )
+ || !Single.TryParse( value, out valueFloat ) )
+ return defValue;
+
+ Utils.Clamp( ref valueFloat, min, max );
+ return valueFloat;
+ }
+
public static Key GetKey( string key, Key defValue ) {
string value = Options.Get( key.ToLower() );
if( value == null ) {
diff --git a/ClassicalSharp/Utils/Utils.cs b/ClassicalSharp/Utils/Utils.cs
index 890986acc..89d2237e9 100644
--- a/ClassicalSharp/Utils/Utils.cs
+++ b/ClassicalSharp/Utils/Utils.cs
@@ -237,12 +237,6 @@ namespace ClassicalSharp {
return (int)(1.4142135 * value);
}
- public static float GuiScale( int width, int height ) {
- float scaleX = width / 640f;
- float scaleY = height / 480f;
- return Math.Min( scaleX, scaleY );
- }
-
/// Returns the number of vertices needed to subdivide a quad.
internal static int CountVertices( int axis1Len, int axis2Len, int axisSize ) {
return CeilDiv( axis1Len, axisSize ) * CeilDiv( axis2Len, axisSize ) * 4;