mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -04:00
Use gui.png.
This commit is contained in:
parent
4ccbc900a1
commit
a13d3147bc
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using OpenTK.Input;
|
||||
|
||||
namespace ClassicalSharp {
|
||||
|
||||
public class AdvancedKeyBindingsScreen : KeyBindingsScreen {
|
||||
|
||||
public AdvancedKeyBindingsScreen( Game game ) : base( game ) {
|
||||
}
|
||||
|
||||
static string[] normDescriptions = new [] { "Speed", "Toggle noclip", "Toggle fly",
|
||||
"Fly up", "Fly down", "Toggle extended input", "Hide FPS", "Take screenshot",
|
||||
"Toggle fullscreen", "Toggle 3rd person", "Hide gui" };
|
||||
|
||||
public override void Init() {
|
||||
base.Init();
|
||||
descriptions = normDescriptions;
|
||||
buttons = new ButtonWidget[descriptions.Length + 2];
|
||||
MakeKeys( KeyBinding.Speed, 0, 6, -150 );
|
||||
MakeKeys( KeyBinding.HideFps, 6, 5, 150 );
|
||||
buttons[index++] = MakeBack( false, titleFont,
|
||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) );
|
||||
buttons[index++] = ButtonWidget.Create(
|
||||
game, 0, 170, 300, 35, "Normal key bindings",
|
||||
Anchor.Centre, Anchor.Centre, titleFont, NextClick );
|
||||
}
|
||||
|
||||
void NextClick( Game game, Widget widget ) {
|
||||
game.SetNewScreen( new NormalKeyBindingsScreen( game ) );
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ using OpenTK.Input;
|
||||
|
||||
namespace ClassicalSharp {
|
||||
|
||||
public class KeyBindingsScreen : MenuScreen {
|
||||
public abstract class KeyBindingsScreen : MenuScreen {
|
||||
|
||||
public KeyBindingsScreen( Game game ) : base( game ) {
|
||||
}
|
||||
@ -20,43 +20,33 @@ namespace ClassicalSharp {
|
||||
Font keyFont;
|
||||
TextWidget statusWidget;
|
||||
static string[] keyNames;
|
||||
static string[] descriptions = new [] { "Forward", "Back", "Left", "Right", "Jump", "Respawn",
|
||||
"Set spawn", "Open chat", "Send chat", "Pause", "Open inventory", "Cycle view distance",
|
||||
"Show player list", "Speed", "Toggle noclip", "Toggle fly", "Fly up", "Fly down",
|
||||
"Hide gui", "Hide FPS", "Take screenshot", "Toggle fullscreen", "Toggle 3rd person",
|
||||
"Toggle extended input", };
|
||||
protected string[] descriptions;
|
||||
|
||||
public override void Init() {
|
||||
base.Init();
|
||||
if( keyNames == null )
|
||||
keyNames = Enum.GetNames( typeof( Key ) );
|
||||
keyFont = new Font( "Arial", 14, FontStyle.Bold );
|
||||
regularFont = new Font( "Arial", 14, FontStyle.Italic );
|
||||
titleFont = new Font( "Arial", 16, FontStyle.Bold );
|
||||
buttons = new ButtonWidget[descriptions.Length + 1];
|
||||
|
||||
MakeKeys( 0, 12, -140 );
|
||||
MakeKeys( 12, 12, 140 );
|
||||
buttons[index] = MakeOther( 0, 5, 160, "Back to menu", Anchor.Centre,
|
||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) );
|
||||
statusWidget = TextWidget.Create( game, 0, 160, "", Anchor.Centre, Anchor.Centre, regularFont );
|
||||
keyFont = new Font( "Arial", 15, FontStyle.Bold );
|
||||
regularFont = new Font( "Arial", 15, FontStyle.Italic );
|
||||
statusWidget = TextWidget.Create( game, 0, 130, "", Anchor.Centre, Anchor.Centre, regularFont );
|
||||
}
|
||||
|
||||
int index;
|
||||
void MakeKeys( int start, int len, int x ) {
|
||||
int y = -200;
|
||||
protected int index;
|
||||
protected void MakeKeys( KeyBinding start, int descStart, int len, int x ) {
|
||||
int y = -180;
|
||||
for( int i = 0; i < len; i++ ) {
|
||||
KeyBinding binding = (KeyBinding)((int)start + i);
|
||||
string text = descriptions[start + i] + ": "
|
||||
string text = descriptions[descStart + i] + ": "
|
||||
+ keyNames[(int)game.Mapping( binding )];
|
||||
|
||||
buttons[index++] = ButtonWidget.Create( game, x, y, 240, 25, text,
|
||||
Anchor.Centre, Anchor.Centre, keyFont, OnWidgetClick );
|
||||
y += 30;
|
||||
buttons[index++] = ButtonWidget.Create( game, x, y, 260, 35, text,
|
||||
Anchor.Centre, Anchor.Centre, keyFont, OnBindingClick );
|
||||
y += 45;
|
||||
}
|
||||
}
|
||||
|
||||
ButtonWidget curWidget;
|
||||
void OnWidgetClick( Game game, Widget realWidget ) {
|
||||
void OnBindingClick( Game game, Widget realWidget ) {
|
||||
this.curWidget = (ButtonWidget)realWidget;
|
||||
int index = Array.IndexOf<ButtonWidget>( buttons, curWidget );
|
||||
string text = "&ePress new key binding for " + descriptions[index] + ":";
|
||||
@ -89,11 +79,6 @@ namespace ClassicalSharp {
|
||||
return true;
|
||||
}
|
||||
|
||||
ButtonWidget MakeOther( int x, int y, int width, string text, Anchor hAnchor, Action<Game, Widget> onClick ) {
|
||||
return ButtonWidget.Create( game, x, y, width, 35, text,
|
||||
hAnchor, Anchor.BottomOrRight, titleFont, onClick );
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
keyFont.Dispose();
|
||||
base.Dispose();
|
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using OpenTK.Input;
|
||||
|
||||
namespace ClassicalSharp {
|
||||
|
||||
public class NormalKeyBindingsScreen : KeyBindingsScreen {
|
||||
|
||||
public NormalKeyBindingsScreen( Game game ) : base( game ) {
|
||||
}
|
||||
|
||||
static string[] normDescriptions = new [] { "Forward", "Back", "Left",
|
||||
"Right", "Jump", "Respawn", "Set spawn", "Open chat", "Send chat",
|
||||
"Pause", "Open inventory", "Cycle view distance", "Show player list" };
|
||||
|
||||
public override void Init() {
|
||||
base.Init();
|
||||
descriptions = normDescriptions;
|
||||
buttons = new ButtonWidget[descriptions.Length + 2];
|
||||
MakeKeys( KeyBinding.Forward, 0, 6, -150 );
|
||||
MakeKeys( KeyBinding.SetSpawn, 6, 7, 150 );
|
||||
buttons[index++] = MakeBack( false, titleFont,
|
||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) );
|
||||
buttons[index++] = ButtonWidget.Create(
|
||||
game, 0, 170, 300, 35, "Advanced key bindings",
|
||||
Anchor.Centre, Anchor.Centre, titleFont, NextClick );
|
||||
}
|
||||
|
||||
void NextClick( Game game, Widget widget ) {
|
||||
game.SetNewScreen( new AdvancedKeyBindingsScreen( game ) );
|
||||
}
|
||||
}
|
||||
}
|
@ -44,5 +44,12 @@ namespace ClassicalSharp {
|
||||
|
||||
protected virtual void WidgetSelected( Widget widget ) {
|
||||
}
|
||||
|
||||
protected ButtonWidget MakeBack( bool toGame, Font font, Action<Game, Widget> onClick ) {
|
||||
string text = toGame ? "Back to game" : "Back to menu";
|
||||
return ButtonWidget.Create(
|
||||
game, 0, 5, 180, 35, text,
|
||||
Anchor.Centre, Anchor.BottomOrRight, font, onClick );
|
||||
}
|
||||
}
|
||||
}
|
@ -20,7 +20,8 @@ namespace ClassicalSharp {
|
||||
public override void Init() {
|
||||
textFont = new Font( "Arial", 14, FontStyle.Bold );
|
||||
arrowFont = new Font( "Arial", 18, FontStyle.Bold );
|
||||
titleFont = new Font( "Arial", 16, FontStyle.Bold );
|
||||
int size = game.Drawer2D.UseBitmappedChat ? 13 : 16;
|
||||
titleFont = new Font( "Arial", size, FontStyle.Bold );
|
||||
title = TextWidget.Create( game, 0, -130, titleText, Anchor.Centre, Anchor.Centre, titleFont );
|
||||
title.Init();
|
||||
|
||||
|
@ -82,10 +82,7 @@ namespace ClassicalSharp {
|
||||
game.Events.ChatFontChanged -= ChatFontChanged;
|
||||
}
|
||||
|
||||
void ChatFontChanged( object sender, EventArgs e ) {
|
||||
Dispose();
|
||||
Init();
|
||||
}
|
||||
void ChatFontChanged( object sender, EventArgs e ) { Recreate(); }
|
||||
|
||||
public override void OnResize( int oldWidth, int oldHeight, int width, int height ) {
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ namespace ClassicalSharp {
|
||||
|
||||
public override void Init() {
|
||||
game.Keyboard.KeyRepeat = true;
|
||||
titleFont = new Font( "Arial", 16, FontStyle.Bold );
|
||||
base.Init();
|
||||
regularFont = new Font( "Arial", 16, FontStyle.Regular );
|
||||
hintFont = new Font( "Arial", 14, FontStyle.Italic );
|
||||
arrowFont = new Font( "Arial", 18, FontStyle.Bold );
|
||||
@ -88,8 +88,8 @@ namespace ClassicalSharp {
|
||||
Make( -160, -80, "<", 40, 40, arrowFont, (g, w) => PageClick( false ) ),
|
||||
Make( 160, -80, ">", 40, 40, arrowFont, (g, w) => PageClick( true ) ),
|
||||
|
||||
ButtonWidget.Create( game, 0, 5, 160, 35, "Back to menu", Anchor.Centre, Anchor.BottomOrRight,
|
||||
titleFont, (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
|
||||
MakeBack( false, titleFont,
|
||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
|
||||
null, // current key
|
||||
null, // current modifiers
|
||||
null, // leave open current
|
||||
|
@ -49,7 +49,7 @@ namespace ClassicalSharp {
|
||||
g => g.Map.EdgeHeight.ToString(),
|
||||
(g, v) => g.Map.SetEdgeLevel( Int32.Parse( v ) ) ),
|
||||
|
||||
MakeOther( 0, 5, 160, "Back to menu", Anchor.Centre,
|
||||
MakeBack( false, titleFont,
|
||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
|
||||
null,
|
||||
};
|
||||
@ -77,10 +77,5 @@ namespace ClassicalSharp {
|
||||
widget.SetValue = setter;
|
||||
return widget;
|
||||
}
|
||||
|
||||
ButtonWidget MakeOther( int x, int y, int width, string text, Anchor hAnchor, Action<Game, Widget> onClick ) {
|
||||
return ButtonWidget.Create( game, x, y, width, 35, text,
|
||||
hAnchor, Anchor.BottomOrRight, titleFont, onClick );
|
||||
}
|
||||
}
|
||||
}
|
@ -37,10 +37,6 @@ namespace ClassicalSharp {
|
||||
g.RefreshHud();
|
||||
} ),
|
||||
|
||||
Make( -140, 50, "Use gui.png (WIP)", Anchor.Centre, OnWidgetClick,
|
||||
g => g.UseGuiPng ? "yes" : "no",
|
||||
(g, v) => game.UseGuiPng = v == "yes" ),
|
||||
|
||||
// Column 2
|
||||
Make( 140, -150, "Clickable chat", Anchor.Centre, OnWidgetClick,
|
||||
g => g.ClickableChat ? "yes" : "no",
|
||||
@ -69,10 +65,11 @@ namespace ClassicalSharp {
|
||||
Options.Set( OptionsKey.ArialChatFont, v == "yes" );
|
||||
game.Events.RaiseChatFontChanged();
|
||||
g.RefreshHud();
|
||||
Recreate();
|
||||
} ),
|
||||
|
||||
|
||||
MakeOther( 0, 5, 160, "Back to menu", Anchor.Centre,
|
||||
MakeBack( false, titleFont,
|
||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
|
||||
null,
|
||||
};
|
||||
@ -81,7 +78,6 @@ namespace ClassicalSharp {
|
||||
new IntegerValidator( 1, 179 ),
|
||||
new BooleanValidator(),
|
||||
new RealValidator( 0.25f, 5f ),
|
||||
new BooleanValidator(),
|
||||
|
||||
new BooleanValidator(),
|
||||
new RealValidator( 0.25f, 5f ),
|
||||
@ -99,10 +95,5 @@ namespace ClassicalSharp {
|
||||
widget.SetValue = setter;
|
||||
return widget;
|
||||
}
|
||||
|
||||
ButtonWidget MakeOther( int x, int y, int width, string text, Anchor hAnchor, Action<Game, Widget> onClick ) {
|
||||
return ButtonWidget.Create( game, x, y, width, 35, text,
|
||||
hAnchor, Anchor.BottomOrRight, titleFont, onClick );
|
||||
}
|
||||
}
|
||||
}
|
@ -24,12 +24,7 @@ namespace ClassicalSharp {
|
||||
public override void Init() {
|
||||
base.Init();
|
||||
buttons[buttons.Length - 1] =
|
||||
Make( 0, 5, "Back to menu", (g, w) => g.SetNewScreen( new PauseScreen( g ) ) );
|
||||
}
|
||||
|
||||
ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick ) {
|
||||
return ButtonWidget.Create( game, x, y, 160, 35, text,
|
||||
Anchor.Centre, Anchor.BottomOrRight, titleFont, onClick );
|
||||
MakeBack( false, titleFont, (g, w) => g.SetNewScreen( new PauseScreen( g ) ) );
|
||||
}
|
||||
|
||||
protected override void TextButtonClick( Game game, Widget widget ) {
|
||||
|
@ -27,7 +27,7 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
public override void Init() {
|
||||
titleFont = new Font( "Arial", 16, FontStyle.Bold );
|
||||
base.Init();
|
||||
regularFont = new Font( "Arial", 16, FontStyle.Regular );
|
||||
hintFont = new Font( "Arial", 14, FontStyle.Italic );
|
||||
game.Keyboard.KeyRepeat = true;
|
||||
|
@ -22,6 +22,11 @@ namespace ClassicalSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public override void Init() {
|
||||
int size = game.Drawer2D.UseBitmappedChat ? 13 : 16;
|
||||
titleFont = new Font( "Arial", size, FontStyle.Bold );
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
for( int i = 0; i < buttons.Length; i++ ) {
|
||||
if( buttons[i] == null ) continue;
|
||||
|
@ -42,7 +42,7 @@ namespace ClassicalSharp {
|
||||
|
||||
// Column 2
|
||||
!network.IsSinglePlayer ? null :
|
||||
Make( 140, -200, "Singleplayer physics", Anchor.Centre, OnWidgetClick,
|
||||
Make( 140, -200, "Block physics", Anchor.Centre, OnWidgetClick,
|
||||
g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no",
|
||||
(g, v) => {
|
||||
((SinglePlayerServer)network).physics.Enabled = v == "yes";
|
||||
@ -63,7 +63,7 @@ namespace ClassicalSharp {
|
||||
g => Options.GetBool( OptionsKey.AutoCloseLauncher, false ) ? "yes" : "no",
|
||||
(g, v) => Options.Set( OptionsKey.AutoCloseLauncher, v == "yes" ) ),
|
||||
|
||||
Make( 140, 0, "Pushback block placing", Anchor.Centre, OnWidgetClick,
|
||||
Make( 140, 0, "Pushback placing", Anchor.Centre, OnWidgetClick,
|
||||
g => g.LocalPlayer.PushbackBlockPlacing
|
||||
&& g.LocalPlayer.CanPushbackBlocks ? "yes" : "no",
|
||||
(g, v) => {
|
||||
@ -76,7 +76,7 @@ namespace ClassicalSharp {
|
||||
(g, v) => { g.MouseSensitivity = Int32.Parse( v );
|
||||
Options.Set( OptionsKey.Sensitivity, v ); } ),
|
||||
|
||||
MakeOther( 0, 5, 160, "Back to menu", Anchor.Centre,
|
||||
MakeBack( false, titleFont,
|
||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
|
||||
null,
|
||||
};
|
||||
@ -107,10 +107,5 @@ namespace ClassicalSharp {
|
||||
widget.SetValue = setter;
|
||||
return widget;
|
||||
}
|
||||
|
||||
ButtonWidget MakeOther( int x, int y, int width, string text, Anchor hAnchor, Action<Game, Widget> onClick ) {
|
||||
return ButtonWidget.Create( game, x, y, width, 35, text,
|
||||
hAnchor, Anchor.BottomOrRight, titleFont, onClick );
|
||||
}
|
||||
}
|
||||
}
|
@ -17,17 +17,17 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
public override void Init() {
|
||||
titleFont = new Font( "Arial", 16, FontStyle.Bold );
|
||||
base.Init();
|
||||
buttons = new ButtonWidget[] {
|
||||
// Column 1
|
||||
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,
|
||||
Make( -140, -50, "Env settings", Anchor.Centre,
|
||||
(g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ),
|
||||
Make( -140, 0, "Key bindings", Anchor.Centre,
|
||||
(g, w) => g.SetNewScreen( new KeyBindingsScreen( g ) ) ),
|
||||
(g, w) => g.SetNewScreen( new NormalKeyBindingsScreen( g ) ) ),
|
||||
Make( -140, 50, "Hotkeys", Anchor.Centre,
|
||||
(g, w) => g.SetNewScreen( new HotkeyScreen( g ) ) ),
|
||||
// Column 2
|
||||
@ -42,7 +42,7 @@ namespace ClassicalSharp {
|
||||
// Other
|
||||
MakeOther( 10, 5, 120, "Quit game", Anchor.BottomOrRight,
|
||||
(g, w) => g.Exit() ),
|
||||
MakeOther( 0, 5, 160, "Back to game", Anchor.Centre,
|
||||
MakeBack( true, titleFont,
|
||||
(g, w) => g.SetNewScreen( null ) ),
|
||||
};
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ namespace ClassicalSharp {
|
||||
|
||||
public override void Init() {
|
||||
game.Keyboard.KeyRepeat = true;
|
||||
titleFont = new Font( "Arial", 16, FontStyle.Bold );
|
||||
base.Init();
|
||||
regularFont = new Font( "Arial", 16, FontStyle.Regular );
|
||||
hintFont = new Font( "Arial", 14, FontStyle.Italic );
|
||||
|
||||
@ -58,8 +58,8 @@ namespace ClassicalSharp {
|
||||
buttons = new [] {
|
||||
ButtonWidget.Create( game, 260, 50, 60, 30, "Save", Anchor.Centre,
|
||||
Anchor.Centre, titleFont, OkButtonClick ),
|
||||
ButtonWidget.Create( game, 0, 5, 160, 35, "Back to menu", Anchor.Centre, Anchor.BottomOrRight,
|
||||
titleFont, (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
|
||||
MakeBack( false, titleFont,
|
||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -22,12 +22,7 @@ namespace ClassicalSharp {
|
||||
public override void Init() {
|
||||
base.Init();
|
||||
buttons[buttons.Length - 1] =
|
||||
Make( 0, 5, "Back to menu", (g, w) => g.SetNewScreen( new PauseScreen( g ) ) );
|
||||
}
|
||||
|
||||
ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick ) {
|
||||
return ButtonWidget.Create( game, x, y, 160, 35, text,
|
||||
Anchor.Centre, Anchor.BottomOrRight, titleFont, onClick );
|
||||
MakeBack( false, titleFont, (g, w) => g.SetNewScreen( new PauseScreen( g ) ) );
|
||||
}
|
||||
|
||||
protected override void TextButtonClick( Game game, Widget widget ) {
|
||||
@ -36,6 +31,7 @@ namespace ClassicalSharp {
|
||||
game.DefaultTexturePack = path;
|
||||
TexturePackExtractor extractor = new TexturePackExtractor();
|
||||
extractor.Extract( path, game );
|
||||
Recreate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,5 +22,12 @@ namespace ClassicalSharp {
|
||||
public virtual bool HidesHud {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
/// <summary> Causes the screen to recreate all of its contained widgets. </summary>
|
||||
/// <remarks> Typically used when bitmap font changes. </remarks>
|
||||
public virtual void Recreate() {
|
||||
Dispose();
|
||||
Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ namespace ClassicalSharp {
|
||||
|
||||
int hotbarCount;
|
||||
Texture selectedBlock, background;
|
||||
int blockSize, borderSize;
|
||||
int barHeight, selBlockSize, elemSize;
|
||||
int barXOffset, borderSize;
|
||||
|
||||
public override bool HandlesKeyDown( Key key ) {
|
||||
if( key >= Key.Number1 && key <= Key.Number9 ) {
|
||||
@ -25,19 +26,20 @@ namespace ClassicalSharp {
|
||||
return false;
|
||||
}
|
||||
|
||||
static FastColour backCol = new FastColour( 60, 60, 60, 160 );
|
||||
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);
|
||||
borderSize = (int)(3 * game.GuiScale);
|
||||
int width = blockSize * hotbarCount;
|
||||
X = game.Width / 2 - width / 2;
|
||||
Y = game.Height - blockSize;
|
||||
float scale = 2 * game.GuiScale;
|
||||
selBlockSize = (int)(24 * scale);
|
||||
barHeight = (int)(22 * scale);
|
||||
Width = (int)(182 * scale);
|
||||
Height = barHeight;
|
||||
|
||||
Width = width;
|
||||
Height = blockSize;
|
||||
MakeBackgroundTexture( width );
|
||||
elemSize = (int)(16 * scale);
|
||||
barXOffset = (int)(3 * scale);
|
||||
borderSize = (int)(4 * scale);
|
||||
X = game.Width / 2 - Width / 2;
|
||||
Y = game.Height - barHeight;
|
||||
|
||||
MakeBackgroundTexture();
|
||||
MakeSelectionTexture();
|
||||
}
|
||||
|
||||
@ -48,21 +50,20 @@ namespace ClassicalSharp {
|
||||
graphicsApi.SetBatchFormat( VertexFormat.Pos3fTex2fCol4b );
|
||||
|
||||
for( int i = 0; i < hotbarCount; i++ ) {
|
||||
int x = X + i * blockSize;
|
||||
IsometricBlockDrawer.Draw( game, (byte)game.Inventory.Hotbar[i], blockSize / 2 - borderSize - 2,
|
||||
x + 1 + blockSize / 2, game.Height - blockSize / 2 );
|
||||
byte block = (byte)game.Inventory.Hotbar[i];
|
||||
int x = X + barXOffset + (elemSize + borderSize) * i + elemSize / 2;
|
||||
int y = game.Height - barHeight / 2;
|
||||
float scale = (elemSize - 4) / 2f;
|
||||
IsometricBlockDrawer.Draw( game, block, scale, x, y );
|
||||
if( i == game.Inventory.HeldBlockIndex )
|
||||
selectedBlock.X1 = x;
|
||||
selectedBlock.X1 = x - selBlockSize / 2;
|
||||
}
|
||||
|
||||
selectedBlock.Render( graphicsApi );
|
||||
graphicsApi.Texturing = false;
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
graphicsApi.DeleteTexture( ref selectedBlock );
|
||||
graphicsApi.DeleteTexture( ref background );
|
||||
}
|
||||
public override void Dispose() { }
|
||||
|
||||
public override void MoveTo( int newX, int newY ) {
|
||||
int diffX = newX - X, diffY = newY - Y;
|
||||
@ -71,30 +72,16 @@ namespace ClassicalSharp {
|
||||
Init();
|
||||
}
|
||||
|
||||
void MakeBackgroundTexture( int width ) {
|
||||
Size size = new Size( width, blockSize );
|
||||
using( Bitmap bmp = IDrawer2D.CreatePow2Bitmap( size ) )
|
||||
using( IDrawer2D drawer = game.Drawer2D )
|
||||
{
|
||||
drawer.SetBitmap( bmp );
|
||||
drawer.Clear( backCol );
|
||||
for( int xx = 0; xx < hotbarCount; xx++ ) {
|
||||
drawer.DrawRectBounds( outlineCol, borderSize, xx * blockSize,
|
||||
0, blockSize, blockSize );
|
||||
}
|
||||
background = drawer.Make2DTexture( bmp, size, X, Y );
|
||||
}
|
||||
void MakeBackgroundTexture() {
|
||||
TextureRec rec = new TextureRec( 0, 0, 182/256f, 22/256f );
|
||||
background = new Texture( game.GuiTexId, X, Y, Width, Height, rec );
|
||||
}
|
||||
|
||||
void MakeSelectionTexture() {
|
||||
Size size = new Size( blockSize, blockSize );
|
||||
using( Bitmap bmp = IDrawer2D.CreatePow2Bitmap( size ) )
|
||||
using( IDrawer2D drawer = game.Drawer2D )
|
||||
{
|
||||
drawer.SetBitmap( bmp );
|
||||
drawer.DrawRectBounds( selCol, borderSize, 0, 0, blockSize, blockSize );
|
||||
selectedBlock = drawer.Make2DTexture( bmp, size, 0, Y );
|
||||
}
|
||||
int y = game.Height - selBlockSize;
|
||||
TextureRec rec = new TextureRec( 0, 22/256f, 24/256f, 24/256f );
|
||||
selectedBlock = new Texture( game.GuiTexId, 0, y,
|
||||
selBlockSize, selBlockSize, rec );
|
||||
}
|
||||
}
|
||||
}
|
@ -35,8 +35,11 @@ namespace ClassicalSharp {
|
||||
Height = defaultHeight;
|
||||
}
|
||||
|
||||
static FastColour boxCol = new FastColour( 169, 143, 192 ), shadowCol = new FastColour( 97, 81, 110 );
|
||||
//static FastColour boxCol = new FastColour( 29, 126, 192 ), shadowCol = new FastColour( 16, 72, 109 );
|
||||
static TextureRec shadowRec = new TextureRec( 0, 66/256f, 200/256f, 20/256f );
|
||||
static TextureRec selectedRec = new TextureRec( 0, 86/256f, 200/256f, 20/256f );
|
||||
static Texture shadowTex = new Texture( 0, 0, 0, 0, 0, shadowRec );
|
||||
static Texture selectedTex = new Texture( 0, 0, 0, 0, 0, selectedRec );
|
||||
|
||||
public string Text;
|
||||
public void SetText( string text ) {
|
||||
graphicsApi.DeleteTexture( ref texture );
|
||||
@ -55,6 +58,11 @@ namespace ClassicalSharp {
|
||||
|
||||
public override void Render( double delta ) {
|
||||
if( texture.IsValid ) {
|
||||
Texture backTex = Active ? selectedTex : shadowTex;
|
||||
backTex.ID = game.GuiTexId;
|
||||
backTex.X1 = X; backTex.Y1 = Y;
|
||||
backTex.Width = Width; backTex.Height = Height;
|
||||
backTex.Render( graphicsApi );
|
||||
FastColour col = Active ? FastColour.White : new FastColour( 200, 200, 200 );
|
||||
texture.Render( graphicsApi, col );
|
||||
}
|
||||
@ -78,26 +86,19 @@ namespace ClassicalSharp {
|
||||
|
||||
void MakeTexture( string text ) {
|
||||
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
||||
Size size = game.Drawer2D.MeasureSize( ref args );
|
||||
Size size = game.Drawer2D.MeasureChatSize( ref args );
|
||||
|
||||
int xOffset = Math.Max( size.Width, DesiredMaxWidth ) - size.Width;
|
||||
size.Width = Math.Max( size.Width, DesiredMaxWidth );
|
||||
int yOffset = Math.Max( size.Height, DesiredMaxHeight ) - size.Height;
|
||||
size.Height = Math.Max( size.Height, DesiredMaxHeight );
|
||||
Size baseSize = size;
|
||||
const int borderSize = 3; // 1 px for base border, 2 px for shadow, 1 px for offset text
|
||||
size.Width += borderSize; size.Height += borderSize;
|
||||
|
||||
using( Bitmap bmp = IDrawer2D.CreatePow2Bitmap( size ) )
|
||||
using( IDrawer2D drawer = game.Drawer2D )
|
||||
{
|
||||
drawer.SetBitmap( bmp );
|
||||
drawer.DrawRoundedRect( shadowCol, 3, IDrawer2D.Offset, IDrawer2D.Offset,
|
||||
baseSize.Width, baseSize.Height );
|
||||
drawer.DrawRoundedRect( boxCol, 3, 0, 0, baseSize.Width, baseSize.Height );
|
||||
|
||||
args.SkipPartsCheck = true;
|
||||
drawer.DrawText( ref args, 1 + xOffset / 2, 1 + yOffset / 2 );
|
||||
drawer.DrawChatText( ref args, xOffset / 2, yOffset / 2 );
|
||||
texture = drawer.Make2DTexture( bmp, size, 0, 0 );
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace ClassicalSharp {
|
||||
public ChatTextWidget( Game game, Font font ) : base( game, font ) {
|
||||
}
|
||||
|
||||
public static ChatTextWidget Create( Game game, int x, int y, string text, Anchor horizontal, Anchor vertical, Font font ) {
|
||||
public static new ChatTextWidget Create( Game game, int x, int y, string text, Anchor horizontal, Anchor vertical, Font font ) {
|
||||
ChatTextWidget widget = new ChatTextWidget( game, font );
|
||||
widget.Init();
|
||||
widget.HorizontalAnchor = horizontal; widget.VerticalAnchor = vertical;
|
||||
|
@ -86,6 +86,9 @@
|
||||
<Compile Include="2D\Drawing\DrawTextArgs.cs" />
|
||||
<Compile Include="2D\Drawing\GdiPlusDrawer2D.cs" />
|
||||
<Compile Include="2D\Drawing\IDrawer2D.cs" />
|
||||
<Compile Include="2D\Screens\Bindings\AdvancedKeyBindingsScreen.cs" />
|
||||
<Compile Include="2D\Screens\Bindings\KeyBindingsScreen.cs" />
|
||||
<Compile Include="2D\Screens\Bindings\NormalKeyBindingsScreen.cs" />
|
||||
<Compile Include="2D\Screens\BlockSelectScreen.cs" />
|
||||
<Compile Include="2D\Screens\ChatScreen.cs" />
|
||||
<Compile Include="2D\Screens\ClickableScreen.cs" />
|
||||
@ -96,7 +99,6 @@
|
||||
<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" />
|
||||
<Compile Include="2D\Screens\Menu\MenuScreen.cs" />
|
||||
@ -258,6 +260,7 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="2D\Drawing" />
|
||||
<Folder Include="2D\Screens" />
|
||||
<Folder Include="2D\Screens\Bindings" />
|
||||
<Folder Include="2D\Screens\Menu" />
|
||||
<Folder Include="2D\Widgets" />
|
||||
<Folder Include="2D\Widgets\Menu" />
|
||||
|
@ -111,7 +111,7 @@ namespace ClassicalSharp {
|
||||
public int ChatLines = 12;
|
||||
public bool ClickableChat, HideGui, ShowFPS = true;
|
||||
internal float HudScale = 1.0f, ChatScale = 1.0f;
|
||||
public bool ViewBobbing, UseGuiPng, ShowBlockInHand;
|
||||
public bool ViewBobbing, ShowBlockInHand;
|
||||
public bool UseSound, UseMusic;
|
||||
|
||||
public Animations Animations;
|
||||
|
@ -309,10 +309,7 @@ namespace ClassicalSharp {
|
||||
activeScreen = screen;
|
||||
}
|
||||
|
||||
public void RefreshHud() {
|
||||
hudScreen.Dispose();
|
||||
hudScreen.Init();
|
||||
}
|
||||
public void RefreshHud() { hudScreen.Recreate(); }
|
||||
|
||||
public void ShowWarning( WarningScreen screen ) {
|
||||
if( !(activeScreen is WarningScreen) ) {
|
||||
|
@ -6,8 +6,8 @@ namespace ClassicalSharp {
|
||||
public enum KeyBinding {
|
||||
Forward, Back, Left, Right, Jump, Respawn, SetSpawn, OpenChat,
|
||||
SendChat, PauseOrExit, OpenInventory, ViewDistance, PlayerList,
|
||||
Speed, NoClip, Fly, FlyUp, FlyDown, HideGui, HideFps,
|
||||
Screenshot, Fullscreen, ThirdPersonCamera, ExtendedInput,
|
||||
Speed, NoClip, Fly, FlyUp, FlyDown, ExtendedInput, HideFps,
|
||||
Screenshot, Fullscreen, ThirdPersonCamera, HideGui,
|
||||
}
|
||||
|
||||
public class KeyMap {
|
||||
@ -46,9 +46,9 @@ namespace ClassicalSharp {
|
||||
Keys[8] = Key.Enter; Keys[9] = Key.Escape; Keys[10] = Key.B;
|
||||
Keys[11] = Key.F; Keys[12] = Key.Tab; Keys[13] = Key.ShiftLeft;
|
||||
Keys[14] = Key.X; Keys[15] = Key.Z; Keys[16] = Key.Q;
|
||||
Keys[17] = Key.E; Keys[18] = Key.F1; Keys[19] = Key.F3;
|
||||
Keys[17] = Key.E; Keys[18] = Key.AltLeft; Keys[19] = Key.F3;
|
||||
Keys[20] = Key.F12; Keys[21] = Key.F11; Keys[22] = Key.F5;
|
||||
Keys[23] = Key.AltLeft;
|
||||
Keys[23] = Key.F1;
|
||||
LoadKeyBindings();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user