use of com.badlogic.gdx.utils.XmlReader in project talos by rockbite.
the class UIKit method create.
@Override
public void create() {
super.create();
TextureAtlas atlas = new TextureAtlas(Gdx.files.internal("skin/uiskin.atlas"));
skin = new Skin(Gdx.files.internal("skin/uiskin.json"));
skin.addRegions(atlas);
table = new Table();
AbstractShaderNode shaderNode = new AbstractShaderNode() {
@Override
public void prepareDeclarations(ShaderBuilder shaderBuilder) {
}
@Override
public String writeOutputCode(String slotId) {
return null;
}
};
shaderNode.init(skin, null);
XmlReader reader = new XmlReader();
XmlReader.Element root = reader.parse(Gdx.files.internal("addons/shader/nodes.xml"));
shaderNode.constructNode(root.getChild(0).getChild(0));
table.add(shaderNode);
stage = new Stage();
Gdx.input.setInputProcessor(stage);
table.setFillParent(true);
stage.addActor(table);
}
use of com.badlogic.gdx.utils.XmlReader in project talos by rockbite.
the class ExternalShaderNode method addUniformInput.
private void addUniformInput(String uniformName, String method, String[] args) {
String xml = "<value port=\"input\" name=\"" + uniformName + "\" type=\"float\">" + uniformName + "</value>";
XmlReader reader = new XmlReader();
XmlReader.Element elem = reader.parse(xml);
addRow(elem, 0, 0, false, customContainer, true);
String moduleName = "FloatUniform";
// todo: check this cast
ShaderNodeStage nodeStage = (ShaderNodeStage) TalosMain.Instance().getNodeStage();
NodeWidget node = nodeStage.createNode(moduleName, this.getX() - 200, this.getY());
UniformNode uniformNode = (UniformNode) node;
node.constructNode(nodeStage.getNodeListPopup().getModuleByName(moduleName));
Notifications.fireEvent(Notifications.obtainEvent(NodeCreatedEvent.class).set(node));
nodeStage.getNodeBoard().makeConnection(node, this, "out", uniformName);
((UniformNode) node).setValue(0.5f);
uniformNode.setUniformName(uniformName);
}
use of com.badlogic.gdx.utils.XmlReader in project TooCruelPixelDungeon by juh9870.
the class ShatteredNews method checkForArticles.
@Override
public void checkForArticles(boolean useMetered, boolean preferHTTPS, NewsResultCallback callback) {
if (!useMetered && !Game.platform.connectedToUnmeteredNetwork()) {
callback.onConnectionFailed();
return;
}
Net.HttpRequest httpGet = new Net.HttpRequest(Net.HttpMethods.GET);
if (preferHTTPS) {
httpGet.setUrl("https://shatteredpixel.com/feed_by_tag/SHPD_INGAME.xml");
} else {
httpGet.setUrl("http://shatteredpixel.com/feed_by_tag/SHPD_INGAME.xml");
}
Gdx.net.sendHttpRequest(httpGet, new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
ArrayList<NewsArticle> articles = new ArrayList<>();
XmlReader reader = new XmlReader();
XmlReader.Element xmlDoc = reader.parse(httpResponse.getResultAsStream());
SimpleDateFormat dateParser = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
for (XmlReader.Element xmlArticle : xmlDoc.getChildrenByName("entry")) {
NewsArticle article = new NewsArticle();
article.title = xmlArticle.get("title");
try {
article.date = dateParser.parse(xmlArticle.get("published"));
} catch (ParseException e) {
Game.reportException(e);
}
article.summary = xmlArticle.get("summary");
article.URL = xmlArticle.getChildByName("link").getAttribute("href");
if (!preferHTTPS) {
article.URL = article.URL.replace("https://", "http://");
}
Pattern versionCodeMatcher = Pattern.compile("v[0-9]+");
try {
Array<XmlReader.Element> properties = xmlArticle.getChildrenByName("category");
for (XmlReader.Element prop : properties) {
String propVal = prop.getAttribute("term");
if (propVal.startsWith("SHPD_ICON")) {
Matcher m = versionCodeMatcher.matcher(propVal);
if (m.find()) {
int iconGameVer = Integer.parseInt(m.group().substring(1));
if (iconGameVer <= Game.versionCode) {
article.icon = propVal.substring(propVal.indexOf(": ") + 2);
}
}
}
}
} catch (Exception e) {
article.icon = null;
}
articles.add(article);
}
callback.onArticlesFound(articles);
}
@Override
public void failed(Throwable t) {
callback.onConnectionFailed();
}
@Override
public void cancelled() {
callback.onConnectionFailed();
}
});
}
use of com.badlogic.gdx.utils.XmlReader in project visit-bayanaul by nextgenprog.
the class MainScreen method initLocs.
private void initLocs() {
XmlReader reader = new XmlReader();
XmlReader.Element root = reader.parse(Gdx.files.getFileHandle("locations.xml", Files.FileType.Internal));
for (int i = 0; i < root.getChildCount(); i++) {
XmlReader.Element child = root.getChild(i);
if (child.getName().equalsIgnoreCase("location")) {
try {
String name = child.getAttribute("name");
try {
String url = child.getAttribute("mapUrl");
try {
String image = child.getAttribute("image");
try {
String icon = child.getAttribute("icon");
// String icon = "pin";
try {
String content = child.getAttribute("content");
try {
float x = child.getFloatAttribute("x");
try {
float y = child.getFloatAttribute("y");
LocationData locData = new LocationData(name, new Texture(image), new Texture(icon + ".png"), content, new Vector2(x, y), url);
locations.add(locData);
} catch (Exception e) {
}
} catch (Exception e) {
}
} catch (Exception e) {
}
} catch (Exception e) {
}
} catch (Exception e) {
}
} catch (Exception e) {
}
} catch (Exception e) {
}
}
}
}
use of com.badlogic.gdx.utils.XmlReader in project gaiasky by langurmonkey.
the class AttitudeXmlParser method parseFile.
private static AttitudeIntervalBean parseFile(FileHandle fh, Duration duration, Instant activationTime) {
BaseAttitudeDataServer<?> result = null;
XmlReader reader = new XmlReader();
XmlReader.Element element = reader.parse(fh);
XmlReader.Element model = element.getChildByName("model");
/**
* MODEL ELEMENT *
*/
String name = model.get("name");
String className = model.get("classname").replace("gaia.cu9.ari.gaiaorbit", "gaiasky");
long startTimeNsSince2010 = (long) ((AstroUtils.getJulianDate(activationTime) - AstroUtils.JD_J2010) * Nature.D_TO_NS);
/**
* SCAN LAW ELEMENT *
*/
XmlReader.Element scanlaw = model.getChildByName("scanlaw");
String epochRef = scanlaw.getAttribute("epochref");
Instant refEpochDate = getDate(epochRef);
long refEpochJ2010 = (long) ((AstroUtils.getJulianDate(refEpochDate) - AstroUtils.JD_J2010) * Nature.D_TO_NS);
// Spin phase
XmlReader.Element spinphase = scanlaw.getChildByName("spinphase");
Quantity.Angle spinPhase = new Quantity.Angle(getDouble(spinphase, "value"), spinphase.get("unit"));
// Precession pahse
XmlReader.Element precessphase = scanlaw.getChildByName("precessphase");
Quantity.Angle precessionPhase = new Quantity.Angle(getDouble(precessphase, "value"), precessphase.get("unit"));
// Precession rate - always in rev/yr
XmlReader.Element precessrate = scanlaw.getChildByName("precessrate");
Double precessionRate = getDouble(precessrate, "value");
// Scan rate
XmlReader.Element scanrate = scanlaw.getChildByName("scanrate");
Quantity.Angle scanRate = new Quantity.Angle(getDouble(scanrate, "value"), scanrate.get("unit").split("_")[0]);
// Solar aspect angle
XmlReader.Element saa = scanlaw.getChildByName("solaraspectangle");
Quantity.Angle solarAspectAngle = new Quantity.Angle(getDouble(saa, "value"), saa.get("unit"));
if (className.contains("MslAttitudeDataServer")) {
// We need to pass the startTime, duration and MSL to the constructor
ModifiedScanningLaw msl = new ModifiedScanningLaw(startTimeNsSince2010);
msl.setRefEpoch(refEpochJ2010);
msl.setRefNu(precessionPhase.get(Quantity.Angle.AngleUnit.RAD));
msl.setRefOmega(spinPhase.get(Quantity.Angle.AngleUnit.RAD));
msl.setPrecRate(precessionRate);
msl.setScanRate(scanRate.get(Quantity.Angle.AngleUnit.ARCSEC));
msl.setRefXi(solarAspectAngle.get(Quantity.Angle.AngleUnit.RAD));
msl.setTypicalHighDensityArea();
msl.initialize();
MslAttitudeDataServer mslDatServ = new MslAttitudeDataServer(startTimeNsSince2010, duration, msl);
mslDatServ.initialize();
result = mslDatServ;
} else if (className.contains("Epsl")) {
Epsl.Mode mode = name.equals("EPSL_F") ? Epsl.Mode.FOLLOWING : Epsl.Mode.PRECEDING;
Epsl epsl = new Epsl(mode);
epsl.setRefTime((long) refEpochJ2010);
epsl.setNuRef(precessionPhase.get(Quantity.Angle.AngleUnit.RAD));
epsl.setOmegaRef(spinPhase.get(Quantity.Angle.AngleUnit.RAD));
epsl.setXiRef(solarAspectAngle.get(Quantity.Angle.AngleUnit.RAD));
epsl.setTargetScanRate(scanRate.get(Quantity.Angle.AngleUnit.ARCSEC));
epsl.setTargetPrecessionRate(precessionRate);
result = epsl;
}
return new AttitudeIntervalBean(name, new Date(activationTime.toEpochMilli()), result, fh.name());
}
Aggregations