add messages of the day

This commit is contained in:
GenZmeY 2022-09-08 22:17:55 +03:00
parent f05e1dcca4
commit ee0f203f3a
4 changed files with 99 additions and 12 deletions

View File

@ -0,0 +1,37 @@
class MessageOfTheDay extends Object
config(YAS);
var public config bool bRandomize;
var public config int DisplayTime;
var public config Array<String> Message;
public static function InitConfig(int Version, int LatestVersion)
{
switch (Version)
{
case `NO_CONFIG:
ApplyDefault();
default: break;
}
if (LatestVersion != Version)
{
StaticSaveConfig();
}
}
private static function ApplyDefault()
{
default.DisplayTime = 30;
default.bRandomize = true;
default.Message.Length = 0;
default.Message.AddItem("UwU");
default.Message.AddItem("OwO");
}
defaultproperties
{
}

View File

@ -3,8 +3,9 @@ class YAS extends Info
const LatestVersion = 1;
const CfgRanks = class'Ranks';
const CfgRankRelations = class'RankRelations';
const CfgRanks = class'Ranks';
const CfgRankRelations = class'RankRelations';
const CfgMessageOfTheDay = class'MessageOfTheDay';
const UpdateInterval = 1.0f;
@ -14,7 +15,6 @@ const MatchGroupSteamID64 = "10358279";
var private config int Version;
var private config E_LogLevel LogLevel;
var private config String MessageOfTheDay;
var private KFGameInfo KFGI;
var private KFGameInfo_Survival KFGIS;
@ -29,6 +29,8 @@ var private Array<YAS_RepInfo> RepInfos;
var private Array<CachedRankRelation> PlayerRelations;
var private Array<CachedRankRelation> GroupRelations;
var private int LastMessageID;
public simulated function bool SafeDestroy()
{
`Log_Trace();
@ -70,12 +72,12 @@ private function PreInit()
if (Version == `NO_CONFIG)
{
LogLevel = LL_Info;
MessageOfTheDay = "";
SaveConfig();
}
CfgRanks.static.InitConfig(Version, LatestVersion);
CfgRankRelations.static.InitConfig(Version, LatestVersion);
CfgMessageOfTheDay.static.InitConfig(Version, LatestVersion);
switch (Version)
{
@ -256,6 +258,14 @@ private function PostInit()
KFGIE = KFGameInfo_Endless(KFGI);
SetTimer(UpdateInterval, true, nameof(UpdateTimer));
`Log_Base("MessageOfTheDayTimer Length:" @ CfgMessageOfTheDay.default.Message.Length);
if (CfgMessageOfTheDay.default.Message.Length > 0)
{
`Log_Base("init MessageOfTheDayTimer:");
MessageOfTheDayTimer();
SetTimer(CfgMessageOfTheDay.default.DisplayTime, true, nameof(MessageOfTheDayTimer));
}
}
private function UpdateTimer()
@ -271,6 +281,40 @@ private function UpdateTimer()
}
}
private function MessageOfTheDayTimer()
{
local YAS_RepInfo RepInfo;
local int MessageIndex;
if (CfgMessageOfTheDay.default.bRandomize)
{
MessageIndex = Rand(CfgMessageOfTheDay.default.Message.Length);
}
else
{
MessageIndex = LastMessageID + 1;
}
if (MessageIndex == LastMessageID)
{
++MessageIndex;
}
if (MessageIndex >= CfgMessageOfTheDay.default.Message.Length)
{
MessageIndex = 0;
}
`Log_Base("MessageOfTheDayTimer:" @ MessageIndex);
foreach RepInfos(RepInfo)
{
RepInfo.MessageOfTheDay = CfgMessageOfTheDay.default.Message[MessageIndex];
}
LastMessageID = MessageIndex;
}
public function NotifyLogin(Controller C)
{
local YAS_RepInfo RepInfo;
@ -320,7 +364,7 @@ public function YAS_RepInfo CreateRepInfo(Controller C)
OwnerRepInfo.LogLevel = LogLevel;
OwnerRepInfo.RankPlayer = CfgRanks.default.Player;
OwnerRepInfo.RankAdmin = CfgRanks.default.Admin;
OwnerRepInfo.MessageOfTheDay = MessageOfTheDay;
OwnerRepInfo.MessageOfTheDay = CfgMessageOfTheDay.default.Message[LastMessageID];
}
return OwnerRepInfo;

View File

@ -22,10 +22,10 @@ var private int Retries;
replication
{
if (bNetInitial)
LogLevel, RankPlayer, RankAdmin, MessageOfTheDay;
LogLevel, RankPlayer, RankAdmin;
if (bNetDirty)
DynamicServerName, UsesStats, Custom, PasswordRequired;
DynamicServerName, UsesStats, Custom, PasswordRequired, MessageOfTheDay;
}
public simulated function bool SafeDestroy()

View File

@ -1,10 +1,11 @@
class YAS_ScoreBoard extends KFGUI_Page
dependson(YAS_Types);
const HeaderWidthRatio = 0.30f;
const PlayerListWidthRatio = 0.6f;
const PlayerEntryHeightMod = 1.05f;
const ListItems = 16;
const HeaderWidthRatio = 0.30f;
const PlayerListWidthRatio = 0.6f;
const PlayerEntryHeightMod = 1.05f;
const ListItems = 12;
const PlayerEntryFontScalarMod = 1.25f;
/*
const IconRanked = Texture2D'YAS.IconRanked';
@ -125,7 +126,7 @@ function float MinPerkBoxWidth(float FontScalar)
foreach PerkNames(PerkName)
{
Canvas.TextSize(PerkName $ "A", XL, YL, FontScalar, FontScalar);
Canvas.TextSize(PerkName $ "A", XL, YL, FontScalar * PlayerEntryFontScalarMod, FontScalar * PlayerEntryFontScalarMod);
if (XL > MaxWidth) MaxWidth = XL;
}
@ -380,6 +381,10 @@ function DrawMenu()
BoxW = 0;
Canvas.TextSize("0000", BoxW, YL, FontScalar, FontScalar);
HealthWBox = BoxW + BorderSize * 2;
if (HealthWBox < PlayersList.GetItemHeight())
{
HealthWBox = PlayersList.GetItemHeight();
}
PlayerXPos = HealthXPos + HealthWBox + PlayersList.GetItemHeight() + Settings.Style.EdgeSize;
@ -535,6 +540,7 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float
C.Font = Owner.CurrentStyle.PickFont(FontScalar);
FontScalar *= PlayerEntryFontScalarMod;
Canvas.TextSize("ABC", XL, YL, FontScalar, FontScalar);
ShapeHealth = Settings.Style.ShapeStateHealthBoxMidPlayer;