New UI
BIN
core/assets-raw/sprites/ui/icons-category/icon-crafting.png
Normal file
After Width: | Height: | Size: 231 B |
BIN
core/assets-raw/sprites/ui/icons-category/icon-defense.png
Normal file
After Width: | Height: | Size: 273 B |
BIN
core/assets-raw/sprites/ui/icons-category/icon-distribution.png
Normal file
After Width: | Height: | Size: 204 B |
BIN
core/assets-raw/sprites/ui/icons-category/icon-effect.png
Normal file
After Width: | Height: | Size: 268 B |
BIN
core/assets-raw/sprites/ui/icons-category/icon-liquid.png
Normal file
After Width: | Height: | Size: 266 B |
BIN
core/assets-raw/sprites/ui/icons-category/icon-power.png
Normal file
After Width: | Height: | Size: 231 B |
BIN
core/assets-raw/sprites/ui/icons-category/icon-production.png
Normal file
After Width: | Height: | Size: 246 B |
BIN
core/assets-raw/sprites/ui/icons-category/icon-turret.png
Normal file
After Width: | Height: | Size: 246 B |
BIN
core/assets-raw/sprites/ui/icons-category/icon-units.png
Normal file
After Width: | Height: | Size: 238 B |
BIN
core/assets-raw/sprites/ui/icons-category/icon-upgrade.png
Normal file
After Width: | Height: | Size: 252 B |
Before Width: | Height: | Size: 109 B |
Before Width: | Height: | Size: 104 B |
Before Width: | Height: | Size: 97 B |
Before Width: | Height: | Size: 110 B |
Before Width: | Height: | Size: 98 B |
Before Width: | Height: | Size: 97 B |
Before Width: | Height: | Size: 125 B |
Before Width: | Height: | Size: 116 B |
Before Width: | Height: | Size: 560 B |
Before Width: | Height: | Size: 551 B |
Before Width: | Height: | Size: 557 B |
@ -288,6 +288,7 @@ text.no = No
|
||||
text.info.title = Info
|
||||
text.error.title = [crimson]An error has occured
|
||||
text.error.crashtitle = An error has occured
|
||||
text.blocks.unknown=[LIGHT_GRAY]???
|
||||
text.blocks.blockinfo = Block Info
|
||||
text.blocks.powercapacity = Power Capacity
|
||||
text.blocks.powershot = Power/Shot
|
||||
@ -406,8 +407,6 @@ mode.waves.name = waves
|
||||
mode.waves.description = the normal mode. limited resources and automatic incoming waves.
|
||||
mode.sandbox.name = sandbox
|
||||
mode.sandbox.description = infinite resources and no timer for waves.
|
||||
mode.custom.warning = [scarlet]UNLOCKS IN CUSTOM GAMES OR SERVERS ARE NOT SAVED.[]\n\nPlay in sectors to unlock things.
|
||||
mode.custom.warning.read = Just to make sure you've read it\:\n[scarlet]UNLOCKS IN CUSTOM GAMES DO NOT CARRY OVER TO SECTORS OR OTHER MODES\!\n\n[LIGHT_GRAY](I wish this wasn't necessary, but apparently it is)
|
||||
mode.freebuild.name = freebuild
|
||||
mode.freebuild.description = limited resources and no timer for waves.
|
||||
mode.pvp.name = PvP
|
||||
@ -495,7 +494,7 @@ text.mech.ability = [LIGHT_GRAY]Ability\: {0}
|
||||
text.liquid.heatcapacity = [LIGHT_GRAY]Heat Capacity\: {0}
|
||||
text.liquid.viscosity = [LIGHT_GRAY]Viscosity\: {0}
|
||||
text.liquid.temperature = [LIGHT_GRAY]Temperature\: {0}
|
||||
block.constructing = {0}\n[LIGHT_GRAY](Constructing)
|
||||
block.constructing = {0} [LIGHT_GRAY](Constructing)
|
||||
block.spawn.name = Enemy Spawn
|
||||
block.core.name = Core
|
||||
block.metalfloor.name = Metal Floor
|
||||
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 98 KiB |
@ -5,8 +5,7 @@ Color: {
|
||||
gray: {a: 1, b: 0.32, g: 0.32, r: 0.32 },
|
||||
lightgray: {a: 1, b: 0.65, g: 0.65, r: 0.65 }
|
||||
orange: {hex: "FFA500"},
|
||||
accent: {hex: "f4ba6e"},
|
||||
accentDark: {hex: "f4ba6e"},
|
||||
accent: {hex: "ffd37f"}
|
||||
},
|
||||
TintedDrawable: {
|
||||
dialogDim: {name: white, color: {r: 0, g: 0, b: 0, a: 0.9} },
|
||||
@ -15,12 +14,12 @@ TintedDrawable: {
|
||||
chatfield: {name: white, color: {r: 0, g: 0, b: 0, a: 0.2}},
|
||||
clear: {name: white, color: {r: 0.1, g: 0.1, b: 0.1, a: 0.75}},
|
||||
none: {name: white, color: {r: 0, g: 0, b: 0, a: 0}},
|
||||
clear-over: {name: white, color: {r: 1, g: 1, b: 1, a: 0.2} },
|
||||
clear-down: {name: white, color: {r: 1, g: 1, b: 1, a: 0.4} }
|
||||
clear-over: {name: white, color: { hex: "#ffffff82" }},
|
||||
clear-alpha: {name: white, color: { hex: "#ffd37fff" }},
|
||||
clear-down: {name: white, color: { hex: "#ffd37fff" }}
|
||||
},
|
||||
ButtonStyle: {
|
||||
default: {down: button-down, up: button },
|
||||
menu: {up: text-sides, over: text-sides-over, down: text-sides-down},
|
||||
toggle: {checked: button-down, down: button-down, up: button }
|
||||
},
|
||||
TextButtonStyle: {
|
||||
@ -28,6 +27,7 @@ TextButtonStyle: {
|
||||
discord: {font: default-font, fontColor: white, up: discord-banner},
|
||||
info: {font: default-font, fontColor: white, up: info-banner},
|
||||
clear: {down: clear-down, up: clear, over: clear-over, font: default-font, fontColor: white, disabledFontColor: gray },
|
||||
clear-partial: {down: white, up: button-select, over: clear-down, font: default-font, fontColor: white, disabledFontColor: gray },
|
||||
empty: {font: default-font},
|
||||
toggle: {font: default-font, fontColor: white, checked: button-down, down: button-down, up: button, over: button-over, disabled: button, disabledFontColor: gray }
|
||||
},
|
||||
@ -40,6 +40,9 @@ ImageButtonStyle: {
|
||||
toggle: {checked: button-down, down: button-down, up: button, imageDisabledColor: gray, imageUpColor: white },
|
||||
select: {checked: button-select, up: none },
|
||||
clear: {down: clear-down, up: clear, over: clear-over},
|
||||
clear-partial: {down: clear-down, up: none, over: clear-over},
|
||||
clear-toggle: {down: clear-down, checked: clear-down, up: clear, over: clear-over},
|
||||
clear-toggle-partial: {down: clear-down, checked: clear-down, up: none, over: clear-over},
|
||||
},
|
||||
ScrollPaneStyle: {
|
||||
default: {background: border, vScroll: scroll, vScrollKnob: scroll-knob-vertical-black},
|
||||
|
@ -43,38 +43,41 @@ public class Recipes implements ContentList{
|
||||
new Recipe(defense, DefenseBlocks.surgeWallLarge, new ItemStack(Items.surgealloy, 12 * 4));
|
||||
|
||||
//projectors
|
||||
new Recipe(defense, DefenseBlocks.mendProjector, new ItemStack(Items.lead, 200), new ItemStack(Items.densealloy, 150), new ItemStack(Items.titanium, 50), new ItemStack(Items.silicon, 180));
|
||||
new Recipe(defense, DefenseBlocks.overdriveProjector, new ItemStack(Items.lead, 200), new ItemStack(Items.densealloy, 150), new ItemStack(Items.titanium, 150), new ItemStack(Items.silicon, 250));
|
||||
new Recipe(defense, DefenseBlocks.forceProjector, new ItemStack(Items.lead, 200), new ItemStack(Items.densealloy, 150), new ItemStack(Items.titanium, 150), new ItemStack(Items.silicon, 250));
|
||||
new Recipe(effect, DefenseBlocks.mendProjector, new ItemStack(Items.lead, 200), new ItemStack(Items.densealloy, 150), new ItemStack(Items.titanium, 50), new ItemStack(Items.silicon, 180));
|
||||
new Recipe(effect, DefenseBlocks.overdriveProjector, new ItemStack(Items.lead, 200), new ItemStack(Items.densealloy, 150), new ItemStack(Items.titanium, 150), new ItemStack(Items.silicon, 250));
|
||||
new Recipe(effect, DefenseBlocks.forceProjector, new ItemStack(Items.lead, 200), new ItemStack(Items.densealloy, 150), new ItemStack(Items.titanium, 150), new ItemStack(Items.silicon, 250));
|
||||
|
||||
//extra blocks
|
||||
new Recipe(defense, DefenseBlocks.shockMine, new ItemStack(Items.lead, 50), new ItemStack(Items.silicon, 25))
|
||||
new Recipe(effect, StorageBlocks.unloader, new ItemStack(Items.densealloy, 50), new ItemStack(Items.silicon, 60));
|
||||
new Recipe(effect, StorageBlocks.container, new ItemStack(Items.densealloy, 200));
|
||||
new Recipe(effect, StorageBlocks.vault, new ItemStack(Items.densealloy, 500), new ItemStack(Items.thorium, 250));
|
||||
|
||||
new Recipe(effect, DefenseBlocks.shockMine, new ItemStack(Items.lead, 50), new ItemStack(Items.silicon, 25))
|
||||
.setDependencies(Items.blastCompound);
|
||||
|
||||
//TURRETS
|
||||
new Recipe(weapon, TurretBlocks.duo, new ItemStack(Items.copper, 40)).setAlwaysUnlocked(true);
|
||||
new Recipe(weapon, TurretBlocks.arc, new ItemStack(Items.copper, 50), new ItemStack(Items.lead, 30), new ItemStack(Items.silicon, 20));
|
||||
new Recipe(weapon, TurretBlocks.hail, new ItemStack(Items.copper, 60), new ItemStack(Items.densealloy, 35));
|
||||
new Recipe(weapon, TurretBlocks.lancer, new ItemStack(Items.copper, 50), new ItemStack(Items.lead, 100), new ItemStack(Items.silicon, 90));
|
||||
new Recipe(weapon, TurretBlocks.wave, new ItemStack(Items.densealloy, 60), new ItemStack(Items.titanium, 70), new ItemStack(Items.lead, 150));
|
||||
new Recipe(weapon, TurretBlocks.salvo, new ItemStack(Items.copper, 210), new ItemStack(Items.densealloy, 190), new ItemStack(Items.thorium, 130));
|
||||
new Recipe(weapon, TurretBlocks.swarmer, new ItemStack(Items.densealloy, 70), new ItemStack(Items.titanium, 70), new ItemStack(Items.plastanium, 90), new ItemStack(Items.silicon, 60));
|
||||
new Recipe(weapon, TurretBlocks.ripple, new ItemStack(Items.copper, 300), new ItemStack(Items.densealloy, 220), new ItemStack(Items.thorium, 120));
|
||||
new Recipe(weapon, TurretBlocks.cyclone, new ItemStack(Items.copper, 400), new ItemStack(Items.densealloy, 400), new ItemStack(Items.surgealloy, 200), new ItemStack(Items.plastanium, 150));
|
||||
new Recipe(weapon, TurretBlocks.fuse, new ItemStack(Items.copper, 450), new ItemStack(Items.densealloy, 450), new ItemStack(Items.surgealloy, 250));
|
||||
new Recipe(weapon, TurretBlocks.spectre, new ItemStack(Items.copper, 700), new ItemStack(Items.densealloy, 600), new ItemStack(Items.surgealloy, 500), new ItemStack(Items.plastanium, 350), new ItemStack(Items.thorium, 500));
|
||||
new Recipe(weapon, TurretBlocks.meltdown, new ItemStack(Items.copper, 500), new ItemStack(Items.lead, 700), new ItemStack(Items.densealloy, 600), new ItemStack(Items.surgealloy, 650), new ItemStack(Items.silicon, 650));
|
||||
new Recipe(turret, TurretBlocks.duo, new ItemStack(Items.copper, 40)).setAlwaysUnlocked(true);
|
||||
new Recipe(turret, TurretBlocks.arc, new ItemStack(Items.copper, 50), new ItemStack(Items.lead, 30), new ItemStack(Items.silicon, 20));
|
||||
new Recipe(turret, TurretBlocks.hail, new ItemStack(Items.copper, 60), new ItemStack(Items.densealloy, 35));
|
||||
new Recipe(turret, TurretBlocks.lancer, new ItemStack(Items.copper, 50), new ItemStack(Items.lead, 100), new ItemStack(Items.silicon, 90));
|
||||
new Recipe(turret, TurretBlocks.wave, new ItemStack(Items.densealloy, 60), new ItemStack(Items.titanium, 70), new ItemStack(Items.lead, 150));
|
||||
new Recipe(turret, TurretBlocks.salvo, new ItemStack(Items.copper, 210), new ItemStack(Items.densealloy, 190), new ItemStack(Items.thorium, 130));
|
||||
new Recipe(turret, TurretBlocks.swarmer, new ItemStack(Items.densealloy, 70), new ItemStack(Items.titanium, 70), new ItemStack(Items.plastanium, 90), new ItemStack(Items.silicon, 60));
|
||||
new Recipe(turret, TurretBlocks.ripple, new ItemStack(Items.copper, 300), new ItemStack(Items.densealloy, 220), new ItemStack(Items.thorium, 120));
|
||||
new Recipe(turret, TurretBlocks.cyclone, new ItemStack(Items.copper, 400), new ItemStack(Items.densealloy, 400), new ItemStack(Items.surgealloy, 200), new ItemStack(Items.plastanium, 150));
|
||||
new Recipe(turret, TurretBlocks.fuse, new ItemStack(Items.copper, 450), new ItemStack(Items.densealloy, 450), new ItemStack(Items.surgealloy, 250));
|
||||
new Recipe(turret, TurretBlocks.spectre, new ItemStack(Items.copper, 700), new ItemStack(Items.densealloy, 600), new ItemStack(Items.surgealloy, 500), new ItemStack(Items.plastanium, 350), new ItemStack(Items.thorium, 500));
|
||||
new Recipe(turret, TurretBlocks.meltdown, new ItemStack(Items.copper, 500), new ItemStack(Items.lead, 700), new ItemStack(Items.densealloy, 600), new ItemStack(Items.surgealloy, 650), new ItemStack(Items.silicon, 650));
|
||||
|
||||
//DISTRIBUTION
|
||||
new Recipe(distribution, DistributionBlocks.conveyor, new ItemStack(Items.copper, 1)).setAlwaysUnlocked(true);
|
||||
new Recipe(distribution, DistributionBlocks.titaniumconveyor, new ItemStack(Items.copper, 2), new ItemStack(Items.titanium, 1));
|
||||
new Recipe(distribution, DistributionBlocks.phaseConveyor, new ItemStack(Items.phasefabric, 10), new ItemStack(Items.silicon, 15), new ItemStack(Items.lead, 20), new ItemStack(Items.densealloy, 20));
|
||||
|
||||
//starter lead transportation
|
||||
//starter transport
|
||||
new Recipe(distribution, DistributionBlocks.junction, new ItemStack(Items.copper, 2)).setAlwaysUnlocked(true);
|
||||
new Recipe(distribution, DistributionBlocks.router, new ItemStack(Items.copper, 6)).setAlwaysUnlocked(true);
|
||||
|
||||
//advanced densealloy transporation
|
||||
//advanced densealloy transporat
|
||||
new Recipe(distribution, DistributionBlocks.distributor, new ItemStack(Items.densealloy, 8), new ItemStack(Items.copper, 8));
|
||||
new Recipe(distribution, DistributionBlocks.sorter, new ItemStack(Items.densealloy, 4), new ItemStack(Items.copper, 4));
|
||||
new Recipe(distribution, DistributionBlocks.overflowGate, new ItemStack(Items.densealloy, 4), new ItemStack(Items.copper, 8));
|
||||
@ -131,9 +134,6 @@ public class Recipes implements ContentList{
|
||||
new Recipe(power, PowerBlocks.thoriumReactor, new ItemStack(Items.lead, 600), new ItemStack(Items.silicon, 400), new ItemStack(Items.densealloy, 300), new ItemStack(Items.thorium, 300));
|
||||
new Recipe(power, PowerBlocks.rtgGenerator, new ItemStack(Items.lead, 200), new ItemStack(Items.silicon, 150), new ItemStack(Items.phasefabric, 50), new ItemStack(Items.plastanium, 150), new ItemStack(Items.thorium, 100));
|
||||
|
||||
new Recipe(distribution, StorageBlocks.unloader, new ItemStack(Items.densealloy, 50), new ItemStack(Items.silicon, 60));
|
||||
new Recipe(distribution, StorageBlocks.container, new ItemStack(Items.densealloy, 200));
|
||||
new Recipe(distribution, StorageBlocks.vault, new ItemStack(Items.densealloy, 500), new ItemStack(Items.thorium, 250));
|
||||
//core disabled due to being broken
|
||||
/*new Recipe(distribution, StorageBlocks.core,
|
||||
new ItemStack(Items.copper, 2000), new ItemStack(Items.densealloy, 1500),
|
||||
@ -153,16 +153,16 @@ public class Recipes implements ContentList{
|
||||
|
||||
//UNITS
|
||||
|
||||
//bodies
|
||||
new Recipe(units, UpgradeBlocks.dartPad, new ItemStack(Items.lead, 150), new ItemStack(Items.copper, 150), new ItemStack(Items.silicon, 200), new ItemStack(Items.titanium, 240)).setVisible(RecipeVisibility.desktopOnly);
|
||||
new Recipe(units, UpgradeBlocks.tridentPad, new ItemStack(Items.lead, 250), new ItemStack(Items.copper, 250), new ItemStack(Items.silicon, 250), new ItemStack(Items.titanium, 300), new ItemStack(Items.plastanium, 200));
|
||||
new Recipe(units, UpgradeBlocks.javelinPad, new ItemStack(Items.lead, 350), new ItemStack(Items.silicon, 450), new ItemStack(Items.titanium, 500), new ItemStack(Items.plastanium, 400), new ItemStack(Items.phasefabric, 200));
|
||||
new Recipe(units, UpgradeBlocks.glaivePad, new ItemStack(Items.lead, 450), new ItemStack(Items.silicon, 650), new ItemStack(Items.titanium, 700), new ItemStack(Items.plastanium, 600), new ItemStack(Items.surgealloy, 200));
|
||||
//upgrades
|
||||
new Recipe(upgrade, UpgradeBlocks.dartPad, new ItemStack(Items.lead, 150), new ItemStack(Items.copper, 150), new ItemStack(Items.silicon, 200), new ItemStack(Items.titanium, 240)).setVisible(RecipeVisibility.desktopOnly);
|
||||
new Recipe(upgrade, UpgradeBlocks.tridentPad, new ItemStack(Items.lead, 250), new ItemStack(Items.copper, 250), new ItemStack(Items.silicon, 250), new ItemStack(Items.titanium, 300), new ItemStack(Items.plastanium, 200));
|
||||
new Recipe(upgrade, UpgradeBlocks.javelinPad, new ItemStack(Items.lead, 350), new ItemStack(Items.silicon, 450), new ItemStack(Items.titanium, 500), new ItemStack(Items.plastanium, 400), new ItemStack(Items.phasefabric, 200));
|
||||
new Recipe(upgrade, UpgradeBlocks.glaivePad, new ItemStack(Items.lead, 450), new ItemStack(Items.silicon, 650), new ItemStack(Items.titanium, 700), new ItemStack(Items.plastanium, 600), new ItemStack(Items.surgealloy, 200));
|
||||
|
||||
new Recipe(units, UpgradeBlocks.alphaPad, new ItemStack(Items.lead, 200), new ItemStack(Items.densealloy, 100), new ItemStack(Items.copper, 150)).setVisible(RecipeVisibility.mobileOnly);
|
||||
new Recipe(units, UpgradeBlocks.tauPad, new ItemStack(Items.lead, 250), new ItemStack(Items.densealloy, 250), new ItemStack(Items.copper, 250), new ItemStack(Items.silicon, 250));
|
||||
new Recipe(units, UpgradeBlocks.deltaPad, new ItemStack(Items.lead, 350), new ItemStack(Items.densealloy, 350), new ItemStack(Items.copper, 400), new ItemStack(Items.silicon, 450), new ItemStack(Items.thorium, 300));
|
||||
new Recipe(units, UpgradeBlocks.omegaPad, new ItemStack(Items.lead, 450), new ItemStack(Items.densealloy, 550), new ItemStack(Items.silicon, 650), new ItemStack(Items.thorium, 600), new ItemStack(Items.surgealloy, 240));
|
||||
new Recipe(upgrade, UpgradeBlocks.alphaPad, new ItemStack(Items.lead, 200), new ItemStack(Items.densealloy, 100), new ItemStack(Items.copper, 150)).setVisible(RecipeVisibility.mobileOnly);
|
||||
new Recipe(upgrade, UpgradeBlocks.tauPad, new ItemStack(Items.lead, 250), new ItemStack(Items.densealloy, 250), new ItemStack(Items.copper, 250), new ItemStack(Items.silicon, 250));
|
||||
new Recipe(upgrade, UpgradeBlocks.deltaPad, new ItemStack(Items.lead, 350), new ItemStack(Items.densealloy, 350), new ItemStack(Items.copper, 400), new ItemStack(Items.silicon, 450), new ItemStack(Items.thorium, 300));
|
||||
new Recipe(upgrade, UpgradeBlocks.omegaPad, new ItemStack(Items.lead, 450), new ItemStack(Items.densealloy, 550), new ItemStack(Items.silicon, 650), new ItemStack(Items.thorium, 600), new ItemStack(Items.surgealloy, 240));
|
||||
|
||||
//actual unit related stuff
|
||||
new Recipe(units, UnitBlocks.spiritFactory, new ItemStack(Items.copper, 70), new ItemStack(Items.lead, 110), new ItemStack(Items.silicon, 130));
|
||||
|
@ -111,15 +111,6 @@ public class Control extends Module{
|
||||
}
|
||||
|
||||
state.set(State.playing);
|
||||
|
||||
if(world.getSector() == null && !Settings.getBool("custom-warning-for-real-1", false)){
|
||||
threads.runGraphics(() -> ui.showInfo("$mode.custom.warning", () ->
|
||||
ui.showInfo("$mode.custom.warning.read", () -> {
|
||||
Settings.putBool("custom-warning-for-real-1", true);
|
||||
Settings.save();
|
||||
})));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Events.on(WorldLoadGraphicsEvent.class, event -> {
|
||||
|
@ -28,6 +28,7 @@ import io.anuke.ucore.scene.ui.TextField.TextFieldFilter;
|
||||
import io.anuke.ucore.scene.ui.TooltipManager;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.ucore.scene.actions.Actions.*;
|
||||
@ -293,4 +294,16 @@ public class UI extends SceneModule{
|
||||
dialog.keyDown(Keys.BACK, dialog::hide);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public String formatAmount(int number){
|
||||
if(number >= 1000000){
|
||||
return Strings.toFixed(number / 1000000f, 1) + "[gray]mil[]";
|
||||
}else if(number >= 10000){
|
||||
return number / 1000 + "[gray]k[]";
|
||||
}else if(number >= 1000){
|
||||
return Strings.toFixed(number / 1000f, 1) + "[gray]k[]";
|
||||
}else{
|
||||
return number + "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,16 +4,12 @@ import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.badlogic.gdx.utils.ObjectMap.Entry;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
/**Stores player unlocks. Clientside only.*/
|
||||
public class Unlocks{
|
||||
private ObjectMap<String, ContentUnlockSet> sets = new ObjectMap<>();
|
||||
ContentUnlockSet set = new ContentUnlockSet();
|
||||
|
||||
static{
|
||||
Settings.setSerializer(ContentType.class, (stream, t) -> stream.writeInt(t.ordinal()), stream -> ContentType.values()[stream.readInt()]);
|
||||
@ -21,7 +17,7 @@ public class Unlocks{
|
||||
|
||||
/** Returns whether or not this piece of content is unlocked yet.*/
|
||||
public boolean isUnlocked(UnlockableContent content){
|
||||
return rootSet().isUnlocked(content) || currentSet().isUnlocked(content);
|
||||
return set.isUnlocked(content);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -32,77 +28,42 @@ public class Unlocks{
|
||||
* @return whether or not this content was newly unlocked.
|
||||
*/
|
||||
public boolean unlockContent(UnlockableContent content){
|
||||
return !rootSet().isUnlocked(content) && currentSet().unlockContent(content);
|
||||
return !set.isUnlocked(content) && currentSet().unlockContent(content);
|
||||
}
|
||||
|
||||
private ContentUnlockSet currentSet(){
|
||||
//client connected to server: always return the IP-specific set
|
||||
if(Net.client()){
|
||||
return getSet(Net.getLastIP());
|
||||
}else if((world.getSector() != null || state.mode.infiniteResources) || state.is(State.menu)){ //sector-sandbox have shared set
|
||||
return rootSet();
|
||||
}else{ //per-mode set
|
||||
return getSet(state.mode.name());
|
||||
}
|
||||
}
|
||||
|
||||
private ContentUnlockSet rootSet(){
|
||||
return getSet("root");
|
||||
}
|
||||
|
||||
private ContentUnlockSet getSet(String name){
|
||||
if(!sets.containsKey(name)){
|
||||
sets.put(name, new ContentUnlockSet());
|
||||
}
|
||||
return sets.get(name);
|
||||
return set;
|
||||
}
|
||||
|
||||
/** Returns whether unlockables have changed since the last save.*/
|
||||
public boolean isDirty(){
|
||||
for(ContentUnlockSet set : sets.values()){
|
||||
if(set.isDirty()){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return set.isDirty();
|
||||
}
|
||||
|
||||
/** Clears all unlocked content. Automatically saves.*/
|
||||
public void reset(){
|
||||
sets.clear();
|
||||
save();
|
||||
}
|
||||
|
||||
public void load(){
|
||||
sets.clear();
|
||||
ObjectMap<ContentType, Array<String>> outer = Settings.getObject("unlocks", ObjectMap.class, ObjectMap::new);
|
||||
ContentUnlockSet cset = new ContentUnlockSet();
|
||||
|
||||
ObjectMap<String, ObjectMap<ContentType, Array<String>>> result = Settings.getObject("content-sets", ObjectMap.class, ObjectMap::new);
|
||||
|
||||
for(Entry<String, ObjectMap<ContentType, Array<String>>> outer : result.entries()){
|
||||
ContentUnlockSet cset = new ContentUnlockSet();
|
||||
for (Entry<ContentType, Array<String>> entry : outer.value.entries()){
|
||||
ObjectSet<String> set = new ObjectSet<>();
|
||||
set.addAll(entry.value);
|
||||
cset.getUnlocked().put(entry.key, set);
|
||||
}
|
||||
sets.put(outer.key, cset);
|
||||
for (Entry<ContentType, Array<String>> entry : outer.entries()){
|
||||
ObjectSet<String> set = new ObjectSet<>();
|
||||
set.addAll(entry.value);
|
||||
cset.getUnlocked().put(entry.key, set);
|
||||
}
|
||||
}
|
||||
|
||||
public void save(){
|
||||
ObjectMap<String, ObjectMap<ContentType, Array<String>>> output = new ObjectMap<>();
|
||||
ObjectMap<ContentType, Array<String>> write = new ObjectMap<>();
|
||||
|
||||
for(Entry<String, ContentUnlockSet> centry : sets.entries()){
|
||||
ObjectMap<ContentType, Array<String>> write = new ObjectMap<>();
|
||||
|
||||
for(Entry<ContentType, ObjectSet<String>> entry : centry.value.getUnlocked().entries()){
|
||||
write.put(entry.key, entry.value.iterator().toArray());
|
||||
}
|
||||
|
||||
output.put(centry.key, write);
|
||||
for(Entry<ContentType, ObjectSet<String>> entry : set.getUnlocked().entries()){
|
||||
write.put(entry.key, entry.value.iterator().toArray());
|
||||
}
|
||||
|
||||
Settings.putObject("content-sets", output);
|
||||
Settings.putObject("unlocks", write);
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ public class Palette{
|
||||
|
||||
lightishGray = Color.valueOf("a2a2a2"),
|
||||
darkishGray = new Color(0.3f, 0.3f, 0.3f, 1f),
|
||||
darkerGray = new Color(0.2f, 0.2f, 0.2f, 1f),
|
||||
|
||||
boostTo = Color.valueOf("ffad4d"),
|
||||
boostFrom = Color.valueOf("ff7f57"),
|
||||
|
@ -25,7 +25,7 @@ import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.core.Inputs;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Translator;
|
||||
@ -145,7 +145,7 @@ public abstract class InputHandler extends InputAdapter{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void buildUI(Group group){
|
||||
public void buildUI(Table table){
|
||||
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,7 @@ import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.event.Touchable;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
@ -208,78 +207,53 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
//region UI and drawing
|
||||
|
||||
@Override
|
||||
public void buildUI(Group group){
|
||||
public void buildUI(Table table){
|
||||
table.addImage("blank").color(Palette.accent).height(3f).colspan(4).growX();
|
||||
table.row();
|
||||
table.left().margin(0f).defaults().size(48f);
|
||||
|
||||
//Create confirm/cancel table
|
||||
group.fill(c -> {
|
||||
c.bottom().left().visible(() -> !state.is(State.menu));
|
||||
table.addImageButton("icon-break", "clear-toggle-partial", 16 * 2f, () -> {
|
||||
mode = mode == breaking ? recipe == null ? none : placing : breaking;
|
||||
lastRecipe = recipe;
|
||||
if(mode == breaking){
|
||||
showGuide("deconstruction");
|
||||
}
|
||||
}).update(l -> l.setChecked(mode == breaking));
|
||||
|
||||
c.table("pane", act -> {
|
||||
act.margin(5);
|
||||
act.defaults().size(60f);
|
||||
//rotate button
|
||||
table.addImageButton("icon-arrow", "clear-partial", 16 * 2f, () -> rotation = Mathf.mod(rotation + 1, 4))
|
||||
.update(i -> i.getImage().setRotationOrigin(rotation * 90, Align.center))
|
||||
.visible(() -> recipe != null && recipe.result.rotate);
|
||||
|
||||
//Add a cancel button
|
||||
act.addImageButton("icon-cancel", 16*2f, () -> {
|
||||
mode = none;
|
||||
recipe = null;
|
||||
});
|
||||
//cancel button
|
||||
table.addImageButton("icon-cancel", "clear-partial", 16 * 2f, () -> {
|
||||
player.clearBuilding();
|
||||
mode = none;
|
||||
recipe = null;
|
||||
}).visible(() -> player.isBuilding() || mode != none);
|
||||
|
||||
act.row();
|
||||
//confirm button
|
||||
table.addImageButton("icon-check", "clear-partial", 16 * 2f, () -> {
|
||||
for(PlaceRequest request : selection){
|
||||
Tile tile = request.tile();
|
||||
|
||||
//Add an accept button, which places everything.
|
||||
act.addImageButton("icon-check", 16 * 2f, () -> {
|
||||
for(PlaceRequest request : selection){
|
||||
Tile tile = request.tile();
|
||||
|
||||
//actually place/break all selected blocks
|
||||
if(tile != null){
|
||||
if(!request.remove){
|
||||
rotation = request.rotation;
|
||||
recipe = request.recipe;
|
||||
tryPlaceBlock(tile.x, tile.y);
|
||||
}else{
|
||||
tryBreakBlock(tile.x, tile.y);
|
||||
}
|
||||
}
|
||||
//actually place/break all selected blocks
|
||||
if(tile != null){
|
||||
if(!request.remove){
|
||||
rotation = request.rotation;
|
||||
recipe = request.recipe;
|
||||
tryPlaceBlock(tile.x, tile.y);
|
||||
}else{
|
||||
tryBreakBlock(tile.x, tile.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//move all current requests to removal array so they fade out
|
||||
removals.addAll(selection);
|
||||
selection.clear();
|
||||
selecting = false;
|
||||
}).disabled(i -> selection.size == 0);
|
||||
|
||||
act.row();
|
||||
|
||||
//Add a rotate button
|
||||
act.addImageButton("icon-arrow", 16 * 2f, () -> rotation = Mathf.mod(rotation + 1, 4))
|
||||
.update(i -> i.getImage().setRotationOrigin(rotation * 90, Align.center))
|
||||
.disabled(i -> recipe == null || !recipe.result.rotate);
|
||||
}).visible(() -> mode != none).touchable(Touchable.enabled);
|
||||
|
||||
c.row();
|
||||
|
||||
c.table("pane", remove -> {
|
||||
remove.defaults().size(60f);
|
||||
|
||||
//Add a break button.
|
||||
remove.addImageButton("icon-break", "toggle", 16 * 2f, () -> {
|
||||
mode = mode == breaking ? recipe == null ? none : placing : breaking;
|
||||
lastRecipe = recipe;
|
||||
if(mode == breaking){
|
||||
showGuide("deconstruction");
|
||||
}
|
||||
}).update(l -> l.setChecked(mode == breaking));
|
||||
}).margin(5).touchable(Touchable.enabled);
|
||||
|
||||
c.table("pane", cancel -> {
|
||||
cancel.defaults().size(60f);
|
||||
|
||||
//Add a 'cancel building' button.
|
||||
cancel.addImageButton("icon-cancel", 16 * 2f, player::clearBuilding);
|
||||
|
||||
}).left().colspan(2).margin(5).touchable(Touchable.enabled).visible(() -> player.getPlaceQueue().size > 0);
|
||||
});
|
||||
//move all current requests to removal array so they fade out
|
||||
removals.addAll(selection);
|
||||
selection.clear();
|
||||
selecting = false;
|
||||
}).visible(() -> !selection.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,24 @@
|
||||
package io.anuke.mindustry.type;
|
||||
|
||||
public enum Category{
|
||||
weapon, production, distribution, liquid, power, defense, crafting, units
|
||||
/**Offensive turrets.*/
|
||||
turret,
|
||||
/**Blocks that produce raw resources, such as drills.*/
|
||||
production,
|
||||
/**Blocks that move items around.*/
|
||||
distribution,
|
||||
/**Blocks that move liquids around.*/
|
||||
liquid,
|
||||
/**Blocks that generate or transport power.*/
|
||||
power,
|
||||
/**Walls and other defensive structures.*/
|
||||
defense,
|
||||
/**Blocks that craft things.*/
|
||||
crafting,
|
||||
/**Blocks that create units.*/
|
||||
units,
|
||||
/**Things that upgrade the player such as mech pads.*/
|
||||
upgrade,
|
||||
/**Things for storage or passive effects.*/
|
||||
effect
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Recipe extends UnlockableContent{
|
||||
private static ObjectMap<Block, Recipe> recipeMap = new ObjectMap<>();
|
||||
private static Array<Recipe> returnArray = new Array<>();
|
||||
|
||||
public final Block result;
|
||||
public final ItemStack[] requirements;
|
||||
@ -55,34 +56,15 @@ public class Recipe extends UnlockableContent{
|
||||
recipeMap.put(result, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns unlocked recipes in a category.
|
||||
* Do not call on the server backend, as unlocking does not exist!
|
||||
*/
|
||||
public static void getUnlockedByCategory(Category category, Array<Recipe> arr){
|
||||
if(headless){
|
||||
throw new RuntimeException("Not implemented on the headless backend!");
|
||||
}
|
||||
|
||||
arr.clear();
|
||||
for(Recipe r : content.recipes()){
|
||||
if(r.category == category && (control.unlocks.isUnlocked(r)) &&
|
||||
!((r.mode != null && r.mode != state.mode) || !r.visibility.shown())){
|
||||
arr.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all recipes in a category.
|
||||
*/
|
||||
public static void getByCategory(Category category, Array<Recipe> r){
|
||||
r.clear();
|
||||
/**Returns all non-hidden recipes in a category.*/
|
||||
public static Array<Recipe> getByCategory(Category category){
|
||||
returnArray.clear();
|
||||
for(Recipe recipe : content.recipes()){
|
||||
if(recipe.category == category){
|
||||
r.add(recipe);
|
||||
if(recipe.category == category && !recipe.isHidden()){
|
||||
returnArray.add(recipe);
|
||||
}
|
||||
}
|
||||
return returnArray;
|
||||
}
|
||||
|
||||
public static Recipe getByResult(Block block){
|
||||
|
14
core/src/io/anuke/mindustry/ui/ImageStack.java
Normal file
@ -0,0 +1,14 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.layout.Stack;
|
||||
|
||||
public class ImageStack extends Stack{
|
||||
|
||||
public ImageStack(TextureRegion... regions){
|
||||
for(TextureRegion region : regions){
|
||||
add(new Image(region));
|
||||
}
|
||||
}
|
||||
}
|
18
core/src/io/anuke/mindustry/ui/ItemDisplay.java
Normal file
@ -0,0 +1,18 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
/**An item image with text.*/
|
||||
public class ItemDisplay extends Table{
|
||||
|
||||
public ItemDisplay(Item item){
|
||||
this(item, 0);
|
||||
}
|
||||
|
||||
public ItemDisplay(Item item, int amount){
|
||||
add(new ItemImage(new ItemStack(item, amount))).size(8*3);
|
||||
add(item.localizedName()).padLeft(4);
|
||||
}
|
||||
}
|
@ -18,10 +18,12 @@ public class ItemImage extends Stack{
|
||||
}
|
||||
|
||||
public ItemImage(ItemStack stack){
|
||||
Table t = new Table().left().bottom();
|
||||
t.add(stack.amount + "");
|
||||
|
||||
add(new Image(stack.item.region));
|
||||
add(t);
|
||||
|
||||
if(stack.amount != 0){
|
||||
Table t = new Table().left().bottom();
|
||||
t.add(stack.amount + "");
|
||||
add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
core/src/io/anuke/mindustry/ui/LiquidDisplay.java
Normal file
@ -0,0 +1,14 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
/**An ItemDisplay, but for liquids.*/
|
||||
public class LiquidDisplay extends Table{
|
||||
|
||||
public LiquidDisplay(Liquid liquid){
|
||||
add(new Image(liquid.getContentIcon())).size(8*3);
|
||||
add(liquid.localizedName()).padLeft(3);
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.OreBlock;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.scene.style.TextureRegionDrawable;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class SelectionTable extends Table{
|
||||
Tile lastTile;
|
||||
|
||||
public SelectionTable(){
|
||||
super("clear");
|
||||
|
||||
margin(5f);
|
||||
|
||||
update(() -> {
|
||||
Block result;
|
||||
Tile tile = world.tileWorld(Graphics.mouseWorld().x, Graphics.mouseWorld().y);
|
||||
if(tile != null){
|
||||
tile = tile.target();
|
||||
result = tile.block().synthetic() ? tile.block() : tile.floor() instanceof OreBlock ? tile.floor() : null;
|
||||
}else{
|
||||
result = null;
|
||||
}
|
||||
|
||||
if(result != null){
|
||||
lastTile = tile;
|
||||
}
|
||||
|
||||
getTranslation().y = Mathf.lerp(getTranslation().y, result == null ? -getHeight() : 0f, 0.2f);
|
||||
});
|
||||
|
||||
Image image = new Image(new TextureRegionDrawable(new TextureRegion(Draw.region("clear"))));
|
||||
image.update(() ->
|
||||
((TextureRegionDrawable)image.getDrawable()).setRegion(lastTile == null ? Draw.getBlankRegion() :
|
||||
(lastTile.block().synthetic() ? lastTile.block() : lastTile.floor()).getDisplayIcon(lastTile)));
|
||||
|
||||
add(image).size(8*5).padRight(4);
|
||||
label(() -> lastTile == null ? "" : (lastTile.block().synthetic() ? lastTile.block() : lastTile.floor()).getDisplayName(lastTile));
|
||||
|
||||
pack();
|
||||
getTranslation().y = - getHeight();
|
||||
}
|
||||
}
|
@ -6,10 +6,10 @@ import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
import io.anuke.mindustry.world.meta.StatValue;
|
||||
import io.anuke.ucore.scene.event.HandCursorListener;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||
import io.anuke.ucore.scene.ui.Tooltip;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.scene.utils.UIUtils;
|
||||
|
||||
@ -65,7 +65,10 @@ public class UnlocksDialog extends FloatingDialog{
|
||||
|
||||
if(control.unlocks.isUnlocked(unlock)){
|
||||
image.clicked(() -> Vars.ui.content.show(unlock));
|
||||
StatValue.addToolTip(image, unlock);
|
||||
image.addListener(new Tooltip<>(new Table("clear"){{
|
||||
add(unlock.localizedName());
|
||||
margin(4);
|
||||
}}));
|
||||
}
|
||||
|
||||
if((++count) % maxWidth == 0){
|
||||
|
@ -180,7 +180,9 @@ public class BlockInventoryFragment extends Fragment{
|
||||
|
||||
private String round(float f){
|
||||
f = (int) f;
|
||||
if(f >= 1000){
|
||||
if(f >= 1000000){
|
||||
return Strings.toFixed(f / 1000000f, 1) + "[gray]mil[]";
|
||||
}else if(f >= 1000){
|
||||
return Strings.toFixed(f / 1000, 1) + "k";
|
||||
}else{
|
||||
return (int) f + "";
|
||||
|
@ -1,349 +0,0 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.type.Category;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Events;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
import io.anuke.ucore.scene.event.ClickListener;
|
||||
import io.anuke.ucore.scene.event.InputEvent;
|
||||
import io.anuke.ucore.scene.event.Touchable;
|
||||
import io.anuke.ucore.scene.ui.*;
|
||||
import io.anuke.ucore.scene.ui.layout.Stack;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class BlocksFragment extends Fragment{
|
||||
//number of block icon rows
|
||||
private static final int rows = 4;
|
||||
//number of category button rows
|
||||
private static final int secrows = 4;
|
||||
//size of each block icon
|
||||
private static final float size = 48;
|
||||
//maximum recipe rows
|
||||
private static final int maxrow = 3;
|
||||
/** Table containing description that is shown on top.*/
|
||||
private Table descTable;
|
||||
/** Main table containing the whole menu.*/
|
||||
private Table mainTable;
|
||||
/** Table for all section buttons and blocks.*/
|
||||
private Table selectTable;
|
||||
/** Whether the whole thing is shown or hidden by the popup button.*/
|
||||
private boolean shown = true;
|
||||
/** Recipe currently hovering over.*/
|
||||
private Recipe hoverRecipe;
|
||||
/** Last category selected.*/
|
||||
private Category lastCategory;
|
||||
/** Last block pane scroll Y position.*/
|
||||
private float lastScroll;
|
||||
/** Temporary recipe array for storage*/
|
||||
private Array<Recipe> recipes = new Array<>();
|
||||
|
||||
public void build(Group parent){
|
||||
InputHandler input = control.input(0);
|
||||
|
||||
parent.fill(container -> {
|
||||
container.bottom().right().visible(() -> !state.is(State.menu));
|
||||
|
||||
mainTable = container.table(main -> {
|
||||
|
||||
//add top description table
|
||||
descTable = new Table("button");
|
||||
descTable.visible(() -> (hoverRecipe != null || input.recipe != null) && shown); //make sure it's visible when necessary
|
||||
descTable.update(() -> {
|
||||
if(state.is(State.menu)){
|
||||
descTable.clear();
|
||||
control.input(0).recipe = null;
|
||||
}
|
||||
// note: This is required because there is no direct connection between input.recipe and the description ui.
|
||||
// If input.recipe gets set to null, a proper cleanup of the ui elements is required.
|
||||
boolean anyRecipeShown = input.recipe != null || hoverRecipe != null;
|
||||
boolean descriptionTableClean = descTable.getChildren().size == 0;
|
||||
boolean cleanupRequired = (!anyRecipeShown && !descriptionTableClean);
|
||||
if(cleanupRequired){
|
||||
descTable.clear();
|
||||
}
|
||||
});
|
||||
|
||||
float w = 246f;
|
||||
|
||||
main.add(descTable).width(w);
|
||||
|
||||
main.row();
|
||||
|
||||
//now add the block selection menu
|
||||
selectTable = main.table("pane", select -> {})
|
||||
.margin(10f).marginLeft(0f).marginRight(0f).marginTop(-5)
|
||||
.touchable(Touchable.enabled).right().bottom().width(w).get();
|
||||
|
||||
}).bottom().right().get();
|
||||
});
|
||||
|
||||
Events.on(WorldLoadEvent.class, event -> rebuild());
|
||||
|
||||
rebuild();
|
||||
}
|
||||
|
||||
/**Rebuilds the whole placement menu, attempting to preserve previous state.*/
|
||||
void rebuild(){
|
||||
selectTable.clear();
|
||||
|
||||
InputHandler input = control.input(0);
|
||||
Stack stack = new Stack();
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
Table catTable = selectTable;
|
||||
|
||||
int cati = 0;
|
||||
int checkedi = 0;
|
||||
int rowsUsed = 0;
|
||||
|
||||
//add categories
|
||||
for(Category cat : Category.values()){
|
||||
//get recipes out by category
|
||||
Recipe.getUnlockedByCategory(cat, recipes);
|
||||
|
||||
//empty section, nothing to see here
|
||||
if(recipes.size == 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
//table where actual recipes go
|
||||
Table recipeTable = new Table();
|
||||
recipeTable.margin(4).top().left().marginRight(15);
|
||||
|
||||
//add a new row here when needed
|
||||
if(cati % secrows == 0){
|
||||
catTable = new Table();
|
||||
selectTable.row();
|
||||
selectTable.add(catTable).colspan(secrows).padTop(-5).growX();
|
||||
}
|
||||
|
||||
//add category button
|
||||
ImageButton catb = catTable.addImageButton("icon-" + cat.name(), "toggle", 40, () -> {
|
||||
if(!recipeTable.isVisible() && input.recipe != null){
|
||||
input.recipe = null;
|
||||
}
|
||||
lastCategory = cat;
|
||||
stack.act(Gdx.graphics.getDeltaTime());
|
||||
stack.act(Gdx.graphics.getDeltaTime());
|
||||
}).growX().height(54).group(group)
|
||||
.name("sectionbutton" + cat.name()).get();
|
||||
|
||||
if(lastCategory == cat || lastCategory == null){
|
||||
checkedi = cati;
|
||||
lastCategory = cat;
|
||||
}
|
||||
|
||||
//scrollpane for recipes
|
||||
ScrollPane pane = new ScrollPane(recipeTable, "clear-black");
|
||||
pane.setOverscroll(false, false);
|
||||
pane.visible(catb::isChecked);
|
||||
pane.setScrollYForce(lastScroll);
|
||||
pane.update(() -> {
|
||||
Element e = Core.scene.hit(Graphics.mouse().x, Graphics.mouse().y, true);
|
||||
if(e != null && e.isDescendantOf(pane)){
|
||||
Core.scene.setScrollFocus(pane);
|
||||
}else if(Core.scene.getScrollFocus() == pane){
|
||||
Core.scene.setScrollFocus(null);
|
||||
}
|
||||
|
||||
if(lastCategory == cat){
|
||||
lastScroll = pane.getVisualScrollY();
|
||||
}
|
||||
});
|
||||
stack.add(pane);
|
||||
|
||||
int i = 0;
|
||||
|
||||
//add actual recipes
|
||||
for(Recipe r : recipes){
|
||||
if((r.mode != null && r.mode != state.mode) || !r.visibility.shown()) continue;
|
||||
|
||||
ImageButton image = new ImageButton(new TextureRegion(), "select");
|
||||
|
||||
TextureRegion[] regions = r.result.getCompactIcon();
|
||||
Stack istack = new Stack();
|
||||
for(TextureRegion region : regions){
|
||||
Image u = new Image(region);
|
||||
u.update(() -> u.setColor(istack.getColor()));
|
||||
istack.add(u);
|
||||
}
|
||||
|
||||
image.getImageCell().setActor(istack).size(size);
|
||||
image.addChild(istack);
|
||||
image.setTouchable(Touchable.enabled);
|
||||
image.getImage().remove();
|
||||
|
||||
image.addListener(new ClickListener(){
|
||||
@Override
|
||||
public void enter(InputEvent event, float x, float y, int pointer, Element fromActor){
|
||||
super.enter(event, x, y, pointer, fromActor);
|
||||
if(hoverRecipe != r){
|
||||
hoverRecipe = r;
|
||||
updateRecipe(r);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit(InputEvent event, float x, float y, int pointer, Element toActor){
|
||||
super.exit(event, x, y, pointer, toActor);
|
||||
hoverRecipe = null;
|
||||
updateRecipe(input.recipe);
|
||||
}
|
||||
});
|
||||
|
||||
image.clicked(() -> {
|
||||
// note: input.recipe only gets set here during a click.
|
||||
// during a hover only the visual description will be updated.
|
||||
InputHandler handler = mobile ? input : control.input(0);
|
||||
|
||||
boolean nothingSelectedYet = handler.recipe == null;
|
||||
boolean selectedSomethingElse = !nothingSelectedYet && handler.recipe != r;
|
||||
boolean shouldMakeSelection = nothingSelectedYet || selectedSomethingElse;
|
||||
if(shouldMakeSelection){
|
||||
handler.recipe = r;
|
||||
hoverRecipe = r;
|
||||
updateRecipe(r);
|
||||
}else{
|
||||
handler.recipe = null;
|
||||
hoverRecipe = null;
|
||||
updateRecipe(null);
|
||||
}
|
||||
});
|
||||
|
||||
recipeTable.add(image).size(size + 8);
|
||||
|
||||
image.update(() -> {
|
||||
image.setChecked(r == control.input(0).recipe);
|
||||
TileEntity entity = players[0].getClosestCore();
|
||||
|
||||
if(entity == null) return;
|
||||
|
||||
if(!state.mode.infiniteResources){
|
||||
for(ItemStack s : r.requirements){
|
||||
if(!entity.items.has(s.item, Mathf.ceil(s.amount))){
|
||||
istack.setColor(Color.GRAY);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
istack.setColor(Color.WHITE);
|
||||
});
|
||||
|
||||
if(i % rows == rows - 1){
|
||||
rowsUsed = Math.max((i + 1) / rows, rowsUsed);
|
||||
recipeTable.row();
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
cati++;
|
||||
}
|
||||
|
||||
if(group.getButtons().size > 0){
|
||||
group.getButtons().get(checkedi).setChecked(true);
|
||||
}
|
||||
|
||||
selectTable.row();
|
||||
selectTable.add(stack).growX().left().top().colspan(Category.values().length).padBottom(-5).height((size + 12) * Math.min(rowsUsed, 3));
|
||||
}
|
||||
|
||||
void toggle(float t, Interpolation ip){
|
||||
if(shown){
|
||||
shown = false;
|
||||
mainTable.actions(Actions.translateBy(0, mainTable.getTranslation().y + (-mainTable.getHeight() - descTable.getHeight()), t, ip));
|
||||
}else{
|
||||
shown = true;
|
||||
mainTable.actions(Actions.translateBy(0, -mainTable.getTranslation().y, t, ip));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateRecipe(Recipe recipe){
|
||||
if(recipe == null){
|
||||
descTable.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
descTable.clear();
|
||||
descTable.setTouchable(Touchable.enabled);
|
||||
|
||||
descTable.defaults().left();
|
||||
descTable.left();
|
||||
descTable.margin(12);
|
||||
|
||||
Table header = new Table();
|
||||
|
||||
descTable.add(header).left();
|
||||
|
||||
descTable.row();
|
||||
|
||||
TextureRegion[] regions = recipe.result.getCompactIcon();
|
||||
|
||||
Stack istack = new Stack();
|
||||
|
||||
for(TextureRegion region : regions) istack.add(new Image(region));
|
||||
|
||||
header.add(istack).size(8 * 5).padTop(4);
|
||||
Label nameLabel = new Label(recipe.result.formalName);
|
||||
nameLabel.setWrap(true);
|
||||
header.add(nameLabel).padLeft(2).width(120f);
|
||||
|
||||
header.addButton("?", () -> ui.content.show(recipe)).expandX().padLeft(3).top().right().size(40f, 44f).padTop(-2);
|
||||
|
||||
descTable.add().pad(2);
|
||||
|
||||
Table requirements = new Table();
|
||||
|
||||
descTable.row();
|
||||
|
||||
descTable.left();
|
||||
descTable.add(requirements);
|
||||
|
||||
for(ItemStack stack : recipe.requirements){
|
||||
requirements.addImage(stack.item.region).size(8 * 3);
|
||||
Label reqlabel = new Label(() -> {
|
||||
TileEntity core = players[0].getClosestCore();
|
||||
if(core == null || state.mode.infiniteResources) return "*/*";
|
||||
|
||||
int amount = core.items.get(stack.item);
|
||||
String color = (amount < stack.amount / 2f ? "[red]" : amount < stack.amount ? "[accent]" : "[white]");
|
||||
|
||||
return color + format(amount) + "[white]/" + stack.amount;
|
||||
});
|
||||
|
||||
requirements.add(reqlabel).left();
|
||||
requirements.row();
|
||||
}
|
||||
|
||||
descTable.row();
|
||||
}
|
||||
|
||||
String format(int number){
|
||||
if(number >= 1000000){
|
||||
return Strings.toFixed(number / 1000000f, 1) + "[gray]mil[]";
|
||||
}else if(number >= 10000){
|
||||
return number / 1000 + "[gray]k[]";
|
||||
}else if(number >= 1000){
|
||||
return Strings.toFixed(number / 1000f, 1) + "[gray]k[]";
|
||||
}else{
|
||||
return number + "";
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ import io.anuke.mindustry.net.Packets.AdminAction;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.ui.IntFormat;
|
||||
import io.anuke.mindustry.ui.Minimap;
|
||||
import io.anuke.mindustry.ui.SelectionTable;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.graphics.Hue;
|
||||
@ -33,7 +32,7 @@ import io.anuke.ucore.util.Mathf;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class HudFragment extends Fragment{
|
||||
public final BlocksFragment blockfrag = new BlocksFragment();
|
||||
public final PlacementFragment blockfrag = new PlacementFragment();
|
||||
|
||||
private ImageButton menu, flip;
|
||||
private Stack wavetable;
|
||||
@ -199,12 +198,6 @@ public class HudFragment extends Fragment{
|
||||
t.add("$text.saveload");
|
||||
});
|
||||
|
||||
//tapped block indicator
|
||||
parent.fill(t -> {
|
||||
t.bottom().visible(() -> !state.is(State.menu));
|
||||
t.add(new SelectionTable());
|
||||
});
|
||||
|
||||
blockfrag.build(Core.scene.getRoot());
|
||||
}
|
||||
|
||||
@ -231,7 +224,6 @@ public class HudFragment extends Fragment{
|
||||
|
||||
/**Show unlock notification for a new recipe.*/
|
||||
public void showUnlock(Recipe recipe){
|
||||
blockfrag.rebuild();
|
||||
|
||||
//if there's currently no unlock notification...
|
||||
if(lastUnlockTable == null){
|
||||
|
@ -31,7 +31,7 @@ public class OverlayFragment extends Fragment{
|
||||
config.build(group);
|
||||
consume.build(group);
|
||||
|
||||
input.buildUI(group);
|
||||
//input.buildUI(group);
|
||||
}
|
||||
|
||||
public void remove(){
|
||||
|
230
core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java
Normal file
@ -0,0 +1,230 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.type.Category;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.ui.ImageStack;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.OreBlock;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
import io.anuke.ucore.scene.event.Touchable;
|
||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.ImageButton;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class PlacementFragment extends Fragment{
|
||||
final int rowWidth = 4;
|
||||
|
||||
Category currentCategory = Category.turret;
|
||||
Block hovered, lastDisplay;
|
||||
Tile hoverTile;
|
||||
Table blockTable, toggler;
|
||||
boolean shown = true;
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
parent.fill(full -> {
|
||||
toggler = full;
|
||||
full.bottom().right().visible(() -> !state.is(State.menu));
|
||||
|
||||
full.table(frame -> {
|
||||
InputHandler input = control.input(0);
|
||||
|
||||
//rebuilds the category table with the correct recipes
|
||||
Runnable rebuildCategory = () -> {
|
||||
blockTable.clear();
|
||||
blockTable.top().margin(5);
|
||||
|
||||
int index = 0;
|
||||
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
group.setMinCheckCount(0);
|
||||
|
||||
for(Recipe recipe : Recipe.getByCategory(currentCategory)){
|
||||
|
||||
if(index++ % rowWidth == 0){
|
||||
blockTable.row();
|
||||
}
|
||||
|
||||
boolean[] unlocked = {false};
|
||||
|
||||
ImageButton button = blockTable.addImageButton("icon-locked", "select", 8*4, () -> {
|
||||
if(control.unlocks.isUnlocked(recipe)){
|
||||
input.recipe = input.recipe == recipe ? null : recipe;
|
||||
}
|
||||
}).size(46f).group(group).get();
|
||||
|
||||
button.update(() -> { //color unplacable things gray
|
||||
boolean ulock = control.unlocks.isUnlocked(recipe);
|
||||
TileEntity core = players[0].getClosestCore();
|
||||
Color color = core != null && core.items.has(recipe.requirements) ? Color.WHITE : ulock ? Color.GRAY : Color.WHITE;
|
||||
button.forEach(elem -> elem.setColor(color));
|
||||
button.setChecked(input.recipe == recipe);
|
||||
|
||||
if(ulock == unlocked[0]) return;
|
||||
unlocked[0] = ulock;
|
||||
|
||||
if(!ulock){
|
||||
button.replaceImage(new Image("icon-locked"));
|
||||
}else{
|
||||
button.replaceImage(new ImageStack(recipe.result.getCompactIcon()));
|
||||
}
|
||||
});
|
||||
|
||||
if(!mobile){
|
||||
button.hovered(() -> hovered = recipe.result);
|
||||
button.exited(() -> {
|
||||
if(hovered == recipe.result){
|
||||
hovered = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
blockTable.act(0f);
|
||||
};
|
||||
|
||||
//top table with hover info
|
||||
frame.table("clear", top -> {
|
||||
top.add(new Table()).growX().update(topTable -> {
|
||||
if((tileDisplayBlock() == null && lastDisplay == getSelected()) ||
|
||||
(tileDisplayBlock() != null && lastDisplay == tileDisplayBlock())) return;
|
||||
|
||||
topTable.clear();
|
||||
topTable.top().left().margin(5);
|
||||
|
||||
lastDisplay = getSelected();
|
||||
|
||||
if(lastDisplay != null){ //show selected recipe
|
||||
topTable.table(header -> {
|
||||
header.left();
|
||||
header.add(new ImageStack(lastDisplay.getCompactIcon())).size(8*4);
|
||||
header.labelWrap(() ->
|
||||
!control.unlocks.isUnlocked(Recipe.getByResult(lastDisplay)) ? Bundles.get("text.blocks.unknown") : lastDisplay.formalName)
|
||||
.left().width(190f).padLeft(5);
|
||||
header.add().growX();
|
||||
if(control.unlocks.isUnlocked(Recipe.getByResult(lastDisplay))){
|
||||
header.addButton("?", "clear-partial", () -> ui.content.show(Recipe.getByResult(lastDisplay)))
|
||||
.size(8 * 5).padTop(-5).padRight(-5).right().grow();
|
||||
}
|
||||
}).growX().left();
|
||||
topTable.row();
|
||||
//add requirement table
|
||||
topTable.table(req -> {
|
||||
req.top().left();
|
||||
|
||||
for(ItemStack stack : Recipe.getByResult(lastDisplay).requirements){
|
||||
req.table(line -> {
|
||||
line.left();
|
||||
line.addImage(stack.item.region).size(8*2);
|
||||
line.add(stack.item.localizedName()).color(Color.LIGHT_GRAY).padLeft(2).left();
|
||||
line.labelWrap(() -> {
|
||||
TileEntity core = players[0].getClosestCore();
|
||||
if(core == null || state.mode.infiniteResources) return "*/*";
|
||||
|
||||
int amount = core.items.get(stack.item);
|
||||
String color = (amount < stack.amount / 2f ? "[red]" : amount < stack.amount ? "[accent]" : "[white]");
|
||||
|
||||
return color + ui.formatAmount(amount) + "[white]/" + stack.amount;
|
||||
}).padLeft(5);
|
||||
}).left();
|
||||
req.row();
|
||||
}
|
||||
}).growX().left().margin(3);
|
||||
|
||||
}else if(tileDisplayBlock() != null){ //show selected tile
|
||||
lastDisplay = tileDisplayBlock();
|
||||
topTable.add(new ImageStack(lastDisplay.getDisplayIcon(hoverTile))).size(8*4);
|
||||
topTable.labelWrap(lastDisplay.getDisplayName(hoverTile)).left().width(190f).padLeft(5);
|
||||
}
|
||||
});
|
||||
top.row();
|
||||
top.addImage("blank").growX().color(Palette.accent).height(3f);
|
||||
}).colspan(3).fillX().visible(() -> getSelected() != null || tileDisplayBlock() != null).touchable(Touchable.enabled);
|
||||
frame.row();
|
||||
frame.table("clear", blocksSelect -> {
|
||||
blocksSelect.table(blocks -> blockTable = blocks).grow();
|
||||
blocksSelect.row();
|
||||
blocksSelect.table(input::buildUI).growX();
|
||||
}).fillY().bottom().touchable(Touchable.enabled);
|
||||
frame.addImage("blank").width(3f).fillY().color(Palette.accent);
|
||||
frame.table(categories -> {
|
||||
categories.defaults().size(50f);
|
||||
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
|
||||
for(Category cat : Category.values()){
|
||||
if(Recipe.getByCategory(cat).isEmpty()) continue;
|
||||
|
||||
categories.addImageButton("icon-" + cat.name(), "clear-toggle", 16*2, () -> {
|
||||
currentCategory = cat;
|
||||
rebuildCategory.run();
|
||||
}).group(group);
|
||||
|
||||
if(cat.ordinal() %2 == 1) categories.row();
|
||||
}
|
||||
}).touchable(Touchable.enabled);
|
||||
|
||||
rebuildCategory.run();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**Returns the currently displayed block in the top box.*/
|
||||
Block getSelected(){
|
||||
Block toDisplay = null;
|
||||
|
||||
//setup hovering tile
|
||||
if(!ui.hasMouse()){
|
||||
Tile tile = world.tileWorld(Graphics.mouseWorld().x, Graphics.mouseWorld().y);
|
||||
if(tile != null){
|
||||
hoverTile = tile.target();
|
||||
}else{
|
||||
hoverTile = null;
|
||||
}
|
||||
}else{
|
||||
hoverTile = null;
|
||||
}
|
||||
|
||||
//block currently selected
|
||||
if(control.input(0).recipe != null){
|
||||
toDisplay = control.input(0).recipe.result;
|
||||
}
|
||||
|
||||
//block hovered on in build menu
|
||||
if(hovered != null){
|
||||
toDisplay = hovered;
|
||||
}
|
||||
|
||||
return toDisplay;
|
||||
}
|
||||
|
||||
/**Returns the block currently being hovered over in the world.*/
|
||||
Block tileDisplayBlock(){
|
||||
return hoverTile == null ? null : hoverTile.block().synthetic() ? hoverTile.block() : hoverTile.floor() instanceof OreBlock ? hoverTile.floor() : null;
|
||||
}
|
||||
|
||||
/**Show or hide the placement menu.*/
|
||||
void toggle(float t, Interpolation ip){
|
||||
if(shown){
|
||||
shown = false;
|
||||
toggler.actions(Actions.translateBy(toggler.getTranslation().x + toggler.getWidth(), 0, t, ip));
|
||||
}else{
|
||||
shown = true;
|
||||
toggler.actions(Actions.translateBy(-toggler.getTranslation().x, 0, t, ip));
|
||||
}
|
||||
}
|
||||
}
|
@ -16,14 +16,11 @@ import io.anuke.mindustry.world.consumers.ConsumeLiquid;
|
||||
import io.anuke.mindustry.world.meta.BlockGroup;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.StatUnit;
|
||||
import io.anuke.mindustry.world.meta.StatValue;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Effects.Effect;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
@ -135,8 +132,9 @@ public class Drill extends Block{
|
||||
|
||||
for(int i = 0; i < list.size; i++){
|
||||
Item item = list.get(i);
|
||||
Cell<Image> imageCell = table.addImage(item.name + "1").size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3);
|
||||
StatValue.addToolTip(imageCell.getElement(), item);
|
||||
|
||||
table.addImage(item.name + "1").size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3);
|
||||
table.add(item.localizedName());
|
||||
if(i != list.size - 1){
|
||||
table.add("/");
|
||||
}
|
||||
|
@ -1,10 +1,5 @@
|
||||
package io.anuke.mindustry.world.meta;
|
||||
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.Tooltip;
|
||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
/**
|
||||
@ -13,37 +8,7 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
||||
public interface StatValue{
|
||||
/**
|
||||
* This method should provide all elements necessary to display this stat to the specified table.
|
||||
* For example, a stat that is just text would add label to the table.
|
||||
* For example, a stat that is just text would add a label to the table.
|
||||
*/
|
||||
void display(Table table);
|
||||
|
||||
/**
|
||||
* This method adds an icon image together with a tool tip which contains the name of the item.
|
||||
* @param table the table to add the image cell to.
|
||||
* @param item The item which provides the tool tip content.
|
||||
* @return the image cell which was created. The cell is not yet sized or padded.
|
||||
*/
|
||||
static Cell<Image> addImageWithToolTip(Table table, UnlockableContent item){
|
||||
|
||||
// Create a table cell with a new image as provided by the item
|
||||
Cell<Image> imageCell = table.addImage(item.getContentIcon());
|
||||
|
||||
// Retrieve the image and add a tool tip with the item's name
|
||||
addToolTip(imageCell.getElement(), item);
|
||||
|
||||
// Return the table cell for further processing (sizing, padding, ...)
|
||||
return imageCell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tool tip containing the item's localized name to the given element.
|
||||
* @param element The element to assign the tool tip to.
|
||||
* @param item The item which provides the tool tip content.
|
||||
*/
|
||||
static void addToolTip(Element element, UnlockableContent item){
|
||||
element.addListener(new Tooltip<>(new Table("clear"){{
|
||||
add(item.localizedName());
|
||||
margin(4);
|
||||
}}));
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,12 @@ package io.anuke.mindustry.world.meta.values;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.ui.ItemDisplay;
|
||||
import io.anuke.mindustry.world.meta.StatValue;
|
||||
import io.anuke.ucore.function.Predicate;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
|
||||
public class ItemFilterValue implements StatValue{
|
||||
private final Predicate<Item> filter;
|
||||
@ -27,10 +27,7 @@ public class ItemFilterValue implements StatValue{
|
||||
for(int i = 0; i < list.size; i++){
|
||||
Item item = list.get(i);
|
||||
|
||||
Cell<Image> imageCell = table.addImage(item.region);
|
||||
imageCell.size(8 * 3).padRight(2).padLeft(2);
|
||||
|
||||
StatValue.addToolTip(imageCell.getElement(), item);
|
||||
table.add(new ItemDisplay(item)).padRight(5);
|
||||
|
||||
if(i != list.size - 1){
|
||||
table.add("/");
|
||||
|
@ -3,11 +3,8 @@ package io.anuke.mindustry.world.meta.values;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.ui.ItemImage;
|
||||
import io.anuke.mindustry.ui.ItemDisplay;
|
||||
import io.anuke.mindustry.world.meta.ContentStatValue;
|
||||
import io.anuke.mindustry.world.meta.StatValue;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
public class ItemListValue implements ContentStatValue{
|
||||
@ -41,17 +38,11 @@ public class ItemListValue implements ContentStatValue{
|
||||
public void display(Table table){
|
||||
if(items != null){
|
||||
for(Item item : items){
|
||||
Cell<Image> imageCell = table.addImage(item.region);
|
||||
imageCell.size(8 * 3).padRight(5);
|
||||
|
||||
StatValue.addToolTip(imageCell.getElement(), item);
|
||||
table.add(new ItemDisplay(item));
|
||||
}
|
||||
}else{
|
||||
for(ItemStack stack : stacks){
|
||||
ItemImage image = new ItemImage(stack);
|
||||
table.add(image).size(8 * 3).padRight(5);
|
||||
|
||||
StatValue.addToolTip(image, stack.item);
|
||||
new ItemDisplay(stack.item, stack.amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,8 @@ package io.anuke.mindustry.world.meta.values;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.ui.ItemImage;
|
||||
import io.anuke.mindustry.ui.ItemDisplay;
|
||||
import io.anuke.mindustry.world.meta.ContentStatValue;
|
||||
import io.anuke.mindustry.world.meta.StatValue;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
public class ItemValue implements ContentStatValue{
|
||||
@ -22,9 +21,6 @@ public class ItemValue implements ContentStatValue{
|
||||
|
||||
@Override
|
||||
public void display(Table table){
|
||||
//TODO better implementation, quantity support
|
||||
ItemImage image = new ItemImage(item);
|
||||
table.add(image).size(8 * 3);
|
||||
StatValue.addToolTip(image, item.item);
|
||||
table.add(new ItemDisplay(item.item, item.amount));
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,12 @@ package io.anuke.mindustry.world.meta.values;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.ui.LiquidDisplay;
|
||||
import io.anuke.mindustry.world.meta.StatValue;
|
||||
import io.anuke.ucore.function.Predicate;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.Tooltip;
|
||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
|
||||
public class LiquidFilterValue implements StatValue{
|
||||
private final Predicate<Liquid> filter;
|
||||
@ -26,10 +25,7 @@ public class LiquidFilterValue implements StatValue{
|
||||
}
|
||||
|
||||
for(int i = 0; i < list.size; i++){
|
||||
Liquid item = list.get(i);
|
||||
|
||||
Cell<Image> imageCell = StatValue.addImageWithToolTip(table, item);
|
||||
imageCell.size(8 * 3).padRight(2).padLeft(2).padTop(2).padBottom(2);
|
||||
table.add(new LiquidDisplay(list.get(i))).padRight(5);
|
||||
|
||||
if(i != list.size - 1){
|
||||
table.add("/");
|
||||
|
@ -2,10 +2,8 @@ package io.anuke.mindustry.world.meta.values;
|
||||
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.ui.LiquidDisplay;
|
||||
import io.anuke.mindustry.world.meta.ContentStatValue;
|
||||
import io.anuke.mindustry.world.meta.StatValue;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
public class LiquidValue implements ContentStatValue{
|
||||
@ -22,7 +20,6 @@ public class LiquidValue implements ContentStatValue{
|
||||
|
||||
@Override
|
||||
public void display(Table table){
|
||||
Cell<Image> imageCell = StatValue.addImageWithToolTip(table, liquid);
|
||||
imageCell.size(8 * 3);
|
||||
table.add(new LiquidDisplay(liquid));
|
||||
}
|
||||
}
|
||||
|