Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add preferences for "change-recipe-productivity" technology unlocks #334

Merged
merged 7 commits into from
Oct 31, 2024

Conversation

will14smith
Copy link

I was playing over the weekend and needed this to plan out my factory, based on the discussion in #331 this would be option 3
I had to move the "done" button to the top of the screen to avoid it overlapping with the levels, and I couldn't quite figure out how to make a scrollable box

I'm happy to split the PR into the parsing/calculating change vs the UI change if you think there's a nicer UI to be had :)

Screenshots

Preferences screen:
(I have some WIP commits that fix the icon rendering too, I'll clean them up soon)
image

No tech unlocked:
image

Level 10 plastic (+100% productivity) unlocked:
image

@will14smith will14smith changed the title Add preferences for "change-recipe-productivity" technology unlocks feat: Add preferences for "change-recipe-productivity" technology unlocks Oct 28, 2024
@veger
Copy link
Collaborator

veger commented Oct 28, 2024

Hi,
Thank you for your contribution!

I believe the UI part needs to be updated, as @DaleStan made the preparations for this in #332? I didn't compare carefully enough (I use the dark theme, so I was a little confused), but I see it is part of the updated preferences UI already 😄

@DaleStan
Copy link
Collaborator

I had to move the "done" button to the top of the screen to avoid it overlapping with the levels, and I couldn't quite figure out how to make a scrollable box

The first part is my fault. It's fixed now in #336.
I'd still like to see a scroll box, so you can display the first ten or so technologies and then scroll if there are more. I got that working with ModuleFillerParametersScreen.overrideList, but I also remember having to fight with it.

(I have some WIP commits that fix the icon rendering too, I'll clean them up soon)

Looking forward to that! I've always been bothered by the icon rendering bugs, but never enough to dig through how it all works.

Copy link
Collaborator

@DaleStan DaleStan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I have a mod that does this

Code
function deep_copy(t)
  local t2 = {}
  for k,v in pairs(t) do
    if type(v) == "table" then
      t2[k] = deep_copy(v)
    else
      t2[k] = v
    end
  end
  return t2
end

data.raw.technology["steel-plate-productivity-1"] = data.raw.technology["steel-plate-productivity"]
data.raw.technology["steel-plate-productivity-2"] = deep_copy(data.raw.technology["steel-plate-productivity"])
data.raw.technology["steel-plate-productivity-3"] = deep_copy(data.raw.technology["steel-plate-productivity"])
data.raw.technology["steel-plate-productivity"] = nil

data.raw.technology["steel-plate-productivity-1"].max_level = nil;
data.raw.technology["steel-plate-productivity-2"].max_level = nil;
data.raw.technology["steel-plate-productivity-1"].name = "steel-plate-productivity-1"
data.raw.technology["steel-plate-productivity-2"].name = "steel-plate-productivity-2"
data.raw.technology["steel-plate-productivity-3"].name = "steel-plate-productivity-3"

data.raw.technology["steel-plate-productivity-1"].effects[1].change = 0.04
data.raw.technology["steel-plate-productivity-2"].effects[1].change = 0.06
data.raw.technology["steel-plate-productivity-1"].effects[2].change = 0.04
data.raw.technology["steel-plate-productivity-2"].effects[2].change = 0.06

(which I stuffed in postprocess.lua for testing)

then I get this.
image
This works, but only if I fill in the boxes correctly. If I forget to subtract 2 from my actual research level before sticking it in the "Steel plate productivity 3 level" box, or don't put 1s in the other boxes, the calculations will be wrong.

Yafc/Windows/PreferencesScreen.cs Outdated Show resolved Hide resolved
@DaleStan DaleStan linked an issue Oct 30, 2024 that may be closed by this pull request
@will14smith
Copy link
Author

@DaleStan thanks for the review, I've rebased on your changes from #336 and included a little bug fix for calculating the max height too

How would you feel about me splitting that code with mods into a follow up PR to keep this one clean? I have an idea of how to fix it but probably need to spend some more timing thinking about how to implement nicely, there seem to be a bunch of fun edge cases around defining multiple levels of technologies

Code

function deep_copy(t)
    local t2 = {}
    for k,v in pairs(t) do
      if type(v) == "table" then
        t2[k] = deep_copy(v)
      else
        t2[k] = v
      end
    end
    return t2
  end
  
  data.raw.technology["steel-plate-productivity-1"] = data.raw.technology["steel-plate-productivity"]
  data.raw.technology["steel-plate-productivity-2"] = deep_copy(data.raw.technology["steel-plate-productivity"])
  data.raw.technology["steel-plate-productivity-5"] = deep_copy(data.raw.technology["steel-plate-productivity"])
  data.raw.technology["steel-plate-productivity"] = nil
  
  data.raw.technology["steel-plate-productivity-1"].max_level = nil;
  data.raw.technology["steel-plate-productivity-2"].max_level = 4;
  data.raw.technology["steel-plate-productivity-1"].name = "steel-plate-productivity-1"
  data.raw.technology["steel-plate-productivity-2"].name = "steel-plate-productivity-2"
  data.raw.technology["steel-plate-productivity-5"].name = "steel-plate-productivity-5"
  
  data.raw.technology["steel-plate-productivity-1"].effects[1].change = 0.04
  data.raw.technology["steel-plate-productivity-2"].effects[1].change = 0.06
  data.raw.technology["steel-plate-productivity-1"].effects[2].change = 0.04
  data.raw.technology["steel-plate-productivity-2"].effects[2].change = 0.06

Copy link
Collaborator

@DaleStan DaleStan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@will14smith Yeah, there's a lot of "fun" going on with the multi-level technologies. As long as you're aware of it and have a plan, I'm OK with merging.

@shpaass shpaass merged commit bb37a39 into shpaass:master Oct 31, 2024
1 check passed
@will14smith will14smith deleted the technology-productivity branch November 2, 2024 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[UI design] Recipe productivity technologies
4 participants