Skip to content

Commit

Permalink
Nouvelles planetes, et icones par defaut (+ modification dans tweaks)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsht committed Nov 9, 2024
1 parent 4412397 commit 351d091
Show file tree
Hide file tree
Showing 49 changed files with 137 additions and 49 deletions.
Binary file added resources/planets/clouds-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/planets/clouds-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/planets/gas-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/planets/gas-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/planets/icons/2k_mars_default_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/planets/icons/clouds-1_default_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/planets/icons/clouds-2_default_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/planets/icons/clouds-3_default_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/planets/icons/earth2_default_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/planets/icons/earth3_default_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/planets/icons/foret_default_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/planets/icons/gas-1_default_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/planets/icons/gas-2_default_icon.png
Binary file added resources/planets/icons/gas-3_default_icon.png
Binary file added resources/planets/icons/lava-1_default_icon.png
Binary file added resources/planets/icons/moon-1_default_icon.png
Binary file added resources/planets/icons/planet-1_default_icon.png
Binary file added resources/planets/icons/star-1_default_icon.png
Binary file added resources/planets/planet-3.png
Binary file added resources/planets/planet-4.png
Binary file added resources/planets/planet-5.png
97 changes: 77 additions & 20 deletions src/screens/gm/tweak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2177,30 +2177,70 @@ GuiShipTweakPlanet::GuiShipTweakPlanet(GuiContainer* owner)
: GuiTweakPage(owner)
{
auto left_col = new GuiElement(this, "LEFT_LAYOUT");
left_col->setPosition(50, 25, sp::Alignment::TopLeft)->setSize(200, GuiElement::GuiSizeMax)->setAttribute("layout", "vertical");
left_col->setPosition(50, 25, sp::Alignment::TopLeft)->setSize(600, GuiElement::GuiSizeMax)->setAttribute("layout", "vertical");

auto center_col = new GuiElement(this, "CENTER_LAYOUT");
center_col->setPosition(0, 25, sp::Alignment::TopCenter)->setSize(200, GuiElement::GuiSizeMax)->setAttribute("layout", "vertical");
(new GuiLabel(left_col, "", "Surface Texture (modifies icon)", 30))->setSize(GuiElement::GuiSizeMax, 50);
surface_texture_selector = new GuiSelector(left_col, "", [this](int index, string value)
{
if(target)
{
target->setPlanetSurfaceTexture(value);
string icon = target->getPlanetIcon();
int id_icon = icon_selector->indexByValue(icon);
icon_selector->setSelectionIndex(id_icon);
}
});
surface_texture_selector->setPosition(0, 0, sp::Alignment::TopRight)->setSize(GuiElement::GuiSizeMax, 50);

auto right_col = new GuiElement(this, "RIGHT_LAYOUT");
right_col->setPosition(-25, 25, sp::Alignment::TopRight)->setSize(200, GuiElement::GuiSizeMax)->setAttribute("layout", "vertical");
(new GuiLabel(left_col, "", "Atmosphere Texture (modifies icon)", 30))->setSize(GuiElement::GuiSizeMax, 50);
atmosphere_texture_selector = new GuiSelector(left_col, "", [this](int index, string value)
{
if(target)
{
target->setPlanetAtmosphereTexture(value);
string icon = target->getPlanetIcon();
int id_icon = icon_selector->indexByValue(icon);
icon_selector->setSelectionIndex(id_icon);
}
});
atmosphere_texture_selector->setPosition(0, 0, sp::Alignment::TopRight)->setSize(GuiElement::GuiSizeMax, 50);

(new GuiLabel(left_col, "", "Texture", 30))->setSize(GuiElement::GuiSizeMax, 50);
texture_selector = new GuiSelector(left_col, "", [this](int index, string value)
(new GuiLabel(left_col, "", "Cloud Texture", 30))->setSize(GuiElement::GuiSizeMax, 50);
cloud_texture_selector = new GuiSelector(left_col, "", [this](int index, string value)
{
if(target)
target->setPlanetSurfaceTexture(value);
target->setPlanetCloudTexture(value);
});
cloud_texture_selector->setPosition(0, 0, sp::Alignment::TopRight)->setSize(GuiElement::GuiSizeMax, 50);

(new GuiLabel(left_col, "", "Icon on radar", 30))->setSize(GuiElement::GuiSizeMax, 50);
icon_selector = new GuiSelector(left_col, "", [this](int index, string value)
{
if(target)
target->setPlanetIcon(value);
});
texture_selector->setPosition(0, 0, sp::Alignment::TopRight)->setSize(GuiElement::GuiSizeMax, 50);
icon_selector->setPosition(0, 0, sp::Alignment::TopRight)->setSize(GuiElement::GuiSizeMax, 50);

std::vector<string> texture_filenames = findResources("planets/*.jpg");
std::vector<string> texture_filenames2 = findResources("planets/*.png");
texture_filenames.insert(texture_filenames.end(), texture_filenames2.begin(), texture_filenames2.end());
std::sort(texture_filenames.begin(), texture_filenames.end());
for(string filename : texture_filenames)
{
surface_texture_selector->addEntry(filename.substr(filename.rfind("/") + 1, filename.rfind(".")), filename);
atmosphere_texture_selector->addEntry(filename.substr(filename.rfind("/") + 1, filename.rfind(".")), filename);
cloud_texture_selector->addEntry(filename.substr(filename.rfind("/") + 1, filename.rfind(".")), filename);
}

std::vector<string> icon_filenames = findResources("planets/icons/*.jpg");
std::vector<string> icon_filenames2 = findResources("planets/icons/*.png");
icon_filenames.insert(icon_filenames.end(), icon_filenames2.begin(), icon_filenames2.end());
std::sort(icon_filenames.begin(), icon_filenames.end());
for(string filename : icon_filenames)
{
icon_selector->addEntry(filename.substr(filename.rfind("/") + 1, filename.rfind(".")), filename);
}

std::vector<string> texture_filenames_jpg = findResources("planets/*.jpg");
std::sort(texture_filenames_jpg.begin(), texture_filenames_jpg.end());
std::vector<string> texture_filenames_png = findResources("planets/*.png");
std::sort(texture_filenames_png.begin(), texture_filenames_png.end());
for(string filename : texture_filenames_jpg)
texture_selector->addEntry(filename.substr(filename.rfind("/") + 1, filename.rfind(".")), filename);
for(string filename : texture_filenames_png)
texture_selector->addEntry(filename.substr(filename.rfind("/") + 1, filename.rfind(".")), filename);
}

void GuiShipTweakPlanet::onDraw(sp::RenderTarget& renderer)
Expand All @@ -2212,9 +2252,26 @@ void GuiShipTweakPlanet::open(P<SpaceObject> target)
{
P<Planet> planet = target;
this->target = planet;
string texture = planet->getPlanetSurfaceTexture();
int id_texture = texture_selector->indexByValue(texture);
texture_selector->setSelectionIndex(id_texture);
{
string texture = planet->getPlanetSurfaceTexture();
int id_texture = surface_texture_selector->indexByValue(texture);
surface_texture_selector->setSelectionIndex(id_texture);
}
{
string texture = planet->getPlanetAtmosphereTexture();
int id_texture = atmosphere_texture_selector->indexByValue(texture);
atmosphere_texture_selector->setSelectionIndex(id_texture);
}
{
string texture = planet->getPlanetCloudTexture();
int id_texture = cloud_texture_selector->indexByValue(texture);
cloud_texture_selector->setSelectionIndex(id_texture);
}
{
string icon = planet->getPlanetIcon();
int id_icon = icon_selector->indexByValue(icon);
icon_selector->setSelectionIndex(id_icon);
}
}

GuiShipTweakInfos::GuiShipTweakInfos(GuiContainer* owner)
Expand Down
5 changes: 4 additions & 1 deletion src/screens/gm/tweak.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,10 @@ class GuiShipTweakPlanet : public GuiTweakPage
{
private:
P<Planet> target;
GuiSelector* texture_selector;
GuiSelector* surface_texture_selector;
GuiSelector* atmosphere_texture_selector;
GuiSelector* cloud_texture_selector;
GuiSelector* icon_selector;

public:
GuiShipTweakPlanet(GuiContainer* owner);
Expand Down
81 changes: 53 additions & 28 deletions src/spaceObjects/planet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,20 @@ REGISTER_SCRIPT_SUBCLASS(Planet, SpaceObject)
REGISTER_SCRIPT_CLASS_FUNCTION(Planet, setPlanetAtmosphereColor);
/// Sets this Planet's atmospheric effect texture.
/// Valid values are filenames of PNG files relative to the resources/ directory.
/// Also sets icon : value of string = "default_icon.png"
/// Optional; if defined, atmosphere textures should be transparent or translucent.
/// For stars, you can set an atmosphere texture such as planets/star-1.png with no surface texture.
/// Example: planet:setPlanetSurfaceTexture("planets/atmosphere.png")
REGISTER_SCRIPT_CLASS_FUNCTION(Planet, setPlanetAtmosphereTexture);
/// Sets this Planet's surface texture.
/// Valid values are filenames of PNG files relative to the resources/ directory.
/// Also sets icon : value of string = "default_icon.png"
/// Optional; if defined, surface textures should be opaque and use a 2:1-ratio equirectangular projection.
/// Example: planet:setPlanetSurfaceTexture("planets/planet-1.png")
REGISTER_SCRIPT_CLASS_FUNCTION(Planet, setPlanetSurfaceTexture);
/// Set this planet's icon on radar
/// This feature is not that well done, it's here to override default icon.
/// Example : planet:setPlanetIcon("planets/icons/17.png")
REGISTER_SCRIPT_CLASS_FUNCTION(Planet, setPlanetIcon);
REGISTER_SCRIPT_CLASS_FUNCTION(Planet, getPlanetSurfaceTexture);
/// Sets this Planet's cloud layer effect texture, which rotates independently of the planet.
Expand Down Expand Up @@ -182,14 +187,17 @@ Planet::Planet()
planet_size = 5000;
cloud_size = 5200;
planet_texture = "planets/2k_mercury.jpg";
planet_icon = "planets/icons/Storm-Planet.png";
planet_icon = "planets/icons/" + planet_texture.substr(planet_texture.find("/") + 1, planet_texture.rfind(".")) + "_default_icon.png";

cloud_texture = "";
atmosphere_texture = "";
atmosphere_size = 0;
atmosphere_size = 0;
distance_from_movement_plane = 0;
axial_rotation_time = random(100.0,400.0);
rotation_axis = random(0.0,360.0);
//axial_rotation_time = random(100.0,400.0);
//rotation_axis = random(0.0,360.0);
axial_rotation_time = 0;
rotation_axis = 0;
orbit_target_id = -1;
orbit_time = 0.0f;
orbit_distance = 0.0f;
Expand All @@ -201,31 +209,31 @@ Planet::Planet()

setRadarSignatureInfo(0.5f, 0.f, 0.3f);

addInfos(0,tr("Rotation"),string(irandom(5,45))+ " H.LO");
addInfos(1,tr("Revolution"),string(irandom(50,5000))+ " J.LO");
addInfos(2,tr("Rotation axis"),string(irandom(1,360))+"deg" + string(irandom(1,60))+"'" + string(irandom(1,60))+"''");
addInfos(3,tr("Size"),string(irandom(50,500) * 100) + " km");
if (random(0.f,1.f) < 0.1f)
{
addInfos(4,tr("Type"),tr("Gazeous"));
}
else
{
addInfos(4,tr("Type"),tr("Terestrial"));
}
addInfos(5,tr("Age"),string(irandom(5,100)*100)+ " M3 A.LO");

if (infos_value[4] == tr("Terestrial") && random(0.f,1.f) < 0.3f)
{
addInfos(6,tr("Atmosphere"),tr("Yes"));
}
else
{
addInfos(6,tr("Atmosphere"),tr("No"));
}
addInfos(7,tr("Pressure"),string(random(0.1,4),1)+" Pa");
addInfos(8,tr("Gravity"),string(random(2.0,20.0),3)+" m/s2");
addInfos(9,tr("Main resource"),"");
// addInfos(0,tr("Rotation"),string(irandom(5,45))+ " H.LO");
// addInfos(1,tr("Revolution"),string(irandom(50,5000))+ " J.LO");
// addInfos(2,tr("Rotation axis"),string(irandom(1,360))+"deg" + string(irandom(1,60))+"'" + string(irandom(1,60))+"''");
// addInfos(3,tr("Size"),string(irandom(50,500) * 100) + " km");
// if (random(0.f,1.f) < 0.1f)
// {
// addInfos(4,tr("Type"),tr("Gazeous"));
// }
// else
// {
// addInfos(4,tr("Type"),tr("Terestrial"));
// }
// addInfos(5,tr("Age"),string(irandom(5,100)*100)+ " M3 A.LO");

// if (infos_value[4] == tr("Terestrial") && random(0.f,1.f) < 0.3f)
// {
// addInfos(6,tr("Atmosphere"),tr("Yes"));
// }
// else
// {
// addInfos(6,tr("Atmosphere"),tr("No"));
// }
// addInfos(7,tr("Pressure"),string(random(0.1,4),1)+" Pa");
// addInfos(8,tr("Gravity"),string(random(2.0,20.0),3)+" m/s2");
// addInfos(9,tr("Main resource"),"");

registerMemberReplication(&planet_size);
registerMemberReplication(&cloud_size);
Expand All @@ -252,11 +260,18 @@ void Planet::setPlanetAtmosphereColor(float r, float g, float b)
void Planet::setPlanetAtmosphereTexture(std::string_view texture_name)
{
atmosphere_texture = texture_name;
planet_icon = "planets/icons/" + atmosphere_texture.substr(atmosphere_texture.find("/") + 1, atmosphere_texture.rfind(".")) + "_default_icon.png"; //By default, set with setPlanetIcon after otherwise
}

string Planet::getPlanetAtmosphereTexture()
{
return atmosphere_texture;
}

void Planet::setPlanetSurfaceTexture(std::string_view texture_name)
{
planet_texture = texture_name;
planet_icon = "planets/icons/" + planet_texture.substr(planet_texture.find("/") + 1, planet_texture.rfind(".")) + "_default_icon.png"; //By default, set with setPlanetIcon after otherwise
}

string Planet::getPlanetSurfaceTexture()
Expand All @@ -269,11 +284,21 @@ void Planet::setPlanetIcon(string texture_name)
planet_icon = texture_name;
}

string Planet::getPlanetIcon()
{
return planet_icon;
}

void Planet::setPlanetCloudTexture(std::string_view texture_name)
{
cloud_texture = texture_name;
}

string Planet::getPlanetCloudTexture()
{
return cloud_texture;
}

float Planet::getPlanetRadius()
{
return planet_size;
Expand Down
3 changes: 3 additions & 0 deletions src/spaceObjects/planet.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ class Planet : public SpaceObject, public Updatable

void setPlanetAtmosphereColor(float r, float g, float b);
void setPlanetAtmosphereTexture(std::string_view texture_name);
string getPlanetAtmosphereTexture();
void setPlanetSurfaceTexture(std::string_view texture_name);
string getPlanetSurfaceTexture();
void setPlanetIcon(string texture_name); //TODO : check string view
string getPlanetIcon();
void setPlanetCloudTexture(std::string_view texture_name);
string getPlanetCloudTexture();
void setPlanetRadius(float size);
void setPlanetCloudRadius(float size);
void setPlanetAtmosphereRadius(float size);
Expand Down

0 comments on commit 351d091

Please sign in to comment.