Skip to content

Commit 5448807

Browse files
committed
Editor: Added Button.WrapText property
1 parent d414f54 commit 5448807

File tree

7 files changed

+35
-3
lines changed

7 files changed

+35
-3
lines changed

Editor/AGS.Editor/AGSEditor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ public class AGSEditor
107107
* 3.6.2 - Character.TurnWhenFacing, Settings.UseOldVoiceClipNaming,
108108
* ScriptModules for interaction/event lists,
109109
* GlobalVariable may be of array type.
110+
* 3.6.2.2 - Button.WrapText
110111
*/
111-
public const int LATEST_XML_VERSION_INDEX = 3060200;
112+
public const int LATEST_XML_VERSION_INDEX = 3060202;
112113
/*
113114
* LATEST_USER_DATA_VERSION is the last version of the user data file that used a
114115
* 4-point-4-number string to identify the version of AGS that saved the file.

Editor/AGS.Editor/DataFileWriter.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,16 @@ public FrameAlignment TextAlignment
10591059
}
10601060
}
10611061

1062+
public bool WrapText
1063+
{
1064+
get
1065+
{
1066+
GUIButton button = (GUIButton)this;
1067+
if (button != null) return button.WrapText;
1068+
return false;
1069+
}
1070+
}
1071+
10621072
public string OnClick
10631073
{
10641074
get
@@ -1122,7 +1132,8 @@ private void WriteAllButtonsAndTextWindowEdges()
11221132
foreach (GUIButtonOrTextWindowEdge ctrl in GUIButtonsAndTextWindowEdges)
11231133
{
11241134
int flags;
1125-
flags = (ctrl.ClipImage ? NativeConstants.GUIF_CLIP : 0);
1135+
flags = (ctrl.ClipImage ? NativeConstants.GUIF_CLIP : 0) |
1136+
(ctrl.WrapText ? NativeConstants.GUIF_WRAPTEXT : 0);
11261137
WriteGUIControl(ctrl, flags, new string[] { ctrl.OnClick });
11271138
writer.Write(ctrl.Image); // pic
11281139
writer.Write(ctrl.MouseoverImage); // overpic

Editor/AGS.Editor/Utils/NativeConstants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class NativeConstants
5656
public static readonly int GUIF_VISIBLE = (int)Factory.NativeProxy.GetNativeConstant("GUIF_VISIBLE");
5757
public static readonly int GUIF_CLIP = (int)Factory.NativeProxy.GetNativeConstant("GUIF_CLIP");
5858
public static readonly int GUIF_TRANSLATED = (int)Factory.NativeProxy.GetNativeConstant("GUIF_TRANSLATED");
59+
public static readonly int GUIF_WRAPTEXT = (int)Factory.NativeProxy.GetNativeConstant("GUIF_WRAPTEXT");
5960
public static readonly int GLF_SHOWBORDER = (int)Factory.NativeProxy.GetNativeConstant("GLF_SHOWBORDER");
6061
public static readonly int GLF_SHOWARROWS = (int)Factory.NativeProxy.GetNativeConstant("GLF_SHOWARROWS");
6162
public static readonly int GUI_POPUP_MODAL = (int)Factory.NativeProxy.GetNativeConstant("GUI_POPUP_MODAL");

Editor/AGS.Native/NativeMethods.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ namespace AGS
805805
if (name->Equals("GUIF_VISIBLE")) return (int)Common::kGUICtrl_Visible;
806806
if (name->Equals("GUIF_CLIP")) return (int)Common::kGUICtrl_Clip;
807807
if (name->Equals("GUIF_TRANSLATED")) return (int)Common::kGUICtrl_Translated;
808+
if (name->Equals("GUIF_WRAPTEXT")) return (int)Common::kGUICtrl_WrapText;
808809
if (name->Equals("GLF_SHOWBORDER")) return (int)Common::kListBox_ShowBorder;
809810
if (name->Equals("GLF_SHOWARROWS")) return (int)Common::kListBox_ShowArrows;
810811
if (name->Equals("GUI_POPUP_MODAL")) return (int)Common::kGUIPopupModal;

Editor/AGS.Native/agsnative.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2730,6 +2730,7 @@ void ConvertGUIToBinaryFormat(GUI ^guiObj, GUIMain *gui)
27302730
nbut.SetMouseOverImage(button->MouseoverImage);
27312731
nbut.SetPushedImage(button->PushedImage);
27322732
nbut.TextAlignment = (::FrameAlignment)button->TextAlignment;
2733+
nbut.SetWrapText(button->WrapText);
27332734
nbut.ClickAction[Common::kGUIClickLeft] = (Common::GUIClickAction)button->ClickAction;
27342735
nbut.ClickData[Common::kGUIClickLeft] = button->NewModeNumber;
27352736
nbut.SetClipImage(button->ClipImage);

Editor/AGS.Types/GUIButton.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public GUIButton() : base()
3737
private int _font;
3838
private int _textColor;
3939
private FrameAlignment _textAlign;
40+
private bool _wrapText;
4041
private bool _clipImage;
4142
private GUIClickAction _clickAction;
4243
private int _newModeNumber;
@@ -86,6 +87,14 @@ public FrameAlignment TextAlignment
8687
set { _textAlign = value; }
8788
}
8889

90+
[Description("Whether button will wrap long text")]
91+
[Category("Appearance")]
92+
public bool WrapText
93+
{
94+
get { return _wrapText; }
95+
set { _wrapText = value; }
96+
}
97+
8998
[Description("AGS Colour Number of the button text")]
9099
[Category("Appearance")]
91100
[DisplayName("TextColourNumber")]

Editor/Native/acgui_agsnative.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,15 @@ void GUIInvWindow::Draw(Bitmap *ds, int x, int y)
146146

147147
void GUIButton::PrepareTextToDraw()
148148
{
149-
_textToDraw = _text;
149+
if (IsWrapText())
150+
{
151+
_textToDraw = _text;
152+
GUI::SplitLinesForDrawing(_text, false, Lines, Font, _width);
153+
}
154+
else
155+
{
156+
_textToDraw = _text;
157+
}
150158
}
151159

152160
} // namespace Common

0 commit comments

Comments
 (0)