49 int32_t obj_count = size();
78 for (
const C4Value &v : (*
this))
79 if ((obj = v.getObj()))
88 for (
const C4Value &v : (*
this))
89 if ((obj = v.getObj()))
104 if (obj == v.getObj())
115 for (
const C4Value &v : (*
this))
if (obj == v.getPropList())
return true;
129 #ifdef WITH_QT_EDITOR
130 : shapes(
new C4ConsoleQtShapes())
173 #ifdef USE_WIN32_WINDOWS
192 bool fAltIsDown = (dwKeyState & MK_ALT) != 0;
202 bool fShiftIsDown = (dwKeyState & MK_SHIFT) != 0;
207 float xoff = iX-
X;
float yoff = iY-
Y;
208 X = iX;
Y = iY;
Zoom = iZoom;
217 if (new_rot < 0) new_rot += 360;
218 if (fShiftIsDown) new_rot = (new_rot + 23) / 45 * 45;
220 int32_t con_step =
FullCon / 5;
221 if (fShiftIsDown) new_con = (new_con + con_step/2) / con_step * con_step;
223 new_con = std::max<int32_t>(new_con, fShiftIsDown ? 1 : con_step);
224 bool any_change =
false;
245 #ifdef WITH_QT_EDITOR
246 shapes->MouseMove(
X,
Y,
Hold, 3.0f/
Zoom, !!(dwKeyState & MK_SHIFT), !!(dwKeyState & MK_CONTROL));
298 int32_t
X=this->
X,
Y=this->
Y;
316 str.
Format(
"%i/%i (fg: %s, bg: %s)",
X,
Y,
333 if (!add_proplist)
return;
335 if (add_obj && !add_obj->
Status)
return;
343 if (!remove_proplist)
return false;
345 if (remove_obj && !remove_obj->
Status)
return false;
369 #ifdef WITH_QT_EDITOR
370 if (shapes->MouseDown(
X,
Y, 3.0f /
Zoom, !!(dwKeyState & MK_SHIFT), !!(dwKeyState & MK_CONTROL)))
376 if (dwKeyState & MK_CONTROL)
401 if(obj.getObj() && obj.getObj()->At(
X,
Y))
452 if ( (dwKeyState & MK_CONTROL) == 0)
455 bool fCursorIsOnSelection =
false;
458 if (obj.getObj() && obj.getObj()->At(
X,
Y))
460 fCursorIsOnSelection =
true;
464 if (!fCursorIsOnSelection)
514 #ifdef WITH_QT_EDITOR
515 shapes->MouseUp(
X,
Y, !!(dwKeyState & MK_SHIFT), !!(dwKeyState & MK_CONTROL));
531 bool fAltIsDown = (dwKeyState & MK_ALT) != 0;
532 fAltIsDown = fAltIsDown || KeyCode == K_ALT_L || KeyCode == K_ALT_R;
542 bool fShiftIsDown = (dwKeyState & MK_SHIFT) != 0;
543 fShiftIsDown = fShiftIsDown || KeyCode == K_SHIFT_L || KeyCode == K_SHIFT_R;
553 bool fAltIsDown = (dwKeyState & MK_ALT) != 0;
554 fAltIsDown = fAltIsDown && !( KeyCode == K_ALT_L || KeyCode == K_ALT_R);
564 bool fShiftIsDown = (dwKeyState & MK_SHIFT) != 0;
565 fShiftIsDown = fShiftIsDown && !(KeyCode == K_SHIFT_L || KeyCode == K_SHIFT_R);
572 #ifdef USE_WIN32_WINDOWS
573 bool SetMenuItemEnable(HMENU hMenu,
WORD id,
bool fEnable)
575 return !!EnableMenuItem(hMenu,
id,MF_BYCOMMAND | MF_ENABLED | ( fEnable ? 0 : MF_GRAYED));
582 minfo.cbSize =
sizeof(minfo);
583 minfo.fMask = MIIM_ID | MIIM_TYPE | MIIM_DATA;
584 minfo.fType = MFT_STRING;
587 minfo.dwTypeData = getMBufPtr<wchar_t>(td);
588 minfo.cch = wcslen(minfo.dwTypeData);
589 return !!SetMenuItemInfoW(hMenu,
id,
false,&minfo);
596 #ifndef WITH_QT_EDITOR
639 if (!object_count)
return;
644 object_numbers_c4v->SetSize(object_count);
645 int32_t total_object_count = 0;
646 for (int32_t i = 0; i < object_count; ++i)
652 object_numbers_c4v->SetSize(total_object_count);
656 bool result = !!result_c4v;
682 bool any_duplicates =
false;
685 if (obj->Number > prev_oei)
687 any_duplicates =
true;
702 int64_t X_all = 0, Y_all = 0, n_selected = 0;
703 float old_x =
X, old_y =
Y;
706 if (obj->Number > prev_oei)
709 X_all += obj->GetX();
710 Y_all += obj->GetY();
717 X = X_all / n_selected;
718 Y = Y_all / n_selected;
724 DWORD last_key_state = MK_SHIFT;
727 Move(old_x, old_y,
Zoom, last_key_state);
736 for (
int i = 0; i<iObjectNum; ++i)
753 for (
int i = 0; i<iObjectNum; ++i)
764 float line_width = std::max<float>(1.0f, 1.0f / cgo.
Zoom);
765 float offX, offY, newzoom;
768 if (select_mark_color)
782 uint32_t dwOldBlitMode = cobj->
BlitMode;
799 if (draw_transform_marker)
801 float transform_marker_x = 0.0f, transform_marker_y = 0.0f;
804 transform_marker_x += offX; transform_marker_y += offY;
806 C4Facet transform_target_sfc(cgo.
Surface, transform_marker_x-sz/2, transform_marker_y-sz/2, sz, sz);
812 transform_target_sfc.
X +=
X -
X2;
813 transform_target_sfc.
Y +=
Y -
Y2;
826 if (!obj)
return false;
830 float vis_wdt = float(obj->
Shape.
Wdt) * zoom;
831 float vis_hgt = float(obj->
Shape.
Wdt) * zoom;
842 float line_width = std::max<float>(1.0f, 1.0f / cgo.
Zoom);
843 #ifdef WITH_QT_EDITOR
900 if (highlight)
DrawObject(cgo, highlight, 0xffff8000,
true,
false);
906 if ((cgo.
Wdt<1) || (cgo.
Hgt<1))
return;
910 const float EDGE_WIDTH = 2.f;
912 unsigned char c[4] = {
913 static_cast<unsigned char>((color >> 16) & 0xff),
914 static_cast<unsigned char>((color >> 8) & 0xff),
915 static_cast<unsigned char>((color >> 0) & 0xff),
916 static_cast<unsigned char>((color >> 24) & 0xff)
920 { 0.f, 0.f, { c[0], c[1], c[2], c[3] }, frame.
left + EDGE_WIDTH, frame.
top, 0.f },
921 { 0.f, 0.f, { c[0], c[1], c[2], c[3] }, frame.
left, frame.
top, 0.f },
922 { 0.f, 0.f, { c[0], c[1], c[2], c[3] }, frame.
left, frame.
top, 0.f },
923 { 0.f, 0.f, { c[0], c[1], c[2], c[3] }, frame.
left, frame.
top+EDGE_WIDTH, 0.f },
925 { 0.f, 0.f, { c[0], c[1], c[2], c[3] }, frame.
left+EDGE_WIDTH, frame.
bottom-1, 0.f },
926 { 0.f, 0.f, { c[0], c[1], c[2], c[3] }, frame.
left, frame.
bottom-1, 0.f },
927 { 0.f, 0.f, { c[0], c[1], c[2], c[3] }, frame.
left, frame.
bottom-1, 0.f },
928 { 0.f, 0.f, { c[0], c[1], c[2], c[3] }, frame.
left, frame.
bottom-1-EDGE_WIDTH, 0.f },
930 { 0.f, 0.f, { c[0], c[1], c[2], c[3] }, frame.
right-1-EDGE_WIDTH, frame.
top, 0.f },
931 { 0.f, 0.f, { c[0], c[1], c[2], c[3] }, frame.
right-1, frame.
top, 0.f },
932 { 0.f, 0.f, { c[0], c[1], c[2], c[3] }, frame.
right-1, frame.
top, 0.f },
933 { 0.f, 0.f, { c[0], c[1], c[2], c[3] }, frame.
right-1, frame.
top+EDGE_WIDTH, 0.f },
935 { 0.f, 0.f, { c[0], c[1], c[2], c[3] }, frame.
right-1-EDGE_WIDTH, frame.
bottom-1, 0.f },
936 { 0.f, 0.f, { c[0], c[1], c[2], c[3] }, frame.
right-1, frame.
bottom-1, 0.f },
937 { 0.f, 0.f, { c[0], c[1], c[2], c[3] }, frame.
right-1, frame.
bottom-1, 0.f },
938 { 0.f, 0.f, { c[0], c[1], c[2], c[3] }, frame.
right-1, frame.
bottom-1-EDGE_WIDTH, 0.f },
941 const unsigned int n_vertices =
sizeof(vertices) /
sizeof(vertices[0]);
982 #ifdef USE_WIN32_WINDOWS
996 #ifdef USE_WIN32_WINDOWS
997 if (hMenu) DestroyMenu(hMenu); hMenu=
nullptr;
999 #ifdef WITH_DEBUG_MODE
1005 #ifdef WITH_QT_EDITOR
1006 shapes->ClearShapes();
1013 #ifdef USE_WIN32_WINDOWS
1014 HWND hFocus=GetFocus();
1019 if (iMode==
Mode)
return true;
1042 #ifdef USE_WIN32_WINDOWS
1059 #ifdef WITH_QT_EDITOR
1089 EMControl(
CID_EMDrawTool,
new C4ControlEMDrawTool(
EMDT_Brush, ::
Landscape.
GetMode(),
X,
Y,0,0, pTools->
Grade, pTools->
Material, pTools->
Texture, pTools->
BackMaterial, pTools->
BackTexture));
1097 EMControl(
CID_EMDrawTool,
new C4ControlEMDrawTool(
EMDT_Line, ::
Landscape.
GetMode(),
X,
Y,
X2,
Y2, pTools->
Grade, pTools->
Material,pTools->
Texture, pTools->
BackMaterial, pTools->
BackTexture));
1105 EMControl(
CID_EMDrawTool,
new C4ControlEMDrawTool(
EMDT_Rect, ::
Landscape.
GetMode(),
X,
Y,
X2,
Y2, pTools->
Grade, pTools->
Material, pTools->
Texture, pTools->
BackMaterial, pTools->
BackTexture));
1113 EMControl(
CID_EMDrawTool,
new C4ControlEMDrawTool(
EMDT_Fill, ::
Landscape.
GetMode(),
X,
Y,0,
Y2, pTools->
Grade, pTools->
Material,
nullptr,
nullptr,
nullptr));
1118 #ifdef USE_WIN32_WINDOWS
1121 AppendMenu(GetSubMenu(hMenu,0), MF_STRING,
IDM_VPORTDYN_FIRST + num, label.GetWideChar());
1129 #ifdef USE_WIN32_WINDOWS
1131 POINT point; GetCursorPos(&point);
1132 HMENU hContext = GetSubMenu(hMenu,0);
1145 int itemcount = atcursor->
GetSize();
1149 int entrycount = itemcount;
1150 for (
int i_item = 0; i_item < itemcount; ++i_item)
1152 C4Object *pObj = (*atcursor)[i_item].getObj(); assert(pObj);
1154 if (custom_commands) entrycount += custom_commands->
GetSize();
1156 #ifdef USE_WIN32_WINDOWS
1158 const int maxentries = 25;
1159 bool has_too_many_entries = (entrycount > maxentries);
1160 if (has_too_many_entries) entrycount = maxentries + 1;
1162 const int maxentries = std::numeric_limits<int>::max();
1172 for (
int i_item = 0; i_item < itemcount; ++i_item)
1174 ++i_entry;
if (i_entry >= maxentries)
break;
1176 C4Object *obj = (*atcursor)[i_item].getObj();
1185 if (custom_commands)
for (
int i_cmd = 0; i_cmd < custom_commands->
GetSize(); ++i_cmd)
1187 ++i_entry;
if (i_entry >= maxentries)
break;
1192 custom_command_szstr.
Format(
"%s()", custom_command->
GetName());
1193 else if ((custom_command_string = cmd.
getStr()))
1194 custom_command_szstr.
Copy(custom_command_string->
GetData());
1204 #ifdef USE_WIN32_WINDOWS
1205 if (has_too_many_entries)
1216 #ifdef USE_WIN32_WINDOWS
1217 int32_t iItem = TrackPopupMenu(
1219 TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD | TPM_LEFTBUTTON | TPM_NONOTIFY,
1231 if(it->ItemId == iItem)
1233 if (it->Command.getLength())
1265 if (dwKeyState & MK_CONTROL)
1270 if (!cobj->Contained)
1271 if (Inside<int32_t>(
X-(cobj->GetX()+cobj->Shape.x),0,cobj->Shape.Wdt-1))
1272 if (Inside<int32_t>(
Y-(cobj->GetY()+cobj->Shape.y),0,cobj->Shape.Hgt-1))
1321 bool material_set =
false;
1338 if (pBgTex && !pBgTex->
isNull())
1353 material_set =
true;
1377 int32_t iObjCnt = 0; int32_t *pObjIDs =
nullptr;
1380 pObjIDs =
new int32_t [iObjCnt];
1383 for (
const C4Value &vobj : *pObjs)
1388 pObjIDs[i++] = obj->
Number;
1409 #if defined(USE_WIN32_WINDOWS)
1410 if(!it->ItemId) { ++it;
continue; }
1411 HMENU hContext = GetSubMenu(hMenu,0);
1412 DeleteMenu(hContext, it->ItemId, MF_BYCOMMAND);
1450 if (!obj || !cmd)
return;
1457 if (!obj || !obj->
Status)
return false;
1470 float trf_marker_x, trf_marker_y;
1474 float dx = (float(
X - obj->
GetX()) - trf_marker_x) *
Zoom;
1475 float dy = (float(
Y - obj->
GetY()) - trf_marker_y) *
Zoom;
const int C4CNS_ModeCreateObject
bool SetMenuItemText(HMENU hMenu, WORD id, const char *szText)
const uint32_t OCF_NotContained
#define PSF_EditCursorDeselection
#define PSF_SaveScenarioObjects
#define PSF_EditCursorSelection
C4AulScriptEngine ScriptEngine
C4Application Application
C4MouseControl MouseControl
C4GraphicsResource GraphicsResource
int32_t GBackMat(int32_t x, int32_t y)
const char * LoadResStr(const char *id)
bool LogF(const char *strMessage,...)
C4MaterialMap MaterialMap
bool MatValid(int32_t mat)
const int32_t C4MC_Cursor_DropInto
C4Fixed itofix(int32_t x)
#define C4GFXBLIT_ADDITIVE
#define C4GFXBLIT_CLRSFC_MOD2
C4Value C4VObj(C4Object *pObj)
C4Value C4VArray(C4ValueArray *pArray)
C4Value C4VInt(int32_t i)
C4Value C4VPropList(C4PropList *p)
StdBuf GetWideCharBuf(const char *utf8)
std::enable_if< std::is_pod< T >::value >::type ZeroMem(T *lpMem, size_t dwSize)
bool Inside(T ival, U lbound, V rbound)
StdStrBuf FormatString(const char *szFmt,...)
C4Value DirectExec(C4PropList *p, const char *szScript, const char *szContext, bool fPassErrors=false, C4AulScriptContext *context=nullptr, bool parse_function=false)
const char * GetName() const
C4PropListStatic * GetPropList()
C4AulUserFile * GetUserFile(int32_t handle)
void CloseUserFile(int32_t handle)
StdStrBuf GrabFileContents()
bool UpdateModeCtrls(int iMode)
void PropertyDlgUpdate(class C4EditCursorSelection &rSelection, bool force_function_update)
void DisplayInfoText(InfoTextType type, StdStrBuf &text)
bool Message(const char *szMessage, bool fQuery=false)
C4ObjectListDlg ObjectListDlg
void RegisterRecentInput(const char *input, RecentScriptInputLists section)
static C4ControlEMMoveObject * CreateObject(const C4ID &id, C4Real x, C4Real y, C4Object *container)
void DrawCircleDw(C4Surface *sfcTarget, float cx, float cy, float r, DWORD dwClr, float width=1.0f)
void DrawFrameDw(C4Surface *sfcDest, int x1, int y1, int x2, int y2, DWORD dwClr, float width=1.0f)
void SetBlitMode(DWORD dwBlitMode)
virtual void PerformMultiLines(C4Surface *sfcTarget, const C4BltVertex *vertices, unsigned int n_vertices, float width, C4ShaderCall *shader_call)=0
void DrawLineDw(C4Surface *sfcTarget, float x1, float y1, float x2, float y2, DWORD dwClr, float width=1.0f)
bool EditingOK(bool for_landscape_drawing=false)
bool LeftButtonDown(DWORD dwKeyState)
bool SetMode(int32_t iMode)
bool KeyDown(C4KeyCode KeyCode, DWORD dwKeyState)
void UpdateDropTarget(DWORD dwKeyState)
void DrawObject(C4TargetFacet &cgo, C4Object *cobj, uint32_t select_mark_color, bool highlight, bool draw_transform_marker)
void PerformDuplicationLegacy(int32_t *pObjects, int32_t iObjectNum, bool fLocalCall)
bool HasTransformMarker(float *x, float *y, float zoom) const
void Draw(C4TargetFacet &cgo)
void AddToSelection(C4PropList *add_obj)
bool In(const char *szText)
void PerformDuplication(int32_t *object_numbers, int32_t object_count, bool local_call)
void MoveSelection(C4Real iXOff, C4Real iYOff, bool drag_finished)
bool IsHoveringTransformMarker() const
bool RemoveFromSelection(C4PropList *remove_obj)
void EMControl(enum C4PacketType eCtrlType, class C4ControlPacket *pCtrl)
C4Value highlighted_object
bool GetCurrentSelectionPosition(int32_t *x, int32_t *y)
std::unique_ptr< C4GraphicsOverlay > creator_overlay
void SetHighlightedObject(C4Object *new_highlight)
void ApplyCreateObject(bool contained)
std::vector< ObjselItemDt > itemsObjselect
void DrawSelectMark(C4Facet &cgo, FLOAT_RECT r, float width, uint32_t color=0xffffffff)
bool RightButtonDown(DWORD dwKeyState)
bool RightButtonUp(DWORD dwKeyState)
bool LeftButtonUp(DWORD dwKeyState)
class C4Def * creator_def
void DoContextObjsel(C4Object *, bool clear)
void ClearPointers(C4Object *pObj)
void AppendMenuItem(int num, const StdStrBuf &label)
void SetHold(bool fToState)
void EMMoveObject(enum C4ControlEMObjectAction eAction, C4Real tx, C4Real ty, C4Object *pTargetObj, const C4EditCursorSelection *pObjs=nullptr, const char *szScript=nullptr, bool drag_finished=false)
C4EditCursorSelection selection
bool Move(float iX, float iY, float zoom, DWORD dwKeyState)
void OnSelectionChanged(bool by_objectlist=false)
bool DoContextMenu(DWORD dwKeyState)
void ClearSelection(C4PropList *next_selection=nullptr)
bool IsSelectionInvalidated() const
bool KeyUp(C4KeyCode KeyCode, DWORD dwKeyState)
void DoContextObjCommand(C4Object *, const char *cmd)
int32_t ObjectCount() const
bool IsContained(C4PropList *obj) const
bool ClearPointers(C4Object *obj)
C4Object * GetLastObject() const
StdStrBuf GetDataString() const
C4Object * GetObject(int32_t index=0) const
void Draw(C4Facet &cgo, bool fAspect=true, int32_t iPhaseX=0, int32_t iPhaseY=0, bool fTransparent=true)
void DrawX(C4Surface *sfcTarget, float iX, float iY, float iWdt, float iHgt, int32_t iPhaseX=0, int32_t iPhaseY=0) const
C4ValueArray * FindMany(const C4ObjectList &Objs)
void DoInput(C4PacketType eCtrlType, C4ControlPacket *pPkt, C4ControlDeliveryType eDelivery)
C4Object * FindObject(C4Def *def, int32_t x=0, int32_t y=0, int32_t wdt=0, int32_t hgt=0, DWORD ocf=OCF_All, C4Object *find_next=nullptr)
C4Object * CreateObject(C4PropList *type, C4Object *creator, int32_t owner=NO_OWNER, int32_t x=50, int32_t y=50, int32_t r=0, bool grow_from_center=false, C4Real xdir=Fix0, C4Real ydir=Fix0, C4Real rdir=Fix0, int32_t controller=NO_OWNER)
C4Object * SafeObjectPointer(int32_t object_number)
C4FacetID fctTransformKnob
BYTE GetMapIndex(int32_t iX, int32_t iY) const
LandscapeMode GetMode() const
BYTE GetBackPix(int32_t x, int32_t y) const
int32_t GetBackMat(int32_t x, int32_t y) const
int32_t GetMat(int32_t x, int32_t y) const
int32_t GetMapZoom() const
BYTE GetBackMapIndex(int32_t iX, int32_t iY) const
const char * GetCaption()
bool GetDrawPosition(const C4TargetFacet &cgo, float &resultx, float &resulty, float &resultzoom) const
void DrawTopFace(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
int32_t AddObjectAndContentsToArray(C4ValueArray *target_array, int32_t index=0)
StdStrBuf GetDataString()
StdMeshInstance * pMeshInstance
C4NotifyingObjectList Contents
void Draw(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
void Update(class C4EditCursorSelection &rSelection)
int ObjectCount(C4ID id=C4ID::None) const
virtual C4Object * GetObject()
virtual const char * GetName() const
C4ValueArray * GetPropertyArray(C4PropertyName n) const
C4PropList * GetPrototype() const
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
static int32_t GetEnumerationIndex()
const char * GetName() const override
StdStrBuf GetData() const
void Set(const C4Facet &cpy)
const char * GetTextureName() const
const char * GetMaterialName() const
const C4TexMapEntry * GetEntry(int32_t iIndex) const
const C4Value & GetItem(int32_t iElem) const
C4Object * getObj() const
C4String * getStr() const
C4AulFunc * getFunction() const
void SetFaceOrderingForClrModulation(uint32_t clrmod)
void SetFaceOrdering(FaceOrdering ordering)
void CopyUntil(const char *szString, char cUntil)
const char * getData() const
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
#define IDM_VPORTDYN_FIRST
#define IDM_VIEWPORT_DELETE
#define IDM_VIEWPORT_CONTENTS
#define IDM_VIEWPORT_DUPLICATE