mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
profiles: rendering
This commit is contained in:
parent
ddfba212b3
commit
41d8ee9f32
@ -20,5 +20,4 @@ data class OtherGameConfig(
|
|||||||
@Json(name = "flower_random_offset") var flowerRandomOffset: Boolean = true,
|
@Json(name = "flower_random_offset") var flowerRandomOffset: Boolean = true,
|
||||||
@Json(name = "block_outline") var blockOutline: BlockOutline = BlockOutline(),
|
@Json(name = "block_outline") var blockOutline: BlockOutline = BlockOutline(),
|
||||||
@Json(name = "experimental_fps") var experimentalFPS: Boolean = false,
|
@Json(name = "experimental_fps") var experimentalFPS: Boolean = false,
|
||||||
@Json(name = "super_dumb_advanced_setting_leave_at_1") var swapInterval: Int = 1,
|
|
||||||
)
|
)
|
||||||
|
@ -7,6 +7,7 @@ import de.bixilon.minosoft.config.profile.profiles.audio.AudioProfileManager
|
|||||||
import de.bixilon.minosoft.config.profile.profiles.entity.EntityProfileManager
|
import de.bixilon.minosoft.config.profile.profiles.entity.EntityProfileManager
|
||||||
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
|
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
|
||||||
import de.bixilon.minosoft.config.profile.profiles.particle.ParticleProfileManager
|
import de.bixilon.minosoft.config.profile.profiles.particle.ParticleProfileManager
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfileManager
|
||||||
import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfileManager
|
import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfileManager
|
||||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||||
import de.bixilon.minosoft.gui.eros.crash.ErosCrashReport.Companion.crash
|
import de.bixilon.minosoft.gui.eros.crash.ErosCrashReport.Companion.crash
|
||||||
@ -30,6 +31,7 @@ object GlobalProfileManager {
|
|||||||
EntityProfileManager,
|
EntityProfileManager,
|
||||||
ResourcesProfileManager,
|
ResourcesProfileManager,
|
||||||
AccountProfileManager,
|
AccountProfileManager,
|
||||||
|
RenderingProfileManager,
|
||||||
)
|
)
|
||||||
private val SELECTED_PROFILES_TYPE: MapType = Jackson.MAPPER.typeFactory.constructMapType(HashMap::class.java, ResourceLocation::class.java, String::class.java)
|
private val SELECTED_PROFILES_TYPE: MapType = Jackson.MAPPER.typeFactory.constructMapType(HashMap::class.java, ResourceLocation::class.java, String::class.java)
|
||||||
val CLASS_MAPPING: Map<Class<out Profile>, ProfileManager<*>>
|
val CLASS_MAPPING: Map<Class<out Profile>, ProfileManager<*>>
|
||||||
|
@ -8,6 +8,8 @@ import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfile
|
|||||||
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
|
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
|
||||||
import de.bixilon.minosoft.config.profile.profiles.particle.ParticleProfile
|
import de.bixilon.minosoft.config.profile.profiles.particle.ParticleProfile
|
||||||
import de.bixilon.minosoft.config.profile.profiles.particle.ParticleProfileManager
|
import de.bixilon.minosoft.config.profile.profiles.particle.ParticleProfileManager
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfile
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfileManager
|
||||||
import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfile
|
import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfile
|
||||||
import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfileManager
|
import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfileManager
|
||||||
|
|
||||||
@ -17,4 +19,5 @@ data class ProfileCollection(
|
|||||||
val audio: AudioProfile = AudioProfileManager.selected,
|
val audio: AudioProfile = AudioProfileManager.selected,
|
||||||
val entity: EntityProfile = EntityProfileManager.selected,
|
val entity: EntityProfile = EntityProfileManager.selected,
|
||||||
val resources: ResourcesProfile = ResourcesProfileManager.selected,
|
val resources: ResourcesProfile = ResourcesProfileManager.selected,
|
||||||
|
val rendering: RenderingProfile = RenderingProfileManager.selected,
|
||||||
)
|
)
|
||||||
|
@ -3,6 +3,7 @@ package de.bixilon.minosoft.config.profile.change.listener
|
|||||||
import de.bixilon.minosoft.config.profile.change.ProfilesChangeManager
|
import de.bixilon.minosoft.config.profile.change.ProfilesChangeManager
|
||||||
import de.bixilon.minosoft.config.profile.profiles.Profile
|
import de.bixilon.minosoft.config.profile.profiles.Profile
|
||||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
||||||
|
import de.bixilon.minosoft.gui.rendering.Rendering
|
||||||
import de.bixilon.minosoft.util.KUtil.unsafeCast
|
import de.bixilon.minosoft.util.KUtil.unsafeCast
|
||||||
import java.lang.reflect.Field
|
import java.lang.reflect.Field
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
@ -41,5 +42,18 @@ class SimpleChangeListener<T>(
|
|||||||
fun <T> KProperty<T>.listenFX(reference: Any, instant: Boolean = false, profile: Profile? = null, callback: ((T) -> Unit)) {
|
fun <T> KProperty<T>.listenFX(reference: Any, instant: Boolean = false, profile: Profile? = null, callback: ((T) -> Unit)) {
|
||||||
ProfilesChangeManager.register(reference, SimpleChangeListener(this, javaField!!, profile, instant) { JavaFXUtil.runLater { callback(it) } })
|
ProfilesChangeManager.register(reference, SimpleChangeListener(this, javaField!!, profile, instant) { JavaFXUtil.runLater { callback(it) } })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmOverloads
|
||||||
|
fun <T> KProperty<T>.listenRendering(reference: Any, instant: Boolean = false, profile: Profile? = null, callback: ((T) -> Unit)) {
|
||||||
|
val context = Rendering.currentContext ?: throw IllegalStateException("Can only be registered in a render context!")
|
||||||
|
ProfilesChangeManager.register(reference, SimpleChangeListener(this, javaField!!, profile, instant) {
|
||||||
|
val changeContext = Rendering.currentContext
|
||||||
|
if (changeContext === context) {
|
||||||
|
callback(it)
|
||||||
|
} else {
|
||||||
|
context.queue += { callback(it) }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,15 +26,9 @@ class AccountProfile(
|
|||||||
var entries: MutableMap<String, Account> by mapDelegate()
|
var entries: MutableMap<String, Account> by mapDelegate()
|
||||||
private set
|
private set
|
||||||
|
|
||||||
@get:JsonProperty("selected")
|
@get:JsonProperty("selected") private var _selected: String? by delegate(null)
|
||||||
private var _selected: String? by delegate(null)
|
|
||||||
|
|
||||||
@get:JsonIgnore
|
@get:JsonIgnore var selected: Account? by backingDelegate(getter = { entries[_selected] }, setter = { _selected = it?.id })
|
||||||
var selected: Account? by backingDelegate(getter = {
|
|
||||||
entries[_selected]
|
|
||||||
}, setter = {
|
|
||||||
_selected = it?.id
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package de.bixilon.minosoft.config.profile.profiles.rendering
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.Profile
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfileManager.delegate
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfileManager.latestVersion
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.rendering.advanced.AdvancedC
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Profile for general rendering
|
||||||
|
*/
|
||||||
|
class RenderingProfile(
|
||||||
|
description: String? = null,
|
||||||
|
) : Profile {
|
||||||
|
override var initializing: Boolean = true
|
||||||
|
private set
|
||||||
|
override var saved: Boolean = true
|
||||||
|
override val version: Int = latestVersion
|
||||||
|
override val description by delegate(description ?: "")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enabled or disables the whole rendering subsystem
|
||||||
|
* Does skip the loading of audio. Exits the rendering if disabled
|
||||||
|
*/
|
||||||
|
var enabled by delegate(true)
|
||||||
|
|
||||||
|
val advanced = AdvancedC()
|
||||||
|
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return RenderingProfileManager.getName(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
initializing = false
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package de.bixilon.minosoft.config.profile.profiles.rendering
|
||||||
|
|
||||||
|
import com.google.common.collect.HashBiMap
|
||||||
|
import de.bixilon.minosoft.config.profile.GlobalProfileManager
|
||||||
|
import de.bixilon.minosoft.config.profile.ProfileManager
|
||||||
|
import de.bixilon.minosoft.modding.event.master.GlobalEventMaster
|
||||||
|
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||||
|
import de.bixilon.minosoft.util.KUtil.unsafeCast
|
||||||
|
import java.util.concurrent.locks.ReentrantLock
|
||||||
|
|
||||||
|
object RenderingProfileManager : ProfileManager<RenderingProfile> {
|
||||||
|
override val namespace = "minosoft:rendering".toResourceLocation()
|
||||||
|
override val latestVersion = 1
|
||||||
|
override val saveLock = ReentrantLock()
|
||||||
|
override val profileClass = RenderingProfile::class.java
|
||||||
|
|
||||||
|
|
||||||
|
override var currentLoadingPath: String? = null
|
||||||
|
override val profiles: HashBiMap<String, RenderingProfile> = HashBiMap.create()
|
||||||
|
|
||||||
|
override var selected: RenderingProfile = null.unsafeCast()
|
||||||
|
set(value) {
|
||||||
|
field = value
|
||||||
|
GlobalProfileManager.selectProfile(this, value)
|
||||||
|
GlobalEventMaster.fireEvent(RenderingProfileSelectEvent(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createDefaultProfile(name: String): RenderingProfile {
|
||||||
|
currentLoadingPath = name
|
||||||
|
val profile = RenderingProfile("Default rendering profile")
|
||||||
|
currentLoadingPath = null
|
||||||
|
profiles[name] = profile
|
||||||
|
|
||||||
|
return profile
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package de.bixilon.minosoft.config.profile.profiles.rendering
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.modding.event.events.Event
|
||||||
|
|
||||||
|
class RenderingProfileSelectEvent(
|
||||||
|
val profile: RenderingProfile,
|
||||||
|
) : Event
|
@ -0,0 +1,14 @@
|
|||||||
|
package de.bixilon.minosoft.config.profile.profiles.rendering.advanced
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfileManager.delegate
|
||||||
|
|
||||||
|
class AdvancedC {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the window swap interval (vsync)
|
||||||
|
* 0 means vsync disabled
|
||||||
|
* Every value above 0 means 1/x * <vsync framerate>
|
||||||
|
* Must not be negative
|
||||||
|
*/
|
||||||
|
var swapInterval by delegate(1) { check(it >= 0) { "Swap interval must not be negative!" } }
|
||||||
|
}
|
@ -149,7 +149,7 @@ class RenderWindow(
|
|||||||
Log.log(LogMessageType.RENDERING_LOADING) { "Creating window..." }
|
Log.log(LogMessageType.RENDERING_LOADING) { "Creating window..." }
|
||||||
val stopwatch = Stopwatch()
|
val stopwatch = Stopwatch()
|
||||||
|
|
||||||
window.init()
|
window.init(connection.profiles.rendering)
|
||||||
window.setDefaultIcon(connection.assetsManager)
|
window.setDefaultIcon(connection.assetsManager)
|
||||||
|
|
||||||
inputHandler.camera.init(this)
|
inputHandler.camera.init(this)
|
||||||
|
@ -13,8 +13,9 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.gui.rendering.system.window
|
package de.bixilon.minosoft.gui.rendering.system.window
|
||||||
|
|
||||||
import de.bixilon.minosoft.Minosoft
|
|
||||||
import de.bixilon.minosoft.config.StaticConfiguration
|
import de.bixilon.minosoft.config.StaticConfiguration
|
||||||
|
import de.bixilon.minosoft.config.profile.change.listener.SimpleChangeListener.Companion.listenRendering
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfile
|
||||||
import de.bixilon.minosoft.data.assets.AssetsManager
|
import de.bixilon.minosoft.data.assets.AssetsManager
|
||||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||||
import de.matthiasmann.twl.utils.PNGDecoder
|
import de.matthiasmann.twl.utils.PNGDecoder
|
||||||
@ -44,9 +45,9 @@ interface BaseWindow {
|
|||||||
|
|
||||||
val time: Double
|
val time: Double
|
||||||
|
|
||||||
fun init() {
|
fun init(profile: RenderingProfile) {
|
||||||
resizable = true
|
resizable = true
|
||||||
swapInterval = Minosoft.config.config.game.other.swapInterval
|
profile.advanced::swapInterval.listenRendering(this, true, profile) { swapInterval = it }
|
||||||
|
|
||||||
if (!StaticConfiguration.DEBUG_MODE) {
|
if (!StaticConfiguration.DEBUG_MODE) {
|
||||||
cursorMode = CursorModes.DISABLED
|
cursorMode = CursorModes.DISABLED
|
||||||
@ -54,6 +55,8 @@ interface BaseWindow {
|
|||||||
size = DEFAULT_WINDOW_SIZE
|
size = DEFAULT_WINDOW_SIZE
|
||||||
minSize = DEFAULT_MINIMUM_WINDOW_SIZE
|
minSize = DEFAULT_MINIMUM_WINDOW_SIZE
|
||||||
maxSize = DEFAULT_MAXIMUM_WINDOW_SIZE
|
maxSize = DEFAULT_MAXIMUM_WINDOW_SIZE
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun destroy()
|
fun destroy()
|
||||||
|
@ -15,6 +15,7 @@ package de.bixilon.minosoft.gui.rendering.system.window
|
|||||||
|
|
||||||
import de.bixilon.minosoft.Minosoft
|
import de.bixilon.minosoft.Minosoft
|
||||||
import de.bixilon.minosoft.config.key.KeyCodes
|
import de.bixilon.minosoft.config.key.KeyCodes
|
||||||
|
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfile
|
||||||
import de.bixilon.minosoft.gui.rendering.modding.events.ResizeWindowEvent
|
import de.bixilon.minosoft.gui.rendering.modding.events.ResizeWindowEvent
|
||||||
import de.bixilon.minosoft.gui.rendering.modding.events.WindowCloseEvent
|
import de.bixilon.minosoft.gui.rendering.modding.events.WindowCloseEvent
|
||||||
import de.bixilon.minosoft.gui.rendering.modding.events.WindowFocusChangeEvent
|
import de.bixilon.minosoft.gui.rendering.modding.events.WindowFocusChangeEvent
|
||||||
@ -127,7 +128,7 @@ class GLFWWindow(
|
|||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun init() {
|
override fun init(profile: RenderingProfile) {
|
||||||
GLFWErrorCallback.createPrint(System.err).set()
|
GLFWErrorCallback.createPrint(System.err).set()
|
||||||
check(glfwInit()) { "Unable to initialize GLFW" }
|
check(glfwInit()) { "Unable to initialize GLFW" }
|
||||||
|
|
||||||
@ -148,7 +149,7 @@ class GLFWWindow(
|
|||||||
|
|
||||||
glfwMakeContextCurrent(window)
|
glfwMakeContextCurrent(window)
|
||||||
|
|
||||||
super.init()
|
super.init(profile)
|
||||||
|
|
||||||
val primaryMonitor = glfwGetPrimaryMonitor()
|
val primaryMonitor = glfwGetPrimaryMonitor()
|
||||||
if (primaryMonitor != MemoryUtil.NULL) {
|
if (primaryMonitor != MemoryUtil.NULL) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user