Add lobby options for Shroud and Fog.
This commit is contained in:
@@ -15,8 +15,8 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
public class ShroudRenderer
|
public class ShroudRenderer
|
||||||
{
|
{
|
||||||
|
World world;
|
||||||
Map map;
|
Map map;
|
||||||
ShroudInfo shroudInfo;
|
|
||||||
Sprite[] shadowBits = Game.modData.SpriteLoader.LoadAllSprites("shadow");
|
Sprite[] shadowBits = Game.modData.SpriteLoader.LoadAllSprites("shadow");
|
||||||
Sprite[,] sprites, fogSprites;
|
Sprite[,] sprites, fogSprites;
|
||||||
int shroudHash;
|
int shroudHash;
|
||||||
@@ -46,8 +46,8 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public ShroudRenderer(World world)
|
public ShroudRenderer(World world)
|
||||||
{
|
{
|
||||||
|
this.world = world;
|
||||||
this.map = world.Map;
|
this.map = world.Map;
|
||||||
shroudInfo = Rules.Info["player"].Traits.Get<ShroudInfo>();
|
|
||||||
|
|
||||||
sprites = new Sprite[map.MapSize.X, map.MapSize.Y];
|
sprites = new Sprite[map.MapSize.X, map.MapSize.Y];
|
||||||
fogSprites = new Sprite[map.MapSize.X, map.MapSize.Y];
|
fogSprites = new Sprite[map.MapSize.X, map.MapSize.Y];
|
||||||
@@ -152,9 +152,10 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
if (initializePalettes)
|
if (initializePalettes)
|
||||||
{
|
{
|
||||||
if (shroudInfo.Fog)
|
if (world.LobbyInfo.GlobalSettings.Fog)
|
||||||
fogPalette = wr.Palette("fog");
|
fogPalette = wr.Palette("fog");
|
||||||
shroudPalette = wr.Palette("shroud");
|
|
||||||
|
shroudPalette = world.LobbyInfo.GlobalSettings.Fog ? wr.Palette("shroud") : wr.Palette("shroudfog");
|
||||||
initializePalettes = false;
|
initializePalettes = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +166,7 @@ namespace OpenRA.Graphics
|
|||||||
// We draw the shroud when disabled to hide the sharp map edges
|
// We draw the shroud when disabled to hide the sharp map edges
|
||||||
DrawShroud(wr, clipRect, sprites, shroudPalette);
|
DrawShroud(wr, clipRect, sprites, shroudPalette);
|
||||||
|
|
||||||
if (shroudInfo.Fog)
|
if (world.LobbyInfo.GlobalSettings.Fog)
|
||||||
DrawShroud(wr, clipRect, fogSprites, fogPalette);
|
DrawShroud(wr, clipRect, fogSprites, fogPalette);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ namespace OpenRA.Network
|
|||||||
public bool Dedicated;
|
public bool Dedicated;
|
||||||
public string Difficulty;
|
public string Difficulty;
|
||||||
public bool Crates = true;
|
public bool Crates = true;
|
||||||
|
public bool Shroud = true;
|
||||||
|
public bool Fog = true;
|
||||||
public string StartingUnitsClass = "default";
|
public string StartingUnitsClass = "default";
|
||||||
public bool AllowVersionMismatch;
|
public bool AllowVersionMismatch;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,14 +18,11 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
public class ShroudInfo : ITraitInfo
|
public class ShroudInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public readonly bool Shroud = true;
|
public object Create(ActorInitializer init) { return new Shroud(init.self); }
|
||||||
public readonly bool Fog = true;
|
|
||||||
public object Create(ActorInitializer init) { return new Shroud(init.self, this); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Shroud
|
public class Shroud
|
||||||
{
|
{
|
||||||
public ShroudInfo Info;
|
|
||||||
Actor self;
|
Actor self;
|
||||||
Map map;
|
Map map;
|
||||||
|
|
||||||
@@ -42,9 +39,8 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public int Hash { get; private set; }
|
public int Hash { get; private set; }
|
||||||
|
|
||||||
public Shroud(Actor self, ShroudInfo info)
|
public Shroud(Actor self)
|
||||||
{
|
{
|
||||||
Info = info;
|
|
||||||
this.self = self;
|
this.self = self;
|
||||||
map = self.World.Map;
|
map = self.World.Map;
|
||||||
|
|
||||||
@@ -58,7 +54,7 @@ namespace OpenRA.Traits
|
|||||||
self.World.ActorAdded += AddShroudGeneration;
|
self.World.ActorAdded += AddShroudGeneration;
|
||||||
self.World.ActorRemoved += RemoveShroudGeneration;
|
self.World.ActorRemoved += RemoveShroudGeneration;
|
||||||
|
|
||||||
if (!info.Shroud)
|
if (!self.World.LobbyInfo.GlobalSettings.Shroud)
|
||||||
ExploredBounds = map.Bounds;
|
ExploredBounds = map.Bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,7 +248,7 @@ namespace OpenRA.Traits
|
|||||||
if (!map.IsInMap(x, y))
|
if (!map.IsInMap(x, y))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!Info.Shroud)
|
if (!self.World.LobbyInfo.GlobalSettings.Shroud)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return explored[x, y] && (generatedShroudCount[x, y] == 0 || visibleCount[x, y] > 0);
|
return explored[x, y] && (generatedShroudCount[x, y] == 0 || visibleCount[x, y] > 0);
|
||||||
@@ -271,7 +267,7 @@ namespace OpenRA.Traits
|
|||||||
if (x < 0 || x >= map.MapSize.X || y < 0 || y >= map.MapSize.Y)
|
if (x < 0 || x >= map.MapSize.X || y < 0 || y >= map.MapSize.Y)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!Info.Fog)
|
if (!self.World.LobbyInfo.GlobalSettings.Fog)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return visibleCount[x, y] > 0;
|
return visibleCount[x, y] > 0;
|
||||||
|
|||||||
@@ -326,6 +326,32 @@ namespace OpenRA.Mods.RA.Server
|
|||||||
server.SyncLobbyInfo();
|
server.SyncLobbyInfo();
|
||||||
return true;
|
return true;
|
||||||
}},
|
}},
|
||||||
|
{ "shroud",
|
||||||
|
s =>
|
||||||
|
{
|
||||||
|
if (!client.IsAdmin)
|
||||||
|
{
|
||||||
|
server.SendOrderTo(conn, "Message", "Only the host can set that option");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool.TryParse(s, out server.lobbyInfo.GlobalSettings.Shroud);
|
||||||
|
server.SyncLobbyInfo();
|
||||||
|
return true;
|
||||||
|
}},
|
||||||
|
{ "fog",
|
||||||
|
s =>
|
||||||
|
{
|
||||||
|
if (!client.IsAdmin)
|
||||||
|
{
|
||||||
|
server.SendOrderTo(conn, "Message", "Only the host can set that option");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool.TryParse(s, out server.lobbyInfo.GlobalSettings.Fog);
|
||||||
|
server.SyncLobbyInfo();
|
||||||
|
return true;
|
||||||
|
}},
|
||||||
{ "assignteams",
|
{ "assignteams",
|
||||||
s =>
|
s =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -360,6 +360,24 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
optionsBin.Get<LabelWidget>("STARTINGUNITS_DESC").IsVisible = startingUnits.IsVisible;
|
optionsBin.Get<LabelWidget>("STARTINGUNITS_DESC").IsVisible = startingUnits.IsVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var enableShroud = optionsBin.GetOrNull<CheckboxWidget>("SHROUD_CHECKBOX");
|
||||||
|
if (enableShroud != null)
|
||||||
|
{
|
||||||
|
enableShroud.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Shroud;
|
||||||
|
enableShroud.IsDisabled = configurationDisabled;
|
||||||
|
enableShroud.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||||
|
"shroud {0}".F(!orderManager.LobbyInfo.GlobalSettings.Shroud)));
|
||||||
|
};
|
||||||
|
|
||||||
|
var enableFog = optionsBin.GetOrNull<CheckboxWidget>("FOG_CHECKBOX");
|
||||||
|
if (enableFog != null)
|
||||||
|
{
|
||||||
|
enableFog.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Fog;
|
||||||
|
enableFog.IsDisabled = configurationDisabled;
|
||||||
|
enableFog.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||||
|
"fog {0}".F(!orderManager.LobbyInfo.GlobalSettings.Fog)));
|
||||||
|
};
|
||||||
|
|
||||||
var disconnectButton = lobby.Get<ButtonWidget>("DISCONNECT_BUTTON");
|
var disconnectButton = lobby.Get<ButtonWidget>("DISCONNECT_BUTTON");
|
||||||
disconnectButton.OnClick = () => { CloseWindow(); onExit(); };
|
disconnectButton.OnClick = () => { CloseWindow(); onExit(); };
|
||||||
|
|
||||||
|
|||||||
@@ -206,45 +206,57 @@ Background@LOBBY_OPTIONS_BIN:
|
|||||||
Children:
|
Children:
|
||||||
Label@TITLE:
|
Label@TITLE:
|
||||||
X:0
|
X:0
|
||||||
Y:50
|
Y:40
|
||||||
Width:PARENT_RIGHT
|
Width:PARENT_RIGHT
|
||||||
Height:25
|
Height:25
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Align:Center
|
Align:Center
|
||||||
Text: Map Options
|
Text: Map Options
|
||||||
Checkbox@ALLOWCHEATS_CHECKBOX:
|
Checkbox@ALLOWCHEATS_CHECKBOX:
|
||||||
X:150
|
X:80
|
||||||
Y:80
|
Y:75
|
||||||
Width:230
|
Width:230
|
||||||
Height:20
|
Height:20
|
||||||
Text:Enable Cheats / Debug Menu
|
Text:Cheats / Debug Menu
|
||||||
Checkbox@CRATES_CHECKBOX:
|
Checkbox@CRATES_CHECKBOX:
|
||||||
X:150
|
X:80
|
||||||
Y:110
|
Y:110
|
||||||
Width:230
|
Width:230
|
||||||
Height:20
|
Height:20
|
||||||
Text:Enable Crates
|
Text:Crates
|
||||||
|
Checkbox@SHROUD_CHECKBOX:
|
||||||
|
X:310
|
||||||
|
Y:75
|
||||||
|
Width:230
|
||||||
|
Height:20
|
||||||
|
Text:Shroud
|
||||||
|
Checkbox@FOG_CHECKBOX:
|
||||||
|
X:310
|
||||||
|
Y:110
|
||||||
|
Width:230
|
||||||
|
Height:20
|
||||||
|
Text:Fog of War
|
||||||
Label@STARTINGUNITS_DESC:
|
Label@STARTINGUNITS_DESC:
|
||||||
X:150
|
X:135
|
||||||
Y:140
|
Y:142
|
||||||
Width:120
|
Width:120
|
||||||
Height:25
|
Height:25
|
||||||
Text:Starting Units:
|
Text:Starting Units:
|
||||||
DropDownButton@STARTINGUNITS_DROPDOWNBUTTON:
|
DropDownButton@STARTINGUNITS_DROPDOWNBUTTON:
|
||||||
X:245
|
X:230
|
||||||
Y:140
|
Y:142
|
||||||
Width:140
|
Width:140
|
||||||
Height:25
|
Height:25
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Label@DIFFICULTY_DESC:
|
Label@DIFFICULTY_DESC:
|
||||||
X:150
|
X:125
|
||||||
Y:170
|
Y:177
|
||||||
Width:120
|
Width:120
|
||||||
Height:25
|
Height:25
|
||||||
Text:Mission Difficulty:
|
Text:Mission Difficulty:
|
||||||
DropDownButton@DIFFICULTY_DROPDOWNBUTTON:
|
DropDownButton@DIFFICULTY_DROPDOWNBUTTON:
|
||||||
X:265
|
X:230
|
||||||
Y:170
|
Y:177
|
||||||
Width:100
|
Width:100
|
||||||
Height:25
|
Height:25
|
||||||
Font:Bold
|
Font:Bold
|
||||||
|
|||||||
@@ -123,6 +123,8 @@ LobbyDefaults:
|
|||||||
Crates: true
|
Crates: true
|
||||||
StartingUnitsClass: default
|
StartingUnitsClass: default
|
||||||
FragileAlliances: false
|
FragileAlliances: false
|
||||||
|
Shroud: true
|
||||||
|
Fog: true
|
||||||
|
|
||||||
ChromeMetrics:
|
ChromeMetrics:
|
||||||
mods/cnc/metrics.yaml
|
mods/cnc/metrics.yaml
|
||||||
|
|||||||
@@ -264,6 +264,9 @@ World:
|
|||||||
ShroudPalette@fog:
|
ShroudPalette@fog:
|
||||||
Name: fog
|
Name: fog
|
||||||
Type: Fog
|
Type: Fog
|
||||||
|
ShroudPalette@combined:
|
||||||
|
Name: shroudfog
|
||||||
|
Type: Combined
|
||||||
Country@gdi:
|
Country@gdi:
|
||||||
Name: GDI
|
Name: GDI
|
||||||
Race: gdi
|
Race: gdi
|
||||||
|
|||||||
@@ -109,6 +109,8 @@ LobbyDefaults:
|
|||||||
Crates: true
|
Crates: true
|
||||||
StartingUnitsClass: default
|
StartingUnitsClass: default
|
||||||
FragileAlliances: false
|
FragileAlliances: false
|
||||||
|
Shroud: false
|
||||||
|
Fog: true
|
||||||
|
|
||||||
ChromeMetrics:
|
ChromeMetrics:
|
||||||
mods/d2k/metrics.yaml
|
mods/d2k/metrics.yaml
|
||||||
|
|||||||
@@ -342,6 +342,9 @@ World:
|
|||||||
ShroudPalette@fog:
|
ShroudPalette@fog:
|
||||||
Name: fog
|
Name: fog
|
||||||
Type: Fog
|
Type: Fog
|
||||||
|
ShroudPalette@combined:
|
||||||
|
Name: shroudfog
|
||||||
|
Type: Combined
|
||||||
Country@Atreides:
|
Country@Atreides:
|
||||||
Name: Atreides
|
Name: Atreides
|
||||||
Race: atreides
|
Race: atreides
|
||||||
|
|||||||
@@ -59,39 +59,63 @@ Background@LOBBY_OPTIONS_BIN:
|
|||||||
Children:
|
Children:
|
||||||
Label@TITLE:
|
Label@TITLE:
|
||||||
X:0
|
X:0
|
||||||
Y:50
|
Y:40
|
||||||
Width:PARENT_RIGHT
|
Width:PARENT_RIGHT
|
||||||
Height:25
|
Height:25
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Align:Center
|
Align:Center
|
||||||
Text: Map Options
|
Text: Map Options
|
||||||
Checkbox@ALLOWCHEATS_CHECKBOX:
|
Checkbox@ALLOWCHEATS_CHECKBOX:
|
||||||
X:150
|
X:80
|
||||||
Y:80
|
Y:75
|
||||||
Width:220
|
Width:230
|
||||||
Height:20
|
Height:20
|
||||||
Text:Enable Cheats / Debug Menu
|
Text:Cheats / Debug Menu
|
||||||
Checkbox@CRATES_CHECKBOX:
|
Checkbox@FRAGILEALLIANCES_CHECKBOX:
|
||||||
X:150
|
X:80
|
||||||
Y:110
|
Y:110
|
||||||
Width:220
|
Width:220
|
||||||
Height:20
|
Height:20
|
||||||
Text:Enable Crates
|
|
||||||
Checkbox@FRAGILEALLIANCES_CHECKBOX:
|
|
||||||
X:150
|
|
||||||
Y:140
|
|
||||||
Width:220
|
|
||||||
Height:20
|
|
||||||
Text:Allow Team Changes
|
Text:Allow Team Changes
|
||||||
|
Checkbox@CRATES_CHECKBOX:
|
||||||
|
X:80
|
||||||
|
Y:145
|
||||||
|
Width:230
|
||||||
|
Height:20
|
||||||
|
Text:Crates
|
||||||
|
Checkbox@SHROUD_CHECKBOX:
|
||||||
|
X:310
|
||||||
|
Y:75
|
||||||
|
Width:230
|
||||||
|
Height:20
|
||||||
|
Text:Shroud
|
||||||
|
Checkbox@FOG_CHECKBOX:
|
||||||
|
X:310
|
||||||
|
Y:110
|
||||||
|
Width:230
|
||||||
|
Height:20
|
||||||
|
Text:Fog of War
|
||||||
|
Label@STARTINGUNITS_DESC:
|
||||||
|
X:215
|
||||||
|
Y:142
|
||||||
|
Width:120
|
||||||
|
Height:25
|
||||||
|
Text:Starting Units:
|
||||||
|
DropDownButton@STARTINGUNITS_DROPDOWNBUTTON:
|
||||||
|
X:310
|
||||||
|
Y:142
|
||||||
|
Width:140
|
||||||
|
Height:25
|
||||||
|
Font:Bold
|
||||||
Label@DIFFICULTY_DESC:
|
Label@DIFFICULTY_DESC:
|
||||||
X:150
|
X:195
|
||||||
Y:170
|
Y:177
|
||||||
Width:120
|
Width:120
|
||||||
Height:25
|
Height:25
|
||||||
Text:Mission Difficulty:
|
Text:Mission Difficulty:
|
||||||
DropDownButton@DIFFICULTY_DROPDOWNBUTTON:
|
DropDownButton@DIFFICULTY_DROPDOWNBUTTON:
|
||||||
X:265
|
X:310
|
||||||
Y:170
|
Y:177
|
||||||
Width:100
|
Width:100
|
||||||
Height:25
|
Height:25
|
||||||
Font:Bold
|
Font:Bold
|
||||||
|
|||||||
@@ -125,6 +125,8 @@ LobbyDefaults:
|
|||||||
Crates: true
|
Crates: true
|
||||||
StartingUnitsClass: default
|
StartingUnitsClass: default
|
||||||
FragileAlliances: false
|
FragileAlliances: false
|
||||||
|
Shroud: true
|
||||||
|
Fog: true
|
||||||
|
|
||||||
ChromeMetrics:
|
ChromeMetrics:
|
||||||
mods/ra/metrics.yaml
|
mods/ra/metrics.yaml
|
||||||
|
|||||||
@@ -601,6 +601,9 @@ World:
|
|||||||
ShroudPalette@fog:
|
ShroudPalette@fog:
|
||||||
Name: fog
|
Name: fog
|
||||||
Type: Fog
|
Type: Fog
|
||||||
|
ShroudPalette@combined:
|
||||||
|
Name: shroudfog
|
||||||
|
Type: Combined
|
||||||
Country@0:
|
Country@0:
|
||||||
Name: Allies
|
Name: Allies
|
||||||
Race: allies
|
Race: allies
|
||||||
|
|||||||
@@ -148,6 +148,8 @@ LobbyDefaults:
|
|||||||
Crates: true
|
Crates: true
|
||||||
StartingUnitsClass: default
|
StartingUnitsClass: default
|
||||||
FragileAlliances: false
|
FragileAlliances: false
|
||||||
|
Shroud: true
|
||||||
|
Fog: true
|
||||||
|
|
||||||
ChromeMetrics:
|
ChromeMetrics:
|
||||||
mods/ra/metrics.yaml
|
mods/ra/metrics.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user