diff options
Diffstat (limited to '')
-rw-r--r-- | Game/Code/Menu/UMenu.pas | 188 | ||||
-rw-r--r-- | Game/Code/Menu/UMenuSelect.pas | 201 |
2 files changed, 2 insertions, 387 deletions
diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 2606802a..e352febd 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -8,7 +8,7 @@ interface {$I switches.inc} -uses gl, SysUtils, UTexture, UMenuStatic, UMenuText, UMenuButton, UMenuSelect, UMenuSelectSlide, +uses gl, SysUtils, UTexture, UMenuStatic, UMenuText, UMenuButton, UMenuSelectSlide, UMenuInteract, UThemes, UMenuButtonCollection, Math, UMusic; type @@ -22,7 +22,6 @@ type Interactions: array of TInteract; SelInteraction: integer; Button: array of TButton; - Selects: array of TSelect; SelectsS: array of TSelectSlide; ButtonCollection: array of TButtonCollection; BackImg: TTexture; @@ -89,18 +88,6 @@ type procedure AddButtonText(AddX, AddY: real; ColR, ColG, ColB: real; Font: integer; Size: integer; Align: integer; const AddText: string); overload; procedure AddButtonText(CustomButton: TButton; AddX, AddY: real; ColR, ColG, ColB: real; Font: integer; Size: integer; Align: integer; const AddText: string); overload; - // select - function AddSelect(ThemeSelect: TThemeSelect; var Data: integer; Values: array of string): integer; overload; - function AddSelect(X, Y, W, H, SkipX, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt, - TColR, TColG, TColB, TInt, TDColR, TDColG, TDColB, TDInt, - SBGColR, SBGColG, SBGColB, SBGInt, SBGDColR, SBGDColG, SBGDColB, SBGDInt, - STColR, STColG, STColB, STInt, STDColR, STDColG, STDColB, STDInt: real; - const Name: String; Typ: TTextureType; const SBGName: String; SBGTyp: TTextureType; - const Caption: string; var Data: integer): integer; overload; - procedure AddSelectOption(AddX, AddY: real; const AddText: string); overload; - procedure AddSelectOption(SelectNo: Cardinal; AddX, AddY: real; const AddText: string); overload; - procedure UpdateSelectOptions(ThemeSelect: TThemeSelect; SelectNum: integer; Values: array of string; var Data: integer); - // select slide function AddSelectSlide(ThemeSelectS: TThemeSelectSlide; var Data: integer; Values: array of string): integer; overload; function AddSelectSlide(X, Y, W, H, SkipX, SBGW, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt, @@ -151,7 +138,6 @@ const pmUnClick = 3; iButton = 0; // interaction type - iSelect = 1; iText = 2; iSelectS = 3; iBCollectionChild = 5; @@ -250,7 +236,6 @@ begin case OldTyp of iButton: Button[OldNum].Selected := False; - iSelect: Selects[OldNum].Selected := False; iText: Text[OldNum].Selected := False; iSelectS: SelectsS[OldNum].Selected := False; //Button Collection Mod @@ -268,7 +253,6 @@ begin SelInteraction := Num; case NewTyp of iButton: Button[NewNum].Selected := True; - iSelect: Selects[NewNum].Selected := True; iText: Text[NewNum].Selected := True; iSelectS: SelectsS[NewNum].Selected := True; @@ -771,7 +755,6 @@ begin for J := 0 to Length(Text) - 1 do Text[J].Draw; - // Draw all ButtonCollections for J := 0 to High(ButtonCollection) do ButtonCollection[J].Draw; @@ -780,10 +763,6 @@ begin for J := 0 to Length(Button) - 1 do Button[J].Draw; - // Third, we draw all of our selects - for J := 0 to Length(Selects) - 1 do - Selects[J].Draw(1); - for J := 0 to Length(SelectsS) - 1 do SelectsS[J].Draw; @@ -855,8 +834,7 @@ begin case Interactions[Int].Typ of //Button iButton: Result := Button[Interactions[Int].Num].Visible and Button[Interactions[Int].Num].Selectable; - //Select - iSelect: Result := true; + //Select Slide iSelectS: Result := SelectsS[Interactions[Int].Num].Visible; @@ -1070,154 +1048,6 @@ begin end; end; -function TMenu.AddSelect(ThemeSelect: TThemeSelect; var Data: integer; Values: array of string): integer; -var - SO: integer; -begin - Result := AddSelect(ThemeSelect.X, ThemeSelect.Y, ThemeSelect.W, ThemeSelect.H, ThemeSelect.SkipX, - ThemeSelect.ColR, ThemeSelect.ColG, ThemeSelect.ColB, ThemeSelect.Int, - ThemeSelect.DColR, ThemeSelect.DColG, ThemeSelect.DColB, ThemeSelect.DInt, - ThemeSelect.TColR, ThemeSelect.TColG, ThemeSelect.TColB, ThemeSelect.TInt, - ThemeSelect.TDColR, ThemeSelect.TDColG, ThemeSelect.TDColB, ThemeSelect.TDInt, - ThemeSelect.SBGColR, ThemeSelect.SBGColG, ThemeSelect.SBGColB, ThemeSelect.SBGInt, - ThemeSelect.SBGDColR, ThemeSelect.SBGDColG, ThemeSelect.SBGDColB, ThemeSelect.SBGDInt, - ThemeSelect.STColR, ThemeSelect.STColG, ThemeSelect.STColB, ThemeSelect.STInt, - ThemeSelect.STDColR, ThemeSelect.STDColG, ThemeSelect.STDColB, ThemeSelect.STDInt, - Skin.GetTextureFileName(ThemeSelect.Tex), TEXTURE_TYPE_COLORIZED, - Skin.GetTextureFileName(ThemeSelect.TexSBG), TEXTURE_TYPE_COLORIZED, - ThemeSelect.Text, Data); - for SO := 0 to High(Values) do - AddSelectOption(ThemeSelect.X + ThemeSelect.W + ThemeSelect.SkipX + SO * 100 + 20, ThemeSelect.Y + 20, Values[SO]); -end; - -function TMenu.AddSelect(X, Y, W, H, SkipX, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt, - TColR, TColG, TColB, TInt, TDColR, TDColG, TDColB, TDInt, - SBGColR, SBGColG, SBGColB, SBGInt, SBGDColR, SBGDColG, SBGDColB, SBGDInt, - STColR, STColG, STColB, STInt, STDColR, STDColG, STDColB, STDInt: real; - const Name: String; Typ: TTextureType; const SBGName: String; SBGTyp: TTextureType; - const Caption: string; var Data: integer): integer; -var - S: integer; -begin - S := Length(Selects); - SetLength(Selects, S + 1); - Selects[S] := TSelect.Create; - - if (Typ = TEXTURE_TYPE_COLORIZED) then - Selects[S].Texture := Texture.GetTexture(Name, Typ, RGBFloatToInt(ColR, ColG, ColB)) - else - Selects[S].Texture := Texture.GetTexture(Name, Typ); - Selects[S].X := X; - Selects[S].Y := Y; - Selects[S].W := W; - Selects[S].H := H; - Selects[S].ColR := ColR; - Selects[S].ColG := ColG; - Selects[S].ColB := ColB; - Selects[S].Int := Int; - Selects[S].DColR := DColR; - Selects[S].DColG := DColG; - Selects[S].DColB := DColB; - Selects[S].DInt := DInt; - - if (SBGTyp = TEXTURE_TYPE_COLORIZED) then - Selects[S].TextureSBG := Texture.GetTexture(SBGName, SBGTyp, RGBFloatToInt(SBGColR, SBGColG, SBGColB)) - else - Selects[S].TextureSBG := Texture.GetTexture(SBGName, SBGTyp); - Selects[S].TextureSBG.X := X + W + SkipX; - Selects[S].TextureSBG.Y := Y; - Selects[S].TextureSBG.W := 450; - Selects[S].TextureSBG.H := H; - Selects[S].SBGColR := SBGColR; - Selects[S].SBGColG := SBGColG; - Selects[S].SBGColB := SBGColB; - Selects[S].SBGInt := SBGInt; - Selects[S].SBGDColR := SBGDColR; - Selects[S].SBGDColG := SBGDColG; - Selects[S].SBGDColB := SBGDColB; - Selects[S].SBGDInt := SBGDInt; - - Selects[S].Text.X := X + 20; - Selects[S].Text.Y := Y + 20; - Selects[S].Text.Text := Caption; - Selects[S].Text.Size := 10; - Selects[S].Text.Visible := true; - Selects[S].TColR := TColR; - Selects[S].TColG := TColG; - Selects[S].TColB := TColB; - Selects[S].TInt := TInt; - Selects[S].TDColR := TDColR; - Selects[S].TDColG := TDColG; - Selects[S].TDColB := TDColB; - Selects[S].TDInt := TDInt; - - Selects[S].STColR := STColR; - Selects[S].STColG := STColG; - Selects[S].STColB := STColB; - Selects[S].STInt := STInt; - Selects[S].STDColR := STDColR; - Selects[S].STDColG := STDColG; - Selects[S].STDColB := STDColB; - Selects[S].STDInt := STDInt; - - // new - Selects[S].Texture.TexX1 := 0; - Selects[S].Texture.TexY1 := 0; - Selects[S].Texture.TexX2 := 1; - Selects[S].Texture.TexY2 := 1; - Selects[S].TextureSBG.TexX1 := 0; - Selects[S].TextureSBG.TexY1 := 0; - Selects[S].TextureSBG.TexX2 := 1; - Selects[S].TextureSBG.TexY2 := 1; - - // Sets Data to copy the value of selectops to global value; - Selects[S].PData := @Data; - - // Sets default value of selectopt from Data; - Selects[S].SelectedOption := Data; - - // Disables default selection - Selects[S].SetSelect(false); - - // adds interaction - AddInteraction(iSelect, S); -end; - -procedure TMenu.AddSelectOption(AddX, AddY: real; const AddText: string); -begin - AddSelectOption (High(Selects), AddX, AddY, AddText); -end; - -procedure TMenu.AddSelectOption(SelectNo: Cardinal; AddX, AddY: real; const AddText: string); -var - SO: integer; -begin - SO := Length(Selects[SelectNo].TextOpt); - SetLength(Selects[SelectNo].TextOpt, SO + 1); - - Selects[SelectNo].TextOpt[SO] := TText.Create; - - Selects[SelectNo].TextOpt[SO].X := AddX; - Selects[SelectNo].TextOpt[SO].Y := AddY; - Selects[SelectNo].TextOpt[SO].Text := AddText; - Selects[SelectNo].TextOpt[SO].Size := 10; - Selects[SelectNo].TextOpt[SO].ColR := Selects[SelectNo].STDColR; - Selects[SelectNo].TextOpt[SO].ColG := Selects[SelectNo].STDColG; - Selects[SelectNo].TextOpt[SO].ColB := Selects[SelectNo].STDColB; - Selects[SelectNo].TextOpt[SO].Int := Selects[SelectNo].STDInt; - Selects[SelectNo].TextOpt[SO].Visible := true; - - if SO = Selects[SelectNo].PData^ then Selects[SelectNo].SelectedOption := SO; -end; - -procedure TMenu.UpdateSelectOptions(ThemeSelect: TThemeSelect; SelectNum: integer; Values: array of string; var Data: integer); -var - SO: integer; -begin - SetLength(Selects[SelectNum].TextOpt, 0); - for SO := 0 to High(Values) do - AddSelectOption(SelectNum, ThemeSelect.X + ThemeSelect.W + ThemeSelect.SkipX + SO * 100 + 20, ThemeSelect.Y + 20, Values[SO]); -end; function TMenu.AddSelectSlide(ThemeSelectS: TThemeSelectSlide; var Data: integer; Values: array of string): integer; var @@ -1419,12 +1249,6 @@ var Value: integer; begin case Interactions[Interaction].Typ of - iSelect: begin - Num := Interactions[Interaction].Num; - Value := Selects[Num].SelectedOption; - Value := (Value + 1) Mod (Length(Selects[Num].TextOpt)); - Selects[Num].SelectedOption := Value; - end; iSelectS: begin Num := Interactions[Interaction].Num; Value := SelectsS[Num].SelectedOption; @@ -1466,14 +1290,6 @@ var Value: integer; begin case Interactions[Interaction].Typ of - iSelect: begin - Num := Interactions[Interaction].Num; - Value := Selects[Num].SelectedOption; - Value := Value - 1; - if Value = -1 then - Value := High(Selects[Num].TextOpt); - Selects[Num].SelectedOption := Value; - end; iSelectS: begin Num := Interactions[Interaction].Num; Value := SelectsS[Num].SelectedOption; diff --git a/Game/Code/Menu/UMenuSelect.pas b/Game/Code/Menu/UMenuSelect.pas deleted file mode 100644 index a93c4ed0..00000000 --- a/Game/Code/Menu/UMenuSelect.pas +++ /dev/null @@ -1,201 +0,0 @@ -unit UMenuSelect; - -interface - -{$I switches.inc} - -uses TextGL, UTexture, gl, UMenuText; - -type - PSelect = ^TSelect; - TSelect = class - private - SelectBool: boolean; - public - // objects - Text: TText; // Main Text - TextOpt: array of TText; // Options Text - Texture: TTexture; // Select Texture - TextureSBG: TTexture; // Background Selections Texture - TextureS: array of TTexture; // Selections Texture - SelectOptInt: integer; - PData: ^integer; - - // for selection and deselection - // main static - ColR: real; - ColG: real; - ColB: real; - Int: real; - DColR: real; - DColG: real; - DColB: real; - DInt: real; - - // main text - TColR: real; - TColG: real; - TColB: real; - TInt: real; - TDColR: real; - TDColG: real; - TDColB: real; - TDInt: real; - - // selection background static - SBGColR: real; - SBGColG: real; - SBGColB: real; - SBGInt: real; - SBGDColR: real; - SBGDColG: real; - SBGDColB: real; - SBGDInt: real; - - // selection statics - SColR: real; - SColG: real; - SColB: real; - SInt: real; - SDColR: real; - SDColG: real; - SDColB: real; - SDInt: real; - - // selection text - STColR: real; - STColG: real; - STColB: real; - STInt: real; - STDColR: real; - STDColG: real; - STDColB: real; - STDInt: real; - - // position and size - property X: real read Texture.x write Texture.x; - property Y: real read Texture.y write Texture.y; - property W: real read Texture.w write Texture.w; - property H: real read Texture.h write Texture.h; -// property X2: real read Texture2.x write Texture2.x; -// property Y2: real read Texture2.y write Texture2.y; -// property W2: real read Texture2.w write Texture2.w; -// property H2: real read Texture2.h write Texture2.h; - - // procedures - procedure SetSelect(Value: boolean); - property Selected: Boolean read SelectBool write SetSelect; - procedure SetSelectOpt(Value: integer); - property SelectedOption: integer read SelectOptInt write SetSelectOpt; - procedure Draw(ButtonAlpha: real); - constructor Create; - end; - -implementation -uses UDrawTexture; - -// ------------ Select -constructor TSelect.Create; -begin - inherited Create; - Text := TText.Create; -end; - -procedure TSelect.SetSelect(Value: boolean); -{var - SO: integer;} -begin // default 1, 0.4 - SelectBool := Value; - if Value then begin - Texture.ColR := ColR; - Texture.ColG := ColG; - Texture.ColB := ColB; - Texture.Int := Int; - - Text.ColR := TColR; - Text.ColG := TColG; - Text.ColB := TColB; - Text.Int := TInt; - - TextureSBG.ColR := SBGColR; - TextureSBG.ColG := SBGColG; - TextureSBG.ColB := SBGColB; - TextureSBG.Int := SBGInt; - -{ for SO := 0 to High(TextOpt) do begin - if SelectOptInt = SO then begin - TextOpt[SO].ColR := STColR; - TextOpt[SO].ColG := STColG; - TextOpt[SO].ColB := STColB; - TextOpt[SO].Int := STInt; - end else begin - TextOpt[SO].ColR := STDColR; - TextOpt[SO].ColG := STDColG; - TextOpt[SO].ColB := STDColB; - TextOpt[SO].Int := STDInt; - end; - end;} - - end else begin - Texture.ColR := DColR; - Texture.ColG := DColG; - Texture.ColB := DColB; - Texture.Int := DInt; - - Text.ColR := TDColR; - Text.ColG := TDColG; - Text.ColB := TDColB; - Text.Int := TDInt; - - TextureSBG.ColR := SBGDColR; - TextureSBG.ColG := SBGDColG; - TextureSBG.ColB := SBGDColB; - TextureSBG.Int := SBGDInt; - -{ for SO := 0 to High(TextOpt) do begin - TextOpt[SO].ColR := STDColR; - TextOpt[SO].ColG := STDColG; - TextOpt[SO].ColB := STDColB; - TextOpt[SO].Int := STDInt; - end;} - end; -end; - -procedure TSelect.SetSelectOpt(Value: integer); -var - SO: integer; -begin - SelectOptInt := Value; - PData^ := Value; -// SetSelect(true); // reset all colors - - for SO := 0 to High(TextOpt) do begin - if SelectOptInt = SO then begin - TextOpt[SO].ColR := STColR; - TextOpt[SO].ColG := STColG; - TextOpt[SO].ColB := STColB; - TextOpt[SO].Int := STInt; - end else begin - TextOpt[SO].ColR := STDColR; - TextOpt[SO].ColG := STDColG; - TextOpt[SO].ColB := STDColB; - TextOpt[SO].Int := STDInt; - end; - end; -end; - -procedure TSelect.Draw(ButtonAlpha: real); -var - SO: integer; -begin - DrawTexture(Texture); - DrawTexture(TextureSBG); - - Text.Draw; - - for SO := 0 to High(TextOpt) do begin - TextOpt[SO].Draw; - end; -end; - -end. |