Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model View ViewModel (MVVM) #56

Draft
wants to merge 210 commits into
base: development
Choose a base branch
from
Draft

Model View ViewModel (MVVM) #56

wants to merge 210 commits into from

Conversation

Jacob-Mango
Copy link
Collaborator

No description provided.

@Jacob-Mango Jacob-Mango marked this pull request as draft June 16, 2021 18:35
@Jacob-Mango
Copy link
Collaborator Author

Jacob-Mango commented Jun 16, 2021

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"
  }
 }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants