Mod import progress bar
This commit is contained in:
@@ -317,7 +317,7 @@ data.invalid = This isn't valid game data.
|
||||
data.import.confirm = Importing external data will overwrite[scarlet] all[] your current game data.\n[accent]This cannot be undone![]\n\nOnce the data is imported, your game will exit immediately.
|
||||
quit.confirm = Are you sure you want to quit?
|
||||
loading = [accent]Loading...
|
||||
reloading = [accent]Reloading Mods...
|
||||
downloading = [accent]Downloading...
|
||||
saving = [accent]Saving...
|
||||
respawn = [accent][[{0}][] to respawn in core
|
||||
cancelbuilding = [accent][[{0}][] to clear plan
|
||||
@@ -1103,7 +1103,6 @@ unit.reign.name = Reign
|
||||
unit.vela.name = Vela
|
||||
unit.corvus.name = Corvus
|
||||
|
||||
block.resupply-point.name = Resupply Point
|
||||
block.parallax.name = Parallax
|
||||
block.cliff.name = Cliff
|
||||
block.sand-boulder.name = Sand Boulder
|
||||
@@ -1407,7 +1406,6 @@ liquid.oil.description = Used in advanced material production and as incendiary
|
||||
liquid.cryofluid.description = Used as coolant in reactors, turrets and factories.
|
||||
|
||||
block.derelict = [lightgray] Derelict
|
||||
block.resupply-point.description = Resupplies nearby units with copper ammunition. Not compatible with units that require battery power.
|
||||
block.armored-conveyor.description = Moves items forward. Does not accept inputs from the sides.
|
||||
block.illuminator.description = Emits light.
|
||||
block.message.description = Stores a message for communication between allies.
|
||||
|
||||
@@ -107,8 +107,10 @@ public class Bar extends Element{
|
||||
}
|
||||
|
||||
Draw.colorl(0.1f);
|
||||
Draw.alpha(parentAlpha);
|
||||
bar.draw(x, y, width, height);
|
||||
Draw.color(color, blinkColor, blink);
|
||||
Draw.alpha(parentAlpha);
|
||||
|
||||
Drawable top = Tex.barTop;
|
||||
float topWidth = width * value;
|
||||
@@ -128,7 +130,7 @@ public class Bar extends Element{
|
||||
GlyphLayout lay = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
|
||||
lay.setText(font, name);
|
||||
|
||||
font.setColor(Color.white);
|
||||
font.setColor(1f, 1f, 1f, parentAlpha);
|
||||
font.draw(name, x + width / 2f - lay.width / 2f, y + height / 2f + lay.height / 2f + 1);
|
||||
|
||||
Pools.free(lay);
|
||||
|
||||
@@ -36,6 +36,7 @@ import static mindustry.Vars.*;
|
||||
public class ModsDialog extends BaseDialog{
|
||||
private ObjectMap<String, TextureRegion> textureCache = new ObjectMap<>();
|
||||
|
||||
private float modImportProgress;
|
||||
private String searchtxt = "";
|
||||
private @Nullable Seq<ModListing> modList;
|
||||
private boolean orderDate = false;
|
||||
@@ -488,11 +489,16 @@ public class ModsDialog extends BaseDialog{
|
||||
private void handleMod(String repo, HttpResponse result){
|
||||
try{
|
||||
Fi file = tmpDirectory.child(repo.replace("/", "") + ".zip");
|
||||
Streams.copy(result.getResultAsStream(), file.write(false));
|
||||
long len = result.getContentLength();
|
||||
Floatc cons = len <= 0 ? f -> {} : p -> modImportProgress = p;
|
||||
|
||||
Streams.copyProgress(result.getResultAsStream(), file.write(false), len, 4096, cons);
|
||||
|
||||
var mod = mods.importMod(file);
|
||||
mod.setRepo(repo);
|
||||
file.delete();
|
||||
Core.app.post(() -> {
|
||||
|
||||
try{
|
||||
setup();
|
||||
ui.loadfrag.hide();
|
||||
@@ -510,10 +516,13 @@ public class ModsDialog extends BaseDialog{
|
||||
}
|
||||
|
||||
private void githubImportMod(String repo, boolean isJava){
|
||||
modImportProgress = 0f;
|
||||
ui.loadfrag.show("@downloading");
|
||||
ui.loadfrag.setProgress(() -> modImportProgress);
|
||||
|
||||
if(isJava){
|
||||
githubImportJavaMod(repo);
|
||||
}else{
|
||||
ui.loadfrag.show();
|
||||
Http.get(ghApi + "/repos/" + repo, res -> {
|
||||
var json = Jval.read(res.getResultAsString());
|
||||
String mainBranch = json.getString("default_branch");
|
||||
|
||||
@@ -38,7 +38,7 @@ public class LoadingFragment extends Fragment{
|
||||
|
||||
text("@loading");
|
||||
|
||||
bar = t.add(new Bar()).pad(3).size(500f, 40f).visible(false).get();
|
||||
bar = t.add(new Bar()).pad(3).padTop(6).size(500f, 40f).visible(false).get();
|
||||
t.row();
|
||||
button = t.button("@cancel", () -> {}).pad(20).size(250f, 70f).visible(false).get();
|
||||
table = t;
|
||||
|
||||
@@ -8,4 +8,4 @@ kapt.include.compile.classpath=false
|
||||
kotlin.stdlib.default.dependency=false
|
||||
#needed for android compilation
|
||||
android.useAndroidX=true
|
||||
archash=94dd6bbd29ea8e71daffaabb530bb7697017d66d
|
||||
archash=8d15f16848ae0b2a94e38e63be965fdeb9e51f54
|
||||
|
||||
Reference in New Issue
Block a user