aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorKari Salminen2007-07-10 15:28:43 +0000
committerKari Salminen2007-07-10 15:28:43 +0000
commit80cdd532bc8460d23b2562cafe336bedcbe6fb18 (patch)
treee2a87dc3265efc5cbbfaa316eba4ae6b9f745b7c /engines
parent728fe1ff86e26f781a0bd0656822b6845ef5707a (diff)
downloadscummvm-rg350-80cdd532bc8460d23b2562cafe336bedcbe6fb18.tar.gz
scummvm-rg350-80cdd532bc8460d23b2562cafe336bedcbe6fb18.tar.bz2
scummvm-rg350-80cdd532bc8460d23b2562cafe336bedcbe6fb18.zip
Add AgiButtonStyle and create correct style according to render mode (Supports PC and Amiga styles).
svn-id: r28009
Diffstat (limited to 'engines')
-rw-r--r--engines/agi/agi.cpp53
-rw-r--r--engines/agi/agi.h113
2 files changed, 166 insertions, 0 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 61430dcaea..cb02df1ecc 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -535,6 +535,58 @@ static const GameSettings agiSettings[] = {
{NULL, NULL, 0, 0, NULL}
};
+AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, bool positive) const {
+ if (_amigaStyle)
+ if (positive)
+ if (pressed) // Positive pressed Amiga-style button
+ return AgiTextColor(amigaBlack, _olderAgi? amigaOrange : amigaPurple);
+ else // Positive unpressed Amiga-style button
+ return AgiTextColor(amigaWhite, amigaGreen);
+ else // _amigaStyle && !positive
+ if (pressed) // Negative pressed Amiga-style button
+ return AgiTextColor(amigaBlack, amigaCyan);
+ else // Negative unpressed Amiga-style button
+ return AgiTextColor(amigaWhite, amigaRed);
+ else // PC-style button
+ if (hasFocus || pressed) // A pressed or in focus PC-style button
+ return AgiTextColor(pcWhite, pcBlack);
+ else // An unpressed PC-style button without focus
+ return AgiTextColor(pcBlack, pcWhite);
+}
+
+AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, bool baseFgColor, bool baseBgColor) const {
+ return getColor(hasFocus, pressed, AgiTextColor(baseFgColor, baseBgColor));
+}
+
+AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, const AgiTextColor &baseColor) const {
+ if (hasFocus || pressed)
+ return baseColor.swap();
+ else
+ return baseColor;
+}
+
+int AgiButtonStyle::getTextOffset(bool hasFocus, bool pressed) const {
+ return (pressed && !_amigaStyle) ? 1 : 0;
+}
+
+bool AgiButtonStyle::getBorder(bool hasFocus, bool pressed) const {
+ return _amigaStyle && !_authenticAmiga && (hasFocus || pressed);
+}
+
+void AgiButtonStyle::setAmigaStyle(bool amigaStyle, bool olderAgi, bool authenticAmiga) {
+ _amigaStyle = amigaStyle;
+ _olderAgi = olderAgi;
+ _authenticAmiga = authenticAmiga;
+}
+
+void AgiButtonStyle::setPcStyle(bool pcStyle) {
+ setAmigaStyle(!pcStyle);
+}
+
+AgiButtonStyle::AgiButtonStyle(Common::RenderMode renderMode) {
+ setAmigaStyle(renderMode == Common::kRenderAmiga);
+}
+
AgiEngine::AgiEngine(OSystem *syst) : Engine(syst) {
// Setup mixer
@@ -635,6 +687,7 @@ void AgiEngine::initialize() {
}
}
+ _buttonStyle = AgiButtonStyle(_renderMode);
_console = new Console(this);
_gfx = new GfxMgr(this);
_sound = new SoundMgr(this, _mixer);
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 825d475314..216cb47e45 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -318,6 +318,118 @@ struct AgiBlock {
uint8 *buffer; /* used for window background */
};
+/** AGI text color (Background and foreground color). */
+struct AgiTextColor {
+ /** Creates an AGI text color. Uses white text on black background by default. */
+ AgiTextColor(int fgColor = 0x0F, int bgColor = 0x00) : fg(fgColor), bg(bgColor) {}
+
+ /** Get an AGI text color with swapped foreground and background color. */
+ AgiTextColor swap() const { return AgiTextColor(bg, fg); }
+
+ int fg; ///< Foreground color (Used for text).
+ int bg; ///< Background color (Used for text's background).
+};
+
+/**
+ * AGI button style (Amiga or PC).
+ *
+ * Supports positive and negative button types (Used with Amiga-style only):
+ * Positive buttons do what the dialog was opened for.
+ * Negative buttons cancel what the dialog was opened for.
+ * Restart-dialog example: Restart-button is positive, Cancel-button negative.
+ * Paused-dialog example: Continue-button is positive.
+ */
+struct AgiButtonStyle {
+// Public constants etc
+public:
+ static const int
+ // Amiga colors (Indexes into the Amiga-ish palette)
+ amigaBlack = 0x00, ///< Accurate, is #000000 (24-bit RGB)
+ amigaWhite = 0x0F, ///< Practically accurate, is close to #FFFFFF (24-bit RGB)
+ amigaGreen = 0x02, ///< Quite accurate, should be #008A00 (24-bit RGB)
+ amigaOrange = 0x0C, ///< Inaccurate, too much blue, should be #FF7500 (24-bit RGB)
+ amigaPurple = 0x0D, ///< Inaccurate, too much green, should be #FF00FF (24-bit RGB)
+ amigaRed = 0x04, ///< Quite accurate, should be #BD0000 (24-bit RGB)
+ amigaCyan = 0x0B, ///< Inaccurate, too much red, should be #00FFDE (24-bit RGB)
+ // PC colors (Indexes into the EGA-palette)
+ pcBlack = 0x00,
+ pcWhite = 0x0F;
+
+// Public methods
+public:
+ /**
+ * Get the color of the button with the given state and type using current style.
+ *
+ * @param hasFocus True if button has focus, false otherwise.
+ * @param pressed True if button is being pressed, false otherwise.
+ * @param positive True if button is positive, false if button is negative. Only matters for Amiga-style buttons.
+ */
+ AgiTextColor getColor(bool hasFocus, bool pressed, bool positive = true) const;
+
+ /**
+ * Get the color of a button with the given base color and state ignoring current style.
+ * Swaps foreground and background color when the button has focus or is being pressed.
+ *
+ * @param hasFocus True if button has focus, false otherwise.
+ * @param pressed True if button is being pressed, false otherwise.
+ * @param baseFgColor Foreground color of the button when it has no focus and is not being pressed.
+ * @param baseBgColor Background color of the button when it has no focus and is not being pressed.
+ */
+ AgiTextColor getColor(bool hasFocus, bool pressed, bool baseFgColor, bool baseBgColor) const;
+
+ /**
+ * Get the color of a button with the given base color and state ignoring current style.
+ * Swaps foreground and background color when the button has focus or is being pressed.
+ *
+ * @param hasFocus True if button has focus, false otherwise.
+ * @param pressed True if button is being pressed, false otherwise.
+ * @param baseColor Color of the button when it has no focus and is not being pressed.
+ */
+ AgiTextColor getColor(bool hasFocus, bool pressed, const AgiTextColor &baseColor) const;
+
+ /**
+ * How many pixels to offset the shown text diagonally down and to the right.
+ * Currently only used for pressed PC-style buttons.
+ */
+ int getTextOffset(bool hasFocus, bool pressed) const;
+
+ /**
+ * Show border around the button?
+ * Currently border is only used for in focus or pressed Amiga-style buttons
+ * when in inauthentic Amiga-style mode.
+ */
+ bool getBorder(bool hasFocus, bool pressed) const;
+
+ /**
+ * Set Amiga-button style.
+ *
+ * @param amigaStyle Set Amiga-button style if true, otherwise set PC-button style.
+ * @param olderAgi If true then use older AGI style in Amiga-mode, otherwise use newer.
+ * @param authenticAmiga If true then don't use a border around buttons in Amiga-mode, otherwise use.
+ */
+ void setAmigaStyle(bool amigaStyle = true, bool olderAgi = false, bool authenticAmiga = false);
+
+ /**
+ * Set PC-button style.
+ * @param pcStyle Set PC-button style if true, otherwise set default Amiga-button style.
+ */
+ void setPcStyle(bool pcStyle = true);
+
+// Public constructors
+public:
+ /**
+ * Create a button style based on the given rendering mode.
+ * @param renderMode If Common::kRenderAmiga then creates default Amiga-button style, otherwise PC-style.
+ */
+ AgiButtonStyle(Common::RenderMode renderMode = Common::kRenderDefault);
+
+// Private member variables
+private:
+ bool _amigaStyle; ///< Use Amiga-style buttons if true, otherwise use PC-style buttons.
+ bool _olderAgi; ///< Use older AGI style in Amiga-style mode.
+ bool _authenticAmiga; ///< Don't use border around buttons in Amiga-style mode.
+};
+
#define EGO_VIEW_TABLE 0
#define HORIZON 36
#define _WIDTH 160
@@ -595,6 +707,7 @@ public:
int _oldMode;
Menu* _menu;
+ AgiButtonStyle _buttonStyle;
char _lastSentence[40];