Closed Snayff closed 4 years ago
Not sure what is causing this, but I have changed this part of the code for 0.5.0 anyway so it may just resolve itself.
If not, things that might help to narrow it down:
Think this has fairly good test coverage already, guess we'll see if it resolves with the changes made to how paths are calculated before digging in any more.
That's good to hear - its still an issue, unfortunately. Do you have an ETA for 0.5?
Should be soon, I'm onto working on the documentation now.
That's fantastic. I am very excited for the new release! Do you think the new version is likely to break a lot of compatibility?
Some. It depends what aspects you are using. The windows have changed a lot because I moved a lot of features I was repeating for each window so they are built in to the core window class.
Most of the regular elements should be pretty much the same interface wise, with some new options.
Unfortunately, this was not resolved by 0.5.*.
I've solved this in your code. Here:
class _UIManager:
"""
Manage the UI, such as windows, resource bars etc
"""
def __init__(self):
# first action needs to be to init pygame.
pygame.init()
# now init the pygame_gui
self._gui = UIManager((VisualInfo.BASE_WINDOW_WIDTH,
VisualInfo.BASE_WINDOW_HEIGHT), "data/ui/themes.json")
# display info
# TODO - allow for selection by player but only multiples of base (16:9)
self._desired_width = VisualInfo.BASE_WINDOW_WIDTH
self._desired_height = VisualInfo.BASE_WINDOW_HEIGHT
self._screen_scaling_mod_x = self._desired_width // VisualInfo.BASE_WINDOW_WIDTH
self._screen_scaling_mod_y = self._desired_height // VisualInfo.BASE_WINDOW_HEIGHT
self._window: pygame.display = pygame.display.set_mode((self._desired_width, self._desired_height))
self._main_surface: pygame.Surface = pygame.Surface((VisualInfo.BASE_WINDOW_WIDTH,
VisualInfo.BASE_WINDOW_HEIGHT), pygame.SRCALPHA)
The UIManager is created before the window, unfortunately pygame requires the window to be created before it can load any images, so you can fix all the loading issues (except the missing icon_00.png) by swapping the order of creation to this:
class _UIManager:
"""
Manage the UI, such as windows, resource bars etc
"""
def __init__(self):
# first action needs to be to init pygame.
pygame.init()
# display info
# TODO - allow for selection by player but only multiples of base (16:9)
self._desired_width = VisualInfo.BASE_WINDOW_WIDTH
self._desired_height = VisualInfo.BASE_WINDOW_HEIGHT
self._screen_scaling_mod_x = self._desired_width // VisualInfo.BASE_WINDOW_WIDTH
self._screen_scaling_mod_y = self._desired_height // VisualInfo.BASE_WINDOW_HEIGHT
self._window: pygame.display = pygame.display.set_mode((self._desired_width, self._desired_height))
self._main_surface: pygame.Surface = pygame.Surface((VisualInfo.BASE_WINDOW_WIDTH,
VisualInfo.BASE_WINDOW_HEIGHT), pygame.SRCALPHA)
# now init the pygame_gui
self._gui = UIManager((VisualInfo.BASE_WINDOW_WIDTH,
VisualInfo.BASE_WINDOW_HEIGHT), "data/ui/themes.json")
# elements info
self._elements = {} # dict of all init'd ui_manager elements
# process config
self._load_display_config()
self._load_fonts()
logging.info(f"UIManager initialised.")
I probably thought I was being smart when I reordered it and didnt notice the loss of those images. You're spot on, moving the init to after the display is set worked. Thank you, mate. I really appreciate your help.
Describe the bug Image not loading in to buttons.
Expected behaviour Expect to see the image in the button. If the path given in the error is pasted into windows explorer it immediately load the image so the path is correct.
Platform and software (please complete the following information):
Additional context Error message:
themes.json: