--- a/easy3d/easy3d_planet.cpp Tue Apr 29 09:54:20 2008 +0200
+++ b/easy3d/easy3d_planet.cpp Tue Apr 29 10:30:15 2008 +0200
@@ -34,6 +34,7 @@
#include "easy3d_writemap.h"
#include "load_universe.h"
+#include "utils.h"
#include <osg/BlendFunc>
#include <osg/Geode>
@@ -162,15 +163,15 @@ void ScenePlanet::load()
mItems.clear();
- int galaxy = mGalaxyId;
- int planet = mPlanetId;
int nbItems = 0;
- Galaxy* gxy = 0;
-
- if (planet != -1 && galaxy != -1) {
- fixGalaxyIdAndPlanetId (galaxy, planet);
- gxy = LoadUniverse::instance()->galaxyVector[galaxy];
- nbItems = (int)gxy->planetVector[planet]->satelliteVector.size();
+ Galaxy *gxy = 0;
+
+ if (mPlanetId != -1 && mGalaxyId != -1) {
+ fixGalaxyIdAndPlanetId (mGalaxyId, mPlanetId);
+ gxy = LoadUniverse::instance()->galaxyVector[mGalaxyId];
+ nbItems = (int)gxy->planetVector[mPlanetId]->satelliteVector.size();
+ } else {
+ trace("No mPlanetId or mGalaxyId defined !!!!\n");
}
std::string urlTexture;
@@ -179,16 +180,28 @@ void ScenePlanet::load()
VarsEditor::instance()->get("planet_icon_command", commandTexture);
mItems.resize(nbItems);
- for (int i = 0; i < (int)mItems.size(); i++) {
+
+ for (unsigned int i = 0; i < mItems.size(); i++) {
+
+ Satellite *satellite = gxy->planetVector[mPlanetId]->satelliteVector[i];
+
mItems[i].create();
mItems[i].loadSettings();
- mItems[i].getText()->setText(gxy->planetVector[planet]->satelliteVector[i]->name, osgText::String::ENCODING_UTF8);
- if (gxy->planetVector[planet]->satelliteVector[i]->icon_filename.empty() == false)
- mItems[i].setTextureIcon(gxy->planetVector[planet]->satelliteVector[i]->icon_filename);
- else if (gxy->planetVector[planet]->satelliteVector[i]->isCommand())
+ mItems[i].getText()->setText(satellite->name, osgText::String::ENCODING_UTF8);
+
+ if (satellite->icon_filename.empty() == false)
+ mItems[i].setTextureIcon(satellite->icon_filename);
+ else if (satellite->isCommand())
mItems[i].setTextureIcon(commandTexture);
- else if (gxy->planetVector[planet]->satelliteVector[i]->isUrl())
+ else if (satellite->isUrl())
mItems[i].setTextureIcon(urlTexture);
+
+ if (satellite->text_color)
+ mItems[i].setTextColor(*satellite->text_color);
+
+ if (satellite->text_color_when_selected)
+ mItems[i].setTextSelectedColor(*satellite->text_color_when_selected);
+
mTextsTransform->addChild(mItems[i].getTransform());
}
--- a/easy3d/easy3d_planet_animation.cpp Tue Apr 29 09:54:20 2008 +0200
+++ b/easy3d/easy3d_planet_animation.cpp Tue Apr 29 10:30:15 2008 +0200
@@ -78,6 +78,16 @@ void PlanetItemTextAnimated::setTextureI
mIcon->setTexture(texture);
}
+void PlanetItemTextAnimated::setTextColor(const osg::Vec4 &color)
+{
+ mTextColor = color;
+}
+
+void PlanetItemTextAnimated::setTextSelectedColor(const osg::Vec4 &color)
+{
+ mTextColorSelected = color;
+}
+
void PlanetItemTextAnimated::loadSettings()
{
mTextAnimationTransitionIn.load("planet_","text_transition_in");
--- a/easy3d/easy3d_planet_animation.h Tue Apr 29 09:54:20 2008 +0200
+++ b/easy3d/easy3d_planet_animation.h Tue Apr 29 10:30:15 2008 +0200
@@ -62,6 +62,8 @@ public:
PlanetItemTextAnimated() {}
void setTextureIcon(const std::string& texturename);
void setPosition(const osg::Vec3& src);
+ void setTextColor(const osg::Vec4& color);
+ void setTextSelectedColor(const osg::Vec4& color);
const osg::Vec3& getPosition() const;
void update(float dt);
void loadSettings();
--- a/easy3d/load_universe.cpp Tue Apr 29 09:54:20 2008 +0200
+++ b/easy3d/load_universe.cpp Tue Apr 29 10:30:15 2008 +0200
@@ -45,8 +45,13 @@ bool Satellite::isUrl() { return comman
bool Satellite::isUrl() { return command_type == AppLaunch::APPLAUNCH_URL; }
bool Satellite::isGoto() { return !go_to.empty(); }
-Satellite::Satellite() {}
+Satellite::Satellite() {
+ text_color = NULL;
+ text_color_when_selected = NULL;
+}
+
Planet::Planet() {}
+
Galaxy::Galaxy() {
hidden = false;
position = NULL;
@@ -56,7 +61,6 @@ Galaxy::Galaxy() {
Satellite* LoadUniverse::loadSatellite(xmlDocPtr doc, xmlNodePtr cur) {
- xmlChar *type;
xmlChar *value;
Satellite* satellite = new Satellite();
@@ -84,19 +88,19 @@ Satellite* LoadUniverse::loadSatellite(x
}
- type = xmlGetProp(cur,(const xmlChar *)"type");
- if (type != NULL) {
- if ((!xmlStrcmp(type, (const xmlChar *)"url")) && xmlHasProp(cur,(const xmlChar *)"a")) {
+ value = xmlGetProp(cur,(const xmlChar *)"type");
+ if (value != NULL) {
+ if ((!xmlStrcmp(value, (const xmlChar *)"url")) && xmlHasProp(cur,(const xmlChar *)"a")) {
satellite->command_type = AppLaunch::APPLAUNCH_URL;
satellite->command = std::string((char*)xmlGetProp(cur,(const xmlChar *)"a"));
- } else if ((!xmlStrcmp(type, (const xmlChar *)"command")) && (xmlHasProp(cur,(const xmlChar *)"command") != NULL)) {
+ } else if ((!xmlStrcmp(value, (const xmlChar *)"command")) && (xmlHasProp(cur,(const xmlChar *)"command") != NULL)) {
satellite->command_type = AppLaunch::APPLAUNCH_EXE;
satellite->command = std::string((char*)xmlGetProp(cur,(const xmlChar *)"command"));
- } else if ((!xmlStrcmp(type, (const xmlChar *)"go")) && (xmlHasProp(cur,(const xmlChar *)"to") != NULL)) {
+ } else if ((!xmlStrcmp(value, (const xmlChar *)"go")) && (xmlHasProp(cur,(const xmlChar *)"to") != NULL)) {
satellite->go_to = std::string((char*)xmlGetProp(cur,(const xmlChar *)"to"));
@@ -105,8 +109,35 @@ Satellite* LoadUniverse::loadSatellite(x
std::cerr << "Bad planet description for " << satellite->name << std::endl;
}
- xmlFree(type);
- }
+ xmlFree(value);
+ }
+
+ value = xmlGetProp(cur,(const xmlChar *)"color");
+ if (value) {
+ float r, g, b, a;
+
+ if (sscanf((const char *)value, "Vec4 %f %f %f %f", &r, &g, &b, &a) == 4) {
+ satellite->text_color = new osg::Vec4(r, g, b, a);
+ } else {
+ error("Bad value for color=\"%s\"\n", (char *)value);
+ }
+
+ xmlFree(value);
+ }
+
+ value = xmlGetProp(cur,(const xmlChar *)"color_when_selected");
+ if (value) {
+ float r, g, b, a;
+
+ if (sscanf((const char *)value, "Vec4 %f %f %f %f", &r, &g, &b, &a) == 4) {
+ satellite->text_color_when_selected = new osg::Vec4(r, g, b, a);
+ } else {
+ error("Bad value for color_when_selected=\"%s\"\n", (char *)value);
+ }
+
+ xmlFree(value);
+ }
+
return satellite;
}
--- a/easy3d/load_universe.h Tue Apr 29 09:54:20 2008 +0200
+++ b/easy3d/load_universe.h Tue Apr 29 10:30:15 2008 +0200
@@ -40,6 +40,9 @@ public:
std::string icon_filename; // texture used as "satellite icon"
AppLaunch::AppLaunchType command_type; // type of the satellite (url or application)
+ osg::Vec4 *text_color;
+ osg::Vec4 *text_color_when_selected;
+
bool isCommand();
bool isUrl();
bool isGoto();