mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-19 04:26:52 -04:00
Make loading screen look more like classic one
This commit is contained in:
parent
3b299519cd
commit
0f261a0d74
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user