gdx-studio
git clone https://git.pyrossh.dev/gdx-studio
An IDE for creating Games using libgdx and Java supported on all platforms Android, iOS, Desktop
src/gdxstudio/panel/ProjectSettingsPanel.java
| a9b2a64 | 1 | package gdxstudio.panel; |
| a9b2a64 | 2 | |
| a9b2a64 | 3 | import gdxstudio.Content; |
| a9b2a64 | 4 | import gdxstudio.Export; |
| a9b2a64 | 5 | |
| a9b2a64 | 6 | import java.awt.event.ItemEvent; |
| a9b2a64 | 7 | import java.awt.event.ItemListener; |
| a9b2a64 | 8 | import java.io.File; |
| a9b2a64 | 9 | |
| a9b2a64 | 10 | import javax.swing.DefaultCellEditor; |
| a9b2a64 | 11 | import javax.swing.JComboBox; |
| a9b2a64 | 12 | |
| a9b2a64 | 13 | import scene2d.Scene; |
| a9b2a64 | 14 | |
| a9b2a64 | 15 | import com.badlogic.gdx.utils.JsonReader; |
| a9b2a64 | 16 | import com.badlogic.gdx.utils.JsonValue; |
| a9b2a64 | 17 | |
| a9b2a64 | 18 | public class ProjectSettingsPanel extends BaseTable {
|
| a9b2a64 | 19 | private static final long serialVersionUID = 1L; |
| a9b2a64 | 20 | String[] screenSizes = {
|
| a9b2a64 | 21 | "320x240", "480x320", "800x480", "852x480", "960x540", "1280x720", "1980x1080" |
| a9b2a64 | 22 | }; |
| a9b2a64 | 23 | String[] targetSizes = {
|
| a9b2a64 | 24 | "800x480" |
| a9b2a64 | 25 | }; |
| a9b2a64 | 26 | JComboBox<String> screenCombo = createComboBox(screenSizes); |
| a9b2a64 | 27 | JComboBox<String> targetCombo = createComboBox(targetSizes); |
| a9b2a64 | 28 | |
| a9b2a64 | 29 | public ProjectSettingsPanel(){
|
| a9b2a64 | 30 | super("Settings");
|
| a9b2a64 | 31 | editors.add(createTextFieldEditor()); |
| a9b2a64 | 32 | editors.add(new DefaultCellEditor(targetCombo)); |
| a9b2a64 | 33 | editors.add(new DefaultCellEditor(screenCombo)); |
| a9b2a64 | 34 | editors.add(createNumberField()); |
| a9b2a64 | 35 | editors.add(createCheckBoxEditor()); |
| a9b2a64 | 36 | editors.add(createCheckBoxEditor()); |
| a9b2a64 | 37 | editors.add(createCheckBoxEditor()); |
| a9b2a64 | 38 | editors.add(createCheckBoxEditor()); |
| a9b2a64 | 39 | editors.add(createCheckBoxEditor()); |
| a9b2a64 | 40 | editors.add(createCheckBoxEditor()); |
| a9b2a64 | 41 | editors.add(createCheckBoxEditor()); |
| a9b2a64 | 42 | editors.add(createCheckBoxEditor()); |
| a9b2a64 | 43 | editors.add(createCheckBoxEditor()); |
| a9b2a64 | 44 | editors.add(createCheckBoxEditor()); |
| a9b2a64 | 45 | editors.add(createCheckBoxEditor()); |
| a9b2a64 | 46 | if(Content.projectExists()) |
| a9b2a64 | 47 | update(); |
| a9b2a64 | 48 | screenCombo.addItemListener(new ItemListener(){
|
| a9b2a64 | 49 | @Override |
| a9b2a64 | 50 | public void itemStateChanged(ItemEvent e) {
|
| a9b2a64 | 51 | //String val[] = screenCombo.getSelectedItem().toString().split("x");
|
| a9b2a64 | 52 | //Content.studioPanel.setGdxScreenSize(Integer.parseInt(val[0]), Integer.parseInt(val[1])); |
| a9b2a64 | 53 | } |
| a9b2a64 | 54 | }); |
| a9b2a64 | 55 | } |
| a9b2a64 | 56 | |
| a9b2a64 | 57 | @Override |
| a9b2a64 | 58 | public void clear(String... items){
|
| a9b2a64 | 59 | super.clear("", "" ,"" ,"" ,"", "", "", "", "", "", "", "", "");
|
| a9b2a64 | 60 | } |
| a9b2a64 | 61 | |
| a9b2a64 | 62 | private static JsonValue jsonValue; |
| a9b2a64 | 63 | JsonReader jsonReader = new JsonReader(); |
| a9b2a64 | 64 | @Override |
| a9b2a64 | 65 | public void update(String... items){
|
| a9b2a64 | 66 | super.update(); |
| a9b2a64 | 67 | String text = Export.readFile("config");
|
| a9b2a64 | 68 | if(text.isEmpty()) |
| a9b2a64 | 69 | return; |
| a9b2a64 | 70 | jsonValue = jsonReader.parse(text); |
| a9b2a64 | 71 | addRow("Title", jsonValue.getString("title"));
|
| a9b2a64 | 72 | addRow("TargetSize", jsonValue.getString("targetSize"));
|
| a9b2a64 | 73 | addRow("ScreenSize", jsonValue.getString("screenSize"));
|
| a9b2a64 | 74 | addRow("AudioBufferCount", jsonValue.getString("audioBufferCount"));
|
| a9b2a64 | 75 | addRow("Resize", jsonValue.getBoolean("resize"));
|
| a9b2a64 | 76 | addRow("ForceExit", jsonValue.getBoolean("forceExit"));
|
| a9b2a64 | 77 | addRow("FullScreen", jsonValue.getBoolean("fullScreen"));
|
| a9b2a64 | 78 | addRow("UseGL20", jsonValue.getBoolean("useGL20"));
|
| a9b2a64 | 79 | addRow("VSync", jsonValue.getBoolean("vSync"));
|
| a9b2a64 | 80 | addRow("DisableAudio", jsonValue.getBoolean("disableAudio"));
|
| a9b2a64 | 81 | addRow("KeepAspectRatio", jsonValue.getBoolean("keepAspectRatio"));
|
| a9b2a64 | 82 | addRow("ShowFPS", jsonValue.getBoolean("showFPS"));
|
| a9b2a64 | 83 | addRow("LoggingEnabled", jsonValue.getBoolean("loggingEnabled"));
|
| a9b2a64 | 84 | ProjectPanel.updateProperty("Version", jsonValue.getString("version"));
|
| a9b2a64 | 85 | ProjectPanel.updateProperty("Target", jsonValue.getString("target"));
|
| a9b2a64 | 86 | /*createRow(content3, "Use Accelerometer", new WebSwitch()); |
| a9b2a64 | 87 | createRow(content3, "Use Compass", new WebSwitch()); |
| a9b2a64 | 88 | createRow(content3, "Use WakeLock", new WebSwitch()); |
| a9b2a64 | 89 | createRow(content3, "Hide Status Bar", new WebSwitch());*/ |
| a9b2a64 | 90 | } |
| a9b2a64 | 91 | |
| a9b2a64 | 92 | @Override |
| a9b2a64 | 93 | public void setProperty(String key, String value) {
|
| a9b2a64 | 94 | if(key.isEmpty() && value.isEmpty()){
|
| a9b2a64 | 95 | return; |
| a9b2a64 | 96 | } |
| a9b2a64 | 97 | jsonValue.get("hasIcon").set(new File(Content.getProject()+"icon.png").exists());
|
| a9b2a64 | 98 | jsonValue.get(Scene.uncapitalize(key)).set(value); |
| a9b2a64 | 99 | Export.writeFile("config", jsonValue.toString());
|
| a9b2a64 | 100 | } |
| a9b2a64 | 101 | |
| a9b2a64 | 102 | public void updateVersion(String version){
|
| a9b2a64 | 103 | jsonValue.get("version").set(version);
|
| a9b2a64 | 104 | Export.writeFile("config", jsonValue.toString());
|
| a9b2a64 | 105 | } |
| a9b2a64 | 106 | |
| a9b2a64 | 107 | public void updateTarget(String target){
|
| a9b2a64 | 108 | jsonValue.get("target").set(target);
|
| a9b2a64 | 109 | Export.writeFile("config", jsonValue.toString());
|
| a9b2a64 | 110 | } |
| a9b2a64 | 111 | |
| a9b2a64 | 112 | static String jsonizeArray(Object[] array){
|
| a9b2a64 | 113 | StringBuilder sb = new StringBuilder(); |
| a9b2a64 | 114 | for(Object s: array){
|
| a9b2a64 | 115 | sb.append(s.toString().trim()); |
| a9b2a64 | 116 | sb.append(",");
|
| a9b2a64 | 117 | } |
| a9b2a64 | 118 | sb.deleteCharAt(sb.lastIndexOf(","));
|
| a9b2a64 | 119 | return sb.toString(); |
| a9b2a64 | 120 | } |
| a9b2a64 | 121 | } |