https://github.com/libsdl-org/Maelstrom/commit/1bdac1ba2f65ff0a727e5e77fdd361fabbee8981
From 1bdac1ba2f65ff0a727e5e77fdd361fabbee8981 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 28 Oct 2011 01:14:27 -0400
Subject: [PATCH] Dialog elements have a consistent default look and feel.
---
Makefile.am | 2 ++
UI/UITemplates.xml | 4 ----
UI/dawn.xml | 24 ++++++++++++------------
UIDialogLabel.cpp | 13 +++++++++++++
UIDialogLabel.h | 27 +++++++++++++++++++++++++++
UIElements.cpp | 3 +++
6 files changed, 57 insertions(+), 16 deletions(-)
create mode 100644 UIDialogLabel.cpp
create mode 100644 UIDialogLabel.h
diff --git a/Makefile.am b/Makefile.am
index 4a15fd3e..1e975918 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -32,6 +32,8 @@ Maelstrom_SOURCES = \
scores.h \
UIDialog.cpp \
UIDialog.h \
+ UIDialogLabel.cpp \
+ UIDialogLabel.h \
UIElementIcon.cpp \
UIElementIcon.h \
UIElementKeyButton.cpp \
diff --git a/UI/UITemplates.xml b/UI/UITemplates.xml
index 6cd414a0..9c94aa7a 100644
--- a/UI/UITemplates.xml
+++ b/UI/UITemplates.xml
@@ -74,8 +74,4 @@
<Label templateName="LargeYellowUnderline" template="Large" fontStyle="UNDERLINE">
<Color r="0xFF" g="0xFF" b="0x00"/>
</Label>
-
- <Label templateName="Dialog" fontName="Chicago" fontSize="12">
- <Color r="0x00" g="0x00" b="0x00"/>
- </Label>
</UITemplates>
diff --git a/UI/dawn.xml b/UI/dawn.xml
index 96f0e14f..0f8a0020 100644
--- a/UI/dawn.xml
+++ b/UI/dawn.xml
@@ -5,23 +5,23 @@
<Icon name="icon" id="103">
<Anchor anchorFrom="TOPLEFT" anchorTo="TOPLEFT" x="19" y="19"/>
</Icon>
- <Label name="line1" template="Dialog" text="No eternal reward will forgive us">
+ <DialogLabel name="line1" text="No eternal reward will forgive us">
<Anchor anchorFrom="TOPLEFT" anchorTo="TOPRIGHT" anchor="icon" x="25"/>
- </Label>
- <Label name="line2" template="Dialog" text="now">
+ </DialogLabel>
+ <DialogLabel name="line2" text="now">
<Anchor anchorFrom="TOPLEFT" anchorTo="BOTTOMLEFT" anchor="line1" y="2"/>
- </Label>
- <Label name="line3" template="Dialog" text="for">
+ </DialogLabel>
+ <DialogLabel name="line3" text="for">
<Anchor anchorFrom="TOPLEFT" anchorTo="BOTTOMRIGHT" anchor="line2" x="2" y="2"/>
- </Label>
- <Label name="line4" template="Dialog" text="wasting">
+ </DialogLabel>
+ <DialogLabel name="line4" text="wasting">
<Anchor anchorFrom="TOPLEFT" anchorTo="BOTTOMRIGHT" anchor="line3" x="2" y="2"/>
- </Label>
- <Label name="line5" template="Dialog" text="the">
+ </DialogLabel>
+ <DialogLabel name="line5" text="the">
<Anchor anchorFrom="TOPLEFT" anchorTo="BOTTOMRIGHT" anchor="line4" x="2" y="2"/>
- </Label>
- <Label name="line6" template="Dialog" text="dawn.">
+ </DialogLabel>
+ <DialogLabel name="line6" text="dawn.">
<Anchor anchorFrom="TOPLEFT" anchorTo="BOTTOMRIGHT" anchor="line5" x="2" y="2"/>
- </Label>
+ </DialogLabel>
</Elements>
</Dialog>
diff --git a/UIDialogLabel.cpp b/UIDialogLabel.cpp
new file mode 100644
index 00000000..3fdb179c
--- /dev/null
+++ b/UIDialogLabel.cpp
@@ -0,0 +1,13 @@
+
+#include "UIDialogLabel.h"
+#include "Maelstrom_Globals.h"
+
+UIElementType UIDialogLabel::s_elementType;
+
+
+UIDialogLabel::UIDialogLabel(UIPanel *panel, const char *name) :
+ UIElementLabel(panel, name)
+{
+ m_font = fonts[CHICAGO_12];
+ m_color = m_screen->MapRGB(0x00, 0x00, 0x00);
+}
diff --git a/UIDialogLabel.h b/UIDialogLabel.h
new file mode 100644
index 00000000..bdfe2d09
--- /dev/null
+++ b/UIDialogLabel.h
@@ -0,0 +1,27 @@
+#ifndef _UIDialogLabel_h
+#define _UIDialogLabel_h
+
+#include "UIElementLabel.h"
+
+class UIDialogLabel : public UIElementLabel
+{
+public:
+ UIDialogLabel(UIPanel *panel, const char *name = "");
+
+ virtual bool IsA(UIElementType type) {
+ return UIElementLabel::IsA(type) || type == GetType();
+ }
+
+protected:
+ static UIElementType s_elementType;
+
+public:
+ static UIElementType GetType() {
+ if (!s_elementType) {
+ s_elementType = GenerateType();
+ }
+ return s_elementType;
+ }
+};
+
+#endif // _UIDialogLabel_h
diff --git a/UIElements.cpp b/UIElements.cpp
index 0d1563dd..95bd0b6e 100644
--- a/UIElements.cpp
+++ b/UIElements.cpp
@@ -3,6 +3,7 @@
#include "screenlib/UIElementButton.h"
#include "screenlib/UIElementLine.h"
#include "screenlib/UIElementRect.h"
+#include "UIDialogLabel.h"
#include "UIElementIcon.h"
#include "UIElementKeyButton.h"
#include "UIElementLabel.h"
@@ -19,6 +20,8 @@ CreateMaelstromUIElement(UIPanel *panel, const char *type)
return new UIElementRect(panel);
} else if (strcasecmp(type, "Label") == 0) {
return new UIElementLabel(panel);
+ } else if (strcasecmp(type, "DialogLabel") == 0) {
+ return new UIDialogLabel(panel);
} else if (strcasecmp(type, "Button") == 0) {
return new UIElementButton(panel);
} else if (strcasecmp(type, "KeyButton") == 0) {