more
This commit is contained in:
31
panorama/layout/custom_game/frames/message/message.js
Normal file
31
panorama/layout/custom_game/frames/message/message.js
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
|
||||
function ShowMessage(msg, duration, params, color) {
|
||||
color = color || "#fff";
|
||||
|
||||
var msgPanel = $.CreatePanel("Panel", $("#Content"), "");
|
||||
msgPanel.AddClass("Message");
|
||||
|
||||
var label = $.CreatePanel("Label", msgPanel, "");
|
||||
|
||||
if (params) {
|
||||
for(var i in params) {
|
||||
var v = params[i];
|
||||
if (typeof v === 'number') {
|
||||
label.SetDialogVariableInt(i, v);
|
||||
} else {
|
||||
label.SetDialogVariable(i, $.Localize(String(v)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
label.html = true;
|
||||
label.text = $.Localize(msg, label).replace(/%%/g,"%");
|
||||
label.style.color = color;
|
||||
|
||||
msgPanel.DeleteAsync(duration);
|
||||
}
|
||||
|
||||
GameEvents.Subscribe("show_message", function (data) {
|
||||
ShowMessage(data.msg, data.duration || 5, data.params, data.color);
|
||||
})
|
||||
Reference in New Issue
Block a user