Skip to content

Commit

Permalink
#56 Fixes possible illegal argument exception.
Browse files Browse the repository at this point in the history
Adds news label into NewsCorpView.
  • Loading branch information
tuomount committed Jul 30, 2017
1 parent 3f9046a commit ae6a5e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/org/openRealmOfStars/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@ public void showNewsCorpView() {
NewsData[] news = new NewsData[2];
news[0] = NewsFactory.makePeaceNews(players.getPlayerInfoByIndex(0),
players.getPlayerInfoByIndex(1), null);
news[1] = NewsFactory.makeStatNews(starMap);
news[1] = NewsFactory.makeWarNews(players.getPlayerInfoByIndex(1),
players.getPlayerInfoByIndex(0), null, starMap);
newsCorpView = new NewsCorpView(news, this);
this.updateDisplay(newsCorpView);
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/openRealmOfStars/game/States/NewsCorpView.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.openRealmOfStars.gui.buttons.SpaceButton;
import org.openRealmOfStars.gui.infopanel.InfoPanel;
import org.openRealmOfStars.gui.labels.InfoTextArea;
import org.openRealmOfStars.gui.labels.TransparentLabel;
import org.openRealmOfStars.gui.panels.BlackPanel;
import org.openRealmOfStars.gui.panels.ImagePanel;
import org.openRealmOfStars.gui.panels.InvisiblePanel;
Expand Down Expand Up @@ -83,6 +84,11 @@ public class NewsCorpView extends BlackPanel {
* Current news index
*/
private int newsIndex = 0;

/**
* News list label
*/
private TransparentLabel newsLabel;
/**
* Construtor for News Corp View.
* @param news News Data
Expand Down Expand Up @@ -123,6 +129,10 @@ public NewsCorpView(final NewsData[] news, final ActionListener listener) {
this);
iBtn.addActionListener(listener);
invis.add(iBtn);
invis.add(Box.createRigidArea(new Dimension(10, 5)));
newsLabel = new TransparentLabel(invis, "100/100");
newsLabel.setText("1/" + newsList.length);
invis.add(newsLabel);
iBtn = new IconButton(GuiStatics.RIGHT_ARROW,
GuiStatics.RIGHT_ARROW_PRESSED, false, GameCommands.COMMAND_NEXT_TARGET,
this);
Expand Down Expand Up @@ -188,6 +198,7 @@ public void handleAction(final ActionEvent arg0) {
newsList[newsIndex].getImageInstructions());
newsImage.setImage(image);
textArea.setText(newsList[newsIndex].getNewsText());
newsLabel.setText(newsIndex + 1 + "/" + newsList.length);
repaint();
}
if (arg0.getActionCommand().equals(GameCommands.COMMAND_PREV_TARGET)
Expand All @@ -199,6 +210,7 @@ public void handleAction(final ActionEvent arg0) {
newsList[newsIndex].getImageInstructions());
newsImage.setImage(image);
textArea.setText(newsList[newsIndex].getNewsText());
newsLabel.setText(newsIndex + 1 + "/" + newsList.length);
repaint();
}
}
Expand Down

0 comments on commit ae6a5e1

Please sign in to comment.