summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-05-09 23:18:39 +0300
committerAndrei Karas <akaras@inbox.ru>2011-05-09 23:24:06 +0300
commit4561ae35f7c2c641e5dd0070b6cd3779dad0275b (patch)
treedc8cbe215e3ca68f15bab5b510931552d3a1f94b /src
parent94a9a81d9c6aa9fa287616c8b4bfc5ea86214dcd (diff)
downloadmanaverse-4561ae35f7c2c641e5dd0070b6cd3779dad0275b.tar.gz
manaverse-4561ae35f7c2c641e5dd0070b6cd3779dad0275b.tar.bz2
manaverse-4561ae35f7c2c641e5dd0070b6cd3779dad0275b.tar.xz
manaverse-4561ae35f7c2c641e5dd0070b6cd3779dad0275b.zip
Add drawing colors for new collision types.
Diffstat (limited to 'src')
-rw-r--r--src/gui/palette.cpp72
-rw-r--r--src/gui/setup_colors.cpp4
-rw-r--r--src/gui/userpalette.cpp8
-rw-r--r--src/gui/userpalette.h2
-rw-r--r--src/map.cpp57
5 files changed, 63 insertions, 80 deletions
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index 4614d7023..5a61c332a 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -201,75 +201,3 @@ void Palette::advanceGradient()
mRainbowTime = tick_time;
}
}
-
-/*
-gcn::Color Palette::produceHPColor(int hp, int maxHp, int alpha)
-{
- float r1 = 255;
- float g1 = 255;
- float b1 = 255;
- float r2 = 255;
- float g2 = 255;
- float b2 = 255;
-
- float weight = 1.0f;
-
- int thresholdLevel = maxHp / 4;
- int thresholdProgress = hp % thresholdLevel;
-
- if (thresholdLevel)
- weight = 1 - ((float)thresholdProgress) / ((float)thresholdLevel);
- else
- weight = 0;
-
- if (hp < (thresholdLevel))
- {
- gcn::Color color1 = guiPalette->getColor(Palette::HPBAR_ONE_HALF);
- gcn::Color color2 = guiPalette->getColor(Palette::HPBAR_ONE_QUARTER);
- r1 = color1.r; r2 = color2.r;
- g1 = color1.g; g2 = color2.g;
- b1 = color1.b; b2 = color2.b;
- }
- else if (hp < (thresholdLevel*2))
- {
- gcn::Color color1 = guiPalette->getColor(Palette::HPBAR_THREE_QUARTERS);
- gcn::Color color2 = guiPalette->getColor(Palette::HPBAR_ONE_HALF);
- r1 = color1.r; r2 = color2.r;
- g1 = color1.g; g2 = color2.g;
- b1 = color1.b; b2 = color2.b;
- }
- else if (hp < thresholdLevel*3)
- {
- gcn::Color color1 = guiPalette->getColor(Palette::HPBAR_FULL);
- gcn::Color color2 = guiPalette->getColor(Palette::HPBAR_THREE_QUARTERS);
- r1 = color1.r; r2 = color2.r;
- g1 = color1.g; g2 = color2.g;
- b1 = color1.b; b2 = color2.b;
- }
- else
- {
- gcn::Color color1 = guiPalette->getColor(Palette::HPBAR_FULL);
- gcn::Color color2 = guiPalette->getColor(Palette::HPBAR_FULL);
- r1 = color1.r; r2 = color2.r;
- g1 = color1.g; g2 = color2.g;
- b1 = color1.b; b2 = color2.b;
- }
-
- // Safety checks
- if (weight > 1.0f) weight = 1.0f;
- if (weight < 0.0f) weight = 0.0f;
-
- // Do the color blend
- r1 = (int) weightedAverage(r1, r2,weight);
- g1 = (int) weightedAverage(g1, g2, weight);
- b1 = (int) weightedAverage(b1, b2, weight);
-
- // More safety checks
- if (r1 > 255) r1 = 255;
- if (g1 > 255) g1 = 255;
- if (b1 > 255) b1 = 255;
-
- return gcn::Color(r1, g1, b1, alpha);
-}
-*/
-
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index 4e45ef302..0b30aa08e 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -256,6 +256,8 @@ void Setup_Colors::valueChanged(const gcn::SelectionEvent &event _UNUSED_)
switch (type)
{
+ case UserPalette::AIR_COLLISION_HIGHLIGHT:
+ case UserPalette::WATER_COLLISION_HIGHLIGHT:
case UserPalette::COLLISION_HIGHLIGHT:
case UserPalette::PORTAL_HIGHLIGHT:
case UserPalette::HOME_PLACE:
@@ -297,6 +299,8 @@ void Setup_Colors::valueChanged(const gcn::SelectionEvent &event _UNUSED_)
case UserPalette::MONSTER_ATTACK_RANGE:
case UserPalette::HOME_PLACE:
case UserPalette::HOME_PLACE_BORDER:
+ case UserPalette::AIR_COLLISION_HIGHLIGHT:
+ case UserPalette::WATER_COLLISION_HIGHLIGHT:
case UserPalette::COLLISION_HIGHLIGHT:
case UserPalette::WALKABLE_HIGHLIGHT:
case UserPalette::ROAD_POINT:
diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp
index 33a42645f..bc5576469 100644
--- a/src/gui/userpalette.cpp
+++ b/src/gui/userpalette.cpp
@@ -65,6 +65,8 @@ const std::string ColorTypeNames[] =
"ColorMiss",
"ColorPortalHighlight",
"ColorCollisionHighlight",
+ "ColorCollisionAirHighlight",
+ "ColorCollisionWaterHighlight",
"ColorWalkableTileHighlight",
"ColorAttackRange",
"ColorAttackRangeBorder",
@@ -144,7 +146,11 @@ UserPalette::UserPalette():
addColor(MISS, 0xffff00, STATIC, _("Misses"));
addColor(PORTAL_HIGHLIGHT, 0xC80000, STATIC, _("Portal Highlight"));
addColor(COLLISION_HIGHLIGHT, 0x0000C8, STATIC,
- _("Collision Highlight"), 64);
+ _("Default collision Highlight"), 64);
+ addColor(AIR_COLLISION_HIGHLIGHT, 0xe0e0ff, STATIC,
+ _("Air collision Highlight"), 64);
+ addColor(WATER_COLLISION_HIGHLIGHT, 0x2050e0, STATIC,
+ _("Water collision Highlight"), 64);
addColor(WALKABLE_HIGHLIGHT, 0x00D000, STATIC,
_("Walkable Highlight"), 255);
addColor(ATTACK_RANGE, 0xffffff, STATIC,
diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h
index 7a0b83c0f..3bf9c782a 100644
--- a/src/gui/userpalette.h
+++ b/src/gui/userpalette.h
@@ -66,6 +66,8 @@ class UserPalette : public Palette, public gcn::ListModel
MISS,
PORTAL_HIGHLIGHT,
COLLISION_HIGHLIGHT,
+ AIR_COLLISION_HIGHLIGHT,
+ WATER_COLLISION_HIGHLIGHT,
WALKABLE_HIGHLIGHT,
ATTACK_RANGE,
ATTACK_RANGE_BORDER,
diff --git a/src/map.cpp b/src/map.cpp
index 83143a7c8..d35133bcc 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -684,17 +684,60 @@ void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY,
width += 32;
x ++;
}
+ if (width && userPalette)
+ {
+ graphics->setColor(userPalette->getColorWithAlpha(
+ UserPalette::COLLISION_HIGHLIGHT));
+
+ graphics->fillRectangle(gcn::Rectangle(
+ x0 * mTileWidth - scrollX,
+ y * mTileHeight - scrollY,
+ width, 32));
+ }
}
- if (width && userPalette)
+ if (!getWalk(x, y, BLOCKMASK_AIR))
{
- graphics->setColor(userPalette->getColorWithAlpha(
- UserPalette::COLLISION_HIGHLIGHT));
+ width = 32;
+ for (int x2 = x + 1; x < endX; x2 ++)
+ {
+ if (getWalk(x2, y, BLOCKMASK_AIR))
+ break;
+ width += 32;
+ x ++;
+ }
+ if (width && userPalette)
+ {
+ graphics->setColor(userPalette->getColorWithAlpha(
+ UserPalette::AIR_COLLISION_HIGHLIGHT));
- graphics->fillRectangle(gcn::Rectangle(
- x0 * mTileWidth - scrollX,
- y * mTileHeight - scrollY,
- width, 32));
+ graphics->fillRectangle(gcn::Rectangle(
+ x0 * mTileWidth - scrollX,
+ y * mTileHeight - scrollY,
+ width, 32));
+ }
+ }
+
+ if (!getWalk(x, y, BLOCKMASK_WATER))
+ {
+ width = 32;
+ for (int x2 = x + 1; x < endX; x2 ++)
+ {
+ if (getWalk(x2, y, BLOCKMASK_WATER))
+ break;
+ width += 32;
+ x ++;
+ }
+ if (width && userPalette)
+ {
+ graphics->setColor(userPalette->getColorWithAlpha(
+ UserPalette::WATER_COLLISION_HIGHLIGHT));
+
+ graphics->fillRectangle(gcn::Rectangle(
+ x0 * mTileWidth - scrollX,
+ y * mTileHeight - scrollY,
+ width, 32));
+ }
}
}
}