Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Binary file removed bitmaps/gpl/jet2.bmp
Binary file not shown.
2 changes: 2 additions & 0 deletions common/configs/keybind_catalog.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"action": { "type": "string", "description": "Bind command (command + space-separated args), exactly as passed to /bind and reported by GetKeyBindings." },
"label": { "type": "string", "description": "i18n key for the display label." },
"description": { "type": "string", "description": "i18n key for a sentence saying what the action does, for a tooltip. Optional: without one a surface may fall back to the command card's tooltip (commands.<name>_tooltip) or the engine's command description (cmd.<command>)." },
"icon": { "type": "string", "description": "VFS path of a picture for the action, drawn on its key in the keyboard overview and wherever else a surface has room for one. Optional: without one an order shows the cursor it is already known by, and anything else shows no picture." },
"alwaysModifier": { "type": "string", "enum": ["any", "shift"], "description": "Modifier this action always tolerates, so a surface neither shows it nor lets the player pick it. \"any\" binds with the engine's Any+ qualifier and fires whatever is held. \"shift\" has no engine equivalent, so the binding is written twice, bare and Shift+, and both halves move together. Fixed per action rather than chosen." }
}
},
Expand All @@ -63,6 +64,7 @@
"label": { "type": "string", "description": "i18n key for the display label, interpolated per matched action." },
"unit": { "type": "boolean", "description": "When true, the arg after the prefix is a unit codename resolved to its translated human name." },
"members": { "type": "array", "items": { "type": "string" }, "description": "The args this family covers, appended to the prefix to form each action. Listing them makes the rows exist whether or not anything is bound, so unbinding one leaves it there to bind again. Omit for families that cannot be enumerated (buildunit_ is per unit) and they are discovered from what is bound." },
"icon": { "type": "string", "description": "VFS path of a picture shared by every action in the family, drawn on its key in the keyboard overview. Optional." },
"alwaysModifier": { "type": "string", "enum": ["any"], "description": "Modifier this action always tolerates, so a surface neither shows it nor lets the player pick it. \"any\" binds with the engine's Any+ qualifier and fires whatever is held. Fixed per action rather than chosen." }
}
}
Expand Down
4 changes: 4 additions & 0 deletions common/configs/keybind_defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{
"name": "Grid",
"description": "ui.keybinds.presets.grid",
"fakeMeta": "space",
"binds": [
{
"keyset": "esc",
Expand Down Expand Up @@ -1339,6 +1340,7 @@
{
"name": "Grid (60% Keyboard)",
"description": "ui.keybinds.presets.grid60",
"fakeMeta": "space",
"binds": [
{
"keyset": "esc",
Expand Down Expand Up @@ -2585,6 +2587,7 @@
{
"name": "Legacy",
"description": "ui.keybinds.presets.legacy",
"fakeMeta": "space",
"binds": [
{
"keyset": "esc",
Expand Down Expand Up @@ -4371,6 +4374,7 @@
{
"name": "Legacy (60% Keyboard)",
"description": "ui.keybinds.presets.legacy60",
"fakeMeta": "space",
"binds": [
{
"keyset": "esc",
Expand Down
2 changes: 1 addition & 1 deletion common/configs/keybind_defaults.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"fakeMeta": {
"type": "string",
"description": "Key to treat as the Meta modifier, if the profile wants one."
"description": "Key to treat as the Meta modifier. A keycode, never a scancode, which the engine refuses here. Leave it out to get the engine's own, which is space; set \"none\" for a profile that wants no Meta modifier at all."
},
"binds": {
"type": "array",
Expand Down
24 changes: 17 additions & 7 deletions common/configs/keybinds.README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ surface shows it or lets the player pick it:
- `"shift"` has no engine equivalent, so the binding is written twice, bare and `Shift+`,
and both halves move together. Such an action holds exactly one key, not a list.

An entry, action or prefix, may carry `"icon"`: the VFS path of a picture for the action,
drawn on its key in the editor's keyboard overview (and wherever else a surface has room for
one). Without one, an order shows the cursor it is already known by in game, and anything
else shows no picture; the field exists so actions can be given pictures as art for them is
made, without any surface changing.

A category may carry `"layout": "grid"`, drawn as the grid menu's own 3x4 arrangement rather
than a flat list so the keys read the way they sit on screen.

Expand Down Expand Up @@ -111,11 +117,13 @@ shape as the shipped ones plus an `active` field naming the selected profile. Th
is per-install rather than shared, but its format is the contract - a surface that can
read one can read the other.

A player's profile carries `basedOn`, the name of the shipped profile it descends from:
A player's profile carries `basedOn`, the name of the profile it is compared with:
recorded when it was forked or duplicated, and otherwise (imported, or made before the
field existed, or naming a profile that no longer ships) inferred on load as the shipped
field existed, or naming a profile that no longer exists) inferred on load as the shipped
profile it differs from on the fewest actions, and written back. That is what lets a
surface say which keys the player changed and what the default was.
surface say which keys the player changed and what the default was. The player can point
it at any other profile, shipped or their own, or at `"none"`, which means no comparison
and is the one value loading leaves alone rather than replacing with a guess.

A shipped profile may carry `description`, an i18n key for a sentence saying what the
profile is for, shown wherever a surface lets the player pick one.
Expand All @@ -127,10 +135,12 @@ the clipboard and what Import reads back, and the same text a player would put i

- **Which profile are we on?** Read `active` from the player's profile store. If it names
nothing that exists in either file, fall back to the first shipped profile.
- **Apply a profile.** Write its binds out as `bind <keyset> <action>` lines (plus a
leading `fakemeta <key>` if it has one), point the engine config string `KeybindingFile`
at that file, and reload. Reloading clears the keymap first, which is why a profile has
to define every binding it wants.
- **Apply a profile.** Write its binds out as `bind <keyset> <action>` lines with a leading
`fakemeta <key>`, point the engine config string `KeybindingFile` at that file, and
reload. Reloading clears the keymap first, which is why a profile has to define every
binding it wants. It does not clear the meta key, so always write that line: leave it out
and whatever the last profile set stays. A profile naming no key wants the engine's own,
`space`; `fakemeta none` asks for no Meta modifier at all.
- **Edit a binding.** Only in the player's own profiles. Shipped profiles are read-only,
so the first edit made while one is selected forks it into a copy and edits that.
- **Create / rename / delete.** Names are the identity, so they must stay unique across
Expand Down
23 changes: 23 additions & 0 deletions language/en/interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
"allCategories": "All",
"search": "Search actions or keys...",
"boundTo": "Bound to %{keys}",
"boundToAny": "Also fires on this key with any modifier held",
"preset": "Preset",
"defaultTag": "Default",
"pressKey": "Press a key or mouse button...",
Expand All @@ -259,6 +260,12 @@
"noticeUnsaved": "Unsaved changes (Ctrl+Z undoes the last edit).",
"changed": "Changed",
"changedCount": "Changed (%{n})",
"changedUnknown": "Changed (?)",
"changedNoneTooltip": "No preset is being compared with. Pick one in this section to list the actions whose keys differ from it.",
"compareWith": "Compare with",
"compareNone": "None",
"compareNoneHint": "Pick a preset to compare with. The actions whose keys differ from it are listed here, each with the key it has there.",
"changedNothing": "No keys differ from %{name}.",
"changedTooltip": "Every action whose keys differ from %{name}. Restore default keybinds by clicking the button containing the defualt keybind on the right.",
"conflict": "%{keys} is also bound to: %{actions}",
"conflictFirst": "%{action} (tried first)",
Expand All @@ -278,6 +285,8 @@
"exportDone": "\"%{name}\" is on the clipboard. Paste it anywhere to share or keep it; Import reads it back in.",
"import": "Import",
"importTooltip": "Read a preset from text on the clipboard and add it as a new preset.",
"keyboard": "Keyboard",
"keyboardTooltip": "Show this preset's keybinds laid out on a keyboard. Click Shift, Ctrl, Alt or Meta on it to see what the keys do with that held; click again for the list.",
"importTitle": "Import preset",
"importEmpty": "The clipboard is empty. Copy a preset's text first, then try again.",
"importSummary": "%{n} keybinds found",
Expand All @@ -298,6 +307,20 @@
"accept": "Accept",
"cancel": "Cancel"
},
"keyboard": {
"layerBase": "No modifier held",
"layer": "%{mods} held",
"hint": "Click Shift, Ctrl, Alt or Meta to see what the keys do with it held, or hold it. Click a key to list its actions.",
"notShown": "%{n} keybinds sit on keys neither keyboard draws.",
"numpad": "Numpad",
"numpadTooltip": "Show the arrow keys, the navigation keys and the number pad. Click again for the main keys.",
"unbound": "Nothing bound",
"anyModifier": "with any modifier",
"paired": "with or without Shift",
"clickKey": "Click to list everything on this key.",
"clickModifier": "Click to show what the keys do with %{mod} held.",
"clickModifierOff": "Click to stop showing the keys with %{mod} held."
},
"presets": {
"grid": "Builds through the grid menu: QWER, ASDF and ZXCV pick a slot in the build grid, so the same key builds the same slot for every builder. Orders sit on the keys around them.",
"grid60": "The Grid preset for keyboards without a function row: map views, camera anchors and the other F-key actions move to Meta + number, and what sat on ` moves to Meta + Q.",
Expand Down
59 changes: 45 additions & 14 deletions luarules/gadgets/cus_gl4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@

-- Indicates whether the first round of getting units should grab all instead of delta
local manualReload = autoReload.enabled or false
local printfPass = "forward" -- Chose which pass to print debug information for. Can be any of "forward", "shadow", "deferred", "reflection"
local printfMaterial = "unit"
local debugmode = false
local perfdebug = false

Expand Down Expand Up @@ -681,11 +683,9 @@

local LuaShader = gl.LuaShader

local engineUniformBufferDefs = LuaShader.GetEngineUniformBufferDefs()

local QUATERNIONDEFS = ""
if Engine.FeatureSupport.transformsInGL4 then
QUATERNIONDEFS = LuaShader.GetQuaternionDefs()

Check warning on line 688 in luarules/gadgets/cus_gl4.lua

View workflow job for this annotation

GitHub Actions / emmylua_check

need-check-nil

LuaShader may be nil

Check warning on line 688 in luarules/gadgets/cus_gl4.lua

View workflow job for this annotation

GitHub Actions / emmylua_check

call-non-callable

Cannot call expression of type `never`.
end

local defaultMaterialTemplate
Expand Down Expand Up @@ -838,7 +838,7 @@
Spring.Echo(src)
end

local function CompileLuaShader(shader, definitions, plugIns, addName, recompilation)
local function CompileLuaShader(shader, definitions, plugIns, addName, recompilation, stripPrintf)
--Spring.Echo(" CompileLuaShader",shader, definitions, plugIns, addName)
if definitions == nil or definitions == {} then
Spring.Echo(addName, "nul definitions", definitions)
Expand All @@ -857,9 +857,6 @@
-- First the default default defs
shader.definitions = table.concat(definitions, "\n") .. "\n"

-- Then the engineUniformBufferDefs (see LuaShader.lua)
shader.definitions = shader.definitions .. engineUniformBufferDefs

--// insert small pieces of code named `plugins`
--// this way we can use a basic shader and add some simple vertex animations etc.
do
Expand All @@ -884,9 +881,22 @@
end
end

local luaShader = LuaShader(shader, "CUS_" .. addName)
local compilationResult = luaShader:Initialize()
if compilationResult ~= true then
local function CompleteSource(source)
return source and (shader.definitions .. source)
end

local luaShader = LuaShader.CheckShaderUpdates({

Check warning on line 888 in luarules/gadgets/cus_gl4.lua

View workflow job for this annotation

GitHub Actions / emmylua_check

need-check-nil

LuaShader may be nil

Check warning on line 888 in luarules/gadgets/cus_gl4.lua

View workflow job for this annotation

GitHub Actions / emmylua_check

call-non-callable

Cannot call expression of type `never`.
vsSrc = CompleteSource(shader.vertex),
fsSrc = CompleteSource(shader.fragment),
gsSrc = CompleteSource(shader.geometry),
shaderConfig = { stripPrintf = stripPrintf },
shaderName = "CUS_" .. addName,
uniformInt = shader.uniformInt,
uniformFloat = shader.uniformFloat,
forceupdate = true,
silent = true,
}, 0)
if not luaShader then
Spring.Echo("Custom Unit Shaders. " .. addName .. " shader compilation failed")
--dumpShaderCodeToInfolog(shader.definitions, shader.vertex, "vs" .. addName)
--dumpShaderCodeToInfolog(shader.definitions, shader.fragment, "fs" .. addName)
Expand All @@ -896,7 +906,8 @@
return nil
end

return (compilationResult and luaShader) or nil
luaShader.ignoreUnkUniform = false
return luaShader
end

-- {shaderName : {textureUnit : true}}: the texture units the shadow pass has to bind for a
Expand All @@ -912,28 +923,32 @@
template.shaderDefinitions,
template.shaderPlugins,
name .. "_forward",
recompilation
recompilation,
printfPass ~= "forward" or printfMaterial ~= name
)
local shadowShader = CompileLuaShader(
template.shadow,
template.shadowDefinitions,
template.shaderPlugins,
name .. "_shadow",
recompilation
recompilation,
printfPass ~= "shadow" or printfMaterial ~= name
)
local deferredShader = CompileLuaShader(
template.deferred,
template.deferredDefinitions,
template.shaderPlugins,
name .. "_deferred",
recompilation
recompilation,
printfPass ~= "deferred" or printfMaterial ~= name
)
local reflectionShader = CompileLuaShader(
template.reflection,
template.reflectionDefinitions,
template.shaderPlugins,
name .. "_reflection",
recompilation
recompilation,
printfPass ~= "reflection" or printfMaterial ~= name
)
if recompilation then
if (not forwardShader) or not shadowShader or not deferredShader or not reflectionShader then
Expand Down Expand Up @@ -2456,7 +2471,7 @@
tracy.ZoneBeginN("G:CUS:ExecuteDrawPass:VAOSubmit")
end
texAndObj.VAO:Submit()
if detailedTracy then

Check warning on line 2474 in luarules/gadgets/cus_gl4.lua

View workflow job for this annotation

GitHub Actions / emmylua_check

unnecessary-if

Unnecessary `if` statement: this condition is always truthy
tracy.ZoneEnd()
end
end
Expand Down Expand Up @@ -3204,3 +3219,19 @@
local batches, units = ExecuteDrawPass(16)
tracy.ZoneEnd()
end

if autoReload.enabled then

Check warning on line 3223 in luarules/gadgets/cus_gl4.lua

View workflow job for this annotation

GitHub Actions / emmylua_check

unnecessary-if

Impossible `if` statement: this condition is always falsy
function gadget:DrawScreen()
--Spring.Echo("DrawScreen Called")
local yoffset = 0
for drawflag, drawpass in pairs(shaders) do

Check failure on line 3227 in luarules/gadgets/cus_gl4.lua

View workflow job for this annotation

GitHub Actions / stylua

Not formatted

2 line(s) would change. Run stylua 2.5.2 on this file and commit the result.
for binname, shader in pairs(drawpass) do
--Spring.Echo("DrawScreen:", drawflag, binname, "has drawprintf", shader.DrawPrintf ~= nil)
if shader.DrawPrintf then
shader.DrawPrintf(0, yoffset)

Check warning on line 3231 in luarules/gadgets/cus_gl4.lua

View workflow job for this annotation

GitHub Actions / emmylua_check

param-type-mismatch

expected `LuaShader?` but found `0`.
yoffset = yoffset + 24
end
end
end
end
end
Loading
Loading