mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
Move gui options into own screen, allow scaling of chat size in addition to overall hud size.
This commit is contained in:
parent
1e42361684
commit
75fce33012
@ -79,8 +79,8 @@ namespace ClassicalSharp {
|
||||
|
||||
Font chatFont, chatInputFont, chatUnderlineFont, announcementFont;
|
||||
public override void Init() {
|
||||
int fontSize = (int)(14 * game.GuiScale());
|
||||
Utils.Clamp( ref fontSize, 8, 40 );
|
||||
int fontSize = (int)(12 * game.GuiScale() * game.ChatScale);
|
||||
Utils.Clamp( ref fontSize, 8, 60 );
|
||||
|
||||
chatFont = new Font( "Arial", fontSize );
|
||||
chatInputFont = new Font( "Arial", fontSize, FontStyle.Bold );
|
||||
|
76
ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs
Normal file
76
ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using System;
|
||||
|
||||
namespace ClassicalSharp {
|
||||
|
||||
public class GuiOptionsScreen : MenuInputScreen {
|
||||
|
||||
public GuiOptionsScreen( Game game ) : base( game ) {
|
||||
}
|
||||
|
||||
public override void Init() {
|
||||
base.Init();
|
||||
INetworkProcessor network = game.Network;
|
||||
|
||||
buttons = new ButtonWidget[] {
|
||||
// Column 1
|
||||
Make( -140, -50, "Show FPS", Anchor.Centre, OnWidgetClick,
|
||||
g => g.ShowFPS ? "yes" : "no",
|
||||
(g, v) => g.ShowFPS = v == "yes" ),
|
||||
|
||||
Make( -140, 0, "Hud scale", Anchor.Centre, OnWidgetClick,
|
||||
g => g.HudScale.ToString(),
|
||||
(g, v) => { g.HudScale = Single.Parse( v );
|
||||
Options.Set( OptionsKey.HudScale, v );
|
||||
g.RefreshHud();
|
||||
} ),
|
||||
|
||||
// Column 2
|
||||
Make( 140, -50, "Chat scale", Anchor.Centre, OnWidgetClick,
|
||||
g => g.ChatScale.ToString(),
|
||||
(g, v) => { g.ChatScale = Single.Parse( v );
|
||||
Options.Set( OptionsKey.ChatScale, v );
|
||||
g.RefreshHud();
|
||||
} ),
|
||||
|
||||
Make( 140, 0, "Chat lines", Anchor.Centre, OnWidgetClick,
|
||||
g => g.ChatLines.ToString(),
|
||||
(g, v) => { g.ChatLines = Int32.Parse( v );
|
||||
Options.Set( OptionsKey.ChatLines, v );
|
||||
g.RefreshHud();
|
||||
} ),
|
||||
|
||||
Make( 140, 50, "Arial chat font", Anchor.Centre, OnWidgetClick,
|
||||
g => g.Drawer2D.UseBitmappedChat ? "no" : "yes",
|
||||
(g, v) => {
|
||||
g.Drawer2D.UseBitmappedChat = v == "no";
|
||||
Options.Set( OptionsKey.ArialChatFont, v == "yes" );
|
||||
game.Events.RaiseChatFontChanged();
|
||||
g.RefreshHud();
|
||||
} ),
|
||||
|
||||
|
||||
Make( 0, 5, "Back to menu", Anchor.BottomOrRight,
|
||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ),
|
||||
null,
|
||||
};
|
||||
validators = new MenuInputValidator[] {
|
||||
new BooleanValidator(),
|
||||
new RealValidator( 0.25f, 5f ),
|
||||
|
||||
new RealValidator( 0.25f, 5f ),
|
||||
new IntegerValidator( 1, 30 ),
|
||||
new BooleanValidator(),
|
||||
new BooleanValidator(),
|
||||
};
|
||||
okayIndex = buttons.Length - 1;
|
||||
}
|
||||
|
||||
ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action<Game, Widget> onClick,
|
||||
Func<Game, string> getter, Action<Game, string> setter ) {
|
||||
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre, vDocking, titleFont, onClick );
|
||||
widget.GetValue = getter;
|
||||
widget.SetValue = setter;
|
||||
return widget;
|
||||
}
|
||||
}
|
||||
}
|
@ -15,15 +15,17 @@ namespace ClassicalSharp {
|
||||
|
||||
buttons = new ButtonWidget[] {
|
||||
// Column 1
|
||||
Make( -140, -100, "Speed multiplier", Anchor.Centre, OnWidgetClick,
|
||||
Make( -140, -100, "Show hover names", Anchor.Centre, OnWidgetClick,
|
||||
g => g.Players.ShowHoveredNames ? "yes" : "no",
|
||||
(g, v) => {
|
||||
g.Players.ShowHoveredNames = v == "yes";
|
||||
Options.Set( OptionsKey.ShowHoveredNames, v == "yes" );
|
||||
}),
|
||||
Make( -140, -50, "Speed multiplier", Anchor.Centre, OnWidgetClick,
|
||||
g => g.LocalPlayer.SpeedMultiplier.ToString(),
|
||||
(g, v) => { g.LocalPlayer.SpeedMultiplier = Single.Parse( v );
|
||||
Options.Set( OptionsKey.Speed, v ); } ),
|
||||
|
||||
Make( -140, -50, "Show FPS", Anchor.Centre, OnWidgetClick,
|
||||
g => g.ShowFPS ? "yes" : "no",
|
||||
(g, v) => g.ShowFPS = v == "yes" ),
|
||||
|
||||
Make( -140, 0, "VSync active", Anchor.Centre, OnWidgetClick,
|
||||
g => g.VSync ? "yes" : "no",
|
||||
(g, v) => { g.Graphics.SetVSync( g, v == "yes" );
|
||||
@ -32,76 +34,39 @@ namespace ClassicalSharp {
|
||||
Make( -140, 50, "View distance", Anchor.Centre, OnWidgetClick,
|
||||
g => g.ViewDistance.ToString(),
|
||||
(g, v) => g.SetViewDistance( Int32.Parse( v ) ) ),
|
||||
|
||||
// Column 2
|
||||
Make( 140, -100, "Mouse sensitivity", Anchor.Centre, OnWidgetClick,
|
||||
g => g.MouseSensitivity.ToString(),
|
||||
(g, v) => { g.MouseSensitivity = Int32.Parse( v );
|
||||
Options.Set( OptionsKey.Sensitivity, 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();
|
||||
} ),
|
||||
|
||||
Make( 140, 0, "Chat lines", Anchor.Centre, OnWidgetClick,
|
||||
g => g.ChatLines.ToString(),
|
||||
(g, v) => { g.ChatLines = Int32.Parse( v );
|
||||
Options.Set( OptionsKey.ChatLines, v );
|
||||
g.RefreshHud();
|
||||
} ),
|
||||
|
||||
Make( 140, 50, "Arial chat font", Anchor.Centre, OnWidgetClick,
|
||||
g => g.Drawer2D.UseBitmappedChat ? "no" : "yes",
|
||||
(g, v) => {
|
||||
g.Drawer2D.UseBitmappedChat = v == "no";
|
||||
Options.Set( OptionsKey.ArialChatFont, v == "yes" );
|
||||
game.Events.RaiseChatFontChanged();
|
||||
g.RefreshHud();
|
||||
} ),
|
||||
|
||||
// Extra stuff
|
||||
!network.IsSinglePlayer ? null :
|
||||
Make( -140, -200, "Singleplayer physics", Anchor.Centre, OnWidgetClick,
|
||||
Make( 140, -50, "Singleplayer physics", Anchor.Centre, OnWidgetClick,
|
||||
g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no",
|
||||
(g, v) => {
|
||||
((SinglePlayerServer)network).physics.Enabled = v == "yes";
|
||||
Options.Set( OptionsKey.SingleplayerPhysics, v == "yes" );
|
||||
}),
|
||||
Make( 140, -150, "Pushback block placing", Anchor.Centre, OnWidgetClick,
|
||||
g => g.LocalPlayer.PushbackBlockPlacing
|
||||
Make( 140, 0, "Pushback block placing", Anchor.Centre, OnWidgetClick,
|
||||
g => g.LocalPlayer.PushbackBlockPlacing
|
||||
&& g.LocalPlayer.CanPushbackBlocks ? "yes" : "no",
|
||||
(g, v) => {
|
||||
(g, v) => {
|
||||
if( g.LocalPlayer.CanPushbackBlocks)
|
||||
g.LocalPlayer.PushbackBlockPlacing = v == "yes";
|
||||
g.LocalPlayer.PushbackBlockPlacing = v == "yes";
|
||||
}),
|
||||
|
||||
Make( -140, -150, "Show hover names", Anchor.Centre, OnWidgetClick,
|
||||
g => g.Players.ShowHoveredNames ? "yes" : "no",
|
||||
(g, v) => {
|
||||
g.Players.ShowHoveredNames = v == "yes";
|
||||
Options.Set( OptionsKey.ShowHoveredNames, v == "yes" );
|
||||
}),
|
||||
|
||||
Make( 140, 50, "Mouse sensitivity", Anchor.Centre, OnWidgetClick,
|
||||
g => g.MouseSensitivity.ToString(),
|
||||
(g, v) => { g.MouseSensitivity = Int32.Parse( v );
|
||||
Options.Set( OptionsKey.Sensitivity, v ); } ),
|
||||
Make( 0, 5, "Back to menu", Anchor.BottomOrRight,
|
||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ),
|
||||
null,
|
||||
};
|
||||
validators = new MenuInputValidator[] {
|
||||
new RealValidator( 0.1f, 50 ),
|
||||
new BooleanValidator(),
|
||||
new RealValidator( 0.1f, 50 ),
|
||||
new BooleanValidator(),
|
||||
new IntegerValidator( 16, 4096 ),
|
||||
|
||||
new IntegerValidator( 1, 100 ),
|
||||
new RealValidator( 0.25f, 2f ),
|
||||
new IntegerValidator( 1, 30 ),
|
||||
new BooleanValidator(),
|
||||
|
||||
network.IsSinglePlayer ? new BooleanValidator() : null,
|
||||
new BooleanValidator(),
|
||||
new BooleanValidator(),
|
||||
new IntegerValidator( 1, 100 ),
|
||||
};
|
||||
okayIndex = buttons.Length - 1;
|
||||
}
|
||||
|
@ -20,20 +20,21 @@ namespace ClassicalSharp {
|
||||
titleFont = new Font( "Arial", 16, FontStyle.Bold );
|
||||
buttons = new ButtonWidget[] {
|
||||
// Column 1
|
||||
Make( -140, -100, "Options", Anchor.Centre,
|
||||
Make( -140, -150, "Options", Anchor.Centre,
|
||||
(g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ),
|
||||
Make( -140, -100, "Gui options", Anchor.Centre,
|
||||
(g, w) => g.SetNewScreen( new GuiOptionsScreen( g ) ) ),
|
||||
Make( -140, -50, "Environment settings", Anchor.Centre,
|
||||
(g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ),
|
||||
|
||||
Make( -140, 0, "Hotkeys", Anchor.Centre,
|
||||
Make( -140, 0, "Key bindings", Anchor.Centre,
|
||||
(g, w) => g.SetNewScreen( new KeyBindingsScreen( g ) ) ),
|
||||
Make( -140, 50, "Hotkeys", Anchor.Centre,
|
||||
(g, w) => g.SetNewScreen( new HotkeyScreen( g ) ) ),
|
||||
Make( -140, 50, "Key bindings", Anchor.Centre,
|
||||
(g, w) => g.SetNewScreen( new KeyBindingsScreen( g ) ) ),
|
||||
// Column 2
|
||||
Make( 140, -100, "Save level", Anchor.Centre,
|
||||
Make( 140, -150, "Save level", Anchor.Centre,
|
||||
(g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ),
|
||||
!game.Network.IsSinglePlayer ? null :
|
||||
Make( 140, -50, "Load level", Anchor.Centre,
|
||||
Make( 140, -100, "Load level", Anchor.Centre,
|
||||
(g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ),
|
||||
// TODO: singleplayer Generate level screen
|
||||
Make( 140, 50, "Select texture pack", Anchor.Centre,
|
||||
|
@ -26,7 +26,7 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
static FastColour backCol = new FastColour( 60, 60, 60, 160 );
|
||||
static FastColour outlineCol = new FastColour( 169, 143, 192 );
|
||||
static FastColour outlineCol = new FastColour( 151, 120, 180 );
|
||||
static FastColour selCol = new FastColour( 213, 200, 223 );
|
||||
public override void Init() {
|
||||
blockSize = (int)(38 * game.GuiScale());
|
||||
|
@ -91,6 +91,7 @@
|
||||
<Compile Include="2D\Screens\HotkeyScreen.cs" />
|
||||
<Compile Include="2D\Screens\LoadingMapScreen.cs" />
|
||||
<Compile Include="2D\Screens\Menu\EnvSettingsScreen.cs" />
|
||||
<Compile Include="2D\Screens\Menu\GuiOptionsScreen.cs" />
|
||||
<Compile Include="2D\Screens\Menu\KeyBindingsScreen.cs" />
|
||||
<Compile Include="2D\Screens\Menu\LoadLevelScreen.cs" />
|
||||
<Compile Include="2D\Screens\Menu\MenuInputScreen.cs" />
|
||||
|
@ -72,7 +72,7 @@ namespace ClassicalSharp {
|
||||
public int MouseSensitivity = 30;
|
||||
public int ChatLines = 12;
|
||||
public bool HideGui = false, ShowFPS = true;
|
||||
internal float HudScale = 0.8f;
|
||||
internal float HudScale = 1.0f, ChatScale = 1.0f;
|
||||
|
||||
public Animations Animations;
|
||||
internal int CloudsTextureId, RainTextureId, SnowTextureId;
|
||||
@ -124,7 +124,8 @@ namespace ClassicalSharp {
|
||||
ViewDistance = Options.GetInt( OptionsKey.ViewDist, 16, 4096, 512 );
|
||||
InputHandler = new InputHandler( this );
|
||||
Chat = new ChatLog( this );
|
||||
HudScale = Options.GetFloat( OptionsKey.HudScale, 0.25f, 2f, 1 );
|
||||
HudScale = Options.GetFloat( OptionsKey.HudScale, 0.25f, 5f, 1f );
|
||||
ChatScale = Options.GetFloat( OptionsKey.ChatScale, 0.35f, 5f, 1f );
|
||||
defaultIb = Graphics.MakeDefaultIb();
|
||||
MouseSensitivity = Options.GetInt( OptionsKey.Sensitivity, 1, 100, 30 );
|
||||
BlockInfo = new BlockInfo();
|
||||
|
@ -77,9 +77,8 @@ namespace ClassicalSharp {
|
||||
int buttonsDown = (left ? 1 : 0) + (right ? 1 : 0) + (middle ? 1 : 0);
|
||||
if( buttonsDown > 1 || game.ScreenLockedInput || inv.HeldBlock == Block.Air ) return;
|
||||
|
||||
// always play animations, even if we aren't picking a block.
|
||||
// always play delete animations, even if we aren't picking a block.
|
||||
if( left ) game.BlockHandRenderer.SetAnimationClick( true );
|
||||
else if( right ) game.BlockHandRenderer.SetAnimationClick( false );
|
||||
if( !game.SelectedPos.Valid ) return;
|
||||
|
||||
if( middle ) {
|
||||
@ -96,7 +95,7 @@ namespace ClassicalSharp {
|
||||
&& inv.CanDelete[block] ) {
|
||||
game.ParticleManager.BreakBlockEffect( pos, block );
|
||||
game.UpdateBlock( pos.X, pos.Y, pos.Z, 0 );
|
||||
game.Network.SendSetBlock( pos.X, pos.Y, pos.Z, false, (byte)inv.HeldBlock );
|
||||
game.Network.SendSetBlock( pos.X, pos.Y, pos.Z, false, (byte)inv.HeldBlock );
|
||||
}
|
||||
} else if( right ) {
|
||||
Vector3I pos = game.SelectedPos.TranslatedPos;
|
||||
@ -106,7 +105,8 @@ namespace ClassicalSharp {
|
||||
if( !game.CanPick( game.Map.GetBlock( pos ) ) && inv.CanPlace[block]
|
||||
&& CheckIsFree( game.SelectedPos, block ) ) {
|
||||
game.UpdateBlock( pos.X, pos.Y, pos.Z, block );
|
||||
game.Network.SendSetBlock( pos.X, pos.Y, pos.Z, true, block );
|
||||
game.Network.SendSetBlock( pos.X, pos.Y, pos.Z, true, block );
|
||||
game.BlockHandRenderer.SetAnimationClick( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -285,7 +285,7 @@ namespace ClassicalSharp {
|
||||
}
|
||||
}
|
||||
|
||||
void HandleHotkey( Key key ) {
|
||||
void HandleHotkey( Key key ) {
|
||||
string text;
|
||||
bool more;
|
||||
|
||||
|
@ -8,7 +8,8 @@ namespace ClassicalSharp {
|
||||
|
||||
public static class OptionsKey {
|
||||
public const string ViewDist = "viewdist";
|
||||
public const string HudScale = "chatscale";
|
||||
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";
|
||||
|
@ -13,7 +13,7 @@ namespace Launcher2 {
|
||||
titleFont = new Font( "Arial", 16, FontStyle.Bold );
|
||||
inputFont = new Font( "Arial", 13, FontStyle.Regular );
|
||||
boldInputFont = new Font( "Arial", 13, FontStyle.Bold );
|
||||
enterIndex = 4;
|
||||
enterIndex = 5;
|
||||
widgets = new LauncherWidget[7];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user