summary refs log tree commit diff stats
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/radio-receiver.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/gui/radio-receiver.c b/gui/radio-receiver.c
index fef0858..136b45f 100644
--- a/gui/radio-receiver.c
+++ b/gui/radio-receiver.c
@@ -46,13 +46,46 @@ extern int simulator_get_volume();
 [[clang::import_module("simulator")]] [[clang::import_name("get-frequency")]]
 extern int simulator_get_frequency();
 
+[[clang::import_module("screen")]] [[clang::import_name("get-width")]]
+extern int screen_get_width();
+[[clang::import_module("screen")]] [[clang::import_name("get-height")]]
+extern int screen_get_height();
+
+[[clang::import_module("volume-plus-widget")]] [[clang::import_name("set-dimensions")]]
+extern void vp_set_dimensions(int x, int y, int width, int height);
+[[clang::import_module("volume-minus-widget")]] [[clang::import_name("set-dimensions")]]
+extern void vm_set_dimensions(int x, int y, int width, int height);
+[[clang::import_module("frequency-plus-widget")]] [[clang::import_name("set-dimensions")]]
+extern void fp_set_dimensions(int x, int y, int width, int height);
+[[clang::import_module("frequency-minus-widget")]] [[clang::import_name("set-dimensions")]]
+extern void fm_set_dimensions(int x, int y, int width, int height);
+[[clang::import_module("toggle-widget")]] [[clang::import_name("set-dimensions")]]
+extern void mode_set_dimensions(int x, int y, int width, int height);
+
+#define BACKGROUND_WIDTH 200
+#define BACKGROUND_HEIGHT 100
+
 void init() {
 	logger_log_begin(LOG_INFO);
-	logger_log_message("default radio skin.");
-	set_background_size(100, 100);
+	logger_log_message("placeholder radio skin.");
+	set_background_size(BACKGROUND_WIDTH, BACKGROUND_HEIGHT);
+
+	int width = screen_get_width();
+	int height = screen_get_height();
+	int base_x = (width - BACKGROUND_WIDTH) / 2;
+	int base_y = (height - BACKGROUND_HEIGHT) / 2;
+	fp_set_dimensions(base_x + 100 - 40, base_y, 20, 20);
+	fm_set_dimensions(base_x + 120 - 40, base_y, 20, 20);
+	vp_set_dimensions(base_x + 100 - 40, base_y + 20, 20, 20);
+	vm_set_dimensions(base_x + 120 - 40, base_y + 20, 20, 20);
+	mode_set_dimensions(base_x + 100 - 100, base_y + 40, 100, 20);
 }
 
 void render(int mouseX, int mouseY, float delta) {
+	int width = screen_get_width();
+	int height = screen_get_height();
+	int base_x = (width - BACKGROUND_WIDTH) / 2 + 100;
+	int base_y = (height - BACKGROUND_HEIGHT) / 2 + (20 - 9) / 2;
 	int t1;
 	switch (simulator_get_mode()) {
 		case SIMULATOR_FAST:
@@ -71,7 +104,7 @@ void render(int mouseX, int mouseY, float delta) {
 			}
 	}
 	int t2 = text_arguments("pirate-radio.mode.selected", 1, &t1);
-	render_text_object(t2, 200, 100, -1, true);
+	render_text_object(t2, base_x, base_y + 40, -1, true);
 	text_free(t1);
 	text_free(t2);
 
@@ -84,7 +117,7 @@ void render(int mouseX, int mouseY, float delta) {
 		t1 = text_literal(volume_text);
 	}
 	t2 = text_arguments("pirate-radio.volume.selected", 1, &t1);
-	render_text_object(t2, 200, 120, -1, true);
+	render_text_object(t2, base_x, base_y + 20, -1, true);
 	text_free(t1);
 	text_free(t2);
 
@@ -98,7 +131,7 @@ void render(int mouseX, int mouseY, float delta) {
 	t2 = text_literal(freq_text);
 	int freq_args[2] = {t1, t2};
 	int t3 = text_arguments("pirate-radio.frequency.selected", 2, freq_args);
-	render_text_object(t3, 200, 140, -1, true);
+	render_text_object(t3, base_x, base_y + 0, -1, true);
 	text_free(t1);
 	text_free(t2);
 	text_free(t3);