mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 11:06:06 -04:00
Option for all hud scaling, replaces chat font size. Also make block select screen slightly less big at higher scalings.
This commit is contained in:
parent
7eff50e53b
commit
2f940aebaa
@ -66,8 +66,8 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void OnResize( int oldWidth, int oldHeight, int width, int height ) {
|
public override void OnResize( int oldWidth, int oldHeight, int width, int height ) {
|
||||||
blockSize = (int)(50 * Utils.GuiScale( game.Width, game.Height ));
|
blockSize = (int)(50 * Math.Sqrt(game.GuiScale()));
|
||||||
selBlockExpand = (float)(25 * Utils.GuiScale( game.Width, game.Height ));
|
selBlockExpand = (float)(25 * Math.Sqrt(game.GuiScale()));
|
||||||
|
|
||||||
startX = game.Width / 2 - (blockSize * blocksPerRow) / 2;
|
startX = game.Width / 2 - (blockSize * blocksPerRow) / 2;
|
||||||
startY = game.Height / 2 - (rows * blockSize) / 2;
|
startY = game.Height / 2 - (rows * blockSize) / 2;
|
||||||
@ -76,14 +76,14 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
blockSize = (int)(50 * Utils.GuiScale( game.Width, game.Height ));
|
blockSize = (int)(50 * Math.Sqrt(game.GuiScale()));
|
||||||
selBlockExpand = (float)(25 * Utils.GuiScale( game.Width, game.Height ));
|
selBlockExpand = (float)(25 * Math.Sqrt(game.GuiScale()));
|
||||||
game.Events.BlockPermissionsChanged += BlockPermissionsChanged;
|
game.Events.BlockPermissionsChanged += BlockPermissionsChanged;
|
||||||
RecreateBlockTexturess();
|
RecreateBlockTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockPermissionsChanged( object sender, EventArgs e ) {
|
void BlockPermissionsChanged( object sender, EventArgs e ) {
|
||||||
RecreateBlockTexturess();
|
RecreateBlockTextures();
|
||||||
if( selectedIndex >= blocksTable.Length ) {
|
if( selectedIndex >= blocksTable.Length ) {
|
||||||
selectedIndex = blocksTable.Length - 1;
|
selectedIndex = blocksTable.Length - 1;
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ namespace ClassicalSharp {
|
|||||||
blockInfoTexture = game.Drawer2D.MakeTextTexture( ref args, x, y );
|
blockInfoTexture = game.Drawer2D.MakeTextTexture( ref args, x, y );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecreateBlockTexturess() {
|
void RecreateBlockTextures() {
|
||||||
int blocksCount = 0;
|
int blocksCount = 0;
|
||||||
for( int tile = 1; tile < BlockInfo.BlocksCount; tile++ ) {
|
for( int tile = 1; tile < BlockInfo.BlocksCount; tile++ ) {
|
||||||
if( game.Inventory.CanPlace[tile] || game.Inventory.CanDelete[tile] )
|
if( game.Inventory.CanPlace[tile] || game.Inventory.CanDelete[tile] )
|
||||||
|
@ -79,12 +79,14 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
Font chatFont, chatInputFont, chatUnderlineFont, announcementFont;
|
Font chatFont, chatInputFont, chatUnderlineFont, announcementFont;
|
||||||
public override void Init() {
|
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 );
|
chatFont = new Font( "Arial", fontSize );
|
||||||
chatInputFont = new Font( "Arial", fontSize, FontStyle.Bold );
|
chatInputFont = new Font( "Arial", fontSize, FontStyle.Bold );
|
||||||
chatUnderlineFont = new Font( "Arial", fontSize, FontStyle.Underline );
|
chatUnderlineFont = new Font( "Arial", fontSize, FontStyle.Underline );
|
||||||
announcementFont = new Font( "Arial", 14 );
|
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 = new TextInputWidget( game, chatFont, chatInputFont );
|
||||||
textInput.YOffset = blockSize + 5;
|
textInput.YOffset = blockSize + 5;
|
||||||
@ -176,7 +178,7 @@ namespace ClassicalSharp {
|
|||||||
public override void OnResize( int oldWidth, int oldHeight, int width, int height ) {
|
public override void OnResize( int oldWidth, int oldHeight, int width, int height ) {
|
||||||
announcementTex.X1 += (width - oldWidth) / 2;
|
announcementTex.X1 += (width - oldWidth) / 2;
|
||||||
announcementTex.Y1 += (height - oldHeight) / 2;
|
announcementTex.Y1 += (height - oldHeight) / 2;
|
||||||
blockSize = (int)(40 * Utils.GuiScale( game.Width, game.Height ));
|
blockSize = (int)(40 * game.GuiScale());
|
||||||
textInput.YOffset = blockSize + 5;
|
textInput.YOffset = blockSize + 5;
|
||||||
bottomRight.YOffset = blockSize * 3 / 2;
|
bottomRight.YOffset = blockSize * 3 / 2;
|
||||||
|
|
||||||
|
@ -38,10 +38,10 @@ namespace ClassicalSharp {
|
|||||||
(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, -50, "Chat font size", Anchor.Centre, OnWidgetClick,
|
Make( 140, -50, "Hud scale", Anchor.Centre, OnWidgetClick,
|
||||||
g => g.Chat.FontSize.ToString(),
|
g => g.HudScale.ToString(),
|
||||||
(g, v) => { g.Chat.FontSize = Int32.Parse( v );
|
(g, v) => { g.HudScale = Single.Parse( v );
|
||||||
Options.Set( OptionsKey.FontSize, v );
|
Options.Set( OptionsKey.HudScale, v );
|
||||||
g.RefreshHud();
|
g.RefreshHud();
|
||||||
} ),
|
} ),
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ namespace ClassicalSharp {
|
|||||||
new IntegerValidator( 16, 4096 ),
|
new IntegerValidator( 16, 4096 ),
|
||||||
|
|
||||||
new IntegerValidator( 1, 100 ),
|
new IntegerValidator( 1, 100 ),
|
||||||
new IntegerValidator( 6, 30 ),
|
new RealValidator( 0.5f, 2f ),
|
||||||
new IntegerValidator( 1, 30 ),
|
new IntegerValidator( 1, 30 ),
|
||||||
new BooleanValidator(),
|
new BooleanValidator(),
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@ namespace ClassicalSharp {
|
|||||||
static FastColour outlineCol = new FastColour( 169, 143, 192 );
|
static FastColour outlineCol = new FastColour( 169, 143, 192 );
|
||||||
static FastColour selCol = new FastColour( 213, 200, 223 );
|
static FastColour selCol = new FastColour( 213, 200, 223 );
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
blockSize = (int)(38 * Utils.GuiScale( game.Width, game.Height ));
|
blockSize = (int)(38 * game.GuiScale());
|
||||||
borderSize = (int)(3 * Utils.GuiScale( game.Width, game.Height ));
|
borderSize = (int)(3 * game.GuiScale());
|
||||||
int width = blockSize * hotbarCount;
|
int width = blockSize * hotbarCount;
|
||||||
X = game.Width / 2 - width / 2;
|
X = game.Width / 2 - width / 2;
|
||||||
Y = game.Height - blockSize;
|
Y = game.Height - blockSize;
|
||||||
|
@ -22,8 +22,6 @@ namespace ClassicalSharp {
|
|||||||
/// <summary> List of chat messages sent by the user to the server. </summary>
|
/// <summary> List of chat messages sent by the user to the server. </summary>
|
||||||
public List<string> InputLog = new List<string>();
|
public List<string> InputLog = new List<string>();
|
||||||
|
|
||||||
public int FontSize = 12;
|
|
||||||
|
|
||||||
public void Send( string text, bool partial ) {
|
public void Send( string text, bool partial ) {
|
||||||
text = text.TrimEnd( trimChars );
|
text = text.TrimEnd( trimChars );
|
||||||
if( String.IsNullOrEmpty( text ) ) return;
|
if( String.IsNullOrEmpty( text ) ) return;
|
||||||
|
@ -71,6 +71,7 @@ namespace ClassicalSharp {
|
|||||||
public int MouseSensitivity = 30;
|
public int MouseSensitivity = 30;
|
||||||
public int ChatLines = 12;
|
public int ChatLines = 12;
|
||||||
public bool HideGui = false, ShowFPS = true;
|
public bool HideGui = false, ShowFPS = true;
|
||||||
|
internal float HudScale = 1f;
|
||||||
|
|
||||||
public Animations Animations;
|
public Animations Animations;
|
||||||
internal int CloudsTextureId, RainTextureId, SnowTextureId;
|
internal int CloudsTextureId, RainTextureId, SnowTextureId;
|
||||||
@ -79,6 +80,11 @@ namespace ClassicalSharp {
|
|||||||
internal List<WarningScreen> WarningScreens = new List<WarningScreen>();
|
internal List<WarningScreen> WarningScreens = new List<WarningScreen>();
|
||||||
internal AcceptedUrls AcceptedUrls = new AcceptedUrls();
|
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";
|
string defTexturePack = "default.zip";
|
||||||
public string DefaultTexturePack {
|
public string DefaultTexturePack {
|
||||||
get {
|
get {
|
||||||
@ -117,7 +123,7 @@ namespace ClassicalSharp {
|
|||||||
ViewDistance = Options.GetInt( OptionsKey.ViewDist, 16, 4096, 512 );
|
ViewDistance = Options.GetInt( OptionsKey.ViewDist, 16, 4096, 512 );
|
||||||
InputHandler = new InputHandler( this );
|
InputHandler = new InputHandler( this );
|
||||||
Chat = new ChatLog( 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();
|
defaultIb = Graphics.MakeDefaultIb();
|
||||||
MouseSensitivity = Options.GetInt( OptionsKey.Sensitivity, 1, 100, 30 );
|
MouseSensitivity = Options.GetInt( OptionsKey.Sensitivity, 1, 100, 30 );
|
||||||
BlockInfo = new BlockInfo();
|
BlockInfo = new BlockInfo();
|
||||||
@ -303,8 +309,10 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
string timestamp = DateTime.Now.ToString( "dd-MM-yyyy-HH-mm-ss" );
|
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 );
|
Graphics.TakeScreenshot( path, ClientSize );
|
||||||
|
Chat.Add( "&eTaken screenshot as: " + file );
|
||||||
screenshotRequested = false;
|
screenshotRequested = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,10 +44,10 @@ namespace ClassicalSharp {
|
|||||||
width = 640; height = 480;
|
width = 640; height = 480;
|
||||||
|
|
||||||
if( device.Width >= 1024 && device.Height >= 768 ) {
|
if( device.Width >= 1024 && device.Height >= 768 ) {
|
||||||
width = 800; height = 600;
|
//width = 800; height = 600;
|
||||||
}
|
}
|
||||||
if( device.Width >= 1920 && device.Height >= 1080 ) {
|
if( device.Width >= 1920 && device.Height >= 1080 ) {
|
||||||
width = 1600; height = 900;
|
//width = 1600; height = 900;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public static class OptionsKey {
|
public static class OptionsKey {
|
||||||
public const string ViewDist = "viewdist";
|
public const string ViewDist = "viewdist";
|
||||||
public const string FontSize = "chatfontsize";
|
public const string HudScale = "chatscale";
|
||||||
public const string Sensitivity = "mousesensitivity";
|
public const string Sensitivity = "mousesensitivity";
|
||||||
public const string Speed = "speedmultiplier";
|
public const string Speed = "speedmultiplier";
|
||||||
public const string ChatLines = "chatlines";
|
public const string ChatLines = "chatlines";
|
||||||
@ -53,6 +53,17 @@ namespace ClassicalSharp {
|
|||||||
return valueBool;
|
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 ) {
|
public static Key GetKey( string key, Key defValue ) {
|
||||||
string value = Options.Get( key.ToLower() );
|
string value = Options.Get( key.ToLower() );
|
||||||
if( value == null ) {
|
if( value == null ) {
|
||||||
|
@ -237,12 +237,6 @@ namespace ClassicalSharp {
|
|||||||
return (int)(1.4142135 * value);
|
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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Returns the number of vertices needed to subdivide a quad. </summary>
|
/// <summary> Returns the number of vertices needed to subdivide a quad. </summary>
|
||||||
internal static int CountVertices( int axis1Len, int axis2Len, int axisSize ) {
|
internal static int CountVertices( int axis1Len, int axis2Len, int axisSize ) {
|
||||||
return CeilDiv( axis1Len, axisSize ) * CeilDiv( axis2Len, axisSize ) * 4;
|
return CeilDiv( axis1Len, axisSize ) * CeilDiv( axis2Len, axisSize ) * 4;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user