@@ -585,7 +585,7 @@ class MainActivity2 : AppCompatActivity() {
585585 }
586586 }
587587
588- private fun dialog (title : String ,
588+ internal fun dialog (title : String ,
589589 message : String? ,
590590 okListener : OnClickListener ? ,
591591 cancelListener : OnClickListener ? ,
@@ -659,14 +659,16 @@ class MainActivity2 : AppCompatActivity() {
659659 @SuppressLint(" SetTextI18n" )
660660 override fun onOptionsItemSelected (item : MenuItem ): Boolean {
661661 when (item.itemId) {
662+ R .id.newSave ->
663+ input.setText(" {\" version\" :\" 1.8.0\" ,\" roomName\" :\" New Scene\" ,\" coin\" :2000,\" room\" :3,\" gravity\" :true,\" hardcore\" :false,\" playtime\" :0.0,\" temperature\" :20.0,\" ac\" :false,\" light\" :true,\" sign\" :\"\" }\n {\" playerData\" :{\" x\" :-4.90798426,\" y\" :-2.70895219,\" z\" :-10.656539,\" ry\" :0.0,\" rx\" :0.0}, \" itemData\" :[], \" scene\" :{}}" )
662664 R .id.explorer -> {
663665 if (input.text.lines().size < 2 ) return false
664666 val jsonObject = JSONObject (input.text.lines()[1 ])
665667 val itemArray = jsonObject.getJSONArray(" itemData" )
666668 val lists = arrayListOf<String >()
667669 for (i in 0 until itemArray.length()) {
668- val item = itemArray.getJSONObject(i)
669- val spawnId = item .getString(" spawnId" )
670+ val thisitem = itemArray.getJSONObject(i)
671+ val spawnId = thisitem .getString(" spawnId" )
670672 lists.add(spawnId)
671673 }
672674 dialog(resources.getString(R .string.object_explorer), null , null , {_,_-> }, null , " Close" , lists.toTypedArray()) {_, i ->
@@ -721,26 +723,42 @@ class MainActivity2 : AppCompatActivity() {
721723 }
722724 }
723725 }
724- R .id.shortcuts -> if (Build .VERSION .SDK_INT >= 24 ) requestShowKeyboardShortcuts()
725- R .id.decrypt_after_opening -> decrypt_after_opening = decrypt_after_opening.not ()
726- R .id.encrypt_after_saving -> encrypt_after_saving = encrypt_after_saving.not ()
727- R .id.changelog -> dialog(" Changelog (version $version )" , globalVars.ChangelogText , {_,_-> }, null )
728- R .id.about -> dialog(" PC Simulator Save Editor Android Port (version $version )" , """
729- |Created by Mokka Chocolata.
730- |Free, and open source.
731- |Get beta builds at the Actions tab at the GitHub repository.
732- |Report any issues at the Issues tab at the GitHub repository.
733- |This app is licensed with GPLv3.0 or later.
734- |This project is neither associated, affiliated, nor endorsed by Intel or AMD.
735- |""" .trimMargin(), {_,_-> }, null // This way we won't get into trouble
736- )
737- R .id.help -> startActivity(Intent (applicationContext, HelpActivity ::class .java))
738- R .id.repo -> startActivity(Intent (Intent .ACTION_VIEW , Uri .parse(" https://github.com/BeboKhouja/PCSimulatorSaveEditorAndroidPort" )))
739- R .id.discord -> startActivity(Intent (Intent .ACTION_VIEW , Uri .parse(" https://discord.gg/GXRECJjhVr" )))
726+ R .id.shortcuts -> {
727+ if (Build .VERSION .SDK_INT >= 24 ) requestShowKeyboardShortcuts()
728+ }
729+ R .id.decrypt_after_opening -> {
730+ decrypt_after_opening = decrypt_after_opening.not ()
731+ }
732+ R .id.encrypt_after_saving -> {
733+ encrypt_after_saving = encrypt_after_saving.not ()
734+ }
735+ R .id.changelog -> {
736+ dialog(" Changelog (version $version )" , globalVars.ChangelogText , {_,_-> }, null )
737+ }
738+ R .id.about -> {
739+ dialog(" PC Simulator Save Editor Android Port (version $version )" , """
740+ |Created by Mokka Chocolata.
741+ |Free, and open source.
742+ |Get beta builds at the Actions tab at the GitHub repository.
743+ |Report any issues at the Issues tab at the GitHub repository.
744+ |This app is licensed with GPLv3.0 or later.
745+ |This project is neither associated, affiliated, nor endorsed by Intel or AMD.
746+ |""" .trimMargin(), {_,_-> }, null // This way we won't get into trouble
747+ )
748+ }
749+ R .id.help -> {
750+ startActivity(Intent (applicationContext, HelpActivity ::class .java))
751+ }
752+ R .id.repo -> {
753+ startActivity(Intent (Intent .ACTION_VIEW , Uri .parse(" https://github.com/BeboKhouja/PCSimulatorSaveEditorAndroidPort" )))
754+ }
755+ R .id.discord -> {
756+ startActivity(Intent (Intent .ACTION_VIEW , Uri .parse(" https://discord.gg/GXRECJjhVr" )))
757+ }
740758 R .id.clear -> {
741759 // Clear all cardboard boxes
742760 val text = input.text.toString()
743-
761+ if (input.text.lines().size < 2 ) return false
744762 val lines = text.lines()
745763 val jsonObject = JSONObject (lines[1 ])
746764 val itemArray = jsonObject.getJSONArray(" itemData" )
@@ -753,6 +771,7 @@ class MainActivity2 : AppCompatActivity() {
753771 input.setText(lines[0 ] + " \n " + jsonObject.toString())
754772 }
755773 R .id.dump -> {
774+ if (input.text.lines().size < 2 ) return false
756775 val text = input.text.toString()
757776 val jsonObject = JSONObject (text.lines()[1 ])
758777 val itemArray = jsonObject.getJSONArray(" itemData" )
@@ -776,6 +795,7 @@ class MainActivity2 : AppCompatActivity() {
776795 dialog(" Result" , pwd, {_,_-> }, null )
777796 }
778797 R .id.insert -> {
798+ if (input.text.lines().size < 2 ) return false
779799 val text = input.text.toString()
780800 val jsonObject = JSONObject (text.lines()[1 ])
781801 val lines = text.lines()
@@ -804,8 +824,8 @@ class MainActivity2 : AppCompatActivity() {
804824 fun handleClickJson (index : Int ) {
805825 fun putFile (i : Int , array : JSONArray ) {
806826 when (i) {
807- 17 -> array.put(FileObjectJson (fileList[i].path, " pcos" , true , 0 , 0 ))
808- else -> array.put(FileObjectJson (fileList[i].path, " " , false , 0 , 0 ))
827+ 17 -> array.put(FileObjectJson (fileList[i].path, " pcos" , true , 0 , 0 ).toJson() )
828+ else -> array.put(FileObjectJson (fileList[i].path, " " , false , 0 , 0 ).toJson() )
809829 }
810830 }
811831
@@ -1138,6 +1158,7 @@ class MainActivity2 : AppCompatActivity() {
11381158}
11391159
11401160
1161+
11411162class WriteOrReadThread : Runnable {
11421163 var WriteOrRead by Delegates .notNull<Boolean >()
11431164 lateinit var input : EditText
0 commit comments