📄 game.lua
字号:
end -- crazy if (allied[j]:isMarked() and enemy[j]:isMarked()) then if (ThisPlayer:IsAllied(Players[i]) == false or ThisPlayer:IsEnemy(Players[i]) == false) then SetDiplomacy(ThisPlayer.Index, "crazy", i) end end -- shared vision if (sharedvision[j]:isMarked()) then if (ThisPlayer:IsSharedVision(Players[i]) == false) then SetSharedVision(ThisPlayer.Index, true, i) end else if (ThisPlayer:IsSharedVision(Players[i])) then SetSharedVision(ThisPlayer.Index, false, i) end end end menu:stop() end) menu:addSmallButton(_("~!Cancel"), "c", 195, 384 - 40, function() menu:stop() end) menu:run(false)endfunction RunRestartConfirmMenu() RunConfirmTypeMenu( _("Are you sure you want to restart the game?"), _("~!Restart Game"), "r", GameRestart)endfunction RunQuitToMenuConfirmMenu() RunConfirmTypeMenu( _("Are you sure you want to quit to the main menu?"), _("~!Quit to Menu"), "q", GameQuitToMenu)endfunction RunEndGameMenu() local menu = BosGameMenu() menu:addLabel(_("End Game"), 128, 11) local b = menu:addButton(_("~!Restart Game"), "r", 16, 40 + (36 * 0), RunRestartConfirmMenu) if (IsNetworkGame()) then b:setEnabled(false) end menu:addButton(_("~!Surrender"), "s", 16, 40 + (36 * 1), function() RunConfirmTypeMenu( _("Are you sure you want to surrender to your enemies?"), _("~!Surrender"), "s", GameDefeat) end) menu:addButton(_("~!Quit to Menu"), "q", 16, 40 + (36 * 2), RunQuitToMenuConfirmMenu) menu:addButton(_("E~!xit Bos Wars"), "x", 16, 40 + (36 * 3), RunExitConfirmMenu) menu:addButton(_("Previous (~<Esc~>)"), "escape", 16, 248, function() menu:stop() end) menu:run(false)endfunction RunConfirmTypeMenu(boxtext, buttontext, hotkey, stopgametype) local menu = BosGameMenu() local height = 11 height = height + menu:addMultiLineLabel(boxtext, 128, 11):getHeight() menu:addButton(buttontext, hotkey, 16, height + 29, function() StopGame(stopgametype); menu:stopAll() end) menu:addButton(_("Cancel (~<Esc~>)"), "escape", 16, 248, function() menu:stop() end) menu:run(false)endfunction RunExitConfirmMenu() local menu = BosGameMenu() local height = 11 height = height + menu:addMultiLineLabel( _("Are you sure you want to exit Bos Wars?"), 128, 11):getHeight() menu:addButton(_("E~!xit Program"), "x", 16, height + 29, function() Exit(0) end) menu:addButton(_("Cancel (~<Esc~>)"), "escape", 16, 248, function() menu:stop() end) menu:run(false)endfunction RunHelpMenu() local menu = BosGameMenu() menu:addLabel(_("Help Menu"), 128, 11) menu:addButton(_("Keystroke ~!Help"), "h", 16, 40 + (36 * 0), function() RunKeystrokeHelpMenu() end) menu:addButton(_("Bos Wars ~!Tips"), "t", 16, 40 + (36 * 1), function() RunTipsMenu() end) menu:addButton(_("Previous (~<Esc~>)"), "escape", 128 - (224 / 2), 248, function() menu:stop() end) menu:run(false)endlocal keystrokes = { {"Alt-F", "- toggle full screen"}, {"Alt-G", "- toggle grab mouse"}, {"Ctrl-S", "- mute sound"}, {"Ctrl-M", "- mute music"}, {"+", "- increase game speed"}, {"-", "- decrease game speed"}, {"Ctrl-P", "- pause game"}, {"PAUSE", "- pause game"}, {"PRINT", "- make screen shot"}, {"Alt-H", "- help menu"}, {"Alt-R", "- restart game"}, {"Alt-Q", "- quit to main menu"}, {"Alt-X", "- quit game"}, {"Alt-B", "- toggle expand map"}, {"Alt-M", "- game menu"}, {"ENTER", "- write a message"}, {"SPACE", "- goto last event"}, {"TAB", "- hide/unhide terrain"}, {"Ctrl-T", "- track unit"}, {"Alt-I", "- find idle peon"}, {"Alt-C", "- center on selected unit"}, {"Alt-V", "- next view port"}, {"Ctrl-V", "- previous view port"}, {"^", "- select nothing"}, {"#", "- select group"}, {"##", "- center on group"}, {"Ctrl-#", "- define group"}, {"Shift-#", "- add to group"}, {"Alt-#", "- add to alternate group"}, {"F2-F4", "- recall map position"}, {"Shift F2-F4", "- save map postition"}, {"F5", "- game options"}, {"F7", "- sound options"}, {"F8", "- speed options"}, {"F9", "- preferences"}, {"F10", "- game menu"}, {"F11", "- save game"}, {"F12", "- load game"},}function RunKeystrokeHelpMenu() local menu = BosGameMenu() menu:setSize(352, 352) menu:setPosition((Video.Width - menu:getWidth()) / 2, (Video.Height - menu:getHeight()) / 2) local c = Container() c:setOpaque(false) for i=1,table.getn(keystrokes) do local l = Label(keystrokes[i][1]) l:setFont(Fonts["game"]) l:adjustSize() c:add(l, 0, 20 * (i - 1)) local l = Label(keystrokes[i][2]) l:setFont(Fonts["game"]) l:adjustSize() c:add(l, 80, 20 * (i - 1)) end local s = ScrollArea() c:setSize(320 - s:getScrollbarWidth(), 20 * table.getn(keystrokes)) s:setBaseColor(dark) s:setBackgroundColor(dark) s:setForegroundColor(clear) s:setSize(320, 216) s:setContent(c) menu:add(s, 16, 60) menu:addLabel(_("Keystroke Help Menu"), 352 / 2, 11) menu:addButton(_("Previous (~<Esc~>)"), "escape", (352 / 2) - (224 / 2), 352 - 40, function() menu:stop() end) menu:run(false)endlocal tips = { "You can select all of your currently visible units of the same type by holding down the CTRL key and selecting a unit or by \"double clicking\" on a unit.", "The more engineers you have collecting resources, the faster your economy will grow.", "Use your engineers to repair damaged buildings.", "Explore your surroundings early in the game.", "Keep all engineers working. Use ALT-I to find idle engineers.", "You can make units automatically perform special actions by selecting a unit, holding down CTRL and clicking on the icon. CTRL click again to turn off.", -- Shift tips "You can give an unit an order which is executed after it finishes the current work, if you hold the SHIFT key.", "You can give way points, if you press the SHIFT key, while you click right for the move command.", "You can order an engineer to build one building after the other, if you hold the SHIFT key, while you place the building.", "You can build many of the same building, if you hold the ALT and SHIFT keys while you place the buildings.", "Use CTRL-V or ALT-V to cycle through the viewport configuration, you can than monitor your base and lead an attack.", "Know a useful tip? Then add it here!",}function RunTipsMenu() local menu = BosGameMenu() menu:setSize(384, 256) menu:setPosition((Video.Width - menu:getWidth()) / 2, (Video.Height - menu:getHeight()) / 2) menu:addLabel(_("Bos Wars Tips"), 192, 11) local l = MultiLineLabel() l:setFont(Fonts["game"]) l:setSize(356, 144) l:setLineWidth(356) menu:add(l, 14, 36) function l:prevTip() preferences.TipNumber = preferences.TipNumber - 1 if (preferences.TipNumber < 1) then preferences.TipNumber = table.getn(tips) end SavePreferences() end function l:nextTip() preferences.TipNumber = preferences.TipNumber + 1 if (preferences.TipNumber > table.getn(tips)) then preferences.TipNumber = 1 end SavePreferences() end function l:updateCaption() self:setCaption(tips[preferences.TipNumber]) end if (preferences.TipNumber == 0) then l:nextTip() end l:updateCaption() local showtips = {} showtips = menu:addCheckBox(_("Show tips at startup"), 14, 256 - 75, function() preferences.ShowTips = showtips:isMarked() SavePreferences() end) showtips:setMarked(preferences.ShowTips) menu:addSmallButton(_("~!OK"), "o", 14, 256 - 40, function() l:nextTip(); menu:stop() end) menu:addSmallButton(_("~!Previous Tip"), "p", 14 + 106 + 11, 256 - 40, function() l:prevTip(); l:updateCaption() end) menu:addSmallButton(_("~!Next Tip"), "n", 14 + 106 + 11 + 106 + 11, 256 - 40, function() l:nextTip(); l:updateCaption() end) menu:run(false)endfunction RunObjectivesMenu() local menu = BosGameMenu() menu:setSize(384, 256) menu:setPosition((Video.Width - menu:getWidth()) / 2, (Video.Height - menu:getHeight()) / 2) menu:addLabel(_("Objectives"), 192, 11) local l = MultiLineLabel() l:setFont(Fonts["game"]) l:setSize(356, 144) l:setLineWidth(356) menu:add(l, 14, 36) l:setCaption(current_objective) menu:addButton(_("~!OK"), "o", 80, 256 - 40, function() menu:stop() end) menu:run(false)end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -