diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-07-23 12:34:07 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-07-23 12:34:07 +0000 |
commit | 94cefdb78044e0f9996e3032de34b690de98b708 (patch) | |
tree | b858a502ed5f12a02e18c2299e045eb0a757a8b7 /unicode/src/menu | |
parent | d1538b5a15a47b54a53e42d1cc7117780ffafd43 (diff) | |
download | usdx-94cefdb78044e0f9996e3032de34b690de98b708.tar.gz usdx-94cefdb78044e0f9996e3032de34b690de98b708.tar.xz usdx-94cefdb78044e0f9996e3032de34b690de98b708.zip |
- revert to 1777
- Ocean.ini and SVN properties are not reverted
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@1854 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'unicode/src/menu')
-rw-r--r-- | unicode/src/menu/UDisplay.pas | 294 | ||||
-rw-r--r-- | unicode/src/menu/UMenu.pas | 373 | ||||
-rw-r--r-- | unicode/src/menu/UMenuBackgroundFade.pas | 20 | ||||
-rw-r--r-- | unicode/src/menu/UMenuButton.pas | 74 | ||||
-rw-r--r-- | unicode/src/menu/UMenuButtonCollection.pas | 32 | ||||
-rw-r--r-- | unicode/src/menu/UMenuEqualizer.pas | 145 | ||||
-rw-r--r-- | unicode/src/menu/UMenuInteract.pas | 4 | ||||
-rw-r--r-- | unicode/src/menu/UMenuSelectSlide.pas | 272 | ||||
-rw-r--r-- | unicode/src/menu/UMenuStatic.pas | 11 | ||||
-rw-r--r-- | unicode/src/menu/UMenuText.pas | 173 |
10 files changed, 488 insertions, 910 deletions
diff --git a/unicode/src/menu/UDisplay.pas b/unicode/src/menu/UDisplay.pas index f2eb2ced..3e653183 100644 --- a/unicode/src/menu/UDisplay.pas +++ b/unicode/src/menu/UDisplay.pas @@ -45,71 +45,43 @@ type TDisplay = class private //fade-to-black-hack - BlackScreen: boolean; + BlackScreen: Boolean; - FadeEnabled: boolean; // true if fading is enabled - FadeFailed: boolean; // true if fading is possible (enough memory, etc.) - FadeState: integer; // fading state, 0 means that the fade texture must be initialized - LastFadeTime: cardinal; // last fade update time + FadeEnabled: Boolean; // true if fading is enabled + FadeFailed: Boolean; // true if fading is possible (enough memory, etc.) + FadeState: integer; // fading state, 0 means that the fade texture must be initialized + LastFadeTime: Cardinal; // last fade update time - FadeTex: array[1..2] of GLuint; - - FPSCounter: cardinal; - LastFPS: cardinal; - NextFPSSwap: cardinal; + FadeTex: array[1..2] of GLuint; - OSD_LastError: string; + FPSCounter : Cardinal; + LastFPS : Cardinal; + NextFPSSwap : Cardinal; - { software cursor data } - Cursor_X: double; - Cursor_Y: double; - Cursor_Pressed: boolean; - Cursor_HiddenByScreen: boolean; // hides software cursor and deactivate auto fade in - - // used for cursor fade out when there is no movement - Cursor_Visible: boolean; - Cursor_LastMove: cardinal; - Cursor_Fade: boolean; + OSD_LastError : String; procedure DrawDebugInformation; public - NextScreen: PMenu; - CurrentScreen: PMenu; + NextScreen : PMenu; + CurrentScreen : PMenu; //popup data NextScreenWithCheck: Pmenu; - CheckOK: boolean; + CheckOK : Boolean; // FIXME: Fade is set to 0 in UMain and other files but not used here anymore. - Fade: real; + Fade : Real; constructor Create; destructor Destroy; override; procedure SaveScreenShot; - function Draw: boolean; - - { sets SDL_ShowCursor depending on options set in Ini } - procedure SetCursor; - - { called when cursor moves, positioning of software cursor } - procedure MoveCursor(X, Y: double; Pressed: boolean); - - - { draws software cursor } - procedure DrawCursor; + function Draw: Boolean; end; var - Display: TDisplay; - -const - { constants for software cursor effects - time in milliseconds } - Cursor_FadeIn_Time = 500; // seconds the fade in effect lasts - Cursor_FadeOut_Time = 2000; // seconds the fade out effect lasts - Cursor_AutoHide_Time = 5000; // seconds until auto fade out starts if there is no mouse movement + Display: TDisplay; implementation @@ -132,15 +104,15 @@ begin inherited Create; //popup hack - CheckOK := false; + CheckOK := False; NextScreen := nil; NextScreenWithCheck := nil; - BlackScreen := false; + BlackScreen := False; // fade mod - FadeState := 0; + FadeState := 0; FadeEnabled := (Ini.ScreenFade = 1); - FadeFailed := false; + FadeFailed:= false; glGenTextures(2, @FadeTex); @@ -153,15 +125,6 @@ begin //Set LastError for OSD to No Error OSD_LastError := 'No Errors'; - - // software cursor default values - Cursor_LastMove := 0; - Cursor_Visible := false; - Cursor_Pressed := false; - Cursor_X := -1; - Cursor_Y := -1; - Cursor_Fade := false; - Cursor_HiddenByScreen := true; end; destructor TDisplay.Destroy; @@ -170,14 +133,14 @@ begin inherited Destroy; end; -function TDisplay.Draw: boolean; +function TDisplay.Draw: Boolean; var - S: integer; - FadeStateSquare: real; - currentTime: cardinal; - glError: glEnum; + S: integer; + FadeStateSquare: Real; + currentTime: Cardinal; + glError: glEnum; begin - Result := true; + Result := True; //We don't need this here anymore, //Because the background care about cleaning the buffers @@ -203,12 +166,12 @@ begin begin NextScreen := NextScreenWithCheck; NextScreenWithCheck := nil; - CheckOk := false; + CheckOk := False; end else begin // on end of game fade to black before exit - BlackScreen := true; + BlackScreen := True; end; end; @@ -225,16 +188,16 @@ begin // fade mod FadeState := 0; if ((Ini.ScreenFade = 1) and (not FadeFailed)) then - FadeEnabled := true + FadeEnabled := True else if (Ini.ScreenFade = 0) then - FadeEnabled := false; + FadeEnabled := False; end else begin // disable fading if initialization failed if (FadeEnabled and FadeFailed) then begin - FadeEnabled := false; + FadeEnabled := False; end; if (FadeEnabled and not FadeFailed) then @@ -312,7 +275,7 @@ begin glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); end -// blackscreen hack + // blackscreen hack else if not BlackScreen then begin NextScreen.OnShow; @@ -323,7 +286,7 @@ begin // fade out complete... FadeState := 0; CurrentScreen.onHide; - CurrentScreen.ShowFinish := false; + CurrentScreen.ShowFinish := False; CurrentScreen := NextScreen; NextScreen := nil; if not BlackScreen then @@ -333,172 +296,16 @@ begin end else begin - Result := false; + Result := False; Break; end; end; end; // if -// Draw OSD only on first Screen if Debug Mode is enabled + //Draw OSD only on first Screen if Debug Mode is enabled if ((Ini.Debug = 1) or (Params.Debug)) and (S = 1) then DrawDebugInformation; end; // for - - if not BlackScreen then - DrawCursor; -end; - -{ sets SDL_ShowCursor depending on options set in Ini } -procedure TDisplay.SetCursor; -var - Cursor: Integer; -begin - Cursor := 0; - - if (CurrentScreen <> @ScreenSing) or (Cursor_HiddenByScreen) then - begin // hide cursor on singscreen - if (Ini.Mouse = 0) and (Ini.FullScreen = 0) then - // show sdl (os) cursor in window mode even when mouse support is off - Cursor := 1 - else if (Ini.Mouse = 1) then - // show sdl (os) cursor when hardware cursor is selected - Cursor := 1; - - if (Ini.Mouse <> 2) then - Cursor_HiddenByScreen := false; - end - else if (Ini.Mouse <> 2) then - Cursor_HiddenByScreen := true; - - - SDL_ShowCursor(Cursor); - - if (Ini.Mouse = 2) then - begin - if Cursor_HiddenByScreen then - begin - // show software cursor - Cursor_HiddenByScreen := false; - Cursor_Visible := false; - Cursor_Fade := false; - end - else if (CurrentScreen = @ScreenSing) then - begin - // hide software cursor in singscreen - Cursor_HiddenByScreen := true; - Cursor_Visible := false; - Cursor_Fade := false; - end; - end; -end; - -{ called when cursor moves, positioning of software cursor } -procedure TDisplay.MoveCursor(X, Y: double; Pressed: boolean); -var - Ticks: cardinal; -begin - if (Ini.Mouse = 2) and - ((X <> Cursor_X) or (Y <> Cursor_Y) or (Pressed <> Cursor_Pressed)) then - begin - Cursor_X := X; - Cursor_Y := Y; - Cursor_Pressed := Pressed; - - Ticks := SDL_GetTicks; - - { fade in on movement (or button press) if not first movement } - if (not Cursor_Visible) and (Cursor_LastMove <> 0) then - begin - if Cursor_Fade then // we use a trick here to consider progress of fade out - Cursor_LastMove := Ticks - round(Cursor_FadeIn_Time * (1 - (Ticks - Cursor_LastMove)/Cursor_FadeOut_Time)) - else - Cursor_LastMove := Ticks; - - Cursor_Visible := true; - Cursor_Fade := true; - end - else if not Cursor_Fade then - begin - Cursor_LastMove := Ticks; - end; - end; -end; - -{ draws software cursor } -procedure TDisplay.DrawCursor; -var - Alpha: single; - Ticks: cardinal; -begin - if (Ini.Mouse = 2) then - begin // draw software cursor - Ticks := SDL_GetTicks; - - if (Cursor_Visible) and (Cursor_LastMove + Cursor_AutoHide_Time <= Ticks) then - begin // start fade out after 5 secs w/o activity - Cursor_Visible := false; - Cursor_LastMove := Ticks; - Cursor_Fade := true; - end; - - // fading - if Cursor_Fade then - begin - if Cursor_Visible then - begin // fade in - if (Cursor_LastMove + Cursor_FadeIn_Time <= Ticks) then - Cursor_Fade := false - else - Alpha := sin((Ticks - Cursor_LastMove) * 0.5 * pi / Cursor_FadeIn_Time) * 0.7; - end - else - begin //fade out - if (Cursor_LastMove + Cursor_FadeOut_Time <= Ticks) then - Cursor_Fade := false - else - Alpha := cos((Ticks - Cursor_LastMove) * 0.5 * pi / Cursor_FadeOut_Time) * 0.7; - end; - end; - - // no else if here because we may turn off fade in if block - if not Cursor_Fade then - begin - if Cursor_Visible then - Alpha := 0.7 // alpha when cursor visible and not fading - else - Alpha := 0; // alpha when cursor is hidden - end; - - if (Alpha > 0) and (not Cursor_HiddenByScreen) then - begin - glColor4f(1, 1, 1, Alpha); - glEnable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - glDisable(GL_DEPTH_TEST); - - if (Cursor_Pressed) and (Tex_Cursor_Pressed.TexNum > 0) then - glBindTexture(GL_TEXTURE_2D, Tex_Cursor_Pressed.TexNum) - else - glBindTexture(GL_TEXTURE_2D, Tex_Cursor_Unpressed.TexNum); - - glBegin(GL_QUADS); - glTexCoord2f(0, 0); - glVertex2f(Cursor_X, Cursor_Y); - - glTexCoord2f(0, 1); - glVertex2f(Cursor_X, Cursor_Y + 32); - - glTexCoord2f(1, 1); - glVertex2f(Cursor_X + 32, Cursor_Y + 32); - - glTexCoord2f(1, 0); - glVertex2f(Cursor_X + 32, Cursor_Y); - glEnd; - - glDisable(GL_BLEND); - glDisable(GL_TEXTURE_2D); - end; - end; end; procedure TDisplay.SaveScreenShot; @@ -511,7 +318,7 @@ var Align: integer; RowSize: integer; begin -// Exit if Screenshot-path does not exist or read-only + // Exit if Screenshot-path does not exist or read-only if (ScreenshotsPath = '') then Exit; @@ -525,9 +332,9 @@ begin break end; -// we must take the row-alignment (4byte by default) into account + // we must take the row-alignment (4byte by default) into account glGetIntegerv(GL_PACK_ALIGNMENT, @Align); -// calc aligned row-size + // calc aligned row-size RowSize := ((ScreenW*3 + (Align-1)) div Align) * Align; GetMem(ScreenData, RowSize * ScreenH); @@ -540,8 +347,8 @@ begin ScreenData, ScreenW, ScreenH, 24, RowSize, $0000FF, $00FF00, $FF0000, 0); -// Success := WriteJPGImage(FileName, Surface, 95); -// Success := WriteBMPImage(FileName, Surface); + //Success := WriteJPGImage(FileName, Surface, 95); + //Success := WriteBMPImage(FileName, Surface); Success := WritePNGImage(FileName, Surface); if Success then ScreenPopupError.ShowPopup('Screenshot saved: ' + ExtractFileName(FileName)) @@ -553,13 +360,12 @@ begin end; //------------ -// DrawDebugInformation - procedure draw fps and some other informations on screen +// DrawDebugInformation - Procedure draw FPS and some other Informations on Screen //------------ procedure TDisplay.DrawDebugInformation; -var - Ticks: cardinal; +var Ticks: Cardinal; begin -// Some White Background for information + //Some White Background for information glEnable(GL_BLEND); glDisable(GL_TEXTURE_2D); glColor4f(1, 1, 1, 0.5); @@ -571,13 +377,13 @@ begin glEnd; glDisable(GL_BLEND); -// set font specs + //Set Font Specs SetFontStyle(0); SetFontSize(21); - SetFontItalic(false); + SetFontItalic(False); glColor4f(0, 0, 0, 1); -// calculate fps + //Calculate FPS Ticks := SDL_GetTicks(); if (Ticks >= NextFPSSwap) then begin @@ -588,17 +394,17 @@ begin Inc(FPSCounter); -// draw text + //Draw Text -// fps + //FPS SetFontPos(695, 0); glPrint ('FPS: ' + InttoStr(LastFPS)); -// rspeed + //RSpeed SetFontPos(695, 13); glPrint ('RSpeed: ' + InttoStr(Round(1000 * TimeMid))); -// lasterror + //LastError SetFontPos(695, 26); glColor4f(1, 0, 0, 1); glPrint (OSD_LastError); diff --git a/unicode/src/menu/UMenu.pas b/unicode/src/menu/UMenu.pas index 444bac62..6d9fba96 100644 --- a/unicode/src/menu/UMenu.pas +++ b/unicode/src/menu/UMenu.pas @@ -34,20 +34,19 @@ interface {$I switches.inc} uses - SysUtils, - Math, gl, - SDL, - UMenuBackground, - UMenuButton, - UMenuButtonCollection, - UMenuInteract, - UMenuSelectSlide, + SysUtils, + UTexture, UMenuStatic, UMenuText, - UMusic, - UTexture, - UThemes; + UMenuButton, + UMenuSelectSlide, + UMenuInteract, + UMenuBackground, + UThemes, + UMenuButtonCollection, + Math, + UMusic; type { Int16 = SmallInt;} @@ -55,15 +54,15 @@ type PMenu = ^TMenu; TMenu = class protected - Background: TMenuBackground; - - Interactions: array of TInteract; - SelInteraction: integer; + Background: TMenuBackground; - ButtonPos: integer; - Button: array of TButton; + Interactions: array of TInteract; + SelInteraction: integer; - SelectsS: array of TSelectSlide; + ButtonPos: integer; + Button: array of TButton; + + SelectsS: array of TSelectSlide; ButtonCollection: array of TButtonCollection; public Text: array of TText; @@ -73,7 +72,6 @@ type Fade: integer; // fade type ShowFinish: boolean; // true if there is no fade - RightMbESC: boolean; // true to simulate ESC keypress when RMB is pressed destructor Destroy; override; constructor Create; overload; virtual; @@ -82,10 +80,10 @@ type // interaction procedure AddInteraction(Typ, Num: integer); - procedure SetInteraction(Num: integer); virtual; + procedure SetInteraction(Num: integer); property Interaction: integer read SelInteraction write SetInteraction; - // procedure load bg, texts, statics and button collections from themebasic + //Procedure Load BG, Texts, Statics and Button Collections from ThemeBasic procedure LoadFromTheme(const ThemeBasic: TThemeBasic); procedure PrepareButtonCollections(const Collections: AThemeButtonCollection); @@ -111,7 +109,7 @@ type function AddText(X, Y, W: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; const Text_: UTF8String; Reflection_: boolean; ReflectionSpacing_: real; Z : real): integer; overload; // button - procedure SetButtonLength(Length: cardinal); //Function that Set Length of Button Array in one Step instead of register new Memory for every Button + Procedure SetButtonLength(Length: cardinal); //Function that Set Length of Button Array in one Step instead of register new Memory for every Button function AddButton(ThemeButton: TThemeButton): integer; overload; function AddButton(X, Y, W, H: real; const Name: string): integer; overload; function AddButton(X, Y, W, H: real; const Name: string; Typ: TTextureType; Reflection: boolean): integer; overload; @@ -145,10 +143,9 @@ type function DrawFG: boolean; virtual; function Draw: boolean; virtual; function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown : boolean): boolean; virtual; - function ParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: integer): boolean; virtual; - function InRegion(X1, Y1, W, H, X, Y: real): boolean; - function InteractAt(X, Y: real): integer; - function CollectionAt(X, Y: real): integer; + // FIXME: ParseMouse is not implemented in any subclass and not even used anywhere in the code + // -> do this before activation of this method + //function ParseMouse(Typ: integer; X: integer; Y: integer): boolean; virtual; abstract; procedure onShow; virtual; procedure onShowFinish; virtual; procedure onHide; virtual; @@ -168,16 +165,13 @@ type end; const - MENU_MDOWN = 8; - MENU_MUP = 0; - - pmMove = 1; - pmClick = 2; + pmMove = 1; + pmClick = 2; pmUnClick = 3; - iButton = 0; // interaction type - iText = 2; - iSelectS = 3; + iButton = 0; // interaction type + iText = 2; + iSelectS = 3; iBCollectionChild = 5; // fBlack = 0; // fade type @@ -185,22 +179,21 @@ const implementation -uses - UCommon, - UCovers, - UDisplay, - UDrawTexture, - UGraphic, - ULog, - UMain, - USkins, - UTime, - //Background types - UMenuBackgroundNone, - UMenuBackgroundColor, - UMenuBackgroundTexture, - UMenuBackgroundVideo, - UMenuBackgroundFade; +uses UCommon, + ULog, + UMain, + UDrawTexture, + UGraphic, + UDisplay, + UCovers, + UTime, + USkins, + //Background types + UMenuBackgroundNone, + UMenuBackgroundColor, + UMenuBackgroundTexture, + UMenuBackgroundVideo, + UMenuBackgroundFade; destructor TMenu.Destroy; begin @@ -225,8 +218,6 @@ begin ButtonPos := -1; Background := nil; - - RightMbESC := true; end; { constructor TMenu.Create(Back: string); @@ -258,7 +249,7 @@ begin BackH := H; end; } -function RGBFloatToInt(R, G, B: double): cardinal; +function RGBFloatToInt(R, G, B: Double): cardinal; begin Result := (Trunc(255 * R) shl 16) or (Trunc(255 * G) shl 8) or @@ -297,8 +288,8 @@ begin begin Button[OldNum].Selected := false; - // deselect collection if next button is not from collection - if (NewTyp <> iButton) or (Button[NewNum].Parent <> Button[OldNum].Parent) then + //Deselect Collection if Next Button is Not from Collection + if (NewTyp <> iButton) Or (Button[NewNum].Parent <> Button[OldNum].Parent) then ButtonCollection[Button[OldNum].Parent-1].Selected := false; end; end; @@ -346,9 +337,8 @@ procedure TMenu.AddBackground(ThemedSettings: TThemeBackground); var FileExt: string; - function IsInArray(const Piece: string; const A: array of string): boolean; - var - I: integer; + Function IsInArray(const Piece: string; const A: array of string): boolean; + var I: integer; begin Result := false; @@ -360,7 +350,7 @@ procedure TMenu.AddBackground(ThemedSettings: TThemeBackground); end; end; - function TryBGCreate(Typ: cMenuBackground): boolean; + Function TryBGCreate(Typ: cMenuBackground): boolean; begin Result := true; @@ -382,7 +372,7 @@ begin Background := nil; end; - case ThemedSettings.BGType of + Case ThemedSettings.BGType of bgtAuto: begin //Automaticly choose one out of BGT_Texture, BGT_Video or BGT_Color if (Length(ThemedSettings.Tex) > 0) then @@ -499,7 +489,7 @@ end; //---------------------- procedure TMenu.AddButtonCollection(const ThemeCollection: TThemeButtonCollection; const Num: byte); var - BT, BTLen: integer; + BT, BTLen: integer; TempCol, TempDCol: cardinal; begin @@ -602,25 +592,17 @@ begin Result := AddStatic(X, Y, W, H, Name, TEXTURE_TYPE_PLAIN); end; -function TMenu.AddStatic(X, Y, W, H: real; - ColR, ColG, ColB: real; - const Name: string; - Typ: TTextureType): integer; +function TMenu.AddStatic(X, Y, W, H: real; ColR, ColG, ColB: real; const Name: string; Typ: TTextureType): integer; begin Result := AddStatic(X, Y, W, H, ColR, ColG, ColB, Name, Typ, $FFFFFF); end; -function TMenu.AddStatic(X, Y, W, H, Z: real; - ColR, ColG, ColB: real; - const Name: string; - Typ: TTextureType): integer; +function TMenu.AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; const Name: string; Typ: TTextureType): integer; begin Result := AddStatic(X, Y, W, H, Z, ColR, ColG, ColB, Name, Typ, $FFFFFF); end; -function TMenu.AddStatic(X, Y, W, H: real; - const Name: string; - Typ: TTextureType): integer; +function TMenu.AddStatic(X, Y, W, H: real; const Name: string; Typ: TTextureType): integer; var StatNum: integer; begin @@ -638,32 +620,17 @@ begin Result := StatNum; end; -function TMenu.AddStatic(X, Y, W, H: real; - ColR, ColG, ColB: real; - const Name: string; - Typ: TTextureType; - Color: integer): integer; +function TMenu.AddStatic(X, Y, W, H: real; ColR, ColG, ColB: real; const Name: string; Typ: TTextureType; Color: integer): integer; begin Result := AddStatic(X, Y, W, H, 0, ColR, ColG, ColB, Name, Typ, Color); end; -function TMenu.AddStatic(X, Y, W, H, Z: real; - ColR, ColG, ColB: real; - const Name: string; - Typ: TTextureType; - Color: integer): integer; +function TMenu.AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; const Name: string; Typ: TTextureType; Color: integer): integer; begin Result := AddStatic(X, Y, W, H, Z, ColR, ColG, ColB, 0, 0, 1, 1, Name, Typ, Color, false, 0); end; -function TMenu.AddStatic(X, Y, W, H, Z: real; - ColR, ColG, ColB: real; - TexX1, TexY1, TexX2, TexY2: real; - const Name: string; - Typ: TTextureType; - Color: integer; - Reflection: boolean; - ReflectionSpacing: real): integer; +function TMenu.AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; TexX1, TexY1, TexX2, TexY2: real; const Name: string; Typ: TTextureType; Color: integer; Reflection: boolean; ReflectionSpacing: real): integer; var StatNum: integer; begin @@ -681,22 +648,12 @@ begin begin Static[StatNum] := TStatic.Create(Texture.GetTexture(Name, Typ, Color)); // new skin end; - + // configures static Static[StatNum].Texture.X := X; Static[StatNum].Texture.Y := Y; - - //Set height and width via sprite size if omitted - if(H = 0) then - Static[StatNum].Texture.H := Static[StatNum].Texture.H - else - Static[StatNum].Texture.H := H; - - if(W = 0) then - Static[StatNum].Texture.W := Static[StatNum].Texture.W - else - Static[StatNum].Texture.W := W; - + Static[StatNum].Texture.W := W; + Static[StatNum].Texture.H := H; Static[StatNum].Texture.Z := Z; if (Typ <> TEXTURE_TYPE_COLORIZED) then begin @@ -735,22 +692,12 @@ begin Result := TextNum; end; -function TMenu.AddText(X, Y: real; - Style: integer; - Size, ColR, ColG, ColB: real - ; const Text: UTF8String): integer; +function TMenu.AddText(X, Y: real; Style: integer; Size, ColR, ColG, ColB: real; const Text: UTF8String): integer; begin Result := AddText(X, Y, 0, Style, Size, ColR, ColG, ColB, 0, Text, false, 0, 0); end; -function TMenu.AddText(X, Y, W: real; - Style: integer; - Size, ColR, ColG, ColB: real; - Align: integer; - const Text_: UTF8String; - Reflection_: boolean; - ReflectionSpacing_: real; - Z : real): integer; +function TMenu.AddText(X, Y, W: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; const Text_: UTF8String; Reflection_: boolean; ReflectionSpacing_: real; Z : real): integer; var TextNum: integer; begin @@ -762,9 +709,9 @@ begin end; //Function that Set Length of Button boolean in one Step instead of register new Memory for every Button -procedure TMenu.SetButtonLength(Length: cardinal); +Procedure TMenu.SetButtonLength(Length: cardinal); begin - if (ButtonPos = -1) and (Length > 0) then + if (ButtonPos = -1) AND (Length > 0) then begin //Set Length of Button SetLength(Button, Length); @@ -820,10 +767,10 @@ begin ThemeButton.Text[BT].Text); end; - // bautton collection mod + //BAutton Collection Mod if (ThemeButton.Parent <> 0) then begin - // if collection exists then change interaction to child button + //If Collection Exists then Change Interaction to Child Button if (@ButtonCollection[ThemeButton.Parent-1] <> nil) then begin Interactions[High(Interactions)].Typ := iBCollectionChild; @@ -852,10 +799,8 @@ begin end; function TMenu.AddButton(X, Y, W, H, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt: real; - const Name: string; - Typ: TTextureType; - Reflection: boolean; - ReflectionSpacing, DeSelectReflectionSpacing: real): integer; + const Name: string; Typ: TTextureType; + Reflection: boolean; ReflectionSpacing, DeSelectReflectionSpacing: real): integer; begin // adds button //SetLength is used once to reduce Memory usement @@ -908,7 +853,7 @@ begin Button[Result].Reflectionspacing := ReflectionSpacing; Button[Result].DeSelectReflectionspacing := DeSelectReflectionSpacing; - // button collection mod + //Button Collection Mod Button[Result].Parent := 0; // adds interaction @@ -921,10 +866,11 @@ begin Setlength(Button, 0); end; -// method to draw our tmenu and all his child buttons +// Method to draw our TMenu and all his child buttons function TMenu.DrawBG: boolean; begin Background.Draw; + Result := true; end; @@ -972,9 +918,9 @@ end; } { -function TMenu.AddWidget(X, Y: UInt16; WidgetSrc: PSDL_Surface): Int16; +function TMenu.AddWidget(X, Y : UInt16; WidgetSrc : PSDL_Surface): Int16; var - WidgetNum: Int16; + WidgetNum : Int16; begin if (Assigned(WidgetSrc)) then begin @@ -998,9 +944,9 @@ end; } { -procedure TMenu.ClearWidgets(MinNumber: Int16); +procedure TMenu.ClearWidgets(MinNumber : Int16); var - J: Int16; + J : Int16; begin for J := MinNumber to (Length(WidgetsSrc) - 1) do begin @@ -1043,10 +989,9 @@ begin Int := Int - ceil(Length(Interactions) / 2); //Set Interaction - if ((Int < 0) or (Int > Length(Interactions) - 1)) then - Int := Interaction // invalid button, keep current one - else - Interaction := Int; // select row above + if ((Int < 0) or (Int > Length(Interactions) - 1)) + then Int := Interaction //nonvalid button, keep current one + else Interaction := Int; //select row above end; procedure TMenu.InteractNextRow; @@ -1058,10 +1003,9 @@ begin Int := Int + ceil(Length(Interactions) / 2); //Set Interaction - if ((Int < 0) or (Int > Length(Interactions) - 1)) then - Int := Interaction // invalid button, keep current one - else - Interaction := Int; // select row above + if ((Int < 0) or (Int > Length(Interactions) - 1)) + then Int := Interaction //nonvalid button, keep current one + else Interaction := Int; //select row above end; procedure TMenu.InteractNext; @@ -1075,8 +1019,7 @@ begin Int := (Int + 1) mod Length(Interactions); //If no Interaction is Selectable Simply Select Next - if (Int = Interaction) then - Break; + if (Int = Interaction) then Break; until IsSelectable(Int); @@ -1093,12 +1036,10 @@ begin // change interaction as long as it's needed repeat Int := Int - 1; - if Int = -1 then - Int := High(Interactions); + if Int = -1 then Int := High(Interactions); //If no Interaction is Selectable Simply Select Next - if (Int = Interaction) then - Break; + if (Int = Interaction) then Break; until IsSelectable(Int); //Set Interaction @@ -1123,8 +1064,7 @@ begin while (Again = true) do begin Num := SelInteraction - CustomSwitch; - if Num = -1 then - Num := High(Interactions); + if Num = -1 then Num := High(Interactions); Interaction := Num; Again := false; // reset, default to accept changing interaction @@ -1268,9 +1208,6 @@ begin SelectsS[High(SelectsS)].Texture.Z := ThemeSelectS.Z; SelectsS[High(SelectsS)].TextureSBG.Z := ThemeSelectS.Z; - SelectsS[High(SelectsS)].showArrows := ThemeSelectS.showArrows; - SelectsS[High(SelectsS)].oneItemOnly := ThemeSelectS.oneItemOnly; - //Generate Lines SelectsS[High(SelectsS)].GenLines; @@ -1313,21 +1250,9 @@ begin SelectsS[S].TextureSBG := Texture.GetTexture(SBGName, SBGTyp, RGBFloatToInt(SBGColR, SBGColG, SBGColB)) else SelectsS[S].TextureSBG := Texture.GetTexture(SBGName, SBGTyp); - - SelectsS[High(SelectsS)].Tex_SelectS_ArrowL := Tex_SelectS_ArrowL; - SelectsS[High(SelectsS)].Tex_SelectS_ArrowL.X := X + W + SkipX; - SelectsS[High(SelectsS)].Tex_SelectS_ArrowL.Y := Y; - SelectsS[High(SelectsS)].Tex_SelectS_ArrowL.W := Tex_SelectS_ArrowL.W; - SelectsS[High(SelectsS)].Tex_SelectS_ArrowL.H := Tex_SelectS_ArrowL.H; - - SelectsS[High(SelectsS)].Tex_SelectS_ArrowR := Tex_SelectS_ArrowR; - SelectsS[High(SelectsS)].Tex_SelectS_ArrowR.X := X + W + SkipX + SBGW - Tex_SelectS_ArrowR.W; - SelectsS[High(SelectsS)].Tex_SelectS_ArrowR.Y := Y; - SelectsS[High(SelectsS)].Tex_SelectS_ArrowR.W := Tex_SelectS_ArrowR.W; - SelectsS[High(SelectsS)].Tex_SelectS_ArrowR.H := Tex_SelectS_ArrowR.H; - SelectsS[S].TextureSBG.X := X + W + SkipX; SelectsS[S].TextureSBG.Y := Y; + //SelectsS[S].TextureSBG.W := 450; SelectsS[S].SBGW := SBGW; SelectsS[S].TextureSBG.H := H; SelectsS[S].SBGColR := SBGColR; @@ -1425,12 +1350,10 @@ begin SetLength(SelectsS[SelectNo].TextOptT, SO + 1); SelectsS[SelectNo].TextOptT[SO] := AddText; -{ - SelectsS[S].SelectedOption := SelectsS[S].SelectOptInt; // refresh - if SO = Selects[S].PData^ then - Selects[S].SelectedOption := SO; -} + //SelectsS[S].SelectedOption := SelectsS[S].SelectOptInt; // refresh + + //if SO = Selects[S].PData^ then Selects[S].SelectedOption := SO; end; procedure TMenu.UpdateSelectSlideOptions(ThemeSelectSlide: TThemeSelectSlide; SelectNum: integer; const Values: array of string; var Data: integer); @@ -1530,12 +1453,12 @@ begin end; end; end; - // interact prev if there is nothing to change + //interact Prev if there is Nothing to Change else begin InteractPrev; - // if buttoncollection with more than 1 entry then select last entry - if (Button[Interactions[Interaction].Num].Parent <> 0) and (ButtonCollection[Button[Interactions[Interaction].Num].Parent-1].CountChilds > 1) then + //If ButtonCollection with more than 1 Entry then Select Last Entry + if (Button[Interactions[Interaction].Num].Parent <> 0) AND (ButtonCollection[Button[Interactions[Interaction].Num].Parent-1].CountChilds > 1) then begin //Select Last Child for Num := High(Button) downto 1 do @@ -1604,120 +1527,10 @@ begin Result := true; end; -function TMenu.ParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: integer): boolean; -var - nBut: integer; -begin - //default mouse parsing: clicking generates return keypress, - // mousewheel selects in select slide - //override ParseMouse to customize - Result := true; - - if RightMbESC and (MouseButton = SDL_BUTTON_RIGHT) and BtnDown then - begin - //if RightMbESC is set, send ESC keypress - Result:=ParseInput(SDLK_ESCAPE, 0, true); - end; - - nBut := InteractAt(X, Y); - if nBut >= 0 then - begin - //select on mouse-over - if nBut <> Interaction then - SetInteraction(nBut); - if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then - begin - //click button - Result:=ParseInput(SDLK_RETURN, 0, true); - end; - if (Interactions[nBut].Typ = iSelectS) then - begin - //forward/backward in select slide with mousewheel - if (MouseButton = SDL_BUTTON_WHEELDOWN) and BtnDown then - begin - ParseInput(SDLK_RIGHT, 0, true); - end; - if (MouseButton = SDL_BUTTON_WHEELUP) and BtnDown then - begin - ParseInput(SDLK_LEFT, 0, true); - end; - end; - end - else - begin - nBut := CollectionAt(X, Y); - if nBut >= 0 then - begin - // if over button collection, select first child but don't allow click - nBut := ButtonCollection[nBut].FirstChild - 1; - if nBut <> Interaction then - SetInteraction(nBut); - end; - end; -end; - -function TMenu.InRegion(X1, Y1, W, H, X, Y: real): boolean; -begin - Result := false; - X1 := X1 * Screen.w / 800; - W := W * Screen.w / 800; - Y1 := Y1 * Screen.h / 600; - H := H * Screen.h / 600; - if (X >= X1) and (X <= X1 + W) and (Y >= Y1) and (Y <= Y1 + H) then - Result := true; -end; - -//takes x,y coordinates and returns the interaction number -//of the control at this position -function TMenu.InteractAt(X, Y: real): integer; -var - i, nBut: integer; -begin - Result := -1; - for i := Low(Interactions) to High(Interactions) do - begin - case Interactions[i].Typ of - iButton: if InRegion(Button[Interactions[i].Num].X, Button[Interactions[i].Num].Y, Button[Interactions[i].Num].W, Button[Interactions[i].Num].H, X, Y) and - Button[Interactions[i].Num].Visible then - begin - Result:=i; - exit; - end; - iBCollectionChild: if InRegion(Button[Interactions[i].Num].X, Button[Interactions[i].Num].Y, Button[Interactions[i].Num].W, Button[Interactions[i].Num].H, X, Y) then - begin - Result:=i; - exit; - end; - iSelectS: if InRegion(SelectSs[Interactions[i].Num].X, SelectSs[Interactions[i].Num].Y, SelectSs[Interactions[i].Num].W, SelectSs[Interactions[i].Num].H, X, Y) or - InRegion(SelectSs[Interactions[i].Num].TextureSBG.X, SelectSs[Interactions[i].Num].TextureSBG.Y, SelectSs[Interactions[i].Num].TextureSBG.W, SelectSs[Interactions[i].Num].TextureSBG.H, X, Y) then - begin - Result:=i; - exit; - end; - end; - end; -end; - -//takes x,y coordinates and returns the button collection id -function TMenu.CollectionAt(X, Y: real): integer; -var - i, nBut: integer; -begin - Result := -1; - for i:= Low(ButtonCollection) to High(ButtonCollection) do - begin - if InRegion(ButtonCollection[i].X, ButtonCollection[i].Y, ButtonCollection[i].W, ButtonCollection[i].H, X, Y) and - ButtonCollection[i].Visible then - begin - Result:=i; - exit; - end; - end; -end; - procedure TMenu.SetAnimationProgress(Progress: real); begin // nothing end; end. + diff --git a/unicode/src/menu/UMenuBackgroundFade.pas b/unicode/src/menu/UMenuBackgroundFade.pas index b61a4542..dc37da45 100644 --- a/unicode/src/menu/UMenuBackgroundFade.pas +++ b/unicode/src/menu/UMenuBackgroundFade.pas @@ -62,17 +62,15 @@ const FADEINTIME = 1500; //Time the bg fades in
implementation
-uses
- sdl,
- gl,
- glext,
- USkins,
- UCommon,
- UGraphic;
+uses sdl,
+ gl,
+ glext,
+ USkins,
+ UCommon,
+ UGraphic;
constructor TMenuBackgroundFade.Create(const ThemedSettings: TThemeBackground);
-var
- texFilename: string;
+var texFilename: string;
begin
inherited;
FadeTime := 0;
@@ -124,7 +122,7 @@ begin if (UseTexture) then
begin //Draw Texture to Screen
- if (ScreenAct = 1) then //Clear just once when in dual screen mode
+ If (ScreenAct = 1) then //Clear just once when in dual screen mode
glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
@@ -153,7 +151,7 @@ begin end
else
begin //Clear Screen w/ progress Alpha + Color
- if (ScreenAct = 1) then //Clear just once when in dual screen mode
+ If (ScreenAct = 1) then //Clear just once when in dual screen mode
glClear(GL_DEPTH_BUFFER_BIT);
glDisable(GL_TEXTURE_2D);
diff --git a/unicode/src/menu/UMenuButton.pas b/unicode/src/menu/UMenuButton.pas index 923f0b14..c6ff8ab7 100644 --- a/unicode/src/menu/UMenuButton.pas +++ b/unicode/src/menu/UMenuButton.pas @@ -55,6 +55,7 @@ type PosX, PosY: real; + constructor Create(); overload; public Text: array of TText; @@ -112,7 +113,6 @@ type procedure Draw; virtual; - constructor Create(); overload; constructor Create(Textura: TTexture); overload; constructor Create(Textura, DSTexture: TTexture); overload; destructor Destroy; override; @@ -252,6 +252,42 @@ begin end; end; +constructor TButton.Create(); +begin + inherited Create; + // We initialize all to 0, nil or false + Visible := true; + SelectBool := false; + DeselectType := 0; + Selectable := true; + Reflection := false; + Colorized := false; + + SelectColR := 1; + SelectColG := 1; + SelectColB := 1; + SelectInt := 1; + SelectTInt := 1; + + DeselectColR := 1; + DeselectColG := 1; + DeselectColB := 1; + DeselectInt := 0.5; + DeselectTInt := 1; + + Fade := false; + FadeTex.TexNum := 0; + FadeProgress := 0; + FadeText := false; + SelectW := DeSelectW; + SelectH := DeSelectH; + + PosX := 0; + PosY := 0; + + Parent := 0; +end; + // ***** Public methods ****** // procedure TButton.Draw; @@ -535,42 +571,6 @@ begin inherited; end; -constructor TButton.Create(); -begin - inherited Create; - // We initialize all to 0, nil or false - Visible := true; - SelectBool := false; - DeselectType := 0; - Selectable := true; - Reflection := false; - Colorized := false; - - SelectColR := 1; - SelectColG := 1; - SelectColB := 1; - SelectInt := 1; - SelectTInt := 1; - - DeselectColR := 1; - DeselectColG := 1; - DeselectColB := 1; - DeselectInt := 0.5; - DeselectTInt := 1; - - Fade := false; - FadeTex.TexNum := 0; - FadeProgress := 0; - FadeText := false; - SelectW := DeSelectW; - SelectH := DeSelectH; - - PosX := 0; - PosY := 0; - - Parent := 0; -end; - constructor TButton.Create(Textura: TTexture); begin Create(); diff --git a/unicode/src/menu/UMenuButtonCollection.pas b/unicode/src/menu/UMenuButtonCollection.pas index 8b7a1c3f..c6c6dd81 100644 --- a/unicode/src/menu/UMenuButtonCollection.pas +++ b/unicode/src/menu/UMenuButtonCollection.pas @@ -41,61 +41,61 @@ type //TButtonCollection //No Extra Attributes or Functions ATM //---------------- - AButton = array of TButton; + AButton = Array of TButton; PAButton = ^AButton; TButtonCollection = class(TButton) //num of the First Button, that can be Selected - FirstChild: byte; - CountChilds: byte; + FirstChild: Byte; + CountChilds: Byte; ScreenButton: PAButton; - procedure SetSelect(Value : boolean); override; + procedure SetSelect(Value : Boolean); override; procedure Draw; override; end; implementation -procedure TButtonCollection.SetSelect(Value : boolean); -var - Index: integer; +procedure TButtonCollection.SetSelect(Value : Boolean); +var I: Integer; begin inherited; //Set Visible for Every Button that is a Child of this ButtonCollection - if (not Fade) then - for Index := 0 to High(ScreenButton^) do - if (ScreenButton^[Index].Parent = Parent) then - ScreenButton^[Index].Visible := Value; + if (Not Fade) then + For I := 0 to High(ScreenButton^) do + if (ScreenButton^[I].Parent = Parent) then + ScreenButton^[I].Visible := Value; end; procedure TButtonCollection.Draw; -var - I, J: integer; +var I, J: Integer; begin inherited; //If fading is activated, Fade Child Buttons if (Fade) then begin - for I := 0 to High(ScreenButton^) do + For I := 0 to High(ScreenButton^) do if (ScreenButton^[I].Parent = Parent) then begin if (FadeProgress < 0.5) then begin ScreenButton^[I].Visible := SelectBool; - for J := 0 to High(ScreenButton^[I].Text) do + For J := 0 to High(ScreenButton^[I].Text) do ScreenButton^[I].Text[J].Visible := SelectBool; end else begin ScreenButton^[I].Texture.Alpha := (FadeProgress-0.666)*3; - for J := 0 to High(ScreenButton^[I].Text) do + For J := 0 to High(ScreenButton^[I].Text) do ScreenButton^[I].Text[J].Alpha := (FadeProgress-0.666)*3; end; end; end; end; + + end. diff --git a/unicode/src/menu/UMenuEqualizer.pas b/unicode/src/menu/UMenuEqualizer.pas index 8f57e44a..6d77721c 100644 --- a/unicode/src/menu/UMenuEqualizer.pas +++ b/unicode/src/menu/UMenuEqualizer.pas @@ -45,71 +45,69 @@ type Tms_Equalizer = class(TObject) private FFTData: TFFTData; // moved here to avoid stack overflows - BandData: array of byte; - RefreshTime: cardinal; + BandData: array of Byte; + RefreshTime: Cardinal; Source: IAudioPlayback; - procedure Analyse; + Procedure Analyse; public - X: integer; - Y: integer; - Z: real; + X: Integer; + Y: Integer; + Z: Real; - W: integer; - H: integer; - Space: integer; + W: Integer; + H: Integer; + Space: Integer; - Visible: boolean; - Alpha: real; - Color: TRGB; + Visible: Boolean; + Alpha: real; + Color: TRGB; - Direction: boolean; - BandLength: integer; + Direction: Boolean; - Reflection: boolean; - Reflectionspacing: real; + BandLength: Integer; + + Reflection: boolean; + Reflectionspacing: Real; constructor Create(Source: IAudioPlayback; mySkin: TThemeEqualizer); procedure Draw; - procedure SetBands(Value: byte); - function GetBands: byte; - property Bands: byte read GetBands write SetBands; + + Procedure SetBands(Value: Byte); + Function GetBands: Byte; + Property Bands: Byte read GetBands write SetBands; procedure SetSource(newSource: IAudioPlayback); end; implementation -uses - math, - SDL, - gl, - glext; +uses math, SDL, gl, glext; + constructor Tms_Equalizer.Create(Source: IAudioPlayback; mySkin: TThemeEqualizer); -var - I: integer; +var I: Integer; begin - if (Source <> nil) then + If (Source <> nil) then begin - X := mySkin.X; - Y := mySkin.Y; - W := mySkin.W; - H := mySkin.H; - Z := mySkin.Z; + X := mySkin.X; + Y := mySkin.Y; + W := mySkin.W; + H := mySkin.H; + Z := mySkin.Z; - Space := mySkin.Space; + Space := mySkin.Space; - Visible := mySkin.Visible; - Alpha := mySkin.Alpha; - Color.R := mySkin.ColR; - Color.G := mySkin.ColG; - Color.B := mySkin.ColB; + Visible := mySkin.Visible; + Alpha := mySkin.Alpha; + Color.R := mySkin.ColR; + Color.G := mySkin.ColG; + Color.B := mySkin.ColB; - Direction := mySkin.Direction; - Bands := mySkin.Bands; - BandLength := mySkin.Length; + Direction := mySkin.Direction; + Bands := mySkin.Bands; + BandLength := mySkin.Length; Reflection := mySkin.Reflection; Reflectionspacing := mySkin.Reflectionspacing; @@ -118,31 +116,31 @@ begin //Check if Visible - if (Bands <= 0) or - (BandLength <= 0) or - (W <= 0) or - (H <= 0) or + If (Bands <= 0) OR + (BandLength <= 0) OR + (W <= 0) OR + (H <= 0) OR (Alpha <= 0) then - Visible := false; + Visible := False; //ClearArray - for I := low(BandData) to high(BandData) do + For I := low(BandData) to high(BandData) do BandData[I] := 3; end else - Visible := false; + Visible := False; end; //-------- // evaluate FFT-Data //-------- -procedure Tms_Equalizer.Analyse; -var - I: integer; - ChansPerBand: byte; // channels per band - MaxChannel: integer; - Pos: real; - CurBand: integer; +Procedure Tms_Equalizer.Analyse; + var + I: Integer; + ChansPerBand: byte; // channels per band + MaxChannel: Integer; + Pos: Real; + CurBand: Integer; begin Source.GetFFTData(FFTData); @@ -190,26 +188,25 @@ end; // Draw SpectrumAnalyser, Call Analyse //-------- procedure Tms_Equalizer.Draw; -var - CurTime: cardinal; - PosX, PosY: real; - I, J: integer; - Diff: real; + var + CurTime: Cardinal; + PosX, PosY: Real; + I, J: Integer; + Diff: Real; - function GetAlpha(Diff: single): single; + Function GetAlpha(Diff: Single): Single; begin - if Direction then - Result := (Alpha * 0.6) * (0.5 - Diff/(BandLength * (H + Space))) + If Direction then + Result := (Alpha * 0.6) *(0.5 - Diff/(BandLength * (H + Space))) else - Result := (Alpha * 0.6) * (0.5 - Diff/(Bands * (H + Space))); + Result := (Alpha * 0.6) *(0.5 - Diff/(Bands * (H + Space))); end; - begin - if (Visible) and not (AudioPlayback.Finished) then + If (Visible) AND not (AudioPlayback.Finished) then begin //Call Analyse if necessary CurTime := SDL_GetTicks(); - if (CurTime > RefreshTime) then + If (CurTime > RefreshTime) then begin Analyse; @@ -247,12 +244,12 @@ begin glVertex3f(PosX+W, PosY, Z); glEnd; - if (Reflection) and (J <= BandLength div 2) then + If (Reflection) AND (J <= BandLength div 2) then begin Diff := (Y-PosY) + H; //Draw Reflection - if Direction then + If Direction then begin glBegin(GL_QUADS); glColorRGB(Color, GetAlpha(Diff)); @@ -301,20 +298,22 @@ begin end; end; -procedure Tms_Equalizer.SetBands(Value: byte); +Procedure Tms_Equalizer.SetBands(Value: Byte); begin SetLength(BandData, Value); end; -function Tms_Equalizer.GetBands: byte; +Function Tms_Equalizer.GetBands: Byte; begin Result := Length(BandData); end; -procedure Tms_Equalizer.SetSource(newSource: IAudioPlayback); +Procedure Tms_Equalizer.SetSource(newSource: IAudioPlayback); begin - if (newSource <> nil) then + If (newSource <> nil) then Source := newSource; end; + + end.
\ No newline at end of file diff --git a/unicode/src/menu/UMenuInteract.pas b/unicode/src/menu/UMenuInteract.pas index beb6bcef..4c2d4e86 100644 --- a/unicode/src/menu/UMenuInteract.pas +++ b/unicode/src/menu/UMenuInteract.pas @@ -35,8 +35,8 @@ interface type TInteract = record // for moving thru menu - Typ: integer; // 0 - button, 1 - select, 2 - Text, 3 - Select SLide, 5 - ButtonCollection Child - Num: integer; // number of this item in proper list like buttons, selects + Typ: integer; // 0 - button, 1 - select, 2 - Text, 3 - Select SLide, 5 - ButtonCollection Child + Num: integer; // number of this item in proper list like buttons, selects end; implementation diff --git a/unicode/src/menu/UMenuSelectSlide.pas b/unicode/src/menu/UMenuSelectSlide.pas index f9f6bbae..1a0fa725 100644 --- a/unicode/src/menu/UMenuSelectSlide.pas +++ b/unicode/src/menu/UMenuSelectSlide.pas @@ -34,10 +34,10 @@ interface {$I switches.inc} uses - gl, TextGL, - UMenuText, - UTexture; + UTexture, + gl, + UMenuText; type PSelectSlide = ^TSelectSlide; @@ -54,23 +54,17 @@ type TextureSBG: TTexture; // Background Selections Texture // TextureS: array of TTexture; // Selections Texture (not used) - Tex_SelectS_ArrowL: TTexture; // Texture for left arrow - Tex_SelectS_ArrowR: TTexture; // Texture for right arrow +// TextureArrowL: TTexture; // Texture for left arrow (not used yet) +// TextureArrowR: TTexture; // Texture for right arrow (not used yet) SelectOptInt: integer; PData: ^integer; //For automatically Setting LineCount - Lines: byte; - - //Arrows on/off - showArrows: boolean; //default is false - - //whether to show one item or all that fit into the select - oneItemOnly: boolean; //default is false + Lines: Byte; //Visibility - Visible: boolean; + Visible: Boolean; // for selection and deselection // main static @@ -127,7 +121,7 @@ type // procedures procedure SetSelect(Value: boolean); - property Selected: boolean read SelectBool write SetSelect; + property Selected: Boolean read SelectBool write SetSelect; procedure SetSelectOpt(Value: integer); property SelectedOption: integer read SelectOptInt write SetSelectOpt; procedure Draw; @@ -138,12 +132,7 @@ type end; implementation - -uses - math, - SysUtils, - UDrawTexture, - ULog; +uses UDrawTexture, math, ULog, SysUtils; // ------------ Select constructor TSelectSlide.Create; @@ -152,17 +141,24 @@ begin Text := TText.Create; SetLength(TextOpt, 1); TextOpt[0] := TText.Create; - Visible := true; + + //Set Standard Width for Selections Background + SBGW := 450; + + Visible := True; + {SetLength(TextOpt, 3); + TextOpt[0] := TText.Create; + TextOpt[1] := TText.Create; + TextOpt[2] := TText.Create;} end; procedure TSelectSlide.SetSelect(Value: boolean); {var - SO: integer; - I: integer;} + SO: integer; + I: integer;} begin SelectBool := Value; - if Value then - begin + if Value then begin Texture.ColR := ColR; Texture.ColG := ColG; Texture.ColB := ColB; @@ -177,9 +173,15 @@ begin TextureSBG.ColG := SBGColG; TextureSBG.ColB := SBGColB; TextureSBG.Int := SBGInt; - end - else - begin + +{ for I := 0 to High(TextOpt) do begin + TextOpt[I].ColR := STColR; + TextOpt[I].ColG := STColG; + TextOpt[I].ColB := STColB; + TextOpt[I].Int := STInt; + end;} + + end else begin Texture.ColR := DColR; Texture.ColG := DColG; Texture.ColB := DColB; @@ -194,215 +196,185 @@ begin TextureSBG.ColG := SBGDColG; TextureSBG.ColB := SBGDColB; TextureSBG.Int := SBGDInt; + +{ for I := 0 to High(TextOpt) do begin + TextOpt[I].ColR := STDColR; + TextOpt[I].ColG := STDColG; + TextOpt[I].ColB := STDColB; + TextOpt[I].Int := STDInt; + end;} end; end; procedure TSelectSlide.SetSelectOpt(Value: integer); var - SO: integer; - HalfL: integer; - HalfR: integer; + SO: integer; + HalfL: integer; + HalfR: integer; - procedure DoSelection(Sel: cardinal); - var - I: integer; +procedure DoSelection(Sel: Cardinal); + var I: Integer; begin - for I := Low(TextOpt) to High(TextOpt) do + for I := low(TextOpt) to high(TextOpt) do begin TextOpt[I].ColR := STDColR; TextOpt[I].ColG := STDColG; TextOpt[I].ColB := STDColB; TextOpt[I].Int := STDInt; end; - - if (integer(Sel) <= High(TextOpt)) then + if (integer(Sel) <= high(TextOpt)) then begin TextOpt[Sel].ColR := STColR; TextOpt[Sel].ColG := STColG; TextOpt[Sel].ColB := STColB; TextOpt[Sel].Int := STInt; - end; end; - + end; begin SelectOptInt := Value; PData^ := Value; +// SetSelect(true); // reset all colors - if (Length(TextOpt) > 0) and (Length(TextOptT) > 0) then + if (Length(TextOpt)>0) AND (Length(TextOptT)>0) then begin - //First option selected if (Value <= 0) then - begin + begin //First Option Selected Value := 0; - Tex_SelectS_ArrowL.alpha := 0; - Tex_SelectS_ArrowR.alpha := 1; - - for SO := Low(TextOpt) to High(TextOpt) do + for SO := low (TextOpt) to high(TextOpt) do begin - TextOpt[SO].Text := TextOptT[SO]; + TextOpt[SO].Text := TextOptT[SO]; end; DoSelection(0); end + else if (Value >= high(TextOptT)) then + begin //Last Option Selected + Value := high(TextOptT); - //Last option selected - else if (Value >= High(TextOptT)) then - begin - Value := High(TextOptT); - - Tex_SelectS_ArrowL.alpha := 1; - Tex_SelectS_ArrowR.alpha := 0; - - for SO := High(TextOpt) downto Low(TextOpt) do + for SO := high(TextOpt) downto low (TextOpt) do begin - TextOpt[SO].Text := TextOptT[High(TextOptT) - (Lines - SO - 1)]; + TextOpt[SO].Text := TextOptT[high(TextOptT)-(Lines-SO-1)]; end; - DoSelection(Lines - 1); + DoSelection(Lines-1); end - - //in between first and last else begin - Tex_SelectS_ArrowL.alpha := 1; - Tex_SelectS_ArrowR.alpha := 1; - - HalfL := Ceil((Lines - 1) / 2); - HalfR := Lines - 1 - HalfL; - - //Selected option is near to the left side - if (Value <= HalfL) then + HalfL := Ceil((Lines-1)/2); + HalfR := Lines-1-HalfL; + + if (Value <= HalfL) then + begin //Selected Option is near to the left side + {HalfL := Value; + HalfR := Lines-1-HalfL;} + //Change Texts + for SO := low (TextOpt) to high(TextOpt) do begin - //Change texts - for SO := Low(TextOpt) to High(TextOpt) do - begin - TextOpt[SO].Text := TextOptT[SO]; - end; - - DoSelection(Value); - end + TextOpt[SO].Text := TextOptT[SO]; + end; - //Selected option is near to the right side - else if (Value > High(TextOptT) - HalfR) then + DoSelection(Value); + end + else if (Value > High(TextOptT)-HalfR) then + begin //Selected is too near to the right border + HalfR := high(TextOptT) - Value; + HalfL := Lines-1-HalfR; + //Change Texts + for SO := high(TextOpt) downto low (TextOpt) do begin - HalfR := High(TextOptT) - Value; - HalfL := Lines - 1 - HalfR; - //Change texts - for SO := High(TextOpt) downto Low(TextOpt) do - begin - TextOpt[SO].Text := TextOptT[High(TextOptT) - (Lines - SO - 1)]; - end; - - DoSelection (HalfL); - end + TextOpt[SO].Text := TextOptT[high(TextOptT)-(Lines-SO-1)]; + end; - else + DoSelection (HalfL); + end + else + begin + //Change Texts + for SO := low (TextOpt) to high(TextOpt) do begin - //Change Texts - for SO := Low(TextOpt) to High(TextOpt) do - begin - TextOpt[SO].Text := TextOptT[Value - HalfL + SO]; - end; - - DoSelection(HalfL); + TextOpt[SO].Text := TextOptT[Value - HalfL + SO]; end; + + DoSelection(HalfL); + end; + end; + end; + end; procedure TSelectSlide.Draw; var - SO: integer; + SO: integer; begin if Visible then begin DrawTexture(Texture); DrawTexture(TextureSBG); - if showArrows then - begin - DrawTexture(Tex_SelectS_ArrowL); - DrawTexture(Tex_SelectS_ArrowR); - end; - Text.Draw; - for SO := Low(TextOpt) to High(TextOpt) do + for SO := low(TextOpt) to high(TextOpt) do TextOpt[SO].Draw; end; end; procedure TSelectSlide.GenLines; var - maxlength: real; - I: integer; +maxlength: Real; +I: Integer; begin SetFontStyle(0{Text.Style}); SetFontSize(Text.Size); maxlength := 0; - for I := Low(TextOptT) to High(TextOptT) do + for I := low(TextOptT) to high (TextOptT) do begin if (glTextWidth(TextOptT[I]) > maxlength) then maxlength := glTextWidth(TextOptT[I]); end; + Lines := floor((TextureSBG.W-40) / (maxlength+7)); + if (Lines > Length(TextOptT)) then + Lines := Length(TextOptT); - if (oneItemOnly = false) then - begin - //show all items - Lines := floor((TextureSBG.W-40) / (maxlength+7)); - if (Lines > Length(TextOptT)) then - Lines := Length(TextOptT); - - if (Lines <= 0) then - Lines := 1; - end - else - begin - //show one item only + if (Lines <= 0) then Lines := 1; - end; //Free old Space used by Texts - for I := Low(TextOpt) to High(TextOpt) do + For I := low(TextOpt) to high(TextOpt) do TextOpt[I].Free; setLength (TextOpt, Lines); - for I := Low(TextOpt) to High(TextOpt) do - begin - TextOpt[I] := TText.Create; - TextOpt[I].Size := Text.Size; - //TextOpt[I].Align := 1; - TextOpt[I].Align := 0; - TextOpt[I].Visible := true; - - TextOpt[I].ColR := STDColR; - TextOpt[I].ColG := STDColG; - TextOpt[I].ColB := STDColB; - TextOpt[I].Int := STDInt; - - //Generate Positions - //TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W / Lines) * (I + 0.5); - if (I <> High(TextOpt)) or (High(TextOpt) = 0) or (Length(TextOptT) = Lines) then - TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W / Lines) * I - else - TextOpt[I].X := TextureSBG.X + TextureSBG.W - maxlength; + for I := low(TextOpt) to high(TextOpt) do + begin + TextOpt[I] := TText.Create; + TextOpt[I].Size := Text.Size; + //TextOpt[I].Align := 1; + TextOpt[I].Align := 0; + TextOpt[I].Visible := True; - TextOpt[I].Y := TextureSBG.Y + (TextureSBG.H - Text.Size) / 2; + TextOpt[I].ColR := STDColR; + TextOpt[I].ColG := STDColG; + TextOpt[I].ColB := STDColB; + TextOpt[I].Int := STDInt; - //Better Look with 2 Options - if (Lines = 2) and (Length(TextOptT) = 2) then - TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W -40 - glTextWidth(TextOptT[1])) * I; + //Generate Positions + //TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W / Lines) * (I + 0.5); + if (I <> High(TextOpt)) OR (High(TextOpt) = 0) OR (Length(TextOptT) = Lines) then + TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W / Lines) * I + else + TextOpt[I].X := TextureSBG.X + TextureSBG.W - maxlength; - if (Lines = 1) then - begin - TextOpt[I].Align := 1; //center text - TextOpt[I].X := TextureSBG.X + (TextureSBG.W / 2); + TextOpt[I].Y := TextureSBG.Y + (TextureSBG.H - Text.Size) / 2; + + //Better Look with 2 Options + if (Lines=2) AND (Length(TextOptT)= 2) then + TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W -40 - glTextWidth(TextOptT[1])) * I; end; - end; end; end. diff --git a/unicode/src/menu/UMenuStatic.pas b/unicode/src/menu/UMenuStatic.pas index 72f4eb36..9a10fade 100644 --- a/unicode/src/menu/UMenuStatic.pas +++ b/unicode/src/menu/UMenuStatic.pas @@ -40,20 +40,19 @@ uses type TStatic = class public - Texture: TTexture; // Button Screen position and size - Visible: boolean; + Texture: TTexture; // Button Screen position and size + Visible: boolean; //Reflection Mod - Reflection: boolean; - Reflectionspacing: real; + Reflection: boolean; + Reflectionspacing: Real; procedure Draw; constructor Create(Textura: TTexture); overload; end; implementation -uses - UDrawTexture; +uses UDrawTexture; procedure TStatic.Draw; begin diff --git a/unicode/src/menu/UMenuText.pas b/unicode/src/menu/UMenuText.pas index 88cda855..87f9ce54 100644 --- a/unicode/src/menu/UMenuText.pas +++ b/unicode/src/menu/UMenuText.pas @@ -34,29 +34,29 @@ interface {$I switches.inc} uses + TextGL, + UTexture, + gl, math, SysUtils, - gl, - SDL, - TextGL, - UTexture; + SDL; type TText = class private - SelectBool: boolean; - TextString: UTF8String; - TextTiles: array of UTF8String; + SelectBool: boolean; + TextString: UTF8String; + TextTiles: array of UTF8String; - STicks: cardinal; - SelectBlink: boolean; + STicks: Cardinal; + SelectBlink: boolean; public X: real; Y: real; Z: real; - MoveX: real; // some modifier for x - position that don't affect the real Y - MoveY: real; // some modifier for y - position that don't affect the real Y - W: real; // text wider than W is broken + MoveX: real; //Some Modifier for X - Position that don't affect the real Y + MoveY: real; //Some Modifier for Y - Position that don't affect the real Y + W: real; //text wider than W is broken // H: real; Size: real; ColR: real; @@ -64,13 +64,13 @@ type ColB: real; Alpha: real; Int: real; - Style: integer; - Visible: boolean; - Align: integer; // 0 = left, 1 = center, 2 = right + Style: integer; + Visible: boolean; + Align: integer; // 0 = left, 1 = center, 2 = right - // reflection - Reflection: boolean; - ReflectionSpacing: real; + //Reflection + Reflection: boolean; + ReflectionSpacing: real; procedure SetSelect(Value: boolean); property Selected: boolean read SelectBool write SetSelect; @@ -97,36 +97,35 @@ procedure TText.SetSelect(Value: boolean); begin SelectBool := Value; - // set cursor visible - SelectBlink := true; + //Set Cursor Visible + SelectBlink := True; STicks := SDL_GetTicks() div 550; end; procedure TText.SetText(Value: UTF8String); var - NextPos: cardinal; // next pos of a space etc. - LastPos: cardinal; // last pos " - LastBreak: cardinal; // last break - isBreak: boolean; // true if the break is not caused because the text is out of the area - FirstWord: word; // is first word after break? - Len: word; // length of the tiles array + NextPos: Cardinal; //NextPos of a Space etc. + LastPos: Cardinal; //LastPos " + LastBreak: Cardinal; //Last Break + isBreak: boolean; //True if the Break is not Caused because the Text is out of the area + FirstWord: Word; //Is First Word after Break? + Len: Word; //Length of the Tiles Array function GetNextPos: boolean; var - T1, {T2,} T3: cardinal; + T1, {T2,} T3: Cardinal; begin LastPos := NextPos; - // next space (if width is given) + //Next Space (If Width is given) if (W > 0) then T1 := PosEx(' ', Value, LastPos + 1) - else - T1 := Length(Value); + else T1 := Length(Value); - {// next - + {//Next - T2 := PosEx('-', Value, LastPos + 1);} - // next break + //Next Break T3 := PosEx('\n', Value, LastPos + 1); if T1 = 0 then @@ -136,19 +135,19 @@ var if T3 = 0 then T3 := Length(Value); - // get nearest pos + //Get Nearest Pos NextPos := min(T1, T3{min(T2, T3)}); - if (LastPos = cardinal(Length(Value))) then + if (LastPos = Length(Value)) then NextPos := 0; - isBreak := (NextPos = T3) and (NextPos <> cardinal(Length(Value))); + isBreak := (NextPos = T3) AND (NextPos <> Length(Value)); Result := (NextPos <> 0); end; - procedure AddBreak(const From, bTo: cardinal); + procedure AddBreak(const From, bTo: Cardinal); begin - if (isBreak) or (bTo - From >= 1) then + if (isBreak) OR (bTo - From >= 1) then begin Inc(Len); SetLength (TextTiles, Len); @@ -163,14 +162,14 @@ var end; begin - // set TextString + //Set TExtstring TextString := Value; - // set cursor visible - SelectBlink := true; + //Set Cursor Visible + SelectBlink := True; STicks := SDL_GetTicks() div 550; - // exit if there is no need to create tiles + //Exit if there is no Need to Create Tiles if (W <= 0) and (Pos('\n', Value) = 0) then begin SetLength (TextTiles, 1); @@ -178,12 +177,12 @@ begin Exit; end; - // create tiles - // reset text array + //Create Tiles + //Reset Text Array SetLength (TextTiles, 0); Len := 0; - // reset counter vars + //Reset Counter Vars LastPos := 1; NextPos := 1; LastBreak := 1; @@ -191,57 +190,57 @@ begin if (W > 0) then begin - // set font properties + //Set Font Properties SetFontStyle(Style); SetFontSize(Size); end; - // go through text + //go Through Text while (GetNextPos) do begin - // break in text + //Break in Text if isBreak then begin - // look for break before the break + //Look for Break before the Break if (glTextWidth(Copy(Value, LastBreak, NextPos - LastBreak + 1)) > W) AND (NextPos-LastPos > 1) then begin - isBreak := false; - // not the first word after break, so we don't have to break within a word + isBreak := False; + //Not the First word after Break, so we don't have to break within a word if (FirstWord > 1) then begin - // add break before actual position, because there the text fits the area + //Add Break before actual Position, because there the Text fits the Area AddBreak(LastBreak, LastPos); end - else // first word after break break within the word + else //First Word after Break Break within the Word begin - // to do - // AddBreak(LastBreak, LastBreak + 155); + //ToDo + //AddBreak(LastBreak, LastBreak + 155); end; end; - isBreak := true; - // add break from text + isBreak := True; + //Add Break from Text AddBreak(LastBreak, NextPos); end - // text comes out of the text area -> createbreak + //Text comes out of the Text Area -> CreateBreak else if (glTextWidth(Copy(Value, LastBreak, NextPos - LastBreak + 1)) > W) then begin - // not the first word after break, so we don't have to break within a word + //Not the First word after Break, so we don't have to break within a word if (FirstWord > 1) then begin - // add break before actual position, because there the text fits the area + //Add Break before actual Position, because there the Text fits the Area AddBreak(LastBreak, LastPos); end - else // first word after break -> break within the word + else //First Word after Break -> Break within the Word begin - // to do - // AddBreak(LastBreak, LastBreak + 155); + //ToDo + //AddBreak(LastBreak, LastBreak + 155); end; end; //end; Inc(FirstWord) end; - // add ending + //Add Ending AddBreak(LastBreak, Length(Value)+1); end; @@ -263,34 +262,33 @@ var X2, Y2: real; Text2: UTF8String; I: integer; - Ticks: cardinal; begin - if Visible and (Size > 0) then + if Visible then begin SetFontStyle(Style); SetFontSize(Size); - SetFontItalic(false); + SetFontItalic(False); glColor4f(ColR*Int, ColG*Int, ColB*Int, Alpha); - // reflection - if Reflection then + //Reflection + if Reflection = true then SetFontReflection(true, ReflectionSpacing) else SetFontReflection(false,0); - // if selected set blink... + //if selected set blink... if SelectBool then begin - Ticks := SDL_GetTicks() div 550; - if Ticks <> STicks then - begin // change visability - STicks := Ticks; + I := SDL_GetTicks() div 550; + if I <> STicks then + begin //Change Visability + STicks := I; SelectBlink := Not SelectBlink; end; end; - {if (false) then // no width set draw as one long string + {if (False) then //no width set draw as one long string begin if not (SelectBool AND SelectBlink) then Text2 := Text @@ -309,20 +307,20 @@ begin end else begin} - // now use always: - // draw text as many strings + //now use allways: + //draw text as many strings Y2 := Y + MoveY; - for I := 0 to High(TextTiles) do + for I := 0 to high(TextTiles) do begin - if (not (SelectBool and SelectBlink)) or (I <> High(TextTiles)) then + if (not (SelectBool and SelectBlink)) or (I <> high(TextTiles)) then Text2 := TextTiles[I] else Text2 := TextTiles[I] + '|'; case Align of - 1: X2 := X + MoveX - glTextWidth(Text2)/2; { centered } - 2: X2 := X + MoveX - glTextWidth(Text2); { right aligned } - else X2 := X + MoveX; { left aligned (default) } + 0: X2 := X + MoveX; + 1: X2 := X + MoveX - glTextWidth(Text2)/2; + 2: X2 := X + MoveX - glTextWidth(Text2); end; SetFontPos(X2, Y2); @@ -355,14 +353,7 @@ begin Create(X, Y, 0, 0, 30, 0, 0, 0, 0, Text, false, 0, 0); end; -constructor TText.Create(ParX, ParY, ParW: real; - ParStyle: integer; - ParSize, ParColR, ParColG, ParColB: real; - ParAlign: integer; - const ParText: UTF8String; - ParReflection: boolean; - ParReflectionSpacing: real; - ParZ: real); +constructor TText.Create(ParX, ParY, ParW: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; const ParText: UTF8String; ParReflection: boolean; ParReflectionSpacing: real; ParZ:real); begin inherited Create; Alpha := 1; @@ -380,8 +371,8 @@ begin Align := ParAlign; SelectBool := false; Visible := true; - Reflection := ParReflection; - ReflectionSpacing := ParReflectionSpacing; + Reflection:= ParReflection; + ReflectionSpacing:= ParReflectionSpacing; end; end. |