Skip to content

Commit

Permalink
Fixed sector gameover ghost bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Nov 20, 2020
1 parent aa2783a commit 1372fc4
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Expand Up @@ -35,7 +35,7 @@ dependencies{
natives "com.github.Anuken.Arc:natives-box2d-android:${getArcHash()}"

//android dependencies magically disappear during compilation, thanks gradle!
def sdkFile = new File((String)System.getenv("ANDROID_HOME"), "/platforms/android-29/android.jar")
def sdkFile = new File((String)findSdkDir(), "/platforms/android-29/android.jar")
if(sdkFile.exists()) compileOnly files(sdkFile.absolutePath)
}

Expand Down
11 changes: 11 additions & 0 deletions build.gradle
Expand Up @@ -99,6 +99,17 @@ allprojects{
return project.ext.mainClassName.substring(0, project.ext.mainClassName.indexOf("desktop") - 1)
}

findSdkDir = {
//null because IntelliJ doesn't get env variables
def v = System.getenv("ANDROID_HOME")
if(v != null) return v
//rootDir is null here, amazing. brilliant.
def file = new File("local.properties")
if(!file.exists()) file = new File("../local.properties")
def props = new Properties().with{p -> p.load(file.newReader()); return p }
return props.get("sdk.dir")
}

generateLocales = {
def output = 'en\n'
def bundles = new File(project(':core').projectDir, 'assets/bundles/')
Expand Down
1 change: 1 addition & 0 deletions core/assets/bundles/bundle.properties
Expand Up @@ -549,6 +549,7 @@ sectors.nonelaunch = [lightgray]none (sun)
sectors.rename = Rename Sector

sector.curcapture = Sector Captured
sector.curlost = Sector Lost
sector.missingresources = [scarlet]Insufficient Core Resources
sector.attacked = Sector [accent]{0}[white] under attack!
sector.lost = Sector [accent]{0}[white] lost!
Expand Down
2 changes: 1 addition & 1 deletion core/src/mindustry/core/GameState.java
Expand Up @@ -69,7 +69,7 @@ public boolean isEditor(){
}

public boolean isPaused(){
return (is(State.paused) && !net.active()) || (gameOver && !net.active()) || (serverPaused && !isMenu());
return (is(State.paused) && !net.active()) || (gameOver && (!net.active() || isCampaign())) || (serverPaused && !isMenu());
}

public boolean isPlaying(){
Expand Down
2 changes: 1 addition & 1 deletion core/src/mindustry/type/Sector.java
Expand Up @@ -98,7 +98,7 @@ public boolean isAttacked(){

/** @return whether the player has a base here. */
public boolean hasBase(){
return save != null && info.hasCore;
return save != null && info.hasCore && !(Vars.state.isGame() && Vars.state.rules.sector == this && state.gameOver);
}

/** @return whether the enemy has a generated base here. */
Expand Down
4 changes: 2 additions & 2 deletions core/src/mindustry/ui/dialogs/GameOverDialog.java
Expand Up @@ -31,13 +31,13 @@ public void show(Team winner){
}

void rebuild(){
title.setText("@gameover");
title.setText(state.isCampaign() ? "@sector.curlost" : "@gameover");
buttons.clear();
cont.clear();

buttons.margin(10);

if(state.rules.pvp){
if(state.rules.pvp && winner != null){
cont.add(Core.bundle.format("gameover.pvp", winner.localized())).pad(6);
buttons.button("@menu", () -> {
hide();
Expand Down
3 changes: 2 additions & 1 deletion core/src/mindustry/ui/dialogs/PlanetDialog.java
Expand Up @@ -239,6 +239,7 @@ boolean canSelect(Sector sector){
}

Sector findLauncher(Sector to){
Sector launchSector = this.launchSector != null && this.launchSector.hasBase() ? this.launchSector : null;
//directly nearby.
if(to.near().contains(launchSector)) return launchSector;

Expand Down Expand Up @@ -711,7 +712,7 @@ void updateSelected(){

if((sector.hasBase() && mode == look) || canSelect(sector) || (sector.preset != null && sector.preset.alwaysUnlocked) || debugSelect){
stable.button(mode == select ? "@sectors.select" : sector.hasBase() ? "@sectors.resume" : "@sectors.launch", Icon.play, () -> {
if(state.rules.sector == sector && !state.isMenu()){
if(sector.isBeingPlayed()){
//already at this sector
hide();
return;
Expand Down
2 changes: 1 addition & 1 deletion core/src/mindustry/ui/fragments/HudFragment.java
Expand Up @@ -90,7 +90,7 @@ public void build(Group parent){
parent.fill(t -> {
t.name = "paused";
t.top().visible(() -> state.isPaused() && shown).touchable = Touchable.disabled;
t.table(Styles.black5, top -> top.add("@paused").style(Styles.outlineLabel).pad(8f)).growX();
t.table(Styles.black5, top -> top.label(() -> state.gameOver && state.isCampaign() ? "@sector.curlost" : "@paused").style(Styles.outlineLabel).pad(8f)).growX();
});

//minimap + position
Expand Down

1 comment on commit 1372fc4

@Soham-maiti
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is ok but the gameover is a bit late at coming

Please sign in to comment.