actually working load manual/auto button

This commit is contained in:
minjaesong
2023-06-26 20:18:00 +09:00
parent e5e8028b3f
commit 1ef479124e
4 changed files with 52 additions and 12 deletions

View File

@@ -777,8 +777,8 @@ public class App implements ApplicationListener {
public void resize(int w0, int h0) {
float magn = (float) getConfigDouble("screenmagnifying");
int width = Math.round(w0 / magn);
int height = Math.round(h0 / magn);
int width = (int) Math.floor(w0 / magn);
int height = (int) Math.floor(h0 / magn);
printdbg(this, "Resize called: "+width+","+height);

View File

@@ -56,8 +56,8 @@ class TerrarumScreenSize(scrw: Int = defaultW, scrh: Int = defaultH) {
this.magn = magn
windowW = (scrw * magn).roundToInt() and 0x7FFFFFFE
windowH = (scrh * magn).roundToInt() and 0x7FFFFFFE
windowW = (scrw * magn).ceilInt() and 0x7FFFFFFE
windowH = (scrh * magn).ceilInt() and 0x7FFFFFFE
printdbg(this, "Window dim: $windowW x $windowH, called by:")

View File

@@ -191,7 +191,16 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
imageDrawHeight = imageButtonH,
highlightable = false,
useBorder = true,
).also { it.extraDrawOp = getDrawTextualInfoFun(loadables.getManualSave()!!) }
).also {
it.extraDrawOp = getDrawTextualInfoFun(loadables.getManualSave()!!)
it.clickOnceListener = { _,_ ->
loadables.getManualSave()!!.let {
UILoadGovernor.playerDisk = it.player
UILoadGovernor.worldDisk = it.world
}
mode = MODE_LOAD_DA_SHIT_ALREADY
}
}
loadAutoThumbButton = UIItemImageButton(this, autoThumb,
initialX = (Toolkit.drawWidth - altSelDrawW)/2 + altSelQQQdrawW - imageButtonW/2,
initialY = altSelDrawY + 120,
@@ -201,7 +210,16 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
imageDrawHeight = imageButtonH,
highlightable = false,
useBorder = true,
).also { it.extraDrawOp = getDrawTextualInfoFun(loadables.getAutoSave()!!) }
).also {
it.extraDrawOp = getDrawTextualInfoFun(loadables.getAutoSave()!!)
it.clickOnceListener = { _,_ ->
loadables.getAutoSave()!!.let {
UILoadGovernor.playerDisk = it.player
UILoadGovernor.worldDisk = it.world
}
mode = MODE_LOAD_DA_SHIT_ALREADY
}
}
MODE_SAVE_MULTIPLE_CHOICES
}
@@ -217,12 +235,12 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
UILoadGovernor.previousSaveWasLoaded = true
}
// MODE_LOAD_DA_SHIT_ALREADY
MODE_LOAD_DA_SHIT_ALREADY
// test codes //
val autoThumb = loadables.getManualSave()!!.getThumbnail()
/*val autoThumb = loadables.getManualSave()!!.getThumbnail()
val manualThumb = loadables.getManualSave()!!.getThumbnail()
loadManualThumbButton = UIItemImageButton(this, manualThumb,
@@ -234,7 +252,16 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
imageDrawHeight = imageButtonH,
highlightable = false,
useBorder = true,
).also { it.extraDrawOp = getDrawTextualInfoFun(loadables.getManualSave()!!) }
).also {
it.extraDrawOp = getDrawTextualInfoFun(loadables.getManualSave()!!)
it.clickOnceListener = { _,_ ->
loadables.getManualSave()!!.let {
UILoadGovernor.playerDisk = it.player
UILoadGovernor.worldDisk = it.world
}
mode = MODE_LOAD_DA_SHIT_ALREADY
}
}
loadAutoThumbButton = UIItemImageButton(this, autoThumb,
initialX = (Toolkit.drawWidth - altSelDrawW)/2 + altSelQQQdrawW - imageButtonW/2,
initialY = altSelDrawY + 120,
@@ -244,9 +271,18 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
imageDrawHeight = imageButtonH,
highlightable = false,
useBorder = true,
).also { it.extraDrawOp = getDrawTextualInfoFun(loadables.getManualSave()!!) }
).also {
it.extraDrawOp = getDrawTextualInfoFun(loadables.getManualSave()!!)
it.clickOnceListener = { _,_ ->
loadables.getManualSave()!!.let {
UILoadGovernor.playerDisk = it.player
UILoadGovernor.worldDisk = it.world
}
mode = MODE_LOAD_DA_SHIT_ALREADY
}
}
MODE_SAVE_MULTIPLE_CHOICES
MODE_SAVE_MULTIPLE_CHOICES*/
}
}
}
@@ -492,11 +528,15 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
if (mode == MODE_SELECT) getCells().forEach { it.touchDown(screenX, screenY, pointer, button) }
if (::loadAutoThumbButton.isInitialized && mode == MODE_SAVE_MULTIPLE_CHOICES) { loadAutoThumbButton.touchDown(screenX, screenY, pointer, button) }
if (::loadManualThumbButton.isInitialized && mode == MODE_SAVE_MULTIPLE_CHOICES) { loadManualThumbButton.touchDown(screenX, screenY, pointer, button) }
return true
}
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
if (mode == MODE_SELECT) getCells().forEach { it.touchUp(screenX, screenY, pointer, button) }
if (::loadAutoThumbButton.isInitialized && mode == MODE_SAVE_MULTIPLE_CHOICES) { loadAutoThumbButton.touchUp(screenX, screenY, pointer, button) }
if (::loadManualThumbButton.isInitialized && mode == MODE_SAVE_MULTIPLE_CHOICES) { loadManualThumbButton.touchUp(screenX, screenY, pointer, button) }
return true
}

View File

@@ -76,7 +76,7 @@ open class UIItemImageButton(
// draw image
batch.color = if (highlighted) highlightCol
else if (mouseUp) activeCol
else Toolkit.Theme.COL_INACTIVE
else if (useBorder) Toolkit.Theme.COL_INACTIVE else inactiveCol
if (useBorder) {
Toolkit.drawBoxBorder(batch, posX - 1f, posY - 1f, width + 2f, height + 2f)
batch.color = Color.WHITE