/* * BAGSStatusBar.bsh * * Copyright 2005 M. Aaron Wadley * * This file is part of BAGS (Beany Adventure Game System). * BAGS (Beany Adventure Game System) is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * BAGS (Beany Adventure Game System) is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with BAGS (Beany Adventure Game System); if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ StatusBar (sp) { updateColors() { rightPanel.foreground=foreground; rightPanel.background=background; turnLabel.foreground = foreground; turnLabel.background = background; scoreLabel.foreground = foreground; scoreLabel.background = background; roomLabel.foreground = foreground; roomLabel.background = background; } updateColors(newFg, newBg) { foreground = newFg; background = newBg; updateColors(); } updateBackground(newBg) { background = newBg; updateColors(); } updateForeground(newFg) { foreground = newFg; updateColors(); } foreground = sp.foreground; background = sp.background; statusPanel = sp; GridLayout l = new GridLayout(0,2); sp.setLayout(l); roomLabel = new JLabel(); turnLabel = new JLabel(); scoreLabel = new JLabel(); rightPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING, 10,0)); turnLabel.setHorizontalAlignment(SwingConstants.RIGHT); rightPanel.add(scoreLabel); rightPanel.add(turnLabel); sp.add(roomLabel); sp.add(rightPanel); updateColors(); update(game) { if (isTrue(game.showStatus)) { sp.visible=true; scoreLabel.visible=true; scoreLabel.setText("
Score " + game.pc.score + "
"); if (isTrue(game.showTurns)) { turnLabel.visible=true; turnLabel.setText("
Turn " + game.turn + "
"); } else { turnLabel.visible=false; } if (isTrue(game.showRoom)) { roomLabel.visible=true; roomLabel.setText("

" + game.rooms.getDynamicTitle(game.currentLocation) + "

"); } else { roomLabel.visible=false; } } else { sp.visible=false; } } return this; }