private void InputPadButtonKeySetting(bool キー設定Flag, string title, DDInput.Button button) { DDEngine.FreezeInput(); for (; ;) { if ( //DDInput.A.GetInput() == 1 || // ... 現在の割り当てボタン・キーに反応してしまうんでない? //DDInput.B.GetInput() == 1 || DDMouse.R.GetInput() == -1 ) { break; } if (CheckInputPadButtonKey(キー設定Flag, button)) { DDEngine.FreezeInput(GameConsts.LONG_INPUT_SLEEP); // 決定・キャンセルを変更した場合を考慮して、長めにフリーズしておく break; } this.DrawWall(); DDDraw.DrawSimple(Ground.I.Picture.詳細設定枠, 0, 0); if (キー設定Flag) { DrawTabTitle(480, 70, "キーボードのキー設定 / 変更", true); } else { DrawTabTitle(400, 70, "ゲームパッドのボタン設定 / 変更", true); } DDFontUtils.DrawString( 100, 520, "「" + title + "」に割り当てる" + (キー設定Flag ? "キー" : "ボタン") + "を押して下さい。", DDFontUtils.GetFont("Kゴシック", 50), false, new I3Color(255, 255, 255), new I3Color(100, 100, 0) ); this.DrawButton(1630, 950, Ground.I.Picture.SettingButton_キャンセル, true); if (this.LastButtonHoveringFlag && DDMouse.L.GetInput() == -1) { break; } DDEngine.EachFrame(); } DDEngine.FreezeInput(); }
private bool CheckInputPadButtonKey(bool キー設定Flag, DDInput.Button targetButton) // ret: 設定した。 { DDInput.Button[] buttons = new DDInput.Button[] { DDInput.DIR_2, DDInput.DIR_4, DDInput.DIR_6, DDInput.DIR_8, DDInput.A, DDInput.B, DDInput.L, }; if (キー設定Flag) { int pressKeyId = -1; foreach (int keyId in DDSimpleMenu.GetAllKeyId()) { if (DDKey.GetInput(keyId) == 1) { pressKeyId = keyId; } } if (pressKeyId != -1) { int[] keyIds; switch (pressKeyId) { case DX.KEY_INPUT_LCONTROL: case DX.KEY_INPUT_RCONTROL: keyIds = new int[] { DX.KEY_INPUT_LCONTROL, DX.KEY_INPUT_RCONTROL }; break; case DX.KEY_INPUT_LSHIFT: case DX.KEY_INPUT_RSHIFT: keyIds = new int[] { DX.KEY_INPUT_LSHIFT, DX.KEY_INPUT_RSHIFT }; break; case DX.KEY_INPUT_LALT: case DX.KEY_INPUT_RALT: keyIds = new int[] { DX.KEY_INPUT_LALT, DX.KEY_INPUT_RALT }; break; default: keyIds = new int[] { pressKeyId }; break; } // 他ボタンとの重複回避 if (SCommon.Comp(targetButton.KeyIds, keyIds, SCommon.Comp) != 0) // ? 違う { foreach (DDInput.Button button in buttons) { if (SCommon.Comp(button.KeyIds, keyIds, SCommon.Comp) == 0) // ? 同じ { button.KeyIds = targetButton.KeyIds; } } } targetButton.KeyIds = keyIds; return(true); } } else { int pressBtnId = -1; for (int padId = 0; padId < DDPad.GetPadCount(); padId++) { for (int btnId = 0; btnId < DDPad.PAD_BUTTON_MAX; btnId++) { if (DDPad.GetInput(padId, btnId) == 1) { pressBtnId = btnId; } } } if (pressBtnId != -1) { int[] btnIds = new int[] { pressBtnId }; // 他ボタンとの重複回避 if (SCommon.Comp(targetButton.BtnIds, btnIds, SCommon.Comp) != 0) // ? 違う { foreach (DDInput.Button button in buttons) { if (SCommon.Comp(button.BtnIds, btnIds, SCommon.Comp) == 0) // ? 同じ { button.BtnIds = targetButton.BtnIds; } } } targetButton.BtnIds = btnIds; return(true); } } return(false); }
private void PrintPadButtonKeySetting(bool キー設定Flag, int padButtonIndex, string title, DDInput.Button button) { int y = 230 + padButtonIndex * 90; string setting; if (キー設定Flag) { setting = string.Join(" , ", button.KeyIds.Select(keyId => DDSimpleMenu.GetKeyName(keyId))); } else { setting = string.Join(" , ", button.BtnIds.Select(btnId => DDSimpleMenu.GetPadButtonName(btnId))); } this.DrawButton(300, y + 25, Ground.I.Picture.SettingButton_変更, true); if (this.LastButtonHoveringFlag && DDMouse.L.GetInput() == -1) { InputPadButtonKeySetting(キー設定Flag, title, button); } DDFontUtils.DrawString( 550, y, "「" + title + "」 = " + setting, DDFontUtils.GetFont("Kゴシック", 50), false, キー設定Flag ? new I3Color(192, 255, 128) : new I3Color(255, 192, 128), キー設定Flag ? new I3Color(50, 100, 0) : new I3Color(100, 50, 0) ); }
private void CheckInputPadButtonKey(bool キー設定Flag, DDInput.Button targetButton) { DDInput.Button[] buttons = new DDInput.Button[] { DDInput.DIR_2, DDInput.DIR_4, DDInput.DIR_6, DDInput.DIR_8, DDInput.A, DDInput.B, DDInput.L, }; if (キー設定Flag) { int pressKeyId = -1; foreach (int keyId in DDSimpleMenu.GetAllKeyId()) { if (DDKey.GetInput(keyId) == 1) { pressKeyId = keyId; } } if (pressKeyId != -1) { // 他ボタンとの重複回避 foreach (DDInput.Button button in buttons) { button.KeyIds = button.KeyIds.Where(keyId => keyId != pressKeyId).ToArray(); } targetButton.KeyIds = targetButton.KeyIds.Concat(new int[] { pressKeyId }).ToArray(); } } else { int pressBtnId = -1; for (int padId = 0; padId < DDPad.GetPadCount(); padId++) { for (int btnId = 0; btnId < DDPad.PAD_BUTTON_MAX; btnId++) { if (DDPad.GetInput(padId, btnId) == 1) { pressBtnId = btnId; } } } if (pressBtnId != -1) { // 他ボタンとの重複回避 foreach (DDInput.Button button in buttons) { button.BtnIds = button.BtnIds.Where(btnId => btnId != pressBtnId).ToArray(); } targetButton.BtnIds = targetButton.BtnIds.Concat(new int[] { pressBtnId }).ToArray(); } } }
private void InputPadButtonKeySetting(bool キー設定Flag, string title, DDInput.Button button, Func <DDInput.Button, string> getSetting) { DDEngine.FreezeInput(); button.Backup(); if (キー設定Flag) { button.KeyIds = new int[0]; } else { button.BtnIds = new int[0]; } for (; ;) { CheckInputPadButtonKey(キー設定Flag, button); this.DrawWall(); DDDraw.DrawSimple(Ground.I.Picture.詳細設定枠, 0, 0); if (キー設定Flag) { DrawTabTitle(480, 70, "キーボードのキー設定 / 変更", true); } else { DrawTabTitle(400, 70, "ゲームパッドのボタン設定 / 変更", true); } DDFontUtils.DrawString( 100, 400, "「" + title + "」に割り当てる" + (キー設定Flag ? "キー" : "ボタン") + "を押して下さい。(複数可)", DDFontUtils.GetFont("Kゴシック", 50), false, new I3Color(255, 255, 255), new I3Color(100, 100, 0) ); DDFontUtils.DrawString( 100, 475, "入力が終わったら「決定」をクリックして下さい。", DDFontUtils.GetFont("Kゴシック", 50), false, new I3Color(255, 255, 255), new I3Color(100, 100, 0) ); DDFontUtils.DrawString( 100, 600, "現在の割り当て:" + getSetting(button), DDFontUtils.GetFont("Kゴシック", 50), false, new I3Color(255, 255, 255), new I3Color(100, 0, 100) ); bool inputDone; if (キー設定Flag) { inputDone = 1 <= button.KeyIds.Length; } else { inputDone = 1 <= button.BtnIds.Length; } this.DrawButton(1200, 950, Ground.I.Picture.SettingButton_決定, inputDone); if (this.LastButtonHoveringFlag && DDMouse.L.GetInput() == -1 && inputDone) { break; } this.DrawButton(1630, 950, Ground.I.Picture.SettingButton_キャンセル, true); if (this.LastButtonHoveringFlag && DDMouse.L.GetInput() == -1 || DDMouse.R.GetInput() == -1) { button.Restore(); break; } DDEngine.EachFrame(); } DDEngine.FreezeInput(); }
private void PrintPadButtonKeySetting(bool キー設定Flag, int padButtonIndex, string title, DDInput.Button button) { int y = 230 + padButtonIndex * 90; Func <DDInput.Button, string> getSetting; { Func <string, string> w = s => Common.FirstNotEmpty(s, "割り当てナシ"); if (キー設定Flag) { getSetting = btn => w(string.Join(" , ", btn.KeyIds.Select(keyId => DDSimpleMenu.GetKeyName(keyId)))); } else { getSetting = btn => w(string.Join(" , ", btn.BtnIds.Select(btnId => DDSimpleMenu.GetPadButtonName(btnId)))); } } this.DrawButton(300, y + 25, Ground.I.Picture.SettingButton_変更, true); if (this.LastButtonHoveringFlag && DDMouse.L.GetInput() == -1) { InputPadButtonKeySetting(キー設定Flag, title, button, getSetting); } DDFontUtils.DrawString( 550, y, "「" + title + "」 = " + getSetting(button), DDFontUtils.GetFont("Kゴシック", 50), false, キー設定Flag ? new I3Color(192, 255, 128) : new I3Color(255, 192, 128), キー設定Flag ? new I3Color(50, 100, 0) : new I3Color(100, 50, 0) ); }