Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Moondust-Project/Engine/android-project/moondust/src/main/java/ru/wohlsoft/moondust/moondustActivity.java /
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
86 lines (71 sloc)
1.92 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package ru.wohlsoft.moondust; | |
| import android.os.Bundle; | |
| import android.widget.LinearLayout; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import java.util.Locale; | |
| import org.libsdl.app.SDLActivity; | |
| enum ControllerKeys | |
| { | |
| key_BEGIN(0), | |
| key_start(0), | |
| key_left(1), | |
| key_right(2), | |
| key_up(3), | |
| key_down(4), | |
| key_run(5), | |
| key_jump(6), | |
| key_altrun(7), | |
| key_altjump(8), | |
| key_drop(9), | |
| key_END(10); | |
| private final int value; | |
| ControllerKeys(final int newValue) | |
| { | |
| value = newValue; | |
| } | |
| public int getValue() | |
| { | |
| return value; | |
| } | |
| } | |
| public class moondustActivity extends SDLActivity | |
| { | |
| protected String[] getLibraries() | |
| { | |
| return new String[] { | |
| // "SDL2", | |
| "pge_engine" | |
| }; | |
| } | |
| private String detectLanguage() | |
| { | |
| String lang = Locale.getDefault().toString(); | |
| String[] langD = lang.split("_"); | |
| if(langD.length >= 1) | |
| return langD[0]; | |
| return ""; | |
| } | |
| protected String[] getArguments() | |
| { | |
| List<String> args = new ArrayList<>(); | |
| // Detect current language of the system | |
| String lang = detectLanguage(); | |
| if(lang.length() >= 1) | |
| args.add("--lang=" + lang); | |
| String[] argsOut = new String[args.size()]; | |
| args.toArray(argsOut); | |
| return argsOut; | |
| } | |
| @Override | |
| public void onCreate(Bundle savedInstanceState) | |
| { | |
| super.onCreate(savedInstanceState); | |
| LinearLayout ll = new LinearLayout(this); | |
| ll.setBackground(getResources().getDrawable(R.mipmap.buttons)); | |
| addContentView(ll, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, | |
| LinearLayout.LayoutParams.MATCH_PARENT)); | |
| } | |
| public static native void setKeyPos(int cmd, float left, float top, float right, float bottom); | |
| public static native void setCanvasSize(float width, float height); | |
| } |