summary refs log tree commit diff stats
path: root/gui/radio-receiver.c
diff options
context:
space:
mode:
Diffstat (limited to 'gui/radio-receiver.c')
-rw-r--r--gui/radio-receiver.c83
1 files changed, 11 insertions, 72 deletions
diff --git a/gui/radio-receiver.c b/gui/radio-receiver.c
index defd419..de879a2 100644
--- a/gui/radio-receiver.c
+++ b/gui/radio-receiver.c
@@ -51,20 +51,12 @@ 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);
-[[clang::import_module("audio-device-widget")]] [[clang::import_name("set-dimensions")]]
-extern void audio_device_set_dimensions(int x, int y, int width, int height);
+[[clang::import_module("buttons")]] [[clang::import_name("set-dimensions")]]
+extern int buttons_set_dimensions(int button, int x, int y, int width, int height);
+[[clang::import_module("buttons")]] [[clang::import_name("set-base-layout")]]
+extern void buttons_set_base_layout(int layout);
 
-#define BACKGROUND_WIDTH 200
+#define BACKGROUND_WIDTH 320
 #define BACKGROUND_HEIGHT 100
 
 void init() {
@@ -72,70 +64,17 @@ void init() {
 	logger_log_message("placeholder radio skin.");
 	set_background_size(BACKGROUND_WIDTH, BACKGROUND_HEIGHT);
 
+	buttons_set_base_layout(1);
+
 	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);
-	audio_device_set_dimensions(base_x, base_y + 60, 200, 20);
+	buttons_set_dimensions(0, base_x, base_y + 0, 320, 20);
+	buttons_set_dimensions(1, base_x, base_y + 20, 320, 20);
+	buttons_set_dimensions(2, base_x, base_y + 40, 320, 20);
+	buttons_set_dimensions(3, base_x, base_y + 60, 320, 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:
-			{
-				t1 = text_translatable("pirate-radio.mode.fast");
-				break;
-			}
-		case SIMULATOR_DEAF:
-			{
-				t1 = text_translatable("pirate-radio.mode.deaf");
-				break;
-			}
-		default:
-			{
-				t1 = text_translatable("pirate-radio.mode.full");
-			}
-	}
-	int t2 = text_arguments("pirate-radio.mode.selected", 1, &t1);
-	render_text_object(t2, base_x, base_y + 40, -1, true);
-	text_free(t1);
-	text_free(t2);
-
-	int volume = simulator_get_volume();
-	if (volume == 0) {
-		t1 = text_translatable("pirate-radio.volume.off");
-	} else {
-		char volume_text[30];
-		sprintf(volume_text, "%d", volume);
-		t1 = text_literal(volume_text);
-	}
-	t2 = text_arguments("pirate-radio.volume.selected", 1, &t1);
-	render_text_object(t2, base_x, base_y + 20, -1, true);
-	text_free(t1);
-	text_free(t2);
-
-	int frequency = simulator_get_frequency();
-	int freq_mhz = frequency/10;
-	int freq_step = frequency%10;
-	char freq_text[30];
-	sprintf(freq_text, "%d", freq_mhz);
-	t1 = text_literal(freq_text);
-	sprintf(freq_text, "%d", freq_step);
-	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, base_x, base_y + 0, -1, true);
-	text_free(t1);
-	text_free(t2);
-	text_free(t3);
 }