Java Code Examples for com.watabou.noosa.Game#toast()

The following examples show how to use com.watabou.noosa.Game#toast() . 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: Bestiary.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
private static Mob getMob(JSONObject depthDesc) throws JSONException {
	ArrayList<Float> chances = new ArrayList<>();
	ArrayList<String> names = new ArrayList<>();

	Iterator<?> keys = depthDesc.keys();

	while (keys.hasNext()) {
		String mobClassName = (String) keys.next();
		names.add(mobClassName);
		float chance = (float) depthDesc.getDouble(mobClassName);
		chances.add(chance);
	}

	String selectedMobClass = "Rat";

	if(!chances.isEmpty()) {
		selectedMobClass = (String) names.toArray()[Random.chances(chances.toArray(new Float[0]))];
	}	else {
		Game.toast("Bad bestiary desc: %s", depthDesc.toString());
	}
	return MobFactory.mobByName(selectedMobClass);
}
 
Example 2
Source File: ItemSpritesDescription.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
static public void readItemsDesc() {
	if (ModdingMode.isResourceExist(SPRITES_DESC_ITEMS_JSON)) {
		JSONObject itemsDesc = JsonHelper.readJsonFromAsset(SPRITES_DESC_ITEMS_JSON);

		Iterator<?> keys = itemsDesc.keys();

		while (keys.hasNext()) {
			String key = (String) keys.next();
			try {
				JSONObject itemDesc = itemsDesc.getJSONObject(key);

				m_descMap.put(key,
						new ItemSpritesDescription(itemDesc.optString("file", "items.png"),
								itemDesc.optInt("index", 0), 
								itemDesc.optBoolean("fliesStraight", false),
								itemDesc.optBoolean("fliesFastRotating", false)));
			} catch (JSONException e) {
				Game.toast("malformed desc (%s) for %s ignored", itemsDesc.toString(), key);
			}

		}
	}
}
 
Example 3
Source File: WndEuConsent.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void hide() {
    if(!consentChoosen) {
        Game.toast(Game.getVar(R.string.gdpr_choose));
    } else {
        super.hide();
    }
}
 
Example 4
Source File: ModError.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
static public void doReport(String s, Exception e) {
    String errMsg = e.getMessage();
    if(errMsg==null) {
        errMsg = "";
    }
    Game.toast("[%s -> %s]", s, errMsg);
    EventCollector.logException(e,s);
    Notifications.displayNotification(e.getClass().getSimpleName(), s, errMsg);
    GLog.toFile(s);
    GLog.toFile(errMsg);
}
 
Example 5
Source File: AboutScene.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create() {
	super.create();

	Text text = createText(getTXT(), null );
	
	text.camera = uiCamera;
	
	text.x = align( (Camera.main.width - text.width()) / 2 );
	text.y = align( (Camera.main.height - text.height()) / 3 );
	

	Text email = createTouchEmail(Game.getVar(R.string.AboutScene_Mail), text);

	Text visit = createText(Game.getVar(R.string.AboutScene_OurSite), email);
	Text site  = createTouchLink(Game.getVar(R.string.AboutScene_Lnk), visit);
	
	createText("\n"+ getTRN(), site);
	
	Image nyrdie = Icons.NYRDIE.get();
	nyrdie.x = align( text.x + (text.width() - nyrdie.width) / 2 );
	nyrdie.y = text.y - nyrdie.height - 8;
	add( nyrdie );

	TouchArea area = new TouchArea( nyrdie ) {
		private int clickCounter = 0;

		@Override
		protected void onClick( Touch touch ) {
			clickCounter++;

			if(clickCounter > 11) {
				return;
			}

			if(clickCounter>10) {
				Game.toast("Levels test mode enabled");
				Scene.setMode("levelsTest");
				return;
			}

			if(clickCounter>7) {
				Game.toast("Are you sure?");
				return;
			}

			if(clickCounter>3) {
				Game.toast("%d", clickCounter);
			}
		}
	};
	add(area);

	new Flare( 7, 64 ).color( 0x332211, true ).show( nyrdie, 0 ).angularSpeed = -20;
	
	Archs archs = new Archs();
	archs.setSize( Camera.main.width, Camera.main.height );
	addToBack( archs );
	
	ExitButton btnExit = new ExitButton();
	btnExit.setPos( Camera.main.width - btnExit.width(), 0 );
	add( btnExit );
	
	fadeIn();
}
 
Example 6
Source File: Dungeon.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
private static void saveAllImpl() {
    float MBytesAvailable = Util.getAvailableInternalMemorySize() / 1024f / 1024f;

    if (MBytesAvailable < 2) {
        EventCollector.logEvent("saveGame", "lowMemory");
        Game.toast("Low memory condition");
    }

    if (level != null && hero!= null && hero.isAlive()) {
        Level thisLevel = Dungeon.level;

        Actor.fixTime();
        try {
            SaveUtils.copySaveToSlot(SaveUtils.getPrevSave(), heroClass);

            Position current = currentPosition();

            String saveToLevel = getLevelSaveFile(current);
            String saveToGame = SaveUtils.gameFile(hero.getHeroClass());

            saveGame(saveToGame);
            saveLevel(saveToLevel, thisLevel);

            Badges.saveGlobal();
            Library.saveLibrary();

            SaveUtils.copySaveToSlot(SaveUtils.getAutoSave(), heroClass);
        } catch (IOException e) {
            throw new TrackedRuntimeException("cannot write save", e);
        }

        GamesInProgress.set(hero.getHeroClass(), depth, hero.lvl());

    } else if (WndResurrect.instance != null) {

        WndResurrect.instance.hide();
        Hero.reallyDie(WndResurrect.causeOfDeath);
    } else {
        EventCollector.logException(new Exception("spurious save"));
    }
}