├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── build.gradle ├── gdx-setup.png ├── gradle.properties ├── raw ├── color-picker-bar-selector.png ├── color-picker-cross.png ├── color-picker-selector-horizontal.png ├── color-picker-selector-vertical.png ├── cursor.9.png ├── default.png ├── font-small.png ├── icon-arrow-down.png ├── icon-arrow-left.png ├── icon-arrow-right.png ├── icon-arrow-up.png ├── icon-close.png ├── icon-drive.png ├── icon-file-audio.png ├── icon-file-image.png ├── icon-file-pdf.png ├── icon-file-text.png ├── icon-folder-new.png ├── icon-folder-parent.png ├── icon-folder-star.png ├── icon-folder.png ├── icon-list-settings.png ├── icon-minus.png ├── icon-refresh.png ├── icon-star-outline.png ├── icon-star.png ├── icon-trash.png ├── libgdx.png ├── pack.json ├── t-base.9.png ├── t-border-circle.png ├── t-border.9.png ├── t-check-tick.png ├── t-check.png ├── t-dot.png ├── t-hknob.png ├── t-hline.png ├── t-hslider.png ├── t-radio-tick.png ├── t-radio.png ├── t-select-down.png ├── t-select-up.png ├── t-select.9.png ├── t-tree-minus.png ├── t-tree-plus.png ├── t-vknob.png ├── t-vline.png ├── t-vslider.png ├── t-window-border.9.png ├── t-window-resize.9.png └── t-window.9.png ├── src └── main │ ├── kotlin │ └── com │ │ └── github │ │ └── czyzby │ │ └── setup │ │ ├── actions │ │ └── global.kt │ │ ├── application.kt │ │ ├── config │ │ ├── configuration.kt │ │ └── versioning.kt │ │ ├── data │ │ ├── files │ │ │ ├── projectFile.kt │ │ │ ├── propertiesFile.kt │ │ │ └── settingsFile.kt │ │ ├── gradle │ │ │ ├── gradleFile.kt │ │ │ └── rootGradle.kt │ │ ├── langs │ │ │ ├── groovy.kt │ │ │ ├── java.kt │ │ │ ├── kotlin.kt │ │ │ ├── language.kt │ │ │ └── scala.kt │ │ ├── libs │ │ │ ├── library.kt │ │ │ ├── official │ │ │ │ └── officialExtensions.kt │ │ │ └── unofficial │ │ │ │ ├── ktx.kt │ │ │ │ ├── lml.kt │ │ │ │ ├── squidLib.kt │ │ │ │ ├── thirdPartyExtensions.kt │ │ │ │ └── vis.kt │ │ ├── platforms │ │ │ ├── android.kt │ │ │ ├── assets.kt │ │ │ ├── core.kt │ │ │ ├── desktop.kt │ │ │ ├── gwt.kt │ │ │ ├── headless.kt │ │ │ ├── iOS.kt │ │ │ ├── lwjgl3.kt │ │ │ ├── moe.kt │ │ │ ├── platform.kt │ │ │ ├── server.kt │ │ │ └── shared.kt │ │ ├── project │ │ │ └── project.kt │ │ └── templates │ │ │ ├── ktxTemplate.kt │ │ │ ├── official │ │ │ ├── applicationAdapter.kt │ │ │ ├── applicationListener.kt │ │ │ ├── classic.kt │ │ │ ├── empty.kt │ │ │ ├── game.kt │ │ │ ├── inputProcessor.kt │ │ │ ├── ktxClassic.kt │ │ │ └── scene2d.kt │ │ │ ├── template.kt │ │ │ └── unofficial │ │ │ ├── autumnMvcBasic.kt │ │ │ ├── autumnMvcBox2d.kt │ │ │ ├── autumnMvcVis.kt │ │ │ ├── kiwi.kt │ │ │ ├── kiwiInput.kt │ │ │ ├── lml.kt │ │ │ ├── noise4j.kt │ │ │ ├── squidLibBasic.kt │ │ │ ├── viseditorBasic.kt │ │ │ ├── visuiBasic.kt │ │ │ ├── visuiShowcase.kt │ │ │ └── webSocketBasic.kt │ │ ├── main.kt │ │ ├── prefs │ │ ├── abstractStringPreference.kt │ │ ├── androidSdkPreference.kt │ │ ├── gradleTasksPreference.kt │ │ ├── gradleWrapperPreference.kt │ │ ├── gwtVersionPreference.kt │ │ ├── mainClassPreference.kt │ │ ├── packagePreference.kt │ │ ├── sdkVersionPreference.kt │ │ └── toolsVersionPreference.kt │ │ └── views │ │ ├── advanced.kt │ │ ├── basicData.kt │ │ ├── dialogs │ │ ├── deletionPrompt.kt │ │ └── generationPrompt.kt │ │ ├── extensions.kt │ │ ├── languages.kt │ │ ├── mainView.kt │ │ ├── platforms.kt │ │ ├── templates.kt │ │ └── widgets │ │ └── scrollableTextArea.kt │ └── resources │ ├── generator │ ├── android │ │ ├── ic_launcher-web.png │ │ ├── proguard-project.txt │ │ ├── project.properties │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── styles.xml │ ├── assets │ │ └── ui │ │ │ └── skin.json │ ├── gitignore │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── gwt │ │ └── webapp │ │ │ ├── WEB-INF │ │ │ └── web.xml │ │ │ ├── index.html │ │ │ ├── refresh.png │ │ │ ├── soundmanager2-jsmin.js │ │ │ ├── soundmanager2-jsmin_old.js │ │ │ ├── soundmanager2-setup.js │ │ │ └── styles.css │ ├── ios-moe │ │ └── xcode │ │ │ ├── ios-moe-Test │ │ │ ├── Info.plist │ │ │ └── main.cpp │ │ │ └── ios-moe │ │ │ ├── Info.plist │ │ │ ├── custom.xcconfig │ │ │ └── main.cpp │ ├── ios │ │ ├── Info.plist.xml │ │ └── data │ │ │ ├── Default-1024w-1366h@2x~ipad.png │ │ │ ├── Default-375w-667h@2x.png │ │ │ ├── Default-414w-736h@3x.png │ │ │ ├── Default-568h@2x.png │ │ │ ├── Default.png │ │ │ ├── Default@2x.png │ │ │ ├── Default@2x~ipad.png │ │ │ ├── Default~ipad.png │ │ │ ├── Icon-72.png │ │ │ ├── Icon-72@2x.png │ │ │ ├── Icon.png │ │ │ └── Icon@2x.png │ ├── raw │ │ └── ui │ │ │ ├── check-on.png │ │ │ ├── check.png │ │ │ ├── dot.png │ │ │ ├── knob-h.png │ │ │ ├── knob-v.png │ │ │ ├── line-h.png │ │ │ ├── line-v.png │ │ │ ├── pack.json │ │ │ ├── rect.png │ │ │ ├── select.9.png │ │ │ ├── skin.usl │ │ │ ├── square.png │ │ │ ├── tree-minus.png │ │ │ ├── tree-plus.png │ │ │ ├── window-border.9.png │ │ │ └── window-resize.9.png │ └── templates │ │ ├── autumn │ │ ├── box2d │ │ │ ├── bundle.properties │ │ │ ├── bundle_en.properties │ │ │ ├── bundle_pl.properties │ │ │ ├── dialogs │ │ │ │ ├── controls.lml │ │ │ │ ├── edit.lml │ │ │ │ ├── inactive.lml │ │ │ │ ├── settings.lml │ │ │ │ └── switch.lml │ │ │ ├── game.lml │ │ │ ├── loading.lml │ │ │ ├── macros │ │ │ │ └── global.lml │ │ │ └── menu.lml │ │ ├── bundle.properties │ │ ├── bundle_en.properties │ │ ├── bundle_pl.properties │ │ └── theme.ogg │ │ ├── classic │ │ └── badlogic.png │ │ ├── ktxClassic │ │ └── ktx-logo.png │ │ ├── libgdx.png │ │ ├── squidLib │ │ ├── Inconsolata-LGC-Custom-distance.fnt │ │ └── Inconsolata-LGC-Custom-distance.png │ │ └── viseditor │ │ ├── exported │ │ ├── gfx │ │ │ ├── icon.png │ │ │ ├── libgdx.png │ │ │ └── plus.png │ │ ├── scene │ │ │ └── example.scene │ │ ├── textures.atlas │ │ └── textures.png │ │ └── project │ │ ├── assets │ │ ├── gfx │ │ │ ├── icon.png │ │ │ ├── libgdx.png │ │ │ └── plus.png │ │ └── scene │ │ │ └── example.scene │ │ ├── modules │ │ ├── settings │ │ │ └── exportSettings │ │ └── version.json │ │ └── project.json │ ├── i18n │ ├── nls.properties │ ├── nls_en.properties │ └── nls_pl.properties │ ├── icons │ ├── libgdx128.png │ ├── libgdx16.png │ ├── libgdx32.png │ └── libgdx64.png │ ├── skin │ ├── default.fnt │ ├── font-small.fnt │ ├── tinted.atlas │ ├── tinted.json │ └── tinted.png │ └── templates │ ├── basicData.lml │ ├── dialogs │ ├── delete.lml │ ├── deleteError.lml │ └── generation.lml │ ├── header.lml │ ├── macros.lml │ ├── main.lml │ ├── tabs │ ├── advanced.lml │ ├── extensions.lml │ ├── languages.lml │ ├── platforms.lml │ ├── templates.lml │ └── thirdParty.lml │ └── toast.lml └── version.txt /.gitignore: -------------------------------------------------------------------------------- 1 | ## Based on default LibGDX project settings. 2 | 3 | ## Java 4 | *.class 5 | *.war 6 | *.ear 7 | hs_err_pid* 8 | 9 | ## GWT 10 | war/ 11 | html/war/gwt_bree/ 12 | html/gwt-unitCache/ 13 | .apt_generated/ 14 | html/war/WEB-INF/deploy/ 15 | html/war/WEB-INF/classes/ 16 | .gwt/ 17 | gwt-unitCache/ 18 | www-test/ 19 | .gwt-tmp/ 20 | 21 | ## Android Studio, IntelliJ, Android 22 | android/libs/armeabi/ 23 | android/libs/armeabi-v7a/ 24 | android/libs/x86/ 25 | android/gen/ 26 | .idea/ 27 | *.ipr 28 | *.iws 29 | *.iml 30 | out/ 31 | com_crashlytics_export_strings.xml 32 | 33 | ## Eclipse 34 | .classpath 35 | .project 36 | .metadata 37 | **/bin/ 38 | tmp/ 39 | *.tmp 40 | *.bak 41 | *.swp 42 | *~.nib 43 | local.properties 44 | .settings/ 45 | .loadpath 46 | .externalToolBuilders/ 47 | *.launch 48 | 49 | ## Gradle 50 | .gradle 51 | gradle-app.setting 52 | build/ 53 | 54 | ## OS-specific, others 55 | .DS_Store 56 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Don't be afraid to create issues with requests and questions! It's OK to create an issue if: 2 | 3 | - Some extension version is outdated. 4 | - We're too lazy to update to the latest LibGDX. 5 | - A (somewhat stable) third-party extension is missing. 6 | - An interesting game dev-related Java library could be added as third-party extension. 7 | - You'd like to propose a new project template, but you don't want to bother with pull requests. 8 | - You've found a bug or just got a general question. 9 | 10 | Note that all Kotlin sources should be formatted with the default Kotlin IntelliJ formatter. 11 | 12 | ### Adding a new third-party extension 13 | 14 | Open `thirdPartyExtensions.kt`. Create a new class implementing `ThirdPartyExtension`. Annotate it with `@Extension` - 15 | it will be automatically scanned for and initiated, you don't have to register it anywhere else in Kotlin sources. 16 | Choose a unique ID, default version and contact URL. Override `initiateDependencies` to include libraries and GWT 17 | inherits of the extensions. Add `yourLibId` line in `nls.properties` (displayed name of the library) and `yourLibIdTip` 18 | in all other NLS files (tooltips with library description). If you're unable to translate the tip in some language, 19 | make sure to mention it in the issue or pull request. 20 | 21 | ### Adding a new JVM language support 22 | 23 | Open `langs` package. Create a new file with a new class implementing `Language`. Annotate it with `@JvmLanguage`. 24 | Choose a unique language ID and proposed runtime library version. Override `initiate` method to include language 25 | support in the project. Add `langId` line (official language name) and `langIdUrl` (official language website) 26 | in `nls.properties`. Note that you might have to include some third-party Gradle plugins. 27 | 28 | ### Adding a new sources template 29 | 30 | Open `templates` package. Create a new file in `unofficial` package with a new class implementing `Template`. 31 | Annotate it with `@ProjectTemplate`. Choose a unique ID. Implement `getApplicationListenerContent` - 32 | provide source code of `ApplicationListener` implementation. If you need to add additional files or modify 33 | the project structure itself, override `apply` method. Add `templateId` line (default template name) in 34 | `nls.properties` and `templateIdTip` in every other NLS file (template description). 35 | 36 | ### Providing a new translation 37 | 38 | Copy `nls.properties` file. Add ID of your language to its name, for example: `nls_en.properties`. Delete all lines 39 | up to `### THESE LINES SHOULD BE TRANSLATED:`. Translate all other bundle lines. If you think any additional lines 40 | from the `nls.properties` should be translated as well (like template names), copy and translate them in your new file: 41 | they will be overridden. Find `availableLocales` variable in `configuration.kt` and add your language ID. Add line 42 | matching your language ID to `nls.properties` with the language's native name. Note that special characters should 43 | be escaped - for example, `ó` should be entered as `\u00F3` to ensure that it works without any problems on every 44 | platform. Eclipse IDE should automatically convert these characters as you type them in. IntelliJ users can check 45 | *"Transparent native-to-ascii conversion"* in *Settings* and use integrated I18N bundle editor to achieve this. 46 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ``` 2 |   3 |   4 |   5 |   6 |   7 |   8 |   9 |   10 | ``` 11 | 12 | # Disclaimer 13 | 14 | This project is no longer maintained. Please use the official LibGDX setup tool or the [gdx-liftoff](https://github.com/tommyettinger/gdx-liftoff) application instead, which is an updated fork of this project. 15 | 16 | ``` 17 |   18 |   19 |   20 |   21 |   22 |   23 |   24 |   25 | ``` 26 | 27 | # gdx-setup 28 | 29 | This project was meant to be a replacement for the official `gdx-setup` application. 30 | 31 | Additionally to supporting most official `gdx-setup` features, you might want to consider switching because of: 32 | - Project templates. You can choose the initial generated sources of the project - you're no longer forced to use 33 | `ApplicationAdapter` and *BadLogic* logo. (No offence, guys!) 34 | - Input validation. Your project data is validated as you type it in. 35 | - Other JVM languages support. You can choose additional languages for your project - their runtime libraries, 36 | Gradle plugins and source folders will be included. 37 | - Assets folder is now in the root directory and is properly linked by all projects. No more missing resources for 38 | the desktop project. 39 | - Much more settings. You have more control over the versions of software used by your application. 40 | - More third-party extensions. Much, much more. 41 | - Preferences, favorites. Basic data of your application is saved, so you don't have to fill it each time 42 | you generate a project. File chooser allows you to add your "favorite" workspace folders. 43 | - Internationalization. The application can be translated to different languages. It's currently available 44 | in English and Polish. 45 | - Gradle wrapper and running Gradle tasks after generation is entirely optional. This can significantly speed up 46 | the generation process and limit the project size if you'd prefer to use a globally installed Gradle application. 47 | - There are no major *structural differences* between any generated projects, regardless of the platforms 48 | you initially used. Official `gdx-setup` puts assets in `android` or - if Android platform is not supported - 49 | `core` folders. If you don't start with the Android platform, adding it to an existing project would require 50 | a lot of moving around and modifying Gradle scripts. Usually you'd be better off just generating a new project 51 | and moving the code. On contrary, this application puts `assets` in the *root* folder - adding a new platform 52 | to an existing application *never* requires you to modify any of the other platforms, you just have to add 53 | the new project to `settings.gradle` and create its directory. 54 | 55 | ### Running the application 56 | 57 | Stable application versions are uploaded to the [releases section](https://github.com/czyzby/gdx-setup/releases). 58 | 59 | *Pro tip*: check the `Generate skin assets` option in `Advanced` tab and `Desktop` in `Platforms` tab. 60 | Enter `pack desktop:run --daemon` Gradle tasks in `Advanced` tab. Delete project directory with the trash icon 61 | after each run. Now you can easily test all project templates one by one. Find the one that suits you best. 62 | 63 | ![gdx-setup](gdx-setup.png) 64 | 65 | #### Running from sources 66 | 67 | ``` 68 | git clone https://github.com/czyzby/gdx-setup.git 69 | cd gdx-setup 70 | gradle run 71 | ``` 72 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'kotlin' 2 | apply plugin: 'application' 3 | 4 | buildscript { 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" 10 | classpath "com.badlogicgames.gdx:gdx-tools:$gdxVersion" 11 | } 12 | } 13 | 14 | version = "$gdxVersion-SNAPSHOT" 15 | mainClassName = 'com.github.czyzby.setup.MainKt' 16 | 17 | jar { 18 | manifest { 19 | attributes 'Main-Class': mainClassName 20 | } 21 | from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } 22 | } 23 | 24 | repositories { 25 | mavenLocal() 26 | jcenter() 27 | mavenCentral() 28 | maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } 29 | } 30 | 31 | dependencies { 32 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" 33 | compile "org.apache.commons:commons-exec:$commonsExecVersion" 34 | 35 | compile "com.badlogicgames.gdx:gdx:$gdxVersion" 36 | compile "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" 37 | compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" 38 | 39 | compile "com.github.czyzby:gdx-autumn-mvc:$autumnVersion" 40 | compile "com.github.czyzby:gdx-autumn-fcs:$autumnVersion" 41 | compile "com.github.czyzby:gdx-lml-vis:$autumnVersion" 42 | } 43 | 44 | task pack << { 45 | com.badlogic.gdx.tools.texturepacker.TexturePacker.process( 46 | file("raw").absolutePath, 47 | file("src/main/resources/skin").absolutePath, 48 | "tinted" 49 | ) 50 | } 51 | -------------------------------------------------------------------------------- /gdx-setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/gdx-setup.png -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | kotlinVersion=1.2.60 2 | commonsExecVersion=1.3 3 | gdxVersion=1.9.8 4 | autumnVersion=1.8.1.9.4-b1 5 | -------------------------------------------------------------------------------- /raw/color-picker-bar-selector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/color-picker-bar-selector.png -------------------------------------------------------------------------------- /raw/color-picker-cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/color-picker-cross.png -------------------------------------------------------------------------------- /raw/color-picker-selector-horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/color-picker-selector-horizontal.png -------------------------------------------------------------------------------- /raw/color-picker-selector-vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/color-picker-selector-vertical.png -------------------------------------------------------------------------------- /raw/cursor.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/cursor.9.png -------------------------------------------------------------------------------- /raw/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/default.png -------------------------------------------------------------------------------- /raw/font-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/font-small.png -------------------------------------------------------------------------------- /raw/icon-arrow-down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-arrow-down.png -------------------------------------------------------------------------------- /raw/icon-arrow-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-arrow-left.png -------------------------------------------------------------------------------- /raw/icon-arrow-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-arrow-right.png -------------------------------------------------------------------------------- /raw/icon-arrow-up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-arrow-up.png -------------------------------------------------------------------------------- /raw/icon-close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-close.png -------------------------------------------------------------------------------- /raw/icon-drive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-drive.png -------------------------------------------------------------------------------- /raw/icon-file-audio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-file-audio.png -------------------------------------------------------------------------------- /raw/icon-file-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-file-image.png -------------------------------------------------------------------------------- /raw/icon-file-pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-file-pdf.png -------------------------------------------------------------------------------- /raw/icon-file-text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-file-text.png -------------------------------------------------------------------------------- /raw/icon-folder-new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-folder-new.png -------------------------------------------------------------------------------- /raw/icon-folder-parent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-folder-parent.png -------------------------------------------------------------------------------- /raw/icon-folder-star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-folder-star.png -------------------------------------------------------------------------------- /raw/icon-folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-folder.png -------------------------------------------------------------------------------- /raw/icon-list-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-list-settings.png -------------------------------------------------------------------------------- /raw/icon-minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-minus.png -------------------------------------------------------------------------------- /raw/icon-refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-refresh.png -------------------------------------------------------------------------------- /raw/icon-star-outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-star-outline.png -------------------------------------------------------------------------------- /raw/icon-star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-star.png -------------------------------------------------------------------------------- /raw/icon-trash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/icon-trash.png -------------------------------------------------------------------------------- /raw/libgdx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/libgdx.png -------------------------------------------------------------------------------- /raw/pack.json: -------------------------------------------------------------------------------- 1 | { 2 | duplicatePadding: false, 3 | paddingX: 1, 4 | paddingY: 1, 5 | stripWhitespaceX: true, 6 | stripWhitespaceY: true 7 | } -------------------------------------------------------------------------------- /raw/t-base.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-base.9.png -------------------------------------------------------------------------------- /raw/t-border-circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-border-circle.png -------------------------------------------------------------------------------- /raw/t-border.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-border.9.png -------------------------------------------------------------------------------- /raw/t-check-tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-check-tick.png -------------------------------------------------------------------------------- /raw/t-check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-check.png -------------------------------------------------------------------------------- /raw/t-dot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-dot.png -------------------------------------------------------------------------------- /raw/t-hknob.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-hknob.png -------------------------------------------------------------------------------- /raw/t-hline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-hline.png -------------------------------------------------------------------------------- /raw/t-hslider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-hslider.png -------------------------------------------------------------------------------- /raw/t-radio-tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-radio-tick.png -------------------------------------------------------------------------------- /raw/t-radio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-radio.png -------------------------------------------------------------------------------- /raw/t-select-down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-select-down.png -------------------------------------------------------------------------------- /raw/t-select-up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-select-up.png -------------------------------------------------------------------------------- /raw/t-select.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-select.9.png -------------------------------------------------------------------------------- /raw/t-tree-minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-tree-minus.png -------------------------------------------------------------------------------- /raw/t-tree-plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-tree-plus.png -------------------------------------------------------------------------------- /raw/t-vknob.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-vknob.png -------------------------------------------------------------------------------- /raw/t-vline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-vline.png -------------------------------------------------------------------------------- /raw/t-vslider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-vslider.png -------------------------------------------------------------------------------- /raw/t-window-border.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-window-border.9.png -------------------------------------------------------------------------------- /raw/t-window-resize.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-window-resize.9.png -------------------------------------------------------------------------------- /raw/t-window.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/czyzby/gdx-setup/da82263e56f671327d69b872a6a2fca1050b719a/raw/t-window.9.png -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/actions/global.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.actions 2 | 3 | import com.badlogic.gdx.Gdx 4 | import com.github.czyzby.autumn.mvc.stereotype.ViewActionContainer 5 | import com.github.czyzby.kiwi.util.common.Exceptions 6 | import com.github.czyzby.kiwi.util.common.Strings 7 | import com.github.czyzby.lml.annotation.LmlAction 8 | import com.github.czyzby.lml.parser.action.ActionContainer 9 | import com.kotcrab.vis.ui.widget.VisTextField 10 | 11 | 12 | /** 13 | * Contains actions available for all dialogs and views. 14 | * @author MJ 15 | */ 16 | @ViewActionContainer("global") 17 | class GlobalActionContainer : ActionContainer { 18 | @LmlAction("showSite") fun showLibGdxWebsite() = Gdx.net.openURI("http://libgdx.badlogicgames.com/") 19 | 20 | @LmlAction("fileNameFilter") 21 | fun isValidFileNameCharacter(character: Char): Boolean = Character.isDigit(character) || 22 | Character.isLetter(character) || character == '-' || character == '_' 23 | 24 | @LmlAction("isValidFile") 25 | fun isValidFileName(input: String): Boolean = Strings.isNotBlank(input) && input.matches(Regex("[-\\w]+")) 26 | 27 | @LmlAction("isSdk") 28 | fun isAndroidSdkDirectory(path: String): Boolean { 29 | try { 30 | val file = Gdx.files.absolute(path) 31 | if (file.isDirectory) { 32 | return file.child("tools").isDirectory && file.child("platforms").isDirectory 33 | } 34 | } catch(exception: Exception) { 35 | Exceptions.ignore(exception) // Probably not the Android SDK. 36 | } 37 | return false 38 | } 39 | 40 | @LmlAction("javaClassFilter") 41 | fun isValidJavaCharacter(character: Char): Boolean = Character.isJavaIdentifierPart(character) 42 | 43 | @LmlAction("javaPackageFilter") 44 | fun isValidJavaPackageCharacter(character: Char): Boolean = Character.isJavaIdentifierPart(character) || character == '.' 45 | 46 | @LmlAction("isValidClass") 47 | fun isValidClassName(input: String): Boolean { 48 | if (Strings.isBlank(input) || !Character.isJavaIdentifierStart(input[0])) { 49 | return false 50 | } else if (input.length == 1) { 51 | return true 52 | } 53 | for (id in 1..input.length - 1) { 54 | if (!Character.isJavaIdentifierPart(input[id])) { 55 | return false 56 | } 57 | } 58 | return true 59 | } 60 | 61 | @LmlAction("isValidPackage") 62 | fun isValidPackageName(input: String): Boolean { 63 | if (Strings.isBlank(input) || !Character.isJavaIdentifierStart(input[0]) || input.contains("..") || input.endsWith('.')) { 64 | return false 65 | } else if (input.length == 1) { 66 | return true 67 | } 68 | for (id in 1..input.length - 1) { 69 | if (!Character.isJavaIdentifierPart(input[id]) && input[id] != '.') { 70 | return false 71 | } 72 | } 73 | return true 74 | } 75 | 76 | @LmlAction("close") 77 | fun noOp() { 78 | // Empty dialog closing utility. 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/application.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup 2 | 3 | import com.kotcrab.vis.ui.util.OsUtils 4 | import org.apache.commons.exec.CommandLine 5 | import org.apache.commons.exec.DefaultExecuteResultHandler 6 | import org.apache.commons.exec.DefaultExecutor 7 | import org.apache.commons.exec.PumpStreamHandler 8 | import java.io.File 9 | import java.io.PrintWriter 10 | import java.io.StringWriter 11 | import java.lang.management.ManagementFactory 12 | 13 | /** 14 | * Application related utils. 15 | * @author Kotcrab 16 | */ 17 | object Application { 18 | /** 19 | * Starts new instance of application. This method is very flexible and supports starting new instance when 20 | * original application instance was launched via IDE (Intellij IDEA, Eclipse untested), using classpath or via jar. 21 | * After calling this original instance may exit safely. Output of new instance is NOT redirected to original instance 22 | * output streams. 23 | */ 24 | fun startNewInstance() { 25 | try { 26 | val cmdLine = CommandLine.parse(getRestartCommand()) 27 | val executor = DefaultExecutor() 28 | executor.streamHandler = PumpStreamHandler(null, null, null) 29 | executor.execute(cmdLine, DefaultExecuteResultHandler()) 30 | } catch (exception: Exception) { 31 | exception.printStackTrace() 32 | } 33 | } 34 | 35 | private fun getJavaBinPath(): String { 36 | if (OsUtils.isWindows()) { 37 | val javaBin = File(System.getProperty("java.home") + "/bin/java.exe") 38 | if (javaBin.exists()) { 39 | return "\"" + javaBin.absolutePath + "\"" 40 | } 41 | } 42 | 43 | return "java" 44 | } 45 | 46 | private fun getRestartCommand(): String { 47 | val vmArguments = ManagementFactory.getRuntimeMXBean().inputArguments 48 | val vmArgsOneLine = StringBuilder() 49 | 50 | if (OsUtils.isMac()) { 51 | vmArgsOneLine.append("-XstartOnFirstThread ") 52 | } 53 | 54 | for (arg in vmArguments) { 55 | if (arg.contains("-agentlib") == false) { 56 | vmArgsOneLine.append(arg).append(" ") 57 | } 58 | } 59 | 60 | val cmd = StringBuilder(getJavaBinPath() + " " + vmArgsOneLine) 61 | 62 | val mainCommand = System.getProperty("sun.java.command").split(" ") 63 | 64 | if (mainCommand[0].endsWith(".jar")) 65 | cmd.append("-jar " + File(mainCommand[0]).path) 66 | else 67 | cmd.append("-cp \"" + System.getProperty("java.class.path") + "\" " + mainCommand[0]) 68 | 69 | for (i in 1..mainCommand.size - 1) { 70 | cmd.append(" ") 71 | cmd.append(mainCommand[i]) 72 | } 73 | 74 | //if launching from idea, not in debug mode 75 | val ideaLauncher = "-Didea.launcher.bin.path=" 76 | val ideaLauncherStart = cmd.indexOf(ideaLauncher) 77 | if (ideaLauncherStart != -1) { 78 | cmd.insert(ideaLauncherStart + ideaLauncher.length, "\"") 79 | cmd.insert(cmd.indexOf("-cp ", ideaLauncherStart) - 1, "\"") 80 | } 81 | 82 | return cmd.toString() 83 | } 84 | } 85 | 86 | fun Throwable.stackTraceToString(): String { 87 | val sw = StringWriter() 88 | val pw = PrintWriter(sw, true) 89 | this.printStackTrace(pw) 90 | return sw.buffer.toString() 91 | } 92 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/config/configuration.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.config 2 | 3 | import com.badlogic.gdx.Gdx 4 | import com.badlogic.gdx.scenes.scene2d.Actor 5 | import com.github.czyzby.autumn.annotation.Component 6 | import com.github.czyzby.autumn.annotation.Initiate 7 | import com.github.czyzby.autumn.mvc.component.i18n.LocaleService 8 | import com.github.czyzby.autumn.mvc.component.ui.InterfaceService 9 | import com.github.czyzby.autumn.mvc.component.ui.SkinService 10 | import com.github.czyzby.autumn.mvc.config.AutumnActionPriority 11 | import com.github.czyzby.autumn.mvc.stereotype.preference.* 12 | import com.github.czyzby.lml.parser.LmlParser 13 | import com.github.czyzby.lml.parser.tag.LmlAttribute 14 | import com.github.czyzby.lml.parser.tag.LmlTag 15 | import com.github.czyzby.lml.vis.parser.impl.VisLmlSyntax 16 | import com.github.czyzby.lml.vis.parser.impl.nongwt.ExtendedVisLml 17 | import com.github.czyzby.setup.views.widgets.ScrollableTextArea 18 | import com.kotcrab.vis.ui.Locales 19 | import com.kotcrab.vis.ui.VisUI 20 | import com.kotcrab.vis.ui.widget.Tooltip 21 | import com.kotcrab.vis.ui.widget.VisLabel 22 | import com.kotcrab.vis.ui.widget.file.FileChooser 23 | 24 | /** 25 | * Configures Autumn MVC application. 26 | * @author MJ 27 | */ 28 | @Component 29 | class Configuration { 30 | companion object { 31 | const val VERSION = "1.9.8-SNAPSHOT" 32 | const val WIDTH = 600 33 | const val HEIGHT = 670 34 | const val PREFERENCES_PATH = "gdx-setup-prefs" 35 | } 36 | 37 | @LmlParserSyntax val syntax = VisLmlSyntax() 38 | @LmlMacro val macro = "templates/macros.lml" 39 | 40 | @I18nBundle val bundle = "i18n/nls" 41 | @I18nLocale(propertiesPath = PREFERENCES_PATH, defaultLocale = "en") val localePreference = "locale" 42 | @AvailableLocales val availableLocales = arrayOf("en", "pl") 43 | @Preference val preferencesPath = PREFERENCES_PATH; 44 | 45 | @Initiate(priority = AutumnActionPriority.TOP_PRIORITY) 46 | fun initiate(skinService: SkinService, interfaceService: InterfaceService, localeService: LocaleService) { 47 | VisUI.setSkipGdxVersionCheck(true) 48 | VisUI.load(Gdx.files.internal("skin/tinted.json")) 49 | skinService.addSkin("default", VisUI.getSkin()) 50 | FileChooser.setDefaultPrefsName(PREFERENCES_PATH) 51 | 52 | // Adding tags and attributes related to the file chooser: 53 | ExtendedVisLml.registerFileChooser(syntax) 54 | ExtendedVisLml.registerFileValidators(syntax) 55 | // Adding custom ScrollableTextArea widget: 56 | syntax.addTagProvider(ScrollableTextArea.ScrollableTextAreaLmlTagProvider(), "console") 57 | 58 | // Changing FileChooser locale bundle: 59 | interfaceService.setActionOnBundlesReload { 60 | Locales.setFileChooserBundle(localeService.i18nBundle) 61 | } 62 | 63 | // Adding custom tooltip tag attribute: 64 | interfaceService.parser.syntax.addAttributeProcessor(object : LmlAttribute { 65 | override fun getHandledType(): Class = Actor::class.java 66 | override fun process(parser: LmlParser, tag: LmlTag, actor: Actor, rawAttributeData: String) { 67 | val tooltip = Tooltip() 68 | val label = VisLabel(parser.parseString(rawAttributeData, actor), "small") 69 | label.setWrap(true) 70 | tooltip.clear() 71 | tooltip.add(label).width(200f) 72 | tooltip.pad(3f) 73 | tooltip.setTarget(actor) 74 | tooltip.pack() 75 | } 76 | }, "tooltip") 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/config/versioning.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.config 2 | 3 | /** 4 | * Used to represent and compare LibGDX versions using major.minor.revision schema. 5 | */ 6 | data class LibGdxVersion( 7 | val major: Int, 8 | val minor: Int, 9 | val revision: Int 10 | ) : Comparable { 11 | override operator fun compareTo(other: LibGdxVersion) = 12 | compareValuesBy(this, other, { it.major }, { it.minor }, { it.revision }) 13 | 14 | companion object { 15 | fun parseLibGdxVersion(version: String): LibGdxVersion? { 16 | val trimmed = version.trim().removeSuffix("-SNAPSHOT") 17 | val parts = trimmed.split('.') 18 | return if (parts.size != 3 || parts.any { it.toIntOrNull() == null }) { 19 | null 20 | } else { 21 | LibGdxVersion(parts[0].toInt(), parts[1].toInt(), parts[2].toInt()) 22 | } 23 | } 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/files/projectFile.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.files 2 | 3 | import com.badlogic.gdx.Files 4 | import com.badlogic.gdx.Gdx 5 | import com.badlogic.gdx.files.FileHandle 6 | import com.github.czyzby.kiwi.util.common.Strings 7 | import java.io.File 8 | 9 | /** 10 | * Common interface of files generated or copied during project creation. 11 | * @author MJ 12 | */ 13 | interface ProjectFile { 14 | /** 15 | * Relative path to the project file. 16 | */ 17 | val path: String 18 | 19 | /** 20 | * Saves the file at the chosen location. 21 | * @param destination project root folder. 22 | */ 23 | fun save(destination: FileHandle) 24 | } 25 | 26 | /** 27 | * Represents a directory with source files. 28 | * @author MJ 29 | */ 30 | open class SourceDirectory(val projectName: String, val sourcePath: String = path("src", "main", "java")) : ProjectFile { 31 | override val path: String 32 | 33 | init { 34 | path = projectName + File.separator + sourcePath 35 | } 36 | 37 | override fun save(destination: FileHandle) { 38 | destination.child(path).mkdirs() 39 | } 40 | } 41 | 42 | fun path(vararg directories: String) = directories.joinToString(separator = File.separator) 43 | 44 | /** 45 | * Base class for source files. 46 | * @author MJ 47 | */ 48 | open class SourceFile private constructor(val content: String, override val path: String) : ProjectFile { 49 | /** 50 | * @param content content of the source file. 51 | * @param projectName name of the project to which the file should be appended. Optional. 52 | * @param sourceFolderPath path of the source in the selected project. Defaults to "src/main/java". 53 | * @param packageName name of the package of the source file. Optional. 54 | * @param fileName name of the source file. For example, "Content.java". 55 | */ 56 | constructor(content: String, projectName: String, sourceFolderPath: String = path("src", "main", "java"), 57 | packageName: String, fileName: String) 58 | : this(content, toRelativePath(projectName, sourceFolderPath, packageName, fileName)) 59 | 60 | /** 61 | * @param content content of the source file. 62 | * @param projectName name of the project to which the file should be appended. Optional. 63 | * @param fileName name of the source file. For example, "Content.java". 64 | */ 65 | constructor(content: String, projectName: String, fileName: String) 66 | : this(content, if (projectName.isBlank()) { 67 | fileName 68 | } else { 69 | path(projectName, fileName) 70 | }) 71 | 72 | override fun save(destination: FileHandle) { 73 | destination.child(path).writeString(content, false, "UTF-8") 74 | } 75 | } 76 | 77 | fun toRelativePath(projectName: String, sourceFolderPath: String, packageName: String, fileName: String): String { 78 | if (projectName.isEmpty() && sourceFolderPath.isEmpty() && packageName.isEmpty()) { 79 | return fileName 80 | } 81 | return "${if (Strings.isNotBlank(projectName)) { 82 | projectName + File.separator 83 | } else { 84 | Strings.EMPTY_STRING 85 | }}$sourceFolderPath${File.separator}${if (Strings.isNotBlank(packageName)) { 86 | packageName.replace('.', File.separatorChar) + File.separator 87 | } else { 88 | Strings.EMPTY_STRING 89 | }}$fileName" 90 | } 91 | 92 | /** 93 | * Base class for copied project resources. 94 | * @author MJ 95 | */ 96 | open class CopiedFile private constructor(override val path: String, val original: String, val fileType: Files.FileType) : ProjectFile { 97 | /** 98 | * @param projectName name of the project which should contain the file. 99 | * @param path relative path inside the project with the exact file location. 100 | * @param original internal path to the resource. 101 | */ 102 | constructor(projectName: String = "", path: String, original: String, fileType: Files.FileType = Files.FileType.Internal) : 103 | this(if (projectName.isNotEmpty()) { 104 | projectName + File.separator 105 | } else { 106 | "" 107 | } + path, original, fileType) 108 | 109 | override fun save(destination: FileHandle) { 110 | Gdx.files.getFileHandle(original, fileType).copyTo(destination.child(path)) 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/files/propertiesFile.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.files 2 | 3 | import com.badlogic.gdx.files.FileHandle 4 | 5 | /** 6 | * Saves gradle.properties file. 7 | * @author MJ 8 | */ 9 | class PropertiesFile(val properties: Map) : ProjectFile { 10 | override val path = "gradle.properties" 11 | 12 | override fun save(destination: FileHandle) { 13 | val content = properties.map { it.key + "=" + it.value }.joinToString(separator = "\n") 14 | destination.child(path).writeString(content, false, "UTF-8") 15 | } 16 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/files/settingsFile.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.files 2 | 3 | import com.badlogic.gdx.files.FileHandle 4 | import com.github.czyzby.setup.data.platforms.Platform 5 | 6 | /** 7 | * Creates settings.gradle file. 8 | * @author MJ 9 | */ 10 | class SettingsFile(val platforms: Iterable) : ProjectFile { 11 | override val path = "settings.gradle" 12 | override fun save(destination: FileHandle) { 13 | val content = platforms.joinToString(prefix = "include ", separator = ", ") { "'${it.id}'" } 14 | destination.child(path).writeString(content, false, "UTF-8") 15 | } 16 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/gradle/gradleFile.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.gradle 2 | 3 | import com.badlogic.gdx.files.FileHandle 4 | import com.github.czyzby.setup.data.files.ProjectFile 5 | import java.io.File 6 | 7 | abstract class GradleFile private constructor(override val path: String) : ProjectFile { 8 | val buildDependencies = mutableSetOf() 9 | val dependencies = mutableSetOf() 10 | 11 | constructor(projectName: String, fileName: String = "build.gradle") : this(if (projectName.isNotEmpty()) { 12 | projectName + File.separator 13 | } else { 14 | "" 15 | } + fileName) 16 | 17 | fun joinDependencies(dependencies: Collection, type: String = "compile", tab: String = " "): String = if (dependencies.isEmpty()) "" else 18 | dependencies.joinToString(prefix = "$tab$type ", separator = "\n$tab$type ", postfix = "\n") 19 | 20 | /** 21 | * @param dependency will be added as "compile" dependency, quoted. 22 | */ 23 | fun addDependency(dependency: String) = dependencies.add("\"$dependency\"") 24 | 25 | override fun save(destination: FileHandle) { 26 | destination.child(path).writeString(getContent(), false, "UTF-8") 27 | } 28 | 29 | abstract fun getContent(): String 30 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/gradle/rootGradle.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.gradle 2 | 3 | import com.github.czyzby.setup.data.platforms.Android 4 | import com.github.czyzby.setup.data.project.Project 5 | 6 | /** 7 | * Gradle file of the root project. Manages build script and global settings. 8 | * @author MJ 9 | */ 10 | class RootGradleFile(val project: Project) : GradleFile("") { 11 | val plugins = mutableSetOf() 12 | val buildRepositories = mutableSetOf() 13 | 14 | init { 15 | buildDependencies.add("\"com.badlogicgames.gdx:gdx-tools:\$gdxVersion\"") 16 | buildRepositories.add("mavenLocal()") 17 | buildRepositories.add("mavenCentral()") 18 | buildRepositories.add("jcenter()") 19 | buildRepositories.add("google()") 20 | buildRepositories.add("maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }") 21 | } 22 | 23 | override fun getContent(): String = """buildscript { 24 | repositories { 25 | ${buildRepositories.joinToString(separator = "\n") { " $it" }} 26 | } 27 | dependencies { 28 | ${joinDependencies(buildDependencies, type = "classpath", tab = " ")} } 29 | } 30 | 31 | allprojects { 32 | apply plugin: 'eclipse' 33 | apply plugin: 'idea' 34 | } 35 | 36 | configure(subprojects${if (project.hasPlatform(Android.ID)) { 37 | " - project(':android')" 38 | } else { 39 | "" 40 | }}) { 41 | ${plugins.joinToString(separator = "\n") { " apply plugin: '$it'" }} 42 | sourceCompatibility = ${project.advanced.javaVersion} 43 | } 44 | 45 | subprojects { 46 | version = '${project.advanced.version}' 47 | ext.appName = '${project.basic.name}' 48 | repositories { 49 | mavenLocal() 50 | mavenCentral() 51 | jcenter() 52 | google() 53 | maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } 54 | } 55 | } 56 | 57 | // Clearing Eclipse project data in root folder: 58 | tasks.eclipse.doLast { 59 | delete '.project' 60 | delete '.classpath' 61 | delete '.settings/' 62 | } 63 | """ 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/langs/groovy.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.langs 2 | 3 | import com.github.czyzby.setup.data.files.SourceDirectory 4 | import com.github.czyzby.setup.data.files.path 5 | import com.github.czyzby.setup.data.project.Project 6 | import com.github.czyzby.setup.views.JvmLanguage 7 | 8 | /** 9 | * Adds Groovy support to the project. 10 | * @author MJ 11 | */ 12 | @JvmLanguage 13 | class Groovy : Language { 14 | override val id = "groovy" 15 | override val version = "2.4.+" 16 | 17 | override fun initiate(project: Project) { 18 | project.rootGradle.plugins.add(id) 19 | project.platforms.values.forEach { project.files.add(SourceDirectory(it.id, path("src", "main", "groovy"))) } 20 | addDependency(project, "org.codehaus.groovy:groovy-all:\$groovyVersion") 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/langs/java.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.langs 2 | 3 | import com.github.czyzby.setup.data.files.SourceDirectory 4 | import com.github.czyzby.setup.data.files.path 5 | import com.github.czyzby.setup.data.project.Project 6 | 7 | /** 8 | * Adds Java support to the project. 9 | * @author MJ 10 | */ 11 | class Java : Language { 12 | override val id = "java" 13 | override val version = "1.6" 14 | 15 | override fun initiate(project: Project) { 16 | project.rootGradle.plugins.add(id) 17 | project.platforms.values.forEach { project.files.add(SourceDirectory(it.id, path("src", "main", "java"))) } 18 | } 19 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/langs/kotlin.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.langs 2 | 3 | import com.github.czyzby.setup.data.files.SourceDirectory 4 | import com.github.czyzby.setup.data.files.path 5 | import com.github.czyzby.setup.data.platforms.Android 6 | import com.github.czyzby.setup.data.platforms.AndroidGradleFile 7 | import com.github.czyzby.setup.data.project.Project 8 | import com.github.czyzby.setup.views.JvmLanguage 9 | 10 | /** 11 | * Adds Kotlin support to the project. 12 | * @author MJ 13 | */ 14 | @JvmLanguage 15 | class Kotlin : Language { 16 | override val id = "kotlin" 17 | override val version = "1.1.+" 18 | 19 | override fun initiate(project: Project) { 20 | project.rootGradle.buildDependencies.add("\"org.jetbrains.kotlin:kotlin-gradle-plugin:\$kotlinVersion\"") 21 | project.rootGradle.plugins.add(id) 22 | project.platforms.values.forEach { project.files.add(SourceDirectory(it.id, path("src", "main", "kotlin"))) } 23 | if (project.hasPlatform(Android.ID)) { 24 | val gradleFile = project.getGradleFile(Android.ID) as AndroidGradleFile 25 | gradleFile.plugins.add("kotlin-android") 26 | } 27 | addDependency(project, "org.jetbrains.kotlin:kotlin-stdlib:\$kotlinVersion") 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/langs/language.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.langs 2 | 3 | import com.github.czyzby.setup.data.platforms.Core 4 | import com.github.czyzby.setup.data.platforms.Shared 5 | import com.github.czyzby.setup.data.project.Project 6 | 7 | /** 8 | * Common interface for additional JVM languages. If the language is optional, its class should be annotated with 9 | * JvmLanguage. 10 | * @author MJ 11 | */ 12 | interface Language { 13 | val id: String 14 | val version: String 15 | 16 | /** 17 | * Adds language-specific dependencies and plugins. 18 | * @param project is being generated. 19 | */ 20 | fun initiate(project: Project) 21 | 22 | fun addDependency(project: Project, dependency: String) { 23 | project.getGradleFile(Core.ID).addDependency(dependency) 24 | if (project.hasPlatform(Shared.ID)) { 25 | project.getGradleFile(Shared.ID).addDependency(dependency) 26 | } 27 | if (project.hasPlatform(Shared.ID)) { 28 | project.getGradleFile(Shared.ID).addDependency(dependency) 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/langs/scala.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.langs 2 | 3 | import com.github.czyzby.setup.data.files.SourceDirectory 4 | import com.github.czyzby.setup.data.files.path 5 | import com.github.czyzby.setup.data.project.Project 6 | import com.github.czyzby.setup.views.JvmLanguage 7 | 8 | /** 9 | * Adds Scala support to the project. 10 | * @author MJ 11 | */ 12 | @JvmLanguage 13 | class Scala : Language { 14 | override val id = "scala" 15 | override val version = "2.12.+" 16 | 17 | override fun initiate(project: Project) { 18 | project.rootGradle.plugins.add(id) 19 | project.platforms.values.forEach { project.files.add(SourceDirectory(it.id, path("src", "main", "scala"))) } 20 | addDependency(project, "org.scala-lang:scala-library:\$scalaVersion") 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/libs/library.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.libs 2 | 3 | import com.github.czyzby.setup.data.platforms.* 4 | import com.github.czyzby.setup.data.project.Project 5 | 6 | /** 7 | * Interface shared by all LibGDX extensions. 8 | * @author MJ 9 | */ 10 | interface Library { 11 | val id: String 12 | val defaultVersion: String 13 | val url: String 14 | val official: Boolean 15 | 16 | /** 17 | * @param project is currently generated and should have this library included. 18 | */ 19 | fun initiate(project: Project) 20 | 21 | fun addDependency(project: Project, platform: String, dependency: String) { 22 | if (project.hasPlatform(platform)) { 23 | project.getGradleFile(platform).addDependency(dependency) 24 | } 25 | } 26 | 27 | fun addDesktopDependency(project: Project, dependency: String) { 28 | arrayOf(Desktop.ID, LWJGL3.ID).forEach { addDependency(project, it, dependency) } 29 | } 30 | 31 | fun addNativeAndroidDependency(project: Project, dependency: String) { 32 | if (project.hasPlatform(Android.ID)) { 33 | val gradle = project.getGradleFile(Android.ID) as AndroidGradleFile 34 | gradle.addNativeDependency(dependency) 35 | } 36 | } 37 | 38 | fun addNativeMoeDependency(project: Project, dependency: String) { 39 | if (project.hasPlatform(MOE.ID)) { 40 | val gradle = project.getGradleFile(MOE.ID) as MOEGradleFile 41 | gradle.addNativeDependency(dependency) 42 | } 43 | } 44 | 45 | fun addGwtInherit(project: Project, inherit: String) { 46 | if (project.hasPlatform(GWT.ID)) { 47 | project.gwtInherits.add(inherit) 48 | } 49 | } 50 | 51 | fun addAndroidPermission(project: Project, permissionName: String) { 52 | if (project.hasPlatform(Android.ID)) { 53 | project.androidPermissions.add(permissionName) 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/libs/unofficial/squidLib.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.libs.unofficial 2 | 3 | import com.github.czyzby.setup.data.platforms.Core 4 | import com.github.czyzby.setup.data.platforms.GWT 5 | import com.github.czyzby.setup.data.project.Project 6 | import com.github.czyzby.setup.views.Extension 7 | 8 | /** 9 | * Version of SquidLib libraries. 10 | * @author SquidPony 11 | */ 12 | const val SQUID_LIB_VERSION = "3.0.0-b8" 13 | 14 | /** 15 | * URL of SquidLib libraries. 16 | * @author SquidPony 17 | */ 18 | const val SQUID_LIB_URL = "https://github.com/SquidPony/SquidLib" 19 | 20 | /** 21 | * Cross-platform regex utilities. 22 | * @author Tommy Ettinger 23 | */ 24 | @Extension 25 | class RegExodus : ThirdPartyExtension() { 26 | override val id = "regExodus" 27 | override val defaultVersion = "0.1.9" 28 | override val url = "https://github.com/tommyettinger/RegExodus" 29 | 30 | override fun initiateDependencies(project: Project) { 31 | addDependency(project, Core.ID, "com.github.tommyettinger:regexodus") 32 | 33 | addDependency(project, GWT.ID, "com.github.tommyettinger:regexodus:sources") 34 | addGwtInherit(project, "regexodus") 35 | } 36 | } 37 | 38 | /** 39 | * Utility for grid-based games. 40 | * @author SquidPony 41 | */ 42 | @Extension 43 | class SquidLibUtil : ThirdPartyExtension() { 44 | override val id = "squidLibUtil" 45 | override val defaultVersion = SQUID_LIB_VERSION 46 | override val url = SQUID_LIB_URL 47 | 48 | override fun initiateDependencies(project: Project) { 49 | addDependency(project, Core.ID, "com.squidpony:squidlib-util") 50 | 51 | addDependency(project, GWT.ID, "com.squidpony:squidlib-util:sources") 52 | addGwtInherit(project, "squidlib-util") 53 | 54 | RegExodus().initiate(project) 55 | } 56 | } 57 | 58 | /** 59 | * Utility for roguelike games. 60 | * @author SquidPony 61 | */ 62 | @Extension 63 | class SquidLib : ThirdPartyExtension() { 64 | override val id = "squidLib" 65 | override val defaultVersion = SQUID_LIB_VERSION 66 | override val url = SQUID_LIB_URL 67 | 68 | override fun initiateDependencies(project: Project) { 69 | addDependency(project, Core.ID, "com.squidpony:squidlib") 70 | 71 | addDependency(project, GWT.ID, "com.squidpony:squidlib:sources") 72 | addGwtInherit(project, "squidlib") 73 | 74 | SquidLibUtil().initiate(project) 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/libs/unofficial/vis.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.libs.unofficial 2 | 3 | import com.github.czyzby.setup.data.platforms.Core 4 | import com.github.czyzby.setup.data.platforms.GWT 5 | import com.github.czyzby.setup.data.platforms.Headless 6 | import com.github.czyzby.setup.data.project.Project 7 | import com.github.czyzby.setup.views.Extension 8 | 9 | /** 10 | * UI toolkit. 11 | * @author Kotcrab 12 | */ 13 | @Extension 14 | class VisUI : ThirdPartyExtension() { 15 | override val id = "visUi" 16 | override val defaultVersion = "1.3.0" 17 | override val url = "https://github.com/kotcrab/VisEditor/wiki/VisUI" 18 | 19 | override fun initiateDependencies(project: Project) { 20 | addDependency(project, Core.ID, "com.kotcrab.vis:vis-ui") 21 | 22 | addDependency(project, GWT.ID, "com.kotcrab.vis:vis-ui:sources") 23 | addGwtInherit(project, "com.kotcrab.vis.vis-ui") 24 | } 25 | } 26 | 27 | /** 28 | * VisEditor runtime. 29 | * @author Kotcrab 30 | */ 31 | @Extension 32 | class VisRuntime : ThirdPartyExtension() { 33 | override val id = "visRuntime" 34 | override val defaultVersion = "0.3.4" 35 | override val url = "https://vis.kotcrab.com" 36 | 37 | override fun initiateDependencies(project: Project) { 38 | addDependency(project, Core.ID, "com.kotcrab.vis:vis-runtime") 39 | 40 | addDependency(project, GWT.ID, "com.kotcrab.vis:vis-runtime-gwt") 41 | addDependency(project, GWT.ID, "com.kotcrab.vis:vis-runtime-gwt:sources") 42 | addDependency(project, GWT.ID, "com.kotcrab.vis:vis-runtime:sources") 43 | addGwtInherit(project, "com.kotcrab.vis.vis-runtime") 44 | 45 | ArtemisOdb().initiate(project) 46 | project.properties["artemisOdbVersion"] = "1.3.1" 47 | } 48 | } 49 | 50 | /** 51 | * UI styling language extension. 52 | * @author Kotcrab 53 | */ 54 | @Extension 55 | class USL : ThirdPartyExtension() { 56 | override val id = "usl" 57 | override val defaultVersion = "0.2.1" 58 | override val url = "https://github.com/kotcrab/vis-editor/wiki/USL" 59 | 60 | override fun initiateDependencies(project: Project) { 61 | project.rootGradle.buildDependencies.add("\"com.kotcrab.vis:vis-usl:\$uslVersion\""); 62 | 63 | addDependency(project, Headless.ID, "com.kotcrab.vis.vis-usl") 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/platforms/assets.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.platforms 2 | 3 | import com.github.czyzby.setup.data.gradle.GradleFile 4 | import com.github.czyzby.setup.data.project.Project 5 | 6 | /** 7 | * Mock-up platform. Represents assets folder. 8 | * @author MJ 9 | */ 10 | class Assets : Platform { 11 | companion object { 12 | const val ID = "assets" 13 | } 14 | 15 | override val id = ID 16 | override val isGraphical = false 17 | 18 | override fun createGradleFile(project: Project): GradleFile = 19 | throw UnsupportedOperationException("This is a mock-up project with no Gradle file.") 20 | 21 | override fun initiate(project: Project) = 22 | throw UnsupportedOperationException("This is a mock-up project which should not be initiated.") 23 | } 24 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/platforms/core.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.platforms 2 | 3 | import com.github.czyzby.setup.data.gradle.GradleFile 4 | import com.github.czyzby.setup.data.project.Project 5 | import com.github.czyzby.setup.views.GdxPlatform 6 | 7 | /** 8 | * Represents core application's project, used by all backends. 9 | * @author MJ 10 | */ 11 | @GdxPlatform 12 | class Core : Platform { 13 | companion object { 14 | const val ID = "core" 15 | } 16 | 17 | override val id = ID 18 | override val isGraphical = false 19 | override fun createGradleFile(project: Project): GradleFile { 20 | return CoreGradleFile() 21 | } 22 | 23 | override fun initiate(project: Project) { 24 | // Core has no external dependencies by default. 25 | } 26 | } 27 | 28 | /** 29 | * Gradle file of the core project. Should contain all multi-platform dependencies, like "gdx" itself. 30 | * @author MJ 31 | */ 32 | class CoreGradleFile : GradleFile(Core.ID) { 33 | init { 34 | addDependency("com.badlogicgames.gdx:gdx:\$gdxVersion") 35 | } 36 | 37 | override fun getContent(): String { 38 | return """[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' 39 | eclipse.project.name = appName + '-core' 40 | 41 | dependencies { 42 | ${joinDependencies(dependencies)}} 43 | """; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/platforms/desktop.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.platforms 2 | 3 | import com.github.czyzby.setup.data.files.CopiedFile 4 | import com.github.czyzby.setup.data.files.path 5 | import com.github.czyzby.setup.data.gradle.GradleFile 6 | import com.github.czyzby.setup.data.project.Project 7 | import com.github.czyzby.setup.views.GdxPlatform 8 | 9 | /** 10 | * Represents Desktop backend. 11 | * @author MJ 12 | */ 13 | @GdxPlatform 14 | class Desktop : Platform { 15 | companion object { 16 | const val ID = "desktop" 17 | } 18 | 19 | override val id = ID 20 | 21 | override fun createGradleFile(project: Project): GradleFile = DesktopGradleFile(project) 22 | 23 | override fun initiate(project: Project) { 24 | // Adding game icons: 25 | arrayOf(16, 32, 64, 128) 26 | .map { "libgdx${it}.png" } 27 | .forEach { icon -> 28 | project.files.add(CopiedFile(projectName = ID, path = path("src", "main", "resources", icon), 29 | original = path("icons", icon))) 30 | } 31 | 32 | addGradleTaskDescription(project, "run", "starts the application.") 33 | addGradleTaskDescription(project, "jar", "builds application's runnable jar, which can be found at `${id}/build/libs`.") 34 | } 35 | } 36 | 37 | /** 38 | * Gradle file of the desktop project. 39 | * @author MJ 40 | */ 41 | class DesktopGradleFile(val project: Project) : GradleFile(Desktop.ID) { 42 | init { 43 | dependencies.add("project(':${Core.ID}')") 44 | addDependency("com.badlogicgames.gdx:gdx-backend-lwjgl:\$gdxVersion") 45 | addDependency("com.badlogicgames.gdx:gdx-platform:\$gdxVersion:natives-desktop") 46 | } 47 | 48 | override fun getContent(): String = """apply plugin: 'application' 49 | 50 | sourceSets.main.resources.srcDirs += [ rootProject.file('assets').absolutePath ] 51 | mainClassName = '${project.basic.rootPackage}.desktop.DesktopLauncher' 52 | eclipse.project.name = appName + '-desktop' 53 | sourceCompatibility = ${project.advanced.desktopJavaVersion} 54 | 55 | dependencies { 56 | ${joinDependencies(dependencies)}} 57 | 58 | jar { 59 | archiveName "${'$'}{appName}-${'$'}{version}.jar" 60 | from { configurations.compile.collect { zipTree(it) } } 61 | manifest { 62 | attributes 'Main-Class': project.mainClassName 63 | } 64 | } 65 | 66 | run { 67 | ignoreExitValue = true 68 | } 69 | """ 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/platforms/headless.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.platforms 2 | 3 | import com.github.czyzby.setup.data.gradle.GradleFile 4 | import com.github.czyzby.setup.data.project.Project 5 | import com.github.czyzby.setup.views.GdxPlatform 6 | 7 | /** 8 | * Represents headless application project. 9 | * @author MJ 10 | */ 11 | @GdxPlatform 12 | class Headless : Platform { 13 | companion object { 14 | const val ID = "headless" 15 | } 16 | 17 | override val id = ID 18 | override val isGraphical = false 19 | 20 | override fun createGradleFile(project: Project): GradleFile = HeadlessGradleFile(project) 21 | 22 | override fun initiate(project: Project) { 23 | // Headless project has no additional dependencies. 24 | 25 | addGradleTaskDescription(project, "run", "starts the ${id} application. Note: if ${id} sources were not modified - and the application still creates `ApplicationListener` from `core` project - this task might fail due to no graphics support.") 26 | } 27 | } 28 | 29 | /** 30 | * Represents the Gradle file of the headless project. Allows to set up a different Java version and launch the application 31 | * with "run" task. 32 | * @author MJ 33 | */ 34 | class HeadlessGradleFile(val project: Project) : GradleFile(Headless.ID) { 35 | init { 36 | dependencies.add("project(':${Core.ID}')") 37 | addDependency("com.badlogicgames.gdx:gdx-backend-headless:\$gdxVersion") 38 | addDependency("com.badlogicgames.gdx:gdx-platform:\$gdxVersion:natives-desktop") 39 | } 40 | 41 | override fun getContent(): String = """apply plugin: 'application' 42 | 43 | sourceCompatibility = ${project.advanced.serverJavaVersion} 44 | mainClassName = '${project.basic.rootPackage}.headless.HeadlessLauncher' 45 | eclipse.project.name = appName + '-headless' 46 | 47 | dependencies { 48 | ${joinDependencies(dependencies)}} 49 | """ 50 | } 51 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/platforms/iOS.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.platforms 2 | 3 | import com.github.czyzby.setup.data.files.CopiedFile 4 | import com.github.czyzby.setup.data.files.SourceFile 5 | import com.github.czyzby.setup.data.files.path 6 | import com.github.czyzby.setup.data.gradle.GradleFile 7 | import com.github.czyzby.setup.data.project.Project 8 | import com.github.czyzby.setup.views.GdxPlatform 9 | 10 | /** 11 | * Represents iOS backend. 12 | * @author MJ 13 | */ 14 | @GdxPlatform 15 | class iOS : Platform { 16 | companion object { 17 | const val ID = "ios" 18 | } 19 | 20 | override val id = ID 21 | 22 | override fun createGradleFile(project: Project): GradleFile = iOSGradleFile(project) 23 | override fun initiate(project: Project) { 24 | project.rootGradle.buildDependencies.add("\"com.mobidevelop.robovm:robovm-gradle-plugin:\$robovmVersion\"") 25 | project.properties["robovmVersion"] = project.advanced.robovmVersion 26 | 27 | // Including RoboVM config files: 28 | project.files.add(CopiedFile(projectName = ID, path = "Info.plist.xml", 29 | original = path("generator", "ios", "Info.plist.xml"))) 30 | project.files.add(SourceFile(projectName = ID, fileName = "robovm.properties", content = """app.version=${project.advanced.version} 31 | app.id=${project.basic.rootPackage} 32 | app.mainclass=${project.basic.rootPackage}.ios.IOSLauncher 33 | app.executable=IOSLauncher 34 | app.build=1 35 | app.name=${project.basic.name}""")) 36 | project.files.add(SourceFile(projectName = ID, fileName = "robovm.xml", content = """ 37 | ${'$'}{app.executable} 38 | ${'$'}{app.mainclass} 39 | ios 40 | thumbv7 41 | ios 42 | Info.plist.xml 43 | 44 | 45 | ../assets 46 | 47 | ** 48 | 49 | true 50 | 51 | 52 | data 53 | 54 | 55 | 56 | com.badlogic.gdx.scenes.scene2d.ui.* 57 | com.badlogic.gdx.graphics.g3d.particles.** 58 | com.android.okhttp.HttpHandler 59 | com.android.okhttp.HttpsHandler 60 | com.android.org.conscrypt.** 61 | com.android.org.bouncycastle.jce.provider.BouncyCastleProvider 62 | com.android.org.bouncycastle.jcajce.provider.keystore.BC${'$'}Mappings 63 | com.android.org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi 64 | com.android.org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi${'$'}Std 65 | com.android.org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi 66 | com.android.org.bouncycastle.crypto.digests.AndroidDigestFactoryOpenSSL 67 | org.apache.harmony.security.provider.cert.DRLCertFactory 68 | org.apache.harmony.security.provider.crypto.CryptoProvider 69 | 70 | 71 | z 72 | 73 | 74 | UIKit 75 | OpenGLES 76 | QuartzCore 77 | CoreGraphics 78 | OpenAL 79 | AudioToolbox 80 | AVFoundation 81 | 82 | """)) 83 | 84 | // Copying data images: 85 | arrayOf("Default.png", "Default@2x.png", "Default@2x~ipad.png", "Default-375w-667h@2x.png", 86 | "Default-414w-736h@3x.png", "Default-568h@2x.png", "Default-1024w-1366h@2x~ipad.png", 87 | "Default~ipad.png", "Icon.png", "Icon@2x.png", "Icon-72.png", "Icon-72@2x.png").forEach { 88 | project.files.add(CopiedFile(projectName = ID, path = path("data", it), 89 | original = path("generator", "ios", "data", it))) 90 | } 91 | 92 | // Including reflected classes: 93 | if (project.reflectedClasses.isNotEmpty() || project.reflectedPackages.isNotEmpty()) { 94 | project.files.add(SourceFile(projectName = ID, sourceFolderPath = path("src", "main", "resources"), 95 | packageName = "META-INF.robovm.ios", fileName = "robovm.xml", content = """ 96 | 97 | ${project.reflectedPackages.joinToString(separator = "\n") { " ${it}.**" }} 98 | ${project.reflectedClasses.joinToString(separator = "\n") { " ${it}" }} 99 | 100 | """)) 101 | } 102 | } 103 | } 104 | 105 | class iOSGradleFile(val project: Project) : GradleFile(iOS.ID) { 106 | init { 107 | dependencies.add("project(':${Core.ID}')") 108 | addDependency("com.mobidevelop.robovm:robovm-rt:\$robovmVersion") 109 | addDependency("com.mobidevelop.robovm:robovm-cocoatouch:\$robovmVersion") 110 | addDependency("com.badlogicgames.gdx:gdx-backend-robovm:\$gdxVersion") 111 | addDependency("com.badlogicgames.gdx:gdx-platform:\$gdxVersion:natives-ios") 112 | } 113 | 114 | override fun getContent() = """apply plugin: 'robovm' 115 | 116 | [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' 117 | 118 | ext { 119 | mainClassName = "${project.basic.rootPackage}.ios.IOSLauncher" 120 | } 121 | 122 | launchIPhoneSimulator.dependsOn build 123 | launchIPadSimulator.dependsOn build 124 | launchIOSDevice.dependsOn build 125 | createIPA.dependsOn build 126 | 127 | eclipse.project { 128 | name = appName + "-ios" 129 | natures 'org.robovm.eclipse.RoboVMNature' 130 | } 131 | 132 | dependencies { 133 | ${joinDependencies(dependencies)}} 134 | """ 135 | 136 | } 137 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/platforms/lwjgl3.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.platforms 2 | 3 | import com.github.czyzby.setup.data.files.CopiedFile 4 | import com.github.czyzby.setup.data.files.path 5 | import com.github.czyzby.setup.data.gradle.GradleFile 6 | import com.github.czyzby.setup.data.project.Project 7 | import com.github.czyzby.setup.views.GdxPlatform 8 | 9 | /** 10 | * Represents the LWJGL3 backend, which is likely to replace the default desktop platform some day. 11 | * @author MJ 12 | */ 13 | @GdxPlatform 14 | class LWJGL3 : Platform { 15 | companion object { 16 | const val ID = "lwjgl3" 17 | } 18 | 19 | override val id = ID 20 | override val isGraphical = false // LWJGL3 is an alternative to the default desktop project. 21 | override fun createGradleFile(project: Project): GradleFile = Lwjgl3GradleFile(project); 22 | override fun initiate(project: Project) { 23 | // Adding game icons: 24 | arrayOf(16, 32, 64, 128) 25 | .map { "libgdx${it}.png" } 26 | .forEach { icon -> 27 | project.files.add(CopiedFile(projectName = LWJGL3.ID, path = path("src", "main", "resources", icon), 28 | original = path("icons", icon))) 29 | } 30 | 31 | addGradleTaskDescription(project, "run", "starts the application.") 32 | addGradleTaskDescription(project, "jar", "builds application's runnable jar, which can be found at `${id}/build/libs`.") 33 | } 34 | } 35 | 36 | 37 | /** 38 | * Gradle file of the LWJGL3 project. 39 | * @author MJ 40 | */ 41 | class Lwjgl3GradleFile(val project: Project) : GradleFile(LWJGL3.ID) { 42 | init { 43 | dependencies.add("project(':${Core.ID}')") 44 | addDependency("com.badlogicgames.gdx:gdx-backend-lwjgl3:\$gdxVersion") 45 | addDependency("com.badlogicgames.gdx:gdx-platform:\$gdxVersion:natives-desktop") 46 | } 47 | 48 | override fun getContent(): String = """apply plugin: 'application' 49 | 50 | sourceSets.main.resources.srcDirs += [ rootProject.file('assets').absolutePath ] 51 | mainClassName = '${project.basic.rootPackage}.lwjgl3.Lwjgl3Launcher' 52 | eclipse.project.name = appName + '-lwjgl3' 53 | sourceCompatibility = ${project.advanced.desktopJavaVersion} 54 | 55 | dependencies { 56 | ${joinDependencies(dependencies)}} 57 | 58 | jar { 59 | archiveName "${'$'}{appName}-${'$'}{version}.jar" 60 | from { configurations.compile.collect { zipTree(it) } } 61 | manifest { 62 | attributes 'Main-Class': project.mainClassName 63 | } 64 | } 65 | """ 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/platforms/platform.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.platforms 2 | 3 | import com.badlogic.gdx.utils.ObjectMap 4 | import com.github.czyzby.autumn.annotation.Component 5 | import com.github.czyzby.autumn.annotation.Initiate 6 | import com.github.czyzby.autumn.mvc.config.AutumnActionPriority 7 | import com.github.czyzby.setup.data.files.CopiedFile 8 | import com.github.czyzby.setup.data.files.path 9 | import com.github.czyzby.setup.data.gradle.GradleFile 10 | import com.github.czyzby.setup.data.project.Project 11 | 12 | /** 13 | * Common interface for all supported platforms. Implementation should be annotated with GdxPlatform. 14 | * @author MJ 15 | */ 16 | interface Platform { 17 | /** 18 | * Unique ID of the platform. 19 | */ 20 | val id: String 21 | 22 | /** 23 | * This value is set to true if the platform is a standard graphical LibGDX backend. False otherwise. 24 | */ 25 | val isGraphical: Boolean 26 | get() = true 27 | 28 | /** 29 | * Creates a new gradle file used to manage this project's dependencies. 30 | * @param project requests the creation of file. 31 | */ 32 | fun createGradleFile(project: Project): GradleFile 33 | 34 | /** 35 | * This method is used to resolve additional dependencies in other projects. 36 | * @param project contains the platform. 37 | */ 38 | fun initiate(project: Project) 39 | 40 | fun addCopiedFile(project: Project, vararg file: String) { 41 | val originalFile = arrayOf("generator", id) + file 42 | project.files.add(CopiedFile(projectName = id, original = path(*originalFile), path = path(*file))) 43 | } 44 | 45 | fun addGradleTaskDescription(project: Project, task: String, description: String) { 46 | project.addGradleTaskDescription(id + ":" + task, description); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/platforms/server.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.platforms 2 | 3 | import com.github.czyzby.setup.data.gradle.GradleFile 4 | import com.github.czyzby.setup.data.project.Project 5 | import com.github.czyzby.setup.views.GdxPlatform 6 | 7 | /** 8 | * Represents server application project. 9 | * @author MJ 10 | */ 11 | @GdxPlatform 12 | class Server : Platform { 13 | companion object { 14 | const val ID = "server" 15 | } 16 | 17 | override val id = ID 18 | override val isGraphical = false 19 | 20 | override fun createGradleFile(project: Project): GradleFile = ServerGradleFile(project) 21 | 22 | override fun initiate(project: Project) { 23 | // Server project has no additional dependencies. 24 | 25 | addGradleTaskDescription(project, "run", "runs the ${id} application.") 26 | } 27 | } 28 | 29 | /** 30 | * Represents the Gradle file of server project. Allows to set up a different Java version and launch the application 31 | * with "run" task. 32 | * @author MJ 33 | */ 34 | class ServerGradleFile(val project: Project) : GradleFile(Server.ID) { 35 | override fun getContent(): String = """apply plugin: 'application' 36 | 37 | sourceCompatibility = ${project.advanced.serverJavaVersion} 38 | mainClassName = '${project.basic.rootPackage}.server.ServerLauncher' 39 | eclipse.project.name = appName + '-server' 40 | 41 | dependencies { 42 | ${joinDependencies(dependencies)}} 43 | 44 | jar { 45 | from { configurations.compile.collect { zipTree(it) } } 46 | manifest { 47 | attributes 'Main-Class': project.mainClassName 48 | } 49 | }""" 50 | } 51 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/platforms/shared.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.platforms 2 | 3 | import com.github.czyzby.setup.data.gradle.GradleFile 4 | import com.github.czyzby.setup.data.project.Project 5 | import com.github.czyzby.setup.views.GdxPlatform 6 | 7 | /** 8 | * Represents shared project, accessible by both client and server application. 9 | * @author MJ 10 | */ 11 | @GdxPlatform 12 | class Shared : Platform { 13 | companion object { 14 | const val ID = "shared" 15 | } 16 | 17 | override val id = ID 18 | override val isGraphical = false 19 | 20 | override fun createGradleFile(project: Project): GradleFile = SharedGradleFile(project) 21 | 22 | override fun initiate(project: Project) { 23 | project.getGradleFile(Core.ID).dependencies.add("project(':$id')") 24 | if (project.hasPlatform(Server.ID)) { 25 | project.getGradleFile(Server.ID).dependencies.add("project(':$id')") 26 | } 27 | if (project.hasPlatform(GWT.ID)) { 28 | // Including shared project sources in GWT platform: 29 | project.getGradleFile(GWT.ID).buildDependencies.add("project(':$id')") 30 | } 31 | } 32 | } 33 | 34 | /** 35 | * Represents shared project Gradle file. Should include dependencies that should be available for both server and 36 | * client applications. 37 | * @author MJ 38 | */ 39 | class SharedGradleFile(val project: Project) : GradleFile(Shared.ID) { 40 | override fun getContent(): String = """eclipse.project.name = appName + '-shared' 41 | 42 | dependencies { 43 | ${joinDependencies(dependencies)}} 44 | """ 45 | } 46 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/templates/ktxTemplate.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.templates 2 | 3 | import com.github.czyzby.setup.data.files.path 4 | import com.github.czyzby.setup.data.platforms.* 5 | import com.github.czyzby.setup.data.project.Project 6 | 7 | interface KtxTemplate : Template { 8 | 9 | override fun addApplicationListener(project: Project) { 10 | addSourceFile(project = project, platform = Core.ID, packageName = project.basic.rootPackage, 11 | fileName = "${project.basic.mainClass}.kt", content = getApplicationListenerContent(project), sourceFolderPath = path("src", "main", "kotlin")) 12 | } 13 | 14 | override fun addDesktopLauncher(project: Project) { 15 | addSourceFile(project = project, platform = Desktop.ID, packageName = "${project.basic.rootPackage}.desktop", 16 | fileName = "DesktopLauncher.kt", content = getDesktopLauncherContent(project), sourceFolderPath = path("src", "main", "kotlin")) 17 | } 18 | 19 | override fun getDesktopLauncherContent(project: Project): String = """@file:JvmName("DesktopLauncher") 20 | 21 | package ${project.basic.rootPackage}.desktop 22 | 23 | import com.badlogic.gdx.Files 24 | import com.badlogic.gdx.backends.lwjgl.LwjglApplication 25 | import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration 26 | 27 | import ${project.basic.rootPackage}.${project.basic.mainClass} 28 | 29 | /** Launches the desktop (LWJGL) application. */ 30 | fun main(args: Array) { 31 | LwjglApplication(${project.basic.mainClass}(), LwjglApplicationConfiguration().apply { 32 | title = "${project.basic.name}" 33 | width = $width 34 | height = $height 35 | resizable = false 36 | intArrayOf(128, 64, 32, 16).forEach{ 37 | addIcon("libgdx${"$"}it.png", Files.FileType.Internal) 38 | } 39 | }) 40 | } 41 | """ 42 | 43 | override fun addAndroidLauncher(project: Project) { 44 | addSourceFile(project = project, platform = Android.ID, packageName = "${project.basic.rootPackage}.android", 45 | fileName = "AndroidLauncher.kt", content = getAndroidLauncherContent(project), sourceFolderPath = path("src", "main", "kotlin")) 46 | } 47 | 48 | override fun getAndroidLauncherContent(project: Project): String = """package ${project.basic.rootPackage}.android 49 | 50 | import android.os.Bundle 51 | 52 | import com.badlogic.gdx.backends.android.AndroidApplication 53 | import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration 54 | import ${project.basic.rootPackage}.${project.basic.mainClass} 55 | 56 | /** Launches the Android application. */ 57 | class AndroidLauncher : AndroidApplication() { 58 | override fun onCreate(savedInstanceState: Bundle?) { 59 | super.onCreate(savedInstanceState) 60 | initialize(${project.basic.mainClass}(), AndroidApplicationConfiguration()) 61 | } 62 | } 63 | """ 64 | 65 | override fun addHeadlessLauncher(project: Project) { 66 | addSourceFile(project = project, platform = Headless.ID, packageName = "${project.basic.rootPackage}.headless", 67 | fileName = "HeadlessLauncher.kt", content = getHeadlessLauncherContent(project), sourceFolderPath = path("src", "main", "kotlin")) 68 | } 69 | 70 | override fun getHeadlessLauncherContent(project: Project): String = """@file:JvmName("HeadlessLauncher") 71 | 72 | package ${project.basic.rootPackage}.headless 73 | 74 | import com.badlogic.gdx.backends.headless.HeadlessApplication 75 | import com.badlogic.gdx.backends.headless.HeadlessApplicationConfiguration 76 | import ${project.basic.rootPackage}.${project.basic.mainClass} 77 | 78 | /** Launches the headless application. Can be converted into a utilities project or a server application. */ 79 | fun main(args: Array) { 80 | HeadlessApplication(${project.basic.mainClass}(), HeadlessApplicationConfiguration().apply { 81 | renderInterval = -1f 82 | }) 83 | } 84 | """ 85 | 86 | override fun addLwjgl3Launcher(project: Project) { 87 | addSourceFile(project = project, platform = LWJGL3.ID, packageName = "${project.basic.rootPackage}.lwjgl3", 88 | fileName = "Lwjgl3Launcher.kt", content = getLwjgl3LauncherContent(project), sourceFolderPath = path("src", "main", "kotlin")) 89 | } 90 | 91 | override fun getLwjgl3LauncherContent(project: Project): String = """@file:JvmName("Lwjgl3Launcher") 92 | 93 | package ${project.basic.rootPackage}.lwjgl3 94 | 95 | import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application 96 | import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration 97 | import ${project.basic.rootPackage}.${project.basic.mainClass} 98 | 99 | /** Launches the desktop (LWJGL3) application. */ 100 | fun main(args: Array) { 101 | Lwjgl3Application(${project.basic.mainClass}(), Lwjgl3ApplicationConfiguration().apply { 102 | setTitle("${project.basic.name}") 103 | setWindowedMode($width, $height) 104 | setResizable(false) 105 | setWindowIcon(*(arrayOf(128, 64, 32, 16).map { "libgdx${"$"}it.png" }.toTypedArray())) 106 | }) 107 | } 108 | """ 109 | } 110 | 111 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/templates/official/applicationAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.templates.official 2 | 3 | import com.github.czyzby.setup.data.project.Project 4 | import com.github.czyzby.setup.data.templates.Template 5 | import com.github.czyzby.setup.views.ProjectTemplate 6 | 7 | /** 8 | * Extends ApplicationAdapter, overriding no methods. Application does nothing. 9 | * @author MJ 10 | */ 11 | @ProjectTemplate(official = true) 12 | class ApplicationAdapterTemplate : Template { 13 | override val id = "applicationAdapter" 14 | override val description: String 15 | get() = "Project template included simple launchers and an empty `ApplicationAdapter` extension." 16 | 17 | override fun getApplicationListenerContent(project: Project): String = """package ${project.basic.rootPackage}; 18 | 19 | import com.badlogic.gdx.ApplicationAdapter; 20 | 21 | /** {@link com.badlogic.gdx.ApplicationListener} implementation shared by all platforms. */ 22 | public class ${project.basic.mainClass} extends ApplicationAdapter { 23 | }""" 24 | } 25 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/templates/official/applicationListener.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.templates.official 2 | 3 | import com.github.czyzby.setup.data.project.Project 4 | import com.github.czyzby.setup.data.templates.Template 5 | import com.github.czyzby.setup.views.ProjectTemplate 6 | 7 | /** 8 | * Adds empty implementation of all ApplicationListener methods. Application does nothing. 9 | * @author MJ 10 | */ 11 | @ProjectTemplate(official = true) 12 | class ApplicationListenerTemplate : Template { 13 | override val id = "applicationListener" 14 | override val description: String 15 | get() = "Project template included simple launchers and an empty `ApplicationListener` implementation." 16 | 17 | override fun getApplicationListenerContent(project: Project): String = """package ${project.basic.rootPackage}; 18 | 19 | import com.badlogic.gdx.ApplicationListener; 20 | 21 | /** {@link com.badlogic.gdx.ApplicationListener} implementation shared by all platforms. */ 22 | public class ${project.basic.mainClass} implements ApplicationListener { 23 | @Override 24 | public void create() { 25 | // Prepare your application here. 26 | } 27 | 28 | @Override 29 | public void resize(int width, int height) { 30 | // Resize your application here. The parameters represent the new window size. 31 | } 32 | 33 | @Override 34 | public void render() { 35 | // Draw your application here. 36 | } 37 | 38 | @Override 39 | public void pause() { 40 | // Invoked when your application is paused. 41 | } 42 | 43 | @Override 44 | public void resume() { 45 | // Invoked when your application is resumed after pause. 46 | } 47 | 48 | @Override 49 | public void dispose() { 50 | // Destroy application's resources here. 51 | } 52 | }""" 53 | } 54 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/templates/official/classic.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.templates.official 2 | 3 | import com.github.czyzby.setup.data.files.CopiedFile 4 | import com.github.czyzby.setup.data.files.path 5 | import com.github.czyzby.setup.data.platforms.Assets 6 | import com.github.czyzby.setup.data.project.Project 7 | import com.github.czyzby.setup.data.templates.Template 8 | import com.github.czyzby.setup.views.ProjectTemplate 9 | 10 | /** 11 | * Draws Badlogic Games logo at the center of the screen. 12 | * @author MJ 13 | * @author Original gdx-setup maintainers 14 | */ 15 | @ProjectTemplate(official = true) 16 | open class ClassicTemplate : Template { 17 | override val id = "classic" 18 | override val description: String 19 | get() = "Project template includes simple launchers and an `ApplicationAdapter` extension that draws BadLogic logo." 20 | 21 | override fun apply(project: Project) { 22 | super.apply(project) 23 | project.files.add(CopiedFile(projectName = Assets.ID, original = path("generator", "templates", "classic", 24 | "badlogic.png"), path = "badlogic.png")) 25 | } 26 | 27 | override fun getApplicationListenerContent(project: Project): String = """package ${project.basic.rootPackage}; 28 | 29 | import com.badlogic.gdx.ApplicationAdapter; 30 | import com.badlogic.gdx.Gdx; 31 | import com.badlogic.gdx.graphics.GL20; 32 | import com.badlogic.gdx.graphics.Texture; 33 | import com.badlogic.gdx.graphics.g2d.SpriteBatch; 34 | 35 | /** {@link com.badlogic.gdx.ApplicationListener} implementation shared by all platforms. */ 36 | public class ${project.basic.mainClass} extends ApplicationAdapter { 37 | private SpriteBatch batch; 38 | private Texture image; 39 | 40 | @Override 41 | public void create() { 42 | batch = new SpriteBatch(); 43 | image = new Texture("badlogic.png"); 44 | } 45 | 46 | @Override 47 | public void render() { 48 | Gdx.gl.glClearColor(1, 1, 1, 1); 49 | Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 50 | batch.begin(); 51 | batch.draw(image, 165, 180); 52 | batch.end(); 53 | } 54 | 55 | @Override 56 | public void dispose() { 57 | batch.dispose(); 58 | image.dispose(); 59 | } 60 | }""" 61 | } 62 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/templates/official/empty.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.templates.official 2 | 3 | import com.github.czyzby.setup.data.project.Project 4 | import com.github.czyzby.setup.data.templates.Template 5 | import com.github.czyzby.setup.views.ProjectTemplate 6 | 7 | /** 8 | * Generates no source files. 9 | * @author MJ 10 | */ 11 | @ProjectTemplate(official = true) 12 | class EmptyTemplate : Template { 13 | override val id = "emptyTemplate" 14 | override val description: String 15 | get() = "No sources were generated." 16 | 17 | override fun apply(project: Project) { 18 | // Does nothing. 19 | } 20 | 21 | override fun getApplicationListenerContent(project: Project): String = "" 22 | } 23 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/templates/official/game.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.templates.official 2 | 3 | import com.github.czyzby.setup.data.platforms.Core 4 | import com.github.czyzby.setup.data.project.Project 5 | import com.github.czyzby.setup.data.templates.Template 6 | import com.github.czyzby.setup.views.ProjectTemplate 7 | 8 | /** 9 | * Uses Game as ApplicationListener. Provides an example (empty) Screen implementation. 10 | * @author MJ 11 | */ 12 | @ProjectTemplate(official = true) 13 | class GameTemplate : Template { 14 | override val id = "gameTemplate" 15 | override val description: String 16 | get() = "Project template includes simple launchers and a `Game` extension that sets the first screen." 17 | 18 | override fun getApplicationListenerContent(project: Project): String = """package ${project.basic.rootPackage}; 19 | 20 | import com.badlogic.gdx.Game; 21 | 22 | /** {@link com.badlogic.gdx.ApplicationListener} implementation shared by all platforms. */ 23 | public class ${project.basic.mainClass} extends Game { 24 | @Override 25 | public void create() { 26 | setScreen(new FirstScreen()); 27 | } 28 | }""" 29 | 30 | override fun apply(project: Project) { 31 | super.apply(project) 32 | addSourceFile(project = project, platform = Core.ID, packageName = project.basic.rootPackage, 33 | fileName = "FirstScreen.java", content = """package ${project.basic.rootPackage}; 34 | 35 | import com.badlogic.gdx.Screen; 36 | 37 | /** First screen of the application. Displayed after the application is created. */ 38 | public class FirstScreen implements Screen { 39 | @Override 40 | public void show() { 41 | // Prepare your screen here. 42 | } 43 | 44 | @Override 45 | public void render(float delta) { 46 | // Draw your screen here. "delta" is the time since last render in seconds. 47 | } 48 | 49 | @Override 50 | public void resize(int width, int height) { 51 | // Resize your screen here. The parameters represent the new window size. 52 | } 53 | 54 | @Override 55 | public void pause() { 56 | // Invoked when your application is paused. 57 | } 58 | 59 | @Override 60 | public void resume() { 61 | // Invoked when your application is resumed after pause. 62 | } 63 | 64 | @Override 65 | public void hide() { 66 | // This method is called when another screen replaces this one. 67 | } 68 | 69 | @Override 70 | public void dispose() { 71 | // Destroy screen's assets here. 72 | } 73 | }""") 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/templates/official/inputProcessor.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.templates.official 2 | 3 | import com.github.czyzby.setup.data.project.Project 4 | import com.github.czyzby.setup.data.templates.Template 5 | import com.github.czyzby.setup.views.ProjectTemplate 6 | 7 | /** 8 | * Extends InputAdapter, overriding no methods. Sets itself as the input processor. 9 | * @author MJ 10 | */ 11 | @ProjectTemplate(official = true) 12 | class InputProcessorTemplate : Template { 13 | override val id = "inputProcessor" 14 | override val description: String 15 | get() = "Project template included simple launchers and an empty `ApplicationListener` implementation, that also listened to user input." 16 | 17 | 18 | override fun getApplicationListenerContent(project: Project): String = """package ${project.basic.rootPackage}; 19 | 20 | import com.badlogic.gdx.ApplicationListener; 21 | import com.badlogic.gdx.Gdx; 22 | import com.badlogic.gdx.InputAdapter; 23 | 24 | /** {@link com.badlogic.gdx.ApplicationListener} implementation shared by all platforms. Listens to user input. */ 25 | public class ${project.basic.mainClass} extends InputAdapter implements ApplicationListener { 26 | @Override 27 | public void create() { 28 | Gdx.input.setInputProcessor(this); 29 | } 30 | 31 | @Override 32 | public void resize(final int width, final int height) { 33 | } 34 | 35 | @Override 36 | public void render() { 37 | } 38 | 39 | @Override 40 | public void pause() { 41 | } 42 | 43 | @Override 44 | public void resume() { 45 | } 46 | 47 | @Override 48 | public void dispose() { 49 | } 50 | 51 | // Note: you can override methods from InputAdapter API to handle user's input. 52 | }""" 53 | } 54 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/templates/official/ktxClassic.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.templates.official 2 | 3 | import com.github.czyzby.setup.data.files.CopiedFile 4 | import com.github.czyzby.setup.data.files.path 5 | import com.github.czyzby.setup.data.langs.Kotlin 6 | import com.github.czyzby.setup.data.libs.unofficial.KtxApp 7 | import com.github.czyzby.setup.data.libs.unofficial.KtxGraphics 8 | import com.github.czyzby.setup.data.platforms.Assets 9 | import com.github.czyzby.setup.data.project.Project 10 | import com.github.czyzby.setup.data.templates.KtxTemplate 11 | import com.github.czyzby.setup.views.ProjectTemplate 12 | 13 | /** 14 | * Draws Ktx logo at the center of the screen. 15 | * @author David Partouche 16 | * @author Original gdx-setup maintainers 17 | */ 18 | @ProjectTemplate(official = true) 19 | open class KtxClassicTemplate : KtxTemplate { 20 | override val id = "ktxClassic" 21 | override val description: String 22 | get() = "Project template includes simple launchers and an KtxGame extension that draws Ktx logo." 23 | 24 | override fun apply(project: Project) { 25 | super.apply(project) 26 | KtxApp().initiate(project) 27 | KtxGraphics().initiate(project) 28 | project.languages.selectLanguage() 29 | project.files.add(CopiedFile(projectName = Assets.ID, original = path("generator", "templates", "ktxClassic", 30 | "ktx-logo.png"), path = "ktx-logo.png")) 31 | } 32 | 33 | override fun getApplicationListenerContent(project: Project): String = """package ${project.basic.rootPackage} 34 | 35 | import com.badlogic.gdx.graphics.Texture 36 | import com.badlogic.gdx.graphics.g2d.SpriteBatch 37 | import ktx.app.KtxGame 38 | import ktx.app.KtxScreen 39 | import ktx.app.clearScreen 40 | import ktx.graphics.use 41 | 42 | class FirstScreen : KtxScreen { 43 | private val image = Texture("ktx-logo.png") 44 | private val batch = SpriteBatch() 45 | 46 | override fun render(delta: Float) { 47 | clearScreen(0.8f, 0.8f, 0.8f) 48 | batch.use { 49 | it.draw(image, 47.5f, 140f) 50 | } 51 | } 52 | 53 | override fun dispose() { 54 | image.dispose() 55 | batch.dispose() 56 | } 57 | } 58 | 59 | class ${project.basic.mainClass} : KtxGame() { 60 | override fun create() { 61 | addScreen(FirstScreen()) 62 | setScreen() 63 | } 64 | } 65 | """ 66 | } 67 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/templates/official/scene2d.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.templates.official 2 | 3 | import com.github.czyzby.setup.data.project.Project 4 | import com.github.czyzby.setup.data.templates.Template 5 | import com.github.czyzby.setup.views.ProjectTemplate 6 | 7 | /** 8 | * Sets up a simple Scene2D stage. Forces generation of GUI skin. 9 | * @author MJ 10 | */ 11 | @ProjectTemplate(official = true) 12 | class Scene2DTemplate : Template { 13 | override val id = "scene2dTemplate" 14 | override val description: String 15 | get() = "Project template included simple launchers and an `ApplicationAdapter` extension that draws a simple GUI stage on the screen." 16 | 17 | override fun apply(project: Project) { 18 | super.apply(project) 19 | project.advanced.forceSkinGeneration() 20 | } 21 | 22 | override fun getApplicationListenerContent(project: Project): String = """package ${project.basic.rootPackage}; 23 | 24 | import com.badlogic.gdx.ApplicationAdapter; 25 | import com.badlogic.gdx.Gdx; 26 | import com.badlogic.gdx.graphics.GL20; 27 | import com.badlogic.gdx.scenes.scene2d.Actor; 28 | import com.badlogic.gdx.scenes.scene2d.Stage; 29 | import com.badlogic.gdx.scenes.scene2d.actions.Actions; 30 | import com.badlogic.gdx.scenes.scene2d.ui.Skin; 31 | import com.badlogic.gdx.scenes.scene2d.ui.TextButton; 32 | import com.badlogic.gdx.scenes.scene2d.ui.Window; 33 | import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; 34 | import com.badlogic.gdx.utils.viewport.FitViewport; 35 | 36 | /** {@link com.badlogic.gdx.ApplicationListener} implementation shared by all platforms. */ 37 | public class ${project.basic.mainClass} extends ApplicationAdapter { 38 | private Stage stage; 39 | private Skin skin; 40 | 41 | @Override 42 | public void create() { 43 | stage = new Stage(new FitViewport(640, 480)); 44 | skin = new Skin(Gdx.files.internal("ui/skin.json")); 45 | 46 | Window window = new Window("Example screen", skin, "border"); 47 | window.defaults().pad(4f); 48 | window.add("This is a simple Scene2D view.").row(); 49 | final TextButton button = new TextButton("Click me!", skin); 50 | button.pad(8f); 51 | button.addListener(new ChangeListener() { 52 | @Override 53 | public void changed(final ChangeEvent event, final Actor actor) { 54 | button.setText("Clicked."); 55 | } 56 | }); 57 | window.add(button); 58 | window.pack(); 59 | window.setPosition(stage.getWidth() / 2f - window.getWidth() / 2f, 60 | stage.getHeight() / 2f - window.getHeight() / 2f); 61 | window.addAction(Actions.sequence(Actions.alpha(0f), Actions.fadeIn(1f))); 62 | stage.addActor(window); 63 | 64 | Gdx.input.setInputProcessor(stage); 65 | } 66 | 67 | @Override 68 | public void render() { 69 | Gdx.gl.glClearColor(0f, 0f, 0f, 1f); 70 | Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 71 | stage.act(Gdx.graphics.getDeltaTime()); 72 | stage.draw(); 73 | } 74 | 75 | @Override 76 | public void resize(int width, int height) { 77 | stage.getViewport().update(width, height); 78 | } 79 | 80 | @Override 81 | public void dispose() { 82 | stage.dispose(); 83 | skin.dispose(); 84 | } 85 | }""" 86 | } 87 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/templates/unofficial/kiwi.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.templates.unofficial 2 | 3 | import com.github.czyzby.setup.data.libs.unofficial.Kiwi 4 | import com.github.czyzby.setup.data.project.Project 5 | import com.github.czyzby.setup.data.templates.official.ClassicTemplate 6 | import com.github.czyzby.setup.views.ProjectTemplate 7 | 8 | /** 9 | * Classic project template using Kiwi utilities. 10 | * @author MJ 11 | */ 12 | @ProjectTemplate 13 | class KiwiTemplate : ClassicTemplate() { 14 | override val id = "kiwiTemplate" 15 | private lateinit var mainClass: String 16 | override val width: String 17 | get() = mainClass + ".WIDTH" 18 | override val height: String 19 | get() = mainClass + ".HEIGHT" 20 | override val description: String 21 | get() = "Project template included simple launchers and an `AbstractApplicationListener` extension (from [Kiwi](https://github.com/czyzby/gdx-lml/tree/master/kiwi) library) that draws BadLogic logo." 22 | 23 | override fun apply(project: Project) { 24 | mainClass = project.basic.mainClass 25 | super.apply(project) 26 | // Adding gdx-kiwi dependency: 27 | Kiwi().initiate(project) 28 | } 29 | 30 | override fun getApplicationListenerContent(project: Project): String = """package ${project.basic.rootPackage}; 31 | 32 | import com.badlogic.gdx.graphics.Texture; 33 | import com.badlogic.gdx.scenes.scene2d.Stage; 34 | import com.badlogic.gdx.scenes.scene2d.ui.Image; 35 | import com.badlogic.gdx.utils.viewport.ScreenViewport; 36 | import com.github.czyzby.kiwi.util.gdx.AbstractApplicationListener; 37 | import com.github.czyzby.kiwi.util.gdx.asset.Disposables; 38 | import com.github.czyzby.kiwi.util.gdx.scene2d.Actors; 39 | import com.github.czyzby.kiwi.util.gdx.viewport.LetterboxingViewport; 40 | import com.github.czyzby.kiwi.util.gdx.viewport.Viewports; 41 | 42 | /** {@link com.badlogic.gdx.ApplicationListener} implementation shared by all platforms. */ 43 | public class ${project.basic.mainClass} extends AbstractApplicationListener { 44 | /** Default application size. */ 45 | public static final int WIDTH = 640, HEIGHT = 480; 46 | 47 | private Stage stage; 48 | private Texture texture; 49 | private Image image; 50 | 51 | @Override 52 | public void create() { 53 | stage = new Stage(new LetterboxingViewport()); 54 | texture = new Texture("badlogic.png"); 55 | image = new Image(texture); 56 | stage.addActor(image); 57 | Actors.centerActor(image); 58 | } 59 | 60 | @Override 61 | public void resize(int width, int height) { 62 | Viewports.update(stage); 63 | Actors.centerActor(image); 64 | } 65 | 66 | @Override 67 | public void render(float deltaTime) { 68 | // AbstractApplicationListener automatically clears the screen with black color. 69 | stage.act(deltaTime); 70 | stage.draw(); 71 | } 72 | 73 | @Override 74 | public void dispose() { 75 | // Null-safe disposing utility method: 76 | Disposables.disposeOf(stage, texture); 77 | } 78 | }""" 79 | } 80 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/templates/unofficial/kiwiInput.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.templates.unofficial 2 | 3 | import com.github.czyzby.setup.data.libs.unofficial.Kiwi 4 | import com.github.czyzby.setup.data.project.Project 5 | import com.github.czyzby.setup.data.templates.official.ClassicTemplate 6 | import com.github.czyzby.setup.views.ProjectTemplate 7 | 8 | /** 9 | * Classic project template using Kiwi utilities and listening to user input. 10 | * @author MJ 11 | */ 12 | @ProjectTemplate 13 | class KiwiInputTemplate : ClassicTemplate(){ 14 | override val id = "kiwiInputTemplate" 15 | private lateinit var mainClass: String 16 | override val width: String 17 | get() = mainClass + ".WIDTH" 18 | override val height: String 19 | get() = mainClass + ".HEIGHT" 20 | override val description: String 21 | get() = "Project template included simple launchers and an `InputAwareApplicationListener` extension (from [Kiwi](https://github.com/czyzby/gdx-lml/tree/master/kiwi) library) that draws BadLogic logo and changes its color after the application is clicked/touched." 22 | 23 | override fun apply(project: Project) { 24 | mainClass = project.basic.mainClass 25 | super.apply(project) 26 | // Adding gdx-kiwi dependency: 27 | Kiwi().initiate(project) 28 | } 29 | 30 | override fun getApplicationListenerContent(project: Project): String = """package ${project.basic.rootPackage}; 31 | 32 | import com.badlogic.gdx.graphics.Color; 33 | import com.badlogic.gdx.graphics.Texture; 34 | import com.badlogic.gdx.scenes.scene2d.Stage; 35 | import com.badlogic.gdx.scenes.scene2d.ui.Image; 36 | import com.badlogic.gdx.utils.Array; 37 | import com.badlogic.gdx.utils.viewport.ScreenViewport; 38 | import com.github.czyzby.kiwi.util.gdx.InputAwareApplicationListener; 39 | import com.github.czyzby.kiwi.util.gdx.asset.Disposables; 40 | import com.github.czyzby.kiwi.util.gdx.collection.immutable.ImmutableArray; 41 | import com.github.czyzby.kiwi.util.gdx.scene2d.Actors; 42 | import com.github.czyzby.kiwi.util.gdx.viewport.LetterboxingViewport; 43 | import com.github.czyzby.kiwi.util.gdx.viewport.Viewports; 44 | 45 | /** {@link com.badlogic.gdx.ApplicationListener} implementation shared by all platforms. */ 46 | public class ${project.basic.mainClass} extends InputAwareApplicationListener { 47 | /** Default application size. */ 48 | public static final int WIDTH = 640, HEIGHT = 480; 49 | 50 | // Static Kiwi utility - creates an immutable array of colors: 51 | private final Array colors = ImmutableArray.of(Color.WHITE, Color.RED, Color.GREEN, 52 | Color.BLUE, Color.ORANGE, Color.PURPLE, Color.PINK, Color.SKY, Color.SCARLET); 53 | 54 | private Stage stage; 55 | private Texture texture; 56 | private Image image; 57 | 58 | @Override 59 | public void initiate() { 60 | stage = new Stage(new LetterboxingViewport()); 61 | texture = new Texture("badlogic.png"); 62 | image = new Image(texture); 63 | stage.addActor(image); 64 | Actors.centerActor(image); 65 | } 66 | 67 | @Override 68 | public void resize(int width, int height) { 69 | Viewports.update(stage); 70 | Actors.centerActor(image); 71 | } 72 | 73 | @Override 74 | public void render(float deltaTime) { 75 | // InputAwareApplicationListener automatically clears the screen with black color. 76 | stage.act(deltaTime); 77 | stage.draw(); 78 | } 79 | 80 | @Override 81 | public void dispose() { 82 | // Null-safe disposing utility method: 83 | Disposables.disposeOf(stage, texture); 84 | } 85 | 86 | @Override 87 | public boolean touchDown(int screenX, int screenY, int pointer, int button) { 88 | // Changing current logo color when the screen is clicked/touched: 89 | image.setColor(colors.random()); 90 | return true; 91 | } 92 | }""" 93 | } 94 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/templates/unofficial/lml.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.templates.unofficial 2 | 3 | import com.github.czyzby.setup.data.files.SourceFile 4 | import com.github.czyzby.setup.data.libs.unofficial.LML 5 | import com.github.czyzby.setup.data.platforms.Assets 6 | import com.github.czyzby.setup.data.project.Project 7 | import com.github.czyzby.setup.data.templates.Template 8 | import com.github.czyzby.setup.views.ProjectTemplate 9 | 10 | /** 11 | * Uses LML to generate GUI similar to the one presented in the official Scene2D template. Forces skin generation. 12 | * @author MJ 13 | */ 14 | @ProjectTemplate 15 | class LmlTemplate : Template { 16 | override val id: String = "lmlTemplate" 17 | private lateinit var mainClass: String 18 | override val width: String 19 | get() = mainClass + ".WIDTH" 20 | override val height: String 21 | get() = mainClass + ".HEIGHT" 22 | override val description: String 23 | get() = "Project template included simple launchers and an `AbstractApplicationListener` extension (from [Kiwi](https://github.com/czyzby/gdx-lml/tree/master/kiwi) library) that draws a simple GUI created using [LML](https://github.com/czyzby/gdx-lml/tree/master/lml)." 24 | 25 | override fun apply(project: Project) { 26 | mainClass = project.basic.mainClass 27 | super.apply(project) 28 | project.advanced.forceSkinGeneration() 29 | 30 | // Adding LML dependency: 31 | LML().initiate(project) 32 | 33 | // Adding example LML template file: 34 | project.files.add(SourceFile(projectName = Assets.ID, sourceFolderPath = "ui", packageName = "templates", 35 | fileName = "main.lml", content = """ 36 | 37 | This is a simple LML view. 38 | Click me! 39 | """)) 40 | } 41 | 42 | override fun getApplicationListenerContent(project: Project): String = """package ${project.basic.rootPackage}; 43 | 44 | import com.badlogic.gdx.Gdx; 45 | import com.badlogic.gdx.scenes.scene2d.Action; 46 | import com.badlogic.gdx.scenes.scene2d.Stage; 47 | import com.badlogic.gdx.scenes.scene2d.actions.Actions; 48 | import com.badlogic.gdx.scenes.scene2d.ui.Skin; 49 | import com.badlogic.gdx.scenes.scene2d.ui.TextButton; 50 | import com.badlogic.gdx.scenes.scene2d.ui.Window; 51 | import com.badlogic.gdx.utils.viewport.FitViewport; 52 | import com.github.czyzby.kiwi.util.gdx.AbstractApplicationListener; 53 | import com.github.czyzby.kiwi.util.gdx.asset.Disposables; 54 | import com.github.czyzby.lml.parser.LmlParser; 55 | import com.github.czyzby.lml.parser.action.ActorConsumer; 56 | import com.github.czyzby.lml.util.Lml; 57 | 58 | /** {@link com.badlogic.gdx.ApplicationListener} implementation shared by all platforms. */ 59 | public class ${project.basic.mainClass} extends AbstractApplicationListener { 60 | /** Default application size. */ 61 | public static final int WIDTH = 640, HEIGHT = 480; 62 | 63 | private Stage stage; 64 | private Skin skin; 65 | 66 | @Override 67 | public void create() { 68 | stage = new Stage(new FitViewport(WIDTH, HEIGHT)); 69 | skin = new Skin(Gdx.files.internal("ui/skin.json")); 70 | 71 | LmlParser parser = Lml.parser(skin) 72 | // Adding action for the button listener: 73 | .action("setClicked", new ActorConsumer() { 74 | @Override public Void consume(TextButton actor) { 75 | actor.setText("Clicked."); return null; 76 | } 77 | }) 78 | // Adding showing action for the window: 79 | .action("fadeIn", new ActorConsumer() { 80 | @Override public Action consume(Window actor) { 81 | return Actions.fadeIn(1f); 82 | } 83 | }).build(); 84 | 85 | // Parsing actors defined in main.lml template and adding them to stage: 86 | parser.fillStage(stage, Gdx.files.internal("ui/templates/main.lml")); 87 | // Note: there are less verbose and more powerful ways of using LML. See other LML project templates. 88 | 89 | Gdx.input.setInputProcessor(stage); 90 | } 91 | 92 | @Override 93 | public void resize(int width, int height) { 94 | stage.getViewport().update(width, height); 95 | } 96 | 97 | @Override 98 | public void render(float deltaTime) { 99 | // AbstractApplicationListener automatically clears the screen with black color. 100 | stage.act(deltaTime); 101 | stage.draw(); 102 | } 103 | 104 | @Override 105 | public void dispose() { 106 | // Null-safe disposing utility method: 107 | Disposables.disposeOf(stage, skin); 108 | } 109 | }""" 110 | } 111 | 112 | 113 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/data/templates/unofficial/visuiBasic.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.data.templates.unofficial 2 | 3 | import com.github.czyzby.setup.data.libs.unofficial.VisUI 4 | import com.github.czyzby.setup.data.project.Project 5 | import com.github.czyzby.setup.data.templates.Template 6 | import com.github.czyzby.setup.views.ProjectTemplate 7 | 8 | /** 9 | * Simple VisUI example showing how to actually include VisUI in user project 10 | * @author Kotcrab 11 | */ 12 | @ProjectTemplate 13 | class VisUIBasicTemplate : Template { 14 | override val id = "visUiBasicTemplate" 15 | override val description: String 16 | get() = "Project template included simple launchers and an `ApplicationAdapter` extension with GUI created using [VisUI](https://github.com/kotcrab/VisEditor/wiki/VisUI) library." 17 | 18 | override fun apply(project: Project) { 19 | super.apply(project) 20 | VisUI().initiate(project) 21 | } 22 | 23 | override fun getApplicationListenerContent(project: Project): String = """package ${project.basic.rootPackage}; 24 | 25 | import com.badlogic.gdx.ApplicationAdapter; 26 | import com.badlogic.gdx.Gdx; 27 | import com.badlogic.gdx.graphics.GL20; 28 | import com.badlogic.gdx.scenes.scene2d.Actor; 29 | import com.badlogic.gdx.scenes.scene2d.Stage; 30 | import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; 31 | import com.badlogic.gdx.utils.viewport.ScreenViewport; 32 | import com.kotcrab.vis.ui.VisUI; 33 | import com.kotcrab.vis.ui.VisUI.SkinScale; 34 | import com.kotcrab.vis.ui.util.dialog.Dialogs; 35 | import com.kotcrab.vis.ui.widget.VisTable; 36 | import com.kotcrab.vis.ui.widget.VisTextButton; 37 | import com.kotcrab.vis.ui.widget.VisWindow; 38 | 39 | /** {@link com.badlogic.gdx.ApplicationListener} implementation shared by all platforms. */ 40 | public class ${project.basic.mainClass} extends ApplicationAdapter { 41 | private Stage stage; 42 | 43 | @Override 44 | public void create () { 45 | VisUI.load(SkinScale.X1); 46 | 47 | stage = new Stage(new ScreenViewport()); 48 | Gdx.input.setInputProcessor(stage); 49 | 50 | VisTable root = new VisTable(); 51 | root.setFillParent(true); 52 | stage.addActor(root); 53 | 54 | final VisTextButton textButton = new VisTextButton("click me!"); 55 | textButton.addListener(new ChangeListener() { 56 | @Override 57 | public void changed (ChangeEvent event, Actor actor) { 58 | textButton.setText("clicked"); 59 | Dialogs.showOKDialog(stage, "message", "good job!"); 60 | } 61 | }); 62 | 63 | VisWindow window = new VisWindow("example window"); 64 | window.add("this is a simple VisUI window").padTop(5f).row(); 65 | window.add(textButton).pad(10f); 66 | window.pack(); 67 | window.centerWindow(); 68 | stage.addActor(window.fadeIn()); 69 | } 70 | 71 | @Override 72 | public void resize (int width, int height) { 73 | stage.getViewport().update(width, height, true); 74 | } 75 | 76 | @Override 77 | public void render () { 78 | Gdx.gl.glClearColor(0f, 0f, 0f, 1f); 79 | Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 80 | stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); 81 | stage.draw(); 82 | } 83 | 84 | @Override 85 | public void dispose () { 86 | VisUI.dispose(); 87 | stage.dispose(); 88 | } 89 | }""" 90 | } 91 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/main.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup 2 | 3 | import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application 4 | import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration 5 | import com.github.czyzby.autumn.context.ContextInitializer 6 | import com.github.czyzby.autumn.fcs.scanner.DesktopClassScanner 7 | import com.github.czyzby.autumn.mvc.application.AutumnApplication 8 | import com.github.czyzby.setup.config.Configuration 9 | import com.github.czyzby.setup.views.Extension 10 | import com.github.czyzby.setup.views.GdxPlatform 11 | import com.github.czyzby.setup.views.JvmLanguage 12 | import com.github.czyzby.setup.views.ProjectTemplate 13 | import com.kotcrab.vis.ui.util.OsUtils 14 | 15 | fun main(args: Array) { 16 | val config = Lwjgl3ApplicationConfiguration() 17 | config.setTitle("gdx-setup") 18 | config.setWindowedMode(Configuration.WIDTH, Configuration.HEIGHT) 19 | config.disableAudio(true) 20 | config.setDecorated(false) 21 | config.setWindowIcon(*arrayOf(128, 64, 32, 16).map { "icons/libgdx$it.png" }.toTypedArray()) 22 | 23 | try { 24 | Lwjgl3Application(object : AutumnApplication(DesktopClassScanner(), Root::class.java) { 25 | override fun registerDefaultComponentAnnotations(initializer: ContextInitializer) { 26 | super.registerDefaultComponentAnnotations(initializer) 27 | initializer.scanFor(Extension::class.java, ProjectTemplate::class.java, JvmLanguage::class.java, 28 | GdxPlatform::class.java) 29 | } 30 | }, config) 31 | } catch(error: ExceptionInInitializerError) { 32 | if (OsUtils.isMac() && error.cause is IllegalStateException) { 33 | if (error.stackTraceToString().contains("XstartOnFirstThread")) { 34 | println("Application was not launched on first thread. Restarting with -XstartOnFirstThread. " + 35 | "Add VM argument -XstartOnFirstThread to avoid this.") 36 | Application.startNewInstance() 37 | } 38 | } 39 | throw error 40 | } 41 | } 42 | 43 | /** 44 | * Application's scanning root. 45 | * @author MJ 46 | */ 47 | class Root 48 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/prefs/abstractStringPreference.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.prefs 2 | 3 | import com.badlogic.gdx.scenes.scene2d.Actor 4 | import com.badlogic.gdx.scenes.scene2d.ui.SelectBox 5 | import com.badlogic.gdx.utils.GdxRuntimeException 6 | import com.github.czyzby.autumn.mvc.component.preferences.dto.AbstractPreference 7 | import com.github.czyzby.kiwi.util.common.Strings 8 | import com.kotcrab.vis.ui.widget.VisTextField 9 | import com.kotcrab.vis.ui.widget.spinner.Spinner 10 | 11 | /** 12 | * Abstract base for all application's preferences. 13 | * @author MJ 14 | */ 15 | open class AbstractStringPreference : AbstractPreference() { 16 | override fun extractFromActor(actor: Actor): String { 17 | if (actor is VisTextField) { 18 | return actor.text 19 | } else if (actor is Spinner) { 20 | return actor.model.text 21 | } else if (actor is SelectBox<*>) { 22 | if (actor.selectedIndex > 0) { 23 | return actor.selected.toString() 24 | } 25 | return get() 26 | } 27 | throw GdxRuntimeException("Actor type unsupported: " + actor.javaClass) 28 | } 29 | 30 | override fun getDefault(): String = Strings.EMPTY_STRING 31 | 32 | override fun serialize(preference: String): String = preference 33 | 34 | override fun convert(rawPreference: String): String = rawPreference 35 | } 36 | 37 | // Side note: there is no preference for project name, as it is likely to be unique. There is also no preference 38 | // for project's destination folder, but file chooser supports saving default folders, so one can easily remember 39 | // the path to this workspace. -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/prefs/androidSdkPreference.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.prefs 2 | 3 | import com.github.czyzby.autumn.mvc.stereotype.preference.Property 4 | 5 | /** 6 | * Saves Android SDK path. Needless to say, this setting is unlikely to change once set. 7 | * @author MJ 8 | */ 9 | @Property("AndroidSdk") 10 | class AndroidSdkPreference : AbstractStringPreference() { 11 | override fun getDefault(): String = System.getenv("ANDROID_HOME").orEmpty() 12 | } 13 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/prefs/gradleTasksPreference.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.prefs 2 | 3 | import com.github.czyzby.autumn.mvc.stereotype.preference.Property 4 | import com.github.czyzby.kiwi.util.common.Strings 5 | 6 | /** 7 | * These tasks will be run after the project generation. 8 | * @author MJ 9 | */ 10 | @Property("GradleTasks") 11 | class GradleTasksPreference : AbstractStringPreference() { 12 | override fun serialize(preference: String): String = preference.split(Regex(Strings.WHITESPACE_SPLITTER_REGEX)) 13 | .filter { it.isNotBlank() }.joinToString(separator = " ") 14 | } 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/prefs/gradleWrapperPreference.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.prefs 2 | 3 | import com.badlogic.gdx.scenes.scene2d.Actor 4 | import com.badlogic.gdx.scenes.scene2d.ui.Button 5 | import com.github.czyzby.autumn.mvc.component.preferences.dto.AbstractPreference 6 | import com.github.czyzby.autumn.mvc.stereotype.preference.Property 7 | 8 | /** 9 | * Marks whether Gradle wrapper should be included. 10 | * @author MJ 11 | */ 12 | @Property("GradleWrapper") 13 | class GradleWrapperPreference : AbstractPreference() { 14 | override fun getDefault(): Boolean = true 15 | 16 | override fun extractFromActor(actor: Actor): Boolean { 17 | if (actor is Button) { 18 | return actor.isChecked 19 | } 20 | throw UnsupportedOperationException("Cannot extract value from: " + actor) 21 | } 22 | 23 | override fun convert(rawPreference: String): Boolean = rawPreference.toBoolean() 24 | override fun serialize(preference: Boolean): String = preference.toString() 25 | } 26 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/prefs/gwtVersionPreference.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.prefs 2 | 3 | import com.github.czyzby.autumn.mvc.stereotype.preference.Property 4 | 5 | /** 6 | * Saves GWT framework version. This setting is likely to be the same for multiple projects. 7 | * @author MJ 8 | */ 9 | @Property("GwtVersion") 10 | class GwtVersionPreference : AbstractStringPreference() { 11 | override fun getDefault(): String = "2.8.0" 12 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/prefs/mainClassPreference.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.prefs 2 | 3 | import com.github.czyzby.autumn.mvc.stereotype.preference.Property 4 | 5 | /** 6 | * Saves main class name. Main core's project class name is usually generic, like "Core", "Main" or "Root". 7 | * @author MJ 8 | */ 9 | @Property("MainClass") 10 | class MainClassPreference : AbstractStringPreference() { 11 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/prefs/packagePreference.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.prefs 2 | 3 | import com.github.czyzby.autumn.mvc.stereotype.preference.Property 4 | 5 | /** 6 | * Saves package name. Package name is usually company-dependant and often shared (at least partially) across multiple projects. 7 | * @author MJ 8 | */ 9 | @Property("Package") 10 | class PackagePreference : AbstractStringPreference() { 11 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/prefs/sdkVersionPreference.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.prefs 2 | 3 | import com.github.czyzby.autumn.mvc.stereotype.preference.Property 4 | 5 | /** 6 | * Saves Android SDK version. This setting is likely to be the same for multiple projects. 7 | * @author MJ 8 | */ 9 | @Property("SdkVersion") 10 | class SdkVersionPreference : AbstractStringPreference() { 11 | override fun getDefault(): String = "23" 12 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/prefs/toolsVersionPreference.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.prefs 2 | 3 | import com.github.czyzby.autumn.mvc.stereotype.preference.Property 4 | 5 | /** 6 | * Saves Android build tools version. This setting is likely to be the same for multiple projects. 7 | * @author MJ 8 | */ 9 | @Property("ToolsVersion") 10 | class ToolsVersionPreference : AbstractStringPreference() { 11 | override fun getDefault(): String = "25.0.2" 12 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/views/advanced.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.views 2 | 3 | import com.badlogic.gdx.scenes.scene2d.ui.Button 4 | import com.github.czyzby.kiwi.util.common.Strings 5 | import com.github.czyzby.lml.annotation.LmlActor 6 | import com.kotcrab.vis.ui.widget.VisSelectBox 7 | import com.kotcrab.vis.ui.widget.VisTextField 8 | import com.kotcrab.vis.ui.widget.spinner.IntSpinnerModel 9 | import com.kotcrab.vis.ui.widget.spinner.Spinner 10 | 11 | /** 12 | * Stores data from "advanced" tab. 13 | * @author MJ 14 | */ 15 | class AdvancedData { 16 | @LmlActor("version") private lateinit var versionField: VisTextField 17 | @LmlActor("gdxVersion") private lateinit var gdxVersionField: VisTextField 18 | @LmlActor("javaVersion") private lateinit var javaVersionField: Spinner 19 | @LmlActor("sdkVersion") private lateinit var sdkVersionField: Spinner 20 | @LmlActor("toolsVersion") private lateinit var toolsVersionField: VisTextField 21 | @LmlActor("androidPluginVersion") private lateinit var androidPluginVersionField: VisTextField 22 | @LmlActor("robovmVersion") private lateinit var robovmVersionField: VisTextField 23 | @LmlActor("moeVersion") private lateinit var moeVersionField: VisTextField 24 | @LmlActor("gwtVersion") private lateinit var gwtVersionField: VisSelectBox 25 | @LmlActor("gwtPlugin") private lateinit var gwtPluginVersionField: VisTextField 26 | @LmlActor("serverJavaVersion") private lateinit var serverJavaVersionField: Spinner 27 | @LmlActor("desktopJavaVersion") private lateinit var desktopJavaVersionField: Spinner 28 | @LmlActor("generateSkin") private lateinit var generateSkinButton: Button 29 | @LmlActor("generateUsl") private lateinit var generateUslButton: Button 30 | @LmlActor("generateReadme") private lateinit var generateReadmeButton: Button 31 | @LmlActor("gradleWrapper") private lateinit var gradleWrapperButton: Button 32 | @LmlActor("gradleTasks") private lateinit var gradleTasksField: VisTextField 33 | 34 | val version: String 35 | get() = versionField.text 36 | 37 | val gdxVersion: String 38 | get() = gdxVersionField.text 39 | 40 | val javaVersion: String 41 | get() = javaVersionField.model.text 42 | 43 | var androidSdkVersion: String 44 | get() = sdkVersionField.model.text 45 | set(value) { 46 | val model = sdkVersionField.model as IntSpinnerModel 47 | model.value = value.toInt() 48 | sdkVersionField.notifyValueChanged(false) 49 | } 50 | 51 | var androidToolsVersion: String 52 | get() = toolsVersionField.text 53 | set(value) { 54 | toolsVersionField.text = value 55 | } 56 | 57 | val androidPluginVersion: String 58 | get() = androidPluginVersionField.text 59 | 60 | val robovmVersion: String 61 | get() = robovmVersionField.text 62 | 63 | val moeVersion: String 64 | get() = moeVersionField.text 65 | 66 | val gwtVersion: String 67 | get() = gwtVersionField.selected 68 | 69 | val gwtPluginVersion: String 70 | get() = gwtPluginVersionField.text 71 | 72 | val serverJavaVersion: String 73 | get() = serverJavaVersionField.model.text 74 | 75 | val desktopJavaVersion: String 76 | get() = desktopJavaVersionField.model.text 77 | 78 | val generateSkin: Boolean 79 | get() = generateSkinButton.isChecked 80 | 81 | val generateUsl: Boolean 82 | get() = generateUslButton.isChecked 83 | 84 | val generateReadme: Boolean 85 | get() = generateReadmeButton.isChecked 86 | 87 | val addGradleWrapper: Boolean 88 | get() = gradleWrapperButton.isChecked 89 | 90 | val gradleTasks: List 91 | get() = if (gradleTasksField.isEmpty) listOf() 92 | else gradleTasksField.text.split(Regex(Strings.WHITESPACE_SPLITTER_REGEX)).filter { it.isNotBlank() } 93 | 94 | fun forceSkinGeneration() { 95 | generateSkinButton.isChecked = true 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/kotlin/com/github/czyzby/setup/views/basicData.kt: -------------------------------------------------------------------------------- 1 | package com.github.czyzby.setup.views 2 | 3 | import com.badlogic.gdx.Gdx 4 | import com.badlogic.gdx.files.FileHandle 5 | import com.badlogic.gdx.scenes.scene2d.ui.Button 6 | import com.badlogic.gdx.utils.ObjectSet 7 | import com.github.czyzby.kiwi.util.common.Strings 8 | import com.github.czyzby.lml.annotation.LmlActor 9 | import com.kotcrab.vis.ui.widget.VisTextField 10 | import com.kotcrab.vis.ui.widget.VisValidatableTextField 11 | import javax.print.attribute.standard.Destination 12 | 13 | /** 14 | * Filled by the LML parser, this class contains references to basic project data widgets. 15 | * @author MJ 16 | */ 17 | class BasicProjectData { 18 | @LmlActor("name") private lateinit var nameField: VisTextField 19 | @LmlActor("package") private lateinit var rootPackageField: VisTextField 20 | @LmlActor("class") private lateinit var mainClassField: VisTextField 21 | @LmlActor("destination") private lateinit var destinationField: VisTextField 22 | @LmlActor("androidSdk") private lateinit var androidSdkPathField: VisValidatableTextField 23 | 24 | @LmlActor("mkdirs") private lateinit var mkdirsButton: Button 25 | @LmlActor("clearFolder") private lateinit var clearButton: Button 26 | 27 | @LmlActor("useOldestSdk", "useLatestSdk") private lateinit var sdkButtons: ObjectSet