DayZ-CommunityFramework
DayZ-CommunityFramework copied to clipboard
Model View ViewModel (MVVM)
Example of MVVM:
Script
class ExpansionPlayerListEntry : CF_Model
{
int Color;
string Name;
string ID;
void ExpansionPlayerListEntry(string name, string id, Widget parent = null)
{
CF.MVVM.Create(this, "DayZExpansion/PlayerList/GUI/layouts/expansion_player_list_entry.layout", parent);
Name = name;
ID = id;
NotifyPropertyChanged("Name");
NotifyPropertyChanged("ID");
}
void ~ExpansionPlayerListEntry()
{
CF.MVVM.Destroy(this);
}
void OnMouseEnter(CF_MouseEvent evt)
{
Color = ARGB(255, 1, 1, 1);
NotifyPropertyChanged("IconColor");
}
void OnMouseLeave(CF_MouseEvent evt)
{
Color = ARGB(255, 220, 220, 220);
NotifyPropertyChanged("IconColor");
}
};
Layout
GridSpacerWidgetClass ExpansionPlayerListEntry {
scriptclass "CF_GridSpacerWidget"
{
PanelWidgetClass player_entry {
{
ImageWidgetClass player_icon {
scriptclass "CF_ImageWidget"
{
ScriptParamsClass {
Color "Color"
}
}
}
TextWidgetClass player_name {
scriptclass "CF_TextWidget"
{
ScriptParamsClass {
Text "Name"
}
}
}
}
}
}
{
ScriptParamsClass {
Event_MouseEnter "OnMouseEnter"
Event_MouseLeave "OnMouseLeave"
}
}
}
Will resolve #41