summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-02-25 01:20:00 +0200
committerAndrei Karas <akaras@inbox.ru>2011-02-25 01:38:14 +0200
commit5322d978519f9d5677d2096e1167439c84b23cd1 (patch)
treedfe6324fb6d3b573290687716dd98e45efb76019
parent473dc9b1949ba7c51b59146815969b723a748d6d (diff)
downloadmv-5322d978519f9d5677d2096e1167439c84b23cd1.tar.gz
mv-5322d978519f9d5677d2096e1167439c84b23cd1.tar.bz2
mv-5322d978519f9d5677d2096e1167439c84b23cd1.tar.xz
mv-5322d978519f9d5677d2096e1167439c84b23cd1.zip
Add tabs to spells window. Now it 5 tabs.
Also dont save to configs default cell items for different item containers.
-rw-r--r--src/dropshortcut.cpp5
-rw-r--r--src/game.cpp10
-rw-r--r--src/gui/outfitwindow.cpp17
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp19
-rw-r--r--src/gui/widgets/spellshortcutcontainer.h3
-rw-r--r--src/itemshortcut.cpp5
-rw-r--r--src/spellmanager.cpp54
-rw-r--r--src/spellmanager.h1
-rw-r--r--src/spellshortcut.cpp5
-rw-r--r--src/spellshortcut.h2
10 files changed, 90 insertions, 31 deletions
diff --git a/src/dropshortcut.cpp b/src/dropshortcut.cpp
index 763a7aadd..55046c0f6 100644
--- a/src/dropshortcut.cpp
+++ b/src/dropshortcut.cpp
@@ -75,7 +75,10 @@ void DropShortcut::save()
for (int i = 0; i < DROP_SHORTCUT_ITEMS; i++)
{
const int itemId = mItems[i] ? mItems[i] : -1;
- serverConfig.setValue("drop" + toString(i), itemId);
+ if (itemId != -1)
+ serverConfig.setValue("drop" + toString(i), itemId);
+ else
+ serverConfig.deleteKey("drop" + toString(i));
}
}
diff --git a/src/game.cpp b/src/game.cpp
index 4726d2f96..fe459f804 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -210,9 +210,15 @@ static void createGuiWindows()
specialsWindow = new SpecialsWindow();
dropShortcutWindow = new ShortcutWindow("DropShortcut",
new DropShortcutContainer);
+
spellShortcutWindow = new ShortcutWindow("SpellShortcut",
- new SpellShortcutContainer,
- 265, 310);
+ 265, 328);
+ for (int f = 0; f < SPELL_SHORTCUT_TABS; f ++)
+ {
+ spellShortcutWindow->addTab(toString(f + 1),
+ new SpellShortcutContainer(f));
+ }
+
botCheckerWindow = new BotCheckerWindow();
whoIsOnline = new WhoIsOnline();
killStats = new KillStats;
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index ddd337767..2796e13c8 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -157,14 +157,25 @@ void OutfitWindow::save()
std::string outfitStr;
for (int o = 0; o < OUTFITS_COUNT; o++)
{
+ bool good = false;
for (int i = 0; i < OUTFIT_ITEM_COUNT; i++)
{
- outfitStr += mItems[o][i] ? toString(mItems[o][i]) : toString(-1);
+ int res = mItems[o][i] ? mItems[o][i] : -1;
+ if (res != -1)
+ good = true;
+ outfitStr += toString(res);
if (i < OUTFIT_ITEM_COUNT - 1)
outfitStr += " ";
}
- serverConfig.setValue("Outfit" + toString(o), outfitStr);
- serverConfig.setValue("OutfitUnequip" + toString(o), mItemsUnequip[o]);
+ if (good)
+ serverConfig.setValue("Outfit" + toString(o), outfitStr);
+ else
+ serverConfig.deleteKey("Outfit" + toString(o));
+
+ if (mItemsUnequip[o])
+ serverConfig.deleteKey("OutfitUnequip" + toString(o));
+ else
+ serverConfig.setValue("OutfitUnequip" + toString(o), mItemsUnequip[o]);
outfitStr = "";
}
serverConfig.setValue("OutfitAwayIndex", mAwayOutfit);
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 18482369d..d0f6931aa 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -48,10 +48,11 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
-SpellShortcutContainer::SpellShortcutContainer():
+SpellShortcutContainer::SpellShortcutContainer(unsigned number):
ShortcutContainer(),
mSpellClicked(false),
- mSpellMoved(NULL)
+ mSpellMoved(NULL),
+ mNumber(number)
{
mBoxWidth = mBoxWidth;
@@ -115,7 +116,7 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics)
g->drawImage(mBackgroundImg, itemX, itemY);
- int itemId = spellShortcut->getItem(i);
+ int itemId = spellShortcut->getItem((mNumber * SPELL_SHORTCUT_ITEMS) + i);
if (selectedId >= 0 && itemId == selectedId)
{
g->drawRectangle(gcn::Rectangle(
@@ -163,7 +164,8 @@ void SpellShortcutContainer::mouseDragged(gcn::MouseEvent &event)
if (index == -1)
return;
- const int itemId = spellShortcut->getItem(index);
+ const int itemId = spellShortcut->getItem(
+ (mNumber * SPELL_SHORTCUT_ITEMS) + index);
if (itemId < 0)
return;
@@ -195,7 +197,8 @@ void SpellShortcutContainer::mousePressed(gcn::MouseEvent &event)
if (!spellShortcut || !spellManager)
return;
- const int itemId = spellShortcut->getItem(index);
+ const int itemId = spellShortcut->getItem(
+ (mNumber * SPELL_SHORTCUT_ITEMS) + index);
spellManager->invoke(itemId);
}
}
@@ -210,7 +213,8 @@ void SpellShortcutContainer::mouseReleased(gcn::MouseEvent &event)
if (index == -1)
return;
- const int itemId = spellShortcut->getItem(index);
+ const int itemId = spellShortcut->getItem(
+ (mNumber * SPELL_SHORTCUT_ITEMS) + index);
if (event.getButton() == gcn::MouseEvent::LEFT)
{
@@ -263,7 +267,8 @@ void SpellShortcutContainer::mouseMoved(gcn::MouseEvent &event)
if (index == -1)
return;
- const int itemId = spellShortcut->getItem(index);
+ const int itemId = spellShortcut->getItem(
+ (mNumber * SPELL_SHORTCUT_ITEMS) + index);
mSpellPopup->setVisible(false);
TextCommand *spell = spellManager->getSpell(itemId);
diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h
index 8f1c4b221..a4ad1576a 100644
--- a/src/gui/widgets/spellshortcutcontainer.h
+++ b/src/gui/widgets/spellshortcutcontainer.h
@@ -49,7 +49,7 @@ class SpellShortcutContainer : public ShortcutContainer
/**
* Constructor. Initializes the graphic.
*/
- SpellShortcutContainer();
+ SpellShortcutContainer(unsigned number);
/**
* Destructor.
@@ -83,6 +83,7 @@ class SpellShortcutContainer : public ShortcutContainer
bool mSpellClicked;
TextCommand *mSpellMoved;
SpellPopup *mSpellPopup;
+ unsigned mNumber;
};
#endif
diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp
index 4509b1d70..b15e618d7 100644
--- a/src/itemshortcut.cpp
+++ b/src/itemshortcut.cpp
@@ -81,7 +81,10 @@ void ItemShortcut::save()
for (int i = 0; i < SHORTCUT_ITEMS; i++)
{
const int itemId = mItems[i] ? mItems[i] : -1;
- serverConfig.setValue(name + toString(i), itemId);
+ if (itemId != -1)
+ serverConfig.setValue(name + toString(i), itemId);
+ else
+ serverConfig.deleteKey(name + toString(i));
}
}
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
index 2f4e7bd26..f845246fd 100644
--- a/src/spellmanager.cpp
+++ b/src/spellmanager.cpp
@@ -92,7 +92,7 @@ void SpellManager::fillSpells()
addSpell(new TextCommand(11, "hi", "hi", NOTARGET, ""));
addSpell(new TextCommand(12, "hea", "heal", NOTARGET, ""));
addSpell(new TextCommand(13, "@sp", "@spawn maggot 10", NOTARGET, ""));
- for (int f = 12; f < SPELL_SHORTCUT_ITEMS; f++)
+ for (int f = 12; f < SPELL_SHORTCUT_ITEMS * SPELL_SHORTCUT_TABS; f++)
addSpell(new TextCommand(f));
}
@@ -254,7 +254,7 @@ void SpellManager::load(bool oldConfig)
unsigned int mana;
unsigned int commandType;
- for (int i = 0; i < SPELL_SHORTCUT_ITEMS; i++)
+ for (int i = 0; i < SPELL_SHORTCUT_ITEMS * SPELL_SHORTCUT_TABS; i++)
{
std::string flags =
cfg->getValue("commandShortcutFlags" + toString(i), "");
@@ -288,21 +288,49 @@ void SpellManager::load(bool oldConfig)
void SpellManager::save()
{
- for (int i = 0; i < SPELL_SHORTCUT_ITEMS; i++)
+ for (int i = 0; i < SPELL_SHORTCUT_ITEMS * SPELL_SHORTCUT_TABS; i++)
{
TextCommand *spell = mSpellsVector[i];
if (spell)
{
- serverConfig.setValue("commandShortcutCmd" + toString(i),
- spell->getCommand());
- serverConfig.setValue("commandShortcutSymbol" + toString(i),
- spell->getSymbol());
- serverConfig.setValue("commandShortcutIcon" + toString(i),
- spell->getIcon());
- serverConfig.setValue("commandShortcutFlags" + toString(i),
- strprintf("%u %u %u %u %u %u", spell->getCommandType(),
- spell->getTargetType(), spell->getBaseLvl(),
- spell->getSchool(), spell->getSchoolLvl(), spell->getMana()));
+ if (spell->getCommand() != "")
+ {
+ serverConfig.setValue("commandShortcutCmd" + toString(i),
+ spell->getCommand());
+ }
+ else
+ {
+ serverConfig.deleteKey("commandShortcutCmd" + toString(i));
+ }
+ if (spell->getSymbol() != "")
+ {
+ serverConfig.setValue("commandShortcutSymbol" + toString(i),
+ spell->getSymbol());
+ }
+ else
+ {
+ serverConfig.deleteKey("commandShortcutSymbol" + toString(i));
+ }
+ if (spell->getIcon() != "")
+ {
+ serverConfig.setValue("commandShortcutIcon" + toString(i),
+ spell->getIcon());
+ }
+ else
+ {
+ serverConfig.deleteKey("commandShortcutIcon" + toString(i));
+ }
+ if (spell->getCommand() != "" && spell->getSymbol() != "")
+ {
+ serverConfig.setValue("commandShortcutFlags" + toString(i),
+ strprintf("%u %u %u %u %u %u", spell->getCommandType(),
+ spell->getTargetType(), spell->getBaseLvl(),
+ spell->getSchool(), spell->getSchoolLvl(), spell->getMana()));
+ }
+ else
+ {
+ serverConfig.deleteKey("commandShortcutFlags" + toString(i));
+ }
}
}
}
diff --git a/src/spellmanager.h b/src/spellmanager.h
index b156fb74b..931302e37 100644
--- a/src/spellmanager.h
+++ b/src/spellmanager.h
@@ -31,6 +31,7 @@
#define SPELL_MIN_ID 100000
#define SPELL_SHORTCUT_ITEMS 49
+#define SPELL_SHORTCUT_TABS 5
class SpellManager
{
diff --git a/src/spellshortcut.cpp b/src/spellshortcut.cpp
index 5f3da7c4d..89a82401e 100644
--- a/src/spellshortcut.cpp
+++ b/src/spellshortcut.cpp
@@ -48,7 +48,7 @@ SpellShortcut::~SpellShortcut()
void SpellShortcut::load()
{
- for (int f = 0; f < SPELL_SHORTCUT_ITEMS; f ++)
+ for (int f = 0; f < SPELL_SHORTCUT_ITEMS * SPELL_SHORTCUT_TABS; f ++)
mItems[f] = -1;
if (!spellManager)
@@ -58,7 +58,8 @@ void SpellShortcut::load()
int k = 0;
for (std::vector<TextCommand*>::const_iterator i = spells.begin(),
- i_end = spells.end(); i != i_end && k < SPELL_SHORTCUT_ITEMS; ++i)
+ i_end = spells.end(); i != i_end
+ && k < SPELL_SHORTCUT_ITEMS * SPELL_SHORTCUT_TABS; ++i)
{
mItems[k++] = (*i)->getId();
}
diff --git a/src/spellshortcut.h b/src/spellshortcut.h
index 5210fc4dc..99f899eaa 100644
--- a/src/spellshortcut.h
+++ b/src/spellshortcut.h
@@ -81,7 +81,7 @@ class SpellShortcut
{ return mItems[index]; }
private:
- int mItems[SPELL_SHORTCUT_ITEMS]; /**< The items stored. */
+ int mItems[SPELL_SHORTCUT_ITEMS * SPELL_SHORTCUT_TABS];
int mItemSelected; /**< The item held by cursor. */
};