Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
Add missing content warning
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislo27 committed Dec 7, 2016
1 parent e7de5b8 commit 720ba32
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions core/assets/localization/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ loadScreen.confirm=Press [CYAN]ENTER[] to confirm loading this remix, losing all
loadScreen.versionMismatch=[RED]Warning:[] the version this remix was saved in ([GRAY]{0}[]) [PINK]differs[] \
from the current one, which is [LIGHT_GRAY]{1}[]. \
The editor may [RED]crash[] when attempting to load the file, or some parts may be [RED]missing[].
loadScreen.missingContent=[RED]Warning:[] the remix you are trying to load has content the editor doesn't have.
loadScreen.remixInfo=[LIGHT_GRAY]Remix Info[]\n\
Cue count: {0}\n\
Tempo changes: {1}
35 changes: 29 additions & 6 deletions core/src/chrislo27/rhre/SaveLoadScreens.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chrislo27.rhre

import chrislo27.rhre.json.persistent.RemixObject
import chrislo27.rhre.registry.GameRegistry
import chrislo27.rhre.track.Remix
import chrislo27.rhre.util.FileChooser
import com.badlogic.gdx.Gdx
Expand Down Expand Up @@ -169,6 +170,9 @@ class LoadScreen(m: Main) : Updateable<Main>(m) {
@Volatile
private var remixObj: RemixObject? = null

@Volatile
private var missingContent = false

override fun render(delta: Float) {
Gdx.gl.glClearColor(0f, 0f, 0f, 1f)
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
Expand All @@ -193,19 +197,29 @@ class LoadScreen(m: Main) : Updateable<Main>(m) {

if (remixObj!!.version != Main.version) {
main.font.draw(main.batch,
Localization.get("loadScreen.versionMismatch", remixObj!!.version ?: "NO VERSION!", Main.version),
Localization.get("loadScreen.versionMismatch", remixObj!!.version ?: "NO VERSION!",
Main.version),
Gdx.graphics.width * 0.05f,
Gdx.graphics.height * 0.45f + main.font.capHeight * 0.5f + main.font.lineHeight * 2,
Gdx.graphics.width * 0.9f,
Align.left, true)
}

main.font.draw(main.batch, Localization.get("loadScreen.confirm"),
Gdx.graphics.width * 0.05f,
Gdx.graphics.height * 0.35f + main.font.capHeight * 0.5f)
if (missingContent) {
main.font.draw(main.batch,
Localization.get("loadScreen.missingContent"),
Gdx.graphics.width * 0.05f,
Gdx.graphics.height * 0.3f + main.font.capHeight * 0.5f + main.font.lineHeight * 2,
Gdx.graphics.width * 0.9f,
Align.left, true)
} else {
main.font.draw(main.batch, Localization.get("loadScreen.confirm"),
Gdx.graphics.width * 0.05f,
Gdx.graphics.height * 0.175f + main.font.capHeight * 0.5f)
}
}
main.font.draw(main.batch, Localization.get("warning.remixOverwrite"), Gdx.graphics.width * 0.05f,
Gdx.graphics.height * 0.25f + main.font.capHeight * 0.5f)
Gdx.graphics.height * 0.1f + main.font.capHeight * 0.5f)

main.font.draw(main.batch, Localization.get("loadScreen.return"), Gdx.graphics.width * 0.05f,
main.font.capHeight * 2)
Expand All @@ -216,7 +230,7 @@ class LoadScreen(m: Main) : Updateable<Main>(m) {
override fun renderUpdate() {
if (Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) {
main.screen = ScreenRegistry.get("editor")
} else if (Gdx.input.isKeyJustPressed(Input.Keys.ENTER)) {
} else if (Gdx.input.isKeyJustPressed(Input.Keys.ENTER) && !missingContent) {
if (remixObj != null) {
val es = ScreenRegistry.get("editor", EditorScreen::class.java)
es.editor.remix = Remix.readFromObject(remixObj!!)
Expand All @@ -231,6 +245,7 @@ class LoadScreen(m: Main) : Updateable<Main>(m) {
currentThread?.interrupt()
currentThread = null
remixObj = null
missingContent = false
}

private fun showPicker() {
Expand All @@ -249,6 +264,14 @@ class LoadScreen(m: Main) : Updateable<Main>(m) {
val obj: RemixObject = gson.fromJson(handle.readString("UTF-8"), RemixObject::class.java)

remixObj = obj

missingContent = obj.entities.any { entity ->
if (entity.isPattern) {
GameRegistry.instance().gameList.none { it.patterns.any { it.id == entity.id } }
} else {
GameRegistry.instance().gameList.none { it.soundCues.any { it.id == entity.id } }
}
}
}
else -> {
main.screen = ScreenRegistry.get("editor")
Expand Down

0 comments on commit 720ba32

Please sign in to comment.