diff --git a/interface/MapView.qml b/interface/MapView.qml index e1376993ad..e7c2be75e5 100644 --- a/interface/MapView.qml +++ b/interface/MapView.qml @@ -298,6 +298,11 @@ Item { preferences_dialog.open() } break + case Qt.Key_F9: + if (!wyrmgus.map_editor.running) { + diplomacy_dialog.open() + } + break default: break } diff --git a/interface/dialogs/GameMenuDialog.qml b/interface/dialogs/GameMenuDialog.qml index cdcb706da0..7429f187ee 100644 --- a/interface/dialogs/GameMenuDialog.qml +++ b/interface/dialogs/GameMenuDialog.qml @@ -19,7 +19,6 @@ DialogBase { onClicked: { options_dialog.open() - game_menu_dialog.opacity = 0 } } diff --git a/interface/dialogs/OptionsDialog.qml b/interface/dialogs/OptionsDialog.qml index 3f0e2da7d8..83eaa29e70 100644 --- a/interface/dialogs/OptionsDialog.qml +++ b/interface/dialogs/OptionsDialog.qml @@ -45,8 +45,7 @@ DialogBase { interface_style: options_dialog.interface_style onClicked: { - wyrmgus.call_lua_command("RunDiplomacyMenu();") - options_dialog.opacity = 0 + diplomacy_dialog.open() } } @@ -61,7 +60,6 @@ DialogBase { onClicked: { options_dialog.close() - game_menu_dialog.opacity = 1 } } } diff --git a/readme.txt b/readme.txt index 3c5ed89898..7e64bb719d 100644 --- a/readme.txt +++ b/readme.txt @@ -79,6 +79,7 @@ https://github.com/Andrettin/Wyrmsun - Fixed issue which caused dropdowns to gain keyboard focus when clicked. - Fixed issue which caused text fields to not lose keyboard focus when clicked away from. - Fixed issue which caused key events to be propagated to buttons even though a text field had focus. +- Reworked the in-game menu to be QML-based. ----------------------------------------------------------------------- - 5.0.1 diff --git a/scripts/commands.lua b/scripts/commands.lua index 559448bcfb..cbd35a0aae 100644 --- a/scripts/commands.lua +++ b/scripts/commands.lua @@ -1,13 +1,3 @@ -local function HandleIngameCommandKey(key, ctrl, alt, shift) - if (key == "f9") then - if (not IsNetworkGame()) then SetGamePaused(true) end - RunDiplomacyMenu() - else - return false - end - return true -end - local function HandleIneditorCommandKey(key, ctrl, alt, shift) if (key == "f5") then -- Map property RunEditorMapProperties() @@ -24,11 +14,11 @@ local function HandleIneditorCommandKey(key, ctrl, alt, shift) end function HandlewarCommandKey(key, ctrl, alt, shift) - if (CEditor:get():is_running() == false) then - return HandleIngameCommandKey(key, ctrl, alt, shift) - else - return HandleIneditorCommandKey(key, ctrl, alt, shift) - end + if (CEditor:get():is_running()) then + return HandleIneditorCommandKey(key, ctrl, alt, shift) + else + return false + end end HandleCommandKey = HandlewarCommandKey diff --git a/scripts/guichan.lua b/scripts/guichan.lua index f4c1286f1b..fffc976eea 100644 --- a/scripts/guichan.lua +++ b/scripts/guichan.lua @@ -578,7 +578,6 @@ Load("scripts/menus/editor.lua") Load("scripts/menus/game.lua") Load("scripts/menus/help.lua") Load("scripts/menus/objectives.lua") -Load("scripts/menus/diplomacy.lua") Load("scripts/menus/results.lua") Load("scripts/menus/network.lua") Load("scripts/menus/mods.lua") diff --git a/scripts/menus/diplomacy.lua b/scripts/menus/diplomacy.lua deleted file mode 100644 index dc50703921..0000000000 --- a/scripts/menus/diplomacy.lua +++ /dev/null @@ -1,116 +0,0 @@ -function RunDiplomacyMenu() - local menu = WarGameMenu(panel(5)) - menu:resize(352 * get_scale_factor(), 352 * get_scale_factor()) - - menu:addLabel(_("Diplomacy"), 176 * get_scale_factor(), 11 * get_scale_factor()) - - menu:addLabel(_("Allied"), 152 * get_scale_factor(), 30 * get_scale_factor(), Fonts["game"]) - menu:addLabel(_("Enemy"), 212 * get_scale_factor(), 30 * get_scale_factor(), Fonts["game"]) - menu:addLabel(_("Shared Vision"), 286 * get_scale_factor(), 30 * get_scale_factor(), Fonts["game"]) - - local allied = {} - local enemy = {} - local sharedvision = {} - local j = 0 - - for i=0,(PlayerMax - 2) do - if (GetPlayerData(i, "Type") ~= PlayerNobody and GetPlayerData(i, "RaceName") ~= "neutral" and GetThisPlayer() ~= i and GetPlayerData(GetThisPlayer(), "HasContactWith", i)) then - j = j + 1 - - local l = Label(_(GetPlayerData(i, "Name"))) - l:setFont(Fonts["game"]) - l:adjustSize() - menu:add(l, 16 * get_scale_factor(), ((18 * j) + 32) * get_scale_factor()) - - -- FIXME: disable checkboxes in replays or if on the same team - - local alliedcb = {} - local enemycb = {} - local sharedvisioncb = {} - - alliedcb = menu:addImageCheckBox("", 142 * get_scale_factor(), ((18 * j) + 32) * get_scale_factor(), - function() - if (alliedcb:isMarked() and enemycb:isMarked()) then - enemycb:setMarked(false) - end - end) - alliedcb:setMarked(GetPlayerData(GetThisPlayer(), "IsAllied", i)) - allied[j] = alliedcb - allied[j].index = i - - enemycb = menu:addImageCheckBox("", 202 * get_scale_factor(), ((18 * j) + 32) * get_scale_factor(), - function() - if (alliedcb:isMarked() and enemycb:isMarked()) then - alliedcb:setMarked(false) - end - end) - enemycb:setMarked(GetPlayerData(GetThisPlayer(), "IsEnemy", i)) - enemy[j] = enemycb - - sharedvisioncb = menu:addImageCheckBox("", 276 * get_scale_factor(), ((18 * j) + 32) * get_scale_factor(), - function() end) - sharedvisioncb:setMarked(GetPlayerData(GetThisPlayer(), "HasSharedVisionWith", i)) - sharedvision[j] = sharedvisioncb - end - end - - menu:addHalfButton(_("~!OK"), "o", 75 * get_scale_factor(), (352 - 40) * get_scale_factor(), - function() - for j=1,table.getn(allied) do - local i = allied[j].index - - -- allies - if (allied[j]:isMarked() and enemy[j]:isMarked() == false) then - if (GetPlayerData(GetThisPlayer(), "IsAllied", i) == false or - GetPlayerData(GetThisPlayer(), "IsEnemy", i)) then - SetDiplomacy(GetThisPlayer(), "allied", i) - end - end - - -- enemies - if (allied[j]:isMarked() == false and enemy[j]:isMarked()) then - if (GetPlayerData(GetThisPlayer(), "IsAllied", i) or GetPlayerData(GetThisPlayer(), "IsEnemy", i) == false) then - SetDiplomacy(GetThisPlayer(), "enemy", i) - if (GetPlayerData(i, "Type") == PlayerComputer and GetPlayerData(i, "IsEnemy", GetThisPlayer()) == false) then - SetDiplomacy(i, "enemy", GetThisPlayer()) -- Andrettin: this is added so that when the human player decides to attack computer players, computer players become enemies of the human player as well - if (GetPlayerData(i, "Type") == PlayerComputer and GetPlayerData(i, "HasSharedVisionWith", GetThisPlayer())) then - SetSharedVision(i, false, GetThisPlayer()) - end - end - end - end - - -- neutral - if (allied[j]:isMarked() == false and enemy[j]:isMarked() == false) then - if (GetPlayerData(GetThisPlayer(), "IsAllied", i) or - GetPlayerData(GetThisPlayer(), "IsEnemy", i)) then - SetDiplomacy(GetThisPlayer(), "neutral", i) - end - end - - -- crazy - if (allied[j]:isMarked() and enemy[j]:isMarked()) then - if (GetPlayerData(GetThisPlayer(), "IsAllied", i) == false or - GetPlayerData(GetThisPlayer(), "IsEnemy", i) == false) then - SetDiplomacy(GetThisPlayer(), "crazy", i) - end - end - - -- shared vision - if (sharedvision[j]:isMarked()) then - if (GetPlayerData(GetThisPlayer(), "HasSharedVisionWith", i) == false) then - SetSharedVision(GetThisPlayer(), true, i) - end - else - if (GetPlayerData(GetThisPlayer(), "HasSharedVisionWith", i)) then - SetSharedVision(GetThisPlayer(), false, i) - end - end - end - menu:stop() - end) - menu:addHalfButton(_("~!Cancel"), "c", 195 * get_scale_factor(), (352 - 40) * get_scale_factor(), function() menu:stop() end) - - menu:run(false) -end -