Apply desat effect on ingame menu too

This commit is contained in:
Paul Chote
2011-05-08 21:27:44 +12:00
parent d95138b600
commit 2e1e8fd7e8
5 changed files with 16 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ using OpenRA.Widgets;
using System.Drawing; using System.Drawing;
using System.Collections.Generic; using System.Collections.Generic;
using System; using System;
using OpenRA.Mods.RA;
namespace OpenRA.Mods.Cnc.Widgets namespace OpenRA.Mods.Cnc.Widgets
{ {
@@ -88,6 +89,8 @@ namespace OpenRA.Mods.Cnc.Widgets
[ObjectCreator.Param] Action onExit) [ObjectCreator.Param] Action onExit)
{ {
menu = widget.GetWidget("INGAME_MENU"); menu = widget.GetWidget("INGAME_MENU");
world.WorldActor.Trait<DesaturatedPaletteEffect>().Active = true;
var onQuit = (Action)(() => var onQuit = (Action)(() =>
{ {
Game.DisconnectOnly(); Game.DisconnectOnly();
@@ -109,6 +112,7 @@ namespace OpenRA.Mods.Cnc.Widgets
menu.GetWidget<CncMenuButtonWidget>("RESUME_BUTTON").OnClick = () => menu.GetWidget<CncMenuButtonWidget>("RESUME_BUTTON").OnClick = () =>
{ {
Widget.RootWidget.RemoveChild(menu); Widget.RootWidget.RemoveChild(menu);
world.WorldActor.Trait<DesaturatedPaletteEffect>().Active = false;
onExit(); onExit();
}; };
} }

View File

@@ -17,6 +17,7 @@ using System;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Mods.RA;
namespace OpenRA.Mods.Cnc.Widgets namespace OpenRA.Mods.Cnc.Widgets
{ {
@@ -32,8 +33,11 @@ namespace OpenRA.Mods.Cnc.Widgets
MenuType Menu = MenuType.Main; MenuType Menu = MenuType.Main;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CncMenuLogic([ObjectCreator.Param] Widget widget) public CncMenuLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] World world)
{ {
world.WorldActor.Trait<DesaturatedPaletteEffect>().Active = true;
// Root level menu // Root level menu
var mainMenu = widget.GetWidget("MAIN_MENU"); var mainMenu = widget.GetWidget("MAIN_MENU");
mainMenu.IsVisible = () => Menu == MenuType.Main; mainMenu.IsVisible = () => Menu == MenuType.Main;
@@ -105,7 +109,8 @@ namespace OpenRA.Mods.Cnc.Widgets
void RemoveShellmapUI() void RemoveShellmapUI()
{ {
Widget.CloseWindow(); Widget.CloseWindow();
Widget.RootWidget.RemoveChild(Widget.RootWidget.GetWidget("MENU_BACKGROUND")); var root = Widget.RootWidget.GetWidget("MENU_BACKGROUND");
root.Parent.RemoveChild(root);
} }
void OpenLobbyPanel(MenuType menu) void OpenLobbyPanel(MenuType menu)

View File

@@ -19,9 +19,12 @@ namespace OpenRA.Mods.RA
public class DesaturatedPaletteEffect : IPaletteModifier public class DesaturatedPaletteEffect : IPaletteModifier
{ {
// Doing this every frame is stupid public bool Active;
// TODO: Doing this every frame is stupid
public void AdjustPalette(Dictionary<string,Palette> palettes) public void AdjustPalette(Dictionary<string,Palette> palettes)
{ {
if (!Active) return;
var excludePalettes = new List<string>(){"cursor", "chrome", "colorpicker", "shroud", "fog"}; var excludePalettes = new List<string>(){"cursor", "chrome", "colorpicker", "shroud", "fog"};
foreach (var pal in palettes) foreach (var pal in palettes)
{ {

View File

@@ -1013,7 +1013,6 @@ Rules:
-MPStartLocations: -MPStartLocations:
-CrateSpawner: -CrateSpawner:
CncShellmapScript: CncShellmapScript:
DesaturatedPaletteEffect:
LoadWidgetAtGameStart: LoadWidgetAtGameStart:
Widget:MENU_BACKGROUND Widget:MENU_BACKGROUND
LST: LST:

View File

@@ -46,6 +46,7 @@ Player:
World: World:
LoadWidgetAtGameStart: LoadWidgetAtGameStart:
Widget: INGAME_ROOT Widget: INGAME_ROOT
DesaturatedPaletteEffect:
ScreenShaker: ScreenShaker:
NukePaletteEffect: NukePaletteEffect:
CncWaterPaletteRotation: CncWaterPaletteRotation: