Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_LocalizationPlugins.c
Go to the documentation of this file.
1#ifdef WORKBENCH
2[WorkbenchPluginAttribute(name: "Modified Localisation Plugin", wbModules: { "LocalizationEditor" }, awesomeFontCode: 0xF246)]
3class SCR_LocModifiedPlugin : LocalizationEditorPlugin
4{
5 [Attribute(category: "Authorship")]
6 protected string UserName;
7
8 //------------------------------------------------------------------------------------------------
9 protected string GetUserName()
10 {
11 if (UserName.IsEmpty())
12 Workbench.GetUserName(UserName);
13
14 return UserName;
15 }
16
17 //------------------------------------------------------------------------------------------------
18 override void Configure()
19 {
20 Workbench.ScriptDialog("Configure Modified Localisation Plugin", "", this);
21 }
22
23 //------------------------------------------------------------------------------------------------
24 [ButtonAttribute("OK")]
25 void OkButton()
26 {
27 }
28
29 //------------------------------------------------------------------------------------------------
30 override void OnChange(BaseContainer stringTableItem, string propName, string propValue)
31 {
32 LocalizationEditor editor = Workbench.GetModule(LocalizationEditor);
33 editor.ModifyProperty(stringTableItem, stringTableItem.GetVarIndex("Modified"), Workbench.GetPackedUtcTime().ToString());
34
35 string userName = GetUserName();
36
37 if (propName == "Id")
38 editor.ModifyProperty(stringTableItem, stringTableItem.GetVarIndex("Author"), userName);
39
40 editor.ModifyProperty(stringTableItem, stringTableItem.GetVarIndex("LastChanged"), userName);
41 }
42
43 //------------------------------------------------------------------------------------------------
44 override void OnImport(BaseContainer newItem, BaseContainer oldItem)
45 {
46 newItem.Set("Modified", Workbench.GetPackedUtcTime());
47
48 string userName = GetUserName();
49
50 if (oldItem)
51 newItem.Set("LastChanged", userName);
52 else
53 newItem.Set("Author", userName);
54 }
55}
56
57[WorkbenchPluginAttribute(name: "LocExportPlugin", wbModules: {"LocalizationEditor"})]
58class SCR_LocExportPlugin : LocalizationEditorPlugin
59{
60 //------------------------------------------------------------------------------------------------
61 override string GetExportColumn(BaseContainer item, string languageCode)
62 {
63#ifndef LOCALIZATION_BUILD_HIDDEN
64 bool hidden = false;
65 item.Get("Hidden", hidden);
66
67 if (hidden)
68 return string.Empty; // do not export this item
69#endif
70 if (languageCode == "en_us")
71 {
72 string edited;
73 item.Get("Target_en_us_edited", edited);
74
75 if (!edited.IsEmpty())
76 return "Target_en_us_edited";
77 }
78 else
79 {
80 string translation;
81 item.Get("Target_"+languageCode, translation);
82 if (translation.IsEmpty())
83 return "Target_en_us";
84 }
85
86 return "Target_" + languageCode;
87 }
88}
89
90/*
91[WorkbenchPluginAttribute(name: "LocTestPlugin", wbModules: {"LocalizationEditor"})]
92class SCR_LocTestPlugin : LocalizationEditorPlugin
93{
94 //------------------------------------------------------------------------------------------------
95 override void Run()
96 {
97 LocalizationEditor editor = Workbench.GetModule(LocalizationEditor);
98 editor.AddUserFilter({ 1, 2, 3, 4, 5 }, "Test");
99 }
100}
101*/
102
103[WorkbenchPluginAttribute(name: "Check length", wbModules: { "LocalizationEditor" })]
104class SCR_LocLengthPlugin : LocalizationEditorPlugin
105{
106 //------------------------------------------------------------------------------------------------
107 override void Run()
108 {
109 LocalizationEditor editor = Workbench.GetModule(LocalizationEditor);
110 BaseContainer stringTableSrc = editor.GetTable();
111 if (!stringTableSrc)
112 return;
113
114 array<int> indices = {};
115 array<string> targets;
116// string id;
117 BaseContainerList rows = stringTableSrc.GetObjectArray("Items");
118 BaseContainer row;
119
120 for (int iRow, count = rows.Count(); iRow < count; iRow++)
121 {
122 row = rows[iRow];
123
124 if (!targets)
125 {
126 targets = new array<string>;
127 for (int iCol; iCol < row.GetNumVars(); iCol++)
128 {
129 string colName = row.GetVarName(iCol);
130 if (colName.Contains("Target_"))
131 targets.Insert(colName);
132 }
133 }
134
135 string ID;
136 row.Get("Id", ID);
137
138 foreach (string targetCol : targets)
139 {
140 int maxLength;
141 row.Get("MaxLength", maxLength);
142
143 if (maxLength > 0)
144 {
145 string targetText;
146 row.Get(targetCol, targetText);
147
148 if (targetText.Length() > maxLength)
149 {
150 indices.Insert(iRow);
151 Print(string.Format("LocLengthPlugin: ID: '%1', %2: '%3' is too long (%4/%5)", ID, targetCol, targetText, targetText.Length(), maxLength), LogLevel.NORMAL);
152 }
153 }
154 }
155 }
156
157 if (!indices.IsEmpty())
158 editor.AddUserFilter(indices, "Long texts");
159 }
160}
161#endif // WORKBENCH
GenerateFlowMaps WorkbenchPlugin WorkbenchPluginAttribute("Regenerate river flow-maps", "Generate and save/overwrite river flow-maps", "", "", {"WorldEditor"}, "", 0xf773)
Definition FlowmapTool.c:59
override void Run()
override void Configure()
class WorkbenchDialog_AbortRetryIgnore ButtonAttribute("OK", true)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute
@ ID
Ordered by Group application ID.