Thanks all.
In the meantime I wrote something myself as well which looks a bit different.
Seems to work as well, but not sure what would be the best way to go and why…
public class PaintingsHashMap {
public static HashMap<String, String[]> paintingsHashMap;
public static String[] milkmaid, house, italian;
private Array<String[]> StringArrayCollection = new Array<String[]>();
public PaintingsHashMap() {
paintingsHashMap = new HashMap<String, String[]>();
loadStringArrays();
loadArray();
keyValuePairing();
}
public void loadArray(){
StringArrayCollection.add(milkmaid);
StringArrayCollection.add(house);
StringArrayCollection.add(italian);
}
public void keyValuePairing(){
System.out.println("StringArrayCollection size = " + StringArrayCollection.size);
for (int i = 0; i < StringArrayCollection.size; i++) {
// key value pairing
paintingsHashMap.put(StringArrayCollection.get(i)[0], StringArrayCollection.get(i));
System.out.println(" key = " + StringArrayCollection.get(i)[0] + " , collection name = " + StringArrayCollection.get(i).toString());
}
}
public void loadStringArrays(){
// StringArray consist of Index 0 = KEY for HashMAP, 1 = Painter; 2 = Title 3= Sub Title;
// 4 = Year; 5 = FilePath Image Texture; 6 = FilePath ButtonTexture
milkmaid = new String[]{"milkmaid","Johannes Vermeer", "The Milkmaid", "null", "1660", "", "select_screen/milkmaid.png"};
italian = new String[]{"italian", "Hendrik Voogd", "Italian Landscape with Umbrella Pines", "null", "1807", "", "select_screen/italian_landscape.png"};
house = new String[]{"house", "Willem Troost", "Front View of Buitenzorg Palace after the Earthquake of 10 October 1834", "null", "1834 - 1836",
"", "select_screen/house.png"};
}
public static String[] getStringArray(String key){
return paintingsHashMap.get(key);
}
}
Consequently I can load the button textures for my level select and “full” textures for my game screen like this f.e. :
import static com.norakomi.helpers.PaintingsHashMap.*;
...
...
etc.
button_italian = new Texture(getStringArray("italian")[6]);
Now I’m actually storing everything as a String instead of having each key paired up with different data type values…
Any additional/final thoughts?
edit: probably I can reduce the amount of code -specially if i have a large amount of String[]) - by “filling” StringArrayCollection something like this instead of creating the loadArray() and then I don’t have to explicitly declare the differnt String[] (…public static String[] milkmaid, house, italian;) :
StringArrayCollection.add(new String[]{"milkmaid","Johannes Vermeer", "The Milkmaid", "null", "1660", "", "select_screen/milkmaid.png"}
);