📄 statusbar.cpp
字号:
//*************************************************************************
//***** Function: RemoveItem(char type)
//***** Details: Remove a specific item from the player's inventory
//*************************************************************************
DBOOL CStatusBar::RemoveItem(char type)
{
if(!m_nNumItems) return 0;
short i;
char found = 0;
for(i = 0; i < SB_NUM_ITEMS; i++)
if(m_hItems[i].type == type)
{
if(m_hItems[i].amount > 1) { m_hItems[i].amount--; return 1; }
memset(&(m_hItems[i]), 0, sizeof(CInventoryItem));
m_hItems[i].locXRight = SB_INVICON_SIZE_X;
m_nNumItems--;
SetupEquipList();
return 1;
}
return 0;
}
//*************************************************************************
//***** Function: ClearItems()
//***** Details: Removes all items in the player's inventory
//*************************************************************************
void CStatusBar::ClearItems()
{
char i;
memset(m_hItems, 0, sizeof(CInventoryItem) * SB_NUM_ITEMS);
for(i = 0; i < SB_NUM_ITEMS; i++)
{
m_hItems[i].slot = i;
m_hItems[i].locXRight = SB_INVICON_SIZE_X;
m_hItemList[i] = &(m_hItems[i]);
}
for(i = 4; i < SB_NUM_ITEMS; i++)
{
m_hItems[i].type = (INV_PROXIMITY + i - 4);
m_hItems[i].amount = 0;
m_hItems[i].locXLeft = (INV_PROXIMITY + i - 4) * SB_INVICON_SIZE_X;
m_hItems[i].locXRight = m_hItems[i].locXLeft + SB_INVICON_SIZE_X;
m_nNumItems++;
}
m_hSelectedItem = m_hItemList[0];
m_bCurrentItem = m_hSelectedItem->type;
m_nNumItems = 0;
}
//*************************************************************************
//***** Function: AddSpell(char type)
//***** Details: Add a spell to the player's spell book
//*************************************************************************
/*
DBOOL CStatusBar::AddSpell(char type)
{
CInventoryItem *tempSpell;
char i;
if(m_nNumSpells == SB_NUM_SPELLS) return 0;
for(i = 0; i < SB_NUM_SPELLS; i++)
if(m_hSpells[i].type == type) return 0;
for(i = 0; i < SB_NUM_SPELLS; i++)
if(!m_hSpells[i].type) { tempSpell = &(m_hSpells[i]); break; }
tempSpell->type = type;
tempSpell->slot = i;
tempSpell->amount = 1;
tempSpell->locXLeft = type * SB_INVICON_SIZE_X;
tempSpell->locXRight = tempSpell->locXLeft + SB_INVICON_SIZE_X;
m_nNumSpells++;
m_hSelectedSpell = tempSpell;
m_bCurrentItem = INV_BASESPELL + m_hSelectedSpell->type - 1;
tempSpell = 0;
SetupEquipList();
if(type) m_pCurrentSpells[type-1] = 1;
return 1;
}
*/
//*************************************************************************
//***** Function: RemoveSpell(char type)
//***** Details: Removes a spell from the player's spell book
//*************************************************************************
DBOOL CStatusBar::RemoveSpell(char type)
{
if(!m_nNumSpells) return 0;
short i;
char found = 0;
for(i = 0; i < SB_NUM_SPELLS; i++)
if(m_hSpellList[i]->type == type)
{
memset(m_hSpellList[i], 0, sizeof(CInventoryItem));
m_hSpellList[i]->locXRight = SB_INVICON_SIZE_X;
m_nNumSpells--;
if(type) m_pCurrentSpells[type-1] = 0;
SetupEquipList();
return 1;
}
return 0;
}
//*************************************************************************
//***** Function: ClearSpells()
//***** Details: Removes all spells in the player's spell book
//*************************************************************************
void CStatusBar::ClearSpells()
{
char i;
memset(m_hSpells, 0, sizeof(CInventoryItem) * SB_NUM_SPELLS);
for(i = 0; i < SB_NUM_SPELLS; i++)
{
m_hSpells[i].slot = i;
m_hSpells[i].locXRight = SB_INVICON_SIZE_X;
m_hSpellList[i] = &(m_hSpells[i]);
}
m_hSelectedSpell = m_hSpellList[0];
m_nNumSpells = 0;
memset(m_pCurrentSpells, 0, SB_NUM_SINGLEPLAYER_SPELLS + 1);
}
//*************************************************************************
//***** Function: SetupEquipList(char *weapons, char *items, char *spells, char spellOffset)
//***** Details: Fill in the equipment list with all correct values
//*************************************************************************
void CStatusBar::SetupEquipList()
{
char i;
m_pEquipList[0].type = 0; m_pEquipList[0].name = 0; m_pEquipList[0].offset = 0;
m_pEquipList[1].type = 1; m_pEquipList[1].name = WEAP_MELEE; m_pEquipList[1].offset = 25;
for(i = 2; i < 11; i++)
{ m_pEquipList[i].type = 1; m_pEquipList[i].name = m_hWeapons[i-1]; m_pEquipList[i].offset = 25; }
m_pEquipList[11].type = 0; m_pEquipList[11].name = 1; m_pEquipList[11].offset = 0;
for(i = 12; i < 16; i++)
{ m_pEquipList[i].type = 2; m_pEquipList[i].name = m_hItems[i-12].type; m_pEquipList[i].offset = 25; }
for(i = 16; i < 20; i++)
{ m_pEquipList[i].type = 3; m_pEquipList[i].name = m_hItems[i-12].type; m_pEquipList[i].offset = 25; }
m_pEquipList[20].type = 0; m_pEquipList[20].name = 2; m_pEquipList[20].offset = 0;
for(i = 21; i < 27; i++)
{ m_pEquipList[i].type = 4; m_pEquipList[i].name = m_hSpells[i-21].type; m_pEquipList[i].offset = 25; }
}
//*************************************************************************
//***** Function: HandleKeyDown()
//***** Details: Handle the in-game interface control
//*************************************************************************
DBOOL CStatusBar::HandleKeyDown(int key)
{
switch(key)
{
case VK_F1: // turn on information screen
m_bInfoOn = !m_bInfoOn;
return 1;
/* case VK_TAB: // turn on the big inventory screen
m_bEquipOn = 1;
m_bInventoryOn = 0;
return 1;
*/
case VK_ADD: // turn on more stats
case 0x00BB:
if(m_bStatsOn < 4) m_bStatsOn++;
m_nInventoryY = m_nScreenHeight - SB_INVICON_SIZE_Y;
return 1;
case VK_SUBTRACT:// turn off more stats
case 0x00BD:
if(m_bStatsOn > 0) m_bStatsOn--;
if(!m_bStatsOn) m_nInventoryY = m_nScreenHeight + SB_HIGHLIGHT_OFFSET_Y;
return 1;
/* case VK_W: // Spell cycle right
if(m_bInventoryOn != 2)
{ m_fInvStartTime = m_pClientDE->GetTime(); m_bInventoryOn = 2; m_bInventoryState = 0; }
else if(m_bInventoryState == 2)
{ m_fInvStartTime = m_pClientDE->GetTime(); m_bInventoryState = 4; }
return 1;
case VK_Q: // Spell cycle left
if(m_bInventoryOn != 2)
{ m_fInvStartTime = m_pClientDE->GetTime(); m_bInventoryOn = 2; m_bInventoryState = 0; }
else if(m_bInventoryState == 2)
{ m_fInvStartTime = m_pClientDE->GetTime(); m_bInventoryState = 3; }
return 1;
case 0xDD: // ']' = Item cycle right
if(m_bInventoryOn != 1)
{ m_fInvStartTime = m_pClientDE->GetTime(); m_bInventoryOn = 1; m_bInventoryState = 0; }
else if(m_bInventoryState == 2)
{ m_fInvStartTime = m_pClientDE->GetTime(); m_bInventoryState = 4; }
return 1;
case 0xDB: // '[' = Item cycle left
if(m_bInventoryOn != 1)
{ m_fInvStartTime = m_pClientDE->GetTime(); m_bInventoryOn = 1; m_bInventoryState = 0; }
else if(m_bInventoryState == 2)
{ m_fInvStartTime = m_pClientDE->GetTime(); m_bInventoryState = 3; }
return 1;
case VK_E:
if(!m_bInventoryOn)
{
if(m_hSelectedSpell->type)
{ m_bCurrentItem = m_hSelectedSpell->slot; return 4; }
else
m_bCurrentItem = 0;
}
else if(m_bInventoryState == 2)
{ m_fInvStartTime = m_pClientDE->GetTime(); m_bInventoryState = 5; return 2; }
return 1;
case VK_RETURN:
if(!m_bInventoryOn)
{
m_bCurrentItem = m_hSelectedItem->slot;
if(m_hSelectedItem->type == INV_SPELLBOOK) { InitSpellbook(); return 1; }
return 3;
}
else if(m_bInventoryState == 2)
{ m_fInvStartTime = m_pClientDE->GetTime(); m_bInventoryState = 5; return 2; }
return 1;
*/
// case VK_F5:
// InitCharScreen();
// m_pClientDE->SetInputState (DFALSE);
// return 1;
case VK_DELETE:
return 5;
}
return 0;
}
//*************************************************************************
//***** Function: HandleSpellbookControl(int key)
//***** Details:
//*************************************************************************
/*
DBOOL CStatusBar::HandleSpellbookControl(int key)
{
switch(key)
{
case VK_ESCAPE:
TermSpellbook();
m_pClientDE->SetInputState (DTRUE);
return 1;
case VK_DOWN:
case VK_RIGHT:
case VK_W:
case 0xDD: // Move down the list of spells
m_bCurrentSpell++;
if(m_bCurrentSpell > SB_NUM_SINGLEPLAYER_SPELLS) m_bCurrentSpell = 0;
return 1;
case VK_UP:
case VK_LEFT:
case VK_Q:
case 0xDB: // Move up the list of spells
m_bCurrentSpell--;
if(m_bCurrentSpell < 0) m_bCurrentSpell = SB_NUM_SINGLEPLAYER_SPELLS;
return 1;
case VK_DELETE: // Remove spell
if(m_pCurrentSpells[g_SpellNameFix[m_bCurrentSpell]])
{
m_bCurrentItem = INV_BASESPELL + g_SpellNameFix[m_bCurrentSpell];
return 3;
}
return 1;
case VK_RETURN: // Memorize a spell
if(!m_pCurrentSpells[g_SpellNameFix[m_bCurrentSpell]] && (m_bSpellLevel >= g_SpellLevel[g_SpellNameFix[m_bCurrentSpell]]) && (m_nNumSpells < SB_NUM_SPELLS))
{
m_bCurrentItem = INV_BASESPELL + g_SpellNameFix[m_bCurrentSpell];
TermSpellbook();
m_pClientDE->SetInputState (DTRUE);
return 2;
}
return 1;
}
return 0;
}
*/
//*************************************************************************
//***** Function: HandleEquipControl(int key)
//***** Details:
//*************************************************************************
DBOOL CStatusBar::HandleEquipControl(int key)
{
switch(key)
{
case VK_TAB: // turn off the big inventory screen
m_bEquipOn = 0;
return 1;
case VK_W:
case 0xDD: // Move down the list of equipment
{
char i = 0;
if(m_bSelectedEquipItem < SB_NUM_EQUIP_ITEMS - 1) { m_bSelectedEquipItem++; i++; }
if(!m_pEquipList[m_bSelectedEquipItem].type) { m_bSelectedEquipItem++; i++; }
if(m_bSelectedEquipItem > m_bTopEquipItem + SB_NUM_EQUIP_DISP_ITEMS - 1)
m_bTopEquipItem += i;
return 1;
}
case VK_Q:
case 0xDB: // Move up the list of equipment
if(m_bSelectedEquipItem == 1) { m_bTopEquipItem = 0; return 1; }
if(m_bSelectedEquipItem > 1) m_bSelectedEquipItem--;
if(!m_pEquipList[m_bSelectedEquipItem].type) m_bSelectedEquipItem--;
if(m_bSelectedEquipItem < m_bTopEquipItem)
m_bTopEquipItem = m_bSelectedEquipItem;
return 1;
case VK_DELETE: // Remove item / spell / weapon
switch(m_pEquipList[m_bSelectedEquipItem].type)
{
case 1:
if(m_pEquipList[m_bSelectedEquipItem].name)
{ m_bCurrentItem = m_bSelectedEquipItem - 1; return 2; }
break;
case 2:
if(m_pEquipList[m_bSelectedEquipItem].name)
{ m_bCurrentItem = m_bSelectedEquipItem - 12; return 3; }
break;
case 3:
break;
case 4:
/*
if(m_pEquipList[m_bSelectedEquipItem].name)
{ m_bCurrentItem = INV_BASESPELL + m_pEquipList[m_bSelectedEquipItem].name - 1; return 4; }
*/
break;
}
return 1;
case VK_RETURN: // Ready item / spell / weapon
switch(m_pEquipList[m_bSelectedEquipItem].type)
{
case 1:
if(m_pEquipList[m_bSelectedEquipItem].name)
{ m_bCurrentItem = m_bSelectedEquipItem - 1; return 5; }
break;
case 2:
m_hSelectedItem = &(m_hItems[m_bSelectedEquipItem - 12]);
break;
case 3:
m_hSelectedItem = &(m_hItems[m_bSelectedEquipItem - 12]);
m_bCurrentItem = m_hSelectedItem->slot;
return 6;
case 4:
m_hSelectedSpell = &(m_hSpells[m_bSelectedEquipItem - 21]);
break;
}
return 1;
}
return 0;
}
//*************************************************************************
//***** Function: HandleCharScreenControl(int key)
//***** Details:
//*************************************************************************
DBOOL CStatusBar::HandleCharScreenControl(int key)
{
if(m_bCSSelectState)
{
switch(key)
{
case VK_ESCAPE:
m_bCSSelectState = 0;
m_pCharFileIndex = 0;
m_pClientDE->FreeFileList(m_pCharFiles);
m_pCharFiles = 0;
return 1;
case VK_RETURN:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -