Added wait for Progress Stage
This commit is contained in:
parent
ae9463124f
commit
1d9d752832
3 changed files with 41 additions and 37 deletions
|
@ -202,6 +202,7 @@ public class DataFixerAPI {
|
||||||
|
|
||||||
Runnable runner = () -> {
|
Runnable runner = () -> {
|
||||||
if (createBackup) {
|
if (createBackup) {
|
||||||
|
progress.progressStage(new TranslatableComponent("message.bclib.datafixer.progress.waitbackup"));
|
||||||
EditWorldScreen.makeBackupAndShowToast(Minecraft.getInstance().getLevelSource(), levelID);
|
EditWorldScreen.makeBackupAndShowToast(Minecraft.getInstance().getLevelSource(), levelID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,44 +44,46 @@ class ProgressLogoRender extends GridCustomRenderCell {
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0f);
|
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0f);
|
||||||
|
|
||||||
|
final int yBarLocal = (int)(transform.height*percentage);
|
||||||
|
final int yBar = transform.top + yBarLocal;
|
||||||
|
|
||||||
final float fScale = (float)(0.3*((Math.sin(time)+1.0)*0.5) + 0.7);
|
final float fScale = (float)(0.3*((Math.sin(time)+1.0)*0.5) + 0.7);
|
||||||
int height = (int)(transform.height*fScale);
|
int height = (int)(transform.height*fScale);
|
||||||
int width = (int)(transform.width*fScale);
|
int width = (int)(transform.width*fScale);
|
||||||
width -= ((transform.width-width)%2);
|
width -= ((transform.width-width)%2);
|
||||||
height -= ((transform.height-height)%2);
|
height -= ((transform.height-height)%2);
|
||||||
|
|
||||||
final int yOffset = (transform.height-height)/2;
|
final int yOffset = (transform.height-height)/2;
|
||||||
final int xOffset = (transform.width-width)/2;
|
final int xOffset = (transform.width-width)/2;
|
||||||
|
|
||||||
final int yBarLocal = (int)(transform.height*percentage);
|
|
||||||
final int yBar = transform.top + yBarLocal;
|
final int yBarImage = Math.max(0, Math.min(height, yBarLocal - yOffset));
|
||||||
|
final float relativeY = ((float)yBarImage/height);
|
||||||
final float relativeY = ((float)(yBarLocal - yOffset)/height);
|
|
||||||
|
if (yBarImage>0) {
|
||||||
final int uvTopLogo = (int)(relativeY * LOGO_SIZE);
|
final int uvTopLogo = (int)(relativeY * LOGO_SIZE);
|
||||||
final int uvTopPixelated = (int)(relativeY * PIXELATED_SIZE);
|
|
||||||
|
|
||||||
if (uvTopLogo>0) {
|
|
||||||
RenderSystem.setShaderTexture(0, BCLibScreen.BCLIB_LOGO_LOCATION);
|
RenderSystem.setShaderTexture(0, BCLibScreen.BCLIB_LOGO_LOCATION);
|
||||||
GuiComponent.blit(poseStack,
|
GuiComponent.blit(poseStack,
|
||||||
xOffset + transform.left,
|
xOffset + transform.left,
|
||||||
yOffset + transform.top,
|
yOffset + transform.top,
|
||||||
width,
|
width,
|
||||||
yBarLocal - yOffset,
|
yBarImage,
|
||||||
0, 0, LOGO_SIZE, uvTopLogo,
|
0, 0, LOGO_SIZE, uvTopLogo,
|
||||||
LOGO_SIZE, LOGO_SIZE
|
LOGO_SIZE, LOGO_SIZE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uvTopPixelated<PIXELATED_SIZE) {
|
if (yBarImage<height) {
|
||||||
|
final int uvTopPixelated = (int)(relativeY * PIXELATED_SIZE);
|
||||||
RenderSystem.setShaderTexture(0, ProgressScreen.BCLIB_LOGO_PIXELATED_LOCATION);
|
RenderSystem.setShaderTexture(0, ProgressScreen.BCLIB_LOGO_PIXELATED_LOCATION);
|
||||||
GuiComponent.blit(poseStack,
|
GuiComponent.blit(poseStack,
|
||||||
xOffset + transform.left,
|
xOffset + transform.left,
|
||||||
yBar,
|
yOffset + transform.top + yBarImage,
|
||||||
width,
|
width,
|
||||||
height-(yBarLocal - yOffset),
|
height - yBarImage,
|
||||||
0, uvTopPixelated, PIXELATED_SIZE, PIXELATED_SIZE-uvTopPixelated,
|
0, uvTopPixelated, PIXELATED_SIZE, PIXELATED_SIZE-uvTopPixelated,
|
||||||
PIXELATED_SIZE, PIXELATED_SIZE
|
PIXELATED_SIZE, PIXELATED_SIZE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +103,7 @@ public class ProgressScreen extends GridScreen implements ProgressListener, Atom
|
||||||
|
|
||||||
static final ResourceLocation BCLIB_LOGO_PIXELATED_LOCATION = new ResourceLocation(BCLib.MOD_ID, "iconpixelated.png");
|
static final ResourceLocation BCLIB_LOGO_PIXELATED_LOCATION = new ResourceLocation(BCLib.MOD_ID, "iconpixelated.png");
|
||||||
public ProgressScreen(@Nullable Screen parent, Component title, Component description) {
|
public ProgressScreen(@Nullable Screen parent, Component title, Component description) {
|
||||||
super(parent, title, 20, false);
|
super(parent, title, 20, true);
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +130,7 @@ public class ProgressScreen extends GridScreen implements ProgressListener, Atom
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldCloseOnEsc() {
|
public boolean shouldCloseOnEsc() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component getProgressComponent(){
|
public Component getProgressComponent(){
|
||||||
|
@ -163,28 +165,28 @@ public class ProgressScreen extends GridScreen implements ProgressListener, Atom
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void progressStartNoAbort(Component component) {
|
public void progressStartNoAbort(Component text) {
|
||||||
this.progressStage(component);
|
this.progressStage(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void progressStart(Component component) {
|
public void progressStart(Component text) {
|
||||||
this.progressStage(component);
|
this.progressStage(text);
|
||||||
this.progressStagePercentage(0);
|
this.progressStagePercentage(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void progressStage(Component component) {
|
public void progressStage(Component text) {
|
||||||
stageComponent = component;
|
stageComponent = text;
|
||||||
if (stage!=null) stage.setText(component);
|
if (stage!=null) stage.setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void progressStagePercentage(int i) {
|
public void progressStagePercentage(int progress) {
|
||||||
if (i!=currentProgress) {
|
if (progress!=currentProgress) {
|
||||||
currentProgress = i;
|
currentProgress = progress;
|
||||||
if (progressImage!=null) progressImage.percentage = currentProgress / 100.0f;
|
if (progressImage!=null) progressImage.percentage = currentProgress / 100.0f;
|
||||||
if (progress!=null) progress.setText(getProgressComponent());
|
if (this.progress !=null) this.progress.setText(getProgressComponent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
"title.bclib.modmissmatch": "Mod Version Conflict",
|
"title.bclib.modmissmatch": "Mod Version Conflict",
|
||||||
"message.bclib.modmissmatch": "Some Mods on this client do not match the version of Mods on the Server.\n\nMismatching Mods can result in odd game behavior or crashes. Please make sue that you use the same mods as the server.",
|
"message.bclib.modmissmatch": "Some Mods on this client do not match the version of Mods on the Server.\n\nMismatching Mods can result in odd game behavior or crashes. Please make sue that you use the same mods as the server.",
|
||||||
|
|
||||||
|
"message.bclib.datafixer.progress.waitbackup": "Waiting for Backup to finish. This may take a while!",
|
||||||
"message.bclib.datafixer.progress.reading": "Reading Data",
|
"message.bclib.datafixer.progress.reading": "Reading Data",
|
||||||
"message.bclib.datafixer.progress.players": "Fixing Players",
|
"message.bclib.datafixer.progress.players": "Fixing Players",
|
||||||
"message.bclib.datafixer.progress.level": "Applying Patches to level.dat",
|
"message.bclib.datafixer.progress.level": "Applying Patches to level.dat",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue