Skip to content

Commit

Permalink
sort planets by orbital period (#37)
Browse files Browse the repository at this point in the history
* sort planets by orbital period

* fix button colours in planet selection UI
  • Loading branch information
jmoiron authored Jul 3, 2024
1 parent 1a83bb8 commit a8c57f3
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ protected void init() {

// All buttons are data-driven; they are created from files in the /planet_data/planets directory.
List<Planet> planets = new ArrayList<>(PlanetData.planets().values());
planets.sort(Comparator.comparing(g -> g.translation().substring(Math.abs(g.translation().indexOf(".text")))));
// sort planets based on their orbital period
planets.sort(Comparator.comparing(p -> p.daysInYear()));

planets.forEach(planet -> {
Category galaxyCategory = new Category(planet.galaxy(), Category.GALAXY_CATEGORY);
Category solarSystemCategory = new Category(planet.solarSystem(), galaxyCategory);
Expand Down Expand Up @@ -316,10 +318,11 @@ public Button createButton(int row, Component label, Category category, int colo
public Button createButton(int row, int column, Component label, Category category, int colour, int sizeX, int sizeY, TooltipType tooltip, Planet planetInfo, Consumer<Button> onClick) {
LinkedList<ExtendedButton> buttons = this.categoryButtons.getOrDefault(category, new LinkedList<>());

float colorR = (float) ((colour << 16) & 0xFF) / 255.0f;
float colorG = (float) ((colour << 8) & 0xFF) / 255.0f;
float colorB = (float) (colour & 0xFF) / 255.0f;
ExtendedButton button = new ExtendedButton(row, column, sizeX, sizeY, colorR, colorG, colorB, label, onClick::accept, (button1) -> renderButtonTooltip(planetInfo, tooltip, button1));
float colourR = (float) ((colour & 0xff0000) >> 16) / 255.0f;
float colourG = (float) ((colour & 0x00ff00) >> 8) / 255.0f;
float colourB = (float) ((colour & 0x0000ff)) / 255.0f;

ExtendedButton button = new ExtendedButton(row, column, sizeX, sizeY, colourR, colourG, colourB, label, onClick::accept, (button1) -> renderButtonTooltip(planetInfo, tooltip, button1));
this.addRenderableWidget(button);

buttons.add(button);
Expand Down

0 comments on commit a8c57f3

Please sign in to comment.