Skip to content

Commit

Permalink
Extra info with Shift
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 committed Jul 11, 2023
1 parent d0a6b66 commit 41d6bae
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 17 deletions.
12 changes: 6 additions & 6 deletions Source/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ void DrawTalkPan(const Surface &out)
}
}

void DrawInvFloatingInfo(const Surface &out)
void DrawInvFloatingInfo(const Surface &out, bool isShiftHeld)
{
Player &myPlayer = *InspectPlayer;

Expand Down Expand Up @@ -1493,7 +1493,7 @@ void DrawInvFloatingInfo(const Surface &out)
const Point position = GetPanelPosition(UiPanels::Inventory, { screenX, screenY });

if (pcursinvitem == slot) {
DrawFloatingItemInfoBox(out, position);
DrawFloatingItemInfoBox(out, position, isShiftHeld);
}
}
}
Expand All @@ -1505,7 +1505,7 @@ void DrawInvFloatingInfo(const Surface &out)

const Point position = GetPanelPosition(UiPanels::Inventory, InvRect[j + SLOTXY_INV_FIRST].position) + Displacement { 0, -1 + INV_SLOT_SIZE_PX };
if (pcursinvitem == ii + INVITEM_INV_FIRST) {
DrawFloatingItemInfoBox(out, position);
DrawFloatingItemInfoBox(out, position, isShiftHeld);
}
}
}
Expand All @@ -1520,12 +1520,12 @@ void DrawInvFloatingInfo(const Surface &out)
const Point position { InvRect[i + SLOTXY_BELT_FIRST].position.x + mainPanelPosition.x, InvRect[i + SLOTXY_BELT_FIRST].position.y + mainPanelPosition.y + InventorySlotSizeInPixels.height };

if (pcursinvitem == i + INVITEM_BELT_FIRST) {
DrawFloatingItemInfoBox(out, position);
DrawFloatingItemInfoBox(out, position, isShiftHeld);
}
}
}

void DrawStashFloatingInfo(const Surface &out)
void DrawStashFloatingInfo(const Surface &out, bool isShiftHeld)
{
constexpr Displacement offset { 0, INV_SLOT_SIZE_PX - 1 };

Expand All @@ -1543,7 +1543,7 @@ void DrawStashFloatingInfo(const Surface &out)
const Point position = GetStashSlotCoord(item.position) + offset;

if (pcursstashitem == itemId) {
DrawFloatingItemInfoBox(out, position);
DrawFloatingItemInfoBox(out, position, isShiftHeld);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ void DrawSpellBook(const Surface &out);
void DrawGoldSplit(const Surface &out, int amount);
void control_drop_gold(SDL_Keycode vkey);
void DrawTalkPan(const Surface &out);
void DrawInvFloatingInfo(const Surface &out);
void DrawStashFloatingInfo(const Surface &out);
void DrawInvFloatingInfo(const Surface &out, bool isShiftHeld);
void DrawStashFloatingInfo(const Surface &out, bool isShiftHeld);
bool control_check_talk_btn();
void control_release_talk_btn();
void control_type_message();
Expand Down
2 changes: 1 addition & 1 deletion Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ void GameEventHandler(const SDL_Event &event, uint16_t modState)
while (IsRedrawEverything()) {
// In direct rendering mode with double/triple buffering, we need
// to prepare all buffers before fading in.
DrawAndBlit();
DrawAndBlit((modState & KMOD_SHIFT) != 0);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Source/engine/render/scrollrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ void scrollrt_draw_game_screen()
RenderPresent();
}

void DrawAndBlit()
void DrawAndBlit(bool isShiftHeld)
{
if (!gbRunGame || HeadlessMode) {
return;
Expand Down Expand Up @@ -1683,8 +1683,8 @@ void DrawAndBlit()
DrawFlaskValues(out, { mainPanel.position.x + mainPanel.size.width - 138, mainPanel.position.y + 28 }, MyPlayer->_pMana >> 6, MyPlayer->_pMaxMana >> 6);

if (*sgOptions.Gameplay.enableFloatingInfoBox) {
DrawInvFloatingInfo(out);
DrawStashFloatingInfo(out);
DrawInvFloatingInfo(out, isShiftHeld);
DrawStashFloatingInfo(out, isShiftHeld);
}

DrawCursor(out);
Expand Down
2 changes: 1 addition & 1 deletion Source/engine/render/scrollrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ void scrollrt_draw_game_screen();
/**
* @brief Render the game
*/
void DrawAndBlit();
void DrawAndBlit(bool isShiftHeld = false);

} // namespace devilution
90 changes: 87 additions & 3 deletions Source/qol/floatinginfobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ int16_t CalculateModifiedStatValue(const ItemStatModifier stat, const Item &item
}
}

void DrawFloatingItemInfoBox(const Surface &out, Point position)
void DrawFloatingItemInfoBox(const Surface &out, Point position, bool isShiftHeld)
{
Player &myPlayer = *MyPlayer;

Expand All @@ -304,8 +304,8 @@ void DrawFloatingItemInfoBox(const Surface &out, Point position)
// Add Item Damage
std::string formattedDam;
if (item._iClass == ICLASS_WEAPON || item._iMinDam != 0 || item._iMaxDam != 0) {
uint8_t minDam = CalculateModifiedStatValue(ItemStatModifier::MinDamage, item);
uint8_t maxDam = CalculateModifiedStatValue(ItemStatModifier::MaxDamage, item);
int16_t minDam = CalculateModifiedStatValue(ItemStatModifier::MinDamage, item);
int16_t maxDam = CalculateModifiedStatValue(ItemStatModifier::MaxDamage, item);
UiFlags damColor = GetItemBonusColors(ItemStatType::Damage, item);
linesWithColor.emplace_back(_("Damage:"), UiFlags::ColorWhite);

Expand Down Expand Up @@ -424,6 +424,90 @@ void DrawFloatingItemInfoBox(const Surface &out, Point position)
}
}

// Add Item Value
std::string formattedValue;
if (item._iClass != ICLASS_GOLD) {
int32_t value = item._iIdentified ? item._iIvalue : item._ivalue;
linesWithColor.emplace_back(_("Value:"), UiFlags::ColorWhite);
formattedValue = fmt::format(fmt::runtime(_("{:d}")), value);
linesWithColor.emplace_back(formattedValue, UiFlags::ColorWhite);
}

// Add Create Info
std::string formattedLevel;
std::string formattedSourceOnlyGood;
std::string formattedSourceMonster;
std::string formattedSourceUnique;
std::string formattedSourceDungeon;
std::string formattedSourceSmith;
std::string formattedSourceSmithPremium;
std::string formattedSourceBoy;
std::string formattedSourceWitch;
std::string formattedSourceHealer;
std::string formattedSourcePregen;
std::string formattedGame;
if (isShiftHeld) {
uint8_t level = item._iCreateInfo & CF_LEVEL;
linesWithColor.emplace_back(_("Level:"), UiFlags::ColorWhite);
formattedLevel = fmt::format(fmt::runtime(_("{:d}")), level);
linesWithColor.emplace_back(formattedLevel, UiFlags::ColorWhite);

std::string source;
linesWithColor.emplace_back(_("Source:"), UiFlags::ColorWhite);
if (HasAllOf(item._iCreateInfo, CF_ONLYGOOD)) {
source = _("??? (OnlyGood)");
formattedSourceOnlyGood = fmt::format(fmt::runtime(_("{:s}")), source);
linesWithColor.emplace_back(formattedSourceOnlyGood, UiFlags::ColorOrange);
}
if (HasAllOf(item._iCreateInfo, CF_UPER1) && HasNoneOf(item._iCreateInfo, CF_UPER15)) {
source = _("Monster");
formattedSourceMonster = fmt::format(fmt::runtime(_("{:s}")), source);
linesWithColor.emplace_back(formattedSourceMonster, UiFlags::ColorOrange);
}
if (HasNoneOf(item._iCreateInfo, CF_UPER1) && HasAllOf(item._iCreateInfo, CF_UPER15)) {
source = _("Unique Monster");
formattedSourceUnique = fmt::format(fmt::runtime(_("{:s}")), source);
linesWithColor.emplace_back(formattedSourceUnique, UiFlags::ColorOrange);
}
if (HasAllOf(item._iCreateInfo, CF_USEFUL)) {
source = _("Dungeon Floor");
formattedSourceDungeon = fmt::format(fmt::runtime(_("{:s}")), source);
linesWithColor.emplace_back(formattedSourceDungeon, UiFlags::ColorOrange);
}
if (HasAllOf(item._iCreateInfo, CF_SMITH)) {
source = _("Griswold");
formattedSourceSmith = fmt::format(fmt::runtime(_("{:s}")), source);
linesWithColor.emplace_back(formattedSourceSmith, UiFlags::ColorOrange);
}
if (HasAllOf(item._iCreateInfo, CF_SMITHPREMIUM)) {
source = _("Griswold Premium");
formattedSourceSmithPremium = fmt::format(fmt::runtime(_("{:s}")), source);
linesWithColor.emplace_back(formattedSourceSmithPremium, UiFlags::ColorOrange);
}
if (HasAllOf(item._iCreateInfo, CF_BOY)) {
source = _("Wirt");
formattedSourceBoy = fmt::format(fmt::runtime(_("{:s}")), source);
linesWithColor.emplace_back(formattedSourceBoy, UiFlags::ColorOrange);
}
if (HasAllOf(item._iCreateInfo, CF_WITCH)) {
source = _("Adria");
formattedSourceWitch = fmt::format(fmt::runtime(_("{:s}")), source);
linesWithColor.emplace_back(formattedSourceWitch, UiFlags::ColorOrange);
}
if (HasAllOf(item._iCreateInfo, CF_HEALER)) {
source = _("Pepin");
formattedSourceHealer = fmt::format(fmt::runtime(_("{:s}")), source);
linesWithColor.emplace_back(formattedSourceHealer, UiFlags::ColorOrange);
}
if (HasAllOf(item._iCreateInfo, CF_PREGEN)) {
source = _("??? (Pregen)");
formattedSourcePregen = fmt::format(fmt::runtime(_("{:s}")), source);
linesWithColor.emplace_back(formattedSourcePregen, UiFlags::ColorOrange);
}
} else {
linesWithColor.emplace_back(_("Hold Shift to see extra info"), UiFlags::ColorOrange);
}

// CONSTRUCT STRING AS A BASE FOR UTILIZING LINESWITHCOLOR DATA
// linesBase is used to place the {} and newlines to grab the actual string data
// Lines that contain a colon may have a different color for the second part, so two {}'s are added
Expand Down
3 changes: 2 additions & 1 deletion Source/qol/floatinginfobox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
#include "engine/point.hpp"
#include "engine/surface.hpp"
#include "items.h"
#include "utils/enum_traits.h"

namespace devilution {

void DrawFloatingItemInfoBox(const Surface &out, Point position);
void DrawFloatingItemInfoBox(const Surface &out, Point position, bool isShiftHeld);

} // namespace devilution

0 comments on commit 41d6bae

Please sign in to comment.