2024-02-25 14:46:47 +00:00
|
|
|
#pragma once
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
#include "StarApplication.hpp"
|
|
|
|
#include "StarStatisticsService.hpp"
|
|
|
|
#include "StarP2PNetworkingService.hpp"
|
|
|
|
#include "StarUserGeneratedContentService.hpp"
|
|
|
|
#include "StarDesktopService.hpp"
|
2023-06-23 08:13:26 +00:00
|
|
|
#include "StarImage.hpp"
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
namespace Star {
|
|
|
|
|
|
|
|
STAR_CLASS(ApplicationController);
|
|
|
|
|
|
|
|
// Audio format is always 16 bit signed integer samples
|
|
|
|
struct AudioFormat {
|
|
|
|
unsigned sampleRate;
|
|
|
|
unsigned channels;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Window size defaults to 800x600, target update rate to 60hz, maximized and
|
|
|
|
// fullscreen are false, vsync is on, the cursor is visible, and audio and text
|
|
|
|
// input are disabled.
|
|
|
|
class ApplicationController {
|
|
|
|
public:
|
|
|
|
virtual ~ApplicationController() = default;
|
|
|
|
|
|
|
|
// Target hz at which update() will be called
|
|
|
|
virtual void setTargetUpdateRate(float targetUpdateRate) = 0;
|
|
|
|
// Window that controls how long the update rate will be increased or
|
|
|
|
// decreased to make up for rate errors in the past.
|
|
|
|
virtual void setUpdateTrackWindow(float updateTrackWindow) = 0;
|
|
|
|
// Maximum number of calls to update() that can occur before we force
|
|
|
|
// 'render()' to be called, even if we are still behind on our update rate.
|
|
|
|
virtual void setMaxFrameSkip(unsigned maxFrameSkip) = 0;
|
|
|
|
|
|
|
|
virtual void setApplicationTitle(String title) = 0;
|
|
|
|
virtual void setFullscreenWindow(Vec2U fullScreenResolution) = 0;
|
|
|
|
virtual void setNormalWindow(Vec2U windowSize) = 0;
|
|
|
|
virtual void setMaximizedWindow() = 0;
|
|
|
|
virtual void setBorderlessWindow() = 0;
|
|
|
|
virtual void setVSyncEnabled(bool vSync) = 0;
|
|
|
|
virtual void setCursorVisible(bool cursorVisible) = 0;
|
2023-11-01 21:12:21 +00:00
|
|
|
virtual void setCursorPosition(Vec2I cursorPosition) = 0;
|
2023-06-23 08:13:26 +00:00
|
|
|
virtual bool setCursorImage(const String& id, const ImageConstPtr& image, unsigned scale, const Vec2I& offset) = 0;
|
2023-06-20 04:33:09 +00:00
|
|
|
virtual void setAcceptingTextInput(bool acceptingTextInput) = 0;
|
|
|
|
|
2023-07-13 09:12:55 +00:00
|
|
|
|
|
|
|
|
2023-06-20 04:33:09 +00:00
|
|
|
virtual AudioFormat enableAudio() = 0;
|
|
|
|
virtual void disableAudio() = 0;
|
2023-07-13 09:12:55 +00:00
|
|
|
|
2023-07-21 02:22:26 +00:00
|
|
|
typedef void (*AudioCallback)(void* userdata, uint8_t* stream, int len);
|
2023-07-13 09:12:55 +00:00
|
|
|
|
|
|
|
virtual bool openAudioInputDevice(const char* name, int freq, int channels, void* userdata, AudioCallback callback) = 0;
|
|
|
|
virtual bool closeAudioInputDevice() = 0;
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-16 14:52:34 +00:00
|
|
|
virtual bool hasClipboard() = 0;
|
2023-06-20 04:33:09 +00:00
|
|
|
virtual void setClipboard(String text) = 0;
|
|
|
|
virtual Maybe<String> getClipboard() = 0;
|
|
|
|
|
|
|
|
// Returns the latest actual measured update and render rate, which may be
|
|
|
|
// different than the target update rate.
|
|
|
|
virtual float updateRate() const = 0;
|
|
|
|
virtual float renderFps() const = 0;
|
|
|
|
|
|
|
|
virtual StatisticsServicePtr statisticsService() const = 0;
|
|
|
|
virtual P2PNetworkingServicePtr p2pNetworkingService() const = 0;
|
|
|
|
virtual UserGeneratedContentServicePtr userGeneratedContentService() const = 0;
|
|
|
|
virtual DesktopServicePtr desktopService() const = 0;
|
|
|
|
|
|
|
|
// Signals the application to quit
|
|
|
|
virtual void quit() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|