Skip to content

Commit

Permalink
STARK: Move the Color struct into a separate header
Browse files Browse the repository at this point in the history
  • Loading branch information
ccawley2011 committed Feb 3, 2023
1 parent 46118c2 commit aa5076f
Show file tree
Hide file tree
Showing 23 changed files with 103 additions and 68 deletions.
50 changes: 50 additions & 0 deletions engines/stark/gfx/color.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

#ifndef STARK_GFX_COLOR_H
#define STARK_GFX_COLOR_H

#include "common/scummsys.h"

namespace Stark {
namespace Gfx {

struct Color {
uint8 r;
uint8 g;
uint8 b;
uint8 a;

Color(uint8 red, uint8 green, uint8 blue, uint8 alpha = 0xFF) :
r(red), g(green), b(blue), a(alpha) {}

bool operator==(const Color &color) const {
return r == color.r &&
g == color.g &&
b == color.b &&
a == color.a;
}
};

} // End of namespace Gfx
} // End of namespace Stark

#endif // STARK_GFX_COLOR_H
2 changes: 1 addition & 1 deletion engines/stark/resources/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void ImageStill::printData() {

ImageText::ImageText(Object *parent, byte subType, uint16 index, const Common::String &name) :
Image(parent, subType, index, name),
_color(Color(0, 0, 0)),
_color(Gfx::Color(0, 0, 0)),
_font(0) {
}

Expand Down
5 changes: 3 additions & 2 deletions engines/stark/resources/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
#include "common/str.h"

#include "engines/stark/resources/object.h"
#include "engines/stark/visual/text.h"
#include "engines/stark/gfx/color.h"

namespace Stark {

class Visual;
class VisualImageXMG;
class VisualText;
namespace Formats {
class XRCReadStream;
}
Expand Down Expand Up @@ -140,7 +141,7 @@ class ImageText : public Image {

Common::Point _size;
Common::String _text;
Color _color;
Gfx::Color _color;
uint32 _font;
};

Expand Down
4 changes: 2 additions & 2 deletions engines/stark/ui/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ void Cursor::setMouseHint(const Common::String &hint) {
if (!hint.empty()) {
_mouseText = new VisualText(_gfx);
_mouseText->setText(hint);
_mouseText->setColor(Color(0xFF, 0xFF, 0xFF));
_mouseText->setBackgroundColor(Color(0x00, 0x00, 0x00, 0x80));
_mouseText->setColor(Gfx::Color(0xFF, 0xFF, 0xFF));
_mouseText->setBackgroundColor(Gfx::Color(0x00, 0x00, 0x00, 0x80));
_mouseText->setFont(FontProvider::kSmallFont);
_mouseText->setTargetWidth(96);
} else {
Expand Down
4 changes: 2 additions & 2 deletions engines/stark/ui/dialogbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "engines/stark/stark.h"
#include "engines/stark/ui/window.h"
#include "engines/stark/visual/text.h"
#include "engines/stark/gfx/color.h"

#include "common/keyboard.h"
#include "common/scummsys.h"
Expand Down Expand Up @@ -90,7 +90,7 @@ class DialogBox : public Window {
Common::Rect _cancelButtonRect;
Common::Rect _messageRect;

const Color _textColor = Color(0xFF, 0xFF, 0xFF);
const Gfx::Color _textColor = Gfx::Color(0xFF, 0xFF, 0xFF);

ConfirmCallback *_confirmCallback;
};
Expand Down
2 changes: 1 addition & 1 deletion engines/stark/ui/menu/dialogmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ DialogLineText::DialogLineText(Gfx::Driver *gfx, uint logIndex, uint lineIndex,
Common::String name = StarkGlobal->getCharacterName(logLine.characterId);
name.toUppercase();

Color color = logLine.characterId == StarkGlobal->getApril()->getCharacterIndex() ? _textColorApril : _textColorNormal;
Gfx::Color color = logLine.characterId == StarkGlobal->getApril()->getCharacterIndex() ? _textColorApril : _textColorNormal;

_nameText.setText(name);
_nameText.setColor(color);
Expand Down
10 changes: 5 additions & 5 deletions engines/stark/ui/menu/dialogmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class ChapterTitleText {
void onScreenChanged() { _text.reset(); }

private:
const Color _color = Color(0x68, 0x05, 0x04);
const Gfx::Color _color = Gfx::Color(0x68, 0x05, 0x04);

Common::Point _pos;
VisualText _text;
Expand Down Expand Up @@ -127,8 +127,8 @@ class DialogLineText {
}

private:
const Color _textColorApril = Color(0x68, 0x05, 0x04);
const Color _textColorNormal = Color(0x1E, 0x1E, 0x96);
const Gfx::Color _textColorApril = Gfx::Color(0x68, 0x05, 0x04);
const Gfx::Color _textColorNormal = Gfx::Color(0x1E, 0x1E, 0x96);

Common::Point _namePos, _linePos;
VisualText _nameText, _lineText;
Expand Down Expand Up @@ -158,8 +158,8 @@ class DialogTitleWidget : public StaticLocationWidget {
void onScreenChanged() override;

private:
const Color _textColorHovered = Color(0x1E, 0x1E, 0x96);
const Color _textColorDefault = Color(0x00, 0x00, 0x00);
const Gfx::Color _textColorHovered = Gfx::Color(0x1E, 0x1E, 0x96);
const Gfx::Color _textColorDefault = Gfx::Color(0x00, 0x00, 0x00);

uint _logIndex, _chapter;
int _width, _height;
Expand Down
2 changes: 1 addition & 1 deletion engines/stark/ui/menu/diaryindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void DiaryIndexScreen::open() {

void DiaryIndexScreen::widgetTextColorHandler(StaticLocationWidget &widget, const Common::Point &mousePos) {
if (widget.isVisible()) {
Color textColor = widget.isMouseInside(mousePos) ? _textColorHovered : _textColorDefault;
Gfx::Color textColor = widget.isMouseInside(mousePos) ? _textColorHovered : _textColorDefault;
widget.setTextColor(textColor);
}
}
Expand Down
4 changes: 2 additions & 2 deletions engines/stark/ui/menu/diaryindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class DiaryIndexScreen : public StaticLocationScreen {
void dialogHandler();
void quitHandler();

const Color _textColorHovered = Color(0x1E, 0x1E, 0x96);
const Color _textColorDefault = Color(0x00, 0x00, 0x00);
const Gfx::Color _textColorHovered = Gfx::Color(0x1E, 0x1E, 0x96);
const Gfx::Color _textColorDefault = Gfx::Color(0x00, 0x00, 0x00);
};

} // End of namespace Stark
Expand Down
6 changes: 3 additions & 3 deletions engines/stark/ui/menu/fmvmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ class FMVWidget {

void onClick();

void setTextColor(const Color &color) { _title.setColor(color); }
void setTextColor(const Gfx::Color &color) { _title.setColor(color); }

void onScreenChanged() { _title.reset(); }

private:
const Color _textColorHovered = Color(0x1E, 0x1E, 0x96);
const Color _textColorDefault = Color(0x00, 0x00, 0x00);
const Gfx::Color _textColorHovered = Gfx::Color(0x1E, 0x1E, 0x96);
const Gfx::Color _textColorDefault = Gfx::Color(0x00, 0x00, 0x00);

Common::Point _formatRectPos;
int _fontHeight;
Expand Down
2 changes: 1 addition & 1 deletion engines/stark/ui/menu/locationscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void StaticLocationWidget::setupSounds(int16 enterSound, int16 clickSound) {
}
}

void StaticLocationWidget::setTextColor(const Color &textColor) {
void StaticLocationWidget::setTextColor(const Gfx::Color &textColor) {
if (!_renderEntry) return;

VisualText *text = _renderEntry->getText();
Expand Down
4 changes: 2 additions & 2 deletions engines/stark/ui/menu/locationscreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "engines/stark/ui/screen.h"
#include "engines/stark/ui/window.h"
#include "engines/stark/visual/text.h"
#include "engines/stark/gfx/color.h"

namespace Stark {

Expand Down Expand Up @@ -121,7 +121,7 @@ class StaticLocationWidget {
*
* Only applies for widget referring to a RenderEntry for a text visual
*/
void setTextColor(const Color &textColor);
void setTextColor(const Gfx::Color &textColor);

/** Widgets must be visible to be rendered and interactive */
bool isVisible() const;
Expand Down
4 changes: 2 additions & 2 deletions engines/stark/ui/menu/saveloadmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ void SaveLoadMenuScreen::open() {
CLICK_HANDLER(SaveLoadMenuScreen, prevPageHandler),
nullptr));
_widgets.back()->setupSounds(0, 1);
_widgets.back()->setTextColor(Color(0, 0, 0));
_widgets.back()->setTextColor(Gfx::Color(0, 0, 0));
_widgets.back()->setVisible(_page > 0);

_widgets.push_back(new StaticLocationWidget(
"Next",
CLICK_HANDLER(SaveLoadMenuScreen, nextPageHandler),
nullptr));
_widgets.back()->setupSounds(0, 1);
_widgets.back()->setTextColor(Color(0, 0, 0));
_widgets.back()->setTextColor(Gfx::Color(0, 0, 0));
_widgets.back()->setVisible(_page < _maxPage);

loadSaveData(_page);
Expand Down
4 changes: 2 additions & 2 deletions engines/stark/ui/menu/saveloadmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ class SaveDataWidget : public StaticLocationWidget {
bool hasSave() { return _hasSave; }

private:
const Color _outlineColor = Color(0x1E, 0x1E, 0x96);
const Color _textColor = Color(0x5C, 0x48, 0x3D);
const Gfx::Color _outlineColor = Gfx::Color(0x1E, 0x1E, 0x96);
const Gfx::Color _textColor = Gfx::Color(0x5C, 0x48, 0x3D);

int _slot;
SaveLoadMenuScreen *_screen;
Expand Down
6 changes: 3 additions & 3 deletions engines/stark/ui/menu/settingsmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ class SettingsMenuScreen : public StaticLocationScreen {
void backHandler();

private:
const Color _textColorHovered = Color(0x1E, 0x1E, 0x96);
const Color _textColorDefault = Color(0x00, 0x00, 0x00);
const Gfx::Color _textColorHovered = Gfx::Color(0x1E, 0x1E, 0x96);
const Gfx::Color _textColorDefault = Gfx::Color(0x00, 0x00, 0x00);

TestSoundManager _soundManager;
};
Expand Down Expand Up @@ -155,7 +155,7 @@ class VolumeWidget : public StaticLocationWidget {
void onMouseUp() override;

private:
const Color _textColorBgHovered = Color(0xFF, 0xFF, 0xFF);
const Gfx::Color _textColorBgHovered = Gfx::Color(0xFF, 0xFF, 0xFF);
static const int _maxVolume = 256;

VisualImageXMG *_sliderImage;
Expand Down
4 changes: 2 additions & 2 deletions engines/stark/ui/world/actionmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ ActionMenu::ActionMenu(Gfx::Driver *gfx, Cursor *cursor) :
_background = StarkStaticProvider->getUIElement(StaticProvider::kActionMenuBg);

_itemDescription = new VisualText(gfx);
_itemDescription->setColor(Color(0xFF, 0xFF, 0xFF));
_itemDescription->setBackgroundColor(Color(0x00, 0x00, 0x00, 0x80));
_itemDescription->setColor(Gfx::Color(0xFF, 0xFF, 0xFF));
_itemDescription->setBackgroundColor(Gfx::Color(0x00, 0x00, 0x00, 0x80));
_itemDescription->setFont(FontProvider::kSmallFont);
_itemDescription->setTargetWidth(96);

Expand Down
2 changes: 1 addition & 1 deletion engines/stark/ui/world/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void Button::showButtonHint() {
if (!_mouseText) {
_mouseText = new VisualText(StarkGfx);
_mouseText->setText(_text);
_mouseText->setColor(Color(0xFF, 0xFF, 0xFF));
_mouseText->setColor(Gfx::Color(0xFF, 0xFF, 0xFF));
_mouseText->setFont(FontProvider::kSmallFont);
_mouseText->setTargetWidth(96);
}
Expand Down
4 changes: 2 additions & 2 deletions engines/stark/ui/world/clicktext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace Stark {

ClickText::ClickText(const Common::String &text, const Color &color) :
ClickText::ClickText(const Common::String &text, const Gfx::Color &color) :
_text(text),
_color(color) {
_visualPassive = new VisualText(StarkGfx);
Expand All @@ -36,7 +36,7 @@ ClickText::ClickText(const Common::String &text, const Color &color) :

_visualActive = new VisualText(StarkGfx);
_visualActive->setText(_text);
_visualActive->setColor(Color(0x00, 0x00, 0x00));
_visualActive->setColor(Gfx::Color(0x00, 0x00, 0x00));
_visualActive->setBackgroundColor(_color);
_visualActive->setFont(FontProvider::kBigFont);
_visualActive->setTargetWidth(600);
Expand Down
6 changes: 3 additions & 3 deletions engines/stark/ui/world/clicktext.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#ifndef STARK_UI_CLICK_TEXT_H
#define STARK_UI_CLICK_TEXT_H

#include "engines/stark/visual/text.h"
#include "engines/stark/gfx/color.h"

#include "common/scummsys.h"
#include "common/rect.h"
Expand All @@ -34,7 +34,7 @@ class VisualText;

class ClickText {
public:
ClickText(const Common::String &text, const Color &color);
ClickText(const Common::String &text, const Gfx::Color &color);
~ClickText();

void setPosition(const Common::Point &pos) { _position = pos; }
Expand All @@ -52,7 +52,7 @@ class ClickText {
Common::Point _position;
Common::String _text;
Common::Rect _bbox;
Color _color;
Gfx::Color _color;
};

} // End of namespace Stark
Expand Down
2 changes: 1 addition & 1 deletion engines/stark/ui/world/dialogpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void DialogPanel::onRender() {
void DialogPanel::updateSubtitleVisual() {
clearSubtitleVisual();

Color color = _otherColor;
Gfx::Color color = _otherColor;
if (_currentSpeech->characterIsApril())
color = _aprilColor;

Expand Down
7 changes: 4 additions & 3 deletions engines/stark/ui/world/dialogpanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define STARK_UI_DIALOG_PANEL_H

#include "engines/stark/ui/window.h"
#include "engines/stark/visual/text.h"
#include "engines/stark/gfx/color.h"

#include "common/scummsys.h"
#include "common/str.h"
Expand All @@ -34,6 +34,7 @@
namespace Stark {

class VisualImageXMG;
class VisualText;
class ClickText;

namespace Resources {
Expand Down Expand Up @@ -103,8 +104,8 @@ class DialogPanel : public Window {
Common::Array<ClickText*> _options;
bool _acceptIdleMousePos;

Color _aprilColor = Color(0xFF, 0xC0, 0x00);
Color _otherColor = Color(0xFF, 0x40, 0x40);
const Gfx::Color _aprilColor = Gfx::Color(0xFF, 0xC0, 0x00);
const Gfx::Color _otherColor = Gfx::Color(0xFF, 0x40, 0x40);
static const uint32 _optionsTop = 4;
static const uint32 _optionsLeft = 30;
static const uint32 _optionsHeight = 80;
Expand Down
Loading

0 comments on commit aa5076f

Please sign in to comment.