implement FR bug #13172...

...(output a WML-style list of selected tiles from the editor). Uses
the system clipboard.
This commit is contained in:
Tomasz Śniatowski 2009-03-22 00:25:29 +01:00
parent fb90b8dc87
commit b358e4611e
5 changed files with 29 additions and 1 deletions

View file

@ -130,7 +130,7 @@
id=menu-editor-edit
title= _ "Edit"
image=lite
items=undo,redo,editor-cut,editor-copy,editor-paste, editor-select-all,editor-select-inverse,editor-select-none, editor-selection-fill,editor-selection-rotate,editor-selection-flip, editor-selection-generate,editor-selection-randomize, editor-clipboard-rotate-cw,editor-clipboard-rotate-ccw, editor-clipboard-flip-horizontal,editor-clipboard-flip-vertical
items=undo,redo,editor-cut,editor-copy,editor-paste,editor-export-selection-coords,editor-select-all,editor-select-inverse,editor-select-none, editor-selection-fill,editor-selection-rotate,editor-selection-flip, editor-selection-generate,editor-selection-randomize, editor-clipboard-rotate-cw,editor-clipboard-rotate-ccw, editor-clipboard-flip-horizontal,editor-clipboard-flip-vertical
rect="+2,=,+100,="
xanchor=fixed
yanchor=fixed

View file

@ -25,6 +25,7 @@
#include "gui/dialogs/editor_settings.hpp"
#include "gui/widgets/window.hpp"
#include "../clipboard.hpp"
#include "../config_adapter.hpp"
#include "../filechooser.hpp"
#include "../filesystem.hpp"
@ -770,6 +771,7 @@ bool editor_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int
return true; //tool selection always possible
case HOTKEY_EDITOR_CUT:
case HOTKEY_EDITOR_COPY:
case HOTKEY_EDITOR_EXPORT_SELECTION_COORDS:
case HOTKEY_EDITOR_SELECTION_FILL:
case HOTKEY_EDITOR_SELECTION_RANDOMIZE:
return !get_map().selection().empty();
@ -896,6 +898,9 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde
case HOTKEY_EDITOR_CUT:
cut_selection();
return true;
case HOTKEY_EDITOR_EXPORT_SELECTION_COORDS:
export_selection_coords();
return true;
case HOTKEY_EDITOR_SELECT_ALL:
if (!get_map().everything_selected()) {
perform_refresh(editor_action_select_all());
@ -1071,6 +1076,24 @@ void editor_controller::cut_selection()
perform_refresh(editor_action_paint_area(get_map().selection(), background_terrain_));
}
void editor_controller::export_selection_coords()
{
std::stringstream ssx, ssy;
std::set<map_location>::const_iterator i = get_map().selection().begin();
if (i != get_map().selection().end()) {
ssx << "x = " << i->x + 1;
ssy << "y = " << i->y + 1;
++i;
while (i != get_map().selection().end()) {
ssx << ", " << i->x + 1;
ssy << ", " << i->y + 1;
++i;
}
ssx << "\n" << ssy.str() << "\n";
copy_to_clipboard(ssx.str(), false);
}
}
void editor_controller::fill_selection()
{
perform_refresh(editor_action_paint_area(get_map().selection(), foreground_terrain_));

View file

@ -212,6 +212,9 @@ class editor_controller : public controller_base,
/** Cut the selection from the current map to the clipboard */
void cut_selection();
/** Export the WML-compatible list of selected tiles to the system clipboard */
void export_selection_coords();
/** Fill the selection with the foreground terrain */
void fill_selection();

View file

@ -124,6 +124,7 @@ const struct {
{ hotkey::HOTKEY_EDITOR_CUT, "editor-cut", N_("Cut"), false, hotkey::SCOPE_EDITOR },
{ hotkey::HOTKEY_EDITOR_COPY, "editor-copy", N_("Copy"), false, hotkey::SCOPE_EDITOR },
{ hotkey::HOTKEY_EDITOR_PASTE, "editor-paste", N_("Paste"), false, hotkey::SCOPE_EDITOR },
{ hotkey::HOTKEY_EDITOR_EXPORT_SELECTION_COORDS, "editor-export-selection-coords", N_("Export selected coordinates to system clipboard"), false, hotkey::SCOPE_EDITOR },
{ hotkey::HOTKEY_EDITOR_SELECT_ALL, "editor-select-all",
N_("Select All"), false, hotkey::SCOPE_EDITOR },
{ hotkey::HOTKEY_EDITOR_SELECT_INVERSE, "editor-select-inverse",

View file

@ -73,6 +73,7 @@ enum HOTKEY_COMMAND {
HOTKEY_EDITOR_TOOL_SELECT, HOTKEY_EDITOR_TOOL_STARTING_POSITION,
HOTKEY_EDITOR_BRUSH_NEXT, HOTKEY_EDITOR_BRUSH_DEFAULT,
HOTKEY_EDITOR_CUT, HOTKEY_EDITOR_COPY, HOTKEY_EDITOR_PASTE,
HOTKEY_EDITOR_EXPORT_SELECTION_COORDS,
HOTKEY_EDITOR_SELECT_ALL, HOTKEY_EDITOR_SELECT_INVERSE,
HOTKEY_EDITOR_SELECT_NONE,
HOTKEY_EDITOR_CLIPBOARD_ROTATE_CW, HOTKEY_EDITOR_CLIPBOARD_ROTATE_CCW,