2020-04-20 16:52:02 +00:00
|
|
|
/*
|
|
|
|
Created on: Apr 20, 2020
|
|
|
|
|
|
|
|
Copyright 2020 flyinghead
|
|
|
|
|
|
|
|
This file is part of flycast.
|
|
|
|
|
|
|
|
flycast is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
flycast is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with flycast. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <atomic>
|
2021-01-19 20:31:48 +00:00
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
2020-04-20 16:52:02 +00:00
|
|
|
|
2021-03-01 09:13:40 +00:00
|
|
|
void LoadGameSpecificSettings();
|
2020-04-20 16:52:02 +00:00
|
|
|
void SaveSettings();
|
|
|
|
|
|
|
|
extern std::atomic<bool> loading_canceled;
|
|
|
|
|
|
|
|
int reicast_init(int argc, char* argv[]);
|
|
|
|
void dc_reset(bool hard);
|
|
|
|
void dc_init();
|
|
|
|
void* dc_run(void*);
|
|
|
|
void dc_term();
|
|
|
|
void dc_stop();
|
2021-03-01 09:13:40 +00:00
|
|
|
void dc_term_game();
|
2020-04-20 16:52:02 +00:00
|
|
|
void dc_request_reset();
|
|
|
|
void dc_exit();
|
|
|
|
void dc_resume();
|
2021-03-23 13:49:19 +00:00
|
|
|
void dc_step();
|
2020-04-20 16:52:02 +00:00
|
|
|
void dc_savestate();
|
|
|
|
void dc_loadstate();
|
|
|
|
void dc_load_game(const char *path);
|
|
|
|
bool dc_is_load_done();
|
|
|
|
void dc_cancel_load();
|
|
|
|
void dc_get_load_status();
|
2020-05-23 11:03:59 +00:00
|
|
|
bool dc_is_running();
|
2021-04-22 08:59:40 +00:00
|
|
|
void dc_resize_renderer();
|
2021-01-19 20:31:48 +00:00
|
|
|
|
|
|
|
enum class Event {
|
|
|
|
Start,
|
|
|
|
Pause,
|
|
|
|
Resume,
|
|
|
|
Terminate,
|
|
|
|
LoadState,
|
|
|
|
};
|
|
|
|
|
|
|
|
class EventManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using Callback = void (*)(Event);
|
|
|
|
|
|
|
|
static void listen(Event event, Callback callback) {
|
|
|
|
Instance.registerEvent(event, callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void unlisten(Event event, Callback callback) {
|
|
|
|
Instance.unregisterEvent(event, callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void event(Event event) {
|
|
|
|
Instance.broadcastEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2021-03-14 17:52:04 +00:00
|
|
|
EventManager() = default;
|
2021-01-19 20:31:48 +00:00
|
|
|
|
|
|
|
void registerEvent(Event event, Callback callback);
|
|
|
|
void unregisterEvent(Event event, Callback callback);
|
|
|
|
void broadcastEvent(Event event);
|
|
|
|
|
|
|
|
static EventManager Instance;
|
|
|
|
std::map<Event, std::vector<Callback>> callbacks;
|
|
|
|
};
|