29 #include YFM_Helper_HostRenderer // for Host::WindowThread;
30 #include YFM_Helper_Initialization
31 #include YFM_YSLib_Adaptor_Font
33 #if YCL_MULTITHREAD == 1
39 #include YFM_YCLib_Debug
40 #include YFM_Helper_Host
45 using namespace Drawing;
52 std::chrono::nanoseconds host_sleep(
u64(1000000000 / g_max_free_fps));
57 DSApplication* ApplicationPtr;
62 DSApplication::DSApplication()
63 : GUIApplication(), DSVideoState(),
69 using Devices::DSScreen;
71 YAssert(!ApplicationPtr,
"Duplicate instance found.");
73 ApplicationPtr =
this;
81 FillPixel<PixelType>(scrs[0]->GetCheckedBufferPtr(),
83 FillPixel<PixelType>(scrs[1]->GetCheckedBufferPtr(),
89 YAssert(IsScreenReady(),
"Screen is not ready.");
90 p_wnd_thrd.reset(
new WindowThread([
this]{
93 | WS_SYSMENU | WS_MINIMIZEBOX), *scrs[0], *scrs[1], GetHost()));
95 while(!p_wnd_thrd->GetWindowPtr())
97 std::this_thread::sleep_for(host_sleep);
99 const auto h_wnd(p_wnd_thrd->GetWindowPtr()->GetNativeHandle());
101 yunseq(scrs[0]->WindowHandle = h_wnd, scrs[1]->WindowHandle = h_wnd);
105 DSApplication::~DSApplication()
122 DSApplication::GetDSScreenUp() const
ynothrow
128 DSApplication::GetDSScreenDown() const
ynothrow
134 DSApplication::GetScreenUp() const
ynothrow
136 return GetDSScreenUp();
139 DSApplication::GetScreenDown() const
ynothrow
141 return GetDSScreenDown();
145 DSApplication::SwapScreens()
150 std::swap(GetDSScreenUp().Offset, GetDSScreenDown().Offset);
152 if(
const auto p_wnd = GetHost().GetForegroundWindow())
161 InitConsole(Devices::Screen& scr, Drawing::PixelType
fc, Drawing::PixelType bc)
163 using namespace platform;
165 if(&FetchGlobalInstance<DSApplication>().GetScreenUp() == &scr)
167 else if(&FetchGlobalInstance<DSApplication>().GetScreenDown() == &scr)
171 #elif YCL_Win32 || YCL_Android
172 InitConsole(Devices::Screen&, Drawing::PixelType, Drawing::PixelType)
175 # error "Unsupported platform found."
183 using namespace platform;
187 std::printf(
"Fatal Error:\n%s\n", s);
196 TestFramework(
size_t idx)
yconstexpr wchar_t WindowClassName[]
YF_API GUIState & FetchGUIState()
取默认图形用户界面公共状态。
#define yunused(...)
标记未使用的表达式。
YF_API void YDebugBegin()
调试模式:显示控制台。
yconstfn auto GetAreaOf(const Size &s) ynothrow-> decltype(s.Width *s.Height)
取面积。
YF_API void YDebugSetStatus(bool=true)
调试模式:设置状态。
YB_NORETURN YF_API void terminate() ynothrow
异常终止函数。
YF_API NativeWindowHandle CreateNativeWindow(const wchar_t *, const YSLib::Drawing::Size &, const wchar_t *=L"",::DWORD=WS_POPUP,::DWORD=WS_EX_LTRREADING)
按指定窗口类名、客户区大小、标题文本、样式和附加样式创建本机顶层窗口。
void swap(any &x, any &y)
交换对象。
#define yunseq
无序列依赖表达式组求值。
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
YF_API Drawing::FontCache & FetchDefaultFontCache()
取默认字体缓存。
YF_API void YConsoleInit(std::uint8_t dspIndex, Color fc=ColorSpace::White, Color bc=ColorSpace::Black)
启动控制台。
#define YAssertNonnull(_expr)
if(YB_LIKELY(!error)) if(YB_LIKELY(!(error
bool reset(std::unique_ptr< _type > &p)
std::string to_string(unsigned char val)
转换为字符串。
#define YTraceDe(...)
YCLib 默认调试跟踪。
#define yconstexpr
指定编译时常量表达式。
void InitDSScreen(unique_ptr< DSScreen > &p_up, unique_ptr< DSScreen > &p_dn) ynothrow
初始化 DS 屏幕。
void ShowFatalError(const char *s)
#define YAssert(_expr, _msg)