Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorDY authored Mar 21, 2024
2 parents 51e3511 + 14bb329 commit 39a27d9
Show file tree
Hide file tree
Showing 18 changed files with 169 additions and 84 deletions.
18 changes: 15 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
# Changelog

## 2.4.1
## Unreleased

### :sparkles: Enhancements

- Regions with newer textures will now display properly.

- More locations added

- Regions with newer textures will now display properly.

- Add custom scale factors and default to 1:128 instead of 1:100 – [#177](https://github.com/ConnorDY/OSRS-Environment-Exporter/pull/177) @ScoreUnder

- Add command line option to select Z layers – [#181](https://github.com/ConnorDY/OSRS-Environment-Exporter/pull/181) @ScoreUnder

## 2.4.1

### :bug: Bug Fixes

- Fix `idOffset` reading in `LocationsLoader` – [#174](https://github.com/ConnorDY/OSRS-Environment-Exporter/pull/174) @dennisdev

- Add default object transform – [#175](https://github.com/ConnorDY/OSRS-Environment-Exporter/pull/175) @dennisdev

## 2.4.0

### :sparkles: Enhancements
Expand Down
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ java --version
| `power-saving-mode` | `Boolean` | `false` | If enabled, will attempt to keep the idle frame rate as low as possible without impacting usability. |
| `priority-renderer` | `Enum` | Varies | The face-sorting renderer to use. May not actually sort faces. One of `GLSL`, `CPU_NAIVE`. Set to `CPU_NAIVE` on MacOS due to missing compute shader support, and `GLSL` everywhere else. |
| `sample-shading` | `Boolean` | `false` | If enabled, tells OpenGL to shade sub-samples in MSAA (OpenGL 4.0+). |
| `scale-mode` | `Enum` | `SCALE_1TO128` | The scaling mode to use. One of `SCALE_1TO1`, `SCALE1TO100`, `SCALE_1TO128`. See also `--scale`. |

## Development

Expand Down Expand Up @@ -74,16 +75,7 @@ java --version

## Credits

Original idea by [Trillion](https://twitter.com/TrillionStudios).

Based on [@tpetrychyn](https://github.com/tpetrychyn)'s [OSRS Map Editor](https://github.com/tpetrychyn/osrs-map-editor).

Using changes from [@partyvaper](https://github.com/partyvaper)'s [fork](https://github.com/partyvaper/osrs-map-editor).

## Donate

If you would like to financially support the primary developers ([@ScoreUnder](https://github.com/ScoreUnder) & [@ConnorDY](https://github.com/ConnorDY)) of the OSRS Environment Exporter, click the button below: [^1]

[![Donate](./docs/donate-button.png)](https://www.paypal.com/donate/?business=DVHHXKWFYZUJL&no_recurring=0&item_name=Donations+will+go+directly+to+the+primary+developers+%28score+and+wiz%29+of+the+OSRS+Environment+Exporter.&currency_code=USD)

[^1]: Donating will not guarantee that more time is spent developing this application.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "link.cdy"
version = "2.4.0"
version = "2.4.1"

repositories {
mavenCentral {
Expand Down
5 changes: 4 additions & 1 deletion run
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ if [ "${1#--debug}" != "$1" ]; then
shift
fi

exec "$java" $debug_params -jar ./build/libs/osrs-environment-exporter-fat-2.3.0.jar "$@"
# Get the appropriate version from build.gradle.kts
version=$(grep -oP '(?<=version = ").*(?=")' build.gradle.kts)

exec "$java" $debug_params -jar ./build/libs/osrs-environment-exporter-fat-$version.jar "$@"
2 changes: 1 addition & 1 deletion run.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
java -jar ./build/libs/osrs-environment-exporter-fat-2.3.0.jar %*
java -jar ./build/libs/osrs-environment-exporter-fat-2.4.1.jar %*
70 changes: 55 additions & 15 deletions src/main/kotlin/App.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import cache.definitions.RegionDefinition.Companion.Z
import controllers.CacheChooserController
import models.StartupOptions
import models.config.ConfigOptions
Expand All @@ -10,6 +11,7 @@ import javax.swing.SwingUtilities
import javax.swing.ToolTipManager
import javax.swing.UIManager
import javax.swing.UnsupportedLookAndFeelException
import kotlin.system.exitProcess

private fun setSysProperty(key: String, value: String) {
if (System.getProperty(key) == null) {
Expand Down Expand Up @@ -53,14 +55,21 @@ private fun printHelp() {
println(" --export-dir <path> Set the export directory for this run")
println(" --flat, -f Do not use timestamped subdirectories for export")
println(" --format <format> Set the export format for this run")
println(" --scale <factor> Set the export scale factor (e.g. 1:128), overrides config")
println(" --no-preview Run the GUI, but don't render the preview")
println(" --z-layers <layers> Set the Z layers to render (e.g. 0,1,2,3)")
println(" -- End of options")
println()
println("Arguments:")
println(" regionID The region ID to load")
println(" radius The radius of regions to load")
}

private fun errorExit(message: String): Nothing {
System.err.println("Error: $message")
exitProcess(1)
}

fun main(args: Array<String>) {
val configOptions = ConfigOptions(Configuration())
val startupOptions = StartupOptions(configOptions)
Expand All @@ -83,49 +92,81 @@ fun main(args: Array<String>) {
configOptions.debug.value.set(true)
}
"--cache-dir" -> {
if (args.size < 2) {
println("Error: --cache-dir requires an argument")
return
if (args.size - argIndex < 2) {
errorExit("--cache-dir requires an argument")
}
startupOptions.cacheDir = args[++argIndex]
}
"--export", "-e" -> {
startupOptions.exportOnly = true
}
"--export-dir" -> {
if (args.size < 2) {
println("Error: --export-dir requires an argument")
return
if (args.size - argIndex < 2) {
errorExit("--export-dir requires an argument")
}
startupOptions.exportDir = args[++argIndex]
}
"--flat", "-f" -> {
startupOptions.exportFlat = true
}
"--format" -> {
if (args.size < 2) {
println("Error: --format requires an argument")
return
if (args.size - argIndex < 2) {
errorExit("--format requires an argument")
}
val formatName = args[++argIndex]
// Placeholder for when we actually support multiple export formats
if (formatName != "gltf") {
println("Error: Unknown export format: $formatName")
return
errorExit("Unknown export format: $formatName")
}
}
"--scale" -> {
if (args.size - argIndex < 2) {
errorExit("--scale requires an argument")
}
val scale = args[++argIndex]
val scaleParts = scale.split(":")
if (scaleParts.size != 2) {
errorExit("Invalid scale: $scale")
}
try {
val scaleNumerator = scaleParts[0].trim().toFloat()
val scaleDenominator = scaleParts[1].trim().toFloat()
if (scaleNumerator == 0f || scaleDenominator == 0f) {
errorExit("Invalid scale: $scale")
}
startupOptions.scaleFactor = scaleNumerator / scaleDenominator
startupOptions.hasScaleFactor = true
} catch (e: NumberFormatException) {
errorExit("Invalid scale: $scale")
}
}
"--no-preview" -> {
startupOptions.showPreview = false
}
"--z-layers" -> {
if (args.size - argIndex < 2) {
errorExit("--z-layers requires an argument")
}
val zLayers = args[++argIndex]
val zLayerParts = zLayers.split(",")
val zLayersList = try {
zLayerParts.map { it.trim().toInt() }
} catch (e: NumberFormatException) {
errorExit("List of Z layers should contain only numbers: $zLayers")
}
if (zLayersList.any { it < 0 || it >= Z }) {
errorExit("All Z layers should be in the range 0-${Z - 1}: $zLayers")
}
startupOptions.enabledZLayers = zLayersList
}
"--" -> {
argIndex++
break
}

else -> {
if (arg.startsWith("-")) {
println("Error: Unknown option '$arg'")
return
errorExit("Unknown option '$arg'")
} else {
// Positional argument, pass downwards
break
Expand All @@ -137,8 +178,7 @@ fun main(args: Array<String>) {

// We should have 2 arguments left: region ID and radius. Anything else is an error.
if (args.size - argIndex > 2) {
println("Error: Too many arguments")
return
errorExit("Too many arguments")
}

if (argIndex < args.size) {
Expand Down
8 changes: 7 additions & 1 deletion src/main/kotlin/CliExporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class CliExporter(startupOptions: StartupOptions) {
val modelLoader = ModelLoader(cacheLibrary)

val debugOptionsModel = DebugOptionsModel()
debugOptionsModel.setZLevelsFromList(startupOptions.enabledZLayers)

val textureManager = TextureManager(spriteLoader, textureLoader)
val objectToModelConverter = ObjectToModelConverter(modelLoader, debugOptionsModel)
Expand All @@ -50,7 +51,12 @@ class CliExporter(startupOptions: StartupOptions) {

scene.sceneChangeListeners.add {
// Export the scene once it has been loaded.
exporter.exportSceneToFile(scene, startupOptions.exportDir, startupOptions.exportFlat)
exporter.exportSceneToFile(
scene,
startupOptions.exportDir,
startupOptions.exportFlat,
startupOptions.scaleFactor
)
}

// Listen for progress updates
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/cache/definitions/ObjectDefinition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ObjectDefinition {
var obstructsGround = false
var contouredGround = -1
var supportsItems = -1
lateinit var transforms: IntArray
var transforms: IntArray? = null
var isRotated = false
var transformVarp = -1
var ambientSoundId = -1
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/cache/loaders/LocationsLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class LocationsLoader(
positionOffset = buffer.readUnsignedShortSmart()
}

idOffset = buffer.readUnsignedShortSmart()
idOffset = buffer.readUnsignedSmartShortExtended()
}

return locationsDefinition
Expand Down
9 changes: 8 additions & 1 deletion src/main/kotlin/controllers/main/MainController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class MainController constructor(
layout = BorderLayout()
preferredSize = Dimension(1600, 800)

debugOptions.setZLevelsFromList(startupOptions.enabledZLayers)

val camera = Camera()
val objectToModelConverter =
ObjectToModelConverter(ModelLoader(cacheLibrary), debugOptions)
Expand Down Expand Up @@ -299,7 +301,12 @@ class MainController constructor(
Thread {
try {
try {
exporter.exportSceneToFile(scene, startupOptions.exportDir, startupOptions.exportFlat)
val scaleFactor =
if (startupOptions.hasScaleFactor)
startupOptions.scaleFactor
else
configOptions.scaleMode.value.get().scaleFactor
exporter.exportSceneToFile(scene, startupOptions.exportDir, startupOptions.exportFlat, scaleFactor)
} catch (_: CancelledException) {
return@Thread
}
Expand Down
Loading

0 comments on commit 39a27d9

Please sign in to comment.