repo_name
stringclasses
5 values
pr_number
int64
1.52k
15.5k
pr_title
stringlengths
8
143
pr_description
stringlengths
0
10.2k
author
stringlengths
3
18
date_created
unknown
date_merged
unknown
previous_commit
stringlengths
40
40
pr_commit
stringlengths
40
40
query
stringlengths
11
10.2k
filepath
stringlengths
6
220
before_content
stringlengths
0
597M
after_content
stringlengths
0
597M
label
int64
-1
1
libgdx/libgdx
7,311
Set GdxSetup source level to java 8
Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
obigu
"2023-12-28T13:24:30"
"2023-12-28T19:35:04"
7f682a7921a47f0da858508f6b6fd58426dd05d7
449619e48dc25ce335c4003830e409aa69f5f3f7
Set GdxSetup source level to java 8. Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
./extensions/gdx-setup/res/com/badlogic/gdx/setup/resources/core/build.gradle
sourceCompatibility = 1.7 [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' sourceSets.main.java.srcDirs = [ "src/" ] eclipse.project.name = appName + "-core"
sourceCompatibility = 1.8 [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' sourceSets.main.java.srcDirs = [ "src/" ] eclipse.project.name = appName + "-core"
1
libgdx/libgdx
7,311
Set GdxSetup source level to java 8
Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
obigu
"2023-12-28T13:24:30"
"2023-12-28T19:35:04"
7f682a7921a47f0da858508f6b6fd58426dd05d7
449619e48dc25ce335c4003830e409aa69f5f3f7
Set GdxSetup source level to java 8. Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
./extensions/gdx-setup/res/com/badlogic/gdx/setup/resources/html/build.gradle
gwt { gwtVersion='%GWT_VERSION%' // Should match the gwt version used for building the gwt backend maxHeapSize="1G" // Default 256m is not enough for gwt compiler. GWT is HUNGRY minHeapSize="1G" src = files(file("src/")) // Needs to be in front of "modules" below. modules '%PACKAGE%.GdxDefinition' devModules '%PACKAGE%.GdxDefinitionSuperdev' project.webAppDirName = 'webapp' compiler { strict = true; disableCastChecking = true; } } import org.docstr.gradle.plugins.gwt.GwtSuperDev import org.akhikhl.gretty.AppBeforeIntegrationTestTask gretty.httpPort = 8080 gretty.resourceBase = project.buildDir.path + "/gwt/draftOut" gretty.contextPath = "/" gretty.portPropertiesFileName = "TEMP_PORTS.properties" tasks.register('startHttpServer') { dependsOn draftCompileGwt doFirst { copy { from "webapp" into gretty.resourceBase } copy { from "war" into gretty.resourceBase } } } task beforeRun(type: AppBeforeIntegrationTestTask, dependsOn: startHttpServer) { // The next line allows ports to be reused instead of // needing a process to be manually terminated. file("build/TEMP_PORTS.properties").delete() // Somewhat of a hack; uses Gretty's support for wrapping a task in // a start and then stop of a Jetty server that serves files while // also running the SuperDev code server. integrationTestTask 'superDev' interactive false } tasks.register('superDev', GwtSuperDev) { dependsOn startHttpServer doFirst { gwt.modules = gwt.devModules } } tasks.register('dist') { dependsOn clean, compileGwt doLast { file("build/dist").mkdirs() copy { from "build/gwt/out" into "build/dist" } copy { from "webapp" into "build/dist" } copy { from "war" into "build/dist" } } } tasks.register('addSource') { doLast { sourceSets.main.compileClasspath += files(project(':core').sourceSets.main.allJava.srcDirs) } } tasks.compileGwt.dependsOn(addSource) tasks.draftCompileGwt.dependsOn(addSource) tasks.checkGwt.dependsOn(addSource) sourceCompatibility = 1.7 sourceSets.main.java.srcDirs = [ "src/" ] eclipse.project.name = appName + "-html"
gwt { gwtVersion='%GWT_VERSION%' // Should match the gwt version used for building the gwt backend maxHeapSize="1G" // Default 256m is not enough for gwt compiler. GWT is HUNGRY minHeapSize="1G" src = files(file("src/")) // Needs to be in front of "modules" below. modules '%PACKAGE%.GdxDefinition' devModules '%PACKAGE%.GdxDefinitionSuperdev' project.webAppDirName = 'webapp' compiler { strict = true; disableCastChecking = true; } } import org.docstr.gradle.plugins.gwt.GwtSuperDev import org.akhikhl.gretty.AppBeforeIntegrationTestTask gretty.httpPort = 8080 gretty.resourceBase = project.buildDir.path + "/gwt/draftOut" gretty.contextPath = "/" gretty.portPropertiesFileName = "TEMP_PORTS.properties" tasks.register('startHttpServer') { dependsOn draftCompileGwt doFirst { copy { from "webapp" into gretty.resourceBase } copy { from "war" into gretty.resourceBase } } } task beforeRun(type: AppBeforeIntegrationTestTask, dependsOn: startHttpServer) { // The next line allows ports to be reused instead of // needing a process to be manually terminated. file("build/TEMP_PORTS.properties").delete() // Somewhat of a hack; uses Gretty's support for wrapping a task in // a start and then stop of a Jetty server that serves files while // also running the SuperDev code server. integrationTestTask 'superDev' interactive false } tasks.register('superDev', GwtSuperDev) { dependsOn startHttpServer doFirst { gwt.modules = gwt.devModules } } tasks.register('dist') { dependsOn clean, compileGwt doLast { file("build/dist").mkdirs() copy { from "build/gwt/out" into "build/dist" } copy { from "webapp" into "build/dist" } copy { from "war" into "build/dist" } } } tasks.register('addSource') { doLast { sourceSets.main.compileClasspath += files(project(':core').sourceSets.main.allJava.srcDirs) } } tasks.compileGwt.dependsOn(addSource) tasks.draftCompileGwt.dependsOn(addSource) tasks.checkGwt.dependsOn(addSource) sourceCompatibility = 1.8 sourceSets.main.java.srcDirs = [ "src/" ] eclipse.project.name = appName + "-html"
1
libgdx/libgdx
7,311
Set GdxSetup source level to java 8
Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
obigu
"2023-12-28T13:24:30"
"2023-12-28T19:35:04"
7f682a7921a47f0da858508f6b6fd58426dd05d7
449619e48dc25ce335c4003830e409aa69f5f3f7
Set GdxSetup source level to java 8. Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
./extensions/gdx-setup/res/com/badlogic/gdx/setup/resources/ios/build.gradle
sourceSets.main.java.srcDirs = [ "src/" ] sourceCompatibility = '1.7' [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' ext { mainClassName = "%PACKAGE%.IOSLauncher" } launchIPhoneSimulator.dependsOn build launchIPadSimulator.dependsOn build launchIOSDevice.dependsOn build createIPA.dependsOn build robovm { archs = "arm64" } eclipse.project.name = appName + "-ios"
sourceSets.main.java.srcDirs = [ "src/" ] sourceCompatibility = '1.8' [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' ext { mainClassName = "%PACKAGE%.IOSLauncher" } launchIPhoneSimulator.dependsOn build launchIPadSimulator.dependsOn build launchIOSDevice.dependsOn build createIPA.dependsOn build robovm { archs = "arm64" } eclipse.project.name = appName + "-ios"
1
libgdx/libgdx
7,311
Set GdxSetup source level to java 8
Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
obigu
"2023-12-28T13:24:30"
"2023-12-28T19:35:04"
7f682a7921a47f0da858508f6b6fd58426dd05d7
449619e48dc25ce335c4003830e409aa69f5f3f7
Set GdxSetup source level to java 8. Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
./extensions/gdx-setup/res/com/badlogic/gdx/setup/resources/lwjgl2/build.gradle
sourceCompatibility = 1.7 sourceSets.main.java.srcDirs = [ "src/" ] sourceSets.main.resources.srcDirs = ["../%ASSET_PATH%"] project.ext.mainClassName = "%PACKAGE%.DesktopLauncher" project.ext.assetsDir = new File("../%ASSET_PATH%") tasks.register('run', JavaExec) { dependsOn classes mainClass = project.mainClassName classpath = sourceSets.main.runtimeClasspath standardInput = System.in workingDir = project.assetsDir ignoreExitValue = true } tasks.register('debug', JavaExec) { dependsOn classes mainClass = project.mainClassName classpath = sourceSets.main.runtimeClasspath standardInput = System.in workingDir = project.assetsDir ignoreExitValue = true debug = true } tasks.register('dist', Jar) { manifest { attributes 'Main-Class': project.mainClassName } dependsOn configurations.runtimeClasspath from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } with jar } dist.dependsOn classes eclipse.project.name = appName + "-legacy_desktop"
sourceCompatibility = 1.8 sourceSets.main.java.srcDirs = [ "src/" ] sourceSets.main.resources.srcDirs = ["../%ASSET_PATH%"] project.ext.mainClassName = "%PACKAGE%.DesktopLauncher" project.ext.assetsDir = new File("../%ASSET_PATH%") tasks.register('run', JavaExec) { dependsOn classes mainClass = project.mainClassName classpath = sourceSets.main.runtimeClasspath standardInput = System.in workingDir = project.assetsDir ignoreExitValue = true } tasks.register('debug', JavaExec) { dependsOn classes mainClass = project.mainClassName classpath = sourceSets.main.runtimeClasspath standardInput = System.in workingDir = project.assetsDir ignoreExitValue = true debug = true } tasks.register('dist', Jar) { manifest { attributes 'Main-Class': project.mainClassName } dependsOn configurations.runtimeClasspath from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } with jar } dist.dependsOn classes eclipse.project.name = appName + "-legacy_desktop"
1
libgdx/libgdx
7,311
Set GdxSetup source level to java 8
Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
obigu
"2023-12-28T13:24:30"
"2023-12-28T19:35:04"
7f682a7921a47f0da858508f6b6fd58426dd05d7
449619e48dc25ce335c4003830e409aa69f5f3f7
Set GdxSetup source level to java 8. Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
./extensions/gdx-setup/src/com/badlogic/gdx/setup/GdxSetupUI.java
/******************************************************************************* * Copyright 2014 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.setup; import static java.awt.GridBagConstraints.BOTH; import static java.awt.GridBagConstraints.CENTER; import static java.awt.GridBagConstraints.EAST; import static java.awt.GridBagConstraints.HORIZONTAL; import static java.awt.GridBagConstraints.NONE; import static java.awt.GridBagConstraints.NORTH; import static java.awt.GridBagConstraints.NORTHEAST; import static java.awt.GridBagConstraints.NORTHWEST; import static java.awt.GridBagConstraints.VERTICAL; import static java.awt.GridBagConstraints.WEST; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Desktop; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.FileDialog; import java.awt.Graphics; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; import java.awt.Insets; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.imageio.ImageIO; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JEditorPane; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.border.Border; import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import com.badlogic.gdx.setup.DependencyBank.ProjectDependency; import com.badlogic.gdx.setup.DependencyBank.ProjectType; import com.badlogic.gdx.setup.Executor.CharCallback; @SuppressWarnings("serial") public class GdxSetupUI extends JFrame { // DependencyBank dependencyBank; ProjectBuilder builder; List<ProjectType> modules = new ArrayList<ProjectType>(); List<Dependency> dependencies = new ArrayList<Dependency>(); UI ui = new UI(); static Point point = new Point(); static SetupPreferences prefs = new SetupPreferences(); public GdxSetupUI () { setTitle("libGDX Project Generator"); setLayout(new BorderLayout()); add(ui, BorderLayout.CENTER); setSize(620, 720); setLocationRelativeTo(null); setUndecorated(true); pack(); setDefaultCloseOperation(EXIT_ON_CLOSE); addMouseListener(new MouseAdapter() { public void mousePressed (MouseEvent e) { point.x = e.getX(); point.y = e.getY(); } }); addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged (MouseEvent e) { Point p = getLocation(); setLocation(p.x + e.getX() - point.x, p.y + e.getY() - point.y); } }); setVisible(true); builder = new ProjectBuilder(new DependencyBank()); modules.add(ProjectType.CORE); dependencies.add(builder.bank.getDependency(ProjectDependency.GDX)); } void generate () { final String name = ui.form.nameText.getText().trim(); if (name.length() == 0) { JOptionPane.showMessageDialog(this, "Please enter a project name."); return; } final String pack = ui.form.packageText.getText().trim(); if (pack.length() == 0) { JOptionPane.showMessageDialog(this, "Please enter a package name."); return; } Pattern pattern = Pattern.compile("[a-z][a-z0-9_]*(\\.[a-z0-9_]+)+[0-9a-z_]"); Matcher matcher = pattern.matcher(pack); boolean matches = matcher.matches(); if (!matches) { JOptionPane.showMessageDialog(this, "Invalid package name"); return; } final String clazz = ui.form.gameClassText.getText().trim(); if (clazz.length() == 0) { JOptionPane.showMessageDialog(this, "Please enter a game class name."); return; } final Language languageEnum = ui.settings.kotlinBox.isSelected() ? Language.KOTLIN : Language.JAVA; final String destination = ui.form.destinationText.getText().trim(); if (destination.length() == 0) { JOptionPane.showMessageDialog(this, "Please enter a destination directory."); return; } final String assetPath; if (ui.settings.oldAssetsBox.isSelected()) { assetPath = modules.contains(ProjectType.ANDROID) ? "android/assets" : "core/assets"; } else { assetPath = GdxSetup.DEFAULT_ASSET_PATH; } final String sdkLocation = ui.form.sdkLocationText.getText().trim(); if (sdkLocation.length() == 0 && modules.contains(ProjectType.ANDROID)) { JOptionPane.showMessageDialog(this, "Please enter your Android SDK's path"); return; } if (!GdxSetup.isSdkLocationValid(sdkLocation) && modules.contains(ProjectType.ANDROID)) { JOptionPane.showMessageDialog(this, "Your Android SDK path doesn't contain an SDK! Please install the Android SDK, including all platforms and build tools!"); return; } if (modules.contains(ProjectType.HTML) && !languageEnum.gwtSupported) { JOptionPane.showMessageDialog(this, "HTML sub-projects are not supported by the selected programming language."); ui.form.gwtCheckBox.setSelected(false); modules.remove(ProjectType.HTML); } if (modules.contains(ProjectType.ANDROID)) { if (!GdxSetup.isSdkUpToDate(sdkLocation)) { File sdkLocationFile = new File(sdkLocation); try { // give them a poke in the right direction if (System.getProperty("os.name").contains("Windows")) { String replaced = sdkLocation.replace("\\", "\\\\"); Runtime.getRuntime().exec("\"" + replaced + "\\SDK Manager.exe\""); } else { File sdkManager = new File(sdkLocation, "tools/android"); Runtime.getRuntime().exec(new String[] {sdkManager.getAbsolutePath(), "sdk"}); } } catch (IOException e) { e.printStackTrace(); } return; } } if (!GdxSetup.isEmptyDirectory(destination)) { int value = JOptionPane.showConfirmDialog(this, "The destination is not empty, do you want to overwrite?", "Warning!", JOptionPane.YES_NO_OPTION); if (value != 0) { return; } } List<String> incompatList = builder.buildProject(modules, dependencies); if (incompatList.size() == 0) { try { builder.build(languageEnum); } catch (IOException e) { e.printStackTrace(); } } else { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); for (String subIncompat : incompatList) { JLabel label = new JLabel(subIncompat); label.setAlignmentX(Component.CENTER_ALIGNMENT); panel.add(label); } JLabel infoLabel = new JLabel( "<html><br><br>The project can be generated, but you wont be able to use these extensions in the respective sub modules<br>Please see the link to learn about extensions</html>"); infoLabel.setAlignmentX(Component.CENTER_ALIGNMENT); panel.add(infoLabel); JEditorPane pane = new JEditorPane("text/html", "<a href=\"https://libgdx.com/wiki/articles/dependency-management-with-gradle\">Dependency Management</a>"); pane.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate (HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) try { Desktop.getDesktop().browse(new URI(e.getURL().toString())); } catch (IOException e1) { e1.printStackTrace(); } catch (URISyntaxException e1) { e1.printStackTrace(); } } }); pane.setEditable(false); pane.setOpaque(false); pane.setAlignmentX(Component.CENTER_ALIGNMENT); panel.add(pane); Object[] options = {"Yes, build it!", "No, I'll change my extensions"}; int value = JOptionPane.showOptionDialog(null, panel, "Extension Incompatibilities", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, null); if (value != 0) { return; } else { try { builder.build(languageEnum); } catch (IOException e) { e.printStackTrace(); } } } ui.generateButton.setEnabled(false); new Thread() { public void run () { log("Generating app in " + destination); new GdxSetup().build(builder, destination, name, pack, clazz, languageEnum, assetPath, sdkLocation, new CharCallback() { @Override public void character (char c) { log(c); } }, ui.settings.getGradleArgs()); log("Done!"); log("To import in Eclipse: File -> Import -> Gradle -> Existing Gradle Project"); log("To import to Intellij IDEA: File -> Open -> build.gradle"); log("To import to NetBeans: File -> Open Project..."); SwingUtilities.invokeLater(new Runnable() { @Override public void run () { ui.generateButton.setEnabled(true); } }); } }.start(); } void log (final char c) { EventQueue.invokeLater(new Runnable() { public void run () { ui.textArea.append("" + c); ui.textArea.setCaretPosition(ui.textArea.getDocument().getLength()); } }); } void log (final String text) { EventQueue.invokeLater(new Runnable() { public void run () { ui.textArea.append(text + "\n"); ui.textArea.setCaretPosition(ui.textArea.getDocument().getLength()); } }); } class UI extends JPanel { Form form = new Form(); SettingsDialog settings; SetupButton generateButton = new SetupButton("Generate"); SetupButton advancedButton = new SetupButton("Advanced"); JPanel buttonPanel = new JPanel(); JTextArea textArea = new JTextArea(8, 40); JScrollPane scrollPane = new JScrollPane(textArea); JPanel title = new JPanel(); JPanel topBar = new JPanel(); JLabel windowLabel = new JLabel(" libGDX Project Generator (" + DependencyBank.libgdxVersion + ")"); JButton exit; JButton minimize; JLabel logo; { setBackground(new Color(36, 36, 36)); topBar.setBackground(new Color(64, 67, 69)); title.setBackground(new Color(94, 97, 99)); windowLabel.setForeground(new Color(255, 255, 255)); form.setBackground(new Color(36, 36, 36)); for (int i = 0; i < form.getComponents().length; i++) { Component component = form.getComponents()[i]; if (component instanceof JTextField) { component.setBackground(new Color(46, 46, 46)); component.setForeground(new Color(255, 255, 255)); Border line = BorderFactory.createEtchedBorder(); Border pad = new EmptyBorder(0, 5, 0, 0); CompoundBorder compoundBorder = new CompoundBorder(line, pad); ((JComponent)component).setBorder(compoundBorder); continue; } } buttonPanel.setBackground(new Color(46, 46, 46)); textArea.setBackground(new Color(46, 46, 46)); textArea.setForeground(new Color(255, 255, 255)); Border line = BorderFactory.createLineBorder(Color.DARK_GRAY); scrollPane.setBorder(line); try { BufferedImage exitimg = ImageIO.read(GdxSetupUI.class.getResourceAsStream("/com/badlogic/gdx/setup/data/exitup.png")); BufferedImage minimg = ImageIO .read(GdxSetupUI.class.getResourceAsStream("/com/badlogic/gdx/setup/data/minimizeup.png")); BufferedImage exitimgdown = ImageIO .read(GdxSetupUI.class.getResourceAsStream("/com/badlogic/gdx/setup/data/exitdown.png")); BufferedImage minimgdown = ImageIO .read(GdxSetupUI.class.getResourceAsStream("/com/badlogic/gdx/setup/data/minimizedown.png")); BufferedImage exithover = ImageIO .read(GdxSetupUI.class.getResourceAsStream("/com/badlogic/gdx/setup/data/exithover.png")); BufferedImage minimghover = ImageIO .read(GdxSetupUI.class.getResourceAsStream("/com/badlogic/gdx/setup/data/minimizehover.png")); BufferedImage img = ImageIO.read(GdxSetupUI.class.getResourceAsStream("/com/badlogic/gdx/setup/data/logo.png")); ImageIcon icon = new ImageIcon(img); ImageIcon exitIcon = new ImageIcon(exitimg); ImageIcon minIcon = new ImageIcon(minimg); ImageIcon exitIconDown = new ImageIcon(exitimgdown); ImageIcon minIconDown = new ImageIcon(minimgdown); ImageIcon exitIconHover = new ImageIcon(exithover); ImageIcon minIconHover = new ImageIcon(minimghover); logo = new JLabel(icon); exit = new JButton(exitIcon); minimize = new JButton(minIcon); exit.setOpaque(false); exit.setContentAreaFilled(false); exit.setFocusPainted(false); exit.setBorderPainted(false); exit.setPressedIcon(exitIconDown); exit.setRolloverIcon(exitIconHover); minimize.setOpaque(false); minimize.setContentAreaFilled(false); minimize.setFocusPainted(false); minimize.setBorderPainted(false); minimize.setPressedIcon(minIconDown); minimize.setRolloverIcon(minIconHover); } catch (IOException e) { e.printStackTrace(); } buttonPanel.add(advancedButton); buttonPanel.add(generateButton); textArea.setEditable(false); textArea.setLineWrap(true); uiLayout(); uiEvents(); settings = new SettingsDialog(form.gwtCheckBox); titleEvents(minimize, exit); } private void titleEvents (JButton minimize, JButton exit) { minimize.addActionListener(new ActionListener() { @Override public void actionPerformed (ActionEvent e) { setState(ICONIFIED); } }); exit.addActionListener(new ActionListener() { @Override public void actionPerformed (ActionEvent e) { dispose(); System.exit(0); } }); } private void uiLayout () { title.setLayout(new GridLayout(1, 2)); minimize.setPreferredSize(new Dimension(50, 26)); exit.setPreferredSize(new Dimension(50, 26)); title.add(minimize); title.add(exit); topBar.setLayout(new GridLayout(1, 1)); topBar.add(windowLabel, new GridBagConstraints(0, 0, 0, 0, 0, 0, NORTHWEST, VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); setLayout(new GridBagLayout()); add(topBar, new GridBagConstraints(0, 0, 0, 0, 0, 0, NORTH, HORIZONTAL, new Insets(0, 0, 0, 100), 0, 10)); add(title, new GridBagConstraints(0, 0, 0, 0, 0, 0, NORTHEAST, NONE, new Insets(0, 0, 0, 0), 0, 0)); add(logo, new GridBagConstraints(0, 0, 1, 1, 1, 0, CENTER, HORIZONTAL, new Insets(40, 6, 6, 6), 0, 0)); add(form, new GridBagConstraints(0, 1, 1, 1, 1, 0, CENTER, HORIZONTAL, new Insets(6, 6, 0, 6), 0, 0)); add(buttonPanel, new GridBagConstraints(0, 2, 1, 1, 0, 0, CENTER, NONE, new Insets(0, 0, 0, 0), 0, 0)); add(scrollPane, new GridBagConstraints(0, 3, 1, 1, 1, 1, CENTER, BOTH, new Insets(6, 6, 6, 6), 0, 0)); } private void uiEvents () { advancedButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e) { settings.showDialog(form, form.gwtCheckBox); } }); generateButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e) { generate(); } }); } } class Form extends JPanel { ExternalExtensionsDialog externalExtensionsDialog = new ExternalExtensionsDialog(dependencies); JLabel nameLabel = new JLabel("Project name:"); JTextField nameText = new JTextField("My GDX Game"); JLabel packageLabel = new JLabel("Package name:"); JTextField packageText = new JTextField("com.mygdx.game"); JLabel gameClassLabel = new JLabel("Game class:"); JTextField gameClassText = new JTextField("MyGdxGame"); JLabel destinationLabel = new JLabel("Output folder:"); JTextField destinationText = new JTextField(new File("test").getAbsolutePath()); SetupButton destinationButton = new SetupButton("Browse"); JLabel sdkLocationLabel = new JLabel("Android SDK"); JTextField sdkLocationText = new JTextField( System.getProperty("os.name").contains("Windows") ? "C:\\Path\\To\\Your\\Sdk" : "/path/to/your/sdk"); SetupButton sdkLocationButton = new SetupButton("Browse"); JPanel subProjectsPanel = new JPanel(new GridLayout()); JLabel projectsLabel = new JLabel("Supported Platforms"); JLabel extensionsLabel = new JLabel("Official Extensions"); List<JPanel> extensionsPanels = new ArrayList<JPanel>(); SetupButton showMoreExtensionsButton = new SetupButton("Show Third-Party Extensions"); SetupCheckBox gwtCheckBox; { uiLayout(); uiEvents(); uiStyle(); } private void uiStyle () { nameText.setCaretColor(Color.WHITE); packageText.setCaretColor(Color.WHITE); gameClassText.setCaretColor(Color.WHITE); destinationText.setCaretColor(Color.WHITE); sdkLocationText.setCaretColor(Color.WHITE); nameLabel.setForeground(Color.WHITE); packageLabel.setForeground(Color.WHITE); gameClassLabel.setForeground(Color.WHITE); destinationLabel.setForeground(Color.WHITE); sdkLocationLabel.setForeground(Color.WHITE); sdkLocationText.setDisabledTextColor(Color.GRAY); projectsLabel.setForeground(new Color(235, 70, 61)); extensionsLabel.setForeground(new Color(235, 70, 61)); subProjectsPanel.setOpaque(true); subProjectsPanel.setBackground(new Color(46, 46, 46)); for (JPanel extensionPanel : extensionsPanels) { extensionPanel.setOpaque(true); extensionPanel.setBackground(new Color(46, 46, 46)); } nameLabel.setToolTipText("The name of the application used in gradle"); packageLabel.setToolTipText("The package name of the application"); gameClassLabel.setToolTipText("The name of the main class implementing ApplicationListener"); destinationLabel.setToolTipText("The root directory of the project; will be created if it does not exist"); sdkLocationLabel.setToolTipText("The location of your Android SDK"); } private void uiLayout () { setLayout(new GridBagLayout()); add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, EAST, NONE, new Insets(0, 0, 6, 6), 0, 0)); add(nameText, new GridBagConstraints(1, 0, 2, 1, 1, 0, CENTER, HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0)); add(packageLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, EAST, NONE, new Insets(0, 0, 6, 6), 0, 0)); add(packageText, new GridBagConstraints(1, 1, 2, 1, 1, 0, CENTER, HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0)); add(gameClassLabel, new GridBagConstraints(0, 2, 1, 1, 0, 0, EAST, NONE, new Insets(0, 0, 6, 6), 0, 0)); add(gameClassText, new GridBagConstraints(1, 2, 2, 1, 1, 0, CENTER, HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0)); add(destinationLabel, new GridBagConstraints(0, 3, 1, 1, 0, 0, EAST, NONE, new Insets(0, 0, 0, 6), 0, 0)); add(destinationText, new GridBagConstraints(1, 3, 1, 1, 1, 0, CENTER, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); add(destinationButton, new GridBagConstraints(2, 3, 1, 1, 0, 0, CENTER, NONE, new Insets(0, 6, 0, 0), 0, 0)); if (System.getenv("ANDROID_HOME") != null) { sdkLocationText.setText(System.getenv("ANDROID_HOME")); } if (prefs.getString("ANDROID_HOME", null) != null) { sdkLocationText.setText(prefs.getString("ANDROID_HOME")); } add(sdkLocationLabel, new GridBagConstraints(0, 4, 1, 1, 0, 0, EAST, NONE, new Insets(0, 0, 0, 6), 0, 0)); add(sdkLocationText, new GridBagConstraints(1, 4, 1, 1, 1, 0, CENTER, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); add(sdkLocationButton, new GridBagConstraints(2, 4, 1, 1, 0, 0, CENTER, NONE, new Insets(0, 6, 0, 0), 0, 0)); for (final ProjectType projectType : ProjectType.values()) { if (projectType.equals(ProjectType.CORE)) { continue; } if (projectType.equals(ProjectType.LWJGL2)) { continue; // LWJGL 2 projects can only be built via command line } SetupCheckBox checkBox = new SetupCheckBox(projectType.getDisplayName()); if (projectType == ProjectType.HTML) { gwtCheckBox = checkBox; } modules.add(projectType); checkBox.setSelected(true); subProjectsPanel.add(checkBox); checkBox.addItemListener(new ItemListener() { @Override public void itemStateChanged (ItemEvent e) { SetupCheckBox box = (SetupCheckBox)e.getSource(); if (projectType.equals(ProjectType.ANDROID)) { sdkLocationText.setEnabled(box.isSelected()); } if (box.isSelected()) { modules.add(projectType); } else { if (modules.contains(projectType)) { modules.remove(projectType); } } } }); } add(projectsLabel, new GridBagConstraints(0, 6, 1, 1, 0, 0, WEST, WEST, new Insets(20, 0, 0, 0), 0, 0)); add(subProjectsPanel, new GridBagConstraints(0, 7, 3, 1, 0, 0, CENTER, HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0)); int depCounter = 0; for (int row = 0; row <= (ProjectDependency.values().length / 5); row++) { JPanel extensionPanel = new JPanel(new GridLayout(1, 5)); while (depCounter < ProjectDependency.values().length) { if (ProjectDependency.values()[depCounter] != null) { final ProjectDependency projDep = ProjectDependency.values()[depCounter]; if (projDep.equals(ProjectDependency.GDX)) { depCounter++; continue; } SetupCheckBox depCheckBox = new SetupCheckBox( projDep.name().substring(0, 1) + projDep.name().substring(1, projDep.name().length()).toLowerCase()); depCheckBox.setToolTipText(projDep.getDescription()); extensionPanel.add(depCheckBox); depCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged (ItemEvent e) { SetupCheckBox box = (SetupCheckBox)e.getSource(); if (box.isSelected()) { dependencies.add(builder.bank.getDependency(projDep)); } else { if (dependencies.contains(builder.bank.getDependency(projDep))) { dependencies.remove(builder.bank.getDependency(projDep)); } } } }); if (depCounter % 5 == 0) { depCounter++; break; } depCounter++; } } for (int left = ((depCounter - 1) % 5); left > 1; left--) { extensionPanel.add(Box.createHorizontalBox()); } extensionsPanels.add(extensionPanel); } add(extensionsLabel, new GridBagConstraints(0, 8, 1, 1, 0, 0, WEST, WEST, new Insets(10, 0, 0, 0), 0, 0)); int rowCounter = 9; for (JPanel extensionsPanel : extensionsPanels) { add(extensionsPanel, new GridBagConstraints(0, rowCounter, 3, 1, 0, 0, CENTER, HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0)); rowCounter++; } add(showMoreExtensionsButton, new GridBagConstraints(0, 12, 0, 1, 0, 0, CENTER, WEST, new Insets(10, 0, 10, 0), 0, 0)); } File getDirectory (String dialogTitle) { if (System.getProperty("os.name").contains("Mac")) { System.setProperty("apple.awt.fileDialogForDirectories", "true"); FileDialog dialog = new FileDialog(GdxSetupUI.this, dialogTitle, FileDialog.LOAD); dialog.setVisible(true); String name = dialog.getFile(); String dir = dialog.getDirectory(); if (name == null || dir == null) return null; return new File(dialog.getDirectory(), dialog.getFile()); } else { JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogTitle(dialogTitle); int result = chooser.showOpenDialog(GdxSetupUI.this); if (result == JFileChooser.APPROVE_OPTION) { File dir = chooser.getSelectedFile(); if (dir == null) return null; if (dir.getAbsolutePath().trim().length() == 0) return null; return dir; } else { return null; } } } private void uiEvents () { destinationButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e) { File path = getDirectory("Choose destination"); if (path != null) { destinationText.setText(path.getAbsolutePath()); } } }); sdkLocationButton.addActionListener(new ActionListener() { @Override public void actionPerformed (ActionEvent e) { File path = getDirectory("Choose Android SDK"); if (path != null) { sdkLocationText.setText(path.getAbsolutePath()); prefs.putString("ANDROID_HOME", path.getAbsolutePath()); prefs.flush(); } } }); showMoreExtensionsButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e) { externalExtensionsDialog.showDialog(Form.this); } }); } } public static class SetupCheckBox extends JCheckBox { static Icon icon; static Icon iconOver; static Icon iconPressed; static Icon iconPressedSelected; static Icon iconSelected; static Icon iconOverSelected; static { try { BufferedImage iconImg = getCheckboxImage("checkbox"); BufferedImage iconOverImg = getCheckboxImage("checkboxover"); BufferedImage iconPressedImg = getCheckboxImage("checkboxpressed"); BufferedImage iconPressedSelectedImg = getCheckboxImage("checkboxpressedselected"); BufferedImage iconSelectedImg = getCheckboxImage("checkboxselected"); BufferedImage iconOverSelectedImg = getCheckboxImage("checkboxoverselected"); icon = new ImageIcon(iconImg); iconOver = new ImageIcon(iconOverImg); iconPressed = new ImageIcon(iconPressedImg); iconPressedSelected = new ImageIcon(iconPressedSelectedImg); iconSelected = new ImageIcon(iconSelectedImg); iconOverSelected = new ImageIcon(iconOverSelectedImg); } catch (IOException e) { e.printStackTrace(); } } private static BufferedImage getCheckboxImage (String imageName) throws IOException { return ImageIO.read(GdxSetupUI.class.getResourceAsStream("/com/badlogic/gdx/setup/data/" + imageName + ".png")); } SetupCheckBox () { super(); initUI(); } SetupCheckBox (String selectName) { super(selectName); initUI(); } private void initUI () { setOpaque(false); setBackground(new Color(0, 0, 0)); setForeground(new Color(255, 255, 255)); setFocusPainted(false); setIcon(icon); setRolloverIcon(iconOver); setPressedIcon(iconPressed); setSelectedIcon(iconSelected); setRolloverSelectedIcon(iconOverSelected); } public Icon getPressedIcon () { // checkbox is missing 'pressed selected' icon, this allows us to add it if (isSelected()) return iconPressedSelected; else return super.getPressedIcon(); } } public static class SetupButton extends JButton { private Color textColor = Color.WHITE; private Color backgroundColor = new Color(18, 18, 18); private Color overColor = new Color(120, 20, 20); private Color pressedColor = new Color(240, 40, 40); SetupButton (String buttonTag) { super(buttonTag); setBackground(backgroundColor); setForeground(textColor); setContentAreaFilled(false); setFocusPainted(false); Border line = BorderFactory.createLineBorder(new Color(80, 80, 80)); Border empty = new EmptyBorder(4, 4, 4, 4); CompoundBorder border = new CompoundBorder(line, empty); setBorder(border); } @Override protected void paintComponent (Graphics g) { if (getModel().isPressed()) { g.setColor(pressedColor); } else if (getModel().isRollover()) { g.setColor(overColor); } else { g.setColor(getBackground()); } g.fillRect(0, 0, getWidth(), getHeight()); super.paintComponent(g); } } public static void main (String[] args) throws Exception { SwingUtilities.invokeLater(new Runnable() { @Override public void run () { new GdxSetupUI(); } }); } }
/******************************************************************************* * Copyright 2014 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.setup; import static java.awt.GridBagConstraints.BOTH; import static java.awt.GridBagConstraints.CENTER; import static java.awt.GridBagConstraints.EAST; import static java.awt.GridBagConstraints.HORIZONTAL; import static java.awt.GridBagConstraints.NONE; import static java.awt.GridBagConstraints.NORTH; import static java.awt.GridBagConstraints.NORTHEAST; import static java.awt.GridBagConstraints.NORTHWEST; import static java.awt.GridBagConstraints.VERTICAL; import static java.awt.GridBagConstraints.WEST; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Desktop; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.FileDialog; import java.awt.Graphics; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; import java.awt.Insets; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.imageio.ImageIO; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JEditorPane; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.border.Border; import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import com.badlogic.gdx.setup.DependencyBank.ProjectDependency; import com.badlogic.gdx.setup.DependencyBank.ProjectType; import com.badlogic.gdx.setup.Executor.CharCallback; @SuppressWarnings("serial") public class GdxSetupUI extends JFrame { // DependencyBank dependencyBank; ProjectBuilder builder; List<ProjectType> modules = new ArrayList<ProjectType>(); List<Dependency> dependencies = new ArrayList<Dependency>(); UI ui = new UI(); static Point point = new Point(); static SetupPreferences prefs = new SetupPreferences(); public GdxSetupUI () { setTitle("libGDX Project Generator"); setLayout(new BorderLayout()); add(ui, BorderLayout.CENTER); setSize(620, 720); setLocationRelativeTo(null); setUndecorated(true); pack(); setDefaultCloseOperation(EXIT_ON_CLOSE); addMouseListener(new MouseAdapter() { public void mousePressed (MouseEvent e) { point.x = e.getX(); point.y = e.getY(); } }); addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged (MouseEvent e) { Point p = getLocation(); setLocation(p.x + e.getX() - point.x, p.y + e.getY() - point.y); } }); setVisible(true); builder = new ProjectBuilder(new DependencyBank()); modules.add(ProjectType.CORE); dependencies.add(builder.bank.getDependency(ProjectDependency.GDX)); } void generate () { final String name = ui.form.nameText.getText().trim(); if (name.length() == 0) { JOptionPane.showMessageDialog(this, "Please enter a project name."); return; } final String pack = ui.form.packageText.getText().trim(); if (pack.length() == 0) { JOptionPane.showMessageDialog(this, "Please enter a package name."); return; } Pattern pattern = Pattern.compile("[a-z][a-z0-9_]*(\\.[a-z0-9_]+)+[0-9a-z_]"); Matcher matcher = pattern.matcher(pack); boolean matches = matcher.matches(); if (!matches) { JOptionPane.showMessageDialog(this, "Invalid package name"); return; } final String clazz = ui.form.gameClassText.getText().trim(); if (clazz.length() == 0) { JOptionPane.showMessageDialog(this, "Please enter a game class name."); return; } final Language languageEnum = ui.settings.kotlinBox.isSelected() ? Language.KOTLIN : Language.JAVA; final String destination = ui.form.destinationText.getText().trim(); if (destination.length() == 0) { JOptionPane.showMessageDialog(this, "Please enter a destination directory."); return; } final String assetPath; if (ui.settings.oldAssetsBox.isSelected()) { assetPath = modules.contains(ProjectType.ANDROID) ? "android/assets" : "core/assets"; } else { assetPath = GdxSetup.DEFAULT_ASSET_PATH; } final String sdkLocation = ui.form.sdkLocationText.getText().trim(); if (sdkLocation.length() == 0 && modules.contains(ProjectType.ANDROID)) { JOptionPane.showMessageDialog(this, "Please enter your Android SDK's path"); return; } if (!GdxSetup.isSdkLocationValid(sdkLocation) && modules.contains(ProjectType.ANDROID)) { JOptionPane.showMessageDialog(this, "Your Android SDK path doesn't contain an SDK! Please install the Android SDK, including all platforms and build tools!"); return; } if (modules.contains(ProjectType.HTML) && !languageEnum.gwtSupported) { JOptionPane.showMessageDialog(this, "HTML sub-projects are not supported by the selected programming language."); ui.form.gwtCheckBox.setSelected(false); modules.remove(ProjectType.HTML); } if (modules.contains(ProjectType.IOS)) { JOptionPane.showMessageDialog(this, "WARNING. iOS has limited support to Java 8 languages features and APIs."); } if (modules.contains(ProjectType.ANDROID)) { if (!GdxSetup.isSdkUpToDate(sdkLocation)) { File sdkLocationFile = new File(sdkLocation); try { // give them a poke in the right direction if (System.getProperty("os.name").contains("Windows")) { String replaced = sdkLocation.replace("\\", "\\\\"); Runtime.getRuntime().exec("\"" + replaced + "\\SDK Manager.exe\""); } else { File sdkManager = new File(sdkLocation, "tools/android"); Runtime.getRuntime().exec(new String[] {sdkManager.getAbsolutePath(), "sdk"}); } } catch (IOException e) { e.printStackTrace(); } return; } } if (!GdxSetup.isEmptyDirectory(destination)) { int value = JOptionPane.showConfirmDialog(this, "The destination is not empty, do you want to overwrite?", "Warning!", JOptionPane.YES_NO_OPTION); if (value != 0) { return; } } List<String> incompatList = builder.buildProject(modules, dependencies); if (incompatList.size() == 0) { try { builder.build(languageEnum); } catch (IOException e) { e.printStackTrace(); } } else { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); for (String subIncompat : incompatList) { JLabel label = new JLabel(subIncompat); label.setAlignmentX(Component.CENTER_ALIGNMENT); panel.add(label); } JLabel infoLabel = new JLabel( "<html><br><br>The project can be generated, but you wont be able to use these extensions in the respective sub modules<br>Please see the link to learn about extensions</html>"); infoLabel.setAlignmentX(Component.CENTER_ALIGNMENT); panel.add(infoLabel); JEditorPane pane = new JEditorPane("text/html", "<a href=\"https://libgdx.com/wiki/articles/dependency-management-with-gradle\">Dependency Management</a>"); pane.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate (HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) try { Desktop.getDesktop().browse(new URI(e.getURL().toString())); } catch (IOException e1) { e1.printStackTrace(); } catch (URISyntaxException e1) { e1.printStackTrace(); } } }); pane.setEditable(false); pane.setOpaque(false); pane.setAlignmentX(Component.CENTER_ALIGNMENT); panel.add(pane); Object[] options = {"Yes, build it!", "No, I'll change my extensions"}; int value = JOptionPane.showOptionDialog(null, panel, "Extension Incompatibilities", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, null); if (value != 0) { return; } else { try { builder.build(languageEnum); } catch (IOException e) { e.printStackTrace(); } } } ui.generateButton.setEnabled(false); new Thread() { public void run () { log("Generating app in " + destination); new GdxSetup().build(builder, destination, name, pack, clazz, languageEnum, assetPath, sdkLocation, new CharCallback() { @Override public void character (char c) { log(c); } }, ui.settings.getGradleArgs()); log("Done!"); log("To import in Eclipse: File -> Import -> Gradle -> Existing Gradle Project"); log("To import to Intellij IDEA: File -> Open -> build.gradle"); log("To import to NetBeans: File -> Open Project..."); SwingUtilities.invokeLater(new Runnable() { @Override public void run () { ui.generateButton.setEnabled(true); } }); } }.start(); } void log (final char c) { EventQueue.invokeLater(new Runnable() { public void run () { ui.textArea.append("" + c); ui.textArea.setCaretPosition(ui.textArea.getDocument().getLength()); } }); } void log (final String text) { EventQueue.invokeLater(new Runnable() { public void run () { ui.textArea.append(text + "\n"); ui.textArea.setCaretPosition(ui.textArea.getDocument().getLength()); } }); } class UI extends JPanel { Form form = new Form(); SettingsDialog settings; SetupButton generateButton = new SetupButton("Generate"); SetupButton advancedButton = new SetupButton("Advanced"); JPanel buttonPanel = new JPanel(); JTextArea textArea = new JTextArea(8, 40); JScrollPane scrollPane = new JScrollPane(textArea); JPanel title = new JPanel(); JPanel topBar = new JPanel(); JLabel windowLabel = new JLabel(" libGDX Project Generator (" + DependencyBank.libgdxVersion + ")"); JButton exit; JButton minimize; JLabel logo; { setBackground(new Color(36, 36, 36)); topBar.setBackground(new Color(64, 67, 69)); title.setBackground(new Color(94, 97, 99)); windowLabel.setForeground(new Color(255, 255, 255)); form.setBackground(new Color(36, 36, 36)); for (int i = 0; i < form.getComponents().length; i++) { Component component = form.getComponents()[i]; if (component instanceof JTextField) { component.setBackground(new Color(46, 46, 46)); component.setForeground(new Color(255, 255, 255)); Border line = BorderFactory.createEtchedBorder(); Border pad = new EmptyBorder(0, 5, 0, 0); CompoundBorder compoundBorder = new CompoundBorder(line, pad); ((JComponent)component).setBorder(compoundBorder); continue; } } buttonPanel.setBackground(new Color(46, 46, 46)); textArea.setBackground(new Color(46, 46, 46)); textArea.setForeground(new Color(255, 255, 255)); Border line = BorderFactory.createLineBorder(Color.DARK_GRAY); scrollPane.setBorder(line); try { BufferedImage exitimg = ImageIO.read(GdxSetupUI.class.getResourceAsStream("/com/badlogic/gdx/setup/data/exitup.png")); BufferedImage minimg = ImageIO .read(GdxSetupUI.class.getResourceAsStream("/com/badlogic/gdx/setup/data/minimizeup.png")); BufferedImage exitimgdown = ImageIO .read(GdxSetupUI.class.getResourceAsStream("/com/badlogic/gdx/setup/data/exitdown.png")); BufferedImage minimgdown = ImageIO .read(GdxSetupUI.class.getResourceAsStream("/com/badlogic/gdx/setup/data/minimizedown.png")); BufferedImage exithover = ImageIO .read(GdxSetupUI.class.getResourceAsStream("/com/badlogic/gdx/setup/data/exithover.png")); BufferedImage minimghover = ImageIO .read(GdxSetupUI.class.getResourceAsStream("/com/badlogic/gdx/setup/data/minimizehover.png")); BufferedImage img = ImageIO.read(GdxSetupUI.class.getResourceAsStream("/com/badlogic/gdx/setup/data/logo.png")); ImageIcon icon = new ImageIcon(img); ImageIcon exitIcon = new ImageIcon(exitimg); ImageIcon minIcon = new ImageIcon(minimg); ImageIcon exitIconDown = new ImageIcon(exitimgdown); ImageIcon minIconDown = new ImageIcon(minimgdown); ImageIcon exitIconHover = new ImageIcon(exithover); ImageIcon minIconHover = new ImageIcon(minimghover); logo = new JLabel(icon); exit = new JButton(exitIcon); minimize = new JButton(minIcon); exit.setOpaque(false); exit.setContentAreaFilled(false); exit.setFocusPainted(false); exit.setBorderPainted(false); exit.setPressedIcon(exitIconDown); exit.setRolloverIcon(exitIconHover); minimize.setOpaque(false); minimize.setContentAreaFilled(false); minimize.setFocusPainted(false); minimize.setBorderPainted(false); minimize.setPressedIcon(minIconDown); minimize.setRolloverIcon(minIconHover); } catch (IOException e) { e.printStackTrace(); } buttonPanel.add(advancedButton); buttonPanel.add(generateButton); textArea.setEditable(false); textArea.setLineWrap(true); uiLayout(); uiEvents(); settings = new SettingsDialog(form.gwtCheckBox); titleEvents(minimize, exit); } private void titleEvents (JButton minimize, JButton exit) { minimize.addActionListener(new ActionListener() { @Override public void actionPerformed (ActionEvent e) { setState(ICONIFIED); } }); exit.addActionListener(new ActionListener() { @Override public void actionPerformed (ActionEvent e) { dispose(); System.exit(0); } }); } private void uiLayout () { title.setLayout(new GridLayout(1, 2)); minimize.setPreferredSize(new Dimension(50, 26)); exit.setPreferredSize(new Dimension(50, 26)); title.add(minimize); title.add(exit); topBar.setLayout(new GridLayout(1, 1)); topBar.add(windowLabel, new GridBagConstraints(0, 0, 0, 0, 0, 0, NORTHWEST, VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); setLayout(new GridBagLayout()); add(topBar, new GridBagConstraints(0, 0, 0, 0, 0, 0, NORTH, HORIZONTAL, new Insets(0, 0, 0, 100), 0, 10)); add(title, new GridBagConstraints(0, 0, 0, 0, 0, 0, NORTHEAST, NONE, new Insets(0, 0, 0, 0), 0, 0)); add(logo, new GridBagConstraints(0, 0, 1, 1, 1, 0, CENTER, HORIZONTAL, new Insets(40, 6, 6, 6), 0, 0)); add(form, new GridBagConstraints(0, 1, 1, 1, 1, 0, CENTER, HORIZONTAL, new Insets(6, 6, 0, 6), 0, 0)); add(buttonPanel, new GridBagConstraints(0, 2, 1, 1, 0, 0, CENTER, NONE, new Insets(0, 0, 0, 0), 0, 0)); add(scrollPane, new GridBagConstraints(0, 3, 1, 1, 1, 1, CENTER, BOTH, new Insets(6, 6, 6, 6), 0, 0)); } private void uiEvents () { advancedButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e) { settings.showDialog(form, form.gwtCheckBox); } }); generateButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e) { generate(); } }); } } class Form extends JPanel { ExternalExtensionsDialog externalExtensionsDialog = new ExternalExtensionsDialog(dependencies); JLabel nameLabel = new JLabel("Project name:"); JTextField nameText = new JTextField("My GDX Game"); JLabel packageLabel = new JLabel("Package name:"); JTextField packageText = new JTextField("com.mygdx.game"); JLabel gameClassLabel = new JLabel("Game class:"); JTextField gameClassText = new JTextField("MyGdxGame"); JLabel destinationLabel = new JLabel("Output folder:"); JTextField destinationText = new JTextField(new File("test").getAbsolutePath()); SetupButton destinationButton = new SetupButton("Browse"); JLabel sdkLocationLabel = new JLabel("Android SDK"); JTextField sdkLocationText = new JTextField( System.getProperty("os.name").contains("Windows") ? "C:\\Path\\To\\Your\\Sdk" : "/path/to/your/sdk"); SetupButton sdkLocationButton = new SetupButton("Browse"); JPanel subProjectsPanel = new JPanel(new GridLayout()); JLabel projectsLabel = new JLabel("Supported Platforms"); JLabel extensionsLabel = new JLabel("Official Extensions"); List<JPanel> extensionsPanels = new ArrayList<JPanel>(); SetupButton showMoreExtensionsButton = new SetupButton("Show Third-Party Extensions"); SetupCheckBox gwtCheckBox; { uiLayout(); uiEvents(); uiStyle(); } private void uiStyle () { nameText.setCaretColor(Color.WHITE); packageText.setCaretColor(Color.WHITE); gameClassText.setCaretColor(Color.WHITE); destinationText.setCaretColor(Color.WHITE); sdkLocationText.setCaretColor(Color.WHITE); nameLabel.setForeground(Color.WHITE); packageLabel.setForeground(Color.WHITE); gameClassLabel.setForeground(Color.WHITE); destinationLabel.setForeground(Color.WHITE); sdkLocationLabel.setForeground(Color.WHITE); sdkLocationText.setDisabledTextColor(Color.GRAY); projectsLabel.setForeground(new Color(235, 70, 61)); extensionsLabel.setForeground(new Color(235, 70, 61)); subProjectsPanel.setOpaque(true); subProjectsPanel.setBackground(new Color(46, 46, 46)); for (JPanel extensionPanel : extensionsPanels) { extensionPanel.setOpaque(true); extensionPanel.setBackground(new Color(46, 46, 46)); } nameLabel.setToolTipText("The name of the application used in gradle"); packageLabel.setToolTipText("The package name of the application"); gameClassLabel.setToolTipText("The name of the main class implementing ApplicationListener"); destinationLabel.setToolTipText("The root directory of the project; will be created if it does not exist"); sdkLocationLabel.setToolTipText("The location of your Android SDK"); } private void uiLayout () { setLayout(new GridBagLayout()); add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, EAST, NONE, new Insets(0, 0, 6, 6), 0, 0)); add(nameText, new GridBagConstraints(1, 0, 2, 1, 1, 0, CENTER, HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0)); add(packageLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, EAST, NONE, new Insets(0, 0, 6, 6), 0, 0)); add(packageText, new GridBagConstraints(1, 1, 2, 1, 1, 0, CENTER, HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0)); add(gameClassLabel, new GridBagConstraints(0, 2, 1, 1, 0, 0, EAST, NONE, new Insets(0, 0, 6, 6), 0, 0)); add(gameClassText, new GridBagConstraints(1, 2, 2, 1, 1, 0, CENTER, HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0)); add(destinationLabel, new GridBagConstraints(0, 3, 1, 1, 0, 0, EAST, NONE, new Insets(0, 0, 0, 6), 0, 0)); add(destinationText, new GridBagConstraints(1, 3, 1, 1, 1, 0, CENTER, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); add(destinationButton, new GridBagConstraints(2, 3, 1, 1, 0, 0, CENTER, NONE, new Insets(0, 6, 0, 0), 0, 0)); if (System.getenv("ANDROID_HOME") != null) { sdkLocationText.setText(System.getenv("ANDROID_HOME")); } if (prefs.getString("ANDROID_HOME", null) != null) { sdkLocationText.setText(prefs.getString("ANDROID_HOME")); } add(sdkLocationLabel, new GridBagConstraints(0, 4, 1, 1, 0, 0, EAST, NONE, new Insets(0, 0, 0, 6), 0, 0)); add(sdkLocationText, new GridBagConstraints(1, 4, 1, 1, 1, 0, CENTER, HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); add(sdkLocationButton, new GridBagConstraints(2, 4, 1, 1, 0, 0, CENTER, NONE, new Insets(0, 6, 0, 0), 0, 0)); for (final ProjectType projectType : ProjectType.values()) { if (projectType.equals(ProjectType.CORE)) { continue; } if (projectType.equals(ProjectType.LWJGL2)) { continue; // LWJGL 2 projects can only be built via command line } SetupCheckBox checkBox = new SetupCheckBox(projectType.getDisplayName()); if (projectType == ProjectType.HTML) { gwtCheckBox = checkBox; } modules.add(projectType); checkBox.setSelected(true); subProjectsPanel.add(checkBox); checkBox.addItemListener(new ItemListener() { @Override public void itemStateChanged (ItemEvent e) { SetupCheckBox box = (SetupCheckBox)e.getSource(); if (projectType.equals(ProjectType.ANDROID)) { sdkLocationText.setEnabled(box.isSelected()); } if (box.isSelected()) { modules.add(projectType); } else { if (modules.contains(projectType)) { modules.remove(projectType); } } } }); } add(projectsLabel, new GridBagConstraints(0, 6, 1, 1, 0, 0, WEST, WEST, new Insets(20, 0, 0, 0), 0, 0)); add(subProjectsPanel, new GridBagConstraints(0, 7, 3, 1, 0, 0, CENTER, HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0)); int depCounter = 0; for (int row = 0; row <= (ProjectDependency.values().length / 5); row++) { JPanel extensionPanel = new JPanel(new GridLayout(1, 5)); while (depCounter < ProjectDependency.values().length) { if (ProjectDependency.values()[depCounter] != null) { final ProjectDependency projDep = ProjectDependency.values()[depCounter]; if (projDep.equals(ProjectDependency.GDX)) { depCounter++; continue; } SetupCheckBox depCheckBox = new SetupCheckBox( projDep.name().substring(0, 1) + projDep.name().substring(1, projDep.name().length()).toLowerCase()); depCheckBox.setToolTipText(projDep.getDescription()); extensionPanel.add(depCheckBox); depCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged (ItemEvent e) { SetupCheckBox box = (SetupCheckBox)e.getSource(); if (box.isSelected()) { dependencies.add(builder.bank.getDependency(projDep)); } else { if (dependencies.contains(builder.bank.getDependency(projDep))) { dependencies.remove(builder.bank.getDependency(projDep)); } } } }); if (depCounter % 5 == 0) { depCounter++; break; } depCounter++; } } for (int left = ((depCounter - 1) % 5); left > 1; left--) { extensionPanel.add(Box.createHorizontalBox()); } extensionsPanels.add(extensionPanel); } add(extensionsLabel, new GridBagConstraints(0, 8, 1, 1, 0, 0, WEST, WEST, new Insets(10, 0, 0, 0), 0, 0)); int rowCounter = 9; for (JPanel extensionsPanel : extensionsPanels) { add(extensionsPanel, new GridBagConstraints(0, rowCounter, 3, 1, 0, 0, CENTER, HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0)); rowCounter++; } add(showMoreExtensionsButton, new GridBagConstraints(0, 12, 0, 1, 0, 0, CENTER, WEST, new Insets(10, 0, 10, 0), 0, 0)); } File getDirectory (String dialogTitle) { if (System.getProperty("os.name").contains("Mac")) { System.setProperty("apple.awt.fileDialogForDirectories", "true"); FileDialog dialog = new FileDialog(GdxSetupUI.this, dialogTitle, FileDialog.LOAD); dialog.setVisible(true); String name = dialog.getFile(); String dir = dialog.getDirectory(); if (name == null || dir == null) return null; return new File(dialog.getDirectory(), dialog.getFile()); } else { JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogTitle(dialogTitle); int result = chooser.showOpenDialog(GdxSetupUI.this); if (result == JFileChooser.APPROVE_OPTION) { File dir = chooser.getSelectedFile(); if (dir == null) return null; if (dir.getAbsolutePath().trim().length() == 0) return null; return dir; } else { return null; } } } private void uiEvents () { destinationButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e) { File path = getDirectory("Choose destination"); if (path != null) { destinationText.setText(path.getAbsolutePath()); } } }); sdkLocationButton.addActionListener(new ActionListener() { @Override public void actionPerformed (ActionEvent e) { File path = getDirectory("Choose Android SDK"); if (path != null) { sdkLocationText.setText(path.getAbsolutePath()); prefs.putString("ANDROID_HOME", path.getAbsolutePath()); prefs.flush(); } } }); showMoreExtensionsButton.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent e) { externalExtensionsDialog.showDialog(Form.this); } }); } } public static class SetupCheckBox extends JCheckBox { static Icon icon; static Icon iconOver; static Icon iconPressed; static Icon iconPressedSelected; static Icon iconSelected; static Icon iconOverSelected; static { try { BufferedImage iconImg = getCheckboxImage("checkbox"); BufferedImage iconOverImg = getCheckboxImage("checkboxover"); BufferedImage iconPressedImg = getCheckboxImage("checkboxpressed"); BufferedImage iconPressedSelectedImg = getCheckboxImage("checkboxpressedselected"); BufferedImage iconSelectedImg = getCheckboxImage("checkboxselected"); BufferedImage iconOverSelectedImg = getCheckboxImage("checkboxoverselected"); icon = new ImageIcon(iconImg); iconOver = new ImageIcon(iconOverImg); iconPressed = new ImageIcon(iconPressedImg); iconPressedSelected = new ImageIcon(iconPressedSelectedImg); iconSelected = new ImageIcon(iconSelectedImg); iconOverSelected = new ImageIcon(iconOverSelectedImg); } catch (IOException e) { e.printStackTrace(); } } private static BufferedImage getCheckboxImage (String imageName) throws IOException { return ImageIO.read(GdxSetupUI.class.getResourceAsStream("/com/badlogic/gdx/setup/data/" + imageName + ".png")); } SetupCheckBox () { super(); initUI(); } SetupCheckBox (String selectName) { super(selectName); initUI(); } private void initUI () { setOpaque(false); setBackground(new Color(0, 0, 0)); setForeground(new Color(255, 255, 255)); setFocusPainted(false); setIcon(icon); setRolloverIcon(iconOver); setPressedIcon(iconPressed); setSelectedIcon(iconSelected); setRolloverSelectedIcon(iconOverSelected); } public Icon getPressedIcon () { // checkbox is missing 'pressed selected' icon, this allows us to add it if (isSelected()) return iconPressedSelected; else return super.getPressedIcon(); } } public static class SetupButton extends JButton { private Color textColor = Color.WHITE; private Color backgroundColor = new Color(18, 18, 18); private Color overColor = new Color(120, 20, 20); private Color pressedColor = new Color(240, 40, 40); SetupButton (String buttonTag) { super(buttonTag); setBackground(backgroundColor); setForeground(textColor); setContentAreaFilled(false); setFocusPainted(false); Border line = BorderFactory.createLineBorder(new Color(80, 80, 80)); Border empty = new EmptyBorder(4, 4, 4, 4); CompoundBorder border = new CompoundBorder(line, empty); setBorder(border); } @Override protected void paintComponent (Graphics g) { if (getModel().isPressed()) { g.setColor(pressedColor); } else if (getModel().isRollover()) { g.setColor(overColor); } else { g.setColor(getBackground()); } g.fillRect(0, 0, getWidth(), getHeight()); super.paintComponent(g); } } public static void main (String[] args) throws Exception { SwingUtilities.invokeLater(new Runnable() { @Override public void run () { new GdxSetupUI(); } }); } }
1
libgdx/libgdx
7,311
Set GdxSetup source level to java 8
Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
obigu
"2023-12-28T13:24:30"
"2023-12-28T19:35:04"
7f682a7921a47f0da858508f6b6fd58426dd05d7
449619e48dc25ce335c4003830e409aa69f5f3f7
Set GdxSetup source level to java 8. Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
./extensions/gdx-bullet/jni/swig-src/collision/com/badlogic/gdx/physics/bullet/collision/btTriangleInfoMap.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.linearmath.*; public class btTriangleInfoMap extends btHashMapInternalShortBtHashIntBtTriangleInfo { private long swigCPtr; protected btTriangleInfoMap (final String className, long cPtr, boolean cMemoryOwn) { super(className, CollisionJNI.btTriangleInfoMap_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btTriangleInfoMap, normally you should not need this constructor it's intended for low-level usage. */ public btTriangleInfoMap (long cPtr, boolean cMemoryOwn) { this("btTriangleInfoMap", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(CollisionJNI.btTriangleInfoMap_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (btTriangleInfoMap obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btTriangleInfoMap(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setConvexEpsilon (float value) { CollisionJNI.btTriangleInfoMap_convexEpsilon_set(swigCPtr, this, value); } public float getConvexEpsilon () { return CollisionJNI.btTriangleInfoMap_convexEpsilon_get(swigCPtr, this); } public void setPlanarEpsilon (float value) { CollisionJNI.btTriangleInfoMap_planarEpsilon_set(swigCPtr, this, value); } public float getPlanarEpsilon () { return CollisionJNI.btTriangleInfoMap_planarEpsilon_get(swigCPtr, this); } public void setEqualVertexThreshold (float value) { CollisionJNI.btTriangleInfoMap_equalVertexThreshold_set(swigCPtr, this, value); } public float getEqualVertexThreshold () { return CollisionJNI.btTriangleInfoMap_equalVertexThreshold_get(swigCPtr, this); } public void setEdgeDistanceThreshold (float value) { CollisionJNI.btTriangleInfoMap_edgeDistanceThreshold_set(swigCPtr, this, value); } public float getEdgeDistanceThreshold () { return CollisionJNI.btTriangleInfoMap_edgeDistanceThreshold_get(swigCPtr, this); } public void setMaxEdgeAngleThreshold (float value) { CollisionJNI.btTriangleInfoMap_maxEdgeAngleThreshold_set(swigCPtr, this, value); } public float getMaxEdgeAngleThreshold () { return CollisionJNI.btTriangleInfoMap_maxEdgeAngleThreshold_get(swigCPtr, this); } public void setZeroAreaThreshold (float value) { CollisionJNI.btTriangleInfoMap_zeroAreaThreshold_set(swigCPtr, this, value); } public float getZeroAreaThreshold () { return CollisionJNI.btTriangleInfoMap_zeroAreaThreshold_get(swigCPtr, this); } public btTriangleInfoMap () { this(CollisionJNI.new_btTriangleInfoMap(), true); } public int calculateSerializeBufferSize () { return CollisionJNI.btTriangleInfoMap_calculateSerializeBufferSize(swigCPtr, this); } public String serialize (long dataBuffer, btSerializer serializer) { return CollisionJNI.btTriangleInfoMap_serialize(swigCPtr, this, dataBuffer, btSerializer.getCPtr(serializer), serializer); } public void deSerialize (btTriangleInfoMapData data) { CollisionJNI.btTriangleInfoMap_deSerialize(swigCPtr, this, btTriangleInfoMapData.getCPtr(data), data); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.linearmath.*; public class btTriangleInfoMap extends btHashMapInternalShortBtHashIntBtTriangleInfo { private long swigCPtr; protected btTriangleInfoMap (final String className, long cPtr, boolean cMemoryOwn) { super(className, CollisionJNI.btTriangleInfoMap_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btTriangleInfoMap, normally you should not need this constructor it's intended for low-level usage. */ public btTriangleInfoMap (long cPtr, boolean cMemoryOwn) { this("btTriangleInfoMap", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(CollisionJNI.btTriangleInfoMap_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (btTriangleInfoMap obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btTriangleInfoMap(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setConvexEpsilon (float value) { CollisionJNI.btTriangleInfoMap_convexEpsilon_set(swigCPtr, this, value); } public float getConvexEpsilon () { return CollisionJNI.btTriangleInfoMap_convexEpsilon_get(swigCPtr, this); } public void setPlanarEpsilon (float value) { CollisionJNI.btTriangleInfoMap_planarEpsilon_set(swigCPtr, this, value); } public float getPlanarEpsilon () { return CollisionJNI.btTriangleInfoMap_planarEpsilon_get(swigCPtr, this); } public void setEqualVertexThreshold (float value) { CollisionJNI.btTriangleInfoMap_equalVertexThreshold_set(swigCPtr, this, value); } public float getEqualVertexThreshold () { return CollisionJNI.btTriangleInfoMap_equalVertexThreshold_get(swigCPtr, this); } public void setEdgeDistanceThreshold (float value) { CollisionJNI.btTriangleInfoMap_edgeDistanceThreshold_set(swigCPtr, this, value); } public float getEdgeDistanceThreshold () { return CollisionJNI.btTriangleInfoMap_edgeDistanceThreshold_get(swigCPtr, this); } public void setMaxEdgeAngleThreshold (float value) { CollisionJNI.btTriangleInfoMap_maxEdgeAngleThreshold_set(swigCPtr, this, value); } public float getMaxEdgeAngleThreshold () { return CollisionJNI.btTriangleInfoMap_maxEdgeAngleThreshold_get(swigCPtr, this); } public void setZeroAreaThreshold (float value) { CollisionJNI.btTriangleInfoMap_zeroAreaThreshold_set(swigCPtr, this, value); } public float getZeroAreaThreshold () { return CollisionJNI.btTriangleInfoMap_zeroAreaThreshold_get(swigCPtr, this); } public btTriangleInfoMap () { this(CollisionJNI.new_btTriangleInfoMap(), true); } public int calculateSerializeBufferSize () { return CollisionJNI.btTriangleInfoMap_calculateSerializeBufferSize(swigCPtr, this); } public String serialize (long dataBuffer, btSerializer serializer) { return CollisionJNI.btTriangleInfoMap_serialize(swigCPtr, this, dataBuffer, btSerializer.getCPtr(serializer), serializer); } public void deSerialize (btTriangleInfoMapData data) { CollisionJNI.btTriangleInfoMap_deSerialize(swigCPtr, this, btTriangleInfoMapData.getCPtr(data), data); } }
-1
libgdx/libgdx
7,311
Set GdxSetup source level to java 8
Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
obigu
"2023-12-28T13:24:30"
"2023-12-28T19:35:04"
7f682a7921a47f0da858508f6b6fd58426dd05d7
449619e48dc25ce335c4003830e409aa69f5f3f7
Set GdxSetup source level to java 8. Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
./extensions/gdx-box2d/gdx-box2d-gwt/src/com/badlogic/gdx/physics/box2d/gwt/emu/org/jbox2d/dynamics/joints/LimitState.java
/******************************************************************************* * Copyright (c) 2013, Daniel Murphy * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ package org.jbox2d.dynamics.joints; public enum LimitState { INACTIVE, AT_LOWER, AT_UPPER, EQUAL }
/******************************************************************************* * Copyright (c) 2013, Daniel Murphy * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ package org.jbox2d.dynamics.joints; public enum LimitState { INACTIVE, AT_LOWER, AT_UPPER, EQUAL }
-1
libgdx/libgdx
7,311
Set GdxSetup source level to java 8
Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
obigu
"2023-12-28T13:24:30"
"2023-12-28T19:35:04"
7f682a7921a47f0da858508f6b6fd58426dd05d7
449619e48dc25ce335c4003830e409aa69f5f3f7
Set GdxSetup source level to java 8. Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
./extensions/gdx-bullet/jni/swig-src/collision/com/badlogic/gdx/physics/bullet/collision/btMultiSphereShape.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.math.Vector3; public class btMultiSphereShape extends btConvexInternalAabbCachingShape { private long swigCPtr; protected btMultiSphereShape (final String className, long cPtr, boolean cMemoryOwn) { super(className, CollisionJNI.btMultiSphereShape_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btMultiSphereShape, normally you should not need this constructor it's intended for low-level usage. */ public btMultiSphereShape (long cPtr, boolean cMemoryOwn) { this("btMultiSphereShape", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(CollisionJNI.btMultiSphereShape_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (btMultiSphereShape obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btMultiSphereShape(swigCPtr); } swigCPtr = 0; } super.delete(); } public long operatorNew (long sizeInBytes) { return CollisionJNI.btMultiSphereShape_operatorNew__SWIG_0(swigCPtr, this, sizeInBytes); } public void operatorDelete (long ptr) { CollisionJNI.btMultiSphereShape_operatorDelete__SWIG_0(swigCPtr, this, ptr); } public long operatorNew (long arg0, long ptr) { return CollisionJNI.btMultiSphereShape_operatorNew__SWIG_1(swigCPtr, this, arg0, ptr); } public void operatorDelete (long arg0, long arg1) { CollisionJNI.btMultiSphereShape_operatorDelete__SWIG_1(swigCPtr, this, arg0, arg1); } public long operatorNewArray (long sizeInBytes) { return CollisionJNI.btMultiSphereShape_operatorNewArray__SWIG_0(swigCPtr, this, sizeInBytes); } public void operatorDeleteArray (long ptr) { CollisionJNI.btMultiSphereShape_operatorDeleteArray__SWIG_0(swigCPtr, this, ptr); } public long operatorNewArray (long arg0, long ptr) { return CollisionJNI.btMultiSphereShape_operatorNewArray__SWIG_1(swigCPtr, this, arg0, ptr); } public void operatorDeleteArray (long arg0, long arg1) { CollisionJNI.btMultiSphereShape_operatorDeleteArray__SWIG_1(swigCPtr, this, arg0, arg1); } public btMultiSphereShape (Vector3[] positions, float[] radi, int numSpheres) { this(CollisionJNI.new_btMultiSphereShape(positions, radi, numSpheres), true); } public int getSphereCount () { return CollisionJNI.btMultiSphereShape_getSphereCount(swigCPtr, this); } public Vector3 getSpherePosition (int index) { return CollisionJNI.btMultiSphereShape_getSpherePosition(swigCPtr, this, index); } public float getSphereRadius (int index) { return CollisionJNI.btMultiSphereShape_getSphereRadius(swigCPtr, this, index); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.math.Vector3; public class btMultiSphereShape extends btConvexInternalAabbCachingShape { private long swigCPtr; protected btMultiSphereShape (final String className, long cPtr, boolean cMemoryOwn) { super(className, CollisionJNI.btMultiSphereShape_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btMultiSphereShape, normally you should not need this constructor it's intended for low-level usage. */ public btMultiSphereShape (long cPtr, boolean cMemoryOwn) { this("btMultiSphereShape", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(CollisionJNI.btMultiSphereShape_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (btMultiSphereShape obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btMultiSphereShape(swigCPtr); } swigCPtr = 0; } super.delete(); } public long operatorNew (long sizeInBytes) { return CollisionJNI.btMultiSphereShape_operatorNew__SWIG_0(swigCPtr, this, sizeInBytes); } public void operatorDelete (long ptr) { CollisionJNI.btMultiSphereShape_operatorDelete__SWIG_0(swigCPtr, this, ptr); } public long operatorNew (long arg0, long ptr) { return CollisionJNI.btMultiSphereShape_operatorNew__SWIG_1(swigCPtr, this, arg0, ptr); } public void operatorDelete (long arg0, long arg1) { CollisionJNI.btMultiSphereShape_operatorDelete__SWIG_1(swigCPtr, this, arg0, arg1); } public long operatorNewArray (long sizeInBytes) { return CollisionJNI.btMultiSphereShape_operatorNewArray__SWIG_0(swigCPtr, this, sizeInBytes); } public void operatorDeleteArray (long ptr) { CollisionJNI.btMultiSphereShape_operatorDeleteArray__SWIG_0(swigCPtr, this, ptr); } public long operatorNewArray (long arg0, long ptr) { return CollisionJNI.btMultiSphereShape_operatorNewArray__SWIG_1(swigCPtr, this, arg0, ptr); } public void operatorDeleteArray (long arg0, long arg1) { CollisionJNI.btMultiSphereShape_operatorDeleteArray__SWIG_1(swigCPtr, this, arg0, arg1); } public btMultiSphereShape (Vector3[] positions, float[] radi, int numSpheres) { this(CollisionJNI.new_btMultiSphereShape(positions, radi, numSpheres), true); } public int getSphereCount () { return CollisionJNI.btMultiSphereShape_getSphereCount(swigCPtr, this); } public Vector3 getSpherePosition (int index) { return CollisionJNI.btMultiSphereShape_getSpherePosition(swigCPtr, this, index); } public float getSphereRadius (int index) { return CollisionJNI.btMultiSphereShape_getSphereRadius(swigCPtr, this, index); } }
-1
libgdx/libgdx
7,311
Set GdxSetup source level to java 8
Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
obigu
"2023-12-28T13:24:30"
"2023-12-28T19:35:04"
7f682a7921a47f0da858508f6b6fd58426dd05d7
449619e48dc25ce335c4003830e409aa69f5f3f7
Set GdxSetup source level to java 8. Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
./extensions/gdx-box2d/gdx-box2d/src/com/badlogic/gdx/physics/box2d/DestructionListener.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.physics.box2d; public interface DestructionListener { }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.physics.box2d; public interface DestructionListener { }
-1
libgdx/libgdx
7,311
Set GdxSetup source level to java 8
Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
obigu
"2023-12-28T13:24:30"
"2023-12-28T19:35:04"
7f682a7921a47f0da858508f6b6fd58426dd05d7
449619e48dc25ce335c4003830e409aa69f5f3f7
Set GdxSetup source level to java 8. Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
./gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Cullable.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.scenes.scene2d.utils; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.utils.Null; /** Allows a parent to set the area that is visible on a child actor to allow the child to cull when drawing itself. This must * only be used for actors that are not rotated or scaled. * @author Nathan Sweet */ public interface Cullable { /** @param cullingArea The culling area in the child actor's coordinates. */ public void setCullingArea (@Null Rectangle cullingArea); }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.scenes.scene2d.utils; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.utils.Null; /** Allows a parent to set the area that is visible on a child actor to allow the child to cull when drawing itself. This must * only be used for actors that are not rotated or scaled. * @author Nathan Sweet */ public interface Cullable { /** @param cullingArea The culling area in the child actor's coordinates. */ public void setCullingArea (@Null Rectangle cullingArea); }
-1
libgdx/libgdx
7,311
Set GdxSetup source level to java 8
Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
obigu
"2023-12-28T13:24:30"
"2023-12-28T19:35:04"
7f682a7921a47f0da858508f6b6fd58426dd05d7
449619e48dc25ce335c4003830e409aa69f5f3f7
Set GdxSetup source level to java 8. Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
./extensions/gdx-bullet/jni/swig-src/extras/com/badlogic/gdx/physics/bullet/extras/DillCreator.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.extras; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.physics.bullet.collision.*; import com.badlogic.gdx.physics.bullet.dynamics.*; public class DillCreator extends MultiBodyTreeCreator { private long swigCPtr; protected DillCreator (final String className, long cPtr, boolean cMemoryOwn) { super(className, ExtrasJNI.DillCreator_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new DillCreator, normally you should not need this constructor it's intended for low-level usage. */ public DillCreator (long cPtr, boolean cMemoryOwn) { this("DillCreator", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(ExtrasJNI.DillCreator_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (DillCreator obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; ExtrasJNI.delete_DillCreator(swigCPtr); } swigCPtr = 0; } super.delete(); } public DillCreator (int levels) { this(ExtrasJNI.new_DillCreator(levels), true); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.extras; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.physics.bullet.collision.*; import com.badlogic.gdx.physics.bullet.dynamics.*; public class DillCreator extends MultiBodyTreeCreator { private long swigCPtr; protected DillCreator (final String className, long cPtr, boolean cMemoryOwn) { super(className, ExtrasJNI.DillCreator_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new DillCreator, normally you should not need this constructor it's intended for low-level usage. */ public DillCreator (long cPtr, boolean cMemoryOwn) { this("DillCreator", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(ExtrasJNI.DillCreator_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (DillCreator obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; ExtrasJNI.delete_DillCreator(swigCPtr); } swigCPtr = 0; } super.delete(); } public DillCreator (int levels) { this(ExtrasJNI.new_DillCreator(levels), true); } }
-1
libgdx/libgdx
7,311
Set GdxSetup source level to java 8
Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
obigu
"2023-12-28T13:24:30"
"2023-12-28T19:35:04"
7f682a7921a47f0da858508f6b6fd58426dd05d7
449619e48dc25ce335c4003830e409aa69f5f3f7
Set GdxSetup source level to java 8. Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
./backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/DefaultAndroidInput.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.backends.android; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnCancelListener; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Handler; import android.text.InputType; import android.text.method.PasswordTransformationMethod; import android.view.MotionEvent; import android.view.Surface; import android.view.View; import android.view.View.OnGenericMotionListener; import android.view.View.OnKeyListener; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import com.badlogic.gdx.AbstractInput; import com.badlogic.gdx.Application; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Graphics.DisplayMode; import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.backends.android.surfaceview.GLSurfaceView20; import com.badlogic.gdx.utils.Pool; import java.util.ArrayList; import java.util.List; /** An implementation of the {@link Input} interface for Android. * * @author mzechner */ /** @author jshapcot */ public class DefaultAndroidInput extends AbstractInput implements AndroidInput { static class KeyEvent { static final int KEY_DOWN = 0; static final int KEY_UP = 1; static final int KEY_TYPED = 2; long timeStamp; int type; int keyCode; char keyChar; } static class TouchEvent { static final int TOUCH_DOWN = 0; static final int TOUCH_UP = 1; static final int TOUCH_DRAGGED = 2; static final int TOUCH_SCROLLED = 3; static final int TOUCH_MOVED = 4; static final int TOUCH_CANCELLED = 5; long timeStamp; int type; int x; int y; int scrollAmountX; int scrollAmountY; int button; int pointer; } Pool<KeyEvent> usedKeyEvents = new Pool<KeyEvent>(16, 1000) { protected KeyEvent newObject () { return new KeyEvent(); } }; Pool<TouchEvent> usedTouchEvents = new Pool<TouchEvent>(16, 1000) { protected TouchEvent newObject () { return new TouchEvent(); } }; public static final int NUM_TOUCHES = 20; ArrayList<OnKeyListener> keyListeners = new ArrayList(); ArrayList<KeyEvent> keyEvents = new ArrayList(); ArrayList<TouchEvent> touchEvents = new ArrayList(); int[] touchX = new int[NUM_TOUCHES]; int[] touchY = new int[NUM_TOUCHES]; int[] deltaX = new int[NUM_TOUCHES]; int[] deltaY = new int[NUM_TOUCHES]; boolean[] touched = new boolean[NUM_TOUCHES]; int[] button = new int[NUM_TOUCHES]; int[] realId = new int[NUM_TOUCHES]; float[] pressure = new float[NUM_TOUCHES]; final boolean hasMultitouch; private boolean[] justPressedButtons = new boolean[NUM_TOUCHES]; private SensorManager manager; public boolean accelerometerAvailable = false; protected final float[] accelerometerValues = new float[3]; public boolean gyroscopeAvailable = false; protected final float[] gyroscopeValues = new float[3]; private Handler handle; final Application app; final Context context; protected final AndroidTouchHandler touchHandler; private int sleepTime = 0; protected final AndroidHaptics haptics; private boolean compassAvailable = false; private boolean rotationVectorAvailable = false; boolean keyboardAvailable; protected final float[] magneticFieldValues = new float[3]; protected final float[] rotationVectorValues = new float[3]; private float azimuth = 0; private float pitch = 0; private float roll = 0; private boolean justTouched = false; private InputProcessor processor; private final AndroidApplicationConfiguration config; protected final Orientation nativeOrientation; private long currentEventTimeStamp = 0; private SensorEventListener accelerometerListener; private SensorEventListener gyroscopeListener; private SensorEventListener compassListener; private SensorEventListener rotationVectorListener; private final ArrayList<OnGenericMotionListener> genericMotionListeners = new ArrayList(); private final AndroidMouseHandler mouseHandler; public DefaultAndroidInput (Application activity, Context context, Object view, AndroidApplicationConfiguration config) { // we hook into View, for LWPs we call onTouch below directly from // within the AndroidLivewallpaperEngine#onTouchEvent() method. if (view instanceof View) { View v = (View)view; v.setOnKeyListener(this); v.setOnTouchListener(this); v.setFocusable(true); v.setFocusableInTouchMode(true); v.requestFocus(); v.setOnGenericMotionListener(this); } this.config = config; this.mouseHandler = new AndroidMouseHandler(); for (int i = 0; i < realId.length; i++) realId[i] = -1; handle = new Handler(); this.app = activity; this.context = context; this.sleepTime = config.touchSleepTime; touchHandler = new AndroidTouchHandler(); hasMultitouch = touchHandler.supportsMultitouch(context); haptics = new AndroidHaptics(context); int rotation = getRotation(); DisplayMode mode = app.getGraphics().getDisplayMode(); if (((rotation == 0 || rotation == 180) && (mode.width >= mode.height)) || ((rotation == 90 || rotation == 270) && (mode.width <= mode.height))) { nativeOrientation = Orientation.Landscape; } else { nativeOrientation = Orientation.Portrait; } // this is for backward compatibility: libGDX always caught the circle button, original comment: // circle button on Xperia Play shouldn't need catchBack == true setCatchKey(Keys.BUTTON_CIRCLE, true); } @Override public float getAccelerometerX () { return accelerometerValues[0]; } @Override public float getAccelerometerY () { return accelerometerValues[1]; } @Override public float getAccelerometerZ () { return accelerometerValues[2]; } @Override public float getGyroscopeX () { return gyroscopeValues[0]; } @Override public float getGyroscopeY () { return gyroscopeValues[1]; } @Override public float getGyroscopeZ () { return gyroscopeValues[2]; } @Override public void getTextInput (TextInputListener listener, String title, String text, String hint) { getTextInput(listener, title, text, hint, OnscreenKeyboardType.Default); } @Override public void getTextInput (final TextInputListener listener, final String title, final String text, final String hint, final OnscreenKeyboardType keyboardType) { handle.post(new Runnable() { public void run () { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle(title); final EditText input = new EditText(context); if (keyboardType != OnscreenKeyboardType.Default) { input.setInputType(getAndroidInputType(keyboardType)); } input.setHint(hint); input.setText(text); input.setSingleLine(); if (keyboardType == OnscreenKeyboardType.Password) { input.setTransformationMethod(new PasswordTransformationMethod()); } alert.setView(input); alert.setPositiveButton(context.getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int whichButton) { Gdx.app.postRunnable(new Runnable() { @Override public void run () { listener.input(input.getText().toString()); } }); } }); alert.setNegativeButton(context.getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int whichButton) { Gdx.app.postRunnable(new Runnable() { @Override public void run () { listener.canceled(); } }); } }); alert.setOnCancelListener(new OnCancelListener() { @Override public void onCancel (DialogInterface arg0) { Gdx.app.postRunnable(new Runnable() { @Override public void run () { listener.canceled(); } }); } }); alert.show(); } }); } public static int getAndroidInputType (OnscreenKeyboardType type) { int inputType; switch (type) { case NumberPad: inputType = InputType.TYPE_CLASS_NUMBER; break; case PhonePad: inputType = InputType.TYPE_CLASS_PHONE; break; case Email: inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; break; case Password: inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD; break; case URI: inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI; break; default: inputType = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD; break; } return inputType; } @Override public int getMaxPointers () { return NUM_TOUCHES; } @Override public int getX () { synchronized (this) { return touchX[0]; } } @Override public int getY () { synchronized (this) { return touchY[0]; } } @Override public int getX (int pointer) { synchronized (this) { return touchX[pointer]; } } @Override public int getY (int pointer) { synchronized (this) { return touchY[pointer]; } } public boolean isTouched (int pointer) { synchronized (this) { return touched[pointer]; } } @Override public float getPressure () { return getPressure(0); } @Override public float getPressure (int pointer) { return pressure[pointer]; } @Override public void setKeyboardAvailable (boolean available) { this.keyboardAvailable = available; } @Override public boolean isTouched () { synchronized (this) { if (hasMultitouch) { for (int pointer = 0; pointer < NUM_TOUCHES; pointer++) { if (touched[pointer]) { return true; } } } return touched[0]; } } public void setInputProcessor (InputProcessor processor) { synchronized (this) { this.processor = processor; } } @Override public void processEvents () { synchronized (this) { if (justTouched) { justTouched = false; for (int i = 0; i < justPressedButtons.length; i++) { justPressedButtons[i] = false; } } if (keyJustPressed) { keyJustPressed = false; for (int i = 0; i < justPressedKeys.length; i++) { justPressedKeys[i] = false; } } if (processor != null) { final InputProcessor processor = this.processor; int len = keyEvents.size(); for (int i = 0; i < len; i++) { KeyEvent e = keyEvents.get(i); currentEventTimeStamp = e.timeStamp; switch (e.type) { case KeyEvent.KEY_DOWN: processor.keyDown(e.keyCode); keyJustPressed = true; justPressedKeys[e.keyCode] = true; break; case KeyEvent.KEY_UP: processor.keyUp(e.keyCode); break; case KeyEvent.KEY_TYPED: processor.keyTyped(e.keyChar); } usedKeyEvents.free(e); } len = touchEvents.size(); for (int i = 0; i < len; i++) { TouchEvent e = touchEvents.get(i); currentEventTimeStamp = e.timeStamp; switch (e.type) { case TouchEvent.TOUCH_DOWN: processor.touchDown(e.x, e.y, e.pointer, e.button); justTouched = true; justPressedButtons[e.button] = true; break; case TouchEvent.TOUCH_UP: processor.touchUp(e.x, e.y, e.pointer, e.button); break; case TouchEvent.TOUCH_DRAGGED: processor.touchDragged(e.x, e.y, e.pointer); break; case TouchEvent.TOUCH_CANCELLED: processor.touchCancelled(e.x, e.y, e.pointer, e.button); break; case TouchEvent.TOUCH_MOVED: processor.mouseMoved(e.x, e.y); break; case TouchEvent.TOUCH_SCROLLED: processor.scrolled(e.scrollAmountX, e.scrollAmountY); } usedTouchEvents.free(e); } } else { int len = touchEvents.size(); for (int i = 0; i < len; i++) { TouchEvent e = touchEvents.get(i); if (e.type == TouchEvent.TOUCH_DOWN) justTouched = true; usedTouchEvents.free(e); } len = keyEvents.size(); for (int i = 0; i < len; i++) { usedKeyEvents.free(keyEvents.get(i)); } } if (touchEvents.isEmpty()) { for (int i = 0; i < deltaX.length; i++) { deltaX[0] = 0; deltaY[0] = 0; } } keyEvents.clear(); touchEvents.clear(); } } boolean requestFocus = true; @Override public boolean onTouch (View view, MotionEvent event) { if (requestFocus && view != null) { view.setFocusableInTouchMode(true); view.requestFocus(); requestFocus = false; } // synchronized in handler.postTouchEvent() touchHandler.onTouch(event, this); if (sleepTime != 0) { try { Thread.sleep(sleepTime); } catch (InterruptedException e) { } } return true; } // TODO Seems unused. Delete when confirmed. // /** Called in {@link AndroidLiveWallpaperService} on tap // * @param x // * @param y */ // public void onTap (int x, int y) { // postTap(x, y); // } // // /** Called in {@link AndroidLiveWallpaperService} on drop // * @param x // * @param y */ // public void onDrop (int x, int y) { // postTap(x, y); // } // // protected void postTap (int x, int y) { // synchronized (this) { // TouchEvent event = usedTouchEvents.obtain(); // event.timeStamp = System.nanoTime(); // event.pointer = 0; // event.x = x; // event.y = y; // event.type = TouchEvent.TOUCH_DOWN; // touchEvents.add(event); // // event = usedTouchEvents.obtain(); // event.timeStamp = System.nanoTime(); // event.pointer = 0; // event.x = x; // event.y = y; // event.type = TouchEvent.TOUCH_UP; // touchEvents.add(event); // } // Gdx.app.getGraphics().requestRendering(); // } @Override public boolean onKey (View v, int keyCode, android.view.KeyEvent e) { for (int i = 0, n = keyListeners.size(); i < n; i++) if (keyListeners.get(i).onKey(v, keyCode, e)) return true; // If the key is held sufficiently long that it repeats, then the initial down is followed // additional key events with ACTION_DOWN and a non-zero value for getRepeatCount(). // We are only interested in the first key down event here and must ignore all others if (e.getAction() == android.view.KeyEvent.ACTION_DOWN && e.getRepeatCount() > 0) return isCatchKey(keyCode); synchronized (this) { KeyEvent event = null; if (e.getKeyCode() == android.view.KeyEvent.KEYCODE_UNKNOWN && e.getAction() == android.view.KeyEvent.ACTION_MULTIPLE) { String chars = e.getCharacters(); for (int i = 0; i < chars.length(); i++) { event = usedKeyEvents.obtain(); event.timeStamp = System.nanoTime(); event.keyCode = 0; event.keyChar = chars.charAt(i); event.type = KeyEvent.KEY_TYPED; keyEvents.add(event); } return false; } char character = (char)e.getUnicodeChar(); // Android doesn't report a unicode char for back space. hrm... if (keyCode == 67) character = '\b'; if (e.getKeyCode() < 0 || e.getKeyCode() > Keys.MAX_KEYCODE) { return false; } switch (e.getAction()) { case android.view.KeyEvent.ACTION_DOWN: event = usedKeyEvents.obtain(); event.timeStamp = System.nanoTime(); event.keyChar = 0; event.keyCode = e.getKeyCode(); event.type = KeyEvent.KEY_DOWN; // Xperia hack for circle key. gah... if (keyCode == android.view.KeyEvent.KEYCODE_BACK && e.isAltPressed()) { keyCode = Keys.BUTTON_CIRCLE; event.keyCode = keyCode; } keyEvents.add(event); if (!pressedKeys[event.keyCode]) { pressedKeyCount++; pressedKeys[event.keyCode] = true; } break; case android.view.KeyEvent.ACTION_UP: long timeStamp = System.nanoTime(); event = usedKeyEvents.obtain(); event.timeStamp = timeStamp; event.keyChar = 0; event.keyCode = e.getKeyCode(); event.type = KeyEvent.KEY_UP; // Xperia hack for circle key. gah... if (keyCode == android.view.KeyEvent.KEYCODE_BACK && e.isAltPressed()) { keyCode = Keys.BUTTON_CIRCLE; event.keyCode = keyCode; } keyEvents.add(event); event = usedKeyEvents.obtain(); event.timeStamp = timeStamp; event.keyChar = character; event.keyCode = 0; event.type = KeyEvent.KEY_TYPED; keyEvents.add(event); if (keyCode == Keys.BUTTON_CIRCLE) { if (pressedKeys[Keys.BUTTON_CIRCLE]) { pressedKeyCount--; pressedKeys[Keys.BUTTON_CIRCLE] = false; } } else { if (pressedKeys[e.getKeyCode()]) { pressedKeyCount--; pressedKeys[e.getKeyCode()] = false; } } } app.getGraphics().requestRendering(); } return isCatchKey(keyCode); } @Override public void setOnscreenKeyboardVisible (final boolean visible) { setOnscreenKeyboardVisible(visible, OnscreenKeyboardType.Default); } @Override public void setOnscreenKeyboardVisible (final boolean visible, final OnscreenKeyboardType type) { handle.post(new Runnable() { public void run () { InputMethodManager manager = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE); if (visible) { View view = ((AndroidGraphics)app.getGraphics()).getView(); OnscreenKeyboardType tmp = type == null ? OnscreenKeyboardType.Default : type; if (((GLSurfaceView20)view).onscreenKeyboardType != tmp) { ((GLSurfaceView20)view).onscreenKeyboardType = tmp; manager.restartInput(view); } view.setFocusable(true); view.setFocusableInTouchMode(true); manager.showSoftInput(((AndroidGraphics)app.getGraphics()).getView(), 0); } else { manager.hideSoftInputFromWindow(((AndroidGraphics)app.getGraphics()).getView().getWindowToken(), 0); } } }); } @Override public void vibrate (int milliseconds) { haptics.vibrate(milliseconds); } @Override public void vibrate (int milliseconds, boolean fallback) { haptics.vibrate(milliseconds); } @Override public void vibrate (int milliseconds, int amplitude, boolean fallback) { haptics.vibrate(milliseconds, amplitude, fallback); } @Override public void vibrate (VibrationType vibrationType) { haptics.vibrate(vibrationType); } @Override public boolean justTouched () { return justTouched; } @Override public boolean isButtonPressed (int button) { synchronized (this) { if (hasMultitouch) { for (int pointer = 0; pointer < NUM_TOUCHES; pointer++) { if (touched[pointer] && (this.button[pointer] == button)) { return true; } } } return (touched[0] && (this.button[0] == button)); } } @Override public boolean isButtonJustPressed (int button) { if (button < 0 || button > NUM_TOUCHES) return false; return justPressedButtons[button]; } final float[] R = new float[9]; final float[] orientation = new float[3]; private void updateOrientation () { if (rotationVectorAvailable) { SensorManager.getRotationMatrixFromVector(R, rotationVectorValues); } else if (!SensorManager.getRotationMatrix(R, null, accelerometerValues, magneticFieldValues)) { return; // compass + accelerometer in free fall } SensorManager.getOrientation(R, orientation); azimuth = (float)Math.toDegrees(orientation[0]); pitch = (float)Math.toDegrees(orientation[1]); roll = (float)Math.toDegrees(orientation[2]); } /** Returns the rotation matrix describing the devices rotation as per * <a href= "http://developer.android.com/reference/android/hardware/SensorManager.html#getRotationMatrix(float[], float[], * float[], float[])" >SensorManager#getRotationMatrix(float[], float[], float[], float[])</a>. Does not manipulate the matrix * if the platform does not have an accelerometer and compass, or a rotation vector sensor. * @param matrix */ public void getRotationMatrix (float[] matrix) { if (rotationVectorAvailable) SensorManager.getRotationMatrixFromVector(matrix, rotationVectorValues); else // compass + accelerometer SensorManager.getRotationMatrix(matrix, null, accelerometerValues, magneticFieldValues); } @Override public float getAzimuth () { if (!compassAvailable && !rotationVectorAvailable) return 0; updateOrientation(); return azimuth; } @Override public float getPitch () { if (!compassAvailable && !rotationVectorAvailable) return 0; updateOrientation(); return pitch; } @Override public float getRoll () { if (!compassAvailable && !rotationVectorAvailable) return 0; updateOrientation(); return roll; } void registerSensorListeners () { if (config.useAccelerometer) { manager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE); if (manager.getSensorList(Sensor.TYPE_ACCELEROMETER).isEmpty()) { accelerometerAvailable = false; } else { Sensor accelerometer = manager.getSensorList(Sensor.TYPE_ACCELEROMETER).get(0); accelerometerListener = new SensorListener(); accelerometerAvailable = manager.registerListener(accelerometerListener, accelerometer, config.sensorDelay); } } else accelerometerAvailable = false; if (config.useGyroscope) { manager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE); if (manager.getSensorList(Sensor.TYPE_GYROSCOPE).isEmpty()) { gyroscopeAvailable = false; } else { Sensor gyroscope = manager.getSensorList(Sensor.TYPE_GYROSCOPE).get(0); gyroscopeListener = new SensorListener(); gyroscopeAvailable = manager.registerListener(gyroscopeListener, gyroscope, config.sensorDelay); } } else gyroscopeAvailable = false; rotationVectorAvailable = false; if (config.useRotationVectorSensor) { if (manager == null) manager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE); List<Sensor> rotationVectorSensors = manager.getSensorList(Sensor.TYPE_ROTATION_VECTOR); if (!rotationVectorSensors.isEmpty()) { rotationVectorListener = new SensorListener(); for (Sensor sensor : rotationVectorSensors) { // favor AOSP sensor if (sensor.getVendor().equals("Google Inc.") && sensor.getVersion() == 3) { rotationVectorAvailable = manager.registerListener(rotationVectorListener, sensor, config.sensorDelay); break; } } if (!rotationVectorAvailable) rotationVectorAvailable = manager.registerListener(rotationVectorListener, rotationVectorSensors.get(0), config.sensorDelay); } } if (config.useCompass && !rotationVectorAvailable) { if (manager == null) manager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE); Sensor sensor = manager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); if (sensor != null) { compassAvailable = accelerometerAvailable; if (compassAvailable) { compassListener = new SensorListener(); compassAvailable = manager.registerListener(compassListener, sensor, config.sensorDelay); } } else { compassAvailable = false; } } else compassAvailable = false; Gdx.app.log("AndroidInput", "sensor listener setup"); } void unregisterSensorListeners () { if (manager != null) { if (accelerometerListener != null) { manager.unregisterListener(accelerometerListener); accelerometerListener = null; } if (gyroscopeListener != null) { manager.unregisterListener(gyroscopeListener); gyroscopeListener = null; } if (rotationVectorListener != null) { manager.unregisterListener(rotationVectorListener); rotationVectorListener = null; } if (compassListener != null) { manager.unregisterListener(compassListener); compassListener = null; } manager = null; } Gdx.app.log("AndroidInput", "sensor listener tear down"); } @Override public InputProcessor getInputProcessor () { return this.processor; } @Override public boolean isPeripheralAvailable (Peripheral peripheral) { if (peripheral == Peripheral.Accelerometer) return accelerometerAvailable; if (peripheral == Peripheral.Gyroscope) return gyroscopeAvailable; if (peripheral == Peripheral.Compass) return compassAvailable; if (peripheral == Peripheral.HardwareKeyboard) return keyboardAvailable; if (peripheral == Peripheral.OnscreenKeyboard) return true; if (peripheral == Peripheral.Vibrator) return haptics.hasVibratorAvailable(); if (peripheral == Peripheral.HapticFeedback) return haptics.hasHapticsSupport(); if (peripheral == Peripheral.MultitouchScreen) return hasMultitouch; if (peripheral == Peripheral.RotationVector) return rotationVectorAvailable; if (peripheral == Peripheral.Pressure) return true; return false; } public int getFreePointerIndex () { int len = realId.length; for (int i = 0; i < len; i++) { if (realId[i] == -1) return i; } pressure = resize(pressure); realId = resize(realId); touchX = resize(touchX); touchY = resize(touchY); deltaX = resize(deltaX); deltaY = resize(deltaY); touched = resize(touched); button = resize(button); return len; } private int[] resize (int[] orig) { int[] tmp = new int[orig.length + 2]; System.arraycopy(orig, 0, tmp, 0, orig.length); return tmp; } private boolean[] resize (boolean[] orig) { boolean[] tmp = new boolean[orig.length + 2]; System.arraycopy(orig, 0, tmp, 0, orig.length); return tmp; } private float[] resize (float[] orig) { float[] tmp = new float[orig.length + 2]; System.arraycopy(orig, 0, tmp, 0, orig.length); return tmp; } public int lookUpPointerIndex (int pointerId) { int len = realId.length; for (int i = 0; i < len; i++) { if (realId[i] == pointerId) return i; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < len; i++) { sb.append(i + ":" + realId[i] + " "); } Gdx.app.log("AndroidInput", "Pointer ID lookup failed: " + pointerId + ", " + sb.toString()); return -1; } @Override public int getRotation () { int orientation = 0; if (context instanceof Activity) { orientation = ((Activity)context).getWindowManager().getDefaultDisplay().getRotation(); } else { orientation = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation(); } switch (orientation) { case Surface.ROTATION_0: return 0; case Surface.ROTATION_90: return 90; case Surface.ROTATION_180: return 180; case Surface.ROTATION_270: return 270; default: return 0; } } @Override public Orientation getNativeOrientation () { return nativeOrientation; } @Override public void setCursorCatched (boolean catched) { } @Override public boolean isCursorCatched () { return false; } @Override public int getDeltaX () { return deltaX[0]; } @Override public int getDeltaX (int pointer) { return deltaX[pointer]; } @Override public int getDeltaY () { return deltaY[0]; } @Override public int getDeltaY (int pointer) { return deltaY[pointer]; } @Override public void setCursorPosition (int x, int y) { } @Override public long getCurrentEventTime () { return currentEventTimeStamp; } @Override public void addKeyListener (OnKeyListener listener) { keyListeners.add(listener); } @Override public boolean onGenericMotion (View view, MotionEvent event) { if (mouseHandler.onGenericMotion(event, this)) return true; for (int i = 0, n = genericMotionListeners.size(); i < n; i++) if (genericMotionListeners.get(i).onGenericMotion(view, event)) return true; return false; } @Override public void addGenericMotionListener (OnGenericMotionListener listener) { genericMotionListeners.add(listener); } @Override public void onPause () { unregisterSensorListeners(); } @Override public void onResume () { registerSensorListeners(); } @Override public void onDreamingStarted () { registerSensorListeners(); } @Override public void onDreamingStopped () { unregisterSensorListeners(); } /** Our implementation of SensorEventListener. Because Android doesn't like it when we register more than one Sensor to a * single SensorEventListener, we add one of these for each Sensor. Could use an anonymous class, but I don't see any harm in * explicitly defining it here. Correct me if I am wrong. */ private class SensorListener implements SensorEventListener { public SensorListener () { } @Override public void onAccuracyChanged (Sensor arg0, int arg1) { } @Override public void onSensorChanged (SensorEvent event) { if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { if (nativeOrientation == Orientation.Portrait) { System.arraycopy(event.values, 0, accelerometerValues, 0, accelerometerValues.length); } else { accelerometerValues[0] = event.values[1]; accelerometerValues[1] = -event.values[0]; accelerometerValues[2] = event.values[2]; } } if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) { System.arraycopy(event.values, 0, magneticFieldValues, 0, magneticFieldValues.length); } if (event.sensor.getType() == Sensor.TYPE_GYROSCOPE) { if (nativeOrientation == Orientation.Portrait) { System.arraycopy(event.values, 0, gyroscopeValues, 0, gyroscopeValues.length); } else { gyroscopeValues[0] = event.values[1]; gyroscopeValues[1] = -event.values[0]; gyroscopeValues[2] = event.values[2]; } } if (event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) { if (nativeOrientation == Orientation.Portrait) { System.arraycopy(event.values, 0, rotationVectorValues, 0, rotationVectorValues.length); } else { rotationVectorValues[0] = event.values[1]; rotationVectorValues[1] = -event.values[0]; rotationVectorValues[2] = event.values[2]; } } } } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.backends.android; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnCancelListener; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Handler; import android.text.InputType; import android.text.method.PasswordTransformationMethod; import android.view.MotionEvent; import android.view.Surface; import android.view.View; import android.view.View.OnGenericMotionListener; import android.view.View.OnKeyListener; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import com.badlogic.gdx.AbstractInput; import com.badlogic.gdx.Application; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Graphics.DisplayMode; import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.backends.android.surfaceview.GLSurfaceView20; import com.badlogic.gdx.utils.Pool; import java.util.ArrayList; import java.util.List; /** An implementation of the {@link Input} interface for Android. * * @author mzechner */ /** @author jshapcot */ public class DefaultAndroidInput extends AbstractInput implements AndroidInput { static class KeyEvent { static final int KEY_DOWN = 0; static final int KEY_UP = 1; static final int KEY_TYPED = 2; long timeStamp; int type; int keyCode; char keyChar; } static class TouchEvent { static final int TOUCH_DOWN = 0; static final int TOUCH_UP = 1; static final int TOUCH_DRAGGED = 2; static final int TOUCH_SCROLLED = 3; static final int TOUCH_MOVED = 4; static final int TOUCH_CANCELLED = 5; long timeStamp; int type; int x; int y; int scrollAmountX; int scrollAmountY; int button; int pointer; } Pool<KeyEvent> usedKeyEvents = new Pool<KeyEvent>(16, 1000) { protected KeyEvent newObject () { return new KeyEvent(); } }; Pool<TouchEvent> usedTouchEvents = new Pool<TouchEvent>(16, 1000) { protected TouchEvent newObject () { return new TouchEvent(); } }; public static final int NUM_TOUCHES = 20; ArrayList<OnKeyListener> keyListeners = new ArrayList(); ArrayList<KeyEvent> keyEvents = new ArrayList(); ArrayList<TouchEvent> touchEvents = new ArrayList(); int[] touchX = new int[NUM_TOUCHES]; int[] touchY = new int[NUM_TOUCHES]; int[] deltaX = new int[NUM_TOUCHES]; int[] deltaY = new int[NUM_TOUCHES]; boolean[] touched = new boolean[NUM_TOUCHES]; int[] button = new int[NUM_TOUCHES]; int[] realId = new int[NUM_TOUCHES]; float[] pressure = new float[NUM_TOUCHES]; final boolean hasMultitouch; private boolean[] justPressedButtons = new boolean[NUM_TOUCHES]; private SensorManager manager; public boolean accelerometerAvailable = false; protected final float[] accelerometerValues = new float[3]; public boolean gyroscopeAvailable = false; protected final float[] gyroscopeValues = new float[3]; private Handler handle; final Application app; final Context context; protected final AndroidTouchHandler touchHandler; private int sleepTime = 0; protected final AndroidHaptics haptics; private boolean compassAvailable = false; private boolean rotationVectorAvailable = false; boolean keyboardAvailable; protected final float[] magneticFieldValues = new float[3]; protected final float[] rotationVectorValues = new float[3]; private float azimuth = 0; private float pitch = 0; private float roll = 0; private boolean justTouched = false; private InputProcessor processor; private final AndroidApplicationConfiguration config; protected final Orientation nativeOrientation; private long currentEventTimeStamp = 0; private SensorEventListener accelerometerListener; private SensorEventListener gyroscopeListener; private SensorEventListener compassListener; private SensorEventListener rotationVectorListener; private final ArrayList<OnGenericMotionListener> genericMotionListeners = new ArrayList(); private final AndroidMouseHandler mouseHandler; public DefaultAndroidInput (Application activity, Context context, Object view, AndroidApplicationConfiguration config) { // we hook into View, for LWPs we call onTouch below directly from // within the AndroidLivewallpaperEngine#onTouchEvent() method. if (view instanceof View) { View v = (View)view; v.setOnKeyListener(this); v.setOnTouchListener(this); v.setFocusable(true); v.setFocusableInTouchMode(true); v.requestFocus(); v.setOnGenericMotionListener(this); } this.config = config; this.mouseHandler = new AndroidMouseHandler(); for (int i = 0; i < realId.length; i++) realId[i] = -1; handle = new Handler(); this.app = activity; this.context = context; this.sleepTime = config.touchSleepTime; touchHandler = new AndroidTouchHandler(); hasMultitouch = touchHandler.supportsMultitouch(context); haptics = new AndroidHaptics(context); int rotation = getRotation(); DisplayMode mode = app.getGraphics().getDisplayMode(); if (((rotation == 0 || rotation == 180) && (mode.width >= mode.height)) || ((rotation == 90 || rotation == 270) && (mode.width <= mode.height))) { nativeOrientation = Orientation.Landscape; } else { nativeOrientation = Orientation.Portrait; } // this is for backward compatibility: libGDX always caught the circle button, original comment: // circle button on Xperia Play shouldn't need catchBack == true setCatchKey(Keys.BUTTON_CIRCLE, true); } @Override public float getAccelerometerX () { return accelerometerValues[0]; } @Override public float getAccelerometerY () { return accelerometerValues[1]; } @Override public float getAccelerometerZ () { return accelerometerValues[2]; } @Override public float getGyroscopeX () { return gyroscopeValues[0]; } @Override public float getGyroscopeY () { return gyroscopeValues[1]; } @Override public float getGyroscopeZ () { return gyroscopeValues[2]; } @Override public void getTextInput (TextInputListener listener, String title, String text, String hint) { getTextInput(listener, title, text, hint, OnscreenKeyboardType.Default); } @Override public void getTextInput (final TextInputListener listener, final String title, final String text, final String hint, final OnscreenKeyboardType keyboardType) { handle.post(new Runnable() { public void run () { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle(title); final EditText input = new EditText(context); if (keyboardType != OnscreenKeyboardType.Default) { input.setInputType(getAndroidInputType(keyboardType)); } input.setHint(hint); input.setText(text); input.setSingleLine(); if (keyboardType == OnscreenKeyboardType.Password) { input.setTransformationMethod(new PasswordTransformationMethod()); } alert.setView(input); alert.setPositiveButton(context.getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int whichButton) { Gdx.app.postRunnable(new Runnable() { @Override public void run () { listener.input(input.getText().toString()); } }); } }); alert.setNegativeButton(context.getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialog, int whichButton) { Gdx.app.postRunnable(new Runnable() { @Override public void run () { listener.canceled(); } }); } }); alert.setOnCancelListener(new OnCancelListener() { @Override public void onCancel (DialogInterface arg0) { Gdx.app.postRunnable(new Runnable() { @Override public void run () { listener.canceled(); } }); } }); alert.show(); } }); } public static int getAndroidInputType (OnscreenKeyboardType type) { int inputType; switch (type) { case NumberPad: inputType = InputType.TYPE_CLASS_NUMBER; break; case PhonePad: inputType = InputType.TYPE_CLASS_PHONE; break; case Email: inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; break; case Password: inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD; break; case URI: inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI; break; default: inputType = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD; break; } return inputType; } @Override public int getMaxPointers () { return NUM_TOUCHES; } @Override public int getX () { synchronized (this) { return touchX[0]; } } @Override public int getY () { synchronized (this) { return touchY[0]; } } @Override public int getX (int pointer) { synchronized (this) { return touchX[pointer]; } } @Override public int getY (int pointer) { synchronized (this) { return touchY[pointer]; } } public boolean isTouched (int pointer) { synchronized (this) { return touched[pointer]; } } @Override public float getPressure () { return getPressure(0); } @Override public float getPressure (int pointer) { return pressure[pointer]; } @Override public void setKeyboardAvailable (boolean available) { this.keyboardAvailable = available; } @Override public boolean isTouched () { synchronized (this) { if (hasMultitouch) { for (int pointer = 0; pointer < NUM_TOUCHES; pointer++) { if (touched[pointer]) { return true; } } } return touched[0]; } } public void setInputProcessor (InputProcessor processor) { synchronized (this) { this.processor = processor; } } @Override public void processEvents () { synchronized (this) { if (justTouched) { justTouched = false; for (int i = 0; i < justPressedButtons.length; i++) { justPressedButtons[i] = false; } } if (keyJustPressed) { keyJustPressed = false; for (int i = 0; i < justPressedKeys.length; i++) { justPressedKeys[i] = false; } } if (processor != null) { final InputProcessor processor = this.processor; int len = keyEvents.size(); for (int i = 0; i < len; i++) { KeyEvent e = keyEvents.get(i); currentEventTimeStamp = e.timeStamp; switch (e.type) { case KeyEvent.KEY_DOWN: processor.keyDown(e.keyCode); keyJustPressed = true; justPressedKeys[e.keyCode] = true; break; case KeyEvent.KEY_UP: processor.keyUp(e.keyCode); break; case KeyEvent.KEY_TYPED: processor.keyTyped(e.keyChar); } usedKeyEvents.free(e); } len = touchEvents.size(); for (int i = 0; i < len; i++) { TouchEvent e = touchEvents.get(i); currentEventTimeStamp = e.timeStamp; switch (e.type) { case TouchEvent.TOUCH_DOWN: processor.touchDown(e.x, e.y, e.pointer, e.button); justTouched = true; justPressedButtons[e.button] = true; break; case TouchEvent.TOUCH_UP: processor.touchUp(e.x, e.y, e.pointer, e.button); break; case TouchEvent.TOUCH_DRAGGED: processor.touchDragged(e.x, e.y, e.pointer); break; case TouchEvent.TOUCH_CANCELLED: processor.touchCancelled(e.x, e.y, e.pointer, e.button); break; case TouchEvent.TOUCH_MOVED: processor.mouseMoved(e.x, e.y); break; case TouchEvent.TOUCH_SCROLLED: processor.scrolled(e.scrollAmountX, e.scrollAmountY); } usedTouchEvents.free(e); } } else { int len = touchEvents.size(); for (int i = 0; i < len; i++) { TouchEvent e = touchEvents.get(i); if (e.type == TouchEvent.TOUCH_DOWN) justTouched = true; usedTouchEvents.free(e); } len = keyEvents.size(); for (int i = 0; i < len; i++) { usedKeyEvents.free(keyEvents.get(i)); } } if (touchEvents.isEmpty()) { for (int i = 0; i < deltaX.length; i++) { deltaX[0] = 0; deltaY[0] = 0; } } keyEvents.clear(); touchEvents.clear(); } } boolean requestFocus = true; @Override public boolean onTouch (View view, MotionEvent event) { if (requestFocus && view != null) { view.setFocusableInTouchMode(true); view.requestFocus(); requestFocus = false; } // synchronized in handler.postTouchEvent() touchHandler.onTouch(event, this); if (sleepTime != 0) { try { Thread.sleep(sleepTime); } catch (InterruptedException e) { } } return true; } // TODO Seems unused. Delete when confirmed. // /** Called in {@link AndroidLiveWallpaperService} on tap // * @param x // * @param y */ // public void onTap (int x, int y) { // postTap(x, y); // } // // /** Called in {@link AndroidLiveWallpaperService} on drop // * @param x // * @param y */ // public void onDrop (int x, int y) { // postTap(x, y); // } // // protected void postTap (int x, int y) { // synchronized (this) { // TouchEvent event = usedTouchEvents.obtain(); // event.timeStamp = System.nanoTime(); // event.pointer = 0; // event.x = x; // event.y = y; // event.type = TouchEvent.TOUCH_DOWN; // touchEvents.add(event); // // event = usedTouchEvents.obtain(); // event.timeStamp = System.nanoTime(); // event.pointer = 0; // event.x = x; // event.y = y; // event.type = TouchEvent.TOUCH_UP; // touchEvents.add(event); // } // Gdx.app.getGraphics().requestRendering(); // } @Override public boolean onKey (View v, int keyCode, android.view.KeyEvent e) { for (int i = 0, n = keyListeners.size(); i < n; i++) if (keyListeners.get(i).onKey(v, keyCode, e)) return true; // If the key is held sufficiently long that it repeats, then the initial down is followed // additional key events with ACTION_DOWN and a non-zero value for getRepeatCount(). // We are only interested in the first key down event here and must ignore all others if (e.getAction() == android.view.KeyEvent.ACTION_DOWN && e.getRepeatCount() > 0) return isCatchKey(keyCode); synchronized (this) { KeyEvent event = null; if (e.getKeyCode() == android.view.KeyEvent.KEYCODE_UNKNOWN && e.getAction() == android.view.KeyEvent.ACTION_MULTIPLE) { String chars = e.getCharacters(); for (int i = 0; i < chars.length(); i++) { event = usedKeyEvents.obtain(); event.timeStamp = System.nanoTime(); event.keyCode = 0; event.keyChar = chars.charAt(i); event.type = KeyEvent.KEY_TYPED; keyEvents.add(event); } return false; } char character = (char)e.getUnicodeChar(); // Android doesn't report a unicode char for back space. hrm... if (keyCode == 67) character = '\b'; if (e.getKeyCode() < 0 || e.getKeyCode() > Keys.MAX_KEYCODE) { return false; } switch (e.getAction()) { case android.view.KeyEvent.ACTION_DOWN: event = usedKeyEvents.obtain(); event.timeStamp = System.nanoTime(); event.keyChar = 0; event.keyCode = e.getKeyCode(); event.type = KeyEvent.KEY_DOWN; // Xperia hack for circle key. gah... if (keyCode == android.view.KeyEvent.KEYCODE_BACK && e.isAltPressed()) { keyCode = Keys.BUTTON_CIRCLE; event.keyCode = keyCode; } keyEvents.add(event); if (!pressedKeys[event.keyCode]) { pressedKeyCount++; pressedKeys[event.keyCode] = true; } break; case android.view.KeyEvent.ACTION_UP: long timeStamp = System.nanoTime(); event = usedKeyEvents.obtain(); event.timeStamp = timeStamp; event.keyChar = 0; event.keyCode = e.getKeyCode(); event.type = KeyEvent.KEY_UP; // Xperia hack for circle key. gah... if (keyCode == android.view.KeyEvent.KEYCODE_BACK && e.isAltPressed()) { keyCode = Keys.BUTTON_CIRCLE; event.keyCode = keyCode; } keyEvents.add(event); event = usedKeyEvents.obtain(); event.timeStamp = timeStamp; event.keyChar = character; event.keyCode = 0; event.type = KeyEvent.KEY_TYPED; keyEvents.add(event); if (keyCode == Keys.BUTTON_CIRCLE) { if (pressedKeys[Keys.BUTTON_CIRCLE]) { pressedKeyCount--; pressedKeys[Keys.BUTTON_CIRCLE] = false; } } else { if (pressedKeys[e.getKeyCode()]) { pressedKeyCount--; pressedKeys[e.getKeyCode()] = false; } } } app.getGraphics().requestRendering(); } return isCatchKey(keyCode); } @Override public void setOnscreenKeyboardVisible (final boolean visible) { setOnscreenKeyboardVisible(visible, OnscreenKeyboardType.Default); } @Override public void setOnscreenKeyboardVisible (final boolean visible, final OnscreenKeyboardType type) { handle.post(new Runnable() { public void run () { InputMethodManager manager = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE); if (visible) { View view = ((AndroidGraphics)app.getGraphics()).getView(); OnscreenKeyboardType tmp = type == null ? OnscreenKeyboardType.Default : type; if (((GLSurfaceView20)view).onscreenKeyboardType != tmp) { ((GLSurfaceView20)view).onscreenKeyboardType = tmp; manager.restartInput(view); } view.setFocusable(true); view.setFocusableInTouchMode(true); manager.showSoftInput(((AndroidGraphics)app.getGraphics()).getView(), 0); } else { manager.hideSoftInputFromWindow(((AndroidGraphics)app.getGraphics()).getView().getWindowToken(), 0); } } }); } @Override public void vibrate (int milliseconds) { haptics.vibrate(milliseconds); } @Override public void vibrate (int milliseconds, boolean fallback) { haptics.vibrate(milliseconds); } @Override public void vibrate (int milliseconds, int amplitude, boolean fallback) { haptics.vibrate(milliseconds, amplitude, fallback); } @Override public void vibrate (VibrationType vibrationType) { haptics.vibrate(vibrationType); } @Override public boolean justTouched () { return justTouched; } @Override public boolean isButtonPressed (int button) { synchronized (this) { if (hasMultitouch) { for (int pointer = 0; pointer < NUM_TOUCHES; pointer++) { if (touched[pointer] && (this.button[pointer] == button)) { return true; } } } return (touched[0] && (this.button[0] == button)); } } @Override public boolean isButtonJustPressed (int button) { if (button < 0 || button > NUM_TOUCHES) return false; return justPressedButtons[button]; } final float[] R = new float[9]; final float[] orientation = new float[3]; private void updateOrientation () { if (rotationVectorAvailable) { SensorManager.getRotationMatrixFromVector(R, rotationVectorValues); } else if (!SensorManager.getRotationMatrix(R, null, accelerometerValues, magneticFieldValues)) { return; // compass + accelerometer in free fall } SensorManager.getOrientation(R, orientation); azimuth = (float)Math.toDegrees(orientation[0]); pitch = (float)Math.toDegrees(orientation[1]); roll = (float)Math.toDegrees(orientation[2]); } /** Returns the rotation matrix describing the devices rotation as per * <a href= "http://developer.android.com/reference/android/hardware/SensorManager.html#getRotationMatrix(float[], float[], * float[], float[])" >SensorManager#getRotationMatrix(float[], float[], float[], float[])</a>. Does not manipulate the matrix * if the platform does not have an accelerometer and compass, or a rotation vector sensor. * @param matrix */ public void getRotationMatrix (float[] matrix) { if (rotationVectorAvailable) SensorManager.getRotationMatrixFromVector(matrix, rotationVectorValues); else // compass + accelerometer SensorManager.getRotationMatrix(matrix, null, accelerometerValues, magneticFieldValues); } @Override public float getAzimuth () { if (!compassAvailable && !rotationVectorAvailable) return 0; updateOrientation(); return azimuth; } @Override public float getPitch () { if (!compassAvailable && !rotationVectorAvailable) return 0; updateOrientation(); return pitch; } @Override public float getRoll () { if (!compassAvailable && !rotationVectorAvailable) return 0; updateOrientation(); return roll; } void registerSensorListeners () { if (config.useAccelerometer) { manager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE); if (manager.getSensorList(Sensor.TYPE_ACCELEROMETER).isEmpty()) { accelerometerAvailable = false; } else { Sensor accelerometer = manager.getSensorList(Sensor.TYPE_ACCELEROMETER).get(0); accelerometerListener = new SensorListener(); accelerometerAvailable = manager.registerListener(accelerometerListener, accelerometer, config.sensorDelay); } } else accelerometerAvailable = false; if (config.useGyroscope) { manager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE); if (manager.getSensorList(Sensor.TYPE_GYROSCOPE).isEmpty()) { gyroscopeAvailable = false; } else { Sensor gyroscope = manager.getSensorList(Sensor.TYPE_GYROSCOPE).get(0); gyroscopeListener = new SensorListener(); gyroscopeAvailable = manager.registerListener(gyroscopeListener, gyroscope, config.sensorDelay); } } else gyroscopeAvailable = false; rotationVectorAvailable = false; if (config.useRotationVectorSensor) { if (manager == null) manager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE); List<Sensor> rotationVectorSensors = manager.getSensorList(Sensor.TYPE_ROTATION_VECTOR); if (!rotationVectorSensors.isEmpty()) { rotationVectorListener = new SensorListener(); for (Sensor sensor : rotationVectorSensors) { // favor AOSP sensor if (sensor.getVendor().equals("Google Inc.") && sensor.getVersion() == 3) { rotationVectorAvailable = manager.registerListener(rotationVectorListener, sensor, config.sensorDelay); break; } } if (!rotationVectorAvailable) rotationVectorAvailable = manager.registerListener(rotationVectorListener, rotationVectorSensors.get(0), config.sensorDelay); } } if (config.useCompass && !rotationVectorAvailable) { if (manager == null) manager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE); Sensor sensor = manager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); if (sensor != null) { compassAvailable = accelerometerAvailable; if (compassAvailable) { compassListener = new SensorListener(); compassAvailable = manager.registerListener(compassListener, sensor, config.sensorDelay); } } else { compassAvailable = false; } } else compassAvailable = false; Gdx.app.log("AndroidInput", "sensor listener setup"); } void unregisterSensorListeners () { if (manager != null) { if (accelerometerListener != null) { manager.unregisterListener(accelerometerListener); accelerometerListener = null; } if (gyroscopeListener != null) { manager.unregisterListener(gyroscopeListener); gyroscopeListener = null; } if (rotationVectorListener != null) { manager.unregisterListener(rotationVectorListener); rotationVectorListener = null; } if (compassListener != null) { manager.unregisterListener(compassListener); compassListener = null; } manager = null; } Gdx.app.log("AndroidInput", "sensor listener tear down"); } @Override public InputProcessor getInputProcessor () { return this.processor; } @Override public boolean isPeripheralAvailable (Peripheral peripheral) { if (peripheral == Peripheral.Accelerometer) return accelerometerAvailable; if (peripheral == Peripheral.Gyroscope) return gyroscopeAvailable; if (peripheral == Peripheral.Compass) return compassAvailable; if (peripheral == Peripheral.HardwareKeyboard) return keyboardAvailable; if (peripheral == Peripheral.OnscreenKeyboard) return true; if (peripheral == Peripheral.Vibrator) return haptics.hasVibratorAvailable(); if (peripheral == Peripheral.HapticFeedback) return haptics.hasHapticsSupport(); if (peripheral == Peripheral.MultitouchScreen) return hasMultitouch; if (peripheral == Peripheral.RotationVector) return rotationVectorAvailable; if (peripheral == Peripheral.Pressure) return true; return false; } public int getFreePointerIndex () { int len = realId.length; for (int i = 0; i < len; i++) { if (realId[i] == -1) return i; } pressure = resize(pressure); realId = resize(realId); touchX = resize(touchX); touchY = resize(touchY); deltaX = resize(deltaX); deltaY = resize(deltaY); touched = resize(touched); button = resize(button); return len; } private int[] resize (int[] orig) { int[] tmp = new int[orig.length + 2]; System.arraycopy(orig, 0, tmp, 0, orig.length); return tmp; } private boolean[] resize (boolean[] orig) { boolean[] tmp = new boolean[orig.length + 2]; System.arraycopy(orig, 0, tmp, 0, orig.length); return tmp; } private float[] resize (float[] orig) { float[] tmp = new float[orig.length + 2]; System.arraycopy(orig, 0, tmp, 0, orig.length); return tmp; } public int lookUpPointerIndex (int pointerId) { int len = realId.length; for (int i = 0; i < len; i++) { if (realId[i] == pointerId) return i; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < len; i++) { sb.append(i + ":" + realId[i] + " "); } Gdx.app.log("AndroidInput", "Pointer ID lookup failed: " + pointerId + ", " + sb.toString()); return -1; } @Override public int getRotation () { int orientation = 0; if (context instanceof Activity) { orientation = ((Activity)context).getWindowManager().getDefaultDisplay().getRotation(); } else { orientation = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation(); } switch (orientation) { case Surface.ROTATION_0: return 0; case Surface.ROTATION_90: return 90; case Surface.ROTATION_180: return 180; case Surface.ROTATION_270: return 270; default: return 0; } } @Override public Orientation getNativeOrientation () { return nativeOrientation; } @Override public void setCursorCatched (boolean catched) { } @Override public boolean isCursorCatched () { return false; } @Override public int getDeltaX () { return deltaX[0]; } @Override public int getDeltaX (int pointer) { return deltaX[pointer]; } @Override public int getDeltaY () { return deltaY[0]; } @Override public int getDeltaY (int pointer) { return deltaY[pointer]; } @Override public void setCursorPosition (int x, int y) { } @Override public long getCurrentEventTime () { return currentEventTimeStamp; } @Override public void addKeyListener (OnKeyListener listener) { keyListeners.add(listener); } @Override public boolean onGenericMotion (View view, MotionEvent event) { if (mouseHandler.onGenericMotion(event, this)) return true; for (int i = 0, n = genericMotionListeners.size(); i < n; i++) if (genericMotionListeners.get(i).onGenericMotion(view, event)) return true; return false; } @Override public void addGenericMotionListener (OnGenericMotionListener listener) { genericMotionListeners.add(listener); } @Override public void onPause () { unregisterSensorListeners(); } @Override public void onResume () { registerSensorListeners(); } @Override public void onDreamingStarted () { registerSensorListeners(); } @Override public void onDreamingStopped () { unregisterSensorListeners(); } /** Our implementation of SensorEventListener. Because Android doesn't like it when we register more than one Sensor to a * single SensorEventListener, we add one of these for each Sensor. Could use an anonymous class, but I don't see any harm in * explicitly defining it here. Correct me if I am wrong. */ private class SensorListener implements SensorEventListener { public SensorListener () { } @Override public void onAccuracyChanged (Sensor arg0, int arg1) { } @Override public void onSensorChanged (SensorEvent event) { if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { if (nativeOrientation == Orientation.Portrait) { System.arraycopy(event.values, 0, accelerometerValues, 0, accelerometerValues.length); } else { accelerometerValues[0] = event.values[1]; accelerometerValues[1] = -event.values[0]; accelerometerValues[2] = event.values[2]; } } if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) { System.arraycopy(event.values, 0, magneticFieldValues, 0, magneticFieldValues.length); } if (event.sensor.getType() == Sensor.TYPE_GYROSCOPE) { if (nativeOrientation == Orientation.Portrait) { System.arraycopy(event.values, 0, gyroscopeValues, 0, gyroscopeValues.length); } else { gyroscopeValues[0] = event.values[1]; gyroscopeValues[1] = -event.values[0]; gyroscopeValues[2] = event.values[2]; } } if (event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) { if (nativeOrientation == Orientation.Portrait) { System.arraycopy(event.values, 0, rotationVectorValues, 0, rotationVectorValues.length); } else { rotationVectorValues[0] = event.values[1]; rotationVectorValues[1] = -event.values[0]; rotationVectorValues[2] = event.values[2]; } } } } }
-1
libgdx/libgdx
7,311
Set GdxSetup source level to java 8
Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
obigu
"2023-12-28T13:24:30"
"2023-12-28T19:35:04"
7f682a7921a47f0da858508f6b6fd58426dd05d7
449619e48dc25ce335c4003830e409aa69f5f3f7
Set GdxSetup source level to java 8. Since Java 21 (LTS) is the default version when downloading java, many users (specially new libGDX users) are complaining new projects don't work. Even if libGDX iOS backend doesn't fully support Java 8 language features (see https://github.com/libgdx/libgdx/issues/5487) at this point I think, until we decide on the approach to move forward, we should change Gdx Setup source level to 8 on all modules.
./extensions/gdx-box2d/gdx-box2d-gwt/build.gradle
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ dependencies { api libraries.gwt compileOnly libraries.compileOnly.gwt } configurations.all { // gwt-dev pulls in apache-jsp (Tomcat), but we don't need it and it messes with gretty exclude group: 'org.eclipse.jetty', module: 'apache-jsp' } sourceSets.main.java.exclude "**/System.java" eclipse { classpath { containers += [ 'com.google.gwt.eclipse.core.GWT_CONTAINER', 'com.gwtplugins.gwt.eclipse.core.GWT_CONTAINER' ] file { withXml { def node = it.asNode() // Collect nodes to modify def nodesToModify = [] node.children().each { c -> if (c.attribute('path').equals('src')) { nodesToModify << c } } // Modify the collected nodes nodesToModify.each { c -> def newAttrs = c.attributes().collectEntries { [(it.key): it.value] } newAttrs.put('excluding', 'com/badlogic/gdx/physics/box2d/gwt/emu/') def newNode = new Node(c.parent(), c.name(), newAttrs) c.children().each { child -> newNode.append(child) } c.replaceNode(newNode) } // Add second classpath entry for emu folder if not exists def emuNodes = node.children().findAll { it.name() == 'classpathentry' && it.'@path'.equals('src/com/badlogic/gdx/physics/box2d/gwt/emu/')} if (emuNodes.size() == 0) { node.appendNode('classpathentry', [ kind: 'src', path: 'src/com/badlogic/gdx/physics/box2d/gwt/emu/', excluding: 'java/lang/System.java' ]) } } } } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ dependencies { api libraries.gwt compileOnly libraries.compileOnly.gwt } configurations.all { // gwt-dev pulls in apache-jsp (Tomcat), but we don't need it and it messes with gretty exclude group: 'org.eclipse.jetty', module: 'apache-jsp' } sourceSets.main.java.exclude "**/System.java" eclipse { classpath { containers += [ 'com.google.gwt.eclipse.core.GWT_CONTAINER', 'com.gwtplugins.gwt.eclipse.core.GWT_CONTAINER' ] file { withXml { def node = it.asNode() // Collect nodes to modify def nodesToModify = [] node.children().each { c -> if (c.attribute('path').equals('src')) { nodesToModify << c } } // Modify the collected nodes nodesToModify.each { c -> def newAttrs = c.attributes().collectEntries { [(it.key): it.value] } newAttrs.put('excluding', 'com/badlogic/gdx/physics/box2d/gwt/emu/') def newNode = new Node(c.parent(), c.name(), newAttrs) c.children().each { child -> newNode.append(child) } c.replaceNode(newNode) } // Add second classpath entry for emu folder if not exists def emuNodes = node.children().findAll { it.name() == 'classpathentry' && it.'@path'.equals('src/com/badlogic/gdx/physics/box2d/gwt/emu/')} if (emuNodes.size() == 0) { node.appendNode('classpathentry', [ kind: 'src', path: 'src/com/badlogic/gdx/physics/box2d/gwt/emu/', excluding: 'java/lang/System.java' ]) } } } } }
-1
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
0
Edit dataset card