mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-30 14:39:10 +07:00
New mobile text dialog / Cleanup / Minimap fix / Collision optimization
This commit is contained in:
@ -10,7 +10,6 @@ import io.anuke.mindustry.core.Platform;
|
||||
import io.anuke.mindustry.game.Saves.SaveSlot;
|
||||
import io.anuke.mindustry.io.SaveIO;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.scene.ui.TextField;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
@ -40,16 +39,6 @@ public class IOSLauncher extends IOSApplication.Delegate {
|
||||
|
||||
Platform.instance = new Platform() {
|
||||
|
||||
@Override
|
||||
public void addDialog(TextField field) {
|
||||
TextFieldDialogListener.add(field, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDialog(TextField field, int maxLength) {
|
||||
TextFieldDialogListener.add(field, maxLength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shareFile(FileHandle file){
|
||||
FileHandle to = Gdx.files.absolute(getDocumentsDirectory()).child(file.name());
|
||||
|
@ -1,105 +0,0 @@
|
||||
package io.anuke.mindustry;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import io.anuke.ucore.scene.event.ClickListener;
|
||||
import io.anuke.ucore.scene.event.InputEvent;
|
||||
import io.anuke.ucore.scene.event.InputListener;
|
||||
import io.anuke.ucore.scene.ui.TextField;
|
||||
import org.robovm.apple.foundation.NSRange;
|
||||
import org.robovm.apple.uikit.*;
|
||||
import org.robovm.rt.bro.annotation.ByVal;
|
||||
|
||||
public class TextFieldDialogListener {
|
||||
|
||||
public static void add(TextField field, int maxLength){
|
||||
field.addListener(new ClickListener(){
|
||||
public void clicked(final InputEvent event, float x, float y){
|
||||
show(field, maxLength);
|
||||
event.cancel();
|
||||
}
|
||||
});
|
||||
field.addListener(new InputListener(){
|
||||
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
||||
Gdx.input.setOnscreenKeyboardVisible(false);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static void show(TextField field, int maxLength){
|
||||
|
||||
UIAlertViewDelegateAdapter delegate = new UIAlertViewDelegateAdapter() {
|
||||
|
||||
@Override
|
||||
public void didDismiss(UIAlertView alertView, long buttonIndex) {
|
||||
if (buttonIndex == 1) {
|
||||
UITextField textField = alertView.getTextField(0);
|
||||
final String result = textField.getText();
|
||||
|
||||
Gdx.app.postRunnable(() -> {
|
||||
field.setText(result);
|
||||
field.change();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clicked(UIAlertView alertView, long buttonIndex) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(UIAlertView alertView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void willPresent(UIAlertView alertView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didPresent(UIAlertView alertView) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void willDismiss(UIAlertView alertView, long buttonIndex) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldEnableFirstOtherButton(UIAlertView alertView) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
String[] otherButtons = new String[1];
|
||||
otherButtons[0] = "OK";
|
||||
|
||||
UIAlertView alertView = new UIAlertView("", "", delegate, "Cancel", otherButtons);
|
||||
|
||||
alertView.setAlertViewStyle(UIAlertViewStyle.PlainTextInput);
|
||||
|
||||
UITextField uiTextField = alertView.getTextField(0);
|
||||
uiTextField.setText(field.getText());
|
||||
|
||||
uiTextField.setDelegate(new UITextFieldDelegateAdapter() {
|
||||
@Override
|
||||
public boolean shouldChangeCharacters(UITextField textField, @ByVal NSRange nsRange, String additionalText) {
|
||||
|
||||
if (textField.getText().length() + additionalText.length() > maxLength) {
|
||||
String oldText = textField.getText();
|
||||
String newText = oldText + additionalText;
|
||||
textField.setText(newText.substring(0, maxLength));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
alertView.show();
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user