Histidine91 / Nexerelin

The Nexerelin 4x mod for Starsector.
65 stars 15 forks source link

Mining UI - Adding a list of favorite planets - Idea and pseudocode #54

Open Ronkhar opened 1 year ago

Ronkhar commented 1 year ago

Hi Histidine, I'm back (cf. 14th September 2022) with yet another idea to hopefully improve the mining experience.

The concept

The player can see the current distance and exhaustion for the planets he wants to mine again.

How? When the player selects an uncolonized planet and opens the mining menu, he sees three additional options :

When the players selects an asteroid and opens the mining menu, he sees one additional option:

The list of favorites shows a table (similar to the fantastic job you did with the database of mining ships/weapons/wings)

The columns are:

Edit: An image should be easier to understand. (Paint skills!) Mining favorites

The pseudocode

(Sorry for all the horrible pseudocode below, I think the last time I wrote java was ~2006)

1) create an ArrayList to store the favorite planets List<SectorEntityToken> arr_fav_mine_pl = new ArrayList<>();

2) add the new lines to the mining menu (Nexerelin\data\campaign\rules.csv)

I don't know if it's possible for options to be conditionaly hidden. Maybe it's impossible since the functions for start mining and prisoner actions make the option greyed, not hidden.

Anyway, I think we want something like

if (current_target instanceof PlanetAPI && !arr_fav_mine_pl.contains(current_target)) {show or activate the line "Add this planet to the mining favorites"}

if (current_target instanceof PlanetAPI && arr_fav_mine_pl.contains(current_target)) {show or activate the line "Remove this planet from the mining favorites"}

if (arr_fav_mine_pl.length) {show or activate the line "Show favorite mining planets"}

3) effect of the new menu options "Add this planet to the mining favorites" calls a function add_fav_mine_pl(planet_id) "Remove this planet from the mining favorites" calls a function del_fav_mine_pl(planet_id) "Show favorite mining planets" calls a function show_fav_mine_planets()

3a) function del_fav_mine_pl(planet_id) arr_fav_mine_pl.remove(planet_id)

3b) function add_fav_mine_pl(planet_id) arr_fav_mine_pl.add(planet_id)

3c) function show_fav_mine_planets()

List<Pair<SectorEntityToken, Float>> miningFavPlanets = new ArrayList<>();

for (SectorEntityToken current_planet in arr_fav_mine_pl){
    MiningReport report = MiningHelperLegacy.getMiningReport(playerFleet, current_planet, 1);
    float exhaustion = report.exhaustion;
    miningFavPlanets.add(new Pair<>(current_planet, exhaustion));
}

No idea how you put that in a table and add the other parameters (resources, distance...)

4) Possible causes of bugs. a)What happens it a planet in the mining favorites is no longer eligible (for example if it got colonized)? Perhaps add a check inside the loop in function show_fav_mine_planets that calls del_fav_mine_pl if necessary

What do you think? Ronkhar

Histidine91 commented 1 year ago

Thanks for the ideas! I might try some stuff in the future, although not for next update.