diff --git a/ClassicalSharp/2D/GuiElement.cs b/ClassicalSharp/2D/GuiElement.cs index c4bbc1f36..05a1b4e37 100644 --- a/ClassicalSharp/2D/GuiElement.cs +++ b/ClassicalSharp/2D/GuiElement.cs @@ -54,7 +54,7 @@ namespace ClassicalSharp.Gui { public bool HandlesAllInput, BlocksWorld, HidesHud, RenderHudOver; - public abstract void OnResize(int width, int height); + public abstract void OnResize(); protected abstract void ContextLost(); diff --git a/ClassicalSharp/2D/Screens/ChatScreen.cs b/ClassicalSharp/2D/Screens/ChatScreen.cs index bf7512c81..b87476809 100644 --- a/ClassicalSharp/2D/Screens/ChatScreen.cs +++ b/ClassicalSharp/2D/Screens/ChatScreen.cs @@ -297,7 +297,7 @@ namespace ClassicalSharp.Gui.Screens { UpdateChatYOffset(true); } - public override void OnResize(int width, int height) { + public override void OnResize() { bool active = altText != null && altText.Active; Recreate(); altText.SetActive(active); diff --git a/ClassicalSharp/2D/Screens/DisconnectScreen.cs b/ClassicalSharp/2D/Screens/DisconnectScreen.cs index 6a455c9ed..0b3289283 100644 --- a/ClassicalSharp/2D/Screens/DisconnectScreen.cs +++ b/ClassicalSharp/2D/Screens/DisconnectScreen.cs @@ -56,7 +56,7 @@ namespace ClassicalSharp.Gui.Screens { messageFont.Dispose(); } - public override void OnResize(int width, int height) { + public override void OnResize() { titleWidget.Reposition(); messageWidget.Reposition(); reconnect.Reposition(); diff --git a/ClassicalSharp/2D/Screens/HudScreen.cs b/ClassicalSharp/2D/Screens/HudScreen.cs index d140b4774..9f2ae670a 100644 --- a/ClassicalSharp/2D/Screens/HudScreen.cs +++ b/ClassicalSharp/2D/Screens/HudScreen.cs @@ -106,8 +106,8 @@ namespace ClassicalSharp.Gui.Screens { game.Graphics.ContextRecreated -= ContextRecreated; } - public override void OnResize(int width, int height) { - chat.OnResize(width, height); + public override void OnResize() { + chat.OnResize(); hotbar.Reposition(); if (playerList != null) { diff --git a/ClassicalSharp/2D/Screens/InventoryScreen.cs b/ClassicalSharp/2D/Screens/InventoryScreen.cs index a10c71a6b..e8ed542b2 100644 --- a/ClassicalSharp/2D/Screens/InventoryScreen.cs +++ b/ClassicalSharp/2D/Screens/InventoryScreen.cs @@ -34,7 +34,7 @@ namespace ClassicalSharp.Gui.Screens { public override void Render(double delta) { table.Render(delta); } - public override void OnResize(int width, int height) { table.Reposition(); } + public override void OnResize() { table.Reposition(); } public override void Dispose() { font.Dispose(); diff --git a/ClassicalSharp/2D/Screens/LoadingMapScreen.cs b/ClassicalSharp/2D/Screens/LoadingMapScreen.cs index c8660f8a2..d902f271b 100644 --- a/ClassicalSharp/2D/Screens/LoadingMapScreen.cs +++ b/ClassicalSharp/2D/Screens/LoadingMapScreen.cs @@ -25,7 +25,7 @@ namespace ClassicalSharp.Gui.Screens { string title, message; float progress; TextWidget titleWidget, messageWidget; - const int progWidth = 220, progHeight = 10; + const int progWidth = 200, progHeight = 4; readonly FastColour backCol = new FastColour(128, 128, 128); readonly FastColour progressCol = new FastColour(128, 255, 128); @@ -44,7 +44,7 @@ namespace ClassicalSharp.Gui.Screens { if (titleWidget != null) titleWidget.Dispose(); titleWidget = TextWidget.Create(game, title, font) - .SetLocation(Anchor.Centre, Anchor.Centre, 0, -80); + .SetLocation(Anchor.Centre, Anchor.Centre, 0, -31); } public void SetMessage(string message) { @@ -52,7 +52,7 @@ namespace ClassicalSharp.Gui.Screens { if (messageWidget != null) messageWidget.Dispose(); messageWidget = TextWidget.Create(game, message, font) - .SetLocation(Anchor.Centre, Anchor.Centre, 0, -30); + .SetLocation(Anchor.Centre, Anchor.Centre, 0, 17); } public void SetProgress(float progress) { @@ -72,7 +72,7 @@ namespace ClassicalSharp.Gui.Screens { game.Graphics.ContextRecreated -= ContextRecreated; } - public override void OnResize(int width, int height) { + public override void OnResize() { messageWidget.Reposition(); titleWidget.Reposition(); } @@ -121,10 +121,11 @@ namespace ClassicalSharp.Gui.Screens { messageWidget.Render(delta); gfx.Texturing = false; - int progX = game.Width / 2 - progWidth / 2; - int progY = game.Height / 2 - progHeight / 2; - gfx.Draw2DQuad(progX, progY, progWidth, progHeight, backCol); - gfx.Draw2DQuad(progX, progY, (int)(progWidth * progress), progHeight, progressCol); + int x = CalcPos(Anchor.Centre, 0, progWidth, game.Width); + int y = CalcPos(Anchor.Centre, 34, progHeight, game.Height); + + gfx.Draw2DQuad(x, y, progWidth, progHeight, backCol); + gfx.Draw2DQuad(x, y, (int)(progWidth * progress), progHeight, progressCol); } void DrawBackground() { @@ -134,7 +135,7 @@ namespace ClassicalSharp.Gui.Screens { int col = new FastColour(64, 64, 64).Pack(); int texLoc = BlockInfo.GetTextureLoc(Block.Dirt, Side.Top); - Texture tex = new Texture(0, 0, 0, game.Width, 64, + Texture tex = new Texture(0, 0, 0, game.Width, 64, TerrainAtlas1D.GetTexRec(texLoc, 1, out atlasIndex)); tex.U2 = (float)game.Width / 64; bool bound = false; @@ -155,7 +156,7 @@ namespace ClassicalSharp.Gui.Screens { bound = true; game.Graphics.BindTexture(TerrainAtlas1D.TexIds[atlasIndex]); } - + ModelCache cache = game.ModelCache; game.Graphics.SetBatchFormat(VertexFormat.P3fT2fC4b); game.Graphics.UpdateDynamicVb_IndexedTris(cache.vb, cache.vertices, index); diff --git a/ClassicalSharp/2D/Screens/Menu/ListScreen.cs b/ClassicalSharp/2D/Screens/Menu/ListScreen.cs index 5625897f8..17cbc9639 100644 --- a/ClassicalSharp/2D/Screens/Menu/ListScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/ListScreen.cs @@ -124,7 +124,7 @@ namespace ClassicalSharp.Gui.Screens { return HandleMouseDown(widgets, mouseX, mouseY, button) >= 0; } - public override void OnResize(int width, int height) { + public override void OnResize() { RepositionWidgets(widgets); } } diff --git a/ClassicalSharp/2D/Screens/Menu/MenuOptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/MenuOptionsScreen.cs index 2e93796f8..a0257b18f 100644 --- a/ClassicalSharp/2D/Screens/Menu/MenuOptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/MenuOptionsScreen.cs @@ -41,8 +41,8 @@ namespace ClassicalSharp.Gui.Screens { base.Dispose(); } - public override void OnResize(int width, int height) { - base.OnResize(width, height); + public override void OnResize() { + base.OnResize(); if (extHelp == null) return; RepositionExtendedHelp(); } diff --git a/ClassicalSharp/2D/Screens/Menu/MenuScreen.cs b/ClassicalSharp/2D/Screens/Menu/MenuScreen.cs index ad86738a5..796bb4540 100644 --- a/ClassicalSharp/2D/Screens/Menu/MenuScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/MenuScreen.cs @@ -40,7 +40,7 @@ namespace ClassicalSharp.Gui.Screens { protected override void ContextLost() { DisposeWidgets(widgets); } - public override void OnResize(int width, int height) { + public override void OnResize() { RepositionWidgets(widgets); } diff --git a/ClassicalSharp/2D/Screens/StatusScreen.cs b/ClassicalSharp/2D/Screens/StatusScreen.cs index e752b2513..94c2a301e 100644 --- a/ClassicalSharp/2D/Screens/StatusScreen.cs +++ b/ClassicalSharp/2D/Screens/StatusScreen.cs @@ -119,7 +119,7 @@ namespace ClassicalSharp.Gui.Screens { void ChatFontChanged(object sender, EventArgs e) { Recreate(); } - public override void OnResize(int width, int height) { } + public override void OnResize() { } void DrawPosition() { int index = 0; diff --git a/ClassicalSharp/Game/GuiInterface.cs b/ClassicalSharp/Game/GuiInterface.cs index cc94ddb9f..7055471c1 100644 --- a/ClassicalSharp/Game/GuiInterface.cs +++ b/ClassicalSharp/Game/GuiInterface.cs @@ -131,12 +131,11 @@ namespace ClassicalSharp { } internal void OnResize() { - if (activeScreen != null) - activeScreen.OnResize(game.Width, game.Height); - hudScreen.OnResize(game.Width, game.Height); + if (activeScreen != null) activeScreen.OnResize(); + hudScreen.OnResize(); for (int i = 0; i < overlays.Count; i++) { - overlays[i].OnResize(game.Width, game.Height); + overlays[i].OnResize(); } } } diff --git a/src/Client/Program.c b/src/Client/Program.c index 29c897590..4c2aa77a5 100644 --- a/src/Client/Program.c +++ b/src/Client/Program.c @@ -49,7 +49,7 @@ int main(void) { String title = String_FromConst(PROGRAM_APP_NAME); String rawArgs = Platform_GetCommandLineArgs(); - // rawArgs = String_FromReadonly("UnknownShadow200 fff 127.0.0.1 25566"); + rawArgs = String_FromReadonly("UnknownShadow200 fff 127.0.0.1 25566"); //rawArgs = String_FromReadonly("UnknownShadow200"); String args[5]; UInt32 argsCount = Array_Elems(args); diff --git a/src/Client/Screens.c b/src/Client/Screens.c index 73192f64f..b87ce2a98 100644 --- a/src/Client/Screens.c +++ b/src/Client/Screens.c @@ -450,7 +450,7 @@ void LoadingScreen_SetTitle(LoadingScreen* screen) { Elem_TryFree(&screen->Title); TextWidget_Create(&screen->Title, &title, &screen->Font); - Widget_SetLocation((Widget*)(&screen->Title), ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -80); + Widget_SetLocation((Widget*)(&screen->Title), ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -31); } void LoadingScreen_SetMessage(LoadingScreen* screen) { @@ -458,7 +458,7 @@ void LoadingScreen_SetMessage(LoadingScreen* screen) { Elem_TryFree(&screen->Message); TextWidget_Create(&screen->Message, &message, &screen->Font); - Widget_SetLocation((Widget*)(&screen->Message), ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -30); + Widget_SetLocation((Widget*)(&screen->Message), ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 17); } void LoadingScreen_MapLoading(void* obj, Real32 progress) { @@ -554,19 +554,18 @@ void LoadingScreen_Init(GuiElement* elem) { Event_RegisterVoid(&GfxEvents_ContextRecreated, screen, LoadingScreen_ContextRecreated); } -#define PROG_BAR_WIDTH 220 -#define PROG_BAR_HEIGHT 10 +#define PROG_BAR_WIDTH 200 +#define PROG_BAR_HEIGHT 4 void LoadingScreen_Render(GuiElement* elem, Real64 delta) { LoadingScreen* screen = (LoadingScreen*)elem; Gfx_SetTexturing(true); LoadingScreen_DrawBackground(); Elem_Render(&screen->Title, delta); Elem_Render(&screen->Message, delta); - Gfx_SetTexturing(false); - Int32 x = Game_Width / 2 - PROG_BAR_WIDTH / 2; - Int32 y = Game_Height / 2 - PROG_BAR_HEIGHT / 2; + Int32 x = Gui_CalcPos(ANCHOR_CENTRE, 0, PROG_BAR_WIDTH, Game_Width); + Int32 y = Gui_CalcPos(ANCHOR_CENTRE, 34, PROG_BAR_HEIGHT, Game_Height); Int32 progWidth = (Int32)(PROG_BAR_WIDTH * screen->Progress); PackedCol backCol = PACKEDCOL_CONST(128, 128, 128, 255);