case GAME_STATE_LEVEL:
return level_sound(game->level, game->sound_samples);
case GAME_STATE_LEVEL_PICKER:
+ return 0;
case GAME_STATE_LEVEL_EDITOR:
+ level_editor_sound(game->level_editor, game->sound_samples);
+ return 0;
case GAME_STATE_QUIT:
return 0;
}
#include <stdbool.h>
#include "game/camera.h"
+#include "game/sound_samples.h"
#include "game/level_metadata.h"
#include "game/level/boxes.h"
#include "game/level/level_editor/color_picker.h"
case SDLK_z: {
if (event->key.keysym.mod & KMOD_CTRL) {
- log_info("Undo\n");
+ if (undo_history_empty(&level_editor->undo_history)) {
+ level_editor->bell = 1;
+ }
undo_history_pop(&level_editor->undo_history);
}
} break;
{
return fading_wiggly_text_update(&level_editor->notice, delta_time);
}
+
+void level_editor_sound(LevelEditor *level_editor, Sound_samples *sound_samples)
+{
+ // trace_assert(level_editor);
+ trace_assert(sound_samples);
+
+ if (level_editor && level_editor->bell) {
+ level_editor->bell = 0;
+ sound_samples_play_sound(sound_samples, 2);
+ }
+}
typedef struct PointLayer PointLayer;
typedef struct LabelLayer LabelLayer;
typedef struct Edit_field Edit_field;
+typedef struct Sound_samples Sound_samples;
typedef enum {
LEVEL_EDITOR_IDLE = 0,
UndoHistory undo_history;
bool drag;
+ int bell;
const char *file_name;
};
int level_editor_focus_camera(LevelEditor *level_editor,
Camera *camera);
int level_editor_update(LevelEditor *level_editor, float delta_time);
+void level_editor_sound(LevelEditor *level_editor, Sound_samples *sound_samples);
#endif // LEVEL_EDITOR_H_
size_t context_data_size);
void undo_history_pop(UndoHistory *undo_history);
+static inline
+int undo_history_empty(UndoHistory *undo_history)
+{
+ return undo_history->actions.size == 0;
+}
+
#endif // UNDO_HISTORY_H_
const char * sound_sample_files[] = {
"./sounds/nothing.wav",
- "./sounds/something.wav"
+ "./sounds/something.wav",
+ "./sounds/dev/ding.wav",
};
const size_t sound_sample_files_count = sizeof(sound_sample_files) / sizeof(char*);