Skip to content

Commit f82e702

Browse files
committed
Added a deletion button next to all "Browse..."-like buttons in editors, when it made sense.
1 parent 1bcd4a2 commit f82e702

File tree

3 files changed

+113
-22
lines changed

3 files changed

+113
-22
lines changed

source/source/game_state/animation_editor/gui.cpp

+23-1
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,30 @@ void AnimationEditor::process_gui_options_dialog() {
711711
if(use_bg) {
712712
ImGui::Indent();
713713

714+
//Remove background texture button.
715+
unsigned char rem_bg_opacity =
716+
game.options.anim_editor.bg_path.empty() ? 50 : 255;
717+
if(
718+
ImGui::ImageButton(
719+
"remBgButton", editor_icons[EDITOR_ICON_REMOVE],
720+
Point(ImGui::GetTextLineHeight()), Point(), Point(1.0f),
721+
COLOR_EMPTY, map_alpha(rem_bg_opacity)
722+
)
723+
) {
724+
game.options.anim_editor.bg_path.clear();
725+
if(bg) {
726+
al_destroy_bitmap(bg);
727+
bg = nullptr;
728+
}
729+
}
730+
set_tooltip(
731+
"Remove the background image.\n"
732+
"This does not delete the file on your disk."
733+
);
734+
714735
//Background texture browse button.
715-
if(ImGui::Button("Browse...", ImVec2(96.0f, 32.0f))) {
736+
ImGui::SameLine();
737+
if(ImGui::Button("Browse...")) {
716738
vector<string> f =
717739
prompt_file_dialog(
718740
FOLDER_PATHS_FROM_ROOT::BASE_PACK + "/" +

source/source/game_state/area_editor/gui.cpp

+60-14
Original file line numberDiff line numberDiff line change
@@ -2247,7 +2247,28 @@ void AreaEditor::process_gui_panel_info() {
22472247
ImGui::Spacer();
22482248
if(saveable_tree_node("info", "Thumbnail")) {
22492249

2250+
//Remove thumbnail button.
2251+
unsigned char rem_thumb_opacity =
2252+
!game.cur_area_data->thumbnail ? 50 : 255;
2253+
if(
2254+
ImGui::ImageButton(
2255+
"remThumbButton", editor_icons[EDITOR_ICON_REMOVE],
2256+
Point(ImGui::GetTextLineHeight()), Point(), Point(1.0f),
2257+
COLOR_EMPTY, map_alpha(rem_thumb_opacity)
2258+
) &&
2259+
game.cur_area_data->thumbnail
2260+
) {
2261+
register_change("area thumbnail removal");
2262+
remove_thumbnail();
2263+
thumbnail_needs_saving = true;
2264+
thumbnail_backup_needs_saving = true;
2265+
}
2266+
set_tooltip(
2267+
"Remove the current thumbnail, if any."
2268+
);
2269+
22502270
//Thumbnail browse button.
2271+
ImGui::SameLine();
22512272
if(ImGui::Button("Browse...")) {
22522273
vector<string> f =
22532274
prompt_file_dialog(
@@ -2274,18 +2295,7 @@ void AreaEditor::process_gui_panel_info() {
22742295
"a file on your disk. When you save the area, the thumbnail\n"
22752296
"gets saved into thumbnail.png in the area's folder, \n"
22762297
"but the original file you selected with the\n"
2277-
"Browse... button will be left untouched."
2278-
);
2279-
2280-
//Thumbnail remove button.
2281-
ImGui::SameLine();
2282-
if(ImGui::Button("Remove thumbnail")) {
2283-
remove_thumbnail();
2284-
thumbnail_needs_saving = true;
2285-
thumbnail_backup_needs_saving = true;
2286-
}
2287-
set_tooltip(
2288-
"Removes the current thumbnail, if any."
2298+
"'Browse...' button will be left untouched."
22892299
);
22902300

22912301
//Current thumbnail text.
@@ -2314,7 +2324,27 @@ void AreaEditor::process_gui_panel_info() {
23142324
ImGui::Spacer();
23152325
if(saveable_tree_node("info", "Background")) {
23162326

2317-
//Choose background image button.
2327+
//Remove background texture button.
2328+
unsigned char rem_bg_opacity =
2329+
game.cur_area_data->bg_bmp_name.empty() ? 50 : 255;
2330+
if(
2331+
ImGui::ImageButton(
2332+
"remBgButton", editor_icons[EDITOR_ICON_REMOVE],
2333+
Point(ImGui::GetTextLineHeight()), Point(), Point(1.0f),
2334+
COLOR_EMPTY, map_alpha(rem_bg_opacity)
2335+
) &&
2336+
!game.cur_area_data->bg_bmp_name.empty()
2337+
) {
2338+
register_change("area background removal");
2339+
game.cur_area_data->bg_bmp_name.clear();
2340+
set_status("Removed the background image successfully.");
2341+
}
2342+
set_tooltip(
2343+
"Remove the background image for the area."
2344+
);
2345+
2346+
//Choose background texture button.
2347+
ImGui::SameLine();
23182348
if(ImGui::Button("Choose image...")) {
23192349
open_bitmap_dialog(
23202350
[this] (const string &bmp) {
@@ -5386,9 +5416,25 @@ void AreaEditor::process_gui_panel_tools() {
53865416
//Reference image node.
53875417
if(saveable_tree_node("tools", "Reference image")) {
53885418

5389-
string old_ref_file_name = reference_file_path;
5419+
//Remove reference image button.
5420+
unsigned char rem_ref_opacity = reference_file_path.empty() ? 50 : 255;
5421+
if(
5422+
ImGui::ImageButton(
5423+
"remRefButton", editor_icons[EDITOR_ICON_REMOVE],
5424+
Point(ImGui::GetTextLineHeight()), Point(), Point(1.0f),
5425+
COLOR_EMPTY, map_alpha(rem_ref_opacity)
5426+
)
5427+
) {
5428+
reference_file_path.clear();
5429+
update_reference();
5430+
}
5431+
set_tooltip(
5432+
"Remove the reference image.\n"
5433+
"This does not delete the file on your disk."
5434+
);
53905435

53915436
//Browse for a reference image button.
5437+
ImGui::SameLine();
53925438
if(ImGui::Button("Browse...")) {
53935439
vector<string> f =
53945440
prompt_file_dialog(

source/source/game_state/particle_editor/gui.cpp

+30-7
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,30 @@ void ParticleEditor::process_gui_options_dialog() {
613613
if(use_bg) {
614614
ImGui::Indent();
615615

616+
//Remove background texture button.
617+
unsigned char rem_bg_opacity =
618+
game.options.particle_editor.bg_path.empty() ? 50 : 255;
619+
if(
620+
ImGui::ImageButton(
621+
"remBgButton", editor_icons[EDITOR_ICON_REMOVE],
622+
Point(ImGui::GetTextLineHeight()), Point(), Point(1.0f),
623+
COLOR_EMPTY, map_alpha(rem_bg_opacity)
624+
)
625+
) {
626+
game.options.particle_editor.bg_path.clear();
627+
if(bg) {
628+
al_destroy_bitmap(bg);
629+
bg = nullptr;
630+
}
631+
}
632+
set_tooltip(
633+
"Remove the background image.\n"
634+
"This does not delete the file on your disk."
635+
);
636+
616637
//Background texture browse button.
617-
if(ImGui::Button("Browse...", ImVec2(96.0f, 32.0f))) {
638+
ImGui::SameLine();
639+
if(ImGui::Button("Browse...")) {
618640
vector<string> f =
619641
prompt_file_dialog(
620642
FOLDER_PATHS_FROM_ROOT::BASE_PACK + "/" +
@@ -1091,10 +1113,13 @@ void ParticleEditor::process_gui_panel_generator() {
10911113
if(open_image_node) {
10921114

10931115
//Remove bitmap button.
1116+
unsigned char rem_bmp_opacity =
1117+
loaded_gen.base_particle.bmp_name.empty() ? 50 : 255;
10941118
if(
10951119
ImGui::ImageButton(
1096-
"removeBitmap", editor_icons[EDITOR_ICON_REMOVE],
1097-
Point(EDITOR::ICON_BMP_SIZE)
1120+
"remBmpButton", editor_icons[EDITOR_ICON_REMOVE],
1121+
Point(ImGui::GetTextLineHeight()), Point(), Point(1.0f),
1122+
COLOR_EMPTY, map_alpha(rem_bmp_opacity)
10981123
)
10991124
) {
11001125
//We can't have living particles with destroyed bitmaps,
@@ -1104,15 +1129,13 @@ void ParticleEditor::process_gui_panel_generator() {
11041129
changes_mgr.mark_as_changed();
11051130
}
11061131
set_tooltip(
1107-
"Removes the particles' image.\n"
1132+
"Remove the particles' image.\n"
11081133
"This makes the particles be circles."
11091134
);
11101135

11111136
//Choose image button.
11121137
ImGui::SameLine();
1113-
if(
1114-
ImGui::Button("Choose image...", ImVec2(0, 30))
1115-
) {
1138+
if(ImGui::Button("Choose image...")) {
11161139
open_bitmap_dialog(
11171140
[this] (const string &bmp) {
11181141
//We can't have living particles with destroyed bitmaps,

0 commit comments

Comments
 (0)