Research system progress
This commit is contained in:
@@ -30,7 +30,7 @@ public class LanguageDialog extends BaseDialog{
|
||||
Table langs = new Table();
|
||||
langs.marginRight(24f).marginLeft(24f);
|
||||
ScrollPane pane = new ScrollPane(langs);
|
||||
pane.setFadeScrollBars(false);
|
||||
pane.setScrollingDisabled(true, false);
|
||||
|
||||
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
||||
|
||||
|
||||
@@ -40,11 +40,12 @@ public class PausedDialog extends BaseDialog{
|
||||
cont.button("$back", Icon.left, this::hide).colspan(2).width(dw * 2 + 20f);
|
||||
|
||||
cont.row();
|
||||
if(state.isCampaign()){
|
||||
cont.button("$techtree", Icon.tree, ui.tech::show);
|
||||
}else{
|
||||
cont.button("$database", Icon.book, ui.database::show);
|
||||
}
|
||||
//if(state.isCampaign()){
|
||||
// cont.button("$techtree", Icon.tree, ui.tech::show);
|
||||
//}else{
|
||||
// cont.button("$database", Icon.book, ui.database::show);
|
||||
//}
|
||||
cont.button("placeholder", Icon.warning, () -> ui.showInfo("go away"));
|
||||
cont.button("$settings", Icon.settings, ui.settings::show);
|
||||
|
||||
if(!state.rules.tutorial){
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.ui.dialogs;
|
||||
|
||||
import arc.graphics.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
@@ -23,14 +22,15 @@ public class ResourcesDialog extends BaseDialog{
|
||||
t.margin(10f);
|
||||
int[] exports = universe.getTotalExports();
|
||||
for(Item item : content.items()){
|
||||
if(exports[item.id] > 0 || data.getItem(item) > 0){
|
||||
//TODO display total items
|
||||
if(exports[item.id] > 0){
|
||||
t.image(item.icon(Cicon.small)).padRight(4);
|
||||
t.add(ui.formatAmount(data.getItem(item))).color(Color.lightGray);
|
||||
if(exports[item.id] > 0){
|
||||
//t.add(ui.formatAmount(data.getItem(item))).color(Color.lightGray);
|
||||
//if(exports[item.id] > 0){
|
||||
t.add("+ [accent]" + ui.formatAmount(exports[item.id]) + " [lightgray]/T");
|
||||
}else{
|
||||
t.add();
|
||||
}
|
||||
//}else{
|
||||
// t.add();
|
||||
//}
|
||||
t.row();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import arc.scene.ui.TextButton.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.core.GameState.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.game.EventType.*;
|
||||
@@ -21,7 +22,11 @@ import mindustry.graphics.*;
|
||||
import mindustry.input.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
import static arc.Core.bundle;
|
||||
import java.io.*;
|
||||
import java.util.zip.*;
|
||||
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.net;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class SettingsMenuDialog extends SettingsDialog{
|
||||
@@ -107,7 +112,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
if(ios){
|
||||
Fi file = Core.files.local("mindustry-data-export.zip");
|
||||
try{
|
||||
data.exportData(file);
|
||||
exportData(file);
|
||||
}catch(Exception e){
|
||||
ui.showException(e);
|
||||
}
|
||||
@@ -115,7 +120,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
}else{
|
||||
platform.showFileChooser(false, "zip", file -> {
|
||||
try{
|
||||
data.exportData(file);
|
||||
exportData(file);
|
||||
ui.showInfo("$data.exported");
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
@@ -129,7 +134,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
|
||||
t.button("$data.import", Icon.download, style, () -> ui.showConfirm("$confirm", "$data.import.confirm", () -> platform.showFileChooser(true, "zip", file -> {
|
||||
try{
|
||||
data.importData(file);
|
||||
importData(file);
|
||||
Core.app.exit();
|
||||
}catch(IllegalArgumentException e){
|
||||
ui.showErrorMessage("$data.invalid");
|
||||
@@ -365,6 +370,43 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
graphics.checkPref("flow", true);
|
||||
}
|
||||
|
||||
public void exportData(Fi file) throws IOException{
|
||||
Seq<Fi> files = new Seq<>();
|
||||
files.add(Core.settings.getSettingsFile());
|
||||
files.addAll(customMapDirectory.list());
|
||||
files.addAll(saveDirectory.list());
|
||||
files.addAll(screenshotDirectory.list());
|
||||
files.addAll(modDirectory.list());
|
||||
files.addAll(schematicDirectory.list());
|
||||
String base = Core.settings.getDataDirectory().path();
|
||||
|
||||
try(OutputStream fos = file.write(false, 2048); ZipOutputStream zos = new ZipOutputStream(fos)){
|
||||
for(Fi add : files){
|
||||
if(add.isDirectory()) continue;
|
||||
zos.putNextEntry(new ZipEntry(add.path().substring(base.length())));
|
||||
Streams.copy(add.read(), zos);
|
||||
zos.closeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void importData(Fi file){
|
||||
Fi dest = Core.files.local("zipdata.zip");
|
||||
file.copyTo(dest);
|
||||
Fi zipped = new ZipFi(dest);
|
||||
|
||||
Fi base = Core.settings.getDataDirectory();
|
||||
if(!zipped.child("settings.bin").exists()){
|
||||
throw new IllegalArgumentException("Not valid save data.");
|
||||
}
|
||||
|
||||
//purge existing tmp data, keep everything else
|
||||
tmpDirectory.deleteDirectory();
|
||||
|
||||
zipped.walk(f -> f.copyTo(base.child(f.path())));
|
||||
dest.delete();
|
||||
}
|
||||
|
||||
private void back(){
|
||||
rebuildMenu();
|
||||
prefs.clearChildren();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mindustry.ui.dialogs;
|
||||
|
||||
import arc.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.input.*;
|
||||
@@ -35,15 +36,17 @@ public class TechTreeDialog extends BaseDialog{
|
||||
private ObjectSet<TechTreeNode> nodes = new ObjectSet<>();
|
||||
private TechTreeNode root = new TechTreeNode(TechTree.root, null);
|
||||
private Rect bounds = new Rect();
|
||||
private ItemsDisplay items;
|
||||
private View view;
|
||||
private Cons<TechNode> selector = c -> {};
|
||||
|
||||
public TechTreeDialog(){
|
||||
super("");
|
||||
|
||||
titleTable.remove();
|
||||
margin(0f).marginBottom(8);
|
||||
Stack stack = cont.stack(view = new View(), items = new ItemsDisplay()).grow().get();
|
||||
Stack stack = cont.stack(view = new View()/*, items = new ItemsDisplay()*/).grow().get();
|
||||
|
||||
shouldPause = true;
|
||||
|
||||
Events.on(ContentReloadEvent.class, e -> {
|
||||
nodes.clear();
|
||||
@@ -72,7 +75,7 @@ public class TechTreeDialog extends BaseDialog{
|
||||
addListener(new InputListener(){
|
||||
@Override
|
||||
public boolean scrolled(InputEvent event, float x, float y, float amountX, float amountY){
|
||||
view.setScale(Mathf.clamp(view.getScaleX() - amountY / 40f, 0.25f, 1f));
|
||||
view.setScale(Mathf.clamp(view.getScaleX() - amountY / 10f * view.getScaleX(), 0.25f, 1f));
|
||||
view.setOrigin(Align.center);
|
||||
view.setTransform(true);
|
||||
return true;
|
||||
@@ -112,6 +115,15 @@ public class TechTreeDialog extends BaseDialog{
|
||||
});
|
||||
}
|
||||
|
||||
public Dialog show(Cons<TechNode> selector){
|
||||
this.selector = selector;
|
||||
return super.show();
|
||||
}
|
||||
|
||||
public Dialog show(){
|
||||
return show(c -> {});
|
||||
}
|
||||
|
||||
void treeLayout(){
|
||||
float spacing = 20f;
|
||||
LayoutNode node = new LayoutNode(root, null);
|
||||
@@ -163,8 +175,6 @@ public class TechTreeDialog extends BaseDialog{
|
||||
l.visible = !locked;
|
||||
checkNodes(l);
|
||||
}
|
||||
|
||||
items.rebuild();
|
||||
}
|
||||
|
||||
void showToast(String info){
|
||||
@@ -247,9 +257,13 @@ public class TechTreeDialog extends BaseDialog{
|
||||
}
|
||||
});
|
||||
}
|
||||
}else if(data.hasItems(node.node.requirements) && locked(node.node)){
|
||||
unlock(node.node);
|
||||
}else if(locked(node.node)){
|
||||
selector.get(node.node);
|
||||
}
|
||||
//TODO select it
|
||||
//else if(data.hasItems(node.node.requirements) && locked(node.node)){
|
||||
// unlock(node.node);
|
||||
//}
|
||||
});
|
||||
button.hovered(() -> {
|
||||
if(!mobile && hoverNode != button && node.visible){
|
||||
@@ -269,7 +283,7 @@ public class TechTreeDialog extends BaseDialog{
|
||||
button.update(() -> {
|
||||
float offset = (Core.graphics.getHeight() % 2) / 2f;
|
||||
button.setPosition(node.x + panX + width / 2f, node.y + panY + height / 2f + offset, Align.center);
|
||||
button.getStyle().up = !locked(node.node) ? Tex.buttonOver : !data.hasItems(node.node.requirements) ? Tex.buttonRed : Tex.button;
|
||||
button.getStyle().up = !locked(node.node) ? Tex.buttonOver : Tex.button;
|
||||
((TextureRegionDrawable)button.getStyle().imageUp)
|
||||
.setRegion(node.visible ? node.node.content.icon(Cicon.medium) : Icon.lock.getRegion());
|
||||
button.getImage().setColor(!locked(node.node) ? Color.white : Color.gray);
|
||||
@@ -304,9 +318,11 @@ public class TechTreeDialog extends BaseDialog{
|
||||
panY = ry - bounds.y - oy;
|
||||
}
|
||||
|
||||
/*
|
||||
void unlock(TechNode node){
|
||||
data.unlockContent(node.content);
|
||||
data.removeItems(node.requirements);
|
||||
//TODO this should not happen
|
||||
//data.removeItems(node.requirements);
|
||||
showToast(Core.bundle.format("researched", node.content.localizedName));
|
||||
checkNodes(root);
|
||||
hoverNode = null;
|
||||
@@ -315,7 +331,7 @@ public class TechTreeDialog extends BaseDialog{
|
||||
Core.scene.act();
|
||||
Sounds.unlock.play();
|
||||
Events.fire(new ResearchEvent(node.content));
|
||||
}
|
||||
}*/
|
||||
|
||||
void rebuild(){
|
||||
ImageButton button = hoverNode;
|
||||
@@ -357,8 +373,8 @@ public class TechTreeDialog extends BaseDialog{
|
||||
list.left();
|
||||
list.image(req.item.icon(Cicon.small)).size(8 * 3).padRight(3);
|
||||
list.add(req.item.localizedName).color(Color.lightGray);
|
||||
list.label(() -> " " + Math.min(data.getItem(req.item), req.amount) + " / " + req.amount)
|
||||
.update(l -> l.setColor(data.has(req.item, req.amount) ? Color.lightGray : Color.scarlet));
|
||||
list.label(() -> " " + (player.team().core() != null ? Math.min(player.team().core().items.get(req.item), req.amount) + " / " : "") + req.amount)
|
||||
.update(l -> {}/*l.setColor(data.has(req.item, req.amount) ? Color.lightGray : Color.scarlet)*/);//TODO
|
||||
}).fillX().left();
|
||||
t.row();
|
||||
}
|
||||
@@ -383,11 +399,13 @@ public class TechTreeDialog extends BaseDialog{
|
||||
}
|
||||
}).pad(9);
|
||||
|
||||
//TODO research select button
|
||||
/*
|
||||
if(mobile && locked(node)){
|
||||
b.row();
|
||||
b.button("$research", Icon.ok, Styles.nodet, () -> unlock(node))
|
||||
.disabled(i -> !data.hasItems(node.requirements)).growX().height(44f).colspan(3);
|
||||
}
|
||||
}*/
|
||||
});
|
||||
|
||||
infoTable.row();
|
||||
|
||||
Reference in New Issue
Block a user