Skip to content

Commit

Permalink
XmlReader.getChildren() + XmlReader.replaceChild() (libgdx#7499)
Browse files Browse the repository at this point in the history
* XmlReader.replaceChild

* Update XmlReader.rl

* Apply formatter

---------

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
TCreutzenberg and actions-user authored Nov 3, 2024
1 parent 98d64e2 commit 1ba527c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[1.13.1]
- iOS: Update to MobiVM 2.3.22
- Change visibility of PolygonSpriteBatch.switchTexture() to protected
- Added XmlReader.getChildren() and XmlReader.replaceChild()

[1.13.0]
- [BREAKING CHANGE] GWT: Updated to 2.11.0. `com.google.jsinterop:jsinterop-annotations:2.0.2:sources` must be added as a dependency to your html project dependencies.
Expand Down
11 changes: 11 additions & 0 deletions gdx/res/com/badlogic/gdx/utils/XmlReader.rl
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ public class XmlReader {
if (children == null) return 0;
return children.size;
}

public Array<Element> getChildren () {
return children;
}

/** @throws GdxRuntimeException if the element has no children. */
public Element getChild (int index) {
Expand Down Expand Up @@ -325,6 +329,13 @@ public class XmlReader {
public void remove () {
parent.removeChild(this);
}

public void replaceChild (Element child, Element replacement) {
if (children == null) throw new GdxRuntimeException("Element has no children: " + name);
final int index = children.indexOf(child, true);
if (index == -1) throw new GdxRuntimeException("Element does not contain child: " + child);
children.set(index, replacement);
}

public Element getParent () {
return parent;
Expand Down
11 changes: 11 additions & 0 deletions gdx/src/com/badlogic/gdx/utils/XmlReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,10 @@ public int getChildCount () {
return children.size;
}

public Array<Element> getChildren () {
return children;
}

/** @throws GdxRuntimeException if the element has no children. */
public Element getChild (int index) {
if (children == null) throw new GdxRuntimeException("Element has no children: " + name);
Expand Down Expand Up @@ -538,6 +542,13 @@ public void remove () {
parent.removeChild(this);
}

public void replaceChild (Element child, Element replacement) {
if (children == null) throw new GdxRuntimeException("Element has no children: " + name);
final int index = children.indexOf(child, true);
if (index == -1) throw new GdxRuntimeException("Element does not contain child: " + child);
children.set(index, replacement);
}

public Element getParent () {
return parent;
}
Expand Down

0 comments on commit 1ba527c

Please sign in to comment.