Skip to content

Commit caeb85e

Browse files
Revert commit e0736e5
Do not merge again until fix profiles with no avatar
1 parent fb53441 commit caeb85e

File tree

9 files changed

+638
-184
lines changed

9 files changed

+638
-184
lines changed

src/base/UAvatars.pas

Lines changed: 409 additions & 88 deletions
Large diffs are not rendered by default.

src/base/UCommon.pas

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ procedure FreeAlignedMem(P: pointer);
118118
function Equals(A, B: string; CaseSensitive: boolean = false): Boolean; overload;
119119

120120
function GetArrayIndex(const SearchArray: array of UTF8String; Value: string; CaseInsensitiv: boolean = false): integer; overload;
121-
function GetArrayIndex(const SearchArray: array of string; Value: string; CaseInsensitiv: boolean = false): integer; overload;
122121
function GetArrayIndex(const SearchArray: array of integer; Value: integer): integer; overload;
123122

124123
function ParseResolutionString(const ResolutionString: string; out x, y: integer): boolean;
@@ -635,11 +634,6 @@ function GetArrayIndex(const SearchArray: array of UTF8String; Value: string;
635634
end;
636635
end;
637636

638-
function GetArrayIndex(const SearchArray: array of string; Value: string; CaseInsensitiv: boolean = false): integer;
639-
begin
640-
Result := GetArrayIndex(SearchArray, Value, CaseInsensitiv);
641-
end;
642-
643637
(**
644638
* Returns the index of Value in SearchArray
645639
* or -1 if Value is not in SearchArray.

src/base/UIni.pas

Lines changed: 67 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ TInputDeviceConfig = record
7474
DEFAULT_RESOLUTION = '800x600';
7575
IMaxPlayerCount = 6;
7676
IPlayers: array[0..4] of UTF8String = ('1', '2', '3', '4', '6');
77+
IPlayersVals: array[0..4] of integer = (1, 2, 3, 4, 6);
7778

7879
type
7980

@@ -101,13 +102,13 @@ TIni = class
101102
procedure LoadWebcamSettings(IniFile: TCustomIniFile);
102103
public
103104
// Players or Teams colors
104-
SingColor: array[0..(IMaxPlayerCount-1)] of integer; //FIXME remove this variable in all files
105+
SingColor: array[0..(IMaxPlayerCount-1)] of integer;
105106

106107
Name: array[0..(IMaxPlayerCount-1)] of UTF8String;
107108
PlayerColor: array[0..(IMaxPlayerCount-1)] of integer;
108109
TeamColor: array[0..2] of integer;
109110

110-
PlayerAvatar: array[0..(IMaxPlayerCount-1)] of string;
111+
PlayerAvatar: array[0..(IMaxPlayerCount-1)] of UTF8String;
111112
PlayerLevel: array[0..(IMaxPlayerCount-1)] of integer;
112113

113114
// Templates for Names Mod
@@ -229,19 +230,15 @@ TIni = class
229230
procedure Save();
230231
procedure SaveNames();
231232
procedure SaveLevel();
232-
procedure SavePlayers(
233-
TotalNumber: integer;
234-
Names: array of UTF8String;
235-
Colors: array of integer;
236-
Levels: array of integer;
237-
AvatarButtonsMd5: array of string;
238-
Avatars: array of integer
239-
);
233+
procedure SavePlayerColors();
234+
procedure SavePlayerAvatars();
235+
procedure SavePlayerLevels();
240236
procedure SaveTeamColors();
241237
procedure SaveShowWebScore();
242238
procedure SaveJukeboxSongMenu();
243239
procedure SaveSoundFont(Name: string);
244240
procedure SaveWebcamSettings();
241+
procedure SaveNumberOfPlayers();
245242
procedure SaveSingTimebarMode();
246243
procedure SaveJukeboxTimebarMode();
247244
procedure SaveJukeboxRepeatSongList();
@@ -846,10 +843,13 @@ procedure TIni.Load();
846843

847844
for I := 0 to IMaxPlayerCount-1 do
848845
begin
846+
// Name
849847
Name[I] := IniFile.ReadString('Name', 'P'+IntToStr(I+1), 'Player'+IntToStr(I+1));
848+
// Color Player
850849
PlayerColor[I] := IniFile.ReadInteger('PlayerColor', 'P'+IntToStr(I+1), I + 1);
851-
Self.SingColor[I] := Self.PlayerColor[I];
850+
// Avatar Player
852851
PlayerAvatar[I] := IniFile.ReadString('PlayerAvatar', 'P'+IntToStr(I+1), '');
852+
// Level Player
853853
PlayerLevel[I] := IniFile.ReadInteger('PlayerLevel', 'P'+IntToStr(I+1), 0);
854854
end;
855855

@@ -1317,39 +1317,54 @@ procedure TIni.SaveShowWebScore;
13171317
end;
13181318

13191319

1320-
procedure TIni.SavePlayers(
1321-
TotalNumber: integer;
1322-
Names: array of UTF8String;
1323-
Colors: array of integer;
1324-
Levels: array of integer;
1325-
AvatarButtonsMd5: array of string;
1326-
Avatars: array of integer
1327-
);
1320+
procedure TIni.SavePlayerColors;
1321+
13281322
var
13291323
IniFile: TIniFile;
1330-
I, J: integer;
1331-
PlayerNumber: string;
1324+
I: integer;
13321325
begin
13331326
if not Filename.IsReadOnly() then
13341327
begin
1335-
Self.Players := TotalNumber;
13361328
IniFile := TIniFile.Create(Filename.ToNative);
1337-
IniFile.WriteString('Game', 'Players', IPlayers[Players]);
1329+
1330+
//Colors for Names Mod
13381331
for I := 1 to IMaxPlayerCount do
1339-
begin
1340-
J := I - 1;
1341-
Self.Name[J] := Names[J];
1342-
Self.PlayerAvatar[J] := AvatarButtonsMd5[Avatars[J]];
1343-
Self.PlayerColor[J] := Colors[J];
1344-
Self.PlayerLevel[J] := Levels[J];
1345-
Self.SingColor[J] := Colors[J];
1346-
PlayerNumber := 'P' + IntToStr(I);
1347-
IniFile.WriteString('Name', PlayerNumber, Self.Name[J]);
1348-
IniFile.WriteString('PlayerAvatar', PlayerNumber, Self.PlayerAvatar[J]);
1349-
IniFile.WriteString('PlayerColor', PlayerNumber, IntToStr(Self.PlayerColor[J]));
1350-
IniFile.WriteInteger('PlayerLevel', PlayerNumber, Levels[J]);
1351-
end;
1352-
IniFile.Free();
1332+
IniFile.WriteString('PlayerColor', 'P' + IntToStr(I), IntToStr(PlayerColor[I-1]));
1333+
1334+
IniFile.Free;
1335+
end;
1336+
end;
1337+
1338+
procedure TIni.SavePlayerAvatars;
1339+
var
1340+
IniFile: TIniFile;
1341+
I: integer;
1342+
begin
1343+
if not Filename.IsReadOnly() then
1344+
begin
1345+
IniFile := TIniFile.Create(Filename.ToNative);
1346+
1347+
//Colors for Names Mod
1348+
for I := 1 to IMaxPlayerCount do
1349+
IniFile.WriteString('PlayerAvatar', 'P' + IntToStr(I), PlayerAvatar[I-1]);
1350+
1351+
IniFile.Free;
1352+
end;
1353+
end;
1354+
1355+
procedure TIni.SavePlayerLevels;
1356+
var
1357+
IniFile: TIniFile;
1358+
I: integer;
1359+
begin
1360+
if not Filename.IsReadOnly() then
1361+
begin
1362+
IniFile := TIniFile.Create(Filename.ToNative);
1363+
1364+
for I := 1 to IMaxPlayerCount do
1365+
IniFile.WriteInteger('PlayerLevel', 'P' + IntToStr(I), PlayerLevel[I-1]);
1366+
1367+
IniFile.Free;
13531368
end;
13541369
end;
13551370

@@ -1401,6 +1416,21 @@ procedure TIni.SaveWebcamSettings;
14011416

14021417
end;
14031418

1419+
procedure TIni.SaveNumberOfPlayers;
1420+
var
1421+
IniFile: TIniFile;
1422+
begin
1423+
if not Filename.IsReadOnly() then
1424+
begin
1425+
IniFile := TIniFile.Create(Filename.ToNative);
1426+
1427+
// Players
1428+
IniFile.WriteString('Game', 'Players', IPlayers[Players]);
1429+
1430+
IniFile.Free;
1431+
end;
1432+
end;
1433+
14041434
procedure TIni.SaveSingTimebarMode;
14051435
var
14061436
IniFile: TIniFile;

src/base/UMain.pas

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,14 @@ procedure Main;
175175
USongs.CatSongs := TCatSongs.Create();
176176
USongs.Songs := TSongs.Create(); //in a new thread
177177

178+
// Theme
178179
UThemes.Theme.LoadTheme(Ini.Theme, Ini.Color);
180+
181+
//avatars cache
182+
UAvatars.Avatars := TAvatarDatabase.Create();
183+
184+
// Graphics
179185
UGraphic.Initialize3D(WindowTitle);
180-
UAvatars.SetAvatarsList();
181186

182187
UMusic.InitializeSound();
183188
UMusic.InitializeVideo();

src/screens/UScreenPartyPlayer.pas

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,13 @@ procedure TScreenPartyPlayer.UpdateParty;
168168
Party.AddPlayer(I, Button[I * 5 + 1 + J].Text[0].Text);
169169

170170
// no avatar on Party
171-
UAvatars.GetAvatarsList().LoadConfig(true);
171+
AvatarPlayerTextures[I + 1] := NoAvatarTexture[I + 1];
172+
173+
Col := GetPlayerColor(Num[I]);
174+
175+
AvatarPlayerTextures[I + 1].ColR := Col.R;
176+
AvatarPlayerTextures[I + 1].ColG := Col.G;
177+
AvatarPlayerTextures[I + 1].ColB := Col.B;
172178
end;
173179

174180

0 commit comments

Comments
 (0)