Crossfire JXClient, Trunk  R20561
Animations.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff.
19  * Copyright (C) 2006-2011 Andreas Kirschbaum.
20  */
21 
22 package com.realtime.crossfire.jxclient.animations;
23 
27 import java.util.HashMap;
28 import java.util.Map;
29 import org.jetbrains.annotations.NotNull;
30 import org.jetbrains.annotations.Nullable;
31 
37 public class Animations {
38 
42  @NotNull
43  private final Map<Integer, Animation> animations = new HashMap<>();
44 
49  @NotNull
50  @SuppressWarnings("FieldCanBeLocal")
52 
53  @Override
54  public void start() {
55  // ignore
56  }
57 
58  @Override
59  public void metaserver() {
60  // ignore
61  }
62 
63  @Override
64  public void preConnecting(@NotNull final String serverInfo) {
65  // ignore
66  }
67 
68  @Override
69  public void connecting(@NotNull final String serverInfo) {
70  animations.clear();
71  }
72 
73  @Override
74  public void connecting(@NotNull final ClientSocketState clientSocketState) {
75  // ignore
76  }
77 
78  @Override
79  public void connected() {
80  // ignore
81  }
82 
83  @Override
84  public void connectFailed(@NotNull final String reason) {
85  // ignore
86  }
87 
88  };
89 
95  public Animations(@Nullable final GuiStateManager guiStateManager) {
96  if (guiStateManager != null) {
97  guiStateManager.addGuiStateListener(guiStateListener);
98  }
99  }
100 
107  public void addAnimation(final int animationId, final int flags, @NotNull final int[] faces) {
108  if (faces.length == 1) {
109  System.err.println("Warning: animation id "+animationId+" has only one face");
110  }
111 
112  final Animation animation = new Animation(animationId, flags, faces);
113  if (animations.put(animationId, animation) != null) {
114  System.err.println("Warning: duplicate animation id "+animationId);
115  }
116  }
117 
124  @Nullable
125  public Animation get(final int animationId) {
126  return animations.get(animationId);
127  }
128 
129 }
Interface for listeners interested gui state changes.
void addAnimation(final int animationId, final int flags, @NotNull final int[] faces)
Defines a new animation.
final GuiStateListener guiStateListener
The GuiStateListener for detecting established or dropped connections.
Definition: Animations.java:51
final Map< Integer, Animation > animations
All defined animations.
Definition: Animations.java:43
Animations(@Nullable final GuiStateManager guiStateManager)
Creates a new instance.
Definition: Animations.java:95
Manages animations received from the server.
Definition: Animation.java:31
Connection progress states of the Crossfire server connection.
Manages animations received from the server.
Definition: Animations.java:37