Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/caveexpress/client/CaveExpressClientMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@

namespace caveexpress {

static const Color waterLineColor = { 0.99f, 0.99f, 1.0f, 1.0f };
static const Color color = { (float)WATERCOLOR[0] / 255.0f, (float)WATERCOLOR[1] / 255.0f, (float)WATERCOLOR[2] / 255.0f, WATER_ALPHA
/ 255.0f };

CaveExpressClientMap::CaveExpressClientMap (int x, int y, int width, int height, IFrontend *frontend,
ServiceProvider& serviceProvider, int referenceTileWidth) :
ClientMap(x, y, width, height, frontend, serviceProvider, referenceTileWidth), _waterHeight(0.0), _target(nullptr)
Expand Down Expand Up @@ -58,7 +54,7 @@ void CaveExpressClientMap::renderWater (int x, int y) const
const SDL_Rect& rect = getWaterRect(x, y);
Log::trace(LOG_GAMEIMPL, "rect:(%i,%i,%i,%i), x:%i, y:%i, water:(w:%i, h:%i, surf:%i, grnd:%i, wh:%f, scale:%i)",
_x, _y, _width, _height, x, y, rect.w, rect.h, rect.y, rect.y + rect.h, _waterHeight, _scale);
_frontend->renderWaterPlane(rect.x, rect.y, rect.w, rect.h, color, waterLineColor);
_frontend->renderWaterPlane(rect.x, rect.y, rect.w, rect.h, waterColor, waterLineColor);
if (Config.isDebug()) {
const int waterGround = rect.y + rect.h;
_frontend->renderLine(rect.x, rect.y, rect.x + rect.w, rect.y, colorRed);
Expand Down
5 changes: 2 additions & 3 deletions src/caveexpress/client/ui/nodes/UINodeBackgroundScene.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "UINodeBackgroundScene.h"
#include "common/Math.h"
#include "ui/UI.h"
#include "client/ClientMap.h"
#include "caveexpress/shared/CaveExpressMapFailedReasons.h"
Expand Down Expand Up @@ -86,9 +87,7 @@ int UINodeBackgroundScene::renderGround (int x, int y) const

void UINodeBackgroundScene::renderWater (int x, int y) const
{
static const Color color = { WATERCOLOR[0] / 255.0f, WATERCOLOR[1] / 255.0f, WATERCOLOR[2] / 255.0f, WATER_ALPHA
/ 255.0f };
_frontend->renderFilledRect(x, y, _frontend->getWidth() - x, _frontend->getHeight() - y, color);
_frontend->renderFilledRect(x, y, _frontend->getWidth() - x, _frontend->getHeight() - y, waterColor);
}

void UINodeBackgroundScene::renderFailedOnGround (int x, int y, const MapFailedReason& reason, float offsetY) const
Expand Down
4 changes: 1 addition & 3 deletions src/caveexpress/client/ui/nodes/UINodeMapEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ void UINodeMapEditor::renderWater (int x, int y) const
const int waterPixelHeight = _waterHeight * tileHeight;
const int waterPixelWidth = getScreenMapGridWidth() * tileWidth;

Color waterColor = { 0.7f, 0.7f, 1.0f, 0.8f };
renderLine(x, waterPixelSurface, x + waterPixelWidth, waterPixelSurface, waterColor);
waterColor[3] = 0.4;
renderLine(x, waterPixelSurface, x + waterPixelWidth, waterPixelSurface, waterLineColor);
renderFilledRect(x, waterPixelSurface + 1, waterPixelWidth, waterPixelHeight, waterColor);
}

Expand Down
5 changes: 0 additions & 5 deletions src/modules/client/ClientMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
#include <vector>
#include <unordered_map>

namespace {
const uint8_t WATER_ALPHA = 120;
const uint8_t WATERCOLOR[] = { 178, 178, 255, WATER_ALPHA };
}

class ClientMap: public IMap, public IClientCallback, public IEventObserver, public IParticleEnvironment {
public:
typedef std::unordered_map<uint16_t, ClientEntityPtr> ClientEntityMap;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/common/IFrontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class IFrontend {
// @param w the width of the rect to fill <= 0 to use the full screen width
// @param h the height of the rect to fill <= 0 to use the full screen height
virtual void renderRect (int x, int y, int w, int h, const Color& color) = 0;
virtual bool renderWaterPlane (int x, int y, int w, int h, const Color& fillColor, const Color& waterLineColor) {
renderLine(x, y - 1, x + w, y - 1, waterLineColor);
virtual bool renderWaterPlane (int x, int y, int w, int h, const Color& fillColor, const Color& lineColor) {
renderLine(x, y - 1, x + w, y - 1, lineColor);
renderFilledRect(x, y, w, h, fillColor);
return true;
}
Expand Down
15 changes: 15 additions & 0 deletions src/modules/common/Math.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ static const Color highlightColor = { 1.0f, 1.0f, 1.0f, 0.5f };
static const Color colorYellow = { 1.0f, 1.0f, 0.0f, 1.0f };
static const Color colorCyan = { 0.2313f, 0.7372f, 0.8274f, 1.0f };

// water color
// const uint8_t WATER_ALPHA = 80, WATERCOLOR[] = { 26, 45, 71, WATER_ALPHA }; // dark blue
// const uint8_t WATER_ALPHA = 120, WATERCOLOR[] = { 56, 85, 121, WATER_ALPHA }; // dark cyan
// const uint8_t WATER_ALPHA = 130, WATERCOLOR[] = { 56, 95, 151, WATER_ALPHA }; // cyan
static const uint8_t WATER_ALPHA = 150, WATERCOLOR[] = { 58, 118, 181, WATER_ALPHA }; // skyblue

static const Color waterLineColor =
{ (float)WATERCOLOR[0] / 255.0f * 1.2f,
(float)WATERCOLOR[1] / 255.0f * 1.2f,
(float)WATERCOLOR[2] / 255.0f * 1.2f, 1.f };
static const Color waterColor =
{ (float)WATERCOLOR[0] / 255.0f,
(float)WATERCOLOR[1] / 255.0f,
(float)WATERCOLOR[2] / 255.0f, WATER_ALPHA / 255.0f };

inline void FadeIn (float& value, float frac)
{
value *= frac;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/gfx/GL3Frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ GL3Frontend::~GL3Frontend ()
{
}

bool GL3Frontend::renderWaterPlane (int x, int y, int w, int h, const Color& fillColor, const Color& waterLineColor)
bool GL3Frontend::renderWaterPlane (int x, int y, int w, int h, const Color& fillColor, const Color& lineColor)
{
renderBatches();
const float width = _fbo.rect().w;
Expand Down Expand Up @@ -45,7 +45,7 @@ bool GL3Frontend::renderWaterPlane (int x, int y, int w, int h, const Color& fil
if (_waterShader.hasUniform("u_watercolor"))
_waterShader.setUniform4fv("u_watercolor", fillColor, 0, 4);
renderBatchesWithShader(_waterShader);
renderLine(x, y - 1, x + w, y - 1, waterLineColor);
renderLine(x, y - 1, x + w, y - 1, lineColor);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/gfx/GL3Frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class GL3Frontend: public AbstractGLFrontend {
explicit GL3Frontend (std::shared_ptr<IConsole> console);
virtual ~GL3Frontend ();

bool renderWaterPlane (int x, int y, int w, int h, const Color& fillColor, const Color& waterLineColor) override;
bool renderWaterPlane (int x, int y, int w, int h, const Color& fillColor, const Color& lineColor) override;
void initRenderer () override;
void renderBatches () override;
};
Loading