Browse Source

[QOL/UX] Multiplayer Player Colors (#8317)

pull/8327/head^2
Eric Robinson 2 months ago committed by GitHub
parent
commit
2e394d0f00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 22
      Source/automap.cpp
  2. 33
      Source/engine/render/scrollrt.cpp
  3. BIN
      assets/data/monstertags.clx
  4. 5
      docs/CHANGELOG.md

22
Source/automap.cpp

@ -38,7 +38,10 @@ Point Automap;
enum MapColors : uint8_t {
/** color used to draw the player's arrow */
MapColorsPlayer = (PAL8_ORANGE + 1),
MapColorsPlayer1 = (PAL8_ORANGE + 1),
MapColorsPlayer2 = (PAL8_YELLOW + 1),
MapColorsPlayer3 = (PAL8_RED + 1),
MapColorsPlayer4 = (PAL8_BLUE + 1),
/** color for bright map lines (doors, stairs etc.) */
MapColorsBright = PAL8_YELLOW,
/** color for dim map lines/dots */
@ -1318,12 +1321,27 @@ void SearchAutomapItem(const Surface &out, const Displacement &myPlayerOffset, i
}
}
uint8_t GetPlayerMapColor(int id)
{
static constexpr uint8_t PlayerMapColors[] = {
MapColorsPlayer1,
MapColorsPlayer2,
MapColorsPlayer3,
MapColorsPlayer4,
};
if (id < 0 || id >= static_cast<int>(SDL_arraysize(PlayerMapColors)))
return MapColorsPlayer1;
return PlayerMapColors[id];
}
/**
* @brief Renders an arrow on the automap, centered on and facing the direction of the player.
*/
void DrawAutomapPlr(const Surface &out, const Displacement &myPlayerOffset, const Player &player)
{
const uint8_t playerColor = MapColorsPlayer + (8 * player.getId()) % 128;
const uint8_t playerColor = GetPlayerMapColor(player.getId());
const Point tile = player.position.tile;

33
Source/engine/render/scrollrt.cpp

@ -87,6 +87,16 @@
namespace devilution {
enum OutlineColors : uint8_t {
OutlineColorsPlayer1 = (PAL16_ORANGE + 7),
OutlineColorsPlayer2 = (PAL16_YELLOW + 7),
OutlineColorsPlayer3 = (PAL16_RED + 7),
OutlineColorsPlayer4 = (PAL16_BLUE + 7),
OutlineColorsObject = (PAL16_YELLOW + 2),
OutlineColorsTowner = (PAL16_BEIGE + 6),
OutlineColorsMonster = (PAL16_RED + 9),
};
bool AutoMapShowItems;
// DevilutionX extension.
@ -430,6 +440,21 @@ void DrawPlayerIcons(const Surface &out, const Player &player, Point position, b
DrawPlayerIconHelper(out, MissileGraphicID::Reflect, position + Displacement { 0, 16 }, player, infraVision, lightTableIndex);
}
uint8_t GetPlayerOutlineColor(int id)
{
static constexpr uint8_t PlayerOutlineColors[] = {
OutlineColorsPlayer1,
OutlineColorsPlayer2,
OutlineColorsPlayer3,
OutlineColorsPlayer4,
};
if (id < 0 || id >= static_cast<int>(SDL_arraysize(PlayerOutlineColors)))
return OutlineColorsPlayer1;
return PlayerOutlineColors[id];
}
/**
* @brief Render a player sprite
* @param out Output buffer
@ -447,7 +472,7 @@ void DrawPlayer(const Surface &out, const Player &player, Point tilePosition, Po
const Point spriteBufferPosition = targetBufferPosition + player.getRenderingOffset(sprite);
if (&player == PlayerUnderCursor)
ClxDrawOutlineSkipColorZero(out, 165, spriteBufferPosition, sprite);
ClxDrawOutlineSkipColorZero(out, GetPlayerOutlineColor(player.getId()), spriteBufferPosition, sprite);
if (&player == MyPlayer && IsNoneOf(leveltype, DTYPE_NEST, DTYPE_CRYPT)) {
ClxDraw(out, spriteBufferPosition, sprite);
@ -500,7 +525,7 @@ void DrawObject(const Surface &out, const Object &objectToDraw, Point tilePositi
const Point screenPosition = targetBufferPosition + objectToDraw.getRenderingOffset(sprite, tilePosition);
if (&objectToDraw == ObjectUnderCursor) {
ClxDrawOutlineSkipColorZero(out, 194, screenPosition, sprite);
ClxDrawOutlineSkipColorZero(out, OutlineColorsObject, screenPosition, sprite);
}
if (objectToDraw.applyLighting) {
ClxDrawLight(out, screenPosition, sprite, lightTableIndex);
@ -713,7 +738,7 @@ void DrawMonsterHelper(const Surface &out, Point tilePosition, Point targetBuffe
const Point position = targetBufferPosition + towner.getRenderingOffset();
const ClxSprite sprite = towner.currentSprite();
if (mi == pcursmonst) {
ClxDrawOutlineSkipColorZero(out, 166, position, sprite);
ClxDrawOutlineSkipColorZero(out, OutlineColorsTowner, position, sprite);
}
ClxDraw(out, position, sprite);
return;
@ -738,7 +763,7 @@ void DrawMonsterHelper(const Surface &out, Point tilePosition, Point targetBuffe
const Point monsterRenderPosition = targetBufferPosition + offset;
if (mi == pcursmonst) {
ClxDrawOutlineSkipColorZero(out, 233, monsterRenderPosition, sprite);
ClxDrawOutlineSkipColorZero(out, OutlineColorsMonster, monsterRenderPosition, sprite);
}
DrawMonster(out, tilePosition, monsterRenderPosition, monster, lightTableIndex);
}

BIN
assets/data/monstertags.clx

Binary file not shown.

5
docs/CHANGELOG.md

@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Features
#### Graphics / Audio
- Better use of colors to differentiate players in multiplayer
### Bug Fixes
#### Graphics / Audio

Loading…
Cancel
Save