2022年4月10日日曜日

Windows上でHSP3Dishを使ったWindows用アプリを作る際の画面サイズをディスプレイサイズに自動的に合わせるソース

//このコードは、[F5]ではなく、エディタの[コンパイル+実行(C)]で実行してください。


#include "hsp3dish.as"


#const SCREEN_WIDTH_SIZE 720

#const SCREEN_HEIGHT_SIZE 1280

#const MINUS_SIZE 250


#module

; ---------- zoomxy(元の横大きさ, 元の縦大きさ, 変更したい横大きさ)

#defcfunc zoomxy int moto_x, int moto_y, int henkou_x

return (henkou_x * 1000 / moto_x) * moto_y / 1000


; ---------- zoomyx(元の横大きさ, 元の縦大きさ, 変更したい縦大きさ)

#defcfunc zoomyx int moto_x, int moto_y, int henkou_y

return (henkou_y * 1000 / moto_y) * moto_x / 1000

#global


plat_form = PLATFORM_WINDOWS

getreq plat_form, SYSREQ_PLATFORM

if plat_form == PLATFORM_WINDOWS {

if ginfo_dispx > ginfo_dispy {

display_size = ginfo_dispx - MINUS_SIZE

} else {

display_size = ginfo_dispy - MINUS_SIZE

}


window_size_width = SCREEN_WIDTH_SIZE

window_size_height = SCREEN_HEIGHT_SIZE

window_size_change_width = display_size

window_size_y = zoomxy(window_size_width, window_size_height, window_size_change_width)

window_size_x = zoomyx(window_size_width, window_size_height, window_size_y)


if window_size_y > ginfo_dispy {

display_size = ginfo_dispy - MINUS_SIZE

window_size_change_h = display_size

window_size_x = zoomyx(window_size_width, window_size_height, window_size_change_h)

window_size_y = zoomxy(window_size_width, window_size_height, window_size_x)

}


screen 0, window_size_x, window_size_y, 0, (ginfo_dispx - window_size_x) / 2, (ginfo_dispy - window_size_y) / 2

scale_x = double(window_size_x) / double(window_size_width)

scale_y = double(window_size_y) / double(window_size_height)

viewcalc vptype_2d, scale_x, scale_y

}


repeat

redraw 0

color 0, 0, 0 : boxf 0, 0, SCREEN_WIDTH_SIZE, SCREEN_HEIGHT_SIZE

redraw 1

await 16

loop


0 件のコメント:

コメントを投稿

Windows11 home Bitlocker解除

  設定→プライバシーとセキュリティ→デバイスの暗号化(オフ)