mirror of
https://github.com/kichikuou/system3-sdl2.git
synced 2026-10-11 08:48:11 +03:00
Merge upstream changes: Add wait after opening menu
This prevents mis-selection by key repeat etc.
This commit is contained in:
@@ -383,6 +383,37 @@ uint16 NACT::random(uint16 range)
|
||||
return (uint16)(((uint32)range * (seed & 0xffff)) >> 16) + 1;
|
||||
}
|
||||
|
||||
void NACT::wait_after_open_menu()
|
||||
{
|
||||
// 連打による誤クリック防止
|
||||
Uint32 dwTime = SDL_GetTicks();
|
||||
Uint32 dwWait = dwTime + 400;
|
||||
|
||||
while(dwTime < dwWait) {
|
||||
if(terminate) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
if(get_key() == 16) {
|
||||
break;
|
||||
}
|
||||
*/
|
||||
SDL_Delay(10);
|
||||
dwTime = SDL_GetTicks();
|
||||
}
|
||||
|
||||
// クリック中の間は待機
|
||||
for(;;) {
|
||||
if(terminate) {
|
||||
return;
|
||||
}
|
||||
if(!get_key()) {
|
||||
break;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
// WinMainとのインターフェース
|
||||
|
||||
int NACT::get_screen_height()
|
||||
|
||||
@@ -162,6 +162,8 @@ protected:
|
||||
uint16 random(uint16 range);
|
||||
uint32 seed;
|
||||
|
||||
void wait_after_open_menu();
|
||||
|
||||
uint8 get_key();
|
||||
void get_cursor(int* x, int* y);
|
||||
void set_cursor(int x, int y);
|
||||
|
||||
+12
-42
@@ -326,21 +326,8 @@ void NACT_Sys1::cmd_open_menu()
|
||||
}
|
||||
}
|
||||
|
||||
// クリック中の間は待機
|
||||
for(;;) {
|
||||
if(terminate) {
|
||||
return;
|
||||
}
|
||||
// if(get_key() != 32) {
|
||||
if(!get_key()) {
|
||||
break;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
// メニュー表示
|
||||
ags->open_menu_window(menu_window);
|
||||
int current_index = 0;
|
||||
|
||||
// マウス移動
|
||||
int sx = ags->menu_w[menu_window - 1].sx;
|
||||
@@ -349,7 +336,10 @@ void NACT_Sys1::cmd_open_menu()
|
||||
int mx = ex - 16;
|
||||
int my = sy + 10;
|
||||
int height = ags->menu_font_size + 4;
|
||||
int current_index = 0;
|
||||
|
||||
set_cursor(mx, my);
|
||||
wait_after_open_menu();
|
||||
|
||||
// メニュー選択
|
||||
for(bool selectable = true;;) {
|
||||
@@ -359,7 +349,7 @@ void NACT_Sys1::cmd_open_menu()
|
||||
if(terminate) {
|
||||
return;
|
||||
}
|
||||
if((val = get_key())) {
|
||||
if((val = get_key()) != 0) {
|
||||
SDL_Delay(100);
|
||||
break;
|
||||
}
|
||||
@@ -522,21 +512,8 @@ top2:
|
||||
}
|
||||
ags->draw_menu = false;
|
||||
|
||||
// クリック中の間は待機
|
||||
for(;;) {
|
||||
if(terminate) {
|
||||
return;
|
||||
}
|
||||
// if(get_key() != 32) {
|
||||
if(!get_key()) {
|
||||
break;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
// メニュー表示
|
||||
ags->open_menu_window(menu_window);
|
||||
int current_index = 0;
|
||||
|
||||
// マウス移動
|
||||
int sx = ags->menu_w[menu_window - 1].sx;
|
||||
@@ -545,7 +522,10 @@ top2:
|
||||
int mx = ex - 16;
|
||||
int my = sy + 10;
|
||||
int height = ags->menu_font_size + 4;
|
||||
int current_index = 0;
|
||||
|
||||
set_cursor(mx, my);
|
||||
wait_after_open_menu();
|
||||
|
||||
// メニュー選択
|
||||
for(bool selectable = true;;) {
|
||||
@@ -555,7 +535,7 @@ top2:
|
||||
if(terminate) {
|
||||
return;
|
||||
}
|
||||
if((val = get_key())) {
|
||||
if((val = get_key()) != 0) {
|
||||
SDL_Delay(100);
|
||||
break;
|
||||
}
|
||||
@@ -714,21 +694,8 @@ top2:
|
||||
}
|
||||
ags->draw_menu = false;
|
||||
|
||||
// クリック中の間は待機
|
||||
for(;;) {
|
||||
if(terminate) {
|
||||
return;
|
||||
}
|
||||
// if(get_key() != 32) {
|
||||
if(!get_key()) {
|
||||
break;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
// メニュー表示
|
||||
ags->open_menu_window(menu_window);
|
||||
int current_index = 0;
|
||||
|
||||
// マウス移動
|
||||
int sx = ags->menu_w[menu_window - 1].sx;
|
||||
@@ -737,7 +704,10 @@ top2:
|
||||
int mx = ex - 16;
|
||||
int my = sy + 10;
|
||||
int height = ags->menu_font_size + 4;
|
||||
int current_index = 0;
|
||||
|
||||
set_cursor(mx, my);
|
||||
wait_after_open_menu();
|
||||
|
||||
// メニュー選択
|
||||
for(bool selectable = true;;) {
|
||||
@@ -747,7 +717,7 @@ top2:
|
||||
if(terminate) {
|
||||
return;
|
||||
}
|
||||
if((val = get_key())) {
|
||||
if((val = get_key()) != 0) {
|
||||
SDL_Delay(100);
|
||||
break;
|
||||
}
|
||||
|
||||
+12
-42
@@ -333,21 +333,8 @@ void NACT_Sys2::cmd_open_menu()
|
||||
return;
|
||||
}
|
||||
|
||||
// クリック中の間は待機
|
||||
for(;;) {
|
||||
if(terminate) {
|
||||
return;
|
||||
}
|
||||
// if(get_key() != 32) {
|
||||
if(!get_key()) {
|
||||
break;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
// メニュー表示
|
||||
ags->open_menu_window(menu_window);
|
||||
int current_index = 0;
|
||||
|
||||
// マウス移動
|
||||
int sx = ags->menu_w[menu_window - 1].sx;
|
||||
@@ -356,7 +343,10 @@ void NACT_Sys2::cmd_open_menu()
|
||||
int mx = ex - 16;
|
||||
int my = sy + 10;
|
||||
int height = ags->menu_font_size + 4;
|
||||
int current_index = 0;
|
||||
|
||||
set_cursor(mx, my);
|
||||
wait_after_open_menu();
|
||||
|
||||
// メニュー選択
|
||||
for(bool selectable = true;;) {
|
||||
@@ -366,7 +356,7 @@ void NACT_Sys2::cmd_open_menu()
|
||||
if(terminate) {
|
||||
return;
|
||||
}
|
||||
if((val = get_key())) {
|
||||
if((val = get_key()) != 0) {
|
||||
SDL_Delay(100);
|
||||
break;
|
||||
}
|
||||
@@ -494,21 +484,8 @@ void NACT_Sys2::cmd_open_verb()
|
||||
}
|
||||
ags->draw_menu = false;
|
||||
|
||||
// クリック中の間は待機
|
||||
for(;;) {
|
||||
if(terminate) {
|
||||
return;
|
||||
}
|
||||
// if(get_key() != 32) {
|
||||
if(!get_key()) {
|
||||
break;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
// メニュー表示
|
||||
ags->open_menu_window(menu_window);
|
||||
int current_index = 0;
|
||||
|
||||
// マウス移動
|
||||
int sx = ags->menu_w[menu_window - 1].sx;
|
||||
@@ -517,7 +494,10 @@ void NACT_Sys2::cmd_open_verb()
|
||||
int mx = ex - 16;
|
||||
int my = sy + 10;
|
||||
int height = ags->menu_font_size + 4;
|
||||
int current_index = 0;
|
||||
|
||||
set_cursor(mx, my);
|
||||
wait_after_open_menu();
|
||||
|
||||
// メニュー選択
|
||||
for(bool selectable = true;;) {
|
||||
@@ -527,7 +507,7 @@ void NACT_Sys2::cmd_open_verb()
|
||||
if(terminate) {
|
||||
return;
|
||||
}
|
||||
if((val = get_key())) {
|
||||
if((val = get_key()) != 0) {
|
||||
SDL_Delay(100);
|
||||
break;
|
||||
}
|
||||
@@ -642,21 +622,8 @@ void NACT_Sys2::cmd_open_obj(int verb)
|
||||
ags->menu_dest_y += ags->menu_font_size + 2;
|
||||
ags->draw_menu = false;
|
||||
|
||||
// クリック中の間は待機
|
||||
for(;;) {
|
||||
if(terminate) {
|
||||
return;
|
||||
}
|
||||
// if(get_key() != 32) {
|
||||
if(!get_key()) {
|
||||
break;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
// メニュー表示
|
||||
ags->open_menu_window(menu_window);
|
||||
int current_index = 0;
|
||||
|
||||
// マウス移動
|
||||
int sx = ags->menu_w[menu_window - 1].sx;
|
||||
@@ -665,7 +632,10 @@ void NACT_Sys2::cmd_open_obj(int verb)
|
||||
int mx = ex - 16;
|
||||
int my = sy + 10;
|
||||
int height = ags->menu_font_size + 4;
|
||||
int current_index = 0;
|
||||
|
||||
set_cursor(mx, my);
|
||||
wait_after_open_menu();
|
||||
|
||||
// メニュー選択
|
||||
for(bool selectable = true;;) {
|
||||
@@ -675,7 +645,7 @@ void NACT_Sys2::cmd_open_obj(int verb)
|
||||
if(terminate) {
|
||||
return;
|
||||
}
|
||||
if((val = get_key())) {
|
||||
if((val = get_key()) != 0) {
|
||||
SDL_Delay(100);
|
||||
break;
|
||||
}
|
||||
|
||||
+5
-15
@@ -128,21 +128,8 @@ void NACT_Sys3::cmd_set_menu()
|
||||
|
||||
int NACT_Sys3::menu_select(int num_items)
|
||||
{
|
||||
// クリック中の間は待機
|
||||
for(;;) {
|
||||
if(terminate) {
|
||||
return -1;
|
||||
}
|
||||
// if(get_key() != 32) {
|
||||
if(!get_key()) {
|
||||
break;
|
||||
}
|
||||
SDL_Delay(16);
|
||||
}
|
||||
|
||||
// メニュー表示
|
||||
ags->open_menu_window(menu_window);
|
||||
int current_index = 0;
|
||||
|
||||
// マウス移動
|
||||
int sx = ags->menu_w[menu_window - 1].sx;
|
||||
@@ -151,7 +138,10 @@ int NACT_Sys3::menu_select(int num_items)
|
||||
int mx = ex - 16;
|
||||
int my = sy + 10;
|
||||
int height = ags->menu_font_size + 4;
|
||||
int current_index = 0;
|
||||
|
||||
set_cursor(mx, my);
|
||||
wait_after_open_menu();
|
||||
|
||||
// メニュー選択
|
||||
for(bool selectable = true;;) {
|
||||
@@ -166,7 +156,7 @@ int NACT_Sys3::menu_select(int num_items)
|
||||
int dy = my - current_my;
|
||||
if (dx*dx + dy*dy > 10)
|
||||
break;
|
||||
if((val = get_key())) {
|
||||
if((val = get_key()) != 0) {
|
||||
SDL_Delay(100);
|
||||
break;
|
||||
}
|
||||
@@ -622,7 +612,7 @@ void NACT_Sys3::cmd_k()
|
||||
if(terminate) {
|
||||
return;
|
||||
}
|
||||
if((val = get_key())) {
|
||||
if((val = get_key()) != 0) {
|
||||
break;
|
||||
}
|
||||
if(1 <= cmd && cmd <= 3) {
|
||||
|
||||
Reference in New Issue
Block a user