Browse Source

Experience bar

pull/1108/head
qndel 5 years ago committed by Anders Jenbo
parent
commit
82ab76b22b
  1. 24
      Source/diablo.cpp
  2. 1
      Source/diablo.h
  3. 1
      Source/player.h
  4. 1
      Source/scrollrt.cpp
  5. 40
      SourceX/qol.cpp
  6. 1
      SourceX/qol.h

24
Source/diablo.cpp

@ -423,6 +423,7 @@ static void SaveOptions()
setIniInt("Game", "Cow Quest", sgOptions.bCowQuest);
setIniInt("Game", "Test Bard", sgOptions.bTestBard);
setIniInt("Game", "Test Barbarian", sgOptions.bTestBarbarian);
setIniInt("Game", "Experience Bar", sgOptions.bExperienceBar);
setIniInt("Game", "Enemy Health Bar", sgOptions.bEnemyHealthBar);
setIniValue("Network", "Bind Address", sgOptions.szBindAddress);
@ -465,6 +466,7 @@ static void LoadOptions()
sgOptions.bCowQuest = getIniBool("Game", "Cow Quest", false);
sgOptions.bTestBard = getIniBool("Game", "Test Bard", false);
sgOptions.bTestBarbarian = getIniBool("Game", "Test Barbarian", false);
sgOptions.bExperienceBar = getIniBool("Game", "Experience Bar", false);
sgOptions.bEnemyHealthBar = getIniBool("Game", "Enemy Health Bar", false);
getIniValue("Network", "Bind Address", sgOptions.szBindAddress, sizeof(sgOptions.szBindAddress), "0.0.0.0");
@ -849,17 +851,17 @@ static void ReleaseKey(int vkey)
static void ClosePanels()
{
if (PANELS_COVER) {
if (!chrflag && !questlog && (invflag || sbookflag) && MouseX < 480 && MouseY < PANEL_TOP) {
SetCursorPos(MouseX + 160, MouseY);
} else if (!invflag && !sbookflag && (chrflag || questlog) && MouseX > 160 && MouseY < PANEL_TOP) {
SetCursorPos(MouseX - 160, MouseY);
}
}
invflag = FALSE;
chrflag = FALSE;
sbookflag = FALSE;
questlog = FALSE;
if (PANELS_COVER) {
if (!chrflag && !questlog && (invflag || sbookflag) && MouseX < 480 && MouseY < PANEL_TOP) {
SetCursorPos(MouseX + 160, MouseY);
} else if (!invflag && !sbookflag && (chrflag || questlog) && MouseX > 160 && MouseY < PANEL_TOP) {
SetCursorPos(MouseX - 160, MouseY);
}
}
invflag = FALSE;
chrflag = FALSE;
sbookflag = FALSE;
questlog = FALSE;
}
bool PressEscKey()

1
Source/diablo.h

@ -43,6 +43,7 @@ typedef struct Options {
bool bCowQuest; // Enable the cow quest
bool bTestBard; // Enable the bard hero class
bool bTestBarbarian; // Enable the babarian hero class
bool bExperienceBar; // Show the current level progress
bool bEnemyHealthBar; // Show enemy health at the top of the screen
char szBindAddress[129]; // Optionally bind to a specific network interface

1
Source/player.h

@ -268,6 +268,7 @@ extern int MagicTbl[NUM_CLASSES];
extern int DexterityTbl[NUM_CLASSES];
extern int VitalityTbl[NUM_CLASSES];
extern int MaxStats[NUM_CLASSES][4];
extern int ExpLvlsTbl[MAXCHARLEVEL];
extern const char *const ClassStrTblOld[];
extern const char *const ClassStrTbl[];

1
Source/scrollrt.cpp

@ -1579,6 +1579,7 @@ void DrawAndBlit()
DrawTalkPan(out);
hgt = SCREEN_HEIGHT;
}
DrawXPBar();
scrollrt_draw_cursor_item();
DrawFPS(out);

40
SourceX/qol.cpp

@ -134,4 +134,44 @@ void DrawMonsterHealthBar()
PrintGameStr(out, xPos2 + width / 2 - GetTextWidth(vulnText), yPos + yOffset + height + borderSize + 12, vulnText, COL_RED);
}
void DrawXPBar()
{
if (!sgOptions.bExperienceBar)
return;
int barWidth = 306;
int barHeight = 5;
int yPos = SCREEN_HEIGHT - 9; // y position of xp bar
int xPos = (SCREEN_WIDTH - barWidth) / 2 + 5; // x position of xp bar
int dividerHeight = 3;
int numDividers = 10;
int barColor = 198;
int emptyBarColor = 0;
int frameColor = 245;
bool space = true; // add 1 pixel separator on top/bottom of the bar
CelOutputBuffer out = GlobalBackBuffer();
PrintGameStr(out, xPos - 22, yPos + 6, "XP", COL_WHITE);
int charLevel = plr[myplr]._pLevel;
if (charLevel == MAXCHARLEVEL - 1)
return;
int curXp = ExpLvlsTbl[charLevel];
int prevXp = ExpLvlsTbl[charLevel - 1];
int prevXpDelta = curXp - prevXp;
int prevXpDelta_1 = plr[myplr]._pExperience - prevXp;
if (plr[myplr]._pExperience < prevXp)
return;
int visibleBar = barWidth * (unsigned __int64)prevXpDelta_1 / prevXpDelta;
FillRect(xPos, yPos, barWidth, barHeight, emptyBarColor);
FillRect(xPos, yPos + (space ? 1 : 0), visibleBar, barHeight - (space ? 2 : 0), barColor);
FastDrawHorizLine(xPos - 1, yPos - 1, barWidth + 2, frameColor);
FastDrawHorizLine(xPos - 1, yPos + barHeight, barWidth + 2, frameColor);
FastDrawVertLine(xPos - 1, yPos - 1, barHeight + 2, frameColor);
FastDrawVertLine(xPos + barWidth, yPos - 1, barHeight + 2, frameColor);
for (int i = 1; i < numDividers; i++)
FastDrawVertLine(xPos - 1 + (barWidth * i / numDividers), yPos - dividerHeight - 1, barHeight + dividerHeight * 2 + 2, frameColor);
}
DEVILUTION_END_NAMESPACE

1
SourceX/qol.h

@ -9,6 +9,7 @@
DEVILUTION_BEGIN_NAMESPACE
void DrawMonsterHealthBar();
void DrawXPBar();
DEVILUTION_END_NAMESPACE

Loading…
Cancel
Save