Conversation
|
Oh thanks! |
bonjorno7
left a comment
There was a problem hiding this comment.
Sorry it took so long, I forgor.
I hope it puts the messages from top to bottom instead of chronologically.
|
|
||
| studiomdl = self.bin.joinpath('studiomdl.exe') | ||
| studiomdl = game_utils.get_studiomdl_path(game) | ||
| quickmdl = self.bin.joinpath('quickmdl.exe') | ||
| self.studiomdl = quickmdl if quickmdl.is_file() else studiomdl |
There was a problem hiding this comment.
Let's move the QuickMDL thing into get_studiomdl_path too.
There was a problem hiding this comment.
Oh I don't know actually.. I assume it works through Wine but don't know if there's a native binary.
addon/types/model_export/model.py
Outdated
| from pathlib import Path | ||
| from traceback import print_exc | ||
| from ... utils import common | ||
| from ... utils import game as game_utils |
There was a problem hiding this comment.
I don't love importing as; would it be possible to import utils itself and then use utils.common and utils.game everywhere in this file?
Don't pay it any mind if you think it's a bad idea.
There was a problem hiding this comment.
Added this as a lazy workaround for a parameter with the name game ![]()
will change though
addon/utils/game.py
Outdated
| from pathlib import Path | ||
| from ..utils.common import resolve | ||
|
|
||
| import os |
There was a problem hiding this comment.
Move this import above the others please.
addon/utils/game.py
Outdated
| self['game'] = resolve(self.game) | ||
| g = resolve(self.game) | ||
| # Don't bother re-resolving paths if we haven't changed our game path | ||
| if g == self['game']: | ||
| return | ||
|
|
||
| self['game'] = g |
There was a problem hiding this comment.
As far as I know, Blender does not call an update function if the value did not change, so this check shouldn't be necessary.
| studiomdl = Path(game.bin).joinpath('studiomdl.exe') | ||
| return gameinfo.is_file() and studiomdl.is_file() | ||
| return gameinfo.is_file() and get_studiomdl_path(game).is_file() | ||
|
|
||
| def get_studiomdl_path(game): | ||
| if os.name == 'posix' and (game.bin.endswith('linux32') or game.bin.endswith('linux64')): | ||
| p = Path(game.bin).joinpath('studiomdl') | ||
| if p.is_file(): | ||
| return p | ||
| return Path(game.bin).joinpath('studiomdl.exe') | ||
|
|
There was a problem hiding this comment.
Same point about variable names here.
Sorry to have so many nitpicks, I really do appreciate your contribution.
There was a problem hiding this comment.
This message is supposed to show up below the next one.
The aformentioned point about variable names is that I'd like longer ones.
| if not bin.joinpath('studiomdl.exe').is_file(): | ||
| for path in bin.iterdir(): | ||
| if path.is_dir() and path.joinpath('studiomdl.exe').is_file(): | ||
| bin = path | ||
| break | ||
| # If we're not on the old-style pattern bin/<something> layout, check for platform subdirs | ||
| actualbin = None | ||
| if not bin.joinpath('studiomdl.exe').is_file() and not bin.joinpath('studiomdl').is_file(): | ||
| def check_subdir(subdirs, smdl): | ||
| for s in subdirs: | ||
| p = bin.joinpath(s) | ||
| if p.is_dir() and p.joinpath(smdl).is_file(): | ||
| return p | ||
| return None | ||
|
|
||
| # For linux, prefer the native binaries (if possible) | ||
| if os.name == 'posix': | ||
| actualbin = check_subdir(['linux32', 'linux64'], 'studiomdl') | ||
| # Resolve windows paths | ||
| if actualbin is None: | ||
| actualbin = check_subdir(['win32', 'win64'], 'studiomdl.exe') | ||
|
|
||
| if actualbin is not None: | ||
| bin = actualbin |
There was a problem hiding this comment.
Kind of a nitpick but I'm not a fan of these short variable names, I think renaming s to subdir and p to path would make it easier to read.
I'll probably refactor this function a little anyway after merging though.
|
@JJL772 The force push makes it kind of confusing to review but I'll try. |
|
@bonjorno7 Sorry for the force push! Totally forgot about this PR until now- is there anything else you want me to do here? |
|
It's been 10 months and I've completely forgotten what this is about lol |
|
Is this still a thing, or is this just not something that's coming? |
Some games like Momentum Mod and Portal 2: Community Edition ship a Linux-native version of studiomdl. This PR adds support for Linux-native studiomdl if it exists.
Summary of changes:
I wasn't able to test this on Windows yet, just opening for preliminary review I guess