Feature #1587 » 0081-optiondlgs-Automatically-apply-options-before-saving.patch
| client/gui-gtk-3.22/optiondlg.c | ||
|---|---|---|
|     option_dialog_foreach(pdialog, option_dialog_option_refresh); | ||
|     break; | ||
|   case RESPONSE_SAVE: | ||
|     desired_settable_options_update(); | ||
|     options_save(NULL); | ||
|     option_dialog_foreach(pdialog, option_dialog_option_apply); | ||
|     queue_options_save(NULL); | ||
|     break; | ||
|   } | ||
| } | ||
| client/gui-gtk-4.0/optiondlg.c | ||
|---|---|---|
|     option_dialog_foreach(pdialog, option_dialog_option_refresh); | ||
|     break; | ||
|   case RESPONSE_SAVE: | ||
|     desired_settable_options_update(); | ||
|     options_save(NULL); | ||
|     option_dialog_foreach(pdialog, option_dialog_option_apply); | ||
|     queue_options_save(NULL); | ||
|     break; | ||
|   } | ||
| } | ||
| client/gui-gtk-5.0/optiondlg.c | ||
|---|---|---|
|     option_dialog_foreach(pdialog, option_dialog_option_refresh); | ||
|     break; | ||
|   case RESPONSE_SAVE: | ||
|     desired_settable_options_update(); | ||
|     options_save(NULL); | ||
|     option_dialog_foreach(pdialog, option_dialog_option_apply); | ||
|     queue_options_save(NULL); | ||
|     break; | ||
|   } | ||
| } | ||
| client/gui-qt/optiondlg.cpp | ||
|---|---|---|
|     close(); | ||
|     break; | ||
|   case RESPONSE_SAVE: | ||
|     desired_settable_options_update(); | ||
|     options_save(nullptr); | ||
|     apply_options(); | ||
|     queue_options_save(nullptr); | ||
|     break; | ||
|   case RESPONSE_RESET: | ||
|     full_reset(); | ||
| client/options.c | ||
|---|---|---|
| static bool options_fully_initialized = FALSE; | ||
| static int sync_serial = 0; | ||
| static int reply_serial = 0; | ||
| static bool queue_save = FALSE; | ||
| static option_save_log_callback queued_cb; | ||
| static const struct strvec *get_mapimg_format_list(const struct option *poption); | ||
| ... | ... | |
| } | ||
| /************************************************************************//** | ||
|   Set the option to its default value.  Returns TRUE if the option changed. | ||
|   Set the option to its default value. Returns TRUE if the option changed. | ||
| ****************************************************************************/ | ||
| bool option_reset(struct option *poption) | ||
| { | ||
| ... | ... | |
| } | ||
| /************************************************************************//** | ||
|   Set the value of this server option of type OT_BOOLEAN.  Returns TRUE if | ||
|   Set the value of this server option of type OT_BOOLEAN. Returns TRUE if | ||
|   the value changed. | ||
| ****************************************************************************/ | ||
| static bool server_option_bool_set(struct option *poption, bool val) | ||
| ... | ... | |
|   send_chat_printf("/set %s %s", psoption->name, | ||
|                    val ? "enabled" : "disabled"); | ||
|   dsend_packet_sync_serial(&client.conn, ++sync_serial); | ||
|   return TRUE; | ||
| } | ||
| ... | ... | |
|   } | ||
|   send_chat_printf("/set %s %d", psoption->name, val); | ||
|   dsend_packet_sync_serial(&client.conn, ++sync_serial); | ||
|   return TRUE; | ||
| } | ||
| ... | ... | |
|   } | ||
|   send_chat_printf("/set %s \"%s\"", psoption->name, str); | ||
|   dsend_packet_sync_serial(&client.conn, ++sync_serial); | ||
|   return TRUE; | ||
| } | ||
| ... | ... | |
|   } | ||
|   send_chat_printf("/set %s \"%s\"", psoption->name, name); | ||
|   dsend_packet_sync_serial(&client.conn, ++sync_serial); | ||
|   return TRUE; | ||
| } | ||
| ... | ... | |
|   server_option_bitwise_support_base(psoption->bitwise.support_names, val, | ||
|                                      name, sizeof(name)); | ||
|   send_chat_printf("/set %s \"%s\"", psoption->name, name); | ||
|   dsend_packet_sync_serial(&client.conn, ++sync_serial); | ||
|   return TRUE; | ||
| } | ||
| ... | ... | |
|   va_end(args); | ||
| } | ||
| /************************************************************************//** | ||
|   Save the options as soon as they have been synced with the server. | ||
| ****************************************************************************/ | ||
| void queue_options_save(option_save_log_callback log_cb) | ||
| { | ||
|   if (reply_serial >= sync_serial) { | ||
|     /* We've already got reply to the latest options sync request */ | ||
|     log_debug("Options save immediate (%d vs %d)", sync_serial, reply_serial); | ||
|     desired_settable_options_update(); | ||
|     options_save(log_cb); | ||
|   } else { | ||
|     log_debug("Options save queued (%d vs %d)", sync_serial, reply_serial); | ||
|     queue_save = TRUE; | ||
|     queued_cb = log_cb; | ||
|   } | ||
| } | ||
| /************************************************************************//** | ||
|   Server has replied to some sync request | ||
| ****************************************************************************/ | ||
| void options_sync_reply(int serial) | ||
| { | ||
|   reply_serial = serial; | ||
|   if (queue_save && reply_serial >= sync_serial) { | ||
|     log_debug("Pop queued options saving."); | ||
|     desired_settable_options_update(); | ||
|     options_save(queued_cb); | ||
|   } | ||
| } | ||
| /************************************************************************//** | ||
|   Save all options. | ||
| ****************************************************************************/ | ||
| ... | ... | |
|   char dir_name[2048]; | ||
|   int i; | ||
|   queue_save = FALSE; | ||
|   if (log_cb == NULL) { | ||
|     /* Default callback */ | ||
|     log_cb = option_save_output_window_callback; | ||
| client/options.h | ||
|---|---|---|
| void server_options_init(void); | ||
| void server_options_free(void); | ||
| void options_load(void); | ||
| void queue_options_save(option_save_log_callback log_cb); | ||
| void options_save(option_save_log_callback log_cb); | ||
| void options_sync_reply(int serial); | ||
| /* Option sets. */ | ||
| extern const struct option_set *client_optset; | ||
| client/packhand.c | ||
|---|---|---|
| **************************************************************************/ | ||
| void handle_sync_serial_reply(int serial) | ||
| { | ||
|   options_sync_reply(serial); | ||
| } | ||