Skip to content

Commit caa55ac

Browse files
committed
added opt-in clouds for fellow girlypops
1 parent 3ffbaef commit caa55ac

5 files changed

Lines changed: 41 additions & 6 deletions

File tree

resources/clouds.png

4.79 MB
Loading

settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"ui_scale": 1.0,
66
"earth_rotation_offset": 0.0,
77
"orbits_to_draw": 3.0,
8+
"show_clouds": false,
89

910
"bg_color": "#101010FF",
1011
"orbit_normal": "#D3D3D326",

src/config.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <string.h>
44
#include <stdlib.h>
55

6+
bool show_clouds = false; // Global state
7+
68
// turn hex strings into real colors
79
Color ParseHexColor(const char* hexStr, Color fallback) {
810
if (!hexStr || hexStr[0] != '#') return fallback;
@@ -47,6 +49,16 @@ void LoadAppConfig(const char* filename, AppConfig* config) {
4749
PARSE_FLOAT("earth_rotation_offset", earth_rotation_offset);
4850
PARSE_FLOAT("orbits_to_draw", orbits_to_draw);
4951

52+
// parse the global cloud toggle
53+
char* sc_ptr = strstr(text, "\"show_clouds\"");
54+
if (sc_ptr) {
55+
char* comma = strchr(sc_ptr, ',');
56+
char* false_ptr = strstr(sc_ptr, "false");
57+
if (false_ptr && (!comma || false_ptr < comma)) {
58+
show_clouds = false;
59+
}
60+
}
61+
5062
// grabbing all the colors
5163
PARSE_COLOR("bg_color", bg_color);
5264
PARSE_COLOR("orbit_normal", orbit_normal);

src/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#ifndef CONFIG_H
22
#define CONFIG_H
33

4+
#include <stdbool.h>
45
#include "types.h"
56

7+
extern bool show_clouds;
8+
69
void LoadAppConfig(const char* filename, AppConfig* config);
710

811
#endif // CONFIG_H

src/main.c

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ static AppConfig cfg = {
2020
};
2121

2222
static Font customFont;
23-
static Texture2D satIcon, markerIcon, earthTexture, moonTexture;
24-
static Texture2D periMark, apoMark; // New textures
25-
static Model earthModel, moonModel;
23+
static Texture2D satIcon, markerIcon, earthTexture, moonTexture, cloudTexture;
24+
static Texture2D periMark, apoMark;
25+
static Model earthModel, moonModel, cloudModel;
2626

2727
// safely modifies the alpha channel without relying on raylib's Fade()
2828
static Color ApplyAlpha(Color c, float alpha) {
@@ -187,6 +187,12 @@ int main(void) {
187187
earthTexture = LoadTexture("resources/earth.png");
188188
earthModel.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = earthTexture;
189189

190+
float draw_cloud_radius = (EARTH_RADIUS_KM + 25.0f) / DRAW_SCALE;
191+
Mesh cloudMesh = GenEarthMesh(draw_cloud_radius, 64, 64);
192+
cloudModel = LoadModelFromMesh(cloudMesh);
193+
cloudTexture = LoadTexture("resources/clouds.png");
194+
cloudModel.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = cloudTexture;
195+
190196
float draw_moon_radius = MOON_RADIUS_KM / DRAW_SCALE;
191197
Mesh moonMesh = GenEarthMesh(draw_moon_radius, 32, 32);
192198
moonModel = LoadModelFromMesh(moonMesh);
@@ -340,11 +346,11 @@ int main(void) {
340346
}
341347
}
342348

343-
// defining a hitbox area to cover the UI checkbox + its text
344-
Rectangle cbHitbox = { 10 * cfg.ui_scale, (10 + 104) * cfg.ui_scale, 200 * cfg.ui_scale, 24 * cfg.ui_scale };
349+
// defining a hitbox area to cover the UI checkboxes + texts
350+
Rectangle cbHitbox = { 10 * cfg.ui_scale, (10 + 104) * cfg.ui_scale, 200 * cfg.ui_scale, 50 * cfg.ui_scale };
345351

346352
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
347-
// only update selection if the mouse is not clicking on the UI Checkbox
353+
// only update selection if the mouse is not clicking on the UI Checkboxes
348354
if (!CheckCollisionPointRec(GetMousePosition(), cbHitbox)) {
349355
selected_sat = hovered_sat;
350356

@@ -585,6 +591,14 @@ int main(void) {
585591
earthModel.transform = MatrixRotateY((gmst_deg + cfg.earth_rotation_offset) * DEG2RAD);
586592
DrawModel(earthModel, Vector3Zero(), 1.0f, WHITE);
587593

594+
if (show_clouds) {
595+
double continuous_cloud_angle = fmod(gmst_deg + cfg.earth_rotation_offset + (current_epoch * 360.0 * 0.04), 360.0);
596+
cloudModel.transform = MatrixRotateY((float)(continuous_cloud_angle * DEG2RAD));
597+
// BeginBlendMode(BLEND_ADDITIVE); // garbage tint, dont use it
598+
DrawModel(cloudModel, Vector3Zero(), 1.0f, WHITE);
599+
EndBlendMode();
600+
}
601+
588602
// render Moon (not sure what for tbh but I'm sure someone will appreciate it :3)
589603
DrawModel(moonModel, draw_moon_pos, 1.0f, WHITE);
590604

@@ -708,6 +722,9 @@ int main(void) {
708722
Rectangle cbRec = { 10 * cfg.ui_scale, (10 + 104) * cfg.ui_scale, 20 * cfg.ui_scale, 20 * cfg.ui_scale };
709723
GuiCheckBox(cbRec, "Hide Unselected", &hide_unselected);
710724

725+
Rectangle cbRec2 = { 10 * cfg.ui_scale, (10 + 128) * cfg.ui_scale, 20 * cfg.ui_scale, 20 * cfg.ui_scale };
726+
GuiCheckBox(cbRec2, "Show Clouds", &show_clouds);
727+
711728
if (active_sat) {
712729
Vector2 screenPos;
713730
if (is_2d_view) {
@@ -812,6 +829,8 @@ int main(void) {
812829
UnloadTexture(apoMark);
813830
UnloadTexture(earthTexture);
814831
UnloadModel(earthModel);
832+
UnloadTexture(cloudTexture);
833+
UnloadModel(cloudModel);
815834
UnloadTexture(moonTexture);
816835
UnloadModel(moonModel);
817836
UnloadFont(customFont);

0 commit comments

Comments
 (0)