mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
A little more minor skin clean up.
This commit is contained in:
parent
2b4bbcb4ee
commit
65752c6d39
@ -44,7 +44,7 @@ public class Skin {
|
|||||||
final OrderedSet<SkinEntry> attachments = new OrderedSet();
|
final OrderedSet<SkinEntry> attachments = new OrderedSet();
|
||||||
final Array<BoneData> bones = new Array(0);
|
final Array<BoneData> bones = new Array(0);
|
||||||
final Array<ConstraintData> constraints = new Array(0);
|
final Array<ConstraintData> constraints = new Array(0);
|
||||||
private final SkinEntry lookup = new SkinEntry();
|
private final SkinEntry lookup = new SkinEntry(0, "", null);
|
||||||
|
|
||||||
public Skin (String name) {
|
public Skin (String name) {
|
||||||
if (name == null) throw new IllegalArgumentException("name cannot be null.");
|
if (name == null) throw new IllegalArgumentException("name cannot be null.");
|
||||||
@ -54,10 +54,9 @@ public class Skin {
|
|||||||
|
|
||||||
/** Adds an attachment to the skin for the specified slot index and name. */
|
/** Adds an attachment to the skin for the specified slot index and name. */
|
||||||
public void setAttachment (int slotIndex, String name, Attachment attachment) {
|
public void setAttachment (int slotIndex, String name, Attachment attachment) {
|
||||||
if (slotIndex < 0) throw new IllegalArgumentException("slotIndex must be >= 0.");
|
|
||||||
if (attachment == null) throw new IllegalArgumentException("attachment cannot be null.");
|
if (attachment == null) throw new IllegalArgumentException("attachment cannot be null.");
|
||||||
SkinEntry newEntry = new SkinEntry(slotIndex, name, attachment);
|
SkinEntry entry = new SkinEntry(slotIndex, name, attachment);
|
||||||
if (!attachments.add(newEntry)) attachments.get(newEntry).attachment = attachment;
|
if (!attachments.add(entry)) attachments.get(entry).attachment = attachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds all attachments, bones, and constraints from the specified skin to this skin. */
|
/** Adds all attachments, bones, and constraints from the specified skin to this skin. */
|
||||||
@ -95,7 +94,6 @@ public class Skin {
|
|||||||
|
|
||||||
/** Returns the attachment for the specified slot index and name, or null. */
|
/** Returns the attachment for the specified slot index and name, or null. */
|
||||||
public Attachment getAttachment (int slotIndex, String name) {
|
public Attachment getAttachment (int slotIndex, String name) {
|
||||||
if (slotIndex < 0) throw new IllegalArgumentException("slotIndex must be >= 0.");
|
|
||||||
lookup.set(slotIndex, name);
|
lookup.set(slotIndex, name);
|
||||||
SkinEntry entry = attachments.get(lookup);
|
SkinEntry entry = attachments.get(lookup);
|
||||||
return entry != null ? entry.attachment : null;
|
return entry != null ? entry.attachment : null;
|
||||||
@ -103,7 +101,6 @@ public class Skin {
|
|||||||
|
|
||||||
/** Removes the attachment in the skin for the specified slot index and name, if any. */
|
/** Removes the attachment in the skin for the specified slot index and name, if any. */
|
||||||
public void removeAttachment (int slotIndex, String name) {
|
public void removeAttachment (int slotIndex, String name) {
|
||||||
if (slotIndex < 0) throw new IllegalArgumentException("slotIndex must be >= 0.");
|
|
||||||
lookup.set(slotIndex, name);
|
lookup.set(slotIndex, name);
|
||||||
attachments.remove(lookup);
|
attachments.remove(lookup);
|
||||||
}
|
}
|
||||||
@ -164,16 +161,14 @@ public class Skin {
|
|||||||
Attachment attachment;
|
Attachment attachment;
|
||||||
private int hashCode;
|
private int hashCode;
|
||||||
|
|
||||||
SkinEntry () {
|
/** @param attachment May be null. */
|
||||||
set(0, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
SkinEntry (int slotIndex, String name, Attachment attachment) {
|
SkinEntry (int slotIndex, String name, Attachment attachment) {
|
||||||
set(slotIndex, name);
|
set(slotIndex, name);
|
||||||
this.attachment = attachment;
|
this.attachment = attachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set (int slotIndex, String name) {
|
void set (int slotIndex, String name) {
|
||||||
|
if (slotIndex < 0) throw new IllegalArgumentException("slotIndex must be >= 0.");
|
||||||
if (name == null) throw new IllegalArgumentException("name cannot be null.");
|
if (name == null) throw new IllegalArgumentException("name cannot be null.");
|
||||||
this.slotIndex = slotIndex;
|
this.slotIndex = slotIndex;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user