DDNet documentation
Loading...
Searching...
No Matches
quick_actions.h
Go to the documentation of this file.
1// This file can be included several times.
2
3#ifndef REGISTER_QUICK_ACTION
4// This helps IDEs properly syntax highlight the uses of the macro below.
5#define REGISTER_QUICK_ACTION(name, text, callback, disabled, active, button_color, description)
6#endif
7
8#define ALWAYS_FALSE []() -> bool { return false; }
9#define DEFAULT_BTN []() -> int { return -1; }
10
12 ShowHelp,
13 "Show help",
14 [&]() { ShowHelp(); },
18 "[F1] Open the DDNet Wiki page for the map editor in a web browser.")
20 BrushPicker,
21 "Brush picker",
22 [&]() { m_ShowPickerToggle = !m_ShowPickerToggle; },
23 [&]() -> bool {
24 return m_Mode != MODE_LAYERS ||
25 Map()->m_vSelectedLayers.size() != 1 ||
26 Map()->SelectedLayer(0) == nullptr ||
27 (Map()->SelectedLayer(0)->m_Type != LAYERTYPE_TILES && Map()->SelectedLayer(0)->m_Type != LAYERTYPE_QUADS);
28 },
29 [&]() -> bool { return m_ShowPickerToggle; },
31 "[Ctrl+Space, Hold Space] Toggle brush picker.")
33 ToggleGrid,
34 "Toggle grid",
35 [&]() { MapView()->MapGrid()->Toggle(); },
37 [&]() -> bool { return MapView()->MapGrid()->IsEnabled(); },
39 "[Ctrl+G] Toggle grid.")
41 GameTilesAir,
42 "Game tiles: Air",
43 [&]() { FillGameTiles(EGameTileOp::AIR); },
44 [&]() -> bool { return !CanFillGameTiles(); },
47 "Construct game tiles from this layer.")
49 GameTilesHookable,
50 "Game tiles: Hookable",
51 [&]() { FillGameTiles(EGameTileOp::HOOKABLE); },
52 [&]() -> bool { return !CanFillGameTiles(); },
55 "Construct game tiles from this layer.")
57 GameTilesDeath,
58 "Game tiles: Death",
59 [&]() { FillGameTiles(EGameTileOp::DEATH); },
60 [&]() -> bool { return !CanFillGameTiles(); },
63 "Construct game tiles from this layer.")
65 GameTilesUnhookable,
66 "Game tiles: Unhookable",
67 [&]() { FillGameTiles(EGameTileOp::UNHOOKABLE); },
68 [&]() -> bool { return !CanFillGameTiles(); },
71 "Construct game tiles from this layer.")
73 GameTilesHookthrough,
74 "Game tiles: Hookthrough",
75 [&]() { FillGameTiles(EGameTileOp::HOOKTHROUGH); },
76 [&]() -> bool { return !CanFillGameTiles(); },
79 "Construct game tiles from this layer.")
81 GameTilesFreeze,
82 "Game tiles: Freeze",
83 [&]() { FillGameTiles(EGameTileOp::FREEZE); },
84 [&]() -> bool { return !CanFillGameTiles(); },
87 "Construct game tiles from this layer.")
89 GameTilesUnfreeze,
90 "Game tiles: Unfreeze",
91 [&]() { FillGameTiles(EGameTileOp::UNFREEZE); },
92 [&]() -> bool { return !CanFillGameTiles(); },
95 "Construct game tiles from this layer.")
97 GameTilesDeepFreeze,
98 "Game tiles: Deep Freeze",
99 [&]() { FillGameTiles(EGameTileOp::DEEP_FREEZE); },
100 [&]() -> bool { return !CanFillGameTiles(); },
103 "Construct game tiles from this layer.")
105 GameTilesDeepUnfreeze,
106 "Game tiles: Deep Unfreeze",
107 [&]() { FillGameTiles(EGameTileOp::DEEP_UNFREEZE); },
108 [&]() -> bool { return !CanFillGameTiles(); },
111 "Construct game tiles from this layer.")
113 GameTilesBlueCheckTele,
114 "Game tiles: Blue Check Tele",
115 [&]() { FillGameTiles(EGameTileOp::BLUE_CHECK_TELE); },
116 [&]() -> bool { return !CanFillGameTiles(); },
119 "Construct game tiles from this layer.")
121 GameTilesRedCheckTele,
122 "Game tiles: Red Check Tele",
123 [&]() { FillGameTiles(EGameTileOp::RED_CHECK_TELE); },
124 [&]() -> bool { return !CanFillGameTiles(); },
127 "Construct game tiles from this layer.")
129 GameTilesLiveFreeze,
130 "Game tiles: Live Freeze",
131 [&]() { FillGameTiles(EGameTileOp::LIVE_FREEZE); },
132 [&]() -> bool { return !CanFillGameTiles(); },
135 "Construct game tiles from this layer.")
137 GameTilesLiveUnfreeze,
138 "Game tiles: Live Unfreeze",
139 [&]() { FillGameTiles(EGameTileOp::LIVE_UNFREEZE); },
140 [&]() -> bool { return !CanFillGameTiles(); },
143 "Construct game tiles from this layer.")
145 AddGroup,
146 "Add group",
147 [&]() { AddGroup(); },
151 "Add a new group.")
153 ResetZoom,
154 "Reset zoom",
155 [&]() { MapView()->ResetZoom(); },
159 "[Numpad*] Zoom to normal and remove editor offset.")
161 ZoomOut,
162 "Zoom out",
163 [&]() { MapView()->Zoom()->ScaleValue(1.331f); },
167 "[Numpad-] Zoom out.")
169 ZoomIn,
170 "Zoom in",
171 [&]() { MapView()->Zoom()->ScaleValue(1.0f / 1.331f); },
175 "[Numpad+] Zoom in.")
177 Refocus,
178 "Refocus",
179 [&]() { MapView()->Focus(); },
183 "[Home] Restore map focus.")
185 Proof,
186 "Proof",
187 [&]() { MapView()->ProofMode()->Toggle(); },
189 [&]() -> bool { return MapView()->ProofMode()->IsEnabled(); },
191 "Toggle proof borders. These borders represent the area that a player can see with default zoom.")
193 AddTileLayer, "Add tile layer", [&]() { AddTileLayer(); }, ALWAYS_FALSE, ALWAYS_FALSE, DEFAULT_BTN, "Create a new tile layer.")
195 AddSwitchLayer,
196 "Add switch layer",
197 [&]() { AddSwitchLayer(); },
198 [&]() -> bool { return !Map()->SelectedGroup()->m_GameGroup || Map()->m_pSwitchLayer; },
201 "Create a new switch layer.")
203 AddTuneLayer,
204 "Add tune layer",
205 [&]() { AddTuneLayer(); },
206 [&]() -> bool { return !Map()->SelectedGroup()->m_GameGroup || Map()->m_pTuneLayer; },
209 "Create a new tuning layer.")
211 AddSpeedupLayer,
212 "Add speedup layer",
213 [&]() { AddSpeedupLayer(); },
214 [&]() -> bool { return !Map()->SelectedGroup()->m_GameGroup || Map()->m_pSpeedupLayer; },
217 "Create a new speedup layer.")
219 AddTeleLayer,
220 "Add tele layer",
221 [&]() { AddTeleLayer(); },
222 [&]() -> bool { return !Map()->SelectedGroup()->m_GameGroup || Map()->m_pTeleLayer; },
225 "Create a new tele layer.")
227 AddFrontLayer,
228 "Add front layer",
229 [&]() { AddFrontLayer(); },
230 [&]() -> bool { return !Map()->SelectedGroup()->m_GameGroup || Map()->m_pFrontLayer; },
233 "Create a new item layer.")
235 AddQuadsLayer, "Add quads layer", [&]() { AddQuadsLayer(); }, ALWAYS_FALSE, ALWAYS_FALSE, DEFAULT_BTN, "Create a new quads layer.")
237 AddSoundLayer, "Add sound layer", [&]() { AddSoundLayer(); }, ALWAYS_FALSE, ALWAYS_FALSE, DEFAULT_BTN, "Create a new sound layer.")
239 SaveAs,
240 "Save as",
241 [&]() {
242 char aDefaultName[IO_MAX_PATH_LENGTH];
243 fs_split_file_extension(fs_filename(Map()->m_aFilename), aDefaultName, sizeof(aDefaultName));
244 m_FileBrowser.ShowFileDialog(IStorage::TYPE_SAVE, CFileBrowser::EFileType::MAP, "Save map", "Save as", "maps", aDefaultName, CallbackSaveMap, this);
245 },
249 "[Ctrl+Shift+S] Save the current map under a new name.")
251 LoadCurrentMap,
252 "Load current map",
253 [&]() {
254 if(HasUnsavedData())
255 {
256 if(!m_PopupEventWasActivated)
257 {
258 m_PopupEventType = POPEVENT_LOADCURRENT;
259 m_PopupEventActivated = true;
260 }
261 }
262 else
263 {
264 LoadCurrentMap();
265 }
266 },
267 [&]() -> bool { return Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK; },
270 "[Ctrl+Shift+L] Open the current ingame map for editing.")
272 Envelopes,
273 "Envelopes",
274 [&]() { m_ActiveExtraEditor = m_ActiveExtraEditor == EXTRAEDITOR_ENVELOPES ? EXTRAEDITOR_NONE : EXTRAEDITOR_ENVELOPES; },
277 [&]() -> int { return m_ShowPicker ? -1 : m_ActiveExtraEditor == EXTRAEDITOR_ENVELOPES; },
278 "Toggle the envelope editor.")
280 ServerSettings,
281 "Server settings",
282 [&]() { m_ActiveExtraEditor = m_ActiveExtraEditor == EXTRAEDITOR_SERVER_SETTINGS ? EXTRAEDITOR_NONE : EXTRAEDITOR_SERVER_SETTINGS; },
285 [&]() -> int { return m_ShowPicker ? -1 : m_ActiveExtraEditor == EXTRAEDITOR_SERVER_SETTINGS; },
286 "Toggle the server settings editor.")
288 History,
289 "History",
290 [&]() { m_ActiveExtraEditor = m_ActiveExtraEditor == EXTRAEDITOR_HISTORY ? EXTRAEDITOR_NONE : EXTRAEDITOR_HISTORY; },
293 [&]() -> int { return m_ShowPicker ? -1 : m_ActiveExtraEditor == EXTRAEDITOR_HISTORY; },
294 "Toggle the editor history view.")
296 AddImage,
297 "Add image",
298 [&]() { m_FileBrowser.ShowFileDialog(IStorage::TYPE_ALL, CFileBrowser::EFileType::IMAGE, "Add image", "Add", "mapres", "", AddImage, this); },
302 "Load a new image to use in the map.")
304 LayerPropAddImage,
305 "Layer: add image",
306 [&]() { LayerSelectImage(); },
307 [&]() -> bool { return !IsNonGameTileLayerSelected(); },
310 "Pick mapres image for currently selected layer.")
312 ShowInfoOff,
313 "Show info: Off",
314 [&]() {
315 m_ShowTileInfo = SHOW_TILE_OFF;
316 },
318 [&]() -> bool { return m_ShowTileInfo == SHOW_TILE_OFF; },
320 "Do not show tile information.")
322 ShowInfoDec,
323 "Show info: Dec",
324 [&]() {
325 m_ShowTileInfo = SHOW_TILE_DECIMAL;
326 },
328 [&]() -> bool { return m_ShowTileInfo == SHOW_TILE_DECIMAL; },
330 "[Ctrl+I] Show tile information.")
332 ShowInfoHex,
333 "Show info: Hex",
334 [&]() {
335 m_ShowTileInfo = SHOW_TILE_HEXADECIMAL;
336 },
338 [&]() -> bool { return m_ShowTileInfo == SHOW_TILE_HEXADECIMAL; },
340 "[Ctrl+Shift+I] Show tile information in hexadecimal.")
342 PreviewQuadEnvelopes,
343 "Preview quad envelopes",
344 [&]() {
345 m_ShowEnvelopePreview = !m_ShowEnvelopePreview;
346 m_ActiveEnvelopePreview = EEnvelopePreview::NONE;
347 },
349 [&]() -> bool { return m_ShowEnvelopePreview; },
351 "Toggle previewing the paths of quads with a position envelope when a quad layer is selected.")
353 DeleteLayer,
354 "Delete layer",
355 [&]() { DeleteSelectedLayer(); },
356 [&]() -> bool {
357 std::shared_ptr<CLayer> pCurrentLayer = Map()->SelectedLayer(0);
358 if(!pCurrentLayer)
359 return true;
360 return Map()->m_pGameLayer == pCurrentLayer;
361 },
364 "Delete the layer.")
366 Pipette,
367 "Pipette",
368 [&]() { m_ColorPipetteActive = !m_ColorPipetteActive; },
370 [&]() -> bool { return m_ColorPipetteActive; },
372 "[Ctrl+Shift+C] Color pipette. Pick a color from the screen by clicking on it.")
374 MapDetails,
375 "Map details",
376 [&]() { MapDetails(); },
380 "Adjust the map details of the current map.")
382 AddQuad,
383 "Add quad",
384 [&]() { AddQuadOrSound(); },
385 [&]() -> bool {
386 std::shared_ptr<CLayer> pLayer = Map()->SelectedLayer(0);
387 if(!pLayer)
388 return false;
389 return pLayer->m_Type != LAYERTYPE_QUADS;
390 },
393 "[Ctrl+Q] Add a new quad.")
395 AddSoundSource,
396 "Add sound source",
397 [&]() { AddQuadOrSound(); },
398 [&]() -> bool {
399 std::shared_ptr<CLayer> pLayer = Map()->SelectedLayer(0);
400 if(!pLayer)
401 return false;
402 return pLayer->m_Type != LAYERTYPE_SOUNDS;
403 },
406 "[Ctrl+Q] Add a new sound source.")
408 TestMapLocally,
409 "Test map locally",
410 [&]() { TestMapLocally(); },
414 "Run a local server with the current map and connect you to it.")
415
416#undef ALWAYS_FALSE
417#undef DEFAULT_BTN
@ IMAGE
Definition file_browser.h:22
@ MAP
Definition file_browser.h:21
@ STATE_DEMOPLAYBACK
Definition client.h:60
@ STATE_ONLINE
Definition client.h:59
@ TYPE_ALL
Definition storage.h:27
@ TYPE_SAVE
Definition storage.h:26
#define ALWAYS_FALSE
@ MODE_LAYERS
Definition editor.h:57
#define DEFAULT_BTN
@ DEEP_FREEZE
Definition enums.h:28
@ DEEP_UNFREEZE
Definition enums.h:29
@ FREEZE
Definition enums.h:26
@ AIR
Definition enums.h:21
@ UNHOOKABLE
Definition enums.h:24
@ LIVE_FREEZE
Definition enums.h:32
@ UNFREEZE
Definition enums.h:27
@ HOOKABLE
Definition enums.h:22
@ DEATH
Definition enums.h:23
@ LIVE_UNFREEZE
Definition enums.h:33
@ HOOKTHROUGH
Definition enums.h:25
@ BLUE_CHECK_TELE
Definition enums.h:30
@ RED_CHECK_TELE
Definition enums.h:31
constexpr auto IO_MAX_PATH_LENGTH
Definition types.h:26
const char * fs_filename(const char *path)
Definition fs.cpp:456
void fs_split_file_extension(const char *filename, char *name, size_t name_size, char *extension, size_t extension_size)
Definition fs.cpp:466
@ LAYERTYPE_TILES
Definition mapitems.h:14
@ LAYERTYPE_QUADS
Definition mapitems.h:15
@ LAYERTYPE_SOUNDS
Definition mapitems.h:22
#define REGISTER_QUICK_ACTION(name, text, callback, disabled, active, button_color, description)
Definition quick_actions.h:5