diff --git a/src/QFO2Tool/Edit_TILES_LST.cpp b/src/QFO2Tool/Edit_TILES_LST.cpp index ab490fd..01604ac 100644 --- a/src/QFO2Tool/Edit_TILES_LST.cpp +++ b/src/QFO2Tool/Edit_TILES_LST.cpp @@ -202,7 +202,7 @@ char* save_NEW_FRM_tiles_LST(tt_arr_handle* handle, char* game_path, export_stat bool success = io_create_path_from_file(save_path); if (!success) { - set_false(state); + state->set_false(); set_popup_warning( "Error: save_NEW_FRM_tiles_LST()\n" "Unable to create folders\n" @@ -271,7 +271,7 @@ char* check_FRM_LST_names(char* tiles_lst, tt_arr_handle* handle, export_state* if (append_new_only == false) { //append popup here ImGui::OpenPopup("Append to FRM LST"); - set_false(state); + state->set_false(); return NULL; } @@ -322,27 +322,6 @@ char* append_FRM_tiles_LST(char* old_FRM_LST, tt_arr_handle* handle, export_stat return final_FRM_LST; } -void set_false(export_state* state) -{ - state->auto_export = false; - state->export_proto = false; - state->export_pattern = false; - state->chk_game_path = false; - - state->make_FRM_LST = false; - state->make_PRO_LST = false; - state->make_PRO_MSG = false; - - state->load_files = false; - - state->loaded_FRM_LST = false; - state->loaded_PRO_LST = false; - state->loaded_PRO_MSG = false; - state->append_FRM_LST = false; - state->append_PRO_LST = false; - state->append_PRO_MSG = false; -} - bool load_FRM_tiles_LST(user_info* usr_nfo, export_state* state) { char* LST_path = state->LST_path; @@ -359,23 +338,7 @@ bool load_FRM_tiles_LST(user_info* usr_nfo, export_state* state) // to return NULL/nullptr ImGui::OpenPopup("Missing Files"); - state->auto_export = false; - state->export_proto = false; - state->export_pattern = false; - state->chk_game_path = false; - - state->make_FRM_LST = false; - state->make_PRO_LST = false; - state->make_PRO_MSG = false; - - state->load_files = false; - // state->loaded_FRM_LST = false; - // state->loaded_PRO_LST = false; - // state->loaded_PRO_MSG = false; - - state->append_FRM_LST = false; - state->append_PRO_LST = false; - state->append_PRO_MSG = false; + state->load_frm_tiles_list_failed(); printf("Unable to load /art/tiles/TILES.LST...\nCreating new one...\n"); return false; @@ -469,9 +432,7 @@ void append_FRM_tiles_POPUP(user_info* usr_nfo, tt_arr_handle* handle, export_st if (!auto_export) { if (ImGui::Button("Append to art/tiles/TILES.LST")) { - state->chk_game_path = true; - state->load_files = true; - state->append_FRM_LST = true; + state->append_to_art_tiles_clicked(); } } @@ -485,7 +446,7 @@ void append_FRM_tiles_POPUP(user_info* usr_nfo, tt_arr_handle* handle, export_st //copy any game_path changes to user_info for saving to config if (fallout2exe_exists(FObuff) == false) { ImGui::OpenPopup("fallout2.exe not found"); - set_false(state); + state->set_false(); return; } strncpy(usr_nfo->default_game_path, FObuff, MAX_PATH); diff --git a/src/QFO2Tool/Edit_TILES_LST.h b/src/QFO2Tool/Edit_TILES_LST.h index bf6f5b9..ec4ef91 100644 --- a/src/QFO2Tool/Edit_TILES_LST.h +++ b/src/QFO2Tool/Edit_TILES_LST.h @@ -28,6 +28,198 @@ struct export_state { bool append_FRM_LST = false; bool append_PRO_LST = false; bool append_PRO_MSG = false; + + void set_false() + { + auto_export = false; + export_proto = false; + export_pattern = false; + chk_game_path = false; + + make_FRM_LST = false; + make_PRO_LST = false; + make_PRO_MSG = false; + + load_files = false; + + loaded_FRM_LST = false; + loaded_PRO_LST = false; + loaded_PRO_MSG = false; + append_FRM_LST = false; + append_PRO_LST = false; + append_PRO_MSG = false; + } + + void load_frm_tiles_list_failed() { + auto_export = false; + export_proto = false; + export_pattern = false; + chk_game_path = false; + + make_FRM_LST = false; + make_PRO_LST = false; + make_PRO_MSG = false; + + load_files = false; + // loaded_FRM_LST = false; + // loaded_PRO_LST = false; + // loaded_PRO_MSG = false; + + append_FRM_LST = false; + append_PRO_LST = false; + append_PRO_MSG = false; + } + + void create_new_files_clicked() { + if (loaded_FRM_LST == false) { + make_FRM_LST = true; + } + else { + append_FRM_LST = true; + } + + if (loaded_PRO_LST == false) { + make_PRO_LST = true; + } + else { + append_PRO_LST = true; + } + + if (loaded_PRO_MSG == false) { + make_PRO_MSG = true; + } + else { + append_PRO_MSG = true; + } + + export_proto = true; + } + + void append_to_frm_tiles_list_clicked() { + auto_export = true; + + if (art) { + load_files = true; + append_FRM_LST = true; + } + if (pro) { + export_proto = true; + append_PRO_LST = true; + append_PRO_MSG = true; + } + if (pat) { + export_pattern = true; + } + } + + void append_to_pro_tiles_list_clicked() { + auto_export = true; + + // if (art) { + // load_files = true; + // append_FRM_LST = true; + // } + if (pro) { + export_proto = true; + append_PRO_LST = true; + append_PRO_MSG = true; + } + if (pat) { + export_pattern = true; + } + } + + void append_to_msg_tiles_list_clicked() { + auto_export = true; + // append_FRM_LST = true; + // append_PRO_LST = true; + append_PRO_MSG = true; + } + + void create_new_pro_list_clicked() { + make_PRO_LST = true; + append_PRO_MSG = true; + export_proto = true; + } + + void create_new_frm_list_clicked() { + make_FRM_LST = true; + append_PRO_MSG = true; + export_proto = true; + } + + void pro_tiles_msg_failed_to_load() { + auto_export = false; + export_proto = false; + export_pattern = false; + chk_game_path = false; + + make_FRM_LST = false; + make_PRO_LST = false; + make_PRO_MSG = false; + + load_files = false; + // loaded_FRM_LST = false; + // loaded_PRO_LST = false; + // loaded_PRO_MSG = false; + + append_FRM_LST = false; + append_PRO_LST = false; + append_PRO_MSG = false; + } + + void pro_tiles_lst_failed_to_load() { + auto_export = false; + export_proto = false; + export_pattern = false; + chk_game_path = false; + + make_FRM_LST = false; + make_PRO_LST = false; + make_PRO_MSG = false; + + load_files = false; + // loaded_FRM_LST = false; + // loaded_PRO_LST = false; + // loaded_PRO_MSG = false; + + append_FRM_LST = false; + append_PRO_LST = false; + append_PRO_MSG = false; + } + + void add_to_fallout_2_clicked() { + export_proto = true; + + load_files = true; + + // append_FRM_LST = true; + append_PRO_LST = true; + append_PRO_MSG = true; + + chk_game_path = true; + } + + void auto_export_all_clicked() { + if (art) { + load_files = true; + append_FRM_LST = true; + } + if (pro) { + export_proto = true; + append_PRO_LST = true; + append_PRO_MSG = true; + } + if (pat) { + export_pattern = true; + } + } + + void append_to_art_tiles_clicked() { + chk_game_path = true; + load_files = true; + append_FRM_LST = true; + } }; struct tile_name { @@ -49,6 +241,5 @@ char* save_NEW_FRM_tiles_LST(tt_arr_handle* handle, char* save_path, export_stat char* load_LST_file(char* game_path, char* LST_path, char* LST_file); char* append_FRM_tiles_LST(char* tiles_lst_path, tt_arr_handle* handle, export_state* state); bool load_FRM_tiles_LST(user_info* usr_nfo, export_state* cur_state); -void set_false(export_state* cur_state); char* check_FRM_LST_names(char* tiles_lst, tt_arr_handle* handle, export_state* state); void append_FRM_tiles_POPUP(user_info* usr_nfo, tt_arr_handle* handle, export_state* state, bool auto_export); diff --git a/src/QFO2Tool/Preview_Tiles.cpp b/src/QFO2Tool/Preview_Tiles.cpp index 44175be..ef2491e 100644 --- a/src/QFO2Tool/Preview_Tiles.cpp +++ b/src/QFO2Tool/Preview_Tiles.cpp @@ -313,7 +313,7 @@ void export_button_table(tt_arr_handle* exported_tiles, user_info* usr_nfo, expo { append_FRM_tiles_POPUP(usr_nfo, exported_tiles, state, false); if (ImGui::Button("Close")) { - set_false(state); + state->set_false(); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); @@ -325,7 +325,7 @@ void export_button_table(tt_arr_handle* exported_tiles, user_info* usr_nfo, expo { export_PRO_tiles_POPUP(usr_nfo, exported_tiles, state, false); if (ImGui::Button("Close")) { - set_false(state); + state->set_false(); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); @@ -336,7 +336,7 @@ void export_button_table(tt_arr_handle* exported_tiles, user_info* usr_nfo, expo { export_PAT_file_POPUP(usr_nfo, exported_tiles, state, false); if (ImGui::Button("Close")) { - set_false(state); + state->set_false(); ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); @@ -363,24 +363,13 @@ tt_arr_handle* TMAP_tile_buttons(user_info* usr_nfo, Surface* srfc, Rect* offset if (ImGui::BeginPopupModal("Export Tiles", &close_x, ImGuiChildFlags_AutoResizeY)) { if (state.art || state.pro || state.pat) { if (ImGui::Button("Auto Export All")) { - if (state.art) { - state.load_files = true; - state.append_FRM_LST = true; - } - if (state.pro) { - state.export_proto = true; - state.append_PRO_LST = true; - state.append_PRO_MSG = true; - } - if (state.pat) { - state.export_pattern = true; - } + state.auto_export_all_clicked(); save_folder_dialog(usr_nfo); } } if (ImGui::Button("Close")) { - set_false(&state); + state.set_false(); ImGui::CloseCurrentPopup(); } @@ -400,7 +389,7 @@ tt_arr_handle* TMAP_tile_buttons(user_info* usr_nfo, Surface* srfc, Rect* offset if (state.pat) { export_PAT_file_POPUP(usr_nfo, exported_tiles, &state, state.pat); } - set_false(&state); + state.set_false(); ImGui::EndPopup(); } diff --git a/src/QFO2Tool/Proto_Files.cpp b/src/QFO2Tool/Proto_Files.cpp index accf912..5ce75dd 100644 --- a/src/QFO2Tool/Proto_Files.cpp +++ b/src/QFO2Tool/Proto_Files.cpp @@ -227,11 +227,7 @@ void append_to_MSG(export_state* state) , state->LST_path ); if (ImGui::Button("Append to TILES.LST")) { - state->auto_export = true; - // state->append_FRM_LST = true; - // state->append_PRO_LST = true; - state->append_PRO_MSG = true; - + state->append_to_msg_tiles_list_clicked(); ImGui::CloseCurrentPopup(); } if (ImGui::Button("Cancel")) { @@ -253,21 +249,7 @@ void append_to_FRM_LST(export_state* state) , state->LST_path ); if (ImGui::Button("Append to TILES.LST")) { - state->auto_export = true; - - if (state->art) { - state->load_files = true; - state->append_FRM_LST = true; - } - if (state->pro) { - state->export_proto = true; - state->append_PRO_LST = true; - state->append_PRO_MSG = true; - } - if (state->pat) { - state->export_pattern = true; - } - + state->append_to_frm_tiles_list_clicked(); ImGui::CloseCurrentPopup(); } if (ImGui::Button("Cancel")) { @@ -289,21 +271,7 @@ void append_to_PRO_LST(export_state* state) , state->LST_path ); if (ImGui::Button("Append to TILES.LST")) { - state->auto_export = true; - - // if (state->art) { - // state->load_files = true; - // state->append_FRM_LST = true; - // } - if (state->pro) { - state->export_proto = true; - state->append_PRO_LST = true; - state->append_PRO_MSG = true; - } - if (state->pat) { - state->export_pattern = true; - } - + state->append_to_pro_tiles_list_clicked(); ImGui::CloseCurrentPopup(); } if (ImGui::Button("Cancel")) { @@ -374,25 +342,7 @@ bool missing_files_popup(export_state* state) , art,pro,msg//,language[0] ); if (ImGui::Button("Create new files?")) { - if (state->loaded_FRM_LST == false) { - state->make_FRM_LST = true; - } else { - state->append_FRM_LST = true; - } - - if (state->loaded_PRO_LST == false) { - state->make_PRO_LST = true; - } else { - state->append_PRO_LST = true; - } - - if (state->loaded_PRO_MSG == false) { - state->make_PRO_MSG = true; - } else { - state->append_PRO_MSG = true; - } - - state->export_proto = true; + state->create_new_files_clicked(); ImGui::CloseCurrentPopup(); return true; } @@ -619,7 +569,7 @@ char* save_NEW_PRO_tile_MSG(tt_arr_handle* handle, user_info* usr_nfo, export_st bool success = io_create_path_from_file(save_path); if (!success) { - set_false(state); + state->set_false(); set_popup_warning( "Error: save_NEW_FRM_tiles_LST()\n" "Unable to create folders\n" @@ -656,7 +606,7 @@ char* save_NEW_PRO_tiles_LST(tt_arr_handle* handle, user_info* usr_nfo, export_s bool success = io_create_path_from_file(save_path); if (!success) { - set_false(state); + state->set_false(); set_popup_warning( "Error: save_NEW_FRM_tiles_LST()\n" "Unable to create folders\n" @@ -708,9 +658,7 @@ bool create_PRO_tiles_LST_popup(export_state* state) , lst_path ); if (ImGui::Button("Create new LST file?")) { - state->make_PRO_LST = true; - state->append_PRO_MSG = true; - state->export_proto = true; + state->create_new_pro_list_clicked(); return true; } @@ -759,9 +707,7 @@ bool create_FRM_tiles_LST_popup(export_state* state) , lst_path ); if (ImGui::Button("Create new LST file?")) { - state->make_FRM_LST = true; - state->append_PRO_MSG = true; - state->export_proto = true; + state->create_new_frm_list_clicked(); return true; } @@ -845,23 +791,7 @@ bool load_PRO_tiles_MSG(user_info* usr_nfo, export_state* state) ImGui::OpenPopup("Missing Files"); - state->auto_export = false; - state->export_proto = false; - state->export_pattern = false; - state->chk_game_path = false; - - state->make_FRM_LST = false; - state->make_PRO_LST = false; - state->make_PRO_MSG = false; - - state->load_files = false; - // state->loaded_FRM_LST = false; - // state->loaded_PRO_LST = false; - // state->loaded_PRO_MSG = false; - - state->append_FRM_LST = false; - state->append_PRO_LST = false; - state->append_PRO_MSG = false; + state->pro_tiles_msg_failed_to_load(); printf("Unable to load /proto/tiles/TILES.LST...\nCreating new one...\n"); return false; @@ -891,23 +821,7 @@ bool load_PRO_tiles_LST(user_info* usr_nfo, export_state* state) ImGui::OpenPopup("Missing Files"); - state->auto_export = false; - state->export_proto = false; - state->export_pattern = false; - state->chk_game_path = false; - - state->make_FRM_LST = false; - state->make_PRO_LST = false; - state->make_PRO_MSG = false; - - state->load_files = false; - // state->loaded_FRM_LST = false; - // state->loaded_PRO_LST = false; - // state->loaded_PRO_MSG = false; - - state->append_FRM_LST = false; - state->append_PRO_LST = false; - state->append_PRO_MSG = false; + state->pro_tiles_lst_failed_to_load(); printf("Unable to load /proto/tiles/TILES.LST...\nCreating new one...\n"); return false; @@ -971,15 +885,7 @@ void export_PRO_tiles_POPUP(user_info* usr_nfo, tt_arr_handle* handle, export_st if (!auto_export) { if (ImGui::Button("Add to Fallout 2")) { - state->export_proto = true; - - state->load_files = true; - - // state->append_FRM_LST = true; - state->append_PRO_LST = true; - state->append_PRO_MSG = true; - - state->chk_game_path = true; + state->add_to_fallout_2_clicked(); } export_tiles_POPUPS(state, FObuff); } @@ -1013,7 +919,7 @@ void export_PRO_tiles_POPUP(user_info* usr_nfo, tt_arr_handle* handle, export_st //copy any game_path changes to user_info for saving to config if (fallout2exe_exists(FObuff) == false) { ImGui::OpenPopup("fallout2.exe not found"); - set_false(state); + state->set_false(); return; } strncpy(usr_nfo->default_game_path, FObuff, MAX_PATH); @@ -1060,7 +966,7 @@ void export_PRO_tiles_POPUP(user_info* usr_nfo, tt_arr_handle* handle, export_st //append to art/tiles/TILES.LST success = append_TMAP_tiles_LST(usr_nfo, handle, state); if (!success) { - set_false(state); + state->set_false(); return; } } @@ -1068,7 +974,7 @@ void export_PRO_tiles_POPUP(user_info* usr_nfo, tt_arr_handle* handle, export_st //append to proto/tiles/TILES.LST success = append_TMAP_PRO_tiles_LST(usr_nfo, handle, state); if (!success) { - set_false(state); + state->set_false(); return; } } @@ -1079,7 +985,7 @@ void export_PRO_tiles_POPUP(user_info* usr_nfo, tt_arr_handle* handle, export_st //add name/description to data/text/english/game/pro_tile.msg success = append_PRO_tile_MSG(usr_nfo, NULL, handle); if (!success) { - set_false(state); + state->set_false(); return; } }