Code Monkey home page Code Monkey logo

Comments (13)

le717 avatar le717 commented on August 18, 2024

Fixed in f0037a7. I should have already done this, but I'll add you to the list of authors. Do you want to go by Steffen or MinnieTheMoocher? 😉

from ldr-importer.

MinnieTheMoocher avatar MinnieTheMoocher commented on August 18, 2024

the latter, please. it's my github identity.

from ldr-importer.

MinnieTheMoocher avatar MinnieTheMoocher commented on August 18, 2024

your f0037a7 corrects the unofficial/official files search order, but the error with the p/8 folder is still in it.

it needs to be treated like this

paths = []
paths.append(file_directory)
paths.append(os.path.join(LDrawDir, "models"))
paths.append(os.path.join(LDrawDir, "unofficial", "parts"))
if HighRes:
paths.append(os.path.join(LDrawDir, "unofficial", "p", "48"))
elif LowRes:
paths.append(os.path.join(LDrawDir, "unofficial", "p", "8"))
paths.append(os.path.join(LDrawDir, "unofficial", "p"))
paths.append(os.path.join(LDrawDir, "parts"))
if HighRes:
paths.append(os.path.join(LDrawDir, "p", "48"))
elif LowRes:
paths.append(os.path.join(LDrawDir, "p", "8"))
paths.append(os.path.join(LDrawDir, "p"))

I.e.,
"When the HighRes flag is set to true, let the p/48 folder take precedence.
ELSE
When the LowRes flag is set to true, let the p/8 folder take precedence.
ELSE
Fallback to the p/ folder
"

from ldr-importer.

le717 avatar le717 commented on August 18, 2024

There is no LowRes variable (unless you are referring to #44), so it would actually be elif not HighRes.

Is this the proper formatting? Python uses indentation levels for if/elif/else. In this, parts/ and p/ are always searched no matter the value of HighRes. Do I need to move those under elif not HighRes as well? There really is no else in this section.

paths = []
paths.append(file_directory)
paths.append(os.path.join(LDrawDir, "models"))
paths.append(os.path.join(LDrawDir, "unofficial", "parts"))
if HighRes:
    paths.append(os.path.join(LDrawDir, "unofficial", "p", "48"))
elif not HighRes:
    paths.append(os.path.join(LDrawDir, "unofficial", "p", "8"))
    paths.append(os.path.join(LDrawDir, "unofficial", "p"))
paths.append(os.path.join(LDrawDir, "parts"))
if HighRes:
    paths.append(os.path.join(LDrawDir, "p", "48"))
elif not HighRes:
    paths.append(os.path.join(LDrawDir, "p", "8"))
paths.append(os.path.join(LDrawDir, "p"))

from ldr-importer.

MinnieTheMoocher avatar MinnieTheMoocher commented on August 18, 2024

no, "elif not HighRes" would be equal to "else" which is wrong here!:

the p/8 folder must ONLY be used if the user explicitly requests so.

the current implementation is wrong, because it always uses that folder if HighRes is NOT enabled,
which is wrong.

the fix is very simple!
just introduce a flag "LogRes" completely analogous to "HighRes", i.e., change

highResPrims = BoolProperty(
    name="Use High-Res Primitives",
    description="Replace all Primitives by Hi-Res (48ed) Primitives",
    default=False
)

to

highResPrims = BoolProperty(
    name="Use High-Res Primitives",
    description="Replace all Primitives by Hi-Res (48ed) Primitives",
    default=False
)

lowResPrims = BoolProperty(
    name="Use Low-Res Primitives",
    description="Replace all Primitives by Lo-Res (8ed) Primitives",
    default=False
)

and

    box.prop(self, "highResPrims", icon="MOD_BUILD")

to

    box.prop(self, "highResPrims", icon="MOD_BUILD")
    box.prop(self, "lowResPrims", icon="MOD_BUILD")

and

    global LDrawDir, CleanUp, GameFix, HighRes, CleanUpOpt
    LDrawDir = str(self.ldrawPath)
    HighRes = bool(self.highResPrims)

to

    global LDrawDir, CleanUp, GameFix, HighRes, LowRes, CleanUpOpt
    LDrawDir = str(self.ldrawPath)
    HighRes = bool(self.highResPrims)
    LowRes = bool(self.lowResPrims)

and

    if HighRes:
        debugPrint("High resolution bricks option selected")

to

    if HighRes:
        debugPrint("High resolution bricks option selected")
    if LowRes:
        debugPrint("Low resolution bricks option selected")

from ldr-importer.

MinnieTheMoocher avatar MinnieTheMoocher commented on August 18, 2024

in a future refacturing, you can merge these 2 boolean flags to a simple multiple choice:

  • do no primtives replacement (default)
  • always use High-Res primitives (this currently is the flag "HighRes")
  • always use Low-Res primitives (this currently is the flag "LowRes")

from ldr-importer.

MinnieTheMoocher avatar MinnieTheMoocher commented on August 18, 2024

to make is simple, here is the corrected file (untested):
https://gist.github.com/MinnieTheMoocher/d337bb86864befd094b8

from ldr-importer.

le717 avatar le717 commented on August 18, 2024

Yikes the formatting. You might want to paste that in a Gist and edit your comment with the link.

from ldr-importer.

MinnieTheMoocher avatar MinnieTheMoocher commented on August 18, 2024

here it is :)

from ldr-importer.

le717 avatar le717 commented on August 18, 2024

I tested the patch and it works. However, I did edit it to make the options exclusive so both are not used (and clean up the options a bit) and to work better with your last patch. The layout looks like this now.

image1
image2
image3

You can review the changes (and the descriptions) on the highres-or-lowres branch.

from ldr-importer.

rioforce avatar rioforce commented on August 18, 2024

What about "normal-res" primitives? All you have is low and high.

from ldr-importer.

le717 avatar le717 commented on August 18, 2024

I didn't show that option in the screenshots. ;)

from ldr-importer.

le717 avatar le717 commented on August 18, 2024

Fixed by #54, issue solved!

from ldr-importer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.