diff options
| author | ilotterytea <iltsu@alright.party> | 2024-10-26 00:52:53 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-10-26 00:52:53 +0500 |
| commit | 4c205aaaf26b65ed6f5ada09b894345f131d5be7 (patch) | |
| tree | 0feeb0aa6cd7057f1ce4ec344a9d86c9bf67cee0 /core | |
| parent | d1ee70ccb99cc23cbd3d20bb5daf70cd9aa54205 (diff) | |
upd: code cleanup
Diffstat (limited to 'core')
25 files changed, 43 insertions, 247 deletions
diff --git a/core/src/kz/ilotterytea/javaextra/tuples/Triple.java b/core/src/kz/ilotterytea/javaextra/tuples/Triple.java index 7309120..0fd7fbf 100644 --- a/core/src/kz/ilotterytea/javaextra/tuples/Triple.java +++ b/core/src/kz/ilotterytea/javaextra/tuples/Triple.java @@ -1,9 +1,9 @@ package kz.ilotterytea.javaextra.tuples; public class Triple<A, B, C> { - private A first; - private B second; - private C third; + private final A first; + private final B second; + private final C third; public Triple(A first, B second, C third) { this.first = first; @@ -15,23 +15,12 @@ public class Triple<A, B, C> { return first; } - public void setFirst(A first) { - this.first = first; - } - public B getSecond() { return second; } - public void setSecond(B second) { - this.second = second; - } - public C getThird() { return third; } - public void setThird(C third) { - this.third = third; - } } diff --git a/core/src/kz/ilotterytea/maxon/MaxonConstants.java b/core/src/kz/ilotterytea/maxon/MaxonConstants.java index dca8771..7583aba 100644 --- a/core/src/kz/ilotterytea/maxon/MaxonConstants.java +++ b/core/src/kz/ilotterytea/maxon/MaxonConstants.java @@ -8,7 +8,6 @@ import com.badlogic.gdx.graphics.Texture; import kz.ilotterytea.maxon.utils.OsUtils; import java.text.DecimalFormat; -import java.text.SimpleDateFormat; public class MaxonConstants { public static final String GAME_NAME = "Maxon Petting Simulator"; @@ -36,9 +35,6 @@ public class MaxonConstants { public static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("###,###.#"); public static final DecimalFormat DECIMAL_FORMAT2 = new DecimalFormat("###,###"); - @SuppressWarnings("SimpleDateFormat") - public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd/M/yyyy hh:mm:ss"); - public static final long startTime = System.currentTimeMillis(); public static final String GAME_VERSIONS_FILE_URL = "https://assets.ilotterytea.kz/maxon/versions.json"; diff --git a/core/src/kz/ilotterytea/maxon/MaxonGame.java b/core/src/kz/ilotterytea/maxon/MaxonGame.java index 675d7d6..63de3e8 100644 --- a/core/src/kz/ilotterytea/maxon/MaxonGame.java +++ b/core/src/kz/ilotterytea/maxon/MaxonGame.java @@ -5,7 +5,6 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Preferences; import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import kz.ilotterytea.maxon.localization.LocalizationManager; import kz.ilotterytea.maxon.pets.PetManager; import kz.ilotterytea.maxon.screens.SplashScreen; @@ -13,7 +12,6 @@ import kz.ilotterytea.maxon.utils.GameUpdater; public class MaxonGame extends Game { public SpriteBatch batch; - public ShapeRenderer shapeRenderer; public AssetManager assetManager; public Preferences prefs; @@ -53,7 +51,6 @@ public class MaxonGame extends Game { new GameUpdater().checkLatestUpdate(); batch = new SpriteBatch(); - shapeRenderer = new ShapeRenderer(); prefs = Gdx.app.getPreferences(MaxonConstants.GAME_APP_PACKAGE); locale = new LocalizationManager(Gdx.files.internal("i18n/" + prefs.getString("lang", "en_us") + ".json")); @@ -92,11 +89,6 @@ public class MaxonGame extends Game { } @Override - public void render () { - super.render(); - } - - @Override public void dispose () { batch.dispose(); for (String name : assetManager.getAssetNames()) { diff --git a/core/src/kz/ilotterytea/maxon/anim/SpriteUtils.java b/core/src/kz/ilotterytea/maxon/anim/SpriteUtils.java index d7ca027..9421f79 100644 --- a/core/src/kz/ilotterytea/maxon/anim/SpriteUtils.java +++ b/core/src/kz/ilotterytea/maxon/anim/SpriteUtils.java @@ -9,16 +9,12 @@ public class SpriteUtils { public static ArrayList<TextureRegion> splitToTextureRegions( Texture texture, int tileWidth, - int tileHeight, - int columns, - int rows + int tileHeight ) { TextureRegion[][] tmp = TextureRegion.split(texture, tileWidth, tileHeight); ArrayList<TextureRegion> frames = new ArrayList<>(); - int index = 0; - for (TextureRegion[] regArray : tmp) { for (TextureRegion reg : regArray) { if (reg != null) { diff --git a/core/src/kz/ilotterytea/maxon/assets/AssetUtils.java b/core/src/kz/ilotterytea/maxon/assets/AssetUtils.java index 8b3f6f0..4492a5f 100644 --- a/core/src/kz/ilotterytea/maxon/assets/AssetUtils.java +++ b/core/src/kz/ilotterytea/maxon/assets/AssetUtils.java @@ -14,9 +14,6 @@ import kz.ilotterytea.maxon.assets.loaders.TextLoader; import net.mgsx.gltf.loaders.glb.GLBAssetLoader; import net.mgsx.gltf.scene3d.scene.SceneAsset; -import java.util.List; -import java.util.stream.Collectors; - public class AssetUtils { public static void setup(AssetManager assetManager) { assetManager.setLoader(SceneAsset.class, ".glb", new GLBAssetLoader()); diff --git a/core/src/kz/ilotterytea/maxon/assets/loaders/Text.java b/core/src/kz/ilotterytea/maxon/assets/loaders/Text.java index 6ce483e..2bac2ce 100644 --- a/core/src/kz/ilotterytea/maxon/assets/loaders/Text.java +++ b/core/src/kz/ilotterytea/maxon/assets/loaders/Text.java @@ -3,37 +3,14 @@ package kz.ilotterytea.maxon.assets.loaders; import com.badlogic.gdx.files.FileHandle; public class Text { - private String string; - - public Text() { - this.string = new String("".getBytes()); - } - - public Text(byte[] data) { - this.string = new String(data); - } - - public Text(String string) { - this.string = new String(string.getBytes()); - } + private final String string; public Text(FileHandle file) { this.string = new String(file.readBytes()); } - public Text(Text text) { - this.string = new String(text.getString().getBytes()); - } - - public void setString(String string) { - this.string = string; - } - public String getString() { return this.string; } - public void clear() { - this.string = new String("".getBytes()); - } }
\ No newline at end of file diff --git a/core/src/kz/ilotterytea/maxon/audio/Playlist.kt b/core/src/kz/ilotterytea/maxon/audio/Playlist.kt index c1c56cf..10363a5 100644 --- a/core/src/kz/ilotterytea/maxon/audio/Playlist.kt +++ b/core/src/kz/ilotterytea/maxon/audio/Playlist.kt @@ -9,7 +9,7 @@ import kz.ilotterytea.maxon.utils.math.Math class Playlist(vararg musics: Music) { private val playlist: Array<out Music> = musics var playingNow: Music = playlist[0] - private var index = 0; + private var index = 0 var shuffleMode = false diff --git a/core/src/kz/ilotterytea/maxon/localization/LocalizationManager.java b/core/src/kz/ilotterytea/maxon/localization/LocalizationManager.java index afa2841..6a28d55 100644 --- a/core/src/kz/ilotterytea/maxon/localization/LocalizationManager.java +++ b/core/src/kz/ilotterytea/maxon/localization/LocalizationManager.java @@ -63,8 +63,4 @@ public class LocalizationManager { public FileHandle getHandle() { return handle; } - - public Map<LineId, String> getLines() { - return lines; - } } diff --git a/core/src/kz/ilotterytea/maxon/pets/Pet.java b/core/src/kz/ilotterytea/maxon/pets/Pet.java index 0106439..7428cf3 100644 --- a/core/src/kz/ilotterytea/maxon/pets/Pet.java +++ b/core/src/kz/ilotterytea/maxon/pets/Pet.java @@ -41,9 +41,7 @@ public class Pet { regions = SpriteUtils.splitToTextureRegions( texture, texture.getWidth() / iconColumns, - texture.getHeight() / iconRows, - iconColumns, - iconRows + texture.getHeight() / iconRows ); } catch (GdxRuntimeException e) { diff --git a/core/src/kz/ilotterytea/maxon/pets/PetManager.java b/core/src/kz/ilotterytea/maxon/pets/PetManager.java index 650e8c5..bcb354e 100644 --- a/core/src/kz/ilotterytea/maxon/pets/PetManager.java +++ b/core/src/kz/ilotterytea/maxon/pets/PetManager.java @@ -8,7 +8,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.*; -import java.util.stream.Collectors; public class PetManager { private final ArrayList<Pet> pets; diff --git a/core/src/kz/ilotterytea/maxon/pets/PetWidget.java b/core/src/kz/ilotterytea/maxon/pets/PetWidget.java index 96b069a..70a0e94 100644 --- a/core/src/kz/ilotterytea/maxon/pets/PetWidget.java +++ b/core/src/kz/ilotterytea/maxon/pets/PetWidget.java @@ -18,7 +18,7 @@ public class PetWidget extends Table { private double price; private final Skin skin; private final Label priceLabel, nameLabel; - private TextTooltip priceTooltip, nameTooltip; + private TextTooltip priceTooltip; private final Pet pet; private boolean isDisabled = false, isLocked = false; @@ -55,7 +55,7 @@ public class PetWidget extends Table { this.nameLabel = new Label(pet.getName(), skin, storeItemStyle); nameLabel.setAlignment(Align.left); - this.nameTooltip = new TextTooltip(pet.getDescription(), skin); + TextTooltip nameTooltip = new TextTooltip(pet.getDescription(), skin); nameTooltip.setInstant(true); nameLabel.addListener(nameTooltip); diff --git a/core/src/kz/ilotterytea/maxon/player/Savegame.java b/core/src/kz/ilotterytea/maxon/player/Savegame.java index 6dc6458..3a8ac3f 100644 --- a/core/src/kz/ilotterytea/maxon/player/Savegame.java +++ b/core/src/kz/ilotterytea/maxon/player/Savegame.java @@ -124,10 +124,6 @@ public class Savegame implements Serializable { return multiplier; } - public void setMultiplier(double multiplier) { - this.multiplier = multiplier; - } - public void increaseMultiplier(double multiplier) { this.multiplier += multiplier; } @@ -158,10 +154,6 @@ public class Savegame implements Serializable { return name; } - public void setName(String name) { - this.name = name; - } - public long getElapsedTime() { return elapsedTime; } diff --git a/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java b/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java index de84cd7..11bd67f 100644 --- a/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java +++ b/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java @@ -14,7 +14,6 @@ import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.actions.Actions; import com.badlogic.gdx.scenes.scene2d.actions.RepeatAction; import com.badlogic.gdx.scenes.scene2d.ui.*; -import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Timer; @@ -39,10 +38,10 @@ import net.mgsx.gltf.scene3d.utils.IBLBuilder; import java.util.ArrayList; public class MenuScreen implements Screen { - private final MaxonGame game; + private MaxonGame game; - private final Stage stage; - private final Music menuMusic; + private Stage stage; + private Music menuMusic; private final Savegame savegame = Savegame.getInstance(); @@ -52,7 +51,7 @@ public class MenuScreen implements Screen { private final ArrayList<Timer.Task> tasks = new ArrayList<>(); private Sound clickSound; - public MenuScreen() { + @Override public void show() { this.game = MaxonGame.getInstance(); game.getDiscordActivityClient().runThread(); @@ -63,9 +62,6 @@ public class MenuScreen implements Screen { Skin uiSkin = game.assetManager.get("sprites/gui/ui.skin", Skin.class); Skin widgetSkin = game.assetManager.get("sprites/gui/widgets.skin", Skin.class); TextureAtlas brandAtlas = game.assetManager.get("sprites/gui/brand.atlas", TextureAtlas.class); - TextureAtlas widgetAtlas = game.assetManager.get("sprites/gui/widgets.atlas", TextureAtlas.class); - - Skin friendsSkin = game.assetManager.get("sprites/gui/friends.skin", Skin.class); // Main Menu music: this.menuMusic = game.assetManager.get("mus/menu/mus_menu_loop.mp3", Music.class); @@ -333,13 +329,8 @@ public class MenuScreen implements Screen { create3D(); Gdx.input.setInputProcessor(stage); - } - @Override public void show() { if (game.prefs.getBoolean("music", true)) menuMusic.play(); - - // Start to render: - render(Gdx.graphics.getDeltaTime()); } @Override diff --git a/core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.kt b/core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.kt index bd164c3..4f489ac 100644 --- a/core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.kt +++ b/core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.kt @@ -1,3 +1,7 @@ +@file:Suppress("unused", "unused", "unused", "unused", "unused", "unused", "unused", "unused", "unused", "unused", + "unused", "unused", "unused", "unused", "unused", "unused", "unused", "unused" +) + package kz.ilotterytea.maxon.screens import com.badlogic.gdx.Gdx @@ -40,6 +44,9 @@ private enum class Slot(val multiplier: Int) { private class SlotImage(slot: Slot, assetManager: AssetManager) : Image(assetManager.get("sprites/minigames/slots/${slot.name.lowercase()}.png", Texture::class.java)) +@Suppress("unused", "unused", "unused", "unused", "unused", "unused", "unused", "unused", "unused", "unused", "unused", + "unused", "unused", "unused", "unused", "unused", "unused", "unused" +) class SlotsMinigameScreen : Screen { private val savegame = Savegame.getInstance() @@ -60,7 +67,6 @@ class SlotsMinigameScreen : Screen { private var loseStreak = 0 private var maxLoseStreak = Random.nextInt(20, 50) - private var finished = false private var disabled = false private var lockedColumns = -1 private val columnSlots = arrayListOf<Slot>() @@ -250,7 +256,6 @@ class SlotsMinigameScreen : Screen { private fun finish() { if (audioLoop.isPlaying) audioLoop.stop() - finished = true stakeField?.isDisabled = false exitButton?.isDisabled = false spinButton?.isDisabled = false @@ -277,7 +282,6 @@ class SlotsMinigameScreen : Screen { stakeField?.isDisabled = true loseSlot = Slot.values()[Random.nextInt(0,3)] - finished = false lockedColumns = -1 loseStreak = 0 prize = 0.0 diff --git a/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java b/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java index 5cf0a5a..be6f840 100644 --- a/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java +++ b/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java @@ -9,18 +9,12 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g3d.decals.CameraGroupStrategy; import com.badlogic.gdx.graphics.g3d.decals.Decal; import com.badlogic.gdx.graphics.g3d.decals.DecalBatch; -import com.badlogic.gdx.math.Interpolation; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector3; -import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.Stage; -import com.badlogic.gdx.scenes.scene2d.actions.Actions; import com.badlogic.gdx.scenes.scene2d.ui.*; -import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; -import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Timer; import com.badlogic.gdx.utils.viewport.ScreenViewport; -import kz.ilotterytea.maxon.MaxonConstants; import kz.ilotterytea.maxon.MaxonGame; import kz.ilotterytea.maxon.anim.SpriteUtils; import kz.ilotterytea.maxon.audio.Playlist; @@ -28,16 +22,12 @@ import kz.ilotterytea.maxon.inputprocessors.CrossProcessor; import kz.ilotterytea.maxon.pets.Pet; import kz.ilotterytea.maxon.pets.PetManager; import kz.ilotterytea.maxon.player.DecalPlayer; -import kz.ilotterytea.maxon.player.MaxonItem; -import kz.ilotterytea.maxon.player.MaxonItemRegister; import kz.ilotterytea.maxon.player.Savegame; import kz.ilotterytea.maxon.screens.MenuScreen; import kz.ilotterytea.maxon.screens.game.shop.ShopUI; import kz.ilotterytea.maxon.ui.*; import kz.ilotterytea.maxon.ui.game.QuickActionsTable; import kz.ilotterytea.maxon.utils.OsUtils; -import kz.ilotterytea.maxon.utils.math.Math; -import com.rafaskoberg.gdx.typinglabel.TypingLabel; import net.mgsx.gltf.scene3d.attributes.PBRCubemapAttribute; import net.mgsx.gltf.scene3d.attributes.PBRTextureAttribute; import net.mgsx.gltf.scene3d.lights.DirectionalShadowLight; @@ -50,33 +40,17 @@ import net.mgsx.gltf.scene3d.utils.EnvironmentUtil; import net.mgsx.gltf.scene3d.utils.IBLBuilder; import java.util.ArrayList; -import java.util.Map; public class GameScreen implements Screen, InputProcessor { - final MaxonGame game; - final long playTimestamp; - boolean isShopping = false, isInventoryEnabled = false; - - private Savegame savegame = Savegame.getInstance(); + private MaxonGame game; + private long playTimestamp; private final Savegame savegame = Savegame.getInstance(); private Stage stage; private Skin uiSkin; - Label pointsLabel, multiplierLabel; - AnimatedImage cat; - AnimatedImageButton maxon; - - Table boardTable, quickTable; - - Dialog notEnoughPointsDialog; - - ArrayList<MaxonItem> items; - Map<Integer, Integer> invItems; - - MovingChessBackground bg; - Playlist playlist; + private Playlist playlist; private ShopUI shopUI; @@ -93,7 +67,8 @@ public class GameScreen implements Screen, InputProcessor { private final ArrayList<Timer.Task> tasks = new ArrayList<>(); - public GameScreen() { + @Override + public void show() { this.game = MaxonGame.getInstance(); this.playTimestamp = System.currentTimeMillis(); if (savegame.isNewlyCreated()) savegame.setNewlyCreated(false); @@ -103,7 +78,7 @@ public class GameScreen implements Screen, InputProcessor { decalBatch = new DecalBatch(new CameraGroupStrategy(camera)); decals = new ArrayList<>(); - ArrayList<TextureRegion> playerTextureRegions = SpriteUtils.splitToTextureRegions(game.assetManager.get("sprites/sheet/loadingCircle.png", Texture.class), 112, 112, 10, 5); + ArrayList<TextureRegion> playerTextureRegions = SpriteUtils.splitToTextureRegions(game.assetManager.get("sprites/sheet/loadingCircle.png", Texture.class), 112, 112); decalPlayer = new DecalPlayer(savegame, playerTextureRegions); decals.add(decalPlayer.getDecal()); @@ -116,17 +91,12 @@ public class GameScreen implements Screen, InputProcessor { playlist.setShuffleMode(true); if (game.prefs.getBoolean("music", true)) playlist.next(); - items = new ArrayList<>(); - createStageUI(); giftbox = new Giftbox(stage, uiSkin, game.assetManager, sceneManager); Gdx.input.setInputProcessor(new InputMultiplexer(this, new CrossProcessor(), stage)); - } - @Override - public void show() { tasks.add(Timer.schedule(new Timer.Task() { @Override public void run() { @@ -171,23 +141,6 @@ public class GameScreen implements Screen, InputProcessor { playlist.next(); } - // i've temporarily commented it all out while i set up 3d - //game.batch.begin(); - - //bg.draw(game.batch); - - //game.batch.end(); - - // Update the points label: - //pointsLabel.setText(game.locale.FormattedText("game.points", - // MaxonConstants.DECIMAL_FORMAT.format(player.points) - //)); - - // Update the multiplier label: - //multiplierLabel.setText(game.locale.FormattedText("game.multiplier", - // MaxonConstants.DECIMAL_FORMAT.format(player.multiplier) - //)); - // Render 3D sceneManager.update(Gdx.graphics.getDeltaTime()); sceneManager.render(); @@ -284,10 +237,8 @@ public class GameScreen implements Screen, InputProcessor { public boolean keyDown(int keycode) { if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) { game.setScreen(new MenuScreen()); + return true; } - //if (Gdx.input.isKeyPressed(Input.Keys.SPACE) || Gdx.input.isKeyPressed(Input.Keys.UP)) { - // displayPointIncrease(); - //} return false; } diff --git a/core/src/kz/ilotterytea/maxon/screens/game/Giftbox.java b/core/src/kz/ilotterytea/maxon/screens/game/Giftbox.java index 752d7a1..bb3a185 100644 --- a/core/src/kz/ilotterytea/maxon/screens/game/Giftbox.java +++ b/core/src/kz/ilotterytea/maxon/screens/game/Giftbox.java @@ -73,7 +73,7 @@ public class Giftbox implements Disposable { this.boxImage = new AnimatedImage( SpriteUtils.splitToTextureRegions( assetManager.get("sprites/giftbox/gift.png"), - 256, 256, 2, 1 + 256, 256 ), 10 ); diff --git a/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java b/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java index 50ab62e..567dff7 100644 --- a/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java +++ b/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java @@ -39,7 +39,6 @@ public class ShopUI { private final Sound clickSound, notEnoughMoneySound, purchaseSound, sellSound; private final String styleName = OsUtils.isMobile ? "defaultMobile" : "default"; - private final float iconSize = OsUtils.isMobile ? 64f : 32f; public ShopUI(final Savegame savegame, Stage stage, Skin skin, TextureAtlas atlas) { this.savegame = savegame; diff --git a/core/src/kz/ilotterytea/maxon/ui/AnimatedImage.java b/core/src/kz/ilotterytea/maxon/ui/AnimatedImage.java index d1f5b90..97cd354 100644 --- a/core/src/kz/ilotterytea/maxon/ui/AnimatedImage.java +++ b/core/src/kz/ilotterytea/maxon/ui/AnimatedImage.java @@ -2,7 +2,6 @@ package kz.ilotterytea.maxon.ui; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.scenes.scene2d.ui.Image; -import com.badlogic.gdx.scenes.scene2d.utils.Drawable; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.utils.Disposable; @@ -13,13 +12,7 @@ public class AnimatedImage extends Image implements Disposable { private final int fps; private int index = 0, seconds = 0; - private boolean stopAnim = false; - - public AnimatedImage(ArrayList<TextureRegion> regions) { - super(regions.get(0)); - this.regions = regions; - this.fps = 0; - } + private final boolean stopAnim = false; public AnimatedImage(ArrayList<TextureRegion> regions, int fps) { super(regions.get(0)); @@ -48,23 +41,6 @@ public class AnimatedImage extends Image implements Disposable { } public TextureRegion getFrame(int index) { return regions.get(index); } - public int getIndex() { return index; } - public Drawable getDrawable() { return super.getDrawable(); } - - public void nextFrame() { - index++; - - if (index > regions.size() - 1 || regions.get(index) == null) { - index = 0; - } - - super.setDrawable(new TextureRegionDrawable(regions.get(index))); - } - - public void disableAnim() { stopAnim = true; } - public void enableAnim() { stopAnim = false; } - - public boolean isAnimationStopped() { return stopAnim; } @Override public void dispose() { for (TextureRegion reg : regions) { diff --git a/core/src/kz/ilotterytea/maxon/ui/LeafParticle.java b/core/src/kz/ilotterytea/maxon/ui/LeafParticle.java index 82879cf..e6a8cf2 100644 --- a/core/src/kz/ilotterytea/maxon/ui/LeafParticle.java +++ b/core/src/kz/ilotterytea/maxon/ui/LeafParticle.java @@ -6,7 +6,11 @@ import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.TextureRegion; public class LeafParticle extends Sprite { - private float angle, x, y, vertAngle, rotation, time; + private final float angle; + private float x; + private float y; + private final float vertAngle; + private final float rotation; public LeafParticle(TextureRegion region, float x, float y, float angle, float vertAngle, float rotation) { super(region); @@ -19,7 +23,7 @@ public class LeafParticle extends Sprite { @Override public void draw(Batch batch) { - this.time = Gdx.graphics.getDeltaTime(); + float time = Gdx.graphics.getDeltaTime(); this.x -= (float) Math.sin(time) * this.angle; this.y -= (float) Math.sin(time) * this.vertAngle; diff --git a/core/src/kz/ilotterytea/maxon/ui/MovingChessBackground.java b/core/src/kz/ilotterytea/maxon/ui/MovingChessBackground.java index a585d0b..3ae73c6 100644 --- a/core/src/kz/ilotterytea/maxon/ui/MovingChessBackground.java +++ b/core/src/kz/ilotterytea/maxon/ui/MovingChessBackground.java @@ -69,14 +69,14 @@ public class MovingChessBackground { totalDWidth = totalDWidth / drawables.size(); totalDHeight = totalDHeight / drawables.size(); - log.info(String.format("Total size of %s drawables: %sx%s", drawables.size(), totalDWidth, totalDHeight)); + log.info("Total size of {} drawables: {}x{}", drawables.size(), totalDWidth, totalDHeight); int DIndex = 0; log.info("Starting to generating tiles..."); for (int h = 0; h < height / totalDHeight + 3; h++) { - tiles.add(h, new ArrayList<Image>()); + tiles.add(h, new ArrayList<>()); for (int w = -1; w < width / totalDWidth; w++) { if (DIndex + 1 > drawables.size()) DIndex = 0; diff --git a/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt b/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt index 7c66513..72ab8c5 100644 --- a/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt +++ b/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.kt @@ -9,7 +9,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.utils.ClickListener import com.badlogic.gdx.utils.Align import kz.ilotterytea.maxon.MaxonGame -import kz.ilotterytea.maxon.player.Savegame import kz.ilotterytea.maxon.screens.MenuScreen import kz.ilotterytea.maxon.screens.SlotsMinigameScreen import kz.ilotterytea.maxon.ui.ShakingImageButton diff --git a/core/src/kz/ilotterytea/maxon/utils/GameUpdater.java b/core/src/kz/ilotterytea/maxon/utils/GameUpdater.java index 1c4ef94..6b7c407 100644 --- a/core/src/kz/ilotterytea/maxon/utils/GameUpdater.java +++ b/core/src/kz/ilotterytea/maxon/utils/GameUpdater.java @@ -68,8 +68,5 @@ public class GameUpdater implements Net.HttpResponseListener { return version; } - public void setVersion(String version) { - this.version = version; - } } } diff --git a/core/src/kz/ilotterytea/maxon/utils/OsUtils.java b/core/src/kz/ilotterytea/maxon/utils/OsUtils.java index 7d45c5d..bbefc41 100644 --- a/core/src/kz/ilotterytea/maxon/utils/OsUtils.java +++ b/core/src/kz/ilotterytea/maxon/utils/OsUtils.java @@ -1,7 +1,7 @@ package kz.ilotterytea.maxon.utils; public class OsUtils { - private static String OS = System.getProperty("os.name").toLowerCase(); + private static final String OS = System.getProperty("os.name").toLowerCase(); static public boolean isAndroid = System.getProperty("java.runtime.name").contains("Android"); static public boolean isMac = !isAndroid && OS.contains("mac"); @@ -9,19 +9,13 @@ public class OsUtils { static public boolean isLinux = !isAndroid && OS.contains("linux"); static public boolean isIos = !isAndroid && (!(isWindows || isLinux || isMac)) || OS.startsWith("ios"); - static public boolean isARM = System.getProperty("os.arch").startsWith("arm") || System.getProperty("os.arch").startsWith("aarch64"); - static public boolean is64Bit = System.getProperty("os.arch").contains("64") || System.getProperty("os.arch").startsWith("armv8"); - - public static boolean isGwt = false; - public static boolean isMobile = isIos || isAndroid; - public static boolean isPC = isWindows || isMac || isIos; + public static final boolean isPC = isWindows || isMac || isIos; static { try { Class.forName("com.google.gwt.core.client.GWT"); - isGwt = true; } catch(Exception ignored) { /* IGNORED */ } @@ -32,56 +26,13 @@ public class OsUtils { isWindows = false; isLinux = false; isMac = false; - is64Bit = false; isMobile = true; } } - public static String getUserConfigDirectory() - { - return getUserConfigDirectory(null); - } - - public static String getUserConfigDirectory(String applicationName) - { - String CONFIG_HOME = null; - - if((CONFIG_HOME = System.getenv("XDG_CONFIG_HOME"))==null) - { - if(isLinux || isAndroid) - { - CONFIG_HOME = System.getProperty("user.home")+"/.config"; - } - else if(isMac) - { - CONFIG_HOME = System.getProperty("user.home")+"/Library/Preferences"; - } - else if(isIos) - { - CONFIG_HOME = System.getProperty("user.home")+"/Documents"; - } - else if(isWindows) - { - if((CONFIG_HOME = System.getenv("APPDATA"))==null) - { - CONFIG_HOME = System.getProperty("user.home")+"/Documents/My Games"; - } - } - } - - if(applicationName==null || CONFIG_HOME==null) return CONFIG_HOME; - - return CONFIG_HOME+"/"+applicationName; - } - - public static String getUserDataDirectory() - { - return getUserDataDirectory(null); - } - public static String getUserDataDirectory(String applicationName) { - String DATA_HOME = null; + String DATA_HOME; if((DATA_HOME = System.getenv("XDG_DATA_HOME"))==null) { diff --git a/core/src/kz/ilotterytea/maxon/utils/ScreenshotFactory.java b/core/src/kz/ilotterytea/maxon/utils/ScreenshotFactory.java index 76cd92b..d955935 100644 --- a/core/src/kz/ilotterytea/maxon/utils/ScreenshotFactory.java +++ b/core/src/kz/ilotterytea/maxon/utils/ScreenshotFactory.java @@ -18,17 +18,10 @@ public class ScreenshotFactory { * Default without any compression. Y is flipped. */ public static void takeScreenshot(){ - _takeScreenshot(Deflater.NO_COMPRESSION, true); + _takeScreenshot(); } - /** - * Take a screenshot. It will be saved in the user data directory, it is different for each platform (Windows: %appdata%/.maxoning/screenshots/, Linux: ~/.local/share/maxoning/screenshots). - */ - public static void takeScreenshot(int compression, boolean flipY){ - _takeScreenshot(compression, flipY); - } - - private static void _takeScreenshot(int compression, boolean flipY) { + private static void _takeScreenshot() { File file = new File(MaxonConstants.GAME_SCREENSHOT_FOLDER); if (!file.exists()) { @@ -45,7 +38,7 @@ public class ScreenshotFactory { pixels.put(i, (byte) 255); } - PixmapIO.writePNG(new FileHandle(file.getPath() + String.format("/screenshot-%s.png", dtf.format(now))), pixmap, compression, flipY); + PixmapIO.writePNG(new FileHandle(file.getPath() + String.format("/screenshot-%s.png", dtf.format(now))), pixmap, Deflater.NO_COMPRESSION, true); pixmap.dispose(); } }
\ No newline at end of file diff --git a/core/src/kz/ilotterytea/maxon/utils/formatters/NumberFormatter.java b/core/src/kz/ilotterytea/maxon/utils/formatters/NumberFormatter.java index f6c0fa4..7ed4583 100644 --- a/core/src/kz/ilotterytea/maxon/utils/formatters/NumberFormatter.java +++ b/core/src/kz/ilotterytea/maxon/utils/formatters/NumberFormatter.java @@ -41,7 +41,6 @@ public class NumberFormatter { String suffix = e.getValue(); double truncated = value / (divideBy / 10.0); //the number part of the output times 10 - boolean hasDecimal = truncated < 100 && (truncated / 10d) != (truncated / 10); return formatWithSuffix(truncated / 10d, suffix); } |
