diff options
-rw-r--r-- | game/themes/Classic.ini | 1 | ||||
-rw-r--r-- | src/base/UIni.pas | 17 |
2 files changed, 16 insertions, 2 deletions
diff --git a/game/themes/Classic.ini b/game/themes/Classic.ini index 1ea83f5e..f317e55e 100644 --- a/game/themes/Classic.ini +++ b/game/themes/Classic.ini @@ -5,7 +5,6 @@ [Theme] Name=Classic -US_Version=USD 101 [Colors] White = 255 255 255 diff --git a/src/base/UIni.pas b/src/base/UIni.pas index 6f875e50..6e86c558 100644 --- a/src/base/UIni.pas +++ b/src/base/UIni.pas @@ -721,6 +721,7 @@ var SearchResult: TSearchRec; ThemeIni: TMemIniFile; ThemeName: string; + ThemeVersion: string; I: integer; Iter: IFileIterator; FileInfo: TFileInfo; @@ -737,10 +738,18 @@ begin Log.LogStatus('Found Theme: ' + FileInfo.Name.ToNative, 'Theme'); //Read Themename from Theme - ThemeIni := TMemIniFile.Create(FileInfo.Name.ToNative); + ThemeIni := TMemIniFile.Create(ThemePath.Append(FileInfo.Name).ToNative); ThemeName := UpperCase(ThemeIni.ReadString('Theme','Name', FileInfo.Name.SetExtension('').ToNative)); + ThemeVersion := Trim(UpperCase(ThemeIni.ReadString('Theme','US_Version', 'no version tag'))); ThemeIni.Free; + // don't load theme with wrong version tag + if ThemeVersion <> 'USD 110' then + begin + Log.LogWarn('Wrong Version (' + ThemeVersion + ') in Theme : ' + ThemeName, 'Theme'); + Continue; + end; + //Search for Skins for this Theme for I := Low(Skin.Skin) to High(Skin.Skin) do begin @@ -767,6 +776,12 @@ begin Skin.onThemeChange; SkinNo := GetArrayIndex(ISkin, IniFile.ReadString('Themes', 'Skin', ISkin[0])); + + { there may be a not existing skin in the ini file + e.g. due to manual edit or corrupted file. + in this case we load the first Skin } + if SkinNo = -1 then + SkinNo := 0; end; procedure TIni.LoadScreenModes(IniFile: TCustomIniFile); |