Code Monkey home page Code Monkey logo

Comments (2)

Lonami avatar Lonami commented on May 23, 2024

Is this still an issue after #43 got merged? (I see you moved the Waterdrop static initialization into the constructor which is nice).

Also regarding the FIXME you introduced:

// FIXME theme should NOT be static as it might load textures which will expose it to the race condition iff GDX got initialized before or not
public static Theme theme;

Sure, it's static, but it's not loading anything. It defaults to null, and is loaded later on create:

public void create() {
onDesktop = Gdx.app.getType().equals(Application.ApplicationType.Desktop);
prefs = Gdx.app.getPreferences("io.github.lonamiwebs.klooni.game");
// Load the best match for the skin (depending on the device screen dimensions)
skin = SkinLoader.loadSkin();
// Use only one instance for the theme, so anyone using it uses the most up-to-date
Theme.skin = skin; // Not the best idea
final String themeName = prefs.getString("themeName", "default");
if (Theme.exists(themeName))
theme = Theme.getTheme(themeName);
else
theme = Theme.getTheme("default");

So, is this still wrong?

from klooni1010.

andidevi avatar andidevi commented on May 23, 2024

The text is according to your TODO that have been there before. I did'n have any look into it beside the code of SkinLoader.

As to to the comment in Line 89 says it is a singleton, you should not allow public write access to it and use a public getter ... and have a look if that's really a performance hit or not ;)

As it isn't loaded that early there's no need for static at all. If other classes need access, they should simply know Klooni. This would lead to more refactoring, ie. making the cellTexture a parameter of Cell.draw or supplying it at cell creation and changing the parameter of set to the already resolved texture to having Cells and maybe other to not needing to know Klooni.

Alternatively you could have a private static variable to store the Klooni instance and supply it with a public static getter.

... much changes and I don't see a practical benefit now. As a big difference to effects you only have one Theme class and there's no need to change as long as that one size fits all.

from klooni1010.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.