Debian Codegraph @

src/cdogsed/editor_ui_common.h

raw symbols SCIP
1 /*
2 C-Dogs SDL
3 A port of the legendary (and fun) action/arcade cdogs.
4 Copyright (c) 2014, 2016, 2020, 2022-2023 Cong Xu
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9
10 Redistributions of source code must retain the above copyright notice, this
11 list of conditions and the following disclaimer.
12 Redistributions in binary form must reproduce the above copyright notice,
13 this list of conditions and the following disclaimer in the documentation
14 and/or other materials provided with the distribution.
15
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 POSSIBILITY OF SUCH DAMAGE.
27 */
28 #pragma once
29
30 #include <cdogs/campaigns.h>
31 #include <cdogs/map_object.h>
32 #include <cdogs/vector.h>
33
34 #include "editor_brush.h"
35 #include "ui_object.h"
36
37 #ifdef __APPLE__
38 #define KMOD_CMD KMOD_GUI
39 #define KMOD_CMD_NAME "Cmd"
40 #else
41 #define KMOD_CMD KMOD_CTRL
42 #define KMOD_CMD_NAME "Ctrl"
43 #endif
44
45 typedef struct
46 {
47 EditorBrush *Brush;
48 union
49 {
50 int ItemIndex;
51 MapObject *MapObject;
52 } u;
53 int Index2;
54 } IndexedEditorBrush;
55 typedef struct
56 {
57 IndexedEditorBrush Brush;
58 Campaign *Campaign;
59 } EditorBrushAndCampaign;
60
61 void DisplayMapItem(const struct vec2i pos, const MapObject *mo);
62 void DisplayMapItemWithDensity(
63 const struct vec2i pos, const MapObjectDensity *mod, const bool isHighlighted);
64 void DisplayPickup(const struct vec2i pos, const PickupClass *p);
65 void DisplayPickupWithCount(
66 const struct vec2i pos, const PickupCount *pc,
67 const bool isHighlighted);
68 void DrawKey(UIObject *o, GraphicsDevice *g, struct vec2i pos, void *vData);
69
70 void InsertMission(Campaign *co, Mission *mission, int idx);
71
72 bool ConfirmScreen(const char *info, const char *msg);
73 void ClearScreen(GraphicsDevice *g);
74
75 void DisplayFlag(
76 const struct vec2i pos, const char *s, const bool isOn, const bool isHighlighted);
77
78 UIObject *CreateCampaignSeedObj(const struct vec2i pos, Campaign *co);
79 UIObject *CreateAddMapItemObjs(
80 const struct vec2i pos, bool (*objFunc)(UIObject *, MapObject *, void *),
81 void *data, const size_t dataSize, const bool expandDown);
82 UIObject *CreateAddPickupObjs(
83 const struct vec2i pos, bool (*objFunc)(UIObject *, PickupClass *, void *),
84 void *data, const size_t dataSize, const bool expandDown);
85 UIObject *CreateAddPickupSpawnerObjs(
86 const struct vec2i pos, bool (*objFunc)(UIObject *, MapObject *, void *),
87 void *data, const size_t dataSize);
88
89 char *MakeMapObjectTooltip(const MapObject *mo);
90 char *MakePickupTooltip(const PickupClass *p);
91 void MapObjectGetPlacementFlagNames(const MapObject *mo, char *buf, const char *sep);
92 void MapObjectGetExplosionGunNames(const MapObject *mo, char *buf, const char *sep);
93
94 // Create a dummy label that can be clicked to close the context menu
95 void CreateCloseLabel(UIObject *c, const struct vec2i pos);
96
97 // Macro for creating the helper function to show/hide controls for specific
98 // map types
99 #define MISSION_CHECK_TYPE_FUNC(_type)\
100 static void MissionCheckTypeFunc(UIObject *o, void *data)\
101 {\
102 Campaign *co = data;\
103 const Mission *m = CampaignGetCurrentMission(co);\
104 if (!m || m->Type != (_type))\
105 {\
106 o->IsVisible = false;\
107 /* Need to unhighlight to prevent children being drawn*/\
108 UIObjectUnhighlight(o, false);\
109 return;\
110 }\
111 o->IsVisible = true;\
112 }
113
114 void TileClassGetBrushName(char *buf, const TileClass *tc);
115 // Get a null-separated string; for nk_combo_separator
116 char *GetClassNames(const size_t len, const char *(*indexNameFunc)(const int));
117
118 void TexArrayInit(CArray *arr, const size_t count);
119 void TexArrayTerminate(CArray *arr);