apply plugin: 'java-library' dependencies { implementation "com.github.xpenatan.gdx-teavm:backend-teavm:$gdxTeaVMVersion" implementation "com.github.xpenatan.gdx-teavm:gdx-freetype-teavm:$gdxTeaVMVersion" implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" implementation project(':core') } repositories { mavenCentral() maven { url = uri("https://central.sonatype.com/repository/maven-snapshots/") } maven { url = uri("https://jitpack.io") } maven { url 'https://teavm.org/maven/repository' } } tasks.register('compileClient', JavaExec) { classpath(sourceSets.main.runtimeClasspath) mainClass.set('com.shatteredpixel.shatteredpixeldungeon.html.Compile') jvmArgs('-Xms8g', '-Xmx14g', '-Xss16m', '-XX:MaxMetaspaceSize=12g', '-Dfile.encoding=UTF-8') outputs.dir '../release/webapp' doFirst { println "Running compileClient..." } doLast { println "compileClient completed!" } } task modifyHtml { doLast { def htmlFile = file("../release/webapp/index.html") def destinationDir = file("../release/webapp/assets") def sourceFavicon = file("../desktop/src/main/assets/icons/windows.ico") def sourceGif = file("../html/src/main/assets/logo.gif") def destinationStartupLogo = file("../release/webapp/startup-logo.png") // copy windows.ico if (sourceFavicon.exists()) { def destinationFile = new File(destinationDir, "windows.ico") sourceFavicon.withInputStream { input -> destinationFile.withOutputStream { output -> output << input } } println "Copied windows.ico to assets folder." } else { println "windows.ico does not exist. Skipping copy step." } if (sourceGif.exists()) { destinationStartupLogo.parentFile.mkdirs() sourceGif.withInputStream { input -> destinationStartupLogo.withOutputStream { output -> output << input } } println "Replaced startup-logo.png with a gif." } else { println "Gif does not exist. Skipping replacement step." } if (htmlFile.exists()) { def faviconLink = '' def content = htmlFile.text // add a link for the favicon if (content.contains("")) { content = content.replace("", faviconLink + "\n") println "Favicon link added to index.html." } // Change page title if (content.contains("")) { content = content.replaceFirst("<title>.*?", "Shattered Pixel Dungeon") println "Title updated to 'Shattered Pixel Dungeon'." } else { println "No tag found in index.html. Skipping title update." } if (content.contains("<style>") && content.contains("</style>")) { content = content.replaceAll( "(?s)<style>.*?</style>", """<style> body { display: flex; justify-content: center; align-items: center; background: #000; height: 100vh; margin: 0; padding: 0; overflow: hidden; } #progress { display: flex; flex-direction: column; justify-content: center; align-items: center; position: fixed; top: 0; left: 0; height: 100%; width: 100%; } #progress-img { display: flex; width: 850px; height: auto; margin-bottom: -20px; } #progress-box { background: rgba(255,255,255,0.1); border: 2px solid #fff; display: flex; margin-top: -20px; justify-content: center; align-items: center; position: relative; height: 30px; width: 600px; } #progress-bar { display: block; background: #44FF82; height: 20px; width: 0%; } </style>""" ) println "Successfully replaced the <style> block in index.html." } else { println "No <style> block found in index.html. Skipping style replacement." } htmlFile.text = content } else { println "index.html does not exist. Skipping favicon injection." } } } tasks.named('modifyHtml') { mustRunAfter('compileClient') } tasks.named('build') { dependsOn 'compileClient' finalizedBy 'modifyHtml' }