Add separate option for hotbar and inventory scale (Thanks FabTheZen), also fix blocks in hotbar not properly scaling on large resolutions.

This commit is contained in:
UnknownShadow200 2016-01-13 23:32:26 +11:00
parent 363a847152
commit c11f1d2ebd
10 changed files with 81 additions and 62 deletions

View File

@ -62,7 +62,6 @@ namespace ClassicalSharp {
if( index == 0 ) return; if( index == 0 ) return;
if( atlas.TexIds[texIndex] != lastTexId ) { if( atlas.TexIds[texIndex] != lastTexId ) {
lastTexId = atlas.TexIds[texIndex]; lastTexId = atlas.TexIds[texIndex];
Console.WriteLine( "BIND: " + texIndex );
api.BindTexture( lastTexId ); api.BindTexture( lastTexId );
} }
for( int i = 0; i < index; i++ ) for( int i = 0; i < index; i++ )
@ -149,7 +148,6 @@ namespace ClassicalSharp {
index = 0; index = 0;
} }
lastTexId = texId; lastTexId = texId;
Console.WriteLine( "BIND" + texIndex );
api.BindTexture( texId ); api.BindTexture( texId );
} }

View File

@ -77,8 +77,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 * Math.Sqrt(game.GuiScale)); blockSize = (int)(50 * Math.Sqrt(game.GuiInventoryScale));
selBlockExpand = (float)(25 * Math.Sqrt(game.GuiScale)); selBlockExpand = (float)(25 * Math.Sqrt(game.GuiInventoryScale));
startX = game.Width / 2 - (blockSize * blocksPerRow) / 2; startX = game.Width / 2 - (blockSize * blocksPerRow) / 2;
startY = game.Height / 2 - (maxRows * blockSize) / 2; startY = game.Height / 2 - (maxRows * blockSize) / 2;
@ -87,8 +87,8 @@ namespace ClassicalSharp {
} }
public override void Init() { public override void Init() {
blockSize = (int)(50 * Math.Sqrt(game.GuiScale)); blockSize = (int)(50 * Math.Sqrt(game.GuiInventoryScale));
selBlockExpand = (float)(25 * Math.Sqrt(game.GuiScale)); selBlockExpand = (float)(25 * Math.Sqrt(game.GuiInventoryScale));
game.Events.BlockPermissionsChanged += BlockPermissionsChanged; game.Events.BlockPermissionsChanged += BlockPermissionsChanged;
RecreateBlockTable(); RecreateBlockTable();

View File

@ -105,7 +105,7 @@ namespace ClassicalSharp {
fontSize = (int)(14 * game.GuiChatScale); fontSize = (int)(14 * game.GuiChatScale);
Utils.Clamp( ref fontSize, 8, 60 ); Utils.Clamp( ref fontSize, 8, 60 );
announcementFont = new Font( "Arial", fontSize ); announcementFont = new Font( "Arial", fontSize );
blockSize = (int)(23 * 2 * game.GuiScale); blockSize = (int)(23 * 2 * game.GuiHotbarScale);
textInput = new TextInputWidget( game, chatFont, chatInputFont ); textInput = new TextInputWidget( game, chatFont, chatInputFont );
textInput.YOffset = blockSize + 5; textInput.YOffset = blockSize + 5;
@ -213,7 +213,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)(23 * 2 * game.GuiScale); blockSize = (int)(23 * 2 * game.GuiHotbarScale);
textInput.YOffset = blockSize + 5; textInput.YOffset = blockSize + 5;
bottomRight.YOffset = blockSize * 3 / 2; bottomRight.YOffset = blockSize * 3 / 2;

View File

@ -23,58 +23,47 @@ namespace ClassicalSharp {
g => g.ShowFPS ? "yes" : "no", g => g.ShowFPS ? "yes" : "no",
(g, v) => g.ShowFPS = v == "yes" ), (g, v) => g.ShowFPS = v == "yes" ),
Make( -140, -50, "Hud scale", OnWidgetClick, Make( -140, -50, "Hotbar scale", OnWidgetClick,
g => g.HudScale.ToString(), g => g.HotbarScale.ToString(),
(g, v) => { g.HudScale = Single.Parse( v ); (g, v) => { g.HotbarScale = Single.Parse( v );
Options.Set( OptionsKey.HudScale, v ); Options.Set( OptionsKey.HotbarScale, v );
g.RefreshHud(); g.RefreshHud();
} ), } ),
Make( -140, 0, "Tab auto-complete", OnWidgetClick, Make( -140, 0, "Inventory scale", OnWidgetClick,
g => g.InventoryScale.ToString(),
(g, v) => { g.InventoryScale = Single.Parse( v );
Options.Set( OptionsKey.InventoryScale, v );
g.RefreshHud();
} ),
// Column 2
Make( 140, -150, "Tab auto-complete", OnWidgetClick,
g => g.TabAutocomplete ? "yes" : "no", g => g.TabAutocomplete ? "yes" : "no",
(g, v) => { g.TabAutocomplete = v == "yes"; (g, v) => { g.TabAutocomplete = v == "yes";
Options.Set( OptionsKey.TabAutocomplete, v == "yes" ); Options.Set( OptionsKey.TabAutocomplete, v == "yes" );
} ), } ),
// Column 2 Make( 140, -100, "Clickable chat", OnWidgetClick,
Make( 140, -150, "Clickable chat", OnWidgetClick,
g => g.ClickableChat ? "yes" : "no", g => g.ClickableChat ? "yes" : "no",
(g, v) => { g.ClickableChat = v == "yes"; (g, v) => { g.ClickableChat = v == "yes";
Options.Set( OptionsKey.ClickableChat, v == "yes" ); Options.Set( OptionsKey.ClickableChat, v == "yes" );
} ), } ),
Make( 140, -100, "Chat scale", OnWidgetClick, Make( 140, -50, "Chat scale", OnWidgetClick,
g => g.ChatScale.ToString(), g => g.ChatScale.ToString(),
(g, v) => { g.ChatScale = Single.Parse( v ); (g, v) => { g.ChatScale = Single.Parse( v );
Options.Set( OptionsKey.ChatScale, v ); Options.Set( OptionsKey.ChatScale, v );
g.RefreshHud(); g.RefreshHud();
} ), } ),
Make( 140, -50, "Chat lines", OnWidgetClick, Make( 140, 0, "Chat lines", OnWidgetClick,
g => g.ChatLines.ToString(), g => g.ChatLines.ToString(),
(g, v) => { g.ChatLines = Int32.Parse( v ); (g, v) => { g.ChatLines = Int32.Parse( v );
Options.Set( OptionsKey.ChatLines, v ); Options.Set( OptionsKey.ChatLines, v );
g.RefreshHud(); g.RefreshHud();
} ), } ),
Make( 140, 0, "Arial chat font", OnWidgetClick,
g => g.Drawer2D.UseBitmappedChat ? "no" : "yes",
(g, v) => {
g.Drawer2D.UseBitmappedChat = v == "no";
Options.Set( OptionsKey.ArialChatFont, v == "yes" );
game.Events.RaiseChatFontChanged();
if( inputWidget != null ) {
inputWidget.Dispose(); inputWidget = null;
}
if( descWidget != null ) {
descWidget.Dispose(); descWidget = null;
}
g.RefreshHud();
Recreate();
} ),
MakeBack( false, titleFont, MakeBack( false, titleFont,
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ), (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
null, null,
@ -83,7 +72,7 @@ namespace ClassicalSharp {
new BooleanValidator(), new BooleanValidator(),
new BooleanValidator(), new BooleanValidator(),
new RealValidator( 0.25f, 5f ), new RealValidator( 0.25f, 5f ),
new BooleanValidator(), new RealValidator( 0.25f, 5f ),
new BooleanValidator(), new BooleanValidator(),
new RealValidator( 0.25f, 5f ), new RealValidator( 0.25f, 5f ),

View File

@ -21,7 +21,7 @@ namespace ClassicalSharp {
(g, v) => { g.SimpleArmsAnim = v == "yes"; (g, v) => { g.SimpleArmsAnim = v == "yes";
Options.Set( OptionsKey.SimpleArmsAnim, v == "yes" ); }), Options.Set( OptionsKey.SimpleArmsAnim, v == "yes" ); }),
Make( -140, -50, "Use classic gui", OnWidgetClick, Make( -140, -50, "Classic gui textures", OnWidgetClick,
g => g.UseClassicGui ? "yes" : "no", g => g.UseClassicGui ? "yes" : "no",
(g, v) => { g.UseClassicGui = v == "yes"; (g, v) => { g.UseClassicGui = v == "yes";
Options.Set( OptionsKey.UseClassicGui, v == "yes" ); Options.Set( OptionsKey.UseClassicGui, v == "yes" );
@ -33,6 +33,24 @@ namespace ClassicalSharp {
Options.Set( OptionsKey.UseClassicTabList, v == "yes" ); Options.Set( OptionsKey.UseClassicTabList, v == "yes" );
} ), } ),
Make( -140, 50, "Arial chat font", OnWidgetClick,
g => g.Drawer2D.UseBitmappedChat ? "no" : "yes",
(g, v) => {
g.Drawer2D.UseBitmappedChat = v == "no";
Options.Set( OptionsKey.ArialChatFont, v == "yes" );
game.Events.RaiseChatFontChanged();
if( inputWidget != null ) {
inputWidget.Dispose(); inputWidget = null;
}
if( descWidget != null ) {
descWidget.Dispose(); descWidget = null;
}
g.RefreshHud();
Recreate();
} ),
// Column 2 // Column 2
Make( 140, -100, "Allow custom blocks", OnWidgetClick, Make( 140, -100, "Allow custom blocks", OnWidgetClick,
g => g.AllowCustomBlocks ? "yes" : "no", g => g.AllowCustomBlocks ? "yes" : "no",
@ -61,6 +79,7 @@ namespace ClassicalSharp {
new BooleanValidator(), new BooleanValidator(),
new BooleanValidator(), new BooleanValidator(),
new BooleanValidator(), new BooleanValidator(),
new BooleanValidator(),
new BooleanValidator(), new BooleanValidator(),
new BooleanValidator(), new BooleanValidator(),

View File

@ -19,7 +19,7 @@ namespace ClassicalSharp {
float barXOffset, borderSize; float barXOffset, borderSize;
public override void Init() { public override void Init() {
float scale = 2 * game.GuiScale; float scale = 2 * game.GuiHotbarScale;
selBlockSize = (float)Math.Ceiling( 24 * scale ); selBlockSize = (float)Math.Ceiling( 24 * scale );
barHeight = (int)(22 * scale); barHeight = (int)(22 * scale);
Width = (int)(182 * scale); Width = (int)(182 * scale);
@ -45,7 +45,7 @@ namespace ClassicalSharp {
int x = (int)(X + barXOffset + (elemSize + borderSize) * i + elemSize / 2); int x = (int)(X + barXOffset + (elemSize + borderSize) * i + elemSize / 2);
int y = (int)(game.Height - barHeight / 2); int y = (int)(game.Height - barHeight / 2);
float scale = (elemSize - 8) / 2f; float scale = (elemSize * 14/16f) / 2f;
IsometricBlockDrawer.Draw( game, block, scale, x, y ); IsometricBlockDrawer.Draw( game, block, scale, x, y );
} }
RenderSelected(); RenderSelected();
@ -84,7 +84,7 @@ namespace ClassicalSharp {
void MakeSelectionTexture() { void MakeSelectionTexture() {
int hSize = (int)selBlockSize; int hSize = (int)selBlockSize;
int vSize = (int)Math.Floor( 23 * 2 * game.GuiScale ); int vSize = (int)Math.Floor( 23 * 2 * game.GuiHotbarScale );
int y = game.Height - vSize; int y = game.Height - vSize;
TextureRec rec = new TextureRec( 0, 22/256f, 24/256f, 24/256f ); TextureRec rec = new TextureRec( 0, 22/256f, 24/256f, 24/256f );
selTex = new Texture( 0, 0, y, hSize, vSize, rec ); selTex = new Texture( 0, 0, y, hSize, vSize, rec );

View File

@ -4,7 +4,7 @@
<ProjectGuid>{BEB1C785-5CAD-48FF-A886-876BF0A318D4}</ProjectGuid> <ProjectGuid>{BEB1C785-5CAD-48FF-A886-876BF0A318D4}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>WinExe</OutputType> <OutputType>Exe</OutputType>
<RootNamespace>ClassicalSharp</RootNamespace> <RootNamespace>ClassicalSharp</RootNamespace>
<AssemblyName>ClassicalSharp</AssemblyName> <AssemblyName>ClassicalSharp</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion> <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>

View File

@ -133,7 +133,7 @@ namespace ClassicalSharp {
public int ChatLines = 12; public int ChatLines = 12;
public bool ClickableChat = false, HideGui = false, ShowFPS = true; public bool ClickableChat = false, HideGui = false, ShowFPS = true;
internal float HudScale = 1.0f, ChatScale = 1.0f; internal float HotbarScale = 1.0f, ChatScale = 1.0f, InventoryScale = 1.0f;
public bool ViewBobbing, ShowBlockInHand; public bool ViewBobbing, ShowBlockInHand;
public bool UseSound, UseMusic, LiquidsBreakable; public bool UseSound, UseMusic, LiquidsBreakable;
@ -145,13 +145,23 @@ namespace ClassicalSharp {
internal List<WarningScreen> WarningScreens = new List<WarningScreen>(); internal List<WarningScreen> WarningScreens = new List<WarningScreen>();
internal UrlsList AcceptedUrls = new UrlsList( "acceptedurls.txt" ), DeniedUrls = new UrlsList( "deniedurls.txt" ); internal UrlsList AcceptedUrls = new UrlsList( "acceptedurls.txt" ), DeniedUrls = new UrlsList( "deniedurls.txt" );
/// <summary> Calculates the amount that 2D widgets should be scaled by when rendered. </summary> /// <summary> Calculates the amount that the hotbar widget should be scaled by when rendered. </summary>
/// <remarks> Affected by both the current resolution of the window, as well as the /// <remarks> Affected by both the current resolution of the window, as well as the
/// scaling specified by the user (field HudScale). </remarks> /// scaling specified by the user (field HotbarScale). </remarks>
public float GuiScale { public float GuiHotbarScale {
get { get {
float scaleX = Width / 640f, scaleY = Height / 480f; float scaleX = Width / 640f, scaleY = Height / 480f;
return Math.Min( scaleX, scaleY ) * HudScale; return Math.Min( scaleX, scaleY ) * HotbarScale;
}
}
/// <summary> Calculates the amount that the block inventory menu should be scaled by when rendered. </summary>
/// <remarks> Affected by both the current resolution of the window, as well as the
/// scaling specified by the user (field InventoryScale). </remarks>
public float GuiInventoryScale {
get {
float scaleX = Width / 640f, scaleY = Height / 480f;
return Math.Min( scaleX, scaleY ) * InventoryScale;
} }
} }

View File

@ -53,7 +53,8 @@ namespace ClassicalSharp {
InputHandler = new InputHandler( this ); InputHandler = new InputHandler( this );
Chat = new Chat( this ); Chat = new Chat( this );
ParticleManager = new ParticleManager( this ); ParticleManager = new ParticleManager( this );
HudScale = Options.GetFloat( OptionsKey.HudScale, 0.25f, 5f, 1f ); InventoryScale = Options.GetFloat( OptionsKey.InventoryScale, 0.25f, 5f, 1f );
HotbarScale = Options.GetFloat( OptionsKey.HotbarScale, 0.25f, 5f, 1f );
ChatScale = Options.GetFloat( OptionsKey.ChatScale, 0.35f, 5f, 1f ); ChatScale = Options.GetFloat( OptionsKey.ChatScale, 0.35f, 5f, 1f );
defaultIb = Graphics.MakeDefaultIb(); defaultIb = Graphics.MakeDefaultIb();
MouseSensitivity = Options.GetInt( OptionsKey.Sensitivity, 1, 100, 30 ); MouseSensitivity = Options.GetInt( OptionsKey.Sensitivity, 1, 100, 30 );

View File

@ -10,35 +10,37 @@ namespace ClassicalSharp {
public static class OptionsKey { public static class OptionsKey {
public const string ViewDist = "viewdist"; public const string ViewDist = "viewdist";
public const string HudScale = "hudscale";
public const string ChatScale = "chatscale";
public const string Sensitivity = "mousesensitivity";
public const string Speed = "speedmultiplier";
public const string ChatLines = "chatlines";
public const string ClickableChat = "chatclickable";
public const string ArialChatFont = "arialchatfont";
public const string DefaultTexturePack = "defaulttexpack"; public const string DefaultTexturePack = "defaulttexpack";
public const string SingleplayerPhysics = "singleplayerphysics"; public const string SingleplayerPhysics = "singleplayerphysics";
public const string ShowBlockInHand = "blockinhand";
public const string UseMusic = "usemusic"; public const string UseMusic = "usemusic";
public const string UseSound = "usesound"; public const string UseSound = "usesound";
public const string HacksEnabled = "hacksenabled";
public const string NamesMode = "namesmode"; public const string NamesMode = "namesmode";
public const string InvertMouse = "invertmouse";
public const string Sensitivity = "mousesensitivity";
public const string MouseLeft = "mouseleft"; public const string MouseLeft = "mouseleft";
public const string MouseMiddle = "mousemiddle"; public const string MouseMiddle = "mousemiddle";
public const string MouseRight = "mouseright"; public const string MouseRight = "mouseright";
public const string FpsLimit = "fpslimit"; public const string FpsLimit = "fpslimit";
public const string AutoCloseLauncher = "autocloselauncher"; public const string AutoCloseLauncher = "autocloselauncher";
public const string ViewBobbing = "viewbobbing"; public const string ViewBobbing = "viewbobbing";
public const string FieldOfView = "fov";
public const string HacksEnabled = "hacksenabled";
public const string FieldOfView = "fov";
public const string Speed = "speedmultiplier";
public const string LiquidsBreakable = "liquidsbreakable"; public const string LiquidsBreakable = "liquidsbreakable";
public const string PushbackPlacing = "pushbackplacing"; public const string PushbackPlacing = "pushbackplacing";
public const string InvertMouse = "invertmouse";
public const string NoclipSlide = "noclipslide"; public const string NoclipSlide = "noclipslide";
public const string CameraClipping = "cameraclipping"; public const string CameraClipping = "cameraclipping";
public const string DoubleJump = "doublejump"; public const string DoubleJump = "doublejump";
public const string TabAutocomplete = "tab-autocomplete"; public const string TabAutocomplete = "tab-autocomplete";
public const string ShowBlockInHand = "blockinhand";
public const string ChatLines = "chatlines";
public const string ClickableChat = "chatclickable";
public const string ArialChatFont = "arialchatfont";
public const string HotbarScale = "gui-hotbarscale";
public const string InventoryScale = "gui-inventoryscale";
public const string ChatScale = "chatscale";
public const string AllowCustomBlocks = "nostalgia-customblocks"; public const string AllowCustomBlocks = "nostalgia-customblocks";
public const string UseCPE = "nostalgia-usecpe"; public const string UseCPE = "nostalgia-usecpe";