diff options
author | Stijn Buys <ingar@osirion.org> | 2012-10-13 10:51:48 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2012-10-13 10:51:48 +0000 |
commit | 0d58c4f8ab1d174c808c77bf94342c91f6e0c443 (patch) | |
tree | 9f32d388ca32dba337739494db2687aa5b2a8225 | |
parent | a41a544a498baf2235348b2edb76781f442651d6 (diff) |
Draw zone colors and background texture on the galactic map.
-rw-r--r-- | src/client/galaxymapwidget.cc | 13 | ||||
-rw-r--r-- | src/core/zone.cc | 38 | ||||
-rw-r--r-- | src/core/zone.h | 23 | ||||
-rw-r--r-- | src/filesystem/inistream.cc | 6 | ||||
-rw-r--r-- | src/game/base/faction.cc | 2 | ||||
-rw-r--r-- | src/game/base/game.cc | 16 |
6 files changed, 76 insertions, 22 deletions
diff --git a/src/client/galaxymapwidget.cc b/src/client/galaxymapwidget.cc index be9a6e0..0cc04af 100644 --- a/src/client/galaxymapwidget.cc +++ b/src/client/galaxymapwidget.cc @@ -66,15 +66,15 @@ void GalaxyMapWidget::draw() map_location[1] += (height() - map_size) * 0.5f; } - // draw background - math::Vector2f background_size(map_size, map_size); - ui::Paint::draw_material(map_location, background_size, "ui/background"); + // draw widget background + math::Vector2f background_size(map_size, map_size); + ui::Paint::draw_bitmap(map_location, background_size, math::Color(), "bitmaps/ui/map_background"); // number of squares in one grid segment const float grid_size = 16.0f; // draw the grid itself - gl::color(0, 0, 0.8f); + gl::color(0, 0, 0.25f); gl::begin(gl::Lines); for (float i = 0; i <= grid_size; i += 1.0f) { @@ -135,10 +135,11 @@ void GalaxyMapWidget::draw() draw_icon = false; } } + // TODO draw a ship icon for current location if (draw_icon) { - gl::begin(gl::Quads); - + color.assign(zone->color()); + gl::color(color); glTexCoord2f(0.0f, 0.0f); gl::vertex(icon_location.x() - r, icon_location.y() - r); diff --git a/src/core/zone.cc b/src/core/zone.cc index b038d82..dbd257e 100644 --- a/src/core/zone.cc +++ b/src/core/zone.cc @@ -122,11 +122,14 @@ void Zone ::clear() Zone::Zone(std::string const & label) : Label(label), - zone_ambient_color(0.1f, 0.1f, 0.1f) + zone_location(), + zone_color(1.0f), + zone_ambient_color(0.1f) { - zone_id = 0; + zone_id = 0; zone_defaultview = 0; - zone_info = 0 ; + zone_info = 0; + zone_flags = 0; btVector3 worldAabbMin(-10000, -10000, -10000); btVector3 worldAabbMax(10000, 10000, 10000); @@ -142,11 +145,14 @@ Zone::Zone(std::string const & label) : Zone::Zone(std::istream & is) : Label(), - zone_ambient_color(0.1f, 0.1f, 0.1f) + zone_location(), + zone_color(1.0f), + zone_ambient_color(0.1f) { zone_id = 0; zone_defaultview = 0; - zone_info = 0 ; + zone_info = 0; + zone_flags = 0; // client side does not setup a bullet physics environment zone_bullet_cache = 0; @@ -180,7 +186,16 @@ void Zone::set_info(const Info *info) zone_info = info; } - +void Zone::set_color(const math::Color & color) +{ + zone_color.assign(color); +} + +void Zone::set_color(float r, float g, float b) +{ + zone_color.assign(r, g, b); +} + void Zone::print() { con_print << " zone id ^B" << id() << " ^Nlabel ^B" << label() << " ^Nname ^B" << name() << std::endl; @@ -283,8 +298,11 @@ void Zone::serialize_server_update(std::ostream & os) const os << zone_ambient_color.b << " "; os << (zone_defaultview ? zone_defaultview->id() : 0) << " "; os << zone_location << " "; - os << zone_flags; - + os << zone_flags << " "; + os << zone_ambient_color.r << " "; + os << zone_ambient_color.g << " "; + os << zone_ambient_color.b; + } void Zone::receive_server_update(std::istream &is) @@ -326,6 +344,10 @@ void Zone::receive_server_update(std::istream &is) // flags is >> zone_flags; + + // zone color + is >> r >> g >> b; + zone_color.assign(r, g, b); } } diff --git a/src/core/zone.h b/src/core/zone.h index 22440c4..860c871 100644 --- a/src/core/zone.h +++ b/src/core/zone.h @@ -139,6 +139,14 @@ public: } /** + * @brief return the zone's color + * This is the color used to represent the zone on the galactic map + * */ + const math::Color & color() const { + return zone_color; + } + + /** * @brief returns the galactic location of this zone * */ const math::Vector3f & location() const { @@ -222,7 +230,14 @@ public: * @brief set the information record for this zone * */ void set_info(const Info *info); - + + /** + * @brief set the zone color + * */ + void set_color(const math::Color & color); + + void set_color(float r, float g, float b); + /* ---- serializers ---------------------------------------- */ /** @@ -273,10 +288,12 @@ public: private: unsigned int zone_id; unsigned int zone_flags; - + math::Vector3f zone_location; + math::Color zone_color; + std::string zone_sky; math::Color zone_ambient_color; - math::Vector3f zone_location; + Content zone_content; Entity *zone_defaultview; diff --git a/src/filesystem/inistream.cc b/src/filesystem/inistream.cc index d07745b..54400d0 100644 --- a/src/filesystem/inistream.cc +++ b/src/filesystem/inistream.cc @@ -209,6 +209,8 @@ bool IniStream::got_key_color(const char * keylabel, math::Color & color) if ((r > 1.0f) || (g > 1.0f) || (b > 1.0f)) { if (is >> a) { a /= 255.0f; + } else { + a = 1.0f; } r /= 255.0f; g /= 255.0f; @@ -218,9 +220,9 @@ bool IniStream::got_key_color(const char * keylabel, math::Color & color) a = 1.0f; } } - color = math::Color(r, g, b, a); + color.assign(r, g, b, a); } else { - color = math::Color(); + color.assign(1.0f, 1.0f); } return true; } else { diff --git a/src/game/base/faction.cc b/src/game/base/faction.cc index 3466265..323a199 100644 --- a/src/game/base/faction.cc +++ b/src/game/base/faction.cc @@ -82,7 +82,7 @@ bool Faction::init() } else if (inifile.got_key_color("color", colorvalue)) { faction->set_color(colorvalue); - + } else if (inifile.got_key_color("colorsecond", colorvalue)) { faction->set_color_second(colorvalue); diff --git a/src/game/base/game.cc b/src/game/base/game.cc index 8c82968..dd720f0 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -1085,8 +1085,6 @@ bool Game::load_world() if (inifile.got_key_label("zone", label)) { zone = new core::Zone(label); - // set default ambient light color - zone->set_ambient_color(0.1f, 0.1f, 0.1f); core::Zone::add(zone); } else { inifile.unknown_key(); @@ -1124,6 +1122,10 @@ bool Game::load_zone(core::Zone *zone) using math::Vector3f; using math::Color; + // set zone defaults + zone->set_color(0.5f); + zone->set_ambient_color(0.1f); + std::string inifilename("ini/zones/"); inifilename.append(zone->label()); @@ -1274,6 +1276,16 @@ bool Game::load_zone(core::Zone *zone) } else if (zoneini.got_key_string("sky", strval)) { zone->set_sky(strval); continue; + } else if (zoneini.got_key_color("color", color)) { + zone->set_color(color); + continue; + } else if (zoneini.got_key_label("faction", strval)) { + Faction *faction = Faction::find(strval); + if (!faction) { + zoneini.unknown_error("unknown faction '" + strval + "'"); + } else { + zone->set_color(faction->color()); + } } else if (zoneini.got_key_color("ambient", color)) { zone->set_ambient_color(color); continue; |