<commit_before>using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Assets.Scripts.Content;

public class EditorComponentEventVars : EditorComponent
{
    private readonly StringKey TESTS = new StringKey("val","TESTS");
    private readonly StringKey VAR = new StringKey("val", "VAR");
    private readonly StringKey OP = new StringKey("val", "OP");
    private readonly StringKey VALUE = new StringKey("val", "VALUE");
    private readonly StringKey ASSIGN = new StringKey("val", "ASSIGN");
    private readonly StringKey VAR_NAME = new StringKey("val", "VAR_NAME");
    private readonly StringKey NUMBER = new StringKey("val", "NUMBER");

    QuestData.Event eventComponent;
    EditorSelectionList varESL;
    QuestEditorTextEdit varText;


    public EditorComponentEventVars(string nameIn) : base()
    {
        Game game = Game.Get();
        eventComponent = game.quest.qd.components[nameIn] as QuestData.Event;
        component = eventComponent;
        name = component.sectionName;
        Update();
    }
    
    override public void Update()
    {
        base.Update();
        if (eventComponent.locationSpecified)
        {
            CameraController.SetCamera(eventComponent.location);
        }
        Game game = Game.Get();

        string type = QuestData.Event.type;
        if (eventComponent is QuestData.Door)
        {
            type = QuestData.Door.type;
        }
        if (eventComponent is QuestData.Spawn)
        {
            type = QuestData.Spawn.type;
        }
        if (eventComponent is QuestData.Token)
        {
            type = QuestData.Token.type;
        }

        TextButton tb = new TextButton(new Vector2(0, 0), new Vector2(4, 1), 
            new StringKey(type,false), delegate { QuestEditorData.TypeSelect(); });
        tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
        tb.button.GetComponent<UnityEngine.UI.Text>().alignment = TextAnchor.MiddleRight;
        tb.ApplyTag("editor");

        tb = new TextButton(new Vector2(4, 0), new Vector2(15, 1),
            new StringKey(name.Substring(type.Length),false), delegate { QuestEditorData.ListEvent(); });
        tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
        tb.button.GetComponent<UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft;
        tb.ApplyTag("editor");

        tb = new TextButton(new Vector2(19, 0), new Vector2(1, 1), CommonStringKeys.E, delegate { Rename(); });
        tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
        tb.ApplyTag("editor");
        
        float offset = 2;
        DialogBox db = new DialogBox(new Vector2(0, offset), new Vector2(19, 1), 
            new StringKey("val","X_COLON",TESTS));
        db.ApplyTag("editor");

        tb = new TextButton(new Vector2(19, offset), new Vector2(1, 1), 
            CommonStringKeys.PLUS, delegate { AddTestOp(); }, Color.green);
        tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
        tb.ApplyTag("editor");

        offset++;
        foreach (QuestData.Event.VarOperation op in eventComponent.conditions)
        {
            QuestData.Event.VarOperation tmp = op;
            db = new DialogBox(new Vector2(0, offset), new Vector2(9, 1),
                new StringKey(op.var,false));
            db.AddBorder();
            db.ApplyTag("editor");
            tb = new TextButton(new Vector2(9, offset), new Vector2(2, 1),
                new StringKey(op.operation, false), delegate { SetTestOpp(tmp); });
            tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
            tb.ApplyTag("editor");
            tb = new TextButton(new Vector2(11, offset), new Vector2(8, 1),
                new StringKey(op.value, false), delegate { SetValue(tmp); });
            tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
            tb.ApplyTag("editor");
            tb = new TextButton(new Vector2(19, offset), new Vector2(1, 1), 
                CommonStringKeys.MINUS, delegate { RemoveOp(tmp); }, Color.red);
            tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
            tb.ApplyTag("editor");
            offset++;
        }

        offset++;
        db = new DialogBox(new Vector2(0, offset), new Vector2(19, 1),
            new StringKey("val","X_COLON",ASSIGN));
        db.ApplyTag("editor");

        tb = new TextButton(new Vector2(19, offset), new Vector2(1, 1), 
            CommonStringKeys.PLUS, delegate { AddAssignOp(); }, Color.green);
        tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
        tb.ApplyTag("editor");

        offset++;
        foreach (QuestData.Event.VarOperation op in eventComponent.operations)
        {
            QuestData.Event.VarOperation tmp = op;
            db = new DialogBox(new Vector2(0, offset), new Vector2(9, 1),
                new StringKey(op.var,false));
            db.AddBorder();
            db.ApplyTag("editor");
            tb = new TextButton(new Vector2(9, offset), new Vector2(2, 1),
                new StringKey(op.operation, false), delegate { SetAssignOpp(tmp); });
            tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
            tb.ApplyTag("editor");
            tb = new TextButton(new Vector2(11, offset), new Vector2(8, 1),
                new StringKey(op.value, false), delegate { SetValue(tmp); });
            tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
            tb.ApplyTag("editor");
            tb = new TextButton(new Vector2(19, offset), new Vector2(1, 1), 
                CommonStringKeys.MINUS, delegate { RemoveOp(tmp); }, Color.red);
            tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
            tb.ApplyTag("editor");
            offset++;
        }

        if (eventComponent.locationSpecified)
        {
            game.tokenBoard.AddHighlight(eventComponent.location, "EventLoc", "editor");
        }
    }

    public void AddTestOp()
    {
        List<EditorSelectionList.SelectionListEntry> list = new List<EditorSelectionList.SelectionListEntry>();
        list.Add(new EditorSelectionList.SelectionListEntry("{NEW}"));
        foreach (string s in GetQuestVars())
        {
            list.Add(new EditorSelectionList.SelectionListEntry(s));
        }
        varESL = new EditorSelectionList(new StringKey("val", "SELECT", VAR), list, delegate { SelectAddOp(); });
        varESL.SelectItem();
    }

    public void AddAssignOp()
    {
        List<EditorSelectionList.SelectionListEntry> list = new List<EditorSelectionList.SelectionListEntry>();
        list.Add(new EditorSelectionList.SelectionListEntry("{NEW}", "Quest"));
        foreach (string s in GetQuestVars())
        {
            list.Add(new EditorSelectionList.SelectionListEntry(s, "Quest"));
        }

        list.Add(new EditorSelectionList.SelectionListEntry("#monsters", "Valkyrie"));
        list.Add(new EditorSelectionList.SelectionListEntry("#heroes", "Valkyrie"));
        list.Add(new EditorSelectionList.SelectionListEntry("#round", "Valkyrie"));
        list.Add(new EditorSelectionList.SelectionListEntry("#fire", "Valkyrie"));
        list.Add(new EditorSelectionList.SelectionListEntry("#eliminated", "Valkyrie"));
        foreach (ContentData.ContentPack pack in Game.Get().cd.allPacks)
        {
            if (pack.id.Length > 0)
            {
                list.Add(new EditorSelectionList.SelectionListEntry("#" + pack.id, "Valkyrie"));
            }
        }
        varESL = new EditorSelectionList(new StringKey("val", "SELECT", VAR), list, delegate { SelectAddOp(false); });
        varESL.SelectItem();
    }

    public HashSet<string> GetQuestVars()
    {
        HashSet<string> vars = new HashSet<string>();

        Game game = Game.Get();
        foreach (KeyValuePair<string, QuestData.QuestComponent> kv in game.quest.qd.components)
        {
            if (kv.Value is QuestData.Event)
            {
                QuestData.Event e = kv.Value as QuestData.Event;
                foreach (QuestData.Event.VarOperation op in e.operations)
                {<commit_msg>#206 valkyrie vars under assign rather than test in editor.<commit_after>using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Assets.Scripts.Content;

public class EditorComponentEventVars : EditorComponent
{
    private readonly StringKey TESTS = new StringKey("val","TESTS");
    private readonly StringKey VAR = new StringKey("val", "VAR");
    private readonly StringKey OP = new StringKey("val", "OP");
    private readonly StringKey VALUE = new StringKey("val", "VALUE");
    private readonly StringKey ASSIGN = new StringKey("val", "ASSIGN");
    private readonly StringKey VAR_NAME = new StringKey("val", "VAR_NAME");
    private readonly StringKey NUMBER = new StringKey("val", "NUMBER");

    QuestData.Event eventComponent;
    EditorSelectionList varESL;
    QuestEditorTextEdit varText;


    public EditorComponentEventVars(string nameIn) : base()
    {
        Game game = Game.Get();
        eventComponent = game.quest.qd.components[nameIn] as QuestData.Event;
        component = eventComponent;
        name = component.sectionName;
        Update();
    }
    
    override public void Update()
    {
        base.Update();
        if (eventComponent.locationSpecified)
        {
            CameraController.SetCamera(eventComponent.location);
        }
        Game game = Game.Get();

        string type = QuestData.Event.type;
        if (eventComponent is QuestData.Door)
        {
            type = QuestData.Door.type;
        }
        if (eventComponent is QuestData.Spawn)
        {
            type = QuestData.Spawn.type;
        }
        if (eventComponent is QuestData.Token)
        {
            type = QuestData.Token.type;
        }

        TextButton tb = new TextButton(new Vector2(0, 0), new Vector2(4, 1), 
            new StringKey(type,false), delegate { QuestEditorData.TypeSelect(); });
        tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
        tb.button.GetComponent<UnityEngine.UI.Text>().alignment = TextAnchor.MiddleRight;
        tb.ApplyTag("editor");

        tb = new TextButton(new Vector2(4, 0), new Vector2(15, 1),
            new StringKey(name.Substring(type.Length),false), delegate { QuestEditorData.ListEvent(); });
        tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
        tb.button.GetComponent<UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft;
        tb.ApplyTag("editor");

        tb = new TextButton(new Vector2(19, 0), new Vector2(1, 1), CommonStringKeys.E, delegate { Rename(); });
        tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
        tb.ApplyTag("editor");
        
        float offset = 2;
        DialogBox db = new DialogBox(new Vector2(0, offset), new Vector2(19, 1), 
            new StringKey("val","X_COLON",TESTS));
        db.ApplyTag("editor");

        tb = new TextButton(new Vector2(19, offset), new Vector2(1, 1), 
            CommonStringKeys.PLUS, delegate { AddTestOp(); }, Color.green);
        tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
        tb.ApplyTag("editor");

        offset++;
        foreach (QuestData.Event.VarOperation op in eventComponent.conditions)
        {
            QuestData.Event.VarOperation tmp = op;
            db = new DialogBox(new Vector2(0, offset), new Vector2(9, 1),
                new StringKey(op.var,false));
            db.AddBorder();
            db.ApplyTag("editor");
            tb = new TextButton(new Vector2(9, offset), new Vector2(2, 1),
                new StringKey(op.operation, false), delegate { SetTestOpp(tmp); });
            tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
            tb.ApplyTag("editor");
            tb = new TextButton(new Vector2(11, offset), new Vector2(8, 1),
                new StringKey(op.value, false), delegate { SetValue(tmp); });
            tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
            tb.ApplyTag("editor");
            tb = new TextButton(new Vector2(19, offset), new Vector2(1, 1), 
                CommonStringKeys.MINUS, delegate { RemoveOp(tmp); }, Color.red);
            tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
            tb.ApplyTag("editor");
            offset++;
        }

        offset++;
        db = new DialogBox(new Vector2(0, offset), new Vector2(19, 1),
            new StringKey("val","X_COLON",ASSIGN));
        db.ApplyTag("editor");

        tb = new TextButton(new Vector2(19, offset), new Vector2(1, 1), 
            CommonStringKeys.PLUS, delegate { AddAssignOp(); }, Color.green);
        tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
        tb.ApplyTag("editor");

        offset++;
        foreach (QuestData.Event.VarOperation op in eventComponent.operations)
        {
            QuestData.Event.VarOperation tmp = op;
            db = new DialogBox(new Vector2(0, offset), new Vector2(9, 1),
                new StringKey(op.var,false));
            db.AddBorder();
            db.ApplyTag("editor");
            tb = new TextButton(new Vector2(9, offset), new Vector2(2, 1),
                new StringKey(op.operation, false), delegate { SetAssignOpp(tmp); });
            tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
            tb.ApplyTag("editor");
            tb = new TextButton(new Vector2(11, offset), new Vector2(8, 1),
                new StringKey(op.value, false), delegate { SetValue(tmp); });
            tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
            tb.ApplyTag("editor");
            tb = new TextButton(new Vector2(19, offset), new Vector2(1, 1), 
                CommonStringKeys.MINUS, delegate { RemoveOp(tmp); }, Color.red);
            tb.button.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
            tb.ApplyTag("editor");
            offset++;
        }

        if (eventComponent.locationSpecified)
        {
            game.tokenBoard.AddHighlight(eventComponent.location, "EventLoc", "editor");
        }
    }

    public void AddTestOp()
    {
        List<EditorSelectionList.SelectionListEntry> list = new List<EditorSelectionList.SelectionListEntry>();
        list.Add(new EditorSelectionList.SelectionListEntry("{NEW}", "Quest"));
        foreach (string s in GetQuestVars())
        {
            list.Add(new EditorSelectionList.SelectionListEntry(s, "Quest"));
        }

        list.Add(new EditorSelectionList.SelectionListEntry("#monsters", "Valkyrie"));
        list.Add(new EditorSelectionList.SelectionListEntry("#heroes", "Valkyrie"));
        list.Add(new EditorSelectionList.SelectionListEntry("#round", "Valkyrie"));
        list.Add(new EditorSelectionList.SelectionListEntry("#fire", "Valkyrie"));
        list.Add(new EditorSelectionList.SelectionListEntry("#eliminated", "Valkyrie"));
        foreach (ContentData.ContentPack pack in Game.Get().cd.allPacks)
        {
            if (pack.id.Length > 0)
            {
                list.Add(new EditorSelectionList.SelectionListEntry("#" + pack.id, "Valkyrie"));
            }
        }

        varESL = new EditorSelectionList(new StringKey("val", "SELECT", VAR), list, delegate { SelectAddOp(); });
        varESL.SelectItem();
    }

    public void AddAssignOp()
    {
        List<EditorSelectionList.SelectionListEntry> list = new List<EditorSelectionList.SelectionListEntry>();
        list.Add(new EditorSelectionList.SelectionListEntry("{NEW}"));
        foreach (string s in GetQuestVars())
        {
            list.Add(new EditorSelectionList.SelectionListEntry(s));
        }
        varESL = new EditorSelectionList(new StringKey("val", "SELECT", VAR), list, delegate { SelectAddOp(false); });
        varESL.SelectItem();
    }

    public HashSet<string> GetQuestVars()
    {
        HashSet<string> vars = new HashSet<string>();

        Game game = Game.Get();
        foreach (KeyValuePair<string, QuestData.QuestComponent> kv in game.quest.qd.components)
        {
            if (kv.Value is QuestData.Event)
            {
                QuestData.Event e = kv.Value as QuestData.Event;
                foreach (QuestData.Event.VarOperation op in e.operations)
                {
{'fraction_non_alphanumeric': 0.12830143683300543, 'fraction_numerical': 0.010910391700947953, 'mean_word_length': 2.6166451056489866, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3397393', 'n_tokens_mistral': 4791, 'n_tokens_neox': 4680, 'n_words': 957}