| 1 | /* |
| 2 | * LegacyClonk |
| 3 | * |
| 4 | * Copyright (c) 1998-2000, Matthes Bender (RedWolf Design) |
| 5 | * Copyright (c) 2017-2020, The LegacyClonk Team and contributors |
| 6 | * |
| 7 | * Distributed under the terms of the ISC license; see accompanying file |
| 8 | * "COPYING" for details. |
| 9 | * |
| 10 | * "Clonk" is a registered trademark of Matthes Bender, used with permission. |
| 11 | * See accompanying file "TRADEMARK" for details. |
| 12 | * |
| 13 | * To redistribute this file separately, substitute the full license texts |
| 14 | * for the above references. |
| 15 | */ |
| 16 | |
| 17 | /* Handles viewport editing in console mode */ |
| 18 | |
| 19 | #pragma once |
| 20 | |
| 21 | #include "C4ObjectList.h" |
| 22 | #include "C4Control.h" |
| 23 | |
| 24 | #ifdef WITH_DEVELOPER_MODE |
| 25 | #include <gtk/gtk.h> |
| 26 | #endif |
| 27 | |
| 28 | class C4EditCursor |
| 29 | { |
| 30 | public: |
| 31 | C4EditCursor(); |
| 32 | ~C4EditCursor(); |
| 33 | |
| 34 | protected: |
| 35 | bool fAltWasDown; |
| 36 | bool fSelectionChanged; |
| 37 | int32_t Mode; |
| 38 | int32_t X, Y, X2, Y2; |
| 39 | bool Hold, DragFrame, DragLine; |
| 40 | C4Object *Target, *DropTarget; |
| 41 | #ifdef _WIN32 |
| 42 | HMENU hMenu; |
| 43 | #elif defined(WITH_DEVELOPER_MODE) |
| 44 | GtkWidget *; |
| 45 | |
| 46 | GtkWidget *itemDelete; |
| 47 | GtkWidget *itemDuplicate; |
| 48 | GtkWidget *itemGrabContents; |
| 49 | GtkWidget *itemProperties; |
| 50 | #endif // _WIN32/WITH_DEVELOPER_MODE |
| 51 | C4ObjectList Selection; |
| 52 | |
| 53 | public: |
| 54 | void Default(); |
| 55 | void Clear(); |
| 56 | void Execute(); |
| 57 | void ClearPointers(C4Object *pObj); |
| 58 | bool ToggleMode(); |
| 59 | void Draw(C4FacetEx &cgo); |
| 60 | int32_t GetMode(); |
| 61 | C4Object *GetTarget(); |
| 62 | bool SetMode(int32_t iMode); |
| 63 | bool In(const char *szText); |
| 64 | bool Duplicate(); |
| 65 | bool OpenPropTools(); |
| 66 | bool Delete(); |
| 67 | bool LeftButtonUp(); |
| 68 | bool LeftButtonDown(bool fControl); |
| 69 | bool RightButtonUp(); |
| 70 | bool RightButtonDown(bool fControl); |
| 71 | void MiddleButtonUp(); |
| 72 | bool Move(int32_t iX, int32_t iY, uint16_t wKeyFlags); |
| 73 | bool Init(); |
| 74 | bool EditingOK(); |
| 75 | C4ObjectList &GetSelection() { return Selection; } |
| 76 | void SetHold(bool fToState) { Hold = fToState; } |
| 77 | void OnSelectionChanged(); |
| 78 | bool AltDown(); |
| 79 | bool AltUp(); |
| 80 | |
| 81 | protected: |
| 82 | bool UpdateStatusBar(); |
| 83 | void ApplyToolPicker(); |
| 84 | void PutContents(); |
| 85 | void UpdateDropTarget(uint16_t wKeyFlags); |
| 86 | void GrabContents(); |
| 87 | bool (); |
| 88 | void ApplyToolFill(); |
| 89 | void ApplyToolRect(); |
| 90 | void ApplyToolLine(); |
| 91 | void ApplyToolBrush(); |
| 92 | void DrawSelectMark(C4Facet &cgo); |
| 93 | void FrameSelection(); |
| 94 | void MoveSelection(int32_t iXOff, int32_t iYOff); |
| 95 | void EMMoveObject(enum C4ControlEMObjectAction eAction, int32_t tx, int32_t ty, C4Object *pTargetObj, const C4ObjectList *pObjs = nullptr, const char *szScript = nullptr); |
| 96 | void EMControl(enum C4PacketType eCtrlType, class C4ControlPacket *pCtrl); |
| 97 | |
| 98 | #ifdef WITH_DEVELOPER_MODE |
| 99 | static void OnDelete(GtkWidget *widget, gpointer data); |
| 100 | static void OnDuplicate(GtkWidget *widget, gpointer data); |
| 101 | static void OnGrabContents(GtkWidget *widget, gpointer data); |
| 102 | static void OnProperties(GtkWidget *widget, gpointer data); |
| 103 | #endif |
| 104 | }; |
| 105 | |