pause audio when settings are open
This commit is contained in:
parent
10d00e73f7
commit
3e5c51d838
@ -97,7 +97,10 @@ pub fn reset_rom(self: *Self) void {
|
|||||||
|
|
||||||
pub fn update(self: *Self, dt: f32) void {
|
pub fn update(self: *Self, dt: f32) void {
|
||||||
if (!self.is_gui_open) {
|
if (!self.is_gui_open) {
|
||||||
|
rl.ResumeSound(self.chip_sound);
|
||||||
self.raylib_chip.update(dt);
|
self.raylib_chip.update(dt);
|
||||||
|
} else {
|
||||||
|
rl.PauseSound(self.chip_sound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,8 +213,7 @@ pub fn drawGui(self: *Self, allocator: Allocator) !void {
|
|||||||
var window_layout = GUILayout.init();
|
var window_layout = GUILayout.init();
|
||||||
defer window_layout.deinit();
|
defer window_layout.deinit();
|
||||||
|
|
||||||
const screen_width: f32 = @floatFromInt(rl.GetScreenWidth());
|
// Draw overlay, to indicate that emulator is paused
|
||||||
const screen_height: f32 = @floatFromInt(rl.GetScreenHeight());
|
|
||||||
rl.DrawRectangle(0, 0, rl.GetScreenWidth(), rl.GetScreenHeight(), .{
|
rl.DrawRectangle(0, 0, rl.GetScreenWidth(), rl.GetScreenHeight(), .{
|
||||||
.r = 22,
|
.r = 22,
|
||||||
.g = 22,
|
.g = 22,
|
||||||
@ -221,6 +223,8 @@ pub fn drawGui(self: *Self, allocator: Allocator) !void {
|
|||||||
|
|
||||||
const window_width: f32 = 400;
|
const window_width: f32 = 400;
|
||||||
const window_height: f32 = 200;
|
const window_height: f32 = 200;
|
||||||
|
const screen_width: f32 = @floatFromInt(rl.GetScreenWidth());
|
||||||
|
const screen_height: f32 = @floatFromInt(rl.GetScreenHeight());
|
||||||
const window = rl.Rectangle{
|
const window = rl.Rectangle{
|
||||||
.x = @trunc((screen_width-window_width)/2),
|
.x = @trunc((screen_width-window_width)/2),
|
||||||
.y = @trunc((screen_height-window_height)/2),
|
.y = @trunc((screen_height-window_height)/2),
|
||||||
|
@ -64,6 +64,10 @@ pub fn update(self: *Self, dt: f32) void {
|
|||||||
self.tick_time -= 1/self.tick_speed;
|
self.tick_time -= 1/self.tick_speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.update_timers(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update_timers(self: *Self, dt: f32) void {
|
||||||
self.timer_time += dt;
|
self.timer_time += dt;
|
||||||
while (self.timer_time > 1/self.timer_speed) {
|
while (self.timer_time > 1/self.timer_speed) {
|
||||||
self.chip.update_timer();
|
self.chip.update_timer();
|
||||||
|
Loading…
Reference in New Issue
Block a user