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