Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
mainmenudata.c
Go to the documentation of this file.
2{
3 protected static ref JsonDataNewsList m_NewsData;
4 protected static ref array<ref ModInfo> m_AllMods;
6
8 {
9 if (!m_NewsData)
11
12 return m_NewsData;
13 }
14
16 {
17 if (!m_NewsData)
18 return null;
19
20 if (index > m_NewsData.News.Count() - 1)
21 {
22 ErrorEx(string.Format("Requested news article for index %1 but article count is %2. Index out of bounds!", index, m_NewsData.News.Count()));
23 return null;
24 }
25
26 return m_NewsData.News[index];
27 }
28
29 static void LoadMods()
30 {
31 if (!m_NewsData)
33
34 if (m_AllMods != null)
35 return;
36
38
39 g_Game.GetModInfos(m_AllMods);
40 if (m_AllMods.Count() > 0)
41 {
42 m_AllMods.Remove(m_AllMods.Count() - 1);
43 m_AllMods.Invert();
44 }
45
47
49 }
50
51 static void FilterDLCs(inout array<ref ModInfo> modArray)
52 {
53 if (!m_AllDlcsMap)
55 else
56 m_AllDlcsMap.Clear();
57
58 ModInfo info;
59 int count = modArray.Count();
60 for (int i = count - 1; i >= 0; i--)
61 {
62 info = modArray[i];
63 if (info.GetIsDLC())
64 {
65 string dlcName = info.GetName();
66 dlcName.ToLower();
67 dlcName.Replace("dayz ", "");
68 m_AllDlcsMap.Insert(dlcName, info);
69 }
70 }
71 }
72
73 static void CreateDLCArticles()
74 {
75 if (!m_AllDlcsMap)
76 {
77 ErrorEx("Failed to get DLC map data!", ErrorExSeverity.WARNING);
78 return;
79 }
80
81 if (!m_NewsData)
82 {
83 ErrorEx("Failed to get news data!", ErrorExSeverity.WARNING);
84 return;
85 }
86
87 for (int i = 0; i < m_AllDlcsMap.Count(); i++)
88 {
89 ModInfo info = m_AllDlcsMap.GetElement(i);
90 if (info.GetIsOwned())
91 {
92 continue;
93 }
95
96 dlcArticle.categoryID = NewsCategory.DLCS;
97 dlcArticle.excerpt = info.GetOverview();
98 dlcArticle.title = info.GetName();
99 dlcArticle.fullUrl = info.GetAction();
100 string dlcName = info.GetName();
101 dlcName.ToLower();
102 dlcName.Replace("dayz ", "");
103 dlcArticle.dlcName = dlcName;
104 dlcArticle.coverImage = ModInfo.GetDLCImage(dlcName);
105 m_NewsData.News.Insert(dlcArticle);
106 }
107
109 JsonDataNewsArticle tempDLCArticle = new JsonDataNewsArticle;
110 tempDLCArticle.categoryID = NewsCategory.DLC_PROMO;
111 tempDLCArticle.title = "#dlc_news_badlands";
112 #ifdef PLATFORM_WINDOWS
113 tempDLCArticle.fullUrl = "https://store.steampowered.com/app/3816030";
114 #else
115 tempDLCArticle.fullUrl = "";
116 #endif
117 tempDLCArticle.dlcName = "badlands";
118 tempDLCArticle.coverImage = ModInfo.GetDLCImage(tempDLCArticle.dlcName);
119 m_NewsData.News.Insert(tempDLCArticle);
120 }
121
122 static void ClearAllDLCs()
123 {
124 m_AllMods = null;
125 m_AllDlcsMap = null;
126 m_NewsData = null;
127 }
128
130 static ModInfo GetDLCModInfoByName(string dlcName)
131 {
132 ModInfo modInfo;
133 m_AllDlcsMap.Find(dlcName, modInfo);
134 return modInfo;
135 }
136
139 {
140 return m_AllMods;
141 }
142}
string coverImage
int categoryID
string excerpt
string title
string fullUrl
string dlcName
static array< ref ModInfo > GetAllMods()
All mods including DLCs.
static JsonDataNewsList GetNewsData()
Definition mainmenudata.c:7
static JsonDataNewsArticle GetNewsArticle(int index)
static ref array< ref ModInfo > m_AllMods
Definition mainmenudata.c:4
static ModInfo GetDLCModInfoByName(string dlcName)
DLCs only.
static void CreateDLCArticles()
static ref JsonDataNewsList m_NewsData
Definition mainmenudata.c:3
static void FilterDLCs(inout array< ref ModInfo > modArray)
static void LoadMods()
static ref map< string, ref ModInfo > m_AllDlcsMap
Definition mainmenudata.c:5
static void ClearAllDLCs()
static string GetDLCImage(string name)
Definition modinfo.c:24
proto owned string GetOverview()
proto owned string GetName()
proto bool GetIsDLC()
proto bool GetIsOwned()
proto owned string GetAction()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZGame g_Game
Definition dayzgame.c:3942
ErrorExSeverity
Definition endebug.c:62
enum ShapeType ErrorEx
proto int Replace(string sample, string replace)
Replace all occurrances of 'sample' in 'str' by 'replace'.
proto int ToLower()
Changes string to lowercase.
NewsCategory
Definition newscarousel.c:2