new icon.java proposal

overdhose

Active Member
Contributor
Design
World
GUI
hey Cervator,

I created a modified icon.java to better support mods, would be nice if you could let me know if this is acceptable for the main dev, I also removed deprecated code and still left an oldsize / newsize, for those that don't want to handle bigger icons, the card items use the new 32pix icons, and it works, this allows modders to use a seperate png then the engine:items :
newicons.png

pastebin link
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
Ideally we should probably set up some flavor of asset to the asset system for atlases/icons - maybe have json files mapping textures to icons, and then you would obtain icons through Assets.getIcon() similar to any other asset.

I welcome any change in that direction though, and this looks like a good start.
 

overdhose

Active Member
Contributor
Design
World
GUI
allright, still needs work anyway... while all seemed to run smooth, rendering it in first person is "not supported" atm ^^... I'll see if I can add it to the assets as proposed. But the extra pixels are welcome for some stuff, specially the books for example look a lot better. Now to make some oreos...
 

overdhose

Active Member
Contributor
Design
World
GUI
nudge Immortius,

would this be an improvement?

Assets.java:
Code:
 public static UIImage getAtlasTexture(String simpleUri, int x, int y, int size){
        UIImage iconimage = new UIImage(get(new AssetUri(AssetType.TEXTURE, simpleUri), Texture.class));
        iconimage.setSize(new Vector2f(32,32));
        iconimage.setTextureSize(new Vector2f(size, size));
        iconimage.setTextureOrigin(new Vector2f(x * size, y * size));
        return iconimage;
    }
Icon.java:
Code:
public static void set(String name, String modtexture, int atlasx, int atlasy, int size){
   if(icons == null){
   loadIcons();
   }
   Icon addicon = new Icon(Assets.getAtlasTexture(modtexture, atlasx, atlasy, size));
   icons.put(name, addicon);
    }
}
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Oh, it might have helped our earlier conversation on IRC if I had gotten around to reading this first :)

Earlier today you mentioned getting some stuff working, is there an update on this then?

Keeping everything Assets and improving the handling to where higher resolution stuff is supported ftw. I know the temptation to forge ahead with something that works can be strong though :)
 

overdhose

Active Member
Contributor
Design
World
GUI
I will keep the code to play around with, tried to fiddle with the assets method and combining a texture with a json file, but couldn't quite figure it out atm. Haven't given up, but not to mess up other dev plans or cause issues, I reduced the current solution to the option to use individual textures like this :
java.icon addition :
Code:
    /**
    * new Icon constructor for mods, enables using non atlas png
    * @param iconimage a mod texture
    */
    public Icon(Texture iconimage) {
        _blockFamily = null;
        _element = new UIImage();
        _element.setTexture(iconimage);
        _element.setSize(new Vector2f(32, 32));
        _element.setTextureSize(new Vector2f(16, 16));
        _element.setVisible(true);
        _element.setPosition(new Vector2f(-10f, -16f));                     
        setAtlasPosition(0,0);
    }
 
    /**
    * set method, to be used by mods, only size 16 allowed atm 16
    * @param name the name of the icon in icons.java
    * @param icontexture the simple uri of the mod texture
    */
    public static void set(String name, String icontexture){
        if(icons == null){
            loadIcons();
        }
        Icon addicon = new Icon(Assets.getTexture(icontexture));       
        icons.put(name, addicon);
    }

Code:
public ModIcons(){       
    }
   
    public static void loadIcons(){
        Icon.set("emptycardIcon", "miniion:emptycard");
        Icon.set("filledcardIcon", "miniion:filledcard");
        Icon.set("oreominionIcon", "miniion:oreominion");
       
    }
}
This shouldn't disturb the existing code to much, and won't cause probs with first person rendering and throwing.
 

overdhose

Active Member
Contributor
Design
World
GUI
for some reason, the above while not generating errors doesn't render the icons, so I must have overlooked something (most likely related to the size of the texture) . It's really starting to bug me now, it's a sidetrack, but I'm gonna work it out a bit more. I also overlooked the fact that regardless, I still need to alter meshfactory to keep track of the different resources for first person rendering. I think I'll try to propose an initial version that enables different texture files, and it might be me but there's something weird about the way things work atm, even though I can't exactly point out what it is that bugs me.
 
Top