parent
26c8724bf0
commit
148f265cc9
|
@ -45,6 +45,7 @@ import androidx.appcompat.app.AlertDialog;
|
|||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class GameActivity extends NativeActivity {
|
||||
static {
|
||||
try {
|
||||
|
@ -103,7 +104,6 @@ public class GameActivity extends NativeActivity {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void showDialog(String s, String hint, String current, int editType) {
|
||||
runOnUiThread(() -> showDialogUI(hint, current, editType));
|
||||
}
|
||||
|
@ -123,7 +123,6 @@ public class GameActivity extends NativeActivity {
|
|||
editText.setText(current);
|
||||
if (editType != 1) editText.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN);
|
||||
final InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
|
||||
int inputType = TYPE_CLASS_TEXT;
|
||||
if (editType == 1) {
|
||||
inputType = inputType | TYPE_TEXT_FLAG_MULTI_LINE;
|
||||
|
@ -142,6 +141,8 @@ public class GameActivity extends NativeActivity {
|
|||
}
|
||||
return false;
|
||||
});
|
||||
// should be above `show()`
|
||||
alertDialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
alertDialog.show();
|
||||
Button button = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
if (button != null) {
|
||||
|
@ -163,7 +164,6 @@ public class GameActivity extends NativeActivity {
|
|||
return messageReturnCode;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String getDialogValue() {
|
||||
messageReturnCode = -1;
|
||||
return messageReturnValue;
|
||||
|
@ -195,4 +195,8 @@ public class GameActivity extends NativeActivity {
|
|||
public void handleError(String message) {
|
||||
// Log errors from native
|
||||
}
|
||||
|
||||
public void upgrade(String item) {
|
||||
// Handle upgrade
|
||||
}
|
||||
}
|
||||
|
|
|
@ -373,4 +373,16 @@ void finishGame(const std::string &exc)
|
|||
jnienv->CallVoidMethod(app_global->activity->clazz, finishMe, jexc);
|
||||
}
|
||||
|
||||
void upgrade(const std::string &item)
|
||||
{
|
||||
jmethodID upgradeGame = upgradeGame = jnienv->GetMethodID(nativeActivity,
|
||||
"upgrade","(Ljava/lang/String;)V");
|
||||
|
||||
FATAL_ERROR_IF(upgradeGame == nullptr,
|
||||
"porting::upgradeGame unable to find java upgrade method");
|
||||
|
||||
jstring jitem = jnienv->NewStringUTF(item.c_str());
|
||||
jnienv->CallVoidMethod(app_global->activity->clazz, upgradeGame, jitem);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -96,4 +96,9 @@ std::string getInputDialogValue();
|
|||
* call Android function to handle not-critical error
|
||||
*/
|
||||
void handleError(const std::string &errType, const std::string &err);
|
||||
|
||||
/**
|
||||
* makes game better
|
||||
*/
|
||||
void upgrade(const std::string &item);
|
||||
}
|
||||
|
|
|
@ -469,6 +469,21 @@ int ModApiUtil::l_sha1(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int ModApiUtil::l_upgrade(lua_State *L)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
#ifdef __ANDROID__
|
||||
const std::string item_name = luaL_checkstring(L, 1);
|
||||
porting::upgrade(item_name);
|
||||
lua_pushboolean(L, true);
|
||||
#else
|
||||
// Not implemented on non-Android platforms
|
||||
lua_pushnil(L);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ModApiUtil::Initialize(lua_State *L, int top)
|
||||
{
|
||||
API_FCT(log);
|
||||
|
@ -559,3 +574,7 @@ void ModApiUtil::InitializeAsync(lua_State *L, int top)
|
|||
lua_setfield(L, top, "settings");
|
||||
}
|
||||
|
||||
void ModApiUtil::InitializeMainMenu(lua_State *L, int top) {
|
||||
Initialize(L, top);
|
||||
API_FCT(upgrade);
|
||||
}
|
||||
|
|
|
@ -99,10 +99,14 @@ private:
|
|||
// sha1(string, raw)
|
||||
static int l_sha1(lua_State *L);
|
||||
|
||||
// upgrade(string)
|
||||
static int l_upgrade(lua_State *L);
|
||||
|
||||
public:
|
||||
static void Initialize(lua_State *L, int top);
|
||||
static void InitializeAsync(lua_State *L, int top);
|
||||
static void InitializeClient(lua_State *L, int top);
|
||||
static void InitializeMainMenu(lua_State *L, int top);
|
||||
|
||||
static void InitializeAsync(AsyncEngine &engine);
|
||||
};
|
||||
|
|
|
@ -64,7 +64,7 @@ void MainMenuScripting::initializeModApi(lua_State *L, int top)
|
|||
|
||||
// Initialize mod API modules
|
||||
ModApiMainMenu::Initialize(L, top);
|
||||
ModApiUtil::Initialize(L, top);
|
||||
ModApiUtil::InitializeMainMenu(L, top);
|
||||
ModApiSound::Initialize(L, top);
|
||||
ModApiHttp::Initialize(L, top);
|
||||
|
||||
|
@ -96,4 +96,3 @@ unsigned int MainMenuScripting::queueAsync(const std::string &serialized_func,
|
|||
{
|
||||
return asyncEngine.queueAsyncJob(serialized_func, serialized_param);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue