Skip to content

Commit

Permalink
GUI: Load flags using g_languages[] list
Browse files Browse the repository at this point in the history
  • Loading branch information
av-dx authored and sev- committed Nov 12, 2021
1 parent 0c159e3 commit 4115f4c
Show file tree
Hide file tree
Showing 31 changed files with 37 additions and 216 deletions.
25 changes: 10 additions & 15 deletions gui/widgets/grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "common/system.h"
#include "common/file.h"
#include "common/language.h"

#include "gui/gui-manager.h"
#include "gui/widgets/grid.h"
Expand Down Expand Up @@ -323,7 +324,7 @@ const Graphics::ManagedSurface *GridWidget::languageToSurface(const String &lang
}

const Graphics::ManagedSurface *GridWidget::platformToSurface(Platform platformCode) {
if ((platformCode == kPlatformUnknown) || (platformCode < 0 || platformCode >= _platformIcons.size())) {
if ((platformCode == kPlatformUnknown) || (platformCode < 0 || platformCode >= (int)_platformIcons.size())) {
warning("Unknown Platform");
return nullptr;
}
Expand Down Expand Up @@ -383,25 +384,19 @@ void GridWidget::reloadThumbnails() {
}

void GridWidget::loadFlagIcons() {
String pathPrefix("./icons/");
StringArray iconFilenames;

// TODO: Can we read the language list from language.cpp?
iconFilenames.push_back(String("en.svg"));
iconFilenames.push_back(String("en-gb.svg"));
iconFilenames.push_back(String("en-us.svg"));
iconFilenames.push_back(String("it.svg"));
iconFilenames.push_back(String("fr.svg"));

for (auto i = iconFilenames.begin(); i != iconFilenames.end(); ++i) {
String fullPath = pathPrefix + (*i);
Graphics::ManagedSurface *gfx = loadSurfaceFromFile(fullPath);
const Common::LanguageDescription *l =Common::g_languages;
for (; l->code; ++l) {
String path = String::format("./icons/%s.svg", l->code);
Graphics::ManagedSurface *gfx = loadSurfaceFromFile(path);
if (gfx) {
const Graphics::ManagedSurface *scGfx = scaleGfx(gfx, 32, 32);
_loadedSurfaces[fullPath] = scGfx;
_loadedSurfaces[path] = scGfx;
gfx->free();
delete gfx;
}
else {
_loadedSurfaces[path] = nullptr;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions icons/br.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/cz.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/da.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/de.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/es.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/et.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/fa.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/fi.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4115f4c

Please sign in to comment.