Added unlock messages for all content
This commit is contained in:
@@ -43,8 +43,7 @@ about.button = About
|
|||||||
name = Name:
|
name = Name:
|
||||||
noname = Pick a[accent] player name[] first.
|
noname = Pick a[accent] player name[] first.
|
||||||
filename = File Name:
|
filename = File Name:
|
||||||
unlocked = New Block Unlocked!
|
unlocked = New content unlocked!
|
||||||
unlocked.plural = New Blocks Unlocked!
|
|
||||||
players = {0} players online
|
players = {0} players online
|
||||||
players.single = {0} player online
|
players.single = {0} player online
|
||||||
server.closing = [accent]Closing server...
|
server.closing = [accent]Closing server...
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ public class Mechs implements ContentList{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAlt(Player player){
|
public boolean alwaysUnlocked(){
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -182,18 +182,25 @@ public class Mechs implements ContentList{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
dart = new Mech("dart-ship", true){{
|
dart = new Mech("dart-ship", true){
|
||||||
drillPower = 1;
|
{
|
||||||
mineSpeed = 0.9f;
|
drillPower = 1;
|
||||||
speed = 0.4f;
|
mineSpeed = 0.9f;
|
||||||
drag = 0.1f;
|
speed = 0.4f;
|
||||||
armor = 10f;
|
drag = 0.1f;
|
||||||
weapon = Weapons.blasterSmall;
|
armor = 10f;
|
||||||
weaponOffsetX = -1;
|
weapon = Weapons.blasterSmall;
|
||||||
weaponOffsetY = -1;
|
weaponOffsetX = -1;
|
||||||
trailColor = Palette.lightTrail;
|
weaponOffsetY = -1;
|
||||||
cellTrnsY = 1f;
|
trailColor = Palette.lightTrail;
|
||||||
}};
|
cellTrnsY = 1f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean alwaysUnlocked(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
javelin = new Mech("javelin-ship", true){
|
javelin = new Mech("javelin-ship", true){
|
||||||
float minV = 3.6f;
|
float minV = 3.6f;
|
||||||
|
|||||||
@@ -133,6 +133,8 @@ public class Control implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Events.on(UnlockEvent.class, e -> ui.hudfrag.showUnlock(e.content));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(int index){
|
public void addPlayer(int index){
|
||||||
|
|||||||
@@ -60,9 +60,9 @@ public class EventType{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class UnlockEvent implements Event{
|
public static class UnlockEvent implements Event{
|
||||||
public final Content content;
|
public final UnlockableContent content;
|
||||||
|
|
||||||
public UnlockEvent(Content content){
|
public UnlockEvent(UnlockableContent content){
|
||||||
this.content = content;
|
this.content = content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,23 +57,17 @@ public class GlobalData{
|
|||||||
* Makes this piece of content 'unlocked', if possible.
|
* Makes this piece of content 'unlocked', if possible.
|
||||||
* If this piece of content is already unlocked or cannot be unlocked due to dependencies, nothing changes.
|
* If this piece of content is already unlocked or cannot be unlocked due to dependencies, nothing changes.
|
||||||
* Results are not saved until you call {@link #save()}.
|
* Results are not saved until you call {@link #save()}.
|
||||||
*
|
|
||||||
* @return whether or not this content was newly unlocked.
|
|
||||||
*/
|
*/
|
||||||
public boolean unlockContent(UnlockableContent content){
|
public void unlockContent(UnlockableContent content){
|
||||||
if(!content.canBeUnlocked() || content.alwaysUnlocked()) return false;
|
if(!content.canBeUnlocked() || content.alwaysUnlocked()) return;
|
||||||
|
|
||||||
boolean ret = unlocked.getOr(content.getContentType(), ObjectSet::new).add(content.getContentName());
|
|
||||||
|
|
||||||
//fire unlock event so other classes can use it
|
//fire unlock event so other classes can use it
|
||||||
if(ret){
|
if(unlocked.getOr(content.getContentType(), ObjectSet::new).add(content.getContentName())){
|
||||||
modified = true;
|
modified = true;
|
||||||
content.onUnlock();
|
content.onUnlock();
|
||||||
Events.fire(new UnlockEvent(content));
|
Events.fire(new UnlockEvent(content));
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Clears all unlocked content. Automatically saves.*/
|
/** Clears all unlocked content. Automatically saves.*/
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import io.anuke.arc.Core;
|
|||||||
import io.anuke.arc.Events;
|
import io.anuke.arc.Events;
|
||||||
import io.anuke.arc.collection.Array;
|
import io.anuke.arc.collection.Array;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
|
||||||
import io.anuke.arc.math.Interpolation;
|
import io.anuke.arc.math.Interpolation;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.scene.Element;
|
import io.anuke.arc.scene.Element;
|
||||||
@@ -13,7 +12,6 @@ import io.anuke.arc.scene.actions.Actions;
|
|||||||
import io.anuke.arc.scene.event.Touchable;
|
import io.anuke.arc.scene.event.Touchable;
|
||||||
import io.anuke.arc.scene.ui.Image;
|
import io.anuke.arc.scene.ui.Image;
|
||||||
import io.anuke.arc.scene.ui.ImageButton;
|
import io.anuke.arc.scene.ui.ImageButton;
|
||||||
import io.anuke.arc.scene.ui.Label;
|
|
||||||
import io.anuke.arc.scene.ui.TextButton;
|
import io.anuke.arc.scene.ui.TextButton;
|
||||||
import io.anuke.arc.scene.ui.layout.Stack;
|
import io.anuke.arc.scene.ui.layout.Stack;
|
||||||
import io.anuke.arc.scene.ui.layout.Table;
|
import io.anuke.arc.scene.ui.layout.Table;
|
||||||
@@ -24,12 +22,12 @@ import io.anuke.arc.util.Time;
|
|||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.game.EventType.StateChangeEvent;
|
import io.anuke.mindustry.game.EventType.StateChangeEvent;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
|
import io.anuke.mindustry.game.UnlockableContent;
|
||||||
import io.anuke.mindustry.gen.Call;
|
import io.anuke.mindustry.gen.Call;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.input.Binding;
|
import io.anuke.mindustry.input.Binding;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.net.Packets.AdminAction;
|
import io.anuke.mindustry.net.Packets.AdminAction;
|
||||||
import io.anuke.mindustry.type.Recipe;
|
|
||||||
import io.anuke.mindustry.ui.IntFormat;
|
import io.anuke.mindustry.ui.IntFormat;
|
||||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||||
|
|
||||||
@@ -229,7 +227,9 @@ public class HudFragment extends Fragment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Show unlock notification for a new recipe. */
|
/** Show unlock notification for a new recipe. */
|
||||||
public void showUnlock(Recipe recipe){
|
public void showUnlock(UnlockableContent content){
|
||||||
|
//some content may not have icons... yet
|
||||||
|
if(content.getContentIcon() == null) return;
|
||||||
|
|
||||||
//if there's currently no unlock notification...
|
//if there's currently no unlock notification...
|
||||||
if(lastUnlockTable == null){
|
if(lastUnlockTable == null){
|
||||||
@@ -246,14 +246,10 @@ public class HudFragment extends Fragment{
|
|||||||
Table in = new Table();
|
Table in = new Table();
|
||||||
|
|
||||||
//create texture stack for displaying
|
//create texture stack for displaying
|
||||||
Stack stack = new Stack();
|
Image image = new Image(content.getContentIcon());
|
||||||
for(TextureRegion region : recipe.result.getCompactIcon()){
|
image.setScaling(Scaling.fit);
|
||||||
Image image = new Image(region);
|
|
||||||
image.setScaling(Scaling.fit);
|
|
||||||
stack.add(image);
|
|
||||||
}
|
|
||||||
|
|
||||||
in.add(stack).size(48f).pad(2);
|
in.add(image).size(48f).pad(2);
|
||||||
|
|
||||||
//add to table
|
//add to table
|
||||||
table.add(in).padRight(8);
|
table.add(in).padRight(8);
|
||||||
@@ -289,11 +285,6 @@ public class HudFragment extends Fragment{
|
|||||||
//get size of each element
|
//get size of each element
|
||||||
float size = 48f / Math.min(elements.size + 1, col);
|
float size = 48f / Math.min(elements.size + 1, col);
|
||||||
|
|
||||||
//correct plurals if needed
|
|
||||||
if(esize == 1){
|
|
||||||
((Label) lastUnlockLayout.getParent().find(e -> e instanceof Label)).setText("$unlocked.plural");
|
|
||||||
}
|
|
||||||
|
|
||||||
lastUnlockLayout.clearChildren();
|
lastUnlockLayout.clearChildren();
|
||||||
lastUnlockLayout.defaults().size(size).pad(2);
|
lastUnlockLayout.defaults().size(size).pad(2);
|
||||||
|
|
||||||
@@ -308,14 +299,10 @@ public class HudFragment extends Fragment{
|
|||||||
//if there's space, add it
|
//if there's space, add it
|
||||||
if(esize < cap){
|
if(esize < cap){
|
||||||
|
|
||||||
Stack stack = new Stack();
|
Image image = new Image(content.getContentIcon());
|
||||||
for(TextureRegion region : recipe.result.getCompactIcon()){
|
image.setScaling(Scaling.fit);
|
||||||
Image image = new Image(region);
|
|
||||||
image.setScaling(Scaling.fit);
|
|
||||||
stack.add(image);
|
|
||||||
}
|
|
||||||
|
|
||||||
lastUnlockLayout.add(stack);
|
lastUnlockLayout.add(image);
|
||||||
}else{ //else, add a specific icon to denote no more space
|
}else{ //else, add a specific icon to denote no more space
|
||||||
lastUnlockLayout.addImage("icon-add");
|
lastUnlockLayout.addImage("icon-add");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user