Java Code Examples for com.badlogic.gdx.Application.ApplicationType#Desktop

The following examples show how to use com.badlogic.gdx.Application.ApplicationType#Desktop . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GDXDialogsSystem.java    From gdx-dialogs with Apache License 2.0 6 votes vote down vote up
private void installDesktopGDXDialogs() {
	if (Gdx.app.getType() != ApplicationType.Desktop) {
		showDebugSkipInstall(ApplicationType.Desktop.name());
		return;
	}
	try {

		final Class<?> dialogManagerClazz = ClassReflection.forName("de.tomgrill.gdxdialogs.desktop.DesktopGDXDialogs");

		Object dialogManager = ClassReflection.getConstructor(dialogManagerClazz).newInstance();

		this.gdxDialogs = (GDXDialogs) dialogManager;

		showDebugInstallSuccessful(ApplicationType.Desktop.name());

	} catch (ReflectionException e) {
		showErrorInstall(ApplicationType.Desktop.name(), "desktop");
		e.printStackTrace();
	}

}
 
Example 2
Source File: MusicManager.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
public void playMusic() {
	if (music != null && !music.isPlaying()) {

		try {
			music.play();
			music.setLooping(desc.isLoop());
			music.setVolume(desc.getVolume() * VOLUME_MULTIPLIER);
		} catch (Exception e) {

			// DEAL WITH OPENAL BUG
			if (Gdx.app.getType() == ApplicationType.Desktop && e.getMessage().contains("40963")) {
				EngineLogger.debug("!!!!!!!!!!!!!!!!!!!!!!!ERROR playing music trying again...!!!!!!!!!!!!!!!");

				MusicDesc desc2 = desc;
				desc = null;
				setMusic(desc2);

				return;
			}

			EngineLogger.error("Error Playing music: " + desc.getFilename(), e);
		}
	}
}
 
Example 3
Source File: World.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
public void saveGameState() throws IOException {
	boolean takeScreenshot = false;

	// Only take screenshot for desktop. For iOs or Android is slow.
	if (Gdx.app.getType() == ApplicationType.Desktop)
		takeScreenshot = true;

	serialization.saveGameState(GAMESTATE_FILENAME, takeScreenshot);
}
 
Example 4
Source File: UI.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
public void resume() {
	if (Gdx.app.getType() != ApplicationType.Desktop) {
		// RESTORE GL CONTEXT
		RectangleRenderer.dispose();
	}

	if (screen != null)
		screen.resume();
}
 
Example 5
Source File: Keybinds.java    From Cubes with MIT License 5 votes vote down vote up
public static SettingGroup init() {
  if (settingGroup == null) {
    Settings.addSetting(KEYBIND_FORWARD, new KeybindSetting(Keys.W));
    Settings.addSetting(KEYBIND_BACK, new KeybindSetting(Keys.S));
    Settings.addSetting(KEYBIND_LEFT, new KeybindSetting(Keys.A));
    Settings.addSetting(KEYBIND_RIGHT, new KeybindSetting(Keys.D));
    Settings.addSetting(KEYBIND_JUMP, new KeybindSetting(Keys.SPACE));
    Settings.addSetting(KEYBIND_DESCEND, new KeybindSetting(Keys.SHIFT_LEFT));
    
    Settings.addSetting(KEYBIND_THROW, new KeybindSetting(Keys.Q));
    Settings.addSetting(KEYBIND_INVENTORY, new KeybindSetting(Keys.E));
    Settings.addSetting(KEYBIND_CHAT, new KeybindSetting(Keys.F4));
    
    Settings.addSetting(KEYBIND_FULLSCREEN, new KeybindSetting(Keys.F11));
    Settings.addSetting(KEYBIND_HIDEGUI, new KeybindSetting(Keys.F1));
    Settings.addSetting(KEYBIND_SCREENSHOT, new KeybindSetting(Keys.F2));
    Settings.addSetting(KEYBIND_DEBUG, new KeybindSetting(Keys.F3));
    Settings.addSetting(KEYBIND_AREABOUNDARIES, new KeybindSetting(Keys.F7));
    
    settingGroup = new SettingGroup() {
      @Override
      public boolean shouldDisplay() {
        return Compatibility.get().getApplicationType() == ApplicationType.Desktop;
      }
    };
    settingGroup.add(KEYBIND_FORWARD).add(KEYBIND_BACK).add(KEYBIND_LEFT).add(KEYBIND_RIGHT).add(KEYBIND_JUMP).add(KEYBIND_DESCEND);
    settingGroup.add(KEYBIND_INVENTORY).add(KEYBIND_CHAT);
    settingGroup.add(KEYBIND_FULLSCREEN).add(KEYBIND_HIDEGUI).add(KEYBIND_SCREENSHOT).add(KEYBIND_DEBUG).add(KEYBIND_AREABOUNDARIES);
  }
  return settingGroup;
}
 
Example 6
Source File: SeventhGame.java    From seventh with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Hide the Mouse cursor
 * 
 * @param visible
 */
private void setHWCursorVisible(boolean visible) {
    if (Gdx.app.getType() != ApplicationType.Desktop && Gdx.app instanceof LwjglApplication) {
        return;
    }

    try {
        /* make sure the mouse doesn't move off the screen */
        seventh.client.gfx.Cursor cursor = this.uiManager.getCursor();
        cursor.setClampEnabled(config.getVideo().isFullscreen());
        Gdx.input.setCursorCatched(config.getVideo().isFullscreen());
        
        //Gdx.input.setCursorCatched(true);
        //Gdx.input.setCursorPosition(getScreenWidth()/2, getScreenHeight()/2);
        
        Cursor emptyCursor = null;
        if (Mouse.isCreated()) {
            int min = org.lwjgl.input.Cursor.getMinCursorSize();
            IntBuffer tmp = BufferUtils.createIntBuffer(min * min);
            emptyCursor = new org.lwjgl.input.Cursor(min, min, min / 2, min / 2, 1, tmp, null);
        } else {
            Cons.println("Could not create empty cursor before Mouse object is created");
        }
    
        if (/*Mouse.isInsideWindow() &&*/ emptyCursor != null) {
            Mouse.setNativeCursor(visible ? null : emptyCursor);
        }
    }
    catch(LWJGLException e) {
        Cons.println("*** Unable to hide cursor: " + e);
    }
}
 
Example 7
Source File: BulletSteeringTest.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
public static void init () {
	if (initialized) return;
	// Need to initialize bullet before using it.
	if (Gdx.app.getType() == ApplicationType.Desktop && customDesktopLib != null) {
		System.load(customDesktopLib);
	} else
		Bullet.init();
	Gdx.app.log("Bullet", "Version = " + LinearMath.btGetVersion());
	initialized = true;
}
 
Example 8
Source File: URacer.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
@Override
public void create () {
	Gdx.app.setLogLevel(Application.LOG_DEBUG);
	isDesktop = (Gdx.app.getType() == ApplicationType.Desktop);

	System.out.println();
	Gdx.app.log("URacer", "Booting version " + URacer.versionInfo);
	Gdx.app.log("URacer", "GL vendor is " + Gdx.gl.glGetString(GL20.GL_VENDOR));
	Gdx.app.log("URacer", "GL version is " + Gdx.gl.glGetString(GL20.GL_VERSION));
	Gdx.app.log("URacer", "Java vendor is " + System.getProperty("java.vendor"));
	Gdx.app.log("URacer", "Java version is " + System.getProperty("java.version"));
	Gdx.app.log("URacer", "Using real frametime: " + (useRealFrametime ? "YES" : "NO"));
	Gdx.app.log("URacer", "Physics at " + timeStepHz + "Hz (dT=" + String.format("%.05f", Config.Physics.Dt) + ")");

	Storage.init();
	boot.store();
	UserPreferences.load();
	ScreensShared.loadFromUserPrefs();

	ScaleUtils.init(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

	// create input system
	input = new Input(ScaleUtils.PlayViewport, 350, 50);
	Gdx.app.log("URacer", "Input system created.");

	Art.init();
	Sounds.init();
	TransitionFactory.init(screenFactory);
	SpriteBatchUtils.init(Art.debugFont, Art.DebugFontWidth);
	screenMgr = new ScreenManager(ScaleUtils.PlayViewport, screenFactory);

	// enumerate available game tracks
	try {
		GameLevels.init();
	} catch (URacerRuntimeException e) {
		Gdx.app.error("URacer", e.getMessage());
		System.exit(-1);
	}

	Game.show(ScreenType.MainScreen);
	// Game.show(ScreenType.GameScreen);
	// Screens.setScreen(ScreenType.OptionsScreen, TransitionType.CrossFader, 500);
}
 
Example 9
Source File: EngineAssetManager.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
public FileHandle getUserFolder() {
	FileHandle file = null;

	if (Gdx.app.getType() == ApplicationType.Desktop && desktopUserFolder != null) {

		StringBuilder sb = new StringBuilder();

		if (System.getProperty("os.name").toLowerCase().contains("mac")
				&& System.getenv("HOME").contains("Containers")) {

			file = Gdx.files.absolute(System.getenv("HOME") + "/" + sb.append(desktopUserFolder).toString());
		} else {

			file = Gdx.files.external(sb.append(desktopUserFolder).toString());
		}

	} else {
		file = Gdx.files.local(NOT_DESKTOP_PREFS_DIR);
	}

	return file;
}