mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
More work on EnvMapAppearance v3.
This commit is contained in:
parent
b3a7df8776
commit
e05c1a14ed
@ -145,7 +145,7 @@ namespace ClassicalSharp {
|
||||
void DrawUnderline( FastBitmap dst, int x, int yOffset, ref DrawTextArgs args, bool shadowCol ) {
|
||||
int point = Utils.Floor( args.Font.Size );
|
||||
int padding = CellSize( point ) - AdjTextSize( point );
|
||||
int height = AdjTextSize( point ) + Utils.CeilDiv(padding, 2);
|
||||
int height = AdjTextSize( point ) + Utils.CeilDiv( padding, 2 );
|
||||
int offset = ShadowOffset( args.Font.Size );
|
||||
|
||||
int col = FastColour.White.ToArgb();
|
||||
|
@ -23,15 +23,13 @@ namespace ClassicalSharp.Gui {
|
||||
int chatIndex;
|
||||
int blockSize;
|
||||
|
||||
Font chatFont, chatBoldFont, chatItalicFont, chatUnderlineFont, announcementFont;
|
||||
Font chatFont, chatUrlFont, announcementFont;
|
||||
public override void Init() {
|
||||
float textScale = game.Drawer2D.UseBitmappedChat ? 1.25f : 1;
|
||||
int fontSize = (int)(12 * game.GuiChatScale * textScale);
|
||||
Utils.Clamp( ref fontSize, 8, 60 );
|
||||
chatFont = new Font( game.FontName, fontSize );
|
||||
chatBoldFont = new Font( game.FontName, fontSize, FontStyle.Bold );
|
||||
chatItalicFont = new Font( game.FontName, fontSize, FontStyle.Italic );
|
||||
chatUnderlineFont = new Font( game.FontName, fontSize, FontStyle.Underline );
|
||||
chatUrlFont = new Font( game.FontName, fontSize, FontStyle.Underline );
|
||||
|
||||
fontSize = (int)(14 * game.GuiChatScale);
|
||||
Utils.Clamp( ref fontSize, 8, 60 );
|
||||
@ -51,24 +49,24 @@ namespace ClassicalSharp.Gui {
|
||||
}
|
||||
|
||||
void ConstructWidgets() {
|
||||
textInput = new TextInputWidget( game, chatFont, chatBoldFont );
|
||||
textInput = new TextInputWidget( game, chatFont );
|
||||
textInput.YOffset = blockSize + 5;
|
||||
status = new TextGroupWidget( game, 5, chatFont, chatUnderlineFont,
|
||||
status = new TextGroupWidget( game, 5, chatFont, chatUrlFont,
|
||||
Anchor.BottomOrRight, Anchor.LeftOrTop );
|
||||
status.Init();
|
||||
status.SetUsePlaceHolder( 0, false );
|
||||
status.SetUsePlaceHolder( 1, false );
|
||||
bottomRight = new TextGroupWidget( game, 3, chatFont, chatUnderlineFont,
|
||||
bottomRight = new TextGroupWidget( game, 3, chatFont, chatUrlFont,
|
||||
Anchor.BottomOrRight, Anchor.BottomOrRight );
|
||||
bottomRight.YOffset = blockSize * 3 / 2;
|
||||
bottomRight.Init();
|
||||
normalChat = new TextGroupWidget( game, chatLines, chatFont, chatUnderlineFont,
|
||||
normalChat = new TextGroupWidget( game, chatLines, chatFont, chatUrlFont,
|
||||
Anchor.LeftOrTop, Anchor.BottomOrRight );
|
||||
normalChat.XOffset = 10;
|
||||
normalChat.YOffset = blockSize * 2 + 15;
|
||||
normalChat.Init();
|
||||
clientStatus = new TextGroupWidget( game, game.Chat.ClientStatus.Length, chatFont,
|
||||
chatUnderlineFont, Anchor.LeftOrTop, Anchor.BottomOrRight );
|
||||
chatUrlFont, Anchor.LeftOrTop, Anchor.BottomOrRight );
|
||||
clientStatus.XOffset = 10;
|
||||
clientStatus.YOffset = blockSize * 2 + 15;
|
||||
clientStatus.Init();
|
||||
@ -252,9 +250,7 @@ namespace ClassicalSharp.Gui {
|
||||
game.chatInInputBuffer = null;
|
||||
}
|
||||
chatFont.Dispose();
|
||||
chatItalicFont.Dispose();
|
||||
chatBoldFont.Dispose();
|
||||
chatUnderlineFont.Dispose();
|
||||
chatUrlFont.Dispose();
|
||||
announcementFont.Dispose();
|
||||
|
||||
normalChat.Dispose();
|
||||
|
@ -13,7 +13,6 @@ namespace ClassicalSharp.Gui {
|
||||
|
||||
public override void Init() {
|
||||
base.Init();
|
||||
INetworkProcessor network = game.Network;
|
||||
extHelpY = 50;
|
||||
|
||||
widgets = new Widget[] {
|
||||
@ -49,7 +48,6 @@ namespace ClassicalSharp.Gui {
|
||||
}
|
||||
|
||||
void MakeValidators() {
|
||||
INetworkProcessor network = game.Network;
|
||||
validators = new MenuInputValidator[] {
|
||||
new EnumValidator( typeof(FpsLimitMethod) ),
|
||||
new IntegerValidator( 16, 4096 ),
|
||||
|
@ -8,13 +8,13 @@ namespace ClassicalSharp.Gui {
|
||||
|
||||
const int lines = 3;
|
||||
internal AltTextInputWidget altText;
|
||||
public TextInputWidget( Game game, Font font, Font boldFont ) : base( game ) {
|
||||
public TextInputWidget( Game game, Font font ) : base( game ) {
|
||||
HorizontalAnchor = Anchor.LeftOrTop;
|
||||
VerticalAnchor = Anchor.BottomOrRight;
|
||||
typingLogPos = game.Chat.InputLog.Count; // Index of newest entry + 1.
|
||||
buffer = new WrappableStringBuffer( 64 * lines );
|
||||
|
||||
DrawTextArgs args = new DrawTextArgs( "_", boldFont, true );
|
||||
DrawTextArgs args = new DrawTextArgs( "_", font, true );
|
||||
caretTex = game.Drawer2D.MakeChatTextTexture( ref args, 0, 0 );
|
||||
caretTex.Width = (caretTex.Width * 3) / 4;
|
||||
defaultCaretWidth = caretTex.Width;
|
||||
|
@ -10,7 +10,7 @@ namespace ClassicalSharp.Gui {
|
||||
|
||||
public ExtPlayerListWidget( Game game, Font font ) : base( game, font ) {
|
||||
textures = new Texture[512];
|
||||
titleFont = new Font( game.FontName, font.Size, FontStyle.Italic );
|
||||
titleFont = new Font( game.FontName, font.Size );
|
||||
elementOffset = 10;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace ClassicalSharp.Events {
|
||||
SunlightColour,
|
||||
ShadowlightColour,
|
||||
|
||||
RainSpeed,
|
||||
SnowSpeed,
|
||||
WeatherSpeed,
|
||||
WeatherFade,
|
||||
}
|
||||
}
|
||||
|
@ -28,11 +28,8 @@ namespace ClassicalSharp.Map {
|
||||
/// <summary> Modifier of how fast clouds travel across the world, defaults to 1. </summary>
|
||||
public float CloudsSpeed = 1;
|
||||
|
||||
/// <summary> Modifier of how fast rain falls, defaults to 1. </summary>
|
||||
public float RainSpeed = 1;
|
||||
|
||||
/// <summary> Modifier of how fast snow falls, defaults to 1. </summary>
|
||||
public float SnowSpeed = 1;
|
||||
/// <summary> Modifier of how fast rain/snow falls, defaults to 1. </summary>
|
||||
public float WeatherSpeed = 1;
|
||||
|
||||
/// <summary> Modifier of how fast rain/snow fades, defaults to 1. </summary>
|
||||
public float WeatherFade = 1;
|
||||
@ -76,8 +73,7 @@ namespace ClassicalSharp.Map {
|
||||
EdgeBlock = Block.StillWater;
|
||||
SidesBlock = Block.Bedrock;
|
||||
CloudsSpeed = 1;
|
||||
RainSpeed = 1;
|
||||
SnowSpeed = 1;
|
||||
WeatherSpeed = 1;
|
||||
WeatherFade = 1;
|
||||
|
||||
ResetLight();
|
||||
@ -128,13 +124,13 @@ namespace ClassicalSharp.Map {
|
||||
/// event with variable 'CloudsSpeed'. </summary>
|
||||
public void SetCloudsSpeed( float speed ) { Set( speed, ref CloudsSpeed, EnvVar.CloudsSpeed ); }
|
||||
|
||||
/// <summary> Sets rain speed and raises EnvVariableChanged
|
||||
/// event with variable 'RainSpeed'. </summary>
|
||||
public void SetRainSpeed( float speed ) { Set( speed, ref RainSpeed, EnvVar.RainSpeed ); }
|
||||
/// <summary> Sets weather speed, and raises EnvVariableChanged
|
||||
/// event with variable 'WeatherSpeed'. </summary>
|
||||
public void SetWeatherSpeed( float speed ) { Set( speed, ref WeatherSpeed, EnvVar.WeatherSpeed ); }
|
||||
|
||||
/// <summary> Sets snow speed, and raises EnvVariableChanged
|
||||
/// event with variable 'SnowSpeed'. </summary>
|
||||
public void SetSnowSpeed( float speed ) { Set( speed, ref SnowSpeed, EnvVar.SnowSpeed ); }
|
||||
/// <summary> Sets weather fade rate, and raises EnvVariableChanged
|
||||
/// event with variable 'WeatherFade'. </summary>
|
||||
public void SetWeatherFade( float rate ) { Set( rate, ref WeatherFade, EnvVar.WeatherFade ); }
|
||||
|
||||
/// <summary> Sets height of the map edges in world space, and raises
|
||||
/// EnvVariableChanged event with variable 'EdgeLevel'. </summary>
|
||||
|
@ -377,9 +377,30 @@ namespace ClassicalSharp.Network {
|
||||
internal void HandleSetEnvMapProperty() {
|
||||
byte type = reader.ReadUInt8();
|
||||
int value = reader.ReadInt32();
|
||||
WorldEnv env = game.World.Env;
|
||||
Utils.Clamp( ref value, short.MinValue, short.MaxValue );
|
||||
|
||||
switch( type ) {
|
||||
// TODO: Property list
|
||||
case 0:
|
||||
Utils.Clamp( ref value, byte.MinValue, byte.MaxValue );
|
||||
env.SetSidesBlock( (Block)value ); break;
|
||||
case 1:
|
||||
Utils.Clamp( ref value, byte.MinValue, byte.MaxValue );
|
||||
env.SetEdgeBlock( (Block)value ); break;
|
||||
case 2:
|
||||
env.SetEdgeLevel( value ); break;
|
||||
case 3:
|
||||
env.SetCloudsLevel( value ); break;
|
||||
case 4:
|
||||
game.MaxViewDistance = value <= 0 ? 32768 : value;
|
||||
game.SetViewDistance( game.UserViewDistance, false ); break;
|
||||
case 5:
|
||||
env.SetCloudsSpeed( value / 256f ); break;
|
||||
case 6:
|
||||
env.SetWeatherSpeed( value / 256f ); break;
|
||||
case 7:
|
||||
Utils.Clamp( ref value, byte.MinValue, byte.MaxValue );
|
||||
env.SetWeatherFade( value / 256f ); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,8 +45,7 @@ namespace ClassicalSharp.Renderers {
|
||||
lastPos = pos;
|
||||
WorldEnv env = game.World.Env;
|
||||
|
||||
float speed = weather == Weather.Rainy ?
|
||||
1.0f * env.RainSpeed : 0.2f * env.SnowSpeed;
|
||||
float speed = (weather == Weather.Rainy ? 1.0f : 0.2f) * env.WeatherSpeed;
|
||||
vOffset = -(float)game.accumulator * speed;
|
||||
rainAcc += deltaTime;
|
||||
bool particles = weather == Weather.Rainy;
|
||||
|
Loading…
x
Reference in New Issue
Block a user