Use default.png for chat, can toggle on or off with an option.

This commit is contained in:
UnknownShadow200 2015-10-28 17:21:29 +11:00
parent 57d4a937c8
commit f069a32222
8 changed files with 52 additions and 38 deletions

View File

@ -35,7 +35,8 @@ namespace ClassicalSharp {
MakeKeys( 0, 11, -140 ); MakeKeys( 0, 11, -140 );
MakeKeys( 11, 11, 140 ); MakeKeys( 11, 11, 140 );
buttons[index] = Make( 0, 5, "Back to menu", Anchor.BottomOrRight, (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ); buttons[index] = Make( 0, 5, "Back to menu", Anchor.BottomOrRight,
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) );
statusWidget = TextWidget.Create( game, 0, 150, "", Anchor.Centre, Anchor.Centre, regularFont ); statusWidget = TextWidget.Create( game, 0, 150, "", Anchor.Centre, Anchor.Centre, regularFont );
} }

View File

@ -33,28 +33,33 @@ namespace ClassicalSharp {
g => g.ViewDistance.ToString(), g => g.ViewDistance.ToString(),
(g, v) => g.SetViewDistance( Int32.Parse( v ) ) ), (g, v) => g.SetViewDistance( Int32.Parse( v ) ) ),
// Column 2 // Column 2
Make( 140, -100, "Chat font size", Anchor.Centre, OnWidgetClick, Make( 140, -100, "Mouse sensitivity", Anchor.Centre, OnWidgetClick,
g => g.Chat.FontSize.ToString(),
(g, v) => { g.Chat.FontSize = Int32.Parse( v );
Options.Set( OptionsKey.FontSize, v ); } ),
Make( 140, -50, "Chat lines", Anchor.Centre, OnWidgetClick,
g => g.ChatLines.ToString(),
(g, v) => { g.ChatLines = Int32.Parse( v );
Options.Set( OptionsKey.ChatLines, v ); } ),
Make( 140, 0, "Mouse sensitivity", Anchor.Centre, OnWidgetClick,
g => g.MouseSensitivity.ToString(), g => g.MouseSensitivity.ToString(),
(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, "Key bindings", Anchor.Centre, Make( 140, -50, "Chat font size", Anchor.Centre, OnWidgetClick,
(g, w) => g.SetNewScreen( new KeyBindingsScreen( g ) ), null, null ), g => g.Chat.FontSize.ToString(),
(g, v) => { g.Chat.FontSize = Int32.Parse( v );
Options.Set( OptionsKey.FontSize, v ); } ),
Make( 140, 0, "Chat lines", Anchor.Centre, OnWidgetClick,
g => g.ChatLines.ToString(),
(g, v) => { g.ChatLines = Int32.Parse( v );
Options.Set( OptionsKey.ChatLines, v ); } ),
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(); } ),
// Extra stuff // Extra stuff
!network.IsSinglePlayer ? null : !network.IsSinglePlayer ? null :
Make( -140, -150, "Singleplayer physics", Anchor.Centre, OnWidgetClick, Make( -140, -150, "Singleplayer physics", Anchor.Centre, OnWidgetClick,
g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no", g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no",
(g, v) => ((SinglePlayerServer)network).physics.Enabled = (v == "yes") ), (g, v) => ((SinglePlayerServer)network).physics.Enabled = (v == "yes") ),
Make( 140, -150, "Pushback block placing", Anchor.Centre, OnWidgetClick, Make( 140, -150, "Pushback block placing", Anchor.Centre, OnWidgetClick,
g => g.PushbackBlockPlacing ? "yes" : "no", g => g.PushbackBlockPlacing ? "yes" : "no",
(g, v) => g.PushbackBlockPlacing = (v == "yes" ) ), (g, v) => g.PushbackBlockPlacing = (v == "yes" ) ),
@ -69,10 +74,10 @@ namespace ClassicalSharp {
new BooleanValidator(), new BooleanValidator(),
new IntegerValidator( 16, 4096 ), new IntegerValidator( 16, 4096 ),
new IntegerValidator( 1, 100 ),
new IntegerValidator( 6, 30 ), new IntegerValidator( 6, 30 ),
new IntegerValidator( 1, 30 ), new IntegerValidator( 1, 30 ),
new IntegerValidator( 1, 100 ), new BooleanValidator(),
null,
network.IsSinglePlayer ? new BooleanValidator() : null, network.IsSinglePlayer ? new BooleanValidator() : null,
new BooleanValidator() new BooleanValidator()

View File

@ -19,17 +19,28 @@ namespace ClassicalSharp {
public override void Init() { public override void Init() {
titleFont = new Font( "Arial", 16, FontStyle.Bold ); titleFont = new Font( "Arial", 16, FontStyle.Bold );
buttons = new ButtonWidget[] { buttons = new ButtonWidget[] {
Make( -140, -100, "Options", Anchor.Centre, (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ), // Column 1
Make( -140, -50, "Environment settings", Anchor.Centre, (g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ), Make( -140, -100, "Options", Anchor.Centre,
Make( -140, 0, "Select texture pack", Anchor.Centre, (g, w) => g.SetNewScreen( new TexturePackScreen( g ) ) ), (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ),
Make( -140, 50, "Hotkeys", Anchor.Centre, (g, w) => g.SetNewScreen( new HotkeyScreen( g ) ) ), Make( -140, -50, "Environment settings", Anchor.Centre,
(g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ),
Make( 140, -100, "Save level", Anchor.Centre, (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ), Make( -140, 0, "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,
(g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ),
!game.Network.IsSinglePlayer ? null : !game.Network.IsSinglePlayer ? null :
Make( 140, -50, "Load level", Anchor.Centre, (g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ), Make( 140, -50, "Load level", Anchor.Centre,
(g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ),
// TODO: singleplayer Generate level screen // TODO: singleplayer Generate level screen
Make( 140, 50, "Select texture pack", Anchor.Centre,
Make( 0, 55, "Back to game", Anchor.BottomOrRight, (g, w) => g.SetNewScreen( new NormalScreen( g ) ) ), (g, w) => g.SetNewScreen( new TexturePackScreen( g ) ) ),
// Other
Make( 0, 55, "Back to game", Anchor.BottomOrRight,
(g, w) => g.SetNewScreen( new NormalScreen( g ) ) ),
Make( 0, 5, "Quit game", Anchor.BottomOrRight, (g, w) => g.Exit() ), Make( 0, 5, "Quit game", Anchor.BottomOrRight, (g, w) => g.Exit() ),
}; };
} }

View File

@ -42,14 +42,16 @@ namespace ClassicalSharp {
public override void Init() { public override void Init() {
X = 10; X = 10;
DrawTextArgs args = new DrawTextArgs( "_", boldFont, false ); DrawTextArgs args = new DrawTextArgs( "_", boldFont, false );
caretTexture = game.Drawer2D.MakeTextTexture( ref args, 0, 0 ); caretTexture = game.Drawer2D.UseBitmappedChat ?
game.Drawer2D.MakeBitmappedTextTexture( ref args, 0, 0 ) :
game.Drawer2D.MakeTextTexture( ref args, 0, 0 );
chatInputText.WordWrap( ref parts, ref partLens, 64 ); chatInputText.WordWrap( ref parts, ref partLens, 64 );
maxWidth = 0; maxWidth = 0;
args = new DrawTextArgs( null, font, false ); args = new DrawTextArgs( null, font, false );
for( int i = 0; i < lines; i++ ) { for( int i = 0; i < lines; i++ ) {
args.Text = parts[i]; args.Text = parts[i];
sizes[i] = game.Drawer2D.MeasureSize( ref args ); sizes[i] = game.Drawer2D.MeasureChatSize( ref args );
maxWidth = Math.Max( maxWidth, sizes[i].Width ); maxWidth = Math.Max( maxWidth, sizes[i].Width );
} }
@ -80,11 +82,11 @@ namespace ClassicalSharp {
caretCol = nextCaretCol; caretCol = nextCaretCol;
} else { } else {
args.Text = parts[indexY].Substring( 0, indexX ); args.Text = parts[indexY].Substring( 0, indexX );
Size trimmedSize = game.Drawer2D.MeasureSize( ref args ); Size trimmedSize = game.Drawer2D.MeasureChatSize( ref args );
caretTexture.X1 = 10 + trimmedSize.Width; caretTexture.X1 = 10 + trimmedSize.Width;
args.Text = new String( parts[indexY][indexX], 1 ); args.Text = new String( parts[indexY][indexX], 1 );
Size charSize = game.Drawer2D.MeasureSize( ref args ); Size charSize = game.Drawer2D.MeasureChatSize( ref args );
caretTexture.Width = charSize.Width; caretTexture.Width = charSize.Width;
caretTexture.Y1 = sizes[0].Height * indexY; caretTexture.Y1 = sizes[0].Height * indexY;
@ -112,7 +114,7 @@ namespace ClassicalSharp {
args.Text = parts[i]; args.Text = parts[i];
drawer.Clear( backColour, 0, yyy, sizes[i].Width, sizes[i].Height ); drawer.Clear( backColour, 0, yyy, sizes[i].Width, sizes[i].Height );
drawer.DrawText( ref args, 0, yyy ); drawer.DrawChatText( ref args, 0, yyy );
yyy += sizes[i].Height; yyy += sizes[i].Height;
} }
chatInputTexture = drawer.Make2DTexture( bmp, size, 10, y ); chatInputTexture = drawer.Make2DTexture( bmp, size, 10, y );

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

@ -109,6 +109,7 @@ namespace ClassicalSharp {
ModelCache.InitCache(); ModelCache.InitCache();
AsyncDownloader = new AsyncDownloader( skinServer ); AsyncDownloader = new AsyncDownloader( skinServer );
Drawer2D = new GdiPlusDrawer2D( Graphics ); Drawer2D = new GdiPlusDrawer2D( Graphics );
Drawer2D.UseBitmappedChat = !Options.GetBool( OptionsKey.ArialChatFont, false );
TerrainAtlas1D = new TerrainAtlas1D( Graphics ); TerrainAtlas1D = new TerrainAtlas1D( Graphics );
TerrainAtlas = new TerrainAtlas2D( Graphics, Drawer2D ); TerrainAtlas = new TerrainAtlas2D( Graphics, Drawer2D );

View File

@ -268,13 +268,6 @@ namespace ClassicalSharp {
Key key = e.Key; Key key = e.Key;
if( SimulateMouse( key, true ) ) return; if( SimulateMouse( key, true ) ) return;
// TODO: this is a temp debug statement
// NOTE: this is a temp debug statement
if( key == Key.F8 ) {
game.Drawer2D.UseBitmappedChat = !game.Drawer2D.UseBitmappedChat;
game.Events.RaiseChatFontChanged();
return;
}
if( key == Key.F4 && (game.IsKeyDown( Key.AltLeft ) || game.IsKeyDown( Key.AltRight )) ) { if( key == Key.F4 && (game.IsKeyDown( Key.AltLeft ) || game.IsKeyDown( Key.AltRight )) ) {
game.Exit(); game.Exit();
} else if( key == Keys[KeyBinding.Screenshot] ) { } else if( key == Keys[KeyBinding.Screenshot] ) {

View File

@ -12,6 +12,7 @@ namespace ClassicalSharp {
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";
public const string ArialChatFont = "arialchatfont";
public const string MouseLeft = "mouseleft"; public const string MouseLeft = "mouseleft";
public const string MouseMiddle = "mousemiddle"; public const string MouseMiddle = "mousemiddle";