Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
- Fix missing icons when 'SLADE Classic' icon set is selected
- Other very minor things
  • Loading branch information
sirjuddington committed Jun 2, 2020
1 parent 505857a commit 91e371d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 18 deletions.
6 changes: 3 additions & 3 deletions dist/res/actions/ppal.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ action ppal_tint
action ppal_tweak
{
text = "Tweak";
icon = "sliders", "palette_tweak";
icon = "palette_tweak", "sliders";
help_text = "Tweak the palette";
}

Expand All @@ -58,7 +58,7 @@ action ppal_invert
action ppal_gradient
{
text = "Gradient";
icon = "gradient", "palette_gradient";
icon = "palette_gradient", "gradient";
help_text = "Add a gradient to the palette";
}

Expand Down Expand Up @@ -107,7 +107,7 @@ action ppal_report
action ppal_generate
{
text = "Generate Palettes";
icon = "palette_generate", "palette";
icon = "palette_generate";
help_text = "Generate full range of palettes from the first";
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/mkdocs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ local archive = Archives.OpenFile("c:/games/doom/somewad.wad")

-- The first element in entries is entries[1], because it is a Lua array
-- (entries[0] is invalid)
local entries = some_archive.entries
local entries = archive.entries

-- Will print "0" because entries in SLADE begin at index 0
App.LogMessage(entries[1].index)
Expand Down
2 changes: 1 addition & 1 deletion src/Application/SLADEWxApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int win_version_major = 0;
int win_version_minor = 0;
} // namespace slade::global

string current_action = current_action;
string current_action;
bool update_check_message_box = false;
CVAR(String, dir_last, "", CVar::Flag::Save)
CVAR(Bool, update_check, true, CVar::Flag::Save)
Expand Down
49 changes: 36 additions & 13 deletions src/Graphics/Icons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,35 @@ vector<Icon>& iconList(Type type)
}

// -----------------------------------------------------------------------------
// Loads all icons in [dir] to the list for [type]
// Loads all icons in [dir] to the list for [type].
// If [append_default] is true, we are only loading icons from the default set
// that don't already exist in the icon list
// -----------------------------------------------------------------------------
bool loadIconsDir(Type type, ArchiveDir* dir)
bool loadIconsDir(Type type, ArchiveDir* dir, bool append_default)
{
if (!dir)
return false;

// Check for icon set dirs
for (const auto& subdir : dir->subdirs())
if (!append_default)
{
if (subdir->name() != "16" && subdir->name() != "24" && subdir->name() != "32")
for (const auto& subdir : dir->subdirs())
{
if (type == General)
iconsets_general.push_back(subdir->name());
else if (type == Entry)
iconsets_entry.push_back(subdir->name());
if (subdir->name() != "16" && subdir->name() != "24" && subdir->name() != "32")
{
if (type == General)
iconsets_general.push_back(subdir->name());
else if (type == Entry)
iconsets_entry.push_back(subdir->name());
}
}
}

// Get icon set dir
string icon_set_dir = "Default";
if (type == Entry)
if (type == Entry && !append_default)
icon_set_dir = iconset_entry_list;
if (type == General)
if (type == General && !append_default)
icon_set_dir = iconset_general;
if (icon_set_dir != "Default")
if (auto subdir = dir->subdir(icon_set_dir))
Expand All @@ -126,6 +131,7 @@ bool loadIconsDir(Type type, ArchiveDir* dir)
auto& icons = iconList(type);

// Load 16x16 icons (these must exist)
bool found = false;
auto* dir_16 = dir->subdir("16").get();
if (!dir_16)
{
Expand All @@ -141,6 +147,19 @@ bool loadIconsDir(Type type, ArchiveDir* dir)
continue;
}

if (append_default)
{
found = false;
for (const auto& icon : icons)
if (icon.name == entry->nameNoExt())
{
found = true;
break;
}
if (found)
continue;
}

// Load 16x16 icon image
Icon n_icon;
auto stream = wxMemoryInputStream(entry->rawData(), entry->size());
Expand Down Expand Up @@ -279,14 +298,18 @@ bool icons::loadIcons()

// Load general icons
iconsets_general.emplace_back("Default");
loadIconsDir(General, dir_icons->subdir("general").get());
loadIconsDir(General, dir_icons->subdir("general").get(), false);

// Load entry list icons
iconsets_entry.emplace_back("Default");
loadIconsDir(Entry, dir_icons->subdir("entry_list").get());
loadIconsDir(Entry, dir_icons->subdir("entry_list").get(), false);

// Load text editor icons
loadIconsDir(TextEditor, dir_icons->subdir("text_editor").get());
loadIconsDir(TextEditor, dir_icons->subdir("text_editor").get(), false);

// Load any missing icons from the default set
if (iconset_general != "Default")
loadIconsDir(General, dir_icons->subdir("general").get(), true);

return true;
}
Expand Down

0 comments on commit 91e371d

Please sign in to comment.