Skip to content

Commit

Permalink
Merge pull request #938 from cwtickle/feature/0330-reset-window
Browse files Browse the repository at this point in the history
[0330/reset-window] 画面初期表示と画面消去を統一
  • Loading branch information
cwtickle committed Jan 16, 2021
2 parents 6480806 + 40d6ac4 commit d415f5d
Showing 1 changed file with 22 additions and 56 deletions.
78 changes: 22 additions & 56 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,38 +3500,23 @@ 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(), {
x: g_sWidth / 2 + 175 - C_LEN_SETMINI_WIDTH / 2, y: 25,
w: C_LEN_SETMINI_WIDTH, h: 40,
title: g_msgObj.toDisplay,
w: C_LEN_SETMINI_WIDTH, h: 40, title: g_msgObj.toDisplay,
}, g_cssObj.button_Mini),

// データセーブフラグの切替
Expand All @@ -3554,7 +3542,6 @@ function optionInit() {
}

if (setCode === `Enter`) {
clearWindow();
loadMusic();
}
return blockCode(setCode);
Expand Down Expand Up @@ -4730,6 +4717,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,34 +4750,20 @@ 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(), {
x: g_sWidth / 2 - 175 - C_LEN_SETMINI_WIDTH / 2, y: 25,
w: C_LEN_SETMINI_WIDTH, h: 40,
title: g_msgObj.toSettings,
w: C_LEN_SETMINI_WIDTH, h: 40, title: g_msgObj.toSettings,
}, g_cssObj.button_Mini)

);
Expand All @@ -4803,7 +4777,6 @@ function settingsDisplayInit() {
}

if (setCode === `Enter`) {
clearWindow();
loadMusic();
}
return blockCode(setCode);
Expand Down Expand Up @@ -4961,10 +4934,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 +5163,6 @@ function keyConfigInit() {
g_currentj = 0;
g_currentk = 0;
g_prevKey = 0;
clearWindow();

if (g_baseDisp === `Settings`) {
optionInit();
Expand All @@ -5211,7 +5185,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 +5200,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 +5652,6 @@ function loadingScoreInit() {
const tempId = setInterval(() => {
const executeMain = _ => {
clearInterval(tempId);
clearWindow();
MainInit();
}
if (g_audio.duration !== undefined) {
Expand Down Expand Up @@ -7067,6 +7038,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 +7512,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 +8253,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 +8843,7 @@ function finishViewing() {
*/
function resultInit() {

clearWindow();
drawDefaultBackImage(``);

// 結果画面用フレーム初期化
Expand Down Expand Up @@ -9253,7 +9221,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 +9259,6 @@ function resultInit() {
}
clearTimeout(g_timeoutEvtId);
clearTimeout(g_timeoutEvtResultId);
clearWindow();
loadMusic();
}, {
x: g_sWidth / 4 * 3,
Expand Down

0 comments on commit d415f5d

Please sign in to comment.