Updated gdx-teavm and added new preload screen using the java based solution instead of directly altering the index.html file
This commit is contained in:
@@ -29,17 +29,50 @@ tasks.register('compileClient', JavaExec) {
|
||||
|
||||
task modifyHtml {
|
||||
doLast {
|
||||
def htmlFile = file("../release/webapp/index.html")
|
||||
def destinationDir = file("../release/webapp/assets")
|
||||
def rootFS = file("../release/webapp")
|
||||
def htmlFile = new File(rootFS, "index.html")
|
||||
def assetsDir = new File(rootFS, "assets")
|
||||
def faviconDest = new File(rootFS, "favicon.ico")
|
||||
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")
|
||||
def startupLogo = new File(assetsDir, "startup-logo.png")
|
||||
def assetsTxt = new File(assetsDir, "assets.txt")
|
||||
|
||||
// copy windows.ico
|
||||
// delete placeholder startup-logo.png
|
||||
if (startupLogo.exists()) {
|
||||
if (startupLogo.delete()) {
|
||||
println "Deleted startup-logo.png from assets folder."
|
||||
} else {
|
||||
println "Failed to delete startup-logo.png. Check permissions."
|
||||
}
|
||||
} else {
|
||||
println "startup-logo.png not found in assets folder. Nothing to delete."
|
||||
}
|
||||
|
||||
// remove lines containing the word 'frame' (case-insensitive) from assets.txt
|
||||
if (assetsTxt.exists()) {
|
||||
def originalLines = assetsTxt.readLines('UTF-8')
|
||||
def filteredLines = originalLines.findAll { line ->
|
||||
!(line =~ /(?i)frame/)
|
||||
}
|
||||
if (filteredLines.size() != originalLines.size()) {
|
||||
assetsTxt.withWriter('UTF-8') { writer ->
|
||||
filteredLines.eachWithIndex { l, i ->
|
||||
writer.write(l)
|
||||
if (i < filteredLines.size() - 1) writer.newLine()
|
||||
}
|
||||
}
|
||||
println "Removed lines containing 'frame' from assets.txt."
|
||||
} else {
|
||||
println "No lines containing 'frame' found in assets.txt. No changes made."
|
||||
}
|
||||
} else {
|
||||
println "assets.txt not found in assets folder. Skipping assets.txt cleanup."
|
||||
}
|
||||
|
||||
// copy windows.ico to favicon.ico
|
||||
if (sourceFavicon.exists()) {
|
||||
def destinationFile = new File(destinationDir, "windows.ico")
|
||||
sourceFavicon.withInputStream { input ->
|
||||
destinationFile.withOutputStream { output ->
|
||||
faviconDest.withOutputStream { output ->
|
||||
output << input
|
||||
}
|
||||
}
|
||||
@@ -48,28 +81,9 @@ task modifyHtml {
|
||||
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 = '<link rel="icon" href="assets/windows.ico" type="image/x-icon">'
|
||||
def content = htmlFile.text
|
||||
|
||||
// add a link for the favicon
|
||||
if (content.contains("</head>")) {
|
||||
content = content.replace("</head>", faviconLink + "\n</head>")
|
||||
println "Favicon link added to index.html."
|
||||
}
|
||||
|
||||
// Change page title
|
||||
if (content.contains("<title>")) {
|
||||
content = content.replaceFirst("<title>.*?</title>", "<title>Shattered Pixel Dungeon</title>")
|
||||
@@ -78,62 +92,6 @@ task modifyHtml {
|
||||
println "No <title> 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."
|
||||
|
||||
Reference in New Issue
Block a user