├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── formatter.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── src ├── com │ └── strongjoshua │ │ ├── console.gwt.xml │ │ └── console │ │ ├── AbstractConsole.java │ │ ├── CommandCompleter.java │ │ ├── CommandExecutor.java │ │ ├── CommandHistory.java │ │ ├── Console.java │ │ ├── ConsoleContext.java │ │ ├── ConsoleUtils.java │ │ ├── GUIConsole.java │ │ ├── HeadlessConsole.java │ │ ├── Log.java │ │ ├── LogEntry.java │ │ ├── LogLevel.java │ │ └── annotation │ │ ├── ConsoleDoc.java │ │ └── HiddenCommand.java └── default_skin │ ├── default.fnt │ ├── default.png │ ├── uiskin.atlas │ ├── uiskin.json │ └── uiskin.png └── test ├── com └── strongjoshua │ └── console │ ├── CommandHistoryTest.java │ └── ConsoleTest.java └── tests ├── Box2DTest.java ├── StageTest.java ├── VisUITest.java ├── badlogic.jpg └── test_skin ├── console-font.fnt ├── console-font.png ├── default.fnt ├── default.png ├── uiskin.atlas ├── uiskin.json └── uiskin.png /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | 3 | dist 4 | bin 5 | .classpath 6 | .project 7 | .settings 8 | 9 | # Idea 10 | /.idea/ 11 | *.iml 12 | *.ipr 13 | *.iws 14 | 15 | # Gradle 16 | /.gradle/ 17 | /build/ 18 | 19 | # Maven 20 | /target/ 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2015 StrongJoshua 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # libGDX In-Game Console 2 | This is a libGDX library that allows a developer to add a console (similar to how it is featured in Source games) to their game. Check out the changelog at my [website](https://www.strongjoshua.net/projects/games/libgdx-ingame-console)! 3 | 4 | ### How it works 5 | Essentially what the console allows you to do is specify commands that you will be able to access from within the game, using the console. The console also enables live logging from within the application. 6 | 7 | ### Purpose 8 | This console speeds up development substantially by removing the need to recompile a program every time a minute change is made, specifically in regard to manipulating constants or other values when balancing a game, for example. 9 | 10 | ### Integration 11 | #### Gradle 12 | Add the following line to your build.gradle file under the dependencies section of the **core** project: 13 | `compile "com.strongjoshua:libgdx-inGameConsole:{version}"` 14 | Replace **{version}** with the newest version number! 15 | 16 | Then simply right-click the project and choose `Gradle->Refresh All`. 17 | 18 | #### Maven 19 | Right-click on your project and choose `Maven->Add Dependency` and search for `strongjoshua`. Make sure to choose the most recent version if multiple appear! 20 | 21 | #### Eclipse 22 | First, clone this project to your computer and [add it to Eclipse](http://www.eclipse.org/forums/index.php/t/226301/). Then simply click on your project, and choose `Build Path->Configure Build Path`. Then go to `Projects->Add` and add the cloned project. 23 | 24 | Versions 25 | ======== 26 | Latest Stable: **1.0.0** 27 | Latest Snapshot: 28 | ### How the Numbers Work 29 | #### First Digit 30 | This digit goes up whenever I feel that the project has reached a milestone and/or no longer resembles the first version in it's current digit (e.g.: 0.13.3 is completely different from 0.1.0). 31 | #### Second Digit 32 | This digit goes up whenever a new feature is added, but if two or more features are added in one group of updates, this digit will still only rise by one. This number resets to 0 when the first digit goes up. 33 | #### Third Digit 34 | This digit goes up whenever a bugfix is released. This number resets to 0 when the second digit goes up. 35 | 36 | License 37 | ======= 38 | Copyright 2015 39 | 40 | Licensed under the Apache License, Version 2.0 (the "License"); 41 | you may not use these files except in compliance with the License. 42 | You may obtain a copy of the License at 43 | 44 | http://www.apache.org/licenses/LICENSE-2.0 45 | 46 | Unless required by applicable law or agreed to in writing, software 47 | distributed under the License is distributed on an "AS IS" BASIS, 48 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 49 | See the License for the specific language governing permissions and 50 | limitations under the License. 51 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'maven' 3 | apply plugin: 'signing' 4 | 5 | group = 'com.strongjoshua' 6 | version = '1.0.0' 7 | 8 | description = """LibGdx In-Game Console""" 9 | 10 | sourceCompatibility = 1.8 11 | targetCompatibility = 1.8 12 | 13 | repositories { 14 | maven { url "http://repo.maven.apache.org/maven2" } 15 | } 16 | 17 | ext { 18 | gdxVersion = '1.9.9' 19 | } 20 | 21 | dependencies { 22 | compile group: 'com.badlogicgames.gdx', name: 'gdx', version:gdxVersion 23 | testCompile group: 'com.badlogicgames.gdx', name: 'gdx-backend-lwjgl', version:gdxVersion 24 | testCompile group: 'com.badlogicgames.gdx', name: 'gdx-platform', version:gdxVersion, classifier:'natives-desktop' 25 | testCompile group: 'com.badlogicgames.gdx', name: 'gdx-box2d', version:gdxVersion 26 | testCompile group: 'com.badlogicgames.gdx', name: 'gdx-box2d-platform', version:gdxVersion, classifier:'natives-desktop' 27 | testCompile group: 'junit', name: 'junit', version:'4.12' 28 | testCompile group: 'com.kotcrab.vis', name: 'vis-ui', version: '1.4.0' 29 | } 30 | 31 | sourceSets { 32 | main { 33 | java { 34 | srcDirs = ['src'] 35 | } 36 | resources { 37 | srcDirs = ['src'] 38 | } 39 | } 40 | test { 41 | java { 42 | srcDirs = ['test'] 43 | } 44 | resources { 45 | srcDirs = ['test'] 46 | } 47 | } 48 | } 49 | 50 | task javadocJar(type: Jar) { 51 | archiveClassifier.set('javadoc') 52 | from javadoc 53 | } 54 | 55 | task sourcesJar(type: Jar) { 56 | archiveClassifier.set('sources') 57 | from sourceSets.main.allSource 58 | } 59 | 60 | artifacts { 61 | archives javadocJar, sourcesJar 62 | } 63 | 64 | signing { 65 | sign configurations.archives 66 | } 67 | 68 | uploadArchives { 69 | repositories { 70 | mavenDeployer { 71 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 72 | 73 | repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { 74 | authentication(userName: ossrhUsername, password: ossrhPassword) 75 | } 76 | 77 | snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { 78 | authentication(userName: ossrhUsername, password: ossrhPassword) 79 | } 80 | 81 | pom.project { 82 | name 'libGdx In-Game Console' 83 | packaging 'jar' 84 | // optionally artifactId can be defined here 85 | description 'libGdx In-Game Console' 86 | url 'https://www.strongjoshua.net/projects/games/libgdx-ingame-console' 87 | 88 | scm { 89 | connection 'scm:git:git@github.com:StrongJoshua/libgdx-inGameConsole.git' 90 | developerConnection 'scm:git:git@github.com:StrongJoshua/libgdx-inGameConsole.git' 91 | url 'https://github.com/StrongJoshua/libgdx-inGameConsole' 92 | } 93 | 94 | licenses { 95 | license { 96 | name 'The Apache License, Version 2.0' 97 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt' 98 | } 99 | } 100 | 101 | developers { 102 | developer { 103 | id 'StrongJoshua' 104 | name 'Jan Risse' 105 | email 'strongjoshua@hotmail.com' 106 | } 107 | } 108 | } 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /formatter.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StrongJoshua/libgdx-inGameConsole/6ef713ee3fe2b94e553943ce64700b15149e2888/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Aug 16 11:11:15 EDT 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'libgdx-inGameConsole' 2 | -------------------------------------------------------------------------------- /src/com/strongjoshua/console.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/com/strongjoshua/console/AbstractConsole.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 StrongJoshua (strongjoshua@hotmail.com) 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | *

7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *

9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | package com.strongjoshua.console; 15 | 16 | import com.badlogic.gdx.Gdx; 17 | import com.badlogic.gdx.InputProcessor; 18 | import com.badlogic.gdx.files.FileHandle; 19 | import com.badlogic.gdx.graphics.Color; 20 | import com.badlogic.gdx.scenes.scene2d.ui.Window; 21 | import com.badlogic.gdx.utils.Array; 22 | import com.badlogic.gdx.utils.Disposable; 23 | import com.badlogic.gdx.utils.reflect.Annotation; 24 | import com.badlogic.gdx.utils.reflect.ClassReflection; 25 | import com.badlogic.gdx.utils.reflect.Method; 26 | import com.badlogic.gdx.utils.reflect.ReflectionException; 27 | import com.strongjoshua.console.annotation.ConsoleDoc; 28 | 29 | import java.util.ArrayList; 30 | import java.util.Collections; 31 | 32 | /** 33 | * @author Eric 34 | */ 35 | public abstract class AbstractConsole implements Console, Disposable { 36 | protected final Log log; 37 | protected CommandExecutor exec; 38 | protected boolean logToSystem; 39 | 40 | protected boolean disabled; 41 | 42 | protected boolean executeHiddenCommands = true; 43 | protected boolean displayHiddenCommands = false; 44 | protected boolean consoleTrace = false; 45 | 46 | public AbstractConsole () { 47 | log = new Log(); 48 | } 49 | 50 | @Override public void setLoggingToSystem (Boolean log) { 51 | this.logToSystem = log; 52 | } 53 | 54 | @Override public void log (String msg, LogLevel level) { 55 | log.addEntry(msg, level); 56 | 57 | if (logToSystem) { 58 | switch (level) { 59 | case ERROR: 60 | System.err.println("> " + msg); 61 | break; 62 | default: 63 | System.out.println("> " + msg); 64 | break; 65 | } 66 | } 67 | } 68 | 69 | @Override public void log (String msg) { 70 | this.log(msg, LogLevel.DEFAULT); 71 | } 72 | 73 | @Override public void log (Throwable exception, LogLevel level) { 74 | this.log(ConsoleUtils.exceptionToString(exception), level); 75 | } 76 | 77 | @Override public void log (Throwable exception) { 78 | this.log(exception, LogLevel.ERROR); 79 | } 80 | 81 | @Override public void printLogToFile (String file) { 82 | this.printLogToFile(Gdx.files.local(file)); 83 | } 84 | 85 | @Override public void printLogToFile (FileHandle fh) { 86 | if (log.printToFile(fh)) { 87 | log("Successfully wrote logs to file.", LogLevel.SUCCESS); 88 | } else { 89 | log("Unable to write logs to file.", LogLevel.ERROR); 90 | } 91 | } 92 | 93 | @Override public boolean isDisabled () { 94 | return disabled; 95 | } 96 | 97 | @Override public void setDisabled (boolean disabled) { 98 | this.disabled = disabled; 99 | } 100 | 101 | @Override public void setCommandExecutor (CommandExecutor commandExec) { 102 | exec = commandExec; 103 | exec.setConsole(this); 104 | } 105 | 106 | @Override public void execCommand (String command) { 107 | if (disabled) 108 | return; 109 | 110 | log(command, LogLevel.COMMAND); 111 | 112 | String[] parts = command.split(" "); 113 | String methodName = parts[0]; 114 | String[] sArgs = null; 115 | if (parts.length > 1) { 116 | sArgs = new String[parts.length - 1]; 117 | for (int i = 1; i < parts.length; i++) { 118 | sArgs[i - 1] = parts[i]; 119 | } 120 | } 121 | 122 | Class clazz = exec.getClass(); 123 | Method[] methods = ClassReflection.getMethods(clazz); 124 | Array possible = new Array(); 125 | for (int i = 0; i < methods.length; i++) { 126 | Method method = methods[i]; 127 | if (method.getName().equalsIgnoreCase(methodName) && ConsoleUtils.canExecuteCommand(this, method)) { 128 | possible.add(i); 129 | } 130 | } 131 | 132 | if (possible.size <= 0) { 133 | log("No such method found.", LogLevel.ERROR); 134 | return; 135 | } 136 | 137 | int size = possible.size; 138 | int numArgs = sArgs == null ? 0 : sArgs.length; 139 | for (int i = 0; i < size; i++) { 140 | Method m = methods[possible.get(i)]; 141 | Class[] params = m.getParameterTypes(); 142 | if (numArgs == params.length) { 143 | try { 144 | Object[] args = null; 145 | 146 | try { 147 | if (sArgs != null) { 148 | args = new Object[numArgs]; 149 | 150 | for (int j = 0; j < params.length; j++) { 151 | Class param = params[j]; 152 | final String value = sArgs[j]; 153 | 154 | if (param.equals(String.class)) { 155 | args[j] = value; 156 | } else if (param.equals(Boolean.class) || param.equals(boolean.class)) { 157 | args[j] = Boolean.parseBoolean(value); 158 | } else if (param.equals(Byte.class) || param.equals(byte.class)) { 159 | args[j] = Byte.parseByte(value); 160 | } else if (param.equals(Short.class) || param.equals(short.class)) { 161 | args[j] = Short.parseShort(value); 162 | } else if (param.equals(Integer.class) || param.equals(int.class)) { 163 | args[j] = Integer.parseInt(value); 164 | } else if (param.equals(Long.class) || param.equals(long.class)) { 165 | args[j] = Long.parseLong(value); 166 | } else if (param.equals(Float.class) || param.equals(float.class)) { 167 | args[j] = Float.parseFloat(value); 168 | } else if (param.equals(Double.class) || param.equals(double.class)) { 169 | args[j] = Double.parseDouble(value); 170 | } 171 | } 172 | } 173 | } catch (Exception e) { 174 | // Error occurred trying to parse parameter, continue 175 | // to next function 176 | continue; 177 | } 178 | 179 | m.setAccessible(true); 180 | m.invoke(exec, args); 181 | return; 182 | } catch (ReflectionException e) { 183 | String msg = e.getMessage(); 184 | if (msg == null || msg.length() <= 0) { 185 | msg = "Unknown Error"; 186 | e.printStackTrace(); 187 | } 188 | log(msg, LogLevel.ERROR); 189 | if (consoleTrace) { 190 | log(e, LogLevel.ERROR); 191 | } 192 | return; 193 | } 194 | } 195 | } 196 | 197 | log("Bad parameters. Check your code.", LogLevel.ERROR); 198 | } 199 | 200 | private ArrayList getAllMethods () { 201 | ArrayList methods = new ArrayList(); 202 | Class c = exec.getClass(); 203 | while (c != Object.class) { 204 | Collections.addAll(methods, ClassReflection.getDeclaredMethods(c)); 205 | c = c.getSuperclass(); 206 | } 207 | return methods; 208 | } 209 | 210 | @Override public void printCommands () { 211 | for (Method m : getAllMethods()) { 212 | if (m.isPublic() && ConsoleUtils.canDisplayCommand(this, m)) { 213 | String s = ""; 214 | s += m.getName(); 215 | s += " : "; 216 | 217 | Class[] params = m.getParameterTypes(); 218 | for (int i = 0; i < params.length; i++) { 219 | s += params[i].getSimpleName(); 220 | if (i < params.length - 1) { 221 | s += ", "; 222 | } 223 | } 224 | 225 | log(s); 226 | } 227 | } 228 | } 229 | 230 | @Override public void printHelp (String command) { 231 | boolean found = false; 232 | for (Method m : getAllMethods()) { 233 | if (m.getName().equals(command)) { 234 | found = true; 235 | StringBuilder sb = new StringBuilder(); 236 | sb.append(m.getName()).append(": "); 237 | Annotation annotation = m.getDeclaredAnnotation(ConsoleDoc.class); 238 | if (annotation != null) { 239 | ConsoleDoc doc = annotation.getAnnotation(ConsoleDoc.class); 240 | sb.append(doc.description()); 241 | Class[] params = m.getParameterTypes(); 242 | for (int i = 0; i < params.length; i++) { 243 | sb.append("\n"); 244 | for (int j = 0; j < m.getName().length() + 2; j++) 245 | // using spaces this way works with monotype fonts 246 | sb.append(" "); 247 | sb.append(params[i].getSimpleName()).append(": "); 248 | if (i < doc.paramDescriptions().length) 249 | sb.append(doc.paramDescriptions()[i]); 250 | } 251 | } else { 252 | Class[] params = m.getParameterTypes(); 253 | for (int i = 0; i < params.length; i++) { 254 | sb.append(params[i].getSimpleName()); 255 | if (i < params.length - 1) { 256 | sb.append(", "); 257 | } 258 | } 259 | } 260 | 261 | log(sb.toString()); 262 | } 263 | } 264 | 265 | if (!found) 266 | log("Command does not exist."); 267 | } 268 | 269 | @Override public void setExecuteHiddenCommands (boolean enabled) { 270 | executeHiddenCommands = enabled; 271 | } 272 | 273 | @Override public boolean isExecuteHiddenCommandsEnabled () { 274 | return executeHiddenCommands; 275 | } 276 | 277 | @Override public void setDisplayHiddenCommands (boolean enabled) { 278 | displayHiddenCommands = enabled; 279 | } 280 | 281 | @Override public boolean isDisplayHiddenCommandsEnabled () { 282 | return displayHiddenCommands; 283 | } 284 | 285 | @Override public void setConsoleStackTrace (boolean enabled) { 286 | this.consoleTrace = enabled; 287 | } 288 | 289 | @Override public void setMaxEntries (int numEntries) { 290 | } 291 | 292 | @Override public void clear () { 293 | } 294 | 295 | @Override public void setSize (int width, int height) { 296 | } 297 | 298 | @Override public void setSizePercent (float wPct, float hPct) { 299 | } 300 | 301 | @Override public void setPosition (int x, int y) { 302 | } 303 | 304 | @Override public void setPositionPercent (float xPosPct, float yPosPct) { 305 | } 306 | 307 | @Override public void resetInputProcessing () { 308 | } 309 | 310 | @Override public InputProcessor getInputProcessor () { 311 | return null; 312 | } 313 | 314 | @Override public void draw () { 315 | } 316 | 317 | @Override public void refresh () { 318 | } 319 | 320 | @Override public void refresh (boolean retain) { 321 | } 322 | 323 | @Override public int getDisplayKeyID () { 324 | return 0; 325 | } 326 | 327 | @Override public void setDisplayKeyID (int code) { 328 | } 329 | 330 | @Override public boolean hitsConsole (float screenX, float screenY) { 331 | return false; 332 | } 333 | 334 | @Override public void dispose () { 335 | } 336 | 337 | @Override public boolean isVisible () { 338 | return false; 339 | } 340 | 341 | @Override public void setVisible (boolean visible) { 342 | } 343 | 344 | @Override public void select () { 345 | } 346 | 347 | @Override public void deselect () { 348 | } 349 | 350 | @Override public void setTitle (String title) { 351 | } 352 | 353 | @Override public void setHoverAlpha (float alpha) { 354 | } 355 | 356 | @Override public void setNoHoverAlpha (float alpha) { 357 | } 358 | 359 | @Override public void setHoverColor (Color color) { 360 | } 361 | 362 | @Override public void setNoHoverColor (Color color) { 363 | } 364 | 365 | @Override public void enableSubmitButton (boolean enable) { 366 | } 367 | 368 | @Override public void setSubmitText (String text) { 369 | } 370 | 371 | @Override public Window getWindow () { 372 | return null; 373 | } 374 | } 375 | -------------------------------------------------------------------------------- /src/com/strongjoshua/console/CommandCompleter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 StrongJoshua (strongjoshua@hotmail.com) 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | *

7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *

9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | package com.strongjoshua.console; 15 | 16 | import com.badlogic.gdx.utils.Array; 17 | import com.badlogic.gdx.utils.ObjectSet; 18 | import com.badlogic.gdx.utils.ObjectSet.ObjectSetIterator; 19 | import com.badlogic.gdx.utils.reflect.ClassReflection; 20 | import com.badlogic.gdx.utils.reflect.Method; 21 | 22 | public class CommandCompleter { 23 | private ObjectSet possibleCommands; 24 | private ObjectSetIterator iterator; 25 | private String setString; 26 | 27 | public CommandCompleter () { 28 | possibleCommands = new ObjectSet<>(); 29 | setString = ""; 30 | } 31 | 32 | public void set (CommandExecutor ce, String s) { 33 | reset(); 34 | setString = s.toLowerCase(); 35 | Array methods = getAllMethods(ce); 36 | for (Method m : methods) { 37 | String name = m.getName(); 38 | if (name.toLowerCase().startsWith(setString) && ConsoleUtils.canDisplayCommand(ce.console, m)) { 39 | possibleCommands.add(name); 40 | } 41 | } 42 | iterator = new ObjectSetIterator<>(possibleCommands); 43 | } 44 | 45 | public void reset () { 46 | possibleCommands.clear(); 47 | setString = ""; 48 | iterator = null; 49 | } 50 | 51 | public boolean isNew () { 52 | return possibleCommands.size == 0; 53 | } 54 | 55 | public boolean wasSetWith (String s) { 56 | return setString.equalsIgnoreCase(s); 57 | } 58 | 59 | public String next () { 60 | if (!iterator.hasNext) { 61 | iterator.reset(); 62 | return setString; 63 | } 64 | return iterator.next(); 65 | } 66 | 67 | private Array getAllMethods (CommandExecutor ce) { 68 | Array methods = new Array<>(); 69 | Method[] ms = ClassReflection.getDeclaredMethods(ce.getClass()); 70 | for (Method m : ms) { 71 | if (m.isPublic()) { 72 | methods.add(m); 73 | } 74 | } 75 | ms = ClassReflection.getDeclaredMethods(ce.getClass().getSuperclass()); 76 | for (Method m : ms) { 77 | if (m.isPublic()) { 78 | methods.add(m); 79 | } 80 | } 81 | 82 | return methods; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/com/strongjoshua/console/CommandExecutor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 StrongJoshua (strongjoshua@hotmail.com) 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use this file except in compliance with the License. You may 6 | * obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions 14 | * and limitations under the License. 15 | */ 16 | 17 | package com.strongjoshua.console; 18 | 19 | import com.badlogic.gdx.Gdx; 20 | import com.strongjoshua.console.annotation.ConsoleDoc; 21 | 22 | /** 23 | * Extend this class and fill it with methods (also public) that you wish to have work with the {@link Console}. Then 24 | * call {@link Console#setCommandExecutor(CommandExecutor)}.
25 | *
26 | * Notes
27 | *

33 | * 34 | * @author StrongJoshua 35 | */ 36 | public class CommandExecutor { 37 | protected Console console; 38 | 39 | protected void setConsole (Console c) { 40 | console = c; 41 | } 42 | 43 | /** 44 | * Prints the log to a local file. 45 | * 46 | * @param path The relative path of the local file to print to. 47 | */ 48 | public final void printLog (String path) { 49 | console.printLogToFile(path); 50 | } 51 | 52 | /** 53 | * Closes the application completely. 54 | */ 55 | @ConsoleDoc(description = "Exits the application.") public final void exitApp () { 56 | Gdx.app.exit(); 57 | } 58 | 59 | /** 60 | * Shows all available methods, and their parameter types, in the console. 61 | */ 62 | @ConsoleDoc(description = "Shows all available methods.") public final void help () { 63 | console.printCommands(); 64 | } 65 | 66 | /** 67 | * Prints out ConsoleDoc for the given command, if it exists. 68 | * 69 | * @param command The command to get help for. 70 | */ 71 | @ConsoleDoc(description = "Prints console docs for the given command.") public final void help (String command) { 72 | console.printHelp(command); 73 | } 74 | 75 | /** 76 | * Deselects the text field in the console. Gives keyboard control back to the application. 77 | */ 78 | @ConsoleDoc(description = "Deselects the console text field. Click to " + "re-select.") public final void logView () { 79 | console.deselect(); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/com/strongjoshua/console/CommandHistory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 StrongJoshua (strongjoshua@hotmail.com) 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | *

7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *

9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | package com.strongjoshua.console; 15 | 16 | import com.badlogic.gdx.utils.Array; 17 | 18 | public class CommandHistory { 19 | private final Array commands = new Array(true, 20); 20 | private int index; 21 | 22 | public void store (String command) { 23 | if (commands.size > 0 && isLastCommand(command)) { 24 | return; 25 | } 26 | commands.insert(0, command); 27 | indexAtBeginning(); 28 | } 29 | 30 | public String getPreviousCommand () { 31 | index++; 32 | 33 | if (commands.size == 0) { 34 | indexAtBeginning(); 35 | return ""; 36 | } else if (index >= commands.size) { 37 | index = 0; 38 | } 39 | 40 | return commands.get(index); 41 | } 42 | 43 | public String getNextCommand () { 44 | index--; 45 | if (commands.size <= 1 || index < 0) { 46 | indexAtBeginning(); 47 | return ""; 48 | } 49 | return commands.get(index); 50 | } 51 | 52 | private boolean isLastCommand (String command) { 53 | return command.equals(commands.first()); 54 | } 55 | 56 | private void indexAtBeginning () { 57 | index = -1; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/com/strongjoshua/console/Console.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 StrongJoshua (strongjoshua@hotmail.com) 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | *

7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *

9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | package com.strongjoshua.console; 15 | 16 | import com.badlogic.gdx.Files; 17 | import com.badlogic.gdx.Input.Keys; 18 | import com.badlogic.gdx.InputProcessor; 19 | import com.badlogic.gdx.files.FileHandle; 20 | import com.badlogic.gdx.graphics.Color; 21 | import com.badlogic.gdx.scenes.scene2d.ui.Window; 22 | import com.strongjoshua.console.annotation.HiddenCommand; 23 | 24 | /** 25 | * A simple console that allows live logging, and live execution of methods, from within an application. Please see the GitHub Repository for more information. 27 | * 28 | * @author StrongJoshua 29 | */ 30 | public interface Console { 31 | 32 | /** 33 | * Use to set the amount of entries to be stored to unlimited. 34 | */ 35 | int UNLIMITED_ENTRIES = -1; 36 | 37 | /** 38 | * @param numEntries maximum number of entries the console will hold. 39 | */ 40 | void setMaxEntries (int numEntries); 41 | 42 | /** 43 | * Clears all log entries. 44 | */ 45 | void clear (); 46 | 47 | /** 48 | * Set size of the console in pixels 49 | * 50 | * @param width width of the console in pixels 51 | * @param height height of the console in pixels 52 | */ 53 | void setSize (int width, int height); 54 | 55 | /** 56 | * Makes the console also log to the System when {@link Console#log(String)} is called. 57 | * 58 | * @param log to the system 59 | */ 60 | void setLoggingToSystem (Boolean log); 61 | 62 | /** 63 | * Set size of the console as a percent of screen size 64 | * 65 | * @param wPct width of the console as a percent of screen width 66 | * @param hPct height of the console as a percent of screen height 67 | */ 68 | void setSizePercent (float wPct, float hPct); 69 | 70 | /** 71 | * Set position of the lower left corner of the console 72 | * 73 | * @param x X coordinate. 74 | * @param y Y coordinate. 75 | */ 76 | void setPosition (int x, int y); 77 | 78 | /** 79 | * Set position of the lower left corner of the console as a percent of screen size 80 | * 81 | * @param xPosPct Percentage for the x position relative to the screen size. 82 | * @param yPosPct Percentage for the y position relative to the screen size. 83 | */ 84 | void setPositionPercent (float xPosPct, float yPosPct); 85 | 86 | /** 87 | * Call this method if you changed the input processor while this console was active. 88 | */ 89 | void resetInputProcessing (); 90 | 91 | /** 92 | * @return {@link InputProcessor} for this {@link Console} 93 | */ 94 | InputProcessor getInputProcessor (); 95 | 96 | /** 97 | * Draws the console. 98 | */ 99 | void draw (); 100 | 101 | /** 102 | * Calls {@link Console#refresh(boolean)} with true. 103 | */ 104 | void refresh (); 105 | 106 | /** 107 | * Refreshes the console's stage. Use if the app's window size was changed. 108 | * 109 | * @param retain True if you want position and size percentages to be kept. 110 | */ 111 | void refresh (boolean retain); 112 | 113 | /** 114 | * Logs a new entry to the console. 115 | * 116 | * @param msg The message to be logged. 117 | * @param level The {@link LogLevel} of the log entry. 118 | * @see LogLevel 119 | */ 120 | void log (String msg, LogLevel level); 121 | 122 | /** 123 | * Logs a new entry to the console using {@link LogLevel#DEFAULT}. 124 | * 125 | * @param msg The message to be logged. 126 | * @see LogLevel 127 | * @see Console#log(String, LogLevel) 128 | */ 129 | void log (String msg); 130 | 131 | /** 132 | * Logs a new entry to the console using {@link LogLevel#ERROR}. 133 | * 134 | * @param exception The exception to be logged 135 | */ 136 | void log (Throwable exception); 137 | 138 | /** 139 | * Logs a new entry to the console using {@link LogLevel}. 140 | * 141 | * @param exception The exception to be logged 142 | * @param level The {@link LogLevel} of the log entry. 143 | */ 144 | void log (Throwable exception, LogLevel level); 145 | 146 | /** 147 | * Prints all log entries to the given file. Log entries include logs in the code and commands made from within in the console 148 | * while the program is running.
149 | *

150 | * WARNING
151 | * The file that is sent to this function will be overwritten! 152 | * 153 | * @param file The relative path to the file to print to. This method uses {@link Files#local(String)}. 154 | */ 155 | void printLogToFile (String file); 156 | 157 | /** 158 | * Prints all log entries to the given file. Log entries include logs in the code and commands made from within in the console 159 | * while the program is running.
160 | *

161 | * WARNING
162 | * The file that is sent to this function will be overwritten! 163 | * 164 | * @param fh The {@link FileHandle} that links to the file to be written to. Note that classpath and 165 | * internal FileHandles cannot be written to. 166 | */ 167 | void printLogToFile (FileHandle fh); 168 | 169 | /** 170 | * Prints all commands 171 | */ 172 | void printCommands (); 173 | 174 | /** 175 | * Prints ConsoleDoc for the given command. 176 | * 177 | * @param command The command to get help for. 178 | */ 179 | void printHelp (String command); 180 | 181 | /** 182 | * @return If the console is disabled. 183 | * @see Console#setDisabled(boolean) 184 | */ 185 | boolean isDisabled (); 186 | 187 | /** 188 | * @param disabled True if the console should be disabled (unable to be shown or used). False otherwise. 189 | */ 190 | void setDisabled (boolean disabled); 191 | 192 | /** 193 | * Gets the console's display key. If the console is enabled, the console will be shown upon this key being pressed.
194 | * Default key is ` a.k.a. 'backtick'. 195 | * 196 | * @return the keyID 197 | */ 198 | int getDisplayKeyID (); 199 | 200 | /** 201 | * @param code The new key's ID. Cannot be {@link Keys#ENTER}. 202 | * @see Console#getDisplayKeyID() 203 | */ 204 | void setDisplayKeyID (int code); 205 | 206 | /** 207 | * Sets this console's {@link CommandExecutor}. Its methods are the methods that are referenced within the console. Can be set 208 | * to null, but this will result in no commands being fired. 209 | * 210 | * @param commandExec The {@link CommandExecutor} to use. 211 | */ 212 | void setCommandExecutor (CommandExecutor commandExec); 213 | 214 | /** 215 | * Executes the specified command via the set {@link CommandExecutor}. 216 | * 217 | * @param command The command to execute. 218 | */ 219 | void execCommand (String command); 220 | 221 | /** 222 | * Returns if the given screen coordinates hit the console. 223 | * 224 | * @param screenX X coordinate on the screen. 225 | * @param screenY Y coordinate on the screen. 226 | * @return True, if the console was hit. 227 | */ 228 | boolean hitsConsole (float screenX, float screenY); 229 | 230 | /** 231 | * Resets the {@link InputProcessor} to the one that was the default before this console object was created. 232 | */ 233 | void dispose (); 234 | 235 | /** 236 | * @return If console is visible 237 | */ 238 | boolean isVisible (); 239 | 240 | /** 241 | * Hides or shows the console. Same effect as pushing the display button, except it doesn't toggle. 242 | * 243 | * @param visible If the console should be visible. 244 | */ 245 | void setVisible (boolean visible); 246 | 247 | /** 248 | * Sets the executeHiddenCommands field 249 | * 250 | * @param enabled - if true, commands annotated with {@link HiddenCommand} can be executed 251 | */ 252 | void setExecuteHiddenCommands (boolean enabled); 253 | 254 | /** 255 | * Sets the executeHiddenCommands field 256 | * 257 | * @param enabled - if true, commands annotated with {@link HiddenCommand} show when printCommands (help) is executed 258 | */ 259 | void setDisplayHiddenCommands (boolean enabled); 260 | 261 | /** 262 | * @return If hidden commands can be executed 263 | */ 264 | boolean isExecuteHiddenCommandsEnabled (); 265 | 266 | /** 267 | * @return If hidden commands can be displayed 268 | */ 269 | boolean isDisplayHiddenCommandsEnabled (); 270 | 271 | /** 272 | * @param enabled If the command execution stack traces should be printed to the console. 273 | */ 274 | void setConsoleStackTrace (boolean enabled); 275 | 276 | /** 277 | * Works only for GUIConsole. Selects the text field. 278 | */ 279 | void select (); 280 | 281 | /** 282 | * Works only for a GUIConsole. Deselects the text field. 283 | */ 284 | void deselect (); 285 | 286 | /** 287 | * Works only for GUIConsole. 288 | * 289 | * @param title - The title for the console window. 290 | */ 291 | void setTitle (String title); 292 | 293 | /** 294 | * Works only for GUIConsole. Sets the transparency for when the mouse is over the console window. 295 | * 296 | * @param alpha The transparency (scale from 0 to 1). 297 | */ 298 | void setHoverAlpha (float alpha); 299 | 300 | /** 301 | * Works only for GUIConsole. Sets the transparency for when the mouse is not over the console window. 302 | * 303 | * @param alpha The transparency (scale from 0 to 1). 304 | */ 305 | void setNoHoverAlpha (float alpha); 306 | 307 | /** 308 | * Works only for GUIConsole. Sets the color for when the mouse is over the console window. (Resets previous alpha changes). 309 | * 310 | * @param color The color. 311 | */ 312 | void setHoverColor (Color color); 313 | 314 | /** 315 | * Works only for GUIConsole. Sets the color for when the mouse is not over the console window. (Resets previous alpha changes). 316 | * 317 | * @param color The color. 318 | */ 319 | void setNoHoverColor (Color color); 320 | 321 | /** 322 | * Works only for GUIConsole. Adds a 'Submit' button next to the input field. 323 | * 324 | * @param enable Whether to show the submit button. 325 | */ 326 | void enableSubmitButton (boolean enable); 327 | 328 | /** 329 | * Sets the text the submit button should show. 330 | * 331 | * @param text The text. 332 | */ 333 | void setSubmitText (String text); 334 | 335 | /** 336 | * Returns the Console's Window object. 337 | * 338 | * @return The window. 339 | */ 340 | Window getWindow (); 341 | } 342 | -------------------------------------------------------------------------------- /src/com/strongjoshua/console/ConsoleContext.java: -------------------------------------------------------------------------------- 1 | package com.strongjoshua.console; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.Color; 5 | import com.badlogic.gdx.scenes.scene2d.Actor; 6 | import com.badlogic.gdx.scenes.scene2d.InputEvent; 7 | import com.badlogic.gdx.scenes.scene2d.InputListener; 8 | import com.badlogic.gdx.scenes.scene2d.Stage; 9 | import com.badlogic.gdx.scenes.scene2d.ui.Label; 10 | import com.badlogic.gdx.scenes.scene2d.ui.Skin; 11 | import com.badlogic.gdx.scenes.scene2d.ui.Table; 12 | import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; 13 | import com.badlogic.gdx.utils.reflect.ClassReflection; 14 | 15 | public class ConsoleContext { 16 | private Table root; 17 | private Label label, copy; 18 | private InputListener stageListener; 19 | 20 | ConsoleContext (Class tableClass, Class labelClass, Skin skin, String background) { 21 | try { 22 | root = ClassReflection.newInstance(tableClass); 23 | } catch (Exception e) { 24 | throw new RuntimeException("Table class does not support empty constructor."); 25 | } 26 | try { 27 | copy = (Label) ClassReflection.getConstructor(labelClass, CharSequence.class, Skin.class) 28 | .newInstance("Copy", skin); 29 | } catch (Exception e) { 30 | try { 31 | copy = (Label) ClassReflection.getConstructor(labelClass, CharSequence.class) 32 | .newInstance("Copy"); 33 | } catch (Exception e2) { 34 | throw new RuntimeException( 35 | "Label class does not support either (, ) or () constructors."); 36 | } 37 | } 38 | copy.addListener(new ClickListener() { 39 | @Override public void clicked (InputEvent event, float x, float y) { 40 | if (event.getPointer() != 0) 41 | return; 42 | if (label == null) 43 | throw new RuntimeException("Trying to copy a null label (this should never happen)."); 44 | Gdx.app.getClipboard().setContents(label.getText().toString().trim()); 45 | ConsoleContext.this.remove(); 46 | } 47 | }); 48 | copy.addListener(new HoverListener(copy)); 49 | 50 | root.add(copy); 51 | root.pad(5); 52 | root.setBackground(skin.getDrawable(background)); 53 | root.setSize(root.getPrefWidth(), root.getPrefHeight()); 54 | 55 | stageListener = new InputListener() { 56 | @Override public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { 57 | if (ConsoleContext.this.root.hit(x, y, false) == null) 58 | remove(); 59 | return true; 60 | } 61 | }; 62 | } 63 | 64 | void setLabel (Label l) { 65 | label = l; 66 | } 67 | 68 | protected void setStage (Stage stage) { 69 | if (stage != null) { 70 | stage.addListener(stageListener); 71 | stage.addActor(root); 72 | } 73 | } 74 | 75 | protected boolean remove () { 76 | if (root.getStage() != null) 77 | root.getStage().removeListener(stageListener); 78 | return root.remove(); 79 | } 80 | 81 | protected void setPosition (float x, float y) { 82 | root.setPosition(x, y); 83 | } 84 | 85 | private class HoverListener extends InputListener { 86 | private Label label; 87 | 88 | HoverListener (Label l) { 89 | this.label = l; 90 | } 91 | 92 | @Override public void enter (InputEvent event, float x, float y, int pointer, Actor fromActor) { 93 | label.setColor(Color.CYAN); 94 | } 95 | 96 | @Override public void exit (InputEvent event, float x, float y, int pointer, Actor toActor) { 97 | label.setColor(Color.WHITE); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/com/strongjoshua/console/ConsoleUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 StrongJoshua (strongjoshua@hotmail.com) 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | *

7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *

9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | package com.strongjoshua.console; 15 | 16 | import com.badlogic.gdx.utils.reflect.Method; 17 | import com.strongjoshua.console.annotation.HiddenCommand; 18 | 19 | /** 20 | * @author Eric 21 | */ 22 | public final class ConsoleUtils { 23 | public static boolean canExecuteCommand (Console console, Method method) { 24 | return console.isExecuteHiddenCommandsEnabled() || !method.isAnnotationPresent(HiddenCommand.class); 25 | } 26 | 27 | public static boolean canDisplayCommand (Console console, Method method) { 28 | return console.isDisplayHiddenCommandsEnabled() || !method.isAnnotationPresent(HiddenCommand.class); 29 | } 30 | 31 | public static String exceptionToString (final Throwable throwable) { 32 | StringBuilder result = new StringBuilder(); 33 | Throwable cause = throwable; 34 | 35 | while (cause != null) { 36 | result.append("\nCaused by: ") 37 | .append(cause.getClass().getCanonicalName()) 38 | .append(": ") 39 | .append(cause.getMessage()); 40 | 41 | for (final StackTraceElement traceElement : cause.getStackTrace()) { 42 | result.append("\n\tat ").append(traceElement.toString()); 43 | } 44 | cause = cause.getCause(); 45 | } 46 | return result.toString(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/com/strongjoshua/console/GUIConsole.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 StrongJoshua (strongjoshua@hotmail.com) 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | *

7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *

9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | package com.strongjoshua.console; 15 | 16 | import com.badlogic.gdx.Gdx; 17 | import com.badlogic.gdx.Input.Keys; 18 | import com.badlogic.gdx.InputMultiplexer; 19 | import com.badlogic.gdx.InputProcessor; 20 | import com.badlogic.gdx.graphics.Color; 21 | import com.badlogic.gdx.graphics.g2d.BitmapFont; 22 | import com.badlogic.gdx.math.Vector2; 23 | import com.badlogic.gdx.math.Vector3; 24 | import com.badlogic.gdx.scenes.scene2d.*; 25 | import com.badlogic.gdx.scenes.scene2d.ui.*; 26 | import com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListener; 27 | import com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldStyle; 28 | import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; 29 | import com.badlogic.gdx.scenes.scene2d.utils.DragScrollListener; 30 | import com.badlogic.gdx.scenes.scene2d.utils.Drawable; 31 | import com.badlogic.gdx.utils.Array; 32 | import com.badlogic.gdx.utils.SnapshotArray; 33 | import com.badlogic.gdx.utils.reflect.ClassReflection; 34 | 35 | /** 36 | * A simple console that allows live logging, and live execution of methods, from within an application. Please see the GitHub Repository for more information. 38 | * 39 | * @author StrongJoshua 40 | */ 41 | public class GUIConsole extends AbstractConsole { 42 | private int keyID; 43 | 44 | private ConsoleDisplay display; 45 | private boolean hidden = true; 46 | private boolean usesMultiplexer; 47 | private InputProcessor appInput; 48 | private InputMultiplexer multiplexer; 49 | private Stage stage; 50 | private CommandHistory commandHistory; 51 | private CommandCompleter commandCompleter; 52 | private Window consoleWindow; 53 | private boolean hasHover; 54 | private Color hoverColor, noHoverColor; 55 | private Vector3 stageCoords = new Vector3(); 56 | private ScrollPane scroll; 57 | 58 | private Class tableClass; 59 | private String tableBackground; 60 | 61 | private Class textFieldClass; 62 | private Class textButtonClass; 63 | private Class labelClass; 64 | private Class scrollPaneClass; 65 | 66 | /** 67 | * Creates the console using the default skin.
68 | * ***IMPORTANT*** Call {@link Console#dispose()} to make your {@link InputProcessor} the default processor again (this 69 | * console uses a multiplexer to circumvent it). 70 | *
Default key toggle is apostrophe: ' 71 | * 72 | * @see Console#dispose() 73 | */ 74 | public GUIConsole () { 75 | this(new Skin(Gdx.files.classpath("default_skin/uiskin.json"))); 76 | } 77 | 78 | /** 79 | * Creates the console.
80 | * ***IMPORTANT*** Call {@link Console#dispose()} to make your {@link InputProcessor} the default processor again (this 81 | * console uses a multiplexer to circumvent it). 82 | *
Default key toggle is apostrophe: ' 83 | * 84 | * @param skin Uses skins for Label, TextField, and Table. Skin must contain a font called 'default-font'. 85 | * @see Console#dispose() 86 | */ 87 | public GUIConsole (Skin skin) { 88 | this(skin, true); 89 | } 90 | 91 | /** 92 | * Creates the console.
93 | * ***IMPORTANT*** Call {@link Console#dispose()} to make your {@link InputProcessor} the default processor again (this 94 | * console uses a multiplexer to circumvent it). 95 | *
Default key toggle is apostrophe: ' 96 | * 97 | * @param useMultiplexer If internal multiplexer should be used 98 | * @see Console#dispose() 99 | */ 100 | public GUIConsole (boolean useMultiplexer) { 101 | this(new Skin(Gdx.files.classpath("default_skin/uiskin.json")), useMultiplexer); 102 | } 103 | 104 | /** 105 | * Creates the console.
106 | * ***IMPORTANT*** Call {@link Console#dispose()} to make your {@link InputProcessor} the default processor again (this 107 | * console uses a multiplexer to circumvent it). 108 | *
Default key toggle is apostrophe: ' 109 | * 110 | * @param skin Uses skins for Label, TextField, and Table. Skin must contain a font called 'default-font'. 111 | * @param useMultiplexer If internal multiplexer should be used 112 | * @see Console#dispose() 113 | */ 114 | public GUIConsole (Skin skin, boolean useMultiplexer) { 115 | this(skin, useMultiplexer, Keys.APOSTROPHE); 116 | } 117 | 118 | /** 119 | * Creates the console.
120 | * ***IMPORTANT*** Call {@link Console#dispose()} to make your {@link InputProcessor} the default processor again (this 121 | * console uses a multiplexer to circumvent it). 122 | * 123 | * @param skin Uses skins for Label, TextField, and Table. Skin must contain a font called 'default-font'. 124 | * @param useMultiplexer If internal multiplexer should be used 125 | * @param keyID Sets the key used to open/close the console (default is apostrophe: ') 126 | * @see Console#dispose() 127 | */ 128 | public GUIConsole (Skin skin, boolean useMultiplexer, int keyID) { 129 | this(skin, useMultiplexer, keyID, Window.class, Table.class, "default-rect", TextField.class, TextButton.class, 130 | Label.class, ScrollPane.class); 131 | } 132 | 133 | public GUIConsole (Skin skin, boolean useMultiplexer, int keyID, Class windowClass, 134 | Class tableClass, String tableBackground, Class textFieldClass, 135 | Class textButtonClass, Class labelClass, 136 | Class scrollPaneClass) { 137 | 138 | this.tableClass = tableClass; 139 | this.tableBackground = tableBackground; 140 | this.textFieldClass = textFieldClass; 141 | this.textButtonClass = textButtonClass; 142 | this.labelClass = labelClass; 143 | this.scrollPaneClass = scrollPaneClass; 144 | 145 | this.keyID = keyID; 146 | stage = new Stage(); 147 | display = new ConsoleDisplay(skin); 148 | commandHistory = new CommandHistory(); 149 | commandCompleter = new CommandCompleter(); 150 | logToSystem = false; 151 | 152 | usesMultiplexer = useMultiplexer; 153 | if (useMultiplexer) { 154 | resetInputProcessing(); 155 | } 156 | 157 | display.root.pad(4); 158 | display.root.padTop(22); 159 | display.root.setFillParent(true); 160 | display.showSubmit(false); 161 | 162 | try { 163 | consoleWindow = (Window) ClassReflection.getConstructor(Window.class, String.class, Skin.class) 164 | .newInstance("Console", skin); 165 | } catch (Exception e) { 166 | try { 167 | consoleWindow = (Window) ClassReflection.getConstructor(Window.class, String.class) 168 | .newInstance("Console"); 169 | } catch (Exception e2) { 170 | throw new RuntimeException("Window class does not support either (, ) or () constructors."); 171 | } 172 | } 173 | consoleWindow.setMovable(true); 174 | consoleWindow.setResizable(true); 175 | consoleWindow.setKeepWithinStage(true); 176 | consoleWindow.addActor(display.root); 177 | consoleWindow.setTouchable(Touchable.disabled); 178 | 179 | hoverColor = new Color(1, 1, 1, 1); 180 | noHoverColor = new Color(1, 1, 1, 1); 181 | 182 | stage.addListener(new DisplayListener()); 183 | stage.addActor(consoleWindow); 184 | stage.setKeyboardFocus(display.root); 185 | 186 | setSizePercent(50, 50); 187 | setPositionPercent(50, 50); 188 | } 189 | 190 | @Override public void setMaxEntries (int numEntries) { 191 | if (numEntries > 0 || numEntries == UNLIMITED_ENTRIES) { 192 | log.setMaxEntries(numEntries); 193 | } else { 194 | throw new IllegalArgumentException("Maximum entries must be greater than 0 or use Console.UNLIMITED_ENTRIES."); 195 | } 196 | } 197 | 198 | @Override public void clear () { 199 | log.getLogEntries().clear(); 200 | display.refresh(); 201 | } 202 | 203 | @Override public void setSize (int width, int height) { 204 | if (width <= 0 || height <= 0) { 205 | throw new IllegalArgumentException("Pixel size must be greater than 0."); 206 | } 207 | consoleWindow.setSize(width, height); 208 | } 209 | 210 | @Override public void setSizePercent (float wPct, float hPct) { 211 | if (wPct <= 0 || hPct <= 0) { 212 | throw new IllegalArgumentException("Size percentage must be greater than 0."); 213 | } 214 | if (wPct > 100 || hPct > 100) { 215 | throw new IllegalArgumentException("Size percentage cannot be greater than 100."); 216 | } 217 | float w = Gdx.graphics.getWidth(), h = Gdx.graphics.getHeight(); 218 | consoleWindow.setSize(w * wPct / 100.0f, h * hPct / 100.0f); 219 | } 220 | 221 | @Override public void setPosition (int x, int y) { 222 | consoleWindow.setPosition(x, y); 223 | } 224 | 225 | @Override public void setPositionPercent (float xPosPct, float yPosPct) { 226 | if (xPosPct > 100 || yPosPct > 100) { 227 | throw new IllegalArgumentException("Error: The console would be drawn outside of the screen."); 228 | } 229 | float w = Gdx.graphics.getWidth(), h = Gdx.graphics.getHeight(); 230 | consoleWindow.setPosition(w * xPosPct / 100.0f, h * yPosPct / 100.0f); 231 | } 232 | 233 | @Override public void resetInputProcessing () { 234 | usesMultiplexer = true; 235 | appInput = Gdx.input.getInputProcessor(); 236 | if (appInput != null) { 237 | if (hasStage(appInput)) { 238 | log("Console already added to input processor!", LogLevel.ERROR); 239 | Gdx.app.log("Console", "Already added to input processor!"); 240 | return; 241 | } 242 | multiplexer = new InputMultiplexer(); 243 | multiplexer.addProcessor(stage); 244 | multiplexer.addProcessor(appInput); 245 | Gdx.input.setInputProcessor(multiplexer); 246 | } else { 247 | Gdx.input.setInputProcessor(stage); 248 | } 249 | } 250 | 251 | /** 252 | * Compares the given processor to the console's stage. If given a multiplexer, it is iterated through recursively to check all 253 | * of the multiplexer's processors for comparison. 254 | * 255 | * @param processor 256 | * @return processor == this.stage 257 | */ 258 | private boolean hasStage (InputProcessor processor) { 259 | if (!(processor instanceof InputMultiplexer)) { 260 | return processor == stage; 261 | } 262 | InputMultiplexer im = (InputMultiplexer)processor; 263 | SnapshotArray ips = im.getProcessors(); 264 | for (InputProcessor ip : ips) { 265 | if (hasStage(ip)) { 266 | return true; 267 | } 268 | } 269 | return false; 270 | } 271 | 272 | @Override public InputProcessor getInputProcessor () { 273 | return stage; 274 | } 275 | 276 | @Override public void draw () { 277 | if (disabled) { 278 | return; 279 | } 280 | stage.act(); 281 | 282 | if (hidden) { 283 | return; 284 | } 285 | stage.draw(); 286 | } 287 | 288 | @Override public void refresh () { 289 | this.refresh(true); 290 | } 291 | 292 | @Override public void refresh (boolean retain) { 293 | float oldWPct = 0, oldHPct = 0, oldXPosPct = 0, oldYPosPct = 0; 294 | if (retain) { 295 | oldWPct = consoleWindow.getWidth() / stage.getWidth() * 100; 296 | oldHPct = consoleWindow.getHeight() / stage.getHeight() * 100; 297 | oldXPosPct = consoleWindow.getX() / stage.getWidth() * 100; 298 | oldYPosPct = consoleWindow.getY() / stage.getHeight() * 100; 299 | } 300 | int width = Gdx.graphics.getWidth(), height = Gdx.graphics.getHeight(); 301 | stage.getViewport().setWorldSize(width, height); 302 | stage.getViewport().update(width, height, true); 303 | if (retain) { 304 | this.setSizePercent(oldWPct, oldHPct); 305 | this.setPositionPercent(oldXPosPct, oldYPosPct); 306 | } 307 | } 308 | 309 | @Override public void log (String msg, LogLevel level) { 310 | super.log(msg, level); 311 | display.refresh(); 312 | } 313 | 314 | @Override public void setDisabled (boolean disabled) { 315 | if (disabled) { 316 | display.setHidden(true); 317 | } 318 | this.disabled = disabled; 319 | } 320 | 321 | @Override public int getDisplayKeyID () { 322 | return keyID; 323 | } 324 | 325 | @Override public void setDisplayKeyID (int code) { 326 | if (code == Keys.ENTER) { 327 | return; 328 | } 329 | keyID = code; 330 | } 331 | 332 | @Override public boolean hitsConsole (float screenX, float screenY) { 333 | if (disabled || hidden) { 334 | return false; 335 | } 336 | stage.getCamera().unproject(stageCoords.set(screenX, screenY, 0)); 337 | return stage.hit(stageCoords.x, stageCoords.y, true) != null; 338 | } 339 | 340 | @Override public void dispose () { 341 | if (usesMultiplexer && appInput != null) { 342 | Gdx.input.setInputProcessor(appInput); 343 | } 344 | stage.dispose(); 345 | } 346 | 347 | @Override public boolean isVisible () { 348 | return !hidden; 349 | } 350 | 351 | @Override public void setVisible (boolean visible) { 352 | display.setHidden(!visible); 353 | } 354 | 355 | @Override public void select () { 356 | display.select(); 357 | } 358 | 359 | @Override public void deselect () { 360 | display.deselect(); 361 | } 362 | 363 | @Override public void setTitle (String title) { 364 | consoleWindow.getTitleLabel().setText(title); 365 | } 366 | 367 | private void refreshWindowColor () { 368 | consoleWindow.setColor(hasHover ? hoverColor : noHoverColor); 369 | } 370 | 371 | @Override public void setHoverAlpha (float alpha) { 372 | hoverColor.a = alpha; 373 | refreshWindowColor(); 374 | } 375 | 376 | @Override public void setNoHoverAlpha (float alpha) { 377 | noHoverColor.a = alpha; 378 | refreshWindowColor(); 379 | } 380 | 381 | @Override public void setHoverColor (Color color) { 382 | hoverColor = color; 383 | refreshWindowColor(); 384 | } 385 | 386 | @Override public void setNoHoverColor (Color color) { 387 | noHoverColor = color; 388 | refreshWindowColor(); 389 | } 390 | 391 | @Override public void enableSubmitButton (boolean enable) { 392 | display.showSubmit(enable); 393 | } 394 | 395 | @Override public void setSubmitText (String text) { 396 | display.setSubmitText(text); 397 | } 398 | 399 | @Override public Window getWindow () { 400 | return this.consoleWindow; 401 | } 402 | 403 | private class ConsoleDisplay { 404 | private Table root, logEntries; 405 | private TextField input; 406 | private TextButton submit; 407 | private Skin skin; 408 | private Array

4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | *

7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *

9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | package com.strongjoshua.console; 15 | 16 | /** 17 | * Headless Console used for servers. 18 | * 19 | * @author Eric 20 | */ 21 | public class HeadlessConsole extends AbstractConsole { 22 | /** 23 | * Creates an Headless console 24 | */ 25 | public HeadlessConsole () { 26 | logToSystem = true; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/com/strongjoshua/console/Log.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 StrongJoshua (strongjoshua@hotmail.com) 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | *

7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *

9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | package com.strongjoshua.console; 15 | 16 | import com.badlogic.gdx.files.FileHandle; 17 | import com.badlogic.gdx.utils.Array; 18 | 19 | import java.io.IOException; 20 | import java.io.Writer; 21 | 22 | public class Log { 23 | private Array logEntries; 24 | private int numEntries = Console.UNLIMITED_ENTRIES; 25 | 26 | protected Log () { 27 | logEntries = new Array(); 28 | } 29 | 30 | public void setMaxEntries (int numEntries) { 31 | this.numEntries = numEntries; 32 | } 33 | 34 | protected void addEntry (String msg, LogLevel level) { 35 | logEntries.add(new LogEntry(msg, level)); 36 | if (logEntries.size > numEntries && numEntries != Console.UNLIMITED_ENTRIES) { 37 | logEntries.removeIndex(0); 38 | } 39 | } 40 | 41 | protected Array getLogEntries () { 42 | return logEntries; 43 | } 44 | 45 | public boolean printToFile (FileHandle fh) { 46 | if (fh.isDirectory()) { 47 | throw new IllegalArgumentException("File cannot be a directory!"); 48 | } 49 | 50 | Writer out = null; 51 | try { 52 | out = fh.writer(false); 53 | } catch (Exception e) { 54 | return false; 55 | } 56 | 57 | String toWrite = ""; 58 | for (LogEntry l : logEntries) { 59 | toWrite += l.toString() + "\n"; 60 | } 61 | 62 | try { 63 | out.write(toWrite); 64 | out.close(); 65 | return true; 66 | } catch (IOException e) { 67 | e.printStackTrace(); 68 | return false; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/com/strongjoshua/console/LogEntry.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 StrongJoshua (strongjoshua@hotmail.com) 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | *

7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *

9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | package com.strongjoshua.console; 15 | 16 | import com.badlogic.gdx.graphics.Color; 17 | import com.badlogic.gdx.utils.TimeUtils; 18 | 19 | public class LogEntry { 20 | private String text; 21 | private LogLevel level; 22 | private long timeStamp; 23 | 24 | protected LogEntry (String msg, LogLevel level) { 25 | this.text = msg; 26 | this.level = level; 27 | timeStamp = TimeUtils.millis(); 28 | } 29 | 30 | public Color getColor () { 31 | return level.getColor(); 32 | } 33 | 34 | protected String toConsoleString () { 35 | String r = ""; 36 | if (level.equals(LogLevel.COMMAND)) { 37 | r += level.getIdentifier(); 38 | } 39 | r += text; 40 | return r; 41 | } 42 | 43 | @Override public String toString () { 44 | return timeStamp + ": " + level.getIdentifier() + text; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/com/strongjoshua/console/LogLevel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 StrongJoshua (strongjoshua@hotmail.com) 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | *

7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *

9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions 11 | * and limitations under the License. 12 | */ 13 | 14 | package com.strongjoshua.console; 15 | 16 | import com.badlogic.gdx.graphics.Color; 17 | 18 | /** 19 | * Specifies the 'level' of a log entry. The level affects the color of the entry in the console and is also displayed next to the 20 | * entry when the log entries are printed to a file with {@link Console#printLogToFile(String)}. 21 | * 22 | * @author StrongJoshua 23 | */ 24 | public enum LogLevel { 25 | /** 26 | * The default log level. Prints in white to the console and has no special indicator in the log file.
27 | * Intentional Use: debugging. 28 | */ 29 | DEFAULT(new Color(1, 1, 1, 1), ""), /** 30 | * Use to print errors. Prints in red to the console and has the 'ERROR' marking in 31 | * the log file.
32 | * Intentional Use: printing internal console errors; debugging. 33 | */ 34 | ERROR(new Color(217f / 255f, 0, 0, 1), "Error: "), /** 35 | * Prints in green. Use to print success notifications of events.
36 | * Intentional Use: Print successful execution of console commands (if needed). 37 | */ 38 | SUCCESS(new Color(0, 217f / 255f, 0, 1), "Success! "), /** 39 | * Prints in white with {@literal "> "} prepended to the command. Also has 40 | * that prepended text as the indicator in the log file.
41 | * Intentional Use: To be used by the console, alone. 42 | */ 43 | COMMAND(new Color(1, 1, 1, 1), "> "); 44 | 45 | private Color color; 46 | private String identifier; 47 | 48 | LogLevel (Color c, String identity) { 49 | this.color = c; 50 | identifier = identity; 51 | } 52 | 53 | Color getColor () { 54 | return color; 55 | } 56 | 57 | String getIdentifier () { 58 | return identifier; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/com/strongjoshua/console/annotation/ConsoleDoc.java: -------------------------------------------------------------------------------- 1 | package com.strongjoshua.console.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface ConsoleDoc { 9 | String description () default ""; 10 | 11 | /** 12 | * Put these in the same order as your actual function parameters. 13 | * 14 | * @return An array of parameter descriptions. 15 | */ 16 | String[] paramDescriptions () default {}; 17 | } 18 | -------------------------------------------------------------------------------- /src/com/strongjoshua/console/annotation/HiddenCommand.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | package com.strongjoshua.console.annotation; 6 | 7 | import java.lang.annotation.*; 8 | 9 | /** 10 | * @author Eric Burns (ThaBalla1148) 11 | */ 12 | @Documented @Target(ElementType.METHOD) @Inherited @Retention(RetentionPolicy.RUNTIME) public @interface HiddenCommand { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/default_skin/default.fnt: -------------------------------------------------------------------------------- 1 | info face="Droid Sans" size=17 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1 2 | common lineHeight=20 base=18 scaleW=256 scaleH=128 pages=1 packed=0 3 | page id=0 file="default.png" 4 | chars count=96 5 | char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=16 xadvance=4 page=0 chnl=0 6 | char id=124 x=0 y=0 width=6 height=20 xoffset=1 yoffset=3 xadvance=9 page=0 chnl=0 7 | char id=106 x=6 y=0 width=9 height=20 xoffset=-4 yoffset=3 xadvance=4 page=0 chnl=0 8 | char id=81 x=15 y=0 width=15 height=19 xoffset=-2 yoffset=3 xadvance=12 page=0 chnl=0 9 | char id=74 x=30 y=0 width=11 height=19 xoffset=-5 yoffset=3 xadvance=4 page=0 chnl=0 10 | char id=125 x=41 y=0 width=10 height=18 xoffset=-3 yoffset=3 xadvance=6 page=0 chnl=0 11 | char id=123 x=51 y=0 width=10 height=18 xoffset=-3 yoffset=3 xadvance=6 page=0 chnl=0 12 | char id=93 x=61 y=0 width=8 height=18 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0 13 | char id=91 x=69 y=0 width=8 height=18 xoffset=-2 yoffset=3 xadvance=5 page=0 chnl=0 14 | char id=41 x=77 y=0 width=9 height=18 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0 15 | char id=40 x=86 y=0 width=9 height=18 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0 16 | char id=64 x=95 y=0 width=18 height=17 xoffset=-3 yoffset=3 xadvance=14 page=0 chnl=0 17 | char id=121 x=113 y=0 width=13 height=17 xoffset=-3 yoffset=6 xadvance=8 page=0 chnl=0 18 | char id=113 x=126 y=0 width=13 height=17 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0 19 | char id=112 x=139 y=0 width=13 height=17 xoffset=-2 yoffset=6 xadvance=9 page=0 chnl=0 20 | char id=103 x=152 y=0 width=13 height=17 xoffset=-3 yoffset=6 xadvance=8 page=0 chnl=0 21 | char id=38 x=165 y=0 width=16 height=16 xoffset=-3 yoffset=3 xadvance=11 page=0 chnl=0 22 | char id=37 x=181 y=0 width=18 height=16 xoffset=-3 yoffset=3 xadvance=14 page=0 chnl=0 23 | char id=36 x=199 y=0 width=12 height=16 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0 24 | char id=63 x=211 y=0 width=11 height=16 xoffset=-3 yoffset=3 xadvance=7 page=0 chnl=0 25 | char id=33 x=222 y=0 width=7 height=16 xoffset=-2 yoffset=3 xadvance=4 page=0 chnl=0 26 | char id=48 x=229 y=0 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 27 | char id=57 x=242 y=0 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 28 | char id=56 x=0 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 29 | char id=54 x=13 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 30 | char id=53 x=26 y=20 width=12 height=16 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0 31 | char id=51 x=38 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 32 | char id=100 x=51 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 33 | char id=98 x=64 y=20 width=13 height=16 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0 34 | char id=85 x=77 y=20 width=14 height=16 xoffset=-2 yoffset=3 xadvance=11 page=0 chnl=0 35 | char id=83 x=91 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=8 page=0 chnl=0 36 | char id=79 x=104 y=20 width=15 height=16 xoffset=-2 yoffset=3 xadvance=12 page=0 chnl=0 37 | char id=71 x=119 y=20 width=14 height=16 xoffset=-2 yoffset=3 xadvance=11 page=0 chnl=0 38 | char id=67 x=133 y=20 width=13 height=16 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0 39 | char id=127 x=146 y=20 width=12 height=15 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0 40 | char id=35 x=158 y=20 width=15 height=15 xoffset=-3 yoffset=3 xadvance=10 page=0 chnl=0 41 | char id=92 x=173 y=20 width=11 height=15 xoffset=-3 yoffset=3 xadvance=6 page=0 chnl=0 42 | char id=47 x=184 y=20 width=11 height=15 xoffset=-3 yoffset=3 xadvance=6 page=0 chnl=0 43 | char id=59 x=195 y=20 width=8 height=15 xoffset=-3 yoffset=6 xadvance=4 page=0 chnl=0 44 | char id=55 x=203 y=20 width=13 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 45 | char id=52 x=216 y=20 width=14 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 46 | char id=50 x=230 y=20 width=13 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 47 | char id=49 x=243 y=20 width=9 height=15 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0 48 | char id=116 x=0 y=36 width=10 height=15 xoffset=-3 yoffset=4 xadvance=5 page=0 chnl=0 49 | char id=108 x=10 y=36 width=6 height=15 xoffset=-2 yoffset=3 xadvance=4 page=0 chnl=0 50 | char id=107 x=16 y=36 width=12 height=15 xoffset=-2 yoffset=3 xadvance=8 page=0 chnl=0 51 | char id=105 x=28 y=36 width=7 height=15 xoffset=-2 yoffset=3 xadvance=4 page=0 chnl=0 52 | char id=104 x=35 y=36 width=12 height=15 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0 53 | char id=102 x=47 y=36 width=11 height=15 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0 54 | char id=90 x=58 y=36 width=13 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 55 | char id=89 x=71 y=36 width=13 height=15 xoffset=-3 yoffset=3 xadvance=8 page=0 chnl=0 56 | char id=88 x=84 y=36 width=14 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 57 | char id=87 x=98 y=36 width=19 height=15 xoffset=-3 yoffset=3 xadvance=15 page=0 chnl=0 58 | char id=86 x=117 y=36 width=14 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 59 | char id=84 x=131 y=36 width=13 height=15 xoffset=-3 yoffset=3 xadvance=8 page=0 chnl=0 60 | char id=82 x=144 y=36 width=13 height=15 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0 61 | char id=80 x=157 y=36 width=12 height=15 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0 62 | char id=78 x=169 y=36 width=14 height=15 xoffset=-2 yoffset=3 xadvance=12 page=0 chnl=0 63 | char id=77 x=183 y=36 width=17 height=15 xoffset=-2 yoffset=3 xadvance=14 page=0 chnl=0 64 | char id=76 x=200 y=36 width=11 height=15 xoffset=-2 yoffset=3 xadvance=8 page=0 chnl=0 65 | char id=75 x=211 y=36 width=13 height=15 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0 66 | char id=73 x=224 y=36 width=10 height=15 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0 67 | char id=72 x=234 y=36 width=14 height=15 xoffset=-2 yoffset=3 xadvance=11 page=0 chnl=0 68 | char id=70 x=0 y=51 width=11 height=15 xoffset=-2 yoffset=3 xadvance=8 page=0 chnl=0 69 | char id=69 x=11 y=51 width=11 height=15 xoffset=-2 yoffset=3 xadvance=8 page=0 chnl=0 70 | char id=68 x=22 y=51 width=14 height=15 xoffset=-2 yoffset=3 xadvance=11 page=0 chnl=0 71 | char id=66 x=36 y=51 width=13 height=15 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0 72 | char id=65 x=49 y=51 width=15 height=15 xoffset=-3 yoffset=3 xadvance=10 page=0 chnl=0 73 | char id=58 x=64 y=51 width=7 height=13 xoffset=-2 yoffset=6 xadvance=4 page=0 chnl=0 74 | char id=117 x=71 y=51 width=12 height=13 xoffset=-2 yoffset=6 xadvance=10 page=0 chnl=0 75 | char id=115 x=83 y=51 width=11 height=13 xoffset=-3 yoffset=6 xadvance=7 page=0 chnl=0 76 | char id=111 x=94 y=51 width=13 height=13 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0 77 | char id=101 x=107 y=51 width=13 height=13 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0 78 | char id=99 x=120 y=51 width=12 height=13 xoffset=-3 yoffset=6 xadvance=7 page=0 chnl=0 79 | char id=97 x=132 y=51 width=12 height=13 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0 80 | char id=60 x=144 y=51 width=13 height=12 xoffset=-3 yoffset=5 xadvance=9 page=0 chnl=0 81 | char id=122 x=157 y=51 width=11 height=12 xoffset=-3 yoffset=6 xadvance=7 page=0 chnl=0 82 | char id=120 x=168 y=51 width=13 height=12 xoffset=-3 yoffset=6 xadvance=8 page=0 chnl=0 83 | char id=119 x=181 y=51 width=17 height=12 xoffset=-3 yoffset=6 xadvance=12 page=0 chnl=0 84 | char id=118 x=198 y=51 width=13 height=12 xoffset=-3 yoffset=6 xadvance=8 page=0 chnl=0 85 | char id=114 x=211 y=51 width=10 height=12 xoffset=-2 yoffset=6 xadvance=6 page=0 chnl=0 86 | char id=110 x=221 y=51 width=12 height=12 xoffset=-2 yoffset=6 xadvance=10 page=0 chnl=0 87 | char id=109 x=233 y=51 width=17 height=12 xoffset=-2 yoffset=6 xadvance=15 page=0 chnl=0 88 | char id=94 x=0 y=66 width=13 height=11 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 89 | char id=62 x=13 y=66 width=13 height=11 xoffset=-3 yoffset=5 xadvance=9 page=0 chnl=0 90 | char id=42 x=26 y=66 width=13 height=10 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 91 | char id=43 x=39 y=66 width=13 height=10 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0 92 | char id=61 x=52 y=66 width=13 height=8 xoffset=-3 yoffset=7 xadvance=9 page=0 chnl=0 93 | char id=39 x=65 y=66 width=6 height=8 xoffset=-2 yoffset=3 xadvance=3 page=0 chnl=0 94 | char id=34 x=71 y=66 width=9 height=8 xoffset=-2 yoffset=3 xadvance=6 page=0 chnl=0 95 | char id=44 x=80 y=66 width=8 height=7 xoffset=-3 yoffset=14 xadvance=4 page=0 chnl=0 96 | char id=126 x=88 y=66 width=13 height=6 xoffset=-3 yoffset=8 xadvance=9 page=0 chnl=0 97 | char id=46 x=101 y=66 width=7 height=6 xoffset=-2 yoffset=13 xadvance=4 page=0 chnl=0 98 | char id=96 x=108 y=66 width=8 height=6 xoffset=0 yoffset=2 xadvance=9 page=0 chnl=0 99 | char id=45 x=116 y=66 width=9 height=5 xoffset=-3 yoffset=10 xadvance=5 page=0 chnl=0 100 | char id=95 x=125 y=66 width=13 height=4 xoffset=-4 yoffset=17 xadvance=6 page=0 chnl=0 101 | kernings count=-1 -------------------------------------------------------------------------------- /src/default_skin/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StrongJoshua/libgdx-inGameConsole/6ef713ee3fe2b94e553943ce64700b15149e2888/src/default_skin/default.png -------------------------------------------------------------------------------- /src/default_skin/uiskin.atlas: -------------------------------------------------------------------------------- 1 | 2 | uiskin.png 3 | size: 256,128 4 | format: RGBA8888 5 | filter: Linear,Linear 6 | repeat: none 7 | check-off 8 | rotate: false 9 | xy: 11, 5 10 | size: 14, 14 11 | orig: 14, 14 12 | offset: 0, 0 13 | index: -1 14 | textfield 15 | rotate: false 16 | xy: 11, 5 17 | size: 14, 14 18 | split: 3, 3, 3, 3 19 | orig: 14, 14 20 | offset: 0, 0 21 | index: -1 22 | check-on 23 | rotate: false 24 | xy: 125, 35 25 | size: 14, 14 26 | orig: 14, 14 27 | offset: 0, 0 28 | index: -1 29 | cursor 30 | rotate: false 31 | xy: 23, 1 32 | size: 3, 3 33 | split: 1, 1, 1, 1 34 | orig: 3, 3 35 | offset: 0, 0 36 | index: -1 37 | default 38 | rotate: false 39 | xy: 1, 50 40 | size: 254, 77 41 | orig: 254, 77 42 | offset: 0, 0 43 | index: -1 44 | default-pane 45 | rotate: false 46 | xy: 11, 1 47 | size: 5, 3 48 | split: 1, 1, 1, 1 49 | orig: 5, 3 50 | offset: 0, 0 51 | index: -1 52 | default-rect-pad 53 | rotate: false 54 | xy: 11, 1 55 | size: 5, 3 56 | split: 1, 1, 1, 1 57 | orig: 5, 3 58 | offset: 0, 0 59 | index: -1 60 | default-pane-noborder 61 | rotate: false 62 | xy: 170, 44 63 | size: 1, 1 64 | split: 0, 0, 0, 0 65 | orig: 1, 1 66 | offset: 0, 0 67 | index: -1 68 | default-rect 69 | rotate: false 70 | xy: 38, 25 71 | size: 3, 3 72 | split: 1, 1, 1, 1 73 | orig: 3, 3 74 | offset: 0, 0 75 | index: -1 76 | default-rect-down 77 | rotate: false 78 | xy: 170, 46 79 | size: 3, 3 80 | split: 1, 1, 1, 1 81 | orig: 3, 3 82 | offset: 0, 0 83 | index: -1 84 | default-round 85 | rotate: false 86 | xy: 112, 29 87 | size: 12, 20 88 | split: 5, 5, 5, 4 89 | pad: 4, 4, 1, 1 90 | orig: 12, 20 91 | offset: 0, 0 92 | index: -1 93 | default-round-down 94 | rotate: false 95 | xy: 99, 29 96 | size: 12, 20 97 | split: 5, 5, 5, 4 98 | pad: 4, 4, 1, 1 99 | orig: 12, 20 100 | offset: 0, 0 101 | index: -1 102 | default-round-large 103 | rotate: false 104 | xy: 57, 29 105 | size: 20, 20 106 | split: 5, 5, 5, 4 107 | orig: 20, 20 108 | offset: 0, 0 109 | index: -1 110 | default-scroll 111 | rotate: false 112 | xy: 78, 29 113 | size: 20, 20 114 | split: 2, 2, 2, 2 115 | orig: 20, 20 116 | offset: 0, 0 117 | index: -1 118 | default-select 119 | rotate: false 120 | xy: 29, 29 121 | size: 27, 20 122 | split: 4, 14, 4, 4 123 | orig: 27, 20 124 | offset: 0, 0 125 | index: -1 126 | default-select-selection 127 | rotate: false 128 | xy: 26, 16 129 | size: 3, 3 130 | split: 1, 1, 1, 1 131 | orig: 3, 3 132 | offset: 0, 0 133 | index: -1 134 | default-slider 135 | rotate: false 136 | xy: 29, 20 137 | size: 8, 8 138 | split: 2, 2, 2, 2 139 | orig: 8, 8 140 | offset: 0, 0 141 | index: -1 142 | default-slider-knob 143 | rotate: false 144 | xy: 1, 1 145 | size: 9, 18 146 | orig: 9, 18 147 | offset: 0, 0 148 | index: -1 149 | default-splitpane 150 | rotate: false 151 | xy: 17, 1 152 | size: 5, 3 153 | split: 0, 5, 0, 0 154 | orig: 5, 3 155 | offset: 0, 0 156 | index: -1 157 | default-splitpane-vertical 158 | rotate: false 159 | xy: 125, 29 160 | size: 3, 5 161 | split: 0, 0, 0, 5 162 | orig: 3, 5 163 | offset: 0, 0 164 | index: -1 165 | default-window 166 | rotate: false 167 | xy: 1, 20 168 | size: 27, 29 169 | split: 4, 3, 20, 3 170 | orig: 27, 29 171 | offset: 0, 0 172 | index: -1 173 | selection 174 | rotate: false 175 | xy: 174, 48 176 | size: 1, 1 177 | orig: 1, 1 178 | offset: 0, 0 179 | index: -1 180 | tree-minus 181 | rotate: false 182 | xy: 140, 35 183 | size: 14, 14 184 | orig: 14, 14 185 | offset: 0, 0 186 | index: -1 187 | tree-plus 188 | rotate: false 189 | xy: 155, 35 190 | size: 14, 14 191 | orig: 14, 14 192 | offset: 0, 0 193 | index: -1 194 | white 195 | rotate: false 196 | xy: 129, 31 197 | size: 3, 3 198 | orig: 3, 3 199 | offset: 0, 0 200 | index: -1 -------------------------------------------------------------------------------- /src/default_skin/uiskin.json: -------------------------------------------------------------------------------- 1 | { 2 | com.badlogic.gdx.graphics.g2d.BitmapFont: { 3 | default-font: { 4 | file: default.fnt 5 | } 6 | }, 7 | com.badlogic.gdx.graphics.Color: { 8 | green: { 9 | a: 1, 10 | b: 0, 11 | g: 1, 12 | r: 0 13 | }, 14 | white: { 15 | a: 1, 16 | b: 1, 17 | g: 1, 18 | r: 1 19 | }, 20 | red: { 21 | a: 1, 22 | b: 0, 23 | g: 0, 24 | r: 1 25 | }, 26 | black: { 27 | a: 1, 28 | b: 0, 29 | g: 0, 30 | r: 0 31 | } 32 | }, 33 | com.badlogic.gdx.scenes.scene2d.ui.Skin$TintedDrawable: { 34 | dialogDim: { 35 | name: white, 36 | color: { 37 | r: 0, 38 | g: 0, 39 | b: 0, 40 | a: 0.45 41 | } 42 | } 43 | }, 44 | com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle: { 45 | default: { 46 | down: default-round-down, 47 | up: default-round 48 | }, 49 | toggle: { 50 | down: default-round-down, 51 | checked: default-round-down, 52 | up: default-round 53 | } 54 | }, 55 | com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle: { 56 | default: { 57 | down: default-round-down, 58 | up: default-round, 59 | font: default-font, 60 | fontColor: white 61 | }, 62 | toggle: { 63 | down: default-round-down, 64 | up: default-round, 65 | checked: default-round-down, 66 | font: default-font, 67 | fontColor: white, 68 | downFontColor: red 69 | } 70 | }, 71 | com.badlogic.gdx.scenes.scene2d.ui.ScrollPane$ScrollPaneStyle: { 72 | default: { 73 | vScroll: default-scroll, 74 | hScrollKnob: default-round-large, 75 | background: default-rect, 76 | hScroll: default-scroll, 77 | vScrollKnob: default-round-large 78 | } 79 | }, 80 | com.badlogic.gdx.scenes.scene2d.ui.SelectBox$SelectBoxStyle: { 81 | default: { 82 | font: default-font, 83 | fontColor: white, 84 | background: default-select, 85 | scrollStyle: default, 86 | listStyle: { 87 | font: default-font, 88 | selection: default-select-selection 89 | } 90 | } 91 | }, 92 | com.badlogic.gdx.scenes.scene2d.ui.SplitPane$SplitPaneStyle: { 93 | default-vertical: { 94 | handle: default-splitpane-vertical 95 | }, 96 | default-horizontal: { 97 | handle: default-splitpane 98 | } 99 | }, 100 | com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle: { 101 | default: { 102 | titleFont: default-font, 103 | background: default-window, 104 | titleFontColor: white 105 | }, 106 | dialog: { 107 | titleFont: default-font, 108 | background: default-window, 109 | titleFontColor: white, 110 | stageBackground: dialogDim 111 | } 112 | }, 113 | com.badlogic.gdx.scenes.scene2d.ui.ProgressBar$ProgressBarStyle: { 114 | default-horizontal: { 115 | background: default-slider, 116 | knob: default-slider-knob 117 | }, 118 | default-vertical: { 119 | background: default-slider, 120 | knob: default-round-large 121 | } 122 | }, 123 | com.badlogic.gdx.scenes.scene2d.ui.Slider$SliderStyle: { 124 | default-horizontal: { 125 | background: default-slider, 126 | knob: default-slider-knob 127 | }, 128 | default-vertical: { 129 | background: default-slider, 130 | knob: default-round-large 131 | } 132 | }, 133 | com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle: { 134 | default: { 135 | font: default-font, 136 | fontColor: white 137 | } 138 | }, 139 | com.badlogic.gdx.scenes.scene2d.ui.TextField$TextFieldStyle: { 140 | default: { 141 | selection: selection, 142 | background: textfield, 143 | font: default-font, 144 | fontColor: white, 145 | cursor: cursor 146 | } 147 | }, 148 | com.badlogic.gdx.scenes.scene2d.ui.CheckBox$CheckBoxStyle: { 149 | default: { 150 | checkboxOn: check-on, 151 | checkboxOff: check-off, 152 | font: default-font, 153 | fontColor: white 154 | } 155 | }, 156 | com.badlogic.gdx.scenes.scene2d.ui.List$ListStyle: { 157 | default: { 158 | fontColorUnselected: white, 159 | selection: selection, 160 | fontColorSelected: white, 161 | font: default-font 162 | } 163 | }, 164 | com.badlogic.gdx.scenes.scene2d.ui.Touchpad$TouchpadStyle: { 165 | default: { 166 | background: default-pane, 167 | knob: default-round-large 168 | } 169 | }, 170 | com.badlogic.gdx.scenes.scene2d.ui.Tree$TreeStyle: { 171 | default: { 172 | minus: tree-minus, 173 | plus: tree-plus, 174 | selection: default-select-selection 175 | } 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /src/default_skin/uiskin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StrongJoshua/libgdx-inGameConsole/6ef713ee3fe2b94e553943ce64700b15149e2888/src/default_skin/uiskin.png -------------------------------------------------------------------------------- /test/com/strongjoshua/console/CommandHistoryTest.java: -------------------------------------------------------------------------------- 1 | package com.strongjoshua.console; 2 | 3 | import org.junit.Before; 4 | import org.junit.Test; 5 | 6 | import static org.junit.Assert.assertEquals; 7 | 8 | public class CommandHistoryTest { 9 | private CommandHistory history; 10 | 11 | @Before public void setUp () throws Exception { 12 | history = new CommandHistory(); 13 | } 14 | 15 | @Test public void shouldCycleFromBeginningIfPreviousCommandIsUsedAtTheEndOfHistory () { 16 | history.store("1"); 17 | history.store("2"); 18 | 19 | history.getPreviousCommand(); 20 | history.getPreviousCommand(); 21 | 22 | assertEquals("2", history.getPreviousCommand()); 23 | } 24 | 25 | @Test public void shouldOnlyStoreACommandOnceIfItIsRanMultipleTimesRightAfterEachOther () { 26 | history.store("1"); 27 | history.store("2"); 28 | history.store("2"); 29 | 30 | assertEquals("2", history.getPreviousCommand()); 31 | assertEquals("1", history.getPreviousCommand()); 32 | } 33 | 34 | @Test public void shouldResetTheHistoryPositionWhenANewCommandIsStored () { 35 | history.store("command 1"); 36 | history.store("command 2"); 37 | history.store("command 3"); 38 | history.getPreviousCommand(); 39 | 40 | history.store("command 4"); 41 | assertEquals("command 4", history.getPreviousCommand()); 42 | } 43 | 44 | @Test public void shouldAllowGoingOverTheCompleteCommandHistory () { 45 | for (int i = 0; i < 5; i++) { 46 | history.store("command " + i); 47 | } 48 | 49 | for (int i = 4; i >= 0; i--) { 50 | assertEquals("command " + i, history.getPreviousCommand()); 51 | } 52 | 53 | for (int i = 1; i < 5; i++) { 54 | assertEquals("command " + i, history.getNextCommand()); 55 | } 56 | } 57 | 58 | @Test public void shouldNotReturnTheLastStoredCommandWhenGoingToTheNextCommand () { 59 | history.store("command"); 60 | 61 | assertEquals("", history.getNextCommand()); 62 | } 63 | 64 | @Test public void shouldNotReturnThePreviousCommandWhenGoingToTheNextCommand () { 65 | history.store("command 2"); 66 | 67 | assertEquals("command 2", history.getPreviousCommand()); 68 | assertEquals("", history.getNextCommand()); 69 | } 70 | 71 | @Test public void shouldReturnNothingWhenTryingToLookAtFutureCommandsThatDoNotExist () { 72 | history.store("command"); 73 | assertEquals("", history.getNextCommand()); 74 | assertEquals("", history.getNextCommand()); 75 | } 76 | 77 | @Test public void shouldAllowMeToFindMyPreviousCommand () { 78 | history.store("command"); 79 | 80 | assertEquals("command", history.getPreviousCommand()); 81 | } 82 | 83 | @Test public void shouldReturnTheLastCommandRunWhenThereAreNoMorePastCommands () { 84 | history.store("command"); 85 | history.getPreviousCommand(); 86 | 87 | assertEquals("command", history.getPreviousCommand()); 88 | } 89 | 90 | @Test public void shouldReturnNothingWhenWeHaveNoHistory () { 91 | assertEquals("", history.getPreviousCommand()); 92 | assertEquals("", history.getNextCommand()); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /test/com/strongjoshua/console/ConsoleTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | package com.strongjoshua.console; 6 | 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | 10 | import static org.junit.Assert.assertFalse; 11 | import static org.junit.Assert.assertTrue; 12 | 13 | /** 14 | * @author Eric 15 | */ 16 | public class ConsoleTest { 17 | 18 | private Console headlessConsole; 19 | private CommandExecutor commandExec; 20 | private boolean commandFound; 21 | 22 | @Before public void setup () { 23 | commandFound = false; 24 | headlessConsole = new HeadlessConsole(); 25 | commandExec = new CommandExecutor() { 26 | 27 | public void testString (String str) { 28 | commandFound = true; 29 | 30 | console.log(str); 31 | } 32 | 33 | public void testBoolean (Boolean arg1, boolean arg2) { 34 | commandFound = true; 35 | 36 | console.log(String.valueOf(arg1)); 37 | console.log(String.valueOf(arg2)); 38 | } 39 | 40 | public void testByte (Byte arg1, byte arg2) { 41 | commandFound = true; 42 | 43 | console.log(String.valueOf(arg1)); 44 | console.log(String.valueOf(arg2)); 45 | } 46 | 47 | public void testShort (Short arg1, short arg2) { 48 | commandFound = true; 49 | 50 | console.log(String.valueOf(arg1)); 51 | console.log(String.valueOf(arg2)); 52 | } 53 | 54 | public void testInteger (Integer arg1, int arg2) { 55 | commandFound = true; 56 | 57 | console.log(String.valueOf(arg1)); 58 | console.log(String.valueOf(arg2)); 59 | } 60 | 61 | public void testLong (Long arg1, long arg2) { 62 | commandFound = true; 63 | 64 | console.log(String.valueOf(arg1)); 65 | console.log(String.valueOf(arg2)); 66 | } 67 | 68 | public void testFloat (Float arg1, float arg2) { 69 | commandFound = true; 70 | 71 | console.log(String.valueOf(arg1)); 72 | console.log(String.valueOf(arg2)); 73 | } 74 | 75 | public void testDouble (Double arg1, double arg2) { 76 | commandFound = true; 77 | 78 | console.log(String.valueOf(arg1)); 79 | console.log(String.valueOf(arg2)); 80 | } 81 | 82 | public void testObject (Object arg1) { 83 | commandFound = true; 84 | 85 | console.log(String.valueOf(arg1)); 86 | } 87 | }; 88 | 89 | headlessConsole.setCommandExecutor(commandExec); 90 | } 91 | 92 | @Test public void test_StringArgument () { 93 | headlessConsole.execCommand("testString STRING"); 94 | 95 | assertTrue(commandFound); 96 | } 97 | 98 | @Test public void test_BooleanArgument () { 99 | headlessConsole.execCommand("testBoolean true false"); 100 | 101 | assertTrue(commandFound); 102 | } 103 | 104 | @Test public void test_ByteArgument () { 105 | headlessConsole.execCommand("testByte " + Byte.MAX_VALUE + " " + Byte.MIN_VALUE); 106 | 107 | assertTrue(commandFound); 108 | } 109 | 110 | @Test public void test_ShortArgument () { 111 | headlessConsole.execCommand("testShort " + Short.MAX_VALUE + " " + Short.MIN_VALUE); 112 | 113 | assertTrue(commandFound); 114 | } 115 | 116 | @Test public void test_IntegerArgument () { 117 | headlessConsole.execCommand("testInteger " + Integer.MAX_VALUE + " " + Integer.MIN_VALUE); 118 | 119 | assertTrue(commandFound); 120 | } 121 | 122 | @Test public void test_LongArgument () { 123 | headlessConsole.execCommand("testLong " + Long.MAX_VALUE + " " + Long.MIN_VALUE); 124 | 125 | assertTrue(commandFound); 126 | } 127 | 128 | @Test public void test_FloatArgument () { 129 | headlessConsole.execCommand("testFloat " + Float.MAX_VALUE + " " + Float.MIN_VALUE); 130 | 131 | assertTrue(commandFound); 132 | } 133 | 134 | @Test public void test_DoubleArgument () { 135 | headlessConsole.execCommand("testDouble " + Double.MAX_VALUE + " " + Double.MIN_VALUE); 136 | 137 | assertTrue(commandFound); 138 | } 139 | 140 | @Test public void test_ObjectArgument () { 141 | headlessConsole.execCommand("testObject test test"); 142 | 143 | assertFalse(commandFound); 144 | } 145 | 146 | } 147 | -------------------------------------------------------------------------------- /test/tests/Box2DTest.java: -------------------------------------------------------------------------------- 1 | package tests; 2 | 3 | import com.badlogic.gdx.ApplicationAdapter; 4 | import com.badlogic.gdx.Gdx; 5 | import com.badlogic.gdx.Input; 6 | import com.badlogic.gdx.InputMultiplexer; 7 | import com.badlogic.gdx.backends.lwjgl.LwjglApplication; 8 | import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; 9 | import com.badlogic.gdx.graphics.Color; 10 | import com.badlogic.gdx.graphics.GL20; 11 | import com.badlogic.gdx.graphics.OrthographicCamera; 12 | import com.badlogic.gdx.graphics.Texture; 13 | import com.badlogic.gdx.graphics.g2d.Sprite; 14 | import com.badlogic.gdx.graphics.g2d.SpriteBatch; 15 | import com.badlogic.gdx.math.Intersector; 16 | import com.badlogic.gdx.math.MathUtils; 17 | import com.badlogic.gdx.math.Vector2; 18 | import com.badlogic.gdx.math.Vector3; 19 | import com.badlogic.gdx.math.collision.BoundingBox; 20 | import com.badlogic.gdx.math.collision.Ray; 21 | import com.badlogic.gdx.physics.box2d.*; 22 | import com.badlogic.gdx.scenes.scene2d.Stage; 23 | import com.badlogic.gdx.scenes.scene2d.ui.Skin; 24 | import com.strongjoshua.console.CommandExecutor; 25 | import com.strongjoshua.console.Console; 26 | import com.strongjoshua.console.GUIConsole; 27 | import com.strongjoshua.console.LogLevel; 28 | import com.strongjoshua.console.annotation.ConsoleDoc; 29 | import com.strongjoshua.console.annotation.HiddenCommand; 30 | 31 | /** 32 | * Extension of the Simple Box2D 34 | * test to incorporate the console. 35 | * 36 | * @author StrongJoshua 37 | */ 38 | public class Box2DTest extends ApplicationAdapter { 39 | final int WIDTH = 100, HEIGHT = 100; 40 | SpriteBatch batch; 41 | Sprite[] sprites; 42 | World world; 43 | OrthographicCamera c; 44 | Box2DDebugRenderer debugRenderer; 45 | Body[] bodies; 46 | float mX, mY, ratio; 47 | Console console; 48 | MyCommandExecutor cExec; 49 | 50 | public static void main (String[] args) { 51 | LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); 52 | new LwjglApplication(new Box2DTest(), config); 53 | } 54 | 55 | @Override public void create () { 56 | float w = Gdx.graphics.getWidth(); 57 | w *= 2; 58 | float h = Gdx.graphics.getHeight(); 59 | h *= 2; 60 | ratio = h / w; 61 | Gdx.app.getGraphics().setWindowedMode((int)w, (int)h); 62 | 63 | mX = (float)WIDTH / w; 64 | mY = (float)HEIGHT / h; 65 | 66 | Box2D.init(); 67 | world = new World(new Vector2(0, -9.81f), true); 68 | batch = new SpriteBatch(); 69 | 70 | sprites = new Sprite[250]; 71 | bodies = new Body[sprites.length]; 72 | float k, j; 73 | for (int i = 0; i < sprites.length; i++) { 74 | if (i < 50) { 75 | k = 0; 76 | j = 1; 77 | } else if (i < 100) { 78 | k = 50 * sprites[i - 1].getWidth() + sprites[i - 1].getWidth() / 2; 79 | j = 2; 80 | } else if (i < 150) { 81 | k = 100 * sprites[i - 1].getWidth() + sprites[i - 1].getWidth() / 2; 82 | j = 3; 83 | } else if (i < 200) { 84 | k = 150 * sprites[i - 1].getWidth() + sprites[i - 1].getWidth() / 2; 85 | j = 4; 86 | } else { 87 | k = 200 * sprites[i - 1].getWidth() + sprites[i - 1].getWidth() / 2; 88 | j = 5; 89 | } 90 | 91 | sprites[i] = new Sprite(new Texture(Gdx.files.classpath("tests/badlogic.jpg"))); 92 | sprites[i].setSize(2, 2); 93 | sprites[i].setOriginCenter(); 94 | 95 | BodyDef bdef = new BodyDef(); 96 | bdef.type = BodyDef.BodyType.DynamicBody; 97 | bdef.position.set(i * sprites[i].getWidth() + sprites[i].getWidth() / 2 - k, 15 * j); 98 | bodies[i] = world.createBody(bdef); 99 | PolygonShape poly = new PolygonShape(); 100 | poly.setAsBox(sprites[i].getWidth() / 2, sprites[i].getHeight() / 2); 101 | FixtureDef fdef = new FixtureDef(); 102 | fdef.shape = poly; 103 | fdef.restitution = .2f; 104 | fdef.density = 1f; 105 | bodies[i].createFixture(fdef); 106 | 107 | poly.dispose(); 108 | } 109 | 110 | BodyDef bdef = new BodyDef(); 111 | bdef.type = BodyDef.BodyType.StaticBody; 112 | bdef.position.set(WIDTH / 2, -5); 113 | Body b = world.createBody(bdef); 114 | PolygonShape poly = new PolygonShape(); 115 | poly.setAsBox(50, 5); 116 | b.createFixture(poly, 0); 117 | 118 | bdef = new BodyDef(); 119 | bdef.type = BodyDef.BodyType.StaticBody; 120 | bdef.position.set(-5, HEIGHT / 2); 121 | b = world.createBody(bdef); 122 | poly = new PolygonShape(); 123 | poly.setAsBox(5, 50); 124 | b.createFixture(poly, 0); 125 | 126 | bdef = new BodyDef(); 127 | bdef.type = BodyDef.BodyType.StaticBody; 128 | bdef.position.set(WIDTH + 5, (HEIGHT * ratio) / 2); 129 | b = world.createBody(bdef); 130 | poly = new PolygonShape(); 131 | poly.setAsBox(5, 50); 132 | b.createFixture(poly, 0); 133 | 134 | bdef = new BodyDef(); 135 | bdef.type = BodyDef.BodyType.StaticBody; 136 | bdef.position.set(WIDTH / 2, HEIGHT * ratio + 5); 137 | b = world.createBody(bdef); 138 | poly = new PolygonShape(); 139 | poly.setAsBox(50, 5); 140 | b.createFixture(poly, 0); 141 | 142 | poly.dispose(); 143 | 144 | c = new OrthographicCamera(WIDTH, HEIGHT * ratio); 145 | c.position.set(c.viewportWidth / 2, c.viewportHeight / 2, 0); 146 | c.update(); 147 | batch.setProjectionMatrix(c.combined); 148 | 149 | debugRenderer = new Box2DDebugRenderer(); 150 | 151 | console = new GUIConsole(new Skin(Gdx.files.classpath("tests/test_skin/uiskin.json")), false); 152 | cExec = new MyCommandExecutor(); 153 | console.setCommandExecutor(cExec); 154 | // set to 'Z' to demonstrate that it works with binds other than the 155 | // default 156 | console.setDisplayKeyID(Input.Keys.Z); 157 | console.setVisible(true); 158 | console.setConsoleStackTrace(true); 159 | console.setTitle("Test Console"); 160 | console.setHoverColor(Color.WHITE); 161 | console.setNoHoverColor(Color.BLUE); 162 | console.setHoverAlpha(.9f); 163 | console.setNoHoverAlpha(.4f); 164 | 165 | // test multiple resets with nested multiplexers 166 | InputMultiplexer im1 = new InputMultiplexer(); 167 | im1.addProcessor(new Stage()); 168 | im1.addProcessor(new Stage()); 169 | 170 | InputMultiplexer im2 = new InputMultiplexer(); 171 | im2.addProcessor(new Stage()); 172 | im2.addProcessor(new Stage()); 173 | im1.addProcessor(im2); 174 | Gdx.input.setInputProcessor(im1); 175 | console.setMaxEntries(16); 176 | console.resetInputProcessing(); 177 | // console already present, logged to consoles 178 | console.resetInputProcessing(); 179 | 180 | console.setSizePercent(100, 33); 181 | console.setPositionPercent(0, 67); 182 | 183 | console.enableSubmitButton(true); 184 | console.setSubmitText("Fire!"); 185 | } 186 | 187 | @Override public void render () { 188 | if (Gdx.input.isTouched()) { 189 | float x = Gdx.input.getX(); 190 | float y = Gdx.input.getY(); 191 | 192 | if (!console.hitsConsole(x, y)) { 193 | Vector3 worldVector = c.unproject(new Vector3(x, y, 0)); 194 | 195 | createExplosion(worldVector.x, worldVector.y, 2000); 196 | 197 | console 198 | .log(String.format("Created touch explosion at %.2f, %.2f!", worldVector.x, worldVector.y), LogLevel.SUCCESS); 199 | } 200 | } 201 | 202 | if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) 203 | Gdx.app.exit(); 204 | world.step(1 / 60f, 6, 2); 205 | 206 | Gdx.gl.glClearColor(0, 0, 0, 1); 207 | Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 208 | batch.begin(); 209 | for (int i = 0; i < bodies.length; i++) { 210 | Vector2 pos = bodies[i].getPosition(); 211 | sprites[i].setPosition(pos.x - sprites[i].getWidth() / 2, pos.y - sprites[i].getHeight() / 2); 212 | sprites[i].setRotation(MathUtils.radiansToDegrees * bodies[i].getAngle()); 213 | sprites[i].draw(batch); 214 | } 215 | 216 | batch.end(); 217 | 218 | debugRenderer.render(world, c.combined); 219 | 220 | console.draw(); 221 | } 222 | 223 | /** 224 | * Creates an explosion that applies forces to the bodies relative to their position and the given x and y values. 225 | * 226 | * @param maxForce The maximum force to be applied to the bodies (diminishes as distance from touch increases). 227 | */ 228 | private void createExplosion (float x, float y, float maxForce) { 229 | float force; 230 | Vector2 touch = new Vector2(x, y); 231 | for (int i = 0; i < bodies.length; i++) { 232 | Body b = bodies[i]; 233 | Vector2 v = b.getPosition(); 234 | float dist = v.dst2(touch); 235 | 236 | if (dist == 0) 237 | force = maxForce; 238 | else 239 | force = MathUtils.clamp(maxForce / dist, 0, maxForce); 240 | 241 | float angle = v.cpy().sub(touch).angle(); 242 | float xForce = force * MathUtils.cosDeg(angle); 243 | float yForce = force * MathUtils.sinDeg(angle); 244 | 245 | Vector3 touch3, v3, boundMin, boundMax, intersection; 246 | touch3 = new Vector3(touch.x, touch.y, 0); 247 | v3 = new Vector3(v.x, v.y, 0); 248 | boundMin = new Vector3(v.x - 1, v.y - 1, 0); 249 | boundMax = new Vector3(v.x + 1, v.y + 1, 0); 250 | intersection = Vector3.Zero; 251 | 252 | Intersector.intersectRayBounds(new Ray(touch3, v3), new BoundingBox(boundMin, boundMax), intersection); 253 | 254 | b.applyForce(new Vector2(xForce, yForce), new Vector2(intersection.x, intersection.y), true); 255 | } 256 | } 257 | 258 | @Override public void dispose () { 259 | console.dispose(); 260 | super.dispose(); 261 | } 262 | 263 | public class MyCommandExecutor extends CommandExecutor { 264 | @HiddenCommand public void superExplode () { 265 | explode(0, 0, 1000000); 266 | } 267 | 268 | public void setExecuteHiddenCommands (boolean enabled) { 269 | console.setExecuteHiddenCommands(enabled); 270 | console.log("ExecuteHiddenCommands was set to " + enabled); 271 | } 272 | 273 | public void setDisplayHiddenCommands (boolean enabled) { 274 | console.setDisplayHiddenCommands(enabled); 275 | console.log("DisplayHiddenCommands was set to " + enabled); 276 | } 277 | 278 | @ConsoleDoc(description = "Creates an explosion.", paramDescriptions = {"The x coordinate", "The y coordinate", 279 | "The amount of force"}) public void explode (float x, float y, float maxForce) { 280 | createExplosion(x, y, maxForce); 281 | console.log("Created console explosion!", LogLevel.SUCCESS); 282 | } 283 | 284 | public void clear () { 285 | console.clear(); 286 | } 287 | 288 | public void failFunction () { 289 | throw new RuntimeException("This function was designed to fail."); 290 | } 291 | 292 | boolean last = true; 293 | public void toggleSubmit () { 294 | last = !last; 295 | console.enableSubmitButton(last); 296 | } 297 | } 298 | } 299 | -------------------------------------------------------------------------------- /test/tests/StageTest.java: -------------------------------------------------------------------------------- 1 | package tests; 2 | 3 | import com.badlogic.gdx.ApplicationAdapter; 4 | import com.badlogic.gdx.Gdx; 5 | import com.badlogic.gdx.Input; 6 | import com.badlogic.gdx.backends.lwjgl.LwjglApplication; 7 | import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; 8 | import com.badlogic.gdx.graphics.GL20; 9 | import com.badlogic.gdx.graphics.Texture; 10 | import com.badlogic.gdx.scenes.scene2d.Actor; 11 | import com.badlogic.gdx.scenes.scene2d.InputEvent; 12 | import com.badlogic.gdx.scenes.scene2d.InputListener; 13 | import com.badlogic.gdx.scenes.scene2d.Stage; 14 | import com.badlogic.gdx.scenes.scene2d.actions.Actions; 15 | import com.badlogic.gdx.scenes.scene2d.ui.Image; 16 | import com.badlogic.gdx.scenes.scene2d.ui.Label; 17 | import com.badlogic.gdx.scenes.scene2d.ui.Skin; 18 | import com.strongjoshua.console.CommandExecutor; 19 | import com.strongjoshua.console.GUIConsole; 20 | import com.strongjoshua.console.annotation.ConsoleDoc; 21 | 22 | public class StageTest extends ApplicationAdapter { 23 | private Stage stage; 24 | private GUIConsole console; 25 | private Image image; 26 | private Label selectLabel; 27 | private Label deselectLabel; 28 | 29 | public static void main (String[] args) { 30 | LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); 31 | new LwjglApplication(new StageTest(), config); 32 | } 33 | 34 | @Override public void create () { 35 | stage = new Stage(); 36 | Gdx.input.setInputProcessor(stage); 37 | 38 | Skin skin = new Skin(Gdx.files.classpath("tests/test_skin/uiskin.json")); 39 | console = new GUIConsole(skin); 40 | console.setCommandExecutor(new MyCommandExecutor()); 41 | console.setSizePercent(100, 50); 42 | 43 | stage.addListener(new InputListener() { 44 | @Override public boolean keyDown (InputEvent event, int keycode) { 45 | if (keycode == Input.Keys.F) { 46 | blink(); 47 | return true; 48 | } else if (keycode == Input.Keys.TAB) { 49 | console.select(); 50 | return true; 51 | } else if (keycode == Input.Keys.D) { 52 | System.out.println("Console " + (console.isDisabled() ? "enabled" : "disabled")); 53 | console.setDisabled(!console.isDisabled()); 54 | return true; 55 | } 56 | return false; 57 | } 58 | }); 59 | 60 | image = new Image(new Texture(Gdx.files.classpath("tests/badlogic" + "" + ".jpg"))); 61 | image.setScale(.5f); 62 | stage.addActor(image); 63 | 64 | selectLabel = new Label("Select", skin); 65 | deselectLabel = new Label("Deselect", skin); 66 | stage.addActor(selectLabel); 67 | stage.addActor(deselectLabel); 68 | int padding = 25; 69 | selectLabel.setPosition(Gdx.graphics.getWidth() - selectLabel.getWidth() - deselectLabel.getWidth() - 2 * padding, 70 | selectLabel.getHeight()); 71 | deselectLabel.setPosition(Gdx.graphics.getWidth() - deselectLabel.getWidth() - padding, deselectLabel.getHeight()); 72 | } 73 | 74 | @Override public void render () { 75 | if (Gdx.input.justTouched()) { 76 | Actor actor = stage.hit(Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY(), true); 77 | if (actor == selectLabel) { 78 | console.select(); 79 | } else if (actor == deselectLabel) { 80 | console.deselect(); 81 | } 82 | } 83 | 84 | Gdx.gl.glClearColor(0, 0, 0, 1); 85 | Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 86 | 87 | stage.act(); 88 | stage.draw(); 89 | console.draw(); 90 | } 91 | 92 | private void blink () { 93 | image.addAction(Actions.sequence(Actions.fadeOut(1), Actions.fadeIn(1))); 94 | } 95 | 96 | @Override public void dispose () { 97 | console.dispose(); 98 | stage.dispose(); 99 | super.dispose(); 100 | } 101 | 102 | private class MyCommandExecutor extends CommandExecutor { 103 | @ConsoleDoc(description = "Makes the badlogic image fade out and back in.") 104 | public void blink() { 105 | StageTest.this.blink(); 106 | } 107 | 108 | public void setExecuteHiddenCommands (boolean enabled) { 109 | console.setExecuteHiddenCommands(enabled); 110 | console.log("ExecuteHiddenCommands was set to " + enabled); 111 | } 112 | 113 | public void setDisplayHiddenCommands (boolean enabled) { 114 | console.setDisplayHiddenCommands(enabled); 115 | console.log("DisplayHiddenCommands was set to " + enabled); 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /test/tests/VisUITest.java: -------------------------------------------------------------------------------- 1 | package tests; 2 | 3 | import com.badlogic.gdx.ApplicationAdapter; 4 | import com.badlogic.gdx.Gdx; 5 | import com.badlogic.gdx.backends.lwjgl.LwjglApplication; 6 | import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; 7 | import com.badlogic.gdx.graphics.GL20; 8 | import com.badlogic.gdx.scenes.scene2d.ui.TextField; 9 | import com.kotcrab.vis.ui.VisUI; 10 | import com.kotcrab.vis.ui.widget.*; 11 | import com.strongjoshua.console.CommandExecutor; 12 | import com.strongjoshua.console.Console; 13 | import com.strongjoshua.console.GUIConsole; 14 | import com.strongjoshua.console.LogLevel; 15 | 16 | public class VisUITest extends ApplicationAdapter { 17 | public static void main(String[] args) { 18 | new LwjglApplication(new VisUITest(), new LwjglApplicationConfiguration()); 19 | } 20 | 21 | private Console console; 22 | 23 | @Override public void create () { 24 | VisUI.load(); 25 | Gdx.gl.glClearColor(0, 0, 0, 1); 26 | console = new GUIConsole(VisUI.getSkin(), false, 0, VisWindow.class, VisTable.class, "default-pane", TextField.class, 27 | VisTextButton.class, VisLabel.class, VisScrollPane.class); 28 | console.setCommandExecutor(new MyCommandExecutor()); 29 | console.setSizePercent(100, 100); 30 | console.setPosition(0, 0); 31 | console.setVisible(true); 32 | console.enableSubmitButton(true); 33 | console.resetInputProcessing(); 34 | } 35 | 36 | @Override public void render () { 37 | Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 38 | console.draw(); 39 | } 40 | 41 | private class MyCommandExecutor extends CommandExecutor { 42 | public void success() { 43 | console.log("Success", LogLevel.SUCCESS); 44 | } 45 | 46 | public void error() { 47 | console.log("Error", LogLevel.ERROR); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /test/tests/badlogic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StrongJoshua/libgdx-inGameConsole/6ef713ee3fe2b94e553943ce64700b15149e2888/test/tests/badlogic.jpg -------------------------------------------------------------------------------- /test/tests/test_skin/console-font.fnt: -------------------------------------------------------------------------------- 1 | info face="Courier New" size=18 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=-2,-2 2 | common lineHeight=21 base=15 scaleW=512 scaleH=512 pages=1 packed=0 3 | page id=0 file="console-font.png" 4 | chars count=97 5 | char id=0 x=352 y=0 width=12 height=14 xoffset=0 yoffset=2 xadvance=11 page=0 chnl=0 6 | char id=10 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=0 xadvance=0 page=0 chnl=0 7 | char id=32 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=0 xadvance=11 page=0 chnl=0 8 | char id=33 x=327 y=0 width=5 height=14 xoffset=3 yoffset=2 xadvance=11 page=0 chnl=0 9 | char id=34 x=391 y=18 width=9 height=8 xoffset=1 yoffset=2 xadvance=11 page=0 chnl=0 10 | char id=35 x=84 y=0 width=11 height=16 xoffset=0 yoffset=1 xadvance=11 page=0 chnl=0 11 | char id=36 x=9 y=0 width=10 height=17 xoffset=1 yoffset=1 xadvance=11 page=0 chnl=0 12 | char id=37 x=342 y=0 width=10 height=14 xoffset=1 yoffset=2 xadvance=11 page=0 chnl=0 13 | char id=38 x=216 y=18 width=10 height=12 xoffset=1 yoffset=4 xadvance=11 page=0 chnl=0 14 | char id=39 x=400 y=18 width=5 height=8 xoffset=3 yoffset=2 xadvance=11 page=0 chnl=0 15 | char id=40 x=105 y=0 width=6 height=15 xoffset=4 yoffset=3 xadvance=11 page=0 chnl=0 16 | char id=41 x=111 y=0 width=6 height=15 xoffset=2 yoffset=3 xadvance=11 page=0 chnl=0 17 | char id=42 x=382 y=18 width=9 height=9 xoffset=1 yoffset=3 xadvance=11 page=0 chnl=0 18 | char id=43 x=204 y=18 width=12 height=12 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 19 | char id=44 x=405 y=18 width=5 height=8 xoffset=2 yoffset=11 xadvance=11 page=0 chnl=0 20 | char id=45 x=451 y=18 width=11 height=4 xoffset=0 yoffset=7 xadvance=11 page=0 chnl=0 21 | char id=46 x=436 y=18 width=5 height=5 xoffset=3 yoffset=11 xadvance=11 page=0 chnl=0 22 | char id=47 x=53 y=0 width=11 height=16 xoffset=-1 yoffset=1 xadvance=11 page=0 chnl=0 23 | char id=48 x=317 y=0 width=10 height=14 xoffset=1 yoffset=2 xadvance=11 page=0 chnl=0 24 | char id=49 x=249 y=0 width=10 height=14 xoffset=1 yoffset=2 xadvance=11 page=0 chnl=0 25 | char id=50 x=153 y=18 width=11 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 26 | char id=51 x=259 y=0 width=9 height=14 xoffset=1 yoffset=2 xadvance=11 page=0 chnl=0 27 | char id=52 x=268 y=0 width=11 height=14 xoffset=0 yoffset=2 xadvance=11 page=0 chnl=0 28 | char id=53 x=279 y=0 width=10 height=14 xoffset=1 yoffset=2 xadvance=11 page=0 chnl=0 29 | char id=54 x=164 y=18 width=12 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 30 | char id=55 x=289 y=0 width=10 height=14 xoffset=1 yoffset=2 xadvance=11 page=0 chnl=0 31 | char id=56 x=299 y=0 width=9 height=14 xoffset=1 yoffset=2 xadvance=11 page=0 chnl=0 32 | char id=57 x=308 y=0 width=9 height=14 xoffset=1 yoffset=2 xadvance=11 page=0 chnl=0 33 | char id=58 x=356 y=18 width=5 height=11 xoffset=3 yoffset=5 xadvance=11 page=0 chnl=0 34 | char id=59 x=176 y=18 width=6 height=13 xoffset=2 yoffset=5 xadvance=11 page=0 chnl=0 35 | char id=60 x=182 y=18 width=11 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 36 | char id=61 x=419 y=18 width=12 height=7 xoffset=0 yoffset=6 xadvance=11 page=0 chnl=0 37 | char id=62 x=193 y=18 width=11 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 38 | char id=63 x=332 y=0 width=10 height=14 xoffset=1 yoffset=2 xadvance=11 page=0 chnl=0 39 | char id=64 x=64 y=0 width=10 height=16 xoffset=1 yoffset=1 xadvance=11 page=0 chnl=0 40 | char id=65 x=364 y=0 width=14 height=13 xoffset=-1 yoffset=3 xadvance=11 page=0 chnl=0 41 | char id=66 x=378 y=0 width=11 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 42 | char id=67 x=389 y=0 width=12 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 43 | char id=68 x=401 y=0 width=12 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 44 | char id=69 x=413 y=0 width=11 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 45 | char id=70 x=424 y=0 width=11 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 46 | char id=71 x=123 y=0 width=12 height=14 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 47 | char id=72 x=435 y=0 width=12 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 48 | char id=73 x=447 y=0 width=10 height=13 xoffset=1 yoffset=3 xadvance=11 page=0 chnl=0 49 | char id=74 x=457 y=0 width=12 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 50 | char id=75 x=469 y=0 width=12 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 51 | char id=76 x=481 y=0 width=12 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 52 | char id=77 x=493 y=0 width=14 height=13 xoffset=-1 yoffset=3 xadvance=11 page=0 chnl=0 53 | char id=78 x=0 y=18 width=12 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 54 | char id=79 x=12 y=18 width=12 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 55 | char id=80 x=24 y=18 width=10 height=13 xoffset=1 yoffset=3 xadvance=11 page=0 chnl=0 56 | char id=81 x=19 y=0 width=12 height=16 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 57 | char id=82 x=34 y=18 width=12 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 58 | char id=83 x=46 y=18 width=10 height=13 xoffset=1 yoffset=3 xadvance=11 page=0 chnl=0 59 | char id=84 x=56 y=18 width=12 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 60 | char id=85 x=68 y=18 width=12 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 61 | char id=86 x=80 y=18 width=13 height=13 xoffset=-1 yoffset=3 xadvance=11 page=0 chnl=0 62 | char id=87 x=93 y=18 width=14 height=13 xoffset=-1 yoffset=3 xadvance=11 page=0 chnl=0 63 | char id=88 x=107 y=18 width=13 height=13 xoffset=-1 yoffset=3 xadvance=11 page=0 chnl=0 64 | char id=89 x=120 y=18 width=12 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 65 | char id=90 x=132 y=18 width=10 height=13 xoffset=1 yoffset=3 xadvance=11 page=0 chnl=0 66 | char id=91 x=31 y=0 width=6 height=16 xoffset=4 yoffset=2 xadvance=11 page=0 chnl=0 67 | char id=92 x=74 y=0 width=10 height=16 xoffset=0 yoffset=2 xadvance=11 page=0 chnl=0 68 | char id=93 x=37 y=0 width=6 height=16 xoffset=2 yoffset=2 xadvance=11 page=0 chnl=0 69 | char id=94 x=410 y=18 width=9 height=7 xoffset=1 yoffset=2 xadvance=11 page=0 chnl=0 70 | char id=95 x=462 y=18 width=14 height=4 xoffset=-1 yoffset=17 xadvance=11 page=0 chnl=0 71 | char id=96 x=431 y=18 width=5 height=5 xoffset=3 yoffset=2 xadvance=11 page=0 chnl=0 72 | char id=97 x=361 y=18 width=11 height=10 xoffset=1 yoffset=6 xadvance=11 page=0 chnl=0 73 | char id=98 x=135 y=0 width=11 height=14 xoffset=0 yoffset=2 xadvance=11 page=0 chnl=0 74 | char id=99 x=226 y=18 width=11 height=11 xoffset=0 yoffset=5 xadvance=11 page=0 chnl=0 75 | char id=100 x=146 y=0 width=12 height=14 xoffset=0 yoffset=2 xadvance=11 page=0 chnl=0 76 | char id=101 x=237 y=18 width=11 height=11 xoffset=0 yoffset=5 xadvance=11 page=0 chnl=0 77 | char id=102 x=158 y=0 width=10 height=14 xoffset=1 yoffset=2 xadvance=11 page=0 chnl=0 78 | char id=103 x=168 y=0 width=11 height=14 xoffset=0 yoffset=5 xadvance=11 page=0 chnl=0 79 | char id=104 x=179 y=0 width=12 height=14 xoffset=0 yoffset=2 xadvance=11 page=0 chnl=0 80 | char id=105 x=95 y=0 width=10 height=15 xoffset=1 yoffset=1 xadvance=11 page=0 chnl=0 81 | char id=106 x=0 y=0 width=9 height=18 xoffset=0 yoffset=1 xadvance=11 page=0 chnl=0 82 | char id=107 x=191 y=0 width=11 height=14 xoffset=1 yoffset=2 xadvance=11 page=0 chnl=0 83 | char id=108 x=202 y=0 width=10 height=14 xoffset=1 yoffset=2 xadvance=11 page=0 chnl=0 84 | char id=109 x=248 y=18 width=14 height=11 xoffset=-1 yoffset=5 xadvance=11 page=0 chnl=0 85 | char id=110 x=262 y=18 width=12 height=11 xoffset=0 yoffset=5 xadvance=11 page=0 chnl=0 86 | char id=111 x=372 y=18 width=10 height=10 xoffset=0 yoffset=6 xadvance=11 page=0 chnl=0 87 | char id=112 x=212 y=0 width=11 height=14 xoffset=0 yoffset=5 xadvance=11 page=0 chnl=0 88 | char id=113 x=223 y=0 width=12 height=14 xoffset=0 yoffset=5 xadvance=11 page=0 chnl=0 89 | char id=114 x=274 y=18 width=10 height=11 xoffset=1 yoffset=5 xadvance=11 page=0 chnl=0 90 | char id=115 x=284 y=18 width=10 height=11 xoffset=1 yoffset=5 xadvance=11 page=0 chnl=0 91 | char id=116 x=142 y=18 width=11 height=13 xoffset=0 yoffset=3 xadvance=11 page=0 chnl=0 92 | char id=117 x=294 y=18 width=12 height=11 xoffset=0 yoffset=5 xadvance=11 page=0 chnl=0 93 | char id=118 x=306 y=18 width=13 height=11 xoffset=-1 yoffset=5 xadvance=11 page=0 chnl=0 94 | char id=119 x=319 y=18 width=14 height=11 xoffset=-1 yoffset=5 xadvance=11 page=0 chnl=0 95 | char id=120 x=333 y=18 width=12 height=11 xoffset=0 yoffset=5 xadvance=11 page=0 chnl=0 96 | char id=121 x=235 y=0 width=14 height=14 xoffset=-1 yoffset=5 xadvance=11 page=0 chnl=0 97 | char id=122 x=345 y=18 width=11 height=11 xoffset=0 yoffset=5 xadvance=11 page=0 chnl=0 98 | char id=123 x=43 y=0 width=6 height=16 xoffset=2 yoffset=2 xadvance=11 page=0 chnl=0 99 | char id=124 x=49 y=0 width=4 height=16 xoffset=4 yoffset=2 xadvance=11 page=0 chnl=0 100 | char id=125 x=117 y=0 width=6 height=15 xoffset=3 yoffset=3 xadvance=11 page=0 chnl=0 101 | char id=126 x=441 y=18 width=10 height=5 xoffset=0 yoffset=8 xadvance=11 page=0 chnl=0 102 | kernings count=0 103 | -------------------------------------------------------------------------------- /test/tests/test_skin/console-font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StrongJoshua/libgdx-inGameConsole/6ef713ee3fe2b94e553943ce64700b15149e2888/test/tests/test_skin/console-font.png -------------------------------------------------------------------------------- /test/tests/test_skin/default.fnt: -------------------------------------------------------------------------------- 1 | info face="Droid Sans" size=17 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1 2 | common lineHeight=20 base=18 scaleW=256 scaleH=128 pages=1 packed=0 3 | page id=0 file="default.png" 4 | chars count=96 5 | char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=16 xadvance=4 page=0 chnl=0 6 | char id=124 x=0 y=0 width=6 height=20 xoffset=1 yoffset=3 xadvance=9 page=0 chnl=0 7 | char id=106 x=6 y=0 width=9 height=20 xoffset=-4 yoffset=3 xadvance=4 page=0 chnl=0 8 | char id=81 x=15 y=0 width=15 height=19 xoffset=-2 yoffset=3 xadvance=12 page=0 chnl=0 9 | char id=74 x=30 y=0 width=11 height=19 xoffset=-5 yoffset=3 xadvance=4 page=0 chnl=0 10 | char id=125 x=41 y=0 width=10 height=18 xoffset=-3 yoffset=3 xadvance=6 page=0 chnl=0 11 | char id=123 x=51 y=0 width=10 height=18 xoffset=-3 yoffset=3 xadvance=6 page=0 chnl=0 12 | char id=93 x=61 y=0 width=8 height=18 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0 13 | char id=91 x=69 y=0 width=8 height=18 xoffset=-2 yoffset=3 xadvance=5 page=0 chnl=0 14 | char id=41 x=77 y=0 width=9 height=18 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0 15 | char id=40 x=86 y=0 width=9 height=18 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0 16 | char id=64 x=95 y=0 width=18 height=17 xoffset=-3 yoffset=3 xadvance=14 page=0 chnl=0 17 | char id=121 x=113 y=0 width=13 height=17 xoffset=-3 yoffset=6 xadvance=8 page=0 chnl=0 18 | char id=113 x=126 y=0 width=13 height=17 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0 19 | char id=112 x=139 y=0 width=13 height=17 xoffset=-2 yoffset=6 xadvance=9 page=0 chnl=0 20 | char id=103 x=152 y=0 width=13 height=17 xoffset=-3 yoffset=6 xadvance=8 page=0 chnl=0 21 | char id=38 x=165 y=0 width=16 height=16 xoffset=-3 yoffset=3 xadvance=11 page=0 chnl=0 22 | char id=37 x=181 y=0 width=18 height=16 xoffset=-3 yoffset=3 xadvance=14 page=0 chnl=0 23 | char id=36 x=199 y=0 width=12 height=16 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0 24 | char id=63 x=211 y=0 width=11 height=16 xoffset=-3 yoffset=3 xadvance=7 page=0 chnl=0 25 | char id=33 x=222 y=0 width=7 height=16 xoffset=-2 yoffset=3 xadvance=4 page=0 chnl=0 26 | char id=48 x=229 y=0 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 27 | char id=57 x=242 y=0 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 28 | char id=56 x=0 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 29 | char id=54 x=13 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 30 | char id=53 x=26 y=20 width=12 height=16 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0 31 | char id=51 x=38 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 32 | char id=100 x=51 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 33 | char id=98 x=64 y=20 width=13 height=16 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0 34 | char id=85 x=77 y=20 width=14 height=16 xoffset=-2 yoffset=3 xadvance=11 page=0 chnl=0 35 | char id=83 x=91 y=20 width=13 height=16 xoffset=-3 yoffset=3 xadvance=8 page=0 chnl=0 36 | char id=79 x=104 y=20 width=15 height=16 xoffset=-2 yoffset=3 xadvance=12 page=0 chnl=0 37 | char id=71 x=119 y=20 width=14 height=16 xoffset=-2 yoffset=3 xadvance=11 page=0 chnl=0 38 | char id=67 x=133 y=20 width=13 height=16 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0 39 | char id=127 x=146 y=20 width=12 height=15 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0 40 | char id=35 x=158 y=20 width=15 height=15 xoffset=-3 yoffset=3 xadvance=10 page=0 chnl=0 41 | char id=92 x=173 y=20 width=11 height=15 xoffset=-3 yoffset=3 xadvance=6 page=0 chnl=0 42 | char id=47 x=184 y=20 width=11 height=15 xoffset=-3 yoffset=3 xadvance=6 page=0 chnl=0 43 | char id=59 x=195 y=20 width=8 height=15 xoffset=-3 yoffset=6 xadvance=4 page=0 chnl=0 44 | char id=55 x=203 y=20 width=13 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 45 | char id=52 x=216 y=20 width=14 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 46 | char id=50 x=230 y=20 width=13 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 47 | char id=49 x=243 y=20 width=9 height=15 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0 48 | char id=116 x=0 y=36 width=10 height=15 xoffset=-3 yoffset=4 xadvance=5 page=0 chnl=0 49 | char id=108 x=10 y=36 width=6 height=15 xoffset=-2 yoffset=3 xadvance=4 page=0 chnl=0 50 | char id=107 x=16 y=36 width=12 height=15 xoffset=-2 yoffset=3 xadvance=8 page=0 chnl=0 51 | char id=105 x=28 y=36 width=7 height=15 xoffset=-2 yoffset=3 xadvance=4 page=0 chnl=0 52 | char id=104 x=35 y=36 width=12 height=15 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0 53 | char id=102 x=47 y=36 width=11 height=15 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0 54 | char id=90 x=58 y=36 width=13 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 55 | char id=89 x=71 y=36 width=13 height=15 xoffset=-3 yoffset=3 xadvance=8 page=0 chnl=0 56 | char id=88 x=84 y=36 width=14 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 57 | char id=87 x=98 y=36 width=19 height=15 xoffset=-3 yoffset=3 xadvance=15 page=0 chnl=0 58 | char id=86 x=117 y=36 width=14 height=15 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 59 | char id=84 x=131 y=36 width=13 height=15 xoffset=-3 yoffset=3 xadvance=8 page=0 chnl=0 60 | char id=82 x=144 y=36 width=13 height=15 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0 61 | char id=80 x=157 y=36 width=12 height=15 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0 62 | char id=78 x=169 y=36 width=14 height=15 xoffset=-2 yoffset=3 xadvance=12 page=0 chnl=0 63 | char id=77 x=183 y=36 width=17 height=15 xoffset=-2 yoffset=3 xadvance=14 page=0 chnl=0 64 | char id=76 x=200 y=36 width=11 height=15 xoffset=-2 yoffset=3 xadvance=8 page=0 chnl=0 65 | char id=75 x=211 y=36 width=13 height=15 xoffset=-2 yoffset=3 xadvance=9 page=0 chnl=0 66 | char id=73 x=224 y=36 width=10 height=15 xoffset=-3 yoffset=3 xadvance=5 page=0 chnl=0 67 | char id=72 x=234 y=36 width=14 height=15 xoffset=-2 yoffset=3 xadvance=11 page=0 chnl=0 68 | char id=70 x=0 y=51 width=11 height=15 xoffset=-2 yoffset=3 xadvance=8 page=0 chnl=0 69 | char id=69 x=11 y=51 width=11 height=15 xoffset=-2 yoffset=3 xadvance=8 page=0 chnl=0 70 | char id=68 x=22 y=51 width=14 height=15 xoffset=-2 yoffset=3 xadvance=11 page=0 chnl=0 71 | char id=66 x=36 y=51 width=13 height=15 xoffset=-2 yoffset=3 xadvance=10 page=0 chnl=0 72 | char id=65 x=49 y=51 width=15 height=15 xoffset=-3 yoffset=3 xadvance=10 page=0 chnl=0 73 | char id=58 x=64 y=51 width=7 height=13 xoffset=-2 yoffset=6 xadvance=4 page=0 chnl=0 74 | char id=117 x=71 y=51 width=12 height=13 xoffset=-2 yoffset=6 xadvance=10 page=0 chnl=0 75 | char id=115 x=83 y=51 width=11 height=13 xoffset=-3 yoffset=6 xadvance=7 page=0 chnl=0 76 | char id=111 x=94 y=51 width=13 height=13 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0 77 | char id=101 x=107 y=51 width=13 height=13 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0 78 | char id=99 x=120 y=51 width=12 height=13 xoffset=-3 yoffset=6 xadvance=7 page=0 chnl=0 79 | char id=97 x=132 y=51 width=12 height=13 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0 80 | char id=60 x=144 y=51 width=13 height=12 xoffset=-3 yoffset=5 xadvance=9 page=0 chnl=0 81 | char id=122 x=157 y=51 width=11 height=12 xoffset=-3 yoffset=6 xadvance=7 page=0 chnl=0 82 | char id=120 x=168 y=51 width=13 height=12 xoffset=-3 yoffset=6 xadvance=8 page=0 chnl=0 83 | char id=119 x=181 y=51 width=17 height=12 xoffset=-3 yoffset=6 xadvance=12 page=0 chnl=0 84 | char id=118 x=198 y=51 width=13 height=12 xoffset=-3 yoffset=6 xadvance=8 page=0 chnl=0 85 | char id=114 x=211 y=51 width=10 height=12 xoffset=-2 yoffset=6 xadvance=6 page=0 chnl=0 86 | char id=110 x=221 y=51 width=12 height=12 xoffset=-2 yoffset=6 xadvance=10 page=0 chnl=0 87 | char id=109 x=233 y=51 width=17 height=12 xoffset=-2 yoffset=6 xadvance=15 page=0 chnl=0 88 | char id=94 x=0 y=66 width=13 height=11 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 89 | char id=62 x=13 y=66 width=13 height=11 xoffset=-3 yoffset=5 xadvance=9 page=0 chnl=0 90 | char id=42 x=26 y=66 width=13 height=10 xoffset=-3 yoffset=3 xadvance=9 page=0 chnl=0 91 | char id=43 x=39 y=66 width=13 height=10 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0 92 | char id=61 x=52 y=66 width=13 height=8 xoffset=-3 yoffset=7 xadvance=9 page=0 chnl=0 93 | char id=39 x=65 y=66 width=6 height=8 xoffset=-2 yoffset=3 xadvance=3 page=0 chnl=0 94 | char id=34 x=71 y=66 width=9 height=8 xoffset=-2 yoffset=3 xadvance=6 page=0 chnl=0 95 | char id=44 x=80 y=66 width=8 height=7 xoffset=-3 yoffset=14 xadvance=4 page=0 chnl=0 96 | char id=126 x=88 y=66 width=13 height=6 xoffset=-3 yoffset=8 xadvance=9 page=0 chnl=0 97 | char id=46 x=101 y=66 width=7 height=6 xoffset=-2 yoffset=13 xadvance=4 page=0 chnl=0 98 | char id=96 x=108 y=66 width=8 height=6 xoffset=0 yoffset=2 xadvance=9 page=0 chnl=0 99 | char id=45 x=116 y=66 width=9 height=5 xoffset=-3 yoffset=10 xadvance=5 page=0 chnl=0 100 | char id=95 x=125 y=66 width=13 height=4 xoffset=-4 yoffset=17 xadvance=6 page=0 chnl=0 101 | kernings count=-1 -------------------------------------------------------------------------------- /test/tests/test_skin/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StrongJoshua/libgdx-inGameConsole/6ef713ee3fe2b94e553943ce64700b15149e2888/test/tests/test_skin/default.png -------------------------------------------------------------------------------- /test/tests/test_skin/uiskin.atlas: -------------------------------------------------------------------------------- 1 | 2 | uiskin.png 3 | size: 256,128 4 | format: RGBA8888 5 | filter: Linear,Linear 6 | repeat: none 7 | check-off 8 | rotate: false 9 | xy: 11, 5 10 | size: 14, 14 11 | orig: 14, 14 12 | offset: 0, 0 13 | index: -1 14 | textfield 15 | rotate: false 16 | xy: 11, 5 17 | size: 14, 14 18 | split: 3, 3, 3, 3 19 | orig: 14, 14 20 | offset: 0, 0 21 | index: -1 22 | check-on 23 | rotate: false 24 | xy: 125, 35 25 | size: 14, 14 26 | orig: 14, 14 27 | offset: 0, 0 28 | index: -1 29 | cursor 30 | rotate: false 31 | xy: 23, 1 32 | size: 3, 3 33 | split: 1, 1, 1, 1 34 | orig: 3, 3 35 | offset: 0, 0 36 | index: -1 37 | default 38 | rotate: false 39 | xy: 1, 50 40 | size: 254, 77 41 | orig: 254, 77 42 | offset: 0, 0 43 | index: -1 44 | default-pane 45 | rotate: false 46 | xy: 11, 1 47 | size: 5, 3 48 | split: 1, 1, 1, 1 49 | orig: 5, 3 50 | offset: 0, 0 51 | index: -1 52 | default-rect-pad 53 | rotate: false 54 | xy: 11, 1 55 | size: 5, 3 56 | split: 1, 1, 1, 1 57 | orig: 5, 3 58 | offset: 0, 0 59 | index: -1 60 | default-pane-noborder 61 | rotate: false 62 | xy: 170, 44 63 | size: 1, 1 64 | split: 0, 0, 0, 0 65 | orig: 1, 1 66 | offset: 0, 0 67 | index: -1 68 | default-rect 69 | rotate: false 70 | xy: 38, 25 71 | size: 3, 3 72 | split: 1, 1, 1, 1 73 | orig: 3, 3 74 | offset: 0, 0 75 | index: -1 76 | default-rect-down 77 | rotate: false 78 | xy: 170, 46 79 | size: 3, 3 80 | split: 1, 1, 1, 1 81 | orig: 3, 3 82 | offset: 0, 0 83 | index: -1 84 | default-round 85 | rotate: false 86 | xy: 112, 29 87 | size: 12, 20 88 | split: 5, 5, 5, 4 89 | pad: 4, 4, 1, 1 90 | orig: 12, 20 91 | offset: 0, 0 92 | index: -1 93 | default-round-down 94 | rotate: false 95 | xy: 99, 29 96 | size: 12, 20 97 | split: 5, 5, 5, 4 98 | pad: 4, 4, 1, 1 99 | orig: 12, 20 100 | offset: 0, 0 101 | index: -1 102 | default-round-large 103 | rotate: false 104 | xy: 57, 29 105 | size: 20, 20 106 | split: 5, 5, 5, 4 107 | orig: 20, 20 108 | offset: 0, 0 109 | index: -1 110 | default-scroll 111 | rotate: false 112 | xy: 78, 29 113 | size: 20, 20 114 | split: 2, 2, 2, 2 115 | orig: 20, 20 116 | offset: 0, 0 117 | index: -1 118 | default-select 119 | rotate: false 120 | xy: 29, 29 121 | size: 27, 20 122 | split: 4, 14, 4, 4 123 | orig: 27, 20 124 | offset: 0, 0 125 | index: -1 126 | default-select-selection 127 | rotate: false 128 | xy: 26, 16 129 | size: 3, 3 130 | split: 1, 1, 1, 1 131 | orig: 3, 3 132 | offset: 0, 0 133 | index: -1 134 | default-slider 135 | rotate: false 136 | xy: 29, 20 137 | size: 8, 8 138 | split: 2, 2, 2, 2 139 | orig: 8, 8 140 | offset: 0, 0 141 | index: -1 142 | default-slider-knob 143 | rotate: false 144 | xy: 1, 1 145 | size: 9, 18 146 | orig: 9, 18 147 | offset: 0, 0 148 | index: -1 149 | default-splitpane 150 | rotate: false 151 | xy: 17, 1 152 | size: 5, 3 153 | split: 0, 5, 0, 0 154 | orig: 5, 3 155 | offset: 0, 0 156 | index: -1 157 | default-splitpane-vertical 158 | rotate: false 159 | xy: 125, 29 160 | size: 3, 5 161 | split: 0, 0, 0, 5 162 | orig: 3, 5 163 | offset: 0, 0 164 | index: -1 165 | default-window 166 | rotate: false 167 | xy: 1, 20 168 | size: 27, 29 169 | split: 4, 3, 20, 3 170 | orig: 27, 29 171 | offset: 0, 0 172 | index: -1 173 | selection 174 | rotate: false 175 | xy: 174, 48 176 | size: 1, 1 177 | orig: 1, 1 178 | offset: 0, 0 179 | index: -1 180 | tree-minus 181 | rotate: false 182 | xy: 140, 35 183 | size: 14, 14 184 | orig: 14, 14 185 | offset: 0, 0 186 | index: -1 187 | tree-plus 188 | rotate: false 189 | xy: 155, 35 190 | size: 14, 14 191 | orig: 14, 14 192 | offset: 0, 0 193 | index: -1 194 | white 195 | rotate: false 196 | xy: 129, 31 197 | size: 3, 3 198 | orig: 3, 3 199 | offset: 0, 0 200 | index: -1 -------------------------------------------------------------------------------- /test/tests/test_skin/uiskin.json: -------------------------------------------------------------------------------- 1 | { 2 | com.badlogic.gdx.graphics.g2d.BitmapFont: { 3 | default-font: { 4 | file: default.fnt 5 | }, 6 | console-font: { 7 | file: console-font.fnt 8 | } 9 | }, 10 | com.badlogic.gdx.graphics.Color: { 11 | green: { 12 | a: 1, 13 | b: 0, 14 | g: 1, 15 | r: 0 16 | }, 17 | white: { 18 | a: 1, 19 | b: 1, 20 | g: 1, 21 | r: 1 22 | }, 23 | red: { 24 | a: 1, 25 | b: 0, 26 | g: 0, 27 | r: 1 28 | }, 29 | black: { 30 | a: 1, 31 | b: 0, 32 | g: 0, 33 | r: 0 34 | } 35 | }, 36 | com.badlogic.gdx.scenes.scene2d.ui.Skin$TintedDrawable: { 37 | dialogDim: { 38 | name: white, 39 | color: { 40 | r: 0, 41 | g: 0, 42 | b: 0, 43 | a: 0.45 44 | } 45 | } 46 | }, 47 | com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle: { 48 | default: { 49 | down: default-round-down, 50 | up: default-round 51 | }, 52 | toggle: { 53 | down: default-round-down, 54 | checked: default-round-down, 55 | up: default-round 56 | } 57 | }, 58 | com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle: { 59 | default: { 60 | down: default-round-down, 61 | up: default-round, 62 | font: default-font, 63 | fontColor: white 64 | }, 65 | toggle: { 66 | down: default-round-down, 67 | up: default-round, 68 | checked: default-round-down, 69 | font: default-font, 70 | fontColor: white, 71 | downFontColor: red 72 | } 73 | }, 74 | com.badlogic.gdx.scenes.scene2d.ui.ScrollPane$ScrollPaneStyle: { 75 | default: { 76 | vScroll: default-scroll, 77 | hScrollKnob: default-round-large, 78 | background: default-rect, 79 | hScroll: default-scroll, 80 | vScrollKnob: default-round-large 81 | } 82 | }, 83 | com.badlogic.gdx.scenes.scene2d.ui.SelectBox$SelectBoxStyle: { 84 | default: { 85 | font: default-font, 86 | fontColor: white, 87 | background: default-select, 88 | scrollStyle: default, 89 | listStyle: { 90 | font: default-font, 91 | selection: default-select-selection 92 | } 93 | } 94 | }, 95 | com.badlogic.gdx.scenes.scene2d.ui.SplitPane$SplitPaneStyle: { 96 | default-vertical: { 97 | handle: default-splitpane-vertical 98 | }, 99 | default-horizontal: { 100 | handle: default-splitpane 101 | } 102 | }, 103 | com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle: { 104 | default: { 105 | titleFont: default-font, 106 | background: default-window, 107 | titleFontColor: white 108 | }, 109 | dialog: { 110 | titleFont: default-font, 111 | background: default-window, 112 | titleFontColor: white, 113 | stageBackground: dialogDim 114 | } 115 | }, 116 | com.badlogic.gdx.scenes.scene2d.ui.ProgressBar$ProgressBarStyle: { 117 | default-horizontal: { 118 | background: default-slider, 119 | knob: default-slider-knob 120 | }, 121 | default-vertical: { 122 | background: default-slider, 123 | knob: default-round-large 124 | } 125 | }, 126 | com.badlogic.gdx.scenes.scene2d.ui.Slider$SliderStyle: { 127 | default-horizontal: { 128 | background: default-slider, 129 | knob: default-slider-knob 130 | }, 131 | default-vertical: { 132 | background: default-slider, 133 | knob: default-round-large 134 | } 135 | }, 136 | com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle: { 137 | default: { 138 | font: default-font, 139 | fontColor: white 140 | } 141 | }, 142 | com.badlogic.gdx.scenes.scene2d.ui.TextField$TextFieldStyle: { 143 | default: { 144 | selection: selection, 145 | background: textfield, 146 | font: default-font, 147 | fontColor: white, 148 | cursor: cursor 149 | } 150 | }, 151 | com.badlogic.gdx.scenes.scene2d.ui.CheckBox$CheckBoxStyle: { 152 | default: { 153 | checkboxOn: check-on, 154 | checkboxOff: check-off, 155 | font: default-font, 156 | fontColor: white 157 | } 158 | }, 159 | com.badlogic.gdx.scenes.scene2d.ui.List$ListStyle: { 160 | default: { 161 | fontColorUnselected: white, 162 | selection: selection, 163 | fontColorSelected: white, 164 | font: default-font 165 | } 166 | }, 167 | com.badlogic.gdx.scenes.scene2d.ui.Touchpad$TouchpadStyle: { 168 | default: { 169 | background: default-pane, 170 | knob: default-round-large 171 | } 172 | }, 173 | com.badlogic.gdx.scenes.scene2d.ui.Tree$TreeStyle: { 174 | default: { 175 | minus: tree-minus, 176 | plus: tree-plus, 177 | selection: default-select-selection 178 | } 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /test/tests/test_skin/uiskin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StrongJoshua/libgdx-inGameConsole/6ef713ee3fe2b94e553943ce64700b15149e2888/test/tests/test_skin/uiskin.png --------------------------------------------------------------------------------