Fixes in build scripts & tools.
Tetris: fixes for full screen mode.
This commit is contained in:
+1
-1
@@ -91,7 +91,7 @@ internal class NativeIndexImpl(val language: Language) : NativeIndex() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (underlying is ConstArrayType)
|
if (underlying !is ConstArrayType) return underlying
|
||||||
// So the result must feel like array:
|
// So the result must feel like array:
|
||||||
return ConstArrayType(RecordType(structDeclaration), 1)
|
return ConstArrayType(RecordType(structDeclaration), 1)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -148,7 +148,7 @@ private fun Properties.defaultCompilerOpts(target: String, dependencies: String)
|
|||||||
"-miphoneos-version-min=5.0.0")
|
"-miphoneos-version-min=5.0.0")
|
||||||
"osx-ios-sim" ->
|
"osx-ios-sim" ->
|
||||||
return listOf(
|
return listOf(
|
||||||
"-arch", "amd64",
|
"-arch", "x86_64",
|
||||||
"-isystem", isystem,
|
"-isystem", isystem,
|
||||||
"-B$sysRoot/usr/bin",
|
"-B$sysRoot/usr/bin",
|
||||||
"--sysroot=$targetSysRoot",
|
"--sysroot=$targetSysRoot",
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ osVersionMin.osx = -macosx_version_min 10.10.0
|
|||||||
// iphone
|
// iphone
|
||||||
arch.osx-ios = arm64
|
arch.osx-ios = arm64
|
||||||
sysRoot.osx-ios = target-sysroot-1-darwin-macos
|
sysRoot.osx-ios = target-sysroot-1-darwin-macos
|
||||||
targetSysRoot.osx-ios = target-sysroot-1-darwin-ios
|
targetSysRoot.osx-ios = target-sysroot-2-darwin-ios
|
||||||
llvmHome.osx-ios = clang+llvm-3.9.0-darwin-macos
|
llvmHome.osx-ios = clang+llvm-3.9.0-darwin-macos
|
||||||
llvmLtoFlags.osx-ios = -O3 -function-sections -exported-symbol=_main
|
llvmLtoFlags.osx-ios = -O3 -function-sections -exported-symbol=_main
|
||||||
llvmLlcFlags.osx-ios = -mtriple=arm64-apple-ios5.0.0 --disable-fp-elim
|
llvmLlcFlags.osx-ios = -mtriple=arm64-apple-ios5.0.0 --disable-fp-elim
|
||||||
|
|||||||
Vendored
+1
-1
@@ -87,7 +87,7 @@ if (isLinux()) {
|
|||||||
baseName = "target-sysroot-1-$host"
|
baseName = "target-sysroot-1-$host"
|
||||||
}
|
}
|
||||||
task iphoneSysroot(type: TgzNativeDep) {
|
task iphoneSysroot(type: TgzNativeDep) {
|
||||||
baseName = "target-sysroot-1-darwin-ios"
|
baseName = "target-sysroot-2-darwin-ios"
|
||||||
}
|
}
|
||||||
// TODO: re-enable when we known how to bring the simulator
|
// TODO: re-enable when we known how to bring the simulator
|
||||||
// sysroot to dependencies.
|
// sysroot to dependencies.
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>BuildMachineOSBuild</key>
|
||||||
|
<string>15G1212</string>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>en</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>tetris.kexe</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>tetris.kexe</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>tetris.kexe</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleSupportedPlatforms</key>
|
||||||
|
<array>
|
||||||
|
<string>iPhoneOS</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>DTCompiler</key>
|
||||||
|
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||||
|
<key>DTPlatformBuild</key>
|
||||||
|
<string>14C89</string>
|
||||||
|
<key>DTPlatformName</key>
|
||||||
|
<string>iphoneos</string>
|
||||||
|
<key>DTPlatformVersion</key>
|
||||||
|
<string>10.2</string>
|
||||||
|
<key>DTSDKBuild</key>
|
||||||
|
<string>14C89</string>
|
||||||
|
<key>DTSDKName</key>
|
||||||
|
<string>iphoneos10.2</string>
|
||||||
|
<key>DTXcode</key>
|
||||||
|
<string>0821</string>
|
||||||
|
<key>DTXcodeBuild</key>
|
||||||
|
<string>8C1002</string>
|
||||||
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
<true/>
|
||||||
|
<key>MinimumOSVersion</key>
|
||||||
|
<string>10.2</string>
|
||||||
|
<key>UIDeviceFamily</key>
|
||||||
|
<array>
|
||||||
|
<integer>1</integer>
|
||||||
|
</array>
|
||||||
|
<key>UILaunchStoryboardName</key>
|
||||||
|
<string>LaunchScreen</string>
|
||||||
|
<key>UIRequiredDeviceCapabilities</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
</array>
|
||||||
|
<key>UIStatusBarHidden</key>
|
||||||
|
<true/>
|
||||||
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleIcons</key>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundlePrimaryIcon</key>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleIconFiles</key>
|
||||||
|
<array>
|
||||||
|
<string>Icon-60x2</string>
|
||||||
|
<string>Icon-60</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
+20
-14
@@ -2,25 +2,31 @@
|
|||||||
|
|
||||||
DIR=.
|
DIR=.
|
||||||
DIST=../../dist
|
DIST=../../dist
|
||||||
OSX_CFLAGS=-I/Library/Frameworks/SDL2.framework/Headers
|
DEPS=../../dependencies/all
|
||||||
OSX_LINKER_ARGS="-F /Library/Frameworks -framework SDL2"
|
CFLAGS_macbook=-I/Library/Frameworks/SDL2.framework/Headers
|
||||||
#OSX_CFLAGS=-I/opt/local/include/SDL2
|
LINKER_ARGS_macbook="-F /Library/Frameworks -framework SDL2"
|
||||||
#OSX_LINKER_ARGS="-L/opt/local/lib -lSDL2"
|
#CFLAGS_macbook=-I/opt/local/include/SDL2
|
||||||
LINUX_CFLAGS=-I/usr/include/SDL2
|
#LINKER_ARGS_macbook="-L/opt/local/lib -lSDL2"
|
||||||
LINUX_LINKER_ARGS="-L/usr/lib/x86_64-linux-gnu -lSDL2"
|
CFLAGS_linux=-I/usr/include/SDL2
|
||||||
|
LINKER_ARGS_linux="-L/usr/lib/x86_64-linux-gnu -lSDL2"
|
||||||
|
CFLAGS_iphone=-I$DEPS/target-sysroot-2-darwin-ios/System/Library/Frameworks/SDL2.framework/Headers
|
||||||
|
LINKER_ARGS_iphone="-framework SDL2 \
|
||||||
|
-framework AVFoundation -framework CoreGraphics -framework CoreMotion -framework Foundation -framework GameController \
|
||||||
|
-framework AudioToolbox -framework OpenGLES -framework QuartzCore -framework UIKit"
|
||||||
|
|
||||||
|
if [ x$TARGET == x ]; then
|
||||||
case "$OSTYPE" in
|
case "$OSTYPE" in
|
||||||
darwin*) OS=OSX ;;
|
darwin*) TARGET=macbook ;;
|
||||||
linux*) OS=LINUX ;;
|
linux*) TARGET=linux ;;
|
||||||
*) echo "unknown: $OSTYPE" && exit 1;;
|
*) echo "unknown: $OSTYPE" && exit 1;;
|
||||||
esac
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
var=${OS}_CFLAGS
|
var=CFLAGS_${TARGET}
|
||||||
CFLAGS=${!var}
|
CFLAGS=${!var}
|
||||||
var=${OS}_LINKER_ARGS
|
var=LINKER_ARGS_${TARGET}
|
||||||
LINKER_ARGS=${!var}
|
LINKER_ARGS=${!var}
|
||||||
|
|
||||||
$DIST/bin/interop -def:$DIR/sdl.def -copt:$CFLAGS || exit 1
|
$DIST/bin/interop -def:$DIR/sdl.def -copt:"$CFLAGS" -target:$TARGET || exit 1
|
||||||
$DIST/bin/konanc -opt $DIR/tetris.kt sdl -nativelibrary sdlstubs.bc -linkerArgs "$LINKER_ARGS" -o tetris.kexe || exit 1
|
$DIST/bin/konanc -target $TARGET sdl $DIR/tetris.kt -nativelibrary sdlstubs.bc -linkerArgs "$LINKER_ARGS" -o tetris.kexe || exit 1
|
||||||
strip tetris.kexe
|
#strip tetris.kexe
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
headers = SDL.h stdio.h string.h unistd.h stdlib.h time.h
|
headers = SDL.h stdio.h string.h unistd.h stdlib.h time.h
|
||||||
excludedFunctions = _IO_flockfile _IO_funlockfile _IO_ftrylockfile \
|
excludedFunctions = _IO_flockfile _IO_funlockfile _IO_ftrylockfile \
|
||||||
_IO_cleanup_region_start _IO_cleanup_region_end \
|
_IO_cleanup_region_start _IO_cleanup_region_end \
|
||||||
mkstemp_dprotected_np
|
mkstemp_dprotected_np add_profil profil unwhiteout zopen \
|
||||||
|
SDL_PointInRect SDL_RectEmpty SDL_RectEquals \
|
||||||
|
__darwin_fd_isset __sputc matherr _mm_stream_si32 _mm_stream_si64
|
||||||
entryPoint = SDL_main
|
entryPoint = SDL_main
|
||||||
|
|
||||||
compilerOpts.osx = -D_POSIX_SOURCE -mxsave -mavx -mf16c
|
compilerOpts.osx = -D_POSIX_SOURCE -mxsave -mavx -mf16c
|
||||||
|
|||||||
+74
-53
@@ -507,9 +507,12 @@ class SDL_Visualizer(val width: Int, val height: Int): GameFieldVisualizer, User
|
|||||||
private val LEVEL_LABEL_WIDTH = 103
|
private val LEVEL_LABEL_WIDTH = 103
|
||||||
private val NEXT_LABEL_WIDTH = 85
|
private val NEXT_LABEL_WIDTH = 85
|
||||||
private val TETRISES_LABEL_WIDTH = 162
|
private val TETRISES_LABEL_WIDTH = 162
|
||||||
private val GAMEPAD_HEIGHT = 100
|
|
||||||
|
|
||||||
inner class GamePadButtons(val width: Int, val height: Int) {
|
private val ratio: Float
|
||||||
|
|
||||||
|
private fun stretch(value: Int) = (value.toFloat() * ratio + 0.5).toInt()
|
||||||
|
|
||||||
|
inner class GamePadButtons(width: Int, height: Int, gamePadHeight: Int) {
|
||||||
val arena = Arena()
|
val arena = Arena()
|
||||||
val leftRect: SDL_Rect
|
val leftRect: SDL_Rect
|
||||||
val rightRect: SDL_Rect
|
val rightRect: SDL_Rect
|
||||||
@@ -518,40 +521,40 @@ class SDL_Visualizer(val width: Int, val height: Int): GameFieldVisualizer, User
|
|||||||
val rotateRect: SDL_Rect
|
val rotateRect: SDL_Rect
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val s = 30
|
val s1 = 50
|
||||||
val m = 15
|
val s2 = 80
|
||||||
val x = (width - 3 * s - 2 * m - 3 * s) / 2
|
val m = 25
|
||||||
val y1 = (GAMEPAD_HEIGHT - s) / 2
|
val x = (width - 3 * s1 - 2 * m - m - s2) / 2 - s1
|
||||||
val y2 = (GAMEPAD_HEIGHT - 2 * s - m) / 2
|
val y2 = (gamePadHeight - 2 * s1 - m) / 2
|
||||||
leftRect = arena.alloc<SDL_Rect>()
|
leftRect = arena.alloc<SDL_Rect>()
|
||||||
leftRect.w.value = s
|
leftRect.w.value = s1
|
||||||
leftRect.h.value = s
|
leftRect.h.value = s1
|
||||||
leftRect.x.value = x
|
leftRect.x.value = x
|
||||||
leftRect.y.value = height - GAMEPAD_HEIGHT + y2 + s + m
|
leftRect.y.value = height - gamePadHeight + y2 + s1 + m
|
||||||
|
|
||||||
downRect = arena.alloc<SDL_Rect>()
|
downRect = arena.alloc<SDL_Rect>()
|
||||||
downRect.w.value = s
|
downRect.w.value = s1
|
||||||
downRect.h.value = s
|
downRect.h.value = s1
|
||||||
downRect.x.value = x + s + m
|
downRect.x.value = x + s1 + m
|
||||||
downRect.y.value = leftRect.y.value
|
downRect.y.value = leftRect.y.value
|
||||||
|
|
||||||
dropRect = arena.alloc<SDL_Rect>()
|
dropRect = arena.alloc<SDL_Rect>()
|
||||||
dropRect.w.value = s
|
dropRect.w.value = s1
|
||||||
dropRect.h.value = s
|
dropRect.h.value = s1
|
||||||
dropRect.x.value = downRect.x.value
|
dropRect.x.value = downRect.x.value
|
||||||
dropRect.y.value = height - GAMEPAD_HEIGHT + y2
|
dropRect.y.value = height - gamePadHeight + y2
|
||||||
|
|
||||||
rightRect = arena.alloc<SDL_Rect>()
|
rightRect = arena.alloc<SDL_Rect>()
|
||||||
rightRect.w.value = s
|
rightRect.w.value = s1
|
||||||
rightRect.h.value = s
|
rightRect.h.value = s1
|
||||||
rightRect.x.value = x + 2 * s + 2 * m
|
rightRect.x.value = x + 2 * s1 + 2 * m
|
||||||
rightRect.y.value = height - GAMEPAD_HEIGHT + y2 + s + m
|
rightRect.y.value = height - gamePadHeight + y2 + s1 + m
|
||||||
|
|
||||||
rotateRect = arena.alloc<SDL_Rect>()
|
rotateRect = arena.alloc<SDL_Rect>()
|
||||||
rotateRect.w.value = s
|
rotateRect.w.value = s2
|
||||||
rotateRect.h.value = s
|
rotateRect.h.value = s2
|
||||||
rotateRect.x.value = x + 3 * s + 2 * m + 2 * s
|
rotateRect.x.value = x + 3 * s1 + 2 * m + m
|
||||||
rotateRect.y.value = height - GAMEPAD_HEIGHT + y1
|
rotateRect.y.value = height - gamePadHeight + y2 - m
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCommandAt(x: Int, y: Int): UserCommand? {
|
fun getCommandAt(x: Int, y: Int): UserCommand? {
|
||||||
@@ -566,8 +569,8 @@ class SDL_Visualizer(val width: Int, val height: Int): GameFieldVisualizer, User
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun inside(rect: SDL_Rect, x: Int, y: Int): Boolean {
|
private fun inside(rect: SDL_Rect, x: Int, y: Int): Boolean {
|
||||||
return x >= rect.x.value && x <= rect.x.value + rect.w.value
|
return x >= stretch(rect.x.value) && x <= stretch(rect.x.value + rect.w.value)
|
||||||
&& y >= rect.y.value && y <= rect.y.value + rect.h.value
|
&& y >= stretch(rect.y.value) && y <= stretch(rect.y.value + rect.h.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun destroy() {
|
fun destroy() {
|
||||||
@@ -586,14 +589,13 @@ class SDL_Visualizer(val width: Int, val height: Int): GameFieldVisualizer, User
|
|||||||
private var displayHeight: Int = 0
|
private var displayHeight: Int = 0
|
||||||
private val fieldWidth: Int
|
private val fieldWidth: Int
|
||||||
private val fieldHeight: Int
|
private val fieldHeight: Int
|
||||||
private val windowWidth: Int
|
|
||||||
private val windowHeight: Int
|
|
||||||
private val windowX: Int
|
private val windowX: Int
|
||||||
private val windowY: Int
|
private val windowY: Int
|
||||||
private val window: CPointer<SDL_Window>
|
private val window: CPointer<SDL_Window>
|
||||||
private val renderer: CPointer<SDL_Renderer>
|
private val renderer: CPointer<SDL_Renderer>
|
||||||
private val texture: CPointer<SDL_Texture>
|
private val texture: CPointer<SDL_Texture>
|
||||||
private val gamePadButtons: GamePadButtons
|
private val gamePadButtons: GamePadButtons?
|
||||||
|
private val platform: String
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
|
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
|
||||||
@@ -601,6 +603,8 @@ class SDL_Visualizer(val width: Int, val height: Int): GameFieldVisualizer, User
|
|||||||
throw Error()
|
throw Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
platform = SDL_GetPlatform()!!.toKString()
|
||||||
|
|
||||||
memScoped {
|
memScoped {
|
||||||
val displayMode = alloc<SDL_DisplayMode>()
|
val displayMode = alloc<SDL_DisplayMode>()
|
||||||
if (SDL_GetCurrentDisplayMode(0, displayMode.ptr.reinterpret()) != 0) {
|
if (SDL_GetCurrentDisplayMode(0, displayMode.ptr.reinterpret()) != 0) {
|
||||||
@@ -613,11 +617,24 @@ class SDL_Visualizer(val width: Int, val height: Int): GameFieldVisualizer, User
|
|||||||
}
|
}
|
||||||
fieldWidth = width * (CELL_SIZE + MARGIN) + MARGIN + BORDER_WIDTH * 2
|
fieldWidth = width * (CELL_SIZE + MARGIN) + MARGIN + BORDER_WIDTH * 2
|
||||||
fieldHeight = height * (CELL_SIZE + MARGIN) + MARGIN + BORDER_WIDTH * 2
|
fieldHeight = height * (CELL_SIZE + MARGIN) + MARGIN + BORDER_WIDTH * 2
|
||||||
windowWidth = fieldWidth + INFO_SPACE_WIDTH
|
var windowWidth = fieldWidth + INFO_SPACE_WIDTH
|
||||||
windowHeight = fieldHeight + GAMEPAD_HEIGHT
|
var windowHeight = 0
|
||||||
gamePadButtons = GamePadButtons(windowWidth, windowHeight)
|
if (platform == "iOS") {
|
||||||
windowX = (displayWidth - windowWidth) / 2
|
val gamePadHeight = (displayHeight * windowWidth - fieldHeight * displayWidth) / displayWidth
|
||||||
windowY = (displayHeight - windowHeight) / 2
|
windowHeight = fieldHeight + gamePadHeight
|
||||||
|
gamePadButtons = GamePadButtons(windowWidth, windowHeight, gamePadHeight)
|
||||||
|
windowX = 0
|
||||||
|
windowY = 0
|
||||||
|
ratio = displayHeight.toFloat() / windowHeight
|
||||||
|
windowWidth = displayWidth
|
||||||
|
windowHeight = displayHeight
|
||||||
|
} else {
|
||||||
|
windowHeight = fieldHeight
|
||||||
|
gamePadButtons = null
|
||||||
|
windowX = (displayWidth - windowWidth) / 2
|
||||||
|
windowY = (displayHeight - windowHeight) / 2
|
||||||
|
ratio = 1.0f
|
||||||
|
}
|
||||||
val window = SDL_CreateWindow("Tetris", windowX, windowY, windowWidth, windowHeight, SDL_WINDOW_SHOWN)
|
val window = SDL_CreateWindow("Tetris", windowX, windowY, windowWidth, windowHeight, SDL_WINDOW_SHOWN)
|
||||||
if (window == null) {
|
if (window == null) {
|
||||||
println("SDL_CreateWindow Error: ${get_SDL_Error()}")
|
println("SDL_CreateWindow Error: ${get_SDL_Error()}")
|
||||||
@@ -842,15 +859,27 @@ class SDL_Visualizer(val width: Int, val height: Int): GameFieldVisualizer, User
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun drawGamePad() {
|
private fun drawGamePad() {
|
||||||
|
if (gamePadButtons == null) return
|
||||||
SDL_SetRenderDrawColor(renderer, 127, 127, 127, SDL_ALPHA_OPAQUE.toByte())
|
SDL_SetRenderDrawColor(renderer, 127, 127, 127, SDL_ALPHA_OPAQUE.toByte())
|
||||||
SDL_RenderFillRect(renderer, gamePadButtons.leftRect.ptr.reinterpret())
|
fillRect(gamePadButtons.leftRect)
|
||||||
SDL_RenderFillRect(renderer, gamePadButtons.downRect.ptr.reinterpret())
|
fillRect(gamePadButtons.downRect)
|
||||||
SDL_RenderFillRect(renderer, gamePadButtons.dropRect.ptr.reinterpret())
|
fillRect(gamePadButtons.dropRect)
|
||||||
SDL_RenderFillRect(renderer, gamePadButtons.rightRect.ptr.reinterpret())
|
fillRect(gamePadButtons.rightRect)
|
||||||
SDL_RenderFillRect(renderer, gamePadButtons.rotateRect.ptr.reinterpret())
|
fillRect(gamePadButtons.rotateRect)
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE.toByte())
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE.toByte())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun fillRect(rect: SDL_Rect) {
|
||||||
|
memScoped {
|
||||||
|
val stretchedRect = alloc<SDL_Rect>()
|
||||||
|
stretchedRect.w.value = stretch(rect.w.value)
|
||||||
|
stretchedRect.h.value = stretch(rect.h.value)
|
||||||
|
stretchedRect.x.value = stretch(rect.x.value)
|
||||||
|
stretchedRect.y.value = stretch(rect.y.value)
|
||||||
|
SDL_RenderFillRect(renderer, stretchedRect.ptr.reinterpret())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun copyRect(srcX: Int, srcY: Int, destX: Int, destY: Int, width: Int, height: Int) {
|
private fun copyRect(srcX: Int, srcY: Int, destX: Int, destY: Int, width: Int, height: Int) {
|
||||||
memScoped {
|
memScoped {
|
||||||
val srcRect = alloc<SDL_Rect>()
|
val srcRect = alloc<SDL_Rect>()
|
||||||
@@ -859,10 +888,10 @@ class SDL_Visualizer(val width: Int, val height: Int): GameFieldVisualizer, User
|
|||||||
srcRect.h.value = height
|
srcRect.h.value = height
|
||||||
srcRect.x.value = srcX
|
srcRect.x.value = srcX
|
||||||
srcRect.y.value = srcY
|
srcRect.y.value = srcY
|
||||||
destRect.w.value = width
|
destRect.w.value = stretch(width)
|
||||||
destRect.h.value = height
|
destRect.h.value = stretch(height)
|
||||||
destRect.x.value = destX
|
destRect.x.value = stretch(destX)
|
||||||
destRect.y.value = destY
|
destRect.y.value = stretch(destY)
|
||||||
SDL_RenderCopy(renderer, texture, srcRect.ptr.reinterpret(), destRect.ptr.reinterpret())
|
SDL_RenderCopy(renderer, texture, srcRect.ptr.reinterpret(), destRect.ptr.reinterpret())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -886,7 +915,7 @@ class SDL_Visualizer(val width: Int, val height: Int): GameFieldVisualizer, User
|
|||||||
SDL_SCANCODE_ESCAPE -> commands.add(UserCommand.EXIT)
|
SDL_SCANCODE_ESCAPE -> commands.add(UserCommand.EXIT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_MOUSEBUTTONDOWN -> {
|
SDL_MOUSEBUTTONDOWN -> if (gamePadButtons != null) {
|
||||||
val mouseEvent = event.ptr.reinterpret<SDL_MouseButtonEvent>().pointed
|
val mouseEvent = event.ptr.reinterpret<SDL_MouseButtonEvent>().pointed
|
||||||
val x = mouseEvent.x.value
|
val x = mouseEvent.x.value
|
||||||
val y = mouseEvent.y.value
|
val y = mouseEvent.y.value
|
||||||
@@ -894,14 +923,6 @@ class SDL_Visualizer(val width: Int, val height: Int): GameFieldVisualizer, User
|
|||||||
if (command != null)
|
if (command != null)
|
||||||
commands.add(command)
|
commands.add(command)
|
||||||
}
|
}
|
||||||
SDL_FINGERDOWN -> {
|
|
||||||
val touchFingerEvent = event.ptr.reinterpret<SDL_TouchFingerEvent>().pointed
|
|
||||||
val x = (touchFingerEvent.x.value * displayWidth).toInt() - windowX
|
|
||||||
val y = (touchFingerEvent.y.value * displayHeight).toInt() - windowY
|
|
||||||
val command = getCommandAt(x, y)
|
|
||||||
if (command != null)
|
|
||||||
commands.add(command)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -913,7 +934,7 @@ class SDL_Visualizer(val width: Int, val height: Int): GameFieldVisualizer, User
|
|||||||
SDL_DestroyRenderer(renderer)
|
SDL_DestroyRenderer(renderer)
|
||||||
SDL_DestroyWindow(window)
|
SDL_DestroyWindow(window)
|
||||||
SDL_Quit()
|
SDL_Quit()
|
||||||
gamePadButtons.destroy()
|
gamePadButtons?.destroy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user