本文整理汇总了Java中com.watabou.pixeldungeon.Preferences类的典型用法代码示例。如果您正苦于以下问题:Java Preferences类的具体用法?Java Preferences怎么用?Java Preferences使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Preferences类属于com.watabou.pixeldungeon包,在下文中一共展示了Preferences类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resetKeyMappings
import com.watabou.pixeldungeon.Preferences; //导入依赖的package包/类
@Override
public void resetKeyMappings() {
keyMappings.clear();
for (GameAction action : GameAction.values()) {
KeyPair pair = DEFAULTS.get( action );
if (pair != null) {
setKeyMapping( action, pair.code1, pair.code2 );
} else {
pair = new KeyPair();
}
Preferences.INSTANCE.put( getPrefKey( action, true ), pair.code1 );
Preferences.INSTANCE.put( getPrefKey( action, false ), pair.code2 );
}
}
示例2: init
import com.watabou.pixeldungeon.Preferences; //导入依赖的package包/类
@Override
public void init() {
super.init();
// Load the default mappings...
// ...ONLY IF IT'S THE FIRST RUN!
if (Preferences.INSTANCE.getInt( getPrefKey( GameAction.BACK, true ), 0 ) == 0) {
resetKeyMappings();
}
for (GameAction action : GameAction.values()) {
loadKeyMapping( action );
}
}
示例3: loadKeyMapping
import com.watabou.pixeldungeon.Preferences; //导入依赖的package包/类
private void loadKeyMapping( GameAction action ) {
/*
* Right now we store key mapping preferences on the default game preferences file/registry/whatever. It will probably
* be a good idea to have a separate one for this
*/
int mapping1 = Preferences.INSTANCE.getInt( getPrefKey( action, true ), -1 );
if (mapping1 > 0) {
keyMappings.put( mapping1, new GameActionWrapper( action, true ) );
}
int mapping2 = Preferences.INSTANCE.getInt( getPrefKey( action, false ), -1 );
if (mapping2 > 0) {
keyMappings.put( mapping2, new GameActionWrapper( action, false ) );
}
}
示例4: setKeyMapping
import com.watabou.pixeldungeon.Preferences; //导入依赖的package包/类
@Override
public GameActionWrapper setKeyMapping( GameAction action, boolean defaultKey, int code ) {
final GameActionWrapper existingMapping = keyMappings.get(code);
keyMappings.put(code, new GameActionWrapper(action, defaultKey));
Preferences.INSTANCE.put( getPrefKey( action, defaultKey ), code);
if (existingMapping != null && (existingMapping.gameAction != action || existingMapping.defaultKey != defaultKey)) {
// If some other action was mapped to this key, then we have
// to remove a record about it from the preferences
Preferences.INSTANCE.put( getPrefKey( existingMapping.gameAction, existingMapping.defaultKey ), -1);
return existingMapping;
} else {
return null;
}
}
示例5: main
import com.watabou.pixeldungeon.Preferences; //导入依赖的package包/类
public static void main (String[] arg) {
String version = DesktopLauncher.class.getPackage().getSpecificationVersion();
if (version == null) {
version = "1.0";
}
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
if (SharedLibraryLoader.isMac) {
config.preferencesDirectory = "Library/Application Support/Pixel Dungeon/";
} else if (SharedLibraryLoader.isLinux) {
config.preferencesDirectory = ".watabou/pixel-dungeon/";
} else if (SharedLibraryLoader.isWindows) {
config.preferencesDirectory = "Saved Games/Pixel Dungeon/";
}
// FIXME: This is a hack to get access to the preferences before we have an application setup
com.badlogic.gdx.Preferences prefs = new LwjglPreferences(Preferences.FILE_NAME, config.preferencesDirectory);
boolean isFullscreen = prefs.getBoolean(Preferences.KEY_WINDOW_FULLSCREEN, false);
config.fullscreen = isFullscreen;
if (!isFullscreen) {
config.width = prefs.getInteger(Preferences.KEY_WINDOW_WIDTH, Preferences.DEFAULT_WINDOW_WIDTH);
config.height = prefs.getInteger(Preferences.KEY_WINDOW_HEIGHT, Preferences.DEFAULT_WINDOW_HEIGHT);
}
config.addIcon( "ic_launcher_128.png", Files.FileType.Internal );
config.addIcon( "ic_launcher_32.png", Files.FileType.Internal );
config.addIcon( "ic_launcher_16.png", Files.FileType.Internal );
// TODO: It have to be pulled from build.gradle, but I don't know how it can be done
config.title = "Pixel Dungeon";
new LwjglApplication(new PixelDungeon(
new DesktopSupport(version, config.preferencesDirectory, new DesktopInputProcessor())
), config);
}
示例6: main
import com.watabou.pixeldungeon.Preferences; //导入依赖的package包/类
public static void main (String[] arg) {
String version = DesktopLauncher.class.getPackage().getSpecificationVersion();
if (version == null) {
version = "???";
}
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
if (SharedLibraryLoader.isMac) {
config.preferencesDirectory = "Library/Application Support/BravePixel/Pixel Dungeon/";
} else if (SharedLibraryLoader.isLinux) {
config.preferencesDirectory = ".bravepixel/pixel-dungeon/";
} else if (SharedLibraryLoader.isWindows) {
config.preferencesDirectory = "Saved Games/BravePixel/PixelDungeon";
}
// FIXME: This is a hack to get access to the preferences before we have an application setup
com.badlogic.gdx.Preferences prefs = new LwjglPreferences(Preferences.FILE_NAME, config.preferencesDirectory);
boolean isFullscreen = prefs.getBoolean(Preferences.KEY_WINDOW_FULLSCREEN, false);
config.fullscreen = isFullscreen;
if (!isFullscreen) {
config.width = prefs.getInteger(Preferences.KEY_WINDOW_WIDTH, Preferences.DEFAULT_WINDOW_WIDTH);
config.height = prefs.getInteger(Preferences.KEY_WINDOW_HEIGHT, Preferences.DEFAULT_WINDOW_HEIGHT);
}
config.addIcon( "ic_launcher_128.png", Files.FileType.Internal );
config.addIcon( "ic_launcher_32.png", Files.FileType.Internal );
config.addIcon( "ic_launcher_16.png", Files.FileType.Internal );
// TODO: It have to be pulled from build.gradle, but I don't know how it can be done
config.title = "Pixel Dungeon";
new LwjglApplication(new PixelDungeon(
new DesktopSupport(version, config.preferencesDirectory, new DesktopInputProcessor())
), config);
}
示例7: onOrientationChanged
import com.watabou.pixeldungeon.Preferences; //导入依赖的package包/类
@Override
public void onOrientationChanged(boolean isLandscape) {
final Preferences prefs = Preferences.INSTANCE;
int width = prefs.getInt(Preferences.KEY_WINDOW_WIDTH, Preferences.DEFAULT_WINDOW_WIDTH);
int height = prefs.getInt(Preferences.KEY_WINDOW_HEIGHT, Preferences.DEFAULT_WINDOW_HEIGHT);
if(isLandscape){
Gdx.graphics.setDisplayMode(height, width, false);
} else {
Gdx.graphics.setDisplayMode(width, height, false);
}
}
示例8: connect
import com.watabou.pixeldungeon.Preferences; //导入依赖的package包/类
public void connect() {
Preferences.INSTANCE.put(Preferences.KEY_USE_PLAY_GAMES, true);
if (!isConnected()) {
Log.i("Play Games", "connect");
googleApiClient.connect();
}
}
示例9: disconnect
import com.watabou.pixeldungeon.Preferences; //导入依赖的package包/类
public void disconnect() {
Preferences.INSTANCE.put(Preferences.KEY_USE_PLAY_GAMES, false);
if (isConnected()) {
Log.i("Play Games", "disconnect");
Games.signOut(googleApiClient);
googleApiClient.disconnect();
}
}
示例10: ownIt
import com.watabou.pixeldungeon.Preferences; //导入依赖的package包/类
public void ownIt(boolean reallyOwn) {
if(reallyOwn) {
Preferences.INSTANCE.put(prefProperty(), getClass().getSimpleName());
} else {
Preferences.INSTANCE.put(prefProperty(), "");
}
}
示例11: equip
import com.watabou.pixeldungeon.Preferences; //导入依赖的package包/类
public void equip (){
if(!haveIt()) {
return;
}
Preferences.INSTANCE.put(Accessory.class.getSimpleName(), getClass().getSimpleName());
}
示例12: equipped
import com.watabou.pixeldungeon.Preferences; //导入依赖的package包/类
static public Accessory equipped() {
String itemName = Preferences.INSTANCE.getString(Accessory.class.getSimpleName(),"");
if(!itemName.equals("")) {
return getByName(itemName);
}
return null;
}
示例13: viewportSizeChanged
import com.watabou.pixeldungeon.Preferences; //导入依赖的package包/类
private static void viewportSizeChanged() {
float minWidth, minHeight;
if (PixelDungeon.landscape()) {
minWidth = MIN_WIDTH_L;
minHeight = MIN_HEIGHT_L;
} else {
minWidth = MIN_WIDTH_P;
minHeight = MIN_HEIGHT_P;
}
defaultZoom = 20;
while ((Game.width() / defaultZoom < minWidth || Game.height()
/ defaultZoom < minHeight)
&& defaultZoom > 1) {
defaultZoom-=0.01;
}
WndHelper.update(Game.width() / defaultZoom, Game.height() / defaultZoom);
minZoom = 1;
maxZoom = defaultZoom * 2;
Camera.reset(new PixelCamera(defaultZoom));
float uiZoom = (float) Preferences.INSTANCE.getDouble(Preferences.KEY_UI_ZOOM, defaultZoom);
uiCamera = Camera.createFullscreen(uiZoom);
Camera.add(uiCamera);
}
示例14: removeKeyMapping
import com.watabou.pixeldungeon.Preferences; //导入依赖的package包/类
@Override
public GameActionWrapper removeKeyMapping(GameAction action, boolean defaultKey, int code) {
final GameActionWrapper result = keyMappings.remove(code);
Preferences.INSTANCE.put( getPrefKey( action, defaultKey ), -1);
return result;
}
示例15: putToPrefs
import com.watabou.pixeldungeon.Preferences; //导入依赖的package包/类
private static void putToPrefs( GameAction action, boolean defaultKey, boolean code ) {
Preferences.INSTANCE.put( getPrefKey( action, defaultKey ), code );
}