22#ifndef AGS_SHARED_GUI_GUI_MAIN_H
23#define AGS_SHARED_GUI_GUI_MAIN_H
25#include "common/std/vector.h"
26#include "ags/engine/ac/draw.h"
27#include "ags/shared/ac/common.h"
28#include "ags/shared/ac/common_defines.h"
29#include "ags/shared/gfx/gfx_def.h"
30#include "ags/shared/gui/gui_defines.h"
31#include "ags/shared/util/error.h"
32#include "ags/shared/util/geometry.h"
33#include "ags/shared/util/string.h"
47#define LEGACY_MAX_OBJS_ON_GUI 30
49#define GUIMAIN_LEGACY_RESERVED_INTS 5
50#define GUIMAIN_LEGACY_NAME_LENGTH 16
51#define GUIMAIN_LEGACY_EVENTHANDLER_LENGTH 20
52#define GUIMAIN_LEGACY_TW_FLAGS_SIZE 4
58enum LegacyGUIVisState {
59 kGUIVisibility_LockedOff = -1,
60 kGUIVisibility_Off = 0,
78 bool HasAlphaChannel()
const;
80 bool IsClickable()
const {
return (_flags & kGUIMain_Clickable) != 0; }
83 bool IsConcealed()
const {
return (_flags & kGUIMain_Concealed) != 0; }
87 bool IsDisplayed()
const {
return IsVisible() && !IsConcealed(); }
90 bool IsInteractableAt(
int x,
int y)
const;
92 bool IsTextWindow()
const {
return (_flags & kGUIMain_TextWindow) != 0; }
98 bool IsVisible()
const {
return (_flags & kGUIMain_Visible) != 0; }
101 bool HasChanged()
const {
return _hasChanged; }
102 bool HasControlsChanged()
const {
return _hasControlsChanged; }
108 void MarkControlChanged();
112 void NotifyControlPosition();
114 void NotifyControlState(
int objid,
bool mark_changed);
116 void ResetOverControl();
121 int32_t FindControlAt(
int atx,
int aty,
int leeway = 0,
bool must_be_clickable =
true)
const;
123 int32_t GetControlCount()
const;
125 GUIObject *GetControl(int32_t index)
const;
127 GUIControlType GetControlType(int32_t index)
const;
129 int32_t GetControlID(int32_t index)
const;
135 void AddControl(GUIControlType type, int32_t
id,
GUIObject *control);
136 void RemoveAllControls();
139 bool BringControlToFront(int32_t index);
140 void DrawSelf(
Bitmap *ds);
141 void DrawWithControls(
Bitmap *ds);
143 void Poll(
int mx,
int my);
146 bool SendControlToBack(int32_t index);
148 void SetClickable(
bool on);
151 void SetConceal(
bool on);
153 bool SetControlZOrder(int32_t index,
int zorder);
155 void SetTextWindow(
bool on);
157 void SetTransparencyAsPercentage(
int percent);
159 void SetVisible(
bool on);
162 void OnMouseButtonDown(
int mx,
int my);
163 void OnMouseButtonUp();
166 void ReadFromFile(
Stream *in, GuiVersion gui_version);
167 void WriteToFile(
Stream *out)
const;
170 void ReadFromSavegame(
Stream *in, GuiSvgVersion svg_version);
171 void WriteToSavegame(
Stream *out)
const;
174 void DrawBlob(
Bitmap *ds,
int x,
int y, color_t draw_color);
176 int32_t FindControlAtLocal(
int atx,
int aty,
int leeway,
bool must_be_clickable)
const;
192 GUIPopupStyle PopupStyle;
193 int32_t PopupAtMouseY;
194 int32_t Transparency;
198 int32_t HighlightCtrl;
199 int32_t MouseOverCtrl;
200 int32_t MouseDownCtrl;
208 bool _hasControlsChanged;
223extern GuiVersion GameGuiVersion;
230Point CalcTextPosition(
const char *text,
int font,
const Rect &frame, FrameAlignment align,
Rect *gr_rect =
nullptr);
233Line CalcTextPositionHor(
const char *text,
int font,
int x1,
int x2,
int y, FrameAlignment align);
236Rect CalcTextGraphicalRect(
const char *text,
int font,
const Point &at);
239Rect CalcTextGraphicalRect(
const char *text,
int font,
const Rect &frame, FrameAlignment align);
243Line CalcFontGraphicalVExtent(
int font);
245void DrawDisabledEffect(
Bitmap *ds,
const Rect &rc);
247void DrawTextAligned(
Bitmap *ds,
const char *text,
int font, color_t text_color,
const Rect &frame, FrameAlignment align);
249void DrawTextAlignedHor(
Bitmap *ds,
const char *text,
int font, color_t text_color,
int x1,
int x2,
int y, FrameAlignment align);
252GUILabelMacro FindLabelMacros(
const String &text);
255String TransformTextForDrawing(
const String &text,
bool translate,
bool apply_direction);
258size_t SplitLinesForDrawing(
const char *text,
bool apply_direction,
SplitLines &lines,
int font,
int width,
size_t max_lines = -1);
261void MarkAllGUIForUpdate(
bool redraw,
bool reset_over_ctrl);
263void MarkForTranslationUpdate();
266void MarkForFontUpdate(
int font);
268void MarkSpecialLabelsForUpdate(GUILabelMacro macro);
271void MarkInventoryForUpdate(
int char_id,
bool is_player);
280void WriteGUI(
Stream *out);
282void ApplyLegacyVisibility(
GUIMain &gui, LegacyGUIVisState vis);
292extern int get_adjusted_spritewidth(
int spr);
293extern int get_adjusted_spriteheight(
int spr);
294extern bool is_sprite_alpha(
int spr);
296extern void set_eip_guiobj(
int eip);
297extern int get_eip_guiobj();
Definition: allegro_bitmap.h:44
Definition: gui_main.h:68
Definition: gui_object.h:44
Definition: gui_defines.h:203
Definition: geometry.h:118
Definition: geometry.h:87
Definition: geometry.h:219