[HTML5] Add override keyword, cleanup methods.
This commit is contained in:
parent
179e6fabb4
commit
27ab97501b
4 changed files with 82 additions and 110 deletions
|
@ -46,21 +46,21 @@ public:
|
||||||
|
|
||||||
static AudioDriverJavaScript *singleton;
|
static AudioDriverJavaScript *singleton;
|
||||||
|
|
||||||
virtual const char *get_name() const;
|
const char *get_name() const override;
|
||||||
|
|
||||||
virtual Error init();
|
Error init() override;
|
||||||
virtual void start();
|
void start() override;
|
||||||
void resume();
|
void resume();
|
||||||
virtual float get_latency();
|
float get_latency() override;
|
||||||
virtual int get_mix_rate() const;
|
int get_mix_rate() const override;
|
||||||
virtual SpeakerMode get_speaker_mode() const;
|
SpeakerMode get_speaker_mode() const override;
|
||||||
virtual void lock();
|
void lock() override;
|
||||||
virtual void unlock();
|
void unlock() override;
|
||||||
virtual void finish();
|
void finish() override;
|
||||||
void finish_async();
|
void finish_async();
|
||||||
|
|
||||||
virtual Error capture_start();
|
Error capture_start() override;
|
||||||
virtual Error capture_stop();
|
Error capture_stop() override;
|
||||||
|
|
||||||
AudioDriverJavaScript();
|
AudioDriverJavaScript();
|
||||||
};
|
};
|
||||||
|
|
|
@ -93,7 +93,7 @@ class DisplayServerJavaScript : public DisplayServer {
|
||||||
static void _dispatch_input_event(const Ref<InputEvent> &p_event);
|
static void _dispatch_input_event(const Ref<InputEvent> &p_event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int get_current_video_driver() const;
|
int get_current_video_driver() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Override return type to make writing static callbacks less tedious.
|
// Override return type to make writing static callbacks less tedious.
|
||||||
|
@ -113,92 +113,92 @@ public:
|
||||||
bool check_size_force_redraw();
|
bool check_size_force_redraw();
|
||||||
|
|
||||||
// from DisplayServer
|
// from DisplayServer
|
||||||
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
|
void alert(const String &p_alert, const String &p_title = "ALERT!") override;
|
||||||
virtual bool has_feature(Feature p_feature) const;
|
bool has_feature(Feature p_feature) const override;
|
||||||
virtual String get_name() const;
|
String get_name() const override;
|
||||||
|
|
||||||
// cursor
|
// cursor
|
||||||
virtual void cursor_set_shape(CursorShape p_shape);
|
void cursor_set_shape(CursorShape p_shape) override;
|
||||||
virtual CursorShape cursor_get_shape() const;
|
CursorShape cursor_get_shape() const override;
|
||||||
virtual void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2());
|
void cursor_set_custom_image(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()) override;
|
||||||
|
|
||||||
// mouse
|
// mouse
|
||||||
virtual void mouse_set_mode(MouseMode p_mode);
|
void mouse_set_mode(MouseMode p_mode) override;
|
||||||
virtual MouseMode mouse_get_mode() const;
|
MouseMode mouse_get_mode() const override;
|
||||||
|
|
||||||
// touch
|
// touch
|
||||||
virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
|
||||||
|
|
||||||
// clipboard
|
// clipboard
|
||||||
virtual void clipboard_set(const String &p_text);
|
void clipboard_set(const String &p_text) override;
|
||||||
virtual String clipboard_get() const;
|
String clipboard_get() const override;
|
||||||
|
|
||||||
// screen
|
// screen
|
||||||
virtual int get_screen_count() const;
|
int get_screen_count() const override;
|
||||||
virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
|
||||||
virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
|
||||||
virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
|
||||||
virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
|
int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
|
||||||
|
|
||||||
// windows
|
// windows
|
||||||
virtual Vector<DisplayServer::WindowID> get_window_list() const;
|
Vector<DisplayServer::WindowID> get_window_list() const override;
|
||||||
virtual WindowID get_window_at_screen_position(const Point2i &p_position) const;
|
WindowID get_window_at_screen_position(const Point2i &p_position) const override;
|
||||||
|
|
||||||
virtual void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID);
|
void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID) override;
|
||||||
virtual ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const;
|
ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const override;
|
||||||
|
|
||||||
virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
|
void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
|
||||||
|
|
||||||
virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
|
void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
|
||||||
virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
|
void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
|
||||||
virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
|
void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
|
||||||
|
|
||||||
virtual void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID);
|
void window_set_drop_files_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override;
|
||||||
|
|
||||||
virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID);
|
void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID) override;
|
||||||
|
|
||||||
virtual int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const;
|
int window_get_current_screen(WindowID p_window = MAIN_WINDOW_ID) const override;
|
||||||
virtual void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID);
|
void window_set_current_screen(int p_screen, WindowID p_window = MAIN_WINDOW_ID) override;
|
||||||
|
|
||||||
virtual Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const;
|
Point2i window_get_position(WindowID p_window = MAIN_WINDOW_ID) const override;
|
||||||
virtual void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID);
|
void window_set_position(const Point2i &p_position, WindowID p_window = MAIN_WINDOW_ID) override;
|
||||||
|
|
||||||
virtual void window_set_transient(WindowID p_window, WindowID p_parent);
|
void window_set_transient(WindowID p_window, WindowID p_parent) override;
|
||||||
|
|
||||||
virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
|
void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
|
||||||
virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const;
|
Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const override;
|
||||||
|
|
||||||
virtual void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
|
void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
|
||||||
virtual Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const;
|
Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const override;
|
||||||
|
|
||||||
virtual void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID);
|
void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
|
||||||
virtual Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const;
|
Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const override;
|
||||||
virtual Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const; // FIXME: Find clearer name for this.
|
Size2i window_get_real_size(WindowID p_window = MAIN_WINDOW_ID) const override;
|
||||||
|
|
||||||
virtual void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID);
|
void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) override;
|
||||||
virtual WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const;
|
WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const override;
|
||||||
|
|
||||||
virtual bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const;
|
bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const override;
|
||||||
|
|
||||||
virtual void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID);
|
void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID) override;
|
||||||
virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const;
|
bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const override;
|
||||||
|
|
||||||
virtual void window_request_attention(WindowID p_window = MAIN_WINDOW_ID);
|
void window_request_attention(WindowID p_window = MAIN_WINDOW_ID) override;
|
||||||
virtual void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID);
|
void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID) override;
|
||||||
|
|
||||||
virtual bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const;
|
bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const override;
|
||||||
|
|
||||||
virtual bool can_any_window_draw() const;
|
bool can_any_window_draw() const override;
|
||||||
|
|
||||||
// events
|
// events
|
||||||
virtual void process_events();
|
void process_events() override;
|
||||||
|
|
||||||
// icon
|
// icon
|
||||||
virtual void set_icon(const Ref<Image> &p_icon);
|
void set_icon(const Ref<Image> &p_icon) override;
|
||||||
|
|
||||||
// others
|
// others
|
||||||
virtual bool get_swap_cancel_ok();
|
bool get_swap_cancel_ok() override;
|
||||||
virtual void swap_buffers();
|
void swap_buffers() override;
|
||||||
|
|
||||||
static void register_javascript_driver();
|
static void register_javascript_driver();
|
||||||
DisplayServerJavaScript(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
|
DisplayServerJavaScript(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
|
||||||
|
|
|
@ -46,24 +46,6 @@
|
||||||
#include <emscripten.h>
|
#include <emscripten.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
bool OS_JavaScript::has_touchscreen_ui_hint() const {
|
|
||||||
/* clang-format off */
|
|
||||||
return EM_ASM_INT_V(
|
|
||||||
return 'ontouchstart' in window;
|
|
||||||
);
|
|
||||||
/* clang-format on */
|
|
||||||
}
|
|
||||||
|
|
||||||
// Audio
|
|
||||||
|
|
||||||
int OS_JavaScript::get_audio_driver_count() const {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *OS_JavaScript::get_audio_driver_name(int p_driver) const {
|
|
||||||
return "JavaScript";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lifecycle
|
// Lifecycle
|
||||||
void OS_JavaScript::initialize() {
|
void OS_JavaScript::initialize() {
|
||||||
OS_Unix::initialize_core();
|
OS_Unix::initialize_core();
|
||||||
|
@ -201,10 +183,6 @@ String OS_JavaScript::get_name() const {
|
||||||
return "HTML5";
|
return "HTML5";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OS_JavaScript::can_draw() const {
|
|
||||||
return true; // Always?
|
|
||||||
}
|
|
||||||
|
|
||||||
String OS_JavaScript::get_user_data_dir() const {
|
String OS_JavaScript::get_user_data_dir() const {
|
||||||
return "/userfs";
|
return "/userfs";
|
||||||
};
|
};
|
||||||
|
|
|
@ -52,49 +52,43 @@ class OS_JavaScript : public OS_Unix {
|
||||||
static void file_access_close_callback(const String &p_file, int p_flags);
|
static void file_access_close_callback(const String &p_file, int p_flags);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void initialize();
|
void initialize() override;
|
||||||
|
|
||||||
virtual void set_main_loop(MainLoop *p_main_loop);
|
void set_main_loop(MainLoop *p_main_loop) override;
|
||||||
virtual void delete_main_loop();
|
void delete_main_loop() override;
|
||||||
|
|
||||||
virtual void finalize();
|
void finalize() override;
|
||||||
|
|
||||||
virtual bool _check_internal_feature_support(const String &p_feature);
|
bool _check_internal_feature_support(const String &p_feature) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Override return type to make writing static callbacks less tedious.
|
// Override return type to make writing static callbacks less tedious.
|
||||||
static OS_JavaScript *get_singleton();
|
static OS_JavaScript *get_singleton();
|
||||||
|
|
||||||
virtual void initialize_joypads();
|
void initialize_joypads() override;
|
||||||
|
|
||||||
virtual bool has_touchscreen_ui_hint() const;
|
MainLoop *get_main_loop() const override;
|
||||||
|
|
||||||
virtual int get_audio_driver_count() const;
|
|
||||||
virtual const char *get_audio_driver_name(int p_driver) const;
|
|
||||||
|
|
||||||
virtual MainLoop *get_main_loop() const;
|
|
||||||
void finalize_async();
|
void finalize_async();
|
||||||
bool main_loop_iterate();
|
bool main_loop_iterate();
|
||||||
|
|
||||||
virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = nullptr, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr);
|
Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = nullptr, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr) override;
|
||||||
virtual Error kill(const ProcessID &p_pid);
|
Error kill(const ProcessID &p_pid) override;
|
||||||
virtual int get_process_id() const;
|
int get_process_id() const override;
|
||||||
|
|
||||||
String get_executable_path() const;
|
String get_executable_path() const override;
|
||||||
virtual Error shell_open(String p_uri);
|
Error shell_open(String p_uri) override;
|
||||||
virtual String get_name() const;
|
String get_name() const override;
|
||||||
// Override default OS implementation which would block the main thread with delay_usec.
|
// Override default OS implementation which would block the main thread with delay_usec.
|
||||||
// Implemented in javascript_main.cpp loop callback instead.
|
// Implemented in javascript_main.cpp loop callback instead.
|
||||||
virtual void add_frame_delay(bool p_can_draw) {}
|
void add_frame_delay(bool p_can_draw) override {}
|
||||||
virtual bool can_draw() const;
|
|
||||||
|
|
||||||
virtual String get_cache_path() const;
|
String get_cache_path() const override;
|
||||||
virtual String get_config_path() const;
|
String get_config_path() const override;
|
||||||
virtual String get_data_path() const;
|
String get_data_path() const override;
|
||||||
virtual String get_user_data_dir() const;
|
String get_user_data_dir() const override;
|
||||||
|
|
||||||
void set_idb_available(bool p_idb_available);
|
void set_idb_available(bool p_idb_available);
|
||||||
virtual bool is_userfs_persistent() const;
|
bool is_userfs_persistent() const override;
|
||||||
|
|
||||||
void resume_audio();
|
void resume_audio();
|
||||||
bool is_finalizing() { return finalizing; }
|
bool is_finalizing() { return finalizing; }
|
||||||
|
|
Loading…
Reference in a new issue