Added github import dialog
This commit is contained in:
@@ -338,6 +338,7 @@ public class UI implements ApplicationListener, Loadable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showException(String text, Throwable exc){
|
public void showException(String text, Throwable exc){
|
||||||
|
loadfrag.hide();
|
||||||
new Dialog(""){{
|
new Dialog(""){{
|
||||||
String message = Strings.getFinalMesage(exc);
|
String message = Strings.getFinalMesage(exc);
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import io.anuke.arc.*;
|
|||||||
import io.anuke.arc.collection.*;
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.io.*;
|
import io.anuke.arc.util.io.*;
|
||||||
import io.anuke.mindustry.game.*;
|
|
||||||
import io.anuke.mindustry.gen.*;
|
import io.anuke.mindustry.gen.*;
|
||||||
import io.anuke.mindustry.graphics.*;
|
import io.anuke.mindustry.graphics.*;
|
||||||
import io.anuke.mindustry.mod.Mods.*;
|
import io.anuke.mindustry.mod.Mods.*;
|
||||||
@@ -24,9 +23,35 @@ public class ModsDialog extends FloatingDialog{
|
|||||||
() -> Core.net.openURI(reportIssueURL))
|
() -> Core.net.openURI(reportIssueURL))
|
||||||
.size(250f, 64f);
|
.size(250f, 64f);
|
||||||
|
|
||||||
|
buttons.row();
|
||||||
|
|
||||||
buttons.addImageTextButton("$mods.guide", Icon.wiki,
|
buttons.addImageTextButton("$mods.guide", Icon.wiki,
|
||||||
() -> Core.net.openURI(modGuideURL))
|
() -> Core.net.openURI(modGuideURL))
|
||||||
.size(280f, 64f);
|
.size(210f, 64f);
|
||||||
|
|
||||||
|
buttons.addImageTextButton("$mod.import.github", Icon.github, () -> {
|
||||||
|
ui.showTextInput("$mod.import.github", "", "Anuken/ExampleMod", text -> {
|
||||||
|
ui.loadfrag.show();
|
||||||
|
Core.net.httpGet("http://api.github.com/repos/" + text + "/zipball/master", loc -> {
|
||||||
|
Core.net.httpGet(loc.getHeader("Location"), result -> {
|
||||||
|
try{
|
||||||
|
Streams.copyStream(result.getResultAsStream(), modDirectory.child(text.replace("/", "") + ".zip").write(false));
|
||||||
|
Core.app.post(() -> {
|
||||||
|
try{
|
||||||
|
mods.reloadContent();
|
||||||
|
setup();
|
||||||
|
ui.loadfrag.hide();
|
||||||
|
}catch(Exception e){
|
||||||
|
ui.showException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}catch(Exception e){
|
||||||
|
ui.showException(e);
|
||||||
|
}
|
||||||
|
}, t -> Core.app.post(() -> ui.showException(t)));
|
||||||
|
}, t -> Core.app.post(() -> ui.showException(t)));
|
||||||
|
});
|
||||||
|
}).size(250f, 64f);
|
||||||
|
|
||||||
shown(this::setup);
|
shown(this::setup);
|
||||||
|
|
||||||
@@ -120,27 +145,5 @@ public class ModsDialog extends FloatingDialog{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).margin(12f).width(500f);
|
}).margin(12f).width(500f);
|
||||||
|
|
||||||
//not well tested currently
|
|
||||||
if(Version.build == -1){
|
|
||||||
cont.row();
|
|
||||||
|
|
||||||
cont.addImageTextButton("$mod.import.github", Icon.github, () -> {
|
|
||||||
ui.showTextInput("$mod.import.github", "", "Anuken/ExampleMod", text -> {
|
|
||||||
Core.net.httpGet("http://api.github.com/repos/" + text + "/zipball/master", loc -> {
|
|
||||||
Core.net.httpGet(loc.getHeader("Location"), result -> {
|
|
||||||
try{
|
|
||||||
Streams.copyStream(result.getResultAsStream(), modDirectory.child(text.replace("/", "") + ".zip").write(false));
|
|
||||||
ui.loadAnd(() -> {
|
|
||||||
mods.reloadContent();
|
|
||||||
});
|
|
||||||
}catch(Exception e){
|
|
||||||
ui.showException(e);
|
|
||||||
}
|
|
||||||
}, ui::showException);
|
|
||||||
}, ui::showException);
|
|
||||||
});
|
|
||||||
}).margin(12f).width(500f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -216,7 +216,7 @@ public class TechTreeDialog extends FloatingDialog{
|
|||||||
addListener(new InputListener(){
|
addListener(new InputListener(){
|
||||||
@Override
|
@Override
|
||||||
public boolean scrolled(InputEvent event, float x, float y, float amountX, float amountY){
|
public boolean scrolled(InputEvent event, float x, float y, float amountX, float amountY){
|
||||||
setScale(Mathf.clamp(getScaleX() - amountY / 100f, 0.2f, 1f));
|
setScale(Mathf.clamp(getScaleX() - amountY / 40f, 0.2f, 1f));
|
||||||
setOrigin(Align.center);
|
setOrigin(Align.center);
|
||||||
setTransform(true);
|
setTransform(true);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user