<commit_before>package com.galvarez.ttw.rendering;

import static java.lang.String.format;

import java.util.ArrayList;
import java.util.List;

import com.artemis.systems.VoidEntitySystem;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.galvarez.ttw.rendering.ui.FramedDialog;

/**
 * Store notifications until processed.
 * 
 * @author <NAME>
 */
public final class NotificationsSystem extends VoidEntitySystem {

  private final List<String> titles = new ArrayList<>();

  private final List<String> notifications = new ArrayList<>();

  private final List<ChangeListener> listeners = new ArrayList<>();

  private final Stage stage;

  private final Skin skin;

  public NotificationsSystem(Stage stage) {
    this.stage = stage;

    this.skin = new Skin(new FileHandle("resources/uiskin/uiskin.json"));
  }

  @Override
  protected void processSystem() {
    for (int i = 0; i < titles.size(); i++) {
      FramedDialog dialog = new FramedDialog(skin, titles.get(i), notifications.get(i));
      dialog.addButton("OK", listeners.get(i));
      dialog.setKey(Keys.ENTER, null);
      dialog.addToStage(stage, 350, 200);
    }
    titles.clear();
    notifications.clear();
  }

  public void addNotification(String title, String msg, Object ... args) {
    addNotification(null, title, msg, args);
  }

  public void addNotification(ChangeListener listener, String title, String msg, Object ... args) {
    titles.add(title);
    listeners.add(listener);
    if (args == null || args.length == 0)
      notifications.add(msg);
    else
      notifications.add(format(msg, args));
  }
}<commit_msg>Fix bug with notifications 'OK' button listener.<commit_after>package com.galvarez.ttw.rendering;

import static java.lang.String.format;

import java.util.ArrayList;
import java.util.List;

import com.artemis.systems.VoidEntitySystem;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.galvarez.ttw.rendering.ui.FramedDialog;

/**
 * Store notifications until processed.
 * 
 * @author <NAME>
 */
public final class NotificationsSystem extends VoidEntitySystem {

  private final List<String> titles = new ArrayList<>();

  private final List<String> notifications = new ArrayList<>();

  private final List<ChangeListener> listeners = new ArrayList<>();

  private final Stage stage;

  private final Skin skin;

  public NotificationsSystem(Stage stage) {
    this.stage = stage;

    this.skin = new Skin(new FileHandle("resources/uiskin/uiskin.json"));
  }

  @Override
  protected void processSystem() {
    for (int i = 0; i < titles.size(); i++) {
      FramedDialog dialog = new FramedDialog(skin, titles.get(i), notifications.get(i));
      dialog.addButton("OK", listeners.get(i));
      dialog.setKey(Keys.ENTER, null);
      dialog.addToStage(stage, 350, 200);
    }
    titles.clear();
    notifications.clear();
    listeners.clear();
  }

  public void addNotification(String title, String msg, Object ... args) {
    addNotification(null, title, msg, args);
  }

  public void addNotification(ChangeListener listener, String title, String msg, Object ... args) {
    titles.add(title);
    listeners.add(listener);
    if (args == null || args.length == 0)
      notifications.add(msg);
    else
      notifications.add(format(msg, args));
  }
}
{'fraction_non_alphanumeric': 0.1273274917853231, 'fraction_numerical': 0.006024096385542169, 'mean_word_length': 4.017857142857143, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2140809', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1104, 'n_words': 265}