Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0330/reset-window] 画面初期表示と画面消去を統一 #938

Merged
merged 3 commits into from
Jan 16, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 20 additions & 52 deletions js/danoni_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,8 @@ function loadSettingJs() {
}

function loadMusic() {

clearWindow();
document.onkeydown = evt => blockCode(transCode(evt.code));

const musicUrl = g_headerObj.musicUrls[g_headerObj.musicNos[g_stateObj.scoreId]] || g_headerObj.musicUrls[0];
Expand Down Expand Up @@ -2021,6 +2023,8 @@ function drawTitleResultMotion(_spriteName) {
* タイトル画面初期化
*/
function titleInit() {

clearWindow();
drawDefaultBackImage(``);

// タイトル用フレーム初期化
Expand Down Expand Up @@ -2182,7 +2186,6 @@ function titleInit() {
// Click Here
createCss2Button(`btnStart`, `Click Here!!`, _ => {
clearTimeout(g_timeoutEvtTitleId);
clearWindow();
optionInit();
}, {
w: g_sWidth, siz: C_LBL_TITLESIZE,
Expand Down Expand Up @@ -2329,7 +2332,6 @@ function titleInit() {

if (setCode === `Enter`) {
clearTimeout(g_timeoutEvtTitleId);
clearWindow();
optionInit();
}
return blockCode(setCode);
Expand Down Expand Up @@ -3475,6 +3477,7 @@ function keysConvert(_dosObj) {
*/
function optionInit() {

clearWindow();
drawDefaultBackImage(``);
const divRoot = document.querySelector(`#divRoot`);
g_baseDisp = `Settings`;
Expand All @@ -3497,35 +3500,21 @@ function optionInit() {
multiAppend(divRoot,

// タイトル画面へ戻る
createCss2Button(`btnBack`, `Back`, _ => {
clearWindow();
titleInit();
}, {
createCss2Button(`btnBack`, `Back`, _ => titleInit(), {
animationName: (g_initialFlg ? `` : `smallToNormalY`),
}, g_cssObj.button_Back),

// キーコンフィグ画面へ移動
createCss2Button(`btnKeyConfig`, `KeyConfig`, _ => {
// キーコンフィグ画面へ遷移
g_kcType = `Main`;
clearWindow();
keyConfigInit();
}, {
createCss2Button(`btnKeyConfig`, `KeyConfig`, _ => keyConfigInit(`Main`), {
x: g_sWidth / 3,
animationName: (g_initialFlg ? `` : `smallToNormalY`),
}, g_cssObj.button_Setting),

// プレイ開始
makePlayButton(_ => {
clearWindow();
loadMusic();
}),
makePlayButton(_ => loadMusic()),

// Display設定へ移動
createCss2Button(`btnDisplay`, `>`, _ => {
clearWindow();
settingsDisplayInit();
}, {
createCss2Button(`btnDisplay`, `>`, _ => settingsDisplayInit(), {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

x: g_sWidth / 2 + 175 - C_LEN_SETMINI_WIDTH / 2, y: 25,
w: C_LEN_SETMINI_WIDTH, h: 40,
title: g_msgObj.toDisplay,
Expand Down Expand Up @@ -3554,7 +3543,6 @@ function optionInit() {
}

if (setCode === `Enter`) {
clearWindow();
loadMusic();
}
return blockCode(setCode);
Expand Down Expand Up @@ -4730,6 +4718,7 @@ function makeMiniCssButton(_id, _directionFlg, _heightPos, _func, { dx = 0, dy =

function settingsDisplayInit() {

clearWindow();
drawDefaultBackImage(``);
const divRoot = document.querySelector(`#divRoot`);
g_baseDisp = `Display`;
Expand Down Expand Up @@ -4762,31 +4751,18 @@ function settingsDisplayInit() {
multiAppend(divRoot,

// タイトル画面へ戻る
createCss2Button(`btnBack`, `Back`, _ => {
clearWindow();
titleInit();
}, {}, g_cssObj.button_Back),
createCss2Button(`btnBack`, `Back`, _ => titleInit(), {}, g_cssObj.button_Back),

// キーコンフィグ画面へ移動
createCss2Button(`btnKeyConfig`, `KeyConfig`, _ => {
g_kcType = `Main`;
clearWindow();
keyConfigInit();
}, {
createCss2Button(`btnKeyConfig`, `KeyConfig`, _ => keyConfigInit(`Main`), {
x: g_sWidth / 3,
}, g_cssObj.button_Setting),

// プレイ開始
makePlayButton(_ => {
clearWindow();
loadMusic();
}),
makePlayButton(_ => loadMusic()),

// メイン設定へ戻る
createCss2Button(`btnSettings`, `<`, _ => {
clearWindow();
optionInit();
}, {
createCss2Button(`btnSettings`, `<`, _ => optionInit(), {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

x: g_sWidth / 2 - 175 - C_LEN_SETMINI_WIDTH / 2, y: 25,
w: C_LEN_SETMINI_WIDTH, h: 40,
title: g_msgObj.toSettings,
Expand All @@ -4803,7 +4779,6 @@ function settingsDisplayInit() {
}

if (setCode === `Enter`) {
clearWindow();
loadMusic();
}
return blockCode(setCode);
Expand Down Expand Up @@ -4961,10 +4936,12 @@ function interlockingButton(_headerObj, _name, _current, _next, _buttonFlg = fal
/**
* キーコンフィグ画面初期化
*/
function keyConfigInit() {
function keyConfigInit(_kcType = g_kcType) {

clearWindow();
drawDefaultBackImage(``);
const divRoot = document.querySelector(`#divRoot`);
g_kcType = _kcType;

// 譜面初期情報ロード許可フラグ
g_canLoadDifInfoFlg = false;
Expand Down Expand Up @@ -5188,7 +5165,6 @@ function keyConfigInit() {
g_currentj = 0;
g_currentk = 0;
g_prevKey = 0;
clearWindow();

if (g_baseDisp === `Settings`) {
optionInit();
Expand All @@ -5211,7 +5187,6 @@ function keyConfigInit() {
g_keyObj.currentPtn = (g_keyObj[`keyCtrl${g_keyObj.currentKey}_${tempPtn}`] !== undefined ?
tempPtn : (g_keyObj[`keyCtrl${g_keyObj.currentKey}_-1`] !== undefined ? -1 : 0));

clearWindow();
keyConfigInit();
const keyCtrlPtn = `${g_keyObj.currentKey}_${g_keyObj.currentPtn}`;
const divideCnt = g_keyObj[`div${keyCtrlPtn}`] - 1;
Expand All @@ -5227,7 +5202,6 @@ function keyConfigInit() {
g_keyObj.currentPtn = (g_keyObj[`keyCtrl${g_keyObj.currentKey}_${tempPtn}`] !== undefined ?
tempPtn : searchPattern(searchPattern(0, 1) - 1, -1, g_headerObj.transKeyUse, `transKey`));

clearWindow();
keyConfigInit();
const keyCtrlPtn = `${g_keyObj.currentKey}_${g_keyObj.currentPtn}`;
const divideCnt = g_keyObj[`div${keyCtrlPtn}`] - 1;
Expand Down Expand Up @@ -5680,7 +5654,6 @@ function loadingScoreInit() {
const tempId = setInterval(() => {
const executeMain = _ => {
clearInterval(tempId);
clearWindow();
MainInit();
}
if (g_audio.duration !== undefined) {
Expand Down Expand Up @@ -7067,6 +7040,7 @@ function setKeyCtrl(_localStorage, _keyNum, _keyCtrlPtn) {
* メイン画面初期化
*/
function MainInit() {
clearWindow();
drawDefaultBackImage(`Main`);
const divRoot = document.querySelector(`#divRoot`);
document.oncontextmenu = _ => false;
Expand Down Expand Up @@ -7540,7 +7514,6 @@ function MainInit() {
} else if (setCode === g_kCdN[g_headerObj.keyTitleBack]) {
g_audio.pause();
clearTimeout(g_timeoutEvtId);
clearWindow();
if (keyIsDown(`ShiftLeft`)) {
g_gameOverFlg = true;
g_finishFlg = false;
Expand Down Expand Up @@ -8282,17 +8255,13 @@ function MainInit() {
document.onkeyup = evt => { }

clearTimeout(g_timeoutEvtId);
setTimeout(_ => {
clearWindow();
resultInit();
}, 100);
setTimeout(_ => resultInit(), 100);

} else if (g_workObj.lifeVal === 0 && g_workObj.lifeBorder === 0) {

// ライフ制&ライフ0の場合は途中終了
g_audio.pause();
clearTimeout(g_timeoutEvtId);
clearWindow();
g_gameOverFlg = true;
g_finishFlg = false;
resultInit();
Expand Down Expand Up @@ -8876,6 +8845,7 @@ function finishViewing() {
*/
function resultInit() {

clearWindow();
drawDefaultBackImage(``);

// 結果画面用フレーム初期化
Expand Down Expand Up @@ -9253,7 +9223,6 @@ function resultInit() {
}
clearTimeout(g_timeoutEvtId);
clearTimeout(g_timeoutEvtResultId);
clearWindow();
titleInit();
}, {
w: g_sWidth / 4, h: C_BTN_HEIGHT * 5 / 4,
Expand Down Expand Up @@ -9292,7 +9261,6 @@ function resultInit() {
}
clearTimeout(g_timeoutEvtId);
clearTimeout(g_timeoutEvtResultId);
clearWindow();
loadMusic();
}, {
x: g_sWidth / 4 * 3,
Expand Down