Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to release-20231010 #193

Merged
merged 11 commits into from
Nov 3, 2023
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
836 changes: 770 additions & 66 deletions .editorconfig

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run: |
sudo apt-get install lua5.1
make check-scripts
make test
make TREAT_WARNINGS_AS_ERRORS=true test

linux-mono:
name: Linux (mono)
Expand All @@ -59,7 +59,7 @@ jobs:
- name: Check Mod
run: |
# check-scripts does not depend on .net/mono, so is not needed here
make RUNTIME=mono test
make RUNTIME=mono TREAT_WARNINGS_AS_ERRORS=true test

windows:
name: Windows (.NET 6.0)
Expand All @@ -85,5 +85,6 @@ jobs:
run: |
choco install lua --version 5.1.5.52
$ENV:Path = $ENV:Path + ";C:\Program Files (x86)\Lua\5.1\"
$ENV:TREAT_WARNINGS_AS_ERRORS = "true"
.\make.ps1 check-scripts
.\make.ps1 test
12 changes: 5 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# to compile, run:
# make
#
# to compile using Mono (version 6.4 or greater) instead of .NET 6, run:
# to compile using Mono (version 6.12 or greater) instead of .NET 6, run:
# make RUNTIME=mono
#
# to compile using system libraries for native dependencies, run:
Expand All @@ -22,7 +22,7 @@
# make [RUNTIME=net6] check
#
# to check your mod yaml for errors, run:
# make [RUNTIME=net6] test
# make [RUNTIME=net6] [TREAT_WARNINGS_AS_ERRORS=false] test
#
# the following are internal sdk helpers that are not intended to be run directly:
# make check-variables
Expand Down Expand Up @@ -145,7 +145,7 @@ engine: check-variables check-sdk-scripts

all: engine
ifeq ($(RUNTIME), mono)
@command -v $(MSBUILD) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 6.4."; exit 1)
@command -v $(MSBUILD) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 6.12."; exit 1)
ifneq ("$(MOD_SOLUTION_FILES)","")
@find . -maxdepth 1 -name '*.sln' -exec $(MSBUILD) -t:Build -restore -p:Configuration=${CONFIGURATION} -p:TargetPlatform=$(TARGETPLATFORM) -p:Mono=true \;
endif
Expand Down Expand Up @@ -181,12 +181,10 @@ check: engine
ifneq ("$(MOD_SOLUTION_FILES)","")
@echo "Compiling in Debug mode..."
ifeq ($(RUNTIME), mono)
# Enabling EnforceCodeStyleInBuild and GenerateDocumentationFile as a workaround for some code style rules (in particular IDE0005) being bugged and not reporting warnings/errors otherwise.
@$(MSBUILD) -t:clean\;build -restore -p:Configuration=Debug -warnaserror -p:TargetPlatform=$(TARGETPLATFORM) -p:Mono=true -p:EnforceCodeStyleInBuild=true -p:GenerateDocumentationFile=true
@$(MSBUILD) -t:clean\;build -restore -p:Configuration=Debug -warnaserror -p:TargetPlatform=$(TARGETPLATFORM)
else
# Enabling EnforceCodeStyleInBuild and GenerateDocumentationFile as a workaround for some code style rules (in particular IDE0005) being bugged and not reporting warnings/errors otherwise.
@$(DOTNET) clean -c Debug --nologo --verbosity minimal
@$(DOTNET) build -c Debug -nologo -warnaserror -p:TargetPlatform=$(TARGETPLATFORM) -p:EnforceCodeStyleInBuild=true -p:GenerateDocumentationFile=true
@$(DOTNET) build -c Debug -nologo -warnaserror -p:TargetPlatform=$(TARGETPLATFORM)
endif
endif
@echo "Checking for explicit interface violations..."
Expand Down
27 changes: 19 additions & 8 deletions OpenRA.Mods.Example/Rendering/ColorPickerColorShift.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace OpenRA.Mods.Example.Rendering
public class ColorPickerColorShiftInfo : TraitInfo
{
[PaletteReference]
[FieldLoader.RequireAttribute]
[FieldLoader.Require]
[Desc("The name of the palette to base off.")]
public readonly string BasePalette = "";

Expand All @@ -37,46 +37,57 @@ public class ColorPickerColorShiftInfo : TraitInfo
[Desc("Saturation reference for the color shift.")]
public readonly float ReferenceSaturation = 1;

[Desc("Value reference for the color shift.")]
public readonly float ReferenceValue = 0.95f;

public override object Create(ActorInitializer init) { return new ColorPickerColorShift(this); }
}

public class ColorPickerColorShift : ILoadsPalettes, ITickRender
{
readonly ColorPickerColorShiftInfo info;
readonly ColorPickerManagerInfo colorManager;
Color color;
Color preferredColor;

public ColorPickerColorShift(ColorPickerColorShiftInfo info)
{
colorManager = Game.ModData.DefaultRules.Actors[SystemActors.World].TraitInfo<ColorPickerManagerInfo>();
// All users need to use the same TraitInfo instance, chosen as the default mod rules
var colorManager = Game.ModData.DefaultRules.Actors[SystemActors.World].TraitInfo<IColorPickerManagerInfo>();
colorManager.OnColorPickerColorUpdate += c => preferredColor = c;
preferredColor = Game.Settings.Player.Color;

this.info = info;
}

void ILoadsPalettes.LoadPalettes(WorldRenderer worldRenderer)
{
color = colorManager.Color;
var (_, hue, saturation, _) = color.ToAhsv();
color = preferredColor;
var (r, g, b) = color.ToLinear();
var (hue, saturation, value) = Color.RgbToHsv(r, g, b);

worldRenderer.SetPaletteColorShift(
info.BasePalette,
hue - info.ReferenceHue,
saturation - info.ReferenceSaturation,
value / info.ReferenceValue,
info.MinHue,
info.MaxHue);
}

void ITickRender.TickRender(WorldRenderer worldRenderer, Actor self)
{
if (color == colorManager.Color)
if (color == preferredColor)
return;

color = colorManager.Color;
var (_, hue, saturation, _) = color.ToAhsv();
color = preferredColor;
var (r, g, b) = color.ToLinear();
var (hue, saturation, value) = Color.RgbToHsv(r, g, b);

worldRenderer.SetPaletteColorShift(
info.BasePalette,
hue - info.ReferenceHue,
saturation - info.ReferenceSaturation,
value / info.ReferenceValue,
info.MinHue,
info.MaxHue);
}
Expand Down
9 changes: 7 additions & 2 deletions OpenRA.Mods.Example/Rendering/PlayerColorShift.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace OpenRA.Mods.Example.Rendering
public class PlayerColorShiftInfo : TraitInfo
{
[PaletteReference(true)]
[FieldLoader.RequireAttribute]
[FieldLoader.Require]
[Desc("The name of the palette to base off.")]
public readonly string BasePalette = "";

Expand All @@ -36,6 +36,9 @@ public class PlayerColorShiftInfo : TraitInfo
[Desc("Saturation reference for the color shift.")]
public readonly float ReferenceSaturation = 1;

[Desc("Value reference for the color shift.")]
public readonly float ReferenceValue = 0.95f;

public override object Create(ActorInitializer init) { return new PlayerColorShift(this); }
}

Expand All @@ -50,12 +53,14 @@ public PlayerColorShift(PlayerColorShiftInfo info)

void ILoadsPlayerPalettes.LoadPlayerPalettes(WorldRenderer worldRenderer, string playerName, Color color, bool replaceExisting)
{
var (_, hue, saturation, _) = color.ToAhsv();
var (r, g, b) = color.ToLinear();
var (hue, saturation, value) = Color.RgbToHsv(r, g, b);

worldRenderer.SetPaletteColorShift(
info.BasePalette + playerName,
hue - info.ReferenceHue,
saturation - info.ReferenceSaturation,
value - info.ReferenceValue,
info.MinHue,
info.MaxHue);
}
Expand Down
5 changes: 3 additions & 2 deletions launch-dedicated.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@echo on

set Name="Dedicated Server"
set Map=""
set ListenPort=1234
set AdvertiseOnline=True
set Password=""
Expand All @@ -18,7 +19,7 @@ set EnableGeoIP=True
set EnableLintChecks=True
set ShareAnonymizedIPs=True

set JoinChatDelay=5000
set FloodLimitJoinCooldown=5000

@echo off
setlocal EnableDelayedExpansion
Expand All @@ -37,7 +38,7 @@ if not exist %ENGINE_DIRECTORY%\bin\OpenRA.exe goto noengine
cd %ENGINE_DIRECTORY%

:loop
bin\OpenRA.Server.exe Game.Mod=%MOD_ID% Engine.EngineDir=".." Server.Name=%Name% Server.ListenPort=%ListenPort% Server.AdvertiseOnline=%AdvertiseOnline% Server.EnableSingleplayer=%EnableSingleplayer% Server.Password=%Password% Server.RequireAuthentication=%RequireAuthentication% Server.RecordReplays=%RecordReplays% Server.ProfileIDBlacklist=%ProfileIDBlacklist% Server.ProfileIDWhitelist=%ProfileIDWhitelist% Server.EnableSyncReports=%EnableSyncReports% Server.EnableGeoIP=%EnableGeoIP% Server.ShareAnonymizedIPs=%ShareAnonymizedIPs% Server.EnableLintChecks=%EnableLintChecks% Engine.SupportDir=%SupportDir% Server.JoinChatDelay=%JoinChatDelay%
bin\OpenRA.Server.exe Game.Mod=%MOD_ID% Engine.EngineDir=".." Server.Name=%Name% Server.Map=%Map% Server.ListenPort=%ListenPort% Server.AdvertiseOnline=%AdvertiseOnline% Server.EnableSingleplayer=%EnableSingleplayer% Server.Password=%Password% Server.RequireAuthentication=%RequireAuthentication% Server.RecordReplays=%RecordReplays% Server.ProfileIDBlacklist=%ProfileIDBlacklist% Server.ProfileIDWhitelist=%ProfileIDWhitelist% Server.EnableSyncReports=%EnableSyncReports% Server.EnableGeoIP=%EnableGeoIP% Server.ShareAnonymizedIPs=%ShareAnonymizedIPs% Server.EnableLintChecks=%EnableLintChecks% Engine.SupportDir=%SupportDir% Server.FloodLimitJoinCooldown=%FloodLimitJoinCooldown%
goto loop

:noengine
Expand Down
6 changes: 4 additions & 2 deletions launch-dedicated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ fi

NAME="${Name:-"Dedicated Server"}"
LAUNCH_MOD="${Mod:-"${MOD_ID}"}"
MAP="${Map:-""}"
LISTEN_PORT="${ListenPort:-"1234"}"
ADVERTISE_ONLINE="${AdvertiseOnline:-"True"}"
PASSWORD="${Password:-""}"
Expand All @@ -65,7 +66,7 @@ ENABLE_GEOIP="${EnableGeoIP:-"True"}"
ENABLE_LINT_CHECKS="${EnableLintChecks:-"True"}"
SHARE_ANONYMISED_IPS="${ShareAnonymizedIPs:-"True"}"

JOIN_CHAT_DELAY="${JoinChatDelay:-"5000"}"
FLOOD_LIMIT_JOIN_COOLDOWN="${FloodLimitJoinCooldown:-"5000"}"

SUPPORT_DIR="${SupportDir:-""}"

Expand All @@ -82,6 +83,7 @@ while true; do
MOD_SEARCH_PATHS="${MOD_SEARCH_PATHS}" \
${RUNTIME_LAUNCHER} bin/OpenRA.Server.dll Engine.EngineDir=".." Game.Mod="${LAUNCH_MOD}" \
Server.Name="${NAME}" \
Server.Map="${MAP}" \
Server.ListenPort="${LISTEN_PORT}" \
Server.AdvertiseOnline="${ADVERTISE_ONLINE}" \
Server.Password="${PASSWORD}" \
Expand All @@ -94,6 +96,6 @@ while true; do
Server.EnableGeoIP="${ENABLE_GEOIP}" \
Server.EnableLintChecks="${ENABLE_LINT_CHECKS}" \
Server.ShareAnonymizedIPs="${SHARE_ANONYMISED_IPS}" \
Server.JoinChatDelay="${JOIN_CHAT_DELAY}" \
Server.FloodLimitJoinCooldown="${FLOOD_LIMIT_JOIN_COOLDOWN}" \
Engine.SupportDir="${SUPPORT_DIR}"
done
4 changes: 2 additions & 2 deletions make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ function Check-Command

Write-Host "Compiling $modID in Debug configuration..." -ForegroundColor Cyan

# Enabling EnforceCodeStyleInBuild and GenerateDocumentationFile as a workaround for some code style rules (in particular IDE0005) being bugged and not reporting warnings/errors otherwise.
dotnet clean -c Debug --nologo --verbosity minimal
dotnet build -c Debug --nologo -warnaserror -p:TargetPlatform=win-x64 -p:EnforceCodeStyleInBuild=true -p:GenerateDocumentationFile=true
dotnet build -c Debug --nologo -warnaserror -p:TargetPlatform=win-x64

if ($lastexitcode -ne 0)
{
Write-Host "Build failed." -ForegroundColor Red
Expand Down
2 changes: 1 addition & 1 deletion mod.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
MOD_ID="example"

# The OpenRA engine version to use for this project.
ENGINE_VERSION="release-20230225"
ENGINE_VERSION="release-20231010"

##############################################################################
# Packaging
Expand Down
Loading