Compare commits
8 Commits
b5bb79ae6b
...
8d70ced693
Author | SHA1 | Date | |
---|---|---|---|
8d70ced693 | |||
0ea6d32fa5 | |||
c0232c6b5f | |||
265ed76131 | |||
668ae8a20e | |||
b15eb6909e | |||
798cff1f6f | |||
230c7ca27d |
@ -5,6 +5,10 @@ charset = utf-8
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.py]
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
|
||||
[*.sh]
|
||||
indent_style = tab
|
||||
function_next_line = true
|
||||
|
@ -3,6 +3,7 @@
|
||||
\\.gitea/.* @Stan @Itms
|
||||
## Linting
|
||||
\\.pre-commit-config\\.yaml @Dunedan
|
||||
ruff\\.toml @Dunedan
|
||||
|
||||
## == Build & Libraries
|
||||
(build|libraries)/.* @Itms @Stan
|
||||
|
@ -30,8 +30,6 @@ repos:
|
||||
- id: ruff-format
|
||||
args:
|
||||
- --check
|
||||
- --target-version
|
||||
- py311
|
||||
exclude: ^source/tools/webservices/
|
||||
- repo: local
|
||||
hooks:
|
||||
|
@ -1219,16 +1219,28 @@ function getResourceDropsiteTooltip(template)
|
||||
});
|
||||
}
|
||||
|
||||
function showTemplateViewerOnRightClickTooltip()
|
||||
function getFocusOnLeftClickTooltip()
|
||||
{
|
||||
// Translation: Appears in a tooltip to indicate that right-clicking the corresponding GUI element will open the Template Details GUI page.
|
||||
return translate("Right-click to view more information.");
|
||||
// Translation: Appears in a tooltip to indicate that left-clicking the corresponding GUI element will center the view on the selected entity.
|
||||
return translate("Left-click to focus.");
|
||||
}
|
||||
|
||||
function showTemplateViewerOnClickTooltip()
|
||||
function getFollowOnLeftClickTooltip()
|
||||
{
|
||||
// Translation: Appears in a tooltip to indicate that left-clicking the corresponding GUI element will make the camera follow the selected unit.
|
||||
return translate("Left-click to follow.");
|
||||
}
|
||||
|
||||
function getTemplateViewerOnRightClickTooltip()
|
||||
{
|
||||
// Translation: Appears in a tooltip to indicate that right-clicking the corresponding GUI element will open the Template Details GUI page.
|
||||
return translate("Right-click for more information.");
|
||||
}
|
||||
|
||||
function getTemplateViewerOnClickTooltip()
|
||||
{
|
||||
// Translation: Appears in a tooltip to indicate that clicking the corresponding GUI element will open the Template Details GUI page.
|
||||
return translate("Click to view more information.");
|
||||
return translate("Click for more information.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ class EntityBox
|
||||
|
||||
static compileTooltip(template)
|
||||
{
|
||||
return ReferencePage.buildText(template, this.prototype.TooltipFunctions) + "\n" + showTemplateViewerOnClickTooltip();
|
||||
return ReferencePage.buildText(template, this.prototype.TooltipFunctions) + "\n" + getTemplateViewerOnClickTooltip();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@
|
||||
<!-- Background circle -->
|
||||
<object
|
||||
type="image"
|
||||
size="4 4 100%-4 100%-4"
|
||||
size="4 6 100%-4 100%-6"
|
||||
sprite="stretched:session/minimap_circle_modern.png"
|
||||
ghost="true"
|
||||
/>
|
||||
@ -24,7 +24,7 @@
|
||||
<!-- Idle Worker Button -->
|
||||
<object name="idleWorkerButton"
|
||||
type="button"
|
||||
size="100%-119 100%-120 100%-4 100%-5"
|
||||
size="100%-119 100%-121 100%-4 100%-6"
|
||||
tooltip_style="sessionToolTip"
|
||||
hotkey="selection.idleworker"
|
||||
sprite="stretched:session/minimap-idle.png"
|
||||
@ -45,7 +45,7 @@
|
||||
<!-- Diplomacy Colors Button -->
|
||||
<object name="diplomacyColorsButton"
|
||||
type="button"
|
||||
size="4 100%-120 119 100%-5"
|
||||
size="3 100%-121 118 100%-6"
|
||||
tooltip_style="sessionToolTip"
|
||||
hotkey="session.diplomacycolors"
|
||||
/>
|
||||
@ -54,7 +54,7 @@
|
||||
<object
|
||||
name="flareButton"
|
||||
type="button"
|
||||
size="3 3 118 118"
|
||||
size="2 4 117 119"
|
||||
tooltip_style="sessionToolTip"
|
||||
hotkey="session.flareactivate"
|
||||
sprite="stretched:session/minimap-flare.png"
|
||||
@ -66,7 +66,7 @@
|
||||
<!-- MiniMap -->
|
||||
<object
|
||||
name="minimap"
|
||||
size="8 8 100%-8 100%-8"
|
||||
size="8 10 100%-8 100%-10"
|
||||
type="minimap"
|
||||
mask="true"
|
||||
flare_texture_count="16"
|
||||
|
@ -479,8 +479,8 @@ EntitySelection.prototype.selectAndMoveTo = function(entityID)
|
||||
this.reset();
|
||||
this.addList([entityID]);
|
||||
|
||||
Engine.CameraMoveTo(entState.position.x, entState.position.z);
|
||||
}
|
||||
setCameraFollow(entityID);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds the formation members of a selected entities to the selection.
|
||||
|
@ -324,9 +324,17 @@ function displaySingle(entState)
|
||||
// TODO: we should require all entities to have icons
|
||||
Engine.GetGUIObjectByName("icon").sprite = template.icon ? ("stretched:session/portraits/" + template.icon) : "BackgroundBlack";
|
||||
if (template.icon)
|
||||
Engine.GetGUIObjectByName("iconBorder").onPressRight = () => {
|
||||
{
|
||||
const iconBorder = Engine.GetGUIObjectByName("iconBorder");
|
||||
|
||||
iconBorder.onPress = () => {
|
||||
setCameraFollow(entState.id);
|
||||
};
|
||||
|
||||
iconBorder.onPressRight = () => {
|
||||
showTemplateDetails(entState.template, playerState.civ);
|
||||
};
|
||||
}
|
||||
|
||||
let detailedTooltip = [
|
||||
getAttackTooltip,
|
||||
@ -357,10 +365,12 @@ function displaySingle(entState)
|
||||
getVisibleEntityClassesFormatted,
|
||||
getAurasTooltip,
|
||||
getEntityTooltip,
|
||||
getTreasureTooltip,
|
||||
showTemplateViewerOnRightClickTooltip
|
||||
getTreasureTooltip
|
||||
].map(func => func(template)));
|
||||
|
||||
const leftClickTooltip = hasClass(entState, "Unit") ? getFollowOnLeftClickTooltip() : getFocusOnLeftClickTooltip();
|
||||
iconTooltips.push(leftClickTooltip + " " + getTemplateViewerOnRightClickTooltip());
|
||||
|
||||
Engine.GetGUIObjectByName("iconBorder").tooltip = iconTooltips.filter(tip => tip).join("\n");
|
||||
|
||||
Engine.GetGUIObjectByName("detailsAreaSingle").hidden = false;
|
||||
|
@ -207,7 +207,7 @@ g_SelectionPanels.Construction = {
|
||||
getGarrisonTooltip(template),
|
||||
getTurretsTooltip(template),
|
||||
getPopulationBonusTooltip(template),
|
||||
showTemplateViewerOnRightClickTooltip(template)
|
||||
getTemplateViewerOnRightClickTooltip(template)
|
||||
);
|
||||
|
||||
|
||||
@ -578,7 +578,7 @@ g_SelectionPanels.Queue = {
|
||||
"neededSlots": queuedItem.neededSlots
|
||||
}));
|
||||
}
|
||||
tooltips.push(showTemplateViewerOnRightClickTooltip(template));
|
||||
tooltips.push(getTemplateViewerOnRightClickTooltip(template));
|
||||
data.button.tooltip = tooltips.join("\n");
|
||||
|
||||
data.countDisplay.caption = queuedItem.count > 1 ? queuedItem.count : "";
|
||||
@ -763,7 +763,7 @@ g_SelectionPanels.Research = {
|
||||
getEntityNamesFormatted,
|
||||
getEntityTooltip,
|
||||
getEntityCostTooltip,
|
||||
showTemplateViewerOnRightClickTooltip
|
||||
getTemplateViewerOnRightClickTooltip
|
||||
].map(func => func(template));
|
||||
|
||||
if (!requirementsPassed)
|
||||
@ -1058,7 +1058,7 @@ g_SelectionPanels.Training = {
|
||||
getResourceDropsiteTooltip
|
||||
].map(func => func(template)));
|
||||
|
||||
tooltips.push(showTemplateViewerOnRightClickTooltip());
|
||||
tooltips.push(getTemplateViewerOnRightClickTooltip());
|
||||
tooltips.push(
|
||||
formatBatchTrainingString(buildingsCountToTrainFullBatch, fullBatchSize, remainderBatch),
|
||||
getRequirementsTooltip(requirementsMet, template.requirements, GetSimState().players[data.player].civ),
|
||||
@ -1180,7 +1180,8 @@ g_SelectionPanels.Upgrade = {
|
||||
formatMatchLimitString(limits.matchLimit, limits.matchCount, limits.type),
|
||||
getRequirementsTooltip(requirementsMet, data.item.requirements, GetSimState().players[data.player].civ),
|
||||
getNeededResourcesTooltip(neededResources),
|
||||
showTemplateViewerOnRightClickTooltip());
|
||||
getTemplateViewerOnRightClickTooltip()
|
||||
);
|
||||
|
||||
tooltip = tooltips.filter(tip => tip).join("\n");
|
||||
|
||||
|
@ -386,14 +386,16 @@ function cancelUpgradeEntity()
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the camera to follow the given entity if it's a unit.
|
||||
* Otherwise stop following.
|
||||
* Focus the camera on the entity and follow if it's a unit.
|
||||
* If that's not possible, stop any current follow.
|
||||
*/
|
||||
function setCameraFollow(entity)
|
||||
{
|
||||
let entState = entity && GetEntityState(entity);
|
||||
const entState = entity && GetEntityState(entity);
|
||||
if (entState && hasClass(entState, "Unit"))
|
||||
Engine.CameraFollow(entity);
|
||||
else if (entState?.position)
|
||||
Engine.CameraMoveTo(entState.position.x, entState.position.z);
|
||||
else
|
||||
Engine.CameraFollow(0);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
>
|
||||
|
||||
<!-- Names and civilization emblem etc. (This must come before the attack and resistance icon to avoid clipping issues.) -->
|
||||
<object size="0 92 100% 100%" name="statsArea" type="image" sprite="edgedPanelShader">
|
||||
<object size="0 96 100% 100%" name="statsArea" type="image" sprite="edgedPanelShader">
|
||||
<!-- Civilization tooltip. -->
|
||||
<object size="0 38 100% 62" tooltip_style="sessionToolTip">
|
||||
<!-- Civilization emblem. -->
|
||||
@ -26,14 +26,14 @@
|
||||
</object>
|
||||
|
||||
<!-- Stats Bars -->
|
||||
<object size= "0 0 100% 96" type="image" tooltip_style="sessionToolTip">
|
||||
<object size= "0 0 100% 100" type="image" tooltip_style="sessionToolTip">
|
||||
|
||||
<object size="0 0 100% 60" type="image" sprite="topEdgedPanelShader">
|
||||
<object size="0 0 100% 65" type="image" sprite="topEdgedPanelShader">
|
||||
|
||||
<!-- Placeholders storing the position for the bars. -->
|
||||
<object size="96 1 100% 24" name="sectionPosTop" hidden="true"/>
|
||||
<object size="96 11 100% 34" name="sectionPosMiddle" hidden="true"/>
|
||||
<object size="96 32 100% 55" name="sectionPosBottom" hidden="true"/>
|
||||
<object size="96 2 100% 24" name="sectionPosTop" hidden="true"/>
|
||||
<object size="96 12 100% 34" name="sectionPosMiddle" hidden="true"/>
|
||||
<object size="96 35 100% 55" name="sectionPosBottom" hidden="true"/>
|
||||
|
||||
<!-- Capture bar -->
|
||||
<object name="captureSection">
|
||||
@ -78,15 +78,15 @@
|
||||
</object>
|
||||
</object>
|
||||
|
||||
<object size="0 59 100% 95" type="image" sprite="edgedPanelShader">
|
||||
<object size="0 63 100% 98" type="image" sprite="edgedPanelShader">
|
||||
<!-- Attack and Resistance -->
|
||||
<object size="96 0 128 32" name="attackAndResistanceStats" type="image" sprite="stretched:session/icons/stances/defensive.png" tooltip_style="sessionToolTipInstantly">
|
||||
<object size="97 0 129 32" name="attackAndResistanceStats" type="image" sprite="stretched:session/icons/stances/defensive.png" tooltip_style="sessionToolTipInstantly">
|
||||
<translatableAttribute id="tooltip">Attack and Resistance</translatableAttribute>
|
||||
</object>
|
||||
|
||||
<!-- Resource carrying icon/counter -->
|
||||
<!-- Used also for number of gatherers/builders -->
|
||||
<object size="100%-96 0 100%-36 32" type="text" name="resourceCarryingText" style="CarryingTextRight"/>
|
||||
<object size="100%-96 0 100%-33 32" type="text" name="resourceCarryingText" style="CarryingTextRight"/>
|
||||
<object size="100%-32 0 100% 32" type="image" name="resourceCarryingIcon" tooltip_style="sessionToolTip"/>
|
||||
</object>
|
||||
|
||||
|
@ -79,7 +79,7 @@
|
||||
<!-- Limit to the minimal supported width of 1024 pixels. -->
|
||||
<object size="50%-512 0 50%+512 100%">
|
||||
|
||||
<object size="50%-512 100%-200 50%-312 100%">
|
||||
<object size="50%-512 100%-204 50%-312 100%">
|
||||
<include file="gui/session/minimap/MiniMap.xml"/>
|
||||
</object>
|
||||
|
||||
@ -95,7 +95,7 @@
|
||||
|
||||
<!-- Selection Details Panel (middle). -->
|
||||
<object name="selectionDetails"
|
||||
size="50%-114 100%-200 50%+114 100%"
|
||||
size="50%-114 100%-204 50%+114 100%"
|
||||
sprite="selectionDetailsPanel"
|
||||
type="image"
|
||||
>
|
||||
|
12
ruff.toml
12
ruff.toml
@ -1,5 +1,7 @@
|
||||
line-length = 99
|
||||
|
||||
target-version = "py311"
|
||||
|
||||
[format]
|
||||
line-ending = "lf"
|
||||
|
||||
@ -10,36 +12,29 @@ ignore = [
|
||||
"C90",
|
||||
"COM812",
|
||||
"D10",
|
||||
"DTZ005",
|
||||
"EM",
|
||||
"FA",
|
||||
"FIX",
|
||||
"FBT",
|
||||
"ISC001",
|
||||
"N817",
|
||||
"PERF203",
|
||||
"PERF401",
|
||||
"PLR0912",
|
||||
"PLR0913",
|
||||
"PLR0915",
|
||||
"PLR2004",
|
||||
"PLW2901",
|
||||
"PT",
|
||||
"PTH",
|
||||
"RUF012",
|
||||
"S101",
|
||||
"S310",
|
||||
"S314",
|
||||
"S324",
|
||||
"S320",
|
||||
"S603",
|
||||
"S607",
|
||||
"T20",
|
||||
"TD002",
|
||||
"TD003",
|
||||
"TRY002",
|
||||
"TRY003",
|
||||
"TRY004",
|
||||
"UP038",
|
||||
"W505"
|
||||
]
|
||||
@ -52,3 +47,6 @@ max-doc-length = 72
|
||||
|
||||
[lint.pydocstyle]
|
||||
convention = "pep257"
|
||||
|
||||
[lint.pylint]
|
||||
max-args = 8
|
||||
|
1
source/tools/dist/dmgbuild-settings.py
vendored
1
source/tools/dist/dmgbuild-settings.py
vendored
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os.path
|
||||
|
||||
#
|
||||
|
@ -8,7 +8,6 @@ from json import load, loads
|
||||
from logging import INFO, WARNING, Filter, Formatter, StreamHandler, getLogger
|
||||
from pathlib import Path
|
||||
from struct import calcsize, unpack
|
||||
from typing import Dict, List, Set, Tuple
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
from scriptlib import SimulTemplateEntity, find_files
|
||||
@ -27,9 +26,9 @@ class SingleLevelFilter(Filter):
|
||||
|
||||
class CheckRefs:
|
||||
def __init__(self):
|
||||
self.files: List[Path] = []
|
||||
self.roots: List[Path] = []
|
||||
self.deps: List[Tuple[Path, Path]] = []
|
||||
self.files: list[Path] = []
|
||||
self.roots: list[Path] = []
|
||||
self.deps: list[tuple[Path, Path]] = []
|
||||
self.vfs_root = Path(__file__).resolve().parents[3] / "binaries" / "data" / "mods"
|
||||
self.supportedTextureFormats = ("dds", "png")
|
||||
self.supportedMeshesFormats = ("pmd", "dae")
|
||||
@ -794,7 +793,7 @@ class CheckRefs:
|
||||
uniq_files = {r.as_posix() for r in self.files}
|
||||
lower_case_files = {f.lower(): f for f in uniq_files}
|
||||
|
||||
missing_files: Dict[str, Set[str]] = defaultdict(set)
|
||||
missing_files: dict[str, set[str]] = defaultdict(set)
|
||||
|
||||
for parent, dep in self.deps:
|
||||
dep_str = dep.as_posix()
|
||||
|
@ -7,7 +7,6 @@ import shutil
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from subprocess import CalledProcessError, run
|
||||
from typing import Sequence
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
from scriptlib import SimulTemplateEntity, find_files
|
||||
@ -50,7 +49,7 @@ errorch.setFormatter(logging.Formatter("%(levelname)s - %(message)s"))
|
||||
logger.addHandler(errorch)
|
||||
|
||||
|
||||
def main(argv: Sequence[str] | None = None) -> int:
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="Validate templates")
|
||||
parser.add_argument("-m", "--mod-name", required=True, help="The name of the mod to validate.")
|
||||
parser.add_argument(
|
||||
@ -73,7 +72,7 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||
)
|
||||
parser.add_argument("-v", "--verbose", help="Be verbose about the output.", default=False)
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
args = parser.parse_args()
|
||||
|
||||
if not args.relaxng_schema.exists():
|
||||
logging.error(RELAXNG_SCHEMA_ERROR_MSG.format(args.relaxng_schema))
|
||||
|
@ -1,7 +1,10 @@
|
||||
# Adapted from http://cairographics.org/freetypepython/
|
||||
|
||||
# ruff: noqa: TRY002
|
||||
|
||||
import ctypes
|
||||
import sys
|
||||
from typing import ClassVar
|
||||
|
||||
import cairo
|
||||
|
||||
@ -40,7 +43,7 @@ _surface = cairo.ImageSurface(cairo.FORMAT_A8, 0, 0)
|
||||
|
||||
|
||||
class PycairoContext(ctypes.Structure):
|
||||
_fields_ = [
|
||||
_fields_: ClassVar = [
|
||||
("PyObject_HEAD", ctypes.c_byte * object.__basicsize__),
|
||||
("ctx", ctypes.c_void_p),
|
||||
("base", ctypes.c_void_p),
|
||||
|
@ -22,7 +22,6 @@ import io
|
||||
import os
|
||||
import subprocess
|
||||
from itertools import islice
|
||||
from typing import List
|
||||
|
||||
from i18n_helper import PROJECT_ROOT_DIRECTORY
|
||||
|
||||
@ -38,7 +37,7 @@ def get_diff():
|
||||
return io.StringIO(diff_process.stdout.decode("utf-8"))
|
||||
|
||||
|
||||
def check_diff(diff: io.StringIO) -> List[str]:
|
||||
def check_diff(diff: io.StringIO) -> list[str]:
|
||||
"""Check a diff of .po files for meaningful changes.
|
||||
|
||||
Run through a diff of .po files and check that some of the changes
|
||||
@ -87,7 +86,7 @@ def check_diff(diff: io.StringIO) -> List[str]:
|
||||
return list(files.difference(keep))
|
||||
|
||||
|
||||
def revert_files(files: List[str], verbose=False):
|
||||
def revert_files(files: list[str], verbose=False):
|
||||
def batched(iterable, n):
|
||||
"""Split an iterable in equally sized chunks.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""Wrapper around babel Catalog / .po handling."""
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from babel.messages.catalog import Catalog as BabelCatalog
|
||||
from babel.messages.pofile import read_po, write_po
|
||||
@ -10,7 +10,7 @@ class Catalog(BabelCatalog):
|
||||
"""Wraps a BabelCatalog for convenience."""
|
||||
|
||||
def __init__(self, *args, project=None, copyright_holder=None, **other_kwargs):
|
||||
date = datetime.now()
|
||||
date = datetime.now(tz=UTC)
|
||||
super().__init__(
|
||||
*args,
|
||||
header_comment=(
|
||||
|
@ -1,12 +1,11 @@
|
||||
"""Utils to list .po."""
|
||||
|
||||
import os
|
||||
from typing import List, Optional
|
||||
|
||||
from i18n_helper.catalog import Catalog
|
||||
|
||||
|
||||
def get_catalogs(input_file_path, filters: Optional[List[str]] = None) -> List[Catalog]:
|
||||
def get_catalogs(input_file_path, filters: list[str] | None = None) -> list[Catalog]:
|
||||
"""Return a list of "real" catalogs (.po) in the given folder."""
|
||||
existing_translation_catalogs = []
|
||||
l10n_folder_path = os.path.dirname(input_file_path)
|
||||
|
@ -97,7 +97,7 @@ PATCHES_EXPECT_REVERT = [
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture(params=zip(PATCHES, PATCHES_EXPECT_REVERT))
|
||||
@pytest.fixture(params=zip(PATCHES, PATCHES_EXPECT_REVERT, strict=False))
|
||||
def patch(request):
|
||||
return [io.StringIO(request.param[0]), request.param[1]]
|
||||
|
||||
|
@ -7,11 +7,11 @@ import zero_ad
|
||||
|
||||
|
||||
def dist(p1, p2):
|
||||
return math.sqrt(sum(math.pow(x2 - x1, 2) for (x1, x2) in zip(p1, p2)))
|
||||
return math.sqrt(sum(math.pow(x2 - x1, 2) for (x1, x2) in zip(p1, p2, strict=False)))
|
||||
|
||||
|
||||
def center(units):
|
||||
sum_position = map(sum, zip(*(u.position() for u in units)))
|
||||
sum_position = map(sum, zip(*(u.position() for u in units), strict=False))
|
||||
return [x / len(units) for x in sum_position]
|
||||
|
||||
|
||||
|
@ -11,11 +11,11 @@ with open(path.join(scriptdir, "..", "samples", "arcadia.json"), encoding="utf-8
|
||||
|
||||
|
||||
def dist(p1, p2):
|
||||
return math.sqrt(sum(math.pow(x2 - x1, 2) for (x1, x2) in zip(p1, p2)))
|
||||
return math.sqrt(sum(math.pow(x2 - x1, 2) for (x1, x2) in zip(p1, p2, strict=False)))
|
||||
|
||||
|
||||
def center(units):
|
||||
sum_position = map(sum, zip(*(u.position() for u in units)))
|
||||
sum_position = map(sum, zip(*(u.position() for u in units), strict=False))
|
||||
return [x / len(units) for x in sum_position]
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ class RLAPI:
|
||||
def get_templates(self, names):
|
||||
post_data = "\n".join(names)
|
||||
response = self.post("templates", post_data)
|
||||
return zip(names, response.decode().split("\n"))
|
||||
return zip(names, response.decode().split("\n"), strict=False)
|
||||
|
||||
def evaluate(self, code):
|
||||
response = self.post("evaluate", code)
|
||||
|
@ -17,7 +17,7 @@ class ZeroAD:
|
||||
actions = []
|
||||
player_ids = cycle([self.player_id]) if player is None else cycle(player)
|
||||
|
||||
cmds = zip(player_ids, actions)
|
||||
cmds = zip(player_ids, actions, strict=False)
|
||||
cmds = ((player, action) for (player, action) in cmds if action is not None)
|
||||
state_json = self.api.step(cmds)
|
||||
self.current_state = GameState(json.loads(state_json), self)
|
||||
|
@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- mode: python-mode; python-indent-offset: 4; -*-
|
||||
#
|
||||
# Copyright (C) 2023 Wildfire Games.
|
||||
# Copyright (C) 2024 Wildfire Games.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
@ -47,15 +46,7 @@ def execute(command):
|
||||
def calculate_hash(path):
|
||||
assert os.path.isfile(path)
|
||||
with open(path, "rb") as handle:
|
||||
return hashlib.sha1(handle.read()).hexdigest()
|
||||
|
||||
|
||||
def compare_spirv(path1, path2):
|
||||
with open(path1, "rb") as handle:
|
||||
spirv1 = handle.read()
|
||||
with open(path2, "rb") as handle:
|
||||
spirv2 = handle.read()
|
||||
return spirv1 == spirv2
|
||||
return hashlib.sha256(handle.read()).hexdigest()
|
||||
|
||||
|
||||
def resolve_if(defines, expression):
|
||||
@ -457,19 +448,10 @@ def build(rules, input_mod_path, output_mod_path, dependencies, program_name):
|
||||
|
||||
spirv_hash = calculate_hash(output_spirv_path)
|
||||
if spirv_hash not in hashed_cache:
|
||||
hashed_cache[spirv_hash] = [file_name]
|
||||
hashed_cache[spirv_hash] = file_name
|
||||
else:
|
||||
found_candidate = False
|
||||
for candidate_name in hashed_cache[spirv_hash]:
|
||||
candidate_path = os.path.join(output_spirv_mod_path, candidate_name)
|
||||
if compare_spirv(output_spirv_path, candidate_path):
|
||||
found_candidate = True
|
||||
file_name = candidate_name
|
||||
break
|
||||
if found_candidate:
|
||||
file_name = hashed_cache[spirv_hash]
|
||||
os.remove(output_spirv_path)
|
||||
else:
|
||||
hashed_cache[spirv_hash].append(file_name)
|
||||
|
||||
shader_element = ET.SubElement(program_root, shader["type"])
|
||||
shader_element.set("file", "spirv/" + file_name)
|
||||
|
@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- mode: python-mode; python-indent-offset: 4; -*-
|
||||
#
|
||||
# Copyright (C) 2023 Wildfire Games.
|
||||
# Copyright (C) 2024 Wildfire Games.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -201,7 +201,7 @@ class RelaxNGValidator:
|
||||
try:
|
||||
doc = lxml.etree.parse(str(file[1]))
|
||||
relaxng.assertValid(doc)
|
||||
except Exception:
|
||||
except (lxml.etree.DocumentInvalid, lxml.etree.XMLSyntaxError):
|
||||
error_count = error_count + 1
|
||||
self.logger.exception(file[1])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user