Search in sources :

Example 1 with ActorState

use of com.ixale.starparse.parser.Parser.ActorState in project StarParse by Ixale.

the class HotsPopoutPresenter method setActorStates.

public void setActorStates(final Map<Actor, ActorState> actorStates, final String currentCharacterName) {
    this.currentCharacterName = currentCharacterName;
    autosizeButton.setVisible(currentCharacterName != null);
    if (!isEnabled()) {
        return;
    }
    if (players.size() > matrix.length * matrix[0].length) {
        // safety
        return;
    }
    final List<Object[]> newPlayers = new ArrayList<>();
    for (final Actor actor : actorStates.keySet()) {
        if (!(Actor.Type.SELF.equals(actor.getType()) || Actor.Type.PLAYER.equals(actor.getType()))) {
            continue;
        }
        final ActorState state = actorStates.get(actor);
        if (state.hotLast != null) {
            // ignore extremely old
            if (state.hotLast < TimeUtils.getCurrentTime() - TIMEOUT_WITHOUT_DURATION) {
                continue;
            }
            if (!players.containsKey(actor.getName())) {
                if (ignorePlayers.containsKey(actor.getName())) {
                    if (ignorePlayers.get(actor.getName()) >= state.hotLast) {
                        continue;
                    }
                    ignorePlayers.remove(actor.getName());
                }
                newPlayers.add(new Object[] { actor.getName(), state });
            }
        }
    }
    if (newPlayers.isEmpty()) {
        return;
    }
    // ensure the players are added according to their HOT application to allow simpler overlay setup
    newPlayers.sort(Comparator.comparing(o -> ((ActorState) o[1]).hotLast));
    for (final Object[] pair : newPlayers) {
        addPlayer((String) pair[0], (ActorState) pair[1]);
    }
}
Also used : EventHandler(javafx.event.EventHandler) Button(javafx.scene.control.Button) FontWeight(javafx.scene.text.FontWeight) FilenameFilter(java.io.FilenameFilter) Pos(javafx.geometry.Pos) Arrays(java.util.Arrays) URL(java.net.URL) MouseEvent(javafx.scene.input.MouseEvent) HashMap(java.util.HashMap) Bindings(javafx.beans.binding.Bindings) DragEvent(javafx.scene.input.DragEvent) TransferMode(javafx.scene.input.TransferMode) ArrayList(java.util.ArrayList) Line(javafx.scene.shape.Line) Dragboard(javafx.scene.input.Dragboard) Matcher(java.util.regex.Matcher) Insets(javafx.geometry.Insets) ResourceBundle(java.util.ResourceBundle) CombatStats(com.ixale.starparse.domain.stats.CombatStats) BackgroundFill(javafx.scene.layout.BackgroundFill) Map(java.util.Map) ActorState(com.ixale.starparse.parser.Parser.ActorState) TimeUtils(com.ixale.starparse.time.TimeUtils) Color(javafx.scene.paint.Color) Label(javafx.scene.control.Label) Files(java.nio.file.Files) GraphicsContext(javafx.scene.canvas.GraphicsContext) Combat(com.ixale.starparse.domain.Combat) Event(javafx.event.Event) Font(javafx.scene.text.Font) Canvas(javafx.scene.canvas.Canvas) Screen(javafx.stage.Screen) Background(javafx.scene.layout.Background) File(java.io.File) Objects(java.util.Objects) FXML(javafx.fxml.FXML) Cursor(javafx.scene.Cursor) List(java.util.List) ActionEvent(javafx.event.ActionEvent) DataFormat(javafx.scene.input.DataFormat) AnchorPane(javafx.scene.layout.AnchorPane) Pattern(java.util.regex.Pattern) ClipboardContent(javafx.scene.input.ClipboardContent) Comparator(java.util.Comparator) Actor(com.ixale.starparse.domain.Actor) Collections(java.util.Collections) CornerRadii(javafx.scene.layout.CornerRadii) ActorState(com.ixale.starparse.parser.Parser.ActorState) Actor(com.ixale.starparse.domain.Actor) ArrayList(java.util.ArrayList)

Aggregations

Actor (com.ixale.starparse.domain.Actor)1 Combat (com.ixale.starparse.domain.Combat)1 CombatStats (com.ixale.starparse.domain.stats.CombatStats)1 ActorState (com.ixale.starparse.parser.Parser.ActorState)1 TimeUtils (com.ixale.starparse.time.TimeUtils)1 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 URL (java.net.URL)1 Files (java.nio.file.Files)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 ResourceBundle (java.util.ResourceBundle)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1