aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Menu/UMenuSelect.pas
blob: 67c361111932326b964c58de1620aee295b97bfc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
unit UMenuSelect;

interface
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);
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.