-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a display for the engineer count
- Loading branch information
Showing
6 changed files
with
96 additions
and
14 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.csse3200.game.components.gamearea; | ||
|
||
import com.badlogic.gdx.Gdx; | ||
import com.badlogic.gdx.graphics.Texture; | ||
import com.badlogic.gdx.graphics.g2d.BitmapFont; | ||
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||
import com.badlogic.gdx.graphics.g2d.TextureRegion; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Label; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Table; | ||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; | ||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable; | ||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; | ||
import com.badlogic.gdx.utils.Align; | ||
import com.csse3200.game.services.ServiceLocator; | ||
import com.csse3200.game.ui.UIComponent; | ||
|
||
public class EngineerCountDisplay extends UIComponent { | ||
private Table table; | ||
private TextButton engineerTb; | ||
|
||
@Override | ||
public void create() { | ||
super.create(); | ||
addActors(); | ||
} | ||
|
||
/** | ||
* Initialises the currency labels | ||
* Positions it on the stage using a table | ||
*/ | ||
private void addActors() { | ||
table = new Table(); | ||
table.top().left(); | ||
table.setFillParent(true); | ||
table.padTop(80f).padLeft(20f); | ||
|
||
Drawable drawable = new TextureRegionDrawable(new TextureRegion( | ||
new Texture("images/engineers/engineerBanner.png"))); | ||
TextButton.TextButtonStyle style = new TextButton.TextButtonStyle( | ||
drawable, drawable, drawable, new BitmapFont()); | ||
|
||
String text = String.format("%d", ServiceLocator.getGameEndService().getEngineerCount()); | ||
engineerTb = new TextButton(text, style); | ||
engineerTb.setDisabled(true); | ||
engineerTb.getLabel().setAlignment(Align.right); | ||
|
||
engineerTb.pad(0, 0, 0, 70); | ||
engineerTb.setTransform(true); | ||
|
||
table.add(engineerTb).width(engineerTb.getWidth() * 0.5f).height(engineerTb.getHeight() * 0.5f); | ||
stage.addActor(table); | ||
} | ||
|
||
public void updateCount() { | ||
String text = String.format("%d", ServiceLocator.getGameEndService().getEngineerCount()); | ||
engineerTb.getLabel().setText(text); | ||
} | ||
|
||
@Override | ||
protected void draw(SpriteBatch batch) { | ||
|
||
} | ||
|
||
@Override | ||
public void dispose() { | ||
super.dispose(); | ||
engineerTb.remove(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters