Ejemplo n.º 1
0
  public void setSelectedGame(RecentGame game) {
    item1Label.setItem(Item.getItemFromID(game.getStatistic("ITEM0")));
    item2Label.setItem(Item.getItemFromID(game.getStatistic("ITEM1")));
    item3Label.setItem(Item.getItemFromID(game.getStatistic("ITEM2")));
    item4Label.setItem(Item.getItemFromID(game.getStatistic("ITEM3")));
    item5Label.setItem(Item.getItemFromID(game.getStatistic("ITEM4")));
    item6Label.setItem(Item.getItemFromID(game.getStatistic("ITEM5")));

    statsPanel.removeAll();
    for (Map.Entry<String, Integer> entry : game.getStatistics().entrySet()) {
      String key = entry.getKey();
      if (key.startsWith("ITEM") || key.startsWith("WIN") || key.startsWith("LOSE")) continue;
      statsPanel.add(new LocalizedJLabel(statsMessages, entry.getKey()));
      statsPanel.add(new JLabel(entry.getValue().toString()));
    }
    try {
      currentGameChampion.setChampion(Champion.getChampionFromID(game.getChampionID()));
    } catch (Exception e) {
      e.printStackTrace();
    }
    currentGameChampionName.setText(
        Champion.getChampionFromID(game.getChampionID()).getDisplayName());
    currentGameChampion.setSize(60, 60);
    gameInfo.revalidate();
  }
 public static void save(RecentGame game, Summoner summoner) throws IOException {
   ObjectOutputStream objectOutputStream = null;
   RandomAccessFile raf = null;
   try {
     // TODO: write to XML or something instead of Java's silly format
     String gameFileString =
         String.format(
             gameFileFormat,
             ServerInfo.currentServerInfo.region,
             summoner.getSummonerID(),
             game.getGameID());
     raf = new RandomAccessFile(FileSystem.getFile(gameFileString), "rw");
     FileOutputStream fos = new FileOutputStream(raf.getFD());
     objectOutputStream = new ObjectOutputStream(fos);
     objectOutputStream.writeObject(game);
   } finally {
     if (objectOutputStream != null) {
       objectOutputStream.close();
     }
     if (raf != null) {
       raf.close();
     }
   }
 }