From 322b798413826681915eca1960f081cbc4dd302c Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Mon, 13 Oct 2008 14:14:32 +0000 Subject: Abstraction of the menus background 5 different bg types: none(fallback), colored, texture, video, and fade(for overlays) Some sideeffect is 5 mb less memory usage, don't know for which reasons :P git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1446 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/base/UThemes.pas | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'src/base/UThemes.pas') diff --git a/src/base/UThemes.pas b/src/base/UThemes.pas index 3ee2798e..e5232c17 100644 --- a/src/base/UThemes.pas +++ b/src/base/UThemes.pas @@ -51,10 +51,29 @@ type R, G, B, A: Double; end; - TThemeBackground = record - Tex: string; +TThemeBackground = record + BGType: Byte; + Color: TRGB; + Tex: string; + Alpha: Real; end; +const + BGT_Names: Array [0..4] of String = ('none', 'color', 'texture', 'video', 'fade'); + BGT_None = 0; + BGT_Color = 1; + BGT_Texture = 2; + BGT_Video = 3; + BGT_Fade = 4; + BGT_Auto = 255; + //Defaul Background for Screens w/o Theme e.g. editor + DEFAULTBACKGROUND: TThemeBackground = (BGType: BGT_Color; + Color: (R:1; G:1; B:1); + Tex: ''; + Alpha: 1.0); + + +type TThemeStatic = record X: integer; Y: integer; @@ -1468,8 +1487,25 @@ begin end; procedure TTheme.ThemeLoadBackground(var ThemeBackground: TThemeBackground; Name: string); +var + BGType: String; + I: Integer; begin - ThemeBackground.Tex := ThemeIni.ReadString(Name + 'Background', 'Tex', ''); + BGType := lowercase(ThemeIni.ReadString(Name + 'Background', 'Type', 'auto')); + + ThemeBackground.BGType := BGT_Auto; + For I := 0 to high(BGT_Names) do + If (BGT_Names[I] = BGType) then + begin + ThemeBackground.BGType := I; + Break; + end; + + ThemeBackground.Tex := ThemeIni.ReadString(Name + 'Background', 'Tex', ''); + ThemeBackground.Color.R := ThemeIni.ReadFloat(Name + 'Background', 'ColR', 1); + ThemeBackground.Color.G := ThemeIni.ReadFloat(Name + 'Background', 'ColG', 1); + ThemeBackground.Color.B := ThemeIni.ReadFloat(Name + 'Background', 'ColB', 1); + ThemeBackground.Alpha := ThemeIni.ReadFloat(Name + 'Background', 'Alpha', 1); end; procedure TTheme.ThemeLoadText(var ThemeText: TThemeText; Name: string); -- cgit v1.2.3